opencode-swarm-plugin 0.42.5 → 0.42.7
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/.changeset/swarm-insights-data-layer.md +63 -0
- package/.hive/issues.jsonl +19 -1
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +54 -0
- package/README.md +147 -0
- package/bin/swarm.ts +4 -4
- package/dist/hive.d.ts +12 -0
- package/dist/hive.d.ts.map +1 -1
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +236 -42
- package/dist/plugin.js +236 -42
- package/dist/schemas/cell.d.ts +2 -0
- package/dist/schemas/cell.d.ts.map +1 -1
- package/dist/swarm-insights.d.ts +155 -0
- package/dist/swarm-insights.d.ts.map +1 -0
- package/dist/swarm-prompts.d.ts.map +1 -1
- package/examples/plugin-wrapper-template.ts +30 -0
- package/package.json +2 -2
- package/src/hive.integration.test.ts +105 -0
- package/src/hive.ts +8 -0
- package/src/index.ts +1 -0
- package/src/schemas/cell.ts +1 -0
- package/src/swarm-insights.test.ts +214 -0
- package/src/swarm-insights.ts +459 -0
- package/src/swarm-prompts.test.ts +165 -0
- package/src/swarm-prompts.ts +74 -56
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
|
|
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
|
|
113694
|
-
|
|
113695
|
-
|
|
113696
|
-
|
|
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
|
|
113885
|
+
## \uD83D\uDCCA Historical Insights
|
|
113715
113886
|
|
|
113716
|
-
|
|
113717
|
-
|----------|--------------|----------------|
|
|
113718
|
-
${topRows.join(`
|
|
113719
|
-
`)}
|
|
113887
|
+
${formatted}
|
|
113720
113888
|
|
|
113721
|
-
**Use these
|
|
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
|
|
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
|
|
113741
|
-
|
|
113742
|
-
|
|
113743
|
-
|
|
113744
|
-
|
|
113745
|
-
|
|
113746
|
-
|
|
113747
|
-
|
|
113748
|
-
|
|
113749
|
-
|
|
113750
|
-
|
|
113751
|
-
|
|
113752
|
-
|
|
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
|
package/dist/schemas/cell.d.ts
CHANGED
|
@@ -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,gBAAgB;;;;;EAK3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,uBAAuB;AACvB,eAAO,MAAM,cAAc;;;;;;EAMzB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,4CAA4C;AAC5C,eAAO,MAAM,oBAAoB;;;;;;;;iBAG/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCrB,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,oCAAoC;AACpC,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;iBAY/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,oCAAoC;AACpC,eAAO,M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AC7C,uCAAuC;AACvC,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAEhC,mDAAmD;AACnD,eAAO,MAAM,oBAAoB;;;;;;;;iBAAuB,CAAC;AACzD,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC;AAE5C,yCAAyC;AACzC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAa,CAAC;AACrC,mCAAmC;AACnC,MAAM,MAAM,IAAI,GAAG,IAAI,CAAC;AAExB,mDAAmD;AACnD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;iBAAuB,CAAC;AACzD,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC;AAE5C,mDAAmD;AACnD,eAAO,MAAM,oBAAoB;;;;;;;;;;iBAAuB,CAAC;AACzD,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC;AAE5C,kDAAkD;AAClD,eAAO,MAAM,mBAAmB;;;iBAAsB,CAAC;AACvD,4CAA4C;AAC5C,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC;AAE1C,kDAAkD;AAClD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;iBAAsB,CAAC;AACvD,4CAA4C;AAC5C,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC;AAE1C,6CAA6C;AAC7C,eAAO,MAAM,cAAc;;;;;;;;;;;;iBAAiB,CAAC;AAC7C,uCAAuC;AACvC,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Insights Data Layer
|
|
3
|
+
*
|
|
4
|
+
* Aggregates insights from swarm coordination for prompt injection.
|
|
5
|
+
* Provides 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
|
+
* @param swarmMail - SwarmMail adapter for database access
|
|
45
|
+
* @param _task - Task description (currently unused, reserved for future filtering)
|
|
46
|
+
* @returns Promise resolving to array of strategy insights with success rates and recommendations
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const insights = await getStrategyInsights(swarmMail, "Add authentication");
|
|
51
|
+
* // Returns: [
|
|
52
|
+
* // { strategy: "file-based", successRate: 85.5, totalAttempts: 12, recommendation: "..." },
|
|
53
|
+
* // { strategy: "feature-based", successRate: 65.0, totalAttempts: 8, recommendation: "..." }
|
|
54
|
+
* // ]
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function getStrategyInsights(swarmMail: SwarmMailAdapter, _task: string): Promise<StrategyInsight[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Get insights for specific files based on historical outcomes.
|
|
60
|
+
*
|
|
61
|
+
* Queries the event store for failures involving these files and
|
|
62
|
+
* semantic memory for file-specific gotchas.
|
|
63
|
+
*
|
|
64
|
+
* @param swarmMail - SwarmMail adapter for database access
|
|
65
|
+
* @param files - Array of file paths to analyze
|
|
66
|
+
* @returns Promise resolving to array of file-specific insights including failure counts and gotchas
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const insights = await getFileInsights(swarmMail, ["src/auth.ts", "src/db.ts"]);
|
|
71
|
+
* // Returns: [
|
|
72
|
+
* // { file: "src/auth.ts", failureCount: 3, lastFailure: "2025-12-20T10:30:00Z", gotchas: [...] }
|
|
73
|
+
* // ]
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function getFileInsights(swarmMail: SwarmMailAdapter, files: string[]): Promise<FileInsight[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Get common failure patterns and anti-patterns.
|
|
79
|
+
*
|
|
80
|
+
* Analyzes event store for recurring failure patterns and
|
|
81
|
+
* queries the anti-pattern registry.
|
|
82
|
+
*
|
|
83
|
+
* @param swarmMail - SwarmMail adapter for database access
|
|
84
|
+
* @returns Promise resolving to array of pattern insights with frequency and recommendations
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const patterns = await getPatternInsights(swarmMail);
|
|
89
|
+
* // Returns: [
|
|
90
|
+
* // { pattern: "type_error", frequency: 5, recommendation: "Add explicit type annotations and null checks" },
|
|
91
|
+
* // { pattern: "timeout", frequency: 3, recommendation: "Consider breaking into smaller tasks" }
|
|
92
|
+
* // ]
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function getPatternInsights(swarmMail: SwarmMailAdapter): Promise<PatternInsight[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Format insights bundle for prompt injection.
|
|
98
|
+
*
|
|
99
|
+
* Produces a concise, context-efficient summary suitable for
|
|
100
|
+
* inclusion in coordinator or worker prompts.
|
|
101
|
+
*
|
|
102
|
+
* @param bundle - Insights bundle containing strategies, files, and patterns
|
|
103
|
+
* @param options - Formatting options (maxTokens defaults to 500)
|
|
104
|
+
* @returns Formatted markdown string for prompt injection, or empty string if no insights
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const bundle = {
|
|
109
|
+
* strategies: [{ strategy: "file-based", successRate: 85.5, totalAttempts: 12, recommendation: "..." }],
|
|
110
|
+
* files: [{ file: "src/auth.ts", failureCount: 2, lastFailure: null, gotchas: [] }],
|
|
111
|
+
* patterns: [{ pattern: "type_error", frequency: 3, recommendation: "Add type checks" }]
|
|
112
|
+
* };
|
|
113
|
+
* const formatted = formatInsightsForPrompt(bundle, { maxTokens: 300 });
|
|
114
|
+
* // Returns formatted markdown with top 3 strategies, top 5 files, top 3 patterns
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare function formatInsightsForPrompt(bundle: InsightsBundle, options?: FormatOptions): string;
|
|
118
|
+
/**
|
|
119
|
+
* Get cached insights or compute fresh ones.
|
|
120
|
+
*
|
|
121
|
+
* Simple in-memory cache with 5-minute TTL to avoid redundant database queries.
|
|
122
|
+
*
|
|
123
|
+
* @param _swarmMail - SwarmMail adapter (currently unused, reserved for future cache invalidation)
|
|
124
|
+
* @param cacheKey - Unique key for caching (e.g., "strategies:task-name" or "files:src/auth.ts")
|
|
125
|
+
* @param computeFn - Function to compute fresh insights if cache miss
|
|
126
|
+
* @returns Promise resolving to cached or freshly computed insights bundle
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const insights = await getCachedInsights(
|
|
131
|
+
* swarmMail,
|
|
132
|
+
* "strategies:add-auth",
|
|
133
|
+
* async () => ({
|
|
134
|
+
* strategies: await getStrategyInsights(swarmMail, "add auth"),
|
|
135
|
+
* })
|
|
136
|
+
* );
|
|
137
|
+
* // First call: computes and caches. Subsequent calls within 5min: returns cached.
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export declare function getCachedInsights(_swarmMail: SwarmMailAdapter, cacheKey: string, computeFn: () => Promise<InsightsBundle>): Promise<InsightsBundle>;
|
|
141
|
+
/**
|
|
142
|
+
* Clear the insights cache.
|
|
143
|
+
*
|
|
144
|
+
* Useful for testing or forcing fresh insights computation.
|
|
145
|
+
*
|
|
146
|
+
* @returns void
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* clearInsightsCache();
|
|
151
|
+
* // All cached insights invalidated, next getCachedInsights() will recompute
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export declare function clearInsightsCache(): void;
|
|
155
|
+
//# 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;A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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOvB,CAAC"}
|
|
@@ -1002,6 +1002,32 @@ const skills_execute = tool({
|
|
|
1002
1002
|
execute: (args, ctx) => execTool("skills_execute", args, ctx),
|
|
1003
1003
|
});
|
|
1004
1004
|
|
|
1005
|
+
// =============================================================================
|
|
1006
|
+
// Swarm Insights Tools
|
|
1007
|
+
// =============================================================================
|
|
1008
|
+
|
|
1009
|
+
const swarm_get_strategy_insights = tool({
|
|
1010
|
+
description: "Get strategy success rates for decomposition planning. Use this when planning task decomposition to see which strategies (file-based, feature-based, risk-based) have historically succeeded or failed. Returns success rates and recommendations based on past swarm outcomes.",
|
|
1011
|
+
args: {
|
|
1012
|
+
task: tool.schema.string().describe("Task description to analyze for strategy recommendation"),
|
|
1013
|
+
},
|
|
1014
|
+
execute: (args, ctx) => execTool("swarm_get_strategy_insights", args, ctx),
|
|
1015
|
+
});
|
|
1016
|
+
|
|
1017
|
+
const swarm_get_file_insights = tool({
|
|
1018
|
+
description: "Get file-specific gotchas for worker context. Use this when assigning files to workers to warn them about historical failure patterns. Queries past outcomes and semantic memory for file-specific learnings (edge cases, common bugs, performance traps).",
|
|
1019
|
+
args: {
|
|
1020
|
+
files: tool.schema.array(tool.schema.string()).describe("File paths to get insights for"),
|
|
1021
|
+
},
|
|
1022
|
+
execute: (args, ctx) => execTool("swarm_get_file_insights", args, ctx),
|
|
1023
|
+
});
|
|
1024
|
+
|
|
1025
|
+
const swarm_get_pattern_insights = tool({
|
|
1026
|
+
description: "Get common failure patterns across swarms. Use this during planning or when debugging stuck swarms to see recurring anti-patterns (type errors, timeouts, conflicts, test failures). Returns top 5 most frequent failure patterns with recommendations.",
|
|
1027
|
+
args: {},
|
|
1028
|
+
execute: (args, ctx) => execTool("swarm_get_pattern_insights", args, ctx),
|
|
1029
|
+
});
|
|
1030
|
+
|
|
1005
1031
|
// =============================================================================
|
|
1006
1032
|
// Plugin Export
|
|
1007
1033
|
// =============================================================================
|
|
@@ -2034,6 +2060,10 @@ const SwarmPlugin: Plugin = async (
|
|
|
2034
2060
|
skills_init,
|
|
2035
2061
|
skills_add_script,
|
|
2036
2062
|
skills_execute,
|
|
2063
|
+
// Swarm Insights
|
|
2064
|
+
swarm_get_strategy_insights,
|
|
2065
|
+
swarm_get_file_insights,
|
|
2066
|
+
swarm_get_pattern_insights,
|
|
2037
2067
|
},
|
|
2038
2068
|
|
|
2039
2069
|
// Swarm-aware compaction hook with LLM-powered continuation prompts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm-plugin",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.7",
|
|
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.
|
|
50
|
+
"swarm-mail": "1.5.5",
|
|
51
51
|
"yaml": "^2.8.2",
|
|
52
52
|
"zod": "4.1.8"
|
|
53
53
|
},
|