@lumenflow/core 1.0.0 → 1.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 (79) hide show
  1. package/dist/arg-parser.d.ts +6 -0
  2. package/dist/arg-parser.js +57 -1
  3. package/dist/backlog-generator.js +1 -1
  4. package/dist/backlog-sync-validator.js +3 -3
  5. package/dist/branch-check.d.ts +21 -0
  6. package/dist/branch-check.js +77 -0
  7. package/dist/cli/is-agent-branch.d.ts +11 -0
  8. package/dist/cli/is-agent-branch.js +15 -0
  9. package/dist/code-paths-overlap.js +2 -2
  10. package/dist/error-handler.d.ts +1 -0
  11. package/dist/error-handler.js +4 -1
  12. package/dist/git-adapter.d.ts +23 -0
  13. package/dist/git-adapter.js +38 -2
  14. package/dist/index.d.ts +3 -0
  15. package/dist/index.js +5 -0
  16. package/dist/lane-checker.d.ts +36 -3
  17. package/dist/lane-checker.js +128 -17
  18. package/dist/lane-inference.js +3 -4
  19. package/dist/lumenflow-config-schema.d.ts +125 -0
  20. package/dist/lumenflow-config-schema.js +76 -0
  21. package/dist/lumenflow-home.d.ts +130 -0
  22. package/dist/lumenflow-home.js +208 -0
  23. package/dist/manual-test-validator.js +1 -1
  24. package/dist/orchestration-rules.d.ts +1 -1
  25. package/dist/orchestration-rules.js +2 -2
  26. package/dist/orphan-detector.d.ts +16 -0
  27. package/dist/orphan-detector.js +24 -0
  28. package/dist/path-classifiers.d.ts +1 -1
  29. package/dist/path-classifiers.js +1 -1
  30. package/dist/rebase-artifact-cleanup.d.ts +17 -0
  31. package/dist/rebase-artifact-cleanup.js +49 -8
  32. package/dist/spawn-strategy.d.ts +53 -0
  33. package/dist/spawn-strategy.js +106 -0
  34. package/dist/spec-branch-helpers.d.ts +118 -0
  35. package/dist/spec-branch-helpers.js +192 -0
  36. package/dist/stamp-utils.d.ts +10 -0
  37. package/dist/stamp-utils.js +17 -19
  38. package/dist/token-counter.js +2 -2
  39. package/dist/wu-consistency-checker.d.ts +2 -0
  40. package/dist/wu-consistency-checker.js +40 -6
  41. package/dist/wu-constants.d.ts +98 -3
  42. package/dist/wu-constants.js +108 -3
  43. package/dist/wu-create-validators.d.ts +40 -2
  44. package/dist/wu-create-validators.js +76 -2
  45. package/dist/wu-done-branch-only.js +9 -0
  46. package/dist/wu-done-branch-utils.d.ts +10 -0
  47. package/dist/wu-done-branch-utils.js +31 -0
  48. package/dist/wu-done-cleanup.d.ts +8 -0
  49. package/dist/wu-done-cleanup.js +122 -0
  50. package/dist/wu-done-docs-generate.d.ts +73 -0
  51. package/dist/wu-done-docs-generate.js +108 -0
  52. package/dist/wu-done-docs-only.d.ts +20 -0
  53. package/dist/wu-done-docs-only.js +65 -0
  54. package/dist/wu-done-errors.d.ts +17 -0
  55. package/dist/wu-done-errors.js +24 -0
  56. package/dist/wu-done-inputs.d.ts +12 -0
  57. package/dist/wu-done-inputs.js +51 -0
  58. package/dist/wu-done-metadata.d.ts +100 -0
  59. package/dist/wu-done-metadata.js +193 -0
  60. package/dist/wu-done-paths.d.ts +69 -0
  61. package/dist/wu-done-paths.js +237 -0
  62. package/dist/wu-done-preflight.d.ts +48 -0
  63. package/dist/wu-done-preflight.js +185 -0
  64. package/dist/wu-done-validation.d.ts +82 -0
  65. package/dist/wu-done-validation.js +340 -0
  66. package/dist/wu-done-validators.d.ts +13 -409
  67. package/dist/wu-done-validators.js +9 -1225
  68. package/dist/wu-done-worktree.d.ts +0 -1
  69. package/dist/wu-done-worktree.js +24 -30
  70. package/dist/wu-schema.js +4 -4
  71. package/dist/wu-spawn-skills.d.ts +19 -0
  72. package/dist/wu-spawn-skills.js +148 -0
  73. package/dist/wu-spawn.d.ts +17 -4
  74. package/dist/wu-spawn.js +113 -177
  75. package/dist/wu-validation.d.ts +1 -0
  76. package/dist/wu-validation.js +21 -1
  77. package/dist/wu-validator.d.ts +51 -0
  78. package/dist/wu-validator.js +108 -0
  79. package/package.json +12 -8
@@ -1,411 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Validation functions for wu:done workflow
4
- * Extracted from wu-done.mjs (WU-1215 refactoring)
5
- */
6
- import { execSync as execSyncImport } from 'node:child_process';
7
- import { validateAutomatedTestRequirement } from './manual-test-validator.js';
8
- import { validatePreflight } from './wu-preflight-validators.js';
9
- /**
10
- * Validates command-line inputs and WU ID format
11
- * @param {string[]} argv - Process arguments
12
- * @returns {{ args: object, id: string }} Parsed args and validated WU ID
13
- */
14
- export declare function validateInputs(argv: any): {
15
- args: import("commander").OptionValues;
16
- id: any;
17
- };
18
- /**
19
- * Read WU YAML preferring worktree version over main version
20
- *
21
- * WU-1584 Fix #4: Added diagnostic logging to confirm which YAML file is being
22
- * read for code_paths validation. This helps debug issues where worktree YAML
23
- * differs from main checkout YAML.
24
- *
25
- * @param {string} id - WU ID
26
- * @param {string|null} worktreePath - Worktree path (null if branch-only mode)
27
- * @param {string} mainWUPath - Path to WU YAML in main checkout
28
- * @returns {object} Parsed WU document
29
- */
30
- export declare function readWUPreferWorktree(id: any, worktreePath: any, mainWUPath: any): any;
31
- /**
32
- * Detect if currently running inside a worktree
33
- * Checks for .git file (not directory) which indicates a worktree
34
- * @returns {string|null} Current directory path if inside worktree, null otherwise
35
- */
36
- export declare function detectCurrentWorktree(): string;
37
- /**
38
- * Resolve worktree path from WU YAML
39
- * Originally implemented in WU-1226, extracted to validators module in WU-1215
40
- * Priority:
41
- * 1. Read worktree_path field (set at claim time, immune to lane field changes)
42
- * 2. Fall back to calculating from lane field (for old WUs without worktree_path)
43
- * 3. Use git worktree list to find actual path (defensive fallback)
44
- * @param {object} doc - WU YAML document
45
- * @returns {Promise<string|null>} - Worktree path or null if not found
46
- */
47
- export declare function defaultWorktreeFrom(doc: any): Promise<any>;
48
- /**
49
- * Detect workspace mode from WU YAML
50
- * @param {object} doc - WU YAML document
51
- * @returns {'worktree' | 'branch-only'}
52
- */
53
- export declare function detectWorkspaceMode(doc: any): string;
54
- /**
55
- * Calculate lane branch name from WU YAML
56
- * @param {object} doc - WU YAML document
57
- * @returns {string|null} Lane branch name (e.g., lane/operations-tooling/wu-1215)
58
- */
59
- export declare function defaultBranchFrom(doc: any): string;
60
- /**
61
- * Check if a branch exists
62
- * @param {string} branch - Branch name to check
63
- * @returns {Promise<boolean>} True if branch exists
64
- */
65
- export declare function branchExists(branch: any): Promise<boolean>;
66
- /**
67
- * Detect workspace mode and calculate all relevant paths
68
- * @param {string} id - WU ID
69
- * @param {object} args - Parsed command-line arguments
70
- * @returns {Promise<object>} Object containing paths, mode info, and WU document
71
- */
72
- export declare function detectModeAndPaths(id: any, args: any): Promise<{
73
- WU_PATH: string;
74
- STATUS_PATH: string;
75
- BACKLOG_PATH: string;
76
- STAMPS_DIR: string;
77
- docMain: any;
78
- workspaceMode: string;
79
- isBranchOnly: boolean;
80
- derivedWorktree: any;
81
- docForValidation: any;
82
- isDocsOnly: boolean;
83
- }>;
84
- /**
85
- * Generate commit message for WU completion
86
- * Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
87
- * @param {string} id - WU ID (e.g., "WU-1215")
88
- * @param {string} title - WU title
89
- * @param {number} maxLength - Maximum commit header length from commitlint config
90
- * @returns {string} Formatted commit message
91
- * @throws {Error} If generated message exceeds maxLength
92
- */
93
- export declare function generateCommitMessage(id: any, title: any, maxLength?: number): string;
94
- /**
95
- * Validate that required metadata files exist before updating
96
- * WU-1275: Fail fast before mutations to prevent partial state
97
- *
98
- * @param {object} params - Parameters object
99
- * @param {string} params.statusPath - Path to status.md file
100
- * @param {string} params.backlogPath - Path to backlog.md file
101
- * @throws {WUError} If any required file is missing
102
- */
103
- export declare function validateMetadataFilesExist({ statusPath, backlogPath }: {
104
- statusPath: any;
105
- backlogPath: any;
106
- }): void;
107
- /**
108
- * Update all metadata files for WU completion
109
- * Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
110
- * WU-1572: Made async for WUStateStore integration
111
- * @param {object} params - Parameters object
112
- * @param {string} params.id - WU ID
113
- * @param {string} params.title - WU title
114
- * @param {object} params.doc - WU YAML document to update
115
- * @param {string} params.wuPath - Path to WU YAML file
116
- * @param {string} params.statusPath - Path to status.md file
117
- * @param {string} params.backlogPath - Path to backlog.md file
118
- */
119
- export declare function updateMetadataFiles({ id, title, doc, wuPath, statusPath, backlogPath }: {
120
- id: any;
121
- title: any;
122
- doc: any;
123
- wuPath: any;
124
- statusPath: any;
125
- backlogPath: any;
126
- }): Promise<void>;
127
- /**
128
- * Collect metadata updates to a transaction (WU-1369: Atomic pattern)
129
- *
130
- * This is the atomic version of updateMetadataFiles.
131
- * Instead of writing files immediately, it collects all changes
132
- * into a WUTransaction object for atomic commit.
133
- *
134
- * Usage:
135
- * ```js
136
- * const tx = new WUTransaction(id);
137
- * collectMetadataToTransaction({ id, title, doc, wuPath, statusPath, backlogPath, stampPath, transaction: tx });
138
- * // All changes are now in tx.pendingWrites
139
- * // Validate, then commit or abort
140
- * tx.commit();
141
- * ```
142
- *
143
- * @param {object} params - Parameters object
144
- * @param {string} params.id - WU ID
145
- * @param {string} params.title - WU title
146
- * @param {object} params.doc - WU YAML document to update (will be mutated)
147
- * @param {string} params.wuPath - Path to WU YAML file
148
- * @param {string} params.statusPath - Path to status.md file
149
- * @param {string} params.backlogPath - Path to backlog.md file
150
- * @param {string} params.stampPath - Path to stamp file
151
- * @param {WUTransaction} params.transaction - Transaction to add writes to
152
- */
153
- export declare function collectMetadataToTransaction({ id, title, doc, wuPath, statusPath, backlogPath, stampPath, transaction, }: {
154
- id: any;
155
- title: any;
156
- doc: any;
157
- wuPath: any;
158
- statusPath: any;
159
- backlogPath: any;
160
- stampPath: any;
161
- transaction: any;
162
- }): Promise<void>;
163
- /**
164
- * Stage and format metadata files
165
- * Extracted from wu-done.mjs (WU-1215 Phase 2 Extraction #1 Helper)
166
- * @param {object} params - Parameters object
167
- * @param {string} params.id - WU ID (for error reporting)
168
- * @param {string} params.wuPath - Path to WU YAML file
169
- * @param {string} params.statusPath - Path to status.md file
170
- * @param {string} params.backlogPath - Path to backlog.md file
171
- * @param {string} params.stampsDir - Path to stamps directory
172
- * @throws {Error} If formatting fails
173
- */
174
- export declare function stageAndFormatMetadata({ id, wuPath, statusPath, backlogPath, stampsDir }: {
175
- id: any;
176
- wuPath: any;
177
- statusPath: any;
178
- backlogPath: any;
179
- stampsDir: any;
180
- }): Promise<void>;
181
- /**
182
- * Run cleanup operations after successful merge
183
- * Removes worktree and optionally deletes lane branch
184
- * Extracted from wu-done.mjs (WU-1215 Phase 1 Extraction #3)
185
- *
186
- * WU-2241: Now wrapped with cleanup lock to prevent concurrent collision
187
- * when multiple wu:done commands complete simultaneously.
188
- *
189
- * @param {object} docMain - WU YAML document
190
- * @param {object} args - Parsed CLI arguments
191
- */
192
- export declare function runCleanup(docMain: any, args: any): Promise<void>;
193
- /**
194
- * WU-1351: Validate code_paths files exist on main branch
195
- *
196
- * Prevents false completions by ensuring all code_paths entries
197
- * actually exist on the target branch (main or lane branch).
198
- *
199
- * This guards against:
200
- * - Stamps being created for WUs where code never merged
201
- * - Metadata becoming desynchronized from actual code
202
- *
203
- * @param {object} doc - WU YAML document
204
- * @param {string} id - WU ID
205
- * @param {ValidateCodePathsExistOptions} options - Options
206
- * @returns {Promise<{ valid: boolean, errors: string[], missing: string[] }>} Validation result
207
- */
208
- export interface ValidateCodePathsExistOptions {
209
- /** Branch to check files against (default: 'main') */
210
- targetBranch?: string;
211
- /** Worktree path for worktree mode */
212
- worktreePath?: string | null;
213
- }
214
- export declare function validateCodePathsExist(doc: any, id: any, options?: ValidateCodePathsExistOptions): Promise<{
215
- valid: boolean;
216
- errors: any[];
217
- missing: any[];
218
- }>;
219
- /**
220
- * Validate WU spec completeness (WU-1162, WU-1280)
221
- *
222
- * Ensures WU specifications are complete before allowing wu:done to proceed.
223
- * Prevents placeholder WUs from being marked as done.
224
- *
225
- * WU-1280: Added tests array validation to catch empty tests.manual early
226
- * (previously only validated in pre-commit hook, causing late failures).
227
- *
228
- * @param {object} doc - WU YAML document
229
- * @param {string} id - WU ID
230
- * @returns {{ valid: boolean, errors: string[] }} Validation result
231
- */
232
- export declare function validateSpecCompleteness(doc: any, _id: any): {
233
- valid: boolean;
234
- errors: any[];
235
- };
236
- export { validateAutomatedTestRequirement };
237
- /**
238
- * WU-1617: Post-mutation validation for wu:done
239
- *
240
- * Validates that metadata files written by tx.commit() are valid:
241
- * 1. WU YAML has completed_at field with valid ISO datetime
242
- * 2. WU YAML has locked: true
243
- * 3. Stamp file exists
244
- *
245
- * This catches schema violations that could persist silently after
246
- * transaction commit.
247
- *
248
- * @param {object} params - Validation parameters
249
- * @param {string} params.id - WU ID
250
- * @param {string} params.wuPath - Path to WU YAML file
251
- * @param {string} params.stampPath - Path to stamp file
252
- * @returns {{ valid: boolean, errors: string[] }} Validation result
253
- */
254
- export declare function validatePostMutation({ id, wuPath, stampPath }: {
255
- id: any;
256
- wuPath: any;
257
- stampPath: any;
258
- }): {
259
- valid: boolean;
260
- errors: any[];
261
- };
262
- /**
263
- * WU-1781: Build preflight error message with actionable guidance
264
- *
265
- * Creates a formatted error message for preflight validation failures,
266
- * including specific guidance for stamp-status mismatch errors.
267
- *
268
- * @param {string} id - WU ID being completed
269
- * @param {string[]} errors - List of validation errors
270
- * @returns {string} Formatted error message with fix options
271
- */
272
- export declare function buildPreflightErrorMessage(id: any, errors: any): string;
273
- /**
274
- * WU-1805: Execute preflight code_paths and test_paths validation
275
- *
276
- * Validates that all code_paths and test file paths specified in the WU YAML
277
- * actually exist before running gates. This catches YAML mismatches early,
278
- * saving time compared to discovering issues after a full gate run.
279
- *
280
- * This is run as the FIRST validation step in wu:done, before gates.
281
- *
282
- * @param {string} id - WU ID being completed
283
- * @param {object} paths - Path options
284
- * @param {string} paths.rootDir - Root directory for YAML lookup
285
- * @param {string} paths.worktreePath - Worktree path for file existence checks
286
- * @param {ExecutePreflightCodePathValidationOptions} options - Options for testing
287
- * @returns {Promise<{ valid: boolean, errors: string[], missingCodePaths: string[], missingTestPaths: string[], abortedBeforeGates: boolean }>}
288
- */
289
- interface ExecutePreflightCodePathValidationOptions {
290
- /** Override validatePreflight for testing */
291
- validatePreflightFn?: typeof validatePreflight;
292
- }
293
- export declare function executePreflightCodePathValidation(id: any, paths: any, options?: ExecutePreflightCodePathValidationOptions): Promise<{
294
- valid: boolean;
295
- errors: any[];
296
- missingCodePaths: any[];
297
- missingTestPaths: any[];
298
- abortedBeforeGates: boolean;
299
- }>;
300
- /**
301
- * WU-1805: Build preflight code_paths error message with actionable guidance
302
- *
303
- * Creates a formatted error message for preflight code_paths validation failures,
304
- * including specific guidance for fixing missing files.
305
- *
306
- * @param {string} id - WU ID being completed
307
- * @param {object} result - Preflight validation result
308
- * @param {string[]} result.errors - List of validation errors
309
- * @param {string[]} result.missingCodePaths - Missing code_paths files
310
- * @param {string[]} result.missingTestPaths - Missing test files
311
- * @returns {string} Formatted error message with fix options
312
- */
313
- export declare function buildPreflightCodePathErrorMessage(id: any, result: any): string;
314
- /**
315
- * WU-1781: Run tasks:validate as preflight check before any git operations
316
- *
317
- * This prevents deadlocks where wu:done completes merge but then pre-push
318
- * fails on tasks:validate, leaving local main ahead of origin.
319
- *
320
- * @param {string} id - WU ID being completed
321
- * @param {ExecSyncOverrideOptions} options - Options for testing
322
- * @returns {{ valid: boolean, errors: string[], abortedBeforeMerge: boolean, localMainModified: boolean, hasStampStatusError: boolean }}
323
- */
324
- interface ExecSyncOverrideOptions {
325
- /** Override execSync for testing (default: child_process.execSync) */
326
- execSyncFn?: typeof execSyncImport;
327
- }
328
- export declare function runPreflightTasksValidation(id: any, options?: ExecSyncOverrideOptions): {
329
- valid: boolean;
330
- errors: any;
331
- abortedBeforeMerge: boolean;
332
- localMainModified: boolean;
333
- hasStampStatusError: any;
334
- };
335
- /**
336
- * WU-2308: Validate all pre-commit hooks with worktree context
337
- *
338
- * Runs pre-commit validation gates from the worktree directory when provided.
339
- * This ensures that dependency audits check the worktree's dependencies
340
- * (with any fixes) rather than main's potentially stale dependencies.
341
- *
342
- * @param {string} id - WU ID being completed
343
- * @param {string|null} worktreePath - Path to worktree (null = run from current dir)
344
- * @param {ExecSyncOverrideOptions} options - Options for testing
345
- * @returns {{ valid: boolean, errors: string[] }}
346
- */
347
- export declare function validateAllPreCommitHooks(id: any, worktreePath?: any, options?: ExecSyncOverrideOptions): {
348
- valid: boolean;
349
- errors: any[];
350
- };
351
- /**
352
- * WU-2242: Validate that test_paths is required for non-doc WUs
353
- *
354
- * Enforces that WUs with code changes (non-documentation types with code_paths
355
- * that contain actual code) have at least one test path specified.
356
- *
357
- * Returns valid: true in the following cases:
358
- * - WU type is 'documentation' or 'process'
359
- * - code_paths is empty or only contains documentation paths
360
- * - tests object has at least one test (unit, e2e, manual, or integration)
361
- *
362
- * @param {object} wu - WU document
363
- * @param {string} wu.id - WU ID
364
- * @param {string} wu.type - WU type (feature, bug, documentation, etc.)
365
- * @param {object} wu.tests - Tests object with unit, e2e, manual, integration arrays
366
- * @param {string[]} wu.code_paths - Array of code paths
367
- * @returns {{ valid: boolean, error?: string }}
368
- */
369
- export declare function validateTestPathsRequired(wu: any): {
370
- valid: boolean;
371
- error?: undefined;
372
- } | {
373
- valid: boolean;
374
- error: string;
375
- };
376
- /**
377
- * WU-2310: Validate type vs code_paths at preflight (before transaction starts).
378
- *
379
- * This catches the documentation WU + code file mismatch BEFORE any transaction
380
- * begins, preventing the scenario where:
381
- * 1. Transaction commits files (stamp, status, backlog)
382
- * 2. Git commit fails due to pre-commit hook (gateDocsOnlyPathEnforcement)
383
- * 3. Files are left in inconsistent state
384
- *
385
- * By running this validation at preflight, we fail fast with a clear error
386
- * message before any file mutations occur.
387
- *
388
- * @param {object} wu - WU document
389
- * @param {string} wu.id - WU ID
390
- * @param {string} wu.type - WU type (documentation, feature, bug, etc.)
391
- * @param {string[]} [wu.code_paths] - Array of code paths
392
- * @returns {{ valid: boolean, errors: string[], blockedPaths: string[], abortedBeforeTransaction: boolean }}
393
- */
394
- export declare function validateTypeVsCodePathsPreflight(wu: any): {
395
- valid: boolean;
396
- errors: any[];
397
- blockedPaths: any[];
398
- abortedBeforeTransaction: boolean;
399
- };
400
- /**
401
- * WU-2310: Build error message for type vs code_paths preflight failure.
402
- *
403
- * Provides actionable guidance for fixing the mismatch:
404
- * 1. Change WU type to 'engineering' or appropriate type
405
- * 2. Update code_paths to only include documentation files
406
- *
407
- * @param {string} id - WU ID
408
- * @param {string[]} blockedPaths - Paths that would be blocked
409
- * @returns {string} Formatted error message
410
- */
411
- export declare function buildTypeVsCodePathsErrorMessage(id: any, blockedPaths: any): string;
3
+ * wu:done validators - aggregated exports
4
+ *
5
+ * WU-1049: Split validators into focused modules while preserving exports.
6
+ */
7
+ export { validateInputs } from './wu-done-inputs.js';
8
+ export { readWUPreferWorktree, detectCurrentWorktree, defaultWorktreeFrom, detectWorkspaceMode, defaultBranchFrom, branchExists, detectModeAndPaths, } from './wu-done-paths.js';
9
+ export { generateCommitMessage, validateMetadataFilesExist, updateMetadataFiles, collectMetadataToTransaction, stageAndFormatMetadata, } from './wu-done-metadata.js';
10
+ export { runCleanup } from './wu-done-cleanup.js';
11
+ export { applyExposureDefaults, validateCodePathsExist, validateSpecCompleteness, validatePostMutation, validateTestPathsRequired, validateTypeVsCodePathsPreflight, buildTypeVsCodePathsErrorMessage, } from './wu-done-validation.js';
12
+ export { buildPreflightErrorMessage, executePreflightCodePathValidation, buildPreflightCodePathErrorMessage, runPreflightTasksValidation, validateAllPreCommitHooks, } from './wu-done-preflight.js';
13
+ export { validateAutomatedTestRequirement } from './manual-test-validator.js';
14
+ export type { ValidateCodePathsExistOptions } from './wu-done-validation.js';
15
+ export type { ExecutePreflightCodePathValidationOptions, ExecSyncOverrideOptions, } from './wu-done-preflight.js';