opencode-swarm-plugin 0.44.2 → 0.45.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.
- package/README.md +277 -54
- package/bin/swarm.ts +156 -29
- package/dist/bin/swarm.js +125212 -0
- package/dist/decision-trace-integration.d.ts +204 -0
- package/dist/decision-trace-integration.d.ts.map +1 -0
- package/dist/hive.d.ts.map +1 -1
- package/dist/hive.js +9 -9
- package/dist/index.d.ts +32 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +535 -27
- package/dist/plugin.js +295 -27
- package/dist/query-tools.d.ts +20 -12
- package/dist/query-tools.d.ts.map +1 -1
- package/dist/swarm-decompose.d.ts +4 -4
- package/dist/swarm-decompose.d.ts.map +1 -1
- package/dist/swarm-prompts.d.ts.map +1 -1
- package/dist/swarm-prompts.js +220 -22
- package/dist/swarm-review.d.ts.map +1 -1
- package/dist/swarm-signature.d.ts +106 -0
- package/dist/swarm-signature.d.ts.map +1 -0
- package/dist/swarm-strategies.d.ts +16 -3
- package/dist/swarm-strategies.d.ts.map +1 -1
- package/dist/swarm.d.ts +4 -2
- package/dist/swarm.d.ts.map +1 -1
- package/examples/commands/swarm.md +745 -0
- package/examples/plugin-wrapper-template.ts +2892 -0
- package/examples/skills/hive-workflow/SKILL.md +212 -0
- package/examples/skills/skill-creator/SKILL.md +223 -0
- package/examples/skills/swarm-coordination/SKILL.md +292 -0
- package/global-skills/cli-builder/SKILL.md +344 -0
- package/global-skills/cli-builder/references/advanced-patterns.md +244 -0
- package/global-skills/learning-systems/SKILL.md +644 -0
- package/global-skills/skill-creator/LICENSE.txt +202 -0
- package/global-skills/skill-creator/SKILL.md +352 -0
- package/global-skills/skill-creator/references/output-patterns.md +82 -0
- package/global-skills/skill-creator/references/workflows.md +28 -0
- package/global-skills/swarm-coordination/SKILL.md +995 -0
- package/global-skills/swarm-coordination/references/coordinator-patterns.md +235 -0
- package/global-skills/swarm-coordination/references/strategies.md +138 -0
- package/global-skills/system-design/SKILL.md +213 -0
- package/global-skills/testing-patterns/SKILL.md +430 -0
- package/global-skills/testing-patterns/references/dependency-breaking-catalog.md +586 -0
- package/package.json +6 -3
package/bin/swarm.ts
CHANGED
|
@@ -43,13 +43,61 @@ import {
|
|
|
43
43
|
getLibSQLProjectTempDirName,
|
|
44
44
|
getLibSQLDatabasePath,
|
|
45
45
|
hashLibSQLProjectPath,
|
|
46
|
+
getSwarmMailLibSQL,
|
|
47
|
+
createHiveAdapter,
|
|
48
|
+
resolvePartialId,
|
|
49
|
+
createDurableStreamAdapter,
|
|
50
|
+
createDurableStreamServer,
|
|
46
51
|
} from "swarm-mail";
|
|
52
|
+
import { execSync } from "child_process";
|
|
47
53
|
import { tmpdir } from "os";
|
|
48
54
|
|
|
55
|
+
// Query & observability tools
|
|
56
|
+
import {
|
|
57
|
+
executeQuery,
|
|
58
|
+
executePreset,
|
|
59
|
+
formatAsTable,
|
|
60
|
+
formatAsCSV,
|
|
61
|
+
formatAsJSON,
|
|
62
|
+
} from "../src/query-tools.js";
|
|
63
|
+
import {
|
|
64
|
+
getWorkerStatus,
|
|
65
|
+
getSubtaskProgress,
|
|
66
|
+
getFileLocks,
|
|
67
|
+
getRecentMessages,
|
|
68
|
+
getEpicList,
|
|
69
|
+
} from "../src/dashboard.js";
|
|
70
|
+
import {
|
|
71
|
+
fetchEpicEvents,
|
|
72
|
+
filterEvents,
|
|
73
|
+
replayWithTiming,
|
|
74
|
+
formatReplayEvent,
|
|
75
|
+
} from "../src/replay-tools.js";
|
|
76
|
+
import {
|
|
77
|
+
exportToOTLP,
|
|
78
|
+
exportToCSV,
|
|
79
|
+
exportToJSON,
|
|
80
|
+
} from "../src/export-tools.js";
|
|
81
|
+
import {
|
|
82
|
+
querySwarmHistory,
|
|
83
|
+
formatSwarmHistory,
|
|
84
|
+
formatSwarmStats,
|
|
85
|
+
parseTimePeriod,
|
|
86
|
+
aggregateByStrategy,
|
|
87
|
+
} from "../src/observability-tools.js";
|
|
88
|
+
|
|
89
|
+
// Eval tools
|
|
90
|
+
import { getPhase, getScoreHistory, recordEvalRun, getEvalHistoryPath } from "../src/eval-history.js";
|
|
91
|
+
import { DEFAULT_THRESHOLDS, checkGate } from "../src/eval-gates.js";
|
|
92
|
+
import { captureCompactionEvent } from "../src/eval-capture.js";
|
|
93
|
+
|
|
94
|
+
// All tools (for tool command)
|
|
95
|
+
import { allTools } from "../src/index.js";
|
|
96
|
+
|
|
49
97
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
);
|
|
98
|
+
// When bundled to dist/bin/swarm.js, need to go up two levels to find package.json
|
|
99
|
+
const pkgPath = join(__dirname, "..", "..", "package.json");
|
|
100
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
53
101
|
const VERSION: string = pkg.version;
|
|
54
102
|
|
|
55
103
|
// ============================================================================
|
|
@@ -2536,7 +2584,7 @@ async function query() {
|
|
|
2536
2584
|
const parsed = parseQueryArgs(args);
|
|
2537
2585
|
|
|
2538
2586
|
// Import query tools
|
|
2539
|
-
|
|
2587
|
+
// Static import at top of file
|
|
2540
2588
|
|
|
2541
2589
|
p.intro("swarm query");
|
|
2542
2590
|
|
|
@@ -2614,7 +2662,7 @@ async function dashboard() {
|
|
|
2614
2662
|
const args = process.argv.slice(3);
|
|
2615
2663
|
const parsed = parseDashboardArgs(args);
|
|
2616
2664
|
|
|
2617
|
-
|
|
2665
|
+
// Static import at top of file
|
|
2618
2666
|
|
|
2619
2667
|
p.intro("swarm dashboard");
|
|
2620
2668
|
|
|
@@ -2783,7 +2831,7 @@ async function replay() {
|
|
|
2783
2831
|
process.exit(1);
|
|
2784
2832
|
}
|
|
2785
2833
|
|
|
2786
|
-
|
|
2834
|
+
// Static import at top of file
|
|
2787
2835
|
|
|
2788
2836
|
p.intro(`swarm replay ${parsed.epicId}`);
|
|
2789
2837
|
|
|
@@ -2859,7 +2907,7 @@ async function exportEvents() {
|
|
|
2859
2907
|
const args = process.argv.slice(3);
|
|
2860
2908
|
const parsed = parseExportArgs(args);
|
|
2861
2909
|
|
|
2862
|
-
|
|
2910
|
+
// Static import at top of file
|
|
2863
2911
|
|
|
2864
2912
|
p.intro("swarm export");
|
|
2865
2913
|
|
|
@@ -3038,7 +3086,7 @@ ${dim("Docs: https://github.com/joelhooks/opencode-swarm-plugin")}
|
|
|
3038
3086
|
*/
|
|
3039
3087
|
async function executeTool(toolName: string, argsJson?: string) {
|
|
3040
3088
|
// Lazy import to avoid loading all tools on every CLI invocation
|
|
3041
|
-
|
|
3089
|
+
// Static import at top of file
|
|
3042
3090
|
|
|
3043
3091
|
// Validate tool name
|
|
3044
3092
|
if (!(toolName in allTools)) {
|
|
@@ -3131,7 +3179,7 @@ async function executeTool(toolName: string, argsJson?: string) {
|
|
|
3131
3179
|
* List all available tools
|
|
3132
3180
|
*/
|
|
3133
3181
|
async function listTools() {
|
|
3134
|
-
|
|
3182
|
+
// Static import at top of file
|
|
3135
3183
|
const tools = Object.keys(allTools).sort();
|
|
3136
3184
|
|
|
3137
3185
|
console.log(yellow(BANNER));
|
|
@@ -3358,7 +3406,7 @@ async function migrate() {
|
|
|
3358
3406
|
// Session Log Helpers
|
|
3359
3407
|
// ============================================================================
|
|
3360
3408
|
|
|
3361
|
-
import type { CoordinatorEvent } from "../
|
|
3409
|
+
import type { CoordinatorEvent } from "../dist/eval-capture.js";
|
|
3362
3410
|
|
|
3363
3411
|
/**
|
|
3364
3412
|
* Parse a session file and return events
|
|
@@ -3884,7 +3932,7 @@ async function cells() {
|
|
|
3884
3932
|
|
|
3885
3933
|
// Get adapter using swarm-mail
|
|
3886
3934
|
const projectPath = process.cwd();
|
|
3887
|
-
|
|
3935
|
+
// Static import at top of file
|
|
3888
3936
|
|
|
3889
3937
|
try {
|
|
3890
3938
|
const swarmMail = await getSwarmMailLibSQL(projectPath);
|
|
@@ -4224,7 +4272,7 @@ async function db() {
|
|
|
4224
4272
|
|
|
4225
4273
|
// Check schema
|
|
4226
4274
|
try {
|
|
4227
|
-
|
|
4275
|
+
// Static import at top of file
|
|
4228
4276
|
const schema = execSync(`sqlite3 "${dbFile}" "SELECT sql FROM sqlite_master WHERE type='table' AND name='beads'"`, { encoding: "utf-8" }).trim();
|
|
4229
4277
|
|
|
4230
4278
|
if (schema) {
|
|
@@ -4456,10 +4504,7 @@ function formatEvalRunResultOutput(result: {
|
|
|
4456
4504
|
// ============================================================================
|
|
4457
4505
|
|
|
4458
4506
|
async function stats() {
|
|
4459
|
-
|
|
4460
|
-
const { formatSwarmStats, parseTimePeriod, aggregateByStrategy } = await import(
|
|
4461
|
-
"../src/observability-tools"
|
|
4462
|
-
);
|
|
4507
|
+
// Static import at top of file
|
|
4463
4508
|
|
|
4464
4509
|
p.intro("swarm stats");
|
|
4465
4510
|
|
|
@@ -4628,10 +4673,7 @@ async function stats() {
|
|
|
4628
4673
|
// ============================================================================
|
|
4629
4674
|
|
|
4630
4675
|
async function swarmHistory() {
|
|
4631
|
-
|
|
4632
|
-
querySwarmHistory,
|
|
4633
|
-
formatSwarmHistory,
|
|
4634
|
-
} = await import("../src/observability-tools.js");
|
|
4676
|
+
// Static import at top of file
|
|
4635
4677
|
|
|
4636
4678
|
p.intro("swarm history");
|
|
4637
4679
|
|
|
@@ -4757,8 +4799,7 @@ async function evalHelp() {
|
|
|
4757
4799
|
}
|
|
4758
4800
|
|
|
4759
4801
|
async function evalStatus() {
|
|
4760
|
-
|
|
4761
|
-
const { DEFAULT_THRESHOLDS } = await import("../src/eval-gates.js");
|
|
4802
|
+
// Static imports at top of file
|
|
4762
4803
|
|
|
4763
4804
|
p.intro("swarm eval status");
|
|
4764
4805
|
|
|
@@ -4784,7 +4825,7 @@ async function evalStatus() {
|
|
|
4784
4825
|
}
|
|
4785
4826
|
|
|
4786
4827
|
async function evalHistory() {
|
|
4787
|
-
|
|
4828
|
+
// Static import at top of file
|
|
4788
4829
|
|
|
4789
4830
|
p.intro("swarm eval history");
|
|
4790
4831
|
|
|
@@ -4817,8 +4858,7 @@ async function evalRun() {
|
|
|
4817
4858
|
}
|
|
4818
4859
|
|
|
4819
4860
|
// Import gate checking
|
|
4820
|
-
|
|
4821
|
-
const { recordEvalRun, getScoreHistory } = await import("../src/eval-history.js");
|
|
4861
|
+
// Static imports at top of file
|
|
4822
4862
|
|
|
4823
4863
|
// Run evalite for each eval
|
|
4824
4864
|
const evalFiles = [
|
|
@@ -4935,8 +4975,7 @@ async function serve() {
|
|
|
4935
4975
|
|
|
4936
4976
|
try {
|
|
4937
4977
|
// Import dependencies
|
|
4938
|
-
|
|
4939
|
-
const { createDurableStreamAdapter, createDurableStreamServer } = await import("swarm-mail");
|
|
4978
|
+
// Static imports at top of file
|
|
4940
4979
|
|
|
4941
4980
|
// Get swarm-mail adapter
|
|
4942
4981
|
const swarmMail = await getSwarmMailLibSQL(projectPath);
|
|
@@ -4997,8 +5036,7 @@ async function viz() {
|
|
|
4997
5036
|
|
|
4998
5037
|
try {
|
|
4999
5038
|
// Import dependencies
|
|
5000
|
-
|
|
5001
|
-
const { createDurableStreamAdapter, createDurableStreamServer } = await import("swarm-mail");
|
|
5039
|
+
// Static imports at top of file
|
|
5002
5040
|
|
|
5003
5041
|
// Get swarm-mail adapter
|
|
5004
5042
|
const swarmMail = await getSwarmMailLibSQL(projectPath);
|
|
@@ -5038,6 +5076,92 @@ async function viz() {
|
|
|
5038
5076
|
}
|
|
5039
5077
|
}
|
|
5040
5078
|
|
|
5079
|
+
// ============================================================================
|
|
5080
|
+
// Capture Command - Capture eval events from plugin wrapper
|
|
5081
|
+
// ============================================================================
|
|
5082
|
+
|
|
5083
|
+
/**
|
|
5084
|
+
* Capture command - called by plugin wrapper to record eval events
|
|
5085
|
+
*
|
|
5086
|
+
* Usage:
|
|
5087
|
+
* swarm capture --session <id> --epic <id> --type <type> --payload <json>
|
|
5088
|
+
*
|
|
5089
|
+
* This allows the plugin wrapper to shell out instead of importing,
|
|
5090
|
+
* avoiding version mismatch issues when the plugin is installed globally.
|
|
5091
|
+
*/
|
|
5092
|
+
async function capture() {
|
|
5093
|
+
const args = process.argv.slice(3);
|
|
5094
|
+
|
|
5095
|
+
let sessionId: string | null = null;
|
|
5096
|
+
let epicId: string | null = null;
|
|
5097
|
+
let compactionType: string | null = null;
|
|
5098
|
+
let payloadJson: string | null = null;
|
|
5099
|
+
|
|
5100
|
+
for (let i = 0; i < args.length; i++) {
|
|
5101
|
+
const arg = args[i];
|
|
5102
|
+
|
|
5103
|
+
if ((arg === "--session" || arg === "-s") && i + 1 < args.length) {
|
|
5104
|
+
sessionId = args[++i];
|
|
5105
|
+
} else if ((arg === "--epic" || arg === "-e") && i + 1 < args.length) {
|
|
5106
|
+
epicId = args[++i];
|
|
5107
|
+
} else if ((arg === "--type" || arg === "-t") && i + 1 < args.length) {
|
|
5108
|
+
compactionType = args[++i];
|
|
5109
|
+
} else if ((arg === "--payload" || arg === "-p") && i + 1 < args.length) {
|
|
5110
|
+
payloadJson = args[++i];
|
|
5111
|
+
}
|
|
5112
|
+
}
|
|
5113
|
+
|
|
5114
|
+
// Validate required args
|
|
5115
|
+
if (!sessionId || !epicId || !compactionType) {
|
|
5116
|
+
console.error("Usage: swarm capture --session <id> --epic <id> --type <type> [--payload <json>]");
|
|
5117
|
+
console.error("");
|
|
5118
|
+
console.error("Required:");
|
|
5119
|
+
console.error(" --session, -s Session ID");
|
|
5120
|
+
console.error(" --epic, -e Epic ID");
|
|
5121
|
+
console.error(" --type, -t Compaction type (detection_complete, prompt_generated, context_injected, resumption_started, tool_call_tracked)");
|
|
5122
|
+
console.error("");
|
|
5123
|
+
console.error("Optional:");
|
|
5124
|
+
console.error(" --payload, -p JSON payload");
|
|
5125
|
+
process.exit(1);
|
|
5126
|
+
}
|
|
5127
|
+
|
|
5128
|
+
// Validate compaction type
|
|
5129
|
+
const validTypes = ["detection_complete", "prompt_generated", "context_injected", "resumption_started", "tool_call_tracked"];
|
|
5130
|
+
if (!validTypes.includes(compactionType)) {
|
|
5131
|
+
console.error(`Invalid compaction type: ${compactionType}`);
|
|
5132
|
+
console.error(`Valid types: ${validTypes.join(", ")}`);
|
|
5133
|
+
process.exit(1);
|
|
5134
|
+
}
|
|
5135
|
+
|
|
5136
|
+
// Parse payload
|
|
5137
|
+
let payload: any = {};
|
|
5138
|
+
if (payloadJson) {
|
|
5139
|
+
try {
|
|
5140
|
+
payload = JSON.parse(payloadJson);
|
|
5141
|
+
} catch (error) {
|
|
5142
|
+
console.error(`Invalid JSON payload: ${error}`);
|
|
5143
|
+
process.exit(1);
|
|
5144
|
+
}
|
|
5145
|
+
}
|
|
5146
|
+
|
|
5147
|
+
// Capture the event
|
|
5148
|
+
try {
|
|
5149
|
+
captureCompactionEvent({
|
|
5150
|
+
session_id: sessionId,
|
|
5151
|
+
epic_id: epicId,
|
|
5152
|
+
compaction_type: compactionType as any,
|
|
5153
|
+
payload,
|
|
5154
|
+
});
|
|
5155
|
+
|
|
5156
|
+
// Silent success - this is a fire-and-forget operation
|
|
5157
|
+
// Only output on error to avoid polluting logs
|
|
5158
|
+
} catch (error) {
|
|
5159
|
+
// Non-fatal - log but don't fail
|
|
5160
|
+
console.error(`[swarm capture] Failed: ${error}`);
|
|
5161
|
+
process.exit(1);
|
|
5162
|
+
}
|
|
5163
|
+
}
|
|
5164
|
+
|
|
5041
5165
|
// ============================================================================
|
|
5042
5166
|
// Main
|
|
5043
5167
|
// ============================================================================
|
|
@@ -5107,6 +5231,9 @@ switch (command) {
|
|
|
5107
5231
|
case "eval":
|
|
5108
5232
|
await evalCommand();
|
|
5109
5233
|
break;
|
|
5234
|
+
case "capture":
|
|
5235
|
+
await capture();
|
|
5236
|
+
break;
|
|
5110
5237
|
case "query":
|
|
5111
5238
|
await query();
|
|
5112
5239
|
break;
|