Skip to content

Add a Grok Build harness - #46

Merged
CrypticSwarm merged 6 commits into
masterfrom
grok-build-harness
Aug 24, 2026
Merged

Add a Grok Build harness#46
CrypticSwarm merged 6 commits into
masterfrom
grok-build-harness

Conversation

@CrypticSwarm

@CrypticSwarm CrypticSwarm commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Adds xAI's Grok Build CLI as a third harness, alongside OpenCode and Claude Code.

What's here

build_grok / run_grok / update_grok / stop_grok. The image installs the official CLI via x.ai/cli/install.sh in a grok AGENT branch and relocates the binary to /usr/local/bin/grok, dropping the root-side ~/.grok so the runtime config dir stays credential-only.

Persistent credentialed home, the Claude pattern. $(GROK_HOME_DIR) mounts at /home/anvil and keeps ~/.grok/ across runs. ~/.grok/skills and ~/.grok/commands are tmpfs masks over it, so the entrypoint repopulates them per run and per-repo assets never accumulate in the persistent home or leak between repos.

MCP tongs. A session with an mcp-interface tong previously refused to launch under run_grok, because no MCP emitter existed for the harness. The discovered servers are now emitted in Grok's native TOML shape — [mcp_servers.<name>], where a url key is what selects the remote transport — and delivered through the existing SWARMFORGE_TONG_MCP_FILE mount.

Grok's config dest is its persistent home rather than a directory rebuilt each run, so swarmforge/config/merge_grok_mcp.py keeps the generated servers in a sentinel-delimited managed block: rewritten every run, stripped when a session has no MCP tongs, and yielding to a same-named server the user defines themselves (appending it would be a TOML duplicate-table error). The entrypoint's tong merge is now dispatched per harness, which also stops the fragment from landing in an opencode.json inside a non-OpenCode config dest.

Two renames this pulls in

CLAUDE_REPO_SLUG / CLAUDE_REMOTE_NAME become SWARMFORGE_REPO_SLUG / SWARMFORGE_REMOTE_NAME. Both persistent-home harnesses use them, and neither should have to name Claude to do it. No fallback from the old names — an override under one is silently ignored, as with the OPENCODE_UID/OPENCODE_GID drop.

OPENCODE_INSTALL_BUST and CLAUDE_INSTALL_BUST collapse into one SWARMFORGE_HARNESS_INSTALL_BUST (first commit, so the Grok work uses it rather than adding a third). A build target names both the stage and the agent it installs, so the value only ever reaches that one install step; a name per harness was restating the target, and every new harness added another. make update_opencode and make update_claude are unchanged from the outside.

Not in scope

Subagent definitions are not translated for Grok — the unified-agent pipeline still covers OpenCode and Claude only, and the entrypoint's prepare_unified_agents falls through for the harness. Skills and commands travel the shared asset pipeline as usual.

A build target names both the stage and the agent it installs, so the value
only ever reaches that one install step. A name per harness read as a knob
per harness, and every new one added another.

SWARMFORGE_HARNESS_INSTALL_BUST replaces OPENCODE_INSTALL_BUST and
CLAUDE_INSTALL_BUST; `make update_opencode` and `make update_claude` are
unchanged from the outside, and an override under an old name is ignored.
Add containerized support for xAI's Grok Build CLI, mirroring the Claude
pattern: a persistent credentialed home, the harness's native skills dir,
and the stable repo-slug mount path.

- Dockerfile: install the official CLI via x.ai/cli/install.sh in a `grok`
  AGENT branch, relocate the binary to /usr/local/bin/grok, drop the
  root-side ~/.grok so the runtime config dir stays credential-only, and
  add a grok-runtime stage.
- Makefile: build_grok/update_grok/run_grok/stop_grok targets and the
  matching image/home/args vars; config dest ~/.grok with reset disabled
  so credentials persist across runs.
- entrypoint: deliver shared skills to Grok's native ~/.grok/skills and
  exclude skills/commands plus the host installer artifacts
  (bin/downloads/completions) from the layered config merge.

Rename the repo-slug mount knobs to SWARMFORGE_REPO_SLUG /
SWARMFORGE_REMOTE_NAME so every persistent-home harness shares them without
coupling Grok to Claude.
Add a Grok Build section to the README: the install, the persistent ~/.grok
home, AGENTS.md discovery, skills delivery, and config layering.

A third harness also makes the existing prose wrong wherever it named two.
Point those at every run_* target instead of enumerating, and give the
shared-asset destinations a Grok entry.
A session with an mcp-interface tong refused to launch under run_grok
because no MCP config emitter existed for the harness. Emit the discovered
servers as Grok's native TOML shape ([mcp_servers.<name>] with a url key
selecting the remote transport) and deliver them through the existing
SWARMFORGE_TONG_MCP_FILE mount.

Grok's config dest is its persistent home rather than a dir rebuilt each
run, so merge_grok_mcp keeps the generated servers in a sentinel-delimited
managed block: rewritten every run, stripped when a session has no MCP
tongs, and yielding to a same-named server the user defines themselves
(appending it would be a TOML duplicate-table error).

The entrypoint's tong merge is now dispatched per harness, which also stops
the fragment from being copied into an opencode.json inside a non-OpenCode
config dest.
Note the managed config.toml block, why it exists, and that a user-defined
server of the same name wins.
Docker's TTY default is TERM=xterm, so Grok hides truecolor themes and
diffs quantize onto a tiny ANSI palette. `-e TERM -e COLORTERM` copies
the host values through docker's passthrough, which reads run-anvil's
environment; the same env make inherited from the launching shell.
@CrypticSwarm CrypticSwarm added duplicate This issue or pull request already exists and removed duplicate This issue or pull request already exists labels Aug 24, 2026
@CrypticSwarm
CrypticSwarm merged commit 21237bf into master Aug 24, 2026
4 checks passed
@CrypticSwarm
CrypticSwarm deleted the grok-build-harness branch August 24, 2026 05:54
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