@lumenflow/cli 2.3.2 → 2.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.
Files changed (135) hide show
  1. package/dist/__tests__/init-config-lanes.test.js +131 -0
  2. package/dist/__tests__/init-docs-structure.test.js +119 -0
  3. package/dist/__tests__/init-lane-inference.test.js +125 -0
  4. package/dist/__tests__/init-onboarding-docs.test.js +132 -0
  5. package/dist/__tests__/init-quick-ref.test.js +145 -0
  6. package/dist/__tests__/init-scripts.test.js +96 -0
  7. package/dist/__tests__/init-template-portability.test.js +97 -0
  8. package/dist/__tests__/init.test.js +199 -3
  9. package/dist/__tests__/initiative-add-wu.test.js +420 -0
  10. package/dist/__tests__/initiative-plan-replacement.test.js +162 -0
  11. package/dist/__tests__/initiative-remove-wu.test.js +458 -0
  12. package/dist/__tests__/onboarding-smoke-test.test.js +211 -0
  13. package/dist/__tests__/path-centralization-cli.test.js +234 -0
  14. package/dist/__tests__/plan-create.test.js +126 -0
  15. package/dist/__tests__/plan-edit.test.js +157 -0
  16. package/dist/__tests__/plan-link.test.js +239 -0
  17. package/dist/__tests__/plan-promote.test.js +181 -0
  18. package/dist/__tests__/wu-create-strict.test.js +118 -0
  19. package/dist/__tests__/wu-edit-strict.test.js +109 -0
  20. package/dist/__tests__/wu-validate-strict.test.js +113 -0
  21. package/dist/flow-bottlenecks.js +4 -2
  22. package/dist/flow-report.js +3 -2
  23. package/dist/gates.js +202 -2
  24. package/dist/init.js +720 -40
  25. package/dist/initiative-add-wu.js +112 -16
  26. package/dist/initiative-plan.js +3 -2
  27. package/dist/initiative-remove-wu.js +248 -0
  28. package/dist/mem-context.js +0 -0
  29. package/dist/metrics-snapshot.js +3 -2
  30. package/dist/onboarding-smoke-test.js +400 -0
  31. package/dist/plan-create.js +199 -0
  32. package/dist/plan-edit.js +235 -0
  33. package/dist/plan-link.js +233 -0
  34. package/dist/plan-promote.js +231 -0
  35. package/dist/rotate-progress.js +8 -5
  36. package/dist/spawn-list.js +4 -3
  37. package/dist/state-bootstrap.js +6 -4
  38. package/dist/state-doctor-fix.js +5 -4
  39. package/dist/state-doctor.js +32 -2
  40. package/dist/trace-gen.js +6 -3
  41. package/dist/wu-block.js +16 -5
  42. package/dist/wu-claim.js +15 -9
  43. package/dist/wu-create.js +50 -2
  44. package/dist/wu-deps.js +3 -1
  45. package/dist/wu-done.js +14 -5
  46. package/dist/wu-edit.js +35 -0
  47. package/dist/wu-infer-lane.js +3 -1
  48. package/dist/wu-spawn.js +8 -0
  49. package/dist/wu-unblock.js +34 -2
  50. package/dist/wu-validate.js +25 -17
  51. package/package.json +12 -6
  52. package/templates/core/AGENTS.md.template +2 -2
  53. package/dist/__tests__/init-plan.test.js +0 -340
  54. package/dist/agent-issues-query.d.ts +0 -16
  55. package/dist/agent-log-issue.d.ts +0 -10
  56. package/dist/agent-session-end.d.ts +0 -10
  57. package/dist/agent-session.d.ts +0 -10
  58. package/dist/backlog-prune.d.ts +0 -84
  59. package/dist/cli-entry-point.d.ts +0 -8
  60. package/dist/deps-add.d.ts +0 -91
  61. package/dist/deps-remove.d.ts +0 -17
  62. package/dist/docs-sync.d.ts +0 -50
  63. package/dist/file-delete.d.ts +0 -84
  64. package/dist/file-edit.d.ts +0 -82
  65. package/dist/file-read.d.ts +0 -92
  66. package/dist/file-write.d.ts +0 -90
  67. package/dist/flow-bottlenecks.d.ts +0 -16
  68. package/dist/flow-report.d.ts +0 -16
  69. package/dist/gates.d.ts +0 -94
  70. package/dist/git-branch.d.ts +0 -65
  71. package/dist/git-diff.d.ts +0 -58
  72. package/dist/git-log.d.ts +0 -69
  73. package/dist/git-status.d.ts +0 -58
  74. package/dist/guard-locked.d.ts +0 -62
  75. package/dist/guard-main-branch.d.ts +0 -50
  76. package/dist/guard-worktree-commit.d.ts +0 -59
  77. package/dist/index.d.ts +0 -10
  78. package/dist/init-plan.d.ts +0 -80
  79. package/dist/init-plan.js +0 -337
  80. package/dist/init.d.ts +0 -46
  81. package/dist/initiative-add-wu.d.ts +0 -22
  82. package/dist/initiative-bulk-assign-wus.d.ts +0 -16
  83. package/dist/initiative-create.d.ts +0 -28
  84. package/dist/initiative-edit.d.ts +0 -34
  85. package/dist/initiative-list.d.ts +0 -12
  86. package/dist/initiative-status.d.ts +0 -11
  87. package/dist/lumenflow-upgrade.d.ts +0 -103
  88. package/dist/mem-checkpoint.d.ts +0 -16
  89. package/dist/mem-cleanup.d.ts +0 -29
  90. package/dist/mem-create.d.ts +0 -17
  91. package/dist/mem-export.d.ts +0 -10
  92. package/dist/mem-inbox.d.ts +0 -35
  93. package/dist/mem-init.d.ts +0 -15
  94. package/dist/mem-ready.d.ts +0 -16
  95. package/dist/mem-signal.d.ts +0 -16
  96. package/dist/mem-start.d.ts +0 -16
  97. package/dist/mem-summarize.d.ts +0 -22
  98. package/dist/mem-triage.d.ts +0 -22
  99. package/dist/metrics-cli.d.ts +0 -90
  100. package/dist/metrics-snapshot.d.ts +0 -18
  101. package/dist/orchestrate-init-status.d.ts +0 -11
  102. package/dist/orchestrate-initiative.d.ts +0 -12
  103. package/dist/orchestrate-monitor.d.ts +0 -11
  104. package/dist/release.d.ts +0 -117
  105. package/dist/rotate-progress.d.ts +0 -48
  106. package/dist/session-coordinator.d.ts +0 -74
  107. package/dist/spawn-list.d.ts +0 -16
  108. package/dist/state-bootstrap.d.ts +0 -92
  109. package/dist/sync-templates.d.ts +0 -52
  110. package/dist/trace-gen.d.ts +0 -84
  111. package/dist/validate-agent-skills.d.ts +0 -50
  112. package/dist/validate-agent-sync.d.ts +0 -36
  113. package/dist/validate-backlog-sync.d.ts +0 -37
  114. package/dist/validate-skills-spec.d.ts +0 -40
  115. package/dist/validate.d.ts +0 -60
  116. package/dist/wu-block.d.ts +0 -16
  117. package/dist/wu-claim.d.ts +0 -74
  118. package/dist/wu-cleanup.d.ts +0 -35
  119. package/dist/wu-create.d.ts +0 -69
  120. package/dist/wu-delete.d.ts +0 -21
  121. package/dist/wu-deps.d.ts +0 -13
  122. package/dist/wu-done.d.ts +0 -225
  123. package/dist/wu-edit.d.ts +0 -63
  124. package/dist/wu-infer-lane.d.ts +0 -17
  125. package/dist/wu-preflight.d.ts +0 -47
  126. package/dist/wu-prune.d.ts +0 -16
  127. package/dist/wu-recover.d.ts +0 -37
  128. package/dist/wu-release.d.ts +0 -19
  129. package/dist/wu-repair.d.ts +0 -60
  130. package/dist/wu-spawn-completion.d.ts +0 -10
  131. package/dist/wu-spawn.d.ts +0 -192
  132. package/dist/wu-status.d.ts +0 -25
  133. package/dist/wu-unblock.d.ts +0 -16
  134. package/dist/wu-unlock-lane.d.ts +0 -19
  135. package/dist/wu-validate.d.ts +0 -16
package/dist/init.js CHANGED
@@ -88,14 +88,49 @@ export function parseInitOptions() {
88
88
  };
89
89
  }
90
90
  const DEFAULT_CLIENT_CLAUDE = 'claude-code';
91
+ /**
92
+ * WU-1309: Get docs paths based on structure type
93
+ */
94
+ export function getDocsPath(structure) {
95
+ if (structure === 'simple') {
96
+ return {
97
+ operations: 'docs',
98
+ tasks: 'docs/tasks',
99
+ onboarding: 'docs/_frameworks/lumenflow/agent/onboarding',
100
+ quickRefLink: 'docs/_frameworks/lumenflow/agent/onboarding/quick-ref-commands.md',
101
+ };
102
+ }
103
+ // arc42 structure
104
+ return {
105
+ operations: 'docs/04-operations',
106
+ tasks: 'docs/04-operations/tasks',
107
+ onboarding: 'docs/04-operations/_frameworks/lumenflow/agent/onboarding',
108
+ quickRefLink: 'docs/04-operations/_frameworks/lumenflow/agent/onboarding/quick-ref-commands.md',
109
+ };
110
+ }
111
+ /**
112
+ * WU-1309: Detect existing docs structure or return default
113
+ * Auto-detects arc42 when docs/04-operations or any numbered dir (01-*, 02-*, etc.) exists
114
+ */
115
+ export function detectDocsStructure(targetDir) {
116
+ const docsDir = path.join(targetDir, 'docs');
117
+ if (!fs.existsSync(docsDir)) {
118
+ return 'simple';
119
+ }
120
+ // Check for arc42 numbered directories (01-*, 02-*, ..., 04-operations, etc.)
121
+ const entries = fs.readdirSync(docsDir);
122
+ const hasNumberedDir = entries.some((entry) => /^\d{2}-/.test(entry));
123
+ if (hasNumberedDir) {
124
+ return 'arc42';
125
+ }
126
+ return 'simple';
127
+ }
91
128
  const CONFIG_FILE_NAME = '.lumenflow.config.yaml';
92
129
  const FRAMEWORK_HINT_FILE = '.lumenflow.framework.yaml';
93
130
  const LUMENFLOW_DIR = '.lumenflow';
94
131
  const LUMENFLOW_AGENTS_DIR = `${LUMENFLOW_DIR}/agents`;
95
132
  const CLAUDE_DIR = '.claude';
96
133
  const CLAUDE_AGENTS_DIR = path.join(CLAUDE_DIR, 'agents');
97
- // Shared path segment for docs structure
98
- const DOCS_OPERATIONS_DIR = '04-operations';
99
134
  /**
100
135
  * WU-1177: Detect IDE environment from environment variables
101
136
  * Auto-detects which AI coding assistant is running
@@ -199,9 +234,51 @@ export function checkPrerequisites() {
199
234
  },
200
235
  };
201
236
  }
237
+ /**
238
+ * WU-1307: Default lane definitions for config generation
239
+ * These lanes match the parent lanes used in onboarding documentation.
240
+ */
241
+ const DEFAULT_LANE_DEFINITIONS = [
242
+ {
243
+ name: 'Framework: Core',
244
+ wip_limit: 1,
245
+ code_paths: ['packages/**/core/**', 'src/core/**', 'lib/**'],
246
+ },
247
+ {
248
+ name: 'Framework: CLI',
249
+ wip_limit: 1,
250
+ code_paths: ['packages/**/cli/**', 'src/cli/**', 'bin/**'],
251
+ },
252
+ {
253
+ name: 'Experience: UI',
254
+ wip_limit: 1,
255
+ code_paths: ['apps/web/**', 'src/components/**', 'src/pages/**', 'src/app/**'],
256
+ },
257
+ {
258
+ name: 'Experience: Web',
259
+ wip_limit: 1,
260
+ code_paths: ['apps/web/**', 'web/**'],
261
+ },
262
+ {
263
+ name: 'Operations: Infrastructure',
264
+ wip_limit: 1,
265
+ code_paths: ['apps/**', 'infrastructure/**', 'deploy/**'],
266
+ },
267
+ {
268
+ name: 'Operations: CI/CD',
269
+ wip_limit: 1,
270
+ code_paths: ['.github/workflows/**', '.github/actions/**', '.circleci/**'],
271
+ },
272
+ {
273
+ name: 'Content: Documentation',
274
+ wip_limit: 1,
275
+ code_paths: ['docs/**', '*.md'],
276
+ },
277
+ ];
202
278
  /**
203
279
  * Generate YAML configuration with header comment
204
280
  * WU-1067: Supports --preset option for config-driven gates
281
+ * WU-1307: Includes default lane definitions for onboarding
205
282
  */
206
283
  function generateLumenflowConfigYaml(gatePreset) {
207
284
  const header = `# LumenFlow Configuration\n# Generated by: lumenflow init\n# Customize paths based on your project structure\n\n`;
@@ -215,6 +292,10 @@ function generateLumenflowConfigYaml(gatePreset) {
215
292
  ...presetConfig,
216
293
  };
217
294
  }
295
+ // WU-1307: Add default lane definitions
296
+ config.lanes = {
297
+ definitions: DEFAULT_LANE_DEFINITIONS,
298
+ };
218
299
  return header + yaml.stringify(config);
219
300
  }
220
301
  /**
@@ -254,6 +335,8 @@ function getRelativePath(targetDir, filePath) {
254
335
  return path.relative(targetDir, filePath).split(path.sep).join('/');
255
336
  }
256
337
  // WU-1171: Template for AGENTS.md (universal entry point)
338
+ // WU-1300: Updated quick-ref link to correct path
339
+ // WU-1309: Use {{QUICK_REF_LINK}} and <project-root> placeholder for portability
257
340
  const AGENTS_MD_TEMPLATE = `# Universal Agent Instructions
258
341
 
259
342
  **Last updated:** {{DATE}}
@@ -273,10 +356,12 @@ cd worktrees/<lane>-wu-xxxx
273
356
  pnpm gates
274
357
 
275
358
  # 3. Complete (ALWAYS run this!)
276
- cd {{PROJECT_ROOT}}
359
+ cd <project-root>
277
360
  pnpm wu:done --id WU-XXXX
278
361
  \`\`\`
279
362
 
363
+ > **Complete CLI reference:** See [quick-ref-commands.md]({{QUICK_REF_LINK}})
364
+
280
365
  ---
281
366
 
282
367
  ## Critical: Always wu:done
@@ -314,11 +399,13 @@ This file provides universal guidance for all AI agents. Additional vendor-speci
314
399
  - **Windsurf**: See \`.windsurf/rules/lumenflow.md\` (if present)
315
400
  `;
316
401
  // Template for LUMENFLOW.md (main entry point)
317
- const LUMENFLOW_MD_TEMPLATE = `# LumenFlow Workflow Guide\n\n**Last updated:** {{DATE}}\n\nLumenFlow is a vendor-agnostic workflow framework for AI-native software development.\n\n---\n\n## Critical Rule: ALWAYS Run wu:done\n\n**After completing work on a WU, you MUST run \`pnpm wu:done --id WU-XXXX\` from the main checkout.**\n\nThis is the single most forgotten step. Do NOT:\n- Write "To Complete: pnpm wu:done" and stop\n- Ask if you should run wu:done\n- Forget to run wu:done\n\n**DO**: Run \`pnpm wu:done --id WU-XXXX\` immediately after gates pass.\n\n---\n\n## Quick Start\n\n\`\`\`bash\n# 1. Create a WU\npnpm wu:create --id WU-XXXX --lane <Lane> --title "Title"\n\n# 2. Edit WU spec with acceptance criteria, then claim:\npnpm wu:claim --id WU-XXXX --lane <Lane>\ncd worktrees/<lane>-wu-xxxx\n\n# 3. Implement in worktree\n\n# 4. Run gates\npnpm gates --docs-only # for docs changes\npnpm gates # for code changes\n\n# 5. Complete (from main checkout)\ncd {{PROJECT_ROOT}}\npnpm wu:done --id WU-XXXX\n\`\`\`\n\n---\n\n## Core Principles\n\n1. **TDD**: Failing test -> implementation -> passing test (>=90% coverage on new code)\n2. **Library-First**: Search existing libraries before custom code\n3. **DRY/SOLID/KISS/YAGNI**: No magic numbers, no hardcoded strings\n4. **Worktree Discipline**: After \`wu:claim\`, work ONLY in the worktree\n5. **Gates Before Done**: All gates must pass before \`wu:done\`\n6. **Do Not Bypass Hooks**: No \`--no-verify\`, fix issues properly\n7. **Always wu:done**: Complete every WU by running \`pnpm wu:done\`\n\n---\n\n## Documentation Structure\n\n### Core (Vendor-Agnostic)\n\n- **LUMENFLOW.md** - This file, main entry point\n- **.lumenflow/constraints.md** - Non-negotiable workflow constraints\n- **.lumenflow/agents/** - Agent instructions (vendor-agnostic)\n- **.lumenflow.config.yaml** - Workflow configuration\n\n### Optional Overlays\n\n- **CLAUDE.md + .claude/agents/** - Claude Code overlay (auto if Claude Code detected)\n- **docs/04-operations/tasks/** - Task boards and WU storage (\`lumenflow init --full\`)\n- **docs/04-operations/_frameworks/<framework>/** - Framework overlay docs (\`lumenflow init --framework <name>\`)\n- **.lumenflow.framework.yaml** - Framework hint file (created with \`--framework\`)\n\n---\n\n## Worktree Discipline (IMMUTABLE LAW)\n\nAfter claiming a WU, you MUST work in its worktree:\n\n\`\`\`bash\n# 1. Claim creates worktree\npnpm wu:claim --id WU-XXX --lane <lane>\n\n# 2. IMMEDIATELY cd to worktree\ncd worktrees/<lane>-wu-xxx\n\n# 3. ALL work happens here\n\n# 4. Return to main ONLY to complete\ncd {{PROJECT_ROOT}}\npnpm wu:done --id WU-XXX\n\`\`\`\n\n---\n\n## Definition of Done\n\n- Acceptance criteria satisfied\n- Gates green (\`pnpm gates\` or \`pnpm gates --docs-only\`)\n- WU YAML status = \`done\`\n- \`wu:done\` has been run\n\n---\n\n## Commands Reference\n\n| Command | Description |\n| ----------------- | ----------------------------------- |\n| \`pnpm wu:create\` | Create new WU spec |\n| \`pnpm wu:claim\` | Claim WU and create worktree |\n| \`pnpm wu:done\` | Complete WU (merge, stamp, cleanup) |\n| \`pnpm gates\` | Run quality gates |\n\n---\n\n## Constraints\n\nSee [.lumenflow/constraints.md](.lumenflow/constraints.md) for the 6 non-negotiable rules.\n\n---\n\n## Agent Onboarding\n\n- Start with **CLAUDE.md** if present (Claude Code overlay).\n- Add vendor-agnostic guidance in **.lumenflow/agents/**.\n- Add framework-specific notes in **docs/04-operations/_frameworks/<framework>/**.\n`;
402
+ // WU-1309: Use <project-root> placeholder for portability
403
+ const LUMENFLOW_MD_TEMPLATE = `# LumenFlow Workflow Guide\n\n**Last updated:** {{DATE}}\n\nLumenFlow is a vendor-agnostic workflow framework for AI-native software development.\n\n---\n\n## Critical Rule: ALWAYS Run wu:done\n\n**After completing work on a WU, you MUST run \`pnpm wu:done --id WU-XXXX\` from the main checkout.**\n\nThis is the single most forgotten step. Do NOT:\n- Write "To Complete: pnpm wu:done" and stop\n- Ask if you should run wu:done\n- Forget to run wu:done\n\n**DO**: Run \`pnpm wu:done --id WU-XXXX\` immediately after gates pass.\n\n---\n\n## Quick Start\n\n\`\`\`bash\n# 1. Create a WU\npnpm wu:create --id WU-XXXX --lane <Lane> --title "Title"\n\n# 2. Edit WU spec with acceptance criteria, then claim:\npnpm wu:claim --id WU-XXXX --lane <Lane>\ncd worktrees/<lane>-wu-xxxx\n\n# 3. Implement in worktree\n\n# 4. Run gates\npnpm gates --docs-only # for docs changes\npnpm gates # for code changes\n\n# 5. Complete (from main checkout)\ncd <project-root>\npnpm wu:done --id WU-XXXX\n\`\`\`\n\n---\n\n## Core Principles\n\n1. **TDD**: Failing test -> implementation -> passing test (>=90% coverage on new code)\n2. **Library-First**: Search existing libraries before custom code\n3. **DRY/SOLID/KISS/YAGNI**: No magic numbers, no hardcoded strings\n4. **Worktree Discipline**: After \`wu:claim\`, work ONLY in the worktree\n5. **Gates Before Done**: All gates must pass before \`wu:done\`\n6. **Do Not Bypass Hooks**: No \`--no-verify\`, fix issues properly\n7. **Always wu:done**: Complete every WU by running \`pnpm wu:done\`\n\n---\n\n## Documentation Structure\n\n### Core (Vendor-Agnostic)\n\n- **LUMENFLOW.md** - This file, main entry point\n- **.lumenflow/constraints.md** - Non-negotiable workflow constraints\n- **.lumenflow/agents/** - Agent instructions (vendor-agnostic)\n- **.lumenflow.config.yaml** - Workflow configuration\n\n### Optional Overlays\n\n- **CLAUDE.md + .claude/agents/** - Claude Code overlay (auto if Claude Code detected)\n- **{{DOCS_TASKS_PATH}}** - Task boards and WU storage (\`lumenflow init --full\`)\n- **{{DOCS_ONBOARDING_PATH}}** - Agent onboarding docs\n- **.lumenflow.framework.yaml** - Framework hint file (created with \`--framework\`)\n\n---\n\n## Worktree Discipline (IMMUTABLE LAW)\n\nAfter claiming a WU, you MUST work in its worktree:\n\n\`\`\`bash\n# 1. Claim creates worktree\npnpm wu:claim --id WU-XXX --lane <lane>\n\n# 2. IMMEDIATELY cd to worktree\ncd worktrees/<lane>-wu-xxx\n\n# 3. ALL work happens here\n\n# 4. Return to main ONLY to complete\ncd <project-root>\npnpm wu:done --id WU-XXX\n\`\`\`\n\n---\n\n## Definition of Done\n\n- Acceptance criteria satisfied\n- Gates green (\`pnpm gates\` or \`pnpm gates --docs-only\`)\n- WU YAML status = \`done\`\n- \`wu:done\` has been run\n\n---\n\n## Commands Reference\n\n| Command | Description |\n| ----------------- | ----------------------------------- |\n| \`pnpm wu:create\` | Create new WU spec |\n| \`pnpm wu:claim\` | Claim WU and create worktree |\n| \`pnpm wu:done\` | Complete WU (merge, stamp, cleanup) |\n| \`pnpm gates\` | Run quality gates |\n\n---\n\n## Constraints\n\nSee [.lumenflow/constraints.md](.lumenflow/constraints.md) for the 6 non-negotiable rules.\n\n---\n\n## Agent Onboarding\n\n- Start with **CLAUDE.md** if present (Claude Code overlay).\n- Add vendor-agnostic guidance in **.lumenflow/agents/**.\n- Check the onboarding docs in **{{DOCS_ONBOARDING_PATH}}** for detailed guidance.\n`;
318
404
  // Template for .lumenflow/constraints.md
319
405
  const CONSTRAINTS_MD_TEMPLATE = `# LumenFlow Constraints Capsule\n\n**Version:** 1.0\n**Last updated:** {{DATE}}\n\n## The 6 Non-Negotiable Constraints\n\n### 1. Worktree Discipline and Git Safety\nWork only in worktrees, treat main as read-only, never run destructive git commands on main.\n\n### 2. WUs Are Specs, Not Code\nRespect code_paths boundaries, no feature creep, no code blocks in WU YAML files.\n\n### 3. Docs-Only vs Code WUs\nDocumentation WUs use \`--docs-only\` gates, code WUs run full gates.\n\n### 4. LLM-First, Zero-Fallback Inference\nUse LLMs for semantic tasks, fall back to safe defaults (never regex/keywords).\n\n### 5. Gates and Skip-Gates\nComplete via \`pnpm wu:done\`; skip-gates only for pre-existing failures with \`--reason\` and \`--fix-wu\`.\n\n### 6. Safety and Governance\nRespect privacy rules, approved sources, security policies; when uncertain, choose safer path.\n\n---\n\n## Mini Audit Checklist\n\nBefore running \`wu:done\`, verify:\n\n- [ ] Working in worktree (not main)\n- [ ] Only modified files in \`code_paths\`\n- [ ] Gates pass\n- [ ] No forbidden git commands used\n- [ ] Acceptance criteria satisfied\n\n---\n\n## Escalation Triggers\n\nStop and ask a human when:\n- Same error repeats 3 times\n- Auth or permissions changes required\n- PII/PHI/safety issues discovered\n- Cloud spend or secrets involved\n`;
320
406
  // Template for root CLAUDE.md
321
- const CLAUDE_MD_TEMPLATE = `# Claude Code Instructions\n\n**Last updated:** {{DATE}}\n\nThis project uses LumenFlow workflow. For workflow documentation, see [LUMENFLOW.md](LUMENFLOW.md).\n\n---\n\n## Quick Start\n\n\`\`\`bash\n# 1. Claim a WU\npnpm wu:claim --id WU-XXXX --lane <Lane>\ncd worktrees/<lane>-wu-xxxx\n\n# 2. Work in worktree, run gates\npnpm gates\n\n# 3. Complete (ALWAYS run this!)\ncd {{PROJECT_ROOT}}\npnpm wu:done --id WU-XXXX\n\`\`\`\n\n---\n\n## Critical: Always wu:done\n\nAfter completing work, ALWAYS run \`pnpm wu:done --id WU-XXXX\`.\n\nSee [LUMENFLOW.md](LUMENFLOW.md) for full workflow documentation.\n`;
407
+ // WU-1309: Use <project-root> placeholder for portability
408
+ const CLAUDE_MD_TEMPLATE = `# Claude Code Instructions\n\n**Last updated:** {{DATE}}\n\nThis project uses LumenFlow workflow. For workflow documentation, see [LUMENFLOW.md](LUMENFLOW.md).\n\n---\n\n## Quick Start\n\n\`\`\`bash\n# 1. Claim a WU\npnpm wu:claim --id WU-XXXX --lane <Lane>\ncd worktrees/<lane>-wu-xxxx\n\n# 2. Work in worktree, run gates\npnpm gates\n\n# 3. Complete (ALWAYS run this!)\ncd <project-root>\npnpm wu:done --id WU-XXXX\n\`\`\`\n\n---\n\n## Critical: Always wu:done\n\nAfter completing work, ALWAYS run \`pnpm wu:done --id WU-XXXX\`.\n\nSee [LUMENFLOW.md](LUMENFLOW.md) for full workflow documentation.\n`;
322
409
  // Template for .claude/settings.json
323
410
  const CLAUDE_SETTINGS_TEMPLATE = `{
324
411
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
@@ -351,6 +438,7 @@ const CLAUDE_SETTINGS_TEMPLATE = `{
351
438
  }
352
439
  `;
353
440
  // WU-1171: Template for .cursor/rules/lumenflow.md (updated path)
441
+ // WU-1309: Use <project-root> placeholder for portability
354
442
  const CURSOR_RULES_TEMPLATE = `# Cursor LumenFlow Rules
355
443
 
356
444
  This project uses LumenFlow workflow. See [LUMENFLOW.md](../../LUMENFLOW.md).
@@ -380,11 +468,12 @@ cd worktrees/<lane>-wu-xxx
380
468
  pnpm gates
381
469
 
382
470
  # Complete (from main)
383
- cd {{PROJECT_ROOT}}
471
+ cd <project-root>
384
472
  pnpm wu:done --id WU-XXX
385
473
  \`\`\`
386
474
  `;
387
475
  // WU-1171: Template for .windsurf/rules/lumenflow.md
476
+ // WU-1309: Use <project-root> placeholder for portability
388
477
  const WINDSURF_RULES_TEMPLATE = `# Windsurf LumenFlow Rules
389
478
 
390
479
  This project uses LumenFlow workflow. See [LUMENFLOW.md](../../LUMENFLOW.md).
@@ -414,11 +503,12 @@ cd worktrees/<lane>-wu-xxx
414
503
  pnpm gates
415
504
 
416
505
  # Complete (from main)
417
- cd {{PROJECT_ROOT}}
506
+ cd <project-root>
418
507
  pnpm wu:done --id WU-XXX
419
508
  \`\`\`
420
509
  `;
421
510
  // WU-1177: Template for .clinerules (Cline AI assistant)
511
+ // WU-1309: Use <project-root> placeholder for portability
422
512
  const CLINE_RULES_TEMPLATE = `# Cline LumenFlow Rules
423
513
 
424
514
  This project uses LumenFlow workflow. See [LUMENFLOW.md](LUMENFLOW.md).
@@ -448,7 +538,7 @@ cd worktrees/<lane>-wu-xxx
448
538
  pnpm gates
449
539
 
450
540
  # Complete (from main)
451
- cd {{PROJECT_ROOT}}
541
+ cd <project-root>
452
542
  pnpm wu:done --id WU-XXX
453
543
  \`\`\`
454
544
  `;
@@ -465,6 +555,7 @@ const FRAMEWORK_HINT_TEMPLATE = `# LumenFlow Framework Hint\n# Generated by: lum
465
555
  // Template for docs/04-operations/_frameworks/<framework>/README.md
466
556
  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`;
467
557
  // WU-1083: Agent onboarding docs templates
558
+ // WU-1309: Updated quick-ref with --docs-structure and complete wu:create example
468
559
  const QUICK_REF_COMMANDS_TEMPLATE = `# Quick Reference: LumenFlow Commands
469
560
 
470
561
  **Last updated:** {{DATE}}
@@ -473,24 +564,57 @@ const QUICK_REF_COMMANDS_TEMPLATE = `# Quick Reference: LumenFlow Commands
473
564
 
474
565
  ## Project Setup
475
566
 
476
- | Command | Description |
477
- | --------------------------------------------- | --------------------------------------- |
478
- | \`pnpm exec lumenflow init\` | Scaffold minimal LumenFlow core |
479
- | \`pnpm exec lumenflow init --full\` | Add docs/04-operations task scaffolding |
480
- | \`pnpm exec lumenflow init --framework <name>\` | Add framework hint + overlay docs |
481
- | \`pnpm exec lumenflow init --force\` | Overwrite existing files |
567
+ | Command | Description |
568
+ | ---------------------------------------------------- | ----------------------------------------- |
569
+ | \`pnpm exec lumenflow init\` | Scaffold minimal LumenFlow core |
570
+ | \`pnpm exec lumenflow init --full\` | Add docs + agent onboarding scaffolding |
571
+ | \`pnpm exec lumenflow init --docs-structure simple\` | Use simple docs structure (docs/tasks) |
572
+ | \`pnpm exec lumenflow init --docs-structure arc42\` | Use arc42 structure (docs/04-operations) |
573
+ | \`pnpm exec lumenflow init --framework <name>\` | Add framework hint + overlay docs |
574
+ | \`pnpm exec lumenflow init --client <type>\` | Add client overlay (claude, cursor, etc.) |
575
+ | \`pnpm exec lumenflow init --force\` | Overwrite existing files |
482
576
 
483
577
  ---
484
578
 
485
579
  ## WU Management
486
580
 
487
- | Command | Description |
488
- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
489
- | \`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 |
490
- | \`pnpm wu:claim --id WU-XXX --lane <Lane>\` | Claim WU (creates worktree) |
491
- | \`pnpm wu:done --id WU-XXX\` | Complete WU (merge, stamp, cleanup) |
492
- | \`pnpm wu:block --id WU-XXX --reason "Reason"\` | Block a WU |
493
- | \`pnpm wu:unblock --id WU-XXX\` | Unblock a WU |
581
+ | Command | Description |
582
+ | ----------------------------------------- | ------------------------------- |
583
+ | \`pnpm wu:create ...\` (see example below) | Create new WU |
584
+ | \`pnpm wu:claim --id WU-XXX --lane <Lane>\`| Claim WU (creates worktree) |
585
+ | \`pnpm wu:done --id WU-XXX\` | Complete WU (merge, stamp) |
586
+ | \`pnpm wu:block --id WU-XXX --reason "..."\`| Block a WU |
587
+ | \`pnpm wu:unblock --id WU-XXX\` | Unblock a WU |
588
+ | \`pnpm wu:status --id WU-XXX\` | Check WU status and location |
589
+
590
+ ---
591
+
592
+ ## Complete wu:create Example
593
+
594
+ \`\`\`bash
595
+ pnpm wu:create \\
596
+ --id WU-001 \\
597
+ --lane "Framework: Core" \\
598
+ --title "Add validation feature" \\
599
+ --description "Context: Users need input validation. Problem: No validation exists. Solution: Add Zod-based validation." \\
600
+ --acceptance "Validation rejects invalid input" \\
601
+ --acceptance "Unit tests cover edge cases with >90% coverage" \\
602
+ --acceptance "Documentation updated" \\
603
+ --code-paths "packages/@lumenflow/core/src/validation.ts" \\
604
+ --test-paths-unit "packages/@lumenflow/core/src/__tests__/validation.test.ts" \\
605
+ --exposure backend-only \\
606
+ --spec-refs "lumenflow://plans/WU-001-plan.md"
607
+ \`\`\`
608
+
609
+ **Required fields for code WUs:**
610
+ - \`--lane\`: Format is "Parent: Sublane" (e.g., "Framework: Core")
611
+ - \`--title\`: Short descriptive title
612
+ - \`--description\`: Context, Problem, Solution
613
+ - \`--acceptance\`: At least one (repeatable)
614
+ - \`--code-paths\`: Files to modify (repeatable)
615
+ - \`--test-paths-unit\` or \`--test-paths-e2e\`: Test files
616
+ - \`--exposure\`: ui | api | backend-only | documentation
617
+ - \`--spec-refs\`: Required for type: feature
494
618
 
495
619
  ---
496
620
 
@@ -525,7 +649,7 @@ const QUICK_REF_COMMANDS_TEMPLATE = `# Quick Reference: LumenFlow Commands
525
649
  cd worktrees/<lane>-wu-xxx
526
650
 
527
651
  # Return to main for wu:done
528
- cd /path/to/main
652
+ cd <project-root>
529
653
  \`\`\`
530
654
 
531
655
  ---
@@ -533,13 +657,14 @@ cd /path/to/main
533
657
  ## Workflow Sequence
534
658
 
535
659
  \`\`\`bash
536
- # 1. Create
660
+ # 1. Create (see complete example above)
537
661
  pnpm wu:create --id WU-001 --lane "Framework: Core" --title "Add feature" \\
538
- --description "Context: ...\\nProblem: ...\\nSolution: ..." \\
539
- --acceptance "Criterion 1" --acceptance "Criterion 2" \\
540
- --code-paths "src/example.ts" \\
541
- --test-paths-unit "src/__tests__/example.test.ts" \\
542
- --exposure backend-only
662
+ --description "Context: ... Problem: ... Solution: ..." \\
663
+ --acceptance "Feature works" --acceptance "Tests pass" \\
664
+ --code-paths "src/feature.ts" \\
665
+ --test-paths-unit "src/__tests__/feature.test.ts" \\
666
+ --exposure backend-only \\
667
+ --spec-refs "lumenflow://plans/WU-001-plan.md"
543
668
 
544
669
  # 2. Claim
545
670
  pnpm wu:claim --id WU-001 --lane "Framework: Core"
@@ -556,8 +681,8 @@ git push origin lane/framework-core/wu-001
556
681
  # 5. Gates
557
682
  pnpm gates
558
683
 
559
- # 6. Complete
560
- cd /path/to/main
684
+ # 6. Complete (from main checkout)
685
+ cd <project-root>
561
686
  pnpm wu:done --id WU-001
562
687
  \`\`\`
563
688
 
@@ -565,12 +690,12 @@ pnpm wu:done --id WU-001
565
690
 
566
691
  ## File Paths
567
692
 
568
- | Path | Description |
569
- | ----------------------------------------- | -------------------- |
570
- | \`docs/04-operations/tasks/wu/WU-XXX.yaml\` | WU specification |
571
- | \`docs/04-operations/tasks/status.md\` | Current status board |
572
- | \`.lumenflow/stamps/WU-XXX.done\` | Completion stamp |
573
- | \`worktrees/<lane>-wu-xxx/\` | Worktree directory |
693
+ | Path | Description |
694
+ | ------------------------------------ | -------------------- |
695
+ | \`{{DOCS_TASKS_PATH}}/wu/WU-XXX.yaml\` | WU specification |
696
+ | \`{{DOCS_TASKS_PATH}}/status.md\` | Current status board |
697
+ | \`.lumenflow/stamps/WU-XXX.done\` | Completion stamp |
698
+ | \`worktrees/<lane>-wu-xxx/\` | Worktree directory |
574
699
  `;
575
700
  const FIRST_WU_MISTAKES_TEMPLATE = `# First WU Mistakes
576
701
 
@@ -920,6 +1045,175 @@ Choose the safer path:
920
1045
  - Don't skip gates
921
1046
  - Ask rather than assume
922
1047
  `;
1048
+ // WU-1307: Lane inference configuration template (hierarchical Parent→Sublane format)
1049
+ // This format is required by lane-inference.ts and lane-checker.ts
1050
+ const LANE_INFERENCE_TEMPLATE = `# Lane Inference Configuration
1051
+ # Generated by: lumenflow init
1052
+ #
1053
+ # Hierarchical format: Parent -> Sublane -> { code_paths, keywords }
1054
+ # This format is required by lane-inference.ts for proper sub-lane suggestion.
1055
+
1056
+ # Framework Lane: Core packages and libraries
1057
+ Framework:
1058
+ Core:
1059
+ description: 'Core library: business logic, domain models, utilities'
1060
+ code_paths:
1061
+ - 'packages/**/core/**'
1062
+ - 'src/core/**'
1063
+ - 'lib/**'
1064
+ keywords:
1065
+ - 'core library'
1066
+ - 'business logic'
1067
+ - 'domain'
1068
+ - 'utility'
1069
+
1070
+ CLI:
1071
+ description: 'CLI commands and tooling'
1072
+ code_paths:
1073
+ - 'packages/**/cli/**'
1074
+ - 'src/cli/**'
1075
+ - 'bin/**'
1076
+ keywords:
1077
+ - 'cli command'
1078
+ - 'command line'
1079
+ - 'tooling'
1080
+
1081
+ # Experience Lane: User-facing frontend work
1082
+ Experience:
1083
+ UI:
1084
+ description: 'User interface components and pages'
1085
+ code_paths:
1086
+ - 'apps/web/**'
1087
+ - 'src/components/**'
1088
+ - 'src/pages/**'
1089
+ - 'src/app/**'
1090
+ keywords:
1091
+ - 'ui'
1092
+ - 'component'
1093
+ - 'page'
1094
+ - 'frontend'
1095
+ - 'user interface'
1096
+
1097
+ Web:
1098
+ description: 'Web application features'
1099
+ code_paths:
1100
+ - 'apps/web/**'
1101
+ - 'web/**'
1102
+ keywords:
1103
+ - 'web'
1104
+ - 'browser'
1105
+ - 'frontend'
1106
+
1107
+ # Operations Lane: Infrastructure and CI/CD
1108
+ Operations:
1109
+ Infrastructure:
1110
+ description: 'Apps, deployment, hosting configuration'
1111
+ code_paths:
1112
+ - 'apps/**'
1113
+ - 'infrastructure/**'
1114
+ - 'deploy/**'
1115
+ - 'turbo.json'
1116
+ - 'pnpm-workspace.yaml'
1117
+ keywords:
1118
+ - 'infrastructure'
1119
+ - 'deployment'
1120
+ - 'hosting'
1121
+ - 'monorepo'
1122
+
1123
+ CI/CD:
1124
+ description: 'GitHub Actions, workflows, build pipelines'
1125
+ code_paths:
1126
+ - '.github/workflows/**'
1127
+ - '.github/actions/**'
1128
+ - '.github/**'
1129
+ - '.circleci/**'
1130
+ keywords:
1131
+ - 'ci'
1132
+ - 'cd'
1133
+ - 'github actions'
1134
+ - 'workflow'
1135
+ - 'pipeline'
1136
+
1137
+ # Content Lane: Documentation
1138
+ Content:
1139
+ Documentation:
1140
+ description: 'All documentation: guides, references, specs'
1141
+ code_paths:
1142
+ - 'docs/**'
1143
+ - '*.md'
1144
+ - 'README.md'
1145
+ keywords:
1146
+ - 'documentation'
1147
+ - 'docs'
1148
+ - 'guide'
1149
+ - 'readme'
1150
+ - 'markdown'
1151
+ {{FRAMEWORK_LANES}}
1152
+ `;
1153
+ // WU-1300: Starting prompt template for agent onboarding
1154
+ const STARTING_PROMPT_TEMPLATE = `# Starting Prompt for LumenFlow Agents
1155
+
1156
+ **Last updated:** {{DATE}}
1157
+
1158
+ This document provides the initial context for AI agents working on this project.
1159
+
1160
+ ---
1161
+
1162
+ ## Step 1: Read Core Documentation
1163
+
1164
+ Before starting any work, read these documents in order:
1165
+
1166
+ 1. **[LUMENFLOW.md](../../../../../../LUMENFLOW.md)** - Main workflow documentation
1167
+ 2. **[constraints.md](../../../../../../.lumenflow/constraints.md)** - Non-negotiable rules
1168
+ 3. **This file** - Onboarding context
1169
+
1170
+ ---
1171
+
1172
+ ## Step 2: Understand the Workflow
1173
+
1174
+ LumenFlow uses Work Units (WUs) to track all changes:
1175
+
1176
+ 1. **Claim a WU**: \`pnpm wu:claim --id WU-XXX --lane <Lane>\`
1177
+ 2. **Work in worktree**: \`cd worktrees/<lane>-wu-xxx\`
1178
+ 3. **Run gates**: \`pnpm gates\`
1179
+ 4. **Complete WU**: \`pnpm wu:done --id WU-XXX\` (from main checkout)
1180
+
1181
+ ---
1182
+
1183
+ ## Step 3: Key Constraints
1184
+
1185
+ 1. **Worktree Discipline**: Never work in main after claiming a WU
1186
+ 2. **TDD**: Write tests first, then implementation
1187
+ 3. **Gates**: Must pass before \`wu:done\`
1188
+ 4. **Always wu:done**: Never skip the completion step
1189
+
1190
+ ---
1191
+
1192
+ ## Step 4: Common Commands
1193
+
1194
+ | Command | Description |
1195
+ | ------- | ----------- |
1196
+ | \`pnpm wu:claim --id WU-XXX --lane <Lane>\` | Claim a WU |
1197
+ | \`pnpm gates\` | Run quality gates |
1198
+ | \`pnpm wu:done --id WU-XXX\` | Complete WU |
1199
+ | \`pnpm wu:status --id WU-XXX\` | Check WU status |
1200
+
1201
+ ---
1202
+
1203
+ ## Step 5: When Stuck
1204
+
1205
+ 1. Read the WU spec at \`docs/04-operations/tasks/wu/WU-XXX.yaml\`
1206
+ 2. Check [troubleshooting-wu-done.md](troubleshooting-wu-done.md)
1207
+ 3. Review [first-wu-mistakes.md](first-wu-mistakes.md)
1208
+
1209
+ ---
1210
+
1211
+ ## Additional Resources
1212
+
1213
+ - [quick-ref-commands.md](quick-ref-commands.md) - Complete command reference
1214
+ - [agent-safety-card.md](agent-safety-card.md) - Safety guidelines
1215
+ - [wu-create-checklist.md](wu-create-checklist.md) - WU creation guide
1216
+ `;
923
1217
  const WU_CREATE_CHECKLIST_TEMPLATE = `# WU Creation Checklist
924
1218
 
925
1219
  **Last updated:** {{DATE}}
@@ -1033,6 +1327,280 @@ pnpm wu:create \\
1033
1327
  2. Claim the WU: \`pnpm wu:claim --id WU-XXX --lane "Lane"\`
1034
1328
  3. cd to worktree: \`cd worktrees/<lane>-wu-xxx\`
1035
1329
  `;
1330
+ // WU-1309: First 15 Minutes template
1331
+ const FIRST_15_MINS_TEMPLATE = `# First 15 Minutes with LumenFlow
1332
+
1333
+ **Last updated:** {{DATE}}
1334
+
1335
+ A quick-start guide for your first session with LumenFlow.
1336
+
1337
+ ---
1338
+
1339
+ ## Minute 0-2: Verify Setup
1340
+
1341
+ \`\`\`bash
1342
+ # Check LumenFlow is configured
1343
+ ls LUMENFLOW.md AGENTS.md .lumenflow.config.yaml
1344
+
1345
+ # Run doctor to verify safety components
1346
+ pnpm exec lumenflow doctor
1347
+ \`\`\`
1348
+
1349
+ ---
1350
+
1351
+ ## Minute 2-5: Read Essential Docs
1352
+
1353
+ 1. Open **LUMENFLOW.md** - Main workflow guide
1354
+ 2. Scan **AGENTS.md** - Quick reference for commands
1355
+ 3. Review **.lumenflow/constraints.md** - The 6 rules you must follow
1356
+
1357
+ ---
1358
+
1359
+ ## Minute 5-8: Find a WU to Work On
1360
+
1361
+ \`\`\`bash
1362
+ # Check status board
1363
+ cat docs/04-operations/tasks/status.md
1364
+
1365
+ # List ready WUs
1366
+ ls docs/04-operations/tasks/wu/*.yaml | head -5
1367
+ \`\`\`
1368
+
1369
+ ---
1370
+
1371
+ ## Minute 8-12: Claim and Start
1372
+
1373
+ \`\`\`bash
1374
+ # Claim a WU
1375
+ pnpm wu:claim --id WU-XXX --lane "Framework: Core"
1376
+
1377
+ # IMPORTANT: cd to worktree immediately
1378
+ cd worktrees/framework-core-wu-xxx
1379
+
1380
+ # Verify you're in the right place
1381
+ pwd # Should end with worktrees/...
1382
+ \`\`\`
1383
+
1384
+ ---
1385
+
1386
+ ## Minute 12-15: Begin TDD Cycle
1387
+
1388
+ \`\`\`bash
1389
+ # 1. Write a failing test
1390
+ # 2. Run it to confirm RED
1391
+ pnpm test -- --run
1392
+
1393
+ # 3. Write minimal code to pass
1394
+ # 4. Run test again for GREEN
1395
+ pnpm test -- --run
1396
+
1397
+ # 5. Run gates to check everything
1398
+ pnpm gates
1399
+ \`\`\`
1400
+
1401
+ ---
1402
+
1403
+ ## Key Reminders
1404
+
1405
+ - **Stay in the worktree** after claiming
1406
+ - **TDD**: Test first, then code
1407
+ - **Gates before done**: Always run \`pnpm gates\`
1408
+ - **Always wu:done**: Never forget to complete
1409
+
1410
+ ---
1411
+
1412
+ ## When Done
1413
+
1414
+ \`\`\`bash
1415
+ # From worktree: run gates
1416
+ pnpm gates
1417
+
1418
+ # From main: complete WU
1419
+ cd <project-root>
1420
+ pnpm wu:done --id WU-XXX
1421
+ \`\`\`
1422
+ `;
1423
+ // WU-1309: Local-only / no remote template
1424
+ const LOCAL_ONLY_TEMPLATE = `# Local-Only Development
1425
+
1426
+ **Last updated:** {{DATE}}
1427
+
1428
+ Configure LumenFlow for local development without a remote repository.
1429
+
1430
+ ---
1431
+
1432
+ ## When to Use
1433
+
1434
+ - Air-gapped environments
1435
+ - Testing/evaluation
1436
+ - Pre-remote development (haven't pushed to GitHub yet)
1437
+ - Offline development
1438
+
1439
+ ---
1440
+
1441
+ ## Configuration
1442
+
1443
+ Add this to \`.lumenflow.config.yaml\`:
1444
+
1445
+ \`\`\`yaml
1446
+ git:
1447
+ requireRemote: false
1448
+ \`\`\`
1449
+
1450
+ ---
1451
+
1452
+ ## Behavior Changes
1453
+
1454
+ When \`requireRemote: false\`:
1455
+
1456
+ | Command | Default Behavior | Local-Only Behavior |
1457
+ |---------|------------------|---------------------|
1458
+ | \`wu:create\` | Fetches origin/main | Skips remote fetch |
1459
+ | \`wu:claim\` | Pushes lane branch | Creates local branch only |
1460
+ | \`wu:done\` | Pushes to origin | Commits to local main |
1461
+
1462
+ ---
1463
+
1464
+ ## Warnings
1465
+
1466
+ With local-only mode:
1467
+
1468
+ 1. **No remote visibility** - Team members can't see your WUs
1469
+ 2. **No backup** - Work is only on your machine
1470
+ 3. **Manual sync required** - When adding a remote later
1471
+
1472
+ ---
1473
+
1474
+ ## Transitioning to Remote
1475
+
1476
+ When you add an origin remote:
1477
+
1478
+ 1. Update config: \`git.requireRemote: true\` or remove the setting
1479
+ 2. Push your main branch: \`git push -u origin main\`
1480
+ 3. Resume normal workflow
1481
+
1482
+ ---
1483
+
1484
+ ## Troubleshooting
1485
+
1486
+ ### "No origin remote configured"
1487
+
1488
+ **Cause:** \`requireRemote: true\` (default) but no origin exists.
1489
+
1490
+ **Fix:** Add remote or set \`requireRemote: false\`:
1491
+
1492
+ \`\`\`bash
1493
+ # Option 1: Add remote
1494
+ git remote add origin <url>
1495
+
1496
+ # Option 2: Enable local-only mode
1497
+ echo "git:\\n requireRemote: false" >> .lumenflow.config.yaml
1498
+ \`\`\`
1499
+ `;
1500
+ // WU-1309: Lane Inference template
1501
+ const LANE_INFERENCE_DOC_TEMPLATE = `# Lane Inference
1502
+
1503
+ **Last updated:** {{DATE}}
1504
+
1505
+ How LumenFlow determines which lane a WU belongs to.
1506
+
1507
+ ---
1508
+
1509
+ ## Lane Format
1510
+
1511
+ LumenFlow uses hierarchical lanes: \`"Parent: Sublane"\`
1512
+
1513
+ Examples:
1514
+ - \`"Framework: Core"\`
1515
+ - \`"Framework: CLI"\`
1516
+ - \`"Experience: UI"\`
1517
+ - \`"Operations: CI/CD"\`
1518
+ - \`"Content: Documentation"\`
1519
+
1520
+ ---
1521
+
1522
+ ## Lane Taxonomy File
1523
+
1524
+ Lanes are defined in \`.lumenflow.lane-inference.yaml\`:
1525
+
1526
+ \`\`\`yaml
1527
+ Framework:
1528
+ Core:
1529
+ description: 'Core library'
1530
+ code_paths:
1531
+ - 'packages/**/core/**'
1532
+ keywords:
1533
+ - 'core'
1534
+ - 'library'
1535
+
1536
+ CLI:
1537
+ description: 'CLI commands'
1538
+ code_paths:
1539
+ - 'packages/**/cli/**'
1540
+ - 'bin/**'
1541
+ keywords:
1542
+ - 'cli'
1543
+ - 'command'
1544
+ \`\`\`
1545
+
1546
+ ---
1547
+
1548
+ ## Auto-Inference
1549
+
1550
+ Use \`wu:infer-lane\` to suggest a lane based on code paths:
1551
+
1552
+ \`\`\`bash
1553
+ # Infer from WU code_paths
1554
+ pnpm wu:infer-lane --id WU-XXX
1555
+
1556
+ # Infer from manual inputs
1557
+ pnpm wu:infer-lane --paths "packages/@lumenflow/cli/**" --desc "Add CLI command"
1558
+ \`\`\`
1559
+
1560
+ ---
1561
+
1562
+ ## Generating Lane Taxonomy
1563
+
1564
+ If no taxonomy exists, generate one:
1565
+
1566
+ \`\`\`bash
1567
+ pnpm lane:suggest --output .lumenflow.lane-inference.yaml
1568
+ \`\`\`
1569
+
1570
+ ---
1571
+
1572
+ ## Common Issues
1573
+
1574
+ ### "Lane format invalid"
1575
+
1576
+ **Cause:** Missing colon or space.
1577
+
1578
+ **Fix:** Use \`"Parent: Sublane"\` format (colon + space).
1579
+
1580
+ ### "Sub-lane validation failed"
1581
+
1582
+ **Cause:** No \`.lumenflow.lane-inference.yaml\` file.
1583
+
1584
+ **Fix:** Create the file or generate it:
1585
+
1586
+ \`\`\`bash
1587
+ pnpm lane:suggest --output .lumenflow.lane-inference.yaml
1588
+ \`\`\`
1589
+
1590
+ ---
1591
+
1592
+ ## Lane Health
1593
+
1594
+ Check lane configuration for issues:
1595
+
1596
+ \`\`\`bash
1597
+ pnpm lane:health
1598
+ \`\`\`
1599
+
1600
+ This detects:
1601
+ - Overlapping code paths between lanes
1602
+ - Code files not covered by any lane
1603
+ `;
1036
1604
  // WU-1083: Claude skills templates
1037
1605
  const WU_LIFECYCLE_SKILL_TEMPLATE = `---
1038
1606
  name: wu-lifecycle
@@ -1311,9 +1879,16 @@ export async function scaffoldProject(targetDir, options) {
1311
1879
  if (!fs.existsSync(targetDir)) {
1312
1880
  fs.mkdirSync(targetDir, { recursive: true });
1313
1881
  }
1882
+ // WU-1309: Detect or use specified docs structure
1883
+ const docsStructure = options.docsStructure ?? detectDocsStructure(targetDir);
1884
+ const docsPaths = getDocsPath(docsStructure);
1314
1885
  const tokenDefaults = {
1315
1886
  DATE: getCurrentDate(),
1316
- PROJECT_ROOT: targetDir,
1887
+ PROJECT_ROOT: '<project-root>', // WU-1309: Use portable placeholder
1888
+ QUICK_REF_LINK: docsPaths.quickRefLink,
1889
+ DOCS_OPERATIONS_PATH: docsPaths.operations, // WU-1309: For framework overlay
1890
+ DOCS_TASKS_PATH: docsPaths.tasks,
1891
+ DOCS_ONBOARDING_PATH: docsPaths.onboarding,
1317
1892
  };
1318
1893
  // Create .lumenflow.config.yaml (WU-1067: includes gate preset if specified)
1319
1894
  // Note: Config files don't use merge mode (always skip or force)
@@ -1344,10 +1919,73 @@ export async function scaffoldProject(targetDir, options) {
1344
1919
  }
1345
1920
  // Scaffold client-specific files (WU-1171: renamed from vendor)
1346
1921
  await scaffoldClientFiles(targetDir, options, result, tokenDefaults, client);
1922
+ // WU-1300: Inject LumenFlow scripts into package.json
1923
+ if (options.full) {
1924
+ await injectPackageJsonScripts(targetDir, options, result);
1925
+ }
1347
1926
  return result;
1348
1927
  }
1928
+ /**
1929
+ * WU-1307: LumenFlow scripts to inject into package.json
1930
+ * Uses standalone binaries (wu-claim, wu-done, gates) that work in consumer projects
1931
+ * after installing @lumenflow/cli.
1932
+ */
1933
+ const LUMENFLOW_SCRIPTS = {
1934
+ 'wu:claim': 'wu-claim',
1935
+ 'wu:done': 'wu-done',
1936
+ 'wu:create': 'wu-create',
1937
+ 'wu:status': 'wu-status',
1938
+ 'wu:block': 'wu-block',
1939
+ 'wu:unblock': 'wu-unblock',
1940
+ gates: 'gates',
1941
+ 'gates:docs': 'gates --docs-only',
1942
+ };
1943
+ /**
1944
+ * WU-1300: Inject LumenFlow scripts into package.json
1945
+ * - Creates package.json if it doesn't exist
1946
+ * - Preserves existing scripts (doesn't overwrite unless --force)
1947
+ * - Adds missing LumenFlow scripts
1948
+ */
1949
+ async function injectPackageJsonScripts(targetDir, options, result) {
1950
+ const packageJsonPath = path.join(targetDir, 'package.json');
1951
+ let packageJson;
1952
+ if (fs.existsSync(packageJsonPath)) {
1953
+ // Read existing package.json
1954
+ const content = fs.readFileSync(packageJsonPath, 'utf-8');
1955
+ packageJson = JSON.parse(content);
1956
+ }
1957
+ else {
1958
+ // Create minimal package.json
1959
+ packageJson = {
1960
+ name: path.basename(targetDir),
1961
+ version: '0.0.1',
1962
+ private: true,
1963
+ };
1964
+ }
1965
+ // Ensure scripts object exists
1966
+ if (!packageJson.scripts || typeof packageJson.scripts !== 'object') {
1967
+ packageJson.scripts = {};
1968
+ }
1969
+ const scripts = packageJson.scripts;
1970
+ let modified = false;
1971
+ // Add LumenFlow scripts (only if not already present, unless --force)
1972
+ for (const [scriptName, scriptCommand] of Object.entries(LUMENFLOW_SCRIPTS)) {
1973
+ if (options.force || !(scriptName in scripts)) {
1974
+ if (!(scriptName in scripts)) {
1975
+ scripts[scriptName] = scriptCommand;
1976
+ modified = true;
1977
+ }
1978
+ }
1979
+ }
1980
+ if (modified) {
1981
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
1982
+ result.created.push('package.json (scripts updated)');
1983
+ }
1984
+ }
1349
1985
  async function scaffoldFullDocs(targetDir, options, result, tokens) {
1350
- const tasksDir = path.join(targetDir, 'docs', DOCS_OPERATIONS_DIR, 'tasks');
1986
+ // WU-1309: Use docs structure from tokens (computed in scaffoldProject)
1987
+ const tasksPath = tokens.DOCS_TASKS_PATH;
1988
+ const tasksDir = path.join(targetDir, tasksPath);
1351
1989
  const wuDir = path.join(tasksDir, 'wu');
1352
1990
  const templatesDir = path.join(tasksDir, 'templates');
1353
1991
  await createDirectory(wuDir, result, targetDir);
@@ -1356,15 +1994,56 @@ async function scaffoldFullDocs(targetDir, options, result, tokens) {
1356
1994
  await createFile(path.join(tasksDir, 'backlog.md'), BACKLOG_TEMPLATE, options.force, result, targetDir);
1357
1995
  await createFile(path.join(tasksDir, 'status.md'), STATUS_TEMPLATE, options.force, result, targetDir);
1358
1996
  await createFile(path.join(templatesDir, 'wu-template.yaml'), processTemplate(WU_TEMPLATE_YAML, tokens), options.force, result, targetDir);
1997
+ // WU-1300: Scaffold lane inference configuration
1998
+ await scaffoldLaneInference(targetDir, options, result, tokens);
1359
1999
  // WU-1083: Scaffold agent onboarding docs with --full
1360
2000
  await scaffoldAgentOnboardingDocs(targetDir, options, result, tokens);
1361
2001
  }
2002
+ /**
2003
+ * WU-1307: Scaffold lane inference configuration
2004
+ * Uses hierarchical Parent→Sublane format required by lane-inference.ts
2005
+ */
2006
+ async function scaffoldLaneInference(targetDir, options, result, tokens) {
2007
+ // WU-1307: Add framework-specific lanes in hierarchical format if framework is provided
2008
+ let frameworkLanes = '';
2009
+ if (options.framework) {
2010
+ const { name, slug } = normalizeFrameworkName(options.framework);
2011
+ // Add framework lanes in hierarchical format (indentation matters in YAML)
2012
+ frameworkLanes = `
2013
+ # Framework-specific lanes (added with --framework ${name})
2014
+ ${name}:
2015
+ description: '${name} framework-specific code'
2016
+ code_paths:
2017
+ - 'src/${slug}/**'
2018
+ - 'packages/${slug}/**'
2019
+ keywords:
2020
+ - '${slug}'
2021
+ - '${name.toLowerCase()}'
2022
+ `;
2023
+ }
2024
+ const laneInferenceContent = processTemplate(LANE_INFERENCE_TEMPLATE, {
2025
+ ...tokens,
2026
+ FRAMEWORK_LANES: frameworkLanes,
2027
+ });
2028
+ await createFile(path.join(targetDir, '.lumenflow.lane-inference.yaml'), laneInferenceContent, options.force ? 'force' : 'skip', result, targetDir);
2029
+ }
1362
2030
  /**
1363
2031
  * WU-1083: Scaffold agent onboarding documentation
2032
+ * WU-1300: Added starting-prompt.md
2033
+ * WU-1309: Added first-15-mins.md, local-only.md, lane-inference.md; use dynamic docs path
1364
2034
  */
1365
2035
  async function scaffoldAgentOnboardingDocs(targetDir, options, result, tokens) {
1366
- const onboardingDir = path.join(targetDir, 'docs', DOCS_OPERATIONS_DIR, '_frameworks', 'lumenflow', 'agent', 'onboarding');
2036
+ // WU-1309: Use dynamic onboarding path from tokens
2037
+ const onboardingDir = path.join(targetDir, tokens.DOCS_ONBOARDING_PATH);
1367
2038
  await createDirectory(onboardingDir, result, targetDir);
2039
+ // WU-1300: Add starting-prompt.md as first file
2040
+ await createFile(path.join(onboardingDir, 'starting-prompt.md'), processTemplate(STARTING_PROMPT_TEMPLATE, tokens), options.force, result, targetDir);
2041
+ // WU-1309: Add first-15-mins.md
2042
+ await createFile(path.join(onboardingDir, 'first-15-mins.md'), processTemplate(FIRST_15_MINS_TEMPLATE, tokens), options.force, result, targetDir);
2043
+ // WU-1309: Add local-only.md
2044
+ await createFile(path.join(onboardingDir, 'local-only.md'), processTemplate(LOCAL_ONLY_TEMPLATE, tokens), options.force, result, targetDir);
2045
+ // WU-1309: Add lane-inference.md
2046
+ await createFile(path.join(onboardingDir, 'lane-inference.md'), processTemplate(LANE_INFERENCE_DOC_TEMPLATE, tokens), options.force, result, targetDir);
1368
2047
  await createFile(path.join(onboardingDir, 'quick-ref-commands.md'), processTemplate(QUICK_REF_COMMANDS_TEMPLATE, tokens), options.force, result, targetDir);
1369
2048
  await createFile(path.join(onboardingDir, 'first-wu-mistakes.md'), processTemplate(FIRST_WU_MISTAKES_TEMPLATE, tokens), options.force, result, targetDir);
1370
2049
  await createFile(path.join(onboardingDir, 'troubleshooting-wu-done.md'), processTemplate(TROUBLESHOOTING_WU_DONE_TEMPLATE, tokens), options.force, result, targetDir);
@@ -1400,7 +2079,8 @@ async function scaffoldFrameworkOverlay(targetDir, options, result, tokens) {
1400
2079
  FRAMEWORK_SLUG: slug,
1401
2080
  };
1402
2081
  await createFile(path.join(targetDir, FRAMEWORK_HINT_FILE), processTemplate(FRAMEWORK_HINT_TEMPLATE, frameworkTokens), options.force, result, targetDir);
1403
- const overlayDir = path.join(targetDir, 'docs', DOCS_OPERATIONS_DIR, '_frameworks', slug);
2082
+ // WU-1309: Use dynamic operations path from tokens
2083
+ const overlayDir = path.join(targetDir, tokens.DOCS_OPERATIONS_PATH, '_frameworks', slug);
1404
2084
  await createDirectory(overlayDir, result, targetDir);
1405
2085
  await createFile(path.join(overlayDir, 'README.md'), processTemplate(FRAMEWORK_OVERLAY_TEMPLATE, frameworkTokens), options.force, result, targetDir);
1406
2086
  }