Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-agents-detect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'detect-agent': minor
---

Add detection for Kimi Code and Grok Build plugin hooks.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ This package can detect the following AI agents and development environments:
- **Cursor** (Anysphere)
- **Claude Code** (Anthropic)
- **Claude Cowork** (Anthropic)
- **Kimi Code** (Moonshot AI)
- **Grok Build** (xAI)
- **Devin** (Cognition Labs)
- **Gemini CLI** (Google)
- **Codex** (OpenAI)
Expand Down
21 changes: 21 additions & 0 deletions agents.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@
]
}
},
{
"key": "KIMI",
"name": "kimi",
"description": "Kimi Code plugin hooks. KIMI_CODE_HOME may be configured outside an active Kimi session, so detection uses the plugin-scoped KIMI_PLUGIN_ROOT marker.",
"match": {
"type": "anyOf",
"conditions": [{ "type": "env_set", "name": "KIMI_PLUGIN_ROOT" }]
}
},
{
"key": "GROK",
"name": "grok",
"description": "Grok Build plugin hooks. Evaluated before Claude Code because Grok supports Claude Code plugins and may expose compatibility markers.",
"match": {
"type": "anyOf",
"conditions": [
{ "type": "env_set", "name": "GROK_PLUGIN_ROOT" },
{ "type": "env_set", "name": "GROK_PLUGIN_DATA" }
]
}
},
{
"key": "GEMINI",
"name": "gemini_cli",
Expand Down
4 changes: 3 additions & 1 deletion detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ func clearAgentEnvs(t *testing.T) {
for _, v := range []string{
"AI_AGENT",
"CURSOR_TRACE_ID", "CURSOR_AGENT", "CURSOR_EXTENSION_HOST_ROLE",
"KIMI_PLUGIN_ROOT",
"GROK_PLUGIN_ROOT", "GROK_PLUGIN_DATA",
"GEMINI_CLI",
"CODEX_SANDBOX", "CODEX_CI", "CODEX_THREAD_ID",
"CODEX_SANDBOX", "CODEX_CI", "CODEX_THREAD_ID", "CODEX_SANDBOX_NETWORK_DISABLED",
"ANTIGRAVITY_AGENT",
"AUGMENT_AGENT",
"OPENCODE_CLIENT", "OPENCODE",
Expand Down
4 changes: 4 additions & 0 deletions src/determine-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ const ALL_AGENT_ENVS = [
'CURSOR_TRACE_ID',
'CURSOR_AGENT',
'CURSOR_EXTENSION_HOST_ROLE',
'KIMI_PLUGIN_ROOT',
'GROK_PLUGIN_ROOT',
'GROK_PLUGIN_DATA',
'GEMINI_CLI',
'CODEX_SANDBOX',
'CODEX_CI',
'CODEX_THREAD_ID',
'CODEX_SANDBOX_NETWORK_DISABLED',
'ANTIGRAVITY_AGENT',
'AUGMENT_AGENT',
'OPENCODE_CLIENT',
Expand Down
28 changes: 28 additions & 0 deletions testcases.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,34 @@
"expectedAgentKey": "CURSOR_CLI"
},

{
"name": "detects kimi from KIMI_PLUGIN_ROOT",
"env": { "KIMI_PLUGIN_ROOT": "/tmp/kimi-plugin" },
"expectedIsAgent": true,
"expectedAgentKey": "KIMI"
},
{
"name": "does not detect kimi from KIMI_CODE_HOME alone",
"env": { "KIMI_CODE_HOME": "/tmp/kimi" },
"expectedIsAgent": false
},

{
"name": "detects grok from GROK_PLUGIN_ROOT",
"env": { "GROK_PLUGIN_ROOT": "/tmp/grok-plugin" },
"expectedIsAgent": true,
"expectedAgentKey": "GROK"
},
{
"name": "detects grok from GROK_PLUGIN_DATA before Claude compatibility markers",
"env": {
"GROK_PLUGIN_DATA": "/tmp/grok-data",
"CLAUDE_CODE": "1"
},
"expectedIsAgent": true,
"expectedAgentKey": "GROK"
},

{
"name": "detects gemini_cli from GEMINI_CLI",
"env": { "GEMINI_CLI": "1" },
Expand Down
Loading