Skip to content

feat: delegate -w to gemini and qwen native worktree support#39

Merged
trieloff merged 2 commits into
mainfrom
feat/gemini-qwen-native-worktree
Jun 8, 2026
Merged

feat: delegate -w to gemini and qwen native worktree support#39
trieloff merged 2 commits into
mainfrom
feat/gemini-qwen-native-worktree

Conversation

@trieloff

@trieloff trieloff commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

What

The Gemini CLI (≥ 0.45) and Qwen Code (≥ 0.17) have both gained a native --worktree flag that creates and manages an isolated git worktree for the session — exactly the capability claude, grok, and droid already expose and that YOLO already delegates to.

This PR teaches YOLO to delegate -w to gemini's and qwen's built-in worktree support instead of creating its own .yolo/ worktree.

How it was discovered

The agents were installed via Homebrew/npm and were several versions behind. After updating them and re-checking --help:

Agent Old → New Native worktree flag
gemini (gemini-cli) 0.21.3 → 0.45.2 -w, --worktree"Start Gemini in a new git worktree. If no name is provided, one is generated automatically."
qwen (@qwen-code/qwen-code) 0.3.0 → 0.17.1 --worktree"Start the session inside a git worktree at <repoRoot>/.qwen/worktrees/<slug>/… On exit, the WorktreeExitDialog prompts to keep or remove."

The other agents were also updated and re-checked (codex, copilot, cursor-agent, opencode, kimi, crush, goose, pi, amp, auggie) — none of them gained git-worktree creation (they expose --add-dir / --cwd / session --fork only), so they continue to use YOLO-managed .yolo/ worktrees.

Behavior

yolo -w gemini "implement feature"   # → gemini --yolo -i implement feature --worktree
yolo -w qwen "refactor the parser"   # → qwen --yolo -i refactor the parser --worktree
  • The --worktree flag is appended bare and last (after the -i prompt) so each tool auto-generates the worktree name without consuming a following token as the name.
  • As with claude/grok/droid, the tool owns the worktree lifecycle, so YOLO's -c/--clean and -nc/--no-clean are ignored in this mode.
  • Single-agent runs only — multi-agent mode keeps using YOLO's own per-agent worktrees for pane/cleanup orchestration (unchanged).

Changes

  • executable_yolo: add gemini/qwen to the worktree-delegation exception list; append --worktree in the gemini|qwen case; update help text.
  • README.md: new "Native Worktree Delegation" table covering all five delegating agents.
  • test.sh: add delegation tests for gemini and qwen (10 new assertions, mirroring the claude/droid tests).

Testing

  • ./test.sh — the 10 new gemini/qwen assertions pass. The 3 remaining failures (aider, kimi) are pre-existing on main and unrelated to this change.
  • shellcheck executable_yolo test.shtest.sh clean; executable_yolo only shows two pre-existing SC2329 info notices on untouched functions.

🤖 Generated with Claude Code

The Gemini CLI (>=0.45) and Qwen Code (>=0.17) both gained a native
`--worktree` flag that creates and manages an isolated git worktree for
the session, just like claude/grok/droid already do. Detected by updating
the installed CLIs and re-checking their --help.

When `yolo -w gemini` / `yolo -w qwen` is requested, delegate worktree
management to the tool instead of creating a `.yolo/` worktree:

- gemini: appends `--worktree` (auto-generates a name)
- qwen:   appends `--worktree` (worktree under <repoRoot>/.qwen/worktrees/)

The flag is appended bare and last (after the `-i` prompt) so each tool
auto-generates the worktree name without consuming a following token.
As with the other native-delegation agents, yolo's -c/--clean and
-nc/--no-clean flags don't apply (the tool owns the lifecycle), and this
applies to single-agent runs only — multi-agent mode still uses yolo's
own per-agent worktrees for pane/cleanup orchestration.

Updates help text, README, and adds delegation tests for both agents.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Lars Trieloff <lars@trieloff.net>
Copilot AI review requested due to automatic review settings June 8, 2026 10:10

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d951f8ccb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread executable_yolo Outdated
local yolo_managed_worktree=false
if [[ "$use_worktree" == "true" ]]; then
if [[ "$command_name" == "claude" || "$command_name" == "grok" || "$command_name" == "droid" ]]; then
if [[ "$command_name" == "claude" || "$command_name" == "grok" || "$command_name" == "droid" || "$command_name" == "gemini" || "$command_name" == "qwen" ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep fallback worktrees when native mode is unavailable

In environments where Gemini's native worktree feature is not enabled, this branch skips create_worktree and only appends --worktree, so yolo -w gemini ... fails instead of using the existing .yolo/ fallback. The current Gemini CLI reference documents --worktree as requiring experimental.worktrees: true in settings (https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/cli-reference.md#cli-options), and older Gemini/Qwen versions also lack the flag, so please detect native support/config or keep these agents on YOLO-managed worktrees unless delegation is known to work.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates YOLO’s -w/--worktree behavior for gemini and qwen to delegate worktree creation/cleanup to each tool’s newly added native --worktree support, aligning them with existing delegation for claude, grok, and droid.

Changes:

  • Treat gemini and qwen as worktree-delegating agents (YOLO no longer creates .yolo/ worktrees for yolo -w gemini|qwen single-agent runs).
  • Append --worktree bare and last for gemini/qwen after -i <prompt> so the tools auto-generate the worktree name.
  • Add README documentation and test coverage verifying pass-through and “no YOLO-managed worktree” behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
executable_yolo Adds gemini/qwen to the worktree-delegation list; appends --worktree in the `gemini
README.md Documents native worktree delegation and updates supported-command notes for gemini/qwen.
test.sh Adds shared assertions + new tests validating delegation behavior for gemini and qwen.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread executable_yolo
Comment on lines +1713 to +1716
# gemini and qwen have native git worktree support; delegate to it
# when -w is requested rather than creating one with yolo's own logic.
# gemini: --worktree [name] (worktree under git's worktree dir)
# qwen: --worktree [slug] (worktree under <repoRoot>/.qwen/worktrees/)
Address automated review feedback on the gemini/qwen worktree delegation:

- gemini's `--worktree` is gated behind `experimental.worktrees: true` in its
  settings and errors out otherwise; older gemini/qwen builds lack the flag
  entirely. Delegating unconditionally would break `yolo -w gemini` where the
  previous `.yolo/` fallback worked (flagged by the Codex reviewer).

  Add `agent_native_worktree_ready()` + `gemini_worktrees_enabled()`: probe
  `<agent> --help` for `--worktree`, and for gemini also confirm the
  experimental setting (jq when available, conservative grep otherwise). When
  delegation isn't usable, fall back transparently to a yolo-managed `.yolo/`
  worktree. The case blocks now gate the native flag on `delegate_worktree` so
  the fallback path never passes `--worktree`.

- Fix a misleading code comment about gemini's worktree path (the docs don't
  specify a fixed location; flagged by the Copilot reviewer).

- Docs (help text + README) now describe gemini's experimental requirement and
  the graceful fallback.

- Tests: dummy agents now answer `--help`, the gemini test enables
  experimental.worktrees, and a new Test 13 asserts the fallback path
  (creates `.yolo/`, does not pass `--worktree`). Verified end-to-end against
  the real gemini 0.45.2 and qwen 0.17.1 binaries via --dry-run.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Lars Trieloff <lars@trieloff.net>

trieloff commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the reviews — both points were valid and are addressed in 51fe696.

@chatgpt-codex-connector (P2 — keep fallback when native mode unavailable): Confirmed empirically — gemini 0.45.2 exits with "The --worktree flag is only available when experimental.worktrees is enabled in your settings", and the official cli-reference says the same. So unconditional delegation would indeed break yolo -w gemini. Fixed by adding capability detection:

  • agent_native_worktree_ready() probes <agent> --help for --worktree, and for gemini additionally checks experimental.worktrees via gemini_worktrees_enabled() (jq when present, conservative grep fallback, reading workspace / git-root / $HOME settings).
  • When delegation isn't usable (older build without the flag, or gemini without the setting), yolo falls back to a .yolo/ worktree — the previous behavior — and does not pass --worktree. The command builders now gate the native flag on a single delegate_worktree decision so the two code paths can't disagree.
  • Verified against the real binaries: gemini-enabled → delegates; gemini-disabled → .yolo/ fallback; qwen (works out of the box) → delegates. New Test 13 locks in the fallback path.

Note: qwen's --worktree is not gated — it created .qwen/worktrees/<slug>/ immediately in testing — so it delegates whenever the flag is present.

@copilot — misleading worktree-path comment: Fixed. The Gemini docs don't actually specify a fixed location, so the comment is now non-committal (gemini manages the location) and notes the experimental requirement, rather than claiming a path.

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

  • Confirmed no additional code change is needed: the current HEAD already contains the review-feedback fixes described in the trigger.
  • Gemini native worktree delegation is now gated by both --worktree availability and experimental.worktrees being enabled via settings checks, with jq preferred and conservative grep fallback. executable_yoloL379-L420
  • The single-agent -w path now uses one delegate_worktree decision and falls back to a YOLO-managed .yolo/ worktree when native support is unavailable. executable_yoloL1664-L1688
  • The Gemini/Qwen command builder only appends --worktree when delegation was deemed usable, preventing the fallback path from passing an unsupported native flag. executable_yoloL1784-L1795
  • The misleading Gemini path comment is now non-committal about Gemini’s worktree location and notes the experimental settings requirement. executable_yoloL1787-L1789
  • README docs now describe Gemini as “managed by gemini” and document the graceful fallback behavior. README.mdL203-L220
  • Test 13 covers the disabled-Gemini-experimental-settings fallback path, including preserving .yolo/ fallback behavior and ensuring --worktree is not passed to Gemini. test.shL726-L782

No commit or new PR was created because the working tree had no necessary source changes after verification.

Testing

  • ./test.sh — all executable tests passed with 0 failures.
  • ⚠️ shellcheck executable_yolo test.sh — could not run because shellcheck is not installed in this environment.

View task →

@trieloff trieloff merged commit e156836 into main Jun 8, 2026
3 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.

3 participants