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

@leihanchen leihanchen commented Jul 17, 2026

Copy link
Copy Markdown

Adds a Grok Build installer target so codegraph install auto-wires the CodeGraph MCP server into Grok Build.

Closes #1347

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.

quickbeard added a commit to quickbeard/codegraph that referenced this pull request Jul 27, 2026
Adds spec-driven custom installer targets so agents without a built-in
target (opencode forks like CoDev Code colbymchenry#1272, Codex-shaped TOML agents
like Grok Build colbymchenry#1324) can be wired up with a small declarative spec
instead of a registry PR.

- Extract the opencode and codex targets into family factories
  (opencode-family.ts, toml-family.ts) — behavior-preserving, pinned by
  the existing 162-test installer contract suite. Add a third generic
  mcp-json family for standard mcpServers-JSON agents.
- targets/custom.ts: spec schema + validation (id shape, reserved
  words, builtin collisions, path-shape rules), tolerant loader
  (invalid specs skip with a warning, never crash the installer),
  strict add/remove persistence to ~/.codegraph/targets.json
  (CODEGRAPH_TARGETS_FILE override).
- Registry merges customs after built-ins; --target <id>/auto/all, the
  interactive multiselect, uninstall's sweep, and --print-config all
  see them with no further changes.
- CLI: codegraph targets add|list|remove.
- 30 new tests in __tests__/custom-targets.test.ts; design doc at
  docs/design/custom-installer-targets.md; CHANGELOG entry.
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.

add GROK BUILD support

1 participant