@lumenflow/cli 2.1.1 → 2.2.0

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 (89) hide show
  1. package/dist/__tests__/guard-main-branch.test.js +79 -0
  2. package/dist/agent-issues-query.d.ts +16 -0
  3. package/dist/agent-log-issue.d.ts +10 -0
  4. package/dist/agent-session-end.d.ts +10 -0
  5. package/dist/agent-session.d.ts +10 -0
  6. package/dist/backlog-prune.d.ts +84 -0
  7. package/dist/cli-entry-point.d.ts +8 -0
  8. package/dist/deps-add.d.ts +91 -0
  9. package/dist/deps-remove.d.ts +17 -0
  10. package/dist/docs-sync.d.ts +50 -0
  11. package/dist/file-delete.d.ts +84 -0
  12. package/dist/file-edit.d.ts +82 -0
  13. package/dist/file-read.d.ts +92 -0
  14. package/dist/file-write.d.ts +90 -0
  15. package/dist/flow-bottlenecks.d.ts +16 -0
  16. package/dist/flow-report.d.ts +16 -0
  17. package/dist/gates.d.ts +94 -0
  18. package/dist/git-branch.d.ts +65 -0
  19. package/dist/git-diff.d.ts +58 -0
  20. package/dist/git-log.d.ts +69 -0
  21. package/dist/git-status.d.ts +58 -0
  22. package/dist/guard-locked.d.ts +62 -0
  23. package/dist/guard-main-branch.d.ts +50 -0
  24. package/dist/guard-main-branch.js +11 -0
  25. package/dist/guard-worktree-commit.d.ts +59 -0
  26. package/dist/index.d.ts +10 -0
  27. package/dist/init-plan.d.ts +80 -0
  28. package/dist/init.d.ts +46 -0
  29. package/dist/initiative-add-wu.d.ts +22 -0
  30. package/dist/initiative-bulk-assign-wus.d.ts +16 -0
  31. package/dist/initiative-create.d.ts +28 -0
  32. package/dist/initiative-edit.d.ts +34 -0
  33. package/dist/initiative-list.d.ts +12 -0
  34. package/dist/initiative-status.d.ts +11 -0
  35. package/dist/lumenflow-upgrade.d.ts +103 -0
  36. package/dist/mem-checkpoint.d.ts +16 -0
  37. package/dist/mem-cleanup.d.ts +29 -0
  38. package/dist/mem-create.d.ts +17 -0
  39. package/dist/mem-export.d.ts +10 -0
  40. package/dist/mem-export.js +138 -0
  41. package/dist/mem-inbox.d.ts +35 -0
  42. package/dist/mem-init.d.ts +15 -0
  43. package/dist/mem-ready.d.ts +16 -0
  44. package/dist/mem-signal.d.ts +16 -0
  45. package/dist/mem-start.d.ts +16 -0
  46. package/dist/mem-summarize.d.ts +22 -0
  47. package/dist/mem-triage.d.ts +22 -0
  48. package/dist/metrics-cli.d.ts +90 -0
  49. package/dist/metrics-snapshot.d.ts +18 -0
  50. package/dist/orchestrate-init-status.d.ts +11 -0
  51. package/dist/orchestrate-initiative.d.ts +12 -0
  52. package/dist/orchestrate-monitor.d.ts +11 -0
  53. package/dist/release.d.ts +117 -0
  54. package/dist/rotate-progress.d.ts +48 -0
  55. package/dist/session-coordinator.d.ts +74 -0
  56. package/dist/spawn-list.d.ts +16 -0
  57. package/dist/state-bootstrap.d.ts +92 -0
  58. package/dist/sync-templates.d.ts +52 -0
  59. package/dist/trace-gen.d.ts +84 -0
  60. package/dist/validate-agent-skills.d.ts +50 -0
  61. package/dist/validate-agent-sync.d.ts +36 -0
  62. package/dist/validate-backlog-sync.d.ts +37 -0
  63. package/dist/validate-skills-spec.d.ts +40 -0
  64. package/dist/validate.d.ts +60 -0
  65. package/dist/wu-block.d.ts +16 -0
  66. package/dist/wu-claim.d.ts +74 -0
  67. package/dist/wu-cleanup.d.ts +35 -0
  68. package/dist/wu-cleanup.js +11 -2
  69. package/dist/wu-create.d.ts +69 -0
  70. package/dist/wu-delete.d.ts +21 -0
  71. package/dist/wu-deps.d.ts +13 -0
  72. package/dist/wu-done.d.ts +225 -0
  73. package/dist/wu-done.js +9 -3
  74. package/dist/wu-edit.d.ts +63 -0
  75. package/dist/wu-edit.js +76 -9
  76. package/dist/wu-infer-lane.d.ts +17 -0
  77. package/dist/wu-preflight.d.ts +47 -0
  78. package/dist/wu-prune.d.ts +16 -0
  79. package/dist/wu-recover.d.ts +37 -0
  80. package/dist/wu-release.d.ts +19 -0
  81. package/dist/wu-repair.d.ts +60 -0
  82. package/dist/wu-spawn-completion.d.ts +10 -0
  83. package/dist/wu-spawn.d.ts +192 -0
  84. package/dist/wu-spawn.js +176 -12
  85. package/dist/wu-status.d.ts +25 -0
  86. package/dist/wu-unblock.d.ts +16 -0
  87. package/dist/wu-unlock-lane.d.ts +19 -0
  88. package/dist/wu-validate.d.ts +16 -0
  89. package/package.json +7 -6
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Generate the Completion Workflow section for sub-agents (WU-2682).
3
+ *
4
+ * Explicitly instructs sub-agents to run wu:done autonomously after gates pass.
5
+ * This prevents agents from asking permission instead of completing.
6
+ *
7
+ * @param {string} id - WU ID
8
+ * @returns {string} Completion Workflow section
9
+ */
10
+ export declare function generateCompletionWorkflowSection(id: string): string;
@@ -0,0 +1,192 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * WU Spawn Helper
4
+ *
5
+ * Generates ready-to-use Task tool invocations for sub-agent WU execution.
6
+ * Includes context loading preamble, skills selection guidance, and constraints block.
7
+ *
8
+ * Usage:
9
+ * pnpm wu:spawn --id WU-123
10
+ * pnpm wu:spawn --id WU-123 --codex
11
+ *
12
+ * Output:
13
+ * A complete Task tool invocation block with:
14
+ * - Context loading preamble (.claude/CLAUDE.md, README, lumenflow, WU YAML)
15
+ * - WU details and acceptance criteria
16
+ * - Skills Selection section (sub-agent reads catalogue and selects at runtime)
17
+ * - Mandatory agent advisory
18
+ * - Constraints block at end (Lost in the Middle research)
19
+ *
20
+ * Skills Selection:
21
+ * This command is AGENT-FACING. Unlike /wu-prompt (human-facing, skills selected
22
+ * at generation time), wu:spawn instructs the sub-agent to read the skill catalogue
23
+ * and select skills at execution time based on WU context.
24
+ *
25
+ * Codex Mode:
26
+ * When --codex is used, outputs a Codex/GPT-friendly Markdown prompt (no antml/XML escaping).
27
+ *
28
+ * @see {@link docs/04-operations/_frameworks/lumenflow/agent/onboarding/agent-invocation-guide.md} - Context loading templates
29
+ */
30
+ import { getConfig } from '@lumenflow/core/dist/lumenflow-config.js';
31
+ import type { ClientConfig } from '@lumenflow/core/dist/lumenflow-config-schema.js';
32
+ /**
33
+ * WU-1131: Truncation prevention constants
34
+ *
35
+ * These constants help detect when spawn output has been truncated during
36
+ * copy-paste operations or context loading. The warning banner alerts users
37
+ * to the truncation risk, and the end sentinel allows verification that
38
+ * the full output was received.
39
+ */
40
+ export declare const TRUNCATION_WARNING_BANNER = "<!-- LUMENFLOW_TRUNCATION_WARNING -->\n<!--\n \u26A0\uFE0F CRITICAL: DO NOT TRUNCATE THIS OUTPUT\n\n This spawn prompt MUST be copied verbatim. Truncation causes:\n - Missing constraints (agents ignore safety rules)\n - Missing TDD directives (agents skip tests)\n - Degraded agent performance\n\n VERIFICATION: The output MUST end with: <!-- LUMENFLOW_SPAWN_END -->\n If you don't see that sentinel at the end, the output was truncated.\n-->\n";
41
+ export declare const SPAWN_END_SENTINEL = "<!-- LUMENFLOW_SPAWN_END -->";
42
+ /**
43
+ * Generate effort scaling rules section (WU-1986)
44
+ *
45
+ * Based on Anthropic multi-agent research: helps agents decide when to
46
+ * spawn sub-agents vs handle inline.
47
+ *
48
+ * @returns {string} Effort scaling section
49
+ */
50
+ export declare function generateEffortScalingRules(): string;
51
+ /**
52
+ * Generate parallel tool call guidance (WU-1986)
53
+ *
54
+ * Based on Anthropic research: 3+ parallel tool calls significantly improve performance.
55
+ *
56
+ * @returns {string} Parallel tool call guidance
57
+ */
58
+ export declare function generateParallelToolCallGuidance(): string;
59
+ /**
60
+ * Generate iterative search heuristics (WU-1986)
61
+ *
62
+ * Based on Anthropic research: start broad, narrow focus.
63
+ *
64
+ * @returns {string} Search heuristics section
65
+ */
66
+ export declare function generateIterativeSearchHeuristics(): string;
67
+ /**
68
+ * Generate token budget awareness section (WU-1986)
69
+ *
70
+ * @param {string} id - WU ID
71
+ * @returns {string} Token budget section
72
+ */
73
+ export declare function generateTokenBudgetAwareness(id: any): string;
74
+ /**
75
+ * Generate structured completion format (WU-1986)
76
+ *
77
+ * @param {string} id - WU ID
78
+ * @returns {string} Completion format section
79
+ */
80
+ export declare function generateCompletionFormat(_id: any): string;
81
+ /**
82
+ * Generate agent coordination section (WU-1987)
83
+ *
84
+ * Provides guidance on mem:signal for parallel agent coordination,
85
+ * orchestrate:status for dashboard checks, and abandoned WU handling.
86
+ *
87
+ * @param {string} id - WU ID
88
+ * @returns {string} Agent coordination section
89
+ */
90
+ export declare function generateAgentCoordinationSection(id: any): string;
91
+ /**
92
+ * Generate quick fix commands section (WU-1987)
93
+ *
94
+ * Provides format/lint/typecheck commands for quick fixes before gates.
95
+ *
96
+ * @returns {string} Quick fix commands section
97
+ */
98
+ export declare function generateQuickFixCommands(): string;
99
+ /**
100
+ * Generate Lane Selection section (WU-2107)
101
+ *
102
+ * Provides guidance on lane selection when creating new WUs.
103
+ * Points agents to wu:infer-lane for automated lane suggestions.
104
+ *
105
+ * @returns {string} Lane Selection section
106
+ */
107
+ export declare function generateLaneSelectionSection(): string;
108
+ /**
109
+ * Generate Worktree Path Guidance section (WU-2362)
110
+ *
111
+ * Provides guidance for sub-agents on working within worktrees, including
112
+ * how to determine the worktree root and where to create stamps.
113
+ *
114
+ * Problem: CLAUDE_PROJECT_DIR is hook-only; sub-agents inherit parent cwd (main).
115
+ * Solution: Use git rev-parse --show-toplevel to determine actual worktree root.
116
+ *
117
+ * @param {string|undefined} worktreePath - Worktree path from WU YAML
118
+ * @returns {string} Worktree path guidance section
119
+ */
120
+ export declare function generateWorktreePathGuidance(worktreePath: any): string;
121
+ /**
122
+ * Generate the Action section based on WU claim status (WU-1745).
123
+ *
124
+ * If WU is already claimed (has claimed_at and worktree_path), tells agent
125
+ * to continue in the existing worktree.
126
+ *
127
+ * If WU is unclaimed (status: ready), tells agent to run wu:claim first.
128
+ *
129
+ * @param {object} doc - WU YAML document
130
+ * @param {string} id - WU ID
131
+ * @returns {string} Action section content
132
+ */
133
+ export declare function generateActionSection(doc: any, id: any): string;
134
+ /**
135
+ * Generate the Completion Workflow section for sub-agents (WU-2682).
136
+ *
137
+ * Explicitly instructs sub-agents to run wu:done autonomously after gates pass.
138
+ * This prevents agents from asking permission instead of completing.
139
+ *
140
+ * @param {string} id - WU ID
141
+ * @returns {string} Completion Workflow section
142
+ */
143
+ export declare function generateCompletionWorkflowSection(id: string): string;
144
+ interface ClientContext {
145
+ name: string;
146
+ config?: ClientConfig;
147
+ }
148
+ interface SpawnOptions {
149
+ thinking?: boolean;
150
+ noThinking?: boolean;
151
+ budget?: string;
152
+ client?: ClientContext;
153
+ config?: ReturnType<typeof getConfig>;
154
+ }
155
+ /**
156
+ * Generate the complete Task tool invocation
157
+ *
158
+ * @param {object} doc - WU YAML document
159
+ * @param {string} id - WU ID
160
+ * @param {SpawnStrategy} strategy - Client strategy
161
+ * @param {object} [options={}] - Thinking mode options
162
+ * @param {boolean} [options.thinking] - Whether extended thinking is enabled
163
+ * @param {boolean} [options.noThinking] - Whether thinking is explicitly disabled
164
+ * @param {string} [options.budget] - Token budget for thinking
165
+ * @returns {string} Complete Task tool invocation
166
+ */
167
+ export declare function generateTaskInvocation(doc: any, id: any, strategy: any, options?: SpawnOptions): string;
168
+ export declare function generateCodexPrompt(doc: any, id: any, strategy: any, options?: SpawnOptions): string;
169
+ /**
170
+ * WU-1603: Check if a lane is currently occupied by another WU
171
+ *
172
+ * @param {string} lane - Lane name (e.g., "Operations: Tooling")
173
+ * @returns {import('@lumenflow/core/dist/lane-lock.js').LockMetadata|null} Lock metadata if occupied, null otherwise
174
+ */
175
+ export declare function checkLaneOccupation(lane: any): import("@lumenflow/core/dist/lane-lock.js").LockMetadata;
176
+ /**
177
+ * WU-1603: Generate a warning message when lane is occupied
178
+ *
179
+ * @param {import('@lumenflow/core/dist/lane-lock.js').LockMetadata} lockMetadata - Lock metadata
180
+ * @param {string} targetWuId - WU ID being spawned
181
+ * @param {Object} [options={}] - Options
182
+ * @param {boolean} [options.isStale] - Whether the lock is stale (>24h old)
183
+ * @returns {string} Warning message
184
+ */
185
+ interface LaneOccupationOptions {
186
+ isStale?: boolean;
187
+ }
188
+ export declare function generateLaneOccupationWarning(lockMetadata: {
189
+ lane: string;
190
+ wuId: string;
191
+ }, targetWuId: string, options?: LaneOccupationOptions): string;
192
+ export {};
package/dist/wu-spawn.js CHANGED
@@ -53,6 +53,28 @@ const MANDATORY_TRIGGERS = {
53
53
  'beacon-guardian': ['**/prompts/**', '**/classification/**', '**/detector/**', '**/llm/**'],
54
54
  };
55
55
  const LOG_PREFIX = '[wu:spawn]';
56
+ /**
57
+ * WU-1131: Truncation prevention constants
58
+ *
59
+ * These constants help detect when spawn output has been truncated during
60
+ * copy-paste operations or context loading. The warning banner alerts users
61
+ * to the truncation risk, and the end sentinel allows verification that
62
+ * the full output was received.
63
+ */
64
+ export const TRUNCATION_WARNING_BANNER = `<!-- LUMENFLOW_TRUNCATION_WARNING -->
65
+ <!--
66
+ ⚠️ CRITICAL: DO NOT TRUNCATE THIS OUTPUT
67
+
68
+ This spawn prompt MUST be copied verbatim. Truncation causes:
69
+ - Missing constraints (agents ignore safety rules)
70
+ - Missing TDD directives (agents skip tests)
71
+ - Degraded agent performance
72
+
73
+ VERIFICATION: The output MUST end with: <!-- LUMENFLOW_SPAWN_END -->
74
+ If you don't see that sentinel at the end, the output was truncated.
75
+ -->
76
+ `;
77
+ export const SPAWN_END_SENTINEL = '<!-- LUMENFLOW_SPAWN_END -->';
56
78
  /**
57
79
  * Detect mandatory agents based on code paths.
58
80
  *
@@ -259,6 +281,79 @@ function generateInvariantsPriorArtSection(codePaths) {
259
281
  ];
260
282
  return lines.join('\n');
261
283
  }
284
+ /**
285
+ * WU types that require TDD (failing test first)
286
+ */
287
+ const TDD_REQUIRED_TYPES = ['feature', 'bug', 'tooling', 'enhancement'];
288
+ /**
289
+ * WU types that require existing tests to pass (no new tests mandated)
290
+ */
291
+ const EXISTING_TESTS_TYPES = ['refactor'];
292
+ /**
293
+ * WU types that require smoke tests + manual QA
294
+ */
295
+ const SMOKE_TEST_TYPES = ['visual', 'design', 'ui'];
296
+ /**
297
+ * WU types that only need format checks (no TDD)
298
+ */
299
+ const DOCS_ONLY_TYPES = ['documentation', 'docs', 'config'];
300
+ /**
301
+ * Generate type-aware test guidance (WU-1142)
302
+ *
303
+ * Returns appropriate test guidance based on WU type:
304
+ * - feature/bug/tooling: Full TDD directive
305
+ * - documentation: Format check only
306
+ * - visual/design: Smoke test + manual QA
307
+ * - refactor: Existing tests must pass
308
+ *
309
+ * @param {string} wuType - WU type from YAML
310
+ * @returns {string} Test guidance section
311
+ */
312
+ export function generateTestGuidance(wuType) {
313
+ const type = (wuType || 'feature').toLowerCase();
314
+ // Documentation WUs - no TDD, just format checks
315
+ if (DOCS_ONLY_TYPES.includes(type)) {
316
+ return `## Documentation Standards
317
+
318
+ **Format check only** - No TDD required for documentation WUs.
319
+
320
+ ### Requirements
321
+
322
+ 1. Run \`pnpm gates --docs-only\` before completion
323
+ 2. Ensure markdown formatting is correct
324
+ 3. Verify links are valid
325
+ 4. Check spelling and grammar`;
326
+ }
327
+ // Visual/Design WUs - smoke tests + manual QA
328
+ if (SMOKE_TEST_TYPES.includes(type)) {
329
+ return `## Visual/Design Testing
330
+
331
+ **Smoke test + manual QA** - Visual WUs require different verification.
332
+
333
+ ### Requirements
334
+
335
+ 1. Create smoke test for component rendering (if applicable)
336
+ 2. Verify visual appearance manually
337
+ 3. Test responsive behavior across breakpoints
338
+ 4. Check accessibility (keyboard navigation, screen reader)
339
+ 5. Document manual QA results in completion notes`;
340
+ }
341
+ // Refactor WUs - existing tests must pass
342
+ if (EXISTING_TESTS_TYPES.includes(type)) {
343
+ return `## Refactor Testing
344
+
345
+ **Existing tests must pass** - Refactoring must not break current behavior.
346
+
347
+ ### Requirements
348
+
349
+ 1. Run all existing tests BEFORE refactoring
350
+ 2. Run all existing tests AFTER refactoring
351
+ 3. No new tests required unless behavior changes
352
+ 4. If tests fail after refactor, the refactor introduced a bug`;
353
+ }
354
+ // Default: TDD required (feature, bug, tooling, enhancement)
355
+ return generateTDDDirective();
356
+ }
262
357
  /**
263
358
  * Generate the TDD directive section (WU-1585)
264
359
  *
@@ -363,6 +458,12 @@ CRITICAL RULES - ENFORCE BEFORE EVERY ACTION:
363
458
  - Use \`pnpm mem:checkpoint --wu ${id}\` to save progress before risky operations
364
459
  - Check \`pnpm mem:inbox --wu ${id}\` periodically for parallel signals from other agents
365
460
  - Checkpoint triggers (WU-1943): checkpoint after each acceptance criterion completed, checkpoint before gates, checkpoint every 30 tool calls
461
+
462
+ 8. SKIP-GATES AUTONOMY (WU-1142)
463
+ - If gates fail, first check if failure is pre-existing on main: \`git checkout main && pnpm gates\`
464
+ - If failure exists on main (not your change), use: \`pnpm wu:done --id ${id} --skip-gates --reason "pre-existing on main" --fix-wu WU-XXXX\`
465
+ - Do NOT ask for approval - autonomous skip-gates for pre-existing failures is correct
466
+ - This prevents getting stuck on infrastructure debt
366
467
  </constraints>`;
367
468
  }
368
469
  function generateCodexConstraints(id) {
@@ -373,7 +474,8 @@ function generateCodexConstraints(id) {
373
474
  3. **Verify before success**: run \`pnpm gates\` in the worktree, then run \`node tools/lib/agent-verification.mjs ${id}\` (from the shared checkout)
374
475
  4. **No fabrication**: if blockers remain or verification fails, report INCOMPLETE
375
476
  5. **Git workflow**: avoid merge commits; let \`pnpm wu:done\` handle completion
376
- 6. **Scope discipline**: stay within \`code_paths\`; capture out-of-scope issues via \`pnpm mem:create\``;
477
+ 6. **Scope discipline**: stay within \`code_paths\`; capture out-of-scope issues via \`pnpm mem:create\`
478
+ 7. **Skip-gates for pre-existing**: if gates fail due to pre-existing issue on main, use \`--skip-gates --reason "pre-existing" --fix-wu WU-XXX\``;
377
479
  }
378
480
  /**
379
481
  * Generate mandatory agent advisory section
@@ -579,6 +681,45 @@ pnpm typecheck # Check TypeScript types
579
681
 
580
682
  **Use before gates** to catch simple issues early. These are faster than full \`pnpm gates\`.`;
581
683
  }
684
+ /**
685
+ * Generate Worktree Block Recovery section (WU-1134)
686
+ *
687
+ * Provides guidance for agents when they're blocked by the worktree hook.
688
+ * This happens when agents try to commit from main instead of the worktree.
689
+ *
690
+ * @param {string} worktreePath - Worktree path from WU YAML
691
+ * @returns {string} Worktree block recovery section
692
+ */
693
+ export function generateWorktreeBlockRecoverySection(worktreePath) {
694
+ return `## When Blocked by Worktree Hook
695
+
696
+ If you encounter a "worktree required" or "commit blocked" error:
697
+
698
+ 1. **Check existing worktrees**: \`git worktree list\`
699
+ 2. **Navigate to the worktree**: \`cd ${worktreePath || 'worktrees/<lane>-wu-xxx'}\`
700
+ 3. **Retry your operation** from within the worktree
701
+ 4. **Use relative paths only** (never absolute paths like \`/home/...\`)
702
+
703
+ ### Common Causes
704
+
705
+ - Running \`git commit\` from main checkout instead of worktree
706
+ - Using absolute paths that bypass worktree isolation
707
+ - Forgetting to \`cd\` to worktree after \`wu:claim\`
708
+
709
+ ### Quick Fix
710
+
711
+ \`\`\`bash
712
+ # Check where you are
713
+ pwd
714
+ git worktree list
715
+
716
+ # Navigate to your worktree
717
+ cd ${worktreePath || 'worktrees/<lane>-wu-xxx'}
718
+
719
+ # Retry your commit
720
+ git add . && git commit -m "your message"
721
+ \`\`\``;
722
+ }
582
723
  /**
583
724
  * Generate Lane Selection section (WU-2107)
584
725
  *
@@ -832,10 +973,12 @@ export function generateTaskInvocation(doc, id, strategy, options = {}) {
832
973
  const codePaths = doc.code_paths || [];
833
974
  const mandatoryAgents = detectMandatoryAgents(codePaths);
834
975
  const preamble = generatePreamble(id, strategy);
835
- const tddDirective = generateTDDDirective();
976
+ // WU-1142: Use type-aware test guidance instead of hardcoded TDD directive
977
+ const testGuidance = generateTestGuidance(doc.type);
836
978
  const clientContext = options.client;
837
979
  const config = options.config || getConfig();
838
- const clientSkillsGuidance = generateClientSkillsGuidance(clientContext);
980
+ // WU-1142: Pass lane to get byLane skills
981
+ const clientSkillsGuidance = generateClientSkillsGuidance(clientContext, doc.lane);
839
982
  const skillsSection = generateSkillsSelectionSection(doc, config, clientContext?.name) +
840
983
  (clientSkillsGuidance ? `\n${clientSkillsGuidance}` : '');
841
984
  const clientBlocks = generateClientBlocksSection(clientContext);
@@ -859,6 +1002,8 @@ export function generateTaskInvocation(doc, id, strategy, options = {}) {
859
1002
  const laneSelection = generateLaneSelectionSection();
860
1003
  // WU-2362: Worktree path guidance for sub-agents
861
1004
  const worktreeGuidance = generateWorktreePathGuidance(doc.worktree_path);
1005
+ // WU-1134: Worktree block recovery guidance
1006
+ const worktreeBlockRecovery = generateWorktreeBlockRecoverySection(doc.worktree_path);
862
1007
  // Generate thinking mode sections if applicable
863
1008
  const executionModeSection = generateExecutionModeSection(options);
864
1009
  const thinkToolGuidance = generateThinkToolGuidance(options);
@@ -868,14 +1013,15 @@ export function generateTaskInvocation(doc, id, strategy, options = {}) {
868
1013
  .join('\n\n---\n\n');
869
1014
  const thinkingBlock = thinkingSections ? `${thinkingSections}\n\n---\n\n` : '';
870
1015
  // Build the task prompt
871
- // TDD directive appears immediately after </task> per "Lost in the Middle" research (WU-1585)
872
- const taskPrompt = `<task>
1016
+ // WU-1131: Warning banner at start, end sentinel after constraints
1017
+ // WU-1142: Type-aware test guidance (TDD for code, format-only for docs, etc.)
1018
+ const taskPrompt = `${TRUNCATION_WARNING_BANNER}<task>
873
1019
  ${preamble}
874
1020
  </task>
875
1021
 
876
1022
  ---
877
1023
 
878
- ${tddDirective}
1024
+ ${testGuidance}
879
1025
 
880
1026
  ---
881
1027
 
@@ -959,7 +1105,13 @@ ${laneGuidance}${laneGuidance ? '\n\n---\n\n' : ''}## Action
959
1105
 
960
1106
  ${generateActionSection(doc, id)}
961
1107
 
962
- ${constraints}`;
1108
+ ---
1109
+
1110
+ ${worktreeBlockRecovery}
1111
+
1112
+ ${constraints}
1113
+
1114
+ ${SPAWN_END_SENTINEL}`;
963
1115
  // Escape special characters for XML output
964
1116
  const escapedPrompt = taskPrompt
965
1117
  .replace(/&/g, '&amp;')
@@ -986,7 +1138,8 @@ export function generateCodexPrompt(doc, id, strategy, options = {}) {
986
1138
  const codePaths = doc.code_paths || [];
987
1139
  const mandatoryAgents = detectMandatoryAgents(codePaths);
988
1140
  const preamble = generatePreamble(id, strategy);
989
- const tddDirective = generateTDDDirective();
1141
+ // WU-1142: Use type-aware test guidance instead of hardcoded TDD directive
1142
+ const testGuidance = generateTestGuidance(doc.type);
990
1143
  const mandatorySection = generateMandatoryAgentSection(mandatoryAgents, id);
991
1144
  const laneGuidance = generateLaneGuidance(doc.lane);
992
1145
  const bugDiscoverySection = generateBugDiscoverySection(id);
@@ -995,7 +1148,8 @@ export function generateCodexPrompt(doc, id, strategy, options = {}) {
995
1148
  const constraints = generateCodexConstraints(id);
996
1149
  const clientContext = options.client;
997
1150
  const config = options.config || getConfig();
998
- const clientSkillsGuidance = generateClientSkillsGuidance(clientContext);
1151
+ // WU-1142: Pass lane to get byLane skills
1152
+ const clientSkillsGuidance = generateClientSkillsGuidance(clientContext, doc.lane);
999
1153
  const skillsSection = generateSkillsSelectionSection(doc, config, clientContext?.name) +
1000
1154
  (clientSkillsGuidance ? `\n${clientSkillsGuidance}` : '');
1001
1155
  const clientBlocks = generateClientBlocksSection(clientContext);
@@ -1005,9 +1159,13 @@ export function generateCodexPrompt(doc, id, strategy, options = {}) {
1005
1159
  .filter((section) => section.length > 0)
1006
1160
  .join('\n\n---\n\n');
1007
1161
  const thinkingBlock = thinkingSections ? `${thinkingSections}\n\n---\n\n` : '';
1008
- return `# ${id}: ${doc.title || 'Untitled'}
1162
+ // WU-1134: Worktree block recovery guidance
1163
+ const worktreeBlockRecovery = generateWorktreeBlockRecoverySection(doc.worktree_path);
1164
+ // WU-1131: Warning banner at start, end sentinel after constraints
1165
+ // WU-1142: Type-aware test guidance
1166
+ return `${TRUNCATION_WARNING_BANNER}# ${id}: ${doc.title || 'Untitled'}
1009
1167
 
1010
- ${tddDirective}
1168
+ ${testGuidance}
1011
1169
 
1012
1170
  ---
1013
1171
 
@@ -1062,7 +1220,13 @@ ${mandatorySection}${implementationContext ? `${implementationContext}\n\n---\n\
1062
1220
 
1063
1221
  ---
1064
1222
 
1065
- ${laneGuidance}${laneGuidance ? '\n\n---\n\n' : ''}${constraints}
1223
+ ${laneGuidance}${laneGuidance ? '\n\n---\n\n' : ''}${worktreeBlockRecovery}
1224
+
1225
+ ---
1226
+
1227
+ ${constraints}
1228
+
1229
+ ${SPAWN_END_SENTINEL}
1066
1230
  `;
1067
1231
  }
1068
1232
  /**
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * WU Status Command
4
+ *
5
+ * WU-1090: Context-aware state machine for WU lifecycle commands
6
+ *
7
+ * Shows:
8
+ * - Current location (main checkout vs worktree)
9
+ * - WU state if in worktree or --id provided
10
+ * - Git state (branch, dirty, ahead/behind)
11
+ * - Valid commands for current context
12
+ *
13
+ * Usage:
14
+ * pnpm wu:status # Auto-detect from current directory
15
+ * pnpm wu:status --id WU-123 # Show status for specific WU
16
+ */
17
+ import type { WuContext } from '@lumenflow/core/dist/validation/types.js';
18
+ /**
19
+ * Format complete status output
20
+ */
21
+ export declare function formatStatusOutput(context: WuContext): string;
22
+ /**
23
+ * Get exit code based on context state
24
+ */
25
+ export declare function getStatusExitCode(context: WuContext): number;
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * WU Unblock Helper
4
+ *
5
+ * Sequence (micro-worktree pattern):
6
+ * 1) Create micro-worktree from main
7
+ * 2) Auto-update WU YAML/backlog/status to In Progress in micro-worktree
8
+ * 3) Commit in micro-worktree, push directly to origin/main
9
+ * 4) Optionally create a fresh work worktree/branch (default: skip unless --create-worktree)
10
+ *
11
+ * Uses micro-worktree pattern to avoid pre-commit hook blocking commits to main.
12
+ *
13
+ * Usage:
14
+ * pnpm wu:unblock --id WU-334 [--reason "Dependency cleared"] [--create-worktree] [--worktree ...] [--branch ...] [--no-auto]
15
+ */
16
+ export {};
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * WU Unlock Lane Helper
4
+ *
5
+ * Provides a dedicated audited command for operators to safely clear lane locks.
6
+ *
7
+ * Safety-first approach:
8
+ * - Zombie locks (PID not running): Can be unlocked without --force
9
+ * - Stale locks (>24h old): Can be unlocked without --force
10
+ * - Active locks (recent, PID running): Require --force to unlock
11
+ *
12
+ * All unlocks require a --reason parameter for audit purposes.
13
+ *
14
+ * Usage:
15
+ * pnpm wu:unlock-lane --lane "Core" --reason "Process crashed"
16
+ * pnpm wu:unlock-lane --lane "Core" --reason "Emergency" --force
17
+ * pnpm wu:unlock-lane --list # List all current locks
18
+ */
19
+ export {};
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * WU Validation Tool
4
+ *
5
+ * Validates WU YAML files against schema and checks for quality warnings.
6
+ * Returns exit code 0 if valid (warnings are advisory, not blocking).
7
+ * Returns exit code 1 only for schema errors.
8
+ *
9
+ * Usage:
10
+ * pnpm wu:validate --id WU-123 # Validate specific WU
11
+ * pnpm wu:validate --all # Validate all WUs
12
+ * pnpm wu:validate --all --strict # Fail on warnings too
13
+ *
14
+ * @see {@link tools/lib/wu-schema.mjs} - Schema definitions
15
+ */
16
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumenflow/cli",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "Command-line interface for LumenFlow workflow framework",
5
5
  "keywords": [
6
6
  "lumenflow",
@@ -57,6 +57,7 @@
57
57
  "mem-checkpoint": "./dist/mem-checkpoint.js",
58
58
  "mem-start": "./dist/mem-start.js",
59
59
  "mem-ready": "./dist/mem-ready.js",
60
+ "mem-export": "./dist/mem-export.js",
60
61
  "mem-signal": "./dist/mem-signal.js",
61
62
  "mem-cleanup": "./dist/mem-cleanup.js",
62
63
  "mem-create": "./dist/mem-create.js",
@@ -132,11 +133,11 @@
132
133
  "pretty-ms": "^9.2.0",
133
134
  "simple-git": "^3.30.0",
134
135
  "yaml": "^2.8.2",
135
- "@lumenflow/core": "2.1.1",
136
- "@lumenflow/metrics": "2.1.1",
137
- "@lumenflow/memory": "2.1.1",
138
- "@lumenflow/initiatives": "2.1.1",
139
- "@lumenflow/agent": "2.1.1"
136
+ "@lumenflow/memory": "2.2.0",
137
+ "@lumenflow/metrics": "2.2.0",
138
+ "@lumenflow/initiatives": "2.2.0",
139
+ "@lumenflow/agent": "2.2.0",
140
+ "@lumenflow/core": "2.2.0"
140
141
  },
141
142
  "devDependencies": {
142
143
  "@vitest/coverage-v8": "^4.0.17",