From faf1f4c001892106400363e693308b7da785cbe0 Mon Sep 17 00:00:00 2001 From: David Mokos Date: Mon, 24 Aug 2026 23:27:05 +0200 Subject: [PATCH 1/2] adds Grok environment detection --- README.md | 4 +++- src/agents.ts | 9 +++++++++ src/types.ts | 1 + test/detector.test.mjs | 16 ++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index daa86c1..c4fb0dc 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Officially supported coding agents: | [Devin](https://devin.ai/) | `devin` | 🚫 | | [Gemini CLI](https://github.com/google-gemini/gemini-cli) | `gemini` | 🚫 | | [GitHub Copilot CLI](https://github.com/github/copilot-cli) | `copilot` | ✅ | +| [Grok](https://x.ai/build) | `grok` | ✅ | | [Kilo Code](https://kilocode.ai/) | `kilocode` | ✅ | | [Kiro](https://kiro.dev/) | `kiro` | ✅ | | [Muse Code][muse-code] | `muse` | 🚫 | @@ -101,7 +102,8 @@ A string containing the agent's session identifier, normalized from agent-specific environment variables such as `CODEX_THREAD_ID`, `CURSOR_CONVERSATION_ID`, `CLAUDE_CODE_SESSION_ID`, `ANTIGRAVITY_TRAJECTORY_ID`, `KIRO_SESSION_ID`, `KILO_RUN_ID`, and -`COPILOT_AGENT_SESSION_ID`, and `REPLIT_SESSION`. Omitted when the agent doesn't expose one +`COPILOT_AGENT_SESSION_ID`, `REPLIT_SESSION`, and `GROK_SESSION_ID`. +Omitted when the agent doesn't expose one (see the Session ID column in the support table above). ### `isRunningFromAgent([options])` diff --git a/src/agents.ts b/src/agents.ts index e0e228d..0f2ff37 100644 --- a/src/agents.ts +++ b/src/agents.ts @@ -52,6 +52,15 @@ export const defaultAgents = [ env: [{ name: "GEMINI_CLI", value: "1" }], process: [{ pattern: /^gemini$/i }] }, + { + id: "grok", + name: "Grok", + env: [ + { name: "GROK_AGENT", value: "1" }, + { name: "GROK_SESSION_ID" } + ], + sessionEnv: ["GROK_SESSION_ID"] + }, { id: "antigravity", name: "Antigravity", diff --git a/src/types.ts b/src/types.ts index c69db9a..a9c29fd 100644 --- a/src/types.ts +++ b/src/types.ts @@ -7,6 +7,7 @@ export type AgentId = | "cursor" | "devin" | "gemini" + | "grok" | "kiro" | "kilocode" | "claude-code" diff --git a/test/detector.test.mjs b/test/detector.test.mjs index a09036d..7c0f447 100644 --- a/test/detector.test.mjs +++ b/test/detector.test.mjs @@ -64,6 +64,22 @@ test("detects replit and normalizes its session id", () => { }); }); +test("detects grok and normalizes its session id", () => { + const result = detectAgent({ + env: { + GROK_AGENT: "1", + GROK_SESSION_ID: "01a035a8-166c-7771-8e5e-f67e0dd98c83" + } + }); + + assert.equal(result.detected, true); + assert.deepEqual(result.agent, { + id: "grok", + name: "Grok", + sessionId: "01a035a8-166c-7771-8e5e-f67e0dd98c83" + }); +}); + test("detects rork from RORK_API_URL", () => { const result = detectAgent({ env: { From ed4ee7fce40145c60bd6f258324b9f8a79281921 Mon Sep 17 00:00:00 2001 From: David Mokos Date: Mon, 24 Aug 2026 23:28:59 +0200 Subject: [PATCH 2/2] bumps version to 0.1.7 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 61fbd59..6cd04f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "agent-cli-detector", - "version": "0.1.6", + "version": "0.1.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "agent-cli-detector", - "version": "0.1.6", + "version": "0.1.7", "license": "MIT", "bin": { "agent-cli-detector": "dist/cli.js" diff --git a/package.json b/package.json index 5c50610..d90825b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "agent-cli-detector", - "version": "0.1.6", + "version": "0.1.7", "description": "Detect whether a JavaScript CLI is running inside a coding agent.", "type": "module", "sideEffects": false,