@lumenflow/core 2.2.1 → 2.3.1

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 (221) 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/system-map-validator.d.ts +18 -0
  134. package/dist/system-map-validator.js +50 -16
  135. package/dist/telemetry.d.ts +1 -1
  136. package/dist/telemetry.js +1 -1
  137. package/dist/template-loader.d.ts +162 -0
  138. package/dist/template-loader.js +372 -0
  139. package/dist/test-baseline.d.ts +176 -0
  140. package/dist/test-baseline.js +282 -0
  141. package/dist/usecases/get-suggestions.usecase.d.ts +1 -1
  142. package/dist/validation/command-registry.js +37 -0
  143. package/dist/validators/backlog-sync.d.ts +14 -0
  144. package/dist/validators/backlog-sync.js +62 -0
  145. package/dist/validators/supabase-docs-linter.d.ts +18 -0
  146. package/dist/validators/supabase-docs-linter.js +42 -0
  147. package/dist/validators/wu-tasks.d.ts +24 -0
  148. package/dist/validators/wu-tasks.js +90 -0
  149. package/dist/worktree-scanner.d.ts +1 -1
  150. package/dist/worktree-scanner.js +1 -1
  151. package/dist/worktree-symlink.d.ts +3 -3
  152. package/dist/worktree-symlink.js +3 -3
  153. package/dist/wu-backlog-updater.d.ts +1 -1
  154. package/dist/wu-backlog-updater.js +1 -1
  155. package/dist/wu-claim-helpers.d.ts +1 -1
  156. package/dist/wu-claim-helpers.js +1 -1
  157. package/dist/wu-claim-resume.d.ts +1 -1
  158. package/dist/wu-claim-resume.js +1 -1
  159. package/dist/wu-consistency-checker.d.ts +1 -1
  160. package/dist/wu-consistency-checker.js +17 -11
  161. package/dist/wu-constants.d.ts +73 -36
  162. package/dist/wu-constants.js +65 -92
  163. package/dist/wu-done-branch-only.d.ts +1 -1
  164. package/dist/wu-done-branch-only.js +1 -1
  165. package/dist/wu-done-docs-generate.d.ts +1 -1
  166. package/dist/wu-done-docs-generate.js +1 -1
  167. package/dist/wu-done-messages.d.ts +2 -2
  168. package/dist/wu-done-messages.js +2 -2
  169. package/dist/wu-done-metadata.d.ts +3 -3
  170. package/dist/wu-done-metadata.js +3 -3
  171. package/dist/wu-done-pr.d.ts +1 -1
  172. package/dist/wu-done-pr.js +4 -2
  173. package/dist/wu-done-preflight.d.ts +20 -10
  174. package/dist/wu-done-preflight.js +48 -47
  175. package/dist/wu-done-ui.d.ts +3 -3
  176. package/dist/wu-done-ui.js +3 -3
  177. package/dist/wu-done-validation.d.ts +30 -0
  178. package/dist/wu-done-validation.js +106 -1
  179. package/dist/wu-done-validators.d.ts +1 -1
  180. package/dist/wu-done-worktree.d.ts +1 -1
  181. package/dist/wu-done-worktree.js +11 -1
  182. package/dist/wu-events-cleanup.d.ts +148 -0
  183. package/dist/wu-events-cleanup.js +401 -0
  184. package/dist/wu-helpers.d.ts +2 -2
  185. package/dist/wu-helpers.js +2 -2
  186. package/dist/wu-id-generator.d.ts +58 -0
  187. package/dist/wu-id-generator.js +103 -0
  188. package/dist/wu-lint.js +1 -1
  189. package/dist/wu-preflight-validators.d.ts +13 -1
  190. package/dist/wu-preflight-validators.js +56 -1
  191. package/dist/wu-recovery.d.ts +2 -2
  192. package/dist/wu-recovery.js +4 -4
  193. package/dist/wu-repair-core.d.ts +5 -5
  194. package/dist/wu-repair-core.js +6 -6
  195. package/dist/wu-schema-normalization.d.ts +1 -1
  196. package/dist/wu-schema-normalization.js +1 -1
  197. package/dist/wu-schema.d.ts +7 -7
  198. package/dist/wu-schema.js +8 -8
  199. package/dist/wu-spawn-context.d.ts +87 -0
  200. package/dist/wu-spawn-context.js +175 -0
  201. package/dist/wu-spawn-helpers.d.ts +1 -1
  202. package/dist/wu-spawn-helpers.js +1 -1
  203. package/dist/wu-spawn.d.ts +177 -4
  204. package/dist/wu-spawn.js +694 -72
  205. package/dist/wu-state-schema.d.ts +1 -1
  206. package/dist/wu-state-schema.js +1 -1
  207. package/dist/wu-state-store.d.ts +3 -3
  208. package/dist/wu-state-store.js +3 -3
  209. package/dist/wu-status-transition.d.ts +1 -1
  210. package/dist/wu-status-transition.js +1 -1
  211. package/dist/wu-status-updater.d.ts +3 -3
  212. package/dist/wu-status-updater.js +3 -3
  213. package/dist/wu-validation-constants.d.ts +2 -2
  214. package/dist/wu-validation-constants.js +2 -2
  215. package/dist/wu-validation.d.ts +3 -3
  216. package/dist/wu-validation.js +3 -3
  217. package/dist/wu-yaml-fixer.d.ts +2 -2
  218. package/dist/wu-yaml-fixer.js +3 -3
  219. package/dist/wu-yaml.d.ts +23 -0
  220. package/dist/wu-yaml.js +76 -2
  221. package/package.json +5 -2
@@ -4,16 +4,15 @@
4
4
  * Centralized constants for wu- scripts to ensure consistency and DRY compliance.
5
5
  * Single source of truth for magic strings, section headings, and patterns.
6
6
  *
7
- * Part of WU-1214: Extract hardcoded strings to wu-constants.mjs
7
+ * Part of WU-1214: Extract hardcoded strings to wu-constants.ts
8
8
  * Part of WU-1240: Consolidated toKebab using change-case library
9
9
  *
10
- * @see {@link tools/wu-done.mjs} - Primary consumer
11
- * @see {@link tools/wu-claim.mjs} - Branch/worktree creation
12
- * @see {@link tools/lib/wu-schema.mjs} - PLACEHOLDER_SENTINEL (already centralized)
10
+ * @see {@link packages/@lumenflow/cli/src/wu-done.ts} - Primary consumer
11
+ * @see {@link packages/@lumenflow/cli/src/wu-claim.ts} - Branch/worktree creation
12
+ * @see {@link packages/@lumenflow/cli/src/lib/wu-schema.ts} - PLACEHOLDER_SENTINEL (already centralized)
13
13
  */
14
14
  import path from 'node:path';
15
- import { existsSync } from 'node:fs';
16
- import { createRequire } from 'node:module';
15
+ import { tmpdir } from 'node:os';
17
16
  import { kebabCase } from 'change-case';
18
17
  /**
19
18
  * Git branch names
@@ -78,7 +77,7 @@ export const WU_STATUS = {
78
77
  /**
79
78
  * WU status groups for state management (WU-1742)
80
79
  *
81
- * Used by state-bootstrap.mjs to categorize YAML statuses.
80
+ * Used by state-bootstrap.ts to categorize YAML statuses.
82
81
  */
83
82
  export const WU_STATUS_GROUPS = {
84
83
  /** Statuses representing unclaimed work (not tracked in state store) */
@@ -118,7 +117,7 @@ export const INCIDENT_SEVERITY = {
118
117
  MINOR: 'minor',
119
118
  INFO: 'info',
120
119
  };
121
- // Note: PATHS object removed in WU-1240 - use WU_PATHS from wu-paths.mjs instead
120
+ // Note: PATHS object removed in WU-1240 - use WU_PATHS from wu-paths.ts instead
122
121
  /**
123
122
  * Backlog section headings (with emojis)
124
123
  *
@@ -157,7 +156,7 @@ export const STATUS_SECTIONS = {
157
156
  /**
158
157
  * Regex patterns for WU operations
159
158
  *
160
- * Note: WU_ID pattern is also in wu-schema.mjs for Zod validation
159
+ * Note: WU_ID pattern is also in wu-schema.ts for Zod validation
161
160
  */
162
161
  export const PATTERNS = {
163
162
  /** WU identifier format: WU-123 */
@@ -269,7 +268,7 @@ export const LOG_PREFIX = {
269
268
  REPAIR: '[wu:repair]',
270
269
  CONSISTENCY: '[wu-consistency]',
271
270
  PREFLIGHT: '[wu-preflight]',
272
- INIT_PLAN: '[init:plan]',
271
+ INITIATIVE_PLAN: '[initiative:plan]',
273
272
  };
274
273
  /**
275
274
  * Consistency check types (WU-1276)
@@ -481,7 +480,7 @@ export const YAML_OPTIONS = {
481
480
  /**
482
481
  * UI display constants
483
482
  *
484
- * WU-1281: Centralized from hardcoded values in wu-done.mjs
483
+ * WU-1281: Centralized from hardcoded values in wu-done.ts
485
484
  */
486
485
  export const UI = {
487
486
  /** Width for error/info boxes in console output */
@@ -527,6 +526,7 @@ export const CLEANUP_GUARD = {
527
526
  MISSING_STAMP: 'WU stamp is missing. Refusing to delete.',
528
527
  PR_NOT_MERGED: 'PR is not merged (or cannot be verified). Refusing to delete.',
529
528
  },
529
+ /* eslint-disable sonarjs/no-duplicate-string -- Intentional: cleanup instructions repeated for each error type for readability */
530
530
  NEXT_STEPS: {
531
531
  DEFAULT: [
532
532
  { text: '1. Resolve the issue above', appendId: false },
@@ -556,6 +556,7 @@ export const CLEANUP_GUARD = {
556
556
  { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
557
557
  ],
558
558
  },
559
+ /* eslint-enable sonarjs/no-duplicate-string */
559
560
  PR_CHECK: {
560
561
  START: 'Verifying PR merge status...',
561
562
  RESULT: 'PR merge verification via',
@@ -586,14 +587,14 @@ export const GIT = {
586
587
  * P0 incident: 2025-12-10 server crash due to recursive fork bomb.
587
588
  *
588
589
  * @see tools/shims/git - The git shim that blocks destructive commands
589
- * @see tools/lib/wu-helpers.mjs - Uses REAL_GIT to avoid recursion
590
+ * @see tools/lib/wu-helpers.ts - Uses REAL_GIT to avoid recursion
590
591
  */
591
592
  export const REAL_GIT = '/usr/bin/git';
592
593
  /**
593
594
  * Git command flags
594
595
  *
595
596
  * Centralized git flag constants to eliminate hardcoded strings.
596
- * Used by git-adapter.mjs and other git operation utilities.
597
+ * Used by git-adapter.ts and other git operation utilities.
597
598
  */
598
599
  export const GIT_FLAGS = {
599
600
  /** Show abbreviated ref names (for branch name resolution) */
@@ -717,8 +718,8 @@ export const WU_TYPES = {
717
718
  * Defines how a WU exposes its functionality to users.
718
719
  * Used to ensure backend features have corresponding UI coverage.
719
720
  *
720
- * @see {@link tools/lib/wu-schema.mjs} - Schema validation
721
- * @see {@link packages/linters/wu-schema-linter.mjs} - Linter validation
721
+ * @see {@link packages/@lumenflow/cli/src/lib/wu-schema.ts} - Schema validation
722
+ * @see {@link packages/linters/wu-schema-linter.ts} - Linter validation
722
723
  */
723
724
  export const WU_EXPOSURE = {
724
725
  /** User-facing UI changes (pages, components, widgets) */
@@ -805,7 +806,7 @@ export const EMOJI = {
805
806
  * WU-1337: Centralized defaults for auto-repair in schema validation
806
807
  * DRY principle: Single source of truth for optional field defaults
807
808
  *
808
- * Used by wu-schema.mjs Zod transformations to provide sensible defaults
809
+ * Used by wu-schema.ts Zod transformations to provide sensible defaults
809
810
  * when agents omit optional fields, reducing validation errors.
810
811
  */
811
812
  export const WU_DEFAULTS = {
@@ -842,7 +843,7 @@ export const WU_DEFAULTS = {
842
843
  * WU-1068: Removed hardcoded @patientpath references. These patterns
843
844
  * should be configured in .lumenflow.config.yaml per-project.
844
845
  *
845
- * @see {@link tools/lib/lane-validator.mjs} - Validation logic
846
+ * @see {@link packages/@lumenflow/cli/src/lib/lane-validator.ts} - Validation logic
846
847
  */
847
848
  export const LANE_PATH_PATTERNS = {
848
849
  /**
@@ -865,7 +866,7 @@ export const LANE_PATH_PATTERNS = {
865
866
  /**
866
867
  * Process detection constants for background process warning (WU-1381)
867
868
  *
868
- * Used by process-detector.mjs to identify processes that may interfere
869
+ * Used by process-detector.ts to identify processes that may interfere
869
870
  * with wu:done gates execution.
870
871
  */
871
872
  export const PROCESS_DETECTION = {
@@ -962,7 +963,7 @@ export const SCRIPTS = {
962
963
  /**
963
964
  * Gate names for quality gates
964
965
  *
965
- * Centralized gate identifiers for gates.mjs and telemetry.
966
+ * Centralized gate identifiers for gates.ts and telemetry.
966
967
  */
967
968
  export const GATE_NAMES = {
968
969
  /** WU-2252: Invariants check (runs first, non-bypassable) */
@@ -982,11 +983,13 @@ export const GATE_NAMES = {
982
983
  INTEGRATION_TEST: 'integration-test',
983
984
  /** WU-2315: System map validation (warn-only until orphan docs are indexed) */
984
985
  SYSTEM_MAP_VALIDATE: 'system-map:validate',
986
+ /** WU-1191: Lane health check (overlap detection) */
987
+ LANE_HEALTH: 'lane-health',
985
988
  };
986
989
  /**
987
990
  * Gate command sentinels (special values for non-shell commands)
988
991
  *
989
- * These are not shell commands but trigger special handling in gates.mjs.
992
+ * These are not shell commands but trigger special handling in gates.ts.
990
993
  */
991
994
  export const GATE_COMMANDS = {
992
995
  /** WU-2252: Triggers invariants check */
@@ -1002,64 +1005,6 @@ export const GATE_COMMANDS = {
1002
1005
  /** WU-2062: Triggers tiered test execution based on risk */
1003
1006
  TIERED_TEST: 'tiered-test',
1004
1007
  };
1005
- const require = createRequire(import.meta.url);
1006
- const NOOP_NODE_COMMAND = 'node -e "process.exit(0)"';
1007
- function resolveNodeModulePath(modulePath) {
1008
- try {
1009
- return require.resolve(modulePath);
1010
- }
1011
- catch {
1012
- return null;
1013
- }
1014
- }
1015
- function resolveRepoPath(relativePath, requireExists = false) {
1016
- const candidate = path.join(process.cwd(), relativePath);
1017
- if (requireExists && !existsSync(candidate)) {
1018
- return null;
1019
- }
1020
- return candidate;
1021
- }
1022
- function buildNodeCommand({ modulePath, repoPath, allowMissing = false, repoPathRequiresExistence = false, }) {
1023
- const resolved = modulePath ? resolveNodeModulePath(modulePath) : null;
1024
- if (resolved) {
1025
- return `node ${resolved}`;
1026
- }
1027
- const fallback = repoPath ? resolveRepoPath(repoPath, repoPathRequiresExistence) : null;
1028
- if (fallback) {
1029
- return `node ${fallback}`;
1030
- }
1031
- if (allowMissing) {
1032
- return NOOP_NODE_COMMAND;
1033
- }
1034
- if (repoPath) {
1035
- return `node ${resolveRepoPath(repoPath)}`;
1036
- }
1037
- if (modulePath) {
1038
- return `node ${modulePath}`;
1039
- }
1040
- return NOOP_NODE_COMMAND;
1041
- }
1042
- /**
1043
- * Tool paths for scripts
1044
- *
1045
- * Centralized paths to tool scripts.
1046
- */
1047
- export const TOOL_PATHS = {
1048
- VALIDATE_BACKLOG_SYNC: buildNodeCommand({
1049
- modulePath: '@lumenflow/cli/dist/validate-backlog-sync.js',
1050
- repoPath: 'packages/@lumenflow/cli/dist/validate-backlog-sync.js',
1051
- }),
1052
- SUPABASE_DOCS_LINTER: buildNodeCommand({
1053
- repoPath: 'packages/linters/supabase-docs-linter.js',
1054
- allowMissing: true,
1055
- repoPathRequiresExistence: true,
1056
- }),
1057
- /** WU-2315: System map validator script */
1058
- SYSTEM_MAP_VALIDATE: buildNodeCommand({
1059
- modulePath: '@lumenflow/core/dist/system-map-validator.js',
1060
- repoPath: 'packages/@lumenflow/core/dist/system-map-validator.js',
1061
- }),
1062
- };
1063
1008
  /**
1064
1009
  * CLI mode flags
1065
1010
  *
@@ -1156,6 +1101,22 @@ export const EXIT_CODES = {
1156
1101
  /** Fatal or distinct failure exit code */
1157
1102
  FAILURE: 2,
1158
1103
  };
1104
+ /**
1105
+ * Stream error codes
1106
+ *
1107
+ * WU-1233: Error codes for stream operations (stdout/stderr).
1108
+ * Used by StreamErrorHandler for graceful pipe closure handling.
1109
+ */
1110
+ export const STREAM_ERRORS = {
1111
+ /**
1112
+ * EPIPE error code
1113
+ *
1114
+ * Occurs when writing to a pipe whose read end has been closed.
1115
+ * This is normal behavior when CLI output is piped through head/tail.
1116
+ * Unix convention: exit with code 0 on EPIPE (consumer got what it needed).
1117
+ */
1118
+ EPIPE: 'EPIPE',
1119
+ };
1159
1120
  /**
1160
1121
  * ESLint command names
1161
1122
  *
@@ -1278,16 +1239,6 @@ export const AUDIT_ARGS = {
1278
1239
  * Centralized paths to validation scripts.
1279
1240
  */
1280
1241
  export const SCRIPT_PATHS = {
1281
- /** Gates runner */
1282
- GATES: buildNodeCommand({
1283
- modulePath: '@lumenflow/cli/dist/gates.js',
1284
- repoPath: 'packages/@lumenflow/cli/dist/gates.js',
1285
- }),
1286
- /** WU YAML validation */
1287
- VALIDATE: buildNodeCommand({
1288
- modulePath: '@lumenflow/cli/dist/validate.js',
1289
- repoPath: 'packages/@lumenflow/cli/dist/validate.js',
1290
- }),
1291
1242
  /** Prompt registry validation */
1292
1243
  VALIDATE_PROMPT_REGISTRY: 'tools/validate-prompt-registry.js',
1293
1244
  };
@@ -1315,6 +1266,13 @@ export const ERROR_CODES = {
1315
1266
  /** Timeout error code */
1316
1267
  ETIMEDOUT: 'ETIMEDOUT',
1317
1268
  };
1269
+ /**
1270
+ * WU-1174: Lock directory name constant
1271
+ *
1272
+ * Defined separately so it can be used both in LUMENFLOW_PATHS.LOCK_DIR
1273
+ * and for test isolation in cleanup-lock.ts/merge-lock.ts.
1274
+ */
1275
+ export const LOCK_DIR_NAME = '.lumenflow-locks';
1318
1276
  /**
1319
1277
  * LumenFlow directory paths
1320
1278
  *
@@ -1356,10 +1314,23 @@ export const LUMENFLOW_PATHS = {
1356
1314
  SESSION_CURRENT: '.lumenflow/sessions/current.json',
1357
1315
  /** WU events log */
1358
1316
  WU_EVENTS: '.lumenflow/state/wu-events.jsonl',
1359
- /** Lock files directory */
1317
+ /** Lock files directory (lane locks - persisted) */
1360
1318
  LOCKS_DIR: '.lumenflow/locks',
1361
1319
  /** Force bypass audit log */
1362
1320
  FORCE_BYPASSES: '.lumenflow/force-bypasses.log',
1321
+ /**
1322
+ * WU-1174: Runtime lock directory for merge/cleanup locks
1323
+ *
1324
+ * These locks are transient and should NOT be created in the main checkout
1325
+ * because wu:done runs from main. Using os.tmpdir() ensures:
1326
+ * 1. Locks don't pollute the git working tree
1327
+ * 2. Locks work across processes on the same machine
1328
+ * 3. No "Working tree is not clean" errors if process crashes
1329
+ *
1330
+ * Note: Lane locks still use LOCKS_DIR (.lumenflow/locks) because they need
1331
+ * to persist across sessions and be visible to other agents.
1332
+ */
1333
+ LOCK_DIR: path.join(tmpdir(), LOCK_DIR_NAME),
1363
1334
  };
1364
1335
  /**
1365
1336
  * @deprecated Use LUMENFLOW_PATHS instead. Will be removed in v2.0.
@@ -1421,6 +1392,7 @@ export const PATH_LITERALS = {
1421
1392
  /** Plan file suffix for WU plans */
1422
1393
  PLAN_FILE_SUFFIX: '-plan.md',
1423
1394
  /** Trailing slash regex pattern */
1395
+ // eslint-disable-next-line sonarjs/slow-regex -- False positive: simple end-anchor regex, no catastrophic backtracking possible
1424
1396
  TRAILING_SLASH_REGEX: /\/+$/,
1425
1397
  };
1426
1398
  /**
@@ -1484,7 +1456,7 @@ export function getLaneBranch(lane, id) {
1484
1456
  return `lane/${laneKebab}/${idLower}`;
1485
1457
  }
1486
1458
  // Note: getWuYamlPath and getStampPath removed in WU-1240
1487
- // Use WU_PATHS.WU(id) and WU_PATHS.STAMP(id) from wu-paths.mjs instead
1459
+ // Use WU_PATHS.WU(id) and WU_PATHS.STAMP(id) from wu-paths.ts instead
1488
1460
  /**
1489
1461
  * File tool constants (WU-1403)
1490
1462
  *
@@ -1557,8 +1529,8 @@ export const PHI_CONFIG = {
1557
1529
  * Constants for the readiness summary box displayed after wu:create and wu:edit.
1558
1530
  * Provides visual feedback on whether WU is ready for wu:claim.
1559
1531
  *
1560
- * @see tools/wu-create.mjs - displayReadinessSummary()
1561
- * @see tools/wu-edit.mjs - displayReadinessSummary()
1532
+ * @see tools/wu-create.ts - displayReadinessSummary()
1533
+ * @see tools/wu-edit.ts - displayReadinessSummary()
1562
1534
  */
1563
1535
  export const READINESS_UI = {
1564
1536
  /** Box width (inner content area) */
@@ -1800,6 +1772,7 @@ export const CONTEXT_VALIDATION = {
1800
1772
  COMMANDS: {
1801
1773
  WU_CREATE: 'wu:create',
1802
1774
  WU_CLAIM: 'wu:claim',
1775
+ WU_PREP: 'wu:prep',
1803
1776
  WU_DONE: 'wu:done',
1804
1777
  WU_BLOCK: 'wu:block',
1805
1778
  WU_UNBLOCK: 'wu:unblock',
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * Branch-Only mode completion workflow for wu:done
4
- * Extracted from wu-done.mjs (WU-1215 refactoring)
4
+ * Extracted from wu-done.ts (WU-1215 refactoring)
5
5
  *
6
6
  * Flow:
7
7
  * 1. Switch to main branch
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * Branch-Only mode completion workflow for wu:done
4
- * Extracted from wu-done.mjs (WU-1215 refactoring)
4
+ * Extracted from wu-done.ts (WU-1215 refactoring)
5
5
  *
6
6
  * Flow:
7
7
  * 1. Switch to main branch
@@ -11,7 +11,7 @@
11
11
  * Pathspecs for files that affect generated documentation.
12
12
  * When any of these files change, docs:generate should be run.
13
13
  *
14
- * Based on .husky/hooks/docs-sync.mjs patterns, expanded to match
14
+ * Based on .husky/hooks/docs-sync.ts patterns, expanded to match
15
15
  * all files that can affect CLI/config documentation.
16
16
  */
17
17
  export declare const DOC_SOURCE_PATHSPECS: readonly ["tools/generate-cli-docs.ts", "packages/@lumenflow/core/src/arg-parser.ts", "packages/@lumenflow/core/src/lumenflow-config-schema.ts", "packages/@lumenflow/core/src/index.ts", "packages/@lumenflow/cli/package.json", "packages/@lumenflow/cli/src/"];
@@ -14,7 +14,7 @@ import { STDIO, PKG_MANAGER, SCRIPTS, PRETTIER_FLAGS } from './wu-constants.js';
14
14
  * Pathspecs for files that affect generated documentation.
15
15
  * When any of these files change, docs:generate should be run.
16
16
  *
17
- * Based on .husky/hooks/docs-sync.mjs patterns, expanded to match
17
+ * Based on .husky/hooks/docs-sync.ts patterns, expanded to match
18
18
  * all files that can affect CLI/config documentation.
19
19
  */
20
20
  export const DOC_SOURCE_PATHSPECS = [
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @file wu-done-messages.mjs
2
+ * @file wu-done-messages.ts
3
3
  * @description Constants and message templates for wu-done operations
4
4
  * WU-1159: Eliminate string literals (DRY/SOLID compliance)
5
- * WU-1281: Use centralized LOG_PREFIX and EMOJI from wu-constants.mjs
5
+ * WU-1281: Use centralized LOG_PREFIX and EMOJI from wu-constants.ts
6
6
  *
7
7
  * All log messages, error messages, and text templates extracted to constants.
8
8
  * Prevents duplication and makes text maintainable.
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @file wu-done-messages.mjs
2
+ * @file wu-done-messages.ts
3
3
  * @description Constants and message templates for wu-done operations
4
4
  * WU-1159: Eliminate string literals (DRY/SOLID compliance)
5
- * WU-1281: Use centralized LOG_PREFIX and EMOJI from wu-constants.mjs
5
+ * WU-1281: Use centralized LOG_PREFIX and EMOJI from wu-constants.ts
6
6
  *
7
7
  * All log messages, error messages, and text templates extracted to constants.
8
8
  * Prevents duplication and makes text maintainable.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  /**
5
5
  * Generate commit message for WU completion
6
- * Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
6
+ * Extracted from wu-done.ts (WU-1215 Phase 2 Extraction #1 Helper)
7
7
  * @param {string} id - WU ID (e.g., "WU-1215")
8
8
  * @param {string} title - WU title
9
9
  * @param {number} maxLength - Maximum commit header length from commitlint config
@@ -26,7 +26,7 @@ export declare function validateMetadataFilesExist({ statusPath, backlogPath }:
26
26
  }): void;
27
27
  /**
28
28
  * Update all metadata files for WU completion
29
- * Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
29
+ * Extracted from wu-done.ts (WU-1215 Phase 2 Extraction #1 Helper)
30
30
  * WU-1572: Made async for WUStateStore integration
31
31
  * @param {object} params - Parameters object
32
32
  * @param {string} params.id - WU ID
@@ -82,7 +82,7 @@ export declare function collectMetadataToTransaction({ id, title, doc, wuPath, s
82
82
  }): Promise<void>;
83
83
  /**
84
84
  * Stage and format metadata files
85
- * Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
85
+ * Extracted from wu-done.ts (WU-1215 Phase 2 Extraction #1 Helper)
86
86
  * @param {object} params - Parameters object
87
87
  * @param {string} params.id - WU ID (for error reporting)
88
88
  * @param {string} params.wuPath - Path to WU YAML file
@@ -18,7 +18,7 @@ import { writeWU } from './wu-yaml.js';
18
18
  const execAsync = promisify(execCallback);
19
19
  /**
20
20
  * Generate commit message for WU completion
21
- * Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
21
+ * Extracted from wu-done.ts (WU-1215 Phase 2 Extraction #1 Helper)
22
22
  * @param {string} id - WU ID (e.g., "WU-1215")
23
23
  * @param {string} title - WU title
24
24
  * @param {number} maxLength - Maximum commit header length from commitlint config
@@ -71,7 +71,7 @@ export function validateMetadataFilesExist({ statusPath, backlogPath }) {
71
71
  }
72
72
  /**
73
73
  * Update all metadata files for WU completion
74
- * Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
74
+ * Extracted from wu-done.ts (WU-1215 Phase 2 Extraction #1 Helper)
75
75
  * WU-1572: Made async for WUStateStore integration
76
76
  * @param {object} params - Parameters object
77
77
  * @param {string} params.id - WU ID
@@ -156,7 +156,7 @@ export async function collectMetadataToTransaction({ id, title, doc, wuPath, sta
156
156
  }
157
157
  /**
158
158
  * Stage and format metadata files
159
- * Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
159
+ * Extracted from wu-done.ts (WU-1215 Phase 2 Extraction #1 Helper)
160
160
  * @param {object} params - Parameters object
161
161
  * @param {string} params.id - WU ID (for error reporting)
162
162
  * @param {string} params.wuPath - Path to WU YAML file
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * PR mode completion workflow for wu:done
4
- * Extracted from wu-done.mjs (WU-1215 refactoring)
4
+ * Extracted from wu-done.ts (WU-1215 refactoring)
5
5
  *
6
6
  * PR mode creates a GitHub PR instead of auto-merging to main.
7
7
  * Used for:
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * PR mode completion workflow for wu:done
4
- * Extracted from wu-done.mjs (WU-1215 refactoring)
4
+ * Extracted from wu-done.ts (WU-1215 refactoring)
5
5
  *
6
6
  * PR mode creates a GitHub PR instead of auto-merging to main.
7
7
  * Used for:
@@ -13,6 +13,7 @@ import { execSync } from 'node:child_process';
13
13
  import { getGitForCwd } from './git-adapter.js';
14
14
  import { createError, ErrorCodes } from './error-handler.js';
15
15
  import { LOG_PREFIX, EMOJI, REMOTES, STDIO } from './wu-constants.js';
16
+ import { createWuPaths } from './wu-paths.js';
16
17
  /**
17
18
  * @typedef {Object} PRContext
18
19
  * @property {string} branch - Lane branch name
@@ -105,7 +106,8 @@ export async function createPR(context) {
105
106
  * @returns {string} PR body markdown
106
107
  */
107
108
  export function buildPRBody(doc, id) {
108
- const wuPath = `docs/04-operations/tasks/wu/${id}.yaml`;
109
+ const paths = createWuPaths();
110
+ const wuPath = paths.WU(id);
109
111
  const description = doc.description || doc.problem || '';
110
112
  const acceptance = doc.acceptance_criteria || doc.acceptance || {};
111
113
  let body = `## Summary\n\n${description}\n\n`;
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * Preflight validation helpers for wu:done.
3
3
  */
4
- import { execSync as execSyncImport } from 'node:child_process';
5
4
  import { validatePreflight } from './wu-preflight-validators.js';
6
5
  /**
7
6
  * WU-1781: Build preflight error message with actionable guidance
@@ -20,6 +19,14 @@ export declare function executePreflightCodePathValidation(id: any, paths: any,
20
19
  missingCodePaths: any[];
21
20
  missingTestPaths: any[];
22
21
  abortedBeforeGates: boolean;
22
+ suggestedTestPaths?: undefined;
23
+ } | {
24
+ valid: boolean;
25
+ errors: any[];
26
+ missingCodePaths: any[];
27
+ missingTestPaths: any[];
28
+ suggestedTestPaths: {};
29
+ abortedBeforeGates: boolean;
23
30
  }>;
24
31
  /**
25
32
  * WU-1805: Build preflight code_paths error message with actionable guidance
@@ -28,21 +35,24 @@ export declare function buildPreflightCodePathErrorMessage(id: any, result: any)
28
35
  /**
29
36
  * WU-1781: Run tasks:validate as preflight check before any git operations
30
37
  */
31
- export interface ExecSyncOverrideOptions {
32
- /** Override execSync for testing (default: child_process.execSync) */
33
- execSyncFn?: typeof execSyncImport;
34
- }
35
- export declare function runPreflightTasksValidation(id: any, options?: ExecSyncOverrideOptions): {
38
+ export declare function runPreflightTasksValidation(id: any): {
36
39
  valid: boolean;
37
- errors: any;
40
+ errors: string[];
38
41
  abortedBeforeMerge: boolean;
39
42
  localMainModified: boolean;
40
- hasStampStatusError: any;
43
+ hasStampStatusError: boolean;
41
44
  };
42
45
  /**
43
46
  * WU-2308: Validate all pre-commit hooks with worktree context
44
47
  */
45
- export declare function validateAllPreCommitHooks(id: any, worktreePath?: any, options?: ExecSyncOverrideOptions): {
48
+ export interface ValidateAllPreCommitHooksOptions {
49
+ runGates?: (options: {
50
+ cwd?: string;
51
+ docsOnly?: boolean;
52
+ wuId?: string;
53
+ }) => Promise<boolean>;
54
+ }
55
+ export declare function validateAllPreCommitHooks(id: any, worktreePath?: any, options?: ValidateAllPreCommitHooksOptions): Promise<{
46
56
  valid: boolean;
47
57
  errors: any[];
48
- };
58
+ }>;