@lumenflow/core 2.2.2 → 2.3.2

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 (213) hide show
  1. package/dist/active-wu-detector.d.ts +1 -1
  2. package/dist/active-wu-detector.js +1 -1
  3. package/dist/arg-parser.js +51 -18
  4. package/dist/backlog-generator.d.ts +4 -4
  5. package/dist/backlog-generator.js +4 -4
  6. package/dist/backlog-sync-validator.js +1 -1
  7. package/dist/cleanup-lock.d.ts +9 -2
  8. package/dist/cleanup-lock.js +17 -7
  9. package/dist/code-path-validator.d.ts +3 -3
  10. package/dist/code-path-validator.js +3 -3
  11. package/dist/compliance-parser.d.ts +1 -1
  12. package/dist/compliance-parser.js +1 -1
  13. package/dist/constants/backlog-patterns.d.ts +1 -1
  14. package/dist/constants/backlog-patterns.js +1 -1
  15. package/dist/constants/dora-constants.d.ts +1 -1
  16. package/dist/constants/dora-constants.js +1 -1
  17. package/dist/constants/gate-constants.d.ts +1 -1
  18. package/dist/constants/gate-constants.js +1 -1
  19. package/dist/constants/linter-constants.d.ts +1 -1
  20. package/dist/constants/linter-constants.js +1 -1
  21. package/dist/constants/tokenizer-constants.d.ts +1 -1
  22. package/dist/constants/tokenizer-constants.js +1 -1
  23. package/dist/context/location-resolver.js +2 -1
  24. package/dist/context-validation-integration.d.ts +1 -0
  25. package/dist/core/scope-checker.d.ts +3 -3
  26. package/dist/core/scope-checker.js +3 -3
  27. package/dist/core/tool-runner.d.ts +5 -5
  28. package/dist/core/tool-runner.js +5 -5
  29. package/dist/core/tool.constants.d.ts +1 -1
  30. package/dist/core/tool.constants.js +1 -1
  31. package/dist/core/tool.schemas.d.ts +2 -2
  32. package/dist/core/tool.schemas.js +1 -1
  33. package/dist/core/worktree-guard.d.ts +1 -1
  34. package/dist/core/worktree-guard.js +1 -1
  35. package/dist/coverage-gate.d.ts +12 -3
  36. package/dist/coverage-gate.js +15 -8
  37. package/dist/date-utils.d.ts +4 -4
  38. package/dist/date-utils.js +4 -4
  39. package/dist/dependency-graph.d.ts +6 -0
  40. package/dist/dependency-graph.js +43 -2
  41. package/dist/dependency-guard.d.ts +2 -2
  42. package/dist/dependency-guard.js +3 -3
  43. package/dist/dependency-validator.d.ts +4 -4
  44. package/dist/dependency-validator.js +4 -7
  45. package/dist/domain/orchestration.constants.d.ts +31 -10
  46. package/dist/domain/orchestration.constants.js +45 -16
  47. package/dist/domain/orchestration.schemas.d.ts +54 -28
  48. package/dist/domain/orchestration.schemas.js +2 -2
  49. package/dist/domain/orchestration.types.d.ts +2 -2
  50. package/dist/domain/orchestration.types.js +2 -2
  51. package/dist/error-handler.d.ts +10 -10
  52. package/dist/error-handler.js +10 -10
  53. package/dist/file-classifiers.d.ts +6 -6
  54. package/dist/file-classifiers.js +6 -6
  55. package/dist/gates-config.d.ts +74 -0
  56. package/dist/gates-config.js +209 -2
  57. package/dist/git-adapter.d.ts +11 -11
  58. package/dist/git-adapter.js +11 -11
  59. package/dist/git-context-extractor.d.ts +112 -0
  60. package/dist/git-context-extractor.js +559 -0
  61. package/dist/hardcoded-strings.d.ts +1 -1
  62. package/dist/hardcoded-strings.js +1 -1
  63. package/dist/incremental-lint.d.ts +1 -1
  64. package/dist/incremental-lint.js +2 -2
  65. package/dist/incremental-test.d.ts +1 -1
  66. package/dist/incremental-test.js +1 -1
  67. package/dist/index.d.ts +13 -0
  68. package/dist/index.js +25 -0
  69. package/dist/invariants/check-automated-tests.d.ts +2 -2
  70. package/dist/invariants/check-automated-tests.js +3 -3
  71. package/dist/lane-checker.d.ts +28 -7
  72. package/dist/lane-checker.js +316 -159
  73. package/dist/lane-suggest-prompt.d.ts +108 -0
  74. package/dist/lane-suggest-prompt.js +359 -0
  75. package/dist/lane-validator.d.ts +3 -3
  76. package/dist/lane-validator.js +3 -3
  77. package/dist/logs-lib.d.ts +1 -1
  78. package/dist/logs-lib.js +1 -1
  79. package/dist/lumenflow-config-schema.d.ts +162 -0
  80. package/dist/lumenflow-config-schema.js +180 -0
  81. package/dist/manual-test-validator.d.ts +2 -2
  82. package/dist/manual-test-validator.js +3 -3
  83. package/dist/merge-lock.d.ts +8 -1
  84. package/dist/merge-lock.js +16 -7
  85. package/dist/micro-worktree.d.ts +81 -13
  86. package/dist/micro-worktree.js +98 -17
  87. package/dist/migration-deployer.d.ts +1 -1
  88. package/dist/migration-deployer.js +1 -1
  89. package/dist/orchestration-advisory-loader.d.ts +2 -2
  90. package/dist/orchestration-advisory-loader.js +10 -6
  91. package/dist/orchestration-advisory.d.ts +3 -3
  92. package/dist/orchestration-advisory.js +4 -4
  93. package/dist/orchestration-di.d.ts +4 -4
  94. package/dist/orchestration-di.js +4 -4
  95. package/dist/orchestration-rules.d.ts +4 -4
  96. package/dist/orchestration-rules.js +18 -10
  97. package/dist/orphan-detector.d.ts +3 -3
  98. package/dist/orphan-detector.js +3 -3
  99. package/dist/patrol-loop.d.ts +170 -0
  100. package/dist/patrol-loop.js +186 -0
  101. package/dist/process-detector.d.ts +5 -5
  102. package/dist/process-detector.js +5 -5
  103. package/dist/rebase-artifact-cleanup.d.ts +3 -3
  104. package/dist/rebase-artifact-cleanup.js +3 -3
  105. package/dist/resolve-policy.d.ts +195 -0
  106. package/dist/resolve-policy.js +203 -0
  107. package/dist/risk-detector.d.ts +2 -2
  108. package/dist/risk-detector.js +2 -2
  109. package/dist/rollback-utils.d.ts +1 -1
  110. package/dist/rollback-utils.js +1 -1
  111. package/dist/section-headings.d.ts +1 -1
  112. package/dist/section-headings.js +1 -1
  113. package/dist/spawn-escalation.d.ts +4 -4
  114. package/dist/spawn-escalation.js +3 -3
  115. package/dist/spawn-monitor.d.ts +4 -4
  116. package/dist/spawn-monitor.js +4 -4
  117. package/dist/spawn-recovery.d.ts +3 -3
  118. package/dist/spawn-recovery.js +3 -3
  119. package/dist/spawn-registry-schema.d.ts +2 -2
  120. package/dist/spawn-registry-schema.js +2 -2
  121. package/dist/spawn-registry-store.d.ts +2 -2
  122. package/dist/spawn-registry-store.js +2 -2
  123. package/dist/spawn-strategy.d.ts +17 -11
  124. package/dist/spawn-strategy.js +47 -44
  125. package/dist/spawn-tree.d.ts +3 -3
  126. package/dist/spawn-tree.js +3 -3
  127. package/dist/state-cleanup-core.d.ts +205 -0
  128. package/dist/state-cleanup-core.js +240 -0
  129. package/dist/state-doctor-core.d.ts +168 -0
  130. package/dist/state-doctor-core.js +251 -0
  131. package/dist/stream-error-handler.d.ts +67 -0
  132. package/dist/stream-error-handler.js +94 -0
  133. package/dist/telemetry.d.ts +1 -1
  134. package/dist/telemetry.js +1 -1
  135. package/dist/template-loader.d.ts +162 -0
  136. package/dist/template-loader.js +372 -0
  137. package/dist/test-baseline.d.ts +176 -0
  138. package/dist/test-baseline.js +282 -0
  139. package/dist/usecases/get-suggestions.usecase.d.ts +1 -1
  140. package/dist/validation/command-registry.js +37 -0
  141. package/dist/validators/backlog-sync.js +4 -2
  142. package/dist/worktree-scanner.d.ts +1 -1
  143. package/dist/worktree-scanner.js +1 -1
  144. package/dist/worktree-symlink.d.ts +3 -3
  145. package/dist/worktree-symlink.js +3 -3
  146. package/dist/wu-backlog-updater.d.ts +1 -1
  147. package/dist/wu-backlog-updater.js +1 -1
  148. package/dist/wu-claim-helpers.d.ts +1 -1
  149. package/dist/wu-claim-helpers.js +1 -1
  150. package/dist/wu-claim-resume.d.ts +1 -1
  151. package/dist/wu-claim-resume.js +1 -1
  152. package/dist/wu-consistency-checker.d.ts +1 -1
  153. package/dist/wu-consistency-checker.js +17 -11
  154. package/dist/wu-constants.d.ts +73 -21
  155. package/dist/wu-constants.js +65 -22
  156. package/dist/wu-done-branch-only.d.ts +1 -1
  157. package/dist/wu-done-branch-only.js +1 -1
  158. package/dist/wu-done-docs-generate.d.ts +1 -1
  159. package/dist/wu-done-docs-generate.js +1 -1
  160. package/dist/wu-done-messages.d.ts +2 -2
  161. package/dist/wu-done-messages.js +2 -2
  162. package/dist/wu-done-metadata.d.ts +3 -3
  163. package/dist/wu-done-metadata.js +3 -3
  164. package/dist/wu-done-pr.d.ts +1 -1
  165. package/dist/wu-done-pr.js +4 -2
  166. package/dist/wu-done-preflight.d.ts +8 -0
  167. package/dist/wu-done-preflight.js +18 -2
  168. package/dist/wu-done-ui.d.ts +3 -3
  169. package/dist/wu-done-ui.js +3 -3
  170. package/dist/wu-done-validation.d.ts +30 -0
  171. package/dist/wu-done-validation.js +106 -1
  172. package/dist/wu-done-worktree.d.ts +1 -1
  173. package/dist/wu-done-worktree.js +11 -1
  174. package/dist/wu-events-cleanup.d.ts +148 -0
  175. package/dist/wu-events-cleanup.js +401 -0
  176. package/dist/wu-helpers.d.ts +2 -2
  177. package/dist/wu-helpers.js +2 -2
  178. package/dist/wu-id-generator.d.ts +58 -0
  179. package/dist/wu-id-generator.js +103 -0
  180. package/dist/wu-lint.js +1 -1
  181. package/dist/wu-preflight-validators.d.ts +13 -1
  182. package/dist/wu-preflight-validators.js +56 -1
  183. package/dist/wu-recovery.d.ts +2 -2
  184. package/dist/wu-recovery.js +4 -4
  185. package/dist/wu-repair-core.d.ts +5 -5
  186. package/dist/wu-repair-core.js +6 -6
  187. package/dist/wu-schema-normalization.d.ts +1 -1
  188. package/dist/wu-schema-normalization.js +1 -1
  189. package/dist/wu-schema.d.ts +7 -7
  190. package/dist/wu-schema.js +8 -8
  191. package/dist/wu-spawn-context.d.ts +87 -0
  192. package/dist/wu-spawn-context.js +175 -0
  193. package/dist/wu-spawn-helpers.d.ts +1 -1
  194. package/dist/wu-spawn-helpers.js +1 -1
  195. package/dist/wu-spawn.d.ts +177 -4
  196. package/dist/wu-spawn.js +694 -72
  197. package/dist/wu-state-schema.d.ts +1 -1
  198. package/dist/wu-state-schema.js +1 -1
  199. package/dist/wu-state-store.d.ts +3 -3
  200. package/dist/wu-state-store.js +3 -3
  201. package/dist/wu-status-transition.d.ts +1 -1
  202. package/dist/wu-status-transition.js +1 -1
  203. package/dist/wu-status-updater.d.ts +3 -3
  204. package/dist/wu-status-updater.js +3 -3
  205. package/dist/wu-validation-constants.d.ts +2 -2
  206. package/dist/wu-validation-constants.js +2 -2
  207. package/dist/wu-validation.d.ts +3 -3
  208. package/dist/wu-validation.js +3 -3
  209. package/dist/wu-yaml-fixer.d.ts +2 -2
  210. package/dist/wu-yaml-fixer.js +3 -3
  211. package/dist/wu-yaml.d.ts +23 -0
  212. package/dist/wu-yaml.js +76 -2
  213. package/package.json +5 -2
@@ -5,8 +5,8 @@
5
5
  * Single source of truth - types are inferred from these schemas.
6
6
  *
7
7
  * @module orchestration.schemas
8
- * @see {@link ./orchestration.types.mjs} - Types inferred from these schemas
9
- * @see {@link ./orchestration.constants.mjs} - Constants used in validation
8
+ * @see {@link ./orchestration.types.ts} - Types inferred from these schemas
9
+ * @see {@link ./orchestration.constants.ts} - Constants used in validation
10
10
  */
11
11
  import { z } from 'zod';
12
12
  import { LANES, AGENT_NAMES, SEVERITY_LEVELS, AGENT_RESULT_STATUSES, TIMELINE_EVENT_TYPES, EVENT_SEVERITY_LEVELS, USER_CHOICE_OPTIONS, DOD_TOTAL, } from './orchestration.constants.js';
@@ -5,8 +5,8 @@
5
5
  * Single source of truth - schemas validate at runtime, types at compile time.
6
6
  *
7
7
  * @module orchestration.types
8
- * @see {@link ./orchestration.schemas.mjs} - Schemas these types are inferred from
9
- * @see {@link ./orchestration.constants.mjs} - Constants and derived types
8
+ * @see {@link ./orchestration.schemas.ts} - Schemas these types are inferred from
9
+ * @see {@link ./orchestration.constants.ts} - Constants and derived types
10
10
  */
11
11
  import type { z } from 'zod';
12
12
  import type { GlobalStatusSchema, AgentMetricSchema, WUProgressSchema, TimelineEventSchema, AlertSchema, SuggestionSchema, ExecutionPlanSchema, UserChoiceSchema, DashboardDataSchema } from './orchestration.schemas.js';
@@ -5,8 +5,8 @@
5
5
  * Single source of truth - schemas validate at runtime, types at compile time.
6
6
  *
7
7
  * @module orchestration.types
8
- * @see {@link ./orchestration.schemas.mjs} - Schemas these types are inferred from
9
- * @see {@link ./orchestration.constants.mjs} - Constants and derived types
8
+ * @see {@link ./orchestration.schemas.ts} - Schemas these types are inferred from
9
+ * @see {@link ./orchestration.constants.ts} - Constants and derived types
10
10
  */
11
11
  // Re-export const values as well
12
12
  export { LANES, AGENT_NAMES, SEVERITY_LEVELS, AGENT_RESULT_STATUSES, TIMELINE_EVENT_TYPES, EVENT_SEVERITY_LEVELS, USER_CHOICE_OPTIONS, MANDATORY_AGENT_NAMES, } from './orchestration.constants.js';
@@ -1,19 +1,19 @@
1
1
  /**
2
- * @file error-handler.mjs
2
+ * @file error-handler.ts
3
3
  * @description Structured error handling with error codes
4
4
  * WU-1082: Extract shared utilities (eliminate die() duplication)
5
5
  * WU-1006: Library-First - use path.basename() instead of manual split
6
6
  *
7
7
  * Replaces die() function in:
8
- * - tools/wu-claim.mjs
9
- * - tools/wu-done.mjs
10
- * - tools/wu-block.mjs
11
- * - tools/wu-unblock.mjs
12
- * - tools/wu-create.mjs
13
- * - tools/wu-cleanup.mjs
14
- * - tools/gates-pre-commit.mjs
15
- * - tools/validate.mjs
16
- * - tools/guard-worktree-commit.mjs
8
+ * - tools/wu-claim.ts
9
+ * - tools/wu-done.ts
10
+ * - tools/wu-block.ts
11
+ * - tools/wu-unblock.ts
12
+ * - tools/wu-create.ts
13
+ * - tools/wu-cleanup.ts
14
+ * - tools/gates-pre-commit.ts
15
+ * - tools/validate.ts
16
+ * - tools/guard-worktree-commit.ts
17
17
  */
18
18
  /**
19
19
  * Structured error class with error codes and details
@@ -1,19 +1,19 @@
1
1
  /**
2
- * @file error-handler.mjs
2
+ * @file error-handler.ts
3
3
  * @description Structured error handling with error codes
4
4
  * WU-1082: Extract shared utilities (eliminate die() duplication)
5
5
  * WU-1006: Library-First - use path.basename() instead of manual split
6
6
  *
7
7
  * Replaces die() function in:
8
- * - tools/wu-claim.mjs
9
- * - tools/wu-done.mjs
10
- * - tools/wu-block.mjs
11
- * - tools/wu-unblock.mjs
12
- * - tools/wu-create.mjs
13
- * - tools/wu-cleanup.mjs
14
- * - tools/gates-pre-commit.mjs
15
- * - tools/validate.mjs
16
- * - tools/guard-worktree-commit.mjs
8
+ * - tools/wu-claim.ts
9
+ * - tools/wu-done.ts
10
+ * - tools/wu-block.ts
11
+ * - tools/wu-unblock.ts
12
+ * - tools/wu-create.ts
13
+ * - tools/wu-cleanup.ts
14
+ * - tools/gates-pre-commit.ts
15
+ * - tools/validate.ts
16
+ * - tools/guard-worktree-commit.ts
17
17
  */
18
18
  import path from 'node:path';
19
19
  /**
@@ -3,13 +3,13 @@
3
3
  * File Classifiers
4
4
  *
5
5
  * Shared utilities for classifying file types.
6
- * Consolidates duplicated classification logic from wu-validator.mjs
7
- * and code-path-validator.mjs.
6
+ * Consolidates duplicated classification logic from wu-validator.ts
7
+ * and code-path-validator.ts.
8
8
  *
9
9
  * WU-1848: DRY Consolidation - Eliminate duplicated code patterns
10
10
  *
11
- * @see tools/lib/wu-validator.mjs - Original isTestFile, isMarkdownFile
12
- * @see tools/lib/code-path-validator.mjs - Duplicated implementations
11
+ * @see tools/lib/wu-validator.ts - Original isTestFile, isMarkdownFile
12
+ * @see tools/lib/code-path-validator.ts - Duplicated implementations
13
13
  */
14
14
  /**
15
15
  * Prefixes for paths that qualify as documentation-only.
@@ -30,8 +30,8 @@ declare const TEST_FILE_PATTERNS: readonly RegExp[];
30
30
  * Check if a file path is a test file
31
31
  *
32
32
  * Detects test files by extension and directory patterns:
33
- * - *.test.ts, *.test.tsx, *.test.js, *.test.jsx, *.test.mjs
34
- * - *.spec.ts, *.spec.tsx, *.spec.js, *.spec.jsx, *.spec.mjs
33
+ * - *.test.ts, *.test.tsx, *.test.js, *.test.jsx, *.test.ts
34
+ * - *.spec.ts, *.spec.tsx, *.spec.js, *.spec.jsx, *.spec.ts
35
35
  * - Files in __tests__ directories
36
36
  * - *.test-utils.* files
37
37
  * - *.mock.* files
@@ -3,13 +3,13 @@
3
3
  * File Classifiers
4
4
  *
5
5
  * Shared utilities for classifying file types.
6
- * Consolidates duplicated classification logic from wu-validator.mjs
7
- * and code-path-validator.mjs.
6
+ * Consolidates duplicated classification logic from wu-validator.ts
7
+ * and code-path-validator.ts.
8
8
  *
9
9
  * WU-1848: DRY Consolidation - Eliminate duplicated code patterns
10
10
  *
11
- * @see tools/lib/wu-validator.mjs - Original isTestFile, isMarkdownFile
12
- * @see tools/lib/code-path-validator.mjs - Duplicated implementations
11
+ * @see tools/lib/wu-validator.ts - Original isTestFile, isMarkdownFile
12
+ * @see tools/lib/code-path-validator.ts - Duplicated implementations
13
13
  */
14
14
  /**
15
15
  * Prefixes for paths that qualify as documentation-only.
@@ -36,8 +36,8 @@ const TEST_FILE_PATTERNS = Object.freeze([
36
36
  * Check if a file path is a test file
37
37
  *
38
38
  * Detects test files by extension and directory patterns:
39
- * - *.test.ts, *.test.tsx, *.test.js, *.test.jsx, *.test.mjs
40
- * - *.spec.ts, *.spec.tsx, *.spec.js, *.spec.jsx, *.spec.mjs
39
+ * - *.test.ts, *.test.tsx, *.test.js, *.test.jsx, *.test.ts
40
+ * - *.spec.ts, *.spec.tsx, *.spec.js, *.spec.jsx, *.spec.ts
41
41
  * - Files in __tests__ directories
42
42
  * - *.test-utils.* files
43
43
  * - *.mock.* files
@@ -10,6 +10,7 @@
10
10
  * @module gates-config
11
11
  */
12
12
  import { z } from 'zod';
13
+ import { type CoverageMode } from './resolve-policy.js';
13
14
  /**
14
15
  * Schema for a gate command - either a string or an object with options
15
16
  */
@@ -130,3 +131,76 @@ export declare function resolveGatesConfig(projectRoot: string): GatesExecutionC
130
131
  * @returns True if the gate should be skipped
131
132
  */
132
133
  export declare function shouldSkipGate(gateName: keyof Omit<GatesExecutionConfig, 'preset' | 'coverage'>, config: GatesExecutionConfig, skipFlags: Record<string, boolean>): boolean;
134
+ /**
135
+ * WU-1191: Lane health gate mode
136
+ * Controls how lane health check behaves during gates
137
+ */
138
+ export type LaneHealthMode = 'warn' | 'error' | 'off';
139
+ /**
140
+ * WU-1191: Load lane health configuration from .lumenflow.config.yaml
141
+ *
142
+ * Configuration format:
143
+ * ```yaml
144
+ * gates:
145
+ * lane_health: warn|error|off
146
+ * ```
147
+ *
148
+ * @param projectRoot - Project root directory
149
+ * @returns Lane health mode ('warn', 'error', or 'off'), defaults to 'warn'
150
+ */
151
+ export declare function loadLaneHealthConfig(projectRoot: string): LaneHealthMode;
152
+ /**
153
+ * WU-1262: Resolved coverage configuration
154
+ * Contains threshold and mode derived from methodology policy
155
+ */
156
+ export interface CoverageConfig {
157
+ /** Coverage threshold (0-100) */
158
+ threshold: number;
159
+ /** Coverage mode (block, warn, or off) */
160
+ mode: CoverageMode;
161
+ }
162
+ /**
163
+ * WU-1262: Resolve coverage configuration from methodology policy
164
+ *
165
+ * Uses resolvePolicy() to determine coverage defaults based on methodology.testing:
166
+ * - tdd: 90% threshold, block mode
167
+ * - test-after: 70% threshold, warn mode
168
+ * - none: 0% threshold, off mode
169
+ *
170
+ * Precedence (highest to lowest):
171
+ * 1. Explicit gates.minCoverage / gates.enableCoverage
172
+ * 2. methodology.overrides.coverage_threshold / coverage_mode
173
+ * 3. methodology.testing template defaults
174
+ *
175
+ * @param projectRoot - Project root directory
176
+ * @returns Resolved coverage configuration
177
+ */
178
+ export declare function resolveCoverageConfig(projectRoot: string): CoverageConfig;
179
+ /**
180
+ * WU-1280: Resolved test policy configuration
181
+ * Extends CoverageConfig with tests_required from methodology policy
182
+ */
183
+ export interface TestPolicy extends CoverageConfig {
184
+ /** Whether tests are required for completion (from methodology.testing) */
185
+ tests_required: boolean;
186
+ }
187
+ /**
188
+ * WU-1280: Resolve test policy from methodology configuration
189
+ *
190
+ * Returns the full test policy including coverage config AND tests_required.
191
+ * This is used by gates to determine whether test failures should block or warn.
192
+ *
193
+ * Methodology mapping:
194
+ * - tdd: 90% threshold, block mode, tests_required=true
195
+ * - test-after: 70% threshold, warn mode, tests_required=true
196
+ * - none: 0% threshold, off mode, tests_required=false
197
+ *
198
+ * When tests_required=false:
199
+ * - Test failures produce WARNINGS instead of FAILURES
200
+ * - Gates continue but log the test failures
201
+ * - Coverage gate is effectively skipped (mode='off')
202
+ *
203
+ * @param projectRoot - Project root directory
204
+ * @returns Resolved test policy including tests_required
205
+ */
206
+ export declare function resolveTestPolicy(projectRoot: string): TestPolicy;
@@ -13,6 +13,13 @@ import * as fs from 'node:fs';
13
13
  import * as path from 'node:path';
14
14
  import * as yaml from 'yaml';
15
15
  import { z } from 'zod';
16
+ // WU-1262: Import resolvePolicy for methodology-driven coverage defaults
17
+ // Note: resolvePolicy uses type-only import from lumenflow-config-schema, avoiding circular dependency
18
+ import { resolvePolicy, getDefaultPolicy, MethodologyConfigSchema, } from './resolve-policy.js';
19
+ /**
20
+ * Config file name constant to avoid duplicate string literals
21
+ */
22
+ const CONFIG_FILE_NAME = '.lumenflow.config.yaml';
16
23
  /**
17
24
  * Default timeout for gate commands (2 minutes)
18
25
  */
@@ -160,7 +167,7 @@ export function expandPreset(preset) {
160
167
  * @returns Gates execution config, or null if not configured
161
168
  */
162
169
  export function loadGatesConfig(projectRoot) {
163
- const configPath = path.join(projectRoot, '.lumenflow.config.yaml');
170
+ const configPath = path.join(projectRoot, CONFIG_FILE_NAME);
164
171
  if (!fs.existsSync(configPath)) {
165
172
  return null;
166
173
  }
@@ -175,6 +182,7 @@ export function loadGatesConfig(projectRoot) {
175
182
  // Validate the config
176
183
  const result = GatesExecutionConfigSchema.safeParse(executionConfig);
177
184
  if (!result.success) {
185
+ // eslint-disable-next-line no-console -- Intentional warning for invalid config
178
186
  console.warn('Warning: Invalid gates.execution config:', result.error.message);
179
187
  return null;
180
188
  }
@@ -187,7 +195,8 @@ export function loadGatesConfig(projectRoot) {
187
195
  return merged;
188
196
  }
189
197
  catch (error) {
190
- console.warn('Warning: Failed to parse .lumenflow.config.yaml:', error instanceof Error ? error.message : String(error));
198
+ // eslint-disable-next-line no-console -- Intentional warning for parse failure
199
+ console.warn(`Warning: Failed to parse ${CONFIG_FILE_NAME}:`, error instanceof Error ? error.message : String(error));
191
200
  return null;
192
201
  }
193
202
  }
@@ -246,3 +255,201 @@ export function shouldSkipGate(gateName, config, skipFlags) {
246
255
  }
247
256
  return false;
248
257
  }
258
+ /**
259
+ * Schema for lane health mode validation
260
+ */
261
+ const LaneHealthModeSchema = z.enum(['warn', 'error', 'off']);
262
+ /**
263
+ * Default lane health mode (advisory by default)
264
+ */
265
+ const DEFAULT_LANE_HEALTH_MODE = 'warn';
266
+ /**
267
+ * WU-1191: Load lane health configuration from .lumenflow.config.yaml
268
+ *
269
+ * Configuration format:
270
+ * ```yaml
271
+ * gates:
272
+ * lane_health: warn|error|off
273
+ * ```
274
+ *
275
+ * @param projectRoot - Project root directory
276
+ * @returns Lane health mode ('warn', 'error', or 'off'), defaults to 'warn'
277
+ */
278
+ export function loadLaneHealthConfig(projectRoot) {
279
+ const configPath = path.join(projectRoot, CONFIG_FILE_NAME);
280
+ if (!fs.existsSync(configPath)) {
281
+ return DEFAULT_LANE_HEALTH_MODE;
282
+ }
283
+ try {
284
+ const content = fs.readFileSync(configPath, 'utf8');
285
+ const data = yaml.parse(content);
286
+ // Check if gates.lane_health is configured
287
+ const laneHealthConfig = data?.gates?.lane_health;
288
+ if (laneHealthConfig === undefined) {
289
+ return DEFAULT_LANE_HEALTH_MODE;
290
+ }
291
+ // Validate the config value
292
+ const result = LaneHealthModeSchema.safeParse(laneHealthConfig);
293
+ if (!result.success) {
294
+ // eslint-disable-next-line no-console -- Intentional warning for invalid config
295
+ console.warn(`Warning: Invalid gates.lane_health value '${laneHealthConfig}', expected 'warn', 'error', or 'off'. Using default 'warn'.`);
296
+ return DEFAULT_LANE_HEALTH_MODE;
297
+ }
298
+ return result.data;
299
+ }
300
+ catch (error) {
301
+ // eslint-disable-next-line no-console -- Intentional warning for parse failure
302
+ console.warn(`Warning: Failed to parse ${CONFIG_FILE_NAME} for lane_health config:`, error instanceof Error ? error.message : String(error));
303
+ return DEFAULT_LANE_HEALTH_MODE;
304
+ }
305
+ }
306
+ /**
307
+ * WU-1262: Resolve coverage configuration from methodology policy
308
+ *
309
+ * Uses resolvePolicy() to determine coverage defaults based on methodology.testing:
310
+ * - tdd: 90% threshold, block mode
311
+ * - test-after: 70% threshold, warn mode
312
+ * - none: 0% threshold, off mode
313
+ *
314
+ * Precedence (highest to lowest):
315
+ * 1. Explicit gates.minCoverage / gates.enableCoverage
316
+ * 2. methodology.overrides.coverage_threshold / coverage_mode
317
+ * 3. methodology.testing template defaults
318
+ *
319
+ * @param projectRoot - Project root directory
320
+ * @returns Resolved coverage configuration
321
+ */
322
+ export function resolveCoverageConfig(projectRoot) {
323
+ const configPath = path.join(projectRoot, CONFIG_FILE_NAME);
324
+ // Load raw config to detect explicit vs default values
325
+ let rawConfig = {};
326
+ if (fs.existsSync(configPath)) {
327
+ try {
328
+ const content = fs.readFileSync(configPath, 'utf8');
329
+ rawConfig = yaml.parse(content) ?? {};
330
+ }
331
+ catch {
332
+ // Fall through to use defaults
333
+ rawConfig = {};
334
+ }
335
+ }
336
+ // If no config file, use default policy
337
+ if (Object.keys(rawConfig).length === 0) {
338
+ const defaultPolicy = getDefaultPolicy();
339
+ return {
340
+ threshold: defaultPolicy.coverage_threshold,
341
+ mode: defaultPolicy.coverage_mode,
342
+ };
343
+ }
344
+ // Parse methodology config manually to avoid circular dependency with lumenflow-config-schema.ts
345
+ // (lumenflow-config-schema.ts imports GatesExecutionConfigSchema from this file)
346
+ const methodologyRaw = rawConfig.methodology;
347
+ const gatesRaw = rawConfig.gates;
348
+ // Build a minimal config object with only what resolvePolicy needs
349
+ // Parse methodology with Zod to get defaults
350
+ const methodology = MethodologyConfigSchema.parse(methodologyRaw ?? {});
351
+ // Build the config structure that resolvePolicy expects
352
+ const minimalConfig = {
353
+ methodology: methodologyRaw, // Pass raw methodology for explicit detection
354
+ gates: {
355
+ minCoverage: gatesRaw?.minCoverage,
356
+ enableCoverage: gatesRaw?.enableCoverage,
357
+ },
358
+ };
359
+ // Resolve policy using the methodology configuration
360
+ // Pass rawConfig to detect explicit gates.* settings vs Zod defaults
361
+ const policy = resolvePolicy({
362
+ methodology,
363
+ gates: {
364
+ // Default gates values from schema
365
+ maxEslintWarnings: 100,
366
+ enableCoverage: gatesRaw?.enableCoverage !== undefined ? Boolean(gatesRaw.enableCoverage) : true,
367
+ minCoverage: typeof gatesRaw?.minCoverage === 'number' ? gatesRaw.minCoverage : 90,
368
+ enableSafetyCriticalTests: true,
369
+ enableInvariants: true,
370
+ },
371
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Minimal type for config
372
+ }, {
373
+ rawConfig: minimalConfig,
374
+ });
375
+ return {
376
+ threshold: policy.coverage_threshold,
377
+ mode: policy.coverage_mode,
378
+ };
379
+ }
380
+ /**
381
+ * WU-1280: Resolve test policy from methodology configuration
382
+ *
383
+ * Returns the full test policy including coverage config AND tests_required.
384
+ * This is used by gates to determine whether test failures should block or warn.
385
+ *
386
+ * Methodology mapping:
387
+ * - tdd: 90% threshold, block mode, tests_required=true
388
+ * - test-after: 70% threshold, warn mode, tests_required=true
389
+ * - none: 0% threshold, off mode, tests_required=false
390
+ *
391
+ * When tests_required=false:
392
+ * - Test failures produce WARNINGS instead of FAILURES
393
+ * - Gates continue but log the test failures
394
+ * - Coverage gate is effectively skipped (mode='off')
395
+ *
396
+ * @param projectRoot - Project root directory
397
+ * @returns Resolved test policy including tests_required
398
+ */
399
+ export function resolveTestPolicy(projectRoot) {
400
+ const configPath = path.join(projectRoot, CONFIG_FILE_NAME);
401
+ // Load raw config to detect explicit vs default values
402
+ let rawConfig = {};
403
+ if (fs.existsSync(configPath)) {
404
+ try {
405
+ const content = fs.readFileSync(configPath, 'utf8');
406
+ rawConfig = yaml.parse(content) ?? {};
407
+ }
408
+ catch {
409
+ // Fall through to use defaults
410
+ rawConfig = {};
411
+ }
412
+ }
413
+ // If no config file, use default policy (TDD)
414
+ if (Object.keys(rawConfig).length === 0) {
415
+ const defaultPolicy = getDefaultPolicy();
416
+ return {
417
+ threshold: defaultPolicy.coverage_threshold,
418
+ mode: defaultPolicy.coverage_mode,
419
+ tests_required: defaultPolicy.tests_required,
420
+ };
421
+ }
422
+ // Parse methodology config manually to avoid circular dependency with lumenflow-config-schema.ts
423
+ const methodologyRaw = rawConfig.methodology;
424
+ const gatesRaw = rawConfig.gates;
425
+ // Parse methodology with Zod to get defaults
426
+ const methodology = MethodologyConfigSchema.parse(methodologyRaw ?? {});
427
+ // Build the config structure that resolvePolicy expects
428
+ const minimalConfig = {
429
+ methodology: methodologyRaw, // Pass raw methodology for explicit detection
430
+ gates: {
431
+ minCoverage: gatesRaw?.minCoverage,
432
+ enableCoverage: gatesRaw?.enableCoverage,
433
+ },
434
+ };
435
+ // Resolve policy using the methodology configuration
436
+ const policy = resolvePolicy({
437
+ methodology,
438
+ gates: {
439
+ // Default gates values from schema
440
+ maxEslintWarnings: 100,
441
+ enableCoverage: gatesRaw?.enableCoverage !== undefined ? Boolean(gatesRaw.enableCoverage) : true,
442
+ minCoverage: typeof gatesRaw?.minCoverage === 'number' ? gatesRaw.minCoverage : 90,
443
+ enableSafetyCriticalTests: true,
444
+ enableInvariants: true,
445
+ },
446
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Minimal type for config
447
+ }, {
448
+ rawConfig: minimalConfig,
449
+ });
450
+ return {
451
+ threshold: policy.coverage_threshold,
452
+ mode: policy.coverage_mode,
453
+ tests_required: policy.tests_required,
454
+ };
455
+ }
@@ -1,20 +1,20 @@
1
1
  /**
2
- * @file git-adapter.mjs
2
+ * @file git-adapter.ts
3
3
  * @description Git operations adapter using simple-git library
4
4
  * WU-1082: Extract shared utilities (eliminate run() duplication)
5
5
  * WU-1213: Refactor to use simple-git library (eliminate execSync)
6
6
  * WU-2242: Add runtime type assertions to prevent silent API misuse
7
7
  *
8
8
  * Replaces run() function in:
9
- * - tools/wu-claim.mjs
10
- * - tools/wu-done.mjs
11
- * - tools/wu-block.mjs
12
- * - tools/wu-unblock.mjs
13
- * - tools/wu-create.mjs
14
- * - tools/wu-cleanup.mjs
15
- * - tools/gates-pre-commit.mjs
16
- * - tools/validate.mjs
17
- * - tools/guard-worktree-commit.mjs
9
+ * - tools/wu-claim.ts
10
+ * - tools/wu-done.ts
11
+ * - tools/wu-block.ts
12
+ * - tools/wu-unblock.ts
13
+ * - tools/wu-create.ts
14
+ * - tools/wu-cleanup.ts
15
+ * - tools/gates-pre-commit.ts
16
+ * - tools/validate.ts
17
+ * - tools/guard-worktree-commit.ts
18
18
  */
19
19
  import { type SimpleGit } from 'simple-git';
20
20
  interface GitAdapterOptions {
@@ -242,7 +242,7 @@ export declare class GitAdapter {
242
242
  * Get commit log
243
243
  *
244
244
  * WU-1749: Bug 4 fix - Add log() method for counting commits.
245
- * Used by wu-done-retry-helpers.mjs to count previous completion attempts.
245
+ * Used by wu-done-retry-helpers.ts to count previous completion attempts.
246
246
  *
247
247
  * @param {object} [options] - Log options
248
248
  * @param {number} [options.maxCount] - Maximum number of commits to return
@@ -1,20 +1,20 @@
1
1
  /**
2
- * @file git-adapter.mjs
2
+ * @file git-adapter.ts
3
3
  * @description Git operations adapter using simple-git library
4
4
  * WU-1082: Extract shared utilities (eliminate run() duplication)
5
5
  * WU-1213: Refactor to use simple-git library (eliminate execSync)
6
6
  * WU-2242: Add runtime type assertions to prevent silent API misuse
7
7
  *
8
8
  * Replaces run() function in:
9
- * - tools/wu-claim.mjs
10
- * - tools/wu-done.mjs
11
- * - tools/wu-block.mjs
12
- * - tools/wu-unblock.mjs
13
- * - tools/wu-create.mjs
14
- * - tools/wu-cleanup.mjs
15
- * - tools/gates-pre-commit.mjs
16
- * - tools/validate.mjs
17
- * - tools/guard-worktree-commit.mjs
9
+ * - tools/wu-claim.ts
10
+ * - tools/wu-done.ts
11
+ * - tools/wu-block.ts
12
+ * - tools/wu-unblock.ts
13
+ * - tools/wu-create.ts
14
+ * - tools/wu-cleanup.ts
15
+ * - tools/gates-pre-commit.ts
16
+ * - tools/validate.ts
17
+ * - tools/guard-worktree-commit.ts
18
18
  */
19
19
  import { simpleGit } from 'simple-git';
20
20
  import { existsSync, rmSync } from 'node:fs';
@@ -385,7 +385,7 @@ export class GitAdapter {
385
385
  * Get commit log
386
386
  *
387
387
  * WU-1749: Bug 4 fix - Add log() method for counting commits.
388
- * Used by wu-done-retry-helpers.mjs to count previous completion attempts.
388
+ * Used by wu-done-retry-helpers.ts to count previous completion attempts.
389
389
  *
390
390
  * @param {object} [options] - Log options
391
391
  * @param {number} [options.maxCount] - Maximum number of commits to return
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Git Context Extractor Module (WU-1190)
3
+ *
4
+ * Extracts git history insights for LLM context enrichment:
5
+ * - Co-occurrence: files frequently changed together
6
+ * - Ownership: primary contributors to file/directory
7
+ * - Churn: change frequency metrics (hotspots)
8
+ *
9
+ * These signals help the LLM understand codebase relationships
10
+ * without algorithmic clustering - the LLM interprets the patterns.
11
+ */
12
+ /**
13
+ * A pair of files frequently changed together
14
+ */
15
+ export interface CoOccurrence {
16
+ file1: string;
17
+ file2: string;
18
+ /** Number of commits where both files were changed */
19
+ count: number;
20
+ }
21
+ /**
22
+ * Ownership signal for a path (file or directory)
23
+ */
24
+ export interface OwnershipSignal {
25
+ /** The path being analyzed */
26
+ path: string;
27
+ /** Primary contributor (most commits), null if none */
28
+ primaryOwner: string | null;
29
+ /** All contributors with their commit counts */
30
+ contributors: string[];
31
+ /** Total commits touching this path */
32
+ commitCount: number;
33
+ }
34
+ /**
35
+ * Churn metric for a file
36
+ */
37
+ export interface ChurnMetric {
38
+ filePath: string;
39
+ additions: number;
40
+ deletions: number;
41
+ /** Churn score = additions + deletions */
42
+ churnScore: number;
43
+ /** Number of commits modifying this file */
44
+ commitCount: number;
45
+ }
46
+ /**
47
+ * Complete git context extracted from repository
48
+ */
49
+ export interface GitContext {
50
+ coOccurrences: CoOccurrence[];
51
+ ownership: OwnershipSignal[];
52
+ churn: ChurnMetric[];
53
+ hasLimitedHistory: boolean;
54
+ error?: string;
55
+ }
56
+ /**
57
+ * Options for git context extraction
58
+ */
59
+ export interface GitContextOptions {
60
+ /** Maximum number of commits to analyze */
61
+ maxCommits?: number;
62
+ /** Limit history to commits since this date */
63
+ since?: string;
64
+ }
65
+ /**
66
+ * Options for co-occurrence extraction
67
+ */
68
+ interface CoOccurrenceOptions {
69
+ maxResults?: number;
70
+ maxCommits?: number;
71
+ since?: string;
72
+ }
73
+ /**
74
+ * Options for churn metrics extraction
75
+ */
76
+ interface ChurnOptions {
77
+ excludePatterns?: string[];
78
+ maxResults?: number;
79
+ maxCommits?: number;
80
+ since?: string;
81
+ }
82
+ /**
83
+ * Options for summarizing git context
84
+ */
85
+ interface SummarizeOptions {
86
+ /** Approximate max tokens (chars / 4 as rough estimate) */
87
+ maxTokens?: number;
88
+ }
89
+ /**
90
+ * Extract complete git context from a repository
91
+ */
92
+ export declare function extractGitContext(projectRoot: string, options?: GitContextOptions): GitContext;
93
+ /**
94
+ * Extract file co-occurrence patterns from git history
95
+ */
96
+ export declare function getFileCoOccurrence(projectRoot: string, options?: CoOccurrenceOptions): CoOccurrence[];
97
+ /**
98
+ * Extract ownership signals for specified paths.
99
+ * Note: paths are validated internally and not derived from user input.
100
+ */
101
+ export declare function getOwnershipSignals(projectRoot: string, paths: string[]): OwnershipSignal[];
102
+ /**
103
+ * Extract churn metrics for the repository
104
+ */
105
+ export declare function getChurnMetrics(projectRoot: string, options?: ChurnOptions): ChurnMetric[];
106
+ /**
107
+ * Summarize git context for LLM prompt inclusion
108
+ *
109
+ * Produces a token-efficient summary that fits within specified limits.
110
+ */
111
+ export declare function summarizeGitContext(context: GitContext, options?: SummarizeOptions): string;
112
+ export {};