@lumenflow/cli 5.4.0 → 5.7.12

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 (227) hide show
  1. package/README.md +42 -40
  2. package/dist/db-journal-recover.js +400 -0
  3. package/dist/db-journal-recover.js.map +1 -0
  4. package/dist/docs-sync.js +8 -3
  5. package/dist/docs-sync.js.map +1 -1
  6. package/dist/gate-defaults.js +191 -9
  7. package/dist/gate-defaults.js.map +1 -1
  8. package/dist/gate-registry.js.map +1 -1
  9. package/dist/gates/monolithic-file-contention-guard.js +167 -0
  10. package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
  11. package/dist/gates/prod-migration-drift.js +207 -0
  12. package/dist/gates/prod-migration-drift.js.map +1 -0
  13. package/dist/gates/test-over-deletion-guard.js +255 -0
  14. package/dist/gates/test-over-deletion-guard.js.map +1 -0
  15. package/dist/gates-runners.js +401 -2
  16. package/dist/gates-runners.js.map +1 -1
  17. package/dist/gates.js +349 -4
  18. package/dist/gates.js.map +1 -1
  19. package/dist/lumenflow-setup.js +144 -0
  20. package/dist/lumenflow-setup.js.map +1 -0
  21. package/dist/lumenflow-upgrade.js +2 -1
  22. package/dist/lumenflow-upgrade.js.map +1 -1
  23. package/dist/mem-create.js +10 -1
  24. package/dist/mem-create.js.map +1 -1
  25. package/dist/mem-signal.js +21 -4
  26. package/dist/mem-signal.js.map +1 -1
  27. package/dist/metrics-cli.js +19 -2
  28. package/dist/metrics-cli.js.map +1 -1
  29. package/dist/metrics-snapshot.js +25 -2
  30. package/dist/metrics-snapshot.js.map +1 -1
  31. package/dist/orchestrate-initiative.js +28 -3
  32. package/dist/orchestrate-initiative.js.map +1 -1
  33. package/dist/public-manifest.js +17 -0
  34. package/dist/public-manifest.js.map +1 -1
  35. package/dist/release.js +53 -18
  36. package/dist/release.js.map +1 -1
  37. package/dist/wu-done-gates.js +121 -8
  38. package/dist/wu-done-gates.js.map +1 -1
  39. package/dist/wu-done.js +30 -6
  40. package/dist/wu-done.js.map +1 -1
  41. package/dist/wu-edit-operations.js +74 -0
  42. package/dist/wu-edit-operations.js.map +1 -1
  43. package/dist/wu-edit-validators.js +58 -0
  44. package/dist/wu-edit-validators.js.map +1 -1
  45. package/dist/wu-edit.js +106 -4
  46. package/dist/wu-edit.js.map +1 -1
  47. package/dist/wu-prep.js +132 -8
  48. package/dist/wu-prep.js.map +1 -1
  49. package/dist/wu-recover.js +6 -0
  50. package/dist/wu-recover.js.map +1 -1
  51. package/dist/wu-release.js +120 -2
  52. package/dist/wu-release.js.map +1 -1
  53. package/dist/wu-sizing-validation.js +47 -17
  54. package/dist/wu-sizing-validation.js.map +1 -1
  55. package/dist/wu-status.js +33 -0
  56. package/dist/wu-status.js.map +1 -1
  57. package/package.json +13 -11
  58. package/packs/agent-runtime/package.json +1 -1
  59. package/packs/sidekick/package.json +1 -1
  60. package/packs/software-delivery/package.json +1 -1
  61. package/templates/core/AGENTS.md.template +162 -26
  62. package/templates/core/LUMENFLOW.md.template +381 -70
  63. package/templates/core/ai/onboarding/agent-invocation-guide.md.template +0 -5
  64. package/templates/core/ai/onboarding/agent-safety-card.md.template +63 -17
  65. package/templates/core/ai/onboarding/initiative-orchestration.md.template +4 -0
  66. package/templates/core/ai/onboarding/release-process.md.template +7 -7
  67. package/templates/core/ai/onboarding/vendor-support.md.template +74 -10
  68. package/templates/vendors/claude/.claude/skills/frontend-design/SKILL.md.template +1 -1
  69. package/templates/vendors/claude/.claude/skills/wu-lifecycle/SKILL.md.template +28 -0
  70. package/packs/agent-runtime/agent-heartbeat.ts +0 -163
  71. package/packs/agent-runtime/auto-session-integration.ts +0 -888
  72. package/packs/agent-runtime/capability-factory.ts +0 -104
  73. package/packs/agent-runtime/constants.ts +0 -21
  74. package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
  75. package/packs/agent-runtime/delegation-registry-store.ts +0 -269
  76. package/packs/agent-runtime/delegation-tree.ts +0 -328
  77. package/packs/agent-runtime/index.ts +0 -20
  78. package/packs/agent-runtime/manifest.ts +0 -348
  79. package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
  80. package/packs/agent-runtime/orchestration.ts +0 -2027
  81. package/packs/agent-runtime/pack-registration.ts +0 -110
  82. package/packs/agent-runtime/policy-factory.ts +0 -165
  83. package/packs/agent-runtime/remote-controls/index.ts +0 -7
  84. package/packs/agent-runtime/remote-controls/operations.ts +0 -405
  85. package/packs/agent-runtime/remote-controls/port.ts +0 -48
  86. package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
  87. package/packs/agent-runtime/remote-controls/types.ts +0 -105
  88. package/packs/agent-runtime/session-schema.ts +0 -467
  89. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
  90. package/packs/agent-runtime/tool-impl/index.ts +0 -6
  91. package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
  92. package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
  93. package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
  94. package/packs/agent-runtime/tools/index.ts +0 -4
  95. package/packs/agent-runtime/tools/types.ts +0 -47
  96. package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
  97. package/packs/agent-runtime/types.ts +0 -128
  98. package/packs/agent-runtime/vitest.config.ts +0 -11
  99. package/packs/sidekick/channel-ingress.ts +0 -137
  100. package/packs/sidekick/constants.ts +0 -10
  101. package/packs/sidekick/index.ts +0 -8
  102. package/packs/sidekick/manifest-schema.ts +0 -49
  103. package/packs/sidekick/manifest.ts +0 -512
  104. package/packs/sidekick/pack-registration.ts +0 -110
  105. package/packs/sidekick/policy-factory.ts +0 -38
  106. package/packs/sidekick/sidekick-events.ts +0 -694
  107. package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
  108. package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
  109. package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
  110. package/packs/sidekick/src/domain/channel.types.ts +0 -64
  111. package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
  112. package/packs/sidekick/src/routines/commit.ts +0 -74
  113. package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
  114. package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
  115. package/packs/sidekick/tool-impl/index.ts +0 -29
  116. package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
  117. package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
  118. package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
  119. package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
  120. package/packs/sidekick/tool-impl/shared.ts +0 -125
  121. package/packs/sidekick/tool-impl/storage.ts +0 -325
  122. package/packs/sidekick/tool-impl/system-tools.ts +0 -160
  123. package/packs/sidekick/tool-impl/task-tools.ts +0 -506
  124. package/packs/sidekick/tools/channel-tools.ts +0 -53
  125. package/packs/sidekick/tools/index.ts +0 -9
  126. package/packs/sidekick/tools/memory-tools.ts +0 -53
  127. package/packs/sidekick/tools/routine-tools.ts +0 -53
  128. package/packs/sidekick/tools/system-tools.ts +0 -47
  129. package/packs/sidekick/tools/task-tools.ts +0 -61
  130. package/packs/sidekick/tools/types.ts +0 -57
  131. package/packs/sidekick/vitest.config.ts +0 -11
  132. package/packs/software-delivery/constants.ts +0 -10
  133. package/packs/software-delivery/extensions.ts +0 -140
  134. package/packs/software-delivery/gate-policies.ts +0 -134
  135. package/packs/software-delivery/index.ts +0 -8
  136. package/packs/software-delivery/manifest-schema.ts +0 -268
  137. package/packs/software-delivery/manifest.ts +0 -657
  138. package/packs/software-delivery/pack-registration.ts +0 -113
  139. package/packs/software-delivery/src/commands/index.ts +0 -5
  140. package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
  141. package/packs/software-delivery/src/config/env-accessors.ts +0 -66
  142. package/packs/software-delivery/src/config/index.ts +0 -8
  143. package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
  144. package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
  145. package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
  146. package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
  147. package/packs/software-delivery/src/constants/client-ids.ts +0 -19
  148. package/packs/software-delivery/src/constants/config-contract.ts +0 -7
  149. package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
  150. package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
  151. package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
  152. package/packs/software-delivery/src/constants/index.ts +0 -29
  153. package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
  154. package/packs/software-delivery/src/constants/object-guards.ts +0 -12
  155. package/packs/software-delivery/src/constants/section-headings.ts +0 -107
  156. package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -488
  157. package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
  158. package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
  159. package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
  160. package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
  161. package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
  162. package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
  163. package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
  164. package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
  165. package/packs/software-delivery/src/domain/index.ts +0 -5
  166. package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
  167. package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
  168. package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
  169. package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
  170. package/packs/software-delivery/src/methodology/index.ts +0 -6
  171. package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
  172. package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
  173. package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
  174. package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
  175. package/packs/software-delivery/src/policy/gates-config.ts +0 -300
  176. package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
  177. package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
  178. package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
  179. package/packs/software-delivery/src/policy/index.ts +0 -22
  180. package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
  181. package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
  182. package/packs/software-delivery/src/ports/config.ports.ts +0 -90
  183. package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
  184. package/packs/software-delivery/src/ports/index.ts +0 -10
  185. package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
  186. package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
  187. package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
  188. package/packs/software-delivery/src/primitives/index.ts +0 -5
  189. package/packs/software-delivery/src/runtime/index.ts +0 -6
  190. package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
  191. package/packs/software-delivery/src/sandbox/index.ts +0 -10
  192. package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
  193. package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
  194. package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
  195. package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
  196. package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
  197. package/packs/software-delivery/src/schemas/index.ts +0 -5
  198. package/packs/software-delivery/src/state/date-utils.ts +0 -158
  199. package/packs/software-delivery/src/state/index.ts +0 -15
  200. package/packs/software-delivery/src/state/state-machine.ts +0 -119
  201. package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
  202. package/packs/software-delivery/src/state/wu-paths.ts +0 -381
  203. package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
  204. package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
  205. package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
  206. package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
  207. package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
  208. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
  209. package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
  210. package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
  211. package/packs/software-delivery/tool-impl/index.ts +0 -15
  212. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
  213. package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
  214. package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
  215. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
  216. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
  217. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
  218. package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
  219. package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
  220. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
  221. package/packs/software-delivery/tools/delegation-tools.ts +0 -23
  222. package/packs/software-delivery/tools/git-tools.ts +0 -55
  223. package/packs/software-delivery/tools/index.ts +0 -8
  224. package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
  225. package/packs/software-delivery/tools/types.ts +0 -71
  226. package/packs/software-delivery/tools/worktree-tools.ts +0 -49
  227. package/packs/software-delivery/vitest.config.ts +0 -11
@@ -1,466 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * Domain Constants
6
- *
7
- * WU-1549: Extracted from wu-constants.ts for domain-specific modularity.
8
- * Contains WU patterns, commit formats, consistency checks, cleanup guards,
9
- * defaults, validation thresholds, safety tests, lane path patterns, and
10
- * utility functions (toKebab, getWorktreePath, getLaneBranch, getProjectRoot).
11
- *
12
- * @module wu-domain-constants
13
- */
14
-
15
- import path from 'node:path';
16
- import { kebabCase } from 'change-case';
17
- import { LOG_PREFIX } from './wu-ui-constants.js';
18
-
19
- /**
20
- * Regex patterns for WU operations
21
- *
22
- * Note: WU_ID pattern is also in wu-schema.ts for Zod validation
23
- */
24
- export const PATTERNS = {
25
- /** WU identifier format: WU-123 */
26
- WU_ID: /^WU-\d+$/,
27
-
28
- /** Extract WU ID from text: captures "WU-123" */
29
- WU_ID_EXTRACT: /WU-\d+/,
30
-
31
- /**
32
- * Extract WU ID from worktree paths (case-insensitive)
33
- *
34
- * WU-1090: Worktree names use lowercase like 'framework-core-wu-1090'
35
- * This pattern matches both 'WU-123' and 'wu-123' to support
36
- * extracting WU IDs from worktree paths.
37
- */
38
- WU_ID_EXTRACT_CI: /wu-\d+/i,
39
-
40
- /** Lane branch format: lane/<lane-kebab>/wu-<id> */
41
- LANE_BRANCH: /^lane\/[\w-]+\/wu-\d+$/,
42
-
43
- /** Worktree path format: worktrees/<lane-kebab>-wu-<id> */
44
- WORKTREE_PATH: /^worktrees\/[\w-]+-wu-\d+$/,
45
- };
46
-
47
- /**
48
- * Commit message formats
49
- *
50
- * These are functions that generate properly formatted commit messages
51
- */
52
- export const COMMIT_FORMATS = {
53
- CLAIM: (id: string, laneKebab: string) => `wu(${id}): claim for ${laneKebab} lane`,
54
- DONE: (id: string, title: string) => `wu(${id}): done - ${title}`,
55
- CREATE: (id: string, title: string) => `docs: create ${id.toLowerCase()} for ${title}`,
56
- EDIT: (id: string) => `docs: edit ${id.toLowerCase()} spec`,
57
- SPEC_UPDATE: (id: string) => `wu(${id.toLowerCase()}): spec update`,
58
- BLOCK: (id: string) => `wu(${id}): block`,
59
- UNBLOCK: (id: string) => `wu(${id}): unblock`,
60
- REPAIR: (id: string) => `fix(${id}): repair state inconsistency`,
61
- REBASE_ARTIFACT_CLEANUP: (id: string) =>
62
- `chore(${id.toLowerCase()}): remove rebased completion artifacts`,
63
- BACKLOG_REPAIR: (id: string) =>
64
- `chore(repair): repair backlog duplicates for ${id.toLowerCase()}`,
65
- ESCALATE: (id: string) => `wu(${id.toLowerCase()}): resolve escalation`,
66
- };
67
-
68
- /**
69
- * Consistency check types (WU-1276)
70
- *
71
- * Layer 2 defense-in-depth: detect and repair WU state inconsistencies
72
- */
73
- export const CONSISTENCY_TYPES = {
74
- /** WU YAML has status 'done' but WU appears in status.md In Progress section */
75
- YAML_DONE_STATUS_IN_PROGRESS: 'YAML_DONE_STATUS_IN_PROGRESS',
76
-
77
- /** WU appears in both Done AND In Progress sections of backlog.md */
78
- BACKLOG_DUAL_SECTION: 'BACKLOG_DUAL_SECTION',
79
-
80
- /** WU YAML has status 'done' but no stamp file exists */
81
- YAML_DONE_NO_STAMP: 'YAML_DONE_NO_STAMP',
82
-
83
- /** WU has status 'done' but still has an associated worktree */
84
- ORPHAN_WORKTREE_DONE: 'ORPHAN_WORKTREE_DONE',
85
-
86
- /** Stamp file exists but WU YAML status is not 'done' (partial wu:done failure) */
87
- STAMP_EXISTS_YAML_NOT_DONE: 'STAMP_EXISTS_YAML_NOT_DONE',
88
-
89
- /** WU is claimed but its worktree directory is missing */
90
- MISSING_WORKTREE_CLAIMED: 'MISSING_WORKTREE_CLAIMED',
91
- };
92
-
93
- /**
94
- * Consistency check messages
95
- */
96
- export const CONSISTENCY_MESSAGES = {
97
- MISSING_WORKTREE_CLAIMED: (id: string, status: string, worktreePath: string) =>
98
- `WU ${id} is '${status}' but worktree path is missing (${worktreePath})`,
99
- MISSING_WORKTREE_CLAIMED_REPAIR: 'Recover worktree or re-claim WU',
100
- };
101
-
102
- /**
103
- * Worktree warning messages
104
- */
105
- export const WORKTREE_WARNINGS = {
106
- MISSING_TRACKED_HEADER: 'Tracked worktrees missing on disk (possible manual deletion):',
107
- MISSING_TRACKED_LINE: (worktreePath: string) => `Missing: ${worktreePath}`,
108
- };
109
-
110
- /**
111
- * Cleanup guard constants
112
- */
113
- export const CLEANUP_GUARD = {
114
- REASONS: {
115
- UNCOMMITTED_CHANGES: 'UNCOMMITTED_CHANGES',
116
- UNPUSHED_COMMITS: 'UNPUSHED_COMMITS',
117
- STATUS_NOT_DONE: 'STATUS_NOT_DONE',
118
- MISSING_STAMP: 'MISSING_STAMP',
119
- PR_NOT_MERGED: 'PR_NOT_MERGED',
120
- },
121
- TITLES: {
122
- BLOCKED: 'CLEANUP BLOCKED',
123
- NEXT_STEPS: 'Next steps:',
124
- },
125
- MESSAGES: {
126
- UNCOMMITTED_CHANGES: 'Worktree has uncommitted changes. Refusing to delete.',
127
- UNPUSHED_COMMITS: 'Worktree has unpushed commits. Refusing to delete.',
128
- STATUS_NOT_DONE: 'WU YAML status is not done. Refusing to delete.',
129
- MISSING_STAMP: 'WU stamp is missing. Refusing to delete.',
130
- PR_NOT_MERGED: 'PR is not merged (or cannot be verified). Refusing to delete.',
131
- },
132
- /* eslint-disable sonarjs/no-duplicate-string -- Intentional: cleanup instructions repeated for each error type for readability */
133
- NEXT_STEPS: {
134
- DEFAULT: [
135
- { text: '1. Resolve the issue above', appendId: false },
136
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
137
- ],
138
- UNCOMMITTED_CHANGES: [
139
- { text: '1. Commit or stash changes in the worktree', appendId: false },
140
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
141
- ],
142
- UNPUSHED_COMMITS: [
143
- { text: '1. Push the lane branch to origin', appendId: false },
144
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
145
- ],
146
- STATUS_NOT_DONE: [
147
- {
148
- text: `1. Complete the WU with ${LOG_PREFIX.DONE} (creates stamp + done status)`,
149
- appendId: false,
150
- },
151
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
152
- ],
153
- MISSING_STAMP: [
154
- { text: '1. Run wu:done to create the stamp file', appendId: false },
155
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
156
- ],
157
- PR_NOT_MERGED: [
158
- { text: '1. Merge the PR in GitHub', appendId: false },
159
- { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
160
- ],
161
- },
162
- /* eslint-enable sonarjs/no-duplicate-string */
163
- PR_CHECK: {
164
- START: 'Verifying PR merge status...',
165
- RESULT: 'PR merge verification via',
166
- },
167
- };
168
-
169
- /**
170
- * Session display constants
171
- *
172
- * Emergency fix (Session 2): Centralized from hardcoded magic numbers
173
- */
174
- export const SESSION = {
175
- /** Standard length for displaying session ID prefix (e.g., "sess-123") */
176
- ID_DISPLAY_LENGTH: 8,
177
- };
178
-
179
- /**
180
- * Validation constants
181
- *
182
- * WU-1281: Centralized from local constants in validators
183
- */
184
- export const VALIDATION = {
185
- /** Minimum description length for WU spec completeness */
186
- MIN_DESCRIPTION_LENGTH: 50,
187
- };
188
-
189
- /**
190
- * Threshold constants for pre-flight checks
191
- *
192
- * WU-1302: Centralized to eliminate magic numbers
193
- * WU-1370: Added graduated drift thresholds for early warnings
194
- */
195
- export const THRESHOLDS = {
196
- /** Info threshold: commits behind main to suggest rebasing (WU-1370) */
197
- BRANCH_DRIFT_INFO: 10,
198
-
199
- /** Warning threshold: commits behind main where rebase is recommended (WU-1370) */
200
- BRANCH_DRIFT_WARNING: 15,
201
-
202
- /** Maximum commits behind main before requiring rebase (WU-755 pre-flight) */
203
- BRANCH_DRIFT_MAX: 20,
204
- };
205
-
206
- /**
207
- * Default values
208
- */
209
- export const DEFAULTS = {
210
- /** Default worktrees directory */
211
- WORKTREES_DIR: 'worktrees',
212
-
213
- /** Maximum commit subject length (commitlint default) */
214
- MAX_COMMIT_SUBJECT: 100,
215
-
216
- /** Parent directory traversal depth from tools/lib to project root */
217
- PROJECT_ROOT_DEPTH: 2,
218
-
219
- /**
220
- * Default email domain for username -> email conversion
221
- * WU-1068: Made configurable, no longer hardcoded to exampleapp.co.uk
222
- * @see user-normalizer.ts - Infers from git config first
223
- */
224
- EMAIL_DOMAIN: 'example.com',
225
- };
226
-
227
- /**
228
- * Default values for WU YAML fields
229
- *
230
- * WU-1337: Centralized defaults for auto-repair in schema validation
231
- * DRY principle: Single source of truth for optional field defaults
232
- *
233
- * Used by wu-schema.ts Zod transformations to provide sensible defaults
234
- * when agents omit optional fields, reducing validation errors.
235
- */
236
- export const WU_DEFAULTS = {
237
- /** Default priority level (medium priority) */
238
- priority: 'P2',
239
-
240
- /** Default status for new WUs */
241
- status: 'ready',
242
-
243
- /** Default work type */
244
- type: 'feature',
245
-
246
- /** Default code paths (empty until populated) */
247
- code_paths: [] as string[],
248
-
249
- /** Default test structure (includes all test types) */
250
- tests: {
251
- manual: [] as string[],
252
- unit: [] as string[],
253
- integration: [] as string[],
254
- e2e: [] as string[],
255
- },
256
-
257
- /** Default artifacts (empty - wu:done adds stamp) */
258
- artifacts: [] as string[],
259
-
260
- /** Default dependencies (no blockers) */
261
- dependencies: [] as string[],
262
-
263
- /** Default risks (none identified) */
264
- risks: [] as string[],
265
-
266
- /** Default notes (empty string, not undefined) */
267
- notes: '',
268
-
269
- /** Default review requirement (agent-completed WUs) */
270
- requires_review: false,
271
- };
272
-
273
- /**
274
- * Safety-critical test glob patterns
275
- *
276
- * WU-2242: Centralized list of glob patterns for safety tests that MUST exist.
277
- * Gates fail if UnsafeAny of these patterns find no matches.
278
- */
279
- export const SAFETY_CRITICAL_TEST_GLOBS = Object.freeze([
280
- // Escalation trigger tests
281
- 'apps/web/src/**/*escalation*.test.{ts,tsx}',
282
- 'apps/web/src/**/*Escalation*.test.{ts,tsx}',
283
-
284
- // Privacy detection tests
285
- 'apps/web/src/**/*privacy*.test.{ts,tsx}',
286
- 'apps/web/src/**/*Privacy*.test.{ts,tsx}',
287
-
288
- // Constitutional enforcer tests
289
- 'apps/web/src/**/*constitutional*.test.{ts,tsx}',
290
- 'apps/web/src/**/*Constitutional*.test.{ts,tsx}',
291
-
292
- // Safe prompt wrapper tests
293
- 'apps/web/src/**/*safePrompt*.test.{ts,tsx}',
294
- 'apps/web/src/**/*SafePrompt*.test.{ts,tsx}',
295
-
296
- // Crisis/emergency handling tests
297
- 'apps/web/src/**/*crisis*.test.{ts,tsx}',
298
- 'apps/web/src/**/*Crisis*.test.{ts,tsx}',
299
- ]);
300
-
301
- /**
302
- * Lane-to-code_paths validation patterns (WU-1372)
303
- *
304
- * Advisory patterns to warn when a WU's lane doesn't match its code_paths.
305
- */
306
- export const LANE_PATH_PATTERNS = {
307
- Operations: {
308
- exclude: ['ai/prompts/**', 'apps/web/src/lib/prompts/**'],
309
- allowExceptions: [] as string[],
310
- },
311
- Intelligence: {
312
- exclude: ['tools/**'],
313
- allowExceptions: ['tools/lib/prompt-*', 'tools/prompts-eval/**'],
314
- },
315
- };
316
-
317
- /**
318
- * Convert lane name to kebab-case using change-case library
319
- *
320
- * @param lane - Lane name (e.g., 'Operations: Tooling')
321
- * @returns Kebab-case lane (e.g., 'operations-tooling')
322
- */
323
- export function toKebab(lane: string | null | undefined): string {
324
- if (lane == null) return '';
325
- const normalized = String(lane).trim();
326
- if (normalized === '') return '';
327
- return kebabCase(normalized);
328
- }
329
-
330
- /**
331
- * Generate worktree path from lane and WU ID
332
- *
333
- * @param lane - Lane name
334
- * @param id - WU ID
335
- * @returns Worktree path (e.g., 'worktrees/operations-tooling-wu-123')
336
- */
337
- export function getWorktreePath(lane: string, id: string): string {
338
- const laneKebab = toKebab(lane);
339
- const idLower = id.toLowerCase();
340
- return `${DEFAULTS.WORKTREES_DIR}/${laneKebab}-${idLower}`;
341
- }
342
-
343
- /**
344
- * Generate lane branch name from lane and WU ID
345
- *
346
- * @param lane - Lane name
347
- * @param id - WU ID
348
- * @returns Branch name (e.g., 'lane/operations-tooling/wu-123')
349
- */
350
- export function getLaneBranch(lane: string, id: string): string {
351
- const laneKebab = toKebab(lane);
352
- const idLower = id.toLowerCase();
353
- return `lane/${laneKebab}/${idLower}`;
354
- }
355
-
356
- /**
357
- * Get project root directory from a module URL
358
- *
359
- * WU-923: Centralized path resolution to eliminate '../..' magic strings
360
- *
361
- * @param moduleUrl - import.meta.url of the calling module
362
- * @returns Absolute path to project root
363
- */
364
- export function getProjectRoot(moduleUrl: string): string {
365
- const { dirname } = path;
366
- const currentDir = dirname(new URL(moduleUrl).pathname);
367
-
368
- let root = currentDir;
369
- for (let i = 0; i < DEFAULTS.PROJECT_ROOT_DEPTH; i++) {
370
- root = dirname(root);
371
- }
372
- return root;
373
- }
374
-
375
- /**
376
- * Options for discovering safety tests
377
- */
378
- export interface DiscoverSafetyTestsOptions {
379
- /** Project root directory */
380
- projectRoot?: string;
381
- }
382
-
383
- /**
384
- * Discover safety-critical test files
385
- *
386
- * WU-2242: Scans for test files matching safety-critical patterns.
387
- * Uses glob to find all matching files.
388
- *
389
- * @param options - Discovery options
390
- * @returns List of discovered test file paths
391
- */
392
- export async function discoverSafetyTests(
393
- options: DiscoverSafetyTestsOptions = {},
394
- ): Promise<string[]> {
395
- const { projectRoot = process.cwd() } = options;
396
- const { glob } = await import('glob');
397
- const foundFiles: string[] = [];
398
-
399
- for (const pattern of SAFETY_CRITICAL_TEST_GLOBS) {
400
- try {
401
- const matches = await glob(pattern, {
402
- cwd: projectRoot,
403
- absolute: false,
404
- });
405
- foundFiles.push(...matches);
406
- } catch {
407
- // Pattern may not match anything, that's fine
408
- }
409
- }
410
-
411
- return [...new Set(foundFiles)]; // Deduplicate
412
- }
413
-
414
- /**
415
- * Validate that required safety-critical tests exist
416
- *
417
- * WU-2242: Checks that each pattern category has at least one matching test file.
418
- * Returns a validation result with missing patterns and found files.
419
- */
420
- export async function validateSafetyTestsExist(options: DiscoverSafetyTestsOptions = {}) {
421
- const { projectRoot = process.cwd() } = options;
422
- const { glob } = await import('glob');
423
-
424
- const missingTests: string[] = [];
425
- const foundTests: string[] = [];
426
-
427
- const categories = [
428
- { name: 'Escalation', patterns: SAFETY_CRITICAL_TEST_GLOBS.slice(0, 2) },
429
- { name: 'Privacy detection', patterns: SAFETY_CRITICAL_TEST_GLOBS.slice(2, 4) },
430
- { name: 'Constitutional', patterns: SAFETY_CRITICAL_TEST_GLOBS.slice(4, 6) },
431
- { name: 'Safe prompt wrapper', patterns: SAFETY_CRITICAL_TEST_GLOBS.slice(6, 8) },
432
- { name: 'Crisis handling', patterns: SAFETY_CRITICAL_TEST_GLOBS.slice(8, 10) },
433
- ];
434
-
435
- for (const category of categories) {
436
- let categoryHasTests = false;
437
-
438
- for (const pattern of category.patterns) {
439
- try {
440
- const matches = await glob(pattern, {
441
- cwd: projectRoot,
442
- absolute: false,
443
- });
444
- if (matches.length > 0) {
445
- categoryHasTests = true;
446
- foundTests.push(...matches);
447
- }
448
- } catch {
449
- // Pattern error, treat as no matches
450
- }
451
- }
452
-
453
- if (!categoryHasTests) {
454
- missingTests.push(`${category.name}: ${category.patterns.join(', ')}`);
455
- }
456
- }
457
-
458
- const valid = missingTests.length === 0;
459
-
460
- return {
461
- valid,
462
- missingTests,
463
- foundTests: [...new Set(foundTests)],
464
- error: valid ? undefined : `Missing safety-critical tests: ${missingTests.join('; ')}`,
465
- };
466
- }
@@ -1,7 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- // WU-2681 (INIT-058 L2e): Shim — real module lives in @lumenflow/kernel/primitives/git-constants.
5
- // Re-export preserves the `@lumenflow/packs-software-delivery/constants/wu-git-constants` subpath
6
- // for existing consumers (including core's WU-2679 shim) until Layer 7 removes the shim.
7
- export * from '@lumenflow/kernel/primitives/git-constants';