opencode-swarm-plugin 0.21.0 → 0.22.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.
@@ -1356,4 +1356,128 @@ describe("Swarm Prompt V2 (with Swarm Mail/Beads)", () => {
1356
1356
  expect(SUBTASK_PROMPT_V2).toContain("CRITICAL");
1357
1357
  });
1358
1358
  });
1359
+
1360
+ describe("swarm_complete automatic memory capture", () => {
1361
+ let beadsAvailable = false;
1362
+
1363
+ beforeAll(async () => {
1364
+ beadsAvailable = await isBeadsAvailable();
1365
+ });
1366
+
1367
+ it.skipIf(!beadsAvailable)(
1368
+ "includes memory_capture object in response",
1369
+ async () => {
1370
+ // Create a real bead for the test
1371
+ const createResult =
1372
+ await Bun.$`bd create "Test memory capture" -t task --json`
1373
+ .quiet()
1374
+ .nothrow();
1375
+
1376
+ if (createResult.exitCode !== 0) {
1377
+ console.warn(
1378
+ "Could not create bead:",
1379
+ createResult.stderr.toString(),
1380
+ );
1381
+ return;
1382
+ }
1383
+
1384
+ const bead = JSON.parse(createResult.stdout.toString());
1385
+
1386
+ try {
1387
+ const result = await swarm_complete.execute(
1388
+ {
1389
+ project_key: "/tmp/test-memory-capture",
1390
+ agent_name: "test-agent",
1391
+ bead_id: bead.id,
1392
+ summary: "Implemented auto-capture feature",
1393
+ files_touched: ["src/swarm-orchestrate.ts"],
1394
+ skip_verification: true,
1395
+ },
1396
+ mockContext,
1397
+ );
1398
+
1399
+ const parsed = JSON.parse(result);
1400
+
1401
+ // Verify memory capture was attempted
1402
+ expect(parsed).toHaveProperty("memory_capture");
1403
+ expect(parsed.memory_capture).toHaveProperty("attempted", true);
1404
+ expect(parsed.memory_capture).toHaveProperty("stored");
1405
+ expect(parsed.memory_capture).toHaveProperty("information");
1406
+ expect(parsed.memory_capture).toHaveProperty("metadata");
1407
+
1408
+ // Information should contain bead ID and summary
1409
+ expect(parsed.memory_capture.information).toContain(bead.id);
1410
+ expect(parsed.memory_capture.information).toContain(
1411
+ "Implemented auto-capture feature",
1412
+ );
1413
+
1414
+ // Metadata should contain relevant tags
1415
+ expect(parsed.memory_capture.metadata).toContain("swarm");
1416
+ expect(parsed.memory_capture.metadata).toContain("success");
1417
+ } catch (error) {
1418
+ // Clean up bead if test fails
1419
+ await Bun.$`bd close ${bead.id} --reason "Test cleanup"`
1420
+ .quiet()
1421
+ .nothrow();
1422
+ throw error;
1423
+ }
1424
+ },
1425
+ );
1426
+
1427
+ it.skipIf(!beadsAvailable)(
1428
+ "attempts to store in semantic-memory when available",
1429
+ async () => {
1430
+ const createResult =
1431
+ await Bun.$`bd create "Test semantic-memory storage" -t task --json`
1432
+ .quiet()
1433
+ .nothrow();
1434
+
1435
+ if (createResult.exitCode !== 0) {
1436
+ console.warn(
1437
+ "Could not create bead:",
1438
+ createResult.stderr.toString(),
1439
+ );
1440
+ return;
1441
+ }
1442
+
1443
+ const bead = JSON.parse(createResult.stdout.toString());
1444
+
1445
+ try {
1446
+ const result = await swarm_complete.execute(
1447
+ {
1448
+ project_key: "/tmp/test-memory-storage",
1449
+ agent_name: "test-agent",
1450
+ bead_id: bead.id,
1451
+ summary: "Fixed critical bug in auth flow",
1452
+ files_touched: ["src/auth.ts", "src/middleware.ts"],
1453
+ skip_verification: true,
1454
+ },
1455
+ mockContext,
1456
+ );
1457
+
1458
+ const parsed = JSON.parse(result);
1459
+
1460
+ // If semantic-memory is available, stored should be true
1461
+ // If not, error should explain why
1462
+ if (parsed.memory_capture.stored) {
1463
+ expect(parsed.memory_capture.note).toContain(
1464
+ "automatically stored in semantic-memory",
1465
+ );
1466
+ } else {
1467
+ expect(parsed.memory_capture.error).toBeDefined();
1468
+ expect(
1469
+ parsed.memory_capture.error.includes("not available") ||
1470
+ parsed.memory_capture.error.includes("failed"),
1471
+ ).toBe(true);
1472
+ }
1473
+ } catch (error) {
1474
+ // Clean up bead if test fails
1475
+ await Bun.$`bd close ${bead.id} --reason "Test cleanup"`
1476
+ .quiet()
1477
+ .nothrow();
1478
+ throw error;
1479
+ }
1480
+ },
1481
+ );
1482
+ });
1359
1483
  });
@@ -9,5 +9,11 @@ export default defineConfig({
9
9
  sequence: {
10
10
  concurrent: false,
11
11
  },
12
+ env: {
13
+ // Enable test-specific collections to isolate test data from production
14
+ TEST_MEMORY_COLLECTIONS: "true",
15
+ },
16
+ // Global setup/teardown hooks
17
+ globalSetup: "./vitest.integration.setup.ts",
12
18
  },
13
19
  });
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Global setup/teardown for integration tests
3
+ *
4
+ * Ensures test-specific semantic-memory collections are cleaned up
5
+ * after all integration tests complete.
6
+ */
7
+
8
+ export async function setup() {
9
+ console.log("[vitest] Integration test setup: TEST_MEMORY_COLLECTIONS=true");
10
+ // Setup runs before tests - environment variables are already set via vitest config
11
+ }
12
+
13
+ export async function teardown() {
14
+ console.log(
15
+ "[vitest] Integration test teardown: cleaning up test collections",
16
+ );
17
+
18
+ // Clean up test collections
19
+ const testCollections = [
20
+ "swarm-feedback-test",
21
+ "swarm-patterns-test",
22
+ "swarm-maturity-test",
23
+ "swarm-maturity-test-feedback",
24
+ ];
25
+
26
+ for (const collection of testCollections) {
27
+ try {
28
+ // Attempt to remove test collection data
29
+ // Note: semantic-memory doesn't have a built-in "delete collection" command,
30
+ // so we'll use the remove command with a wildcard or rely on TTL/manual cleanup
31
+ console.log(`[vitest] Attempting to clean collection: ${collection}`);
32
+
33
+ // List items and remove them (semantic-memory may not support bulk delete)
34
+ // This is a best-effort cleanup - some backends may require manual cleanup
35
+ // For now, we'll just log that cleanup should happen
36
+ console.log(
37
+ `[vitest] Note: Collection "${collection}" may need manual cleanup via semantic-memory CLI`,
38
+ );
39
+ } catch (error) {
40
+ console.warn(
41
+ `[vitest] Failed to clean collection ${collection}:`,
42
+ error instanceof Error ? error.message : String(error),
43
+ );
44
+ }
45
+ }
46
+
47
+ console.log("[vitest] Integration test teardown complete");
48
+ }