opencode-swarm-plugin 0.45.1 → 0.45.2
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 +68 -0
- package/dist/bin/swarm.js +861 -93
- package/dist/cass-tools.d.ts +75 -0
- package/dist/cass-tools.d.ts.map +1 -0
- package/dist/eval-capture.d.ts +6 -6
- package/dist/hive.d.ts +20 -20
- package/dist/hive.d.ts.map +1 -1
- package/dist/hive.js +79 -0
- package/dist/index.d.ts +91 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +512 -35
- package/dist/memory-tools.d.ts.map +1 -1
- package/dist/plugin.js +511 -35
- package/dist/schemas/cell-events.d.ts +4 -4
- package/dist/schemas/cell.d.ts +10 -10
- package/dist/schemas/swarm-context.d.ts +2 -2
- package/dist/skills.d.ts +8 -8
- package/dist/skills.d.ts.map +1 -1
- package/dist/swarm-orchestrate.d.ts.map +1 -1
- package/dist/swarm-prompts.js +242 -29
- package/examples/plugin-wrapper-template.ts +108 -7
- package/package.json +2 -2
package/dist/bin/swarm.js
CHANGED
|
@@ -27034,6 +27034,34 @@ import {
|
|
|
27034
27034
|
sep as sep3
|
|
27035
27035
|
} from "path";
|
|
27036
27036
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
27037
|
+
import { getSwarmMailLibSQL as getSwarmMailLibSQL8, createEvent as createEvent7 } from "swarm-mail";
|
|
27038
|
+
async function emitSkillLoadedEvent2(data) {
|
|
27039
|
+
try {
|
|
27040
|
+
const projectPath = skillsProjectDirectory2;
|
|
27041
|
+
const swarmMail = await getSwarmMailLibSQL8(projectPath);
|
|
27042
|
+
const event = createEvent7("skill_loaded", {
|
|
27043
|
+
project_key: projectPath,
|
|
27044
|
+
skill_name: data.skill_name,
|
|
27045
|
+
skill_source: data.skill_source,
|
|
27046
|
+
context_provided: data.context_provided,
|
|
27047
|
+
content_length: data.content_length
|
|
27048
|
+
});
|
|
27049
|
+
await swarmMail.appendEvent(event);
|
|
27050
|
+
} catch {}
|
|
27051
|
+
}
|
|
27052
|
+
async function emitSkillCreatedEvent2(data) {
|
|
27053
|
+
try {
|
|
27054
|
+
const projectPath = skillsProjectDirectory2;
|
|
27055
|
+
const swarmMail = await getSwarmMailLibSQL8(projectPath);
|
|
27056
|
+
const event = createEvent7("skill_created", {
|
|
27057
|
+
project_key: projectPath,
|
|
27058
|
+
skill_name: data.skill_name,
|
|
27059
|
+
skill_scope: data.skill_scope,
|
|
27060
|
+
description: data.description
|
|
27061
|
+
});
|
|
27062
|
+
await swarmMail.appendEvent(event);
|
|
27063
|
+
} catch {}
|
|
27064
|
+
}
|
|
27037
27065
|
function setSkillsProjectDirectory2(dir) {
|
|
27038
27066
|
skillsProjectDirectory2 = dir;
|
|
27039
27067
|
skillsCache2 = null;
|
|
@@ -27469,6 +27497,18 @@ If the skill has scripts, you can run them with skills_execute.`,
|
|
|
27469
27497
|
const names = available.map((s) => s.name).join(", ");
|
|
27470
27498
|
return `Skill '${args2.name}' not found. Available skills: ${names || "none"}`;
|
|
27471
27499
|
}
|
|
27500
|
+
let skillSource = "project";
|
|
27501
|
+
if (skill.path.includes(".config/opencode/skills") || skill.path.includes(".claude/skills")) {
|
|
27502
|
+
skillSource = "global";
|
|
27503
|
+
} else if (skill.path.includes("global-skills")) {
|
|
27504
|
+
skillSource = "bundled";
|
|
27505
|
+
}
|
|
27506
|
+
await emitSkillLoadedEvent2({
|
|
27507
|
+
skill_name: skill.metadata.name,
|
|
27508
|
+
skill_source: skillSource,
|
|
27509
|
+
context_provided: true,
|
|
27510
|
+
content_length: skill.body.length
|
|
27511
|
+
});
|
|
27472
27512
|
const includeScripts = args2.include_scripts !== false;
|
|
27473
27513
|
let output = `# Skill: ${skill.metadata.name}
|
|
27474
27514
|
|
|
@@ -27637,6 +27677,12 @@ Good skills have:
|
|
|
27637
27677
|
const content = generateSkillContent2(args2.name, args2.description, args2.body, { tags: args2.tags, tools: args2.tools });
|
|
27638
27678
|
await writeFile2(skillPath, content, "utf-8");
|
|
27639
27679
|
invalidateSkillsCache2();
|
|
27680
|
+
const skillScope = args2.directory === "global" || args2.directory === "global-claude" ? "global" : "project";
|
|
27681
|
+
await emitSkillCreatedEvent2({
|
|
27682
|
+
skill_name: args2.name,
|
|
27683
|
+
skill_scope: skillScope,
|
|
27684
|
+
description: args2.description
|
|
27685
|
+
});
|
|
27640
27686
|
const response = {
|
|
27641
27687
|
success: true,
|
|
27642
27688
|
skill: args2.name,
|
|
@@ -27872,6 +27918,12 @@ echo "Project directory: $1"
|
|
|
27872
27918
|
createdFiles.push("references/guide.md");
|
|
27873
27919
|
}
|
|
27874
27920
|
invalidateSkillsCache2();
|
|
27921
|
+
const skillScope = args2.directory === "global" ? "global" : "project";
|
|
27922
|
+
await emitSkillCreatedEvent2({
|
|
27923
|
+
skill_name: args2.name,
|
|
27924
|
+
skill_scope: skillScope,
|
|
27925
|
+
description: args2.description || "[TODO: Complete description]"
|
|
27926
|
+
});
|
|
27875
27927
|
return JSON.stringify({
|
|
27876
27928
|
success: true,
|
|
27877
27929
|
skill: args2.name,
|
|
@@ -54156,6 +54208,20 @@ var hive_create = tool({
|
|
|
54156
54208
|
parent_id: validated.parent_id
|
|
54157
54209
|
});
|
|
54158
54210
|
await adapter.markDirty(projectKey, cell.id);
|
|
54211
|
+
try {
|
|
54212
|
+
const event = createEvent("cell_created", {
|
|
54213
|
+
project_key: projectKey,
|
|
54214
|
+
cell_id: cell.id,
|
|
54215
|
+
title: validated.title,
|
|
54216
|
+
description: validated.description,
|
|
54217
|
+
issue_type: validated.type || "task",
|
|
54218
|
+
priority: validated.priority ?? 2,
|
|
54219
|
+
parent_id: validated.parent_id
|
|
54220
|
+
});
|
|
54221
|
+
await appendEvent(event, projectKey);
|
|
54222
|
+
} catch (error45) {
|
|
54223
|
+
console.warn("[hive_create] Failed to emit cell_created event:", error45);
|
|
54224
|
+
}
|
|
54159
54225
|
const formatted = formatCellForOutput(cell);
|
|
54160
54226
|
return JSON.stringify(formatted, null, 2);
|
|
54161
54227
|
} catch (error45) {
|
|
@@ -54215,6 +54281,19 @@ var hive_create_epic = tool({
|
|
|
54215
54281
|
subtasks: created.slice(1).map((c) => formatCellForOutput(c))
|
|
54216
54282
|
};
|
|
54217
54283
|
const effectiveProjectKey = args.project_key || projectKey;
|
|
54284
|
+
try {
|
|
54285
|
+
const epicCreatedEvent = createEvent("epic_created", {
|
|
54286
|
+
project_key: effectiveProjectKey,
|
|
54287
|
+
epic_id: epic.id,
|
|
54288
|
+
title: validated.epic_title,
|
|
54289
|
+
description: validated.epic_description,
|
|
54290
|
+
subtask_count: validated.subtasks.length,
|
|
54291
|
+
subtask_ids: created.slice(1).map((c) => c.id)
|
|
54292
|
+
});
|
|
54293
|
+
await appendEvent(epicCreatedEvent, effectiveProjectKey);
|
|
54294
|
+
} catch (error45) {
|
|
54295
|
+
console.warn("[hive_create_epic] Failed to emit epic_created event:", error45);
|
|
54296
|
+
}
|
|
54218
54297
|
try {
|
|
54219
54298
|
const event = createEvent("decomposition_generated", {
|
|
54220
54299
|
project_key: effectiveProjectKey,
|
|
@@ -54379,6 +54458,23 @@ var hive_update = tool({
|
|
|
54379
54458
|
cell = existingCell;
|
|
54380
54459
|
}
|
|
54381
54460
|
await adapter.markDirty(projectKey, cellId);
|
|
54461
|
+
try {
|
|
54462
|
+
const fieldsChanged = [];
|
|
54463
|
+
if (validated.status)
|
|
54464
|
+
fieldsChanged.push("status");
|
|
54465
|
+
if (validated.description !== undefined)
|
|
54466
|
+
fieldsChanged.push("description");
|
|
54467
|
+
if (validated.priority !== undefined)
|
|
54468
|
+
fieldsChanged.push("priority");
|
|
54469
|
+
const event = createEvent("cell_updated", {
|
|
54470
|
+
project_key: projectKey,
|
|
54471
|
+
cell_id: cellId,
|
|
54472
|
+
fields_changed: fieldsChanged
|
|
54473
|
+
});
|
|
54474
|
+
await appendEvent(event, projectKey);
|
|
54475
|
+
} catch (error45) {
|
|
54476
|
+
console.warn("[hive_update] Failed to emit cell_updated event:", error45);
|
|
54477
|
+
}
|
|
54382
54478
|
const formatted = formatCellForOutput(cell);
|
|
54383
54479
|
return JSON.stringify(formatted, null, 2);
|
|
54384
54480
|
} catch (error45) {
|
|
@@ -54495,6 +54591,16 @@ var hive_close = tool({
|
|
|
54495
54591
|
console.warn("[hive_close] Failed to emit SwarmCompletedEvent:", error45);
|
|
54496
54592
|
}
|
|
54497
54593
|
}
|
|
54594
|
+
try {
|
|
54595
|
+
const event = createEvent("cell_closed", {
|
|
54596
|
+
project_key: projectKey,
|
|
54597
|
+
cell_id: cellId,
|
|
54598
|
+
reason: validated.reason
|
|
54599
|
+
});
|
|
54600
|
+
await appendEvent(event, projectKey);
|
|
54601
|
+
} catch (error45) {
|
|
54602
|
+
console.warn("[hive_close] Failed to emit cell_closed event:", error45);
|
|
54603
|
+
}
|
|
54498
54604
|
return `Closed ${cell.id}: ${validated.reason}`;
|
|
54499
54605
|
} catch (error45) {
|
|
54500
54606
|
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
@@ -54520,6 +54626,17 @@ var hive_start = tool({
|
|
|
54520
54626
|
const cellId = await resolvePartialId(adapter, projectKey, args.id) || args.id;
|
|
54521
54627
|
const cell = await adapter.changeCellStatus(projectKey, cellId, "in_progress");
|
|
54522
54628
|
await adapter.markDirty(projectKey, cellId);
|
|
54629
|
+
try {
|
|
54630
|
+
const event = createEvent("cell_status_changed", {
|
|
54631
|
+
project_key: projectKey,
|
|
54632
|
+
cell_id: cellId,
|
|
54633
|
+
old_status: "open",
|
|
54634
|
+
new_status: "in_progress"
|
|
54635
|
+
});
|
|
54636
|
+
await appendEvent(event, projectKey);
|
|
54637
|
+
} catch (error45) {
|
|
54638
|
+
console.warn("[hive_start] Failed to emit cell_status_changed event:", error45);
|
|
54639
|
+
}
|
|
54523
54640
|
return `Started: ${cell.id}`;
|
|
54524
54641
|
} catch (error45) {
|
|
54525
54642
|
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
@@ -54708,11 +54825,25 @@ var hive_sync = tool({
|
|
|
54708
54825
|
}
|
|
54709
54826
|
const remoteCheckResult = await runGitCommand(["remote"]);
|
|
54710
54827
|
const hasRemote = remoteCheckResult.stdout.trim() !== "";
|
|
54828
|
+
let pushSuccess = false;
|
|
54711
54829
|
if (hasRemote) {
|
|
54712
54830
|
const pushResult = await withTimeout(runGitCommand(["push"]), TIMEOUT_MS, "git push");
|
|
54713
54831
|
if (pushResult.exitCode !== 0) {
|
|
54714
54832
|
throw new HiveError(`Failed to push: ${pushResult.stderr}`, "git push", pushResult.exitCode);
|
|
54715
54833
|
}
|
|
54834
|
+
pushSuccess = true;
|
|
54835
|
+
}
|
|
54836
|
+
try {
|
|
54837
|
+
const event = createEvent("hive_synced", {
|
|
54838
|
+
project_key: projectKey,
|
|
54839
|
+
cells_synced: flushResult.cellsExported,
|
|
54840
|
+
push_success: pushSuccess
|
|
54841
|
+
});
|
|
54842
|
+
await appendEvent(event, projectKey);
|
|
54843
|
+
} catch (error45) {
|
|
54844
|
+
console.warn("[hive_sync] Failed to emit hive_synced event:", error45);
|
|
54845
|
+
}
|
|
54846
|
+
if (hasRemote) {
|
|
54716
54847
|
return "Hive synced and pushed successfully";
|
|
54717
54848
|
} else {
|
|
54718
54849
|
return "Hive synced successfully (no remote configured)";
|
|
@@ -54840,14 +54971,15 @@ import {
|
|
|
54840
54971
|
sep as sep2
|
|
54841
54972
|
} from "path";
|
|
54842
54973
|
import { fileURLToPath } from "url";
|
|
54974
|
+
import { getSwarmMailLibSQL as getSwarmMailLibSQL2, createEvent as createEvent2 } from "swarm-mail";
|
|
54843
54975
|
import {
|
|
54844
54976
|
getSwarmInbox,
|
|
54845
54977
|
releaseSwarmFiles,
|
|
54846
54978
|
sendSwarmMessage as sendSwarmMessage2,
|
|
54847
54979
|
getAgent,
|
|
54848
|
-
createEvent as
|
|
54980
|
+
createEvent as createEvent3,
|
|
54849
54981
|
appendEvent as appendEvent2,
|
|
54850
|
-
getSwarmMailLibSQL as
|
|
54982
|
+
getSwarmMailLibSQL as getSwarmMailLibSQL3
|
|
54851
54983
|
} from "swarm-mail";
|
|
54852
54984
|
import { checkSwarmHealth } from "swarm-mail";
|
|
54853
54985
|
import {
|
|
@@ -54855,13 +54987,13 @@ import {
|
|
|
54855
54987
|
FlushManager as FlushManager2,
|
|
54856
54988
|
importFromJSONL as importFromJSONL2,
|
|
54857
54989
|
syncMemories as syncMemories2,
|
|
54858
|
-
getSwarmMailLibSQL as
|
|
54990
|
+
getSwarmMailLibSQL as getSwarmMailLibSQL4,
|
|
54859
54991
|
resolvePartialId as resolvePartialId2,
|
|
54860
54992
|
findCellsByPartialId as findCellsByPartialId2
|
|
54861
54993
|
} from "swarm-mail";
|
|
54862
54994
|
import { existsSync as existsSync22, readFileSync as readFileSync22 } from "node:fs";
|
|
54863
54995
|
import { join as join22 } from "node:path";
|
|
54864
|
-
import { createEvent as
|
|
54996
|
+
import { createEvent as createEvent4, appendEvent as appendEvent3 } from "swarm-mail";
|
|
54865
54997
|
import { join as join4 } from "node:path";
|
|
54866
54998
|
import { existsSync as existsSync32 } from "node:fs";
|
|
54867
54999
|
import { sendSwarmMessage } from "swarm-mail";
|
|
@@ -54871,7 +55003,7 @@ import {
|
|
|
54871
55003
|
} from "swarm-mail";
|
|
54872
55004
|
import { createLibSQLAdapter } from "swarm-mail";
|
|
54873
55005
|
import { getDatabasePath } from "swarm-mail";
|
|
54874
|
-
import { getSwarmMailLibSQL as
|
|
55006
|
+
import { getSwarmMailLibSQL as getSwarmMailLibSQL42, createEvent as createEvent42, appendEvent as appendEvent32 } from "swarm-mail";
|
|
54875
55007
|
import {
|
|
54876
55008
|
createMemoryStore,
|
|
54877
55009
|
getDefaultConfig,
|
|
@@ -72167,6 +72299,33 @@ __export3(exports_skills, {
|
|
|
72167
72299
|
findRelevantSkills: () => findRelevantSkills,
|
|
72168
72300
|
discoverSkills: () => discoverSkills
|
|
72169
72301
|
});
|
|
72302
|
+
async function emitSkillLoadedEvent(data) {
|
|
72303
|
+
try {
|
|
72304
|
+
const projectPath = skillsProjectDirectory;
|
|
72305
|
+
const swarmMail = await getSwarmMailLibSQL2(projectPath);
|
|
72306
|
+
const event = createEvent2("skill_loaded", {
|
|
72307
|
+
project_key: projectPath,
|
|
72308
|
+
skill_name: data.skill_name,
|
|
72309
|
+
skill_source: data.skill_source,
|
|
72310
|
+
context_provided: data.context_provided,
|
|
72311
|
+
content_length: data.content_length
|
|
72312
|
+
});
|
|
72313
|
+
await swarmMail.appendEvent(event);
|
|
72314
|
+
} catch {}
|
|
72315
|
+
}
|
|
72316
|
+
async function emitSkillCreatedEvent(data) {
|
|
72317
|
+
try {
|
|
72318
|
+
const projectPath = skillsProjectDirectory;
|
|
72319
|
+
const swarmMail = await getSwarmMailLibSQL2(projectPath);
|
|
72320
|
+
const event = createEvent2("skill_created", {
|
|
72321
|
+
project_key: projectPath,
|
|
72322
|
+
skill_name: data.skill_name,
|
|
72323
|
+
skill_scope: data.skill_scope,
|
|
72324
|
+
description: data.description
|
|
72325
|
+
});
|
|
72326
|
+
await swarmMail.appendEvent(event);
|
|
72327
|
+
} catch {}
|
|
72328
|
+
}
|
|
72170
72329
|
function setSkillsProjectDirectory(dir) {
|
|
72171
72330
|
skillsProjectDirectory = dir;
|
|
72172
72331
|
skillsCache = null;
|
|
@@ -72616,6 +72775,18 @@ If the skill has scripts, you can run them with skills_execute.`,
|
|
|
72616
72775
|
const names = available.map((s) => s.name).join(", ");
|
|
72617
72776
|
return `Skill '${args.name}' not found. Available skills: ${names || "none"}`;
|
|
72618
72777
|
}
|
|
72778
|
+
let skillSource = "project";
|
|
72779
|
+
if (skill.path.includes(".config/opencode/skills") || skill.path.includes(".claude/skills")) {
|
|
72780
|
+
skillSource = "global";
|
|
72781
|
+
} else if (skill.path.includes("global-skills")) {
|
|
72782
|
+
skillSource = "bundled";
|
|
72783
|
+
}
|
|
72784
|
+
await emitSkillLoadedEvent({
|
|
72785
|
+
skill_name: skill.metadata.name,
|
|
72786
|
+
skill_source: skillSource,
|
|
72787
|
+
context_provided: true,
|
|
72788
|
+
content_length: skill.body.length
|
|
72789
|
+
});
|
|
72619
72790
|
const includeScripts = args.include_scripts !== false;
|
|
72620
72791
|
let output = `# Skill: ${skill.metadata.name}
|
|
72621
72792
|
|
|
@@ -72784,6 +72955,12 @@ Good skills have:
|
|
|
72784
72955
|
const content = generateSkillContent(args.name, args.description, args.body, { tags: args.tags, tools: args.tools });
|
|
72785
72956
|
await writeFile(skillPath, content, "utf-8");
|
|
72786
72957
|
invalidateSkillsCache();
|
|
72958
|
+
const skillScope = args.directory === "global" || args.directory === "global-claude" ? "global" : "project";
|
|
72959
|
+
await emitSkillCreatedEvent({
|
|
72960
|
+
skill_name: args.name,
|
|
72961
|
+
skill_scope: skillScope,
|
|
72962
|
+
description: args.description
|
|
72963
|
+
});
|
|
72787
72964
|
const response = {
|
|
72788
72965
|
success: true,
|
|
72789
72966
|
skill: args.name,
|
|
@@ -73019,6 +73196,12 @@ echo "Project directory: $1"
|
|
|
73019
73196
|
createdFiles.push("references/guide.md");
|
|
73020
73197
|
}
|
|
73021
73198
|
invalidateSkillsCache();
|
|
73199
|
+
const skillScope = args.directory === "global" ? "global" : "project";
|
|
73200
|
+
await emitSkillCreatedEvent({
|
|
73201
|
+
skill_name: args.name,
|
|
73202
|
+
skill_scope: skillScope,
|
|
73203
|
+
description: args.description || "[TODO: Complete description]"
|
|
73204
|
+
});
|
|
73022
73205
|
return JSON.stringify({
|
|
73023
73206
|
success: true,
|
|
73024
73207
|
skill: args.name,
|
|
@@ -75906,7 +76089,7 @@ async function getHiveAdapter2(projectKey) {
|
|
|
75906
76089
|
if (adapterCache2.has(projectKey)) {
|
|
75907
76090
|
return adapterCache2.get(projectKey);
|
|
75908
76091
|
}
|
|
75909
|
-
const swarmMail = await
|
|
76092
|
+
const swarmMail = await getSwarmMailLibSQL4(projectKey);
|
|
75910
76093
|
const db = await swarmMail.getDatabase();
|
|
75911
76094
|
const adapter = createHiveAdapter2(db, projectKey);
|
|
75912
76095
|
await adapter.runMigrations();
|
|
@@ -75976,6 +76159,20 @@ var hive_create2 = tool2({
|
|
|
75976
76159
|
parent_id: validated.parent_id
|
|
75977
76160
|
});
|
|
75978
76161
|
await adapter.markDirty(projectKey, cell.id);
|
|
76162
|
+
try {
|
|
76163
|
+
const event = createEvent4("cell_created", {
|
|
76164
|
+
project_key: projectKey,
|
|
76165
|
+
cell_id: cell.id,
|
|
76166
|
+
title: validated.title,
|
|
76167
|
+
description: validated.description,
|
|
76168
|
+
issue_type: validated.type || "task",
|
|
76169
|
+
priority: validated.priority ?? 2,
|
|
76170
|
+
parent_id: validated.parent_id
|
|
76171
|
+
});
|
|
76172
|
+
await appendEvent3(event, projectKey);
|
|
76173
|
+
} catch (error452) {
|
|
76174
|
+
console.warn("[hive_create] Failed to emit cell_created event:", error452);
|
|
76175
|
+
}
|
|
75979
76176
|
const formatted = formatCellForOutput2(cell);
|
|
75980
76177
|
return JSON.stringify(formatted, null, 2);
|
|
75981
76178
|
} catch (error452) {
|
|
@@ -76036,7 +76233,20 @@ var hive_create_epic2 = tool2({
|
|
|
76036
76233
|
};
|
|
76037
76234
|
const effectiveProjectKey = args.project_key || projectKey;
|
|
76038
76235
|
try {
|
|
76039
|
-
const
|
|
76236
|
+
const epicCreatedEvent = createEvent4("epic_created", {
|
|
76237
|
+
project_key: effectiveProjectKey,
|
|
76238
|
+
epic_id: epic.id,
|
|
76239
|
+
title: validated.epic_title,
|
|
76240
|
+
description: validated.epic_description,
|
|
76241
|
+
subtask_count: validated.subtasks.length,
|
|
76242
|
+
subtask_ids: created.slice(1).map((c) => c.id)
|
|
76243
|
+
});
|
|
76244
|
+
await appendEvent3(epicCreatedEvent, effectiveProjectKey);
|
|
76245
|
+
} catch (error452) {
|
|
76246
|
+
console.warn("[hive_create_epic] Failed to emit epic_created event:", error452);
|
|
76247
|
+
}
|
|
76248
|
+
try {
|
|
76249
|
+
const event = createEvent4("decomposition_generated", {
|
|
76040
76250
|
project_key: effectiveProjectKey,
|
|
76041
76251
|
epic_id: epic.id,
|
|
76042
76252
|
task: args.task || validated.epic_title,
|
|
@@ -76056,7 +76266,7 @@ var hive_create_epic2 = tool2({
|
|
|
76056
76266
|
}
|
|
76057
76267
|
try {
|
|
76058
76268
|
const totalFiles = validated.subtasks.reduce((count, st) => count + (st.files?.length || 0), 0);
|
|
76059
|
-
const swarmStartedEvent =
|
|
76269
|
+
const swarmStartedEvent = createEvent4("swarm_started", {
|
|
76060
76270
|
project_key: effectiveProjectKey,
|
|
76061
76271
|
epic_id: epic.id,
|
|
76062
76272
|
epic_title: validated.epic_title,
|
|
@@ -76199,6 +76409,23 @@ var hive_update2 = tool2({
|
|
|
76199
76409
|
cell = existingCell;
|
|
76200
76410
|
}
|
|
76201
76411
|
await adapter.markDirty(projectKey, cellId);
|
|
76412
|
+
try {
|
|
76413
|
+
const fieldsChanged = [];
|
|
76414
|
+
if (validated.status)
|
|
76415
|
+
fieldsChanged.push("status");
|
|
76416
|
+
if (validated.description !== undefined)
|
|
76417
|
+
fieldsChanged.push("description");
|
|
76418
|
+
if (validated.priority !== undefined)
|
|
76419
|
+
fieldsChanged.push("priority");
|
|
76420
|
+
const event = createEvent4("cell_updated", {
|
|
76421
|
+
project_key: projectKey,
|
|
76422
|
+
cell_id: cellId,
|
|
76423
|
+
fields_changed: fieldsChanged
|
|
76424
|
+
});
|
|
76425
|
+
await appendEvent3(event, projectKey);
|
|
76426
|
+
} catch (error452) {
|
|
76427
|
+
console.warn("[hive_update] Failed to emit cell_updated event:", error452);
|
|
76428
|
+
}
|
|
76202
76429
|
const formatted = formatCellForOutput2(cell);
|
|
76203
76430
|
return JSON.stringify(formatted, null, 2);
|
|
76204
76431
|
} catch (error452) {
|
|
@@ -76315,6 +76542,16 @@ var hive_close2 = tool2({
|
|
|
76315
76542
|
console.warn("[hive_close] Failed to emit SwarmCompletedEvent:", error452);
|
|
76316
76543
|
}
|
|
76317
76544
|
}
|
|
76545
|
+
try {
|
|
76546
|
+
const event = createEvent4("cell_closed", {
|
|
76547
|
+
project_key: projectKey,
|
|
76548
|
+
cell_id: cellId,
|
|
76549
|
+
reason: validated.reason
|
|
76550
|
+
});
|
|
76551
|
+
await appendEvent3(event, projectKey);
|
|
76552
|
+
} catch (error452) {
|
|
76553
|
+
console.warn("[hive_close] Failed to emit cell_closed event:", error452);
|
|
76554
|
+
}
|
|
76318
76555
|
return `Closed ${cell.id}: ${validated.reason}`;
|
|
76319
76556
|
} catch (error452) {
|
|
76320
76557
|
const message = error452 instanceof Error ? error452.message : String(error452);
|
|
@@ -76340,6 +76577,17 @@ var hive_start2 = tool2({
|
|
|
76340
76577
|
const cellId = await resolvePartialId2(adapter, projectKey, args.id) || args.id;
|
|
76341
76578
|
const cell = await adapter.changeCellStatus(projectKey, cellId, "in_progress");
|
|
76342
76579
|
await adapter.markDirty(projectKey, cellId);
|
|
76580
|
+
try {
|
|
76581
|
+
const event = createEvent4("cell_status_changed", {
|
|
76582
|
+
project_key: projectKey,
|
|
76583
|
+
cell_id: cellId,
|
|
76584
|
+
old_status: "open",
|
|
76585
|
+
new_status: "in_progress"
|
|
76586
|
+
});
|
|
76587
|
+
await appendEvent3(event, projectKey);
|
|
76588
|
+
} catch (error452) {
|
|
76589
|
+
console.warn("[hive_start] Failed to emit cell_status_changed event:", error452);
|
|
76590
|
+
}
|
|
76343
76591
|
return `Started: ${cell.id}`;
|
|
76344
76592
|
} catch (error452) {
|
|
76345
76593
|
const message = error452 instanceof Error ? error452.message : String(error452);
|
|
@@ -76469,7 +76717,7 @@ var hive_sync2 = tool2({
|
|
|
76469
76717
|
outputPath: `${projectKey}/.hive/issues.jsonl`
|
|
76470
76718
|
});
|
|
76471
76719
|
const flushResult = await withTimeout(flushManager.flush(), TIMEOUT_MS, "flush hive");
|
|
76472
|
-
const swarmMail = await
|
|
76720
|
+
const swarmMail = await getSwarmMailLibSQL4(projectKey);
|
|
76473
76721
|
const db = await swarmMail.getDatabase();
|
|
76474
76722
|
const hivePath = join22(projectKey, ".hive");
|
|
76475
76723
|
let memoriesSynced = 0;
|
|
@@ -76528,11 +76776,25 @@ var hive_sync2 = tool2({
|
|
|
76528
76776
|
}
|
|
76529
76777
|
const remoteCheckResult = await runGitCommand2(["remote"]);
|
|
76530
76778
|
const hasRemote = remoteCheckResult.stdout.trim() !== "";
|
|
76779
|
+
let pushSuccess = false;
|
|
76531
76780
|
if (hasRemote) {
|
|
76532
76781
|
const pushResult = await withTimeout(runGitCommand2(["push"]), TIMEOUT_MS, "git push");
|
|
76533
76782
|
if (pushResult.exitCode !== 0) {
|
|
76534
76783
|
throw new HiveError2(`Failed to push: ${pushResult.stderr}`, "git push", pushResult.exitCode);
|
|
76535
76784
|
}
|
|
76785
|
+
pushSuccess = true;
|
|
76786
|
+
}
|
|
76787
|
+
try {
|
|
76788
|
+
const event = createEvent4("hive_synced", {
|
|
76789
|
+
project_key: projectKey,
|
|
76790
|
+
cells_synced: flushResult.cellsExported,
|
|
76791
|
+
push_success: pushSuccess
|
|
76792
|
+
});
|
|
76793
|
+
await appendEvent3(event, projectKey);
|
|
76794
|
+
} catch (error452) {
|
|
76795
|
+
console.warn("[hive_sync] Failed to emit hive_synced event:", error452);
|
|
76796
|
+
}
|
|
76797
|
+
if (hasRemote) {
|
|
76536
76798
|
return "Hive synced and pushed successfully";
|
|
76537
76799
|
} else {
|
|
76538
76800
|
return "Hive synced successfully (no remote configured)";
|
|
@@ -77205,9 +77467,9 @@ var swarm_review = tool2({
|
|
|
77205
77467
|
downstream_tasks: downstreamTasks.length > 0 ? downstreamTasks : undefined
|
|
77206
77468
|
});
|
|
77207
77469
|
try {
|
|
77208
|
-
const { createEvent:
|
|
77470
|
+
const { createEvent: createEvent32, appendEvent: appendEvent22 } = await import("swarm-mail");
|
|
77209
77471
|
const attempt = getReviewStatus(args.task_id).attempt_count || 1;
|
|
77210
|
-
const reviewStartedEvent =
|
|
77472
|
+
const reviewStartedEvent = createEvent32("review_started", {
|
|
77211
77473
|
project_key: args.project_key,
|
|
77212
77474
|
epic_id: args.epic_id,
|
|
77213
77475
|
bead_id: args.task_id,
|
|
@@ -77296,9 +77558,9 @@ var swarm_review_feedback = tool2({
|
|
|
77296
77558
|
console.warn("[swarm_review_feedback] Failed to trace review_decision:", error452);
|
|
77297
77559
|
}
|
|
77298
77560
|
try {
|
|
77299
|
-
const { createEvent:
|
|
77561
|
+
const { createEvent: createEvent32, appendEvent: appendEvent22 } = await import("swarm-mail");
|
|
77300
77562
|
const attempt = getReviewStatus(args.task_id).attempt_count || 1;
|
|
77301
|
-
const reviewCompletedEvent =
|
|
77563
|
+
const reviewCompletedEvent = createEvent32("review_completed", {
|
|
77302
77564
|
project_key: args.project_key,
|
|
77303
77565
|
epic_id: epicId,
|
|
77304
77566
|
bead_id: args.task_id,
|
|
@@ -77367,9 +77629,9 @@ You may now complete the task with \`swarm_complete\`.`,
|
|
|
77367
77629
|
console.warn("[swarm_review_feedback] Failed to trace review_decision:", error452);
|
|
77368
77630
|
}
|
|
77369
77631
|
try {
|
|
77370
|
-
const { createEvent:
|
|
77632
|
+
const { createEvent: createEvent32, appendEvent: appendEvent22 } = await import("swarm-mail");
|
|
77371
77633
|
const status = remaining <= 0 ? "blocked" : "needs_changes";
|
|
77372
|
-
const reviewCompletedEvent =
|
|
77634
|
+
const reviewCompletedEvent = createEvent32("review_completed", {
|
|
77373
77635
|
project_key: args.project_key,
|
|
77374
77636
|
epic_id: epicId,
|
|
77375
77637
|
bead_id: args.task_id,
|
|
@@ -77919,7 +78181,7 @@ var swarm_progress = tool2({
|
|
|
77919
78181
|
}
|
|
77920
78182
|
};
|
|
77921
78183
|
const checkpointData = JSON.stringify(checkpoint);
|
|
77922
|
-
const checkpointEvent =
|
|
78184
|
+
const checkpointEvent = createEvent3("swarm_checkpointed", {
|
|
77923
78185
|
project_key: args.project_key,
|
|
77924
78186
|
...checkpoint,
|
|
77925
78187
|
checkpoint_size_bytes: Buffer.byteLength(checkpointData, "utf8"),
|
|
@@ -77927,7 +78189,7 @@ var swarm_progress = tool2({
|
|
|
77927
78189
|
});
|
|
77928
78190
|
await appendEvent2(checkpointEvent, args.project_key);
|
|
77929
78191
|
const checkpointId = `ckpt-${Date.now()}-${args.bead_id}`;
|
|
77930
|
-
const createdEvent =
|
|
78192
|
+
const createdEvent = createEvent3("checkpoint_created", {
|
|
77931
78193
|
project_key: args.project_key,
|
|
77932
78194
|
epic_id: epicId,
|
|
77933
78195
|
bead_id: args.bead_id,
|
|
@@ -78180,7 +78442,7 @@ This will be recorded as a negative learning signal.`;
|
|
|
78180
78442
|
let deferredResolved = false;
|
|
78181
78443
|
let deferredError;
|
|
78182
78444
|
try {
|
|
78183
|
-
const swarmMail = await
|
|
78445
|
+
const swarmMail = await getSwarmMailLibSQL3(args.project_key);
|
|
78184
78446
|
const db = await swarmMail.getDatabase();
|
|
78185
78447
|
const deferredUrl = `deferred:${args.bead_id}`;
|
|
78186
78448
|
const checkResult = await db.query(`SELECT url, resolved FROM deferred WHERE url = ? AND resolved = 0`, [deferredUrl]);
|
|
@@ -78209,16 +78471,16 @@ This will be recorded as a negative learning signal.`;
|
|
|
78209
78471
|
syncError = error452 instanceof Error ? error452.message : String(error452);
|
|
78210
78472
|
console.warn(`[swarm_complete] Auto-sync failed (non-fatal): ${syncError}`);
|
|
78211
78473
|
}
|
|
78474
|
+
const completionDurationMs = args.start_time ? Date.now() - args.start_time : 0;
|
|
78475
|
+
const eventEpicId = cell.parent_id || (args.bead_id.includes(".") ? args.bead_id.split(".")[0] : args.bead_id);
|
|
78212
78476
|
try {
|
|
78213
|
-
const
|
|
78214
|
-
const eventEpicId = cell.parent_id || (args.bead_id.includes(".") ? args.bead_id.split(".")[0] : args.bead_id);
|
|
78215
|
-
const event = createEvent2("subtask_outcome", {
|
|
78477
|
+
const event = createEvent3("subtask_outcome", {
|
|
78216
78478
|
project_key: args.project_key,
|
|
78217
78479
|
epic_id: eventEpicId,
|
|
78218
78480
|
bead_id: args.bead_id,
|
|
78219
78481
|
planned_files: args.planned_files || [],
|
|
78220
78482
|
actual_files: args.files_touched || [],
|
|
78221
|
-
duration_ms:
|
|
78483
|
+
duration_ms: completionDurationMs,
|
|
78222
78484
|
error_count: args.error_count || 0,
|
|
78223
78485
|
retry_count: args.retry_count || 0,
|
|
78224
78486
|
success: true,
|
|
@@ -78229,8 +78491,21 @@ This will be recorded as a negative learning signal.`;
|
|
|
78229
78491
|
} catch (error452) {
|
|
78230
78492
|
console.warn("[swarm_complete] Failed to emit SubtaskOutcomeEvent:", error452);
|
|
78231
78493
|
}
|
|
78494
|
+
try {
|
|
78495
|
+
const workerCompletedEvent = createEvent3("worker_completed", {
|
|
78496
|
+
project_key: args.project_key,
|
|
78497
|
+
epic_id: eventEpicId,
|
|
78498
|
+
bead_id: args.bead_id,
|
|
78499
|
+
worker_agent: args.agent_name,
|
|
78500
|
+
success: true,
|
|
78501
|
+
duration_ms: completionDurationMs,
|
|
78502
|
+
files_touched: args.files_touched || []
|
|
78503
|
+
});
|
|
78504
|
+
await appendEvent2(workerCompletedEvent, args.project_key);
|
|
78505
|
+
} catch (error452) {
|
|
78506
|
+
console.warn("[swarm_complete] Failed to emit worker_completed event:", error452);
|
|
78507
|
+
}
|
|
78232
78508
|
let capturedStrategy;
|
|
78233
|
-
const durationMs = args.start_time ? Date.now() - args.start_time : 0;
|
|
78234
78509
|
const memoryInfo = formatMemoryStoreOnSuccess(args.bead_id, args.summary, args.files_touched || [], capturedStrategy);
|
|
78235
78510
|
let memoryStored = false;
|
|
78236
78511
|
let memoryError;
|
|
@@ -78347,7 +78622,7 @@ Files touched: ${args.files_touched?.join(", ") || "none recorded"}`,
|
|
|
78347
78622
|
};
|
|
78348
78623
|
try {
|
|
78349
78624
|
const { captureSubtaskOutcome: captureSubtaskOutcome22 } = await Promise.resolve().then(() => (init_eval_capture2(), exports_eval_capture2));
|
|
78350
|
-
const
|
|
78625
|
+
const durationMs = args.start_time ? Date.now() - args.start_time : 0;
|
|
78351
78626
|
const evalEpicId = cell.parent_id || epicId2;
|
|
78352
78627
|
captureSubtaskOutcome22({
|
|
78353
78628
|
epicId: evalEpicId,
|
|
@@ -78356,7 +78631,7 @@ Files touched: ${args.files_touched?.join(", ") || "none recorded"}`,
|
|
|
78356
78631
|
title: cell.title,
|
|
78357
78632
|
plannedFiles: args.planned_files || [],
|
|
78358
78633
|
actualFiles: args.files_touched || [],
|
|
78359
|
-
durationMs
|
|
78634
|
+
durationMs,
|
|
78360
78635
|
errorCount: args.error_count || 0,
|
|
78361
78636
|
retryCount: args.retry_count || 0,
|
|
78362
78637
|
success: true
|
|
@@ -78365,7 +78640,7 @@ Files touched: ${args.files_touched?.join(", ") || "none recorded"}`,
|
|
|
78365
78640
|
console.warn("[swarm_complete] Failed to capture subtask outcome:", error452);
|
|
78366
78641
|
}
|
|
78367
78642
|
try {
|
|
78368
|
-
const
|
|
78643
|
+
const durationMs = args.start_time ? Date.now() - args.start_time : 0;
|
|
78369
78644
|
captureCoordinatorEvent2({
|
|
78370
78645
|
session_id: _ctx.sessionID || "unknown",
|
|
78371
78646
|
epic_id: epicId2,
|
|
@@ -78374,7 +78649,7 @@ Files touched: ${args.files_touched?.join(", ") || "none recorded"}`,
|
|
|
78374
78649
|
outcome_type: "subtask_success",
|
|
78375
78650
|
payload: {
|
|
78376
78651
|
bead_id: args.bead_id,
|
|
78377
|
-
duration_ms:
|
|
78652
|
+
duration_ms: durationMs,
|
|
78378
78653
|
files_touched: args.files_touched || [],
|
|
78379
78654
|
verification_passed: verificationResult?.passed ?? false,
|
|
78380
78655
|
verification_skipped: args.skip_verification ?? false
|
|
@@ -78848,7 +79123,7 @@ var swarm_checkpoint = tool2({
|
|
|
78848
79123
|
}
|
|
78849
79124
|
};
|
|
78850
79125
|
const checkpointData = JSON.stringify(checkpoint);
|
|
78851
|
-
const event =
|
|
79126
|
+
const event = createEvent3("swarm_checkpointed", {
|
|
78852
79127
|
project_key: args.project_key,
|
|
78853
79128
|
epic_id: args.epic_id,
|
|
78854
79129
|
bead_id: args.bead_id,
|
|
@@ -78890,8 +79165,8 @@ var swarm_recover = tool2({
|
|
|
78890
79165
|
},
|
|
78891
79166
|
async execute(args) {
|
|
78892
79167
|
try {
|
|
78893
|
-
const { getSwarmMailLibSQL:
|
|
78894
|
-
const swarmMail = await
|
|
79168
|
+
const { getSwarmMailLibSQL: getSwarmMailLibSQL43 } = await import("swarm-mail");
|
|
79169
|
+
const swarmMail = await getSwarmMailLibSQL43(args.project_key);
|
|
78895
79170
|
const db = await swarmMail.getDatabase();
|
|
78896
79171
|
const result = await db.query(`SELECT * FROM swarm_contexts
|
|
78897
79172
|
WHERE epic_id = $1
|
|
@@ -78918,7 +79193,7 @@ var swarm_recover = tool2({
|
|
|
78918
79193
|
created_at: row.created_at,
|
|
78919
79194
|
updated_at: row.updated_at
|
|
78920
79195
|
};
|
|
78921
|
-
const event =
|
|
79196
|
+
const event = createEvent3("swarm_recovered", {
|
|
78922
79197
|
project_key: args.project_key,
|
|
78923
79198
|
epic_id: args.epic_id,
|
|
78924
79199
|
bead_id: context.bead_id,
|
|
@@ -92421,7 +92696,7 @@ async function getMemoryAdapter(projectPath) {
|
|
|
92421
92696
|
if (cachedAdapter && cachedProjectPath === path32) {
|
|
92422
92697
|
return cachedAdapter;
|
|
92423
92698
|
}
|
|
92424
|
-
const swarmMail = await
|
|
92699
|
+
const swarmMail = await getSwarmMailLibSQL42(path32);
|
|
92425
92700
|
const dbAdapter = await swarmMail.getDatabase();
|
|
92426
92701
|
cachedAdapter = await createMemoryAdapter(dbAdapter);
|
|
92427
92702
|
cachedProjectPath = path32;
|
|
@@ -92442,6 +92717,21 @@ var semantic_memory_store = tool2({
|
|
|
92442
92717
|
async execute(args2, ctx) {
|
|
92443
92718
|
const adapter = await getMemoryAdapter();
|
|
92444
92719
|
const result = await adapter.store(args2);
|
|
92720
|
+
try {
|
|
92721
|
+
const projectKey = cachedProjectPath || process.cwd();
|
|
92722
|
+
const tags = args2.tags ? args2.tags.split(",").map((t) => t.trim()) : [];
|
|
92723
|
+
const event = createEvent42("memory_stored", {
|
|
92724
|
+
project_key: projectKey,
|
|
92725
|
+
memory_id: result.id,
|
|
92726
|
+
content_preview: args2.information.slice(0, 100),
|
|
92727
|
+
tags,
|
|
92728
|
+
auto_tagged: args2.autoTag,
|
|
92729
|
+
collection: args2.collection
|
|
92730
|
+
});
|
|
92731
|
+
await appendEvent32(event, projectKey);
|
|
92732
|
+
} catch (error452) {
|
|
92733
|
+
console.warn("[semantic_memory_store] Failed to emit memory_stored event:", error452);
|
|
92734
|
+
}
|
|
92445
92735
|
return JSON.stringify(result, null, 2);
|
|
92446
92736
|
}
|
|
92447
92737
|
});
|
|
@@ -92455,8 +92745,25 @@ var semantic_memory_find = tool2({
|
|
|
92455
92745
|
fts: tool2.schema.boolean().optional().describe("Use full-text search instead of vector search (default: false)")
|
|
92456
92746
|
},
|
|
92457
92747
|
async execute(args2, ctx) {
|
|
92748
|
+
const startTime = Date.now();
|
|
92458
92749
|
const adapter = await getMemoryAdapter();
|
|
92459
92750
|
const result = await adapter.find(args2);
|
|
92751
|
+
const duration32 = Date.now() - startTime;
|
|
92752
|
+
try {
|
|
92753
|
+
const projectKey = cachedProjectPath || process.cwd();
|
|
92754
|
+
const topScore = result.results.length > 0 ? result.results[0].score : undefined;
|
|
92755
|
+
const event = createEvent42("memory_found", {
|
|
92756
|
+
project_key: projectKey,
|
|
92757
|
+
query: args2.query,
|
|
92758
|
+
result_count: result.results.length,
|
|
92759
|
+
top_score: topScore,
|
|
92760
|
+
search_duration_ms: duration32,
|
|
92761
|
+
used_fts: args2.fts
|
|
92762
|
+
});
|
|
92763
|
+
await appendEvent32(event, projectKey);
|
|
92764
|
+
} catch (error452) {
|
|
92765
|
+
console.warn("[semantic_memory_find] Failed to emit memory_found event:", error452);
|
|
92766
|
+
}
|
|
92460
92767
|
return JSON.stringify(result, null, 2);
|
|
92461
92768
|
}
|
|
92462
92769
|
});
|
|
@@ -92479,6 +92786,18 @@ var semantic_memory_remove = tool2({
|
|
|
92479
92786
|
async execute(args2, ctx) {
|
|
92480
92787
|
const adapter = await getMemoryAdapter();
|
|
92481
92788
|
const result = await adapter.remove(args2);
|
|
92789
|
+
if (result.success) {
|
|
92790
|
+
try {
|
|
92791
|
+
const projectKey = cachedProjectPath || process.cwd();
|
|
92792
|
+
const event = createEvent42("memory_deleted", {
|
|
92793
|
+
project_key: projectKey,
|
|
92794
|
+
memory_id: args2.id
|
|
92795
|
+
});
|
|
92796
|
+
await appendEvent32(event, projectKey);
|
|
92797
|
+
} catch (error452) {
|
|
92798
|
+
console.warn("[semantic_memory_remove] Failed to emit memory_deleted event:", error452);
|
|
92799
|
+
}
|
|
92800
|
+
}
|
|
92482
92801
|
return JSON.stringify(result, null, 2);
|
|
92483
92802
|
}
|
|
92484
92803
|
});
|
|
@@ -92490,6 +92809,19 @@ var semantic_memory_validate = tool2({
|
|
|
92490
92809
|
async execute(args2, ctx) {
|
|
92491
92810
|
const adapter = await getMemoryAdapter();
|
|
92492
92811
|
const result = await adapter.validate(args2);
|
|
92812
|
+
if (result.success) {
|
|
92813
|
+
try {
|
|
92814
|
+
const projectKey = cachedProjectPath || process.cwd();
|
|
92815
|
+
const event = createEvent42("memory_validated", {
|
|
92816
|
+
project_key: projectKey,
|
|
92817
|
+
memory_id: args2.id,
|
|
92818
|
+
decay_reset: true
|
|
92819
|
+
});
|
|
92820
|
+
await appendEvent32(event, projectKey);
|
|
92821
|
+
} catch (error452) {
|
|
92822
|
+
console.warn("[semantic_memory_validate] Failed to emit memory_validated event:", error452);
|
|
92823
|
+
}
|
|
92824
|
+
}
|
|
92493
92825
|
return JSON.stringify(result, null, 2);
|
|
92494
92826
|
}
|
|
92495
92827
|
});
|
|
@@ -92537,6 +92869,18 @@ var semantic_memory_upsert = tool2({
|
|
|
92537
92869
|
async execute(args2, ctx) {
|
|
92538
92870
|
const adapter = await getMemoryAdapter();
|
|
92539
92871
|
const result = await adapter.upsert(args2);
|
|
92872
|
+
try {
|
|
92873
|
+
const projectKey = cachedProjectPath || process.cwd();
|
|
92874
|
+
const event = createEvent42("memory_updated", {
|
|
92875
|
+
project_key: projectKey,
|
|
92876
|
+
memory_id: result.memoryId || "unknown",
|
|
92877
|
+
operation: result.operation,
|
|
92878
|
+
reason: result.reason
|
|
92879
|
+
});
|
|
92880
|
+
await appendEvent32(event, projectKey);
|
|
92881
|
+
} catch (error452) {
|
|
92882
|
+
console.warn("[semantic_memory_upsert] Failed to emit memory_updated event:", error452);
|
|
92883
|
+
}
|
|
92540
92884
|
return JSON.stringify(result, null, 2);
|
|
92541
92885
|
}
|
|
92542
92886
|
});
|
|
@@ -93869,9 +94213,9 @@ var swarm_spawn_subtask = tool2({
|
|
|
93869
94213
|
}
|
|
93870
94214
|
if (args2.project_path) {
|
|
93871
94215
|
try {
|
|
93872
|
-
const { createEvent:
|
|
94216
|
+
const { createEvent: createEvent5, appendEvent: appendEvent4 } = await import("swarm-mail");
|
|
93873
94217
|
const spawnOrder = 0;
|
|
93874
|
-
const workerSpawnedEvent =
|
|
94218
|
+
const workerSpawnedEvent = createEvent5("worker_spawned", {
|
|
93875
94219
|
project_key: args2.project_path,
|
|
93876
94220
|
epic_id: args2.epic_id,
|
|
93877
94221
|
bead_id: args2.bead_id,
|
|
@@ -93881,7 +94225,7 @@ var swarm_spawn_subtask = tool2({
|
|
|
93881
94225
|
spawn_order: spawnOrder,
|
|
93882
94226
|
is_parallel: false
|
|
93883
94227
|
});
|
|
93884
|
-
await
|
|
94228
|
+
await appendEvent4(workerSpawnedEvent, args2.project_path);
|
|
93885
94229
|
} catch (error452) {
|
|
93886
94230
|
console.warn("[swarm_spawn_subtask] Failed to emit WorkerSpawnedEvent:", error452);
|
|
93887
94231
|
}
|
|
@@ -94175,13 +94519,13 @@ import {
|
|
|
94175
94519
|
getLibSQLProjectTempDirName,
|
|
94176
94520
|
getLibSQLDatabasePath,
|
|
94177
94521
|
hashLibSQLProjectPath,
|
|
94178
|
-
getSwarmMailLibSQL as
|
|
94522
|
+
getSwarmMailLibSQL as getSwarmMailLibSQL13,
|
|
94179
94523
|
createHiveAdapter as createHiveAdapter4,
|
|
94180
94524
|
resolvePartialId as resolvePartialId4,
|
|
94181
94525
|
createDurableStreamAdapter,
|
|
94182
94526
|
createDurableStreamServer
|
|
94183
94527
|
} from "swarm-mail";
|
|
94184
|
-
import { execSync } from "child_process";
|
|
94528
|
+
import { execSync as execSync2 } from "child_process";
|
|
94185
94529
|
import { tmpdir as tmpdir3 } from "os";
|
|
94186
94530
|
|
|
94187
94531
|
// src/query-tools.ts
|
|
@@ -94890,7 +95234,7 @@ import {
|
|
|
94890
95234
|
agentActivity,
|
|
94891
95235
|
checkpointFrequency,
|
|
94892
95236
|
failedDecompositions,
|
|
94893
|
-
getSwarmMailLibSQL as
|
|
95237
|
+
getSwarmMailLibSQL as getSwarmMailLibSQL6,
|
|
94894
95238
|
humanFeedback,
|
|
94895
95239
|
lockContention,
|
|
94896
95240
|
messageLatency,
|
|
@@ -94955,7 +95299,7 @@ var swarm_analytics = tool3({
|
|
|
94955
95299
|
async execute(args2) {
|
|
94956
95300
|
try {
|
|
94957
95301
|
const projectPath = process.cwd();
|
|
94958
|
-
const db = await
|
|
95302
|
+
const db = await getSwarmMailLibSQL6(projectPath);
|
|
94959
95303
|
const filters = {
|
|
94960
95304
|
project_key: projectPath
|
|
94961
95305
|
};
|
|
@@ -95025,7 +95369,7 @@ var swarm_query = tool3({
|
|
|
95025
95369
|
async execute(args2) {
|
|
95026
95370
|
try {
|
|
95027
95371
|
const projectPath = process.cwd();
|
|
95028
|
-
const swarmMail = await
|
|
95372
|
+
const swarmMail = await getSwarmMailLibSQL6(projectPath);
|
|
95029
95373
|
const db = await swarmMail.getDatabase();
|
|
95030
95374
|
if (!args2.sql.trim().toLowerCase().startsWith("select")) {
|
|
95031
95375
|
return JSON.stringify({
|
|
@@ -95075,7 +95419,7 @@ var swarm_diagnose = tool3({
|
|
|
95075
95419
|
async execute(args2) {
|
|
95076
95420
|
try {
|
|
95077
95421
|
const projectPath = process.cwd();
|
|
95078
|
-
const swarmMail = await
|
|
95422
|
+
const swarmMail = await getSwarmMailLibSQL6(projectPath);
|
|
95079
95423
|
const db = await swarmMail.getDatabase();
|
|
95080
95424
|
const diagnosis = [];
|
|
95081
95425
|
const include = args2.include || [
|
|
@@ -95186,7 +95530,7 @@ var swarm_insights = tool3({
|
|
|
95186
95530
|
});
|
|
95187
95531
|
}
|
|
95188
95532
|
const projectPath = process.cwd();
|
|
95189
|
-
const swarmMail = await
|
|
95533
|
+
const swarmMail = await getSwarmMailLibSQL6(projectPath);
|
|
95190
95534
|
const db = await swarmMail.getDatabase();
|
|
95191
95535
|
const insights = [];
|
|
95192
95536
|
if (args2.metrics.includes("success_rate")) {
|
|
@@ -95314,7 +95658,7 @@ function aggregateByStrategy(outcomes) {
|
|
|
95314
95658
|
}));
|
|
95315
95659
|
}
|
|
95316
95660
|
async function querySwarmHistory(projectPath, options2) {
|
|
95317
|
-
const swarmMail = await
|
|
95661
|
+
const swarmMail = await getSwarmMailLibSQL6(projectPath);
|
|
95318
95662
|
const db = await swarmMail.getDatabase();
|
|
95319
95663
|
const conditions = [];
|
|
95320
95664
|
const params = [];
|
|
@@ -95780,7 +96124,7 @@ import {
|
|
|
95780
96124
|
FlushManager as FlushManager3,
|
|
95781
96125
|
importFromJSONL as importFromJSONL3,
|
|
95782
96126
|
syncMemories as syncMemories3,
|
|
95783
|
-
getSwarmMailLibSQL as
|
|
96127
|
+
getSwarmMailLibSQL as getSwarmMailLibSQL7,
|
|
95784
96128
|
resolvePartialId as resolvePartialId3,
|
|
95785
96129
|
findCellsByPartialId as findCellsByPartialId3
|
|
95786
96130
|
} from "swarm-mail";
|
|
@@ -96347,7 +96691,7 @@ var CellEventSchema3 = exports_external3.discriminatedUnion("type", [
|
|
|
96347
96691
|
CellCompactedEventSchema3
|
|
96348
96692
|
]);
|
|
96349
96693
|
// src/hive.ts
|
|
96350
|
-
import { createEvent as
|
|
96694
|
+
import { createEvent as createEvent6, appendEvent as appendEvent5 } from "swarm-mail";
|
|
96351
96695
|
var hiveWorkingDirectory3 = null;
|
|
96352
96696
|
function setHiveWorkingDirectory2(directory) {
|
|
96353
96697
|
hiveWorkingDirectory3 = directory;
|
|
@@ -96431,7 +96775,7 @@ async function getHiveAdapter3(projectKey) {
|
|
|
96431
96775
|
if (adapterCache3.has(projectKey)) {
|
|
96432
96776
|
return adapterCache3.get(projectKey);
|
|
96433
96777
|
}
|
|
96434
|
-
const swarmMail = await
|
|
96778
|
+
const swarmMail = await getSwarmMailLibSQL7(projectKey);
|
|
96435
96779
|
const db = await swarmMail.getDatabase();
|
|
96436
96780
|
const adapter = createHiveAdapter3(db, projectKey);
|
|
96437
96781
|
await adapter.runMigrations();
|
|
@@ -96501,6 +96845,20 @@ var hive_create3 = tool3({
|
|
|
96501
96845
|
parent_id: validated.parent_id
|
|
96502
96846
|
});
|
|
96503
96847
|
await adapter.markDirty(projectKey, cell.id);
|
|
96848
|
+
try {
|
|
96849
|
+
const event = createEvent6("cell_created", {
|
|
96850
|
+
project_key: projectKey,
|
|
96851
|
+
cell_id: cell.id,
|
|
96852
|
+
title: validated.title,
|
|
96853
|
+
description: validated.description,
|
|
96854
|
+
issue_type: validated.type || "task",
|
|
96855
|
+
priority: validated.priority ?? 2,
|
|
96856
|
+
parent_id: validated.parent_id
|
|
96857
|
+
});
|
|
96858
|
+
await appendEvent5(event, projectKey);
|
|
96859
|
+
} catch (error54) {
|
|
96860
|
+
console.warn("[hive_create] Failed to emit cell_created event:", error54);
|
|
96861
|
+
}
|
|
96504
96862
|
const formatted = formatCellForOutput3(cell);
|
|
96505
96863
|
return JSON.stringify(formatted, null, 2);
|
|
96506
96864
|
} catch (error54) {
|
|
@@ -96561,7 +96919,20 @@ var hive_create_epic3 = tool3({
|
|
|
96561
96919
|
};
|
|
96562
96920
|
const effectiveProjectKey = args2.project_key || projectKey;
|
|
96563
96921
|
try {
|
|
96564
|
-
const
|
|
96922
|
+
const epicCreatedEvent = createEvent6("epic_created", {
|
|
96923
|
+
project_key: effectiveProjectKey,
|
|
96924
|
+
epic_id: epic.id,
|
|
96925
|
+
title: validated.epic_title,
|
|
96926
|
+
description: validated.epic_description,
|
|
96927
|
+
subtask_count: validated.subtasks.length,
|
|
96928
|
+
subtask_ids: created.slice(1).map((c) => c.id)
|
|
96929
|
+
});
|
|
96930
|
+
await appendEvent5(epicCreatedEvent, effectiveProjectKey);
|
|
96931
|
+
} catch (error54) {
|
|
96932
|
+
console.warn("[hive_create_epic] Failed to emit epic_created event:", error54);
|
|
96933
|
+
}
|
|
96934
|
+
try {
|
|
96935
|
+
const event = createEvent6("decomposition_generated", {
|
|
96565
96936
|
project_key: effectiveProjectKey,
|
|
96566
96937
|
epic_id: epic.id,
|
|
96567
96938
|
task: args2.task || validated.epic_title,
|
|
@@ -96581,7 +96952,7 @@ var hive_create_epic3 = tool3({
|
|
|
96581
96952
|
}
|
|
96582
96953
|
try {
|
|
96583
96954
|
const totalFiles = validated.subtasks.reduce((count, st) => count + (st.files?.length || 0), 0);
|
|
96584
|
-
const swarmStartedEvent =
|
|
96955
|
+
const swarmStartedEvent = createEvent6("swarm_started", {
|
|
96585
96956
|
project_key: effectiveProjectKey,
|
|
96586
96957
|
epic_id: epic.id,
|
|
96587
96958
|
epic_title: validated.epic_title,
|
|
@@ -96724,6 +97095,23 @@ var hive_update3 = tool3({
|
|
|
96724
97095
|
cell = existingCell;
|
|
96725
97096
|
}
|
|
96726
97097
|
await adapter.markDirty(projectKey, cellId);
|
|
97098
|
+
try {
|
|
97099
|
+
const fieldsChanged = [];
|
|
97100
|
+
if (validated.status)
|
|
97101
|
+
fieldsChanged.push("status");
|
|
97102
|
+
if (validated.description !== undefined)
|
|
97103
|
+
fieldsChanged.push("description");
|
|
97104
|
+
if (validated.priority !== undefined)
|
|
97105
|
+
fieldsChanged.push("priority");
|
|
97106
|
+
const event = createEvent6("cell_updated", {
|
|
97107
|
+
project_key: projectKey,
|
|
97108
|
+
cell_id: cellId,
|
|
97109
|
+
fields_changed: fieldsChanged
|
|
97110
|
+
});
|
|
97111
|
+
await appendEvent5(event, projectKey);
|
|
97112
|
+
} catch (error54) {
|
|
97113
|
+
console.warn("[hive_update] Failed to emit cell_updated event:", error54);
|
|
97114
|
+
}
|
|
96727
97115
|
const formatted = formatCellForOutput3(cell);
|
|
96728
97116
|
return JSON.stringify(formatted, null, 2);
|
|
96729
97117
|
} catch (error54) {
|
|
@@ -96756,7 +97144,7 @@ var hive_close3 = tool3({
|
|
|
96756
97144
|
await adapter.markDirty(projectKey, cellId);
|
|
96757
97145
|
if (isEpic && cellBeforeClose) {
|
|
96758
97146
|
try {
|
|
96759
|
-
const { createEvent:
|
|
97147
|
+
const { createEvent: createEvent5, appendEvent: appendEvent4 } = await import("swarm-mail");
|
|
96760
97148
|
const subtasks = await adapter.queryCells(projectKey, { parent_id: cellId });
|
|
96761
97149
|
const completedSubtasks = subtasks.filter((st) => st.status === "closed");
|
|
96762
97150
|
const failedSubtasks = subtasks.filter((st) => st.status === "blocked");
|
|
@@ -96794,7 +97182,7 @@ var hive_close3 = tool3({
|
|
|
96794
97182
|
} catch (error54) {
|
|
96795
97183
|
console.warn("[hive_close] Failed to calculate duration:", error54);
|
|
96796
97184
|
}
|
|
96797
|
-
const swarmCompletedEvent =
|
|
97185
|
+
const swarmCompletedEvent = createEvent5("swarm_completed", {
|
|
96798
97186
|
project_key: projectKey,
|
|
96799
97187
|
epic_id: cellId,
|
|
96800
97188
|
epic_title: cellBeforeClose.title,
|
|
@@ -96840,6 +97228,16 @@ var hive_close3 = tool3({
|
|
|
96840
97228
|
console.warn("[hive_close] Failed to emit SwarmCompletedEvent:", error54);
|
|
96841
97229
|
}
|
|
96842
97230
|
}
|
|
97231
|
+
try {
|
|
97232
|
+
const event = createEvent6("cell_closed", {
|
|
97233
|
+
project_key: projectKey,
|
|
97234
|
+
cell_id: cellId,
|
|
97235
|
+
reason: validated.reason
|
|
97236
|
+
});
|
|
97237
|
+
await appendEvent5(event, projectKey);
|
|
97238
|
+
} catch (error54) {
|
|
97239
|
+
console.warn("[hive_close] Failed to emit cell_closed event:", error54);
|
|
97240
|
+
}
|
|
96843
97241
|
return `Closed ${cell.id}: ${validated.reason}`;
|
|
96844
97242
|
} catch (error54) {
|
|
96845
97243
|
const message = error54 instanceof Error ? error54.message : String(error54);
|
|
@@ -96865,6 +97263,17 @@ var hive_start3 = tool3({
|
|
|
96865
97263
|
const cellId = await resolvePartialId3(adapter, projectKey, args2.id) || args2.id;
|
|
96866
97264
|
const cell = await adapter.changeCellStatus(projectKey, cellId, "in_progress");
|
|
96867
97265
|
await adapter.markDirty(projectKey, cellId);
|
|
97266
|
+
try {
|
|
97267
|
+
const event = createEvent6("cell_status_changed", {
|
|
97268
|
+
project_key: projectKey,
|
|
97269
|
+
cell_id: cellId,
|
|
97270
|
+
old_status: "open",
|
|
97271
|
+
new_status: "in_progress"
|
|
97272
|
+
});
|
|
97273
|
+
await appendEvent5(event, projectKey);
|
|
97274
|
+
} catch (error54) {
|
|
97275
|
+
console.warn("[hive_start] Failed to emit cell_status_changed event:", error54);
|
|
97276
|
+
}
|
|
96868
97277
|
return `Started: ${cell.id}`;
|
|
96869
97278
|
} catch (error54) {
|
|
96870
97279
|
const message = error54 instanceof Error ? error54.message : String(error54);
|
|
@@ -96994,7 +97403,7 @@ var hive_sync3 = tool3({
|
|
|
96994
97403
|
outputPath: `${projectKey}/.hive/issues.jsonl`
|
|
96995
97404
|
});
|
|
96996
97405
|
const flushResult = await withTimeout(flushManager.flush(), TIMEOUT_MS, "flush hive");
|
|
96997
|
-
const swarmMail = await
|
|
97406
|
+
const swarmMail = await getSwarmMailLibSQL7(projectKey);
|
|
96998
97407
|
const db = await swarmMail.getDatabase();
|
|
96999
97408
|
const hivePath = join13(projectKey, ".hive");
|
|
97000
97409
|
let memoriesSynced = 0;
|
|
@@ -97053,11 +97462,25 @@ var hive_sync3 = tool3({
|
|
|
97053
97462
|
}
|
|
97054
97463
|
const remoteCheckResult = await runGitCommand3(["remote"]);
|
|
97055
97464
|
const hasRemote = remoteCheckResult.stdout.trim() !== "";
|
|
97465
|
+
let pushSuccess = false;
|
|
97056
97466
|
if (hasRemote) {
|
|
97057
97467
|
const pushResult = await withTimeout(runGitCommand3(["push"]), TIMEOUT_MS, "git push");
|
|
97058
97468
|
if (pushResult.exitCode !== 0) {
|
|
97059
97469
|
throw new HiveError3(`Failed to push: ${pushResult.stderr}`, "git push", pushResult.exitCode);
|
|
97060
97470
|
}
|
|
97471
|
+
pushSuccess = true;
|
|
97472
|
+
}
|
|
97473
|
+
try {
|
|
97474
|
+
const event = createEvent6("hive_synced", {
|
|
97475
|
+
project_key: projectKey,
|
|
97476
|
+
cells_synced: flushResult.cellsExported,
|
|
97477
|
+
push_success: pushSuccess
|
|
97478
|
+
});
|
|
97479
|
+
await appendEvent5(event, projectKey);
|
|
97480
|
+
} catch (error54) {
|
|
97481
|
+
console.warn("[hive_sync] Failed to emit hive_synced event:", error54);
|
|
97482
|
+
}
|
|
97483
|
+
if (hasRemote) {
|
|
97061
97484
|
return "Hive synced and pushed successfully";
|
|
97062
97485
|
} else {
|
|
97063
97486
|
return "Hive synced successfully (no remote configured)";
|
|
@@ -101637,9 +102060,9 @@ import {
|
|
|
101637
102060
|
releaseSwarmFiles as releaseSwarmFiles3,
|
|
101638
102061
|
sendSwarmMessage as sendSwarmMessage6,
|
|
101639
102062
|
getAgent as getAgent2,
|
|
101640
|
-
createEvent as
|
|
102063
|
+
createEvent as createEvent8,
|
|
101641
102064
|
appendEvent as appendEvent6,
|
|
101642
|
-
getSwarmMailLibSQL as
|
|
102065
|
+
getSwarmMailLibSQL as getSwarmMailLibSQL9
|
|
101643
102066
|
} from "swarm-mail";
|
|
101644
102067
|
init_skills2();
|
|
101645
102068
|
|
|
@@ -102142,9 +102565,9 @@ var swarm_review2 = tool3({
|
|
|
102142
102565
|
downstream_tasks: downstreamTasks.length > 0 ? downstreamTasks : undefined
|
|
102143
102566
|
});
|
|
102144
102567
|
try {
|
|
102145
|
-
const { createEvent:
|
|
102568
|
+
const { createEvent: createEvent5, appendEvent: appendEvent4 } = await import("swarm-mail");
|
|
102146
102569
|
const attempt = getReviewStatus2(args2.task_id).attempt_count || 1;
|
|
102147
|
-
const reviewStartedEvent =
|
|
102570
|
+
const reviewStartedEvent = createEvent5("review_started", {
|
|
102148
102571
|
project_key: args2.project_key,
|
|
102149
102572
|
epic_id: args2.epic_id,
|
|
102150
102573
|
bead_id: args2.task_id,
|
|
@@ -102233,9 +102656,9 @@ var swarm_review_feedback2 = tool3({
|
|
|
102233
102656
|
console.warn("[swarm_review_feedback] Failed to trace review_decision:", error54);
|
|
102234
102657
|
}
|
|
102235
102658
|
try {
|
|
102236
|
-
const { createEvent:
|
|
102659
|
+
const { createEvent: createEvent5, appendEvent: appendEvent4 } = await import("swarm-mail");
|
|
102237
102660
|
const attempt = getReviewStatus2(args2.task_id).attempt_count || 1;
|
|
102238
|
-
const reviewCompletedEvent =
|
|
102661
|
+
const reviewCompletedEvent = createEvent5("review_completed", {
|
|
102239
102662
|
project_key: args2.project_key,
|
|
102240
102663
|
epic_id: epicId,
|
|
102241
102664
|
bead_id: args2.task_id,
|
|
@@ -102304,9 +102727,9 @@ You may now complete the task with \`swarm_complete\`.`,
|
|
|
102304
102727
|
console.warn("[swarm_review_feedback] Failed to trace review_decision:", error54);
|
|
102305
102728
|
}
|
|
102306
102729
|
try {
|
|
102307
|
-
const { createEvent:
|
|
102730
|
+
const { createEvent: createEvent5, appendEvent: appendEvent4 } = await import("swarm-mail");
|
|
102308
102731
|
const status = remaining <= 0 ? "blocked" : "needs_changes";
|
|
102309
|
-
const reviewCompletedEvent =
|
|
102732
|
+
const reviewCompletedEvent = createEvent5("review_completed", {
|
|
102310
102733
|
project_key: args2.project_key,
|
|
102311
102734
|
epic_id: epicId,
|
|
102312
102735
|
bead_id: args2.task_id,
|
|
@@ -102862,7 +103285,7 @@ var swarm_progress2 = tool3({
|
|
|
102862
103285
|
}
|
|
102863
103286
|
};
|
|
102864
103287
|
const checkpointData = JSON.stringify(checkpoint);
|
|
102865
|
-
const checkpointEvent =
|
|
103288
|
+
const checkpointEvent = createEvent8("swarm_checkpointed", {
|
|
102866
103289
|
project_key: args2.project_key,
|
|
102867
103290
|
...checkpoint,
|
|
102868
103291
|
checkpoint_size_bytes: Buffer.byteLength(checkpointData, "utf8"),
|
|
@@ -102870,7 +103293,7 @@ var swarm_progress2 = tool3({
|
|
|
102870
103293
|
});
|
|
102871
103294
|
await appendEvent6(checkpointEvent, args2.project_key);
|
|
102872
103295
|
const checkpointId = `ckpt-${Date.now()}-${args2.bead_id}`;
|
|
102873
|
-
const createdEvent =
|
|
103296
|
+
const createdEvent = createEvent8("checkpoint_created", {
|
|
102874
103297
|
project_key: args2.project_key,
|
|
102875
103298
|
epic_id: epicId,
|
|
102876
103299
|
bead_id: args2.bead_id,
|
|
@@ -103123,7 +103546,7 @@ This will be recorded as a negative learning signal.`;
|
|
|
103123
103546
|
let deferredResolved = false;
|
|
103124
103547
|
let deferredError;
|
|
103125
103548
|
try {
|
|
103126
|
-
const swarmMail = await
|
|
103549
|
+
const swarmMail = await getSwarmMailLibSQL9(args2.project_key);
|
|
103127
103550
|
const db = await swarmMail.getDatabase();
|
|
103128
103551
|
const deferredUrl = `deferred:${args2.bead_id}`;
|
|
103129
103552
|
const checkResult = await db.query(`SELECT url, resolved FROM deferred WHERE url = ? AND resolved = 0`, [deferredUrl]);
|
|
@@ -103152,16 +103575,16 @@ This will be recorded as a negative learning signal.`;
|
|
|
103152
103575
|
syncError = error54 instanceof Error ? error54.message : String(error54);
|
|
103153
103576
|
console.warn(`[swarm_complete] Auto-sync failed (non-fatal): ${syncError}`);
|
|
103154
103577
|
}
|
|
103578
|
+
const completionDurationMs = args2.start_time ? Date.now() - args2.start_time : 0;
|
|
103579
|
+
const eventEpicId = cell.parent_id || (args2.bead_id.includes(".") ? args2.bead_id.split(".")[0] : args2.bead_id);
|
|
103155
103580
|
try {
|
|
103156
|
-
const
|
|
103157
|
-
const eventEpicId = cell.parent_id || (args2.bead_id.includes(".") ? args2.bead_id.split(".")[0] : args2.bead_id);
|
|
103158
|
-
const event = createEvent6("subtask_outcome", {
|
|
103581
|
+
const event = createEvent8("subtask_outcome", {
|
|
103159
103582
|
project_key: args2.project_key,
|
|
103160
103583
|
epic_id: eventEpicId,
|
|
103161
103584
|
bead_id: args2.bead_id,
|
|
103162
103585
|
planned_files: args2.planned_files || [],
|
|
103163
103586
|
actual_files: args2.files_touched || [],
|
|
103164
|
-
duration_ms:
|
|
103587
|
+
duration_ms: completionDurationMs,
|
|
103165
103588
|
error_count: args2.error_count || 0,
|
|
103166
103589
|
retry_count: args2.retry_count || 0,
|
|
103167
103590
|
success: true,
|
|
@@ -103172,8 +103595,21 @@ This will be recorded as a negative learning signal.`;
|
|
|
103172
103595
|
} catch (error54) {
|
|
103173
103596
|
console.warn("[swarm_complete] Failed to emit SubtaskOutcomeEvent:", error54);
|
|
103174
103597
|
}
|
|
103598
|
+
try {
|
|
103599
|
+
const workerCompletedEvent = createEvent8("worker_completed", {
|
|
103600
|
+
project_key: args2.project_key,
|
|
103601
|
+
epic_id: eventEpicId,
|
|
103602
|
+
bead_id: args2.bead_id,
|
|
103603
|
+
worker_agent: args2.agent_name,
|
|
103604
|
+
success: true,
|
|
103605
|
+
duration_ms: completionDurationMs,
|
|
103606
|
+
files_touched: args2.files_touched || []
|
|
103607
|
+
});
|
|
103608
|
+
await appendEvent6(workerCompletedEvent, args2.project_key);
|
|
103609
|
+
} catch (error54) {
|
|
103610
|
+
console.warn("[swarm_complete] Failed to emit worker_completed event:", error54);
|
|
103611
|
+
}
|
|
103175
103612
|
let capturedStrategy;
|
|
103176
|
-
const durationMs = args2.start_time ? Date.now() - args2.start_time : 0;
|
|
103177
103613
|
const memoryInfo = formatMemoryStoreOnSuccess2(args2.bead_id, args2.summary, args2.files_touched || [], capturedStrategy);
|
|
103178
103614
|
let memoryStored = false;
|
|
103179
103615
|
let memoryError;
|
|
@@ -103290,7 +103726,7 @@ Files touched: ${args2.files_touched?.join(", ") || "none recorded"}`,
|
|
|
103290
103726
|
};
|
|
103291
103727
|
try {
|
|
103292
103728
|
const { captureSubtaskOutcome: captureSubtaskOutcome4 } = await Promise.resolve().then(() => (init_eval_capture3(), exports_eval_capture3));
|
|
103293
|
-
const
|
|
103729
|
+
const durationMs = args2.start_time ? Date.now() - args2.start_time : 0;
|
|
103294
103730
|
const evalEpicId = cell.parent_id || epicId2;
|
|
103295
103731
|
captureSubtaskOutcome4({
|
|
103296
103732
|
epicId: evalEpicId,
|
|
@@ -103299,7 +103735,7 @@ Files touched: ${args2.files_touched?.join(", ") || "none recorded"}`,
|
|
|
103299
103735
|
title: cell.title,
|
|
103300
103736
|
plannedFiles: args2.planned_files || [],
|
|
103301
103737
|
actualFiles: args2.files_touched || [],
|
|
103302
|
-
durationMs
|
|
103738
|
+
durationMs,
|
|
103303
103739
|
errorCount: args2.error_count || 0,
|
|
103304
103740
|
retryCount: args2.retry_count || 0,
|
|
103305
103741
|
success: true
|
|
@@ -103308,7 +103744,7 @@ Files touched: ${args2.files_touched?.join(", ") || "none recorded"}`,
|
|
|
103308
103744
|
console.warn("[swarm_complete] Failed to capture subtask outcome:", error54);
|
|
103309
103745
|
}
|
|
103310
103746
|
try {
|
|
103311
|
-
const
|
|
103747
|
+
const durationMs = args2.start_time ? Date.now() - args2.start_time : 0;
|
|
103312
103748
|
captureCoordinatorEvent4({
|
|
103313
103749
|
session_id: _ctx.sessionID || "unknown",
|
|
103314
103750
|
epic_id: epicId2,
|
|
@@ -103317,7 +103753,7 @@ Files touched: ${args2.files_touched?.join(", ") || "none recorded"}`,
|
|
|
103317
103753
|
outcome_type: "subtask_success",
|
|
103318
103754
|
payload: {
|
|
103319
103755
|
bead_id: args2.bead_id,
|
|
103320
|
-
duration_ms:
|
|
103756
|
+
duration_ms: durationMs,
|
|
103321
103757
|
files_touched: args2.files_touched || [],
|
|
103322
103758
|
verification_passed: verificationResult?.passed ?? false,
|
|
103323
103759
|
verification_skipped: args2.skip_verification ?? false
|
|
@@ -103791,7 +104227,7 @@ var swarm_checkpoint2 = tool3({
|
|
|
103791
104227
|
}
|
|
103792
104228
|
};
|
|
103793
104229
|
const checkpointData = JSON.stringify(checkpoint);
|
|
103794
|
-
const event =
|
|
104230
|
+
const event = createEvent8("swarm_checkpointed", {
|
|
103795
104231
|
project_key: args2.project_key,
|
|
103796
104232
|
epic_id: args2.epic_id,
|
|
103797
104233
|
bead_id: args2.bead_id,
|
|
@@ -103833,8 +104269,8 @@ var swarm_recover2 = tool3({
|
|
|
103833
104269
|
},
|
|
103834
104270
|
async execute(args2) {
|
|
103835
104271
|
try {
|
|
103836
|
-
const { getSwarmMailLibSQL:
|
|
103837
|
-
const swarmMail = await
|
|
104272
|
+
const { getSwarmMailLibSQL: getSwarmMailLibSQL5 } = await import("swarm-mail");
|
|
104273
|
+
const swarmMail = await getSwarmMailLibSQL5(args2.project_key);
|
|
103838
104274
|
const db = await swarmMail.getDatabase();
|
|
103839
104275
|
const result = await db.query(`SELECT * FROM swarm_contexts
|
|
103840
104276
|
WHERE epic_id = $1
|
|
@@ -103861,7 +104297,7 @@ var swarm_recover2 = tool3({
|
|
|
103861
104297
|
created_at: row.created_at,
|
|
103862
104298
|
updated_at: row.updated_at
|
|
103863
104299
|
};
|
|
103864
|
-
const event =
|
|
104300
|
+
const event = createEvent8("swarm_recovered", {
|
|
103865
104301
|
project_key: args2.project_key,
|
|
103866
104302
|
epic_id: args2.epic_id,
|
|
103867
104303
|
bead_id: context4.bead_id,
|
|
@@ -104036,7 +104472,7 @@ init_eval_capture3();
|
|
|
104036
104472
|
|
|
104037
104473
|
// src/memory-tools.ts
|
|
104038
104474
|
init_dist2();
|
|
104039
|
-
import { getSwarmMailLibSQL as
|
|
104475
|
+
import { getSwarmMailLibSQL as getSwarmMailLibSQL10, createEvent as createEvent9, appendEvent as appendEvent7 } from "swarm-mail";
|
|
104040
104476
|
|
|
104041
104477
|
// ../../node_modules/.bun/effect@3.19.12/node_modules/effect/dist/esm/Function.js
|
|
104042
104478
|
var isFunction3 = (input) => typeof input === "function";
|
|
@@ -117653,7 +118089,7 @@ async function getMemoryAdapter2(projectPath) {
|
|
|
117653
118089
|
if (cachedAdapter2 && cachedProjectPath2 === path4) {
|
|
117654
118090
|
return cachedAdapter2;
|
|
117655
118091
|
}
|
|
117656
|
-
const swarmMail = await
|
|
118092
|
+
const swarmMail = await getSwarmMailLibSQL10(path4);
|
|
117657
118093
|
const dbAdapter = await swarmMail.getDatabase();
|
|
117658
118094
|
cachedAdapter2 = await createMemoryAdapter2(dbAdapter);
|
|
117659
118095
|
cachedProjectPath2 = path4;
|
|
@@ -117674,6 +118110,21 @@ var semantic_memory_store2 = tool3({
|
|
|
117674
118110
|
async execute(args3, ctx) {
|
|
117675
118111
|
const adapter = await getMemoryAdapter2();
|
|
117676
118112
|
const result = await adapter.store(args3);
|
|
118113
|
+
try {
|
|
118114
|
+
const projectKey = cachedProjectPath2 || process.cwd();
|
|
118115
|
+
const tags = args3.tags ? args3.tags.split(",").map((t) => t.trim()) : [];
|
|
118116
|
+
const event = createEvent9("memory_stored", {
|
|
118117
|
+
project_key: projectKey,
|
|
118118
|
+
memory_id: result.id,
|
|
118119
|
+
content_preview: args3.information.slice(0, 100),
|
|
118120
|
+
tags,
|
|
118121
|
+
auto_tagged: args3.autoTag,
|
|
118122
|
+
collection: args3.collection
|
|
118123
|
+
});
|
|
118124
|
+
await appendEvent7(event, projectKey);
|
|
118125
|
+
} catch (error54) {
|
|
118126
|
+
console.warn("[semantic_memory_store] Failed to emit memory_stored event:", error54);
|
|
118127
|
+
}
|
|
117677
118128
|
return JSON.stringify(result, null, 2);
|
|
117678
118129
|
}
|
|
117679
118130
|
});
|
|
@@ -117687,8 +118138,25 @@ var semantic_memory_find2 = tool3({
|
|
|
117687
118138
|
fts: tool3.schema.boolean().optional().describe("Use full-text search instead of vector search (default: false)")
|
|
117688
118139
|
},
|
|
117689
118140
|
async execute(args3, ctx) {
|
|
118141
|
+
const startTime = Date.now();
|
|
117690
118142
|
const adapter = await getMemoryAdapter2();
|
|
117691
118143
|
const result = await adapter.find(args3);
|
|
118144
|
+
const duration4 = Date.now() - startTime;
|
|
118145
|
+
try {
|
|
118146
|
+
const projectKey = cachedProjectPath2 || process.cwd();
|
|
118147
|
+
const topScore = result.results.length > 0 ? result.results[0].score : undefined;
|
|
118148
|
+
const event = createEvent9("memory_found", {
|
|
118149
|
+
project_key: projectKey,
|
|
118150
|
+
query: args3.query,
|
|
118151
|
+
result_count: result.results.length,
|
|
118152
|
+
top_score: topScore,
|
|
118153
|
+
search_duration_ms: duration4,
|
|
118154
|
+
used_fts: args3.fts
|
|
118155
|
+
});
|
|
118156
|
+
await appendEvent7(event, projectKey);
|
|
118157
|
+
} catch (error54) {
|
|
118158
|
+
console.warn("[semantic_memory_find] Failed to emit memory_found event:", error54);
|
|
118159
|
+
}
|
|
117692
118160
|
return JSON.stringify(result, null, 2);
|
|
117693
118161
|
}
|
|
117694
118162
|
});
|
|
@@ -117711,6 +118179,18 @@ var semantic_memory_remove2 = tool3({
|
|
|
117711
118179
|
async execute(args3, ctx) {
|
|
117712
118180
|
const adapter = await getMemoryAdapter2();
|
|
117713
118181
|
const result = await adapter.remove(args3);
|
|
118182
|
+
if (result.success) {
|
|
118183
|
+
try {
|
|
118184
|
+
const projectKey = cachedProjectPath2 || process.cwd();
|
|
118185
|
+
const event = createEvent9("memory_deleted", {
|
|
118186
|
+
project_key: projectKey,
|
|
118187
|
+
memory_id: args3.id
|
|
118188
|
+
});
|
|
118189
|
+
await appendEvent7(event, projectKey);
|
|
118190
|
+
} catch (error54) {
|
|
118191
|
+
console.warn("[semantic_memory_remove] Failed to emit memory_deleted event:", error54);
|
|
118192
|
+
}
|
|
118193
|
+
}
|
|
117714
118194
|
return JSON.stringify(result, null, 2);
|
|
117715
118195
|
}
|
|
117716
118196
|
});
|
|
@@ -117722,6 +118202,19 @@ var semantic_memory_validate2 = tool3({
|
|
|
117722
118202
|
async execute(args3, ctx) {
|
|
117723
118203
|
const adapter = await getMemoryAdapter2();
|
|
117724
118204
|
const result = await adapter.validate(args3);
|
|
118205
|
+
if (result.success) {
|
|
118206
|
+
try {
|
|
118207
|
+
const projectKey = cachedProjectPath2 || process.cwd();
|
|
118208
|
+
const event = createEvent9("memory_validated", {
|
|
118209
|
+
project_key: projectKey,
|
|
118210
|
+
memory_id: args3.id,
|
|
118211
|
+
decay_reset: true
|
|
118212
|
+
});
|
|
118213
|
+
await appendEvent7(event, projectKey);
|
|
118214
|
+
} catch (error54) {
|
|
118215
|
+
console.warn("[semantic_memory_validate] Failed to emit memory_validated event:", error54);
|
|
118216
|
+
}
|
|
118217
|
+
}
|
|
117725
118218
|
return JSON.stringify(result, null, 2);
|
|
117726
118219
|
}
|
|
117727
118220
|
});
|
|
@@ -117769,6 +118262,18 @@ var semantic_memory_upsert2 = tool3({
|
|
|
117769
118262
|
async execute(args3, ctx) {
|
|
117770
118263
|
const adapter = await getMemoryAdapter2();
|
|
117771
118264
|
const result = await adapter.upsert(args3);
|
|
118265
|
+
try {
|
|
118266
|
+
const projectKey = cachedProjectPath2 || process.cwd();
|
|
118267
|
+
const event = createEvent9("memory_updated", {
|
|
118268
|
+
project_key: projectKey,
|
|
118269
|
+
memory_id: result.memoryId || "unknown",
|
|
118270
|
+
operation: result.operation,
|
|
118271
|
+
reason: result.reason
|
|
118272
|
+
});
|
|
118273
|
+
await appendEvent7(event, projectKey);
|
|
118274
|
+
} catch (error54) {
|
|
118275
|
+
console.warn("[semantic_memory_upsert] Failed to emit memory_updated event:", error54);
|
|
118276
|
+
}
|
|
117772
118277
|
return JSON.stringify(result, null, 2);
|
|
117773
118278
|
}
|
|
117774
118279
|
});
|
|
@@ -118754,9 +119259,9 @@ var swarm_spawn_subtask2 = tool3({
|
|
|
118754
119259
|
}
|
|
118755
119260
|
if (args3.project_path) {
|
|
118756
119261
|
try {
|
|
118757
|
-
const { createEvent:
|
|
119262
|
+
const { createEvent: createEvent5, appendEvent: appendEvent4 } = await import("swarm-mail");
|
|
118758
119263
|
const spawnOrder = 0;
|
|
118759
|
-
const workerSpawnedEvent =
|
|
119264
|
+
const workerSpawnedEvent = createEvent5("worker_spawned", {
|
|
118760
119265
|
project_key: args3.project_path,
|
|
118761
119266
|
epic_id: args3.epic_id,
|
|
118762
119267
|
bead_id: args3.bead_id,
|
|
@@ -120398,7 +120903,7 @@ import {
|
|
|
120398
120903
|
agentActivity as agentActivity2,
|
|
120399
120904
|
checkpointFrequency as checkpointFrequency2,
|
|
120400
120905
|
failedDecompositions as failedDecompositions2,
|
|
120401
|
-
getSwarmMailLibSQL as
|
|
120906
|
+
getSwarmMailLibSQL as getSwarmMailLibSQL11,
|
|
120402
120907
|
humanFeedback as humanFeedback2,
|
|
120403
120908
|
lockContention as lockContention2,
|
|
120404
120909
|
messageLatency as messageLatency2,
|
|
@@ -120463,7 +120968,7 @@ var swarm_analytics2 = tool3({
|
|
|
120463
120968
|
async execute(args3) {
|
|
120464
120969
|
try {
|
|
120465
120970
|
const projectPath = process.cwd();
|
|
120466
|
-
const db = await
|
|
120971
|
+
const db = await getSwarmMailLibSQL11(projectPath);
|
|
120467
120972
|
const filters = {
|
|
120468
120973
|
project_key: projectPath
|
|
120469
120974
|
};
|
|
@@ -120533,7 +121038,7 @@ var swarm_query2 = tool3({
|
|
|
120533
121038
|
async execute(args3) {
|
|
120534
121039
|
try {
|
|
120535
121040
|
const projectPath = process.cwd();
|
|
120536
|
-
const swarmMail = await
|
|
121041
|
+
const swarmMail = await getSwarmMailLibSQL11(projectPath);
|
|
120537
121042
|
const db = await swarmMail.getDatabase();
|
|
120538
121043
|
if (!args3.sql.trim().toLowerCase().startsWith("select")) {
|
|
120539
121044
|
return JSON.stringify({
|
|
@@ -120583,7 +121088,7 @@ var swarm_diagnose2 = tool3({
|
|
|
120583
121088
|
async execute(args3) {
|
|
120584
121089
|
try {
|
|
120585
121090
|
const projectPath = process.cwd();
|
|
120586
|
-
const swarmMail = await
|
|
121091
|
+
const swarmMail = await getSwarmMailLibSQL11(projectPath);
|
|
120587
121092
|
const db = await swarmMail.getDatabase();
|
|
120588
121093
|
const diagnosis = [];
|
|
120589
121094
|
const include = args3.include || [
|
|
@@ -120694,7 +121199,7 @@ var swarm_insights2 = tool3({
|
|
|
120694
121199
|
});
|
|
120695
121200
|
}
|
|
120696
121201
|
const projectPath = process.cwd();
|
|
120697
|
-
const swarmMail = await
|
|
121202
|
+
const swarmMail = await getSwarmMailLibSQL11(projectPath);
|
|
120698
121203
|
const db = await swarmMail.getDatabase();
|
|
120699
121204
|
const insights = [];
|
|
120700
121205
|
if (args3.metrics.includes("success_rate")) {
|
|
@@ -121183,6 +121688,268 @@ var contributorTools = {
|
|
|
121183
121688
|
contributor_lookup
|
|
121184
121689
|
};
|
|
121185
121690
|
|
|
121691
|
+
// src/cass-tools.ts
|
|
121692
|
+
init_dist2();
|
|
121693
|
+
import { execSync, spawn } from "child_process";
|
|
121694
|
+
import { getSwarmMailLibSQL as getSwarmMailLibSQL12, createEvent as createEvent10 } from "swarm-mail";
|
|
121695
|
+
function isCassAvailable() {
|
|
121696
|
+
try {
|
|
121697
|
+
execSync("which cass", { stdio: "ignore" });
|
|
121698
|
+
return true;
|
|
121699
|
+
} catch {
|
|
121700
|
+
return false;
|
|
121701
|
+
}
|
|
121702
|
+
}
|
|
121703
|
+
async function execCass(args3) {
|
|
121704
|
+
return new Promise((resolve3, reject) => {
|
|
121705
|
+
const proc = spawn("cass", args3, {
|
|
121706
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
121707
|
+
});
|
|
121708
|
+
let stdout = "";
|
|
121709
|
+
let stderr = "";
|
|
121710
|
+
proc.stdout.on("data", (data) => {
|
|
121711
|
+
stdout += data;
|
|
121712
|
+
});
|
|
121713
|
+
proc.stderr.on("data", (data) => {
|
|
121714
|
+
stderr += data;
|
|
121715
|
+
});
|
|
121716
|
+
proc.on("close", (code) => {
|
|
121717
|
+
if (code === 0) {
|
|
121718
|
+
resolve3(stdout);
|
|
121719
|
+
} else {
|
|
121720
|
+
reject(new Error(stderr || `cass exited with code ${code}`));
|
|
121721
|
+
}
|
|
121722
|
+
});
|
|
121723
|
+
proc.on("error", (err) => {
|
|
121724
|
+
if (err.code === "ENOENT") {
|
|
121725
|
+
reject(new Error("cass CLI not found. Install from: https://github.com/Dicklesworthstone/coding_agent_session_search"));
|
|
121726
|
+
} else {
|
|
121727
|
+
reject(err);
|
|
121728
|
+
}
|
|
121729
|
+
});
|
|
121730
|
+
});
|
|
121731
|
+
}
|
|
121732
|
+
async function emitEvent(eventType, data) {
|
|
121733
|
+
try {
|
|
121734
|
+
const projectPath = process.cwd();
|
|
121735
|
+
const swarmMail = await getSwarmMailLibSQL12(projectPath);
|
|
121736
|
+
const event = createEvent10(eventType, {
|
|
121737
|
+
project_key: projectPath,
|
|
121738
|
+
...data
|
|
121739
|
+
});
|
|
121740
|
+
await swarmMail.appendEvent(event);
|
|
121741
|
+
} catch {}
|
|
121742
|
+
}
|
|
121743
|
+
var cass_search = tool3({
|
|
121744
|
+
description: "Search across all AI coding agent histories (Claude, Codex, Cursor, Gemini, Aider, ChatGPT, Cline, OpenCode). Query BEFORE solving problems from scratch - another agent may have already solved it.",
|
|
121745
|
+
args: {
|
|
121746
|
+
query: tool3.schema.string().describe("Search query (e.g., 'authentication error Next.js')"),
|
|
121747
|
+
agent: tool3.schema.string().optional().describe("Filter by agent name (e.g., 'claude', 'cursor')"),
|
|
121748
|
+
days: tool3.schema.number().optional().describe("Only search sessions from last N days"),
|
|
121749
|
+
limit: tool3.schema.number().optional().describe("Max results to return (default: 5)"),
|
|
121750
|
+
fields: tool3.schema.string().optional().describe("Field selection: 'minimal' for compact output (path, line, agent only)")
|
|
121751
|
+
},
|
|
121752
|
+
async execute(args3) {
|
|
121753
|
+
const startTime = Date.now();
|
|
121754
|
+
if (!isCassAvailable()) {
|
|
121755
|
+
return JSON.stringify({
|
|
121756
|
+
error: "cass CLI not found. Install from: https://github.com/Dicklesworthstone/coding_agent_session_search"
|
|
121757
|
+
});
|
|
121758
|
+
}
|
|
121759
|
+
try {
|
|
121760
|
+
const cliArgs = ["search", args3.query];
|
|
121761
|
+
if (args3.agent) {
|
|
121762
|
+
cliArgs.push("--agent", args3.agent);
|
|
121763
|
+
}
|
|
121764
|
+
if (args3.days) {
|
|
121765
|
+
cliArgs.push("--days", String(args3.days));
|
|
121766
|
+
}
|
|
121767
|
+
if (args3.limit) {
|
|
121768
|
+
cliArgs.push("--limit", String(args3.limit));
|
|
121769
|
+
}
|
|
121770
|
+
if (args3.fields === "minimal") {
|
|
121771
|
+
cliArgs.push("--minimal");
|
|
121772
|
+
}
|
|
121773
|
+
const output = await execCass(cliArgs);
|
|
121774
|
+
const lines = output.trim().split(`
|
|
121775
|
+
`).filter((l2) => l2.trim());
|
|
121776
|
+
const resultCount = lines.length;
|
|
121777
|
+
await emitEvent("cass_searched", {
|
|
121778
|
+
query: args3.query,
|
|
121779
|
+
agent_filter: args3.agent,
|
|
121780
|
+
days_filter: args3.days,
|
|
121781
|
+
result_count: resultCount,
|
|
121782
|
+
search_duration_ms: Date.now() - startTime
|
|
121783
|
+
});
|
|
121784
|
+
return output;
|
|
121785
|
+
} catch (error54) {
|
|
121786
|
+
return JSON.stringify({
|
|
121787
|
+
error: error54 instanceof Error ? error54.message : String(error54)
|
|
121788
|
+
});
|
|
121789
|
+
}
|
|
121790
|
+
}
|
|
121791
|
+
});
|
|
121792
|
+
var cass_view = tool3({
|
|
121793
|
+
description: "View a specific conversation/session from search results. Use source_path from cass_search output.",
|
|
121794
|
+
args: {
|
|
121795
|
+
path: tool3.schema.string().describe("Path to session file (from cass_search results)"),
|
|
121796
|
+
line: tool3.schema.number().optional().describe("Jump to specific line number")
|
|
121797
|
+
},
|
|
121798
|
+
async execute(args3) {
|
|
121799
|
+
if (!isCassAvailable()) {
|
|
121800
|
+
return JSON.stringify({
|
|
121801
|
+
error: "cass CLI not found. Install from: https://github.com/Dicklesworthstone/coding_agent_session_search"
|
|
121802
|
+
});
|
|
121803
|
+
}
|
|
121804
|
+
try {
|
|
121805
|
+
const cliArgs = ["view", args3.path];
|
|
121806
|
+
if (args3.line) {
|
|
121807
|
+
cliArgs.push("--line", String(args3.line));
|
|
121808
|
+
}
|
|
121809
|
+
const output = await execCass(cliArgs);
|
|
121810
|
+
let agentType;
|
|
121811
|
+
if (args3.path.includes("claude"))
|
|
121812
|
+
agentType = "claude";
|
|
121813
|
+
else if (args3.path.includes("cursor"))
|
|
121814
|
+
agentType = "cursor";
|
|
121815
|
+
else if (args3.path.includes("opencode"))
|
|
121816
|
+
agentType = "opencode";
|
|
121817
|
+
else if (args3.path.includes("codex"))
|
|
121818
|
+
agentType = "codex";
|
|
121819
|
+
await emitEvent("cass_viewed", {
|
|
121820
|
+
session_path: args3.path,
|
|
121821
|
+
line_number: args3.line,
|
|
121822
|
+
agent_type: agentType
|
|
121823
|
+
});
|
|
121824
|
+
return output;
|
|
121825
|
+
} catch (error54) {
|
|
121826
|
+
return JSON.stringify({
|
|
121827
|
+
error: error54 instanceof Error ? error54.message : String(error54)
|
|
121828
|
+
});
|
|
121829
|
+
}
|
|
121830
|
+
}
|
|
121831
|
+
});
|
|
121832
|
+
var cass_expand = tool3({
|
|
121833
|
+
description: "Expand context around a specific line in a session. Shows messages before/after.",
|
|
121834
|
+
args: {
|
|
121835
|
+
path: tool3.schema.string().describe("Path to session file"),
|
|
121836
|
+
line: tool3.schema.number().describe("Line number to expand around"),
|
|
121837
|
+
context: tool3.schema.number().optional().describe("Number of lines before/after to show (default: 5)")
|
|
121838
|
+
},
|
|
121839
|
+
async execute(args3) {
|
|
121840
|
+
if (!isCassAvailable()) {
|
|
121841
|
+
return JSON.stringify({
|
|
121842
|
+
error: "cass CLI not found. Install from: https://github.com/Dicklesworthstone/coding_agent_session_search"
|
|
121843
|
+
});
|
|
121844
|
+
}
|
|
121845
|
+
try {
|
|
121846
|
+
const cliArgs = ["expand", args3.path, "--line", String(args3.line)];
|
|
121847
|
+
if (args3.context) {
|
|
121848
|
+
cliArgs.push("--context", String(args3.context));
|
|
121849
|
+
}
|
|
121850
|
+
const output = await execCass(cliArgs);
|
|
121851
|
+
await emitEvent("cass_viewed", {
|
|
121852
|
+
session_path: args3.path,
|
|
121853
|
+
line_number: args3.line
|
|
121854
|
+
});
|
|
121855
|
+
return output;
|
|
121856
|
+
} catch (error54) {
|
|
121857
|
+
return JSON.stringify({
|
|
121858
|
+
error: error54 instanceof Error ? error54.message : String(error54)
|
|
121859
|
+
});
|
|
121860
|
+
}
|
|
121861
|
+
}
|
|
121862
|
+
});
|
|
121863
|
+
var cass_health = tool3({
|
|
121864
|
+
description: "Check if cass index is healthy. Exit 0 = ready, Exit 1 = needs indexing. Run this before searching.",
|
|
121865
|
+
args: {},
|
|
121866
|
+
async execute() {
|
|
121867
|
+
if (!isCassAvailable()) {
|
|
121868
|
+
return JSON.stringify({
|
|
121869
|
+
healthy: false,
|
|
121870
|
+
error: "cass CLI not found. Install from: https://github.com/Dicklesworthstone/coding_agent_session_search"
|
|
121871
|
+
});
|
|
121872
|
+
}
|
|
121873
|
+
try {
|
|
121874
|
+
await execCass(["health"]);
|
|
121875
|
+
return JSON.stringify({ healthy: true, message: "Index is ready" });
|
|
121876
|
+
} catch (error54) {
|
|
121877
|
+
return JSON.stringify({
|
|
121878
|
+
healthy: false,
|
|
121879
|
+
message: "Index needs rebuilding. Run cass_index()",
|
|
121880
|
+
error: error54 instanceof Error ? error54.message : String(error54)
|
|
121881
|
+
});
|
|
121882
|
+
}
|
|
121883
|
+
}
|
|
121884
|
+
});
|
|
121885
|
+
var cass_index = tool3({
|
|
121886
|
+
description: "Build or rebuild the search index. Run this if health check fails or to pick up new sessions.",
|
|
121887
|
+
args: {
|
|
121888
|
+
full: tool3.schema.boolean().optional().describe("Force full rebuild (default: incremental)")
|
|
121889
|
+
},
|
|
121890
|
+
async execute(args3) {
|
|
121891
|
+
const startTime = Date.now();
|
|
121892
|
+
if (!isCassAvailable()) {
|
|
121893
|
+
return JSON.stringify({
|
|
121894
|
+
error: "cass CLI not found. Install from: https://github.com/Dicklesworthstone/coding_agent_session_search"
|
|
121895
|
+
});
|
|
121896
|
+
}
|
|
121897
|
+
try {
|
|
121898
|
+
const cliArgs = ["index"];
|
|
121899
|
+
if (args3.full) {
|
|
121900
|
+
cliArgs.push("--full");
|
|
121901
|
+
}
|
|
121902
|
+
const output = await execCass(cliArgs);
|
|
121903
|
+
let sessionsIndexed = 0;
|
|
121904
|
+
let messagesIndexed = 0;
|
|
121905
|
+
const sessionsMatch = output.match(/(\d+)\s*sessions?/i);
|
|
121906
|
+
const messagesMatch = output.match(/(\d+)\s*messages?/i);
|
|
121907
|
+
if (sessionsMatch)
|
|
121908
|
+
sessionsIndexed = parseInt(sessionsMatch[1], 10);
|
|
121909
|
+
if (messagesMatch)
|
|
121910
|
+
messagesIndexed = parseInt(messagesMatch[1], 10);
|
|
121911
|
+
await emitEvent("cass_indexed", {
|
|
121912
|
+
sessions_indexed: sessionsIndexed,
|
|
121913
|
+
messages_indexed: messagesIndexed,
|
|
121914
|
+
duration_ms: Date.now() - startTime,
|
|
121915
|
+
full_rebuild: args3.full ?? false
|
|
121916
|
+
});
|
|
121917
|
+
return output;
|
|
121918
|
+
} catch (error54) {
|
|
121919
|
+
return JSON.stringify({
|
|
121920
|
+
error: error54 instanceof Error ? error54.message : String(error54)
|
|
121921
|
+
});
|
|
121922
|
+
}
|
|
121923
|
+
}
|
|
121924
|
+
});
|
|
121925
|
+
var cass_stats = tool3({
|
|
121926
|
+
description: "Show index statistics - how many sessions, messages, agents indexed.",
|
|
121927
|
+
args: {},
|
|
121928
|
+
async execute() {
|
|
121929
|
+
if (!isCassAvailable()) {
|
|
121930
|
+
return JSON.stringify({
|
|
121931
|
+
error: "cass CLI not found. Install from: https://github.com/Dicklesworthstone/coding_agent_session_search"
|
|
121932
|
+
});
|
|
121933
|
+
}
|
|
121934
|
+
try {
|
|
121935
|
+
const output = await execCass(["stats"]);
|
|
121936
|
+
return output;
|
|
121937
|
+
} catch (error54) {
|
|
121938
|
+
return JSON.stringify({
|
|
121939
|
+
error: error54 instanceof Error ? error54.message : String(error54)
|
|
121940
|
+
});
|
|
121941
|
+
}
|
|
121942
|
+
}
|
|
121943
|
+
});
|
|
121944
|
+
var cassTools = {
|
|
121945
|
+
cass_search,
|
|
121946
|
+
cass_view,
|
|
121947
|
+
cass_expand,
|
|
121948
|
+
cass_health,
|
|
121949
|
+
cass_index,
|
|
121950
|
+
cass_stats
|
|
121951
|
+
};
|
|
121952
|
+
|
|
121186
121953
|
// src/planning-guardrails.ts
|
|
121187
121954
|
init_eval_capture3();
|
|
121188
121955
|
|
|
@@ -121386,7 +122153,8 @@ var allTools = {
|
|
|
121386
122153
|
...mandateTools,
|
|
121387
122154
|
...memoryTools,
|
|
121388
122155
|
...observabilityTools,
|
|
121389
|
-
...contributorTools
|
|
122156
|
+
...contributorTools,
|
|
122157
|
+
...cassTools
|
|
121390
122158
|
};
|
|
121391
122159
|
|
|
121392
122160
|
// bin/swarm.ts
|
|
@@ -124277,7 +125045,7 @@ async function cells() {
|
|
|
124277
125045
|
}
|
|
124278
125046
|
const projectPath = process.cwd();
|
|
124279
125047
|
try {
|
|
124280
|
-
const swarmMail = await
|
|
125048
|
+
const swarmMail = await getSwarmMailLibSQL13(projectPath);
|
|
124281
125049
|
const db = await swarmMail.getDatabase();
|
|
124282
125050
|
const adapter = createHiveAdapter4(db, projectPath);
|
|
124283
125051
|
await adapter.runMigrations();
|
|
@@ -124533,7 +125301,7 @@ async function db() {
|
|
|
124533
125301
|
const sizeKB = Math.round(stats.size / 1024);
|
|
124534
125302
|
console.log(` ${green("\u2713")} Database exists (${sizeKB} KB)`);
|
|
124535
125303
|
try {
|
|
124536
|
-
const schema =
|
|
125304
|
+
const schema = execSync2(`sqlite3 "${dbFile}" "SELECT sql FROM sqlite_master WHERE type='table' AND name='beads'"`, { encoding: "utf-8" }).trim();
|
|
124537
125305
|
if (schema) {
|
|
124538
125306
|
const hasProjectKey = schema.includes("project_key");
|
|
124539
125307
|
if (hasProjectKey) {
|
|
@@ -124548,7 +125316,7 @@ async function db() {
|
|
|
124548
125316
|
console.log(` ${dim("\u25CB")} No beads table yet (will be created on first use)`);
|
|
124549
125317
|
}
|
|
124550
125318
|
try {
|
|
124551
|
-
const version5 =
|
|
125319
|
+
const version5 = execSync2(`sqlite3 "${dbFile}" "SELECT MAX(version) FROM schema_version"`, { encoding: "utf-8" }).trim();
|
|
124552
125320
|
if (version5 && version5 !== "") {
|
|
124553
125321
|
console.log(` ${dim("\u25CB")} Schema version: ${version5}`);
|
|
124554
125322
|
}
|
|
@@ -124556,11 +125324,11 @@ async function db() {
|
|
|
124556
125324
|
console.log(` ${dim("\u25CB")} No schema_version table`);
|
|
124557
125325
|
}
|
|
124558
125326
|
try {
|
|
124559
|
-
const beadCount =
|
|
125327
|
+
const beadCount = execSync2(`sqlite3 "${dbFile}" "SELECT COUNT(*) FROM beads"`, { encoding: "utf-8" }).trim();
|
|
124560
125328
|
console.log(` ${dim("\u25CB")} Cells: ${beadCount}`);
|
|
124561
125329
|
} catch {}
|
|
124562
125330
|
try {
|
|
124563
|
-
const memoryCount =
|
|
125331
|
+
const memoryCount = execSync2(`sqlite3 "${dbFile}" "SELECT COUNT(*) FROM memories"`, { encoding: "utf-8" }).trim();
|
|
124564
125332
|
console.log(` ${dim("\u25CB")} Memories: ${memoryCount}`);
|
|
124565
125333
|
} catch {}
|
|
124566
125334
|
} catch (error54) {
|
|
@@ -124691,7 +125459,7 @@ async function stats() {
|
|
|
124691
125459
|
}
|
|
124692
125460
|
try {
|
|
124693
125461
|
const projectPath = process.cwd();
|
|
124694
|
-
const swarmMail = await
|
|
125462
|
+
const swarmMail = await getSwarmMailLibSQL13(projectPath);
|
|
124695
125463
|
const db2 = await swarmMail.getDatabase();
|
|
124696
125464
|
const since = parseTimePeriod(period);
|
|
124697
125465
|
const periodMatch = period.match(/^(\d+)([dhm])$/);
|
|
@@ -124997,7 +125765,7 @@ async function serve() {
|
|
|
124997
125765
|
M2.message(dim(` Project: ${projectPath}`));
|
|
124998
125766
|
M2.message(dim(` Port: ${port} (HIVE on phone keypad)`));
|
|
124999
125767
|
try {
|
|
125000
|
-
const swarmMail = await
|
|
125768
|
+
const swarmMail = await getSwarmMailLibSQL13(projectPath);
|
|
125001
125769
|
const streamAdapter = createDurableStreamAdapter(swarmMail, projectPath);
|
|
125002
125770
|
const db2 = await swarmMail.getDatabase(projectPath);
|
|
125003
125771
|
const hiveAdapter = createHiveAdapter4(db2, projectPath);
|
|
@@ -125032,7 +125800,7 @@ async function viz() {
|
|
|
125032
125800
|
M2.message(dim(` Project: ${projectPath}`));
|
|
125033
125801
|
M2.message(dim(` Port: ${port}`));
|
|
125034
125802
|
try {
|
|
125035
|
-
const swarmMail = await
|
|
125803
|
+
const swarmMail = await getSwarmMailLibSQL13(projectPath);
|
|
125036
125804
|
const streamAdapter = createDurableStreamAdapter(swarmMail, projectPath);
|
|
125037
125805
|
const db2 = await swarmMail.getDatabase(projectPath);
|
|
125038
125806
|
const hiveAdapter = createHiveAdapter4(db2, projectPath);
|