@lumenflow/cli 2.2.1 → 2.3.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.
- package/README.md +147 -57
- package/dist/__tests__/agent-log-issue.test.js +56 -0
- package/dist/__tests__/cli-entry-point.test.js +66 -17
- package/dist/__tests__/cli-subprocess.test.js +25 -0
- package/dist/__tests__/init.test.js +298 -0
- package/dist/__tests__/initiative-plan.test.js +340 -0
- package/dist/__tests__/mem-cleanup-execution.test.js +19 -0
- package/dist/__tests__/merge-block.test.js +220 -0
- package/dist/__tests__/release.test.js +28 -0
- package/dist/__tests__/safe-git.test.js +191 -0
- package/dist/__tests__/state-doctor.test.js +274 -0
- package/dist/__tests__/wu-done.test.js +36 -0
- package/dist/__tests__/wu-edit.test.js +119 -0
- package/dist/__tests__/wu-prep.test.js +108 -0
- package/dist/agent-issues-query.js +4 -3
- package/dist/agent-log-issue.js +25 -4
- package/dist/backlog-prune.js +5 -4
- package/dist/cli-entry-point.js +11 -1
- package/dist/doctor.js +368 -0
- package/dist/flow-bottlenecks.js +6 -5
- package/dist/flow-report.js +4 -3
- package/dist/gates.js +468 -116
- package/dist/guard-locked.js +4 -3
- package/dist/guard-worktree-commit.js +4 -3
- package/dist/init.js +508 -86
- package/dist/initiative-add-wu.js +4 -3
- package/dist/initiative-bulk-assign-wus.js +8 -5
- package/dist/initiative-create.js +73 -37
- package/dist/initiative-edit.js +37 -21
- package/dist/initiative-list.js +4 -3
- package/dist/initiative-plan.js +337 -0
- package/dist/initiative-status.js +4 -3
- package/dist/lane-health.js +377 -0
- package/dist/lane-suggest.js +382 -0
- package/dist/mem-checkpoint.js +2 -2
- package/dist/mem-cleanup.js +2 -2
- package/dist/mem-context.js +306 -0
- package/dist/mem-create.js +2 -2
- package/dist/mem-delete.js +293 -0
- package/dist/mem-inbox.js +2 -2
- package/dist/mem-index.js +211 -0
- package/dist/mem-init.js +1 -1
- package/dist/mem-profile.js +207 -0
- package/dist/mem-promote.js +254 -0
- package/dist/mem-ready.js +2 -2
- package/dist/mem-signal.js +2 -2
- package/dist/mem-start.js +2 -2
- package/dist/mem-summarize.js +2 -2
- package/dist/mem-triage.js +2 -2
- package/dist/merge-block.js +222 -0
- package/dist/metrics-cli.js +7 -4
- package/dist/metrics-snapshot.js +4 -3
- package/dist/orchestrate-initiative.js +10 -4
- package/dist/orchestrate-monitor.js +379 -31
- package/dist/signal-cleanup.js +296 -0
- package/dist/spawn-list.js +6 -5
- package/dist/state-bootstrap.js +5 -4
- package/dist/state-cleanup.js +360 -0
- package/dist/state-doctor-fix.js +196 -0
- package/dist/state-doctor.js +501 -0
- package/dist/validate-agent-skills.js +4 -3
- package/dist/validate-agent-sync.js +4 -3
- package/dist/validate-backlog-sync.js +7 -84
- package/dist/validate-skills-spec.js +4 -3
- package/dist/validate.js +7 -107
- package/dist/wu-block.js +3 -3
- package/dist/wu-claim.js +208 -98
- package/dist/wu-cleanup.js +5 -4
- package/dist/wu-create.js +71 -46
- package/dist/wu-delete.js +88 -60
- package/dist/wu-deps.js +6 -5
- package/dist/wu-done-check.js +34 -0
- package/dist/wu-done.js +60 -24
- package/dist/wu-edit.js +63 -28
- package/dist/wu-infer-lane.js +7 -6
- package/dist/wu-preflight.js +23 -81
- package/dist/wu-prep.js +125 -0
- package/dist/wu-prune.js +4 -3
- package/dist/wu-recover.js +88 -22
- package/dist/wu-repair.js +7 -6
- package/dist/wu-spawn.js +226 -270
- package/dist/wu-status.js +4 -3
- package/dist/wu-unblock.js +5 -5
- package/dist/wu-unlock-lane.js +4 -3
- package/dist/wu-validate.js +5 -4
- package/package.json +16 -7
- package/templates/core/.lumenflow/constraints.md.template +192 -0
- package/templates/core/.lumenflow/rules/git-safety.md.template +27 -0
- package/templates/core/.lumenflow/rules/wu-workflow.md.template +48 -0
- package/templates/core/AGENTS.md.template +60 -0
- package/templates/core/LUMENFLOW.md.template +255 -0
- package/templates/core/UPGRADING.md.template +121 -0
- package/templates/core/ai/onboarding/agent-safety-card.md.template +106 -0
- package/templates/core/ai/onboarding/first-wu-mistakes.md.template +198 -0
- package/templates/core/ai/onboarding/quick-ref-commands.md.template +186 -0
- package/templates/core/ai/onboarding/release-process.md.template +362 -0
- package/templates/core/ai/onboarding/troubleshooting-wu-done.md.template +159 -0
- package/templates/core/ai/onboarding/wu-create-checklist.md.template +117 -0
- package/templates/vendors/aider/.aider.conf.yml.template +27 -0
- package/templates/vendors/claude/.claude/CLAUDE.md.template +52 -0
- package/templates/vendors/claude/.claude/settings.json.template +49 -0
- package/templates/vendors/claude/.claude/skills/bug-classification/SKILL.md.template +192 -0
- package/templates/vendors/claude/.claude/skills/code-quality/SKILL.md.template +152 -0
- package/templates/vendors/claude/.claude/skills/context-management/SKILL.md.template +155 -0
- package/templates/vendors/claude/.claude/skills/execution-memory/SKILL.md.template +304 -0
- package/templates/vendors/claude/.claude/skills/frontend-design/SKILL.md.template +131 -0
- package/templates/vendors/claude/.claude/skills/initiative-management/SKILL.md.template +164 -0
- package/templates/vendors/claude/.claude/skills/library-first/SKILL.md.template +98 -0
- package/templates/vendors/claude/.claude/skills/lumenflow-gates/SKILL.md.template +87 -0
- package/templates/vendors/claude/.claude/skills/multi-agent-coordination/SKILL.md.template +84 -0
- package/templates/vendors/claude/.claude/skills/ops-maintenance/SKILL.md.template +254 -0
- package/templates/vendors/claude/.claude/skills/orchestration/SKILL.md.template +189 -0
- package/templates/vendors/claude/.claude/skills/tdd-workflow/SKILL.md.template +139 -0
- package/templates/vendors/claude/.claude/skills/worktree-discipline/SKILL.md.template +138 -0
- package/templates/vendors/claude/.claude/skills/wu-lifecycle/SKILL.md.template +106 -0
- package/templates/vendors/cline/.clinerules.template +53 -0
- package/templates/vendors/cursor/.cursor/rules/lumenflow.md.template +34 -0
- package/templates/vendors/cursor/.cursor/rules.md.template +28 -0
- package/templates/vendors/windsurf/.windsurf/rules/lumenflow.md.template +34 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: orchestration
|
|
3
|
+
description: Agent orchestration dashboard and initiative execution. Use when running initiatives, monitoring spawned agents, or debugging stuck spawns.
|
|
4
|
+
version: 2.4.0
|
|
5
|
+
source: packages/@lumenflow/cli/src/orchestrate.ts
|
|
6
|
+
last_updated: {{DATE}}
|
|
7
|
+
allowed-tools: Read, Bash, Grep
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Agent Orchestration Skill
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
Activate this skill when:
|
|
15
|
+
|
|
16
|
+
- Running multi-WU initiatives (`pnpm orchestrate:initiative`)
|
|
17
|
+
- Monitoring spawned agents for stuck/crashed states
|
|
18
|
+
- Debugging spawn failures or zombie lane locks
|
|
19
|
+
|
|
20
|
+
**Use skill first**: Run `pnpm orchestrate:monitor` and `pnpm orchestrate:init-status -i <initiative-id>`.
|
|
21
|
+
|
|
22
|
+
## ⛔ MANDATORY: Never Spawn Task Agents Directly
|
|
23
|
+
|
|
24
|
+
**CRITICAL PROHIBITION:** When delegating WUs to sub-agents, you MUST use the proper tooling:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# ✅ CORRECT: Use orchestrate:initiative for initiatives
|
|
28
|
+
pnpm orchestrate:initiative --initiative INIT-XXX
|
|
29
|
+
|
|
30
|
+
# ✅ CORRECT: Use wu:spawn for individual WUs
|
|
31
|
+
pnpm wu:spawn --id WU-XXX
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**❌ NEVER do this:**
|
|
35
|
+
|
|
36
|
+
- Directly invoke Task tool for WU execution without using wu:spawn output
|
|
37
|
+
- Manually craft spawn prompts (they miss context loading, TDD directives, constraints)
|
|
38
|
+
- Skip wu:spawn when delegating entire WUs to sub-agents
|
|
39
|
+
|
|
40
|
+
**Why this matters:**
|
|
41
|
+
|
|
42
|
+
1. `wu:spawn` generates prompts with context loading preamble, TDD directives, and constraints block
|
|
43
|
+
2. Sub-agents need `wu:claim` (inside spawn prompts) to create proper lane locks and event tracking
|
|
44
|
+
3. Direct Task spawns bypass all safety mechanisms, coordination signals, and spawn registry tracking
|
|
45
|
+
|
|
46
|
+
**If you see agents running without proper worktree claims, STOP and investigate.**
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Commands
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Initiative status (compact progress view)
|
|
54
|
+
pnpm orchestrate:init-status -i INIT-001
|
|
55
|
+
|
|
56
|
+
# Initiative execution
|
|
57
|
+
pnpm orchestrate:initiative --initiative INIT-001 --dry-run # Show plan
|
|
58
|
+
pnpm orchestrate:initiative --initiative INIT-001 # Execute
|
|
59
|
+
pnpm orchestrate:initiative --initiative INIT-001 --progress # Progress only
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Monitoring Commands
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Monitor spawn registry for stuck agents (default: 30 min threshold)
|
|
66
|
+
pnpm orchestrate:monitor
|
|
67
|
+
|
|
68
|
+
# Custom threshold
|
|
69
|
+
pnpm orchestrate:monitor --threshold 60
|
|
70
|
+
|
|
71
|
+
# Filter to initiative
|
|
72
|
+
pnpm orchestrate:monitor --initiative INIT-001
|
|
73
|
+
|
|
74
|
+
# JSON output for scripting
|
|
75
|
+
pnpm orchestrate:monitor --json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Spawn Tree Visualisation
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# View spawn tree for a WU
|
|
82
|
+
pnpm spawn:list --wu WU-XXX
|
|
83
|
+
|
|
84
|
+
# View all spawns for an initiative
|
|
85
|
+
pnpm spawn:list --initiative INIT-001
|
|
86
|
+
|
|
87
|
+
# JSON output
|
|
88
|
+
pnpm spawn:list --wu WU-XXX --json
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Spawn states:** `pending`, `completed`, `timeout`, `crashed`, `escalated`
|
|
92
|
+
|
|
93
|
+
## Self-Healing Signal Flow
|
|
94
|
+
|
|
95
|
+
When spawns fail, the system uses agent-in-loop recovery:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
orchestrate:monitor
|
|
99
|
+
│
|
|
100
|
+
▼
|
|
101
|
+
detectStuckSpawns() ──► recoverStuckSpawn()
|
|
102
|
+
│
|
|
103
|
+
▼
|
|
104
|
+
[auto-recovery failed?]
|
|
105
|
+
│
|
|
106
|
+
▼
|
|
107
|
+
signalOrchestratorFailure()
|
|
108
|
+
│
|
|
109
|
+
┌───────────────┴───────────────┐
|
|
110
|
+
▼ ▼
|
|
111
|
+
mem:signal broadcast spawn status = ESCALATED
|
|
112
|
+
│
|
|
113
|
+
▼
|
|
114
|
+
ORCHESTRATOR INBOX
|
|
115
|
+
(agent-in-loop)
|
|
116
|
+
│
|
|
117
|
+
▼
|
|
118
|
+
[orchestrator decides]
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Escalation Levels:**
|
|
122
|
+
|
|
123
|
+
| Attempt | Severity | Action | Outcome |
|
|
124
|
+
| ------- | -------- | -------------- | --------------------------------------- |
|
|
125
|
+
| 1st | warning | retry | Re-spawn with same params |
|
|
126
|
+
| 2nd | error | block | Mark WU blocked, notify parallel agents |
|
|
127
|
+
| 3rd+ | critical | human_escalate | Create Bug WU, alert human |
|
|
128
|
+
|
|
129
|
+
**Check orchestrator inbox:**
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
pnpm mem:inbox --wu WU-XXX --type spawn_failure
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Initiative Orchestration
|
|
136
|
+
|
|
137
|
+
**Wave-based execution**:
|
|
138
|
+
|
|
139
|
+
- Groups WUs by dependency depth (Kahn's algorithm)
|
|
140
|
+
- Parallel spawning within waves
|
|
141
|
+
- Checkpoint mode auto-enabled for >3 WUs or >2 waves
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
pnpm orchestrate:initiative -i INIT-009 -c # Explicit checkpoint
|
|
145
|
+
pnpm orchestrate:initiative -i INIT-009 # Auto-detects
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Checkpoint mode**:
|
|
149
|
+
|
|
150
|
+
- Spawns one wave then exits (no polling)
|
|
151
|
+
- Writes manifest to `.beacon/artifacts/waves/`
|
|
152
|
+
- Idempotent re-runs advance to next wave
|
|
153
|
+
|
|
154
|
+
## Recovery Suggestions
|
|
155
|
+
|
|
156
|
+
When issues are detected, `orchestrate:monitor` outputs copy-pasteable commands:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# For stuck spawns
|
|
160
|
+
pnpm wu:block --id WU-XXX --reason "Spawn stuck for 45 minutes"
|
|
161
|
+
|
|
162
|
+
# For zombie lane locks
|
|
163
|
+
pnpm lane:unlock "Operations: Tooling" --reason "Zombie lock (PID 12345 not running)"
|
|
164
|
+
|
|
165
|
+
# After recovery, re-spawn
|
|
166
|
+
pnpm wu:unblock --id WU-XXX
|
|
167
|
+
pnpm wu:spawn --id WU-XXX
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Decision Tree
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
Starting WU?
|
|
174
|
+
├── Run: pnpm orchestrate:monitor
|
|
175
|
+
└── Review agent status and recommendations
|
|
176
|
+
|
|
177
|
+
Initiative with multiple WUs?
|
|
178
|
+
├── Run: pnpm orchestrate:initiative -i INIT-XXX --dry-run
|
|
179
|
+
└── Review wave plan, then execute
|
|
180
|
+
|
|
181
|
+
Agent appears stuck or crashed?
|
|
182
|
+
├── Run: pnpm orchestrate:monitor
|
|
183
|
+
├── Check spawn tree: pnpm spawn:list --wu WU-XXX
|
|
184
|
+
└── Follow recovery suggestions in output
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
**Full docs**: [execution-memory skill](../execution-memory/SKILL.md)
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tdd-workflow
|
|
3
|
+
description: Test-driven development workflow. RED-GREEN-REFACTOR applies to all code; 5-step ports-first for hex architecture. Use when implementing new features, writing tests, or working with hexagonal architecture.
|
|
4
|
+
version: 2.1.0
|
|
5
|
+
source: docs/04-operations/_frameworks/lumenflow/lumenflow-complete.md
|
|
6
|
+
source_sections: §5 (AI-TDD 5-Step Workflow), §4 (Hexagonal Architecture)
|
|
7
|
+
last_updated: {{DATE}}
|
|
8
|
+
allowed-tools: Read, Write, Edit, Bash, Grep
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# TDD Workflow Skill
|
|
12
|
+
|
|
13
|
+
**Source**: `docs/04-operations/_frameworks/lumenflow/lumenflow-complete.md` §5 (canonical)
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
Activate this skill when:
|
|
18
|
+
|
|
19
|
+
- Implementing new features (write tests first)
|
|
20
|
+
- Working with hexagonal architecture (ports-first pattern)
|
|
21
|
+
- Need to understand which layer code belongs in
|
|
22
|
+
- Writing use cases with dependency injection
|
|
23
|
+
|
|
24
|
+
**Use skill first**: Follow RED-GREEN-REFACTOR cycle and 5-step AI-TDD pattern.
|
|
25
|
+
|
|
26
|
+
**Spawn test-engineer agent when**: Complex test scenarios require golden dataset creation, VCR cassette setup needed, or coverage gaps require investigation.
|
|
27
|
+
|
|
28
|
+
## Universal TDD: RED-GREEN-REFACTOR
|
|
29
|
+
|
|
30
|
+
All code follows this cycle:
|
|
31
|
+
|
|
32
|
+
1. **RED**: Write failing test defining expected behaviour
|
|
33
|
+
2. **GREEN**: Write minimal code to pass
|
|
34
|
+
3. **REFACTOR**: Improve quality, keep tests green
|
|
35
|
+
|
|
36
|
+
**Coverage**: >= 90% for application code.
|
|
37
|
+
|
|
38
|
+
## 5-Step AI-TDD (Hex Architecture)
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
Step 1: Define Ports → @lumenflow/ports (interfaces only)
|
|
42
|
+
Step 2: Write Tests → @lumenflow/application/__tests__ (mocks)
|
|
43
|
+
Step 3: Implement → @lumenflow/application/usecases
|
|
44
|
+
Step 4: Run Tests → RED → GREEN
|
|
45
|
+
Step 5: Create Adapter → @lumenflow/infrastructure
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Architecture Boundaries
|
|
49
|
+
|
|
50
|
+
**Allowed**:
|
|
51
|
+
|
|
52
|
+
- Application → Ports (use interfaces)
|
|
53
|
+
- Infrastructure → Ports (implement interfaces)
|
|
54
|
+
- Apps → Application + Infrastructure (wiring)
|
|
55
|
+
|
|
56
|
+
**Forbidden**:
|
|
57
|
+
|
|
58
|
+
- Application → Infrastructure (blocked by ESLint)
|
|
59
|
+
|
|
60
|
+
## Dependency Injection Pattern
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// Use case accepts deps first, input second
|
|
64
|
+
export async function exampleUseCase(
|
|
65
|
+
deps: { service: ExampleService; observability: ObservabilityService },
|
|
66
|
+
input: { id: string },
|
|
67
|
+
): Promise<ServiceResponse<Result>> {
|
|
68
|
+
const span = deps.observability.startSpan('usecase.example');
|
|
69
|
+
try {
|
|
70
|
+
const result = await deps.service.doSomething(input);
|
|
71
|
+
span.end();
|
|
72
|
+
return result;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
deps.observability.recordError(error as Error);
|
|
75
|
+
span.end();
|
|
76
|
+
return { success: false, error: 'Operation failed', code: 'OPERATION_ERROR' };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Test Pattern
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
describe('exampleUseCase', () => {
|
|
85
|
+
let mockService: ExampleService;
|
|
86
|
+
|
|
87
|
+
beforeEach(() => {
|
|
88
|
+
mockService = { doSomething: vi.fn() };
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should handle happy path', async () => {
|
|
92
|
+
vi.mocked(mockService.doSomething).mockResolvedValue({ success: true, data: {} });
|
|
93
|
+
const result = await exampleUseCase({ service: mockService }, { id: '1' });
|
|
94
|
+
expect(result.success).toBe(true);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should handle errors', async () => {
|
|
98
|
+
vi.mocked(mockService.doSomething).mockRejectedValue(new Error('fail'));
|
|
99
|
+
const result = await exampleUseCase({ service: mockService }, { id: '1' });
|
|
100
|
+
expect(result.success).toBe(false);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Decision Trees
|
|
106
|
+
|
|
107
|
+
**Which Layer?**
|
|
108
|
+
|
|
109
|
+
- Interface definition → ports
|
|
110
|
+
- Business logic → application
|
|
111
|
+
- External services → infrastructure
|
|
112
|
+
- UI → apps
|
|
113
|
+
|
|
114
|
+
**Need a Port?**
|
|
115
|
+
|
|
116
|
+
- Testable with mocks? → YES
|
|
117
|
+
- Swappable implementation? → YES
|
|
118
|
+
- Pure utility? → NO
|
|
119
|
+
|
|
120
|
+
## Commands
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
pnpm test # Run all tests
|
|
124
|
+
pnpm test --filter <pkg> # Run tests for specific package
|
|
125
|
+
pnpm test -- --watch # Watch mode
|
|
126
|
+
pnpm test:coverage # Check coverage
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Definition of Done
|
|
130
|
+
|
|
131
|
+
- [ ] Ports defined
|
|
132
|
+
- [ ] Tests written BEFORE implementation
|
|
133
|
+
- [ ] Coverage >= 90%
|
|
134
|
+
- [ ] No application → infrastructure imports
|
|
135
|
+
- [ ] Gates pass
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
**Full spec**: [lumenflow-complete.md §5](../../../docs/04-operations/_frameworks/lumenflow/lumenflow-complete.md)
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: worktree-discipline
|
|
3
|
+
description: Prevents the "absolute path trap" in Write/Edit/Read tools. Use when working in worktrees, before file operations, or when changes don't appear in git status.
|
|
4
|
+
version: 2.0.0
|
|
5
|
+
source: docs/04-operations/_frameworks/lumenflow/lumenflow-complete.md
|
|
6
|
+
source_sections: §2.4 (Worktree Discipline), §4.1 (Tool Usage)
|
|
7
|
+
last_updated: {{DATE}}
|
|
8
|
+
allowed-tools: Read, Bash, Grep
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Worktree Discipline: Absolute Path Trap Prevention
|
|
12
|
+
|
|
13
|
+
**Purpose**: Prevent AI agents from bypassing worktree isolation via absolute file paths.
|
|
14
|
+
|
|
15
|
+
**For full worktree workflow**: See `wu-lifecycle` skill or `lumenflow-complete.md` §2.4.
|
|
16
|
+
|
|
17
|
+
## The Absolute Path Trap
|
|
18
|
+
|
|
19
|
+
**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.
|
|
20
|
+
|
|
21
|
+
### Example
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// Shell: cd worktrees/operations-wu-427
|
|
25
|
+
|
|
26
|
+
// WRONG - Absolute path bypasses worktree
|
|
27
|
+
Write({
|
|
28
|
+
file_path: '/home/user/source/project/apps/web/src/validator.ts',
|
|
29
|
+
content: '...',
|
|
30
|
+
});
|
|
31
|
+
// Result: Written to MAIN checkout, not worktree!
|
|
32
|
+
|
|
33
|
+
// RIGHT - Relative path respects worktree
|
|
34
|
+
Write({
|
|
35
|
+
file_path: 'apps/web/src/validator.ts',
|
|
36
|
+
content: '...',
|
|
37
|
+
});
|
|
38
|
+
// Result: Written to worktree correctly
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Pre-Operation Checklist
|
|
42
|
+
|
|
43
|
+
**Before ANY Write/Edit/Read operation:**
|
|
44
|
+
|
|
45
|
+
1. **Verify working directory**:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pwd
|
|
49
|
+
# Must show: .../worktrees/<lane>-wu-xxx
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
2. **Check file path format**:
|
|
53
|
+
|
|
54
|
+
| Pattern | Safe? | Example |
|
|
55
|
+
| --------------------------------- | ----- | ------------------------ |
|
|
56
|
+
| Starts with `/home/` or `/Users/` | NO | `/home/user/.../file.ts` |
|
|
57
|
+
| Contains full repo path | NO | `/source/project/...` |
|
|
58
|
+
| Starts with package name | YES | `apps/web/src/...` |
|
|
59
|
+
| Starts with `./` or `../` | YES | `./src/lib/...` |
|
|
60
|
+
| Just filename | YES | `README.md` |
|
|
61
|
+
|
|
62
|
+
3. **Use relative paths for ALL file operations**
|
|
63
|
+
|
|
64
|
+
## Quick Detection
|
|
65
|
+
|
|
66
|
+
**Red flags** (you're about to fall into the trap):
|
|
67
|
+
|
|
68
|
+
- Path starts with `/home/` or `/Users/`
|
|
69
|
+
- Path contains organisation/project name
|
|
70
|
+
- Path length > 50 characters (suspiciously long)
|
|
71
|
+
|
|
72
|
+
**Safe patterns**:
|
|
73
|
+
|
|
74
|
+
- `apps/web/src/...`
|
|
75
|
+
- `packages/@lumenflow/...`
|
|
76
|
+
- `tools/...`
|
|
77
|
+
- `docs/...`
|
|
78
|
+
|
|
79
|
+
## Troubleshooting
|
|
80
|
+
|
|
81
|
+
### "Changes not showing in git status"
|
|
82
|
+
|
|
83
|
+
**Cause**: Absolute paths wrote to main instead of worktree.
|
|
84
|
+
|
|
85
|
+
**Fix**:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Check where changes landed
|
|
89
|
+
cd /path/to/main && git status
|
|
90
|
+
|
|
91
|
+
# If changes are in main, move them
|
|
92
|
+
git stash
|
|
93
|
+
cd worktrees/<lane>-wu-xxx
|
|
94
|
+
git stash pop
|
|
95
|
+
|
|
96
|
+
# Re-apply with relative paths
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### "Pre-commit hook blocked my commit"
|
|
100
|
+
|
|
101
|
+
**Cause**: Attempted WU commit from main checkout.
|
|
102
|
+
|
|
103
|
+
**Fix**: Move to worktree, commit there:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
cd worktrees/<lane>-wu-xxx
|
|
107
|
+
git add . && git commit -m "..."
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Decision Tree
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
About to use Write/Edit/Read?
|
|
114
|
+
├─ Check: Am I in a worktree?
|
|
115
|
+
│ ├─ YES → Use RELATIVE paths only
|
|
116
|
+
│ └─ NO → Did I claim a WU?
|
|
117
|
+
│ ├─ YES → cd worktrees/<lane>-wu-xxx first
|
|
118
|
+
│ └─ NO → Claim WU or use docs-only paths
|
|
119
|
+
└─ Path starts with "/" ?
|
|
120
|
+
├─ YES → STOP! Convert to relative path
|
|
121
|
+
└─ NO → Safe to proceed
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Golden Rules
|
|
125
|
+
|
|
126
|
+
1. **Always verify pwd** before file operations
|
|
127
|
+
2. **Never use absolute paths** in Write/Edit/Read tools
|
|
128
|
+
3. **When in doubt, use relative paths**
|
|
129
|
+
|
|
130
|
+
## Cross-References
|
|
131
|
+
|
|
132
|
+
- **Full worktree workflow**: `wu-lifecycle` skill
|
|
133
|
+
- **Git command restrictions**: `lumenflow-complete.md` §2.4
|
|
134
|
+
|
|
135
|
+
## Version History
|
|
136
|
+
|
|
137
|
+
- **v2.0.0** ({{DATE}}): Refactored to focus on absolute path trap (per Anthropic one-capability-per-skill guideline)
|
|
138
|
+
- **v1.0.0** ({{DATE}}): Initial skill from lumenflow-complete.md
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wu-lifecycle
|
|
3
|
+
description: Work Unit claim/block/done workflow automation. Use when claiming WUs, blocking/unblocking, running wu:done, or understanding WU state transitions.
|
|
4
|
+
version: 2.1.0
|
|
5
|
+
source: docs/04-operations/_frameworks/lumenflow/lumenflow-complete.md
|
|
6
|
+
source_sections: §2.4, §6 (WU Lifecycle)
|
|
7
|
+
last_updated: {{DATE}}
|
|
8
|
+
allowed-tools: Read, Bash, Grep
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# WU Lifecycle Skill
|
|
12
|
+
|
|
13
|
+
**Source**: `docs/04-operations/_frameworks/lumenflow/lumenflow-complete.md` §2.4, §6 (canonical)
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
Activate this skill when:
|
|
18
|
+
|
|
19
|
+
- Claiming a WU (`pnpm wu:claim`)
|
|
20
|
+
- Blocking/unblocking WUs due to dependencies
|
|
21
|
+
- Running `wu:done` completion workflow
|
|
22
|
+
- Understanding WU state machine transitions
|
|
23
|
+
|
|
24
|
+
**Use skill first**: Follow the core commands and worktree discipline patterns.
|
|
25
|
+
|
|
26
|
+
**Spawn lumenflow-pm agent when**: WU lifecycle issues require investigation, coordination across multiple blocked WUs needed, or worktree state requires recovery.
|
|
27
|
+
|
|
28
|
+
## State Machine
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
ready → in_progress → waiting/blocked → done
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Core Commands
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Claim WU
|
|
38
|
+
pnpm wu:claim --id WU-XXX --lane <lane>
|
|
39
|
+
cd worktrees/<lane>-wu-xxx # IMMEDIATELY
|
|
40
|
+
|
|
41
|
+
# Complete WU (from main)
|
|
42
|
+
cd ../..
|
|
43
|
+
pnpm wu:done --id WU-XXX
|
|
44
|
+
|
|
45
|
+
# Block/Unblock
|
|
46
|
+
pnpm wu:block --id WU-XXX --reason "..."
|
|
47
|
+
pnpm wu:unblock --id WU-XXX
|
|
48
|
+
|
|
49
|
+
# Create (full spec)
|
|
50
|
+
pnpm wu:create --id WU-999 --lane "Operations" --title "Add feature" \
|
|
51
|
+
--description "Context: ... Problem: ... Solution: ..." \
|
|
52
|
+
--acceptance "Feature works" --code-paths "src/a.ts" --validate
|
|
53
|
+
|
|
54
|
+
# Edit spec
|
|
55
|
+
pnpm wu:edit --id WU-XXX --description "..." --acceptance "..."
|
|
56
|
+
|
|
57
|
+
# Maintenance
|
|
58
|
+
pnpm wu:prune --execute # Clean stale worktrees
|
|
59
|
+
pnpm wu:cleanup --id WU-XXX # After PR merge
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## wu:done Workflow
|
|
63
|
+
|
|
64
|
+
1. Runs gates in worktree
|
|
65
|
+
2. Fast-forward merge to main
|
|
66
|
+
3. Creates `.beacon/stamps/WU-XXX.done`
|
|
67
|
+
4. Updates backlog.md + status.md
|
|
68
|
+
5. Removes worktree
|
|
69
|
+
|
|
70
|
+
**GitHub rules REJECT merge commits**. Never `git merge` on main.
|
|
71
|
+
|
|
72
|
+
## Worktree Discipline
|
|
73
|
+
|
|
74
|
+
After `wu:claim`:
|
|
75
|
+
|
|
76
|
+
- `cd worktrees/<lane>-wu-xxx` immediately
|
|
77
|
+
- Use relative paths (never absolute)
|
|
78
|
+
- Main is read-only
|
|
79
|
+
|
|
80
|
+
**Blocked on main**: `reset --hard`, `stash`, `clean -fd`, manual merge
|
|
81
|
+
|
|
82
|
+
## Skip Gates (Emergency)
|
|
83
|
+
|
|
84
|
+
Only when pre-existing failures:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pnpm wu:done --id WU-XXX --skip-gates --reason "Pre-existing" --fix-wu WU-YYY
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Fix-in-Place vs Bug WU
|
|
91
|
+
|
|
92
|
+
**Create Bug WU if ANY true**:
|
|
93
|
+
|
|
94
|
+
- Bug in different `code_paths`
|
|
95
|
+
- Fix >10 lines
|
|
96
|
+
- Bug doesn't block acceptance criteria
|
|
97
|
+
|
|
98
|
+
**Fix in place if ALL true**:
|
|
99
|
+
|
|
100
|
+
- Bug blocks your acceptance criteria
|
|
101
|
+
- Bug in your `code_paths`
|
|
102
|
+
- Fix <=10 lines
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
**Full spec**: [lumenflow-complete.md](../../../docs/04-operations/_frameworks/lumenflow/lumenflow-complete.md)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Cline LumenFlow Rules
|
|
2
|
+
|
|
3
|
+
This project uses LumenFlow workflow. See [LUMENFLOW.md](LUMENFLOW.md) for complete documentation.
|
|
4
|
+
|
|
5
|
+
## Critical Rules
|
|
6
|
+
|
|
7
|
+
1. **Always run wu:done** - After gates pass, run `pnpm wu:done --id WU-XXX`
|
|
8
|
+
2. **Work in worktrees** - After `wu:claim`, work only in the worktree
|
|
9
|
+
3. **Never bypass hooks** - No `--no-verify`
|
|
10
|
+
4. **TDD** - Write tests first
|
|
11
|
+
|
|
12
|
+
## Forbidden Commands
|
|
13
|
+
|
|
14
|
+
- `git reset --hard`
|
|
15
|
+
- `git push --force`
|
|
16
|
+
- `git stash` (on main)
|
|
17
|
+
- `--no-verify`
|
|
18
|
+
|
|
19
|
+
## Quick Reference
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Claim WU
|
|
23
|
+
pnpm wu:claim --id WU-XXX --lane <Lane>
|
|
24
|
+
cd worktrees/<lane>-wu-xxx
|
|
25
|
+
|
|
26
|
+
# Run gates
|
|
27
|
+
pnpm gates
|
|
28
|
+
|
|
29
|
+
# Complete (from main)
|
|
30
|
+
cd {{PROJECT_ROOT}}
|
|
31
|
+
pnpm wu:done --id WU-XXX
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
> **Complete CLI reference (60+ commands):** See [quick-ref-commands.md](ai/onboarding/quick-ref-commands.md)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Workflow Summary
|
|
39
|
+
|
|
40
|
+
| Step | Command |
|
|
41
|
+
|------|---------|
|
|
42
|
+
| 1. Create WU | `pnpm wu:create --id WU-XXX ...` |
|
|
43
|
+
| 2. Claim | `pnpm wu:claim --id WU-XXX --lane <Lane>` |
|
|
44
|
+
| 3. Work | `cd worktrees/<lane>-wu-xxx` |
|
|
45
|
+
| 4. Gates | `pnpm gates` |
|
|
46
|
+
| 5. Complete | `pnpm wu:done --id WU-XXX` |
|
|
47
|
+
|
|
48
|
+
## Safety Reminders
|
|
49
|
+
|
|
50
|
+
- **Worktree Discipline**: After claiming a WU, immediately `cd` to the worktree
|
|
51
|
+
- **Main is read-only**: Do not edit files in the main checkout after claiming
|
|
52
|
+
- **Gates before done**: Always run `pnpm gates` before `wu:done`
|
|
53
|
+
- **Never skip hooks**: The `--no-verify` flag is forbidden
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Cursor LumenFlow Rules
|
|
2
|
+
|
|
3
|
+
This project uses LumenFlow workflow. See [LUMENFLOW.md](../../LUMENFLOW.md) for complete documentation.
|
|
4
|
+
|
|
5
|
+
## Critical Rules
|
|
6
|
+
|
|
7
|
+
1. **Always run wu:done** - After gates pass, run `pnpm wu:done --id WU-XXX`
|
|
8
|
+
2. **Work in worktrees** - After `wu:claim`, work only in the worktree
|
|
9
|
+
3. **Never bypass hooks** - No `--no-verify`
|
|
10
|
+
4. **TDD** - Write tests first
|
|
11
|
+
|
|
12
|
+
## Forbidden Commands
|
|
13
|
+
|
|
14
|
+
- `git reset --hard`
|
|
15
|
+
- `git push --force`
|
|
16
|
+
- `git stash` (on main)
|
|
17
|
+
- `--no-verify`
|
|
18
|
+
|
|
19
|
+
## Quick Reference
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Claim WU
|
|
23
|
+
pnpm wu:claim --id WU-XXX --lane <Lane>
|
|
24
|
+
cd worktrees/<lane>-wu-xxx
|
|
25
|
+
|
|
26
|
+
# Run gates
|
|
27
|
+
pnpm gates
|
|
28
|
+
|
|
29
|
+
# Complete (from main)
|
|
30
|
+
cd {{PROJECT_ROOT}}
|
|
31
|
+
pnpm wu:done --id WU-XXX
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
> **Complete CLI reference (60+ commands):** See [quick-ref-commands.md](../../ai/onboarding/quick-ref-commands.md)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Cursor Rules
|
|
2
|
+
|
|
3
|
+
This project uses LumenFlow workflow. See [LUMENFLOW.md](../LUMENFLOW.md).
|
|
4
|
+
|
|
5
|
+
## Critical Rules
|
|
6
|
+
|
|
7
|
+
1. **Always run wu:done** - After gates pass, run `pnpm wu:done --id WU-XXX`
|
|
8
|
+
2. **Work in worktrees** - After `wu:claim`, work only in the worktree
|
|
9
|
+
3. **Never bypass hooks** - No `--no-verify`
|
|
10
|
+
4. **TDD** - Write tests first
|
|
11
|
+
|
|
12
|
+
## Forbidden Commands
|
|
13
|
+
|
|
14
|
+
- `git reset --hard`
|
|
15
|
+
- `git push --force`
|
|
16
|
+
- `git stash` (on main)
|
|
17
|
+
- `--no-verify`
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm wu:claim --id WU-XXX --lane <Lane>
|
|
23
|
+
cd worktrees/<lane>-wu-xxx
|
|
24
|
+
# ... work ...
|
|
25
|
+
pnpm gates
|
|
26
|
+
cd {{PROJECT_ROOT}}
|
|
27
|
+
pnpm wu:done --id WU-XXX
|
|
28
|
+
```
|