Skip to content

feat(installer): add Grok Build target#1324

Open
leihanchen wants to merge 1 commit into
colbymchenry:mainfrom
leihanchen:feat/grok_build_target
Open

feat(installer): add Grok Build target#1324
leihanchen wants to merge 1 commit into
colbymchenry:mainfrom
leihanchen:feat/grok_build_target

Conversation

@leihanchen

Copy link
Copy Markdown

Adds a Grok Build installer target so codegraph install auto-wires the CodeGraph MCP server into Grok Build. Grok Build becomes the 10th supported agent — joining Claude, Cursor, Codex, opencode, Hermes, Gemini, Antigravity, Kiro, and OpenClaw.

What is in this PR:

  • src/installer/targets/grok.ts (new) — implements AgentTarget for Grok Build:
    • Detects ~/.grok/config.toml (falls back to $GROK_HOME/config.toml)
    • Writes [mcp_servers.codegraph] TOML table with command = "codegraph" and args = ["serve", "--mcp"]
    • Supports both global (~/.grok/config.toml) and project-scoped (.grok/config.toml) installs
    • Respects GROK_HOME env var override for config directory
    • Surgical [mcp_servers.codegraph] write — preserves all sibling MCP servers and other top-level TOML sections ([cli], [models], [ui], [plugins], [marketplace], etc.)
    • Idempotent: byte-identical re-runs return action: "unchanged"
    • Uninstall drops only [mcp_servers.codegraph]; siblings and other sections intact
    • For local uninstall, removes .grok/config.toml and the empty .grok/ dir if only codegraph was present
    • Writes marker-fenced CodeGraph block to ~/.grok/AGENTS.md (global only) — subagents and non-MCP harnesses read AGENTS.md but never the MCP initialize instructions
    • No permissions concept — Grok gates tool invocations through its own UI
  • src/installer/targets/registry.ts — registers grokTarget
  • src/installer/targets/types.ts — extends TargetId union with "grok"
  • __tests__/installer-targets.test.ts — 13 new grok-specific tests (sibling preservation, top-level section preservation, idempotency, uninstall, local install, local uninstall cleanup, detect transitions, GROK_HOME override)
  • README.md — adds Grok Build to supported-agents badges and prose

Why Grok Build: Grok Build is xAI's CLI agent (https://x.ai) with a TOML-based config at ~/.grok/config.toml. It uses [mcp_servers.<name>] sections for MCP server entries — the same TOML format as Codex, so it reuses the existing toml.ts serializer. It also supports project-scoped config at .grok/config.toml, making it a natural fit for both install locations.

Test Results:

Suite Result
installer-targets (176 tests) all pass
Full suite (2084 tests) all pass
npm run build (tsc) clean
Live CLI smoke test (install → verify → idempotent re-run → uninstall → byte-equal round-trip) all pass

Notes:

  • Follows the same single-file-per-target + registry-entry + TargetId union pattern as the existing targets. Mirrors the Codex test scaffolding (TOML format, global-only instructions).
  • Reuses the existing TOML serializer (toml.ts) — no new dependency.
  • Docs reference: Grok MCP server config format is documented at ~/.grok/docs/user-guide/07-mcp-servers.md and ~/.grok/docs/user-guide/05-configuration.md.

Add Grok Build (xAI) as a supported installer target so codegraph
install auto-wires the CodeGraph MCP server into Grok's config.

- New src/installer/targets/grok.ts implementing AgentTarget for Grok
  - Config: ~/.grok/config.toml (global) or .grok/config.toml (local)
  - MCP format: [mcp_servers.codegraph] TOML table (same as Codex)
  - Supports both global and project-scoped installs
  - Respects GROK_HOME env var override
  - Writes marker-fenced CodeGraph block to ~/.grok/AGENTS.md (global)
  - No permissions concept (Grok gates through its own UI)
  - Idempotent: byte-equal re-runs return action='unchanged'
  - Uninstall preserves sibling MCP servers and other TOML sections
- Register grokTarget in registry.ts, add 'grok' to TargetId union
- 13 new tests in installer-targets.test.ts covering install, sibling
  preservation, top-level section preservation, idempotent re-run,
  uninstall, local install, detect transitions, and GROK_HOME override
- Update README.md with Grok Build in badges and agent lists
@leihanchen
leihanchen force-pushed the feat/grok_build_target branch from c11fc34 to 3c6041a Compare July 17, 2026 03:07
@leihanchen
leihanchen marked this pull request as ready for review July 17, 2026 03:08
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant