Skip to content

feat(grok): add verified full native Grok Build support #2190

Description

@rechedev9

Pre-flight Checklist

🔍 Affected Area

Installation Pipeline

Secondary areas: CLI, TUI, Agent Detection, Catalog/Steps, SDD, MCP, permissions, sync, doctor, uninstall, and documentation.

💡 Problem Statement

Gentle AI does not currently manage Grok Build as a first-class native agent. Grok users cannot receive the same safe install, configuration, SDD, persistent memory, skills, project scope, diagnostics, sync, and uninstall lifecycle available for the other supported agents without relying on Claude compatibility or maintaining .grok files manually.

The integration also has correctness and safety constraints that a minimal path-only adapter does not cover:

  • Grok uses native commands, agents, skills, hooks, permissions, and TOML MCP configuration at both user and project scope.
  • Global and workspace files must not leak into OpenClaw or another adapter's workspace.
  • Generated files and named TOML tables need ownership semantics so install, sync, and uninstall preserve user edits and collisions.
  • Grok subagents use native frontmatter, tool names, MCP inheritance, and spawn_subagent; Claude-specific model routing and prompt vocabulary cannot be copied verbatim.
  • A partial uninstall must not leave global files, external workspace files, or Gentle AI state in a mixed transaction state.

📦 Proposed Solution

Add complete native Grok Build support with the following behavior.

Native adapter and product integration

  • Register Grok Build as a full-tier agent.
  • Detect an existing grok binary and ~/.grok configuration.
  • Add Grok to the catalog, TUI, installer, validation, doctor, state, sync, upgrade, and uninstall surfaces.
  • Configure Grok without executing its remote bootstrap installer.

Global and workspace layouts

  • Write global instructions to ~/.grok/AGENTS.md.
  • Write workspace instructions to <repo>/.grok/rules/gentle-ai.md.
  • Project native commands/, agents/, skills/, hooks/, and config.toml assets at the correct scope.
  • Reject workspace paths whose symlink ancestry escapes the repository.
  • Keep Grok and OpenClaw workspace destinations isolated.

SDD, Judgment Day, agents, and skills

  • Project 18 named agents into Grok-native frontmatter.
  • Install 10 native SDD commands.
  • Expose 11 public skills while keeping internal SDD executor documents out of Grok's public skill registry.
  • Use native tools and spawn_subagent with capability-specific permission modes.
  • Inherit the active Grok session model instead of emitting unsupported per-phase model or reasoning overrides.
  • Restrict MCP inheritance to the named Engram server where required.

MCP, permissions, hooks, and ownership

  • Configure Context7 and Engram through Grok-native TOML.
  • Preserve user TOML, comments, multiline strings, structural boundaries, and file modes.
  • Add native permission rules and the skill-registry startup hook.
  • Discover semantic Engram operations through Grok's native search_tool / use_tool bridge.
  • Use ownership digests for generated Markdown and managed TOML.
  • Preserve edited or unowned collisions instead of overwriting or deleting them.

Transactional uninstall

  • Snapshot global files, external workspace files, and Gentle AI state before uninstall.
  • Roll back Pi cleanup, late operation, state-read, and state-write failures.
  • Restore every snapshot entry best-effort and join restoration errors.
  • Preserve backup material and manual recovery instructions if rollback itself fails.

Deliberate boundaries

  • Users install the Grok CLI themselves; Gentle AI configures an existing runtime.
  • GGA and CodeGraph remain excluded because neither exposes a compatible Grok provider contract.
  • Grok inherits the active session model; no unsupported per-agent model overrides are invented.
  • gentle-ai sync --agent grok refreshes global managed configuration. Project-local configuration is refreshed by rerunning workspace install from that repository.

🔄 Alternatives Considered

  • Bounded adapter-only slice from feat: Grok CLI integration as native agent (MCP, SDD, skills, Engram, personas) #1739. Easier to review, but it leaves native SDD projection, project scope, permissions, hooks, ownership, and safe uninstall unresolved. The complete implementation is already built and verified as one coherent lifecycle.
  • Rely only on Grok's Claude compatibility. Useful for discovery, but it does not provide first-class Gentle AI ownership, native paths, project isolation, permissions, or deterministic uninstall behavior.
  • Reuse the generic Codex TOML strategy unchanged. The base format is similar, but Grok needs destination-specific table ownership, permission handling, multiline-string-safe scanning, and native MCP execution semantics.
  • Run Grok's remote bootstrap installer automatically. More convenient, but it makes Gentle AI execute a separate remote trust step. Manual CLI installation keeps that decision with the user.

📎 Additional Context

Published implementation

Verification

  • git diff --check, formatting checks, and go vet ./... completed successfully.
  • Candidate package, focused CLI, race-enabled backup, and race-enabled uninstall suites completed successfully.
  • Late-operation and post-state-write rollback cases passed 20 repeated runs.
  • Linux and Windows builds completed successfully.
  • Real Grok Build 0.2.118 global and workspace installations completed successfully.
  • grok inspect --json discovered the generated agents, commands, skills, instructions, permissions, hooks, and MCP configuration.
  • grok mcp doctor reported two healthy servers and zero failures.
  • Full uninstall removed 137 managed files and 69 managed directories without removing neighboring user content.
  • Mixed OpenClaw/Grok workspace, Judgment Day lifecycle, TOML preservation, idempotence, and ownership smokes completed successfully.
  • A four-lens native RDD reviewed the exact 103-path candidate with no CRITICAL or WARNING findings.
  • RDD lineage: review-ac926c99173a59ff.
  • RDD post-apply gate: allow.
  • Approved candidate tree: 4c727741b72775061469d8bc83a0e9f87a39ecbc.

Two unrelated host-baseline failures were reproduced outside the candidate: Git 2.34.1 on the verification server lacks git merge-tree --write-tree for internal/reviewtransaction, and one existing CLI reconciliation test reports receipt_scope_changed. No internal/reviewtransaction path is changed by this implementation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions