@lumenflow/cli 2.4.0 → 2.5.1

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 (147) hide show
  1. package/README.md +11 -8
  2. package/dist/__tests__/init-config-lanes.test.js +131 -0
  3. package/dist/__tests__/init-docs-structure.test.js +119 -0
  4. package/dist/__tests__/init-lane-inference.test.js +125 -0
  5. package/dist/__tests__/init-onboarding-docs.test.js +132 -0
  6. package/dist/__tests__/init-quick-ref.test.js +145 -0
  7. package/dist/__tests__/init-scripts.test.js +207 -0
  8. package/dist/__tests__/init-template-portability.test.js +97 -0
  9. package/dist/__tests__/init.test.js +7 -2
  10. package/dist/__tests__/initiative-add-wu.test.js +420 -0
  11. package/dist/__tests__/initiative-plan-replacement.test.js +162 -0
  12. package/dist/__tests__/initiative-remove-wu.test.js +458 -0
  13. package/dist/__tests__/onboarding-smoke-test.test.js +211 -0
  14. package/dist/__tests__/path-centralization-cli.test.js +234 -0
  15. package/dist/__tests__/plan-create.test.js +126 -0
  16. package/dist/__tests__/plan-edit.test.js +157 -0
  17. package/dist/__tests__/plan-link.test.js +239 -0
  18. package/dist/__tests__/plan-promote.test.js +181 -0
  19. package/dist/__tests__/templates-sync.test.js +219 -0
  20. package/dist/__tests__/wu-create-strict.test.js +118 -0
  21. package/dist/__tests__/wu-edit-strict.test.js +109 -0
  22. package/dist/__tests__/wu-validate-strict.test.js +113 -0
  23. package/dist/flow-bottlenecks.js +4 -2
  24. package/dist/gates.js +22 -0
  25. package/dist/init.js +670 -87
  26. package/dist/initiative-add-wu.js +112 -16
  27. package/dist/initiative-remove-wu.js +248 -0
  28. package/dist/onboarding-smoke-test.js +400 -0
  29. package/dist/orchestrate-init-status.js +37 -9
  30. package/dist/orchestrate-initiative.js +10 -4
  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/sync-templates.js +137 -5
  36. package/dist/wu-block.js +16 -5
  37. package/dist/wu-claim.js +15 -9
  38. package/dist/wu-create.js +50 -2
  39. package/dist/wu-deps.js +3 -1
  40. package/dist/wu-done.js +14 -5
  41. package/dist/wu-edit.js +35 -0
  42. package/dist/wu-prep.js +131 -8
  43. package/dist/wu-spawn.js +14 -1
  44. package/dist/wu-unblock.js +34 -2
  45. package/dist/wu-validate.js +25 -17
  46. package/package.json +11 -7
  47. package/templates/core/.lumenflow/constraints.md.template +61 -3
  48. package/templates/core/AGENTS.md.template +2 -2
  49. package/templates/core/LUMENFLOW.md.template +85 -23
  50. package/templates/core/ai/onboarding/agent-invocation-guide.md.template +157 -0
  51. package/templates/core/ai/onboarding/agent-safety-card.md.template +227 -0
  52. package/templates/core/ai/onboarding/docs-generation.md.template +277 -0
  53. package/templates/core/ai/onboarding/first-wu-mistakes.md.template +49 -7
  54. package/templates/core/ai/onboarding/quick-ref-commands.md.template +343 -110
  55. package/templates/core/ai/onboarding/release-process.md.template +8 -2
  56. package/templates/core/ai/onboarding/starting-prompt.md.template +407 -0
  57. package/templates/core/ai/onboarding/test-ratchet.md.template +131 -0
  58. package/templates/core/ai/onboarding/troubleshooting-wu-done.md.template +91 -38
  59. package/templates/core/ai/onboarding/vendor-support.md.template +219 -0
  60. package/templates/vendors/claude/.claude/skills/context-management/SKILL.md.template +13 -1
  61. package/templates/vendors/claude/.claude/skills/execution-memory/SKILL.md.template +14 -16
  62. package/templates/vendors/claude/.claude/skills/orchestration/SKILL.md.template +48 -4
  63. package/templates/vendors/claude/.claude/skills/worktree-discipline/SKILL.md.template +5 -1
  64. package/templates/vendors/claude/.claude/skills/wu-lifecycle/SKILL.md.template +19 -8
  65. package/dist/__tests__/init-plan.test.js +0 -340
  66. package/dist/agent-issues-query.d.ts +0 -16
  67. package/dist/agent-log-issue.d.ts +0 -10
  68. package/dist/agent-session-end.d.ts +0 -10
  69. package/dist/agent-session.d.ts +0 -10
  70. package/dist/backlog-prune.d.ts +0 -84
  71. package/dist/cli-entry-point.d.ts +0 -8
  72. package/dist/deps-add.d.ts +0 -91
  73. package/dist/deps-remove.d.ts +0 -17
  74. package/dist/docs-sync.d.ts +0 -50
  75. package/dist/file-delete.d.ts +0 -84
  76. package/dist/file-edit.d.ts +0 -82
  77. package/dist/file-read.d.ts +0 -92
  78. package/dist/file-write.d.ts +0 -90
  79. package/dist/flow-bottlenecks.d.ts +0 -16
  80. package/dist/flow-report.d.ts +0 -16
  81. package/dist/gates.d.ts +0 -94
  82. package/dist/git-branch.d.ts +0 -65
  83. package/dist/git-diff.d.ts +0 -58
  84. package/dist/git-log.d.ts +0 -69
  85. package/dist/git-status.d.ts +0 -58
  86. package/dist/guard-locked.d.ts +0 -62
  87. package/dist/guard-main-branch.d.ts +0 -50
  88. package/dist/guard-worktree-commit.d.ts +0 -59
  89. package/dist/index.d.ts +0 -10
  90. package/dist/init-plan.d.ts +0 -80
  91. package/dist/init-plan.js +0 -337
  92. package/dist/init.d.ts +0 -46
  93. package/dist/initiative-add-wu.d.ts +0 -22
  94. package/dist/initiative-bulk-assign-wus.d.ts +0 -16
  95. package/dist/initiative-create.d.ts +0 -28
  96. package/dist/initiative-edit.d.ts +0 -34
  97. package/dist/initiative-list.d.ts +0 -12
  98. package/dist/initiative-status.d.ts +0 -11
  99. package/dist/lumenflow-upgrade.d.ts +0 -103
  100. package/dist/mem-checkpoint.d.ts +0 -16
  101. package/dist/mem-cleanup.d.ts +0 -29
  102. package/dist/mem-create.d.ts +0 -17
  103. package/dist/mem-export.d.ts +0 -10
  104. package/dist/mem-inbox.d.ts +0 -35
  105. package/dist/mem-init.d.ts +0 -15
  106. package/dist/mem-ready.d.ts +0 -16
  107. package/dist/mem-signal.d.ts +0 -16
  108. package/dist/mem-start.d.ts +0 -16
  109. package/dist/mem-summarize.d.ts +0 -22
  110. package/dist/mem-triage.d.ts +0 -22
  111. package/dist/metrics-cli.d.ts +0 -90
  112. package/dist/metrics-snapshot.d.ts +0 -18
  113. package/dist/orchestrate-init-status.d.ts +0 -11
  114. package/dist/orchestrate-initiative.d.ts +0 -12
  115. package/dist/orchestrate-monitor.d.ts +0 -11
  116. package/dist/release.d.ts +0 -117
  117. package/dist/rotate-progress.d.ts +0 -48
  118. package/dist/session-coordinator.d.ts +0 -74
  119. package/dist/spawn-list.d.ts +0 -16
  120. package/dist/state-bootstrap.d.ts +0 -92
  121. package/dist/sync-templates.d.ts +0 -52
  122. package/dist/trace-gen.d.ts +0 -84
  123. package/dist/validate-agent-skills.d.ts +0 -50
  124. package/dist/validate-agent-sync.d.ts +0 -36
  125. package/dist/validate-backlog-sync.d.ts +0 -37
  126. package/dist/validate-skills-spec.d.ts +0 -40
  127. package/dist/validate.d.ts +0 -60
  128. package/dist/wu-block.d.ts +0 -16
  129. package/dist/wu-claim.d.ts +0 -74
  130. package/dist/wu-cleanup.d.ts +0 -35
  131. package/dist/wu-create.d.ts +0 -69
  132. package/dist/wu-delete.d.ts +0 -21
  133. package/dist/wu-deps.d.ts +0 -13
  134. package/dist/wu-done.d.ts +0 -225
  135. package/dist/wu-edit.d.ts +0 -63
  136. package/dist/wu-infer-lane.d.ts +0 -17
  137. package/dist/wu-preflight.d.ts +0 -47
  138. package/dist/wu-prune.d.ts +0 -16
  139. package/dist/wu-recover.d.ts +0 -37
  140. package/dist/wu-release.d.ts +0 -19
  141. package/dist/wu-repair.d.ts +0 -60
  142. package/dist/wu-spawn-completion.d.ts +0 -10
  143. package/dist/wu-spawn.d.ts +0 -192
  144. package/dist/wu-status.d.ts +0 -25
  145. package/dist/wu-unblock.d.ts +0 -16
  146. package/dist/wu-unlock-lane.d.ts +0 -19
  147. 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
  /**
@@ -255,6 +336,7 @@ function getRelativePath(targetDir, filePath) {
255
336
  }
256
337
  // WU-1171: Template for AGENTS.md (universal entry point)
257
338
  // WU-1300: Updated quick-ref link to correct path
339
+ // WU-1309: Use {{QUICK_REF_LINK}} and <project-root> placeholder for portability
258
340
  const AGENTS_MD_TEMPLATE = `# Universal Agent Instructions
259
341
 
260
342
  **Last updated:** {{DATE}}
@@ -274,11 +356,11 @@ cd worktrees/<lane>-wu-xxxx
274
356
  pnpm gates
275
357
 
276
358
  # 3. Complete (ALWAYS run this!)
277
- cd {{PROJECT_ROOT}}
359
+ cd <project-root>
278
360
  pnpm wu:done --id WU-XXXX
279
361
  \`\`\`
280
362
 
281
- > **Complete CLI reference:** See [quick-ref-commands.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/quick-ref-commands.md)
363
+ > **Complete CLI reference:** See [quick-ref-commands.md]({{QUICK_REF_LINK}})
282
364
 
283
365
  ---
284
366
 
@@ -317,11 +399,13 @@ This file provides universal guidance for all AI agents. Additional vendor-speci
317
399
  - **Windsurf**: See \`.windsurf/rules/lumenflow.md\` (if present)
318
400
  `;
319
401
  // Template for LUMENFLOW.md (main entry point)
320
- 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`;
321
404
  // Template for .lumenflow/constraints.md
322
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`;
323
406
  // Template for root CLAUDE.md
324
- 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`;
325
409
  // Template for .claude/settings.json
326
410
  const CLAUDE_SETTINGS_TEMPLATE = `{
327
411
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
@@ -354,6 +438,7 @@ const CLAUDE_SETTINGS_TEMPLATE = `{
354
438
  }
355
439
  `;
356
440
  // WU-1171: Template for .cursor/rules/lumenflow.md (updated path)
441
+ // WU-1309: Use <project-root> placeholder for portability
357
442
  const CURSOR_RULES_TEMPLATE = `# Cursor LumenFlow Rules
358
443
 
359
444
  This project uses LumenFlow workflow. See [LUMENFLOW.md](../../LUMENFLOW.md).
@@ -383,11 +468,12 @@ cd worktrees/<lane>-wu-xxx
383
468
  pnpm gates
384
469
 
385
470
  # Complete (from main)
386
- cd {{PROJECT_ROOT}}
471
+ cd <project-root>
387
472
  pnpm wu:done --id WU-XXX
388
473
  \`\`\`
389
474
  `;
390
475
  // WU-1171: Template for .windsurf/rules/lumenflow.md
476
+ // WU-1309: Use <project-root> placeholder for portability
391
477
  const WINDSURF_RULES_TEMPLATE = `# Windsurf LumenFlow Rules
392
478
 
393
479
  This project uses LumenFlow workflow. See [LUMENFLOW.md](../../LUMENFLOW.md).
@@ -417,11 +503,12 @@ cd worktrees/<lane>-wu-xxx
417
503
  pnpm gates
418
504
 
419
505
  # Complete (from main)
420
- cd {{PROJECT_ROOT}}
506
+ cd <project-root>
421
507
  pnpm wu:done --id WU-XXX
422
508
  \`\`\`
423
509
  `;
424
510
  // WU-1177: Template for .clinerules (Cline AI assistant)
511
+ // WU-1309: Use <project-root> placeholder for portability
425
512
  const CLINE_RULES_TEMPLATE = `# Cline LumenFlow Rules
426
513
 
427
514
  This project uses LumenFlow workflow. See [LUMENFLOW.md](LUMENFLOW.md).
@@ -451,7 +538,7 @@ cd worktrees/<lane>-wu-xxx
451
538
  pnpm gates
452
539
 
453
540
  # Complete (from main)
454
- cd {{PROJECT_ROOT}}
541
+ cd <project-root>
455
542
  pnpm wu:done --id WU-XXX
456
543
  \`\`\`
457
544
  `;
@@ -468,6 +555,7 @@ const FRAMEWORK_HINT_TEMPLATE = `# LumenFlow Framework Hint\n# Generated by: lum
468
555
  // Template for docs/04-operations/_frameworks/<framework>/README.md
469
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`;
470
557
  // WU-1083: Agent onboarding docs templates
558
+ // WU-1309: Updated quick-ref with --docs-structure and complete wu:create example
471
559
  const QUICK_REF_COMMANDS_TEMPLATE = `# Quick Reference: LumenFlow Commands
472
560
 
473
561
  **Last updated:** {{DATE}}
@@ -476,24 +564,57 @@ const QUICK_REF_COMMANDS_TEMPLATE = `# Quick Reference: LumenFlow Commands
476
564
 
477
565
  ## Project Setup
478
566
 
479
- | Command | Description |
480
- | --------------------------------------------- | --------------------------------------- |
481
- | \`pnpm exec lumenflow init\` | Scaffold minimal LumenFlow core |
482
- | \`pnpm exec lumenflow init --full\` | Add docs/04-operations task scaffolding |
483
- | \`pnpm exec lumenflow init --framework <name>\` | Add framework hint + overlay docs |
484
- | \`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 |
485
576
 
486
577
  ---
487
578
 
488
579
  ## WU Management
489
580
 
490
- | Command | Description |
491
- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
492
- | \`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 |
493
- | \`pnpm wu:claim --id WU-XXX --lane <Lane>\` | Claim WU (creates worktree) |
494
- | \`pnpm wu:done --id WU-XXX\` | Complete WU (merge, stamp, cleanup) |
495
- | \`pnpm wu:block --id WU-XXX --reason "Reason"\` | Block a WU |
496
- | \`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
497
618
 
498
619
  ---
499
620
 
@@ -528,7 +649,7 @@ const QUICK_REF_COMMANDS_TEMPLATE = `# Quick Reference: LumenFlow Commands
528
649
  cd worktrees/<lane>-wu-xxx
529
650
 
530
651
  # Return to main for wu:done
531
- cd /path/to/main
652
+ cd <project-root>
532
653
  \`\`\`
533
654
 
534
655
  ---
@@ -536,13 +657,14 @@ cd /path/to/main
536
657
  ## Workflow Sequence
537
658
 
538
659
  \`\`\`bash
539
- # 1. Create
660
+ # 1. Create (see complete example above)
540
661
  pnpm wu:create --id WU-001 --lane "Framework: Core" --title "Add feature" \\
541
- --description "Context: ...\\nProblem: ...\\nSolution: ..." \\
542
- --acceptance "Criterion 1" --acceptance "Criterion 2" \\
543
- --code-paths "src/example.ts" \\
544
- --test-paths-unit "src/__tests__/example.test.ts" \\
545
- --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"
546
668
 
547
669
  # 2. Claim
548
670
  pnpm wu:claim --id WU-001 --lane "Framework: Core"
@@ -559,8 +681,8 @@ git push origin lane/framework-core/wu-001
559
681
  # 5. Gates
560
682
  pnpm gates
561
683
 
562
- # 6. Complete
563
- cd /path/to/main
684
+ # 6. Complete (from main checkout)
685
+ cd <project-root>
564
686
  pnpm wu:done --id WU-001
565
687
  \`\`\`
566
688
 
@@ -568,12 +690,12 @@ pnpm wu:done --id WU-001
568
690
 
569
691
  ## File Paths
570
692
 
571
- | Path | Description |
572
- | ----------------------------------------- | -------------------- |
573
- | \`docs/04-operations/tasks/wu/WU-XXX.yaml\` | WU specification |
574
- | \`docs/04-operations/tasks/status.md\` | Current status board |
575
- | \`.lumenflow/stamps/WU-XXX.done\` | Completion stamp |
576
- | \`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 |
577
699
  `;
578
700
  const FIRST_WU_MISTAKES_TEMPLATE = `# First WU Mistakes
579
701
 
@@ -923,39 +1045,109 @@ Choose the safer path:
923
1045
  - Don't skip gates
924
1046
  - Ask rather than assume
925
1047
  `;
926
- // WU-1300: Lane inference configuration template
1048
+ // WU-1307: Lane inference configuration template (hierarchical Parent→Sublane format)
1049
+ // This format is required by lane-inference.ts and lane-checker.ts
927
1050
  const LANE_INFERENCE_TEMPLATE = `# Lane Inference Configuration
928
1051
  # Generated by: lumenflow init
929
- # Configure how lanes are inferred from file paths
930
-
931
- lanes:
932
- - name: "Framework: Core"
933
- patterns:
934
- - "packages/@lumenflow/core/**"
935
- - "src/core/**"
936
-
937
- - name: "Framework: CLI"
938
- patterns:
939
- - "packages/@lumenflow/cli/**"
940
- - "src/cli/**"
941
-
942
- - name: "Content: Documentation"
943
- patterns:
944
- - "docs/**"
945
- - "*.md"
946
-
947
- - name: "Operations: Infrastructure"
948
- patterns:
949
- - "apps/**"
950
- - "infrastructure/**"
951
- - ".github/**"
952
-
953
- - name: "Operations: CI/CD"
954
- patterns:
955
- - ".github/workflows/**"
956
- - ".circleci/**"
957
-
958
- # Framework-specific lanes (added with --framework)
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'
959
1151
  {{FRAMEWORK_LANES}}
960
1152
  `;
961
1153
  // WU-1300: Starting prompt template for agent onboarding
@@ -1135,6 +1327,280 @@ pnpm wu:create \\
1135
1327
  2. Claim the WU: \`pnpm wu:claim --id WU-XXX --lane "Lane"\`
1136
1328
  3. cd to worktree: \`cd worktrees/<lane>-wu-xxx\`
1137
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
+ `;
1138
1604
  // WU-1083: Claude skills templates
1139
1605
  const WU_LIFECYCLE_SKILL_TEMPLATE = `---
1140
1606
  name: wu-lifecycle
@@ -1413,9 +1879,16 @@ export async function scaffoldProject(targetDir, options) {
1413
1879
  if (!fs.existsSync(targetDir)) {
1414
1880
  fs.mkdirSync(targetDir, { recursive: true });
1415
1881
  }
1882
+ // WU-1309: Detect or use specified docs structure
1883
+ const docsStructure = options.docsStructure ?? detectDocsStructure(targetDir);
1884
+ const docsPaths = getDocsPath(docsStructure);
1416
1885
  const tokenDefaults = {
1417
1886
  DATE: getCurrentDate(),
1418
- 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,
1419
1892
  };
1420
1893
  // Create .lumenflow.config.yaml (WU-1067: includes gate preset if specified)
1421
1894
  // Note: Config files don't use merge mode (always skip or force)
@@ -1436,6 +1909,8 @@ export async function scaffoldProject(targetDir, options) {
1436
1909
  // Create .lumenflow/agents directory with .gitkeep
1437
1910
  await createDirectory(path.join(targetDir, LUMENFLOW_AGENTS_DIR), result, targetDir);
1438
1911
  await createFile(path.join(targetDir, LUMENFLOW_AGENTS_DIR, '.gitkeep'), '', options.force ? 'force' : 'skip', result, targetDir);
1912
+ // WU-1342: Create .gitignore with required exclusions
1913
+ await scaffoldGitignore(targetDir, options, result);
1439
1914
  // Optional: full docs scaffolding
1440
1915
  if (options.full) {
1441
1916
  await scaffoldFullDocs(targetDir, options, result, tokenDefaults);
@@ -1453,17 +1928,107 @@ export async function scaffoldProject(targetDir, options) {
1453
1928
  return result;
1454
1929
  }
1455
1930
  /**
1456
- * WU-1300: LumenFlow scripts to inject into package.json
1931
+ * WU-1342: .gitignore template with required exclusions
1932
+ * Includes node_modules, .lumenflow/state, and worktrees
1933
+ */
1934
+ const GITIGNORE_TEMPLATE = `# Dependencies
1935
+ node_modules/
1936
+
1937
+ # LumenFlow state (local only, not shared)
1938
+ .lumenflow/state/
1939
+
1940
+ # Worktrees (isolated parallel work directories)
1941
+ worktrees/
1942
+
1943
+ # Build output
1944
+ dist/
1945
+ *.tsbuildinfo
1946
+
1947
+ # Environment files
1948
+ .env
1949
+ .env.local
1950
+ .env.*.local
1951
+
1952
+ # IDE
1953
+ .idea/
1954
+ .vscode/
1955
+ *.swp
1956
+ *.swo
1957
+
1958
+ # OS files
1959
+ .DS_Store
1960
+ Thumbs.db
1961
+ `;
1962
+ /** Gitignore file name constant to avoid duplicate string lint error */
1963
+ const GITIGNORE_FILE_NAME = '.gitignore';
1964
+ /**
1965
+ * WU-1342: Scaffold .gitignore file with LumenFlow exclusions
1966
+ * Supports merge mode to add exclusions to existing .gitignore
1967
+ */
1968
+ async function scaffoldGitignore(targetDir, options, result) {
1969
+ const gitignorePath = path.join(targetDir, GITIGNORE_FILE_NAME);
1970
+ const fileMode = getFileMode(options);
1971
+ if (fileMode === 'merge' && fs.existsSync(gitignorePath)) {
1972
+ // Merge mode: append LumenFlow exclusions if not already present
1973
+ const existingContent = fs.readFileSync(gitignorePath, 'utf-8');
1974
+ const linesToAdd = [];
1975
+ // Check each required exclusion
1976
+ const requiredExclusions = [
1977
+ { pattern: 'node_modules', line: 'node_modules/' },
1978
+ { pattern: '.lumenflow/state', line: '.lumenflow/state/' },
1979
+ { pattern: 'worktrees', line: 'worktrees/' },
1980
+ ];
1981
+ for (const { pattern, line } of requiredExclusions) {
1982
+ if (!existingContent.includes(pattern)) {
1983
+ linesToAdd.push(line);
1984
+ }
1985
+ }
1986
+ if (linesToAdd.length > 0) {
1987
+ const separator = existingContent.endsWith('\n') ? '' : '\n';
1988
+ const lumenflowBlock = `${separator}
1989
+ # LumenFlow (auto-added)
1990
+ ${linesToAdd.join('\n')}
1991
+ `;
1992
+ fs.writeFileSync(gitignorePath, existingContent + lumenflowBlock);
1993
+ result.merged?.push(GITIGNORE_FILE_NAME);
1994
+ }
1995
+ else {
1996
+ result.skipped.push(GITIGNORE_FILE_NAME);
1997
+ }
1998
+ return;
1999
+ }
2000
+ // Skip or force mode
2001
+ await createFile(gitignorePath, GITIGNORE_TEMPLATE, fileMode, result, targetDir);
2002
+ }
2003
+ /**
2004
+ * WU-1307: LumenFlow scripts to inject into package.json
2005
+ * WU-1342: Expanded to include all 17 essential commands
2006
+ * Uses standalone binaries (wu-claim, wu-done, gates) that work in consumer projects
2007
+ * after installing @lumenflow/cli.
1457
2008
  */
1458
2009
  const LUMENFLOW_SCRIPTS = {
1459
- 'wu:claim': 'pnpm exec lumenflow wu:claim',
1460
- 'wu:done': 'pnpm exec lumenflow wu:done',
1461
- 'wu:create': 'pnpm exec lumenflow wu:create',
1462
- 'wu:status': 'pnpm exec lumenflow wu:status',
1463
- 'wu:block': 'pnpm exec lumenflow wu:block',
1464
- 'wu:unblock': 'pnpm exec lumenflow wu:unblock',
1465
- gates: 'pnpm exec lumenflow gates',
1466
- 'gates:docs': 'pnpm exec lumenflow gates --docs-only',
2010
+ // Core WU lifecycle
2011
+ 'wu:claim': 'wu-claim',
2012
+ 'wu:done': 'wu-done',
2013
+ 'wu:create': 'wu-create',
2014
+ 'wu:status': 'wu-status',
2015
+ 'wu:block': 'wu-block',
2016
+ 'wu:unblock': 'wu-unblock',
2017
+ // WU-1342: Additional critical commands
2018
+ 'wu:prep': 'wu-prep',
2019
+ 'wu:recover': 'wu-recover',
2020
+ 'wu:spawn': 'wu-spawn',
2021
+ 'wu:validate': 'wu-validate',
2022
+ 'wu:infer-lane': 'wu-infer-lane',
2023
+ // Memory commands
2024
+ 'mem:init': 'mem-init',
2025
+ 'mem:checkpoint': 'mem-checkpoint',
2026
+ 'mem:inbox': 'mem-inbox',
2027
+ // Lane commands
2028
+ 'lane:suggest': 'lane-suggest',
2029
+ // Gates
2030
+ gates: 'gates',
2031
+ 'gates:docs': 'gates --docs-only',
1467
2032
  };
1468
2033
  /**
1469
2034
  * WU-1300: Inject LumenFlow scripts into package.json
@@ -1508,7 +2073,9 @@ async function injectPackageJsonScripts(targetDir, options, result) {
1508
2073
  }
1509
2074
  }
1510
2075
  async function scaffoldFullDocs(targetDir, options, result, tokens) {
1511
- const tasksDir = path.join(targetDir, 'docs', DOCS_OPERATIONS_DIR, 'tasks');
2076
+ // WU-1309: Use docs structure from tokens (computed in scaffoldProject)
2077
+ const tasksPath = tokens.DOCS_TASKS_PATH;
2078
+ const tasksDir = path.join(targetDir, tasksPath);
1512
2079
  const wuDir = path.join(tasksDir, 'wu');
1513
2080
  const templatesDir = path.join(tasksDir, 'templates');
1514
2081
  await createDirectory(wuDir, result, targetDir);
@@ -1523,18 +2090,25 @@ async function scaffoldFullDocs(targetDir, options, result, tokens) {
1523
2090
  await scaffoldAgentOnboardingDocs(targetDir, options, result, tokens);
1524
2091
  }
1525
2092
  /**
1526
- * WU-1300: Scaffold lane inference configuration
2093
+ * WU-1307: Scaffold lane inference configuration
2094
+ * Uses hierarchical Parent→Sublane format required by lane-inference.ts
1527
2095
  */
1528
2096
  async function scaffoldLaneInference(targetDir, options, result, tokens) {
1529
- // Add framework-specific lanes if framework is provided
2097
+ // WU-1307: Add framework-specific lanes in hierarchical format if framework is provided
1530
2098
  let frameworkLanes = '';
1531
2099
  if (options.framework) {
1532
2100
  const { name, slug } = normalizeFrameworkName(options.framework);
2101
+ // Add framework lanes in hierarchical format (indentation matters in YAML)
1533
2102
  frameworkLanes = `
1534
- - name: "Framework: ${name}"
1535
- patterns:
1536
- - "src/${slug}/**"
1537
- - "packages/${slug}/**"
2103
+ # Framework-specific lanes (added with --framework ${name})
2104
+ ${name}:
2105
+ description: '${name} framework-specific code'
2106
+ code_paths:
2107
+ - 'src/${slug}/**'
2108
+ - 'packages/${slug}/**'
2109
+ keywords:
2110
+ - '${slug}'
2111
+ - '${name.toLowerCase()}'
1538
2112
  `;
1539
2113
  }
1540
2114
  const laneInferenceContent = processTemplate(LANE_INFERENCE_TEMPLATE, {
@@ -1546,12 +2120,20 @@ async function scaffoldLaneInference(targetDir, options, result, tokens) {
1546
2120
  /**
1547
2121
  * WU-1083: Scaffold agent onboarding documentation
1548
2122
  * WU-1300: Added starting-prompt.md
2123
+ * WU-1309: Added first-15-mins.md, local-only.md, lane-inference.md; use dynamic docs path
1549
2124
  */
1550
2125
  async function scaffoldAgentOnboardingDocs(targetDir, options, result, tokens) {
1551
- const onboardingDir = path.join(targetDir, 'docs', DOCS_OPERATIONS_DIR, '_frameworks', 'lumenflow', 'agent', 'onboarding');
2126
+ // WU-1309: Use dynamic onboarding path from tokens
2127
+ const onboardingDir = path.join(targetDir, tokens.DOCS_ONBOARDING_PATH);
1552
2128
  await createDirectory(onboardingDir, result, targetDir);
1553
2129
  // WU-1300: Add starting-prompt.md as first file
1554
2130
  await createFile(path.join(onboardingDir, 'starting-prompt.md'), processTemplate(STARTING_PROMPT_TEMPLATE, tokens), options.force, result, targetDir);
2131
+ // WU-1309: Add first-15-mins.md
2132
+ await createFile(path.join(onboardingDir, 'first-15-mins.md'), processTemplate(FIRST_15_MINS_TEMPLATE, tokens), options.force, result, targetDir);
2133
+ // WU-1309: Add local-only.md
2134
+ await createFile(path.join(onboardingDir, 'local-only.md'), processTemplate(LOCAL_ONLY_TEMPLATE, tokens), options.force, result, targetDir);
2135
+ // WU-1309: Add lane-inference.md
2136
+ await createFile(path.join(onboardingDir, 'lane-inference.md'), processTemplate(LANE_INFERENCE_DOC_TEMPLATE, tokens), options.force, result, targetDir);
1555
2137
  await createFile(path.join(onboardingDir, 'quick-ref-commands.md'), processTemplate(QUICK_REF_COMMANDS_TEMPLATE, tokens), options.force, result, targetDir);
1556
2138
  await createFile(path.join(onboardingDir, 'first-wu-mistakes.md'), processTemplate(FIRST_WU_MISTAKES_TEMPLATE, tokens), options.force, result, targetDir);
1557
2139
  await createFile(path.join(onboardingDir, 'troubleshooting-wu-done.md'), processTemplate(TROUBLESHOOTING_WU_DONE_TEMPLATE, tokens), options.force, result, targetDir);
@@ -1587,7 +2169,8 @@ async function scaffoldFrameworkOverlay(targetDir, options, result, tokens) {
1587
2169
  FRAMEWORK_SLUG: slug,
1588
2170
  };
1589
2171
  await createFile(path.join(targetDir, FRAMEWORK_HINT_FILE), processTemplate(FRAMEWORK_HINT_TEMPLATE, frameworkTokens), options.force, result, targetDir);
1590
- const overlayDir = path.join(targetDir, 'docs', DOCS_OPERATIONS_DIR, '_frameworks', slug);
2172
+ // WU-1309: Use dynamic operations path from tokens
2173
+ const overlayDir = path.join(targetDir, tokens.DOCS_OPERATIONS_PATH, '_frameworks', slug);
1591
2174
  await createDirectory(overlayDir, result, targetDir);
1592
2175
  await createFile(path.join(overlayDir, 'README.md'), processTemplate(FRAMEWORK_OVERLAY_TEMPLATE, frameworkTokens), options.force, result, targetDir);
1593
2176
  }