@lumenflow/cli 1.3.6 → 1.5.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.
package/dist/init.js CHANGED
@@ -3,13 +3,58 @@
3
3
  * LumenFlow project scaffolding command (WU-1045)
4
4
  * WU-1006: Library-First - use core defaults for config generation
5
5
  * WU-1028: Vendor-agnostic core + vendor overlays
6
+ * WU-1085: Added createWUParser for proper --help support
6
7
  */
7
8
  import * as fs from 'node:fs';
8
9
  import * as path from 'node:path';
9
10
  import * as yaml from 'yaml';
10
- import { getDefaultConfig } from '@lumenflow/core';
11
+ import { getDefaultConfig, createWUParser, WU_OPTIONS } from '@lumenflow/core';
11
12
  // WU-1067: Import GATE_PRESETS for --preset support
12
13
  import { GATE_PRESETS } from '@lumenflow/core/dist/gates-config.js';
14
+ /**
15
+ * WU-1085: CLI option definitions for init command
16
+ */
17
+ const INIT_OPTIONS = {
18
+ full: {
19
+ name: 'full',
20
+ flags: '--full',
21
+ description: 'Add docs + agent onboarding + task scaffolding',
22
+ },
23
+ framework: {
24
+ name: 'framework',
25
+ flags: '--framework <name>',
26
+ description: 'Add framework hint + overlay docs',
27
+ },
28
+ vendor: {
29
+ name: 'vendor',
30
+ flags: '--vendor <type>',
31
+ description: 'Vendor type (claude, cursor, aider, all, none)',
32
+ },
33
+ preset: {
34
+ name: 'preset',
35
+ flags: '--preset <preset>',
36
+ description: 'Gate preset for config (node, python, go, rust, dotnet)',
37
+ },
38
+ force: WU_OPTIONS.force,
39
+ };
40
+ /**
41
+ * WU-1085: Parse init command options using createWUParser
42
+ * Provides proper --help, --version, and option parsing
43
+ */
44
+ export function parseInitOptions() {
45
+ const opts = createWUParser({
46
+ name: 'lumenflow-init',
47
+ description: 'Initialize LumenFlow in a project',
48
+ options: Object.values(INIT_OPTIONS),
49
+ });
50
+ return {
51
+ force: opts.force ?? false,
52
+ full: opts.full ?? false,
53
+ framework: opts.framework,
54
+ vendor: opts.vendor,
55
+ preset: opts.preset,
56
+ };
57
+ }
13
58
  const CONFIG_FILE_NAME = '.lumenflow.config.yaml';
14
59
  const FRAMEWORK_HINT_FILE = '.lumenflow.framework.yaml';
15
60
  const LUMENFLOW_DIR = '.lumenflow';
@@ -118,6 +163,773 @@ const WU_TEMPLATE_YAML = `# Work Unit Template (LumenFlow WU Schema)\n#\n# Copy
118
163
  const FRAMEWORK_HINT_TEMPLATE = `# LumenFlow Framework Hint\n# Generated by: lumenflow init --framework {{FRAMEWORK_NAME}}\n\nframework: "{{FRAMEWORK_NAME}}"\nslug: "{{FRAMEWORK_SLUG}}"\n`;
119
164
  // Template for docs/04-operations/_frameworks/<framework>/README.md
120
165
  const FRAMEWORK_OVERLAY_TEMPLATE = `# {{FRAMEWORK_NAME}} Framework Overlay\n\n**Last updated:** {{DATE}}\n\nThis overlay captures framework-specific conventions, constraints, and references for {{FRAMEWORK_NAME}} projects.\n\n## Scope\n\n- Project structure conventions\n- Framework-specific testing guidance\n- Common pitfalls and mitigations\n\n## References\n\n- Add official docs links here\n`;
166
+ // WU-1083: Agent onboarding docs templates
167
+ const QUICK_REF_COMMANDS_TEMPLATE = `# Quick Reference: LumenFlow Commands
168
+
169
+ **Last updated:** {{DATE}}
170
+
171
+ ---
172
+
173
+ ## Project Setup
174
+
175
+ | Command | Description |
176
+ | --------------------------------------------- | --------------------------------------- |
177
+ | \`pnpm exec lumenflow init\` | Scaffold minimal LumenFlow core |
178
+ | \`pnpm exec lumenflow init --full\` | Add docs/04-operations task scaffolding |
179
+ | \`pnpm exec lumenflow init --framework <name>\` | Add framework hint + overlay docs |
180
+ | \`pnpm exec lumenflow init --force\` | Overwrite existing files |
181
+
182
+ ---
183
+
184
+ ## WU Management
185
+
186
+ | Command | Description |
187
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
188
+ | \`pnpm wu:create --id WU-XXX --lane <Lane> --title "Title" --description "..." --acceptance "..." --code-paths "path" --test-paths-unit "path" --exposure backend-only --spec-refs "~/.lumenflow/plans/WU-XXX.md"\` | Create new WU |
189
+ | \`pnpm wu:claim --id WU-XXX --lane <Lane>\` | Claim WU (creates worktree) |
190
+ | \`pnpm wu:done --id WU-XXX\` | Complete WU (merge, stamp, cleanup) |
191
+ | \`pnpm wu:block --id WU-XXX --reason "Reason"\` | Block a WU |
192
+ | \`pnpm wu:unblock --id WU-XXX\` | Unblock a WU |
193
+
194
+ ---
195
+
196
+ ## Gates
197
+
198
+ | Command | Description |
199
+ | ------------------------ | -------------------------- |
200
+ | \`pnpm gates\` | Run all quality gates |
201
+ | \`pnpm gates --docs-only\` | Run gates for docs changes |
202
+ | \`pnpm format\` | Format all files |
203
+ | \`pnpm lint\` | Run linter |
204
+ | \`pnpm typecheck\` | Run TypeScript check |
205
+ | \`pnpm test\` | Run tests |
206
+
207
+ ---
208
+
209
+ ## Git (Safe Operations)
210
+
211
+ | Command | Description |
212
+ | ------------------------------------ | ------------------------- |
213
+ | \`git status\` | Check working tree status |
214
+ | \`git add .\` | Stage all changes |
215
+ | \`git commit -m "type: message"\` | Commit with message |
216
+ | \`git push origin lane/<lane>/wu-xxx\` | Push to remote |
217
+
218
+ ---
219
+
220
+ ## Navigation
221
+
222
+ \`\`\`bash
223
+ # After claiming, go to worktree
224
+ cd worktrees/<lane>-wu-xxx
225
+
226
+ # Return to main for wu:done
227
+ cd /path/to/main
228
+ \`\`\`
229
+
230
+ ---
231
+
232
+ ## Workflow Sequence
233
+
234
+ \`\`\`bash
235
+ # 1. Create
236
+ pnpm wu:create --id WU-001 --lane "Framework: Core" --title "Add feature" \\
237
+ --description "Context: ...\\nProblem: ...\\nSolution: ..." \\
238
+ --acceptance "Criterion 1" --acceptance "Criterion 2" \\
239
+ --code-paths "src/example.ts" \\
240
+ --test-paths-unit "src/__tests__/example.test.ts" \\
241
+ --exposure backend-only
242
+
243
+ # 2. Claim
244
+ pnpm wu:claim --id WU-001 --lane "Framework: Core"
245
+ cd worktrees/framework-core-wu-001
246
+
247
+ # 3. Work (TDD)
248
+ # ... write tests first, then code ...
249
+
250
+ # 4. Commit
251
+ git add .
252
+ git commit -m "feat: add feature"
253
+ git push origin lane/framework-core/wu-001
254
+
255
+ # 5. Gates
256
+ pnpm gates
257
+
258
+ # 6. Complete
259
+ cd /path/to/main
260
+ pnpm wu:done --id WU-001
261
+ \`\`\`
262
+
263
+ ---
264
+
265
+ ## File Paths
266
+
267
+ | Path | Description |
268
+ | ----------------------------------------- | -------------------- |
269
+ | \`docs/04-operations/tasks/wu/WU-XXX.yaml\` | WU specification |
270
+ | \`docs/04-operations/tasks/status.md\` | Current status board |
271
+ | \`.lumenflow/stamps/WU-XXX.done\` | Completion stamp |
272
+ | \`worktrees/<lane>-wu-xxx/\` | Worktree directory |
273
+ `;
274
+ const FIRST_WU_MISTAKES_TEMPLATE = `# First WU Mistakes
275
+
276
+ **Last updated:** {{DATE}}
277
+
278
+ Common mistakes agents make on their first WU, and how to avoid them.
279
+
280
+ ---
281
+
282
+ ## Mistake 1: Not Using Worktrees
283
+
284
+ ### Wrong
285
+
286
+ \`\`\`bash
287
+ # Working directly in main
288
+ vim src/feature.ts
289
+ git commit -m "feat: add feature"
290
+ git push origin main
291
+ \`\`\`
292
+
293
+ ### Right
294
+
295
+ \`\`\`bash
296
+ # Claim first, then work in worktree
297
+ pnpm wu:claim --id WU-123 --lane Core
298
+ cd worktrees/core-wu-123
299
+ vim src/feature.ts
300
+ git commit -m "feat: add feature"
301
+ git push origin lane/core/wu-123
302
+ cd /path/to/main
303
+ pnpm wu:done --id WU-123
304
+ \`\`\`
305
+
306
+ ---
307
+
308
+ ## Mistake 2: Forgetting to Run wu:done
309
+
310
+ See [troubleshooting-wu-done.md](troubleshooting-wu-done.md) for the full explanation.
311
+
312
+ **TL;DR:** After gates pass, ALWAYS run \`pnpm wu:done --id WU-XXX\`.
313
+
314
+ ---
315
+
316
+ ## Mistake 3: Working Outside code_paths
317
+
318
+ ### Wrong
319
+
320
+ The WU says \`code_paths: [src/api/**]\` but you edit \`src/ui/component.ts\`.
321
+
322
+ ### Right
323
+
324
+ Only edit files within the specified \`code_paths\`. If you need to edit other files, that's a different WU.
325
+
326
+ ---
327
+
328
+ ## Mistake 4: Skipping TDD
329
+
330
+ ### Wrong
331
+
332
+ \`\`\`
333
+ 1. Write the feature
334
+ 2. Maybe write tests later
335
+ 3. Tests are hard, skip them
336
+ \`\`\`
337
+
338
+ ### Right
339
+
340
+ \`\`\`
341
+ 1. Write failing test
342
+ 2. Run test (confirm RED)
343
+ 3. Write minimum code
344
+ 4. Run test (confirm GREEN)
345
+ 5. Refactor if needed
346
+ \`\`\`
347
+
348
+ ---
349
+
350
+ ## Mistake 5: Using Forbidden Git Commands
351
+
352
+ ### Wrong
353
+
354
+ \`\`\`bash
355
+ git reset --hard HEAD
356
+ git push --force
357
+ git commit --no-verify
358
+ \`\`\`
359
+
360
+ ### Right
361
+
362
+ \`\`\`bash
363
+ git add .
364
+ git commit -m "feat: description"
365
+ git push origin lane/core/wu-123
366
+ \`\`\`
367
+
368
+ ---
369
+
370
+ ## Mistake 6: Ignoring Gate Failures
371
+
372
+ ### Wrong
373
+
374
+ \`\`\`
375
+ Gates failed but I think the code is fine.
376
+ Let me use --skip-gates.
377
+ \`\`\`
378
+
379
+ ### Right
380
+
381
+ \`\`\`
382
+ Gates failed. Let me read the error:
383
+ - TypeScript error in src/api/handler.ts
384
+ - Missing return type
385
+
386
+ Fix: Add the return type.
387
+ Re-run: pnpm gates
388
+ \`\`\`
389
+
390
+ ---
391
+
392
+ ## Quick Checklist
393
+
394
+ Before starting any WU:
395
+
396
+ - [ ] Read the full WU spec
397
+ - [ ] Understand acceptance criteria
398
+ - [ ] Claim the WU with \`pnpm wu:claim\`
399
+ - [ ] cd to the worktree IMMEDIATELY
400
+ - [ ] Work only in the worktree
401
+ - [ ] Stay within code_paths
402
+ - [ ] Follow TDD
403
+ - [ ] Run gates before wu:done
404
+ - [ ] ALWAYS run wu:done
405
+ `;
406
+ const TROUBLESHOOTING_WU_DONE_TEMPLATE = `# Troubleshooting: wu:done Not Run
407
+
408
+ **Last updated:** {{DATE}}
409
+
410
+ This is the most common mistake agents make. This document explains why it happens and how to fix it.
411
+
412
+ ---
413
+
414
+ ## The Problem
415
+
416
+ Agents complete their work, write "To Complete: pnpm wu:done --id WU-XXX" in their response, and then **stop without actually running the command**.
417
+
418
+ ### Why This Happens
419
+
420
+ 1. **Confusion about scope**: Agent thinks completion is a "next step" for the human
421
+ 2. **Fear of overstepping**: Agent hesitates to take "final" actions
422
+ 3. **Missing context**: Agent doesn't realize wu:done is expected to be run immediately
423
+ 4. **Token limits**: Agent runs out of context and summarizes remaining steps
424
+
425
+ ---
426
+
427
+ ## The Fix
428
+
429
+ ### Rule: ALWAYS Run wu:done
430
+
431
+ After gates pass, you MUST run:
432
+
433
+ \`\`\`bash
434
+ cd /path/to/main
435
+ pnpm wu:done --id WU-XXX
436
+ \`\`\`
437
+
438
+ Do NOT:
439
+
440
+ - Ask "Should I run wu:done?"
441
+ - Write "To Complete: pnpm wu:done"
442
+ - Wait for permission
443
+ - Treat it as a "future step"
444
+
445
+ ---
446
+
447
+ ## Correct Completion Flow
448
+
449
+ \`\`\`bash
450
+ # 1. In worktree, run gates
451
+ pnpm gates
452
+
453
+ # 2. If gates pass, return to main
454
+ cd /path/to/main
455
+
456
+ # 3. IMMEDIATELY run wu:done
457
+ pnpm wu:done --id WU-XXX
458
+
459
+ # 4. Report success with the wu:done output
460
+ \`\`\`
461
+
462
+ ---
463
+
464
+ ## What wu:done Does
465
+
466
+ When you run \`pnpm wu:done --id WU-XXX\`:
467
+
468
+ 1. Validates the worktree exists and has commits
469
+ 2. Runs gates in the worktree (not main)
470
+ 3. Fast-forward merges to main
471
+ 4. Creates the done stamp
472
+ 5. Updates status and backlog docs
473
+ 6. Removes the worktree
474
+ 7. Pushes to origin
475
+
476
+ **This is the ONLY way to complete a WU.** Manual steps will leave things in an inconsistent state.
477
+
478
+ ---
479
+
480
+ ## Symptoms of Incomplete WU
481
+
482
+ If wu:done wasn't run, you'll see:
483
+
484
+ - Worktree still exists: \`ls worktrees/\`
485
+ - No stamp: \`ls .lumenflow/stamps/WU-XXX.done\` returns nothing
486
+ - Status unchanged: WU still shows as \`in_progress\`
487
+ - Branch not merged: Changes only on lane branch
488
+
489
+ ---
490
+
491
+ ## Recovery
492
+
493
+ If a previous agent forgot to run wu:done:
494
+
495
+ \`\`\`bash
496
+ # 1. Check worktree exists
497
+ ls worktrees/
498
+
499
+ # 2. If it does, run wu:done
500
+ pnpm wu:done --id WU-XXX
501
+ \`\`\`
502
+
503
+ ---
504
+
505
+ ## Checklist Before Ending Session
506
+
507
+ - [ ] Did I run \`pnpm gates\` in the worktree?
508
+ - [ ] Did gates pass?
509
+ - [ ] Did I \`cd\` back to main?
510
+ - [ ] Did I run \`pnpm wu:done --id WU-XXX\`?
511
+ - [ ] Did wu:done complete successfully?
512
+
513
+ If any answer is "no", you're not done yet.
514
+ `;
515
+ const AGENT_SAFETY_CARD_TEMPLATE = `# Agent Safety Card
516
+
517
+ **Last updated:** {{DATE}}
518
+
519
+ Quick reference for AI agents working in LumenFlow projects.
520
+
521
+ ---
522
+
523
+ ## Stop and Ask When
524
+
525
+ - Same error repeats 3 times
526
+ - Auth or permissions changes needed
527
+ - PII/PHI/secrets involved
528
+ - Cloud spend decisions
529
+ - Policy changes required
530
+ - Anything feels irreversible
531
+
532
+ ---
533
+
534
+ ## Never Do
535
+
536
+ | Action | Why |
537
+ | ------------------------ | ---------------- |
538
+ | \`git reset --hard\` | Data loss |
539
+ | \`git push --force\` | History rewrite |
540
+ | \`--no-verify\` | Bypasses safety |
541
+ | \`git stash\` (on main) | Hides work |
542
+ | \`git clean -fd\` | Deletes files |
543
+ | Work in main after claim | Breaks isolation |
544
+ | Skip wu:done | Incomplete WU |
545
+
546
+ ---
547
+
548
+ ## Always Do
549
+
550
+ | Action | Why |
551
+ | -------------------------- | ---------------- |
552
+ | Read WU spec first | Understand scope |
553
+ | cd to worktree after claim | Isolation |
554
+ | Write tests before code | TDD |
555
+ | Run gates before wu:done | Quality |
556
+ | Run wu:done | Complete WU |
557
+ | Stay within code_paths | Scope discipline |
558
+
559
+ ---
560
+
561
+ ## Error Handling
562
+
563
+ ### Max 3 Attempts
564
+
565
+ If same error happens 3 times:
566
+
567
+ 1. Stop trying
568
+ 2. Document what happened
569
+ 3. Ask for help
570
+
571
+ ### Gate Failures
572
+
573
+ 1. Read the error message
574
+ 2. Fix the underlying issue
575
+ 3. Re-run gates
576
+ 4. Never use \`--skip-gates\` for new failures
577
+
578
+ ---
579
+
580
+ ## Quick Commands
581
+
582
+ \`\`\`bash
583
+ # Check lane availability
584
+ cat docs/04-operations/tasks/status.md
585
+
586
+ # Claim a WU
587
+ pnpm wu:claim --id WU-XXX --lane <Lane>
588
+
589
+ # Work in worktree
590
+ cd worktrees/<lane>-wu-xxx
591
+
592
+ # Run gates
593
+ pnpm gates # Code changes
594
+ pnpm gates --docs-only # Docs changes
595
+
596
+ # Complete WU
597
+ cd /path/to/main
598
+ pnpm wu:done --id WU-XXX
599
+ \`\`\`
600
+
601
+ ---
602
+
603
+ ## Completion Checklist
604
+
605
+ - [ ] Gates pass
606
+ - [ ] cd to main
607
+ - [ ] Run wu:done
608
+ - [ ] Verify success output
609
+ - [ ] Report completion
610
+
611
+ ---
612
+
613
+ ## When Uncertain
614
+
615
+ Choose the safer path:
616
+
617
+ - Don't modify files outside code_paths
618
+ - Don't bypass hooks
619
+ - Don't skip gates
620
+ - Ask rather than assume
621
+ `;
622
+ const WU_CREATE_CHECKLIST_TEMPLATE = `# WU Creation Checklist
623
+
624
+ **Last updated:** {{DATE}}
625
+
626
+ Before running \`pnpm wu:create\`, verify these items.
627
+
628
+ ---
629
+
630
+ ## Step 1: Check Valid Lanes
631
+
632
+ \`\`\`bash
633
+ grep -A 30 "lanes:" .lumenflow.config.yaml
634
+ \`\`\`
635
+
636
+ **Format:** \`"Parent: Sublane"\` (colon + single space)
637
+
638
+ Examples:
639
+ - \`"Framework: CLI"\`
640
+ - \`"Framework: Core"\`
641
+ - \`"Operations: CI/CD"\`
642
+ - \`"Content: Documentation"\`
643
+
644
+ ---
645
+
646
+ ## Step 2: Required Fields
647
+
648
+ | Field | Required For | Example |
649
+ |-------|--------------|---------|
650
+ | \`--id\` | All | \`WU-1234\` |
651
+ | \`--lane\` | All | \`"Experience: Chat"\` |
652
+ | \`--title\` | All | \`"Add feature"\` |
653
+ | \`--description\` | All | \`"Context: ... Problem: ... Solution: ..."\` |
654
+ | \`--acceptance\` | All | \`--acceptance "Works"\` (repeatable) |
655
+ | \`--exposure\` | All | \`ui\`, \`api\`, \`backend-only\`, \`documentation\` |
656
+ | \`--code-paths\` | Code WUs | \`"src/a.ts,src/b.ts"\` |
657
+ | \`--test-paths-unit\` | Code WUs | \`"src/__tests__/a.test.ts"\` |
658
+ | \`--spec-refs\` | Feature WUs | \`"~/.lumenflow/plans/WU-XXX.md"\` |
659
+
660
+ ---
661
+
662
+ ## Step 3: Plan Storage
663
+
664
+ Plans go in \`~/.lumenflow/plans/\` (NOT in project):
665
+
666
+ \`\`\`bash
667
+ mkdir -p ~/.lumenflow/plans
668
+ # Create your plan
669
+ vim ~/.lumenflow/plans/WU-XXX-plan.md
670
+ \`\`\`
671
+
672
+ Reference in wu:create:
673
+ \`\`\`bash
674
+ --spec-refs "~/.lumenflow/plans/WU-XXX-plan.md"
675
+ \`\`\`
676
+
677
+ ---
678
+
679
+ ## Step 4: Validate First
680
+
681
+ \`\`\`bash
682
+ pnpm wu:create --id WU-XXX ... --validate
683
+ \`\`\`
684
+
685
+ Fix errors, then remove \`--validate\` to create.
686
+
687
+ ---
688
+
689
+ ## Complete Example
690
+
691
+ \`\`\`bash
692
+ pnpm wu:create \\
693
+ --id WU-1234 \\
694
+ --lane "Framework: CLI" \\
695
+ --title "Add feature X" \\
696
+ --description "Context: Users need X. Problem: X doesn't exist. Solution: Add X." \\
697
+ --acceptance "Feature X works as specified" \\
698
+ --acceptance "Unit tests pass with >90% coverage" \\
699
+ --code-paths "packages/@lumenflow/cli/src/x.ts" \\
700
+ --test-paths-unit "packages/@lumenflow/cli/__tests__/x.test.ts" \\
701
+ --exposure backend-only \\
702
+ --spec-refs "~/.lumenflow/plans/WU-1234-plan.md"
703
+ \`\`\`
704
+
705
+ ---
706
+
707
+ ## Common Errors
708
+
709
+ ### "Lane format invalid"
710
+
711
+ **Cause:** Missing colon or space in lane format.
712
+
713
+ **Fix:** Use \`"Parent: Sublane"\` format (colon + space).
714
+
715
+ ### "Missing required field"
716
+
717
+ **Cause:** Required field not provided.
718
+
719
+ **Fix:** Add the missing \`--field\` argument.
720
+
721
+ ### "WU already exists"
722
+
723
+ **Cause:** WU with this ID already exists.
724
+
725
+ **Fix:** Use a different ID or check existing WUs.
726
+
727
+ ---
728
+
729
+ ## After Creation
730
+
731
+ 1. Review the created YAML: \`cat docs/04-operations/tasks/wu/WU-XXX.yaml\`
732
+ 2. Claim the WU: \`pnpm wu:claim --id WU-XXX --lane "Lane"\`
733
+ 3. cd to worktree: \`cd worktrees/<lane>-wu-xxx\`
734
+ `;
735
+ // WU-1083: Claude skills templates
736
+ const WU_LIFECYCLE_SKILL_TEMPLATE = `---
737
+ name: wu-lifecycle
738
+ description: Work Unit claim/block/done workflow automation.
739
+ version: 1.0.0
740
+ ---
741
+
742
+ # WU Lifecycle Skill
743
+
744
+ ## When to Use
745
+
746
+ Activate this skill when:
747
+
748
+ - Claiming a WU (\`pnpm wu:claim\`)
749
+ - Blocking/unblocking WUs due to dependencies
750
+ - Running \`wu:done\` completion workflow
751
+ - Understanding WU state machine transitions
752
+
753
+ ## State Machine
754
+
755
+ \`\`\`
756
+ ready -> in_progress -> waiting/blocked -> done
757
+ \`\`\`
758
+
759
+ ## Core Commands
760
+
761
+ \`\`\`bash
762
+ # Claim WU
763
+ pnpm wu:claim --id WU-XXX --lane <lane>
764
+ cd worktrees/<lane>-wu-xxx # IMMEDIATELY
765
+
766
+ # Complete WU (from main)
767
+ cd ../..
768
+ pnpm wu:done --id WU-XXX
769
+
770
+ # Block/Unblock
771
+ pnpm wu:block --id WU-XXX --reason "..."
772
+ pnpm wu:unblock --id WU-XXX
773
+
774
+ # Create (full spec)
775
+ pnpm wu:create --id WU-999 --lane "Operations" --title "Add feature" \\
776
+ --description "Context: ... Problem: ... Solution: ..." \\
777
+ --acceptance "Feature works" --code-paths "src/a.ts" --validate
778
+ \`\`\`
779
+
780
+ ## wu:done Workflow
781
+
782
+ 1. Runs gates in worktree
783
+ 2. Fast-forward merge to main
784
+ 3. Creates \`.lumenflow/stamps/WU-XXX.done\`
785
+ 4. Updates backlog.md + status.md
786
+ 5. Removes worktree
787
+
788
+ ## Worktree Discipline
789
+
790
+ After \`wu:claim\`:
791
+
792
+ - \`cd worktrees/<lane>-wu-xxx\` immediately
793
+ - Use relative paths (never absolute)
794
+ - Main is read-only
795
+ `;
796
+ const WORKTREE_DISCIPLINE_SKILL_TEMPLATE = `---
797
+ name: worktree-discipline
798
+ description: Prevents the "absolute path trap" in Write/Edit/Read tools.
799
+ version: 1.0.0
800
+ ---
801
+
802
+ # Worktree Discipline: Absolute Path Trap Prevention
803
+
804
+ **Purpose**: Prevent AI agents from bypassing worktree isolation via absolute file paths.
805
+
806
+ ## The Absolute Path Trap
807
+
808
+ **Problem**: AI agents using Write/Edit/Read tools can bypass worktree isolation by passing absolute paths. Even when your shell is in the worktree, absolute paths target the main checkout.
809
+
810
+ ### Example
811
+
812
+ \`\`\`typescript
813
+ // Shell: cd worktrees/operations-wu-427
814
+
815
+ // WRONG - Absolute path bypasses worktree
816
+ Write({
817
+ file_path: '/home/user/source/project/apps/web/src/validator.ts',
818
+ content: '...',
819
+ });
820
+ // Result: Written to MAIN checkout, not worktree!
821
+
822
+ // RIGHT - Relative path respects worktree
823
+ Write({
824
+ file_path: 'apps/web/src/validator.ts',
825
+ content: '...',
826
+ });
827
+ // Result: Written to worktree correctly
828
+ \`\`\`
829
+
830
+ ## Pre-Operation Checklist
831
+
832
+ **Before ANY Write/Edit/Read operation:**
833
+
834
+ 1. **Verify working directory**:
835
+
836
+ \`\`\`bash
837
+ pwd
838
+ # Must show: .../worktrees/<lane>-wu-xxx
839
+ \`\`\`
840
+
841
+ 2. **Check file path format**:
842
+
843
+ | Pattern | Safe? | Example |
844
+ | --------------------------------- | ----- | ------------------------ |
845
+ | Starts with \`/home/\` or \`/Users/\` | NO | \`/home/user/.../file.ts\` |
846
+ | Contains full repo path | NO | \`/source/project/...\` |
847
+ | Starts with package name | YES | \`apps/web/src/...\` |
848
+ | Starts with \`./\` or \`../\` | YES | \`./src/lib/...\` |
849
+ | Just filename | YES | \`README.md\` |
850
+
851
+ 3. **Use relative paths for ALL file operations**
852
+
853
+ ## Golden Rules
854
+
855
+ 1. **Always verify pwd** before file operations
856
+ 2. **Never use absolute paths** in Write/Edit/Read tools
857
+ 3. **When in doubt, use relative paths**
858
+ `;
859
+ const LUMENFLOW_GATES_SKILL_TEMPLATE = `---
860
+ name: lumenflow-gates
861
+ description: Quality gates troubleshooting (format, lint, typecheck, tests).
862
+ version: 1.0.0
863
+ ---
864
+
865
+ # LumenFlow Gates Skill
866
+
867
+ ## When to Use
868
+
869
+ Activate this skill when:
870
+
871
+ - \`pnpm gates\` fails with format, lint, or typecheck errors
872
+ - Need to determine if failure is from your changes vs pre-existing
873
+ - Debugging test failures or coverage issues
874
+ - Deciding whether to use \`--skip-gates\` (emergency only)
875
+
876
+ ## Gate Sequence
877
+
878
+ \`\`\`
879
+ pnpm gates = format:check -> lint -> typecheck -> spec:linter -> tests
880
+ \`\`\`
881
+
882
+ ## Fix Patterns
883
+
884
+ | Gate | Auto-fix | Manual |
885
+ | --------- | --------------- | ----------------------------------- |
886
+ | Format | \`pnpm format\` | - |
887
+ | Lint | \`pnpm lint:fix\` | Fix reported issues |
888
+ | Typecheck | - | Fix type errors (first error first) |
889
+ | Tests | - | Debug, fix mocks, update snapshots |
890
+
891
+ ## Decision Tree
892
+
893
+ **Gate failed. Is it from YOUR changes?**
894
+
895
+ \`\`\`bash
896
+ git checkout main && pnpm gates # Check main
897
+ # Pass on main -> Your change caused it -> Fix it
898
+ # Fail on main -> Pre-existing -> Consider --skip-gates
899
+ \`\`\`
900
+
901
+ **Can you fix it?**
902
+
903
+ - In your \`code_paths\`, <=10 lines -> Fix in place
904
+ - Different paths, >10 lines -> Create Bug WU
905
+
906
+ ## Skip Gates (Emergency)
907
+
908
+ Only when pre-existing failures:
909
+
910
+ \`\`\`bash
911
+ pnpm wu:done --id WU-XXX --skip-gates --reason "Pre-existing" --fix-wu WU-YYY
912
+ \`\`\`
913
+
914
+ ## Common Lint Fixes
915
+
916
+ \`\`\`
917
+ no-explicit-any -> Add proper types
918
+ no-unused-vars -> Remove or prefix with _
919
+ no-restricted-paths -> Check hex boundaries
920
+ exhaustive-deps -> Add missing dependencies
921
+ \`\`\`
922
+
923
+ ## Validation Commands
924
+
925
+ \`\`\`bash
926
+ pnpm gates # All gates
927
+ pnpm gates -- --docs-only # Docs WUs
928
+ pnpm format # Fix formatting
929
+ pnpm lint:fix # Fix lint issues
930
+ pnpm typecheck # Check types
931
+ \`\`\`
932
+ `;
121
933
  /**
122
934
  * Detect default client from environment
123
935
  */
@@ -232,6 +1044,38 @@ async function scaffoldFullDocs(targetDir, options, result, tokens) {
232
1044
  await createFile(path.join(tasksDir, 'backlog.md'), BACKLOG_TEMPLATE, options.force, result, targetDir);
233
1045
  await createFile(path.join(tasksDir, 'status.md'), STATUS_TEMPLATE, options.force, result, targetDir);
234
1046
  await createFile(path.join(templatesDir, 'wu-template.yaml'), processTemplate(WU_TEMPLATE_YAML, tokens), options.force, result, targetDir);
1047
+ // WU-1083: Scaffold agent onboarding docs with --full
1048
+ await scaffoldAgentOnboardingDocs(targetDir, options, result, tokens);
1049
+ }
1050
+ /**
1051
+ * WU-1083: Scaffold agent onboarding documentation
1052
+ */
1053
+ async function scaffoldAgentOnboardingDocs(targetDir, options, result, tokens) {
1054
+ const onboardingDir = path.join(targetDir, 'docs', '04-operations', '_frameworks', 'lumenflow', 'agent', 'onboarding');
1055
+ await createDirectory(onboardingDir, result, targetDir);
1056
+ await createFile(path.join(onboardingDir, 'quick-ref-commands.md'), processTemplate(QUICK_REF_COMMANDS_TEMPLATE, tokens), options.force, result, targetDir);
1057
+ await createFile(path.join(onboardingDir, 'first-wu-mistakes.md'), processTemplate(FIRST_WU_MISTAKES_TEMPLATE, tokens), options.force, result, targetDir);
1058
+ await createFile(path.join(onboardingDir, 'troubleshooting-wu-done.md'), processTemplate(TROUBLESHOOTING_WU_DONE_TEMPLATE, tokens), options.force, result, targetDir);
1059
+ await createFile(path.join(onboardingDir, 'agent-safety-card.md'), processTemplate(AGENT_SAFETY_CARD_TEMPLATE, tokens), options.force, result, targetDir);
1060
+ await createFile(path.join(onboardingDir, 'wu-create-checklist.md'), processTemplate(WU_CREATE_CHECKLIST_TEMPLATE, tokens), options.force, result, targetDir);
1061
+ }
1062
+ /**
1063
+ * WU-1083: Scaffold Claude skills
1064
+ */
1065
+ async function scaffoldClaudeSkills(targetDir, options, result, tokens) {
1066
+ const skillsDir = path.join(targetDir, '.claude', 'skills');
1067
+ // wu-lifecycle skill
1068
+ const wuLifecycleDir = path.join(skillsDir, 'wu-lifecycle');
1069
+ await createDirectory(wuLifecycleDir, result, targetDir);
1070
+ await createFile(path.join(wuLifecycleDir, 'SKILL.md'), processTemplate(WU_LIFECYCLE_SKILL_TEMPLATE, tokens), options.force, result, targetDir);
1071
+ // worktree-discipline skill
1072
+ const worktreeDir = path.join(skillsDir, 'worktree-discipline');
1073
+ await createDirectory(worktreeDir, result, targetDir);
1074
+ await createFile(path.join(worktreeDir, 'SKILL.md'), processTemplate(WORKTREE_DISCIPLINE_SKILL_TEMPLATE, tokens), options.force, result, targetDir);
1075
+ // lumenflow-gates skill
1076
+ const gatesDir = path.join(skillsDir, 'lumenflow-gates');
1077
+ await createDirectory(gatesDir, result, targetDir);
1078
+ await createFile(path.join(gatesDir, 'SKILL.md'), processTemplate(LUMENFLOW_GATES_SKILL_TEMPLATE, tokens), options.force, result, targetDir);
235
1079
  }
236
1080
  async function scaffoldFrameworkOverlay(targetDir, options, result, tokens) {
237
1081
  if (!options.framework) {
@@ -258,6 +1102,10 @@ async function scaffoldVendorFiles(targetDir, options, result, tokens, vendor) {
258
1102
  await createDirectory(path.join(targetDir, CLAUDE_AGENTS_DIR), result, targetDir);
259
1103
  await createFile(path.join(targetDir, CLAUDE_AGENTS_DIR, '.gitkeep'), '', options.force, result, targetDir);
260
1104
  await createFile(path.join(targetDir, CLAUDE_DIR, 'settings.json'), CLAUDE_SETTINGS_TEMPLATE, options.force, result, targetDir);
1105
+ // WU-1083: Scaffold Claude skills
1106
+ await scaffoldClaudeSkills(targetDir, options, result, tokens);
1107
+ // WU-1083: Scaffold agent onboarding docs for Claude vendor (even without --full)
1108
+ await scaffoldAgentOnboardingDocs(targetDir, options, result, tokens);
261
1109
  }
262
1110
  // Cursor
263
1111
  if (vendor === 'cursor' || vendor === 'all') {
@@ -297,26 +1145,22 @@ async function createFile(filePath, content, force, result, targetDir) {
297
1145
  }
298
1146
  /**
299
1147
  * CLI entry point
1148
+ * WU-1085: Updated to use parseInitOptions for proper --help support
300
1149
  */
301
1150
  export async function main() {
302
- const args = process.argv.slice(2);
303
- const force = args.includes('--force') || args.includes('-f');
304
- const full = args.includes('--full');
305
- const vendor = parseVendorArg(args);
306
- const framework = parseFrameworkArg(args);
307
- const gatePreset = parsePresetArg(args); // WU-1067
1151
+ const opts = parseInitOptions();
308
1152
  const targetDir = process.cwd();
309
1153
  console.log('[lumenflow init] Scaffolding LumenFlow project...');
310
- console.log(` Mode: ${full ? 'full' : 'minimal'}`);
311
- console.log(` Framework: ${framework ?? 'none'}`);
312
- console.log(` Vendor overlays: ${vendor ?? 'auto'}`);
313
- console.log(` Gate preset: ${gatePreset ?? 'none (manual config)'}`);
1154
+ console.log(` Mode: ${opts.full ? 'full' : 'minimal'}`);
1155
+ console.log(` Framework: ${opts.framework ?? 'none'}`);
1156
+ console.log(` Vendor overlays: ${opts.vendor ?? 'auto'}`);
1157
+ console.log(` Gate preset: ${opts.preset ?? 'none (manual config)'}`);
314
1158
  const result = await scaffoldProject(targetDir, {
315
- force,
316
- full,
317
- vendor,
318
- framework,
319
- gatePreset,
1159
+ force: opts.force,
1160
+ full: opts.full,
1161
+ vendor: opts.vendor,
1162
+ framework: opts.framework,
1163
+ gatePreset: opts.preset,
320
1164
  });
321
1165
  if (result.created.length > 0) {
322
1166
  console.log('\nCreated:');