opencode-swarm-plugin 0.26.1 → 0.27.0
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/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +23 -0
- package/README.md +43 -46
- package/bin/swarm.ts +8 -8
- package/dist/compaction-hook.d.ts +57 -0
- package/dist/compaction-hook.d.ts.map +1 -0
- package/dist/hive.d.ts +741 -0
- package/dist/hive.d.ts.map +1 -0
- package/dist/index.d.ts +139 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1353 -350
- package/dist/learning.d.ts +9 -9
- package/dist/plugin.js +1176 -350
- package/dist/schemas/cell-events.d.ts +1352 -0
- package/dist/schemas/{bead-events.d.ts.map → cell-events.d.ts.map} +1 -1
- package/dist/schemas/{bead.d.ts → cell.d.ts} +173 -29
- package/dist/schemas/cell.d.ts.map +1 -0
- package/dist/schemas/index.d.ts +11 -7
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/structured.d.ts +17 -7
- package/dist/structured.d.ts.map +1 -1
- package/dist/swarm-decompose.d.ts +5 -5
- package/dist/swarm-orchestrate.d.ts +16 -2
- package/dist/swarm-orchestrate.d.ts.map +1 -1
- package/dist/swarm-prompts.d.ts +9 -9
- package/dist/swarm-prompts.d.ts.map +1 -1
- package/dist/swarm-review.d.ts +210 -0
- package/dist/swarm-review.d.ts.map +1 -0
- package/dist/swarm-worktree.d.ts +185 -0
- package/dist/swarm-worktree.d.ts.map +1 -0
- package/dist/swarm.d.ts +7 -0
- package/dist/swarm.d.ts.map +1 -1
- package/dist/tool-availability.d.ts +3 -2
- package/dist/tool-availability.d.ts.map +1 -1
- package/docs/analysis-socratic-planner-pattern.md +1 -1
- package/docs/planning/ADR-007-swarm-enhancements-worktree-review.md +168 -0
- package/docs/testing/context-recovery-test.md +2 -2
- package/evals/README.md +2 -2
- package/evals/scorers/index.ts +7 -7
- package/examples/commands/swarm.md +21 -23
- package/examples/plugin-wrapper-template.ts +310 -44
- package/examples/skills/{beads-workflow → hive-workflow}/SKILL.md +40 -40
- package/examples/skills/swarm-coordination/SKILL.md +1 -1
- package/global-skills/swarm-coordination/SKILL.md +14 -14
- package/global-skills/swarm-coordination/references/coordinator-patterns.md +3 -3
- package/package.json +2 -2
- package/src/compaction-hook.ts +161 -0
- package/src/{beads.integration.test.ts → hive.integration.test.ts} +92 -80
- package/src/{beads.ts → hive.ts} +378 -219
- package/src/index.ts +57 -20
- package/src/learning.ts +9 -9
- package/src/output-guardrails.test.ts +4 -4
- package/src/output-guardrails.ts +9 -9
- package/src/planning-guardrails.test.ts +1 -1
- package/src/planning-guardrails.ts +1 -1
- package/src/schemas/{bead-events.test.ts → cell-events.test.ts} +83 -77
- package/src/schemas/cell-events.ts +807 -0
- package/src/schemas/{bead.ts → cell.ts} +95 -41
- package/src/schemas/evaluation.ts +1 -1
- package/src/schemas/index.ts +90 -18
- package/src/schemas/swarm-context.ts +2 -2
- package/src/structured.test.ts +15 -15
- package/src/structured.ts +18 -11
- package/src/swarm-decompose.ts +23 -23
- package/src/swarm-orchestrate.ts +135 -21
- package/src/swarm-prompts.ts +43 -43
- package/src/swarm-review.test.ts +702 -0
- package/src/swarm-review.ts +696 -0
- package/src/swarm-worktree.test.ts +501 -0
- package/src/swarm-worktree.ts +575 -0
- package/src/swarm.integration.test.ts +12 -12
- package/src/tool-availability.ts +36 -3
- package/dist/beads.d.ts +0 -386
- package/dist/beads.d.ts.map +0 -1
- package/dist/schemas/bead-events.d.ts +0 -698
- package/dist/schemas/bead.d.ts.map +0 -1
- package/src/schemas/bead-events.ts +0 -583
|
@@ -1,59 +1,65 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tests for
|
|
2
|
+
* Tests for Cell Event Schemas
|
|
3
3
|
*
|
|
4
4
|
* Validates event creation, validation, and type guards.
|
|
5
5
|
*/
|
|
6
6
|
import { describe, expect, test } from "bun:test";
|
|
7
7
|
import {
|
|
8
|
+
type CellCreatedEvent,
|
|
9
|
+
CellEventSchema,
|
|
10
|
+
createCellEvent,
|
|
11
|
+
getCellIdFromEvent,
|
|
12
|
+
isAgentEvent,
|
|
13
|
+
isCellEventType,
|
|
14
|
+
isEpicEvent,
|
|
15
|
+
isStateTransitionEvent,
|
|
16
|
+
// Legacy aliases for backward compatibility
|
|
8
17
|
type BeadCreatedEvent,
|
|
9
18
|
BeadEventSchema,
|
|
10
19
|
createBeadEvent,
|
|
11
20
|
getBeadIdFromEvent,
|
|
12
|
-
isAgentEvent,
|
|
13
21
|
isBeadEventType,
|
|
14
|
-
|
|
15
|
-
isStateTransitionEvent,
|
|
16
|
-
} from "./bead-events.js";
|
|
22
|
+
} from "./cell-events.js";
|
|
17
23
|
|
|
18
|
-
describe("
|
|
24
|
+
describe("CellEventSchema", () => {
|
|
19
25
|
const projectKey = "/path/to/repo";
|
|
20
26
|
|
|
21
|
-
describe("
|
|
22
|
-
test("creates valid
|
|
23
|
-
const event =
|
|
27
|
+
describe("createCellEvent", () => {
|
|
28
|
+
test("creates valid cell_created event", () => {
|
|
29
|
+
const event = createCellEvent("cell_created", {
|
|
24
30
|
project_key: projectKey,
|
|
25
|
-
|
|
31
|
+
cell_id: "bd-123",
|
|
26
32
|
title: "Add authentication",
|
|
27
33
|
issue_type: "feature",
|
|
28
34
|
priority: 2,
|
|
29
35
|
});
|
|
30
36
|
|
|
31
|
-
expect(event.type).toBe("
|
|
32
|
-
expect(event.
|
|
37
|
+
expect(event.type).toBe("cell_created");
|
|
38
|
+
expect(event.cell_id).toBe("bd-123");
|
|
33
39
|
expect(event.title).toBe("Add authentication");
|
|
34
40
|
expect(event.timestamp).toBeGreaterThan(0);
|
|
35
41
|
});
|
|
36
42
|
|
|
37
|
-
test("creates valid
|
|
38
|
-
const event =
|
|
43
|
+
test("creates valid cell_closed event", () => {
|
|
44
|
+
const event = createCellEvent("cell_closed", {
|
|
39
45
|
project_key: projectKey,
|
|
40
|
-
|
|
46
|
+
cell_id: "bd-123",
|
|
41
47
|
reason: "Implemented OAuth flow",
|
|
42
48
|
closed_by: "BlueLake",
|
|
43
49
|
files_touched: ["src/auth.ts", "src/oauth.ts"],
|
|
44
50
|
duration_ms: 45000,
|
|
45
51
|
});
|
|
46
52
|
|
|
47
|
-
expect(event.type).toBe("
|
|
53
|
+
expect(event.type).toBe("cell_closed");
|
|
48
54
|
expect(event.reason).toBe("Implemented OAuth flow");
|
|
49
55
|
expect(event.closed_by).toBe("BlueLake");
|
|
50
56
|
expect(event.files_touched).toHaveLength(2);
|
|
51
57
|
});
|
|
52
58
|
|
|
53
|
-
test("creates valid
|
|
54
|
-
const event =
|
|
59
|
+
test("creates valid cell_dependency_added event", () => {
|
|
60
|
+
const event = createCellEvent("cell_dependency_added", {
|
|
55
61
|
project_key: projectKey,
|
|
56
|
-
|
|
62
|
+
cell_id: "bd-123",
|
|
57
63
|
dependency: {
|
|
58
64
|
id: "bd-456",
|
|
59
65
|
type: "blocks",
|
|
@@ -61,65 +67,65 @@ describe("BeadEventSchema", () => {
|
|
|
61
67
|
reason: "Needs database schema before service layer",
|
|
62
68
|
});
|
|
63
69
|
|
|
64
|
-
expect(event.type).toBe("
|
|
70
|
+
expect(event.type).toBe("cell_dependency_added");
|
|
65
71
|
expect(event.dependency.type).toBe("blocks");
|
|
66
72
|
expect(event.dependency.id).toBe("bd-456");
|
|
67
73
|
});
|
|
68
74
|
|
|
69
|
-
test("creates valid
|
|
70
|
-
const event =
|
|
75
|
+
test("creates valid cell_epic_child_added event", () => {
|
|
76
|
+
const event = createCellEvent("cell_epic_child_added", {
|
|
71
77
|
project_key: projectKey,
|
|
72
|
-
|
|
78
|
+
cell_id: "bd-epic-1",
|
|
73
79
|
child_id: "bd-epic-1.1",
|
|
74
80
|
child_index: 0,
|
|
75
81
|
});
|
|
76
82
|
|
|
77
|
-
expect(event.type).toBe("
|
|
83
|
+
expect(event.type).toBe("cell_epic_child_added");
|
|
78
84
|
expect(event.child_id).toBe("bd-epic-1.1");
|
|
79
85
|
});
|
|
80
86
|
|
|
81
87
|
test("throws on invalid event data", () => {
|
|
82
88
|
expect(() =>
|
|
83
|
-
|
|
89
|
+
createCellEvent("cell_created", {
|
|
84
90
|
project_key: projectKey,
|
|
85
|
-
|
|
91
|
+
cell_id: "bd-123",
|
|
86
92
|
title: "Test",
|
|
87
93
|
// @ts-expect-error - Testing invalid issue_type
|
|
88
94
|
issue_type: "invalid_type",
|
|
89
95
|
priority: 2,
|
|
90
96
|
}),
|
|
91
|
-
).toThrow("Invalid
|
|
97
|
+
).toThrow("Invalid cell event");
|
|
92
98
|
});
|
|
93
99
|
});
|
|
94
100
|
|
|
95
101
|
describe("type guards", () => {
|
|
96
|
-
test("
|
|
97
|
-
const event:
|
|
102
|
+
test("isCellEventType narrows type correctly", () => {
|
|
103
|
+
const event: CellCreatedEvent = createCellEvent("cell_created", {
|
|
98
104
|
project_key: projectKey,
|
|
99
|
-
|
|
105
|
+
cell_id: "bd-123",
|
|
100
106
|
title: "Test",
|
|
101
107
|
issue_type: "task",
|
|
102
108
|
priority: 2,
|
|
103
109
|
});
|
|
104
110
|
|
|
105
|
-
if (
|
|
106
|
-
// TypeScript knows this is
|
|
111
|
+
if (isCellEventType(event, "cell_created")) {
|
|
112
|
+
// TypeScript knows this is CellCreatedEvent
|
|
107
113
|
expect(event.title).toBe("Test");
|
|
108
114
|
}
|
|
109
115
|
});
|
|
110
116
|
|
|
111
117
|
test("isStateTransitionEvent identifies status changes", () => {
|
|
112
|
-
const closedEvent =
|
|
118
|
+
const closedEvent = createCellEvent("cell_closed", {
|
|
113
119
|
project_key: projectKey,
|
|
114
|
-
|
|
120
|
+
cell_id: "bd-123",
|
|
115
121
|
reason: "Done",
|
|
116
122
|
});
|
|
117
123
|
|
|
118
124
|
expect(isStateTransitionEvent(closedEvent)).toBe(true);
|
|
119
125
|
|
|
120
|
-
const createdEvent =
|
|
126
|
+
const createdEvent = createCellEvent("cell_created", {
|
|
121
127
|
project_key: projectKey,
|
|
122
|
-
|
|
128
|
+
cell_id: "bd-123",
|
|
123
129
|
title: "Test",
|
|
124
130
|
issue_type: "task",
|
|
125
131
|
priority: 2,
|
|
@@ -129,17 +135,17 @@ describe("BeadEventSchema", () => {
|
|
|
129
135
|
});
|
|
130
136
|
|
|
131
137
|
test("isEpicEvent identifies epic operations", () => {
|
|
132
|
-
const epicEvent =
|
|
138
|
+
const epicEvent = createCellEvent("cell_epic_child_added", {
|
|
133
139
|
project_key: projectKey,
|
|
134
|
-
|
|
140
|
+
cell_id: "bd-epic",
|
|
135
141
|
child_id: "bd-epic.1",
|
|
136
142
|
});
|
|
137
143
|
|
|
138
144
|
expect(isEpicEvent(epicEvent)).toBe(true);
|
|
139
145
|
|
|
140
|
-
const regularEvent =
|
|
146
|
+
const regularEvent = createCellEvent("cell_created", {
|
|
141
147
|
project_key: projectKey,
|
|
142
|
-
|
|
148
|
+
cell_id: "bd-123",
|
|
143
149
|
title: "Test",
|
|
144
150
|
issue_type: "task",
|
|
145
151
|
priority: 2,
|
|
@@ -149,17 +155,17 @@ describe("BeadEventSchema", () => {
|
|
|
149
155
|
});
|
|
150
156
|
|
|
151
157
|
test("isAgentEvent detects agent-triggered events", () => {
|
|
152
|
-
const agentEvent =
|
|
158
|
+
const agentEvent = createCellEvent("cell_assigned", {
|
|
153
159
|
project_key: projectKey,
|
|
154
|
-
|
|
160
|
+
cell_id: "bd-123",
|
|
155
161
|
agent_name: "BlueLake",
|
|
156
162
|
});
|
|
157
163
|
|
|
158
164
|
expect(isAgentEvent(agentEvent)).toBe(true);
|
|
159
165
|
|
|
160
|
-
const closedByAgentEvent =
|
|
166
|
+
const closedByAgentEvent = createCellEvent("cell_closed", {
|
|
161
167
|
project_key: projectKey,
|
|
162
|
-
|
|
168
|
+
cell_id: "bd-123",
|
|
163
169
|
reason: "Done",
|
|
164
170
|
closed_by: "agent",
|
|
165
171
|
});
|
|
@@ -168,47 +174,47 @@ describe("BeadEventSchema", () => {
|
|
|
168
174
|
});
|
|
169
175
|
});
|
|
170
176
|
|
|
171
|
-
describe("
|
|
172
|
-
test("extracts
|
|
177
|
+
describe("getCellIdFromEvent", () => {
|
|
178
|
+
test("extracts cell_id from any event", () => {
|
|
173
179
|
const events = [
|
|
174
|
-
|
|
180
|
+
createCellEvent("cell_created", {
|
|
175
181
|
project_key: projectKey,
|
|
176
|
-
|
|
182
|
+
cell_id: "bd-123",
|
|
177
183
|
title: "Test",
|
|
178
184
|
issue_type: "task",
|
|
179
185
|
priority: 2,
|
|
180
186
|
}),
|
|
181
|
-
|
|
187
|
+
createCellEvent("cell_closed", {
|
|
182
188
|
project_key: projectKey,
|
|
183
|
-
|
|
189
|
+
cell_id: "bd-456",
|
|
184
190
|
reason: "Done",
|
|
185
191
|
}),
|
|
186
|
-
|
|
192
|
+
createCellEvent("cell_epic_child_added", {
|
|
187
193
|
project_key: projectKey,
|
|
188
|
-
|
|
194
|
+
cell_id: "bd-epic",
|
|
189
195
|
child_id: "bd-epic.1",
|
|
190
196
|
}),
|
|
191
197
|
];
|
|
192
198
|
|
|
193
|
-
expect(
|
|
194
|
-
expect(
|
|
195
|
-
expect(
|
|
199
|
+
expect(getCellIdFromEvent(events[0])).toBe("bd-123");
|
|
200
|
+
expect(getCellIdFromEvent(events[1])).toBe("bd-456");
|
|
201
|
+
expect(getCellIdFromEvent(events[2])).toBe("bd-epic");
|
|
196
202
|
});
|
|
197
203
|
});
|
|
198
204
|
|
|
199
205
|
describe("discriminated union validation", () => {
|
|
200
|
-
test("validates against full
|
|
206
|
+
test("validates against full CellEventSchema", () => {
|
|
201
207
|
const rawEvent = {
|
|
202
|
-
type: "
|
|
208
|
+
type: "cell_created",
|
|
203
209
|
project_key: projectKey,
|
|
204
210
|
timestamp: Date.now(),
|
|
205
|
-
|
|
206
|
-
title: "Test
|
|
211
|
+
cell_id: "bd-123",
|
|
212
|
+
title: "Test cell",
|
|
207
213
|
issue_type: "feature",
|
|
208
214
|
priority: 1,
|
|
209
215
|
};
|
|
210
216
|
|
|
211
|
-
const result =
|
|
217
|
+
const result = CellEventSchema.safeParse(rawEvent);
|
|
212
218
|
expect(result.success).toBe(true);
|
|
213
219
|
});
|
|
214
220
|
|
|
@@ -217,10 +223,10 @@ describe("BeadEventSchema", () => {
|
|
|
217
223
|
type: "invalid_event",
|
|
218
224
|
project_key: projectKey,
|
|
219
225
|
timestamp: Date.now(),
|
|
220
|
-
|
|
226
|
+
cell_id: "bd-123",
|
|
221
227
|
};
|
|
222
228
|
|
|
223
|
-
const result =
|
|
229
|
+
const result = CellEventSchema.safeParse(rawEvent);
|
|
224
230
|
expect(result.success).toBe(false);
|
|
225
231
|
});
|
|
226
232
|
|
|
@@ -233,9 +239,9 @@ describe("BeadEventSchema", () => {
|
|
|
233
239
|
] as const;
|
|
234
240
|
|
|
235
241
|
for (const depType of validTypes) {
|
|
236
|
-
const event =
|
|
242
|
+
const event = createCellEvent("cell_dependency_added", {
|
|
237
243
|
project_key: projectKey,
|
|
238
|
-
|
|
244
|
+
cell_id: "bd-123",
|
|
239
245
|
dependency: {
|
|
240
246
|
id: "bd-456",
|
|
241
247
|
type: depType,
|
|
@@ -249,9 +255,9 @@ describe("BeadEventSchema", () => {
|
|
|
249
255
|
|
|
250
256
|
describe("event metadata", () => {
|
|
251
257
|
test("supports metadata field", () => {
|
|
252
|
-
const event =
|
|
258
|
+
const event = createCellEvent("cell_created", {
|
|
253
259
|
project_key: projectKey,
|
|
254
|
-
|
|
260
|
+
cell_id: "bd-123",
|
|
255
261
|
title: "Test",
|
|
256
262
|
issue_type: "task",
|
|
257
263
|
priority: 2,
|
|
@@ -269,15 +275,15 @@ describe("BeadEventSchema", () => {
|
|
|
269
275
|
|
|
270
276
|
describe("epic closure eligible event", () => {
|
|
271
277
|
test("creates valid closure eligible event", () => {
|
|
272
|
-
const event =
|
|
278
|
+
const event = createCellEvent("cell_epic_closure_eligible", {
|
|
273
279
|
project_key: projectKey,
|
|
274
|
-
|
|
280
|
+
cell_id: "bd-epic",
|
|
275
281
|
child_ids: ["bd-epic.1", "bd-epic.2", "bd-epic.3"],
|
|
276
282
|
total_duration_ms: 120000,
|
|
277
283
|
all_files_touched: ["src/a.ts", "src/b.ts"],
|
|
278
284
|
});
|
|
279
285
|
|
|
280
|
-
expect(event.type).toBe("
|
|
286
|
+
expect(event.type).toBe("cell_epic_closure_eligible");
|
|
281
287
|
expect(event.child_ids).toHaveLength(3);
|
|
282
288
|
expect(event.total_duration_ms).toBe(120000);
|
|
283
289
|
});
|
|
@@ -285,9 +291,9 @@ describe("BeadEventSchema", () => {
|
|
|
285
291
|
|
|
286
292
|
describe("status changed event", () => {
|
|
287
293
|
test("tracks status transitions", () => {
|
|
288
|
-
const event =
|
|
294
|
+
const event = createCellEvent("cell_status_changed", {
|
|
289
295
|
project_key: projectKey,
|
|
290
|
-
|
|
296
|
+
cell_id: "bd-123",
|
|
291
297
|
from_status: "open",
|
|
292
298
|
to_status: "in_progress",
|
|
293
299
|
changed_by: "agent",
|
|
@@ -298,9 +304,9 @@ describe("BeadEventSchema", () => {
|
|
|
298
304
|
});
|
|
299
305
|
|
|
300
306
|
test("includes optional reason for blocked/closed", () => {
|
|
301
|
-
const event =
|
|
307
|
+
const event = createCellEvent("cell_status_changed", {
|
|
302
308
|
project_key: projectKey,
|
|
303
|
-
|
|
309
|
+
cell_id: "bd-123",
|
|
304
310
|
from_status: "in_progress",
|
|
305
311
|
to_status: "blocked",
|
|
306
312
|
reason: "Waiting for API credentials",
|
|
@@ -312,9 +318,9 @@ describe("BeadEventSchema", () => {
|
|
|
312
318
|
|
|
313
319
|
describe("comment events", () => {
|
|
314
320
|
test("creates comment with optional parent", () => {
|
|
315
|
-
const event =
|
|
321
|
+
const event = createCellEvent("cell_comment_added", {
|
|
316
322
|
project_key: projectKey,
|
|
317
|
-
|
|
323
|
+
cell_id: "bd-123",
|
|
318
324
|
author: "BlueLake",
|
|
319
325
|
body: "Progress update: auth service implemented",
|
|
320
326
|
parent_comment_id: 42,
|
|
@@ -327,9 +333,9 @@ describe("BeadEventSchema", () => {
|
|
|
327
333
|
|
|
328
334
|
describe("work tracking events", () => {
|
|
329
335
|
test("tracks work start with file reservations", () => {
|
|
330
|
-
const event =
|
|
336
|
+
const event = createCellEvent("cell_work_started", {
|
|
331
337
|
project_key: projectKey,
|
|
332
|
-
|
|
338
|
+
cell_id: "bd-123",
|
|
333
339
|
agent_name: "BlueLake",
|
|
334
340
|
reserved_files: ["src/auth/**"],
|
|
335
341
|
});
|