Skip to content

feat: run under Codex, Gemini CLI and Cursor, not only Claude Code - #88

Merged
matheusPavaneli merged 2 commits into
mainfrom
WB-61-make-workbench-agent-agnostic
Sep 28, 2026
Merged

matheusPavaneli merged 2 commits into
mainfrom
WB-61-make-workbench-agent-agnostic

Conversation

@matheusPavaneli

Copy link
Copy Markdown
Owner

What

workbench's skills, scope guard and headless runner now work under Claude Code, OpenAI Codex, Gemini CLI and Cursor. Claude Code behaviour is unchanged.

Why

WB-61. The CLI core was already agent-neutral, but its edges were not: skills called ${CLAUDE_PLUGIN_ROOT}/lib/wb.py, which only Claude Code substitutes; the hooks spoke only Claude Code's protocol; wb run could only start claude -p.

How

  • Skills call wb, falling back to ../../lib/wb.py relative to the skill. Claude Code already puts the plugin's bin/ on its shell's PATH, so nothing changes there. Kept to one line so no skill grows past the 80-line cap.
  • Hooks: the decision is made once in hooks.py (guard_edit, check_stop, paths in, reason out). hook_agents.py holds each agent's payload reading and answer shape. The Claude Code path still goes through the old pre_tool_use/stop, so its JSON is byte-identical and hooks/hooks.json is untouched.
  • Codex gets its own hooks/codex.json, named explicitly in .codex-plugin/plugin.json: Codex loads hooks/hooks.json when a manifest names no hooks, and that file is Claude's. apply_patch is checked path by path, resolved against the session's cwd; a patch touching one unplanned file is refused whole.
  • Gemini CLI has no extension manifest on purpose: an extension can only load hooks/hooks.json. Gemini and Cursor get skills from .agents/skills/ and hooks from wb hooks install gemini|cursor, which proposes first, merges only with --write, keeps foreign keys, and replaces its own entries on a rerun.
  • Cursor answers in its native permission: deny. It refuses a tool call whose hook answer is off-schema, so on an internal error its adapter prints nothing and reports on stderr. Its stop cannot block, so "hooks": "strict" sends one followup_message.
  • wb run --agent / run.agent, claude-code by default. Each report is normalised to the same run.json keys. Claude-only flags (--permission-mode, --plugin-dir, --setting-sources) are not handed to other agents.

Verification

wb impl verify WB-61, verdict pass, bound to the committed tree:

  • python -m unittest discover -s tests -q: exit 0 (1245 tests)
  • python -m ruff check lib: exit 0
  • python -m mypy: exit 0

Self-review (.workflow/WB-61/review.md) found one medium issue, fixed before commit: Codex patch paths were resolved against the repo root rather than the session's directory. Its regression test fails without the fix.

None of the three new agents is installed on the machine that ran this, so their adapters are tested against their documented formats, not against live sessions.

Risk and rollback

No critical zone touched. Rollback: revert the commit. Claude Code users see no change during or after. Gemini/Cursor configs written by wb hooks install would then call a wb_hook.py that ignores --agent and fails open, so nothing blocks.

Open questions

  • Cursor does not document the path field in a Write tool input; the adapter reads file_path, then path, and allows the edit if neither is there. Confirm on a real session before release.
  • Gemini's JSON stats.models.*.tokens subfields are not fully documented; usage sums whatever numeric fields it carries, cost stays empty.
  • No agent documents that relative paths in SKILL.md resolve from the skill directory; wb on PATH is the primary route for that reason.
  • .codex-plugin/plugin.json uses the compatibility location; Codex docs now prefer a root plugin.json with an extensions.com.openai block.
  • bench/ stays Claude-only by design: it measures workbench against plain Claude Code.

workbench's core was already agent-neutral; its edges were not. Skills
called ${CLAUDE_PLUGIN_ROOT}/lib/wb.py, which only Claude Code
substitutes, the hooks spoke only Claude Code's protocol, and wb run
could only start claude -p (WB-61).

Skills now call wb, falling back to lib/wb.py relative to the skill.
The scope guard decides once in hooks.py and each agent's payload and
answer shape lives in hook_agents.py: Codex's apply_patch is checked
path by path, Gemini denies with decision: deny, Cursor with
permission: deny. Claude Code's hook output is unchanged.

wb run --agent (or run.agent) picks claude-code, codex, gemini or
cursor, claude-code by default, and normalises each report into the
same run.json keys. wb hooks install gemini|cursor proposes the
project hook config and merges it with --write. A Codex plugin
manifest and marketplace ship alongside the Claude Code one, with its
own hooks/codex.json so Codex never loads the Claude-format file.
@matheusPavaneli
matheusPavaneli merged commit e0a4c34 into main Sep 28, 2026
10 checks passed
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