opencode-swarm-plugin 0.13.2 → 0.15.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.
@@ -252,139 +252,7 @@ const beads_link_thread = tool({
252
252
  });
253
253
 
254
254
  // =============================================================================
255
- // Agent Mail Tools
256
- // =============================================================================
257
-
258
- const agentmail_init = tool({
259
- description: "Initialize Agent Mail session",
260
- args: {
261
- project_path: tool.schema.string().describe("Absolute path to the project"),
262
- agent_name: tool.schema.string().optional().describe("Custom agent name"),
263
- task_description: tool.schema
264
- .string()
265
- .optional()
266
- .describe("Task description"),
267
- },
268
- execute: (args, ctx) => execTool("agentmail_init", args, ctx),
269
- });
270
-
271
- const agentmail_send = tool({
272
- description: "Send message to other agents",
273
- args: {
274
- to: tool.schema
275
- .array(tool.schema.string())
276
- .describe("Recipient agent names"),
277
- subject: tool.schema.string().describe("Message subject"),
278
- body: tool.schema.string().describe("Message body"),
279
- thread_id: tool.schema
280
- .string()
281
- .optional()
282
- .describe("Thread ID for grouping"),
283
- importance: tool.schema
284
- .enum(["low", "normal", "high", "urgent"])
285
- .optional()
286
- .describe("Message importance"),
287
- ack_required: tool.schema
288
- .boolean()
289
- .optional()
290
- .describe("Require acknowledgment"),
291
- },
292
- execute: (args, ctx) => execTool("agentmail_send", args, ctx),
293
- });
294
-
295
- const agentmail_inbox = tool({
296
- description: "Fetch inbox (CONTEXT-SAFE: bodies excluded, limit 5)",
297
- args: {
298
- limit: tool.schema
299
- .number()
300
- .max(5)
301
- .optional()
302
- .describe("Max messages (max 5)"),
303
- urgent_only: tool.schema
304
- .boolean()
305
- .optional()
306
- .describe("Only urgent messages"),
307
- since_ts: tool.schema
308
- .string()
309
- .optional()
310
- .describe("Messages since timestamp"),
311
- },
312
- execute: (args, ctx) => execTool("agentmail_inbox", args, ctx),
313
- });
314
-
315
- const agentmail_read_message = tool({
316
- description: "Fetch ONE message body by ID",
317
- args: {
318
- message_id: tool.schema.number().describe("Message ID"),
319
- },
320
- execute: (args, ctx) => execTool("agentmail_read_message", args, ctx),
321
- });
322
-
323
- const agentmail_summarize_thread = tool({
324
- description: "Summarize thread (PREFERRED over fetching all messages)",
325
- args: {
326
- thread_id: tool.schema.string().describe("Thread ID"),
327
- include_examples: tool.schema
328
- .boolean()
329
- .optional()
330
- .describe("Include example messages"),
331
- },
332
- execute: (args, ctx) => execTool("agentmail_summarize_thread", args, ctx),
333
- });
334
-
335
- const agentmail_reserve = tool({
336
- description: "Reserve file paths for exclusive editing",
337
- args: {
338
- paths: tool.schema
339
- .array(tool.schema.string())
340
- .describe("File paths/patterns"),
341
- ttl_seconds: tool.schema.number().optional().describe("Reservation TTL"),
342
- exclusive: tool.schema.boolean().optional().describe("Exclusive lock"),
343
- reason: tool.schema.string().optional().describe("Reservation reason"),
344
- },
345
- execute: (args, ctx) => execTool("agentmail_reserve", args, ctx),
346
- });
347
-
348
- const agentmail_release = tool({
349
- description: "Release file reservations",
350
- args: {
351
- paths: tool.schema
352
- .array(tool.schema.string())
353
- .optional()
354
- .describe("Paths to release"),
355
- reservation_ids: tool.schema
356
- .array(tool.schema.number())
357
- .optional()
358
- .describe("Reservation IDs"),
359
- },
360
- execute: (args, ctx) => execTool("agentmail_release", args, ctx),
361
- });
362
-
363
- const agentmail_ack = tool({
364
- description: "Acknowledge a message",
365
- args: {
366
- message_id: tool.schema.number().describe("Message ID"),
367
- },
368
- execute: (args, ctx) => execTool("agentmail_ack", args, ctx),
369
- });
370
-
371
- const agentmail_search = tool({
372
- description: "Search messages by keyword",
373
- args: {
374
- query: tool.schema.string().describe("Search query"),
375
- limit: tool.schema.number().optional().describe("Max results"),
376
- },
377
- execute: (args, ctx) => execTool("agentmail_search", args, ctx),
378
- });
379
-
380
- const agentmail_health = tool({
381
- description: "Check if Agent Mail server is running",
382
- args: {},
383
- execute: (args, ctx) => execTool("agentmail_health", args, ctx),
384
- });
385
-
386
- // =============================================================================
387
- // Swarm Mail Tools (Embedded - Primary)
255
+ // Swarm Mail Tools (Embedded)
388
256
  // =============================================================================
389
257
 
390
258
  const swarmmail_init = tool({
@@ -901,18 +769,7 @@ export const SwarmPlugin: Plugin = async (
901
769
  beads_ready,
902
770
  beads_sync,
903
771
  beads_link_thread,
904
- // Agent Mail (Legacy MCP)
905
- agentmail_init,
906
- agentmail_send,
907
- agentmail_inbox,
908
- agentmail_read_message,
909
- agentmail_summarize_thread,
910
- agentmail_reserve,
911
- agentmail_release,
912
- agentmail_ack,
913
- agentmail_search,
914
- agentmail_health,
915
- // Swarm Mail (Embedded - Primary)
772
+ // Swarm Mail (Embedded)
916
773
  swarmmail_init,
917
774
  swarmmail_send,
918
775
  swarmmail_inbox,
@@ -95,30 +95,76 @@ skills_list();
95
95
 
96
96
  Synthesize findings into `shared_context` for workers.
97
97
 
98
- ### Phase 3: Decomposition
98
+ ### Phase 3: Decomposition (DELEGATE TO SUBAGENT)
99
+
100
+ > **⚠️ CRITICAL: Context Preservation Pattern**
101
+ >
102
+ > **NEVER do planning inline in the coordinator thread.** Decomposition work (file reading, CASS searching, reasoning about task breakdown) consumes massive amounts of context and will exhaust your token budget on long swarms.
103
+ >
104
+ > **ALWAYS delegate planning to a `swarm/planner` subagent** and receive only the structured BeadTree JSON result back.
105
+
106
+ **❌ Anti-Pattern (Context-Heavy):**
99
107
 
100
108
  ```typescript
101
- // Auto-select strategy and generate decomposition prompt
102
- const plan = await swarm_plan_prompt({
103
- task: "Add user authentication with OAuth",
104
- max_subtasks: 5,
105
- query_cass: true, // searches history
106
- include_skills: true, // lists relevant skills
109
+ // DON'T DO THIS - pollutes main thread context
110
+ const plan = await swarm_plan_prompt({ task, ... });
111
+ // ... agent reasons about decomposition inline ...
112
+ // ... context fills with file contents, analysis ...
113
+ const validation = await swarm_validate_decomposition({ ... });
114
+ ```
115
+
116
+ **✅ Correct Pattern (Context-Lean):**
117
+
118
+ ```typescript
119
+ // 1. Create planning bead with full context
120
+ await beads_create({
121
+ title: `Plan: ${taskTitle}`,
122
+ type: "task",
123
+ description: `Decompose into subtasks. Context: ${synthesizedContext}`,
107
124
  });
108
125
 
109
- // Agent responds with BeadTree JSON, then validate
110
- const validation = await swarm_validate_decomposition({
111
- response: agentResponse,
126
+ // 2. Delegate to swarm/planner subagent
127
+ const planningResult = await Task({
128
+ subagent_type: "swarm/planner",
129
+ description: `Decompose task: ${taskTitle}`,
130
+ prompt: `
131
+ You are a swarm planner. Generate a BeadTree for this task.
132
+
133
+ ## Task
134
+ ${taskDescription}
135
+
136
+ ## Synthesized Context
137
+ ${synthesizedContext}
138
+
139
+ ## Instructions
140
+ 1. Use swarm_plan_prompt(task="...", max_subtasks=5, query_cass=true)
141
+ 2. Reason about decomposition strategy
142
+ 3. Generate BeadTree JSON
143
+ 4. Validate with swarm_validate_decomposition
144
+ 5. Return ONLY the validated BeadTree JSON (no analysis, no file contents)
145
+
146
+ Output format: Valid BeadTree JSON only.
147
+ `,
112
148
  });
113
149
 
114
- // Create epic + subtasks atomically
150
+ // 3. Parse result (subagent already validated)
151
+ const beadTree = JSON.parse(planningResult);
152
+
153
+ // 4. Create epic + subtasks atomically
115
154
  await beads_create_epic({
116
- epic_title: "Add OAuth Authentication",
117
- epic_description: "...",
118
- subtasks: validation.subtasks,
155
+ epic_title: beadTree.epic.title,
156
+ epic_description: beadTree.epic.description,
157
+ subtasks: beadTree.subtasks,
119
158
  });
120
159
  ```
121
160
 
161
+ **Why This Matters:**
162
+
163
+ - **Main thread context stays clean** - only receives final JSON, not reasoning
164
+ - **Subagent context is disposable** - gets garbage collected after planning
165
+ - **Scales to long swarms** - coordinator can manage 10+ workers without exhaustion
166
+ - **Faster coordination** - less context = faster responses when monitoring workers
167
+
122
168
  ### Phase 4: Reserve Files (via Swarm Mail)
123
169
 
124
170
  ```typescript
@@ -263,12 +309,16 @@ One blocker affects multiple subtasks.
263
309
 
264
310
  ## Anti-Patterns
265
311
 
266
- | Anti-Pattern | Symptom | Fix |
267
- | -------------------- | -------------------------------- | ----------------------------- |
268
- | **Mega-Coordinator** | Coordinator editing files | Coordinator only orchestrates |
269
- | **Silent Swarm** | No communication, late conflicts | Require updates, check inbox |
270
- | **Over-Decomposed** | 10 subtasks for 20 lines | 2-5 subtasks max |
271
- | **Under-Specified** | "Implement backend" | Clear goal, files, criteria |
312
+ | Anti-Pattern | Symptom | Fix |
313
+ | ------------------------ | ------------------------------------------ | ------------------------------------ |
314
+ | **Mega-Coordinator** | Coordinator editing files | Coordinator only orchestrates |
315
+ | **Silent Swarm** | No communication, late conflicts | Require updates, check inbox |
316
+ | **Over-Decomposed** | 10 subtasks for 20 lines | 2-5 subtasks max |
317
+ | **Under-Specified** | "Implement backend" | Clear goal, files, criteria |
318
+ | **Inline Planning** ⚠️ | Context pollution, exhaustion on long runs | Delegate planning to subagent |
319
+ | **Heavy File Reading** | Coordinator reading 10+ files | Subagent reads, returns summary only |
320
+ | **Deep CASS Drilling** | Multiple cass_search calls inline | Subagent searches, summarizes |
321
+ | **Manual Decomposition** | Hand-crafting subtasks without validation | Use swarm_plan_prompt + validation |
272
322
 
273
323
  ## Shared Context Template
274
324
 
@@ -49,7 +49,7 @@ For each subtask:
49
49
  ### 4. Progress Monitoring
50
50
 
51
51
  - Check `beads_query(status="in_progress")` for active work
52
- - Check `agentmail_inbox()` for worker messages
52
+ - Check `swarmmail_inbox()` for worker messages
53
53
  - Intervene on blockers (see Intervention Patterns below)
54
54
 
55
55
  ### 5. Completion & Aggregation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm-plugin",
3
- "version": "0.13.2",
3
+ "version": "0.15.0",
4
4
  "description": "Multi-agent swarm coordination for OpenCode with learning capabilities, beads integration, and Agent Mail",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -135,7 +135,6 @@ export const SwarmPlugin: Plugin = async (
135
135
  */
136
136
  tool: {
137
137
  ...beadsTools,
138
- ...agentMailTools,
139
138
  ...swarmMailTools,
140
139
  ...structuredTools,
141
140
  ...swarmTools,
@@ -357,7 +356,6 @@ export {
357
356
  */
358
357
  export const allTools = {
359
358
  ...beadsTools,
360
- ...agentMailTools,
361
359
  ...swarmMailTools,
362
360
  ...structuredTools,
363
361
  ...swarmTools,
@@ -1427,3 +1427,313 @@ describe("Storage Module", () => {
1427
1427
  });
1428
1428
  });
1429
1429
  });
1430
+
1431
+ // ============================================================================
1432
+ // 3-Strike Detection Tests
1433
+ // ============================================================================
1434
+
1435
+ import {
1436
+ InMemoryStrikeStorage,
1437
+ addStrike,
1438
+ getStrikes,
1439
+ isStrikedOut,
1440
+ getArchitecturePrompt,
1441
+ clearStrikes,
1442
+ type StrikeStorage,
1443
+ } from "./learning";
1444
+
1445
+ describe("3-Strike Detection", () => {
1446
+ let storage: StrikeStorage;
1447
+
1448
+ beforeEach(() => {
1449
+ storage = new InMemoryStrikeStorage();
1450
+ });
1451
+
1452
+ describe("addStrike", () => {
1453
+ it("records first strike", async () => {
1454
+ const record = await addStrike(
1455
+ "test-bead-1",
1456
+ "Attempted null check fix",
1457
+ "Still getting undefined errors",
1458
+ storage,
1459
+ );
1460
+
1461
+ expect(record.bead_id).toBe("test-bead-1");
1462
+ expect(record.strike_count).toBe(1);
1463
+ expect(record.failures).toHaveLength(1);
1464
+ expect(record.failures[0].attempt).toBe("Attempted null check fix");
1465
+ expect(record.failures[0].reason).toBe("Still getting undefined errors");
1466
+ expect(record.first_strike_at).toBeDefined();
1467
+ expect(record.last_strike_at).toBeDefined();
1468
+ });
1469
+
1470
+ it("increments strike count on subsequent strikes", async () => {
1471
+ await addStrike("test-bead-2", "Fix 1", "Failed 1", storage);
1472
+ const record2 = await addStrike(
1473
+ "test-bead-2",
1474
+ "Fix 2",
1475
+ "Failed 2",
1476
+ storage,
1477
+ );
1478
+
1479
+ expect(record2.strike_count).toBe(2);
1480
+ expect(record2.failures).toHaveLength(2);
1481
+ });
1482
+
1483
+ it("caps strike count at 3", async () => {
1484
+ await addStrike("test-bead-3", "Fix 1", "Failed 1", storage);
1485
+ await addStrike("test-bead-3", "Fix 2", "Failed 2", storage);
1486
+ await addStrike("test-bead-3", "Fix 3", "Failed 3", storage);
1487
+ const record4 = await addStrike(
1488
+ "test-bead-3",
1489
+ "Fix 4",
1490
+ "Failed 4",
1491
+ storage,
1492
+ );
1493
+
1494
+ expect(record4.strike_count).toBe(3);
1495
+ expect(record4.failures).toHaveLength(4); // Records all attempts
1496
+ });
1497
+
1498
+ it("preserves first_strike_at timestamp", async () => {
1499
+ const record1 = await addStrike(
1500
+ "test-bead-4",
1501
+ "Fix 1",
1502
+ "Failed 1",
1503
+ storage,
1504
+ );
1505
+ await new Promise((resolve) => setTimeout(resolve, 100));
1506
+ const record2 = await addStrike(
1507
+ "test-bead-4",
1508
+ "Fix 2",
1509
+ "Failed 2",
1510
+ storage,
1511
+ );
1512
+
1513
+ expect(record2.first_strike_at).toBe(record1.first_strike_at);
1514
+ expect(record2.last_strike_at).not.toBe(record1.last_strike_at);
1515
+ });
1516
+ });
1517
+
1518
+ describe("getStrikes", () => {
1519
+ it("returns 0 for bead with no strikes", async () => {
1520
+ const count = await getStrikes("no-strikes-bead", storage);
1521
+ expect(count).toBe(0);
1522
+ });
1523
+
1524
+ it("returns correct strike count", async () => {
1525
+ await addStrike("bead-with-strikes", "Fix 1", "Failed 1", storage);
1526
+ await addStrike("bead-with-strikes", "Fix 2", "Failed 2", storage);
1527
+
1528
+ const count = await getStrikes("bead-with-strikes", storage);
1529
+ expect(count).toBe(2);
1530
+ });
1531
+ });
1532
+
1533
+ describe("isStrikedOut", () => {
1534
+ it("returns false for bead with < 3 strikes", async () => {
1535
+ await addStrike("bead-safe", "Fix 1", "Failed 1", storage);
1536
+ await addStrike("bead-safe", "Fix 2", "Failed 2", storage);
1537
+
1538
+ const strikedOut = await isStrikedOut("bead-safe", storage);
1539
+ expect(strikedOut).toBe(false);
1540
+ });
1541
+
1542
+ it("returns true for bead with 3 strikes", async () => {
1543
+ await addStrike("bead-danger", "Fix 1", "Failed 1", storage);
1544
+ await addStrike("bead-danger", "Fix 2", "Failed 2", storage);
1545
+ await addStrike("bead-danger", "Fix 3", "Failed 3", storage);
1546
+
1547
+ const strikedOut = await isStrikedOut("bead-danger", storage);
1548
+ expect(strikedOut).toBe(true);
1549
+ });
1550
+
1551
+ it("returns false for bead with no strikes", async () => {
1552
+ const strikedOut = await isStrikedOut("no-record", storage);
1553
+ expect(strikedOut).toBe(false);
1554
+ });
1555
+ });
1556
+
1557
+ describe("getArchitecturePrompt", () => {
1558
+ it("returns empty string for bead with < 3 strikes", async () => {
1559
+ await addStrike("bead-prompt-1", "Fix 1", "Failed 1", storage);
1560
+
1561
+ const prompt = await getArchitecturePrompt("bead-prompt-1", storage);
1562
+ expect(prompt).toBe("");
1563
+ });
1564
+
1565
+ it("returns empty string for bead with no strikes", async () => {
1566
+ const prompt = await getArchitecturePrompt("no-strikes", storage);
1567
+ expect(prompt).toBe("");
1568
+ });
1569
+
1570
+ it("generates architecture review prompt for struck out bead", async () => {
1571
+ await addStrike(
1572
+ "bead-prompt-2",
1573
+ "Added null checks",
1574
+ "Still crashes on undefined",
1575
+ storage,
1576
+ );
1577
+ await addStrike(
1578
+ "bead-prompt-2",
1579
+ "Used optional chaining",
1580
+ "Runtime error persists",
1581
+ storage,
1582
+ );
1583
+ await addStrike(
1584
+ "bead-prompt-2",
1585
+ "Wrapped in try-catch",
1586
+ "Error still happening",
1587
+ storage,
1588
+ );
1589
+
1590
+ const prompt = await getArchitecturePrompt("bead-prompt-2", storage);
1591
+
1592
+ expect(prompt).toContain("Architecture Review Required");
1593
+ expect(prompt).toContain("bead-prompt-2");
1594
+ expect(prompt).toContain("Added null checks");
1595
+ expect(prompt).toContain("Still crashes on undefined");
1596
+ expect(prompt).toContain("Used optional chaining");
1597
+ expect(prompt).toContain("Runtime error persists");
1598
+ expect(prompt).toContain("Wrapped in try-catch");
1599
+ expect(prompt).toContain("Error still happening");
1600
+ expect(prompt).toContain("architectural problem");
1601
+ expect(prompt).toContain("DO NOT attempt Fix #4");
1602
+ expect(prompt).toContain("Refactor architecture");
1603
+ expect(prompt).toContain("Continue with Fix #4");
1604
+ expect(prompt).toContain("Abandon this approach");
1605
+ });
1606
+
1607
+ it("lists all failures in order", async () => {
1608
+ await addStrike(
1609
+ "bead-prompt-3",
1610
+ "First attempt",
1611
+ "First failure",
1612
+ storage,
1613
+ );
1614
+ await addStrike(
1615
+ "bead-prompt-3",
1616
+ "Second attempt",
1617
+ "Second failure",
1618
+ storage,
1619
+ );
1620
+ await addStrike(
1621
+ "bead-prompt-3",
1622
+ "Third attempt",
1623
+ "Third failure",
1624
+ storage,
1625
+ );
1626
+
1627
+ const prompt = await getArchitecturePrompt("bead-prompt-3", storage);
1628
+
1629
+ const lines = prompt.split("\n");
1630
+ const failureLine1 = lines.find((l) => l.includes("First attempt"));
1631
+ const failureLine2 = lines.find((l) => l.includes("Second attempt"));
1632
+ const failureLine3 = lines.find((l) => l.includes("Third attempt"));
1633
+
1634
+ expect(failureLine1).toBeDefined();
1635
+ expect(failureLine2).toBeDefined();
1636
+ expect(failureLine3).toBeDefined();
1637
+
1638
+ // Check ordering
1639
+ const idx1 = lines.indexOf(failureLine1!);
1640
+ const idx2 = lines.indexOf(failureLine2!);
1641
+ const idx3 = lines.indexOf(failureLine3!);
1642
+
1643
+ expect(idx1).toBeLessThan(idx2);
1644
+ expect(idx2).toBeLessThan(idx3);
1645
+ });
1646
+ });
1647
+
1648
+ describe("clearStrikes", () => {
1649
+ it("clears strikes for a bead", async () => {
1650
+ await addStrike("bead-clear", "Fix 1", "Failed 1", storage);
1651
+ await addStrike("bead-clear", "Fix 2", "Failed 2", storage);
1652
+
1653
+ expect(await getStrikes("bead-clear", storage)).toBe(2);
1654
+
1655
+ await clearStrikes("bead-clear", storage);
1656
+
1657
+ expect(await getStrikes("bead-clear", storage)).toBe(0);
1658
+ expect(await isStrikedOut("bead-clear", storage)).toBe(false);
1659
+ });
1660
+
1661
+ it("handles clearing non-existent bead gracefully", async () => {
1662
+ await expect(clearStrikes("no-bead", storage)).resolves.toBeUndefined();
1663
+ });
1664
+ });
1665
+
1666
+ describe("InMemoryStrikeStorage", () => {
1667
+ it("stores and retrieves strike records", async () => {
1668
+ const storage = new InMemoryStrikeStorage();
1669
+ const record = await addStrike("bead-1", "Fix", "Failed", storage);
1670
+
1671
+ const retrieved = await storage.get("bead-1");
1672
+ expect(retrieved).not.toBeNull();
1673
+ expect(retrieved!.bead_id).toBe("bead-1");
1674
+ expect(retrieved!.strike_count).toBe(1);
1675
+ });
1676
+
1677
+ it("returns null for non-existent bead", async () => {
1678
+ const storage = new InMemoryStrikeStorage();
1679
+ const retrieved = await storage.get("non-existent");
1680
+ expect(retrieved).toBeNull();
1681
+ });
1682
+
1683
+ it("lists all strike records", async () => {
1684
+ const storage = new InMemoryStrikeStorage();
1685
+ await addStrike("bead-1", "Fix", "Failed", storage);
1686
+ await addStrike("bead-2", "Fix", "Failed", storage);
1687
+
1688
+ const all = await storage.getAll();
1689
+ expect(all).toHaveLength(2);
1690
+ });
1691
+
1692
+ it("clears specific bead strikes", async () => {
1693
+ const storage = new InMemoryStrikeStorage();
1694
+ await addStrike("bead-1", "Fix", "Failed", storage);
1695
+ await addStrike("bead-2", "Fix", "Failed", storage);
1696
+
1697
+ await storage.clear("bead-1");
1698
+
1699
+ expect(await storage.get("bead-1")).toBeNull();
1700
+ expect(await storage.get("bead-2")).not.toBeNull();
1701
+ });
1702
+ });
1703
+
1704
+ describe("3-Strike Rule Integration", () => {
1705
+ it("follows complete workflow from no strikes to architecture review", async () => {
1706
+ const beadId = "integration-bead";
1707
+
1708
+ // Start: No strikes
1709
+ expect(await getStrikes(beadId, storage)).toBe(0);
1710
+ expect(await isStrikedOut(beadId, storage)).toBe(false);
1711
+ expect(await getArchitecturePrompt(beadId, storage)).toBe("");
1712
+
1713
+ // Strike 1
1714
+ await addStrike(beadId, "Tried approach A", "Didn't work", storage);
1715
+ expect(await getStrikes(beadId, storage)).toBe(1);
1716
+ expect(await isStrikedOut(beadId, storage)).toBe(false);
1717
+
1718
+ // Strike 2
1719
+ await addStrike(beadId, "Tried approach B", "Also failed", storage);
1720
+ expect(await getStrikes(beadId, storage)).toBe(2);
1721
+ expect(await isStrikedOut(beadId, storage)).toBe(false);
1722
+
1723
+ // Strike 3 - STRUCK OUT
1724
+ await addStrike(beadId, "Tried approach C", "Still broken", storage);
1725
+ expect(await getStrikes(beadId, storage)).toBe(3);
1726
+ expect(await isStrikedOut(beadId, storage)).toBe(true);
1727
+
1728
+ // Architecture prompt should now be available
1729
+ const prompt = await getArchitecturePrompt(beadId, storage);
1730
+ expect(prompt).not.toBe("");
1731
+ expect(prompt).toContain("Architecture Review Required");
1732
+
1733
+ // Clear strikes (e.g., after human intervention)
1734
+ await clearStrikes(beadId, storage);
1735
+ expect(await getStrikes(beadId, storage)).toBe(0);
1736
+ expect(await isStrikedOut(beadId, storage)).toBe(false);
1737
+ });
1738
+ });
1739
+ });