@camaradesuk/git-worktree-tools 1.6.0 → 1.8.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 +371 -421
- package/dist/cli/cleanpr.js +11 -5
- package/dist/cli/cleanpr.js.map +1 -1
- package/dist/cli/cleanpr.test.js +12 -1
- package/dist/cli/cleanpr.test.js.map +1 -1
- package/dist/cli/newpr.js +148 -39
- package/dist/cli/newpr.js.map +1 -1
- package/dist/cli/newpr.test.js +57 -21
- package/dist/cli/newpr.test.js.map +1 -1
- package/dist/cli/prs.d.ts +22 -0
- package/dist/cli/prs.d.ts.map +1 -0
- package/dist/cli/prs.js +275 -0
- package/dist/cli/prs.js.map +1 -0
- package/dist/cli/prs.test.d.ts +8 -0
- package/dist/cli/prs.test.d.ts.map +1 -0
- package/dist/cli/prs.test.js +408 -0
- package/dist/cli/prs.test.js.map +1 -0
- 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 +43 -0
- package/dist/cli/wt/interactive-menu.d.ts.map +1 -0
- package/dist/cli/wt/interactive-menu.js +656 -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 +736 -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/prs.d.ts +21 -0
- package/dist/cli/wt/prs.d.ts.map +1 -0
- package/dist/cli/wt/prs.js +251 -0
- package/dist/cli/wt/prs.js.map +1 -0
- package/dist/cli/wt/prs.test.d.ts +5 -0
- package/dist/cli/wt/prs.test.d.ts.map +1 -0
- package/dist/cli/wt/prs.test.js +410 -0
- package/dist/cli/wt/prs.test.js.map +1 -0
- 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 +3 -1
- package/dist/cli/wt.d.ts.map +1 -1
- package/dist/cli/wt.js +103 -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 +21 -16
- package/dist/cli/wtconfig.test.js.map +1 -1
- package/dist/cli/wtlink.d.ts +2 -1
- package/dist/cli/wtlink.d.ts.map +1 -1
- package/dist/cli/wtlink.js +41 -2
- package/dist/cli/wtlink.js.map +1 -1
- package/dist/e2e/cli.e2e.test.js +6 -2
- package/dist/e2e/cli.e2e.test.js.map +1 -1
- package/dist/e2e/helpers/cli-runner.d.ts.map +1 -1
- package/dist/e2e/helpers/cli-runner.js +1 -0
- package/dist/e2e/helpers/cli-runner.js.map +1 -1
- package/dist/e2e/helpers/gh-mock.d.ts.map +1 -1
- package/dist/e2e/helpers/gh-mock.js +55 -1
- package/dist/e2e/helpers/gh-mock.js.map +1 -1
- package/dist/e2e/helpers/pty-wrapper.d.ts +15 -0
- package/dist/e2e/helpers/pty-wrapper.d.ts.map +1 -1
- package/dist/e2e/helpers/pty-wrapper.js +65 -0
- package/dist/e2e/helpers/pty-wrapper.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/newpr-full-flow.e2e.test.js +1 -0
- package/dist/e2e/newpr-full-flow.e2e.test.js.map +1 -1
- package/dist/e2e/prs/prs.e2e.test.d.ts +7 -0
- package/dist/e2e/prs/prs.e2e.test.d.ts.map +1 -0
- package/dist/e2e/prs/prs.e2e.test.js +606 -0
- package/dist/e2e/prs/prs.e2e.test.js.map +1 -0
- package/dist/e2e/wt/interactive-menu.e2e.test.d.ts +8 -0
- package/dist/e2e/wt/interactive-menu.e2e.test.d.ts.map +1 -0
- package/dist/e2e/wt/interactive-menu.e2e.test.js +583 -0
- package/dist/e2e/wt/interactive-menu.e2e.test.js.map +1 -0
- 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 +597 -0
- package/dist/e2e/wt/wt.e2e.test.js.map +1 -0
- package/dist/integration/prs.integration.test.d.ts +8 -0
- package/dist/integration/prs.integration.test.d.ts.map +1 -0
- package/dist/integration/prs.integration.test.js +478 -0
- package/dist/integration/prs.integration.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 +590 -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 +149 -6
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +261 -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 +44 -0
- package/dist/lib/git.d.ts.map +1 -1
- package/dist/lib/git.js +121 -1
- package/dist/lib/git.js.map +1 -1
- package/dist/lib/git.test.js +118 -1
- package/dist/lib/git.test.js.map +1 -1
- package/dist/lib/github.d.ts +41 -0
- package/dist/lib/github.d.ts.map +1 -1
- package/dist/lib/github.js +109 -0
- package/dist/lib/github.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 +150 -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 +1 -0
- package/dist/lib/json-output.d.ts.map +1 -1
- package/dist/lib/json-output.js +2 -0
- package/dist/lib/json-output.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.d.ts.map +1 -1
- package/dist/lib/lswt/action-executors.js +2 -1
- package/dist/lib/lswt/action-executors.js.map +1 -1
- package/dist/lib/lswt/action-executors.test.js +3 -0
- package/dist/lib/lswt/action-executors.test.js.map +1 -1
- package/dist/lib/lswt/actions.d.ts +1 -0
- package/dist/lib/lswt/actions.d.ts.map +1 -1
- package/dist/lib/lswt/actions.js +38 -10
- package/dist/lib/lswt/actions.js.map +1 -1
- package/dist/lib/lswt/actions.test.js +34 -22
- package/dist/lib/lswt/actions.test.js.map +1 -1
- package/dist/lib/lswt/interactive.js +8 -8
- package/dist/lib/lswt/interactive.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 +39 -13
- 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/prs/actions.d.ts +70 -0
- package/dist/lib/prs/actions.d.ts.map +1 -0
- package/dist/lib/prs/actions.js +444 -0
- package/dist/lib/prs/actions.js.map +1 -0
- package/dist/lib/prs/actions.test.d.ts +5 -0
- package/dist/lib/prs/actions.test.d.ts.map +1 -0
- package/dist/lib/prs/actions.test.js +313 -0
- package/dist/lib/prs/actions.test.js.map +1 -0
- package/dist/lib/prs/data.d.ts +48 -0
- package/dist/lib/prs/data.d.ts.map +1 -0
- package/dist/lib/prs/data.js +171 -0
- package/dist/lib/prs/data.js.map +1 -0
- package/dist/lib/prs/data.test.d.ts +5 -0
- package/dist/lib/prs/data.test.d.ts.map +1 -0
- package/dist/lib/prs/data.test.js +417 -0
- package/dist/lib/prs/data.test.js.map +1 -0
- package/dist/lib/prs/details.d.ts +57 -0
- package/dist/lib/prs/details.d.ts.map +1 -0
- package/dist/lib/prs/details.js +246 -0
- package/dist/lib/prs/details.js.map +1 -0
- package/dist/lib/prs/details.test.d.ts +5 -0
- package/dist/lib/prs/details.test.d.ts.map +1 -0
- package/dist/lib/prs/details.test.js +325 -0
- package/dist/lib/prs/details.test.js.map +1 -0
- package/dist/lib/prs/filters.d.ts +56 -0
- package/dist/lib/prs/filters.d.ts.map +1 -0
- package/dist/lib/prs/filters.js +171 -0
- package/dist/lib/prs/filters.js.map +1 -0
- package/dist/lib/prs/filters.test.d.ts +5 -0
- package/dist/lib/prs/filters.test.d.ts.map +1 -0
- package/dist/lib/prs/filters.test.js +312 -0
- package/dist/lib/prs/filters.test.js.map +1 -0
- package/dist/lib/prs/formatters.d.ts +83 -0
- package/dist/lib/prs/formatters.d.ts.map +1 -0
- package/dist/lib/prs/formatters.js +389 -0
- package/dist/lib/prs/formatters.js.map +1 -0
- package/dist/lib/prs/formatters.test.d.ts +2 -0
- package/dist/lib/prs/formatters.test.d.ts.map +1 -0
- package/dist/lib/prs/formatters.test.js +387 -0
- package/dist/lib/prs/formatters.test.js.map +1 -0
- package/dist/lib/prs/interactive.d.ts +50 -0
- package/dist/lib/prs/interactive.d.ts.map +1 -0
- package/dist/lib/prs/interactive.js +453 -0
- package/dist/lib/prs/interactive.js.map +1 -0
- package/dist/lib/prs/interactive.test.d.ts +5 -0
- package/dist/lib/prs/interactive.test.d.ts.map +1 -0
- package/dist/lib/prs/interactive.test.js +364 -0
- package/dist/lib/prs/interactive.test.js.map +1 -0
- package/dist/lib/prs/types.d.ts +152 -0
- package/dist/lib/prs/types.d.ts.map +1 -0
- package/dist/lib/prs/types.js +17 -0
- package/dist/lib/prs/types.js.map +1 -0
- 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/config-manifest.d.ts +101 -0
- package/dist/lib/wtlink/config-manifest.d.ts.map +1 -0
- package/dist/lib/wtlink/config-manifest.js +219 -0
- package/dist/lib/wtlink/config-manifest.js.map +1 -0
- package/dist/lib/wtlink/config-manifest.test.d.ts +2 -0
- package/dist/lib/wtlink/config-manifest.test.d.ts.map +1 -0
- package/dist/lib/wtlink/config-manifest.test.js +460 -0
- package/dist/lib/wtlink/config-manifest.test.js.map +1 -0
- package/dist/lib/wtlink/link-configs.d.ts.map +1 -1
- package/dist/lib/wtlink/link-configs.js +36 -11
- package/dist/lib/wtlink/link-configs.js.map +1 -1
- package/dist/lib/wtlink/main-menu.d.ts.map +1 -1
- package/dist/lib/wtlink/main-menu.js +58 -50
- package/dist/lib/wtlink/main-menu.js.map +1 -1
- package/dist/lib/wtlink/main-menu.test.js +42 -40
- package/dist/lib/wtlink/main-menu.test.js.map +1 -1
- package/dist/lib/wtlink/manage-manifest.d.ts +9 -0
- package/dist/lib/wtlink/manage-manifest.d.ts.map +1 -1
- package/dist/lib/wtlink/manage-manifest.js +346 -25
- package/dist/lib/wtlink/manage-manifest.js.map +1 -1
- package/dist/lib/wtlink/manage-manifest.test.js +196 -7
- package/dist/lib/wtlink/manage-manifest.test.js.map +1 -1
- package/dist/lib/wtlink/validate-manifest.d.ts.map +1 -1
- package/dist/lib/wtlink/validate-manifest.js +27 -6
- package/dist/lib/wtlink/validate-manifest.js.map +1 -1
- package/package.json +2 -1
- package/schemas/worktreerc.schema.json +441 -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,88 @@ 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
|
-
|
|
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
|
+
# Browse all repository PRs
|
|
45
|
+
wt prs
|
|
46
|
+
|
|
47
|
+
# Clean up merged/closed PRs
|
|
48
|
+
wt clean
|
|
49
|
+
|
|
50
|
+
# Initialize configuration
|
|
51
|
+
wt init
|
|
48
52
|
```
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## The `wt` Command
|
|
51
57
|
|
|
52
|
-
|
|
58
|
+
The unified `wt` command provides access to all git-worktree-tools functionality through an interactive menu or subcommands.
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
### Interactive Mode
|
|
61
|
+
|
|
62
|
+
Run `wt` without arguments to launch the interactive menu:
|
|
55
63
|
|
|
56
64
|
```bash
|
|
57
|
-
wt
|
|
65
|
+
wt
|
|
58
66
|
```
|
|
59
67
|
|
|
68
|
+
The menu provides guided workflows for:
|
|
69
|
+
|
|
70
|
+
- Creating new PRs (from description, existing PR, or current branch)
|
|
71
|
+
- Listing and navigating worktrees
|
|
72
|
+
- Browsing all repository PRs and creating worktrees
|
|
73
|
+
- Cleaning up merged/closed PR worktrees
|
|
74
|
+
- Managing config file linking
|
|
75
|
+
- Viewing git state
|
|
76
|
+
- Editing configuration
|
|
77
|
+
|
|
78
|
+
### Subcommands
|
|
79
|
+
|
|
60
80
|
| Command | Alias | Description |
|
|
61
81
|
| -------------------- | -------- | ----------------------------------- |
|
|
82
|
+
| `wt` | - | Interactive main menu |
|
|
62
83
|
| `wt new <desc>` | `wt n` | Create a new PR with worktree |
|
|
63
84
|
| `wt list` | `wt ls` | List worktrees with PR status |
|
|
85
|
+
| `wt prs` | - | Browse all repository PRs |
|
|
64
86
|
| `wt clean [pr]` | `wt c` | Clean up merged/closed PR worktrees |
|
|
65
87
|
| `wt link [cmd]` | `wt l` | Manage gitignored files via links |
|
|
66
88
|
| `wt state` | `wt s` | Query git worktree state |
|
|
67
89
|
| `wt config [cmd]` | `wt cfg` | Configuration management |
|
|
90
|
+
| `wt init` | - | Initialize configuration |
|
|
68
91
|
| `wt completion <sh>` | - | Generate shell completion scripts |
|
|
69
92
|
|
|
70
|
-
|
|
93
|
+
### Global Options
|
|
71
94
|
|
|
72
95
|
```bash
|
|
73
|
-
wt
|
|
74
|
-
wt
|
|
75
|
-
wt
|
|
96
|
+
wt -v # Verbose output (debug level)
|
|
97
|
+
wt -vv # Very verbose (trace level)
|
|
98
|
+
wt --debug # Debug output
|
|
99
|
+
wt -q, --quiet # Suppress non-essential output
|
|
100
|
+
wt --log-file FILE # Write logs to file
|
|
76
101
|
```
|
|
77
102
|
|
|
78
|
-
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Commands Reference
|
|
106
|
+
|
|
107
|
+
### wt new / newpr
|
|
79
108
|
|
|
80
109
|
Create a new PR with an associated worktree.
|
|
81
110
|
|
|
82
111
|
```bash
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
112
|
+
wt new "Description of the feature"
|
|
113
|
+
wt new --branch my-feature "Feature description"
|
|
114
|
+
wt new --pr 123 # Work on existing PR
|
|
115
|
+
wt new --draft "WIP feature"
|
|
116
|
+
wt new --install --code # Install deps and open editor
|
|
87
117
|
```
|
|
88
118
|
|
|
89
119
|
**Smart State Handling**: The tool detects your current git state and offers appropriate options:
|
|
@@ -93,371 +123,233 @@ newpr --draft "WIP feature"
|
|
|
93
123
|
- On a feature branch? Create PR for it or start new
|
|
94
124
|
- Detached HEAD? Create branch from current commit or main
|
|
95
125
|
|
|
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
|
|
126
|
+
### wt list / lswt
|
|
107
127
|
|
|
108
128
|
List and manage git worktrees with an interactive interface.
|
|
109
129
|
|
|
110
130
|
```bash
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
lswt | cat # Automatically uses list mode when piped
|
|
131
|
+
wt list # Interactive mode (default in terminal)
|
|
132
|
+
wt ls --no-interactive # List-only mode
|
|
133
|
+
wt ls --status # Include PR status (requires gh cli)
|
|
134
|
+
wt ls --json # Output as JSON for scripting
|
|
135
|
+
wt ls --verbose # Show more details
|
|
117
136
|
```
|
|
118
137
|
|
|
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`)
|
|
138
|
+
**Interactive Mode Shortcuts**:
|
|
140
139
|
|
|
141
|
-
|
|
140
|
+
| Key | Action |
|
|
141
|
+
| --- | ------------------------------------------ |
|
|
142
|
+
| `e` | Open in editor (VS Code or Cursor) |
|
|
143
|
+
| `t` | Open terminal at worktree path |
|
|
144
|
+
| `p` | Open PR in browser / Create PR from branch |
|
|
145
|
+
| `d` | Show worktree details |
|
|
146
|
+
| `c` | Copy path to clipboard |
|
|
147
|
+
| `l` | Link config files (via wtlink) |
|
|
148
|
+
| `r` | Remove worktree (not available for main) |
|
|
149
|
+
| `/` | Fuzzy search worktrees |
|
|
150
|
+
| `q` | Quit |
|
|
142
151
|
|
|
143
|
-
|
|
152
|
+
### wt prs
|
|
144
153
|
|
|
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.
|
|
154
|
+
Browse all repository pull requests with an interactive interface.
|
|
148
155
|
|
|
149
156
|
```bash
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
157
|
+
wt prs # Interactive mode (default)
|
|
158
|
+
wt prs --state=all # Show all PRs (open, merged, closed)
|
|
159
|
+
wt prs --state=merged # Show only merged PRs
|
|
160
|
+
wt prs --author=@me # Filter by current user
|
|
161
|
+
wt prs --label=preview # Filter by label
|
|
162
|
+
wt prs --draft # Show only drafts
|
|
163
|
+
wt prs --no-draft # Exclude drafts
|
|
164
|
+
wt prs --with-worktree # Only PRs that have local worktrees
|
|
165
|
+
wt prs --limit=100 # Fetch more PRs (default: 50)
|
|
166
|
+
wt prs --json # JSON output for scripting
|
|
167
|
+
wt prs --no-interactive # Plain table output
|
|
155
168
|
```
|
|
156
169
|
|
|
157
|
-
**
|
|
170
|
+
**Interactive Mode Shortcuts**:
|
|
171
|
+
|
|
172
|
+
| Key | Action |
|
|
173
|
+
| ------- | ------------------------------------- |
|
|
174
|
+
| `Enter` | Show PR details |
|
|
175
|
+
| `w` | Create worktree for PR |
|
|
176
|
+
| `e` | Open worktree in editor (if exists) |
|
|
177
|
+
| `t` | Open terminal at worktree (if exists) |
|
|
178
|
+
| `b` | Open PR in browser |
|
|
179
|
+
| `c` | Copy PR URL to clipboard |
|
|
180
|
+
| `n` | Copy PR number to clipboard |
|
|
181
|
+
| `d` | Show PR details |
|
|
182
|
+
| `/` | Fuzzy search PRs |
|
|
183
|
+
| `o` | Toggle open PRs filter |
|
|
184
|
+
| `m` | Toggle merged PRs filter |
|
|
185
|
+
| `x` | Toggle closed PRs filter |
|
|
186
|
+
| `r` | Refresh PR list |
|
|
187
|
+
| `q` | Quit |
|
|
188
|
+
|
|
189
|
+
**PR List Display**:
|
|
190
|
+
|
|
191
|
+
- Shows PR number, state, draft indicator, title, author, age
|
|
192
|
+
- Indicates which PRs have local worktrees
|
|
193
|
+
- Shows review status (approved, changes requested, pending)
|
|
194
|
+
- Shows CI/checks status (passing, failing, pending)
|
|
195
|
+
- Highlights configurable label (default: "preview")
|
|
196
|
+
|
|
197
|
+
### wt clean / cleanpr
|
|
158
198
|
|
|
159
|
-
|
|
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
|
|
166
|
-
|
|
167
|
-
# link - Create links between worktrees
|
|
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
|
|
199
|
+
Clean up worktrees for merged or closed PRs.
|
|
172
200
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
201
|
+
```bash
|
|
202
|
+
wt clean # Interactive cleanup
|
|
203
|
+
wt clean --all # Clean all merged/closed automatically
|
|
204
|
+
wt clean --force # Force remove even if not merged
|
|
205
|
+
wt clean --dry-run # Preview what would be cleaned
|
|
176
206
|
```
|
|
177
207
|
|
|
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.
|
|
208
|
+
### wt link / wtlink
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
Interactive CLI for managing configuration file links between git worktrees.
|
|
211
211
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
212
|
+
```bash
|
|
213
|
+
wt link # Interactive main menu
|
|
214
|
+
wt link manage # Interactive file browser
|
|
215
|
+
wt link link # Create hard links based on manifest
|
|
216
|
+
wt link link ../my-app.pr42 # Link to specific worktree
|
|
217
|
+
wt link validate # Verify manifest integrity
|
|
218
|
+
wt link migrate # Migrate legacy .wtlinkrc to .worktreerc
|
|
219
|
+
```
|
|
219
220
|
|
|
220
|
-
|
|
221
|
+
**Configuration format (`.worktreerc`):**
|
|
221
222
|
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
.env.local
|
|
226
|
-
|
|
223
|
+
```json
|
|
224
|
+
{
|
|
225
|
+
"wtlink": {
|
|
226
|
+
"enabled": [".vscode/settings.json", ".editorconfig", ".env.local"],
|
|
227
|
+
"disabled": [".vscode/launch.json"]
|
|
228
|
+
}
|
|
229
|
+
}
|
|
227
230
|
```
|
|
228
231
|
|
|
229
|
-
-
|
|
230
|
-
-
|
|
231
|
-
- Files marked "Skip" are not added to the manifest at all
|
|
232
|
-
|
|
233
|
-
**Best practices:**
|
|
232
|
+
- `enabled` — Files that are hard-linked between worktrees
|
|
233
|
+
- `disabled` — Files tracked but not currently linked (toggle on/off via manage)
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
**Legacy format (`.wtlinkrc`):** Still supported for backwards compatibility. Run `wtlink migrate` to convert to the new JSON format.
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
- `.env.local`, `.env.development` — Local environment variables
|
|
239
|
-
- `certificates/`, `credentials/` — Local dev certificates
|
|
237
|
+
**Best practices:**
|
|
240
238
|
|
|
241
|
-
|
|
239
|
+
- **Good for linking:** `.vscode/settings.json`, `.editorconfig`, `.env.local`, certificates
|
|
240
|
+
- **Not for linking:** `node_modules/`, `dist/`, `build/`, `.git/`
|
|
242
241
|
|
|
243
|
-
|
|
244
|
-
- `dist/`, `build/` — Build artifacts should be separate per worktree
|
|
245
|
-
- `.git/` — Never link git internals
|
|
242
|
+
See [wtlink documentation](#wtlink-details) for full details.
|
|
246
243
|
|
|
247
|
-
### wtstate
|
|
244
|
+
### wt state / wtstate
|
|
248
245
|
|
|
249
|
-
Query the current git state for AI agents and automation.
|
|
246
|
+
Query the current git state for AI agents and automation.
|
|
250
247
|
|
|
251
248
|
```bash
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
249
|
+
wt state # Human-readable output
|
|
250
|
+
wt state --json # Machine-readable JSON output
|
|
251
|
+
wt state --verbose # Include file lists and commit details
|
|
252
|
+
wt state --base dev # Specify base branch
|
|
256
253
|
```
|
|
257
254
|
|
|
258
255
|
**JSON output includes:**
|
|
259
256
|
|
|
260
|
-
- `scenario` —
|
|
261
|
-
- `
|
|
262
|
-
- `currentBranch` — Current branch name (null if detached HEAD)
|
|
263
|
-
- `baseBranch` — Base branch for comparison
|
|
257
|
+
- `scenario` — Git state scenario (e.g., `main_staged_same`)
|
|
258
|
+
- `currentBranch` — Current branch name
|
|
264
259
|
- `worktreeType` — Type: `main_worktree`, `pr_worktree`, or `other`
|
|
265
|
-
- `hasChanges`, `hasStagedChanges`, `hasUnstagedChanges` — Change flags
|
|
266
|
-
- `localCommits` — List of local commits not in origin
|
|
267
260
|
- `availableActions` — Actions available for this scenario
|
|
268
261
|
- `recommendedAction` — Suggested action to take
|
|
269
262
|
|
|
270
|
-
###
|
|
263
|
+
### wt config
|
|
271
264
|
|
|
272
|
-
Configuration management with
|
|
265
|
+
Configuration management with interactive editing.
|
|
273
266
|
|
|
274
267
|
```bash
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
268
|
+
wt config # Interactive config editor
|
|
269
|
+
wt cfg init # Run setup wizard (alias for wt init)
|
|
270
|
+
wt cfg show # Show current configuration
|
|
271
|
+
wt cfg set key value # Set a configuration value
|
|
272
|
+
wt cfg get key # Get a configuration value
|
|
273
|
+
wt cfg edit # Open config in default editor
|
|
274
|
+
wt cfg validate # Validate configuration
|
|
275
|
+
wt cfg schema # Show JSON schema URL
|
|
281
276
|
```
|
|
282
277
|
|
|
283
|
-
|
|
278
|
+
### wt init
|
|
284
279
|
|
|
285
|
-
-
|
|
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)
|
|
296
|
-
|
|
297
|
-
Repository config overrides global settings.
|
|
298
|
-
|
|
299
|
-
**Example AI workflow:**
|
|
280
|
+
Initialize git-worktree-tools configuration.
|
|
300
281
|
|
|
301
282
|
```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
|
|
283
|
+
wt init # Interactive initialization
|
|
284
|
+
wt init --local # Create local config (gitignored)
|
|
285
|
+
wt init --global # Create global config
|
|
286
|
+
wt init --force # Overwrite existing config
|
|
310
287
|
```
|
|
311
288
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
All commands support `--json` for machine-readable output, enabling integration with AI CLI tools like Claude Code, Gemini CLI, and Codex.
|
|
315
|
-
|
|
316
|
-
> **Comprehensive Guide:** See [docs/AI-TOOLING.md](docs/AI-TOOLING.md) for detailed documentation including programmatic API, error codes, lifecycle hooks, and integration examples.
|
|
289
|
+
---
|
|
317
290
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
The recommended workflow is a three-step "look before you leap" pattern:
|
|
291
|
+
## Configuration
|
|
321
292
|
|
|
322
|
-
|
|
323
|
-
# 1. Query current git state
|
|
324
|
-
STATE=$(wtstate --json)
|
|
293
|
+
git-worktree-tools uses a three-tier configuration system:
|
|
325
294
|
|
|
326
|
-
|
|
327
|
-
|
|
295
|
+
| Level | File | Purpose | Git Status |
|
|
296
|
+
| ------ | ------------------------------------------ | -------------------- | ---------- |
|
|
297
|
+
| Local | `.worktreerc.local` | Personal overrides | gitignored |
|
|
298
|
+
| Repo | `.worktreerc` or `.worktreerc.json` | Shared team settings | committed |
|
|
299
|
+
| Global | `~/.config/git-worktree-tools/config.json` | User-wide defaults | N/A |
|
|
328
300
|
|
|
329
|
-
|
|
330
|
-
newpr "Add feature X" --non-interactive --action=$ACTION --json
|
|
331
|
-
```
|
|
301
|
+
**Merge order:** defaults ← global ← repo ← local
|
|
332
302
|
|
|
333
|
-
###
|
|
303
|
+
### Creating Configuration
|
|
334
304
|
|
|
335
305
|
```bash
|
|
336
|
-
#
|
|
337
|
-
|
|
338
|
-
newpr "Fix bug" --non-interactive --action=commit_staged --json
|
|
306
|
+
# Interactive setup (recommended)
|
|
307
|
+
wt init
|
|
339
308
|
|
|
340
|
-
#
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
# Link configs without prompts
|
|
345
|
-
wtlink link --yes --json
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
### JSON Output Schema
|
|
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
|
-
});
|
|
309
|
+
# Or create specific configs
|
|
310
|
+
wt init --global # User-wide defaults
|
|
311
|
+
wt init --local # Personal repo overrides
|
|
424
312
|
```
|
|
425
313
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
## Configuration
|
|
429
|
-
|
|
430
|
-
Create a `.worktreerc` file in your repository root, or use `wtconfig init` to generate one interactively:
|
|
314
|
+
### Example Configuration
|
|
431
315
|
|
|
432
316
|
```json
|
|
433
317
|
{
|
|
318
|
+
"$schema": "https://unpkg.com/@camaradesuk/git-worktree-tools/schemas/worktreerc.schema.json",
|
|
434
319
|
"baseBranch": "main",
|
|
435
320
|
"draftPr": true,
|
|
436
321
|
"branchPrefix": "feat",
|
|
322
|
+
"preferredEditor": "vscode",
|
|
437
323
|
"ai": {
|
|
438
324
|
"provider": "auto",
|
|
439
325
|
"branchName": true,
|
|
440
326
|
"prDescription": true
|
|
441
327
|
},
|
|
442
328
|
"hooks": {
|
|
443
|
-
"post-worktree": "npm install"
|
|
329
|
+
"post-worktree": ["npm install", "code ."]
|
|
330
|
+
},
|
|
331
|
+
"logging": {
|
|
332
|
+
"level": "info"
|
|
444
333
|
}
|
|
445
334
|
}
|
|
446
335
|
```
|
|
447
336
|
|
|
448
|
-
### Options
|
|
449
|
-
|
|
450
|
-
| Option | Type | Default | Description
|
|
451
|
-
| ----------------- | -------- | --------------------- |
|
|
452
|
-
| `
|
|
453
|
-
| `
|
|
454
|
-
| `
|
|
455
|
-
| `
|
|
456
|
-
| `
|
|
457
|
-
| `
|
|
458
|
-
| `preferredEditor` | string | `"vscode"` | Editor
|
|
459
|
-
| `
|
|
460
|
-
| `
|
|
337
|
+
### Configuration Options
|
|
338
|
+
|
|
339
|
+
| Option | Type | Default | Description |
|
|
340
|
+
| ----------------- | -------- | --------------------- | ------------------------------------------- |
|
|
341
|
+
| `baseBranch` | string | `"main"` | Base branch for new PRs |
|
|
342
|
+
| `draftPr` | boolean | `false` | Create PRs as drafts by default |
|
|
343
|
+
| `worktreePattern` | string | `"{repo}.pr{number}"` | Worktree directory naming pattern |
|
|
344
|
+
| `worktreeParent` | string | `".."` | Parent directory for worktrees |
|
|
345
|
+
| `branchPrefix` | string | `"feat"` | Prefix for auto-generated branch names |
|
|
346
|
+
| `sharedRepos` | string[] | `[]` | Sibling repos to also create worktrees for |
|
|
347
|
+
| `preferredEditor` | string | `"vscode"` | Editor: `"vscode"`, `"cursor"`, or `"auto"` |
|
|
348
|
+
| `syncPatterns` | string[] | `[]` | Patterns to sync between worktrees |
|
|
349
|
+
| `previewLabel` | string | `"preview"` | Label to highlight in PR browser |
|
|
350
|
+
| `ai` | object | `{}` | AI content generation settings |
|
|
351
|
+
| `hooks` | object | `{}` | Lifecycle hook commands |
|
|
352
|
+
| `logging` | object | `{}` | Logging configuration |
|
|
461
353
|
|
|
462
354
|
### AI Content Generation
|
|
463
355
|
|
|
@@ -466,19 +358,20 @@ Enable AI-powered content generation for branch names and PR descriptions:
|
|
|
466
358
|
```json
|
|
467
359
|
{
|
|
468
360
|
"ai": {
|
|
469
|
-
"provider": "auto",
|
|
470
|
-
"branchName": true,
|
|
471
|
-
"prTitle": true,
|
|
472
|
-
"prDescription": true
|
|
361
|
+
"provider": "auto",
|
|
362
|
+
"branchName": true,
|
|
363
|
+
"prTitle": true,
|
|
364
|
+
"prDescription": true,
|
|
365
|
+
"commitMessage": true
|
|
473
366
|
}
|
|
474
367
|
}
|
|
475
368
|
```
|
|
476
369
|
|
|
477
|
-
|
|
370
|
+
**Providers:** `"auto"` (detects available tools), `"claude"`, `"gemini"`, `"openai"`, `"ollama"`, `"none"`
|
|
478
371
|
|
|
479
372
|
### Lifecycle Hooks
|
|
480
373
|
|
|
481
|
-
Run custom commands at various points in the
|
|
374
|
+
Run custom commands at various points in the workflow:
|
|
482
375
|
|
|
483
376
|
```json
|
|
484
377
|
{
|
|
@@ -487,110 +380,106 @@ Run custom commands at various points in the `newpr` workflow:
|
|
|
487
380
|
"post-pr": ["echo 'PR created!'", "./notify-team.sh"],
|
|
488
381
|
"pre-branch": {
|
|
489
382
|
"command": "npm test",
|
|
490
|
-
"failOnError": true
|
|
383
|
+
"failOnError": true,
|
|
384
|
+
"timeout": 60000
|
|
491
385
|
}
|
|
492
386
|
}
|
|
493
387
|
}
|
|
494
388
|
```
|
|
495
389
|
|
|
496
|
-
**Available hooks:**
|
|
390
|
+
**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
391
|
|
|
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 |
|
|
392
|
+
**Hook context variables** (environment variables):
|
|
513
393
|
|
|
514
|
-
|
|
394
|
+
| Variable | Description |
|
|
395
|
+
| ------------------ | ----------------- |
|
|
396
|
+
| `WT_BRANCH_NAME` | New branch name |
|
|
397
|
+
| `WT_PR_NUMBER` | PR number |
|
|
398
|
+
| `WT_PR_URL` | PR URL |
|
|
399
|
+
| `WT_WORKTREE_PATH` | New worktree path |
|
|
400
|
+
| `WT_REPO_ROOT` | Main repo root |
|
|
401
|
+
| `WT_BASE_BRANCH` | Base branch |
|
|
402
|
+
| `WT_DESCRIPTION` | PR description |
|
|
515
403
|
|
|
516
|
-
|
|
404
|
+
### Logging Configuration
|
|
517
405
|
|
|
518
406
|
```json
|
|
519
407
|
{
|
|
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
|
-
}
|
|
408
|
+
"logging": {
|
|
409
|
+
"level": "info",
|
|
410
|
+
"logFile": "/path/to/logfile.log"
|
|
534
411
|
}
|
|
535
412
|
}
|
|
536
413
|
```
|
|
537
414
|
|
|
538
|
-
**
|
|
415
|
+
**Levels:** `silent`, `error`, `warn`, `info`, `debug`, `trace`
|
|
539
416
|
|
|
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 |
|
|
417
|
+
CLI flags override config: `-v` (debug), `-vv` (trace), `-q` (silent), `--log-file`
|
|
549
418
|
|
|
550
|
-
|
|
419
|
+
---
|
|
551
420
|
|
|
552
|
-
##
|
|
421
|
+
## AI Tool Integration
|
|
422
|
+
|
|
423
|
+
All commands support `--json` for machine-readable output, enabling integration with AI CLI tools.
|
|
424
|
+
|
|
425
|
+
### Quick Start for AI Agents
|
|
553
426
|
|
|
554
427
|
```bash
|
|
555
|
-
#
|
|
556
|
-
|
|
428
|
+
# 1. Query current git state
|
|
429
|
+
STATE=$(wt state --json)
|
|
557
430
|
|
|
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
|
|
431
|
+
# 2. Extract recommended action
|
|
432
|
+
ACTION=$(echo $STATE | jq -r '.data.recommendedAction')
|
|
564
433
|
|
|
565
|
-
#
|
|
566
|
-
|
|
434
|
+
# 3. Execute with the chosen action
|
|
435
|
+
wt new "Add feature X" --non-interactive --action=$ACTION --json
|
|
436
|
+
```
|
|
567
437
|
|
|
568
|
-
|
|
569
|
-
cd ~/projects/my-app
|
|
570
|
-
newpr "Fix login bug"
|
|
571
|
-
# → Creates another worktree: ~/projects/my-app.pr43
|
|
438
|
+
### Non-Interactive Mode
|
|
572
439
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
# ~/projects/my-app.pr43 feat/fix-login-bug-abc456 #43 open
|
|
440
|
+
```bash
|
|
441
|
+
wt new "Feature" --non-interactive --json
|
|
442
|
+
wt clean --all --json
|
|
443
|
+
wt link link --yes --json
|
|
444
|
+
```
|
|
579
445
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
446
|
+
### JSON Response Schema
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
interface CommandResult<T> {
|
|
450
|
+
success: boolean;
|
|
451
|
+
command: string;
|
|
452
|
+
timestamp: string;
|
|
453
|
+
data?: T;
|
|
454
|
+
error?: { code: string; message: string };
|
|
455
|
+
warnings?: string[];
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### Programmatic API
|
|
460
|
+
|
|
461
|
+
```typescript
|
|
462
|
+
import { queryState, createPr, listWorktrees } from '@camaradesuk/git-worktree-tools';
|
|
463
|
+
|
|
464
|
+
const state = queryState({ baseBranch: 'main' });
|
|
465
|
+
const result = await createPr({
|
|
466
|
+
description: 'Add dark mode',
|
|
467
|
+
action: 'commit_staged',
|
|
468
|
+
draft: true,
|
|
469
|
+
});
|
|
584
470
|
```
|
|
585
471
|
|
|
472
|
+
See [docs/AI-TOOLING.md](docs/AI-TOOLING.md) for comprehensive AI integration documentation including error codes, available actions, and integration examples.
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
586
476
|
## Shell Completion
|
|
587
477
|
|
|
588
|
-
Enable tab completion for `wt` commands
|
|
478
|
+
Enable tab completion for `wt` commands:
|
|
589
479
|
|
|
590
480
|
### Bash
|
|
591
481
|
|
|
592
482
|
```bash
|
|
593
|
-
# Add to ~/.bashrc
|
|
594
483
|
wt completion bash >> ~/.bashrc
|
|
595
484
|
source ~/.bashrc
|
|
596
485
|
```
|
|
@@ -598,13 +487,9 @@ source ~/.bashrc
|
|
|
598
487
|
### Zsh
|
|
599
488
|
|
|
600
489
|
```bash
|
|
601
|
-
# Create completion directory and add completion
|
|
602
490
|
mkdir -p ~/.zsh/completions
|
|
603
491
|
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
|
|
492
|
+
# Add to ~/.zshrc: fpath=(~/.zsh/completions $fpath)
|
|
608
493
|
```
|
|
609
494
|
|
|
610
495
|
### Fish
|
|
@@ -613,35 +498,100 @@ autoload -Uz compinit && compinit
|
|
|
613
498
|
wt completion fish > ~/.config/fish/completions/wt.fish
|
|
614
499
|
```
|
|
615
500
|
|
|
616
|
-
|
|
501
|
+
---
|
|
502
|
+
|
|
503
|
+
## wtlink Details
|
|
504
|
+
|
|
505
|
+
The `wtlink` command provides an interactive TUI for managing configuration file links.
|
|
506
|
+
|
|
507
|
+
### Interactive UI Navigation
|
|
508
|
+
|
|
509
|
+
| Key | Action |
|
|
510
|
+
| --- | ------------------------------------------------ |
|
|
511
|
+
| ↑/↓ | Navigate file list |
|
|
512
|
+
| ←/→ | Navigate into/out of folders (hierarchical view) |
|
|
513
|
+
| A | Mark as "Will Link" (added to manifest) |
|
|
514
|
+
| C | Mark as "Track" (commented in manifest) |
|
|
515
|
+
| S | Mark as "Skip" (not in manifest) |
|
|
516
|
+
| 0-3 | Toggle filter visibility |
|
|
517
|
+
| V | Toggle hierarchical/flat view |
|
|
518
|
+
| ? | Show help |
|
|
519
|
+
| Q | Save and quit |
|
|
520
|
+
| X | Cancel without saving |
|
|
521
|
+
|
|
522
|
+
### Command Options
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
# manage - Discover and manage the manifest
|
|
526
|
+
wtlink manage # Interactive mode
|
|
527
|
+
wtlink manage --non-interactive # Auto-add new files as commented
|
|
528
|
+
wtlink manage --clean # Remove stale entries
|
|
529
|
+
wtlink manage --dry-run # Preview changes
|
|
530
|
+
|
|
531
|
+
# link - Create links between worktrees
|
|
532
|
+
wtlink link [source] [dest] # Link from source to destination
|
|
533
|
+
wtlink link --dry-run # Preview what would be linked
|
|
534
|
+
wtlink link --type symbolic # Use symlinks instead of hard links
|
|
535
|
+
wtlink link --yes # Skip confirmation prompts
|
|
536
|
+
|
|
537
|
+
# validate - Check manifest integrity
|
|
538
|
+
wtlink validate # Validate against current worktree
|
|
539
|
+
|
|
540
|
+
# migrate - Convert legacy .wtlinkrc to .worktreerc
|
|
541
|
+
wtlink migrate # Migrate to new JSON format
|
|
542
|
+
wtlink migrate --delete-legacy # Also delete old .wtlinkrc file
|
|
543
|
+
wtlink migrate --dry-run # Preview migration
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
548
|
+
## Example Workflow
|
|
617
549
|
|
|
618
550
|
```bash
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
551
|
+
# Start in your main repo
|
|
552
|
+
cd ~/projects/my-app
|
|
553
|
+
|
|
554
|
+
# Create a new feature PR
|
|
555
|
+
wt new "Add dark mode support"
|
|
556
|
+
# → Creates branch: feat/add-dark-mode-support-xyz123
|
|
557
|
+
# → Creates PR: #42
|
|
558
|
+
# → Creates worktree: ~/projects/my-app.pr42
|
|
559
|
+
# → Runs post-worktree hooks (npm install, etc.)
|
|
560
|
+
|
|
561
|
+
# Work on the feature in the dedicated worktree
|
|
562
|
+
# ... make changes, commit, push ...
|
|
563
|
+
|
|
564
|
+
# Need another feature? No problem!
|
|
565
|
+
cd ~/projects/my-app
|
|
566
|
+
wt new "Fix login bug"
|
|
567
|
+
# → Creates worktree: ~/projects/my-app.pr43
|
|
568
|
+
|
|
569
|
+
# List your worktrees
|
|
570
|
+
wt list
|
|
571
|
+
# Interactive selection with PR status
|
|
572
|
+
|
|
573
|
+
# After PRs are merged, clean up
|
|
574
|
+
wt clean
|
|
575
|
+
# → Removes worktrees for merged PRs
|
|
576
|
+
# → Deletes local branches
|
|
622
577
|
```
|
|
623
578
|
|
|
579
|
+
---
|
|
580
|
+
|
|
624
581
|
## Development
|
|
625
582
|
|
|
626
583
|
```bash
|
|
627
|
-
# Clone the repo
|
|
628
584
|
git clone https://github.com/camaradesuk/git-worktree-tools.git
|
|
629
585
|
cd git-worktree-tools
|
|
630
|
-
|
|
631
|
-
# Install dependencies
|
|
632
586
|
npm install
|
|
633
|
-
|
|
634
|
-
# Build
|
|
635
587
|
npm run build
|
|
636
|
-
|
|
637
|
-
# Test
|
|
638
588
|
npm test
|
|
639
|
-
|
|
640
|
-
# Link for local development
|
|
641
|
-
npm link
|
|
589
|
+
npm link # For local development
|
|
642
590
|
```
|
|
643
591
|
|
|
644
|
-
See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for detailed
|
|
592
|
+
See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for detailed development instructions.
|
|
593
|
+
|
|
594
|
+
---
|
|
645
595
|
|
|
646
596
|
## License
|
|
647
597
|
|