opencode-swarm-plugin 0.42.4 → 0.42.6

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/dist/plugin.js CHANGED
@@ -27652,6 +27652,178 @@ echo "Project directory: $1"
27652
27652
  };
27653
27653
  });
27654
27654
 
27655
+ // src/swarm-insights.ts
27656
+ var exports_swarm_insights = {};
27657
+ __export(exports_swarm_insights, {
27658
+ getStrategyInsights: () => getStrategyInsights,
27659
+ getPatternInsights: () => getPatternInsights,
27660
+ getFileInsights: () => getFileInsights,
27661
+ getCachedInsights: () => getCachedInsights,
27662
+ formatInsightsForPrompt: () => formatInsightsForPrompt,
27663
+ clearInsightsCache: () => clearInsightsCache
27664
+ });
27665
+ async function getStrategyInsights(swarmMail, _task) {
27666
+ const db = await swarmMail.getDatabase();
27667
+ const query = `
27668
+ SELECT
27669
+ json_extract(data, '$.strategy') as strategy,
27670
+ COUNT(*) as total_attempts,
27671
+ SUM(CASE WHEN json_extract(data, '$.success') = 'true' THEN 1 ELSE 0 END) as successes
27672
+ FROM events
27673
+ WHERE type = 'subtask_outcome'
27674
+ AND json_extract(data, '$.strategy') IS NOT NULL
27675
+ GROUP BY json_extract(data, '$.strategy')
27676
+ ORDER BY total_attempts DESC
27677
+ `;
27678
+ const result = await db.query(query, []);
27679
+ const rows = result.rows;
27680
+ return rows.map((row) => {
27681
+ const successRate = row.successes / row.total_attempts * 100;
27682
+ return {
27683
+ strategy: row.strategy,
27684
+ successRate: Math.round(successRate * 100) / 100,
27685
+ totalAttempts: row.total_attempts,
27686
+ recommendation: getStrategyRecommendation(row.strategy, successRate)
27687
+ };
27688
+ });
27689
+ }
27690
+ function getStrategyRecommendation(strategy, successRate) {
27691
+ if (successRate >= 80) {
27692
+ return `${strategy} is performing well (${successRate.toFixed(0)}% success)`;
27693
+ }
27694
+ if (successRate >= 60) {
27695
+ return `${strategy} is moderate - monitor for issues`;
27696
+ }
27697
+ if (successRate >= 40) {
27698
+ return `${strategy} has low success - consider alternatives`;
27699
+ }
27700
+ return `AVOID ${strategy} - high failure rate (${successRate.toFixed(0)}%)`;
27701
+ }
27702
+ async function getFileInsights(swarmMail, files) {
27703
+ if (files.length === 0)
27704
+ return [];
27705
+ const db = await swarmMail.getDatabase();
27706
+ const insights = [];
27707
+ for (const file2 of files) {
27708
+ const query = `
27709
+ SELECT
27710
+ COUNT(*) as failure_count,
27711
+ MAX(timestamp) as last_failure
27712
+ FROM events
27713
+ WHERE type = 'subtask_outcome'
27714
+ AND json_extract(data, '$.success') = 'false'
27715
+ AND json_extract(data, '$.files_touched') LIKE ?
27716
+ `;
27717
+ const result = await db.query(query, [`%${file2}%`]);
27718
+ const row = result.rows[0];
27719
+ if (row && row.failure_count > 0) {
27720
+ const gotchas = await getFileGotchas(swarmMail, file2);
27721
+ insights.push({
27722
+ file: file2,
27723
+ failureCount: row.failure_count,
27724
+ lastFailure: row.last_failure,
27725
+ gotchas
27726
+ });
27727
+ }
27728
+ }
27729
+ return insights;
27730
+ }
27731
+ async function getFileGotchas(_swarmMail, _file2) {
27732
+ return [];
27733
+ }
27734
+ async function getPatternInsights(swarmMail) {
27735
+ const db = await swarmMail.getDatabase();
27736
+ const patterns = [];
27737
+ const query = `
27738
+ SELECT
27739
+ json_extract(data, '$.error_type') as error_type,
27740
+ COUNT(*) as frequency
27741
+ FROM events
27742
+ WHERE type = 'subtask_outcome'
27743
+ AND json_extract(data, '$.success') = 'false'
27744
+ AND json_extract(data, '$.error_type') IS NOT NULL
27745
+ GROUP BY json_extract(data, '$.error_type')
27746
+ HAVING COUNT(*) >= 2
27747
+ ORDER BY frequency DESC
27748
+ LIMIT 5
27749
+ `;
27750
+ const result = await db.query(query, []);
27751
+ const rows = result.rows;
27752
+ for (const row of rows) {
27753
+ patterns.push({
27754
+ pattern: row.error_type,
27755
+ frequency: row.frequency,
27756
+ recommendation: getPatternRecommendation(row.error_type)
27757
+ });
27758
+ }
27759
+ return patterns;
27760
+ }
27761
+ function getPatternRecommendation(errorType) {
27762
+ const recommendations = {
27763
+ type_error: "Add explicit type annotations and null checks",
27764
+ timeout: "Consider breaking into smaller tasks",
27765
+ conflict: "Check file reservations before editing",
27766
+ test_failure: "Run tests incrementally during implementation"
27767
+ };
27768
+ return recommendations[errorType] || `Address ${errorType} issues`;
27769
+ }
27770
+ function formatInsightsForPrompt(bundle, options2 = {}) {
27771
+ const { maxTokens = 500 } = options2;
27772
+ const sections = [];
27773
+ if (bundle.strategies && bundle.strategies.length > 0) {
27774
+ const strategyLines = bundle.strategies.slice(0, 3).map((s) => `- ${s.strategy}: ${s.successRate.toFixed(0)}% success (${s.totalAttempts} attempts)`);
27775
+ sections.push(`**Strategy Performance:**
27776
+ ${strategyLines.join(`
27777
+ `)}`);
27778
+ }
27779
+ if (bundle.files && bundle.files.length > 0) {
27780
+ const fileLines = bundle.files.slice(0, 5).map((f) => {
27781
+ const gotchaStr = f.gotchas.length > 0 ? ` - ${f.gotchas[0]}` : "";
27782
+ return `- ${f.file}: ${f.failureCount} past failures${gotchaStr}`;
27783
+ });
27784
+ sections.push(`**File-Specific Gotchas:**
27785
+ ${fileLines.join(`
27786
+ `)}`);
27787
+ }
27788
+ if (bundle.patterns && bundle.patterns.length > 0) {
27789
+ const patternLines = bundle.patterns.slice(0, 3).map((p) => `- ${p.pattern} (${p.frequency}x): ${p.recommendation}`);
27790
+ sections.push(`**Common Pitfalls:**
27791
+ ${patternLines.join(`
27792
+ `)}`);
27793
+ }
27794
+ if (sections.length === 0) {
27795
+ return "";
27796
+ }
27797
+ let result = sections.join(`
27798
+
27799
+ `);
27800
+ const maxChars = maxTokens * 4;
27801
+ if (result.length > maxChars) {
27802
+ result = result.slice(0, maxChars - 3) + "...";
27803
+ }
27804
+ return result;
27805
+ }
27806
+ async function getCachedInsights(_swarmMail, cacheKey, computeFn) {
27807
+ const cached5 = insightsCache.get(cacheKey);
27808
+ if (cached5 && cached5.expires > Date.now()) {
27809
+ return cached5.data;
27810
+ }
27811
+ const data = await computeFn();
27812
+ insightsCache.set(cacheKey, {
27813
+ data,
27814
+ expires: Date.now() + CACHE_TTL_MS
27815
+ });
27816
+ return data;
27817
+ }
27818
+ function clearInsightsCache() {
27819
+ insightsCache.clear();
27820
+ }
27821
+ var insightsCache, CACHE_TTL_MS;
27822
+ var init_swarm_insights = __esm(() => {
27823
+ insightsCache = new Map;
27824
+ CACHE_TTL_MS = 5 * 60 * 1000;
27825
+ });
27826
+
27655
27827
  // src/model-selection.ts
27656
27828
  var exports_model_selection = {};
27657
27829
  __export(exports_model_selection, {
@@ -91404,6 +91576,7 @@ var CellQueryArgsSchema = exports_external.object({
91404
91576
  status: CellStatusSchema.optional(),
91405
91577
  type: CellTypeSchema.optional(),
91406
91578
  ready: exports_external.boolean().optional(),
91579
+ parent_id: exports_external.string().optional(),
91407
91580
  limit: exports_external.number().int().positive().default(20)
91408
91581
  });
91409
91582
  var SubtaskSpecSchema = exports_external.object({
@@ -92205,6 +92378,7 @@ var hive_query = tool({
92205
92378
  status: tool.schema.enum(["open", "in_progress", "blocked", "closed"]).optional().describe("Filter by status"),
92206
92379
  type: tool.schema.enum(["bug", "feature", "task", "epic", "chore"]).optional().describe("Filter by type"),
92207
92380
  ready: tool.schema.boolean().optional().describe("Only show unblocked cells"),
92381
+ parent_id: tool.schema.string().optional().describe("Filter by parent epic ID (returns children of an epic)"),
92208
92382
  limit: tool.schema.number().optional().describe("Max results to return (default: 20)")
92209
92383
  },
92210
92384
  async execute(args, ctx) {
@@ -92220,6 +92394,7 @@ var hive_query = tool({
92220
92394
  cells = await adapter.queryCells(projectKey, {
92221
92395
  status: validated.status,
92222
92396
  type: validated.type,
92397
+ parent_id: validated.parent_id,
92223
92398
  limit: validated.limit || 20
92224
92399
  });
92225
92400
  }
@@ -92356,6 +92531,7 @@ USE THIS TOOL TO:
92356
92531
  - Find cells by type: hive_cells({ type: "bug" })
92357
92532
  - Get a specific cell by partial ID: hive_cells({ id: "mjkmd" })
92358
92533
  - Get the next ready (unblocked) cell: hive_cells({ ready: true })
92534
+ - Get children of an epic: hive_cells({ parent_id: "epic-id" })
92359
92535
  - Combine filters: hive_cells({ status: "open", type: "task" })
92360
92536
 
92361
92537
  RETURNS: Array of cells with id, title, status, priority, type, parent_id, created_at, updated_at
@@ -92369,6 +92545,7 @@ PREFER THIS OVER hive_query when you need to:
92369
92545
  id: tool.schema.string().optional().describe("Partial or full cell ID to look up"),
92370
92546
  status: tool.schema.enum(["open", "in_progress", "blocked", "closed"]).optional().describe("Filter by status"),
92371
92547
  type: tool.schema.enum(["task", "bug", "feature", "epic", "chore"]).optional().describe("Filter by type"),
92548
+ parent_id: tool.schema.string().optional().describe("Filter by parent epic ID (returns children of an epic)"),
92372
92549
  ready: tool.schema.boolean().optional().describe("If true, return only the next unblocked cell"),
92373
92550
  limit: tool.schema.number().optional().describe("Max cells to return (default 20)")
92374
92551
  },
@@ -92396,6 +92573,7 @@ PREFER THIS OVER hive_query when you need to:
92396
92573
  const cells = await adapter.queryCells(projectKey, {
92397
92574
  status: args.status,
92398
92575
  type: args.type,
92576
+ parent_id: args.parent_id,
92399
92577
  limit: args.limit || 20
92400
92578
  });
92401
92579
  const formatted = cells.map((c) => formatCellForOutput(c));
@@ -113687,38 +113865,28 @@ async function getPromptInsights(options2) {
113687
113865
  }
113688
113866
  async function getCoordinatorInsights(project_key) {
113689
113867
  try {
113690
- const { createLibSQLAdapter, createSwarmMailAdapter: createSwarmMailAdapter2, strategySuccessRates } = await import("swarm-mail");
113868
+ const { createLibSQLAdapter, createSwarmMailAdapter: createSwarmMailAdapter2 } = await import("swarm-mail");
113869
+ const { getStrategyInsights: getStrategyInsights2, getPatternInsights: getPatternInsights2, formatInsightsForPrompt: formatInsightsForPrompt2 } = await Promise.resolve().then(() => (init_swarm_insights(), exports_swarm_insights));
113691
113870
  const dbAdapter = await createLibSQLAdapter({ url: "file:./.swarm-mail/streams.db" });
113692
113871
  const adapter = createSwarmMailAdapter2(dbAdapter, project_key || "default");
113693
- const db = await adapter.getDatabase();
113694
- const query = strategySuccessRates({ project_key });
113695
- const result = await db.query(query.sql, Object.values(query.parameters || {}));
113696
- if (!result || !result.rows || result.rows.length === 0) {
113872
+ const [strategies, patterns] = await Promise.all([
113873
+ getStrategyInsights2(adapter, ""),
113874
+ getPatternInsights2(adapter)
113875
+ ]);
113876
+ const bundle = {
113877
+ strategies,
113878
+ patterns
113879
+ };
113880
+ const formatted = formatInsightsForPrompt2(bundle, { maxTokens: 500 });
113881
+ if (!formatted) {
113697
113882
  return "";
113698
113883
  }
113699
- const rows = result.rows.map((r) => {
113700
- const strategy = r.strategy || "unknown";
113701
- const total = r.total_attempts || 0;
113702
- const successRate = r.success_rate || 0;
113703
- const emoji3 = successRate >= 80 ? "✅" : successRate >= 60 ? "⚠️" : "❌";
113704
- return `| ${emoji3} ${strategy} | ${successRate.toFixed(1)}% | ${total} |`;
113705
- });
113706
- const topRows = rows.slice(0, 5);
113707
- const antiPatterns = result.rows.filter((r) => r.success_rate < 60).map((r) => `- AVOID: ${r.strategy} strategy (${r.success_rate.toFixed(1)}% success rate)`).slice(0, 3);
113708
- const antiPatternsSection = antiPatterns.length > 0 ? `
113709
-
113710
- **Anti-Patterns:**
113711
- ${antiPatterns.join(`
113712
- `)}` : "";
113713
113884
  return `
113714
- ## \uD83D\uDCCA Swarm Insights (Strategy Success Rates)
113885
+ ## \uD83D\uDCCA Historical Insights
113715
113886
 
113716
- | Strategy | Success Rate | Total Attempts |
113717
- |----------|--------------|----------------|
113718
- ${topRows.join(`
113719
- `)}
113887
+ ${formatted}
113720
113888
 
113721
- **Use these insights to select decomposition strategies.**${antiPatternsSection}
113889
+ **Use these learnings when selecting decomposition strategies and planning subtasks.**
113722
113890
  `;
113723
113891
  } catch (e) {
113724
113892
  console.warn("Failed to get coordinator insights:", e);
@@ -113727,7 +113895,9 @@ ${topRows.join(`
113727
113895
  }
113728
113896
  async function getWorkerInsights(files, domain2) {
113729
113897
  try {
113730
- const adapter = await getMemoryAdapter();
113898
+ const { createLibSQLAdapter, createSwarmMailAdapter: createSwarmMailAdapter2 } = await import("swarm-mail");
113899
+ const { getFileInsights: getFileInsights2, formatInsightsForPrompt: formatInsightsForPrompt2 } = await Promise.resolve().then(() => (init_swarm_insights(), exports_swarm_insights));
113900
+ const memoryAdapter = await getMemoryAdapter();
113731
113901
  let query = "";
113732
113902
  if (files && files.length > 0) {
113733
113903
  const keywords = files.flatMap((f) => f.split(/[\/\\.]/).filter((part) => part.length > 2)).slice(0, 5);
@@ -113737,25 +113907,48 @@ async function getWorkerInsights(files, domain2) {
113737
113907
  } else {
113738
113908
  return "";
113739
113909
  }
113740
- const result = await adapter.find({
113741
- query: `${query} gotcha pitfall pattern bug`,
113742
- limit: 3
113743
- });
113744
- if (result.count === 0) {
113745
- return "";
113746
- }
113747
- const learnings = result.results.map((r) => {
113748
- const content = r.content.length > 150 ? r.content.slice(0, 150) + "..." : r.content;
113749
- return `- ${content}`;
113750
- });
113751
- return `
113752
- ## \uD83D\uDCA1 Relevant Learnings (from past agents)
113910
+ const [fileInsights, memoryResult] = await Promise.all([
113911
+ (async () => {
113912
+ if (!files || files.length === 0)
113913
+ return [];
113914
+ try {
113915
+ const dbAdapter = await createLibSQLAdapter({ url: "file:./.swarm-mail/streams.db" });
113916
+ const swarmMail = createSwarmMailAdapter2(dbAdapter, "default");
113917
+ return await getFileInsights2(swarmMail, files);
113918
+ } catch (e) {
113919
+ console.warn("Failed to get file insights from event store:", e);
113920
+ return [];
113921
+ }
113922
+ })(),
113923
+ memoryAdapter.find({
113924
+ query: `${query} gotcha pitfall pattern bug`,
113925
+ limit: 3
113926
+ })
113927
+ ]);
113928
+ const bundle = {
113929
+ files: fileInsights
113930
+ };
113931
+ const formattedFileInsights = formatInsightsForPrompt2(bundle, { maxTokens: 300 });
113932
+ let formattedMemory = "";
113933
+ if (memoryResult.count > 0) {
113934
+ const learnings = memoryResult.results.map((r) => {
113935
+ const content = r.content.length > 150 ? r.content.slice(0, 150) + "..." : r.content;
113936
+ return `- ${content}`;
113937
+ });
113938
+ formattedMemory = `## \uD83D\uDCA1 Relevant Learnings (from past agents)
113753
113939
 
113754
113940
  ${learnings.join(`
113755
113941
  `)}
113756
113942
 
113757
- **Check semantic-memory for full details if needed.**
113758
- `;
113943
+ **Check semantic-memory for full details if needed.**`;
113944
+ }
113945
+ const sections = [formattedFileInsights, formattedMemory].filter((s) => s.length > 0);
113946
+ if (sections.length === 0) {
113947
+ return "";
113948
+ }
113949
+ return sections.join(`
113950
+
113951
+ `);
113759
113952
  } catch (e) {
113760
113953
  console.warn("Failed to get worker insights:", e);
113761
113954
  return "";
@@ -120450,7 +120643,8 @@ var allTools = {
120450
120643
  ...repoCrawlTools,
120451
120644
  ...skillsTools,
120452
120645
  ...mandateTools,
120453
- ...memoryTools
120646
+ ...memoryTools,
120647
+ ...observabilityTools
120454
120648
  };
120455
120649
 
120456
120650
  // src/plugin.ts
@@ -130,6 +130,7 @@ export declare const CellQueryArgsSchema: z.ZodObject<{
130
130
  chore: "chore";
131
131
  }>>;
132
132
  ready: z.ZodOptional<z.ZodBoolean>;
133
+ parent_id: z.ZodOptional<z.ZodString>;
133
134
  limit: z.ZodDefault<z.ZodNumber>;
134
135
  }, z.core.$strip>;
135
136
  export type CellQueryArgs = z.infer<typeof CellQueryArgsSchema>;
@@ -376,6 +377,7 @@ export declare const BeadQueryArgsSchema: z.ZodObject<{
376
377
  chore: "chore";
377
378
  }>>;
378
379
  ready: z.ZodOptional<z.ZodBoolean>;
380
+ parent_id: z.ZodOptional<z.ZodString>;
379
381
  limit: z.ZodDefault<z.ZodNumber>;
380
382
  }, z.core.$strip>;
381
383
  /** @deprecated Use CellQueryArgs instead */
@@ -1 +1 @@
1
- {"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../../src/schemas/cell.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0BAA0B;AAC1B,eAAO,MAAM,gBAAg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concise, context-efficient summaries for coordinators and workers.
6
+ *
7
+ * Data sources:
8
+ * - Event store (subtask_outcome, eval_finalized)
9
+ * - Semantic memory (file-specific learnings)
10
+ * - Anti-pattern registry
11
+ */
12
+ import type { SwarmMailAdapter } from "swarm-mail";
13
+ export interface StrategyInsight {
14
+ strategy: string;
15
+ successRate: number;
16
+ totalAttempts: number;
17
+ recommendation: string;
18
+ }
19
+ export interface FileInsight {
20
+ file: string;
21
+ failureCount: number;
22
+ lastFailure: string | null;
23
+ gotchas: string[];
24
+ }
25
+ export interface PatternInsight {
26
+ pattern: string;
27
+ frequency: number;
28
+ recommendation: string;
29
+ }
30
+ export interface InsightsBundle {
31
+ strategies?: StrategyInsight[];
32
+ files?: FileInsight[];
33
+ patterns?: PatternInsight[];
34
+ }
35
+ export interface FormatOptions {
36
+ maxTokens?: number;
37
+ }
38
+ /**
39
+ * Get strategy success rates and recommendations for a task.
40
+ *
41
+ * Queries the event store for subtask_outcome events and calculates
42
+ * success rates by strategy. Returns recommendations based on historical data.
43
+ */
44
+ export declare function getStrategyInsights(swarmMail: SwarmMailAdapter, _task: string): Promise<StrategyInsight[]>;
45
+ /**
46
+ * Get insights for specific files based on historical outcomes.
47
+ *
48
+ * Queries the event store for failures involving these files and
49
+ * semantic memory for file-specific gotchas.
50
+ */
51
+ export declare function getFileInsights(swarmMail: SwarmMailAdapter, files: string[]): Promise<FileInsight[]>;
52
+ /**
53
+ * Get common failure patterns and anti-patterns.
54
+ *
55
+ * Analyzes event store for recurring failure patterns and
56
+ * queries the anti-pattern registry.
57
+ */
58
+ export declare function getPatternInsights(swarmMail: SwarmMailAdapter): Promise<PatternInsight[]>;
59
+ /**
60
+ * Format insights bundle for prompt injection.
61
+ *
62
+ * Produces a concise, context-efficient summary suitable for
63
+ * inclusion in coordinator or worker prompts.
64
+ *
65
+ * @param bundle - Insights to format
66
+ * @param options - Formatting options (maxTokens)
67
+ * @returns Formatted string for prompt injection
68
+ */
69
+ export declare function formatInsightsForPrompt(bundle: InsightsBundle, options?: FormatOptions): string;
70
+ /**
71
+ * Get cached insights or compute fresh ones.
72
+ */
73
+ export declare function getCachedInsights(_swarmMail: SwarmMailAdapter, cacheKey: string, computeFn: () => Promise<InsightsBundle>): Promise<InsightsBundle>;
74
+ /**
75
+ * Clear the insights cache.
76
+ */
77
+ export declare function clearInsightsCache(): void;
78
+ //# sourceMappingURL=swarm-insights.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swarm-insights.d.ts","sourceRoot":"","sources":["../src/swarm-insights.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMnD,MAAM,WAAW,eAAe;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC9B,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACxC,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,EAAE,CAAC,CA+B5B;A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;;;;;;;;;;;;;;;;CAkH9B,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;CAsDjC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;CA+I5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;CAoClC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;CAsI5B,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOvB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm-plugin",
3
- "version": "0.42.4",
3
+ "version": "0.42.6",
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",
@@ -47,7 +47,7 @@
47
47
  "minimatch": "^10.1.1",
48
48
  "pino": "^9.6.0",
49
49
  "pino-roll": "^1.3.0",
50
- "swarm-mail": "1.5.4",
50
+ "swarm-mail": "1.5.5",
51
51
  "yaml": "^2.8.2",
52
52
  "zod": "4.1.8"
53
53
  },
@@ -17,6 +17,7 @@ import {
17
17
  hive_close,
18
18
  hive_start,
19
19
  hive_ready,
20
+ hive_cells,
20
21
  hive_link_thread,
21
22
  hive_sync,
22
23
  HiveError,
@@ -2133,4 +2134,108 @@ describe("beads integration", () => {
2133
2134
  }
2134
2135
  });
2135
2136
  });
2137
+
2138
+ describe("parent_id filter", () => {
2139
+ it("hive_query filters by parent_id to get epic children", async () => {
2140
+ const { rmSync } = await import("node:fs");
2141
+ const tempProject = join(tmpdir(), `hive-parent-filter-${Date.now()}`);
2142
+ const originalDir = getHiveWorkingDirectory();
2143
+ setHiveWorkingDirectory(tempProject);
2144
+
2145
+ try {
2146
+ // Create an epic
2147
+ const epicResponse = await hive_create.execute(
2148
+ { title: "Epic Task", type: "epic", priority: 1 },
2149
+ mockContext
2150
+ );
2151
+ const epic = parseResponse<Cell>(epicResponse);
2152
+
2153
+ // Create children of the epic
2154
+ const child1Response = await hive_create.execute(
2155
+ { title: "Subtask 1", type: "task", parent_id: epic.id },
2156
+ mockContext
2157
+ );
2158
+ const child1 = parseResponse<Cell>(child1Response);
2159
+
2160
+ const child2Response = await hive_create.execute(
2161
+ { title: "Subtask 2", type: "task", parent_id: epic.id },
2162
+ mockContext
2163
+ );
2164
+ const child2 = parseResponse<Cell>(child2Response);
2165
+
2166
+ // Create unrelated cell
2167
+ await hive_create.execute(
2168
+ { title: "Unrelated Task", type: "task" },
2169
+ mockContext
2170
+ );
2171
+
2172
+ // Query by parent_id
2173
+ const queryResponse = await hive_query.execute(
2174
+ { parent_id: epic.id },
2175
+ mockContext
2176
+ );
2177
+ const children = parseResponse<Cell[]>(queryResponse);
2178
+
2179
+ // Should only return the 2 children
2180
+ expect(children).toHaveLength(2);
2181
+ expect(children.map(c => c.id)).toContain(child1.id);
2182
+ expect(children.map(c => c.id)).toContain(child2.id);
2183
+ expect(children.every(c => c.parent_id === epic.id)).toBe(true);
2184
+ } finally {
2185
+ setHiveWorkingDirectory(originalDir);
2186
+ rmSync(tempProject, { recursive: true, force: true });
2187
+ }
2188
+ });
2189
+
2190
+ it("hive_cells filters by parent_id to get epic children", async () => {
2191
+ const { rmSync } = await import("node:fs");
2192
+ const tempProject = join(tmpdir(), `hive-cells-parent-filter-${Date.now()}`);
2193
+ const originalDir = getHiveWorkingDirectory();
2194
+ setHiveWorkingDirectory(tempProject);
2195
+
2196
+ try {
2197
+ // Create an epic
2198
+ const epicResponse = await hive_create.execute(
2199
+ { title: "Epic with Children", type: "epic", priority: 1 },
2200
+ mockContext
2201
+ );
2202
+ const epic = parseResponse<Cell>(epicResponse);
2203
+
2204
+ // Create children
2205
+ const child1Response = await hive_create.execute(
2206
+ { title: "Child A", type: "task", parent_id: epic.id },
2207
+ mockContext
2208
+ );
2209
+ const child1 = parseResponse<Cell>(child1Response);
2210
+
2211
+ const child2Response = await hive_create.execute(
2212
+ { title: "Child B", type: "bug", parent_id: epic.id },
2213
+ mockContext
2214
+ );
2215
+ const child2 = parseResponse<Cell>(child2Response);
2216
+
2217
+ // Create unrelated cells
2218
+ await hive_create.execute(
2219
+ { title: "Orphan Task", type: "task" },
2220
+ mockContext
2221
+ );
2222
+
2223
+ // Query using hive_cells with parent_id
2224
+ const cellsResponse = await hive_cells.execute(
2225
+ { parent_id: epic.id },
2226
+ mockContext
2227
+ );
2228
+ const cells = parseResponse<Cell[]>(cellsResponse);
2229
+
2230
+ // Should only return the 2 children
2231
+ expect(cells).toHaveLength(2);
2232
+ expect(cells.map(c => c.id)).toContain(child1.id);
2233
+ expect(cells.map(c => c.id)).toContain(child2.id);
2234
+ expect(cells.every(c => c.parent_id === epic.id)).toBe(true);
2235
+ } finally {
2236
+ setHiveWorkingDirectory(originalDir);
2237
+ rmSync(tempProject, { recursive: true, force: true });
2238
+ }
2239
+ });
2240
+ });
2136
2241
  });
package/src/hive.ts CHANGED
@@ -873,6 +873,10 @@ export const hive_query = tool({
873
873
  .boolean()
874
874
  .optional()
875
875
  .describe("Only show unblocked cells"),
876
+ parent_id: tool.schema
877
+ .string()
878
+ .optional()
879
+ .describe("Filter by parent epic ID (returns children of an epic)"),
876
880
  limit: tool.schema
877
881
  .number()
878
882
  .optional()
@@ -893,6 +897,7 @@ export const hive_query = tool({
893
897
  cells = await adapter.queryCells(projectKey, {
894
898
  status: validated.status,
895
899
  type: validated.type,
900
+ parent_id: validated.parent_id,
896
901
  limit: validated.limit || 20,
897
902
  });
898
903
  }
@@ -1139,6 +1144,7 @@ USE THIS TOOL TO:
1139
1144
  - Find cells by type: hive_cells({ type: "bug" })
1140
1145
  - Get a specific cell by partial ID: hive_cells({ id: "mjkmd" })
1141
1146
  - Get the next ready (unblocked) cell: hive_cells({ ready: true })
1147
+ - Get children of an epic: hive_cells({ parent_id: "epic-id" })
1142
1148
  - Combine filters: hive_cells({ status: "open", type: "task" })
1143
1149
 
1144
1150
  RETURNS: Array of cells with id, title, status, priority, type, parent_id, created_at, updated_at
@@ -1152,6 +1158,7 @@ PREFER THIS OVER hive_query when you need to:
1152
1158
  id: tool.schema.string().optional().describe("Partial or full cell ID to look up"),
1153
1159
  status: tool.schema.enum(["open", "in_progress", "blocked", "closed"]).optional().describe("Filter by status"),
1154
1160
  type: tool.schema.enum(["task", "bug", "feature", "epic", "chore"]).optional().describe("Filter by type"),
1161
+ parent_id: tool.schema.string().optional().describe("Filter by parent epic ID (returns children of an epic)"),
1155
1162
  ready: tool.schema.boolean().optional().describe("If true, return only the next unblocked cell"),
1156
1163
  limit: tool.schema.number().optional().describe("Max cells to return (default 20)"),
1157
1164
  },
@@ -1185,6 +1192,7 @@ PREFER THIS OVER hive_query when you need to:
1185
1192
  const cells = await adapter.queryCells(projectKey, {
1186
1193
  status: args.status,
1187
1194
  type: args.type,
1195
+ parent_id: args.parent_id,
1188
1196
  limit: args.limit || 20,
1189
1197
  });
1190
1198