Skip to content

feat(types): add grok-build agent type (xAI Grok Build CLI)#216

Draft
fujibee wants to merge 2 commits into
mainfrom
feat/grok-build-type
Draft

feat(types): add grok-build agent type (xAI Grok Build CLI)#216
fujibee wants to merge 2 commits into
mainfrom
feat/grok-build-type

Conversation

@fujibee

@fujibee fujibee commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Adds an agmsg agent type for xAI's official Grok Build CLI (binary grok, from x.ai/cli), so Grok Build can join a team alongside Claude Code, Codex, Gemini, Cursor, and Hermes. Refs #214.

Disambiguation: the target is the official xAI Grok Build terminal agent, not the unrelated community superagent-ai/grok-cli.

Why this is small

Grok Build adopts Claude-Code-style hook conventions, so this is largely a manifest + path/detect remap on top of the manifest-driven type registry rather than new infrastructure. The Stop-hook delivery script (check-inbox.sh) is reused as-is for delivery; the only behavioral change to shared scripts is a vendor-neutral session-id resolver (see below).

What's in this PR

  • scripts/drivers/types/grok-build/type.conf (cli=grok, detect=GROK_SESSION_ID, delivery_modes="turn off" with default turn, hooks_file=.grok/hooks/agmsg.json), template.md (the /agmsg SKILL, modeled on the Copilot turn/off template), and _delivery.sh (writes a dedicated .grok/hooks/agmsg.json, Copilot file-ownership model).
  • scripts/session-start.sh / scripts/check-inbox.sh — session-id resolution now tries snake_case session_id (Claude) → camelCase sessionId (Grok Build / Cursor) → $GROK_SESSION_ID env. Additive and snake-first, so Claude Code behavior is unchanged. Without this, Grok's camelCase stdin would resolve empty and degrade to a synthesized id, breaking per-session dedup (Parallel claude --continue / --resume sessions share session_id, breaking actas lock distinctness #93) and the delivery watermark.
  • install.sh — ships the skill to ~/.grok/skills/<name>/SKILL.md, accepts --agent-type grok-build, and infers grok-build on --update from an existing grok-typed SKILL.md.
  • Tests — grok-build delivery (turn / off / reject monitor+both / status), session-id resolution (camelCase / env fallback / snake-still-wins), install (skill drop + --agent-type + --update), join, and the registry's nine-built-ins count.

Grok Build has no Monitor-tool equivalent, so there is no monitor/both mode (turn = Stop hook checks inbox between turns; off = manual). monitor mode can be added later if Grok can consume the watcher stream. spawn support is deferred.

Hook schema (confirmed on a real install)

The hook file path and JSON schema were confirmed against a real Grok Build install and xAI's local docs (~/.grok/docs/user-guide/10-hooks.md):

  • <project>/.grok/hooks/agmsg.json, nested Claude shape, no top-level version:
    { "hooks": { "Stop": [ { "hooks": [ { "type": "command", "command": "<abs path>", "timeout": 30 } ] } ] } }
  • command is the absolute check-inbox.sh path. Stop is a lifecycle event ("agent turn ends"), no matcher.
  • ~/.grok/hooks/*.json is always trusted (no prompt); a project .grok/hooks/agmsg.json requires /hooks-trust. Grok also reads .claude/settings.json in compat mode, but the dedicated .grok/hooks/ file is used to avoid compat-dependence / double-fire.

Verification

  • grok-build delivery + session-id resolution + install + join + registry tests: green.
  • Full bats suite: green.

Pending before merge: an end-to-end handoff smoke test on a real Grok Build session (grok session → team join → round-trip) — kept as draft until that passes.

Refs #214. (Intentionally not Closes — leave #214 open until the end-to-end handoff is verified.)

fujibee added 2 commits June 23, 2026 23:10
Add an agmsg agent type for xAI's official Grok Build CLI (binary 'grok',
x.ai/cli) so it can join a team alongside Claude Code, Codex, Gemini, Cursor,
and Hermes. Grok Build deliberately adopts Claude-Code-style conventions, so
this is a manifest + path/detect remap rather than new infrastructure — the
existing Stop-hook delivery script reads session_id from the hook input JSON on
stdin, which Grok Build emits the same way, so no env remap is needed.

- scripts/drivers/types/grok-build/{type.conf,template.md,_delivery.sh}: a
  turn/off type (no Monitor-tool equivalent, so delivery_modes='turn off',
  default turn). detect=GROK_SESSION_ID for whoami; cli=grok. The _delivery.sh
  writes a dedicated .grok/hooks/agmsg.json (copilot model).
- install.sh: ship the skill to ~/.grok/skills/<name>/ and accept
  --agent-type grok-build, both via the type registry.
- tests: grok-build delivery (turn/off/reject), install (skill drop +
  --agent-type), join, and the registry's nine-built-ins count.

C-GATED (#214): the hook filename and JSON schema in _delivery.sh and the
delivery tests are the assumed Claude-Code shape — xAI's official schema page
was not directly fetchable. They are scaffolded and must be confirmed against a
real install with 'grok inspect' before release; everything else (manifest,
template, whoami detect, install placement, join) is schema-independent.
Confirmed the Grok Build hook contract against a real install (xAI local
docs ~/.grok/docs/user-guide/10-hooks.md) and finalize the type:

- _delivery.sh: write the confirmed nested Claude hook shape
  { hooks: { Stop: [ { hooks: [ { type:command, command:<abs>, timeout:N } ] } ] } }
  at .grok/hooks/agmsg.json (no top-level version), command as the
  absolute check-inbox.sh path. Replaces the provisional copilot-flat scaffold.
- session-start.sh / check-inbox.sh: resolve the session id from snake_case
  session_id (Claude) -> camelCase sessionId (Grok Build / Cursor) ->
  $GROK_SESSION_ID env. Additive and snake-first, so claude-code is unchanged.
  Grok emits camelCase stdin, which previously degraded to a synthesized id
  and broke per-session dedup (#93) and the delivery watermark.
- type.conf: spawnable=yes. spawn.sh already launches direct-CLI types via
  `grok "/agmsg actas <name>"` and skips the readiness wait for monitor=no
  types, so no spawn.sh change is needed.
- install.sh: infer grok-build on --update from an existing grok-typed SKILL.md.
- tests: nested hook shape, session-id resolution (camelCase / env / snake-wins),
  status detection, --update inference, and grok-build in the spawnable set.

Refs #214.
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