Milestone 1.3: Implement git_worktree_list tool (#3) #16

Merged
david merged 2 commits from issue-3 into main 2026-07-24 13:11:09 +00:00

2 commits

Author SHA1 Message Date
David Kong
fc19b36cd8 fix: address all code review findings for issue-3
Critical fixes:
- Normalize path comparison with path.resolve() (Task 001)
- Add validation guards for malformed lines in parser (Task 002)

Major fixes:
- Extract tool definitions to factory functions (Task 003)
- Use WorktreeListResult interface with enriched metadata (Tasks 004, 010)
- Add unit tests for parseWorktreeList — 12 tests covering edge cases (Task 005)
- Return warning message when zero worktrees found (Task 006)

Minor fixes:
- Apply consistent JSDoc to all functions including factories (Task 007)
- Replace em-dash with ASCII separator for encoding safety (Task 008)
- Add section comments between tool factories and command registration (Task 009)

Suggestions implemented:
- Export parseWorktreeList in separate testable module (Task 011)
2026-07-24 23:01:40 +10:00
David Kong
fd607f511e feat: implement git_worktree_list tool
- Implement parseWorktreeList() to parse /home/david/Projects/extensions/pi-worktrees         e597520 [issue-1-tmp]
/home/david/Projects/extensions/pi-worktrees/issue-3 dd2202f [issue-3]
/home/david/Projects/extensions/pi-worktrees/main    dd2202f [main] output
  into structured WorktreeEntry[] with path, commit, branch, isCurrent
- Handle detached HEAD (no brackets → '(detached)')
- Wire the parser into git_worktree_list execute function
- Return formatted display text + structured details for downstream use
- Move tool definitions inside extension factory to capture  closure
- Add error handling with clear message when not in a git repo
2026-07-24 22:53:04 +10:00