opencodekit 0.16.10 → 0.16.13

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.
@@ -2,10 +2,14 @@
2
2
  * Swarm Enforcer Plugin
3
3
  *
4
4
  * Beads is the single source of truth for the swarm board.
5
- * This plugin nudges agents to:
6
- * - Claim a Beads task before making code changes
7
- * - Ensure `spec.md` exists for in-progress tasks
8
- * - Close/sync in-progress work at session end
5
+ * This plugin provides non-intrusive enforcement:
6
+ * - Toast warning when code is edited without a claimed task
7
+ * - Toast warning when in-progress tasks are missing spec.md
8
+ * - Session-end reminder to close/sync in-progress tasks
9
+ *
10
+ * NOTE: chat.message nudging was removed — AGENTS.md and the beads skill
11
+ * already instruct agents on the beads protocol. Injecting ASCII blocks
12
+ * on every user message mentioning work intent caused excessive noise.
9
13
  *
10
14
  * This plugin is intentionally non-destructive: it never runs `br update/close/sync`.
11
15
  */
@@ -40,15 +44,6 @@ const CODE_EXTENSIONS = [
40
44
  ".hpp",
41
45
  ];
42
46
 
43
- const WORK_INTENT_PATTERNS = [
44
- /\b(implement|fix|refactor|add|remove|delete|update|change|modify|create|build)\b/i,
45
- /\b(edit|patch)\b/i,
46
- ];
47
-
48
- function looksLikeWorkIntent(text: string): boolean {
49
- return WORK_INTENT_PATTERNS.some((p) => p.test(text));
50
- }
51
-
52
47
  function isCodeFile(filePath: string): boolean {
53
48
  return CODE_EXTENSIONS.some((ext) => filePath.endsWith(ext));
54
49
  }
@@ -119,47 +114,6 @@ async function specExists(repoDir: string, issueId: string): Promise<boolean> {
119
114
  }
120
115
  }
121
116
 
122
- function buildNudge(params: {
123
- inProgress: BeadsIssue[];
124
- missingSpec: BeadsIssue[];
125
- }): string {
126
- const { inProgress, missingSpec } = params;
127
-
128
- if (inProgress.length === 0) {
129
- return `
130
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
131
- ⚡ [BEADS PROTOCOL]
132
-
133
- Pick a task before code changes:
134
-
135
- 1) \`br ready\` → find unblocked work
136
- 2) \`br show <id>\` → inspect task
137
- 3) \`br update <id> --status in_progress\` → claim it
138
-
139
- For parallel work, use the Task tool to spawn subagents.
140
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
141
- `;
142
- }
143
-
144
- if (missingSpec.length > 0) {
145
- const ids = missingSpec
146
- .slice(0, 3)
147
- .map((i) => i.id)
148
- .join(", ");
149
- return `
150
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
151
- ⚡ [BEADS PROTOCOL]
152
-
153
- Missing \`spec.md\` for: ${ids}
154
-
155
- Create \`.beads/artifacts/<id>/spec.md\` before implementation.
156
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
157
- `;
158
- }
159
-
160
- return "";
161
- }
162
-
163
117
  export const SwarmEnforcer: Plugin = async ({ client, directory }) => {
164
118
  const repoDir = directory || process.cwd();
165
119
  let lastStateAt = 0;
@@ -188,7 +142,7 @@ export const SwarmEnforcer: Plugin = async ({ client, directory }) => {
188
142
  const showToast = async (
189
143
  title: string,
190
144
  message: string,
191
- variant: "info" | "success" | "warning" | "error" = "info",
145
+ variant: "info" | "warning" = "info",
192
146
  ) => {
193
147
  try {
194
148
  await client.tui.showToast({
@@ -196,7 +150,7 @@ export const SwarmEnforcer: Plugin = async ({ client, directory }) => {
196
150
  title,
197
151
  message,
198
152
  variant,
199
- duration: variant === "error" ? 8000 : 5000,
153
+ duration: variant === "warning" ? 8000 : 5000,
200
154
  },
201
155
  });
202
156
  } catch {
@@ -205,69 +159,40 @@ export const SwarmEnforcer: Plugin = async ({ client, directory }) => {
205
159
  };
206
160
 
207
161
  return {
208
- // Nudge early when user expresses implementation intent
209
- "chat.message": async (input, output) => {
210
- const { sessionID, messageID } = input;
211
- const { message, parts } = output;
212
- if (message.role !== "user") return;
213
-
214
- const fullText = parts
215
- .filter((p) => p.type === "text" && !("synthetic" in p && p.synthetic))
216
- .map((p) => ("text" in p ? p.text : ""))
217
- .join(" ");
218
-
219
- if (!looksLikeWorkIntent(fullText)) return;
220
-
221
- await refreshState();
222
-
223
- const nudge = buildNudge({
224
- inProgress: cachedInProgress,
225
- missingSpec: cachedMissingSpec,
226
- });
227
- if (!nudge) return;
228
-
229
- parts.push({
230
- id: `beads-nudge-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
231
- sessionID,
232
- messageID: messageID || "",
233
- type: "text",
234
- text: nudge,
235
- synthetic: true,
236
- } as import("@opencode-ai/sdk").Part);
237
- },
238
-
239
162
  // Warn if code gets edited while no task is claimed / spec missing
240
- "file.edited": async ({ event }) => {
241
- const filePath = event.properties?.file || event.properties?.path;
242
- if (!filePath || typeof filePath !== "string") return;
243
- if (isIgnoredPath(repoDir, filePath)) return;
244
-
245
- const absPath = path.isAbsolute(filePath)
246
- ? filePath
247
- : path.join(repoDir, filePath);
248
-
249
- if (!isCodeFile(absPath)) return;
250
-
251
- await refreshState();
252
-
253
- if (cachedInProgress.length === 0) {
254
- await showToast(
255
- "Beads: No task claimed",
256
- "Run br ready/show/update to claim a task before edits.",
257
- "warning",
258
- );
259
- return;
260
- }
261
-
262
- if (cachedMissingSpec.length > 0) {
263
- await showToast(
264
- "Beads: Missing spec.md",
265
- `Create .beads/artifacts/<id>/spec.md for: ${cachedMissingSpec
266
- .slice(0, 3)
267
- .map((i) => i.id)
268
- .join(", ")}`,
269
- "warning",
270
- );
163
+ event: async ({ event }) => {
164
+ if (event.type === "file.edited") {
165
+ const filePath = event.properties?.file;
166
+ if (!filePath || typeof filePath !== "string") return;
167
+ if (isIgnoredPath(repoDir, filePath)) return;
168
+
169
+ const absPath = path.isAbsolute(filePath)
170
+ ? filePath
171
+ : path.join(repoDir, filePath);
172
+
173
+ if (!isCodeFile(absPath)) return;
174
+
175
+ await refreshState();
176
+
177
+ if (cachedInProgress.length === 0) {
178
+ await showToast(
179
+ "Beads: No task claimed",
180
+ "Run br ready/show/update to claim a task before edits.",
181
+ "warning",
182
+ );
183
+ return;
184
+ }
185
+
186
+ if (cachedMissingSpec.length > 0) {
187
+ await showToast(
188
+ "Beads: Missing spec.md",
189
+ `Create .beads/artifacts/<id>/spec.md for: ${cachedMissingSpec
190
+ .slice(0, 3)
191
+ .map((i) => i.id)
192
+ .join(", ")}`,
193
+ "warning",
194
+ );
195
+ }
271
196
  }
272
197
  },
273
198
 
@@ -283,7 +208,6 @@ export const SwarmEnforcer: Plugin = async ({ client, directory }) => {
283
208
  await showToast(
284
209
  "Beads: Work still in progress",
285
210
  `In-progress: ${list}. Close with br close + br sync when done.`,
286
- "info",
287
211
  );
288
212
  },
289
213
  };
@@ -0,0 +1,242 @@
1
+ ---
2
+ name: agent-teams
3
+ description: >
4
+ Use when working with Claude Code-style agent teams for parallel research, review, competing hypotheses,
5
+ or any task that benefits from multiple agents working simultaneously under a lead coordinator.
6
+ Covers team configuration, task distribution, coordination patterns, and best practices.
7
+ version: "1.0.0"
8
+ license: MIT
9
+ ---
10
+
11
+ # Agent Teams - Multi-Agent Team Coordination
12
+
13
+ Coordinate multiple agents working as a team under a lead agent. Unlike subagents (fire-and-forget), teams enable continuous coordination, shared context, and dynamic task reassignment.
14
+
15
+ ## Overview
16
+
17
+ **Agent Teams = Lead + Teammates + Shared Task List + Messaging**
18
+
19
+ - **Lead agent**: Coordinates the team - distributes tasks, monitors progress, synthesizes results
20
+ - **Teammates**: Execute tasks independently but can message each other and the lead
21
+ - **Task list**: Shared work queue that the lead manages
22
+ - **Messaging**: Bidirectional communication between lead and teammates
23
+
24
+ ## When to Use Agent Teams vs Subagents
25
+
26
+ | Criteria | Agent Teams | Subagents (Task tool) |
27
+ | --------------------- | -------------------------------------- | ----------------------------------- |
28
+ | **Coordination** | Lead coordinates, teammates message | Fire-and-forget, results return |
29
+ | **Communication** | Bidirectional messaging | One-way (result only) |
30
+ | **Task reassignment** | Dynamic - lead can reassign | Fixed - each subagent does its task |
31
+ | **Context sharing** | Shared through lead | Independent contexts |
32
+ | **Best for** | Research, review, competing approaches | Independent implementation tasks |
33
+ | **Overhead** | Higher - coordination cost | Lower - no coordination |
34
+
35
+ ### Decision Matrix
36
+
37
+ ```
38
+ Need coordination between workers? → Agent Teams
39
+ Workers are fully independent? → Subagents (Task tool)
40
+ Need competing hypotheses? → Agent Teams
41
+ Need shared findings? → Agent Teams
42
+ Simple parallel execution? → Subagents (Task tool)
43
+ ```
44
+
45
+ ## When to Use
46
+
47
+ - **Parallel research**: Multiple agents researching different aspects of a problem
48
+ - **Code review**: Multiple reviewers examining different files/concerns
49
+ - **Competing hypotheses**: Agents try different approaches, best one wins
50
+ - **Large refactors**: Agents handle different subsystems with coordination
51
+ - **Architecture exploration**: Agents explore different design options simultaneously
52
+
53
+ ## When NOT to Use
54
+
55
+ - Single-agent tasks (overhead not worth it)
56
+ - Tightly coupled work where agents would constantly block each other
57
+ - Tasks under 3 independent units of work
58
+ - Simple file edits with no research needed
59
+
60
+ ## Team Configuration Patterns
61
+
62
+ ### Pattern 1: Research Team
63
+
64
+ ```
65
+ Lead: build agent
66
+ ├── Teammate 1 (explore): Search codebase for existing patterns
67
+ ├── Teammate 2 (scout): Research external docs and best practices
68
+ └── Teammate 3 (review): Analyze current implementation for issues
69
+ ```
70
+
71
+ **Use when**: Entering unfamiliar territory, evaluating new libraries, understanding complex systems.
72
+
73
+ ### Pattern 2: Review Team
74
+
75
+ ```
76
+ Lead: build agent
77
+ ├── Teammate 1 (review): Security audit
78
+ ├── Teammate 2 (review): Performance review
79
+ └── Teammate 3 (review): Architecture review
80
+ ```
81
+
82
+ **Use when**: Pre-merge review of significant features, security-sensitive changes.
83
+
84
+ ### Pattern 3: Competing Approaches
85
+
86
+ ```
87
+ Lead: build agent
88
+ ├── Teammate 1 (general): Implement approach A
89
+ ├── Teammate 2 (general): Implement approach B
90
+ └── Teammate 3 (general): Implement approach C
91
+ ```
92
+
93
+ **Use when**: Multiple valid solutions exist and you need to compare empirically.
94
+
95
+ ### Pattern 4: Subsystem Team
96
+
97
+ ```
98
+ Lead: build agent
99
+ ├── Teammate 1 (general): Handle frontend changes
100
+ ├── Teammate 2 (general): Handle backend changes
101
+ └── Teammate 3 (general): Handle database migrations
102
+ ```
103
+
104
+ **Use when**: Large features spanning multiple subsystems with clear boundaries.
105
+
106
+ ## Best Practices
107
+
108
+ ### Task Distribution
109
+
110
+ 1. **5-6 tasks per teammate maximum** - More than this degrades quality
111
+ 2. **Clear boundaries** - Each teammate should own distinct files/modules
112
+ 3. **Avoid file conflicts** - Never assign the same file to multiple teammates
113
+ 4. **Include verification** - Each task should include its own verification step
114
+
115
+ ### Coordination
116
+
117
+ 1. **Lead synthesizes** - Don't let teammates make final decisions; lead integrates
118
+ 2. **Regular check-ins** - Lead should review intermediate results, not just final
119
+ 3. **Fail fast** - If a teammate hits a blocker, escalate to lead immediately
120
+ 4. **Shared conventions** - Establish naming, formatting, and style before dispatching
121
+
122
+ ### Communication
123
+
124
+ 1. **Task descriptions should be self-contained** - Teammate shouldn't need to ask clarifying questions
125
+ 2. **Include context** - What files to read, what patterns to follow, what constraints exist
126
+ 3. **Specify output format** - What should the teammate report back?
127
+ 4. **Include acceptance criteria** - How does the lead know the task is done?
128
+
129
+ ## Implementation with OpenCode
130
+
131
+ ### Using the Task Tool (Current)
132
+
133
+ ```typescript
134
+ // Spawn research team
135
+ const codebaseAnalysis = Task({
136
+ subagent_type: "explore",
137
+ description: "Analyze auth patterns",
138
+ prompt: `Research authentication patterns in this codebase:
139
+ 1. Find all auth-related files
140
+ 2. Map the auth flow
141
+ 3. Identify potential security issues
142
+ Report back: file list, flow diagram, issues found`,
143
+ });
144
+
145
+ const externalResearch = Task({
146
+ subagent_type: "scout",
147
+ description: "Research JWT best practices",
148
+ prompt: `Research current JWT best practices:
149
+ 1. Token rotation patterns
150
+ 2. Refresh token security
151
+ 3. Common vulnerabilities
152
+ Report back: recommended patterns with code examples`,
153
+ });
154
+
155
+ const codeReview = Task({
156
+ subagent_type: "review",
157
+ description: "Review auth security",
158
+ prompt: `Security review of auth implementation:
159
+ 1. Check token storage
160
+ 2. Verify CSRF protection
161
+ 3. Audit session management
162
+ Report back: vulnerabilities found with severity ratings`,
163
+ });
164
+
165
+ // Lead synthesizes all results into unified recommendation
166
+ ```
167
+
168
+ ### Using Swarm Coordination (Advanced)
169
+
170
+ For more structured parallel work, combine with the `swarm-coordination` skill:
171
+
172
+ ```typescript
173
+ // Load swarm for structured coordination
174
+ skill({ name: "swarm-coordination" });
175
+
176
+ // Analyze and plan
177
+ swarm({ op: "plan", task: "Implement auth overhaul across 3 subsystems" });
178
+
179
+ // Create delegation packets
180
+ swarm({
181
+ op: "delegate",
182
+ bead_id: "auth-frontend",
183
+ title: "Frontend auth components",
184
+ outcome: "All auth forms and guards updated",
185
+ must_do: "Follow existing component patterns, run component tests",
186
+ must_not: "Don't modify API contracts, don't add new dependencies",
187
+ });
188
+ ```
189
+
190
+ ## Anti-Patterns
191
+
192
+ ### ❌ Too Many Teammates
193
+
194
+ ```
195
+ Lead
196
+ ├── T1: Button component ← Too granular
197
+ ├── T2: Input component ← Too granular
198
+ ├── T3: Form component ← Too granular
199
+ ├── T4: Modal component ← Too granular
200
+ ├── T5: Toast component ← Too granular
201
+ ├── T6: Dialog component ← Too granular
202
+ ├── T7: Dropdown component ← Too granular
203
+ └── T8: Tabs component ← Too granular
204
+ ```
205
+
206
+ **Fix**: Group related work. 2-3 teammates handling related components each.
207
+
208
+ ### ❌ Overlapping File Ownership
209
+
210
+ ```
211
+ T1: Refactor auth service ← Both touch auth.ts!
212
+ T2: Add new auth endpoint ← Both touch auth.ts!
213
+ ```
214
+
215
+ **Fix**: One teammate owns auth.ts changes. The other waits or works on different files.
216
+
217
+ ### ❌ Missing Context
218
+
219
+ ```
220
+ Task({ prompt: "Fix the auth bug" }) ← Which bug? What file? What behavior?
221
+ ```
222
+
223
+ **Fix**: Include file paths, error messages, expected vs actual behavior, and reproduction steps.
224
+
225
+ ### ❌ No Verification
226
+
227
+ ```
228
+ Task({ prompt: "Implement feature X" }) ← No way to verify success
229
+ ```
230
+
231
+ **Fix**: Include acceptance criteria: "Run `npm test auth`, ensure all pass. Run `npm run typecheck`."
232
+
233
+ ## Checklist
234
+
235
+ Before dispatching a team:
236
+
237
+ - [ ] Identified 3+ independent tasks (otherwise use single agent)
238
+ - [ ] Each task has clear file ownership (no overlaps)
239
+ - [ ] Each task has self-contained context (files, patterns, constraints)
240
+ - [ ] Each task has acceptance criteria (verification commands)
241
+ - [ ] Lead has a synthesis plan (how to integrate results)
242
+ - [ ] Tasks are sized appropriately (5-6 per teammate max)