Repository navigation
Description
Description
just worktree-start (aliased as wt-start) has two preflight gaps that cause silent or confusing failures. Both should be caught early with clear diagnostics.
Problem 1: agent --print hangs during branch name derivation
agent --print (cursor-agent CLI 2026.02.13-41ac335) hangs indefinitely in headless mode regardless of model. Because the script uses set -euo pipefail, the failed command substitution on line 130 of justfile.worktree kills the script before the explicit error handler on line 138 ever runs.
Steps to Reproduce
- Ensure issue has no linked branch (e.g.
gh issue develop --list <issue>returns empty) - Run
just wt-start <issue> "/worktree_solve-and-pr" - The recipe reaches the
agent --printcall to derive a branch name summary agent --printhangs indefinitely, eventually the script fails
Actual Behavior
[*] No linked branch for issue #121. Creating one...
error: Recipe `worktree-start` failed with exit code 1
No indication of what failed.
Possible Solution
- Wrap the
agent --printcall intimeout 30(or similar) so it can't hang indefinitely - Capture the exit code explicitly instead of relying on
set -eto kill the script:SUMMARY=$(timeout 30 agent --print --yolo --trust --model "$MODEL" "..." | tail -1 | tr -d '[:space:]') || true
- Keep the existing guard (
if [ -z "$SUMMARY" ]) reachable so the diagnostic message and manual workaround instructions are printed
Problem 2: gh commands fail when multiple remotes exist (no default repo)
When a collaborator adds a fork as a second remote (e.g. origin + nacholiya), gh can no longer auto-detect which repository to target. All gh API calls (gh issue develop, gh issue view, gh repo view, etc.) fail with:
No default remote repository has been set. To learn more about the default repository, run: gh repo set-default --help
The recipe exits with exit code 1 and no further context.
Steps to Reproduce
- Add a second remote pointing to a fork:
git remote add myfork [email protected]:user/devcontainer - Run
just wt-start <issue> "/worktree_solve-and-pr" - The first
ghcommand fails with the "no default remote" error
Possible Solution
Add a preflight check near the existing prerequisites block:
- Run
gh repo set-default --viewto test if a default is set - If not, auto-resolve from
originremote (git remote get-url origin→ extractowner/repo) and rungh repo set-default owner/repo - Or fail with a clear message:
"Multiple remotes detected. Run: gh repo set-default <owner/repo>"
Expected Behavior (both problems)
- Clear, actionable error messages when something fails
- Manual workaround instructions included in the error output
- Preflight checks catch known failure modes before the main logic runs
Environment
- OS: macOS 24.5.0 (darwin, arm64)
- cursor-agent CLI: 2026.02.13-41ac335
- just: latest
- Shell: zsh
Acceptance Criteria
-
agent --printcall has a timeout; failure produces a clear error with manual workaround -
gh repo set-defaultis checked before anyghAPI calls; auto-resolved or error with instructions - Both failures tested manually by reproducing the conditions
Changelog Category
Fixed
Activity
[-][BUG] worktree-start silently fails when agent --print hangs during branch name derivation[/-][+][BUG] worktree-start preflight gaps — agent --print hang and gh repo set-default ambiguity[/+]gerchowl commentedon Feb 23, 2026
Design
Brainstorm: agents for branch naming — testing, local models, devcontainer.
Current State
justfile.worktree): When no linked branch exists,worktree-startusesagent --print --yolo --trust --model $(_read_model lightweight)to derive a kebab-case summary from the issue title.composer-1.5(Cursor API).worktree.batscoversresolve-branch.sh, tmux, and worktree-attach — but not the agent-based branch naming.1. How to Test Agent-Based Branch Naming
Option A: Unit-style tests with mock agent
scripts/derive-branch-summary.sh) that accepts issue title + rules path, callsagent --print, returns summary.BRANCH_SUMMARY_CMD="echo fix-login-bug"or similar.Option B: Snapshot / golden tests
Option C: Deterministic fallback + agent optional
tr '[:upper:]' '[:lower:]' | tr -s ' ' '-' | sed 's/^...//') as fallback.Option D: Contract tests
^[a-z0-9]+(-[a-z0-9]+)*$".2. Small Local Models in the Devcontainer
Candidates:
Integration options:
ollamaservice indocker-compose.project.yaml, mount model cache volume. Agent would need to call Ollama instead of Cursor API (or a custom script would).agent --printwith a script that callsollama run <model> "<prompt>"(or curl to Ollama API), parses last line as summary. No Cursor API for this step; fully local.Tradeoffs: Pros: no API key, no network, predictable latency, works offline. Cons: image size, startup time, memory; quality may be lower than cloud models for edge cases.
3. Putting Local Models into the Devcontainer
Minimal approach:
ollamaservice indocker-compose.project.yamlwith model cache volume.scripts/derive-branch-summary-ollama.shthat usesollama runor HTTP API.justfile.worktree, branch: useagent --printwhen CURSOR_API_KEY set, else use Ollama script when OLLAMA_HOST set or when running in devcontainer.Hybrid strategy: Default to Cursor API for best quality; fallback to Ollama when API unavailable (no key, offline); override via
BRANCH_NAMING_BACKEND=ollama.Testing with local models: In CI, either skip agent-based tests, use mock (
BRANCH_SUMMARY_CMD), or run a tiny Ollama model in a CI service container (slower, more complex).4. Suggested Path (YAGNI)
scripts/derive-branch-summary.shthat acceptsTITLEandNAMING_RULEpath, callsagent --print, returns summary.BRANCH_SUMMARY_CMDenv var to override the agent.gerchowl commentedon Feb 23, 2026
Implementation Plan
Issue: #154
Branch: bugfix/154-worktree-start-silent-fail-agent-print-hang
Tasks
justfile.worktree— verify:just --list | grep worktree-startscripts/derive-branch-summary.sh,justfile.worktree— verify:BRANCH_SUMMARY_CMD="echo test-summary" just worktree-start 154 "" 2>&1 | head -5(or existing worktree path)tests/bats/worktree.bats— verify:just test-bats(new test fails)scripts/derive-branch-summary.sh— verify:just test-bats(all pass)tests/bats/worktree.bats— verify:just test-bats(new test fails)scripts/derive-branch-summary.sh— verify:just test-bats(all pass)tests/bats/worktree.bats— verify:just test-bats(new test fails)justfile.worktree— verify:just test-bats(all pass)fix(worktree): add agent timeout and gh preflight to worktree-start
gerchowl commentedon Feb 23, 2026
Autonomous Run Complete
fix(worktree): add agent timeout and gh preflight to worktree-start (#…