Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

feat(cli): add Grok Build as an install target

Martin Vogel72ee88054fd4
diff --git a/README.md b/README.md
index ca39ef418..b6ffd884b 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@
**The fastest and most efficient code intelligence engine for AI coding agents.** Full-indexes an average repository in milliseconds, the Linux kernel (28M LOC, 75K files) in 3 minutes. Answers structural queries in under 1ms. Ships as a native executable with a small verified runtime-asset set for macOS, Linux, and Windows — download, run `install`, done.
-High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across all 158 languages, enhanced with [**Hybrid LSP** semantic type resolution](#hybrid-lsp) for Python, TypeScript / JavaScript / JSX / TSX, PHP, C#, Go, C, C++, Java, Kotlin, Rust, and Perl — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 15 MCP tools. No language runtime, hosted service, or API key. Plug and play across 43 supported automatic/conditional client surfaces.
+High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across all 158 languages, enhanced with [**Hybrid LSP** semantic type resolution](#hybrid-lsp) for Python, TypeScript / JavaScript / JSX / TSX, PHP, C#, Go, C, C++, Java, Kotlin, Rust, and Perl — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 15 MCP tools. No language runtime, hosted service, or API key. Plug and play across 44 supported automatic/conditional client surfaces.
> **Research** — The design and benchmarks behind this project are described in the preprint [*Codebase-Memory: Tree-Sitter-Based Knowledge Graphs for LLM Code Exploration via MCP*](https://arxiv.org/abs/2603.27277) (arXiv:2603.27277). Evaluated across 31 real-world repositories: 83% answer quality, 10× fewer tokens, 2.1× fewer tool calls vs. file-by-file exploration.
@@ -34,7 +34,7 @@ High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-si
- **Plug and play** — native executable plus authenticated release-owned assets for macOS (arm64/amd64), Linux (arm64/amd64), and Windows (amd64). The native install needs no Docker, language runtime, or API keys. Download → `install` → restart agent → done.
- **158 languages** — vendored tree-sitter grammars compiled into the binary. Nothing to install, nothing that breaks.
- **120x fewer tokens** — 5 structural queries: ~3,400 tokens vs ~412,000 via file-by-file search. One graph query replaces dozens of grep/read cycles.
-- **43 supported automatic/conditional client surfaces** — `install` configures detected clients and safely activates conditional clients only when their documented platform, marker, or explicit existing config path is present. See [Multi-Agent Support](#multi-agent-support) for the complete matrix and manual/UI-only boundaries.
+- **44 supported automatic/conditional client surfaces** — `install` configures detected clients and safely activates conditional clients only when their documented platform, marker, or explicit existing config path is present. See [Multi-Agent Support](#multi-agent-support) for the complete matrix and manual/UI-only boundaries.
- **Built-in graph visualization** — 3D interactive UI at `localhost:9749`, served from the binary itself.
- **Infrastructure-as-code indexing** — Dockerfiles, Kubernetes manifests, and Kustomize overlays indexed as graph nodes with cross-references. `Resource` nodes for K8s kinds, `Module` nodes for Kustomize overlays with `IMPORTS` edges to referenced resources.
- **15 MCP tools** — search, trace, architecture, impact analysis, targeted index-coverage checks, Cypher queries, dead code detection, cross-service HTTP linking, ADR management, and more.
@@ -425,7 +425,7 @@ Restart your agent. Verify with `/mcp` — you should see `codebase-memory-mcp`
## Multi-Agent Support
-`install` configures 43 client surfaces: 37 detected automatically and 6
+`install` configures 44 client surfaces: 38 detected automatically and 6
conditional or explicit. “Conditional” means the installer writes only when the
documented platform or an explicit, already-existing config path proves the
target is active. It never flips experimental feature flags, enables plugins,
@@ -473,6 +473,7 @@ overwrite user-modified agents.
| Crush | Detected | `.config/crush/crush.json` | Managed context path with explicit parent-to-child handoff |
| Goose | Detected | `.config/goose/config.yaml` | `.goosehints` |
| Mistral Vibe | Detected | `$VIBE_HOME/config.toml` | `AGENTS.md`, skill, and three matched agent/prompt pairs with explicit read-only graph-tool allowlists |
+| Grok Build | Detected | `$GROK_HOME/config.toml` | Owned `rules/codebase-memory.md`, skill, three graph agents with named-server `mcpInheritance` and exact `server__tool` dispatcher ids; context hooks withheld because its passive hook events discard stdout |
| Qoder CLI | Detected | `~/.qoder/settings.json` | Skill, three directly MCP-attached agents with named-server scoping and exact per-tier graph-tool lists; `SessionStart`, `SubagentStart`, and post-`Read` coverage, including documented PowerShell execution on Windows |
| Kimi Code CLI | Detected | `$KIMI_CODE_HOME/mcp.json` (default `~/.kimi-code`) | Same-root `AGENTS.md` + skill; fail-open `UserPromptSubmit` hook in `config.toml` |
| GitLab Duo CLI | Detected | `$GLAB_CONFIG_DIR/duo/mcp.json` or platform fallback | Fail-open user `SessionStart` on macOS/Linux; hook withheld on Windows; no experimental global skill enablement |
@@ -521,7 +522,7 @@ carry the contract across fresh sessions and compaction: verify the graph projec
and index freshness, query structural facts in the parent, then pass the project,
qualified symbols, paths, and call-chain evidence in every delegated task.
Claude, Codex, Gemini, Kiro, Qwen, Copilot, CodeBuddy, OpenCode, Kilo, Vibe,
-Qoder, Junie, and Factory receive Scout, Verify, and Auditor graph profiles.
+Qoder, Junie, Factory, and Grok Build receive Scout, Verify, and Auditor graph profiles.
Kiro embeds this MCP server with `--tool-profile scout` for Scout and
`--tool-profile analysis` for Verify/Auditor. Junie registers equivalent named
server aliases because its subagent schema filters by server rather than by
@@ -547,7 +548,12 @@ project or plugin agents before user agents with the same name; reload the
client after installation or profile changes.
Cursor context
hooks are withheld: session context injection has a known race, `subagentStart`
-is control-only, and read-only subagents cannot safely receive MCP access. Rovo
+is control-only, and read-only subagents cannot safely receive MCP access. Grok Build's
+passive hook events (`SessionStart`, `SubagentStart`, `PostToolUse`) discard
+stdout and `PreToolUse` honors only deny/rewrite decisions, so its context hooks
+are withheld; Grok also reads Claude and Cursor MCP, skill, and hook files
+through its compat layer, and the native `config.toml` entry shadows that copy
+by name. Rovo
has no documented session context-output hook, and Bob
documents neither a suitable hook nor a custom-agent surface. Those surfaces are
not approximated with invented augmentation. Kimi plugins, Amp plugins, and
@@ -778,7 +784,7 @@ src/
main.c Entry point (MCP stdio server + CLI + install/update/config)
daemon/ Per-account session coordination, IPC, lifecycle, shared jobs/watchers
mcp/ MCP server (15 tools, JSON-RPC 2.0, session detection, auto-index)
- cli/ Install/uninstall/update/config (43 client surfaces, hooks, instructions)
+ cli/ Install/uninstall/update/config (44 client surfaces, hooks, instructions)
store/ SQLite graph storage (nodes, edges, traversal, search, Louvain)
pipeline/ Multi-pass indexing (structure → definitions → calls → HTTP links → config → tests)
cypher/ Cypher query lexer, parser, planner, executor
diff --git a/docs/index.html b/docs/index.html
index abf053b54..7e4a1c7aa 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>codebase-memory-mcp — Code Intelligence Knowledge Graph for AI Coding Agents</title>
- <meta name="description" content="codebase-memory-mcp is an open-source MCP server that indexes any codebase into a persistent knowledge graph so AI coding agents answer structural questions with ~120x fewer tokens. 158 languages, Hybrid LSP type resolution, local semantic vector search, code-clone detection, sub-1ms queries, Linux kernel indexed in 3 minutes. Native executable with verified assets and no language runtime. One command configures 43 automatic/conditional client surfaces.">
+ <meta name="description" content="codebase-memory-mcp is an open-source MCP server that indexes any codebase into a persistent knowledge graph so AI coding agents answer structural questions with ~120x fewer tokens. 158 languages, Hybrid LSP type resolution, local semantic vector search, code-clone detection, sub-1ms queries, Linux kernel indexed in 3 minutes. Native executable with verified assets and no language runtime. One command configures 44 automatic/conditional client surfaces.">
<meta name="keywords" content="MCP server, code intelligence, knowledge graph, tree-sitter, Hybrid LSP, semantic code search, code embeddings, code clone detection, cross-repo analysis, data-flow analysis, Claude Code, Codex CLI, Gemini CLI, Cursor, Zed, code exploration, token reduction, call graph, dead code detection">
<meta name="author" content="DeusData">
<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
@@ -68,7 +68,7 @@
"Infrastructure-as-code indexing for Dockerfiles, Kubernetes, and Kustomize",
"Built-in 3D graph visualization UI",
"Auto-sync background watcher for incremental re-indexing",
- "One command configures 43 automatic/conditional client surfaces"
+ "One command configures 44 automatic/conditional client surfaces"
],
"author": {
"@type": "Organization",
@@ -157,7 +157,7 @@
"name": "Which AI coding agents work with codebase-memory-mcp?",
"acceptedAnswer": {
"@type": "Answer",
- "text": "A single install command configures 43 automatic/conditional client surfaces. The 37 detected surfaces are Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, Cursor, Windsurf, Augment / Auggie, OpenClaw, Kiro, Junie, Hermes, OpenHands, Cline, Warp, Qwen Code, GitHub Copilot CLI, Factory Droid, Crush, Goose, Mistral Vibe, Qoder CLI, Kimi Code CLI, GitLab Duo CLI, Rovo Dev CLI, Amp, Devin CLI / Local, Tabnine, Amazon Q Developer IDE, CodeBuddy Code CLI, IBM Bob Shell, Pochi, and Pi. Continue / cn, Visual Studio, TRAE, Roo Code, IBM Bob IDE, and Sourcegraph Cody are conditional or explicit integrations. Qodo, Warp MCP, JetBrains AI/ACP, GitHub Copilot coding agent, Jules, CodeRabbit, Replit, BLACKBOX AI, Plandex, and SWE-agent require manual, UI, cloud, or repository-managed setup and are not counted among the 43."
+ "text": "A single install command configures 44 automatic/conditional client surfaces. The 38 detected surfaces are Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, Cursor, Windsurf, Augment / Auggie, OpenClaw, Kiro, Junie, Hermes, OpenHands, Cline, Warp, Qwen Code, GitHub Copilot CLI, Factory Droid, Crush, Goose, Mistral Vibe, Grok Build, Qoder CLI, Kimi Code CLI, GitLab Duo CLI, Rovo Dev CLI, Amp, Devin CLI / Local, Tabnine, Amazon Q Developer IDE, CodeBuddy Code CLI, IBM Bob Shell, Pochi, and Pi. Continue / cn, Visual Studio, TRAE, Roo Code, IBM Bob IDE, and Sourcegraph Cody are conditional or explicit integrations. Qodo, Warp MCP, JetBrains AI/ACP, GitHub Copilot coding agent, Jules, CodeRabbit, Replit, BLACKBOX AI, Plandex, and SWE-agent require manual, UI, cloud, or repository-managed setup and are not counted among the 43."
}
},
{
@@ -527,10 +527,10 @@
<span class="cmd">"Index this project"</span>
</div>
<p class="muted">
- One command configures 43 automatic/conditional client surfaces. <strong>Detected automatically (37):</strong>
+ One command configures 44 automatic/conditional client surfaces. <strong>Detected automatically (38):</strong>
Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, Cursor,
Windsurf, Augment / Auggie, OpenClaw, Kiro, Junie, Hermes, OpenHands, Cline, Warp, Qwen Code,
- GitHub Copilot CLI, Factory Droid, Crush, Goose, Mistral Vibe, Qoder CLI, Kimi Code CLI,
+ GitHub Copilot CLI, Factory Droid, Crush, Goose, Mistral Vibe, Grok Build, Qoder CLI, Kimi Code CLI,
GitLab Duo CLI, Rovo Dev CLI, Amp, Devin CLI / Local, Tabnine, Amazon Q Developer IDE,
CodeBuddy Code CLI, IBM Bob Shell, Pochi, and Pi.
</p>
diff --git a/docs/llms.txt b/docs/llms.txt
index f7edd0316..ce927ad91 100644
--- a/docs/llms.txt
+++ b/docs/llms.txt
@@ -12,7 +12,7 @@
- Semantic & similarity edges: SEMANTICALLY_RELATED (vocabulary-mismatch matches) and SIMILAR_TO (MinHash + LSH near-clone / duplicate detection).
- Cross-repo intelligence: CROSS_* edges link nodes across multiple repos indexed in one store; multi-galaxy 3D layout and cross-repo architecture summary.
- Cross-service linking: HTTP route ↔ call-site matching, plus gRPC/GraphQL/tRPC detection and pub/sub channels (EMITS/LISTENS_ON for Socket.IO, EventEmitter, generic buses).
-- Supported agents: 43 automatic/conditional client surfaces (37 automatically detected + 6 conditional/explicit): Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, Cursor, Windsurf, Augment / Auggie, OpenClaw, Kiro, Junie, Hermes, OpenHands, Cline, Warp, Qwen Code, GitHub Copilot CLI, Factory Droid, Crush, Goose, Mistral Vibe, Qoder CLI, Kimi Code CLI, GitLab Duo CLI, Rovo Dev CLI, Amp, Devin CLI / Local, Tabnine, Continue / cn, Visual Studio, TRAE, Roo Code, Amazon Q Developer IDE, CodeBuddy Code CLI, IBM Bob IDE, IBM Bob Shell, Pochi, Pi, and Sourcegraph Cody.
+- Supported agents: 44 automatic/conditional client surfaces (38 automatically detected + 6 conditional/explicit): Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, Cursor, Windsurf, Augment / Auggie, OpenClaw, Kiro, Junie, Hermes, OpenHands, Cline, Warp, Qwen Code, GitHub Copilot CLI, Factory Droid, Crush, Goose, Mistral Vibe, Grok Build, Qoder CLI, Kimi Code CLI, GitLab Duo CLI, Rovo Dev CLI, Amp, Devin CLI / Local, Tabnine, Continue / cn, Visual Studio, TRAE, Roo Code, Amazon Q Developer IDE, CodeBuddy Code CLI, IBM Bob IDE, IBM Bob Shell, Pochi, Pi, and Sourcegraph Cody.
- Agent profiles: documented custom-agent formats receive Scout (fast/provisional), Verify (default/task-directed), and Auditor (bounded/full verification) definitions. Every direct tier checks exact path/scope coverage with check_index_coverage and falls back to source for flagged gaps; unsafe child-MCP formats use explicit parent handoff. Kiro and Junie use positive-allowlist Scout/Analysis server profiles (7/11 tools); Qoder combines named-server selection with exact tier-specific MCP tool IDs, while Factory uses exact registered IDs without additive whole-server exposure. Foreign Junie aliases are preserved and force parent handoff.
- Performance: Linux kernel (28M LOC, 75K files) full index in 3 minutes → 4.81M nodes, 7.72M edges; Cypher queries in under 1ms.
- Distribution: verified runtime set (native executable plus authenticated release-owned assets); fully static Linux builds are available in the `-portable` archives. Also available through npm, PyPI, Homebrew, Scoop, Winget, Chocolatey, AUR, and `go install`.
diff --git a/pkg/npm/README.md b/pkg/npm/README.md
index 0121a3635..2fed116ab 100644
--- a/pkg/npm/README.md
+++ b/pkg/npm/README.md
@@ -7,7 +7,7 @@
**The fastest and most efficient code intelligence engine for AI coding agents.** Full-indexes an average repository in milliseconds, the Linux kernel (28M LOC, 75K files) in 3 minutes. Answers structural queries in under 1ms. This npm wrapper downloads, verifies, and caches the selected native runtime set: the executable, its authenticated integration asset, and—when requested—the content-addressed UI pack.
-High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across 158 languages — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 15 MCP tools. No hosted service or API key; this package requires Node.js to manage and launch the cached native runtime set. Plug and play across 43 automatic/conditional client surfaces.
+High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across 158 languages — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 15 MCP tools. No hosted service or API key; this package requires Node.js to manage and launch the cached native runtime set. Plug and play across 44 automatic/conditional client surfaces.
## Installation
@@ -31,12 +31,12 @@ Restart your agent. Say **"Index this project"** — done.
- **Plug and play** — verified native runtime sets for macOS (arm64/amd64), Linux (arm64/amd64), and Windows (arm64/amd64). No Docker or API keys; Node.js owns package download, cache repair, and launch.
- **158 languages** — vendored tree-sitter grammars compiled into the binary. Nothing to install, nothing that breaks.
- **120x fewer tokens** — 5 structural queries: ~3,400 tokens vs ~412,000 via file-by-file search.
-- **43 supported automatic/conditional client surfaces** — `install` configures the appropriate MCP, durable-context, and documented hook surfaces without widening client permissions.
-- **Detected automatically (37)** — Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, Cursor, Windsurf, Augment / Auggie, OpenClaw, Kiro, Junie, Hermes, OpenHands, Cline, Warp, Qwen Code, GitHub Copilot CLI, Factory Droid, Crush, Goose, Mistral Vibe, Qoder CLI, Kimi Code CLI, GitLab Duo CLI, Rovo Dev CLI, Amp, Devin CLI / Local, Tabnine, Amazon Q Developer IDE, CodeBuddy Code CLI, IBM Bob Shell, Pochi, and Pi.
+- **44 supported automatic/conditional client surfaces** — `install` configures the appropriate MCP, durable-context, and documented hook surfaces without widening client permissions.
+- **Detected automatically (38)** — Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, Cursor, Windsurf, Augment / Auggie, OpenClaw, Kiro, Junie, Hermes, OpenHands, Cline, Warp, Qwen Code, GitHub Copilot CLI, Factory Droid, Crush, Goose, Mistral Vibe, Grok Build, Qoder CLI, Kimi Code CLI, GitLab Duo CLI, Rovo Dev CLI, Amp, Devin CLI / Local, Tabnine, Amazon Q Developer IDE, CodeBuddy Code CLI, IBM Bob Shell, Pochi, and Pi.
- **Conditional or explicit (6)** — Continue / cn, Visual Studio, TRAE, Roo Code, IBM Bob IDE, and Sourcegraph Cody. Bob IDE is touched only when `~/.bob/mcp.json` already exists.
- **New documented adapters** — CodeBuddy uses `~/.codebuddy/.mcp.json` while preserving active older files; Bob Shell uses `~/.bob/mcp_settings.json`; Pochi uses the `mcp` section in `~/.pochi/config.jsonc`; Amazon Q Developer IDE defaults to `~/.aws/amazonq/default.json` while preserving either documented alternative.
- **Lifecycle hooks stay conservative** — Kimi uses `UserPromptSubmit`; on macOS/Linux, GitLab Duo gets a fail-open user `SessionStart`, while Devin gets `UserPromptSubmit`, `PostCompaction`, and a deduplicated `SessionStart` when Claude does not already provide it. Qoder, GitLab Duo, Devin, and Factory hooks are withheld on Windows without a documented shell/executor contract. Cline's auto-activating file hooks are withheld because their context output is not reliably consumed, CodeBuddy beta hooks are not auto-installed, and Cursor context hooks remain withheld.
-- **Subagent access is explicit** — Claude, Gemini, Kiro, Qwen, CodeBuddy, KiloCode, Mistral Vibe, Qoder, Junie, and Factory get documented graph profiles with the narrowest tool/server filters their schemas support. KiloCode and Vibe enumerate read-only query tools rather than using server wildcards. Cursor, Rovo, Pochi, and Cline use explicit parent handoff where child MCP is unavailable or unsafe; IBM Bob receives no invented hook or agent.
+- **Subagent access is explicit** — Claude, Gemini, Kiro, Qwen, CodeBuddy, KiloCode, Mistral Vibe, Grok Build, Qoder, Junie, and Factory get documented graph profiles with the narrowest tool/server filters their schemas support. KiloCode and Vibe enumerate read-only query tools rather than using server wildcards. Cursor, Rovo, Pochi, and Cline use explicit parent handoff where child MCP is unavailable or unsafe; IBM Bob receives no invented hook or agent.
- **Manual, UI, cloud, or repository-managed (not counted)** — Qodo, Warp MCP, JetBrains AI/ACP, GitHub Copilot coding agent, Jules, CodeRabbit, Replit, BLACKBOX AI, Plandex, and SWE-agent. Warp is counted above for its detected skill installation; its MCP connection remains manual.
- **15 MCP tools** — search, trace, architecture, impact analysis, Cypher queries, dead code detection, cross-service HTTP linking, ADR management, and more.
diff --git a/scripts/smoke-test.sh b/scripts/smoke-test.sh
index 53dc130ae..3f0e52fcd 100755
--- a/scripts/smoke-test.sh
+++ b/scripts/smoke-test.sh
@@ -1314,6 +1314,7 @@ echo "=== Phase 8: agent config install E2E ==="
FAKE_HOME=$(smoke_mktemp_dir)
mkdir -p "$FAKE_HOME/.claude"
mkdir -p "$FAKE_HOME/.codex"
+mkdir -p "$FAKE_HOME/.grok"
mkdir -p "$FAKE_HOME/.gemini/antigravity-cli"
mkdir -p "$FAKE_HOME/.junie"
mkdir -p "$FAKE_HOME/.cursor"
@@ -2558,8 +2559,41 @@ assert_tier_profile_set "Qoder" "$FAKE_HOME/.qoder/agents" ".md" "direct"
assert_tier_profile_set "CodeBuddy" "$FAKE_HOME/.codebuddy/agents" ".md" "direct"
assert_tier_profile_set "Pochi" "$FAKE_HOME/.pochi/agents" ".md" "handoff"
assert_tier_profile_set "Rovo" "$FAKE_HOME/.rovodev/subagents" ".md" "handoff"
+assert_tier_profile_set "Grok" "$FAKE_HOME/.grok/agents" ".md" "direct"
echo "OK 8aw: all supported Scout/Verify/Auditor profile sets"
+# 8ax: Grok Build config.toml MCP table (exactly one header), owned rules file,
+# skill, named-server subagent inheritance with dispatcher tool ids, and NO
+# hook: Grok's passive hook events discard stdout, so context hooks are withheld.
+GROK_CONFIG="$FAKE_HOME/.grok/config.toml"
+GROK_CMD=$(sed -n 's/^command *= *//p' "$GROK_CONFIG" 2>/dev/null | head -1)
+if ! grep -q '^\[mcp_servers\.codebase-memory-mcp\]$' "$GROK_CONFIG" 2>/dev/null ||
+ [ "$(grep -c '^\[mcp_servers\.codebase-memory-mcp\]$' "$GROK_CONFIG" 2>/dev/null)" != "1" ] ||
+ ! grep -q '^args = \[\]$' "$GROK_CONFIG" 2>/dev/null ||
+ ! quoted_path_value_matches "$GROK_CMD" "$SELF_PATH"; then
+ echo "FAIL 8ax: Grok Build MCP table missing or malformed"
+ exit 1
+fi
+if ! grep -q 'search_graph' "$FAKE_HOME/.grok/rules/codebase-memory.md" 2>/dev/null ||
+ ! grep -q 'search_graph' "$FAKE_HOME/.grok/skills/codebase-memory/SKILL.md" 2>/dev/null; then
+ echo "FAIL 8ax: Grok Build rules file or skill missing"
+ exit 1
+fi
+GROK_AGENT="$FAKE_HOME/.grok/agents/codebase-memory.md"
+if ! grep -Fq 'tools: read_file, grep, list_dir, search_tool, use_tool' "$GROK_AGENT" 2>/dev/null ||
+ ! grep -Fq ' - codebase-memory-mcp' "$GROK_AGENT" 2>/dev/null ||
+ ! grep -Fq 'codebase-memory-mcp__search_graph' "$GROK_AGENT" 2>/dev/null ||
+ ! grep -Fq 'codebase-memory-mcp__check_index_coverage' "$GROK_AGENT" 2>/dev/null ||
+ grep -Fq 'codebase-memory-mcp__*' "$GROK_AGENT" 2>/dev/null; then
+ echo "FAIL 8ax: Grok Build graph agent lacks named inheritance or dispatcher tool ids"
+ exit 1
+fi
+if [ -e "$FAKE_HOME/.grok/hooks" ]; then
+ echo "FAIL 8ax: Grok Build must not receive hooks"
+ exit 1
+fi
+echo "OK 8ax: Grok Build MCP + rules + skill + named-inheritance agents; hooks withheld"
+
echo ""
echo "=== Phase 9: agent config uninstall E2E ==="
@@ -2813,6 +2847,7 @@ echo "OK 9l: JSON agents, lifecycle hooks, and Kilo cleaned; foreign settings pr
if grep -q '^ codebase-memory-mcp:' "$FAKE_HOME/.hermes/config.yaml" 2>/dev/null ||
grep -q '^ pre_llm_call:' "$FAKE_HOME/.hermes/config.yaml" 2>/dev/null ||
grep -q '^ codebase-memory-mcp:' "$GOOSE_CFG" 2>/dev/null ||
+ grep -q 'codebase-memory-mcp' "$FAKE_HOME/.grok/config.toml" 2>/dev/null ||
grep -q '^name = "codebase-memory-mcp"' "$FAKE_HOME/.vibe/config.toml" 2>/dev/null; then
echo "FAIL 9m: YAML/TOML MCP entry remains"
exit 1
@@ -2834,6 +2869,7 @@ for CONTEXT_FILE in \
"$KILO_RULE" \
"$CLINE_RULE" \
"$FAKE_HOME/.vibe/AGENTS.md" \
+ "$FAKE_HOME/.grok/rules/codebase-memory.md" \
"$FAKE_HOME/.codeium/windsurf/memories/global_rules.md" \
"$DEVIN_INSTRUCTIONS" \
"$CODEBUDDY_INSTRUCTIONS" \
@@ -2872,6 +2908,7 @@ if [ -d "$FAKE_HOME/.claude/skills/codebase-memory" ] ||
[ -d "$FAKE_HOME/.rovodev/skills/codebase-memory" ] ||
[ -d "$FAKE_HOME/.copilot/skills/codebase-memory" ] ||
[ -d "$FAKE_HOME/.vibe/skills/codebase-memory" ] ||
+ [ -d "$FAKE_HOME/.grok/skills/codebase-memory" ] ||
[ -e "$DEVIN_SKILL" ] ||
[ -e "$CODEBUDDY_SKILL" ] ||
[ -e "$BOB_SKILL" ] ||
@@ -2909,6 +2946,7 @@ assert_tier_profile_set_removed "Qwen" "$FAKE_HOME/.qwen/agents" ".md"
assert_tier_profile_set_removed "Factory" "$FAKE_HOME/.factory/droids" ".md"
assert_tier_profile_set_removed "Vibe" "$FAKE_HOME/.vibe/agents" ".toml"
assert_tier_profile_set_removed "Vibe prompt" "$FAKE_HOME/.vibe/prompts" ".md"
+assert_tier_profile_set_removed "Grok" "$FAKE_HOME/.grok/agents" ".md"
assert_tier_profile_set_removed "Copilot" "$FAKE_HOME/.copilot/agents" ".agent.md"
assert_tier_profile_set_removed "Qoder" "$FAKE_HOME/.qoder/agents" ".md"
assert_tier_profile_set_removed "CodeBuddy" "$FAKE_HOME/.codebuddy/agents" ".md"
diff --git a/src/cli/agent_profiles.c b/src/cli/agent_profiles.c
index f091f55e6..d42b0a263 100644
--- a/src/cli/agent_profiles.c
+++ b/src/cli/agent_profiles.c
@@ -311,6 +311,8 @@ static const char *dialect_tool_prefix(cbm_graph_profile_dialect_t dialect) {
return "codebase-memory-mcp_";
case CBM_GRAPH_DIALECT_KIRO:
return "@codebase-memory-mcp/";
+ case CBM_GRAPH_DIALECT_GROK:
+ return "codebase-memory-mcp__";
default:
return NULL;
}
@@ -618,6 +620,27 @@ static bool render_profile_text(profile_buffer_t *buffer, cbm_graph_profile_dial
return false;
}
return true;
+ case CBM_GRAPH_DIALECT_GROK:
+ /* Grok Build children reach MCP only through the search_tool/use_tool
+ * dispatcher and inherit servers by NAME (mcpInheritance), never by
+ * tool, so the tier allowlist is spelled out in the body as the exact
+ * `server__tool` ids the dispatcher accepts. Handoff inherits nothing. */
+ if (!append_yaml_identity(buffer, slug, description) ||
+ !profile_buffer_append(buffer, "tools: read_file, grep, list_dir") ||
+ (direct && !profile_buffer_append(buffer, ", search_tool, use_tool")) ||
+ !profile_buffer_append(
+ buffer, direct ? "\nmcpInheritance:\n named:\n - codebase-memory-mcp\n---\n"
+ : "\nmcpInheritance: none\n---\n") ||
+ (direct && (!profile_buffer_append(
+ buffer, "Reach the graph only through `search_tool`/`use_tool`. "
+ "The only allowed tool ids are ") ||
+ !append_csv_mcp_tools(buffer, dialect, tier) ||
+ !profile_buffer_append(
+ buffer, "; never call any other codebase-memory-mcp tool.\n\n"))) ||
+ !profile_buffer_append(buffer, prompt)) {
+ return false;
+ }
+ return true;
case CBM_GRAPH_DIALECT_AUGMENT:
return append_yaml_identity(buffer, slug, description) &&
profile_buffer_append(buffer, "---\n") && profile_buffer_append(buffer, prompt);
diff --git a/src/cli/agent_profiles.h b/src/cli/agent_profiles.h
index 0bd23bf41..1f012ae2b 100644
--- a/src/cli/agent_profiles.h
+++ b/src/cli/agent_profiles.h
@@ -41,6 +41,7 @@ typedef enum {
CBM_GRAPH_DIALECT_CURSOR,
CBM_GRAPH_DIALECT_ROVO,
CBM_GRAPH_DIALECT_POCHI,
+ CBM_GRAPH_DIALECT_GROK,
CBM_GRAPH_DIALECT_COUNT
} cbm_graph_profile_dialect_t;
diff --git a/src/cli/cli.c b/src/cli/cli.c
index d981af266..a76e49a13 100644
--- a/src/cli/cli.c
+++ b/src/cli/cli.c
@@ -2638,6 +2638,17 @@ static void cbm_vibe_config_dir(const char *home_dir, char *out, size_t out_sz)
}
}
+/* Resolve Grok Build's user configuration directory.
+ * Honors $GROK_HOME; falls back to "$home_dir/.grok". */
+static void cbm_grok_config_dir(const char *home_dir, char *out, size_t out_sz) {
+ char env_buf[CLI_BUF_1K];
+ const char *custom = cbm_safe_getenv("GROK_HOME", env_buf, sizeof(env_buf), NULL);
+ snprintf(out, out_sz, "%s", custom && custom[0] ? custom : "");
+ if ((!custom || !custom[0]) && home_dir && home_dir[0]) {
+ snprintf(out, out_sz, "%s/.grok", home_dir);
+ }
+}
+
static bool cbm_hook_script_name_safe(const char *script_name) {
if (!script_name || !script_name[0]) {
return false;
@@ -2878,6 +2889,9 @@ cbm_detected_agents_t cbm_detect_agents(const char *home_dir) {
cbm_vibe_config_dir(home_dir, path, sizeof(path));
agents.mistral_vibe = dir_exists(path) || cbm_agent_cli_exists("vibe", home_dir);
+ cbm_grok_config_dir(home_dir, path, sizeof(path));
+ agents.grok = dir_exists(path) || cbm_agent_cli_exists("grok", home_dir);
+
return agents;
}
@@ -4062,6 +4076,53 @@ static int cbm_remove_vibe_mcp_owned(const char *binary_path, const char *config
"codebase-memory-mcp", body);
}
+/* ── Grok Build MCP config (TOML) ────────────────────────────── */
+
+#define GROK_CMM_TABLE "mcp_servers.codebase-memory-mcp"
+#define GROK_CMM_SECTION "[" GROK_CMM_TABLE "]"
+#define GROK_MCP_BEGIN "# >>> codebase-memory-mcp MCP >>>"
+#define GROK_MCP_END "# <<< codebase-memory-mcp MCP <<<"
+
+/* A pre-marker table with the known owned shape (what `grok mcp add` writes
+ * for this binary) is adopted; any other same-name table is foreign and left
+ * byte-identical, because a second [mcp_servers.codebase-memory-mcp] header
+ * would make Grok reject the whole config.toml. */
+static int cbm_remove_grok_legacy_mcp(const char *config_path) {
+ return cbm_toml_remove_legacy_table(config_path, GROK_CMM_TABLE, GROK_MCP_BEGIN, GROK_MCP_END);
+}
+
+static int cbm_upsert_grok_mcp(const char *binary_path, const char *config_path) {
+ if (!binary_path || !config_path) {
+ return CLI_ERR;
+ }
+ char escaped[CLI_BUF_8K];
+ if (cbm_toml_escape_basic_string(binary_path, escaped, sizeof(escaped)) != 0) {
+ return CLI_ERR;
+ }
+ /* Grok spawns stdio servers with the full parent environment (verified
+ * against grok 1.0.5), so unlike Codex (#1562) nothing has to be
+ * forwarded: CBM_CACHE_DIR and CBM_RUNTIME_DIR reach the server as-is. */
+ char block[CLI_BUF_8K];
+ int written =
+ snprintf(block, sizeof(block), GROK_CMM_SECTION "\ncommand = \"%s\"\nargs = []\n", escaped);
+ if (written < 0 || (size_t)written >= sizeof(block) ||
+ cbm_remove_grok_legacy_mcp(config_path) != 0) {
+ return CLI_ERR;
+ }
+ return cbm_toml_upsert_managed_block(config_path, GROK_MCP_BEGIN, GROK_MCP_END, block) == 0
+ ? CLI_OK
+ : CLI_ERR;
+}
+
+static int cbm_remove_grok_mcp_owned(const char *binary_path, const char *config_path) {
+ (void)binary_path;
+ if (!config_path ||
+ cbm_toml_remove_managed_block(config_path, GROK_MCP_BEGIN, GROK_MCP_END) != 0) {
+ return CLI_ERR;
+ }
+ return cbm_remove_grok_legacy_mcp(config_path) >= 0 ? CLI_OK : CLI_ERR;
+}
+
/* ── Claude Code pre-tool hooks ───────────────────────────────── */
/* Search augmentation runs before Grep/Glob; exact coverage context runs after
@@ -7409,6 +7470,7 @@ static void print_detected_agents(const cbm_detected_agents_t *a, const char *ho
{a->crush, "Crush"},
{a->goose, "Goose"},
{a->mistral_vibe, "Mistral-Vibe"},
+ {a->grok, "Grok-Build"},
};
printf("Detected agents:");
bool any = false;
@@ -9363,6 +9425,38 @@ static void install_additional_agent_configs(const cbm_detected_agents_t *agents
install_tiered_profile_prompts("Mistral Vibe", prompt_path, CBM_GRAPH_DIALECT_VIBE,
legacy_vibe_verify_prompt_content, dry_run);
}
+ if (agents->grok) {
+ char config_dir[CLI_BUF_1K];
+ char cp[CLI_BUF_1K];
+ char ip[CLI_BUF_1K];
+ char skills_dir[CLI_BUF_1K];
+ char ap[CLI_BUF_1K];
+ cbm_grok_config_dir(home, config_dir, sizeof(config_dir));
+ snprintf(cp, sizeof(cp), "%s/config.toml", config_dir);
+ /* Every .md under $GROK_HOME/rules/ is always scanned and applies to
+ * every project; an owned file there never touches a user AGENTS.md. */
+ snprintf(ip, sizeof(ip), "%s/rules/codebase-memory.md", config_dir);
+ snprintf(skills_dir, sizeof(skills_dir), "%s/skills", config_dir);
+ snprintf(ap, sizeof(ap), "%s/agents/codebase-memory.md", config_dir);
+ install_generic_agent_config("Grok Build", binary_path, cp, ip, dry_run,
+ cbm_upsert_grok_mcp);
+ install_agent_skill("Grok Build", skills_dir, force, dry_run);
+ install_tiered_agent_profiles(
+ (cbm_tiered_profile_set_t){
+ .label = "Grok Build",
+ .verify_path = ap,
+ .binary_path = binary_path,
+ .dialect = CBM_GRAPH_DIALECT_GROK,
+ },
+ dry_run);
+ /* Grok's passive hook events (SessionStart, SubagentStart, PostToolUse)
+ * discard stdout and PreToolUse honors only decision/updatedInput, so
+ * the context augmenter would run for nothing: no hook is installed. */
+ if (!g_install_plan) {
+ printf(" hooks: withheld (Grok passive hook events discard stdout; no context "
+ "contract)\n");
+ }
+ }
}
/* #1558: set by `install --clients=...` after validation, consumed at the one
@@ -9540,6 +9634,7 @@ static const cli_client_def_t CLI_CLIENTS[] = {
CLI_CLIENT(crush, "crush", "Crush"),
CLI_CLIENT(goose, "goose", "Goose"),
CLI_CLIENT(mistral_vibe, "mistral-vibe", "Mistral Vibe"),
+ CLI_CLIENT(grok, "grok", "Grok Build"),
};
enum { CLI_CLIENT_COUNT = sizeof(CLI_CLIENTS) / sizeof(CLI_CLIENTS[0]) };
@@ -9778,6 +9873,7 @@ static char *cbm_build_install_plan_json_options(const char *home, const char *b
{det.crush, "crush"},
{det.goose, "goose"},
{det.mistral_vibe, "mistral-vibe"},
+ {det.grok, "grok"},
};
yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL);
@@ -11475,6 +11571,28 @@ static void uninstall_additional_agents(const cbm_detected_agents_t *agents, con
uninstall_tiered_profile_prompts("Mistral Vibe", prompt_path, CBM_GRAPH_DIALECT_VIBE,
legacy_vibe_verify_prompt_content, dry_run);
}
+ if (agents->grok) {
+ char config_dir[CLI_BUF_1K];
+ char cp[CLI_BUF_1K];
+ char ip[CLI_BUF_1K];
+ char skills_dir[CLI_BUF_1K];
+ char ap[CLI_BUF_1K];
+ cbm_grok_config_dir(home, config_dir, sizeof(config_dir));
+ snprintf(cp, sizeof(cp), "%s/config.toml", config_dir);
+ snprintf(ip, sizeof(ip), "%s/rules/codebase-memory.md", config_dir);
+ snprintf(skills_dir, sizeof(skills_dir), "%s/skills", config_dir);
+ snprintf(ap, sizeof(ap), "%s/agents/codebase-memory.md", config_dir);
+ uninstall_agent_mcp_instr((mcp_uninstall_args_t){"Grok Build", cp, ip}, dry_run,
+ cbm_remove_grok_mcp_owned);
+ uninstall_agent_skill("Grok Build", skills_dir, dry_run);
+ uninstall_tiered_agent_profiles(
+ (cbm_tiered_profile_set_t){
+ .label = "Grok Build",
+ .verify_path = ap,
+ .dialect = CBM_GRAPH_DIALECT_GROK,
+ },
+ dry_run);
+ }
}
typedef struct {
diff --git a/src/cli/cli.h b/src/cli/cli.h
index c2121a940..465f97cc2 100644
--- a/src/cli/cli.h
+++ b/src/cli/cli.h
@@ -193,6 +193,7 @@ typedef struct {
bool crush; /* Crush config or CLI exists */
bool goose; /* Goose config or CLI exists */
bool mistral_vibe; /* $VIBE_HOME, ~/.vibe/, or vibe CLI exists */
+ bool grok; /* $GROK_HOME, ~/.grok/, or grok CLI exists */
} cbm_detected_agents_t;
/* Detect which coding agents are installed.
diff --git a/src/main.c b/src/main.c
index c5c936e49..c2c44c316 100644
--- a/src/main.c
+++ b/src/main.c
@@ -912,12 +912,12 @@ static void print_help(void) {
printf(" --ui=false Disable HTTP graph visualization (persisted)\n");
printf(" --port=N Set UI port (default 9749, persisted)\n");
printf(" --tool-profile=analysis|scout Expose a restricted inspection surface\n");
- printf("\nSupported automatic/conditional client surfaces (43):\n");
+ printf("\nSupported automatic/conditional client surfaces (44):\n");
printf(" Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode,\n");
printf(" Antigravity, Aider, KiloCode, VS Code, Cursor, Windsurf,\n");
printf(" Augment / Auggie, OpenClaw, Kiro, Junie, Hermes, OpenHands,\n");
printf(" Cline, Warp, Qwen Code, GitHub Copilot CLI, Factory Droid, Crush,\n");
- printf(" Goose, Mistral Vibe, Qoder CLI, Kimi Code CLI, GitLab Duo CLI,\n");
+ printf(" Goose, Mistral Vibe, Grok Build, Qoder CLI, Kimi Code CLI, GitLab Duo CLI,\n");
printf(" Rovo Dev CLI, Amp, Devin CLI / Local, Tabnine, Continue / cn,\n");
printf(" Visual Studio, TRAE, Roo Code, Amazon Q Developer IDE,\n");
printf(" CodeBuddy Code CLI, IBM Bob IDE, IBM Bob Shell, Pochi, Pi,\n");
diff --git a/tests/test_agent_profiles.c b/tests/test_agent_profiles.c
index 461bbf4bc..052f185d4 100644
--- a/tests/test_agent_profiles.c
+++ b/tests/test_agent_profiles.c
@@ -31,6 +31,7 @@ static const direct_dialect_expectation_t direct_dialects[] = {
{CBM_GRAPH_DIALECT_FACTORY, "mcp__codebase-memory-mcp__check_index_coverage",
"tools: [\"Read\", \"LS\", \"Grep\", \"Glob\"", "source read/grep fallback"},
{CBM_GRAPH_DIALECT_VIBE, "agent_type = \"subagent\"", "\"read_file\"", "\"grep_search\""},
+ {CBM_GRAPH_DIALECT_GROK, "mcpInheritance:", "read_file", "grep"},
};
static const cbm_graph_profile_dialect_t handoff_only_dialects[] = {
@@ -279,6 +280,41 @@ TEST(agent_profiles_vibe_uses_matching_prompt_identifier_and_contract) {
PASS();
}
+/* Grok Build children reach MCP only through its search_tool/use_tool
+ * dispatcher and filter inheritance per server, so the direct profile must
+ * name the server for inheritance and spell out the tier's qualified tool ids
+ * as the dispatcher accepts them; handoff profiles must inherit nothing. */
+TEST(agent_profiles_grok_uses_dispatcher_ids_and_named_inheritance) {
+ for (int tier = 0; tier < (int)CBM_GRAPH_TIER_COUNT; tier++) {
+ const char *slug = cbm_graph_tier_slug((cbm_graph_tier_t)tier);
+ char *direct = cbm_render_graph_profile(CBM_GRAPH_DIALECT_GROK, (cbm_graph_tier_t)tier,
+ CBM_GRAPH_ACCESS_DIRECT, NULL);
+ char *handoff = cbm_render_graph_profile(CBM_GRAPH_DIALECT_GROK, (cbm_graph_tier_t)tier,
+ CBM_GRAPH_ACCESS_HANDOFF, NULL);
+ char name_line[128];
+ snprintf(name_line, sizeof(name_line), "---\nname: %s\n", slug);
+ int direct_ok =
+ direct && strstr(direct, name_line) &&
+ strstr(direct, "tools: read_file, grep, list_dir, search_tool, use_tool\n") &&
+ strstr(direct, "mcpInheritance:\n named:\n - codebase-memory-mcp\n---\n") &&
+ strstr(direct, "codebase-memory-mcp__search_graph") &&
+ strstr(direct, "codebase-memory-mcp__check_index_coverage") &&
+ !strstr(direct, "codebase-memory-mcp__*") && !profile_has_mutator(direct) &&
+ (tier != (int)CBM_GRAPH_TIER_SCOUT) ==
+ (strstr(direct, "codebase-memory-mcp__query_graph") != NULL);
+ int handoff_ok = handoff && strstr(handoff, name_line) &&
+ strstr(handoff, "tools: read_file, grep, list_dir\n") &&
+ strstr(handoff, "mcpInheritance: none\n---\n") &&
+ !strstr(handoff, "use_tool") && !strstr(handoff, "codebase-memory-mcp__");
+ free(direct);
+ free(handoff);
+ if (!direct_ok || !handoff_ok) {
+ FAIL("Grok profiles must name the server for inheritance and list dispatcher tool ids");
+ }
+ }
+ PASS();
+}
+
TEST(agent_profiles_render_deterministically_and_reject_invalid_inputs) {
char *first = cbm_render_graph_profile(CBM_GRAPH_DIALECT_QWEN, CBM_GRAPH_TIER_VERIFY,
CBM_GRAPH_ACCESS_DIRECT, NULL);
@@ -312,5 +348,6 @@ SUITE(agent_profiles) {
RUN_TEST(agent_profiles_kiro_is_valid_json_and_escapes_binary_path);
RUN_TEST(agent_profiles_codex_declares_transport_and_escapes_binary_path);
RUN_TEST(agent_profiles_vibe_uses_matching_prompt_identifier_and_contract);
+ RUN_TEST(agent_profiles_grok_uses_dispatcher_ids_and_named_inheritance);
RUN_TEST(agent_profiles_render_deterministically_and_reject_invalid_inputs);
}
diff --git a/tests/test_cli.c b/tests/test_cli.c
index 6295479f2..ca3f19e1b 100644
--- a/tests/test_cli.c
+++ b/tests/test_cli.c
@@ -4412,6 +4412,31 @@ TEST(cli_detect_agents_finds_codex) {
PASS();
}
+TEST(cli_detect_agents_finds_grok) {
+ char tmpdir[256];
+ snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-detect-XXXXXX");
+ if (!cbm_mkdtemp(tmpdir))
+ FAIL("cbm_mkdtemp failed");
+
+ char *saved_grok = save_test_env("GROK_HOME");
+ char *saved_path = save_test_env("PATH");
+ cbm_unsetenv("GROK_HOME");
+ cbm_setenv("PATH", tmpdir, 1);
+ cbm_detected_agents_t before = cbm_detect_agents(tmpdir);
+
+ char dir[512];
+ snprintf(dir, sizeof(dir), "%s/.grok", tmpdir);
+ test_mkdirp(dir);
+ cbm_detected_agents_t agents = cbm_detect_agents(tmpdir);
+
+ restore_test_env("GROK_HOME", saved_grok);
+ restore_test_env("PATH", saved_path);
+ test_rmdir_r(tmpdir);
+ ASSERT_FALSE(before.grok);
+ ASSERT_TRUE(agents.grok);
+ PASS();
+}
+
/* issue #222: Cursor (~/.cursor/) must be detected so install/update registers
* the MCP server in ~/.cursor/mcp.json — previously it was never discovered. */
TEST(cli_detect_agents_finds_cursor_issue222) {
@@ -4527,6 +4552,7 @@ TEST(cli_supported_agent_surfaces_match_installers) {
"Crush",
"Goose",
"Mistral Vibe",
+ "Grok Build",
"Qoder CLI",
"Kimi Code CLI",
"GitLab Duo CLI",
@@ -4546,13 +4572,13 @@ TEST(cli_supported_agent_surfaces_match_installers) {
"Pi",
"Sourcegraph Cody",
};
- ASSERT_EQ(sizeof(required_agents) / sizeof(required_agents[0]), 43U);
+ ASSERT_EQ(sizeof(required_agents) / sizeof(required_agents[0]), 44U);
char *data = read_test_file_alloc("README.md");
if (!data)
FAIL("could not read README.md for supported-agent contract");
- if (!strstr(data, "43 supported automatic/conditional client surfaces")) {
+ if (!strstr(data, "44 supported automatic/conditional client surfaces")) {
free(data);
- FAIL("README must describe all 43 automatic/conditional client surfaces accurately");
+ FAIL("README must describe all 44 automatic/conditional client surfaces accurately");
}
for (size_t i = 0; i < sizeof(required_agents) / sizeof(required_agents[0]); i++) {
if (!strstr(data, required_agents[i])) {
@@ -4565,9 +4591,9 @@ TEST(cli_supported_agent_surfaces_match_installers) {
data = read_test_file_alloc("pkg/npm/README.md");
if (!data)
FAIL("could not read npm README for supported-agent contract");
- if (!strstr(data, "43 supported automatic/conditional client surfaces")) {
+ if (!strstr(data, "44 supported automatic/conditional client surfaces")) {
free(data);
- FAIL("npm README must describe all 43 automatic/conditional client surfaces accurately");
+ FAIL("npm README must describe all 44 automatic/conditional client surfaces accurately");
}
for (size_t i = 0; i < sizeof(required_agents) / sizeof(required_agents[0]); i++) {
if (!strstr(data, required_agents[i])) {
@@ -4580,9 +4606,9 @@ TEST(cli_supported_agent_surfaces_match_installers) {
data = read_test_file_alloc("docs/index.html");
if (!data)
FAIL("could not read docs/index.html for supported-agent contract");
- if (!strstr(data, "configures 43 automatic/conditional client surfaces")) {
+ if (!strstr(data, "configures 44 automatic/conditional client surfaces")) {
free(data);
- FAIL("landing page must describe all 43 automatic/conditional client surfaces accurately");
+ FAIL("landing page must describe all 44 automatic/conditional client surfaces accurately");
}
for (size_t i = 0; i < sizeof(required_agents) / sizeof(required_agents[0]); i++) {
if (!strstr(data, required_agents[i])) {
@@ -4601,7 +4627,7 @@ TEST(cli_supported_agent_surfaces_match_installers) {
FAIL("CLI help must list every automatic/conditional client surface");
}
}
- if (!strstr(data, "Supported automatic/conditional client surfaces (43)")) {
+ if (!strstr(data, "Supported automatic/conditional client surfaces (44)")) {
free(data);
FAIL("CLI help must not describe all conditional surfaces as auto-detected");
}
@@ -4610,10 +4636,10 @@ TEST(cli_supported_agent_surfaces_match_installers) {
data = read_test_file_alloc("docs/llms.txt");
if (!data)
FAIL("could not read docs/llms.txt for supported-agent contract");
- if (!strstr(data, "43 automatic/conditional client surfaces") ||
- !strstr(data, "37 automatically detected") || !strstr(data, "6 conditional/explicit")) {
+ if (!strstr(data, "44 automatic/conditional client surfaces") ||
+ !strstr(data, "38 automatically detected") || !strstr(data, "6 conditional/explicit")) {
free(data);
- FAIL("llms.txt must describe the 43-surface 37+6 support matrix accurately");
+ FAIL("llms.txt must describe the 44-surface 38+6 support matrix accurately");
}
for (size_t i = 0; i < sizeof(required_agents) / sizeof(required_agents[0]); i++) {
if (!strstr(data, required_agents[i])) {
@@ -4634,10 +4660,12 @@ TEST(cli_new_agent_install_plans_use_documented_paths) {
char *saved_copilot = save_test_env("COPILOT_HOME");
char *saved_crush = save_test_env("CRUSH_GLOBAL_CONFIG");
char *saved_vibe = save_test_env("VIBE_HOME");
+ char *saved_grok = save_test_env("GROK_HOME");
char *saved_appdata = save_test_env("APPDATA");
cbm_unsetenv("COPILOT_HOME");
cbm_unsetenv("CRUSH_GLOBAL_CONFIG");
cbm_unsetenv("VIBE_HOME");
+ cbm_unsetenv("GROK_HOME");
#ifdef _WIN32
char appdata[512];
snprintf(appdata, sizeof(appdata), "%s/AppData/Roaming", tmpdir);
@@ -4658,6 +4686,7 @@ TEST(cli_new_agent_install_plans_use_documented_paths) {
".config/goose",
#endif
".vibe",
+ ".grok",
};
char path[768];
for (size_t i = 0; i < sizeof(dirs) / sizeof(dirs[0]); i++) {
@@ -4702,6 +4731,11 @@ TEST(cli_new_agent_install_plans_use_documented_paths) {
"\"mistral-vibe\"",
"/.vibe/config.toml",
"/.vibe/AGENTS.md",
+ "\"grok\"",
+ "/.grok/config.toml",
+ "/.grok/rules/codebase-memory.md",
+ "/.grok/skills/codebase-memory/SKILL.md",
+ "/.grok/agents/codebase-memory.md",
};
const char *missing = NULL;
for (size_t i = 0; json && i < sizeof(expected) / sizeof(expected[0]); i++) {
@@ -4715,6 +4749,7 @@ TEST(cli_new_agent_install_plans_use_documented_paths) {
restore_test_env("COPILOT_HOME", saved_copilot);
restore_test_env("CRUSH_GLOBAL_CONFIG", saved_crush);
restore_test_env("VIBE_HOME", saved_vibe);
+ restore_test_env("GROK_HOME", saved_grok);
restore_test_env("APPDATA", saved_appdata);
test_rmdir_r(tmpdir);
@@ -4731,7 +4766,8 @@ TEST(cli_new_agent_configs_use_documented_schemas) {
const char *const env_names[] = {
"PATH", "COPILOT_HOME", "CRUSH_GLOBAL_CONFIG", "VIBE_HOME",
- "CODEX_HOME", "CLAUDE_CONFIG_DIR", "OPENCODE_CONFIG", "APPDATA"};
+ "CODEX_HOME", "CLAUDE_CONFIG_DIR", "OPENCODE_CONFIG", "APPDATA",
+ "GROK_HOME"};
char *saved_env[sizeof(env_names) / sizeof(env_names[0])];
for (size_t i = 0; i < sizeof(env_names) / sizeof(env_names[0]); i++) {
saved_env[i] = save_test_env(env_names[i]);
@@ -4758,6 +4794,7 @@ TEST(cli_new_agent_configs_use_documented_schemas) {
".config/goose",
#endif
".vibe",
+ ".grok",
};
char path[768];
for (size_t i = 0; i < sizeof(dirs) / sizeof(dirs[0]); i++) {
@@ -4859,6 +4896,12 @@ TEST(cli_new_agent_configs_use_documented_schemas) {
schemas_ok = schemas_ok && test_file_contains_all(path, vibe, 5);
snprintf(path, sizeof(path), "%s/.vibe/AGENTS.md", tmpdir);
schemas_ok = schemas_ok && test_file_contains_all(path, durable_hint, 3);
+ const char *const grok[] = {"[mcp_servers.codebase-memory-mcp]", "command = \"", "args = []",
+ binary};
+ snprintf(path, sizeof(path), "%s/.grok/config.toml", tmpdir);
+ schemas_ok = schemas_ok && test_file_contains_all(path, grok, 4);
+ snprintf(path, sizeof(path), "%s/.grok/rules/codebase-memory.md", tmpdir);
+ schemas_ok = schemas_ok && test_file_contains_all(path, durable_hint, 3);
for (size_t i = 0; i < sizeof(env_names) / sizeof(env_names[0]); i++) {
restore_test_env(env_names[i], saved_env[i]);
@@ -5171,6 +5214,7 @@ TEST(cli_durable_profiles_follow_current_vendor_paths) {
"CLINE_DATA_DIR",
"KIRO_HOME",
"VIBE_HOME",
+ "GROK_HOME",
"OPENCODE_CONFIG",
/* Linux path resolvers prefer $XDG_CONFIG_HOME over $HOME/.config;
* CI runners export it, so an isolated-process run resolved OUTSIDE
@@ -5189,18 +5233,21 @@ TEST(cli_durable_profiles_follow_current_vendor_paths) {
char cline_data_dir[512];
char kiro_home[512];
char vibe_home[512];
+ char grok_home[512];
snprintf(codex_home, sizeof(codex_home), "%s/vendor-codex", tmpdir);
snprintf(qwen_home, sizeof(qwen_home), "%s/vendor-qwen", tmpdir);
snprintf(copilot_home, sizeof(copilot_home), "%s/vendor-copilot", tmpdir);
snprintf(cline_data_dir, sizeof(cline_data_dir), "%s/vendor-cline-data", tmpdir);
snprintf(kiro_home, sizeof(kiro_home), "%s/vendor-kiro", tmpdir);
snprintf(vibe_home, sizeof(vibe_home), "%s/vendor-vibe", tmpdir);
+ snprintf(grok_home, sizeof(grok_home), "%s/vendor-grok", tmpdir);
test_mkdirp(codex_home);
test_mkdirp(qwen_home);
test_mkdirp(copilot_home);
test_mkdirp(cline_data_dir);
test_mkdirp(kiro_home);
test_mkdirp(vibe_home);
+ test_mkdirp(grok_home);
const char *const dirs[] = {
".claude",
@@ -5233,6 +5280,7 @@ TEST(cli_durable_profiles_follow_current_vendor_paths) {
cbm_setenv("CLINE_DATA_DIR", cline_data_dir, 1);
cbm_setenv("KIRO_HOME", kiro_home, 1);
cbm_setenv("VIBE_HOME", vibe_home, 1);
+ cbm_setenv("GROK_HOME", grok_home, 1);
char qwen_settings[640];
snprintf(qwen_settings, sizeof(qwen_settings), "%s/settings.json", qwen_home);
@@ -5264,6 +5312,10 @@ TEST(cli_durable_profiles_follow_current_vendor_paths) {
"/vendor-vibe/skills/codebase-memory/SKILL.md",
"/vendor-vibe/agents/codebase-memory.toml",
"/vendor-vibe/prompts/codebase-memory.md",
+ "/vendor-grok/skills/codebase-memory/SKILL.md",
+ "/vendor-grok/agents/codebase-memory.md",
+ "/vendor-grok/agents/codebase-memory-scout.md",
+ "/vendor-grok/agents/codebase-memory-auditor.md",
"/.config/kilo/agents/codebase-memory.md",
"/.factory/skills/codebase-memory/SKILL.md",
"/.factory/droids/codebase-memory.md",
@@ -5458,6 +5510,21 @@ TEST(cli_durable_profiles_follow_current_vendor_paths) {
free(profile);
snprintf(path, sizeof(path), "%s/prompts/codebase-memory.md", vibe_home);
files_ok = files_ok && test_file_contains_all(path, graph_terms, 3U);
+ snprintf(path, sizeof(path), "%s/skills/codebase-memory/SKILL.md", grok_home);
+ files_ok = files_ok && test_file_contains_all(path, graph_terms, 3);
+ snprintf(path, sizeof(path), "%s/agents/codebase-memory.md", grok_home);
+ const char *const grok_agent_terms[] = {
+ "name: codebase-memory\n",
+ "tools: read_file, grep, list_dir, search_tool, use_tool",
+ "mcpInheritance:\n named:\n - codebase-memory-mcp",
+ "codebase-memory-mcp__search_graph",
+ "codebase-memory-mcp__check_index_coverage",
+ "Tier 2"};
+ files_ok = files_ok && test_file_contains_all(path, grok_agent_terms, 6U);
+ profile = read_test_file_alloc(path);
+ files_ok = files_ok && profile && !strstr(profile, "codebase-memory-mcp__*") &&
+ !strstr(profile, "delete_project") && !strstr(profile, "manage_adr");
+ free(profile);
snprintf(path, sizeof(path), "%s/.factory/droids/codebase-memory.md", tmpdir);
const char *const factory_agent_terms[] = {"name: codebase-memory",
@@ -5906,6 +5973,147 @@ TEST(cli_tiered_vibe_installs_matching_agent_prompt_sets) {
PASS();
}
+/* Grok Build: config.toml table, owned rules file, skill, three graph agents
+ * with named-server inheritance; hooks withheld (its passive events discard
+ * stdout); uninstall removes exactly the owned state. */
+TEST(cli_tiered_grok_installs_profiles_and_withholds_hooks) {
+ char tmpdir[256];
+ snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-tiered-grok-XXXXXX");
+ if (!cbm_mkdtemp(tmpdir))
+ FAIL("cbm_mkdtemp failed");
+
+ char grok_home[512];
+ snprintf(grok_home, sizeof(grok_home), "%s/grok", tmpdir);
+ test_mkdirp(grok_home);
+ char *saved_home = save_test_env("HOME");
+ char *saved_path = save_test_env("PATH");
+ char *saved_grok = save_test_env("GROK_HOME");
+ cbm_setenv("HOME", tmpdir, 1);
+ cbm_setenv("PATH", tmpdir, 1);
+ cbm_setenv("GROK_HOME", grok_home, 1);
+
+ char config_path[640];
+ char rules_path[640];
+ char skill_path[640];
+ char hooks_dir[640];
+ snprintf(config_path, sizeof(config_path), "%s/config.toml", grok_home);
+ snprintf(rules_path, sizeof(rules_path), "%s/rules/codebase-memory.md", grok_home);
+ snprintf(skill_path, sizeof(skill_path), "%s/skills/codebase-memory/SKILL.md", grok_home);
+ snprintf(hooks_dir, sizeof(hooks_dir), "%s/hooks", grok_home);
+ /* A pre-existing user table must survive both install and uninstall. */
+ write_test_file(config_path, "[cli]\ninstaller = \"internal\"\n");
+
+ const char *const slugs[] = {
+ "codebase-memory-scout",
+ "codebase-memory",
+ "codebase-memory-auditor",
+ };
+ const char *const tier_markers[] = {"Tier 1", "Tier 2", "Tier 3"};
+ char agent_paths[3][640];
+ for (size_t i = 0U; i < 3U; i++) {
+ snprintf(agent_paths[i], sizeof(agent_paths[i]), "%s/agents/%s.md", grok_home, slugs[i]);
+ }
+
+ int install_rc = cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-mcp", false, false);
+ bool installed = install_rc == 0;
+ const char *const mcp_terms[] = {"[mcp_servers.codebase-memory-mcp]",
+ "command = \"/opt/codebase-memory-mcp\"", "args = []",
+ "installer = \"internal\""};
+ installed = installed && test_file_contains_all(config_path, mcp_terms, 4U);
+ const char *const rules_terms[] = {"search_graph", "trace_path", "check_index_coverage"};
+ installed = installed && test_file_contains_all(rules_path, rules_terms, 3U);
+ const char *const skill_terms[] = {"name: codebase-memory", "search_graph"};
+ installed = installed && test_file_contains_all(skill_path, skill_terms, 2U);
+ for (size_t i = 0U; installed && i < 3U; i++) {
+ char name_line[128];
+ snprintf(name_line, sizeof(name_line), "name: %s\n", slugs[i]);
+ char *agent = read_test_file_alloc(agent_paths[i]);
+ installed = agent && strstr(agent, name_line) && strstr(agent, tier_markers[i]) &&
+ strstr(agent, "tools: read_file, grep, list_dir, search_tool, use_tool") &&
+ strstr(agent, "mcpInheritance:\n named:\n - codebase-memory-mcp") &&
+ strstr(agent, "codebase-memory-mcp__check_index_coverage") &&
+ !strstr(agent, "index_repository") && !strstr(agent, "delete_project") &&
+ !strstr(agent, "manage_adr") && !strstr(agent, "ingest_traces");
+ free(agent);
+ }
+ struct stat state;
+ bool hooks_withheld = stat(hooks_dir, &state) != 0;
+ char *config = read_test_file_alloc(config_path);
+ size_t tables = 0U;
+ for (const char *at = config; at && (at = strstr(at, "[mcp_servers.codebase-memory-mcp]"));
+ at++) {
+ tables++;
+ }
+ bool single_table = tables == 1U;
+ free(config);
+
+ char *argv[] = {"uninstall", "--yes"};
+ int uninstall_rc = cli_test_cmd_uninstall(2, argv);
+ bool removed = uninstall_rc == 0;
+ for (size_t i = 0U; removed && i < 3U; i++) {
+ removed = stat(agent_paths[i], &state) != 0;
+ }
+ removed = removed && stat(skill_path, &state) != 0;
+ char *after = read_test_file_alloc(config_path);
+ removed = removed && after && !strstr(after, "codebase-memory-mcp") &&
+ strstr(after, "installer = \"internal\"");
+ free(after);
+ char *rules_after = read_test_file_alloc(rules_path);
+ removed = removed && (!rules_after || !strstr(rules_after, "search_graph"));
+ free(rules_after);
+
+ restore_test_env("HOME", saved_home);
+ restore_test_env("PATH", saved_path);
+ restore_test_env("GROK_HOME", saved_grok);
+ test_rmdir_r(tmpdir);
+ if (!installed)
+ FAIL("Grok Build must install config.toml table, rules, skill, and three graph agents");
+ if (!hooks_withheld)
+ FAIL("Grok Build must not receive hooks (passive events discard stdout)");
+ if (!single_table)
+ FAIL("Grok Build install must write exactly one MCP table");
+ if (!removed)
+ FAIL("Grok Build uninstall must remove exactly the owned state");
+ PASS();
+}
+
+/* A same-name table that is not ours (for example a remote url entry) must be
+ * left byte-identical: a second [mcp_servers.codebase-memory-mcp] header would
+ * make Grok reject the whole config.toml. */
+TEST(cli_grok_mcp_preserves_foreign_table) {
+ char tmpdir[256];
+ snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-grok-foreign-XXXXXX");
+ if (!cbm_mkdtemp(tmpdir))
+ FAIL("cbm_mkdtemp failed");
+
+ char grok_home[512];
+ snprintf(grok_home, sizeof(grok_home), "%s/.grok", tmpdir);
+ test_mkdirp(grok_home);
+ char *saved_path = save_test_env("PATH");
+ char *saved_grok = save_test_env("GROK_HOME");
+ cbm_setenv("PATH", tmpdir, 1);
+ cbm_unsetenv("GROK_HOME");
+
+ char config_path[640];
+ snprintf(config_path, sizeof(config_path), "%s/config.toml", grok_home);
+ const char *foreign = "[mcp_servers.codebase-memory-mcp]\n"
+ "url = \"https://mcp.example.com/mcp\"\n"
+ "headers = { \"Authorization\" = \"Bearer ${TOKEN}\" }\n";
+ write_test_file(config_path, foreign);
+
+ (void)cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-mcp", false, false);
+ char *after = read_test_file_alloc(config_path);
+ bool preserved = after && strcmp(after, foreign) == 0;
+ free(after);
+
+ restore_test_env("PATH", saved_path);
+ restore_test_env("GROK_HOME", saved_grok);
+ test_rmdir_r(tmpdir);
+ if (!preserved)
+ FAIL("Grok Build install must leave a foreign same-name MCP table byte-identical");
+ PASS();
+}
+
TEST(cli_junie_current_durable_context_contract) {
char tmpdir[256];
snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-junie-current-XXXXXX");
@@ -7381,6 +7589,48 @@ TEST(cli_codex_respects_codex_home) {
PASS();
}
+TEST(cli_grok_respects_grok_home) {
+ char tmpdir[256];
+ snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-grok-home-XXXXXX");
+ if (!cbm_mkdtemp(tmpdir))
+ FAIL("cbm_mkdtemp failed");
+ char grok_home[512];
+ snprintf(grok_home, sizeof(grok_home), "%s/custom-grok", tmpdir);
+ test_mkdirp(grok_home);
+ char *saved = save_test_env("GROK_HOME");
+ cbm_setenv("GROK_HOME", grok_home, 1);
+
+ cbm_detected_agents_t agents = cbm_detect_agents(tmpdir);
+ char *json = cbm_build_install_plan_json(tmpdir, "/usr/local/bin/codebase-memory-mcp");
+ const char *const suffixes[] = {
+ "/config.toml",
+ "/rules/codebase-memory.md",
+ "/skills/codebase-memory/SKILL.md",
+ "/agents/codebase-memory.md",
+ "/agents/codebase-memory-scout.md",
+ "/agents/codebase-memory-auditor.md",
+ };
+ bool planned = json != NULL;
+ for (size_t i = 0U; planned && i < sizeof(suffixes) / sizeof(suffixes[0]); i++) {
+ char expected[640];
+ snprintf(expected, sizeof(expected), "%s%s", grok_home, suffixes[i]);
+ planned = strstr(json, expected) != NULL;
+ }
+ /* Grok's passive hook events discard stdout, so no hook may be planned. */
+ bool no_hooks = json && !strstr(json, "custom-grok/hooks");
+
+ free(json);
+ restore_test_env("GROK_HOME", saved);
+ test_rmdir_r(tmpdir);
+
+ if (!agents.grok)
+ FAIL("Grok Build detection must honor GROK_HOME");
+ if (!planned || !no_hooks)
+ FAIL("Grok install plan must place config, rules, skill, and agents under GROK_HOME "
+ "and never plan a hook");
+ PASS();
+}
+
TEST(cli_gemini_session_hook_uses_json_for_all_sources) {
char tmpdir[256];
snprintf(tmpdir, sizeof(tmpdir), "/tmp/cli-gemini-session-XXXXXX");
@@ -13111,6 +13361,7 @@ SUITE(cli) {
RUN_TEST(cli_detect_agents_finds_claude);
RUN_TEST(cli_detect_agents_finds_claude_via_env);
RUN_TEST(cli_detect_agents_finds_codex);
+ RUN_TEST(cli_detect_agents_finds_grok);
RUN_TEST(cli_detect_agents_finds_cursor_issue222);
RUN_TEST(cli_install_plan_receipt_no_mutation_issue388);
RUN_TEST(cli_supported_agent_surfaces_match_installers);
@@ -13128,6 +13379,8 @@ SUITE(cli) {
RUN_TEST(cli_owned_durable_profiles_preserve_user_files);
RUN_TEST(cli_tiered_codex_profiles_migrate_preserve_and_uninstall);
RUN_TEST(cli_tiered_vibe_installs_matching_agent_prompt_sets);
+ RUN_TEST(cli_tiered_grok_installs_profiles_and_withholds_hooks);
+ RUN_TEST(cli_grok_mcp_preserves_foreign_table);
RUN_TEST(cli_junie_current_durable_context_contract);
RUN_TEST(cli_rovo_installs_documented_global_memory);
RUN_TEST(cli_hermes_stable_shell_context_contract);
@@ -13148,6 +13401,7 @@ SUITE(cli) {
RUN_TEST(cli_openclaw_resolves_active_json5_workspace);
RUN_TEST(cli_claude_user_scope_avoids_nested_mcp_json);
RUN_TEST(cli_codex_respects_codex_home);
+ RUN_TEST(cli_grok_respects_grok_home);
RUN_TEST(cli_gemini_session_hook_uses_json_for_all_sources);
RUN_TEST(cli_gemini_installs_dedicated_graph_subagent);
RUN_TEST(cli_antigravity_does_not_imply_gemini);