feat(dev): fix dot-worktree resolution, unique task files, and --agent/-a UX#458
feat(dev): fix dot-worktree resolution, unique task files, and --agent/-a UX#458basnijholt merged 4 commits intomainfrom
Conversation
basnijholt
left a comment
There was a problem hiding this comment.
[BUG] . resolves to the main checkout for nested worktrees
_find_worktree_for_cwd() currently returns the first worktree whose path prefixes the current directory. git worktree list reports the main checkout first, so when a worktree lives under the repo root (for example .worktrees/feature), the main repo matches before the nested worktree does.
That makes the new . behavior target the wrong checkout for the exact dot-worktree layout called out in this PR: dev agent ., dev path ., dev editor ., and dev rm . will all resolve to the main repo instead of the nested worktree.
Minimal repro:
- main repo:
/repo - worktree:
/repo/.worktrees/feature - cwd:
/repo/.worktrees/feature/src - current result:
/repo - expected result:
/repo/.worktrees/feature
Please pick the most specific matching worktree path instead of the first match, and add a regression test that uses a nested .worktrees/... layout.
[MINOR] docs/commands/dev.md still describes the old task-file behavior
The paragraph at docs/commands/dev.md:748 still says .claude/TASK.md reflects the most recent launch. After this patch each launch writes a unique TASK-{timestamp}-{hex}.md, so that note is now stale.
…ent/-a primary
- dev agent . resolves to current worktree via find_worktree_by_name
- write_prompt_to_worktree uses unique TASK-{ts}-{hex}.md filenames
- _create_prompt_wrapper_script uses mkstemp for unique script paths
- dev agent: --agent/-a is primary flag, --with-agent deprecated alias
- Updated help text, docs, skill documentation
- 7 new tests covering all fixes + race condition regression
Summary
dev agent .and other dev commands to resolve the current worktree viafind_worktree_by_name.claude/TASK-{timestamp}-{hex}.mdfiles to avoid parallel-launch collisionsmkstempfor unique prompt wrapper scripts--agent/-athe primary selector fordev agent, while keeping--with-agentas a deprecated aliasTesting
uv run pytest tests/dev/test_cli.py tests/dev/test_launch.py tests/dev/test_worktree.py