@camaradesuk/git-worktree-tools 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +307 -418
- package/dist/cli/cleanpr.test.js +2 -0
- package/dist/cli/cleanpr.test.js.map +1 -1
- package/dist/cli/newpr.js +48 -11
- package/dist/cli/newpr.js.map +1 -1
- package/dist/cli/newpr.test.js +33 -15
- package/dist/cli/newpr.test.js.map +1 -1
- package/dist/cli/wt/clean.d.ts +1 -0
- package/dist/cli/wt/clean.d.ts.map +1 -1
- package/dist/cli/wt/clean.js +11 -1
- package/dist/cli/wt/clean.js.map +1 -1
- package/dist/cli/wt/config.d.ts +1 -1
- package/dist/cli/wt/config.d.ts.map +1 -1
- package/dist/cli/wt/config.js +148 -13
- package/dist/cli/wt/config.js.map +1 -1
- package/dist/cli/wt/config.test.d.ts +5 -0
- package/dist/cli/wt/config.test.d.ts.map +1 -0
- package/dist/cli/wt/config.test.js +260 -0
- package/dist/cli/wt/config.test.js.map +1 -0
- package/dist/cli/wt/entry.test.js +11 -8
- package/dist/cli/wt/entry.test.js.map +1 -1
- package/dist/cli/wt/init.d.ts +14 -0
- package/dist/cli/wt/init.d.ts.map +1 -0
- package/dist/cli/wt/init.js +209 -0
- package/dist/cli/wt/init.js.map +1 -0
- package/dist/cli/wt/init.test.d.ts +5 -0
- package/dist/cli/wt/init.test.d.ts.map +1 -0
- package/dist/cli/wt/init.test.js +165 -0
- package/dist/cli/wt/init.test.js.map +1 -0
- package/dist/cli/wt/init.unit.test.d.ts +5 -0
- package/dist/cli/wt/init.unit.test.d.ts.map +1 -0
- package/dist/cli/wt/init.unit.test.js +432 -0
- package/dist/cli/wt/init.unit.test.js.map +1 -0
- package/dist/cli/wt/interactive-menu.d.ts +41 -0
- package/dist/cli/wt/interactive-menu.d.ts.map +1 -0
- package/dist/cli/wt/interactive-menu.js +639 -0
- package/dist/cli/wt/interactive-menu.js.map +1 -0
- package/dist/cli/wt/interactive-menu.test.d.ts +10 -0
- package/dist/cli/wt/interactive-menu.test.d.ts.map +1 -0
- package/dist/cli/wt/interactive-menu.test.js +711 -0
- package/dist/cli/wt/interactive-menu.test.js.map +1 -0
- package/dist/cli/wt/link.d.ts +9 -0
- package/dist/cli/wt/link.d.ts.map +1 -1
- package/dist/cli/wt/link.js +27 -0
- package/dist/cli/wt/link.js.map +1 -1
- package/dist/cli/wt/list.d.ts +2 -2
- package/dist/cli/wt/list.d.ts.map +1 -1
- package/dist/cli/wt/list.js +17 -17
- package/dist/cli/wt/list.js.map +1 -1
- package/dist/cli/wt/new.d.ts +7 -1
- package/dist/cli/wt/new.d.ts.map +1 -1
- package/dist/cli/wt/new.js +58 -6
- package/dist/cli/wt/new.js.map +1 -1
- package/dist/cli/wt/wt.test.js +159 -16
- package/dist/cli/wt/wt.test.js.map +1 -1
- package/dist/cli/wt.d.ts +2 -1
- package/dist/cli/wt.d.ts.map +1 -1
- package/dist/cli/wt.js +98 -3
- package/dist/cli/wt.js.map +1 -1
- package/dist/cli/wt.unit.test.d.ts +7 -0
- package/dist/cli/wt.unit.test.d.ts.map +1 -0
- package/dist/cli/wt.unit.test.js +182 -0
- package/dist/cli/wt.unit.test.js.map +1 -0
- package/dist/cli/wtconfig.js +18 -4
- package/dist/cli/wtconfig.js.map +1 -1
- package/dist/cli/wtconfig.test.js +18 -16
- package/dist/cli/wtconfig.test.js.map +1 -1
- package/dist/e2e/newpr/scenarios.e2e.test.js +7 -7
- package/dist/e2e/newpr/scenarios.e2e.test.js.map +1 -1
- package/dist/e2e/wt/wt.e2e.test.d.ts +9 -0
- package/dist/e2e/wt/wt.e2e.test.d.ts.map +1 -0
- package/dist/e2e/wt/wt.e2e.test.js +384 -0
- package/dist/e2e/wt/wt.e2e.test.js.map +1 -0
- package/dist/lib/ai/base-provider.d.ts +22 -0
- package/dist/lib/ai/base-provider.d.ts.map +1 -1
- package/dist/lib/ai/base-provider.js +180 -99
- package/dist/lib/ai/base-provider.js.map +1 -1
- package/dist/lib/ai/base-provider.test.js +13 -14
- package/dist/lib/ai/base-provider.test.js.map +1 -1
- package/dist/lib/ai/cli-provider.d.ts +11 -7
- package/dist/lib/ai/cli-provider.d.ts.map +1 -1
- package/dist/lib/ai/cli-provider.js +19 -49
- package/dist/lib/ai/cli-provider.js.map +1 -1
- package/dist/lib/ai/cli-provider.test.js +47 -49
- package/dist/lib/ai/cli-provider.test.js.map +1 -1
- package/dist/lib/ai/index.d.ts +2 -1
- package/dist/lib/ai/index.d.ts.map +1 -1
- package/dist/lib/ai/index.js +2 -0
- package/dist/lib/ai/index.js.map +1 -1
- package/dist/lib/ai/provider-manager.js +2 -2
- package/dist/lib/ai/provider-manager.js.map +1 -1
- package/dist/lib/ai/repo-docs.d.ts +43 -0
- package/dist/lib/ai/repo-docs.d.ts.map +1 -0
- package/dist/lib/ai/repo-docs.js +274 -0
- package/dist/lib/ai/repo-docs.js.map +1 -0
- package/dist/lib/ai/repo-docs.test.d.ts +5 -0
- package/dist/lib/ai/repo-docs.test.d.ts.map +1 -0
- package/dist/lib/ai/repo-docs.test.js +357 -0
- package/dist/lib/ai/repo-docs.test.js.map +1 -0
- package/dist/lib/ai/types.d.ts +18 -2
- package/dist/lib/ai/types.d.ts.map +1 -1
- package/dist/lib/ai/types.js.map +1 -1
- package/dist/lib/config-editor.d.ts +21 -0
- package/dist/lib/config-editor.d.ts.map +1 -0
- package/dist/lib/config-editor.js +729 -0
- package/dist/lib/config-editor.js.map +1 -0
- package/dist/lib/config-editor.test.d.ts +11 -0
- package/dist/lib/config-editor.test.d.ts.map +1 -0
- package/dist/lib/config-editor.test.js +526 -0
- package/dist/lib/config-editor.test.js.map +1 -0
- package/dist/lib/config-validation.d.ts +28 -0
- package/dist/lib/config-validation.d.ts.map +1 -0
- package/dist/lib/config-validation.js +534 -0
- package/dist/lib/config-validation.js.map +1 -0
- package/dist/lib/config-validation.test.d.ts +5 -0
- package/dist/lib/config-validation.test.d.ts.map +1 -0
- package/dist/lib/config-validation.test.js +398 -0
- package/dist/lib/config-validation.test.js.map +1 -0
- package/dist/lib/config.d.ts +115 -6
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +251 -55
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/config.test.js +2 -1
- package/dist/lib/config.test.js.map +1 -1
- package/dist/lib/constants.d.ts +50 -1
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +67 -1
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/constants.test.d.ts +5 -0
- package/dist/lib/constants.test.d.ts.map +1 -0
- package/dist/lib/constants.test.js +121 -0
- package/dist/lib/constants.test.js.map +1 -0
- package/dist/lib/git.d.ts +12 -0
- package/dist/lib/git.d.ts.map +1 -1
- package/dist/lib/git.js +26 -0
- package/dist/lib/git.js.map +1 -1
- package/dist/lib/global-check.d.ts +38 -0
- package/dist/lib/global-check.d.ts.map +1 -0
- package/dist/lib/global-check.js +135 -0
- package/dist/lib/global-check.js.map +1 -0
- package/dist/lib/global-check.test.d.ts +5 -0
- package/dist/lib/global-check.test.d.ts.map +1 -0
- package/dist/lib/global-check.test.js +153 -0
- package/dist/lib/global-check.test.js.map +1 -0
- package/dist/lib/global-config.d.ts +102 -0
- package/dist/lib/global-config.d.ts.map +1 -0
- package/dist/lib/global-config.js +234 -0
- package/dist/lib/global-config.js.map +1 -0
- package/dist/lib/global-config.test.d.ts +5 -0
- package/dist/lib/global-config.test.d.ts.map +1 -0
- package/dist/lib/global-config.test.js +282 -0
- package/dist/lib/global-config.test.js.map +1 -0
- package/dist/lib/logger.d.ts +175 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +475 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/logger.test.d.ts +5 -0
- package/dist/lib/logger.test.d.ts.map +1 -0
- package/dist/lib/logger.test.js +292 -0
- package/dist/lib/logger.test.js.map +1 -0
- package/dist/lib/lswt/action-executors.test.js +2 -0
- package/dist/lib/lswt/action-executors.test.js.map +1 -1
- package/dist/lib/newpr/args.d.ts.map +1 -1
- package/dist/lib/newpr/args.js +9 -2
- package/dist/lib/newpr/args.js.map +1 -1
- package/dist/lib/newpr/args.test.js +1 -1
- package/dist/lib/newpr/args.test.js.map +1 -1
- package/dist/lib/newpr/types.d.ts +2 -0
- package/dist/lib/newpr/types.d.ts.map +1 -1
- package/dist/lib/prompts.d.ts +6 -0
- package/dist/lib/prompts.d.ts.map +1 -1
- package/dist/lib/prompts.js +31 -9
- package/dist/lib/prompts.js.map +1 -1
- package/dist/lib/prompts.test.js +72 -1
- package/dist/lib/prompts.test.js.map +1 -1
- package/dist/lib/schema.test.d.ts +10 -0
- package/dist/lib/schema.test.d.ts.map +1 -0
- package/dist/lib/schema.test.js +309 -0
- package/dist/lib/schema.test.js.map +1 -0
- package/dist/lib/wtconfig/environment.d.ts.map +1 -1
- package/dist/lib/wtconfig/environment.js +6 -4
- package/dist/lib/wtconfig/environment.js.map +1 -1
- package/dist/lib/wtconfig/environment.test.js +2 -7
- package/dist/lib/wtconfig/environment.test.js.map +1 -1
- package/dist/lib/wtconfig/types.d.ts +3 -1
- package/dist/lib/wtconfig/types.d.ts.map +1 -1
- package/dist/lib/wtlink/manage-manifest.test.js +145 -7
- package/dist/lib/wtlink/manage-manifest.test.js.map +1 -1
- package/package.json +2 -1
- package/schemas/worktreerc.schema.json +416 -0
package/README.md
CHANGED
|
@@ -8,12 +8,14 @@ Cross-platform CLI tools for git worktree workflow management. Create PRs with d
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **Config Syncing
|
|
16
|
-
- **
|
|
11
|
+
- **Unified CLI** — Single `wt` command with interactive menu or subcommands
|
|
12
|
+
- **Cross-platform** — Works natively on Windows, macOS, and Linux (no bash/WSL required)
|
|
13
|
+
- **Smart State Detection** — Intelligently handles 10+ git scenarios (uncommitted changes, local commits, existing branches, etc.)
|
|
14
|
+
- **PR + Worktree Workflow** — Create PRs and dedicated worktrees in one command
|
|
15
|
+
- **Config Syncing** — Share gitignored config files (.env, .vscode, etc.) between worktrees via hard links
|
|
16
|
+
- **Three-Tier Configuration** — Global, repo, and local config with JSON schema validation
|
|
17
|
+
- **Structured Logging** — Configurable log levels with file output support
|
|
18
|
+
- **AI Tool Integration** — JSON output mode and programmatic API for AI agents
|
|
17
19
|
|
|
18
20
|
## Installation
|
|
19
21
|
|
|
@@ -30,60 +32,83 @@ npm install -g @camaradesuk/git-worktree-tools
|
|
|
30
32
|
## Quick Start
|
|
31
33
|
|
|
32
34
|
```bash
|
|
33
|
-
#
|
|
34
|
-
wt
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
wt
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
wtconfig init
|
|
35
|
+
# Interactive menu (recommended for exploration)
|
|
36
|
+
wt
|
|
37
|
+
|
|
38
|
+
# Create a new PR with worktree
|
|
39
|
+
wt new "Add user authentication feature"
|
|
40
|
+
|
|
41
|
+
# List worktrees with interactive selection
|
|
42
|
+
wt list
|
|
43
|
+
|
|
44
|
+
# Clean up merged/closed PRs
|
|
45
|
+
wt clean
|
|
46
|
+
|
|
47
|
+
# Initialize configuration
|
|
48
|
+
wt init
|
|
48
49
|
```
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
---
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
## The `wt` Command
|
|
53
54
|
|
|
54
|
-
The `wt` command provides
|
|
55
|
+
The unified `wt` command provides access to all git-worktree-tools functionality through an interactive menu or subcommands.
|
|
56
|
+
|
|
57
|
+
### Interactive Mode
|
|
58
|
+
|
|
59
|
+
Run `wt` without arguments to launch the interactive menu:
|
|
55
60
|
|
|
56
61
|
```bash
|
|
57
|
-
wt
|
|
62
|
+
wt
|
|
58
63
|
```
|
|
59
64
|
|
|
65
|
+
The menu provides guided workflows for:
|
|
66
|
+
|
|
67
|
+
- Creating new PRs (from description, existing PR, or current branch)
|
|
68
|
+
- Listing and navigating worktrees
|
|
69
|
+
- Cleaning up merged/closed PR worktrees
|
|
70
|
+
- Managing config file linking
|
|
71
|
+
- Viewing git state
|
|
72
|
+
- Editing configuration
|
|
73
|
+
|
|
74
|
+
### Subcommands
|
|
75
|
+
|
|
60
76
|
| Command | Alias | Description |
|
|
61
77
|
| -------------------- | -------- | ----------------------------------- |
|
|
78
|
+
| `wt` | - | Interactive main menu |
|
|
62
79
|
| `wt new <desc>` | `wt n` | Create a new PR with worktree |
|
|
63
80
|
| `wt list` | `wt ls` | List worktrees with PR status |
|
|
64
81
|
| `wt clean [pr]` | `wt c` | Clean up merged/closed PR worktrees |
|
|
65
82
|
| `wt link [cmd]` | `wt l` | Manage gitignored files via links |
|
|
66
83
|
| `wt state` | `wt s` | Query git worktree state |
|
|
67
84
|
| `wt config [cmd]` | `wt cfg` | Configuration management |
|
|
85
|
+
| `wt init` | - | Initialize configuration |
|
|
68
86
|
| `wt completion <sh>` | - | Generate shell completion scripts |
|
|
69
87
|
|
|
70
|
-
|
|
88
|
+
### Global Options
|
|
71
89
|
|
|
72
90
|
```bash
|
|
73
|
-
wt
|
|
74
|
-
wt
|
|
75
|
-
wt
|
|
91
|
+
wt -v # Verbose output (debug level)
|
|
92
|
+
wt -vv # Very verbose (trace level)
|
|
93
|
+
wt --debug # Debug output
|
|
94
|
+
wt -q, --quiet # Suppress non-essential output
|
|
95
|
+
wt --log-file FILE # Write logs to file
|
|
76
96
|
```
|
|
77
97
|
|
|
78
|
-
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Commands Reference
|
|
101
|
+
|
|
102
|
+
### wt new / newpr
|
|
79
103
|
|
|
80
104
|
Create a new PR with an associated worktree.
|
|
81
105
|
|
|
82
106
|
```bash
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
107
|
+
wt new "Description of the feature"
|
|
108
|
+
wt new --branch my-feature "Feature description"
|
|
109
|
+
wt new --pr 123 # Work on existing PR
|
|
110
|
+
wt new --draft "WIP feature"
|
|
111
|
+
wt new --install --code # Install deps and open editor
|
|
87
112
|
```
|
|
88
113
|
|
|
89
114
|
**Smart State Handling**: The tool detects your current git state and offers appropriate options:
|
|
@@ -93,131 +118,56 @@ newpr --draft "WIP feature"
|
|
|
93
118
|
- On a feature branch? Create PR for it or start new
|
|
94
119
|
- Detached HEAD? Create branch from current commit or main
|
|
95
120
|
|
|
96
|
-
###
|
|
97
|
-
|
|
98
|
-
Clean up worktrees for merged or closed PRs.
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
cleanpr # Interactive cleanup
|
|
102
|
-
cleanpr --all # Clean all merged/closed automatically
|
|
103
|
-
cleanpr --force # Force remove even if not merged
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### lswt
|
|
121
|
+
### wt list / lswt
|
|
107
122
|
|
|
108
123
|
List and manage git worktrees with an interactive interface.
|
|
109
124
|
|
|
110
125
|
```bash
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
lswt | cat # Automatically uses list mode when piped
|
|
126
|
+
wt list # Interactive mode (default in terminal)
|
|
127
|
+
wt ls --no-interactive # List-only mode
|
|
128
|
+
wt ls --status # Include PR status (requires gh cli)
|
|
129
|
+
wt ls --json # Output as JSON for scripting
|
|
130
|
+
wt ls --verbose # Show more details
|
|
117
131
|
```
|
|
118
132
|
|
|
119
|
-
**Interactive
|
|
120
|
-
|
|
121
|
-
When running in a TTY terminal, `lswt` enters interactive mode where you can select a worktree and perform actions:
|
|
122
|
-
|
|
123
|
-
| Shortcut | Action |
|
|
124
|
-
| -------- | ------------------------------------------ |
|
|
125
|
-
| `e` | Open in editor (VSCode or Cursor) |
|
|
126
|
-
| `t` | Open terminal at worktree path |
|
|
127
|
-
| `p` | Open PR in browser / Create PR from branch |
|
|
128
|
-
| `d` | Show worktree details |
|
|
129
|
-
| `c` | Copy path to clipboard |
|
|
130
|
-
| `l` | Link config files (via wtlink) |
|
|
131
|
-
| `r` | Remove worktree (not available for main) |
|
|
132
|
-
| `q` | Quit |
|
|
133
|
-
|
|
134
|
-
**Fuzzy search** — Press `/` to enter search mode and filter worktrees by:
|
|
135
|
-
|
|
136
|
-
- Branch name (`dark-mode`, `feat/auth`)
|
|
137
|
-
- PR number (`#42`, `42`)
|
|
138
|
-
- PR title (`Add dark mode`)
|
|
139
|
-
- PR state (`OPEN`, `MERGED`, `CLOSED`)
|
|
133
|
+
**Interactive Mode Shortcuts**:
|
|
140
134
|
|
|
141
|
-
|
|
135
|
+
| Key | Action |
|
|
136
|
+
| --- | ------------------------------------------ |
|
|
137
|
+
| `e` | Open in editor (VS Code or Cursor) |
|
|
138
|
+
| `t` | Open terminal at worktree path |
|
|
139
|
+
| `p` | Open PR in browser / Create PR from branch |
|
|
140
|
+
| `d` | Show worktree details |
|
|
141
|
+
| `c` | Copy path to clipboard |
|
|
142
|
+
| `l` | Link config files (via wtlink) |
|
|
143
|
+
| `r` | Remove worktree (not available for main) |
|
|
144
|
+
| `/` | Fuzzy search worktrees |
|
|
145
|
+
| `q` | Quit |
|
|
142
146
|
|
|
143
|
-
|
|
147
|
+
### wt clean / cleanpr
|
|
144
148
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
Interactive CLI for managing configuration file links between git worktrees. Share config files while keeping build artifacts separate using hard links and a manifest file.
|
|
149
|
+
Clean up worktrees for merged or closed PRs.
|
|
148
150
|
|
|
149
151
|
```bash
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
wtlink validate # Verify manifest integrity
|
|
152
|
+
wt clean # Interactive cleanup
|
|
153
|
+
wt clean --all # Clean all merged/closed automatically
|
|
154
|
+
wt clean --force # Force remove even if not merged
|
|
155
|
+
wt clean --dry-run # Preview what would be cleaned
|
|
155
156
|
```
|
|
156
157
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
# manage - Discover and manage the manifest
|
|
161
|
-
wtlink manage # Interactive mode
|
|
162
|
-
wtlink manage --non-interactive # Auto-add new files as commented
|
|
163
|
-
wtlink manage --clean # Remove stale entries automatically
|
|
164
|
-
wtlink manage --dry-run # Preview changes without writing
|
|
165
|
-
wtlink manage --backup # Create .wtlinkrc.bak before updating
|
|
158
|
+
### wt link / wtlink
|
|
166
159
|
|
|
167
|
-
|
|
168
|
-
wtlink link [source] [dest] # Link from source to destination
|
|
169
|
-
wtlink link --dry-run # Preview what would be linked
|
|
170
|
-
wtlink link --type symbolic # Use symlinks instead of hard links
|
|
171
|
-
wtlink link --yes # Skip confirmation prompts
|
|
160
|
+
Interactive CLI for managing configuration file links between git worktrees.
|
|
172
161
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
162
|
+
```bash
|
|
163
|
+
wt link # Interactive main menu
|
|
164
|
+
wt link manage # Interactive file browser
|
|
165
|
+
wt link link # Create hard links based on manifest
|
|
166
|
+
wt link link ../my-app.pr42 # Link to specific worktree
|
|
167
|
+
wt link validate # Verify manifest integrity
|
|
176
168
|
```
|
|
177
169
|
|
|
178
|
-
**
|
|
179
|
-
|
|
180
|
-
1. **Discover** — Scans for git-ignored files in your repository
|
|
181
|
-
2. **Decide** — Interactive UI to categorize each file (link, track, or skip)
|
|
182
|
-
3. **Link** — Creates hard links from main worktree to feature worktrees
|
|
183
|
-
4. **Validate** — Ensures manifest entries exist and remain git-ignored
|
|
184
|
-
|
|
185
|
-
**Interactive UI navigation:**
|
|
186
|
-
|
|
187
|
-
| Key | Action |
|
|
188
|
-
| --- | ------------------------------------------------ |
|
|
189
|
-
| ↑/↓ | Navigate file list |
|
|
190
|
-
| ←/→ | Navigate into/out of folders (hierarchical view) |
|
|
191
|
-
| A | Mark as "Will Link" (added to manifest) |
|
|
192
|
-
| C | Mark as "Track" (commented in manifest) |
|
|
193
|
-
| S | Mark as "Skip" (not in manifest) |
|
|
194
|
-
| 0 | Toggle showing undecided items |
|
|
195
|
-
| 1 | Toggle showing "Will Link" items |
|
|
196
|
-
| 2 | Toggle showing "Track" items |
|
|
197
|
-
| 3 | Toggle showing "Skip" items |
|
|
198
|
-
| V | Toggle hierarchical/flat view |
|
|
199
|
-
| ? | Show help |
|
|
200
|
-
| Q | Save and quit |
|
|
201
|
-
| X | Cancel without saving |
|
|
202
|
-
|
|
203
|
-
**Folder operations:** Actions on folders apply to all files inside. The UI shows a breakdown of child states for each folder.
|
|
204
|
-
|
|
205
|
-
**Safety confirmations:** Before linking, the tool shows source and destination worktrees with their branch names and warns about potentially dangerous operations:
|
|
206
|
-
|
|
207
|
-
- **Yellow warning** — Source is not on a base branch (main/master/develop). This is unusual since config files should typically flow from main to feature branches.
|
|
208
|
-
- **Red warning** — Destination is a base branch. This would overwrite your main worktree's config files, which is usually not intended.
|
|
209
|
-
|
|
210
|
-
The tool recognizes `main`, `master`, and `develop` as base branches. Use `--yes` to skip these confirmations if you're sure about your operation.
|
|
211
|
-
|
|
212
|
-
**Conflict detection:** When linking, if a file already exists at the destination with different content, you'll be prompted to:
|
|
213
|
-
|
|
214
|
-
- **Replace** — Delete destination and create link
|
|
215
|
-
- **Ignore** — Keep destination file as-is
|
|
216
|
-
- **Remove** — Remove entry from manifest
|
|
217
|
-
|
|
218
|
-
**Manifest format (`.wtlinkrc`):**
|
|
219
|
-
|
|
220
|
-
The manifest lives in your repository root and tracks which files to share:
|
|
170
|
+
**Manifest format (`.wtlink`):**
|
|
221
171
|
|
|
222
172
|
```text
|
|
223
173
|
.vscode/settings.json
|
|
@@ -227,237 +177,123 @@ The manifest lives in your repository root and tracks which files to share:
|
|
|
227
177
|
```
|
|
228
178
|
|
|
229
179
|
- Active entries (no `#`) are hard-linked between worktrees
|
|
230
|
-
- Commented entries (`#`) are tracked but not
|
|
231
|
-
- Files marked "Skip" are not added to the manifest at all
|
|
180
|
+
- Commented entries (`#`) are tracked but not linked
|
|
232
181
|
|
|
233
182
|
**Best practices:**
|
|
234
183
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
- `.vscode/settings.json`, `.editorconfig` — Editor config
|
|
238
|
-
- `.env.local`, `.env.development` — Local environment variables
|
|
239
|
-
- `certificates/`, `credentials/` — Local dev certificates
|
|
240
|
-
|
|
241
|
-
❌ **Not suitable for linking:**
|
|
184
|
+
- **Good for linking:** `.vscode/settings.json`, `.editorconfig`, `.env.local`, certificates
|
|
185
|
+
- **Not for linking:** `node_modules/`, `dist/`, `build/`, `.git/`
|
|
242
186
|
|
|
243
|
-
|
|
244
|
-
- `dist/`, `build/` — Build artifacts should be separate per worktree
|
|
245
|
-
- `.git/` — Never link git internals
|
|
187
|
+
See [wtlink documentation](#wtlink-details) for full details.
|
|
246
188
|
|
|
247
|
-
### wtstate
|
|
189
|
+
### wt state / wtstate
|
|
248
190
|
|
|
249
|
-
Query the current git state for AI agents and automation.
|
|
191
|
+
Query the current git state for AI agents and automation.
|
|
250
192
|
|
|
251
193
|
```bash
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
194
|
+
wt state # Human-readable output
|
|
195
|
+
wt state --json # Machine-readable JSON output
|
|
196
|
+
wt state --verbose # Include file lists and commit details
|
|
197
|
+
wt state --base dev # Specify base branch
|
|
256
198
|
```
|
|
257
199
|
|
|
258
200
|
**JSON output includes:**
|
|
259
201
|
|
|
260
|
-
- `scenario` —
|
|
261
|
-
- `
|
|
262
|
-
- `currentBranch` — Current branch name (null if detached HEAD)
|
|
263
|
-
- `baseBranch` — Base branch for comparison
|
|
202
|
+
- `scenario` — Git state scenario (e.g., `main_staged_same`)
|
|
203
|
+
- `currentBranch` — Current branch name
|
|
264
204
|
- `worktreeType` — Type: `main_worktree`, `pr_worktree`, or `other`
|
|
265
|
-
- `hasChanges`, `hasStagedChanges`, `hasUnstagedChanges` — Change flags
|
|
266
|
-
- `localCommits` — List of local commits not in origin
|
|
267
205
|
- `availableActions` — Actions available for this scenario
|
|
268
206
|
- `recommendedAction` — Suggested action to take
|
|
269
207
|
|
|
270
|
-
###
|
|
208
|
+
### wt config
|
|
271
209
|
|
|
272
|
-
Configuration management with
|
|
210
|
+
Configuration management with interactive editing.
|
|
273
211
|
|
|
274
212
|
```bash
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
213
|
+
wt config # Interactive config editor
|
|
214
|
+
wt cfg init # Run setup wizard (alias for wt init)
|
|
215
|
+
wt cfg show # Show current configuration
|
|
216
|
+
wt cfg set key value # Set a configuration value
|
|
217
|
+
wt cfg get key # Get a configuration value
|
|
218
|
+
wt cfg edit # Open config in default editor
|
|
219
|
+
wt cfg validate # Validate configuration
|
|
220
|
+
wt cfg schema # Show JSON schema URL
|
|
281
221
|
```
|
|
282
222
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
- Operating system and installed tools
|
|
286
|
-
- Git configuration (version, user, email)
|
|
287
|
-
- GitHub CLI authentication
|
|
288
|
-
- Available AI tools (Claude Code, Gemini CLI, Ollama)
|
|
289
|
-
- Package manager (npm, pnpm, yarn, bun)
|
|
290
|
-
- IDE availability (VS Code, Cursor)
|
|
291
|
-
|
|
292
|
-
**Configuration locations:**
|
|
293
|
-
|
|
294
|
-
- **Global:** `~/.worktreerc` (applies to all repos)
|
|
295
|
-
- **Repository:** `.worktreerc` or `.worktreerc.json` (repo-specific)
|
|
223
|
+
### wt init
|
|
296
224
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
**Example AI workflow:**
|
|
225
|
+
Initialize git-worktree-tools configuration.
|
|
300
226
|
|
|
301
227
|
```bash
|
|
302
|
-
#
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
#
|
|
306
|
-
ACTION=$(echo $STATE | jq -r '.data.recommendedAction')
|
|
307
|
-
|
|
308
|
-
# 3. Execute with chosen action
|
|
309
|
-
newpr "Add feature" --non-interactive --action=$ACTION --json
|
|
228
|
+
wt init # Interactive initialization
|
|
229
|
+
wt init --local # Create local config (gitignored)
|
|
230
|
+
wt init --global # Create global config
|
|
231
|
+
wt init --force # Overwrite existing config
|
|
310
232
|
```
|
|
311
233
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
All commands support `--json` for machine-readable output, enabling integration with AI CLI tools like Claude Code, Gemini CLI, and Codex.
|
|
234
|
+
---
|
|
315
235
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
### Quick Start for AI Agents
|
|
236
|
+
## Configuration
|
|
319
237
|
|
|
320
|
-
|
|
238
|
+
git-worktree-tools uses a three-tier configuration system:
|
|
321
239
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
ACTION=$(echo $STATE | jq -r '.data.recommendedAction')
|
|
240
|
+
| Level | File | Purpose | Git Status |
|
|
241
|
+
| ------ | ------------------------------------------ | -------------------- | ---------- |
|
|
242
|
+
| Local | `.worktreerc.local` | Personal overrides | gitignored |
|
|
243
|
+
| Repo | `.worktreerc` or `.worktreerc.json` | Shared team settings | committed |
|
|
244
|
+
| Global | `~/.config/git-worktree-tools/config.json` | User-wide defaults | N/A |
|
|
328
245
|
|
|
329
|
-
|
|
330
|
-
newpr "Add feature X" --non-interactive --action=$ACTION --json
|
|
331
|
-
```
|
|
246
|
+
**Merge order:** defaults ← global ← repo ← local
|
|
332
247
|
|
|
333
|
-
###
|
|
248
|
+
### Creating Configuration
|
|
334
249
|
|
|
335
250
|
```bash
|
|
336
|
-
#
|
|
337
|
-
|
|
338
|
-
newpr "Fix bug" --non-interactive --action=commit_staged --json
|
|
251
|
+
# Interactive setup (recommended)
|
|
252
|
+
wt init
|
|
339
253
|
|
|
340
|
-
#
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
# Link configs without prompts
|
|
345
|
-
wtlink link --yes --json
|
|
254
|
+
# Or create specific configs
|
|
255
|
+
wt init --global # User-wide defaults
|
|
256
|
+
wt init --local # Personal repo overrides
|
|
346
257
|
```
|
|
347
258
|
|
|
348
|
-
###
|
|
349
|
-
|
|
350
|
-
All commands return consistent JSON:
|
|
351
|
-
|
|
352
|
-
```typescript
|
|
353
|
-
interface CommandResult<T> {
|
|
354
|
-
success: boolean; // Whether the command succeeded
|
|
355
|
-
command: string; // Command name (e.g., "newpr", "cleanpr")
|
|
356
|
-
timestamp: string; // ISO 8601 timestamp
|
|
357
|
-
data?: T; // Command-specific data (on success)
|
|
358
|
-
error?: {
|
|
359
|
-
// Error details (on failure)
|
|
360
|
-
code: string; // Machine-readable error code
|
|
361
|
-
message: string; // Human-readable message
|
|
362
|
-
};
|
|
363
|
-
warnings?: string[]; // Non-fatal warnings
|
|
364
|
-
}
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
### Structured Error Codes
|
|
368
|
-
|
|
369
|
-
Error codes enable programmatic error handling:
|
|
370
|
-
|
|
371
|
-
| Code | Description |
|
|
372
|
-
| ---------------------- | ---------------------------- |
|
|
373
|
-
| `NOT_GIT_REPO` | Not inside a git repository |
|
|
374
|
-
| `GH_NOT_AUTHENTICATED` | GitHub CLI not authenticated |
|
|
375
|
-
| `INVALID_ACTION` | Invalid action for scenario |
|
|
376
|
-
| `HOOK_FAILED` | Lifecycle hook failed |
|
|
377
|
-
| `USER_CANCELLED` | Operation cancelled |
|
|
378
|
-
| `PR_CREATE_FAILED` | Failed to create PR |
|
|
379
|
-
|
|
380
|
-
See [docs/AI-TOOLING.md](docs/AI-TOOLING.md#structured-error-codes) for the complete list.
|
|
381
|
-
|
|
382
|
-
### Available Actions for `--action` Flag
|
|
383
|
-
|
|
384
|
-
| Action | Description |
|
|
385
|
-
| ---------------------------- | ------------------------------------------ |
|
|
386
|
-
| `empty_commit` | Create empty initial commit |
|
|
387
|
-
| `commit_staged` | Commit staged changes to new branch |
|
|
388
|
-
| `commit_all` | Stage all and commit to new branch |
|
|
389
|
-
| `stash_and_empty` | Stash changes, create empty commit |
|
|
390
|
-
| `use_commits` | Use local commits (branch from HEAD) |
|
|
391
|
-
| `push_then_branch` | Push to main first, then create branch |
|
|
392
|
-
| `use_commits_and_commit_all` | Include commits + commit uncommitted |
|
|
393
|
-
| `use_commits_and_stash` | Include commits, stash uncommitted |
|
|
394
|
-
| `create_pr_for_branch` | Create PR for existing branch |
|
|
395
|
-
| `pr_for_branch_commit_all` | Create PR for branch, commit changes first |
|
|
396
|
-
| `pr_for_branch_stash` | Create PR for branch, stash changes |
|
|
397
|
-
| `branch_from_detached` | Create branch from detached HEAD |
|
|
398
|
-
|
|
399
|
-
### Programmatic API
|
|
400
|
-
|
|
401
|
-
For deeper integration, use the programmatic API:
|
|
402
|
-
|
|
403
|
-
```typescript
|
|
404
|
-
import {
|
|
405
|
-
queryState,
|
|
406
|
-
listWorktrees,
|
|
407
|
-
cleanWorktrees,
|
|
408
|
-
createPr,
|
|
409
|
-
} from '@camaradesuk/git-worktree-tools';
|
|
410
|
-
|
|
411
|
-
// Query git state
|
|
412
|
-
const state = queryState({ baseBranch: 'main' });
|
|
413
|
-
if (state.success) {
|
|
414
|
-
console.log(`Scenario: ${state.data.scenario}`);
|
|
415
|
-
console.log(`Recommended: ${state.data.recommendedAction}`);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// Create PR
|
|
419
|
-
const result = await createPr({
|
|
420
|
-
description: 'Add dark mode',
|
|
421
|
-
action: 'commit_staged',
|
|
422
|
-
draft: true,
|
|
423
|
-
});
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
See [docs/AI-TOOLING.md](docs/AI-TOOLING.md#programmatic-api) for complete API documentation.
|
|
427
|
-
|
|
428
|
-
## Configuration
|
|
429
|
-
|
|
430
|
-
Create a `.worktreerc` file in your repository root, or use `wtconfig init` to generate one interactively:
|
|
259
|
+
### Example Configuration
|
|
431
260
|
|
|
432
261
|
```json
|
|
433
262
|
{
|
|
263
|
+
"$schema": "https://unpkg.com/@camaradesuk/git-worktree-tools/schemas/worktreerc.schema.json",
|
|
434
264
|
"baseBranch": "main",
|
|
435
265
|
"draftPr": true,
|
|
436
266
|
"branchPrefix": "feat",
|
|
267
|
+
"preferredEditor": "vscode",
|
|
437
268
|
"ai": {
|
|
438
269
|
"provider": "auto",
|
|
439
270
|
"branchName": true,
|
|
440
271
|
"prDescription": true
|
|
441
272
|
},
|
|
442
273
|
"hooks": {
|
|
443
|
-
"post-worktree": "npm install"
|
|
274
|
+
"post-worktree": ["npm install", "code ."]
|
|
275
|
+
},
|
|
276
|
+
"logging": {
|
|
277
|
+
"level": "info"
|
|
444
278
|
}
|
|
445
279
|
}
|
|
446
280
|
```
|
|
447
281
|
|
|
448
|
-
### Options
|
|
449
|
-
|
|
450
|
-
| Option | Type | Default | Description
|
|
451
|
-
| ----------------- | -------- | --------------------- |
|
|
452
|
-
| `
|
|
453
|
-
| `
|
|
454
|
-
| `
|
|
455
|
-
| `
|
|
456
|
-
| `
|
|
457
|
-
| `
|
|
458
|
-
| `preferredEditor` | string | `"vscode"` | Editor
|
|
459
|
-
| `
|
|
460
|
-
| `
|
|
282
|
+
### Configuration Options
|
|
283
|
+
|
|
284
|
+
| Option | Type | Default | Description |
|
|
285
|
+
| ----------------- | -------- | --------------------- | ------------------------------------------- |
|
|
286
|
+
| `baseBranch` | string | `"main"` | Base branch for new PRs |
|
|
287
|
+
| `draftPr` | boolean | `false` | Create PRs as drafts by default |
|
|
288
|
+
| `worktreePattern` | string | `"{repo}.pr{number}"` | Worktree directory naming pattern |
|
|
289
|
+
| `worktreeParent` | string | `".."` | Parent directory for worktrees |
|
|
290
|
+
| `branchPrefix` | string | `"feat"` | Prefix for auto-generated branch names |
|
|
291
|
+
| `sharedRepos` | string[] | `[]` | Sibling repos to also create worktrees for |
|
|
292
|
+
| `preferredEditor` | string | `"vscode"` | Editor: `"vscode"`, `"cursor"`, or `"auto"` |
|
|
293
|
+
| `syncPatterns` | string[] | `[]` | Patterns to sync between worktrees |
|
|
294
|
+
| `ai` | object | `{}` | AI content generation settings |
|
|
295
|
+
| `hooks` | object | `{}` | Lifecycle hook commands |
|
|
296
|
+
| `logging` | object | `{}` | Logging configuration |
|
|
461
297
|
|
|
462
298
|
### AI Content Generation
|
|
463
299
|
|
|
@@ -466,19 +302,20 @@ Enable AI-powered content generation for branch names and PR descriptions:
|
|
|
466
302
|
```json
|
|
467
303
|
{
|
|
468
304
|
"ai": {
|
|
469
|
-
"provider": "auto",
|
|
470
|
-
"branchName": true,
|
|
471
|
-
"prTitle": true,
|
|
472
|
-
"prDescription": true
|
|
305
|
+
"provider": "auto",
|
|
306
|
+
"branchName": true,
|
|
307
|
+
"prTitle": true,
|
|
308
|
+
"prDescription": true,
|
|
309
|
+
"commitMessage": true
|
|
473
310
|
}
|
|
474
311
|
}
|
|
475
312
|
```
|
|
476
313
|
|
|
477
|
-
|
|
314
|
+
**Providers:** `"auto"` (detects available tools), `"claude"`, `"gemini"`, `"openai"`, `"ollama"`, `"none"`
|
|
478
315
|
|
|
479
316
|
### Lifecycle Hooks
|
|
480
317
|
|
|
481
|
-
Run custom commands at various points in the
|
|
318
|
+
Run custom commands at various points in the workflow:
|
|
482
319
|
|
|
483
320
|
```json
|
|
484
321
|
{
|
|
@@ -487,110 +324,106 @@ Run custom commands at various points in the `newpr` workflow:
|
|
|
487
324
|
"post-pr": ["echo 'PR created!'", "./notify-team.sh"],
|
|
488
325
|
"pre-branch": {
|
|
489
326
|
"command": "npm test",
|
|
490
|
-
"failOnError": true
|
|
327
|
+
"failOnError": true,
|
|
328
|
+
"timeout": 60000
|
|
491
329
|
}
|
|
492
330
|
}
|
|
493
331
|
}
|
|
494
332
|
```
|
|
495
333
|
|
|
496
|
-
**Available hooks:**
|
|
334
|
+
**Available hooks:** `pre-analyze`, `post-analyze`, `pre-branch`, `post-branch`, `pre-commit`, `post-commit`, `pre-push`, `post-push`, `pre-pr`, `post-pr`, `pre-worktree`, `post-worktree`, `cleanup`
|
|
497
335
|
|
|
498
|
-
|
|
499
|
-
| --------------- | ------------------------- | -------- |
|
|
500
|
-
| `pre-analyze` | Before git state analysis | Yes |
|
|
501
|
-
| `post-analyze` | After state analysis | No |
|
|
502
|
-
| `pre-branch` | Before branch creation | Yes |
|
|
503
|
-
| `post-branch` | After branch creation | No |
|
|
504
|
-
| `pre-commit` | Before initial commit | Yes |
|
|
505
|
-
| `post-commit` | After initial commit | No |
|
|
506
|
-
| `pre-push` | Before push to origin | Yes |
|
|
507
|
-
| `post-push` | After push to origin | No |
|
|
508
|
-
| `pre-pr` | Before PR creation | Yes |
|
|
509
|
-
| `post-pr` | After PR creation | No |
|
|
510
|
-
| `pre-worktree` | Before worktree creation | Yes |
|
|
511
|
-
| `post-worktree` | After worktree creation | No |
|
|
512
|
-
| `cleanup` | On error (for rollback) | No |
|
|
336
|
+
**Hook context variables** (environment variables):
|
|
513
337
|
|
|
514
|
-
|
|
338
|
+
| Variable | Description |
|
|
339
|
+
| ------------------ | ----------------- |
|
|
340
|
+
| `WT_BRANCH_NAME` | New branch name |
|
|
341
|
+
| `WT_PR_NUMBER` | PR number |
|
|
342
|
+
| `WT_PR_URL` | PR URL |
|
|
343
|
+
| `WT_WORKTREE_PATH` | New worktree path |
|
|
344
|
+
| `WT_REPO_ROOT` | Main repo root |
|
|
345
|
+
| `WT_BASE_BRANCH` | Base branch |
|
|
346
|
+
| `WT_DESCRIPTION` | PR description |
|
|
515
347
|
|
|
516
|
-
|
|
348
|
+
### Logging Configuration
|
|
517
349
|
|
|
518
350
|
```json
|
|
519
351
|
{
|
|
520
|
-
"
|
|
521
|
-
|
|
522
|
-
"
|
|
523
|
-
|
|
524
|
-
// Multiple commands (run in sequence)
|
|
525
|
-
"post-pr": ["echo 'Done!'", "./scripts/notify.sh"],
|
|
526
|
-
|
|
527
|
-
// Complex definition
|
|
528
|
-
"pre-commit": {
|
|
529
|
-
"command": "npm test",
|
|
530
|
-
"timeout": 60000,
|
|
531
|
-
"failOnError": true,
|
|
532
|
-
"if": "exists:package.json"
|
|
533
|
-
}
|
|
352
|
+
"logging": {
|
|
353
|
+
"level": "info",
|
|
354
|
+
"logFile": "/path/to/logfile.log"
|
|
534
355
|
}
|
|
535
356
|
}
|
|
536
357
|
```
|
|
537
358
|
|
|
538
|
-
**
|
|
359
|
+
**Levels:** `silent`, `error`, `warn`, `info`, `debug`, `trace`
|
|
539
360
|
|
|
540
|
-
|
|
541
|
-
| ------------------ | ------------------ |
|
|
542
|
-
| `WT_BRANCH_NAME` | New branch name |
|
|
543
|
-
| `WT_PR_NUMBER` | PR number |
|
|
544
|
-
| `WT_PR_URL` | PR URL |
|
|
545
|
-
| `WT_WORKTREE_PATH` | New worktree path |
|
|
546
|
-
| `WT_REPO_ROOT` | Main repo root |
|
|
547
|
-
| `WT_BASE_BRANCH` | Base branch (main) |
|
|
548
|
-
| `WT_DESCRIPTION` | PR description |
|
|
361
|
+
CLI flags override config: `-v` (debug), `-vv` (trace), `-q` (silent), `--log-file`
|
|
549
362
|
|
|
550
|
-
|
|
363
|
+
---
|
|
551
364
|
|
|
552
|
-
##
|
|
365
|
+
## AI Tool Integration
|
|
366
|
+
|
|
367
|
+
All commands support `--json` for machine-readable output, enabling integration with AI CLI tools.
|
|
368
|
+
|
|
369
|
+
### Quick Start for AI Agents
|
|
553
370
|
|
|
554
371
|
```bash
|
|
555
|
-
#
|
|
556
|
-
|
|
372
|
+
# 1. Query current git state
|
|
373
|
+
STATE=$(wt state --json)
|
|
557
374
|
|
|
558
|
-
#
|
|
559
|
-
|
|
560
|
-
# → Creates branch: feat/add-dark-mode-support-xyz123
|
|
561
|
-
# → Creates PR: #42
|
|
562
|
-
# → Creates worktree: ~/projects/my-app.pr42
|
|
563
|
-
# → Switches to worktree
|
|
375
|
+
# 2. Extract recommended action
|
|
376
|
+
ACTION=$(echo $STATE | jq -r '.data.recommendedAction')
|
|
564
377
|
|
|
565
|
-
#
|
|
566
|
-
|
|
378
|
+
# 3. Execute with the chosen action
|
|
379
|
+
wt new "Add feature X" --non-interactive --action=$ACTION --json
|
|
380
|
+
```
|
|
567
381
|
|
|
568
|
-
|
|
569
|
-
cd ~/projects/my-app
|
|
570
|
-
newpr "Fix login bug"
|
|
571
|
-
# → Creates another worktree: ~/projects/my-app.pr43
|
|
382
|
+
### Non-Interactive Mode
|
|
572
383
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
# ~/projects/my-app.pr43 feat/fix-login-bug-abc456 #43 open
|
|
384
|
+
```bash
|
|
385
|
+
wt new "Feature" --non-interactive --json
|
|
386
|
+
wt clean --all --json
|
|
387
|
+
wt link link --yes --json
|
|
388
|
+
```
|
|
579
389
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
390
|
+
### JSON Response Schema
|
|
391
|
+
|
|
392
|
+
```typescript
|
|
393
|
+
interface CommandResult<T> {
|
|
394
|
+
success: boolean;
|
|
395
|
+
command: string;
|
|
396
|
+
timestamp: string;
|
|
397
|
+
data?: T;
|
|
398
|
+
error?: { code: string; message: string };
|
|
399
|
+
warnings?: string[];
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### Programmatic API
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
import { queryState, createPr, listWorktrees } from '@camaradesuk/git-worktree-tools';
|
|
407
|
+
|
|
408
|
+
const state = queryState({ baseBranch: 'main' });
|
|
409
|
+
const result = await createPr({
|
|
410
|
+
description: 'Add dark mode',
|
|
411
|
+
action: 'commit_staged',
|
|
412
|
+
draft: true,
|
|
413
|
+
});
|
|
584
414
|
```
|
|
585
415
|
|
|
416
|
+
See [docs/AI-TOOLING.md](docs/AI-TOOLING.md) for comprehensive AI integration documentation including error codes, available actions, and integration examples.
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
586
420
|
## Shell Completion
|
|
587
421
|
|
|
588
|
-
Enable tab completion for `wt` commands
|
|
422
|
+
Enable tab completion for `wt` commands:
|
|
589
423
|
|
|
590
424
|
### Bash
|
|
591
425
|
|
|
592
426
|
```bash
|
|
593
|
-
# Add to ~/.bashrc
|
|
594
427
|
wt completion bash >> ~/.bashrc
|
|
595
428
|
source ~/.bashrc
|
|
596
429
|
```
|
|
@@ -598,13 +431,9 @@ source ~/.bashrc
|
|
|
598
431
|
### Zsh
|
|
599
432
|
|
|
600
433
|
```bash
|
|
601
|
-
# Create completion directory and add completion
|
|
602
434
|
mkdir -p ~/.zsh/completions
|
|
603
435
|
wt completion zsh > ~/.zsh/completions/_wt
|
|
604
|
-
|
|
605
|
-
# Add to ~/.zshrc (if not already present)
|
|
606
|
-
fpath=(~/.zsh/completions $fpath)
|
|
607
|
-
autoload -Uz compinit && compinit
|
|
436
|
+
# Add to ~/.zshrc: fpath=(~/.zsh/completions $fpath)
|
|
608
437
|
```
|
|
609
438
|
|
|
610
439
|
### Fish
|
|
@@ -613,35 +442,95 @@ autoload -Uz compinit && compinit
|
|
|
613
442
|
wt completion fish > ~/.config/fish/completions/wt.fish
|
|
614
443
|
```
|
|
615
444
|
|
|
616
|
-
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
## wtlink Details
|
|
448
|
+
|
|
449
|
+
The `wtlink` command provides an interactive TUI for managing configuration file links.
|
|
450
|
+
|
|
451
|
+
### Interactive UI Navigation
|
|
452
|
+
|
|
453
|
+
| Key | Action |
|
|
454
|
+
| --- | ------------------------------------------------ |
|
|
455
|
+
| ↑/↓ | Navigate file list |
|
|
456
|
+
| ←/→ | Navigate into/out of folders (hierarchical view) |
|
|
457
|
+
| A | Mark as "Will Link" (added to manifest) |
|
|
458
|
+
| C | Mark as "Track" (commented in manifest) |
|
|
459
|
+
| S | Mark as "Skip" (not in manifest) |
|
|
460
|
+
| 0-3 | Toggle filter visibility |
|
|
461
|
+
| V | Toggle hierarchical/flat view |
|
|
462
|
+
| ? | Show help |
|
|
463
|
+
| Q | Save and quit |
|
|
464
|
+
| X | Cancel without saving |
|
|
465
|
+
|
|
466
|
+
### Command Options
|
|
617
467
|
|
|
618
468
|
```bash
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
469
|
+
# manage - Discover and manage the manifest
|
|
470
|
+
wtlink manage # Interactive mode
|
|
471
|
+
wtlink manage --non-interactive # Auto-add new files as commented
|
|
472
|
+
wtlink manage --clean # Remove stale entries
|
|
473
|
+
wtlink manage --dry-run # Preview changes
|
|
474
|
+
|
|
475
|
+
# link - Create links between worktrees
|
|
476
|
+
wtlink link [source] [dest] # Link from source to destination
|
|
477
|
+
wtlink link --dry-run # Preview what would be linked
|
|
478
|
+
wtlink link --type symbolic # Use symlinks instead of hard links
|
|
479
|
+
wtlink link --yes # Skip confirmation prompts
|
|
480
|
+
|
|
481
|
+
# validate - Check manifest integrity
|
|
482
|
+
wtlink validate # Validate against current worktree
|
|
622
483
|
```
|
|
623
484
|
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
## Example Workflow
|
|
488
|
+
|
|
489
|
+
```bash
|
|
490
|
+
# Start in your main repo
|
|
491
|
+
cd ~/projects/my-app
|
|
492
|
+
|
|
493
|
+
# Create a new feature PR
|
|
494
|
+
wt new "Add dark mode support"
|
|
495
|
+
# → Creates branch: feat/add-dark-mode-support-xyz123
|
|
496
|
+
# → Creates PR: #42
|
|
497
|
+
# → Creates worktree: ~/projects/my-app.pr42
|
|
498
|
+
# → Runs post-worktree hooks (npm install, etc.)
|
|
499
|
+
|
|
500
|
+
# Work on the feature in the dedicated worktree
|
|
501
|
+
# ... make changes, commit, push ...
|
|
502
|
+
|
|
503
|
+
# Need another feature? No problem!
|
|
504
|
+
cd ~/projects/my-app
|
|
505
|
+
wt new "Fix login bug"
|
|
506
|
+
# → Creates worktree: ~/projects/my-app.pr43
|
|
507
|
+
|
|
508
|
+
# List your worktrees
|
|
509
|
+
wt list
|
|
510
|
+
# Interactive selection with PR status
|
|
511
|
+
|
|
512
|
+
# After PRs are merged, clean up
|
|
513
|
+
wt clean
|
|
514
|
+
# → Removes worktrees for merged PRs
|
|
515
|
+
# → Deletes local branches
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
624
520
|
## Development
|
|
625
521
|
|
|
626
522
|
```bash
|
|
627
|
-
# Clone the repo
|
|
628
523
|
git clone https://github.com/camaradesuk/git-worktree-tools.git
|
|
629
524
|
cd git-worktree-tools
|
|
630
|
-
|
|
631
|
-
# Install dependencies
|
|
632
525
|
npm install
|
|
633
|
-
|
|
634
|
-
# Build
|
|
635
526
|
npm run build
|
|
636
|
-
|
|
637
|
-
# Test
|
|
638
527
|
npm test
|
|
639
|
-
|
|
640
|
-
# Link for local development
|
|
641
|
-
npm link
|
|
528
|
+
npm link # For local development
|
|
642
529
|
```
|
|
643
530
|
|
|
644
|
-
See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for detailed
|
|
531
|
+
See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for detailed development instructions.
|
|
532
|
+
|
|
533
|
+
---
|
|
645
534
|
|
|
646
535
|
## License
|
|
647
536
|
|