Skip to content

feat(agents): add grok adapter#120

Closed
yyovil wants to merge 2 commits into
agents/00-platformfrom
agents/01-grok
Closed

feat(agents): add grok adapter#120
yyovil wants to merge 2 commits into
agents/00-platformfrom
agents/01-grok

Conversation

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 6, 2026

Greptile Summary

This PR adds a Grok Build (xAI) agent adapter alongside registration in the adapter registry and a resolver test. Since Grok has a documented zero-config Claude Code compatibility layer, the implementation consciously delegates hook installation to claudecode.Plugin.GetAgentHooks, reuses the ao hooks claude-code <event> dispatch path, and reads the same ports.MetadataKey* constants for SessionInfo.

  • New grok.Plugin satisfies both adapters.Adapter and ports.Agent; uses -p for prompt delivery and -r for session restore via a hook-captured native session ID.
  • GetAgentHooks delegates entirely to claudecode.Plugin, writing hooks that fire as ao hooks claude-code <event> so the existing CLI dispatcher handles them with zero additional routing code.
  • Grok is registered in registry.Constructors() and the daemon wiring test verifies HarnessGrok resolves to manifest ID \"grok\".

Confidence Score: 5/5

Safe to merge; the change is an isolated new adapter with no effect on existing adapters or shared state.

The grok adapter is entirely additive: it adds a new package, a single line to the registry, and one entry to the wiring test. The delegation to claudecode.Plugin.GetAgentHooks is safe because that method is stateless with respect to the Plugin struct. Session metadata keys are sourced from the exported ports.Metadata* constants, matching the same constants used in claudecode.SessionInfo, so there is no hidden string coupling. Binary resolution, permission-mode mapping, and restore logic follow the same patterns as the existing adapters.

No files require special attention.

Important Files Changed

Filename Overview
backend/internal/adapters/agent/grok/grok.go New grok adapter implementing the full ports.Agent interface; binary resolution, permission-mode mapping, hook delegation to claudecode, and session restore are all well-structured and consistent with existing adapters.
backend/internal/adapters/agent/grok/grok_test.go Good unit-test coverage: manifest, config spec, prompt strategy, launch command (all permission modes), restore command (with and without session ID), SessionInfo (populated and empty), and hook delegation smoke-test.
backend/internal/adapters/agent/registry/registry.go Minimal, correct one-line registration of grok.New() in Constructors(); no issues.
backend/internal/daemon/wiring_test.go Adds {domain.HarnessGrok, "grok"} to the resolver table test; straightforward and correct.

Reviews (2): Last reviewed commit: "feat(agents): add grok adapter" | Re-trigger Greptile

Comment thread backend/internal/adapters/agent/grok/grok.go Outdated
yyovil and others added 2 commits June 6, 2026 08:08
…wlist

Introduces the shared platform that per-agent adapters plug into, wired for the
three shipped harnesses (claude-code, codex, opencode):

- adapters/agent/registry: single source of truth for shipped adapters
  (Constructors), consumed by the daemon to resolve a session's harness.
- adapters/agent/activitydispatch + 'ao hooks' command: maps an agent's native
  hook callbacks onto AO activity states (active/idle/waiting/...).
- claudecode/codex/opencode: emit SessionStart/UserPromptSubmit/Stop activity.
- HTTP + OpenAPI: report session activity state.
- db: single migration widening sessions.harness to all shipped harnesses, so
  adding an adapter needs no further migration.
- domain: harness constants + --agent alias for 'ao spawn'.

Adding a new agent is now one adapter package plus a line in Constructors().

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Registers the grok harness (xAI Grok CLI). grok installs Claude Code-compatible
hooks, so it reuses the claude-code activity deriver already in the platform.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yyovil yyovil force-pushed the agents/00-platform branch from da14c97 to ea78106 Compare June 6, 2026 03:31
@harshitsinghbhandari harshitsinghbhandari added this to the rewrite milestone Jun 6, 2026
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.

2 participants