opencode-swarm 7.77.3 → 7.77.5
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/.opencode/skills/swarm-pr-feedback/SKILL.md +8 -0
- package/dist/cli/index.js +770 -695
- package/dist/commands/registry.d.ts +109 -0
- package/dist/commands/tool-policy.d.ts +2 -2
- package/dist/index.js +1084 -916
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ var package_default;
|
|
|
69
69
|
var init_package = __esm(() => {
|
|
70
70
|
package_default = {
|
|
71
71
|
name: "opencode-swarm",
|
|
72
|
-
version: "7.77.
|
|
72
|
+
version: "7.77.5",
|
|
73
73
|
description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
74
74
|
main: "dist/index.js",
|
|
75
75
|
types: "dist/index.d.ts",
|
|
@@ -611,7 +611,7 @@ var init_tool_metadata = __esm(() => {
|
|
|
611
611
|
agents: ["architect"]
|
|
612
612
|
},
|
|
613
613
|
write_final_council_evidence: {
|
|
614
|
-
description: "
|
|
614
|
+
description: "Persist project-scoped final council evidence to .swarm/evidence/final-council.json. PREREQUISITE: dispatch critic, reviewer, sme, test_engineer, and explorer as project-scoped Agent tasks and collect their CouncilMemberVerdict JSON — this tool synthesizes only. Rejects on insufficient quorum or CONCERNS with unresolved requiredFixes; normalizes verdicts to approved/concerns/rejected. Architect-only.",
|
|
615
615
|
agents: ["architect"]
|
|
616
616
|
},
|
|
617
617
|
skill_generate: {
|
|
@@ -17346,6 +17346,14 @@ async function bunWrite(filePath, data) {
|
|
|
17346
17346
|
} catch {}
|
|
17347
17347
|
throw lastError;
|
|
17348
17348
|
}
|
|
17349
|
+
try {
|
|
17350
|
+
const dirFd = await fsPromises2.open(dir, "r");
|
|
17351
|
+
try {
|
|
17352
|
+
await dirFd.sync();
|
|
17353
|
+
} finally {
|
|
17354
|
+
await dirFd.close();
|
|
17355
|
+
}
|
|
17356
|
+
} catch {}
|
|
17349
17357
|
const stats = await fsPromises2.stat(filePath);
|
|
17350
17358
|
return stats.size;
|
|
17351
17359
|
}
|
|
@@ -17670,14 +17678,23 @@ function validateSwarmPath(directory, filename) {
|
|
|
17670
17678
|
return resolved;
|
|
17671
17679
|
}
|
|
17672
17680
|
async function readSwarmFileAsync(directory, filename) {
|
|
17673
|
-
|
|
17674
|
-
|
|
17675
|
-
|
|
17676
|
-
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
17681
|
+
const maxAttempts = 5;
|
|
17682
|
+
const retryDelayMs = 10;
|
|
17683
|
+
for (let attempt = 0;attempt < maxAttempts; attempt++) {
|
|
17684
|
+
try {
|
|
17685
|
+
const resolvedPath = _internals3.validateSwarmPath(directory, filename);
|
|
17686
|
+
const file2 = bunFile(resolvedPath);
|
|
17687
|
+
const content = await file2.text();
|
|
17688
|
+
return content;
|
|
17689
|
+
} catch (err2) {
|
|
17690
|
+
const isNotFound = err2?.code === "ENOENT";
|
|
17691
|
+
if (!isNotFound || attempt === maxAttempts - 1) {
|
|
17692
|
+
return null;
|
|
17693
|
+
}
|
|
17694
|
+
await new Promise((resolve3) => setTimeout(resolve3, retryDelayMs));
|
|
17695
|
+
}
|
|
17680
17696
|
}
|
|
17697
|
+
return null;
|
|
17681
17698
|
}
|
|
17682
17699
|
function estimateTokens(text) {
|
|
17683
17700
|
if (!text) {
|
|
@@ -20808,7 +20825,7 @@ GFS4: `);
|
|
|
20808
20825
|
}
|
|
20809
20826
|
function ReadStream$open() {
|
|
20810
20827
|
var that = this;
|
|
20811
|
-
|
|
20828
|
+
open2(that.path, that.flags, that.mode, function(err2, fd) {
|
|
20812
20829
|
if (err2) {
|
|
20813
20830
|
if (that.autoClose)
|
|
20814
20831
|
that.destroy();
|
|
@@ -20828,7 +20845,7 @@ GFS4: `);
|
|
|
20828
20845
|
}
|
|
20829
20846
|
function WriteStream$open() {
|
|
20830
20847
|
var that = this;
|
|
20831
|
-
|
|
20848
|
+
open2(that.path, that.flags, that.mode, function(err2, fd) {
|
|
20832
20849
|
if (err2) {
|
|
20833
20850
|
that.destroy();
|
|
20834
20851
|
that.emit("error", err2);
|
|
@@ -20845,8 +20862,8 @@ GFS4: `);
|
|
|
20845
20862
|
return new fs8.WriteStream(path9, options);
|
|
20846
20863
|
}
|
|
20847
20864
|
var fs$open = fs8.open;
|
|
20848
|
-
fs8.open =
|
|
20849
|
-
function
|
|
20865
|
+
fs8.open = open2;
|
|
20866
|
+
function open2(path9, flags2, mode, cb) {
|
|
20850
20867
|
if (typeof mode === "function")
|
|
20851
20868
|
cb = mode, mode = null;
|
|
20852
20869
|
return go$open(path9, flags2, mode, cb);
|
|
@@ -22180,6 +22197,9 @@ function wrapFlatRetrospective(flatEntry, taskId) {
|
|
|
22180
22197
|
async function loadEvidence(directory, taskId) {
|
|
22181
22198
|
const sanitizedTaskId = sanitizeTaskId2(taskId);
|
|
22182
22199
|
const relativePath = path10.join("evidence", sanitizedTaskId, "evidence.json");
|
|
22200
|
+
if (relativePath.length > 4096) {
|
|
22201
|
+
return { status: "not_found" };
|
|
22202
|
+
}
|
|
22183
22203
|
const evidencePath = validateSwarmPath(directory, relativePath);
|
|
22184
22204
|
const content = await readSwarmFileAsync(directory, relativePath);
|
|
22185
22205
|
if (content === null) {
|
|
@@ -24393,16 +24413,16 @@ var require_parse = __commonJS((exports, module2) => {
|
|
|
24393
24413
|
const analysis = analyzeRepeatedExtglob(body2, opts);
|
|
24394
24414
|
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
24395
24415
|
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : undefined;
|
|
24396
|
-
const
|
|
24397
|
-
|
|
24398
|
-
|
|
24399
|
-
|
|
24416
|
+
const open2 = tokens[token.tokensIndex];
|
|
24417
|
+
open2.type = "text";
|
|
24418
|
+
open2.value = literal2;
|
|
24419
|
+
open2.output = safeOutput || utils.escapeRegex(literal2);
|
|
24400
24420
|
for (let i2 = token.tokensIndex + 1;i2 < tokens.length; i2++) {
|
|
24401
24421
|
tokens[i2].value = "";
|
|
24402
24422
|
tokens[i2].output = "";
|
|
24403
24423
|
delete tokens[i2].suffix;
|
|
24404
24424
|
}
|
|
24405
|
-
state.output = token.output +
|
|
24425
|
+
state.output = token.output + open2.output;
|
|
24406
24426
|
state.backtrack = true;
|
|
24407
24427
|
push({ type: "paren", extglob: true, value, output: "" });
|
|
24408
24428
|
decrement("parens");
|
|
@@ -24622,15 +24642,15 @@ var require_parse = __commonJS((exports, module2) => {
|
|
|
24622
24642
|
}
|
|
24623
24643
|
if (value === "{" && opts.nobrace !== true) {
|
|
24624
24644
|
increment("braces");
|
|
24625
|
-
const
|
|
24645
|
+
const open2 = {
|
|
24626
24646
|
type: "brace",
|
|
24627
24647
|
value,
|
|
24628
24648
|
output: "(",
|
|
24629
24649
|
outputIndex: state.output.length,
|
|
24630
24650
|
tokensIndex: state.tokens.length
|
|
24631
24651
|
};
|
|
24632
|
-
braces.push(
|
|
24633
|
-
push(
|
|
24652
|
+
braces.push(open2);
|
|
24653
|
+
push(open2);
|
|
24634
24654
|
continue;
|
|
24635
24655
|
}
|
|
24636
24656
|
if (value === "}") {
|
|
@@ -27147,6 +27167,291 @@ var init_stored_input_args = __esm(() => {
|
|
|
27147
27167
|
storedInputArgs = new Map;
|
|
27148
27168
|
});
|
|
27149
27169
|
|
|
27170
|
+
// src/commands/command-dispatch.ts
|
|
27171
|
+
function normalizeSwarmCommandInput(command, argumentText) {
|
|
27172
|
+
if (command !== "swarm" && !command.startsWith("swarm-")) {
|
|
27173
|
+
return { isSwarmCommand: false, tokens: [] };
|
|
27174
|
+
}
|
|
27175
|
+
if (command === "swarm") {
|
|
27176
|
+
return {
|
|
27177
|
+
isSwarmCommand: true,
|
|
27178
|
+
tokens: argumentText.trim().split(/\s+/).filter(Boolean)
|
|
27179
|
+
};
|
|
27180
|
+
}
|
|
27181
|
+
const subcommand = command.slice("swarm-".length);
|
|
27182
|
+
const extraArgs = argumentText.trim().split(/\s+/).filter(Boolean);
|
|
27183
|
+
return {
|
|
27184
|
+
isSwarmCommand: true,
|
|
27185
|
+
tokens: [subcommand, ...extraArgs].filter(Boolean)
|
|
27186
|
+
};
|
|
27187
|
+
}
|
|
27188
|
+
function canonicalCommandKey(resolved) {
|
|
27189
|
+
return resolved.entry.aliasOf ?? resolved.key;
|
|
27190
|
+
}
|
|
27191
|
+
function formatCommandNotFound(tokens) {
|
|
27192
|
+
const attemptedCommand = tokens[0] || "";
|
|
27193
|
+
const MAX_DISPLAY = 100;
|
|
27194
|
+
const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
|
|
27195
|
+
const similar = _internals13.findSimilarCommands(attemptedCommand);
|
|
27196
|
+
const header = `Command \`/swarm ${displayCommand}\` not found.`;
|
|
27197
|
+
const suggestions = similar.length > 0 ? `Did you mean:
|
|
27198
|
+
${similar.map((cmd) => ` - /swarm ${cmd}`).join(`
|
|
27199
|
+
`)}` : "";
|
|
27200
|
+
const footer = "Run `/swarm help` for all commands.";
|
|
27201
|
+
return [header, suggestions, footer].filter(Boolean).join(`
|
|
27202
|
+
|
|
27203
|
+
`);
|
|
27204
|
+
}
|
|
27205
|
+
async function executeSwarmCommand(args2) {
|
|
27206
|
+
const {
|
|
27207
|
+
directory,
|
|
27208
|
+
agents,
|
|
27209
|
+
sessionID,
|
|
27210
|
+
tokens,
|
|
27211
|
+
packageRoot,
|
|
27212
|
+
buildHelpText,
|
|
27213
|
+
policy
|
|
27214
|
+
} = args2;
|
|
27215
|
+
let text;
|
|
27216
|
+
const resolved = resolveCommand(tokens);
|
|
27217
|
+
if (!resolved) {
|
|
27218
|
+
text = tokens.length === 0 && buildHelpText ? buildHelpText() : formatCommandNotFound(tokens);
|
|
27219
|
+
} else {
|
|
27220
|
+
const policyResult = policy?.(resolved) ?? { allowed: true };
|
|
27221
|
+
if (!policyResult.allowed) {
|
|
27222
|
+
text = policyResult.message;
|
|
27223
|
+
} else {
|
|
27224
|
+
try {
|
|
27225
|
+
text = await resolved.entry.handler({
|
|
27226
|
+
directory,
|
|
27227
|
+
args: resolved.remainingArgs,
|
|
27228
|
+
sessionID,
|
|
27229
|
+
agents,
|
|
27230
|
+
packageRoot,
|
|
27231
|
+
source: "chat"
|
|
27232
|
+
});
|
|
27233
|
+
} catch (_err) {
|
|
27234
|
+
const cmdName = tokens[0] || "unknown";
|
|
27235
|
+
const errMsg = _err instanceof Error ? _err.message : String(_err);
|
|
27236
|
+
text = `Error executing /swarm ${cmdName}: ${errMsg}`;
|
|
27237
|
+
}
|
|
27238
|
+
if (resolved.warning) {
|
|
27239
|
+
text = `${resolved.warning}
|
|
27240
|
+
|
|
27241
|
+
${text}`;
|
|
27242
|
+
}
|
|
27243
|
+
}
|
|
27244
|
+
}
|
|
27245
|
+
return {
|
|
27246
|
+
text,
|
|
27247
|
+
resolved: resolved ?? undefined,
|
|
27248
|
+
canonicalKey: resolved ? canonicalCommandKey(resolved) : undefined
|
|
27249
|
+
};
|
|
27250
|
+
}
|
|
27251
|
+
var init_command_dispatch = __esm(() => {
|
|
27252
|
+
init_registry();
|
|
27253
|
+
});
|
|
27254
|
+
|
|
27255
|
+
// src/commands/tool-policy.ts
|
|
27256
|
+
function lazySet(getValues) {
|
|
27257
|
+
let cached2 = null;
|
|
27258
|
+
const ensure = () => {
|
|
27259
|
+
if (cached2 === null)
|
|
27260
|
+
cached2 = new Set(getValues());
|
|
27261
|
+
return cached2;
|
|
27262
|
+
};
|
|
27263
|
+
return new Proxy({}, {
|
|
27264
|
+
get(_target, prop) {
|
|
27265
|
+
const set2 = ensure();
|
|
27266
|
+
const value = Reflect.get(set2, prop);
|
|
27267
|
+
return typeof value === "function" ? value.bind(set2) : value;
|
|
27268
|
+
}
|
|
27269
|
+
});
|
|
27270
|
+
}
|
|
27271
|
+
function lazyArray(getValues) {
|
|
27272
|
+
let cached2 = null;
|
|
27273
|
+
const ensure = () => {
|
|
27274
|
+
if (cached2 === null)
|
|
27275
|
+
cached2 = getValues();
|
|
27276
|
+
return cached2;
|
|
27277
|
+
};
|
|
27278
|
+
return new Proxy([], {
|
|
27279
|
+
get(_target, prop) {
|
|
27280
|
+
const arr = ensure();
|
|
27281
|
+
const value = Reflect.get(arr, prop);
|
|
27282
|
+
return typeof value === "function" ? value.bind(arr) : value;
|
|
27283
|
+
}
|
|
27284
|
+
});
|
|
27285
|
+
}
|
|
27286
|
+
function classifySwarmCommandToolUse(resolved) {
|
|
27287
|
+
const canonicalKey = canonicalCommandKey(resolved);
|
|
27288
|
+
const args2 = resolved.remainingArgs;
|
|
27289
|
+
if (!SWARM_COMMAND_TOOL_ALLOWLIST.has(canonicalKey)) {
|
|
27290
|
+
if (HUMAN_ONLY_SWARM_COMMANDS.has(canonicalKey)) {
|
|
27291
|
+
return {
|
|
27292
|
+
allowed: false,
|
|
27293
|
+
message: `/swarm ${canonicalKey} is a human-only command. ` + `Present the situation to the user and ask them to run \`/swarm ${canonicalKey}\` themselves ` + `(or \`bunx opencode-swarm run ${canonicalKey}\` from a terminal). ` + `You MUST NOT run it yourself via Bash, swarm_command, or any other tool — ` + `the runtime guardrail will block such attempts.`
|
|
27294
|
+
};
|
|
27295
|
+
}
|
|
27296
|
+
return {
|
|
27297
|
+
allowed: false,
|
|
27298
|
+
message: `/swarm ${canonicalKey} is not available through the chat tool yet.
|
|
27299
|
+
|
|
27300
|
+
` + `Use the canonical CLI path for now: \`bunx opencode-swarm run ${canonicalKey}\`.
|
|
27301
|
+
` + `Commands with state changes, auto-heal behavior, or subprocesses need confirmation gates before chat-tool support.`
|
|
27302
|
+
};
|
|
27303
|
+
}
|
|
27304
|
+
if (canonicalKey === "config doctor" && args2.some((arg) => arg === "--fix" || arg === "-f")) {
|
|
27305
|
+
return {
|
|
27306
|
+
allowed: false,
|
|
27307
|
+
message: "/swarm config doctor --fix is not available through swarm_command. Run the CLI command directly when you intend to modify config files."
|
|
27308
|
+
};
|
|
27309
|
+
}
|
|
27310
|
+
if (NO_ARGS.has(canonicalKey) && args2.length > 0) {
|
|
27311
|
+
return {
|
|
27312
|
+
allowed: false,
|
|
27313
|
+
message: `/swarm ${canonicalKey} does not accept arguments through swarm_command.`
|
|
27314
|
+
};
|
|
27315
|
+
}
|
|
27316
|
+
if (canonicalKey === "knowledge") {
|
|
27317
|
+
if (args2.length === 0)
|
|
27318
|
+
return { allowed: true };
|
|
27319
|
+
if (args2.length === 1 && (args2[0] === "list" || args2[0] === "unactionable"))
|
|
27320
|
+
return { allowed: true };
|
|
27321
|
+
return {
|
|
27322
|
+
allowed: false,
|
|
27323
|
+
message: "Only `/swarm knowledge`, `/swarm knowledge list`, and `/swarm knowledge unactionable` are available through swarm_command. Knowledge migrate/quarantine/restore/retry-hardening are intentionally excluded."
|
|
27324
|
+
};
|
|
27325
|
+
}
|
|
27326
|
+
if (canonicalKey === "memory") {
|
|
27327
|
+
if (args2.length === 0)
|
|
27328
|
+
return { allowed: true };
|
|
27329
|
+
return {
|
|
27330
|
+
allowed: false,
|
|
27331
|
+
message: "Use `/swarm memory status`, `/swarm memory pending`, `/swarm memory recall-log`, `/swarm memory stale`, `/swarm memory export`, or `/swarm memory evaluate --json` through swarm_command. Memory import, migrate, and compact are intentionally excluded from chat-tool execution."
|
|
27332
|
+
};
|
|
27333
|
+
}
|
|
27334
|
+
if (canonicalKey === "memory evaluate") {
|
|
27335
|
+
if (args2.length === 0)
|
|
27336
|
+
return { allowed: true };
|
|
27337
|
+
if (args2.length === 1 && args2[0] === "--json")
|
|
27338
|
+
return { allowed: true };
|
|
27339
|
+
return {
|
|
27340
|
+
allowed: false,
|
|
27341
|
+
message: "Usage through swarm_command: `/swarm memory evaluate --json`. Custom fixture directories are only available through direct user command execution."
|
|
27342
|
+
};
|
|
27343
|
+
}
|
|
27344
|
+
if (canonicalKey === "sdd status") {
|
|
27345
|
+
if (args2.length === 0)
|
|
27346
|
+
return { allowed: true };
|
|
27347
|
+
if (args2.length === 1 && args2[0] === "--json")
|
|
27348
|
+
return { allowed: true };
|
|
27349
|
+
return {
|
|
27350
|
+
allowed: false,
|
|
27351
|
+
message: "Usage through swarm_command: `/swarm sdd status` or `/swarm sdd status --json`."
|
|
27352
|
+
};
|
|
27353
|
+
}
|
|
27354
|
+
if (canonicalKey === "sdd validate") {
|
|
27355
|
+
if (args2.length === 0)
|
|
27356
|
+
return { allowed: true };
|
|
27357
|
+
if (args2.length === 1 && args2[0] === "--json")
|
|
27358
|
+
return { allowed: true };
|
|
27359
|
+
if (args2.length === 2 && args2[0] === "--change" && /^[A-Za-z0-9_.-]{1,128}$/.test(args2[1])) {
|
|
27360
|
+
return { allowed: true };
|
|
27361
|
+
}
|
|
27362
|
+
return {
|
|
27363
|
+
allowed: false,
|
|
27364
|
+
message: "Usage through swarm_command: `/swarm sdd validate`, `/swarm sdd validate --json`, or `/swarm sdd validate --change <id>`."
|
|
27365
|
+
};
|
|
27366
|
+
}
|
|
27367
|
+
if (canonicalKey === "memory pending" || canonicalKey === "memory recall-log" || canonicalKey === "memory stale") {
|
|
27368
|
+
if (args2.length === 0)
|
|
27369
|
+
return { allowed: true };
|
|
27370
|
+
if (args2.length === 2 && args2[0] === "--limit" && /^\d+$/.test(args2[1])) {
|
|
27371
|
+
return { allowed: true };
|
|
27372
|
+
}
|
|
27373
|
+
return {
|
|
27374
|
+
allowed: false,
|
|
27375
|
+
message: `Usage through swarm_command: \`/swarm ${canonicalKey}\` or ` + `\`/swarm ${canonicalKey} --limit <n>\`.`
|
|
27376
|
+
};
|
|
27377
|
+
}
|
|
27378
|
+
if (canonicalKey === "retrieve") {
|
|
27379
|
+
if (args2.length !== 1 || !SUMMARY_ID_PATTERN.test(args2[0])) {
|
|
27380
|
+
return {
|
|
27381
|
+
allowed: false,
|
|
27382
|
+
message: "Usage through swarm_command: `/swarm retrieve <summary-id>` with a single summary ID such as S1."
|
|
27383
|
+
};
|
|
27384
|
+
}
|
|
27385
|
+
}
|
|
27386
|
+
if (canonicalKey === "benchmark") {
|
|
27387
|
+
const allowedFlags = new Set(["--cumulative", "--ci-gate"]);
|
|
27388
|
+
const invalid = args2.filter((arg) => !allowedFlags.has(arg));
|
|
27389
|
+
if (invalid.length > 0) {
|
|
27390
|
+
return {
|
|
27391
|
+
allowed: false,
|
|
27392
|
+
message: "Only `--cumulative` and `--ci-gate` are supported for `/swarm benchmark` through swarm_command."
|
|
27393
|
+
};
|
|
27394
|
+
}
|
|
27395
|
+
}
|
|
27396
|
+
if (canonicalKey === "show-plan") {
|
|
27397
|
+
if (args2.length > 1 || args2[0] && !/^\d+$/.test(args2[0])) {
|
|
27398
|
+
return {
|
|
27399
|
+
allowed: false,
|
|
27400
|
+
message: "Usage through swarm_command: `/swarm show-plan` or `/swarm show-plan <phase-number>`."
|
|
27401
|
+
};
|
|
27402
|
+
}
|
|
27403
|
+
}
|
|
27404
|
+
if (canonicalKey === "evidence") {
|
|
27405
|
+
if (args2.length > 1 || args2[0] && !TASK_ID_PATTERN.test(args2[0])) {
|
|
27406
|
+
return {
|
|
27407
|
+
allowed: false,
|
|
27408
|
+
message: "Usage through swarm_command: `/swarm evidence` or `/swarm evidence <task-id>`."
|
|
27409
|
+
};
|
|
27410
|
+
}
|
|
27411
|
+
}
|
|
27412
|
+
if (canonicalKey === "help" && args2.length > 2) {
|
|
27413
|
+
return {
|
|
27414
|
+
allowed: false,
|
|
27415
|
+
message: "Usage through swarm_command: `/swarm help` or `/swarm help <command>`."
|
|
27416
|
+
};
|
|
27417
|
+
}
|
|
27418
|
+
return { allowed: true };
|
|
27419
|
+
}
|
|
27420
|
+
function classifySwarmCommandChatFallbackUse(resolved) {
|
|
27421
|
+
const canonicalKey = canonicalCommandKey(resolved);
|
|
27422
|
+
const args2 = resolved.remainingArgs;
|
|
27423
|
+
if (canonicalKey === "config doctor" && args2.some((arg) => arg === "--fix" || arg === "-f")) {
|
|
27424
|
+
return {
|
|
27425
|
+
allowed: false,
|
|
27426
|
+
message: "/swarm config doctor --fix is not available through chat fallback because it can modify configuration files. Run the CLI command directly when you intend to apply fixes."
|
|
27427
|
+
};
|
|
27428
|
+
}
|
|
27429
|
+
if (canonicalKey === "knowledge migrate" || canonicalKey === "knowledge quarantine" || canonicalKey === "knowledge restore" || canonicalKey === "memory import" || canonicalKey === "memory migrate" || canonicalKey === "memory compact" || canonicalKey === "sdd project") {
|
|
27430
|
+
return {
|
|
27431
|
+
allowed: false,
|
|
27432
|
+
message: `/swarm ${canonicalKey} is not available through chat fallback because it mutates .swarm state. ` + "Run the CLI command directly after confirming the intended state change."
|
|
27433
|
+
};
|
|
27434
|
+
}
|
|
27435
|
+
return { allowed: true };
|
|
27436
|
+
}
|
|
27437
|
+
var SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, NO_ARGS, SUMMARY_ID_PATTERN, TASK_ID_PATTERN;
|
|
27438
|
+
var init_tool_policy = __esm(() => {
|
|
27439
|
+
init_command_dispatch();
|
|
27440
|
+
init_registry();
|
|
27441
|
+
SWARM_COMMAND_TOOL_COMMANDS = lazyArray(() => VALID_COMMANDS.filter((cmd) => {
|
|
27442
|
+
const policy = COMMAND_REGISTRY[cmd]?.toolPolicy;
|
|
27443
|
+
return policy === "agent" || policy === "human-only";
|
|
27444
|
+
}).sort());
|
|
27445
|
+
SWARM_COMMAND_TOOL_ALLOWLIST = lazySet(() => VALID_COMMANDS.filter((cmd) => COMMAND_REGISTRY[cmd]?.toolPolicy === "agent"));
|
|
27446
|
+
HUMAN_ONLY_SWARM_COMMANDS = lazySet(() => VALID_COMMANDS.filter((cmd) => {
|
|
27447
|
+
const policy = COMMAND_REGISTRY[cmd]?.toolPolicy;
|
|
27448
|
+
return policy === "human-only" || policy === "restricted";
|
|
27449
|
+
}));
|
|
27450
|
+
NO_ARGS = lazySet(() => VALID_COMMANDS.filter((cmd) => COMMAND_REGISTRY[cmd]?.toolNoArgs === true));
|
|
27451
|
+
SUMMARY_ID_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
|
|
27452
|
+
TASK_ID_PATTERN = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
27453
|
+
});
|
|
27454
|
+
|
|
27150
27455
|
// src/sandbox/win32/runner-client.ts
|
|
27151
27456
|
var exports_runner_client = {};
|
|
27152
27457
|
__export(exports_runner_client, {
|
|
@@ -27154,7 +27459,7 @@ __export(exports_runner_client, {
|
|
|
27154
27459
|
execute: () => execute,
|
|
27155
27460
|
buildDefaultPolicy: () => buildDefaultPolicy,
|
|
27156
27461
|
_resetProbeCache: () => _resetProbeCache,
|
|
27157
|
-
_internals: () =>
|
|
27462
|
+
_internals: () => _internals14,
|
|
27158
27463
|
RUNNER_EXIT_CODES: () => RUNNER_EXIT_CODES
|
|
27159
27464
|
});
|
|
27160
27465
|
import { spawn, spawnSync } from "node:child_process";
|
|
@@ -27203,7 +27508,7 @@ function probe() {
|
|
|
27203
27508
|
};
|
|
27204
27509
|
return _cachedProbe;
|
|
27205
27510
|
}
|
|
27206
|
-
const binary2 =
|
|
27511
|
+
const binary2 = _internals14.findRunnerBinary();
|
|
27207
27512
|
if (!binary2) {
|
|
27208
27513
|
_cachedProbe = {
|
|
27209
27514
|
available: false,
|
|
@@ -27215,7 +27520,7 @@ function probe() {
|
|
|
27215
27520
|
return _cachedProbe;
|
|
27216
27521
|
}
|
|
27217
27522
|
try {
|
|
27218
|
-
const result =
|
|
27523
|
+
const result = _internals14.spawnRunner(binary2, ["--probe"], {
|
|
27219
27524
|
windowsHide: true,
|
|
27220
27525
|
encoding: "utf-8",
|
|
27221
27526
|
timeout: 2000,
|
|
@@ -27268,7 +27573,7 @@ function probe() {
|
|
|
27268
27573
|
}
|
|
27269
27574
|
}
|
|
27270
27575
|
async function execute(command, policy, mode = "auto") {
|
|
27271
|
-
const binary2 =
|
|
27576
|
+
const binary2 = _internals14.findRunnerBinary();
|
|
27272
27577
|
if (!binary2) {
|
|
27273
27578
|
throw new Error("runner binary not found");
|
|
27274
27579
|
}
|
|
@@ -27285,7 +27590,7 @@ async function execute(command, policy, mode = "auto") {
|
|
|
27285
27590
|
unref.call(timeout);
|
|
27286
27591
|
}
|
|
27287
27592
|
try {
|
|
27288
|
-
proc =
|
|
27593
|
+
proc = _internals14.spawnAsync(binary2, args2, {
|
|
27289
27594
|
windowsHide: true,
|
|
27290
27595
|
stdio: ["pipe", "pipe", "pipe"],
|
|
27291
27596
|
cwd: policy.workspace_roots[0] ?? os4.tmpdir()
|
|
@@ -27371,7 +27676,7 @@ function buildDefaultPolicy(workspaceRoot, runId) {
|
|
|
27371
27676
|
deny_symlink_egress: true
|
|
27372
27677
|
};
|
|
27373
27678
|
}
|
|
27374
|
-
var _runtimeDir, RUNNER_EXIT_CODES, _cachedProbe,
|
|
27679
|
+
var _runtimeDir, RUNNER_EXIT_CODES, _cachedProbe, _internals14;
|
|
27375
27680
|
var init_runner_client = __esm(() => {
|
|
27376
27681
|
init_logger();
|
|
27377
27682
|
_runtimeDir = fileURLToPath(new URL(".", import.meta.url));
|
|
@@ -27385,7 +27690,7 @@ var init_runner_client = __esm(() => {
|
|
|
27385
27690
|
OS_API_FAILURE: 68,
|
|
27386
27691
|
PROBE_FAILED: 69
|
|
27387
27692
|
};
|
|
27388
|
-
|
|
27693
|
+
_internals14 = {
|
|
27389
27694
|
findRunnerBinary,
|
|
27390
27695
|
spawnRunner: spawnSync,
|
|
27391
27696
|
spawnAsync: spawn
|
|
@@ -27636,7 +27941,7 @@ class BubblewrapSandboxExecutor {
|
|
|
27636
27941
|
this._available = false;
|
|
27637
27942
|
this._disabledReason = null;
|
|
27638
27943
|
try {
|
|
27639
|
-
if (!
|
|
27944
|
+
if (!_internals15.probeBwrap()) {
|
|
27640
27945
|
this._disabledReason = "bwrap not available or not functional";
|
|
27641
27946
|
warn(`Sandbox disabled: ${this._disabledReason}. Falling through to tool-layer enforcement.`);
|
|
27642
27947
|
} else {
|
|
@@ -27707,12 +28012,12 @@ class BubblewrapSandboxExecutor {
|
|
|
27707
28012
|
return {};
|
|
27708
28013
|
}
|
|
27709
28014
|
}
|
|
27710
|
-
var BWRAP_VERSION_EXIT = 0, BWRAP_UNAVAILABLE_CODES,
|
|
28015
|
+
var BWRAP_VERSION_EXIT = 0, BWRAP_UNAVAILABLE_CODES, _internals15;
|
|
27711
28016
|
var init_bubblewrap_executor = __esm(() => {
|
|
27712
28017
|
init_logger();
|
|
27713
28018
|
init_executor();
|
|
27714
28019
|
BWRAP_UNAVAILABLE_CODES = new Set(["ENOENT", "EACCES", "ENOSPC"]);
|
|
27715
|
-
|
|
28020
|
+
_internals15 = {
|
|
27716
28021
|
probeBwrap
|
|
27717
28022
|
};
|
|
27718
28023
|
});
|
|
@@ -27799,7 +28104,7 @@ class MacOSSandboxExecutor {
|
|
|
27799
28104
|
this._available = false;
|
|
27800
28105
|
this._disabledReason = null;
|
|
27801
28106
|
try {
|
|
27802
|
-
if (!
|
|
28107
|
+
if (!_internals16.probeSandboxExec()) {
|
|
27803
28108
|
this._disabledReason = "sandbox-exec not available or not functional";
|
|
27804
28109
|
warn(`Sandbox disabled: ${this._disabledReason}. Falling through to tool-layer enforcement.`);
|
|
27805
28110
|
} else {
|
|
@@ -27824,7 +28129,7 @@ class MacOSSandboxExecutor {
|
|
|
27824
28129
|
if (!this._available) {
|
|
27825
28130
|
throw new SandboxError("Sandbox not available", "SANDBOX_UNAVAILABLE");
|
|
27826
28131
|
}
|
|
27827
|
-
if (!
|
|
28132
|
+
if (!_internals16.probeSandboxExec()) {
|
|
27828
28133
|
this._available = false;
|
|
27829
28134
|
this._disabledReason = "sandbox-exec became unavailable between calls";
|
|
27830
28135
|
warn(`Sandbox disabled: ${this._disabledReason}. Falling through to tool-layer enforcement.`);
|
|
@@ -27857,12 +28162,12 @@ class MacOSSandboxExecutor {
|
|
|
27857
28162
|
};
|
|
27858
28163
|
}
|
|
27859
28164
|
}
|
|
27860
|
-
var SANDBOX_UNAVAILABLE_CODES,
|
|
28165
|
+
var SANDBOX_UNAVAILABLE_CODES, _internals16;
|
|
27861
28166
|
var init_sandbox_exec_executor = __esm(() => {
|
|
27862
28167
|
init_logger();
|
|
27863
28168
|
init_executor();
|
|
27864
28169
|
SANDBOX_UNAVAILABLE_CODES = new Set(["ENOENT", "EACCES", "ENOSPC"]);
|
|
27865
|
-
|
|
28170
|
+
_internals16 = {
|
|
27866
28171
|
probeSandboxExec
|
|
27867
28172
|
};
|
|
27868
28173
|
});
|
|
@@ -27999,7 +28304,7 @@ class WindowsSandboxExecutor {
|
|
|
27999
28304
|
this._disabled = false;
|
|
28000
28305
|
this._disabledReason = null;
|
|
28001
28306
|
try {
|
|
28002
|
-
if (!
|
|
28307
|
+
if (!_internals17.probeWindowsSandbox()) {
|
|
28003
28308
|
this._available = false;
|
|
28004
28309
|
this._disabledReason = "Windows sandbox not available or not functional";
|
|
28005
28310
|
warn(`Sandbox unavailable: ${this._disabledReason}. Falling through to tool-layer enforcement.`);
|
|
@@ -28025,7 +28330,7 @@ class WindowsSandboxExecutor {
|
|
|
28025
28330
|
if (!this.isAvailable()) {
|
|
28026
28331
|
throw new SandboxError("Sandbox not available", "SANDBOX_UNAVAILABLE");
|
|
28027
28332
|
}
|
|
28028
|
-
if (!
|
|
28333
|
+
if (!_internals17.probeWindowsSandbox()) {
|
|
28029
28334
|
this._available = false;
|
|
28030
28335
|
this._disabledReason = "Windows sandbox became unavailable between calls";
|
|
28031
28336
|
warn(`Sandbox disabled: ${this._disabledReason}. Falling through to tool-layer enforcement.`);
|
|
@@ -28090,7 +28395,7 @@ try {
|
|
|
28090
28395
|
};
|
|
28091
28396
|
}
|
|
28092
28397
|
}
|
|
28093
|
-
var SANDBOX_UNAVAILABLE_CODES2,
|
|
28398
|
+
var SANDBOX_UNAVAILABLE_CODES2, _internals17;
|
|
28094
28399
|
var init_restricted_environment_executor = __esm(() => {
|
|
28095
28400
|
init_logger();
|
|
28096
28401
|
init_executor();
|
|
@@ -28100,7 +28405,7 @@ var init_restricted_environment_executor = __esm(() => {
|
|
|
28100
28405
|
"EPERM",
|
|
28101
28406
|
"ENOSPC"
|
|
28102
28407
|
]);
|
|
28103
|
-
|
|
28408
|
+
_internals17 = {
|
|
28104
28409
|
probeWindowsSandbox
|
|
28105
28410
|
};
|
|
28106
28411
|
});
|
|
@@ -28158,7 +28463,7 @@ class NativeWindowsSandboxExecutor {
|
|
|
28158
28463
|
return this._fallbackExecutor.wrapCommand(command, scopePaths, tempDir);
|
|
28159
28464
|
}
|
|
28160
28465
|
_wrapWithRunner(command, scopePaths, tempDir) {
|
|
28161
|
-
const binary2 =
|
|
28466
|
+
const binary2 = _internals14.findRunnerBinary();
|
|
28162
28467
|
if (!binary2) {
|
|
28163
28468
|
throw new SandboxError("Runner binary not found", "RUNNER_NOT_FOUND");
|
|
28164
28469
|
}
|
|
@@ -40959,14 +41264,7 @@ function createToolBeforeHandler(ctx) {
|
|
|
40959
41264
|
throw new Error(`BLOCKED: "7z" with delete-source flag targeting .swarm/ detected — archive with source deletion under .swarm/ is not allowed`);
|
|
40960
41265
|
}
|
|
40961
41266
|
{
|
|
40962
|
-
const HUMAN_ONLY_SWARM_SUBCOMMANDS =
|
|
40963
|
-
"acknowledge-spec-drift",
|
|
40964
|
-
"reset",
|
|
40965
|
-
"reset-session",
|
|
40966
|
-
"rollback",
|
|
40967
|
-
"checkpoint",
|
|
40968
|
-
"consolidate"
|
|
40969
|
-
]);
|
|
41267
|
+
const HUMAN_ONLY_SWARM_SUBCOMMANDS = HUMAN_ONLY_SWARM_COMMANDS;
|
|
40970
41268
|
let probe2 = seg.replace(/^(?:[A-Za-z_][A-Za-z0-9_]*=\S+\s+)+/, "").replace(/^eval(?:\s+--)?\s+["']?/, "").replace(/["']\s*$/, "").replace(/^\$\(\s*/, "").replace(/^\(\s*/, "").replace(/\s*\)$/, "").replace(/^`/, "").replace(/`$/, "").trim();
|
|
40971
41269
|
for (let i2 = 0;i2 < 4; i2++) {
|
|
40972
41270
|
const before = probe2;
|
|
@@ -40974,17 +41272,35 @@ function createToolBeforeHandler(ctx) {
|
|
|
40974
41272
|
if (probe2 === before)
|
|
40975
41273
|
break;
|
|
40976
41274
|
}
|
|
40977
|
-
const swarmCliBypassMatch = probe2.match(/^\\?(?:bunx|npx|pnpx|npm(?:\s+(?:exec|x)(?:\s+--)?)?|pnpm(?:\s+(?:dlx|exec))?|yarn(?:\s+(?:dlx|exec))?|bun(?:\s+x)?|node|deno\s+run|tsx|ts-node)\b[^|;&]*?\bopencode-swarm\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+)/i);
|
|
40978
|
-
if (swarmCliBypassMatch
|
|
40979
|
-
|
|
41275
|
+
const swarmCliBypassMatch = probe2.match(/^\\?(?:bunx|npx|pnpx|npm(?:\s+(?:exec|x)(?:\s+--)?)?|pnpm(?:\s+(?:dlx|exec))?|yarn(?:\s+(?:dlx|exec))?|bun(?:\s+x)?|node|deno\s+run|tsx|ts-node)\b[^|;&]*?\bopencode-swarm\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+(?:\s+(?!-)[A-Za-z0-9_-]+)?)/i);
|
|
41276
|
+
if (swarmCliBypassMatch) {
|
|
41277
|
+
const captured = swarmCliBypassMatch[1];
|
|
41278
|
+
const normalized = captured.trim().split(/\s+/).join(" ");
|
|
41279
|
+
const firstToken = normalized.includes(" ") ? normalized.split(" ")[0] : normalized;
|
|
41280
|
+
const cmdName = HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) ? normalized : firstToken;
|
|
41281
|
+
if (HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) || HUMAN_ONLY_SWARM_SUBCOMMANDS.has(firstToken)) {
|
|
41282
|
+
throw new Error(`BLOCKED: "${cmdName}" is a human-only swarm command and may not be invoked from shell by an agent. ` + `Present the situation to the user and ask them to run \`/swarm ${cmdName}\` themselves.`);
|
|
41283
|
+
}
|
|
40980
41284
|
}
|
|
40981
|
-
const swarmBareBinMatch = probe2.match(/^\\?opencode-swarm\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+)/i);
|
|
40982
|
-
if (swarmBareBinMatch
|
|
40983
|
-
|
|
41285
|
+
const swarmBareBinMatch = probe2.match(/^\\?opencode-swarm\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+(?:\s+(?!-)[A-Za-z0-9_-]+)?)/i);
|
|
41286
|
+
if (swarmBareBinMatch) {
|
|
41287
|
+
const captured = swarmBareBinMatch[1];
|
|
41288
|
+
const normalized = captured.trim().split(/\s+/).join(" ");
|
|
41289
|
+
const firstToken = normalized.includes(" ") ? normalized.split(" ")[0] : normalized;
|
|
41290
|
+
const cmdName = HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) ? normalized : firstToken;
|
|
41291
|
+
if (HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) || HUMAN_ONLY_SWARM_SUBCOMMANDS.has(firstToken)) {
|
|
41292
|
+
throw new Error(`BLOCKED: "${cmdName}" is a human-only swarm command and may not be invoked from shell by an agent. ` + `Present the situation to the user and ask them to run \`/swarm ${cmdName}\` themselves.`);
|
|
41293
|
+
}
|
|
40984
41294
|
}
|
|
40985
|
-
const swarmCliPathMatch = probe2.match(/\bcli[/\\]+index\.[mc]?(?:js|ts)\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+)/i);
|
|
40986
|
-
if (swarmCliPathMatch
|
|
40987
|
-
|
|
41295
|
+
const swarmCliPathMatch = probe2.match(/\bcli[/\\]+index\.[mc]?(?:js|ts)\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+(?:\s+(?!-)[A-Za-z0-9_-]+)?)/i);
|
|
41296
|
+
if (swarmCliPathMatch) {
|
|
41297
|
+
const captured = swarmCliPathMatch[1];
|
|
41298
|
+
const normalized = captured.trim().split(/\s+/).join(" ");
|
|
41299
|
+
const firstToken = normalized.includes(" ") ? normalized.split(" ")[0] : normalized;
|
|
41300
|
+
const cmdName = HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) ? normalized : firstToken;
|
|
41301
|
+
if (HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) || HUMAN_ONLY_SWARM_SUBCOMMANDS.has(firstToken)) {
|
|
41302
|
+
throw new Error(`BLOCKED: "${cmdName}" is a human-only swarm command and may not be invoked from shell by an agent. ` + `Present the situation to the user and ask them to run \`/swarm ${cmdName}\` themselves.`);
|
|
41303
|
+
}
|
|
40988
41304
|
}
|
|
40989
41305
|
}
|
|
40990
41306
|
{
|
|
@@ -41338,11 +41654,15 @@ function createToolBeforeHandler(ctx) {
|
|
|
41338
41654
|
}
|
|
41339
41655
|
return out2;
|
|
41340
41656
|
}
|
|
41657
|
+
function getHumanOnlyAlternation() {
|
|
41658
|
+
return [...HUMAN_ONLY_SWARM_COMMANDS].map((c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).sort((a, b) => b.length - a.length).join("|");
|
|
41659
|
+
}
|
|
41341
41660
|
function patchPayloadHasHumanOnlyInvocation(args2) {
|
|
41342
41661
|
const payloads = extractAllPatchPayloads(args2);
|
|
41343
41662
|
if (payloads.length === 0)
|
|
41344
41663
|
return false;
|
|
41345
|
-
const
|
|
41664
|
+
const alternation = getHumanOnlyAlternation();
|
|
41665
|
+
const re = new RegExp(`\\bopencode-swarm\\b[\\s\\S]*?\\brun\\s+(${alternation})\\b`, "i");
|
|
41346
41666
|
return payloads.some((p) => re.test(p));
|
|
41347
41667
|
}
|
|
41348
41668
|
function extractPatchTargetPaths(tool, args2) {
|
|
@@ -41414,7 +41734,7 @@ function createToolBeforeHandler(ctx) {
|
|
|
41414
41734
|
throw new Error("SPEC_DRIFT_VIOLATION: Direct writes to .swarm/spec-staleness.json are blocked. " + "This file is system-managed and gates plan-mutating tools while spec drift is unresolved. " + "Present the drift to the user and ask them to run /swarm clarify or /swarm acknowledge-spec-drift.");
|
|
41415
41735
|
}
|
|
41416
41736
|
const content = toolArgs?.content ?? toolArgs?.text ?? toolArgs?.new_string ?? toolArgs?.newText;
|
|
41417
|
-
if (typeof content === "string" &&
|
|
41737
|
+
if (typeof content === "string" && new RegExp(`\\bopencode-swarm\\b[\\s\\S]*?\\brun\\s+(${getHumanOnlyAlternation()})\\b`, "i").test(content)) {
|
|
41418
41738
|
throw new Error("BLOCKED: write/edit tool would create a script invoking a human-only swarm CLI subcommand. " + "Present the situation to the user and ask them to run the command themselves.");
|
|
41419
41739
|
}
|
|
41420
41740
|
}
|
|
@@ -41653,6 +41973,7 @@ function createToolBeforeHandler(ctx) {
|
|
|
41653
41973
|
};
|
|
41654
41974
|
}
|
|
41655
41975
|
var init_tool_before = __esm(() => {
|
|
41976
|
+
init_tool_policy();
|
|
41656
41977
|
init_constants();
|
|
41657
41978
|
init_schema();
|
|
41658
41979
|
init_executor();
|
|
@@ -42059,9 +42380,9 @@ function createGuardrailsHooks(directory, directoryOrConfig, config2, authorityC
|
|
|
42059
42380
|
const isContentFilter = CONTENT_FILTER_PATTERN.test(errorSignal);
|
|
42060
42381
|
if (session && !session.modelFallbackExhausted) {
|
|
42061
42382
|
session.model_fallback_index++;
|
|
42062
|
-
const swarmId =
|
|
42383
|
+
const swarmId = _internals18.extractSwarmIdFromAgentName(session.agentName);
|
|
42063
42384
|
const baseAgentName = session.agentName ? session.agentName.replace(/^[^_]+[_]/, "") : "";
|
|
42064
|
-
const swarmAgents =
|
|
42385
|
+
const swarmAgents = _internals18.getSwarmAgents(swarmId);
|
|
42065
42386
|
const fallbackModels = swarmAgents?.[baseAgentName]?.fallback_models;
|
|
42066
42387
|
session.modelFallbackExhausted = !fallbackModels || session.model_fallback_index > fallbackModels.length;
|
|
42067
42388
|
session.pendingAdvisoryMessages ??= [];
|
|
@@ -42084,12 +42405,12 @@ function createGuardrailsHooks(directory, directoryOrConfig, config2, authorityC
|
|
|
42084
42405
|
let modelFallbackAdvisoryEmitted = false;
|
|
42085
42406
|
if (session && isTransientMatch && !session.modelFallbackExhausted && !isDegraded) {
|
|
42086
42407
|
session.model_fallback_index++;
|
|
42087
|
-
const swarmId =
|
|
42408
|
+
const swarmId = _internals18.extractSwarmIdFromAgentName(session.agentName);
|
|
42088
42409
|
const baseAgentName = session.agentName ? session.agentName.replace(/^[^_]+[_]/, "") : "";
|
|
42089
|
-
const swarmAgents =
|
|
42410
|
+
const swarmAgents = _internals18.getSwarmAgents(swarmId);
|
|
42090
42411
|
const fallbackModels = swarmAgents?.[baseAgentName]?.fallback_models;
|
|
42091
42412
|
session.modelFallbackExhausted = !fallbackModels || session.model_fallback_index > fallbackModels.length;
|
|
42092
|
-
const fallbackModel =
|
|
42413
|
+
const fallbackModel = _internals18.resolveFallbackModel(baseAgentName, session.model_fallback_index, swarmAgents);
|
|
42093
42414
|
const primaryModel = swarmAgents?.[baseAgentName]?.model ?? "default";
|
|
42094
42415
|
if (fallbackModel) {
|
|
42095
42416
|
if (swarmAgents?.[baseAgentName]) {
|
|
@@ -42127,7 +42448,7 @@ function createGuardrailsHooks(directory, directoryOrConfig, config2, authorityC
|
|
|
42127
42448
|
messagesTransform
|
|
42128
42449
|
};
|
|
42129
42450
|
}
|
|
42130
|
-
var
|
|
42451
|
+
var _internals18, SPEC_DRIFT_BLOCKED_TOOLS, TRANSIENT_STATUS_CODES2, TRANSIENT_MODEL_ERROR_PATTERN2, DEGRADED_ERROR_PATTERN, CONTENT_FILTER_PATTERN, toolCallsSinceLastWrite, noOpWarningIssued;
|
|
42131
42452
|
var init_guardrails = __esm(() => {
|
|
42132
42453
|
init_agents2();
|
|
42133
42454
|
init_constants();
|
|
@@ -42145,7 +42466,7 @@ var init_guardrails = __esm(() => {
|
|
|
42145
42466
|
init_messages_transform();
|
|
42146
42467
|
init_stored_input_args();
|
|
42147
42468
|
init_tool_before();
|
|
42148
|
-
|
|
42469
|
+
_internals18 = {
|
|
42149
42470
|
extractSwarmIdFromAgentName,
|
|
42150
42471
|
getSwarmAgents,
|
|
42151
42472
|
getMostRecentAssistantText,
|
|
@@ -42380,21 +42701,21 @@ async function atomicWriteFile(targetPath, content) {
|
|
|
42380
42701
|
const tempPath = `${targetPath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
42381
42702
|
try {
|
|
42382
42703
|
await bunWrite(tempPath, content);
|
|
42383
|
-
|
|
42704
|
+
_internals19.renameSync(tempPath, targetPath);
|
|
42384
42705
|
} finally {
|
|
42385
42706
|
try {
|
|
42386
|
-
|
|
42707
|
+
_internals19.unlinkSync(tempPath);
|
|
42387
42708
|
} catch {}
|
|
42388
42709
|
}
|
|
42389
42710
|
}
|
|
42390
42711
|
function withTaskEvidenceLock(directory, taskId, agent, fn2) {
|
|
42391
42712
|
return withEvidenceLock(directory, taskEvidenceRelPath(taskId), agent, taskId, fn2);
|
|
42392
42713
|
}
|
|
42393
|
-
var
|
|
42714
|
+
var _internals19;
|
|
42394
42715
|
var init_task_file = __esm(() => {
|
|
42395
42716
|
init_bun_compat();
|
|
42396
42717
|
init_lock();
|
|
42397
|
-
|
|
42718
|
+
_internals19 = {
|
|
42398
42719
|
renameSync: renameSync6,
|
|
42399
42720
|
unlinkSync: unlinkSync4
|
|
42400
42721
|
};
|
|
@@ -42947,7 +43268,7 @@ function createDelegationGateHook(config2, directory) {
|
|
|
42947
43268
|
if (standardWorktreeSerializationSessions.has(input.sessionID)) {
|
|
42948
43269
|
throw new Error("STANDARD_WORKTREE_ISOLATION_SERIALIZED: prior standard worktree isolation setup failed in this session; wait for the active coder task to finish before dispatching another coder.");
|
|
42949
43270
|
}
|
|
42950
|
-
const plan = await
|
|
43271
|
+
const plan = await _internals20.loadPlanJsonOnly(directory);
|
|
42951
43272
|
if (!plan)
|
|
42952
43273
|
return;
|
|
42953
43274
|
const profile = plan.execution_profile;
|
|
@@ -43562,7 +43883,7 @@ ${warningLines.join(`
|
|
|
43562
43883
|
toolAfter
|
|
43563
43884
|
};
|
|
43564
43885
|
}
|
|
43565
|
-
var EvidenceTaskIdPlanSchema, pendingCoderScopeByTaskId, SWARM_BACKGROUND_TASK_BLOCKED_MESSAGE, ACTIVE_PARALLEL_TASK_STATES,
|
|
43886
|
+
var EvidenceTaskIdPlanSchema, pendingCoderScopeByTaskId, SWARM_BACKGROUND_TASK_BLOCKED_MESSAGE, ACTIVE_PARALLEL_TASK_STATES, _internals20;
|
|
43566
43887
|
var init_delegation_gate = __esm(() => {
|
|
43567
43888
|
init_zod();
|
|
43568
43889
|
init_schema();
|
|
@@ -43592,7 +43913,7 @@ var init_delegation_gate = __esm(() => {
|
|
|
43592
43913
|
"reviewer_run",
|
|
43593
43914
|
"tests_run"
|
|
43594
43915
|
]);
|
|
43595
|
-
|
|
43916
|
+
_internals20 = {
|
|
43596
43917
|
resolveEvidenceTaskId,
|
|
43597
43918
|
resolveDelegatedPlanTaskId,
|
|
43598
43919
|
buildParallelExecutionGuidance,
|
|
@@ -43926,7 +44247,7 @@ __export(exports_state, {
|
|
|
43926
44247
|
advanceTaskState: () => advanceTaskState,
|
|
43927
44248
|
addKnowledgeAckDedup: () => addKnowledgeAckDedup,
|
|
43928
44249
|
_resetCouncilDisagreementWarnings: () => _resetCouncilDisagreementWarnings,
|
|
43929
|
-
_internals: () =>
|
|
44250
|
+
_internals: () => _internals21,
|
|
43930
44251
|
MAX_TRACKED_KNOWLEDGE_ACKS: () => MAX_TRACKED_KNOWLEDGE_ACKS,
|
|
43931
44252
|
MAX_TRACKED_CRITICAL_SHOWN: () => MAX_TRACKED_CRITICAL_SHOWN,
|
|
43932
44253
|
AgentRunContext: () => AgentRunContext
|
|
@@ -44054,10 +44375,10 @@ function startAgentSession(sessionId, agentName, staleDurationMs = 7200000, dire
|
|
|
44054
44375
|
swarmState.agentSessions.set(sessionId, sessionState);
|
|
44055
44376
|
telemetry.sessionStarted(sessionId, agentName);
|
|
44056
44377
|
swarmState.activeAgent.set(sessionId, agentName);
|
|
44057
|
-
|
|
44378
|
+
_internals21.applyRehydrationCache(sessionState);
|
|
44058
44379
|
if (directory) {
|
|
44059
44380
|
let rehydrationPromise;
|
|
44060
|
-
rehydrationPromise =
|
|
44381
|
+
rehydrationPromise = _internals21.rehydrateSessionFromDisk(directory, sessionState).then(async () => {
|
|
44061
44382
|
try {
|
|
44062
44383
|
sessionState.prSubscriptions = await rehydratePrSubscriptions(sessionId, directory);
|
|
44063
44384
|
} catch (err2) {
|
|
@@ -44233,7 +44554,7 @@ function ensureAgentSession(sessionId, agentName, directory) {
|
|
|
44233
44554
|
session.lastToolCallTime = now;
|
|
44234
44555
|
return session;
|
|
44235
44556
|
}
|
|
44236
|
-
|
|
44557
|
+
_internals21.startAgentSession(sessionId, agentName ?? "unknown", 7200000, directory);
|
|
44237
44558
|
session = swarmState.agentSessions.get(sessionId);
|
|
44238
44559
|
if (!session) {
|
|
44239
44560
|
throw new Error(`Failed to create guardrail session for ${sessionId}`);
|
|
@@ -44594,8 +44915,8 @@ function applyRehydrationCache(session) {
|
|
|
44594
44915
|
}
|
|
44595
44916
|
}
|
|
44596
44917
|
async function rehydrateSessionFromDisk(directory, session) {
|
|
44597
|
-
await
|
|
44598
|
-
|
|
44918
|
+
await _internals21.buildRehydrationCache(directory);
|
|
44919
|
+
_internals21.applyRehydrationCache(session);
|
|
44599
44920
|
}
|
|
44600
44921
|
function hasActiveTurboMode(sessionID) {
|
|
44601
44922
|
if (sessionID) {
|
|
@@ -44703,7 +45024,7 @@ async function rehydratePrSubscriptions(sessionID, directory) {
|
|
|
44703
45024
|
}
|
|
44704
45025
|
return map2;
|
|
44705
45026
|
}
|
|
44706
|
-
var _rehydrationCache = null, _councilDisagreementWarned, STATE_ORDER, _toolAggregates, defaultRunContext, _runContexts, swarmState, MAX_TRACKED_CRITICAL_SHOWN = 500, MAX_TRACKED_KNOWLEDGE_ACKS = 5000,
|
|
45027
|
+
var _rehydrationCache = null, _councilDisagreementWarned, STATE_ORDER, _toolAggregates, defaultRunContext, _runContexts, swarmState, MAX_TRACKED_CRITICAL_SHOWN = 500, MAX_TRACKED_KNOWLEDGE_ACKS = 5000, _internals21;
|
|
44707
45028
|
var init_state = __esm(() => {
|
|
44708
45029
|
init_constants();
|
|
44709
45030
|
init_plan_schema();
|
|
@@ -44746,7 +45067,7 @@ var init_state = __esm(() => {
|
|
|
44746
45067
|
fullAutoEnabledInConfig: false,
|
|
44747
45068
|
environmentProfiles: defaultRunContext.environmentProfiles
|
|
44748
45069
|
};
|
|
44749
|
-
|
|
45070
|
+
_internals21 = {
|
|
44750
45071
|
swarmState,
|
|
44751
45072
|
resetSwarmState,
|
|
44752
45073
|
ensureAgentSession,
|
|
@@ -58414,7 +58735,7 @@ function resetToRemoteBranch(cwd, options) {
|
|
|
58414
58735
|
const prunedBranches = [];
|
|
58415
58736
|
try {
|
|
58416
58737
|
const currentBranch = getCurrentBranch(cwd);
|
|
58417
|
-
const defaultRemoteBranch =
|
|
58738
|
+
const defaultRemoteBranch = _internals22.detectDefaultRemoteBranch(cwd);
|
|
58418
58739
|
if (!defaultRemoteBranch) {
|
|
58419
58740
|
return {
|
|
58420
58741
|
success: false,
|
|
@@ -58596,7 +58917,7 @@ function resetToRemoteBranch(cwd, options) {
|
|
|
58596
58917
|
function resetToMainAfterMerge(cwd, options) {
|
|
58597
58918
|
const warnings = [];
|
|
58598
58919
|
try {
|
|
58599
|
-
const defaultBranch =
|
|
58920
|
+
const defaultBranch = _internals22.detectDefaultRemoteBranch(cwd);
|
|
58600
58921
|
if (!defaultBranch) {
|
|
58601
58922
|
return {
|
|
58602
58923
|
success: false,
|
|
@@ -58623,7 +58944,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58623
58944
|
}
|
|
58624
58945
|
if (currentBranch === defaultBranch) {
|
|
58625
58946
|
try {
|
|
58626
|
-
const logOutput =
|
|
58947
|
+
const logOutput = _internals22.gitExec(["log", `${targetBranch}..HEAD`, "--oneline"], cwd);
|
|
58627
58948
|
if (logOutput.trim().length > 0) {
|
|
58628
58949
|
return {
|
|
58629
58950
|
success: false,
|
|
@@ -58638,11 +58959,11 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58638
58959
|
} catch {}
|
|
58639
58960
|
} else {
|
|
58640
58961
|
try {
|
|
58641
|
-
|
|
58962
|
+
_internals22.gitExec(["rev-parse", "--abbrev-ref", `${currentBranch}@{upstream}`], cwd);
|
|
58642
58963
|
} catch {
|
|
58643
58964
|
try {
|
|
58644
|
-
const localSha =
|
|
58645
|
-
const remoteSha =
|
|
58965
|
+
const localSha = _internals22.gitExec(["rev-parse", "HEAD"], cwd).trim();
|
|
58966
|
+
const remoteSha = _internals22.gitExec(["rev-parse", targetBranch], cwd).trim();
|
|
58646
58967
|
if (localSha !== remoteSha) {
|
|
58647
58968
|
return {
|
|
58648
58969
|
success: false,
|
|
@@ -58668,7 +58989,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58668
58989
|
}
|
|
58669
58990
|
}
|
|
58670
58991
|
try {
|
|
58671
|
-
|
|
58992
|
+
_internals22.gitExec(["fetch", "--prune", "origin"], cwd);
|
|
58672
58993
|
} catch (err2) {
|
|
58673
58994
|
return {
|
|
58674
58995
|
success: false,
|
|
@@ -58684,7 +59005,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58684
59005
|
let switchedBranch = false;
|
|
58685
59006
|
if (currentBranch !== defaultBranch) {
|
|
58686
59007
|
try {
|
|
58687
|
-
|
|
59008
|
+
_internals22.gitExec(["checkout", defaultBranch], cwd);
|
|
58688
59009
|
switchedBranch = true;
|
|
58689
59010
|
} catch (err2) {
|
|
58690
59011
|
return {
|
|
@@ -58699,7 +59020,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58699
59020
|
}
|
|
58700
59021
|
}
|
|
58701
59022
|
try {
|
|
58702
|
-
|
|
59023
|
+
_internals22.gitExec(["reset", "--hard", targetBranch], cwd);
|
|
58703
59024
|
} catch (err2) {
|
|
58704
59025
|
return {
|
|
58705
59026
|
success: false,
|
|
@@ -58720,7 +59041,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58720
59041
|
while (Date.now() < endTime) {}
|
|
58721
59042
|
}
|
|
58722
59043
|
try {
|
|
58723
|
-
|
|
59044
|
+
_internals22.gitExec(["checkout", "--", "."], cwd);
|
|
58724
59045
|
discardSucceeded = true;
|
|
58725
59046
|
break;
|
|
58726
59047
|
} catch {}
|
|
@@ -58731,18 +59052,18 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58731
59052
|
changesDiscarded = discardSucceeded;
|
|
58732
59053
|
}
|
|
58733
59054
|
try {
|
|
58734
|
-
|
|
59055
|
+
_internals22.gitExec(["clean", "-fd"], cwd);
|
|
58735
59056
|
} catch {
|
|
58736
59057
|
warnings.push("Could not clean untracked files");
|
|
58737
59058
|
}
|
|
58738
59059
|
let branchDeleted = false;
|
|
58739
59060
|
if (switchedBranch && previousBranch !== defaultBranch) {
|
|
58740
59061
|
try {
|
|
58741
|
-
const mergedOutput =
|
|
59062
|
+
const mergedOutput = _internals22.gitExec(["branch", "--merged", defaultBranch], cwd);
|
|
58742
59063
|
const isMerged = mergedOutput.split(`
|
|
58743
59064
|
`).some((line) => line.trim() === previousBranch || line.trim() === `* ${previousBranch}`);
|
|
58744
59065
|
if (isMerged) {
|
|
58745
|
-
|
|
59066
|
+
_internals22.gitExec(["branch", "-d", previousBranch], cwd);
|
|
58746
59067
|
branchDeleted = true;
|
|
58747
59068
|
} else {
|
|
58748
59069
|
warnings.push(`Branch ${previousBranch} is not merged into ${defaultBranch} — keeping it`);
|
|
@@ -58753,7 +59074,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58753
59074
|
}
|
|
58754
59075
|
if (options?.pruneBranches) {
|
|
58755
59076
|
try {
|
|
58756
|
-
const mergedOutput =
|
|
59077
|
+
const mergedOutput = _internals22.gitExec(["branch", "--merged", defaultBranch], cwd);
|
|
58757
59078
|
const mergedLines = mergedOutput.split(`
|
|
58758
59079
|
`);
|
|
58759
59080
|
for (const line of mergedLines) {
|
|
@@ -58762,7 +59083,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58762
59083
|
continue;
|
|
58763
59084
|
}
|
|
58764
59085
|
try {
|
|
58765
|
-
|
|
59086
|
+
_internals22.gitExec(["branch", "-d", trimmedLine], cwd);
|
|
58766
59087
|
} catch {
|
|
58767
59088
|
warnings.push(`Could not prune branch: ${trimmedLine}`);
|
|
58768
59089
|
}
|
|
@@ -58792,10 +59113,10 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58792
59113
|
};
|
|
58793
59114
|
}
|
|
58794
59115
|
}
|
|
58795
|
-
var GIT_TIMEOUT_MS2 = 30000,
|
|
59116
|
+
var GIT_TIMEOUT_MS2 = 30000, _internals22;
|
|
58796
59117
|
var init_branch = __esm(() => {
|
|
58797
59118
|
init_logger();
|
|
58798
|
-
|
|
59119
|
+
_internals22 = {
|
|
58799
59120
|
gitExec: gitExec2,
|
|
58800
59121
|
detectDefaultRemoteBranch,
|
|
58801
59122
|
getDefaultBaseBranch,
|
|
@@ -59374,7 +59695,7 @@ __export(exports_knowledge_store, {
|
|
|
59374
59695
|
appendRejectedLesson: () => appendRejectedLesson,
|
|
59375
59696
|
appendKnowledgeWithCapEnforcement: () => appendKnowledgeWithCapEnforcement,
|
|
59376
59697
|
appendKnowledge: () => appendKnowledge,
|
|
59377
|
-
_internals: () =>
|
|
59698
|
+
_internals: () => _internals23,
|
|
59378
59699
|
OUTCOME_SIGNAL_SMOOTHING: () => OUTCOME_SIGNAL_SMOOTHING
|
|
59379
59700
|
});
|
|
59380
59701
|
import { existsSync as existsSync13 } from "node:fs";
|
|
@@ -59850,11 +60171,11 @@ async function applyConfidenceDeltas(filePath, deltas) {
|
|
|
59850
60171
|
}
|
|
59851
60172
|
}
|
|
59852
60173
|
}
|
|
59853
|
-
var import_proper_lockfile3, OUTCOME_SIGNAL_SMOOTHING = 4, CONFIDENCE_FLOOR = 0.1, CONFIDENCE_CEILING = 1,
|
|
60174
|
+
var import_proper_lockfile3, OUTCOME_SIGNAL_SMOOTHING = 4, CONFIDENCE_FLOOR = 0.1, CONFIDENCE_CEILING = 1, _internals23;
|
|
59854
60175
|
var init_knowledge_store = __esm(() => {
|
|
59855
60176
|
init_task_file();
|
|
59856
60177
|
import_proper_lockfile3 = __toESM(require_proper_lockfile(), 1);
|
|
59857
|
-
|
|
60178
|
+
_internals23 = {
|
|
59858
60179
|
getPlatformConfigDir,
|
|
59859
60180
|
resolveSwarmKnowledgePath,
|
|
59860
60181
|
resolveSwarmRejectedPath,
|
|
@@ -59899,7 +60220,7 @@ __export(exports_knowledge_events, {
|
|
|
59899
60220
|
countEntryViolationsInWindow: () => countEntryViolationsInWindow,
|
|
59900
60221
|
applyKnowledgeVerdictFeedback: () => applyKnowledgeVerdictFeedback,
|
|
59901
60222
|
appendKnowledgeEvent: () => appendKnowledgeEvent,
|
|
59902
|
-
_internals: () =>
|
|
60223
|
+
_internals: () => _internals24,
|
|
59903
60224
|
RECEIPT_EVENT_TYPES: () => RECEIPT_EVENT_TYPES,
|
|
59904
60225
|
MAX_VIOLATION_TIMESTAMPS: () => MAX_VIOLATION_TIMESTAMPS,
|
|
59905
60226
|
MAX_EVENT_LOG_ENTRIES: () => MAX_EVENT_LOG_ENTRIES,
|
|
@@ -60355,7 +60676,7 @@ async function applyKnowledgeVerdictFeedback(directory, options) {
|
|
|
60355
60676
|
return { processed: 0, bumps: 0 };
|
|
60356
60677
|
}
|
|
60357
60678
|
}
|
|
60358
|
-
var import_proper_lockfile4, KNOWLEDGE_EVENT_SCHEMA_VERSION = 1, MAX_EVENT_LOG_ENTRIES = 5000, counterRollupCache, MAX_COUNTER_ROLLUP_CACHE_DIRS = 32, RECEIPT_EVENT_TYPES, MAX_VIOLATION_TIMESTAMPS = 10, VERDICT_CONFIDENCE_BOOST = 0.03, VERDICT_CONFIDENCE_DECAY = 0.05,
|
|
60679
|
+
var import_proper_lockfile4, KNOWLEDGE_EVENT_SCHEMA_VERSION = 1, MAX_EVENT_LOG_ENTRIES = 5000, counterRollupCache, MAX_COUNTER_ROLLUP_CACHE_DIRS = 32, RECEIPT_EVENT_TYPES, MAX_VIOLATION_TIMESTAMPS = 10, VERDICT_CONFIDENCE_BOOST = 0.03, VERDICT_CONFIDENCE_DECAY = 0.05, _internals24;
|
|
60359
60680
|
var init_knowledge_events = __esm(() => {
|
|
60360
60681
|
init_task_file();
|
|
60361
60682
|
init_logger();
|
|
@@ -60370,7 +60691,7 @@ var init_knowledge_events = __esm(() => {
|
|
|
60370
60691
|
"n_a",
|
|
60371
60692
|
"override"
|
|
60372
60693
|
]);
|
|
60373
|
-
|
|
60694
|
+
_internals24 = {
|
|
60374
60695
|
resolveKnowledgeEventsPath,
|
|
60375
60696
|
resolveKnowledgeCounterBaselinePath,
|
|
60376
60697
|
appendKnowledgeEvent,
|
|
@@ -61911,7 +62232,7 @@ __export(exports_skill_generator, {
|
|
|
61911
62232
|
activeRepoRelativePath: () => activeRepoRelativePath,
|
|
61912
62233
|
activePath: () => activePath,
|
|
61913
62234
|
activateProposal: () => activateProposal,
|
|
61914
|
-
_internals: () =>
|
|
62235
|
+
_internals: () => _internals25,
|
|
61915
62236
|
STRONG_SKILL_OUTCOME_COUNT: () => STRONG_SKILL_OUTCOME_COUNT,
|
|
61916
62237
|
DEFAULT_SKILL_MIN_CONFIRMATIONS: () => DEFAULT_SKILL_MIN_CONFIRMATIONS,
|
|
61917
62238
|
DEFAULT_SKILL_MIN_CONFIDENCE: () => DEFAULT_SKILL_MIN_CONFIDENCE
|
|
@@ -62501,7 +62822,7 @@ async function activateProposal(directory, slug, force = false, options = {}) {
|
|
|
62501
62822
|
try {
|
|
62502
62823
|
await stampSourceEntries(directory, cleanSlug, fm.sourceKnowledgeIds);
|
|
62503
62824
|
try {
|
|
62504
|
-
|
|
62825
|
+
_internals25.unlinkSync(from);
|
|
62505
62826
|
} catch {}
|
|
62506
62827
|
return {
|
|
62507
62828
|
activated: true,
|
|
@@ -62606,7 +62927,7 @@ async function autoApplyProposals(directory, llmDelegate) {
|
|
|
62606
62927
|
}
|
|
62607
62928
|
} else if (verdict === "REJECT") {
|
|
62608
62929
|
try {
|
|
62609
|
-
|
|
62930
|
+
_internals25.unlinkSync(proposal.path);
|
|
62610
62931
|
warn(`[skill-generator] auto-apply rejected proposal "${proposal.slug}"; deleted ${proposal.path}`);
|
|
62611
62932
|
result.rejected.push(proposal.slug);
|
|
62612
62933
|
} catch (delErr) {
|
|
@@ -62716,7 +63037,7 @@ async function regenerateSkill(directory, slug, options = {}) {
|
|
|
62716
63037
|
matchedEntries = all.filter((e) => idSet.has(e.id));
|
|
62717
63038
|
if (matchedEntries.length === idSet.size && idSet.size > 0 && matchedEntries.every((e) => e.status === "archived")) {
|
|
62718
63039
|
try {
|
|
62719
|
-
await
|
|
63040
|
+
await _internals25.retireSkill(directory, cleanSlug, "auto-retire: all source knowledge entries archived at regeneration time");
|
|
62720
63041
|
} catch {}
|
|
62721
63042
|
return {
|
|
62722
63043
|
regenerated: false,
|
|
@@ -62739,7 +63060,7 @@ async function regenerateSkill(directory, slug, options = {}) {
|
|
|
62739
63060
|
const activeEntries = matchedEntries.filter((e) => e.status !== "archived");
|
|
62740
63061
|
if (activeEntries.length === 0) {
|
|
62741
63062
|
try {
|
|
62742
|
-
await
|
|
63063
|
+
await _internals25.retireSkill(directory, cleanSlug, "auto-retire: all matched source knowledge entries archived at regeneration time");
|
|
62743
63064
|
} catch {}
|
|
62744
63065
|
return {
|
|
62745
63066
|
regenerated: false,
|
|
@@ -62856,7 +63177,7 @@ async function regenerateSkill(directory, slug, options = {}) {
|
|
|
62856
63177
|
evaluation
|
|
62857
63178
|
};
|
|
62858
63179
|
}
|
|
62859
|
-
var SLUG_PATTERN2, DEFAULT_SKILL_MIN_CONFIDENCE = 0.7, DEFAULT_SKILL_MIN_CONFIRMATIONS = 2, STRONG_SKILL_OUTCOME_COUNT = 3, MIN_CLUSTER_SIZE = 2, JACCARD_THRESHOLD = 0.5, AUTO_APPLY_BATCH_LIMIT = 5,
|
|
63180
|
+
var SLUG_PATTERN2, DEFAULT_SKILL_MIN_CONFIDENCE = 0.7, DEFAULT_SKILL_MIN_CONFIRMATIONS = 2, STRONG_SKILL_OUTCOME_COUNT = 3, MIN_CLUSTER_SIZE = 2, JACCARD_THRESHOLD = 0.5, AUTO_APPLY_BATCH_LIMIT = 5, _internals25;
|
|
62860
63181
|
var init_skill_generator = __esm(() => {
|
|
62861
63182
|
init_knowledge_events();
|
|
62862
63183
|
init_knowledge_store();
|
|
@@ -62865,7 +63186,7 @@ var init_skill_generator = __esm(() => {
|
|
|
62865
63186
|
init_skill_changelog();
|
|
62866
63187
|
init_skill_evaluator();
|
|
62867
63188
|
SLUG_PATTERN2 = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
62868
|
-
|
|
63189
|
+
_internals25 = {
|
|
62869
63190
|
sanitizeSlug,
|
|
62870
63191
|
isValidSlug: isValidSlug2,
|
|
62871
63192
|
selectCandidateEntries,
|
|
@@ -63152,7 +63473,7 @@ async function reviseSkill(params) {
|
|
|
63152
63473
|
}
|
|
63153
63474
|
if (!params.delegate) {
|
|
63154
63475
|
try {
|
|
63155
|
-
const revised =
|
|
63476
|
+
const revised = _internals26.buildDeterministicRevision(params.currentContent, params.currentVersion, params.violationContexts);
|
|
63156
63477
|
const validation = await validateRevisionCandidate(params, revised, "skill_reviser:deterministic");
|
|
63157
63478
|
if (!validation.passed) {
|
|
63158
63479
|
return {
|
|
@@ -63279,13 +63600,13 @@ async function reviseSkill(params) {
|
|
|
63279
63600
|
};
|
|
63280
63601
|
}
|
|
63281
63602
|
}
|
|
63282
|
-
var REVISION_VIOLATION_THRESHOLD = 0.15, MAX_REVISION_CALLS_PER_PHASE = 3, DEFAULT_MAX_CALLS = 10,
|
|
63603
|
+
var REVISION_VIOLATION_THRESHOLD = 0.15, MAX_REVISION_CALLS_PER_PHASE = 3, DEFAULT_MAX_CALLS = 10, _internals26;
|
|
63283
63604
|
var init_skill_reviser = __esm(() => {
|
|
63284
63605
|
init_logger();
|
|
63285
63606
|
init_skill_changelog();
|
|
63286
63607
|
init_skill_evaluator();
|
|
63287
63608
|
init_skill_improver_quota();
|
|
63288
|
-
|
|
63609
|
+
_internals26 = {
|
|
63289
63610
|
reviseSkill,
|
|
63290
63611
|
getSkillVersion,
|
|
63291
63612
|
buildDeterministicRevision,
|
|
@@ -63356,9 +63677,9 @@ function parseFeedbackMarker(raw) {
|
|
|
63356
63677
|
function readFeedbackAppliedEntryIds(directory) {
|
|
63357
63678
|
const resolved = resolveLogPath(directory);
|
|
63358
63679
|
const processed = new Set;
|
|
63359
|
-
if (!
|
|
63680
|
+
if (!_internals27.existsSync(resolved))
|
|
63360
63681
|
return processed;
|
|
63361
|
-
const raw =
|
|
63682
|
+
const raw = _internals27.readFileSync(resolved, "utf-8");
|
|
63362
63683
|
for (const line of raw.split(`
|
|
63363
63684
|
`)) {
|
|
63364
63685
|
const trimmed = line.trim();
|
|
@@ -63379,15 +63700,15 @@ function appendFeedbackAppliedMarker(directory, processedEntryIds) {
|
|
|
63379
63700
|
return;
|
|
63380
63701
|
const resolved = resolveLogPath(directory);
|
|
63381
63702
|
const dir = path38.dirname(resolved);
|
|
63382
|
-
if (!
|
|
63383
|
-
|
|
63703
|
+
if (!_internals27.existsSync(dir)) {
|
|
63704
|
+
_internals27.mkdirSync(dir, { recursive: true });
|
|
63384
63705
|
}
|
|
63385
63706
|
const marker = {
|
|
63386
63707
|
type: "feedback_applied",
|
|
63387
63708
|
timestamp: new Date().toISOString(),
|
|
63388
63709
|
processedEntryIds: [...new Set(processedEntryIds)]
|
|
63389
63710
|
};
|
|
63390
|
-
|
|
63711
|
+
_internals27.appendFileSync(resolved, `${JSON.stringify(marker)}
|
|
63391
63712
|
`, "utf-8");
|
|
63392
63713
|
}
|
|
63393
63714
|
function appendSkillUsageEntry(directory, entry) {
|
|
@@ -63424,11 +63745,11 @@ function appendSkillUsageEntry(directory, entry) {
|
|
|
63424
63745
|
}
|
|
63425
63746
|
const resolved = validateSwarmPath(directory, "skill-usage.jsonl");
|
|
63426
63747
|
const dir = path38.dirname(resolved);
|
|
63427
|
-
if (!
|
|
63428
|
-
|
|
63748
|
+
if (!_internals27.existsSync(dir)) {
|
|
63749
|
+
_internals27.mkdirSync(dir, { recursive: true });
|
|
63429
63750
|
}
|
|
63430
63751
|
const fullEntry = {
|
|
63431
|
-
id:
|
|
63752
|
+
id: _internals27.generateId(),
|
|
63432
63753
|
skillPath,
|
|
63433
63754
|
agentName,
|
|
63434
63755
|
taskID,
|
|
@@ -63438,21 +63759,21 @@ function appendSkillUsageEntry(directory, entry) {
|
|
|
63438
63759
|
...reviewerNotes !== undefined && { reviewerNotes },
|
|
63439
63760
|
...skillVersion !== undefined && { skillVersion }
|
|
63440
63761
|
};
|
|
63441
|
-
|
|
63762
|
+
_internals27.appendFileSync(resolved, `${JSON.stringify(fullEntry)}
|
|
63442
63763
|
`, "utf-8");
|
|
63443
63764
|
try {
|
|
63444
|
-
const stat6 =
|
|
63765
|
+
const stat6 = _internals27.statSync(resolved);
|
|
63445
63766
|
if (stat6.size > SKILL_USAGE_LOG_ROTATE_BYTES) {
|
|
63446
|
-
|
|
63767
|
+
_internals27.pruneSkillUsageLog(directory, SKILL_USAGE_LOG_MAX_ENTRIES_PER_SKILL);
|
|
63447
63768
|
}
|
|
63448
63769
|
} catch {}
|
|
63449
63770
|
}
|
|
63450
63771
|
function readSkillUsageEntries(directory, options) {
|
|
63451
63772
|
const resolved = resolveLogPath(directory);
|
|
63452
|
-
if (!
|
|
63773
|
+
if (!_internals27.existsSync(resolved)) {
|
|
63453
63774
|
return [];
|
|
63454
63775
|
}
|
|
63455
|
-
const raw =
|
|
63776
|
+
const raw = _internals27.readFileSync(resolved, "utf-8");
|
|
63456
63777
|
const entries = [];
|
|
63457
63778
|
for (const line of raw.split(`
|
|
63458
63779
|
`)) {
|
|
@@ -63491,20 +63812,20 @@ function readSkillUsageEntries(directory, options) {
|
|
|
63491
63812
|
}
|
|
63492
63813
|
function readSkillUsageEntriesTail(directory, filters, maxBytes = TAIL_BYTES_DEFAULT) {
|
|
63493
63814
|
const logPath = resolveLogPath(directory);
|
|
63494
|
-
if (!
|
|
63815
|
+
if (!_internals27.existsSync(logPath))
|
|
63495
63816
|
return [];
|
|
63496
63817
|
try {
|
|
63497
63818
|
const normalizedMaxBytes = Number.isFinite(maxBytes) ? maxBytes : TAIL_BYTES_DEFAULT;
|
|
63498
63819
|
const boundedMaxBytes = Math.min(Math.max(1, normalizedMaxBytes), MAX_TAIL_BYTES);
|
|
63499
|
-
const stat6 =
|
|
63820
|
+
const stat6 = _internals27.statSync(logPath);
|
|
63500
63821
|
const start2 = Math.max(0, stat6.size - boundedMaxBytes);
|
|
63501
|
-
const fd =
|
|
63822
|
+
const fd = _internals27.openSync(logPath, "r");
|
|
63502
63823
|
try {
|
|
63503
63824
|
const readLen = stat6.size - start2;
|
|
63504
63825
|
if (readLen === 0)
|
|
63505
63826
|
return [];
|
|
63506
63827
|
const buf = Buffer.alloc(readLen);
|
|
63507
|
-
|
|
63828
|
+
_internals27.readSync(fd, buf, 0, buf.length, start2);
|
|
63508
63829
|
const content = buf.toString("utf-8");
|
|
63509
63830
|
let usable;
|
|
63510
63831
|
if (start2 > 0) {
|
|
@@ -63531,7 +63852,7 @@ function readSkillUsageEntriesTail(directory, filters, maxBytes = TAIL_BYTES_DEF
|
|
|
63531
63852
|
}
|
|
63532
63853
|
return entries;
|
|
63533
63854
|
} finally {
|
|
63534
|
-
|
|
63855
|
+
_internals27.closeSync(fd);
|
|
63535
63856
|
}
|
|
63536
63857
|
} catch {
|
|
63537
63858
|
return [];
|
|
@@ -63568,7 +63889,7 @@ function computeComplianceByVersion(entries, skillPath) {
|
|
|
63568
63889
|
}
|
|
63569
63890
|
function pruneSkillUsageLog(directory, maxEntriesPerSkill = 500) {
|
|
63570
63891
|
const resolved = resolveLogPath(directory);
|
|
63571
|
-
if (!
|
|
63892
|
+
if (!_internals27.existsSync(resolved)) {
|
|
63572
63893
|
return { pruned: 0, remaining: 0 };
|
|
63573
63894
|
}
|
|
63574
63895
|
const allEntries = readSkillUsageEntries(directory);
|
|
@@ -63604,13 +63925,13 @@ function pruneSkillUsageLog(directory, maxEntriesPerSkill = 500) {
|
|
|
63604
63925
|
`).concat(`
|
|
63605
63926
|
`);
|
|
63606
63927
|
try {
|
|
63607
|
-
|
|
63608
|
-
|
|
63928
|
+
_internals27.writeFileSync(tmpPath, content, "utf-8");
|
|
63929
|
+
_internals27.renameSync(tmpPath, resolved);
|
|
63609
63930
|
} catch (writeErr) {
|
|
63610
63931
|
const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
|
|
63611
63932
|
try {
|
|
63612
|
-
if (
|
|
63613
|
-
|
|
63933
|
+
if (_internals27.existsSync(tmpPath)) {
|
|
63934
|
+
_internals27.writeFileSync(tmpPath, "", "utf-8");
|
|
63614
63935
|
}
|
|
63615
63936
|
} catch {}
|
|
63616
63937
|
return { pruned: 0, remaining: allEntries.length, error: msg };
|
|
@@ -63632,10 +63953,10 @@ async function resolveSourceKnowledgeIds(directory, skillPath) {
|
|
|
63632
63953
|
if (!isContained) {
|
|
63633
63954
|
return [];
|
|
63634
63955
|
}
|
|
63635
|
-
if (!
|
|
63956
|
+
if (!_internals27.existsSync(absolute)) {
|
|
63636
63957
|
return [];
|
|
63637
63958
|
}
|
|
63638
|
-
const content =
|
|
63959
|
+
const content = _internals27.readFileSync(absolute, "utf-8");
|
|
63639
63960
|
return parseGeneratedFromKnowledge(content);
|
|
63640
63961
|
} catch (err2) {
|
|
63641
63962
|
console.warn("[skill-usage-log] resolveSourceKnowledgeIds failed (fail-open):", err2 instanceof Error ? err2.message : String(err2));
|
|
@@ -63735,11 +64056,11 @@ async function applySkillUsageFeedback(directory, options) {
|
|
|
63735
64056
|
}
|
|
63736
64057
|
return { processed, bumps };
|
|
63737
64058
|
}
|
|
63738
|
-
var
|
|
64059
|
+
var _internals27, TAIL_BYTES_DEFAULT, MAX_TAIL_BYTES, SKILL_USAGE_LOG_ROTATE_BYTES, SKILL_USAGE_LOG_MAX_ENTRIES_PER_SKILL = 500, COMPLIANCE_BOOST = 0.05, VIOLATION_DECAY = 0.1;
|
|
63739
64060
|
var init_skill_usage_log = __esm(() => {
|
|
63740
64061
|
init_knowledge_store();
|
|
63741
64062
|
init_utils2();
|
|
63742
|
-
|
|
64063
|
+
_internals27 = {
|
|
63743
64064
|
generateId: () => crypto4.randomUUID(),
|
|
63744
64065
|
appendFileSync: fs19.appendFileSync.bind(fs19),
|
|
63745
64066
|
readFileSync: fs19.readFileSync.bind(fs19),
|
|
@@ -63772,8 +64093,8 @@ import * as path39 from "node:path";
|
|
|
63772
64093
|
async function autoRetireSkills(directory, curatorKnowledgePath, excludeSlugs) {
|
|
63773
64094
|
const observations = [];
|
|
63774
64095
|
try {
|
|
63775
|
-
const skillListResult = await
|
|
63776
|
-
const usageEntries =
|
|
64096
|
+
const skillListResult = await _internals28.listSkills(directory);
|
|
64097
|
+
const usageEntries = _internals28.readSkillUsageEntries(directory);
|
|
63777
64098
|
for (const active of skillListResult.active) {
|
|
63778
64099
|
if (excludeSlugs?.has(active.slug))
|
|
63779
64100
|
continue;
|
|
@@ -63791,19 +64112,19 @@ async function autoRetireSkills(directory, curatorKnowledgePath, excludeSlugs) {
|
|
|
63791
64112
|
return true;
|
|
63792
64113
|
return false;
|
|
63793
64114
|
});
|
|
63794
|
-
const violations = skillUsage.filter((e) =>
|
|
64115
|
+
const violations = skillUsage.filter((e) => e.complianceVerdict === "violation").length;
|
|
63795
64116
|
const violationRate = skillUsage.length > 0 ? violations / skillUsage.length : 0;
|
|
63796
64117
|
let allArchived = false;
|
|
63797
64118
|
try {
|
|
63798
|
-
const content = await
|
|
63799
|
-
const fm =
|
|
64119
|
+
const content = await _internals28.readFileAsync(active.path, "utf-8");
|
|
64120
|
+
const fm = _internals28.parseDraftFrontmatter(content);
|
|
63800
64121
|
if (fm && fm.sourceKnowledgeIds.length > 0) {
|
|
63801
|
-
const swarmKnowledge = await
|
|
64122
|
+
const swarmKnowledge = await _internals28.readKnowledge(curatorKnowledgePath);
|
|
63802
64123
|
let hiveKnowledge = [];
|
|
63803
64124
|
try {
|
|
63804
64125
|
const hivePath = resolveHiveKnowledgePath();
|
|
63805
64126
|
if (fs20.existsSync(hivePath)) {
|
|
63806
|
-
hiveKnowledge = await
|
|
64127
|
+
hiveKnowledge = await _internals28.readKnowledge(hivePath);
|
|
63807
64128
|
}
|
|
63808
64129
|
} catch {}
|
|
63809
64130
|
const allKnowledge = [...swarmKnowledge, ...hiveKnowledge];
|
|
@@ -63814,7 +64135,7 @@ async function autoRetireSkills(directory, curatorKnowledgePath, excludeSlugs) {
|
|
|
63814
64135
|
} catch {}
|
|
63815
64136
|
if (violationRate > 0.3 || allArchived) {
|
|
63816
64137
|
const reason = violationRate > 0.3 ? `auto-retire: violation rate ${(violationRate * 100).toFixed(0)}% exceeds 30% threshold` : "auto-retire: all source knowledge entries archived";
|
|
63817
|
-
await
|
|
64138
|
+
await _internals28.retireSkill(directory, active.slug, reason);
|
|
63818
64139
|
observations.push(`Skill '${active.slug}' auto-retired: ${reason}`);
|
|
63819
64140
|
warn(`[curator] ${observations[observations.length - 1]}`);
|
|
63820
64141
|
}
|
|
@@ -63991,9 +64312,7 @@ async function readCuratorSummary(directory) {
|
|
|
63991
64312
|
async function writeCuratorSummary(directory, summary) {
|
|
63992
64313
|
const resolvedPath = validateSwarmPath(directory, "curator-summary.json");
|
|
63993
64314
|
fs20.mkdirSync(path39.dirname(resolvedPath), { recursive: true });
|
|
63994
|
-
|
|
63995
|
-
await bunWrite(tempPath, JSON.stringify(summary, null, 2));
|
|
63996
|
-
fs20.renameSync(tempPath, resolvedPath);
|
|
64315
|
+
await bunWrite(resolvedPath, JSON.stringify(summary, null, 2));
|
|
63997
64316
|
}
|
|
63998
64317
|
function normalizeAgentName(name2) {
|
|
63999
64318
|
const registry3 = swarmState.generatedAgentNames.length > 0 ? swarmState.generatedAgentNames : undefined;
|
|
@@ -64027,8 +64346,8 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
64027
64346
|
const observations = [];
|
|
64028
64347
|
const timestamp = new Date().toISOString();
|
|
64029
64348
|
for (const agent of requiredAgents) {
|
|
64030
|
-
const normalizedAgent =
|
|
64031
|
-
const isDispatched = agentsDispatched.some((a) =>
|
|
64349
|
+
const normalizedAgent = _internals28.normalizeAgentName(agent);
|
|
64350
|
+
const isDispatched = agentsDispatched.some((a) => _internals28.normalizeAgentName(a) === normalizedAgent);
|
|
64032
64351
|
if (!isDispatched) {
|
|
64033
64352
|
observations.push({
|
|
64034
64353
|
phase,
|
|
@@ -64047,7 +64366,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
64047
64366
|
if (e.type === "agent.delegation") {
|
|
64048
64367
|
const agent = e.agent;
|
|
64049
64368
|
if (agent && typeof agent === "string") {
|
|
64050
|
-
const normalized =
|
|
64369
|
+
const normalized = _internals28.normalizeAgentName(agent);
|
|
64051
64370
|
if (normalized === "coder") {
|
|
64052
64371
|
coderDelegations.push({ event: e, index: i2 });
|
|
64053
64372
|
} else if (normalized === "reviewer") {
|
|
@@ -64104,7 +64423,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
64104
64423
|
if (e.type === "agent.delegation" && e.agent) {
|
|
64105
64424
|
const agent = e.agent;
|
|
64106
64425
|
if (agent && typeof agent === "string") {
|
|
64107
|
-
const normalized =
|
|
64426
|
+
const normalized = _internals28.normalizeAgentName(agent);
|
|
64108
64427
|
if (normalized === "sme") {
|
|
64109
64428
|
smeDelegations.push({ event: e, index: i2 });
|
|
64110
64429
|
}
|
|
@@ -64128,7 +64447,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
64128
64447
|
}
|
|
64129
64448
|
async function runCuratorInit(directory, config3, llmDelegate) {
|
|
64130
64449
|
try {
|
|
64131
|
-
const priorSummary = await
|
|
64450
|
+
const priorSummary = await _internals28.readCuratorSummary(directory);
|
|
64132
64451
|
const knowledgePath = resolveSwarmKnowledgePath(directory);
|
|
64133
64452
|
const allEntries = await readKnowledge(knowledgePath);
|
|
64134
64453
|
const highConfidenceEntries = allEntries.filter((e) => typeof e.confidence === "number" && e.confidence >= config3.min_knowledge_confidence);
|
|
@@ -64249,7 +64568,7 @@ Could not load prior session context.`,
|
|
|
64249
64568
|
}
|
|
64250
64569
|
async function runCuratorPhase(directory, phase, agentsDispatched, config3, _knowledgeConfig, llmDelegate) {
|
|
64251
64570
|
try {
|
|
64252
|
-
const priorSummary = await
|
|
64571
|
+
const priorSummary = await _internals28.readCuratorSummary(directory);
|
|
64253
64572
|
if (priorSummary?.phase_digests.some((d) => d.phase === phase)) {
|
|
64254
64573
|
const existingDigest = priorSummary.phase_digests.find((d) => d.phase === phase);
|
|
64255
64574
|
return {
|
|
@@ -64262,10 +64581,10 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
|
|
|
64262
64581
|
};
|
|
64263
64582
|
}
|
|
64264
64583
|
const eventsJsonlContent = await readSwarmFileAsync(directory, "events.jsonl");
|
|
64265
|
-
const phaseEvents = eventsJsonlContent ?
|
|
64584
|
+
const phaseEvents = eventsJsonlContent ? _internals28.filterPhaseEvents(eventsJsonlContent, phase) : [];
|
|
64266
64585
|
const contextMd = await readSwarmFileAsync(directory, "context.md");
|
|
64267
64586
|
const requiredAgents = ["reviewer", "test_engineer"];
|
|
64268
|
-
const complianceObservations =
|
|
64587
|
+
const complianceObservations = _internals28.checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, phase);
|
|
64269
64588
|
const plan = await loadPlanJsonOnly(directory);
|
|
64270
64589
|
const phaseData = plan?.phases.find((p) => p.id === phase);
|
|
64271
64590
|
const tasksCompleted = phaseData ? phaseData.tasks.filter((t) => t.status === "completed").length : 0;
|
|
@@ -64289,7 +64608,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
|
|
|
64289
64608
|
timestamp: new Date().toISOString(),
|
|
64290
64609
|
summary: `Phase ${phase} completed. ${tasksCompleted}/${tasksTotal} tasks completed. ${complianceObservations.length} compliance observations.`,
|
|
64291
64610
|
agents_used: [
|
|
64292
|
-
...new Set(agentsDispatched.map((a) =>
|
|
64611
|
+
...new Set(agentsDispatched.map((a) => _internals28.normalizeAgentName(a)))
|
|
64293
64612
|
],
|
|
64294
64613
|
tasks_completed: tasksCompleted,
|
|
64295
64614
|
tasks_total: tasksTotal,
|
|
@@ -64339,7 +64658,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
|
|
|
64339
64658
|
clearTimeout(timer);
|
|
64340
64659
|
}
|
|
64341
64660
|
if (llmOutput?.trim()) {
|
|
64342
|
-
knowledgeRecommendations =
|
|
64661
|
+
knowledgeRecommendations = _internals28.parseKnowledgeRecommendations(llmOutput);
|
|
64343
64662
|
const structured = parseStructuredCuratorBlocks(llmOutput);
|
|
64344
64663
|
knowledgeApplicationFindings = structured.findings;
|
|
64345
64664
|
skillCandidates = structured.candidates;
|
|
@@ -64390,15 +64709,13 @@ ${phaseDigest.summary}`,
|
|
|
64390
64709
|
knowledge_recommendations: knowledgeRecommendations
|
|
64391
64710
|
};
|
|
64392
64711
|
}
|
|
64393
|
-
await
|
|
64712
|
+
await _internals28.writeCuratorSummary(directory, updatedSummary);
|
|
64394
64713
|
if (knowledgeApplicationFindings.length > 0) {
|
|
64395
64714
|
try {
|
|
64396
64715
|
const evidenceDir = path39.join(directory, ".swarm", "evidence", String(phase));
|
|
64397
64716
|
fs20.mkdirSync(evidenceDir, { recursive: true });
|
|
64398
64717
|
const findingsPath = path39.join(evidenceDir, "curator-findings.json");
|
|
64399
|
-
|
|
64400
|
-
fs20.writeFileSync(tmpPath, JSON.stringify({ findings: knowledgeApplicationFindings }, null, 2));
|
|
64401
|
-
fs20.renameSync(tmpPath, findingsPath);
|
|
64718
|
+
await bunWrite(findingsPath, JSON.stringify({ findings: knowledgeApplicationFindings }, null, 2));
|
|
64402
64719
|
} catch (err2) {
|
|
64403
64720
|
warn(`[curator] failed to persist application findings: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
64404
64721
|
}
|
|
@@ -64434,8 +64751,8 @@ ${phaseDigest.summary}`,
|
|
|
64434
64751
|
}
|
|
64435
64752
|
const revisedSlugs = new Set;
|
|
64436
64753
|
try {
|
|
64437
|
-
const skillListResult = await
|
|
64438
|
-
const usageEntries =
|
|
64754
|
+
const skillListResult = await _internals28.listSkills(directory);
|
|
64755
|
+
const usageEntries = _internals28.readSkillUsageEntries(directory);
|
|
64439
64756
|
let revisionCallsThisPhase = 0;
|
|
64440
64757
|
for (const active of skillListResult.active) {
|
|
64441
64758
|
if (revisionCallsThisPhase >= MAX_REVISION_CALLS_PER_PHASE)
|
|
@@ -64456,22 +64773,22 @@ ${phaseDigest.summary}`,
|
|
|
64456
64773
|
});
|
|
64457
64774
|
if (skillUsage.length === 0)
|
|
64458
64775
|
continue;
|
|
64459
|
-
const violations = skillUsage.filter((e) =>
|
|
64776
|
+
const violations = skillUsage.filter((e) => e.complianceVerdict === "violation").length;
|
|
64460
64777
|
const violationRate = violations / skillUsage.length;
|
|
64461
64778
|
if (violationRate > REVISION_VIOLATION_THRESHOLD && violationRate <= 0.3) {
|
|
64462
|
-
const content = await
|
|
64463
|
-
const fm =
|
|
64779
|
+
const content = await _internals28.readFileAsync(active.path, "utf-8");
|
|
64780
|
+
const fm = _internals28.parseDraftFrontmatter(content);
|
|
64464
64781
|
if (fm && fm.skillOrigin === "promoted_external")
|
|
64465
64782
|
continue;
|
|
64466
64783
|
const currentVersion = fm?.version ?? 1;
|
|
64467
|
-
const violationContexts = skillUsage.filter((e) =>
|
|
64784
|
+
const violationContexts = skillUsage.filter((e) => e.complianceVerdict === "violation").slice(-10).map((e) => ({
|
|
64468
64785
|
taskId: e.taskID,
|
|
64469
64786
|
agent: e.agentName,
|
|
64470
64787
|
verdict: e.complianceVerdict,
|
|
64471
64788
|
reviewerNotes: e.reviewerNotes,
|
|
64472
64789
|
timestamp: e.timestamp
|
|
64473
64790
|
}));
|
|
64474
|
-
const result2 = await
|
|
64791
|
+
const result2 = await _internals28.reviseSkill({
|
|
64475
64792
|
directory,
|
|
64476
64793
|
slug: active.slug,
|
|
64477
64794
|
skillPath: active.path,
|
|
@@ -64490,7 +64807,7 @@ ${phaseDigest.summary}`,
|
|
|
64490
64807
|
} catch (revisionErr) {
|
|
64491
64808
|
warn(`[curator] skill revision check failed: ${revisionErr instanceof Error ? revisionErr.message : String(revisionErr)}`);
|
|
64492
64809
|
}
|
|
64493
|
-
const autoRetireObservations = await
|
|
64810
|
+
const autoRetireObservations = await _internals28.autoRetireSkills(directory, curatorKnowledgePath, revisedSlugs);
|
|
64494
64811
|
if (autoRetireObservations.length > 0) {
|
|
64495
64812
|
const retireNote = ` [${autoRetireObservations.length} skill(s) auto-retired]`;
|
|
64496
64813
|
phaseDigest.summary += retireNote;
|
|
@@ -64698,7 +65015,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
64698
65015
|
}
|
|
64699
65016
|
return { applied, skipped };
|
|
64700
65017
|
}
|
|
64701
|
-
var DEFAULT_CURATOR_LLM_TIMEOUT_MS = 300000,
|
|
65018
|
+
var DEFAULT_CURATOR_LLM_TIMEOUT_MS = 300000, _internals28;
|
|
64702
65019
|
var init_curator = __esm(() => {
|
|
64703
65020
|
init_event_bus();
|
|
64704
65021
|
init_schema();
|
|
@@ -64713,7 +65030,7 @@ var init_curator = __esm(() => {
|
|
|
64713
65030
|
init_knowledge_validator();
|
|
64714
65031
|
init_skill_usage_log();
|
|
64715
65032
|
init_utils2();
|
|
64716
|
-
|
|
65033
|
+
_internals28 = {
|
|
64717
65034
|
parseKnowledgeRecommendations,
|
|
64718
65035
|
readCuratorSummary,
|
|
64719
65036
|
writeCuratorSummary,
|
|
@@ -65559,7 +65876,7 @@ function rankSkillsForContext(skills, taskContext, directory) {
|
|
|
65559
65876
|
const results = [];
|
|
65560
65877
|
for (const skillPath of skills) {
|
|
65561
65878
|
const skillEntries = allEntries.filter((e) => e.skillPath === skillPath);
|
|
65562
|
-
const metadata2 =
|
|
65879
|
+
const metadata2 = _internals29.readSkillMetadata(skillPath, directory);
|
|
65563
65880
|
const score = computeSkillRelevanceScore(skillPath, taskContext, skillEntries, metadata2);
|
|
65564
65881
|
const entriesWithVerdict = skillEntries.filter((e) => e.complianceVerdict !== undefined && e.complianceVerdict !== "not_checked");
|
|
65565
65882
|
const compliantCount = entriesWithVerdict.filter((e) => e.complianceVerdict === "compliant").length;
|
|
@@ -65614,7 +65931,7 @@ function formatSkillIndexWithContext(skills, directory) {
|
|
|
65614
65931
|
} catch {}
|
|
65615
65932
|
if (!hasHistory) {
|
|
65616
65933
|
return skills.map((sp) => {
|
|
65617
|
-
const meta3 =
|
|
65934
|
+
const meta3 = _internals29.readSkillMetadata(sp, directory);
|
|
65618
65935
|
return ` - file:${meta3.path} - ${meta3.name}: ${meta3.description}`;
|
|
65619
65936
|
}).join(`
|
|
65620
65937
|
`);
|
|
@@ -65622,7 +65939,7 @@ function formatSkillIndexWithContext(skills, directory) {
|
|
|
65622
65939
|
const lines = [];
|
|
65623
65940
|
for (const skillPath of skills) {
|
|
65624
65941
|
const stats = getSkillStats(skillPath, directory);
|
|
65625
|
-
const meta3 =
|
|
65942
|
+
const meta3 = _internals29.readSkillMetadata(skillPath, directory);
|
|
65626
65943
|
const compliancePct = Math.round(stats.complianceRate * 100);
|
|
65627
65944
|
const topAgentNames = stats.topAgents.slice(0, 3).map((a) => a.agent).join(", ");
|
|
65628
65945
|
lines.push(` - file:${meta3.path} - ${meta3.name}: ${meta3.description} (used: ${stats.totalUsage}, compliance: ${compliancePct}%)` + (stats.topAgents.length > 0 ? ` → ${topAgentNames}` : ""));
|
|
@@ -65630,12 +65947,12 @@ function formatSkillIndexWithContext(skills, directory) {
|
|
|
65630
65947
|
return lines.join(`
|
|
65631
65948
|
`);
|
|
65632
65949
|
}
|
|
65633
|
-
var FREQUENCY_CAP = 10, FREQUENCY_WEIGHT = 0.3, COMPLIANCE_WEIGHT = 0.3, RECENCY_WEIGHT = 0.15, TASK_DIVERSITY_WEIGHT = 0.05, CONTEXT_WEIGHT = 0.2, WORKFLOW_BOOST = 0.1, SKILL_TRIGGER_BOOST = 0.3, SKILL_TRIGGER_MIN_LENGTH = 3, MAX_SKILL_TRIGGERS = 20, MAX_SKILL_TRIGGER_LENGTH = 120, WORKFLOW_BOOST_MIN_CONTEXT = 0.05, RECENCY_DECAY_MS, SKILL_FRONTMATTER_READ_BYTES,
|
|
65950
|
+
var FREQUENCY_CAP = 10, FREQUENCY_WEIGHT = 0.3, COMPLIANCE_WEIGHT = 0.3, RECENCY_WEIGHT = 0.15, TASK_DIVERSITY_WEIGHT = 0.05, CONTEXT_WEIGHT = 0.2, WORKFLOW_BOOST = 0.1, SKILL_TRIGGER_BOOST = 0.3, SKILL_TRIGGER_MIN_LENGTH = 3, MAX_SKILL_TRIGGERS = 20, MAX_SKILL_TRIGGER_LENGTH = 120, WORKFLOW_BOOST_MIN_CONTEXT = 0.05, RECENCY_DECAY_MS, SKILL_FRONTMATTER_READ_BYTES, _internals29, MIN_KEYWORD_LENGTH = 3;
|
|
65634
65951
|
var init_skill_scoring = __esm(() => {
|
|
65635
65952
|
init_skill_usage_log();
|
|
65636
65953
|
RECENCY_DECAY_MS = 30 * 24 * 60 * 60 * 1000;
|
|
65637
65954
|
SKILL_FRONTMATTER_READ_BYTES = 16 * 1024;
|
|
65638
|
-
|
|
65955
|
+
_internals29 = {
|
|
65639
65956
|
computeSkillRelevanceScore: null,
|
|
65640
65957
|
rankSkillsForContext: null,
|
|
65641
65958
|
getSkillStats: null,
|
|
@@ -65647,16 +65964,16 @@ var init_skill_scoring = __esm(() => {
|
|
|
65647
65964
|
computeContextMatchScore: null,
|
|
65648
65965
|
computeTriggerMatchBoost: null
|
|
65649
65966
|
};
|
|
65650
|
-
|
|
65651
|
-
|
|
65652
|
-
|
|
65653
|
-
|
|
65654
|
-
|
|
65655
|
-
|
|
65656
|
-
|
|
65657
|
-
|
|
65658
|
-
|
|
65659
|
-
|
|
65967
|
+
_internals29.computeSkillRelevanceScore = computeSkillRelevanceScore;
|
|
65968
|
+
_internals29.rankSkillsForContext = rankSkillsForContext;
|
|
65969
|
+
_internals29.getSkillStats = getSkillStats;
|
|
65970
|
+
_internals29.formatSkillIndexWithContext = formatSkillIndexWithContext;
|
|
65971
|
+
_internals29.parseSkillFrontmatter = parseSkillFrontmatter;
|
|
65972
|
+
_internals29.readSkillMetadata = readSkillMetadata;
|
|
65973
|
+
_internals29.extractSkillName = extractSkillName;
|
|
65974
|
+
_internals29.computeRecencyScore = computeRecencyScore;
|
|
65975
|
+
_internals29.computeContextMatchScore = computeContextMatchScore;
|
|
65976
|
+
_internals29.computeTriggerMatchBoost = computeTriggerMatchBoost;
|
|
65660
65977
|
});
|
|
65661
65978
|
|
|
65662
65979
|
// src/hooks/skill-propagation-gate.ts
|
|
@@ -65761,10 +66078,10 @@ function parseYamlValue(value) {
|
|
|
65761
66078
|
}
|
|
65762
66079
|
function loadRoutingSkills(directory, targetAgent) {
|
|
65763
66080
|
const routingPath = path43.join(directory, ".opencode", "skill-routing.yaml");
|
|
65764
|
-
if (!
|
|
66081
|
+
if (!_internals30.existsSync(routingPath))
|
|
65765
66082
|
return [];
|
|
65766
66083
|
try {
|
|
65767
|
-
const content =
|
|
66084
|
+
const content = _internals30.readFileSync(routingPath, "utf-8");
|
|
65768
66085
|
const config3 = parseSimpleYaml(content);
|
|
65769
66086
|
if (!config3?.routing)
|
|
65770
66087
|
return [];
|
|
@@ -65781,11 +66098,11 @@ function discoverAvailableSkills(directory) {
|
|
|
65781
66098
|
const results = [];
|
|
65782
66099
|
for (const root of SKILL_SEARCH_ROOTS) {
|
|
65783
66100
|
const rootPath = path43.join(directory, root);
|
|
65784
|
-
if (!
|
|
66101
|
+
if (!_internals30.existsSync(rootPath))
|
|
65785
66102
|
continue;
|
|
65786
66103
|
let entries;
|
|
65787
66104
|
try {
|
|
65788
|
-
entries =
|
|
66105
|
+
entries = _internals30.readdirSync(rootPath);
|
|
65789
66106
|
} catch {
|
|
65790
66107
|
continue;
|
|
65791
66108
|
}
|
|
@@ -65793,11 +66110,11 @@ function discoverAvailableSkills(directory) {
|
|
|
65793
66110
|
if (entry.startsWith("."))
|
|
65794
66111
|
continue;
|
|
65795
66112
|
const skillDir = path43.join(rootPath, entry);
|
|
65796
|
-
if (
|
|
66113
|
+
if (_internals30.existsSync(path43.join(skillDir, "retired.marker")))
|
|
65797
66114
|
continue;
|
|
65798
66115
|
const skillFile = path43.join(skillDir, "SKILL.md");
|
|
65799
66116
|
try {
|
|
65800
|
-
if (
|
|
66117
|
+
if (_internals30.statSync(skillDir).isDirectory() && _internals30.existsSync(skillFile)) {
|
|
65801
66118
|
results.push(path43.join(root, entry, "SKILL.md").replace(/\\/g, "/"));
|
|
65802
66119
|
}
|
|
65803
66120
|
} catch (err2) {
|
|
@@ -65829,7 +66146,7 @@ function parseDelegationArgs(args2) {
|
|
|
65829
66146
|
}
|
|
65830
66147
|
if (!targetAgent)
|
|
65831
66148
|
return null;
|
|
65832
|
-
const skillsField = prompt ?
|
|
66149
|
+
const skillsField = prompt ? _internals30.extractSkillsFieldFromPrompt(prompt) : "";
|
|
65833
66150
|
return { targetAgent, skillsField };
|
|
65834
66151
|
}
|
|
65835
66152
|
function extractSkillsFieldFromPrompt(prompt) {
|
|
@@ -65870,10 +66187,10 @@ function writeWarnEvent(directory, record3) {
|
|
|
65870
66187
|
const filePath = path43.join(directory, ".swarm", "events.jsonl");
|
|
65871
66188
|
try {
|
|
65872
66189
|
const dir = path43.dirname(filePath);
|
|
65873
|
-
if (!
|
|
65874
|
-
|
|
66190
|
+
if (!_internals30.existsSync(dir)) {
|
|
66191
|
+
_internals30.mkdirSync(dir, { recursive: true });
|
|
65875
66192
|
}
|
|
65876
|
-
|
|
66193
|
+
_internals30.appendFileSync(filePath, `${JSON.stringify(record3)}
|
|
65877
66194
|
`, "utf-8");
|
|
65878
66195
|
} catch (err2) {
|
|
65879
66196
|
warn(`[skill-propagation-gate] failed to write warning event: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
@@ -65924,19 +66241,19 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
65924
66241
|
const baseAgent = stripKnownSwarmPrefix(agentRaw);
|
|
65925
66242
|
if (baseAgent !== "architect")
|
|
65926
66243
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
65927
|
-
const parsed =
|
|
66244
|
+
const parsed = _internals30.parseDelegationArgs(input.args);
|
|
65928
66245
|
if (!parsed)
|
|
65929
66246
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
65930
66247
|
const targetBase = stripKnownSwarmPrefix(parsed.targetAgent);
|
|
65931
|
-
if (!
|
|
66248
|
+
if (!_internals30.SKILL_CAPABLE_AGENTS.has(targetBase))
|
|
65932
66249
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
65933
66250
|
const sessionID = typeof input.sessionID === "string" ? input.sessionID : "unknown";
|
|
65934
|
-
const availableSkills =
|
|
66251
|
+
const availableSkills = _internals30.discoverAvailableSkills(directory);
|
|
65935
66252
|
const skillsValue = parsed.skillsField.trim();
|
|
65936
66253
|
if (skillsValue && skillsValue.toLowerCase() !== "none") {
|
|
65937
66254
|
const prompt = typeof input.args?.prompt === "string" ? String(input.args.prompt) : "";
|
|
65938
|
-
const taskId =
|
|
65939
|
-
const skillPaths =
|
|
66255
|
+
const taskId = _internals30.extractTaskIdFromPrompt(prompt);
|
|
66256
|
+
const skillPaths = _internals30.parseSkillPaths(skillsValue);
|
|
65940
66257
|
let coderSkillPaths = [];
|
|
65941
66258
|
if (prompt) {
|
|
65942
66259
|
for (const line of prompt.split(`
|
|
@@ -65944,7 +66261,7 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
65944
66261
|
const trimmed = line.trim();
|
|
65945
66262
|
if (trimmed.startsWith("SKILLS_USED_BY_CODER:")) {
|
|
65946
66263
|
const fieldVal = trimmed.slice("SKILLS_USED_BY_CODER:".length).trim();
|
|
65947
|
-
coderSkillPaths =
|
|
66264
|
+
coderSkillPaths = _internals30.parseSkillPaths(fieldVal);
|
|
65948
66265
|
break;
|
|
65949
66266
|
}
|
|
65950
66267
|
}
|
|
@@ -65952,7 +66269,7 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
65952
66269
|
const allPaths = [...new Set([...skillPaths, ...coderSkillPaths])];
|
|
65953
66270
|
for (const skillPath of allPaths) {
|
|
65954
66271
|
try {
|
|
65955
|
-
|
|
66272
|
+
_internals30.appendSkillUsageEntry(directory, {
|
|
65956
66273
|
skillPath,
|
|
65957
66274
|
agentName: targetBase,
|
|
65958
66275
|
taskID: taskId,
|
|
@@ -65969,18 +66286,18 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
65969
66286
|
let scored = [];
|
|
65970
66287
|
if (skillsValue.toLowerCase() !== "none" && availableSkills.length > 0) {
|
|
65971
66288
|
try {
|
|
65972
|
-
const sessionEntries =
|
|
66289
|
+
const sessionEntries = _internals30.readSkillUsageEntriesTail(directory, {
|
|
65973
66290
|
sessionID
|
|
65974
66291
|
});
|
|
65975
|
-
if (sessionEntries.length >
|
|
66292
|
+
if (sessionEntries.length > _internals30.MAX_SCORING_SESSION_ENTRIES) {
|
|
65976
66293
|
scoringSkipped = true;
|
|
65977
|
-
warn(`[skill-propagation-gate] skipping scoring — tail window has ${sessionEntries.length} session entries (limit: ${
|
|
66294
|
+
warn(`[skill-propagation-gate] skipping scoring — tail window has ${sessionEntries.length} session entries (limit: ${_internals30.MAX_SCORING_SESSION_ENTRIES})`);
|
|
65978
66295
|
} else {
|
|
65979
66296
|
const prompt = typeof input.args?.prompt === "string" ? String(input.args.prompt) : "";
|
|
65980
66297
|
scored = availableSkills.map((skillPath) => {
|
|
65981
66298
|
const skillEntries = sessionEntries.filter((e) => e.skillPath === skillPath);
|
|
65982
|
-
const metadata2 =
|
|
65983
|
-
const score =
|
|
66299
|
+
const metadata2 = _internals30.readSkillMetadata(skillPath, directory);
|
|
66300
|
+
const score = _internals30.computeSkillRelevanceScore(skillPath, prompt, skillEntries, metadata2);
|
|
65984
66301
|
return { skillPath, score, usageCount: skillEntries.length };
|
|
65985
66302
|
}).sort((a, b) => b.score - a.score || b.usageCount - a.usageCount);
|
|
65986
66303
|
if (scored.length > 0) {
|
|
@@ -65994,12 +66311,12 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
65994
66311
|
}
|
|
65995
66312
|
}
|
|
65996
66313
|
try {
|
|
65997
|
-
const routingPaths =
|
|
66314
|
+
const routingPaths = _internals30.loadRoutingSkills(directory, targetBase);
|
|
65998
66315
|
if (routingPaths.length > 0) {
|
|
65999
66316
|
const existingPaths = new Set(scored.map((s) => s.skillPath));
|
|
66000
66317
|
for (const routingPath of routingPaths) {
|
|
66001
66318
|
const routedSkillDir = path43.dirname(path43.join(directory, routingPath));
|
|
66002
|
-
if (
|
|
66319
|
+
if (_internals30.existsSync(path43.join(routedSkillDir, "retired.marker")))
|
|
66003
66320
|
continue;
|
|
66004
66321
|
if (!existingPaths.has(routingPath)) {
|
|
66005
66322
|
scored.push({
|
|
@@ -66025,12 +66342,12 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
66025
66342
|
} else if (typeof scored !== "undefined" && scored.length > 0) {
|
|
66026
66343
|
skillsForIndex = scored.map((r) => r.skillPath);
|
|
66027
66344
|
}
|
|
66028
|
-
const formattedIndex =
|
|
66345
|
+
const formattedIndex = _internals30.formatSkillIndexWithContext(skillsForIndex, directory);
|
|
66029
66346
|
if (formattedIndex.length > 0) {
|
|
66030
66347
|
const contextPath = path43.join(directory, ".swarm", "context.md");
|
|
66031
66348
|
let existingContent = "";
|
|
66032
|
-
if (
|
|
66033
|
-
existingContent =
|
|
66349
|
+
if (_internals30.existsSync(contextPath)) {
|
|
66350
|
+
existingContent = _internals30.readFileSync(contextPath, "utf-8");
|
|
66034
66351
|
}
|
|
66035
66352
|
const sectionHeader = "## Available Skills";
|
|
66036
66353
|
const newSection = `${sectionHeader}
|
|
@@ -66050,10 +66367,10 @@ ${newSection}`;
|
|
|
66050
66367
|
}
|
|
66051
66368
|
}
|
|
66052
66369
|
const swarmDir = path43.dirname(contextPath);
|
|
66053
|
-
if (!
|
|
66054
|
-
|
|
66370
|
+
if (!_internals30.existsSync(swarmDir)) {
|
|
66371
|
+
_internals30.mkdirSync(swarmDir, { recursive: true });
|
|
66055
66372
|
}
|
|
66056
|
-
|
|
66373
|
+
_internals30.writeFileSync(contextPath, updatedContent, "utf-8");
|
|
66057
66374
|
}
|
|
66058
66375
|
} catch (err2) {
|
|
66059
66376
|
warn(`[skill-propagation-gate] failed to write skill index to context.md: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
@@ -66079,7 +66396,7 @@ ${newSection}`;
|
|
|
66079
66396
|
});
|
|
66080
66397
|
const warningMsg = `Skill propagation warning: Delegating to ${targetBase} without SKILLS field. ` + `Available skills: ${skillNames.join(", ")}`;
|
|
66081
66398
|
try {
|
|
66082
|
-
|
|
66399
|
+
_internals30.writeWarnEvent(directory, {
|
|
66083
66400
|
type: "skill_propagation_warn",
|
|
66084
66401
|
timestamp: new Date().toISOString(),
|
|
66085
66402
|
tool: toolName,
|
|
@@ -66106,7 +66423,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
66106
66423
|
let dedupKeys = new Set;
|
|
66107
66424
|
let existingEntries = [];
|
|
66108
66425
|
try {
|
|
66109
|
-
existingEntries =
|
|
66426
|
+
existingEntries = _internals30.readSkillUsageEntriesTail(directory, {
|
|
66110
66427
|
sessionID
|
|
66111
66428
|
});
|
|
66112
66429
|
dedupKeys = new Set(existingEntries.map((e, i2) => {
|
|
@@ -66144,7 +66461,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
66144
66461
|
}
|
|
66145
66462
|
const coderMatch = trimmed.match(CODER_SKILLS_PATTERN);
|
|
66146
66463
|
if (coderMatch) {
|
|
66147
|
-
const parsed =
|
|
66464
|
+
const parsed = _internals30.parseSkillPaths(coderMatch[1]);
|
|
66148
66465
|
skillPaths.push(...parsed);
|
|
66149
66466
|
}
|
|
66150
66467
|
}
|
|
@@ -66177,7 +66494,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
66177
66494
|
if (isDuplicate(skillPath, "reviewer", resolvedTaskID))
|
|
66178
66495
|
continue;
|
|
66179
66496
|
try {
|
|
66180
|
-
|
|
66497
|
+
_internals30.appendSkillUsageEntry(directory, {
|
|
66181
66498
|
skillPath,
|
|
66182
66499
|
agentName: "reviewer",
|
|
66183
66500
|
taskID: resolvedTaskID,
|
|
@@ -66221,15 +66538,15 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
66221
66538
|
skillsField = trimmed.slice("SKILLS:".length).trim();
|
|
66222
66539
|
}
|
|
66223
66540
|
if (currentTargetAgent && skillsField && skillsField.toLowerCase() !== "none") {
|
|
66224
|
-
const skillPaths =
|
|
66225
|
-
const taskId =
|
|
66541
|
+
const skillPaths = _internals30.parseSkillPaths(skillsField);
|
|
66542
|
+
const taskId = _internals30.extractTaskIdFromPrompt(text);
|
|
66226
66543
|
for (const skillPath of skillPaths) {
|
|
66227
66544
|
if (hadRecordingError)
|
|
66228
66545
|
break;
|
|
66229
66546
|
if (isDuplicate(skillPath, currentTargetAgent, taskId))
|
|
66230
66547
|
continue;
|
|
66231
66548
|
try {
|
|
66232
|
-
|
|
66549
|
+
_internals30.appendSkillUsageEntry(directory, {
|
|
66233
66550
|
skillPath,
|
|
66234
66551
|
agentName: currentTargetAgent,
|
|
66235
66552
|
taskID: taskId,
|
|
@@ -66249,7 +66566,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
66249
66566
|
break;
|
|
66250
66567
|
}
|
|
66251
66568
|
}
|
|
66252
|
-
var SKILL_CAPABLE_AGENTS, SKILL_SEARCH_ROOTS, MAX_SCORING_SESSION_ENTRIES = 500,
|
|
66569
|
+
var SKILL_CAPABLE_AGENTS, SKILL_SEARCH_ROOTS, MAX_SCORING_SESSION_ENTRIES = 500, _internals30, COMPLIANCE_PATTERN, CODER_SKILLS_PATTERN, REVIEWER_TASK_PATTERN;
|
|
66253
66570
|
var init_skill_propagation_gate = __esm(() => {
|
|
66254
66571
|
init_schema();
|
|
66255
66572
|
init_logger();
|
|
@@ -66268,7 +66585,7 @@ var init_skill_propagation_gate = __esm(() => {
|
|
|
66268
66585
|
".opencode/skills/generated",
|
|
66269
66586
|
".claude/skills"
|
|
66270
66587
|
];
|
|
66271
|
-
|
|
66588
|
+
_internals30 = {
|
|
66272
66589
|
readdirSync: fs22.readdirSync.bind(fs22),
|
|
66273
66590
|
existsSync: fs22.existsSync.bind(fs22),
|
|
66274
66591
|
statSync: fs22.statSync.bind(fs22),
|
|
@@ -66297,16 +66614,16 @@ var init_skill_propagation_gate = __esm(() => {
|
|
|
66297
66614
|
COMPLIANCE_PATTERN = /SKILL_COMPLIANCE\s*:\s*(COMPLIANT|PARTIAL|VIOLATED)(?:\s*(?:—|-)\s*(.*))?\s*$/i;
|
|
66298
66615
|
CODER_SKILLS_PATTERN = /SKILLS_USED_BY_CODER\s*:\s*(.+)/i;
|
|
66299
66616
|
REVIEWER_TASK_PATTERN = /TASK\s*:\s*(\S+)/i;
|
|
66300
|
-
|
|
66301
|
-
|
|
66302
|
-
|
|
66303
|
-
|
|
66304
|
-
|
|
66305
|
-
|
|
66306
|
-
|
|
66307
|
-
|
|
66308
|
-
|
|
66309
|
-
|
|
66617
|
+
_internals30.skillPropagationGateBefore = skillPropagationGateBefore;
|
|
66618
|
+
_internals30.skillPropagationTransformScan = skillPropagationTransformScan;
|
|
66619
|
+
_internals30.writeWarnEvent = writeWarnEvent;
|
|
66620
|
+
_internals30.discoverAvailableSkills = discoverAvailableSkills;
|
|
66621
|
+
_internals30.parseDelegationArgs = parseDelegationArgs;
|
|
66622
|
+
_internals30.parseSkillPaths = parseSkillPaths;
|
|
66623
|
+
_internals30.extractTaskIdFromPrompt = extractTaskIdFromPrompt;
|
|
66624
|
+
_internals30.extractSkillsFieldFromPrompt = extractSkillsFieldFromPrompt;
|
|
66625
|
+
_internals30.formatSkillIndexWithContext = formatSkillIndexWithContext;
|
|
66626
|
+
_internals30.loadRoutingSkills = loadRoutingSkills;
|
|
66310
66627
|
});
|
|
66311
66628
|
|
|
66312
66629
|
// src/hooks/micro-reflector.ts
|
|
@@ -67138,7 +67455,7 @@ async function curateAndStoreSwarm(lessons, projectName, phaseInfo, directory, c
|
|
|
67138
67455
|
} catch {}
|
|
67139
67456
|
}
|
|
67140
67457
|
if (!options?.skipAutoPromotion) {
|
|
67141
|
-
await
|
|
67458
|
+
await _internals31.runAutoPromotion(directory, config3);
|
|
67142
67459
|
}
|
|
67143
67460
|
return { stored, reinforced, skipped, rejected, quarantined };
|
|
67144
67461
|
}
|
|
@@ -67221,7 +67538,7 @@ function createKnowledgeCuratorHook(directory, config3, options = {}) {
|
|
|
67221
67538
|
recordSeenRetroSection(evidenceKey, evidenceHash, Date.now());
|
|
67222
67539
|
const projectName2 = evidenceData.project_name ?? "unknown";
|
|
67223
67540
|
const phaseNumber2 = typeof evidenceData.phase_number === "number" ? evidenceData.phase_number : 1;
|
|
67224
|
-
await
|
|
67541
|
+
await _internals31.curateAndStoreSwarm(lessons, projectName2, { phase_number: phaseNumber2 }, directory, config3, {
|
|
67225
67542
|
llmDelegate: options.llmDelegateFactory?.(sessionID),
|
|
67226
67543
|
enrichmentQuota: options.enrichmentQuota
|
|
67227
67544
|
});
|
|
@@ -67246,14 +67563,14 @@ function createKnowledgeCuratorHook(directory, config3, options = {}) {
|
|
|
67246
67563
|
const projectName = projectNameMatch ? projectNameMatch[1].trim() : "unknown";
|
|
67247
67564
|
const phaseMatch = /^Phase:\s*(\d+)/m.exec(planContent);
|
|
67248
67565
|
const phaseNumber = phaseMatch ? parseInt(phaseMatch[1], 10) : 1;
|
|
67249
|
-
await
|
|
67566
|
+
await _internals31.curateAndStoreSwarm(normalLessons, projectName, { phase_number: phaseNumber }, directory, config3, {
|
|
67250
67567
|
llmDelegate: options.llmDelegateFactory?.(sessionID),
|
|
67251
67568
|
enrichmentQuota: options.enrichmentQuota
|
|
67252
67569
|
});
|
|
67253
67570
|
};
|
|
67254
67571
|
return safeHook(handler);
|
|
67255
67572
|
}
|
|
67256
|
-
var seenRetroSections, MAX_TRACKED_RETRO_SECTIONS = 500, ENRICHMENT_ALLOWED_FIELDS, ENRICHMENT_LLM_TIMEOUT_MS = 60000, MESO_INSIGHT_BATCH_LIMIT = 20, KNOWLEDGE_CATEGORIES, OUTCOME_PROMOTION_BLOCK = -0.3,
|
|
67573
|
+
var seenRetroSections, MAX_TRACKED_RETRO_SECTIONS = 500, ENRICHMENT_ALLOWED_FIELDS, ENRICHMENT_LLM_TIMEOUT_MS = 60000, MESO_INSIGHT_BATCH_LIMIT = 20, KNOWLEDGE_CATEGORIES, OUTCOME_PROMOTION_BLOCK = -0.3, _internals31;
|
|
67257
67574
|
var init_knowledge_curator = __esm(() => {
|
|
67258
67575
|
init_skill_improver_quota();
|
|
67259
67576
|
init_synonym_map();
|
|
@@ -67286,7 +67603,7 @@ var init_knowledge_curator = __esm(() => {
|
|
|
67286
67603
|
"todo",
|
|
67287
67604
|
"other"
|
|
67288
67605
|
]);
|
|
67289
|
-
|
|
67606
|
+
_internals31 = {
|
|
67290
67607
|
isWriteToEvidenceFile,
|
|
67291
67608
|
curateAndStoreSwarm,
|
|
67292
67609
|
runAutoPromotion,
|
|
@@ -68534,7 +68851,7 @@ async function executeWriteRetro(args2, directory) {
|
|
|
68534
68851
|
}, null, 2);
|
|
68535
68852
|
}
|
|
68536
68853
|
}
|
|
68537
|
-
var write_retro,
|
|
68854
|
+
var write_retro, _internals32;
|
|
68538
68855
|
var init_write_retro = __esm(() => {
|
|
68539
68856
|
init_zod();
|
|
68540
68857
|
init_evidence_schema();
|
|
@@ -68581,13 +68898,13 @@ var init_write_retro = __esm(() => {
|
|
|
68581
68898
|
task_id: args2.task_id !== undefined ? String(args2.task_id) : undefined,
|
|
68582
68899
|
metadata: args2.metadata
|
|
68583
68900
|
};
|
|
68584
|
-
return await
|
|
68901
|
+
return await _internals32.executeWriteRetro(writeRetroArgs, directory);
|
|
68585
68902
|
} catch {
|
|
68586
68903
|
return JSON.stringify({ success: false, phase: rawPhase, message: "Invalid arguments" }, null, 2);
|
|
68587
68904
|
}
|
|
68588
68905
|
}
|
|
68589
68906
|
});
|
|
68590
|
-
|
|
68907
|
+
_internals32 = {
|
|
68591
68908
|
executeWriteRetro,
|
|
68592
68909
|
write_retro
|
|
68593
68910
|
};
|
|
@@ -68597,7 +68914,7 @@ var init_write_retro = __esm(() => {
|
|
|
68597
68914
|
var exports_curator_postmortem = {};
|
|
68598
68915
|
__export(exports_curator_postmortem, {
|
|
68599
68916
|
runCuratorPostMortem: () => runCuratorPostMortem,
|
|
68600
|
-
_internals: () =>
|
|
68917
|
+
_internals: () => _internals33
|
|
68601
68918
|
});
|
|
68602
68919
|
import { existsSync as existsSync26, readdirSync as readdirSync6, readFileSync as readFileSync12 } from "node:fs";
|
|
68603
68920
|
import * as path48 from "node:path";
|
|
@@ -68922,9 +69239,9 @@ ${llmOutput}`;
|
|
|
68922
69239
|
reportContent = buildDataOnlyReport(planId, planSummary, knowledgeSummary, curatorDigest, proposals, unactionable, retrospectives, driftReports);
|
|
68923
69240
|
}
|
|
68924
69241
|
try {
|
|
68925
|
-
const { mkdirSync: mkdirSync16, writeFileSync:
|
|
69242
|
+
const { mkdirSync: mkdirSync16, writeFileSync: writeFileSync9 } = await import("node:fs");
|
|
68926
69243
|
mkdirSync16(path48.dirname(reportPath), { recursive: true });
|
|
68927
|
-
|
|
69244
|
+
writeFileSync9(reportPath, reportContent, "utf-8");
|
|
68928
69245
|
} catch (err2) {
|
|
68929
69246
|
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
68930
69247
|
return {
|
|
@@ -68951,13 +69268,13 @@ ${llmOutput}`;
|
|
|
68951
69268
|
warnings
|
|
68952
69269
|
};
|
|
68953
69270
|
}
|
|
68954
|
-
var
|
|
69271
|
+
var _internals33;
|
|
68955
69272
|
var init_curator_postmortem = __esm(() => {
|
|
68956
69273
|
init_manager();
|
|
68957
69274
|
init_knowledge_events();
|
|
68958
69275
|
init_knowledge_store();
|
|
68959
69276
|
init_utils2();
|
|
68960
|
-
|
|
69277
|
+
_internals33 = {
|
|
68961
69278
|
collectKnowledgeSummary,
|
|
68962
69279
|
collectRetrospectives,
|
|
68963
69280
|
collectDriftReports,
|
|
@@ -69962,7 +70279,7 @@ __export(exports_skill_consolidation, {
|
|
|
69962
70279
|
runSkillConsolidationFireAndForget: () => runSkillConsolidationFireAndForget,
|
|
69963
70280
|
runSkillConsolidation: () => runSkillConsolidation,
|
|
69964
70281
|
consolidationStatePath: () => consolidationStatePath,
|
|
69965
|
-
_internals: () =>
|
|
70282
|
+
_internals: () => _internals34
|
|
69966
70283
|
});
|
|
69967
70284
|
import { existsSync as existsSync27 } from "node:fs";
|
|
69968
70285
|
import { mkdir as mkdir15, readFile as readFile15, rename as rename9, writeFile as writeFile13 } from "node:fs/promises";
|
|
@@ -70086,12 +70403,12 @@ function runSkillConsolidationFireAndForget(req, onComplete, onError) {
|
|
|
70086
70403
|
runSkillConsolidation(req).then(onComplete).catch(onError);
|
|
70087
70404
|
});
|
|
70088
70405
|
}
|
|
70089
|
-
var DEFAULT_CONSOLIDATION_INTERVAL_HOURS = 24, DEFAULT_CONSOLIDATION_MAX_CALLS_PER_RUN = 1, CONSOLIDATION_RUN_TIMEOUT_MS, runningByDirectory,
|
|
70406
|
+
var DEFAULT_CONSOLIDATION_INTERVAL_HOURS = 24, DEFAULT_CONSOLIDATION_MAX_CALLS_PER_RUN = 1, CONSOLIDATION_RUN_TIMEOUT_MS, runningByDirectory, _internals34;
|
|
70090
70407
|
var init_skill_consolidation = __esm(() => {
|
|
70091
70408
|
init_skill_improver();
|
|
70092
70409
|
CONSOLIDATION_RUN_TIMEOUT_MS = 5 * 60 * 1000;
|
|
70093
70410
|
runningByDirectory = new Map;
|
|
70094
|
-
|
|
70411
|
+
_internals34 = {
|
|
70095
70412
|
readState: readState2,
|
|
70096
70413
|
writeState: writeState2,
|
|
70097
70414
|
intervalElapsed,
|
|
@@ -70281,7 +70598,7 @@ __export(exports_co_change_analyzer, {
|
|
|
70281
70598
|
darkMatterToKnowledgeEntries: () => darkMatterToKnowledgeEntries,
|
|
70282
70599
|
co_change_analyzer: () => co_change_analyzer,
|
|
70283
70600
|
buildCoChangeMatrix: () => buildCoChangeMatrix,
|
|
70284
|
-
_internals: () =>
|
|
70601
|
+
_internals: () => _internals35
|
|
70285
70602
|
});
|
|
70286
70603
|
import * as child_process3 from "node:child_process";
|
|
70287
70604
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
@@ -70507,9 +70824,9 @@ async function detectDarkMatter(directory, options) {
|
|
|
70507
70824
|
} catch {
|
|
70508
70825
|
return [];
|
|
70509
70826
|
}
|
|
70510
|
-
const commitMap = await
|
|
70511
|
-
const matrix =
|
|
70512
|
-
const staticEdges = await
|
|
70827
|
+
const commitMap = await _internals35.parseGitLog(directory, maxCommitsToAnalyze);
|
|
70828
|
+
const matrix = _internals35.buildCoChangeMatrix(commitMap, maxFilesPerCommit);
|
|
70829
|
+
const staticEdges = await _internals35.getStaticEdges(directory);
|
|
70513
70830
|
const results = [];
|
|
70514
70831
|
for (const entry of matrix.values()) {
|
|
70515
70832
|
const key = `${entry.fileA}::${entry.fileB}`;
|
|
@@ -70597,7 +70914,7 @@ ${rows}
|
|
|
70597
70914
|
These pairs likely share an architectural concern invisible to static analysis.
|
|
70598
70915
|
Consider adding explicit documentation or extracting the shared concern.`;
|
|
70599
70916
|
}
|
|
70600
|
-
var co_change_analyzer,
|
|
70917
|
+
var co_change_analyzer, _internals35;
|
|
70601
70918
|
var init_co_change_analyzer = __esm(() => {
|
|
70602
70919
|
init_zod();
|
|
70603
70920
|
init_create_tool();
|
|
@@ -70629,11 +70946,11 @@ var init_co_change_analyzer = __esm(() => {
|
|
|
70629
70946
|
npmiThreshold,
|
|
70630
70947
|
maxCommitsToAnalyze
|
|
70631
70948
|
};
|
|
70632
|
-
const pairs = await
|
|
70633
|
-
return
|
|
70949
|
+
const pairs = await _internals35.detectDarkMatter(directory, options);
|
|
70950
|
+
return _internals35.formatDarkMatterOutput(pairs);
|
|
70634
70951
|
}
|
|
70635
70952
|
});
|
|
70636
|
-
|
|
70953
|
+
_internals35 = {
|
|
70637
70954
|
parseGitLog,
|
|
70638
70955
|
buildCoChangeMatrix,
|
|
70639
70956
|
getStaticEdges,
|
|
@@ -70664,7 +70981,7 @@ async function handleDarkMatterCommand(directory, args2) {
|
|
|
70664
70981
|
}
|
|
70665
70982
|
let pairs;
|
|
70666
70983
|
try {
|
|
70667
|
-
pairs = await
|
|
70984
|
+
pairs = await _internals35.detectDarkMatter(directory, options);
|
|
70668
70985
|
} catch (err2) {
|
|
70669
70986
|
const errMsg = err2 instanceof Error ? err2.message : String(err2);
|
|
70670
70987
|
return `## Dark Matter Analysis Failed
|
|
@@ -71182,7 +71499,7 @@ var init_gate_bridge = __esm(() => {
|
|
|
71182
71499
|
});
|
|
71183
71500
|
|
|
71184
71501
|
// src/services/version-check.ts
|
|
71185
|
-
import { existsSync as existsSync28, mkdirSync as mkdirSync16, readFileSync as readFileSync13, writeFileSync as
|
|
71502
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync16, readFileSync as readFileSync13, writeFileSync as writeFileSync9 } from "node:fs";
|
|
71186
71503
|
import { homedir as homedir6 } from "node:os";
|
|
71187
71504
|
import { join as join43 } from "node:path";
|
|
71188
71505
|
function cacheDir() {
|
|
@@ -71212,7 +71529,7 @@ function writeVersionCache(entry) {
|
|
|
71212
71529
|
try {
|
|
71213
71530
|
const dir = cacheDir();
|
|
71214
71531
|
mkdirSync16(dir, { recursive: true });
|
|
71215
|
-
|
|
71532
|
+
writeFileSync9(cacheFile(), JSON.stringify(entry, null, 2), "utf-8");
|
|
71216
71533
|
} catch {}
|
|
71217
71534
|
}
|
|
71218
71535
|
function compareVersions(a, b) {
|
|
@@ -74700,7 +75017,7 @@ function isCommandAvailable(command) {
|
|
|
74700
75017
|
const isWindows = process.platform === "win32";
|
|
74701
75018
|
const cmd = isWindows ? `${command}.exe` : command;
|
|
74702
75019
|
try {
|
|
74703
|
-
const result =
|
|
75020
|
+
const result = _internals36.spawnSyncImpl(isWindows ? ["where", cmd] : ["which", cmd], {
|
|
74704
75021
|
cwd: process.cwd(),
|
|
74705
75022
|
stdin: "ignore",
|
|
74706
75023
|
stdout: "ignore",
|
|
@@ -74850,7 +75167,7 @@ async function discoverBuildCommands(workingDir, options) {
|
|
|
74850
75167
|
const scope = options?.scope ?? "all";
|
|
74851
75168
|
const changedFiles = options?.changedFiles ?? [];
|
|
74852
75169
|
const _filesToCheck = filterByScope(workingDir, scope, changedFiles);
|
|
74853
|
-
const profileResult = await
|
|
75170
|
+
const profileResult = await _internals36.discoverBuildCommandsFromProfiles(workingDir);
|
|
74854
75171
|
const profileCommands = profileResult.commands;
|
|
74855
75172
|
const profileSkipped = profileResult.skipped;
|
|
74856
75173
|
const coveredEcosystems = new Set;
|
|
@@ -74913,7 +75230,7 @@ function clearToolchainCache() {
|
|
|
74913
75230
|
function getEcosystems() {
|
|
74914
75231
|
return ECOSYSTEMS.map((e) => e.ecosystem);
|
|
74915
75232
|
}
|
|
74916
|
-
var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache, IS_COMMAND_AVAILABLE_TIMEOUT_MS = 3000,
|
|
75233
|
+
var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache, IS_COMMAND_AVAILABLE_TIMEOUT_MS = 3000, _internals36, build_discovery;
|
|
74917
75234
|
var init_discovery = __esm(() => {
|
|
74918
75235
|
init_dist();
|
|
74919
75236
|
init_detector();
|
|
@@ -75031,7 +75348,7 @@ var init_discovery = __esm(() => {
|
|
|
75031
75348
|
php: ["php-composer"]
|
|
75032
75349
|
};
|
|
75033
75350
|
toolchainCache = new Map;
|
|
75034
|
-
|
|
75351
|
+
_internals36 = {
|
|
75035
75352
|
isCommandAvailable,
|
|
75036
75353
|
discoverBuildCommandsFromProfiles,
|
|
75037
75354
|
discoverBuildCommands,
|
|
@@ -75328,7 +75645,7 @@ var exports_evidence_summary_service = {};
|
|
|
75328
75645
|
__export(exports_evidence_summary_service, {
|
|
75329
75646
|
isAutoSummaryEnabled: () => isAutoSummaryEnabled,
|
|
75330
75647
|
buildEvidenceSummary: () => buildEvidenceSummary,
|
|
75331
|
-
_internals: () =>
|
|
75648
|
+
_internals: () => _internals37,
|
|
75332
75649
|
REQUIRED_EVIDENCE_TYPES: () => REQUIRED_EVIDENCE_TYPES,
|
|
75333
75650
|
EVIDENCE_SUMMARY_VERSION: () => EVIDENCE_SUMMARY_VERSION
|
|
75334
75651
|
});
|
|
@@ -75366,7 +75683,7 @@ function getTaskStatus(task, bundle) {
|
|
|
75366
75683
|
if (task?.status) {
|
|
75367
75684
|
return task.status;
|
|
75368
75685
|
}
|
|
75369
|
-
const entries =
|
|
75686
|
+
const entries = _internals37.normalizeBundleEntries(bundle);
|
|
75370
75687
|
if (entries.length > 0) {
|
|
75371
75688
|
return "completed";
|
|
75372
75689
|
}
|
|
@@ -75392,7 +75709,7 @@ function evidenceCompleteFromEntries(entries) {
|
|
|
75392
75709
|
};
|
|
75393
75710
|
}
|
|
75394
75711
|
function isEvidenceComplete(bundle) {
|
|
75395
|
-
return evidenceCompleteFromEntries(
|
|
75712
|
+
return evidenceCompleteFromEntries(_internals37.normalizeBundleEntries(bundle));
|
|
75396
75713
|
}
|
|
75397
75714
|
function getTaskBlockers(task, summary, status) {
|
|
75398
75715
|
const blockers = [];
|
|
@@ -75412,9 +75729,9 @@ async function buildTaskSummary(directory, task, taskId) {
|
|
|
75412
75729
|
const bundle = result.status === "found" ? result.bundle : null;
|
|
75413
75730
|
const gateEvidence = await readDurableGateEvidence(directory, taskId);
|
|
75414
75731
|
const phase = task?.phase ?? 0;
|
|
75415
|
-
const status =
|
|
75416
|
-
const entries = mergeDurableGateEntriesFromEvidence(taskId,
|
|
75417
|
-
let evidenceCheck =
|
|
75732
|
+
const status = _internals37.getTaskStatus(task, bundle);
|
|
75733
|
+
const entries = mergeDurableGateEntriesFromEvidence(taskId, _internals37.normalizeBundleEntries(bundle), gateEvidence);
|
|
75734
|
+
let evidenceCheck = _internals37.evidenceCompleteFromEntries(entries);
|
|
75418
75735
|
if (gateEvidence) {
|
|
75419
75736
|
const gateStatus = getDurableGateEvidenceStatus(gateEvidence);
|
|
75420
75737
|
evidenceCheck = gateStatus.isComplete ? { isComplete: true, missingEvidence: [] } : {
|
|
@@ -75422,7 +75739,7 @@ async function buildTaskSummary(directory, task, taskId) {
|
|
|
75422
75739
|
missingEvidence: gateStatus.missingGates.map((gate) => `gate:${gate}`)
|
|
75423
75740
|
};
|
|
75424
75741
|
}
|
|
75425
|
-
const blockers =
|
|
75742
|
+
const blockers = _internals37.getTaskBlockers(task, evidenceCheck, status);
|
|
75426
75743
|
const hasReview = entries.some((e) => e.type === "review");
|
|
75427
75744
|
const hasTest = entries.some((e) => e.type === "test");
|
|
75428
75745
|
const hasApproval = entries.some((e) => e.type === "approval");
|
|
@@ -75451,12 +75768,12 @@ async function buildPhaseSummary(directory, phase) {
|
|
|
75451
75768
|
const taskSummaries = [];
|
|
75452
75769
|
const _taskMap = new Map(phase.tasks.map((t) => [t.id, t]));
|
|
75453
75770
|
for (const task of phase.tasks) {
|
|
75454
|
-
const summary = await
|
|
75771
|
+
const summary = await _internals37.buildTaskSummary(directory, task, task.id);
|
|
75455
75772
|
taskSummaries.push(summary);
|
|
75456
75773
|
}
|
|
75457
75774
|
const extraTaskIds = taskIds.filter((id) => !phaseTaskIds.has(id));
|
|
75458
75775
|
for (const taskId of extraTaskIds) {
|
|
75459
|
-
const summary = await
|
|
75776
|
+
const summary = await _internals37.buildTaskSummary(directory, undefined, taskId);
|
|
75460
75777
|
if (summary.phase === phase.id) {
|
|
75461
75778
|
taskSummaries.push(summary);
|
|
75462
75779
|
}
|
|
@@ -75557,7 +75874,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
75557
75874
|
let totalTasks = 0;
|
|
75558
75875
|
let completedTasks = 0;
|
|
75559
75876
|
for (const phase of phasesToProcess) {
|
|
75560
|
-
const summary = await
|
|
75877
|
+
const summary = await _internals37.buildPhaseSummary(directory, phase);
|
|
75561
75878
|
phaseSummaries.push(summary);
|
|
75562
75879
|
totalTasks += summary.totalTasks;
|
|
75563
75880
|
completedTasks += summary.completedTasks;
|
|
@@ -75579,7 +75896,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
75579
75896
|
overallBlockers,
|
|
75580
75897
|
summaryText: ""
|
|
75581
75898
|
};
|
|
75582
|
-
artifact.summaryText =
|
|
75899
|
+
artifact.summaryText = _internals37.generateSummaryText(artifact);
|
|
75583
75900
|
log("[EvidenceSummary] Summary built", {
|
|
75584
75901
|
phases: phaseSummaries.length,
|
|
75585
75902
|
totalTasks,
|
|
@@ -75598,7 +75915,7 @@ function isAutoSummaryEnabled(automationConfig) {
|
|
|
75598
75915
|
}
|
|
75599
75916
|
return automationConfig.capabilities?.evidence_auto_summaries === true;
|
|
75600
75917
|
}
|
|
75601
|
-
var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0",
|
|
75918
|
+
var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0", _internals37;
|
|
75602
75919
|
var init_evidence_summary_service = __esm(() => {
|
|
75603
75920
|
init_gate_bridge();
|
|
75604
75921
|
init_manager2();
|
|
@@ -75613,7 +75930,7 @@ var init_evidence_summary_service = __esm(() => {
|
|
|
75613
75930
|
"retrospective"
|
|
75614
75931
|
]);
|
|
75615
75932
|
REQUIRED_EVIDENCE_TYPES = ["review", "test"];
|
|
75616
|
-
|
|
75933
|
+
_internals37 = {
|
|
75617
75934
|
buildEvidenceSummary,
|
|
75618
75935
|
isAutoSummaryEnabled,
|
|
75619
75936
|
normalizeBundleEntries,
|
|
@@ -75669,7 +75986,7 @@ function getVerdictEmoji(verdict) {
|
|
|
75669
75986
|
return getVerdictIcon(verdict);
|
|
75670
75987
|
}
|
|
75671
75988
|
async function getTaskEvidenceData(directory, taskId) {
|
|
75672
|
-
const result = await
|
|
75989
|
+
const result = await _internals38.loadEvidence(directory, taskId);
|
|
75673
75990
|
if (result.status !== "found") {
|
|
75674
75991
|
return {
|
|
75675
75992
|
hasEvidence: false,
|
|
@@ -75692,13 +76009,13 @@ async function getTaskEvidenceData(directory, taskId) {
|
|
|
75692
76009
|
};
|
|
75693
76010
|
}
|
|
75694
76011
|
async function getEvidenceListData(directory) {
|
|
75695
|
-
const taskIds = await
|
|
76012
|
+
const taskIds = await _internals38.listEvidenceTaskIds(directory);
|
|
75696
76013
|
if (taskIds.length === 0) {
|
|
75697
76014
|
return { hasEvidence: false, tasks: [] };
|
|
75698
76015
|
}
|
|
75699
76016
|
const tasks = [];
|
|
75700
76017
|
for (const taskId of taskIds) {
|
|
75701
|
-
const result = await
|
|
76018
|
+
const result = await _internals38.loadEvidence(directory, taskId);
|
|
75702
76019
|
if (result.status === "found") {
|
|
75703
76020
|
tasks.push({
|
|
75704
76021
|
taskId,
|
|
@@ -75812,10 +76129,10 @@ async function handleEvidenceSummaryCommand(directory) {
|
|
|
75812
76129
|
return lines.join(`
|
|
75813
76130
|
`);
|
|
75814
76131
|
}
|
|
75815
|
-
var
|
|
76132
|
+
var _internals38;
|
|
75816
76133
|
var init_evidence_service = __esm(() => {
|
|
75817
76134
|
init_manager2();
|
|
75818
|
-
|
|
76135
|
+
_internals38 = {
|
|
75819
76136
|
loadEvidence,
|
|
75820
76137
|
listEvidenceTaskIds
|
|
75821
76138
|
};
|
|
@@ -76464,7 +76781,7 @@ function extractCurrentPhaseFromPlan2(plan) {
|
|
|
76464
76781
|
if (!plan) {
|
|
76465
76782
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
76466
76783
|
}
|
|
76467
|
-
if (!
|
|
76784
|
+
if (!_internals39.validatePlanPhases(plan)) {
|
|
76468
76785
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
76469
76786
|
}
|
|
76470
76787
|
let currentPhase = null;
|
|
@@ -76606,9 +76923,9 @@ function extractPhaseMetrics(content) {
|
|
|
76606
76923
|
async function getHandoffData(directory) {
|
|
76607
76924
|
const now = new Date().toISOString();
|
|
76608
76925
|
const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
|
|
76609
|
-
const sessionState =
|
|
76926
|
+
const sessionState = _internals39.parseSessionState(sessionContent);
|
|
76610
76927
|
const plan = await loadPlanJsonOnly(directory);
|
|
76611
|
-
const planInfo =
|
|
76928
|
+
const planInfo = _internals39.extractCurrentPhaseFromPlan(plan);
|
|
76612
76929
|
if (!plan) {
|
|
76613
76930
|
const planMdContent = await readSwarmFileAsync(directory, "plan.md");
|
|
76614
76931
|
if (planMdContent) {
|
|
@@ -76627,8 +76944,8 @@ async function getHandoffData(directory) {
|
|
|
76627
76944
|
}
|
|
76628
76945
|
}
|
|
76629
76946
|
const contextContent = await readSwarmFileAsync(directory, "context.md");
|
|
76630
|
-
const recentDecisions =
|
|
76631
|
-
const rawPhaseMetrics =
|
|
76947
|
+
const recentDecisions = _internals39.extractDecisions(contextContent);
|
|
76948
|
+
const rawPhaseMetrics = _internals39.extractPhaseMetrics(contextContent);
|
|
76632
76949
|
const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
|
|
76633
76950
|
let delegationState = null;
|
|
76634
76951
|
if (sessionState?.delegationState) {
|
|
@@ -76792,13 +77109,13 @@ ${lines.join(`
|
|
|
76792
77109
|
`)}
|
|
76793
77110
|
\`\`\``;
|
|
76794
77111
|
}
|
|
76795
|
-
var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20,
|
|
77112
|
+
var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20, _internals39;
|
|
76796
77113
|
var init_handoff_service = __esm(() => {
|
|
76797
77114
|
init_utils2();
|
|
76798
77115
|
init_manager();
|
|
76799
77116
|
init_utils();
|
|
76800
77117
|
RTL_OVERRIDE_PATTERN = /[\u202e\u202d\u202c\u200f]/g;
|
|
76801
|
-
|
|
77118
|
+
_internals39 = {
|
|
76802
77119
|
getHandoffData,
|
|
76803
77120
|
formatHandoffMarkdown,
|
|
76804
77121
|
formatContinuationPrompt,
|
|
@@ -76813,7 +77130,7 @@ var init_handoff_service = __esm(() => {
|
|
|
76813
77130
|
});
|
|
76814
77131
|
|
|
76815
77132
|
// src/session/snapshot-writer.ts
|
|
76816
|
-
import { closeSync as closeSync5, fsyncSync as fsyncSync2, mkdirSync as mkdirSync19, openSync as openSync5, renameSync as
|
|
77133
|
+
import { closeSync as closeSync5, fsyncSync as fsyncSync2, mkdirSync as mkdirSync19, openSync as openSync5, renameSync as renameSync11 } from "node:fs";
|
|
76817
77134
|
import * as path59 from "node:path";
|
|
76818
77135
|
function serializeAgentSession(s) {
|
|
76819
77136
|
const gateLog = {};
|
|
@@ -76932,7 +77249,7 @@ async function writeSnapshot(directory, state) {
|
|
|
76932
77249
|
closeSync5(fd);
|
|
76933
77250
|
}
|
|
76934
77251
|
} catch {}
|
|
76935
|
-
|
|
77252
|
+
renameSync11(tempPath, resolvedPath);
|
|
76936
77253
|
} catch (error93) {
|
|
76937
77254
|
log("[snapshot-writer] write failed", {
|
|
76938
77255
|
error: error93 instanceof Error ? error93.message : String(error93)
|
|
@@ -76941,22 +77258,22 @@ async function writeSnapshot(directory, state) {
|
|
|
76941
77258
|
}
|
|
76942
77259
|
function createSnapshotWriterHook(directory) {
|
|
76943
77260
|
return (_input, _output) => {
|
|
76944
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
77261
|
+
_writeInFlight = _writeInFlight.then(() => _internals40.writeSnapshot(directory, swarmState), () => _internals40.writeSnapshot(directory, swarmState));
|
|
76945
77262
|
return _writeInFlight;
|
|
76946
77263
|
};
|
|
76947
77264
|
}
|
|
76948
77265
|
async function flushPendingSnapshot(directory) {
|
|
76949
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
77266
|
+
_writeInFlight = _writeInFlight.then(() => _internals40.writeSnapshot(directory, swarmState), () => _internals40.writeSnapshot(directory, swarmState));
|
|
76950
77267
|
await _writeInFlight;
|
|
76951
77268
|
}
|
|
76952
|
-
var _writeInFlight,
|
|
77269
|
+
var _writeInFlight, _internals40;
|
|
76953
77270
|
var init_snapshot_writer = __esm(() => {
|
|
76954
77271
|
init_utils2();
|
|
76955
77272
|
init_state();
|
|
76956
77273
|
init_utils();
|
|
76957
77274
|
init_bun_compat();
|
|
76958
77275
|
_writeInFlight = Promise.resolve();
|
|
76959
|
-
|
|
77276
|
+
_internals40 = {
|
|
76960
77277
|
writeSnapshot,
|
|
76961
77278
|
createSnapshotWriterHook,
|
|
76962
77279
|
flushPendingSnapshot
|
|
@@ -76965,7 +77282,7 @@ var init_snapshot_writer = __esm(() => {
|
|
|
76965
77282
|
|
|
76966
77283
|
// src/commands/handoff.ts
|
|
76967
77284
|
import crypto6 from "node:crypto";
|
|
76968
|
-
import { renameSync as
|
|
77285
|
+
import { renameSync as renameSync12, unlinkSync as unlinkSync7 } from "node:fs";
|
|
76969
77286
|
async function handleHandoffCommand(directory, _args) {
|
|
76970
77287
|
const handoffData = await getHandoffData(directory);
|
|
76971
77288
|
const markdown = formatHandoffMarkdown(handoffData);
|
|
@@ -76974,7 +77291,7 @@ async function handleHandoffCommand(directory, _args) {
|
|
|
76974
77291
|
const tempPath = `${resolvedPath}.tmp.${crypto6.randomUUID()}`;
|
|
76975
77292
|
await bunWrite(tempPath, markdown);
|
|
76976
77293
|
try {
|
|
76977
|
-
|
|
77294
|
+
renameSync12(tempPath, resolvedPath);
|
|
76978
77295
|
} catch (renameErr) {
|
|
76979
77296
|
try {
|
|
76980
77297
|
unlinkSync7(tempPath);
|
|
@@ -76986,7 +77303,7 @@ async function handleHandoffCommand(directory, _args) {
|
|
|
76986
77303
|
const promptTempPath = `${promptPath}.tmp.${crypto6.randomUUID()}`;
|
|
76987
77304
|
await bunWrite(promptTempPath, continuationPrompt);
|
|
76988
77305
|
try {
|
|
76989
|
-
|
|
77306
|
+
renameSync12(promptTempPath, promptPath);
|
|
76990
77307
|
} catch (renameErr) {
|
|
76991
77308
|
try {
|
|
76992
77309
|
unlinkSync7(promptTempPath);
|
|
@@ -77276,7 +77593,7 @@ function validateAndSanitizeGithubUrl(rawUrl, resource) {
|
|
|
77276
77593
|
}
|
|
77277
77594
|
function detectGitRemote(cwd) {
|
|
77278
77595
|
try {
|
|
77279
|
-
const result =
|
|
77596
|
+
const result = _internals41.spawnSync("git", ["remote", "get-url", "origin"], {
|
|
77280
77597
|
encoding: "utf-8",
|
|
77281
77598
|
stdio: ["ignore", "pipe", "pipe"],
|
|
77282
77599
|
timeout: 5000,
|
|
@@ -77321,7 +77638,7 @@ function parseGitRemoteUrl(remoteUrl) {
|
|
|
77321
77638
|
}
|
|
77322
77639
|
return null;
|
|
77323
77640
|
}
|
|
77324
|
-
var MAX_URL_LEN = 2048, IPV4_PRIVATE, IPV4_LOOPBACK, IPV4_LINK_LOCAL, IPV4_PRIVATE_172, IPV4_PRIVATE_192, IPV4_ZERO_NETWORK, IPV6_LINK_LOCAL, IPV6_UNIQUE_LOCAL,
|
|
77641
|
+
var MAX_URL_LEN = 2048, IPV4_PRIVATE, IPV4_LOOPBACK, IPV4_LINK_LOCAL, IPV4_PRIVATE_172, IPV4_PRIVATE_192, IPV4_ZERO_NETWORK, IPV6_LINK_LOCAL, IPV6_UNIQUE_LOCAL, _internals41;
|
|
77325
77642
|
var init_url_security = __esm(() => {
|
|
77326
77643
|
IPV4_PRIVATE = /^10\./;
|
|
77327
77644
|
IPV4_LOOPBACK = /^127\./;
|
|
@@ -77331,7 +77648,7 @@ var init_url_security = __esm(() => {
|
|
|
77331
77648
|
IPV4_ZERO_NETWORK = /^0\./;
|
|
77332
77649
|
IPV6_LINK_LOCAL = /^fe80:/i;
|
|
77333
77650
|
IPV6_UNIQUE_LOCAL = /^f[cd][0-9a-f]{2}:/i;
|
|
77334
|
-
|
|
77651
|
+
_internals41 = { spawnSync: spawnSync8 };
|
|
77335
77652
|
});
|
|
77336
77653
|
|
|
77337
77654
|
// src/commands/issue.ts
|
|
@@ -77505,9 +77822,9 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
77505
77822
|
skippedReason: "empty-context"
|
|
77506
77823
|
};
|
|
77507
77824
|
}
|
|
77508
|
-
const rawEntries =
|
|
77825
|
+
const rawEntries = _internals42.parseContextMd(contextContent);
|
|
77509
77826
|
if (rawEntries.length === 0) {
|
|
77510
|
-
await
|
|
77827
|
+
await _internals42.writeSentinel(sentinelPath, 0, 0);
|
|
77511
77828
|
return {
|
|
77512
77829
|
migrated: true,
|
|
77513
77830
|
entriesMigrated: 0,
|
|
@@ -77518,10 +77835,10 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
77518
77835
|
const existing = await readKnowledge(knowledgePath);
|
|
77519
77836
|
let migrated = 0;
|
|
77520
77837
|
let dropped = 0;
|
|
77521
|
-
const projectName =
|
|
77838
|
+
const projectName = _internals42.inferProjectName(directory);
|
|
77522
77839
|
for (const raw of rawEntries) {
|
|
77523
77840
|
if (config3.validation_enabled !== false) {
|
|
77524
|
-
const category = raw.categoryHint ??
|
|
77841
|
+
const category = raw.categoryHint ?? _internals42.inferCategoryFromText(raw.text);
|
|
77525
77842
|
const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
|
|
77526
77843
|
category,
|
|
77527
77844
|
scope: "global",
|
|
@@ -77541,8 +77858,8 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
77541
77858
|
const entry = {
|
|
77542
77859
|
id: randomUUID6(),
|
|
77543
77860
|
tier: "swarm",
|
|
77544
|
-
lesson:
|
|
77545
|
-
category: raw.categoryHint ??
|
|
77861
|
+
lesson: _internals42.truncateLesson(raw.text),
|
|
77862
|
+
category: raw.categoryHint ?? _internals42.inferCategoryFromText(raw.text),
|
|
77546
77863
|
tags: [...inferredTags, `migration:${raw.sourceSection}`],
|
|
77547
77864
|
scope: "global",
|
|
77548
77865
|
confidence: 0.3,
|
|
@@ -77565,7 +77882,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
77565
77882
|
if (migrated > 0) {
|
|
77566
77883
|
await rewriteKnowledge(knowledgePath, existing);
|
|
77567
77884
|
}
|
|
77568
|
-
await
|
|
77885
|
+
await _internals42.writeSentinel(sentinelPath, migrated, dropped);
|
|
77569
77886
|
log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
|
|
77570
77887
|
return {
|
|
77571
77888
|
migrated: true,
|
|
@@ -77575,7 +77892,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
77575
77892
|
};
|
|
77576
77893
|
}
|
|
77577
77894
|
async function migrateHiveKnowledgeLegacy(config3) {
|
|
77578
|
-
const legacyHivePath =
|
|
77895
|
+
const legacyHivePath = _internals42.resolveLegacyHiveKnowledgePath();
|
|
77579
77896
|
const canonicalHivePath = resolveHiveKnowledgePath();
|
|
77580
77897
|
const sentinelPath = path60.join(path60.dirname(canonicalHivePath), ".hive-knowledge-migrated");
|
|
77581
77898
|
if (existsSync34(sentinelPath)) {
|
|
@@ -77598,7 +77915,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
77598
77915
|
}
|
|
77599
77916
|
const legacyEntries = await readKnowledge(legacyHivePath);
|
|
77600
77917
|
if (legacyEntries.length === 0) {
|
|
77601
|
-
await
|
|
77918
|
+
await _internals42.writeSentinel(sentinelPath, 0, 0);
|
|
77602
77919
|
return {
|
|
77603
77920
|
migrated: true,
|
|
77604
77921
|
entriesMigrated: 0,
|
|
@@ -77646,7 +77963,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
77646
77963
|
const newHiveEntry = {
|
|
77647
77964
|
id: resolvedId,
|
|
77648
77965
|
tier: "hive",
|
|
77649
|
-
lesson:
|
|
77966
|
+
lesson: _internals42.truncateLesson(lesson),
|
|
77650
77967
|
category,
|
|
77651
77968
|
tags: ["migration:legacy-hive"],
|
|
77652
77969
|
scope: scopeTag,
|
|
@@ -77665,7 +77982,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
77665
77982
|
encounter_score: 1
|
|
77666
77983
|
};
|
|
77667
77984
|
try {
|
|
77668
|
-
await
|
|
77985
|
+
await _internals42.appendKnowledge(canonicalHivePath, newHiveEntry);
|
|
77669
77986
|
existingHiveEntries.push(newHiveEntry);
|
|
77670
77987
|
migrated++;
|
|
77671
77988
|
} catch (appendError) {
|
|
@@ -77681,7 +77998,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
77681
77998
|
dropped++;
|
|
77682
77999
|
}
|
|
77683
78000
|
}
|
|
77684
|
-
await
|
|
78001
|
+
await _internals42.writeSentinel(sentinelPath, migrated, dropped);
|
|
77685
78002
|
log(`[knowledge-migrator] Migrated ${migrated} legacy hive entries, dropped ${dropped}`);
|
|
77686
78003
|
return {
|
|
77687
78004
|
migrated: true,
|
|
@@ -77692,7 +78009,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
77692
78009
|
};
|
|
77693
78010
|
}
|
|
77694
78011
|
function parseContextMd(content) {
|
|
77695
|
-
const sections =
|
|
78012
|
+
const sections = _internals42.splitIntoSections(content);
|
|
77696
78013
|
const entries = [];
|
|
77697
78014
|
const seen = new Set;
|
|
77698
78015
|
const sectionPatterns = [
|
|
@@ -77708,7 +78025,7 @@ function parseContextMd(content) {
|
|
|
77708
78025
|
const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
|
|
77709
78026
|
if (!match)
|
|
77710
78027
|
continue;
|
|
77711
|
-
const bullets =
|
|
78028
|
+
const bullets = _internals42.extractBullets(section.body);
|
|
77712
78029
|
for (const bullet of bullets) {
|
|
77713
78030
|
if (bullet.length < 15)
|
|
77714
78031
|
continue;
|
|
@@ -77717,9 +78034,9 @@ function parseContextMd(content) {
|
|
|
77717
78034
|
continue;
|
|
77718
78035
|
seen.add(normalized);
|
|
77719
78036
|
entries.push({
|
|
77720
|
-
text:
|
|
78037
|
+
text: _internals42.truncateLesson(bullet),
|
|
77721
78038
|
sourceSection: match.sourceSection,
|
|
77722
|
-
categoryHint:
|
|
78039
|
+
categoryHint: _internals42.inferCategoryFromText(bullet)
|
|
77723
78040
|
});
|
|
77724
78041
|
}
|
|
77725
78042
|
}
|
|
@@ -77825,12 +78142,12 @@ function resolveLegacyHiveKnowledgePath() {
|
|
|
77825
78142
|
}
|
|
77826
78143
|
return path60.join(dataDir, "hive-knowledge.jsonl");
|
|
77827
78144
|
}
|
|
77828
|
-
var
|
|
78145
|
+
var _internals42;
|
|
77829
78146
|
var init_knowledge_migrator = __esm(() => {
|
|
77830
78147
|
init_logger();
|
|
77831
78148
|
init_knowledge_store();
|
|
77832
78149
|
init_knowledge_validator();
|
|
77833
|
-
|
|
78150
|
+
_internals42 = {
|
|
77834
78151
|
appendKnowledge,
|
|
77835
78152
|
migrateContextToKnowledge,
|
|
77836
78153
|
migrateKnowledgeToExternal,
|
|
@@ -82415,9 +82732,9 @@ var init_memory2 = __esm(() => {
|
|
|
82415
82732
|
|
|
82416
82733
|
// src/services/plan-service.ts
|
|
82417
82734
|
async function getPlanData(directory, phaseArg) {
|
|
82418
|
-
const plan = await
|
|
82735
|
+
const plan = await _internals43.loadPlanJsonOnly(directory);
|
|
82419
82736
|
if (plan) {
|
|
82420
|
-
const fullMarkdown =
|
|
82737
|
+
const fullMarkdown = _internals43.derivePlanMarkdown(plan);
|
|
82421
82738
|
if (phaseArg === undefined || phaseArg === null || phaseArg === "") {
|
|
82422
82739
|
return {
|
|
82423
82740
|
hasPlan: true,
|
|
@@ -82460,7 +82777,7 @@ async function getPlanData(directory, phaseArg) {
|
|
|
82460
82777
|
isLegacy: false
|
|
82461
82778
|
};
|
|
82462
82779
|
}
|
|
82463
|
-
const planContent = await
|
|
82780
|
+
const planContent = await _internals43.readSwarmFileAsync(directory, "plan.md");
|
|
82464
82781
|
if (!planContent) {
|
|
82465
82782
|
return {
|
|
82466
82783
|
hasPlan: false,
|
|
@@ -82556,11 +82873,11 @@ async function handlePlanCommand(directory, args2) {
|
|
|
82556
82873
|
const planData = await getPlanData(directory, phaseArg);
|
|
82557
82874
|
return formatPlanMarkdown(planData);
|
|
82558
82875
|
}
|
|
82559
|
-
var
|
|
82876
|
+
var _internals43;
|
|
82560
82877
|
var init_plan_service = __esm(() => {
|
|
82561
82878
|
init_utils2();
|
|
82562
82879
|
init_manager();
|
|
82563
|
-
|
|
82880
|
+
_internals43 = {
|
|
82564
82881
|
loadPlanJsonOnly,
|
|
82565
82882
|
derivePlanMarkdown,
|
|
82566
82883
|
readSwarmFileAsync
|
|
@@ -82750,7 +83067,7 @@ function formatRelativeTime(epochMs) {
|
|
|
82750
83067
|
return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
|
|
82751
83068
|
}
|
|
82752
83069
|
async function handlePrMonitorStatusCommand(directory, _args, sessionID) {
|
|
82753
|
-
const allActive = await
|
|
83070
|
+
const allActive = await _internals44.listActive(directory);
|
|
82754
83071
|
const sessionSubs = allActive.filter((record3) => record3.sessionID === sessionID);
|
|
82755
83072
|
if (sessionSubs.length === 0) {
|
|
82756
83073
|
return "No active PR subscriptions for this session.";
|
|
@@ -82779,10 +83096,10 @@ async function handlePrMonitorStatusCommand(directory, _args, sessionID) {
|
|
|
82779
83096
|
return lines.join(`
|
|
82780
83097
|
`);
|
|
82781
83098
|
}
|
|
82782
|
-
var
|
|
83099
|
+
var _internals44;
|
|
82783
83100
|
var init_pr_monitor_status = __esm(() => {
|
|
82784
83101
|
init_pr_subscriptions();
|
|
82785
|
-
|
|
83102
|
+
_internals44 = {
|
|
82786
83103
|
formatRelativeTime,
|
|
82787
83104
|
listActive
|
|
82788
83105
|
};
|
|
@@ -82887,7 +83204,7 @@ async function handlePrSubscribeCommand(directory, args2, sessionID) {
|
|
|
82887
83204
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
82888
83205
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
82889
83206
|
try {
|
|
82890
|
-
const config3 =
|
|
83207
|
+
const config3 = _internals45.loadPluginConfig(directory);
|
|
82891
83208
|
const prMonitorConfig = config3.pr_monitor;
|
|
82892
83209
|
if (!prMonitorConfig?.enabled) {
|
|
82893
83210
|
return [
|
|
@@ -82897,7 +83214,7 @@ async function handlePrSubscribeCommand(directory, args2, sessionID) {
|
|
|
82897
83214
|
].join(`
|
|
82898
83215
|
`);
|
|
82899
83216
|
}
|
|
82900
|
-
await
|
|
83217
|
+
await _internals45.subscribe(directory, {
|
|
82901
83218
|
sessionID,
|
|
82902
83219
|
prNumber: prInfo.number,
|
|
82903
83220
|
repoFullName,
|
|
@@ -82921,12 +83238,12 @@ async function handlePrSubscribeCommand(directory, args2, sessionID) {
|
|
|
82921
83238
|
`);
|
|
82922
83239
|
}
|
|
82923
83240
|
}
|
|
82924
|
-
var
|
|
83241
|
+
var _internals45;
|
|
82925
83242
|
var init_pr_subscribe = __esm(() => {
|
|
82926
83243
|
init_pr_subscriptions();
|
|
82927
83244
|
init_loader();
|
|
82928
83245
|
init_pr_ref();
|
|
82929
|
-
|
|
83246
|
+
_internals45 = {
|
|
82930
83247
|
loadPluginConfig,
|
|
82931
83248
|
subscribe
|
|
82932
83249
|
};
|
|
@@ -82950,9 +83267,9 @@ async function handlePrUnsubscribeCommand(directory, args2, sessionID) {
|
|
|
82950
83267
|
`);
|
|
82951
83268
|
}
|
|
82952
83269
|
const refToken = rest[0];
|
|
82953
|
-
const prInfo =
|
|
83270
|
+
const prInfo = _internals46.parsePrRef(refToken, directory);
|
|
82954
83271
|
if (!prInfo) {
|
|
82955
|
-
if (
|
|
83272
|
+
if (_internals46.looksLikePrRef(refToken)) {
|
|
82956
83273
|
return [
|
|
82957
83274
|
`Error: Could not resolve PR reference from "${refToken}".`,
|
|
82958
83275
|
"",
|
|
@@ -82973,8 +83290,8 @@ async function handlePrUnsubscribeCommand(directory, args2, sessionID) {
|
|
|
82973
83290
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
82974
83291
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
82975
83292
|
try {
|
|
82976
|
-
const correlationId =
|
|
82977
|
-
const result = await
|
|
83293
|
+
const correlationId = _internals46.buildCorrelationId(sessionID, repoFullName, prInfo.number);
|
|
83294
|
+
const result = await _internals46.unsubscribe(directory, correlationId);
|
|
82978
83295
|
if (!result) {
|
|
82979
83296
|
return [
|
|
82980
83297
|
`Not subscribed to ${prUrl}`,
|
|
@@ -83001,11 +83318,11 @@ async function handlePrUnsubscribeCommand(directory, args2, sessionID) {
|
|
|
83001
83318
|
`);
|
|
83002
83319
|
}
|
|
83003
83320
|
}
|
|
83004
|
-
var
|
|
83321
|
+
var _internals46;
|
|
83005
83322
|
var init_pr_unsubscribe = __esm(() => {
|
|
83006
83323
|
init_pr_subscriptions();
|
|
83007
83324
|
init_pr_ref();
|
|
83008
|
-
|
|
83325
|
+
_internals46 = {
|
|
83009
83326
|
unsubscribe,
|
|
83010
83327
|
buildCorrelationId,
|
|
83011
83328
|
parsePrRef,
|
|
@@ -83461,7 +83778,7 @@ async function runAdditionalLint(linter, mode, cwd) {
|
|
|
83461
83778
|
};
|
|
83462
83779
|
}
|
|
83463
83780
|
}
|
|
83464
|
-
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint,
|
|
83781
|
+
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals47;
|
|
83465
83782
|
var init_lint = __esm(() => {
|
|
83466
83783
|
init_zod();
|
|
83467
83784
|
init_discovery();
|
|
@@ -83493,15 +83810,15 @@ var init_lint = __esm(() => {
|
|
|
83493
83810
|
}
|
|
83494
83811
|
const { mode } = args2;
|
|
83495
83812
|
const cwd = directory;
|
|
83496
|
-
const linter = await
|
|
83813
|
+
const linter = await _internals47.detectAvailableLinter(directory);
|
|
83497
83814
|
if (linter) {
|
|
83498
|
-
const result = await
|
|
83815
|
+
const result = await _internals47.runLint(linter, mode, directory);
|
|
83499
83816
|
return JSON.stringify(result, null, 2);
|
|
83500
83817
|
}
|
|
83501
|
-
const additionalLinter =
|
|
83818
|
+
const additionalLinter = _internals47.detectAdditionalLinter(cwd);
|
|
83502
83819
|
if (additionalLinter) {
|
|
83503
83820
|
warn(`[lint] Using ${additionalLinter} linter for this project`);
|
|
83504
|
-
const result = await
|
|
83821
|
+
const result = await _internals47.runAdditionalLint(additionalLinter, mode, cwd);
|
|
83505
83822
|
return JSON.stringify(result, null, 2);
|
|
83506
83823
|
}
|
|
83507
83824
|
const errorResult = {
|
|
@@ -83515,7 +83832,7 @@ For Rust: rustup component add clippy`
|
|
|
83515
83832
|
return JSON.stringify(errorResult, null, 2);
|
|
83516
83833
|
}
|
|
83517
83834
|
});
|
|
83518
|
-
|
|
83835
|
+
_internals47 = {
|
|
83519
83836
|
detectAvailableLinter,
|
|
83520
83837
|
runLint,
|
|
83521
83838
|
detectAdditionalLinter,
|
|
@@ -83829,7 +84146,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
83829
84146
|
}
|
|
83830
84147
|
async function runSecretscan(directory) {
|
|
83831
84148
|
try {
|
|
83832
|
-
const result = await
|
|
84149
|
+
const result = await _internals48.secretscan.execute({ directory }, {});
|
|
83833
84150
|
const jsonStr = typeof result === "string" ? result : result.output;
|
|
83834
84151
|
return JSON.parse(jsonStr);
|
|
83835
84152
|
} catch (e) {
|
|
@@ -83844,7 +84161,7 @@ async function runSecretscan(directory) {
|
|
|
83844
84161
|
return errorResult;
|
|
83845
84162
|
}
|
|
83846
84163
|
}
|
|
83847
|
-
var MAX_FILE_PATH_LENGTH = 500, MAX_FILE_SIZE_BYTES, MAX_FILES_SCANNED = 1000, MAX_FINDINGS = 100, MAX_OUTPUT_BYTES2 = 512000, MAX_LINE_LENGTH = 1e4, MAX_CONTENT_BYTES, BINARY_SIGNATURES, BINARY_PREFIX_BYTES = 4, BINARY_NULL_CHECK_BYTES = 8192, BINARY_NULL_THRESHOLD = 0.1, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXCLUDE_EXTENSIONS, SECRET_PATTERNS2, O_NOFOLLOW, secretscan,
|
|
84164
|
+
var MAX_FILE_PATH_LENGTH = 500, MAX_FILE_SIZE_BYTES, MAX_FILES_SCANNED = 1000, MAX_FINDINGS = 100, MAX_OUTPUT_BYTES2 = 512000, MAX_LINE_LENGTH = 1e4, MAX_CONTENT_BYTES, BINARY_SIGNATURES, BINARY_PREFIX_BYTES = 4, BINARY_NULL_CHECK_BYTES = 8192, BINARY_NULL_THRESHOLD = 0.1, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXCLUDE_EXTENSIONS, SECRET_PATTERNS2, O_NOFOLLOW, secretscan, _internals48;
|
|
83848
84165
|
var init_secretscan = __esm(() => {
|
|
83849
84166
|
init_zod();
|
|
83850
84167
|
init_path_security();
|
|
@@ -84216,7 +84533,7 @@ var init_secretscan = __esm(() => {
|
|
|
84216
84533
|
}
|
|
84217
84534
|
}
|
|
84218
84535
|
});
|
|
84219
|
-
|
|
84536
|
+
_internals48 = {
|
|
84220
84537
|
secretscan,
|
|
84221
84538
|
runSecretscan
|
|
84222
84539
|
};
|
|
@@ -84808,14 +85125,14 @@ function buildGoBackend() {
|
|
|
84808
85125
|
selectEntryPoints
|
|
84809
85126
|
};
|
|
84810
85127
|
}
|
|
84811
|
-
var PROFILE_ID = "go", IMPORT_REGEX_SINGLE, IMPORT_REGEX_GROUP, IMPORT_REGEX_GROUP_LINE,
|
|
85128
|
+
var PROFILE_ID = "go", IMPORT_REGEX_SINGLE, IMPORT_REGEX_GROUP, IMPORT_REGEX_GROUP_LINE, _internals49;
|
|
84812
85129
|
var init_go = __esm(() => {
|
|
84813
85130
|
init_default_backend();
|
|
84814
85131
|
init_profiles();
|
|
84815
85132
|
IMPORT_REGEX_SINGLE = /^\s*import\s+(?:[a-zA-Z_.][a-zA-Z0-9_]*\s+)?"([^"]+)"/gm;
|
|
84816
85133
|
IMPORT_REGEX_GROUP = /^\s*import\s*\(([\s\S]*?)\)/gm;
|
|
84817
85134
|
IMPORT_REGEX_GROUP_LINE = /(?:[a-zA-Z_.][a-zA-Z0-9_]*\s+)?"([^"]+)"/g;
|
|
84818
|
-
|
|
85135
|
+
_internals49 = { extractImports };
|
|
84819
85136
|
});
|
|
84820
85137
|
|
|
84821
85138
|
// src/lang/backends/python.ts
|
|
@@ -84927,13 +85244,13 @@ function buildPythonBackend() {
|
|
|
84927
85244
|
selectEntryPoints: selectEntryPoints2
|
|
84928
85245
|
};
|
|
84929
85246
|
}
|
|
84930
|
-
var PROFILE_ID2 = "python", IMPORT_REGEX_FROM_WITH_TARGETS, IMPORT_REGEX_IMPORT,
|
|
85247
|
+
var PROFILE_ID2 = "python", IMPORT_REGEX_FROM_WITH_TARGETS, IMPORT_REGEX_IMPORT, _internals50;
|
|
84931
85248
|
var init_python = __esm(() => {
|
|
84932
85249
|
init_default_backend();
|
|
84933
85250
|
init_profiles();
|
|
84934
85251
|
IMPORT_REGEX_FROM_WITH_TARGETS = /^\s*from\s+(\.*[\w.]*)\s+import\s+(\([^)]*\)|[^\n#]+)/gm;
|
|
84935
85252
|
IMPORT_REGEX_IMPORT = /^\s*import\s+([^\n#]+)/gm;
|
|
84936
|
-
|
|
85253
|
+
_internals50 = { extractImports: extractImports2 };
|
|
84937
85254
|
});
|
|
84938
85255
|
|
|
84939
85256
|
// src/test-impact/analyzer.ts
|
|
@@ -85157,7 +85474,7 @@ function addImpactEdgesForTestFile(testFile, content, impactMap) {
|
|
|
85157
85474
|
return;
|
|
85158
85475
|
}
|
|
85159
85476
|
if (PYTHON_EXTENSIONS.has(ext)) {
|
|
85160
|
-
const modules =
|
|
85477
|
+
const modules = _internals50.extractImports(testFile, content);
|
|
85161
85478
|
for (const mod of modules) {
|
|
85162
85479
|
const resolved = resolvePythonImport(testDir, mod);
|
|
85163
85480
|
if (resolved !== null)
|
|
@@ -85166,7 +85483,7 @@ function addImpactEdgesForTestFile(testFile, content, impactMap) {
|
|
|
85166
85483
|
return;
|
|
85167
85484
|
}
|
|
85168
85485
|
if (GO_EXTENSIONS.has(ext)) {
|
|
85169
|
-
const imports =
|
|
85486
|
+
const imports = _internals49.extractImports(testFile, content);
|
|
85170
85487
|
for (const importPath of imports) {
|
|
85171
85488
|
const sourceFiles = resolveGoImport(testDir, importPath);
|
|
85172
85489
|
for (const source of sourceFiles)
|
|
@@ -85193,8 +85510,8 @@ async function buildImpactMapInternal(cwd) {
|
|
|
85193
85510
|
return impactMap;
|
|
85194
85511
|
}
|
|
85195
85512
|
async function buildImpactMap(cwd) {
|
|
85196
|
-
const impactMap = await
|
|
85197
|
-
await
|
|
85513
|
+
const impactMap = await _internals51.buildImpactMapInternal(cwd);
|
|
85514
|
+
await _internals51.saveImpactMap(cwd, impactMap);
|
|
85198
85515
|
return impactMap;
|
|
85199
85516
|
}
|
|
85200
85517
|
async function loadImpactMap(cwd, options) {
|
|
@@ -85208,7 +85525,7 @@ async function loadImpactMap(cwd, options) {
|
|
|
85208
85525
|
const hasValidValues = Object.values(map3).every((v) => Array.isArray(v) && v.every((item) => typeof item === "string"));
|
|
85209
85526
|
if (hasValidValues) {
|
|
85210
85527
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
85211
|
-
if (!
|
|
85528
|
+
if (!_internals51.isCacheStale(map3, generatedAt)) {
|
|
85212
85529
|
return map3;
|
|
85213
85530
|
}
|
|
85214
85531
|
if (options?.skipRebuild) {
|
|
@@ -85228,13 +85545,13 @@ async function loadImpactMap(cwd, options) {
|
|
|
85228
85545
|
if (options?.skipRebuild) {
|
|
85229
85546
|
return {};
|
|
85230
85547
|
}
|
|
85231
|
-
return
|
|
85548
|
+
return _internals51.buildImpactMap(cwd);
|
|
85232
85549
|
}
|
|
85233
85550
|
async function saveImpactMap(cwd, impactMap) {
|
|
85234
85551
|
if (!path74.isAbsolute(cwd)) {
|
|
85235
85552
|
throw new Error(`saveImpactMap requires an absolute project root path, got: "${cwd}"`);
|
|
85236
85553
|
}
|
|
85237
|
-
|
|
85554
|
+
_internals51.validateProjectRoot(cwd);
|
|
85238
85555
|
const cacheDir2 = path74.join(cwd, ".swarm", "cache");
|
|
85239
85556
|
const cachePath = path74.join(cacheDir2, "impact-map.json");
|
|
85240
85557
|
if (!fs34.existsSync(cacheDir2)) {
|
|
@@ -85258,7 +85575,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
|
|
|
85258
85575
|
};
|
|
85259
85576
|
}
|
|
85260
85577
|
const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
|
|
85261
|
-
const impactMap = await
|
|
85578
|
+
const impactMap = await _internals51.loadImpactMap(cwd);
|
|
85262
85579
|
const impactedTestsSet = new Set;
|
|
85263
85580
|
const untestedFiles = [];
|
|
85264
85581
|
let visitedCount = 0;
|
|
@@ -85343,7 +85660,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
|
|
|
85343
85660
|
budgetExceeded
|
|
85344
85661
|
};
|
|
85345
85662
|
}
|
|
85346
|
-
var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, TS_EXTENSIONS, PYTHON_EXTENSIONS, GO_EXTENSIONS, EXTENSIONS_TO_TRY, goModuleCache,
|
|
85663
|
+
var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, TS_EXTENSIONS, PYTHON_EXTENSIONS, GO_EXTENSIONS, EXTENSIONS_TO_TRY, goModuleCache, _internals51;
|
|
85347
85664
|
var init_analyzer = __esm(() => {
|
|
85348
85665
|
init_manager2();
|
|
85349
85666
|
init_go();
|
|
@@ -85356,7 +85673,7 @@ var init_analyzer = __esm(() => {
|
|
|
85356
85673
|
GO_EXTENSIONS = new Set([".go"]);
|
|
85357
85674
|
EXTENSIONS_TO_TRY = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
85358
85675
|
goModuleCache = new Map;
|
|
85359
|
-
|
|
85676
|
+
_internals51 = {
|
|
85360
85677
|
validateProjectRoot,
|
|
85361
85678
|
normalizePath,
|
|
85362
85679
|
isCacheStale,
|
|
@@ -85739,7 +86056,7 @@ function batchAppendTestRuns(records, workingDir) {
|
|
|
85739
86056
|
}
|
|
85740
86057
|
const historyPath = getHistoryPath(workingDir);
|
|
85741
86058
|
const historyDir = path75.dirname(historyPath);
|
|
85742
|
-
|
|
86059
|
+
_internals52.validateProjectRoot(workingDir);
|
|
85743
86060
|
if (!fs35.existsSync(historyDir)) {
|
|
85744
86061
|
fs35.mkdirSync(historyDir, { recursive: true });
|
|
85745
86062
|
}
|
|
@@ -85862,7 +86179,7 @@ function getAllHistory(workingDir) {
|
|
|
85862
86179
|
records.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
85863
86180
|
return records;
|
|
85864
86181
|
}
|
|
85865
|
-
var MAX_HISTORY_PER_TEST = 20, MAX_ERROR_LENGTH = 500, MAX_STACK_LENGTH = 200, MAX_CHANGED_FILES = 50, HISTORY_WRITE_LOCK_TIMEOUT_MS = 5000, HISTORY_WRITE_LOCK_STALE_MS = 60000, HISTORY_WRITE_LOCK_BACKOFF_MS = 10, DANGEROUS_PROPERTY_NAMES,
|
|
86182
|
+
var MAX_HISTORY_PER_TEST = 20, MAX_ERROR_LENGTH = 500, MAX_STACK_LENGTH = 200, MAX_CHANGED_FILES = 50, HISTORY_WRITE_LOCK_TIMEOUT_MS = 5000, HISTORY_WRITE_LOCK_STALE_MS = 60000, HISTORY_WRITE_LOCK_BACKOFF_MS = 10, DANGEROUS_PROPERTY_NAMES, _internals52;
|
|
85866
86183
|
var init_history_store = __esm(() => {
|
|
85867
86184
|
init_manager2();
|
|
85868
86185
|
DANGEROUS_PROPERTY_NAMES = new Set([
|
|
@@ -85870,7 +86187,7 @@ var init_history_store = __esm(() => {
|
|
|
85870
86187
|
"constructor",
|
|
85871
86188
|
"prototype"
|
|
85872
86189
|
]);
|
|
85873
|
-
|
|
86190
|
+
_internals52 = {
|
|
85874
86191
|
validateProjectRoot
|
|
85875
86192
|
};
|
|
85876
86193
|
});
|
|
@@ -86120,7 +86437,7 @@ function readPackageJsonRaw(dir) {
|
|
|
86120
86437
|
}
|
|
86121
86438
|
}
|
|
86122
86439
|
function readPackageJson(dir) {
|
|
86123
|
-
return
|
|
86440
|
+
return _internals53.readPackageJsonRaw(dir);
|
|
86124
86441
|
}
|
|
86125
86442
|
function readPackageJsonTestScript(dir) {
|
|
86126
86443
|
return readPackageJson(dir)?.scripts?.test ?? null;
|
|
@@ -86290,7 +86607,7 @@ function buildTypescriptBackend() {
|
|
|
86290
86607
|
selectEntryPoints: selectEntryPoints3
|
|
86291
86608
|
};
|
|
86292
86609
|
}
|
|
86293
|
-
var PROFILE_ID4 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2,
|
|
86610
|
+
var PROFILE_ID4 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2, _internals53;
|
|
86294
86611
|
var init_typescript = __esm(() => {
|
|
86295
86612
|
init_default_backend();
|
|
86296
86613
|
init_profiles();
|
|
@@ -86299,7 +86616,7 @@ var init_typescript = __esm(() => {
|
|
|
86299
86616
|
IMPORT_REGEX_REQUIRE2 = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
86300
86617
|
IMPORT_REGEX_DYNAMIC = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
86301
86618
|
IMPORT_REGEX_REEXPORT2 = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
|
|
86302
|
-
|
|
86619
|
+
_internals53 = {
|
|
86303
86620
|
readPackageJsonRaw,
|
|
86304
86621
|
readPackageJsonTestScript,
|
|
86305
86622
|
frameworkFromScriptsTest
|
|
@@ -86332,7 +86649,7 @@ __export(exports_dispatch, {
|
|
|
86332
86649
|
pickedProfiles: () => pickedProfiles,
|
|
86333
86650
|
pickBackend: () => pickBackend,
|
|
86334
86651
|
clearDispatchCache: () => clearDispatchCache,
|
|
86335
|
-
_internals: () =>
|
|
86652
|
+
_internals: () => _internals54
|
|
86336
86653
|
});
|
|
86337
86654
|
import * as fs39 from "node:fs";
|
|
86338
86655
|
import * as path79 from "node:path";
|
|
@@ -86387,7 +86704,7 @@ function findManifestRoot(start2) {
|
|
|
86387
86704
|
return start2;
|
|
86388
86705
|
}
|
|
86389
86706
|
function evictIfNeeded() {
|
|
86390
|
-
if (cache.size <=
|
|
86707
|
+
if (cache.size <= _internals54.cacheCapacity)
|
|
86391
86708
|
return;
|
|
86392
86709
|
let oldestKey;
|
|
86393
86710
|
let oldestOrder = Infinity;
|
|
@@ -86418,7 +86735,7 @@ async function pickBackend(dir) {
|
|
|
86418
86735
|
evictIfNeeded();
|
|
86419
86736
|
return null;
|
|
86420
86737
|
}
|
|
86421
|
-
const profiles = await
|
|
86738
|
+
const profiles = await _internals54.detectProjectLanguages(root);
|
|
86422
86739
|
if (profiles.length === 0) {
|
|
86423
86740
|
cache.set(cacheKey, {
|
|
86424
86741
|
hash: hash4,
|
|
@@ -86450,12 +86767,12 @@ function clearDispatchCache() {
|
|
|
86450
86767
|
manifestRootCache.clear();
|
|
86451
86768
|
insertCounter = 0;
|
|
86452
86769
|
}
|
|
86453
|
-
var
|
|
86770
|
+
var _internals54, cache, insertCounter = 0, MANIFEST_FILES, _MANIFEST_SET, manifestRootCache;
|
|
86454
86771
|
var init_dispatch = __esm(() => {
|
|
86455
86772
|
init_backends();
|
|
86456
86773
|
init_detector();
|
|
86457
86774
|
init_registry_backend();
|
|
86458
|
-
|
|
86775
|
+
_internals54 = {
|
|
86459
86776
|
detectProjectLanguages,
|
|
86460
86777
|
cacheCapacity: 64
|
|
86461
86778
|
};
|
|
@@ -88311,9 +88628,9 @@ function getVersionFileVersion(dir) {
|
|
|
88311
88628
|
async function runVersionCheck2(dir, _timeoutMs) {
|
|
88312
88629
|
const startTime = Date.now();
|
|
88313
88630
|
try {
|
|
88314
|
-
const packageVersion =
|
|
88315
|
-
const changelogVersion =
|
|
88316
|
-
const versionFileVersion =
|
|
88631
|
+
const packageVersion = _internals55.getPackageVersion(dir);
|
|
88632
|
+
const changelogVersion = _internals55.getChangelogVersion(dir);
|
|
88633
|
+
const versionFileVersion = _internals55.getVersionFileVersion(dir);
|
|
88317
88634
|
const versions3 = [];
|
|
88318
88635
|
if (packageVersion)
|
|
88319
88636
|
versions3.push(`package.json: ${packageVersion}`);
|
|
@@ -88677,7 +88994,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88677
88994
|
const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
88678
88995
|
let validatedDir;
|
|
88679
88996
|
try {
|
|
88680
|
-
validatedDir =
|
|
88997
|
+
validatedDir = _internals55.validateDirectoryPath(dir);
|
|
88681
88998
|
} catch (error93) {
|
|
88682
88999
|
return {
|
|
88683
89000
|
id: reportId,
|
|
@@ -88697,7 +89014,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88697
89014
|
}
|
|
88698
89015
|
let validatedTimeout;
|
|
88699
89016
|
try {
|
|
88700
|
-
validatedTimeout =
|
|
89017
|
+
validatedTimeout = _internals55.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
|
|
88701
89018
|
} catch (error93) {
|
|
88702
89019
|
return {
|
|
88703
89020
|
id: reportId,
|
|
@@ -88738,12 +89055,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88738
89055
|
});
|
|
88739
89056
|
const checks5 = [];
|
|
88740
89057
|
log("[Preflight] Running lint check...");
|
|
88741
|
-
const lintResult = await
|
|
89058
|
+
const lintResult = await _internals55.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
|
|
88742
89059
|
checks5.push(lintResult);
|
|
88743
89060
|
log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
|
|
88744
89061
|
if (!cfg.skipTests) {
|
|
88745
89062
|
log("[Preflight] Running tests check...");
|
|
88746
|
-
const testsResult = await
|
|
89063
|
+
const testsResult = await _internals55.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
|
|
88747
89064
|
checks5.push(testsResult);
|
|
88748
89065
|
log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
|
|
88749
89066
|
} else {
|
|
@@ -88755,7 +89072,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88755
89072
|
}
|
|
88756
89073
|
if (!cfg.skipSecrets) {
|
|
88757
89074
|
log("[Preflight] Running secrets check...");
|
|
88758
|
-
const secretsResult = await
|
|
89075
|
+
const secretsResult = await _internals55.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
|
|
88759
89076
|
checks5.push(secretsResult);
|
|
88760
89077
|
log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
|
|
88761
89078
|
} else {
|
|
@@ -88767,7 +89084,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88767
89084
|
}
|
|
88768
89085
|
if (!cfg.skipEvidence) {
|
|
88769
89086
|
log("[Preflight] Running evidence check...");
|
|
88770
|
-
const evidenceResult = await
|
|
89087
|
+
const evidenceResult = await _internals55.runEvidenceCheck(validatedDir);
|
|
88771
89088
|
checks5.push(evidenceResult);
|
|
88772
89089
|
log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
|
|
88773
89090
|
} else {
|
|
@@ -88778,12 +89095,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88778
89095
|
});
|
|
88779
89096
|
}
|
|
88780
89097
|
log("[Preflight] Running requirement coverage check...");
|
|
88781
|
-
const reqCoverageResult = await
|
|
89098
|
+
const reqCoverageResult = await _internals55.runRequirementCoverageCheck(validatedDir, phase);
|
|
88782
89099
|
checks5.push(reqCoverageResult);
|
|
88783
89100
|
log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
|
|
88784
89101
|
if (!cfg.skipVersion) {
|
|
88785
89102
|
log("[Preflight] Running version check...");
|
|
88786
|
-
const versionResult = await
|
|
89103
|
+
const versionResult = await _internals55.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
|
|
88787
89104
|
checks5.push(versionResult);
|
|
88788
89105
|
log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
|
|
88789
89106
|
} else {
|
|
@@ -88846,10 +89163,10 @@ function formatPreflightMarkdown(report) {
|
|
|
88846
89163
|
async function handlePreflightCommand(directory, _args) {
|
|
88847
89164
|
const plan = await loadPlan(directory);
|
|
88848
89165
|
const phase = plan?.current_phase ?? 1;
|
|
88849
|
-
const report = await
|
|
88850
|
-
return
|
|
89166
|
+
const report = await _internals55.runPreflight(directory, phase);
|
|
89167
|
+
return _internals55.formatPreflightMarkdown(report);
|
|
88851
89168
|
}
|
|
88852
|
-
var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG,
|
|
89169
|
+
var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals55;
|
|
88853
89170
|
var init_preflight_service = __esm(() => {
|
|
88854
89171
|
init_gate_bridge();
|
|
88855
89172
|
init_manager2();
|
|
@@ -88868,7 +89185,7 @@ var init_preflight_service = __esm(() => {
|
|
|
88868
89185
|
testScope: "convention",
|
|
88869
89186
|
linter: "biome"
|
|
88870
89187
|
};
|
|
88871
|
-
|
|
89188
|
+
_internals55 = {
|
|
88872
89189
|
runPreflight,
|
|
88873
89190
|
formatPreflightMarkdown,
|
|
88874
89191
|
handlePreflightCommand,
|
|
@@ -89909,7 +90226,7 @@ var init_reset_session = __esm(() => {
|
|
|
89909
90226
|
});
|
|
89910
90227
|
|
|
89911
90228
|
// src/summaries/manager.ts
|
|
89912
|
-
import { mkdirSync as mkdirSync22, readdirSync as readdirSync17, renameSync as
|
|
90229
|
+
import { mkdirSync as mkdirSync22, readdirSync as readdirSync17, renameSync as renameSync13, rmSync as rmSync5, statSync as statSync18 } from "node:fs";
|
|
89913
90230
|
import * as path84 from "node:path";
|
|
89914
90231
|
function sanitizeSummaryId(id) {
|
|
89915
90232
|
if (!id || id.length === 0) {
|
|
@@ -89959,7 +90276,7 @@ async function storeSummary(directory, id, fullOutput, summaryText, maxStoredByt
|
|
|
89959
90276
|
const tempPath = path84.join(summaryDir, `${sanitizedId}.json.tmp.${Date.now()}.${process.pid}`);
|
|
89960
90277
|
try {
|
|
89961
90278
|
await bunWrite(tempPath, entryJson);
|
|
89962
|
-
|
|
90279
|
+
renameSync13(tempPath, summaryPath);
|
|
89963
90280
|
} catch (error93) {
|
|
89964
90281
|
try {
|
|
89965
90282
|
rmSync5(tempPath, { force: true });
|
|
@@ -90351,7 +90668,7 @@ async function handleSimulateCommand(directory, args2) {
|
|
|
90351
90668
|
}
|
|
90352
90669
|
let darkMatterPairs;
|
|
90353
90670
|
try {
|
|
90354
|
-
darkMatterPairs = await
|
|
90671
|
+
darkMatterPairs = await _internals35.detectDarkMatter(directory, options);
|
|
90355
90672
|
} catch (err2) {
|
|
90356
90673
|
const errMsg = err2 instanceof Error ? err2.message : String(err2);
|
|
90357
90674
|
return `## Simulate Report
|
|
@@ -90936,7 +91253,7 @@ async function getStatusData(directory, agents) {
|
|
|
90936
91253
|
}
|
|
90937
91254
|
function enrichWithLeanTurbo(status, directory) {
|
|
90938
91255
|
const turboMode = hasActiveTurboMode();
|
|
90939
|
-
const leanActive =
|
|
91256
|
+
const leanActive = _internals56.hasActiveLeanTurbo();
|
|
90940
91257
|
let turboStrategy = "off";
|
|
90941
91258
|
if (leanActive) {
|
|
90942
91259
|
turboStrategy = "lean";
|
|
@@ -90955,7 +91272,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
90955
91272
|
}
|
|
90956
91273
|
}
|
|
90957
91274
|
if (leanSessionID) {
|
|
90958
|
-
const runState =
|
|
91275
|
+
const runState = _internals56.loadLeanTurboRunState(directory, leanSessionID);
|
|
90959
91276
|
if (runState) {
|
|
90960
91277
|
status.leanTurboPhase = runState.phase;
|
|
90961
91278
|
status.leanMaxParallelCoders = runState.maxParallelCoders;
|
|
@@ -90987,7 +91304,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
90987
91304
|
}
|
|
90988
91305
|
}
|
|
90989
91306
|
}
|
|
90990
|
-
status.fullAutoActive =
|
|
91307
|
+
status.fullAutoActive = _internals56.hasActiveFullAuto();
|
|
90991
91308
|
return status;
|
|
90992
91309
|
}
|
|
90993
91310
|
function formatStatusMarkdown(status) {
|
|
@@ -91115,7 +91432,7 @@ async function countProposals(directory) {
|
|
|
91115
91432
|
return 0;
|
|
91116
91433
|
}
|
|
91117
91434
|
}
|
|
91118
|
-
var
|
|
91435
|
+
var _internals56;
|
|
91119
91436
|
var init_status_service = __esm(() => {
|
|
91120
91437
|
init_extractors();
|
|
91121
91438
|
init_knowledge_escalator();
|
|
@@ -91125,7 +91442,7 @@ var init_status_service = __esm(() => {
|
|
|
91125
91442
|
init_state3();
|
|
91126
91443
|
init_compaction_service();
|
|
91127
91444
|
init_context_budget_service();
|
|
91128
|
-
|
|
91445
|
+
_internals56 = {
|
|
91129
91446
|
loadLeanTurboRunState,
|
|
91130
91447
|
hasActiveLeanTurbo,
|
|
91131
91448
|
hasActiveFullAuto
|
|
@@ -91216,7 +91533,7 @@ async function handleTurboCommand(directory, args2, sessionID) {
|
|
|
91216
91533
|
if (arg0 === "on") {
|
|
91217
91534
|
let strategy = "standard";
|
|
91218
91535
|
try {
|
|
91219
|
-
const { config: config3 } =
|
|
91536
|
+
const { config: config3 } = _internals57.loadPluginConfigWithMeta(directory);
|
|
91220
91537
|
if (config3.turbo?.strategy === "lean") {
|
|
91221
91538
|
strategy = "lean";
|
|
91222
91539
|
}
|
|
@@ -91271,7 +91588,7 @@ function enableLeanTurbo(session, directory, sessionID) {
|
|
|
91271
91588
|
let maxParallelCoders = 4;
|
|
91272
91589
|
let conflictPolicy = "serialize";
|
|
91273
91590
|
try {
|
|
91274
|
-
const { config: config3 } =
|
|
91591
|
+
const { config: config3 } = _internals57.loadPluginConfigWithMeta(directory);
|
|
91275
91592
|
const leanConfig = config3.turbo?.lean;
|
|
91276
91593
|
if (leanConfig) {
|
|
91277
91594
|
maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
|
|
@@ -91341,13 +91658,13 @@ function buildStatusMessage2(session, directory, sessionID) {
|
|
|
91341
91658
|
].join(`
|
|
91342
91659
|
`);
|
|
91343
91660
|
}
|
|
91344
|
-
var
|
|
91661
|
+
var _internals57;
|
|
91345
91662
|
var init_turbo = __esm(() => {
|
|
91346
91663
|
init_config();
|
|
91347
91664
|
init_state();
|
|
91348
91665
|
init_state3();
|
|
91349
91666
|
init_logger();
|
|
91350
|
-
|
|
91667
|
+
_internals57 = {
|
|
91351
91668
|
loadPluginConfigWithMeta
|
|
91352
91669
|
};
|
|
91353
91670
|
});
|
|
@@ -91413,342 +91730,6 @@ var init_write_retro2 = __esm(() => {
|
|
|
91413
91730
|
init_write_retro();
|
|
91414
91731
|
});
|
|
91415
91732
|
|
|
91416
|
-
// src/commands/command-dispatch.ts
|
|
91417
|
-
function normalizeSwarmCommandInput(command, argumentText) {
|
|
91418
|
-
if (command !== "swarm" && !command.startsWith("swarm-")) {
|
|
91419
|
-
return { isSwarmCommand: false, tokens: [] };
|
|
91420
|
-
}
|
|
91421
|
-
if (command === "swarm") {
|
|
91422
|
-
return {
|
|
91423
|
-
isSwarmCommand: true,
|
|
91424
|
-
tokens: argumentText.trim().split(/\s+/).filter(Boolean)
|
|
91425
|
-
};
|
|
91426
|
-
}
|
|
91427
|
-
const subcommand = command.slice("swarm-".length);
|
|
91428
|
-
const extraArgs = argumentText.trim().split(/\s+/).filter(Boolean);
|
|
91429
|
-
return {
|
|
91430
|
-
isSwarmCommand: true,
|
|
91431
|
-
tokens: [subcommand, ...extraArgs].filter(Boolean)
|
|
91432
|
-
};
|
|
91433
|
-
}
|
|
91434
|
-
function canonicalCommandKey(resolved) {
|
|
91435
|
-
return resolved.entry.aliasOf ?? resolved.key;
|
|
91436
|
-
}
|
|
91437
|
-
function formatCommandNotFound(tokens) {
|
|
91438
|
-
const attemptedCommand = tokens[0] || "";
|
|
91439
|
-
const MAX_DISPLAY = 100;
|
|
91440
|
-
const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
|
|
91441
|
-
const similar = _internals57.findSimilarCommands(attemptedCommand);
|
|
91442
|
-
const header = `Command \`/swarm ${displayCommand}\` not found.`;
|
|
91443
|
-
const suggestions = similar.length > 0 ? `Did you mean:
|
|
91444
|
-
${similar.map((cmd) => ` - /swarm ${cmd}`).join(`
|
|
91445
|
-
`)}` : "";
|
|
91446
|
-
const footer = "Run `/swarm help` for all commands.";
|
|
91447
|
-
return [header, suggestions, footer].filter(Boolean).join(`
|
|
91448
|
-
|
|
91449
|
-
`);
|
|
91450
|
-
}
|
|
91451
|
-
async function executeSwarmCommand(args2) {
|
|
91452
|
-
const {
|
|
91453
|
-
directory,
|
|
91454
|
-
agents,
|
|
91455
|
-
sessionID,
|
|
91456
|
-
tokens,
|
|
91457
|
-
packageRoot,
|
|
91458
|
-
buildHelpText,
|
|
91459
|
-
policy
|
|
91460
|
-
} = args2;
|
|
91461
|
-
let text;
|
|
91462
|
-
const resolved = resolveCommand(tokens);
|
|
91463
|
-
if (!resolved) {
|
|
91464
|
-
text = tokens.length === 0 && buildHelpText ? buildHelpText() : formatCommandNotFound(tokens);
|
|
91465
|
-
} else {
|
|
91466
|
-
const policyResult = policy?.(resolved) ?? { allowed: true };
|
|
91467
|
-
if (!policyResult.allowed) {
|
|
91468
|
-
text = policyResult.message;
|
|
91469
|
-
} else {
|
|
91470
|
-
try {
|
|
91471
|
-
text = await resolved.entry.handler({
|
|
91472
|
-
directory,
|
|
91473
|
-
args: resolved.remainingArgs,
|
|
91474
|
-
sessionID,
|
|
91475
|
-
agents,
|
|
91476
|
-
packageRoot,
|
|
91477
|
-
source: "chat"
|
|
91478
|
-
});
|
|
91479
|
-
} catch (_err) {
|
|
91480
|
-
const cmdName = tokens[0] || "unknown";
|
|
91481
|
-
const errMsg = _err instanceof Error ? _err.message : String(_err);
|
|
91482
|
-
text = `Error executing /swarm ${cmdName}: ${errMsg}`;
|
|
91483
|
-
}
|
|
91484
|
-
if (resolved.warning) {
|
|
91485
|
-
text = `${resolved.warning}
|
|
91486
|
-
|
|
91487
|
-
${text}`;
|
|
91488
|
-
}
|
|
91489
|
-
}
|
|
91490
|
-
}
|
|
91491
|
-
return {
|
|
91492
|
-
text,
|
|
91493
|
-
resolved: resolved ?? undefined,
|
|
91494
|
-
canonicalKey: resolved ? canonicalCommandKey(resolved) : undefined
|
|
91495
|
-
};
|
|
91496
|
-
}
|
|
91497
|
-
var init_command_dispatch = __esm(() => {
|
|
91498
|
-
init_registry();
|
|
91499
|
-
});
|
|
91500
|
-
|
|
91501
|
-
// src/commands/tool-policy.ts
|
|
91502
|
-
function classifySwarmCommandToolUse(resolved) {
|
|
91503
|
-
const canonicalKey = canonicalCommandKey(resolved);
|
|
91504
|
-
const args2 = resolved.remainingArgs;
|
|
91505
|
-
if (!SWARM_COMMAND_TOOL_ALLOWLIST.has(canonicalKey)) {
|
|
91506
|
-
if (HUMAN_ONLY_SWARM_COMMANDS.has(canonicalKey)) {
|
|
91507
|
-
return {
|
|
91508
|
-
allowed: false,
|
|
91509
|
-
message: `/swarm ${canonicalKey} is a human-only command. ` + `Present the situation to the user and ask them to run \`/swarm ${canonicalKey}\` themselves ` + `(or \`bunx opencode-swarm run ${canonicalKey}\` from a terminal). ` + `You MUST NOT run it yourself via Bash, swarm_command, or any other tool — ` + `the runtime guardrail will block such attempts.`
|
|
91510
|
-
};
|
|
91511
|
-
}
|
|
91512
|
-
return {
|
|
91513
|
-
allowed: false,
|
|
91514
|
-
message: `/swarm ${canonicalKey} is not available through the chat tool yet.
|
|
91515
|
-
|
|
91516
|
-
` + `Use the canonical CLI path for now: \`bunx opencode-swarm run ${canonicalKey}\`.
|
|
91517
|
-
` + `Commands with state changes, auto-heal behavior, or subprocesses need confirmation gates before chat-tool support.`
|
|
91518
|
-
};
|
|
91519
|
-
}
|
|
91520
|
-
if (canonicalKey === "config doctor" && args2.some((arg) => arg === "--fix" || arg === "-f")) {
|
|
91521
|
-
return {
|
|
91522
|
-
allowed: false,
|
|
91523
|
-
message: "/swarm config doctor --fix is not available through swarm_command. Run the CLI command directly when you intend to modify config files."
|
|
91524
|
-
};
|
|
91525
|
-
}
|
|
91526
|
-
if (NO_ARGS.has(canonicalKey) && args2.length > 0) {
|
|
91527
|
-
return {
|
|
91528
|
-
allowed: false,
|
|
91529
|
-
message: `/swarm ${canonicalKey} does not accept arguments through swarm_command.`
|
|
91530
|
-
};
|
|
91531
|
-
}
|
|
91532
|
-
if (canonicalKey === "knowledge") {
|
|
91533
|
-
if (args2.length === 0)
|
|
91534
|
-
return { allowed: true };
|
|
91535
|
-
if (args2.length === 1 && (args2[0] === "list" || args2[0] === "unactionable"))
|
|
91536
|
-
return { allowed: true };
|
|
91537
|
-
return {
|
|
91538
|
-
allowed: false,
|
|
91539
|
-
message: "Only `/swarm knowledge`, `/swarm knowledge list`, and `/swarm knowledge unactionable` are available through swarm_command. Knowledge migrate/quarantine/restore/retry-hardening are intentionally excluded."
|
|
91540
|
-
};
|
|
91541
|
-
}
|
|
91542
|
-
if (canonicalKey === "memory") {
|
|
91543
|
-
if (args2.length === 0)
|
|
91544
|
-
return { allowed: true };
|
|
91545
|
-
return {
|
|
91546
|
-
allowed: false,
|
|
91547
|
-
message: "Use `/swarm memory status`, `/swarm memory pending`, `/swarm memory recall-log`, `/swarm memory stale`, `/swarm memory export`, or `/swarm memory evaluate --json` through swarm_command. Memory import, migrate, and compact are intentionally excluded from chat-tool execution."
|
|
91548
|
-
};
|
|
91549
|
-
}
|
|
91550
|
-
if (canonicalKey === "memory evaluate") {
|
|
91551
|
-
if (args2.length === 0)
|
|
91552
|
-
return { allowed: true };
|
|
91553
|
-
if (args2.length === 1 && args2[0] === "--json")
|
|
91554
|
-
return { allowed: true };
|
|
91555
|
-
return {
|
|
91556
|
-
allowed: false,
|
|
91557
|
-
message: "Usage through swarm_command: `/swarm memory evaluate --json`. Custom fixture directories are only available through direct user command execution."
|
|
91558
|
-
};
|
|
91559
|
-
}
|
|
91560
|
-
if (canonicalKey === "sdd status") {
|
|
91561
|
-
if (args2.length === 0)
|
|
91562
|
-
return { allowed: true };
|
|
91563
|
-
if (args2.length === 1 && args2[0] === "--json")
|
|
91564
|
-
return { allowed: true };
|
|
91565
|
-
return {
|
|
91566
|
-
allowed: false,
|
|
91567
|
-
message: "Usage through swarm_command: `/swarm sdd status` or `/swarm sdd status --json`."
|
|
91568
|
-
};
|
|
91569
|
-
}
|
|
91570
|
-
if (canonicalKey === "sdd validate") {
|
|
91571
|
-
if (args2.length === 0)
|
|
91572
|
-
return { allowed: true };
|
|
91573
|
-
if (args2.length === 1 && args2[0] === "--json")
|
|
91574
|
-
return { allowed: true };
|
|
91575
|
-
if (args2.length === 2 && args2[0] === "--change" && /^[A-Za-z0-9_.-]{1,128}$/.test(args2[1])) {
|
|
91576
|
-
return { allowed: true };
|
|
91577
|
-
}
|
|
91578
|
-
return {
|
|
91579
|
-
allowed: false,
|
|
91580
|
-
message: "Usage through swarm_command: `/swarm sdd validate`, `/swarm sdd validate --json`, or `/swarm sdd validate --change <id>`."
|
|
91581
|
-
};
|
|
91582
|
-
}
|
|
91583
|
-
if (canonicalKey === "memory pending" || canonicalKey === "memory recall-log" || canonicalKey === "memory stale") {
|
|
91584
|
-
if (args2.length === 0)
|
|
91585
|
-
return { allowed: true };
|
|
91586
|
-
if (args2.length === 2 && args2[0] === "--limit" && /^\d+$/.test(args2[1])) {
|
|
91587
|
-
return { allowed: true };
|
|
91588
|
-
}
|
|
91589
|
-
return {
|
|
91590
|
-
allowed: false,
|
|
91591
|
-
message: `Usage through swarm_command: \`/swarm ${canonicalKey}\` or ` + `\`/swarm ${canonicalKey} --limit <n>\`.`
|
|
91592
|
-
};
|
|
91593
|
-
}
|
|
91594
|
-
if (canonicalKey === "retrieve") {
|
|
91595
|
-
if (args2.length !== 1 || !SUMMARY_ID_PATTERN.test(args2[0])) {
|
|
91596
|
-
return {
|
|
91597
|
-
allowed: false,
|
|
91598
|
-
message: "Usage through swarm_command: `/swarm retrieve <summary-id>` with a single summary ID such as S1."
|
|
91599
|
-
};
|
|
91600
|
-
}
|
|
91601
|
-
}
|
|
91602
|
-
if (canonicalKey === "benchmark") {
|
|
91603
|
-
const allowedFlags = new Set(["--cumulative", "--ci-gate"]);
|
|
91604
|
-
const invalid = args2.filter((arg) => !allowedFlags.has(arg));
|
|
91605
|
-
if (invalid.length > 0) {
|
|
91606
|
-
return {
|
|
91607
|
-
allowed: false,
|
|
91608
|
-
message: "Only `--cumulative` and `--ci-gate` are supported for `/swarm benchmark` through swarm_command."
|
|
91609
|
-
};
|
|
91610
|
-
}
|
|
91611
|
-
}
|
|
91612
|
-
if (canonicalKey === "show-plan") {
|
|
91613
|
-
if (args2.length > 1 || args2[0] && !/^\d+$/.test(args2[0])) {
|
|
91614
|
-
return {
|
|
91615
|
-
allowed: false,
|
|
91616
|
-
message: "Usage through swarm_command: `/swarm show-plan` or `/swarm show-plan <phase-number>`."
|
|
91617
|
-
};
|
|
91618
|
-
}
|
|
91619
|
-
}
|
|
91620
|
-
if (canonicalKey === "evidence") {
|
|
91621
|
-
if (args2.length > 1 || args2[0] && !TASK_ID_PATTERN.test(args2[0])) {
|
|
91622
|
-
return {
|
|
91623
|
-
allowed: false,
|
|
91624
|
-
message: "Usage through swarm_command: `/swarm evidence` or `/swarm evidence <task-id>`."
|
|
91625
|
-
};
|
|
91626
|
-
}
|
|
91627
|
-
}
|
|
91628
|
-
if (canonicalKey === "help" && args2.length > 2) {
|
|
91629
|
-
return {
|
|
91630
|
-
allowed: false,
|
|
91631
|
-
message: "Usage through swarm_command: `/swarm help` or `/swarm help <command>`."
|
|
91632
|
-
};
|
|
91633
|
-
}
|
|
91634
|
-
return { allowed: true };
|
|
91635
|
-
}
|
|
91636
|
-
function classifySwarmCommandChatFallbackUse(resolved) {
|
|
91637
|
-
const canonicalKey = canonicalCommandKey(resolved);
|
|
91638
|
-
const args2 = resolved.remainingArgs;
|
|
91639
|
-
if (canonicalKey === "config doctor" && args2.some((arg) => arg === "--fix" || arg === "-f")) {
|
|
91640
|
-
return {
|
|
91641
|
-
allowed: false,
|
|
91642
|
-
message: "/swarm config doctor --fix is not available through chat fallback because it can modify configuration files. Run the CLI command directly when you intend to apply fixes."
|
|
91643
|
-
};
|
|
91644
|
-
}
|
|
91645
|
-
if (canonicalKey === "knowledge migrate" || canonicalKey === "knowledge quarantine" || canonicalKey === "knowledge restore" || canonicalKey === "memory import" || canonicalKey === "memory migrate" || canonicalKey === "memory compact" || canonicalKey === "sdd project") {
|
|
91646
|
-
return {
|
|
91647
|
-
allowed: false,
|
|
91648
|
-
message: `/swarm ${canonicalKey} is not available through chat fallback because it mutates .swarm state. ` + "Run the CLI command directly after confirming the intended state change."
|
|
91649
|
-
};
|
|
91650
|
-
}
|
|
91651
|
-
return { allowed: true };
|
|
91652
|
-
}
|
|
91653
|
-
var SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, NO_ARGS, SUMMARY_ID_PATTERN, TASK_ID_PATTERN;
|
|
91654
|
-
var init_tool_policy = __esm(() => {
|
|
91655
|
-
init_command_dispatch();
|
|
91656
|
-
SWARM_COMMAND_TOOL_COMMANDS = [
|
|
91657
|
-
"agents",
|
|
91658
|
-
"config",
|
|
91659
|
-
"config doctor",
|
|
91660
|
-
"doctor tools",
|
|
91661
|
-
"status",
|
|
91662
|
-
"show-plan",
|
|
91663
|
-
"help",
|
|
91664
|
-
"history",
|
|
91665
|
-
"evidence",
|
|
91666
|
-
"evidence summary",
|
|
91667
|
-
"retrieve",
|
|
91668
|
-
"diagnose",
|
|
91669
|
-
"preflight",
|
|
91670
|
-
"benchmark",
|
|
91671
|
-
"knowledge",
|
|
91672
|
-
"memory",
|
|
91673
|
-
"memory status",
|
|
91674
|
-
"memory pending",
|
|
91675
|
-
"memory recall-log",
|
|
91676
|
-
"memory compact",
|
|
91677
|
-
"memory stale",
|
|
91678
|
-
"memory export",
|
|
91679
|
-
"memory evaluate",
|
|
91680
|
-
"memory import",
|
|
91681
|
-
"memory migrate",
|
|
91682
|
-
"sdd",
|
|
91683
|
-
"sdd status",
|
|
91684
|
-
"sdd validate",
|
|
91685
|
-
"sdd project",
|
|
91686
|
-
"sync-plan",
|
|
91687
|
-
"export",
|
|
91688
|
-
"auto-proceed"
|
|
91689
|
-
];
|
|
91690
|
-
SWARM_COMMAND_TOOL_ALLOWLIST = new Set([
|
|
91691
|
-
"agents",
|
|
91692
|
-
"config",
|
|
91693
|
-
"config doctor",
|
|
91694
|
-
"doctor tools",
|
|
91695
|
-
"status",
|
|
91696
|
-
"show-plan",
|
|
91697
|
-
"help",
|
|
91698
|
-
"history",
|
|
91699
|
-
"evidence",
|
|
91700
|
-
"evidence summary",
|
|
91701
|
-
"retrieve",
|
|
91702
|
-
"diagnose",
|
|
91703
|
-
"preflight",
|
|
91704
|
-
"benchmark",
|
|
91705
|
-
"knowledge",
|
|
91706
|
-
"memory",
|
|
91707
|
-
"memory status",
|
|
91708
|
-
"memory pending",
|
|
91709
|
-
"memory recall-log",
|
|
91710
|
-
"memory stale",
|
|
91711
|
-
"memory export",
|
|
91712
|
-
"memory evaluate",
|
|
91713
|
-
"sdd",
|
|
91714
|
-
"sdd status",
|
|
91715
|
-
"sdd validate",
|
|
91716
|
-
"sync-plan",
|
|
91717
|
-
"export",
|
|
91718
|
-
"auto-proceed"
|
|
91719
|
-
]);
|
|
91720
|
-
HUMAN_ONLY_SWARM_COMMANDS = new Set([
|
|
91721
|
-
"acknowledge-spec-drift",
|
|
91722
|
-
"reset",
|
|
91723
|
-
"reset-session",
|
|
91724
|
-
"rollback",
|
|
91725
|
-
"checkpoint",
|
|
91726
|
-
"consolidate",
|
|
91727
|
-
"memory import",
|
|
91728
|
-
"memory migrate",
|
|
91729
|
-
"memory compact",
|
|
91730
|
-
"sdd project"
|
|
91731
|
-
]);
|
|
91732
|
-
NO_ARGS = new Set([
|
|
91733
|
-
"agents",
|
|
91734
|
-
"config",
|
|
91735
|
-
"config doctor",
|
|
91736
|
-
"doctor tools",
|
|
91737
|
-
"status",
|
|
91738
|
-
"history",
|
|
91739
|
-
"evidence summary",
|
|
91740
|
-
"diagnose",
|
|
91741
|
-
"preflight",
|
|
91742
|
-
"sync-plan",
|
|
91743
|
-
"export",
|
|
91744
|
-
"memory",
|
|
91745
|
-
"memory status",
|
|
91746
|
-
"memory export"
|
|
91747
|
-
]);
|
|
91748
|
-
SUMMARY_ID_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
|
|
91749
|
-
TASK_ID_PATTERN = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
91750
|
-
});
|
|
91751
|
-
|
|
91752
91733
|
// src/commands/command-names.ts
|
|
91753
91734
|
var COMMAND_NAMES, COMMAND_NAME_SET;
|
|
91754
91735
|
var init_command_names = __esm(() => {
|
|
@@ -91966,7 +91947,7 @@ async function buildSwarmCommandPrompt(args2) {
|
|
|
91966
91947
|
packageRoot,
|
|
91967
91948
|
registeredAgents
|
|
91968
91949
|
} = args2;
|
|
91969
|
-
const resolved =
|
|
91950
|
+
const resolved = _internals13.resolveCommand(tokens);
|
|
91970
91951
|
if (!resolved) {
|
|
91971
91952
|
if (tokens.length === 0) {
|
|
91972
91953
|
return buildHelpText();
|
|
@@ -92139,7 +92120,7 @@ function findSimilarCommands(query) {
|
|
|
92139
92120
|
}
|
|
92140
92121
|
const scored = VALID_COMMANDS.map((cmd) => {
|
|
92141
92122
|
const cmdLower = cmd.toLowerCase();
|
|
92142
|
-
const fullScore =
|
|
92123
|
+
const fullScore = _internals13.levenshteinDistance(q, cmdLower);
|
|
92143
92124
|
let tokenScore = Infinity;
|
|
92144
92125
|
if (cmd.includes(" ") || cmd.includes("-")) {
|
|
92145
92126
|
const qTokens = q.split(/[\s-]+/);
|
|
@@ -92152,7 +92133,7 @@ function findSimilarCommands(query) {
|
|
|
92152
92133
|
for (const ct of cmdTokens) {
|
|
92153
92134
|
if (ct.length === 0)
|
|
92154
92135
|
continue;
|
|
92155
|
-
const dist =
|
|
92136
|
+
const dist = _internals13.levenshteinDistance(qt, ct);
|
|
92156
92137
|
if (dist < minDist)
|
|
92157
92138
|
minDist = dist;
|
|
92158
92139
|
}
|
|
@@ -92162,7 +92143,7 @@ function findSimilarCommands(query) {
|
|
|
92162
92143
|
}
|
|
92163
92144
|
const dashStrippedQ = q.replace(/-/g, "");
|
|
92164
92145
|
const dashStrippedCmd = cmdLower.replace(/-/g, "");
|
|
92165
|
-
const dashScore =
|
|
92146
|
+
const dashScore = _internals13.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
|
|
92166
92147
|
const score = Math.min(fullScore, tokenScore, dashScore);
|
|
92167
92148
|
return { cmd, score };
|
|
92168
92149
|
});
|
|
@@ -92194,11 +92175,11 @@ async function handleHelpCommand(ctx) {
|
|
|
92194
92175
|
return buildHelpText2();
|
|
92195
92176
|
}
|
|
92196
92177
|
const tokens = targetCommand.split(/\s+/);
|
|
92197
|
-
const resolved =
|
|
92178
|
+
const resolved = _internals13.resolveCommand(tokens);
|
|
92198
92179
|
if (resolved) {
|
|
92199
|
-
return
|
|
92180
|
+
return _internals13.buildDetailedHelp(resolved.key, resolved.entry);
|
|
92200
92181
|
}
|
|
92201
|
-
const similar =
|
|
92182
|
+
const similar = _internals13.findSimilarCommands(targetCommand);
|
|
92202
92183
|
const { buildHelpText: fullHelp } = await Promise.resolve().then(() => (init_commands(), exports_commands));
|
|
92203
92184
|
if (similar.length > 0) {
|
|
92204
92185
|
return `Command '/swarm ${targetCommand}' not found.
|
|
@@ -92269,6 +92250,18 @@ function validateAliases() {
|
|
|
92269
92250
|
}
|
|
92270
92251
|
return { valid: errors5.length === 0, errors: errors5, warnings };
|
|
92271
92252
|
}
|
|
92253
|
+
function validateToolPolicy() {
|
|
92254
|
+
const warnings = [];
|
|
92255
|
+
for (const [name2, entry] of Object.entries(COMMAND_REGISTRY)) {
|
|
92256
|
+
const cmdEntry = entry;
|
|
92257
|
+
if (cmdEntry.aliasOf || cmdEntry.subcommandOf)
|
|
92258
|
+
continue;
|
|
92259
|
+
if (cmdEntry.toolPolicy === undefined) {
|
|
92260
|
+
warnings.push(`Command '${name2}' has no toolPolicy field — it will not be available through the swarm_command tool. Add toolPolicy: 'agent' | 'human-only' | 'restricted' | 'none'.`);
|
|
92261
|
+
}
|
|
92262
|
+
}
|
|
92263
|
+
return { valid: warnings.length === 0, warnings };
|
|
92264
|
+
}
|
|
92272
92265
|
function resolveCommand(tokens) {
|
|
92273
92266
|
if (tokens.length === 0)
|
|
92274
92267
|
return null;
|
|
@@ -92298,7 +92291,7 @@ function resolveCommand(tokens) {
|
|
|
92298
92291
|
}
|
|
92299
92292
|
return null;
|
|
92300
92293
|
}
|
|
92301
|
-
var COMMAND_REGISTRY, VALID_COMMANDS,
|
|
92294
|
+
var COMMAND_REGISTRY, VALID_COMMANDS, _internals13, validation;
|
|
92302
92295
|
var init_registry = __esm(() => {
|
|
92303
92296
|
init_bundled_skills();
|
|
92304
92297
|
init_acknowledge_spec_drift();
|
|
@@ -92354,19 +92347,23 @@ var init_registry = __esm(() => {
|
|
|
92354
92347
|
handler: (ctx) => handleAcknowledgeSpecDriftCommand(ctx.directory, ctx.args, ctx.source === "cli" ? "cli" : ctx.source === "chat" ? "user" : "unknown"),
|
|
92355
92348
|
description: "Acknowledge that the spec has drifted from the plan and suppress further warnings",
|
|
92356
92349
|
args: "",
|
|
92357
|
-
category: "diagnostics"
|
|
92350
|
+
category: "diagnostics",
|
|
92351
|
+
toolPolicy: "restricted"
|
|
92358
92352
|
},
|
|
92359
92353
|
status: {
|
|
92360
92354
|
handler: (ctx) => handleStatusCommand(ctx.directory, ctx.agents),
|
|
92361
92355
|
description: "Show current swarm state",
|
|
92362
92356
|
category: "core",
|
|
92363
|
-
clashesWithNativeCcCommand: "/status"
|
|
92357
|
+
clashesWithNativeCcCommand: "/status",
|
|
92358
|
+
toolPolicy: "agent",
|
|
92359
|
+
toolNoArgs: true
|
|
92364
92360
|
},
|
|
92365
92361
|
"show-plan": {
|
|
92366
92362
|
handler: (ctx) => handlePlanCommand(ctx.directory, ctx.args),
|
|
92367
92363
|
description: "Show current plan (optionally filter by phase number)",
|
|
92368
92364
|
category: "core",
|
|
92369
|
-
args: "[phase-number]"
|
|
92365
|
+
args: "[phase-number]",
|
|
92366
|
+
toolPolicy: "agent"
|
|
92370
92367
|
},
|
|
92371
92368
|
plan: {
|
|
92372
92369
|
handler: (ctx) => handlePlanCommand(ctx.directory, ctx.args),
|
|
@@ -92380,32 +92377,41 @@ var init_registry = __esm(() => {
|
|
|
92380
92377
|
handler: (ctx) => Promise.resolve(handleAgentsCommand(ctx.agents, undefined)),
|
|
92381
92378
|
description: "List registered agents",
|
|
92382
92379
|
category: "core",
|
|
92383
|
-
clashesWithNativeCcCommand: "/agents"
|
|
92380
|
+
clashesWithNativeCcCommand: "/agents",
|
|
92381
|
+
toolPolicy: "agent",
|
|
92382
|
+
toolNoArgs: true
|
|
92384
92383
|
},
|
|
92385
92384
|
help: {
|
|
92386
|
-
handler: (ctx) =>
|
|
92385
|
+
handler: (ctx) => _internals13.handleHelpCommand(ctx),
|
|
92387
92386
|
description: "Show help for swarm commands",
|
|
92388
92387
|
category: "core",
|
|
92389
92388
|
args: "[command]",
|
|
92390
|
-
details: "Without argument, shows full command listing. With argument, shows detailed help for a specific command."
|
|
92389
|
+
details: "Without argument, shows full command listing. With argument, shows detailed help for a specific command.",
|
|
92390
|
+
toolPolicy: "agent"
|
|
92391
92391
|
},
|
|
92392
92392
|
history: {
|
|
92393
92393
|
handler: (ctx) => handleHistoryCommand(ctx.directory, ctx.args),
|
|
92394
92394
|
description: "Show completed phases summary",
|
|
92395
92395
|
category: "utility",
|
|
92396
|
-
clashesWithNativeCcCommand: "/history"
|
|
92396
|
+
clashesWithNativeCcCommand: "/history",
|
|
92397
|
+
toolPolicy: "agent",
|
|
92398
|
+
toolNoArgs: true
|
|
92397
92399
|
},
|
|
92398
92400
|
config: {
|
|
92399
92401
|
handler: (ctx) => handleConfigCommand(ctx.directory, ctx.args),
|
|
92400
92402
|
description: "Show current resolved configuration",
|
|
92401
92403
|
category: "config",
|
|
92402
|
-
clashesWithNativeCcCommand: "/config"
|
|
92404
|
+
clashesWithNativeCcCommand: "/config",
|
|
92405
|
+
toolPolicy: "agent",
|
|
92406
|
+
toolNoArgs: true
|
|
92403
92407
|
},
|
|
92404
92408
|
"config doctor": {
|
|
92405
92409
|
handler: (ctx) => handleDoctorCommand(ctx.directory, ctx.args),
|
|
92406
92410
|
description: "Run config doctor checks",
|
|
92407
92411
|
subcommandOf: "config",
|
|
92408
|
-
category: "diagnostics"
|
|
92412
|
+
category: "diagnostics",
|
|
92413
|
+
toolPolicy: "agent",
|
|
92414
|
+
toolNoArgs: true
|
|
92409
92415
|
},
|
|
92410
92416
|
"config-doctor": {
|
|
92411
92417
|
handler: (ctx) => handleDoctorCommand(ctx.directory, ctx.args),
|
|
@@ -92418,7 +92424,9 @@ var init_registry = __esm(() => {
|
|
|
92418
92424
|
"doctor tools": {
|
|
92419
92425
|
handler: (ctx) => handleDoctorToolsCommand(ctx.directory, ctx.args),
|
|
92420
92426
|
description: "Run tool registration coherence check",
|
|
92421
|
-
category: "diagnostics"
|
|
92427
|
+
category: "diagnostics",
|
|
92428
|
+
toolPolicy: "agent",
|
|
92429
|
+
toolNoArgs: true
|
|
92422
92430
|
},
|
|
92423
92431
|
"doctor-tools": {
|
|
92424
92432
|
handler: (ctx) => handleDoctorToolsCommand(ctx.directory, ctx.args),
|
|
@@ -92430,7 +92438,9 @@ var init_registry = __esm(() => {
|
|
|
92430
92438
|
diagnose: {
|
|
92431
92439
|
handler: (ctx) => handleDiagnoseCommand(ctx.directory, ctx.args),
|
|
92432
92440
|
description: "Run health check on swarm state",
|
|
92433
|
-
category: "diagnostics"
|
|
92441
|
+
category: "diagnostics",
|
|
92442
|
+
toolPolicy: "agent",
|
|
92443
|
+
toolNoArgs: true
|
|
92434
92444
|
},
|
|
92435
92445
|
diagnosis: {
|
|
92436
92446
|
handler: (ctx) => handleDiagnoseCommand(ctx.directory, ctx.args),
|
|
@@ -92442,26 +92452,32 @@ var init_registry = __esm(() => {
|
|
|
92442
92452
|
preflight: {
|
|
92443
92453
|
handler: (ctx) => handlePreflightCommand(ctx.directory, ctx.args),
|
|
92444
92454
|
description: "Run preflight automation checks",
|
|
92445
|
-
category: "diagnostics"
|
|
92455
|
+
category: "diagnostics",
|
|
92456
|
+
toolPolicy: "agent",
|
|
92457
|
+
toolNoArgs: true
|
|
92446
92458
|
},
|
|
92447
92459
|
"sync-plan": {
|
|
92448
92460
|
handler: (ctx) => handleSyncPlanCommand(ctx.directory, ctx.args),
|
|
92449
92461
|
description: "Ensure plan.json and plan.md are synced",
|
|
92450
92462
|
args: "",
|
|
92451
|
-
category: "config"
|
|
92463
|
+
category: "config",
|
|
92464
|
+
toolPolicy: "agent",
|
|
92465
|
+
toolNoArgs: true
|
|
92452
92466
|
},
|
|
92453
92467
|
benchmark: {
|
|
92454
92468
|
handler: (ctx) => handleBenchmarkCommand(ctx.directory, ctx.args),
|
|
92455
92469
|
description: "Show performance metrics [--cumulative] [--ci-gate]",
|
|
92456
92470
|
args: "--cumulative, --ci-gate",
|
|
92457
|
-
category: "diagnostics"
|
|
92471
|
+
category: "diagnostics",
|
|
92472
|
+
toolPolicy: "agent"
|
|
92458
92473
|
},
|
|
92459
92474
|
learning: {
|
|
92460
92475
|
handler: (ctx) => handleLearningCommand(ctx.directory, ctx.args),
|
|
92461
92476
|
description: "Show learning metrics and violation trends",
|
|
92462
92477
|
args: "--json, --phase <N>",
|
|
92463
92478
|
details: "Computes aggregate learning metrics from knowledge events: violation-rate trends, directive application rates, escalation frequency, per-entry ROI, and never-applied entries. Surfaces a learning summary for the curator digest.",
|
|
92464
|
-
category: "diagnostics"
|
|
92479
|
+
category: "diagnostics",
|
|
92480
|
+
toolPolicy: "agent"
|
|
92465
92481
|
},
|
|
92466
92482
|
export: {
|
|
92467
92483
|
handler: (ctx) => handleExportCommand(ctx.directory, ctx.args),
|
|
@@ -92469,14 +92485,17 @@ var init_registry = __esm(() => {
|
|
|
92469
92485
|
args: "",
|
|
92470
92486
|
details: "Exports the current plan and context as JSON to stdout. Useful for piping to external tools or debugging swarm state.",
|
|
92471
92487
|
category: "utility",
|
|
92472
|
-
clashesWithNativeCcCommand: "/export"
|
|
92488
|
+
clashesWithNativeCcCommand: "/export",
|
|
92489
|
+
toolPolicy: "agent",
|
|
92490
|
+
toolNoArgs: true
|
|
92473
92491
|
},
|
|
92474
92492
|
evidence: {
|
|
92475
92493
|
handler: (ctx) => handleEvidenceCommand(ctx.directory, ctx.args),
|
|
92476
92494
|
description: "Show evidence bundles [taskId]",
|
|
92477
92495
|
args: "<taskId>",
|
|
92478
92496
|
details: 'Displays review results, test verdicts, and other evidence bundles for the given task ID (e.g., "2.1").',
|
|
92479
|
-
category: "utility"
|
|
92497
|
+
category: "utility",
|
|
92498
|
+
toolPolicy: "agent"
|
|
92480
92499
|
},
|
|
92481
92500
|
"evidence summary": {
|
|
92482
92501
|
handler: (ctx) => handleEvidenceSummaryCommand(ctx.directory),
|
|
@@ -92484,7 +92503,9 @@ var init_registry = __esm(() => {
|
|
|
92484
92503
|
subcommandOf: "evidence",
|
|
92485
92504
|
args: "",
|
|
92486
92505
|
details: "Generates a summary showing completion ratio across all tasks, lists blockers, and identifies missing evidence.",
|
|
92487
|
-
category: "utility"
|
|
92506
|
+
category: "utility",
|
|
92507
|
+
toolPolicy: "agent",
|
|
92508
|
+
toolNoArgs: true
|
|
92488
92509
|
},
|
|
92489
92510
|
"evidence-summary": {
|
|
92490
92511
|
handler: (ctx) => handleEvidenceSummaryCommand(ctx.directory),
|
|
@@ -92544,13 +92565,15 @@ var init_registry = __esm(() => {
|
|
|
92544
92565
|
description: "Archive old evidence bundles [--dry-run]",
|
|
92545
92566
|
details: "Archives evidence bundles older than max_age_days (config, default 90) or beyond max_bundles cap (config, default 1000). --dry-run previews which bundles would be archived without deleting them. Applies two-tier retention: age-based first, then count-based on oldest remaining.",
|
|
92546
92567
|
args: "--dry-run",
|
|
92547
|
-
category: "utility"
|
|
92568
|
+
category: "utility",
|
|
92569
|
+
toolPolicy: "none"
|
|
92548
92570
|
},
|
|
92549
92571
|
curate: {
|
|
92550
92572
|
handler: (ctx) => handleCurateCommand(ctx.directory, ctx.args),
|
|
92551
92573
|
description: "Run knowledge curation and hive promotion review",
|
|
92552
92574
|
args: "",
|
|
92553
|
-
category: "utility"
|
|
92575
|
+
category: "utility",
|
|
92576
|
+
toolPolicy: "none"
|
|
92554
92577
|
},
|
|
92555
92578
|
consolidate: {
|
|
92556
92579
|
handler: (ctx) => handleConsolidateCommand(ctx.directory, ctx.args, {
|
|
@@ -92559,13 +92582,15 @@ var init_registry = __esm(() => {
|
|
|
92559
92582
|
description: "Run quota-bounded skill-improver consolidation and stage skill proposals",
|
|
92560
92583
|
details: "Runs the same consolidation pass used by scheduled skill_improver trigger points: queue hardening, skill-improver proposal writing, and optional draft-skill generation. It never auto-activates skills. Use --respect-interval to obey the configured cadence instead of forcing a run.",
|
|
92561
92584
|
args: "--force, --respect-interval, --evaluate",
|
|
92562
|
-
category: "utility"
|
|
92585
|
+
category: "utility",
|
|
92586
|
+
toolPolicy: "restricted"
|
|
92563
92587
|
},
|
|
92564
92588
|
"dark-matter": {
|
|
92565
92589
|
handler: (ctx) => handleDarkMatterCommand(ctx.directory, ctx.args),
|
|
92566
92590
|
description: "Detect hidden file couplings via co-change NPMI analysis",
|
|
92567
92591
|
args: "--threshold <number>, --min-commits <number>",
|
|
92568
|
-
category: "diagnostics"
|
|
92592
|
+
category: "diagnostics",
|
|
92593
|
+
toolPolicy: "none"
|
|
92569
92594
|
},
|
|
92570
92595
|
finalize: {
|
|
92571
92596
|
handler: (ctx) => handleCloseCommand(ctx.directory, ctx.args, {
|
|
@@ -92574,7 +92599,8 @@ var init_registry = __esm(() => {
|
|
|
92574
92599
|
description: "Use /swarm finalize to finalize the swarm project and archive evidence",
|
|
92575
92600
|
details: "Idempotent 4-stage terminal finalization: (1) finalize writes retrospectives for in-progress phases, (2) archive creates timestamped bundle of swarm artifacts and evidence, (3) clean removes active-state files for a clean slate, (4) align performs safe git ff-only to main. Resets agent sessions and delegation chains. Reads .swarm/close-lessons.md for explicit lessons and runs curation. Use --skill-review to run the quota-bounded skill_improver in proposal mode.",
|
|
92576
92601
|
args: "--prune-branches, --skill-review",
|
|
92577
|
-
category: "core"
|
|
92602
|
+
category: "core",
|
|
92603
|
+
toolPolicy: "none"
|
|
92578
92604
|
},
|
|
92579
92605
|
close: {
|
|
92580
92606
|
handler: (ctx) => handleCloseCommand(ctx.directory, ctx.args, {
|
|
@@ -92594,7 +92620,8 @@ var init_registry = __esm(() => {
|
|
|
92594
92620
|
description: "Run the post-mortem agent: project-end synthesis, queue triage, and final curation pass",
|
|
92595
92621
|
details: "Reads .swarm/ evidence (knowledge entries, events, curator digests, proposals, retrospectives, drift reports) and produces a post-mortem report at .swarm/post-mortem-{planId}.md. Idempotent: re-runs skip if report exists unless --force is passed.",
|
|
92596
92622
|
args: "--force",
|
|
92597
|
-
category: "core"
|
|
92623
|
+
category: "core",
|
|
92624
|
+
toolPolicy: "agent"
|
|
92598
92625
|
},
|
|
92599
92626
|
concurrency: {
|
|
92600
92627
|
handler: (ctx) => handleConcurrencyCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
@@ -92611,115 +92638,133 @@ Subcommands:
|
|
|
92611
92638
|
` + ` concurrency reset — Clear the session concurrency override
|
|
92612
92639
|
` + `
|
|
92613
92640
|
` + "Session-scoped — resets on new session.",
|
|
92614
|
-
category: "utility"
|
|
92641
|
+
category: "utility",
|
|
92642
|
+
toolPolicy: "none"
|
|
92615
92643
|
},
|
|
92616
92644
|
simulate: {
|
|
92617
92645
|
handler: (ctx) => handleSimulateCommand(ctx.directory, ctx.args),
|
|
92618
92646
|
description: "Dry-run hidden coupling analysis with configurable thresholds",
|
|
92619
92647
|
args: "--threshold <number>, --min-commits <number>",
|
|
92620
|
-
category: "diagnostics"
|
|
92648
|
+
category: "diagnostics",
|
|
92649
|
+
toolPolicy: "none"
|
|
92621
92650
|
},
|
|
92622
92651
|
sdd: {
|
|
92623
92652
|
handler: (ctx) => handleSddCommand(ctx.directory, ctx.args),
|
|
92624
92653
|
description: "Manage OpenSpec-compatible SDD artifacts and effective spec projection",
|
|
92625
92654
|
args: "status|validate|project [--json] [--change <id>] [--dry-run]",
|
|
92626
92655
|
details: "Parent command for spec-driven development artifacts. Use sdd status to inspect .swarm/spec.md plus openspec/ artifacts, sdd validate to validate OpenSpec-compatible deltas, and sdd project to materialize the effective spec into .swarm/spec.md for planning.",
|
|
92627
|
-
category: "utility"
|
|
92656
|
+
category: "utility",
|
|
92657
|
+
toolPolicy: "agent"
|
|
92628
92658
|
},
|
|
92629
92659
|
"sdd status": {
|
|
92630
92660
|
handler: (ctx) => handleSddStatusCommand(ctx.directory, ctx.args),
|
|
92631
92661
|
description: "Show OpenSpec-compatible SDD status and effective spec source",
|
|
92632
92662
|
subcommandOf: "sdd",
|
|
92633
92663
|
args: "[--json]",
|
|
92634
|
-
category: "utility"
|
|
92664
|
+
category: "utility",
|
|
92665
|
+
toolPolicy: "agent"
|
|
92635
92666
|
},
|
|
92636
92667
|
"sdd validate": {
|
|
92637
92668
|
handler: (ctx) => handleSddValidateCommand(ctx.directory, ctx.args),
|
|
92638
92669
|
description: "Validate OpenSpec-compatible artifacts and effective spec projection",
|
|
92639
92670
|
subcommandOf: "sdd",
|
|
92640
92671
|
args: "[--json] [--change <id>]",
|
|
92641
|
-
category: "utility"
|
|
92672
|
+
category: "utility",
|
|
92673
|
+
toolPolicy: "agent"
|
|
92642
92674
|
},
|
|
92643
92675
|
"sdd project": {
|
|
92644
92676
|
handler: (ctx) => handleSddProjectCommand(ctx.directory, ctx.args),
|
|
92645
92677
|
description: "Materialize the OpenSpec-compatible effective spec into .swarm/spec.md",
|
|
92646
92678
|
subcommandOf: "sdd",
|
|
92647
92679
|
args: "[--dry-run] [--json] [--change <id>]",
|
|
92648
|
-
category: "utility"
|
|
92680
|
+
category: "utility",
|
|
92681
|
+
toolPolicy: "human-only"
|
|
92649
92682
|
},
|
|
92650
92683
|
analyze: {
|
|
92651
92684
|
handler: (ctx) => handleAnalyzeCommand(ctx.directory, ctx.args),
|
|
92652
92685
|
description: "Analyze spec.md vs plan.md for requirement coverage gaps",
|
|
92653
92686
|
args: "",
|
|
92654
|
-
category: "agent"
|
|
92687
|
+
category: "agent",
|
|
92688
|
+
toolPolicy: "none"
|
|
92655
92689
|
},
|
|
92656
92690
|
clarify: {
|
|
92657
92691
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleClarifyCommand),
|
|
92658
92692
|
description: "Clarify and refine an existing feature specification",
|
|
92659
92693
|
args: "[description-text]",
|
|
92660
|
-
category: "agent"
|
|
92694
|
+
category: "agent",
|
|
92695
|
+
toolPolicy: "none"
|
|
92661
92696
|
},
|
|
92662
92697
|
specify: {
|
|
92663
92698
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleSpecifyCommand),
|
|
92664
92699
|
description: "Generate or import a feature specification [description]",
|
|
92665
92700
|
args: "[description-text]",
|
|
92666
|
-
category: "agent"
|
|
92701
|
+
category: "agent",
|
|
92702
|
+
toolPolicy: "none"
|
|
92667
92703
|
},
|
|
92668
92704
|
brainstorm: {
|
|
92669
92705
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleBrainstormCommand),
|
|
92670
92706
|
description: "Enter architect MODE: BRAINSTORM — structured seven-phase planning workflow [topic]",
|
|
92671
92707
|
args: "[topic-text]",
|
|
92672
92708
|
details: "Triggers the architect to run the brainstorm workflow: CONTEXT SCAN, single-question DIALOGUE, APPROACHES, DESIGN SECTIONS, SPEC WRITE + SELF-REVIEW, QA GATE SELECTION, TRANSITION. Use for new plans where requirements need to be drawn out before writing spec.md / plan.md.",
|
|
92673
|
-
category: "agent"
|
|
92709
|
+
category: "agent",
|
|
92710
|
+
toolPolicy: "none"
|
|
92674
92711
|
},
|
|
92675
92712
|
council: {
|
|
92676
92713
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleCouncilCommand),
|
|
92677
92714
|
description: "Enter architect MODE: COUNCIL — multi-model deliberation [question] [--preset <name>] [--spec-review]",
|
|
92678
92715
|
args: "<question> [--preset <name>] [--spec-review]",
|
|
92679
92716
|
details: "Triggers the architect to convene a three-agent General Council: Generalist (reviewer model), Skeptic (critic model), and Domain Expert (SME model). Use --preset <name> to choose a named member preset from council.general.presets. " + "The architect first runs 1–3 targeted web searches and passes a compiled RESEARCH CONTEXT " + "to all three agents before dispatching them in parallel. Agents deliberate using the NSED peer-review protocol (Round 1 independent analysis, Round 2 MAINTAIN/CONCEDE/NUANCE for disagreements). The architect synthesizes the final answer directly from convene_general_council output. --spec-review switches to single-pass advisory mode for spec review. Requires council.general.enabled: true and a search API key in the resolved config: global ~/.config/opencode/opencode-swarm.json, then project .opencode/opencode-swarm.json overrides.",
|
|
92680
|
-
category: "agent"
|
|
92717
|
+
category: "agent",
|
|
92718
|
+
toolPolicy: "none"
|
|
92681
92719
|
},
|
|
92682
92720
|
"pr-review": {
|
|
92683
92721
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handlePrReviewCommand),
|
|
92684
92722
|
description: "Launch deep PR review with multi-lane analysis [url] [--council]",
|
|
92685
92723
|
args: "<pr-url|owner/repo#N|N> [--council]",
|
|
92686
92724
|
details: "Launches a structured PR review: reconstructs PR intent via obligation extraction cascade, runs 6 parallel explorer lanes through the deterministic dispatch_lanes join barrier (correctness, security, dependencies, docs-intent-vs-actual, tests, performance-architecture), validates findings through independent reviewer confirmation, applies critic challenge to HIGH/CRITICAL findings, synthesizes structured report. --council variant fires adversarial multi-model review. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolves against origin remote).",
|
|
92687
|
-
category: "agent"
|
|
92725
|
+
category: "agent",
|
|
92726
|
+
toolPolicy: "none"
|
|
92688
92727
|
},
|
|
92689
92728
|
"pr-feedback": {
|
|
92690
92729
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handlePrFeedbackCommand),
|
|
92691
92730
|
description: "Ingest and close known PR feedback (review comments, CI failures, conflicts) [pr] [instructions]",
|
|
92692
92731
|
args: "[url|owner/repo#N|N] [instructions...]",
|
|
92693
92732
|
details: "Triggers MODE: PR_FEEDBACK — ingests existing pull-request feedback (review threads, requested changes, CI/check failures, merge conflicts, stale branch state, pasted notes), verifies every claim against source, clusters related problems, fixes confirmed items, validates the branch, and reports closure status for every ledger item. Distinct from /swarm pr-review, which discovers new findings. The PR reference is optional: with none, the architect builds the ledger from the current PR/branch; text after the reference is forwarded as extra instructions. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolved against origin).",
|
|
92694
|
-
category: "agent"
|
|
92733
|
+
category: "agent",
|
|
92734
|
+
toolPolicy: "none"
|
|
92695
92735
|
},
|
|
92696
92736
|
"pr subscribe": {
|
|
92697
92737
|
handler: (ctx) => handlePrSubscribeCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92698
92738
|
description: "Subscribe the current session to PR state-change notifications",
|
|
92699
92739
|
args: "<pr-url|owner/repo#N|N>",
|
|
92700
92740
|
details: "Subscribes the current session to receive advisory notifications for the specified PR. When pr_monitor.enabled is true, the background polling worker will detect CI failures, new comments, merge conflicts, review state changes, and merge/close events. Notifications are delivered as session-scoped advisories with dedup tokens. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolved against origin). Requires pr_monitor.enabled: true in config.",
|
|
92701
|
-
category: "agent"
|
|
92741
|
+
category: "agent",
|
|
92742
|
+
toolPolicy: "human-only"
|
|
92702
92743
|
},
|
|
92703
92744
|
"pr unsubscribe": {
|
|
92704
92745
|
handler: (ctx) => handlePrUnsubscribeCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92705
92746
|
description: "Unsubscribe the current session from PR state-change notifications",
|
|
92706
92747
|
args: "<pr-url|owner/repo#N|N>",
|
|
92707
92748
|
details: "Unsubscribes the current session from receiving advisory notifications for the specified PR. Removes the active subscription record. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolved against origin).",
|
|
92708
|
-
category: "agent"
|
|
92749
|
+
category: "agent",
|
|
92750
|
+
toolPolicy: "human-only"
|
|
92709
92751
|
},
|
|
92710
92752
|
"pr status": {
|
|
92711
92753
|
handler: (ctx) => handlePrMonitorStatusCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92712
92754
|
description: "Show PR monitor subscription status for the current session",
|
|
92713
92755
|
args: "",
|
|
92714
92756
|
details: "Displays all active PR subscriptions for the current session. Shows PR URL, last checked time, watching status, and error count per subscription. Also shows total active subscriptions across all sessions.",
|
|
92715
|
-
category: "agent"
|
|
92757
|
+
category: "agent",
|
|
92758
|
+
toolPolicy: "agent",
|
|
92759
|
+
toolNoArgs: true
|
|
92716
92760
|
},
|
|
92717
92761
|
"deep-dive": {
|
|
92718
92762
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleDeepDiveCommand),
|
|
92719
92763
|
description: "Launch deep codebase audit with parallel explorer waves, dual reviewers, and critic challenge [scope]",
|
|
92720
92764
|
args: "<scope> [--profile standard|security|ux|architecture|full] [--max-explorers 1..8] [--json] [--skip-update] [--allow-dirty]",
|
|
92721
92765
|
details: "Runs a read-only deep audit of the specified scope using parallel explorer waves (8-file cap per mission, ~3500 line guardrail), always 2 parallel reviewers for verification, and sequential critic challenge on HIGH/CRITICAL findings. Profiles select explorer lanes: standard (5 lanes), security, ux, architecture, full (all 8 lanes). Emits a structured findings report without mutating source code.",
|
|
92722
|
-
category: "agent"
|
|
92766
|
+
category: "agent",
|
|
92767
|
+
toolPolicy: "none"
|
|
92723
92768
|
},
|
|
92724
92769
|
"deep dive": {
|
|
92725
92770
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleDeepDiveCommand),
|
|
@@ -92733,7 +92778,8 @@ Subcommands:
|
|
|
92733
92778
|
description: "Launch a multi-source, fact-checked deep research pass and synthesize a cited report [question]",
|
|
92734
92779
|
args: "<question> [--depth standard|exhaustive] [--max-researchers 1..6] [--rounds 1..4] [--brief]",
|
|
92735
92780
|
details: "Runs the orchestrator-worker deep-research protocol: the architect decomposes the question into subtopics, gathers evidence with web_search and web_fetch across up to N iterative rounds, dispatches parallel sme synthesis workers, verifies every claim against cited sources with dual reviewers, challenges high-stakes claims with the critic, and presents a cited report in chat. Read-only — does not mutate source code, delegate to coder, or call declare_scope. Requires council.general.enabled and a search API key.",
|
|
92736
|
-
category: "agent"
|
|
92781
|
+
category: "agent",
|
|
92782
|
+
toolPolicy: "none"
|
|
92737
92783
|
},
|
|
92738
92784
|
"deep research": {
|
|
92739
92785
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleDeepResearchCommand),
|
|
@@ -92747,7 +92793,8 @@ Subcommands:
|
|
|
92747
92793
|
description: "Launch codebase-review-swarm for a quote-grounded full-repo or large-subsystem audit",
|
|
92748
92794
|
args: "[scope] [--mode phase0|complete|defect|security|correctness|testing|ui|performance|ai-slop|enhancements|custom] [--tracks <list>] [--continue <run-id>] [--json] [--skip-update] [--allow-dirty]",
|
|
92749
92795
|
details: "Runs the codebase-review-swarm workflow: Phase 0 inventory, selected-track depth planning, non-diluting review passes, coverage closure, reviewer validation, critic challenge, and .swarm/review-v8 artifacts. Materializes the bundled skill package if missing, then emits a MODE signal; the architect workflow must not mutate source files.",
|
|
92750
|
-
category: "agent"
|
|
92796
|
+
category: "agent",
|
|
92797
|
+
toolPolicy: "none"
|
|
92751
92798
|
},
|
|
92752
92799
|
"codebase review": {
|
|
92753
92800
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleCodebaseReviewCommand),
|
|
@@ -92761,7 +92808,8 @@ Subcommands:
|
|
|
92761
92808
|
description: "Generate or sync language-agnostic design docs (domain, technical-spec, behavior-spec, reference/) for the project under build [description]",
|
|
92762
92809
|
args: "<description> [--out <dir>] [--lang <name>] [--update]",
|
|
92763
92810
|
details: "Triggers the architect to enter MODE: DESIGN_DOCS — delegates to the docs_design agent to author/sync docs/domain.md, docs/technical-spec.md, docs/behavior-spec.md, and docs/reference/* (plus reference/traceability.json and design-changelog.md). Normative docs are 100% language-agnostic; all framework-specific material is quarantined under reference/. --update syncs existing docs to current code/spec instead of generating fresh. Requires design_docs.enabled: true.",
|
|
92764
|
-
category: "agent"
|
|
92811
|
+
category: "agent",
|
|
92812
|
+
toolPolicy: "none"
|
|
92765
92813
|
},
|
|
92766
92814
|
"design docs": {
|
|
92767
92815
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleDesignDocsCommand),
|
|
@@ -92775,21 +92823,24 @@ Subcommands:
|
|
|
92775
92823
|
description: "Ingest a GitHub issue into the swarm workflow [url] [--plan] [--trace] [--no-repro]",
|
|
92776
92824
|
args: "<issue-url|owner/repo#N|N> [--plan] [--trace] [--no-repro]",
|
|
92777
92825
|
details: "Triggers the architect to enter MODE: ISSUE_INGEST — ingests a GitHub issue, restructures it into a normalized intake note, localizes root cause through hypothesis-driven tracing, and outputs a resolution spec. --plan transitions to plan creation after spec generation. --trace runs the full fix-and-PR workflow (implies --plan). --no-repro skips the reproduction step. Supports full GitHub URL, owner/repo#N shorthand, or bare issue number (resolves against origin remote).",
|
|
92778
|
-
category: "agent"
|
|
92826
|
+
category: "agent",
|
|
92827
|
+
toolPolicy: "none"
|
|
92779
92828
|
},
|
|
92780
92829
|
"qa-gates": {
|
|
92781
92830
|
handler: (ctx) => handleQaGatesCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92782
92831
|
description: "View or modify QA gate profile for the current plan [enable|override <gate>...]",
|
|
92783
92832
|
args: "[show|enable|override] <gate>...",
|
|
92784
92833
|
details: "show: display spec-level, session-override, and effective QA gates for the current plan. enable: persist gate(s) into the locked-once profile (architect; rejected after critic approval lock). override: session-only ratchet-tighter enable. Valid gates: reviewer, test_engineer, council_mode, sme_enabled, critic_pre_plan, hallucination_guard, sast_enabled, mutation_test, phase_council, drift_check, final_council.",
|
|
92785
|
-
category: "config"
|
|
92834
|
+
category: "config",
|
|
92835
|
+
toolPolicy: "none"
|
|
92786
92836
|
},
|
|
92787
92837
|
promote: {
|
|
92788
92838
|
handler: (ctx) => handlePromoteCommand(ctx.directory, ctx.args),
|
|
92789
92839
|
description: "Manually promote lesson to hive knowledge",
|
|
92790
92840
|
details: "Promotes a lesson directly to hive knowledge (--category flag sets category) or references an existing swarm lesson by ID (--from-swarm). Validates lesson text before promotion. Either direct text or --from-swarm ID is required.",
|
|
92791
92841
|
args: "--category <category>, --from-swarm <lesson-id>, <lesson-text>",
|
|
92792
|
-
category: "utility"
|
|
92842
|
+
category: "utility",
|
|
92843
|
+
toolPolicy: "none"
|
|
92793
92844
|
},
|
|
92794
92845
|
reset: {
|
|
92795
92846
|
handler: (ctx) => handleResetCommand(ctx.directory, ctx.args),
|
|
@@ -92797,35 +92848,40 @@ Subcommands:
|
|
|
92797
92848
|
details: "DELETES plan.md, context.md, and summaries/ directory from .swarm/. Stops background automation and clears in-memory queues. SAFETY: requires --confirm flag — without it, displays a warning and tips to export first.",
|
|
92798
92849
|
args: "--confirm (required)",
|
|
92799
92850
|
category: "utility",
|
|
92800
|
-
clashesWithNativeCcCommand: "/reset"
|
|
92851
|
+
clashesWithNativeCcCommand: "/reset",
|
|
92852
|
+
toolPolicy: "restricted"
|
|
92801
92853
|
},
|
|
92802
92854
|
"reset-session": {
|
|
92803
92855
|
handler: (ctx) => handleResetSessionCommand(ctx.directory, ctx.args),
|
|
92804
92856
|
description: "Clear session state while preserving plan, evidence, and knowledge",
|
|
92805
92857
|
details: "Deletes only .swarm/session/state.json and any other session files. Clears in-memory agent sessions and delegation chains. Preserves plan, evidence, and knowledge for cross-session continuity.",
|
|
92806
92858
|
args: "",
|
|
92807
|
-
category: "utility"
|
|
92859
|
+
category: "utility",
|
|
92860
|
+
toolPolicy: "restricted"
|
|
92808
92861
|
},
|
|
92809
92862
|
rollback: {
|
|
92810
92863
|
handler: (ctx) => handleRollbackCommand(ctx.directory, ctx.args),
|
|
92811
92864
|
description: "Restore swarm state to a checkpoint <phase>",
|
|
92812
92865
|
details: "Restores .swarm/ state by directly overwriting files from a checkpoint directory (checkpoints/phase-<N>). Writes rollback event to events.jsonl. Without phase argument, lists available checkpoints. Partial failures are reported but processing continues.",
|
|
92813
92866
|
args: "<phase-number>",
|
|
92814
|
-
category: "utility"
|
|
92867
|
+
category: "utility",
|
|
92868
|
+
toolPolicy: "restricted"
|
|
92815
92869
|
},
|
|
92816
92870
|
retrieve: {
|
|
92817
92871
|
handler: (ctx) => handleRetrieveCommand(ctx.directory, ctx.args),
|
|
92818
92872
|
description: "Retrieve full output from a summary <id>",
|
|
92819
92873
|
args: "<summary-id>",
|
|
92820
92874
|
details: "Loads the full tool output that was previously summarized (referenced by IDs like S1, S2). Use when you need the complete output instead of the truncated summary.",
|
|
92821
|
-
category: "utility"
|
|
92875
|
+
category: "utility",
|
|
92876
|
+
toolPolicy: "agent"
|
|
92822
92877
|
},
|
|
92823
92878
|
handoff: {
|
|
92824
92879
|
handler: (ctx) => handleHandoffCommand(ctx.directory, ctx.args),
|
|
92825
92880
|
description: "Prepare state for clean model switch (new session)",
|
|
92826
92881
|
args: "",
|
|
92827
92882
|
details: "Generates handoff.md with full session state snapshot, including plan progress, recent decisions, and agent delegation history. Prepended to the next session prompt for seamless model switches.",
|
|
92828
|
-
category: "core"
|
|
92883
|
+
category: "core",
|
|
92884
|
+
toolPolicy: "none"
|
|
92829
92885
|
},
|
|
92830
92886
|
turbo: {
|
|
92831
92887
|
handler: (ctx) => handleTurboCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
@@ -92847,28 +92903,32 @@ Subcommands:
|
|
|
92847
92903
|
` + ` turbo status — show detailed status including active strategy and lanes
|
|
92848
92904
|
` + `
|
|
92849
92905
|
` + "Session-scoped — resets on new session.",
|
|
92850
|
-
category: "utility"
|
|
92906
|
+
category: "utility",
|
|
92907
|
+
toolPolicy: "none"
|
|
92851
92908
|
},
|
|
92852
92909
|
"full-auto": {
|
|
92853
92910
|
handler: (ctx) => handleFullAutoCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92854
92911
|
description: "Toggle Full-Auto Mode for the active session [on [mode]|off|status]",
|
|
92855
92912
|
args: "on [assisted|supervised|strict], off, status",
|
|
92856
92913
|
details: 'First-class toggle for Full-Auto Mode — autonomous execution with the critic reviewing escalations on your behalf. No config-level enablement is required: "on" activates immediately (unless full_auto.locked is true in config), "off" disarms the run and returns the session to normal interactive operation, "status" reports the durable run state. ' + 'An optional mode after "on" overrides full_auto.mode for this run: assisted (critic consulted only on policy escalations), supervised (default — risky/high-impact actions reviewed by the critic), strict (ALL plan mutations reviewed by the critic). ' + "While active, the critic answers architect questions and reviews phase boundaries, delegations, and risky actions on your behalf; only ESCALATE_TO_HUMAN verdicts halt the run for your input. The run state is durable (.swarm/full-auto-state.json) and survives restarts; toggle with no argument flips the current state.",
|
|
92857
|
-
category: "utility"
|
|
92914
|
+
category: "utility",
|
|
92915
|
+
toolPolicy: "none"
|
|
92858
92916
|
},
|
|
92859
92917
|
"auto-proceed": {
|
|
92860
92918
|
handler: (ctx) => handleAutoProceedCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92861
92919
|
description: "Toggle or set auto-proceed override for the active session",
|
|
92862
92920
|
args: "[on|off]",
|
|
92863
92921
|
category: "config",
|
|
92864
|
-
details: 'Without argument, toggles auto-proceed mode. With "on" or "off", sets the state explicitly.'
|
|
92922
|
+
details: 'Without argument, toggles auto-proceed mode. With "on" or "off", sets the state explicitly.',
|
|
92923
|
+
toolPolicy: "agent"
|
|
92865
92924
|
},
|
|
92866
92925
|
"write-retro": {
|
|
92867
92926
|
handler: (ctx) => handleWriteRetroCommand(ctx.directory, ctx.args),
|
|
92868
92927
|
description: "Write a retrospective evidence bundle for a completed phase <json>",
|
|
92869
92928
|
details: "Writes retrospective evidence bundle to .swarm/evidence/retro-{phase}/evidence.json. Required JSON: phase, summary, task_count, task_complexity, total_tool_calls, coder_revisions, reviewer_rejections, test_failures, security_findings, integration_issues. Optional: lessons_learned (max 5), top_rejection_reasons, task_id, metadata.",
|
|
92870
92929
|
args: "<json: {phase, summary, task_count, task_complexity, ...}>",
|
|
92871
|
-
category: "utility"
|
|
92930
|
+
category: "utility",
|
|
92931
|
+
toolPolicy: "none"
|
|
92872
92932
|
},
|
|
92873
92933
|
"knowledge migrate": {
|
|
92874
92934
|
handler: (ctx) => handleKnowledgeMigrateCommand(ctx.directory, ctx.args),
|
|
@@ -92912,75 +92972,89 @@ Subcommands:
|
|
|
92912
92972
|
knowledge: {
|
|
92913
92973
|
handler: (ctx) => handleKnowledgeListCommand(ctx.directory, ctx.args),
|
|
92914
92974
|
description: "List knowledge entries",
|
|
92915
|
-
category: "utility"
|
|
92975
|
+
category: "utility",
|
|
92976
|
+
toolPolicy: "agent"
|
|
92916
92977
|
},
|
|
92917
92978
|
memory: {
|
|
92918
92979
|
handler: (ctx) => handleMemoryCommand(ctx.directory, ctx.args),
|
|
92919
92980
|
description: "Show Swarm memory commands",
|
|
92920
|
-
category: "utility"
|
|
92981
|
+
category: "utility",
|
|
92982
|
+
toolPolicy: "agent",
|
|
92983
|
+
toolNoArgs: true
|
|
92921
92984
|
},
|
|
92922
92985
|
"memory status": {
|
|
92923
92986
|
handler: (ctx) => handleMemoryStatusCommand(ctx.directory, ctx.args),
|
|
92924
92987
|
description: "Show Swarm memory provider, JSONL, and migration status",
|
|
92925
92988
|
subcommandOf: "memory",
|
|
92926
92989
|
args: "",
|
|
92927
|
-
category: "diagnostics"
|
|
92990
|
+
category: "diagnostics",
|
|
92991
|
+
toolPolicy: "agent",
|
|
92992
|
+
toolNoArgs: true
|
|
92928
92993
|
},
|
|
92929
92994
|
"memory pending": {
|
|
92930
92995
|
handler: (ctx) => handleMemoryPendingCommand(ctx.directory, ctx.args),
|
|
92931
92996
|
description: "Show pending Swarm memory proposals and rejection reasons",
|
|
92932
92997
|
subcommandOf: "memory",
|
|
92933
92998
|
args: "--limit <n>",
|
|
92934
|
-
category: "diagnostics"
|
|
92999
|
+
category: "diagnostics",
|
|
93000
|
+
toolPolicy: "agent"
|
|
92935
93001
|
},
|
|
92936
93002
|
"memory recall-log": {
|
|
92937
93003
|
handler: (ctx) => handleMemoryRecallLogCommand(ctx.directory, ctx.args),
|
|
92938
93004
|
description: "Summarize Swarm memory recall usage",
|
|
92939
93005
|
subcommandOf: "memory",
|
|
92940
93006
|
args: "--limit <n>",
|
|
92941
|
-
category: "diagnostics"
|
|
93007
|
+
category: "diagnostics",
|
|
93008
|
+
toolPolicy: "agent"
|
|
92942
93009
|
},
|
|
92943
93010
|
"memory compact": {
|
|
92944
93011
|
handler: (ctx) => handleMemoryCompactCommand(ctx.directory, ctx.args),
|
|
92945
93012
|
description: "Compact deleted, superseded, and expired scratch memories",
|
|
92946
93013
|
subcommandOf: "memory",
|
|
92947
93014
|
args: "--confirm",
|
|
92948
|
-
category: "utility"
|
|
93015
|
+
category: "utility",
|
|
93016
|
+
toolPolicy: "human-only"
|
|
92949
93017
|
},
|
|
92950
93018
|
"memory stale": {
|
|
92951
93019
|
handler: (ctx) => handleMemoryStaleCommand(ctx.directory, ctx.args),
|
|
92952
93020
|
description: "List stale and low-utility Swarm memories",
|
|
92953
93021
|
subcommandOf: "memory",
|
|
92954
93022
|
args: "--limit <n>",
|
|
92955
|
-
category: "diagnostics"
|
|
93023
|
+
category: "diagnostics",
|
|
93024
|
+
toolPolicy: "agent"
|
|
92956
93025
|
},
|
|
92957
93026
|
"memory export": {
|
|
92958
93027
|
handler: (ctx) => handleMemoryExportCommand(ctx.directory, ctx.args),
|
|
92959
93028
|
description: "Export current Swarm memory to JSONL files",
|
|
92960
93029
|
subcommandOf: "memory",
|
|
92961
93030
|
args: "",
|
|
92962
|
-
category: "utility"
|
|
93031
|
+
category: "utility",
|
|
93032
|
+
toolPolicy: "agent",
|
|
93033
|
+
toolNoArgs: true
|
|
92963
93034
|
},
|
|
92964
93035
|
"memory evaluate": {
|
|
92965
93036
|
handler: (ctx) => handleMemoryEvaluateCommand(ctx.directory, ctx.args),
|
|
92966
93037
|
description: "Run golden Swarm memory recall evaluation fixtures",
|
|
92967
93038
|
subcommandOf: "memory",
|
|
92968
93039
|
args: "--json, --fixtures <directory>",
|
|
92969
|
-
category: "diagnostics"
|
|
93040
|
+
category: "diagnostics",
|
|
93041
|
+
toolPolicy: "agent"
|
|
92970
93042
|
},
|
|
92971
93043
|
"memory import": {
|
|
92972
93044
|
handler: (ctx) => handleMemoryImportCommand(ctx.directory, ctx.args),
|
|
92973
93045
|
description: "Import legacy JSONL memory into SQLite",
|
|
92974
93046
|
subcommandOf: "memory",
|
|
92975
93047
|
args: "",
|
|
92976
|
-
category: "utility"
|
|
93048
|
+
category: "utility",
|
|
93049
|
+
toolPolicy: "human-only"
|
|
92977
93050
|
},
|
|
92978
93051
|
"memory migrate": {
|
|
92979
93052
|
handler: (ctx) => handleMemoryMigrateCommand(ctx.directory, ctx.args),
|
|
92980
93053
|
description: "Run the one-time legacy JSONL to SQLite migration",
|
|
92981
93054
|
subcommandOf: "memory",
|
|
92982
93055
|
args: "",
|
|
92983
|
-
category: "utility"
|
|
93056
|
+
category: "utility",
|
|
93057
|
+
toolPolicy: "human-only"
|
|
92984
93058
|
},
|
|
92985
93059
|
checkpoint: {
|
|
92986
93060
|
handler: (ctx) => handleCheckpointCommand(ctx.directory, ctx.args),
|
|
@@ -92988,19 +93062,21 @@ Subcommands:
|
|
|
92988
93062
|
details: "save: creates named snapshot of current .swarm/ state. restore: soft-resets to checkpoint by overwriting current .swarm/ files. delete: removes named checkpoint. list: shows all checkpoints with timestamps. All subcommands require a label except list.",
|
|
92989
93063
|
args: "<save|restore|delete|list> <label>",
|
|
92990
93064
|
category: "utility",
|
|
92991
|
-
clashesWithNativeCcCommand: "/checkpoint"
|
|
93065
|
+
clashesWithNativeCcCommand: "/checkpoint",
|
|
93066
|
+
toolPolicy: "restricted"
|
|
92992
93067
|
}
|
|
92993
93068
|
};
|
|
92994
93069
|
VALID_COMMANDS = Object.keys(COMMAND_REGISTRY);
|
|
92995
|
-
|
|
93070
|
+
_internals13 = {
|
|
92996
93071
|
handleHelpCommand,
|
|
92997
93072
|
validateAliases,
|
|
93073
|
+
validateToolPolicy,
|
|
92998
93074
|
resolveCommand,
|
|
92999
93075
|
levenshteinDistance: levenshteinDistance2,
|
|
93000
93076
|
findSimilarCommands,
|
|
93001
93077
|
buildDetailedHelp
|
|
93002
93078
|
};
|
|
93003
|
-
validation =
|
|
93079
|
+
validation = _internals13.validateAliases();
|
|
93004
93080
|
if (!validation.valid) {
|
|
93005
93081
|
throw new Error(`COMMAND_REGISTRY alias validation failed:
|
|
93006
93082
|
${validation.errors.join(`
|
|
@@ -93011,6 +93087,16 @@ ${validation.errors.join(`
|
|
|
93011
93087
|
${validation.warnings.join(`
|
|
93012
93088
|
`)}`);
|
|
93013
93089
|
}
|
|
93090
|
+
try {
|
|
93091
|
+
const toolPolicyValidation = _internals13.validateToolPolicy();
|
|
93092
|
+
if (toolPolicyValidation.warnings.length > 0) {
|
|
93093
|
+
console.warn(`COMMAND_REGISTRY toolPolicy warnings:
|
|
93094
|
+
${toolPolicyValidation.warnings.join(`
|
|
93095
|
+
`)}`);
|
|
93096
|
+
}
|
|
93097
|
+
} catch (e) {
|
|
93098
|
+
console.warn(`COMMAND_REGISTRY toolPolicy validation failed (non-fatal): ${e.message}`);
|
|
93099
|
+
}
|
|
93014
93100
|
});
|
|
93015
93101
|
|
|
93016
93102
|
// src/agents/architect.ts
|
|
@@ -97448,7 +97534,7 @@ __export(exports_evidence_summary_integration, {
|
|
|
97448
97534
|
createEvidenceSummaryIntegration: () => createEvidenceSummaryIntegration,
|
|
97449
97535
|
EvidenceSummaryIntegration: () => EvidenceSummaryIntegration
|
|
97450
97536
|
});
|
|
97451
|
-
import { existsSync as existsSync50, mkdirSync as mkdirSync24, writeFileSync as
|
|
97537
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync24, writeFileSync as writeFileSync13 } from "node:fs";
|
|
97452
97538
|
import * as path90 from "node:path";
|
|
97453
97539
|
function persistSummary(projectDir, artifact, filename) {
|
|
97454
97540
|
const swarmPath = path90.join(projectDir, ".swarm");
|
|
@@ -97457,7 +97543,7 @@ function persistSummary(projectDir, artifact, filename) {
|
|
|
97457
97543
|
}
|
|
97458
97544
|
const artifactPath = path90.join(swarmPath, filename);
|
|
97459
97545
|
const content = JSON.stringify(artifact, null, 2);
|
|
97460
|
-
|
|
97546
|
+
writeFileSync13(artifactPath, content, "utf-8");
|
|
97461
97547
|
log("[EvidenceSummaryIntegration] Summary persisted", {
|
|
97462
97548
|
path: artifactPath,
|
|
97463
97549
|
size: content.length
|
|
@@ -98467,17 +98553,17 @@ import {
|
|
|
98467
98553
|
existsSync as existsSync62,
|
|
98468
98554
|
mkdirSync as mkdirSync31,
|
|
98469
98555
|
readFileSync as readFileSync41,
|
|
98470
|
-
renameSync as
|
|
98556
|
+
renameSync as renameSync19,
|
|
98471
98557
|
unlinkSync as unlinkSync15,
|
|
98472
|
-
writeFileSync as
|
|
98558
|
+
writeFileSync as writeFileSync20
|
|
98473
98559
|
} from "node:fs";
|
|
98474
98560
|
import * as path103 from "node:path";
|
|
98475
98561
|
function writeRawSidecar(absPath, bundle) {
|
|
98476
98562
|
mkdirSync31(path103.dirname(absPath), { recursive: true });
|
|
98477
98563
|
const tempFile = `${absPath}.tmp-${Date.now()}-${process.pid}`;
|
|
98478
98564
|
try {
|
|
98479
|
-
|
|
98480
|
-
|
|
98565
|
+
writeFileSync20(tempFile, JSON.stringify(bundle, null, 2), "utf-8");
|
|
98566
|
+
renameSync19(tempFile, absPath);
|
|
98481
98567
|
} finally {
|
|
98482
98568
|
if (existsSync62(tempFile)) {
|
|
98483
98569
|
try {
|
|
@@ -104782,6 +104868,7 @@ function createBackgroundCompletionObserver(opts) {
|
|
|
104782
104868
|
// src/index.ts
|
|
104783
104869
|
init_pr_subscriptions();
|
|
104784
104870
|
init_commands();
|
|
104871
|
+
init_registry();
|
|
104785
104872
|
init_config();
|
|
104786
104873
|
init_bundled_skills();
|
|
104787
104874
|
init_constants();
|
|
@@ -105497,7 +105584,7 @@ async function writeFullAutoOversightEvidence(directory, phase, event) {
|
|
|
105497
105584
|
}
|
|
105498
105585
|
}
|
|
105499
105586
|
async function dispatchFullAutoOversight(input) {
|
|
105500
|
-
const client =
|
|
105587
|
+
const client = _internals21.swarmState.opencodeClient;
|
|
105501
105588
|
const sequence = nextFullAutoOversightSequence(input.directory);
|
|
105502
105589
|
oversightSequenceCounter = sequence;
|
|
105503
105590
|
const beforeStatus = loadFullAutoRunState(input.directory, input.sessionID)?.status;
|
|
@@ -105831,7 +105918,7 @@ init_state();
|
|
|
105831
105918
|
init_utils();
|
|
105832
105919
|
init_bun_compat();
|
|
105833
105920
|
init_utils2();
|
|
105834
|
-
import { renameSync as
|
|
105921
|
+
import { renameSync as renameSync16, unlinkSync as unlinkSync13 } from "node:fs";
|
|
105835
105922
|
import * as nodePath2 from "node:path";
|
|
105836
105923
|
function createAgentActivityHooks(config3, directory) {
|
|
105837
105924
|
if (config3.hooks?.agent_activity === false) {
|
|
@@ -105906,7 +105993,7 @@ async function doFlush(directory) {
|
|
|
105906
105993
|
const tempPath = `${path98}.tmp`;
|
|
105907
105994
|
try {
|
|
105908
105995
|
await bunWrite(tempPath, updated);
|
|
105909
|
-
|
|
105996
|
+
renameSync16(tempPath, path98);
|
|
105910
105997
|
} catch (writeError) {
|
|
105911
105998
|
try {
|
|
105912
105999
|
unlinkSync13(tempPath);
|
|
@@ -107478,7 +107565,7 @@ Critic reasoning: ${criticResult.reasoning}`
|
|
|
107478
107565
|
}
|
|
107479
107566
|
}
|
|
107480
107567
|
async function dispatchCriticAndWriteEvent(directory, architectOutput, criticContext, criticModel, escalationType, interactionCount, deadlockCount, oversightAgentName, sessionID) {
|
|
107481
|
-
const client =
|
|
107568
|
+
const client = _internals21.swarmState.opencodeClient;
|
|
107482
107569
|
if (!client) {
|
|
107483
107570
|
warn("[full-auto-intercept] No opencodeClient — critic dispatch skipped (fallback to PENDING)");
|
|
107484
107571
|
const result = {
|
|
@@ -107605,11 +107692,11 @@ function createFullAutoInterceptHook(config3, directory) {
|
|
|
107605
107692
|
if (!architectText)
|
|
107606
107693
|
return;
|
|
107607
107694
|
const sessionID = architectMessage.info?.sessionID;
|
|
107608
|
-
if (!
|
|
107695
|
+
if (!_internals21.hasActiveFullAuto(sessionID))
|
|
107609
107696
|
return;
|
|
107610
107697
|
let session = null;
|
|
107611
107698
|
if (sessionID) {
|
|
107612
|
-
session =
|
|
107699
|
+
session = _internals21.ensureAgentSession(sessionID);
|
|
107613
107700
|
}
|
|
107614
107701
|
if (session) {
|
|
107615
107702
|
const interactionCount = session.fullAutoInteractionCount ?? 0;
|
|
@@ -114359,13 +114446,14 @@ function evictCooldownMap() {
|
|
|
114359
114446
|
}
|
|
114360
114447
|
function execGit2(directory, args2, opts) {
|
|
114361
114448
|
return new Promise((resolve46, reject) => {
|
|
114362
|
-
child_process7.execFile("git", args2, {
|
|
114449
|
+
const proc = child_process7.execFile("git", args2, {
|
|
114363
114450
|
encoding: "utf-8",
|
|
114364
114451
|
cwd: directory,
|
|
114365
114452
|
timeout: opts.timeoutMs,
|
|
114366
114453
|
maxBuffer: opts.maxBuffer,
|
|
114367
114454
|
stdio: ["ignore", "pipe", "pipe"]
|
|
114368
114455
|
}, (error93, stdout) => {
|
|
114456
|
+
proc.kill();
|
|
114369
114457
|
if (error93) {
|
|
114370
114458
|
reject(error93);
|
|
114371
114459
|
return;
|
|
@@ -114467,15 +114555,26 @@ async function dispatchReviewer(directory, prompt, agentName, timeoutMs) {
|
|
|
114467
114555
|
client.session.delete({ path: { id: sessionId } }).catch(() => {});
|
|
114468
114556
|
}
|
|
114469
114557
|
}
|
|
114558
|
+
var _eventWriteLockChain = Promise.resolve();
|
|
114559
|
+
function withEventWriteLock(fn2) {
|
|
114560
|
+
let release;
|
|
114561
|
+
_eventWriteLockChain = new Promise((r) => {
|
|
114562
|
+
release = r;
|
|
114563
|
+
});
|
|
114564
|
+
try {
|
|
114565
|
+
return fn2();
|
|
114566
|
+
} finally {
|
|
114567
|
+
release();
|
|
114568
|
+
}
|
|
114569
|
+
}
|
|
114470
114570
|
function writeAutoReviewEvent(directory, event) {
|
|
114471
114571
|
try {
|
|
114472
114572
|
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
114473
|
-
const existing = fs71.existsSync(eventsPath) ? fs71.readFileSync(eventsPath, "utf-8") : "";
|
|
114474
114573
|
const line = `${JSON.stringify(event)}
|
|
114475
114574
|
`;
|
|
114476
|
-
|
|
114477
|
-
|
|
114478
|
-
|
|
114575
|
+
withEventWriteLock(() => {
|
|
114576
|
+
fs71.appendFileSync(eventsPath, line, "utf-8");
|
|
114577
|
+
});
|
|
114479
114578
|
} catch (err2) {
|
|
114480
114579
|
warn(`[auto-review] event write failed: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
114481
114580
|
}
|
|
@@ -114793,7 +114892,7 @@ init_task_file();
|
|
|
114793
114892
|
init_logger();
|
|
114794
114893
|
init_knowledge_store();
|
|
114795
114894
|
var import_proper_lockfile9 = __toESM(require_proper_lockfile(), 1);
|
|
114796
|
-
import { existsSync as
|
|
114895
|
+
import { existsSync as existsSync70 } from "node:fs";
|
|
114797
114896
|
import { appendFile as appendFile11, mkdir as mkdir26, readFile as readFile27 } from "node:fs/promises";
|
|
114798
114897
|
import * as path123 from "node:path";
|
|
114799
114898
|
function resolveApplicationLogPath(directory) {
|
|
@@ -114878,7 +114977,7 @@ async function bumpCountersBatch(directory, bumps) {
|
|
|
114878
114977
|
const swarmPath = resolveSwarmKnowledgePath(directory);
|
|
114879
114978
|
await transactKnowledge(swarmPath, applyOne);
|
|
114880
114979
|
const hivePath = resolveHiveKnowledgePath();
|
|
114881
|
-
if (
|
|
114980
|
+
if (existsSync70(hivePath)) {
|
|
114882
114981
|
await transactKnowledge(hivePath, applyOne);
|
|
114883
114982
|
}
|
|
114884
114983
|
}
|
|
@@ -115852,7 +115951,7 @@ init_extractors();
|
|
|
115852
115951
|
// src/hooks/phase-directives.ts
|
|
115853
115952
|
init_knowledge_events();
|
|
115854
115953
|
init_knowledge_store();
|
|
115855
|
-
import { existsSync as
|
|
115954
|
+
import { existsSync as existsSync71 } from "node:fs";
|
|
115856
115955
|
async function collectPhaseDirectiveIds(directory, phaseLabel) {
|
|
115857
115956
|
const events = await readKnowledgeEvents(directory);
|
|
115858
115957
|
const ids = new Set;
|
|
@@ -115872,7 +115971,7 @@ async function readEntriesById(directory) {
|
|
|
115872
115971
|
for (const e of swarm)
|
|
115873
115972
|
map3.set(e.id, e);
|
|
115874
115973
|
const hivePath = resolveHiveKnowledgePath();
|
|
115875
|
-
if (
|
|
115974
|
+
if (existsSync71(hivePath)) {
|
|
115876
115975
|
const hive = await readKnowledge(hivePath);
|
|
115877
115976
|
for (const e of hive)
|
|
115878
115977
|
if (!map3.has(e.id))
|
|
@@ -117763,7 +117862,7 @@ init_schema();
|
|
|
117763
117862
|
// src/services/directive-predicate-runner.ts
|
|
117764
117863
|
init_bun_compat();
|
|
117765
117864
|
init_logger();
|
|
117766
|
-
import { existsSync as
|
|
117865
|
+
import { existsSync as existsSync74 } from "node:fs";
|
|
117767
117866
|
import * as path129 from "node:path";
|
|
117768
117867
|
var PREDICATE_TIMEOUT_MS = 15000;
|
|
117769
117868
|
var TOOL_BINARY_ALLOWLIST = new Set([
|
|
@@ -117805,7 +117904,7 @@ function findBinaryInPath(binary2) {
|
|
|
117805
117904
|
if (!dir)
|
|
117806
117905
|
continue;
|
|
117807
117906
|
const candidate = path129.join(dir, exeName);
|
|
117808
|
-
if (
|
|
117907
|
+
if (existsSync74(candidate))
|
|
117809
117908
|
return candidate;
|
|
117810
117909
|
}
|
|
117811
117910
|
return null;
|
|
@@ -119639,7 +119738,7 @@ init_state2();
|
|
|
119639
119738
|
init_utils2();
|
|
119640
119739
|
init_state();
|
|
119641
119740
|
init_bun_compat();
|
|
119642
|
-
import { renameSync as
|
|
119741
|
+
import { renameSync as renameSync21 } from "node:fs";
|
|
119643
119742
|
var TRANSIENT_SESSION_FIELDS = [
|
|
119644
119743
|
{ name: "revisionLimitHit", resetValue: false },
|
|
119645
119744
|
{ name: "coderRevisions", resetValue: 0 },
|
|
@@ -119782,7 +119881,7 @@ async function readSnapshot(directory) {
|
|
|
119782
119881
|
if (parsed.version !== 1 && parsed.version !== 2) {
|
|
119783
119882
|
try {
|
|
119784
119883
|
const quarantinePath = validateSwarmPath(directory, "session/state.json.quarantine");
|
|
119785
|
-
|
|
119884
|
+
renameSync21(resolvedPath, quarantinePath);
|
|
119786
119885
|
} catch {}
|
|
119787
119886
|
return null;
|
|
119788
119887
|
}
|
|
@@ -119881,15 +119980,15 @@ init_zod();
|
|
|
119881
119980
|
init_path_security();
|
|
119882
119981
|
init_create_tool();
|
|
119883
119982
|
import {
|
|
119884
|
-
existsSync as
|
|
119983
|
+
existsSync as existsSync76,
|
|
119885
119984
|
mkdirSync as mkdirSync32,
|
|
119886
119985
|
mkdtempSync as mkdtempSync2,
|
|
119887
|
-
readFileSync as
|
|
119986
|
+
readFileSync as readFileSync49,
|
|
119888
119987
|
realpathSync as realpathSync16,
|
|
119889
|
-
renameSync as
|
|
119988
|
+
renameSync as renameSync22,
|
|
119890
119989
|
rmdirSync,
|
|
119891
119990
|
unlinkSync as unlinkSync18,
|
|
119892
|
-
writeFileSync as
|
|
119991
|
+
writeFileSync as writeFileSync21
|
|
119893
119992
|
} from "node:fs";
|
|
119894
119993
|
import * as path135 from "node:path";
|
|
119895
119994
|
var WINDOWS_RESERVED_NAMES2 = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
@@ -120241,16 +120340,16 @@ function atomicWriteFileSync2(targetPath, content) {
|
|
|
120241
120340
|
tempPath = path135.join(dir, `${tempPrefix}.tmp`);
|
|
120242
120341
|
}
|
|
120243
120342
|
try {
|
|
120244
|
-
|
|
120245
|
-
|
|
120343
|
+
writeFileSync21(tempPath, content, "utf-8");
|
|
120344
|
+
renameSync22(tempPath, targetPath);
|
|
120246
120345
|
} finally {
|
|
120247
|
-
if (
|
|
120346
|
+
if (existsSync76(tempPath)) {
|
|
120248
120347
|
try {
|
|
120249
120348
|
unlinkSync18(tempPath);
|
|
120250
120349
|
} catch {}
|
|
120251
120350
|
}
|
|
120252
120351
|
const tempDir = path135.dirname(tempPath);
|
|
120253
|
-
if (tempDir !== dir &&
|
|
120352
|
+
if (tempDir !== dir && existsSync76(tempDir)) {
|
|
120254
120353
|
try {
|
|
120255
120354
|
rmdirSync(tempDir);
|
|
120256
120355
|
} catch {}
|
|
@@ -120327,7 +120426,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
|
|
|
120327
120426
|
};
|
|
120328
120427
|
}
|
|
120329
120428
|
const parentDir = path135.dirname(fullPath);
|
|
120330
|
-
if (!
|
|
120429
|
+
if (!existsSync76(parentDir)) {
|
|
120331
120430
|
return {
|
|
120332
120431
|
file: targetPath,
|
|
120333
120432
|
status: "error",
|
|
@@ -120343,7 +120442,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
|
|
|
120343
120442
|
]
|
|
120344
120443
|
};
|
|
120345
120444
|
}
|
|
120346
|
-
if (
|
|
120445
|
+
if (existsSync76(fullPath)) {
|
|
120347
120446
|
return {
|
|
120348
120447
|
file: targetPath,
|
|
120349
120448
|
status: "error",
|
|
@@ -120418,7 +120517,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
|
|
|
120418
120517
|
]
|
|
120419
120518
|
};
|
|
120420
120519
|
}
|
|
120421
|
-
if (!
|
|
120520
|
+
if (!existsSync76(fullPath)) {
|
|
120422
120521
|
return {
|
|
120423
120522
|
file: targetPath,
|
|
120424
120523
|
status: "error",
|
|
@@ -120462,7 +120561,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
|
|
|
120462
120561
|
hunksFailed: 0
|
|
120463
120562
|
};
|
|
120464
120563
|
}
|
|
120465
|
-
if (!
|
|
120564
|
+
if (!existsSync76(fullPath)) {
|
|
120466
120565
|
return {
|
|
120467
120566
|
file: targetPath,
|
|
120468
120567
|
status: "error",
|
|
@@ -120480,7 +120579,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
|
|
|
120480
120579
|
}
|
|
120481
120580
|
let content;
|
|
120482
120581
|
try {
|
|
120483
|
-
content =
|
|
120582
|
+
content = readFileSync49(fullPath, "utf-8");
|
|
120484
120583
|
} catch (err2) {
|
|
120485
120584
|
return {
|
|
120486
120585
|
file: targetPath,
|
|
@@ -120613,7 +120712,7 @@ var applyPatch = createSwarmTool({
|
|
|
120613
120712
|
const dryRun = obj.dryRun ?? false;
|
|
120614
120713
|
const allowCreates = obj.allowCreates ?? false;
|
|
120615
120714
|
const allowDeletes = obj.allowDeletes ?? false;
|
|
120616
|
-
if (!
|
|
120715
|
+
if (!existsSync76(directory)) {
|
|
120617
120716
|
return JSON.stringify(buildErrorResult("Workspace directory does not exist"), null, 2);
|
|
120618
120717
|
}
|
|
120619
120718
|
if (files.length === 0) {
|
|
@@ -122432,7 +122531,7 @@ ${body2}`);
|
|
|
122432
122531
|
// src/council/council-evidence-writer.ts
|
|
122433
122532
|
init_zod();
|
|
122434
122533
|
init_task_file();
|
|
122435
|
-
import { appendFileSync as
|
|
122534
|
+
import { appendFileSync as appendFileSync16, existsSync as existsSync81, mkdirSync as mkdirSync34, readFileSync as readFileSync55 } from "node:fs";
|
|
122436
122535
|
import { join as join113 } from "node:path";
|
|
122437
122536
|
var EVIDENCE_DIR2 = ".swarm/evidence";
|
|
122438
122537
|
var VALID_TASK_ID = /^\d+\.\d+(\.\d+)*$/;
|
|
@@ -122476,9 +122575,9 @@ async function writeCouncilEvidence(workingDir, synthesis) {
|
|
|
122476
122575
|
const filePath = taskEvidencePath(workingDir, synthesis.taskId);
|
|
122477
122576
|
await _internals78.withTaskEvidenceLock(workingDir, synthesis.taskId, COUNCIL_AGENT_ID, async () => {
|
|
122478
122577
|
const existingRoot = Object.create(null);
|
|
122479
|
-
if (
|
|
122578
|
+
if (existsSync81(filePath)) {
|
|
122480
122579
|
try {
|
|
122481
|
-
const parsed = EvidenceFileSchema.parse(JSON.parse(
|
|
122580
|
+
const parsed = EvidenceFileSchema.parse(JSON.parse(readFileSync55(filePath, "utf-8")));
|
|
122482
122581
|
safeAssignOwnProps(existingRoot, parsed);
|
|
122483
122582
|
} catch {}
|
|
122484
122583
|
}
|
|
@@ -122515,7 +122614,7 @@ async function writeCouncilEvidence(workingDir, synthesis) {
|
|
|
122515
122614
|
timestamp: synthesis.timestamp,
|
|
122516
122615
|
vetoedBy: synthesis.vetoedBy
|
|
122517
122616
|
});
|
|
122518
|
-
|
|
122617
|
+
appendFileSync16(join113(councilDir, `${synthesis.taskId}.rounds.jsonl`), `${auditLine}
|
|
122519
122618
|
`);
|
|
122520
122619
|
} catch (auditError) {
|
|
122521
122620
|
console.warn(`writeCouncilEvidence: failed to append round-history audit log: ${auditError instanceof Error ? auditError.message : String(auditError)}`);
|
|
@@ -122870,7 +122969,7 @@ function buildFinalCouncilFeedback(projectSummary, verdict, vetoedBy, requiredFi
|
|
|
122870
122969
|
|
|
122871
122970
|
// src/council/criteria-store.ts
|
|
122872
122971
|
init_zod();
|
|
122873
|
-
import { existsSync as
|
|
122972
|
+
import { existsSync as existsSync82, mkdirSync as mkdirSync35, readFileSync as readFileSync56, writeFileSync as writeFileSync23 } from "node:fs";
|
|
122874
122973
|
import { join as join114 } from "node:path";
|
|
122875
122974
|
var COUNCIL_DIR = ".swarm/council";
|
|
122876
122975
|
var CouncilCriteriaSchema = exports_external.object({
|
|
@@ -122890,14 +122989,14 @@ function writeCriteria(workingDir, taskId, criteria) {
|
|
|
122890
122989
|
criteria,
|
|
122891
122990
|
declaredAt: new Date().toISOString()
|
|
122892
122991
|
};
|
|
122893
|
-
|
|
122992
|
+
writeFileSync23(join114(dir, `${safeId(taskId)}.json`), JSON.stringify(payload, null, 2));
|
|
122894
122993
|
}
|
|
122895
122994
|
function readCriteria(workingDir, taskId) {
|
|
122896
122995
|
const filePath = join114(workingDir, COUNCIL_DIR, `${safeId(taskId)}.json`);
|
|
122897
|
-
if (!
|
|
122996
|
+
if (!existsSync82(filePath))
|
|
122898
122997
|
return null;
|
|
122899
122998
|
try {
|
|
122900
|
-
return CouncilCriteriaSchema.parse(JSON.parse(
|
|
122999
|
+
return CouncilCriteriaSchema.parse(JSON.parse(readFileSync56(filePath, "utf-8")));
|
|
122901
123000
|
} catch {
|
|
122902
123001
|
return null;
|
|
122903
123002
|
}
|
|
@@ -128887,7 +128986,7 @@ init_zod();
|
|
|
128887
128986
|
init_config();
|
|
128888
128987
|
init_knowledge_store();
|
|
128889
128988
|
init_create_tool();
|
|
128890
|
-
import { existsSync as
|
|
128989
|
+
import { existsSync as existsSync88 } from "node:fs";
|
|
128891
128990
|
var DEFAULT_LIMIT = 10;
|
|
128892
128991
|
var MAX_LESSON_LENGTH = 200;
|
|
128893
128992
|
var VALID_CATEGORIES3 = [
|
|
@@ -128963,14 +129062,14 @@ function validateLimit(limit) {
|
|
|
128963
129062
|
}
|
|
128964
129063
|
async function readSwarmKnowledge(directory) {
|
|
128965
129064
|
const swarmPath = resolveSwarmKnowledgePath(directory);
|
|
128966
|
-
if (!
|
|
129065
|
+
if (!existsSync88(swarmPath)) {
|
|
128967
129066
|
return [];
|
|
128968
129067
|
}
|
|
128969
129068
|
return readKnowledge(swarmPath);
|
|
128970
129069
|
}
|
|
128971
129070
|
async function readHiveKnowledge() {
|
|
128972
129071
|
const hivePath = resolveHiveKnowledgePath();
|
|
128973
|
-
if (!
|
|
129072
|
+
if (!existsSync88(hivePath)) {
|
|
128974
129073
|
return [];
|
|
128975
129074
|
}
|
|
128976
129075
|
return readKnowledge(hivePath);
|
|
@@ -131015,7 +131114,7 @@ import * as path155 from "node:path";
|
|
|
131015
131114
|
|
|
131016
131115
|
// src/mutation/engine.ts
|
|
131017
131116
|
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
131018
|
-
import { unlinkSync as unlinkSync19, writeFileSync as
|
|
131117
|
+
import { unlinkSync as unlinkSync19, writeFileSync as writeFileSync25 } from "node:fs";
|
|
131019
131118
|
import * as path154 from "node:path";
|
|
131020
131119
|
|
|
131021
131120
|
// src/mutation/equivalence.ts
|
|
@@ -131205,7 +131304,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
|
|
|
131205
131304
|
const safeId2 = patch.id.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
131206
131305
|
patchFile = path154.join(workingDir, `.mutation_patch_${safeId2}.diff`);
|
|
131207
131306
|
try {
|
|
131208
|
-
|
|
131307
|
+
writeFileSync25(patchFile, patch.patch);
|
|
131209
131308
|
} catch (writeErr) {
|
|
131210
131309
|
error93 = `Failed to write patch file: ${writeErr}`;
|
|
131211
131310
|
outcome = "error";
|
|
@@ -132623,6 +132722,17 @@ async function runFinalCouncilGate(ctx) {
|
|
|
132623
132722
|
const gateWarnings = [];
|
|
132624
132723
|
try {
|
|
132625
132724
|
const preamble = await resolveGatePreamble(dir, sessionID);
|
|
132725
|
+
if (!preamble.resolved || !preamble.plan) {
|
|
132726
|
+
const warning = "Final council gate: plan.json is missing. If final_council is required, the gate cannot be verified.";
|
|
132727
|
+
gateWarnings.push(warning);
|
|
132728
|
+
safeWarn(`[phase_complete] ${warning}`, undefined);
|
|
132729
|
+
return {
|
|
132730
|
+
blocked: false,
|
|
132731
|
+
agentsDispatched,
|
|
132732
|
+
agentsMissing: [],
|
|
132733
|
+
warnings: [warning]
|
|
132734
|
+
};
|
|
132735
|
+
}
|
|
132626
132736
|
if (preamble.resolved && preamble.plan) {
|
|
132627
132737
|
const lastPhaseId = preamble.plan.phases[preamble.plan.phases.length - 1]?.id;
|
|
132628
132738
|
if (lastPhaseId !== undefined && phase === lastPhaseId) {
|
|
@@ -132638,6 +132748,23 @@ async function runFinalCouncilGate(ctx) {
|
|
|
132638
132748
|
if (typeof entry.type === "string" && entry.type === "final-council" && typeof entry.verdict === "string") {
|
|
132639
132749
|
fcVerdictFound = true;
|
|
132640
132750
|
_fcVerdict = entry.verdict;
|
|
132751
|
+
const now = new Date;
|
|
132752
|
+
const fcTime = entry.timestamp ? new Date(entry.timestamp) : null;
|
|
132753
|
+
if (fcTime && !Number.isNaN(fcTime.getTime()) && fcTime.getTime() > now.getTime()) {
|
|
132754
|
+
return {
|
|
132755
|
+
blocked: true,
|
|
132756
|
+
reason: "FINAL_COUNCIL_FUTURE_TIMESTAMP",
|
|
132757
|
+
message: `Phase ${phase} cannot be completed: final council evidence timestamp is in the future.`,
|
|
132758
|
+
agentsDispatched,
|
|
132759
|
+
agentsMissing: [],
|
|
132760
|
+
warnings: []
|
|
132761
|
+
};
|
|
132762
|
+
}
|
|
132763
|
+
if (fcTime && !Number.isNaN(fcTime.getTime()) && now.getTime() - fcTime.getTime() > 24 * 60 * 60 * 1000) {
|
|
132764
|
+
const warning = "Final council evidence is older than 24 hours. Consider re-running the final council for fresh review.";
|
|
132765
|
+
gateWarnings.push(warning);
|
|
132766
|
+
safeWarn(`[phase_complete] ${warning}`, undefined);
|
|
132767
|
+
}
|
|
132641
132768
|
if (preamble.plan) {
|
|
132642
132769
|
const currentPlanId = derivePlanId(preamble.plan);
|
|
132643
132770
|
if (entry.plan_id && entry.plan_id !== currentPlanId) {
|
|
@@ -133372,58 +133499,56 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
133372
133499
|
safeWarn
|
|
133373
133500
|
};
|
|
133374
133501
|
if (hasActiveTurboMode(sessionID)) {
|
|
133375
|
-
warnings.push(`Turbo mode active — skipped completion-verify, drift-verifier, hallucination-guard, mutation-gate,
|
|
133502
|
+
warnings.push(`Turbo mode active — skipped completion-verify, drift-verifier, hallucination-guard, mutation-gate, and phase-council gates for phase ${phase}.`);
|
|
133376
133503
|
} else {
|
|
133377
133504
|
{
|
|
133378
|
-
const
|
|
133379
|
-
if (
|
|
133380
|
-
return blockedResult(phase,
|
|
133505
|
+
const gateResult2 = await runCompletionVerifyGate(gateCtx);
|
|
133506
|
+
if (gateResult2.blocked) {
|
|
133507
|
+
return blockedResult(phase, gateResult2);
|
|
133381
133508
|
}
|
|
133382
|
-
warnings.push(...
|
|
133509
|
+
warnings.push(...gateResult2.warnings);
|
|
133383
133510
|
}
|
|
133384
133511
|
{
|
|
133385
|
-
const
|
|
133386
|
-
if (
|
|
133387
|
-
return blockedResult(phase,
|
|
133512
|
+
const gateResult2 = await runDriftGate(gateCtx);
|
|
133513
|
+
if (gateResult2.blocked) {
|
|
133514
|
+
return blockedResult(phase, gateResult2);
|
|
133388
133515
|
}
|
|
133389
|
-
warnings.push(...
|
|
133516
|
+
warnings.push(...gateResult2.warnings);
|
|
133390
133517
|
}
|
|
133391
133518
|
{
|
|
133392
|
-
const
|
|
133393
|
-
if (
|
|
133394
|
-
return blockedResult(phase,
|
|
133519
|
+
const gateResult2 = await runHallucinationGate(gateCtx);
|
|
133520
|
+
if (gateResult2.blocked) {
|
|
133521
|
+
return blockedResult(phase, gateResult2);
|
|
133395
133522
|
}
|
|
133396
|
-
warnings.push(...
|
|
133523
|
+
warnings.push(...gateResult2.warnings);
|
|
133397
133524
|
}
|
|
133398
133525
|
{
|
|
133399
|
-
const
|
|
133400
|
-
if (
|
|
133401
|
-
return blockedResult(phase,
|
|
133526
|
+
const gateResult2 = await runMutationGate(gateCtx);
|
|
133527
|
+
if (gateResult2.blocked) {
|
|
133528
|
+
return blockedResult(phase, gateResult2);
|
|
133402
133529
|
}
|
|
133403
|
-
warnings.push(...
|
|
133530
|
+
warnings.push(...gateResult2.warnings);
|
|
133404
133531
|
}
|
|
133405
133532
|
{
|
|
133406
|
-
const
|
|
133407
|
-
if (
|
|
133408
|
-
return blockedResult(phase,
|
|
133533
|
+
const gateResult2 = await runPhaseCouncilGate(gateCtx);
|
|
133534
|
+
if (gateResult2.blocked) {
|
|
133535
|
+
return blockedResult(phase, gateResult2);
|
|
133409
133536
|
}
|
|
133410
|
-
warnings.push(...
|
|
133537
|
+
warnings.push(...gateResult2.warnings);
|
|
133411
133538
|
}
|
|
133412
133539
|
}
|
|
133413
133540
|
if (config3.architectural_supervision?.enabled && config3.architectural_supervision.mode === "gate") {
|
|
133414
|
-
const
|
|
133415
|
-
if (
|
|
133416
|
-
return blockedResult(phase,
|
|
133541
|
+
const gateResult2 = await runArchitectureSupervisorGate(gateCtx);
|
|
133542
|
+
if (gateResult2.blocked) {
|
|
133543
|
+
return blockedResult(phase, gateResult2);
|
|
133417
133544
|
}
|
|
133418
|
-
warnings.push(...
|
|
133545
|
+
warnings.push(...gateResult2.warnings);
|
|
133419
133546
|
}
|
|
133420
|
-
|
|
133421
|
-
|
|
133422
|
-
|
|
133423
|
-
return blockedResult(phase, gateResult);
|
|
133424
|
-
}
|
|
133425
|
-
warnings.push(...gateResult.warnings);
|
|
133547
|
+
const gateResult = await runFinalCouncilGate(gateCtx);
|
|
133548
|
+
if (gateResult.blocked) {
|
|
133549
|
+
return blockedResult(phase, gateResult);
|
|
133426
133550
|
}
|
|
133551
|
+
warnings.push(...gateResult.warnings);
|
|
133427
133552
|
{
|
|
133428
133553
|
const approval = verifyFullAutoPhaseApproval(dir, sessionID, phase, config3);
|
|
133429
133554
|
if (!approval.ok) {
|
|
@@ -141582,12 +141707,12 @@ ${content}
|
|
|
141582
141707
|
init_zod();
|
|
141583
141708
|
init_loader();
|
|
141584
141709
|
import {
|
|
141585
|
-
existsSync as
|
|
141710
|
+
existsSync as existsSync103,
|
|
141586
141711
|
mkdirSync as mkdirSync41,
|
|
141587
|
-
readFileSync as
|
|
141588
|
-
renameSync as
|
|
141712
|
+
readFileSync as readFileSync81,
|
|
141713
|
+
renameSync as renameSync24,
|
|
141589
141714
|
unlinkSync as unlinkSync21,
|
|
141590
|
-
writeFileSync as
|
|
141715
|
+
writeFileSync as writeFileSync31
|
|
141591
141716
|
} from "node:fs";
|
|
141592
141717
|
import path179 from "node:path";
|
|
141593
141718
|
init_create_tool();
|
|
@@ -141758,7 +141883,7 @@ var submit_phase_council_verdicts = createSwarmTool({
|
|
|
141758
141883
|
function getPhaseMutationGapFinding(phaseNumber, workingDir) {
|
|
141759
141884
|
const mutationGatePath = path179.join(workingDir, ".swarm", "evidence", String(phaseNumber), "mutation-gate.json");
|
|
141760
141885
|
try {
|
|
141761
|
-
const raw =
|
|
141886
|
+
const raw = readFileSync81(mutationGatePath, "utf-8");
|
|
141762
141887
|
const parsed = JSON.parse(raw);
|
|
141763
141888
|
const gateEntry = (parsed.entries ?? []).find((entry) => entry?.type === "mutation-gate");
|
|
141764
141889
|
if (!gateEntry) {
|
|
@@ -141854,10 +141979,10 @@ function writePhaseCouncilEvidence(workingDir, synthesis, provenance) {
|
|
|
141854
141979
|
};
|
|
141855
141980
|
const tempFile = `${evidenceFile}.tmp-${Date.now()}`;
|
|
141856
141981
|
try {
|
|
141857
|
-
|
|
141858
|
-
|
|
141982
|
+
writeFileSync31(tempFile, JSON.stringify(evidenceBundle, null, 2), "utf-8");
|
|
141983
|
+
renameSync24(tempFile, evidenceFile);
|
|
141859
141984
|
} finally {
|
|
141860
|
-
if (
|
|
141985
|
+
if (existsSync103(tempFile)) {
|
|
141861
141986
|
unlinkSync21(tempFile);
|
|
141862
141987
|
}
|
|
141863
141988
|
}
|
|
@@ -144573,18 +144698,18 @@ function safeFromCodePoint(code) {
|
|
|
144573
144698
|
return "";
|
|
144574
144699
|
}
|
|
144575
144700
|
}
|
|
144576
|
-
function stripSpans(input,
|
|
144701
|
+
function stripSpans(input, open4, close) {
|
|
144577
144702
|
const lower = input.toLowerCase();
|
|
144578
144703
|
let out2 = "";
|
|
144579
144704
|
let i2 = 0;
|
|
144580
144705
|
while (i2 < input.length) {
|
|
144581
|
-
const start2 = lower.indexOf(
|
|
144706
|
+
const start2 = lower.indexOf(open4, i2);
|
|
144582
144707
|
if (start2 === -1) {
|
|
144583
144708
|
out2 += input.slice(i2);
|
|
144584
144709
|
break;
|
|
144585
144710
|
}
|
|
144586
144711
|
out2 += input.slice(i2, start2);
|
|
144587
|
-
const end = lower.indexOf(close, start2 +
|
|
144712
|
+
const end = lower.indexOf(close, start2 + open4.length);
|
|
144588
144713
|
if (end === -1)
|
|
144589
144714
|
break;
|
|
144590
144715
|
i2 = end + close.length;
|
|
@@ -145596,7 +145721,7 @@ var VerdictSchema3 = exports_external.object({
|
|
|
145596
145721
|
durationMs: exports_external.number().nonnegative()
|
|
145597
145722
|
});
|
|
145598
145723
|
var ArgsSchema9 = exports_external.object({
|
|
145599
|
-
phase: exports_external.number().int().min(1),
|
|
145724
|
+
phase: exports_external.number().int().min(1).max(1000),
|
|
145600
145725
|
projectSummary: exports_external.string().min(1),
|
|
145601
145726
|
roundNumber: exports_external.number().int().min(1).max(10).optional(),
|
|
145602
145727
|
verdicts: exports_external.array(VerdictSchema3).min(1).max(5)
|
|
@@ -145651,7 +145776,16 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
|
|
|
145651
145776
|
}, null, 2);
|
|
145652
145777
|
}
|
|
145653
145778
|
const plan = await loadPlan(directory);
|
|
145654
|
-
|
|
145779
|
+
if (!plan) {
|
|
145780
|
+
return JSON.stringify({
|
|
145781
|
+
success: false,
|
|
145782
|
+
reason: "plan_not_found",
|
|
145783
|
+
message: "Cannot write final council evidence: plan.json not found. The plan must be loaded and available before writing final council evidence.",
|
|
145784
|
+
phase: input.phase,
|
|
145785
|
+
plan_id: "unknown"
|
|
145786
|
+
}, null, 2);
|
|
145787
|
+
}
|
|
145788
|
+
const planId = derivePlanId(plan);
|
|
145655
145789
|
const normalizedVerdict = normalizeFinalVerdict(synthesis.overallVerdict, synthesis.requiredFixes.length);
|
|
145656
145790
|
const evidenceEntry = {
|
|
145657
145791
|
type: "final-council",
|
|
@@ -146693,11 +146827,25 @@ async function initializeOpenCodeSwarm(ctx) {
|
|
|
146693
146827
|
addDeferredWarning("[swarm] auto_select_architect is enabled but no architect agents were found in the generated set. The option has no effect.");
|
|
146694
146828
|
}
|
|
146695
146829
|
}
|
|
146830
|
+
const shortcutDescription = (cmd) => {
|
|
146831
|
+
const entry = COMMAND_REGISTRY[cmd];
|
|
146832
|
+
if (!entry?.description) {
|
|
146833
|
+
return `Use /swarm ${cmd}`;
|
|
146834
|
+
}
|
|
146835
|
+
const desc = entry.description.charAt(0).toLowerCase() + entry.description.slice(1);
|
|
146836
|
+
return `Use /swarm ${cmd} to ${desc}`;
|
|
146837
|
+
};
|
|
146696
146838
|
opencodeConfig.command = {
|
|
146697
146839
|
...opencodeConfig.command || {},
|
|
146698
146840
|
swarm: {
|
|
146699
146841
|
template: "/swarm $ARGUMENTS",
|
|
146700
|
-
description:
|
|
146842
|
+
description: (() => {
|
|
146843
|
+
const standaloneCommands = VALID_COMMANDS.filter((cmd) => {
|
|
146844
|
+
const entry = COMMAND_REGISTRY[cmd];
|
|
146845
|
+
return !entry.aliasOf && !entry.deprecated && !entry.subcommandOf;
|
|
146846
|
+
});
|
|
146847
|
+
return `Swarm management commands: /swarm [${standaloneCommands.join("|")}]`;
|
|
146848
|
+
})()
|
|
146701
146849
|
},
|
|
146702
146850
|
"swarm-status": {
|
|
146703
146851
|
template: "/swarm status",
|
|
@@ -146799,6 +146947,26 @@ async function initializeOpenCodeSwarm(ctx) {
|
|
|
146799
146947
|
template: "/swarm pr-feedback $ARGUMENTS",
|
|
146800
146948
|
description: "Use /swarm pr-feedback to ingest and close known PR feedback (review comments, CI failures, conflicts) without a fresh broad review"
|
|
146801
146949
|
},
|
|
146950
|
+
"swarm-pr-subscribe": {
|
|
146951
|
+
template: "/swarm pr subscribe $ARGUMENTS",
|
|
146952
|
+
description: shortcutDescription("pr subscribe")
|
|
146953
|
+
},
|
|
146954
|
+
"swarm-pr-unsubscribe": {
|
|
146955
|
+
template: "/swarm pr unsubscribe $ARGUMENTS",
|
|
146956
|
+
description: shortcutDescription("pr unsubscribe")
|
|
146957
|
+
},
|
|
146958
|
+
"swarm-pr-status": {
|
|
146959
|
+
template: "/swarm pr status",
|
|
146960
|
+
description: shortcutDescription("pr status")
|
|
146961
|
+
},
|
|
146962
|
+
"swarm-learning": {
|
|
146963
|
+
template: "/swarm learning",
|
|
146964
|
+
description: shortcutDescription("learning")
|
|
146965
|
+
},
|
|
146966
|
+
"swarm-post-mortem": {
|
|
146967
|
+
template: "/swarm post-mortem $ARGUMENTS",
|
|
146968
|
+
description: shortcutDescription("post-mortem")
|
|
146969
|
+
},
|
|
146802
146970
|
"swarm-deep-dive": {
|
|
146803
146971
|
template: "/swarm deep-dive $ARGUMENTS",
|
|
146804
146972
|
description: "Use /swarm deep-dive to launch a read-only deep audit with parallel explorer waves, dual reviewers, and critic challenge"
|