Conversation
Branch created for: add a detector that can determine when old config layouts/schema are being used and suggest migration. Also improve how the hooks are implemented and how the wizard work with this (i.e. wizard should confirm the post-worktree hook action). Also the working directory for the post-worktree hook should default to the WORKTREE_PATH already. Should also add the ability to create an initial plan doc based off of the description using LLM CLI integration which can be part of the initial PR branch commit. 🤖 Created with newpr
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
==========================================
- Coverage 81.97% 81.71% -0.26%
==========================================
Files 72 77 +5
Lines 16631 18118 +1487
Branches 3688 3953 +265
==========================================
+ Hits 13633 14805 +1172
- Misses 2998 3313 +315 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add dependency injection pattern to environment detection and action execution modules to prevent VSCode from opening files during tests. Changes: - Add EnvironmentDeps interface to wtconfig/environment.ts - Add LswtEnvironmentDeps interface to lswt/environment.ts - Add openPathInEditor/openPathInTerminal to prs/actions.ts deps - Add wslPathToWindows to action-executors.ts deps - Update worktree-info files to use git.getStatusOutput() - Add reset functions for test isolation between test cases - Include spec documents for planned features All 1995 lib tests pass with proper mocking. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Previously createWorktreeForPr() used synthetic 'pr-<number>' branch names
instead of the actual PR branch (headBranch). This caused confusion as the
local branch didn't match the remote tracking branch.
- Changed branchName from `pr-${pr.number}` to pr.headBranch
- Updated error message to reference actual branch name
- Added explicit test for branch name requirement
- Created implementation spec document
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement comprehensive config migration system for detecting and migrating legacy configurations: - Add configVersion field to WorktreeConfig (current version: 1) - Create config-migration module with detector, runner, and reporter - Add 'wtconfig migrate' command with --dry-run, --yes, --json flags - Update 'wtlink migrate' to delegate with deprecation notice - Support detection of: missing version, legacy .wtlinkrc, unknown keys - Include Levenshtein-based typo suggestions for unknown keys - Atomic writes with backups in .worktree-backups/ directory - 54 unit tests covering migration scenarios Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…tion
- Add hook confirmation prompts for post-worktree, post-pr, post-push hooks
- Run/skip/edit options for interactive hook management
- CI environment detection to skip prompts in non-interactive contexts
- Add AI plan document generation with --plan/--no-plan flags
- YAML frontmatter with PR metadata
- Configurable path templates with {prNumber}, {slug}, {branch} variables
- Fix CWD bug: post-* hooks now correctly run in worktree directory
- Add resolveHookCwd() with smart defaults for worktree-aware hooks
- Add cwd property to complex hook definitions
- Reorganize spec docs: archive completed specs, consolidate active specs
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
On Windows, file handles may not be released immediately after close(), causing EPERM errors during test cleanup and file operations. - Add delay after fd.close() on Windows before rename in atomicWriteConfig - Add retry logic with exponential backoff in test afterEach cleanup Fixes Windows CI failures in config-migration/runner tests. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
On Windows, fs.promises.rename fails with EPERM when the source file was recently opened, even after calling fd.close(). The file handle release is not synchronous on Windows. Solution: On Windows, use copy+delete pattern instead of atomic rename: 1. Write content to temp file 2. Delete existing target (if exists) 3. Copy temp to target 4. Delete temp file This avoids the file locking issues while still maintaining atomic-like behavior (the target is only replaced after successful write). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The waitFor pattern was matching "Git Worktree Tools" in the header before menu items fully rendered, causing flaky test failures. Changed pattern from /worktree|main menu|select/i to /list worktree/i to wait specifically for menu items to render. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces intelligent config migration detection, enhanced post-worktree hook management with confirmation prompts, and AI-powered planning document generation. Additionally, it fixes critical bugs related to git operations and branch naming.
Changes:
- Config migration system with schema versioning, auto-detection, and guided migration
- Hook confirmation prompts for post-worktree/post-pr/post-push hooks with smart CWD defaults
- AI planning integration with LLM CLI tools for auto-generating plan documents
- Bug fixes: empty commit worktree creation, PR branch naming, and auto-link config files
Reviewed changes
Copilot reviewed 56 out of 58 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/config-migration/* | New migration system for detecting and fixing outdated configs |
| src/lib/hooks/confirmation.ts | New hook confirmation prompts for security-conscious workflows |
| src/lib/newpr/plan-generator.ts | AI-powered plan document generation with template variables |
| src/lib/prs/actions.ts | Fixed to use PR headBranch instead of synthetic pr- names |
| src/cli/newpr.ts | Fixed git operations to use repoRoot parameter, integrated plan generation |
| src/lib/config.ts | Added configVersion and linkConfigFiles properties |
| schemas/worktreerc.schema.json | Updated schema for new config properties |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Tests for Config Migration Detector | ||
| */ | ||
|
|
||
| import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; |
There was a problem hiding this comment.
Unused import vi.
| import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; | |
| import { describe, it, expect, beforeEach, afterEach } from 'vitest'; |
|
|
||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
| import { findRepoConfigFile, getSchemaUrl } from '../global-config.js'; |
There was a problem hiding this comment.
Unused import findRepoConfigFile.
| import fs from 'fs'; | ||
| import path from 'path'; | ||
| import { findRepoConfigFile, getSchemaUrl } from '../global-config.js'; | ||
| import { DEFAULT_MANIFEST_FILE } from '../constants.js'; |
There was a problem hiding this comment.
Unused import DEFAULT_MANIFEST_FILE.
| * Tests for Config Migration Runner | ||
| */ | ||
|
|
||
| import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; |
There was a problem hiding this comment.
Unused import vi.
- Extract CI environment variables to constant in confirmation.ts - Add AWS CodeBuild and Bitbucket Pipelines to CI detection - Refine empty catch blocks in runner.ts to specifically handle ENOENT - Add timeout configuration documentation with examples in executor.ts - Move completed spec 02-newpr-enhancements.md to archive with status badge Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
🎉 This PR is included in version 1.9.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
This PR delivers three major enhancements to git-worktree-tools:
Config Migration System - Automatically detect outdated
.worktreercschemas and guide users through migration with atomic writes, backups, and intelligent suggestions.Hook System Improvements - Fix critical CWD bug where post-* hooks executed in the main repo instead of the worktree, and add interactive confirmation wizard for hook review.
AI Plan Document Generation - Auto-generate implementation planning documents during PR creation with YAML frontmatter metadata and configurable path templates.
Features
Config Migration (
wtconfig migrate)configVersionfield (current: v1).wtlinkrcfiles, unknown/deprecated keys.worktree-backups/--dry-run,--yes,--jsonHook Confirmation Wizard
post-worktree,post-pr,post-pushhooksAI Plan Documents (
--plan/--no-plan){prNumber},{slug},{branch},{date},{timestamp}Bug Fixes
pr-<number>)Refactoring
Test Coverage
config-migration/*.test.ts(997 lines)hooks/confirmation.test.ts(424 lines)newpr/plan-generator.test.ts(531 lines)newpr/hook-runner.test.ts(190 lines)Breaking Changes
None. All changes are backward compatible.
Configuration Example
{ "configVersion": 1, "hooks": { "post-worktree": { "command": "npm install", "timeout": 180000, "cwd": "{{WORKTREE_PATH}}" } }, "ai": { "planDocument": true, "planPath": "docs/plans/PLAN-{prNumber}-{slug}.md" } }🤖 Generated with Claude Code