@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
@@ -2,7 +2,7 @@
2
2
  * Active WU Detection Utilities
3
3
  *
4
4
  * Detects which WU YAMLs are "active" (referenced in backlog.md/status.md)
5
- * vs "orphan" (legacy/unreferenced). Used by validate.mjs to suppress
5
+ * vs "orphan" (legacy/unreferenced). Used by validate.ts to suppress
6
6
  * lane-checker warnings for orphan WUs.
7
7
  *
8
8
  * WU-1814: Stop lane-checker warnings for orphan WU YAMLs
@@ -2,7 +2,7 @@
2
2
  * Active WU Detection Utilities
3
3
  *
4
4
  * Detects which WU YAMLs are "active" (referenced in backlog.md/status.md)
5
- * vs "orphan" (legacy/unreferenced). Used by validate.mjs to suppress
5
+ * vs "orphan" (legacy/unreferenced). Used by validate.ts to suppress
6
6
  * lane-checker warnings for orphan WUs.
7
7
  *
8
8
  * WU-1814: Stop lane-checker warnings for orphan WU YAMLs
@@ -5,6 +5,12 @@ import { EXIT_CODES } from './wu-constants.js';
5
5
  * Collector function for Commander.js repeatable options.
6
6
  * Accumulates multiple flag values into an array.
7
7
  *
8
+ * Usage: --flag a --flag b → ['a', 'b']
9
+ *
10
+ * This follows Commander.js best practices - use repeatable pattern for
11
+ * multi-value options. Do NOT split on commas here; that's a separate
12
+ * pattern with different semantics (see Commander.js docs).
13
+ *
8
14
  * @param {string} value - New value from CLI
9
15
  * @param {string[]} previous - Previously accumulated values
10
16
  * @returns {string[]} Updated array with new value appended
@@ -28,7 +34,7 @@ export const WU_OPTIONS = {
28
34
  id: {
29
35
  name: 'id',
30
36
  flags: '-i, --id <wuId>',
31
- description: 'Work Unit ID (e.g., WU-123)',
37
+ description: 'Work Unit ID (e.g., WU-123). If not provided, auto-generates next sequential ID.',
32
38
  },
33
39
  wu: {
34
40
  name: 'wu',
@@ -205,17 +211,20 @@ export const WU_OPTIONS = {
205
211
  blockedBy: {
206
212
  name: 'blockedBy',
207
213
  flags: '--blocked-by <wuIds>',
208
- description: 'Comma-separated WU IDs that block this WU',
214
+ description: 'WU IDs that block this WU (repeatable)',
215
+ isRepeatable: true,
209
216
  },
210
217
  blocks: {
211
218
  name: 'blocks',
212
219
  flags: '--blocks <wuIds>',
213
- description: 'Comma-separated WU IDs this WU blocks',
220
+ description: 'WU IDs this WU blocks (repeatable)',
221
+ isRepeatable: true,
214
222
  },
215
223
  labels: {
216
224
  name: 'labels',
217
225
  flags: '--labels <labels>',
218
- description: 'Comma-separated labels',
226
+ description: 'Labels (repeatable)',
227
+ isRepeatable: true,
219
228
  },
220
229
  slug: {
221
230
  name: 'slug',
@@ -311,22 +320,26 @@ export const WU_OPTIONS = {
311
320
  codePaths: {
312
321
  name: 'codePaths',
313
322
  flags: '--code-paths <paths>',
314
- description: 'Code paths (comma-separated)',
323
+ description: 'Code paths (repeatable)',
324
+ isRepeatable: true,
315
325
  },
316
326
  testPathsManual: {
317
327
  name: 'testPathsManual',
318
328
  flags: '--test-paths-manual <tests>',
319
- description: 'Manual test descriptions (comma-separated)',
329
+ description: 'Manual test descriptions (repeatable)',
330
+ isRepeatable: true,
320
331
  },
321
332
  testPathsUnit: {
322
333
  name: 'testPathsUnit',
323
334
  flags: '--test-paths-unit <paths>',
324
- description: 'Unit test file paths (comma-separated)',
335
+ description: 'Unit test file paths (repeatable)',
336
+ isRepeatable: true,
325
337
  },
326
338
  testPathsE2e: {
327
339
  name: 'testPathsE2e',
328
340
  flags: '--test-paths-e2e <paths>',
329
- description: 'E2E test file paths (comma-separated)',
341
+ description: 'E2E test file paths (repeatable)',
342
+ isRepeatable: true,
330
343
  },
331
344
  validate: {
332
345
  name: 'validate',
@@ -337,7 +350,8 @@ export const WU_OPTIONS = {
337
350
  specRefs: {
338
351
  name: 'specRefs',
339
352
  flags: '--spec-refs <paths>',
340
- description: 'Spec/plan references (comma-separated paths to docs, required for type: feature)',
353
+ description: 'Spec/plan references (repeatable or comma-separated, required for type: feature)',
354
+ isRepeatable: true,
341
355
  },
342
356
  // WU-1998: Exposure field options
343
357
  exposure: {
@@ -353,7 +367,8 @@ export const WU_OPTIONS = {
353
367
  uiPairingWus: {
354
368
  name: 'uiPairingWus',
355
369
  flags: '--ui-pairing-wus <wuIds>',
356
- description: 'Comma-separated UI WU IDs that consume this API (for api exposure)',
370
+ description: 'UI WU IDs that consume this API (repeatable or comma-separated, for api exposure)',
371
+ isRepeatable: true,
357
372
  },
358
373
  // WU-1577: Thinking mode options for wu:spawn
359
374
  thinking: {
@@ -384,11 +399,18 @@ export const WU_OPTIONS = {
384
399
  flags: '--parent-wu <wuId>',
385
400
  description: 'Parent WU ID for orchestrator context (e.g., WU-1000)',
386
401
  },
402
+ // WU-1240: Skip memory context injection in spawn prompts
403
+ noContext: {
404
+ name: 'noContext',
405
+ flags: '--no-context',
406
+ description: 'Skip memory context injection in spawn prompts',
407
+ isNegated: true,
408
+ },
387
409
  // WU-1542: Mandatory agent enforcement for wu:done
388
410
  requireAgents: {
389
411
  name: 'requireAgents',
390
412
  flags: '--require-agents',
391
- description: 'Block wu:done if mandatory agents (security-auditor, beacon-guardian) were not invoked for WUs touching their trigger paths',
413
+ description: 'Block wu:done if mandatory agents (configured in MANDATORY_TRIGGERS) were not invoked for WUs touching their trigger paths',
392
414
  },
393
415
  // WU-2411: Agent handoff for crashed/killed agents
394
416
  resume: {
@@ -433,22 +455,33 @@ const NEGATED_OPTIONS = ['auto', 'remove', 'merge', 'autoRebase', 'push'];
433
455
  * @returns {object} Processed options with noFoo properties
434
456
  */
435
457
  function processNegatedOptions(opts) {
436
- const result = { ...opts };
458
+ // Build a new object, excluding keys that need removal
459
+ // This avoids dynamic delete which violates @typescript-eslint/no-dynamic-delete
460
+ const keysToRemove = new Set();
461
+ const keysToAdd = {};
437
462
  for (const key of NEGATED_OPTIONS) {
438
463
  // Commander sets the property to false when --no-foo is used
439
464
  // and undefined when not specified
440
- if (key in result && result[key] === false) {
465
+ if (key in opts && opts[key] === false) {
441
466
  // Convert: auto=false → noAuto=true
442
467
  const camelKey = `no${key.charAt(0).toUpperCase()}${key.slice(1)}`;
443
- result[camelKey] = true;
444
- delete result[key];
468
+ keysToAdd[camelKey] = true;
469
+ keysToRemove.add(key);
445
470
  }
446
- else if (key in result && result[key] === true) {
471
+ else if (key in opts && opts[key] === true) {
447
472
  // Default value (not negated) - remove it
448
- delete result[key];
473
+ keysToRemove.add(key);
474
+ }
475
+ }
476
+ // Build result by filtering out removed keys and adding new ones
477
+ const result = {};
478
+ for (const [key, value] of Object.entries(opts)) {
479
+ if (!keysToRemove.has(key)) {
480
+ result[key] = value;
449
481
  }
450
482
  }
451
- return result;
483
+ // Add the transformed keys
484
+ return { ...result, ...keysToAdd };
452
485
  }
453
486
  /**
454
487
  * Create a commander-based CLI parser for a WU script.
@@ -11,10 +11,10 @@
11
11
  * - computeStoreChecksum(): Computes deterministic checksum of store state
12
12
  * - getCompletionDate(): Retrieves completion date from event timestamp
13
13
  *
14
- * @see {@link tools/__tests__/backlog-generator.test.mjs} - Tests
15
- * @see {@link tools/__tests__/backlog-checksum.test.mjs} - Checksum tests
16
- * @see {@link tools/__tests__/status-date-from-event.test.mjs} - Date tests
17
- * @see {@link tools/lib/wu-state-store.mjs} - State store
14
+ * @see {@link packages/@lumenflow/cli/src/__tests__/backlog-generator.test.ts} - Tests
15
+ * @see {@link packages/@lumenflow/cli/src/__tests__/backlog-checksum.test.ts} - Checksum tests
16
+ * @see {@link packages/@lumenflow/cli/src/__tests__/status-date-from-event.test.ts} - Date tests
17
+ * @see {@link packages/@lumenflow/cli/src/lib/wu-state-store.ts} - State store
18
18
  */
19
19
  interface BacklogYamlOptions {
20
20
  wuDir?: string;
@@ -11,10 +11,10 @@
11
11
  * - computeStoreChecksum(): Computes deterministic checksum of store state
12
12
  * - getCompletionDate(): Retrieves completion date from event timestamp
13
13
  *
14
- * @see {@link tools/__tests__/backlog-generator.test.mjs} - Tests
15
- * @see {@link tools/__tests__/backlog-checksum.test.mjs} - Checksum tests
16
- * @see {@link tools/__tests__/status-date-from-event.test.mjs} - Date tests
17
- * @see {@link tools/lib/wu-state-store.mjs} - State store
14
+ * @see {@link packages/@lumenflow/cli/src/__tests__/backlog-generator.test.ts} - Tests
15
+ * @see {@link packages/@lumenflow/cli/src/__tests__/backlog-checksum.test.ts} - Checksum tests
16
+ * @see {@link packages/@lumenflow/cli/src/__tests__/status-date-from-event.test.ts} - Date tests
17
+ * @see {@link packages/@lumenflow/cli/src/lib/wu-state-store.ts} - State store
18
18
  */
19
19
  import { createHash } from 'node:crypto';
20
20
  import { existsSync, readdirSync } from 'node:fs';
@@ -151,7 +151,7 @@ export function validateBacklogSync(backlogPath) {
151
151
  ` Fix: Migrate to sub-lane format using:${STRING_LITERALS.NEWLINE}` +
152
152
  ` pnpm wu:infer-lane --id WU-123 # Suggest a sub-lane${STRING_LITERALS.NEWLINE}` +
153
153
  ` pnpm wu:edit --id WU-123 --lane "Parent: Sub"${STRING_LITERALS.NEWLINE}` +
154
- ` See: docs/04-operations/_frameworks/lumenflow/sub-lanes.md`);
154
+ ` See: https://lumenflow.dev/reference/sub-lanes/`);
155
155
  }
156
156
  return {
157
157
  valid: errors.length === 0,
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * WU-2241: Cleanup Lock Module
3
+ * WU-1174: Lock files moved to temp directory to avoid polluting main checkout
3
4
  *
4
5
  * Provides atomic locking mechanism for wu:done cleanup operations
5
6
  * to prevent race conditions during concurrent worktree/branch cleanup.
@@ -10,11 +11,12 @@
10
11
  * - Zombie lock detection (PID not running)
11
12
  * - Idempotent re-acquisition for same WU
12
13
  * - Guaranteed cleanup via withCleanupLock wrapper
14
+ * - Lock files stored in temp directory (not main checkout)
13
15
  *
14
16
  * Lock ordering (WU-2241):
15
17
  * Lane lock (phase-scoped) -> Merge lock -> Cleanup lock -> State store lock
16
18
  *
17
- * Pattern: Follows lane-lock.mjs and merge-lock.mjs internal patterns.
19
+ * Pattern: Follows lane-lock.ts and merge-lock.ts internal patterns.
18
20
  *
19
21
  * @module cleanup-lock
20
22
  */
@@ -49,7 +51,12 @@ export declare const CLEANUP_LOCK_STALE_MS: number;
49
51
  * Options for lock file operations
50
52
  */
51
53
  interface BaseDirOptions {
52
- /** Base directory (defaults to cwd) */
54
+ /**
55
+ * Base directory override (for testing only)
56
+ *
57
+ * WU-1174: In production, locks are always stored in LUMENFLOW_PATHS.LOCK_DIR
58
+ * (a temp directory). This option allows tests to use isolated directories.
59
+ */
53
60
  baseDir?: string;
54
61
  }
55
62
  /**
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * WU-2241: Cleanup Lock Module
3
+ * WU-1174: Lock files moved to temp directory to avoid polluting main checkout
3
4
  *
4
5
  * Provides atomic locking mechanism for wu:done cleanup operations
5
6
  * to prevent race conditions during concurrent worktree/branch cleanup.
@@ -10,11 +11,12 @@
10
11
  * - Zombie lock detection (PID not running)
11
12
  * - Idempotent re-acquisition for same WU
12
13
  * - Guaranteed cleanup via withCleanupLock wrapper
14
+ * - Lock files stored in temp directory (not main checkout)
13
15
  *
14
16
  * Lock ordering (WU-2241):
15
17
  * Lane lock (phase-scoped) -> Merge lock -> Cleanup lock -> State store lock
16
18
  *
17
- * Pattern: Follows lane-lock.mjs and merge-lock.mjs internal patterns.
19
+ * Pattern: Follows lane-lock.ts and merge-lock.ts internal patterns.
18
20
  *
19
21
  * @module cleanup-lock
20
22
  */
@@ -22,7 +24,7 @@
22
24
  import { existsSync, readFileSync, writeFileSync, unlinkSync, mkdirSync, openSync, closeSync, } from 'node:fs';
23
25
  import path from 'node:path';
24
26
  import crypto from 'node:crypto';
25
- import { LOG_PREFIX, EMOJI, LUMENFLOW_PATHS } from './wu-constants.js';
27
+ import { LOG_PREFIX, EMOJI, LUMENFLOW_PATHS, LOCK_DIR_NAME } from './wu-constants.js';
26
28
  import { createError, ErrorCodes } from './error-handler.js';
27
29
  /**
28
30
  * Default timeout for waiting to acquire lock (ms)
@@ -44,12 +46,19 @@ const LOCK_POLL_INTERVAL_MS = 500;
44
46
  /**
45
47
  * Get the path to the cleanup lock file
46
48
  *
49
+ * WU-1174: Lock files are stored in a temp directory to avoid polluting
50
+ * the main checkout. The baseDir option is only for testing isolation.
51
+ *
47
52
  * @param {BaseDirOptions} [options]
48
53
  * @returns {string} Path to lock file
49
54
  */
50
55
  function getLockPath(options = {}) {
51
- const baseDir = options.baseDir || process.cwd();
52
- return path.join(baseDir, LUMENFLOW_PATHS.BASE, LOCK_FILE_NAME);
56
+ // WU-1174: Use temp directory for locks (not main checkout's .lumenflow/)
57
+ // baseDir is only used for test isolation
58
+ const lockDir = options.baseDir
59
+ ? path.join(options.baseDir, LOCK_DIR_NAME)
60
+ : LUMENFLOW_PATHS.LOCK_DIR;
61
+ return path.join(lockDir, LOCK_FILE_NAME);
53
62
  }
54
63
  /**
55
64
  * Read lock file contents
@@ -168,9 +177,10 @@ export function getCleanupLockInfo(options = {}) {
168
177
  */
169
178
  function tryAtomicLockCreate(lockInfo, options) {
170
179
  const lockPath = getLockPath(options);
171
- const beaconDir = path.dirname(lockPath);
172
- if (!existsSync(beaconDir)) {
173
- mkdirSync(beaconDir, { recursive: true });
180
+ const lockDir = path.dirname(lockPath);
181
+ // WU-1174: Ensure lock directory exists (temp directory, not .lumenflow/)
182
+ if (!existsSync(lockDir)) {
183
+ mkdirSync(lockDir, { recursive: true });
174
184
  }
175
185
  try {
176
186
  // Use 'wx' flag for atomic creation
@@ -3,9 +3,9 @@
3
3
  * Unified Code Path Validator (WU-1825)
4
4
  *
5
5
  * Consolidates three separate code path validators into one module:
6
- * - validateCodePathsExist (wu-done-validators.mjs) - file existence for wu:done
7
- * - validateLaneCodePaths (lane-validator.mjs) - lane pattern matching
8
- * - validateWUCodePaths (wu-validator.mjs) - code quality (TODOs, mocks)
6
+ * - validateCodePathsExist (wu-done-validators.ts) - file existence for wu:done
7
+ * - validateLaneCodePaths (lane-validator.ts) - lane pattern matching
8
+ * - validateWUCodePaths (wu-validator.ts) - code quality (TODOs, mocks)
9
9
  *
10
10
  * Usage:
11
11
  * import { validate } from './code-path-validator.js';
@@ -3,9 +3,9 @@
3
3
  * Unified Code Path Validator (WU-1825)
4
4
  *
5
5
  * Consolidates three separate code path validators into one module:
6
- * - validateCodePathsExist (wu-done-validators.mjs) - file existence for wu:done
7
- * - validateLaneCodePaths (lane-validator.mjs) - lane pattern matching
8
- * - validateWUCodePaths (wu-validator.mjs) - code quality (TODOs, mocks)
6
+ * - validateCodePathsExist (wu-done-validators.ts) - file existence for wu:done
7
+ * - validateLaneCodePaths (lane-validator.ts) - lane pattern matching
8
+ * - validateWUCodePaths (wu-validator.ts) - code quality (TODOs, mocks)
9
9
  *
10
10
  * Usage:
11
11
  * import { validate } from './code-path-validator.js';
@@ -2,7 +2,7 @@
2
2
  * Compliance Parser
3
3
  *
4
4
  * Parses markdown compliance documentation into structured data.
5
- * Used by compliance-snapshot.mjs tool to create snapshots.
5
+ * Used by compliance-snapshot.ts tool to create snapshots.
6
6
  *
7
7
  * @module tools/lib/compliance-parser
8
8
  */
@@ -2,7 +2,7 @@
2
2
  * Compliance Parser
3
3
  *
4
4
  * Parses markdown compliance documentation into structured data.
5
- * Used by compliance-snapshot.mjs tool to create snapshots.
5
+ * Used by compliance-snapshot.ts tool to create snapshots.
6
6
  *
7
7
  * @module tools/lib/compliance-parser
8
8
  */
@@ -2,7 +2,7 @@
2
2
  * Backlog Parsing Patterns
3
3
  *
4
4
  * Centralizes patterns for parsing status.md and backlog.md files.
5
- * Used by lane-checker.mjs and related backlog utilities.
5
+ * Used by lane-checker.ts and related backlog utilities.
6
6
  */
7
7
  /** Markdown section header patterns for In Progress section */
8
8
  export declare const IN_PROGRESS_HEADERS: string[];
@@ -2,7 +2,7 @@
2
2
  * Backlog Parsing Patterns
3
3
  *
4
4
  * Centralizes patterns for parsing status.md and backlog.md files.
5
- * Used by lane-checker.mjs and related backlog utilities.
5
+ * Used by lane-checker.ts and related backlog utilities.
6
6
  */
7
7
  /** Markdown section header patterns for In Progress section */
8
8
  export const IN_PROGRESS_HEADERS = ['## in progress', '## 🔧 in progress'];
@@ -2,7 +2,7 @@
2
2
  * DORA Metrics Constants
3
3
  *
4
4
  * Thresholds based on "Accelerate" research by Nicole Forsgren, Jez Humble, Gene Kim.
5
- * Used by calculate-dora-metrics.mjs.
5
+ * Used by calculate-dora-metrics.ts.
6
6
  */
7
7
  /** Deployment frequency classification thresholds (deploys per week) */
8
8
  export declare const DEPLOYMENT_FREQUENCY: {
@@ -2,7 +2,7 @@
2
2
  * DORA Metrics Constants
3
3
  *
4
4
  * Thresholds based on "Accelerate" research by Nicole Forsgren, Jez Humble, Gene Kim.
5
- * Used by calculate-dora-metrics.mjs.
5
+ * Used by calculate-dora-metrics.ts.
6
6
  */
7
7
  /** Deployment frequency classification thresholds (deploys per week) */
8
8
  export const DEPLOYMENT_FREQUENCY = {
@@ -2,7 +2,7 @@
2
2
  * Gate Configuration Constants
3
3
  *
4
4
  * Centralizes magic numbers for pre-commit and local gates.
5
- * Used by gates-pre-commit.mjs and gates-local.mjs.
5
+ * Used by gates-pre-commit.ts and gates-local.ts.
6
6
  */
7
7
  /** Gate execution configuration */
8
8
  export declare const GATE_CONFIG: {
@@ -2,7 +2,7 @@
2
2
  * Gate Configuration Constants
3
3
  *
4
4
  * Centralizes magic numbers for pre-commit and local gates.
5
- * Used by gates-pre-commit.mjs and gates-local.mjs.
5
+ * Used by gates-pre-commit.ts and gates-local.ts.
6
6
  */
7
7
  /** Gate execution configuration */
8
8
  export const GATE_CONFIG = {
@@ -2,7 +2,7 @@
2
2
  * Linter Configuration Constants
3
3
  *
4
4
  * Centralizes magic numbers for spec-linter and related validation tools.
5
- * Used by packages/linters/spec-linter.mjs.
5
+ * Used by packages/linters/spec-linter.ts.
6
6
  */
7
7
  /** Spec linter configuration */
8
8
  export declare const LINTER_CONFIG: {
@@ -2,7 +2,7 @@
2
2
  * Linter Configuration Constants
3
3
  *
4
4
  * Centralizes magic numbers for spec-linter and related validation tools.
5
- * Used by packages/linters/spec-linter.mjs.
5
+ * Used by packages/linters/spec-linter.ts.
6
6
  */
7
7
  /** Spec linter configuration */
8
8
  export const LINTER_CONFIG = {
@@ -2,7 +2,7 @@
2
2
  * Tokenizer Constants
3
3
  *
4
4
  * Configuration for token estimation in documentation files.
5
- * Used by token-count.mjs.
5
+ * Used by token-count.ts.
6
6
  */
7
7
  /** Token estimation configuration */
8
8
  export declare const TOKENIZER: {
@@ -2,7 +2,7 @@
2
2
  * Tokenizer Constants
3
3
  *
4
4
  * Configuration for token estimation in documentation files.
5
- * Used by token-count.mjs.
5
+ * Used by token-count.ts.
6
6
  */
7
7
  /** Token estimation configuration */
8
8
  export const TOKENIZER = {
@@ -38,7 +38,8 @@ export async function resolveLocation(cwd = process.cwd()) {
38
38
  const gitRoot = (await git.revparse(['--show-toplevel'])).trim();
39
39
  const gitDir = (await git.revparse(['--git-dir'])).trim();
40
40
  // Detect if we're in a worktree (in worktrees, .git is a file not a dir)
41
- const isWorktree = isGitDirFile(gitDir);
41
+ // WU-1223: Fixed - check .git in gitRoot, not the gitDir path returned by rev-parse
42
+ const isWorktree = isGitDirFile(resolve(gitRoot, '.git'));
42
43
  const mainCheckout = isWorktree ? await findMainCheckout(git) : gitRoot;
43
44
  // Parse worktree info
44
45
  const worktreeName = isWorktree ? parseWorktreeName(gitRoot, mainCheckout) : null;
@@ -12,6 +12,7 @@ import type { WuContext, ValidationResult } from './validation/types.js';
12
12
  declare const COMMANDS: {
13
13
  readonly WU_CREATE: "wu:create";
14
14
  readonly WU_CLAIM: "wu:claim";
15
+ readonly WU_PREP: "wu:prep";
15
16
  readonly WU_DONE: "wu:done";
16
17
  readonly WU_BLOCK: "wu:block";
17
18
  readonly WU_UNBLOCK: "wu:unblock";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file scope-checker.mjs
2
+ * @file scope-checker.ts
3
3
  * @description WU scope validation and code_paths enforcement (WU-1397)
4
4
  *
5
5
  * Provides runtime validation that file modifications stay within WU code_paths.
@@ -13,8 +13,8 @@
13
13
  *
14
14
  * Used by wu- scripts and future file operation guards.
15
15
  *
16
- * @see {@link tools/lib/core/worktree-guard.mjs} - WU context detection
17
- * @see {@link tools/lib/wu-schema.mjs} - WU YAML parsing
16
+ * @see {@link packages/@lumenflow/cli/src/lib/core/worktree-guard.ts} - WU context detection
17
+ * @see {@link packages/@lumenflow/cli/src/lib/wu-schema.ts} - WU YAML parsing
18
18
  */
19
19
  import { getWUContext } from './worktree-guard.js';
20
20
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file scope-checker.mjs
2
+ * @file scope-checker.ts
3
3
  * @description WU scope validation and code_paths enforcement (WU-1397)
4
4
  *
5
5
  * Provides runtime validation that file modifications stay within WU code_paths.
@@ -13,8 +13,8 @@
13
13
  *
14
14
  * Used by wu- scripts and future file operation guards.
15
15
  *
16
- * @see {@link tools/lib/core/worktree-guard.mjs} - WU context detection
17
- * @see {@link tools/lib/wu-schema.mjs} - WU YAML parsing
16
+ * @see {@link packages/@lumenflow/cli/src/lib/core/worktree-guard.ts} - WU context detection
17
+ * @see {@link packages/@lumenflow/cli/src/lib/wu-schema.ts} - WU YAML parsing
18
18
  */
19
19
  import micromatch from 'micromatch';
20
20
  import { getWUContext } from './worktree-guard.js';
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @file tool-runner.mjs
2
+ * @file tool-runner.ts
3
3
  * @description Unified tool execution layer integrating all core components (WU-1398)
4
4
  *
5
5
  * This module provides a higher-order function pattern for executing tools with:
6
6
  * - Input validation via Zod schemas (tool.schemas.ts)
7
- * - Worktree context detection (worktree-guard.mjs)
8
- * - Scope validation against code_paths (scope-checker.mjs)
7
+ * - Worktree context detection (worktree-guard.ts)
8
+ * - Scope validation against code_paths (scope-checker.ts)
9
9
  * - Audit logging for telemetry (.lumenflow/telemetry/tools.ndjson)
10
10
  * - Consistent error handling with agent-friendly messages
11
11
  *
@@ -21,8 +21,8 @@
21
21
  * const result = await runner.run('tool:name', { arg: 'value' });
22
22
  *
23
23
  * @see tools/lib/core/tool.schemas.ts - Zod schemas for tool I/O
24
- * @see tools/lib/core/worktree-guard.mjs - WU context detection
25
- * @see tools/lib/core/scope-checker.mjs - Code path validation
24
+ * @see tools/lib/core/worktree-guard.ts - WU context detection
25
+ * @see tools/lib/core/scope-checker.ts - Code path validation
26
26
  */
27
27
  interface ToolMetadata {
28
28
  name: string;
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @file tool-runner.mjs
2
+ * @file tool-runner.ts
3
3
  * @description Unified tool execution layer integrating all core components (WU-1398)
4
4
  *
5
5
  * This module provides a higher-order function pattern for executing tools with:
6
6
  * - Input validation via Zod schemas (tool.schemas.ts)
7
- * - Worktree context detection (worktree-guard.mjs)
8
- * - Scope validation against code_paths (scope-checker.mjs)
7
+ * - Worktree context detection (worktree-guard.ts)
8
+ * - Scope validation against code_paths (scope-checker.ts)
9
9
  * - Audit logging for telemetry (.lumenflow/telemetry/tools.ndjson)
10
10
  * - Consistent error handling with agent-friendly messages
11
11
  *
@@ -21,8 +21,8 @@
21
21
  * const result = await runner.run('tool:name', { arg: 'value' });
22
22
  *
23
23
  * @see tools/lib/core/tool.schemas.ts - Zod schemas for tool I/O
24
- * @see tools/lib/core/worktree-guard.mjs - WU context detection
25
- * @see tools/lib/core/scope-checker.mjs - Code path validation
24
+ * @see tools/lib/core/worktree-guard.ts - WU context detection
25
+ * @see tools/lib/core/scope-checker.ts - Code path validation
26
26
  */
27
27
  import { TOOL_ERROR_CODES, PERMISSION_LEVELS, TOOL_STATUS, DEFAULT_TOOL_TIMEOUT_MS, } from './tool.constants.js';
28
28
  import { validateToolInput, createErrorOutput } from './tool.schemas.js';
@@ -48,7 +48,7 @@ export declare const PERMISSION_LEVELS: {
48
48
  };
49
49
  export type PermissionLevel = (typeof PERMISSION_LEVELS)[keyof typeof PERMISSION_LEVELS];
50
50
  /**
51
- * Tool error codes (extends existing ErrorCodes from error-handler.mjs)
51
+ * Tool error codes (extends existing ErrorCodes from error-handler.ts)
52
52
  */
53
53
  export declare const TOOL_ERROR_CODES: {
54
54
  /** Tool not found in registry */
@@ -46,7 +46,7 @@ export const PERMISSION_LEVELS = {
46
46
  ADMIN: 'admin',
47
47
  };
48
48
  /**
49
- * Tool error codes (extends existing ErrorCodes from error-handler.mjs)
49
+ * Tool error codes (extends existing ErrorCodes from error-handler.ts)
50
50
  */
51
51
  export const TOOL_ERROR_CODES = {
52
52
  /** Tool not found in registry */
@@ -6,7 +6,7 @@
6
6
  * outputs, and metadata. Supports JSON Schema export for provider adapters
7
7
  * (MCP, OpenAI, Gemini).
8
8
  *
9
- * Reference: tools/lib/arg-parser.mjs for current argument handling patterns
9
+ * Reference: tools/lib/arg-parser.ts for current argument handling patterns
10
10
  */
11
11
  import { z, type ZodTypeAny } from 'zod';
12
12
  /**
@@ -140,8 +140,8 @@ export declare const ToolExecutionResultSchema: z.ZodObject<{
140
140
  tool: z.ZodString;
141
141
  status: z.ZodEnum<{
142
142
  cancelled: "cancelled";
143
- timeout: "timeout";
144
143
  success: "success";
144
+ timeout: "timeout";
145
145
  failed: "failed";
146
146
  pending: "pending";
147
147
  running: "running";
@@ -6,7 +6,7 @@
6
6
  * outputs, and metadata. Supports JSON Schema export for provider adapters
7
7
  * (MCP, OpenAI, Gemini).
8
8
  *
9
- * Reference: tools/lib/arg-parser.mjs for current argument handling patterns
9
+ * Reference: tools/lib/arg-parser.ts for current argument handling patterns
10
10
  */
11
11
  import { z } from 'zod';
12
12
  import { TOOL_DOMAINS, PERMISSION_LEVELS, TOOL_STATUS, } from './tool.constants.js';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file worktree-guard.mjs
2
+ * @file worktree-guard.ts
3
3
  * @description WU context validation and main branch protection (WU-1396)
4
4
  *
5
5
  * Provides runtime guards to enforce worktree discipline: