opencode-swarm 7.84.0 → 7.86.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-rtd1x26f.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-8ra2qpk8.js → index-5q66xc88.js} +9 -9
- package/dist/cli/{index-xw0bcy0v.js → index-7r2b453y.js} +2 -2
- package/dist/cli/{index-wg3r6acj.js → index-hw9b2xng.js} +5 -1
- package/dist/cli/{index-j710h2ge.js → index-jwz50183.js} +6 -6
- package/dist/cli/{index-pv2xmc9k.js → index-vq2321gg.js} +1 -1
- 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 +985 -357
- 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/repo-graph/builder.d.ts +46 -0
- package/dist/tools/repo-graph/query.d.ts +26 -1
- package/dist/tools/repo-graph/types.d.ts +73 -1
- package/dist/tools/repo-graph.d.ts +4 -3
- 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.86.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(),
|
|
@@ -45058,7 +45068,7 @@ function recordSessionStart(directory, startMs) {
|
|
|
45058
45068
|
const filePath = path32.join(sessionDir, SESSION_START_FILE);
|
|
45059
45069
|
const line = JSON.stringify({ startMs, ts: Date.now() });
|
|
45060
45070
|
mkdirSync11(sessionDir, { recursive: true });
|
|
45061
|
-
writeFileSync6(filePath, line
|
|
45071
|
+
writeFileSync6(filePath, `${line}
|
|
45062
45072
|
`, { flag: "a" });
|
|
45063
45073
|
} catch {}
|
|
45064
45074
|
}
|
|
@@ -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;
|
|
@@ -113297,7 +113317,25 @@ function safeRealpathSync(targetPath, fallback, realpathResolver = realpathSync1
|
|
|
113297
113317
|
// src/tools/repo-graph/types.ts
|
|
113298
113318
|
import * as path117 from "node:path";
|
|
113299
113319
|
var REPO_GRAPH_FILENAME = "repo-graph.json";
|
|
113300
|
-
var GRAPH_SCHEMA_VERSION = "1.
|
|
113320
|
+
var GRAPH_SCHEMA_VERSION = "1.1.0";
|
|
113321
|
+
function isSchemaVersionAtLeast(version5, minimum) {
|
|
113322
|
+
const parse10 = (v) => v.split(".").map((part) => {
|
|
113323
|
+
const n = Number.parseInt(part, 10);
|
|
113324
|
+
return Number.isFinite(n) ? n : 0;
|
|
113325
|
+
});
|
|
113326
|
+
const a = parse10(version5 ?? "");
|
|
113327
|
+
const b = parse10(minimum);
|
|
113328
|
+
const len = Math.max(a.length, b.length);
|
|
113329
|
+
for (let i2 = 0;i2 < len; i2++) {
|
|
113330
|
+
const av = a[i2] ?? 0;
|
|
113331
|
+
const bv = b[i2] ?? 0;
|
|
113332
|
+
if (av > bv)
|
|
113333
|
+
return true;
|
|
113334
|
+
if (av < bv)
|
|
113335
|
+
return false;
|
|
113336
|
+
}
|
|
113337
|
+
return true;
|
|
113338
|
+
}
|
|
113301
113339
|
var FILE_ROLE_VALUES = [
|
|
113302
113340
|
"api_route",
|
|
113303
113341
|
"middleware",
|
|
@@ -113472,6 +113510,19 @@ function validateGraphNode(node) {
|
|
|
113472
113510
|
throw new Error(`Invalid node: imports contains control characters (file=${node.filePath}, value="${preview}")`);
|
|
113473
113511
|
}
|
|
113474
113512
|
}
|
|
113513
|
+
if (node.exportLines !== undefined) {
|
|
113514
|
+
if (typeof node.exportLines !== "object" || node.exportLines === null || Array.isArray(node.exportLines)) {
|
|
113515
|
+
throw new Error("Invalid node: exportLines must be an object");
|
|
113516
|
+
}
|
|
113517
|
+
for (const [name2, line] of Object.entries(node.exportLines)) {
|
|
113518
|
+
if (containsControlChars(name2)) {
|
|
113519
|
+
throw new Error("Invalid node: exportLines key contains control characters");
|
|
113520
|
+
}
|
|
113521
|
+
if (typeof line !== "number" || !Number.isFinite(line) || line < 0) {
|
|
113522
|
+
throw new Error("Invalid node: exportLines values must be non-negative numbers");
|
|
113523
|
+
}
|
|
113524
|
+
}
|
|
113525
|
+
}
|
|
113475
113526
|
if (node.ontology !== undefined) {
|
|
113476
113527
|
validateOntologyStrings(node);
|
|
113477
113528
|
}
|
|
@@ -113589,6 +113640,19 @@ function validateGraphEdge(edge) {
|
|
|
113589
113640
|
}
|
|
113590
113641
|
}
|
|
113591
113642
|
}
|
|
113643
|
+
if (edge.usedSymbols !== undefined) {
|
|
113644
|
+
if (!Array.isArray(edge.usedSymbols)) {
|
|
113645
|
+
throw new Error("Invalid edge: usedSymbols must be an array");
|
|
113646
|
+
}
|
|
113647
|
+
for (const symbol3 of edge.usedSymbols) {
|
|
113648
|
+
if (typeof symbol3 !== "string") {
|
|
113649
|
+
throw new Error("Invalid edge: usedSymbols must be an array of strings");
|
|
113650
|
+
}
|
|
113651
|
+
if (containsControlChars(symbol3)) {
|
|
113652
|
+
throw new Error("Invalid edge: usedSymbols contains control characters");
|
|
113653
|
+
}
|
|
113654
|
+
}
|
|
113655
|
+
}
|
|
113592
113656
|
}
|
|
113593
113657
|
|
|
113594
113658
|
// src/tools/repo-graph/builder.ts
|
|
@@ -113597,7 +113661,9 @@ var _internals74 = {
|
|
|
113597
113661
|
extractTSSymbols,
|
|
113598
113662
|
extractPythonSymbols,
|
|
113599
113663
|
parseFileImports,
|
|
113600
|
-
extractFileOntology
|
|
113664
|
+
extractFileOntology,
|
|
113665
|
+
stripComments: stripComments2,
|
|
113666
|
+
computeUsedSymbols
|
|
113601
113667
|
};
|
|
113602
113668
|
var SKIP_DIRECTORIES3 = new Set([
|
|
113603
113669
|
"node_modules",
|
|
@@ -113894,11 +113960,89 @@ function parseFileImports(rawContent) {
|
|
|
113894
113960
|
imports.push({
|
|
113895
113961
|
specifier: modulePath,
|
|
113896
113962
|
importType,
|
|
113897
|
-
importedSymbols: parseImportedSymbols(matchedString, importType)
|
|
113963
|
+
importedSymbols: parseImportedSymbols(matchedString, importType),
|
|
113964
|
+
bindings: parseImportBindings(matchedString, importType),
|
|
113965
|
+
reExport: /^\s*export\b/.test(matchedString)
|
|
113898
113966
|
});
|
|
113899
113967
|
}
|
|
113900
113968
|
return imports;
|
|
113901
113969
|
}
|
|
113970
|
+
function parseImportBindings(matchedString, importType) {
|
|
113971
|
+
if (importType === "namespace")
|
|
113972
|
+
return [];
|
|
113973
|
+
if (importType === "default") {
|
|
113974
|
+
const defaultMatch = matchedString.match(/^import\s+(\w+)\s+from\s+['"`]/);
|
|
113975
|
+
return defaultMatch ? [{ imported: "default", local: defaultMatch[1] }] : [];
|
|
113976
|
+
}
|
|
113977
|
+
if (importType !== "named")
|
|
113978
|
+
return [];
|
|
113979
|
+
const braceMatch = matchedString.match(/\{\s*([\s\S]*?)\s*\}/);
|
|
113980
|
+
if (!braceMatch)
|
|
113981
|
+
return [];
|
|
113982
|
+
const bindings = [];
|
|
113983
|
+
const seen = new Set;
|
|
113984
|
+
for (const rawPart of braceMatch[1].split(",")) {
|
|
113985
|
+
const part = rawPart.trim().replace(/^type\s+/, "");
|
|
113986
|
+
if (!part)
|
|
113987
|
+
continue;
|
|
113988
|
+
const aliasSplit = part.split(/\s+as\s+/i);
|
|
113989
|
+
const imported = aliasSplit[0].trim();
|
|
113990
|
+
const local = (aliasSplit[1] ?? aliasSplit[0]).trim();
|
|
113991
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(imported))
|
|
113992
|
+
continue;
|
|
113993
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(local))
|
|
113994
|
+
continue;
|
|
113995
|
+
if (seen.has(imported))
|
|
113996
|
+
continue;
|
|
113997
|
+
seen.add(imported);
|
|
113998
|
+
bindings.push({ imported, local });
|
|
113999
|
+
}
|
|
114000
|
+
return bindings;
|
|
114001
|
+
}
|
|
114002
|
+
var SAFE_USAGE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
114003
|
+
function computeUsedSymbols(strippedContent, bindings) {
|
|
114004
|
+
if (bindings.length === 0)
|
|
114005
|
+
return [];
|
|
114006
|
+
const used = new Set;
|
|
114007
|
+
for (const binding of bindings) {
|
|
114008
|
+
if (!SAFE_USAGE_IDENTIFIER.test(binding.local)) {
|
|
114009
|
+
used.add(binding.imported);
|
|
114010
|
+
continue;
|
|
114011
|
+
}
|
|
114012
|
+
const re = new RegExp(`\\b${binding.local}\\b`, "g");
|
|
114013
|
+
let count = 0;
|
|
114014
|
+
for (const _match of strippedContent.matchAll(re)) {
|
|
114015
|
+
count++;
|
|
114016
|
+
if (count > 1)
|
|
114017
|
+
break;
|
|
114018
|
+
}
|
|
114019
|
+
if (count > 1)
|
|
114020
|
+
used.add(binding.imported);
|
|
114021
|
+
}
|
|
114022
|
+
return [...used].sort((a, b) => a.localeCompare(b));
|
|
114023
|
+
}
|
|
114024
|
+
function usedSymbolsForImport(parsed, strippedContent) {
|
|
114025
|
+
if (parsed.importType === "namespace" || parsed.importType === "sideeffect" || parsed.importType === "require") {
|
|
114026
|
+
return;
|
|
114027
|
+
}
|
|
114028
|
+
if (parsed.reExport) {
|
|
114029
|
+
return [...new Set(parsed.bindings.map((b) => b.imported))].sort((a, b) => a.localeCompare(b));
|
|
114030
|
+
}
|
|
114031
|
+
return computeUsedSymbols(strippedContent, parsed.bindings);
|
|
114032
|
+
}
|
|
114033
|
+
function collectExports(symbols2) {
|
|
114034
|
+
const exported = symbols2.filter((s) => s.exported);
|
|
114035
|
+
const exports = exported.map((s) => s.signature === `default ${s.name}` ? "default" : s.name);
|
|
114036
|
+
const exportLines = {};
|
|
114037
|
+
for (let i2 = 0;i2 < exported.length; i2++) {
|
|
114038
|
+
const s = exported[i2];
|
|
114039
|
+
const name2 = exports[i2];
|
|
114040
|
+
if (typeof s.line === "number" && Number.isFinite(s.line) && exportLines[name2] === undefined) {
|
|
114041
|
+
exportLines[name2] = s.line;
|
|
114042
|
+
}
|
|
114043
|
+
}
|
|
114044
|
+
return { exports, exportLines };
|
|
114045
|
+
}
|
|
113902
114046
|
function parseImportedSymbols(matchedString, importType) {
|
|
113903
114047
|
if (importType === "namespace")
|
|
113904
114048
|
return ["*"];
|
|
@@ -114042,22 +114186,23 @@ function scanFile(filePath, absoluteRoot, maxFileSize) {
|
|
|
114042
114186
|
}
|
|
114043
114187
|
const ext = path118.extname(filePath).toLowerCase();
|
|
114044
114188
|
let exports = [];
|
|
114189
|
+
let exportLines = {};
|
|
114045
114190
|
try {
|
|
114046
114191
|
if ([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"].includes(ext)) {
|
|
114047
114192
|
const relativePath = path118.relative(absoluteRoot, filePath);
|
|
114048
|
-
|
|
114049
|
-
exports = symbols2.filter((s) => s.exported).map((s) => s.name);
|
|
114193
|
+
({ exports, exportLines } = collectExports(_internals74.extractTSSymbols(relativePath, absoluteRoot)));
|
|
114050
114194
|
} else if (ext === ".py") {
|
|
114051
114195
|
const relativePath = path118.relative(absoluteRoot, filePath);
|
|
114052
|
-
|
|
114053
|
-
exports = symbols2.filter((s) => s.exported).map((s) => s.name);
|
|
114196
|
+
({ exports, exportLines } = collectExports(_internals74.extractPythonSymbols(relativePath, absoluteRoot)));
|
|
114054
114197
|
}
|
|
114055
114198
|
const parsedImports = _internals74.parseFileImports(content);
|
|
114199
|
+
const strippedForUsage = parsedImports.length > 0 ? _internals74.stripComments(content) : "";
|
|
114056
114200
|
const moduleName = toModuleName(filePath, absoluteRoot);
|
|
114057
114201
|
const node = {
|
|
114058
114202
|
filePath,
|
|
114059
114203
|
moduleName,
|
|
114060
114204
|
exports,
|
|
114205
|
+
...Object.keys(exportLines).length > 0 ? { exportLines } : {},
|
|
114061
114206
|
imports: parsedImports.map((p) => p.specifier),
|
|
114062
114207
|
language: getLanguage(filePath),
|
|
114063
114208
|
mtime: fileStats.mtime.toISOString(),
|
|
@@ -114075,12 +114220,14 @@ function scanFile(filePath, absoluteRoot, maxFileSize) {
|
|
|
114075
114220
|
for (const parsed of sortedImports) {
|
|
114076
114221
|
const resolvedTarget = resolveModuleSpecifier(absoluteRoot, filePath, parsed.specifier);
|
|
114077
114222
|
if (resolvedTarget !== null) {
|
|
114223
|
+
const usedSymbols = usedSymbolsForImport(parsed, strippedForUsage);
|
|
114078
114224
|
edges.push({
|
|
114079
114225
|
source: filePath,
|
|
114080
114226
|
target: resolvedTarget,
|
|
114081
114227
|
importSpecifier: parsed.specifier,
|
|
114082
114228
|
importType: parsed.importType,
|
|
114083
|
-
importedSymbols: parsed.importedSymbols
|
|
114229
|
+
importedSymbols: parsed.importedSymbols,
|
|
114230
|
+
...usedSymbols !== undefined ? { usedSymbols } : {}
|
|
114084
114231
|
});
|
|
114085
114232
|
}
|
|
114086
114233
|
}
|
|
@@ -114336,6 +114483,113 @@ function getSymbolConsumers(graph, filePath, symbolName) {
|
|
|
114336
114483
|
refs.sort((a, b) => a.file.localeCompare(b.file));
|
|
114337
114484
|
return refs;
|
|
114338
114485
|
}
|
|
114486
|
+
function getCallers(graph, filePath, symbolName) {
|
|
114487
|
+
const node = getGraphNode(graph, filePath);
|
|
114488
|
+
if (!node)
|
|
114489
|
+
return [];
|
|
114490
|
+
const targetKey = normalizeGraphPath(node.filePath);
|
|
114491
|
+
const refs = [];
|
|
114492
|
+
const seen = new Set;
|
|
114493
|
+
for (const edge of graph.edges) {
|
|
114494
|
+
if (normalizeGraphPath(edge.target) !== targetKey)
|
|
114495
|
+
continue;
|
|
114496
|
+
const file3 = moduleNameForEdgePath(graph, edge.source);
|
|
114497
|
+
if (seen.has(file3))
|
|
114498
|
+
continue;
|
|
114499
|
+
if (edge.usedSymbols !== undefined) {
|
|
114500
|
+
if (edge.usedSymbols.includes(symbolName)) {
|
|
114501
|
+
seen.add(file3);
|
|
114502
|
+
refs.push({ file: file3, resolution: "used" });
|
|
114503
|
+
}
|
|
114504
|
+
continue;
|
|
114505
|
+
}
|
|
114506
|
+
const imported = edge.importedSymbols ?? [];
|
|
114507
|
+
if (edge.importType === "namespace" || imported.includes(symbolName)) {
|
|
114508
|
+
seen.add(file3);
|
|
114509
|
+
refs.push({ file: file3, resolution: "imported" });
|
|
114510
|
+
}
|
|
114511
|
+
}
|
|
114512
|
+
refs.sort((a, b) => a.file.localeCompare(b.file));
|
|
114513
|
+
return refs;
|
|
114514
|
+
}
|
|
114515
|
+
var DEAD_EXPORT_EXCLUDED_ROLES = new Set([
|
|
114516
|
+
"api_route",
|
|
114517
|
+
"cli_command",
|
|
114518
|
+
"test_file",
|
|
114519
|
+
"agent",
|
|
114520
|
+
"hook",
|
|
114521
|
+
"middleware"
|
|
114522
|
+
]);
|
|
114523
|
+
function getDeadExports(graph, options) {
|
|
114524
|
+
if (!isSchemaVersionAtLeast(graph.schema_version, "1.1.0")) {
|
|
114525
|
+
return {
|
|
114526
|
+
schemaSupported: false,
|
|
114527
|
+
analyzedFiles: 0,
|
|
114528
|
+
skippedUnresolvable: 0,
|
|
114529
|
+
candidates: [],
|
|
114530
|
+
note: 'Graph predates schema 1.1.0 (no usedSymbols data). Run repo_map action="build" to enable dead_exports.'
|
|
114531
|
+
};
|
|
114532
|
+
}
|
|
114533
|
+
const usage = new Map;
|
|
114534
|
+
for (const edge of graph.edges) {
|
|
114535
|
+
const target = normalizeGraphPath(edge.target);
|
|
114536
|
+
let entry = usage.get(target);
|
|
114537
|
+
if (!entry) {
|
|
114538
|
+
entry = { used: new Set, unresolvable: false };
|
|
114539
|
+
usage.set(target, entry);
|
|
114540
|
+
}
|
|
114541
|
+
if (edge.importType === "namespace" || edge.importType === "sideeffect" || edge.importType === "require") {
|
|
114542
|
+
entry.unresolvable = true;
|
|
114543
|
+
} else if (edge.usedSymbols) {
|
|
114544
|
+
for (const symbol3 of edge.usedSymbols)
|
|
114545
|
+
entry.used.add(symbol3);
|
|
114546
|
+
}
|
|
114547
|
+
}
|
|
114548
|
+
const reverse = getReverseIndex(graph);
|
|
114549
|
+
const candidates = [];
|
|
114550
|
+
let analyzedFiles = 0;
|
|
114551
|
+
let skippedUnresolvable = 0;
|
|
114552
|
+
for (const node of Object.values(graph.nodes)) {
|
|
114553
|
+
if (node.exports.length === 0)
|
|
114554
|
+
continue;
|
|
114555
|
+
const key = normalizeGraphPath(node.filePath);
|
|
114556
|
+
const importerCount = reverse.get(key)?.length ?? 0;
|
|
114557
|
+
if (importerCount === 0)
|
|
114558
|
+
continue;
|
|
114559
|
+
const roles = node.ontology?.roles ?? [];
|
|
114560
|
+
if (roles.some((r) => DEAD_EXPORT_EXCLUDED_ROLES.has(r)))
|
|
114561
|
+
continue;
|
|
114562
|
+
const entry = usage.get(key);
|
|
114563
|
+
if (entry?.unresolvable) {
|
|
114564
|
+
skippedUnresolvable++;
|
|
114565
|
+
continue;
|
|
114566
|
+
}
|
|
114567
|
+
analyzedFiles++;
|
|
114568
|
+
const used = entry?.used ?? new Set;
|
|
114569
|
+
for (const symbol3 of node.exports) {
|
|
114570
|
+
if (symbol3 === "default")
|
|
114571
|
+
continue;
|
|
114572
|
+
if (used.has(symbol3))
|
|
114573
|
+
continue;
|
|
114574
|
+
candidates.push({
|
|
114575
|
+
file: node.moduleName,
|
|
114576
|
+
symbol: symbol3,
|
|
114577
|
+
line: node.exportLines?.[symbol3],
|
|
114578
|
+
importerCount
|
|
114579
|
+
});
|
|
114580
|
+
}
|
|
114581
|
+
}
|
|
114582
|
+
candidates.sort((a, b) => a.file.localeCompare(b.file) || a.symbol.localeCompare(b.symbol));
|
|
114583
|
+
const limit = options?.maxCandidates ?? 100;
|
|
114584
|
+
const truncated = candidates.length > limit;
|
|
114585
|
+
return {
|
|
114586
|
+
schemaSupported: true,
|
|
114587
|
+
analyzedFiles,
|
|
114588
|
+
skippedUnresolvable,
|
|
114589
|
+
candidates: candidates.slice(0, limit),
|
|
114590
|
+
note: "Advisory: exported symbols with no detected in-repo reference, limited to files imported by >=1 other file. " + "Regex analysis cannot see dynamic dispatch, string-keyed access, or namespace/barrel re-export usage; verify before removing." + (truncated ? ` Showing ${limit} of ${candidates.length}.` : "")
|
|
114591
|
+
};
|
|
114592
|
+
}
|
|
114339
114593
|
function getBlastRadius(graph, filePaths, maxDepth = 3) {
|
|
114340
114594
|
const targetNodes = filePaths.map((filePath) => getGraphNode(graph, filePath)).filter((node) => node !== undefined);
|
|
114341
114595
|
const targets = targetNodes.map((node) => normalizeLookupPath(node.moduleName));
|
|
@@ -118187,6 +118441,7 @@ function createToolSummarizerHook(config3, directory) {
|
|
|
118187
118441
|
}
|
|
118188
118442
|
const exemptTools = config3.exempt_tools ?? [
|
|
118189
118443
|
"retrieve_summary",
|
|
118444
|
+
"retrieve_lane_output",
|
|
118190
118445
|
"task",
|
|
118191
118446
|
"read"
|
|
118192
118447
|
];
|
|
@@ -121352,6 +121607,7 @@ var PROBED_TOOLS = new Set([
|
|
|
121352
121607
|
"gitingest",
|
|
121353
121608
|
"extract_code_blocks",
|
|
121354
121609
|
"retrieve_summary",
|
|
121610
|
+
"retrieve_lane_output",
|
|
121355
121611
|
"search",
|
|
121356
121612
|
"read",
|
|
121357
121613
|
"view"
|
|
@@ -127743,7 +127999,7 @@ var diff_summary = createSwarmTool({
|
|
|
127743
127999
|
});
|
|
127744
128000
|
|
|
127745
128001
|
// src/tools/dispatch-lanes.ts
|
|
127746
|
-
import { createHash as
|
|
128002
|
+
import { createHash as createHash19 } from "node:crypto";
|
|
127747
128003
|
|
|
127748
128004
|
// node_modules/yocto-queue/index.js
|
|
127749
128005
|
class Node2 {
|
|
@@ -127903,6 +128159,231 @@ function validateConcurrency(concurrency) {
|
|
|
127903
128159
|
|
|
127904
128160
|
// src/tools/dispatch-lanes.ts
|
|
127905
128161
|
init_zod();
|
|
128162
|
+
|
|
128163
|
+
// src/background/lane-output-store.ts
|
|
128164
|
+
init_zod();
|
|
128165
|
+
init_utils2();
|
|
128166
|
+
import { createHash as createHash18 } from "node:crypto";
|
|
128167
|
+
import {
|
|
128168
|
+
existsSync as existsSync85,
|
|
128169
|
+
mkdirSync as mkdirSync37,
|
|
128170
|
+
readFileSync as readFileSync60,
|
|
128171
|
+
renameSync as renameSync23,
|
|
128172
|
+
unlinkSync as unlinkSync19,
|
|
128173
|
+
writeFileSync as writeFileSync24
|
|
128174
|
+
} from "node:fs";
|
|
128175
|
+
import * as path152 from "node:path";
|
|
128176
|
+
var LANE_OUTPUT_REF_PREFIX = "L1";
|
|
128177
|
+
var MAX_LANE_OUTPUT_STORED_BYTES = 10 * 1024 * 1024;
|
|
128178
|
+
var LANE_OUTPUT_SCHEMA_VERSION = 1;
|
|
128179
|
+
var REF_RE = /^L1:[a-f0-9]{64}:[a-f0-9]{64}:[a-f0-9]{64}$/;
|
|
128180
|
+
var LaneOutputArtifactSchema = exports_external.object({
|
|
128181
|
+
schemaVersion: exports_external.literal(LANE_OUTPUT_SCHEMA_VERSION),
|
|
128182
|
+
ref: exports_external.string().regex(REF_RE),
|
|
128183
|
+
batchId: exports_external.string().min(1),
|
|
128184
|
+
laneId: exports_external.string().min(1),
|
|
128185
|
+
agent: exports_external.string().min(1),
|
|
128186
|
+
role: exports_external.string().min(1),
|
|
128187
|
+
sessionId: exports_external.string().min(1).optional(),
|
|
128188
|
+
parentSessionId: exports_external.string().min(1).optional(),
|
|
128189
|
+
mode: exports_external.string().min(1).optional(),
|
|
128190
|
+
source: exports_external.enum(["dispatch_lanes", "collect_lane_results"]),
|
|
128191
|
+
text: exports_external.string(),
|
|
128192
|
+
chars: exports_external.number().int().nonnegative(),
|
|
128193
|
+
bytes: exports_external.number().int().nonnegative(),
|
|
128194
|
+
digest: exports_external.string().regex(/^[a-f0-9]{64}$/),
|
|
128195
|
+
messageCount: exports_external.number().int().nonnegative().optional(),
|
|
128196
|
+
transcriptIncomplete: exports_external.boolean().optional(),
|
|
128197
|
+
createdAt: exports_external.string(),
|
|
128198
|
+
updatedAt: exports_external.string()
|
|
128199
|
+
}).strict();
|
|
128200
|
+
function storeLaneOutput(directory, input, now = Date.now) {
|
|
128201
|
+
const bytes = Buffer.byteLength(input.text, "utf-8");
|
|
128202
|
+
const digest3 = digestText(input.text);
|
|
128203
|
+
if (bytes > MAX_LANE_OUTPUT_STORED_BYTES) {
|
|
128204
|
+
return {
|
|
128205
|
+
digest: digest3,
|
|
128206
|
+
chars: input.text.length,
|
|
128207
|
+
bytes,
|
|
128208
|
+
degraded: true,
|
|
128209
|
+
error: `lane output exceeds ${MAX_LANE_OUTPUT_STORED_BYTES} byte storage limit`
|
|
128210
|
+
};
|
|
128211
|
+
}
|
|
128212
|
+
const batchDigest = digestText(input.batchId);
|
|
128213
|
+
const laneDigest = digestText(input.laneId);
|
|
128214
|
+
const ref = `${LANE_OUTPUT_REF_PREFIX}:${batchDigest}:${laneDigest}:${digest3}`;
|
|
128215
|
+
const relPath = laneOutputRelativePath(ref);
|
|
128216
|
+
const absPath = validateSwarmPath(directory, relPath);
|
|
128217
|
+
const timestamp = new Date(now()).toISOString();
|
|
128218
|
+
try {
|
|
128219
|
+
if (existsSync85(absPath)) {
|
|
128220
|
+
const existing = LaneOutputArtifactSchema.safeParse(JSON.parse(readFileSync60(absPath, "utf-8")));
|
|
128221
|
+
if (existing.success && existing.data.digest === digest3) {
|
|
128222
|
+
return {
|
|
128223
|
+
ref,
|
|
128224
|
+
digest: digest3,
|
|
128225
|
+
chars: existing.data.chars,
|
|
128226
|
+
bytes: existing.data.bytes,
|
|
128227
|
+
degraded: false
|
|
128228
|
+
};
|
|
128229
|
+
}
|
|
128230
|
+
}
|
|
128231
|
+
const artifact = {
|
|
128232
|
+
schemaVersion: LANE_OUTPUT_SCHEMA_VERSION,
|
|
128233
|
+
ref,
|
|
128234
|
+
batchId: input.batchId,
|
|
128235
|
+
laneId: input.laneId,
|
|
128236
|
+
agent: input.agent,
|
|
128237
|
+
role: input.role,
|
|
128238
|
+
...input.sessionId ? { sessionId: input.sessionId } : {},
|
|
128239
|
+
...input.parentSessionId ? { parentSessionId: input.parentSessionId } : {},
|
|
128240
|
+
...input.mode ? { mode: input.mode } : {},
|
|
128241
|
+
source: input.source,
|
|
128242
|
+
text: input.text,
|
|
128243
|
+
chars: input.text.length,
|
|
128244
|
+
bytes,
|
|
128245
|
+
digest: digest3,
|
|
128246
|
+
...input.messageCount !== undefined ? { messageCount: input.messageCount } : {},
|
|
128247
|
+
...input.transcriptIncomplete !== undefined ? { transcriptIncomplete: input.transcriptIncomplete } : {},
|
|
128248
|
+
createdAt: timestamp,
|
|
128249
|
+
updatedAt: timestamp
|
|
128250
|
+
};
|
|
128251
|
+
writeAtomicJson(absPath, artifact);
|
|
128252
|
+
return {
|
|
128253
|
+
ref,
|
|
128254
|
+
digest: digest3,
|
|
128255
|
+
chars: artifact.chars,
|
|
128256
|
+
bytes: artifact.bytes,
|
|
128257
|
+
degraded: false
|
|
128258
|
+
};
|
|
128259
|
+
} catch (error93) {
|
|
128260
|
+
return {
|
|
128261
|
+
digest: digest3,
|
|
128262
|
+
chars: input.text.length,
|
|
128263
|
+
bytes,
|
|
128264
|
+
degraded: true,
|
|
128265
|
+
error: error93 instanceof Error ? error93.message : "failed to store lane output artifact"
|
|
128266
|
+
};
|
|
128267
|
+
}
|
|
128268
|
+
}
|
|
128269
|
+
function readLaneOutput(directory, ref) {
|
|
128270
|
+
if (!REF_RE.test(ref))
|
|
128271
|
+
return null;
|
|
128272
|
+
const absPath = validateSwarmPath(directory, laneOutputRelativePath(ref));
|
|
128273
|
+
if (!existsSync85(absPath))
|
|
128274
|
+
return null;
|
|
128275
|
+
let parsed;
|
|
128276
|
+
try {
|
|
128277
|
+
parsed = LaneOutputArtifactSchema.safeParse(JSON.parse(readFileSync60(absPath, "utf-8")));
|
|
128278
|
+
} catch {
|
|
128279
|
+
return null;
|
|
128280
|
+
}
|
|
128281
|
+
if (!parsed.success || parsed.data.ref !== ref)
|
|
128282
|
+
return null;
|
|
128283
|
+
return { artifact: parsed.data };
|
|
128284
|
+
}
|
|
128285
|
+
function buildLaneOutputPreview(args2) {
|
|
128286
|
+
const { text, ref, degraded, maxChars } = args2;
|
|
128287
|
+
const needsPreview = text.length > maxChars;
|
|
128288
|
+
if (!needsPreview && !degraded) {
|
|
128289
|
+
return {
|
|
128290
|
+
output: text,
|
|
128291
|
+
output_chars: text.length,
|
|
128292
|
+
output_truncated: false
|
|
128293
|
+
};
|
|
128294
|
+
}
|
|
128295
|
+
const marker = buildPreviewMarker({
|
|
128296
|
+
omittedChars: Math.max(0, text.length - maxChars),
|
|
128297
|
+
ref,
|
|
128298
|
+
degraded: degraded === true
|
|
128299
|
+
});
|
|
128300
|
+
if (text.length <= maxChars && degraded) {
|
|
128301
|
+
return {
|
|
128302
|
+
output: `${text}${marker}`,
|
|
128303
|
+
output_chars: text.length,
|
|
128304
|
+
output_truncated: false
|
|
128305
|
+
};
|
|
128306
|
+
}
|
|
128307
|
+
const budget = Math.max(0, maxChars - marker.length);
|
|
128308
|
+
const headChars = Math.ceil(budget / 2);
|
|
128309
|
+
const tailChars = Math.floor(budget / 2);
|
|
128310
|
+
const head = text.slice(0, headChars);
|
|
128311
|
+
const tail = tailChars > 0 ? text.slice(text.length - tailChars) : "";
|
|
128312
|
+
return {
|
|
128313
|
+
output: `${head}${marker}${tail}`,
|
|
128314
|
+
output_chars: text.length,
|
|
128315
|
+
output_truncated: true
|
|
128316
|
+
};
|
|
128317
|
+
}
|
|
128318
|
+
function paginateLaneOutput(text, offset, limit) {
|
|
128319
|
+
const lines = text.length === 0 ? [] : text.split(`
|
|
128320
|
+
`);
|
|
128321
|
+
const totalLines = lines.length;
|
|
128322
|
+
const startLine = Math.max(0, offset);
|
|
128323
|
+
if (startLine >= totalLines) {
|
|
128324
|
+
return {
|
|
128325
|
+
totalLines,
|
|
128326
|
+
startLine,
|
|
128327
|
+
endLine: totalLines,
|
|
128328
|
+
content: "",
|
|
128329
|
+
exhausted: true
|
|
128330
|
+
};
|
|
128331
|
+
}
|
|
128332
|
+
const endLine = Math.min(startLine + limit, totalLines);
|
|
128333
|
+
return {
|
|
128334
|
+
totalLines,
|
|
128335
|
+
startLine,
|
|
128336
|
+
endLine,
|
|
128337
|
+
content: lines.slice(startLine, endLine).join(`
|
|
128338
|
+
`),
|
|
128339
|
+
exhausted: false
|
|
128340
|
+
};
|
|
128341
|
+
}
|
|
128342
|
+
function buildPreviewMarker(args2) {
|
|
128343
|
+
const retrieval = args2.ref ? ` retrieve_lane_output ref=${args2.ref} for full output.` : " no full output artifact is available; treat this lane as degraded.";
|
|
128344
|
+
const degraded = args2.degraded ? " Artifact storage degraded." : "";
|
|
128345
|
+
return `
|
|
128346
|
+
[... lane output preview omitted middle content.${degraded}${retrieval} ...]
|
|
128347
|
+
`;
|
|
128348
|
+
}
|
|
128349
|
+
function laneOutputRelativePath(ref) {
|
|
128350
|
+
const [, batchDigest, laneDigest, outputDigest] = ref.split(":");
|
|
128351
|
+
return path152.join("lane-results", batchDigest, laneDigest, `${outputDigest}.json`);
|
|
128352
|
+
}
|
|
128353
|
+
var WINDOWS_RENAME_MAX_RETRIES3 = 3;
|
|
128354
|
+
function writeAtomicJson(absPath, value) {
|
|
128355
|
+
mkdirSync37(path152.dirname(absPath), { recursive: true });
|
|
128356
|
+
const tempFile = `${absPath}.tmp-${Date.now()}-${process.pid}`;
|
|
128357
|
+
try {
|
|
128358
|
+
writeFileSync24(tempFile, JSON.stringify(value, null, 2), "utf-8");
|
|
128359
|
+
let lastRenameError;
|
|
128360
|
+
for (let attempt = 0;attempt < WINDOWS_RENAME_MAX_RETRIES3; attempt++) {
|
|
128361
|
+
try {
|
|
128362
|
+
renameSync23(tempFile, absPath);
|
|
128363
|
+
lastRenameError = undefined;
|
|
128364
|
+
break;
|
|
128365
|
+
} catch (err2) {
|
|
128366
|
+
lastRenameError = err2;
|
|
128367
|
+
const code = err2.code;
|
|
128368
|
+
if (code !== "EEXIST" && code !== "EBUSY" && code !== "EPERM")
|
|
128369
|
+
break;
|
|
128370
|
+
}
|
|
128371
|
+
}
|
|
128372
|
+
if (lastRenameError)
|
|
128373
|
+
throw lastRenameError;
|
|
128374
|
+
} finally {
|
|
128375
|
+
if (existsSync85(tempFile)) {
|
|
128376
|
+
try {
|
|
128377
|
+
unlinkSync19(tempFile);
|
|
128378
|
+
} catch {}
|
|
128379
|
+
}
|
|
128380
|
+
}
|
|
128381
|
+
}
|
|
128382
|
+
function digestText(text) {
|
|
128383
|
+
return createHash18("sha256").update(text).digest("hex");
|
|
128384
|
+
}
|
|
128385
|
+
|
|
128386
|
+
// src/tools/dispatch-lanes.ts
|
|
127906
128387
|
init_pending_delegations();
|
|
127907
128388
|
init_constants();
|
|
127908
128389
|
init_schema();
|
|
@@ -127969,6 +128450,7 @@ var COMMON_PROMPT_SEPARATOR = `
|
|
|
127969
128450
|
var DEFAULT_TIMEOUT_MS3 = 300000;
|
|
127970
128451
|
var MAX_TIMEOUT_MS2 = 1800000;
|
|
127971
128452
|
var MAX_LANE_OUTPUT_CHARS = 20000;
|
|
128453
|
+
var ASYNC_MESSAGE_FETCH_LIMIT = 50;
|
|
127972
128454
|
var MAX_ERROR_CHARS = 200;
|
|
127973
128455
|
var ERROR_TRUNCATION_SUFFIX = "...";
|
|
127974
128456
|
var MAX_BATCH_ID_CHARS = 120;
|
|
@@ -128324,7 +128806,7 @@ async function launchAsyncLane(args2) {
|
|
|
128324
128806
|
error: message,
|
|
128325
128807
|
chars: message.length,
|
|
128326
128808
|
truncated: false,
|
|
128327
|
-
digest:
|
|
128809
|
+
digest: digestText2(message)
|
|
128328
128810
|
}
|
|
128329
128811
|
});
|
|
128330
128812
|
cleanupAsyncLaunchSession(args2.session, sessionId);
|
|
@@ -128338,7 +128820,7 @@ async function launchAsyncLane(args2) {
|
|
|
128338
128820
|
error: error93,
|
|
128339
128821
|
chars: error93.length,
|
|
128340
128822
|
truncated: false,
|
|
128341
|
-
digest:
|
|
128823
|
+
digest: digestText2(error93)
|
|
128342
128824
|
}
|
|
128343
128825
|
});
|
|
128344
128826
|
cleanupAsyncLaunchSession(args2.session, sessionId);
|
|
@@ -128383,38 +128865,63 @@ async function collectOnce(session, directory, records, cancelPending) {
|
|
|
128383
128865
|
try {
|
|
128384
128866
|
messages = await session.messages({
|
|
128385
128867
|
path: { id: record3.subagentSessionId },
|
|
128386
|
-
query: { directory, limit:
|
|
128868
|
+
query: { directory, limit: ASYNC_MESSAGE_FETCH_LIMIT }
|
|
128387
128869
|
});
|
|
128388
128870
|
} catch {
|
|
128389
128871
|
continue;
|
|
128390
128872
|
}
|
|
128391
128873
|
if (!messages.data)
|
|
128392
128874
|
continue;
|
|
128393
|
-
const
|
|
128394
|
-
if (!text)
|
|
128875
|
+
const transcript = extractAssistantTranscript(messages.data);
|
|
128876
|
+
if (!transcript.text)
|
|
128395
128877
|
continue;
|
|
128396
|
-
const
|
|
128878
|
+
const output = prepareLaneOutput({
|
|
128879
|
+
directory,
|
|
128880
|
+
batchId: record3.batchId ?? record3.callID,
|
|
128881
|
+
laneId: record3.laneId ?? record3.correlationId,
|
|
128882
|
+
agent: record3.swarmPrefixedAgent,
|
|
128883
|
+
role: record3.normalizedAgent,
|
|
128884
|
+
sessionId: record3.subagentSessionId,
|
|
128885
|
+
parentSessionId: record3.parentSessionId,
|
|
128886
|
+
mode: record3.mode,
|
|
128887
|
+
source: "collect_lane_results",
|
|
128888
|
+
text: transcript.text,
|
|
128889
|
+
messageCount: transcript.messageCount,
|
|
128890
|
+
transcriptIncomplete: transcript.transcriptIncomplete
|
|
128891
|
+
});
|
|
128397
128892
|
await appendDelegationTransition(directory, record3.correlationId, {
|
|
128398
128893
|
status: "completed",
|
|
128399
128894
|
result: {
|
|
128400
|
-
text:
|
|
128401
|
-
chars:
|
|
128402
|
-
truncated:
|
|
128403
|
-
digest:
|
|
128895
|
+
text: output.output,
|
|
128896
|
+
chars: output.output_chars,
|
|
128897
|
+
truncated: output.output_truncated,
|
|
128898
|
+
digest: output.output_digest,
|
|
128899
|
+
...output.output_ref ? { outputRef: output.output_ref } : {},
|
|
128900
|
+
outputPreviewChars: output.output.length,
|
|
128901
|
+
...output.output_degraded !== undefined ? { outputDegraded: output.output_degraded } : {},
|
|
128902
|
+
...output.output_artifact_error ? { outputArtifactError: output.output_artifact_error } : {},
|
|
128903
|
+
...output.transcript_incomplete !== undefined ? { transcriptIncomplete: output.transcript_incomplete } : {},
|
|
128904
|
+
messageCount: transcript.messageCount
|
|
128404
128905
|
}
|
|
128405
128906
|
});
|
|
128406
128907
|
}
|
|
128407
128908
|
}
|
|
128408
|
-
function
|
|
128409
|
-
|
|
128410
|
-
|
|
128909
|
+
function extractAssistantTranscript(messages) {
|
|
128910
|
+
const assistantTexts = [];
|
|
128911
|
+
for (const message of messages) {
|
|
128411
128912
|
if (message.info?.role !== "assistant")
|
|
128412
128913
|
continue;
|
|
128413
128914
|
const text = extractText3(message.parts);
|
|
128414
128915
|
if (text.trim().length > 0)
|
|
128415
|
-
|
|
128916
|
+
assistantTexts.push(text);
|
|
128416
128917
|
}
|
|
128417
|
-
return
|
|
128918
|
+
return {
|
|
128919
|
+
text: assistantTexts.join(`
|
|
128920
|
+
|
|
128921
|
+
`),
|
|
128922
|
+
messageCount: assistantTexts.length,
|
|
128923
|
+
transcriptIncomplete: messages.length >= ASYNC_MESSAGE_FETCH_LIMIT
|
|
128924
|
+
};
|
|
128418
128925
|
}
|
|
128419
128926
|
function nextCollectPollInterval(currentMs) {
|
|
128420
128927
|
if (currentMs <= 0)
|
|
@@ -128483,7 +128990,17 @@ async function runLane(session, dispatcher, lane, directory, timeoutMs, context)
|
|
|
128483
128990
|
if (!promptResult.data) {
|
|
128484
128991
|
return failedLane(lane, role, startedAt, `session.prompt failed: ${formatError3(promptResult.error)}`, decision.slot.slotId, decision.slot.runId, sessionId);
|
|
128485
128992
|
}
|
|
128486
|
-
const
|
|
128993
|
+
const laneOutput = prepareLaneOutput({
|
|
128994
|
+
directory,
|
|
128995
|
+
batchId: `blocking:${sessionId}`,
|
|
128996
|
+
laneId: lane.id,
|
|
128997
|
+
agent: lane.agent,
|
|
128998
|
+
role,
|
|
128999
|
+
sessionId,
|
|
129000
|
+
parentSessionId: context.sessionID,
|
|
129001
|
+
source: "dispatch_lanes",
|
|
129002
|
+
text: extractText3(promptResult.data.parts)
|
|
129003
|
+
});
|
|
128487
129004
|
return {
|
|
128488
129005
|
id: lane.id,
|
|
128489
129006
|
agent: lane.agent,
|
|
@@ -128494,7 +129011,7 @@ async function runLane(session, dispatcher, lane, directory, timeoutMs, context)
|
|
|
128494
129011
|
run_id: decision.slot.runId,
|
|
128495
129012
|
started_at: startedAt,
|
|
128496
129013
|
completed_at: isoNow(),
|
|
128497
|
-
...
|
|
129014
|
+
...laneOutput
|
|
128498
129015
|
};
|
|
128499
129016
|
} catch (error93) {
|
|
128500
129017
|
return failedLane(lane, role, startedAt, formatError3(error93), decision.slot.slotId, decision.slot.runId, sessionId);
|
|
@@ -128556,7 +129073,14 @@ function recordToLaneResult(record3) {
|
|
|
128556
129073
|
...record3.result?.text !== undefined ? {
|
|
128557
129074
|
output: record3.result.text,
|
|
128558
129075
|
output_chars: record3.result.chars,
|
|
128559
|
-
output_truncated: record3.result.truncated
|
|
129076
|
+
output_truncated: record3.result.truncated,
|
|
129077
|
+
output_digest: record3.result.digest,
|
|
129078
|
+
...record3.result.outputRef ? { output_ref: record3.result.outputRef } : {},
|
|
129079
|
+
...record3.result.outputPreviewChars !== undefined ? { output_preview_chars: record3.result.outputPreviewChars } : {},
|
|
129080
|
+
...record3.result.outputDegraded !== undefined ? { output_degraded: record3.result.outputDegraded } : {},
|
|
129081
|
+
...record3.result.outputArtifactError ? { output_artifact_error: record3.result.outputArtifactError } : {},
|
|
129082
|
+
...record3.result.transcriptIncomplete !== undefined ? { transcript_incomplete: record3.result.transcriptIncomplete } : {},
|
|
129083
|
+
...record3.result.messageCount !== undefined ? { message_count: record3.result.messageCount } : {}
|
|
128560
129084
|
} : {},
|
|
128561
129085
|
...record3.result?.error !== undefined ? { error: record3.result.error } : {}
|
|
128562
129086
|
};
|
|
@@ -128633,22 +129157,35 @@ function buildReadOnlyTools() {
|
|
|
128633
129157
|
tools.patch = false;
|
|
128634
129158
|
return tools;
|
|
128635
129159
|
}
|
|
128636
|
-
function
|
|
128637
|
-
|
|
128638
|
-
|
|
128639
|
-
|
|
128640
|
-
|
|
128641
|
-
|
|
128642
|
-
|
|
128643
|
-
|
|
128644
|
-
|
|
128645
|
-
|
|
128646
|
-
|
|
128647
|
-
|
|
129160
|
+
function prepareLaneOutput(args2) {
|
|
129161
|
+
const stored = storeLaneOutput(args2.directory, {
|
|
129162
|
+
batchId: args2.batchId,
|
|
129163
|
+
laneId: args2.laneId,
|
|
129164
|
+
agent: args2.agent,
|
|
129165
|
+
role: args2.role,
|
|
129166
|
+
sessionId: args2.sessionId,
|
|
129167
|
+
parentSessionId: args2.parentSessionId,
|
|
129168
|
+
mode: args2.mode,
|
|
129169
|
+
source: args2.source,
|
|
129170
|
+
text: args2.text,
|
|
129171
|
+
messageCount: args2.messageCount,
|
|
129172
|
+
transcriptIncomplete: args2.transcriptIncomplete
|
|
129173
|
+
});
|
|
129174
|
+
const preview = buildLaneOutputPreview({
|
|
129175
|
+
text: args2.text,
|
|
129176
|
+
ref: stored.ref,
|
|
129177
|
+
degraded: stored.degraded,
|
|
129178
|
+
maxChars: MAX_LANE_OUTPUT_CHARS
|
|
129179
|
+
});
|
|
128648
129180
|
return {
|
|
128649
|
-
|
|
128650
|
-
|
|
128651
|
-
|
|
129181
|
+
...preview,
|
|
129182
|
+
output_ref: stored.ref,
|
|
129183
|
+
output_digest: stored.digest,
|
|
129184
|
+
output_preview_chars: preview.output.length,
|
|
129185
|
+
...stored.degraded ? { output_degraded: true } : {},
|
|
129186
|
+
...stored.error ? { output_artifact_error: stored.error } : {},
|
|
129187
|
+
...args2.transcriptIncomplete !== undefined ? { transcript_incomplete: args2.transcriptIncomplete } : {},
|
|
129188
|
+
...args2.messageCount !== undefined ? { message_count: args2.messageCount } : {}
|
|
128652
129189
|
};
|
|
128653
129190
|
}
|
|
128654
129191
|
function failureResult(args2) {
|
|
@@ -128779,7 +129316,7 @@ function makeBatchId() {
|
|
|
128779
129316
|
return `lanes-${_internals85.now().toString(36)}`;
|
|
128780
129317
|
}
|
|
128781
129318
|
function promptHash(lane, directory, batchId) {
|
|
128782
|
-
return
|
|
129319
|
+
return digestText2(JSON.stringify({
|
|
128783
129320
|
batchId,
|
|
128784
129321
|
laneId: lane.id,
|
|
128785
129322
|
agent: lane.agent,
|
|
@@ -128788,8 +129325,8 @@ function promptHash(lane, directory, batchId) {
|
|
|
128788
129325
|
`)
|
|
128789
129326
|
}));
|
|
128790
129327
|
}
|
|
128791
|
-
function
|
|
128792
|
-
return
|
|
129328
|
+
function digestText2(text) {
|
|
129329
|
+
return createHash19("sha256").update(text).digest("hex");
|
|
128793
129330
|
}
|
|
128794
129331
|
function sleep2(ms) {
|
|
128795
129332
|
if (ms <= 0)
|
|
@@ -129052,7 +129589,7 @@ init_zod();
|
|
|
129052
129589
|
init_create_tool();
|
|
129053
129590
|
init_path_security();
|
|
129054
129591
|
import * as fs94 from "node:fs";
|
|
129055
|
-
import * as
|
|
129592
|
+
import * as path153 from "node:path";
|
|
129056
129593
|
var MAX_FILE_SIZE_BYTES5 = 1024 * 1024;
|
|
129057
129594
|
var MAX_EVIDENCE_FILES = 1000;
|
|
129058
129595
|
var EVIDENCE_DIR3 = ".swarm/evidence";
|
|
@@ -129079,9 +129616,9 @@ function validateRequiredTypes(input) {
|
|
|
129079
129616
|
return null;
|
|
129080
129617
|
}
|
|
129081
129618
|
function isPathWithinSwarm2(filePath, cwd) {
|
|
129082
|
-
const normalizedCwd =
|
|
129083
|
-
const swarmPath =
|
|
129084
|
-
const normalizedPath =
|
|
129619
|
+
const normalizedCwd = path153.resolve(cwd);
|
|
129620
|
+
const swarmPath = path153.join(normalizedCwd, ".swarm");
|
|
129621
|
+
const normalizedPath = path153.resolve(filePath);
|
|
129085
129622
|
return normalizedPath.startsWith(swarmPath);
|
|
129086
129623
|
}
|
|
129087
129624
|
function parseCompletedTasks(planContent) {
|
|
@@ -129111,10 +129648,10 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
129111
129648
|
if (!VALID_EVIDENCE_FILENAME_REGEX.test(filename)) {
|
|
129112
129649
|
continue;
|
|
129113
129650
|
}
|
|
129114
|
-
const filePath =
|
|
129651
|
+
const filePath = path153.join(evidenceDir, filename);
|
|
129115
129652
|
try {
|
|
129116
|
-
const resolvedPath =
|
|
129117
|
-
const evidenceDirResolved =
|
|
129653
|
+
const resolvedPath = path153.resolve(filePath);
|
|
129654
|
+
const evidenceDirResolved = path153.resolve(evidenceDir);
|
|
129118
129655
|
if (!resolvedPath.startsWith(evidenceDirResolved)) {
|
|
129119
129656
|
continue;
|
|
129120
129657
|
}
|
|
@@ -129232,7 +129769,7 @@ var evidence_check = createSwarmTool({
|
|
|
129232
129769
|
return JSON.stringify(errorResult, null, 2);
|
|
129233
129770
|
}
|
|
129234
129771
|
const requiredTypes = requiredTypesValue.split(",").map((t) => t.trim()).filter((t) => t.length > 0).map(normalizeEvidenceType);
|
|
129235
|
-
const planPath =
|
|
129772
|
+
const planPath = path153.join(cwd, PLAN_FILE);
|
|
129236
129773
|
if (!isPathWithinSwarm2(planPath, cwd)) {
|
|
129237
129774
|
const errorResult = {
|
|
129238
129775
|
error: "plan file path validation failed",
|
|
@@ -129264,7 +129801,7 @@ var evidence_check = createSwarmTool({
|
|
|
129264
129801
|
};
|
|
129265
129802
|
return JSON.stringify(result2, null, 2);
|
|
129266
129803
|
}
|
|
129267
|
-
const evidenceDir =
|
|
129804
|
+
const evidenceDir = path153.join(cwd, EVIDENCE_DIR3);
|
|
129268
129805
|
const evidence = readEvidenceFiles(evidenceDir, cwd);
|
|
129269
129806
|
const { tasksWithFullEvidence, gaps } = analyzeGaps(completedTasks, evidence, requiredTypes);
|
|
129270
129807
|
const completeness = completedTasks.length > 0 ? Math.round(tasksWithFullEvidence.length / completedTasks.length * 100) / 100 : 1;
|
|
@@ -129287,7 +129824,7 @@ init_loader();
|
|
|
129287
129824
|
init_task_file();
|
|
129288
129825
|
import * as crypto11 from "node:crypto";
|
|
129289
129826
|
import * as fs95 from "node:fs/promises";
|
|
129290
|
-
import * as
|
|
129827
|
+
import * as path154 from "node:path";
|
|
129291
129828
|
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
129829
|
var EVICTABLE_VERDICTS = new Set([
|
|
129293
129830
|
"pending",
|
|
@@ -129300,7 +129837,7 @@ function candidateFilePath(storePath3, id) {
|
|
|
129300
129837
|
if (!isValidCandidateId(id)) {
|
|
129301
129838
|
return null;
|
|
129302
129839
|
}
|
|
129303
|
-
return
|
|
129840
|
+
return path154.join(storePath3, `${id}.json`);
|
|
129304
129841
|
}
|
|
129305
129842
|
var _internals86 = {
|
|
129306
129843
|
randomUUID: crypto11.randomUUID.bind(crypto11),
|
|
@@ -129313,11 +129850,11 @@ var _internals86 = {
|
|
|
129313
129850
|
atomicWriteFile
|
|
129314
129851
|
};
|
|
129315
129852
|
function createExternalSkillStore(directory, config3) {
|
|
129316
|
-
const storePath3 =
|
|
129853
|
+
const storePath3 = path154.join(directory, ".swarm", "skills", "candidates");
|
|
129317
129854
|
async function add2(candidate) {
|
|
129318
129855
|
const id = _internals86.randomUUID();
|
|
129319
129856
|
const full = { ...candidate, id };
|
|
129320
|
-
const filePath =
|
|
129857
|
+
const filePath = path154.join(storePath3, `${id}.json`);
|
|
129321
129858
|
await _internals86.fs.mkdir(storePath3, { recursive: true });
|
|
129322
129859
|
await _internals86.atomicWriteFile(filePath, JSON.stringify(full, null, "\t"));
|
|
129323
129860
|
return full;
|
|
@@ -129357,7 +129894,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
129357
129894
|
if (!entry.endsWith(".json")) {
|
|
129358
129895
|
continue;
|
|
129359
129896
|
}
|
|
129360
|
-
const filePath =
|
|
129897
|
+
const filePath = path154.join(storePath3, entry);
|
|
129361
129898
|
let raw;
|
|
129362
129899
|
try {
|
|
129363
129900
|
raw = await _internals86.fs.readFile(filePath, "utf-8");
|
|
@@ -129541,11 +130078,11 @@ var external_skill_delete = createSwarmTool({
|
|
|
129541
130078
|
// src/tools/external-skill-discover.ts
|
|
129542
130079
|
init_zod();
|
|
129543
130080
|
init_loader();
|
|
129544
|
-
import { createHash as
|
|
130081
|
+
import { createHash as createHash21, randomUUID as randomUUID12 } from "node:crypto";
|
|
129545
130082
|
|
|
129546
130083
|
// src/services/external-skill-validator.ts
|
|
129547
130084
|
init_knowledge_validator();
|
|
129548
|
-
import { createHash as
|
|
130085
|
+
import { createHash as createHash20 } from "node:crypto";
|
|
129549
130086
|
var PROMPT_INJECTION_PATTERNS = [
|
|
129550
130087
|
{
|
|
129551
130088
|
pattern: /system\s*:/i,
|
|
@@ -130080,7 +130617,7 @@ function evaluateCandidate(candidate, options) {
|
|
|
130080
130617
|
}
|
|
130081
130618
|
var _internals88 = {
|
|
130082
130619
|
getTimestamp: () => new Date().toISOString(),
|
|
130083
|
-
computeSha256: (content) =>
|
|
130620
|
+
computeSha256: (content) => createHash20("sha256").update(content).digest("hex"),
|
|
130084
130621
|
stripMarkdownCodeForUnsafeScan
|
|
130085
130622
|
};
|
|
130086
130623
|
|
|
@@ -130102,7 +130639,7 @@ var _internals89 = {
|
|
|
130102
130639
|
return { content, finalUrl: response.url };
|
|
130103
130640
|
},
|
|
130104
130641
|
getTimestamp: () => new Date().toISOString(),
|
|
130105
|
-
computeSha256: (content) =>
|
|
130642
|
+
computeSha256: (content) => createHash21("sha256").update(content).digest("hex"),
|
|
130106
130643
|
uuid: () => randomUUID12()
|
|
130107
130644
|
};
|
|
130108
130645
|
var SOURCE_TRUST_LEVELS = {
|
|
@@ -130488,9 +131025,9 @@ var external_skill_list = createSwarmTool({
|
|
|
130488
131025
|
// src/tools/external-skill-promote.ts
|
|
130489
131026
|
init_zod();
|
|
130490
131027
|
init_loader();
|
|
130491
|
-
import { createHash as
|
|
131028
|
+
import { createHash as createHash22 } from "node:crypto";
|
|
130492
131029
|
import * as fs96 from "node:fs/promises";
|
|
130493
|
-
import * as
|
|
131030
|
+
import * as path155 from "node:path";
|
|
130494
131031
|
init_create_tool();
|
|
130495
131032
|
var _internals92 = {
|
|
130496
131033
|
loadConfig: (directory) => {
|
|
@@ -130507,7 +131044,7 @@ var _internals92 = {
|
|
|
130507
131044
|
}
|
|
130508
131045
|
},
|
|
130509
131046
|
writeSkillFile: async (filePath, content) => {
|
|
130510
|
-
await fs96.mkdir(
|
|
131047
|
+
await fs96.mkdir(path155.dirname(filePath), { recursive: true });
|
|
130511
131048
|
const handle2 = await fs96.open(filePath, "wx");
|
|
130512
131049
|
try {
|
|
130513
131050
|
await handle2.writeFile(content, "utf-8");
|
|
@@ -130630,8 +131167,8 @@ var external_skill_promote = createSwarmTool({
|
|
|
130630
131167
|
error: "Re-validation failed — candidate no longer passes gates"
|
|
130631
131168
|
});
|
|
130632
131169
|
}
|
|
130633
|
-
const targetDir =
|
|
130634
|
-
const targetPath =
|
|
131170
|
+
const targetDir = path155.join(directory, ".opencode", "skills", "generated", sanitizedSlug);
|
|
131171
|
+
const targetPath = path155.join(targetDir, "SKILL.md");
|
|
130635
131172
|
const timestamp = _internals92.getTimestamp();
|
|
130636
131173
|
const alreadyExists = await _internals92.fileExists(targetPath);
|
|
130637
131174
|
if (alreadyExists) {
|
|
@@ -130653,7 +131190,7 @@ var external_skill_promote = createSwarmTool({
|
|
|
130653
131190
|
}
|
|
130654
131191
|
throw writeErr;
|
|
130655
131192
|
}
|
|
130656
|
-
const promotedContentHash =
|
|
131193
|
+
const promotedContentHash = createHash22("sha256").update(skillMarkdown).digest("hex");
|
|
130657
131194
|
const prePromotionHistory = candidate.evaluation_history;
|
|
130658
131195
|
const lastPrePromotionEntry = prePromotionHistory.length > 0 ? prePromotionHistory[prePromotionHistory.length - 1] : undefined;
|
|
130659
131196
|
const originalEvaluation = lastPrePromotionEntry ? {
|
|
@@ -130805,7 +131342,7 @@ var external_skill_reject = createSwarmTool({
|
|
|
130805
131342
|
// src/tools/external-skill-revoke.ts
|
|
130806
131343
|
init_zod();
|
|
130807
131344
|
init_loader();
|
|
130808
|
-
import * as
|
|
131345
|
+
import * as path156 from "node:path";
|
|
130809
131346
|
init_create_tool();
|
|
130810
131347
|
var _internals94 = {
|
|
130811
131348
|
loadConfig: (directory) => {
|
|
@@ -130904,7 +131441,7 @@ var external_skill_revoke = createSwarmTool({
|
|
|
130904
131441
|
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
131442
|
});
|
|
130906
131443
|
}
|
|
130907
|
-
const skillPath =
|
|
131444
|
+
const skillPath = path156.join(directory, ".opencode", "skills", "generated", slug, "SKILL.md");
|
|
130908
131445
|
const skillFileRemoved = await _internals94.retireSkillFile(skillPath);
|
|
130909
131446
|
const timestamp = _internals94.getTimestamp();
|
|
130910
131447
|
const historyEntry = {
|
|
@@ -130937,7 +131474,7 @@ var external_skill_revoke = createSwarmTool({
|
|
|
130937
131474
|
init_zod();
|
|
130938
131475
|
init_create_tool();
|
|
130939
131476
|
import * as fs97 from "node:fs";
|
|
130940
|
-
import * as
|
|
131477
|
+
import * as path157 from "node:path";
|
|
130941
131478
|
var EXT_MAP = {
|
|
130942
131479
|
python: ".py",
|
|
130943
131480
|
py: ".py",
|
|
@@ -131018,12 +131555,12 @@ var extract_code_blocks = createSwarmTool({
|
|
|
131018
131555
|
if (prefix) {
|
|
131019
131556
|
filename = `${prefix}_${filename}`;
|
|
131020
131557
|
}
|
|
131021
|
-
let filepath =
|
|
131022
|
-
const base =
|
|
131023
|
-
const ext =
|
|
131558
|
+
let filepath = path157.join(targetDir, filename);
|
|
131559
|
+
const base = path157.basename(filepath, path157.extname(filepath));
|
|
131560
|
+
const ext = path157.extname(filepath);
|
|
131024
131561
|
let counter = 1;
|
|
131025
131562
|
while (fs97.existsSync(filepath)) {
|
|
131026
|
-
filepath =
|
|
131563
|
+
filepath = path157.join(targetDir, `${base}_${counter}${ext}`);
|
|
131027
131564
|
counter++;
|
|
131028
131565
|
}
|
|
131029
131566
|
try {
|
|
@@ -131377,7 +131914,7 @@ init_path_security();
|
|
|
131377
131914
|
init_create_tool();
|
|
131378
131915
|
import * as child_process12 from "node:child_process";
|
|
131379
131916
|
import * as fs98 from "node:fs";
|
|
131380
|
-
import * as
|
|
131917
|
+
import * as path158 from "node:path";
|
|
131381
131918
|
var BLAME_TIMEOUT_MS = 30000;
|
|
131382
131919
|
var MAX_OUTPUT_LINES2 = 500;
|
|
131383
131920
|
var MAX_PATH_LENGTH2 = 500;
|
|
@@ -131435,7 +131972,7 @@ function validateFilePath(filePath) {
|
|
|
131435
131972
|
if (filePath.length > MAX_PATH_LENGTH2) {
|
|
131436
131973
|
return `file path exceeds maximum length of ${MAX_PATH_LENGTH2}`;
|
|
131437
131974
|
}
|
|
131438
|
-
if (
|
|
131975
|
+
if (path158.isAbsolute(filePath)) {
|
|
131439
131976
|
return "absolute paths are not allowed; use a relative path from the project root";
|
|
131440
131977
|
}
|
|
131441
131978
|
if (containsPathTraversal(filePath)) {
|
|
@@ -131464,7 +132001,7 @@ function validateLineNumber(value, name2) {
|
|
|
131464
132001
|
return null;
|
|
131465
132002
|
}
|
|
131466
132003
|
function isBinaryFile2(filePath) {
|
|
131467
|
-
const ext =
|
|
132004
|
+
const ext = path158.extname(filePath).toLowerCase();
|
|
131468
132005
|
return BINARY_EXTENSIONS.has(ext);
|
|
131469
132006
|
}
|
|
131470
132007
|
function parsePorcelainBlame(output, linesCap) {
|
|
@@ -131611,7 +132148,7 @@ var git_blame = createSwarmTool({
|
|
|
131611
132148
|
lines: []
|
|
131612
132149
|
});
|
|
131613
132150
|
}
|
|
131614
|
-
const resolvedPath =
|
|
132151
|
+
const resolvedPath = path158.resolve(directory, file3);
|
|
131615
132152
|
if (!fs98.existsSync(resolvedPath)) {
|
|
131616
132153
|
return JSON.stringify({
|
|
131617
132154
|
error: `file not found: ${file3}`,
|
|
@@ -131622,8 +132159,8 @@ var git_blame = createSwarmTool({
|
|
|
131622
132159
|
}
|
|
131623
132160
|
const realDir = fs98.realpathSync(directory);
|
|
131624
132161
|
const realPath = fs98.realpathSync(resolvedPath);
|
|
131625
|
-
const relative32 =
|
|
131626
|
-
if (relative32.startsWith("..") ||
|
|
132162
|
+
const relative32 = path158.relative(realDir, realPath);
|
|
132163
|
+
if (relative32.startsWith("..") || path158.isAbsolute(relative32)) {
|
|
131627
132164
|
return JSON.stringify({
|
|
131628
132165
|
error: "file path resolves outside the workspace",
|
|
131629
132166
|
file: file3,
|
|
@@ -131975,7 +132512,7 @@ init_zod();
|
|
|
131975
132512
|
init_create_tool();
|
|
131976
132513
|
init_path_security();
|
|
131977
132514
|
import * as fs99 from "node:fs";
|
|
131978
|
-
import * as
|
|
132515
|
+
import * as path159 from "node:path";
|
|
131979
132516
|
var MAX_FILE_PATH_LENGTH2 = 500;
|
|
131980
132517
|
var MAX_SYMBOL_LENGTH = 256;
|
|
131981
132518
|
var MAX_FILE_SIZE_BYTES6 = 1024 * 1024;
|
|
@@ -132023,7 +132560,7 @@ function validateSymbolInput(symbol3) {
|
|
|
132023
132560
|
return null;
|
|
132024
132561
|
}
|
|
132025
132562
|
function isBinaryFile3(filePath, buffer) {
|
|
132026
|
-
const ext =
|
|
132563
|
+
const ext = path159.extname(filePath).toLowerCase();
|
|
132027
132564
|
if (ext === ".json" || ext === ".md" || ext === ".txt") {
|
|
132028
132565
|
return false;
|
|
132029
132566
|
}
|
|
@@ -132047,15 +132584,15 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
132047
132584
|
const imports = [];
|
|
132048
132585
|
let _resolvedTarget;
|
|
132049
132586
|
try {
|
|
132050
|
-
_resolvedTarget =
|
|
132587
|
+
_resolvedTarget = path159.resolve(targetFile);
|
|
132051
132588
|
} catch {
|
|
132052
132589
|
_resolvedTarget = targetFile;
|
|
132053
132590
|
}
|
|
132054
|
-
const targetBasename =
|
|
132591
|
+
const targetBasename = path159.basename(targetFile, path159.extname(targetFile));
|
|
132055
132592
|
const targetWithExt = targetFile;
|
|
132056
132593
|
const targetWithoutExt = targetFile.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
132057
|
-
const normalizedTargetWithExt =
|
|
132058
|
-
const normalizedTargetWithoutExt =
|
|
132594
|
+
const normalizedTargetWithExt = path159.normalize(targetWithExt).replace(/\\/g, "/");
|
|
132595
|
+
const normalizedTargetWithoutExt = path159.normalize(targetWithoutExt).replace(/\\/g, "/");
|
|
132059
132596
|
const importRegex = /import\s+(?:\{[\s\S]*?\}|(?:\*\s+as\s+\w+)|\w+)\s+from\s+['"`]([^'"`]+)['"`]|import\s+['"`]([^'"`]+)['"`]|require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
132060
132597
|
for (let match = importRegex.exec(content);match !== null; match = importRegex.exec(content)) {
|
|
132061
132598
|
const modulePath = match[1] || match[2] || match[3];
|
|
@@ -132078,9 +132615,9 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
132078
132615
|
}
|
|
132079
132616
|
const _normalizedModule = modulePath.replace(/^\.\//, "").replace(/^\.\.\\/, "../");
|
|
132080
132617
|
let isMatch = false;
|
|
132081
|
-
const _targetDir =
|
|
132082
|
-
const targetExt =
|
|
132083
|
-
const targetBasenameNoExt =
|
|
132618
|
+
const _targetDir = path159.dirname(targetFile);
|
|
132619
|
+
const targetExt = path159.extname(targetFile);
|
|
132620
|
+
const targetBasenameNoExt = path159.basename(targetFile, targetExt);
|
|
132084
132621
|
const moduleNormalized = modulePath.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
132085
132622
|
const moduleName = modulePath.split(/[/\\]/).pop() || "";
|
|
132086
132623
|
const moduleNameNoExt = moduleName.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
@@ -132148,10 +132685,10 @@ function findSourceFiles2(dir, files = [], stats2 = { skippedDirs: [], skippedFi
|
|
|
132148
132685
|
entries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
132149
132686
|
for (const entry of entries) {
|
|
132150
132687
|
if (SKIP_DIRECTORIES5.has(entry)) {
|
|
132151
|
-
stats2.skippedDirs.push(
|
|
132688
|
+
stats2.skippedDirs.push(path159.join(dir, entry));
|
|
132152
132689
|
continue;
|
|
132153
132690
|
}
|
|
132154
|
-
const fullPath =
|
|
132691
|
+
const fullPath = path159.join(dir, entry);
|
|
132155
132692
|
let stat14;
|
|
132156
132693
|
try {
|
|
132157
132694
|
stat14 = fs99.statSync(fullPath);
|
|
@@ -132165,7 +132702,7 @@ function findSourceFiles2(dir, files = [], stats2 = { skippedDirs: [], skippedFi
|
|
|
132165
132702
|
if (stat14.isDirectory()) {
|
|
132166
132703
|
findSourceFiles2(fullPath, files, stats2);
|
|
132167
132704
|
} else if (stat14.isFile()) {
|
|
132168
|
-
const ext =
|
|
132705
|
+
const ext = path159.extname(fullPath).toLowerCase();
|
|
132169
132706
|
if (SUPPORTED_EXTENSIONS3.includes(ext)) {
|
|
132170
132707
|
files.push(fullPath);
|
|
132171
132708
|
}
|
|
@@ -132222,7 +132759,7 @@ var imports = createSwarmTool({
|
|
|
132222
132759
|
return JSON.stringify(errorResult, null, 2);
|
|
132223
132760
|
}
|
|
132224
132761
|
try {
|
|
132225
|
-
const targetFile =
|
|
132762
|
+
const targetFile = path159.resolve(file3);
|
|
132226
132763
|
if (!fs99.existsSync(targetFile)) {
|
|
132227
132764
|
const errorResult = {
|
|
132228
132765
|
error: `target file not found: ${file3}`,
|
|
@@ -132244,7 +132781,7 @@ var imports = createSwarmTool({
|
|
|
132244
132781
|
};
|
|
132245
132782
|
return JSON.stringify(errorResult, null, 2);
|
|
132246
132783
|
}
|
|
132247
|
-
const baseDir =
|
|
132784
|
+
const baseDir = path159.dirname(targetFile);
|
|
132248
132785
|
const scanStats = {
|
|
132249
132786
|
skippedDirs: [],
|
|
132250
132787
|
skippedFiles: 0,
|
|
@@ -132660,7 +133197,7 @@ init_zod();
|
|
|
132660
133197
|
init_config();
|
|
132661
133198
|
init_knowledge_store();
|
|
132662
133199
|
init_create_tool();
|
|
132663
|
-
import { existsSync as
|
|
133200
|
+
import { existsSync as existsSync90 } from "node:fs";
|
|
132664
133201
|
var DEFAULT_LIMIT = 10;
|
|
132665
133202
|
var MAX_LESSON_LENGTH = 200;
|
|
132666
133203
|
var VALID_CATEGORIES3 = [
|
|
@@ -132736,14 +133273,14 @@ function validateLimit(limit) {
|
|
|
132736
133273
|
}
|
|
132737
133274
|
async function readSwarmKnowledge(directory) {
|
|
132738
133275
|
const swarmPath = resolveSwarmKnowledgePath(directory);
|
|
132739
|
-
if (!
|
|
133276
|
+
if (!existsSync90(swarmPath)) {
|
|
132740
133277
|
return [];
|
|
132741
133278
|
}
|
|
132742
133279
|
return readKnowledge(swarmPath);
|
|
132743
133280
|
}
|
|
132744
133281
|
async function readHiveKnowledge() {
|
|
132745
133282
|
const hivePath = resolveHiveKnowledgePath();
|
|
132746
|
-
if (!
|
|
133283
|
+
if (!existsSync90(hivePath)) {
|
|
132747
133284
|
return [];
|
|
132748
133285
|
}
|
|
132749
133286
|
return readKnowledge(hivePath);
|
|
@@ -133193,11 +133730,11 @@ var lean_turbo_acquire_locks = createSwarmTool({
|
|
|
133193
133730
|
init_zod();
|
|
133194
133731
|
init_constants();
|
|
133195
133732
|
import * as fs101 from "node:fs";
|
|
133196
|
-
import * as
|
|
133733
|
+
import * as path161 from "node:path";
|
|
133197
133734
|
|
|
133198
133735
|
// src/turbo/lean/conflicts.ts
|
|
133199
133736
|
import * as fs100 from "node:fs";
|
|
133200
|
-
import * as
|
|
133737
|
+
import * as path160 from "node:path";
|
|
133201
133738
|
var DEFAULT_GLOBAL_FILES = [
|
|
133202
133739
|
"package.json",
|
|
133203
133740
|
"package-lock.json",
|
|
@@ -133324,7 +133861,7 @@ function isProtectedPath3(normalizedPath) {
|
|
|
133324
133861
|
return false;
|
|
133325
133862
|
}
|
|
133326
133863
|
function readTaskScopes(directory, taskId) {
|
|
133327
|
-
const scopePath =
|
|
133864
|
+
const scopePath = path160.join(directory, ".swarm", "scopes", `scope-${taskId}.json`);
|
|
133328
133865
|
try {
|
|
133329
133866
|
if (!fs100.existsSync(scopePath)) {
|
|
133330
133867
|
return null;
|
|
@@ -133712,7 +134249,7 @@ function createEmptyPlan(phaseNumber, planId) {
|
|
|
133712
134249
|
// src/tools/lean-turbo-plan-lanes.ts
|
|
133713
134250
|
init_create_tool();
|
|
133714
134251
|
function readPlanJson(directory) {
|
|
133715
|
-
const planPath =
|
|
134252
|
+
const planPath = path161.join(directory, ".swarm", "plan.json");
|
|
133716
134253
|
if (!fs101.existsSync(planPath)) {
|
|
133717
134254
|
return null;
|
|
133718
134255
|
}
|
|
@@ -134872,12 +135409,12 @@ var lint_spec = createSwarmTool({
|
|
|
134872
135409
|
// src/tools/mutation-test.ts
|
|
134873
135410
|
init_zod();
|
|
134874
135411
|
import * as fs102 from "node:fs";
|
|
134875
|
-
import * as
|
|
135412
|
+
import * as path163 from "node:path";
|
|
134876
135413
|
|
|
134877
135414
|
// src/mutation/engine.ts
|
|
134878
135415
|
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
134879
|
-
import { unlinkSync as
|
|
134880
|
-
import * as
|
|
135416
|
+
import { unlinkSync as unlinkSync20, writeFileSync as writeFileSync26 } from "node:fs";
|
|
135417
|
+
import * as path162 from "node:path";
|
|
134881
135418
|
|
|
134882
135419
|
// src/mutation/equivalence.ts
|
|
134883
135420
|
function isStaticallyEquivalent(originalCode, mutatedCode) {
|
|
@@ -135040,7 +135577,7 @@ function validateTestCommand(testCommand) {
|
|
|
135040
135577
|
return "testCommand must not be empty";
|
|
135041
135578
|
}
|
|
135042
135579
|
const exe = testCommand[0];
|
|
135043
|
-
const base =
|
|
135580
|
+
const base = path162.basename(exe).replace(/\.(exe|cmd|bat)$/i, "");
|
|
135044
135581
|
if (!ALLOWED_TEST_RUNNERS.has(base)) {
|
|
135045
135582
|
return `testCommand executable '${exe}' is not in the allowed test runner list. Permitted runners: ${[...ALLOWED_TEST_RUNNERS].join(", ")}`;
|
|
135046
135583
|
}
|
|
@@ -135064,9 +135601,9 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
|
|
|
135064
135601
|
let patchFile;
|
|
135065
135602
|
try {
|
|
135066
135603
|
const safeId2 = patch.id.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
135067
|
-
patchFile =
|
|
135604
|
+
patchFile = path162.join(workingDir, `.mutation_patch_${safeId2}.diff`);
|
|
135068
135605
|
try {
|
|
135069
|
-
|
|
135606
|
+
writeFileSync26(patchFile, patch.patch);
|
|
135070
135607
|
} catch (writeErr) {
|
|
135071
135608
|
error93 = `Failed to write patch file: ${writeErr}`;
|
|
135072
135609
|
outcome = "error";
|
|
@@ -135164,7 +135701,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
|
|
|
135164
135701
|
revertError = new Error(`Failed to revert mutation ${patch.id}: ${revertErr}. Working tree may be dirty.`);
|
|
135165
135702
|
}
|
|
135166
135703
|
try {
|
|
135167
|
-
|
|
135704
|
+
unlinkSync20(patchFile);
|
|
135168
135705
|
} catch (_unlinkErr) {}
|
|
135169
135706
|
}
|
|
135170
135707
|
}
|
|
@@ -135481,7 +136018,7 @@ var mutation_test = createSwarmTool({
|
|
|
135481
136018
|
];
|
|
135482
136019
|
for (const filePath of uniquePaths) {
|
|
135483
136020
|
try {
|
|
135484
|
-
const resolvedPath =
|
|
136021
|
+
const resolvedPath = path163.resolve(cwd, filePath);
|
|
135485
136022
|
sourceFiles.set(filePath, fs102.readFileSync(resolvedPath, "utf-8"));
|
|
135486
136023
|
} catch {}
|
|
135487
136024
|
}
|
|
@@ -135504,22 +136041,22 @@ init_schema();
|
|
|
135504
136041
|
init_manager2();
|
|
135505
136042
|
init_task_file();
|
|
135506
136043
|
import * as fs112 from "node:fs";
|
|
135507
|
-
import * as
|
|
136044
|
+
import * as path173 from "node:path";
|
|
135508
136045
|
|
|
135509
136046
|
// src/full-auto/phase-approval.ts
|
|
135510
136047
|
init_utils2();
|
|
135511
136048
|
init_logger();
|
|
135512
136049
|
init_state2();
|
|
135513
136050
|
import * as fs103 from "node:fs";
|
|
135514
|
-
import * as
|
|
136051
|
+
import * as path164 from "node:path";
|
|
135515
136052
|
var APPROVAL_TTL_MS = 24 * 60 * 60 * 1000;
|
|
135516
136053
|
function readEvidenceDir(directory, phase) {
|
|
135517
136054
|
try {
|
|
135518
|
-
const dirPath = validateSwarmPath(directory,
|
|
136055
|
+
const dirPath = validateSwarmPath(directory, path164.posix.join("evidence", String(phase)));
|
|
135519
136056
|
if (!fs103.existsSync(dirPath))
|
|
135520
136057
|
return [];
|
|
135521
136058
|
const entries = fs103.readdirSync(dirPath);
|
|
135522
|
-
return entries.filter((e) => e.startsWith("full-auto-") && e.endsWith(".json")).map((e) =>
|
|
136059
|
+
return entries.filter((e) => e.startsWith("full-auto-") && e.endsWith(".json")).map((e) => path164.join(dirPath, e));
|
|
135523
136060
|
} catch {
|
|
135524
136061
|
return [];
|
|
135525
136062
|
}
|
|
@@ -135774,16 +136311,16 @@ init_plan_schema();
|
|
|
135774
136311
|
init_ledger();
|
|
135775
136312
|
init_manager();
|
|
135776
136313
|
import * as fs104 from "node:fs";
|
|
135777
|
-
import * as
|
|
136314
|
+
import * as path165 from "node:path";
|
|
135778
136315
|
async function writeCheckpoint(directory) {
|
|
135779
136316
|
try {
|
|
135780
136317
|
const plan = await loadPlan(directory);
|
|
135781
136318
|
if (!plan)
|
|
135782
136319
|
return;
|
|
135783
|
-
const swarmDir =
|
|
136320
|
+
const swarmDir = path165.join(directory, ".swarm");
|
|
135784
136321
|
fs104.mkdirSync(swarmDir, { recursive: true });
|
|
135785
|
-
const jsonPath =
|
|
135786
|
-
const mdPath =
|
|
136322
|
+
const jsonPath = path165.join(swarmDir, "SWARM_PLAN.json");
|
|
136323
|
+
const mdPath = path165.join(swarmDir, "SWARM_PLAN.md");
|
|
135787
136324
|
fs104.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
|
|
135788
136325
|
const md = derivePlanMarkdown(plan);
|
|
135789
136326
|
fs104.writeFileSync(mdPath, md, "utf8");
|
|
@@ -135803,7 +136340,7 @@ init_telemetry();
|
|
|
135803
136340
|
// src/turbo/lean/phase-ready.ts
|
|
135804
136341
|
init_file_locks();
|
|
135805
136342
|
import * as fs105 from "node:fs";
|
|
135806
|
-
import * as
|
|
136343
|
+
import * as path166 from "node:path";
|
|
135807
136344
|
init_state3();
|
|
135808
136345
|
var DEFAULT_CONFIG3 = {
|
|
135809
136346
|
phase_reviewer: true,
|
|
@@ -135812,7 +136349,7 @@ var DEFAULT_CONFIG3 = {
|
|
|
135812
136349
|
};
|
|
135813
136350
|
function defaultReadPlanJson(dir) {
|
|
135814
136351
|
try {
|
|
135815
|
-
const planPath =
|
|
136352
|
+
const planPath = path166.join(dir, ".swarm", "plan.json");
|
|
135816
136353
|
if (!fs105.existsSync(planPath))
|
|
135817
136354
|
return null;
|
|
135818
136355
|
const raw = fs105.readFileSync(planPath, "utf-8");
|
|
@@ -135827,7 +136364,7 @@ function defaultReadPlanJson(dir) {
|
|
|
135827
136364
|
}
|
|
135828
136365
|
function readReviewerEvidenceFromFile(directory, phase) {
|
|
135829
136366
|
try {
|
|
135830
|
-
const evidencePath =
|
|
136367
|
+
const evidencePath = path166.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-reviewer.json");
|
|
135831
136368
|
if (!fs105.existsSync(evidencePath)) {
|
|
135832
136369
|
return null;
|
|
135833
136370
|
}
|
|
@@ -135847,7 +136384,7 @@ function readReviewerEvidenceFromFile(directory, phase) {
|
|
|
135847
136384
|
}
|
|
135848
136385
|
function readCriticEvidenceFromFile(directory, phase) {
|
|
135849
136386
|
try {
|
|
135850
|
-
const evidencePath =
|
|
136387
|
+
const evidencePath = path166.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-critic.json");
|
|
135851
136388
|
if (!fs105.existsSync(evidencePath)) {
|
|
135852
136389
|
return null;
|
|
135853
136390
|
}
|
|
@@ -135866,7 +136403,7 @@ function readCriticEvidenceFromFile(directory, phase) {
|
|
|
135866
136403
|
}
|
|
135867
136404
|
}
|
|
135868
136405
|
function listLaneEvidenceSync(directory, phase) {
|
|
135869
|
-
const evidenceDir =
|
|
136406
|
+
const evidenceDir = path166.join(directory, ".swarm", "evidence", String(phase), "lean-turbo");
|
|
135870
136407
|
let entries;
|
|
135871
136408
|
try {
|
|
135872
136409
|
entries = fs105.readdirSync(evidenceDir);
|
|
@@ -135936,7 +136473,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
135936
136473
|
...DEFAULT_CONFIG3,
|
|
135937
136474
|
...actualConfig
|
|
135938
136475
|
};
|
|
135939
|
-
const statePath =
|
|
136476
|
+
const statePath = path166.join(directory, ".swarm", "turbo-state.json");
|
|
135940
136477
|
if (!fs105.existsSync(statePath)) {
|
|
135941
136478
|
return {
|
|
135942
136479
|
ok: false,
|
|
@@ -136124,7 +136661,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
136124
136661
|
}
|
|
136125
136662
|
}
|
|
136126
136663
|
if (mergedConfig.integrated_diff_required) {
|
|
136127
|
-
const evidencePath =
|
|
136664
|
+
const evidencePath = path166.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-phase.json");
|
|
136128
136665
|
let hasDiff = false;
|
|
136129
136666
|
try {
|
|
136130
136667
|
const content = fs105.readFileSync(evidencePath, "utf-8");
|
|
@@ -136290,7 +136827,7 @@ async function runCompletionVerifyGate(ctx) {
|
|
|
136290
136827
|
// src/tools/phase-complete/gates/drift-gate.ts
|
|
136291
136828
|
init_effective_spec();
|
|
136292
136829
|
import * as fs106 from "node:fs";
|
|
136293
|
-
import * as
|
|
136830
|
+
import * as path167 from "node:path";
|
|
136294
136831
|
|
|
136295
136832
|
// src/tools/phase-complete/gates/gate-helpers.ts
|
|
136296
136833
|
init_qa_gate_profile();
|
|
@@ -136339,7 +136876,7 @@ async function runDriftGate(ctx) {
|
|
|
136339
136876
|
}
|
|
136340
136877
|
let phaseType;
|
|
136341
136878
|
try {
|
|
136342
|
-
const planPath =
|
|
136879
|
+
const planPath = path167.join(dir, ".swarm", "plan.json");
|
|
136343
136880
|
if (fs106.existsSync(planPath)) {
|
|
136344
136881
|
const planRaw = fs106.readFileSync(planPath, "utf-8");
|
|
136345
136882
|
const plan = JSON.parse(planRaw);
|
|
@@ -136358,7 +136895,7 @@ async function runDriftGate(ctx) {
|
|
|
136358
136895
|
};
|
|
136359
136896
|
}
|
|
136360
136897
|
try {
|
|
136361
|
-
const driftEvidencePath =
|
|
136898
|
+
const driftEvidencePath = path167.join(dir, ".swarm", "evidence", String(phase), "drift-verifier.json");
|
|
136362
136899
|
let driftVerdictFound = false;
|
|
136363
136900
|
let driftVerdictApproved = false;
|
|
136364
136901
|
try {
|
|
@@ -136399,7 +136936,7 @@ async function runDriftGate(ctx) {
|
|
|
136399
136936
|
let incompleteTaskCount = 0;
|
|
136400
136937
|
let planParseable = false;
|
|
136401
136938
|
try {
|
|
136402
|
-
const planPath =
|
|
136939
|
+
const planPath = path167.join(dir, ".swarm", "plan.json");
|
|
136403
136940
|
if (fs106.existsSync(planPath)) {
|
|
136404
136941
|
const planRaw = fs106.readFileSync(planPath, "utf-8");
|
|
136405
136942
|
const plan = JSON.parse(planRaw);
|
|
@@ -136478,7 +137015,7 @@ async function runDriftGate(ctx) {
|
|
|
136478
137015
|
}
|
|
136479
137016
|
// src/tools/phase-complete/gates/final-council-gate.ts
|
|
136480
137017
|
import * as fs107 from "node:fs";
|
|
136481
|
-
import * as
|
|
137018
|
+
import * as path168 from "node:path";
|
|
136482
137019
|
async function runFinalCouncilGate(ctx) {
|
|
136483
137020
|
const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
|
|
136484
137021
|
let finalCouncilEnabled = false;
|
|
@@ -136501,7 +137038,7 @@ async function runFinalCouncilGate(ctx) {
|
|
|
136501
137038
|
if (lastPhaseId !== undefined && phase === lastPhaseId) {
|
|
136502
137039
|
if (preamble.effectiveGates?.final_council === true) {
|
|
136503
137040
|
finalCouncilEnabled = true;
|
|
136504
|
-
const fcPath =
|
|
137041
|
+
const fcPath = path168.join(dir, ".swarm", "evidence", "final-council.json");
|
|
136505
137042
|
let fcVerdictFound = false;
|
|
136506
137043
|
let _fcVerdict;
|
|
136507
137044
|
try {
|
|
@@ -136655,13 +137192,13 @@ async function runFinalCouncilGate(ctx) {
|
|
|
136655
137192
|
}
|
|
136656
137193
|
// src/tools/phase-complete/gates/hallucination-gate.ts
|
|
136657
137194
|
import * as fs108 from "node:fs";
|
|
136658
|
-
import * as
|
|
137195
|
+
import * as path169 from "node:path";
|
|
136659
137196
|
async function runHallucinationGate(ctx) {
|
|
136660
137197
|
const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
|
|
136661
137198
|
try {
|
|
136662
137199
|
const preamble = await resolveGatePreamble(dir, sessionID);
|
|
136663
137200
|
if (preamble.resolved && preamble.effectiveGates?.hallucination_guard === true) {
|
|
136664
|
-
const hgPath =
|
|
137201
|
+
const hgPath = path169.join(dir, ".swarm", "evidence", String(phase), "hallucination-guard.json");
|
|
136665
137202
|
let hgVerdictFound = false;
|
|
136666
137203
|
let hgVerdictApproved = false;
|
|
136667
137204
|
try {
|
|
@@ -136719,13 +137256,13 @@ async function runHallucinationGate(ctx) {
|
|
|
136719
137256
|
}
|
|
136720
137257
|
// src/tools/phase-complete/gates/mutation-gate.ts
|
|
136721
137258
|
import * as fs109 from "node:fs";
|
|
136722
|
-
import * as
|
|
137259
|
+
import * as path170 from "node:path";
|
|
136723
137260
|
async function runMutationGate(ctx) {
|
|
136724
137261
|
const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
|
|
136725
137262
|
try {
|
|
136726
137263
|
const preamble = await resolveGatePreamble(dir, sessionID);
|
|
136727
137264
|
if (preamble.resolved && preamble.effectiveGates?.mutation_test === true) {
|
|
136728
|
-
const mgPath =
|
|
137265
|
+
const mgPath = path170.join(dir, ".swarm", "evidence", String(phase), "mutation-gate.json");
|
|
136729
137266
|
let mgVerdictFound = false;
|
|
136730
137267
|
let mgVerdict;
|
|
136731
137268
|
try {
|
|
@@ -136783,7 +137320,7 @@ async function runMutationGate(ctx) {
|
|
|
136783
137320
|
}
|
|
136784
137321
|
// src/tools/phase-complete/gates/phase-council-gate.ts
|
|
136785
137322
|
import * as fs110 from "node:fs";
|
|
136786
|
-
import * as
|
|
137323
|
+
import * as path171 from "node:path";
|
|
136787
137324
|
async function runPhaseCouncilGate(ctx) {
|
|
136788
137325
|
const { phase, dir, sessionID, pluginConfig, agentsDispatched, safeWarn } = ctx;
|
|
136789
137326
|
const gateWarnings = [];
|
|
@@ -136792,7 +137329,7 @@ async function runPhaseCouncilGate(ctx) {
|
|
|
136792
137329
|
const preamble = await resolveGatePreamble(dir, sessionID);
|
|
136793
137330
|
if (preamble.resolved && preamble.effectiveGates?.phase_council === true && pluginConfig.council?.enabled === true) {
|
|
136794
137331
|
councilModeEnabled = true;
|
|
136795
|
-
const pcPath =
|
|
137332
|
+
const pcPath = path171.join(dir, ".swarm", "evidence", String(phase), "phase-council.json");
|
|
136796
137333
|
let pcVerdictFound = false;
|
|
136797
137334
|
let _pcVerdict;
|
|
136798
137335
|
let pcQuorumSize;
|
|
@@ -137359,7 +137896,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
137359
137896
|
}
|
|
137360
137897
|
if (retroFound && retroEntry?.lessons_learned && retroEntry.lessons_learned.length > 0) {
|
|
137361
137898
|
try {
|
|
137362
|
-
const projectName =
|
|
137899
|
+
const projectName = path173.basename(dir);
|
|
137363
137900
|
const curationResult = await curateAndStoreSwarm(retroEntry.lessons_learned, projectName, { phase_number: phase }, dir, knowledgeConfig, {
|
|
137364
137901
|
llmDelegate: createCuratorLLMDelegate(dir, "phase", sessionID),
|
|
137365
137902
|
enrichmentQuota: {
|
|
@@ -137921,7 +138458,7 @@ init_utils();
|
|
|
137921
138458
|
init_bun_compat();
|
|
137922
138459
|
init_create_tool();
|
|
137923
138460
|
import * as fs113 from "node:fs";
|
|
137924
|
-
import * as
|
|
138461
|
+
import * as path174 from "node:path";
|
|
137925
138462
|
var MAX_OUTPUT_BYTES7 = 52428800;
|
|
137926
138463
|
var AUDIT_TIMEOUT_MS = 120000;
|
|
137927
138464
|
function isValidEcosystem(value) {
|
|
@@ -137949,16 +138486,16 @@ function validateArgs3(args2) {
|
|
|
137949
138486
|
function detectEcosystems(directory) {
|
|
137950
138487
|
const ecosystems = [];
|
|
137951
138488
|
const cwd = directory;
|
|
137952
|
-
if (fs113.existsSync(
|
|
138489
|
+
if (fs113.existsSync(path174.join(cwd, "package.json"))) {
|
|
137953
138490
|
ecosystems.push("npm");
|
|
137954
138491
|
}
|
|
137955
|
-
if (fs113.existsSync(
|
|
138492
|
+
if (fs113.existsSync(path174.join(cwd, "pyproject.toml")) || fs113.existsSync(path174.join(cwd, "requirements.txt"))) {
|
|
137956
138493
|
ecosystems.push("pip");
|
|
137957
138494
|
}
|
|
137958
|
-
if (fs113.existsSync(
|
|
138495
|
+
if (fs113.existsSync(path174.join(cwd, "Cargo.toml"))) {
|
|
137959
138496
|
ecosystems.push("cargo");
|
|
137960
138497
|
}
|
|
137961
|
-
if (fs113.existsSync(
|
|
138498
|
+
if (fs113.existsSync(path174.join(cwd, "go.mod"))) {
|
|
137962
138499
|
ecosystems.push("go");
|
|
137963
138500
|
}
|
|
137964
138501
|
try {
|
|
@@ -137967,13 +138504,13 @@ function detectEcosystems(directory) {
|
|
|
137967
138504
|
ecosystems.push("dotnet");
|
|
137968
138505
|
}
|
|
137969
138506
|
} catch {}
|
|
137970
|
-
if (fs113.existsSync(
|
|
138507
|
+
if (fs113.existsSync(path174.join(cwd, "Gemfile")) || fs113.existsSync(path174.join(cwd, "Gemfile.lock"))) {
|
|
137971
138508
|
ecosystems.push("ruby");
|
|
137972
138509
|
}
|
|
137973
|
-
if (fs113.existsSync(
|
|
138510
|
+
if (fs113.existsSync(path174.join(cwd, "pubspec.yaml"))) {
|
|
137974
138511
|
ecosystems.push("dart");
|
|
137975
138512
|
}
|
|
137976
|
-
if (fs113.existsSync(
|
|
138513
|
+
if (fs113.existsSync(path174.join(cwd, "composer.lock"))) {
|
|
137977
138514
|
ecosystems.push("composer");
|
|
137978
138515
|
}
|
|
137979
138516
|
return ecosystems;
|
|
@@ -139110,7 +139647,7 @@ var pkg_audit = createSwarmTool({
|
|
|
139110
139647
|
init_zod();
|
|
139111
139648
|
init_manager2();
|
|
139112
139649
|
import * as fs114 from "node:fs";
|
|
139113
|
-
import * as
|
|
139650
|
+
import * as path175 from "node:path";
|
|
139114
139651
|
init_utils();
|
|
139115
139652
|
init_create_tool();
|
|
139116
139653
|
var MAX_FILE_SIZE = 1024 * 1024;
|
|
@@ -139233,7 +139770,7 @@ function isScaffoldFile(filePath) {
|
|
|
139233
139770
|
if (SCAFFOLD_PATH_PATTERNS.some((pattern) => pattern.test(normalizedPath))) {
|
|
139234
139771
|
return true;
|
|
139235
139772
|
}
|
|
139236
|
-
const filename =
|
|
139773
|
+
const filename = path175.basename(filePath);
|
|
139237
139774
|
if (SCAFFOLD_FILENAME_PATTERNS.some((pattern) => pattern.test(filename))) {
|
|
139238
139775
|
return true;
|
|
139239
139776
|
}
|
|
@@ -139250,7 +139787,7 @@ function isAllowedByGlobs(filePath, allowGlobs) {
|
|
|
139250
139787
|
if (regex.test(normalizedPath)) {
|
|
139251
139788
|
return true;
|
|
139252
139789
|
}
|
|
139253
|
-
const filename =
|
|
139790
|
+
const filename = path175.basename(filePath);
|
|
139254
139791
|
const filenameRegex = new RegExp(`^${regexPattern}$`, "i");
|
|
139255
139792
|
if (filenameRegex.test(filename)) {
|
|
139256
139793
|
return true;
|
|
@@ -139259,7 +139796,7 @@ function isAllowedByGlobs(filePath, allowGlobs) {
|
|
|
139259
139796
|
return false;
|
|
139260
139797
|
}
|
|
139261
139798
|
function isParserSupported(filePath) {
|
|
139262
|
-
const ext =
|
|
139799
|
+
const ext = path175.extname(filePath).toLowerCase();
|
|
139263
139800
|
return SUPPORTED_PARSER_EXTENSIONS.has(ext);
|
|
139264
139801
|
}
|
|
139265
139802
|
function isPlanFile(filePath) {
|
|
@@ -139506,9 +140043,9 @@ async function placeholderScan(input, directory) {
|
|
|
139506
140043
|
let filesScanned = 0;
|
|
139507
140044
|
const filesWithFindings = new Set;
|
|
139508
140045
|
for (const filePath of changed_files) {
|
|
139509
|
-
const fullPath =
|
|
139510
|
-
const resolvedDirectory =
|
|
139511
|
-
if (!fullPath.startsWith(resolvedDirectory +
|
|
140046
|
+
const fullPath = path175.isAbsolute(filePath) ? filePath : path175.resolve(directory, filePath);
|
|
140047
|
+
const resolvedDirectory = path175.resolve(directory);
|
|
140048
|
+
if (!fullPath.startsWith(resolvedDirectory + path175.sep) && fullPath !== resolvedDirectory) {
|
|
139512
140049
|
continue;
|
|
139513
140050
|
}
|
|
139514
140051
|
if (!fs114.existsSync(fullPath)) {
|
|
@@ -139517,7 +140054,7 @@ async function placeholderScan(input, directory) {
|
|
|
139517
140054
|
if (isAllowedByGlobs(filePath, allow_globs)) {
|
|
139518
140055
|
continue;
|
|
139519
140056
|
}
|
|
139520
|
-
const relativeFilePath =
|
|
140057
|
+
const relativeFilePath = path175.relative(directory, fullPath).replace(/\\/g, "/");
|
|
139521
140058
|
if (FILE_ALLOWLIST.some((allowed) => relativeFilePath.endsWith(allowed))) {
|
|
139522
140059
|
continue;
|
|
139523
140060
|
}
|
|
@@ -139590,7 +140127,7 @@ var placeholder_scan = createSwarmTool({
|
|
|
139590
140127
|
|
|
139591
140128
|
// src/tools/pre-check-batch.ts
|
|
139592
140129
|
import * as fs118 from "node:fs";
|
|
139593
|
-
import * as
|
|
140130
|
+
import * as path179 from "node:path";
|
|
139594
140131
|
init_zod();
|
|
139595
140132
|
init_manager2();
|
|
139596
140133
|
init_utils();
|
|
@@ -139731,7 +140268,7 @@ init_zod();
|
|
|
139731
140268
|
init_manager2();
|
|
139732
140269
|
init_detector();
|
|
139733
140270
|
import * as fs117 from "node:fs";
|
|
139734
|
-
import * as
|
|
140271
|
+
import * as path178 from "node:path";
|
|
139735
140272
|
import { extname as extname19 } from "node:path";
|
|
139736
140273
|
|
|
139737
140274
|
// src/sast/rules/c.ts
|
|
@@ -140441,7 +140978,7 @@ function executeRulesSync(filePath, content, language) {
|
|
|
140441
140978
|
// src/sast/semgrep.ts
|
|
140442
140979
|
import * as child_process13 from "node:child_process";
|
|
140443
140980
|
import * as fs115 from "node:fs";
|
|
140444
|
-
import * as
|
|
140981
|
+
import * as path176 from "node:path";
|
|
140445
140982
|
var semgrepAvailableCache = null;
|
|
140446
140983
|
var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
|
|
140447
140984
|
var DEFAULT_TIMEOUT_MS4 = 30000;
|
|
@@ -140728,7 +141265,7 @@ async function runSemgrep(options) {
|
|
|
140728
141265
|
}
|
|
140729
141266
|
function getRulesDirectory(projectRoot) {
|
|
140730
141267
|
if (projectRoot) {
|
|
140731
|
-
return
|
|
141268
|
+
return path176.resolve(projectRoot, DEFAULT_RULES_DIR);
|
|
140732
141269
|
}
|
|
140733
141270
|
return DEFAULT_RULES_DIR;
|
|
140734
141271
|
}
|
|
@@ -140749,24 +141286,24 @@ init_create_tool();
|
|
|
140749
141286
|
init_utils2();
|
|
140750
141287
|
import * as crypto12 from "node:crypto";
|
|
140751
141288
|
import * as fs116 from "node:fs";
|
|
140752
|
-
import * as
|
|
141289
|
+
import * as path177 from "node:path";
|
|
140753
141290
|
var BASELINE_SCHEMA_VERSION = "1.0.0";
|
|
140754
141291
|
var MAX_BASELINE_FINDINGS = 2000;
|
|
140755
141292
|
var MAX_BASELINE_BYTES = 2 * 1048576;
|
|
140756
141293
|
var LOCK_RETRY_DELAYS_MS = [50, 100, 200, 400, 800];
|
|
140757
141294
|
function normalizeFindingPath(directory, file3) {
|
|
140758
|
-
const resolved =
|
|
140759
|
-
const rel =
|
|
141295
|
+
const resolved = path177.isAbsolute(file3) ? file3 : path177.resolve(directory, file3);
|
|
141296
|
+
const rel = path177.relative(path177.resolve(directory), resolved);
|
|
140760
141297
|
return rel.replace(/\\/g, "/");
|
|
140761
141298
|
}
|
|
140762
141299
|
function baselineRelPath(phase) {
|
|
140763
|
-
return
|
|
141300
|
+
return path177.join("evidence", String(phase), "sast-baseline.json");
|
|
140764
141301
|
}
|
|
140765
141302
|
function tempRelPath(phase) {
|
|
140766
|
-
return
|
|
141303
|
+
return path177.join("evidence", String(phase), `sast-baseline.json.tmp.${Date.now()}.${process.pid}`);
|
|
140767
141304
|
}
|
|
140768
141305
|
function lockRelPath(phase) {
|
|
140769
|
-
return
|
|
141306
|
+
return path177.join("evidence", String(phase), "sast-baseline.json.lock");
|
|
140770
141307
|
}
|
|
140771
141308
|
function getLine(lines, idx) {
|
|
140772
141309
|
if (idx < 0 || idx >= lines.length)
|
|
@@ -140887,8 +141424,8 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
140887
141424
|
message: e instanceof Error ? e.message : "Path validation failed"
|
|
140888
141425
|
};
|
|
140889
141426
|
}
|
|
140890
|
-
fs116.mkdirSync(
|
|
140891
|
-
fs116.mkdirSync(
|
|
141427
|
+
fs116.mkdirSync(path177.dirname(baselinePath), { recursive: true });
|
|
141428
|
+
fs116.mkdirSync(path177.dirname(tempPath), { recursive: true });
|
|
140892
141429
|
const releaseLock = await acquireLock2(lockPath);
|
|
140893
141430
|
try {
|
|
140894
141431
|
let existing = null;
|
|
@@ -141161,9 +141698,9 @@ async function sastScan(input, directory, config3) {
|
|
|
141161
141698
|
_filesSkipped++;
|
|
141162
141699
|
continue;
|
|
141163
141700
|
}
|
|
141164
|
-
const resolvedPath =
|
|
141165
|
-
const resolvedDirectory =
|
|
141166
|
-
if (!resolvedPath.startsWith(resolvedDirectory +
|
|
141701
|
+
const resolvedPath = path178.isAbsolute(filePath) ? filePath : path178.resolve(directory, filePath);
|
|
141702
|
+
const resolvedDirectory = path178.resolve(directory);
|
|
141703
|
+
if (!resolvedPath.startsWith(resolvedDirectory + path178.sep) && resolvedPath !== resolvedDirectory) {
|
|
141167
141704
|
_filesSkipped++;
|
|
141168
141705
|
continue;
|
|
141169
141706
|
}
|
|
@@ -141478,18 +142015,18 @@ function validatePath(inputPath, baseDir, workspaceDir) {
|
|
|
141478
142015
|
let resolved;
|
|
141479
142016
|
const isWinAbs = isWindowsAbsolutePath(inputPath);
|
|
141480
142017
|
if (isWinAbs) {
|
|
141481
|
-
resolved =
|
|
141482
|
-
} else if (
|
|
141483
|
-
resolved =
|
|
142018
|
+
resolved = path179.win32.resolve(inputPath);
|
|
142019
|
+
} else if (path179.isAbsolute(inputPath)) {
|
|
142020
|
+
resolved = path179.resolve(inputPath);
|
|
141484
142021
|
} else {
|
|
141485
|
-
resolved =
|
|
142022
|
+
resolved = path179.resolve(baseDir, inputPath);
|
|
141486
142023
|
}
|
|
141487
|
-
const workspaceResolved =
|
|
142024
|
+
const workspaceResolved = path179.resolve(workspaceDir);
|
|
141488
142025
|
let relative36;
|
|
141489
142026
|
if (isWinAbs) {
|
|
141490
|
-
relative36 =
|
|
142027
|
+
relative36 = path179.win32.relative(workspaceResolved, resolved);
|
|
141491
142028
|
} else {
|
|
141492
|
-
relative36 =
|
|
142029
|
+
relative36 = path179.relative(workspaceResolved, resolved);
|
|
141493
142030
|
}
|
|
141494
142031
|
if (relative36.startsWith("..")) {
|
|
141495
142032
|
return "path traversal detected";
|
|
@@ -141554,7 +142091,7 @@ async function runLintOnFiles(linter, files, workspaceDir) {
|
|
|
141554
142091
|
if (typeof file3 !== "string") {
|
|
141555
142092
|
continue;
|
|
141556
142093
|
}
|
|
141557
|
-
const resolvedPath =
|
|
142094
|
+
const resolvedPath = path179.resolve(file3);
|
|
141558
142095
|
const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
|
|
141559
142096
|
if (validationError) {
|
|
141560
142097
|
continue;
|
|
@@ -141711,7 +142248,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
141711
142248
|
skippedFiles++;
|
|
141712
142249
|
continue;
|
|
141713
142250
|
}
|
|
141714
|
-
const resolvedPath =
|
|
142251
|
+
const resolvedPath = path179.resolve(file3);
|
|
141715
142252
|
const validationError = validatePath(resolvedPath, directory, directory);
|
|
141716
142253
|
if (validationError) {
|
|
141717
142254
|
skippedFiles++;
|
|
@@ -141729,7 +142266,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
141729
142266
|
};
|
|
141730
142267
|
}
|
|
141731
142268
|
for (const file3 of validatedFiles) {
|
|
141732
|
-
const ext =
|
|
142269
|
+
const ext = path179.extname(file3).toLowerCase();
|
|
141733
142270
|
if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
|
|
141734
142271
|
skippedFiles++;
|
|
141735
142272
|
continue;
|
|
@@ -141948,7 +142485,7 @@ function classifySastFindings(findings, changedLineRanges, directory) {
|
|
|
141948
142485
|
const preexistingFindings = [];
|
|
141949
142486
|
for (const finding of findings) {
|
|
141950
142487
|
const filePath = finding.location.file;
|
|
141951
|
-
const normalised =
|
|
142488
|
+
const normalised = path179.relative(directory, filePath).replace(/\\/g, "/");
|
|
141952
142489
|
const changedLines = changedLineRanges.get(normalised);
|
|
141953
142490
|
if (changedLines?.has(finding.location.line)) {
|
|
141954
142491
|
newFindings.push(finding);
|
|
@@ -141999,7 +142536,7 @@ async function runPreCheckBatch(input, workspaceDir, contextDir) {
|
|
|
141999
142536
|
warn(`pre_check_batch: Invalid file path: ${file3}`);
|
|
142000
142537
|
continue;
|
|
142001
142538
|
}
|
|
142002
|
-
changedFiles.push(
|
|
142539
|
+
changedFiles.push(path179.resolve(directory, file3));
|
|
142003
142540
|
}
|
|
142004
142541
|
if (changedFiles.length === 0) {
|
|
142005
142542
|
warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
|
|
@@ -142200,9 +142737,9 @@ var pre_check_batch = createSwarmTool({
|
|
|
142200
142737
|
};
|
|
142201
142738
|
return JSON.stringify(errorResult, null, 2);
|
|
142202
142739
|
}
|
|
142203
|
-
const resolvedDirectory =
|
|
142204
|
-
const workspaceAnchor =
|
|
142205
|
-
if (resolvedDirectory !== workspaceAnchor && resolvedDirectory.startsWith(workspaceAnchor +
|
|
142740
|
+
const resolvedDirectory = path179.resolve(typedArgs.directory);
|
|
142741
|
+
const workspaceAnchor = path179.resolve(directory);
|
|
142742
|
+
if (resolvedDirectory !== workspaceAnchor && resolvedDirectory.startsWith(workspaceAnchor + path179.sep)) {
|
|
142206
142743
|
const subDirError = `directory "${typedArgs.directory}" is a subdirectory of the project root — pre_check_batch requires the project root directory "${workspaceAnchor}"`;
|
|
142207
142744
|
const subDirResult = {
|
|
142208
142745
|
gates_passed: false,
|
|
@@ -142256,7 +142793,7 @@ var pre_check_batch = createSwarmTool({
|
|
|
142256
142793
|
init_zod();
|
|
142257
142794
|
init_path_security();
|
|
142258
142795
|
init_create_tool();
|
|
142259
|
-
import * as
|
|
142796
|
+
import * as path180 from "node:path";
|
|
142260
142797
|
var VALID_ACTIONS = [
|
|
142261
142798
|
"build",
|
|
142262
142799
|
"importers",
|
|
@@ -142266,7 +142803,9 @@ var VALID_ACTIONS = [
|
|
|
142266
142803
|
"key_files",
|
|
142267
142804
|
"ontology",
|
|
142268
142805
|
"package_boundaries",
|
|
142269
|
-
"preflight_packet"
|
|
142806
|
+
"preflight_packet",
|
|
142807
|
+
"callers",
|
|
142808
|
+
"dead_exports"
|
|
142270
142809
|
];
|
|
142271
142810
|
var MAX_FILE_PATH_LENGTH3 = 500;
|
|
142272
142811
|
var MAX_SYMBOL_LENGTH2 = 256;
|
|
@@ -142282,7 +142821,7 @@ function validateFile(p) {
|
|
|
142282
142821
|
return "file contains control characters";
|
|
142283
142822
|
if (containsPathTraversal(p))
|
|
142284
142823
|
return "file contains path traversal";
|
|
142285
|
-
if (
|
|
142824
|
+
if (path180.isAbsolute(p) || /^[a-zA-Z]:[\\/]/.test(p)) {
|
|
142286
142825
|
return "file must be a workspace-relative path, not absolute";
|
|
142287
142826
|
}
|
|
142288
142827
|
return null;
|
|
@@ -142305,8 +142844,8 @@ function ok(action, payload) {
|
|
|
142305
142844
|
}
|
|
142306
142845
|
function toRelativeGraphPath(input, workspaceRoot) {
|
|
142307
142846
|
const normalized = input.replace(/\\/g, "/");
|
|
142308
|
-
if (
|
|
142309
|
-
const rel =
|
|
142847
|
+
if (path180.isAbsolute(normalized)) {
|
|
142848
|
+
const rel = path180.relative(workspaceRoot, normalized).replace(/\\/g, "/");
|
|
142310
142849
|
return normalizeGraphPath(rel);
|
|
142311
142850
|
}
|
|
142312
142851
|
return normalizeGraphPath(normalized);
|
|
@@ -142330,7 +142869,7 @@ async function loadOrError(directory, action) {
|
|
|
142330
142869
|
}
|
|
142331
142870
|
}
|
|
142332
142871
|
var repo_map = createSwarmTool({
|
|
142333
|
-
description: "Query the repository code graph for structural awareness before editing. " + 'Actions: "build" (build/refresh .swarm/repo-graph.json), "importers" (who imports a file), ' + '"dependencies" (what a file imports), "blast_radius" (transitive dependents + risk), ' + '"localization" (compact context block for a target file), "key_files" (top-N most-imported files), ' + '"ontology" (file roles/routes/data/security/findings), "package_boundaries" (inferred package/layer boundaries), ' + '"preflight_packet" (bounded ontology packet for planning). ' + "Use this before refactoring shared modules to avoid breaking unseen consumers.",
|
|
142872
|
+
description: "Query the repository code graph for structural awareness before editing. " + 'Actions: "build" (build/refresh .swarm/repo-graph.json), "importers" (who imports a file), ' + '"dependencies" (what a file imports), "blast_radius" (transitive dependents + risk), ' + '"localization" (compact context block for a target file), "key_files" (top-N most-imported files), ' + '"ontology" (file roles/routes/data/security/findings), "package_boundaries" (inferred package/layer boundaries), ' + '"preflight_packet" (bounded ontology packet for planning), ' + '"callers" (files that reference an exported symbol, call-site granularity; needs file+symbol), ' + '"dead_exports" (advisory: exported symbols with no detected in-repo reference). ' + "Use this before refactoring shared modules to avoid breaking unseen consumers. " + 'Note: "callers"/"dead_exports" use conservative regex analysis (TS/JS/Python) and cannot see ' + 'dynamic dispatch or namespace/barrel re-export usage; "dead_exports" results are review candidates, not delete directives.',
|
|
142334
142873
|
args: {
|
|
142335
142874
|
action: exports_external.enum([
|
|
142336
142875
|
"build",
|
|
@@ -142341,12 +142880,14 @@ var repo_map = createSwarmTool({
|
|
|
142341
142880
|
"key_files",
|
|
142342
142881
|
"ontology",
|
|
142343
142882
|
"package_boundaries",
|
|
142344
|
-
"preflight_packet"
|
|
142345
|
-
|
|
142883
|
+
"preflight_packet",
|
|
142884
|
+
"callers",
|
|
142885
|
+
"dead_exports"
|
|
142886
|
+
]).describe('Query action: "build" | "importers" | "dependencies" | "blast_radius" | "localization" | "key_files" | "ontology" | "package_boundaries" | "preflight_packet" | "callers" | "dead_exports"'),
|
|
142346
142887
|
file: exports_external.string().optional().describe("Target file (workspace-relative or absolute). Required for importers/dependencies/localization/ontology. Optional for preflight_packet."),
|
|
142347
142888
|
files: exports_external.array(exports_external.string()).optional().describe("Multiple target files for blast_radius/preflight_packet. If omitted, falls back to `file`."),
|
|
142348
|
-
symbol: exports_external.string().optional().describe('
|
|
142349
|
-
top_n: exports_external.number().int().min(1).max(100).optional().describe('For action="key_files"
|
|
142889
|
+
symbol: exports_external.string().optional().describe('Exported symbol name. Restricts consumers on action="importers"; required for action="callers".'),
|
|
142890
|
+
top_n: exports_external.number().int().min(1).max(100).optional().describe('For action="key_files"/"package_boundaries": entries to return (default 10). For action="dead_exports": max candidates (default 100).'),
|
|
142350
142891
|
max_depth: exports_external.number().int().min(1).max(10).optional().describe('For action="blast_radius": max BFS depth (default 3).')
|
|
142351
142892
|
},
|
|
142352
142893
|
async execute(args2, directory, _ctx) {
|
|
@@ -142408,6 +142949,10 @@ var repo_map = createSwarmTool({
|
|
|
142408
142949
|
stale
|
|
142409
142950
|
});
|
|
142410
142951
|
}
|
|
142952
|
+
if (action === "dead_exports") {
|
|
142953
|
+
const result = getDeadExports(graph, { maxCandidates: a.top_n ?? 100 });
|
|
142954
|
+
return ok(action, { ...result, stale });
|
|
142955
|
+
}
|
|
142411
142956
|
if (action === "preflight_packet") {
|
|
142412
142957
|
const inputs = a.files && a.files.length > 0 ? a.files : a.file ? [a.file] : [];
|
|
142413
142958
|
for (const f of inputs) {
|
|
@@ -142467,6 +143012,22 @@ var repo_map = createSwarmTool({
|
|
|
142467
143012
|
stale
|
|
142468
143013
|
});
|
|
142469
143014
|
}
|
|
143015
|
+
if (action === "callers") {
|
|
143016
|
+
if (a.symbol === undefined) {
|
|
143017
|
+
return err2(action, "callers requires `symbol` (the exported name)");
|
|
143018
|
+
}
|
|
143019
|
+
const sErr = validateSymbol(a.symbol);
|
|
143020
|
+
if (sErr)
|
|
143021
|
+
return err2(action, `invalid symbol: ${sErr}`);
|
|
143022
|
+
const callers = getCallers(graph, target, a.symbol);
|
|
143023
|
+
return ok(action, {
|
|
143024
|
+
target,
|
|
143025
|
+
symbol: a.symbol,
|
|
143026
|
+
count: callers.length,
|
|
143027
|
+
callers,
|
|
143028
|
+
stale
|
|
143029
|
+
});
|
|
143030
|
+
}
|
|
142470
143031
|
if (action === "dependencies") {
|
|
142471
143032
|
const deps = getDependencies(graph, target);
|
|
142472
143033
|
return ok(action, {
|
|
@@ -142498,7 +143059,7 @@ init_zod();
|
|
|
142498
143059
|
init_effective_spec();
|
|
142499
143060
|
init_create_tool();
|
|
142500
143061
|
import * as fs119 from "node:fs";
|
|
142501
|
-
import * as
|
|
143062
|
+
import * as path181 from "node:path";
|
|
142502
143063
|
var EVIDENCE_DIR4 = ".swarm/evidence";
|
|
142503
143064
|
var OBLIGATION_KEYWORDS2 = ["MUST", "SHOULD", "SHALL"];
|
|
142504
143065
|
var MAX_FILE_SIZE_BYTES8 = 1024 * 1024;
|
|
@@ -142566,7 +143127,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
142566
143127
|
return [];
|
|
142567
143128
|
}
|
|
142568
143129
|
for (const entry of entries) {
|
|
142569
|
-
const entryPath =
|
|
143130
|
+
const entryPath = path181.join(evidenceDir, entry);
|
|
142570
143131
|
try {
|
|
142571
143132
|
const stat14 = fs119.statSync(entryPath);
|
|
142572
143133
|
if (!stat14.isDirectory()) {
|
|
@@ -142582,11 +143143,11 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
142582
143143
|
if (entryPhase !== String(phase)) {
|
|
142583
143144
|
continue;
|
|
142584
143145
|
}
|
|
142585
|
-
const evidenceFilePath =
|
|
143146
|
+
const evidenceFilePath = path181.join(entryPath, "evidence.json");
|
|
142586
143147
|
try {
|
|
142587
|
-
const resolvedPath =
|
|
142588
|
-
const evidenceDirResolved =
|
|
142589
|
-
if (!resolvedPath.startsWith(evidenceDirResolved +
|
|
143148
|
+
const resolvedPath = path181.resolve(evidenceFilePath);
|
|
143149
|
+
const evidenceDirResolved = path181.resolve(evidenceDir);
|
|
143150
|
+
if (!resolvedPath.startsWith(evidenceDirResolved + path181.sep)) {
|
|
142590
143151
|
continue;
|
|
142591
143152
|
}
|
|
142592
143153
|
const stat14 = fs119.lstatSync(evidenceFilePath);
|
|
@@ -142620,7 +143181,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
142620
143181
|
if (Array.isArray(diffEntry.files_changed)) {
|
|
142621
143182
|
for (const file3 of diffEntry.files_changed) {
|
|
142622
143183
|
if (typeof file3 === "string") {
|
|
142623
|
-
touchedFiles.add(
|
|
143184
|
+
touchedFiles.add(path181.resolve(cwd, file3));
|
|
142624
143185
|
}
|
|
142625
143186
|
}
|
|
142626
143187
|
}
|
|
@@ -142633,8 +143194,8 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
142633
143194
|
}
|
|
142634
143195
|
function searchFileForKeywords(filePath, keywords, cwd) {
|
|
142635
143196
|
try {
|
|
142636
|
-
const resolvedPath =
|
|
142637
|
-
const cwdResolved =
|
|
143197
|
+
const resolvedPath = path181.resolve(filePath);
|
|
143198
|
+
const cwdResolved = path181.resolve(cwd);
|
|
142638
143199
|
if (!resolvedPath.startsWith(cwdResolved)) {
|
|
142639
143200
|
return false;
|
|
142640
143201
|
}
|
|
@@ -142793,7 +143354,7 @@ var req_coverage = createSwarmTool({
|
|
|
142793
143354
|
message: "No FR requirements found in spec.md"
|
|
142794
143355
|
}, null, 2);
|
|
142795
143356
|
}
|
|
142796
|
-
const evidenceDir =
|
|
143357
|
+
const evidenceDir = path181.join(cwd, EVIDENCE_DIR4);
|
|
142797
143358
|
const touchedFiles = readTouchedFiles(evidenceDir, phase, cwd);
|
|
142798
143359
|
const analyzedRequirements = [];
|
|
142799
143360
|
let coveredCount = 0;
|
|
@@ -142819,7 +143380,7 @@ var req_coverage = createSwarmTool({
|
|
|
142819
143380
|
requirements: analyzedRequirements
|
|
142820
143381
|
};
|
|
142821
143382
|
const reportFilename = `req-coverage-phase-${phase}.json`;
|
|
142822
|
-
const reportPath =
|
|
143383
|
+
const reportPath = path181.join(evidenceDir, reportFilename);
|
|
142823
143384
|
try {
|
|
142824
143385
|
if (!fs119.existsSync(evidenceDir)) {
|
|
142825
143386
|
fs119.mkdirSync(evidenceDir, { recursive: true });
|
|
@@ -142832,6 +143393,72 @@ var req_coverage = createSwarmTool({
|
|
|
142832
143393
|
}
|
|
142833
143394
|
});
|
|
142834
143395
|
|
|
143396
|
+
// src/tools/retrieve-lane-output.ts
|
|
143397
|
+
init_zod();
|
|
143398
|
+
init_create_tool();
|
|
143399
|
+
var RetrieveLaneOutputArgsSchema = exports_external.object({
|
|
143400
|
+
ref: exports_external.string().min(1).describe("Opaque lane output ref returned as output_ref by dispatch tools."),
|
|
143401
|
+
offset: exports_external.number().int().min(0).default(0).describe("Line offset to start from."),
|
|
143402
|
+
limit: exports_external.number().int().min(1).max(500).default(100).describe("Number of lines to return, max 500.")
|
|
143403
|
+
});
|
|
143404
|
+
var retrieve_lane_output = createSwarmTool({
|
|
143405
|
+
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.",
|
|
143406
|
+
args: {
|
|
143407
|
+
ref: RetrieveLaneOutputArgsSchema.shape.ref,
|
|
143408
|
+
offset: RetrieveLaneOutputArgsSchema.shape.offset,
|
|
143409
|
+
limit: RetrieveLaneOutputArgsSchema.shape.limit
|
|
143410
|
+
},
|
|
143411
|
+
async execute(args2, directory) {
|
|
143412
|
+
const parsed = RetrieveLaneOutputArgsSchema.safeParse(args2);
|
|
143413
|
+
if (!parsed.success) {
|
|
143414
|
+
return JSON.stringify({
|
|
143415
|
+
success: false,
|
|
143416
|
+
failure_class: "invalid_args",
|
|
143417
|
+
message: "Invalid retrieve_lane_output arguments",
|
|
143418
|
+
errors: parsed.error.issues.map((issue3) => `${issue3.path.join(".")}: ${issue3.message}`)
|
|
143419
|
+
}, null, 2);
|
|
143420
|
+
}
|
|
143421
|
+
let loaded;
|
|
143422
|
+
try {
|
|
143423
|
+
loaded = readLaneOutput(directory, parsed.data.ref);
|
|
143424
|
+
} catch {
|
|
143425
|
+
loaded = null;
|
|
143426
|
+
}
|
|
143427
|
+
if (!loaded) {
|
|
143428
|
+
return JSON.stringify({
|
|
143429
|
+
success: false,
|
|
143430
|
+
failure_class: "not_found",
|
|
143431
|
+
message: `No lane output artifact found for ${parsed.data.ref}`
|
|
143432
|
+
}, null, 2);
|
|
143433
|
+
}
|
|
143434
|
+
const page = paginateLaneOutput(loaded.artifact.text, parsed.data.offset, Math.min(parsed.data.limit, 500));
|
|
143435
|
+
if (page.exhausted) {
|
|
143436
|
+
return `--- Lane output ${loaded.artifact.ref} offset beyond range ---
|
|
143437
|
+
` + `Lane: ${loaded.artifact.laneId} (${loaded.artifact.agent})
|
|
143438
|
+
` + `Digest: ${loaded.artifact.digest}
|
|
143439
|
+
` + `Content has ${page.totalLines} line${page.totalLines === 1 ? "" : "s"}.`;
|
|
143440
|
+
}
|
|
143441
|
+
const header = `--- Lane output ${loaded.artifact.ref} lines ${page.startLine + 1}-${page.endLine} of ${page.totalLines} ---
|
|
143442
|
+
` + `Batch: ${loaded.artifact.batchId}
|
|
143443
|
+
` + `Lane: ${loaded.artifact.laneId}
|
|
143444
|
+
` + `Agent: ${loaded.artifact.agent}
|
|
143445
|
+
` + `Source: ${loaded.artifact.source}
|
|
143446
|
+
` + `Digest: ${loaded.artifact.digest}
|
|
143447
|
+
` + `Chars: ${loaded.artifact.chars}
|
|
143448
|
+
` + (loaded.artifact.transcriptIncomplete ? `Warning: transcript may be incomplete because the session message fetch hit its limit.
|
|
143449
|
+
` : "");
|
|
143450
|
+
let response = `${header}
|
|
143451
|
+
${page.content}`;
|
|
143452
|
+
if (page.endLine < page.totalLines) {
|
|
143453
|
+
const remaining = page.totalLines - page.endLine;
|
|
143454
|
+
response += `
|
|
143455
|
+
|
|
143456
|
+
... ${remaining} more line${remaining === 1 ? "" : "s"}. Use offset=${page.endLine} to retrieve more.`;
|
|
143457
|
+
}
|
|
143458
|
+
return response;
|
|
143459
|
+
}
|
|
143460
|
+
});
|
|
143461
|
+
|
|
142835
143462
|
// src/tools/retrieve-summary.ts
|
|
142836
143463
|
init_zod();
|
|
142837
143464
|
init_manager4();
|
|
@@ -142908,7 +143535,7 @@ init_plan_schema();
|
|
|
142908
143535
|
init_qa_gate_profile();
|
|
142909
143536
|
init_file_locks();
|
|
142910
143537
|
import * as fs120 from "node:fs";
|
|
142911
|
-
import * as
|
|
143538
|
+
import * as path182 from "node:path";
|
|
142912
143539
|
init_ledger();
|
|
142913
143540
|
init_manager();
|
|
142914
143541
|
init_effective_spec();
|
|
@@ -142990,8 +143617,8 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
142990
143617
|
};
|
|
142991
143618
|
}
|
|
142992
143619
|
if (args2.working_directory && fallbackDir) {
|
|
142993
|
-
const resolvedTarget =
|
|
142994
|
-
const resolvedRoot =
|
|
143620
|
+
const resolvedTarget = path182.resolve(args2.working_directory);
|
|
143621
|
+
const resolvedRoot = path182.resolve(fallbackDir);
|
|
142995
143622
|
let fallbackExists = false;
|
|
142996
143623
|
try {
|
|
142997
143624
|
fs120.accessSync(resolvedRoot, fs120.constants.F_OK);
|
|
@@ -143000,7 +143627,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
143000
143627
|
fallbackExists = false;
|
|
143001
143628
|
}
|
|
143002
143629
|
if (fallbackExists) {
|
|
143003
|
-
const isSubdirectory = resolvedTarget.startsWith(resolvedRoot +
|
|
143630
|
+
const isSubdirectory = resolvedTarget.startsWith(resolvedRoot + path182.sep);
|
|
143004
143631
|
if (isSubdirectory) {
|
|
143005
143632
|
return {
|
|
143006
143633
|
success: false,
|
|
@@ -143031,7 +143658,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
143031
143658
|
specHash = spec.hash;
|
|
143032
143659
|
}
|
|
143033
143660
|
if (process.env.SWARM_SKIP_GATE_SELECTION !== "1") {
|
|
143034
|
-
const contextPath =
|
|
143661
|
+
const contextPath = path182.join(targetWorkspace, ".swarm", "context.md");
|
|
143035
143662
|
let contextContent = "";
|
|
143036
143663
|
try {
|
|
143037
143664
|
contextContent = await fs120.promises.readFile(contextPath, "utf8");
|
|
@@ -143321,7 +143948,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
143321
143948
|
}
|
|
143322
143949
|
await writeCheckpoint(dir).catch(() => {});
|
|
143323
143950
|
try {
|
|
143324
|
-
const markerPath =
|
|
143951
|
+
const markerPath = path182.join(dir, ".swarm", ".plan-write-marker");
|
|
143325
143952
|
const marker = JSON.stringify({
|
|
143326
143953
|
source: "save_plan",
|
|
143327
143954
|
timestamp: new Date().toISOString(),
|
|
@@ -143344,7 +143971,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
143344
143971
|
return {
|
|
143345
143972
|
success: true,
|
|
143346
143973
|
message: "Plan saved successfully",
|
|
143347
|
-
plan_path:
|
|
143974
|
+
plan_path: path182.join(dir, ".swarm", "plan.json"),
|
|
143348
143975
|
phases_count: plan.phases.length,
|
|
143349
143976
|
tasks_count: tasksCount,
|
|
143350
143977
|
...resolvedProfile !== undefined ? { execution_profile: resolvedProfile } : {},
|
|
@@ -143412,7 +144039,7 @@ var save_plan = createSwarmTool({
|
|
|
143412
144039
|
init_zod();
|
|
143413
144040
|
init_manager2();
|
|
143414
144041
|
import * as fs121 from "node:fs";
|
|
143415
|
-
import * as
|
|
144042
|
+
import * as path183 from "node:path";
|
|
143416
144043
|
|
|
143417
144044
|
// src/sbom/detectors/index.ts
|
|
143418
144045
|
init_utils();
|
|
@@ -144262,7 +144889,7 @@ function findManifestFiles(rootDir) {
|
|
|
144262
144889
|
try {
|
|
144263
144890
|
const entries = fs121.readdirSync(dir, { withFileTypes: true });
|
|
144264
144891
|
for (const entry of entries) {
|
|
144265
|
-
const fullPath =
|
|
144892
|
+
const fullPath = path183.join(dir, entry.name);
|
|
144266
144893
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
|
|
144267
144894
|
continue;
|
|
144268
144895
|
}
|
|
@@ -144271,7 +144898,7 @@ function findManifestFiles(rootDir) {
|
|
|
144271
144898
|
} else if (entry.isFile()) {
|
|
144272
144899
|
for (const pattern of patterns) {
|
|
144273
144900
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
144274
|
-
manifestFiles.push(
|
|
144901
|
+
manifestFiles.push(path183.relative(rootDir, fullPath));
|
|
144275
144902
|
break;
|
|
144276
144903
|
}
|
|
144277
144904
|
}
|
|
@@ -144289,11 +144916,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
144289
144916
|
try {
|
|
144290
144917
|
const entries = fs121.readdirSync(dir, { withFileTypes: true });
|
|
144291
144918
|
for (const entry of entries) {
|
|
144292
|
-
const fullPath =
|
|
144919
|
+
const fullPath = path183.join(dir, entry.name);
|
|
144293
144920
|
if (entry.isFile()) {
|
|
144294
144921
|
for (const pattern of patterns) {
|
|
144295
144922
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
144296
|
-
found.push(
|
|
144923
|
+
found.push(path183.relative(workingDir, fullPath));
|
|
144297
144924
|
break;
|
|
144298
144925
|
}
|
|
144299
144926
|
}
|
|
@@ -144306,11 +144933,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
144306
144933
|
function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
|
|
144307
144934
|
const dirs = new Set;
|
|
144308
144935
|
for (const file3 of changedFiles) {
|
|
144309
|
-
let currentDir =
|
|
144936
|
+
let currentDir = path183.dirname(file3);
|
|
144310
144937
|
while (true) {
|
|
144311
|
-
if (currentDir && currentDir !== "." && currentDir !==
|
|
144312
|
-
dirs.add(
|
|
144313
|
-
const parent =
|
|
144938
|
+
if (currentDir && currentDir !== "." && currentDir !== path183.sep) {
|
|
144939
|
+
dirs.add(path183.join(workingDir, currentDir));
|
|
144940
|
+
const parent = path183.dirname(currentDir);
|
|
144314
144941
|
if (parent === currentDir)
|
|
144315
144942
|
break;
|
|
144316
144943
|
currentDir = parent;
|
|
@@ -144394,7 +145021,7 @@ var sbom_generate = createSwarmTool({
|
|
|
144394
145021
|
const changedFiles = obj.changed_files;
|
|
144395
145022
|
const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
|
|
144396
145023
|
const workingDir = directory;
|
|
144397
|
-
const outputDir =
|
|
145024
|
+
const outputDir = path183.isAbsolute(relativeOutputDir) ? relativeOutputDir : path183.join(workingDir, relativeOutputDir);
|
|
144398
145025
|
let manifestFiles = [];
|
|
144399
145026
|
if (scope === "all") {
|
|
144400
145027
|
manifestFiles = findManifestFiles(workingDir);
|
|
@@ -144417,7 +145044,7 @@ var sbom_generate = createSwarmTool({
|
|
|
144417
145044
|
const processedFiles = [];
|
|
144418
145045
|
for (const manifestFile of manifestFiles) {
|
|
144419
145046
|
try {
|
|
144420
|
-
const fullPath =
|
|
145047
|
+
const fullPath = path183.isAbsolute(manifestFile) ? manifestFile : path183.join(workingDir, manifestFile);
|
|
144421
145048
|
if (!fs121.existsSync(fullPath)) {
|
|
144422
145049
|
continue;
|
|
144423
145050
|
}
|
|
@@ -144434,7 +145061,7 @@ var sbom_generate = createSwarmTool({
|
|
|
144434
145061
|
const bom = generateCycloneDX(allComponents);
|
|
144435
145062
|
const bomJson = serializeCycloneDX(bom);
|
|
144436
145063
|
const filename = generateSbomFilename();
|
|
144437
|
-
const outputPath =
|
|
145064
|
+
const outputPath = path183.join(outputDir, filename);
|
|
144438
145065
|
fs121.writeFileSync(outputPath, bomJson, "utf-8");
|
|
144439
145066
|
const verdict = processedFiles.length > 0 ? "pass" : "pass";
|
|
144440
145067
|
try {
|
|
@@ -144479,7 +145106,7 @@ var sbom_generate = createSwarmTool({
|
|
|
144479
145106
|
init_zod();
|
|
144480
145107
|
init_create_tool();
|
|
144481
145108
|
import * as fs122 from "node:fs";
|
|
144482
|
-
import * as
|
|
145109
|
+
import * as path184 from "node:path";
|
|
144483
145110
|
var SPEC_CANDIDATES = [
|
|
144484
145111
|
"openapi.json",
|
|
144485
145112
|
"openapi.yaml",
|
|
@@ -144511,12 +145138,12 @@ function normalizePath5(p) {
|
|
|
144511
145138
|
}
|
|
144512
145139
|
function discoverSpecFile(cwd, specFileArg) {
|
|
144513
145140
|
if (specFileArg) {
|
|
144514
|
-
const resolvedPath =
|
|
144515
|
-
const normalizedCwd = cwd.endsWith(
|
|
145141
|
+
const resolvedPath = path184.resolve(cwd, specFileArg);
|
|
145142
|
+
const normalizedCwd = cwd.endsWith(path184.sep) ? cwd : cwd + path184.sep;
|
|
144516
145143
|
if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
|
|
144517
145144
|
throw new Error("Invalid spec_file: path traversal detected");
|
|
144518
145145
|
}
|
|
144519
|
-
const ext =
|
|
145146
|
+
const ext = path184.extname(resolvedPath).toLowerCase();
|
|
144520
145147
|
if (!ALLOWED_EXTENSIONS.includes(ext)) {
|
|
144521
145148
|
throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
|
|
144522
145149
|
}
|
|
@@ -144530,7 +145157,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
144530
145157
|
return resolvedPath;
|
|
144531
145158
|
}
|
|
144532
145159
|
for (const candidate of SPEC_CANDIDATES) {
|
|
144533
|
-
const candidatePath =
|
|
145160
|
+
const candidatePath = path184.resolve(cwd, candidate);
|
|
144534
145161
|
if (fs122.existsSync(candidatePath)) {
|
|
144535
145162
|
const stats2 = fs122.statSync(candidatePath);
|
|
144536
145163
|
if (stats2.size <= MAX_SPEC_SIZE) {
|
|
@@ -144542,7 +145169,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
144542
145169
|
}
|
|
144543
145170
|
function parseSpec(specFile) {
|
|
144544
145171
|
const content = fs122.readFileSync(specFile, "utf-8");
|
|
144545
|
-
const ext =
|
|
145172
|
+
const ext = path184.extname(specFile).toLowerCase();
|
|
144546
145173
|
if (ext === ".json") {
|
|
144547
145174
|
return parseJsonSpec(content);
|
|
144548
145175
|
}
|
|
@@ -144618,7 +145245,7 @@ function extractRoutes2(cwd) {
|
|
|
144618
145245
|
return;
|
|
144619
145246
|
}
|
|
144620
145247
|
for (const entry of entries) {
|
|
144621
|
-
const fullPath =
|
|
145248
|
+
const fullPath = path184.join(dir, entry.name);
|
|
144622
145249
|
if (entry.isSymbolicLink()) {
|
|
144623
145250
|
continue;
|
|
144624
145251
|
}
|
|
@@ -144628,7 +145255,7 @@ function extractRoutes2(cwd) {
|
|
|
144628
145255
|
}
|
|
144629
145256
|
walkDir2(fullPath);
|
|
144630
145257
|
} else if (entry.isFile()) {
|
|
144631
|
-
const ext =
|
|
145258
|
+
const ext = path184.extname(entry.name).toLowerCase();
|
|
144632
145259
|
const baseName = entry.name.toLowerCase();
|
|
144633
145260
|
if (![".ts", ".js", ".mjs"].includes(ext)) {
|
|
144634
145261
|
continue;
|
|
@@ -144797,7 +145424,7 @@ init_bun_compat();
|
|
|
144797
145424
|
init_path_security();
|
|
144798
145425
|
init_create_tool();
|
|
144799
145426
|
import * as fs123 from "node:fs";
|
|
144800
|
-
import * as
|
|
145427
|
+
import * as path185 from "node:path";
|
|
144801
145428
|
var DEFAULT_MAX_RESULTS = 100;
|
|
144802
145429
|
var DEFAULT_MAX_LINES = 200;
|
|
144803
145430
|
var REGEX_TIMEOUT_MS = 5000;
|
|
@@ -144833,11 +145460,11 @@ function containsWindowsAttacks4(str) {
|
|
|
144833
145460
|
}
|
|
144834
145461
|
function isPathInWorkspace3(filePath, workspace) {
|
|
144835
145462
|
try {
|
|
144836
|
-
const resolvedPath =
|
|
145463
|
+
const resolvedPath = path185.resolve(workspace, filePath);
|
|
144837
145464
|
const realWorkspace = fs123.realpathSync(workspace);
|
|
144838
145465
|
const realResolvedPath = fs123.realpathSync(resolvedPath);
|
|
144839
|
-
const relativePath =
|
|
144840
|
-
if (relativePath.startsWith("..") ||
|
|
145466
|
+
const relativePath = path185.relative(realWorkspace, realResolvedPath);
|
|
145467
|
+
if (relativePath.startsWith("..") || path185.isAbsolute(relativePath)) {
|
|
144841
145468
|
return false;
|
|
144842
145469
|
}
|
|
144843
145470
|
return true;
|
|
@@ -144850,11 +145477,11 @@ function validatePathForRead2(filePath, workspace) {
|
|
|
144850
145477
|
}
|
|
144851
145478
|
function findRgInEnvPath() {
|
|
144852
145479
|
const searchPath = process.env.PATH ?? "";
|
|
144853
|
-
for (const dir of searchPath.split(
|
|
145480
|
+
for (const dir of searchPath.split(path185.delimiter)) {
|
|
144854
145481
|
if (!dir)
|
|
144855
145482
|
continue;
|
|
144856
145483
|
const isWindows = process.platform === "win32";
|
|
144857
|
-
const candidate =
|
|
145484
|
+
const candidate = path185.join(dir, isWindows ? "rg.exe" : "rg");
|
|
144858
145485
|
if (fs123.existsSync(candidate))
|
|
144859
145486
|
return candidate;
|
|
144860
145487
|
}
|
|
@@ -144984,8 +145611,8 @@ function collectFiles(dir, workspace, includeGlobs, excludeGlobs) {
|
|
|
144984
145611
|
try {
|
|
144985
145612
|
const entries = fs123.readdirSync(dir, { withFileTypes: true });
|
|
144986
145613
|
for (const entry of entries) {
|
|
144987
|
-
const fullPath =
|
|
144988
|
-
const relativePath =
|
|
145614
|
+
const fullPath = path185.join(dir, entry.name);
|
|
145615
|
+
const relativePath = path185.relative(workspace, fullPath);
|
|
144989
145616
|
if (!validatePathForRead2(fullPath, workspace)) {
|
|
144990
145617
|
continue;
|
|
144991
145618
|
}
|
|
@@ -145026,7 +145653,7 @@ async function fallbackSearch(opts) {
|
|
|
145026
145653
|
const matches = [];
|
|
145027
145654
|
let total = 0;
|
|
145028
145655
|
for (const file3 of files) {
|
|
145029
|
-
const fullPath =
|
|
145656
|
+
const fullPath = path185.join(opts.workspace, file3);
|
|
145030
145657
|
if (!validatePathForRead2(fullPath, opts.workspace)) {
|
|
145031
145658
|
continue;
|
|
145032
145659
|
}
|
|
@@ -145458,7 +146085,7 @@ init_config();
|
|
|
145458
146085
|
init_schema();
|
|
145459
146086
|
init_create_tool();
|
|
145460
146087
|
import { mkdir as mkdir33, rename as rename14, writeFile as writeFile23 } from "node:fs/promises";
|
|
145461
|
-
import * as
|
|
146088
|
+
import * as path186 from "node:path";
|
|
145462
146089
|
var MAX_SPEC_BYTES2 = 256 * 1024;
|
|
145463
146090
|
var spec_write = createSwarmTool({
|
|
145464
146091
|
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 +146126,8 @@ var spec_write = createSwarmTool({
|
|
|
145499
146126
|
reason: 'spec must contain at least one top-level "# Heading"'
|
|
145500
146127
|
}, null, 2);
|
|
145501
146128
|
}
|
|
145502
|
-
const target =
|
|
145503
|
-
await mkdir33(
|
|
146129
|
+
const target = path186.join(directory, ".swarm", "spec.md");
|
|
146130
|
+
await mkdir33(path186.dirname(target), { recursive: true });
|
|
145504
146131
|
const tmp = `${target}.tmp-${process.pid}-${Date.now()}`;
|
|
145505
146132
|
let finalContent = content;
|
|
145506
146133
|
if (mode === "append") {
|
|
@@ -145529,14 +146156,14 @@ ${content}
|
|
|
145529
146156
|
init_zod();
|
|
145530
146157
|
init_loader();
|
|
145531
146158
|
import {
|
|
145532
|
-
existsSync as
|
|
145533
|
-
mkdirSync as
|
|
145534
|
-
readFileSync as
|
|
145535
|
-
renameSync as
|
|
145536
|
-
unlinkSync as
|
|
145537
|
-
writeFileSync as
|
|
146159
|
+
existsSync as existsSync105,
|
|
146160
|
+
mkdirSync as mkdirSync43,
|
|
146161
|
+
readFileSync as readFileSync83,
|
|
146162
|
+
renameSync as renameSync25,
|
|
146163
|
+
unlinkSync as unlinkSync22,
|
|
146164
|
+
writeFileSync as writeFileSync32
|
|
145538
146165
|
} from "node:fs";
|
|
145539
|
-
import
|
|
146166
|
+
import path187 from "node:path";
|
|
145540
146167
|
init_create_tool();
|
|
145541
146168
|
init_resolve_working_directory();
|
|
145542
146169
|
var VerdictSchema2 = exports_external.object({
|
|
@@ -145703,9 +146330,9 @@ var submit_phase_council_verdicts = createSwarmTool({
|
|
|
145703
146330
|
}
|
|
145704
146331
|
});
|
|
145705
146332
|
function getPhaseMutationGapFinding(phaseNumber, workingDir) {
|
|
145706
|
-
const mutationGatePath =
|
|
146333
|
+
const mutationGatePath = path187.join(workingDir, ".swarm", "evidence", String(phaseNumber), "mutation-gate.json");
|
|
145707
146334
|
try {
|
|
145708
|
-
const raw =
|
|
146335
|
+
const raw = readFileSync83(mutationGatePath, "utf-8");
|
|
145709
146336
|
const parsed = JSON.parse(raw);
|
|
145710
146337
|
const gateEntry = (parsed.entries ?? []).find((entry) => entry?.type === "mutation-gate");
|
|
145711
146338
|
if (!gateEntry) {
|
|
@@ -145765,9 +146392,9 @@ function getPhaseMutationGapFinding(phaseNumber, workingDir) {
|
|
|
145765
146392
|
}
|
|
145766
146393
|
}
|
|
145767
146394
|
function writePhaseCouncilEvidence(workingDir, synthesis, provenance) {
|
|
145768
|
-
const evidenceDir =
|
|
145769
|
-
|
|
145770
|
-
const evidenceFile =
|
|
146395
|
+
const evidenceDir = path187.join(workingDir, ".swarm", "evidence", String(synthesis.phaseNumber));
|
|
146396
|
+
mkdirSync43(evidenceDir, { recursive: true });
|
|
146397
|
+
const evidenceFile = path187.join(evidenceDir, "phase-council.json");
|
|
145771
146398
|
const evidenceBundle = {
|
|
145772
146399
|
entries: [
|
|
145773
146400
|
{
|
|
@@ -145801,11 +146428,11 @@ function writePhaseCouncilEvidence(workingDir, synthesis, provenance) {
|
|
|
145801
146428
|
};
|
|
145802
146429
|
const tempFile = `${evidenceFile}.tmp-${Date.now()}`;
|
|
145803
146430
|
try {
|
|
145804
|
-
|
|
145805
|
-
|
|
146431
|
+
writeFileSync32(tempFile, JSON.stringify(evidenceBundle, null, 2), "utf-8");
|
|
146432
|
+
renameSync25(tempFile, evidenceFile);
|
|
145806
146433
|
} finally {
|
|
145807
|
-
if (
|
|
145808
|
-
|
|
146434
|
+
if (existsSync105(tempFile)) {
|
|
146435
|
+
unlinkSync22(tempFile);
|
|
145809
146436
|
}
|
|
145810
146437
|
}
|
|
145811
146438
|
}
|
|
@@ -145830,7 +146457,7 @@ init_zod();
|
|
|
145830
146457
|
init_path_security();
|
|
145831
146458
|
init_create_tool();
|
|
145832
146459
|
import * as fs124 from "node:fs";
|
|
145833
|
-
import * as
|
|
146460
|
+
import * as path188 from "node:path";
|
|
145834
146461
|
var BINARY_EXTENSIONS2 = new Set([
|
|
145835
146462
|
".png",
|
|
145836
146463
|
".jpg",
|
|
@@ -145866,14 +146493,14 @@ function containsWindowsAttacks5(str) {
|
|
|
145866
146493
|
}
|
|
145867
146494
|
function isPathInWorkspace4(filePath, workspace) {
|
|
145868
146495
|
try {
|
|
145869
|
-
const resolvedPath =
|
|
146496
|
+
const resolvedPath = path188.resolve(workspace, filePath);
|
|
145870
146497
|
if (!fs124.existsSync(resolvedPath)) {
|
|
145871
146498
|
return true;
|
|
145872
146499
|
}
|
|
145873
146500
|
const realWorkspace = fs124.realpathSync(workspace);
|
|
145874
146501
|
const realResolvedPath = fs124.realpathSync(resolvedPath);
|
|
145875
|
-
const relativePath =
|
|
145876
|
-
if (relativePath.startsWith("..") ||
|
|
146502
|
+
const relativePath = path188.relative(realWorkspace, realResolvedPath);
|
|
146503
|
+
if (relativePath.startsWith("..") || path188.isAbsolute(relativePath)) {
|
|
145877
146504
|
return false;
|
|
145878
146505
|
}
|
|
145879
146506
|
return true;
|
|
@@ -145988,7 +146615,7 @@ function arraysEqual2(a, b) {
|
|
|
145988
146615
|
return true;
|
|
145989
146616
|
}
|
|
145990
146617
|
function isBinaryFile4(filePath) {
|
|
145991
|
-
const ext =
|
|
146618
|
+
const ext = path188.extname(filePath).toLowerCase();
|
|
145992
146619
|
return BINARY_EXTENSIONS2.has(ext);
|
|
145993
146620
|
}
|
|
145994
146621
|
function splitDiffLines(content) {
|
|
@@ -146193,7 +146820,7 @@ var suggestPatch = createSwarmTool({
|
|
|
146193
146820
|
});
|
|
146194
146821
|
continue;
|
|
146195
146822
|
}
|
|
146196
|
-
const fullPath =
|
|
146823
|
+
const fullPath = path188.resolve(directory, change.file);
|
|
146197
146824
|
if (!fs124.existsSync(fullPath)) {
|
|
146198
146825
|
errors5.push({
|
|
146199
146826
|
success: false,
|
|
@@ -146288,7 +146915,7 @@ var suggestPatch = createSwarmTool({
|
|
|
146288
146915
|
const unifiedParts = [];
|
|
146289
146916
|
for (const [file3, entries] of fileGroups) {
|
|
146290
146917
|
entries.sort((a, b) => a.contextMatch.startLineIndex - b.contextMatch.startLineIndex);
|
|
146291
|
-
const entryFullPath =
|
|
146918
|
+
const entryFullPath = path188.resolve(directory, file3);
|
|
146292
146919
|
let entryContent;
|
|
146293
146920
|
try {
|
|
146294
146921
|
entryContent = fs124.readFileSync(entryFullPath, "utf-8");
|
|
@@ -146630,7 +147257,7 @@ function getContextAgent4(ctx) {
|
|
|
146630
147257
|
|
|
146631
147258
|
// src/tools/syntax-check.ts
|
|
146632
147259
|
import * as fs125 from "node:fs";
|
|
146633
|
-
import * as
|
|
147260
|
+
import * as path189 from "node:path";
|
|
146634
147261
|
init_zod();
|
|
146635
147262
|
init_manager2();
|
|
146636
147263
|
init_detector();
|
|
@@ -146702,7 +147329,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
146702
147329
|
if (languages?.length) {
|
|
146703
147330
|
const lowerLangs = languages.map((l) => l.toLowerCase());
|
|
146704
147331
|
filesToCheck = filesToCheck.filter((file3) => {
|
|
146705
|
-
const ext =
|
|
147332
|
+
const ext = path189.extname(file3.path).toLowerCase();
|
|
146706
147333
|
const langDef = getLanguageForExtension(ext);
|
|
146707
147334
|
const fileProfile = getProfileForFile(file3.path);
|
|
146708
147335
|
const langId = fileProfile?.id || langDef?.id;
|
|
@@ -146712,7 +147339,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
146712
147339
|
const { loadGrammar: loadGrammar2 } = await Promise.resolve().then(() => (init_runtime(), exports_runtime));
|
|
146713
147340
|
async function checkOneFile(fileInfo) {
|
|
146714
147341
|
const { path: filePath } = fileInfo;
|
|
146715
|
-
const fullPath =
|
|
147342
|
+
const fullPath = path189.isAbsolute(filePath) ? filePath : path189.join(directory, filePath);
|
|
146716
147343
|
const result = {
|
|
146717
147344
|
path: filePath,
|
|
146718
147345
|
language: "",
|
|
@@ -146759,7 +147386,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
146759
147386
|
result.skipped_reason = "binary_file";
|
|
146760
147387
|
return { result, counted: false, failed: false, skipped: true };
|
|
146761
147388
|
}
|
|
146762
|
-
const ext =
|
|
147389
|
+
const ext = path189.extname(filePath).toLowerCase();
|
|
146763
147390
|
const langDef = getLanguageForExtension(ext);
|
|
146764
147391
|
result.language = profile?.id || langDef?.id || "unknown";
|
|
146765
147392
|
const errors5 = extractSyntaxErrors(parser, content);
|
|
@@ -146871,7 +147498,7 @@ init_utils();
|
|
|
146871
147498
|
init_create_tool();
|
|
146872
147499
|
init_path_security();
|
|
146873
147500
|
import * as fs126 from "node:fs";
|
|
146874
|
-
import * as
|
|
147501
|
+
import * as path190 from "node:path";
|
|
146875
147502
|
var MAX_TEXT_LENGTH = 200;
|
|
146876
147503
|
var MAX_FILE_SIZE_BYTES10 = 1024 * 1024;
|
|
146877
147504
|
var SUPPORTED_EXTENSIONS4 = new Set([
|
|
@@ -146937,9 +147564,9 @@ function validatePathsInput(paths, cwd) {
|
|
|
146937
147564
|
return { error: "paths contains path traversal", resolvedPath: null };
|
|
146938
147565
|
}
|
|
146939
147566
|
try {
|
|
146940
|
-
const resolvedPath =
|
|
146941
|
-
const normalizedCwd =
|
|
146942
|
-
const normalizedResolved =
|
|
147567
|
+
const resolvedPath = path190.resolve(paths);
|
|
147568
|
+
const normalizedCwd = path190.resolve(cwd);
|
|
147569
|
+
const normalizedResolved = path190.resolve(resolvedPath);
|
|
146943
147570
|
if (!normalizedResolved.startsWith(normalizedCwd)) {
|
|
146944
147571
|
return {
|
|
146945
147572
|
error: "paths must be within the current working directory",
|
|
@@ -146955,7 +147582,7 @@ function validatePathsInput(paths, cwd) {
|
|
|
146955
147582
|
}
|
|
146956
147583
|
}
|
|
146957
147584
|
function isSupportedExtension(filePath) {
|
|
146958
|
-
const ext =
|
|
147585
|
+
const ext = path190.extname(filePath).toLowerCase();
|
|
146959
147586
|
return SUPPORTED_EXTENSIONS4.has(ext);
|
|
146960
147587
|
}
|
|
146961
147588
|
function findSourceFiles3(dir, files = []) {
|
|
@@ -146970,7 +147597,7 @@ function findSourceFiles3(dir, files = []) {
|
|
|
146970
147597
|
if (SKIP_DIRECTORIES6.has(entry)) {
|
|
146971
147598
|
continue;
|
|
146972
147599
|
}
|
|
146973
|
-
const fullPath =
|
|
147600
|
+
const fullPath = path190.join(dir, entry);
|
|
146974
147601
|
let stat14;
|
|
146975
147602
|
try {
|
|
146976
147603
|
stat14 = fs126.statSync(fullPath);
|
|
@@ -147082,7 +147709,7 @@ var todo_extract = createSwarmTool({
|
|
|
147082
147709
|
filesToScan.push(scanPath);
|
|
147083
147710
|
} else {
|
|
147084
147711
|
const errorResult = {
|
|
147085
|
-
error: `unsupported file extension: ${
|
|
147712
|
+
error: `unsupported file extension: ${path190.extname(scanPath)}`,
|
|
147086
147713
|
total: 0,
|
|
147087
147714
|
byPriority: { high: 0, medium: 0, low: 0 },
|
|
147088
147715
|
entries: []
|
|
@@ -147132,17 +147759,17 @@ init_schema();
|
|
|
147132
147759
|
init_qa_gate_profile();
|
|
147133
147760
|
init_gate_evidence();
|
|
147134
147761
|
import * as fs130 from "node:fs";
|
|
147135
|
-
import * as
|
|
147762
|
+
import * as path194 from "node:path";
|
|
147136
147763
|
|
|
147137
147764
|
// src/hooks/diff-scope.ts
|
|
147138
147765
|
init_bun_compat();
|
|
147139
147766
|
import * as fs128 from "node:fs";
|
|
147140
|
-
import * as
|
|
147767
|
+
import * as path192 from "node:path";
|
|
147141
147768
|
|
|
147142
147769
|
// src/utils/gitignore-warning.ts
|
|
147143
147770
|
init_bun_compat();
|
|
147144
147771
|
import * as fs127 from "node:fs";
|
|
147145
|
-
import * as
|
|
147772
|
+
import * as path191 from "node:path";
|
|
147146
147773
|
var _internals108 = { bunSpawn };
|
|
147147
147774
|
var _swarmGitExcludedChecked = false;
|
|
147148
147775
|
function fileCoversSwarm(content) {
|
|
@@ -147216,10 +147843,10 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
147216
147843
|
const excludeRelPath = excludePathRaw.trim();
|
|
147217
147844
|
if (!excludeRelPath)
|
|
147218
147845
|
return;
|
|
147219
|
-
const excludePath =
|
|
147846
|
+
const excludePath = path191.isAbsolute(excludeRelPath) ? excludeRelPath : path191.join(directory, excludeRelPath);
|
|
147220
147847
|
if (checkIgnoreExitCode !== 0) {
|
|
147221
147848
|
try {
|
|
147222
|
-
fs127.mkdirSync(
|
|
147849
|
+
fs127.mkdirSync(path191.dirname(excludePath), { recursive: true });
|
|
147223
147850
|
let existing = "";
|
|
147224
147851
|
try {
|
|
147225
147852
|
existing = fs127.readFileSync(excludePath, "utf8");
|
|
@@ -147263,7 +147890,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
147263
147890
|
var _internals109 = { bunSpawn };
|
|
147264
147891
|
function getDeclaredScope(taskId, directory) {
|
|
147265
147892
|
try {
|
|
147266
|
-
const planPath =
|
|
147893
|
+
const planPath = path192.join(directory, ".swarm", "plan.json");
|
|
147267
147894
|
if (!fs128.existsSync(planPath))
|
|
147268
147895
|
return null;
|
|
147269
147896
|
const raw = fs128.readFileSync(planPath, "utf-8");
|
|
@@ -147369,7 +147996,7 @@ init_telemetry();
|
|
|
147369
147996
|
// src/turbo/lean/task-completion.ts
|
|
147370
147997
|
init_file_locks();
|
|
147371
147998
|
import * as fs129 from "node:fs";
|
|
147372
|
-
import * as
|
|
147999
|
+
import * as path193 from "node:path";
|
|
147373
148000
|
var _internals110 = {
|
|
147374
148001
|
listActiveLocks,
|
|
147375
148002
|
verifyLeanTurboTaskCompletion
|
|
@@ -147388,7 +148015,7 @@ var TIER_3_PATTERNS = [
|
|
|
147388
148015
|
];
|
|
147389
148016
|
function matchesTier3Pattern(files) {
|
|
147390
148017
|
for (const file3 of files) {
|
|
147391
|
-
const fileName =
|
|
148018
|
+
const fileName = path193.basename(file3);
|
|
147392
148019
|
for (const pattern of TIER_3_PATTERNS) {
|
|
147393
148020
|
if (pattern.test(fileName)) {
|
|
147394
148021
|
return true;
|
|
@@ -147400,7 +148027,7 @@ function matchesTier3Pattern(files) {
|
|
|
147400
148027
|
function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
147401
148028
|
let persisted = null;
|
|
147402
148029
|
try {
|
|
147403
|
-
const statePath =
|
|
148030
|
+
const statePath = path193.join(directory, ".swarm", "turbo-state.json");
|
|
147404
148031
|
if (!fs129.existsSync(statePath)) {
|
|
147405
148032
|
return {
|
|
147406
148033
|
ok: false,
|
|
@@ -147484,11 +148111,11 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
|
147484
148111
|
};
|
|
147485
148112
|
}
|
|
147486
148113
|
const phase = runState.phase ?? 0;
|
|
147487
|
-
const evidencePath =
|
|
147488
|
-
const expectedDir =
|
|
147489
|
-
const resolvedPath =
|
|
147490
|
-
const resolvedDir =
|
|
147491
|
-
if (!resolvedPath.startsWith(resolvedDir +
|
|
148114
|
+
const evidencePath = path193.join(directory, ".swarm", "evidence", String(phase), "lean-turbo", `${lane.laneId}.json`);
|
|
148115
|
+
const expectedDir = path193.join(directory, ".swarm", "evidence", String(phase), "lean-turbo");
|
|
148116
|
+
const resolvedPath = path193.resolve(evidencePath);
|
|
148117
|
+
const resolvedDir = path193.resolve(expectedDir);
|
|
148118
|
+
if (!resolvedPath.startsWith(resolvedDir + path193.sep) && resolvedPath !== resolvedDir) {
|
|
147492
148119
|
return {
|
|
147493
148120
|
ok: false,
|
|
147494
148121
|
reason: `Lane ID causes path traversal: ${lane.laneId}`,
|
|
@@ -147528,7 +148155,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
|
147528
148155
|
}
|
|
147529
148156
|
let filesTouched = [];
|
|
147530
148157
|
try {
|
|
147531
|
-
const planPath =
|
|
148158
|
+
const planPath = path193.join(directory, ".swarm", "plan.json");
|
|
147532
148159
|
const planRaw = fs129.readFileSync(planPath, "utf-8");
|
|
147533
148160
|
const plan = JSON.parse(planRaw);
|
|
147534
148161
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -147617,7 +148244,7 @@ var TIER_3_PATTERNS2 = [
|
|
|
147617
148244
|
];
|
|
147618
148245
|
function matchesTier3Pattern2(files) {
|
|
147619
148246
|
for (const file3 of files) {
|
|
147620
|
-
const fileName =
|
|
148247
|
+
const fileName = path194.basename(file3);
|
|
147621
148248
|
for (const pattern of TIER_3_PATTERNS2) {
|
|
147622
148249
|
if (pattern.test(fileName)) {
|
|
147623
148250
|
return true;
|
|
@@ -147656,7 +148283,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
147656
148283
|
if (!skipStandardTurboBypass && hasActiveTurboMode()) {
|
|
147657
148284
|
const resolvedDir2 = workingDirectory;
|
|
147658
148285
|
try {
|
|
147659
|
-
const planPath =
|
|
148286
|
+
const planPath = path194.join(resolvedDir2, ".swarm", "plan.json");
|
|
147660
148287
|
const planRaw = fs130.readFileSync(planPath, "utf-8");
|
|
147661
148288
|
const plan = JSON.parse(planRaw);
|
|
147662
148289
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -147734,7 +148361,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
147734
148361
|
}
|
|
147735
148362
|
if (resolvedDir) {
|
|
147736
148363
|
try {
|
|
147737
|
-
const planPath =
|
|
148364
|
+
const planPath = path194.join(resolvedDir, ".swarm", "plan.json");
|
|
147738
148365
|
const planRaw = fs130.readFileSync(planPath, "utf-8");
|
|
147739
148366
|
const plan = JSON.parse(planRaw);
|
|
147740
148367
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -147945,7 +148572,7 @@ function checkCouncilGate(workingDirectory, taskId) {
|
|
|
147945
148572
|
return { blocked: false, reason: "", active: false };
|
|
147946
148573
|
}
|
|
147947
148574
|
try {
|
|
147948
|
-
const planPath =
|
|
148575
|
+
const planPath = path194.join(workingDirectory, ".swarm", "plan.json");
|
|
147949
148576
|
const planRaw = fs130.readFileSync(planPath, "utf-8");
|
|
147950
148577
|
const planObj = JSON.parse(planRaw);
|
|
147951
148578
|
if (planObj.swarm && planObj.title) {
|
|
@@ -148032,7 +148659,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
148032
148659
|
};
|
|
148033
148660
|
}
|
|
148034
148661
|
directory = resolveResult.directory;
|
|
148035
|
-
const planPath =
|
|
148662
|
+
const planPath = path194.join(directory, ".swarm", "plan.json");
|
|
148036
148663
|
if (!fs130.existsSync(planPath)) {
|
|
148037
148664
|
return {
|
|
148038
148665
|
success: false,
|
|
@@ -148041,9 +148668,9 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
148041
148668
|
};
|
|
148042
148669
|
}
|
|
148043
148670
|
if (fallbackDir && directory !== fallbackDir) {
|
|
148044
|
-
const canonicalDir = fs130.realpathSync(
|
|
148045
|
-
const canonicalRoot = fs130.realpathSync(
|
|
148046
|
-
if (canonicalDir.startsWith(canonicalRoot +
|
|
148671
|
+
const canonicalDir = fs130.realpathSync(path194.resolve(directory));
|
|
148672
|
+
const canonicalRoot = fs130.realpathSync(path194.resolve(fallbackDir));
|
|
148673
|
+
if (canonicalDir.startsWith(canonicalRoot + path194.sep)) {
|
|
148047
148674
|
return {
|
|
148048
148675
|
success: false,
|
|
148049
148676
|
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 +148682,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
148055
148682
|
}
|
|
148056
148683
|
if (args2.status === "in_progress") {
|
|
148057
148684
|
try {
|
|
148058
|
-
const evidencePath =
|
|
148059
|
-
fs130.mkdirSync(
|
|
148685
|
+
const evidencePath = path194.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
|
|
148686
|
+
fs130.mkdirSync(path194.dirname(evidencePath), { recursive: true });
|
|
148060
148687
|
const fd = fs130.openSync(evidencePath, "wx");
|
|
148061
148688
|
let writeOk = false;
|
|
148062
148689
|
try {
|
|
@@ -148080,7 +148707,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
148080
148707
|
recoverTaskStateFromDelegations(args2.task_id, directory);
|
|
148081
148708
|
let phaseRequiresReviewer = true;
|
|
148082
148709
|
try {
|
|
148083
|
-
const planPath2 =
|
|
148710
|
+
const planPath2 = path194.join(directory, ".swarm", "plan.json");
|
|
148084
148711
|
const planRaw = fs130.readFileSync(planPath2, "utf-8");
|
|
148085
148712
|
const plan = JSON.parse(planRaw);
|
|
148086
148713
|
const taskPhase = plan.phases.find((p) => p.tasks.some((t) => t.id === args2.task_id));
|
|
@@ -148197,9 +148824,9 @@ import * as zlib from "node:zlib";
|
|
|
148197
148824
|
// src/evidence/documents.ts
|
|
148198
148825
|
init_utils2();
|
|
148199
148826
|
init_redaction();
|
|
148200
|
-
import { createHash as
|
|
148827
|
+
import { createHash as createHash24 } from "node:crypto";
|
|
148201
148828
|
import { appendFile as appendFile17, mkdir as mkdir34 } from "node:fs/promises";
|
|
148202
|
-
import * as
|
|
148829
|
+
import * as path195 from "node:path";
|
|
148203
148830
|
var EVIDENCE_CACHE_FILE = "evidence-cache/documents.jsonl";
|
|
148204
148831
|
var MAX_EVIDENCE_TEXT_LENGTH = 4000;
|
|
148205
148832
|
async function writeEvidenceDocuments(directory, inputs, now = () => new Date) {
|
|
@@ -148207,7 +148834,7 @@ async function writeEvidenceDocuments(directory, inputs, now = () => new Date) {
|
|
|
148207
148834
|
const capturedAt = now().toISOString();
|
|
148208
148835
|
const records = inputs.map((input) => createEvidenceDocumentRecord(input, capturedAt)).filter((record3) => record3 !== null);
|
|
148209
148836
|
if (records.length > 0) {
|
|
148210
|
-
await mkdir34(
|
|
148837
|
+
await mkdir34(path195.dirname(filePath), { recursive: true });
|
|
148211
148838
|
await appendFile17(filePath, `${records.map((record3) => JSON.stringify(record3)).join(`
|
|
148212
148839
|
`)}
|
|
148213
148840
|
`, "utf-8");
|
|
@@ -148241,7 +148868,7 @@ function createEvidenceDocumentRecord(input, defaultCapturedAt) {
|
|
|
148241
148868
|
};
|
|
148242
148869
|
}
|
|
148243
148870
|
function createEvidenceDocumentId(input) {
|
|
148244
|
-
const hash4 =
|
|
148871
|
+
const hash4 = createHash24("sha256").update([
|
|
148245
148872
|
input.sourceType,
|
|
148246
148873
|
input.query ?? "",
|
|
148247
148874
|
input.title ?? "",
|
|
@@ -149224,7 +149851,7 @@ init_schema3();
|
|
|
149224
149851
|
init_store();
|
|
149225
149852
|
init_create_tool();
|
|
149226
149853
|
init_resolve_working_directory();
|
|
149227
|
-
import * as
|
|
149854
|
+
import * as path196 from "node:path";
|
|
149228
149855
|
var FindingSchema2 = exports_external.object({
|
|
149229
149856
|
severity: exports_external.enum(["low", "medium", "high", "critical"]),
|
|
149230
149857
|
category: exports_external.string().min(1),
|
|
@@ -149300,7 +149927,7 @@ var write_architecture_supervisor_evidence = createSwarmTool({
|
|
|
149300
149927
|
if (config3.architectural_supervision?.persist_knowledge_recommendations && args2.knowledge_recommendations.length > 0) {
|
|
149301
149928
|
const knowledgeConfig = KnowledgeConfigSchema.parse(config3.knowledge ?? {});
|
|
149302
149929
|
const lessons = args2.knowledge_recommendations.map((r) => r.lesson);
|
|
149303
|
-
const result = await curateAndStoreSwarm(lessons,
|
|
149930
|
+
const result = await curateAndStoreSwarm(lessons, path196.basename(dirResult.directory), { phase_number: args2.phase }, dirResult.directory, knowledgeConfig, {
|
|
149304
149931
|
skipAutoPromotion: true,
|
|
149305
149932
|
llmDelegate: createCuratorLLMDelegate(dirResult.directory, "phase"),
|
|
149306
149933
|
enrichmentQuota: {
|
|
@@ -149347,7 +149974,7 @@ init_ledger();
|
|
|
149347
149974
|
init_manager();
|
|
149348
149975
|
init_create_tool();
|
|
149349
149976
|
import fs131 from "node:fs";
|
|
149350
|
-
import
|
|
149977
|
+
import path197 from "node:path";
|
|
149351
149978
|
function normalizeVerdict(verdict) {
|
|
149352
149979
|
switch (verdict) {
|
|
149353
149980
|
case "APPROVED":
|
|
@@ -149401,7 +150028,7 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
149401
150028
|
entries: [evidenceEntry]
|
|
149402
150029
|
};
|
|
149403
150030
|
const filename = "drift-verifier.json";
|
|
149404
|
-
const relativePath =
|
|
150031
|
+
const relativePath = path197.join("evidence", String(phase), filename);
|
|
149405
150032
|
let validatedPath;
|
|
149406
150033
|
try {
|
|
149407
150034
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -149412,10 +150039,10 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
149412
150039
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
149413
150040
|
}, null, 2);
|
|
149414
150041
|
}
|
|
149415
|
-
const evidenceDir =
|
|
150042
|
+
const evidenceDir = path197.dirname(validatedPath);
|
|
149416
150043
|
try {
|
|
149417
150044
|
await fs131.promises.mkdir(evidenceDir, { recursive: true });
|
|
149418
|
-
const tempPath =
|
|
150045
|
+
const tempPath = path197.join(evidenceDir, `.${filename}.tmp`);
|
|
149419
150046
|
await fs131.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
149420
150047
|
await fs131.promises.rename(tempPath, validatedPath);
|
|
149421
150048
|
let snapshotInfo;
|
|
@@ -149516,7 +150143,7 @@ var write_drift_evidence = createSwarmTool({
|
|
|
149516
150143
|
init_zod();
|
|
149517
150144
|
init_loader();
|
|
149518
150145
|
import fs132 from "node:fs";
|
|
149519
|
-
import
|
|
150146
|
+
import path198 from "node:path";
|
|
149520
150147
|
init_utils2();
|
|
149521
150148
|
init_manager();
|
|
149522
150149
|
init_create_tool();
|
|
@@ -149630,7 +150257,7 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
|
|
|
149630
150257
|
timestamp: synthesis.timestamp
|
|
149631
150258
|
};
|
|
149632
150259
|
const filename = "final-council.json";
|
|
149633
|
-
const relativePath =
|
|
150260
|
+
const relativePath = path198.join("evidence", filename);
|
|
149634
150261
|
let validatedPath;
|
|
149635
150262
|
try {
|
|
149636
150263
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -149644,10 +150271,10 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
|
|
|
149644
150271
|
const evidenceContent = {
|
|
149645
150272
|
entries: [evidenceEntry]
|
|
149646
150273
|
};
|
|
149647
|
-
const evidenceDir =
|
|
150274
|
+
const evidenceDir = path198.dirname(validatedPath);
|
|
149648
150275
|
try {
|
|
149649
150276
|
await fs132.promises.mkdir(evidenceDir, { recursive: true });
|
|
149650
|
-
const tempPath =
|
|
150277
|
+
const tempPath = path198.join(evidenceDir, `.${filename}.tmp`);
|
|
149651
150278
|
await fs132.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
149652
150279
|
await fs132.promises.rename(tempPath, validatedPath);
|
|
149653
150280
|
return JSON.stringify({
|
|
@@ -149707,7 +150334,7 @@ init_zod();
|
|
|
149707
150334
|
init_utils2();
|
|
149708
150335
|
init_create_tool();
|
|
149709
150336
|
import fs133 from "node:fs";
|
|
149710
|
-
import
|
|
150337
|
+
import path199 from "node:path";
|
|
149711
150338
|
function normalizeVerdict2(verdict) {
|
|
149712
150339
|
switch (verdict) {
|
|
149713
150340
|
case "APPROVED":
|
|
@@ -149755,7 +150382,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
149755
150382
|
entries: [evidenceEntry]
|
|
149756
150383
|
};
|
|
149757
150384
|
const filename = "hallucination-guard.json";
|
|
149758
|
-
const relativePath =
|
|
150385
|
+
const relativePath = path199.join("evidence", String(phase), filename);
|
|
149759
150386
|
let validatedPath;
|
|
149760
150387
|
try {
|
|
149761
150388
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -149766,10 +150393,10 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
149766
150393
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
149767
150394
|
}, null, 2);
|
|
149768
150395
|
}
|
|
149769
|
-
const evidenceDir =
|
|
150396
|
+
const evidenceDir = path199.dirname(validatedPath);
|
|
149770
150397
|
try {
|
|
149771
150398
|
await fs133.promises.mkdir(evidenceDir, { recursive: true });
|
|
149772
|
-
const tempPath =
|
|
150399
|
+
const tempPath = path199.join(evidenceDir, `.${filename}.tmp`);
|
|
149773
150400
|
await fs133.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
149774
150401
|
await fs133.promises.rename(tempPath, validatedPath);
|
|
149775
150402
|
return JSON.stringify({
|
|
@@ -149819,7 +150446,7 @@ init_zod();
|
|
|
149819
150446
|
init_utils2();
|
|
149820
150447
|
init_create_tool();
|
|
149821
150448
|
import fs134 from "node:fs";
|
|
149822
|
-
import
|
|
150449
|
+
import path200 from "node:path";
|
|
149823
150450
|
function normalizeVerdict3(verdict) {
|
|
149824
150451
|
switch (verdict) {
|
|
149825
150452
|
case "PASS":
|
|
@@ -149893,7 +150520,7 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
149893
150520
|
entries: [evidenceEntry]
|
|
149894
150521
|
};
|
|
149895
150522
|
const filename = "mutation-gate.json";
|
|
149896
|
-
const relativePath =
|
|
150523
|
+
const relativePath = path200.join("evidence", String(phase), filename);
|
|
149897
150524
|
let validatedPath;
|
|
149898
150525
|
try {
|
|
149899
150526
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -149904,10 +150531,10 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
149904
150531
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
149905
150532
|
}, null, 2);
|
|
149906
150533
|
}
|
|
149907
|
-
const evidenceDir =
|
|
150534
|
+
const evidenceDir = path200.dirname(validatedPath);
|
|
149908
150535
|
try {
|
|
149909
150536
|
await fs134.promises.mkdir(evidenceDir, { recursive: true });
|
|
149910
|
-
const tempPath =
|
|
150537
|
+
const tempPath = path200.join(evidenceDir, `.${filename}.tmp`);
|
|
149911
150538
|
await fs134.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
149912
150539
|
await fs134.promises.rename(tempPath, validatedPath);
|
|
149913
150540
|
return JSON.stringify({
|
|
@@ -149994,6 +150621,7 @@ var TOOL_MANIFEST = defineHandlers({
|
|
|
149994
150621
|
git_blame: () => git_blame,
|
|
149995
150622
|
gitingest: () => gitingest,
|
|
149996
150623
|
retrieve_summary: () => retrieve_summary,
|
|
150624
|
+
retrieve_lane_output: () => retrieve_lane_output,
|
|
149997
150625
|
extract_code_blocks: () => extract_code_blocks,
|
|
149998
150626
|
phase_complete: () => phase_complete,
|
|
149999
150627
|
save_plan: () => save_plan,
|
|
@@ -150117,7 +150745,7 @@ ${footerLines.join(`
|
|
|
150117
150745
|
init_warning_buffer();
|
|
150118
150746
|
var _heartbeatTimers = new Map;
|
|
150119
150747
|
var SWARM_COMMAND_SYSTEM_RULE_TAG = "[opencode-swarm:swarm-command-rule]";
|
|
150120
|
-
var PACKAGE_ROOT2 =
|
|
150748
|
+
var PACKAGE_ROOT2 = path202.resolve(path202.dirname(fileURLToPath5(import.meta.url)), "..");
|
|
150121
150749
|
var SYNC_BUNDLED_SKILLS_TIMEOUT_MS = 2000;
|
|
150122
150750
|
function createSwarmCommandSystemRuleHook(agentDefinitions, registeredAgents) {
|
|
150123
150751
|
return async (input, output) => {
|
|
@@ -150438,7 +151066,7 @@ async function initializeOpenCodeSwarm(ctx) {
|
|
|
150438
151066
|
const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
|
|
150439
151067
|
preflightTriggerManager = new PTM(automationConfig);
|
|
150440
151068
|
const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
|
|
150441
|
-
const swarmDir =
|
|
151069
|
+
const swarmDir = path202.resolve(ctx.directory, ".swarm");
|
|
150442
151070
|
statusArtifact = new ASA(swarmDir);
|
|
150443
151071
|
statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
|
|
150444
151072
|
if (automationConfig.capabilities?.evidence_auto_summaries === true) {
|
|
@@ -151102,7 +151730,7 @@ ${promptRaw}`;
|
|
|
151102
151730
|
const meta3 = readSkillMetadata(s.skillPath, ctx.directory);
|
|
151103
151731
|
let desc = meta3.description || "";
|
|
151104
151732
|
if (!desc || desc === "No description provided") {
|
|
151105
|
-
desc =
|
|
151733
|
+
desc = path202.basename(path202.dirname(s.skillPath));
|
|
151106
151734
|
}
|
|
151107
151735
|
desc = desc.replace(/,/g, ";");
|
|
151108
151736
|
return `file:${s.skillPath} (-- ${desc})`;
|
|
@@ -151112,7 +151740,7 @@ ${promptRaw}`;
|
|
|
151112
151740
|
|
|
151113
151741
|
${promptRaw}`;
|
|
151114
151742
|
argsRecord.prompt = newPrompt;
|
|
151115
|
-
const skillNames = topSkills.map((s) => `${
|
|
151743
|
+
const skillNames = topSkills.map((s) => `${path202.basename(s.skillPath)} (score: ${s.score.toFixed(2)})`).join(", ");
|
|
151116
151744
|
console.warn(`[skill-propagation-gate] Injected skills: ${skillNames}`);
|
|
151117
151745
|
for (const skill of topSkills) {
|
|
151118
151746
|
try {
|