opencodekit 0.20.4 → 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.
Files changed (30) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/template/.opencode/AGENTS.md +71 -9
  3. package/dist/template/.opencode/agent/build.md +82 -32
  4. package/dist/template/.opencode/agent/plan.md +22 -14
  5. package/dist/template/.opencode/agent/review.md +18 -40
  6. package/dist/template/.opencode/agent/scout.md +17 -0
  7. package/dist/template/.opencode/command/compound.md +24 -2
  8. package/dist/template/.opencode/command/create.md +65 -69
  9. package/dist/template/.opencode/command/explore.md +170 -0
  10. package/dist/template/.opencode/command/health.md +124 -2
  11. package/dist/template/.opencode/command/iterate.md +200 -0
  12. package/dist/template/.opencode/command/plan.md +74 -14
  13. package/dist/template/.opencode/command/pr.md +4 -16
  14. package/dist/template/.opencode/command/research.md +7 -16
  15. package/dist/template/.opencode/command/resume.md +2 -11
  16. package/dist/template/.opencode/command/review-codebase.md +9 -15
  17. package/dist/template/.opencode/command/ship.md +12 -53
  18. package/dist/template/.opencode/memory/_templates/prd.md +16 -5
  19. package/dist/template/.opencode/memory/project/user.md +7 -0
  20. package/dist/template/.opencode/memory.db +0 -0
  21. package/dist/template/.opencode/memory.db-shm +0 -0
  22. package/dist/template/.opencode/memory.db-wal +0 -0
  23. package/dist/template/.opencode/opencode.json +54 -67
  24. package/dist/template/.opencode/package.json +1 -1
  25. package/dist/template/.opencode/skill/memory-grounding/SKILL.md +68 -0
  26. package/dist/template/.opencode/skill/reconcile/SKILL.md +183 -0
  27. package/dist/template/.opencode/skill/verification-before-completion/SKILL.md +75 -0
  28. package/dist/template/.opencode/skill/verification-gates/SKILL.md +63 -0
  29. package/dist/template/.opencode/skill/workspace-setup/SKILL.md +76 -0
  30. package/package.json +1 -1
@@ -16,6 +16,8 @@ Create a bead, write its specification (PRD), claim it, set up the workspace, an
16
16
 
17
17
  ```typescript
18
18
  skill({ name: "beads" });
19
+ skill({ name: "memory-grounding" });
20
+ skill({ name: "workspace-setup" });
19
21
  skill({ name: "prd" }); // PRD template guidance
20
22
  skill({ name: "prd-task" }); // PRD → executable tasks (Phase 8)
21
23
  ```
@@ -43,6 +45,7 @@ skill({ name: "prd-task" }); // PRD → executable tasks (Phase 8)
43
45
  - **Check duplicates**: Always run Phase 1 duplicate check
44
46
  - **No implementation**: This command creates specs and workspace — don't write implementation code
45
47
  - **Verify PRD**: Before saving, verify all sections are filled (no placeholders)
48
+ - **Flag uncertainty**: Use `[NEEDS CLARIFICATION]` markers for unknowns — never guess silently
46
49
 
47
50
  ## Available Tools
48
51
 
@@ -56,14 +59,7 @@ skill({ name: "prd-task" }); // PRD → executable tasks (Phase 8)
56
59
 
57
60
  ### Memory Search
58
61
 
59
- Search memory for prior work on the same topic before creating a new bead:
60
-
61
- ```typescript
62
- memory - search({ query: "<description keywords>" });
63
- memory - search({ query: "<description keywords>", type: "decision" });
64
- ```
65
-
66
- If memory shows a related decision or completed bead, inform the user before proceeding.
62
+ Follow the [memory-grounding](../skill/memory-grounding/SKILL.md) skill protocol. Focus on: duplicate bead detection, prior decisions.
67
63
 
68
64
  ### Bead List Check
69
65
 
@@ -152,13 +148,57 @@ BEAD_ID=$(br create --title "$TITLE" --description "$DESCRIPTION" --type $BEAD_T
152
148
  mkdir -p ".beads/artifacts/$BEAD_ID"
153
149
  ```
154
150
 
155
- ## Phase 6: Write PRD
151
+ ## Phase 6: Determine PRD Rigor
152
+
153
+ Not every change needs a full spec. Assess complexity to choose the right PRD level:
154
+
155
+ | Signal | Lite PRD | Full PRD |
156
+ | --- | --- | --- |
157
+ | Type | `bug`, `task` | `feature`, `epic` |
158
+ | Files affected | 1-3 | 4+ |
159
+ | Scope | Clear, single-concern | Cross-cutting, multi-system |
160
+ | Research depth | Skip or Minimal | Standard or Deep |
161
+ | Description | "Fix X in Y" | "Implement X with Y and Z" |
162
+
163
+ **Auto-detect:** If type is `bug` or `task` AND research was Skip/Minimal AND description is a single sentence → default to Lite.
164
+
165
+ ### Lite PRD Format
166
+
167
+ For simple, well-scoped work (bugs, small tasks):
168
+
169
+ ```markdown
170
+ # [Title]
171
+
172
+ ## Problem
173
+ [1-2 sentences: what's wrong or what's needed]
174
+
175
+ ## Solution
176
+ [1-2 sentences: what to do]
156
177
 
157
- Copy and fill the PRD template using context from Phase 4:
178
+ ## Affected Files
179
+ - `src/path/to/file.ts`
180
+
181
+ ## Tasks
182
+ - [ ] [Task description] → Verify: `[command]`
183
+
184
+ ## Success Criteria
185
+ - Verify: `npm run typecheck && npm run lint`
186
+ - Verify: `[specific test or check]`
187
+ ```
188
+
189
+ ### Full PRD Format
190
+
191
+ For features and complex work, use the full template:
158
192
 
159
193
  Read the PRD template from `.opencode/memory/_templates/prd.md` and write it to `.beads/artifacts/$BEAD_ID/prd.md`.
160
194
 
161
- ### Required Sections
195
+ ## Phase 7: Write PRD
196
+
197
+ Copy and fill the PRD template (lite or full) using context from Phase 4.
198
+
199
+ **If Lite PRD:** Fill the lite format directly. No template file needed.
200
+
201
+ **If Full PRD:** Read the template and fill all required sections:
162
202
 
163
203
  | Section | Source | Required |
164
204
  | ----------------- | ---------------------------------------------------------- | ----------------- |
@@ -181,7 +221,7 @@ Tasks must follow the `prd-task` skill format:
181
221
  - Metadata block: `depends_on`, `parallel`, `conflicts_with`, `files`
182
222
  - At least one verification command per task
183
223
 
184
- ## Phase 7: Validate PRD
224
+ ## Phase 8: Validate PRD
185
225
 
186
226
  Before saving, verify:
187
227
 
@@ -192,12 +232,13 @@ Before saving, verify:
192
232
  - [ ] Tasks have `[category]` headings
193
233
  - [ ] Each task has verification
194
234
  - [ ] No implementation code in the PRD
235
+ - [ ] No unresolved `[NEEDS CLARIFICATION]` markers remain (convert to Open Questions or resolve)
195
236
 
196
237
  If any check fails, fix it — don't ask the user.
197
238
 
198
- ## Phase 8: Claim and Prepare Workspace
239
+ ## Phase 9: Claim and Prepare Workspace
199
240
 
200
- **If `--spec-only` was passed, skip to Phase 10 (Report).**
241
+ **If `--spec-only` was passed, skip to Phase 12 (Report).**
201
242
 
202
243
  ### Workspace Check
203
244
 
@@ -218,66 +259,21 @@ br update $BEAD_ID --status in_progress
218
259
 
219
260
  ### Create Branch
220
261
 
221
- Ask user how to handle workspace:
262
+ ### Workspace Setup
222
263
 
223
- ```typescript
224
- question({
225
- questions: [
226
- {
227
- header: "Workspace",
228
- question: "How do you want to set up the workspace?",
229
- options: [
230
- {
231
- label: "Create feature branch (Recommended)",
232
- description: "git checkout -b feat/<bead-id>-<title>",
233
- },
234
- {
235
- label: "Use current branch",
236
- description: "Work on current branch",
237
- },
238
- {
239
- label: "Create worktree",
240
- description: "Isolated git worktree for this bead",
241
- },
242
- ],
243
- },
244
- ],
245
- });
246
- ```
247
-
248
- **If feature branch selected:**
264
+ Follow the [workspace-setup](../skill/workspace-setup/SKILL.md) skill protocol.
249
265
 
250
- Map bead type to branch prefix:
251
-
252
- | Bead Type | Branch Prefix |
253
- | --------- | ------------- |
254
- | feature | feat |
255
- | bug | fix |
256
- | task | task |
257
- | epic | epic |
258
-
259
- Create the branch:
260
-
261
- ```bash
262
- # Example: feat/br-42-add-auth
263
- git checkout -b $PREFIX/$BEAD_ID-$TITLE_SLUG
264
- ```
265
-
266
- Slugify the title (lowercase, spaces to hyphens) and use the bead type to determine the prefix.
267
-
268
- **If worktree selected:**
266
+ Additionally offer a "Create worktree" option:
269
267
 
270
268
  ```typescript
271
269
  skill({ name: "using-git-worktrees" });
272
270
  ```
273
271
 
274
- **If current branch:** Continue without branch creation.
275
-
276
- ## Phase 9: Convert PRD to Tasks
272
+ ## Phase 10: Convert PRD to Tasks
277
273
 
278
274
  Use `prd-task` skill to convert PRD markdown → executable JSON (`prd.json`).
279
275
 
280
- ## Phase 10: Report
276
+ ## Phase 11: Report
281
277
 
282
278
  Output:
283
279
 
@@ -295,8 +291,8 @@ br comments add $BEAD_ID "Created prd.md with [N] tasks, [M] success criteria"
295
291
 
296
292
  ## Related Commands
297
293
 
298
- | Need | Command |
299
- | ------------------ | ------------- |
300
- | Research first | `/research` |
301
- | Plan after spec | `/plan <id>` |
302
- | Implement and ship | `/ship <id>` |
294
+ | Need | Command |
295
+ | ------------------ | ------------ |
296
+ | Research first | `/research` |
297
+ | Plan after spec | `/plan <id>` |
298
+ | Implement and ship | `/ship <id>` |
@@ -0,0 +1,170 @@
1
+ ---
2
+ description: Think through an idea with structured alternatives before committing to a change
3
+ argument-hint: "<idea or question>"
4
+ agent: plan
5
+ ---
6
+
7
+ # Explore: $ARGUMENTS
8
+
9
+ Think through an idea, problem, or approach with structured alternatives and tradeoffs — before committing to a bead or plan.
10
+
11
+ > **Workflow:** **`/explore`** → `/create` (if worth pursuing) or discard
12
+ >
13
+ > Use when you're not sure WHAT to build or HOW to approach it. This is ideation with rigor, not open-ended brainstorming.
14
+ >
15
+ > **When to use:** Before `/create`, when the approach isn't obvious. Skip for clear, well-scoped work.
16
+
17
+ ## Load Skills
18
+
19
+ ```typescript
20
+ skill({ name: "brainstorming" }); // Collaborative refinement
21
+ skill({ name: "memory-grounding" }); // Load past decisions
22
+ ```
23
+
24
+ ## Phase 1: Ground
25
+
26
+ Search for prior art and past decisions:
27
+
28
+ ```typescript
29
+ memory_search({ query: "<topic keywords>", limit: 5 });
30
+ ```
31
+
32
+ ```bash
33
+ # What exists in the codebase already?
34
+ git log --oneline -20 | grep -i "<keyword>"
35
+ ```
36
+
37
+ Spawn an explore agent to understand the current state:
38
+
39
+ ```typescript
40
+ task({
41
+ subagent_type: "explore",
42
+ description: "Map existing patterns for this area",
43
+ prompt: `Search the codebase for existing implementations, patterns, and conventions related to: $ARGUMENTS
44
+
45
+ Return: what exists today, what patterns are used, what files are involved.`,
46
+ });
47
+ ```
48
+
49
+ ## Phase 2: Frame the Problem
50
+
51
+ Before proposing solutions, state the problem clearly:
52
+
53
+ 1. **What's the goal?** (outcome, not task)
54
+ 2. **What constraints exist?** (tech stack, time, compatibility, user preferences)
55
+ 3. **What's the risk of doing nothing?** (is this urgent or nice-to-have?)
56
+
57
+ If the problem isn't clear after reading context, ask the user to clarify — but max 2 questions.
58
+
59
+ ## Phase 3: Generate Alternatives
60
+
61
+ Produce 2-3 approaches. For each:
62
+
63
+ | Aspect | What to Cover |
64
+ | ------------ | -------------------------------------- |
65
+ | **Approach** | 1-2 sentence summary |
66
+ | **How** | Key implementation steps (3-5 bullets) |
67
+ | **Pros** | What this gets right |
68
+ | **Cons** | What this gets wrong or makes harder |
69
+ | **Effort** | S (<1h), M (1-3h), L (1-2d), XL (>2d) |
70
+ | **Risk** | What could go wrong |
71
+
72
+ **Rules for alternatives:**
73
+
74
+ - At least one must be the simplest viable option
75
+ - At least one must be different in kind, not just degree (different architecture, not just different library)
76
+ - Don't pad with bad options to make the recommended one look good
77
+
78
+ ## Phase 4: Recommend
79
+
80
+ Pick one approach and explain why:
81
+
82
+ ```markdown
83
+ ## Recommendation
84
+
85
+ **Approach:** [Name]
86
+ **Effort:** [S/M/L/XL]
87
+ **Why:** [2-3 sentences — why this over the others]
88
+ **When to reconsider:** [What signals would make you switch to an alternative]
89
+ ```
90
+
91
+ ## Phase 5: Output Proposal
92
+
93
+ Write the proposal as a structured document:
94
+
95
+ ```markdown
96
+ # Exploration: [Topic]
97
+
98
+ ## Problem
99
+
100
+ [What we're trying to solve]
101
+
102
+ ## Constraints
103
+
104
+ - [Constraint 1]
105
+ - [Constraint 2]
106
+
107
+ ## Alternatives
108
+
109
+ ### Option A: [Name]
110
+
111
+ - **How:** ...
112
+ - **Pros:** ...
113
+ - **Cons:** ...
114
+ - **Effort:** S/M/L/XL
115
+
116
+ ### Option B: [Name]
117
+
118
+ - **How:** ...
119
+ - **Pros:** ...
120
+ - **Cons:** ...
121
+ - **Effort:** S/M/L/XL
122
+
123
+ ### Option C: [Name] (if applicable)
124
+
125
+ ...
126
+
127
+ ## Recommendation
128
+
129
+ **Option [X]** because [reasoning].
130
+ **Reconsider if:** [triggers for switching]
131
+
132
+ ## Next Step
133
+
134
+ `/create "[description based on chosen approach]"`
135
+ ```
136
+
137
+ **If a bead exists:** Save to `.beads/artifacts/$BEAD_ID/exploration.md`
138
+ **If no bead:** Display inline, don't create files.
139
+
140
+ ## Phase 6: Ask User
141
+
142
+ Present the proposal and ask:
143
+
144
+ ```typescript
145
+ question({
146
+ questions: [
147
+ {
148
+ header: "Approach",
149
+ question: "Which approach do you want to pursue?",
150
+ options: [
151
+ { label: "Option A (Recommended)", description: "[brief]" },
152
+ { label: "Option B", description: "[brief]" },
153
+ { label: "Option C", description: "[brief]" },
154
+ { label: "None — need more research", description: "Spawn scout agents" },
155
+ ],
156
+ },
157
+ ],
158
+ });
159
+ ```
160
+
161
+ If user picks an approach → suggest `/create "[description]"` with the chosen approach baked in.
162
+ If user wants more research → spawn `@scout` for the specific unknowns.
163
+
164
+ ## Related Commands
165
+
166
+ | Need | Command |
167
+ | ------------------------- | ----------------------------------- |
168
+ | Commit to an approach | `/create` |
169
+ | Research external options | `/research` |
170
+ | Open-ended ideation | Load `brainstorming` skill directly |
@@ -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: Agent Tool Restriction Audit
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 6: Report
295
+ ## Phase 7: Report
174
296
 
175
297
  Output a health report:
176
298