@lumenflow/cli 2.18.3 → 2.19.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 (104) hide show
  1. package/README.md +42 -41
  2. package/dist/delegation-list.js +140 -0
  3. package/dist/delegation-list.js.map +1 -0
  4. package/dist/doctor.js +35 -99
  5. package/dist/doctor.js.map +1 -1
  6. package/dist/gates-plan-resolvers.js +150 -0
  7. package/dist/gates-plan-resolvers.js.map +1 -0
  8. package/dist/gates-runners.js +533 -0
  9. package/dist/gates-runners.js.map +1 -0
  10. package/dist/gates-types.js +3 -0
  11. package/dist/gates-types.js.map +1 -1
  12. package/dist/gates-utils.js +316 -0
  13. package/dist/gates-utils.js.map +1 -0
  14. package/dist/gates.js +44 -1016
  15. package/dist/gates.js.map +1 -1
  16. package/dist/hooks/enforcement-generator.js +16 -880
  17. package/dist/hooks/enforcement-generator.js.map +1 -1
  18. package/dist/hooks/enforcement-sync.js +1 -4
  19. package/dist/hooks/enforcement-sync.js.map +1 -1
  20. package/dist/hooks/generators/auto-checkpoint.js +123 -0
  21. package/dist/hooks/generators/auto-checkpoint.js.map +1 -0
  22. package/dist/hooks/generators/enforce-worktree.js +188 -0
  23. package/dist/hooks/generators/enforce-worktree.js.map +1 -0
  24. package/dist/hooks/generators/index.js +16 -0
  25. package/dist/hooks/generators/index.js.map +1 -0
  26. package/dist/hooks/generators/pre-compact-checkpoint.js +134 -0
  27. package/dist/hooks/generators/pre-compact-checkpoint.js.map +1 -0
  28. package/dist/hooks/generators/require-wu.js +115 -0
  29. package/dist/hooks/generators/require-wu.js.map +1 -0
  30. package/dist/hooks/generators/session-start-recovery.js +101 -0
  31. package/dist/hooks/generators/session-start-recovery.js.map +1 -0
  32. package/dist/hooks/generators/signal-utils.js +52 -0
  33. package/dist/hooks/generators/signal-utils.js.map +1 -0
  34. package/dist/hooks/generators/warn-incomplete.js +65 -0
  35. package/dist/hooks/generators/warn-incomplete.js.map +1 -0
  36. package/dist/init-detection.js +228 -0
  37. package/dist/init-detection.js.map +1 -0
  38. package/dist/init-scaffolding.js +146 -0
  39. package/dist/init-scaffolding.js.map +1 -0
  40. package/dist/init-templates.js +1928 -0
  41. package/dist/init-templates.js.map +1 -0
  42. package/dist/init.js +136 -2425
  43. package/dist/init.js.map +1 -1
  44. package/dist/initiative-edit.js +42 -11
  45. package/dist/initiative-edit.js.map +1 -1
  46. package/dist/initiative-remove-wu.js +0 -0
  47. package/dist/initiative-status.js +29 -2
  48. package/dist/initiative-status.js.map +1 -1
  49. package/dist/mem-context.js +22 -9
  50. package/dist/mem-context.js.map +1 -1
  51. package/dist/orchestrate-init-status.js +32 -1
  52. package/dist/orchestrate-init-status.js.map +1 -1
  53. package/dist/orchestrate-monitor.js +38 -38
  54. package/dist/orchestrate-monitor.js.map +1 -1
  55. package/dist/public-manifest.js +12 -5
  56. package/dist/public-manifest.js.map +1 -1
  57. package/dist/shared-validators.js +1 -0
  58. package/dist/shared-validators.js.map +1 -1
  59. package/dist/spawn-list.js +0 -0
  60. package/dist/wu-claim-branch.js +121 -0
  61. package/dist/wu-claim-branch.js.map +1 -0
  62. package/dist/wu-claim-output.js +83 -0
  63. package/dist/wu-claim-output.js.map +1 -0
  64. package/dist/wu-claim-resume-handler.js +85 -0
  65. package/dist/wu-claim-resume-handler.js.map +1 -0
  66. package/dist/wu-claim-state.js +572 -0
  67. package/dist/wu-claim-state.js.map +1 -0
  68. package/dist/wu-claim-validation.js +439 -0
  69. package/dist/wu-claim-validation.js.map +1 -0
  70. package/dist/wu-claim-worktree.js +221 -0
  71. package/dist/wu-claim-worktree.js.map +1 -0
  72. package/dist/wu-claim.js +54 -1402
  73. package/dist/wu-claim.js.map +1 -1
  74. package/dist/wu-create-content.js +254 -0
  75. package/dist/wu-create-content.js.map +1 -0
  76. package/dist/wu-create-readiness.js +57 -0
  77. package/dist/wu-create-readiness.js.map +1 -0
  78. package/dist/wu-create-validation.js +149 -0
  79. package/dist/wu-create-validation.js.map +1 -0
  80. package/dist/wu-create.js +39 -441
  81. package/dist/wu-create.js.map +1 -1
  82. package/dist/wu-done.js +144 -249
  83. package/dist/wu-done.js.map +1 -1
  84. package/dist/wu-edit-operations.js +432 -0
  85. package/dist/wu-edit-operations.js.map +1 -0
  86. package/dist/wu-edit-validators.js +280 -0
  87. package/dist/wu-edit-validators.js.map +1 -0
  88. package/dist/wu-edit.js +27 -713
  89. package/dist/wu-edit.js.map +1 -1
  90. package/dist/wu-prep.js +32 -2
  91. package/dist/wu-prep.js.map +1 -1
  92. package/dist/wu-repair.js +1 -1
  93. package/dist/wu-repair.js.map +1 -1
  94. package/dist/wu-spawn-prompt-builders.js +1123 -0
  95. package/dist/wu-spawn-prompt-builders.js.map +1 -0
  96. package/dist/wu-spawn-strategy-resolver.js +314 -0
  97. package/dist/wu-spawn-strategy-resolver.js.map +1 -0
  98. package/dist/wu-spawn.js +9 -1398
  99. package/dist/wu-spawn.js.map +1 -1
  100. package/package.json +10 -7
  101. package/templates/core/LUMENFLOW.md.template +29 -99
  102. package/templates/core/ai/onboarding/agent-invocation-guide.md.template +1 -1
  103. package/templates/core/ai/onboarding/quick-ref-commands.md.template +29 -4
  104. package/templates/vendors/claude/.claude/skills/orchestration/SKILL.md.template +8 -8
@@ -0,0 +1,1928 @@
1
+ /**
2
+ * @file init-templates.ts
3
+ * Template string constants for LumenFlow project scaffolding.
4
+ *
5
+ * Extracted from init.ts (WU-1643) to reduce file size and isolate static data.
6
+ * These are pure data constants with no behavioral logic.
7
+ */
8
+ // WU-1576: Lane definitions must have zero overlapping code_paths.
9
+ // Each path must appear in exactly one lane to avoid doctor warnings.
10
+ export const DEFAULT_LANE_DEFINITIONS = [
11
+ {
12
+ name: 'Framework: Core',
13
+ wip_limit: 1,
14
+ code_paths: ['packages/**/core/**', 'src/core/**', 'lib/**'],
15
+ },
16
+ {
17
+ name: 'Framework: CLI',
18
+ wip_limit: 1,
19
+ code_paths: ['packages/**/cli/**', 'src/cli/**', 'bin/**'],
20
+ },
21
+ {
22
+ name: 'Experience: Web',
23
+ wip_limit: 1,
24
+ code_paths: ['apps/web/**', 'web/**', 'src/components/**', 'src/pages/**', 'src/app/**'],
25
+ },
26
+ {
27
+ name: 'Operations: Infrastructure',
28
+ wip_limit: 1,
29
+ code_paths: ['infrastructure/**', 'deploy/**'],
30
+ },
31
+ {
32
+ name: 'Operations: CI/CD',
33
+ wip_limit: 1,
34
+ code_paths: ['.github/workflows/**', '.github/actions/**', '.circleci/**'],
35
+ },
36
+ {
37
+ name: 'Content: Documentation',
38
+ wip_limit: 1,
39
+ code_paths: ['docs/**', '*.md'],
40
+ },
41
+ ];
42
+ // WU-1171: Template for AGENTS.md (universal entry point)
43
+ // WU-1300: Updated quick-ref link to correct path
44
+ // WU-1309: Use {{QUICK_REF_LINK}} and <project-root> placeholder for portability
45
+ export const AGENTS_MD_TEMPLATE = `# Universal Agent Instructions
46
+
47
+ **Last updated:** {{DATE}}
48
+
49
+ This project uses LumenFlow workflow. For complete documentation, see [LUMENFLOW.md](LUMENFLOW.md).
50
+
51
+ ---
52
+
53
+ ## Quick Start
54
+
55
+ \`\`\`bash
56
+ # 1. Claim a WU
57
+ pnpm wu:claim --id WU-XXXX --lane <Lane>
58
+ cd worktrees/<lane>-wu-xxxx
59
+
60
+ # 2. Work in worktree, run gates
61
+ pnpm gates
62
+
63
+ # 3. Complete (ALWAYS run this!)
64
+ cd <project-root>
65
+ pnpm wu:done --id WU-XXXX
66
+ \`\`\`
67
+
68
+ > **Complete CLI reference:** See [quick-ref-commands.md]({{QUICK_REF_LINK}})
69
+
70
+ ---
71
+
72
+ ## Critical: Always wu:done
73
+
74
+ After completing work, ALWAYS run \`pnpm wu:done --id WU-XXXX\` from the main checkout.
75
+
76
+ This is the single most forgotten step. See [LUMENFLOW.md](LUMENFLOW.md) for details.
77
+
78
+ ---
79
+
80
+ ## Core Principles
81
+
82
+ 1. **TDD**: Write tests first, then implementation
83
+ 2. **Worktree Discipline**: After \`wu:claim\`, work ONLY in the worktree
84
+ 3. **Gates Before Done**: Run \`pnpm gates\` before \`wu:done\`
85
+ 4. **Never Bypass Hooks**: No \`--no-verify\`
86
+
87
+ ---
88
+
89
+ ## Forbidden Commands
90
+
91
+ - \`git reset --hard\`
92
+ - \`git push --force\`
93
+ - \`git stash\` (on main)
94
+ - \`--no-verify\`
95
+
96
+ ---
97
+
98
+ ## Vendor-Specific Overlays
99
+
100
+ This file provides universal guidance for all AI agents. Additional vendor-specific configuration:
101
+
102
+ - **Claude Code**: See \`CLAUDE.md\` (if present)
103
+ - **Cursor**: See \`.cursor/rules/lumenflow.md\` (if present)
104
+ - **Windsurf**: See \`.windsurf/rules/lumenflow.md\` (if present)
105
+ `;
106
+ // Template for LUMENFLOW.md (main entry point)
107
+ // WU-1309: Use <project-root> placeholder for portability
108
+ // WU-1364: Added initiative workflow section
109
+ export 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## When to Use Initiatives\n\nUse **Initiatives** for multi-phase work spanning multiple WUs:\n\n- **Product visions**: "Build a task management app"\n- **Larger features**: Work requiring multiple WUs across lanes\n- **Complex projects**: Anything that needs phased delivery\n\n\`\`\`bash\n# Create an initiative for multi-phase work\npnpm initiative:create --id INIT-001 --title "Feature Name" \\\\\n --description "..." --phase "Phase 1: MVP" --phase "Phase 2: Polish"\n\n# Add WUs to the initiative\npnpm initiative:add-wu --initiative INIT-001 --wu WU-XXX --phase 1\n\n# Track progress\npnpm initiative:status --id INIT-001\n\`\`\`\n\n**Skip initiatives** for: single-file bug fixes, small docs updates, isolated refactoring.\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| \`pnpm initiative:create\` | Create multi-phase initiative |\n| \`pnpm initiative:status\` | View initiative progress |\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`;
110
+ // Template for .lumenflow/constraints.md
111
+ export 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`;
112
+ // Template for root CLAUDE.md
113
+ // WU-1309: Use <project-root> placeholder for portability
114
+ // WU-1382: Expanded with CLI commands table and warning about manual YAML editing
115
+ export const CLAUDE_MD_TEMPLATE = `# Claude Code Instructions
116
+
117
+ **Last updated:** {{DATE}}
118
+
119
+ This project uses LumenFlow workflow. For workflow documentation, see [LUMENFLOW.md](LUMENFLOW.md).
120
+
121
+ ---
122
+
123
+ ## Quick Start
124
+
125
+ \`\`\`bash
126
+ # 1. Claim a WU
127
+ pnpm wu:claim --id WU-XXXX --lane <Lane>
128
+ cd worktrees/<lane>-wu-xxxx
129
+
130
+ # 2. Work in worktree, run gates
131
+ pnpm gates
132
+
133
+ # 3. Complete (ALWAYS run this!)
134
+ cd <project-root>
135
+ pnpm wu:done --id WU-XXXX
136
+ \`\`\`
137
+
138
+ ---
139
+
140
+ ## CLI Commands Reference
141
+
142
+ ### WU Lifecycle
143
+
144
+ | Command | Description |
145
+ | ----------------------------------------- | ---------------------------------------- |
146
+ | \`pnpm wu:status --id WU-XXX\` | Show WU status, location, valid commands |
147
+ | \`pnpm wu:claim --id WU-XXX --lane <Lane>\` | Claim WU and create worktree |
148
+ | \`pnpm wu:prep --id WU-XXX\` | Run gates in worktree, prep for wu:done |
149
+ | \`pnpm wu:done --id WU-XXX\` | Complete WU (from main checkout) |
150
+ | \`pnpm wu:block --id WU-XXX --reason "..."\`| Block WU with reason |
151
+ | \`pnpm wu:unblock --id WU-XXX\` | Unblock WU |
152
+
153
+ ### Gates & Quality
154
+
155
+ | Command | Description |
156
+ | ------------------------ | -------------------------- |
157
+ | \`pnpm gates\` | Run all quality gates |
158
+ | \`pnpm gates --docs-only\` | Run gates for docs changes |
159
+ | \`pnpm format\` | Format all files |
160
+ | \`pnpm lint\` | Run linter |
161
+ | \`pnpm typecheck\` | Run TypeScript check |
162
+ | \`pnpm test\` | Run tests |
163
+
164
+ ---
165
+
166
+ ## Critical: Always wu:done
167
+
168
+ After completing work, ALWAYS run \`pnpm wu:done --id WU-XXXX\` from the main checkout.
169
+
170
+ See [LUMENFLOW.md](LUMENFLOW.md) for full workflow documentation.
171
+
172
+ ---
173
+
174
+ ## Warning: Do Not Edit WU YAML Files Manually
175
+
176
+ **Never manually edit WU YAML files** in \`docs/.../tasks/wu/WU-XXX.yaml\`.
177
+
178
+ Use CLI commands instead:
179
+
180
+ - \`pnpm wu:create ...\` to create new WUs
181
+ - \`pnpm wu:edit --id WU-XXX ...\` to modify WU fields
182
+ - \`pnpm wu:claim\` / \`wu:block\` / \`wu:done\` for status changes
183
+
184
+ Manual edits bypass validation and can corrupt workflow state.
185
+ `;
186
+ // Template for .claude/settings.json
187
+ export const CLAUDE_SETTINGS_TEMPLATE = `{
188
+ "$schema": "https://json.schemastore.org/claude-code-settings.json",
189
+ "permissions": {
190
+ "allow": [
191
+ "Bash",
192
+ "Read",
193
+ "Write",
194
+ "Edit",
195
+ "WebFetch",
196
+ "WebSearch"
197
+ ],
198
+ "deny": [
199
+ "Read(./.env)",
200
+ "Read(./.env.*)",
201
+ "Write(./.env*)",
202
+ "Bash(git reset --hard *)",
203
+ "Bash(git stash *)",
204
+ "Bash(git clean -fd *)",
205
+ "Bash(git push --force *)",
206
+ "Bash(git push -f *)",
207
+ "Bash(git commit --no-verify *)",
208
+ "Bash(HUSKY=0 *)",
209
+ "Bash(rm -rf /*)",
210
+ "Bash(sudo *)",
211
+ "Bash(git worktree remove *)",
212
+ "Bash(git worktree prune *)"
213
+ ]
214
+ }
215
+ }
216
+ `;
217
+ // WU-1171: Template for .cursor/rules/lumenflow.md (updated path)
218
+ // WU-1309: Use <project-root> placeholder for portability
219
+ export const CURSOR_RULES_TEMPLATE = `# Cursor LumenFlow Rules
220
+
221
+ This project uses LumenFlow workflow. See [LUMENFLOW.md](../../LUMENFLOW.md).
222
+
223
+ ## Critical Rules
224
+
225
+ 1. **Always run wu:done** - After gates pass, run \`pnpm wu:done --id WU-XXX\`
226
+ 2. **Work in worktrees** - After \`wu:claim\`, work only in the worktree
227
+ 3. **Never bypass hooks** - No \`--no-verify\`
228
+ 4. **TDD** - Write tests first
229
+
230
+ ## Forbidden Commands
231
+
232
+ - \`git reset --hard\`
233
+ - \`git push --force\`
234
+ - \`git stash\` (on main)
235
+ - \`--no-verify\`
236
+
237
+ ## Quick Reference
238
+
239
+ \`\`\`bash
240
+ # Claim WU
241
+ pnpm wu:claim --id WU-XXX --lane <Lane>
242
+ cd worktrees/<lane>-wu-xxx
243
+
244
+ # Run gates
245
+ pnpm gates
246
+
247
+ # Complete (from main)
248
+ cd <project-root>
249
+ pnpm wu:done --id WU-XXX
250
+ \`\`\`
251
+ `;
252
+ // WU-1171: Template for .windsurf/rules/lumenflow.md
253
+ // WU-1309: Use <project-root> placeholder for portability
254
+ export const WINDSURF_RULES_TEMPLATE = `# Windsurf LumenFlow Rules
255
+
256
+ This project uses LumenFlow workflow. See [LUMENFLOW.md](../../LUMENFLOW.md).
257
+
258
+ ## Critical Rules
259
+
260
+ 1. **Always run wu:done** - After gates pass, run \`pnpm wu:done --id WU-XXX\`
261
+ 2. **Work in worktrees** - After \`wu:claim\`, work only in the worktree
262
+ 3. **Never bypass hooks** - No \`--no-verify\`
263
+ 4. **TDD** - Write tests first
264
+
265
+ ## Forbidden Commands
266
+
267
+ - \`git reset --hard\`
268
+ - \`git push --force\`
269
+ - \`git stash\` (on main)
270
+ - \`--no-verify\`
271
+
272
+ ## Quick Reference
273
+
274
+ \`\`\`bash
275
+ # Claim WU
276
+ pnpm wu:claim --id WU-XXX --lane <Lane>
277
+ cd worktrees/<lane>-wu-xxx
278
+
279
+ # Run gates
280
+ pnpm gates
281
+
282
+ # Complete (from main)
283
+ cd <project-root>
284
+ pnpm wu:done --id WU-XXX
285
+ \`\`\`
286
+ `;
287
+ // WU-1177: Template for .clinerules (Cline AI assistant)
288
+ // WU-1309: Use <project-root> placeholder for portability
289
+ export const CLINE_RULES_TEMPLATE = `# Cline LumenFlow Rules
290
+
291
+ This project uses LumenFlow workflow. See [LUMENFLOW.md](LUMENFLOW.md).
292
+
293
+ ## Critical Rules
294
+
295
+ 1. **Always run wu:done** - After gates pass, run \`pnpm wu:done --id WU-XXX\`
296
+ 2. **Work in worktrees** - After \`wu:claim\`, work only in the worktree
297
+ 3. **Never bypass hooks** - No \`--no-verify\`
298
+ 4. **TDD** - Write tests first
299
+
300
+ ## Forbidden Commands
301
+
302
+ - \`git reset --hard\`
303
+ - \`git push --force\`
304
+ - \`git stash\` (on main)
305
+ - \`--no-verify\`
306
+
307
+ ## Quick Reference
308
+
309
+ \`\`\`bash
310
+ # Claim WU
311
+ pnpm wu:claim --id WU-XXX --lane <Lane>
312
+ cd worktrees/<lane>-wu-xxx
313
+
314
+ # Run gates
315
+ pnpm gates
316
+
317
+ # Complete (from main)
318
+ cd <project-root>
319
+ pnpm wu:done --id WU-XXX
320
+ \`\`\`
321
+ `;
322
+ // Template for .aider.conf.yml
323
+ export const AIDER_CONF_TEMPLATE = `# Aider Configuration for LumenFlow Projects\n# See LUMENFLOW.md for workflow documentation\n\nmodel: gpt-4-turbo\nauto-commits: false\ndirty-commits: false\n\nread:\n - LUMENFLOW.md\n - .lumenflow/constraints.md\n`;
324
+ // WU-1413: Template for .mcp.json (MCP server configuration for Claude Code)
325
+ export const MCP_JSON_TEMPLATE = `{
326
+ "mcpServers": {
327
+ "lumenflow": {
328
+ "command": "npx",
329
+ "args": ["@lumenflow/mcp"]
330
+ }
331
+ }
332
+ }
333
+ `;
334
+ // Template for docs/04-operations/tasks/backlog.md
335
+ export const BACKLOG_TEMPLATE = `---\nsections:\n ready:\n heading: '## 🚀 Ready (pull from here)'\n insertion: after_heading_blank_line\n in_progress:\n heading: '## 🔧 In progress'\n insertion: after_heading_blank_line\n blocked:\n heading: '## ⛔ Blocked'\n insertion: after_heading_blank_line\n done:\n heading: '## ✅ Done'\n insertion: after_heading_blank_line\n---\n\n# Backlog (single source of truth)\n\n## 🚀 Ready (pull from here)\n\n(No items ready)\n\n## 🔧 In progress\n\n(No items in progress)\n\n## ⛔ Blocked\n\n(No items blocked)\n\n## ✅ Done\n\n(No items completed yet)\n`;
336
+ // Template for docs/04-operations/tasks/status.md
337
+ export const STATUS_TEMPLATE = `# Status (active work)\n\n## In Progress\n\n(No items in progress)\n\n## Blocked\n\n(No items blocked)\n\n## Completed\n\n(No items completed yet)\n`;
338
+ // Template for docs tasks WU template YAML (scaffolded to {{DOCS_TASKS_PATH}}/templates/wu-template.yaml)
339
+ export const WU_TEMPLATE_YAML = `# Work Unit Template (LumenFlow WU Schema)\n#\n# Copy this template when creating new WUs. Fill in all required fields and\n# remove optional fields if not needed.\n#\n# If you used "lumenflow init --full", this template lives at:\n# {{DOCS_TASKS_PATH}}/templates/wu-template.yaml\n\n# Required: Unique work unit identifier (format: WU-NNN)\nid: WU-XXX\n\n# Required: Short, descriptive title (max 80 chars)\ntitle: 'Your WU title here'\n\n# Required: Lane (Parent: Sublane format)\nlane: '<Parent: Sublane>'\n\n# Required: Type of work\ntype: 'feature' # feature | bug | documentation | process | tooling | chore | refactor\n\n# Required: Current status\nstatus: 'ready' # ready | in_progress | blocked | done | cancelled\n\n# Required: Priority\npriority: P2 # P0 | P1 | P2 | P3\n\n# Required: Creation date (YYYY-MM-DD)\ncreated: {{DATE}}\n\n# Required: Owner/assignee (email)\nassigned_to: 'unassigned@example.com'\n\n# Required: Description\ndescription: |\n Context: ...\n Problem: ...\n Solution: ...\n\n# Required: Acceptance criteria (testable, binary)\nacceptance:\n - Criterion 1 (specific, measurable, testable)\n - Criterion 2 (binary pass/fail)\n - Documentation updated\n\n# Required: References to plans/specs (required for type: feature)\n# Tip: use pnpm wu:create --plan to generate a plan stub at lumenflow://plans/WU-XXX-plan.md\nspec_refs:\n - lumenflow://plans/WU-XXX-plan.md\n\n# Required: Code files changed or created (empty only for docs/process WUs)\n# Docs-only WUs should use docs/ or *.md paths to avoid docs-only gate failures.\ncode_paths:\n - path/to/file.ts\n\n# Required: Test paths (at least one of manual/unit/e2e/integration for non-doc WUs)\ntests:\n manual:\n - Manual check: Verify behavior or docs output\n unit:\n - path/to/test.test.ts\n e2e: []\n integration: []\n\n# Required: Exposure level\nexposure: 'backend-only' # ui | api | backend-only | documentation\n\n# Optional: User journey (recommended for ui/api)\n# user_journey: |\n# User navigates to ...\n# User performs ...\n\n# Optional: UI pairing WUs (for api exposure)\n# ui_pairing_wus:\n# - WU-1234\n\n# Optional: Navigation path (required when exposure=ui and no page file)\n# navigation_path: '/settings'\n\n# Required: Deliverable artifacts (stamps, docs, etc.)\nartifacts:\n - .lumenflow/stamps/WU-XXX.done\n\n# Optional: Dependencies (other WUs that must complete first)\ndependencies: []\n\n# Optional: Risks\nrisks:\n - Risk 1\n\n# Optional: Notes (required by spec linter)\nnotes: 'Implementation notes, rollout context, or plan summary.'\n\n# Optional: Requires human review\nrequires_review: false\n\n# Optional: Claimed mode (worktree or branch-only)\n# Automatically set by wu:claim, usually don't need to specify\n# claimed_mode: worktree\n\n# Optional: Assigned to (email of current claimant)\n# Automatically set by wu:claim\n# assigned_to: engineer@example.com\n\n# Optional: Locked status (prevents concurrent edits)\n# Automatically set by wu:claim and wu:done\n# locked: false\n\n# Optional: Completion date (ISO 8601 format)\n# Automatically set by wu:done\n# completed: 2025-10-23\n\n# Optional: Completion notes (added by wu:done)\n# completion_notes: |\n# Additional notes added during wu:done.\n# Any deviations from original plan.\n# Lessons learned.\n\n# ============================================================================\n# GOVERNANCE BLOCK (WU Schema v2.0)\n# ============================================================================\n# Optional: COS governance rules that apply to this WU\n# Only include if this WU needs specific governance enforcement\n\n# governance:\n# # Rules that apply to this WU (evaluated during cos:gates)\n# rules:\n# - rule_id: UPAIN-01\n# satisfied: false # Initially false, set true when evidence provided\n# evidence:\n# - type: link\n# value: docs/product/voc/feature-user-pain.md\n# description: "Voice of Customer analysis showing user pain"\n# notes: |\n# VOC analysis shows 40% of support tickets request this feature.\n# Average time wasted: 15min/user/week.\n#\n# - rule_id: CASH-03\n# satisfied: false\n# evidence:\n# - type: link\n# value: docs/finance/spend-reviews/2025-10-cloud-infra.md\n# description: "Spend review for £1200/month cloud infrastructure"\n# - type: approval\n# value: owner@example.com\n# description: "Owner approval for spend commitment"\n# notes: |\n# New cloud infrastructure commitment: £1200/month for 12 months.\n# ROI: Reduces latency by 50%, improves user retention.\n#\n# # Gate checks (enforced by cos-gates.ts)\n# gates:\n# narrative: "pending" # Status: pending, passed, skipped, failed\n# finance: "pending"\n#\n# # Exemptions (only if rule doesn't apply)\n# exemptions:\n# - rule_id: FAIR-01\n# reason: "No user-facing pricing changes in this WU"\n# approved_by: product-owner@example.com\n# approved_at: 2025-10-23\n\n# ============================================================================\n# USAGE NOTES\n# ============================================================================\n#\n# 1. Remove this entire governance block if no COS rules apply to your WU\n# 2. Only include rules that require enforcement (not all rules apply to all WUs)\n# 3. Evidence types: link:, metric:, screenshot:, approval:\n# 4. Gates are checked during wu:done (before merge)\n# 5. Exemptions require approval from rule owner\n#\n# For more details, see:\n# - {{DOCS_OPERATIONS_PATH}}/_frameworks/cos/system-prompt-v1.3.md\n# - {{DOCS_OPERATIONS_PATH}}/_frameworks/cos/evidence-format.md\n`;
340
+ // Template for .lumenflow.framework.yaml
341
+ export const FRAMEWORK_HINT_TEMPLATE = `# LumenFlow Framework Hint\n# Generated by: lumenflow init --framework {{FRAMEWORK_NAME}}\n\nframework: "{{FRAMEWORK_NAME}}"\nslug: "{{FRAMEWORK_SLUG}}"\n`;
342
+ // Template for docs/04-operations/_frameworks/<framework>/README.md
343
+ export 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`;
344
+ // WU-1083: Agent onboarding docs templates
345
+ // WU-1309: Updated quick-ref with --docs-structure and complete wu:create example
346
+ export const QUICK_REF_COMMANDS_TEMPLATE = `# Quick Reference: LumenFlow Commands
347
+
348
+ **Last updated:** {{DATE}}
349
+
350
+ ---
351
+
352
+ ## Project Setup
353
+
354
+ | Command | Description |
355
+ | ---------------------------------------------------- | ----------------------------------------- |
356
+ | \`pnpm exec lumenflow init\` | Scaffold minimal LumenFlow core |
357
+ | \`pnpm exec lumenflow init --full\` | Add docs + agent onboarding scaffolding |
358
+ | \`pnpm exec lumenflow init --docs-structure simple\` | Use simple docs structure (docs/tasks) |
359
+ | \`pnpm exec lumenflow init --docs-structure arc42\` | Use arc42 structure (docs/04-operations) |
360
+ | \`pnpm exec lumenflow init --framework <name>\` | Add framework hint + overlay docs |
361
+ | \`pnpm exec lumenflow init --client <type>\` | Add client overlay (claude, cursor, etc.) |
362
+ | \`pnpm exec lumenflow init --force\` | Overwrite existing files |
363
+
364
+ ---
365
+
366
+ ## WU Management
367
+
368
+ | Command | Description |
369
+ | ----------------------------------------- | ------------------------------- |
370
+ | \`pnpm wu:create ...\` (see example below) | Create new WU |
371
+ | \`pnpm wu:claim --id WU-XXX --lane <Lane>\`| Claim WU (creates worktree) |
372
+ | \`pnpm wu:done --id WU-XXX\` | Complete WU (merge, stamp) |
373
+ | \`pnpm wu:block --id WU-XXX --reason "..."\`| Block a WU |
374
+ | \`pnpm wu:unblock --id WU-XXX\` | Unblock a WU |
375
+ | \`pnpm wu:status --id WU-XXX\` | Check WU status and location |
376
+
377
+ ---
378
+
379
+ ## Complete wu:create Example
380
+
381
+ \`\`\`bash
382
+ pnpm wu:create \\
383
+ --id WU-001 \\
384
+ --lane "Framework: Core" \\
385
+ --title "Add validation feature" \\
386
+ --description "Context: Users need input validation. Problem: No validation exists. Solution: Add Zod-based validation." \\
387
+ --acceptance "Validation rejects invalid input" \\
388
+ --acceptance "Unit tests cover edge cases with >90% coverage" \\
389
+ --acceptance "Documentation updated" \\
390
+ --code-paths "packages/@lumenflow/core/src/validation.ts" \\
391
+ --test-paths-unit "packages/@lumenflow/core/src/__tests__/validation.test.ts" \\
392
+ --exposure backend-only \\
393
+ --spec-refs "lumenflow://plans/WU-001-plan.md"
394
+ \`\`\`
395
+
396
+ **Required fields for code WUs:**
397
+ - \`--lane\`: Format is "Parent: Sublane" (e.g., "Framework: Core")
398
+ - \`--title\`: Short descriptive title
399
+ - \`--description\`: Context, Problem, Solution
400
+ - \`--acceptance\`: At least one (repeatable)
401
+ - \`--code-paths\`: Files to modify (repeatable)
402
+ - \`--test-paths-unit\` or \`--test-paths-e2e\`: Test files
403
+ - \`--exposure\`: ui | api | backend-only | documentation
404
+ - \`--spec-refs\`: Required for type: feature
405
+
406
+ ---
407
+
408
+ ## Gates
409
+
410
+ | Command | Description |
411
+ | ------------------------ | -------------------------- |
412
+ | \`pnpm gates\` | Run all quality gates |
413
+ | \`pnpm gates --docs-only\` | Run gates for docs changes |
414
+ | \`pnpm format\` | Format all files |
415
+ | \`pnpm lint\` | Run linter |
416
+ | \`pnpm typecheck\` | Run TypeScript check |
417
+ | \`pnpm test\` | Run tests |
418
+
419
+ ---
420
+
421
+ ## Git (Safe Operations)
422
+
423
+ | Command | Description |
424
+ | ------------------------------------ | ------------------------- |
425
+ | \`git status\` | Check working tree status |
426
+ | \`git add .\` | Stage all changes |
427
+ | \`git commit -m "type: message"\` | Commit with message |
428
+ | \`git push origin lane/<lane>/wu-xxx\` | Push to remote |
429
+
430
+ ---
431
+
432
+ ## Navigation
433
+
434
+ \`\`\`bash
435
+ # After claiming, go to worktree
436
+ cd worktrees/<lane>-wu-xxx
437
+
438
+ # Return to main for wu:done
439
+ cd <project-root>
440
+ \`\`\`
441
+
442
+ ---
443
+
444
+ ## Workflow Sequence
445
+
446
+ \`\`\`bash
447
+ # 1. Create (see complete example above)
448
+ pnpm wu:create --id WU-001 --lane "Framework: Core" --title "Add feature" \\
449
+ --description "Context: ... Problem: ... Solution: ..." \\
450
+ --acceptance "Feature works" --acceptance "Tests pass" \\
451
+ --code-paths "src/feature.ts" \\
452
+ --test-paths-unit "src/__tests__/feature.test.ts" \\
453
+ --exposure backend-only \\
454
+ --spec-refs "lumenflow://plans/WU-001-plan.md"
455
+
456
+ # 2. Claim
457
+ pnpm wu:claim --id WU-001 --lane "Framework: Core"
458
+ cd worktrees/framework-core-wu-001
459
+
460
+ # 3. Work (TDD)
461
+ # ... write tests first, then code ...
462
+
463
+ # 4. Commit
464
+ git add .
465
+ git commit -m "feat: add feature"
466
+ git push origin lane/framework-core/wu-001
467
+
468
+ # 5. Gates
469
+ pnpm gates
470
+
471
+ # 6. Complete (from main checkout)
472
+ cd <project-root>
473
+ pnpm wu:done --id WU-001
474
+ \`\`\`
475
+
476
+ ---
477
+
478
+ ## File Paths
479
+
480
+ | Path | Description |
481
+ | ------------------------------------ | -------------------- |
482
+ | \`{{DOCS_TASKS_PATH}}/wu/WU-XXX.yaml\` | WU specification |
483
+ | \`{{DOCS_TASKS_PATH}}/status.md\` | Current status board |
484
+ | \`.lumenflow/stamps/WU-XXX.done\` | Completion stamp |
485
+ | \`worktrees/<lane>-wu-xxx/\` | Worktree directory |
486
+ `;
487
+ export const FIRST_WU_MISTAKES_TEMPLATE = `# First WU Mistakes
488
+
489
+ **Last updated:** {{DATE}}
490
+
491
+ Common mistakes agents make on their first WU, and how to avoid them.
492
+
493
+ ---
494
+
495
+ ## Mistake 1: Not Using Worktrees
496
+
497
+ ### Wrong
498
+
499
+ \`\`\`bash
500
+ # Working directly in main
501
+ vim src/feature.ts
502
+ git commit -m "feat: add feature"
503
+ git push origin main
504
+ \`\`\`
505
+
506
+ ### Right
507
+
508
+ \`\`\`bash
509
+ # Claim first, then work in worktree
510
+ pnpm wu:claim --id WU-123 --lane Core
511
+ cd worktrees/core-wu-123
512
+ vim src/feature.ts
513
+ git commit -m "feat: add feature"
514
+ git push origin lane/core/wu-123
515
+ cd /path/to/main
516
+ pnpm wu:done --id WU-123
517
+ \`\`\`
518
+
519
+ ---
520
+
521
+ ## Mistake 2: Forgetting to Run wu:done
522
+
523
+ See [troubleshooting-wu-done.md](troubleshooting-wu-done.md) for the full explanation.
524
+
525
+ **TL;DR:** After gates pass, ALWAYS run \`pnpm wu:done --id WU-XXX\`.
526
+
527
+ ---
528
+
529
+ ## Mistake 3: Working Outside code_paths
530
+
531
+ ### Wrong
532
+
533
+ The WU says \`code_paths: [src/api/**]\` but you edit \`src/ui/component.ts\`.
534
+
535
+ ### Right
536
+
537
+ Only edit files within the specified \`code_paths\`. If you need to edit other files, that's a different WU.
538
+
539
+ ---
540
+
541
+ ## Mistake 4: Skipping TDD
542
+
543
+ ### Wrong
544
+
545
+ \`\`\`
546
+ 1. Write the feature
547
+ 2. Maybe write tests later
548
+ 3. Tests are hard, skip them
549
+ \`\`\`
550
+
551
+ ### Right
552
+
553
+ \`\`\`
554
+ 1. Write failing test
555
+ 2. Run test (confirm RED)
556
+ 3. Write minimum code
557
+ 4. Run test (confirm GREEN)
558
+ 5. Refactor if needed
559
+ \`\`\`
560
+
561
+ ---
562
+
563
+ ## Mistake 5: Using Forbidden Git Commands
564
+
565
+ ### Wrong
566
+
567
+ \`\`\`bash
568
+ git reset --hard HEAD
569
+ git push --force
570
+ git commit --no-verify
571
+ \`\`\`
572
+
573
+ ### Right
574
+
575
+ \`\`\`bash
576
+ git add .
577
+ git commit -m "feat: description"
578
+ git push origin lane/core/wu-123
579
+ \`\`\`
580
+
581
+ ---
582
+
583
+ ## Mistake 6: Ignoring Gate Failures
584
+
585
+ ### Wrong
586
+
587
+ \`\`\`
588
+ Gates failed but I think the code is fine.
589
+ Let me use --skip-gates.
590
+ \`\`\`
591
+
592
+ ### Right
593
+
594
+ \`\`\`
595
+ Gates failed. Let me read the error:
596
+ - TypeScript error in src/api/handler.ts
597
+ - Missing return type
598
+
599
+ Fix: Add the return type.
600
+ Re-run: pnpm gates
601
+ \`\`\`
602
+
603
+ ---
604
+
605
+ ## Quick Checklist
606
+
607
+ Before starting any WU:
608
+
609
+ - [ ] Read the full WU spec
610
+ - [ ] Understand acceptance criteria
611
+ - [ ] Claim the WU with \`pnpm wu:claim\`
612
+ - [ ] cd to the worktree IMMEDIATELY
613
+ - [ ] Work only in the worktree
614
+ - [ ] Stay within code_paths
615
+ - [ ] Follow TDD
616
+ - [ ] Run gates before wu:done
617
+ - [ ] ALWAYS run wu:done
618
+ `;
619
+ export const TROUBLESHOOTING_WU_DONE_TEMPLATE = `# Troubleshooting: wu:done Not Run
620
+
621
+ **Last updated:** {{DATE}}
622
+
623
+ This is the most common mistake agents make. This document explains why it happens and how to fix it.
624
+
625
+ ---
626
+
627
+ ## The Problem
628
+
629
+ Agents complete their work, write "To Complete: pnpm wu:done --id WU-XXX" in their response, and then **stop without actually running the command**.
630
+
631
+ ### Why This Happens
632
+
633
+ 1. **Confusion about scope**: Agent thinks completion is a "next step" for the human
634
+ 2. **Fear of overstepping**: Agent hesitates to take "final" actions
635
+ 3. **Missing context**: Agent doesn't realize wu:done is expected to be run immediately
636
+ 4. **Token limits**: Agent runs out of context and summarizes remaining steps
637
+
638
+ ---
639
+
640
+ ## The Fix
641
+
642
+ ### Rule: ALWAYS Run wu:done
643
+
644
+ After gates pass, you MUST run:
645
+
646
+ \`\`\`bash
647
+ cd /path/to/main
648
+ pnpm wu:done --id WU-XXX
649
+ \`\`\`
650
+
651
+ Do NOT:
652
+
653
+ - Ask "Should I run wu:done?"
654
+ - Write "To Complete: pnpm wu:done"
655
+ - Wait for permission
656
+ - Treat it as a "future step"
657
+
658
+ ---
659
+
660
+ ## Correct Completion Flow
661
+
662
+ \`\`\`bash
663
+ # 1. In worktree, run gates
664
+ pnpm gates
665
+
666
+ # 2. If gates pass, return to main
667
+ cd /path/to/main
668
+
669
+ # 3. IMMEDIATELY run wu:done
670
+ pnpm wu:done --id WU-XXX
671
+
672
+ # 4. Report success with the wu:done output
673
+ \`\`\`
674
+
675
+ ---
676
+
677
+ ## What wu:done Does
678
+
679
+ When you run \`pnpm wu:done --id WU-XXX\`:
680
+
681
+ 1. Validates the worktree exists and has commits
682
+ 2. Runs gates in the worktree (not main)
683
+ 3. Fast-forward merges to main
684
+ 4. Creates the done stamp
685
+ 5. Updates status and backlog docs
686
+ 6. Removes the worktree
687
+ 7. Pushes to origin
688
+
689
+ **This is the ONLY way to complete a WU.** Manual steps will leave things in an inconsistent state.
690
+
691
+ ---
692
+
693
+ ## Symptoms of Incomplete WU
694
+
695
+ If wu:done wasn't run, you'll see:
696
+
697
+ - Worktree still exists: \`ls worktrees/\`
698
+ - No stamp: \`ls .lumenflow/stamps/WU-XXX.done\` returns nothing
699
+ - Status unchanged: WU still shows as \`in_progress\`
700
+ - Branch not merged: Changes only on lane branch
701
+
702
+ ---
703
+
704
+ ## Recovery
705
+
706
+ If a previous agent forgot to run wu:done:
707
+
708
+ \`\`\`bash
709
+ # 1. Check worktree exists
710
+ ls worktrees/
711
+
712
+ # 2. If it does, run wu:done
713
+ pnpm wu:done --id WU-XXX
714
+ \`\`\`
715
+
716
+ ---
717
+
718
+ ## Checklist Before Ending Session
719
+
720
+ - [ ] Did I run \`pnpm gates\` in the worktree?
721
+ - [ ] Did gates pass?
722
+ - [ ] Did I \`cd\` back to main?
723
+ - [ ] Did I run \`pnpm wu:done --id WU-XXX\`?
724
+ - [ ] Did wu:done complete successfully?
725
+
726
+ If any answer is "no", you're not done yet.
727
+ `;
728
+ export const AGENT_SAFETY_CARD_TEMPLATE = `# Agent Safety Card
729
+
730
+ **Last updated:** {{DATE}}
731
+
732
+ Quick reference for AI agents working in LumenFlow projects.
733
+
734
+ ---
735
+
736
+ ## Stop and Ask When
737
+
738
+ - Same error repeats 3 times
739
+ - Auth or permissions changes needed
740
+ - PII/PHI/secrets involved
741
+ - Cloud spend decisions
742
+ - Policy changes required
743
+ - Anything feels irreversible
744
+
745
+ ---
746
+
747
+ ## Never Do
748
+
749
+ | Action | Why |
750
+ | ------------------------ | ---------------- |
751
+ | \`git reset --hard\` | Data loss |
752
+ | \`git push --force\` | History rewrite |
753
+ | \`--no-verify\` | Bypasses safety |
754
+ | \`git stash\` (on main) | Hides work |
755
+ | \`git clean -fd\` | Deletes files |
756
+ | Work in main after claim | Breaks isolation |
757
+ | Skip wu:done | Incomplete WU |
758
+
759
+ ---
760
+
761
+ ## Always Do
762
+
763
+ | Action | Why |
764
+ | -------------------------- | ---------------- |
765
+ | Read WU spec first | Understand scope |
766
+ | cd to worktree after claim | Isolation |
767
+ | Write tests before code | TDD |
768
+ | Run gates before wu:done | Quality |
769
+ | Run wu:done | Complete WU |
770
+ | Stay within code_paths | Scope discipline |
771
+
772
+ ---
773
+
774
+ ## Error Handling
775
+
776
+ ### Max 3 Attempts
777
+
778
+ If same error happens 3 times:
779
+
780
+ 1. Stop trying
781
+ 2. Document what happened
782
+ 3. Ask for help
783
+
784
+ ### Gate Failures
785
+
786
+ 1. Read the error message
787
+ 2. Fix the underlying issue
788
+ 3. Re-run gates
789
+ 4. Never use \`--skip-gates\` for new failures
790
+
791
+ ---
792
+
793
+ ## Quick Commands
794
+
795
+ \`\`\`bash
796
+ # Check lane availability
797
+ cat {{DOCS_TASKS_PATH}}/status.md
798
+
799
+ # Claim a WU
800
+ pnpm wu:claim --id WU-XXX --lane <Lane>
801
+
802
+ # Work in worktree
803
+ cd worktrees/<lane>-wu-xxx
804
+
805
+ # Run gates
806
+ pnpm gates # Code changes
807
+ pnpm gates --docs-only # Docs changes
808
+
809
+ # Complete WU
810
+ cd /path/to/main
811
+ pnpm wu:done --id WU-XXX
812
+ \`\`\`
813
+
814
+ ---
815
+
816
+ ## Completion Checklist
817
+
818
+ - [ ] Gates pass
819
+ - [ ] cd to main
820
+ - [ ] Run wu:done
821
+ - [ ] Verify success output
822
+ - [ ] Report completion
823
+
824
+ ---
825
+
826
+ ## When Uncertain
827
+
828
+ Choose the safer path:
829
+
830
+ - Don't modify files outside code_paths
831
+ - Don't bypass hooks
832
+ - Don't skip gates
833
+ - Ask rather than assume
834
+ `;
835
+ // WU-1307: Lane inference configuration template (hierarchical Parent→Sublane format)
836
+ // WU-1364: Added Core and Feature as parent lanes for intuitive naming
837
+ // WU-1382: Added managed file header to prevent manual edits
838
+ // This format is required by lane-inference.ts and lane-checker.ts
839
+ export const LANE_INFERENCE_TEMPLATE = `# ============================================================================
840
+ # LUMENFLOW MANAGED FILE - DO NOT EDIT MANUALLY
841
+ # ============================================================================
842
+ # Generated by: lumenflow init
843
+ # Regenerate with: pnpm exec lumenflow init --force
844
+ #
845
+ # This file is managed by LumenFlow tooling. Manual edits may be overwritten.
846
+ # To customize lanes, use: pnpm lane:suggest --output .lumenflow.lane-inference.yaml
847
+ # ============================================================================
848
+
849
+ # Lane Inference Configuration
850
+ #
851
+ # Hierarchical format: Parent -> Sublane -> { code_paths, keywords }
852
+ # This format is required by lane-inference.ts for proper sub-lane suggestion.
853
+ #
854
+ # Common parent lanes: Core, Feature, Framework, Experience, Operations, Content
855
+
856
+ # Core Lane: Platform foundations, shared libraries, base infrastructure
857
+ Core:
858
+ Platform:
859
+ description: 'Core platform: shared utilities, base infrastructure, common libraries'
860
+ code_paths:
861
+ - 'packages/**/core/**'
862
+ - 'src/core/**'
863
+ - 'src/lib/**'
864
+ - 'lib/**'
865
+ keywords:
866
+ - 'platform'
867
+ - 'core'
868
+ - 'infrastructure'
869
+ - 'foundation'
870
+
871
+ Library:
872
+ description: 'Shared libraries and utilities'
873
+ code_paths:
874
+ - 'packages/**/lib/**'
875
+ - 'src/utils/**'
876
+ - 'src/helpers/**'
877
+ keywords:
878
+ - 'library'
879
+ - 'utility'
880
+ - 'helper'
881
+ - 'shared'
882
+
883
+ # Feature Lane: Product features and user-facing functionality
884
+ Feature:
885
+ Backend:
886
+ description: 'Backend features: APIs, services, business logic'
887
+ code_paths:
888
+ - 'src/api/**'
889
+ - 'src/services/**'
890
+ - 'packages/**/api/**'
891
+ keywords:
892
+ - 'api'
893
+ - 'service'
894
+ - 'backend'
895
+ - 'business logic'
896
+
897
+ Frontend:
898
+ description: 'Frontend features: UI, components, pages'
899
+ code_paths:
900
+ - 'src/components/**'
901
+ - 'src/pages/**'
902
+ - 'src/app/**'
903
+ - 'apps/web/**'
904
+ keywords:
905
+ - 'frontend'
906
+ - 'ui'
907
+ - 'component'
908
+ - 'page'
909
+
910
+ # Framework Lane: Framework-specific code and tooling
911
+ Framework:
912
+ Core:
913
+ description: 'Core framework: business logic, domain models, utilities'
914
+ code_paths:
915
+ - 'packages/**/core/**'
916
+ - 'src/core/**'
917
+ - 'lib/**'
918
+ keywords:
919
+ - 'core library'
920
+ - 'business logic'
921
+ - 'domain'
922
+ - 'utility'
923
+
924
+ CLI:
925
+ description: 'CLI commands and tooling'
926
+ code_paths:
927
+ - 'packages/**/cli/**'
928
+ - 'src/cli/**'
929
+ - 'bin/**'
930
+ keywords:
931
+ - 'cli command'
932
+ - 'command line'
933
+ - 'tooling'
934
+
935
+ # Experience Lane: User-facing frontend work
936
+ Experience:
937
+ UI:
938
+ description: 'User interface components and pages'
939
+ code_paths:
940
+ - 'apps/web/**'
941
+ - 'src/components/**'
942
+ - 'src/pages/**'
943
+ - 'src/app/**'
944
+ keywords:
945
+ - 'ui'
946
+ - 'component'
947
+ - 'page'
948
+ - 'frontend'
949
+ - 'user interface'
950
+
951
+ Web:
952
+ description: 'Web application features'
953
+ code_paths:
954
+ - 'apps/web/**'
955
+ - 'web/**'
956
+ keywords:
957
+ - 'web'
958
+ - 'browser'
959
+ - 'frontend'
960
+
961
+ # Operations Lane: Infrastructure and CI/CD
962
+ Operations:
963
+ Infrastructure:
964
+ description: 'Apps, deployment, hosting configuration'
965
+ code_paths:
966
+ - 'apps/**'
967
+ - 'infrastructure/**'
968
+ - 'deploy/**'
969
+ - 'turbo.json'
970
+ - 'pnpm-workspace.yaml'
971
+ keywords:
972
+ - 'infrastructure'
973
+ - 'deployment'
974
+ - 'hosting'
975
+ - 'monorepo'
976
+
977
+ CI/CD:
978
+ description: 'GitHub Actions, workflows, build pipelines'
979
+ code_paths:
980
+ - '.github/workflows/**'
981
+ - '.github/actions/**'
982
+ - '.github/**'
983
+ - '.circleci/**'
984
+ keywords:
985
+ - 'ci'
986
+ - 'cd'
987
+ - 'github actions'
988
+ - 'workflow'
989
+ - 'pipeline'
990
+
991
+ # Content Lane: Documentation
992
+ Content:
993
+ Documentation:
994
+ description: 'All documentation: guides, references, specs'
995
+ code_paths:
996
+ - 'docs/**'
997
+ - '*.md'
998
+ - 'README.md'
999
+ keywords:
1000
+ - 'documentation'
1001
+ - 'docs'
1002
+ - 'guide'
1003
+ - 'readme'
1004
+ - 'markdown'
1005
+ {{FRAMEWORK_LANES}}
1006
+ `;
1007
+ // WU-1300: Starting prompt template for agent onboarding
1008
+ // WU-1364: Added "When Starting From Product Vision" section for initiative-first workflow
1009
+ export const STARTING_PROMPT_TEMPLATE = `# Starting Prompt for LumenFlow Agents
1010
+
1011
+ **Last updated:** {{DATE}}
1012
+
1013
+ This document provides the initial context for AI agents working on this project.
1014
+
1015
+ ---
1016
+
1017
+ ## When Starting From Product Vision
1018
+
1019
+ If you are starting a new project or feature from a product vision (e.g., "Build a task management app"), **do NOT create standalone WUs immediately**. Instead, follow the initiative-first workflow:
1020
+
1021
+ ### 4-Step Initiative Workflow
1022
+
1023
+ 1. **Create an Initiative**: Capture the vision as an initiative
1024
+ \`\`\`bash
1025
+ pnpm initiative:create --id INIT-001 --title "Task Management App" \\
1026
+ --description "Build a task management application with..." \\
1027
+ --phase "Phase 1: Core MVP" --phase "Phase 2: Collaboration"
1028
+ \`\`\`
1029
+
1030
+ 2. **Define Phases**: Break the vision into logical phases (MVP, iteration, polish)
1031
+
1032
+ 3. **Create WUs under the Initiative**: Each WU belongs to a phase
1033
+ \`\`\`bash
1034
+ pnpm wu:create --lane "Core: Platform" --title "Add task model" \\
1035
+ --description "..." --acceptance "..." --code-paths "..." \\
1036
+ && pnpm initiative:add-wu --initiative INIT-001 --wu WU-XXX --phase 1
1037
+ \`\`\`
1038
+
1039
+ 4. **Track Progress**: Use \`pnpm initiative:status --id INIT-001\` to see overall progress
1040
+
1041
+ ### Why Initiatives Matter
1042
+
1043
+ - **Avoid orphan WUs**: Without initiative structure, agents create disconnected WUs that lack coherent scope
1044
+ - **Better coordination**: Phases enable parallel work across lanes
1045
+ - **Clear completion criteria**: The initiative tracks when all phases are done
1046
+ - **Visibility**: Stakeholders can see multi-phase progress
1047
+
1048
+ ### When to Skip Initiatives
1049
+
1050
+ Only skip initiatives for:
1051
+ - Single-file bug fixes
1052
+ - Small documentation updates
1053
+ - Isolated refactoring tasks
1054
+
1055
+ If work spans multiple WUs or multiple days, create an initiative first.
1056
+
1057
+ ---
1058
+
1059
+ ## Step 1: Read Core Documentation
1060
+
1061
+ Before starting any work, read these documents in order:
1062
+
1063
+ 1. **[LUMENFLOW.md](../../../../../../LUMENFLOW.md)** - Main workflow documentation
1064
+ 2. **[constraints.md](../../../../../../.lumenflow/constraints.md)** - Non-negotiable rules
1065
+ 3. **This file** - Onboarding context
1066
+
1067
+ ---
1068
+
1069
+ ## Step 2: Understand the Workflow
1070
+
1071
+ LumenFlow uses Work Units (WUs) to track all changes:
1072
+
1073
+ 1. **Claim a WU**: \`pnpm wu:claim --id WU-XXX --lane <Lane>\`
1074
+ 2. **Work in worktree**: \`cd worktrees/<lane>-wu-xxx\`
1075
+ 3. **Run gates**: \`pnpm gates\`
1076
+ 4. **Complete WU**: \`pnpm wu:done --id WU-XXX\` (from main checkout)
1077
+
1078
+ ---
1079
+
1080
+ ## Step 3: Key Constraints
1081
+
1082
+ 1. **Worktree Discipline**: Never work in main after claiming a WU
1083
+ 2. **TDD**: Write tests first, then implementation
1084
+ 3. **Gates**: Must pass before \`wu:done\`
1085
+ 4. **Always wu:done**: Never skip the completion step
1086
+
1087
+ ---
1088
+
1089
+ ## Step 4: Common Commands
1090
+
1091
+ | Command | Description |
1092
+ | ------- | ----------- |
1093
+ | \`pnpm wu:claim --id WU-XXX --lane <Lane>\` | Claim a WU |
1094
+ | \`pnpm gates\` | Run quality gates |
1095
+ | \`pnpm wu:done --id WU-XXX\` | Complete WU |
1096
+ | \`pnpm wu:status --id WU-XXX\` | Check WU status |
1097
+ | \`pnpm initiative:create ...\` | Create a new initiative |
1098
+ | \`pnpm initiative:status --id INIT-XXX\` | Check initiative progress |
1099
+
1100
+ ---
1101
+
1102
+ ## Step 5: When Stuck
1103
+
1104
+ 1. Read the WU spec at \`{{DOCS_TASKS_PATH}}/wu/WU-XXX.yaml\`
1105
+ 2. Check [troubleshooting-wu-done.md](troubleshooting-wu-done.md)
1106
+ 3. Review [first-wu-mistakes.md](first-wu-mistakes.md)
1107
+
1108
+ ---
1109
+
1110
+ ## Additional Resources
1111
+
1112
+ - [quick-ref-commands.md](quick-ref-commands.md) - Complete command reference
1113
+ - [agent-safety-card.md](agent-safety-card.md) - Safety guidelines
1114
+ - [wu-create-checklist.md](wu-create-checklist.md) - WU creation guide
1115
+ - [wu-sizing-guide.md](wu-sizing-guide.md) - WU complexity and context management
1116
+ `;
1117
+ export const WU_CREATE_CHECKLIST_TEMPLATE = `# WU Creation Checklist
1118
+
1119
+ **Last updated:** {{DATE}}
1120
+
1121
+ Before running \`pnpm wu:create\`, verify these items.
1122
+
1123
+ ---
1124
+
1125
+ ## Step 1: Check Valid Lanes
1126
+
1127
+ \`\`\`bash
1128
+ grep -A 30 "lanes:" .lumenflow.config.yaml
1129
+ \`\`\`
1130
+
1131
+ **Format:** \`"Parent: Sublane"\` (colon + single space)
1132
+
1133
+ Examples:
1134
+ - \`"Framework: CLI"\`
1135
+ - \`"Framework: Core"\`
1136
+ - \`"Operations: CI/CD"\`
1137
+ - \`"Content: Documentation"\`
1138
+
1139
+ ---
1140
+
1141
+ ## Step 2: Required Fields
1142
+
1143
+ | Field | Required For | Example |
1144
+ |-------|--------------|---------|
1145
+ | \`--id\` | All | \`WU-1234\` |
1146
+ | \`--lane\` | All | \`"Experience: Chat"\` |
1147
+ | \`--title\` | All | \`"Add feature"\` |
1148
+ | \`--description\` | All | \`"Context: ... Problem: ... Solution: ..."\` |
1149
+ | \`--acceptance\` | All | \`--acceptance "Works"\` (repeatable) |
1150
+ | \`--exposure\` | All | \`ui\`, \`api\`, \`backend-only\`, \`documentation\` |
1151
+ | \`--code-paths\` | Code WUs | \`"src/a.ts,src/b.ts"\` |
1152
+ | \`--test-paths-unit\` | Code WUs | \`"src/__tests__/a.test.ts"\` |
1153
+ | \`--spec-refs\` | Feature WUs | \`"~/.lumenflow/plans/WU-XXX.md"\` |
1154
+
1155
+ ---
1156
+
1157
+ ## Step 3: Plan Storage
1158
+
1159
+ Plans go in \`~/.lumenflow/plans/\` (NOT in project):
1160
+
1161
+ \`\`\`bash
1162
+ mkdir -p ~/.lumenflow/plans
1163
+ # Create your plan
1164
+ vim ~/.lumenflow/plans/WU-XXX-plan.md
1165
+ \`\`\`
1166
+
1167
+ Reference in wu:create:
1168
+ \`\`\`bash
1169
+ --spec-refs "~/.lumenflow/plans/WU-XXX-plan.md"
1170
+ \`\`\`
1171
+
1172
+ ---
1173
+
1174
+ ## Step 4: Validate First
1175
+
1176
+ \`\`\`bash
1177
+ pnpm wu:create --id WU-XXX ... --validate
1178
+ \`\`\`
1179
+
1180
+ Fix errors, then remove \`--validate\` to create.
1181
+
1182
+ ---
1183
+
1184
+ ## Complete Example
1185
+
1186
+ \`\`\`bash
1187
+ pnpm wu:create \\
1188
+ --id WU-1234 \\
1189
+ --lane "Framework: CLI" \\
1190
+ --title "Add feature X" \\
1191
+ --description "Context: Users need X. Problem: X doesn't exist. Solution: Add X." \\
1192
+ --acceptance "Feature X works as specified" \\
1193
+ --acceptance "Unit tests pass with >90% coverage" \\
1194
+ --code-paths "packages/@lumenflow/cli/src/x.ts" \\
1195
+ --test-paths-unit "packages/@lumenflow/cli/__tests__/x.test.ts" \\
1196
+ --exposure backend-only \\
1197
+ --spec-refs "~/.lumenflow/plans/WU-1234-plan.md"
1198
+ \`\`\`
1199
+
1200
+ ---
1201
+
1202
+ ## Common Errors
1203
+
1204
+ ### "Lane format invalid"
1205
+
1206
+ **Cause:** Missing colon or space in lane format.
1207
+
1208
+ **Fix:** Use \`"Parent: Sublane"\` format (colon + space).
1209
+
1210
+ ### "Missing required field"
1211
+
1212
+ **Cause:** Required field not provided.
1213
+
1214
+ **Fix:** Add the missing \`--field\` argument.
1215
+
1216
+ ### "WU already exists"
1217
+
1218
+ **Cause:** WU with this ID already exists.
1219
+
1220
+ **Fix:** Use a different ID or check existing WUs.
1221
+
1222
+ ---
1223
+
1224
+ ## After Creation
1225
+
1226
+ 1. Review the created YAML: \`cat {{DOCS_TASKS_PATH}}/wu/WU-XXX.yaml\`
1227
+ 2. Claim the WU: \`pnpm wu:claim --id WU-XXX --lane "Lane"\`
1228
+ 3. cd to worktree: \`cd worktrees/<lane>-wu-xxx\`
1229
+ `;
1230
+ // WU-1309: First 15 Minutes template
1231
+ export const FIRST_15_MINS_TEMPLATE = `# First 15 Minutes with LumenFlow
1232
+
1233
+ **Last updated:** {{DATE}}
1234
+
1235
+ A quick-start guide for your first session with LumenFlow.
1236
+
1237
+ ---
1238
+
1239
+ ## Minute 0-2: Verify Setup
1240
+
1241
+ \`\`\`bash
1242
+ # Check LumenFlow is configured
1243
+ ls LUMENFLOW.md AGENTS.md .lumenflow.config.yaml
1244
+
1245
+ # Run doctor to verify safety components
1246
+ pnpm exec lumenflow doctor
1247
+ \`\`\`
1248
+
1249
+ ---
1250
+
1251
+ ## Minute 2-5: Read Essential Docs
1252
+
1253
+ 1. Open **LUMENFLOW.md** - Main workflow guide
1254
+ 2. Scan **AGENTS.md** - Quick reference for commands
1255
+ 3. Review **.lumenflow/constraints.md** - The 6 rules you must follow
1256
+
1257
+ ---
1258
+
1259
+ ## Minute 5-8: Find a WU to Work On
1260
+
1261
+ \`\`\`bash
1262
+ # Check status board
1263
+ cat {{DOCS_TASKS_PATH}}/status.md
1264
+
1265
+ # List ready WUs
1266
+ ls {{DOCS_TASKS_PATH}}/wu/*.yaml | head -5
1267
+ \`\`\`
1268
+
1269
+ ---
1270
+
1271
+ ## Minute 8-12: Claim and Start
1272
+
1273
+ \`\`\`bash
1274
+ # Claim a WU
1275
+ pnpm wu:claim --id WU-XXX --lane "Framework: Core"
1276
+
1277
+ # IMPORTANT: cd to worktree immediately
1278
+ cd worktrees/framework-core-wu-xxx
1279
+
1280
+ # Verify you're in the right place
1281
+ pwd # Should end with worktrees/...
1282
+ \`\`\`
1283
+
1284
+ ---
1285
+
1286
+ ## Minute 12-15: Begin TDD Cycle
1287
+
1288
+ \`\`\`bash
1289
+ # 1. Write a failing test
1290
+ # 2. Run it to confirm RED
1291
+ pnpm test -- --run
1292
+
1293
+ # 3. Write minimal code to pass
1294
+ # 4. Run test again for GREEN
1295
+ pnpm test -- --run
1296
+
1297
+ # 5. Run gates to check everything
1298
+ pnpm gates
1299
+ \`\`\`
1300
+
1301
+ ---
1302
+
1303
+ ## Key Reminders
1304
+
1305
+ - **Stay in the worktree** after claiming
1306
+ - **TDD**: Test first, then code
1307
+ - **Gates before done**: Always run \`pnpm gates\`
1308
+ - **Always wu:done**: Never forget to complete
1309
+
1310
+ ---
1311
+
1312
+ ## When Done
1313
+
1314
+ \`\`\`bash
1315
+ # From worktree: run gates
1316
+ pnpm gates
1317
+
1318
+ # From main: complete WU
1319
+ cd <project-root>
1320
+ pnpm wu:done --id WU-XXX
1321
+ \`\`\`
1322
+ `;
1323
+ // WU-1309: Local-only / no remote template
1324
+ export const LOCAL_ONLY_TEMPLATE = `# Local-Only Development
1325
+
1326
+ **Last updated:** {{DATE}}
1327
+
1328
+ Configure LumenFlow for local development without a remote repository.
1329
+
1330
+ ---
1331
+
1332
+ ## When to Use
1333
+
1334
+ - Air-gapped environments
1335
+ - Testing/evaluation
1336
+ - Pre-remote development (haven't pushed to GitHub yet)
1337
+ - Offline development
1338
+
1339
+ ---
1340
+
1341
+ ## Configuration
1342
+
1343
+ Add this to \`.lumenflow.config.yaml\`:
1344
+
1345
+ \`\`\`yaml
1346
+ git:
1347
+ requireRemote: false
1348
+ \`\`\`
1349
+
1350
+ ---
1351
+
1352
+ ## Behavior Changes
1353
+
1354
+ When \`requireRemote: false\`:
1355
+
1356
+ | Command | Default Behavior | Local-Only Behavior |
1357
+ |---------|------------------|---------------------|
1358
+ | \`wu:create\` | Fetches origin/main | Skips remote fetch |
1359
+ | \`wu:claim\` | Pushes lane branch | Creates local branch only |
1360
+ | \`wu:done\` | Pushes to origin | Commits to local main |
1361
+
1362
+ ---
1363
+
1364
+ ## Warnings
1365
+
1366
+ With local-only mode:
1367
+
1368
+ 1. **No remote visibility** - Team members can't see your WUs
1369
+ 2. **No backup** - Work is only on your machine
1370
+ 3. **Manual sync required** - When adding a remote later
1371
+
1372
+ ---
1373
+
1374
+ ## Transitioning to Remote
1375
+
1376
+ When you add an origin remote:
1377
+
1378
+ 1. Update config: \`git.requireRemote: true\` or remove the setting
1379
+ 2. Push your main branch: \`git push -u origin main\`
1380
+ 3. Resume normal workflow
1381
+
1382
+ ---
1383
+
1384
+ ## Troubleshooting
1385
+
1386
+ ### "No origin remote configured"
1387
+
1388
+ **Cause:** \`requireRemote: true\` (default) but no origin exists.
1389
+
1390
+ **Fix:** Add remote or set \`requireRemote: false\`:
1391
+
1392
+ \`\`\`bash
1393
+ # Option 1: Add remote
1394
+ git remote add origin <url>
1395
+
1396
+ # Option 2: Enable local-only mode
1397
+ echo "git:\\n requireRemote: false" >> .lumenflow.config.yaml
1398
+ \`\`\`
1399
+ `;
1400
+ // WU-1309: Lane Inference template
1401
+ export const LANE_INFERENCE_DOC_TEMPLATE = `# Lane Inference
1402
+
1403
+ **Last updated:** {{DATE}}
1404
+
1405
+ How LumenFlow determines which lane a WU belongs to.
1406
+
1407
+ ---
1408
+
1409
+ ## Lane Format
1410
+
1411
+ LumenFlow uses hierarchical lanes: \`"Parent: Sublane"\`
1412
+
1413
+ Examples:
1414
+ - \`"Framework: Core"\`
1415
+ - \`"Framework: CLI"\`
1416
+ - \`"Experience: UI"\`
1417
+ - \`"Operations: CI/CD"\`
1418
+ - \`"Content: Documentation"\`
1419
+
1420
+ ---
1421
+
1422
+ ## Lane Taxonomy File
1423
+
1424
+ Lanes are defined in \`.lumenflow.lane-inference.yaml\`:
1425
+
1426
+ \`\`\`yaml
1427
+ Framework:
1428
+ Core:
1429
+ description: 'Core library'
1430
+ code_paths:
1431
+ - 'packages/**/core/**'
1432
+ keywords:
1433
+ - 'core'
1434
+ - 'library'
1435
+
1436
+ CLI:
1437
+ description: 'CLI commands'
1438
+ code_paths:
1439
+ - 'packages/**/cli/**'
1440
+ - 'bin/**'
1441
+ keywords:
1442
+ - 'cli'
1443
+ - 'command'
1444
+ \`\`\`
1445
+
1446
+ ---
1447
+
1448
+ ## Auto-Inference
1449
+
1450
+ Use \`wu:infer-lane\` to suggest a lane based on code paths:
1451
+
1452
+ \`\`\`bash
1453
+ # Infer from WU code_paths
1454
+ pnpm wu:infer-lane --id WU-XXX
1455
+
1456
+ # Infer from manual inputs
1457
+ pnpm wu:infer-lane --paths "packages/@lumenflow/cli/**" --desc "Add CLI command"
1458
+ \`\`\`
1459
+
1460
+ ---
1461
+
1462
+ ## Generating Lane Taxonomy
1463
+
1464
+ If no taxonomy exists, generate one:
1465
+
1466
+ \`\`\`bash
1467
+ pnpm lane:suggest --output .lumenflow.lane-inference.yaml
1468
+ \`\`\`
1469
+
1470
+ ---
1471
+
1472
+ ## Common Issues
1473
+
1474
+ ### "Lane format invalid"
1475
+
1476
+ **Cause:** Missing colon or space.
1477
+
1478
+ **Fix:** Use \`"Parent: Sublane"\` format (colon + space).
1479
+
1480
+ ### "Sub-lane validation failed"
1481
+
1482
+ **Cause:** No \`.lumenflow.lane-inference.yaml\` file.
1483
+
1484
+ **Fix:** Create the file or generate it:
1485
+
1486
+ \`\`\`bash
1487
+ pnpm lane:suggest --output .lumenflow.lane-inference.yaml
1488
+ \`\`\`
1489
+
1490
+ ---
1491
+
1492
+ ## Lane Health
1493
+
1494
+ Check lane configuration for issues:
1495
+
1496
+ \`\`\`bash
1497
+ pnpm lane:health
1498
+ \`\`\`
1499
+
1500
+ This detects:
1501
+ - Overlapping code paths between lanes
1502
+ - Code files not covered by any lane
1503
+ `;
1504
+ // WU-1385: WU sizing guide template for agent onboarding
1505
+ export const WU_SIZING_GUIDE_TEMPLATE = `# Work Unit Sizing & Strategy Guide
1506
+
1507
+ **Last updated:** {{DATE}}
1508
+
1509
+ **Purpose:** Decision framework for agents to determine execution strategy based on task complexity.
1510
+
1511
+ **Status:** Active — Thresholds are **mandatory limits**, not guidelines.
1512
+
1513
+ ---
1514
+
1515
+ ## Complexity Assessment Matrix
1516
+
1517
+ Before claiming a WU, estimate its "weight" using these heuristics.
1518
+
1519
+ | Complexity | Files | Tool Calls | Context Budget | Strategy |
1520
+ | :------------ | :---- | :--------- | :------------- | :------------------------------------------- |
1521
+ | **Simple** | <20 | <50 | <30% | **Single Session** (Tier 2 Context) |
1522
+ | **Medium** | 20-50 | 50-100 | 30-50% | **Checkpoint-Resume** (Standard Handoff) |
1523
+ | **Complex** | 50+ | 100+ | >50% | **Orchestrator-Worker** OR **Decomposition** |
1524
+ | **Oversized** | 100+ | 200+ | — | **MUST Split** (See Patterns below) |
1525
+
1526
+ **These thresholds are mandatory.** Exceeding them leads to context exhaustion and rule loss. Agents operate in context windows and tool calls, not clock time.
1527
+
1528
+ ---
1529
+
1530
+ ## Context Safety Triggers
1531
+
1532
+ If you hit ANY of these triggers during a session, you MUST checkpoint and spawn fresh:
1533
+
1534
+ - **Token Limit:** Context usage hits **50% (Warning)** or **80% (Critical)**.
1535
+ - **Tool Volume:** **50+ tool calls** in current session.
1536
+ - **File Volume:** **20+ files** modified in \`git status\`.
1537
+ - **Session Staleness:** Repeated redundant queries or forgotten context.
1538
+
1539
+ ---
1540
+
1541
+ ## Spawn Fresh, Don't Continue
1542
+
1543
+ **When approaching context limits, spawn a fresh agent instead of continuing after compaction.**
1544
+
1545
+ Context compaction causes agents to lose critical rules. The disciplined approach:
1546
+
1547
+ 1. Checkpoint your progress: \`pnpm mem:checkpoint --wu WU-XXX\`
1548
+ 2. Commit and push work
1549
+ 3. Generate fresh agent prompt: \`pnpm wu:brief --id WU-XXX --client claude-code\`
1550
+ 4. EXIT current session (do NOT continue after compaction)
1551
+
1552
+ ---
1553
+
1554
+ ## Splitting Patterns
1555
+
1556
+ When a WU is Oversized or Complex, split it using approved patterns:
1557
+
1558
+ - **Tracer Bullet**: WU-1 proves skeleton works, WU-2 implements real logic
1559
+ - **Layer Split**: WU-1 for ports/application, WU-2 for infrastructure
1560
+ - **UI/Logic Split**: WU-1 for backend, WU-2 for frontend
1561
+ - **Feature Flag**: WU-1 behind flag, WU-2 removes flag
1562
+
1563
+ ---
1564
+
1565
+ ## Quick Reference
1566
+
1567
+ | Scenario | Strategy | Action |
1568
+ | :---------------------------------- | :------------------ | :------------------------------------------- |
1569
+ | Bug fix, single file, <20 calls | Simple | Claim, fix, commit, \`wu:done\` |
1570
+ | Feature 50-100 calls, clear phases | Checkpoint-Resume | Phase 1 → checkpoint → Phase 2 → done |
1571
+ | Multi-domain, must land atomically | Orchestrator-Worker | Main agent coordinates, spawns sub-agents |
1572
+ | Large refactor 100+ calls | Feature Flag Split | WU-A: New behind flag → WU-B: Remove flag |
1573
+
1574
+ ---
1575
+
1576
+ ## Documentation-Only Exception
1577
+
1578
+ Documentation WUs (\`type: documentation\`) have relaxed file count thresholds:
1579
+
1580
+ | Complexity | Files (docs) | Tool Calls | Strategy |
1581
+ | :--------- | :----------- | :--------- | :---------------- |
1582
+ | **Simple** | <40 | <50 | Single Session |
1583
+ | **Medium** | 40-80 | 50-100 | Checkpoint-Resume |
1584
+
1585
+ **Applies when ALL true:**
1586
+ - WU \`type: documentation\`
1587
+ - Only modifies: \`docs/**\`, \`*.md\`
1588
+ - Does NOT touch code paths
1589
+
1590
+ ---
1591
+
1592
+ For complete sizing guidance, see the canonical [wu-sizing-guide.md](https://lumenflow.dev/reference/wu-sizing-guide/) documentation.
1593
+ `;
1594
+ // WU-1083: Claude skills templates
1595
+ export const WU_LIFECYCLE_SKILL_TEMPLATE = `---
1596
+ name: wu-lifecycle
1597
+ description: Work Unit claim/block/done workflow automation.
1598
+ version: 1.0.0
1599
+ ---
1600
+
1601
+ # WU Lifecycle Skill
1602
+
1603
+ ## When to Use
1604
+
1605
+ Activate this skill when:
1606
+
1607
+ - Claiming a WU (\`pnpm wu:claim\`)
1608
+ - Blocking/unblocking WUs due to dependencies
1609
+ - Running \`wu:done\` completion workflow
1610
+ - Understanding WU state machine transitions
1611
+
1612
+ ## State Machine
1613
+
1614
+ \`\`\`
1615
+ ready -> in_progress -> waiting/blocked -> done
1616
+ \`\`\`
1617
+
1618
+ ## Core Commands
1619
+
1620
+ \`\`\`bash
1621
+ # Claim WU
1622
+ pnpm wu:claim --id WU-XXX --lane <lane>
1623
+ cd worktrees/<lane>-wu-xxx # IMMEDIATELY
1624
+
1625
+ # Complete WU (from main)
1626
+ cd ../..
1627
+ pnpm wu:done --id WU-XXX
1628
+
1629
+ # Block/Unblock
1630
+ pnpm wu:block --id WU-XXX --reason "..."
1631
+ pnpm wu:unblock --id WU-XXX
1632
+
1633
+ # Create (full spec)
1634
+ pnpm wu:create --id WU-999 --lane "Operations" --title "Add feature" \\
1635
+ --description "Context: ... Problem: ... Solution: ..." \\
1636
+ --acceptance "Feature works" --code-paths "src/a.ts" --validate
1637
+ \`\`\`
1638
+
1639
+ ## wu:done Workflow
1640
+
1641
+ 1. Runs gates in worktree
1642
+ 2. Fast-forward merge to main
1643
+ 3. Creates \`.lumenflow/stamps/WU-XXX.done\`
1644
+ 4. Updates backlog.md + status.md
1645
+ 5. Removes worktree
1646
+
1647
+ ## Worktree Discipline
1648
+
1649
+ After \`wu:claim\`:
1650
+
1651
+ - \`cd worktrees/<lane>-wu-xxx\` immediately
1652
+ - Use relative paths (never absolute)
1653
+ - Main is read-only
1654
+ `;
1655
+ export const WORKTREE_DISCIPLINE_SKILL_TEMPLATE = `---
1656
+ name: worktree-discipline
1657
+ description: Prevents the "absolute path trap" in Write/Edit/Read tools.
1658
+ version: 1.0.0
1659
+ ---
1660
+
1661
+ # Worktree Discipline: Absolute Path Trap Prevention
1662
+
1663
+ **Purpose**: Prevent AI agents from bypassing worktree isolation via absolute file paths.
1664
+
1665
+ ## The Absolute Path Trap
1666
+
1667
+ **Problem**: AI agents using Write/Edit/Read tools can bypass worktree isolation by passing absolute paths. Even when your shell is in the worktree, absolute paths target the main checkout.
1668
+
1669
+ ### Example
1670
+
1671
+ \`\`\`typescript
1672
+ // Shell: cd worktrees/operations-wu-427
1673
+
1674
+ // WRONG - Absolute path bypasses worktree
1675
+ Write({
1676
+ file_path: '/<user-home>/source/project/apps/web/src/validator.ts',
1677
+ content: '...',
1678
+ });
1679
+ // Result: Written to MAIN checkout, not worktree!
1680
+
1681
+ // RIGHT - Relative path respects worktree
1682
+ Write({
1683
+ file_path: 'apps/web/src/validator.ts',
1684
+ content: '...',
1685
+ });
1686
+ // Result: Written to worktree correctly
1687
+ \`\`\`
1688
+
1689
+ ## Pre-Operation Checklist
1690
+
1691
+ **Before ANY Write/Edit/Read operation:**
1692
+
1693
+ 1. **Verify working directory**:
1694
+
1695
+ \`\`\`bash
1696
+ pwd
1697
+ # Must show: .../worktrees/<lane>-wu-xxx
1698
+ \`\`\`
1699
+
1700
+ 2. **Check file path format**:
1701
+
1702
+ | Pattern | Safe? | Example |
1703
+ | --------------------------------- | ----- | --------------------------- |
1704
+ | Starts with \`/<user-home>/\` | NO | \`/<user-home>/.../file.ts\` |
1705
+ | Contains full repo path | NO | \`/source/project/...\` |
1706
+ | Starts with package name | YES | \`apps/web/src/...\` |
1707
+ | Starts with \`./\` or \`../\` | YES | \`./src/lib/...\` |
1708
+ | Just filename | YES | \`README.md\` |
1709
+
1710
+ 3. **Use relative paths for ALL file operations**
1711
+
1712
+ ## Golden Rules
1713
+
1714
+ 1. **Always verify pwd** before file operations
1715
+ 2. **Never use absolute paths** in Write/Edit/Read tools
1716
+ 3. **When in doubt, use relative paths**
1717
+ `;
1718
+ export const LUMENFLOW_GATES_SKILL_TEMPLATE = `---
1719
+ name: lumenflow-gates
1720
+ description: Quality gates troubleshooting (format, lint, typecheck, tests).
1721
+ version: 1.0.0
1722
+ ---
1723
+
1724
+ # LumenFlow Gates Skill
1725
+
1726
+ ## When to Use
1727
+
1728
+ Activate this skill when:
1729
+
1730
+ - \`pnpm gates\` fails with format, lint, or typecheck errors
1731
+ - Need to determine if failure is from your changes vs pre-existing
1732
+ - Debugging test failures or coverage issues
1733
+ - Deciding whether to use \`--skip-gates\` (emergency only)
1734
+
1735
+ ## Gate Sequence
1736
+
1737
+ \`\`\`
1738
+ pnpm gates = format:check -> lint -> typecheck -> spec:linter -> tests
1739
+ \`\`\`
1740
+
1741
+ ## Fix Patterns
1742
+
1743
+ | Gate | Auto-fix | Manual |
1744
+ | --------- | --------------- | ----------------------------------- |
1745
+ | Format | \`pnpm format\` | - |
1746
+ | Lint | \`pnpm lint:fix\` | Fix reported issues |
1747
+ | Typecheck | - | Fix type errors (first error first) |
1748
+ | Tests | - | Debug, fix mocks, update snapshots |
1749
+
1750
+ ## Decision Tree
1751
+
1752
+ **Gate failed. Is it from YOUR changes?**
1753
+
1754
+ \`\`\`bash
1755
+ git checkout main && pnpm gates # Check main
1756
+ # Pass on main -> Your change caused it -> Fix it
1757
+ # Fail on main -> Pre-existing -> Consider --skip-gates
1758
+ \`\`\`
1759
+
1760
+ **Can you fix it?**
1761
+
1762
+ - In your \`code_paths\`, <=10 lines -> Fix in place
1763
+ - Different paths, >10 lines -> Create Bug WU
1764
+
1765
+ ## Skip Gates (Emergency)
1766
+
1767
+ Only when pre-existing failures:
1768
+
1769
+ \`\`\`bash
1770
+ pnpm wu:done --id WU-XXX --skip-gates --reason "Pre-existing" --fix-wu WU-YYY
1771
+ \`\`\`
1772
+
1773
+ ## Common Lint Fixes
1774
+
1775
+ \`\`\`
1776
+ no-explicit-any -> Add proper types
1777
+ no-unused-vars -> Remove or prefix with _
1778
+ no-restricted-paths -> Check hex boundaries
1779
+ exhaustive-deps -> Add missing dependencies
1780
+ \`\`\`
1781
+
1782
+ ## Validation Commands
1783
+
1784
+ \`\`\`bash
1785
+ pnpm gates # All gates
1786
+ pnpm gates -- --docs-only # Docs WUs
1787
+ pnpm format # Fix formatting
1788
+ pnpm lint:fix # Fix lint issues
1789
+ pnpm typecheck # Check types
1790
+ \`\`\`
1791
+ `;
1792
+ export const GITIGNORE_TEMPLATE = `# Dependencies
1793
+ node_modules/
1794
+
1795
+ # LumenFlow telemetry (local only, not shared)
1796
+ .lumenflow/telemetry/
1797
+
1798
+ # Worktrees (isolated parallel work directories)
1799
+ worktrees/
1800
+
1801
+ # Build output
1802
+ dist/
1803
+ *.tsbuildinfo
1804
+
1805
+ # Environment files
1806
+ .env
1807
+ .env.local
1808
+ .env.*.local
1809
+
1810
+ # IDE
1811
+ .idea/
1812
+ .vscode/
1813
+ *.swp
1814
+ *.swo
1815
+
1816
+ # OS files
1817
+ .DS_Store
1818
+ Thumbs.db
1819
+ `;
1820
+ export const PRETTIERIGNORE_TEMPLATE = `# Dependencies
1821
+ node_modules/
1822
+
1823
+ # Build output
1824
+ dist/
1825
+ *.tsbuildinfo
1826
+
1827
+ # Coverage reports
1828
+ coverage/
1829
+
1830
+ # LumenFlow state (local only)
1831
+ .lumenflow/state/
1832
+
1833
+ # Worktrees
1834
+ worktrees/
1835
+
1836
+ # Lockfiles (auto-generated)
1837
+ pnpm-lock.yaml
1838
+ package-lock.json
1839
+ yarn.lock
1840
+
1841
+ # Environment files
1842
+ .env
1843
+ .env.local
1844
+ .env.*.local
1845
+ `;
1846
+ export const SCRIPT_ARG_OVERRIDES = {
1847
+ 'gates:docs': 'gates --docs-only',
1848
+ };
1849
+ export const SAFE_GIT_TEMPLATE = `#!/bin/sh
1850
+ #
1851
+ # safe-git - LumenFlow safety wrapper for git
1852
+ #
1853
+ # Blocks dangerous operations that can corrupt agent state.
1854
+ # For all other commands, passes through to system git.
1855
+ #
1856
+
1857
+ set -e
1858
+
1859
+ # Block 'worktree remove'
1860
+ if [ "$1" = "worktree" ] && [ "$2" = "remove" ]; then
1861
+ echo "" >&2
1862
+ echo "=== LUMENFLOW SAFETY BLOCK ===" >&2
1863
+ echo "" >&2
1864
+ echo "BLOCKED: Manual 'git worktree remove' is unsafe in this environment." >&2
1865
+ echo "" >&2
1866
+ echo "REASON: Manual removal leaves orphan directories and corrupts agent state." >&2
1867
+ echo "" >&2
1868
+ echo "USE INSTEAD:" >&2
1869
+ echo " pnpm wu:done --id <ID> (To complete a task)" >&2
1870
+ echo " pnpm wu:cleanup --id <ID> (To discard a task)" >&2
1871
+ echo "==============================" >&2
1872
+ exit 1
1873
+ fi
1874
+
1875
+ # Pass through to real git
1876
+ exec git "$@"
1877
+ `;
1878
+ export const PRE_COMMIT_TEMPLATE = `#!/bin/sh
1879
+ #
1880
+ # LumenFlow Pre-Commit Hook
1881
+ #
1882
+ # Enforces worktree discipline by blocking direct commits to main/master.
1883
+ # Does NOT assume pnpm test or any other commands exist.
1884
+ #
1885
+ # Rules:
1886
+ # 1. BLOCK commits to main/master (use WU workflow instead)
1887
+ # 2. ALLOW commits on lane branches (lane/*/wu-*)
1888
+ # 3. ALLOW commits on tmp/* branches (CLI micro-worktrees)
1889
+ #
1890
+
1891
+ # Skip on tmp/* branches (CLI micro-worktrees)
1892
+ BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
1893
+ case "$BRANCH" in tmp/*) exit 0 ;; esac
1894
+
1895
+ # Check for force bypass
1896
+ if [ "$LUMENFLOW_FORCE" = "1" ]; then
1897
+ exit 0
1898
+ fi
1899
+
1900
+ # Block direct commits to main/master
1901
+ case "$BRANCH" in
1902
+ main|master)
1903
+ echo "" >&2
1904
+ echo "=== DIRECT COMMIT TO \${BRANCH} BLOCKED ===" >&2
1905
+ echo "" >&2
1906
+ echo "LumenFlow protects main from direct commits." >&2
1907
+ echo "" >&2
1908
+ echo "USE INSTEAD:" >&2
1909
+ echo " pnpm wu:claim --id WU-XXXX --lane \\"<Lane>\\"" >&2
1910
+ echo " cd worktrees/<lane>-wu-xxxx" >&2
1911
+ echo " # Make commits in the worktree" >&2
1912
+ echo "" >&2
1913
+ echo "EMERGENCY BYPASS (logged):" >&2
1914
+ echo " LUMENFLOW_FORCE=1 git commit ..." >&2
1915
+ echo "==========================================" >&2
1916
+ exit 1
1917
+ ;;
1918
+ esac
1919
+
1920
+ # Allow commits on other branches
1921
+ exit 0
1922
+ `;
1923
+ export const GATE_STUB_SCRIPTS = {
1924
+ 'spec:linter': 'echo "[lumenflow] spec:linter stub -- install a WU spec linter or replace this script" && exit 0',
1925
+ lint: 'echo "[lumenflow] lint stub -- add ESLint or your preferred linter to enable this gate (e.g. eslint .)" && exit 0',
1926
+ typecheck: 'echo "[lumenflow] typecheck stub -- add TypeScript or your type checker to enable this gate (e.g. tsc --noEmit)" && exit 0',
1927
+ };
1928
+ //# sourceMappingURL=init-templates.js.map