opencodekit 0.20.5 → 0.20.7

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.
@@ -0,0 +1,299 @@
1
+ ---
2
+ description: Organize, deduplicate, and curate knowledge in project memory
3
+ argument-hint: "[--scope recent|all] [--auto-merge]"
4
+ agent: build
5
+ ---
6
+
7
+ # Curate: $ARGUMENTS
8
+
9
+ Organize accumulated knowledge. Surface conflicts, merge duplicates, archive stale observations.
10
+
11
+ > **Workflow:** `/ship` → `/compound` → **`/curate`** → `/pr`
12
+ >
13
+ > Run periodically (weekly or after major work) to keep memory sharp. Inspired by ByteRover's structured curation pipeline.
14
+
15
+ ## Load Skills
16
+
17
+ ```typescript
18
+ skill({ name: "memory-system" });
19
+ skill({ name: "verification-before-completion" });
20
+ ```
21
+
22
+ ## Parse Arguments
23
+
24
+ | Argument | Default | Description |
25
+ | -------------- | -------- | ------------------------------------------------ |
26
+ | `--scope` | `recent` | `recent` = last 30 days, `all` = entire memory |
27
+ | `--auto-merge` | false | Auto-merge exact duplicates without confirmation |
28
+
29
+ ## Phase 1: Inventory
30
+
31
+ Take stock of current memory state:
32
+
33
+ ```typescript
34
+ memory_admin({ operation: "status" });
35
+ memory_admin({ operation: "capture-stats" });
36
+ ```
37
+
38
+ Report:
39
+
40
+ ```
41
+ ## Memory Inventory
42
+
43
+ | Metric | Count |
44
+ |--------|-------|
45
+ | Total observations | [N] |
46
+ | Recent (30 days) | [N] |
47
+ | By type | pattern: N, decision: N, bugfix: N, ... |
48
+ | Confidence distribution | high: N, medium: N, low: N |
49
+ ```
50
+
51
+ ## Phase 2: Domain Detection
52
+
53
+ Analyze observations to extract semantic domains — groups of related knowledge.
54
+
55
+ ```typescript
56
+ // Get memory status for inventory
57
+ memory_admin({ operation: "status" });
58
+
59
+ // Search by common concept categories to build domain map
60
+ const domains = [];
61
+ for (const concept of ["build", "test", "memory", "git", "agent", "auth", "ui", "config"]) {
62
+ const results = memory_search({ query: concept, limit: 20 });
63
+ // Group results by concept affinity
64
+ }
65
+ ```
66
+
67
+ Categorize observations into domains based on their `concepts` and `title` fields:
68
+
69
+ | Domain | Example Concepts | Observation Count |
70
+ | -------------- | ---------------------------------- | ----------------- |
71
+ | `build_system` | build, tsdown, rsync, dist | [N] |
72
+ | `testing` | vitest, test, TDD, coverage | [N] |
73
+ | `memory` | observation, FTS5, sqlite, handoff | [N] |
74
+ | `git_workflow` | commit, branch, push, PR | [N] |
75
+ | `agent_system` | subagent, delegation, skills | [N] |
76
+
77
+ **Domain naming rules:**
78
+
79
+ - snake_case, 1-3 words
80
+ - Semantically meaningful (not just "misc")
81
+ - Maximum 10 domains (merge small groups)
82
+
83
+ ## Phase 3: Conflict & Duplicate Detection
84
+
85
+ ### 3a. Exact Duplicates
86
+
87
+ ```typescript
88
+ memory_admin({ operation: "lint" });
89
+ ```
90
+
91
+ Flag observations with identical or near-identical titles and narratives. Present for merge:
92
+
93
+ ```
94
+ ### Duplicates Found
95
+
96
+ | Obs A | Obs B | Similarity | Recommended Action |
97
+ |-------|-------|------------|-------------------|
98
+ | #12 "Use JWT for auth" | #45 "JWT chosen for auth" | 95% title match | MERGE → keep #45 (newer) |
99
+ | #8 "Build copies .opencode/" | #33 "Build copies .opencode/" | 100% title match | MERGE → keep #33 (newer) |
100
+ ```
101
+
102
+ ### 3b. Contradictions
103
+
104
+ Search for observations where:
105
+
106
+ - Same concepts but different decisions
107
+ - Same file paths but conflicting patterns
108
+ - Confidence downgrade without supersedes link
109
+
110
+ ```
111
+ ### Contradictions Found
112
+
113
+ | Obs A | Obs B | Conflict | Recommended Action |
114
+ |-------|-------|----------|-------------------|
115
+ | #5 "Always use X pattern" | #29 "Avoid X pattern" | Opposite recommendations | RESOLVE — ask user which is current |
116
+ ```
117
+
118
+ ### 3c. Stale Observations
119
+
120
+ Flag observations where:
121
+
122
+ - Referenced files no longer exist
123
+ - Referenced patterns no longer appear in codebase
124
+ - Over 90 days old with no related recent activity
125
+
126
+ ```
127
+ ### Stale Observations
128
+
129
+ | Obs | Age | Reason | Recommended Action |
130
+ |-----|-----|--------|-------------------|
131
+ | #3 "src/old-file.ts pattern" | 120 days | File deleted | ARCHIVE |
132
+ | #7 "Use moment.js for dates" | 95 days | Dependency removed | ARCHIVE |
133
+ ```
134
+
135
+ ## Phase 4: Present Curation Plan
136
+
137
+ Compile all findings into a review table:
138
+
139
+ ```
140
+ ## Curation Plan
141
+
142
+ ### Actions Required
143
+
144
+ | # | Observation | Action | Reason |
145
+ |---|------------|--------|--------|
146
+ | 1 | #12 + #45 | MERGE | Duplicate — keep newer |
147
+ | 2 | #5 vs #29 | RESOLVE | Contradicting patterns |
148
+ | 3 | #3 | ARCHIVE | Referenced file deleted |
149
+ | 4 | #7 | ARCHIVE | Dependency removed |
150
+ | 5 | #18 | UPDATE | Low confidence → verify |
151
+ ```
152
+
153
+ ```typescript
154
+ question({
155
+ questions: [
156
+ {
157
+ header: "Curation Plan",
158
+ question: "Review the curation plan. Proceed with all actions?",
159
+ options: [
160
+ { label: "Execute all (Recommended)", description: "Apply all actions above" },
161
+ { label: "Let me cherry-pick", description: "I'll approve individually" },
162
+ { label: "Skip curation", description: "No changes to memory" },
163
+ ],
164
+ },
165
+ ],
166
+ });
167
+ ```
168
+
169
+ ## Phase 5: Execute Curation
170
+
171
+ For each approved action:
172
+
173
+ ### MERGE (duplicates)
174
+
175
+ ```typescript
176
+ // Read both observations
177
+ const older = memory_get({ ids: "<older-id>" });
178
+ const newer = memory_get({ ids: "<newer-id>" });
179
+
180
+ // Union-merge: combine comma-separated lists, deduplicate (case-insensitive), existing items first
181
+ // Example: older.facts="auth, jwt" + newer.facts="jwt, session" → "auth, jwt, session"
182
+
183
+ // Create merged observation (newer as base, merge fields from older)
184
+ observation({
185
+ type: newer.type,
186
+ title: newer.title,
187
+ narrative: newer.narrative,
188
+ // Manually combine comma-separated fields: keep all unique items from both
189
+ facts: "[combined unique facts from older + newer]",
190
+ concepts: "[combined unique concepts from older + newer]",
191
+ files_modified: "[combined unique file paths from older + newer]",
192
+ confidence: newer.confidence, // Newer confidence wins
193
+ supersedes: "<older-id>",
194
+ subtitle: "Merged from #<older-id> + #<newer-id>",
195
+ });
196
+ ```
197
+
198
+ **Union merge rule:** Combine comma-separated lists, deduplicate (case-insensitive), existing items first.
199
+
200
+ ### RESOLVE (contradictions)
201
+
202
+ Present the conflicting observations side-by-side:
203
+
204
+ ```
205
+ ### Contradiction: #5 vs #29
206
+
207
+ **#5 (older, high confidence):**
208
+ > Always use X pattern for Y components
209
+
210
+ **#29 (newer, medium confidence):**
211
+ > Avoid X pattern — causes Z issues
212
+
213
+ Which is the current truth?
214
+ ```
215
+
216
+ ```typescript
217
+ question({
218
+ questions: [
219
+ {
220
+ header: "Resolve Conflict",
221
+ question: "Which observation reflects the current codebase reality?",
222
+ options: [
223
+ { label: "#5 (older) is correct", description: "Archive #29, keep #5" },
224
+ { label: "#29 (newer) is correct", description: "Supersede #5 with #29" },
225
+ { label: "Both partially correct", description: "I'll write a reconciled version" },
226
+ ],
227
+ },
228
+ ],
229
+ });
230
+ ```
231
+
232
+ ### ARCHIVE (stale)
233
+
234
+ ```typescript
235
+ // Verify staleness by checking codebase
236
+ // If file doesn't exist or pattern not found:
237
+ observation({
238
+ type: "warning",
239
+ title: "Archived: [original title]",
240
+ narrative: "Archived during curation — [reason]. Original observation #<id>.",
241
+ supersedes: "<stale-id>",
242
+ confidence: "low",
243
+ });
244
+ ```
245
+
246
+ ### UPDATE (low confidence → verify)
247
+
248
+ ```typescript
249
+ // Search codebase for evidence
250
+ // If evidence found → upgrade confidence
251
+ // If evidence not found → archive
252
+ ```
253
+
254
+ ## Phase 6: Compile Knowledge Index
255
+
256
+ After curation, regenerate the knowledge index:
257
+
258
+ ```typescript
259
+ memory_admin({ operation: "compile" });
260
+ memory_admin({ operation: "index" });
261
+ ```
262
+
263
+ ## Phase 7: Report
264
+
265
+ ```
266
+ ## Curation Summary
267
+
268
+ **Scope:** [recent / all]
269
+ **Observations reviewed:** [N]
270
+ **Domains identified:** [N]
271
+
272
+ | Action | Count | Details |
273
+ |--------|-------|---------|
274
+ | Merged | [N] | [list merged pairs] |
275
+ | Resolved | [N] | [list resolved conflicts] |
276
+ | Archived | [N] | [list archived observations] |
277
+ | Updated | [N] | [list confidence changes] |
278
+ | No change | [N] | |
279
+
280
+ **Memory health:** [Healthy / Needs attention: describe]
281
+ **Next recommended:** /pr or continue work
282
+ ```
283
+
284
+ ## When Nothing to Curate
285
+
286
+ If all observations are clean, well-organized, and non-conflicting:
287
+
288
+ > "Memory is clean. No duplicates, contradictions, or stale observations found. [N] observations across [M] domains."
289
+
290
+ Don't force curation. Quality memory means less curation needed.
291
+
292
+ ## Related Commands
293
+
294
+ | Need | Command |
295
+ | ----------------------- | ------------------------------ |
296
+ | Extract learnings first | `/compound` |
297
+ | Full chain | `/lfg` |
298
+ | Check memory health | `/health` |
299
+ | Search memory | Use `memory-search()` directly |
@@ -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