opencodekit 0.18.6 → 0.18.8
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 +85 -7
- package/dist/template/.opencode/agent/build.md +9 -0
- package/dist/template/.opencode/dcp.jsonc +70 -81
- package/dist/template/.opencode/memory/project/gotchas.md +3 -3
- 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/package.json +1 -1
- package/dist/template/.opencode/pnpm-lock.yaml +71 -0
- package/dist/template/.opencode/skill/compaction/SKILL.md +19 -48
- package/dist/template/.opencode/skill/context-engineering/SKILL.md +1 -1
- package/dist/template/.opencode/skill/context-management/SKILL.md +16 -26
- package/dist/template/.opencode/skill/dispatching-parallel-agents/SKILL.md +4 -1
- package/dist/template/.opencode/skill/requesting-code-review/SKILL.md +30 -0
- package/dist/template/.opencode/skill/subagent-driven-development/SKILL.md +9 -2
- package/dist/template/.opencode/skill/verification-before-completion/SKILL.md +31 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -100,6 +100,14 @@ If a lookup, search, or tool call returns empty, partial, or suspiciously narrow
|
|
|
100
100
|
- For lists, batches, or paginated results: determine expected scope, track processed items, confirm full coverage
|
|
101
101
|
- If any item is blocked by missing data, mark it `[blocked]` and state exactly what is missing
|
|
102
102
|
|
|
103
|
+
### Plan Quality Gate
|
|
104
|
+
|
|
105
|
+
Before approving or executing any implementation plan:
|
|
106
|
+
|
|
107
|
+
1. Plan MUST contain a `## Discovery` section with substantive research findings (>100 characters)
|
|
108
|
+
2. Plans without documented discovery skip the research phase and produce worse implementations
|
|
109
|
+
3. If discovery is missing or boilerplate, reject the plan and research first
|
|
110
|
+
|
|
103
111
|
---
|
|
104
112
|
|
|
105
113
|
## Hard Constraints (Never Violate)
|
|
@@ -157,6 +165,74 @@ Use specialist agents by intent:
|
|
|
157
165
|
|
|
158
166
|
**Parallelism rule**: Use parallel subagents for 3+ independent tasks; otherwise work sequentially.
|
|
159
167
|
|
|
168
|
+
### Worker Distrust Protocol
|
|
169
|
+
|
|
170
|
+
Subagent self-reports are **approximately 50% accurate**. After every `task()` returns:
|
|
171
|
+
|
|
172
|
+
1. **Read changed files directly** — don't trust the summary; `git diff` or read modified files
|
|
173
|
+
2. **Run verification on modified files** — typecheck + lint at minimum; tests if the change touches behavior
|
|
174
|
+
3. **Check acceptance criteria** — compare actual output against the original task spec, not the agent's claims
|
|
175
|
+
4. **Verify nothing was broken** — check that files outside the agent's scope weren't unexpectedly modified
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
✅ Agent reports success → Read diff → Run verification → Confirm criteria → Accept
|
|
179
|
+
❌ Agent reports success → Trust it → Move on
|
|
180
|
+
❌ Agent reports success → Skim summary → Accept
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
This applies to ALL subagent types (`@general`, `@explore`, `@review`, `@scout`), not just implementation agents.
|
|
184
|
+
|
|
185
|
+
### Structured Termination Contract
|
|
186
|
+
|
|
187
|
+
Every subagent task MUST return a structured response. When dispatching, include this in the prompt:
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
Return your results in this exact format:
|
|
191
|
+
|
|
192
|
+
## Result
|
|
193
|
+
- **Status:** completed | blocked | failed
|
|
194
|
+
- **Files Modified:** [list of file paths]
|
|
195
|
+
- **Files Read:** [list of file paths consulted]
|
|
196
|
+
|
|
197
|
+
## Verification
|
|
198
|
+
- [What you verified and how]
|
|
199
|
+
- [Command output or evidence]
|
|
200
|
+
|
|
201
|
+
## Summary
|
|
202
|
+
[2-5 sentences: what was done, key decisions, anything unexpected]
|
|
203
|
+
|
|
204
|
+
## Blockers (if status is blocked/failed)
|
|
205
|
+
- [What's blocking]
|
|
206
|
+
- [What was tried]
|
|
207
|
+
- [Recommended next step]
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
When a subagent returns WITHOUT this structure, treat the response with extra skepticism — unstructured reports are more likely to omit failures or exaggerate completion.
|
|
211
|
+
|
|
212
|
+
### Context File Pattern
|
|
213
|
+
|
|
214
|
+
For complex delegations, write context to a file instead of inlining it in the `task()` prompt:
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
// ❌ Token-expensive: inlining large context
|
|
218
|
+
task({
|
|
219
|
+
prompt: `Here is the full plan:\n${longPlanContent}\n\nImplement task 3...`
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// ✅ Token-efficient: reference by path
|
|
223
|
+
// Write context file first:
|
|
224
|
+
write('.beads/artifacts/<id>/worker-context.md', contextContent);
|
|
225
|
+
// Then reference it:
|
|
226
|
+
task({
|
|
227
|
+
prompt: `Read the context file at .beads/artifacts/<id>/worker-context.md\n\nImplement task 3 as described in that file.`
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Use this pattern when:
|
|
232
|
+
- Context exceeds ~500 tokens
|
|
233
|
+
- Multiple subagents need the same context
|
|
234
|
+
- Plan content, research findings, or specs need to be passed to workers
|
|
235
|
+
|
|
160
236
|
---
|
|
161
237
|
|
|
162
238
|
## Question Policy
|
|
@@ -201,19 +277,21 @@ For major tracked work:
|
|
|
201
277
|
| Phase | Target | Action |
|
|
202
278
|
| ----------------- | ------- | ------------------------------------------ |
|
|
203
279
|
| Starting work | <50k | Load only essential AGENTS.md + task spec |
|
|
204
|
-
| Mid-task | 50-100k |
|
|
205
|
-
| Approaching limit | >100k | Aggressive
|
|
280
|
+
| Mid-task | 50-100k | Compress completed phases, keep active files |
|
|
281
|
+
| Approaching limit | >100k | Aggressive compression, sweep stale noise |
|
|
206
282
|
| Near capacity | >150k | Session restart with handoff |
|
|
207
283
|
|
|
208
|
-
###
|
|
284
|
+
### DCP Commands
|
|
209
285
|
|
|
210
|
-
- `
|
|
211
|
-
- `
|
|
286
|
+
- `/dcp context` — Show current context health and pressure
|
|
287
|
+
- `/dcp compress` — Compress completed conversation ranges (primary tool)
|
|
288
|
+
- `/dcp sweep` — Remove stale/noisy content according to DCP rules
|
|
289
|
+
- `/dcp stats` — Inspect pruning/compression activity
|
|
212
290
|
|
|
213
291
|
### Rules
|
|
214
292
|
|
|
215
|
-
1. **
|
|
216
|
-
2. **Batch
|
|
293
|
+
1. **Compress at phase boundaries** — not during active edits
|
|
294
|
+
2. **Batch cleanup** — use `/dcp sweep` for stale noise, not ad-hoc deletion
|
|
217
295
|
3. **Protected content** — AGENTS.md, .opencode/, .beads/, config files
|
|
218
296
|
|
|
219
297
|
---
|
|
@@ -350,6 +350,15 @@ task({ subagent_type: "general", description: "...", prompt: "..." });
|
|
|
350
350
|
|
|
351
351
|
Then synthesize results, verify locally, and report with file-level evidence.
|
|
352
352
|
|
|
353
|
+
**Mandatory post-delegation steps** (Worker Distrust Protocol):
|
|
354
|
+
|
|
355
|
+
1. Read changed files directly — don't trust the agent summary
|
|
356
|
+
2. Run verification on modified files (typecheck + lint minimum)
|
|
357
|
+
3. Check acceptance criteria against the original task spec
|
|
358
|
+
4. Only then accept the work
|
|
359
|
+
|
|
360
|
+
Include the **Structured Termination Contract** in every subagent prompt (Result/Verification/Summary/Blockers format). See AGENTS.md delegation policy for the template.
|
|
361
|
+
|
|
353
362
|
## Output
|
|
354
363
|
|
|
355
364
|
Report in this order:
|
|
@@ -1,83 +1,72 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// Note: default changed to false in beta, we explicitly enable
|
|
73
|
-
"supersedeWrites": {
|
|
74
|
-
"enabled": true,
|
|
75
|
-
},
|
|
76
|
-
// Purge error inputs after N turns
|
|
77
|
-
"purgeErrors": {
|
|
78
|
-
"enabled": true,
|
|
79
|
-
"turns": 4,
|
|
80
|
-
"protectedTools": [],
|
|
81
|
-
},
|
|
82
|
-
},
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/master/dcp.schema.json",
|
|
3
|
+
"enabled": true,
|
|
4
|
+
"debug": false,
|
|
5
|
+
// "minimal" shows prune activity without noise; "detailed" shows token counts
|
|
6
|
+
"pruneNotification": "detailed",
|
|
7
|
+
// "chat" (in-conversation) or "toast" (system notification)
|
|
8
|
+
"pruneNotificationType": "toast",
|
|
9
|
+
// Commands: /dcp context, /dcp stats, /dcp sweep, /dcp compress, /dcp decompress, /dcp recompress
|
|
10
|
+
"commands": {
|
|
11
|
+
"enabled": true,
|
|
12
|
+
// Protect these from /dcp sweep
|
|
13
|
+
"protectedTools": ["observation", "memory-update", "memory-search"]
|
|
14
|
+
},
|
|
15
|
+
// Manual mode: disables autonomous context management
|
|
16
|
+
"manualMode": {
|
|
17
|
+
"enabled": false,
|
|
18
|
+
"automaticStrategies": true
|
|
19
|
+
},
|
|
20
|
+
"turnProtection": {
|
|
21
|
+
"enabled": true,
|
|
22
|
+
"turns": 4
|
|
23
|
+
},
|
|
24
|
+
// Protected file patterns - never auto-prune reads of these files
|
|
25
|
+
"protectedFilePatterns": [
|
|
26
|
+
"**/.env*",
|
|
27
|
+
"**/AGENTS.md",
|
|
28
|
+
"**/.opencode/**",
|
|
29
|
+
"**/.beads/**",
|
|
30
|
+
"**/package.json",
|
|
31
|
+
"**/tsconfig.json",
|
|
32
|
+
"**/biome.json"
|
|
33
|
+
],
|
|
34
|
+
"compress": {
|
|
35
|
+
// v3.0.0: single compress tool replaces the old 3-tool system
|
|
36
|
+
"permission": "allow",
|
|
37
|
+
"showCompression": false,
|
|
38
|
+
"maxContextLimit": "80%",
|
|
39
|
+
"minContextLimit": 30000,
|
|
40
|
+
"nudgeFrequency": 5,
|
|
41
|
+
"iterationNudgeThreshold": 15,
|
|
42
|
+
"nudgeForce": "soft",
|
|
43
|
+
"flatSchema": false,
|
|
44
|
+
"protectUserMessages": true,
|
|
45
|
+
// v3.0.0 auto-protects: task, skill, todowrite, todoread, compress, batch, plan_enter, plan_exit
|
|
46
|
+
// Only list additional tools here
|
|
47
|
+
"protectedTools": ["write", "edit", "memory-*", "observation", "tilth_*"]
|
|
48
|
+
},
|
|
49
|
+
// Experimental features
|
|
50
|
+
"experimental": {
|
|
51
|
+
"allowSubAgents": true,
|
|
52
|
+
"customPrompts": false
|
|
53
|
+
},
|
|
54
|
+
// Auto strategies
|
|
55
|
+
"strategies": {
|
|
56
|
+
// Dedup = zero LLM cost, high impact - always enable
|
|
57
|
+
"deduplication": {
|
|
58
|
+
"enabled": true,
|
|
59
|
+
"protectedTools": []
|
|
60
|
+
},
|
|
61
|
+
// Supersede writes = zero cost, removes redundant write inputs after read
|
|
62
|
+
"supersedeWrites": {
|
|
63
|
+
"enabled": true
|
|
64
|
+
},
|
|
65
|
+
// Purge error inputs after N turns
|
|
66
|
+
"purgeErrors": {
|
|
67
|
+
"enabled": true,
|
|
68
|
+
"turns": 4,
|
|
69
|
+
"protectedTools": []
|
|
70
|
+
}
|
|
71
|
+
}
|
|
83
72
|
}
|
|
@@ -38,10 +38,10 @@ The edit tool (`str_replace`) is the #1 source of failures in LLM coding. Models
|
|
|
38
38
|
|
|
39
39
|
### Context Hygiene
|
|
40
40
|
|
|
41
|
-
-
|
|
42
|
-
-
|
|
41
|
+
- Compress completed work phases before moving on
|
|
42
|
+
- Use `/dcp sweep` after a closed phase to remove stale noise
|
|
43
43
|
- Token budget: <50k start → 50-100k mid → >150k restart session
|
|
44
|
-
- Subagent outputs can leak tokens —
|
|
44
|
+
- Subagent outputs can leak tokens — compress completed phases and sweep stale subagent noise
|
|
45
45
|
|
|
46
46
|
## OpenCode Config
|
|
47
47
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
lockfileVersion: '9.0'
|
|
2
|
+
|
|
3
|
+
settings:
|
|
4
|
+
autoInstallPeers: true
|
|
5
|
+
excludeLinksFromLockfile: false
|
|
6
|
+
|
|
7
|
+
importers:
|
|
8
|
+
|
|
9
|
+
.:
|
|
10
|
+
dependencies:
|
|
11
|
+
'@opencode-ai/plugin':
|
|
12
|
+
specifier: 1.2.22
|
|
13
|
+
version: 1.2.22
|
|
14
|
+
devDependencies:
|
|
15
|
+
'@types/node':
|
|
16
|
+
specifier: ^25.3.0
|
|
17
|
+
version: 25.3.5
|
|
18
|
+
bun-types:
|
|
19
|
+
specifier: ^1.3.9
|
|
20
|
+
version: 1.3.10
|
|
21
|
+
typescript:
|
|
22
|
+
specifier: ^5.9.3
|
|
23
|
+
version: 5.9.3
|
|
24
|
+
|
|
25
|
+
packages:
|
|
26
|
+
|
|
27
|
+
'@opencode-ai/plugin@1.2.22':
|
|
28
|
+
resolution: {integrity: sha512-vKVHymAGspLDBuObiJNSoCAQR+l6aMx6n21mgwNBa0BY4n0uzdJcM1rAN/Ksv/t6rsswMcsNeH0yMmj9Iokf7Q==}
|
|
29
|
+
|
|
30
|
+
'@opencode-ai/sdk@1.2.22':
|
|
31
|
+
resolution: {integrity: sha512-EXI1+Rc9dkzKo9uDj0EA4pLUCQJS2Qi8/xKwsT6RNZPBpSau05HVPWlZ+t8WyLW4fWymiho8jsXSErfKOpyCsw==}
|
|
32
|
+
|
|
33
|
+
'@types/node@25.3.5':
|
|
34
|
+
resolution: {integrity: sha512-oX8xrhvpiyRCQkG1MFchB09f+cXftgIXb3a7UUa4Y3wpmZPw5tyZGTLWhlESOLq1Rq6oDlc8npVU2/9xiCuXMA==}
|
|
35
|
+
|
|
36
|
+
bun-types@1.3.10:
|
|
37
|
+
resolution: {integrity: sha512-tcpfCCl6XWo6nCVnpcVrxQ+9AYN1iqMIzgrSKYMB/fjLtV2eyAVEg7AxQJuCq/26R6HpKWykQXuSOq/21RYcbg==}
|
|
38
|
+
|
|
39
|
+
typescript@5.9.3:
|
|
40
|
+
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
|
|
41
|
+
engines: {node: '>=14.17'}
|
|
42
|
+
hasBin: true
|
|
43
|
+
|
|
44
|
+
undici-types@7.18.2:
|
|
45
|
+
resolution: {integrity: sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==}
|
|
46
|
+
|
|
47
|
+
zod@4.1.8:
|
|
48
|
+
resolution: {integrity: sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ==}
|
|
49
|
+
|
|
50
|
+
snapshots:
|
|
51
|
+
|
|
52
|
+
'@opencode-ai/plugin@1.2.22':
|
|
53
|
+
dependencies:
|
|
54
|
+
'@opencode-ai/sdk': 1.2.22
|
|
55
|
+
zod: 4.1.8
|
|
56
|
+
|
|
57
|
+
'@opencode-ai/sdk@1.2.22': {}
|
|
58
|
+
|
|
59
|
+
'@types/node@25.3.5':
|
|
60
|
+
dependencies:
|
|
61
|
+
undici-types: 7.18.2
|
|
62
|
+
|
|
63
|
+
bun-types@1.3.10:
|
|
64
|
+
dependencies:
|
|
65
|
+
'@types/node': 25.3.5
|
|
66
|
+
|
|
67
|
+
typescript@5.9.3: {}
|
|
68
|
+
|
|
69
|
+
undici-types@7.18.2: {}
|
|
70
|
+
|
|
71
|
+
zod@4.1.8: {}
|
|
@@ -13,7 +13,7 @@ dependencies: []
|
|
|
13
13
|
|
|
14
14
|
## When to Use
|
|
15
15
|
|
|
16
|
-
- Context is growing large and needs
|
|
16
|
+
- Context is growing large and needs compression/cleanup to continue.
|
|
17
17
|
|
|
18
18
|
## When NOT to Use
|
|
19
19
|
|
|
@@ -33,8 +33,8 @@ Long-running sessions accumulate context (tool outputs, code reads, exploration
|
|
|
33
33
|
| Context Usage | Status | Action |
|
|
34
34
|
| ------------- | ----------- | --------------------------------------------- |
|
|
35
35
|
| 0-50% | 🟢 Normal | Work freely |
|
|
36
|
-
| 50-70% | 🟡 Watch | Start
|
|
37
|
-
| 70-85% | 🟠 Compact | Actively compress
|
|
36
|
+
| 50-70% | 🟡 Watch | Start compressing completed explorations |
|
|
37
|
+
| 70-85% | 🟠 Compact | Actively compress and sweep stale noise |
|
|
38
38
|
| 85-95% | 🔴 Critical | Emergency compaction, prepare session handoff |
|
|
39
39
|
| 95%+ | ⛔ Limit | Session handoff required |
|
|
40
40
|
|
|
@@ -42,31 +42,17 @@ Long-running sessions accumulate context (tool outputs, code reads, exploration
|
|
|
42
42
|
|
|
43
43
|
Pay attention to these signals:
|
|
44
44
|
|
|
45
|
-
-
|
|
45
|
+
- Completed phases accumulating without being compressed
|
|
46
46
|
- Repeated file reads of the same content
|
|
47
47
|
- Large bash outputs from builds/tests
|
|
48
48
|
- Multiple exploration rounds without synthesis
|
|
49
49
|
|
|
50
50
|
## Compaction Strategies
|
|
51
51
|
|
|
52
|
-
### Strategy 1:
|
|
52
|
+
### Strategy 1: Phase Compression (Preferred)
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
Compress completed conversation phases into dense summaries. This is the primary DCP instrument in the installed beta.
|
|
55
55
|
|
|
56
|
-
```
|
|
57
|
-
WHEN: You've read a file and extracted what you need
|
|
58
|
-
DO: distill({ targets: [{ id: "X", distillation: "..." }] })
|
|
59
|
-
|
|
60
|
-
WHEN: Bash output gave you the answer you needed
|
|
61
|
-
DO: distill({ targets: [{ id: "Y", distillation: "..." }] })
|
|
62
|
-
|
|
63
|
-
WHEN: Search results identified the relevant files
|
|
64
|
-
DO: distill({ targets: [{ id: "Z", distillation: "..." }] })
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**Key principle**: Distill when you're DONE with the raw output, not while you still need it.
|
|
68
|
-
|
|
69
|
-
### Strategy 2: Phase Compression
|
|
70
56
|
|
|
71
57
|
Compress completed conversation phases into dense summaries.
|
|
72
58
|
|
|
@@ -84,21 +70,18 @@ DO: compress({
|
|
|
84
70
|
|
|
85
71
|
**Key principle**: Only compress CLOSED chapters. Never compress active work.
|
|
86
72
|
|
|
87
|
-
### Strategy
|
|
73
|
+
### Strategy 2: Sweep Stale Noise
|
|
88
74
|
|
|
89
|
-
|
|
75
|
+
Use `/dcp sweep` after a phase is complete to remove stale/noisy content automatically.
|
|
90
76
|
|
|
91
77
|
```
|
|
92
|
-
WHEN:
|
|
93
|
-
DO:
|
|
94
|
-
|
|
95
|
-
WHEN: Earlier output is superseded by newer data
|
|
96
|
-
DO: prune({ ids: ["old_id"] })
|
|
78
|
+
WHEN: Wrong-target searches or superseded outputs are no longer needed
|
|
79
|
+
DO: /dcp sweep
|
|
97
80
|
```
|
|
98
81
|
|
|
99
|
-
**Key principle**:
|
|
82
|
+
**Key principle**: Sweep only after the relevant phase is closed. If in doubt, keep it.
|
|
100
83
|
|
|
101
|
-
### Strategy
|
|
84
|
+
### Strategy 3: Session Handoff
|
|
102
85
|
|
|
103
86
|
When context is too large to compact further, hand off to a new session.
|
|
104
87
|
|
|
@@ -117,9 +100,8 @@ DO:
|
|
|
117
100
|
Is context growing large?
|
|
118
101
|
├── NO → Continue working normally
|
|
119
102
|
└── YES → What type of content is consuming space?
|
|
120
|
-
├── Tool outputs I'm done with → DISTILL
|
|
121
103
|
├── Completed conversation phases → COMPRESS
|
|
122
|
-
├──
|
|
104
|
+
├── Stale/noisy closed-phase outputs → SWEEP
|
|
123
105
|
└── Everything is still relevant → SESSION HANDOFF
|
|
124
106
|
```
|
|
125
107
|
|
|
@@ -275,9 +257,8 @@ memory - search({ query: "auth implementation" });
|
|
|
275
257
|
|
|
276
258
|
This project uses `@tarquinen/opencode-dcp` for always-on context management (injected via `experimental.chat.system.transform`):
|
|
277
259
|
|
|
278
|
-
- **
|
|
279
|
-
-
|
|
280
|
-
- **prune**: Targeted removal of noise (last resort — batch wisely)
|
|
260
|
+
- **compress**: Phase-level conversation compression (primary DCP tool in the installed beta)
|
|
261
|
+
- **/dcp sweep**: Cleanup command for stale/noisy content after a phase is complete
|
|
281
262
|
- **Prunable-tools list**: Auto-injected into messages with token estimates
|
|
282
263
|
- **Nudge system**: Reminders every N tool calls + critical limit warnings
|
|
283
264
|
|
|
@@ -298,15 +279,6 @@ edit({ ... }) // Now you can't find the right location
|
|
|
298
279
|
|
|
299
280
|
**Fix**: Keep raw content while actively editing. Compress AFTER the edit phase.
|
|
300
281
|
|
|
301
|
-
### ❌ Lossy Distillation
|
|
302
|
-
|
|
303
|
-
```
|
|
304
|
-
// DON'T distill without capturing key details
|
|
305
|
-
distill({ distillation: "Read the auth file, it has some functions" })
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
**Fix**: Include function signatures, types, key logic, constraints — everything you'd need to avoid re-reading.
|
|
309
|
-
|
|
310
282
|
### ❌ Compressing Active Work
|
|
311
283
|
|
|
312
284
|
```
|
|
@@ -324,23 +296,22 @@ compress({ summary: "Explored auth options" })
|
|
|
324
296
|
// By the time you notice, emergency compaction loses information
|
|
325
297
|
```
|
|
326
298
|
|
|
327
|
-
**Fix**: Monitor regularly.
|
|
299
|
+
**Fix**: Monitor regularly. Compress at natural breakpoints and use `/dcp sweep` after closed phases.
|
|
328
300
|
|
|
329
301
|
## Checklist
|
|
330
302
|
|
|
331
303
|
Before compacting:
|
|
332
304
|
|
|
333
305
|
- [ ] Identified what type of content is consuming context
|
|
334
|
-
- [ ] Chosen appropriate strategy (
|
|
306
|
+
- [ ] Chosen appropriate strategy (compress/sweep/handoff)
|
|
335
307
|
- [ ] Verified raw content is no longer needed for active work
|
|
336
|
-
- [ ] Captured all key details in
|
|
308
|
+
- [ ] Captured all key details in the compression summary or handoff
|
|
337
309
|
- [ ] Saved important decisions as observations
|
|
338
310
|
- [ ] Created handoff document if switching sessions
|
|
339
311
|
|
|
340
312
|
During long sessions:
|
|
341
313
|
|
|
342
|
-
- [ ] Distilling tool outputs after extracting insights
|
|
343
314
|
- [ ] Compressing completed phases at natural breakpoints
|
|
344
|
-
- [ ]
|
|
315
|
+
- [ ] Sweeping stale/noisy outputs after phase completion
|
|
345
316
|
- [ ] Monitoring context usage trends
|
|
346
317
|
- [ ] Planning session handoff if approaching limits
|
|
@@ -62,7 +62,7 @@ Extend it by:
|
|
|
62
62
|
| Reading entire files | Use `lsp documentSymbol` for outline |
|
|
63
63
|
| Loading whole documents | Read specific line ranges |
|
|
64
64
|
| Flat file loading | Navigate AGENTS.md hierarchy |
|
|
65
|
-
| Keeping completed work |
|
|
65
|
+
| Keeping completed work | Compress closed phases, sweep stale noise (context-management) |
|
|
66
66
|
|
|
67
67
|
## Anti-Patterns
|
|
68
68
|
|
|
@@ -29,14 +29,14 @@ Use this skill to keep context useful from first turn to final handoff.
|
|
|
29
29
|
Prefer **phase-level compression** over reactive cleanup.
|
|
30
30
|
|
|
31
31
|
```text
|
|
32
|
-
compress >
|
|
32
|
+
compress > sweep > handoff
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
- **compress**: Best default when a phase is complete
|
|
36
|
-
- **
|
|
37
|
-
- **
|
|
36
|
+
- **sweep**: Use `/dcp sweep` to clean stale/noisy content after completion
|
|
37
|
+
- **handoff**: Use when context pressure remains high even after compression
|
|
38
38
|
|
|
39
|
-
## DCP
|
|
39
|
+
## DCP Command Usage
|
|
40
40
|
|
|
41
41
|
### `/dcp compress`
|
|
42
42
|
|
|
@@ -46,26 +46,17 @@ Use for completed chapters of work (research, implementation wave, review sweep)
|
|
|
46
46
|
- Lowest cognitive overhead on later turns
|
|
47
47
|
- Usually lowest risk of deleting needed details
|
|
48
48
|
|
|
49
|
-
### `/dcp
|
|
49
|
+
### `/dcp sweep`
|
|
50
50
|
|
|
51
|
-
Use
|
|
51
|
+
Use after a phase is complete to let DCP remove stale/noisy content automatically.
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
- function signatures
|
|
56
|
-
- constraints and assumptions
|
|
57
|
-
- file paths and key decisions
|
|
58
|
-
- verification outcomes
|
|
59
|
-
|
|
60
|
-
### `/dcp prune`
|
|
61
|
-
|
|
62
|
-
Use only for irrelevant/noise outputs:
|
|
53
|
+
Good candidates for sweep-driven cleanup:
|
|
63
54
|
|
|
64
55
|
- wrong-target searches
|
|
65
56
|
- failed dead-end exploration no longer needed
|
|
66
57
|
- duplicate or superseded junk output
|
|
67
58
|
|
|
68
|
-
Do **not**
|
|
59
|
+
Do **not** sweep because output is merely "long". Length alone is not noise.
|
|
69
60
|
|
|
70
61
|
## Session Lifecycle Protocol
|
|
71
62
|
|
|
@@ -82,7 +73,7 @@ Do **not** prune because output is "long". Length alone is not noise.
|
|
|
82
73
|
|
|
83
74
|
- Keep active files readable until edits are done
|
|
84
75
|
- At each natural boundary, evaluate compress candidates
|
|
85
|
-
-
|
|
76
|
+
- Compress completed phases before starting the next chapter
|
|
86
77
|
|
|
87
78
|
### 3) Pre-Handoff / Closeout
|
|
88
79
|
|
|
@@ -104,7 +95,7 @@ Use these thresholds as operational triggers:
|
|
|
104
95
|
| --- | --- | --- |
|
|
105
96
|
| <50k | Healthy start | Keep inputs minimal, avoid unnecessary reads |
|
|
106
97
|
| 50k–100k | Moderate growth | Compress completed phases, keep active files intact |
|
|
107
|
-
| >100k | High pressure | Aggressively compress by phase;
|
|
98
|
+
| >100k | High pressure | Aggressively compress by phase; run `/dcp sweep` on stale noise |
|
|
108
99
|
| >150k | Near capacity | Perform handoff and resume in a fresh session |
|
|
109
100
|
|
|
110
101
|
Secondary guardrails:
|
|
@@ -140,7 +131,7 @@ Carry forward decisions and constraints, not every intermediate log.
|
|
|
140
131
|
| Anti-Pattern | Why It Hurts | Correct Pattern |
|
|
141
132
|
| --- | --- | --- |
|
|
142
133
|
| Compressing active work areas (losing precision needed for edits) | Removes exact lines needed for safe edits | Keep active file/tool outputs until edit + verification complete |
|
|
143
|
-
|
|
|
134
|
+
| Sweeping content you still need | Forces rework and increases error risk | Keep active files/tool outputs until phase is complete |
|
|
144
135
|
| Not compressing completed exploration phases | Bloats context and degrades later turns | Compress immediately at phase completion |
|
|
145
136
|
| Session handoff without persisting key decisions to memory | Next session loses rationale and constraints | Write observations/memory updates before handoff |
|
|
146
137
|
|
|
@@ -151,7 +142,7 @@ Check context health: are completed phases compressed? Are active files still re
|
|
|
151
142
|
Before claiming cleanup done, confirm:
|
|
152
143
|
|
|
153
144
|
- Active edit targets are still present in readable form
|
|
154
|
-
- Completed phases are compressed
|
|
145
|
+
- Completed phases are compressed or intentionally kept for active work
|
|
155
146
|
- No critical decision exists only in transient tool output
|
|
156
147
|
- Handoff includes next actions and blockers
|
|
157
148
|
|
|
@@ -160,11 +151,10 @@ Before claiming cleanup done, confirm:
|
|
|
160
151
|
```text
|
|
161
152
|
1) Start turn: /dcp context
|
|
162
153
|
2) Identify completed phase ranges
|
|
163
|
-
3) compress completed ranges
|
|
164
|
-
4)
|
|
165
|
-
5)
|
|
166
|
-
6)
|
|
167
|
-
7) handoff/resume with focused rehydration
|
|
154
|
+
3) /dcp compress completed ranges
|
|
155
|
+
4) /dcp sweep stale/noisy outputs after phase completion
|
|
156
|
+
5) persist key decisions to memory
|
|
157
|
+
6) handoff/resume with focused rehydration
|
|
168
158
|
```
|
|
169
159
|
|
|
170
160
|
## See Also
|
|
@@ -82,6 +82,7 @@ Good agent prompts are:
|
|
|
82
82
|
1. **Focused** - One clear problem domain
|
|
83
83
|
2. **Self-contained** - All context needed to understand the problem
|
|
84
84
|
3. **Specific about output** - What should the agent return?
|
|
85
|
+
4. **Structured termination** - Include the Structured Termination Contract from AGENTS.md (Result/Verification/Summary/Blockers format)
|
|
85
86
|
|
|
86
87
|
```markdown
|
|
87
88
|
Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts:
|
|
@@ -101,9 +102,11 @@ These are timing/race condition issues. Your task:
|
|
|
101
102
|
|
|
102
103
|
Do NOT just increase timeouts - find the real issue.
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
[Include Structured Termination Contract here]
|
|
105
106
|
```
|
|
106
107
|
|
|
108
|
+
For large investigations (context >500 tokens), use the **Context File Pattern** from AGENTS.md — write context to `.beads/artifacts/<id>/investigation-context.md` and reference by path in the dispatch prompt.
|
|
109
|
+
|
|
107
110
|
## Common Mistakes
|
|
108
111
|
|
|
109
112
|
**❌ Too broad:** "Fix all the tests" - agent gets lost
|
|
@@ -94,6 +94,36 @@ Choose the smallest review depth that still covers the risk.
|
|
|
94
94
|
|
|
95
95
|
Do **not** dispatch 5 reviewers by reflex for every tiny change. That produces noise, not rigor.
|
|
96
96
|
|
|
97
|
+
## Review Scope Self-Check
|
|
98
|
+
|
|
99
|
+
Before writing ANY review finding, the reviewer MUST ask:
|
|
100
|
+
|
|
101
|
+
> **"Am I questioning APPROACH or DOCUMENTATION/CORRECTNESS?"**
|
|
102
|
+
|
|
103
|
+
| Answer | Action |
|
|
104
|
+
| --- | --- |
|
|
105
|
+
| **APPROACH** — "I would have done it differently" | **Stay silent.** The approach was decided during planning. Review doesn't re-litigate design. |
|
|
106
|
+
| **DOCUMENTATION** — "A new developer couldn't execute this" | **Raise it.** Missing file paths, vague acceptance criteria, assumed context. |
|
|
107
|
+
| **CORRECTNESS** — "This will break at runtime" | **Raise it.** Bugs, security holes, type errors, logic flaws. |
|
|
108
|
+
|
|
109
|
+
### Red Flags for Scope Creep
|
|
110
|
+
|
|
111
|
+
- Suggesting alternative libraries or frameworks → **out of scope** (approach)
|
|
112
|
+
- "I would rename this to..." without a concrete bug → **out of scope** (style preference)
|
|
113
|
+
- "Consider adding feature X" that wasn't in requirements → **out of scope** (scope inflation)
|
|
114
|
+
- "This could be more performant" without evidence of a real problem → **out of scope** (premature optimization)
|
|
115
|
+
|
|
116
|
+
### What Reviewers SHOULD Flag
|
|
117
|
+
|
|
118
|
+
- Missing error handling that will crash in production → **correctness**
|
|
119
|
+
- Vague acceptance criteria that workers can't verify → **documentation**
|
|
120
|
+
- Hardcoded values with no explanation → **documentation**
|
|
121
|
+
- Missing file paths for tasks that require edits → **documentation**
|
|
122
|
+
- "Use the existing pattern" without specifying which pattern → **documentation**
|
|
123
|
+
- Security vulnerabilities (injection, auth bypass, secrets) → **correctness**
|
|
124
|
+
|
|
125
|
+
Include this self-check instruction in EVERY review dispatch prompt to prevent bikeshedding.
|
|
126
|
+
|
|
97
127
|
## Step 1: Get Git Context
|
|
98
128
|
|
|
99
129
|
### Setup Checklist
|
|
@@ -35,6 +35,8 @@ dependencies: [executing-plans]
|
|
|
35
35
|
|
|
36
36
|
Read plan file, create TodoWrite with all tasks.
|
|
37
37
|
|
|
38
|
+
**Context file pattern:** If the plan exceeds ~500 tokens, write it to `.beads/artifacts/<id>/plan-context.md` and reference by path in subagent prompts instead of inlining. This saves tokens when dispatching multiple subagents from the same plan.
|
|
39
|
+
|
|
38
40
|
### 2. Execute Task with Subagent
|
|
39
41
|
|
|
40
42
|
For each task:
|
|
@@ -56,10 +58,15 @@ Task tool (general-purpose):
|
|
|
56
58
|
|
|
57
59
|
Work from: [directory]
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
[Include Structured Termination Contract from AGENTS.md]
|
|
60
62
|
```
|
|
61
63
|
|
|
62
|
-
**
|
|
64
|
+
**After subagent reports back** — follow the **Worker Distrust Protocol** from AGENTS.md:
|
|
65
|
+
|
|
66
|
+
1. Read changed files directly (don't trust the report)
|
|
67
|
+
2. Run verification on modified files (typecheck + lint minimum)
|
|
68
|
+
3. Check acceptance criteria against original task spec
|
|
69
|
+
4. Only then mark the task as complete
|
|
63
70
|
|
|
64
71
|
### 3. Review Subagent's Work
|
|
65
72
|
|
|
@@ -168,6 +168,37 @@ If you just verified and nothing changed, don't re-verify:
|
|
|
168
168
|
|
|
169
169
|
This matters when other commands need verification (e.g., closing beads, `/ship`). If you verified 30 seconds ago and made no changes, the cache lets you skip.
|
|
170
170
|
|
|
171
|
+
## Enforcement Gates
|
|
172
|
+
|
|
173
|
+
Prompt-level rules get ignored under pressure. These gates are **hard blocks** — they must be checked at the tool/action level, not just remembered.
|
|
174
|
+
|
|
175
|
+
### Gate 1: Completion Claims Require verify.log
|
|
176
|
+
|
|
177
|
+
Before ANY completion claim (bead close, PR creation, `/ship`, task completion):
|
|
178
|
+
|
|
179
|
+
1. Check `.beads/verify.log` exists and contains a recent `PASS` stamp
|
|
180
|
+
2. If verify.log is missing or stale (older than last file change) → **BLOCK** — run verification first
|
|
181
|
+
3. If verify.log shows `FAIL` → **BLOCK** — do not proceed
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
✅ verify.log exists, PASS within last edit window → proceed
|
|
185
|
+
❌ verify.log missing → STOP: "Run verification first"
|
|
186
|
+
❌ verify.log shows FAIL → STOP: "Verification failed, fix before claiming complete"
|
|
187
|
+
❌ verify.log stale (files changed since last PASS) → STOP: "Re-run verification"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Gate 2: Agent Delegation Requires Post-Verification
|
|
191
|
+
|
|
192
|
+
After ANY `task()` subagent returns with "success", follow the **Worker Distrust Protocol** from AGENTS.md — read changed files, run verification, check acceptance criteria. Do not trust agent self-reports.
|
|
193
|
+
|
|
194
|
+
### Enforcement Principle
|
|
195
|
+
|
|
196
|
+
> **Prompt rules fail under pressure. Gates fail safe.**
|
|
197
|
+
>
|
|
198
|
+
> When a constraint matters enough to be an iron law, enforce it at the action level:
|
|
199
|
+
> check a file, verify a condition, reject if unmet. Don't rely on the agent
|
|
200
|
+
> "remembering" to follow the rule.
|
|
201
|
+
|
|
171
202
|
## Why This Matters
|
|
172
203
|
|
|
173
204
|
From 24 failure memories:
|