opencode-swarm 7.84.0 → 7.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/skills/codebase-review-swarm/references/review-protocol-v8.2.md +4 -0
- package/.opencode/skills/council/SKILL.md +6 -1
- package/.opencode/skills/deep-dive/SKILL.md +2 -0
- package/.opencode/skills/deep-research/SKILL.md +6 -0
- package/.opencode/skills/swarm-pr-feedback/SKILL.md +6 -0
- package/.opencode/skills/swarm-pr-review/SKILL.md +4 -0
- package/dist/background/lane-output-store.d.ts +72 -0
- package/dist/background/pending-delegations.d.ts +6 -0
- package/dist/cli/{config-doctor-4tcdd9vt.js → config-doctor-zejarrr6.js} +2 -2
- package/dist/cli/{guardrail-explain-tcamcdfy.js → guardrail-explain-w4txg349.js} +5 -5
- package/dist/cli/{guardrail-log-fd14n96q.js → guardrail-log-80116wmz.js} +3 -3
- package/dist/cli/{index-a82d6d87.js → index-0sxvwjt0.js} +1 -1
- package/dist/cli/{index-jfgr5gye.js → index-5cb86007.js} +1 -1
- package/dist/cli/{index-wg3r6acj.js → index-hw9b2xng.js} +5 -1
- package/dist/cli/{index-j710h2ge.js → index-qqabjns2.js} +6 -6
- package/dist/cli/{index-pv2xmc9k.js → index-vq2321gg.js} +1 -1
- package/dist/cli/{index-xw0bcy0v.js → index-x7qck34v.js} +2 -2
- package/dist/cli/{index-8ra2qpk8.js → index-yhqt45de.js} +9 -9
- package/dist/cli/index.js +4 -4
- package/dist/cli/{pending-delegations-pz61mrsz.js → pending-delegations-rd40tv9s.js} +7 -1
- package/dist/cli/{schema-c2dbzhm8.js → schema-8d32b2v6.js} +1 -1
- package/dist/index.js +712 -342
- package/dist/tools/dispatch-lanes.d.ts +14 -3
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/manifest.d.ts +1 -0
- package/dist/tools/retrieve-lane-output.d.ts +2 -0
- package/dist/tools/tool-metadata.d.ts +4 -0
- 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.
|
|
72
|
+
version: "7.85.0",
|
|
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",
|
|
@@ -419,6 +419,10 @@ var init_tool_metadata = __esm(() => {
|
|
|
419
419
|
"test_engineer"
|
|
420
420
|
]
|
|
421
421
|
},
|
|
422
|
+
retrieve_lane_output: {
|
|
423
|
+
description: "retrieve paged full dispatch lane output by output_ref; use before consuming truncated lane previews or routing candidates from lane results",
|
|
424
|
+
agents: ["architect"]
|
|
425
|
+
},
|
|
422
426
|
extract_code_blocks: {
|
|
423
427
|
description: "extract code blocks from text content and save them to files",
|
|
424
428
|
agents: [
|
|
@@ -15653,7 +15657,7 @@ var init_schema = __esm(() => {
|
|
|
15653
15657
|
max_summary_chars: exports_external.number().min(100).max(5000).default(1000),
|
|
15654
15658
|
max_stored_bytes: exports_external.number().min(10240).max(104857600).default(10485760),
|
|
15655
15659
|
retention_days: exports_external.number().min(1).max(365).default(7),
|
|
15656
|
-
exempt_tools: exports_external.array(exports_external.string()).default(["retrieve_summary", "task", "read"])
|
|
15660
|
+
exempt_tools: exports_external.array(exports_external.string()).default(["retrieve_summary", "retrieve_lane_output", "task", "read"])
|
|
15657
15661
|
});
|
|
15658
15662
|
ReviewPassesConfigSchema = exports_external.object({
|
|
15659
15663
|
always_security_review: exports_external.boolean().default(false),
|
|
@@ -43497,7 +43501,13 @@ var init_pending_delegations = __esm(() => {
|
|
|
43497
43501
|
error: exports_external.string().optional(),
|
|
43498
43502
|
chars: exports_external.number(),
|
|
43499
43503
|
truncated: exports_external.boolean(),
|
|
43500
|
-
digest: exports_external.string()
|
|
43504
|
+
digest: exports_external.string(),
|
|
43505
|
+
outputRef: exports_external.string().optional(),
|
|
43506
|
+
outputPreviewChars: exports_external.number().optional(),
|
|
43507
|
+
outputDegraded: exports_external.boolean().optional(),
|
|
43508
|
+
outputArtifactError: exports_external.string().optional(),
|
|
43509
|
+
transcriptIncomplete: exports_external.boolean().optional(),
|
|
43510
|
+
messageCount: exports_external.number().optional()
|
|
43501
43511
|
}).strict();
|
|
43502
43512
|
WorkspaceSchema = exports_external.object({
|
|
43503
43513
|
directory: exports_external.string(),
|
|
@@ -107480,7 +107490,7 @@ __export(exports_design_doc_drift, {
|
|
|
107480
107490
|
_internals: () => _internals101
|
|
107481
107491
|
});
|
|
107482
107492
|
import * as fs111 from "node:fs";
|
|
107483
|
-
import * as
|
|
107493
|
+
import * as path172 from "node:path";
|
|
107484
107494
|
function mtimeMsOrNull(absPath) {
|
|
107485
107495
|
try {
|
|
107486
107496
|
return fs111.statSync(absPath).mtimeMs;
|
|
@@ -107491,35 +107501,35 @@ function mtimeMsOrNull(absPath) {
|
|
|
107491
107501
|
function resolveAnchorWithin(directory, anchor) {
|
|
107492
107502
|
if (!anchor || typeof anchor !== "string")
|
|
107493
107503
|
return null;
|
|
107494
|
-
const root =
|
|
107495
|
-
const resolved =
|
|
107496
|
-
const rel =
|
|
107497
|
-
if (rel.startsWith("..") ||
|
|
107504
|
+
const root = path172.resolve(directory);
|
|
107505
|
+
const resolved = path172.resolve(root, anchor);
|
|
107506
|
+
const rel = path172.relative(root, resolved);
|
|
107507
|
+
if (rel.startsWith("..") || path172.isAbsolute(rel))
|
|
107498
107508
|
return null;
|
|
107499
107509
|
return resolved;
|
|
107500
107510
|
}
|
|
107501
107511
|
async function runDesignDocDriftCheck(directory, phase, outDir) {
|
|
107502
107512
|
try {
|
|
107503
|
-
const root =
|
|
107504
|
-
const outAbs =
|
|
107505
|
-
const outRel =
|
|
107506
|
-
if (outRel.startsWith("..") ||
|
|
107513
|
+
const root = path172.resolve(directory);
|
|
107514
|
+
const outAbs = path172.resolve(root, outDir);
|
|
107515
|
+
const outRel = path172.relative(root, outAbs);
|
|
107516
|
+
if (outRel.startsWith("..") || path172.isAbsolute(outRel)) {
|
|
107507
107517
|
return null;
|
|
107508
107518
|
}
|
|
107509
107519
|
const docMtimes = new Map;
|
|
107510
107520
|
const checkedDocs = [];
|
|
107511
107521
|
const missingDocs = [];
|
|
107512
107522
|
for (const [docName, relFile] of Object.entries(DESIGN_DOC_FILES)) {
|
|
107513
|
-
const abs =
|
|
107523
|
+
const abs = path172.join(outAbs, relFile);
|
|
107514
107524
|
const mtime = mtimeMsOrNull(abs);
|
|
107515
107525
|
docMtimes.set(docName, mtime);
|
|
107516
107526
|
if (mtime === null) {
|
|
107517
|
-
missingDocs.push(
|
|
107527
|
+
missingDocs.push(path172.join(outDir, relFile));
|
|
107518
107528
|
} else {
|
|
107519
|
-
checkedDocs.push(
|
|
107529
|
+
checkedDocs.push(path172.join(outDir, relFile));
|
|
107520
107530
|
}
|
|
107521
107531
|
}
|
|
107522
|
-
const traceabilityAbs =
|
|
107532
|
+
const traceabilityAbs = path172.join(outAbs, TRACEABILITY_REL);
|
|
107523
107533
|
let registry3 = null;
|
|
107524
107534
|
try {
|
|
107525
107535
|
const stat14 = await fs111.promises.stat(traceabilityAbs);
|
|
@@ -107589,7 +107599,7 @@ async function runDesignDocDriftCheck(directory, phase, outDir) {
|
|
|
107589
107599
|
};
|
|
107590
107600
|
const filename = `${DOC_DRIFT_REPORT_PREFIX}${phase}.json`;
|
|
107591
107601
|
const filePath = validateSwarmPath(directory, filename);
|
|
107592
|
-
await fs111.promises.mkdir(
|
|
107602
|
+
await fs111.promises.mkdir(path172.dirname(filePath), { recursive: true });
|
|
107593
107603
|
await fs111.promises.writeFile(filePath, JSON.stringify(report, null, 2), "utf-8");
|
|
107594
107604
|
getGlobalEventBus().publish("curator.docdrift.completed", {
|
|
107595
107605
|
phase,
|
|
@@ -107621,10 +107631,10 @@ var init_design_doc_drift = __esm(() => {
|
|
|
107621
107631
|
domain: "domain.md",
|
|
107622
107632
|
"technical-spec": "technical-spec.md",
|
|
107623
107633
|
"behavior-spec": "behavior-spec.md",
|
|
107624
|
-
"reference-impl":
|
|
107625
|
-
"idiom-notes":
|
|
107634
|
+
"reference-impl": path172.join("reference", "reference-impl.md"),
|
|
107635
|
+
"idiom-notes": path172.join("reference", "idiom-notes.md")
|
|
107626
107636
|
};
|
|
107627
|
-
TRACEABILITY_REL =
|
|
107637
|
+
TRACEABILITY_REL = path172.join("reference", "traceability.json");
|
|
107628
107638
|
_internals101 = {
|
|
107629
107639
|
mtimeMsOrNull,
|
|
107630
107640
|
resolveAnchorWithin,
|
|
@@ -107640,7 +107650,7 @@ __export(exports_project_context, {
|
|
|
107640
107650
|
LANG_BACKEND_DETECTION_TIMEOUT_MS: () => LANG_BACKEND_DETECTION_TIMEOUT_MS
|
|
107641
107651
|
});
|
|
107642
107652
|
import * as fs135 from "node:fs";
|
|
107643
|
-
import * as
|
|
107653
|
+
import * as path201 from "node:path";
|
|
107644
107654
|
function detectFileExists2(directory, pattern) {
|
|
107645
107655
|
if (pattern.includes("*") || pattern.includes("?")) {
|
|
107646
107656
|
try {
|
|
@@ -107652,7 +107662,7 @@ function detectFileExists2(directory, pattern) {
|
|
|
107652
107662
|
}
|
|
107653
107663
|
}
|
|
107654
107664
|
try {
|
|
107655
|
-
fs135.accessSync(
|
|
107665
|
+
fs135.accessSync(path201.join(directory, pattern));
|
|
107656
107666
|
return true;
|
|
107657
107667
|
} catch {
|
|
107658
107668
|
return false;
|
|
@@ -107661,7 +107671,7 @@ function detectFileExists2(directory, pattern) {
|
|
|
107661
107671
|
function selectTestCommandFromScriptsTest(backend, directory) {
|
|
107662
107672
|
let pkgRaw;
|
|
107663
107673
|
try {
|
|
107664
|
-
pkgRaw = fs135.readFileSync(
|
|
107674
|
+
pkgRaw = fs135.readFileSync(path201.join(directory, "package.json"), "utf-8");
|
|
107665
107675
|
} catch {
|
|
107666
107676
|
return null;
|
|
107667
107677
|
}
|
|
@@ -107779,7 +107789,7 @@ var init_project_context = __esm(() => {
|
|
|
107779
107789
|
init_package();
|
|
107780
107790
|
init_agents2();
|
|
107781
107791
|
init_critic();
|
|
107782
|
-
import * as
|
|
107792
|
+
import * as path202 from "node:path";
|
|
107783
107793
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
107784
107794
|
|
|
107785
107795
|
// src/background/index.ts
|
|
@@ -110922,8 +110932,18 @@ function shouldMaskToolOutput(msg, index, totalMessages, recentWindowSize, thres
|
|
|
110922
110932
|
if (text.includes("[Tool output masked") || text.includes("[Context pruned")) {
|
|
110923
110933
|
return false;
|
|
110924
110934
|
}
|
|
110935
|
+
const structuredToolName = msg.info.toolName;
|
|
110936
|
+
const exemptList = [
|
|
110937
|
+
"retrieve_summary",
|
|
110938
|
+
"retrieve_lane_output",
|
|
110939
|
+
"task",
|
|
110940
|
+
"read"
|
|
110941
|
+
];
|
|
110942
|
+
if (structuredToolName && exemptList.includes(structuredToolName.toLowerCase())) {
|
|
110943
|
+
return false;
|
|
110944
|
+
}
|
|
110925
110945
|
const toolName = extractToolName(text);
|
|
110926
|
-
if (toolName &&
|
|
110946
|
+
if (toolName && exemptList.includes(toolName.toLowerCase())) {
|
|
110927
110947
|
return false;
|
|
110928
110948
|
}
|
|
110929
110949
|
const age = totalMessages - 1 - index;
|
|
@@ -118187,6 +118207,7 @@ function createToolSummarizerHook(config3, directory) {
|
|
|
118187
118207
|
}
|
|
118188
118208
|
const exemptTools = config3.exempt_tools ?? [
|
|
118189
118209
|
"retrieve_summary",
|
|
118210
|
+
"retrieve_lane_output",
|
|
118190
118211
|
"task",
|
|
118191
118212
|
"read"
|
|
118192
118213
|
];
|
|
@@ -121352,6 +121373,7 @@ var PROBED_TOOLS = new Set([
|
|
|
121352
121373
|
"gitingest",
|
|
121353
121374
|
"extract_code_blocks",
|
|
121354
121375
|
"retrieve_summary",
|
|
121376
|
+
"retrieve_lane_output",
|
|
121355
121377
|
"search",
|
|
121356
121378
|
"read",
|
|
121357
121379
|
"view"
|
|
@@ -127743,7 +127765,7 @@ var diff_summary = createSwarmTool({
|
|
|
127743
127765
|
});
|
|
127744
127766
|
|
|
127745
127767
|
// src/tools/dispatch-lanes.ts
|
|
127746
|
-
import { createHash as
|
|
127768
|
+
import { createHash as createHash19 } from "node:crypto";
|
|
127747
127769
|
|
|
127748
127770
|
// node_modules/yocto-queue/index.js
|
|
127749
127771
|
class Node2 {
|
|
@@ -127903,6 +127925,231 @@ function validateConcurrency(concurrency) {
|
|
|
127903
127925
|
|
|
127904
127926
|
// src/tools/dispatch-lanes.ts
|
|
127905
127927
|
init_zod();
|
|
127928
|
+
|
|
127929
|
+
// src/background/lane-output-store.ts
|
|
127930
|
+
init_zod();
|
|
127931
|
+
init_utils2();
|
|
127932
|
+
import { createHash as createHash18 } from "node:crypto";
|
|
127933
|
+
import {
|
|
127934
|
+
existsSync as existsSync85,
|
|
127935
|
+
mkdirSync as mkdirSync37,
|
|
127936
|
+
readFileSync as readFileSync60,
|
|
127937
|
+
renameSync as renameSync23,
|
|
127938
|
+
unlinkSync as unlinkSync19,
|
|
127939
|
+
writeFileSync as writeFileSync24
|
|
127940
|
+
} from "node:fs";
|
|
127941
|
+
import * as path152 from "node:path";
|
|
127942
|
+
var LANE_OUTPUT_REF_PREFIX = "L1";
|
|
127943
|
+
var MAX_LANE_OUTPUT_STORED_BYTES = 10 * 1024 * 1024;
|
|
127944
|
+
var LANE_OUTPUT_SCHEMA_VERSION = 1;
|
|
127945
|
+
var REF_RE = /^L1:[a-f0-9]{64}:[a-f0-9]{64}:[a-f0-9]{64}$/;
|
|
127946
|
+
var LaneOutputArtifactSchema = exports_external.object({
|
|
127947
|
+
schemaVersion: exports_external.literal(LANE_OUTPUT_SCHEMA_VERSION),
|
|
127948
|
+
ref: exports_external.string().regex(REF_RE),
|
|
127949
|
+
batchId: exports_external.string().min(1),
|
|
127950
|
+
laneId: exports_external.string().min(1),
|
|
127951
|
+
agent: exports_external.string().min(1),
|
|
127952
|
+
role: exports_external.string().min(1),
|
|
127953
|
+
sessionId: exports_external.string().min(1).optional(),
|
|
127954
|
+
parentSessionId: exports_external.string().min(1).optional(),
|
|
127955
|
+
mode: exports_external.string().min(1).optional(),
|
|
127956
|
+
source: exports_external.enum(["dispatch_lanes", "collect_lane_results"]),
|
|
127957
|
+
text: exports_external.string(),
|
|
127958
|
+
chars: exports_external.number().int().nonnegative(),
|
|
127959
|
+
bytes: exports_external.number().int().nonnegative(),
|
|
127960
|
+
digest: exports_external.string().regex(/^[a-f0-9]{64}$/),
|
|
127961
|
+
messageCount: exports_external.number().int().nonnegative().optional(),
|
|
127962
|
+
transcriptIncomplete: exports_external.boolean().optional(),
|
|
127963
|
+
createdAt: exports_external.string(),
|
|
127964
|
+
updatedAt: exports_external.string()
|
|
127965
|
+
}).strict();
|
|
127966
|
+
function storeLaneOutput(directory, input, now = Date.now) {
|
|
127967
|
+
const bytes = Buffer.byteLength(input.text, "utf-8");
|
|
127968
|
+
const digest3 = digestText(input.text);
|
|
127969
|
+
if (bytes > MAX_LANE_OUTPUT_STORED_BYTES) {
|
|
127970
|
+
return {
|
|
127971
|
+
digest: digest3,
|
|
127972
|
+
chars: input.text.length,
|
|
127973
|
+
bytes,
|
|
127974
|
+
degraded: true,
|
|
127975
|
+
error: `lane output exceeds ${MAX_LANE_OUTPUT_STORED_BYTES} byte storage limit`
|
|
127976
|
+
};
|
|
127977
|
+
}
|
|
127978
|
+
const batchDigest = digestText(input.batchId);
|
|
127979
|
+
const laneDigest = digestText(input.laneId);
|
|
127980
|
+
const ref = `${LANE_OUTPUT_REF_PREFIX}:${batchDigest}:${laneDigest}:${digest3}`;
|
|
127981
|
+
const relPath = laneOutputRelativePath(ref);
|
|
127982
|
+
const absPath = validateSwarmPath(directory, relPath);
|
|
127983
|
+
const timestamp = new Date(now()).toISOString();
|
|
127984
|
+
try {
|
|
127985
|
+
if (existsSync85(absPath)) {
|
|
127986
|
+
const existing = LaneOutputArtifactSchema.safeParse(JSON.parse(readFileSync60(absPath, "utf-8")));
|
|
127987
|
+
if (existing.success && existing.data.digest === digest3) {
|
|
127988
|
+
return {
|
|
127989
|
+
ref,
|
|
127990
|
+
digest: digest3,
|
|
127991
|
+
chars: existing.data.chars,
|
|
127992
|
+
bytes: existing.data.bytes,
|
|
127993
|
+
degraded: false
|
|
127994
|
+
};
|
|
127995
|
+
}
|
|
127996
|
+
}
|
|
127997
|
+
const artifact = {
|
|
127998
|
+
schemaVersion: LANE_OUTPUT_SCHEMA_VERSION,
|
|
127999
|
+
ref,
|
|
128000
|
+
batchId: input.batchId,
|
|
128001
|
+
laneId: input.laneId,
|
|
128002
|
+
agent: input.agent,
|
|
128003
|
+
role: input.role,
|
|
128004
|
+
...input.sessionId ? { sessionId: input.sessionId } : {},
|
|
128005
|
+
...input.parentSessionId ? { parentSessionId: input.parentSessionId } : {},
|
|
128006
|
+
...input.mode ? { mode: input.mode } : {},
|
|
128007
|
+
source: input.source,
|
|
128008
|
+
text: input.text,
|
|
128009
|
+
chars: input.text.length,
|
|
128010
|
+
bytes,
|
|
128011
|
+
digest: digest3,
|
|
128012
|
+
...input.messageCount !== undefined ? { messageCount: input.messageCount } : {},
|
|
128013
|
+
...input.transcriptIncomplete !== undefined ? { transcriptIncomplete: input.transcriptIncomplete } : {},
|
|
128014
|
+
createdAt: timestamp,
|
|
128015
|
+
updatedAt: timestamp
|
|
128016
|
+
};
|
|
128017
|
+
writeAtomicJson(absPath, artifact);
|
|
128018
|
+
return {
|
|
128019
|
+
ref,
|
|
128020
|
+
digest: digest3,
|
|
128021
|
+
chars: artifact.chars,
|
|
128022
|
+
bytes: artifact.bytes,
|
|
128023
|
+
degraded: false
|
|
128024
|
+
};
|
|
128025
|
+
} catch (error93) {
|
|
128026
|
+
return {
|
|
128027
|
+
digest: digest3,
|
|
128028
|
+
chars: input.text.length,
|
|
128029
|
+
bytes,
|
|
128030
|
+
degraded: true,
|
|
128031
|
+
error: error93 instanceof Error ? error93.message : "failed to store lane output artifact"
|
|
128032
|
+
};
|
|
128033
|
+
}
|
|
128034
|
+
}
|
|
128035
|
+
function readLaneOutput(directory, ref) {
|
|
128036
|
+
if (!REF_RE.test(ref))
|
|
128037
|
+
return null;
|
|
128038
|
+
const absPath = validateSwarmPath(directory, laneOutputRelativePath(ref));
|
|
128039
|
+
if (!existsSync85(absPath))
|
|
128040
|
+
return null;
|
|
128041
|
+
let parsed;
|
|
128042
|
+
try {
|
|
128043
|
+
parsed = LaneOutputArtifactSchema.safeParse(JSON.parse(readFileSync60(absPath, "utf-8")));
|
|
128044
|
+
} catch {
|
|
128045
|
+
return null;
|
|
128046
|
+
}
|
|
128047
|
+
if (!parsed.success || parsed.data.ref !== ref)
|
|
128048
|
+
return null;
|
|
128049
|
+
return { artifact: parsed.data };
|
|
128050
|
+
}
|
|
128051
|
+
function buildLaneOutputPreview(args2) {
|
|
128052
|
+
const { text, ref, degraded, maxChars } = args2;
|
|
128053
|
+
const needsPreview = text.length > maxChars;
|
|
128054
|
+
if (!needsPreview && !degraded) {
|
|
128055
|
+
return {
|
|
128056
|
+
output: text,
|
|
128057
|
+
output_chars: text.length,
|
|
128058
|
+
output_truncated: false
|
|
128059
|
+
};
|
|
128060
|
+
}
|
|
128061
|
+
const marker = buildPreviewMarker({
|
|
128062
|
+
omittedChars: Math.max(0, text.length - maxChars),
|
|
128063
|
+
ref,
|
|
128064
|
+
degraded: degraded === true
|
|
128065
|
+
});
|
|
128066
|
+
if (text.length <= maxChars && degraded) {
|
|
128067
|
+
return {
|
|
128068
|
+
output: `${text}${marker}`,
|
|
128069
|
+
output_chars: text.length,
|
|
128070
|
+
output_truncated: false
|
|
128071
|
+
};
|
|
128072
|
+
}
|
|
128073
|
+
const budget = Math.max(0, maxChars - marker.length);
|
|
128074
|
+
const headChars = Math.ceil(budget / 2);
|
|
128075
|
+
const tailChars = Math.floor(budget / 2);
|
|
128076
|
+
const head = text.slice(0, headChars);
|
|
128077
|
+
const tail = tailChars > 0 ? text.slice(text.length - tailChars) : "";
|
|
128078
|
+
return {
|
|
128079
|
+
output: `${head}${marker}${tail}`,
|
|
128080
|
+
output_chars: text.length,
|
|
128081
|
+
output_truncated: true
|
|
128082
|
+
};
|
|
128083
|
+
}
|
|
128084
|
+
function paginateLaneOutput(text, offset, limit) {
|
|
128085
|
+
const lines = text.length === 0 ? [] : text.split(`
|
|
128086
|
+
`);
|
|
128087
|
+
const totalLines = lines.length;
|
|
128088
|
+
const startLine = Math.max(0, offset);
|
|
128089
|
+
if (startLine >= totalLines) {
|
|
128090
|
+
return {
|
|
128091
|
+
totalLines,
|
|
128092
|
+
startLine,
|
|
128093
|
+
endLine: totalLines,
|
|
128094
|
+
content: "",
|
|
128095
|
+
exhausted: true
|
|
128096
|
+
};
|
|
128097
|
+
}
|
|
128098
|
+
const endLine = Math.min(startLine + limit, totalLines);
|
|
128099
|
+
return {
|
|
128100
|
+
totalLines,
|
|
128101
|
+
startLine,
|
|
128102
|
+
endLine,
|
|
128103
|
+
content: lines.slice(startLine, endLine).join(`
|
|
128104
|
+
`),
|
|
128105
|
+
exhausted: false
|
|
128106
|
+
};
|
|
128107
|
+
}
|
|
128108
|
+
function buildPreviewMarker(args2) {
|
|
128109
|
+
const retrieval = args2.ref ? ` retrieve_lane_output ref=${args2.ref} for full output.` : " no full output artifact is available; treat this lane as degraded.";
|
|
128110
|
+
const degraded = args2.degraded ? " Artifact storage degraded." : "";
|
|
128111
|
+
return `
|
|
128112
|
+
[... lane output preview omitted middle content.${degraded}${retrieval} ...]
|
|
128113
|
+
`;
|
|
128114
|
+
}
|
|
128115
|
+
function laneOutputRelativePath(ref) {
|
|
128116
|
+
const [, batchDigest, laneDigest, outputDigest] = ref.split(":");
|
|
128117
|
+
return path152.join("lane-results", batchDigest, laneDigest, `${outputDigest}.json`);
|
|
128118
|
+
}
|
|
128119
|
+
var WINDOWS_RENAME_MAX_RETRIES3 = 3;
|
|
128120
|
+
function writeAtomicJson(absPath, value) {
|
|
128121
|
+
mkdirSync37(path152.dirname(absPath), { recursive: true });
|
|
128122
|
+
const tempFile = `${absPath}.tmp-${Date.now()}-${process.pid}`;
|
|
128123
|
+
try {
|
|
128124
|
+
writeFileSync24(tempFile, JSON.stringify(value, null, 2), "utf-8");
|
|
128125
|
+
let lastRenameError;
|
|
128126
|
+
for (let attempt = 0;attempt < WINDOWS_RENAME_MAX_RETRIES3; attempt++) {
|
|
128127
|
+
try {
|
|
128128
|
+
renameSync23(tempFile, absPath);
|
|
128129
|
+
lastRenameError = undefined;
|
|
128130
|
+
break;
|
|
128131
|
+
} catch (err2) {
|
|
128132
|
+
lastRenameError = err2;
|
|
128133
|
+
const code = err2.code;
|
|
128134
|
+
if (code !== "EEXIST" && code !== "EBUSY" && code !== "EPERM")
|
|
128135
|
+
break;
|
|
128136
|
+
}
|
|
128137
|
+
}
|
|
128138
|
+
if (lastRenameError)
|
|
128139
|
+
throw lastRenameError;
|
|
128140
|
+
} finally {
|
|
128141
|
+
if (existsSync85(tempFile)) {
|
|
128142
|
+
try {
|
|
128143
|
+
unlinkSync19(tempFile);
|
|
128144
|
+
} catch {}
|
|
128145
|
+
}
|
|
128146
|
+
}
|
|
128147
|
+
}
|
|
128148
|
+
function digestText(text) {
|
|
128149
|
+
return createHash18("sha256").update(text).digest("hex");
|
|
128150
|
+
}
|
|
128151
|
+
|
|
128152
|
+
// src/tools/dispatch-lanes.ts
|
|
127906
128153
|
init_pending_delegations();
|
|
127907
128154
|
init_constants();
|
|
127908
128155
|
init_schema();
|
|
@@ -127969,6 +128216,7 @@ var COMMON_PROMPT_SEPARATOR = `
|
|
|
127969
128216
|
var DEFAULT_TIMEOUT_MS3 = 300000;
|
|
127970
128217
|
var MAX_TIMEOUT_MS2 = 1800000;
|
|
127971
128218
|
var MAX_LANE_OUTPUT_CHARS = 20000;
|
|
128219
|
+
var ASYNC_MESSAGE_FETCH_LIMIT = 50;
|
|
127972
128220
|
var MAX_ERROR_CHARS = 200;
|
|
127973
128221
|
var ERROR_TRUNCATION_SUFFIX = "...";
|
|
127974
128222
|
var MAX_BATCH_ID_CHARS = 120;
|
|
@@ -128324,7 +128572,7 @@ async function launchAsyncLane(args2) {
|
|
|
128324
128572
|
error: message,
|
|
128325
128573
|
chars: message.length,
|
|
128326
128574
|
truncated: false,
|
|
128327
|
-
digest:
|
|
128575
|
+
digest: digestText2(message)
|
|
128328
128576
|
}
|
|
128329
128577
|
});
|
|
128330
128578
|
cleanupAsyncLaunchSession(args2.session, sessionId);
|
|
@@ -128338,7 +128586,7 @@ async function launchAsyncLane(args2) {
|
|
|
128338
128586
|
error: error93,
|
|
128339
128587
|
chars: error93.length,
|
|
128340
128588
|
truncated: false,
|
|
128341
|
-
digest:
|
|
128589
|
+
digest: digestText2(error93)
|
|
128342
128590
|
}
|
|
128343
128591
|
});
|
|
128344
128592
|
cleanupAsyncLaunchSession(args2.session, sessionId);
|
|
@@ -128383,38 +128631,63 @@ async function collectOnce(session, directory, records, cancelPending) {
|
|
|
128383
128631
|
try {
|
|
128384
128632
|
messages = await session.messages({
|
|
128385
128633
|
path: { id: record3.subagentSessionId },
|
|
128386
|
-
query: { directory, limit:
|
|
128634
|
+
query: { directory, limit: ASYNC_MESSAGE_FETCH_LIMIT }
|
|
128387
128635
|
});
|
|
128388
128636
|
} catch {
|
|
128389
128637
|
continue;
|
|
128390
128638
|
}
|
|
128391
128639
|
if (!messages.data)
|
|
128392
128640
|
continue;
|
|
128393
|
-
const
|
|
128394
|
-
if (!text)
|
|
128641
|
+
const transcript = extractAssistantTranscript(messages.data);
|
|
128642
|
+
if (!transcript.text)
|
|
128395
128643
|
continue;
|
|
128396
|
-
const
|
|
128644
|
+
const output = prepareLaneOutput({
|
|
128645
|
+
directory,
|
|
128646
|
+
batchId: record3.batchId ?? record3.callID,
|
|
128647
|
+
laneId: record3.laneId ?? record3.correlationId,
|
|
128648
|
+
agent: record3.swarmPrefixedAgent,
|
|
128649
|
+
role: record3.normalizedAgent,
|
|
128650
|
+
sessionId: record3.subagentSessionId,
|
|
128651
|
+
parentSessionId: record3.parentSessionId,
|
|
128652
|
+
mode: record3.mode,
|
|
128653
|
+
source: "collect_lane_results",
|
|
128654
|
+
text: transcript.text,
|
|
128655
|
+
messageCount: transcript.messageCount,
|
|
128656
|
+
transcriptIncomplete: transcript.transcriptIncomplete
|
|
128657
|
+
});
|
|
128397
128658
|
await appendDelegationTransition(directory, record3.correlationId, {
|
|
128398
128659
|
status: "completed",
|
|
128399
128660
|
result: {
|
|
128400
|
-
text:
|
|
128401
|
-
chars:
|
|
128402
|
-
truncated:
|
|
128403
|
-
digest:
|
|
128661
|
+
text: output.output,
|
|
128662
|
+
chars: output.output_chars,
|
|
128663
|
+
truncated: output.output_truncated,
|
|
128664
|
+
digest: output.output_digest,
|
|
128665
|
+
...output.output_ref ? { outputRef: output.output_ref } : {},
|
|
128666
|
+
outputPreviewChars: output.output.length,
|
|
128667
|
+
...output.output_degraded !== undefined ? { outputDegraded: output.output_degraded } : {},
|
|
128668
|
+
...output.output_artifact_error ? { outputArtifactError: output.output_artifact_error } : {},
|
|
128669
|
+
...output.transcript_incomplete !== undefined ? { transcriptIncomplete: output.transcript_incomplete } : {},
|
|
128670
|
+
messageCount: transcript.messageCount
|
|
128404
128671
|
}
|
|
128405
128672
|
});
|
|
128406
128673
|
}
|
|
128407
128674
|
}
|
|
128408
|
-
function
|
|
128409
|
-
|
|
128410
|
-
|
|
128675
|
+
function extractAssistantTranscript(messages) {
|
|
128676
|
+
const assistantTexts = [];
|
|
128677
|
+
for (const message of messages) {
|
|
128411
128678
|
if (message.info?.role !== "assistant")
|
|
128412
128679
|
continue;
|
|
128413
128680
|
const text = extractText3(message.parts);
|
|
128414
128681
|
if (text.trim().length > 0)
|
|
128415
|
-
|
|
128682
|
+
assistantTexts.push(text);
|
|
128416
128683
|
}
|
|
128417
|
-
return
|
|
128684
|
+
return {
|
|
128685
|
+
text: assistantTexts.join(`
|
|
128686
|
+
|
|
128687
|
+
`),
|
|
128688
|
+
messageCount: assistantTexts.length,
|
|
128689
|
+
transcriptIncomplete: messages.length >= ASYNC_MESSAGE_FETCH_LIMIT
|
|
128690
|
+
};
|
|
128418
128691
|
}
|
|
128419
128692
|
function nextCollectPollInterval(currentMs) {
|
|
128420
128693
|
if (currentMs <= 0)
|
|
@@ -128483,7 +128756,17 @@ async function runLane(session, dispatcher, lane, directory, timeoutMs, context)
|
|
|
128483
128756
|
if (!promptResult.data) {
|
|
128484
128757
|
return failedLane(lane, role, startedAt, `session.prompt failed: ${formatError3(promptResult.error)}`, decision.slot.slotId, decision.slot.runId, sessionId);
|
|
128485
128758
|
}
|
|
128486
|
-
const
|
|
128759
|
+
const laneOutput = prepareLaneOutput({
|
|
128760
|
+
directory,
|
|
128761
|
+
batchId: `blocking:${sessionId}`,
|
|
128762
|
+
laneId: lane.id,
|
|
128763
|
+
agent: lane.agent,
|
|
128764
|
+
role,
|
|
128765
|
+
sessionId,
|
|
128766
|
+
parentSessionId: context.sessionID,
|
|
128767
|
+
source: "dispatch_lanes",
|
|
128768
|
+
text: extractText3(promptResult.data.parts)
|
|
128769
|
+
});
|
|
128487
128770
|
return {
|
|
128488
128771
|
id: lane.id,
|
|
128489
128772
|
agent: lane.agent,
|
|
@@ -128494,7 +128777,7 @@ async function runLane(session, dispatcher, lane, directory, timeoutMs, context)
|
|
|
128494
128777
|
run_id: decision.slot.runId,
|
|
128495
128778
|
started_at: startedAt,
|
|
128496
128779
|
completed_at: isoNow(),
|
|
128497
|
-
...
|
|
128780
|
+
...laneOutput
|
|
128498
128781
|
};
|
|
128499
128782
|
} catch (error93) {
|
|
128500
128783
|
return failedLane(lane, role, startedAt, formatError3(error93), decision.slot.slotId, decision.slot.runId, sessionId);
|
|
@@ -128556,7 +128839,14 @@ function recordToLaneResult(record3) {
|
|
|
128556
128839
|
...record3.result?.text !== undefined ? {
|
|
128557
128840
|
output: record3.result.text,
|
|
128558
128841
|
output_chars: record3.result.chars,
|
|
128559
|
-
output_truncated: record3.result.truncated
|
|
128842
|
+
output_truncated: record3.result.truncated,
|
|
128843
|
+
output_digest: record3.result.digest,
|
|
128844
|
+
...record3.result.outputRef ? { output_ref: record3.result.outputRef } : {},
|
|
128845
|
+
...record3.result.outputPreviewChars !== undefined ? { output_preview_chars: record3.result.outputPreviewChars } : {},
|
|
128846
|
+
...record3.result.outputDegraded !== undefined ? { output_degraded: record3.result.outputDegraded } : {},
|
|
128847
|
+
...record3.result.outputArtifactError ? { output_artifact_error: record3.result.outputArtifactError } : {},
|
|
128848
|
+
...record3.result.transcriptIncomplete !== undefined ? { transcript_incomplete: record3.result.transcriptIncomplete } : {},
|
|
128849
|
+
...record3.result.messageCount !== undefined ? { message_count: record3.result.messageCount } : {}
|
|
128560
128850
|
} : {},
|
|
128561
128851
|
...record3.result?.error !== undefined ? { error: record3.result.error } : {}
|
|
128562
128852
|
};
|
|
@@ -128633,22 +128923,35 @@ function buildReadOnlyTools() {
|
|
|
128633
128923
|
tools.patch = false;
|
|
128634
128924
|
return tools;
|
|
128635
128925
|
}
|
|
128636
|
-
function
|
|
128637
|
-
|
|
128638
|
-
|
|
128639
|
-
|
|
128640
|
-
|
|
128641
|
-
|
|
128642
|
-
|
|
128643
|
-
|
|
128644
|
-
|
|
128645
|
-
|
|
128646
|
-
|
|
128647
|
-
|
|
128926
|
+
function prepareLaneOutput(args2) {
|
|
128927
|
+
const stored = storeLaneOutput(args2.directory, {
|
|
128928
|
+
batchId: args2.batchId,
|
|
128929
|
+
laneId: args2.laneId,
|
|
128930
|
+
agent: args2.agent,
|
|
128931
|
+
role: args2.role,
|
|
128932
|
+
sessionId: args2.sessionId,
|
|
128933
|
+
parentSessionId: args2.parentSessionId,
|
|
128934
|
+
mode: args2.mode,
|
|
128935
|
+
source: args2.source,
|
|
128936
|
+
text: args2.text,
|
|
128937
|
+
messageCount: args2.messageCount,
|
|
128938
|
+
transcriptIncomplete: args2.transcriptIncomplete
|
|
128939
|
+
});
|
|
128940
|
+
const preview = buildLaneOutputPreview({
|
|
128941
|
+
text: args2.text,
|
|
128942
|
+
ref: stored.ref,
|
|
128943
|
+
degraded: stored.degraded,
|
|
128944
|
+
maxChars: MAX_LANE_OUTPUT_CHARS
|
|
128945
|
+
});
|
|
128648
128946
|
return {
|
|
128649
|
-
|
|
128650
|
-
|
|
128651
|
-
|
|
128947
|
+
...preview,
|
|
128948
|
+
output_ref: stored.ref,
|
|
128949
|
+
output_digest: stored.digest,
|
|
128950
|
+
output_preview_chars: preview.output.length,
|
|
128951
|
+
...stored.degraded ? { output_degraded: true } : {},
|
|
128952
|
+
...stored.error ? { output_artifact_error: stored.error } : {},
|
|
128953
|
+
...args2.transcriptIncomplete !== undefined ? { transcript_incomplete: args2.transcriptIncomplete } : {},
|
|
128954
|
+
...args2.messageCount !== undefined ? { message_count: args2.messageCount } : {}
|
|
128652
128955
|
};
|
|
128653
128956
|
}
|
|
128654
128957
|
function failureResult(args2) {
|
|
@@ -128779,7 +129082,7 @@ function makeBatchId() {
|
|
|
128779
129082
|
return `lanes-${_internals85.now().toString(36)}`;
|
|
128780
129083
|
}
|
|
128781
129084
|
function promptHash(lane, directory, batchId) {
|
|
128782
|
-
return
|
|
129085
|
+
return digestText2(JSON.stringify({
|
|
128783
129086
|
batchId,
|
|
128784
129087
|
laneId: lane.id,
|
|
128785
129088
|
agent: lane.agent,
|
|
@@ -128788,8 +129091,8 @@ function promptHash(lane, directory, batchId) {
|
|
|
128788
129091
|
`)
|
|
128789
129092
|
}));
|
|
128790
129093
|
}
|
|
128791
|
-
function
|
|
128792
|
-
return
|
|
129094
|
+
function digestText2(text) {
|
|
129095
|
+
return createHash19("sha256").update(text).digest("hex");
|
|
128793
129096
|
}
|
|
128794
129097
|
function sleep2(ms) {
|
|
128795
129098
|
if (ms <= 0)
|
|
@@ -129052,7 +129355,7 @@ init_zod();
|
|
|
129052
129355
|
init_create_tool();
|
|
129053
129356
|
init_path_security();
|
|
129054
129357
|
import * as fs94 from "node:fs";
|
|
129055
|
-
import * as
|
|
129358
|
+
import * as path153 from "node:path";
|
|
129056
129359
|
var MAX_FILE_SIZE_BYTES5 = 1024 * 1024;
|
|
129057
129360
|
var MAX_EVIDENCE_FILES = 1000;
|
|
129058
129361
|
var EVIDENCE_DIR3 = ".swarm/evidence";
|
|
@@ -129079,9 +129382,9 @@ function validateRequiredTypes(input) {
|
|
|
129079
129382
|
return null;
|
|
129080
129383
|
}
|
|
129081
129384
|
function isPathWithinSwarm2(filePath, cwd) {
|
|
129082
|
-
const normalizedCwd =
|
|
129083
|
-
const swarmPath =
|
|
129084
|
-
const normalizedPath =
|
|
129385
|
+
const normalizedCwd = path153.resolve(cwd);
|
|
129386
|
+
const swarmPath = path153.join(normalizedCwd, ".swarm");
|
|
129387
|
+
const normalizedPath = path153.resolve(filePath);
|
|
129085
129388
|
return normalizedPath.startsWith(swarmPath);
|
|
129086
129389
|
}
|
|
129087
129390
|
function parseCompletedTasks(planContent) {
|
|
@@ -129111,10 +129414,10 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
129111
129414
|
if (!VALID_EVIDENCE_FILENAME_REGEX.test(filename)) {
|
|
129112
129415
|
continue;
|
|
129113
129416
|
}
|
|
129114
|
-
const filePath =
|
|
129417
|
+
const filePath = path153.join(evidenceDir, filename);
|
|
129115
129418
|
try {
|
|
129116
|
-
const resolvedPath =
|
|
129117
|
-
const evidenceDirResolved =
|
|
129419
|
+
const resolvedPath = path153.resolve(filePath);
|
|
129420
|
+
const evidenceDirResolved = path153.resolve(evidenceDir);
|
|
129118
129421
|
if (!resolvedPath.startsWith(evidenceDirResolved)) {
|
|
129119
129422
|
continue;
|
|
129120
129423
|
}
|
|
@@ -129232,7 +129535,7 @@ var evidence_check = createSwarmTool({
|
|
|
129232
129535
|
return JSON.stringify(errorResult, null, 2);
|
|
129233
129536
|
}
|
|
129234
129537
|
const requiredTypes = requiredTypesValue.split(",").map((t) => t.trim()).filter((t) => t.length > 0).map(normalizeEvidenceType);
|
|
129235
|
-
const planPath =
|
|
129538
|
+
const planPath = path153.join(cwd, PLAN_FILE);
|
|
129236
129539
|
if (!isPathWithinSwarm2(planPath, cwd)) {
|
|
129237
129540
|
const errorResult = {
|
|
129238
129541
|
error: "plan file path validation failed",
|
|
@@ -129264,7 +129567,7 @@ var evidence_check = createSwarmTool({
|
|
|
129264
129567
|
};
|
|
129265
129568
|
return JSON.stringify(result2, null, 2);
|
|
129266
129569
|
}
|
|
129267
|
-
const evidenceDir =
|
|
129570
|
+
const evidenceDir = path153.join(cwd, EVIDENCE_DIR3);
|
|
129268
129571
|
const evidence = readEvidenceFiles(evidenceDir, cwd);
|
|
129269
129572
|
const { tasksWithFullEvidence, gaps } = analyzeGaps(completedTasks, evidence, requiredTypes);
|
|
129270
129573
|
const completeness = completedTasks.length > 0 ? Math.round(tasksWithFullEvidence.length / completedTasks.length * 100) / 100 : 1;
|
|
@@ -129287,7 +129590,7 @@ init_loader();
|
|
|
129287
129590
|
init_task_file();
|
|
129288
129591
|
import * as crypto11 from "node:crypto";
|
|
129289
129592
|
import * as fs95 from "node:fs/promises";
|
|
129290
|
-
import * as
|
|
129593
|
+
import * as path154 from "node:path";
|
|
129291
129594
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
129292
129595
|
var EVICTABLE_VERDICTS = new Set([
|
|
129293
129596
|
"pending",
|
|
@@ -129300,7 +129603,7 @@ function candidateFilePath(storePath3, id) {
|
|
|
129300
129603
|
if (!isValidCandidateId(id)) {
|
|
129301
129604
|
return null;
|
|
129302
129605
|
}
|
|
129303
|
-
return
|
|
129606
|
+
return path154.join(storePath3, `${id}.json`);
|
|
129304
129607
|
}
|
|
129305
129608
|
var _internals86 = {
|
|
129306
129609
|
randomUUID: crypto11.randomUUID.bind(crypto11),
|
|
@@ -129313,11 +129616,11 @@ var _internals86 = {
|
|
|
129313
129616
|
atomicWriteFile
|
|
129314
129617
|
};
|
|
129315
129618
|
function createExternalSkillStore(directory, config3) {
|
|
129316
|
-
const storePath3 =
|
|
129619
|
+
const storePath3 = path154.join(directory, ".swarm", "skills", "candidates");
|
|
129317
129620
|
async function add2(candidate) {
|
|
129318
129621
|
const id = _internals86.randomUUID();
|
|
129319
129622
|
const full = { ...candidate, id };
|
|
129320
|
-
const filePath =
|
|
129623
|
+
const filePath = path154.join(storePath3, `${id}.json`);
|
|
129321
129624
|
await _internals86.fs.mkdir(storePath3, { recursive: true });
|
|
129322
129625
|
await _internals86.atomicWriteFile(filePath, JSON.stringify(full, null, "\t"));
|
|
129323
129626
|
return full;
|
|
@@ -129357,7 +129660,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
129357
129660
|
if (!entry.endsWith(".json")) {
|
|
129358
129661
|
continue;
|
|
129359
129662
|
}
|
|
129360
|
-
const filePath =
|
|
129663
|
+
const filePath = path154.join(storePath3, entry);
|
|
129361
129664
|
let raw;
|
|
129362
129665
|
try {
|
|
129363
129666
|
raw = await _internals86.fs.readFile(filePath, "utf-8");
|
|
@@ -129541,11 +129844,11 @@ var external_skill_delete = createSwarmTool({
|
|
|
129541
129844
|
// src/tools/external-skill-discover.ts
|
|
129542
129845
|
init_zod();
|
|
129543
129846
|
init_loader();
|
|
129544
|
-
import { createHash as
|
|
129847
|
+
import { createHash as createHash21, randomUUID as randomUUID12 } from "node:crypto";
|
|
129545
129848
|
|
|
129546
129849
|
// src/services/external-skill-validator.ts
|
|
129547
129850
|
init_knowledge_validator();
|
|
129548
|
-
import { createHash as
|
|
129851
|
+
import { createHash as createHash20 } from "node:crypto";
|
|
129549
129852
|
var PROMPT_INJECTION_PATTERNS = [
|
|
129550
129853
|
{
|
|
129551
129854
|
pattern: /system\s*:/i,
|
|
@@ -130080,7 +130383,7 @@ function evaluateCandidate(candidate, options) {
|
|
|
130080
130383
|
}
|
|
130081
130384
|
var _internals88 = {
|
|
130082
130385
|
getTimestamp: () => new Date().toISOString(),
|
|
130083
|
-
computeSha256: (content) =>
|
|
130386
|
+
computeSha256: (content) => createHash20("sha256").update(content).digest("hex"),
|
|
130084
130387
|
stripMarkdownCodeForUnsafeScan
|
|
130085
130388
|
};
|
|
130086
130389
|
|
|
@@ -130102,7 +130405,7 @@ var _internals89 = {
|
|
|
130102
130405
|
return { content, finalUrl: response.url };
|
|
130103
130406
|
},
|
|
130104
130407
|
getTimestamp: () => new Date().toISOString(),
|
|
130105
|
-
computeSha256: (content) =>
|
|
130408
|
+
computeSha256: (content) => createHash21("sha256").update(content).digest("hex"),
|
|
130106
130409
|
uuid: () => randomUUID12()
|
|
130107
130410
|
};
|
|
130108
130411
|
var SOURCE_TRUST_LEVELS = {
|
|
@@ -130488,9 +130791,9 @@ var external_skill_list = createSwarmTool({
|
|
|
130488
130791
|
// src/tools/external-skill-promote.ts
|
|
130489
130792
|
init_zod();
|
|
130490
130793
|
init_loader();
|
|
130491
|
-
import { createHash as
|
|
130794
|
+
import { createHash as createHash22 } from "node:crypto";
|
|
130492
130795
|
import * as fs96 from "node:fs/promises";
|
|
130493
|
-
import * as
|
|
130796
|
+
import * as path155 from "node:path";
|
|
130494
130797
|
init_create_tool();
|
|
130495
130798
|
var _internals92 = {
|
|
130496
130799
|
loadConfig: (directory) => {
|
|
@@ -130507,7 +130810,7 @@ var _internals92 = {
|
|
|
130507
130810
|
}
|
|
130508
130811
|
},
|
|
130509
130812
|
writeSkillFile: async (filePath, content) => {
|
|
130510
|
-
await fs96.mkdir(
|
|
130813
|
+
await fs96.mkdir(path155.dirname(filePath), { recursive: true });
|
|
130511
130814
|
const handle2 = await fs96.open(filePath, "wx");
|
|
130512
130815
|
try {
|
|
130513
130816
|
await handle2.writeFile(content, "utf-8");
|
|
@@ -130630,8 +130933,8 @@ var external_skill_promote = createSwarmTool({
|
|
|
130630
130933
|
error: "Re-validation failed — candidate no longer passes gates"
|
|
130631
130934
|
});
|
|
130632
130935
|
}
|
|
130633
|
-
const targetDir =
|
|
130634
|
-
const targetPath =
|
|
130936
|
+
const targetDir = path155.join(directory, ".opencode", "skills", "generated", sanitizedSlug);
|
|
130937
|
+
const targetPath = path155.join(targetDir, "SKILL.md");
|
|
130635
130938
|
const timestamp = _internals92.getTimestamp();
|
|
130636
130939
|
const alreadyExists = await _internals92.fileExists(targetPath);
|
|
130637
130940
|
if (alreadyExists) {
|
|
@@ -130653,7 +130956,7 @@ var external_skill_promote = createSwarmTool({
|
|
|
130653
130956
|
}
|
|
130654
130957
|
throw writeErr;
|
|
130655
130958
|
}
|
|
130656
|
-
const promotedContentHash =
|
|
130959
|
+
const promotedContentHash = createHash22("sha256").update(skillMarkdown).digest("hex");
|
|
130657
130960
|
const prePromotionHistory = candidate.evaluation_history;
|
|
130658
130961
|
const lastPrePromotionEntry = prePromotionHistory.length > 0 ? prePromotionHistory[prePromotionHistory.length - 1] : undefined;
|
|
130659
130962
|
const originalEvaluation = lastPrePromotionEntry ? {
|
|
@@ -130805,7 +131108,7 @@ var external_skill_reject = createSwarmTool({
|
|
|
130805
131108
|
// src/tools/external-skill-revoke.ts
|
|
130806
131109
|
init_zod();
|
|
130807
131110
|
init_loader();
|
|
130808
|
-
import * as
|
|
131111
|
+
import * as path156 from "node:path";
|
|
130809
131112
|
init_create_tool();
|
|
130810
131113
|
var _internals94 = {
|
|
130811
131114
|
loadConfig: (directory) => {
|
|
@@ -130904,7 +131207,7 @@ var external_skill_revoke = createSwarmTool({
|
|
|
130904
131207
|
error: "Cannot revoke: unable to determine the skill slug from promotion history. The candidate record may be corrupted. Manually remove the skill file from .opencode/skills/generated/ if needed."
|
|
130905
131208
|
});
|
|
130906
131209
|
}
|
|
130907
|
-
const skillPath =
|
|
131210
|
+
const skillPath = path156.join(directory, ".opencode", "skills", "generated", slug, "SKILL.md");
|
|
130908
131211
|
const skillFileRemoved = await _internals94.retireSkillFile(skillPath);
|
|
130909
131212
|
const timestamp = _internals94.getTimestamp();
|
|
130910
131213
|
const historyEntry = {
|
|
@@ -130937,7 +131240,7 @@ var external_skill_revoke = createSwarmTool({
|
|
|
130937
131240
|
init_zod();
|
|
130938
131241
|
init_create_tool();
|
|
130939
131242
|
import * as fs97 from "node:fs";
|
|
130940
|
-
import * as
|
|
131243
|
+
import * as path157 from "node:path";
|
|
130941
131244
|
var EXT_MAP = {
|
|
130942
131245
|
python: ".py",
|
|
130943
131246
|
py: ".py",
|
|
@@ -131018,12 +131321,12 @@ var extract_code_blocks = createSwarmTool({
|
|
|
131018
131321
|
if (prefix) {
|
|
131019
131322
|
filename = `${prefix}_${filename}`;
|
|
131020
131323
|
}
|
|
131021
|
-
let filepath =
|
|
131022
|
-
const base =
|
|
131023
|
-
const ext =
|
|
131324
|
+
let filepath = path157.join(targetDir, filename);
|
|
131325
|
+
const base = path157.basename(filepath, path157.extname(filepath));
|
|
131326
|
+
const ext = path157.extname(filepath);
|
|
131024
131327
|
let counter = 1;
|
|
131025
131328
|
while (fs97.existsSync(filepath)) {
|
|
131026
|
-
filepath =
|
|
131329
|
+
filepath = path157.join(targetDir, `${base}_${counter}${ext}`);
|
|
131027
131330
|
counter++;
|
|
131028
131331
|
}
|
|
131029
131332
|
try {
|
|
@@ -131377,7 +131680,7 @@ init_path_security();
|
|
|
131377
131680
|
init_create_tool();
|
|
131378
131681
|
import * as child_process12 from "node:child_process";
|
|
131379
131682
|
import * as fs98 from "node:fs";
|
|
131380
|
-
import * as
|
|
131683
|
+
import * as path158 from "node:path";
|
|
131381
131684
|
var BLAME_TIMEOUT_MS = 30000;
|
|
131382
131685
|
var MAX_OUTPUT_LINES2 = 500;
|
|
131383
131686
|
var MAX_PATH_LENGTH2 = 500;
|
|
@@ -131435,7 +131738,7 @@ function validateFilePath(filePath) {
|
|
|
131435
131738
|
if (filePath.length > MAX_PATH_LENGTH2) {
|
|
131436
131739
|
return `file path exceeds maximum length of ${MAX_PATH_LENGTH2}`;
|
|
131437
131740
|
}
|
|
131438
|
-
if (
|
|
131741
|
+
if (path158.isAbsolute(filePath)) {
|
|
131439
131742
|
return "absolute paths are not allowed; use a relative path from the project root";
|
|
131440
131743
|
}
|
|
131441
131744
|
if (containsPathTraversal(filePath)) {
|
|
@@ -131464,7 +131767,7 @@ function validateLineNumber(value, name2) {
|
|
|
131464
131767
|
return null;
|
|
131465
131768
|
}
|
|
131466
131769
|
function isBinaryFile2(filePath) {
|
|
131467
|
-
const ext =
|
|
131770
|
+
const ext = path158.extname(filePath).toLowerCase();
|
|
131468
131771
|
return BINARY_EXTENSIONS.has(ext);
|
|
131469
131772
|
}
|
|
131470
131773
|
function parsePorcelainBlame(output, linesCap) {
|
|
@@ -131611,7 +131914,7 @@ var git_blame = createSwarmTool({
|
|
|
131611
131914
|
lines: []
|
|
131612
131915
|
});
|
|
131613
131916
|
}
|
|
131614
|
-
const resolvedPath =
|
|
131917
|
+
const resolvedPath = path158.resolve(directory, file3);
|
|
131615
131918
|
if (!fs98.existsSync(resolvedPath)) {
|
|
131616
131919
|
return JSON.stringify({
|
|
131617
131920
|
error: `file not found: ${file3}`,
|
|
@@ -131622,8 +131925,8 @@ var git_blame = createSwarmTool({
|
|
|
131622
131925
|
}
|
|
131623
131926
|
const realDir = fs98.realpathSync(directory);
|
|
131624
131927
|
const realPath = fs98.realpathSync(resolvedPath);
|
|
131625
|
-
const relative32 =
|
|
131626
|
-
if (relative32.startsWith("..") ||
|
|
131928
|
+
const relative32 = path158.relative(realDir, realPath);
|
|
131929
|
+
if (relative32.startsWith("..") || path158.isAbsolute(relative32)) {
|
|
131627
131930
|
return JSON.stringify({
|
|
131628
131931
|
error: "file path resolves outside the workspace",
|
|
131629
131932
|
file: file3,
|
|
@@ -131975,7 +132278,7 @@ init_zod();
|
|
|
131975
132278
|
init_create_tool();
|
|
131976
132279
|
init_path_security();
|
|
131977
132280
|
import * as fs99 from "node:fs";
|
|
131978
|
-
import * as
|
|
132281
|
+
import * as path159 from "node:path";
|
|
131979
132282
|
var MAX_FILE_PATH_LENGTH2 = 500;
|
|
131980
132283
|
var MAX_SYMBOL_LENGTH = 256;
|
|
131981
132284
|
var MAX_FILE_SIZE_BYTES6 = 1024 * 1024;
|
|
@@ -132023,7 +132326,7 @@ function validateSymbolInput(symbol3) {
|
|
|
132023
132326
|
return null;
|
|
132024
132327
|
}
|
|
132025
132328
|
function isBinaryFile3(filePath, buffer) {
|
|
132026
|
-
const ext =
|
|
132329
|
+
const ext = path159.extname(filePath).toLowerCase();
|
|
132027
132330
|
if (ext === ".json" || ext === ".md" || ext === ".txt") {
|
|
132028
132331
|
return false;
|
|
132029
132332
|
}
|
|
@@ -132047,15 +132350,15 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
132047
132350
|
const imports = [];
|
|
132048
132351
|
let _resolvedTarget;
|
|
132049
132352
|
try {
|
|
132050
|
-
_resolvedTarget =
|
|
132353
|
+
_resolvedTarget = path159.resolve(targetFile);
|
|
132051
132354
|
} catch {
|
|
132052
132355
|
_resolvedTarget = targetFile;
|
|
132053
132356
|
}
|
|
132054
|
-
const targetBasename =
|
|
132357
|
+
const targetBasename = path159.basename(targetFile, path159.extname(targetFile));
|
|
132055
132358
|
const targetWithExt = targetFile;
|
|
132056
132359
|
const targetWithoutExt = targetFile.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
132057
|
-
const normalizedTargetWithExt =
|
|
132058
|
-
const normalizedTargetWithoutExt =
|
|
132360
|
+
const normalizedTargetWithExt = path159.normalize(targetWithExt).replace(/\\/g, "/");
|
|
132361
|
+
const normalizedTargetWithoutExt = path159.normalize(targetWithoutExt).replace(/\\/g, "/");
|
|
132059
132362
|
const importRegex = /import\s+(?:\{[\s\S]*?\}|(?:\*\s+as\s+\w+)|\w+)\s+from\s+['"`]([^'"`]+)['"`]|import\s+['"`]([^'"`]+)['"`]|require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
132060
132363
|
for (let match = importRegex.exec(content);match !== null; match = importRegex.exec(content)) {
|
|
132061
132364
|
const modulePath = match[1] || match[2] || match[3];
|
|
@@ -132078,9 +132381,9 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
132078
132381
|
}
|
|
132079
132382
|
const _normalizedModule = modulePath.replace(/^\.\//, "").replace(/^\.\.\\/, "../");
|
|
132080
132383
|
let isMatch = false;
|
|
132081
|
-
const _targetDir =
|
|
132082
|
-
const targetExt =
|
|
132083
|
-
const targetBasenameNoExt =
|
|
132384
|
+
const _targetDir = path159.dirname(targetFile);
|
|
132385
|
+
const targetExt = path159.extname(targetFile);
|
|
132386
|
+
const targetBasenameNoExt = path159.basename(targetFile, targetExt);
|
|
132084
132387
|
const moduleNormalized = modulePath.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
132085
132388
|
const moduleName = modulePath.split(/[/\\]/).pop() || "";
|
|
132086
132389
|
const moduleNameNoExt = moduleName.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
@@ -132148,10 +132451,10 @@ function findSourceFiles2(dir, files = [], stats2 = { skippedDirs: [], skippedFi
|
|
|
132148
132451
|
entries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
132149
132452
|
for (const entry of entries) {
|
|
132150
132453
|
if (SKIP_DIRECTORIES5.has(entry)) {
|
|
132151
|
-
stats2.skippedDirs.push(
|
|
132454
|
+
stats2.skippedDirs.push(path159.join(dir, entry));
|
|
132152
132455
|
continue;
|
|
132153
132456
|
}
|
|
132154
|
-
const fullPath =
|
|
132457
|
+
const fullPath = path159.join(dir, entry);
|
|
132155
132458
|
let stat14;
|
|
132156
132459
|
try {
|
|
132157
132460
|
stat14 = fs99.statSync(fullPath);
|
|
@@ -132165,7 +132468,7 @@ function findSourceFiles2(dir, files = [], stats2 = { skippedDirs: [], skippedFi
|
|
|
132165
132468
|
if (stat14.isDirectory()) {
|
|
132166
132469
|
findSourceFiles2(fullPath, files, stats2);
|
|
132167
132470
|
} else if (stat14.isFile()) {
|
|
132168
|
-
const ext =
|
|
132471
|
+
const ext = path159.extname(fullPath).toLowerCase();
|
|
132169
132472
|
if (SUPPORTED_EXTENSIONS3.includes(ext)) {
|
|
132170
132473
|
files.push(fullPath);
|
|
132171
132474
|
}
|
|
@@ -132222,7 +132525,7 @@ var imports = createSwarmTool({
|
|
|
132222
132525
|
return JSON.stringify(errorResult, null, 2);
|
|
132223
132526
|
}
|
|
132224
132527
|
try {
|
|
132225
|
-
const targetFile =
|
|
132528
|
+
const targetFile = path159.resolve(file3);
|
|
132226
132529
|
if (!fs99.existsSync(targetFile)) {
|
|
132227
132530
|
const errorResult = {
|
|
132228
132531
|
error: `target file not found: ${file3}`,
|
|
@@ -132244,7 +132547,7 @@ var imports = createSwarmTool({
|
|
|
132244
132547
|
};
|
|
132245
132548
|
return JSON.stringify(errorResult, null, 2);
|
|
132246
132549
|
}
|
|
132247
|
-
const baseDir =
|
|
132550
|
+
const baseDir = path159.dirname(targetFile);
|
|
132248
132551
|
const scanStats = {
|
|
132249
132552
|
skippedDirs: [],
|
|
132250
132553
|
skippedFiles: 0,
|
|
@@ -132660,7 +132963,7 @@ init_zod();
|
|
|
132660
132963
|
init_config();
|
|
132661
132964
|
init_knowledge_store();
|
|
132662
132965
|
init_create_tool();
|
|
132663
|
-
import { existsSync as
|
|
132966
|
+
import { existsSync as existsSync90 } from "node:fs";
|
|
132664
132967
|
var DEFAULT_LIMIT = 10;
|
|
132665
132968
|
var MAX_LESSON_LENGTH = 200;
|
|
132666
132969
|
var VALID_CATEGORIES3 = [
|
|
@@ -132736,14 +133039,14 @@ function validateLimit(limit) {
|
|
|
132736
133039
|
}
|
|
132737
133040
|
async function readSwarmKnowledge(directory) {
|
|
132738
133041
|
const swarmPath = resolveSwarmKnowledgePath(directory);
|
|
132739
|
-
if (!
|
|
133042
|
+
if (!existsSync90(swarmPath)) {
|
|
132740
133043
|
return [];
|
|
132741
133044
|
}
|
|
132742
133045
|
return readKnowledge(swarmPath);
|
|
132743
133046
|
}
|
|
132744
133047
|
async function readHiveKnowledge() {
|
|
132745
133048
|
const hivePath = resolveHiveKnowledgePath();
|
|
132746
|
-
if (!
|
|
133049
|
+
if (!existsSync90(hivePath)) {
|
|
132747
133050
|
return [];
|
|
132748
133051
|
}
|
|
132749
133052
|
return readKnowledge(hivePath);
|
|
@@ -133193,11 +133496,11 @@ var lean_turbo_acquire_locks = createSwarmTool({
|
|
|
133193
133496
|
init_zod();
|
|
133194
133497
|
init_constants();
|
|
133195
133498
|
import * as fs101 from "node:fs";
|
|
133196
|
-
import * as
|
|
133499
|
+
import * as path161 from "node:path";
|
|
133197
133500
|
|
|
133198
133501
|
// src/turbo/lean/conflicts.ts
|
|
133199
133502
|
import * as fs100 from "node:fs";
|
|
133200
|
-
import * as
|
|
133503
|
+
import * as path160 from "node:path";
|
|
133201
133504
|
var DEFAULT_GLOBAL_FILES = [
|
|
133202
133505
|
"package.json",
|
|
133203
133506
|
"package-lock.json",
|
|
@@ -133324,7 +133627,7 @@ function isProtectedPath3(normalizedPath) {
|
|
|
133324
133627
|
return false;
|
|
133325
133628
|
}
|
|
133326
133629
|
function readTaskScopes(directory, taskId) {
|
|
133327
|
-
const scopePath =
|
|
133630
|
+
const scopePath = path160.join(directory, ".swarm", "scopes", `scope-${taskId}.json`);
|
|
133328
133631
|
try {
|
|
133329
133632
|
if (!fs100.existsSync(scopePath)) {
|
|
133330
133633
|
return null;
|
|
@@ -133712,7 +134015,7 @@ function createEmptyPlan(phaseNumber, planId) {
|
|
|
133712
134015
|
// src/tools/lean-turbo-plan-lanes.ts
|
|
133713
134016
|
init_create_tool();
|
|
133714
134017
|
function readPlanJson(directory) {
|
|
133715
|
-
const planPath =
|
|
134018
|
+
const planPath = path161.join(directory, ".swarm", "plan.json");
|
|
133716
134019
|
if (!fs101.existsSync(planPath)) {
|
|
133717
134020
|
return null;
|
|
133718
134021
|
}
|
|
@@ -134872,12 +135175,12 @@ var lint_spec = createSwarmTool({
|
|
|
134872
135175
|
// src/tools/mutation-test.ts
|
|
134873
135176
|
init_zod();
|
|
134874
135177
|
import * as fs102 from "node:fs";
|
|
134875
|
-
import * as
|
|
135178
|
+
import * as path163 from "node:path";
|
|
134876
135179
|
|
|
134877
135180
|
// src/mutation/engine.ts
|
|
134878
135181
|
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
134879
|
-
import { unlinkSync as
|
|
134880
|
-
import * as
|
|
135182
|
+
import { unlinkSync as unlinkSync20, writeFileSync as writeFileSync26 } from "node:fs";
|
|
135183
|
+
import * as path162 from "node:path";
|
|
134881
135184
|
|
|
134882
135185
|
// src/mutation/equivalence.ts
|
|
134883
135186
|
function isStaticallyEquivalent(originalCode, mutatedCode) {
|
|
@@ -135040,7 +135343,7 @@ function validateTestCommand(testCommand) {
|
|
|
135040
135343
|
return "testCommand must not be empty";
|
|
135041
135344
|
}
|
|
135042
135345
|
const exe = testCommand[0];
|
|
135043
|
-
const base =
|
|
135346
|
+
const base = path162.basename(exe).replace(/\.(exe|cmd|bat)$/i, "");
|
|
135044
135347
|
if (!ALLOWED_TEST_RUNNERS.has(base)) {
|
|
135045
135348
|
return `testCommand executable '${exe}' is not in the allowed test runner list. Permitted runners: ${[...ALLOWED_TEST_RUNNERS].join(", ")}`;
|
|
135046
135349
|
}
|
|
@@ -135064,9 +135367,9 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
|
|
|
135064
135367
|
let patchFile;
|
|
135065
135368
|
try {
|
|
135066
135369
|
const safeId2 = patch.id.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
135067
|
-
patchFile =
|
|
135370
|
+
patchFile = path162.join(workingDir, `.mutation_patch_${safeId2}.diff`);
|
|
135068
135371
|
try {
|
|
135069
|
-
|
|
135372
|
+
writeFileSync26(patchFile, patch.patch);
|
|
135070
135373
|
} catch (writeErr) {
|
|
135071
135374
|
error93 = `Failed to write patch file: ${writeErr}`;
|
|
135072
135375
|
outcome = "error";
|
|
@@ -135164,7 +135467,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
|
|
|
135164
135467
|
revertError = new Error(`Failed to revert mutation ${patch.id}: ${revertErr}. Working tree may be dirty.`);
|
|
135165
135468
|
}
|
|
135166
135469
|
try {
|
|
135167
|
-
|
|
135470
|
+
unlinkSync20(patchFile);
|
|
135168
135471
|
} catch (_unlinkErr) {}
|
|
135169
135472
|
}
|
|
135170
135473
|
}
|
|
@@ -135481,7 +135784,7 @@ var mutation_test = createSwarmTool({
|
|
|
135481
135784
|
];
|
|
135482
135785
|
for (const filePath of uniquePaths) {
|
|
135483
135786
|
try {
|
|
135484
|
-
const resolvedPath =
|
|
135787
|
+
const resolvedPath = path163.resolve(cwd, filePath);
|
|
135485
135788
|
sourceFiles.set(filePath, fs102.readFileSync(resolvedPath, "utf-8"));
|
|
135486
135789
|
} catch {}
|
|
135487
135790
|
}
|
|
@@ -135504,22 +135807,22 @@ init_schema();
|
|
|
135504
135807
|
init_manager2();
|
|
135505
135808
|
init_task_file();
|
|
135506
135809
|
import * as fs112 from "node:fs";
|
|
135507
|
-
import * as
|
|
135810
|
+
import * as path173 from "node:path";
|
|
135508
135811
|
|
|
135509
135812
|
// src/full-auto/phase-approval.ts
|
|
135510
135813
|
init_utils2();
|
|
135511
135814
|
init_logger();
|
|
135512
135815
|
init_state2();
|
|
135513
135816
|
import * as fs103 from "node:fs";
|
|
135514
|
-
import * as
|
|
135817
|
+
import * as path164 from "node:path";
|
|
135515
135818
|
var APPROVAL_TTL_MS = 24 * 60 * 60 * 1000;
|
|
135516
135819
|
function readEvidenceDir(directory, phase) {
|
|
135517
135820
|
try {
|
|
135518
|
-
const dirPath = validateSwarmPath(directory,
|
|
135821
|
+
const dirPath = validateSwarmPath(directory, path164.posix.join("evidence", String(phase)));
|
|
135519
135822
|
if (!fs103.existsSync(dirPath))
|
|
135520
135823
|
return [];
|
|
135521
135824
|
const entries = fs103.readdirSync(dirPath);
|
|
135522
|
-
return entries.filter((e) => e.startsWith("full-auto-") && e.endsWith(".json")).map((e) =>
|
|
135825
|
+
return entries.filter((e) => e.startsWith("full-auto-") && e.endsWith(".json")).map((e) => path164.join(dirPath, e));
|
|
135523
135826
|
} catch {
|
|
135524
135827
|
return [];
|
|
135525
135828
|
}
|
|
@@ -135774,16 +136077,16 @@ init_plan_schema();
|
|
|
135774
136077
|
init_ledger();
|
|
135775
136078
|
init_manager();
|
|
135776
136079
|
import * as fs104 from "node:fs";
|
|
135777
|
-
import * as
|
|
136080
|
+
import * as path165 from "node:path";
|
|
135778
136081
|
async function writeCheckpoint(directory) {
|
|
135779
136082
|
try {
|
|
135780
136083
|
const plan = await loadPlan(directory);
|
|
135781
136084
|
if (!plan)
|
|
135782
136085
|
return;
|
|
135783
|
-
const swarmDir =
|
|
136086
|
+
const swarmDir = path165.join(directory, ".swarm");
|
|
135784
136087
|
fs104.mkdirSync(swarmDir, { recursive: true });
|
|
135785
|
-
const jsonPath =
|
|
135786
|
-
const mdPath =
|
|
136088
|
+
const jsonPath = path165.join(swarmDir, "SWARM_PLAN.json");
|
|
136089
|
+
const mdPath = path165.join(swarmDir, "SWARM_PLAN.md");
|
|
135787
136090
|
fs104.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
|
|
135788
136091
|
const md = derivePlanMarkdown(plan);
|
|
135789
136092
|
fs104.writeFileSync(mdPath, md, "utf8");
|
|
@@ -135803,7 +136106,7 @@ init_telemetry();
|
|
|
135803
136106
|
// src/turbo/lean/phase-ready.ts
|
|
135804
136107
|
init_file_locks();
|
|
135805
136108
|
import * as fs105 from "node:fs";
|
|
135806
|
-
import * as
|
|
136109
|
+
import * as path166 from "node:path";
|
|
135807
136110
|
init_state3();
|
|
135808
136111
|
var DEFAULT_CONFIG3 = {
|
|
135809
136112
|
phase_reviewer: true,
|
|
@@ -135812,7 +136115,7 @@ var DEFAULT_CONFIG3 = {
|
|
|
135812
136115
|
};
|
|
135813
136116
|
function defaultReadPlanJson(dir) {
|
|
135814
136117
|
try {
|
|
135815
|
-
const planPath =
|
|
136118
|
+
const planPath = path166.join(dir, ".swarm", "plan.json");
|
|
135816
136119
|
if (!fs105.existsSync(planPath))
|
|
135817
136120
|
return null;
|
|
135818
136121
|
const raw = fs105.readFileSync(planPath, "utf-8");
|
|
@@ -135827,7 +136130,7 @@ function defaultReadPlanJson(dir) {
|
|
|
135827
136130
|
}
|
|
135828
136131
|
function readReviewerEvidenceFromFile(directory, phase) {
|
|
135829
136132
|
try {
|
|
135830
|
-
const evidencePath =
|
|
136133
|
+
const evidencePath = path166.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-reviewer.json");
|
|
135831
136134
|
if (!fs105.existsSync(evidencePath)) {
|
|
135832
136135
|
return null;
|
|
135833
136136
|
}
|
|
@@ -135847,7 +136150,7 @@ function readReviewerEvidenceFromFile(directory, phase) {
|
|
|
135847
136150
|
}
|
|
135848
136151
|
function readCriticEvidenceFromFile(directory, phase) {
|
|
135849
136152
|
try {
|
|
135850
|
-
const evidencePath =
|
|
136153
|
+
const evidencePath = path166.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-critic.json");
|
|
135851
136154
|
if (!fs105.existsSync(evidencePath)) {
|
|
135852
136155
|
return null;
|
|
135853
136156
|
}
|
|
@@ -135866,7 +136169,7 @@ function readCriticEvidenceFromFile(directory, phase) {
|
|
|
135866
136169
|
}
|
|
135867
136170
|
}
|
|
135868
136171
|
function listLaneEvidenceSync(directory, phase) {
|
|
135869
|
-
const evidenceDir =
|
|
136172
|
+
const evidenceDir = path166.join(directory, ".swarm", "evidence", String(phase), "lean-turbo");
|
|
135870
136173
|
let entries;
|
|
135871
136174
|
try {
|
|
135872
136175
|
entries = fs105.readdirSync(evidenceDir);
|
|
@@ -135936,7 +136239,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
135936
136239
|
...DEFAULT_CONFIG3,
|
|
135937
136240
|
...actualConfig
|
|
135938
136241
|
};
|
|
135939
|
-
const statePath =
|
|
136242
|
+
const statePath = path166.join(directory, ".swarm", "turbo-state.json");
|
|
135940
136243
|
if (!fs105.existsSync(statePath)) {
|
|
135941
136244
|
return {
|
|
135942
136245
|
ok: false,
|
|
@@ -136124,7 +136427,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
136124
136427
|
}
|
|
136125
136428
|
}
|
|
136126
136429
|
if (mergedConfig.integrated_diff_required) {
|
|
136127
|
-
const evidencePath =
|
|
136430
|
+
const evidencePath = path166.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-phase.json");
|
|
136128
136431
|
let hasDiff = false;
|
|
136129
136432
|
try {
|
|
136130
136433
|
const content = fs105.readFileSync(evidencePath, "utf-8");
|
|
@@ -136290,7 +136593,7 @@ async function runCompletionVerifyGate(ctx) {
|
|
|
136290
136593
|
// src/tools/phase-complete/gates/drift-gate.ts
|
|
136291
136594
|
init_effective_spec();
|
|
136292
136595
|
import * as fs106 from "node:fs";
|
|
136293
|
-
import * as
|
|
136596
|
+
import * as path167 from "node:path";
|
|
136294
136597
|
|
|
136295
136598
|
// src/tools/phase-complete/gates/gate-helpers.ts
|
|
136296
136599
|
init_qa_gate_profile();
|
|
@@ -136339,7 +136642,7 @@ async function runDriftGate(ctx) {
|
|
|
136339
136642
|
}
|
|
136340
136643
|
let phaseType;
|
|
136341
136644
|
try {
|
|
136342
|
-
const planPath =
|
|
136645
|
+
const planPath = path167.join(dir, ".swarm", "plan.json");
|
|
136343
136646
|
if (fs106.existsSync(planPath)) {
|
|
136344
136647
|
const planRaw = fs106.readFileSync(planPath, "utf-8");
|
|
136345
136648
|
const plan = JSON.parse(planRaw);
|
|
@@ -136358,7 +136661,7 @@ async function runDriftGate(ctx) {
|
|
|
136358
136661
|
};
|
|
136359
136662
|
}
|
|
136360
136663
|
try {
|
|
136361
|
-
const driftEvidencePath =
|
|
136664
|
+
const driftEvidencePath = path167.join(dir, ".swarm", "evidence", String(phase), "drift-verifier.json");
|
|
136362
136665
|
let driftVerdictFound = false;
|
|
136363
136666
|
let driftVerdictApproved = false;
|
|
136364
136667
|
try {
|
|
@@ -136399,7 +136702,7 @@ async function runDriftGate(ctx) {
|
|
|
136399
136702
|
let incompleteTaskCount = 0;
|
|
136400
136703
|
let planParseable = false;
|
|
136401
136704
|
try {
|
|
136402
|
-
const planPath =
|
|
136705
|
+
const planPath = path167.join(dir, ".swarm", "plan.json");
|
|
136403
136706
|
if (fs106.existsSync(planPath)) {
|
|
136404
136707
|
const planRaw = fs106.readFileSync(planPath, "utf-8");
|
|
136405
136708
|
const plan = JSON.parse(planRaw);
|
|
@@ -136478,7 +136781,7 @@ async function runDriftGate(ctx) {
|
|
|
136478
136781
|
}
|
|
136479
136782
|
// src/tools/phase-complete/gates/final-council-gate.ts
|
|
136480
136783
|
import * as fs107 from "node:fs";
|
|
136481
|
-
import * as
|
|
136784
|
+
import * as path168 from "node:path";
|
|
136482
136785
|
async function runFinalCouncilGate(ctx) {
|
|
136483
136786
|
const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
|
|
136484
136787
|
let finalCouncilEnabled = false;
|
|
@@ -136501,7 +136804,7 @@ async function runFinalCouncilGate(ctx) {
|
|
|
136501
136804
|
if (lastPhaseId !== undefined && phase === lastPhaseId) {
|
|
136502
136805
|
if (preamble.effectiveGates?.final_council === true) {
|
|
136503
136806
|
finalCouncilEnabled = true;
|
|
136504
|
-
const fcPath =
|
|
136807
|
+
const fcPath = path168.join(dir, ".swarm", "evidence", "final-council.json");
|
|
136505
136808
|
let fcVerdictFound = false;
|
|
136506
136809
|
let _fcVerdict;
|
|
136507
136810
|
try {
|
|
@@ -136655,13 +136958,13 @@ async function runFinalCouncilGate(ctx) {
|
|
|
136655
136958
|
}
|
|
136656
136959
|
// src/tools/phase-complete/gates/hallucination-gate.ts
|
|
136657
136960
|
import * as fs108 from "node:fs";
|
|
136658
|
-
import * as
|
|
136961
|
+
import * as path169 from "node:path";
|
|
136659
136962
|
async function runHallucinationGate(ctx) {
|
|
136660
136963
|
const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
|
|
136661
136964
|
try {
|
|
136662
136965
|
const preamble = await resolveGatePreamble(dir, sessionID);
|
|
136663
136966
|
if (preamble.resolved && preamble.effectiveGates?.hallucination_guard === true) {
|
|
136664
|
-
const hgPath =
|
|
136967
|
+
const hgPath = path169.join(dir, ".swarm", "evidence", String(phase), "hallucination-guard.json");
|
|
136665
136968
|
let hgVerdictFound = false;
|
|
136666
136969
|
let hgVerdictApproved = false;
|
|
136667
136970
|
try {
|
|
@@ -136719,13 +137022,13 @@ async function runHallucinationGate(ctx) {
|
|
|
136719
137022
|
}
|
|
136720
137023
|
// src/tools/phase-complete/gates/mutation-gate.ts
|
|
136721
137024
|
import * as fs109 from "node:fs";
|
|
136722
|
-
import * as
|
|
137025
|
+
import * as path170 from "node:path";
|
|
136723
137026
|
async function runMutationGate(ctx) {
|
|
136724
137027
|
const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
|
|
136725
137028
|
try {
|
|
136726
137029
|
const preamble = await resolveGatePreamble(dir, sessionID);
|
|
136727
137030
|
if (preamble.resolved && preamble.effectiveGates?.mutation_test === true) {
|
|
136728
|
-
const mgPath =
|
|
137031
|
+
const mgPath = path170.join(dir, ".swarm", "evidence", String(phase), "mutation-gate.json");
|
|
136729
137032
|
let mgVerdictFound = false;
|
|
136730
137033
|
let mgVerdict;
|
|
136731
137034
|
try {
|
|
@@ -136783,7 +137086,7 @@ async function runMutationGate(ctx) {
|
|
|
136783
137086
|
}
|
|
136784
137087
|
// src/tools/phase-complete/gates/phase-council-gate.ts
|
|
136785
137088
|
import * as fs110 from "node:fs";
|
|
136786
|
-
import * as
|
|
137089
|
+
import * as path171 from "node:path";
|
|
136787
137090
|
async function runPhaseCouncilGate(ctx) {
|
|
136788
137091
|
const { phase, dir, sessionID, pluginConfig, agentsDispatched, safeWarn } = ctx;
|
|
136789
137092
|
const gateWarnings = [];
|
|
@@ -136792,7 +137095,7 @@ async function runPhaseCouncilGate(ctx) {
|
|
|
136792
137095
|
const preamble = await resolveGatePreamble(dir, sessionID);
|
|
136793
137096
|
if (preamble.resolved && preamble.effectiveGates?.phase_council === true && pluginConfig.council?.enabled === true) {
|
|
136794
137097
|
councilModeEnabled = true;
|
|
136795
|
-
const pcPath =
|
|
137098
|
+
const pcPath = path171.join(dir, ".swarm", "evidence", String(phase), "phase-council.json");
|
|
136796
137099
|
let pcVerdictFound = false;
|
|
136797
137100
|
let _pcVerdict;
|
|
136798
137101
|
let pcQuorumSize;
|
|
@@ -137359,7 +137662,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
137359
137662
|
}
|
|
137360
137663
|
if (retroFound && retroEntry?.lessons_learned && retroEntry.lessons_learned.length > 0) {
|
|
137361
137664
|
try {
|
|
137362
|
-
const projectName =
|
|
137665
|
+
const projectName = path173.basename(dir);
|
|
137363
137666
|
const curationResult = await curateAndStoreSwarm(retroEntry.lessons_learned, projectName, { phase_number: phase }, dir, knowledgeConfig, {
|
|
137364
137667
|
llmDelegate: createCuratorLLMDelegate(dir, "phase", sessionID),
|
|
137365
137668
|
enrichmentQuota: {
|
|
@@ -137921,7 +138224,7 @@ init_utils();
|
|
|
137921
138224
|
init_bun_compat();
|
|
137922
138225
|
init_create_tool();
|
|
137923
138226
|
import * as fs113 from "node:fs";
|
|
137924
|
-
import * as
|
|
138227
|
+
import * as path174 from "node:path";
|
|
137925
138228
|
var MAX_OUTPUT_BYTES7 = 52428800;
|
|
137926
138229
|
var AUDIT_TIMEOUT_MS = 120000;
|
|
137927
138230
|
function isValidEcosystem(value) {
|
|
@@ -137949,16 +138252,16 @@ function validateArgs3(args2) {
|
|
|
137949
138252
|
function detectEcosystems(directory) {
|
|
137950
138253
|
const ecosystems = [];
|
|
137951
138254
|
const cwd = directory;
|
|
137952
|
-
if (fs113.existsSync(
|
|
138255
|
+
if (fs113.existsSync(path174.join(cwd, "package.json"))) {
|
|
137953
138256
|
ecosystems.push("npm");
|
|
137954
138257
|
}
|
|
137955
|
-
if (fs113.existsSync(
|
|
138258
|
+
if (fs113.existsSync(path174.join(cwd, "pyproject.toml")) || fs113.existsSync(path174.join(cwd, "requirements.txt"))) {
|
|
137956
138259
|
ecosystems.push("pip");
|
|
137957
138260
|
}
|
|
137958
|
-
if (fs113.existsSync(
|
|
138261
|
+
if (fs113.existsSync(path174.join(cwd, "Cargo.toml"))) {
|
|
137959
138262
|
ecosystems.push("cargo");
|
|
137960
138263
|
}
|
|
137961
|
-
if (fs113.existsSync(
|
|
138264
|
+
if (fs113.existsSync(path174.join(cwd, "go.mod"))) {
|
|
137962
138265
|
ecosystems.push("go");
|
|
137963
138266
|
}
|
|
137964
138267
|
try {
|
|
@@ -137967,13 +138270,13 @@ function detectEcosystems(directory) {
|
|
|
137967
138270
|
ecosystems.push("dotnet");
|
|
137968
138271
|
}
|
|
137969
138272
|
} catch {}
|
|
137970
|
-
if (fs113.existsSync(
|
|
138273
|
+
if (fs113.existsSync(path174.join(cwd, "Gemfile")) || fs113.existsSync(path174.join(cwd, "Gemfile.lock"))) {
|
|
137971
138274
|
ecosystems.push("ruby");
|
|
137972
138275
|
}
|
|
137973
|
-
if (fs113.existsSync(
|
|
138276
|
+
if (fs113.existsSync(path174.join(cwd, "pubspec.yaml"))) {
|
|
137974
138277
|
ecosystems.push("dart");
|
|
137975
138278
|
}
|
|
137976
|
-
if (fs113.existsSync(
|
|
138279
|
+
if (fs113.existsSync(path174.join(cwd, "composer.lock"))) {
|
|
137977
138280
|
ecosystems.push("composer");
|
|
137978
138281
|
}
|
|
137979
138282
|
return ecosystems;
|
|
@@ -139110,7 +139413,7 @@ var pkg_audit = createSwarmTool({
|
|
|
139110
139413
|
init_zod();
|
|
139111
139414
|
init_manager2();
|
|
139112
139415
|
import * as fs114 from "node:fs";
|
|
139113
|
-
import * as
|
|
139416
|
+
import * as path175 from "node:path";
|
|
139114
139417
|
init_utils();
|
|
139115
139418
|
init_create_tool();
|
|
139116
139419
|
var MAX_FILE_SIZE = 1024 * 1024;
|
|
@@ -139233,7 +139536,7 @@ function isScaffoldFile(filePath) {
|
|
|
139233
139536
|
if (SCAFFOLD_PATH_PATTERNS.some((pattern) => pattern.test(normalizedPath))) {
|
|
139234
139537
|
return true;
|
|
139235
139538
|
}
|
|
139236
|
-
const filename =
|
|
139539
|
+
const filename = path175.basename(filePath);
|
|
139237
139540
|
if (SCAFFOLD_FILENAME_PATTERNS.some((pattern) => pattern.test(filename))) {
|
|
139238
139541
|
return true;
|
|
139239
139542
|
}
|
|
@@ -139250,7 +139553,7 @@ function isAllowedByGlobs(filePath, allowGlobs) {
|
|
|
139250
139553
|
if (regex.test(normalizedPath)) {
|
|
139251
139554
|
return true;
|
|
139252
139555
|
}
|
|
139253
|
-
const filename =
|
|
139556
|
+
const filename = path175.basename(filePath);
|
|
139254
139557
|
const filenameRegex = new RegExp(`^${regexPattern}$`, "i");
|
|
139255
139558
|
if (filenameRegex.test(filename)) {
|
|
139256
139559
|
return true;
|
|
@@ -139259,7 +139562,7 @@ function isAllowedByGlobs(filePath, allowGlobs) {
|
|
|
139259
139562
|
return false;
|
|
139260
139563
|
}
|
|
139261
139564
|
function isParserSupported(filePath) {
|
|
139262
|
-
const ext =
|
|
139565
|
+
const ext = path175.extname(filePath).toLowerCase();
|
|
139263
139566
|
return SUPPORTED_PARSER_EXTENSIONS.has(ext);
|
|
139264
139567
|
}
|
|
139265
139568
|
function isPlanFile(filePath) {
|
|
@@ -139506,9 +139809,9 @@ async function placeholderScan(input, directory) {
|
|
|
139506
139809
|
let filesScanned = 0;
|
|
139507
139810
|
const filesWithFindings = new Set;
|
|
139508
139811
|
for (const filePath of changed_files) {
|
|
139509
|
-
const fullPath =
|
|
139510
|
-
const resolvedDirectory =
|
|
139511
|
-
if (!fullPath.startsWith(resolvedDirectory +
|
|
139812
|
+
const fullPath = path175.isAbsolute(filePath) ? filePath : path175.resolve(directory, filePath);
|
|
139813
|
+
const resolvedDirectory = path175.resolve(directory);
|
|
139814
|
+
if (!fullPath.startsWith(resolvedDirectory + path175.sep) && fullPath !== resolvedDirectory) {
|
|
139512
139815
|
continue;
|
|
139513
139816
|
}
|
|
139514
139817
|
if (!fs114.existsSync(fullPath)) {
|
|
@@ -139517,7 +139820,7 @@ async function placeholderScan(input, directory) {
|
|
|
139517
139820
|
if (isAllowedByGlobs(filePath, allow_globs)) {
|
|
139518
139821
|
continue;
|
|
139519
139822
|
}
|
|
139520
|
-
const relativeFilePath =
|
|
139823
|
+
const relativeFilePath = path175.relative(directory, fullPath).replace(/\\/g, "/");
|
|
139521
139824
|
if (FILE_ALLOWLIST.some((allowed) => relativeFilePath.endsWith(allowed))) {
|
|
139522
139825
|
continue;
|
|
139523
139826
|
}
|
|
@@ -139590,7 +139893,7 @@ var placeholder_scan = createSwarmTool({
|
|
|
139590
139893
|
|
|
139591
139894
|
// src/tools/pre-check-batch.ts
|
|
139592
139895
|
import * as fs118 from "node:fs";
|
|
139593
|
-
import * as
|
|
139896
|
+
import * as path179 from "node:path";
|
|
139594
139897
|
init_zod();
|
|
139595
139898
|
init_manager2();
|
|
139596
139899
|
init_utils();
|
|
@@ -139731,7 +140034,7 @@ init_zod();
|
|
|
139731
140034
|
init_manager2();
|
|
139732
140035
|
init_detector();
|
|
139733
140036
|
import * as fs117 from "node:fs";
|
|
139734
|
-
import * as
|
|
140037
|
+
import * as path178 from "node:path";
|
|
139735
140038
|
import { extname as extname19 } from "node:path";
|
|
139736
140039
|
|
|
139737
140040
|
// src/sast/rules/c.ts
|
|
@@ -140441,7 +140744,7 @@ function executeRulesSync(filePath, content, language) {
|
|
|
140441
140744
|
// src/sast/semgrep.ts
|
|
140442
140745
|
import * as child_process13 from "node:child_process";
|
|
140443
140746
|
import * as fs115 from "node:fs";
|
|
140444
|
-
import * as
|
|
140747
|
+
import * as path176 from "node:path";
|
|
140445
140748
|
var semgrepAvailableCache = null;
|
|
140446
140749
|
var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
|
|
140447
140750
|
var DEFAULT_TIMEOUT_MS4 = 30000;
|
|
@@ -140728,7 +141031,7 @@ async function runSemgrep(options) {
|
|
|
140728
141031
|
}
|
|
140729
141032
|
function getRulesDirectory(projectRoot) {
|
|
140730
141033
|
if (projectRoot) {
|
|
140731
|
-
return
|
|
141034
|
+
return path176.resolve(projectRoot, DEFAULT_RULES_DIR);
|
|
140732
141035
|
}
|
|
140733
141036
|
return DEFAULT_RULES_DIR;
|
|
140734
141037
|
}
|
|
@@ -140749,24 +141052,24 @@ init_create_tool();
|
|
|
140749
141052
|
init_utils2();
|
|
140750
141053
|
import * as crypto12 from "node:crypto";
|
|
140751
141054
|
import * as fs116 from "node:fs";
|
|
140752
|
-
import * as
|
|
141055
|
+
import * as path177 from "node:path";
|
|
140753
141056
|
var BASELINE_SCHEMA_VERSION = "1.0.0";
|
|
140754
141057
|
var MAX_BASELINE_FINDINGS = 2000;
|
|
140755
141058
|
var MAX_BASELINE_BYTES = 2 * 1048576;
|
|
140756
141059
|
var LOCK_RETRY_DELAYS_MS = [50, 100, 200, 400, 800];
|
|
140757
141060
|
function normalizeFindingPath(directory, file3) {
|
|
140758
|
-
const resolved =
|
|
140759
|
-
const rel =
|
|
141061
|
+
const resolved = path177.isAbsolute(file3) ? file3 : path177.resolve(directory, file3);
|
|
141062
|
+
const rel = path177.relative(path177.resolve(directory), resolved);
|
|
140760
141063
|
return rel.replace(/\\/g, "/");
|
|
140761
141064
|
}
|
|
140762
141065
|
function baselineRelPath(phase) {
|
|
140763
|
-
return
|
|
141066
|
+
return path177.join("evidence", String(phase), "sast-baseline.json");
|
|
140764
141067
|
}
|
|
140765
141068
|
function tempRelPath(phase) {
|
|
140766
|
-
return
|
|
141069
|
+
return path177.join("evidence", String(phase), `sast-baseline.json.tmp.${Date.now()}.${process.pid}`);
|
|
140767
141070
|
}
|
|
140768
141071
|
function lockRelPath(phase) {
|
|
140769
|
-
return
|
|
141072
|
+
return path177.join("evidence", String(phase), "sast-baseline.json.lock");
|
|
140770
141073
|
}
|
|
140771
141074
|
function getLine(lines, idx) {
|
|
140772
141075
|
if (idx < 0 || idx >= lines.length)
|
|
@@ -140887,8 +141190,8 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
140887
141190
|
message: e instanceof Error ? e.message : "Path validation failed"
|
|
140888
141191
|
};
|
|
140889
141192
|
}
|
|
140890
|
-
fs116.mkdirSync(
|
|
140891
|
-
fs116.mkdirSync(
|
|
141193
|
+
fs116.mkdirSync(path177.dirname(baselinePath), { recursive: true });
|
|
141194
|
+
fs116.mkdirSync(path177.dirname(tempPath), { recursive: true });
|
|
140892
141195
|
const releaseLock = await acquireLock2(lockPath);
|
|
140893
141196
|
try {
|
|
140894
141197
|
let existing = null;
|
|
@@ -141161,9 +141464,9 @@ async function sastScan(input, directory, config3) {
|
|
|
141161
141464
|
_filesSkipped++;
|
|
141162
141465
|
continue;
|
|
141163
141466
|
}
|
|
141164
|
-
const resolvedPath =
|
|
141165
|
-
const resolvedDirectory =
|
|
141166
|
-
if (!resolvedPath.startsWith(resolvedDirectory +
|
|
141467
|
+
const resolvedPath = path178.isAbsolute(filePath) ? filePath : path178.resolve(directory, filePath);
|
|
141468
|
+
const resolvedDirectory = path178.resolve(directory);
|
|
141469
|
+
if (!resolvedPath.startsWith(resolvedDirectory + path178.sep) && resolvedPath !== resolvedDirectory) {
|
|
141167
141470
|
_filesSkipped++;
|
|
141168
141471
|
continue;
|
|
141169
141472
|
}
|
|
@@ -141478,18 +141781,18 @@ function validatePath(inputPath, baseDir, workspaceDir) {
|
|
|
141478
141781
|
let resolved;
|
|
141479
141782
|
const isWinAbs = isWindowsAbsolutePath(inputPath);
|
|
141480
141783
|
if (isWinAbs) {
|
|
141481
|
-
resolved =
|
|
141482
|
-
} else if (
|
|
141483
|
-
resolved =
|
|
141784
|
+
resolved = path179.win32.resolve(inputPath);
|
|
141785
|
+
} else if (path179.isAbsolute(inputPath)) {
|
|
141786
|
+
resolved = path179.resolve(inputPath);
|
|
141484
141787
|
} else {
|
|
141485
|
-
resolved =
|
|
141788
|
+
resolved = path179.resolve(baseDir, inputPath);
|
|
141486
141789
|
}
|
|
141487
|
-
const workspaceResolved =
|
|
141790
|
+
const workspaceResolved = path179.resolve(workspaceDir);
|
|
141488
141791
|
let relative36;
|
|
141489
141792
|
if (isWinAbs) {
|
|
141490
|
-
relative36 =
|
|
141793
|
+
relative36 = path179.win32.relative(workspaceResolved, resolved);
|
|
141491
141794
|
} else {
|
|
141492
|
-
relative36 =
|
|
141795
|
+
relative36 = path179.relative(workspaceResolved, resolved);
|
|
141493
141796
|
}
|
|
141494
141797
|
if (relative36.startsWith("..")) {
|
|
141495
141798
|
return "path traversal detected";
|
|
@@ -141554,7 +141857,7 @@ async function runLintOnFiles(linter, files, workspaceDir) {
|
|
|
141554
141857
|
if (typeof file3 !== "string") {
|
|
141555
141858
|
continue;
|
|
141556
141859
|
}
|
|
141557
|
-
const resolvedPath =
|
|
141860
|
+
const resolvedPath = path179.resolve(file3);
|
|
141558
141861
|
const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
|
|
141559
141862
|
if (validationError) {
|
|
141560
141863
|
continue;
|
|
@@ -141711,7 +142014,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
141711
142014
|
skippedFiles++;
|
|
141712
142015
|
continue;
|
|
141713
142016
|
}
|
|
141714
|
-
const resolvedPath =
|
|
142017
|
+
const resolvedPath = path179.resolve(file3);
|
|
141715
142018
|
const validationError = validatePath(resolvedPath, directory, directory);
|
|
141716
142019
|
if (validationError) {
|
|
141717
142020
|
skippedFiles++;
|
|
@@ -141729,7 +142032,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
141729
142032
|
};
|
|
141730
142033
|
}
|
|
141731
142034
|
for (const file3 of validatedFiles) {
|
|
141732
|
-
const ext =
|
|
142035
|
+
const ext = path179.extname(file3).toLowerCase();
|
|
141733
142036
|
if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
|
|
141734
142037
|
skippedFiles++;
|
|
141735
142038
|
continue;
|
|
@@ -141948,7 +142251,7 @@ function classifySastFindings(findings, changedLineRanges, directory) {
|
|
|
141948
142251
|
const preexistingFindings = [];
|
|
141949
142252
|
for (const finding of findings) {
|
|
141950
142253
|
const filePath = finding.location.file;
|
|
141951
|
-
const normalised =
|
|
142254
|
+
const normalised = path179.relative(directory, filePath).replace(/\\/g, "/");
|
|
141952
142255
|
const changedLines = changedLineRanges.get(normalised);
|
|
141953
142256
|
if (changedLines?.has(finding.location.line)) {
|
|
141954
142257
|
newFindings.push(finding);
|
|
@@ -141999,7 +142302,7 @@ async function runPreCheckBatch(input, workspaceDir, contextDir) {
|
|
|
141999
142302
|
warn(`pre_check_batch: Invalid file path: ${file3}`);
|
|
142000
142303
|
continue;
|
|
142001
142304
|
}
|
|
142002
|
-
changedFiles.push(
|
|
142305
|
+
changedFiles.push(path179.resolve(directory, file3));
|
|
142003
142306
|
}
|
|
142004
142307
|
if (changedFiles.length === 0) {
|
|
142005
142308
|
warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
|
|
@@ -142200,9 +142503,9 @@ var pre_check_batch = createSwarmTool({
|
|
|
142200
142503
|
};
|
|
142201
142504
|
return JSON.stringify(errorResult, null, 2);
|
|
142202
142505
|
}
|
|
142203
|
-
const resolvedDirectory =
|
|
142204
|
-
const workspaceAnchor =
|
|
142205
|
-
if (resolvedDirectory !== workspaceAnchor && resolvedDirectory.startsWith(workspaceAnchor +
|
|
142506
|
+
const resolvedDirectory = path179.resolve(typedArgs.directory);
|
|
142507
|
+
const workspaceAnchor = path179.resolve(directory);
|
|
142508
|
+
if (resolvedDirectory !== workspaceAnchor && resolvedDirectory.startsWith(workspaceAnchor + path179.sep)) {
|
|
142206
142509
|
const subDirError = `directory "${typedArgs.directory}" is a subdirectory of the project root — pre_check_batch requires the project root directory "${workspaceAnchor}"`;
|
|
142207
142510
|
const subDirResult = {
|
|
142208
142511
|
gates_passed: false,
|
|
@@ -142256,7 +142559,7 @@ var pre_check_batch = createSwarmTool({
|
|
|
142256
142559
|
init_zod();
|
|
142257
142560
|
init_path_security();
|
|
142258
142561
|
init_create_tool();
|
|
142259
|
-
import * as
|
|
142562
|
+
import * as path180 from "node:path";
|
|
142260
142563
|
var VALID_ACTIONS = [
|
|
142261
142564
|
"build",
|
|
142262
142565
|
"importers",
|
|
@@ -142282,7 +142585,7 @@ function validateFile(p) {
|
|
|
142282
142585
|
return "file contains control characters";
|
|
142283
142586
|
if (containsPathTraversal(p))
|
|
142284
142587
|
return "file contains path traversal";
|
|
142285
|
-
if (
|
|
142588
|
+
if (path180.isAbsolute(p) || /^[a-zA-Z]:[\\/]/.test(p)) {
|
|
142286
142589
|
return "file must be a workspace-relative path, not absolute";
|
|
142287
142590
|
}
|
|
142288
142591
|
return null;
|
|
@@ -142305,8 +142608,8 @@ function ok(action, payload) {
|
|
|
142305
142608
|
}
|
|
142306
142609
|
function toRelativeGraphPath(input, workspaceRoot) {
|
|
142307
142610
|
const normalized = input.replace(/\\/g, "/");
|
|
142308
|
-
if (
|
|
142309
|
-
const rel =
|
|
142611
|
+
if (path180.isAbsolute(normalized)) {
|
|
142612
|
+
const rel = path180.relative(workspaceRoot, normalized).replace(/\\/g, "/");
|
|
142310
142613
|
return normalizeGraphPath(rel);
|
|
142311
142614
|
}
|
|
142312
142615
|
return normalizeGraphPath(normalized);
|
|
@@ -142498,7 +142801,7 @@ init_zod();
|
|
|
142498
142801
|
init_effective_spec();
|
|
142499
142802
|
init_create_tool();
|
|
142500
142803
|
import * as fs119 from "node:fs";
|
|
142501
|
-
import * as
|
|
142804
|
+
import * as path181 from "node:path";
|
|
142502
142805
|
var EVIDENCE_DIR4 = ".swarm/evidence";
|
|
142503
142806
|
var OBLIGATION_KEYWORDS2 = ["MUST", "SHOULD", "SHALL"];
|
|
142504
142807
|
var MAX_FILE_SIZE_BYTES8 = 1024 * 1024;
|
|
@@ -142566,7 +142869,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
142566
142869
|
return [];
|
|
142567
142870
|
}
|
|
142568
142871
|
for (const entry of entries) {
|
|
142569
|
-
const entryPath =
|
|
142872
|
+
const entryPath = path181.join(evidenceDir, entry);
|
|
142570
142873
|
try {
|
|
142571
142874
|
const stat14 = fs119.statSync(entryPath);
|
|
142572
142875
|
if (!stat14.isDirectory()) {
|
|
@@ -142582,11 +142885,11 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
142582
142885
|
if (entryPhase !== String(phase)) {
|
|
142583
142886
|
continue;
|
|
142584
142887
|
}
|
|
142585
|
-
const evidenceFilePath =
|
|
142888
|
+
const evidenceFilePath = path181.join(entryPath, "evidence.json");
|
|
142586
142889
|
try {
|
|
142587
|
-
const resolvedPath =
|
|
142588
|
-
const evidenceDirResolved =
|
|
142589
|
-
if (!resolvedPath.startsWith(evidenceDirResolved +
|
|
142890
|
+
const resolvedPath = path181.resolve(evidenceFilePath);
|
|
142891
|
+
const evidenceDirResolved = path181.resolve(evidenceDir);
|
|
142892
|
+
if (!resolvedPath.startsWith(evidenceDirResolved + path181.sep)) {
|
|
142590
142893
|
continue;
|
|
142591
142894
|
}
|
|
142592
142895
|
const stat14 = fs119.lstatSync(evidenceFilePath);
|
|
@@ -142620,7 +142923,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
142620
142923
|
if (Array.isArray(diffEntry.files_changed)) {
|
|
142621
142924
|
for (const file3 of diffEntry.files_changed) {
|
|
142622
142925
|
if (typeof file3 === "string") {
|
|
142623
|
-
touchedFiles.add(
|
|
142926
|
+
touchedFiles.add(path181.resolve(cwd, file3));
|
|
142624
142927
|
}
|
|
142625
142928
|
}
|
|
142626
142929
|
}
|
|
@@ -142633,8 +142936,8 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
142633
142936
|
}
|
|
142634
142937
|
function searchFileForKeywords(filePath, keywords, cwd) {
|
|
142635
142938
|
try {
|
|
142636
|
-
const resolvedPath =
|
|
142637
|
-
const cwdResolved =
|
|
142939
|
+
const resolvedPath = path181.resolve(filePath);
|
|
142940
|
+
const cwdResolved = path181.resolve(cwd);
|
|
142638
142941
|
if (!resolvedPath.startsWith(cwdResolved)) {
|
|
142639
142942
|
return false;
|
|
142640
142943
|
}
|
|
@@ -142793,7 +143096,7 @@ var req_coverage = createSwarmTool({
|
|
|
142793
143096
|
message: "No FR requirements found in spec.md"
|
|
142794
143097
|
}, null, 2);
|
|
142795
143098
|
}
|
|
142796
|
-
const evidenceDir =
|
|
143099
|
+
const evidenceDir = path181.join(cwd, EVIDENCE_DIR4);
|
|
142797
143100
|
const touchedFiles = readTouchedFiles(evidenceDir, phase, cwd);
|
|
142798
143101
|
const analyzedRequirements = [];
|
|
142799
143102
|
let coveredCount = 0;
|
|
@@ -142819,7 +143122,7 @@ var req_coverage = createSwarmTool({
|
|
|
142819
143122
|
requirements: analyzedRequirements
|
|
142820
143123
|
};
|
|
142821
143124
|
const reportFilename = `req-coverage-phase-${phase}.json`;
|
|
142822
|
-
const reportPath =
|
|
143125
|
+
const reportPath = path181.join(evidenceDir, reportFilename);
|
|
142823
143126
|
try {
|
|
142824
143127
|
if (!fs119.existsSync(evidenceDir)) {
|
|
142825
143128
|
fs119.mkdirSync(evidenceDir, { recursive: true });
|
|
@@ -142832,6 +143135,72 @@ var req_coverage = createSwarmTool({
|
|
|
142832
143135
|
}
|
|
142833
143136
|
});
|
|
142834
143137
|
|
|
143138
|
+
// src/tools/retrieve-lane-output.ts
|
|
143139
|
+
init_zod();
|
|
143140
|
+
init_create_tool();
|
|
143141
|
+
var RetrieveLaneOutputArgsSchema = exports_external.object({
|
|
143142
|
+
ref: exports_external.string().min(1).describe("Opaque lane output ref returned as output_ref by dispatch tools."),
|
|
143143
|
+
offset: exports_external.number().int().min(0).default(0).describe("Line offset to start from."),
|
|
143144
|
+
limit: exports_external.number().int().min(1).max(500).default(100).describe("Number of lines to return, max 500.")
|
|
143145
|
+
});
|
|
143146
|
+
var retrieve_lane_output = createSwarmTool({
|
|
143147
|
+
description: "Retrieve paged full output for a dispatch_lanes or collect_lane_results lane by output_ref. Use when a lane preview is truncated, degraded, or needs candidate routing from full text.",
|
|
143148
|
+
args: {
|
|
143149
|
+
ref: RetrieveLaneOutputArgsSchema.shape.ref,
|
|
143150
|
+
offset: RetrieveLaneOutputArgsSchema.shape.offset,
|
|
143151
|
+
limit: RetrieveLaneOutputArgsSchema.shape.limit
|
|
143152
|
+
},
|
|
143153
|
+
async execute(args2, directory) {
|
|
143154
|
+
const parsed = RetrieveLaneOutputArgsSchema.safeParse(args2);
|
|
143155
|
+
if (!parsed.success) {
|
|
143156
|
+
return JSON.stringify({
|
|
143157
|
+
success: false,
|
|
143158
|
+
failure_class: "invalid_args",
|
|
143159
|
+
message: "Invalid retrieve_lane_output arguments",
|
|
143160
|
+
errors: parsed.error.issues.map((issue3) => `${issue3.path.join(".")}: ${issue3.message}`)
|
|
143161
|
+
}, null, 2);
|
|
143162
|
+
}
|
|
143163
|
+
let loaded;
|
|
143164
|
+
try {
|
|
143165
|
+
loaded = readLaneOutput(directory, parsed.data.ref);
|
|
143166
|
+
} catch {
|
|
143167
|
+
loaded = null;
|
|
143168
|
+
}
|
|
143169
|
+
if (!loaded) {
|
|
143170
|
+
return JSON.stringify({
|
|
143171
|
+
success: false,
|
|
143172
|
+
failure_class: "not_found",
|
|
143173
|
+
message: `No lane output artifact found for ${parsed.data.ref}`
|
|
143174
|
+
}, null, 2);
|
|
143175
|
+
}
|
|
143176
|
+
const page = paginateLaneOutput(loaded.artifact.text, parsed.data.offset, Math.min(parsed.data.limit, 500));
|
|
143177
|
+
if (page.exhausted) {
|
|
143178
|
+
return `--- Lane output ${loaded.artifact.ref} offset beyond range ---
|
|
143179
|
+
` + `Lane: ${loaded.artifact.laneId} (${loaded.artifact.agent})
|
|
143180
|
+
` + `Digest: ${loaded.artifact.digest}
|
|
143181
|
+
` + `Content has ${page.totalLines} line${page.totalLines === 1 ? "" : "s"}.`;
|
|
143182
|
+
}
|
|
143183
|
+
const header = `--- Lane output ${loaded.artifact.ref} lines ${page.startLine + 1}-${page.endLine} of ${page.totalLines} ---
|
|
143184
|
+
` + `Batch: ${loaded.artifact.batchId}
|
|
143185
|
+
` + `Lane: ${loaded.artifact.laneId}
|
|
143186
|
+
` + `Agent: ${loaded.artifact.agent}
|
|
143187
|
+
` + `Source: ${loaded.artifact.source}
|
|
143188
|
+
` + `Digest: ${loaded.artifact.digest}
|
|
143189
|
+
` + `Chars: ${loaded.artifact.chars}
|
|
143190
|
+
` + (loaded.artifact.transcriptIncomplete ? `Warning: transcript may be incomplete because the session message fetch hit its limit.
|
|
143191
|
+
` : "");
|
|
143192
|
+
let response = `${header}
|
|
143193
|
+
${page.content}`;
|
|
143194
|
+
if (page.endLine < page.totalLines) {
|
|
143195
|
+
const remaining = page.totalLines - page.endLine;
|
|
143196
|
+
response += `
|
|
143197
|
+
|
|
143198
|
+
... ${remaining} more line${remaining === 1 ? "" : "s"}. Use offset=${page.endLine} to retrieve more.`;
|
|
143199
|
+
}
|
|
143200
|
+
return response;
|
|
143201
|
+
}
|
|
143202
|
+
});
|
|
143203
|
+
|
|
142835
143204
|
// src/tools/retrieve-summary.ts
|
|
142836
143205
|
init_zod();
|
|
142837
143206
|
init_manager4();
|
|
@@ -142908,7 +143277,7 @@ init_plan_schema();
|
|
|
142908
143277
|
init_qa_gate_profile();
|
|
142909
143278
|
init_file_locks();
|
|
142910
143279
|
import * as fs120 from "node:fs";
|
|
142911
|
-
import * as
|
|
143280
|
+
import * as path182 from "node:path";
|
|
142912
143281
|
init_ledger();
|
|
142913
143282
|
init_manager();
|
|
142914
143283
|
init_effective_spec();
|
|
@@ -142990,8 +143359,8 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
142990
143359
|
};
|
|
142991
143360
|
}
|
|
142992
143361
|
if (args2.working_directory && fallbackDir) {
|
|
142993
|
-
const resolvedTarget =
|
|
142994
|
-
const resolvedRoot =
|
|
143362
|
+
const resolvedTarget = path182.resolve(args2.working_directory);
|
|
143363
|
+
const resolvedRoot = path182.resolve(fallbackDir);
|
|
142995
143364
|
let fallbackExists = false;
|
|
142996
143365
|
try {
|
|
142997
143366
|
fs120.accessSync(resolvedRoot, fs120.constants.F_OK);
|
|
@@ -143000,7 +143369,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
143000
143369
|
fallbackExists = false;
|
|
143001
143370
|
}
|
|
143002
143371
|
if (fallbackExists) {
|
|
143003
|
-
const isSubdirectory = resolvedTarget.startsWith(resolvedRoot +
|
|
143372
|
+
const isSubdirectory = resolvedTarget.startsWith(resolvedRoot + path182.sep);
|
|
143004
143373
|
if (isSubdirectory) {
|
|
143005
143374
|
return {
|
|
143006
143375
|
success: false,
|
|
@@ -143031,7 +143400,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
143031
143400
|
specHash = spec.hash;
|
|
143032
143401
|
}
|
|
143033
143402
|
if (process.env.SWARM_SKIP_GATE_SELECTION !== "1") {
|
|
143034
|
-
const contextPath =
|
|
143403
|
+
const contextPath = path182.join(targetWorkspace, ".swarm", "context.md");
|
|
143035
143404
|
let contextContent = "";
|
|
143036
143405
|
try {
|
|
143037
143406
|
contextContent = await fs120.promises.readFile(contextPath, "utf8");
|
|
@@ -143321,7 +143690,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
143321
143690
|
}
|
|
143322
143691
|
await writeCheckpoint(dir).catch(() => {});
|
|
143323
143692
|
try {
|
|
143324
|
-
const markerPath =
|
|
143693
|
+
const markerPath = path182.join(dir, ".swarm", ".plan-write-marker");
|
|
143325
143694
|
const marker = JSON.stringify({
|
|
143326
143695
|
source: "save_plan",
|
|
143327
143696
|
timestamp: new Date().toISOString(),
|
|
@@ -143344,7 +143713,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
143344
143713
|
return {
|
|
143345
143714
|
success: true,
|
|
143346
143715
|
message: "Plan saved successfully",
|
|
143347
|
-
plan_path:
|
|
143716
|
+
plan_path: path182.join(dir, ".swarm", "plan.json"),
|
|
143348
143717
|
phases_count: plan.phases.length,
|
|
143349
143718
|
tasks_count: tasksCount,
|
|
143350
143719
|
...resolvedProfile !== undefined ? { execution_profile: resolvedProfile } : {},
|
|
@@ -143412,7 +143781,7 @@ var save_plan = createSwarmTool({
|
|
|
143412
143781
|
init_zod();
|
|
143413
143782
|
init_manager2();
|
|
143414
143783
|
import * as fs121 from "node:fs";
|
|
143415
|
-
import * as
|
|
143784
|
+
import * as path183 from "node:path";
|
|
143416
143785
|
|
|
143417
143786
|
// src/sbom/detectors/index.ts
|
|
143418
143787
|
init_utils();
|
|
@@ -144262,7 +144631,7 @@ function findManifestFiles(rootDir) {
|
|
|
144262
144631
|
try {
|
|
144263
144632
|
const entries = fs121.readdirSync(dir, { withFileTypes: true });
|
|
144264
144633
|
for (const entry of entries) {
|
|
144265
|
-
const fullPath =
|
|
144634
|
+
const fullPath = path183.join(dir, entry.name);
|
|
144266
144635
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
|
|
144267
144636
|
continue;
|
|
144268
144637
|
}
|
|
@@ -144271,7 +144640,7 @@ function findManifestFiles(rootDir) {
|
|
|
144271
144640
|
} else if (entry.isFile()) {
|
|
144272
144641
|
for (const pattern of patterns) {
|
|
144273
144642
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
144274
|
-
manifestFiles.push(
|
|
144643
|
+
manifestFiles.push(path183.relative(rootDir, fullPath));
|
|
144275
144644
|
break;
|
|
144276
144645
|
}
|
|
144277
144646
|
}
|
|
@@ -144289,11 +144658,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
144289
144658
|
try {
|
|
144290
144659
|
const entries = fs121.readdirSync(dir, { withFileTypes: true });
|
|
144291
144660
|
for (const entry of entries) {
|
|
144292
|
-
const fullPath =
|
|
144661
|
+
const fullPath = path183.join(dir, entry.name);
|
|
144293
144662
|
if (entry.isFile()) {
|
|
144294
144663
|
for (const pattern of patterns) {
|
|
144295
144664
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
144296
|
-
found.push(
|
|
144665
|
+
found.push(path183.relative(workingDir, fullPath));
|
|
144297
144666
|
break;
|
|
144298
144667
|
}
|
|
144299
144668
|
}
|
|
@@ -144306,11 +144675,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
144306
144675
|
function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
|
|
144307
144676
|
const dirs = new Set;
|
|
144308
144677
|
for (const file3 of changedFiles) {
|
|
144309
|
-
let currentDir =
|
|
144678
|
+
let currentDir = path183.dirname(file3);
|
|
144310
144679
|
while (true) {
|
|
144311
|
-
if (currentDir && currentDir !== "." && currentDir !==
|
|
144312
|
-
dirs.add(
|
|
144313
|
-
const parent =
|
|
144680
|
+
if (currentDir && currentDir !== "." && currentDir !== path183.sep) {
|
|
144681
|
+
dirs.add(path183.join(workingDir, currentDir));
|
|
144682
|
+
const parent = path183.dirname(currentDir);
|
|
144314
144683
|
if (parent === currentDir)
|
|
144315
144684
|
break;
|
|
144316
144685
|
currentDir = parent;
|
|
@@ -144394,7 +144763,7 @@ var sbom_generate = createSwarmTool({
|
|
|
144394
144763
|
const changedFiles = obj.changed_files;
|
|
144395
144764
|
const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
|
|
144396
144765
|
const workingDir = directory;
|
|
144397
|
-
const outputDir =
|
|
144766
|
+
const outputDir = path183.isAbsolute(relativeOutputDir) ? relativeOutputDir : path183.join(workingDir, relativeOutputDir);
|
|
144398
144767
|
let manifestFiles = [];
|
|
144399
144768
|
if (scope === "all") {
|
|
144400
144769
|
manifestFiles = findManifestFiles(workingDir);
|
|
@@ -144417,7 +144786,7 @@ var sbom_generate = createSwarmTool({
|
|
|
144417
144786
|
const processedFiles = [];
|
|
144418
144787
|
for (const manifestFile of manifestFiles) {
|
|
144419
144788
|
try {
|
|
144420
|
-
const fullPath =
|
|
144789
|
+
const fullPath = path183.isAbsolute(manifestFile) ? manifestFile : path183.join(workingDir, manifestFile);
|
|
144421
144790
|
if (!fs121.existsSync(fullPath)) {
|
|
144422
144791
|
continue;
|
|
144423
144792
|
}
|
|
@@ -144434,7 +144803,7 @@ var sbom_generate = createSwarmTool({
|
|
|
144434
144803
|
const bom = generateCycloneDX(allComponents);
|
|
144435
144804
|
const bomJson = serializeCycloneDX(bom);
|
|
144436
144805
|
const filename = generateSbomFilename();
|
|
144437
|
-
const outputPath =
|
|
144806
|
+
const outputPath = path183.join(outputDir, filename);
|
|
144438
144807
|
fs121.writeFileSync(outputPath, bomJson, "utf-8");
|
|
144439
144808
|
const verdict = processedFiles.length > 0 ? "pass" : "pass";
|
|
144440
144809
|
try {
|
|
@@ -144479,7 +144848,7 @@ var sbom_generate = createSwarmTool({
|
|
|
144479
144848
|
init_zod();
|
|
144480
144849
|
init_create_tool();
|
|
144481
144850
|
import * as fs122 from "node:fs";
|
|
144482
|
-
import * as
|
|
144851
|
+
import * as path184 from "node:path";
|
|
144483
144852
|
var SPEC_CANDIDATES = [
|
|
144484
144853
|
"openapi.json",
|
|
144485
144854
|
"openapi.yaml",
|
|
@@ -144511,12 +144880,12 @@ function normalizePath5(p) {
|
|
|
144511
144880
|
}
|
|
144512
144881
|
function discoverSpecFile(cwd, specFileArg) {
|
|
144513
144882
|
if (specFileArg) {
|
|
144514
|
-
const resolvedPath =
|
|
144515
|
-
const normalizedCwd = cwd.endsWith(
|
|
144883
|
+
const resolvedPath = path184.resolve(cwd, specFileArg);
|
|
144884
|
+
const normalizedCwd = cwd.endsWith(path184.sep) ? cwd : cwd + path184.sep;
|
|
144516
144885
|
if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
|
|
144517
144886
|
throw new Error("Invalid spec_file: path traversal detected");
|
|
144518
144887
|
}
|
|
144519
|
-
const ext =
|
|
144888
|
+
const ext = path184.extname(resolvedPath).toLowerCase();
|
|
144520
144889
|
if (!ALLOWED_EXTENSIONS.includes(ext)) {
|
|
144521
144890
|
throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
|
|
144522
144891
|
}
|
|
@@ -144530,7 +144899,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
144530
144899
|
return resolvedPath;
|
|
144531
144900
|
}
|
|
144532
144901
|
for (const candidate of SPEC_CANDIDATES) {
|
|
144533
|
-
const candidatePath =
|
|
144902
|
+
const candidatePath = path184.resolve(cwd, candidate);
|
|
144534
144903
|
if (fs122.existsSync(candidatePath)) {
|
|
144535
144904
|
const stats2 = fs122.statSync(candidatePath);
|
|
144536
144905
|
if (stats2.size <= MAX_SPEC_SIZE) {
|
|
@@ -144542,7 +144911,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
144542
144911
|
}
|
|
144543
144912
|
function parseSpec(specFile) {
|
|
144544
144913
|
const content = fs122.readFileSync(specFile, "utf-8");
|
|
144545
|
-
const ext =
|
|
144914
|
+
const ext = path184.extname(specFile).toLowerCase();
|
|
144546
144915
|
if (ext === ".json") {
|
|
144547
144916
|
return parseJsonSpec(content);
|
|
144548
144917
|
}
|
|
@@ -144618,7 +144987,7 @@ function extractRoutes2(cwd) {
|
|
|
144618
144987
|
return;
|
|
144619
144988
|
}
|
|
144620
144989
|
for (const entry of entries) {
|
|
144621
|
-
const fullPath =
|
|
144990
|
+
const fullPath = path184.join(dir, entry.name);
|
|
144622
144991
|
if (entry.isSymbolicLink()) {
|
|
144623
144992
|
continue;
|
|
144624
144993
|
}
|
|
@@ -144628,7 +144997,7 @@ function extractRoutes2(cwd) {
|
|
|
144628
144997
|
}
|
|
144629
144998
|
walkDir2(fullPath);
|
|
144630
144999
|
} else if (entry.isFile()) {
|
|
144631
|
-
const ext =
|
|
145000
|
+
const ext = path184.extname(entry.name).toLowerCase();
|
|
144632
145001
|
const baseName = entry.name.toLowerCase();
|
|
144633
145002
|
if (![".ts", ".js", ".mjs"].includes(ext)) {
|
|
144634
145003
|
continue;
|
|
@@ -144797,7 +145166,7 @@ init_bun_compat();
|
|
|
144797
145166
|
init_path_security();
|
|
144798
145167
|
init_create_tool();
|
|
144799
145168
|
import * as fs123 from "node:fs";
|
|
144800
|
-
import * as
|
|
145169
|
+
import * as path185 from "node:path";
|
|
144801
145170
|
var DEFAULT_MAX_RESULTS = 100;
|
|
144802
145171
|
var DEFAULT_MAX_LINES = 200;
|
|
144803
145172
|
var REGEX_TIMEOUT_MS = 5000;
|
|
@@ -144833,11 +145202,11 @@ function containsWindowsAttacks4(str) {
|
|
|
144833
145202
|
}
|
|
144834
145203
|
function isPathInWorkspace3(filePath, workspace) {
|
|
144835
145204
|
try {
|
|
144836
|
-
const resolvedPath =
|
|
145205
|
+
const resolvedPath = path185.resolve(workspace, filePath);
|
|
144837
145206
|
const realWorkspace = fs123.realpathSync(workspace);
|
|
144838
145207
|
const realResolvedPath = fs123.realpathSync(resolvedPath);
|
|
144839
|
-
const relativePath =
|
|
144840
|
-
if (relativePath.startsWith("..") ||
|
|
145208
|
+
const relativePath = path185.relative(realWorkspace, realResolvedPath);
|
|
145209
|
+
if (relativePath.startsWith("..") || path185.isAbsolute(relativePath)) {
|
|
144841
145210
|
return false;
|
|
144842
145211
|
}
|
|
144843
145212
|
return true;
|
|
@@ -144850,11 +145219,11 @@ function validatePathForRead2(filePath, workspace) {
|
|
|
144850
145219
|
}
|
|
144851
145220
|
function findRgInEnvPath() {
|
|
144852
145221
|
const searchPath = process.env.PATH ?? "";
|
|
144853
|
-
for (const dir of searchPath.split(
|
|
145222
|
+
for (const dir of searchPath.split(path185.delimiter)) {
|
|
144854
145223
|
if (!dir)
|
|
144855
145224
|
continue;
|
|
144856
145225
|
const isWindows = process.platform === "win32";
|
|
144857
|
-
const candidate =
|
|
145226
|
+
const candidate = path185.join(dir, isWindows ? "rg.exe" : "rg");
|
|
144858
145227
|
if (fs123.existsSync(candidate))
|
|
144859
145228
|
return candidate;
|
|
144860
145229
|
}
|
|
@@ -144984,8 +145353,8 @@ function collectFiles(dir, workspace, includeGlobs, excludeGlobs) {
|
|
|
144984
145353
|
try {
|
|
144985
145354
|
const entries = fs123.readdirSync(dir, { withFileTypes: true });
|
|
144986
145355
|
for (const entry of entries) {
|
|
144987
|
-
const fullPath =
|
|
144988
|
-
const relativePath =
|
|
145356
|
+
const fullPath = path185.join(dir, entry.name);
|
|
145357
|
+
const relativePath = path185.relative(workspace, fullPath);
|
|
144989
145358
|
if (!validatePathForRead2(fullPath, workspace)) {
|
|
144990
145359
|
continue;
|
|
144991
145360
|
}
|
|
@@ -145026,7 +145395,7 @@ async function fallbackSearch(opts) {
|
|
|
145026
145395
|
const matches = [];
|
|
145027
145396
|
let total = 0;
|
|
145028
145397
|
for (const file3 of files) {
|
|
145029
|
-
const fullPath =
|
|
145398
|
+
const fullPath = path185.join(opts.workspace, file3);
|
|
145030
145399
|
if (!validatePathForRead2(fullPath, opts.workspace)) {
|
|
145031
145400
|
continue;
|
|
145032
145401
|
}
|
|
@@ -145458,7 +145827,7 @@ init_config();
|
|
|
145458
145827
|
init_schema();
|
|
145459
145828
|
init_create_tool();
|
|
145460
145829
|
import { mkdir as mkdir33, rename as rename14, writeFile as writeFile23 } from "node:fs/promises";
|
|
145461
|
-
import * as
|
|
145830
|
+
import * as path186 from "node:path";
|
|
145462
145831
|
var MAX_SPEC_BYTES2 = 256 * 1024;
|
|
145463
145832
|
var spec_write = createSwarmTool({
|
|
145464
145833
|
description: "Write the canonical project spec to .swarm/spec.md. Atomic write, size-bounded (256 KiB), heading-required. Honors spec_writer.allow_spec_write.",
|
|
@@ -145499,8 +145868,8 @@ var spec_write = createSwarmTool({
|
|
|
145499
145868
|
reason: 'spec must contain at least one top-level "# Heading"'
|
|
145500
145869
|
}, null, 2);
|
|
145501
145870
|
}
|
|
145502
|
-
const target =
|
|
145503
|
-
await mkdir33(
|
|
145871
|
+
const target = path186.join(directory, ".swarm", "spec.md");
|
|
145872
|
+
await mkdir33(path186.dirname(target), { recursive: true });
|
|
145504
145873
|
const tmp = `${target}.tmp-${process.pid}-${Date.now()}`;
|
|
145505
145874
|
let finalContent = content;
|
|
145506
145875
|
if (mode === "append") {
|
|
@@ -145529,14 +145898,14 @@ ${content}
|
|
|
145529
145898
|
init_zod();
|
|
145530
145899
|
init_loader();
|
|
145531
145900
|
import {
|
|
145532
|
-
existsSync as
|
|
145533
|
-
mkdirSync as
|
|
145534
|
-
readFileSync as
|
|
145535
|
-
renameSync as
|
|
145536
|
-
unlinkSync as
|
|
145537
|
-
writeFileSync as
|
|
145901
|
+
existsSync as existsSync105,
|
|
145902
|
+
mkdirSync as mkdirSync43,
|
|
145903
|
+
readFileSync as readFileSync83,
|
|
145904
|
+
renameSync as renameSync25,
|
|
145905
|
+
unlinkSync as unlinkSync22,
|
|
145906
|
+
writeFileSync as writeFileSync32
|
|
145538
145907
|
} from "node:fs";
|
|
145539
|
-
import
|
|
145908
|
+
import path187 from "node:path";
|
|
145540
145909
|
init_create_tool();
|
|
145541
145910
|
init_resolve_working_directory();
|
|
145542
145911
|
var VerdictSchema2 = exports_external.object({
|
|
@@ -145703,9 +146072,9 @@ var submit_phase_council_verdicts = createSwarmTool({
|
|
|
145703
146072
|
}
|
|
145704
146073
|
});
|
|
145705
146074
|
function getPhaseMutationGapFinding(phaseNumber, workingDir) {
|
|
145706
|
-
const mutationGatePath =
|
|
146075
|
+
const mutationGatePath = path187.join(workingDir, ".swarm", "evidence", String(phaseNumber), "mutation-gate.json");
|
|
145707
146076
|
try {
|
|
145708
|
-
const raw =
|
|
146077
|
+
const raw = readFileSync83(mutationGatePath, "utf-8");
|
|
145709
146078
|
const parsed = JSON.parse(raw);
|
|
145710
146079
|
const gateEntry = (parsed.entries ?? []).find((entry) => entry?.type === "mutation-gate");
|
|
145711
146080
|
if (!gateEntry) {
|
|
@@ -145765,9 +146134,9 @@ function getPhaseMutationGapFinding(phaseNumber, workingDir) {
|
|
|
145765
146134
|
}
|
|
145766
146135
|
}
|
|
145767
146136
|
function writePhaseCouncilEvidence(workingDir, synthesis, provenance) {
|
|
145768
|
-
const evidenceDir =
|
|
145769
|
-
|
|
145770
|
-
const evidenceFile =
|
|
146137
|
+
const evidenceDir = path187.join(workingDir, ".swarm", "evidence", String(synthesis.phaseNumber));
|
|
146138
|
+
mkdirSync43(evidenceDir, { recursive: true });
|
|
146139
|
+
const evidenceFile = path187.join(evidenceDir, "phase-council.json");
|
|
145771
146140
|
const evidenceBundle = {
|
|
145772
146141
|
entries: [
|
|
145773
146142
|
{
|
|
@@ -145801,11 +146170,11 @@ function writePhaseCouncilEvidence(workingDir, synthesis, provenance) {
|
|
|
145801
146170
|
};
|
|
145802
146171
|
const tempFile = `${evidenceFile}.tmp-${Date.now()}`;
|
|
145803
146172
|
try {
|
|
145804
|
-
|
|
145805
|
-
|
|
146173
|
+
writeFileSync32(tempFile, JSON.stringify(evidenceBundle, null, 2), "utf-8");
|
|
146174
|
+
renameSync25(tempFile, evidenceFile);
|
|
145806
146175
|
} finally {
|
|
145807
|
-
if (
|
|
145808
|
-
|
|
146176
|
+
if (existsSync105(tempFile)) {
|
|
146177
|
+
unlinkSync22(tempFile);
|
|
145809
146178
|
}
|
|
145810
146179
|
}
|
|
145811
146180
|
}
|
|
@@ -145830,7 +146199,7 @@ init_zod();
|
|
|
145830
146199
|
init_path_security();
|
|
145831
146200
|
init_create_tool();
|
|
145832
146201
|
import * as fs124 from "node:fs";
|
|
145833
|
-
import * as
|
|
146202
|
+
import * as path188 from "node:path";
|
|
145834
146203
|
var BINARY_EXTENSIONS2 = new Set([
|
|
145835
146204
|
".png",
|
|
145836
146205
|
".jpg",
|
|
@@ -145866,14 +146235,14 @@ function containsWindowsAttacks5(str) {
|
|
|
145866
146235
|
}
|
|
145867
146236
|
function isPathInWorkspace4(filePath, workspace) {
|
|
145868
146237
|
try {
|
|
145869
|
-
const resolvedPath =
|
|
146238
|
+
const resolvedPath = path188.resolve(workspace, filePath);
|
|
145870
146239
|
if (!fs124.existsSync(resolvedPath)) {
|
|
145871
146240
|
return true;
|
|
145872
146241
|
}
|
|
145873
146242
|
const realWorkspace = fs124.realpathSync(workspace);
|
|
145874
146243
|
const realResolvedPath = fs124.realpathSync(resolvedPath);
|
|
145875
|
-
const relativePath =
|
|
145876
|
-
if (relativePath.startsWith("..") ||
|
|
146244
|
+
const relativePath = path188.relative(realWorkspace, realResolvedPath);
|
|
146245
|
+
if (relativePath.startsWith("..") || path188.isAbsolute(relativePath)) {
|
|
145877
146246
|
return false;
|
|
145878
146247
|
}
|
|
145879
146248
|
return true;
|
|
@@ -145988,7 +146357,7 @@ function arraysEqual2(a, b) {
|
|
|
145988
146357
|
return true;
|
|
145989
146358
|
}
|
|
145990
146359
|
function isBinaryFile4(filePath) {
|
|
145991
|
-
const ext =
|
|
146360
|
+
const ext = path188.extname(filePath).toLowerCase();
|
|
145992
146361
|
return BINARY_EXTENSIONS2.has(ext);
|
|
145993
146362
|
}
|
|
145994
146363
|
function splitDiffLines(content) {
|
|
@@ -146193,7 +146562,7 @@ var suggestPatch = createSwarmTool({
|
|
|
146193
146562
|
});
|
|
146194
146563
|
continue;
|
|
146195
146564
|
}
|
|
146196
|
-
const fullPath =
|
|
146565
|
+
const fullPath = path188.resolve(directory, change.file);
|
|
146197
146566
|
if (!fs124.existsSync(fullPath)) {
|
|
146198
146567
|
errors5.push({
|
|
146199
146568
|
success: false,
|
|
@@ -146288,7 +146657,7 @@ var suggestPatch = createSwarmTool({
|
|
|
146288
146657
|
const unifiedParts = [];
|
|
146289
146658
|
for (const [file3, entries] of fileGroups) {
|
|
146290
146659
|
entries.sort((a, b) => a.contextMatch.startLineIndex - b.contextMatch.startLineIndex);
|
|
146291
|
-
const entryFullPath =
|
|
146660
|
+
const entryFullPath = path188.resolve(directory, file3);
|
|
146292
146661
|
let entryContent;
|
|
146293
146662
|
try {
|
|
146294
146663
|
entryContent = fs124.readFileSync(entryFullPath, "utf-8");
|
|
@@ -146630,7 +146999,7 @@ function getContextAgent4(ctx) {
|
|
|
146630
146999
|
|
|
146631
147000
|
// src/tools/syntax-check.ts
|
|
146632
147001
|
import * as fs125 from "node:fs";
|
|
146633
|
-
import * as
|
|
147002
|
+
import * as path189 from "node:path";
|
|
146634
147003
|
init_zod();
|
|
146635
147004
|
init_manager2();
|
|
146636
147005
|
init_detector();
|
|
@@ -146702,7 +147071,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
146702
147071
|
if (languages?.length) {
|
|
146703
147072
|
const lowerLangs = languages.map((l) => l.toLowerCase());
|
|
146704
147073
|
filesToCheck = filesToCheck.filter((file3) => {
|
|
146705
|
-
const ext =
|
|
147074
|
+
const ext = path189.extname(file3.path).toLowerCase();
|
|
146706
147075
|
const langDef = getLanguageForExtension(ext);
|
|
146707
147076
|
const fileProfile = getProfileForFile(file3.path);
|
|
146708
147077
|
const langId = fileProfile?.id || langDef?.id;
|
|
@@ -146712,7 +147081,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
146712
147081
|
const { loadGrammar: loadGrammar2 } = await Promise.resolve().then(() => (init_runtime(), exports_runtime));
|
|
146713
147082
|
async function checkOneFile(fileInfo) {
|
|
146714
147083
|
const { path: filePath } = fileInfo;
|
|
146715
|
-
const fullPath =
|
|
147084
|
+
const fullPath = path189.isAbsolute(filePath) ? filePath : path189.join(directory, filePath);
|
|
146716
147085
|
const result = {
|
|
146717
147086
|
path: filePath,
|
|
146718
147087
|
language: "",
|
|
@@ -146759,7 +147128,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
146759
147128
|
result.skipped_reason = "binary_file";
|
|
146760
147129
|
return { result, counted: false, failed: false, skipped: true };
|
|
146761
147130
|
}
|
|
146762
|
-
const ext =
|
|
147131
|
+
const ext = path189.extname(filePath).toLowerCase();
|
|
146763
147132
|
const langDef = getLanguageForExtension(ext);
|
|
146764
147133
|
result.language = profile?.id || langDef?.id || "unknown";
|
|
146765
147134
|
const errors5 = extractSyntaxErrors(parser, content);
|
|
@@ -146871,7 +147240,7 @@ init_utils();
|
|
|
146871
147240
|
init_create_tool();
|
|
146872
147241
|
init_path_security();
|
|
146873
147242
|
import * as fs126 from "node:fs";
|
|
146874
|
-
import * as
|
|
147243
|
+
import * as path190 from "node:path";
|
|
146875
147244
|
var MAX_TEXT_LENGTH = 200;
|
|
146876
147245
|
var MAX_FILE_SIZE_BYTES10 = 1024 * 1024;
|
|
146877
147246
|
var SUPPORTED_EXTENSIONS4 = new Set([
|
|
@@ -146937,9 +147306,9 @@ function validatePathsInput(paths, cwd) {
|
|
|
146937
147306
|
return { error: "paths contains path traversal", resolvedPath: null };
|
|
146938
147307
|
}
|
|
146939
147308
|
try {
|
|
146940
|
-
const resolvedPath =
|
|
146941
|
-
const normalizedCwd =
|
|
146942
|
-
const normalizedResolved =
|
|
147309
|
+
const resolvedPath = path190.resolve(paths);
|
|
147310
|
+
const normalizedCwd = path190.resolve(cwd);
|
|
147311
|
+
const normalizedResolved = path190.resolve(resolvedPath);
|
|
146943
147312
|
if (!normalizedResolved.startsWith(normalizedCwd)) {
|
|
146944
147313
|
return {
|
|
146945
147314
|
error: "paths must be within the current working directory",
|
|
@@ -146955,7 +147324,7 @@ function validatePathsInput(paths, cwd) {
|
|
|
146955
147324
|
}
|
|
146956
147325
|
}
|
|
146957
147326
|
function isSupportedExtension(filePath) {
|
|
146958
|
-
const ext =
|
|
147327
|
+
const ext = path190.extname(filePath).toLowerCase();
|
|
146959
147328
|
return SUPPORTED_EXTENSIONS4.has(ext);
|
|
146960
147329
|
}
|
|
146961
147330
|
function findSourceFiles3(dir, files = []) {
|
|
@@ -146970,7 +147339,7 @@ function findSourceFiles3(dir, files = []) {
|
|
|
146970
147339
|
if (SKIP_DIRECTORIES6.has(entry)) {
|
|
146971
147340
|
continue;
|
|
146972
147341
|
}
|
|
146973
|
-
const fullPath =
|
|
147342
|
+
const fullPath = path190.join(dir, entry);
|
|
146974
147343
|
let stat14;
|
|
146975
147344
|
try {
|
|
146976
147345
|
stat14 = fs126.statSync(fullPath);
|
|
@@ -147082,7 +147451,7 @@ var todo_extract = createSwarmTool({
|
|
|
147082
147451
|
filesToScan.push(scanPath);
|
|
147083
147452
|
} else {
|
|
147084
147453
|
const errorResult = {
|
|
147085
|
-
error: `unsupported file extension: ${
|
|
147454
|
+
error: `unsupported file extension: ${path190.extname(scanPath)}`,
|
|
147086
147455
|
total: 0,
|
|
147087
147456
|
byPriority: { high: 0, medium: 0, low: 0 },
|
|
147088
147457
|
entries: []
|
|
@@ -147132,17 +147501,17 @@ init_schema();
|
|
|
147132
147501
|
init_qa_gate_profile();
|
|
147133
147502
|
init_gate_evidence();
|
|
147134
147503
|
import * as fs130 from "node:fs";
|
|
147135
|
-
import * as
|
|
147504
|
+
import * as path194 from "node:path";
|
|
147136
147505
|
|
|
147137
147506
|
// src/hooks/diff-scope.ts
|
|
147138
147507
|
init_bun_compat();
|
|
147139
147508
|
import * as fs128 from "node:fs";
|
|
147140
|
-
import * as
|
|
147509
|
+
import * as path192 from "node:path";
|
|
147141
147510
|
|
|
147142
147511
|
// src/utils/gitignore-warning.ts
|
|
147143
147512
|
init_bun_compat();
|
|
147144
147513
|
import * as fs127 from "node:fs";
|
|
147145
|
-
import * as
|
|
147514
|
+
import * as path191 from "node:path";
|
|
147146
147515
|
var _internals108 = { bunSpawn };
|
|
147147
147516
|
var _swarmGitExcludedChecked = false;
|
|
147148
147517
|
function fileCoversSwarm(content) {
|
|
@@ -147216,10 +147585,10 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
147216
147585
|
const excludeRelPath = excludePathRaw.trim();
|
|
147217
147586
|
if (!excludeRelPath)
|
|
147218
147587
|
return;
|
|
147219
|
-
const excludePath =
|
|
147588
|
+
const excludePath = path191.isAbsolute(excludeRelPath) ? excludeRelPath : path191.join(directory, excludeRelPath);
|
|
147220
147589
|
if (checkIgnoreExitCode !== 0) {
|
|
147221
147590
|
try {
|
|
147222
|
-
fs127.mkdirSync(
|
|
147591
|
+
fs127.mkdirSync(path191.dirname(excludePath), { recursive: true });
|
|
147223
147592
|
let existing = "";
|
|
147224
147593
|
try {
|
|
147225
147594
|
existing = fs127.readFileSync(excludePath, "utf8");
|
|
@@ -147263,7 +147632,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
147263
147632
|
var _internals109 = { bunSpawn };
|
|
147264
147633
|
function getDeclaredScope(taskId, directory) {
|
|
147265
147634
|
try {
|
|
147266
|
-
const planPath =
|
|
147635
|
+
const planPath = path192.join(directory, ".swarm", "plan.json");
|
|
147267
147636
|
if (!fs128.existsSync(planPath))
|
|
147268
147637
|
return null;
|
|
147269
147638
|
const raw = fs128.readFileSync(planPath, "utf-8");
|
|
@@ -147369,7 +147738,7 @@ init_telemetry();
|
|
|
147369
147738
|
// src/turbo/lean/task-completion.ts
|
|
147370
147739
|
init_file_locks();
|
|
147371
147740
|
import * as fs129 from "node:fs";
|
|
147372
|
-
import * as
|
|
147741
|
+
import * as path193 from "node:path";
|
|
147373
147742
|
var _internals110 = {
|
|
147374
147743
|
listActiveLocks,
|
|
147375
147744
|
verifyLeanTurboTaskCompletion
|
|
@@ -147388,7 +147757,7 @@ var TIER_3_PATTERNS = [
|
|
|
147388
147757
|
];
|
|
147389
147758
|
function matchesTier3Pattern(files) {
|
|
147390
147759
|
for (const file3 of files) {
|
|
147391
|
-
const fileName =
|
|
147760
|
+
const fileName = path193.basename(file3);
|
|
147392
147761
|
for (const pattern of TIER_3_PATTERNS) {
|
|
147393
147762
|
if (pattern.test(fileName)) {
|
|
147394
147763
|
return true;
|
|
@@ -147400,7 +147769,7 @@ function matchesTier3Pattern(files) {
|
|
|
147400
147769
|
function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
147401
147770
|
let persisted = null;
|
|
147402
147771
|
try {
|
|
147403
|
-
const statePath =
|
|
147772
|
+
const statePath = path193.join(directory, ".swarm", "turbo-state.json");
|
|
147404
147773
|
if (!fs129.existsSync(statePath)) {
|
|
147405
147774
|
return {
|
|
147406
147775
|
ok: false,
|
|
@@ -147484,11 +147853,11 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
|
147484
147853
|
};
|
|
147485
147854
|
}
|
|
147486
147855
|
const phase = runState.phase ?? 0;
|
|
147487
|
-
const evidencePath =
|
|
147488
|
-
const expectedDir =
|
|
147489
|
-
const resolvedPath =
|
|
147490
|
-
const resolvedDir =
|
|
147491
|
-
if (!resolvedPath.startsWith(resolvedDir +
|
|
147856
|
+
const evidencePath = path193.join(directory, ".swarm", "evidence", String(phase), "lean-turbo", `${lane.laneId}.json`);
|
|
147857
|
+
const expectedDir = path193.join(directory, ".swarm", "evidence", String(phase), "lean-turbo");
|
|
147858
|
+
const resolvedPath = path193.resolve(evidencePath);
|
|
147859
|
+
const resolvedDir = path193.resolve(expectedDir);
|
|
147860
|
+
if (!resolvedPath.startsWith(resolvedDir + path193.sep) && resolvedPath !== resolvedDir) {
|
|
147492
147861
|
return {
|
|
147493
147862
|
ok: false,
|
|
147494
147863
|
reason: `Lane ID causes path traversal: ${lane.laneId}`,
|
|
@@ -147528,7 +147897,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
|
147528
147897
|
}
|
|
147529
147898
|
let filesTouched = [];
|
|
147530
147899
|
try {
|
|
147531
|
-
const planPath =
|
|
147900
|
+
const planPath = path193.join(directory, ".swarm", "plan.json");
|
|
147532
147901
|
const planRaw = fs129.readFileSync(planPath, "utf-8");
|
|
147533
147902
|
const plan = JSON.parse(planRaw);
|
|
147534
147903
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -147617,7 +147986,7 @@ var TIER_3_PATTERNS2 = [
|
|
|
147617
147986
|
];
|
|
147618
147987
|
function matchesTier3Pattern2(files) {
|
|
147619
147988
|
for (const file3 of files) {
|
|
147620
|
-
const fileName =
|
|
147989
|
+
const fileName = path194.basename(file3);
|
|
147621
147990
|
for (const pattern of TIER_3_PATTERNS2) {
|
|
147622
147991
|
if (pattern.test(fileName)) {
|
|
147623
147992
|
return true;
|
|
@@ -147656,7 +148025,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
147656
148025
|
if (!skipStandardTurboBypass && hasActiveTurboMode()) {
|
|
147657
148026
|
const resolvedDir2 = workingDirectory;
|
|
147658
148027
|
try {
|
|
147659
|
-
const planPath =
|
|
148028
|
+
const planPath = path194.join(resolvedDir2, ".swarm", "plan.json");
|
|
147660
148029
|
const planRaw = fs130.readFileSync(planPath, "utf-8");
|
|
147661
148030
|
const plan = JSON.parse(planRaw);
|
|
147662
148031
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -147734,7 +148103,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
147734
148103
|
}
|
|
147735
148104
|
if (resolvedDir) {
|
|
147736
148105
|
try {
|
|
147737
|
-
const planPath =
|
|
148106
|
+
const planPath = path194.join(resolvedDir, ".swarm", "plan.json");
|
|
147738
148107
|
const planRaw = fs130.readFileSync(planPath, "utf-8");
|
|
147739
148108
|
const plan = JSON.parse(planRaw);
|
|
147740
148109
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -147945,7 +148314,7 @@ function checkCouncilGate(workingDirectory, taskId) {
|
|
|
147945
148314
|
return { blocked: false, reason: "", active: false };
|
|
147946
148315
|
}
|
|
147947
148316
|
try {
|
|
147948
|
-
const planPath =
|
|
148317
|
+
const planPath = path194.join(workingDirectory, ".swarm", "plan.json");
|
|
147949
148318
|
const planRaw = fs130.readFileSync(planPath, "utf-8");
|
|
147950
148319
|
const planObj = JSON.parse(planRaw);
|
|
147951
148320
|
if (planObj.swarm && planObj.title) {
|
|
@@ -148032,7 +148401,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
148032
148401
|
};
|
|
148033
148402
|
}
|
|
148034
148403
|
directory = resolveResult.directory;
|
|
148035
|
-
const planPath =
|
|
148404
|
+
const planPath = path194.join(directory, ".swarm", "plan.json");
|
|
148036
148405
|
if (!fs130.existsSync(planPath)) {
|
|
148037
148406
|
return {
|
|
148038
148407
|
success: false,
|
|
@@ -148041,9 +148410,9 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
148041
148410
|
};
|
|
148042
148411
|
}
|
|
148043
148412
|
if (fallbackDir && directory !== fallbackDir) {
|
|
148044
|
-
const canonicalDir = fs130.realpathSync(
|
|
148045
|
-
const canonicalRoot = fs130.realpathSync(
|
|
148046
|
-
if (canonicalDir.startsWith(canonicalRoot +
|
|
148413
|
+
const canonicalDir = fs130.realpathSync(path194.resolve(directory));
|
|
148414
|
+
const canonicalRoot = fs130.realpathSync(path194.resolve(fallbackDir));
|
|
148415
|
+
if (canonicalDir.startsWith(canonicalRoot + path194.sep)) {
|
|
148047
148416
|
return {
|
|
148048
148417
|
success: false,
|
|
148049
148418
|
message: `Invalid working_directory: "${directory}" is a subdirectory of ` + `the project root "${fallbackDir}". Pass the project root path or ` + `omit working_directory entirely.`,
|
|
@@ -148055,8 +148424,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
148055
148424
|
}
|
|
148056
148425
|
if (args2.status === "in_progress") {
|
|
148057
148426
|
try {
|
|
148058
|
-
const evidencePath =
|
|
148059
|
-
fs130.mkdirSync(
|
|
148427
|
+
const evidencePath = path194.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
|
|
148428
|
+
fs130.mkdirSync(path194.dirname(evidencePath), { recursive: true });
|
|
148060
148429
|
const fd = fs130.openSync(evidencePath, "wx");
|
|
148061
148430
|
let writeOk = false;
|
|
148062
148431
|
try {
|
|
@@ -148080,7 +148449,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
148080
148449
|
recoverTaskStateFromDelegations(args2.task_id, directory);
|
|
148081
148450
|
let phaseRequiresReviewer = true;
|
|
148082
148451
|
try {
|
|
148083
|
-
const planPath2 =
|
|
148452
|
+
const planPath2 = path194.join(directory, ".swarm", "plan.json");
|
|
148084
148453
|
const planRaw = fs130.readFileSync(planPath2, "utf-8");
|
|
148085
148454
|
const plan = JSON.parse(planRaw);
|
|
148086
148455
|
const taskPhase = plan.phases.find((p) => p.tasks.some((t) => t.id === args2.task_id));
|
|
@@ -148197,9 +148566,9 @@ import * as zlib from "node:zlib";
|
|
|
148197
148566
|
// src/evidence/documents.ts
|
|
148198
148567
|
init_utils2();
|
|
148199
148568
|
init_redaction();
|
|
148200
|
-
import { createHash as
|
|
148569
|
+
import { createHash as createHash24 } from "node:crypto";
|
|
148201
148570
|
import { appendFile as appendFile17, mkdir as mkdir34 } from "node:fs/promises";
|
|
148202
|
-
import * as
|
|
148571
|
+
import * as path195 from "node:path";
|
|
148203
148572
|
var EVIDENCE_CACHE_FILE = "evidence-cache/documents.jsonl";
|
|
148204
148573
|
var MAX_EVIDENCE_TEXT_LENGTH = 4000;
|
|
148205
148574
|
async function writeEvidenceDocuments(directory, inputs, now = () => new Date) {
|
|
@@ -148207,7 +148576,7 @@ async function writeEvidenceDocuments(directory, inputs, now = () => new Date) {
|
|
|
148207
148576
|
const capturedAt = now().toISOString();
|
|
148208
148577
|
const records = inputs.map((input) => createEvidenceDocumentRecord(input, capturedAt)).filter((record3) => record3 !== null);
|
|
148209
148578
|
if (records.length > 0) {
|
|
148210
|
-
await mkdir34(
|
|
148579
|
+
await mkdir34(path195.dirname(filePath), { recursive: true });
|
|
148211
148580
|
await appendFile17(filePath, `${records.map((record3) => JSON.stringify(record3)).join(`
|
|
148212
148581
|
`)}
|
|
148213
148582
|
`, "utf-8");
|
|
@@ -148241,7 +148610,7 @@ function createEvidenceDocumentRecord(input, defaultCapturedAt) {
|
|
|
148241
148610
|
};
|
|
148242
148611
|
}
|
|
148243
148612
|
function createEvidenceDocumentId(input) {
|
|
148244
|
-
const hash4 =
|
|
148613
|
+
const hash4 = createHash24("sha256").update([
|
|
148245
148614
|
input.sourceType,
|
|
148246
148615
|
input.query ?? "",
|
|
148247
148616
|
input.title ?? "",
|
|
@@ -149224,7 +149593,7 @@ init_schema3();
|
|
|
149224
149593
|
init_store();
|
|
149225
149594
|
init_create_tool();
|
|
149226
149595
|
init_resolve_working_directory();
|
|
149227
|
-
import * as
|
|
149596
|
+
import * as path196 from "node:path";
|
|
149228
149597
|
var FindingSchema2 = exports_external.object({
|
|
149229
149598
|
severity: exports_external.enum(["low", "medium", "high", "critical"]),
|
|
149230
149599
|
category: exports_external.string().min(1),
|
|
@@ -149300,7 +149669,7 @@ var write_architecture_supervisor_evidence = createSwarmTool({
|
|
|
149300
149669
|
if (config3.architectural_supervision?.persist_knowledge_recommendations && args2.knowledge_recommendations.length > 0) {
|
|
149301
149670
|
const knowledgeConfig = KnowledgeConfigSchema.parse(config3.knowledge ?? {});
|
|
149302
149671
|
const lessons = args2.knowledge_recommendations.map((r) => r.lesson);
|
|
149303
|
-
const result = await curateAndStoreSwarm(lessons,
|
|
149672
|
+
const result = await curateAndStoreSwarm(lessons, path196.basename(dirResult.directory), { phase_number: args2.phase }, dirResult.directory, knowledgeConfig, {
|
|
149304
149673
|
skipAutoPromotion: true,
|
|
149305
149674
|
llmDelegate: createCuratorLLMDelegate(dirResult.directory, "phase"),
|
|
149306
149675
|
enrichmentQuota: {
|
|
@@ -149347,7 +149716,7 @@ init_ledger();
|
|
|
149347
149716
|
init_manager();
|
|
149348
149717
|
init_create_tool();
|
|
149349
149718
|
import fs131 from "node:fs";
|
|
149350
|
-
import
|
|
149719
|
+
import path197 from "node:path";
|
|
149351
149720
|
function normalizeVerdict(verdict) {
|
|
149352
149721
|
switch (verdict) {
|
|
149353
149722
|
case "APPROVED":
|
|
@@ -149401,7 +149770,7 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
149401
149770
|
entries: [evidenceEntry]
|
|
149402
149771
|
};
|
|
149403
149772
|
const filename = "drift-verifier.json";
|
|
149404
|
-
const relativePath =
|
|
149773
|
+
const relativePath = path197.join("evidence", String(phase), filename);
|
|
149405
149774
|
let validatedPath;
|
|
149406
149775
|
try {
|
|
149407
149776
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -149412,10 +149781,10 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
149412
149781
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
149413
149782
|
}, null, 2);
|
|
149414
149783
|
}
|
|
149415
|
-
const evidenceDir =
|
|
149784
|
+
const evidenceDir = path197.dirname(validatedPath);
|
|
149416
149785
|
try {
|
|
149417
149786
|
await fs131.promises.mkdir(evidenceDir, { recursive: true });
|
|
149418
|
-
const tempPath =
|
|
149787
|
+
const tempPath = path197.join(evidenceDir, `.${filename}.tmp`);
|
|
149419
149788
|
await fs131.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
149420
149789
|
await fs131.promises.rename(tempPath, validatedPath);
|
|
149421
149790
|
let snapshotInfo;
|
|
@@ -149516,7 +149885,7 @@ var write_drift_evidence = createSwarmTool({
|
|
|
149516
149885
|
init_zod();
|
|
149517
149886
|
init_loader();
|
|
149518
149887
|
import fs132 from "node:fs";
|
|
149519
|
-
import
|
|
149888
|
+
import path198 from "node:path";
|
|
149520
149889
|
init_utils2();
|
|
149521
149890
|
init_manager();
|
|
149522
149891
|
init_create_tool();
|
|
@@ -149630,7 +149999,7 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
|
|
|
149630
149999
|
timestamp: synthesis.timestamp
|
|
149631
150000
|
};
|
|
149632
150001
|
const filename = "final-council.json";
|
|
149633
|
-
const relativePath =
|
|
150002
|
+
const relativePath = path198.join("evidence", filename);
|
|
149634
150003
|
let validatedPath;
|
|
149635
150004
|
try {
|
|
149636
150005
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -149644,10 +150013,10 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
|
|
|
149644
150013
|
const evidenceContent = {
|
|
149645
150014
|
entries: [evidenceEntry]
|
|
149646
150015
|
};
|
|
149647
|
-
const evidenceDir =
|
|
150016
|
+
const evidenceDir = path198.dirname(validatedPath);
|
|
149648
150017
|
try {
|
|
149649
150018
|
await fs132.promises.mkdir(evidenceDir, { recursive: true });
|
|
149650
|
-
const tempPath =
|
|
150019
|
+
const tempPath = path198.join(evidenceDir, `.${filename}.tmp`);
|
|
149651
150020
|
await fs132.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
149652
150021
|
await fs132.promises.rename(tempPath, validatedPath);
|
|
149653
150022
|
return JSON.stringify({
|
|
@@ -149707,7 +150076,7 @@ init_zod();
|
|
|
149707
150076
|
init_utils2();
|
|
149708
150077
|
init_create_tool();
|
|
149709
150078
|
import fs133 from "node:fs";
|
|
149710
|
-
import
|
|
150079
|
+
import path199 from "node:path";
|
|
149711
150080
|
function normalizeVerdict2(verdict) {
|
|
149712
150081
|
switch (verdict) {
|
|
149713
150082
|
case "APPROVED":
|
|
@@ -149755,7 +150124,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
149755
150124
|
entries: [evidenceEntry]
|
|
149756
150125
|
};
|
|
149757
150126
|
const filename = "hallucination-guard.json";
|
|
149758
|
-
const relativePath =
|
|
150127
|
+
const relativePath = path199.join("evidence", String(phase), filename);
|
|
149759
150128
|
let validatedPath;
|
|
149760
150129
|
try {
|
|
149761
150130
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -149766,10 +150135,10 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
149766
150135
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
149767
150136
|
}, null, 2);
|
|
149768
150137
|
}
|
|
149769
|
-
const evidenceDir =
|
|
150138
|
+
const evidenceDir = path199.dirname(validatedPath);
|
|
149770
150139
|
try {
|
|
149771
150140
|
await fs133.promises.mkdir(evidenceDir, { recursive: true });
|
|
149772
|
-
const tempPath =
|
|
150141
|
+
const tempPath = path199.join(evidenceDir, `.${filename}.tmp`);
|
|
149773
150142
|
await fs133.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
149774
150143
|
await fs133.promises.rename(tempPath, validatedPath);
|
|
149775
150144
|
return JSON.stringify({
|
|
@@ -149819,7 +150188,7 @@ init_zod();
|
|
|
149819
150188
|
init_utils2();
|
|
149820
150189
|
init_create_tool();
|
|
149821
150190
|
import fs134 from "node:fs";
|
|
149822
|
-
import
|
|
150191
|
+
import path200 from "node:path";
|
|
149823
150192
|
function normalizeVerdict3(verdict) {
|
|
149824
150193
|
switch (verdict) {
|
|
149825
150194
|
case "PASS":
|
|
@@ -149893,7 +150262,7 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
149893
150262
|
entries: [evidenceEntry]
|
|
149894
150263
|
};
|
|
149895
150264
|
const filename = "mutation-gate.json";
|
|
149896
|
-
const relativePath =
|
|
150265
|
+
const relativePath = path200.join("evidence", String(phase), filename);
|
|
149897
150266
|
let validatedPath;
|
|
149898
150267
|
try {
|
|
149899
150268
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -149904,10 +150273,10 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
149904
150273
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
149905
150274
|
}, null, 2);
|
|
149906
150275
|
}
|
|
149907
|
-
const evidenceDir =
|
|
150276
|
+
const evidenceDir = path200.dirname(validatedPath);
|
|
149908
150277
|
try {
|
|
149909
150278
|
await fs134.promises.mkdir(evidenceDir, { recursive: true });
|
|
149910
|
-
const tempPath =
|
|
150279
|
+
const tempPath = path200.join(evidenceDir, `.${filename}.tmp`);
|
|
149911
150280
|
await fs134.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
149912
150281
|
await fs134.promises.rename(tempPath, validatedPath);
|
|
149913
150282
|
return JSON.stringify({
|
|
@@ -149994,6 +150363,7 @@ var TOOL_MANIFEST = defineHandlers({
|
|
|
149994
150363
|
git_blame: () => git_blame,
|
|
149995
150364
|
gitingest: () => gitingest,
|
|
149996
150365
|
retrieve_summary: () => retrieve_summary,
|
|
150366
|
+
retrieve_lane_output: () => retrieve_lane_output,
|
|
149997
150367
|
extract_code_blocks: () => extract_code_blocks,
|
|
149998
150368
|
phase_complete: () => phase_complete,
|
|
149999
150369
|
save_plan: () => save_plan,
|
|
@@ -150117,7 +150487,7 @@ ${footerLines.join(`
|
|
|
150117
150487
|
init_warning_buffer();
|
|
150118
150488
|
var _heartbeatTimers = new Map;
|
|
150119
150489
|
var SWARM_COMMAND_SYSTEM_RULE_TAG = "[opencode-swarm:swarm-command-rule]";
|
|
150120
|
-
var PACKAGE_ROOT2 =
|
|
150490
|
+
var PACKAGE_ROOT2 = path202.resolve(path202.dirname(fileURLToPath5(import.meta.url)), "..");
|
|
150121
150491
|
var SYNC_BUNDLED_SKILLS_TIMEOUT_MS = 2000;
|
|
150122
150492
|
function createSwarmCommandSystemRuleHook(agentDefinitions, registeredAgents) {
|
|
150123
150493
|
return async (input, output) => {
|
|
@@ -150438,7 +150808,7 @@ async function initializeOpenCodeSwarm(ctx) {
|
|
|
150438
150808
|
const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
|
|
150439
150809
|
preflightTriggerManager = new PTM(automationConfig);
|
|
150440
150810
|
const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
|
|
150441
|
-
const swarmDir =
|
|
150811
|
+
const swarmDir = path202.resolve(ctx.directory, ".swarm");
|
|
150442
150812
|
statusArtifact = new ASA(swarmDir);
|
|
150443
150813
|
statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
|
|
150444
150814
|
if (automationConfig.capabilities?.evidence_auto_summaries === true) {
|
|
@@ -151102,7 +151472,7 @@ ${promptRaw}`;
|
|
|
151102
151472
|
const meta3 = readSkillMetadata(s.skillPath, ctx.directory);
|
|
151103
151473
|
let desc = meta3.description || "";
|
|
151104
151474
|
if (!desc || desc === "No description provided") {
|
|
151105
|
-
desc =
|
|
151475
|
+
desc = path202.basename(path202.dirname(s.skillPath));
|
|
151106
151476
|
}
|
|
151107
151477
|
desc = desc.replace(/,/g, ";");
|
|
151108
151478
|
return `file:${s.skillPath} (-- ${desc})`;
|
|
@@ -151112,7 +151482,7 @@ ${promptRaw}`;
|
|
|
151112
151482
|
|
|
151113
151483
|
${promptRaw}`;
|
|
151114
151484
|
argsRecord.prompt = newPrompt;
|
|
151115
|
-
const skillNames = topSkills.map((s) => `${
|
|
151485
|
+
const skillNames = topSkills.map((s) => `${path202.basename(s.skillPath)} (score: ${s.score.toFixed(2)})`).join(", ");
|
|
151116
151486
|
console.warn(`[skill-propagation-gate] Injected skills: ${skillNames}`);
|
|
151117
151487
|
for (const skill of topSkills) {
|
|
151118
151488
|
try {
|