@lumenflow/core 2.2.2 → 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 (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
@@ -4,12 +4,12 @@
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
  /**
15
15
  * Git branch names
@@ -70,7 +70,7 @@ export declare const WU_STATUS: {
70
70
  /**
71
71
  * WU status groups for state management (WU-1742)
72
72
  *
73
- * Used by state-bootstrap.mjs to categorize YAML statuses.
73
+ * Used by state-bootstrap.ts to categorize YAML statuses.
74
74
  */
75
75
  export declare const WU_STATUS_GROUPS: {
76
76
  /** Statuses representing unclaimed work (not tracked in state store) */
@@ -140,7 +140,7 @@ export declare const STATUS_SECTIONS: {
140
140
  /**
141
141
  * Regex patterns for WU operations
142
142
  *
143
- * Note: WU_ID pattern is also in wu-schema.mjs for Zod validation
143
+ * Note: WU_ID pattern is also in wu-schema.ts for Zod validation
144
144
  */
145
145
  export declare const PATTERNS: {
146
146
  /** WU identifier format: WU-123 */
@@ -252,7 +252,7 @@ export declare const LOG_PREFIX: {
252
252
  REPAIR: string;
253
253
  CONSISTENCY: string;
254
254
  PREFLIGHT: string;
255
- INIT_PLAN: string;
255
+ INITIATIVE_PLAN: string;
256
256
  };
257
257
  /**
258
258
  * Consistency check types (WU-1276)
@@ -457,7 +457,7 @@ export declare const YAML_OPTIONS: {
457
457
  /**
458
458
  * UI display constants
459
459
  *
460
- * WU-1281: Centralized from hardcoded values in wu-done.mjs
460
+ * WU-1281: Centralized from hardcoded values in wu-done.ts
461
461
  */
462
462
  export declare const UI: {
463
463
  /** Width for error/info boxes in console output */
@@ -559,14 +559,14 @@ export declare const GIT: {
559
559
  * P0 incident: 2025-12-10 server crash due to recursive fork bomb.
560
560
  *
561
561
  * @see tools/shims/git - The git shim that blocks destructive commands
562
- * @see tools/lib/wu-helpers.mjs - Uses REAL_GIT to avoid recursion
562
+ * @see tools/lib/wu-helpers.ts - Uses REAL_GIT to avoid recursion
563
563
  */
564
564
  export declare const REAL_GIT = "/usr/bin/git";
565
565
  /**
566
566
  * Git command flags
567
567
  *
568
568
  * Centralized git flag constants to eliminate hardcoded strings.
569
- * Used by git-adapter.mjs and other git operation utilities.
569
+ * Used by git-adapter.ts and other git operation utilities.
570
570
  */
571
571
  export declare const GIT_FLAGS: {
572
572
  /** Show abbreviated ref names (for branch name resolution) */
@@ -690,8 +690,8 @@ export declare const WU_TYPES: {
690
690
  * Defines how a WU exposes its functionality to users.
691
691
  * Used to ensure backend features have corresponding UI coverage.
692
692
  *
693
- * @see {@link tools/lib/wu-schema.mjs} - Schema validation
694
- * @see {@link packages/linters/wu-schema-linter.mjs} - Linter validation
693
+ * @see {@link packages/@lumenflow/cli/src/lib/wu-schema.ts} - Schema validation
694
+ * @see {@link packages/linters/wu-schema-linter.ts} - Linter validation
695
695
  */
696
696
  export declare const WU_EXPOSURE: {
697
697
  /** User-facing UI changes (pages, components, widgets) */
@@ -759,7 +759,7 @@ export declare const EMOJI: {
759
759
  * WU-1337: Centralized defaults for auto-repair in schema validation
760
760
  * DRY principle: Single source of truth for optional field defaults
761
761
  *
762
- * Used by wu-schema.mjs Zod transformations to provide sensible defaults
762
+ * Used by wu-schema.ts Zod transformations to provide sensible defaults
763
763
  * when agents omit optional fields, reducing validation errors.
764
764
  */
765
765
  export declare const WU_DEFAULTS: {
@@ -801,7 +801,7 @@ export declare const WU_DEFAULTS: {
801
801
  * WU-1068: Removed hardcoded @patientpath references. These patterns
802
802
  * should be configured in .lumenflow.config.yaml per-project.
803
803
  *
804
- * @see {@link tools/lib/lane-validator.mjs} - Validation logic
804
+ * @see {@link packages/@lumenflow/cli/src/lib/lane-validator.ts} - Validation logic
805
805
  */
806
806
  export declare const LANE_PATH_PATTERNS: {
807
807
  /**
@@ -824,7 +824,7 @@ export declare const LANE_PATH_PATTERNS: {
824
824
  /**
825
825
  * Process detection constants for background process warning (WU-1381)
826
826
  *
827
- * Used by process-detector.mjs to identify processes that may interfere
827
+ * Used by process-detector.ts to identify processes that may interfere
828
828
  * with wu:done gates execution.
829
829
  */
830
830
  export declare const PROCESS_DETECTION: {
@@ -918,7 +918,7 @@ export declare const SCRIPTS: {
918
918
  /**
919
919
  * Gate names for quality gates
920
920
  *
921
- * Centralized gate identifiers for gates.mjs and telemetry.
921
+ * Centralized gate identifiers for gates.ts and telemetry.
922
922
  */
923
923
  export declare const GATE_NAMES: {
924
924
  /** WU-2252: Invariants check (runs first, non-bypassable) */
@@ -938,11 +938,13 @@ export declare const GATE_NAMES: {
938
938
  INTEGRATION_TEST: string;
939
939
  /** WU-2315: System map validation (warn-only until orphan docs are indexed) */
940
940
  SYSTEM_MAP_VALIDATE: string;
941
+ /** WU-1191: Lane health check (overlap detection) */
942
+ LANE_HEALTH: string;
941
943
  };
942
944
  /**
943
945
  * Gate command sentinels (special values for non-shell commands)
944
946
  *
945
- * These are not shell commands but trigger special handling in gates.mjs.
947
+ * These are not shell commands but trigger special handling in gates.ts.
946
948
  */
947
949
  export declare const GATE_COMMANDS: {
948
950
  /** WU-2252: Triggers invariants check */
@@ -1053,6 +1055,22 @@ export declare const EXIT_CODES: {
1053
1055
  /** Fatal or distinct failure exit code */
1054
1056
  FAILURE: number;
1055
1057
  };
1058
+ /**
1059
+ * Stream error codes
1060
+ *
1061
+ * WU-1233: Error codes for stream operations (stdout/stderr).
1062
+ * Used by StreamErrorHandler for graceful pipe closure handling.
1063
+ */
1064
+ export declare const STREAM_ERRORS: {
1065
+ /**
1066
+ * EPIPE error code
1067
+ *
1068
+ * Occurs when writing to a pipe whose read end has been closed.
1069
+ * This is normal behavior when CLI output is piped through head/tail.
1070
+ * Unix convention: exit with code 0 on EPIPE (consumer got what it needed).
1071
+ */
1072
+ readonly EPIPE: "EPIPE";
1073
+ };
1056
1074
  /**
1057
1075
  * ESLint command names
1058
1076
  *
@@ -1202,6 +1220,13 @@ export declare const ERROR_CODES: {
1202
1220
  /** Timeout error code */
1203
1221
  ETIMEDOUT: string;
1204
1222
  };
1223
+ /**
1224
+ * WU-1174: Lock directory name constant
1225
+ *
1226
+ * Defined separately so it can be used both in LUMENFLOW_PATHS.LOCK_DIR
1227
+ * and for test isolation in cleanup-lock.ts/merge-lock.ts.
1228
+ */
1229
+ export declare const LOCK_DIR_NAME = ".lumenflow-locks";
1205
1230
  /**
1206
1231
  * LumenFlow directory paths
1207
1232
  *
@@ -1243,10 +1268,23 @@ export declare const LUMENFLOW_PATHS: {
1243
1268
  SESSION_CURRENT: string;
1244
1269
  /** WU events log */
1245
1270
  WU_EVENTS: string;
1246
- /** Lock files directory */
1271
+ /** Lock files directory (lane locks - persisted) */
1247
1272
  LOCKS_DIR: string;
1248
1273
  /** Force bypass audit log */
1249
1274
  FORCE_BYPASSES: string;
1275
+ /**
1276
+ * WU-1174: Runtime lock directory for merge/cleanup locks
1277
+ *
1278
+ * These locks are transient and should NOT be created in the main checkout
1279
+ * because wu:done runs from main. Using os.tmpdir() ensures:
1280
+ * 1. Locks don't pollute the git working tree
1281
+ * 2. Locks work across processes on the same machine
1282
+ * 3. No "Working tree is not clean" errors if process crashes
1283
+ *
1284
+ * Note: Lane locks still use LOCKS_DIR (.lumenflow/locks) because they need
1285
+ * to persist across sessions and be visible to other agents.
1286
+ */
1287
+ LOCK_DIR: string;
1250
1288
  };
1251
1289
  /**
1252
1290
  * @deprecated Use LUMENFLOW_PATHS instead. Will be removed in v2.0.
@@ -1284,10 +1322,23 @@ export declare const BEACON_PATHS: {
1284
1322
  SESSION_CURRENT: string;
1285
1323
  /** WU events log */
1286
1324
  WU_EVENTS: string;
1287
- /** Lock files directory */
1325
+ /** Lock files directory (lane locks - persisted) */
1288
1326
  LOCKS_DIR: string;
1289
1327
  /** Force bypass audit log */
1290
1328
  FORCE_BYPASSES: string;
1329
+ /**
1330
+ * WU-1174: Runtime lock directory for merge/cleanup locks
1331
+ *
1332
+ * These locks are transient and should NOT be created in the main checkout
1333
+ * because wu:done runs from main. Using os.tmpdir() ensures:
1334
+ * 1. Locks don't pollute the git working tree
1335
+ * 2. Locks work across processes on the same machine
1336
+ * 3. No "Working tree is not clean" errors if process crashes
1337
+ *
1338
+ * Note: Lane locks still use LOCKS_DIR (.lumenflow/locks) because they need
1339
+ * to persist across sessions and be visible to other agents.
1340
+ */
1341
+ LOCK_DIR: string;
1291
1342
  };
1292
1343
  /**
1293
1344
  * File extensions
@@ -1463,8 +1514,8 @@ export declare const PHI_CONFIG: {
1463
1514
  * Constants for the readiness summary box displayed after wu:create and wu:edit.
1464
1515
  * Provides visual feedback on whether WU is ready for wu:claim.
1465
1516
  *
1466
- * @see tools/wu-create.mjs - displayReadinessSummary()
1467
- * @see tools/wu-edit.mjs - displayReadinessSummary()
1517
+ * @see tools/wu-create.ts - displayReadinessSummary()
1518
+ * @see tools/wu-edit.ts - displayReadinessSummary()
1468
1519
  */
1469
1520
  export declare const READINESS_UI: {
1470
1521
  /** Box width (inner content area) */
@@ -1650,6 +1701,7 @@ export declare const CONTEXT_VALIDATION: {
1650
1701
  readonly COMMANDS: {
1651
1702
  readonly WU_CREATE: "wu:create";
1652
1703
  readonly WU_CLAIM: "wu:claim";
1704
+ readonly WU_PREP: "wu:prep";
1653
1705
  readonly WU_DONE: "wu:done";
1654
1706
  readonly WU_BLOCK: "wu:block";
1655
1707
  readonly WU_UNBLOCK: "wu:unblock";
@@ -4,14 +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 { tmpdir } from 'node:os';
15
16
  import { kebabCase } from 'change-case';
16
17
  /**
17
18
  * Git branch names
@@ -76,7 +77,7 @@ export const WU_STATUS = {
76
77
  /**
77
78
  * WU status groups for state management (WU-1742)
78
79
  *
79
- * Used by state-bootstrap.mjs to categorize YAML statuses.
80
+ * Used by state-bootstrap.ts to categorize YAML statuses.
80
81
  */
81
82
  export const WU_STATUS_GROUPS = {
82
83
  /** Statuses representing unclaimed work (not tracked in state store) */
@@ -116,7 +117,7 @@ export const INCIDENT_SEVERITY = {
116
117
  MINOR: 'minor',
117
118
  INFO: 'info',
118
119
  };
119
- // 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
120
121
  /**
121
122
  * Backlog section headings (with emojis)
122
123
  *
@@ -155,7 +156,7 @@ export const STATUS_SECTIONS = {
155
156
  /**
156
157
  * Regex patterns for WU operations
157
158
  *
158
- * 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
159
160
  */
160
161
  export const PATTERNS = {
161
162
  /** WU identifier format: WU-123 */
@@ -267,7 +268,7 @@ export const LOG_PREFIX = {
267
268
  REPAIR: '[wu:repair]',
268
269
  CONSISTENCY: '[wu-consistency]',
269
270
  PREFLIGHT: '[wu-preflight]',
270
- INIT_PLAN: '[init:plan]',
271
+ INITIATIVE_PLAN: '[initiative:plan]',
271
272
  };
272
273
  /**
273
274
  * Consistency check types (WU-1276)
@@ -479,7 +480,7 @@ export const YAML_OPTIONS = {
479
480
  /**
480
481
  * UI display constants
481
482
  *
482
- * WU-1281: Centralized from hardcoded values in wu-done.mjs
483
+ * WU-1281: Centralized from hardcoded values in wu-done.ts
483
484
  */
484
485
  export const UI = {
485
486
  /** Width for error/info boxes in console output */
@@ -525,6 +526,7 @@ export const CLEANUP_GUARD = {
525
526
  MISSING_STAMP: 'WU stamp is missing. Refusing to delete.',
526
527
  PR_NOT_MERGED: 'PR is not merged (or cannot be verified). Refusing to delete.',
527
528
  },
529
+ /* eslint-disable sonarjs/no-duplicate-string -- Intentional: cleanup instructions repeated for each error type for readability */
528
530
  NEXT_STEPS: {
529
531
  DEFAULT: [
530
532
  { text: '1. Resolve the issue above', appendId: false },
@@ -554,6 +556,7 @@ export const CLEANUP_GUARD = {
554
556
  { text: '2. Re-run: pnpm wu:cleanup --id', appendId: true },
555
557
  ],
556
558
  },
559
+ /* eslint-enable sonarjs/no-duplicate-string */
557
560
  PR_CHECK: {
558
561
  START: 'Verifying PR merge status...',
559
562
  RESULT: 'PR merge verification via',
@@ -584,14 +587,14 @@ export const GIT = {
584
587
  * P0 incident: 2025-12-10 server crash due to recursive fork bomb.
585
588
  *
586
589
  * @see tools/shims/git - The git shim that blocks destructive commands
587
- * @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
588
591
  */
589
592
  export const REAL_GIT = '/usr/bin/git';
590
593
  /**
591
594
  * Git command flags
592
595
  *
593
596
  * Centralized git flag constants to eliminate hardcoded strings.
594
- * Used by git-adapter.mjs and other git operation utilities.
597
+ * Used by git-adapter.ts and other git operation utilities.
595
598
  */
596
599
  export const GIT_FLAGS = {
597
600
  /** Show abbreviated ref names (for branch name resolution) */
@@ -715,8 +718,8 @@ export const WU_TYPES = {
715
718
  * Defines how a WU exposes its functionality to users.
716
719
  * Used to ensure backend features have corresponding UI coverage.
717
720
  *
718
- * @see {@link tools/lib/wu-schema.mjs} - Schema validation
719
- * @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
720
723
  */
721
724
  export const WU_EXPOSURE = {
722
725
  /** User-facing UI changes (pages, components, widgets) */
@@ -803,7 +806,7 @@ export const EMOJI = {
803
806
  * WU-1337: Centralized defaults for auto-repair in schema validation
804
807
  * DRY principle: Single source of truth for optional field defaults
805
808
  *
806
- * Used by wu-schema.mjs Zod transformations to provide sensible defaults
809
+ * Used by wu-schema.ts Zod transformations to provide sensible defaults
807
810
  * when agents omit optional fields, reducing validation errors.
808
811
  */
809
812
  export const WU_DEFAULTS = {
@@ -840,7 +843,7 @@ export const WU_DEFAULTS = {
840
843
  * WU-1068: Removed hardcoded @patientpath references. These patterns
841
844
  * should be configured in .lumenflow.config.yaml per-project.
842
845
  *
843
- * @see {@link tools/lib/lane-validator.mjs} - Validation logic
846
+ * @see {@link packages/@lumenflow/cli/src/lib/lane-validator.ts} - Validation logic
844
847
  */
845
848
  export const LANE_PATH_PATTERNS = {
846
849
  /**
@@ -863,7 +866,7 @@ export const LANE_PATH_PATTERNS = {
863
866
  /**
864
867
  * Process detection constants for background process warning (WU-1381)
865
868
  *
866
- * Used by process-detector.mjs to identify processes that may interfere
869
+ * Used by process-detector.ts to identify processes that may interfere
867
870
  * with wu:done gates execution.
868
871
  */
869
872
  export const PROCESS_DETECTION = {
@@ -960,7 +963,7 @@ export const SCRIPTS = {
960
963
  /**
961
964
  * Gate names for quality gates
962
965
  *
963
- * Centralized gate identifiers for gates.mjs and telemetry.
966
+ * Centralized gate identifiers for gates.ts and telemetry.
964
967
  */
965
968
  export const GATE_NAMES = {
966
969
  /** WU-2252: Invariants check (runs first, non-bypassable) */
@@ -980,11 +983,13 @@ export const GATE_NAMES = {
980
983
  INTEGRATION_TEST: 'integration-test',
981
984
  /** WU-2315: System map validation (warn-only until orphan docs are indexed) */
982
985
  SYSTEM_MAP_VALIDATE: 'system-map:validate',
986
+ /** WU-1191: Lane health check (overlap detection) */
987
+ LANE_HEALTH: 'lane-health',
983
988
  };
984
989
  /**
985
990
  * Gate command sentinels (special values for non-shell commands)
986
991
  *
987
- * 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.
988
993
  */
989
994
  export const GATE_COMMANDS = {
990
995
  /** WU-2252: Triggers invariants check */
@@ -1096,6 +1101,22 @@ export const EXIT_CODES = {
1096
1101
  /** Fatal or distinct failure exit code */
1097
1102
  FAILURE: 2,
1098
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
+ };
1099
1120
  /**
1100
1121
  * ESLint command names
1101
1122
  *
@@ -1245,6 +1266,13 @@ export const ERROR_CODES = {
1245
1266
  /** Timeout error code */
1246
1267
  ETIMEDOUT: 'ETIMEDOUT',
1247
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';
1248
1276
  /**
1249
1277
  * LumenFlow directory paths
1250
1278
  *
@@ -1286,10 +1314,23 @@ export const LUMENFLOW_PATHS = {
1286
1314
  SESSION_CURRENT: '.lumenflow/sessions/current.json',
1287
1315
  /** WU events log */
1288
1316
  WU_EVENTS: '.lumenflow/state/wu-events.jsonl',
1289
- /** Lock files directory */
1317
+ /** Lock files directory (lane locks - persisted) */
1290
1318
  LOCKS_DIR: '.lumenflow/locks',
1291
1319
  /** Force bypass audit log */
1292
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),
1293
1334
  };
1294
1335
  /**
1295
1336
  * @deprecated Use LUMENFLOW_PATHS instead. Will be removed in v2.0.
@@ -1351,6 +1392,7 @@ export const PATH_LITERALS = {
1351
1392
  /** Plan file suffix for WU plans */
1352
1393
  PLAN_FILE_SUFFIX: '-plan.md',
1353
1394
  /** Trailing slash regex pattern */
1395
+ // eslint-disable-next-line sonarjs/slow-regex -- False positive: simple end-anchor regex, no catastrophic backtracking possible
1354
1396
  TRAILING_SLASH_REGEX: /\/+$/,
1355
1397
  };
1356
1398
  /**
@@ -1414,7 +1456,7 @@ export function getLaneBranch(lane, id) {
1414
1456
  return `lane/${laneKebab}/${idLower}`;
1415
1457
  }
1416
1458
  // Note: getWuYamlPath and getStampPath removed in WU-1240
1417
- // 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
1418
1460
  /**
1419
1461
  * File tool constants (WU-1403)
1420
1462
  *
@@ -1487,8 +1529,8 @@ export const PHI_CONFIG = {
1487
1529
  * Constants for the readiness summary box displayed after wu:create and wu:edit.
1488
1530
  * Provides visual feedback on whether WU is ready for wu:claim.
1489
1531
  *
1490
- * @see tools/wu-create.mjs - displayReadinessSummary()
1491
- * @see tools/wu-edit.mjs - displayReadinessSummary()
1532
+ * @see tools/wu-create.ts - displayReadinessSummary()
1533
+ * @see tools/wu-edit.ts - displayReadinessSummary()
1492
1534
  */
1493
1535
  export const READINESS_UI = {
1494
1536
  /** Box width (inner content area) */
@@ -1730,6 +1772,7 @@ export const CONTEXT_VALIDATION = {
1730
1772
  COMMANDS: {
1731
1773
  WU_CREATE: 'wu:create',
1732
1774
  WU_CLAIM: 'wu:claim',
1775
+ WU_PREP: 'wu:prep',
1733
1776
  WU_DONE: 'wu:done',
1734
1777
  WU_BLOCK: 'wu:block',
1735
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`;
@@ -19,6 +19,14 @@ export declare function executePreflightCodePathValidation(id: any, paths: any,
19
19
  missingCodePaths: any[];
20
20
  missingTestPaths: any[];
21
21
  abortedBeforeGates: boolean;
22
+ suggestedTestPaths?: undefined;
23
+ } | {
24
+ valid: boolean;
25
+ errors: any[];
26
+ missingCodePaths: any[];
27
+ missingTestPaths: any[];
28
+ suggestedTestPaths: {};
29
+ abortedBeforeGates: boolean;
22
30
  }>;
23
31
  /**
24
32
  * WU-1805: Build preflight code_paths error message with actionable guidance