Skip to content

fix: make the Gemini adapters work against a real Gemini CLI - #89

Open
matheusPavaneli wants to merge 2 commits into
mainfrom
WB-62-make-the-gemini-cli-adapters
Open

matheusPavaneli wants to merge 2 commits into
mainfrom
WB-62-make-the-gemini-cli-adapters

Conversation

@matheusPavaneli

Copy link
Copy Markdown
Owner

What

WB-61's Gemini support, run against Gemini CLI 0.61.0, did not work: the hook never ran on Windows and wb run --agent gemini could not start or run wb. This fixes all four causes found.

Why

WB-62. Unit tests matched Gemini's documented formats. The live session showed what the docs leave out.

How

  • Hook on Windows: Gemini runs hooks in PowerShell, where "python.exe" "wb_hook.py" is a string, not a command. wb hooks install gemini now writes & "python.exe" ... on Windows.
  • Trust: untrusted, headless Gemini exits 55 and ignores project hooks. Sessions run with GEMINI_CLI_TRUST_WORKSPACE=true.
  • Shell: headless Gemini throws on a tool that would ask, and auto_edit leaves the shell asking. A policy file (.workflow/gemini-policy.toml) allows run_shell_command only for the session's python "<wb.py>". Gemini checks each command of a chain separately. yolo was rejected because it allows everything.
  • Prompt on stdin: npm installs gemini and codex as .cmd shims on Windows, and cmd.exe cuts an argument at the first newline. The multi-line prompt now goes on stdin (codex exec -, Gemini with a one-line -p). Claude Code and Cursor keep an empty stdin.

Verification

wb impl verify WB-62, verdict pass:

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

The new tests were run by hand against the previous commit in a scratch worktree, and every one failed there. wb impl verify --regression was not run: it needs the owner's approval to run plan commands.

Live, on Gemini CLI 0.61.0 with an API key:

  • An edit outside the audited plan was blocked with the plan's reason. A planned edit went through.
  • Hook payloads match the adapter: replace, tool_input.file_path, cwd, stop_hook_active.
  • Headless Gemini ran the wb command under the generated policy.
  • A multi-line prompt came back empty through the .cmd shim as an argument, and correct on stdin.

Risk and rollback

No critical zone touched. Rollback: revert the commit. Gemini goes back to the WB-61 behaviour. No data or config to migrate.

Open questions

  • End-to-end wb run --agent gemini did not finish. The free-tier quota (20 requests per model per day) ran out mid-test, so each fix was confirmed on its own.
  • Codex's stdin prompt (codex exec -) is documented but has not been run live.
  • Whether Cursor's CLI on Windows is a .cmd shim, or runs hooks through PowerShell, is unknown.

Running WB-61's Gemini adapters against Gemini CLI 0.61.0 found four
things the unit tests could not (WB-62):

- Gemini runs Windows hooks through PowerShell, where a quoted program
  is a string, so the command wb hooks install wrote never ran and
  every edit went through. It now carries the & call operator.
- wb run --agent gemini exited 55 in a folder Gemini had not trusted,
  and untrusted Gemini ignores project hooks. Sessions now run with
  GEMINI_CLI_TRUST_WORKSPACE=true.
- Headless Gemini refuses any tool that would ask, and auto_edit
  leaves the shell asking, so a session could never run wb. A policy
  file allows the session's wb invocation and nothing else, rather
  than yolo.
- npm installs gemini and codex as .cmd shims on Windows, and cmd.exe
  cuts an argument at its first newline. Both now get the prompt on
  stdin.

The Gemini report also carries the session_id it prints.
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