@lumenflow/core 2.15.2 → 2.17.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 (270) hide show
  1. package/dist/adapters/filesystem-metrics.adapter.d.ts.map +1 -1
  2. package/dist/adapters/filesystem-metrics.adapter.js +17 -16
  3. package/dist/adapters/filesystem-metrics.adapter.js.map +1 -1
  4. package/dist/adapters/mock-dashboard-renderer.adapter.d.ts +86 -0
  5. package/dist/adapters/mock-dashboard-renderer.adapter.d.ts.map +1 -0
  6. package/dist/adapters/mock-dashboard-renderer.adapter.js +105 -0
  7. package/dist/adapters/mock-dashboard-renderer.adapter.js.map +1 -0
  8. package/dist/adapters/terminal-renderer.adapter.d.ts.map +1 -1
  9. package/dist/adapters/terminal-renderer.adapter.js +0 -2
  10. package/dist/adapters/terminal-renderer.adapter.js.map +1 -1
  11. package/dist/arg-parser.d.ts.map +1 -1
  12. package/dist/arg-parser.js +4 -3
  13. package/dist/arg-parser.js.map +1 -1
  14. package/dist/backlog-editor.js +1 -1
  15. package/dist/backlog-editor.js.map +1 -1
  16. package/dist/backlog-generator.d.ts.map +1 -1
  17. package/dist/backlog-generator.js +48 -21
  18. package/dist/backlog-generator.js.map +1 -1
  19. package/dist/backlog-parser.d.ts.map +1 -1
  20. package/dist/backlog-parser.js +0 -1
  21. package/dist/backlog-parser.js.map +1 -1
  22. package/dist/backlog-sync-validator.d.ts.map +1 -1
  23. package/dist/backlog-sync-validator.js +5 -3
  24. package/dist/backlog-sync-validator.js.map +1 -1
  25. package/dist/branch-check.d.ts.map +1 -1
  26. package/dist/branch-check.js +1 -0
  27. package/dist/branch-check.js.map +1 -1
  28. package/dist/cli/is-agent-branch.d.ts +2 -1
  29. package/dist/cli/is-agent-branch.d.ts.map +1 -1
  30. package/dist/cli/is-agent-branch.js +8 -1
  31. package/dist/cli/is-agent-branch.js.map +1 -1
  32. package/dist/code-path-validator.d.ts.map +1 -1
  33. package/dist/code-path-validator.js +2 -1
  34. package/dist/code-path-validator.js.map +1 -1
  35. package/dist/code-paths-overlap.js +1 -1
  36. package/dist/code-paths-overlap.js.map +1 -1
  37. package/dist/commands-logger.js +1 -1
  38. package/dist/commands-logger.js.map +1 -1
  39. package/dist/context/location-resolver.js +1 -1
  40. package/dist/context/location-resolver.js.map +1 -1
  41. package/dist/context-validation-integration.d.ts +1 -1
  42. package/dist/context-validation-integration.d.ts.map +1 -1
  43. package/dist/context-validation-integration.js +3 -2
  44. package/dist/context-validation-integration.js.map +1 -1
  45. package/dist/core/tool-runner.js +1 -1
  46. package/dist/core/tool-runner.js.map +1 -1
  47. package/dist/core/tool.schemas.d.ts +3 -3
  48. package/dist/core/tool.schemas.d.ts.map +1 -1
  49. package/dist/core/tool.schemas.js +1 -1
  50. package/dist/core/tool.schemas.js.map +1 -1
  51. package/dist/dependency-graph.js +1 -1
  52. package/dist/dependency-graph.js.map +1 -1
  53. package/dist/dependency-guard.js +1 -1
  54. package/dist/dependency-guard.js.map +1 -1
  55. package/dist/domain/context.schemas.d.ts +3 -3
  56. package/dist/domain/orchestration.constants.d.ts.map +1 -1
  57. package/dist/domain/orchestration.constants.js +7 -6
  58. package/dist/domain/orchestration.constants.js.map +1 -1
  59. package/dist/domain/validation.schemas.d.ts +1 -1
  60. package/dist/error-handler.d.ts +26 -2
  61. package/dist/error-handler.d.ts.map +1 -1
  62. package/dist/error-handler.js +36 -3
  63. package/dist/error-handler.js.map +1 -1
  64. package/dist/force-bypass-audit.d.ts.map +1 -1
  65. package/dist/force-bypass-audit.js +2 -0
  66. package/dist/force-bypass-audit.js.map +1 -1
  67. package/dist/git-context-extractor.d.ts.map +1 -1
  68. package/dist/git-context-extractor.js +1 -0
  69. package/dist/git-context-extractor.js.map +1 -1
  70. package/dist/index.d.ts +5 -1
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +3 -1
  73. package/dist/index.js.map +1 -1
  74. package/dist/invariants/check-automated-tests.js +2 -2
  75. package/dist/invariants/check-automated-tests.js.map +1 -1
  76. package/dist/invariants-runner.d.ts.map +1 -1
  77. package/dist/invariants-runner.js +3 -0
  78. package/dist/invariants-runner.js.map +1 -1
  79. package/dist/lumenflow-config-schema.d.ts.map +1 -1
  80. package/dist/lumenflow-config-schema.js +2 -1
  81. package/dist/lumenflow-config-schema.js.map +1 -1
  82. package/dist/migration-deployer.d.ts +1 -1
  83. package/dist/migration-deployer.d.ts.map +1 -1
  84. package/dist/migration-deployer.js +1 -1
  85. package/dist/migration-deployer.js.map +1 -1
  86. package/dist/patrol-loop.d.ts.map +1 -1
  87. package/dist/patrol-loop.js +9 -1
  88. package/dist/patrol-loop.js.map +1 -1
  89. package/dist/piped-command-detector.d.ts.map +1 -1
  90. package/dist/piped-command-detector.js +1 -0
  91. package/dist/piped-command-detector.js.map +1 -1
  92. package/dist/ports/core-tools.ports.d.ts +32 -17
  93. package/dist/ports/core-tools.ports.d.ts.map +1 -1
  94. package/dist/ports/wu-helpers.ports.d.ts +2 -0
  95. package/dist/ports/wu-helpers.ports.d.ts.map +1 -1
  96. package/dist/prompt-linter.d.ts +5 -0
  97. package/dist/prompt-linter.d.ts.map +1 -1
  98. package/dist/prompt-linter.js +8 -2
  99. package/dist/prompt-linter.js.map +1 -1
  100. package/dist/prompt-monitor.d.ts +5 -1
  101. package/dist/prompt-monitor.d.ts.map +1 -1
  102. package/dist/prompt-monitor.js +16 -8
  103. package/dist/prompt-monitor.js.map +1 -1
  104. package/dist/rebase-artifact-cleanup.d.ts.map +1 -1
  105. package/dist/rebase-artifact-cleanup.js +1 -1
  106. package/dist/rebase-artifact-cleanup.js.map +1 -1
  107. package/dist/rollback-utils.d.ts.map +1 -1
  108. package/dist/rollback-utils.js +0 -1
  109. package/dist/rollback-utils.js.map +1 -1
  110. package/dist/schemas/initiative-arg-validators.d.ts +1 -1
  111. package/dist/schemas/initiative-schemas.d.ts +3 -3
  112. package/dist/spawn-recovery.js +1 -1
  113. package/dist/spawn-recovery.js.map +1 -1
  114. package/dist/stamp-status-validator.d.ts.map +1 -1
  115. package/dist/stamp-status-validator.js +2 -1
  116. package/dist/stamp-status-validator.js.map +1 -1
  117. package/dist/stamp-tracking.d.ts +12 -0
  118. package/dist/stamp-tracking.d.ts.map +1 -0
  119. package/dist/stamp-tracking.js +41 -0
  120. package/dist/stamp-tracking.js.map +1 -0
  121. package/dist/stamp-utils.d.ts.map +1 -1
  122. package/dist/stamp-utils.js +0 -1
  123. package/dist/stamp-utils.js.map +1 -1
  124. package/dist/state-doctor-core.d.ts.map +1 -1
  125. package/dist/state-doctor-core.js +10 -9
  126. package/dist/state-doctor-core.js.map +1 -1
  127. package/dist/system-map-validator.d.ts.map +1 -1
  128. package/dist/system-map-validator.js +7 -3
  129. package/dist/system-map-validator.js.map +1 -1
  130. package/dist/telemetry.d.ts.map +1 -1
  131. package/dist/telemetry.js +3 -1
  132. package/dist/telemetry.js.map +1 -1
  133. package/dist/template-loader.d.ts.map +1 -1
  134. package/dist/template-loader.js +1 -0
  135. package/dist/template-loader.js.map +1 -1
  136. package/dist/token-counter.js +2 -6
  137. package/dist/token-counter.js.map +1 -1
  138. package/dist/usecases/compute-context.usecase.d.ts.map +1 -1
  139. package/dist/usecases/compute-context.usecase.js +2 -1
  140. package/dist/usecases/compute-context.usecase.js.map +1 -1
  141. package/dist/validators/wu-tasks.js +2 -2
  142. package/dist/validators/wu-tasks.js.map +1 -1
  143. package/dist/wu-backlog-updater.d.ts +1 -1
  144. package/dist/wu-backlog-updater.d.ts.map +1 -1
  145. package/dist/wu-backlog-updater.js +1 -1
  146. package/dist/wu-backlog-updater.js.map +1 -1
  147. package/dist/wu-claim-resume.d.ts.map +1 -1
  148. package/dist/wu-claim-resume.js +0 -1
  149. package/dist/wu-claim-resume.js.map +1 -1
  150. package/dist/wu-cli-constants.d.ts +426 -0
  151. package/dist/wu-cli-constants.d.ts.map +1 -0
  152. package/dist/wu-cli-constants.js +429 -0
  153. package/dist/wu-cli-constants.js.map +1 -0
  154. package/dist/wu-consistency-checker.d.ts +5 -1
  155. package/dist/wu-consistency-checker.d.ts.map +1 -1
  156. package/dist/wu-consistency-checker.js +133 -25
  157. package/dist/wu-consistency-checker.js.map +1 -1
  158. package/dist/wu-constants.d.ts +21 -1834
  159. package/dist/wu-constants.d.ts.map +1 -1
  160. package/dist/wu-constants.js +28 -1951
  161. package/dist/wu-constants.js.map +1 -1
  162. package/dist/wu-context-constants.d.ts +264 -0
  163. package/dist/wu-context-constants.d.ts.map +1 -0
  164. package/dist/wu-context-constants.js +259 -0
  165. package/dist/wu-context-constants.js.map +1 -0
  166. package/dist/wu-domain-constants.d.ts +305 -0
  167. package/dist/wu-domain-constants.d.ts.map +1 -0
  168. package/dist/wu-domain-constants.js +401 -0
  169. package/dist/wu-domain-constants.js.map +1 -0
  170. package/dist/wu-done-branch-only.d.ts.map +1 -1
  171. package/dist/wu-done-branch-only.js +2 -2
  172. package/dist/wu-done-branch-only.js.map +1 -1
  173. package/dist/wu-done-concurrent-merge.d.ts.map +1 -1
  174. package/dist/wu-done-concurrent-merge.js +12 -12
  175. package/dist/wu-done-concurrent-merge.js.map +1 -1
  176. package/dist/wu-done-docs-generate.d.ts.map +1 -1
  177. package/dist/wu-done-docs-generate.js +1 -0
  178. package/dist/wu-done-docs-generate.js.map +1 -1
  179. package/dist/wu-done-initiative-sync.d.ts +13 -0
  180. package/dist/wu-done-initiative-sync.d.ts.map +1 -0
  181. package/dist/wu-done-initiative-sync.js +218 -0
  182. package/dist/wu-done-initiative-sync.js.map +1 -0
  183. package/dist/wu-done-inputs.d.ts.map +1 -1
  184. package/dist/wu-done-inputs.js +2 -2
  185. package/dist/wu-done-inputs.js.map +1 -1
  186. package/dist/wu-done-messages.d.ts +1 -1
  187. package/dist/wu-done-messages.d.ts.map +1 -1
  188. package/dist/wu-done-messages.js +2 -2
  189. package/dist/wu-done-messages.js.map +1 -1
  190. package/dist/wu-done-metadata.d.ts +6 -2
  191. package/dist/wu-done-metadata.d.ts.map +1 -1
  192. package/dist/wu-done-metadata.js +31 -7
  193. package/dist/wu-done-metadata.js.map +1 -1
  194. package/dist/wu-done-pr.d.ts.map +1 -1
  195. package/dist/wu-done-pr.js +2 -1
  196. package/dist/wu-done-pr.js.map +1 -1
  197. package/dist/wu-done-validation.d.ts +3 -1
  198. package/dist/wu-done-validation.d.ts.map +1 -1
  199. package/dist/wu-done-validation.js +81 -13
  200. package/dist/wu-done-validation.js.map +1 -1
  201. package/dist/wu-done-worktree.d.ts +54 -0
  202. package/dist/wu-done-worktree.d.ts.map +1 -1
  203. package/dist/wu-done-worktree.js +166 -44
  204. package/dist/wu-done-worktree.js.map +1 -1
  205. package/dist/wu-events-cleanup.d.ts.map +1 -1
  206. package/dist/wu-events-cleanup.js +3 -2
  207. package/dist/wu-events-cleanup.js.map +1 -1
  208. package/dist/wu-git-constants.d.ts +172 -0
  209. package/dist/wu-git-constants.d.ts.map +1 -0
  210. package/dist/wu-git-constants.js +172 -0
  211. package/dist/wu-git-constants.js.map +1 -0
  212. package/dist/wu-helpers.js +1 -1
  213. package/dist/wu-helpers.js.map +1 -1
  214. package/dist/wu-lint.d.ts.map +1 -1
  215. package/dist/wu-lint.js +8 -1
  216. package/dist/wu-lint.js.map +1 -1
  217. package/dist/wu-list.d.ts.map +1 -1
  218. package/dist/wu-list.js +3 -2
  219. package/dist/wu-list.js.map +1 -1
  220. package/dist/wu-paths-constants.d.ts +311 -0
  221. package/dist/wu-paths-constants.d.ts.map +1 -0
  222. package/dist/wu-paths-constants.js +308 -0
  223. package/dist/wu-paths-constants.js.map +1 -0
  224. package/dist/wu-paths.d.ts +12 -0
  225. package/dist/wu-paths.d.ts.map +1 -1
  226. package/dist/wu-paths.js +7 -1
  227. package/dist/wu-paths.js.map +1 -1
  228. package/dist/wu-recovery.d.ts.map +1 -1
  229. package/dist/wu-recovery.js +2 -2
  230. package/dist/wu-recovery.js.map +1 -1
  231. package/dist/wu-repair-core.d.ts +1 -0
  232. package/dist/wu-repair-core.d.ts.map +1 -1
  233. package/dist/wu-repair-core.js +7 -3
  234. package/dist/wu-repair-core.js.map +1 -1
  235. package/dist/wu-schema.d.ts.map +1 -1
  236. package/dist/wu-schema.js +2 -2
  237. package/dist/wu-schema.js.map +1 -1
  238. package/dist/wu-spawn-helpers.d.ts.map +1 -1
  239. package/dist/wu-spawn-helpers.js +3 -2
  240. package/dist/wu-spawn-helpers.js.map +1 -1
  241. package/dist/wu-spawn.js +5 -5
  242. package/dist/wu-spawn.js.map +1 -1
  243. package/dist/wu-state-store.d.ts.map +1 -1
  244. package/dist/wu-state-store.js +20 -19
  245. package/dist/wu-state-store.js.map +1 -1
  246. package/dist/wu-status-transition.d.ts.map +1 -1
  247. package/dist/wu-status-transition.js +3 -26
  248. package/dist/wu-status-transition.js.map +1 -1
  249. package/dist/wu-status-updater.js +1 -1
  250. package/dist/wu-status-updater.js.map +1 -1
  251. package/dist/wu-statuses.d.ts +134 -0
  252. package/dist/wu-statuses.d.ts.map +1 -0
  253. package/dist/wu-statuses.js +149 -0
  254. package/dist/wu-statuses.js.map +1 -0
  255. package/dist/wu-transaction-collectors.d.ts.map +1 -1
  256. package/dist/wu-transaction-collectors.js +6 -3
  257. package/dist/wu-transaction-collectors.js.map +1 -1
  258. package/dist/wu-transaction.d.ts.map +1 -1
  259. package/dist/wu-transaction.js +1 -1
  260. package/dist/wu-transaction.js.map +1 -1
  261. package/dist/wu-ui-constants.d.ts +235 -0
  262. package/dist/wu-ui-constants.d.ts.map +1 -0
  263. package/dist/wu-ui-constants.js +235 -0
  264. package/dist/wu-ui-constants.js.map +1 -0
  265. package/dist/wu-validator.d.ts.map +1 -1
  266. package/dist/wu-validator.js +2 -1
  267. package/dist/wu-validator.js.map +1 -1
  268. package/dist/wu-yaml.js +1 -1
  269. package/dist/wu-yaml.js.map +1 -1
  270. package/package.json +80 -4
@@ -1,1958 +1,35 @@
1
1
  /**
2
- * Work Unit Constants
2
+ * Work Unit Constants - Barrel Re-export
3
3
  *
4
- * Centralized constants for wu- scripts to ensure consistency and DRY compliance.
5
- * Single source of truth for magic strings, section headings, and patterns.
4
+ * WU-1549: This file was decomposed from a 2,300+ line monolith into
5
+ * domain-specific modules. It now serves as a backward-compatible barrel
6
+ * re-exporting all constants from their domain modules.
6
7
  *
7
- * Part of WU-1214: Extract hardcoded strings to wu-constants.ts
8
- * Part of WU-1240: Consolidated toKebab using change-case library
8
+ * Domain modules:
9
+ * - wu-statuses.ts: WU status values, groups, exposure types, claimed modes
10
+ * - wu-git-constants.ts: Git branch names, remotes, refs, flags, commands
11
+ * - wu-paths-constants.ts: LumenFlow paths, file system, PHI config
12
+ * - wu-cli-constants.ts: CLI flags, gates, tooling, process constants
13
+ * - wu-ui-constants.ts: Display, formatting, UI, box drawing
14
+ * - wu-domain-constants.ts: Patterns, commit formats, defaults, safety tests
15
+ * - wu-context-constants.ts: Context validation, hooks, derived types
9
16
  *
10
17
  * @see {@link packages/@lumenflow/cli/src/wu-done.ts} - Primary consumer
11
18
  * @see {@link packages/@lumenflow/cli/src/wu-claim.ts} - Branch/worktree creation
12
- * @see {@link packages/@lumenflow/cli/src/lib/wu-schema.ts} - PLACEHOLDER_SENTINEL (already centralized)
13
- */
14
- import path from 'node:path';
15
- import { tmpdir } from 'node:os';
16
- import { kebabCase } from 'change-case';
17
- /**
18
- * Git branch names
19
- */
20
- export const BRANCHES = {
21
- MAIN: 'main',
22
- MASTER: 'master', // Legacy default branch name (defensive check)
23
- /** Temporary branch prefix for micro-worktree operations */
24
- TEMP_PREFIX: 'tmp/',
25
- };
26
- /**
27
- * Git remote names
28
- *
29
- * WU-1302: Centralized to eliminate hardcoded 'origin' strings
30
- */
31
- export const REMOTES = {
32
- ORIGIN: 'origin',
33
- };
34
- /**
35
- * Git ref construction helpers
36
- *
37
- * Centralized to eliminate hardcoded 'origin/main' strings
38
- */
39
- export const GIT_REFS = {
40
- /** Construct remote ref like 'origin/main' */
41
- remote: (remoteName, branchName) => `${remoteName}/${branchName}`,
42
- /** Shortcut for origin/main */
43
- ORIGIN_MAIN: 'origin/main',
44
- /** Current HEAD ref */
45
- HEAD: 'HEAD',
46
- /** Upstream ref */
47
- UPSTREAM: '@{u}',
48
- /** Range of upstream..HEAD */
49
- UPSTREAM_RANGE: '@{u}..HEAD',
50
- /** Fetch head ref */
51
- FETCH_HEAD: 'FETCH_HEAD',
52
- };
53
- /**
54
- * WU status values
55
- *
56
- * Centralized status strings to avoid magic strings in wu-* scripts.
57
- * Includes both canonical statuses and legacy variants found in YAML files.
58
- */
59
- export const WU_STATUS = {
60
- // Unclaimed statuses (not yet entered state machine)
61
- // WU-1374: Legacy backlog status value
62
- TODO: 'todo',
63
- READY: 'ready', // Canonical unclaimed status
64
- BACKLOG: 'backlog', // Legacy variant of ready
65
- // Active statuses (in state machine)
66
- IN_PROGRESS: 'in_progress',
67
- BLOCKED: 'blocked',
68
- // Terminal statuses (work finished, no further transitions)
69
- DONE: 'done', // Canonical terminal status
70
- COMPLETED: 'completed', // Legacy variant of done
71
- CANCELLED: 'cancelled',
72
- ABANDONED: 'abandoned',
73
- DEFERRED: 'deferred',
74
- CLOSED: 'closed',
75
- SUPERSEDED: 'superseded',
76
- };
77
- /**
78
- * WU status groups for state management (WU-1742)
79
- *
80
- * Used by state-bootstrap.ts to categorize YAML statuses.
81
- */
82
- export const WU_STATUS_GROUPS = {
83
- /** Statuses representing unclaimed work (not tracked in state store) */
84
- UNCLAIMED: [WU_STATUS.READY, WU_STATUS.TODO, WU_STATUS.BACKLOG],
85
- /** Terminal statuses (all map to 'done' in state store) */
86
- TERMINAL: [
87
- WU_STATUS.DONE,
88
- WU_STATUS.COMPLETED,
89
- WU_STATUS.CANCELLED,
90
- WU_STATUS.ABANDONED,
91
- WU_STATUS.DEFERRED,
92
- WU_STATUS.CLOSED,
93
- WU_STATUS.SUPERSEDED,
94
- ],
95
- };
96
- /**
97
- * WU claimed workspace modes
98
- *
99
- * Centralized workspace mode strings for wu:claim operations.
100
- */
101
- export const CLAIMED_MODES = {
102
- /** Standard worktree mode (isolated worktree per WU) */
103
- WORKTREE: 'worktree',
104
- /** Branch-only mode (no worktree, direct branch work) */
105
- BRANCH_ONLY: 'branch-only',
106
- /** Worktree PR mode (worktree with manual PR workflow) */
107
- WORKTREE_PR: 'worktree-pr',
108
- /** Branch PR mode (no worktree, PR-based completion for cloud agents) */
109
- BRANCH_PR: 'branch-pr',
110
- };
111
- /**
112
- * Agent incident severity levels
113
- *
114
- * Centralized severity strings for agent incident reporting.
115
- */
116
- export const INCIDENT_SEVERITY = {
117
- BLOCKER: 'blocker',
118
- MAJOR: 'major',
119
- MINOR: 'minor',
120
- INFO: 'info',
121
- };
122
- // Note: PATHS object removed in WU-1240 - use WU_PATHS from wu-paths.ts instead
123
- /**
124
- * Backlog section headings (with emojis)
125
- *
126
- * These match the frontmatter config in backlog.md
127
- */
128
- export const BACKLOG_SECTIONS = {
129
- READY: '## 🚀 Ready (pull from here)',
130
- IN_PROGRESS: '## 🔧 In progress',
131
- BLOCKED: '## ⛔ Blocked',
132
- DONE: '## ✅ Done',
133
- };
134
- /**
135
- * Backlog bullet format types (WU-1444)
136
- *
137
- * Used by BacklogManager to format list items in each section.
138
- * Each format produces a different markdown bullet style.
139
- */
140
- export const BACKLOG_BULLET_FORMAT = {
141
- /** Ready format: '- [ ] [WU-ID — Title](link)' */
142
- READY: 'ready',
143
- /** Progress format: '- [WU-ID — Title](link)' */
144
- PROGRESS: 'progress',
145
- /** Blocked format: '- [ ] [WU-ID — Title](link) — Reason' */
146
- BLOCKED: 'blocked',
147
- /** Done format: '- [x] [WU-ID — Title](link) (YYYY-MM-DD)' */
148
- DONE: 'done',
149
- };
150
- /**
151
- * Status.md section headings (simpler format)
152
- */
153
- export const STATUS_SECTIONS = {
154
- IN_PROGRESS: '## In Progress',
155
- BLOCKED: '## Blocked',
156
- COMPLETED: '## Completed',
157
- };
158
- /**
159
- * Regex patterns for WU operations
160
- *
161
- * Note: WU_ID pattern is also in wu-schema.ts for Zod validation
162
- */
163
- export const PATTERNS = {
164
- /** WU identifier format: WU-123 */
165
- WU_ID: /^WU-\d+$/,
166
- /** Extract WU ID from text: captures "WU-123" */
167
- WU_ID_EXTRACT: /WU-\d+/,
168
- /**
169
- * Extract WU ID from worktree paths (case-insensitive)
170
- *
171
- * WU-1090: Worktree names use lowercase like 'framework-core-wu-1090'
172
- * This pattern matches both 'WU-123' and 'wu-123' to support
173
- * extracting WU IDs from worktree paths.
174
- */
175
- WU_ID_EXTRACT_CI: /wu-\d+/i,
176
- /** Lane branch format: lane/<lane-kebab>/wu-<id> */
177
- LANE_BRANCH: /^lane\/[\w-]+\/wu-\d+$/,
178
- /** Worktree path format: worktrees/<lane-kebab>-wu-<id> */
179
- WORKTREE_PATH: /^worktrees\/[\w-]+-wu-\d+$/,
180
- };
181
- /**
182
- * Commit message formats
183
- *
184
- * These are functions that generate properly formatted commit messages
185
- */
186
- export const COMMIT_FORMATS = {
187
- /**
188
- * wu:claim commit message
189
- * @param {string} id - WU ID (e.g., 'wu-123')
190
- * @param {string} laneKebab - Lane in kebab-case (e.g., 'operations-tooling')
191
- * @returns {string} Commit message
192
- */
193
- CLAIM: (id, laneKebab) => `wu(${id}): claim for ${laneKebab} lane`,
194
- /**
195
- * wu:done commit message
196
- * @param {string} id - WU ID (e.g., 'wu-123')
197
- * @param {string} title - WU title (will be truncated if needed)
198
- * @returns {string} Commit message
199
- */
200
- DONE: (id, title) => `wu(${id}): done - ${title}`,
201
- /**
202
- * wu:create commit message
203
- * @param {string} id - WU ID (e.g., 'wu-123')
204
- * @param {string} title - WU title (will be truncated if needed)
205
- * @returns {string} Commit message
206
- */
207
- CREATE: (id, title) => `docs: create ${id.toLowerCase()} for ${title}`,
208
- /**
209
- * wu:edit commit message (for ready WUs via micro-worktree)
210
- * @param {string} id - WU ID (e.g., 'wu-123')
211
- * @returns {string} Commit message
212
- */
213
- EDIT: (id) => `docs: edit ${id.toLowerCase()} spec`,
214
- /**
215
- * wu:edit spec update commit message (for in_progress WUs in active worktree)
216
- * WU-1365: Worktree-aware editing applies edits directly in the worktree
217
- * @param {string} id - WU ID (e.g., 'wu-123')
218
- * @returns {string} Commit message
219
- */
220
- SPEC_UPDATE: (id) => `wu(${id.toLowerCase()}): spec update`,
221
- /**
222
- * wu:block commit message
223
- * @param {string} id - WU ID (e.g., 'wu-123')
224
- * @returns {string} Commit message
225
- */
226
- BLOCK: (id) => `wu(${id}): block`,
227
- /**
228
- * wu:unblock commit message
229
- * @param {string} id - WU ID (e.g., 'wu-123')
230
- * @returns {string} Commit message
231
- */
232
- UNBLOCK: (id) => `wu(${id}): unblock`,
233
- /**
234
- * wu:repair commit message
235
- * @param {string} id - WU ID (e.g., 'wu-123')
236
- * @returns {string} Commit message
237
- */
238
- REPAIR: (id) => `fix(${id}): repair state inconsistency`,
239
- /**
240
- * Rebase artifact cleanup commit message
241
- * WU-1371: Used when rebasing brings in completion artifacts from main
242
- * @param {string} id - WU ID (e.g., 'wu-123')
243
- * @returns {string} Commit message
244
- */
245
- REBASE_ARTIFACT_CLEANUP: (id) => `chore(${id.toLowerCase()}): remove rebased completion artifacts`,
246
- /**
247
- * Backlog repair commit message
248
- * WU-1506: Used when backlog invariant repair removes duplicates after rebase
249
- * @param {string} id - WU ID (e.g., 'wu-123')
250
- * @returns {string} Commit message
251
- */
252
- BACKLOG_REPAIR: (id) => `chore(repair): repair backlog duplicates for ${id.toLowerCase()}`,
253
- };
254
- /**
255
- * Log prefixes for wu- scripts
256
- *
257
- * Consistent prefixes for console output
258
- */
259
- export const LOG_PREFIX = {
260
- DONE: '[wu-done]',
261
- CLAIM: '[wu-claim]',
262
- CREATE: '[wu:create]',
263
- EDIT: '[wu:edit]',
264
- DELETE: '[wu:delete]',
265
- BLOCK: '[wu-block]',
266
- UNBLOCK: '[wu-unblock]',
267
- UNLOCK_LANE: '[wu-unlock-lane]',
268
- CLEANUP: '[wu-cleanup]',
269
- PRUNE: '[wu-prune]',
270
- REPAIR: '[wu:repair]',
271
- CONSISTENCY: '[wu-consistency]',
272
- PREFLIGHT: '[wu-preflight]',
273
- INITIATIVE_PLAN: '[initiative:plan]',
274
- PLAN_CREATE: '[plan:create]',
275
- PLAN_LINK: '[plan:link]',
276
- PLAN_EDIT: '[plan:edit]',
277
- PLAN_PROMOTE: '[plan:promote]',
278
- };
279
- /**
280
- * Consistency check types (WU-1276)
281
- *
282
- * Layer 2 defense-in-depth: detect and repair WU state inconsistencies
283
- */
284
- export const CONSISTENCY_TYPES = {
285
- /** WU YAML has status 'done' but WU appears in status.md In Progress section */
286
- YAML_DONE_STATUS_IN_PROGRESS: 'YAML_DONE_STATUS_IN_PROGRESS',
287
- /** WU appears in both Done AND In Progress sections of backlog.md */
288
- BACKLOG_DUAL_SECTION: 'BACKLOG_DUAL_SECTION',
289
- /** WU YAML has status 'done' but no stamp file exists */
290
- YAML_DONE_NO_STAMP: 'YAML_DONE_NO_STAMP',
291
- /** WU has status 'done' but still has an associated worktree */
292
- ORPHAN_WORKTREE_DONE: 'ORPHAN_WORKTREE_DONE',
293
- /** Stamp file exists but WU YAML status is not 'done' (partial wu:done failure) */
294
- STAMP_EXISTS_YAML_NOT_DONE: 'STAMP_EXISTS_YAML_NOT_DONE',
295
- /** WU is claimed but its worktree directory is missing */
296
- MISSING_WORKTREE_CLAIMED: 'MISSING_WORKTREE_CLAIMED',
297
- };
298
- /**
299
- * Consistency check messages
300
- */
301
- export const CONSISTENCY_MESSAGES = {
302
- MISSING_WORKTREE_CLAIMED: (id, status, worktreePath) => `WU ${id} is '${status}' but worktree path is missing (${worktreePath})`,
303
- MISSING_WORKTREE_CLAIMED_REPAIR: 'Recover worktree or re-claim WU',
304
- };
305
- /**
306
- * Worktree warning messages
307
- */
308
- export const WORKTREE_WARNINGS = {
309
- MISSING_TRACKED_HEADER: 'Tracked worktrees missing on disk (possible manual deletion):',
310
- MISSING_TRACKED_LINE: (worktreePath) => `Missing: ${worktreePath}`,
311
- };
312
- /**
313
- * File system constants
314
- *
315
- * WU-923: Centralized to eliminate hardcoded strings
316
- */
317
- export const FILE_SYSTEM = {
318
- /** Standard file encoding */
319
- ENCODING: 'utf8',
320
- /** UTF-8 encoding (alias for compatibility) */
321
- UTF8: 'utf8',
322
- };
323
- /**
324
- * Build artifact cleanup globs
325
- *
326
- * Centralized glob patterns for worktree artifact cleanup.
327
- */
328
- export const BUILD_ARTIFACT_GLOBS = {
329
- /** Common dist directories inside worktrees */
330
- DIST_DIRS: [
331
- 'packages/*/dist',
332
- 'packages/**/dist',
333
- 'apps/*/dist',
334
- 'apps/**/dist',
335
- 'tools/*/dist',
336
- 'tools/**/dist',
337
- ],
338
- /** TypeScript build info files */
339
- TSBUILDINFO_FILES: ['**/*.tsbuildinfo'],
340
- };
341
- /**
342
- * Build artifact cleanup ignore patterns
343
- *
344
- * Centralized ignore globs for artifact cleanup.
345
- */
346
- export const BUILD_ARTIFACT_IGNORES = ['**/node_modules/**', '**/.git/**', '**/.turbo/**'];
347
- /**
348
- * Process stdio constants
349
- *
350
- * Standard values for child_process execSync stdio option.
351
- */
352
- export const STDIO = {
353
- /** Pipe stdout/stderr (capture output) */
354
- PIPE: 'pipe',
355
- /** Inherit stdio from parent process */
356
- INHERIT: 'inherit',
357
- /** Ignore stdio (silent execution) */
358
- IGNORE: 'ignore',
359
- };
360
- /**
361
- * Configuration file paths
362
- *
363
- * WU-923: Centralized config file names
364
- */
365
- export const CONFIG_FILES = {
366
- /** LumenFlow main config */
367
- LUMENFLOW_CONFIG: '.lumenflow.config.yaml',
368
- /** Lane inference taxonomy */
369
- LANE_INFERENCE: '.lumenflow.lane-inference.yaml',
370
- };
371
- /**
372
- * Micro-worktree operation identifiers
373
- *
374
- * WU-923: Centralized operation names for withMicroWorktree()
375
- */
376
- export const MICRO_WORKTREE_OPERATIONS = {
377
- WU_CREATE: 'wu-create',
378
- WU_EDIT: 'wu-edit',
379
- WU_DELETE: 'wu-delete', // WU-1809: Safe WU deletion
380
- WU_DONE: 'wu-done',
381
- WU_BLOCK: 'wu-block',
382
- WU_UNBLOCK: 'wu-unblock',
383
- WU_CLAIM: 'wu-claim',
384
- ORPHAN_REPAIR: 'orphan-repair', // WU-1437: Pre-claim orphan WU repair
385
- INITIATIVE_EDIT: 'initiative-edit', // WU-1451: Initiative edit operation
386
- INITIATIVE_BULK_ASSIGN: 'initiative-bulk-assign', // WU-2553: Bulk WU assignment
387
- };
388
- /**
389
- * Telemetry step identifiers
390
- *
391
- * WU-1584: Centralized telemetry step names to eliminate string literals.
392
- */
393
- export const TELEMETRY_STEPS = {
394
- GATES: 'gates',
395
- /** WU-1467: COS_GATES removed -- was a stub (exit 0), not an authoritative step */
396
- PARALLEL_DETECTION: 'parallel_detection',
397
- PARALLEL_AUTO_REBASE: 'parallel_auto_rebase',
398
- };
399
- /**
400
- * WU-1747: Skip gates reason constants
401
- */
402
- export const SKIP_GATES_REASONS = {
403
- CHECKPOINT_VALID: 'checkpoint_valid',
404
- };
405
- /**
406
- * WU-1747: Checkpoint-related log messages
407
- */
408
- export const CHECKPOINT_MESSAGES = {
409
- SKIPPING_GATES_VALID: 'Skipping gates - valid checkpoint found',
410
- CHECKPOINT_LABEL: 'Checkpoint',
411
- GATES_PASSED_AT: 'Gates passed at',
412
- COULD_NOT_CREATE: 'Could not create WU-1747 checkpoint',
413
- };
414
- /**
415
- * Default values
416
- */
417
- export const DEFAULTS = {
418
- /** Default worktrees directory */
419
- WORKTREES_DIR: 'worktrees',
420
- /** Maximum commit subject length (commitlint default) */
421
- MAX_COMMIT_SUBJECT: 100,
422
- /** Parent directory traversal depth from tools/lib to project root */
423
- PROJECT_ROOT_DEPTH: 2,
424
- /**
425
- * Default email domain for username -> email conversion
426
- * WU-1068: Made configurable, no longer hardcoded to patientpath.co.uk
427
- * @see user-normalizer.ts - Infers from git config first
428
- */
429
- EMAIL_DOMAIN: 'example.com',
430
- };
431
- /**
432
- * Process argv indices (WU-1068)
433
- *
434
- * Centralized indices for process.argv access to eliminate magic numbers.
435
- * In Node.js: argv[0] = node, argv[1] = script, argv[2+] = args
436
- */
437
- export const ARGV_INDICES = {
438
- /** Node executable path */
439
- NODE: 0,
440
- /** Script path */
441
- SCRIPT: 1,
442
- /** First user argument */
443
- FIRST_ARG: 2,
444
- /** Second user argument */
445
- SECOND_ARG: 3,
446
- };
447
- /**
448
- * Display limits for CLI output (WU-1068)
449
- *
450
- * Centralized limits for truncating display strings to avoid magic numbers.
451
- */
452
- export const DISPLAY_LIMITS = {
453
- /** Maximum items to show in lists before truncating */
454
- LIST_ITEMS: 5,
455
- /** Maximum items to show in short lists */
456
- SHORT_LIST: 3,
457
- /** Maximum characters for content preview */
458
- CONTENT_PREVIEW: 200,
459
- /** Maximum characters for short preview */
460
- SHORT_PREVIEW: 60,
461
- /** Maximum characters for title display */
462
- TITLE: 50,
463
- /** Maximum characters for truncated title */
464
- TRUNCATED_TITLE: 40,
465
- /** Maximum characters for command preview */
466
- CMD_PREVIEW: 60,
467
- /** Maximum lines to preview from files */
468
- FILE_LINES: 10,
469
- /** Maximum commits to show in lists */
470
- COMMITS: 50,
471
- /** Maximum overlaps to display */
472
- OVERLAPS: 3,
473
- };
474
- /**
475
- * YAML serialization options
476
- *
477
- * Centralized from duplicated { lineWidth: 100 } across wu-* scripts (WU-1256).
478
- * Use with yaml stringify() options.
479
- */
480
- export const YAML_OPTIONS = {
481
- /** Standard line width for YAML dump (100 chars) */
482
- LINE_WIDTH: 100,
483
- /** No line wrapping (-1 disables wrapping) */
484
- NO_WRAP: -1,
485
- };
486
- /**
487
- * UI display constants
488
- *
489
- * WU-1281: Centralized from hardcoded values in wu-done.ts
490
- */
491
- export const UI = {
492
- /** Width for error/info boxes in console output */
493
- ERROR_BOX_WIDTH: 70,
494
- /** Number of lines to show in status file preview */
495
- STATUS_PREVIEW_LINES: 5,
496
- };
497
- /**
498
- * Box drawing characters for console output
499
- *
500
- * Emergency fix (Session 2): Centralized to eliminate sonarjs/no-duplicate-string errors
501
- * Used for recovery dialogs and error boxes in wu-* scripts
502
- */
503
- export const BOX = {
504
- /** Top border: ╔══...══╗ (66 chars inside + corners = 68 total) */
505
- TOP: '╔══════════════════════════════════════════════════════════════════╗',
506
- /** Middle separator: ╠══...══╣ */
507
- MID: '╠══════════════════════════════════════════════════════════════════╣',
508
- /** Bottom border: ╚══...══╝ */
509
- BOT: '╚══════════════════════════════════════════════════════════════════╝',
510
- /** Side border for content lines */
511
- SIDE: '║',
512
- };
513
- /**
514
- * Cleanup guard constants
515
- */
516
- export const CLEANUP_GUARD = {
517
- REASONS: {
518
- UNCOMMITTED_CHANGES: 'UNCOMMITTED_CHANGES',
519
- UNPUSHED_COMMITS: 'UNPUSHED_COMMITS',
520
- STATUS_NOT_DONE: 'STATUS_NOT_DONE',
521
- MISSING_STAMP: 'MISSING_STAMP',
522
- PR_NOT_MERGED: 'PR_NOT_MERGED',
523
- },
524
- TITLES: {
525
- BLOCKED: 'CLEANUP BLOCKED',
526
- NEXT_STEPS: 'Next steps:',
527
- },
528
- MESSAGES: {
529
- UNCOMMITTED_CHANGES: 'Worktree has uncommitted changes. Refusing to delete.',
530
- UNPUSHED_COMMITS: 'Worktree has unpushed commits. Refusing to delete.',
531
- STATUS_NOT_DONE: 'WU YAML status is not done. Refusing to delete.',
532
- MISSING_STAMP: 'WU stamp is missing. Refusing to delete.',
533
- PR_NOT_MERGED: 'PR is not merged (or cannot be verified). Refusing to delete.',
534
- },
535
- /* eslint-disable sonarjs/no-duplicate-string -- Intentional: cleanup instructions repeated for each error type for readability */
536
- NEXT_STEPS: {
537
- DEFAULT: [
538
- { text: '1. Resolve the issue above', appendId: false },
539
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
540
- ],
541
- UNCOMMITTED_CHANGES: [
542
- { text: '1. Commit or stash changes in the worktree', appendId: false },
543
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
544
- ],
545
- UNPUSHED_COMMITS: [
546
- { text: '1. Push the lane branch to origin', appendId: false },
547
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
548
- ],
549
- STATUS_NOT_DONE: [
550
- {
551
- text: `1. Complete the WU with ${LOG_PREFIX.DONE} (creates stamp + done status)`,
552
- appendId: false,
553
- },
554
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
555
- ],
556
- MISSING_STAMP: [
557
- { text: '1. Run wu:done to create the stamp file', appendId: false },
558
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
559
- ],
560
- PR_NOT_MERGED: [
561
- { text: '1. Merge the PR in GitHub', appendId: false },
562
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
563
- ],
564
- },
565
- /* eslint-enable sonarjs/no-duplicate-string */
566
- PR_CHECK: {
567
- START: 'Verifying PR merge status...',
568
- RESULT: 'PR merge verification via',
569
- },
570
- };
571
- /**
572
- * Git display constants
573
- *
574
- * Emergency fix (Session 2): Centralized from hardcoded magic numbers
575
- * Used for display truncation of SHAs and session IDs
576
- */
577
- export const GIT = {
578
- /** Standard length for displaying short SHA hashes (e.g., "abc12345") */
579
- SHA_SHORT_LENGTH: 8,
580
- /** Max number of commits to inspect in git log lookbacks */
581
- LOG_MAX_COUNT: 50,
582
- };
583
- /**
584
- * Real git executable path - MUST bypass tools/shims to prevent recursion.
585
- *
586
- * CRITICAL: The git shim (tools/shims/git) calls functions that need to run git
587
- * commands. If those functions use 'git' (which resolves to the shim), we get
588
- * infinite recursion: shim → helper → git → shim → helper → git → ...
589
- *
590
- * With VS Code extensions making dozens of git calls per second, this causes
591
- * memory exhaustion within seconds → OOM crash → system reboot.
592
- *
593
- * P0 incident: 2025-12-10 server crash due to recursive fork bomb.
594
- *
595
- * @see tools/shims/git - The git shim that blocks destructive commands
596
- * @see tools/lib/wu-helpers.ts - Uses REAL_GIT to avoid recursion
597
- */
598
- export const REAL_GIT = '/usr/bin/git';
599
- /**
600
- * Git command flags
601
- *
602
- * Centralized git flag constants to eliminate hardcoded strings.
603
- * Used by git-adapter.ts and other git operation utilities.
604
- */
605
- export const GIT_FLAGS = {
606
- /** Show abbreviated ref names (for branch name resolution) */
607
- ABBREV_REF: '--abbrev-ref',
608
- /** Porcelain format (machine-readable output) */
609
- PORCELAIN: '--porcelain',
610
- /** Create new branch and switch to it */
611
- BRANCH: '-b',
612
- /** Force flag (long form) */
613
- FORCE: '--force',
614
- /** Force flag (short form) */
615
- FORCE_SHORT: '-f',
616
- /** Fast-forward only merge */
617
- FF_ONLY: '--ff-only',
618
- /** Rebase local commits on top of fetched branch */
619
- REBASE: '--rebase',
620
- /** Check ancestry without output (merge-base) */
621
- IS_ANCESTOR: '--is-ancestor',
622
- /** Set upstream tracking */
623
- UPSTREAM: '-u',
624
- /** Delete branch (safe - only if merged) */
625
- DELETE: '-d',
626
- /** Delete branch (force - even if not merged) */
627
- DELETE_FORCE: '-D',
628
- /** Delete remote branch flag (for git push --delete) */
629
- DELETE_REMOTE: '--delete',
630
- /** Hard reset flag */
631
- HARD: '--hard',
632
- /** Soft reset flag */
633
- SOFT: '--soft',
634
- /** fd flags for clean (force delete directories) */
635
- FD_SHORT: '-fd',
636
- /** df flags for clean (delete force directories) */
637
- DF_SHORT: '-df',
638
- /** No verify flag (skip pre-commit/commit-msg hooks) */
639
- NO_VERIFY: '--no-verify',
640
- /** No GPG sign flag (skip commit signing) */
641
- NO_GPG_SIGN: '--no-gpg-sign',
642
- /** One-line log format */
643
- ONELINE: '--oneline',
644
- /** List heads only (for ls-remote) */
645
- HEADS: '--heads',
646
- /** Path separator (separates git options from file paths) */
647
- PATH_SEPARATOR: '--',
648
- };
649
- /**
650
- * Git commands
651
- *
652
- * Centralized git command strings to eliminate hardcoded strings.
653
- * Used for direct git command execution via execSync/execa.
654
- */
655
- export const GIT_COMMANDS = {
656
- /** Git binary */
657
- GIT: 'git',
658
- /** Git reset command */
659
- RESET: 'reset',
660
- /** List tree objects (check file existence on branch) */
661
- LS_TREE: 'ls-tree',
662
- /** List remote references */
663
- LS_REMOTE: 'ls-remote',
664
- /** Push command */
665
- PUSH: 'push',
666
- /** Pull command */
667
- PULL: 'pull',
668
- /** Git diff command */
669
- DIFF: 'diff',
670
- /** Git log command */
671
- LOG: 'log',
672
- /** Git merge-base command */
673
- MERGE_BASE: 'merge-base',
674
- /** Git rev-parse command */
675
- REV_PARSE: 'rev-parse',
676
- /** Git diff flags */
677
- CACHED: '--cached',
678
- NAME_ONLY: '--name-only',
679
- DIFF_FILTER_ACM: '--diff-filter=ACM',
680
- };
681
- /**
682
- * Session display constants
683
- *
684
- * Emergency fix (Session 2): Centralized from hardcoded magic numbers
685
- */
686
- export const SESSION = {
687
- /** Standard length for displaying session ID prefix (e.g., "sess-123") */
688
- ID_DISPLAY_LENGTH: 8,
689
- };
690
- /**
691
- * Validation constants
692
- *
693
- * WU-1281: Centralized from local constants in validators
694
- */
695
- export const VALIDATION = {
696
- /** Minimum description length for WU spec completeness */
697
- MIN_DESCRIPTION_LENGTH: 50,
698
- };
699
- /**
700
- * Threshold constants for pre-flight checks
701
- *
702
- * WU-1302: Centralized to eliminate magic numbers
703
- * WU-1370: Added graduated drift thresholds for early warnings
704
- */
705
- export const THRESHOLDS = {
706
- /** Info threshold: commits behind main to suggest rebasing (WU-1370) */
707
- BRANCH_DRIFT_INFO: 10,
708
- /** Warning threshold: commits behind main where rebase is recommended (WU-1370) */
709
- BRANCH_DRIFT_WARNING: 15,
710
- /** Maximum commits behind main before requiring rebase (WU-755 pre-flight) */
711
- BRANCH_DRIFT_MAX: 20,
712
- };
713
- /**
714
- * WU type values
715
- *
716
- * WU-1281: Centralized from hardcoded strings in validators
717
- */
718
- export const WU_TYPES = {
719
- DOCUMENTATION: 'documentation',
720
- PROCESS: 'process',
721
- FEATURE: 'feature',
722
- TOOLING: 'tooling',
723
- BUG: 'bug',
724
- };
725
- /**
726
- * WU exposure values (WU-1998)
727
- *
728
- * Defines how a WU exposes its functionality to users.
729
- * Used to ensure backend features have corresponding UI coverage.
730
- *
731
- * @see {@link packages/@lumenflow/cli/src/lib/wu-schema.ts} - Schema validation
732
- * @see {@link packages/linters/wu-schema-linter.ts} - Linter validation
733
- */
734
- export const WU_EXPOSURE = {
735
- /** User-facing UI changes (pages, components, widgets) */
736
- UI: 'ui',
737
- /** API endpoints that are called by UI or external clients */
738
- API: 'api',
739
- /** Backend-only changes (no user visibility) */
740
- BACKEND_ONLY: 'backend-only',
741
- /** Documentation changes only */
742
- DOCUMENTATION: 'documentation',
743
- };
744
- /**
745
- * Array of valid exposure values for schema validation
746
- * Note: Defined as tuple for Zod enum compatibility
747
- */
748
- export const WU_EXPOSURE_VALUES = ['ui', 'api', 'backend-only', 'documentation'];
749
- /**
750
- * Test type keys
751
- *
752
- * WU-1281: Centralized from hardcoded keys in validators
753
- */
754
- export const TEST_TYPES = {
755
- UNIT: 'unit',
756
- E2E: 'e2e',
757
- MANUAL: 'manual',
758
- INTEGRATION: 'integration',
759
- };
760
- /**
761
- * Safety-critical test glob patterns
762
- *
763
- * WU-2242: Centralized list of glob patterns for safety tests that MUST exist.
764
- * Gates fail if any of these patterns find no matches.
765
- *
766
- * These patterns identify tests for:
767
- * - PHI (Protected Health Information) protection
768
- * - Escalation triggers
769
- * - Privacy detection
770
- * - Constitutional enforcement
771
- * - Safe prompt wrapping
772
- * - Crisis/emergency handling
773
- *
774
- * @type {string[]}
775
- */
776
- export const SAFETY_CRITICAL_TEST_GLOBS = Object.freeze([
777
- // PHI protection tests
778
- 'apps/web/src/**/*PHI*.test.{ts,tsx}',
779
- 'apps/web/src/**/*phi*.test.{ts,tsx}',
780
- // Escalation trigger tests
781
- 'apps/web/src/**/*escalation*.test.{ts,tsx}',
782
- 'apps/web/src/**/*Escalation*.test.{ts,tsx}',
783
- // Privacy detection tests
784
- 'apps/web/src/**/*privacy*.test.{ts,tsx}',
785
- 'apps/web/src/**/*Privacy*.test.{ts,tsx}',
786
- // Constitutional enforcer tests
787
- 'apps/web/src/**/*constitutional*.test.{ts,tsx}',
788
- 'apps/web/src/**/*Constitutional*.test.{ts,tsx}',
789
- // Safe prompt wrapper tests
790
- 'apps/web/src/**/*safePrompt*.test.{ts,tsx}',
791
- 'apps/web/src/**/*SafePrompt*.test.{ts,tsx}',
792
- // Crisis/emergency handling tests
793
- 'apps/web/src/**/*crisis*.test.{ts,tsx}',
794
- 'apps/web/src/**/*Crisis*.test.{ts,tsx}',
795
- ]);
796
- /**
797
- * Emoji constants for consistent console output
798
- *
799
- * WU-1281: Centralized from hardcoded emojis across wu-* scripts
800
- */
801
- export const EMOJI = {
802
- SUCCESS: '✅',
803
- FAILURE: '❌',
804
- WARNING: '⚠️',
805
- INFO: 'ℹ️',
806
- BLOCKED: '⛔',
807
- ROCKET: '🚀',
808
- WRENCH: '🔧',
809
- TARGET: '🎯',
810
- MEMO: '📝',
811
- FOLDER: '📍',
812
- };
813
- /**
814
- * Default values for WU YAML fields
815
- *
816
- * WU-1337: Centralized defaults for auto-repair in schema validation
817
- * DRY principle: Single source of truth for optional field defaults
818
- *
819
- * Used by wu-schema.ts Zod transformations to provide sensible defaults
820
- * when agents omit optional fields, reducing validation errors.
821
- */
822
- export const WU_DEFAULTS = {
823
- /** Default priority level (medium priority) */
824
- priority: 'P2',
825
- /** Default status for new WUs */
826
- status: 'ready',
827
- /** Default work type */
828
- type: 'feature',
829
- /** Default code paths (empty until populated) */
830
- code_paths: [],
831
- /** Default test structure (includes all test types) */
832
- tests: { manual: [], unit: [], integration: [], e2e: [] },
833
- /** Default artifacts (empty - wu:done adds stamp) */
834
- artifacts: [],
835
- /** Default dependencies (no blockers) */
836
- dependencies: [],
837
- /** Default risks (none identified) */
838
- risks: [],
839
- /** Default notes (empty string, not undefined) */
840
- notes: '',
841
- /** Default review requirement (agent-completed WUs) */
842
- requires_review: false,
843
- };
844
- /**
845
- * Lane-to-code_paths validation patterns (WU-1372)
846
- *
847
- * Advisory patterns to warn when a WU's lane doesn't match its code_paths.
848
- * Each lane parent can define paths to exclude (paths that shouldn't appear
849
- * for that lane) and paths that are exceptionally allowed.
850
- *
851
- * Validation is advisory only - never blocks wu:claim or wu:done.
852
- *
853
- * WU-1068: Removed hardcoded @patientpath references. These patterns
854
- * should be configured in .lumenflow.config.yaml per-project.
855
- *
856
- * @see {@link packages/@lumenflow/cli/src/lib/lane-validator.ts} - Validation logic
857
- */
858
- export const LANE_PATH_PATTERNS = {
859
- /**
860
- * Operations lane should not touch prompt-related paths.
861
- * These paths belong to the Intelligence lane.
862
- */
863
- Operations: {
864
- exclude: ['ai/prompts/**', 'apps/web/src/lib/prompts/**'],
865
- allowExceptions: [],
866
- },
867
- /**
868
- * Intelligence lane should not touch tooling paths.
869
- * Exception: tools/lib/prompt-* files are Intelligence-owned.
870
- */
871
- Intelligence: {
872
- exclude: ['tools/**'],
873
- allowExceptions: ['tools/lib/prompt-*', 'tools/prompts-eval/**'],
874
- },
875
- };
876
- /**
877
- * Process detection constants for background process warning (WU-1381)
878
- *
879
- * Used by process-detector.ts to identify processes that may interfere
880
- * with wu:done gates execution.
881
- */
882
- export const PROCESS_DETECTION = {
883
- /**
884
- * Process names that commonly interfere with gates execution.
885
- * These processes may:
886
- * - Write to stdout/stderr (causing mixed output)
887
- * - Hold file locks that may cause test failures
888
- * - Consume resources that affect gate performance
889
- */
890
- INTERFERING_NAMES: ['node', 'pnpm', 'npm', 'vitest', 'tsx', 'eslint', 'prettier', 'tsc', 'turbo'],
891
- /** Maximum characters to display for command in warnings */
892
- CMD_DISPLAY_LIMIT: 60,
893
- };
894
- /**
895
- * CLI argument flags
896
- *
897
- * Centralized command-line argument strings to eliminate hardcoded flags.
898
- * Used across wu-* scripts, gates, and validation tools.
899
- */
900
- export const CLI_FLAGS = {
901
- // Common flags
902
- DRY_RUN: '--dry-run',
903
- EXECUTE: '--execute',
904
- HELP: '--help',
905
- HELP_SHORT: '-h',
906
- VERBOSE: '--verbose',
907
- FIX: '--fix',
908
- JSON: '--json',
909
- FORCE: '--force',
910
- // Gate-specific flags
911
- DOCS_ONLY: '--docs-only',
912
- FULL_LINT: '--full-lint',
913
- FULL_TESTS: '--full-tests', // WU-1920: Force full test suite
914
- FULL_COVERAGE: '--full-coverage', // WU-2244: Force full coverage (deterministic)
915
- COVERAGE_MODE: '--coverage-mode=',
916
- // WU-specific flags
917
- WU: '--wu',
918
- ID: '--id',
919
- ALL: '--all',
920
- CHECK: '--check',
921
- TIER: '--tier',
922
- AGENT_TYPE: '--agent-type',
923
- DESCRIPTION: '--description',
924
- ACCEPTANCE: '--acceptance',
925
- VALIDATE: '--validate',
926
- REASON: '--reason',
927
- WEEK: '--week',
928
- SINCE: '--since',
929
- };
930
- /**
931
- * pnpm/npm command flags
932
- *
933
- * Centralized package manager flag strings.
934
- */
935
- export const PKG_FLAGS = {
936
- FILTER: '--filter',
937
- FROZEN_LOCKFILE: '--frozen-lockfile',
938
- /** WU-1527: Required for pnpm add at workspace root in monorepos */
939
- WORKSPACE_ROOT: '-w',
940
- SAVE_DEV: '--save-dev',
941
- SAVE_EXACT: '--save-exact',
942
- };
943
- /**
944
- * ESLint command flags
945
- *
946
- * Centralized ESLint CLI flag strings.
947
- */
948
- export const ESLINT_FLAGS = {
949
- MAX_WARNINGS: '--max-warnings',
950
- NO_WARN_IGNORED: '--no-warn-ignored',
951
- CACHE: '--cache',
952
- CACHE_STRATEGY: '--cache-strategy',
953
- CACHE_LOCATION: '--cache-location',
954
- PASS_ON_UNPRUNED: '--pass-on-unpruned-suppressions',
955
- };
956
- /**
957
- * pnpm script names
958
- *
959
- * Centralized script names for package.json commands.
960
- */
961
- export const SCRIPTS = {
962
- LINT: 'lint',
963
- TEST: 'test',
964
- TEST_UNIT: 'test:unit',
965
- BUILD: 'build',
966
- FORMAT: 'format',
967
- FORMAT_CHECK: 'format:check',
968
- TYPECHECK: 'typecheck',
969
- DEV: 'dev',
970
- SPEC_LINTER: 'spec:linter',
971
- /** WU-1467: Stub script -- not an enforced gate. Retained for script surface only. */
972
- PROMPTS_LINT: 'prompts:lint',
973
- RUN: 'run',
974
- GATES: 'gates',
975
- /** WU-1467: Stub script -- not an enforced gate. Retained for script surface only. */
976
- COS_GATES: 'cos:gates',
977
- PRETTIER: 'prettier',
978
- /** WU-1467: Root script surface for tasks:validate (delegates to wu:validate --all) */
979
- TASKS_VALIDATE: 'tasks:validate',
980
- };
981
- /**
982
- * Gate names for quality gates
983
- *
984
- * Centralized gate identifiers for gates.ts and telemetry.
985
- */
986
- export const GATE_NAMES = {
987
- /** WU-2252: Invariants check (runs first, non-bypassable) */
988
- INVARIANTS: 'invariants',
989
- FORMAT_CHECK: 'format:check',
990
- SPEC_LINTER: 'spec:linter',
991
- /** WU-1467: PROMPTS_LINT removed -- was a stub (exit 0), not an authoritative gate */
992
- BACKLOG_SYNC: 'backlog-sync',
993
- SUPABASE_DOCS_LINTER: 'supabase-docs:linter',
994
- LINT: 'lint',
995
- TYPECHECK: 'typecheck',
996
- TEST: 'test',
997
- COVERAGE: 'coverage',
998
- /** WU-2062: Safety-critical tests (always run) */
999
- SAFETY_CRITICAL_TEST: 'safety-critical-test',
1000
- /** WU-2062: Integration tests (for high-risk changes) */
1001
- INTEGRATION_TEST: 'integration-test',
1002
- /** WU-2315: System map validation (warn-only until orphan docs are indexed) */
1003
- SYSTEM_MAP_VALIDATE: 'system-map:validate',
1004
- /** WU-1191: Lane health check (overlap detection) */
1005
- LANE_HEALTH: 'lane-health',
1006
- /** WU-1315: Onboarding smoke test (init + wu:create validation) */
1007
- ONBOARDING_SMOKE_TEST: 'onboarding-smoke-test',
1008
- };
1009
- /**
1010
- * Gate command sentinels (special values for non-shell commands)
1011
- *
1012
- * These are not shell commands but trigger special handling in gates.ts.
1013
- */
1014
- export const GATE_COMMANDS = {
1015
- /** WU-2252: Triggers invariants check */
1016
- INVARIANTS: 'invariants',
1017
- /** Triggers incremental lint (only changed files) */
1018
- INCREMENTAL: 'incremental',
1019
- /** Triggers incremental tests (only tests related to changed files) - WU-1920 */
1020
- INCREMENTAL_TEST: 'incremental-test',
1021
- /** Triggers coverage gate check */
1022
- COVERAGE_GATE: 'coverage-gate',
1023
- /** WU-2062: Triggers safety-critical tests (always run) */
1024
- SAFETY_CRITICAL_TEST: 'safety-critical-test',
1025
- /** WU-2062: Triggers tiered test execution based on risk */
1026
- TIERED_TEST: 'tiered-test',
1027
- /** WU-1315: Triggers onboarding smoke test */
1028
- ONBOARDING_SMOKE_TEST: 'onboarding-smoke-test',
1029
- };
1030
- /**
1031
- * CLI mode flags
1032
- *
1033
- * Command-line mode arguments.
1034
- */
1035
- export const CLI_MODES = {
1036
- LOCAL: '--mode=local',
1037
- };
1038
- /**
1039
- * Prettier command flags
1040
- *
1041
- * Centralized prettier CLI flag strings.
1042
- */
1043
- export const PRETTIER_FLAGS = {
1044
- WRITE: '--write',
1045
- };
1046
- /**
1047
- * Package manager commands
1048
- *
1049
- * Centralized pnpm command strings.
1050
- */
1051
- export const PKG_MANAGER = 'pnpm';
1052
- /**
1053
- * Package manager subcommands
1054
- *
1055
- * Centralized pnpm subcommand strings.
1056
- */
1057
- export const PKG_COMMANDS = {
1058
- INSTALL: 'install',
1059
- /** WU-1527: Used by lumenflow-upgrade and deps-add */
1060
- ADD: 'add',
1061
- REMOVE: 'remove',
1062
- };
1063
- /**
1064
- * Package names (monorepo workspaces)
1065
- *
1066
- * Centralized package names for --filter usage.
1067
- * WU-1068: Changed from @patientpath to @lumenflow for framework reusability.
1068
- * Project-specific packages should be configured in .lumenflow.config.yaml.
1069
- */
1070
- export const PACKAGES = {
1071
- WEB: 'web',
1072
- APPLICATION: '@lumenflow/core',
1073
- DOMAIN: '@lumenflow/core',
1074
- INFRASTRUCTURE: '@lumenflow/cli',
1075
- };
1076
- /**
1077
- * Directory paths within the monorepo
1078
- *
1079
- * Centralized directory path strings.
1080
- */
1081
- export const DIRECTORIES = {
1082
- APPS_WEB: 'apps/web/',
1083
- WORKTREES: 'worktrees/',
1084
- AI: 'ai/',
1085
- CLAUDE: '.claude/',
1086
- CLAUDE_HOOKS: '.claude/hooks/',
1087
- DOCS: 'docs/',
1088
- PACKAGES: 'packages/',
1089
- TOOLS: 'tools/',
1090
- MEMORY_BANK: 'memory-bank/',
1091
- WU_DIR: 'docs/04-operations/tasks/wu',
1092
- INITIATIVES_DIR: 'docs/04-operations/tasks/initiatives',
1093
- // WU-1814: Paths for active WU detection
1094
- BACKLOG_PATH: 'docs/04-operations/tasks/backlog.md',
1095
- STATUS_PATH: 'docs/04-operations/tasks/status.md',
1096
- };
1097
- /**
1098
- * Claude Code hook script constants (WU-1394)
1099
- *
1100
- * Centralized constants for Claude Code enforcement and recovery hooks.
1101
- * Used by enforcement-generator.ts, enforcement-sync.ts, and init.ts.
1102
- *
1103
- * @see packages/@lumenflow/cli/src/hooks/enforcement-generator.ts
1104
- * @see packages/@lumenflow/cli/src/hooks/enforcement-sync.ts
1105
- */
1106
- export const CLAUDE_HOOKS = {
1107
- /** Hook script filenames */
1108
- SCRIPTS: {
1109
- ENFORCE_WORKTREE: 'enforce-worktree.sh',
1110
- REQUIRE_WU: 'require-wu.sh',
1111
- WARN_INCOMPLETE: 'warn-incomplete.sh',
1112
- PRE_COMPACT_CHECKPOINT: 'pre-compact-checkpoint.sh',
1113
- SESSION_START_RECOVERY: 'session-start-recovery.sh',
1114
- /** WU-1471: Auto-checkpoint hook for PostToolUse and SubagentStop events */
1115
- AUTO_CHECKPOINT: 'auto-checkpoint.sh',
1116
- /** WU-1502: PostToolUse Bash hook for dirty-main warning */
1117
- WARN_DIRTY_MAIN: 'warn-dirty-main.sh',
1118
- },
1119
- /** Hook command path prefix (uses Claude Code's $CLAUDE_PROJECT_DIR variable) */
1120
- PATH_PREFIX: '$CLAUDE_PROJECT_DIR/.claude/hooks',
1121
- /** Hook matchers for settings.json */
1122
- MATCHERS: {
1123
- ALL: '.*',
1124
- WRITE_EDIT: 'Write|Edit',
1125
- COMPACT: 'compact',
1126
- RESUME: 'resume',
1127
- CLEAR: 'clear',
1128
- /** WU-1471: Matcher for SubagentStop hook event */
1129
- SUBAGENT_STOP: '.*',
1130
- /** WU-1502: Matcher for Bash tool PostToolUse */
1131
- BASH: 'Bash',
1132
- },
1133
- /** Template paths (relative to templates directory) */
1134
- TEMPLATES: {
1135
- SETTINGS: 'vendors/claude/.claude/settings.json.template',
1136
- PRE_COMPACT: 'vendors/claude/.claude/hooks/pre-compact-checkpoint.sh',
1137
- SESSION_START: 'vendors/claude/.claude/hooks/session-start-recovery.sh',
1138
- },
1139
- };
1140
- /** Build full hook command path from script name */
1141
- export const getHookCommand = (scriptName) => `${CLAUDE_HOOKS.PATH_PREFIX}/${scriptName}`;
1142
- /**
1143
- * ESLint cache strategy values
1144
- */
1145
- export const CACHE_STRATEGIES = {
1146
- CONTENT: 'content',
1147
- METADATA: 'metadata',
1148
- };
1149
- /**
1150
- * Process stdio modes
1151
- *
1152
- * Centralized stdio configuration values for child_process operations.
1153
- */
1154
- export const STDIO_MODES = {
1155
- /** Inherit stdio from parent process (shows output in console) */
1156
- INHERIT: 'inherit',
1157
- /** Pipe stdio to parent process (capture output) */
1158
- PIPE: 'pipe',
1159
- /** Ignore stdio (discard output) */
1160
- IGNORE: 'ignore',
1161
- };
1162
- /**
1163
- * Process exit codes
1164
- *
1165
- * Standard exit code values for CLI scripts.
1166
- */
1167
- export const EXIT_CODES = {
1168
- /** Success exit code */
1169
- SUCCESS: 0,
1170
- /** Generic error exit code */
1171
- ERROR: 1,
1172
- /** Fatal or distinct failure exit code */
1173
- FAILURE: 2,
1174
- };
1175
- /**
1176
- * Stream error codes
1177
- *
1178
- * WU-1233: Error codes for stream operations (stdout/stderr).
1179
- * Used by StreamErrorHandler for graceful pipe closure handling.
1180
- */
1181
- export const STREAM_ERRORS = {
1182
- /**
1183
- * EPIPE error code
1184
- *
1185
- * Occurs when writing to a pipe whose read end has been closed.
1186
- * This is normal behavior when CLI output is piped through head/tail.
1187
- * Unix convention: exit with code 0 on EPIPE (consumer got what it needed).
1188
- */
1189
- EPIPE: 'EPIPE',
1190
- };
1191
- /**
1192
- * ESLint command names
1193
- *
1194
- * Centralized ESLint command strings.
1195
- */
1196
- export const ESLINT_COMMANDS = {
1197
- /** ESLint CLI command */
1198
- ESLINT: 'eslint',
1199
- };
1200
- /**
1201
- * ESLint default values
1202
- *
1203
- * Default configuration values for ESLint operations.
1204
- */
1205
- export const ESLINT_DEFAULTS = {
1206
- /**
1207
- * Maximum allowed warnings
1208
- *
1209
- * WU-1866: Temporarily increased from 0 to 100 to unblock gates.
1210
- * There are ~82 pre-existing warnings that need proper fixes.
1211
- */
1212
- MAX_WARNINGS: '100',
1213
- };
1214
- /**
1215
- * Git command combinations
1216
- *
1217
- * Full git command strings for common operations.
1218
- */
1219
- export const GIT_COMMAND_STRINGS = {
1220
- /** Get diff of cached (staged) files */
1221
- DIFF_CACHED: 'git diff --cached',
1222
- /** Get names of cached files */
1223
- DIFF_CACHED_NAMES: 'git diff --cached --name-only',
1224
- /** Get names of cached files (added, copied, modified) */
1225
- DIFF_CACHED_ACM: 'git diff --cached --name-only --diff-filter=ACM',
1226
- /** Get cached diff with zero context (used for hook validation) */
1227
- DIFF_CACHED_UNIFIED_ZERO: 'git diff --cached -U0',
1228
- /** Get current branch name */
1229
- REV_PARSE_ABBREV_REF_HEAD: 'git rev-parse --abbrev-ref HEAD',
1230
- };
1231
- /**
1232
- * Path patterns for WU-related files
1233
- */
1234
- export const PATH_PATTERNS = {
1235
- /** Matches WU YAML paths in both legacy and current locations */
1236
- WU_YAML: /(?:memory-bank|docs\/04-operations)\/tasks\/wu\/(WU-\d+)\.ya?ml$/i,
1237
- /** Matches stamp file paths */
1238
- STAMP: /\.lumenflow\/stamps\/(WU-\d+)\.done$/i,
1239
- };
1240
- /**
1241
- * Common shell commands
1242
- *
1243
- * Centralized command names for child_process operations.
1244
- */
1245
- export const SHELL_COMMANDS = {
1246
- /** Which command (check if executable exists) */
1247
- WHICH: 'which',
1248
- /** Cat command (concatenate files) */
1249
- CAT: 'cat',
1250
- /** Node.js executable */
1251
- NODE: 'node',
1252
- };
1253
- /**
1254
- * External tool commands
1255
- *
1256
- * Centralized tool command names.
1257
- */
1258
- export const TOOLS = {
1259
- /** Gitleaks secret scanner */
1260
- GITLEAKS: 'gitleaks',
1261
- /** ESLint linter */
1262
- ESLINT: 'eslint',
1263
- /** Prettier formatter */
1264
- PRETTIER: 'prettier',
1265
- /** TypeScript compiler */
1266
- TSC: 'tsc',
1267
- };
1268
- /**
1269
- * Gitleaks command arguments
1270
- *
1271
- * Centralized gitleaks CLI arguments.
1272
- */
1273
- export const GITLEAKS_ARGS = {
1274
- /** Protect mode (scan staged files) */
1275
- PROTECT: 'protect',
1276
- /** Staged flag */
1277
- STAGED: '--staged',
1278
- /** Verbose output */
1279
- VERBOSE: '--verbose',
1280
- };
1281
- /**
1282
- * Prettier command arguments
1283
- *
1284
- * Centralized prettier CLI arguments.
1285
- */
1286
- export const PRETTIER_ARGS = {
1287
- /** Check formatting without writing */
1288
- CHECK: '--check',
1289
- /** List files with formatting differences */
1290
- LIST_DIFFERENT: '--list-different',
1291
- };
1292
- /**
1293
- * Audit command arguments
1294
- *
1295
- * Centralized pnpm audit CLI arguments.
1296
- */
1297
- export const AUDIT_ARGS = {
1298
- /** Audit subcommand */
1299
- AUDIT: 'audit',
1300
- /** Audit level flag */
1301
- AUDIT_LEVEL_MODERATE: '--audit-level=moderate',
1302
- /** Ignore registry errors */
1303
- IGNORE_REGISTRY_ERRORS: '--ignore-registry-errors',
1304
- /** Auto-fix flag */
1305
- FIX: '--fix',
1306
- };
1307
- /**
1308
- * Script file paths
1309
- *
1310
- * Centralized paths to validation scripts.
1311
- */
1312
- export const SCRIPT_PATHS = {
1313
- /** Prompt registry validation */
1314
- VALIDATE_PROMPT_REGISTRY: 'tools/validate-prompt-registry.js',
1315
- };
1316
- /**
1317
- * Known package names for vulnerability tracking
1318
- *
1319
- * Package identifiers used in dependency auditing.
1320
- */
1321
- export const KNOWN_PACKAGES = {
1322
- /** node-forge crypto library */
1323
- NODE_FORGE: 'node-forge',
1324
- /** Next.js framework */
1325
- NEXT: 'next',
1326
- /** jsPDF PDF generation library */
1327
- JSPDF: 'jspdf',
1328
- };
1329
- /**
1330
- * Error codes and messages
1331
- *
1332
- * Centralized error identifiers for consistency.
1333
- */
1334
- export const ERROR_CODES = {
1335
- /** Socket timeout error */
1336
- ERR_SOCKET_TIMEOUT: 'ERR_SOCKET_TIMEOUT',
1337
- /** Timeout error code */
1338
- ETIMEDOUT: 'ETIMEDOUT',
1339
- };
1340
- /**
1341
- * WU-1174: Lock directory name constant
1342
- *
1343
- * Defined separately so it can be used both in LUMENFLOW_PATHS.LOCK_DIR
1344
- * and for test isolation in cleanup-lock.ts/merge-lock.ts.
1345
- */
1346
- export const LOCK_DIR_NAME = '.lumenflow-locks';
1347
- /**
1348
- * LumenFlow directory paths
1349
- *
1350
- * Centralized paths for .lumenflow directory structure to eliminate hardcoded strings.
1351
- * Used by telemetry, agent-session, agent-incidents, memory, and commands-logger modules.
1352
- */
1353
- export const LUMENFLOW_PATHS = {
1354
- /** Base directory for all LumenFlow runtime data */
1355
- BASE: '.lumenflow',
1356
- /** WU state store directory */
1357
- STATE_DIR: '.lumenflow/state',
1358
- /** Stamp directory (WU completion markers) */
1359
- STAMPS_DIR: '.lumenflow/stamps',
1360
- /** Archive directory for old WU events (WU-1430) */
1361
- ARCHIVE_DIR: '.lumenflow/archive',
1362
- /** Merge lock file (runtime coordination, WU-1747) */
1363
- MERGE_LOCK: '.lumenflow/merge.lock',
1364
- /** Base telemetry directory */
1365
- TELEMETRY: '.lumenflow/telemetry',
1366
- /** Flow log file (WU flow events) */
1367
- FLOW_LOG: '.lumenflow/flow.log',
1368
- /** Agent sessions directory */
1369
- SESSIONS: '.lumenflow/sessions',
1370
- /** Agent incidents directory */
1371
- INCIDENTS: '.lumenflow/incidents',
1372
- /** Git commands log file */
1373
- COMMANDS_LOG: '.lumenflow/commands.log',
1374
- /** Memory layer directory */
1375
- MEMORY_DIR: '.lumenflow/memory',
1376
- /** Memory layer JSONL file */
1377
- MEMORY_JSONL: '.lumenflow/memory/memory.jsonl',
1378
- /** Audit log for tool calls */
1379
- AUDIT_LOG: '.lumenflow/telemetry/tools.ndjson',
1380
- /** Feedback drafts directory */
1381
- FEEDBACK_DRAFTS: '.lumenflow/feedback-drafts',
1382
- /** Feedback index file */
1383
- FEEDBACK_INDEX: '.lumenflow/feedback-index.ndjson',
1384
- /** Current session file */
1385
- SESSION_CURRENT: '.lumenflow/sessions/current.json',
1386
- /** WU events log */
1387
- WU_EVENTS: '.lumenflow/state/wu-events.jsonl',
1388
- /** Lock files directory (lane locks - persisted) */
1389
- LOCKS_DIR: '.lumenflow/locks',
1390
- /** Force bypass audit log */
1391
- FORCE_BYPASSES: '.lumenflow/force-bypasses.log',
1392
- /** Test baseline file for ratchet pattern (WU-1430) */
1393
- TEST_BASELINE: '.lumenflow/test-baseline.json',
1394
- /** Templates directory (WU-1430) */
1395
- TEMPLATES_DIR: '.lumenflow/templates',
1396
- /** Spawn prompt templates (WU-1430) */
1397
- SPAWN_PROMPT_DIR: '.lumenflow/templates/spawn-prompt',
1398
- /** Template manifest file (WU-1430) */
1399
- TEMPLATE_MANIFEST: '.lumenflow/templates/manifest.yaml',
1400
- /** Skills directory for agent skills (WU-1430) */
1401
- SKILLS_DIR: '.lumenflow/skills',
1402
- /** Agents directory for agent definitions (WU-1430) */
1403
- AGENTS_DIR: '.lumenflow/agents',
1404
- /** Methodology log for spawn telemetry (WU-1430) */
1405
- METHODOLOGY_LOG: '.lumenflow/telemetry/methodology.ndjson',
1406
- /** Prompt metrics cache (WU-1430) */
1407
- PROMPT_METRICS: '.lumenflow/telemetry/prompt-metrics.json',
1408
- /** Prompt lint results (WU-1430) */
1409
- PROMPT_LINT: '.lumenflow/telemetry/prompt-lint.ndjson',
1410
- /** Recovery markers directory (WU-1430) */
1411
- RECOVERY_DIR: '.lumenflow/recovery',
1412
- /** Checkpoints directory (WU-1430) */
1413
- CHECKPOINTS_DIR: '.lumenflow/checkpoints',
1414
- /** WU-1471: Hook counters directory for auto-checkpoint interval tracking */
1415
- HOOK_COUNTERS_DIR: '.lumenflow/state/hook-counters',
1416
- /** Cache directory under user home (WU-1430) */
1417
- HOME_CACHE: 'cache',
1418
- /**
1419
- * WU-1174: Runtime lock directory for merge/cleanup locks
1420
- *
1421
- * These locks are transient and should NOT be created in the main checkout
1422
- * because wu:done runs from main. Using os.tmpdir() ensures:
1423
- * 1. Locks don't pollute the git working tree
1424
- * 2. Locks work across processes on the same machine
1425
- * 3. No "Working tree is not clean" errors if process crashes
1426
- *
1427
- * Note: Lane locks still use LOCKS_DIR (.lumenflow/locks) because they need
1428
- * to persist across sessions and be visible to other agents.
1429
- */
1430
- LOCK_DIR: path.join(tmpdir(), LOCK_DIR_NAME),
1431
- };
1432
- /**
1433
- * File extensions
1434
- *
1435
- * Centralized file extension strings to avoid magic strings.
1436
- */
1437
- export const FILE_EXTENSIONS = {
1438
- /** Newline-delimited JSON format */
1439
- NDJSON: '.ndjson',
1440
- /** Markdown format */
1441
- MARKDOWN: '.md',
1442
- /** YAML format */
1443
- YAML: '.yaml',
1444
- /** Log format */
1445
- LOG: '.log',
1446
- /** Stamp files (completion markers) */
1447
- STAMP: '.done',
1448
- };
1449
- /**
1450
- * String formatting constants
1451
- *
1452
- * Centralized string literals for consistent formatting across scripts.
1453
- * Eliminates hardcoded '\n', ' ', etc. throughout the codebase.
1454
- */
1455
- export const STRING_LITERALS = {
1456
- /** Newline character */
1457
- NEWLINE: '\n',
1458
- /** Double newline (paragraph separator) */
1459
- DOUBLE_NEWLINE: '\n\n',
1460
- /** Space character */
1461
- SPACE: ' ',
1462
- /** Empty string */
1463
- EMPTY: '',
1464
- /** Tab character */
1465
- TAB: '\t',
1466
- /** Comma separator */
1467
- COMMA: ',',
1468
- /** Colon separator */
1469
- COLON: ':',
1470
- /** Dash/hyphen */
1471
- DASH: '-',
1472
- /** Forward slash */
1473
- SLASH: '/',
1474
- };
1475
- /**
1476
- * Path-related constants
1477
- *
1478
- * WU-1062: Centralized path literals for lumenflow-home and spec-branch operations.
1479
- */
1480
- export const PATH_LITERALS = {
1481
- /** Tilde prefix for home directory expansion (e.g., ~/path) */
1482
- TILDE_PREFIX: '~/',
1483
- /** Tilde character for home directory */
1484
- TILDE: '~',
1485
- /** Plan file suffix for WU plans */
1486
- PLAN_FILE_SUFFIX: '-plan.md',
1487
- /** Trailing slash regex pattern */
1488
- TRAILING_SLASH_REGEX: /\/+$/,
1489
- /** .lumenflow path prefix for internal path detection (WU-1430) */
1490
- LUMENFLOW_PREFIX: '.lumenflow/',
1491
- /** Current directory prefix for repo-internal paths (WU-1430) */
1492
- CURRENT_DIR_PREFIX: './',
1493
- };
1494
- /**
1495
- * Slice lengths for path operations
1496
- *
1497
- * WU-1062: Magic numbers extracted for path manipulation.
1498
- */
1499
- export const PATH_SLICE_LENGTHS = {
1500
- /** Length of '~/' prefix for tilde expansion */
1501
- TILDE_PREFIX_LENGTH: 2,
1502
- /** Length of '/' for leading slash removal */
1503
- LEADING_SLASH_LENGTH: 1,
1504
- };
1505
- /**
1506
- * Convert lane name to kebab-case using change-case library
1507
- *
1508
- * Provides null-safe wrapper around paramCase for lane naming.
1509
- * Handles sub-lanes with colon separator and special characters.
1510
- *
1511
- * @param {string|null|undefined} lane - Lane name (e.g., 'Operations: Tooling')
1512
- * @returns {string} Kebab-case lane (e.g., 'operations-tooling')
1513
- *
1514
- * @example
1515
- * toKebab('Operations: Tooling') // 'operations-tooling'
1516
- * toKebab('Core Systems') // 'core-systems'
1517
- * toKebab('Intelligence') // 'intelligence'
1518
- * toKebab(null) // ''
1519
- * toKebab(undefined) // ''
1520
- */
1521
- export function toKebab(lane) {
1522
- // Null safety: kebabCase throws on null/undefined
1523
- if (lane == null)
1524
- return '';
1525
- const normalized = String(lane).trim();
1526
- if (normalized === '')
1527
- return '';
1528
- return kebabCase(normalized);
1529
- }
1530
- /**
1531
- * Generate worktree path from lane and WU ID
1532
- *
1533
- * @param {string} lane - Lane name
1534
- * @param {string} id - WU ID
1535
- * @returns {string} Worktree path (e.g., 'worktrees/operations-tooling-wu-123')
1536
- */
1537
- export function getWorktreePath(lane, id) {
1538
- const laneKebab = toKebab(lane);
1539
- const idLower = id.toLowerCase();
1540
- return `${DEFAULTS.WORKTREES_DIR}/${laneKebab}-${idLower}`;
1541
- }
1542
- /**
1543
- * Generate lane branch name from lane and WU ID
1544
- *
1545
- * @param {string} lane - Lane name
1546
- * @param {string} id - WU ID
1547
- * @returns {string} Branch name (e.g., 'lane/operations-tooling/wu-123')
1548
- */
1549
- export function getLaneBranch(lane, id) {
1550
- const laneKebab = toKebab(lane);
1551
- const idLower = id.toLowerCase();
1552
- return `lane/${laneKebab}/${idLower}`;
1553
- }
1554
- // Note: getWuYamlPath and getStampPath removed in WU-1240
1555
- // Use WU_PATHS.WU(id) and WU_PATHS.STAMP(id) from wu-paths.ts instead
1556
- /**
1557
- * File tool constants (WU-1403)
1558
- *
1559
- * Centralized strings for file:read, file:write, file:edit tools.
1560
- * Prevents duplicate string literals and hardcoded magic values.
1561
- */
1562
- export const FILE_TOOLS = {
1563
- /** Tool name prefixes */
1564
- NAMES: {
1565
- READ: 'file:read',
1566
- WRITE: 'file:write',
1567
- EDIT: 'file:edit',
1568
- DELETE: 'file:delete',
1569
- },
1570
- /** Tool domain */
1571
- DOMAIN: 'file',
1572
- /** Permission levels */
1573
- PERMISSIONS: {
1574
- READ: 'read',
1575
- WRITE: 'write',
1576
- },
1577
- /** Worktree instruction templates (WU-1403: provides reusable instruction strings) */
1578
- WORKTREE_INSTRUCTIONS: {
1579
- CLAIM_COMMAND: 'pnpm wu:claim --id <wu-id> --lane "<lane>"',
1580
- CD_COMMAND: 'cd worktrees/<lane>-<wu-id>/',
1581
- DOC_REFERENCE: 'CLAUDE.md §2 (Worktree Discipline)',
1582
- },
1583
- };
1584
- /**
1585
- * PHI (Protected Health Information) error codes (WU-1404)
1586
- *
1587
- * Error codes for PHI detection in file tools.
1588
- * Used by file:write and file:edit to block PHI leakage.
1589
- *
1590
- * WU-1068: PHI scanning is healthcare-specific functionality.
1591
- * Enable via PHI_CONFIG.ENABLED flag or .lumenflow.config.yaml phi.enabled: true
1592
- */
1593
- export const PHI_ERRORS = {
1594
- /** PHI detected in content - write blocked */
1595
- PHI_DETECTED: 'PHI_DETECTED',
1596
- /** PHI override requested - audit logged */
1597
- PHI_OVERRIDE_ALLOWED: 'PHI_OVERRIDE_ALLOWED',
1598
- };
1599
- /**
1600
- * PHI scanning configuration (WU-1068)
1601
- *
1602
- * Controls whether PHI (Protected Health Information) scanning is enabled.
1603
- * This is healthcare-specific functionality (NHS numbers, UK postcodes)
1604
- * that should only be enabled for healthcare projects.
1605
- *
1606
- * Projects can enable via:
1607
- * 1. Setting PHI_CONFIG.ENABLED = true in code
1608
- * 2. Setting LUMENFLOW_PHI_ENABLED=1 environment variable
1609
- * 3. Adding phi.enabled: true to .lumenflow.config.yaml
1610
- */
1611
- export const PHI_CONFIG = {
1612
- /**
1613
- * Whether PHI scanning is enabled
1614
- * Default: false - projects must explicitly opt-in
1615
- */
1616
- ENABLED: process.env.LUMENFLOW_PHI_ENABLED === '1',
1617
- /**
1618
- * Whether to block on PHI detection (true) or just warn (false)
1619
- */
1620
- BLOCKING: process.env.LUMENFLOW_PHI_BLOCKING === '1',
1621
- };
1622
- /**
1623
- * Readiness summary UI constants (WU-1620)
1624
- *
1625
- * Constants for the readiness summary box displayed after wu:create and wu:edit.
1626
- * Provides visual feedback on whether WU is ready for wu:claim.
1627
- *
1628
- * @see tools/wu-create.ts - displayReadinessSummary()
1629
- * @see tools/wu-edit.ts - displayReadinessSummary()
1630
- */
1631
- export const READINESS_UI = {
1632
- /** Box width (inner content area) */
1633
- BOX_WIDTH: 50,
1634
- /** Box drawing characters */
1635
- BOX: {
1636
- TOP_LEFT: '┌',
1637
- TOP_RIGHT: '┐',
1638
- BOTTOM_LEFT: '└',
1639
- BOTTOM_RIGHT: '┘',
1640
- HORIZONTAL: '─',
1641
- VERTICAL: '│',
1642
- },
1643
- /** Status messages */
1644
- MESSAGES: {
1645
- READY_YES: '✅ Ready to claim: YES',
1646
- READY_NO: '⚠️ Ready to claim: NO',
1647
- MISSING_HEADER: 'Missing:',
1648
- BULLET: '•',
1649
- },
1650
- /** Error truncation length */
1651
- ERROR_MAX_LENGTH: 46,
1652
- ERROR_TRUNCATE_LENGTH: 43,
1653
- TRUNCATION_SUFFIX: '...',
1654
- /** Padding calculations (relative to BOX_WIDTH) */
1655
- PADDING: {
1656
- READY_YES: 27, // 50 - len("✅ Ready to claim: YES") - 1
1657
- READY_NO: 28, // 50 - len("⚠️ Ready to claim: NO") - 1
1658
- MISSING_HEADER: 41, // 50 - len("Missing:") - 1
1659
- ERROR_BULLET: 45, // 50 - len(" • ") - 1
1660
- },
1661
- };
1662
- /**
1663
- * Get project root directory from a module URL
1664
- *
1665
- * WU-923: Centralized path resolution to eliminate '../..' magic strings
1666
- *
1667
- * @param {string} moduleUrl - import.meta.url of the calling module
1668
- * @returns {string} Absolute path to project root
1669
- *
1670
- * @example
1671
- * import { getProjectRoot } from './lib/wu-constants.js';
1672
- * const projectRoot = getProjectRoot(import.meta.url);
1673
- */
1674
- export function getProjectRoot(moduleUrl) {
1675
- const { dirname } = path;
1676
- const currentDir = dirname(new URL(moduleUrl).pathname);
1677
- // Traverse up from tools/lib to project root
1678
- let root = currentDir;
1679
- for (let i = 0; i < DEFAULTS.PROJECT_ROOT_DEPTH; i++) {
1680
- root = dirname(root);
1681
- }
1682
- return root;
1683
- }
1684
- /**
1685
- * Discover safety-critical test files
1686
- *
1687
- * WU-2242: Scans for test files matching safety-critical patterns.
1688
- * Uses glob to find all matching files.
1689
- *
1690
- * @param {DiscoverSafetyTestsOptions} options - Discovery options
1691
- * @returns {Promise<string[]>} List of discovered test file paths
1692
- */
1693
- export async function discoverSafetyTests(options = {}) {
1694
- const { projectRoot = process.cwd() } = options;
1695
- const { glob } = await import('glob');
1696
- const foundFiles = [];
1697
- for (const pattern of SAFETY_CRITICAL_TEST_GLOBS) {
1698
- try {
1699
- const matches = await glob(pattern, {
1700
- cwd: projectRoot,
1701
- absolute: false,
1702
- });
1703
- foundFiles.push(...matches);
1704
- }
1705
- catch {
1706
- // Pattern may not match anything, that's fine
1707
- }
1708
- }
1709
- return [...new Set(foundFiles)]; // Deduplicate
1710
- }
1711
- /**
1712
- * Validate that required safety-critical tests exist
1713
- *
1714
- * WU-2242: Checks that each pattern category has at least one matching test file.
1715
- * Returns a validation result with missing patterns and found files.
1716
- *
1717
- * @param {DiscoverSafetyTestsOptions} options - Validation options
1718
- * @returns {Promise<{valid: boolean, missingTests: string[], foundTests: string[], error?: string}>}
1719
- */
1720
- export async function validateSafetyTestsExist(options = {}) {
1721
- const { projectRoot = process.cwd() } = options;
1722
- const { glob } = await import('glob');
1723
- const missingTests = [];
1724
- const foundTests = [];
1725
- // Group patterns by category (every 2 patterns form a category)
1726
- const categories = [
1727
- { name: 'PHI protection', patterns: SAFETY_CRITICAL_TEST_GLOBS.slice(0, 2) },
1728
- { name: 'Escalation', patterns: SAFETY_CRITICAL_TEST_GLOBS.slice(2, 4) },
1729
- { name: 'Privacy detection', patterns: SAFETY_CRITICAL_TEST_GLOBS.slice(4, 6) },
1730
- { name: 'Constitutional', patterns: SAFETY_CRITICAL_TEST_GLOBS.slice(6, 8) },
1731
- { name: 'Safe prompt wrapper', patterns: SAFETY_CRITICAL_TEST_GLOBS.slice(8, 10) },
1732
- { name: 'Crisis handling', patterns: SAFETY_CRITICAL_TEST_GLOBS.slice(10, 12) },
1733
- ];
1734
- for (const category of categories) {
1735
- let categoryHasTests = false;
1736
- for (const pattern of category.patterns) {
1737
- try {
1738
- const matches = await glob(pattern, {
1739
- cwd: projectRoot,
1740
- absolute: false,
1741
- });
1742
- if (matches.length > 0) {
1743
- categoryHasTests = true;
1744
- foundTests.push(...matches);
1745
- }
1746
- }
1747
- catch {
1748
- // Pattern error, treat as no matches
1749
- }
1750
- }
1751
- if (!categoryHasTests) {
1752
- missingTests.push(`${category.name}: ${category.patterns.join(', ')}`);
1753
- }
1754
- }
1755
- const valid = missingTests.length === 0;
1756
- return {
1757
- valid,
1758
- missingTests,
1759
- foundTests: [...new Set(foundTests)],
1760
- error: valid ? undefined : `Missing safety-critical tests: ${missingTests.join('; ')}`,
1761
- };
1762
- }
1763
- /**
1764
- * Context validation constants (WU-1090)
1765
- *
1766
- * Constants for the context-aware state machine for WU lifecycle commands.
1767
- * Supports unified context model, declarative command requirements,
1768
- * smart validation, and recovery paths.
1769
- */
1770
- export const CONTEXT_VALIDATION = {
1771
- /** Location types for WU operations */
1772
- LOCATION_TYPES: {
1773
- /** Main checkout (not a worktree) */
1774
- MAIN: 'main',
1775
- /** Inside a worktree */
1776
- WORKTREE: 'worktree',
1777
- /** Detached HEAD state */
1778
- DETACHED: 'detached',
1779
- /** Unknown location (not a git repo or error) */
1780
- UNKNOWN: 'unknown',
1781
- },
1782
- /** Validation error codes */
1783
- ERROR_CODES: {
1784
- /** Command run from wrong location type */
1785
- WRONG_LOCATION: 'WRONG_LOCATION',
1786
- /** Target WU does not exist */
1787
- WU_NOT_FOUND: 'WU_NOT_FOUND',
1788
- /** WU with this ID already exists */
1789
- WU_ALREADY_EXISTS: 'WU_ALREADY_EXISTS',
1790
- /** WU in unexpected status for command */
1791
- WRONG_WU_STATUS: 'WRONG_WU_STATUS',
1792
- /** Lane already has WU in progress */
1793
- LANE_OCCUPIED: 'LANE_OCCUPIED',
1794
- /** Worktree already exists for WU */
1795
- WORKTREE_EXISTS: 'WORKTREE_EXISTS',
1796
- /** Expected worktree not found */
1797
- WORKTREE_MISSING: 'WORKTREE_MISSING',
1798
- /** Gates haven't run or failed */
1799
- GATES_NOT_PASSED: 'GATES_NOT_PASSED',
1800
- /** Uncommitted changes exist */
1801
- DIRTY_GIT: 'DIRTY_GIT',
1802
- /** Cannot reach origin remote */
1803
- REMOTE_UNAVAILABLE: 'REMOTE_UNAVAILABLE',
1804
- /** YAML and state store disagree */
1805
- INCONSISTENT_STATE: 'INCONSISTENT_STATE',
1806
- },
1807
- /** Recovery action types */
1808
- RECOVERY_ACTIONS: {
1809
- /** Reconcile state and continue working (preserves work) */
1810
- RESUME: 'resume',
1811
- /** Discard worktree, reset WU to ready */
1812
- RESET: 'reset',
1813
- /** Remove all artifacts completely (requires --force) */
1814
- NUKE: 'nuke',
1815
- /** Remove leftover worktree (for done WUs) */
1816
- CLEANUP: 'cleanup',
1817
- },
1818
- /** Recovery issue codes */
1819
- RECOVERY_ISSUES: {
1820
- /** Worktree exists but WU status is "ready" */
1821
- PARTIAL_CLAIM: 'PARTIAL_CLAIM',
1822
- /** WU is "in_progress" but worktree does not exist */
1823
- ORPHAN_CLAIM: 'ORPHAN_CLAIM',
1824
- /** YAML status differs from state store */
1825
- INCONSISTENT_STATE: 'INCONSISTENT_STATE',
1826
- /** Branch exists but worktree does not */
1827
- ORPHAN_BRANCH: 'ORPHAN_BRANCH',
1828
- /** Lock file from different WU */
1829
- STALE_LOCK: 'STALE_LOCK',
1830
- /** WU is done but worktree was not cleaned up */
1831
- LEFTOVER_WORKTREE: 'LEFTOVER_WORKTREE',
1832
- },
1833
- /** Predicate severity levels */
1834
- SEVERITY: {
1835
- /** Blocks command execution */
1836
- ERROR: 'error',
1837
- /** Shows warning but allows execution */
1838
- WARNING: 'warning',
1839
- },
1840
- /** Performance thresholds */
1841
- THRESHOLDS: {
1842
- /** Max context computation time (ms) - acceptance criterion */
1843
- CONTEXT_COMPUTATION_MS: 100,
1844
- /** Max stale lock age (hours) */
1845
- STALE_LOCK_HOURS: 24,
1846
- },
1847
- /** Feature flag keys for .lumenflow.config.yaml */
1848
- FEATURE_FLAGS: {
1849
- /** Enable context-aware validation */
1850
- CONTEXT_VALIDATION: 'context_validation',
1851
- /** Validation behavior: 'off' | 'warn' | 'error' */
1852
- VALIDATION_MODE: 'validation_mode',
1853
- /** Show next steps after successful commands */
1854
- SHOW_NEXT_STEPS: 'show_next_steps',
1855
- /** Enable wu:recover command */
1856
- RECOVERY_COMMAND: 'recovery_command',
1857
- },
1858
- /** Validation modes */
1859
- VALIDATION_MODES: {
1860
- /** No validation (legacy behavior) */
1861
- OFF: 'off',
1862
- /** Show warnings but proceed */
1863
- WARN: 'warn',
1864
- /** Block on validation failures */
1865
- ERROR: 'error',
1866
- },
1867
- /** Command names for the registry */
1868
- COMMANDS: {
1869
- WU_CREATE: 'wu:create',
1870
- WU_CLAIM: 'wu:claim',
1871
- WU_PREP: 'wu:prep',
1872
- WU_DONE: 'wu:done',
1873
- WU_BLOCK: 'wu:block',
1874
- WU_UNBLOCK: 'wu:unblock',
1875
- WU_STATUS: 'wu:status',
1876
- WU_RECOVER: 'wu:recover',
1877
- GATES: 'gates',
1878
- },
1879
- };
1880
- /**
1881
- * Git hook error messages (WU-1357)
1882
- *
1883
- * Educational, structured messages for git hook blocks.
1884
- * Follows the "message bag" pattern: TITLE, WHY, ACTIONS, HELP, BYPASS.
1885
- *
1886
- * Design principles:
1887
- * - Explain WHY before showing WHAT to do
1888
- * - Provide multiple paths forward (not just one command)
1889
- * - Put emergency bypass LAST with clear warnings
1890
- * - Include help resources for learning
1891
- *
1892
- * @see .husky/hooks/pre-commit.mjs - Primary consumer
1893
- */
1894
- export const HOOK_MESSAGES = {
1895
- /**
1896
- * Main branch protection block message components
1897
- */
1898
- MAIN_BRANCH_BLOCK: {
1899
- /** Box drawing for visual structure */
1900
- BOX: {
1901
- TOP: '══════════════════════════════════════════════════════════════',
1902
- DIVIDER: '──────────────────────────────────────────────────────────────',
1903
- },
1904
- /** Title shown at the top */
1905
- TITLE: (branch) => `DIRECT COMMIT TO ${branch.toUpperCase()} BLOCKED`,
1906
- /** Educational explanation of WHY the block exists */
1907
- WHY: {
1908
- HEADER: 'WHY THIS HAPPENS',
1909
- LINES: [
1910
- 'LumenFlow protects main from direct commits to ensure:',
1911
- ' • All work is tracked in Work Units (WUs)',
1912
- ' • Changes can be reviewed and coordinated',
1913
- ' • Parallel work across lanes stays isolated',
1914
- ],
1915
- },
1916
- /** Action paths - multiple ways forward */
1917
- ACTIONS: {
1918
- HEADER: 'WHAT TO DO',
1919
- HAVE_WU: {
1920
- HEADER: '1. If you have a Work Unit to implement:',
1921
- COMMANDS: ['pnpm wu:claim --id WU-XXXX --lane "<Lane>"', 'cd worktrees/<lane>-wu-xxxx'],
1922
- NOTE: 'Then make your commits there',
1923
- },
1924
- NEED_WU: {
1925
- HEADER: '2. If you need to create a new Work Unit:',
1926
- COMMANDS: ['pnpm wu:create --lane "<Lane>" --title "Your task"'],
1927
- NOTE: 'This generates a WU ID, then claim it as above',
1928
- },
1929
- LIST_LANES: {
1930
- HEADER: '3. Not sure what lane to use?',
1931
- COMMANDS: ['pnpm wu:list-lanes'],
1932
- },
1933
- },
1934
- /** Help resources */
1935
- HELP: {
1936
- HEADER: 'NEED HELP?',
1937
- RESOURCES: [
1938
- '• Read: LUMENFLOW.md (workflow overview)',
1939
- '• Read: docs/04-operations/_frameworks/lumenflow/agent/onboarding/',
1940
- '• Run: pnpm wu:help',
1941
- ],
1942
- },
1943
- /** Emergency bypass (shown last, with warnings) */
1944
- BYPASS: {
1945
- HEADER: 'EMERGENCY BYPASS (logged, use sparingly)',
1946
- WARNING: 'Bypasses are audit-logged. Only use for genuine emergencies.',
1947
- COMMAND: 'LUMENFLOW_FORCE=1 LUMENFLOW_FORCE_REASON="<reason>" git commit ...',
1948
- },
1949
- },
1950
- /**
1951
- * Worktree discipline block message components
1952
- */
1953
- WORKTREE_BLOCK: {
1954
- TITLE: 'LANE BRANCH WORK SHOULD BE IN WORKTREE',
1955
- WHY: 'Worktrees provide isolation for parallel work. Working on a lane branch from the main checkout bypasses this isolation.',
1956
- },
1957
- };
19
+ * @see {@link packages/@lumenflow/cli/src/lib/wu-schema.ts} - PLACEHOLDER_SENTINEL
20
+ */
21
+ // WU Status constants
22
+ export { WU_STATUS, PROTECTED_WU_STATUSES, PROGRESSABLE_WU_STATUSES, WU_STATUS_GROUPS, CLAIMED_MODES, INCIDENT_SEVERITY, WU_TYPES, WU_EXPOSURE, WU_EXPOSURE_VALUES, TEST_TYPES, } from './wu-statuses.js';
23
+ // Git constants
24
+ export { BRANCHES, REMOTES, GIT_REFS, GIT, REAL_GIT, GIT_FLAGS, GIT_COMMANDS, GIT_COMMAND_STRINGS, } from './wu-git-constants.js';
25
+ // Path and filesystem constants
26
+ export { FILE_SYSTEM, CONFIG_FILES, DIRECTORIES, BUILD_ARTIFACT_GLOBS, BUILD_ARTIFACT_IGNORES, SCRIPT_PATHS, FILE_EXTENSIONS, PATH_PATTERNS, PATH_LITERALS, PATH_SLICE_LENGTHS, LOCK_DIR_NAME, LUMENFLOW_PATHS, FILE_TOOLS, PHI_ERRORS, PHI_CONFIG, } from './wu-paths-constants.js';
27
+ // CLI and tooling constants
28
+ export { CLI_FLAGS, PKG_FLAGS, ESLINT_FLAGS, SCRIPTS, GATE_NAMES, GATE_COMMANDS, CLI_MODES, PRETTIER_FLAGS, PKG_MANAGER, PKG_COMMANDS, PACKAGES, STDIO, STDIO_MODES, EXIT_CODES, STREAM_ERRORS, ESLINT_COMMANDS, ESLINT_DEFAULTS, CACHE_STRATEGIES, PRETTIER_ARGS, AUDIT_ARGS, SHELL_COMMANDS, TOOLS, GITLEAKS_ARGS, KNOWN_PACKAGES, ERROR_CODES, MICRO_WORKTREE_OPERATIONS, TELEMETRY_STEPS, SKIP_GATES_REASONS, CHECKPOINT_MESSAGES, PROCESS_DETECTION, } from './wu-cli-constants.js';
29
+ // UI and display constants
30
+ export { BACKLOG_SECTIONS, BACKLOG_BULLET_FORMAT, STATUS_SECTIONS, LOG_PREFIX, EMOJI, BOX, UI, DISPLAY_LIMITS, YAML_OPTIONS, ARGV_INDICES, STRING_LITERALS, READINESS_UI, } from './wu-ui-constants.js';
31
+ // Domain constants and utilities
32
+ export { PATTERNS, COMMIT_FORMATS, CONSISTENCY_TYPES, CONSISTENCY_MESSAGES, WORKTREE_WARNINGS, CLEANUP_GUARD, SESSION, VALIDATION, THRESHOLDS, DEFAULTS, WU_DEFAULTS, SAFETY_CRITICAL_TEST_GLOBS, LANE_PATH_PATTERNS, toKebab, getWorktreePath, getLaneBranch, getProjectRoot, discoverSafetyTests, validateSafetyTestsExist, } from './wu-domain-constants.js';
33
+ // Context validation constants and types
34
+ export { CONTEXT_VALIDATION, HOOK_MESSAGES, LUMENFLOW_CLIENT_IDS, CLAUDE_HOOKS, getHookCommand, } from './wu-context-constants.js';
1958
35
  //# sourceMappingURL=wu-constants.js.map