@lumenflow/core 3.1.2 → 3.1.3

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 (1008) hide show
  1. package/README.md +16 -16
  2. package/dist/cli/is-agent-branch.js +31 -10
  3. package/dist/index.js +3 -0
  4. package/package.json +5 -2
  5. package/dist/active-wu-detector.d.ts +0 -25
  6. package/dist/active-wu-detector.d.ts.map +0 -1
  7. package/dist/active-wu-detector.js +0 -109
  8. package/dist/active-wu-detector.js.map +0 -1
  9. package/dist/adapters/context-adapters.d.ts +0 -101
  10. package/dist/adapters/context-adapters.d.ts.map +0 -1
  11. package/dist/adapters/context-adapters.js +0 -98
  12. package/dist/adapters/context-adapters.js.map +0 -1
  13. package/dist/adapters/filesystem-metrics.adapter.d.ts +0 -91
  14. package/dist/adapters/filesystem-metrics.adapter.d.ts.map +0 -1
  15. package/dist/adapters/filesystem-metrics.adapter.js +0 -530
  16. package/dist/adapters/filesystem-metrics.adapter.js.map +0 -1
  17. package/dist/adapters/index.d.ts +0 -15
  18. package/dist/adapters/index.d.ts.map +0 -1
  19. package/dist/adapters/index.js +0 -21
  20. package/dist/adapters/index.js.map +0 -1
  21. package/dist/adapters/mock-dashboard-renderer.adapter.d.ts +0 -86
  22. package/dist/adapters/mock-dashboard-renderer.adapter.d.ts.map +0 -1
  23. package/dist/adapters/mock-dashboard-renderer.adapter.js +0 -93
  24. package/dist/adapters/mock-dashboard-renderer.adapter.js.map +0 -1
  25. package/dist/adapters/recovery-adapters.d.ts +0 -41
  26. package/dist/adapters/recovery-adapters.d.ts.map +0 -1
  27. package/dist/adapters/recovery-adapters.js +0 -32
  28. package/dist/adapters/recovery-adapters.js.map +0 -1
  29. package/dist/adapters/terminal-renderer.adapter.d.ts +0 -86
  30. package/dist/adapters/terminal-renderer.adapter.d.ts.map +0 -1
  31. package/dist/adapters/terminal-renderer.adapter.js +0 -342
  32. package/dist/adapters/terminal-renderer.adapter.js.map +0 -1
  33. package/dist/adapters/validation-adapters.d.ts +0 -53
  34. package/dist/adapters/validation-adapters.d.ts.map +0 -1
  35. package/dist/adapters/validation-adapters.js +0 -48
  36. package/dist/adapters/validation-adapters.js.map +0 -1
  37. package/dist/agent-patterns-registry.d.ts +0 -141
  38. package/dist/agent-patterns-registry.d.ts.map +0 -1
  39. package/dist/agent-patterns-registry.js +0 -319
  40. package/dist/agent-patterns-registry.js.map +0 -1
  41. package/dist/arg-parser.d.ts +0 -94
  42. package/dist/arg-parser.d.ts.map +0 -1
  43. package/dist/arg-parser.js +0 -774
  44. package/dist/arg-parser.js.map +0 -1
  45. package/dist/atomic-merge.d.ts +0 -21
  46. package/dist/atomic-merge.d.ts.map +0 -1
  47. package/dist/atomic-merge.js +0 -87
  48. package/dist/atomic-merge.js.map +0 -1
  49. package/dist/backlog-editor.d.ts +0 -103
  50. package/dist/backlog-editor.d.ts.map +0 -1
  51. package/dist/backlog-editor.js +0 -158
  52. package/dist/backlog-editor.js.map +0 -1
  53. package/dist/backlog-generator.d.ts +0 -90
  54. package/dist/backlog-generator.d.ts.map +0 -1
  55. package/dist/backlog-generator.js +0 -536
  56. package/dist/backlog-generator.js.map +0 -1
  57. package/dist/backlog-parser.d.ts +0 -46
  58. package/dist/backlog-parser.d.ts.map +0 -1
  59. package/dist/backlog-parser.js +0 -105
  60. package/dist/backlog-parser.js.map +0 -1
  61. package/dist/backlog-sync-validator.d.ts +0 -88
  62. package/dist/backlog-sync-validator.d.ts.map +0 -1
  63. package/dist/backlog-sync-validator.js +0 -324
  64. package/dist/backlog-sync-validator.js.map +0 -1
  65. package/dist/beacon-migration.d.ts +0 -56
  66. package/dist/beacon-migration.js +0 -101
  67. package/dist/branch-check.d.ts +0 -63
  68. package/dist/branch-check.d.ts.map +0 -1
  69. package/dist/branch-check.js +0 -197
  70. package/dist/branch-check.js.map +0 -1
  71. package/dist/branch-drift.d.ts +0 -24
  72. package/dist/branch-drift.d.ts.map +0 -1
  73. package/dist/branch-drift.js +0 -54
  74. package/dist/branch-drift.js.map +0 -1
  75. package/dist/cleanup-install-config.d.ts +0 -24
  76. package/dist/cleanup-install-config.d.ts.map +0 -1
  77. package/dist/cleanup-install-config.js +0 -40
  78. package/dist/cleanup-install-config.js.map +0 -1
  79. package/dist/cleanup-lock.d.ts +0 -125
  80. package/dist/cleanup-lock.d.ts.map +0 -1
  81. package/dist/cleanup-lock.js +0 -325
  82. package/dist/cleanup-lock.js.map +0 -1
  83. package/dist/cli/is-agent-branch.d.ts +0 -15
  84. package/dist/cli/is-agent-branch.d.ts.map +0 -1
  85. package/dist/cli/is-agent-branch.js.map +0 -1
  86. package/dist/cloud-detect.d.ts +0 -145
  87. package/dist/cloud-detect.d.ts.map +0 -1
  88. package/dist/cloud-detect.js +0 -116
  89. package/dist/cloud-detect.js.map +0 -1
  90. package/dist/code-path-validator.d.ts +0 -147
  91. package/dist/code-path-validator.d.ts.map +0 -1
  92. package/dist/code-path-validator.js +0 -551
  93. package/dist/code-path-validator.js.map +0 -1
  94. package/dist/code-paths-overlap.d.ts +0 -50
  95. package/dist/code-paths-overlap.d.ts.map +0 -1
  96. package/dist/code-paths-overlap.js +0 -248
  97. package/dist/code-paths-overlap.js.map +0 -1
  98. package/dist/color-support.d.ts +0 -21
  99. package/dist/color-support.d.ts.map +0 -1
  100. package/dist/color-support.js +0 -67
  101. package/dist/color-support.js.map +0 -1
  102. package/dist/commands-logger.d.ts +0 -71
  103. package/dist/commands-logger.d.ts.map +0 -1
  104. package/dist/commands-logger.js +0 -256
  105. package/dist/commands-logger.js.map +0 -1
  106. package/dist/commit-message-utils.d.ts +0 -26
  107. package/dist/commit-message-utils.d.ts.map +0 -1
  108. package/dist/commit-message-utils.js +0 -44
  109. package/dist/commit-message-utils.js.map +0 -1
  110. package/dist/compliance-parser.d.ts +0 -125
  111. package/dist/compliance-parser.d.ts.map +0 -1
  112. package/dist/compliance-parser.js +0 -457
  113. package/dist/compliance-parser.js.map +0 -1
  114. package/dist/constants/backlog-patterns.d.ts +0 -21
  115. package/dist/constants/backlog-patterns.d.ts.map +0 -1
  116. package/dist/constants/backlog-patterns.js +0 -26
  117. package/dist/constants/backlog-patterns.js.map +0 -1
  118. package/dist/constants/dora-constants.d.ts +0 -50
  119. package/dist/constants/dora-constants.d.ts.map +0 -1
  120. package/dist/constants/dora-constants.js +0 -56
  121. package/dist/constants/dora-constants.js.map +0 -1
  122. package/dist/constants/gate-constants.d.ts +0 -16
  123. package/dist/constants/gate-constants.d.ts.map +0 -1
  124. package/dist/constants/gate-constants.js +0 -18
  125. package/dist/constants/gate-constants.js.map +0 -1
  126. package/dist/constants/linter-constants.d.ts +0 -17
  127. package/dist/constants/linter-constants.d.ts.map +0 -1
  128. package/dist/constants/linter-constants.js +0 -19
  129. package/dist/constants/linter-constants.js.map +0 -1
  130. package/dist/constants/tokenizer-constants.d.ts +0 -16
  131. package/dist/constants/tokenizer-constants.d.ts.map +0 -1
  132. package/dist/constants/tokenizer-constants.js +0 -18
  133. package/dist/constants/tokenizer-constants.js.map +0 -1
  134. package/dist/context/context-computer.d.ts +0 -36
  135. package/dist/context/context-computer.d.ts.map +0 -1
  136. package/dist/context/context-computer.js +0 -128
  137. package/dist/context/context-computer.js.map +0 -1
  138. package/dist/context/git-state-reader.d.ts +0 -37
  139. package/dist/context/git-state-reader.d.ts.map +0 -1
  140. package/dist/context/git-state-reader.js +0 -64
  141. package/dist/context/git-state-reader.js.map +0 -1
  142. package/dist/context/index.d.ts +0 -18
  143. package/dist/context/index.d.ts.map +0 -1
  144. package/dist/context/index.js +0 -20
  145. package/dist/context/index.js.map +0 -1
  146. package/dist/context/location-resolver.d.ts +0 -34
  147. package/dist/context/location-resolver.d.ts.map +0 -1
  148. package/dist/context/location-resolver.js +0 -179
  149. package/dist/context/location-resolver.js.map +0 -1
  150. package/dist/context/wu-state-reader.d.ts +0 -30
  151. package/dist/context/wu-state-reader.d.ts.map +0 -1
  152. package/dist/context/wu-state-reader.js +0 -126
  153. package/dist/context/wu-state-reader.js.map +0 -1
  154. package/dist/context-di.d.ts +0 -185
  155. package/dist/context-di.d.ts.map +0 -1
  156. package/dist/context-di.js +0 -165
  157. package/dist/context-di.js.map +0 -1
  158. package/dist/context-validation-integration.d.ts +0 -69
  159. package/dist/context-validation-integration.d.ts.map +0 -1
  160. package/dist/context-validation-integration.js +0 -161
  161. package/dist/context-validation-integration.js.map +0 -1
  162. package/dist/core/scope-checker.d.ts +0 -80
  163. package/dist/core/scope-checker.d.ts.map +0 -1
  164. package/dist/core/scope-checker.js +0 -166
  165. package/dist/core/scope-checker.js.map +0 -1
  166. package/dist/core/tool-runner.d.ts +0 -136
  167. package/dist/core/tool-runner.d.ts.map +0 -1
  168. package/dist/core/tool-runner.js +0 -396
  169. package/dist/core/tool-runner.js.map +0 -1
  170. package/dist/core/tool.constants.d.ts +0 -106
  171. package/dist/core/tool.constants.d.ts.map +0 -1
  172. package/dist/core/tool.constants.js +0 -104
  173. package/dist/core/tool.constants.js.map +0 -1
  174. package/dist/core/tool.schemas.d.ts +0 -227
  175. package/dist/core/tool.schemas.d.ts.map +0 -1
  176. package/dist/core/tool.schemas.js +0 -229
  177. package/dist/core/tool.schemas.js.map +0 -1
  178. package/dist/core/worktree-guard.d.ts +0 -115
  179. package/dist/core/worktree-guard.d.ts.map +0 -1
  180. package/dist/core/worktree-guard.js +0 -245
  181. package/dist/core/worktree-guard.js.map +0 -1
  182. package/dist/coverage-gate.d.ts +0 -126
  183. package/dist/coverage-gate.d.ts.map +0 -1
  184. package/dist/coverage-gate.js +0 -209
  185. package/dist/coverage-gate.js.map +0 -1
  186. package/dist/cycle-detector.d.ts +0 -52
  187. package/dist/cycle-detector.d.ts.map +0 -1
  188. package/dist/cycle-detector.js +0 -84
  189. package/dist/cycle-detector.js.map +0 -1
  190. package/dist/date-utils.d.ts +0 -66
  191. package/dist/date-utils.d.ts.map +0 -1
  192. package/dist/date-utils.js +0 -143
  193. package/dist/date-utils.js.map +0 -1
  194. package/dist/delegation-escalation.d.ts +0 -71
  195. package/dist/delegation-escalation.d.ts.map +0 -1
  196. package/dist/delegation-escalation.js +0 -264
  197. package/dist/delegation-escalation.js.map +0 -1
  198. package/dist/delegation-monitor.d.ts +0 -262
  199. package/dist/delegation-monitor.d.ts.map +0 -1
  200. package/dist/delegation-monitor.js +0 -678
  201. package/dist/delegation-monitor.js.map +0 -1
  202. package/dist/delegation-recovery.d.ts +0 -62
  203. package/dist/delegation-recovery.d.ts.map +0 -1
  204. package/dist/delegation-recovery.js +0 -304
  205. package/dist/delegation-recovery.js.map +0 -1
  206. package/dist/delegation-registry-schema.d.ts +0 -75
  207. package/dist/delegation-registry-schema.d.ts.map +0 -1
  208. package/dist/delegation-registry-schema.js +0 -93
  209. package/dist/delegation-registry-schema.js.map +0 -1
  210. package/dist/delegation-registry-store.d.ts +0 -145
  211. package/dist/delegation-registry-store.d.ts.map +0 -1
  212. package/dist/delegation-registry-store.js +0 -308
  213. package/dist/delegation-registry-store.js.map +0 -1
  214. package/dist/delegation-tree.d.ts +0 -52
  215. package/dist/delegation-tree.d.ts.map +0 -1
  216. package/dist/delegation-tree.js +0 -205
  217. package/dist/delegation-tree.js.map +0 -1
  218. package/dist/dependency-graph.d.ts +0 -169
  219. package/dist/dependency-graph.d.ts.map +0 -1
  220. package/dist/dependency-graph.js +0 -612
  221. package/dist/dependency-graph.js.map +0 -1
  222. package/dist/dependency-guard.d.ts +0 -41
  223. package/dist/dependency-guard.d.ts.map +0 -1
  224. package/dist/dependency-guard.js +0 -145
  225. package/dist/dependency-guard.js.map +0 -1
  226. package/dist/dependency-validator.d.ts +0 -89
  227. package/dist/dependency-validator.d.ts.map +0 -1
  228. package/dist/dependency-validator.js +0 -155
  229. package/dist/dependency-validator.js.map +0 -1
  230. package/dist/docs-path-validator.d.ts +0 -16
  231. package/dist/docs-path-validator.d.ts.map +0 -1
  232. package/dist/docs-path-validator.js +0 -98
  233. package/dist/docs-path-validator.js.map +0 -1
  234. package/dist/domain/context.schemas.d.ts +0 -170
  235. package/dist/domain/context.schemas.d.ts.map +0 -1
  236. package/dist/domain/context.schemas.js +0 -151
  237. package/dist/domain/context.schemas.js.map +0 -1
  238. package/dist/domain/index.d.ts +0 -15
  239. package/dist/domain/index.d.ts.map +0 -1
  240. package/dist/domain/index.js +0 -23
  241. package/dist/domain/index.js.map +0 -1
  242. package/dist/domain/orchestration.constants.d.ts +0 -111
  243. package/dist/domain/orchestration.constants.d.ts.map +0 -1
  244. package/dist/domain/orchestration.constants.js +0 -130
  245. package/dist/domain/orchestration.constants.js.map +0 -1
  246. package/dist/domain/orchestration.schemas.d.ts +0 -307
  247. package/dist/domain/orchestration.schemas.d.ts.map +0 -1
  248. package/dist/domain/orchestration.schemas.js +0 -214
  249. package/dist/domain/orchestration.schemas.js.map +0 -1
  250. package/dist/domain/orchestration.types.d.ts +0 -134
  251. package/dist/domain/orchestration.types.d.ts.map +0 -1
  252. package/dist/domain/orchestration.types.js +0 -5
  253. package/dist/domain/orchestration.types.js.map +0 -1
  254. package/dist/domain/recovery.schemas.d.ts +0 -164
  255. package/dist/domain/recovery.schemas.d.ts.map +0 -1
  256. package/dist/domain/recovery.schemas.js +0 -134
  257. package/dist/domain/recovery.schemas.js.map +0 -1
  258. package/dist/domain/validation.schemas.d.ts +0 -147
  259. package/dist/domain/validation.schemas.d.ts.map +0 -1
  260. package/dist/domain/validation.schemas.js +0 -117
  261. package/dist/domain/validation.schemas.js.map +0 -1
  262. package/dist/error-handler.d.ts +0 -144
  263. package/dist/error-handler.d.ts.map +0 -1
  264. package/dist/error-handler.js +0 -214
  265. package/dist/error-handler.js.map +0 -1
  266. package/dist/file-classifiers.d.ts +0 -63
  267. package/dist/file-classifiers.d.ts.map +0 -1
  268. package/dist/file-classifiers.js +0 -111
  269. package/dist/file-classifiers.js.map +0 -1
  270. package/dist/force-bypass-audit.d.ts +0 -47
  271. package/dist/force-bypass-audit.d.ts.map +0 -1
  272. package/dist/force-bypass-audit.js +0 -146
  273. package/dist/force-bypass-audit.js.map +0 -1
  274. package/dist/gates-agent-mode.d.ts +0 -107
  275. package/dist/gates-agent-mode.d.ts.map +0 -1
  276. package/dist/gates-agent-mode.js +0 -138
  277. package/dist/gates-agent-mode.js.map +0 -1
  278. package/dist/gates-config.d.ts +0 -268
  279. package/dist/gates-config.d.ts.map +0 -1
  280. package/dist/gates-config.js +0 -644
  281. package/dist/gates-config.js.map +0 -1
  282. package/dist/generate-traceability.d.ts +0 -106
  283. package/dist/generate-traceability.d.ts.map +0 -1
  284. package/dist/generate-traceability.js +0 -387
  285. package/dist/generate-traceability.js.map +0 -1
  286. package/dist/git-adapter.d.ts +0 -406
  287. package/dist/git-adapter.d.ts.map +0 -1
  288. package/dist/git-adapter.js +0 -686
  289. package/dist/git-adapter.js.map +0 -1
  290. package/dist/git-context-extractor.d.ts +0 -102
  291. package/dist/git-context-extractor.d.ts.map +0 -1
  292. package/dist/git-context-extractor.js +0 -571
  293. package/dist/git-context-extractor.js.map +0 -1
  294. package/dist/git-staged-validator.d.ts +0 -33
  295. package/dist/git-staged-validator.d.ts.map +0 -1
  296. package/dist/git-staged-validator.js +0 -52
  297. package/dist/git-staged-validator.js.map +0 -1
  298. package/dist/hardcoded-strings.d.ts +0 -67
  299. package/dist/hardcoded-strings.d.ts.map +0 -1
  300. package/dist/hardcoded-strings.js +0 -276
  301. package/dist/hardcoded-strings.js.map +0 -1
  302. package/dist/incremental-lint.d.ts +0 -71
  303. package/dist/incremental-lint.d.ts.map +0 -1
  304. package/dist/incremental-lint.js +0 -132
  305. package/dist/incremental-lint.js.map +0 -1
  306. package/dist/incremental-test.d.ts +0 -33
  307. package/dist/incremental-test.d.ts.map +0 -1
  308. package/dist/incremental-test.js +0 -64
  309. package/dist/incremental-test.js.map +0 -1
  310. package/dist/index.d.ts +0 -104
  311. package/dist/index.d.ts.map +0 -1
  312. package/dist/index.js.map +0 -1
  313. package/dist/invariants/check-automated-tests.d.ts +0 -42
  314. package/dist/invariants/check-automated-tests.d.ts.map +0 -1
  315. package/dist/invariants/check-automated-tests.js +0 -171
  316. package/dist/invariants/check-automated-tests.js.map +0 -1
  317. package/dist/invariants-runner.d.ts +0 -108
  318. package/dist/invariants-runner.d.ts.map +0 -1
  319. package/dist/invariants-runner.js +0 -547
  320. package/dist/invariants-runner.js.map +0 -1
  321. package/dist/lane-checker.d.ts +0 -132
  322. package/dist/lane-checker.d.ts.map +0 -1
  323. package/dist/lane-checker.js +0 -743
  324. package/dist/lane-checker.js.map +0 -1
  325. package/dist/lane-inference.d.ts +0 -29
  326. package/dist/lane-inference.d.ts.map +0 -1
  327. package/dist/lane-inference.js +0 -210
  328. package/dist/lane-inference.js.map +0 -1
  329. package/dist/lane-lock.d.ts +0 -220
  330. package/dist/lane-lock.d.ts.map +0 -1
  331. package/dist/lane-lock.js +0 -499
  332. package/dist/lane-lock.js.map +0 -1
  333. package/dist/lane-suggest-prompt.d.ts +0 -97
  334. package/dist/lane-suggest-prompt.d.ts.map +0 -1
  335. package/dist/lane-suggest-prompt.js +0 -362
  336. package/dist/lane-suggest-prompt.js.map +0 -1
  337. package/dist/lane-validator.d.ts +0 -49
  338. package/dist/lane-validator.d.ts.map +0 -1
  339. package/dist/lane-validator.js +0 -117
  340. package/dist/lane-validator.js.map +0 -1
  341. package/dist/logs-lib.d.ts +0 -89
  342. package/dist/logs-lib.d.ts.map +0 -1
  343. package/dist/logs-lib.js +0 -214
  344. package/dist/logs-lib.js.map +0 -1
  345. package/dist/lumenflow-config-schema.d.ts +0 -1428
  346. package/dist/lumenflow-config-schema.d.ts.map +0 -1
  347. package/dist/lumenflow-config-schema.js +0 -1255
  348. package/dist/lumenflow-config-schema.js.map +0 -1
  349. package/dist/lumenflow-config.d.ts +0 -94
  350. package/dist/lumenflow-config.d.ts.map +0 -1
  351. package/dist/lumenflow-config.js +0 -253
  352. package/dist/lumenflow-config.js.map +0 -1
  353. package/dist/lumenflow-home.d.ts +0 -118
  354. package/dist/lumenflow-home.d.ts.map +0 -1
  355. package/dist/lumenflow-home.js +0 -214
  356. package/dist/lumenflow-home.js.map +0 -1
  357. package/dist/manual-test-validator.d.ts +0 -84
  358. package/dist/manual-test-validator.d.ts.map +0 -1
  359. package/dist/manual-test-validator.js +0 -206
  360. package/dist/manual-test-validator.js.map +0 -1
  361. package/dist/merge-lock.d.ts +0 -107
  362. package/dist/merge-lock.d.ts.map +0 -1
  363. package/dist/merge-lock.js +0 -263
  364. package/dist/merge-lock.js.map +0 -1
  365. package/dist/micro-worktree-shared.d.ts +0 -128
  366. package/dist/micro-worktree-shared.d.ts.map +0 -1
  367. package/dist/micro-worktree-shared.js +0 -352
  368. package/dist/micro-worktree-shared.js.map +0 -1
  369. package/dist/micro-worktree.d.ts +0 -165
  370. package/dist/micro-worktree.d.ts.map +0 -1
  371. package/dist/micro-worktree.js +0 -463
  372. package/dist/micro-worktree.js.map +0 -1
  373. package/dist/migration-deployer.d.ts +0 -70
  374. package/dist/migration-deployer.d.ts.map +0 -1
  375. package/dist/migration-deployer.js +0 -152
  376. package/dist/migration-deployer.js.map +0 -1
  377. package/dist/normalize-config-keys.d.ts +0 -10
  378. package/dist/normalize-config-keys.d.ts.map +0 -1
  379. package/dist/normalize-config-keys.js +0 -70
  380. package/dist/normalize-config-keys.js.map +0 -1
  381. package/dist/orchestration-advisory-loader.d.ts +0 -19
  382. package/dist/orchestration-advisory-loader.d.ts.map +0 -1
  383. package/dist/orchestration-advisory-loader.js +0 -94
  384. package/dist/orchestration-advisory-loader.js.map +0 -1
  385. package/dist/orchestration-advisory.d.ts +0 -49
  386. package/dist/orchestration-advisory.d.ts.map +0 -1
  387. package/dist/orchestration-advisory.js +0 -97
  388. package/dist/orchestration-advisory.js.map +0 -1
  389. package/dist/orchestration-di.d.ts +0 -36
  390. package/dist/orchestration-di.d.ts.map +0 -1
  391. package/dist/orchestration-di.js +0 -60
  392. package/dist/orchestration-di.js.map +0 -1
  393. package/dist/orchestration-rules.d.ts +0 -60
  394. package/dist/orchestration-rules.d.ts.map +0 -1
  395. package/dist/orchestration-rules.js +0 -212
  396. package/dist/orchestration-rules.js.map +0 -1
  397. package/dist/orphan-detector.d.ts +0 -148
  398. package/dist/orphan-detector.d.ts.map +0 -1
  399. package/dist/orphan-detector.js +0 -253
  400. package/dist/orphan-detector.js.map +0 -1
  401. package/dist/pack-authoring-template-engine.d.ts +0 -54
  402. package/dist/pack-authoring-template-engine.d.ts.map +0 -1
  403. package/dist/pack-authoring-template-engine.js +0 -510
  404. package/dist/pack-authoring-template-engine.js.map +0 -1
  405. package/dist/path-classifiers.d.ts +0 -58
  406. package/dist/path-classifiers.d.ts.map +0 -1
  407. package/dist/path-classifiers.js +0 -96
  408. package/dist/path-classifiers.js.map +0 -1
  409. package/dist/patrol-loop.d.ts +0 -171
  410. package/dist/patrol-loop.d.ts.map +0 -1
  411. package/dist/patrol-loop.js +0 -197
  412. package/dist/patrol-loop.js.map +0 -1
  413. package/dist/piped-command-detector.d.ts +0 -25
  414. package/dist/piped-command-detector.d.ts.map +0 -1
  415. package/dist/piped-command-detector.js +0 -67
  416. package/dist/piped-command-detector.js.map +0 -1
  417. package/dist/ports/context.ports.d.ts +0 -136
  418. package/dist/ports/context.ports.d.ts.map +0 -1
  419. package/dist/ports/context.ports.js +0 -4
  420. package/dist/ports/context.ports.js.map +0 -1
  421. package/dist/ports/core-tools.ports.d.ts +0 -282
  422. package/dist/ports/core-tools.ports.d.ts.map +0 -1
  423. package/dist/ports/core-tools.ports.js +0 -4
  424. package/dist/ports/core-tools.ports.js.map +0 -1
  425. package/dist/ports/dashboard-renderer.port.d.ts +0 -113
  426. package/dist/ports/dashboard-renderer.port.d.ts.map +0 -1
  427. package/dist/ports/dashboard-renderer.port.js +0 -4
  428. package/dist/ports/dashboard-renderer.port.js.map +0 -1
  429. package/dist/ports/git-validator.ports.d.ts +0 -114
  430. package/dist/ports/git-validator.ports.d.ts.map +0 -1
  431. package/dist/ports/git-validator.ports.js +0 -4
  432. package/dist/ports/git-validator.ports.js.map +0 -1
  433. package/dist/ports/index.d.ts +0 -21
  434. package/dist/ports/index.d.ts.map +0 -1
  435. package/dist/ports/index.js +0 -23
  436. package/dist/ports/index.js.map +0 -1
  437. package/dist/ports/metrics-collector.port.d.ts +0 -133
  438. package/dist/ports/metrics-collector.port.d.ts.map +0 -1
  439. package/dist/ports/metrics-collector.port.js +0 -4
  440. package/dist/ports/metrics-collector.port.js.map +0 -1
  441. package/dist/ports/recovery.ports.d.ts +0 -59
  442. package/dist/ports/recovery.ports.d.ts.map +0 -1
  443. package/dist/ports/recovery.ports.js +0 -4
  444. package/dist/ports/recovery.ports.js.map +0 -1
  445. package/dist/ports/validation.ports.d.ts +0 -75
  446. package/dist/ports/validation.ports.d.ts.map +0 -1
  447. package/dist/ports/validation.ports.js +0 -4
  448. package/dist/ports/validation.ports.js.map +0 -1
  449. package/dist/ports/wu-helpers.ports.d.ts +0 -227
  450. package/dist/ports/wu-helpers.ports.d.ts.map +0 -1
  451. package/dist/ports/wu-helpers.ports.js +0 -4
  452. package/dist/ports/wu-helpers.ports.js.map +0 -1
  453. package/dist/process-detector.d.ts +0 -69
  454. package/dist/process-detector.d.ts.map +0 -1
  455. package/dist/process-detector.js +0 -175
  456. package/dist/process-detector.js.map +0 -1
  457. package/dist/prompt-linter.d.ts +0 -66
  458. package/dist/prompt-linter.d.ts.map +0 -1
  459. package/dist/prompt-linter.js +0 -323
  460. package/dist/prompt-linter.js.map +0 -1
  461. package/dist/prompt-monitor.d.ts +0 -6
  462. package/dist/prompt-monitor.d.ts.map +0 -1
  463. package/dist/prompt-monitor.js +0 -218
  464. package/dist/prompt-monitor.js.map +0 -1
  465. package/dist/rebase-artifact-cleanup.d.ts +0 -156
  466. package/dist/rebase-artifact-cleanup.d.ts.map +0 -1
  467. package/dist/rebase-artifact-cleanup.js +0 -475
  468. package/dist/rebase-artifact-cleanup.js.map +0 -1
  469. package/dist/recovery/index.d.ts +0 -12
  470. package/dist/recovery/index.d.ts.map +0 -1
  471. package/dist/recovery/index.js +0 -14
  472. package/dist/recovery/index.js.map +0 -1
  473. package/dist/recovery/recovery-analyzer.d.ts +0 -49
  474. package/dist/recovery/recovery-analyzer.d.ts.map +0 -1
  475. package/dist/recovery/recovery-analyzer.js +0 -149
  476. package/dist/recovery/recovery-analyzer.js.map +0 -1
  477. package/dist/resolve-policy.d.ts +0 -257
  478. package/dist/resolve-policy.d.ts.map +0 -1
  479. package/dist/resolve-policy.js +0 -269
  480. package/dist/resolve-policy.js.map +0 -1
  481. package/dist/retry-strategy.d.ts +0 -191
  482. package/dist/retry-strategy.d.ts.map +0 -1
  483. package/dist/retry-strategy.js +0 -286
  484. package/dist/retry-strategy.js.map +0 -1
  485. package/dist/risk-detector.d.ts +0 -109
  486. package/dist/risk-detector.d.ts.map +0 -1
  487. package/dist/risk-detector.js +0 -253
  488. package/dist/risk-detector.js.map +0 -1
  489. package/dist/rollback-utils.d.ts +0 -129
  490. package/dist/rollback-utils.d.ts.map +0 -1
  491. package/dist/rollback-utils.js +0 -217
  492. package/dist/rollback-utils.js.map +0 -1
  493. package/dist/sandbox-allowlist.d.ts +0 -16
  494. package/dist/sandbox-allowlist.d.ts.map +0 -1
  495. package/dist/sandbox-allowlist.js +0 -77
  496. package/dist/sandbox-allowlist.js.map +0 -1
  497. package/dist/sandbox-backend-linux.d.ts +0 -6
  498. package/dist/sandbox-backend-linux.d.ts.map +0 -1
  499. package/dist/sandbox-backend-linux.js +0 -67
  500. package/dist/sandbox-backend-linux.js.map +0 -1
  501. package/dist/sandbox-backend-macos.d.ts +0 -6
  502. package/dist/sandbox-backend-macos.d.ts.map +0 -1
  503. package/dist/sandbox-backend-macos.js +0 -66
  504. package/dist/sandbox-backend-macos.js.map +0 -1
  505. package/dist/sandbox-backend-windows.d.ts +0 -6
  506. package/dist/sandbox-backend-windows.d.ts.map +0 -1
  507. package/dist/sandbox-backend-windows.js +0 -30
  508. package/dist/sandbox-backend-windows.js.map +0 -1
  509. package/dist/sandbox-profile.d.ts +0 -53
  510. package/dist/sandbox-profile.d.ts.map +0 -1
  511. package/dist/sandbox-profile.js +0 -64
  512. package/dist/sandbox-profile.js.map +0 -1
  513. package/dist/schemas/arg-validators.d.ts +0 -58
  514. package/dist/schemas/arg-validators.d.ts.map +0 -1
  515. package/dist/schemas/arg-validators.js +0 -193
  516. package/dist/schemas/arg-validators.js.map +0 -1
  517. package/dist/schemas/command-schemas.d.ts +0 -171
  518. package/dist/schemas/command-schemas.d.ts.map +0 -1
  519. package/dist/schemas/command-schemas.js +0 -145
  520. package/dist/schemas/command-schemas.js.map +0 -1
  521. package/dist/schemas/flow-arg-validators.d.ts +0 -32
  522. package/dist/schemas/flow-arg-validators.d.ts.map +0 -1
  523. package/dist/schemas/flow-arg-validators.js +0 -57
  524. package/dist/schemas/flow-arg-validators.js.map +0 -1
  525. package/dist/schemas/flow-schemas.d.ts +0 -152
  526. package/dist/schemas/flow-schemas.d.ts.map +0 -1
  527. package/dist/schemas/flow-schemas.js +0 -105
  528. package/dist/schemas/flow-schemas.js.map +0 -1
  529. package/dist/schemas/index.d.ts +0 -33
  530. package/dist/schemas/index.d.ts.map +0 -1
  531. package/dist/schemas/index.js +0 -96
  532. package/dist/schemas/index.js.map +0 -1
  533. package/dist/schemas/initiative-arg-validators.d.ts +0 -64
  534. package/dist/schemas/initiative-arg-validators.d.ts.map +0 -1
  535. package/dist/schemas/initiative-arg-validators.js +0 -65
  536. package/dist/schemas/initiative-arg-validators.js.map +0 -1
  537. package/dist/schemas/initiative-schemas.d.ts +0 -256
  538. package/dist/schemas/initiative-schemas.d.ts.map +0 -1
  539. package/dist/schemas/initiative-schemas.js +0 -186
  540. package/dist/schemas/initiative-schemas.js.map +0 -1
  541. package/dist/schemas/memory-arg-validators.d.ts +0 -91
  542. package/dist/schemas/memory-arg-validators.d.ts.map +0 -1
  543. package/dist/schemas/memory-arg-validators.js +0 -75
  544. package/dist/schemas/memory-arg-validators.js.map +0 -1
  545. package/dist/schemas/memory-schemas.d.ts +0 -287
  546. package/dist/schemas/memory-schemas.d.ts.map +0 -1
  547. package/dist/schemas/memory-schemas.js +0 -242
  548. package/dist/schemas/memory-schemas.js.map +0 -1
  549. package/dist/schemas/schema-utils.d.ts +0 -87
  550. package/dist/schemas/schema-utils.d.ts.map +0 -1
  551. package/dist/schemas/schema-utils.js +0 -320
  552. package/dist/schemas/schema-utils.js.map +0 -1
  553. package/dist/schemas/setup-arg-validators.d.ts +0 -91
  554. package/dist/schemas/setup-arg-validators.d.ts.map +0 -1
  555. package/dist/schemas/setup-arg-validators.js +0 -98
  556. package/dist/schemas/setup-arg-validators.js.map +0 -1
  557. package/dist/schemas/setup-schemas.d.ts +0 -335
  558. package/dist/schemas/setup-schemas.d.ts.map +0 -1
  559. package/dist/schemas/setup-schemas.js +0 -260
  560. package/dist/schemas/setup-schemas.js.map +0 -1
  561. package/dist/schemas/validation-arg-validators.d.ts +0 -18
  562. package/dist/schemas/validation-arg-validators.d.ts.map +0 -1
  563. package/dist/schemas/validation-arg-validators.js +0 -59
  564. package/dist/schemas/validation-arg-validators.js.map +0 -1
  565. package/dist/schemas/validation-schemas.d.ts +0 -80
  566. package/dist/schemas/validation-schemas.d.ts.map +0 -1
  567. package/dist/schemas/validation-schemas.js +0 -88
  568. package/dist/schemas/validation-schemas.js.map +0 -1
  569. package/dist/schemas/wu-lifecycle-arg-validators.d.ts +0 -118
  570. package/dist/schemas/wu-lifecycle-arg-validators.d.ts.map +0 -1
  571. package/dist/schemas/wu-lifecycle-arg-validators.js +0 -82
  572. package/dist/schemas/wu-lifecycle-arg-validators.js.map +0 -1
  573. package/dist/schemas/wu-lifecycle-schemas.d.ts +0 -362
  574. package/dist/schemas/wu-lifecycle-schemas.d.ts.map +0 -1
  575. package/dist/schemas/wu-lifecycle-schemas.js +0 -284
  576. package/dist/schemas/wu-lifecycle-schemas.js.map +0 -1
  577. package/dist/section-headings.d.ts +0 -35
  578. package/dist/section-headings.d.ts.map +0 -1
  579. package/dist/section-headings.js +0 -54
  580. package/dist/section-headings.js.map +0 -1
  581. package/dist/spawn-escalation.d.ts +0 -91
  582. package/dist/spawn-escalation.d.ts.map +0 -1
  583. package/dist/spawn-escalation.js +0 -258
  584. package/dist/spawn-escalation.js.map +0 -1
  585. package/dist/spawn-monitor.d.ts +0 -230
  586. package/dist/spawn-monitor.d.ts.map +0 -1
  587. package/dist/spawn-monitor.js +0 -675
  588. package/dist/spawn-monitor.js.map +0 -1
  589. package/dist/spawn-prompt-schema.d.ts +0 -107
  590. package/dist/spawn-prompt-schema.d.ts.map +0 -1
  591. package/dist/spawn-prompt-schema.js +0 -163
  592. package/dist/spawn-prompt-schema.js.map +0 -1
  593. package/dist/spawn-recovery.d.ts +0 -83
  594. package/dist/spawn-recovery.d.ts.map +0 -1
  595. package/dist/spawn-recovery.js +0 -299
  596. package/dist/spawn-recovery.js.map +0 -1
  597. package/dist/spawn-registry-schema.d.ts +0 -122
  598. package/dist/spawn-registry-schema.d.ts.map +0 -1
  599. package/dist/spawn-registry-schema.js +0 -129
  600. package/dist/spawn-registry-schema.js.map +0 -1
  601. package/dist/spawn-registry-store.d.ts +0 -161
  602. package/dist/spawn-registry-store.d.ts.map +0 -1
  603. package/dist/spawn-registry-store.js +0 -301
  604. package/dist/spawn-registry-store.js.map +0 -1
  605. package/dist/spawn-strategy.d.ts +0 -60
  606. package/dist/spawn-strategy.d.ts.map +0 -1
  607. package/dist/spawn-strategy.js +0 -112
  608. package/dist/spawn-strategy.js.map +0 -1
  609. package/dist/spawn-tree.d.ts +0 -125
  610. package/dist/spawn-tree.d.ts.map +0 -1
  611. package/dist/spawn-tree.js +0 -286
  612. package/dist/spawn-tree.js.map +0 -1
  613. package/dist/stamp-status-validator.d.ts +0 -77
  614. package/dist/stamp-status-validator.d.ts.map +0 -1
  615. package/dist/stamp-status-validator.js +0 -138
  616. package/dist/stamp-status-validator.js.map +0 -1
  617. package/dist/stamp-tracking.d.ts +0 -12
  618. package/dist/stamp-tracking.d.ts.map +0 -1
  619. package/dist/stamp-tracking.js +0 -43
  620. package/dist/stamp-tracking.js.map +0 -1
  621. package/dist/stamp-utils.d.ts +0 -94
  622. package/dist/stamp-utils.d.ts.map +0 -1
  623. package/dist/stamp-utils.js +0 -245
  624. package/dist/stamp-utils.js.map +0 -1
  625. package/dist/state-cleanup-core.d.ts +0 -206
  626. package/dist/state-cleanup-core.d.ts.map +0 -1
  627. package/dist/state-cleanup-core.js +0 -225
  628. package/dist/state-cleanup-core.js.map +0 -1
  629. package/dist/state-doctor-core.d.ts +0 -177
  630. package/dist/state-doctor-core.d.ts.map +0 -1
  631. package/dist/state-doctor-core.js +0 -395
  632. package/dist/state-doctor-core.js.map +0 -1
  633. package/dist/state-machine.d.ts +0 -10
  634. package/dist/state-machine.d.ts.map +0 -1
  635. package/dist/state-machine.js +0 -89
  636. package/dist/state-machine.js.map +0 -1
  637. package/dist/stream-error-handler.d.ts +0 -68
  638. package/dist/stream-error-handler.d.ts.map +0 -1
  639. package/dist/stream-error-handler.js +0 -77
  640. package/dist/stream-error-handler.js.map +0 -1
  641. package/dist/system-map-validator.d.ts +0 -111
  642. package/dist/system-map-validator.d.ts.map +0 -1
  643. package/dist/system-map-validator.js +0 -383
  644. package/dist/system-map-validator.js.map +0 -1
  645. package/dist/telemetry.d.ts +0 -81
  646. package/dist/telemetry.d.ts.map +0 -1
  647. package/dist/telemetry.js +0 -219
  648. package/dist/telemetry.js.map +0 -1
  649. package/dist/template-loader.d.ts +0 -151
  650. package/dist/template-loader.d.ts.map +0 -1
  651. package/dist/template-loader.js +0 -400
  652. package/dist/template-loader.js.map +0 -1
  653. package/dist/test-baseline.d.ts +0 -177
  654. package/dist/test-baseline.d.ts.map +0 -1
  655. package/dist/test-baseline.js +0 -286
  656. package/dist/test-baseline.js.map +0 -1
  657. package/dist/token-counter.d.ts +0 -50
  658. package/dist/token-counter.d.ts.map +0 -1
  659. package/dist/token-counter.js +0 -144
  660. package/dist/token-counter.js.map +0 -1
  661. package/dist/usecases/analyze-recovery.usecase.d.ts +0 -43
  662. package/dist/usecases/analyze-recovery.usecase.d.ts.map +0 -1
  663. package/dist/usecases/analyze-recovery.usecase.js +0 -34
  664. package/dist/usecases/analyze-recovery.usecase.js.map +0 -1
  665. package/dist/usecases/compute-context.usecase.d.ts +0 -63
  666. package/dist/usecases/compute-context.usecase.d.ts.map +0 -1
  667. package/dist/usecases/compute-context.usecase.js +0 -91
  668. package/dist/usecases/compute-context.usecase.js.map +0 -1
  669. package/dist/usecases/get-dashboard-data.usecase.d.ts +0 -53
  670. package/dist/usecases/get-dashboard-data.usecase.d.ts.map +0 -1
  671. package/dist/usecases/get-dashboard-data.usecase.js +0 -54
  672. package/dist/usecases/get-dashboard-data.usecase.js.map +0 -1
  673. package/dist/usecases/get-suggestions.usecase.d.ts +0 -101
  674. package/dist/usecases/get-suggestions.usecase.d.ts.map +0 -1
  675. package/dist/usecases/get-suggestions.usecase.js +0 -148
  676. package/dist/usecases/get-suggestions.usecase.js.map +0 -1
  677. package/dist/usecases/index.d.ts +0 -15
  678. package/dist/usecases/index.d.ts.map +0 -1
  679. package/dist/usecases/index.js +0 -21
  680. package/dist/usecases/index.js.map +0 -1
  681. package/dist/usecases/validate-command.usecase.d.ts +0 -56
  682. package/dist/usecases/validate-command.usecase.d.ts.map +0 -1
  683. package/dist/usecases/validate-command.usecase.js +0 -143
  684. package/dist/usecases/validate-command.usecase.js.map +0 -1
  685. package/dist/user-normalizer.d.ts +0 -36
  686. package/dist/user-normalizer.d.ts.map +0 -1
  687. package/dist/user-normalizer.js +0 -149
  688. package/dist/user-normalizer.js.map +0 -1
  689. package/dist/validation/command-registry.d.ts +0 -26
  690. package/dist/validation/command-registry.d.ts.map +0 -1
  691. package/dist/validation/command-registry.js +0 -269
  692. package/dist/validation/command-registry.js.map +0 -1
  693. package/dist/validation/index.d.ts +0 -16
  694. package/dist/validation/index.d.ts.map +0 -1
  695. package/dist/validation/index.js +0 -18
  696. package/dist/validation/index.js.map +0 -1
  697. package/dist/validation/types.d.ts +0 -140
  698. package/dist/validation/types.d.ts.map +0 -1
  699. package/dist/validation/types.js +0 -4
  700. package/dist/validation/types.js.map +0 -1
  701. package/dist/validation/validate-command.d.ts +0 -16
  702. package/dist/validation/validate-command.d.ts.map +0 -1
  703. package/dist/validation/validate-command.js +0 -163
  704. package/dist/validation/validate-command.js.map +0 -1
  705. package/dist/validators/backlog-sync.d.ts +0 -11
  706. package/dist/validators/backlog-sync.d.ts.map +0 -1
  707. package/dist/validators/backlog-sync.js +0 -65
  708. package/dist/validators/backlog-sync.js.map +0 -1
  709. package/dist/validators/phi-constants.d.ts +0 -98
  710. package/dist/validators/phi-constants.d.ts.map +0 -1
  711. package/dist/validators/phi-constants.js +0 -153
  712. package/dist/validators/phi-constants.js.map +0 -1
  713. package/dist/validators/phi-scanner.d.ts +0 -59
  714. package/dist/validators/phi-scanner.d.ts.map +0 -1
  715. package/dist/validators/phi-scanner.js +0 -222
  716. package/dist/validators/phi-scanner.js.map +0 -1
  717. package/dist/validators/supabase-docs-linter.d.ts +0 -15
  718. package/dist/validators/supabase-docs-linter.d.ts.map +0 -1
  719. package/dist/validators/supabase-docs-linter.js +0 -45
  720. package/dist/validators/supabase-docs-linter.js.map +0 -1
  721. package/dist/validators/wu-tasks.d.ts +0 -21
  722. package/dist/validators/wu-tasks.d.ts.map +0 -1
  723. package/dist/validators/wu-tasks.js +0 -93
  724. package/dist/validators/wu-tasks.js.map +0 -1
  725. package/dist/work-classifier.d.ts +0 -95
  726. package/dist/work-classifier.d.ts.map +0 -1
  727. package/dist/work-classifier.js +0 -408
  728. package/dist/work-classifier.js.map +0 -1
  729. package/dist/worktree-ownership.d.ts +0 -51
  730. package/dist/worktree-ownership.d.ts.map +0 -1
  731. package/dist/worktree-ownership.js +0 -77
  732. package/dist/worktree-ownership.js.map +0 -1
  733. package/dist/worktree-scanner.d.ts +0 -118
  734. package/dist/worktree-scanner.d.ts.map +0 -1
  735. package/dist/worktree-scanner.js +0 -171
  736. package/dist/worktree-scanner.js.map +0 -1
  737. package/dist/worktree-symlink.d.ts +0 -86
  738. package/dist/worktree-symlink.d.ts.map +0 -1
  739. package/dist/worktree-symlink.js +0 -349
  740. package/dist/worktree-symlink.js.map +0 -1
  741. package/dist/wu-backlog-updater.d.ts +0 -10
  742. package/dist/wu-backlog-updater.d.ts.map +0 -1
  743. package/dist/wu-backlog-updater.js +0 -40
  744. package/dist/wu-backlog-updater.js.map +0 -1
  745. package/dist/wu-checkpoint.d.ts +0 -110
  746. package/dist/wu-checkpoint.d.ts.map +0 -1
  747. package/dist/wu-checkpoint.js +0 -236
  748. package/dist/wu-checkpoint.js.map +0 -1
  749. package/dist/wu-claim-helpers.d.ts +0 -21
  750. package/dist/wu-claim-helpers.d.ts.map +0 -1
  751. package/dist/wu-claim-helpers.js +0 -66
  752. package/dist/wu-claim-helpers.js.map +0 -1
  753. package/dist/wu-claim-resume.d.ts +0 -106
  754. package/dist/wu-claim-resume.d.ts.map +0 -1
  755. package/dist/wu-claim-resume.js +0 -279
  756. package/dist/wu-claim-resume.js.map +0 -1
  757. package/dist/wu-cli-constants.d.ts +0 -425
  758. package/dist/wu-cli-constants.d.ts.map +0 -1
  759. package/dist/wu-cli-constants.js +0 -430
  760. package/dist/wu-cli-constants.js.map +0 -1
  761. package/dist/wu-consistency-checker.d.ts +0 -189
  762. package/dist/wu-consistency-checker.d.ts.map +0 -1
  763. package/dist/wu-consistency-checker.js +0 -1026
  764. package/dist/wu-consistency-checker.js.map +0 -1
  765. package/dist/wu-constants.d.ts +0 -29
  766. package/dist/wu-constants.d.ts.map +0 -1
  767. package/dist/wu-constants.js +0 -37
  768. package/dist/wu-constants.js.map +0 -1
  769. package/dist/wu-context-constants.d.ts +0 -270
  770. package/dist/wu-context-constants.d.ts.map +0 -1
  771. package/dist/wu-context-constants.js +0 -267
  772. package/dist/wu-context-constants.js.map +0 -1
  773. package/dist/wu-create-defaults.d.ts +0 -11
  774. package/dist/wu-create-defaults.d.ts.map +0 -1
  775. package/dist/wu-create-defaults.js +0 -13
  776. package/dist/wu-create-defaults.js.map +0 -1
  777. package/dist/wu-create-validators.d.ts +0 -89
  778. package/dist/wu-create-validators.d.ts.map +0 -1
  779. package/dist/wu-create-validators.js +0 -215
  780. package/dist/wu-create-validators.js.map +0 -1
  781. package/dist/wu-domain-constants.d.ts +0 -295
  782. package/dist/wu-domain-constants.d.ts.map +0 -1
  783. package/dist/wu-domain-constants.js +0 -399
  784. package/dist/wu-domain-constants.js.map +0 -1
  785. package/dist/wu-done-branch-only.d.ts +0 -120
  786. package/dist/wu-done-branch-only.d.ts.map +0 -1
  787. package/dist/wu-done-branch-only.js +0 -412
  788. package/dist/wu-done-branch-only.js.map +0 -1
  789. package/dist/wu-done-branch-utils.d.ts +0 -8
  790. package/dist/wu-done-branch-utils.d.ts.map +0 -1
  791. package/dist/wu-done-branch-utils.js +0 -34
  792. package/dist/wu-done-branch-utils.js.map +0 -1
  793. package/dist/wu-done-cleanup.d.ts +0 -6
  794. package/dist/wu-done-cleanup.d.ts.map +0 -1
  795. package/dist/wu-done-cleanup.js +0 -161
  796. package/dist/wu-done-cleanup.js.map +0 -1
  797. package/dist/wu-done-concurrent-merge.d.ts +0 -103
  798. package/dist/wu-done-concurrent-merge.d.ts.map +0 -1
  799. package/dist/wu-done-concurrent-merge.js +0 -375
  800. package/dist/wu-done-concurrent-merge.js.map +0 -1
  801. package/dist/wu-done-docs-generate.d.ts +0 -72
  802. package/dist/wu-done-docs-generate.d.ts.map +0 -1
  803. package/dist/wu-done-docs-generate.js +0 -129
  804. package/dist/wu-done-docs-generate.js.map +0 -1
  805. package/dist/wu-done-docs-only.d.ts +0 -16
  806. package/dist/wu-done-docs-only.d.ts.map +0 -1
  807. package/dist/wu-done-docs-only.js +0 -68
  808. package/dist/wu-done-docs-only.js.map +0 -1
  809. package/dist/wu-done-errors.d.ts +0 -13
  810. package/dist/wu-done-errors.d.ts.map +0 -1
  811. package/dist/wu-done-errors.js +0 -27
  812. package/dist/wu-done-errors.js.map +0 -1
  813. package/dist/wu-done-initiative-sync.d.ts +0 -13
  814. package/dist/wu-done-initiative-sync.d.ts.map +0 -1
  815. package/dist/wu-done-initiative-sync.js +0 -235
  816. package/dist/wu-done-initiative-sync.js.map +0 -1
  817. package/dist/wu-done-inputs.d.ts +0 -10
  818. package/dist/wu-done-inputs.d.ts.map +0 -1
  819. package/dist/wu-done-inputs.js +0 -55
  820. package/dist/wu-done-inputs.js.map +0 -1
  821. package/dist/wu-done-machine.d.ts +0 -175
  822. package/dist/wu-done-machine.d.ts.map +0 -1
  823. package/dist/wu-done-machine.js +0 -227
  824. package/dist/wu-done-machine.js.map +0 -1
  825. package/dist/wu-done-merged-worktree.d.ts +0 -65
  826. package/dist/wu-done-merged-worktree.d.ts.map +0 -1
  827. package/dist/wu-done-merged-worktree.js +0 -197
  828. package/dist/wu-done-merged-worktree.js.map +0 -1
  829. package/dist/wu-done-messages.d.ts +0 -120
  830. package/dist/wu-done-messages.d.ts.map +0 -1
  831. package/dist/wu-done-messages.js +0 -191
  832. package/dist/wu-done-messages.js.map +0 -1
  833. package/dist/wu-done-metadata.d.ts +0 -123
  834. package/dist/wu-done-metadata.d.ts.map +0 -1
  835. package/dist/wu-done-metadata.js +0 -240
  836. package/dist/wu-done-metadata.js.map +0 -1
  837. package/dist/wu-done-paths.d.ts +0 -87
  838. package/dist/wu-done-paths.d.ts.map +0 -1
  839. package/dist/wu-done-paths.js +0 -263
  840. package/dist/wu-done-paths.js.map +0 -1
  841. package/dist/wu-done-pr.d.ts +0 -76
  842. package/dist/wu-done-pr.d.ts.map +0 -1
  843. package/dist/wu-done-pr.js +0 -189
  844. package/dist/wu-done-pr.js.map +0 -1
  845. package/dist/wu-done-preflight.d.ts +0 -65
  846. package/dist/wu-done-preflight.d.ts.map +0 -1
  847. package/dist/wu-done-preflight.js +0 -205
  848. package/dist/wu-done-preflight.js.map +0 -1
  849. package/dist/wu-done-retry-helpers.d.ts +0 -75
  850. package/dist/wu-done-retry-helpers.d.ts.map +0 -1
  851. package/dist/wu-done-retry-helpers.js +0 -175
  852. package/dist/wu-done-retry-helpers.js.map +0 -1
  853. package/dist/wu-done-ui.d.ts +0 -29
  854. package/dist/wu-done-ui.d.ts.map +0 -1
  855. package/dist/wu-done-ui.js +0 -74
  856. package/dist/wu-done-ui.js.map +0 -1
  857. package/dist/wu-done-validation.d.ts +0 -128
  858. package/dist/wu-done-validation.d.ts.map +0 -1
  859. package/dist/wu-done-validation.js +0 -530
  860. package/dist/wu-done-validation.js.map +0 -1
  861. package/dist/wu-done-validators.d.ts +0 -16
  862. package/dist/wu-done-validators.d.ts.map +0 -1
  863. package/dist/wu-done-validators.js +0 -16
  864. package/dist/wu-done-validators.js.map +0 -1
  865. package/dist/wu-done-worktree-services.d.ts +0 -174
  866. package/dist/wu-done-worktree-services.d.ts.map +0 -1
  867. package/dist/wu-done-worktree-services.js +0 -274
  868. package/dist/wu-done-worktree-services.js.map +0 -1
  869. package/dist/wu-done-worktree.d.ts +0 -229
  870. package/dist/wu-done-worktree.d.ts.map +0 -1
  871. package/dist/wu-done-worktree.js +0 -1290
  872. package/dist/wu-done-worktree.js.map +0 -1
  873. package/dist/wu-events-cleanup.d.ts +0 -131
  874. package/dist/wu-events-cleanup.d.ts.map +0 -1
  875. package/dist/wu-events-cleanup.js +0 -404
  876. package/dist/wu-events-cleanup.js.map +0 -1
  877. package/dist/wu-git-constants.d.ts +0 -176
  878. package/dist/wu-git-constants.d.ts.map +0 -1
  879. package/dist/wu-git-constants.js +0 -178
  880. package/dist/wu-git-constants.js.map +0 -1
  881. package/dist/wu-helpers.d.ts +0 -133
  882. package/dist/wu-helpers.d.ts.map +0 -1
  883. package/dist/wu-helpers.js +0 -268
  884. package/dist/wu-helpers.js.map +0 -1
  885. package/dist/wu-id-generator.d.ts +0 -51
  886. package/dist/wu-id-generator.d.ts.map +0 -1
  887. package/dist/wu-id-generator.js +0 -110
  888. package/dist/wu-id-generator.js.map +0 -1
  889. package/dist/wu-lint.d.ts +0 -191
  890. package/dist/wu-lint.d.ts.map +0 -1
  891. package/dist/wu-lint.js +0 -338
  892. package/dist/wu-lint.js.map +0 -1
  893. package/dist/wu-list.d.ts +0 -76
  894. package/dist/wu-list.d.ts.map +0 -1
  895. package/dist/wu-list.js +0 -181
  896. package/dist/wu-list.js.map +0 -1
  897. package/dist/wu-paths-constants.d.ts +0 -264
  898. package/dist/wu-paths-constants.d.ts.map +0 -1
  899. package/dist/wu-paths-constants.js +0 -272
  900. package/dist/wu-paths-constants.js.map +0 -1
  901. package/dist/wu-paths.d.ts +0 -211
  902. package/dist/wu-paths.d.ts.map +0 -1
  903. package/dist/wu-paths.js +0 -223
  904. package/dist/wu-paths.js.map +0 -1
  905. package/dist/wu-preflight-validators.d.ts +0 -64
  906. package/dist/wu-preflight-validators.d.ts.map +0 -1
  907. package/dist/wu-preflight-validators.js +0 -277
  908. package/dist/wu-preflight-validators.js.map +0 -1
  909. package/dist/wu-recovery.d.ts +0 -220
  910. package/dist/wu-recovery.d.ts.map +0 -1
  911. package/dist/wu-recovery.js +0 -470
  912. package/dist/wu-recovery.js.map +0 -1
  913. package/dist/wu-repair-core.d.ts +0 -150
  914. package/dist/wu-repair-core.d.ts.map +0 -1
  915. package/dist/wu-repair-core.js +0 -718
  916. package/dist/wu-repair-core.js.map +0 -1
  917. package/dist/wu-rules-core.d.ts +0 -95
  918. package/dist/wu-rules-core.d.ts.map +0 -1
  919. package/dist/wu-rules-core.js +0 -401
  920. package/dist/wu-rules-core.js.map +0 -1
  921. package/dist/wu-rules-engine.d.ts +0 -29
  922. package/dist/wu-rules-engine.d.ts.map +0 -1
  923. package/dist/wu-rules-engine.js +0 -61
  924. package/dist/wu-rules-engine.js.map +0 -1
  925. package/dist/wu-rules-resolvers.d.ts +0 -19
  926. package/dist/wu-rules-resolvers.d.ts.map +0 -1
  927. package/dist/wu-rules-resolvers.js +0 -210
  928. package/dist/wu-rules-resolvers.js.map +0 -1
  929. package/dist/wu-schema-normalization.d.ts +0 -18
  930. package/dist/wu-schema-normalization.d.ts.map +0 -1
  931. package/dist/wu-schema-normalization.js +0 -87
  932. package/dist/wu-schema-normalization.js.map +0 -1
  933. package/dist/wu-schema.d.ts +0 -772
  934. package/dist/wu-schema.d.ts.map +0 -1
  935. package/dist/wu-schema.js +0 -897
  936. package/dist/wu-schema.js.map +0 -1
  937. package/dist/wu-spawn-context.d.ts +0 -66
  938. package/dist/wu-spawn-context.d.ts.map +0 -1
  939. package/dist/wu-spawn-context.js +0 -185
  940. package/dist/wu-spawn-context.js.map +0 -1
  941. package/dist/wu-spawn-helpers.d.ts +0 -110
  942. package/dist/wu-spawn-helpers.d.ts.map +0 -1
  943. package/dist/wu-spawn-helpers.js +0 -276
  944. package/dist/wu-spawn-helpers.js.map +0 -1
  945. package/dist/wu-spawn-skills.d.ts +0 -39
  946. package/dist/wu-spawn-skills.d.ts.map +0 -1
  947. package/dist/wu-spawn-skills.js +0 -214
  948. package/dist/wu-spawn-skills.js.map +0 -1
  949. package/dist/wu-spawn.d.ts +0 -394
  950. package/dist/wu-spawn.d.ts.map +0 -1
  951. package/dist/wu-spawn.js +0 -1977
  952. package/dist/wu-spawn.js.map +0 -1
  953. package/dist/wu-state-schema.d.ts +0 -237
  954. package/dist/wu-state-schema.d.ts.map +0 -1
  955. package/dist/wu-state-schema.js +0 -172
  956. package/dist/wu-state-schema.js.map +0 -1
  957. package/dist/wu-state-store.d.ts +0 -275
  958. package/dist/wu-state-store.d.ts.map +0 -1
  959. package/dist/wu-state-store.js +0 -1057
  960. package/dist/wu-state-store.js.map +0 -1
  961. package/dist/wu-status-transition.d.ts +0 -58
  962. package/dist/wu-status-transition.d.ts.map +0 -1
  963. package/dist/wu-status-transition.js +0 -370
  964. package/dist/wu-status-transition.js.map +0 -1
  965. package/dist/wu-status-updater.d.ts +0 -18
  966. package/dist/wu-status-updater.d.ts.map +0 -1
  967. package/dist/wu-status-updater.js +0 -123
  968. package/dist/wu-status-updater.js.map +0 -1
  969. package/dist/wu-statuses.d.ts +0 -154
  970. package/dist/wu-statuses.d.ts.map +0 -1
  971. package/dist/wu-statuses.js +0 -176
  972. package/dist/wu-statuses.js.map +0 -1
  973. package/dist/wu-transaction-collectors.d.ts +0 -116
  974. package/dist/wu-transaction-collectors.d.ts.map +0 -1
  975. package/dist/wu-transaction-collectors.js +0 -273
  976. package/dist/wu-transaction-collectors.js.map +0 -1
  977. package/dist/wu-transaction.d.ts +0 -172
  978. package/dist/wu-transaction.d.ts.map +0 -1
  979. package/dist/wu-transaction.js +0 -288
  980. package/dist/wu-transaction.js.map +0 -1
  981. package/dist/wu-type-helpers.d.ts +0 -26
  982. package/dist/wu-type-helpers.d.ts.map +0 -1
  983. package/dist/wu-type-helpers.js +0 -45
  984. package/dist/wu-type-helpers.js.map +0 -1
  985. package/dist/wu-ui-constants.d.ts +0 -235
  986. package/dist/wu-ui-constants.d.ts.map +0 -1
  987. package/dist/wu-ui-constants.js +0 -237
  988. package/dist/wu-ui-constants.js.map +0 -1
  989. package/dist/wu-validation-constants.d.ts +0 -61
  990. package/dist/wu-validation-constants.d.ts.map +0 -1
  991. package/dist/wu-validation-constants.js +0 -69
  992. package/dist/wu-validation-constants.js.map +0 -1
  993. package/dist/wu-validation.d.ts +0 -121
  994. package/dist/wu-validation.d.ts.map +0 -1
  995. package/dist/wu-validation.js +0 -266
  996. package/dist/wu-validation.js.map +0 -1
  997. package/dist/wu-validator.d.ts +0 -128
  998. package/dist/wu-validator.d.ts.map +0 -1
  999. package/dist/wu-validator.js +0 -445
  1000. package/dist/wu-validator.js.map +0 -1
  1001. package/dist/wu-yaml-fixer.d.ts +0 -74
  1002. package/dist/wu-yaml-fixer.d.ts.map +0 -1
  1003. package/dist/wu-yaml-fixer.js +0 -273
  1004. package/dist/wu-yaml-fixer.js.map +0 -1
  1005. package/dist/wu-yaml.d.ts +0 -110
  1006. package/dist/wu-yaml.d.ts.map +0 -1
  1007. package/dist/wu-yaml.js +0 -300
  1008. package/dist/wu-yaml.js.map +0 -1
@@ -1,1026 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: AGPL-3.0-only
3
- /**
4
- * WU Consistency Checker (WU-1276, WU-2412)
5
- *
6
- * Layer 2 defense-in-depth: Detect and repair WU state inconsistencies.
7
- *
8
- * Detects five types of inconsistencies:
9
- * - YAML_DONE_STATUS_IN_PROGRESS: WU YAML done but in status.md In Progress
10
- * - BACKLOG_DUAL_SECTION: WU in both Done and In Progress sections
11
- * - YAML_DONE_NO_STAMP: WU YAML done but no stamp file
12
- * - ORPHAN_WORKTREE_DONE: Done WU still has worktree
13
- * - STAMP_EXISTS_YAML_NOT_DONE: Stamp exists but YAML status is not done (WU-2412)
14
- *
15
- * @see {@link ../wu-repair.ts} CLI interface
16
- */
17
- import { readFile, writeFile, readdir, mkdir, access } from 'node:fs/promises';
18
- import { constants, existsSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs';
19
- import path from 'node:path';
20
- import { parseYAML, stringifyYAML } from './wu-yaml.js';
21
- import { createWuPaths, WU_PATHS } from './wu-paths.js';
22
- import { CONSISTENCY_TYPES, CONSISTENCY_MESSAGES, LUMENFLOW_PATHS, LOG_PREFIX, REMOTES, STRING_LITERALS, toKebab, WU_STATUS, YAML_OPTIONS, } from './wu-constants.js';
23
- import { todayISO, normalizeToDateString } from './date-utils.js';
24
- import { createGitForPath } from './git-adapter.js';
25
- import { withMicroWorktree } from './micro-worktree.js';
26
- import { listTrackedWUStampIds } from './stamp-tracking.js';
27
- /**
28
- * Check a single WU for state inconsistencies
29
- *
30
- * @param {string} id - WU ID (e.g., 'WU-123')
31
- * @param {string} [projectRoot=process.cwd()] - Project root directory
32
- * @param {CheckWUConsistencyOptions} [options] - Optional precomputed context
33
- * @returns {Promise<object>} Consistency report with valid, errors, and stats
34
- */
35
- export async function checkWUConsistency(id, projectRoot = process.cwd(), options = {}) {
36
- const errors = [];
37
- const paths = createWuPaths({ projectRoot });
38
- const wuPath = path.join(projectRoot, paths.WU(id));
39
- const stampPath = path.join(projectRoot, paths.STAMP(id));
40
- const backlogPath = path.join(projectRoot, paths.BACKLOG());
41
- const statusPath = path.join(projectRoot, paths.STATUS());
42
- // Handle missing WU YAML gracefully
43
- try {
44
- await access(wuPath, constants.R_OK);
45
- }
46
- catch {
47
- return { valid: true, errors: [], stats: { wuExists: false } };
48
- }
49
- const wuContent = await readFile(wuPath, { encoding: 'utf-8' });
50
- const wuDoc = parseYAML(wuContent);
51
- const yamlStatus = wuDoc?.status || 'unknown';
52
- const lane = wuDoc?.lane || '';
53
- const title = wuDoc?.title || '';
54
- const worktreePathFromYaml = wuDoc?.worktree_path || '';
55
- // Check stamp existence (guard against untracked local stamp artifacts)
56
- let hasStampFile;
57
- try {
58
- await access(stampPath, constants.R_OK);
59
- hasStampFile = true;
60
- }
61
- catch {
62
- hasStampFile = false;
63
- }
64
- const trackedStampIds = options.trackedStampIds ??
65
- (await listTrackedWUStampIds({ projectRoot, stampsDir: paths.STAMPS_DIR() }));
66
- const hasStamp = hasStampFile && (trackedStampIds === null || trackedStampIds.has(id));
67
- // Parse backlog sections
68
- let backlogContent;
69
- try {
70
- backlogContent = await readFile(backlogPath, { encoding: 'utf-8' });
71
- }
72
- catch {
73
- backlogContent = '';
74
- }
75
- const { inDone: backlogInDone, inProgress: backlogInProgress } = parseBacklogSections(backlogContent, id);
76
- // Parse status.md sections
77
- let statusContent;
78
- try {
79
- statusContent = await readFile(statusPath, { encoding: 'utf-8' });
80
- }
81
- catch {
82
- statusContent = '';
83
- }
84
- const { inProgress: statusInProgress } = parseStatusSections(statusContent, id);
85
- // Check for worktree
86
- const normalizedId = id.toUpperCase();
87
- const hasWorktree = options.activeWorktreeIds !== undefined
88
- ? options.activeWorktreeIds !== null && options.activeWorktreeIds.has(normalizedId)
89
- : await checkWorktreeExists(id, projectRoot);
90
- const worktreePathExists = await checkWorktreePathExists(worktreePathFromYaml);
91
- // Detection logic
92
- // 1. YAML done but in status.md In Progress
93
- if (yamlStatus === WU_STATUS.DONE && statusInProgress) {
94
- errors.push({
95
- type: CONSISTENCY_TYPES.YAML_DONE_STATUS_IN_PROGRESS,
96
- wuId: id,
97
- description: `WU ${id} has status '${WU_STATUS.DONE}' in YAML but still appears in status.md In Progress section`,
98
- repairAction: 'Remove from status.md In Progress section',
99
- canAutoRepair: true,
100
- });
101
- }
102
- // 2. Backlog dual section (Done AND In Progress)
103
- if (backlogInDone && backlogInProgress) {
104
- errors.push({
105
- type: CONSISTENCY_TYPES.BACKLOG_DUAL_SECTION,
106
- wuId: id,
107
- description: `WU ${id} appears in both Done and In Progress sections of backlog.md`,
108
- repairAction: 'Remove from In Progress section (Done wins)',
109
- canAutoRepair: true,
110
- });
111
- }
112
- // 3. YAML done but no stamp
113
- if (yamlStatus === WU_STATUS.DONE && !hasStamp) {
114
- errors.push({
115
- type: CONSISTENCY_TYPES.YAML_DONE_NO_STAMP,
116
- wuId: id,
117
- title,
118
- description: `WU ${id} has status '${WU_STATUS.DONE}' but no stamp file exists`,
119
- repairAction: 'Create stamp file',
120
- canAutoRepair: true,
121
- });
122
- }
123
- // 4. Orphan worktree for done WU
124
- if (yamlStatus === WU_STATUS.DONE && hasWorktree) {
125
- errors.push({
126
- type: CONSISTENCY_TYPES.ORPHAN_WORKTREE_DONE,
127
- wuId: id,
128
- lane,
129
- description: `WU ${id} has status '${WU_STATUS.DONE}' but still has an associated worktree`,
130
- repairAction: 'Remove orphan worktree and lane branch',
131
- canAutoRepair: true,
132
- });
133
- }
134
- // 5. Stamp exists but YAML not done (inverse of YAML_DONE_NO_STAMP)
135
- // This catches partial wu:done failures where stamp was created but YAML update failed
136
- if (hasStamp && yamlStatus !== WU_STATUS.DONE) {
137
- errors.push({
138
- type: CONSISTENCY_TYPES.STAMP_EXISTS_YAML_NOT_DONE,
139
- wuId: id,
140
- title,
141
- description: `WU ${id} has stamp file but YAML status is '${yamlStatus}' (not done)`,
142
- repairAction: 'Update YAML to done+locked+completed',
143
- canAutoRepair: true,
144
- });
145
- }
146
- // 6. Claimed WU missing worktree directory
147
- if (worktreePathFromYaml &&
148
- !worktreePathExists &&
149
- (yamlStatus === WU_STATUS.IN_PROGRESS || yamlStatus === WU_STATUS.BLOCKED)) {
150
- errors.push({
151
- type: CONSISTENCY_TYPES.MISSING_WORKTREE_CLAIMED,
152
- wuId: id,
153
- title,
154
- description: CONSISTENCY_MESSAGES.MISSING_WORKTREE_CLAIMED(id, yamlStatus, worktreePathFromYaml),
155
- repairAction: CONSISTENCY_MESSAGES.MISSING_WORKTREE_CLAIMED_REPAIR,
156
- canAutoRepair: false,
157
- });
158
- }
159
- return {
160
- valid: errors.length === 0,
161
- errors,
162
- stats: {
163
- yamlStatus,
164
- hasStamp,
165
- backlogInDone,
166
- backlogInProgress,
167
- statusInProgress,
168
- hasWorktree,
169
- worktreePathExists,
170
- },
171
- };
172
- }
173
- /**
174
- * Check all WUs for consistency
175
- *
176
- * @param {string} [projectRoot=process.cwd()] - Project root directory
177
- * @returns {Promise<object>} Aggregated report with valid, errors, and checked count
178
- */
179
- export async function checkAllWUConsistency(projectRoot = process.cwd()) {
180
- const paths = createWuPaths({ projectRoot });
181
- const wuDir = path.join(projectRoot, paths.WU_DIR());
182
- try {
183
- await access(wuDir, constants.R_OK);
184
- }
185
- catch {
186
- return { valid: true, errors: [], checked: 0 };
187
- }
188
- const allErrors = [];
189
- const wuFiles = (await readdir(wuDir)).filter((f) => /^WU-\d+\.yaml$/.test(f));
190
- const trackedStampIds = await listTrackedWUStampIds({
191
- projectRoot,
192
- stampsDir: paths.STAMPS_DIR(),
193
- });
194
- const activeWorktreeIds = await listActiveWorktreeIds(projectRoot);
195
- for (const file of wuFiles) {
196
- const id = file.replace('.yaml', '');
197
- const report = await checkWUConsistency(id, projectRoot, {
198
- trackedStampIds,
199
- activeWorktreeIds,
200
- });
201
- allErrors.push(...report.errors);
202
- }
203
- return {
204
- valid: allErrors.length === 0,
205
- errors: allErrors,
206
- checked: wuFiles.length,
207
- };
208
- }
209
- /**
210
- * Check lane for orphan done WUs (pre-flight for wu:claim)
211
- *
212
- * @param {string} lane - Lane name to check
213
- * @param {string} excludeId - WU ID to exclude from check (the one being claimed)
214
- * @param {string} [projectRoot=process.cwd()] - Project root directory
215
- * @returns {Promise<object>} Result with valid, orphans list, and reports
216
- */
217
- export async function checkLaneForOrphanDoneWU(lane, excludeId, projectRoot = process.cwd()) {
218
- const paths = createWuPaths({ projectRoot });
219
- const wuDir = path.join(projectRoot, paths.WU_DIR());
220
- const trackedStampIds = await listTrackedWUStampIds({
221
- projectRoot,
222
- stampsDir: paths.STAMPS_DIR(),
223
- });
224
- try {
225
- await access(wuDir, constants.R_OK);
226
- }
227
- catch {
228
- return { valid: true, orphans: [] };
229
- }
230
- const orphans = [];
231
- const wuFiles = (await readdir(wuDir)).filter((f) => /^WU-\d+\.yaml$/.test(f));
232
- for (const file of wuFiles) {
233
- const id = file.replace('.yaml', '');
234
- if (id === excludeId)
235
- continue;
236
- const wuPath = path.join(wuDir, file);
237
- let wuContent;
238
- try {
239
- wuContent = await readFile(wuPath, { encoding: 'utf-8' });
240
- }
241
- catch {
242
- // Skip unreadable files
243
- continue;
244
- }
245
- let wuDoc;
246
- try {
247
- wuDoc = parseYAML(wuContent);
248
- }
249
- catch {
250
- // Skip malformed YAML files - they're a separate issue
251
- continue;
252
- }
253
- if (wuDoc?.lane === lane && wuDoc?.status === WU_STATUS.DONE) {
254
- const report = await checkWUConsistency(id, projectRoot, { trackedStampIds });
255
- if (!report.valid) {
256
- orphans.push({ id, errors: report.errors });
257
- }
258
- }
259
- }
260
- return {
261
- valid: orphans.length === 0,
262
- orphans: orphans.map((o) => o.id),
263
- reports: orphans,
264
- };
265
- }
266
- /**
267
- * Categorize errors into file-based repairs (need micro-worktree) and git-only repairs
268
- */
269
- function categorizeErrors(errors) {
270
- const fileRepairs = [];
271
- const gitOnlyRepairs = [];
272
- const nonRepairable = [];
273
- for (const error of errors) {
274
- if (!error.canAutoRepair) {
275
- nonRepairable.push(error);
276
- continue;
277
- }
278
- // Git-only repairs: worktree/branch cleanup doesn't need micro-worktree
279
- if (error.type === CONSISTENCY_TYPES.ORPHAN_WORKTREE_DONE) {
280
- gitOnlyRepairs.push(error);
281
- }
282
- else {
283
- // All file-based repairs need micro-worktree isolation
284
- fileRepairs.push(error);
285
- }
286
- }
287
- return { fileRepairs, gitOnlyRepairs, nonRepairable };
288
- }
289
- /**
290
- * Repair WU inconsistencies using micro-worktree isolation (WU-1078)
291
- *
292
- * All file modifications (stamps, YAML, markdown) are made atomically
293
- * in a micro-worktree, then committed and pushed to origin/main.
294
- * This prevents direct writes to the main checkout.
295
- *
296
- * WU-1370: When projectRoot is explicitly provided (not process.cwd()), the caller
297
- * is already inside a micro-worktree context (e.g., handleOrphanCheck during wu:claim).
298
- * In this case, skip creating a nested micro-worktree and work directly in projectRoot.
299
- * This prevents local main drift from nested micro-worktrees merging before pushing.
300
- *
301
- * @param {object} report - Report from checkWUConsistency()
302
- * @param {RepairWUInconsistencyOptions} [options={}] - Repair options
303
- * @returns {Promise<object>} Result with repaired, skipped, and failed counts
304
- */
305
- export async function repairWUInconsistency(report, options = {}) {
306
- const { dryRun = false, projectRoot } = options;
307
- // WU-1370: Detect if projectRoot was explicitly provided
308
- // If provided, we're inside a micro-worktree and should work directly in projectRoot
309
- const isInsideMicroWorktree = projectRoot !== undefined;
310
- const effectiveProjectRoot = projectRoot ?? process.cwd();
311
- if (report.valid) {
312
- return { repaired: 0, skipped: 0, failed: 0 };
313
- }
314
- const { fileRepairs, gitOnlyRepairs, nonRepairable } = categorizeErrors(report.errors);
315
- let repaired = 0;
316
- let skipped = nonRepairable.length;
317
- let failed = 0;
318
- // Dry run mode: just count
319
- if (dryRun) {
320
- return {
321
- repaired: fileRepairs.length + gitOnlyRepairs.length,
322
- skipped,
323
- failed: 0,
324
- };
325
- }
326
- // Step 1: Process file-based repairs
327
- if (fileRepairs.length > 0) {
328
- // WU-1370: When projectRoot is provided, we're already in a micro-worktree context
329
- // (e.g., called from handleOrphanCheck during wu:claim). Work directly in projectRoot
330
- // instead of creating a nested micro-worktree.
331
- if (isInsideMicroWorktree) {
332
- // Direct repair mode: work in the provided projectRoot
333
- for (const error of fileRepairs) {
334
- try {
335
- // When inside a micro-worktree, worktreePath === projectRoot
336
- // We're both reading from and writing to the same location
337
- const result = await repairSingleErrorInWorktree(error, effectiveProjectRoot, effectiveProjectRoot);
338
- if (result.success && result.files) {
339
- repaired++;
340
- }
341
- else if (result.skipped) {
342
- skipped++;
343
- if (result.reason) {
344
- console.warn(`${LOG_PREFIX.REPAIR} Skipped ${error.type}: ${result.reason}`);
345
- }
346
- }
347
- else {
348
- failed++;
349
- }
350
- }
351
- catch (err) {
352
- const errMessage = err instanceof Error ? err.message : String(err);
353
- console.error(`${LOG_PREFIX.REPAIR} Failed to repair ${error.type}: ${errMessage}`);
354
- failed++;
355
- }
356
- }
357
- }
358
- else {
359
- // Standard mode: create micro-worktree for isolation
360
- try {
361
- // Generate a batch ID from the WU IDs being repaired
362
- const batchId = `batch-${fileRepairs.map((e) => e.wuId).join('-')}`.slice(0, 50);
363
- await withMicroWorktree({
364
- operation: 'wu-repair',
365
- id: batchId,
366
- logPrefix: LOG_PREFIX.REPAIR,
367
- execute: async ({ worktreePath }) => {
368
- const filesModified = [];
369
- for (const error of fileRepairs) {
370
- try {
371
- const result = await repairSingleErrorInWorktree(error, worktreePath, worktreePath);
372
- if (result.success && result.files) {
373
- filesModified.push(...result.files);
374
- repaired++;
375
- }
376
- else if (result.skipped) {
377
- skipped++;
378
- if (result.reason) {
379
- console.warn(`${LOG_PREFIX.REPAIR} Skipped ${error.type}: ${result.reason}`);
380
- }
381
- }
382
- else {
383
- failed++;
384
- }
385
- }
386
- catch (err) {
387
- const errMessage = err instanceof Error ? err.message : String(err);
388
- console.error(`${LOG_PREFIX.REPAIR} Failed to repair ${error.type}: ${errMessage}`);
389
- failed++;
390
- }
391
- }
392
- // Deduplicate files
393
- const uniqueFiles = [...new Set(filesModified)];
394
- return {
395
- commitMessage: `fix: repair ${repaired} WU inconsistencies`,
396
- files: uniqueFiles,
397
- };
398
- },
399
- });
400
- }
401
- catch (err) {
402
- // If micro-worktree fails, mark all file repairs as failed
403
- const errMessage = err instanceof Error ? err.message : String(err);
404
- console.error(`${LOG_PREFIX.REPAIR} Micro-worktree operation failed: ${errMessage}`);
405
- failed += fileRepairs.length - repaired;
406
- }
407
- }
408
- }
409
- // Step 2: Process git-only repairs (worktree/branch cleanup) directly
410
- for (const error of gitOnlyRepairs) {
411
- try {
412
- const result = await repairGitOnlyError(error, effectiveProjectRoot);
413
- if (result.success) {
414
- repaired++;
415
- }
416
- else if (result.skipped) {
417
- skipped++;
418
- if (result.reason) {
419
- console.warn(`${LOG_PREFIX.REPAIR} Skipped ${error.type}: ${result.reason}`);
420
- }
421
- }
422
- else {
423
- failed++;
424
- }
425
- }
426
- catch (err) {
427
- const errMessage = err instanceof Error ? err.message : String(err);
428
- console.error(`${LOG_PREFIX.REPAIR} Failed to repair ${error.type}: ${errMessage}`);
429
- failed++;
430
- }
431
- }
432
- return { repaired, skipped, failed };
433
- }
434
- /**
435
- * Repair a single file-based error inside a micro-worktree (WU-1078)
436
- *
437
- * This function performs file modifications inside the worktree path,
438
- * which is then committed and pushed atomically by withMicroWorktree.
439
- *
440
- * @param {ConsistencyError} error - Error object from checkWUConsistency()
441
- * @param {string} worktreePath - Path to the micro-worktree
442
- * @param {string} projectRoot - Original project root (for reading source files)
443
- * @returns {Promise<RepairResult>} Result with success, skipped, reason, and files modified
444
- */
445
- async function repairSingleErrorInWorktree(error, worktreePath, projectRoot) {
446
- switch (error.type) {
447
- case CONSISTENCY_TYPES.YAML_DONE_NO_STAMP: {
448
- const files = await createStampInWorktree(error.wuId, error.title || `WU ${error.wuId}`, worktreePath);
449
- return { success: true, files };
450
- }
451
- case CONSISTENCY_TYPES.YAML_DONE_STATUS_IN_PROGRESS: {
452
- const files = await removeWUFromSectionInWorktree(WU_PATHS.STATUS(), error.wuId, '## In Progress', worktreePath, projectRoot);
453
- return { success: true, files };
454
- }
455
- case CONSISTENCY_TYPES.BACKLOG_DUAL_SECTION: {
456
- const files = await removeWUFromSectionInWorktree(WU_PATHS.BACKLOG(), error.wuId, '## 🔧 In progress', worktreePath, projectRoot);
457
- return { success: true, files };
458
- }
459
- case CONSISTENCY_TYPES.STAMP_EXISTS_YAML_NOT_DONE: {
460
- const files = await updateYamlToDoneInWorktree(error.wuId, worktreePath, projectRoot);
461
- return { success: true, files };
462
- }
463
- default:
464
- return { skipped: true, reason: `Unknown error type: ${error.type}` };
465
- }
466
- }
467
- /**
468
- * Repair git-only errors (worktree/branch cleanup) without micro-worktree
469
- *
470
- * These operations don't modify files in the repo, they only manage git worktrees
471
- * and branches, so they can run directly.
472
- *
473
- * @param {ConsistencyError} error - Error object
474
- * @param {string} projectRoot - Project root directory
475
- * @returns {Promise<RepairResult>} Result with success, skipped, and reason
476
- */
477
- async function repairGitOnlyError(error, projectRoot) {
478
- switch (error.type) {
479
- case CONSISTENCY_TYPES.ORPHAN_WORKTREE_DONE:
480
- if (!error.lane) {
481
- return { skipped: true, reason: 'Missing lane metadata for orphan worktree cleanup' };
482
- }
483
- return await removeOrphanWorktree(error.wuId, error.lane, projectRoot);
484
- default:
485
- return { skipped: true, reason: `Unknown git-only error type: ${error.type}` };
486
- }
487
- }
488
- /**
489
- * Create stamp file inside a micro-worktree (WU-1078)
490
- *
491
- * @param {string} id - WU ID
492
- * @param {string} title - WU title
493
- * @param {string} worktreePath - Path to the micro-worktree
494
- * @returns {Promise<string[]>} List of files created (relative paths)
495
- */
496
- async function createStampInWorktree(id, title, worktreePath) {
497
- const stampsDir = path.join(worktreePath, WU_PATHS.STAMPS_DIR());
498
- const stampRelPath = WU_PATHS.STAMP(id);
499
- const stampAbsPath = path.join(worktreePath, stampRelPath);
500
- // Ensure stamps directory exists
501
- if (!existsSync(stampsDir)) {
502
- mkdirSync(stampsDir, { recursive: true });
503
- }
504
- // Don't overwrite existing stamp
505
- if (existsSync(stampAbsPath)) {
506
- return []; // Stamp already exists
507
- }
508
- // Create stamp file
509
- const body = `WU ${id} — ${title}\nCompleted: ${todayISO()}\n`;
510
- writeFileSync(stampAbsPath, body, { encoding: 'utf-8' });
511
- return [stampRelPath];
512
- }
513
- /**
514
- * Create stamp file in a specific project root (DEPRECATED - use createStampInWorktree)
515
- *
516
- * Kept for backwards compatibility with code that doesn't use micro-worktree.
517
- *
518
- * @param {string} id - WU ID
519
- * @param {string} title - WU title
520
- * @param {string} projectRoot - Project root directory
521
- * @returns {Promise<void>}
522
- */
523
- async function _createStampInProject(id, title, projectRoot) {
524
- const stampsDir = path.join(projectRoot, WU_PATHS.STAMPS_DIR());
525
- const stampPath = path.join(projectRoot, WU_PATHS.STAMP(id));
526
- // Ensure stamps directory exists
527
- try {
528
- await access(stampsDir, constants.R_OK);
529
- }
530
- catch {
531
- await mkdir(stampsDir, { recursive: true });
532
- }
533
- // Don't overwrite existing stamp
534
- try {
535
- await access(stampPath, constants.R_OK);
536
- return; // Stamp already exists
537
- }
538
- catch {
539
- // Stamp doesn't exist, continue to create it
540
- }
541
- // Create stamp file
542
- const body = `WU ${id} — ${title}\nCompleted: ${todayISO()}\n`;
543
- await writeFile(stampPath, body, { encoding: 'utf-8' });
544
- }
545
- /**
546
- * Update WU YAML to done+locked+completed state inside a micro-worktree (WU-1078)
547
- *
548
- * Repairs STAMP_EXISTS_YAML_NOT_DONE by setting:
549
- * - status: done
550
- * - locked: true
551
- * - completed: YYYY-MM-DD (today, unless already set)
552
- *
553
- * @param {string} id - WU ID
554
- * @param {string} worktreePath - Path to the micro-worktree
555
- * @param {string} projectRoot - Original project root (for reading source file)
556
- * @returns {Promise<string[]>} List of files modified (relative paths)
557
- */
558
- async function updateYamlToDoneInWorktree(id, worktreePath, projectRoot) {
559
- const paths = createWuPaths({ projectRoot });
560
- const wuRelPath = paths.WU(id);
561
- const wuSrcPath = path.join(projectRoot, wuRelPath);
562
- const wuDestPath = path.join(worktreePath, wuRelPath);
563
- const wuReadPath = existsSync(wuDestPath) ? wuDestPath : wuSrcPath;
564
- // Read current YAML (prefer destination copy if already modified in this batch)
565
- const content = readFileSync(wuReadPath, { encoding: 'utf-8' });
566
- const wuDoc = parseYAML(content);
567
- if (!wuDoc) {
568
- throw new Error(`Failed to parse WU YAML: ${wuReadPath}`);
569
- }
570
- // Update fields
571
- wuDoc.status = WU_STATUS.DONE;
572
- wuDoc.locked = true;
573
- const existingCompletedAt = wuDoc.completed_at;
574
- const completionTimestamp = typeof existingCompletedAt === 'string'
575
- ? existingCompletedAt
576
- : existingCompletedAt instanceof Date
577
- ? existingCompletedAt.toISOString()
578
- : new Date().toISOString();
579
- wuDoc.completed_at = completionTimestamp;
580
- // Keep legacy completed date in sync with completed_at for compatibility.
581
- wuDoc.completed =
582
- normalizeToDateString(wuDoc.completed ?? completionTimestamp) ??
583
- completionTimestamp.slice(0, 10);
584
- // Ensure directory exists in worktree
585
- const wuDir = path.dirname(wuDestPath);
586
- if (!existsSync(wuDir)) {
587
- mkdirSync(wuDir, { recursive: true });
588
- }
589
- // Write updated YAML to worktree
590
- const updatedContent = stringifyYAML(wuDoc, { lineWidth: YAML_OPTIONS.LINE_WIDTH });
591
- writeFileSync(wuDestPath, updatedContent, { encoding: 'utf-8' });
592
- const eventFiles = appendReconciliationEventsInWorktree({
593
- id,
594
- lane: wuDoc.lane,
595
- title: wuDoc.title,
596
- projectRoot,
597
- worktreePath,
598
- });
599
- return [wuRelPath, ...eventFiles];
600
- }
601
- function deriveStatusFromEvents(eventsContent, wuId) {
602
- let status;
603
- const lines = eventsContent.split(/\r?\n/);
604
- for (const line of lines) {
605
- if (!line.trim())
606
- continue;
607
- try {
608
- const event = JSON.parse(line);
609
- if (event.wuId !== wuId || !event.type)
610
- continue;
611
- switch (event.type) {
612
- case 'claim':
613
- case 'create':
614
- status = WU_STATUS.IN_PROGRESS;
615
- break;
616
- case 'release':
617
- status = WU_STATUS.READY;
618
- break;
619
- case 'complete':
620
- status = WU_STATUS.DONE;
621
- break;
622
- case 'block':
623
- status = WU_STATUS.BLOCKED;
624
- break;
625
- case 'unblock':
626
- status = WU_STATUS.IN_PROGRESS;
627
- break;
628
- }
629
- }
630
- catch {
631
- // Ignore malformed lines; preserve file as-is and append corrective events.
632
- }
633
- }
634
- return status;
635
- }
636
- function appendReconciliationEventsInWorktree({ id, lane, title, projectRoot, worktreePath, }) {
637
- const eventsRelPath = LUMENFLOW_PATHS.WU_EVENTS;
638
- const eventsSrcPath = path.join(projectRoot, eventsRelPath);
639
- const eventsDestPath = path.join(worktreePath, eventsRelPath);
640
- const eventsReadPath = existsSync(eventsDestPath) ? eventsDestPath : eventsSrcPath;
641
- const existingContent = existsSync(eventsReadPath)
642
- ? readFileSync(eventsReadPath, { encoding: 'utf-8' })
643
- : '';
644
- const derivedStatus = deriveStatusFromEvents(existingContent, id);
645
- if (derivedStatus === WU_STATUS.DONE) {
646
- return [];
647
- }
648
- const now = new Date().toISOString();
649
- const appendEvents = [];
650
- if (derivedStatus !== WU_STATUS.IN_PROGRESS) {
651
- appendEvents.push({
652
- type: 'claim',
653
- wuId: id,
654
- lane: typeof lane === 'string' && lane.trim().length > 0 ? lane : 'Operations: Tooling',
655
- title: typeof title === 'string' && title.trim().length > 0 ? title : `WU ${id}`,
656
- timestamp: now,
657
- });
658
- }
659
- appendEvents.push({
660
- type: 'complete',
661
- wuId: id,
662
- reason: 'wu:repair consistency reconciliation for stamp/yaml mismatch',
663
- timestamp: now,
664
- });
665
- const destDir = path.dirname(eventsDestPath);
666
- if (!existsSync(destDir)) {
667
- mkdirSync(destDir, { recursive: true });
668
- }
669
- const suffix = appendEvents.map((event) => JSON.stringify(event)).join(STRING_LITERALS.NEWLINE);
670
- const normalizedExisting = existingContent
671
- ? existingContent.endsWith(STRING_LITERALS.NEWLINE)
672
- ? existingContent
673
- : `${existingContent}${STRING_LITERALS.NEWLINE}`
674
- : '';
675
- writeFileSync(eventsDestPath, `${normalizedExisting}${suffix}${STRING_LITERALS.NEWLINE}`, {
676
- encoding: 'utf-8',
677
- });
678
- return [eventsRelPath];
679
- }
680
- /**
681
- * Update WU YAML to done+locked+completed state (DEPRECATED - use updateYamlToDoneInWorktree)
682
- *
683
- * Kept for backwards compatibility.
684
- *
685
- * @param {string} id - WU ID
686
- * @param {string} projectRoot - Project root directory
687
- * @returns {Promise<void>}
688
- */
689
- async function _updateYamlToDone(id, projectRoot) {
690
- const paths = createWuPaths({ projectRoot });
691
- const wuPath = path.join(projectRoot, paths.WU(id));
692
- // Read current YAML
693
- const content = await readFile(wuPath, { encoding: 'utf-8' });
694
- const wuDoc = parseYAML(content);
695
- if (!wuDoc) {
696
- throw new Error(`Failed to parse WU YAML: ${wuPath}`);
697
- }
698
- // Update fields
699
- wuDoc.status = WU_STATUS.DONE;
700
- wuDoc.locked = true;
701
- // Preserve existing completed date if present, otherwise set to today
702
- if (!wuDoc.completed) {
703
- wuDoc.completed = todayISO();
704
- }
705
- // Write updated YAML
706
- const updatedContent = stringifyYAML(wuDoc, { lineWidth: YAML_OPTIONS.LINE_WIDTH });
707
- await writeFile(wuPath, updatedContent, { encoding: 'utf-8' });
708
- }
709
- /**
710
- * Remove WU entry from a specific section in a markdown file inside a micro-worktree (WU-1078)
711
- *
712
- * @param {string} relFilePath - Relative path to the markdown file
713
- * @param {string} id - WU ID to remove
714
- * @param {string} sectionHeading - Section heading to target
715
- * @param {string} worktreePath - Path to the micro-worktree
716
- * @param {string} projectRoot - Original project root (for reading source file)
717
- * @returns {Promise<string[]>} List of files modified (relative paths)
718
- */
719
- async function removeWUFromSectionInWorktree(relFilePath, id, sectionHeading, worktreePath, projectRoot) {
720
- const srcPath = path.join(projectRoot, relFilePath);
721
- const destPath = path.join(worktreePath, relFilePath);
722
- // Check if source file exists
723
- if (!existsSync(srcPath)) {
724
- return []; // File doesn't exist
725
- }
726
- const content = readFileSync(srcPath, { encoding: 'utf-8' });
727
- const lines = content.split(/\r?\n/);
728
- let inTargetSection = false;
729
- let nextSectionIdx = -1;
730
- let sectionStartIdx = -1;
731
- // Normalize heading for comparison (lowercase, trim)
732
- const normalizedHeading = sectionHeading.toLowerCase().trim();
733
- // Find section boundaries
734
- for (let i = 0; i < lines.length; i++) {
735
- const currentLine = lines[i] ?? '';
736
- const normalizedLine = currentLine.toLowerCase().trim();
737
- if (normalizedLine === normalizedHeading || normalizedLine.startsWith(normalizedHeading)) {
738
- inTargetSection = true;
739
- sectionStartIdx = i;
740
- continue;
741
- }
742
- if (inTargetSection && currentLine.trim().startsWith('## ')) {
743
- nextSectionIdx = i;
744
- break;
745
- }
746
- }
747
- if (sectionStartIdx === -1)
748
- return [];
749
- const endIdx = nextSectionIdx === -1 ? lines.length : nextSectionIdx;
750
- // Filter out lines containing the WU ID in the target section
751
- const newLines = [];
752
- let modified = false;
753
- for (let i = 0; i < lines.length; i++) {
754
- const currentLine = lines[i] ?? '';
755
- if (i > sectionStartIdx && i < endIdx && currentLine.includes(id)) {
756
- modified = true;
757
- continue; // Skip this line
758
- }
759
- newLines.push(currentLine);
760
- }
761
- if (!modified)
762
- return [];
763
- // Ensure directory exists in worktree
764
- const destDir = path.dirname(destPath);
765
- if (!existsSync(destDir)) {
766
- mkdirSync(destDir, { recursive: true });
767
- }
768
- writeFileSync(destPath, newLines.join(STRING_LITERALS.NEWLINE), { encoding: 'utf-8' });
769
- return [relFilePath];
770
- }
771
- /**
772
- * Remove WU entry from a specific section in a markdown file (DEPRECATED)
773
- *
774
- * Kept for backwards compatibility.
775
- *
776
- * @param {string} filePath - Path to the markdown file
777
- * @param {string} id - WU ID to remove
778
- * @param {string} sectionHeading - Section heading to target
779
- * @returns {Promise<void>}
780
- */
781
- async function _removeWUFromSection(filePath, id, sectionHeading) {
782
- try {
783
- await access(filePath, constants.R_OK);
784
- }
785
- catch {
786
- return; // File doesn't exist
787
- }
788
- const content = await readFile(filePath, { encoding: 'utf-8' });
789
- const lines = content.split(/\r?\n/);
790
- let inTargetSection = false;
791
- let nextSectionIdx = -1;
792
- let sectionStartIdx = -1;
793
- // Normalize heading for comparison (lowercase, trim)
794
- const normalizedHeading = sectionHeading.toLowerCase().trim();
795
- // Find section boundaries
796
- for (let i = 0; i < lines.length; i++) {
797
- const currentLine = lines[i] ?? '';
798
- const normalizedLine = currentLine.toLowerCase().trim();
799
- if (normalizedLine === normalizedHeading || normalizedLine.startsWith(normalizedHeading)) {
800
- inTargetSection = true;
801
- sectionStartIdx = i;
802
- continue;
803
- }
804
- if (inTargetSection && currentLine.trim().startsWith('## ')) {
805
- nextSectionIdx = i;
806
- break;
807
- }
808
- }
809
- if (sectionStartIdx === -1)
810
- return;
811
- const endIdx = nextSectionIdx === -1 ? lines.length : nextSectionIdx;
812
- // Filter out lines containing the WU ID in the target section
813
- const newLines = [];
814
- for (let i = 0; i < lines.length; i++) {
815
- const currentLine = lines[i] ?? '';
816
- if (i > sectionStartIdx && i < endIdx && currentLine.includes(id)) {
817
- continue; // Skip this line
818
- }
819
- newLines.push(currentLine);
820
- }
821
- await writeFile(filePath, newLines.join(STRING_LITERALS.NEWLINE));
822
- }
823
- /**
824
- * Remove orphan worktree for a done WU
825
- *
826
- * CRITICAL: This function includes safety guards to prevent data loss.
827
- * See WU-1276 incident report for why these guards are essential.
828
- *
829
- * @param {string} id - WU ID
830
- * @param {string} lane - Lane name
831
- * @param {string} projectRoot - Project root directory
832
- * @returns {Promise<object>} Result with success, skipped, and reason
833
- */
834
- async function removeOrphanWorktree(id, lane, projectRoot) {
835
- // Find worktree path
836
- const laneKebab = toKebab(lane);
837
- const worktreeName = `${laneKebab}-${id.toLowerCase()}`;
838
- const worktreePath = path.join(projectRoot, 'worktrees', worktreeName);
839
- // 🚨 SAFETY GUARD 1: Check if cwd is inside worktree
840
- const cwd = process.cwd();
841
- if (cwd.startsWith(worktreePath)) {
842
- return { skipped: true, reason: 'Cannot delete worktree while inside it' };
843
- }
844
- // 🚨 SAFETY GUARD 2: Check for uncommitted changes (if worktree exists)
845
- try {
846
- await access(worktreePath, constants.R_OK);
847
- // Worktree exists, check for uncommitted changes
848
- try {
849
- const gitWorktree = createGitForPath(worktreePath);
850
- const status = await gitWorktree.getStatus();
851
- if (status.trim().length > 0) {
852
- return { skipped: true, reason: 'Worktree has uncommitted changes' };
853
- }
854
- }
855
- catch {
856
- // Ignore errors checking status - proceed with other guards
857
- }
858
- }
859
- catch {
860
- // Worktree doesn't exist, that's fine
861
- }
862
- // 🚨 SAFETY GUARD 3: Check stamp exists (not rollback state)
863
- const paths = createWuPaths({ projectRoot });
864
- const stampPath = path.join(projectRoot, paths.STAMP(id));
865
- try {
866
- await access(stampPath, constants.R_OK);
867
- }
868
- catch {
869
- return { skipped: true, reason: 'WU marked done but no stamp - possible rollback state' };
870
- }
871
- // Safe to proceed with cleanup
872
- const git = createGitForPath(projectRoot);
873
- try {
874
- await access(worktreePath, constants.R_OK);
875
- await git.worktreeRemove(worktreePath, { force: true });
876
- }
877
- catch {
878
- // Worktree may not exist
879
- }
880
- // Delete lane branch
881
- const branchName = `lane/${laneKebab}/${id.toLowerCase()}`;
882
- try {
883
- await git.deleteBranch(branchName, { force: true });
884
- }
885
- catch {
886
- // Branch may not exist locally
887
- }
888
- try {
889
- await git.raw(['push', REMOTES.ORIGIN, '--delete', branchName]);
890
- }
891
- catch {
892
- // Remote branch may not exist
893
- }
894
- return { success: true };
895
- }
896
- /**
897
- * Parse backlog.md to find which sections contain a WU ID
898
- *
899
- * @param {string} content - Backlog file content
900
- * @param {string} id - WU ID to search for
901
- * @returns {object} Object with inDone and inProgress booleans
902
- */
903
- function parseBacklogSections(content, id) {
904
- const lines = content.split(/\r?\n/);
905
- let inDone = false;
906
- let inProgress = false;
907
- let currentSection = null;
908
- // Match exact WU YAML filename to prevent substring false positives
909
- // e.g., WU-208 should not match lines containing WU-2087
910
- const exactPattern = `(wu/${id}.yaml)`;
911
- for (const line of lines) {
912
- if (line.trim() === '## ✅ Done') {
913
- currentSection = WU_STATUS.DONE;
914
- continue;
915
- }
916
- if (line.trim() === '## 🔧 In progress') {
917
- currentSection = WU_STATUS.IN_PROGRESS;
918
- continue;
919
- }
920
- if (line.trim().startsWith('## ')) {
921
- currentSection = null;
922
- continue;
923
- }
924
- if (line.includes(exactPattern)) {
925
- if (currentSection === WU_STATUS.DONE)
926
- inDone = true;
927
- if (currentSection === WU_STATUS.IN_PROGRESS)
928
- inProgress = true;
929
- }
930
- }
931
- return { inDone, inProgress };
932
- }
933
- /**
934
- * Parse status.md to find if WU is in In Progress section
935
- *
936
- * @param {string} content - Status file content
937
- * @param {string} id - WU ID to search for
938
- * @returns {object} Object with inProgress boolean
939
- */
940
- function parseStatusSections(content, id) {
941
- const lines = content.split(/\r?\n/);
942
- let inProgress = false;
943
- let currentSection = null;
944
- // Match exact WU YAML filename to prevent substring false positives
945
- // e.g., WU-208 should not match lines containing WU-2087
946
- const exactPattern = `(wu/${id}.yaml)`;
947
- for (const line of lines) {
948
- if (line.trim() === '## In Progress') {
949
- currentSection = WU_STATUS.IN_PROGRESS;
950
- continue;
951
- }
952
- if (line.trim().startsWith('## ')) {
953
- currentSection = null;
954
- continue;
955
- }
956
- if (currentSection === WU_STATUS.IN_PROGRESS && line.includes(exactPattern)) {
957
- inProgress = true;
958
- }
959
- }
960
- return { inProgress };
961
- }
962
- /**
963
- * Check if a worktree exists for a given WU ID
964
- *
965
- * Uses word-boundary matching to avoid false positives where one WU ID
966
- * is a prefix of another (e.g., WU-204 should not match wu-2049).
967
- *
968
- * @param {string} id - WU ID
969
- * @param {string} projectRoot - Project root directory
970
- * @returns {Promise<boolean>} True if worktree exists
971
- */
972
- async function checkWorktreeExists(id, projectRoot) {
973
- try {
974
- const git = createGitForPath(projectRoot);
975
- const output = await git.worktreeList();
976
- // Match WU ID followed by non-digit or end of string to prevent
977
- // false positives (e.g., wu-204 matching wu-2049)
978
- // eslint-disable-next-line security/detect-non-literal-regexp -- WU ID from internal state, not user input
979
- const pattern = new RegExp(`${id.toLowerCase()}(?![0-9])`, 'i');
980
- return pattern.test(output);
981
- }
982
- catch {
983
- return false;
984
- }
985
- }
986
- /**
987
- * Precompute active WU IDs from git worktree list.
988
- *
989
- * Returns:
990
- * - Set of normalized WU IDs (e.g. WU-1234) when query succeeds
991
- * - null when git worktree listing is unavailable (caller should fall back)
992
- */
993
- async function listActiveWorktreeIds(projectRoot) {
994
- try {
995
- const git = createGitForPath(projectRoot);
996
- const output = await git.worktreeList();
997
- const matches = output.match(/\bwu-\d+\b/gi) ?? [];
998
- const ids = new Set();
999
- for (const match of matches) {
1000
- ids.add(match.toUpperCase());
1001
- }
1002
- return ids;
1003
- }
1004
- catch {
1005
- return null;
1006
- }
1007
- }
1008
- /**
1009
- * Check whether a worktree path exists on disk
1010
- *
1011
- * @param {string} worktreePath - Worktree path from WU YAML
1012
- * @returns {Promise<boolean>} True if path exists
1013
- */
1014
- async function checkWorktreePathExists(worktreePath) {
1015
- if (!worktreePath) {
1016
- return false;
1017
- }
1018
- try {
1019
- await access(worktreePath, constants.R_OK);
1020
- return true;
1021
- }
1022
- catch {
1023
- return false;
1024
- }
1025
- }
1026
- //# sourceMappingURL=wu-consistency-checker.js.map