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