@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,601 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * Resolve Policy - Single Source of Truth for Methodology Decisions
6
- *
7
- * WU-1259: Provides a unified policy resolver that both wu:spawn and gates use.
8
- *
9
- * This module:
10
- * - Defines the methodology.* config schema
11
- * - Implements resolvePolicy() to produce ResolvedPolicy
12
- * - Applies precedence: template defaults -> methodology.overrides -> explicit gates.* -> CLI flags
13
- *
14
- * @module resolve-policy
15
- */
16
-
17
- import { z } from 'zod';
18
- import { WU_TYPES, WU_TYPE_VALUES, type WUType } from '../constants/wu-statuses.js';
19
-
20
- /**
21
- * Testing methodology options
22
- */
23
- export const TESTING_METHODOLOGY = {
24
- TDD: 'tdd',
25
- TEST_AFTER: 'test-after',
26
- NONE: 'none',
27
- } as const;
28
-
29
- export type TestingMethodology = (typeof TESTING_METHODOLOGY)[keyof typeof TESTING_METHODOLOGY];
30
-
31
- /**
32
- * Architecture methodology options
33
- */
34
- export const ARCHITECTURE_METHODOLOGY = {
35
- HEXAGONAL: 'hexagonal',
36
- LAYERED: 'layered',
37
- NONE: 'none',
38
- } as const;
39
-
40
- export type ArchitectureMethodology =
41
- (typeof ARCHITECTURE_METHODOLOGY)[keyof typeof ARCHITECTURE_METHODOLOGY];
42
-
43
- /**
44
- * Coverage mode options
45
- */
46
- export const COVERAGE_MODE = {
47
- BLOCK: 'block',
48
- WARN: 'warn',
49
- OFF: 'off',
50
- } as const;
51
-
52
- export type CoverageMode = (typeof COVERAGE_MODE)[keyof typeof COVERAGE_MODE];
53
-
54
- /**
55
- * Zod schema for testing methodology enum
56
- */
57
- export const TestingMethodologySchema = z.enum(['tdd', 'test-after', 'none']);
58
-
59
- /**
60
- * Zod schema for architecture methodology enum
61
- */
62
- export const ArchitectureMethodologySchema = z.enum(['hexagonal', 'layered', 'none']);
63
-
64
- /**
65
- * Zod schema for coverage mode enum
66
- */
67
- export const CoverageModeSchema = z.enum(['block', 'warn', 'off']);
68
-
69
- /**
70
- * WU-2905: Default test-file glob patterns for the tdd_diff_evidence gate.
71
- *
72
- * These globs identify files that count as "test evidence" in a branch diff
73
- * for the default TS/JS toolchain. Mirrors the regex set in
74
- * `@lumenflow/core/file-classifiers.ts:TEST_FILE_PATTERNS` (the legacy regex
75
- * form historically used by the gate consumer in wu:prep). When a workspace
76
- * overrides `tdd_diff_evidence.test_file_patterns`, the gate uses the
77
- * override exclusively (no merge) so non-TS/JS toolchains (.NET, Python,
78
- * Go, ...) get a clean opt-in without inheriting TS/JS bias.
79
- */
80
- export const DEFAULT_TDD_DIFF_TEST_FILE_PATTERNS: readonly string[] = Object.freeze([
81
- '**/*.test.ts',
82
- '**/*.test.tsx',
83
- '**/*.test.js',
84
- '**/*.test.jsx',
85
- '**/*.test.mjs',
86
- '**/*.spec.ts',
87
- '**/*.spec.tsx',
88
- '**/*.spec.js',
89
- '**/*.spec.jsx',
90
- '**/*.spec.mjs',
91
- '**/__tests__/**',
92
- '**/*.test-utils.*',
93
- '**/*.mock.*',
94
- ]);
95
-
96
- /**
97
- * WU-2905: Default code file extensions for the tdd_diff_evidence gate.
98
- *
99
- * Determines which changed files count as production code that requires
100
- * accompanying test evidence. Mirrors the historic constant in
101
- * `methodology/incremental-test.ts:CODE_FILE_EXTENSIONS`.
102
- */
103
- export const DEFAULT_TDD_DIFF_CODE_FILE_EXTENSIONS: readonly string[] = Object.freeze([
104
- '.ts',
105
- '.tsx',
106
- '.js',
107
- '.jsx',
108
- '.cjs',
109
- '.mts',
110
- '.cts',
111
- ]);
112
-
113
- export const TddDiffEvidenceConfigSchema = z.object({
114
- mode: CoverageModeSchema.optional(),
115
- applies_to_types: z.array(z.enum(WU_TYPE_VALUES)).min(1).optional(),
116
- exempt_paths: z.array(z.string().min(1)).optional(),
117
- /**
118
- * WU-2905: Optional glob patterns identifying test files for the
119
- * tdd_diff_evidence gate. When omitted, defaults to TS/JS patterns
120
- * (DEFAULT_TDD_DIFF_TEST_FILE_PATTERNS). When set, REPLACES the defaults so
121
- * non-TS/JS consumers can supply only their language's test patterns
122
- * (e.g. ['**\/*Tests.cs', '**\/Test*.cs'] for C# xUnit/NUnit/MSTest).
123
- */
124
- test_file_patterns: z.array(z.string().min(1)).min(1).optional(),
125
- /**
126
- * WU-2905: Optional file extensions identifying production code files for
127
- * the tdd_diff_evidence gate. When omitted, defaults to TS/JS extensions
128
- * (DEFAULT_TDD_DIFF_CODE_FILE_EXTENSIONS). When set, REPLACES the defaults
129
- * (e.g. ['.cs'] for C#, ['.py'] for Python, ['.go'] for Go).
130
- */
131
- code_file_extensions: z.array(z.string().min(1)).min(1).optional(),
132
- });
133
-
134
- export type TddDiffEvidenceConfig = z.infer<typeof TddDiffEvidenceConfigSchema>;
135
-
136
- /**
137
- * WU-2650: Commit-order (RED-first) policy schema.
138
- *
139
- * Sibling to TddDiffEvidenceConfigSchema. Where the diff-evidence policy
140
- * checks that tests EXIST somewhere in the branch diff, this policy checks
141
- * that tests APPEARED BEFORE (or alongside) the runtime code in commit order.
142
- *
143
- * Defaults: when methodology.testing = 'tdd', mode resolves to 'block'.
144
- * Otherwise 'off'. applies_to_types defaults to [feature, bug] so docs /
145
- * chore / process / tooling / refactor WUs bypass automatically.
146
- */
147
- export const TddOrderingConfigSchema = z.object({
148
- mode: CoverageModeSchema.optional(),
149
- applies_to_types: z.array(z.enum(WU_TYPE_VALUES)).min(1).optional(),
150
- min_runtime_loc_per_commit_without_tests: z.number().int().positive().optional(),
151
- grace_commits: z.number().int().nonnegative().optional(),
152
- exempt_paths: z.array(z.string().min(1)).optional(),
153
- });
154
-
155
- export type TddOrderingConfig = z.infer<typeof TddOrderingConfigSchema>;
156
-
157
- /**
158
- * Methodology overrides schema
159
- *
160
- * These allow tweaking template defaults without changing methodology.
161
- */
162
- export const MethodologyOverridesSchema = z.object({
163
- /** Override the default coverage threshold from the testing methodology */
164
- coverage_threshold: z.number().min(0).max(100).optional(),
165
- /** Override the default coverage mode from the testing methodology */
166
- coverage_mode: CoverageModeSchema.optional(),
167
- });
168
-
169
- export type MethodologyOverrides = z.infer<typeof MethodologyOverridesSchema>;
170
-
171
- /**
172
- * WU-1899: Work classification UI pattern configuration
173
- *
174
- * Allows extending default UI detection patterns with project-specific
175
- * code path patterns and lane hints. Custom values EXTEND defaults,
176
- * they do not replace them.
177
- *
178
- * @example
179
- * ```yaml
180
- * methodology:
181
- * work_classification:
182
- * ui:
183
- * code_path_patterns:
184
- * - 'src/widgets/*.tsx'
185
- * lane_hints:
186
- * - 'Design'
187
- * ```
188
- */
189
- export const WorkClassificationUiSchema = z.object({
190
- /**
191
- * Additional glob patterns for detecting UI work via code paths.
192
- * These extend the built-in defaults (CSS, SCSS, LESS, components, pages, etc.).
193
- * Uses minimatch glob syntax.
194
- */
195
- code_path_patterns: z.array(z.string()).optional(),
196
-
197
- /**
198
- * Additional lane parent hints for detecting UI work.
199
- * These extend the built-in defaults (Experience, Frontend, UI, Design).
200
- * Matched case-insensitively against the lane parent (part before the colon).
201
- */
202
- lane_hints: z.array(z.string()).optional(),
203
- });
204
-
205
- /** WU-1899: TypeScript type for work classification UI config */
206
- export type WorkClassificationUi = z.infer<typeof WorkClassificationUiSchema>;
207
-
208
- /**
209
- * WU-1899: Work classification configuration schema
210
- *
211
- * Controls signal-based work domain detection for code-path-aware
212
- * UI/backend/docs/infra classification.
213
- *
214
- * @example
215
- * ```yaml
216
- * methodology:
217
- * work_classification:
218
- * ui:
219
- * code_path_patterns:
220
- * - 'src/widgets/*.tsx'
221
- * lane_hints:
222
- * - 'Design'
223
- * ```
224
- */
225
- export const WorkClassificationConfigSchema = z.object({
226
- /** UI detection pattern overrides (extend defaults) */
227
- ui: WorkClassificationUiSchema.optional(),
228
- });
229
-
230
- /** WU-1899: TypeScript type for work classification config */
231
- export type WorkClassificationSchemaConfig = z.infer<typeof WorkClassificationConfigSchema>;
232
-
233
- /**
234
- * Main methodology configuration schema
235
- *
236
- * Config example in workspace.yaml:
237
- * ```yaml
238
- * methodology:
239
- * testing: 'tdd' # tdd | test-after | none
240
- * architecture: 'hexagonal' # hexagonal | layered | none
241
- * overrides:
242
- * coverage_threshold: 85 # Override TDD's default 90%
243
- * coverage_mode: 'warn' # Override TDD's default 'block'
244
- * work_classification:
245
- * ui:
246
- * code_path_patterns:
247
- * - 'src/widgets/*.tsx'
248
- * lane_hints:
249
- * - 'Design'
250
- * ```
251
- */
252
- export const MethodologyConfigSchema = z.object({
253
- /** Testing methodology (default: 'tdd') */
254
- testing: TestingMethodologySchema.default('tdd'),
255
- /** Architecture methodology (default: 'hexagonal') */
256
- architecture: ArchitectureMethodologySchema.default('hexagonal'),
257
- /** Optional overrides for template defaults */
258
- overrides: MethodologyOverridesSchema.optional(),
259
- /**
260
- * WU-1899: Work classification configuration.
261
- * Extends default signal patterns for UI/backend/docs/infra detection.
262
- * Custom patterns extend defaults, they do not replace them.
263
- */
264
- work_classification: WorkClassificationConfigSchema.optional(),
265
- });
266
-
267
- export type MethodologyConfig = z.infer<typeof MethodologyConfigSchema>;
268
-
269
- /**
270
- * Template defaults by testing methodology
271
- *
272
- * These define the baseline behavior for each testing approach.
273
- *
274
- * | Methodology | Coverage Threshold | Coverage Mode | Tests Required |
275
- * |-------------|-------------------|---------------|----------------|
276
- * | tdd | 90% | block | true |
277
- * | test-after | 70% | warn | true |
278
- * | none | 0% | off | false |
279
- */
280
- interface TestingTemplateDefaults {
281
- coverage_threshold: number;
282
- coverage_mode: CoverageMode;
283
- tests_required: boolean;
284
- }
285
-
286
- const DEFAULT_TDD_DIFF_APPLIES_TO_TYPES = [
287
- WU_TYPES.FEATURE,
288
- WU_TYPES.BUG,
289
- ] as const satisfies readonly WUType[];
290
- const DEFAULT_TDD_DIFF_EXEMPT_PATHS: readonly string[] = [];
291
-
292
- const TESTING_TEMPLATE_DEFAULTS: Record<TestingMethodology, TestingTemplateDefaults> = {
293
- tdd: {
294
- coverage_threshold: 90,
295
- coverage_mode: 'block',
296
- tests_required: true,
297
- },
298
- 'test-after': {
299
- coverage_threshold: 70,
300
- coverage_mode: 'warn',
301
- tests_required: true,
302
- },
303
- none: {
304
- coverage_threshold: 0,
305
- coverage_mode: 'off',
306
- tests_required: false,
307
- },
308
- };
309
-
310
- /**
311
- * The resolved policy used by wu:spawn and gates
312
- *
313
- * This is the single source of truth for methodology decisions.
314
- * All consumers (spawn prompts, gate runners, etc.) should use this type.
315
- */
316
- export interface ResolvedPolicy {
317
- /** Active testing methodology */
318
- testing: TestingMethodology;
319
- /** Active architecture methodology */
320
- architecture: ArchitectureMethodology;
321
- /** Resolved coverage threshold (0-100) */
322
- coverage_threshold: number;
323
- /** Resolved coverage mode */
324
- coverage_mode: CoverageMode;
325
- /** Whether tests are required for completion */
326
- tests_required: boolean;
327
- /** Resolved TDD diff evidence applicability */
328
- tdd_diff_evidence: TddDiffEvidencePolicy;
329
- /** WU-2650: Resolved commit-order (RED-first) policy */
330
- tdd_ordering: TddOrderingPolicy;
331
- }
332
-
333
- export interface TddDiffEvidencePolicy {
334
- mode: CoverageMode;
335
- applies_to_types: WUType[];
336
- exempt_paths: string[];
337
- /**
338
- * WU-2905: Resolved glob patterns identifying test files. Always
339
- * populated — falls back to DEFAULT_TDD_DIFF_TEST_FILE_PATTERNS when the
340
- * workspace does not override.
341
- */
342
- test_file_patterns: string[];
343
- /**
344
- * WU-2905: Resolved file extensions identifying production code files.
345
- * Always populated — falls back to DEFAULT_TDD_DIFF_CODE_FILE_EXTENSIONS
346
- * when the workspace does not override.
347
- */
348
- code_file_extensions: string[];
349
- }
350
-
351
- /**
352
- * WU-2650: Resolved commit-order policy.
353
- */
354
- export interface TddOrderingPolicy {
355
- mode: CoverageMode;
356
- applies_to_types: WUType[];
357
- min_runtime_loc_per_commit_without_tests: number;
358
- grace_commits: number;
359
- exempt_paths: string[];
360
- }
361
-
362
- /**
363
- * WU-2650: Default threshold for "non-trivial runtime LOC" in a single commit
364
- * before the commit-order gate flags a missing preceding test commit.
365
- *
366
- * Rationale: WU-2641 committed 1198 LOC of runtime ahead of tests. 50 is low
367
- * enough to catch meaningful feature work but high enough to ignore small
368
- * config-only edits and typo fixes.
369
- */
370
- const DEFAULT_TDD_ORDERING_MIN_RUNTIME_LOC = 50;
371
- const DEFAULT_TDD_ORDERING_GRACE_COMMITS = 0;
372
-
373
- /**
374
- * Options for resolvePolicy
375
- */
376
- export interface ResolvePolicyOptions {
377
- /**
378
- * Raw config object before Zod defaults were applied.
379
- * Used to detect explicit vs default values for gates.* fields.
380
- *
381
- * When provided, only EXPLICIT gates.* settings override methodology.
382
- * When not provided, UnsafeAny gates.* value (including defaults) overrides methodology.
383
- */
384
- rawConfig?: {
385
- gates?: {
386
- minCoverage?: number;
387
- enableCoverage?: boolean;
388
- tdd_diff_evidence?: TddDiffEvidenceConfig;
389
- tdd_ordering?: TddOrderingConfig;
390
- };
391
- };
392
- }
393
-
394
- interface PolicyConfigInput {
395
- methodology?: MethodologyConfig;
396
- gates: {
397
- minCoverage: number;
398
- enableCoverage: boolean;
399
- tdd_diff_evidence?: TddDiffEvidenceConfig;
400
- tdd_ordering?: TddOrderingConfig;
401
- };
402
- }
403
-
404
- function resolveDefaultTddDiffEvidenceMode(testing: TestingMethodology): CoverageMode {
405
- return testing === TESTING_METHODOLOGY.TDD ? COVERAGE_MODE.BLOCK : COVERAGE_MODE.OFF;
406
- }
407
-
408
- function cloneWuTypes(value: readonly WUType[] | undefined): WUType[] {
409
- return [...(value ?? DEFAULT_TDD_DIFF_APPLIES_TO_TYPES)];
410
- }
411
-
412
- function cloneExemptPaths(value: readonly string[] | undefined): string[] {
413
- return [...(value ?? DEFAULT_TDD_DIFF_EXEMPT_PATHS)];
414
- }
415
-
416
- function cloneTestFilePatterns(value: readonly string[] | undefined): string[] {
417
- return [...(value ?? DEFAULT_TDD_DIFF_TEST_FILE_PATTERNS)];
418
- }
419
-
420
- function cloneCodeFileExtensions(value: readonly string[] | undefined): string[] {
421
- return [...(value ?? DEFAULT_TDD_DIFF_CODE_FILE_EXTENSIONS)];
422
- }
423
-
424
- function resolveTddDiffEvidencePolicy(
425
- testing: TestingMethodology,
426
- config: TddDiffEvidenceConfig | undefined,
427
- ): TddDiffEvidencePolicy {
428
- return {
429
- mode: config?.mode ?? resolveDefaultTddDiffEvidenceMode(testing),
430
- applies_to_types: cloneWuTypes(config?.applies_to_types),
431
- exempt_paths: cloneExemptPaths(config?.exempt_paths),
432
- test_file_patterns: cloneTestFilePatterns(config?.test_file_patterns),
433
- code_file_extensions: cloneCodeFileExtensions(config?.code_file_extensions),
434
- };
435
- }
436
-
437
- /**
438
- * WU-2650: Resolve the commit-order policy. Defaults mirror the diff-evidence
439
- * policy: enforce under TDD, off otherwise; applies to feature/bug only.
440
- */
441
- function resolveTddOrderingPolicyInternal(
442
- testing: TestingMethodology,
443
- config: TddOrderingConfig | undefined,
444
- ): TddOrderingPolicy {
445
- return {
446
- mode: config?.mode ?? resolveDefaultTddDiffEvidenceMode(testing),
447
- applies_to_types: cloneWuTypes(config?.applies_to_types),
448
- min_runtime_loc_per_commit_without_tests:
449
- config?.min_runtime_loc_per_commit_without_tests ?? DEFAULT_TDD_ORDERING_MIN_RUNTIME_LOC,
450
- grace_commits: config?.grace_commits ?? DEFAULT_TDD_ORDERING_GRACE_COMMITS,
451
- exempt_paths: cloneExemptPaths(config?.exempt_paths),
452
- };
453
- }
454
-
455
- /**
456
- * Resolve the effective policy from configuration
457
- *
458
- * Precedence (highest to lowest):
459
- * 1. CLI flags (not handled here - handled by command layer)
460
- * 2. Explicit gates.* configuration (only if rawConfig provided to detect explicit vs default)
461
- * 3. methodology.overrides
462
- * 4. methodology template defaults
463
- *
464
- * This ensures backwards compatibility: existing users with explicit
465
- * gates.* config see no change, while new users can use methodology
466
- * config for a higher-level abstraction.
467
- *
468
- * @param config - The full LumenFlow configuration
469
- * @param options - Options including rawConfig for explicit detection
470
- * @returns The resolved policy for use by wu:spawn and gates
471
- *
472
- * @example
473
- * ```typescript
474
- * import { getConfig } from './lumenflow-config.js';
475
- * import { resolvePolicy } from './resolve-policy.js';
476
- *
477
- * const config = getConfig();
478
- * const policy = resolvePolicy(config);
479
- *
480
- * console.log(policy.coverage_threshold); // 90 (or configured value)
481
- * console.log(policy.testing); // 'tdd' (or configured value)
482
- * ```
483
- *
484
- * @example With raw config for explicit detection
485
- * ```typescript
486
- * const rawConfig = { methodology: { testing: 'test-after' } };
487
- * const config = parseConfig(rawConfig);
488
- * const policy = resolvePolicy(config, { rawConfig });
489
- * // policy.coverage_threshold will be 70 (test-after template default)
490
- * // because gates.minCoverage wasn't EXPLICITLY set
491
- * ```
492
- */
493
- export function resolvePolicy(
494
- config: PolicyConfigInput,
495
- options: ResolvePolicyOptions = {},
496
- ): ResolvedPolicy {
497
- const { rawConfig } = options;
498
-
499
- // Parse methodology config (provides defaults if not specified)
500
- const methodology = MethodologyConfigSchema.parse(config.methodology ?? {});
501
-
502
- // Get template defaults based on testing methodology
503
- const templateDefaults = TESTING_TEMPLATE_DEFAULTS[methodology.testing];
504
-
505
- // Layer 1: Start with template defaults
506
- let coverage_threshold = templateDefaults.coverage_threshold;
507
- let coverage_mode = templateDefaults.coverage_mode;
508
- const tests_required = templateDefaults.tests_required;
509
-
510
- // Layer 2: Apply methodology.overrides (if specified)
511
- if (methodology.overrides?.coverage_threshold !== undefined) {
512
- coverage_threshold = methodology.overrides.coverage_threshold;
513
- }
514
- if (methodology.overrides?.coverage_mode !== undefined) {
515
- coverage_mode = methodology.overrides.coverage_mode;
516
- }
517
-
518
- // Layer 3: Apply explicit gates.* configuration (highest precedence)
519
- // This ensures backwards compatibility with existing gates config
520
- //
521
- // Key insight: We only want EXPLICIT gates.* to override methodology.
522
- // If rawConfig is provided, we check if gates values were explicitly set.
523
- // If rawConfig is NOT provided (legacy mode), we check if methodology
524
- // was specified - if so, methodology controls unless gates differ from default.
525
-
526
- const gates = config.gates;
527
-
528
- // Determine if gates.minCoverage was explicitly set
529
- const gatesMinCoverageExplicit =
530
- rawConfig !== undefined ? rawConfig.gates?.minCoverage !== undefined : false;
531
-
532
- // Determine if gates.enableCoverage was explicitly set
533
- const gatesEnableCoverageExplicit =
534
- rawConfig !== undefined ? rawConfig.gates?.enableCoverage !== undefined : false;
535
-
536
- // Apply gates.minCoverage only if explicitly set, or if no methodology was specified
537
- // (for backwards compatibility with pre-methodology configs)
538
- const methodologySpecified = config.methodology !== undefined;
539
-
540
- if (gatesMinCoverageExplicit || (!methodologySpecified && rawConfig === undefined)) {
541
- // gates.minCoverage overrides methodology coverage_threshold
542
- coverage_threshold = gates.minCoverage;
543
- }
544
-
545
- // gates.enableCoverage: false effectively sets coverage_mode to 'off'
546
- if (gatesEnableCoverageExplicit || (!methodologySpecified && rawConfig === undefined)) {
547
- if (gates?.enableCoverage === false) {
548
- coverage_mode = 'off';
549
- }
550
- }
551
-
552
- const tdd_diff_evidence = resolveTddDiffEvidencePolicy(
553
- methodology.testing,
554
- config.gates?.tdd_diff_evidence,
555
- );
556
-
557
- const tdd_ordering = resolveTddOrderingPolicyInternal(
558
- methodology.testing,
559
- config.gates?.tdd_ordering,
560
- );
561
-
562
- return {
563
- testing: methodology.testing,
564
- architecture: methodology.architecture,
565
- coverage_threshold,
566
- coverage_mode,
567
- tests_required,
568
- tdd_diff_evidence,
569
- tdd_ordering,
570
- };
571
- }
572
-
573
- /**
574
- * Create a default resolved policy
575
- *
576
- * Convenience function for when no config is available.
577
- * Returns strict TDD defaults.
578
- */
579
- export function getDefaultPolicy(): ResolvedPolicy {
580
- return {
581
- testing: 'tdd',
582
- architecture: 'hexagonal',
583
- coverage_threshold: 90,
584
- coverage_mode: 'block',
585
- tests_required: true,
586
- tdd_diff_evidence: {
587
- mode: COVERAGE_MODE.BLOCK,
588
- applies_to_types: [...DEFAULT_TDD_DIFF_APPLIES_TO_TYPES],
589
- exempt_paths: [...DEFAULT_TDD_DIFF_EXEMPT_PATHS],
590
- test_file_patterns: [...DEFAULT_TDD_DIFF_TEST_FILE_PATTERNS],
591
- code_file_extensions: [...DEFAULT_TDD_DIFF_CODE_FILE_EXTENSIONS],
592
- },
593
- tdd_ordering: {
594
- mode: COVERAGE_MODE.BLOCK,
595
- applies_to_types: [...DEFAULT_TDD_DIFF_APPLIES_TO_TYPES],
596
- min_runtime_loc_per_commit_without_tests: DEFAULT_TDD_ORDERING_MIN_RUNTIME_LOC,
597
- grace_commits: DEFAULT_TDD_ORDERING_GRACE_COMMITS,
598
- exempt_paths: [...DEFAULT_TDD_DIFF_EXEMPT_PATHS],
599
- },
600
- };
601
- }
@@ -1,90 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * Configuration Ports (WU-2020)
6
- *
7
- * Focused interfaces for injecting configuration sections into command
8
- * handlers and service functions. These replace module-level getConfig()
9
- * calls with explicit parameter injection (DIP compliance).
10
- *
11
- * Each interface extracts the minimum config surface needed by its
12
- * consumers, following the Interface Segregation Principle (ISP).
13
- *
14
- * @module ports/config
15
- */
16
-
17
- /**
18
- * Git-related configuration for branch checks and worktree operations.
19
- *
20
- * Consumers: branch-check.ts, micro-worktree-shared.ts, micro-worktree.ts
21
- */
22
- export interface IGitConfig {
23
- readonly mainBranch: string;
24
- readonly defaultRemote: string;
25
- readonly requireRemote: boolean;
26
- readonly laneBranchPrefix?: string;
27
- readonly agentBranchPatterns?: string[];
28
- readonly agentBranchPatternsOverride?: string[];
29
- readonly disableAgentPatternRegistry?: boolean;
30
- readonly pushRetry?: {
31
- readonly enabled: boolean;
32
- readonly retries: number;
33
- readonly min_delay_ms: number;
34
- readonly max_delay_ms: number;
35
- readonly jitter: boolean;
36
- };
37
- }
38
-
39
- /**
40
- * Directory paths configuration for WU file resolution.
41
- *
42
- * Consumers: wu-paths.ts, wu-list.ts, spawn-task-builder.ts
43
- */
44
- export interface IDirectoriesConfig {
45
- readonly wuDir: string;
46
- readonly initiativesDir: string;
47
- readonly backlogPath: string;
48
- readonly statusPath: string;
49
- readonly worktrees: string;
50
- readonly stampsDir?: string;
51
- readonly plansDir: string;
52
- readonly templatesDir: string;
53
- readonly onboardingDir: string;
54
- readonly skillsDir: string;
55
- readonly agentsDir: string;
56
- readonly memoryBank: string;
57
- readonly safeGitPath: string;
58
- }
59
-
60
- /**
61
- * State paths configuration for store directory resolution.
62
- *
63
- * Consumers: wu-paths.ts, wu-backlog-updater.ts
64
- */
65
- export interface IStateConfig {
66
- readonly base: string;
67
- readonly stampsDir: string;
68
- readonly stateDir: string;
69
- }
70
-
71
- /**
72
- * Minimal config interface for path-resolution consumers.
73
- *
74
- * Consumers that only need directory and state paths should depend
75
- * on this interface rather than the full LumenFlowConfig.
76
- */
77
- export interface IPathsConfig {
78
- readonly directories: IDirectoriesConfig;
79
- readonly state: IStateConfig;
80
- }
81
-
82
- /**
83
- * Minimal config interface for git-operation consumers.
84
- *
85
- * Consumers that only need git configuration should depend on this
86
- * interface rather than the full LumenFlowConfig.
87
- */
88
- export interface IGitOperationConfig {
89
- readonly git: IGitConfig;
90
- }