@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
@@ -8,17 +8,18 @@ LumenFlow is a vendor-agnostic workflow framework for AI-native software develop
8
8
 
9
9
  ---
10
10
 
11
- ## Critical Rule: ALWAYS Run wu:done
11
+ ## Critical Rule: Use wu:prep Then wu:done
12
12
 
13
- **After completing work on a WU, you MUST run `pnpm wu:done --id WU-XXXX` from the main checkout.**
13
+ **WU-1223 NEW WORKFLOW:**
14
14
 
15
- This is the single most forgotten step. Do NOT:
15
+ 1. From worktree: `pnpm wu:prep --id WU-XXXX` (runs gates, prints copy-paste instruction)
16
+ 2. From main: `pnpm wu:done --id WU-XXXX` (merge + cleanup only)
16
17
 
17
- - Write "To Complete: pnpm wu:done" and stop
18
- - Ask if you should run wu:done
19
- - Forget to run wu:done
18
+ **DO NOT:**
20
19
 
21
- **DO**: Run `pnpm wu:done --id WU-XXXX` immediately after gates pass.
20
+ - Run `wu:done` from a worktree (it will error)
21
+ - Forget to run `wu:done` after `wu:prep`
22
+ - Skip `wu:prep` and go directly to `wu:done` (gates won't run in worktree)
22
23
 
23
24
  See: [docs/04-operations/\_frameworks/lumenflow/agent/onboarding/troubleshooting-wu-done.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/troubleshooting-wu-done.md)
24
25
 
@@ -30,8 +31,8 @@ See: [docs/04-operations/\_frameworks/lumenflow/agent/onboarding/troubleshooting
30
31
  # 1. Setup (first time only)
31
32
  pnpm setup
32
33
 
33
- # 2. Create a WU (default: creates spec/wu-xxxx branch, never writes to main)
34
- pnpm wu:create --id WU-XXXX --lane <Lane> --title "Title" \
34
+ # 2. Create a WU (--id is optional, auto-generates next sequential ID if omitted)
35
+ pnpm wu:create --lane <Lane> --title "Title" \
35
36
  --description "..." --acceptance "..." --code-paths "..." \
36
37
  --test-paths-unit "..." --exposure backend-only \
37
38
  --spec-refs "lumenflow://plans/WU-XXXX-plan.md"
@@ -42,15 +43,49 @@ cd worktrees/<lane>-wu-xxxx
42
43
 
43
44
  # 4. Implement in worktree
44
45
 
45
- # 5. Run gates
46
- pnpm gates --docs-only # for docs changes
47
- pnpm gates # for code changes
46
+ # 5. Prepare (runs gates in worktree) - WU-1223 NEW
47
+ pnpm wu:prep --id WU-XXXX
48
+ # This prints a copy-paste instruction for the next step
48
49
 
49
- # 6. Complete (from main checkout)
50
- cd /path/to/main
51
- pnpm wu:done --id WU-XXXX
50
+ # 6. Complete (from main checkout - copy-paste from wu:prep output)
51
+ cd /path/to/main && pnpm wu:done --id WU-XXXX
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Setup Notes (Common First-Run Failures)
57
+
58
+ ### Lane inference (sub-lanes)
59
+
60
+ If you use sub-lanes like `Experience: UI`, you must have a lane taxonomy:
61
+
62
+ - Ensure `.lumenflow.lane-inference.yaml` exists, or
63
+ - Generate it with `pnpm lane:suggest --output .lumenflow.lane-inference.yaml`
64
+
65
+ Without this file, sub-lane validation will fail.
66
+
67
+ ### Local-only / no remote
68
+
69
+ By default, `wu:create` expects an `origin` remote and will fetch `origin/main`.
70
+
71
+ For local-only or offline development, add this to `.lumenflow.config.yaml`:
72
+
73
+ ```yaml
74
+ git:
75
+ requireRemote: false
52
76
  ```
53
77
 
78
+ When `requireRemote: false`:
79
+
80
+ - `wu:create` skips remote fetch operations
81
+ - `wu:claim` works without pushing to origin
82
+ - Useful for air-gapped environments, testing/evaluation, or pre-remote development
83
+
84
+ When `requireRemote: true` (default):
85
+
86
+ - Operations fail with a clear error if no `origin` remote exists
87
+ - Ensures team visibility via remote branches
88
+
54
89
  ---
55
90
 
56
91
  ## Core Principles
@@ -66,6 +101,18 @@ pnpm wu:done --id WU-XXXX
66
101
 
67
102
  ---
68
103
 
104
+ ## Universal Agent Safety (WU-1170)
105
+
106
+ LumenFlow enforces safety at the repository level so protections apply to all agents and humans.
107
+
108
+ - **Git wrapper**: `scripts/safe-git` blocks destructive operations (e.g. `worktree remove`, `reset --hard`, `clean -fd`, `push --force`).
109
+ - **Husky hooks**: staged secret scanning, absolute-path scanning, lockfile sync, and worktree discipline.
110
+ - **Audit logs**:
111
+ - `.beacon/safety-blocks.log`
112
+ - `.beacon/force-bypasses.log`
113
+
114
+ ---
115
+
69
116
  ## Global State
70
117
 
71
118
  Canonical global state is defined by:
@@ -83,17 +130,31 @@ air-gapped/offline work; it creates a local-only claim and warns explicitly.
83
130
 
84
131
  ### Core (Vendor-Agnostic)
85
132
 
86
- - **LUMENFLOW.md** - This file, main entry point
133
+ - **AGENTS.md** - Universal entry point for AI agents (Codex, Cursor, Windsurf)
134
+ - **LUMENFLOW.md** - This file, main workflow documentation
87
135
  - **.lumenflow/constraints.md** - Non-negotiable workflow constraints
88
136
  - **.lumenflow/rules/** - Workflow rules (git-safety.md, wu-workflow.md, etc.)
89
137
  - **docs/04-operations/\_frameworks/lumenflow/agent/onboarding/** - Agent onboarding documentation
90
138
 
91
- ### Vendor Integrations
139
+ ### Client/Vendor Overlays
140
+
141
+ - **CLAUDE.md** - Claude Code overlay (single file at root)
142
+ - **.claude/** - Claude Code settings, hooks, skills, agents
143
+ - **.cursor/rules/lumenflow.md** - Cursor rules overlay
144
+ - **.windsurf/rules/lumenflow.md** - Windsurf rules overlay
145
+
146
+ Use `lumenflow init --client <type>` to generate client-specific files:
147
+
148
+ ```bash
149
+ lumenflow init # Creates AGENTS.md + LUMENFLOW.md (universal)
150
+ lumenflow init --client claude # + CLAUDE.md, .claude/
151
+ lumenflow init --client cursor # + .cursor/rules/lumenflow.md
152
+ lumenflow init --client windsurf # + .windsurf/rules/lumenflow.md
153
+ lumenflow init --client all # All of the above
154
+ lumenflow init --merge # Safe merge into existing files
155
+ ```
92
156
 
93
- - **.claude/** - Claude Code (settings.json, hooks, .claude/CLAUDE.md)
94
- - **.cursor/** - Cursor (rules, settings)
95
- - **.aider.conf.yml** - Aider configuration
96
- - **.continue/** - Continue configuration
157
+ The `--merge` flag uses bounded markers (`LUMENFLOW:START`/`END`) to safely insert or update LumenFlow config in existing files without overwriting user content.
97
158
 
98
159
  ---
99
160
 
@@ -131,7 +192,7 @@ Main checkout becomes read-only after claim. Hooks will block WU commits from ma
131
192
 
132
193
  ## Core Commands
133
194
 
134
- > **Complete CLI reference (60+ commands):** See [quick-ref-commands.md](ai/onboarding/quick-ref-commands.md)
195
+ > **Complete CLI reference (60+ commands):** See [quick-ref-commands.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/quick-ref-commands.md)
135
196
 
136
197
  | Command | Description |
137
198
  | ------------------------------- | ------------------------------------------------------ |
@@ -161,7 +222,7 @@ When validation fails, commands provide copy-paste ready fix commands:
161
222
  ERROR: WRONG_LOCATION - wu:done must be run from main checkout
162
223
 
163
224
  FIX: Run this command:
164
- cd {{PROJECT_ROOT}} && pnpm wu:done --id WU-1090
225
+ cd <repo-root> && pnpm wu:done --id WU-1090
165
226
  ```
166
227
 
167
228
  Configure validation behavior in `.lumenflow.config.yaml`:
@@ -210,6 +271,7 @@ If you're an AI agent, read the onboarding docs:
210
271
  2. [docs/04-operations/\_frameworks/lumenflow/agent/onboarding/first-wu-mistakes.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/first-wu-mistakes.md) - First WU pitfalls
211
272
  3. [docs/04-operations/\_frameworks/lumenflow/agent/onboarding/agent-safety-card.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/agent-safety-card.md) - Safety guardrails
212
273
  4. [docs/04-operations/\_frameworks/lumenflow/agent/onboarding/quick-ref-commands.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/quick-ref-commands.md) - Command reference
274
+ 5. [docs/04-operations/\_frameworks/lumenflow/agent/onboarding/test-ratchet.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/test-ratchet.md) - Test baseline ratchet pattern
213
275
 
214
276
  ---
215
277
 
@@ -0,0 +1,157 @@
1
+ # Agent Invocation Guide (LumenFlow)
2
+
3
+ **Last updated:** {{DATE}}
4
+
5
+ This guide defines how to spawn and brief sub-agents so they start with the right context,
6
+ follow LumenFlow constraints, and leave durable artifacts for handoff.
7
+
8
+ Use this document when:
9
+
10
+ - Spawning sub-agents or parallel WUs
11
+ - Writing orchestrator prompts
12
+ - Starting a new session after `/clear`
13
+ - Coordinating multi-wave initiatives
14
+
15
+ ---
16
+
17
+ ## 1) Context Tiers (Load Order)
18
+
19
+ Load context in this order to reduce "lost in the middle" failures:
20
+
21
+ 1. `LUMENFLOW.md` — workflow fundamentals
22
+ 2. `README.md` — repo structure / commands
23
+ 3. `lumenflow-complete.md` §§1-7 — constraints + governance
24
+ 4. WU YAML — current task spec
25
+ 5. Task instructions — what to do
26
+ 6. **Critical Constraints block** — append at the end (see below)
27
+
28
+ **Tier guidance:**
29
+
30
+ - **Tier 1 (minimal):** `LUMENFLOW.md`, `README.md`, WU YAML
31
+ - **Tier 2 (standard):** Tier 1 + `lumenflow-complete.md` §§1-7
32
+ - **Tier 3 (full):** Tier 2 + relevant framework/agent docs
33
+
34
+ Use Tier 1 after `/clear` to stay lean, then load more only if needed.
35
+
36
+ ---
37
+
38
+ ## 2) Session Management (Spawn Fresh)
39
+
40
+ When approaching context limits, **spawn a fresh agent instead of compaction**.
41
+ The spawn prompt is the bridge between sessions.
42
+
43
+ **Mandatory triggers:**
44
+
45
+ - Context usage >80%
46
+ - 50+ tool calls
47
+ - Performance degradation (forgotten context, redundant queries)
48
+ - About to run `/compact` or `/clear`
49
+
50
+ **Spawn fresh protocol:**
51
+
52
+ ```bash
53
+ pnpm mem:checkpoint "Progress: completed X, next: Y" --wu WU-XXX
54
+ git add -A && git commit -m "checkpoint: progress on X"
55
+ git push origin lane/<lane>/wu-xxx
56
+ pnpm wu:spawn --id WU-XXX
57
+ # Exit current session; start fresh with the generated prompt.
58
+ ```
59
+
60
+ **Optional safety net:** If your client supports hooks, add a pre-clear checkpoint hook:
61
+
62
+ ```bash
63
+ pnpm mem:checkpoint "Pre-clear: <summary>" --wu WU-XXX --trigger pre-clear
64
+ ```
65
+
66
+ ---
67
+
68
+ ## 2a) Memory Context Injection (Automatic)
69
+
70
+ When the memory layer is initialized (`memory.jsonl` exists), `wu:spawn` automatically
71
+ injects relevant memory context into the spawn prompt under a `## Memory Context` section.
72
+
73
+ **What gets included:**
74
+
75
+ - WU-specific checkpoints and notes
76
+ - Project-level architectural decisions
77
+ - Recent context relevant to the lane
78
+
79
+ **Configuration:**
80
+
81
+ Configure max context size in `.lumenflow.config.yaml`:
82
+
83
+ ```yaml
84
+ memory:
85
+ spawn_context_max_size: 4096 # Default: 4KB
86
+ ```
87
+
88
+ **Skip context injection:**
89
+
90
+ Use `--no-context` when you want a clean spawn without memory context:
91
+
92
+ ```bash
93
+ pnpm wu:spawn --id WU-XXX --no-context
94
+ ```
95
+
96
+ This is useful when:
97
+
98
+ - Starting completely fresh without prior context
99
+ - Debugging context-related issues
100
+ - Memory layer contains stale or irrelevant data
101
+
102
+ ---
103
+
104
+ ## 3) Spawn Prompt Structure (Recommended)
105
+
106
+ Use this structure for sub-agent prompts:
107
+
108
+ 1. **Objective** — clear, single outcome
109
+ 2. **Scope** — what is in/out of scope
110
+ 3. **Code Paths** — allowed paths (from WU `code_paths`)
111
+ 4. **Tests/Gates** — required checks
112
+ 5. **Progress Artifacts** — checkpoints, commits, signals
113
+ 6. **Recovery** — what to do if blocked
114
+ 7. **Critical Constraints** — append at the end
115
+
116
+ ---
117
+
118
+ ## 4) Append These Constraints at the End (Mandatory)
119
+
120
+ Paste this block at the end of every multi-agent prompt:
121
+
122
+ ```
123
+ CRITICAL CONSTRAINTS (append at end, do not omit):
124
+ 1) Work only in worktrees after wu:claim; main is read-only for WU work.
125
+ 2) Never bypass hooks (--no-verify, HUSKY=0). Fix root causes instead.
126
+ 3) WUs are specs, not code; stay within code_paths.
127
+ 4) Run correct gates before wu:done (docs-only vs full).
128
+ 5) Use LLM-first inference; avoid brittle regex/keyword shortcuts.
129
+ 6) If uncertain about safety, stop and ask.
130
+ ```
131
+
132
+ For full details, see `.lumenflow/constraints.md`.
133
+
134
+ ---
135
+
136
+ ## 5) Coordination Checklist (Orchestrators)
137
+
138
+ Before spawning:
139
+
140
+ - Confirm WU status and lane availability
141
+ - Ensure worktree exists (or claim first)
142
+ - Provide explicit code_paths and tests
143
+ - Require `mem:checkpoint` at 50+ tool calls
144
+ - Require `mem:signal` for milestones
145
+
146
+ After spawning:
147
+
148
+ - Monitor with `pnpm mem:inbox --since 30m`
149
+ - Use `pnpm mem:ready --wu WU-XXX` for handoff status
150
+
151
+ ---
152
+
153
+ ## 6) Related Skills
154
+
155
+ - `.claude/skills/context-management/SKILL.md`
156
+ - `.claude/skills/multi-agent-coordination/SKILL.md`
157
+ - `.claude/skills/execution-memory/SKILL.md`
@@ -44,6 +44,35 @@ Quick reference for AI agents working in LumenFlow projects.
44
44
 
45
45
  ---
46
46
 
47
+ ## Universal Safety Mechanisms
48
+
49
+ ### Git Safety Wrapper
50
+
51
+ Use `scripts/safe-git` instead of system `git` when possible.
52
+
53
+ It blocks:
54
+
55
+ - `git worktree remove`
56
+ - `git reset --hard`
57
+ - `git clean -fd`
58
+ - `git push --force`
59
+
60
+ ### Repo Hooks (Husky)
61
+
62
+ These run for everyone:
63
+
64
+ - Secret scanning on staged content
65
+ - Absolute path scanning on staged content
66
+ - Lockfile sync checks
67
+ - Worktree discipline checks
68
+
69
+ Audit logs:
70
+
71
+ - `.beacon/safety-blocks.log` (blocked safety actions)
72
+ - `.beacon/force-bypasses.log` (LUMENFLOW_FORCE bypasses)
73
+
74
+ ---
75
+
47
76
  ## Error Handling
48
77
 
49
78
  ### Max 3 Attempts
@@ -104,3 +133,201 @@ Choose the safer path:
104
133
  - Don't bypass hooks
105
134
  - Don't skip gates
106
135
  - Ask rather than assume
136
+
137
+ ---
138
+
139
+ ## Emergency Override (LUMENFLOW_FORCE)
140
+
141
+ In rare cases, you may need to bypass safety mechanisms. This requires explicit user approval and creates an audit trail.
142
+
143
+ ### When Emergency Override is Appropriate
144
+
145
+ - Fixing YAML parsing bugs in WU specs (spec infrastructure issue)
146
+ - Emergency production hotfixes (with user present)
147
+ - Recovering from corrupted workflow state
148
+ - Bootstrap operations when CLI not yet built
149
+
150
+ ### When NOT to Use Emergency Override
151
+
152
+ - Skipping failing tests
153
+ - Avoiding code review
154
+ - Working around gate failures
155
+ - Convenience or speed
156
+
157
+ ### How to Use LUMENFLOW_FORCE
158
+
159
+ **Step 1: Get user approval**
160
+
161
+ Agents MUST stop and ask before using LUMENFLOW_FORCE. Present the situation to the user:
162
+
163
+ ```
164
+ I need to bypass the safety check for [reason].
165
+ This will be logged to .beacon/force-bypasses.log.
166
+ Do you approve? (yes/no)
167
+ ```
168
+
169
+ **Step 2: Execute with audit trail**
170
+
171
+ ```bash
172
+ # With reason (preferred)
173
+ LUMENFLOW_FORCE_REASON="user-approved: <reason>" LUMENFLOW_FORCE=1 git <command>
174
+
175
+ # Example: bypass safe-git for reset --hard
176
+ LUMENFLOW_FORCE_REASON="user-approved: recovering corrupted state" LUMENFLOW_FORCE=1 git reset --hard HEAD
177
+
178
+ # Example: bypass hook for commit
179
+ LUMENFLOW_FORCE_REASON="user-approved: false positive secret detection" LUMENFLOW_FORCE=1 git commit -m "fix: update config"
180
+ ```
181
+
182
+ **Step 3: Document in WU notes**
183
+
184
+ Add a note to the WU YAML explaining the bypass:
185
+
186
+ ```yaml
187
+ notes: |
188
+ Used LUMENFLOW_FORCE to bypass [mechanism] because [reason].
189
+ Approved by user at [timestamp].
190
+ ```
191
+
192
+ ### Audit Log Format
193
+
194
+ All bypasses are logged to `.beacon/force-bypasses.log`:
195
+
196
+ ```
197
+ ISO_TIMESTAMP|BYPASSED|COMMAND_OR_HOOK|USER|BRANCH|REASON|CWD
198
+ ```
199
+
200
+ Example:
201
+
202
+ ```
203
+ {{DATE}}T12:34:56Z|BYPASSED|git reset --hard HEAD|tom|lane/core/wu-1172|user-approved: recovering state|/home/tom/source/project
204
+ ```
205
+
206
+ ### Warning When No Reason Provided
207
+
208
+ If LUMENFLOW_FORCE=1 is used without LUMENFLOW_FORCE_REASON, a warning is printed:
209
+
210
+ ```
211
+ === LUMENFLOW FORCE WARNING ===
212
+ LUMENFLOW_FORCE used without LUMENFLOW_FORCE_REASON.
213
+ Please provide a reason for audit trail:
214
+ LUMENFLOW_FORCE_REASON="your reason" LUMENFLOW_FORCE=1 git ...
215
+ ===============================
216
+ ```
217
+
218
+ The command still proceeds, but "NO_REASON" is logged.
219
+
220
+ ---
221
+
222
+ ## Task Tool Hook Limitation (WU-1282)
223
+
224
+ **Critical**: Claude Code's Task tool spawns sub-agents in a new session that does NOT inherit PreToolUse hooks from `.claude/settings.json`.
225
+
226
+ ### What This Means
227
+
228
+ When you spawn a sub-agent via Task tool:
229
+
230
+ - The sub-agent runs in a fresh context
231
+ - PreToolUse hooks (like `validate-worktree-path.sh`) do NOT run
232
+ - Sub-agents can write to main checkout even when worktrees exist
233
+
234
+ ### Workaround for Sub-Agents
235
+
236
+ Sub-agents MUST manually verify worktree discipline before any Write/Edit:
237
+
238
+ ```bash
239
+ # BEFORE any file operation, verify location
240
+ pwd
241
+ # Must show: /path/to/repo/worktrees/<lane>-wu-xxx
242
+
243
+ # If not in worktree, navigate first
244
+ cd worktrees/<lane>-wu-xxx
245
+ ```
246
+
247
+ ### For Orchestrators
248
+
249
+ When spawning sub-agents via `pnpm wu:spawn`:
250
+
251
+ 1. The spawn prompt includes constraint #9 (WORKTREE DISCIPLINE)
252
+ 2. Sub-agents are instructed to manually verify worktree location
253
+ 3. This constraint compensates for the missing hook enforcement
254
+
255
+ ### Root Cause
256
+
257
+ This is a Claude Code platform limitation, not a LumenFlow bug. Hooks defined in `.claude/settings.json` only apply to the parent session that loaded the settings file. Task-spawned sub-agents start fresh sessions without hook inheritance.
258
+
259
+ ---
260
+
261
+ ## Setup and Verification
262
+
263
+ ### Claude Code
264
+
265
+ Claude Code automatically respects LumenFlow safety through:
266
+
267
+ 1. **CLAUDE.md** - Entry point that references safety rules
268
+ 2. **.claude/skills/** - Skills include safety context
269
+ 3. **.claude/agents/** - Agent definitions include constraints
270
+
271
+ No additional setup required. Claude Code will read these files on startup.
272
+
273
+ ### Cursor
274
+
275
+ Cursor uses `.cursor/rules/lumenflow.md` for safety rules.
276
+
277
+ **Setup:**
278
+
279
+ ```bash
280
+ # Initialize LumenFlow with Cursor overlay
281
+ lumenflow init --client cursor
282
+
283
+ # Or add to existing project
284
+ mkdir -p .cursor/rules
285
+ # Copy lumenflow.md template to .cursor/rules/
286
+ ```
287
+
288
+ **Verification:**
289
+
290
+ 1. Open a file in Cursor
291
+ 2. Start a chat with Cursor AI
292
+ 3. Ask: "What are the LumenFlow safety rules?"
293
+ 4. Verify it mentions: worktree discipline, forbidden git commands, LUMENFLOW_FORCE
294
+
295
+ ### Windsurf
296
+
297
+ Windsurf uses `.windsurf/rules/lumenflow.md` for safety rules.
298
+
299
+ **Setup:**
300
+
301
+ ```bash
302
+ # Initialize LumenFlow with Windsurf overlay
303
+ lumenflow init --client windsurf
304
+
305
+ # Or add to existing project
306
+ mkdir -p .windsurf/rules
307
+ # Copy lumenflow.md template to .windsurf/rules/
308
+ ```
309
+
310
+ **Verification:**
311
+
312
+ 1. Open project in Windsurf
313
+ 2. Start a Cascade session
314
+ 3. Ask: "What safety mechanisms does this project use?"
315
+ 4. Verify it mentions: safe-git wrapper, Husky hooks, audit logs
316
+
317
+ ### Manual Verification
318
+
319
+ Test that safety mechanisms work:
320
+
321
+ ```bash
322
+ # Verify safe-git blocks dangerous commands
323
+ ./scripts/safe-git reset --hard HEAD
324
+ # Should show: === LUMENFLOW SAFETY BLOCK ===
325
+
326
+ # Verify hooks are installed
327
+ ls -la .husky/
328
+ # Should show: pre-commit, commit-msg, etc.
329
+
330
+ # Verify bypass works with audit
331
+ LUMENFLOW_FORCE_REASON="testing" LUMENFLOW_FORCE=1 ./scripts/safe-git --version
332
+ # Should succeed and log to .beacon/force-bypasses.log
333
+ ```