opencode-swarm-plugin 0.22.0 → 0.23.1

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.
Files changed (128) hide show
  1. package/.turbo/turbo-build.log +9 -0
  2. package/CHANGELOG.md +20 -0
  3. package/README.md +109 -429
  4. package/dist/agent-mail.d.ts +480 -0
  5. package/dist/agent-mail.d.ts.map +1 -0
  6. package/dist/anti-patterns.d.ts +257 -0
  7. package/dist/anti-patterns.d.ts.map +1 -0
  8. package/dist/beads.d.ts +377 -0
  9. package/dist/beads.d.ts.map +1 -0
  10. package/dist/eval-capture.d.ts +206 -0
  11. package/dist/eval-capture.d.ts.map +1 -0
  12. package/dist/index.d.ts +1299 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +498 -4246
  15. package/dist/learning.d.ts +670 -0
  16. package/dist/learning.d.ts.map +1 -0
  17. package/dist/mandate-promotion.d.ts +93 -0
  18. package/dist/mandate-promotion.d.ts.map +1 -0
  19. package/dist/mandate-storage.d.ts +209 -0
  20. package/dist/mandate-storage.d.ts.map +1 -0
  21. package/dist/mandates.d.ts +230 -0
  22. package/dist/mandates.d.ts.map +1 -0
  23. package/dist/output-guardrails.d.ts +125 -0
  24. package/dist/output-guardrails.d.ts.map +1 -0
  25. package/dist/pattern-maturity.d.ts +246 -0
  26. package/dist/pattern-maturity.d.ts.map +1 -0
  27. package/dist/plugin.d.ts +22 -0
  28. package/dist/plugin.d.ts.map +1 -0
  29. package/dist/plugin.js +493 -4241
  30. package/dist/rate-limiter.d.ts +218 -0
  31. package/dist/rate-limiter.d.ts.map +1 -0
  32. package/dist/repo-crawl.d.ts +146 -0
  33. package/dist/repo-crawl.d.ts.map +1 -0
  34. package/dist/schemas/bead.d.ts +255 -0
  35. package/dist/schemas/bead.d.ts.map +1 -0
  36. package/dist/schemas/evaluation.d.ts +161 -0
  37. package/dist/schemas/evaluation.d.ts.map +1 -0
  38. package/dist/schemas/index.d.ts +34 -0
  39. package/dist/schemas/index.d.ts.map +1 -0
  40. package/dist/schemas/mandate.d.ts +336 -0
  41. package/dist/schemas/mandate.d.ts.map +1 -0
  42. package/dist/schemas/swarm-context.d.ts +131 -0
  43. package/dist/schemas/swarm-context.d.ts.map +1 -0
  44. package/dist/schemas/task.d.ts +188 -0
  45. package/dist/schemas/task.d.ts.map +1 -0
  46. package/dist/skills.d.ts +471 -0
  47. package/dist/skills.d.ts.map +1 -0
  48. package/dist/storage.d.ts +260 -0
  49. package/dist/storage.d.ts.map +1 -0
  50. package/dist/structured.d.ts +196 -0
  51. package/dist/structured.d.ts.map +1 -0
  52. package/dist/swarm-decompose.d.ts +201 -0
  53. package/dist/swarm-decompose.d.ts.map +1 -0
  54. package/dist/swarm-mail.d.ts +240 -0
  55. package/dist/swarm-mail.d.ts.map +1 -0
  56. package/dist/swarm-orchestrate.d.ts +708 -0
  57. package/dist/swarm-orchestrate.d.ts.map +1 -0
  58. package/dist/swarm-prompts.d.ts +292 -0
  59. package/dist/swarm-prompts.d.ts.map +1 -0
  60. package/dist/swarm-strategies.d.ts +100 -0
  61. package/dist/swarm-strategies.d.ts.map +1 -0
  62. package/dist/swarm.d.ts +455 -0
  63. package/dist/swarm.d.ts.map +1 -0
  64. package/dist/tool-availability.d.ts +91 -0
  65. package/dist/tool-availability.d.ts.map +1 -0
  66. package/docs/planning/ADR-001-monorepo-structure.md +171 -0
  67. package/docs/planning/ADR-002-package-extraction.md +393 -0
  68. package/docs/planning/ADR-003-performance-improvements.md +451 -0
  69. package/docs/planning/ADR-004-message-queue-features.md +187 -0
  70. package/docs/planning/ADR-005-devtools-observability.md +202 -0
  71. package/docs/planning/ROADMAP.md +368 -0
  72. package/package.json +13 -24
  73. package/src/agent-mail.ts +1 -1
  74. package/src/beads.ts +1 -2
  75. package/src/index.ts +2 -2
  76. package/src/learning.integration.test.ts +66 -11
  77. package/src/mandate-storage.test.ts +3 -3
  78. package/src/storage.ts +78 -10
  79. package/src/swarm-mail.ts +3 -3
  80. package/src/swarm-orchestrate.ts +7 -7
  81. package/src/tool-availability.ts +1 -1
  82. package/tsconfig.json +1 -1
  83. package/.beads/.local_version +0 -1
  84. package/.beads/README.md +0 -81
  85. package/.beads/analysis/skill-architecture-meta-skills.md +0 -1562
  86. package/.beads/config.yaml +0 -62
  87. package/.beads/issues.jsonl +0 -2197
  88. package/.beads/metadata.json +0 -4
  89. package/.gitattributes +0 -3
  90. package/.github/workflows/ci.yml +0 -30
  91. package/.github/workflows/opencode.yml +0 -31
  92. package/.opencode/skills/tdd/SKILL.md +0 -182
  93. package/INTEGRATION_EXAMPLE.md +0 -66
  94. package/VERIFICATION_QUALITY_PATTERNS.md +0 -565
  95. package/bun.lock +0 -286
  96. package/dist/pglite.data +0 -0
  97. package/dist/pglite.wasm +0 -0
  98. package/src/streams/agent-mail.test.ts +0 -777
  99. package/src/streams/agent-mail.ts +0 -535
  100. package/src/streams/debug.test.ts +0 -500
  101. package/src/streams/debug.ts +0 -727
  102. package/src/streams/effect/ask.integration.test.ts +0 -314
  103. package/src/streams/effect/ask.ts +0 -202
  104. package/src/streams/effect/cursor.integration.test.ts +0 -418
  105. package/src/streams/effect/cursor.ts +0 -288
  106. package/src/streams/effect/deferred.test.ts +0 -357
  107. package/src/streams/effect/deferred.ts +0 -445
  108. package/src/streams/effect/index.ts +0 -17
  109. package/src/streams/effect/layers.ts +0 -73
  110. package/src/streams/effect/lock.test.ts +0 -385
  111. package/src/streams/effect/lock.ts +0 -399
  112. package/src/streams/effect/mailbox.test.ts +0 -260
  113. package/src/streams/effect/mailbox.ts +0 -318
  114. package/src/streams/events.test.ts +0 -924
  115. package/src/streams/events.ts +0 -329
  116. package/src/streams/index.test.ts +0 -229
  117. package/src/streams/index.ts +0 -578
  118. package/src/streams/migrations.test.ts +0 -359
  119. package/src/streams/migrations.ts +0 -362
  120. package/src/streams/projections.test.ts +0 -611
  121. package/src/streams/projections.ts +0 -504
  122. package/src/streams/store.integration.test.ts +0 -658
  123. package/src/streams/store.ts +0 -1075
  124. package/src/streams/swarm-mail.ts +0 -552
  125. package/test-bug-fixes.ts +0 -86
  126. package/vitest.integration.config.ts +0 -19
  127. package/vitest.integration.setup.ts +0 -48
  128. package/workflow-integration-analysis.md +0 -876
@@ -1,357 +0,0 @@
1
- /**
2
- * Tests for DurableDeferred service
3
- *
4
- * Verifies:
5
- * - Create deferred with unique URL
6
- * - Resolve deferred from another context
7
- * - Reject deferred with error
8
- * - Timeout when not resolved in time
9
- * - Concurrent access patterns
10
- * - Cleanup of expired entries
11
- */
12
-
13
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
14
- import { mkdir, rm } from "node:fs/promises";
15
- import { join } from "node:path";
16
- import { tmpdir } from "node:os";
17
- import { Effect } from "effect";
18
- import { closeDatabase } from "../index";
19
- import {
20
- TimeoutError,
21
- NotFoundError,
22
- createDeferred,
23
- resolveDeferred,
24
- rejectDeferred,
25
- cleanupDeferreds,
26
- DurableDeferredLive,
27
- } from "./deferred";
28
-
29
- let TEST_PROJECT_PATH: string;
30
-
31
- describe("DurableDeferred", () => {
32
- beforeEach(async () => {
33
- TEST_PROJECT_PATH = join(
34
- tmpdir(),
35
- `deferred-test-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
36
- );
37
- await mkdir(TEST_PROJECT_PATH, { recursive: true });
38
- });
39
-
40
- afterEach(async () => {
41
- try {
42
- await closeDatabase(TEST_PROJECT_PATH);
43
- // Small delay to let PGLite fully release file handles
44
- await new Promise((r) => setTimeout(r, 50));
45
- await rm(join(TEST_PROJECT_PATH, ".opencode"), {
46
- recursive: true,
47
- force: true,
48
- });
49
- } catch {
50
- // Ignore cleanup errors
51
- }
52
- });
53
-
54
- describe("create", () => {
55
- it("creates a deferred with unique URL", async () => {
56
- const program = Effect.gen(function* (_) {
57
- const handle = yield* _(
58
- createDeferred<string>({
59
- ttlSeconds: 60,
60
- projectPath: TEST_PROJECT_PATH,
61
- }),
62
- );
63
-
64
- expect(handle.url).toMatch(/^deferred:/);
65
- expect(handle.value).toBeDefined();
66
- });
67
-
68
- await Effect.runPromise(
69
- program.pipe(Effect.provide(DurableDeferredLive)),
70
- );
71
- });
72
-
73
- it("creates multiple deferreds with different URLs", async () => {
74
- const program = Effect.gen(function* (_) {
75
- const handle1 = yield* _(
76
- createDeferred<string>({
77
- ttlSeconds: 60,
78
- projectPath: TEST_PROJECT_PATH,
79
- }),
80
- );
81
- const handle2 = yield* _(
82
- createDeferred<string>({
83
- ttlSeconds: 60,
84
- projectPath: TEST_PROJECT_PATH,
85
- }),
86
- );
87
-
88
- expect(handle1.url).not.toBe(handle2.url);
89
- });
90
-
91
- await Effect.runPromise(
92
- program.pipe(Effect.provide(DurableDeferredLive)),
93
- );
94
- });
95
- });
96
-
97
- describe("resolve", () => {
98
- it("resolves a deferred and returns value", async () => {
99
- const program = Effect.gen(function* (_) {
100
- const handle = yield* _(
101
- createDeferred<{ message: string }>({
102
- ttlSeconds: 60,
103
- projectPath: TEST_PROJECT_PATH,
104
- }),
105
- );
106
-
107
- // Resolve in background
108
- Effect.runFork(
109
- Effect.gen(function* (_) {
110
- yield* _(Effect.sleep("100 millis"));
111
- yield* _(
112
- resolveDeferred(
113
- handle.url,
114
- { message: "resolved!" },
115
- TEST_PROJECT_PATH,
116
- ),
117
- );
118
- }).pipe(Effect.provide(DurableDeferredLive)),
119
- );
120
-
121
- // Await resolution
122
- const result = yield* _(handle.value);
123
- expect(result).toEqual({ message: "resolved!" });
124
- });
125
-
126
- await Effect.runPromise(
127
- program.pipe(Effect.provide(DurableDeferredLive)),
128
- );
129
- });
130
-
131
- it("fails with NotFoundError for non-existent URL", async () => {
132
- const program = Effect.gen(function* (_) {
133
- yield* _(
134
- resolveDeferred(
135
- "deferred:nonexistent",
136
- { value: 42 },
137
- TEST_PROJECT_PATH,
138
- ),
139
- );
140
- });
141
-
142
- const result = await Effect.runPromise(
143
- program.pipe(
144
- Effect.provide(DurableDeferredLive),
145
- Effect.flip, // Flip to get the error
146
- ),
147
- );
148
-
149
- expect(result).toBeInstanceOf(NotFoundError);
150
- expect((result as NotFoundError).url).toBe("deferred:nonexistent");
151
- });
152
- });
153
-
154
- describe("reject", () => {
155
- it("rejects a deferred with error", async () => {
156
- const program = Effect.gen(function* (_) {
157
- const handle = yield* _(
158
- createDeferred<string>({
159
- ttlSeconds: 60,
160
- projectPath: TEST_PROJECT_PATH,
161
- }),
162
- );
163
-
164
- // Reject in background
165
- Effect.runFork(
166
- Effect.gen(function* (_) {
167
- yield* _(Effect.sleep("100 millis"));
168
- yield* _(
169
- rejectDeferred(
170
- handle.url,
171
- new Error("Something went wrong"),
172
- TEST_PROJECT_PATH,
173
- ),
174
- );
175
- }).pipe(Effect.provide(DurableDeferredLive)),
176
- );
177
-
178
- // Await should fail
179
- yield* _(handle.value);
180
- });
181
-
182
- const result = await Effect.runPromise(
183
- program.pipe(
184
- Effect.provide(DurableDeferredLive),
185
- Effect.flip, // Flip to get the error
186
- ),
187
- );
188
-
189
- // Will be a NotFoundError since we map all errors to NotFoundError in awaitImpl
190
- expect(result).toBeInstanceOf(NotFoundError);
191
- });
192
-
193
- it("fails with NotFoundError for non-existent URL", async () => {
194
- const program = Effect.gen(function* (_) {
195
- yield* _(
196
- rejectDeferred(
197
- "deferred:nonexistent",
198
- new Error("test"),
199
- TEST_PROJECT_PATH,
200
- ),
201
- );
202
- });
203
-
204
- const result = await Effect.runPromise(
205
- program.pipe(Effect.provide(DurableDeferredLive), Effect.flip),
206
- );
207
-
208
- expect(result).toBeInstanceOf(NotFoundError);
209
- });
210
- });
211
-
212
- describe("timeout", () => {
213
- it("times out when not resolved within TTL", async () => {
214
- const program = Effect.gen(function* (_) {
215
- const handle = yield* _(
216
- createDeferred<string>({
217
- ttlSeconds: 1, // 1 second timeout
218
- projectPath: TEST_PROJECT_PATH,
219
- }),
220
- );
221
-
222
- // Don't resolve, just wait for timeout
223
- yield* _(handle.value);
224
- });
225
-
226
- const result = await Effect.runPromise(
227
- program.pipe(Effect.provide(DurableDeferredLive), Effect.flip),
228
- );
229
-
230
- expect(result).toBeInstanceOf(TimeoutError);
231
- expect((result as TimeoutError).ttlSeconds).toBe(1);
232
- }, 10000); // 10s test timeout
233
- });
234
-
235
- describe("concurrent access", () => {
236
- it("handles multiple resolvers racing", async () => {
237
- const program = Effect.gen(function* (_) {
238
- const handle = yield* _(
239
- createDeferred<number>({
240
- ttlSeconds: 60,
241
- projectPath: TEST_PROJECT_PATH,
242
- }),
243
- );
244
-
245
- // Spawn multiple resolvers (first one wins)
246
- Effect.runFork(
247
- Effect.gen(function* (_) {
248
- yield* _(Effect.sleep("50 millis"));
249
- yield* _(resolveDeferred(handle.url, 1, TEST_PROJECT_PATH));
250
- }).pipe(Effect.provide(DurableDeferredLive)),
251
- );
252
-
253
- Effect.runFork(
254
- Effect.gen(function* (_) {
255
- yield* _(Effect.sleep("100 millis"));
256
- yield* _(resolveDeferred(handle.url, 2, TEST_PROJECT_PATH));
257
- }).pipe(Effect.provide(DurableDeferredLive)),
258
- );
259
-
260
- const result = yield* _(handle.value);
261
- expect(result).toBe(1); // First resolver wins
262
- });
263
-
264
- await Effect.runPromise(
265
- program.pipe(Effect.provide(DurableDeferredLive)),
266
- );
267
- });
268
-
269
- it("handles sequential waiters on same deferred", async () => {
270
- const program = Effect.gen(function* (_) {
271
- const handle = yield* _(
272
- createDeferred<string>({
273
- ttlSeconds: 60,
274
- projectPath: TEST_PROJECT_PATH,
275
- }),
276
- );
277
-
278
- // Resolve immediately
279
- yield* _(resolveDeferred(handle.url, "resolved", TEST_PROJECT_PATH));
280
-
281
- // Wait for value
282
- const result = yield* _(handle.value);
283
- expect(result).toBe("resolved");
284
- });
285
-
286
- await Effect.runPromise(
287
- program.pipe(Effect.provide(DurableDeferredLive)),
288
- );
289
- });
290
- });
291
-
292
- describe("cleanup", () => {
293
- it("cleans up expired entries", async () => {
294
- const program = Effect.gen(function* (_) {
295
- // Create deferred with 1s TTL
296
- const handle = yield* _(
297
- createDeferred<string>({
298
- ttlSeconds: 1,
299
- projectPath: TEST_PROJECT_PATH,
300
- }),
301
- );
302
-
303
- // Wait for expiry
304
- yield* _(Effect.sleep("1500 millis"));
305
-
306
- // Cleanup
307
- const count = yield* _(cleanupDeferreds(TEST_PROJECT_PATH));
308
- expect(count).toBeGreaterThanOrEqual(0);
309
- });
310
-
311
- await Effect.runPromise(
312
- program.pipe(Effect.provide(DurableDeferredLive)),
313
- );
314
- });
315
- });
316
-
317
- describe("type safety", () => {
318
- it("preserves types through resolution", async () => {
319
- interface TestData {
320
- id: number;
321
- name: string;
322
- tags: string[];
323
- }
324
-
325
- const program = Effect.gen(function* (_) {
326
- const handle = yield* _(
327
- createDeferred<TestData>({
328
- ttlSeconds: 60,
329
- projectPath: TEST_PROJECT_PATH,
330
- }),
331
- );
332
-
333
- Effect.runFork(
334
- Effect.gen(function* (_) {
335
- yield* _(Effect.sleep("100 millis"));
336
- yield* _(
337
- resolveDeferred(
338
- handle.url,
339
- { id: 1, name: "test", tags: ["a", "b"] },
340
- TEST_PROJECT_PATH,
341
- ),
342
- );
343
- }).pipe(Effect.provide(DurableDeferredLive)),
344
- );
345
-
346
- const result = yield* _(handle.value);
347
- expect(result.id).toBe(1);
348
- expect(result.name).toBe("test");
349
- expect(result.tags).toEqual(["a", "b"]);
350
- });
351
-
352
- await Effect.runPromise(
353
- program.pipe(Effect.provide(DurableDeferredLive)),
354
- );
355
- });
356
- });
357
- });