opencode-swarm-plugin 0.23.5 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +34 -0
- package/README.md +155 -3
- package/bin/swarm.ts +497 -187
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +668 -91
- package/dist/plugin.js +596 -91
- package/dist/schemas/bead-events.d.ts +698 -0
- package/dist/schemas/bead-events.d.ts.map +1 -0
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/skills.d.ts.map +1 -1
- package/dist/swarm-decompose.d.ts +74 -0
- package/dist/swarm-decompose.d.ts.map +1 -1
- package/dist/swarm-orchestrate.d.ts.map +1 -1
- package/dist/swarm-prompts.d.ts +1 -1
- package/dist/swarm-prompts.d.ts.map +1 -1
- package/dist/swarm.d.ts +27 -0
- package/dist/swarm.d.ts.map +1 -1
- package/docs/testing/context-recovery-test.md +470 -0
- package/examples/commands/swarm.md +92 -20
- package/global-skills/swarm-coordination/SKILL.md +380 -10
- package/package.json +2 -2
- package/src/schemas/bead-events.test.ts +341 -0
- package/src/schemas/bead-events.ts +583 -0
- package/src/schemas/index.ts +51 -0
- package/src/skills.ts +10 -3
- package/src/swarm-decompose.ts +337 -0
- package/src/swarm-orchestrate.ts +72 -55
- package/src/swarm-prompts.ts +144 -42
- package/src/swarm.integration.test.ts +581 -31
package/dist/index.js
CHANGED
|
@@ -16973,7 +16973,7 @@ WD9f
|
|
|
16973
16973
|
|
|
16974
16974
|
// ../../node_modules/.bun/ioredis@5.8.2/node_modules/ioredis/built/utils/index.js
|
|
16975
16975
|
var require_utils2 = __commonJS((exports) => {
|
|
16976
|
-
var __dirname = "/home/runner/work/
|
|
16976
|
+
var __dirname = "/home/runner/work/swarm-tools/swarm-tools/node_modules/.bun/ioredis@5.8.2/node_modules/ioredis/built/utils";
|
|
16977
16977
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16978
16978
|
exports.noop = exports.defaults = exports.Debug = exports.getPackageMeta = exports.zipMap = exports.CONNECTION_CLOSED_ERROR_MSG = exports.shuffle = exports.sample = exports.resolveTLSProfile = exports.parseURL = exports.optimizeErrorStack = exports.toArg = exports.convertMapToArray = exports.convertObjectToArray = exports.timeout = exports.packObject = exports.isInt = exports.wrapMultiResult = exports.convertBufferToString = undefined;
|
|
16979
16979
|
var fs_1 = __require("fs");
|
|
@@ -17203,7 +17203,7 @@ var require_utils2 = __commonJS((exports) => {
|
|
|
17203
17203
|
|
|
17204
17204
|
// ../../node_modules/.bun/ioredis@5.8.2/node_modules/ioredis/built/Command.js
|
|
17205
17205
|
var require_Command = __commonJS((exports) => {
|
|
17206
|
-
var __dirname = "/home/runner/work/
|
|
17206
|
+
var __dirname = "/home/runner/work/swarm-tools/swarm-tools/node_modules/.bun/ioredis@5.8.2/node_modules/ioredis/built";
|
|
17207
17207
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17208
17208
|
var commands_1 = require_built();
|
|
17209
17209
|
var calculateSlot = require_lib();
|
|
@@ -26174,6 +26174,7 @@ import {
|
|
|
26174
26174
|
isAbsolute,
|
|
26175
26175
|
sep
|
|
26176
26176
|
} from "path";
|
|
26177
|
+
import { fileURLToPath } from "url";
|
|
26177
26178
|
function setSkillsProjectDirectory(dir) {
|
|
26178
26179
|
skillsProjectDirectory = dir;
|
|
26179
26180
|
skillsCache = null;
|
|
@@ -26220,8 +26221,13 @@ function getClaudeGlobalSkillsDir() {
|
|
|
26220
26221
|
return join4(home, ".claude", "skills");
|
|
26221
26222
|
}
|
|
26222
26223
|
function getPackageSkillsDir() {
|
|
26223
|
-
|
|
26224
|
-
|
|
26224
|
+
try {
|
|
26225
|
+
const currentFilePath = fileURLToPath(import.meta.url);
|
|
26226
|
+
return join4(dirname2(currentFilePath), "..", "global-skills");
|
|
26227
|
+
} catch {
|
|
26228
|
+
const currentDir = decodeURIComponent(new URL(".", import.meta.url).pathname);
|
|
26229
|
+
return join4(currentDir, "..", "global-skills");
|
|
26230
|
+
}
|
|
26225
26231
|
}
|
|
26226
26232
|
async function findSkillFiles(baseDir) {
|
|
26227
26233
|
const skillFiles = [];
|
|
@@ -27422,6 +27428,228 @@ var QuerySwarmContextsArgsSchema = exports_external.object({
|
|
|
27422
27428
|
strategy: SwarmStrategySchema.optional(),
|
|
27423
27429
|
has_errors: exports_external.boolean().optional()
|
|
27424
27430
|
});
|
|
27431
|
+
// src/schemas/bead-events.ts
|
|
27432
|
+
init_zod();
|
|
27433
|
+
var BaseBeadEventSchema = exports_external.object({
|
|
27434
|
+
id: exports_external.number().optional(),
|
|
27435
|
+
type: exports_external.string(),
|
|
27436
|
+
project_key: exports_external.string(),
|
|
27437
|
+
timestamp: exports_external.number(),
|
|
27438
|
+
sequence: exports_external.number().optional()
|
|
27439
|
+
});
|
|
27440
|
+
var BeadCreatedEventSchema = BaseBeadEventSchema.extend({
|
|
27441
|
+
type: exports_external.literal("bead_created"),
|
|
27442
|
+
bead_id: exports_external.string(),
|
|
27443
|
+
title: exports_external.string(),
|
|
27444
|
+
description: exports_external.string().optional(),
|
|
27445
|
+
issue_type: BeadTypeSchema,
|
|
27446
|
+
priority: exports_external.number().int().min(0).max(3),
|
|
27447
|
+
parent_id: exports_external.string().optional(),
|
|
27448
|
+
created_by: exports_external.string().optional(),
|
|
27449
|
+
metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
27450
|
+
});
|
|
27451
|
+
var BeadUpdatedEventSchema = BaseBeadEventSchema.extend({
|
|
27452
|
+
type: exports_external.literal("bead_updated"),
|
|
27453
|
+
bead_id: exports_external.string(),
|
|
27454
|
+
updated_by: exports_external.string().optional(),
|
|
27455
|
+
changes: exports_external.object({
|
|
27456
|
+
title: exports_external.object({
|
|
27457
|
+
old: exports_external.string(),
|
|
27458
|
+
new: exports_external.string()
|
|
27459
|
+
}).optional(),
|
|
27460
|
+
description: exports_external.object({
|
|
27461
|
+
old: exports_external.string(),
|
|
27462
|
+
new: exports_external.string()
|
|
27463
|
+
}).optional(),
|
|
27464
|
+
priority: exports_external.object({
|
|
27465
|
+
old: exports_external.number(),
|
|
27466
|
+
new: exports_external.number()
|
|
27467
|
+
}).optional()
|
|
27468
|
+
})
|
|
27469
|
+
});
|
|
27470
|
+
var BeadStatusChangedEventSchema = BaseBeadEventSchema.extend({
|
|
27471
|
+
type: exports_external.literal("bead_status_changed"),
|
|
27472
|
+
bead_id: exports_external.string(),
|
|
27473
|
+
from_status: BeadStatusSchema,
|
|
27474
|
+
to_status: BeadStatusSchema,
|
|
27475
|
+
changed_by: exports_external.string().optional(),
|
|
27476
|
+
reason: exports_external.string().optional()
|
|
27477
|
+
});
|
|
27478
|
+
var BeadClosedEventSchema = BaseBeadEventSchema.extend({
|
|
27479
|
+
type: exports_external.literal("bead_closed"),
|
|
27480
|
+
bead_id: exports_external.string(),
|
|
27481
|
+
reason: exports_external.string(),
|
|
27482
|
+
closed_by: exports_external.string().optional(),
|
|
27483
|
+
files_touched: exports_external.array(exports_external.string()).optional(),
|
|
27484
|
+
duration_ms: exports_external.number().optional()
|
|
27485
|
+
});
|
|
27486
|
+
var BeadReopenedEventSchema = BaseBeadEventSchema.extend({
|
|
27487
|
+
type: exports_external.literal("bead_reopened"),
|
|
27488
|
+
bead_id: exports_external.string(),
|
|
27489
|
+
reason: exports_external.string().optional(),
|
|
27490
|
+
reopened_by: exports_external.string().optional()
|
|
27491
|
+
});
|
|
27492
|
+
var BeadDeletedEventSchema = BaseBeadEventSchema.extend({
|
|
27493
|
+
type: exports_external.literal("bead_deleted"),
|
|
27494
|
+
bead_id: exports_external.string(),
|
|
27495
|
+
reason: exports_external.string().optional(),
|
|
27496
|
+
deleted_by: exports_external.string().optional()
|
|
27497
|
+
});
|
|
27498
|
+
var BeadDependencyAddedEventSchema = BaseBeadEventSchema.extend({
|
|
27499
|
+
type: exports_external.literal("bead_dependency_added"),
|
|
27500
|
+
bead_id: exports_external.string(),
|
|
27501
|
+
dependency: BeadDependencySchema,
|
|
27502
|
+
added_by: exports_external.string().optional(),
|
|
27503
|
+
reason: exports_external.string().optional()
|
|
27504
|
+
});
|
|
27505
|
+
var BeadDependencyRemovedEventSchema = BaseBeadEventSchema.extend({
|
|
27506
|
+
type: exports_external.literal("bead_dependency_removed"),
|
|
27507
|
+
bead_id: exports_external.string(),
|
|
27508
|
+
dependency: BeadDependencySchema,
|
|
27509
|
+
removed_by: exports_external.string().optional(),
|
|
27510
|
+
reason: exports_external.string().optional()
|
|
27511
|
+
});
|
|
27512
|
+
var BeadLabelAddedEventSchema = BaseBeadEventSchema.extend({
|
|
27513
|
+
type: exports_external.literal("bead_label_added"),
|
|
27514
|
+
bead_id: exports_external.string(),
|
|
27515
|
+
label: exports_external.string(),
|
|
27516
|
+
added_by: exports_external.string().optional()
|
|
27517
|
+
});
|
|
27518
|
+
var BeadLabelRemovedEventSchema = BaseBeadEventSchema.extend({
|
|
27519
|
+
type: exports_external.literal("bead_label_removed"),
|
|
27520
|
+
bead_id: exports_external.string(),
|
|
27521
|
+
label: exports_external.string(),
|
|
27522
|
+
removed_by: exports_external.string().optional()
|
|
27523
|
+
});
|
|
27524
|
+
var BeadCommentAddedEventSchema = BaseBeadEventSchema.extend({
|
|
27525
|
+
type: exports_external.literal("bead_comment_added"),
|
|
27526
|
+
bead_id: exports_external.string(),
|
|
27527
|
+
comment_id: exports_external.number().optional(),
|
|
27528
|
+
author: exports_external.string(),
|
|
27529
|
+
body: exports_external.string(),
|
|
27530
|
+
parent_comment_id: exports_external.number().optional(),
|
|
27531
|
+
metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
27532
|
+
});
|
|
27533
|
+
var BeadCommentUpdatedEventSchema = BaseBeadEventSchema.extend({
|
|
27534
|
+
type: exports_external.literal("bead_comment_updated"),
|
|
27535
|
+
bead_id: exports_external.string(),
|
|
27536
|
+
comment_id: exports_external.number(),
|
|
27537
|
+
old_body: exports_external.string(),
|
|
27538
|
+
new_body: exports_external.string(),
|
|
27539
|
+
updated_by: exports_external.string()
|
|
27540
|
+
});
|
|
27541
|
+
var BeadCommentDeletedEventSchema = BaseBeadEventSchema.extend({
|
|
27542
|
+
type: exports_external.literal("bead_comment_deleted"),
|
|
27543
|
+
bead_id: exports_external.string(),
|
|
27544
|
+
comment_id: exports_external.number(),
|
|
27545
|
+
deleted_by: exports_external.string(),
|
|
27546
|
+
reason: exports_external.string().optional()
|
|
27547
|
+
});
|
|
27548
|
+
var BeadEpicChildAddedEventSchema = BaseBeadEventSchema.extend({
|
|
27549
|
+
type: exports_external.literal("bead_epic_child_added"),
|
|
27550
|
+
bead_id: exports_external.string(),
|
|
27551
|
+
child_id: exports_external.string(),
|
|
27552
|
+
child_index: exports_external.number().optional(),
|
|
27553
|
+
added_by: exports_external.string().optional()
|
|
27554
|
+
});
|
|
27555
|
+
var BeadEpicChildRemovedEventSchema = BaseBeadEventSchema.extend({
|
|
27556
|
+
type: exports_external.literal("bead_epic_child_removed"),
|
|
27557
|
+
bead_id: exports_external.string(),
|
|
27558
|
+
child_id: exports_external.string(),
|
|
27559
|
+
removed_by: exports_external.string().optional(),
|
|
27560
|
+
reason: exports_external.string().optional()
|
|
27561
|
+
});
|
|
27562
|
+
var BeadEpicClosureEligibleEventSchema = BaseBeadEventSchema.extend({
|
|
27563
|
+
type: exports_external.literal("bead_epic_closure_eligible"),
|
|
27564
|
+
bead_id: exports_external.string(),
|
|
27565
|
+
child_ids: exports_external.array(exports_external.string()),
|
|
27566
|
+
total_duration_ms: exports_external.number().optional(),
|
|
27567
|
+
all_files_touched: exports_external.array(exports_external.string()).optional()
|
|
27568
|
+
});
|
|
27569
|
+
var BeadAssignedEventSchema = BaseBeadEventSchema.extend({
|
|
27570
|
+
type: exports_external.literal("bead_assigned"),
|
|
27571
|
+
bead_id: exports_external.string(),
|
|
27572
|
+
agent_name: exports_external.string(),
|
|
27573
|
+
task_description: exports_external.string().optional()
|
|
27574
|
+
});
|
|
27575
|
+
var BeadWorkStartedEventSchema = BaseBeadEventSchema.extend({
|
|
27576
|
+
type: exports_external.literal("bead_work_started"),
|
|
27577
|
+
bead_id: exports_external.string(),
|
|
27578
|
+
agent_name: exports_external.string(),
|
|
27579
|
+
reserved_files: exports_external.array(exports_external.string()).optional()
|
|
27580
|
+
});
|
|
27581
|
+
var BeadCompactedEventSchema = BaseBeadEventSchema.extend({
|
|
27582
|
+
type: exports_external.literal("bead_compacted"),
|
|
27583
|
+
bead_id: exports_external.string(),
|
|
27584
|
+
events_archived: exports_external.number(),
|
|
27585
|
+
new_start_sequence: exports_external.number()
|
|
27586
|
+
});
|
|
27587
|
+
var BeadEventSchema = exports_external.discriminatedUnion("type", [
|
|
27588
|
+
BeadCreatedEventSchema,
|
|
27589
|
+
BeadUpdatedEventSchema,
|
|
27590
|
+
BeadStatusChangedEventSchema,
|
|
27591
|
+
BeadClosedEventSchema,
|
|
27592
|
+
BeadReopenedEventSchema,
|
|
27593
|
+
BeadDeletedEventSchema,
|
|
27594
|
+
BeadDependencyAddedEventSchema,
|
|
27595
|
+
BeadDependencyRemovedEventSchema,
|
|
27596
|
+
BeadLabelAddedEventSchema,
|
|
27597
|
+
BeadLabelRemovedEventSchema,
|
|
27598
|
+
BeadCommentAddedEventSchema,
|
|
27599
|
+
BeadCommentUpdatedEventSchema,
|
|
27600
|
+
BeadCommentDeletedEventSchema,
|
|
27601
|
+
BeadEpicChildAddedEventSchema,
|
|
27602
|
+
BeadEpicChildRemovedEventSchema,
|
|
27603
|
+
BeadEpicClosureEligibleEventSchema,
|
|
27604
|
+
BeadAssignedEventSchema,
|
|
27605
|
+
BeadWorkStartedEventSchema,
|
|
27606
|
+
BeadCompactedEventSchema
|
|
27607
|
+
]);
|
|
27608
|
+
function createBeadEvent(type, data) {
|
|
27609
|
+
const event = {
|
|
27610
|
+
type,
|
|
27611
|
+
timestamp: Date.now(),
|
|
27612
|
+
...data
|
|
27613
|
+
};
|
|
27614
|
+
const result = BeadEventSchema.safeParse(event);
|
|
27615
|
+
if (!result.success) {
|
|
27616
|
+
throw new Error(`Invalid bead event: ${result.error.message}`);
|
|
27617
|
+
}
|
|
27618
|
+
return result.data;
|
|
27619
|
+
}
|
|
27620
|
+
function isBeadEventType(event, type) {
|
|
27621
|
+
return event.type === type;
|
|
27622
|
+
}
|
|
27623
|
+
function getBeadIdFromEvent(event) {
|
|
27624
|
+
return event.bead_id;
|
|
27625
|
+
}
|
|
27626
|
+
function isStateTransitionEvent(event) {
|
|
27627
|
+
return event.type === "bead_status_changed" || event.type === "bead_closed" || event.type === "bead_reopened";
|
|
27628
|
+
}
|
|
27629
|
+
function isEpicEvent(event) {
|
|
27630
|
+
return event.type === "bead_epic_child_added" || event.type === "bead_epic_child_removed" || event.type === "bead_epic_closure_eligible";
|
|
27631
|
+
}
|
|
27632
|
+
function isAgentEvent(event) {
|
|
27633
|
+
if ("agent_name" in event)
|
|
27634
|
+
return true;
|
|
27635
|
+
const actorFields = [
|
|
27636
|
+
"created_by",
|
|
27637
|
+
"updated_by",
|
|
27638
|
+
"changed_by",
|
|
27639
|
+
"closed_by",
|
|
27640
|
+
"deleted_by",
|
|
27641
|
+
"added_by",
|
|
27642
|
+
"removed_by",
|
|
27643
|
+
"reopened_by"
|
|
27644
|
+
];
|
|
27645
|
+
return actorFields.some((field) => {
|
|
27646
|
+
if (field in event) {
|
|
27647
|
+
const value = event[field];
|
|
27648
|
+
return typeof value === "string" && /^[a-z]+$/i.test(value);
|
|
27649
|
+
}
|
|
27650
|
+
return false;
|
|
27651
|
+
});
|
|
27652
|
+
}
|
|
27425
27653
|
// src/beads.ts
|
|
27426
27654
|
import { createEvent, appendEvent } from "swarm-mail";
|
|
27427
27655
|
var beadsWorkingDirectory = null;
|
|
@@ -30694,10 +30922,222 @@ class DecompositionError extends SwarmError {
|
|
|
30694
30922
|
this.zodError = zodError;
|
|
30695
30923
|
}
|
|
30696
30924
|
}
|
|
30925
|
+
var swarm_plan_interactive = tool({
|
|
30926
|
+
description: "Interactive planning phase with Socratic questioning before decomposition. Supports multiple modes from full interactive to auto-proceed.",
|
|
30927
|
+
args: {
|
|
30928
|
+
task: tool.schema.string().min(1).describe("The task to plan"),
|
|
30929
|
+
mode: tool.schema.enum(["socratic", "fast", "auto", "confirm-only"]).default("socratic").describe("Planning mode: socratic (full), fast (skip questions), auto (minimal), confirm-only (single yes/no)"),
|
|
30930
|
+
context: tool.schema.string().optional().describe("Optional additional context about the task"),
|
|
30931
|
+
user_response: tool.schema.string().optional().describe("User's response to a previous question (for multi-turn socratic mode)"),
|
|
30932
|
+
phase: tool.schema.enum(["questioning", "alternatives", "recommendation", "ready"]).optional().describe("Current planning phase (for resuming multi-turn interaction)")
|
|
30933
|
+
},
|
|
30934
|
+
async execute(args) {
|
|
30935
|
+
const { selectStrategy: selectStrategy2, formatStrategyGuidelines: formatStrategyGuidelines2, STRATEGIES: STRATEGIES2 } = await Promise.resolve().then(() => (init_swarm_strategies(), exports_swarm_strategies));
|
|
30936
|
+
const { formatMemoryQueryForDecomposition: formatMemoryQueryForDecomposition2 } = await Promise.resolve().then(() => (init_learning(), exports_learning));
|
|
30937
|
+
const currentPhase = args.phase || "questioning";
|
|
30938
|
+
const mode = args.mode || "socratic";
|
|
30939
|
+
let memoryContext = "";
|
|
30940
|
+
let codebaseContext = {};
|
|
30941
|
+
try {
|
|
30942
|
+
const memoryQuery = formatMemoryQueryForDecomposition2(args.task, 3);
|
|
30943
|
+
memoryContext = `[Memory Query Instruction]
|
|
30944
|
+
${memoryQuery.instruction}
|
|
30945
|
+
Query: "${memoryQuery.query}"
|
|
30946
|
+
Limit: ${memoryQuery.limit}`;
|
|
30947
|
+
} catch (error45) {
|
|
30948
|
+
console.warn("[swarm_plan_interactive] Memory query formatting failed:", error45);
|
|
30949
|
+
}
|
|
30950
|
+
try {
|
|
30951
|
+
const gitResult = await Bun.$`git status --short`.quiet().nothrow();
|
|
30952
|
+
if (gitResult.exitCode === 0) {
|
|
30953
|
+
codebaseContext.git_status = gitResult.stdout.toString().trim();
|
|
30954
|
+
}
|
|
30955
|
+
} catch (error45) {}
|
|
30956
|
+
if (mode === "fast") {
|
|
30957
|
+
const strategyResult = selectStrategy2(args.task);
|
|
30958
|
+
const guidelines = formatStrategyGuidelines2(strategyResult.strategy);
|
|
30959
|
+
const output = {
|
|
30960
|
+
mode: "fast",
|
|
30961
|
+
phase: "ready",
|
|
30962
|
+
recommendation: {
|
|
30963
|
+
approach: strategyResult.strategy,
|
|
30964
|
+
reasoning: `${strategyResult.reasoning}
|
|
30965
|
+
|
|
30966
|
+
${guidelines}`
|
|
30967
|
+
},
|
|
30968
|
+
memory_context: memoryContext || undefined,
|
|
30969
|
+
codebase_context: Object.keys(codebaseContext).length > 0 ? codebaseContext : undefined,
|
|
30970
|
+
ready_to_decompose: true,
|
|
30971
|
+
next_action: "Proceed to swarm_decompose or swarm_delegate_planning"
|
|
30972
|
+
};
|
|
30973
|
+
return JSON.stringify(output, null, 2);
|
|
30974
|
+
}
|
|
30975
|
+
if (mode === "auto") {
|
|
30976
|
+
const strategyResult = selectStrategy2(args.task);
|
|
30977
|
+
const output = {
|
|
30978
|
+
mode: "auto",
|
|
30979
|
+
phase: "ready",
|
|
30980
|
+
recommendation: {
|
|
30981
|
+
approach: strategyResult.strategy,
|
|
30982
|
+
reasoning: `Auto-selected based on task keywords: ${strategyResult.reasoning}`
|
|
30983
|
+
},
|
|
30984
|
+
memory_context: memoryContext || undefined,
|
|
30985
|
+
codebase_context: Object.keys(codebaseContext).length > 0 ? codebaseContext : undefined,
|
|
30986
|
+
ready_to_decompose: true,
|
|
30987
|
+
next_action: "Auto-proceeding to decomposition"
|
|
30988
|
+
};
|
|
30989
|
+
return JSON.stringify(output, null, 2);
|
|
30990
|
+
}
|
|
30991
|
+
if (mode === "confirm-only") {
|
|
30992
|
+
const output = {
|
|
30993
|
+
mode: "confirm-only",
|
|
30994
|
+
phase: "ready",
|
|
30995
|
+
recommendation: {
|
|
30996
|
+
approach: "Will generate decomposition for your review",
|
|
30997
|
+
reasoning: "Use swarm_delegate_planning to generate the plan, then present it for yes/no confirmation"
|
|
30998
|
+
},
|
|
30999
|
+
memory_context: memoryContext || undefined,
|
|
31000
|
+
codebase_context: Object.keys(codebaseContext).length > 0 ? codebaseContext : undefined,
|
|
31001
|
+
ready_to_decompose: false,
|
|
31002
|
+
next_action: "Call swarm_delegate_planning, then show result and ask for confirmation"
|
|
31003
|
+
};
|
|
31004
|
+
return JSON.stringify(output, null, 2);
|
|
31005
|
+
}
|
|
31006
|
+
if (currentPhase === "questioning") {
|
|
31007
|
+
const taskLower = args.task.toLowerCase();
|
|
31008
|
+
const questions = [];
|
|
31009
|
+
const isVague = {
|
|
31010
|
+
noFiles: !taskLower.includes("src/") && !taskLower.includes("file"),
|
|
31011
|
+
vagueVerb: taskLower.includes("improve") || taskLower.includes("fix") || taskLower.includes("update") || taskLower.includes("make better"),
|
|
31012
|
+
noSuccessCriteria: !taskLower.includes("test") && !taskLower.includes("verify")
|
|
31013
|
+
};
|
|
31014
|
+
if (isVague.noFiles) {
|
|
31015
|
+
questions.push({
|
|
31016
|
+
question: "Which part of the codebase should this change affect?",
|
|
31017
|
+
options: [
|
|
31018
|
+
"Core functionality (src/)",
|
|
31019
|
+
"UI components (components/)",
|
|
31020
|
+
"API routes (app/api/)",
|
|
31021
|
+
"Configuration and tooling",
|
|
31022
|
+
"Tests"
|
|
31023
|
+
]
|
|
31024
|
+
});
|
|
31025
|
+
} else if (isVague.vagueVerb) {
|
|
31026
|
+
questions.push({
|
|
31027
|
+
question: "What specific change are you looking for?",
|
|
31028
|
+
options: [
|
|
31029
|
+
"Add new functionality",
|
|
31030
|
+
"Modify existing behavior",
|
|
31031
|
+
"Remove/deprecate something",
|
|
31032
|
+
"Refactor without behavior change",
|
|
31033
|
+
"Fix a bug"
|
|
31034
|
+
]
|
|
31035
|
+
});
|
|
31036
|
+
} else if (isVague.noSuccessCriteria) {
|
|
31037
|
+
questions.push({
|
|
31038
|
+
question: "How will we know this task is complete?",
|
|
31039
|
+
options: [
|
|
31040
|
+
"All tests pass",
|
|
31041
|
+
"Feature works as demonstrated",
|
|
31042
|
+
"Code review approved",
|
|
31043
|
+
"Documentation updated",
|
|
31044
|
+
"Performance target met"
|
|
31045
|
+
]
|
|
31046
|
+
});
|
|
31047
|
+
}
|
|
31048
|
+
if (questions.length === 0) {
|
|
31049
|
+
const output2 = {
|
|
31050
|
+
mode: "socratic",
|
|
31051
|
+
phase: "alternatives",
|
|
31052
|
+
memory_context: memoryContext || undefined,
|
|
31053
|
+
codebase_context: Object.keys(codebaseContext).length > 0 ? codebaseContext : undefined,
|
|
31054
|
+
ready_to_decompose: false,
|
|
31055
|
+
next_action: "Task is clear. Call again with phase=alternatives to explore approaches"
|
|
31056
|
+
};
|
|
31057
|
+
return JSON.stringify(output2, null, 2);
|
|
31058
|
+
}
|
|
31059
|
+
const output = {
|
|
31060
|
+
mode: "socratic",
|
|
31061
|
+
phase: "questioning",
|
|
31062
|
+
questions: [questions[0]],
|
|
31063
|
+
memory_context: memoryContext || undefined,
|
|
31064
|
+
codebase_context: Object.keys(codebaseContext).length > 0 ? codebaseContext : undefined,
|
|
31065
|
+
ready_to_decompose: false,
|
|
31066
|
+
next_action: "User should answer this question, then call again with user_response"
|
|
31067
|
+
};
|
|
31068
|
+
return JSON.stringify(output, null, 2);
|
|
31069
|
+
}
|
|
31070
|
+
if (currentPhase === "alternatives") {
|
|
31071
|
+
const strategyResult = selectStrategy2(args.task);
|
|
31072
|
+
const alternatives = [];
|
|
31073
|
+
alternatives.push({
|
|
31074
|
+
name: strategyResult.strategy,
|
|
31075
|
+
description: strategyResult.reasoning,
|
|
31076
|
+
tradeoffs: `Confidence: ${(strategyResult.confidence * 100).toFixed(0)}%. ${STRATEGIES2[strategyResult.strategy].description}`
|
|
31077
|
+
});
|
|
31078
|
+
for (let i = 0;i < Math.min(2, strategyResult.alternatives.length); i++) {
|
|
31079
|
+
const alt = strategyResult.alternatives[i];
|
|
31080
|
+
alternatives.push({
|
|
31081
|
+
name: alt.strategy,
|
|
31082
|
+
description: STRATEGIES2[alt.strategy].description,
|
|
31083
|
+
tradeoffs: `Match score: ${alt.score}. ${STRATEGIES2[alt.strategy].antiPatterns[0] || "Consider trade-offs carefully"}`
|
|
31084
|
+
});
|
|
31085
|
+
}
|
|
31086
|
+
const output = {
|
|
31087
|
+
mode: "socratic",
|
|
31088
|
+
phase: "alternatives",
|
|
31089
|
+
alternatives,
|
|
31090
|
+
memory_context: memoryContext || undefined,
|
|
31091
|
+
codebase_context: Object.keys(codebaseContext).length > 0 ? codebaseContext : undefined,
|
|
31092
|
+
ready_to_decompose: false,
|
|
31093
|
+
next_action: "User should choose an approach, then call again with phase=recommendation"
|
|
31094
|
+
};
|
|
31095
|
+
return JSON.stringify(output, null, 2);
|
|
31096
|
+
}
|
|
31097
|
+
if (currentPhase === "recommendation") {
|
|
31098
|
+
const strategyResult = selectStrategy2(args.task);
|
|
31099
|
+
const guidelines = formatStrategyGuidelines2(strategyResult.strategy);
|
|
31100
|
+
const output = {
|
|
31101
|
+
mode: "socratic",
|
|
31102
|
+
phase: "recommendation",
|
|
31103
|
+
recommendation: {
|
|
31104
|
+
approach: strategyResult.strategy,
|
|
31105
|
+
reasoning: `Based on your input and task analysis:
|
|
31106
|
+
|
|
31107
|
+
${strategyResult.reasoning}
|
|
31108
|
+
|
|
31109
|
+
${guidelines}`
|
|
31110
|
+
},
|
|
31111
|
+
memory_context: memoryContext || undefined,
|
|
31112
|
+
codebase_context: Object.keys(codebaseContext).length > 0 ? codebaseContext : undefined,
|
|
31113
|
+
ready_to_decompose: false,
|
|
31114
|
+
next_action: "User should confirm to proceed. Then call again with phase=ready"
|
|
31115
|
+
};
|
|
31116
|
+
return JSON.stringify(output, null, 2);
|
|
31117
|
+
}
|
|
31118
|
+
if (currentPhase === "ready") {
|
|
31119
|
+
const output = {
|
|
31120
|
+
mode: "socratic",
|
|
31121
|
+
phase: "ready",
|
|
31122
|
+
recommendation: {
|
|
31123
|
+
approach: "Confirmed by user",
|
|
31124
|
+
reasoning: "Ready to proceed with decomposition"
|
|
31125
|
+
},
|
|
31126
|
+
memory_context: memoryContext || undefined,
|
|
31127
|
+
codebase_context: Object.keys(codebaseContext).length > 0 ? codebaseContext : undefined,
|
|
31128
|
+
ready_to_decompose: true,
|
|
31129
|
+
next_action: "Proceed to swarm_decompose or swarm_delegate_planning"
|
|
31130
|
+
};
|
|
31131
|
+
return JSON.stringify(output, null, 2);
|
|
31132
|
+
}
|
|
31133
|
+
throw new Error(`Invalid planning phase: ${currentPhase}`);
|
|
31134
|
+
}
|
|
31135
|
+
});
|
|
30697
31136
|
var decomposeTools = {
|
|
30698
31137
|
swarm_decompose,
|
|
30699
31138
|
swarm_validate_decomposition,
|
|
30700
|
-
swarm_delegate_planning
|
|
31139
|
+
swarm_delegate_planning,
|
|
31140
|
+
swarm_plan_interactive
|
|
30701
31141
|
};
|
|
30702
31142
|
// src/swarm-prompts.ts
|
|
30703
31143
|
init_dist();
|
|
@@ -30863,13 +31303,11 @@ Only modify these files. Need others? Message the coordinator.
|
|
|
30863
31303
|
|
|
30864
31304
|
{error_context}
|
|
30865
31305
|
|
|
30866
|
-
## [MANDATORY
|
|
30867
|
-
|
|
30868
|
-
**CRITICAL: YOU MUST INITIALIZE SWARM MAIL BEFORE DOING ANY WORK.**
|
|
31306
|
+
## [MANDATORY SURVIVAL CHECKLIST]
|
|
30869
31307
|
|
|
30870
|
-
|
|
31308
|
+
**CRITICAL: Follow this checklist IN ORDER. Each step builds on the previous.**
|
|
30871
31309
|
|
|
30872
|
-
### Step 1: Initialize (REQUIRED - DO THIS FIRST)
|
|
31310
|
+
### Step 1: Initialize Coordination (REQUIRED - DO THIS FIRST)
|
|
30873
31311
|
\`\`\`
|
|
30874
31312
|
swarmmail_init(project_path="{project_path}", task_description="{bead_id}: {subtask_title}")
|
|
30875
31313
|
\`\`\`
|
|
@@ -30882,26 +31320,124 @@ swarmmail_init(project_path="{project_path}", task_description="{bead_id}: {subt
|
|
|
30882
31320
|
|
|
30883
31321
|
**If you skip this step, your work will not be tracked and swarm_complete will fail.**
|
|
30884
31322
|
|
|
30885
|
-
|
|
31323
|
+
### Step 2: Query Past Learnings (BEFORE starting work)
|
|
31324
|
+
\`\`\`
|
|
31325
|
+
semantic-memory_find(query="<keywords from your task>", limit=5)
|
|
31326
|
+
\`\`\`
|
|
30886
31327
|
|
|
30887
|
-
|
|
31328
|
+
**Check if past agents solved similar problems.** Search for:
|
|
31329
|
+
- Error messages if debugging
|
|
31330
|
+
- Domain concepts (e.g., "authentication", "caching")
|
|
31331
|
+
- Technology stack (e.g., "Next.js", "React")
|
|
31332
|
+
- Patterns (e.g., "event sourcing", "validation")
|
|
30888
31333
|
|
|
30889
|
-
|
|
31334
|
+
**Past learnings save time and prevent repeating mistakes.**
|
|
31335
|
+
|
|
31336
|
+
### Step 3: Load Relevant Skills (if available)
|
|
30890
31337
|
\`\`\`
|
|
30891
|
-
|
|
30892
|
-
|
|
31338
|
+
skills_list() # See what skills exist
|
|
31339
|
+
skills_use(name="<relevant-skill>", context="<your task>") # Load skill
|
|
30893
31340
|
\`\`\`
|
|
30894
31341
|
|
|
30895
|
-
|
|
31342
|
+
**Common skill triggers:**
|
|
31343
|
+
- Writing tests? → \`skills_use(name="testing-patterns")\`
|
|
31344
|
+
- Breaking dependencies? → \`skills_use(name="testing-patterns")\`
|
|
31345
|
+
- Multi-agent coordination? → \`skills_use(name="swarm-coordination")\`
|
|
31346
|
+
- Building a CLI? → \`skills_use(name="cli-builder")\`
|
|
31347
|
+
|
|
31348
|
+
### Step 4: Reserve Your Files (YOU reserve, not coordinator)
|
|
30896
31349
|
\`\`\`
|
|
30897
|
-
|
|
30898
|
-
|
|
30899
|
-
|
|
30900
|
-
|
|
30901
|
-
|
|
31350
|
+
swarmmail_reserve(
|
|
31351
|
+
paths=[{file_list}],
|
|
31352
|
+
reason="{bead_id}: {subtask_title}",
|
|
31353
|
+
exclusive=true
|
|
31354
|
+
)
|
|
31355
|
+
\`\`\`
|
|
31356
|
+
|
|
31357
|
+
**Workers reserve their own files.** This prevents edit conflicts with other agents.
|
|
31358
|
+
|
|
31359
|
+
### Step 5: Do the Work
|
|
31360
|
+
- Read your assigned files
|
|
31361
|
+
- Implement changes
|
|
31362
|
+
- Verify (typecheck if applicable)
|
|
31363
|
+
|
|
31364
|
+
### Step 6: Report Progress at Milestones
|
|
31365
|
+
\`\`\`
|
|
31366
|
+
swarm_progress(
|
|
31367
|
+
project_key="{project_path}",
|
|
31368
|
+
agent_name="<your-agent-name>",
|
|
31369
|
+
bead_id="{bead_id}",
|
|
31370
|
+
status="in_progress",
|
|
31371
|
+
progress_percent=25, # or 50, 75
|
|
31372
|
+
message="<what you just completed>"
|
|
31373
|
+
)
|
|
31374
|
+
\`\`\`
|
|
31375
|
+
|
|
31376
|
+
**Report at 25%, 50%, 75% completion.** This:
|
|
31377
|
+
- Triggers auto-checkpoint (saves context)
|
|
31378
|
+
- Keeps coordinator informed
|
|
31379
|
+
- Prevents silent failures
|
|
31380
|
+
|
|
31381
|
+
### Step 7: Manual Checkpoint BEFORE Risky Operations
|
|
31382
|
+
\`\`\`
|
|
31383
|
+
swarm_checkpoint(
|
|
31384
|
+
project_key="{project_path}",
|
|
31385
|
+
agent_name="<your-agent-name>",
|
|
31386
|
+
bead_id="{bead_id}"
|
|
31387
|
+
)
|
|
31388
|
+
\`\`\`
|
|
31389
|
+
|
|
31390
|
+
**Call BEFORE:**
|
|
31391
|
+
- Large refactors
|
|
31392
|
+
- File deletions
|
|
31393
|
+
- Breaking API changes
|
|
31394
|
+
- Anything that might fail catastrophically
|
|
31395
|
+
|
|
31396
|
+
**Checkpoints preserve context so you can recover if things go wrong.**
|
|
31397
|
+
|
|
31398
|
+
### Step 8: Store Learnings (if you discovered something)
|
|
31399
|
+
\`\`\`
|
|
31400
|
+
semantic-memory_store(
|
|
31401
|
+
information="<what you learned, WHY it matters, how to apply it>",
|
|
31402
|
+
metadata="<tags: domain, tech-stack, pattern-type>"
|
|
30902
31403
|
)
|
|
30903
31404
|
\`\`\`
|
|
30904
31405
|
|
|
31406
|
+
**Store:**
|
|
31407
|
+
- Tricky bugs you solved (root cause + solution)
|
|
31408
|
+
- Project-specific patterns or domain rules
|
|
31409
|
+
- Tool/library gotchas and workarounds
|
|
31410
|
+
- Failed approaches (anti-patterns to avoid)
|
|
31411
|
+
|
|
31412
|
+
**Don't store generic knowledge.** Store the WHY, not just the WHAT.
|
|
31413
|
+
|
|
31414
|
+
### Step 9: Complete (REQUIRED - releases reservations)
|
|
31415
|
+
\`\`\`
|
|
31416
|
+
swarm_complete(
|
|
31417
|
+
project_key="{project_path}",
|
|
31418
|
+
agent_name="<your-agent-name>",
|
|
31419
|
+
bead_id="{bead_id}",
|
|
31420
|
+
summary="<what you accomplished>",
|
|
31421
|
+
files_touched=["list", "of", "files"]
|
|
31422
|
+
)
|
|
31423
|
+
\`\`\`
|
|
31424
|
+
|
|
31425
|
+
**This automatically:**
|
|
31426
|
+
- Runs UBS bug scan
|
|
31427
|
+
- Releases file reservations
|
|
31428
|
+
- Records learning signals
|
|
31429
|
+
- Notifies coordinator
|
|
31430
|
+
|
|
31431
|
+
**DO NOT manually close the bead with beads_close.** Use swarm_complete.
|
|
31432
|
+
|
|
31433
|
+
## [SWARM MAIL COMMUNICATION]
|
|
31434
|
+
|
|
31435
|
+
### Check Inbox Regularly
|
|
31436
|
+
\`\`\`
|
|
31437
|
+
swarmmail_inbox() # Check for coordinator messages
|
|
31438
|
+
swarmmail_read_message(message_id=N) # Read specific message
|
|
31439
|
+
\`\`\`
|
|
31440
|
+
|
|
30905
31441
|
### When Blocked
|
|
30906
31442
|
\`\`\`
|
|
30907
31443
|
swarmmail_send(
|
|
@@ -30914,42 +31450,48 @@ swarmmail_send(
|
|
|
30914
31450
|
beads_update(id="{bead_id}", status="blocked")
|
|
30915
31451
|
\`\`\`
|
|
30916
31452
|
|
|
30917
|
-
###
|
|
31453
|
+
### Report Issues to Other Agents
|
|
30918
31454
|
\`\`\`
|
|
30919
|
-
|
|
31455
|
+
swarmmail_send(
|
|
31456
|
+
to=["OtherAgent", "coordinator"],
|
|
31457
|
+
subject="Issue in {bead_id}",
|
|
31458
|
+
body="<describe problem, don't fix their code>",
|
|
31459
|
+
thread_id="{epic_id}"
|
|
31460
|
+
)
|
|
31461
|
+
\`\`\`
|
|
31462
|
+
|
|
31463
|
+
### Manual Release (if needed)
|
|
30920
31464
|
\`\`\`
|
|
31465
|
+
swarmmail_release() # Manually release reservations
|
|
31466
|
+
\`\`\`
|
|
31467
|
+
|
|
31468
|
+
**Note:** \`swarm_complete\` automatically releases reservations. Only use manual release if aborting work.
|
|
30921
31469
|
|
|
30922
31470
|
## [OTHER TOOLS]
|
|
30923
31471
|
### Beads
|
|
30924
31472
|
- beads_update(id, status) - Mark blocked if stuck
|
|
30925
31473
|
- beads_create(title, type) - Log new bugs found
|
|
30926
31474
|
|
|
30927
|
-
### Skills
|
|
31475
|
+
### Skills
|
|
30928
31476
|
- skills_list() - Discover available skills
|
|
30929
31477
|
- skills_use(name) - Activate skill for specialized guidance
|
|
31478
|
+
- skills_create(name) - Create new skill (if you found a reusable pattern)
|
|
30930
31479
|
|
|
30931
|
-
|
|
30932
|
-
|
|
30933
|
-
|
|
30934
|
-
|
|
30935
|
-
|
|
30936
|
-
|
|
30937
|
-
|
|
30938
|
-
|
|
30939
|
-
|
|
30940
|
-
|
|
30941
|
-
|
|
30942
|
-
|
|
30943
|
-
|
|
30944
|
-
|
|
30945
|
-
|
|
30946
|
-
5. Verify (typecheck)
|
|
30947
|
-
6. **swarm_complete** - Mark done, release reservations
|
|
30948
|
-
|
|
30949
|
-
**CRITICAL REQUIREMENTS:**
|
|
30950
|
-
- Step 1 (swarmmail_init) is NON-NEGOTIABLE - do it before anything else
|
|
30951
|
-
- Never work silently - send progress updates via swarmmail_send every significant milestone
|
|
30952
|
-
- If you complete without initializing, swarm_complete will detect this and warn/fail
|
|
31480
|
+
## [CRITICAL REQUIREMENTS]
|
|
31481
|
+
|
|
31482
|
+
**NON-NEGOTIABLE:**
|
|
31483
|
+
1. Step 1 (swarmmail_init) MUST be first - do it before anything else
|
|
31484
|
+
2. Step 2 (semantic-memory_find) MUST happen before starting work
|
|
31485
|
+
3. Step 4 (swarmmail_reserve) - YOU reserve files, not coordinator
|
|
31486
|
+
4. Step 6 (swarm_progress) - Report at milestones, don't work silently
|
|
31487
|
+
5. Step 9 (swarm_complete) - Use this to close, NOT beads_close
|
|
31488
|
+
|
|
31489
|
+
**If you skip these steps:**
|
|
31490
|
+
- Your work won't be tracked (swarm_complete will fail)
|
|
31491
|
+
- You'll waste time repeating solved problems (no semantic memory query)
|
|
31492
|
+
- Edit conflicts with other agents (no file reservation)
|
|
31493
|
+
- Lost work if you crash (no checkpoints)
|
|
31494
|
+
- Future agents repeat your mistakes (no learnings stored)
|
|
30953
31495
|
|
|
30954
31496
|
Begin now.`;
|
|
30955
31497
|
var EVALUATION_PROMPT = `Evaluate the work completed for this subtask.
|
|
@@ -31671,26 +32213,6 @@ var swarm_progress = tool({
|
|
|
31671
32213
|
...checkpoint
|
|
31672
32214
|
});
|
|
31673
32215
|
await appendEvent2(event, args.project_key);
|
|
31674
|
-
const { getDatabase } = await import("swarm-mail");
|
|
31675
|
-
const db = await getDatabase(args.project_key);
|
|
31676
|
-
const now = Date.now();
|
|
31677
|
-
await db.query(`INSERT INTO swarm_contexts (id, epic_id, bead_id, strategy, files, dependencies, directives, recovery, created_at, updated_at)
|
|
31678
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
|
31679
|
-
ON CONFLICT (id) DO UPDATE SET
|
|
31680
|
-
files = EXCLUDED.files,
|
|
31681
|
-
recovery = EXCLUDED.recovery,
|
|
31682
|
-
updated_at = EXCLUDED.updated_at`, [
|
|
31683
|
-
args.bead_id,
|
|
31684
|
-
epicId,
|
|
31685
|
-
args.bead_id,
|
|
31686
|
-
checkpoint.strategy,
|
|
31687
|
-
JSON.stringify(checkpoint.files),
|
|
31688
|
-
JSON.stringify(checkpoint.dependencies),
|
|
31689
|
-
JSON.stringify(checkpoint.directives),
|
|
31690
|
-
JSON.stringify(checkpoint.recovery),
|
|
31691
|
-
now,
|
|
31692
|
-
now
|
|
31693
|
-
]);
|
|
31694
32216
|
checkpointCreated = true;
|
|
31695
32217
|
} catch (error45) {
|
|
31696
32218
|
console.warn(`[swarm_progress] Auto-checkpoint failed at ${args.progress_percent}%:`, error45);
|
|
@@ -31853,7 +32375,23 @@ Continuing with completion, but this should be fixed for future subtasks.`;
|
|
|
31853
32375
|
}
|
|
31854
32376
|
const closeResult = await Bun.$`bd close ${args.bead_id} --reason ${args.summary} --json`.quiet().nothrow();
|
|
31855
32377
|
if (closeResult.exitCode !== 0) {
|
|
31856
|
-
|
|
32378
|
+
const stderrOutput = closeResult.stderr.toString().trim();
|
|
32379
|
+
return JSON.stringify({
|
|
32380
|
+
success: false,
|
|
32381
|
+
error: "Failed to close bead",
|
|
32382
|
+
failed_step: "bd close",
|
|
32383
|
+
details: stderrOutput || "Unknown error from bd close command",
|
|
32384
|
+
bead_id: args.bead_id,
|
|
32385
|
+
recovery: {
|
|
32386
|
+
steps: [
|
|
32387
|
+
`1. Check bead exists: bd show ${args.bead_id}`,
|
|
32388
|
+
`2. Check bead status (might already be closed): beads_query()`,
|
|
32389
|
+
`3. If bead is blocked, unblock first: beads_update(id="${args.bead_id}", status="in_progress")`,
|
|
32390
|
+
`4. Try closing directly: beads_close(id="${args.bead_id}", reason="...")`
|
|
32391
|
+
],
|
|
32392
|
+
hint: "If bead is in 'blocked' status, you must change it to 'in_progress' or 'open' before closing."
|
|
32393
|
+
}
|
|
32394
|
+
}, null, 2);
|
|
31857
32395
|
}
|
|
31858
32396
|
try {
|
|
31859
32397
|
const epicId3 = args.bead_id.includes(".") ? args.bead_id.split(".")[0] : args.bead_id;
|
|
@@ -32026,6 +32564,7 @@ ${errorStack.slice(0, 1000)}
|
|
|
32026
32564
|
"4. Retry swarm_complete after fixing"
|
|
32027
32565
|
].filter(Boolean).join(`
|
|
32028
32566
|
`);
|
|
32567
|
+
let notificationSent = false;
|
|
32029
32568
|
try {
|
|
32030
32569
|
await sendSwarmMessage2({
|
|
32031
32570
|
projectPath: args.project_key,
|
|
@@ -32036,11 +32575,40 @@ ${errorStack.slice(0, 1000)}
|
|
|
32036
32575
|
threadId: epicId,
|
|
32037
32576
|
importance: "urgent"
|
|
32038
32577
|
});
|
|
32578
|
+
notificationSent = true;
|
|
32039
32579
|
} catch (mailError) {
|
|
32040
32580
|
console.error(`[swarm_complete] CRITICAL: Failed to notify coordinator of failure for ${args.bead_id}:`, mailError);
|
|
32041
32581
|
console.error(`[swarm_complete] Original error:`, error45);
|
|
32042
32582
|
}
|
|
32043
|
-
|
|
32583
|
+
return JSON.stringify({
|
|
32584
|
+
success: false,
|
|
32585
|
+
error: errorMessage,
|
|
32586
|
+
failed_step: failedStep,
|
|
32587
|
+
bead_id: args.bead_id,
|
|
32588
|
+
agent_name: args.agent_name,
|
|
32589
|
+
coordinator_notified: notificationSent,
|
|
32590
|
+
stack_trace: errorStack?.slice(0, 500),
|
|
32591
|
+
context: {
|
|
32592
|
+
summary: args.summary,
|
|
32593
|
+
files_touched: args.files_touched || [],
|
|
32594
|
+
skip_ubs_scan: args.skip_ubs_scan ?? false,
|
|
32595
|
+
skip_verification: args.skip_verification ?? false
|
|
32596
|
+
},
|
|
32597
|
+
recovery: {
|
|
32598
|
+
steps: [
|
|
32599
|
+
"1. Check the error message above for specific issue",
|
|
32600
|
+
`2. Review failed step: ${failedStep}`,
|
|
32601
|
+
"3. Fix underlying issue or use skip flags if appropriate",
|
|
32602
|
+
"4. Retry swarm_complete after fixing"
|
|
32603
|
+
],
|
|
32604
|
+
common_fixes: {
|
|
32605
|
+
"Verification Gate": "Use skip_verification=true to bypass (not recommended)",
|
|
32606
|
+
"UBS scan": "Use skip_ubs_scan=true to bypass",
|
|
32607
|
+
"Bead close": "Check bead status with beads_query(), may need beads_update() first",
|
|
32608
|
+
"Self-evaluation": "Check evaluation JSON format matches EvaluationSchema"
|
|
32609
|
+
}
|
|
32610
|
+
}
|
|
32611
|
+
}, null, 2);
|
|
32044
32612
|
}
|
|
32045
32613
|
}
|
|
32046
32614
|
});
|
|
@@ -32312,26 +32880,7 @@ var swarm_checkpoint = tool({
|
|
|
32312
32880
|
recovery: checkpoint.recovery
|
|
32313
32881
|
});
|
|
32314
32882
|
await appendEvent2(event, args.project_key);
|
|
32315
|
-
const { getDatabase } = await import("swarm-mail");
|
|
32316
|
-
const db = await getDatabase(args.project_key);
|
|
32317
32883
|
const now = Date.now();
|
|
32318
|
-
await db.query(`INSERT INTO swarm_contexts (id, epic_id, bead_id, strategy, files, dependencies, directives, recovery, created_at, updated_at)
|
|
32319
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
|
32320
|
-
ON CONFLICT (id) DO UPDATE SET
|
|
32321
|
-
files = EXCLUDED.files,
|
|
32322
|
-
recovery = EXCLUDED.recovery,
|
|
32323
|
-
updated_at = EXCLUDED.updated_at`, [
|
|
32324
|
-
args.bead_id,
|
|
32325
|
-
args.epic_id,
|
|
32326
|
-
args.bead_id,
|
|
32327
|
-
checkpoint.strategy,
|
|
32328
|
-
JSON.stringify(checkpoint.files),
|
|
32329
|
-
JSON.stringify(checkpoint.dependencies),
|
|
32330
|
-
JSON.stringify(checkpoint.directives),
|
|
32331
|
-
JSON.stringify(checkpoint.recovery),
|
|
32332
|
-
now,
|
|
32333
|
-
now
|
|
32334
|
-
]);
|
|
32335
32884
|
return JSON.stringify({
|
|
32336
32885
|
success: true,
|
|
32337
32886
|
checkpoint_timestamp: now,
|
|
@@ -32374,15 +32923,16 @@ var swarm_recover = tool({
|
|
|
32374
32923
|
}, null, 2);
|
|
32375
32924
|
}
|
|
32376
32925
|
const row = result.rows[0];
|
|
32926
|
+
const parseIfString = (val) => typeof val === "string" ? JSON.parse(val) : val;
|
|
32377
32927
|
const context = {
|
|
32378
32928
|
id: row.id,
|
|
32379
32929
|
epic_id: row.epic_id,
|
|
32380
32930
|
bead_id: row.bead_id,
|
|
32381
32931
|
strategy: row.strategy,
|
|
32382
|
-
files:
|
|
32383
|
-
dependencies:
|
|
32384
|
-
directives:
|
|
32385
|
-
recovery:
|
|
32932
|
+
files: parseIfString(row.files),
|
|
32933
|
+
dependencies: parseIfString(row.dependencies),
|
|
32934
|
+
directives: parseIfString(row.directives),
|
|
32935
|
+
recovery: parseIfString(row.recovery),
|
|
32386
32936
|
created_at: row.created_at,
|
|
32387
32937
|
updated_at: row.updated_at
|
|
32388
32938
|
};
|
|
@@ -34410,9 +34960,13 @@ export {
|
|
|
34410
34960
|
mandateSchemas,
|
|
34411
34961
|
listSkills,
|
|
34412
34962
|
isToolAvailable,
|
|
34963
|
+
isStateTransitionEvent,
|
|
34413
34964
|
isSemanticMemoryAvailable,
|
|
34414
34965
|
isProjectNotFoundError,
|
|
34966
|
+
isEpicEvent,
|
|
34967
|
+
isBeadEventType,
|
|
34415
34968
|
isAgentNotFoundError,
|
|
34969
|
+
isAgentEvent,
|
|
34416
34970
|
invalidateSkillsCache,
|
|
34417
34971
|
ifToolAvailable,
|
|
34418
34972
|
guardrailOutput,
|
|
@@ -34426,6 +34980,7 @@ export {
|
|
|
34426
34980
|
getSchemaByName,
|
|
34427
34981
|
getMandateStorage,
|
|
34428
34982
|
getBeadsWorkingDirectory,
|
|
34983
|
+
getBeadIdFromEvent,
|
|
34429
34984
|
getAgentMailProjectDirectory,
|
|
34430
34985
|
formatZodErrors,
|
|
34431
34986
|
formatToolAvailability,
|
|
@@ -34444,6 +34999,7 @@ export {
|
|
|
34444
34999
|
createStorage,
|
|
34445
35000
|
createMetrics,
|
|
34446
35001
|
createMandateStorage,
|
|
35002
|
+
createBeadEvent,
|
|
34447
35003
|
createAgentMailError,
|
|
34448
35004
|
clearSessionState,
|
|
34449
35005
|
checkTool,
|
|
@@ -34513,17 +35069,38 @@ export {
|
|
|
34513
35069
|
CreateSwarmContextArgsSchema,
|
|
34514
35070
|
CreateMandateArgsSchema,
|
|
34515
35071
|
CastVoteArgsSchema,
|
|
35072
|
+
BeadWorkStartedEventSchema,
|
|
34516
35073
|
BeadValidationError,
|
|
35074
|
+
BeadUpdatedEventSchema,
|
|
34517
35075
|
BeadUpdateArgsSchema,
|
|
34518
35076
|
BeadTypeSchema,
|
|
34519
35077
|
BeadTreeSchema,
|
|
34520
35078
|
BeadStatusSchema,
|
|
35079
|
+
BeadStatusChangedEventSchema,
|
|
34521
35080
|
BeadSchema,
|
|
35081
|
+
BeadReopenedEventSchema,
|
|
34522
35082
|
BeadQueryArgsSchema,
|
|
35083
|
+
BeadLabelRemovedEventSchema,
|
|
35084
|
+
BeadLabelAddedEventSchema,
|
|
35085
|
+
BeadEventSchema,
|
|
34523
35086
|
BeadError,
|
|
35087
|
+
BeadEpicClosureEligibleEventSchema,
|
|
35088
|
+
BeadEpicChildRemovedEventSchema,
|
|
35089
|
+
BeadEpicChildAddedEventSchema,
|
|
34524
35090
|
BeadDependencySchema,
|
|
35091
|
+
BeadDependencyRemovedEventSchema,
|
|
35092
|
+
BeadDependencyAddedEventSchema,
|
|
35093
|
+
BeadDeletedEventSchema,
|
|
35094
|
+
BeadCreatedEventSchema,
|
|
34525
35095
|
BeadCreateArgsSchema,
|
|
35096
|
+
BeadCompactedEventSchema,
|
|
35097
|
+
BeadCommentUpdatedEventSchema,
|
|
35098
|
+
BeadCommentDeletedEventSchema,
|
|
35099
|
+
BeadCommentAddedEventSchema,
|
|
35100
|
+
BeadClosedEventSchema,
|
|
34526
35101
|
BeadCloseArgsSchema,
|
|
35102
|
+
BeadAssignedEventSchema,
|
|
35103
|
+
BaseBeadEventSchema,
|
|
34527
35104
|
AgentProgressSchema,
|
|
34528
35105
|
AgentMailNotInitializedError,
|
|
34529
35106
|
AgentMailError
|