Milestone 2.1: Implement git_worktree_create tool (#4) #17
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "issue-4"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements the
git_worktree_createtool with full validation and error handling per issue #4 acceptance criteria.Changes
pi-worktree-create.tsmodule with pure, testable functions (no pi SDK deps)validateCreateWorktreeInput()— validates path and branch name parametersvalidatePathDoesNotExist()— refuses if target path exists (injectable for testing)isCurrentBranch()— prevents creating worktree on current branchbuildWorktreeAddCommand()— builds correct git command with-bflag supportcreateCreateWorktreeTool()in main extensionTesting
bun test .pi/extensions/*.test.ts)Checklist
Critical fixes: - Align create_branch schema description with runtime default (true) - Add ^ and . to branch name start-of-name validation regex Major fixes: - Move dynamic import('node:fs/promises') to static top-level import - Add integration tests for git_worktree_create execute flow - Use WorktreeError + formatValidationError for current-branch error Minor fixes: - Replace fragile .toContain() assertions with specific strings - Add 14 new tests for branch name start/end and dangerous char validation - Document resolveWorktreeTarget as dead code until switch/remove tools ship Suggestions implemented: - Reject leading dot in branch names (git compliance) - Extract formatSuccessResponse() helper for consistency