opencodekit 0.20.5 → 0.20.6
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/dist/index.js +1 -1
- package/dist/template/.opencode/AGENTS.md +57 -0
- package/dist/template/.opencode/agent/build.md +82 -0
- package/dist/template/.opencode/agent/plan.md +22 -0
- package/dist/template/.opencode/agent/review.md +18 -0
- package/dist/template/.opencode/agent/scout.md +17 -0
- package/dist/template/.opencode/command/compound.md +24 -2
- package/dist/template/.opencode/command/create.md +54 -8
- package/dist/template/.opencode/command/explore.md +170 -0
- package/dist/template/.opencode/command/health.md +124 -2
- package/dist/template/.opencode/command/iterate.md +200 -0
- package/dist/template/.opencode/command/plan.md +63 -2
- package/dist/template/.opencode/memory/_templates/prd.md +16 -5
- package/dist/template/.opencode/memory.db +0 -0
- package/dist/template/.opencode/memory.db-shm +0 -0
- package/dist/template/.opencode/memory.db-wal +0 -0
- package/dist/template/.opencode/skill/reconcile/SKILL.md +183 -0
- package/dist/template/.opencode/skill/verification-before-completion/SKILL.md +75 -0
- package/package.json +1 -1
|
@@ -155,7 +155,129 @@ For each rule:
|
|
|
155
155
|
|
|
156
156
|
Flag rules with intent but no control as **IMPORTANT** gaps.
|
|
157
157
|
|
|
158
|
-
## Phase 5:
|
|
158
|
+
## Phase 5: AI Governance Audit
|
|
159
|
+
|
|
160
|
+
Audit AI-facing configuration for token efficiency, rule health, and instruction quality.
|
|
161
|
+
|
|
162
|
+
### 5a. Token Budget Estimation
|
|
163
|
+
|
|
164
|
+
Estimate the total token cost of context injected into each command execution:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Base context (always injected)
|
|
168
|
+
echo "=== Base Context ==="
|
|
169
|
+
wc -c AGENTS.md
|
|
170
|
+
wc -c .opencode/memory/project/user.md .opencode/memory/project/tech-stack.md .opencode/memory/project/project.md 2>/dev/null
|
|
171
|
+
echo "=== Agent Prompts ==="
|
|
172
|
+
wc -c .opencode/agent/*.md 2>/dev/null
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
For each command, estimate total context = Base + Agent prompt + Skills loaded:
|
|
176
|
+
|
|
177
|
+
| Command | Base | Agent | Skills Loaded | Est. Tokens | Budget |
|
|
178
|
+
| ------- | ---- | -------- | ------------------------------------------------------ | ----------- | ------------------ |
|
|
179
|
+
| `/ship` | [N] | build.md | beads, memory-grounding, workspace-setup, verification | [total] | [OK/HEAVY/BLOATED] |
|
|
180
|
+
| `/plan` | [N] | plan.md | beads, memory-grounding, writing-plans | [total] | [OK/HEAVY/BLOATED] |
|
|
181
|
+
| ... | ... | ... | ... | ... | ... |
|
|
182
|
+
|
|
183
|
+
**Thresholds:**
|
|
184
|
+
|
|
185
|
+
- **OK**: < 15k tokens total injected context
|
|
186
|
+
- **HEAVY**: 15-30k tokens (warn — leaves less room for codebase context)
|
|
187
|
+
- **BLOATED**: > 30k tokens (flag — likely causing quality degradation)
|
|
188
|
+
|
|
189
|
+
Rough token estimate: `bytes / 4` for English text.
|
|
190
|
+
|
|
191
|
+
### 5b. Rule Echo Detection
|
|
192
|
+
|
|
193
|
+
Find instructions duplicated across layers:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Find common instruction phrases across AGENTS.md and agent prompts
|
|
197
|
+
# Look for exact or near-duplicate paragraphs
|
|
198
|
+
grep -hF "Never" AGENTS.md .opencode/agent/*.md | sort | uniq -c | sort -rn | head -20
|
|
199
|
+
grep -hF "Always" AGENTS.md .opencode/agent/*.md | sort | uniq -c | sort -rn | head -20
|
|
200
|
+
grep -hF "MUST" AGENTS.md .opencode/agent/*.md | sort | uniq -c | sort -rn | head -20
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Also check for:
|
|
204
|
+
|
|
205
|
+
- Rules in AGENTS.md that are repeated verbatim in agent prompts (redundant — AGENTS.md is already injected)
|
|
206
|
+
- Rules in agent prompts that contradict AGENTS.md (dangerous)
|
|
207
|
+
- Rules in skills that duplicate AGENTS.md content (bloat)
|
|
208
|
+
|
|
209
|
+
Report:
|
|
210
|
+
|
|
211
|
+
| Rule Text (truncated) | Found In | Count | Issue |
|
|
212
|
+
| ----------------------- | ------------------- | ----- | --------------------------- |
|
|
213
|
+
| "Never force push main" | AGENTS.md, build.md | 2 | ECHO — remove from build.md |
|
|
214
|
+
| "Stage specific files" | AGENTS.md, ship.md | 2 | ECHO — remove from ship.md |
|
|
215
|
+
|
|
216
|
+
### 5c. Instruction Bloat Detection
|
|
217
|
+
|
|
218
|
+
Flag oversized configuration files:
|
|
219
|
+
|
|
220
|
+
| File | Lines | Tokens (est.) | Status |
|
|
221
|
+
| ---------------- | ----- | ------------- | ----------------- |
|
|
222
|
+
| AGENTS.md | [N] | [N] | [OK/WARN/BLOATED] |
|
|
223
|
+
| [skill]/SKILL.md | [N] | [N] | [OK/WARN/BLOATED] |
|
|
224
|
+
| [command].md | [N] | [N] | [OK/WARN/BLOATED] |
|
|
225
|
+
|
|
226
|
+
**Thresholds:**
|
|
227
|
+
|
|
228
|
+
- Skills: WARN > 200 lines, BLOATED > 400 lines
|
|
229
|
+
- Commands: WARN > 300 lines, BLOATED > 500 lines
|
|
230
|
+
- AGENTS.md: WARN > 500 lines, BLOATED > 800 lines
|
|
231
|
+
|
|
232
|
+
### 5d. Compression Opportunities
|
|
233
|
+
|
|
234
|
+
Identify repeated boilerplate across skills and commands:
|
|
235
|
+
|
|
236
|
+
````bash
|
|
237
|
+
# Find common blocks across skills
|
|
238
|
+
for f in .opencode/skill/*/SKILL.md; do
|
|
239
|
+
grep -c "## When to Use" "$f"
|
|
240
|
+
grep -c "## When NOT to Use" "$f"
|
|
241
|
+
done
|
|
242
|
+
|
|
243
|
+
# Find repeated code blocks
|
|
244
|
+
grep -rh "```typescript" .opencode/command/*.md | wc -l
|
|
245
|
+
grep -rh "skill({ name:" .opencode/command/*.md | sort | uniq -c | sort -rn | head -10
|
|
246
|
+
````
|
|
247
|
+
|
|
248
|
+
Flag opportunities:
|
|
249
|
+
|
|
250
|
+
- Skills that share >50% identical content (candidates for merging or shared base)
|
|
251
|
+
- Commands with identical boilerplate sections (candidates for shared template)
|
|
252
|
+
- Repeated `skill({ name: "X" })` calls across commands (consider making X a dependency)
|
|
253
|
+
|
|
254
|
+
### AI Governance Report
|
|
255
|
+
|
|
256
|
+
```text
|
|
257
|
+
## AI Governance Summary
|
|
258
|
+
|
|
259
|
+
Token Budget:
|
|
260
|
+
- Lightest command: [command] ([N] tokens)
|
|
261
|
+
- Heaviest command: [command] ([N] tokens)
|
|
262
|
+
- Commands over budget: [list]
|
|
263
|
+
|
|
264
|
+
Rule Health:
|
|
265
|
+
- Echo rules found: [N] (wasted tokens on duplicates)
|
|
266
|
+
- Contradictions found: [N] (CRITICAL)
|
|
267
|
+
- Compression opportunities: [N]
|
|
268
|
+
|
|
269
|
+
Instruction Bloat:
|
|
270
|
+
- Oversized skills: [N]
|
|
271
|
+
- Oversized commands: [N]
|
|
272
|
+
- AGENTS.md status: [OK/WARN/BLOATED]
|
|
273
|
+
|
|
274
|
+
Recommendations:
|
|
275
|
+
1. [Most impactful recommendation]
|
|
276
|
+
2. [Second recommendation]
|
|
277
|
+
3. [Third recommendation]
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Phase 6: Agent Tool Restriction Audit
|
|
159
281
|
|
|
160
282
|
For each agent in `.opencode/agent/*.md`:
|
|
161
283
|
|
|
@@ -170,7 +292,7 @@ Flag:
|
|
|
170
292
|
- **IMPORTANT**: Agents with no tool restrictions at all
|
|
171
293
|
- **MINOR**: Agents with restrictions that could be tighter
|
|
172
294
|
|
|
173
|
-
## Phase
|
|
295
|
+
## Phase 7: Report
|
|
174
296
|
|
|
175
297
|
Output a health report:
|
|
176
298
|
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Refine PRD mid-implementation when scope changes, discoveries emerge, or requirements pivot
|
|
3
|
+
argument-hint: "<bead-id> [--scope expand|reduce|pivot] [--reason <text>]"
|
|
4
|
+
agent: build
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Iterate: $ARGUMENTS
|
|
8
|
+
|
|
9
|
+
Refine a bead's PRD during active implementation. Two-phase process: define what changed, then update spec artifacts and re-derive affected tasks.
|
|
10
|
+
|
|
11
|
+
> **When to use:** Mid-`/ship` when you discover scope changed, requirements shifted, or a technical discovery invalidates the original plan.
|
|
12
|
+
>
|
|
13
|
+
> **NOT for:** Pre-implementation changes (use `/create` to rewrite the PRD) or post-implementation retrospectives (use `/compound`).
|
|
14
|
+
|
|
15
|
+
## Load Skills
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
skill({ name: "beads" });
|
|
19
|
+
skill({ name: "memory-grounding" });
|
|
20
|
+
skill({ name: "prd" });
|
|
21
|
+
skill({ name: "prd-task" });
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Parse Arguments
|
|
25
|
+
|
|
26
|
+
| Argument | Default | Description |
|
|
27
|
+
| ----------- | ------------- | ---------------------------------- |
|
|
28
|
+
| `<bead-id>` | required | The bead being iterated |
|
|
29
|
+
| `--scope` | auto-detected | Change type: expand, reduce, pivot |
|
|
30
|
+
| `--reason` | prompted | Why the change is needed |
|
|
31
|
+
|
|
32
|
+
## Before You Iterate
|
|
33
|
+
|
|
34
|
+
- **Be certain**: Only iterate if continuing with the current spec would produce wrong output
|
|
35
|
+
- **Don't over-iterate**: Minor adjustments don't need a full iterate cycle — just fix inline during `/ship`
|
|
36
|
+
- **Preserve progress**: Completed tasks stay completed unless explicitly invalidated
|
|
37
|
+
- **Document the delta**: Every change must be traceable to a reason
|
|
38
|
+
|
|
39
|
+
## Phase 1: Guards
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
br show $ARGUMENTS
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Read `.beads/artifacts/$ARGUMENTS/` to check what artifacts exist.
|
|
46
|
+
|
|
47
|
+
Verify:
|
|
48
|
+
|
|
49
|
+
- Bead is `in_progress`
|
|
50
|
+
- `prd.md` exists
|
|
51
|
+
- Implementation is partially complete (at least 1 task done or in-progress)
|
|
52
|
+
|
|
53
|
+
If no tasks are started yet, redirect: "Use `/create --spec-only` to rewrite the PRD instead."
|
|
54
|
+
|
|
55
|
+
## Phase 2: Assess Change Type
|
|
56
|
+
|
|
57
|
+
If `--scope` was not provided, determine the change type:
|
|
58
|
+
|
|
59
|
+
| Type | Signal | Example |
|
|
60
|
+
| ---------- | ------------------------------------------------------- | ----------------------------------------- |
|
|
61
|
+
| **expand** | New requirement discovered, additional files needed | "We also need to handle edge case X" |
|
|
62
|
+
| **reduce** | Feature is over-scoped, some tasks are unnecessary | "We don't need the admin panel after all" |
|
|
63
|
+
| **pivot** | Fundamental approach changed, different solution needed | "REST won't work, switching to WebSocket" |
|
|
64
|
+
|
|
65
|
+
Ask user to confirm:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
question({
|
|
69
|
+
questions: [
|
|
70
|
+
{
|
|
71
|
+
header: "Change Type",
|
|
72
|
+
question: "What kind of spec change is this?",
|
|
73
|
+
options: [
|
|
74
|
+
{ label: "Expand", description: "Adding scope — new requirements or files" },
|
|
75
|
+
{ label: "Reduce", description: "Removing scope — dropping unnecessary work" },
|
|
76
|
+
{ label: "Pivot", description: "Changing approach — different solution path" },
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Phase 3: Define the Delta
|
|
84
|
+
|
|
85
|
+
### Step 1: Capture the change reason
|
|
86
|
+
|
|
87
|
+
If `--reason` was not provided, ask:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
question({
|
|
91
|
+
questions: [
|
|
92
|
+
{
|
|
93
|
+
header: "Reason",
|
|
94
|
+
question: "What triggered this change? (Be specific — this goes into the PRD changelog)",
|
|
95
|
+
options: [],
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Step 2: Identify affected artifacts
|
|
102
|
+
|
|
103
|
+
Read the current PRD and list:
|
|
104
|
+
|
|
105
|
+
- **Tasks completed:** (preserve these unless pivot invalidates them)
|
|
106
|
+
- **Tasks in-progress:** (may need modification)
|
|
107
|
+
- **Tasks not started:** (may need modification, removal, or replacement)
|
|
108
|
+
- **New tasks needed:** (for expand/pivot)
|
|
109
|
+
|
|
110
|
+
### Step 3: Document the delta
|
|
111
|
+
|
|
112
|
+
Write a change record to `.beads/artifacts/$ARGUMENTS/iterations.md`:
|
|
113
|
+
|
|
114
|
+
```markdown
|
|
115
|
+
## Iteration [N] — [date]
|
|
116
|
+
|
|
117
|
+
**Type:** [expand | reduce | pivot]
|
|
118
|
+
**Reason:** [user-provided reason]
|
|
119
|
+
**Triggered by:** [discovery | user request | technical constraint | external dependency]
|
|
120
|
+
|
|
121
|
+
### Impact Assessment
|
|
122
|
+
|
|
123
|
+
| Area | Before | After | Action |
|
|
124
|
+
| ----- | ----------------------- | ------------------------- | ------------------------------ |
|
|
125
|
+
| Scope | [original scope] | [new scope] | [expanded/reduced/pivoted] |
|
|
126
|
+
| Tasks | [N] total, [M] complete | [N'] total, [M] preserved | [added/removed/modified count] |
|
|
127
|
+
| Files | [original file list] | [updated file list] | [new/removed files] |
|
|
128
|
+
|
|
129
|
+
### Task Changes
|
|
130
|
+
|
|
131
|
+
- **Preserved:** [list of completed task titles — unchanged]
|
|
132
|
+
- **Modified:** [list of tasks with what changed]
|
|
133
|
+
- **Removed:** [list of tasks marked obsolete, with reason]
|
|
134
|
+
- **Added:** [list of new tasks]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Phase 4: Apply Changes
|
|
138
|
+
|
|
139
|
+
### For Expand:
|
|
140
|
+
|
|
141
|
+
1. Add new sections/requirements to `prd.md`
|
|
142
|
+
2. Add new tasks at the end of the Tasks section
|
|
143
|
+
3. Mark new tasks with `depends_on` referencing completed tasks if needed
|
|
144
|
+
4. Re-run `prd-task` skill to regenerate `prd.json` with merged task state
|
|
145
|
+
|
|
146
|
+
### For Reduce:
|
|
147
|
+
|
|
148
|
+
1. Move removed scope items to "Out-of-Scope" in `prd.md` with note: `[Removed in Iteration N: reason]`
|
|
149
|
+
2. Mark affected tasks by changing their heading from `### Task Title [category]` to `### ~~Task Title~~ [OBSOLETE — Iteration N]` in `prd.md` (don't delete — preserve history). The `prd-task` skill skips headings containing `OBSOLETE` or `INVALIDATED` markers.
|
|
150
|
+
3. Re-run `prd-task` to regenerate `prd.json` (obsolete tasks excluded)
|
|
151
|
+
|
|
152
|
+
### For Pivot:
|
|
153
|
+
|
|
154
|
+
1. Archive current PRD section as `## Original Approach (Superseded)` at bottom of file
|
|
155
|
+
2. Rewrite affected sections (Proposed Solution, Requirements, Tasks)
|
|
156
|
+
3. Preserve completed tasks that are still valid
|
|
157
|
+
4. Mark invalidated completed tasks by changing their heading to `### ~~Task Title~~ [INVALIDATED — Iteration N: reason]`
|
|
158
|
+
5. Re-run `prd-task` to regenerate `prd.json`
|
|
159
|
+
|
|
160
|
+
### Update plan.md (if exists):
|
|
161
|
+
|
|
162
|
+
If `.beads/artifacts/$ARGUMENTS/plan.md` exists:
|
|
163
|
+
|
|
164
|
+
1. Add an "## Iteration [N] Changes" section to the plan
|
|
165
|
+
2. Update dependency graph if tasks changed
|
|
166
|
+
3. Re-compute waves for remaining tasks
|
|
167
|
+
|
|
168
|
+
## Phase 5: Validate
|
|
169
|
+
|
|
170
|
+
After applying changes:
|
|
171
|
+
|
|
172
|
+
- [ ] PRD has no `[NEEDS CLARIFICATION]` markers (resolve or add to Open Questions)
|
|
173
|
+
- [ ] All preserved completed tasks are still valid
|
|
174
|
+
- [ ] New/modified tasks have verification steps
|
|
175
|
+
- [ ] `iterations.md` documents the full delta
|
|
176
|
+
- [ ] `prd.json` reflects the updated task state
|
|
177
|
+
|
|
178
|
+
## Phase 6: Report
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
br comments add $ARGUMENTS "Iteration [N]: [type] — [reason summary]. Tasks: [added/removed/modified] count"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Output:
|
|
185
|
+
|
|
186
|
+
1. **Change type:** [expand | reduce | pivot]
|
|
187
|
+
2. **Reason:** [brief summary]
|
|
188
|
+
3. **Task changes:** [N] preserved, [M] modified, [K] removed, [J] added
|
|
189
|
+
4. **Files affected:** [updated list]
|
|
190
|
+
5. **Iteration log:** `.beads/artifacts/$ARGUMENTS/iterations.md`
|
|
191
|
+
6. **Next step:** Continue `/ship $ARGUMENTS` with updated spec
|
|
192
|
+
|
|
193
|
+
## Related Commands
|
|
194
|
+
|
|
195
|
+
| Need | Command |
|
|
196
|
+
| -------------------------- | ------------------ |
|
|
197
|
+
| Create initial spec | `/create` |
|
|
198
|
+
| Continue shipping | `/ship <id>` |
|
|
199
|
+
| Review after changes | `/review-codebase` |
|
|
200
|
+
| Post-implementation review | `/compound <id>` |
|
|
@@ -317,7 +317,68 @@ Wave 3: C
|
|
|
317
317
|
- **Each step is 2-5 minutes** — one action per step
|
|
318
318
|
- **Tasks map to PRD tasks**
|
|
319
319
|
|
|
320
|
-
## Phase 8:
|
|
320
|
+
## Phase 8: Constitutional Compliance Gate
|
|
321
|
+
|
|
322
|
+
Before executing, scan the plan against AGENTS.md hard constraints. This catches violations before they become implementation bugs.
|
|
323
|
+
|
|
324
|
+
### Automated Checks
|
|
325
|
+
|
|
326
|
+
Scan `plan.md` content for these patterns:
|
|
327
|
+
|
|
328
|
+
| Violation Pattern | AGENTS.md Rule | Severity |
|
|
329
|
+
| ------------------------------------------------- | ------------------------------------------- | ------------ |
|
|
330
|
+
| `git add .` or `git add -A` | Multi-Agent Safety: stage specific files | **CRITICAL** |
|
|
331
|
+
| `--force` push or `force push` | Git Safety: never force push main | **CRITICAL** |
|
|
332
|
+
| `--no-verify` | Git Safety: never bypass hooks | **CRITICAL** |
|
|
333
|
+
| `as any` or `@ts-ignore` without justification | Quality Bar: strong typing | **WARNING** |
|
|
334
|
+
| New package/dependency without approval step | Guardrails: no new deps without approval | **WARNING** |
|
|
335
|
+
| Task modifying >3 files without plan confirmation | Guardrails: no surprise edits | **WARNING** |
|
|
336
|
+
| `reset --hard` or `checkout .` or `clean -fd` | Git Restore: never without explicit request | **CRITICAL** |
|
|
337
|
+
| Secret/credential patterns | Security: never expose credentials | **CRITICAL** |
|
|
338
|
+
|
|
339
|
+
### Check Process
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
# Scan plan for violation patterns (fixed-string mode to avoid regex false positives)
|
|
343
|
+
grep -inF "git add ." .beads/artifacts/$ARGUMENTS/plan.md
|
|
344
|
+
grep -inF "git add -A" .beads/artifacts/$ARGUMENTS/plan.md
|
|
345
|
+
grep -inF -- "--no-verify" .beads/artifacts/$ARGUMENTS/plan.md
|
|
346
|
+
grep -inF "force push" .beads/artifacts/$ARGUMENTS/plan.md
|
|
347
|
+
grep -inF -- "--force" .beads/artifacts/$ARGUMENTS/plan.md
|
|
348
|
+
grep -inF "reset --hard" .beads/artifacts/$ARGUMENTS/plan.md
|
|
349
|
+
grep -inF "checkout ." .beads/artifacts/$ARGUMENTS/plan.md
|
|
350
|
+
grep -inF "clean -fd" .beads/artifacts/$ARGUMENTS/plan.md
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Also check:
|
|
354
|
+
|
|
355
|
+
- Count files per task: if any task lists >3 files in its `files:` metadata, flag as WARNING
|
|
356
|
+
- Check for `as any` or `@ts-ignore` usage that lacks a documented reason
|
|
357
|
+
- Check if any task adds new dependencies (look for `npm install`, `pnpm add`, `yarn add`, `pip install`, `cargo add`)
|
|
358
|
+
|
|
359
|
+
### Violation Response
|
|
360
|
+
|
|
361
|
+
| Severity | Action |
|
|
362
|
+
| ------------ | ------------------------------------------------------------------ |
|
|
363
|
+
| **CRITICAL** | Stop. Remove violation from plan. Report to user. |
|
|
364
|
+
| **WARNING** | Flag in plan output. Add confirmation checkpoint to affected task. |
|
|
365
|
+
|
|
366
|
+
If no violations found, report: `Constitutional compliance: ✓ PASS`
|
|
367
|
+
|
|
368
|
+
If violations found:
|
|
369
|
+
|
|
370
|
+
```markdown
|
|
371
|
+
## ⚠️ Constitutional Compliance Check
|
|
372
|
+
|
|
373
|
+
| # | Pattern Found | Location | Severity | Action |
|
|
374
|
+
| --- | -------------------- | -------------- | -------- | ----------------------------------- |
|
|
375
|
+
| 1 | `git add .` | Task 3, step 2 | CRITICAL | Removed — use specific file staging |
|
|
376
|
+
| 2 | New dependency `zod` | Task 1 | WARNING | Added approval checkpoint |
|
|
377
|
+
|
|
378
|
+
Violations resolved. Plan is compliant.
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## Phase 9: Create Child Beads (if --create-beads or L size)
|
|
321
382
|
|
|
322
383
|
For large work, create child beads for each plan phase:
|
|
323
384
|
|
|
@@ -326,7 +387,7 @@ CHILD=$(br create "[Phase title]" --type task --json | jq -r '.id')
|
|
|
326
387
|
br dep add $CHILD $ARGUMENTS
|
|
327
388
|
```
|
|
328
389
|
|
|
329
|
-
## Phase
|
|
390
|
+
## Phase 10: Report
|
|
330
391
|
|
|
331
392
|
Output:
|
|
332
393
|
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Beads PRD Template
|
|
2
2
|
|
|
3
|
+
> **Template Instructions:**
|
|
4
|
+
>
|
|
5
|
+
> - Replace ALL bracketed placeholders with real content
|
|
6
|
+
> - If you cannot fill a section with confidence, use `[NEEDS CLARIFICATION: reason]` instead of guessing
|
|
7
|
+
> - Any `[NEEDS CLARIFICATION]` markers MUST be resolved before planning can proceed
|
|
8
|
+
> - Delete this instruction block after filling the template
|
|
9
|
+
|
|
3
10
|
**Bead:** br-[id]
|
|
4
11
|
**Created:** [date]
|
|
5
12
|
**Status:** Draft | In Review | Approved
|
|
@@ -20,11 +27,11 @@ estimated_hours: 2 # Time estimate for planning
|
|
|
20
27
|
|
|
21
28
|
### What problem are we solving?
|
|
22
29
|
|
|
23
|
-
[Clear description of the problem. Include user impact and business impact.]
|
|
30
|
+
[Clear description of the problem. Include user impact and business impact. If unclear, use [NEEDS CLARIFICATION: what specifically is unknown]]
|
|
24
31
|
|
|
25
32
|
### Why now?
|
|
26
33
|
|
|
27
|
-
[What triggered this work? Cost of inaction?]
|
|
34
|
+
[What triggered this work? Cost of inaction? Use [NEEDS CLARIFICATION] if motivation is unclear]
|
|
28
35
|
|
|
29
36
|
### Who is affected?
|
|
30
37
|
|
|
@@ -37,11 +44,11 @@ estimated_hours: 2 # Time estimate for planning
|
|
|
37
44
|
|
|
38
45
|
### In-Scope
|
|
39
46
|
|
|
40
|
-
- [List what's
|
|
47
|
+
- [List what's in scope. Use [NEEDS CLARIFICATION] for ambiguous boundaries]
|
|
41
48
|
|
|
42
49
|
### Out-of-Scope
|
|
43
50
|
|
|
44
|
-
- [List what's explicitly off-limits]
|
|
51
|
+
- [List what's explicitly off-limits. Use [NEEDS CLARIFICATION] for unresolved scope questions]
|
|
45
52
|
- [Deferred to future iterations]
|
|
46
53
|
|
|
47
54
|
---
|
|
@@ -50,7 +57,7 @@ estimated_hours: 2 # Time estimate for planning
|
|
|
50
57
|
|
|
51
58
|
### Overview
|
|
52
59
|
|
|
53
|
-
[One paragraph describing what this feature does when complete.]
|
|
60
|
+
[One paragraph describing what this feature does when complete. Use [NEEDS CLARIFICATION] for uncertain design decisions]
|
|
54
61
|
|
|
55
62
|
### User Flow (if user-facing)
|
|
56
63
|
|
|
@@ -80,6 +87,8 @@ Brief description of what must be true.
|
|
|
80
87
|
- **Accessibility:** [WCAG level if applicable]
|
|
81
88
|
- **Compatibility:** [constraint if applicable]
|
|
82
89
|
|
|
90
|
+
> If any requirement is unknown or unresearched, mark it `[NEEDS CLARIFICATION: what needs investigation]` rather than omitting it.
|
|
91
|
+
|
|
83
92
|
---
|
|
84
93
|
|
|
85
94
|
## Success Criteria
|
|
@@ -127,6 +136,8 @@ files:
|
|
|
127
136
|
| ---------- | ----- | -------- | ------------- |
|
|
128
137
|
| Question 1 | Name | Date | Open/Resolved |
|
|
129
138
|
|
|
139
|
+
> **All `[NEEDS CLARIFICATION]` markers should be converted to entries in this table for tracking.**
|
|
140
|
+
|
|
130
141
|
---
|
|
131
142
|
|
|
132
143
|
## Tasks
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reconcile
|
|
3
|
+
description: >
|
|
4
|
+
Use when verifying implementation matches its specification — detects drift between PRD requirements
|
|
5
|
+
and actual code, identifies missing features, extra features, and diverged behavior. Load after /ship
|
|
6
|
+
or before closing a bead.
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
tags: [workflow, verification, quality]
|
|
9
|
+
dependencies: [verification-before-completion]
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Reconcile — Spec↔Code Drift Detection
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
- After `/ship` completes all tasks, before closing the bead
|
|
17
|
+
- When you suspect implementation has drifted from the original spec
|
|
18
|
+
- During `/review-codebase` to check spec adherence
|
|
19
|
+
- Before creating a PR to verify completeness
|
|
20
|
+
|
|
21
|
+
## When NOT to Use
|
|
22
|
+
|
|
23
|
+
- During active implementation (wait until tasks are done)
|
|
24
|
+
- For code quality issues (use `requesting-code-review` instead)
|
|
25
|
+
- For structural config audits (use `/health` instead)
|
|
26
|
+
|
|
27
|
+
## Overview
|
|
28
|
+
|
|
29
|
+
Implementation drift is the silent killer of spec-driven development. Tasks can pass all verification gates while the overall feature drifts from its specification. This skill systematically compares PRD artifacts against code evidence.
|
|
30
|
+
|
|
31
|
+
## Reconciliation Process
|
|
32
|
+
|
|
33
|
+
### Step 1: Load Artifacts
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Read the PRD
|
|
37
|
+
cat .beads/artifacts/$BEAD_ID/prd.md
|
|
38
|
+
|
|
39
|
+
# Read the plan (if exists)
|
|
40
|
+
cat .beads/artifacts/$BEAD_ID/plan.md 2>/dev/null
|
|
41
|
+
|
|
42
|
+
# Determine comparison base (works with main, master, or any default branch)
|
|
43
|
+
BASE=$(git rev-parse origin/main 2>/dev/null || git rev-parse origin/master 2>/dev/null || git merge-base HEAD $(git rev-parse --abbrev-ref HEAD@{upstream} 2>/dev/null || echo HEAD~10))
|
|
44
|
+
|
|
45
|
+
# Get the actual diff
|
|
46
|
+
git diff $BASE --name-only
|
|
47
|
+
git diff $BASE --stat
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Step 2: Extract Spec Claims
|
|
51
|
+
|
|
52
|
+
From the PRD, extract these verifiable claims:
|
|
53
|
+
|
|
54
|
+
| Claim Type | Source Section | Example |
|
|
55
|
+
| --------------------------- | --------------------------------------- | ----------------------------------- |
|
|
56
|
+
| **Success Criteria** | `## Success Criteria` | "User can see existing messages" |
|
|
57
|
+
| **Functional Requirements** | `## Requirements` | "WHEN user clicks X THEN Y happens" |
|
|
58
|
+
| **Affected Files** | `## Technical Context > Affected Files` | `src/api/users.ts` |
|
|
59
|
+
| **Scope Boundaries** | `## Scope` | "In-scope: X, Out-of-scope: Y" |
|
|
60
|
+
| **Task Deliverables** | `## Tasks` | Each task's end-state description |
|
|
61
|
+
|
|
62
|
+
### Step 3: Verify Each Claim
|
|
63
|
+
|
|
64
|
+
For each extracted claim, gather evidence:
|
|
65
|
+
|
|
66
|
+
#### Success Criteria Verification
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# For each success criterion, find code evidence
|
|
70
|
+
# Example: "User can see existing messages"
|
|
71
|
+
grep -r "messages" src/ --include="*.ts" --include="*.tsx" -l
|
|
72
|
+
grep -r "fetchMessages\|getMessages\|listMessages" src/ -l
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Map each criterion to:
|
|
76
|
+
|
|
77
|
+
- **VERIFIED**: Code evidence confirms the criterion is met
|
|
78
|
+
- **PARTIAL**: Some evidence exists but incomplete
|
|
79
|
+
- **MISSING**: No code evidence found
|
|
80
|
+
- **UNTESTABLE**: Cannot be verified via code search (needs manual check)
|
|
81
|
+
|
|
82
|
+
#### Affected Files Verification
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Compare PRD affected files vs actual changed files
|
|
86
|
+
# PRD claims these files would be modified:
|
|
87
|
+
PRD_FILES=$(grep -A 50 "Affected Files" .beads/artifacts/$BEAD_ID/prd.md | grep "src/" | sed 's/.*`//' | sed 's/`.*//')
|
|
88
|
+
|
|
89
|
+
# Actually modified files:
|
|
90
|
+
ACTUAL_FILES=$(git diff $BASE --name-only)
|
|
91
|
+
|
|
92
|
+
# Files in PRD but not modified (missing implementation):
|
|
93
|
+
comm -23 <(echo "$PRD_FILES" | sort) <(echo "$ACTUAL_FILES" | sort)
|
|
94
|
+
|
|
95
|
+
# Files modified but not in PRD (scope creep):
|
|
96
|
+
comm -13 <(echo "$PRD_FILES" | sort) <(echo "$ACTUAL_FILES" | sort)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Scope Boundary Check
|
|
100
|
+
|
|
101
|
+
- **In-scope items**: Verify each has corresponding code changes
|
|
102
|
+
- **Out-of-scope items**: Verify NO code touches those areas (scope creep detection)
|
|
103
|
+
|
|
104
|
+
### Step 4: Detect Drift Patterns
|
|
105
|
+
|
|
106
|
+
| Drift Type | Detection Method | Severity |
|
|
107
|
+
| -------------------------- | ------------------------------------------------------ | -------- |
|
|
108
|
+
| **Missing Feature** | Success criterion with no code evidence | HIGH |
|
|
109
|
+
| **Partial Implementation** | Criterion partially met (stub, TODO) | HIGH |
|
|
110
|
+
| **Scope Creep** | Files modified that aren't in PRD affected files | MEDIUM |
|
|
111
|
+
| **Spec Rot** | PRD sections that contradict actual implementation | MEDIUM |
|
|
112
|
+
| **Over-Engineering** | Significant code not traceable to any PRD requirement | LOW |
|
|
113
|
+
| **Diverged Behavior** | Code does something different from WHEN/THEN scenarios | HIGH |
|
|
114
|
+
|
|
115
|
+
### Step 5: Calculate Drift Score
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
Drift Score Calculation:
|
|
119
|
+
- Total claims: [N]
|
|
120
|
+
- VERIFIED: [n] (×1.0)
|
|
121
|
+
- PARTIAL: [n] (×0.5)
|
|
122
|
+
- MISSING: [n] (×0.0)
|
|
123
|
+
- UNTESTABLE: [n] (excluded from calculation)
|
|
124
|
+
|
|
125
|
+
Adherence = (VERIFIED×1.0 + PARTIAL×0.5) / (Total - UNTESTABLE) × 100
|
|
126
|
+
|
|
127
|
+
Scope Creep = Extra files modified / Total files modified × 100
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Drift Report Format
|
|
131
|
+
|
|
132
|
+
```markdown
|
|
133
|
+
## Reconciliation Report: <bead-id>
|
|
134
|
+
|
|
135
|
+
**PRD:** `.beads/artifacts/<id>/prd.md`
|
|
136
|
+
**Branch:** `<branch-name>`
|
|
137
|
+
**Adherence Score:** [N]%
|
|
138
|
+
**Scope Creep:** [N]%
|
|
139
|
+
|
|
140
|
+
### Success Criteria
|
|
141
|
+
|
|
142
|
+
| # | Criterion | Status | Evidence |
|
|
143
|
+
| --- | ---------------- | ----------- | ------------------------------------------ |
|
|
144
|
+
| 1 | [criterion text] | ✅ VERIFIED | `src/file.ts:42` — [what confirms it] |
|
|
145
|
+
| 2 | [criterion text] | ⚠️ PARTIAL | `src/file.ts` exists but handler is a stub |
|
|
146
|
+
| 3 | [criterion text] | ❌ MISSING | No code evidence found |
|
|
147
|
+
|
|
148
|
+
### File Reconciliation
|
|
149
|
+
|
|
150
|
+
| Category | Files | Count |
|
|
151
|
+
| --------------------------- | -------------------------- | ----- |
|
|
152
|
+
| ✅ Expected & Modified | `src/api/users.ts`, ... | [N] |
|
|
153
|
+
| ❌ Expected but Untouched | `src/models/user.ts`, ... | [N] |
|
|
154
|
+
| ⚠️ Unexpected Modifications | `src/utils/helper.ts`, ... | [N] |
|
|
155
|
+
|
|
156
|
+
### Drift Issues
|
|
157
|
+
|
|
158
|
+
| # | Type | Severity | Description | Recommendation |
|
|
159
|
+
| --- | --------------- | -------- | ---------------- | -------------------------------------------------------------- |
|
|
160
|
+
| 1 | Missing Feature | HIGH | [what's missing] | Implement or use `/iterate --scope reduce` to remove from spec |
|
|
161
|
+
| 2 | Scope Creep | MEDIUM | [what's extra] | Document in PRD or revert |
|
|
162
|
+
|
|
163
|
+
### Verdict
|
|
164
|
+
|
|
165
|
+
| Score | Meaning | Action |
|
|
166
|
+
| ----------- | -------------------- | ------------------------------------------------------ |
|
|
167
|
+
| **90-100%** | Excellent adherence | Ready to close |
|
|
168
|
+
| **70-89%** | Good with minor gaps | Fix gaps or document as intentional deviations |
|
|
169
|
+
| **50-69%** | Significant drift | Use `/iterate` to reconcile spec and code |
|
|
170
|
+
| **<50%** | Major drift | **BLOCK** — spec and code are fundamentally misaligned |
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Integration Points
|
|
174
|
+
|
|
175
|
+
- **`/ship` Phase 5**: Run reconcile after review, before close decision
|
|
176
|
+
- **`/compound`**: Include adherence score in retrospective observations
|
|
177
|
+
- **`/pr`**: Include drift report in PR description
|
|
178
|
+
|
|
179
|
+
## Gotchas
|
|
180
|
+
|
|
181
|
+
- Some criteria genuinely can't be verified by code search (UI behavior, UX feel) — mark as UNTESTABLE, don't count against score
|
|
182
|
+
- Scope creep isn't always bad — sometimes good engineering requires touching adjacent files. Flag it, don't auto-block.
|
|
183
|
+
- Run AFTER phantom completion detection — reconcile assumes code is substantive, not stubs
|