feat: delegate -w to gemini and qwen native worktree support#39
Conversation
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>
There was a problem hiding this comment.
💡 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".
| 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 |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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
geminiandqwenas worktree-delegating agents (YOLO no longer creates.yolo/worktrees foryolo -w gemini|qwensingle-agent runs). - Append
--worktreebare and last forgemini/qwenafter-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.
| # 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>
|
Thanks for the reviews — both points were valid and are addressed in @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
Note: qwen's @copilot — misleading worktree-path comment: Fixed. The Gemini docs don't actually specify a fixed location, so the comment is now non-committal ( |
Summary
No commit or new PR was created because the working tree had no necessary source changes after verification. Testing
|
What
The Gemini CLI (≥ 0.45) and Qwen Code (≥ 0.17) have both gained a native
--worktreeflag that creates and manages an isolated git worktree for the session — exactly the capabilityclaude,grok, anddroidalready expose and that YOLO already delegates to.This PR teaches YOLO to delegate
-wto 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:gemini(gemini-cli)-w, --worktree— "Start Gemini in a new git worktree. If no name is provided, one is generated automatically."qwen(@qwen-code/qwen-code)--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--forkonly), so they continue to use YOLO-managed.yolo/worktrees.Behavior
--worktreeflag is appended bare and last (after the-iprompt) so each tool auto-generates the worktree name without consuming a following token as the name.-c/--cleanand-nc/--no-cleanare ignored in this mode.Changes
executable_yolo: addgemini/qwento the worktree-delegation exception list; append--worktreein thegemini|qwencase; 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 onmainand unrelated to this change.shellcheck executable_yolo test.sh—test.shclean;executable_yoloonly shows two pre-existingSC2329info notices on untouched functions.🤖 Generated with Claude Code