@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.
Files changed (334) hide show
  1. package/README.md +371 -421
  2. package/dist/cli/cleanpr.js +11 -5
  3. package/dist/cli/cleanpr.js.map +1 -1
  4. package/dist/cli/cleanpr.test.js +12 -1
  5. package/dist/cli/cleanpr.test.js.map +1 -1
  6. package/dist/cli/newpr.js +148 -39
  7. package/dist/cli/newpr.js.map +1 -1
  8. package/dist/cli/newpr.test.js +57 -21
  9. package/dist/cli/newpr.test.js.map +1 -1
  10. package/dist/cli/prs.d.ts +22 -0
  11. package/dist/cli/prs.d.ts.map +1 -0
  12. package/dist/cli/prs.js +275 -0
  13. package/dist/cli/prs.js.map +1 -0
  14. package/dist/cli/prs.test.d.ts +8 -0
  15. package/dist/cli/prs.test.d.ts.map +1 -0
  16. package/dist/cli/prs.test.js +408 -0
  17. package/dist/cli/prs.test.js.map +1 -0
  18. package/dist/cli/wt/clean.d.ts +1 -0
  19. package/dist/cli/wt/clean.d.ts.map +1 -1
  20. package/dist/cli/wt/clean.js +11 -1
  21. package/dist/cli/wt/clean.js.map +1 -1
  22. package/dist/cli/wt/config.d.ts +1 -1
  23. package/dist/cli/wt/config.d.ts.map +1 -1
  24. package/dist/cli/wt/config.js +148 -13
  25. package/dist/cli/wt/config.js.map +1 -1
  26. package/dist/cli/wt/config.test.d.ts +5 -0
  27. package/dist/cli/wt/config.test.d.ts.map +1 -0
  28. package/dist/cli/wt/config.test.js +260 -0
  29. package/dist/cli/wt/config.test.js.map +1 -0
  30. package/dist/cli/wt/entry.test.js +11 -8
  31. package/dist/cli/wt/entry.test.js.map +1 -1
  32. package/dist/cli/wt/init.d.ts +14 -0
  33. package/dist/cli/wt/init.d.ts.map +1 -0
  34. package/dist/cli/wt/init.js +209 -0
  35. package/dist/cli/wt/init.js.map +1 -0
  36. package/dist/cli/wt/init.test.d.ts +5 -0
  37. package/dist/cli/wt/init.test.d.ts.map +1 -0
  38. package/dist/cli/wt/init.test.js +165 -0
  39. package/dist/cli/wt/init.test.js.map +1 -0
  40. package/dist/cli/wt/init.unit.test.d.ts +5 -0
  41. package/dist/cli/wt/init.unit.test.d.ts.map +1 -0
  42. package/dist/cli/wt/init.unit.test.js +432 -0
  43. package/dist/cli/wt/init.unit.test.js.map +1 -0
  44. package/dist/cli/wt/interactive-menu.d.ts +43 -0
  45. package/dist/cli/wt/interactive-menu.d.ts.map +1 -0
  46. package/dist/cli/wt/interactive-menu.js +656 -0
  47. package/dist/cli/wt/interactive-menu.js.map +1 -0
  48. package/dist/cli/wt/interactive-menu.test.d.ts +10 -0
  49. package/dist/cli/wt/interactive-menu.test.d.ts.map +1 -0
  50. package/dist/cli/wt/interactive-menu.test.js +736 -0
  51. package/dist/cli/wt/interactive-menu.test.js.map +1 -0
  52. package/dist/cli/wt/link.d.ts +9 -0
  53. package/dist/cli/wt/link.d.ts.map +1 -1
  54. package/dist/cli/wt/link.js +27 -0
  55. package/dist/cli/wt/link.js.map +1 -1
  56. package/dist/cli/wt/list.d.ts +2 -2
  57. package/dist/cli/wt/list.d.ts.map +1 -1
  58. package/dist/cli/wt/list.js +17 -17
  59. package/dist/cli/wt/list.js.map +1 -1
  60. package/dist/cli/wt/new.d.ts +7 -1
  61. package/dist/cli/wt/new.d.ts.map +1 -1
  62. package/dist/cli/wt/new.js +58 -6
  63. package/dist/cli/wt/new.js.map +1 -1
  64. package/dist/cli/wt/prs.d.ts +21 -0
  65. package/dist/cli/wt/prs.d.ts.map +1 -0
  66. package/dist/cli/wt/prs.js +251 -0
  67. package/dist/cli/wt/prs.js.map +1 -0
  68. package/dist/cli/wt/prs.test.d.ts +5 -0
  69. package/dist/cli/wt/prs.test.d.ts.map +1 -0
  70. package/dist/cli/wt/prs.test.js +410 -0
  71. package/dist/cli/wt/prs.test.js.map +1 -0
  72. package/dist/cli/wt/wt.test.js +159 -16
  73. package/dist/cli/wt/wt.test.js.map +1 -1
  74. package/dist/cli/wt.d.ts +3 -1
  75. package/dist/cli/wt.d.ts.map +1 -1
  76. package/dist/cli/wt.js +103 -3
  77. package/dist/cli/wt.js.map +1 -1
  78. package/dist/cli/wt.unit.test.d.ts +7 -0
  79. package/dist/cli/wt.unit.test.d.ts.map +1 -0
  80. package/dist/cli/wt.unit.test.js +182 -0
  81. package/dist/cli/wt.unit.test.js.map +1 -0
  82. package/dist/cli/wtconfig.js +18 -4
  83. package/dist/cli/wtconfig.js.map +1 -1
  84. package/dist/cli/wtconfig.test.js +21 -16
  85. package/dist/cli/wtconfig.test.js.map +1 -1
  86. package/dist/cli/wtlink.d.ts +2 -1
  87. package/dist/cli/wtlink.d.ts.map +1 -1
  88. package/dist/cli/wtlink.js +41 -2
  89. package/dist/cli/wtlink.js.map +1 -1
  90. package/dist/e2e/cli.e2e.test.js +6 -2
  91. package/dist/e2e/cli.e2e.test.js.map +1 -1
  92. package/dist/e2e/helpers/cli-runner.d.ts.map +1 -1
  93. package/dist/e2e/helpers/cli-runner.js +1 -0
  94. package/dist/e2e/helpers/cli-runner.js.map +1 -1
  95. package/dist/e2e/helpers/gh-mock.d.ts.map +1 -1
  96. package/dist/e2e/helpers/gh-mock.js +55 -1
  97. package/dist/e2e/helpers/gh-mock.js.map +1 -1
  98. package/dist/e2e/helpers/pty-wrapper.d.ts +15 -0
  99. package/dist/e2e/helpers/pty-wrapper.d.ts.map +1 -1
  100. package/dist/e2e/helpers/pty-wrapper.js +65 -0
  101. package/dist/e2e/helpers/pty-wrapper.js.map +1 -1
  102. package/dist/e2e/newpr/scenarios.e2e.test.js +7 -7
  103. package/dist/e2e/newpr/scenarios.e2e.test.js.map +1 -1
  104. package/dist/e2e/newpr-full-flow.e2e.test.js +1 -0
  105. package/dist/e2e/newpr-full-flow.e2e.test.js.map +1 -1
  106. package/dist/e2e/prs/prs.e2e.test.d.ts +7 -0
  107. package/dist/e2e/prs/prs.e2e.test.d.ts.map +1 -0
  108. package/dist/e2e/prs/prs.e2e.test.js +606 -0
  109. package/dist/e2e/prs/prs.e2e.test.js.map +1 -0
  110. package/dist/e2e/wt/interactive-menu.e2e.test.d.ts +8 -0
  111. package/dist/e2e/wt/interactive-menu.e2e.test.d.ts.map +1 -0
  112. package/dist/e2e/wt/interactive-menu.e2e.test.js +583 -0
  113. package/dist/e2e/wt/interactive-menu.e2e.test.js.map +1 -0
  114. package/dist/e2e/wt/wt.e2e.test.d.ts +9 -0
  115. package/dist/e2e/wt/wt.e2e.test.d.ts.map +1 -0
  116. package/dist/e2e/wt/wt.e2e.test.js +597 -0
  117. package/dist/e2e/wt/wt.e2e.test.js.map +1 -0
  118. package/dist/integration/prs.integration.test.d.ts +8 -0
  119. package/dist/integration/prs.integration.test.d.ts.map +1 -0
  120. package/dist/integration/prs.integration.test.js +478 -0
  121. package/dist/integration/prs.integration.test.js.map +1 -0
  122. package/dist/lib/ai/base-provider.d.ts +22 -0
  123. package/dist/lib/ai/base-provider.d.ts.map +1 -1
  124. package/dist/lib/ai/base-provider.js +180 -99
  125. package/dist/lib/ai/base-provider.js.map +1 -1
  126. package/dist/lib/ai/base-provider.test.js +13 -14
  127. package/dist/lib/ai/base-provider.test.js.map +1 -1
  128. package/dist/lib/ai/cli-provider.d.ts +11 -7
  129. package/dist/lib/ai/cli-provider.d.ts.map +1 -1
  130. package/dist/lib/ai/cli-provider.js +19 -49
  131. package/dist/lib/ai/cli-provider.js.map +1 -1
  132. package/dist/lib/ai/cli-provider.test.js +47 -49
  133. package/dist/lib/ai/cli-provider.test.js.map +1 -1
  134. package/dist/lib/ai/index.d.ts +2 -1
  135. package/dist/lib/ai/index.d.ts.map +1 -1
  136. package/dist/lib/ai/index.js +2 -0
  137. package/dist/lib/ai/index.js.map +1 -1
  138. package/dist/lib/ai/provider-manager.js +2 -2
  139. package/dist/lib/ai/provider-manager.js.map +1 -1
  140. package/dist/lib/ai/repo-docs.d.ts +43 -0
  141. package/dist/lib/ai/repo-docs.d.ts.map +1 -0
  142. package/dist/lib/ai/repo-docs.js +274 -0
  143. package/dist/lib/ai/repo-docs.js.map +1 -0
  144. package/dist/lib/ai/repo-docs.test.d.ts +5 -0
  145. package/dist/lib/ai/repo-docs.test.d.ts.map +1 -0
  146. package/dist/lib/ai/repo-docs.test.js +357 -0
  147. package/dist/lib/ai/repo-docs.test.js.map +1 -0
  148. package/dist/lib/ai/types.d.ts +18 -2
  149. package/dist/lib/ai/types.d.ts.map +1 -1
  150. package/dist/lib/ai/types.js.map +1 -1
  151. package/dist/lib/config-editor.d.ts +21 -0
  152. package/dist/lib/config-editor.d.ts.map +1 -0
  153. package/dist/lib/config-editor.js +729 -0
  154. package/dist/lib/config-editor.js.map +1 -0
  155. package/dist/lib/config-editor.test.d.ts +11 -0
  156. package/dist/lib/config-editor.test.d.ts.map +1 -0
  157. package/dist/lib/config-editor.test.js +526 -0
  158. package/dist/lib/config-editor.test.js.map +1 -0
  159. package/dist/lib/config-validation.d.ts +28 -0
  160. package/dist/lib/config-validation.d.ts.map +1 -0
  161. package/dist/lib/config-validation.js +590 -0
  162. package/dist/lib/config-validation.js.map +1 -0
  163. package/dist/lib/config-validation.test.d.ts +5 -0
  164. package/dist/lib/config-validation.test.d.ts.map +1 -0
  165. package/dist/lib/config-validation.test.js +398 -0
  166. package/dist/lib/config-validation.test.js.map +1 -0
  167. package/dist/lib/config.d.ts +149 -6
  168. package/dist/lib/config.d.ts.map +1 -1
  169. package/dist/lib/config.js +261 -55
  170. package/dist/lib/config.js.map +1 -1
  171. package/dist/lib/config.test.js +2 -1
  172. package/dist/lib/config.test.js.map +1 -1
  173. package/dist/lib/constants.d.ts +50 -1
  174. package/dist/lib/constants.d.ts.map +1 -1
  175. package/dist/lib/constants.js +67 -1
  176. package/dist/lib/constants.js.map +1 -1
  177. package/dist/lib/constants.test.d.ts +5 -0
  178. package/dist/lib/constants.test.d.ts.map +1 -0
  179. package/dist/lib/constants.test.js +121 -0
  180. package/dist/lib/constants.test.js.map +1 -0
  181. package/dist/lib/git.d.ts +44 -0
  182. package/dist/lib/git.d.ts.map +1 -1
  183. package/dist/lib/git.js +121 -1
  184. package/dist/lib/git.js.map +1 -1
  185. package/dist/lib/git.test.js +118 -1
  186. package/dist/lib/git.test.js.map +1 -1
  187. package/dist/lib/github.d.ts +41 -0
  188. package/dist/lib/github.d.ts.map +1 -1
  189. package/dist/lib/github.js +109 -0
  190. package/dist/lib/github.js.map +1 -1
  191. package/dist/lib/global-check.d.ts +38 -0
  192. package/dist/lib/global-check.d.ts.map +1 -0
  193. package/dist/lib/global-check.js +135 -0
  194. package/dist/lib/global-check.js.map +1 -0
  195. package/dist/lib/global-check.test.d.ts +5 -0
  196. package/dist/lib/global-check.test.d.ts.map +1 -0
  197. package/dist/lib/global-check.test.js +150 -0
  198. package/dist/lib/global-check.test.js.map +1 -0
  199. package/dist/lib/global-config.d.ts +102 -0
  200. package/dist/lib/global-config.d.ts.map +1 -0
  201. package/dist/lib/global-config.js +234 -0
  202. package/dist/lib/global-config.js.map +1 -0
  203. package/dist/lib/global-config.test.d.ts +5 -0
  204. package/dist/lib/global-config.test.d.ts.map +1 -0
  205. package/dist/lib/global-config.test.js +282 -0
  206. package/dist/lib/global-config.test.js.map +1 -0
  207. package/dist/lib/json-output.d.ts +1 -0
  208. package/dist/lib/json-output.d.ts.map +1 -1
  209. package/dist/lib/json-output.js +2 -0
  210. package/dist/lib/json-output.js.map +1 -1
  211. package/dist/lib/logger.d.ts +175 -0
  212. package/dist/lib/logger.d.ts.map +1 -0
  213. package/dist/lib/logger.js +475 -0
  214. package/dist/lib/logger.js.map +1 -0
  215. package/dist/lib/logger.test.d.ts +5 -0
  216. package/dist/lib/logger.test.d.ts.map +1 -0
  217. package/dist/lib/logger.test.js +292 -0
  218. package/dist/lib/logger.test.js.map +1 -0
  219. package/dist/lib/lswt/action-executors.d.ts.map +1 -1
  220. package/dist/lib/lswt/action-executors.js +2 -1
  221. package/dist/lib/lswt/action-executors.js.map +1 -1
  222. package/dist/lib/lswt/action-executors.test.js +3 -0
  223. package/dist/lib/lswt/action-executors.test.js.map +1 -1
  224. package/dist/lib/lswt/actions.d.ts +1 -0
  225. package/dist/lib/lswt/actions.d.ts.map +1 -1
  226. package/dist/lib/lswt/actions.js +38 -10
  227. package/dist/lib/lswt/actions.js.map +1 -1
  228. package/dist/lib/lswt/actions.test.js +34 -22
  229. package/dist/lib/lswt/actions.test.js.map +1 -1
  230. package/dist/lib/lswt/interactive.js +8 -8
  231. package/dist/lib/lswt/interactive.js.map +1 -1
  232. package/dist/lib/newpr/args.d.ts.map +1 -1
  233. package/dist/lib/newpr/args.js +9 -2
  234. package/dist/lib/newpr/args.js.map +1 -1
  235. package/dist/lib/newpr/args.test.js +1 -1
  236. package/dist/lib/newpr/args.test.js.map +1 -1
  237. package/dist/lib/newpr/types.d.ts +2 -0
  238. package/dist/lib/newpr/types.d.ts.map +1 -1
  239. package/dist/lib/prompts.d.ts +6 -0
  240. package/dist/lib/prompts.d.ts.map +1 -1
  241. package/dist/lib/prompts.js +39 -13
  242. package/dist/lib/prompts.js.map +1 -1
  243. package/dist/lib/prompts.test.js +72 -1
  244. package/dist/lib/prompts.test.js.map +1 -1
  245. package/dist/lib/prs/actions.d.ts +70 -0
  246. package/dist/lib/prs/actions.d.ts.map +1 -0
  247. package/dist/lib/prs/actions.js +444 -0
  248. package/dist/lib/prs/actions.js.map +1 -0
  249. package/dist/lib/prs/actions.test.d.ts +5 -0
  250. package/dist/lib/prs/actions.test.d.ts.map +1 -0
  251. package/dist/lib/prs/actions.test.js +313 -0
  252. package/dist/lib/prs/actions.test.js.map +1 -0
  253. package/dist/lib/prs/data.d.ts +48 -0
  254. package/dist/lib/prs/data.d.ts.map +1 -0
  255. package/dist/lib/prs/data.js +171 -0
  256. package/dist/lib/prs/data.js.map +1 -0
  257. package/dist/lib/prs/data.test.d.ts +5 -0
  258. package/dist/lib/prs/data.test.d.ts.map +1 -0
  259. package/dist/lib/prs/data.test.js +417 -0
  260. package/dist/lib/prs/data.test.js.map +1 -0
  261. package/dist/lib/prs/details.d.ts +57 -0
  262. package/dist/lib/prs/details.d.ts.map +1 -0
  263. package/dist/lib/prs/details.js +246 -0
  264. package/dist/lib/prs/details.js.map +1 -0
  265. package/dist/lib/prs/details.test.d.ts +5 -0
  266. package/dist/lib/prs/details.test.d.ts.map +1 -0
  267. package/dist/lib/prs/details.test.js +325 -0
  268. package/dist/lib/prs/details.test.js.map +1 -0
  269. package/dist/lib/prs/filters.d.ts +56 -0
  270. package/dist/lib/prs/filters.d.ts.map +1 -0
  271. package/dist/lib/prs/filters.js +171 -0
  272. package/dist/lib/prs/filters.js.map +1 -0
  273. package/dist/lib/prs/filters.test.d.ts +5 -0
  274. package/dist/lib/prs/filters.test.d.ts.map +1 -0
  275. package/dist/lib/prs/filters.test.js +312 -0
  276. package/dist/lib/prs/filters.test.js.map +1 -0
  277. package/dist/lib/prs/formatters.d.ts +83 -0
  278. package/dist/lib/prs/formatters.d.ts.map +1 -0
  279. package/dist/lib/prs/formatters.js +389 -0
  280. package/dist/lib/prs/formatters.js.map +1 -0
  281. package/dist/lib/prs/formatters.test.d.ts +2 -0
  282. package/dist/lib/prs/formatters.test.d.ts.map +1 -0
  283. package/dist/lib/prs/formatters.test.js +387 -0
  284. package/dist/lib/prs/formatters.test.js.map +1 -0
  285. package/dist/lib/prs/interactive.d.ts +50 -0
  286. package/dist/lib/prs/interactive.d.ts.map +1 -0
  287. package/dist/lib/prs/interactive.js +453 -0
  288. package/dist/lib/prs/interactive.js.map +1 -0
  289. package/dist/lib/prs/interactive.test.d.ts +5 -0
  290. package/dist/lib/prs/interactive.test.d.ts.map +1 -0
  291. package/dist/lib/prs/interactive.test.js +364 -0
  292. package/dist/lib/prs/interactive.test.js.map +1 -0
  293. package/dist/lib/prs/types.d.ts +152 -0
  294. package/dist/lib/prs/types.d.ts.map +1 -0
  295. package/dist/lib/prs/types.js +17 -0
  296. package/dist/lib/prs/types.js.map +1 -0
  297. package/dist/lib/schema.test.d.ts +10 -0
  298. package/dist/lib/schema.test.d.ts.map +1 -0
  299. package/dist/lib/schema.test.js +309 -0
  300. package/dist/lib/schema.test.js.map +1 -0
  301. package/dist/lib/wtconfig/environment.d.ts.map +1 -1
  302. package/dist/lib/wtconfig/environment.js +6 -4
  303. package/dist/lib/wtconfig/environment.js.map +1 -1
  304. package/dist/lib/wtconfig/environment.test.js +2 -7
  305. package/dist/lib/wtconfig/environment.test.js.map +1 -1
  306. package/dist/lib/wtconfig/types.d.ts +3 -1
  307. package/dist/lib/wtconfig/types.d.ts.map +1 -1
  308. package/dist/lib/wtlink/config-manifest.d.ts +101 -0
  309. package/dist/lib/wtlink/config-manifest.d.ts.map +1 -0
  310. package/dist/lib/wtlink/config-manifest.js +219 -0
  311. package/dist/lib/wtlink/config-manifest.js.map +1 -0
  312. package/dist/lib/wtlink/config-manifest.test.d.ts +2 -0
  313. package/dist/lib/wtlink/config-manifest.test.d.ts.map +1 -0
  314. package/dist/lib/wtlink/config-manifest.test.js +460 -0
  315. package/dist/lib/wtlink/config-manifest.test.js.map +1 -0
  316. package/dist/lib/wtlink/link-configs.d.ts.map +1 -1
  317. package/dist/lib/wtlink/link-configs.js +36 -11
  318. package/dist/lib/wtlink/link-configs.js.map +1 -1
  319. package/dist/lib/wtlink/main-menu.d.ts.map +1 -1
  320. package/dist/lib/wtlink/main-menu.js +58 -50
  321. package/dist/lib/wtlink/main-menu.js.map +1 -1
  322. package/dist/lib/wtlink/main-menu.test.js +42 -40
  323. package/dist/lib/wtlink/main-menu.test.js.map +1 -1
  324. package/dist/lib/wtlink/manage-manifest.d.ts +9 -0
  325. package/dist/lib/wtlink/manage-manifest.d.ts.map +1 -1
  326. package/dist/lib/wtlink/manage-manifest.js +346 -25
  327. package/dist/lib/wtlink/manage-manifest.js.map +1 -1
  328. package/dist/lib/wtlink/manage-manifest.test.js +196 -7
  329. package/dist/lib/wtlink/manage-manifest.test.js.map +1 -1
  330. package/dist/lib/wtlink/validate-manifest.d.ts.map +1 -1
  331. package/dist/lib/wtlink/validate-manifest.js +27 -6
  332. package/dist/lib/wtlink/validate-manifest.js.map +1 -1
  333. package/package.json +2 -1
  334. 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
- - **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,60 +32,88 @@ npm install -g @camaradesuk/git-worktree-tools
30
32
  ## Quick Start
31
33
 
32
34
  ```bash
33
- # Using the unified wt command (recommended)
34
- wt new "Add user authentication feature" # Create PR with worktree
35
- wt list # List worktrees
36
- wt clean # Clean up merged/closed PRs
37
- wt link # Manage shared config files
38
- wt state --json # Query git state
39
- wt config init # Configure settings
40
-
41
- # Or use individual commands directly
42
- newpr "Add user authentication feature"
43
- lswt
44
- cleanpr
45
- wtlink
46
- wtstate --json
47
- wtconfig init
35
+ # Interactive menu (recommended for exploration)
36
+ wt
37
+
38
+ # Create a new PR with worktree
39
+ wt new "Add user authentication feature"
40
+
41
+ # List worktrees with interactive selection
42
+ wt list
43
+
44
+ # 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
- ## Commands
54
+ ---
55
+
56
+ ## The `wt` Command
51
57
 
52
- ### wt (Unified Command)
58
+ The unified `wt` command provides access to all git-worktree-tools functionality through an interactive menu or subcommands.
53
59
 
54
- The `wt` command provides a single entry point for all git-worktree-tools functionality:
60
+ ### Interactive Mode
61
+
62
+ Run `wt` without arguments to launch the interactive menu:
55
63
 
56
64
  ```bash
57
- wt <command> [options]
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
- All subcommands accept the same options as their standalone equivalents. For example:
93
+ ### Global Options
71
94
 
72
95
  ```bash
73
- wt new "Add feature" --draft # Same as: newpr "Add feature" --draft
74
- wt list --json # Same as: lswt --json
75
- wt clean --all # Same as: cleanpr --all
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
- ### newpr
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
- newpr "Description of the feature"
84
- newpr --branch my-feature "Feature description"
85
- newpr --pr 123 # Work on existing PR
86
- newpr --draft "WIP feature"
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
- ### cleanpr
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
- lswt # Interactive mode (default in terminal)
112
- lswt --no-interactive # List-only mode
113
- lswt --status # Include PR status (requires gh cli)
114
- lswt --json # Output as JSON for scripting
115
- lswt --verbose # Show more details (commit hashes, full paths)
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 mode** (enabled by default when running in a terminal):
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
- The search uses fuzzy matching, so typing `dm` will match `dark-mode`. Press `Enter` to confirm the filter, `Escape` to cancel, or `Backspace` to edit.
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
- Use `--no-interactive` to disable interactive mode, or pipe output to automatically switch to list mode.
152
+ ### wt prs
144
153
 
145
- ### wtlink
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
- wtlink # Interactive main menu
151
- wtlink manage # Interactive file browser to select files to share
152
- wtlink link # Create hard links based on manifest
153
- wtlink link ../my-app.pr42 # Link to specific worktree
154
- wtlink validate # Verify manifest integrity
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
- **Command options:**
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
- ```bash
160
- # manage - Discover and manage the manifest
161
- wtlink manage # Interactive mode
162
- wtlink manage --non-interactive # Auto-add new files as commented
163
- wtlink manage --clean # Remove stale entries automatically
164
- wtlink manage --dry-run # Preview changes without writing
165
- wtlink manage --backup # Create .wtlinkrc.bak before updating
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
- # validate - Check manifest integrity
174
- wtlink validate # Validate against current worktree
175
- wtlink validate ../other-wt # Validate against specific source
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
- **How it works:**
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
- The tool recognizes `main`, `master`, and `develop` as base branches. Use `--yes` to skip these confirmations if you're sure about your operation.
210
+ Interactive CLI for managing configuration file links between git worktrees.
211
211
 
212
- **Conflict detection:** When linking, if a file already exists at the destination with different content, you'll be prompted to:
213
-
214
- - **Replace** Delete destination and create link
215
- - **Ignore** Keep destination file as-is
216
- - **Remove** Remove entry from manifest
217
-
218
- **Manifest format (`.wtlinkrc`):**
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
- The manifest lives in your repository root and tracks which files to share:
221
+ **Configuration format (`.worktreerc`):**
221
222
 
222
- ```text
223
- .vscode/settings.json
224
- .editorconfig
225
- .env.local
226
- # .vscode/launch.json
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
- - Active entries (no `#`) are hard-linked between worktrees
230
- - Commented entries (`#`) are tracked but not currently linked
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
- **Good candidates for linking:**
235
+ **Legacy format (`.wtlinkrc`):** Still supported for backwards compatibility. Run `wtlink migrate` to convert to the new JSON format.
236
236
 
237
- - `.vscode/settings.json`, `.editorconfig` — Editor config
238
- - `.env.local`, `.env.development` — Local environment variables
239
- - `certificates/`, `credentials/` — Local dev certificates
237
+ **Best practices:**
240
238
 
241
- **Not suitable for linking:**
239
+ - **Good for linking:** `.vscode/settings.json`, `.editorconfig`, `.env.local`, certificates
240
+ - **Not for linking:** `node_modules/`, `dist/`, `build/`, `.git/`
242
241
 
243
- - `node_modules/` — Use [pnpm](https://pnpm.io) for shared dependencies instead
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. Returns structured information about the repository state, available actions, and recommended next steps.
246
+ Query the current git state for AI agents and automation.
250
247
 
251
248
  ```bash
252
- wtstate # Human-readable output
253
- wtstate --json # Machine-readable JSON output
254
- wtstate --verbose # Include file lists and commit details
255
- wtstate --base dev # Specify base branch (default: main)
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` — Current git state scenario (e.g., `main_staged_same`, `branch_with_changes`)
261
- - `scenarioDescription` — Human-readable description
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
- ### wtconfig
263
+ ### wt config
271
264
 
272
- Configuration management with an interactive setup wizard.
265
+ Configuration management with interactive editing.
273
266
 
274
267
  ```bash
275
- wtconfig init # Run interactive setup wizard
276
- wtconfig show # Show current configuration
277
- wtconfig set <key> <val> # Set a configuration value
278
- wtconfig get <key> # Get a configuration value
279
- wtconfig edit # Open config in default editor
280
- wtconfig validate # Validate configuration
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
- **Setup wizard detects:**
278
+ ### wt init
284
279
 
285
- - Operating system and installed tools
286
- - Git configuration (version, user, email)
287
- - GitHub CLI authentication
288
- - Available AI tools (Claude Code, Gemini CLI, Ollama)
289
- - Package manager (npm, pnpm, yarn, bun)
290
- - IDE availability (VS Code, Cursor)
291
-
292
- **Configuration locations:**
293
-
294
- - **Global:** `~/.worktreerc` (applies to all repos)
295
- - **Repository:** `.worktreerc` or `.worktreerc.json` (repo-specific)
296
-
297
- Repository config overrides global settings.
298
-
299
- **Example AI workflow:**
280
+ Initialize git-worktree-tools configuration.
300
281
 
301
282
  ```bash
302
- # 1. Query state
303
- STATE=$(wtstate --json)
304
-
305
- # 2. Extract recommended action
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
- ## AI Tool Integration
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
- ### Quick Start for AI Agents
319
-
320
- The recommended workflow is a three-step "look before you leap" pattern:
291
+ ## Configuration
321
292
 
322
- ```bash
323
- # 1. Query current git state
324
- STATE=$(wtstate --json)
293
+ git-worktree-tools uses a three-tier configuration system:
325
294
 
326
- # 2. Extract recommended action
327
- ACTION=$(echo $STATE | jq -r '.data.recommendedAction')
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
- # 3. Execute with the chosen action
330
- newpr "Add feature X" --non-interactive --action=$ACTION --json
331
- ```
301
+ **Merge order:** defaults global repo ← local
332
302
 
333
- ### Non-Interactive Mode
303
+ ### Creating Configuration
334
304
 
335
305
  ```bash
336
- # Create PR without prompts
337
- newpr "Feature X" --non-interactive --json
338
- newpr "Fix bug" --non-interactive --action=commit_staged --json
306
+ # Interactive setup (recommended)
307
+ wt init
339
308
 
340
- # Clean PRs with dry-run preview
341
- cleanpr --all --dry-run --json
342
- cleanpr --all --json
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
- See [docs/AI-TOOLING.md](docs/AI-TOOLING.md#programmatic-api) for complete API documentation.
427
-
428
- ## Configuration
429
-
430
- Create a `.worktreerc` file in your repository root, or use `wtconfig init` to generate one interactively:
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
- | `sharedRepos` | string[] | `[]` | Sibling repos to also create worktrees for |
453
- | `baseBranch` | string | `"main"` | Base branch for new PRs |
454
- | `draftPr` | boolean | `false` | Create PRs as drafts by default |
455
- | `worktreePattern` | string | `"{repo}.pr{number}"` | Worktree directory naming pattern |
456
- | `worktreeParent` | string | `".."` | Parent directory for worktrees |
457
- | `branchPrefix` | string | `"feat"` | Prefix for auto-generated branch names |
458
- | `preferredEditor` | string | `"vscode"` | Editor for lswt interactive: "vscode", "cursor", or "auto" |
459
- | `ai` | object | `{}` | AI content generation settings (see below) |
460
- | `hooks` | object | `{}` | Lifecycle hook commands (see below) |
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", // "auto" | "claude" | "gemini" | "openai" | "ollama" | "none"
470
- "branchName": true, // Generate smart branch names from description
471
- "prTitle": true, // Generate PR titles
472
- "prDescription": true // Generate PR descriptions from changes
361
+ "provider": "auto",
362
+ "branchName": true,
363
+ "prTitle": true,
364
+ "prDescription": true,
365
+ "commitMessage": true
473
366
  }
474
367
  }
475
368
  ```
476
369
 
477
- When `provider` is `"auto"`, the tool detects available AI tools in order: Claude Code → Gemini CLI → Ollama → OpenAI API.
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 `newpr` workflow:
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
- | Hook | Description | Critical |
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
- **Critical hooks** abort the workflow if they fail. Non-critical hooks show a warning but continue.
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
- **Hook definition formats:**
404
+ ### Logging Configuration
517
405
 
518
406
  ```json
519
407
  {
520
- "hooks": {
521
- // Simple command
522
- "post-worktree": "npm install",
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
- **Hook context variables** (available as environment variables):
415
+ **Levels:** `silent`, `error`, `warn`, `info`, `debug`, `trace`
539
416
 
540
- | Variable | Description |
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
- > **Note:** File syncing between worktrees is managed by `wtlink` using its own `.wtlinkrc` manifest. See the [wtlink section](#wtlink) for details.
419
+ ---
551
420
 
552
- ## Example Workflow
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
- # Start in your main repo
556
- cd ~/projects/my-app
428
+ # 1. Query current git state
429
+ STATE=$(wt state --json)
557
430
 
558
- # Create a new feature PR
559
- newpr "Add dark mode support"
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
- # Work on the feature in the dedicated worktree
566
- # ... make changes, commit, push ...
434
+ # 3. Execute with the chosen action
435
+ wt new "Add feature X" --non-interactive --action=$ACTION --json
436
+ ```
567
437
 
568
- # Need to work on another feature? No problem!
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
- # List your worktrees
574
- lswt
575
- # WORKTREE BRANCH PR STATUS
576
- # ~/projects/my-app main - -
577
- # ~/projects/my-app.pr42 feat/add-dark-mode-xyz123 #42 open
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
- # After PRs are merged, clean up
581
- cleanpr
582
- # → Removes worktrees for merged PRs
583
- # Deletes local branches
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 in your shell:
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
- After setup, you can tab-complete commands and options:
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
- wt <TAB> # Shows: new, list, clean, link, state, config, completion
620
- wt new --<TAB> # Shows: --pr, --draft, --json, --non-interactive, --action
621
- wt list --<TAB> # Shows: --verbose, --json, --no-status, --no-interactive
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 local development instructions, including how to test CLI commands without affecting your global install.
592
+ See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for detailed development instructions.
593
+
594
+ ---
645
595
 
646
596
  ## License
647
597