@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.
Files changed (274) hide show
  1. package/README.md +330 -370
  2. package/dist/cli/cleanpr.js +35 -4
  3. package/dist/cli/cleanpr.js.map +1 -1
  4. package/dist/cli/cleanpr.test.js +256 -0
  5. package/dist/cli/cleanpr.test.js.map +1 -1
  6. package/dist/cli/lswt.js +54 -6
  7. package/dist/cli/lswt.js.map +1 -1
  8. package/dist/cli/lswt.test.js +207 -0
  9. package/dist/cli/lswt.test.js.map +1 -1
  10. package/dist/cli/newpr.js +135 -76
  11. package/dist/cli/newpr.js.map +1 -1
  12. package/dist/cli/newpr.test.js +35 -16
  13. package/dist/cli/newpr.test.js.map +1 -1
  14. package/dist/cli/wt/clean.d.ts +17 -0
  15. package/dist/cli/wt/clean.d.ts.map +1 -0
  16. package/dist/cli/wt/clean.js +74 -0
  17. package/dist/cli/wt/clean.js.map +1 -0
  18. package/dist/cli/wt/completion.d.ts +12 -0
  19. package/dist/cli/wt/completion.d.ts.map +1 -0
  20. package/dist/cli/wt/completion.js +246 -0
  21. package/dist/cli/wt/completion.js.map +1 -0
  22. package/dist/cli/wt/completion.test.d.ts +5 -0
  23. package/dist/cli/wt/completion.test.d.ts.map +1 -0
  24. package/dist/cli/wt/completion.test.js +173 -0
  25. package/dist/cli/wt/completion.test.js.map +1 -0
  26. package/dist/cli/wt/config.d.ts +13 -0
  27. package/dist/cli/wt/config.d.ts.map +1 -0
  28. package/dist/cli/wt/config.js +175 -0
  29. package/dist/cli/wt/config.js.map +1 -0
  30. package/dist/cli/wt/config.test.d.ts +5 -0
  31. package/dist/cli/wt/config.test.d.ts.map +1 -0
  32. package/dist/cli/wt/config.test.js +260 -0
  33. package/dist/cli/wt/config.test.js.map +1 -0
  34. package/dist/cli/wt/entry.test.d.ts +8 -0
  35. package/dist/cli/wt/entry.test.d.ts.map +1 -0
  36. package/dist/cli/wt/entry.test.js +201 -0
  37. package/dist/cli/wt/entry.test.js.map +1 -0
  38. package/dist/cli/wt/init.d.ts +14 -0
  39. package/dist/cli/wt/init.d.ts.map +1 -0
  40. package/dist/cli/wt/init.js +209 -0
  41. package/dist/cli/wt/init.js.map +1 -0
  42. package/dist/cli/wt/init.test.d.ts +5 -0
  43. package/dist/cli/wt/init.test.d.ts.map +1 -0
  44. package/dist/cli/wt/init.test.js +165 -0
  45. package/dist/cli/wt/init.test.js.map +1 -0
  46. package/dist/cli/wt/init.unit.test.d.ts +5 -0
  47. package/dist/cli/wt/init.unit.test.d.ts.map +1 -0
  48. package/dist/cli/wt/init.unit.test.js +432 -0
  49. package/dist/cli/wt/init.unit.test.js.map +1 -0
  50. package/dist/cli/wt/interactive-menu.d.ts +41 -0
  51. package/dist/cli/wt/interactive-menu.d.ts.map +1 -0
  52. package/dist/cli/wt/interactive-menu.js +639 -0
  53. package/dist/cli/wt/interactive-menu.js.map +1 -0
  54. package/dist/cli/wt/interactive-menu.test.d.ts +10 -0
  55. package/dist/cli/wt/interactive-menu.test.d.ts.map +1 -0
  56. package/dist/cli/wt/interactive-menu.test.js +711 -0
  57. package/dist/cli/wt/interactive-menu.test.js.map +1 -0
  58. package/dist/cli/wt/link.d.ts +22 -0
  59. package/dist/cli/wt/link.d.ts.map +1 -0
  60. package/dist/cli/wt/link.js +115 -0
  61. package/dist/cli/wt/link.js.map +1 -0
  62. package/dist/cli/wt/list.d.ts +16 -0
  63. package/dist/cli/wt/list.d.ts.map +1 -0
  64. package/dist/cli/wt/list.js +65 -0
  65. package/dist/cli/wt/list.js.map +1 -0
  66. package/dist/cli/wt/new.d.ts +24 -0
  67. package/dist/cli/wt/new.d.ts.map +1 -0
  68. package/dist/cli/wt/new.js +130 -0
  69. package/dist/cli/wt/new.js.map +1 -0
  70. package/dist/cli/wt/run-command.d.ts +31 -0
  71. package/dist/cli/wt/run-command.d.ts.map +1 -0
  72. package/dist/cli/wt/run-command.js +49 -0
  73. package/dist/cli/wt/run-command.js.map +1 -0
  74. package/dist/cli/wt/run-command.test.d.ts +5 -0
  75. package/dist/cli/wt/run-command.test.d.ts.map +1 -0
  76. package/dist/cli/wt/run-command.test.js +88 -0
  77. package/dist/cli/wt/run-command.test.js.map +1 -0
  78. package/dist/cli/wt/state.d.ts +13 -0
  79. package/dist/cli/wt/state.d.ts.map +1 -0
  80. package/dist/cli/wt/state.js +38 -0
  81. package/dist/cli/wt/state.js.map +1 -0
  82. package/dist/cli/wt/wt.test.d.ts +8 -0
  83. package/dist/cli/wt/wt.test.d.ts.map +1 -0
  84. package/dist/cli/wt/wt.test.js +521 -0
  85. package/dist/cli/wt/wt.test.js.map +1 -0
  86. package/dist/cli/wt.d.ts +26 -0
  87. package/dist/cli/wt.d.ts.map +1 -0
  88. package/dist/cli/wt.js +169 -0
  89. package/dist/cli/wt.js.map +1 -0
  90. package/dist/cli/wt.unit.test.d.ts +7 -0
  91. package/dist/cli/wt.unit.test.d.ts.map +1 -0
  92. package/dist/cli/wt.unit.test.js +182 -0
  93. package/dist/cli/wt.unit.test.js.map +1 -0
  94. package/dist/cli/wtconfig.js +22 -8
  95. package/dist/cli/wtconfig.js.map +1 -1
  96. package/dist/cli/wtconfig.test.js +18 -16
  97. package/dist/cli/wtconfig.test.js.map +1 -1
  98. package/dist/cli/wtlink.js +66 -9
  99. package/dist/cli/wtlink.js.map +1 -1
  100. package/dist/cli/wtlink.test.js +101 -0
  101. package/dist/cli/wtlink.test.js.map +1 -1
  102. package/dist/e2e/cli.e2e.test.js +97 -1
  103. package/dist/e2e/cli.e2e.test.js.map +1 -1
  104. package/dist/e2e/lswt/lswt.e2e.test.js +33 -0
  105. package/dist/e2e/lswt/lswt.e2e.test.js.map +1 -1
  106. package/dist/e2e/newpr/scenarios.e2e.test.js +7 -7
  107. package/dist/e2e/newpr/scenarios.e2e.test.js.map +1 -1
  108. package/dist/e2e/wt/wt.e2e.test.d.ts +9 -0
  109. package/dist/e2e/wt/wt.e2e.test.d.ts.map +1 -0
  110. package/dist/e2e/wt/wt.e2e.test.js +384 -0
  111. package/dist/e2e/wt/wt.e2e.test.js.map +1 -0
  112. package/dist/e2e/wtlink/wtlink.e2e.test.js +52 -0
  113. package/dist/e2e/wtlink/wtlink.e2e.test.js.map +1 -1
  114. package/dist/lib/ai/base-provider.d.ts +22 -0
  115. package/dist/lib/ai/base-provider.d.ts.map +1 -1
  116. package/dist/lib/ai/base-provider.js +180 -99
  117. package/dist/lib/ai/base-provider.js.map +1 -1
  118. package/dist/lib/ai/base-provider.test.js +13 -14
  119. package/dist/lib/ai/base-provider.test.js.map +1 -1
  120. package/dist/lib/ai/cli-provider.d.ts +11 -7
  121. package/dist/lib/ai/cli-provider.d.ts.map +1 -1
  122. package/dist/lib/ai/cli-provider.js +19 -49
  123. package/dist/lib/ai/cli-provider.js.map +1 -1
  124. package/dist/lib/ai/cli-provider.test.js +47 -49
  125. package/dist/lib/ai/cli-provider.test.js.map +1 -1
  126. package/dist/lib/ai/index.d.ts +2 -1
  127. package/dist/lib/ai/index.d.ts.map +1 -1
  128. package/dist/lib/ai/index.js +2 -0
  129. package/dist/lib/ai/index.js.map +1 -1
  130. package/dist/lib/ai/provider-manager.js +2 -2
  131. package/dist/lib/ai/provider-manager.js.map +1 -1
  132. package/dist/lib/ai/repo-docs.d.ts +43 -0
  133. package/dist/lib/ai/repo-docs.d.ts.map +1 -0
  134. package/dist/lib/ai/repo-docs.js +274 -0
  135. package/dist/lib/ai/repo-docs.js.map +1 -0
  136. package/dist/lib/ai/repo-docs.test.d.ts +5 -0
  137. package/dist/lib/ai/repo-docs.test.d.ts.map +1 -0
  138. package/dist/lib/ai/repo-docs.test.js +357 -0
  139. package/dist/lib/ai/repo-docs.test.js.map +1 -0
  140. package/dist/lib/ai/types.d.ts +18 -2
  141. package/dist/lib/ai/types.d.ts.map +1 -1
  142. package/dist/lib/ai/types.js.map +1 -1
  143. package/dist/lib/config-editor.d.ts +21 -0
  144. package/dist/lib/config-editor.d.ts.map +1 -0
  145. package/dist/lib/config-editor.js +729 -0
  146. package/dist/lib/config-editor.js.map +1 -0
  147. package/dist/lib/config-editor.test.d.ts +11 -0
  148. package/dist/lib/config-editor.test.d.ts.map +1 -0
  149. package/dist/lib/config-editor.test.js +526 -0
  150. package/dist/lib/config-editor.test.js.map +1 -0
  151. package/dist/lib/config-validation.d.ts +28 -0
  152. package/dist/lib/config-validation.d.ts.map +1 -0
  153. package/dist/lib/config-validation.js +534 -0
  154. package/dist/lib/config-validation.js.map +1 -0
  155. package/dist/lib/config-validation.test.d.ts +5 -0
  156. package/dist/lib/config-validation.test.d.ts.map +1 -0
  157. package/dist/lib/config-validation.test.js +398 -0
  158. package/dist/lib/config-validation.test.js.map +1 -0
  159. package/dist/lib/config.d.ts +115 -6
  160. package/dist/lib/config.d.ts.map +1 -1
  161. package/dist/lib/config.js +251 -55
  162. package/dist/lib/config.js.map +1 -1
  163. package/dist/lib/config.test.js +2 -1
  164. package/dist/lib/config.test.js.map +1 -1
  165. package/dist/lib/constants.d.ts +50 -1
  166. package/dist/lib/constants.d.ts.map +1 -1
  167. package/dist/lib/constants.js +67 -1
  168. package/dist/lib/constants.js.map +1 -1
  169. package/dist/lib/constants.test.d.ts +5 -0
  170. package/dist/lib/constants.test.d.ts.map +1 -0
  171. package/dist/lib/constants.test.js +121 -0
  172. package/dist/lib/constants.test.js.map +1 -0
  173. package/dist/lib/git.d.ts +12 -0
  174. package/dist/lib/git.d.ts.map +1 -1
  175. package/dist/lib/git.js +26 -0
  176. package/dist/lib/git.js.map +1 -1
  177. package/dist/lib/global-check.d.ts +38 -0
  178. package/dist/lib/global-check.d.ts.map +1 -0
  179. package/dist/lib/global-check.js +135 -0
  180. package/dist/lib/global-check.js.map +1 -0
  181. package/dist/lib/global-check.test.d.ts +5 -0
  182. package/dist/lib/global-check.test.d.ts.map +1 -0
  183. package/dist/lib/global-check.test.js +153 -0
  184. package/dist/lib/global-check.test.js.map +1 -0
  185. package/dist/lib/global-config.d.ts +102 -0
  186. package/dist/lib/global-config.d.ts.map +1 -0
  187. package/dist/lib/global-config.js +234 -0
  188. package/dist/lib/global-config.js.map +1 -0
  189. package/dist/lib/global-config.test.d.ts +5 -0
  190. package/dist/lib/global-config.test.d.ts.map +1 -0
  191. package/dist/lib/global-config.test.js +282 -0
  192. package/dist/lib/global-config.test.js.map +1 -0
  193. package/dist/lib/json-output.d.ts +11 -1
  194. package/dist/lib/json-output.d.ts.map +1 -1
  195. package/dist/lib/json-output.js +42 -1
  196. package/dist/lib/json-output.js.map +1 -1
  197. package/dist/lib/json-output.test.js +2 -0
  198. package/dist/lib/json-output.test.js.map +1 -1
  199. package/dist/lib/logger.d.ts +175 -0
  200. package/dist/lib/logger.d.ts.map +1 -0
  201. package/dist/lib/logger.js +475 -0
  202. package/dist/lib/logger.js.map +1 -0
  203. package/dist/lib/logger.test.d.ts +5 -0
  204. package/dist/lib/logger.test.d.ts.map +1 -0
  205. package/dist/lib/logger.test.js +292 -0
  206. package/dist/lib/logger.test.js.map +1 -0
  207. package/dist/lib/lswt/action-executors.test.js +2 -0
  208. package/dist/lib/lswt/action-executors.test.js.map +1 -1
  209. package/dist/lib/lswt/formatters.d.ts +1 -0
  210. package/dist/lib/lswt/formatters.d.ts.map +1 -1
  211. package/dist/lib/lswt/formatters.js +6 -1
  212. package/dist/lib/lswt/formatters.js.map +1 -1
  213. package/dist/lib/lswt/formatters.test.js +2 -2
  214. package/dist/lib/lswt/formatters.test.js.map +1 -1
  215. package/dist/lib/lswt/fuzzy-search.d.ts +27 -0
  216. package/dist/lib/lswt/fuzzy-search.d.ts.map +1 -0
  217. package/dist/lib/lswt/fuzzy-search.js +130 -0
  218. package/dist/lib/lswt/fuzzy-search.js.map +1 -0
  219. package/dist/lib/lswt/fuzzy-search.test.d.ts +5 -0
  220. package/dist/lib/lswt/fuzzy-search.test.d.ts.map +1 -0
  221. package/dist/lib/lswt/fuzzy-search.test.js +207 -0
  222. package/dist/lib/lswt/fuzzy-search.test.js.map +1 -0
  223. package/dist/lib/lswt/index.d.ts +1 -0
  224. package/dist/lib/lswt/index.d.ts.map +1 -1
  225. package/dist/lib/lswt/index.js +2 -0
  226. package/dist/lib/lswt/index.js.map +1 -1
  227. package/dist/lib/lswt/interactive.d.ts +8 -0
  228. package/dist/lib/lswt/interactive.d.ts.map +1 -1
  229. package/dist/lib/lswt/interactive.js +169 -20
  230. package/dist/lib/lswt/interactive.js.map +1 -1
  231. package/dist/lib/newpr/action-deps.test.d.ts +5 -0
  232. package/dist/lib/newpr/action-deps.test.d.ts.map +1 -0
  233. package/dist/lib/newpr/action-deps.test.js +111 -0
  234. package/dist/lib/newpr/action-deps.test.js.map +1 -0
  235. package/dist/lib/newpr/args.d.ts.map +1 -1
  236. package/dist/lib/newpr/args.js +15 -4
  237. package/dist/lib/newpr/args.js.map +1 -1
  238. package/dist/lib/newpr/args.test.js +210 -2
  239. package/dist/lib/newpr/args.test.js.map +1 -1
  240. package/dist/lib/newpr/types.d.ts +2 -0
  241. package/dist/lib/newpr/types.d.ts.map +1 -1
  242. package/dist/lib/prompts.d.ts +10 -0
  243. package/dist/lib/prompts.d.ts.map +1 -1
  244. package/dist/lib/prompts.js +200 -1
  245. package/dist/lib/prompts.js.map +1 -1
  246. package/dist/lib/prompts.test.js +351 -1
  247. package/dist/lib/prompts.test.js.map +1 -1
  248. package/dist/lib/schema.test.d.ts +10 -0
  249. package/dist/lib/schema.test.d.ts.map +1 -0
  250. package/dist/lib/schema.test.js +309 -0
  251. package/dist/lib/schema.test.js.map +1 -0
  252. package/dist/lib/wtconfig/environment.d.ts.map +1 -1
  253. package/dist/lib/wtconfig/environment.js +6 -4
  254. package/dist/lib/wtconfig/environment.js.map +1 -1
  255. package/dist/lib/wtconfig/environment.test.js +2 -7
  256. package/dist/lib/wtconfig/environment.test.js.map +1 -1
  257. package/dist/lib/wtconfig/types.d.ts +3 -1
  258. package/dist/lib/wtconfig/types.d.ts.map +1 -1
  259. package/dist/lib/wtlink/link-configs.test.js +282 -2
  260. package/dist/lib/wtlink/link-configs.test.js.map +1 -1
  261. package/dist/lib/wtlink/main-menu.js +1 -0
  262. package/dist/lib/wtlink/main-menu.js.map +1 -1
  263. package/dist/lib/wtlink/main-menu.test.d.ts +5 -0
  264. package/dist/lib/wtlink/main-menu.test.d.ts.map +1 -0
  265. package/dist/lib/wtlink/main-menu.test.js +124 -0
  266. package/dist/lib/wtlink/main-menu.test.js.map +1 -0
  267. package/dist/lib/wtlink/manage-manifest.d.ts +5 -0
  268. package/dist/lib/wtlink/manage-manifest.d.ts.map +1 -1
  269. package/dist/lib/wtlink/manage-manifest.js +65 -2
  270. package/dist/lib/wtlink/manage-manifest.js.map +1 -1
  271. package/dist/lib/wtlink/manage-manifest.test.js +282 -2
  272. package/dist/lib/wtlink/manage-manifest.test.js.map +1 -1
  273. package/package.json +3 -1
  274. 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
- - **Cross-platform**: Works natively on Windows, macOS, and Linux (no bash/WSL required)
12
- - **Smart State Detection**: Intelligently handles 10+ git scenarios (uncommitted changes, local commits, existing branches, etc.)
13
- - **PR + Worktree Workflow**: Create PRs and dedicated worktrees in one command
14
- - **Shared Repos**: Automatically create worktrees in related repositories
15
- - **Config Syncing**: Share gitignored config files (.env, .vscode, etc.) between worktrees via hard links
16
- - **Configurable**: Per-repo settings via `.worktreerc`
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
- newpr "Add user authentication feature"
39
+ wt new "Add user authentication feature"
35
40
 
36
- # List all worktrees
37
- lswt
41
+ # List worktrees with interactive selection
42
+ wt list
38
43
 
39
- # Clean up merged/closed PR worktrees
40
- cleanpr
44
+ # Clean up merged/closed PRs
45
+ wt clean
41
46
 
42
- # Manage shared config files between worktrees
43
- wtlink
47
+ # Initialize configuration
48
+ wt init
49
+ ```
44
50
 
45
- # Query git state (for AI agents)
46
- wtstate --json
51
+ ---
47
52
 
48
- # Configure settings with interactive wizard
49
- wtconfig init
50
- ```
53
+ ## The `wt` Command
51
54
 
52
- ## Commands
55
+ The unified `wt` command provides access to all git-worktree-tools functionality through an interactive menu or subcommands.
53
56
 
54
- ### newpr
57
+ ### Interactive Mode
55
58
 
56
- Create a new PR with an associated worktree.
59
+ Run `wt` without arguments to launch the interactive menu:
57
60
 
58
61
  ```bash
59
- newpr "Description of the feature"
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
- **Smart State Handling**: The tool detects your current git state and offers appropriate options:
65
+ The menu provides guided workflows for:
66
66
 
67
- - Uncommitted changes? Choose to commit, stash, or leave them
68
- - Local commits on main? Include them or start fresh
69
- - On a feature branch? Create PR for it or start new
70
- - Detached HEAD? Create branch from current commit or main
71
-
72
- ### cleanpr
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
- Clean up worktrees for merged or closed PRs.
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
- ### lswt
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
- List and manage git worktrees with an interactive interface.
88
+ ### Global Options
85
89
 
86
90
  ```bash
87
- lswt # Interactive mode (default in terminal)
88
- lswt --no-interactive # List-only mode
89
- lswt --status # Include PR status (requires gh cli)
90
- lswt --json # Output as JSON for scripting
91
- lswt --verbose # Show more details (commit hashes, full paths)
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
- **Interactive mode** (enabled by default when running in a terminal):
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
- Use `--no-interactive` to disable interactive mode, or pipe output to automatically switch to list mode.
100
+ ## Commands Reference
111
101
 
112
- ### wtlink
102
+ ### wt new / newpr
113
103
 
114
- 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.
104
+ Create a new PR with an associated worktree.
115
105
 
116
106
  ```bash
117
- wtlink # Interactive main menu
118
- wtlink manage # Interactive file browser to select files to share
119
- wtlink link # Create hard links based on manifest
120
- wtlink link ../my-app.pr42 # Link to specific worktree
121
- wtlink validate # Verify manifest integrity
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
- **Command options:**
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
- # validate - Check manifest integrity
141
- wtlink validate # Validate against current worktree
142
- wtlink validate ../other-wt # Validate against specific source
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
- **How it works:**
121
+ ### wt list / lswt
146
122
 
147
- 1. **Discover** Scans for git-ignored files in your repository
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
- **Interactive UI navigation:**
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
- | Key | Action |
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
- **Folder operations:** Actions on folders apply to all files inside. The UI shows a breakdown of child states for each folder.
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
- **Safety confirmations:** Before linking, the tool shows source and destination worktrees with their branch names and warns about potentially dangerous operations:
147
+ ### wt clean / cleanpr
173
148
 
174
- - **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.
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
- The tool recognizes `main`, `master`, and `develop` as base branches. Use `--yes` to skip these confirmations if you're sure about your operation.
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
- **Conflict detection:** When linking, if a file already exists at the destination with different content, you'll be prompted to:
158
+ ### wt link / wtlink
180
159
 
181
- - **Replace** Delete destination and create link
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
- **Manifest format (`.wtlinkrc`):**
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
- The manifest lives in your repository root and tracks which files to share:
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 currently linked
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
- **Good candidates for linking:**
184
+ - **Good for linking:** `.vscode/settings.json`, `.editorconfig`, `.env.local`, certificates
185
+ - **Not for linking:** `node_modules/`, `dist/`, `build/`, `.git/`
203
186
 
204
- - `.vscode/settings.json`, `.editorconfig` Editor config
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
- **Not suitable for linking:**
189
+ ### wt state / wtstate
209
190
 
210
- - `node_modules/` Use [pnpm](https://pnpm.io) for shared dependencies instead
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
- wtstate # Human-readable output
220
- wtstate --json # Machine-readable JSON output
221
- wtstate --verbose # Include file lists and commit details
222
- wtstate --base dev # Specify base branch (default: main)
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` — Current git state scenario (e.g., `main_staged_same`, `branch_with_changes`)
228
- - `scenarioDescription` — Human-readable description
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
- ### wtconfig
208
+ ### wt config
238
209
 
239
- Configuration management with an interactive setup wizard.
210
+ Configuration management with interactive editing.
240
211
 
241
212
  ```bash
242
- wtconfig init # Run interactive setup wizard
243
- wtconfig show # Show current configuration
244
- wtconfig set <key> <val> # Set a configuration value
245
- wtconfig get <key> # Get a configuration value
246
- wtconfig edit # Open config in default editor
247
- wtconfig validate # Validate configuration
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
- **Setup wizard detects:**
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
- **Configuration locations:**
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
- # 1. Query state
270
- STATE=$(wtstate --json)
271
-
272
- # 2. Extract recommended action
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
- ## AI Tool Integration
234
+ ---
280
235
 
281
- All commands support `--json` for machine-readable output, enabling integration with AI CLI tools like Claude Code, Gemini CLI, and Codex.
236
+ ## Configuration
282
237
 
283
- > **Comprehensive Guide:** See [docs/AI-TOOLING.md](docs/AI-TOOLING.md) for detailed documentation including programmatic API, error codes, lifecycle hooks, and integration examples.
238
+ git-worktree-tools uses a three-tier configuration system:
284
239
 
285
- ### Quick Start for AI Agents
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
- The recommended workflow is a three-step "look before you leap" pattern:
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
- ### Non-Interactive Mode
248
+ ### Creating Configuration
301
249
 
302
250
  ```bash
303
- # Create PR without prompts
304
- newpr "Feature X" --non-interactive --json
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
- ```typescript
371
- import {
372
- queryState,
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
- See [docs/AI-TOOLING.md](docs/AI-TOOLING.md#programmatic-api) for complete API documentation.
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
- | `sharedRepos` | string[] | `[]` | Sibling repos to also create worktrees for |
420
- | `baseBranch` | string | `"main"` | Base branch for new PRs |
421
- | `draftPr` | boolean | `false` | Create PRs as drafts by default |
422
- | `worktreePattern` | string | `"{repo}.pr{number}"` | Worktree directory naming pattern |
423
- | `worktreeParent` | string | `".."` | Parent directory for worktrees |
424
- | `branchPrefix` | string | `"feat"` | Prefix for auto-generated branch names |
425
- | `preferredEditor` | string | `"vscode"` | Editor for lswt interactive: "vscode", "cursor", or "auto" |
426
- | `ai` | object | `{}` | AI content generation settings (see below) |
427
- | `hooks` | object | `{}` | Lifecycle hook commands (see below) |
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", // "auto" | "claude" | "gemini" | "openai" | "ollama" | "none"
437
- "branchName": true, // Generate smart branch names from description
438
- "prTitle": true, // Generate PR titles
439
- "prDescription": true // Generate PR descriptions from changes
305
+ "provider": "auto",
306
+ "branchName": true,
307
+ "prTitle": true,
308
+ "prDescription": true,
309
+ "commitMessage": true
440
310
  }
441
311
  }
442
312
  ```
443
313
 
444
- When `provider` is `"auto"`, the tool detects available AI tools in order: Claude Code → Gemini CLI → Ollama → OpenAI API.
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 `newpr` workflow:
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
- | Hook | Description | Critical |
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
- **Critical hooks** abort the workflow if they fail. Non-critical hooks show a warning but continue.
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
- **Hook definition formats:**
348
+ ### Logging Configuration
484
349
 
485
350
  ```json
486
351
  {
487
- "hooks": {
488
- // Simple command
489
- "post-worktree": "npm install",
352
+ "logging": {
353
+ "level": "info",
354
+ "logFile": "/path/to/logfile.log"
355
+ }
356
+ }
357
+ ```
490
358
 
491
- // Multiple commands (run in sequence)
492
- "post-pr": ["echo 'Done!'", "./scripts/notify.sh"],
359
+ **Levels:** `silent`, `error`, `warn`, `info`, `debug`, `trace`
493
360
 
494
- // Complex definition
495
- "pre-commit": {
496
- "command": "npm test",
497
- "timeout": 60000,
498
- "failOnError": true,
499
- "if": "exists:package.json"
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
- **Hook context variables** (available as environment variables):
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
- | Variable | Description |
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
- > **Note:** File syncing between worktrees is managed by `wtlink` using its own `.wtlinkrc` manifest. See the [wtlink section](#wtlink) for details.
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
- newpr "Add dark mode support"
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
- # → Switches to worktree
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 to work on another feature? No problem!
503
+ # Need another feature? No problem!
536
504
  cd ~/projects/my-app
537
- newpr "Fix login bug"
538
- # → Creates another worktree: ~/projects/my-app.pr43
505
+ wt new "Fix login bug"
506
+ # → Creates worktree: ~/projects/my-app.pr43
539
507
 
540
508
  # List your worktrees
541
- lswt
542
- # WORKTREE BRANCH PR STATUS
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
- cleanpr
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 local development instructions, including how to test CLI commands without affecting your global install.
531
+ See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for detailed development instructions.
532
+
533
+ ---
574
534
 
575
535
  ## License
576
536