From 3042cbc1576d1f3c19e7dfed840dabea184986c0 Mon Sep 17 00:00:00 2001 From: melkeydev Date: Tue, 11 Aug 2026 11:07:38 -0700 Subject: [PATCH] adding better detection for kimi and grok --- .changeset/quiet-agents-detect.md | 5 +++++ README.md | 2 ++ agents.json | 21 +++++++++++++++++++++ detect_test.go | 4 +++- src/determine-agent.test.ts | 4 ++++ testcases.json | 28 ++++++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .changeset/quiet-agents-detect.md diff --git a/.changeset/quiet-agents-detect.md b/.changeset/quiet-agents-detect.md new file mode 100644 index 0000000..069d055 --- /dev/null +++ b/.changeset/quiet-agents-detect.md @@ -0,0 +1,5 @@ +--- +'detect-agent': minor +--- + +Add detection for Kimi Code and Grok Build plugin hooks. diff --git a/README.md b/README.md index c4ce36e..68f8bc2 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/agents.json b/agents.json index 6bff064..f5f8f11 100644 --- a/agents.json +++ b/agents.json @@ -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", diff --git a/detect_test.go b/detect_test.go index 0c17efd..0479e27 100644 --- a/detect_test.go +++ b/detect_test.go @@ -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", diff --git a/src/determine-agent.test.ts b/src/determine-agent.test.ts index 5ee1173..9eb469b 100644 --- a/src/determine-agent.test.ts +++ b/src/determine-agent.test.ts @@ -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', diff --git a/testcases.json b/testcases.json index 7608f63..2d59e29 100644 --- a/testcases.json +++ b/testcases.json @@ -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" },