opencodekit 0.16.4 → 0.16.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 +106 -384
- package/dist/template/.opencode/README.md +170 -104
- package/dist/template/.opencode/agent/build.md +39 -32
- package/dist/template/.opencode/agent/explore.md +2 -0
- package/dist/template/.opencode/agent/review.md +3 -0
- package/dist/template/.opencode/agent/scout.md +22 -11
- package/dist/template/.opencode/command/create.md +164 -106
- package/dist/template/.opencode/command/design.md +5 -1
- package/dist/template/.opencode/command/handoff.md +6 -4
- package/dist/template/.opencode/command/init.md +1 -1
- package/dist/template/.opencode/command/plan.md +26 -23
- package/dist/template/.opencode/command/research.md +13 -6
- package/dist/template/.opencode/command/resume.md +8 -6
- package/dist/template/.opencode/command/ship.md +1 -1
- package/dist/template/.opencode/command/start.md +30 -25
- package/dist/template/.opencode/command/status.md +9 -42
- package/dist/template/.opencode/command/verify.md +11 -11
- package/dist/template/.opencode/memory/README.md +67 -37
- package/dist/template/.opencode/memory/_templates/prd.md +102 -18
- package/dist/template/.opencode/memory/project/gotchas.md +31 -0
- 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/opencode.json +0 -10
- package/dist/template/.opencode/package.json +1 -1
- package/dist/template/.opencode/skill/beads/SKILL.md +164 -380
- package/dist/template/.opencode/skill/beads/references/BOUNDARIES.md +23 -22
- package/dist/template/.opencode/skill/beads/references/DEPENDENCIES.md +23 -29
- package/dist/template/.opencode/skill/beads/references/RESUMABILITY.md +5 -8
- package/dist/template/.opencode/skill/beads/references/WORKFLOWS.md +43 -39
- package/dist/template/.opencode/skill/beads-bridge/SKILL.md +80 -53
- package/dist/template/.opencode/skill/brainstorming/SKILL.md +19 -5
- package/dist/template/.opencode/skill/context-engineering/SKILL.md +30 -63
- package/dist/template/.opencode/skill/context-management/SKILL.md +115 -0
- package/dist/template/.opencode/skill/deep-research/SKILL.md +4 -4
- package/dist/template/.opencode/skill/development-lifecycle/SKILL.md +305 -0
- package/dist/template/.opencode/skill/memory-system/SKILL.md +3 -3
- package/dist/template/.opencode/skill/prd/SKILL.md +47 -122
- package/dist/template/.opencode/skill/prd-task/SKILL.md +48 -4
- package/dist/template/.opencode/skill/prd-task/references/prd-schema.json +120 -24
- package/dist/template/.opencode/skill/swarm-coordination/SKILL.md +79 -61
- package/dist/template/.opencode/skill/tool-priority/SKILL.md +31 -22
- package/dist/template/.opencode/tool/context7.ts +183 -0
- package/dist/template/.opencode/tool/memory-admin.ts +445 -0
- package/dist/template/.opencode/tool/swarm.ts +572 -0
- package/package.json +1 -1
- package/dist/template/.opencode/memory/_templates/spec.md +0 -66
- package/dist/template/.opencode/tool/beads-sync.ts +0 -657
- package/dist/template/.opencode/tool/context7-query-docs.ts +0 -89
- package/dist/template/.opencode/tool/context7-resolve-library-id.ts +0 -113
- package/dist/template/.opencode/tool/memory-maintain.ts +0 -167
- package/dist/template/.opencode/tool/memory-migrate.ts +0 -319
- package/dist/template/.opencode/tool/swarm-delegate.ts +0 -180
- package/dist/template/.opencode/tool/swarm-monitor.ts +0 -388
- package/dist/template/.opencode/tool/swarm-plan.ts +0 -697
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: beads-bridge
|
|
3
3
|
description: >
|
|
4
|
-
Multi-agent task coordination using
|
|
4
|
+
Multi-agent task coordination using br (beads_rust) and OpenCode tools. Use when work spans multiple sessions,
|
|
5
5
|
has dependencies, needs file locking, or requires agent coordination. Covers claim/reserve/done cycle,
|
|
6
6
|
dependency management, hierarchical decomposition, and session protocols.
|
|
7
|
-
version: "
|
|
7
|
+
version: "2.0.0"
|
|
8
8
|
license: MIT
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -12,23 +12,29 @@ license: MIT
|
|
|
12
12
|
|
|
13
13
|
Bridge between Beads git-backed task tracking, OpenCode's native todo system, and swarm coordination.
|
|
14
14
|
|
|
15
|
+
**Note:** `br` (beads_rust) is non-invasive and never executes git commands. After `br sync --flush-only`, you must manually run `git add .beads/ && git commit`.
|
|
16
|
+
|
|
15
17
|
## Overview
|
|
16
18
|
|
|
17
|
-
**Beads Bridge = Beads + OpenCode Todos + Swarm Monitor**
|
|
19
|
+
**Beads Bridge = Beads (br) + OpenCode Todos + Swarm Monitor**
|
|
18
20
|
|
|
19
|
-
- **Beads**: Git-backed task tracking with dependency management
|
|
21
|
+
- **Beads (br)**: Git-backed task tracking with dependency management
|
|
20
22
|
- **OpenCode Todos**: Native session-scoped task lists for subagents
|
|
21
23
|
- **Swarm Monitor**: Real-time progress tracking (visualization only)
|
|
22
24
|
|
|
23
25
|
**Key Tools**:
|
|
24
26
|
|
|
25
|
-
| Tool
|
|
26
|
-
|
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
| Tool | Purpose | When to Use |
|
|
28
|
+
| ------- | --------------------------- | ---------------------------------------------------- |
|
|
29
|
+
| `swarm` | Unified swarm coordination | All swarm operations (sync, monitor, plan, delegate) |
|
|
30
|
+
| `Task` | Parallel subagent execution | Spawning worker swarms |
|
|
31
|
+
|
|
32
|
+
**swarm operations:**
|
|
33
|
+
|
|
34
|
+
- `sync`: Sync Beads ↔ OpenCode todos (start of session, before spawning)
|
|
35
|
+
- `monitor`: Progress tracking/visualization (during swarm execution)
|
|
36
|
+
- `plan`: Task classification + dependency graphs (before spawning workers)
|
|
37
|
+
- `delegate`: Create delegation packets (assigning work to workers)
|
|
32
38
|
|
|
33
39
|
## When to Use This Skill
|
|
34
40
|
|
|
@@ -46,8 +52,9 @@ Make Beads tasks visible to subagents:
|
|
|
46
52
|
|
|
47
53
|
```typescript
|
|
48
54
|
// Push Beads to OpenCode todos
|
|
49
|
-
const result = await
|
|
50
|
-
operation: "
|
|
55
|
+
const result = await swarm({
|
|
56
|
+
operation: "sync",
|
|
57
|
+
action: "push",
|
|
51
58
|
filter: "open", // or "in_progress", "all"
|
|
52
59
|
});
|
|
53
60
|
|
|
@@ -61,8 +68,9 @@ Check current swarm progress:
|
|
|
61
68
|
|
|
62
69
|
```typescript
|
|
63
70
|
// Check swarm status
|
|
64
|
-
const status = await
|
|
65
|
-
operation: "
|
|
71
|
+
const status = await swarm({
|
|
72
|
+
operation: "monitor",
|
|
73
|
+
action: "status",
|
|
66
74
|
team_name: "api-refactor-swarm",
|
|
67
75
|
});
|
|
68
76
|
|
|
@@ -70,8 +78,9 @@ const stats = JSON.parse(status).summary;
|
|
|
70
78
|
console.log(`Workers: ${stats.total_workers}, Completed: ${stats.completed}`);
|
|
71
79
|
|
|
72
80
|
// Render TUI for visualization
|
|
73
|
-
const ui = await
|
|
74
|
-
operation: "
|
|
81
|
+
const ui = await swarm({
|
|
82
|
+
operation: "monitor",
|
|
83
|
+
action: "render_block",
|
|
75
84
|
team_name: "api-refactor-swarm",
|
|
76
85
|
});
|
|
77
86
|
console.log(ui);
|
|
@@ -83,8 +92,9 @@ For work that spans multiple sessions, use shared task lists:
|
|
|
83
92
|
|
|
84
93
|
```typescript
|
|
85
94
|
// Create a shared list that persists across sessions
|
|
86
|
-
const list = await
|
|
87
|
-
operation: "
|
|
95
|
+
const list = await swarm({
|
|
96
|
+
operation: "sync",
|
|
97
|
+
action: "create_shared",
|
|
88
98
|
name: "api-refactor-swarm",
|
|
89
99
|
tasks: JSON.stringify([
|
|
90
100
|
{ id: "task-1", content: "Refactor auth endpoint", status: "pending", priority: "high" },
|
|
@@ -93,8 +103,9 @@ const list = await beads_sync({
|
|
|
93
103
|
});
|
|
94
104
|
|
|
95
105
|
// Workers update the shared list as they complete work
|
|
96
|
-
await
|
|
97
|
-
operation: "
|
|
106
|
+
await swarm({
|
|
107
|
+
operation: "sync",
|
|
108
|
+
action: "update_shared",
|
|
98
109
|
list_id: list.list_id,
|
|
99
110
|
tasks: JSON.stringify([{ id: "task-1", status: "completed" }]),
|
|
100
111
|
});
|
|
@@ -106,8 +117,9 @@ Create persistent task lists that survive session boundaries:
|
|
|
106
117
|
|
|
107
118
|
```typescript
|
|
108
119
|
// Create a shared list for a swarm
|
|
109
|
-
const list = await
|
|
110
|
-
operation: "
|
|
120
|
+
const list = await swarm({
|
|
121
|
+
operation: "sync",
|
|
122
|
+
action: "create_shared",
|
|
111
123
|
name: "api-refactor-swarm",
|
|
112
124
|
tasks: JSON.stringify([
|
|
113
125
|
{ id: "task-1", content: "Refactor auth endpoint", status: "pending", priority: "high" },
|
|
@@ -118,7 +130,7 @@ const list = await beads_sync({
|
|
|
118
130
|
|
|
119
131
|
// Share the list ID with workers
|
|
120
132
|
console.log(`List ID: ${list.list_id}`);
|
|
121
|
-
// Workers can access via:
|
|
133
|
+
// Workers can access via: swarm({ operation: "sync", action: "get_shared", list_id: "..." })
|
|
122
134
|
```
|
|
123
135
|
|
|
124
136
|
### 5. Worker Updates to Shared List
|
|
@@ -127,8 +139,9 @@ Workers can update their task status:
|
|
|
127
139
|
|
|
128
140
|
```typescript
|
|
129
141
|
// Worker completes a task
|
|
130
|
-
await
|
|
131
|
-
operation: "
|
|
142
|
+
await swarm({
|
|
143
|
+
operation: "sync",
|
|
144
|
+
action: "update_shared",
|
|
132
145
|
list_id: "shl_abc123",
|
|
133
146
|
tasks: JSON.stringify([{ id: "task-1", status: "completed" }]),
|
|
134
147
|
});
|
|
@@ -142,14 +155,15 @@ Full cycle from Beads task to swarm execution and back:
|
|
|
142
155
|
|
|
143
156
|
```typescript
|
|
144
157
|
// 1. Start: Push Beads to todos
|
|
145
|
-
await
|
|
158
|
+
await swarm({ operation: "sync", action: "push" });
|
|
146
159
|
|
|
147
160
|
// 2. Claim the parent Bead
|
|
148
161
|
await bash("br update parent-task --status in_progress");
|
|
149
162
|
|
|
150
163
|
// 3. Analyze and spawn swarm
|
|
151
|
-
const analysis = await
|
|
152
|
-
operation: "
|
|
164
|
+
const analysis = await swarm({
|
|
165
|
+
operation: "plan",
|
|
166
|
+
action: "analyze",
|
|
153
167
|
task: "Implement API refactor",
|
|
154
168
|
files: "src/api/users.ts,src/api/posts.ts,src/api/auth.ts",
|
|
155
169
|
});
|
|
@@ -158,26 +172,30 @@ const analysis = await swarm_plan({
|
|
|
158
172
|
// ... spawn workers, monitor progress ...
|
|
159
173
|
|
|
160
174
|
// 5. Complete: Pull completed todos back to Beads
|
|
161
|
-
await
|
|
175
|
+
await swarm({ operation: "sync", action: "pull" });
|
|
162
176
|
|
|
163
177
|
// 6. Clear swarm state
|
|
164
|
-
await
|
|
165
|
-
operation: "
|
|
178
|
+
await swarm({
|
|
179
|
+
operation: "monitor",
|
|
180
|
+
action: "clear",
|
|
166
181
|
team_name: "api-refactor-swarm",
|
|
167
182
|
});
|
|
168
183
|
|
|
169
|
-
// 7. Close parent Bead
|
|
184
|
+
// 7. Close parent Bead and sync
|
|
170
185
|
await bash("br close parent-task --reason 'Swarm completed all subtasks'");
|
|
186
|
+
await bash("br sync --flush-only");
|
|
187
|
+
await bash("git add .beads/ && git commit -m 'close parent-task'");
|
|
171
188
|
```
|
|
172
189
|
|
|
173
190
|
### Pattern B: Dependency-Aware Task Scheduling
|
|
174
191
|
|
|
175
|
-
Use swarm
|
|
192
|
+
Use swarm tool's dependency graph for proper ordering:
|
|
176
193
|
|
|
177
194
|
```typescript
|
|
178
195
|
// Get full analysis with dependency graph
|
|
179
|
-
const analysis = await
|
|
180
|
-
operation: "
|
|
196
|
+
const analysis = await swarm({
|
|
197
|
+
operation: "plan",
|
|
198
|
+
action: "analyze",
|
|
181
199
|
task: "Refactor authentication system",
|
|
182
200
|
files: "src/auth/service.ts,src/auth/types.ts,src/routes/auth.ts,src/middleware/auth.ts",
|
|
183
201
|
});
|
|
@@ -212,8 +230,9 @@ When work needs to continue in a new session:
|
|
|
212
230
|
|
|
213
231
|
```typescript
|
|
214
232
|
// End of session 1: Save state to memory and shared list
|
|
215
|
-
await
|
|
216
|
-
operation: "
|
|
233
|
+
await swarm({
|
|
234
|
+
operation: "sync",
|
|
235
|
+
action: "update_shared",
|
|
217
236
|
list_id: "api-refactor-swarm",
|
|
218
237
|
tasks: JSON.stringify([
|
|
219
238
|
{ id: "worker-1", content: "Auth service", status: "completed" },
|
|
@@ -240,14 +259,20 @@ Next steps:
|
|
|
240
259
|
mode: "replace",
|
|
241
260
|
});
|
|
242
261
|
|
|
262
|
+
// Sync beads before ending session
|
|
263
|
+
await bash("br sync --flush-only");
|
|
264
|
+
await bash("git add .beads/ && git commit -m 'session handoff'");
|
|
265
|
+
|
|
243
266
|
// Start of session 2: Check status and continue
|
|
244
|
-
const status = await
|
|
245
|
-
operation: "
|
|
267
|
+
const status = await swarm({
|
|
268
|
+
operation: "monitor",
|
|
269
|
+
action: "status",
|
|
246
270
|
team_name: "api-refactor-swarm",
|
|
247
271
|
});
|
|
248
272
|
|
|
249
|
-
const shared = await
|
|
250
|
-
operation: "
|
|
273
|
+
const shared = await swarm({
|
|
274
|
+
operation: "sync",
|
|
275
|
+
action: "get_shared",
|
|
251
276
|
list_id: "api-refactor-swarm",
|
|
252
277
|
});
|
|
253
278
|
|
|
@@ -267,28 +292,30 @@ console.log(`Continuing swarm with ${shared.tasks.length} tasks...`);
|
|
|
267
292
|
|
|
268
293
|
```
|
|
269
294
|
SESSION START:
|
|
270
|
-
|
|
271
|
-
swarm
|
|
295
|
+
swarm({ operation: "sync", action: "push" }) // Make Beads visible to subagents
|
|
296
|
+
swarm({ operation: "monitor", action: "status", team_name: "..." }) // Check swarm status
|
|
272
297
|
|
|
273
298
|
DURING WORK:
|
|
274
|
-
swarm
|
|
275
|
-
swarm
|
|
276
|
-
|
|
299
|
+
swarm({ operation: "monitor", action: "progress_update", ... }) // Track worker progress
|
|
300
|
+
swarm({ operation: "monitor", action: "render_block", ... }) // TUI visualization
|
|
301
|
+
swarm({ operation: "sync", action: "update_shared", ... }) // Cross-session updates
|
|
277
302
|
|
|
278
303
|
SESSION END:
|
|
279
|
-
|
|
280
|
-
swarm
|
|
281
|
-
br sync --flush-only // Export Beads changes
|
|
304
|
+
swarm({ operation: "sync", action: "pull" }) // Sync completed todos back to Beads
|
|
305
|
+
swarm({ operation: "monitor", action: "clear", team_name: "..." }) // Cleanup swarm state
|
|
306
|
+
br sync --flush-only // Export Beads changes
|
|
307
|
+
git add .beads/ && git commit -m "..." // Commit changes to git
|
|
282
308
|
|
|
283
309
|
RECOVERY:
|
|
284
|
-
|
|
285
|
-
swarm
|
|
310
|
+
swarm({ operation: "sync", action: "get_shared", list_id: "..." }) // Get shared task list
|
|
311
|
+
swarm({ operation: "monitor", action: "status", team_name: "..." }) // Check swarm status
|
|
286
312
|
```
|
|
287
313
|
|
|
288
314
|
## Rules
|
|
289
315
|
|
|
290
316
|
1. **Always push Beads at session start** - Subagents need visibility via todoread
|
|
291
|
-
2. **Use shared lists for long-running swarms** - Cross-session persistence via
|
|
317
|
+
2. **Use shared lists for long-running swarms** - Cross-session persistence via swarm sync
|
|
292
318
|
3. **Pull completed todos back to Beads** - Keep tracking system in sync
|
|
293
319
|
4. **Check swarm status before spawning** - Avoid duplicate work
|
|
294
320
|
5. **Clear swarm state when done** - Cleanup after completion
|
|
321
|
+
6. **Always sync and commit before session end** - `br sync --flush-only` then `git add .beads/ && git commit`
|
|
@@ -11,6 +11,10 @@ Help turn ideas into fully formed designs and specs through natural collaborativ
|
|
|
11
11
|
|
|
12
12
|
Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design in small sections (200-300 words), checking after each section whether it looks right so far.
|
|
13
13
|
|
|
14
|
+
**Part of:** `development-lifecycle` skill (Phase 1: Ideation)
|
|
15
|
+
|
|
16
|
+
**Output template:** `.opencode/memory/_templates/design.md`
|
|
17
|
+
|
|
14
18
|
## The Process
|
|
15
19
|
|
|
16
20
|
**Understanding the idea:**
|
|
@@ -39,15 +43,25 @@ Start by understanding the current project context, then ask questions one at a
|
|
|
39
43
|
|
|
40
44
|
**Documentation:**
|
|
41
45
|
|
|
42
|
-
- Write the validated design to `.beads/artifacts/<bead-id>/design.md`
|
|
46
|
+
- Write the validated design to `.beads/artifacts/<bead-id>/design.md`
|
|
47
|
+
- Use template from `.opencode/memory/_templates/design.md`
|
|
43
48
|
- Use elements-of-style:writing-clearly-and-concisely skill if available
|
|
44
49
|
- Commit the design document to git
|
|
45
50
|
|
|
46
|
-
**
|
|
51
|
+
**Next Phase (if continuing):**
|
|
52
|
+
|
|
53
|
+
- Ask: "Ready to create the PRD?"
|
|
54
|
+
- Load next skill: `skill({ name: "prd" })`
|
|
55
|
+
- This moves to Phase 2: Specification
|
|
56
|
+
|
|
57
|
+
**Alternative paths:**
|
|
58
|
+
|
|
59
|
+
- Use `skill({ name: "using-git-worktrees" })` to create isolated workspace first
|
|
60
|
+
- Use `skill({ name: "writing-plans" })` if skipping formal PRD
|
|
61
|
+
|
|
62
|
+
**Full lifecycle reference:**
|
|
47
63
|
|
|
48
|
-
-
|
|
49
|
-
- Use skill({ name: "using-git-worktrees" }) to create isolated workspace
|
|
50
|
-
- Use skill({ name: "writing-plans" }) to create detailed implementation plan
|
|
64
|
+
- Use `skill({ name: "development-lifecycle" })` to see all phases
|
|
51
65
|
|
|
52
66
|
## Key Principles
|
|
53
67
|
|
|
@@ -1,94 +1,61 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
name: context-engineering
|
|
3
|
+
description: Use when designing AGENTS.md hierarchies, understanding autonomous duration, or writing intent layers - covers principles for extending agent work capacity
|
|
3
4
|
---
|
|
4
5
|
|
|
5
|
-
# Context Engineering
|
|
6
|
+
# Context Engineering
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Principles for maximizing agent effectiveness through context design.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
**For practical context tools (prune/distill/compress), use `context-management` skill.**
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
- **Stage 6** (Multi-Agent Orchestration): Parallel workstreams with coordination
|
|
12
|
+
## Core Principle
|
|
13
13
|
|
|
14
|
-
**
|
|
14
|
+
**Autonomous Duration**: How long can an agent work before losing the plot?
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
The key metric: **How long can an agent work before losing the plot?**
|
|
19
|
-
|
|
20
|
-
Extend autonomous duration by:
|
|
16
|
+
Extend it by:
|
|
21
17
|
|
|
22
18
|
- Binding tighter to intent (clear specs, constraints, invariants)
|
|
23
19
|
- Providing systematic context (AGENTS.md hierarchy, memory files)
|
|
24
20
|
- Verification loops (test → iterate → verify)
|
|
25
21
|
|
|
26
|
-
## Greenfield vs Legacy
|
|
27
|
-
|
|
28
|
-
| Type | Context | Agent Performance |
|
|
29
|
-
| -------------- | -------------------------- | ----------------------------- |
|
|
30
|
-
| **Greenfield** | Simple, fast prototypes | Works well immediately |
|
|
31
|
-
| **Legacy** | Complex, hidden invariants | Needs careful context loading |
|
|
32
|
-
|
|
33
|
-
Codebase complexity is a primary difficulty knob. Context is how you pay it down.
|
|
34
|
-
|
|
35
22
|
## Three Context Constraints
|
|
36
23
|
|
|
37
|
-
1. **Blind spots cause hallucinations** -
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
3. **Window is finite** - Performance degrades BEFORE hitting hard token limits. Curate the smallest, highest-signal slice.
|
|
42
|
-
|
|
43
|
-
## Practical Implications
|
|
44
|
-
|
|
45
|
-
| Instead of | Do This |
|
|
46
|
-
| ----------------------- | ----------------------------------------------------- |
|
|
47
|
-
| Reading entire files | Use `lsp_lsp_document_symbols` for outline |
|
|
48
|
-
| Loading whole documents | Read specific line ranges |
|
|
49
|
-
| Flat file loading | Navigate AGENTS.md hierarchy (progressive disclosure) |
|
|
50
|
-
| Keeping completed work | Prune context aggressively |
|
|
24
|
+
1. **Blind spots cause hallucinations** - Agent fills gaps with generic priors
|
|
25
|
+
2. **Everything influences everything** - Noise degrades ALL output quality
|
|
26
|
+
3. **Window is finite** - Performance degrades BEFORE hard token limits
|
|
51
27
|
|
|
52
28
|
## Intent Layer Principles
|
|
53
29
|
|
|
54
30
|
### What Belongs in Each AGENTS.md
|
|
55
31
|
|
|
56
|
-
- **Purpose & Scope** - What this area does. What it
|
|
57
|
-
- **Entry Points & Contracts** - Main APIs, invariants
|
|
58
|
-
- **Usage Patterns** - Canonical examples
|
|
59
|
-
- **Anti-patterns** -
|
|
60
|
-
- **Dependencies & Downlinks** -
|
|
61
|
-
- **Pitfalls** - Things that repeatedly confused agents/humans
|
|
32
|
+
- **Purpose & Scope** - What this area does. What it DOESN'T do.
|
|
33
|
+
- **Entry Points & Contracts** - Main APIs, invariants
|
|
34
|
+
- **Usage Patterns** - Canonical examples
|
|
35
|
+
- **Anti-patterns** - What NOT to do
|
|
36
|
+
- **Dependencies & Downlinks** - Pointers to related context
|
|
62
37
|
|
|
63
38
|
### Key Mechanics
|
|
64
39
|
|
|
65
|
-
| Principle
|
|
66
|
-
|
|
|
67
|
-
| **Hierarchical loading**
|
|
68
|
-
| **Compression
|
|
69
|
-
| **
|
|
70
|
-
| **Downlinks
|
|
40
|
+
| Principle | Meaning |
|
|
41
|
+
| ------------------------ | -------------------------------------------------------- |
|
|
42
|
+
| **Hierarchical loading** | When node loads, all ancestors load too (T-shaped view) |
|
|
43
|
+
| **Compression** | Good nodes compress code; don't add bloat |
|
|
44
|
+
| **LCA placement** | Place shared knowledge at shallowest node covering paths |
|
|
45
|
+
| **Downlinks** | Point to related context without loading everything |
|
|
71
46
|
|
|
72
|
-
##
|
|
47
|
+
## Practical Implications
|
|
73
48
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
49
|
+
| Instead of | Do This |
|
|
50
|
+
| ----------------------- | --------------------------------------- |
|
|
51
|
+
| Reading entire files | Use `lsp documentSymbol` for outline |
|
|
52
|
+
| Loading whole documents | Read specific line ranges |
|
|
53
|
+
| Flat file loading | Navigate AGENTS.md hierarchy |
|
|
54
|
+
| Keeping completed work | Prune aggressively (context-management) |
|
|
80
55
|
|
|
81
56
|
## Anti-Patterns
|
|
82
57
|
|
|
83
58
|
❌ Loading "everything that might be relevant"
|
|
84
59
|
❌ Keeping old file reads after editing complete
|
|
85
60
|
❌ Reading entire files when you only need a function
|
|
86
|
-
❌ Ignoring AGENTS.md hierarchy
|
|
87
|
-
|
|
88
|
-
## Best Practices
|
|
89
|
-
|
|
90
|
-
✅ Start with minimum viable context
|
|
91
|
-
✅ Use LSP tools for targeted information
|
|
92
|
-
✅ Prune after each completed sub-task
|
|
93
|
-
✅ Trust AGENTS.md hierarchy for discovery
|
|
94
|
-
✅ Extract findings before pruning valuable reads
|
|
61
|
+
❌ Ignoring AGENTS.md hierarchy
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: context-management
|
|
3
|
+
description: Use when context is growing large, needing to prune/distill tool outputs, or managing conversation size - covers DCP tools (prune, distill, compress) and context budgets
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Context Management (DCP)
|
|
7
|
+
|
|
8
|
+
Manage conversation context to prevent degradation. Uses prune/distill/compress tools.
|
|
9
|
+
|
|
10
|
+
## The Three Tools
|
|
11
|
+
|
|
12
|
+
| Tool | Purpose | When to Use |
|
|
13
|
+
| ---------- | ----------------------------- | ---------------------------------------- |
|
|
14
|
+
| `prune` | Remove tool outputs (no save) | Noise, irrelevant reads, superseded info |
|
|
15
|
+
| `distill` | Extract key info, then remove | Large outputs with valuable details |
|
|
16
|
+
| `compress` | Collapse conversation range | Completed phases, exploration done |
|
|
17
|
+
|
|
18
|
+
## When to Evaluate
|
|
19
|
+
|
|
20
|
+
**DO evaluate context when:**
|
|
21
|
+
|
|
22
|
+
- Accessed something irrelevant
|
|
23
|
+
- Information superseded by newer outputs
|
|
24
|
+
- Starting a new phase of work
|
|
25
|
+
- Large tool outputs with valuable details
|
|
26
|
+
- Phase complete (research, exploration, implementation)
|
|
27
|
+
|
|
28
|
+
**DO NOT prune when:**
|
|
29
|
+
|
|
30
|
+
- Output needed for upcoming edits
|
|
31
|
+
- Contains files you'll reference when editing
|
|
32
|
+
- Uncertain if you'll need it again
|
|
33
|
+
|
|
34
|
+
## Tool Usage
|
|
35
|
+
|
|
36
|
+
### Prune - Remove Noise
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
prune({ ids: ["5", "8"] }); // IDs from <prunable-tools> list
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Distill - Preserve + Remove
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
distill({
|
|
46
|
+
ids: ["10", "11"],
|
|
47
|
+
distillation: [
|
|
48
|
+
"auth.ts: validateToken(token: string) -> User|null, bcrypt 12 rounds",
|
|
49
|
+
"user.ts: interface User { id, email, permissions[], status }",
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Compress - Collapse Ranges
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
compress({
|
|
58
|
+
input: [
|
|
59
|
+
"exact text from start", // Must exist VERBATIM
|
|
60
|
+
"exact text from end", // Must come AFTER start
|
|
61
|
+
"Topic Label", // 3-5 words
|
|
62
|
+
"Summary of accomplishments", // Replacement text
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Critical Rules
|
|
68
|
+
|
|
69
|
+
**For prune/distill:**
|
|
70
|
+
|
|
71
|
+
- IDs MUST come from current `<prunable-tools>` list
|
|
72
|
+
- List refreshes after every tool use - don't cache IDs
|
|
73
|
+
- Invalid IDs error: `"Invalid IDs provided"`
|
|
74
|
+
|
|
75
|
+
**For compress:**
|
|
76
|
+
|
|
77
|
+
- Start/end strings must match EXACTLY
|
|
78
|
+
- Start must appear BEFORE end chronologically
|
|
79
|
+
- Both strings must be unique (appear only once)
|
|
80
|
+
|
|
81
|
+
## Protected Content
|
|
82
|
+
|
|
83
|
+
Auto-protected from pruning:
|
|
84
|
+
|
|
85
|
+
- `.env*` files
|
|
86
|
+
- `AGENTS.md`
|
|
87
|
+
- `.opencode/**` config
|
|
88
|
+
- `.beads/**` tasks
|
|
89
|
+
- `package.json`, `tsconfig.json`, `biome.json`
|
|
90
|
+
|
|
91
|
+
## Context Budget Guidelines
|
|
92
|
+
|
|
93
|
+
| Phase | Target | Action |
|
|
94
|
+
| ----------------- | ------- | ----------------------------------------- |
|
|
95
|
+
| Starting work | <50k | Load only essential AGENTS.md + task spec |
|
|
96
|
+
| Mid-task | 50-100k | Prune completed reads, keep active files |
|
|
97
|
+
| Approaching limit | >100k | Aggressive pruning, extract key findings |
|
|
98
|
+
| Near capacity | >150k | Session restart with handoff |
|
|
99
|
+
|
|
100
|
+
## DCP Commands (User)
|
|
101
|
+
|
|
102
|
+
- `/dcp context` - Token usage breakdown
|
|
103
|
+
- `/dcp stats` - Cumulative pruning statistics
|
|
104
|
+
- `/dcp sweep` - Prune all tools since last user message
|
|
105
|
+
- `/dcp sweep 10` - Prune last 10 tools
|
|
106
|
+
|
|
107
|
+
## Quick Reference
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
PRUNE: Remove noise → prune({ ids: [...] })
|
|
111
|
+
DISTILL: Save + remove → distill({ ids: [...], distillation: [...] })
|
|
112
|
+
COMPRESS: Collapse phase → compress({ input: [start, end, topic, summary] })
|
|
113
|
+
|
|
114
|
+
BUDGET: <50k start → 50-100k mid → >100k prune → >150k restart
|
|
115
|
+
```
|
|
@@ -110,8 +110,8 @@ Only if internal exploration doesn't answer the question:
|
|
|
110
110
|
|
|
111
111
|
```typescript
|
|
112
112
|
// Official docs
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
context7({ operation: "resolve", libraryName: "<lib>" });
|
|
114
|
+
context7({ operation: "query", libraryId: "<id>", topic: "<specific question>" });
|
|
115
115
|
|
|
116
116
|
// Real-world patterns
|
|
117
117
|
codesearch({ query: "<API usage pattern>", tokensNum: 5000 });
|
|
@@ -284,8 +284,8 @@ grep({ pattern: "rateLimit", include: "*.ts" });
|
|
|
284
284
|
glob({ pattern: "src/middleware/*.ts" });
|
|
285
285
|
|
|
286
286
|
// Phase 4: External (if patterns unclear)
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
context7({ operation: "resolve", libraryName: "express" });
|
|
288
|
+
context7({ operation: "query", libraryId: "/expressjs/express", topic: "middleware" });
|
|
289
289
|
|
|
290
290
|
// Document findings
|
|
291
291
|
write({
|