opencode-swarm 7.87.3 → 7.88.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/swarm-pr-review/SKILL.md +304 -9
- package/README.md +1 -0
- package/dist/background/candidate-parser.d.ts +189 -0
- package/dist/background/candidate-sidecar-store.d.ts +56 -0
- package/dist/cli/{config-doctor-6h64pn8n.js → config-doctor-jzbgpbdh.js} +2 -2
- package/dist/cli/{guardrail-explain-2q9myk7c.js → guardrail-explain-sw5bjxtk.js} +5 -5
- package/dist/cli/{guardrail-log-eegabqcp.js → guardrail-log-c7egm5km.js} +3 -3
- package/dist/cli/{index-q9h0wb04.js → index-0asbrmdx.js} +4 -0
- package/dist/cli/{index-1cb4wxnm.js → index-819xp49y.js} +1 -1
- package/dist/cli/{index-r3f47swm.js → index-dkytd370.js} +6 -6
- package/dist/cli/{index-amwa268r.js → index-fwb5f2gr.js} +2 -2
- package/dist/cli/{index-5hvbw5xh.js → index-g00qm2gf.js} +1 -1
- package/dist/cli/{index-kz1bmebr.js → index-jch711dq.js} +9 -9
- package/dist/cli/{index-5vpe6vq9.js → index-vjsr9bqt.js} +1 -1
- package/dist/cli/index.js +4 -4
- package/dist/cli/{schema-84146tvk.js → schema-vb6jkxgg.js} +1 -1
- package/dist/index.js +1015 -244
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/manifest.d.ts +1 -0
- package/dist/tools/parse-lane-candidates.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.88.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",
|
|
@@ -359,6 +359,10 @@ var init_tool_metadata = __esm(() => {
|
|
|
359
359
|
"test_engineer"
|
|
360
360
|
]
|
|
361
361
|
},
|
|
362
|
+
parse_lane_candidates: {
|
|
363
|
+
description: "Parse [CANDIDATE] rows from a dispatch_lanes or collect_lane_results artifact (by output_ref), produce structured records with provenance, optionally persist to a per-batch sidecar JSONL. Pure-parser variant exists as internal module.",
|
|
364
|
+
agents: ["architect"]
|
|
365
|
+
},
|
|
362
366
|
test_runner: {
|
|
363
367
|
description: "auto-detect and run tests",
|
|
364
368
|
agents: ["architect", "reviewer", "test_engineer"]
|
|
@@ -109870,7 +109874,7 @@ __export(exports_design_doc_drift, {
|
|
|
109870
109874
|
_internals: () => _internals111
|
|
109871
109875
|
});
|
|
109872
109876
|
import * as fs118 from "node:fs";
|
|
109873
|
-
import * as
|
|
109877
|
+
import * as path181 from "node:path";
|
|
109874
109878
|
function mtimeMsOrNull(absPath) {
|
|
109875
109879
|
try {
|
|
109876
109880
|
return fs118.statSync(absPath).mtimeMs;
|
|
@@ -109881,35 +109885,35 @@ function mtimeMsOrNull(absPath) {
|
|
|
109881
109885
|
function resolveAnchorWithin(directory, anchor) {
|
|
109882
109886
|
if (!anchor || typeof anchor !== "string")
|
|
109883
109887
|
return null;
|
|
109884
|
-
const root =
|
|
109885
|
-
const resolved =
|
|
109886
|
-
const rel =
|
|
109887
|
-
if (rel.startsWith("..") ||
|
|
109888
|
+
const root = path181.resolve(directory);
|
|
109889
|
+
const resolved = path181.resolve(root, anchor);
|
|
109890
|
+
const rel = path181.relative(root, resolved);
|
|
109891
|
+
if (rel.startsWith("..") || path181.isAbsolute(rel))
|
|
109888
109892
|
return null;
|
|
109889
109893
|
return resolved;
|
|
109890
109894
|
}
|
|
109891
109895
|
async function runDesignDocDriftCheck(directory, phase, outDir) {
|
|
109892
109896
|
try {
|
|
109893
|
-
const root =
|
|
109894
|
-
const outAbs =
|
|
109895
|
-
const outRel =
|
|
109896
|
-
if (outRel.startsWith("..") ||
|
|
109897
|
+
const root = path181.resolve(directory);
|
|
109898
|
+
const outAbs = path181.resolve(root, outDir);
|
|
109899
|
+
const outRel = path181.relative(root, outAbs);
|
|
109900
|
+
if (outRel.startsWith("..") || path181.isAbsolute(outRel)) {
|
|
109897
109901
|
return null;
|
|
109898
109902
|
}
|
|
109899
109903
|
const docMtimes = new Map;
|
|
109900
109904
|
const checkedDocs = [];
|
|
109901
109905
|
const missingDocs = [];
|
|
109902
109906
|
for (const [docName, relFile] of Object.entries(DESIGN_DOC_FILES)) {
|
|
109903
|
-
const abs =
|
|
109907
|
+
const abs = path181.join(outAbs, relFile);
|
|
109904
109908
|
const mtime = mtimeMsOrNull(abs);
|
|
109905
109909
|
docMtimes.set(docName, mtime);
|
|
109906
109910
|
if (mtime === null) {
|
|
109907
|
-
missingDocs.push(
|
|
109911
|
+
missingDocs.push(path181.join(outDir, relFile));
|
|
109908
109912
|
} else {
|
|
109909
|
-
checkedDocs.push(
|
|
109913
|
+
checkedDocs.push(path181.join(outDir, relFile));
|
|
109910
109914
|
}
|
|
109911
109915
|
}
|
|
109912
|
-
const traceabilityAbs =
|
|
109916
|
+
const traceabilityAbs = path181.join(outAbs, TRACEABILITY_REL);
|
|
109913
109917
|
let registry3 = null;
|
|
109914
109918
|
try {
|
|
109915
109919
|
const stat14 = await fs118.promises.stat(traceabilityAbs);
|
|
@@ -109979,7 +109983,7 @@ async function runDesignDocDriftCheck(directory, phase, outDir) {
|
|
|
109979
109983
|
};
|
|
109980
109984
|
const filename = `${DOC_DRIFT_REPORT_PREFIX}${phase}.json`;
|
|
109981
109985
|
const filePath = validateSwarmPath(directory, filename);
|
|
109982
|
-
await fs118.promises.mkdir(
|
|
109986
|
+
await fs118.promises.mkdir(path181.dirname(filePath), { recursive: true });
|
|
109983
109987
|
await fs118.promises.writeFile(filePath, JSON.stringify(report, null, 2), "utf-8");
|
|
109984
109988
|
getGlobalEventBus().publish("curator.docdrift.completed", {
|
|
109985
109989
|
phase,
|
|
@@ -110011,10 +110015,10 @@ var init_design_doc_drift = __esm(() => {
|
|
|
110011
110015
|
domain: "domain.md",
|
|
110012
110016
|
"technical-spec": "technical-spec.md",
|
|
110013
110017
|
"behavior-spec": "behavior-spec.md",
|
|
110014
|
-
"reference-impl":
|
|
110015
|
-
"idiom-notes":
|
|
110018
|
+
"reference-impl": path181.join("reference", "reference-impl.md"),
|
|
110019
|
+
"idiom-notes": path181.join("reference", "idiom-notes.md")
|
|
110016
110020
|
};
|
|
110017
|
-
TRACEABILITY_REL =
|
|
110021
|
+
TRACEABILITY_REL = path181.join("reference", "traceability.json");
|
|
110018
110022
|
_internals111 = {
|
|
110019
110023
|
mtimeMsOrNull,
|
|
110020
110024
|
resolveAnchorWithin,
|
|
@@ -110030,7 +110034,7 @@ __export(exports_project_context, {
|
|
|
110030
110034
|
LANG_BACKEND_DETECTION_TIMEOUT_MS: () => LANG_BACKEND_DETECTION_TIMEOUT_MS
|
|
110031
110035
|
});
|
|
110032
110036
|
import * as fs142 from "node:fs";
|
|
110033
|
-
import * as
|
|
110037
|
+
import * as path210 from "node:path";
|
|
110034
110038
|
function detectFileExists2(directory, pattern) {
|
|
110035
110039
|
if (pattern.includes("*") || pattern.includes("?")) {
|
|
110036
110040
|
try {
|
|
@@ -110042,7 +110046,7 @@ function detectFileExists2(directory, pattern) {
|
|
|
110042
110046
|
}
|
|
110043
110047
|
}
|
|
110044
110048
|
try {
|
|
110045
|
-
fs142.accessSync(
|
|
110049
|
+
fs142.accessSync(path210.join(directory, pattern));
|
|
110046
110050
|
return true;
|
|
110047
110051
|
} catch {
|
|
110048
110052
|
return false;
|
|
@@ -110051,7 +110055,7 @@ function detectFileExists2(directory, pattern) {
|
|
|
110051
110055
|
function selectTestCommandFromScriptsTest(backend, directory) {
|
|
110052
110056
|
let pkgRaw;
|
|
110053
110057
|
try {
|
|
110054
|
-
pkgRaw = fs142.readFileSync(
|
|
110058
|
+
pkgRaw = fs142.readFileSync(path210.join(directory, "package.json"), "utf-8");
|
|
110055
110059
|
} catch {
|
|
110056
110060
|
return null;
|
|
110057
110061
|
}
|
|
@@ -110169,7 +110173,7 @@ var init_project_context = __esm(() => {
|
|
|
110169
110173
|
init_package();
|
|
110170
110174
|
init_agents2();
|
|
110171
110175
|
init_critic();
|
|
110172
|
-
import * as
|
|
110176
|
+
import * as path211 from "node:path";
|
|
110173
110177
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
110174
110178
|
|
|
110175
110179
|
// src/background/index.ts
|
|
@@ -139179,6 +139183,772 @@ var mutation_test = createSwarmTool({
|
|
|
139179
139183
|
}
|
|
139180
139184
|
});
|
|
139181
139185
|
|
|
139186
|
+
// src/tools/parse-lane-candidates.ts
|
|
139187
|
+
init_zod();
|
|
139188
|
+
import { existsSync as existsSync100 } from "node:fs";
|
|
139189
|
+
import * as path172 from "node:path";
|
|
139190
|
+
|
|
139191
|
+
// src/background/candidate-parser.ts
|
|
139192
|
+
init_zod();
|
|
139193
|
+
|
|
139194
|
+
// src/background/candidate-sidecar-store.ts
|
|
139195
|
+
init_zod();
|
|
139196
|
+
init_utils2();
|
|
139197
|
+
var import_proper_lockfile10 = __toESM(require_proper_lockfile(), 1);
|
|
139198
|
+
import { createHash as createHash23 } from "node:crypto";
|
|
139199
|
+
import { appendFileSync as appendFileSync19, mkdirSync as mkdirSync45 } from "node:fs";
|
|
139200
|
+
import * as path171 from "node:path";
|
|
139201
|
+
var BATCH_DIGEST_ALGORITHM = "sha256";
|
|
139202
|
+
var SidecarEnvelopeSchema = exports_external.object({
|
|
139203
|
+
record_type: exports_external.literal("invocation"),
|
|
139204
|
+
source_output_ref: exports_external.string().min(1),
|
|
139205
|
+
source_batch_id: exports_external.string().min(1),
|
|
139206
|
+
source_lane_id: exports_external.string().min(1),
|
|
139207
|
+
source_agent: exports_external.string().min(1),
|
|
139208
|
+
source_digest: exports_external.string().regex(/^[a-f0-9]{64}$/),
|
|
139209
|
+
row_format_version: exports_external.number().int().nonnegative(),
|
|
139210
|
+
producer: exports_external.string().optional(),
|
|
139211
|
+
produced_at: exports_external.string().min(1),
|
|
139212
|
+
record_version: exports_external.object({
|
|
139213
|
+
major: exports_external.number().int().nonnegative(),
|
|
139214
|
+
minor: exports_external.number().int().nonnegative()
|
|
139215
|
+
}),
|
|
139216
|
+
sessionId: exports_external.string().min(1).optional(),
|
|
139217
|
+
parentSessionId: exports_external.string().min(1).optional(),
|
|
139218
|
+
format_families_detected: exports_external.array(exports_external.string()),
|
|
139219
|
+
candidate_count: exports_external.number().int().nonnegative(),
|
|
139220
|
+
parse_errors: exports_external.number().int().nonnegative(),
|
|
139221
|
+
malformed_rows: exports_external.number().int().nonnegative()
|
|
139222
|
+
}).strict();
|
|
139223
|
+
var SidecarCandidateSchema = exports_external.object({
|
|
139224
|
+
record_type: exports_external.literal("candidate"),
|
|
139225
|
+
row_format_family: exports_external.enum(["base_explorer", "micro_lane"]),
|
|
139226
|
+
row_format_version: exports_external.number().int().nonnegative(),
|
|
139227
|
+
record_version: exports_external.object({
|
|
139228
|
+
major: exports_external.number().int().nonnegative(),
|
|
139229
|
+
minor: exports_external.number().int().nonnegative()
|
|
139230
|
+
}),
|
|
139231
|
+
source_output_ref: exports_external.string().min(1),
|
|
139232
|
+
source_batch_id: exports_external.string().min(1),
|
|
139233
|
+
source_lane_id: exports_external.string().min(1),
|
|
139234
|
+
source_agent: exports_external.string().min(1),
|
|
139235
|
+
source_digest: exports_external.string().regex(/^[a-f0-9]{64}$/),
|
|
139236
|
+
sessionId: exports_external.string().min(1).optional(),
|
|
139237
|
+
parentSessionId: exports_external.string().min(1).optional(),
|
|
139238
|
+
producer: exports_external.string().optional(),
|
|
139239
|
+
extracted_from_partial_source: exports_external.boolean(),
|
|
139240
|
+
candidate_id: exports_external.string().min(1),
|
|
139241
|
+
lane: exports_external.string().nullable(),
|
|
139242
|
+
micro_lane: exports_external.string().nullable(),
|
|
139243
|
+
severity: exports_external.string().nullable(),
|
|
139244
|
+
category: exports_external.string().nullable(),
|
|
139245
|
+
file_line: exports_external.string().nullable(),
|
|
139246
|
+
claim: exports_external.string().nullable(),
|
|
139247
|
+
evidence_summary: exports_external.string().nullable(),
|
|
139248
|
+
impact_context: exports_external.string().nullable(),
|
|
139249
|
+
invariant_violated: exports_external.string().nullable(),
|
|
139250
|
+
confidence: exports_external.string().nullable()
|
|
139251
|
+
}).strict();
|
|
139252
|
+
var BIDI_RANGES = [
|
|
139253
|
+
[8234, 8238],
|
|
139254
|
+
[8294, 8297]
|
|
139255
|
+
];
|
|
139256
|
+
function isBidiCodePoint(code) {
|
|
139257
|
+
for (let i2 = 0;i2 < BIDI_RANGES.length; i2++) {
|
|
139258
|
+
const [lo, hi] = BIDI_RANGES[i2];
|
|
139259
|
+
if (code >= lo && code <= hi)
|
|
139260
|
+
return true;
|
|
139261
|
+
}
|
|
139262
|
+
return false;
|
|
139263
|
+
}
|
|
139264
|
+
function sanitizeString3(value) {
|
|
139265
|
+
let result = "";
|
|
139266
|
+
for (let i2 = 0;i2 < value.length; i2++) {
|
|
139267
|
+
const code = value.codePointAt(i2) ?? 0;
|
|
139268
|
+
if (code > 65535) {
|
|
139269
|
+
result += value[i2];
|
|
139270
|
+
i2++;
|
|
139271
|
+
result += value[i2];
|
|
139272
|
+
} else if (code === 0) {
|
|
139273
|
+
result += "\\u0000";
|
|
139274
|
+
} else if (code === 27) {
|
|
139275
|
+
if (i2 + 1 < value.length && value[i2 + 1] === "[") {
|
|
139276
|
+
i2++;
|
|
139277
|
+
while (i2 + 1 < value.length) {
|
|
139278
|
+
const next = value.charCodeAt(i2 + 1);
|
|
139279
|
+
if (next >= 48 && next <= 63) {
|
|
139280
|
+
i2++;
|
|
139281
|
+
} else if (next >= 32 && next <= 47) {
|
|
139282
|
+
i2++;
|
|
139283
|
+
} else if (next >= 64 && next <= 126) {
|
|
139284
|
+
i2++;
|
|
139285
|
+
break;
|
|
139286
|
+
} else {
|
|
139287
|
+
break;
|
|
139288
|
+
}
|
|
139289
|
+
}
|
|
139290
|
+
} else if (i2 + 1 < value.length && value[i2 + 1] === "]") {
|
|
139291
|
+
i2++;
|
|
139292
|
+
while (i2 + 1 < value.length) {
|
|
139293
|
+
const next = value.charCodeAt(i2 + 1);
|
|
139294
|
+
if (next === 7) {
|
|
139295
|
+
i2++;
|
|
139296
|
+
break;
|
|
139297
|
+
} else if (next === 27 && i2 + 2 < value.length && value[i2 + 2] === "\\") {
|
|
139298
|
+
i2 += 2;
|
|
139299
|
+
break;
|
|
139300
|
+
} else {
|
|
139301
|
+
i2++;
|
|
139302
|
+
}
|
|
139303
|
+
}
|
|
139304
|
+
} else if (i2 + 1 < value.length) {
|
|
139305
|
+
const next = value.charCodeAt(i2 + 1);
|
|
139306
|
+
if (next >= 32 && next <= 47) {
|
|
139307
|
+
i2++;
|
|
139308
|
+
while (i2 + 1 < value.length) {
|
|
139309
|
+
const b = value.charCodeAt(i2 + 1);
|
|
139310
|
+
if (b >= 48 && b <= 126) {
|
|
139311
|
+
i2++;
|
|
139312
|
+
break;
|
|
139313
|
+
} else if (b >= 32 && b <= 47) {
|
|
139314
|
+
i2++;
|
|
139315
|
+
} else {
|
|
139316
|
+
break;
|
|
139317
|
+
}
|
|
139318
|
+
}
|
|
139319
|
+
} else if (next >= 48 && next <= 126) {
|
|
139320
|
+
i2++;
|
|
139321
|
+
}
|
|
139322
|
+
}
|
|
139323
|
+
} else if (isBidiCodePoint(code)) {} else {
|
|
139324
|
+
result += value[i2];
|
|
139325
|
+
}
|
|
139326
|
+
}
|
|
139327
|
+
return result;
|
|
139328
|
+
}
|
|
139329
|
+
function sanitizeRecord(record3) {
|
|
139330
|
+
for (const key of Object.keys(record3)) {
|
|
139331
|
+
const value = record3[key];
|
|
139332
|
+
if (typeof value === "string") {
|
|
139333
|
+
record3[key] = sanitizeString3(value);
|
|
139334
|
+
} else if (value !== null && typeof value === "object") {
|
|
139335
|
+
if (Array.isArray(value)) {
|
|
139336
|
+
for (let i2 = 0;i2 < value.length; i2++) {
|
|
139337
|
+
const element = value[i2];
|
|
139338
|
+
if (typeof element === "string") {
|
|
139339
|
+
value[i2] = sanitizeString3(element);
|
|
139340
|
+
} else if (element !== null && typeof element === "object") {
|
|
139341
|
+
sanitizeRecord(element);
|
|
139342
|
+
}
|
|
139343
|
+
}
|
|
139344
|
+
} else {
|
|
139345
|
+
sanitizeRecord(value);
|
|
139346
|
+
}
|
|
139347
|
+
}
|
|
139348
|
+
}
|
|
139349
|
+
return record3;
|
|
139350
|
+
}
|
|
139351
|
+
function computeBatchDigest(batchId) {
|
|
139352
|
+
return createHash23(BATCH_DIGEST_ALGORITHM).update(batchId).digest("hex");
|
|
139353
|
+
}
|
|
139354
|
+
function sidecarRelativePath(batchDigest) {
|
|
139355
|
+
return path171.join("lane-results", batchDigest, "candidates.jsonl");
|
|
139356
|
+
}
|
|
139357
|
+
function validateRecord(record3, schema, label) {
|
|
139358
|
+
const result = schema.safeParse(record3);
|
|
139359
|
+
if (!result.success) {
|
|
139360
|
+
throw new Error(`Sidecar ${label} schema validation failed: ${result.error.issues.map((i2) => `${i2.path.join(".")}: ${i2.message}`).join("; ")}`);
|
|
139361
|
+
}
|
|
139362
|
+
}
|
|
139363
|
+
function withLockfile(lockDir, write) {
|
|
139364
|
+
const lockPath = path171.join(lockDir, ".lock");
|
|
139365
|
+
const lf = import_proper_lockfile10.default;
|
|
139366
|
+
const release = lf.lockSync(lockPath, {
|
|
139367
|
+
realpath: false
|
|
139368
|
+
});
|
|
139369
|
+
try {
|
|
139370
|
+
return write();
|
|
139371
|
+
} finally {
|
|
139372
|
+
release();
|
|
139373
|
+
}
|
|
139374
|
+
}
|
|
139375
|
+
function appendToSidecar(options, batchId, envelope, candidates) {
|
|
139376
|
+
const batchDigest = options.batchDigest ?? computeBatchDigest(batchId);
|
|
139377
|
+
const relPath = sidecarRelativePath(batchDigest);
|
|
139378
|
+
const absPath = validateSwarmPath(options.projectRoot, relPath);
|
|
139379
|
+
validateRecord(envelope, SidecarEnvelopeSchema, "envelope");
|
|
139380
|
+
for (let i2 = 0;i2 < candidates.length; i2++) {
|
|
139381
|
+
validateRecord(candidates[i2], SidecarCandidateSchema, `candidate[${i2}]`);
|
|
139382
|
+
}
|
|
139383
|
+
mkdirSync45(path171.dirname(absPath), { recursive: true });
|
|
139384
|
+
const sanitizedEnvelope = sanitizeRecord(structuredClone(envelope));
|
|
139385
|
+
const sanitizedCandidates = candidates.map((c) => sanitizeRecord(structuredClone(c)));
|
|
139386
|
+
const lines = [JSON.stringify(sanitizedEnvelope)];
|
|
139387
|
+
for (const candidate of sanitizedCandidates) {
|
|
139388
|
+
lines.push(JSON.stringify(candidate));
|
|
139389
|
+
}
|
|
139390
|
+
const payload = `${lines.join(`
|
|
139391
|
+
`)}
|
|
139392
|
+
`;
|
|
139393
|
+
const doWrite = () => {
|
|
139394
|
+
appendFileSync19(absPath, payload, "utf-8");
|
|
139395
|
+
};
|
|
139396
|
+
if (options.useLockfile) {
|
|
139397
|
+
withLockfile(path171.dirname(absPath), doWrite);
|
|
139398
|
+
} else {
|
|
139399
|
+
doWrite();
|
|
139400
|
+
}
|
|
139401
|
+
}
|
|
139402
|
+
|
|
139403
|
+
// src/background/candidate-parser.ts
|
|
139404
|
+
var ArtifactInputSchema = exports_external.object({
|
|
139405
|
+
output_ref: exports_external.string().min(1, "output_ref must be a non-empty string"),
|
|
139406
|
+
batchId: exports_external.string().min(1, "batchId must be a non-empty string"),
|
|
139407
|
+
laneId: exports_external.string().min(1, "laneId must be a non-empty string"),
|
|
139408
|
+
agent: exports_external.string().min(1, "agent must be a non-empty string"),
|
|
139409
|
+
role: exports_external.string().min(1, "role must be a non-empty string"),
|
|
139410
|
+
sessionId: exports_external.string().min(1).optional(),
|
|
139411
|
+
parentSessionId: exports_external.string().min(1).optional(),
|
|
139412
|
+
digest: exports_external.string().regex(/^[a-f0-9]{64}$/, "digest must be a SHA-256 hex string"),
|
|
139413
|
+
text: exports_external.string(),
|
|
139414
|
+
transcriptIncomplete: exports_external.boolean().optional(),
|
|
139415
|
+
artifact_status: exports_external.enum(["ok", "ref-not-found", "artifact-corrupted"]),
|
|
139416
|
+
source: exports_external.enum(["dispatch_lanes", "collect_lane_results"]),
|
|
139417
|
+
produced_at: exports_external.string().min(1, "produced_at must be a non-empty string")
|
|
139418
|
+
}).strict();
|
|
139419
|
+
var ParseFlagsSchema = exports_external.object({
|
|
139420
|
+
accept_partial: exports_external.boolean(),
|
|
139421
|
+
accept_degraded: exports_external.boolean(),
|
|
139422
|
+
degraded: exports_external.boolean(),
|
|
139423
|
+
row_format_version: exports_external.number().int().nonnegative(),
|
|
139424
|
+
producer: exports_external.string().optional()
|
|
139425
|
+
}).strict();
|
|
139426
|
+
var BASE_EXPLORER_FIELDS = [
|
|
139427
|
+
"candidate_id",
|
|
139428
|
+
"lane",
|
|
139429
|
+
"severity",
|
|
139430
|
+
"category",
|
|
139431
|
+
"file_line",
|
|
139432
|
+
"claim",
|
|
139433
|
+
"evidence_summary",
|
|
139434
|
+
"impact_context",
|
|
139435
|
+
"confidence"
|
|
139436
|
+
];
|
|
139437
|
+
var MICRO_LANE_FIELDS = [
|
|
139438
|
+
"candidate_id",
|
|
139439
|
+
"micro_lane",
|
|
139440
|
+
"severity",
|
|
139441
|
+
"category",
|
|
139442
|
+
"file_line",
|
|
139443
|
+
"claim",
|
|
139444
|
+
"invariant_violated",
|
|
139445
|
+
"evidence_summary",
|
|
139446
|
+
"confidence"
|
|
139447
|
+
];
|
|
139448
|
+
var BASE_EXPLORER_DISCRIMINATOR = "impact_context";
|
|
139449
|
+
var MICRO_LANE_DISCRIMINATOR = "invariant_violated";
|
|
139450
|
+
var EXPECTED_FIELD_COUNT = 9;
|
|
139451
|
+
var RECORD_VERSION = { major: 1, minor: 0 };
|
|
139452
|
+
function splitRow(line) {
|
|
139453
|
+
const fields = [];
|
|
139454
|
+
let current = "";
|
|
139455
|
+
let i2 = 0;
|
|
139456
|
+
while (i2 < line.length) {
|
|
139457
|
+
if (line[i2] === "\\" && i2 + 1 < line.length && line[i2 + 1] === "|") {
|
|
139458
|
+
current += "|";
|
|
139459
|
+
i2 += 2;
|
|
139460
|
+
} else if (line[i2] === "|") {
|
|
139461
|
+
fields.push(current);
|
|
139462
|
+
current = "";
|
|
139463
|
+
i2++;
|
|
139464
|
+
} else {
|
|
139465
|
+
current += line[i2];
|
|
139466
|
+
i2++;
|
|
139467
|
+
}
|
|
139468
|
+
}
|
|
139469
|
+
fields.push(current);
|
|
139470
|
+
return fields;
|
|
139471
|
+
}
|
|
139472
|
+
function removeCodeFences(text) {
|
|
139473
|
+
const lines = [];
|
|
139474
|
+
let inFence = false;
|
|
139475
|
+
for (const rawLine of text.split(`
|
|
139476
|
+
`)) {
|
|
139477
|
+
const trimmedStart = rawLine.trimStart();
|
|
139478
|
+
if (trimmedStart.startsWith("```")) {
|
|
139479
|
+
inFence = !inFence;
|
|
139480
|
+
continue;
|
|
139481
|
+
}
|
|
139482
|
+
if (!inFence) {
|
|
139483
|
+
lines.push(rawLine);
|
|
139484
|
+
}
|
|
139485
|
+
}
|
|
139486
|
+
return lines.join(`
|
|
139487
|
+
`);
|
|
139488
|
+
}
|
|
139489
|
+
|
|
139490
|
+
class UnknownFormatFamilyError extends Error {
|
|
139491
|
+
constructor() {
|
|
139492
|
+
super("Unknown format family: neither impact_context nor invariant_violated present");
|
|
139493
|
+
this.name = "UnknownFormatFamilyError";
|
|
139494
|
+
}
|
|
139495
|
+
}
|
|
139496
|
+
function detectFormatFamily(headerFields) {
|
|
139497
|
+
const trimmed = headerFields.map((f) => f.trim());
|
|
139498
|
+
const hasImpactContext = trimmed.includes(BASE_EXPLORER_DISCRIMINATOR);
|
|
139499
|
+
const hasInvariantViolated = trimmed.includes(MICRO_LANE_DISCRIMINATOR);
|
|
139500
|
+
if (hasImpactContext) {
|
|
139501
|
+
return "base_explorer";
|
|
139502
|
+
}
|
|
139503
|
+
if (hasInvariantViolated) {
|
|
139504
|
+
return "micro_lane";
|
|
139505
|
+
}
|
|
139506
|
+
throw new UnknownFormatFamilyError;
|
|
139507
|
+
}
|
|
139508
|
+
function detectRowFormatFamily(rowFields) {
|
|
139509
|
+
const trimmed = rowFields.map((f) => f.trim());
|
|
139510
|
+
const hasImpactContext = trimmed.length > 7 && trimmed[7] !== "";
|
|
139511
|
+
const hasInvariantViolated = trimmed.length > 6 && trimmed[6] !== "";
|
|
139512
|
+
if (hasImpactContext && !hasInvariantViolated)
|
|
139513
|
+
return "base_explorer";
|
|
139514
|
+
if (hasInvariantViolated && !hasImpactContext)
|
|
139515
|
+
return "micro_lane";
|
|
139516
|
+
if (hasImpactContext && hasInvariantViolated)
|
|
139517
|
+
return "base_explorer";
|
|
139518
|
+
throw new UnknownFormatFamilyError;
|
|
139519
|
+
}
|
|
139520
|
+
function mapFields(fields, family) {
|
|
139521
|
+
const trimmed = fields.map((f) => f.trim());
|
|
139522
|
+
const names = family === "base_explorer" ? BASE_EXPLORER_FIELDS : MICRO_LANE_FIELDS;
|
|
139523
|
+
const result = {};
|
|
139524
|
+
for (let i2 = 0;i2 < names.length; i2++) {
|
|
139525
|
+
result[names[i2]] = i2 < trimmed.length && trimmed[i2] !== "" ? trimmed[i2] : null;
|
|
139526
|
+
}
|
|
139527
|
+
if (family === "base_explorer") {
|
|
139528
|
+
result.micro_lane = null;
|
|
139529
|
+
result.invariant_violated = null;
|
|
139530
|
+
} else {
|
|
139531
|
+
result.lane = null;
|
|
139532
|
+
result.impact_context = null;
|
|
139533
|
+
}
|
|
139534
|
+
return result;
|
|
139535
|
+
}
|
|
139536
|
+
function getRequiredFields(family) {
|
|
139537
|
+
return family === "base_explorer" ? BASE_EXPLORER_FIELDS : MICRO_LANE_FIELDS;
|
|
139538
|
+
}
|
|
139539
|
+
function assertNonNullCandidateId(value) {
|
|
139540
|
+
if (value === null || value === "") {
|
|
139541
|
+
throw new Error("Invariant violation: null/empty candidate_id reached candidate builder");
|
|
139542
|
+
}
|
|
139543
|
+
}
|
|
139544
|
+
function buildInvocationEnvelope(input, flags2, formatFamiliesDetected, candidateCount, parseErrors, malformedRows) {
|
|
139545
|
+
return {
|
|
139546
|
+
record_type: "invocation",
|
|
139547
|
+
source_output_ref: input.output_ref,
|
|
139548
|
+
source_batch_id: input.batchId,
|
|
139549
|
+
source_lane_id: input.laneId,
|
|
139550
|
+
source_agent: input.agent,
|
|
139551
|
+
source_digest: input.digest,
|
|
139552
|
+
row_format_version: flags2.row_format_version,
|
|
139553
|
+
sessionId: input.sessionId,
|
|
139554
|
+
parentSessionId: input.parentSessionId,
|
|
139555
|
+
...flags2.producer ? { producer: flags2.producer } : {},
|
|
139556
|
+
produced_at: input.produced_at,
|
|
139557
|
+
record_version: RECORD_VERSION,
|
|
139558
|
+
format_families_detected: formatFamiliesDetected,
|
|
139559
|
+
candidate_count: candidateCount,
|
|
139560
|
+
parse_errors: parseErrors,
|
|
139561
|
+
malformed_rows: malformedRows
|
|
139562
|
+
};
|
|
139563
|
+
}
|
|
139564
|
+
function buildEmptyDiagnostics(input, flags2) {
|
|
139565
|
+
return {
|
|
139566
|
+
candidate_count: 0,
|
|
139567
|
+
parse_errors: 0,
|
|
139568
|
+
parse_error_details: [],
|
|
139569
|
+
malformed_rows: 0,
|
|
139570
|
+
duplicate_id_count: 0,
|
|
139571
|
+
duplicate_id_warnings: [],
|
|
139572
|
+
degraded_source_count: flags2.degraded ? 1 : 0,
|
|
139573
|
+
incomplete_source_count: input.transcriptIncomplete ? 1 : 0,
|
|
139574
|
+
format_families_detected: []
|
|
139575
|
+
};
|
|
139576
|
+
}
|
|
139577
|
+
function refusalResult(errorCode, errorMessage3, input, flags2) {
|
|
139578
|
+
const envelope = buildInvocationEnvelope(input, flags2, [], 0, 0, 0);
|
|
139579
|
+
return {
|
|
139580
|
+
error: errorMessage3,
|
|
139581
|
+
error_code: errorCode,
|
|
139582
|
+
candidates: [],
|
|
139583
|
+
invocation_envelope: envelope,
|
|
139584
|
+
diagnostics: buildEmptyDiagnostics(input, flags2)
|
|
139585
|
+
};
|
|
139586
|
+
}
|
|
139587
|
+
function emptyTextResult(input, flags2) {
|
|
139588
|
+
const envelope = buildInvocationEnvelope(input, flags2, [], 0, 0, 0);
|
|
139589
|
+
return {
|
|
139590
|
+
candidates: [],
|
|
139591
|
+
invocation_envelope: envelope,
|
|
139592
|
+
diagnostics: buildEmptyDiagnostics(input, flags2)
|
|
139593
|
+
};
|
|
139594
|
+
}
|
|
139595
|
+
function parseCandidates(input, flags2) {
|
|
139596
|
+
const inputParse = ArtifactInputSchema.safeParse(input);
|
|
139597
|
+
if (!inputParse.success) {
|
|
139598
|
+
throw new Error(`Invalid ArtifactInput: ${inputParse.error.issues.map((issue3) => issue3.message).join(", ")}`);
|
|
139599
|
+
}
|
|
139600
|
+
const flagsParse = ParseFlagsSchema.safeParse(flags2);
|
|
139601
|
+
if (!flagsParse.success) {
|
|
139602
|
+
throw new Error(`Invalid ParseFlags: ${flagsParse.error.issues.map((issue3) => issue3.message).join(", ")}`);
|
|
139603
|
+
}
|
|
139604
|
+
const validatedInput = inputParse.data;
|
|
139605
|
+
const validatedFlags = flagsParse.data;
|
|
139606
|
+
if (validatedInput.artifact_status === "ref-not-found") {
|
|
139607
|
+
return refusalResult("ref-not-found", "Artifact reference not found in store", validatedInput, validatedFlags);
|
|
139608
|
+
}
|
|
139609
|
+
if (validatedInput.artifact_status === "artifact-corrupted") {
|
|
139610
|
+
return refusalResult("artifact-corrupted", "Artifact data is corrupted", validatedInput, validatedFlags);
|
|
139611
|
+
}
|
|
139612
|
+
if (validatedFlags.degraded && !validatedFlags.accept_degraded) {
|
|
139613
|
+
return refusalResult("degraded-source-refused", "Degraded source refused by caller", validatedInput, validatedFlags);
|
|
139614
|
+
}
|
|
139615
|
+
if (validatedInput.transcriptIncomplete === true && !validatedFlags.accept_partial) {
|
|
139616
|
+
return refusalResult("partial-source-refused", "Partial transcript refused by caller", validatedInput, validatedFlags);
|
|
139617
|
+
}
|
|
139618
|
+
if (validatedInput.text.trim() === "") {
|
|
139619
|
+
return emptyTextResult(validatedInput, validatedFlags);
|
|
139620
|
+
}
|
|
139621
|
+
return parseText(validatedInput, validatedFlags);
|
|
139622
|
+
}
|
|
139623
|
+
function parseText(input, flags2) {
|
|
139624
|
+
const cleanedText = removeCodeFences(input.text);
|
|
139625
|
+
const lines = cleanedText.split(`
|
|
139626
|
+
`);
|
|
139627
|
+
let headerIndex = -1;
|
|
139628
|
+
let headerFields = [];
|
|
139629
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
139630
|
+
const trimmed = lines[i2].trim();
|
|
139631
|
+
if (trimmed === "")
|
|
139632
|
+
continue;
|
|
139633
|
+
const fields = splitRow(trimmed);
|
|
139634
|
+
if (fields.length >= 2 && fields.some((f) => f.trim() !== "")) {
|
|
139635
|
+
headerIndex = i2;
|
|
139636
|
+
headerFields = fields.map((f) => f.trim());
|
|
139637
|
+
break;
|
|
139638
|
+
}
|
|
139639
|
+
}
|
|
139640
|
+
if (headerIndex === -1) {
|
|
139641
|
+
return emptyTextResult(input, flags2);
|
|
139642
|
+
}
|
|
139643
|
+
let headerFamily;
|
|
139644
|
+
try {
|
|
139645
|
+
headerFamily = detectFormatFamily(headerFields);
|
|
139646
|
+
} catch (e) {
|
|
139647
|
+
if (e instanceof UnknownFormatFamilyError) {} else {
|
|
139648
|
+
throw e;
|
|
139649
|
+
}
|
|
139650
|
+
}
|
|
139651
|
+
const bothDiscriminators = headerFields.includes(BASE_EXPLORER_DISCRIMINATOR) && headerFields.includes(MICRO_LANE_DISCRIMINATOR);
|
|
139652
|
+
const parseErrorDetails = [];
|
|
139653
|
+
if (bothDiscriminators && headerFamily === "base_explorer") {
|
|
139654
|
+
parseErrorDetails.push({
|
|
139655
|
+
row_index: headerIndex,
|
|
139656
|
+
field: "header",
|
|
139657
|
+
message: "Both format-family discriminators present; defaulting to base_explorer"
|
|
139658
|
+
});
|
|
139659
|
+
}
|
|
139660
|
+
const candidates = [];
|
|
139661
|
+
const idCounts = new Map;
|
|
139662
|
+
const idFirstRows = new Map;
|
|
139663
|
+
const formatFamiliesDetected = new Set;
|
|
139664
|
+
let malformedRows = 0;
|
|
139665
|
+
let currentCandidate = null;
|
|
139666
|
+
for (let i2 = headerIndex + 1;i2 < lines.length; i2++) {
|
|
139667
|
+
const rawLine = lines[i2];
|
|
139668
|
+
const trimmed = rawLine.trim();
|
|
139669
|
+
if (trimmed === "")
|
|
139670
|
+
continue;
|
|
139671
|
+
const fields = splitRow(trimmed);
|
|
139672
|
+
if (fields.length < EXPECTED_FIELD_COUNT) {
|
|
139673
|
+
if (currentCandidate) {
|
|
139674
|
+
const prev = currentCandidate.evidence_summary ?? "";
|
|
139675
|
+
currentCandidate.evidence_summary = `${prev}
|
|
139676
|
+
${trimmed}`;
|
|
139677
|
+
} else {
|
|
139678
|
+
malformedRows++;
|
|
139679
|
+
}
|
|
139680
|
+
continue;
|
|
139681
|
+
}
|
|
139682
|
+
const rowFields = fields.slice(0, EXPECTED_FIELD_COUNT);
|
|
139683
|
+
let rowFamily;
|
|
139684
|
+
try {
|
|
139685
|
+
rowFamily = detectRowFormatFamily(rowFields);
|
|
139686
|
+
} catch (e) {
|
|
139687
|
+
if (e instanceof UnknownFormatFamilyError) {
|
|
139688
|
+
malformedRows++;
|
|
139689
|
+
continue;
|
|
139690
|
+
}
|
|
139691
|
+
throw e;
|
|
139692
|
+
}
|
|
139693
|
+
const rowHasImpact = rowFields[7].trim() !== "";
|
|
139694
|
+
const rowHasInvariant = rowFields[6].trim() !== "";
|
|
139695
|
+
if (rowHasImpact && rowHasInvariant && rowFamily === "base_explorer") {
|
|
139696
|
+
parseErrorDetails.push({
|
|
139697
|
+
row_index: i2,
|
|
139698
|
+
field: "row",
|
|
139699
|
+
message: "Both format-family discriminators present; defaulting to base_explorer"
|
|
139700
|
+
});
|
|
139701
|
+
}
|
|
139702
|
+
const mapped = mapFields(rowFields, rowFamily);
|
|
139703
|
+
const requiredFields = rowFamily === "base_explorer" ? getRequiredFields("base_explorer") : getRequiredFields("micro_lane");
|
|
139704
|
+
let rowMalformed = false;
|
|
139705
|
+
for (const field of requiredFields) {
|
|
139706
|
+
const value = mapped[field];
|
|
139707
|
+
if (field === "candidate_id") {
|
|
139708
|
+
if (value === null || value === "") {
|
|
139709
|
+
rowMalformed = true;
|
|
139710
|
+
break;
|
|
139711
|
+
}
|
|
139712
|
+
} else if (value === null) {
|
|
139713
|
+
parseErrorDetails.push({
|
|
139714
|
+
row_index: i2,
|
|
139715
|
+
field,
|
|
139716
|
+
message: `Missing required field: ${field}`
|
|
139717
|
+
});
|
|
139718
|
+
}
|
|
139719
|
+
}
|
|
139720
|
+
if (rowMalformed) {
|
|
139721
|
+
malformedRows++;
|
|
139722
|
+
continue;
|
|
139723
|
+
}
|
|
139724
|
+
assertNonNullCandidateId(mapped.candidate_id);
|
|
139725
|
+
const candidateId = mapped.candidate_id;
|
|
139726
|
+
const candidate = {
|
|
139727
|
+
record_type: "candidate",
|
|
139728
|
+
row_format_family: rowFamily,
|
|
139729
|
+
row_format_version: flags2.row_format_version,
|
|
139730
|
+
record_version: RECORD_VERSION,
|
|
139731
|
+
source_output_ref: input.output_ref,
|
|
139732
|
+
source_batch_id: input.batchId,
|
|
139733
|
+
source_lane_id: input.laneId,
|
|
139734
|
+
source_agent: input.agent,
|
|
139735
|
+
source_digest: input.digest,
|
|
139736
|
+
sessionId: input.sessionId,
|
|
139737
|
+
parentSessionId: input.parentSessionId,
|
|
139738
|
+
producer: flags2.producer,
|
|
139739
|
+
extracted_from_partial_source: !!(input.transcriptIncomplete || flags2.degraded),
|
|
139740
|
+
candidate_id: candidateId,
|
|
139741
|
+
lane: mapped.lane,
|
|
139742
|
+
micro_lane: mapped.micro_lane,
|
|
139743
|
+
severity: mapped.severity,
|
|
139744
|
+
category: mapped.category,
|
|
139745
|
+
file_line: mapped.file_line,
|
|
139746
|
+
claim: mapped.claim,
|
|
139747
|
+
evidence_summary: mapped.evidence_summary,
|
|
139748
|
+
impact_context: mapped.impact_context,
|
|
139749
|
+
invariant_violated: mapped.invariant_violated,
|
|
139750
|
+
confidence: mapped.confidence
|
|
139751
|
+
};
|
|
139752
|
+
const cid = candidate.candidate_id;
|
|
139753
|
+
idCounts.set(cid, (idCounts.get(cid) ?? 0) + 1);
|
|
139754
|
+
if (!idFirstRows.has(cid)) {
|
|
139755
|
+
idFirstRows.set(cid, i2);
|
|
139756
|
+
}
|
|
139757
|
+
formatFamiliesDetected.add(rowFamily);
|
|
139758
|
+
candidates.push(candidate);
|
|
139759
|
+
currentCandidate = candidate;
|
|
139760
|
+
}
|
|
139761
|
+
const duplicateIdWarnings = [];
|
|
139762
|
+
let duplicateIdCount = 0;
|
|
139763
|
+
for (const [id, count] of idCounts) {
|
|
139764
|
+
if (count > 1) {
|
|
139765
|
+
duplicateIdCount++;
|
|
139766
|
+
duplicateIdWarnings.push({
|
|
139767
|
+
candidate_id: id,
|
|
139768
|
+
occurrences: count
|
|
139769
|
+
});
|
|
139770
|
+
parseErrorDetails.push({
|
|
139771
|
+
row_index: idFirstRows.get(id) ?? -1,
|
|
139772
|
+
field: "candidate_id",
|
|
139773
|
+
message: `Duplicate candidate_id: "${id}" appears ${count} times`
|
|
139774
|
+
});
|
|
139775
|
+
}
|
|
139776
|
+
}
|
|
139777
|
+
const parseErrors = parseErrorDetails.length;
|
|
139778
|
+
const envelope = buildInvocationEnvelope(input, flags2, Array.from(formatFamiliesDetected), candidates.length, parseErrors, malformedRows);
|
|
139779
|
+
return {
|
|
139780
|
+
candidates,
|
|
139781
|
+
invocation_envelope: envelope,
|
|
139782
|
+
diagnostics: {
|
|
139783
|
+
candidate_count: candidates.length,
|
|
139784
|
+
parse_errors: parseErrors,
|
|
139785
|
+
parse_error_details: parseErrorDetails,
|
|
139786
|
+
malformed_rows: malformedRows,
|
|
139787
|
+
duplicate_id_count: duplicateIdCount,
|
|
139788
|
+
duplicate_id_warnings: duplicateIdWarnings,
|
|
139789
|
+
degraded_source_count: flags2.degraded ? 1 : 0,
|
|
139790
|
+
incomplete_source_count: input.transcriptIncomplete ? 1 : 0,
|
|
139791
|
+
format_families_detected: Array.from(formatFamiliesDetected)
|
|
139792
|
+
}
|
|
139793
|
+
};
|
|
139794
|
+
}
|
|
139795
|
+
function parseAndPersist(input, flags2, options) {
|
|
139796
|
+
const result = parseCandidates(input, flags2);
|
|
139797
|
+
try {
|
|
139798
|
+
appendToSidecar(options, input.batchId, result.invocation_envelope, result.candidates);
|
|
139799
|
+
} catch (error93) {
|
|
139800
|
+
const message = error93 instanceof Error ? error93.message : String(error93);
|
|
139801
|
+
return {
|
|
139802
|
+
...result,
|
|
139803
|
+
sidecar_write_error: message
|
|
139804
|
+
};
|
|
139805
|
+
}
|
|
139806
|
+
return result;
|
|
139807
|
+
}
|
|
139808
|
+
|
|
139809
|
+
// src/tools/parse-lane-candidates.ts
|
|
139810
|
+
init_utils2();
|
|
139811
|
+
init_create_tool();
|
|
139812
|
+
var ParseLaneCandidatesArgsSchema = exports_external.object({
|
|
139813
|
+
output_ref: exports_external.string().min(1).describe("Opaque lane output ref returned as output_ref by dispatch_lanes or collect_lane_results."),
|
|
139814
|
+
accept_partial: exports_external.boolean().default(false).describe("Accept sources where transcriptIncomplete is true (partial transcripts)."),
|
|
139815
|
+
accept_degraded: exports_external.boolean().default(false).describe("Accept sources where the artifact storage was degraded (output_degraded)."),
|
|
139816
|
+
degraded: exports_external.boolean().default(false).describe("Passed through from DispatchLaneResult.output_degraded by the orchestrator."),
|
|
139817
|
+
row_format_version: exports_external.number().int().nonnegative().default(1).describe("Row format version; currently only version 1 is supported."),
|
|
139818
|
+
producer: exports_external.string().optional().default("swarm-pr-review").describe("Producer label for cross-skill filtering in the sidecar."),
|
|
139819
|
+
use_lockfile: exports_external.boolean().default(false).describe("When true, use proper-lockfile for concurrency-safe sidecar writes."),
|
|
139820
|
+
project_root: exports_external.string().optional().describe("Project root directory where .swarm/ lives. Defaults to the injected working directory.")
|
|
139821
|
+
}).strict();
|
|
139822
|
+
var REF_RE2 = /^L1:[a-f0-9]{64}:[a-f0-9]{64}:[a-f0-9]{64}$/;
|
|
139823
|
+
function laneOutputRelativePath2(ref) {
|
|
139824
|
+
const parts2 = ref.split(":");
|
|
139825
|
+
if (parts2.length !== 4)
|
|
139826
|
+
return "";
|
|
139827
|
+
const [, batchDigest, laneDigest, outputDigest] = parts2;
|
|
139828
|
+
return path172.join("lane-results", batchDigest, laneDigest, `${outputDigest}.json`);
|
|
139829
|
+
}
|
|
139830
|
+
var parse_lane_candidates = createSwarmTool({
|
|
139831
|
+
description: "Parse [CANDIDATE] rows from a dispatch_lanes or collect_lane_results artifact (by output_ref), produce structured records with provenance, optionally persist to a per-batch sidecar JSONL. Pure-parser variant exists as internal module.",
|
|
139832
|
+
args: {
|
|
139833
|
+
output_ref: ParseLaneCandidatesArgsSchema.shape.output_ref,
|
|
139834
|
+
accept_partial: ParseLaneCandidatesArgsSchema.shape.accept_partial,
|
|
139835
|
+
accept_degraded: ParseLaneCandidatesArgsSchema.shape.accept_degraded,
|
|
139836
|
+
degraded: ParseLaneCandidatesArgsSchema.shape.degraded,
|
|
139837
|
+
row_format_version: ParseLaneCandidatesArgsSchema.shape.row_format_version,
|
|
139838
|
+
producer: ParseLaneCandidatesArgsSchema.shape.producer,
|
|
139839
|
+
use_lockfile: ParseLaneCandidatesArgsSchema.shape.use_lockfile,
|
|
139840
|
+
project_root: ParseLaneCandidatesArgsSchema.shape.project_root
|
|
139841
|
+
},
|
|
139842
|
+
async execute(args2, directory) {
|
|
139843
|
+
const parsed = ParseLaneCandidatesArgsSchema.safeParse(args2);
|
|
139844
|
+
if (!parsed.success) {
|
|
139845
|
+
return JSON.stringify({
|
|
139846
|
+
success: false,
|
|
139847
|
+
failure_class: "invalid_args",
|
|
139848
|
+
message: "Invalid parse_lane_candidates arguments",
|
|
139849
|
+
errors: parsed.error.issues.map((issue3) => `${issue3.path.join(".")}: ${issue3.message}`)
|
|
139850
|
+
}, null, 2);
|
|
139851
|
+
}
|
|
139852
|
+
const {
|
|
139853
|
+
output_ref,
|
|
139854
|
+
accept_partial,
|
|
139855
|
+
accept_degraded,
|
|
139856
|
+
degraded,
|
|
139857
|
+
row_format_version,
|
|
139858
|
+
producer,
|
|
139859
|
+
use_lockfile,
|
|
139860
|
+
project_root
|
|
139861
|
+
} = parsed.data;
|
|
139862
|
+
if (project_root !== undefined) {
|
|
139863
|
+
const absRoot = path172.resolve(project_root);
|
|
139864
|
+
const absDir = path172.resolve(directory);
|
|
139865
|
+
const rel = path172.relative(absDir, absRoot);
|
|
139866
|
+
if (rel === ".." || rel.startsWith(`..${path172.sep}`) || path172.isAbsolute(rel)) {
|
|
139867
|
+
return JSON.stringify({
|
|
139868
|
+
success: false,
|
|
139869
|
+
failure_class: "invalid_args",
|
|
139870
|
+
message: "project_root must resolve within the injected working directory",
|
|
139871
|
+
errors: [
|
|
139872
|
+
`project_root: ${project_root} is outside the project root ${directory}`
|
|
139873
|
+
]
|
|
139874
|
+
}, null, 2);
|
|
139875
|
+
}
|
|
139876
|
+
}
|
|
139877
|
+
let loaded;
|
|
139878
|
+
try {
|
|
139879
|
+
loaded = readLaneOutput(directory, output_ref);
|
|
139880
|
+
} catch {
|
|
139881
|
+
loaded = null;
|
|
139882
|
+
}
|
|
139883
|
+
if (!loaded) {
|
|
139884
|
+
const relPath = REF_RE2.test(output_ref) ? laneOutputRelativePath2(output_ref) : "";
|
|
139885
|
+
const absPath = relPath ? validateSwarmPath(directory, relPath) : "";
|
|
139886
|
+
const fileExists = absPath ? existsSync100(absPath) : false;
|
|
139887
|
+
const artifactStatus = fileExists ? "artifact-corrupted" : "ref-not-found";
|
|
139888
|
+
const refParts = output_ref.split(":");
|
|
139889
|
+
const hasValidRef = REF_RE2.test(output_ref) && refParts.length === 4;
|
|
139890
|
+
const syntheticBatchId = hasValidRef ? refParts[1] : "unknown";
|
|
139891
|
+
const syntheticLaneId = hasValidRef ? refParts[2] : "unknown";
|
|
139892
|
+
const syntheticDigest = "0".repeat(64);
|
|
139893
|
+
const artifactInput2 = {
|
|
139894
|
+
output_ref,
|
|
139895
|
+
batchId: syntheticBatchId,
|
|
139896
|
+
laneId: syntheticLaneId,
|
|
139897
|
+
agent: "unknown",
|
|
139898
|
+
role: "unknown",
|
|
139899
|
+
digest: syntheticDigest,
|
|
139900
|
+
text: "",
|
|
139901
|
+
artifact_status: artifactStatus,
|
|
139902
|
+
source: "dispatch_lanes",
|
|
139903
|
+
produced_at: new Date().toISOString()
|
|
139904
|
+
};
|
|
139905
|
+
const flags3 = {
|
|
139906
|
+
accept_partial,
|
|
139907
|
+
accept_degraded,
|
|
139908
|
+
degraded,
|
|
139909
|
+
row_format_version,
|
|
139910
|
+
...producer ? { producer } : {}
|
|
139911
|
+
};
|
|
139912
|
+
const options2 = {
|
|
139913
|
+
projectRoot: project_root ?? directory,
|
|
139914
|
+
useLockfile: use_lockfile,
|
|
139915
|
+
batchDigest: syntheticBatchId
|
|
139916
|
+
};
|
|
139917
|
+
const result2 = parseAndPersist(artifactInput2, flags3, options2);
|
|
139918
|
+
return JSON.stringify(result2, null, 2);
|
|
139919
|
+
}
|
|
139920
|
+
const artifact = loaded.artifact;
|
|
139921
|
+
const artifactInput = {
|
|
139922
|
+
output_ref: artifact.ref,
|
|
139923
|
+
batchId: artifact.batchId,
|
|
139924
|
+
laneId: artifact.laneId,
|
|
139925
|
+
agent: artifact.agent,
|
|
139926
|
+
role: artifact.role,
|
|
139927
|
+
...artifact.sessionId !== undefined ? { sessionId: artifact.sessionId } : {},
|
|
139928
|
+
...artifact.parentSessionId !== undefined ? { parentSessionId: artifact.parentSessionId } : {},
|
|
139929
|
+
digest: artifact.digest,
|
|
139930
|
+
text: artifact.text,
|
|
139931
|
+
transcriptIncomplete: artifact.transcriptIncomplete,
|
|
139932
|
+
artifact_status: "ok",
|
|
139933
|
+
source: artifact.source,
|
|
139934
|
+
produced_at: artifact.createdAt ?? artifact.updatedAt
|
|
139935
|
+
};
|
|
139936
|
+
const flags2 = {
|
|
139937
|
+
accept_partial,
|
|
139938
|
+
accept_degraded,
|
|
139939
|
+
degraded,
|
|
139940
|
+
row_format_version,
|
|
139941
|
+
...producer ? { producer } : {}
|
|
139942
|
+
};
|
|
139943
|
+
const options = {
|
|
139944
|
+
projectRoot: project_root ?? directory,
|
|
139945
|
+
useLockfile: use_lockfile
|
|
139946
|
+
};
|
|
139947
|
+
const result = parseAndPersist(artifactInput, flags2, options);
|
|
139948
|
+
return JSON.stringify(result, null, 2);
|
|
139949
|
+
}
|
|
139950
|
+
});
|
|
139951
|
+
|
|
139182
139952
|
// src/tools/phase-complete.ts
|
|
139183
139953
|
init_zod();
|
|
139184
139954
|
init_config();
|
|
@@ -139186,22 +139956,22 @@ init_schema();
|
|
|
139186
139956
|
init_manager2();
|
|
139187
139957
|
init_task_file();
|
|
139188
139958
|
import * as fs119 from "node:fs";
|
|
139189
|
-
import * as
|
|
139959
|
+
import * as path182 from "node:path";
|
|
139190
139960
|
|
|
139191
139961
|
// src/full-auto/phase-approval.ts
|
|
139192
139962
|
init_utils2();
|
|
139193
139963
|
init_logger();
|
|
139194
139964
|
init_state3();
|
|
139195
139965
|
import * as fs110 from "node:fs";
|
|
139196
|
-
import * as
|
|
139966
|
+
import * as path173 from "node:path";
|
|
139197
139967
|
var APPROVAL_TTL_MS = 24 * 60 * 60 * 1000;
|
|
139198
139968
|
function readEvidenceDir(directory, phase) {
|
|
139199
139969
|
try {
|
|
139200
|
-
const dirPath = validateSwarmPath(directory,
|
|
139970
|
+
const dirPath = validateSwarmPath(directory, path173.posix.join("evidence", String(phase)));
|
|
139201
139971
|
if (!fs110.existsSync(dirPath))
|
|
139202
139972
|
return [];
|
|
139203
139973
|
const entries = fs110.readdirSync(dirPath);
|
|
139204
|
-
return entries.filter((e) => e.startsWith("full-auto-") && e.endsWith(".json")).map((e) =>
|
|
139974
|
+
return entries.filter((e) => e.startsWith("full-auto-") && e.endsWith(".json")).map((e) => path173.join(dirPath, e));
|
|
139205
139975
|
} catch {
|
|
139206
139976
|
return [];
|
|
139207
139977
|
}
|
|
@@ -139456,16 +140226,16 @@ init_plan_schema();
|
|
|
139456
140226
|
init_ledger();
|
|
139457
140227
|
init_manager();
|
|
139458
140228
|
import * as fs111 from "node:fs";
|
|
139459
|
-
import * as
|
|
140229
|
+
import * as path174 from "node:path";
|
|
139460
140230
|
async function writeCheckpoint(directory) {
|
|
139461
140231
|
try {
|
|
139462
140232
|
const plan = await loadPlan(directory);
|
|
139463
140233
|
if (!plan)
|
|
139464
140234
|
return;
|
|
139465
|
-
const swarmDir =
|
|
140235
|
+
const swarmDir = path174.join(directory, ".swarm");
|
|
139466
140236
|
fs111.mkdirSync(swarmDir, { recursive: true });
|
|
139467
|
-
const jsonPath =
|
|
139468
|
-
const mdPath =
|
|
140237
|
+
const jsonPath = path174.join(swarmDir, "SWARM_PLAN.json");
|
|
140238
|
+
const mdPath = path174.join(swarmDir, "SWARM_PLAN.md");
|
|
139469
140239
|
fs111.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
|
|
139470
140240
|
const md = derivePlanMarkdown(plan);
|
|
139471
140241
|
fs111.writeFileSync(mdPath, md, "utf8");
|
|
@@ -139486,7 +140256,7 @@ init_state();
|
|
|
139486
140256
|
// src/turbo/lean/phase-ready.ts
|
|
139487
140257
|
init_file_locks();
|
|
139488
140258
|
import * as fs112 from "node:fs";
|
|
139489
|
-
import * as
|
|
140259
|
+
import * as path175 from "node:path";
|
|
139490
140260
|
init_state4();
|
|
139491
140261
|
var DEFAULT_CONFIG3 = {
|
|
139492
140262
|
phase_reviewer: true,
|
|
@@ -139495,7 +140265,7 @@ var DEFAULT_CONFIG3 = {
|
|
|
139495
140265
|
};
|
|
139496
140266
|
function defaultReadPlanJson(dir) {
|
|
139497
140267
|
try {
|
|
139498
|
-
const planPath =
|
|
140268
|
+
const planPath = path175.join(dir, ".swarm", "plan.json");
|
|
139499
140269
|
if (!fs112.existsSync(planPath))
|
|
139500
140270
|
return null;
|
|
139501
140271
|
const raw = fs112.readFileSync(planPath, "utf-8");
|
|
@@ -139510,7 +140280,7 @@ function defaultReadPlanJson(dir) {
|
|
|
139510
140280
|
}
|
|
139511
140281
|
function readReviewerEvidenceFromFile(directory, phase) {
|
|
139512
140282
|
try {
|
|
139513
|
-
const evidencePath =
|
|
140283
|
+
const evidencePath = path175.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-reviewer.json");
|
|
139514
140284
|
if (!fs112.existsSync(evidencePath)) {
|
|
139515
140285
|
return null;
|
|
139516
140286
|
}
|
|
@@ -139530,7 +140300,7 @@ function readReviewerEvidenceFromFile(directory, phase) {
|
|
|
139530
140300
|
}
|
|
139531
140301
|
function readCriticEvidenceFromFile(directory, phase) {
|
|
139532
140302
|
try {
|
|
139533
|
-
const evidencePath =
|
|
140303
|
+
const evidencePath = path175.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-critic.json");
|
|
139534
140304
|
if (!fs112.existsSync(evidencePath)) {
|
|
139535
140305
|
return null;
|
|
139536
140306
|
}
|
|
@@ -139549,7 +140319,7 @@ function readCriticEvidenceFromFile(directory, phase) {
|
|
|
139549
140319
|
}
|
|
139550
140320
|
}
|
|
139551
140321
|
function listLaneEvidenceSync(directory, phase) {
|
|
139552
|
-
const evidenceDir =
|
|
140322
|
+
const evidenceDir = path175.join(directory, ".swarm", "evidence", String(phase), "lean-turbo");
|
|
139553
140323
|
let entries;
|
|
139554
140324
|
try {
|
|
139555
140325
|
entries = fs112.readdirSync(evidenceDir);
|
|
@@ -139619,7 +140389,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
139619
140389
|
...DEFAULT_CONFIG3,
|
|
139620
140390
|
...actualConfig
|
|
139621
140391
|
};
|
|
139622
|
-
const statePath =
|
|
140392
|
+
const statePath = path175.join(directory, ".swarm", "turbo-state.json");
|
|
139623
140393
|
if (!fs112.existsSync(statePath)) {
|
|
139624
140394
|
return {
|
|
139625
140395
|
ok: false,
|
|
@@ -139807,7 +140577,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
139807
140577
|
}
|
|
139808
140578
|
}
|
|
139809
140579
|
if (mergedConfig.integrated_diff_required) {
|
|
139810
|
-
const evidencePath =
|
|
140580
|
+
const evidencePath = path175.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-phase.json");
|
|
139811
140581
|
let hasDiff = false;
|
|
139812
140582
|
try {
|
|
139813
140583
|
const content = fs112.readFileSync(evidencePath, "utf-8");
|
|
@@ -139973,7 +140743,7 @@ async function runCompletionVerifyGate(ctx) {
|
|
|
139973
140743
|
// src/tools/phase-complete/gates/drift-gate.ts
|
|
139974
140744
|
init_effective_spec();
|
|
139975
140745
|
import * as fs113 from "node:fs";
|
|
139976
|
-
import * as
|
|
140746
|
+
import * as path176 from "node:path";
|
|
139977
140747
|
|
|
139978
140748
|
// src/tools/phase-complete/gates/gate-helpers.ts
|
|
139979
140749
|
init_qa_gate_profile();
|
|
@@ -140022,7 +140792,7 @@ async function runDriftGate(ctx) {
|
|
|
140022
140792
|
}
|
|
140023
140793
|
let phaseType;
|
|
140024
140794
|
try {
|
|
140025
|
-
const planPath =
|
|
140795
|
+
const planPath = path176.join(dir, ".swarm", "plan.json");
|
|
140026
140796
|
if (fs113.existsSync(planPath)) {
|
|
140027
140797
|
const planRaw = fs113.readFileSync(planPath, "utf-8");
|
|
140028
140798
|
const plan = JSON.parse(planRaw);
|
|
@@ -140041,7 +140811,7 @@ async function runDriftGate(ctx) {
|
|
|
140041
140811
|
};
|
|
140042
140812
|
}
|
|
140043
140813
|
try {
|
|
140044
|
-
const driftEvidencePath =
|
|
140814
|
+
const driftEvidencePath = path176.join(dir, ".swarm", "evidence", String(phase), "drift-verifier.json");
|
|
140045
140815
|
let driftVerdictFound = false;
|
|
140046
140816
|
let driftVerdictApproved = false;
|
|
140047
140817
|
try {
|
|
@@ -140082,7 +140852,7 @@ async function runDriftGate(ctx) {
|
|
|
140082
140852
|
let incompleteTaskCount = 0;
|
|
140083
140853
|
let planParseable = false;
|
|
140084
140854
|
try {
|
|
140085
|
-
const planPath =
|
|
140855
|
+
const planPath = path176.join(dir, ".swarm", "plan.json");
|
|
140086
140856
|
if (fs113.existsSync(planPath)) {
|
|
140087
140857
|
const planRaw = fs113.readFileSync(planPath, "utf-8");
|
|
140088
140858
|
const plan = JSON.parse(planRaw);
|
|
@@ -140161,7 +140931,7 @@ async function runDriftGate(ctx) {
|
|
|
140161
140931
|
}
|
|
140162
140932
|
// src/tools/phase-complete/gates/final-council-gate.ts
|
|
140163
140933
|
import * as fs114 from "node:fs";
|
|
140164
|
-
import * as
|
|
140934
|
+
import * as path177 from "node:path";
|
|
140165
140935
|
async function runFinalCouncilGate(ctx) {
|
|
140166
140936
|
const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
|
|
140167
140937
|
let finalCouncilEnabled = false;
|
|
@@ -140184,7 +140954,7 @@ async function runFinalCouncilGate(ctx) {
|
|
|
140184
140954
|
if (lastPhaseId !== undefined && phase === lastPhaseId) {
|
|
140185
140955
|
if (preamble.effectiveGates?.final_council === true) {
|
|
140186
140956
|
finalCouncilEnabled = true;
|
|
140187
|
-
const fcPath =
|
|
140957
|
+
const fcPath = path177.join(dir, ".swarm", "evidence", "final-council.json");
|
|
140188
140958
|
let fcVerdictFound = false;
|
|
140189
140959
|
let _fcVerdict;
|
|
140190
140960
|
try {
|
|
@@ -140338,13 +141108,13 @@ async function runFinalCouncilGate(ctx) {
|
|
|
140338
141108
|
}
|
|
140339
141109
|
// src/tools/phase-complete/gates/hallucination-gate.ts
|
|
140340
141110
|
import * as fs115 from "node:fs";
|
|
140341
|
-
import * as
|
|
141111
|
+
import * as path178 from "node:path";
|
|
140342
141112
|
async function runHallucinationGate(ctx) {
|
|
140343
141113
|
const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
|
|
140344
141114
|
try {
|
|
140345
141115
|
const preamble = await resolveGatePreamble(dir, sessionID);
|
|
140346
141116
|
if (preamble.resolved && preamble.effectiveGates?.hallucination_guard === true) {
|
|
140347
|
-
const hgPath =
|
|
141117
|
+
const hgPath = path178.join(dir, ".swarm", "evidence", String(phase), "hallucination-guard.json");
|
|
140348
141118
|
let hgVerdictFound = false;
|
|
140349
141119
|
let hgVerdictApproved = false;
|
|
140350
141120
|
try {
|
|
@@ -140402,13 +141172,13 @@ async function runHallucinationGate(ctx) {
|
|
|
140402
141172
|
}
|
|
140403
141173
|
// src/tools/phase-complete/gates/mutation-gate.ts
|
|
140404
141174
|
import * as fs116 from "node:fs";
|
|
140405
|
-
import * as
|
|
141175
|
+
import * as path179 from "node:path";
|
|
140406
141176
|
async function runMutationGate(ctx) {
|
|
140407
141177
|
const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
|
|
140408
141178
|
try {
|
|
140409
141179
|
const preamble = await resolveGatePreamble(dir, sessionID);
|
|
140410
141180
|
if (preamble.resolved && preamble.effectiveGates?.mutation_test === true) {
|
|
140411
|
-
const mgPath =
|
|
141181
|
+
const mgPath = path179.join(dir, ".swarm", "evidence", String(phase), "mutation-gate.json");
|
|
140412
141182
|
let mgVerdictFound = false;
|
|
140413
141183
|
let mgVerdict;
|
|
140414
141184
|
try {
|
|
@@ -140466,7 +141236,7 @@ async function runMutationGate(ctx) {
|
|
|
140466
141236
|
}
|
|
140467
141237
|
// src/tools/phase-complete/gates/phase-council-gate.ts
|
|
140468
141238
|
import * as fs117 from "node:fs";
|
|
140469
|
-
import * as
|
|
141239
|
+
import * as path180 from "node:path";
|
|
140470
141240
|
async function runPhaseCouncilGate(ctx) {
|
|
140471
141241
|
const { phase, dir, sessionID, pluginConfig, agentsDispatched, safeWarn } = ctx;
|
|
140472
141242
|
const gateWarnings = [];
|
|
@@ -140475,7 +141245,7 @@ async function runPhaseCouncilGate(ctx) {
|
|
|
140475
141245
|
const preamble = await resolveGatePreamble(dir, sessionID);
|
|
140476
141246
|
if (preamble.resolved && preamble.effectiveGates?.phase_council === true && pluginConfig.council?.enabled === true) {
|
|
140477
141247
|
councilModeEnabled = true;
|
|
140478
|
-
const pcPath =
|
|
141248
|
+
const pcPath = path180.join(dir, ".swarm", "evidence", String(phase), "phase-council.json");
|
|
140479
141249
|
let pcVerdictFound = false;
|
|
140480
141250
|
let _pcVerdict;
|
|
140481
141251
|
let pcQuorumSize;
|
|
@@ -141043,7 +141813,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
141043
141813
|
}
|
|
141044
141814
|
if (retroFound && retroEntry?.lessons_learned && retroEntry.lessons_learned.length > 0) {
|
|
141045
141815
|
try {
|
|
141046
|
-
const projectName =
|
|
141816
|
+
const projectName = path182.basename(dir);
|
|
141047
141817
|
const curationResult = await curateAndStoreSwarm(retroEntry.lessons_learned, projectName, { phase_number: phase }, dir, knowledgeConfig, {
|
|
141048
141818
|
llmDelegate: createCuratorLLMDelegate(dir, "phase", sessionID),
|
|
141049
141819
|
enrichmentQuota: {
|
|
@@ -141605,7 +142375,7 @@ init_utils();
|
|
|
141605
142375
|
init_bun_compat();
|
|
141606
142376
|
init_create_tool();
|
|
141607
142377
|
import * as fs120 from "node:fs";
|
|
141608
|
-
import * as
|
|
142378
|
+
import * as path183 from "node:path";
|
|
141609
142379
|
var MAX_OUTPUT_BYTES7 = 52428800;
|
|
141610
142380
|
var AUDIT_TIMEOUT_MS = 120000;
|
|
141611
142381
|
function isValidEcosystem(value) {
|
|
@@ -141633,16 +142403,16 @@ function validateArgs3(args2) {
|
|
|
141633
142403
|
function detectEcosystems(directory) {
|
|
141634
142404
|
const ecosystems = [];
|
|
141635
142405
|
const cwd = directory;
|
|
141636
|
-
if (fs120.existsSync(
|
|
142406
|
+
if (fs120.existsSync(path183.join(cwd, "package.json"))) {
|
|
141637
142407
|
ecosystems.push("npm");
|
|
141638
142408
|
}
|
|
141639
|
-
if (fs120.existsSync(
|
|
142409
|
+
if (fs120.existsSync(path183.join(cwd, "pyproject.toml")) || fs120.existsSync(path183.join(cwd, "requirements.txt"))) {
|
|
141640
142410
|
ecosystems.push("pip");
|
|
141641
142411
|
}
|
|
141642
|
-
if (fs120.existsSync(
|
|
142412
|
+
if (fs120.existsSync(path183.join(cwd, "Cargo.toml"))) {
|
|
141643
142413
|
ecosystems.push("cargo");
|
|
141644
142414
|
}
|
|
141645
|
-
if (fs120.existsSync(
|
|
142415
|
+
if (fs120.existsSync(path183.join(cwd, "go.mod"))) {
|
|
141646
142416
|
ecosystems.push("go");
|
|
141647
142417
|
}
|
|
141648
142418
|
try {
|
|
@@ -141651,13 +142421,13 @@ function detectEcosystems(directory) {
|
|
|
141651
142421
|
ecosystems.push("dotnet");
|
|
141652
142422
|
}
|
|
141653
142423
|
} catch {}
|
|
141654
|
-
if (fs120.existsSync(
|
|
142424
|
+
if (fs120.existsSync(path183.join(cwd, "Gemfile")) || fs120.existsSync(path183.join(cwd, "Gemfile.lock"))) {
|
|
141655
142425
|
ecosystems.push("ruby");
|
|
141656
142426
|
}
|
|
141657
|
-
if (fs120.existsSync(
|
|
142427
|
+
if (fs120.existsSync(path183.join(cwd, "pubspec.yaml"))) {
|
|
141658
142428
|
ecosystems.push("dart");
|
|
141659
142429
|
}
|
|
141660
|
-
if (fs120.existsSync(
|
|
142430
|
+
if (fs120.existsSync(path183.join(cwd, "composer.lock"))) {
|
|
141661
142431
|
ecosystems.push("composer");
|
|
141662
142432
|
}
|
|
141663
142433
|
return ecosystems;
|
|
@@ -141670,7 +142440,7 @@ async function runNpmAudit(directory) {
|
|
|
141670
142440
|
stderr: "pipe",
|
|
141671
142441
|
cwd: directory
|
|
141672
142442
|
});
|
|
141673
|
-
const timeoutPromise = new Promise((
|
|
142443
|
+
const timeoutPromise = new Promise((resolve66) => setTimeout(() => resolve66("timeout"), AUDIT_TIMEOUT_MS));
|
|
141674
142444
|
const result = await Promise.race([
|
|
141675
142445
|
Promise.all([proc.stdout.text(), proc.stderr.text()]).then(([stdout2, stderr2]) => ({ stdout: stdout2, stderr: stderr2 })),
|
|
141676
142446
|
timeoutPromise
|
|
@@ -141790,7 +142560,7 @@ async function runPipAudit(directory) {
|
|
|
141790
142560
|
stderr: "pipe",
|
|
141791
142561
|
cwd: directory
|
|
141792
142562
|
});
|
|
141793
|
-
const timeoutPromise = new Promise((
|
|
142563
|
+
const timeoutPromise = new Promise((resolve66) => setTimeout(() => resolve66("timeout"), AUDIT_TIMEOUT_MS));
|
|
141794
142564
|
const result = await Promise.race([
|
|
141795
142565
|
Promise.all([proc.stdout.text(), proc.stderr.text()]).then(([stdout2, stderr2]) => ({ stdout: stdout2, stderr: stderr2 })),
|
|
141796
142566
|
timeoutPromise
|
|
@@ -141918,7 +142688,7 @@ async function runCargoAudit(directory) {
|
|
|
141918
142688
|
stderr: "pipe",
|
|
141919
142689
|
cwd: directory
|
|
141920
142690
|
});
|
|
141921
|
-
const timeoutPromise = new Promise((
|
|
142691
|
+
const timeoutPromise = new Promise((resolve66) => setTimeout(() => resolve66("timeout"), AUDIT_TIMEOUT_MS));
|
|
141922
142692
|
const result = await Promise.race([
|
|
141923
142693
|
Promise.all([proc.stdout.text(), proc.stderr.text()]).then(([stdout2, stderr]) => ({ stdout: stdout2, stderr })),
|
|
141924
142694
|
timeoutPromise
|
|
@@ -142042,7 +142812,7 @@ async function runGoAudit(directory) {
|
|
|
142042
142812
|
stderr: "pipe",
|
|
142043
142813
|
cwd: directory
|
|
142044
142814
|
});
|
|
142045
|
-
const timeoutPromise = new Promise((
|
|
142815
|
+
const timeoutPromise = new Promise((resolve66) => setTimeout(() => resolve66("timeout"), AUDIT_TIMEOUT_MS));
|
|
142046
142816
|
const result = await Promise.race([
|
|
142047
142817
|
Promise.all([proc.stdout.text(), proc.stderr.text()]).then(([stdout2, stderr]) => ({ stdout: stdout2, stderr })),
|
|
142048
142818
|
timeoutPromise
|
|
@@ -142175,7 +142945,7 @@ async function runDotnetAudit(directory) {
|
|
|
142175
142945
|
stderr: "pipe",
|
|
142176
142946
|
cwd: directory
|
|
142177
142947
|
});
|
|
142178
|
-
const timeoutPromise = new Promise((
|
|
142948
|
+
const timeoutPromise = new Promise((resolve66) => setTimeout(() => resolve66("timeout"), AUDIT_TIMEOUT_MS));
|
|
142179
142949
|
const result = await Promise.race([
|
|
142180
142950
|
Promise.all([proc.stdout.text(), proc.stderr.text()]).then(([stdout2, stderr]) => ({ stdout: stdout2, stderr })),
|
|
142181
142951
|
timeoutPromise
|
|
@@ -142291,7 +143061,7 @@ async function runBundleAudit(directory) {
|
|
|
142291
143061
|
stderr: "pipe",
|
|
142292
143062
|
cwd: directory
|
|
142293
143063
|
});
|
|
142294
|
-
const timeoutPromise = new Promise((
|
|
143064
|
+
const timeoutPromise = new Promise((resolve66) => setTimeout(() => resolve66("timeout"), AUDIT_TIMEOUT_MS));
|
|
142295
143065
|
const result = await Promise.race([
|
|
142296
143066
|
Promise.all([proc.stdout.text(), proc.stderr.text()]).then(([stdout2, stderr]) => ({ stdout: stdout2, stderr })),
|
|
142297
143067
|
timeoutPromise
|
|
@@ -142436,7 +143206,7 @@ async function runDartAudit(directory) {
|
|
|
142436
143206
|
stderr: "pipe",
|
|
142437
143207
|
cwd: directory
|
|
142438
143208
|
});
|
|
142439
|
-
const timeoutPromise = new Promise((
|
|
143209
|
+
const timeoutPromise = new Promise((resolve66) => setTimeout(() => resolve66("timeout"), AUDIT_TIMEOUT_MS));
|
|
142440
143210
|
const result = await Promise.race([
|
|
142441
143211
|
Promise.all([proc.stdout.text(), proc.stderr.text()]).then(([stdout2, stderr]) => ({ stdout: stdout2, stderr })),
|
|
142442
143212
|
timeoutPromise
|
|
@@ -142551,7 +143321,7 @@ async function runComposerAudit(directory) {
|
|
|
142551
143321
|
stderr: "pipe",
|
|
142552
143322
|
cwd: directory
|
|
142553
143323
|
});
|
|
142554
|
-
const timeoutPromise = new Promise((
|
|
143324
|
+
const timeoutPromise = new Promise((resolve66) => setTimeout(() => resolve66("timeout"), AUDIT_TIMEOUT_MS));
|
|
142555
143325
|
const result = await Promise.race([
|
|
142556
143326
|
Promise.all([proc.stdout.text(), proc.stderr.text()]).then(([stdout2, stderr]) => ({ stdout: stdout2, stderr })),
|
|
142557
143327
|
timeoutPromise
|
|
@@ -142794,7 +143564,7 @@ var pkg_audit = createSwarmTool({
|
|
|
142794
143564
|
init_zod();
|
|
142795
143565
|
init_manager2();
|
|
142796
143566
|
import * as fs121 from "node:fs";
|
|
142797
|
-
import * as
|
|
143567
|
+
import * as path184 from "node:path";
|
|
142798
143568
|
init_utils();
|
|
142799
143569
|
init_create_tool();
|
|
142800
143570
|
var MAX_FILE_SIZE = 1024 * 1024;
|
|
@@ -142917,7 +143687,7 @@ function isScaffoldFile(filePath) {
|
|
|
142917
143687
|
if (SCAFFOLD_PATH_PATTERNS.some((pattern) => pattern.test(normalizedPath))) {
|
|
142918
143688
|
return true;
|
|
142919
143689
|
}
|
|
142920
|
-
const filename =
|
|
143690
|
+
const filename = path184.basename(filePath);
|
|
142921
143691
|
if (SCAFFOLD_FILENAME_PATTERNS.some((pattern) => pattern.test(filename))) {
|
|
142922
143692
|
return true;
|
|
142923
143693
|
}
|
|
@@ -142934,7 +143704,7 @@ function isAllowedByGlobs(filePath, allowGlobs) {
|
|
|
142934
143704
|
if (regex.test(normalizedPath)) {
|
|
142935
143705
|
return true;
|
|
142936
143706
|
}
|
|
142937
|
-
const filename =
|
|
143707
|
+
const filename = path184.basename(filePath);
|
|
142938
143708
|
const filenameRegex = new RegExp(`^${regexPattern}$`, "i");
|
|
142939
143709
|
if (filenameRegex.test(filename)) {
|
|
142940
143710
|
return true;
|
|
@@ -142943,7 +143713,7 @@ function isAllowedByGlobs(filePath, allowGlobs) {
|
|
|
142943
143713
|
return false;
|
|
142944
143714
|
}
|
|
142945
143715
|
function isParserSupported(filePath) {
|
|
142946
|
-
const ext =
|
|
143716
|
+
const ext = path184.extname(filePath).toLowerCase();
|
|
142947
143717
|
return SUPPORTED_PARSER_EXTENSIONS.has(ext);
|
|
142948
143718
|
}
|
|
142949
143719
|
function isPlanFile(filePath) {
|
|
@@ -143190,9 +143960,9 @@ async function placeholderScan(input, directory) {
|
|
|
143190
143960
|
let filesScanned = 0;
|
|
143191
143961
|
const filesWithFindings = new Set;
|
|
143192
143962
|
for (const filePath of changed_files) {
|
|
143193
|
-
const fullPath =
|
|
143194
|
-
const resolvedDirectory =
|
|
143195
|
-
if (!fullPath.startsWith(resolvedDirectory +
|
|
143963
|
+
const fullPath = path184.isAbsolute(filePath) ? filePath : path184.resolve(directory, filePath);
|
|
143964
|
+
const resolvedDirectory = path184.resolve(directory);
|
|
143965
|
+
if (!fullPath.startsWith(resolvedDirectory + path184.sep) && fullPath !== resolvedDirectory) {
|
|
143196
143966
|
continue;
|
|
143197
143967
|
}
|
|
143198
143968
|
if (!fs121.existsSync(fullPath)) {
|
|
@@ -143201,7 +143971,7 @@ async function placeholderScan(input, directory) {
|
|
|
143201
143971
|
if (isAllowedByGlobs(filePath, allow_globs)) {
|
|
143202
143972
|
continue;
|
|
143203
143973
|
}
|
|
143204
|
-
const relativeFilePath =
|
|
143974
|
+
const relativeFilePath = path184.relative(directory, fullPath).replace(/\\/g, "/");
|
|
143205
143975
|
if (FILE_ALLOWLIST.some((allowed) => relativeFilePath.endsWith(allowed))) {
|
|
143206
143976
|
continue;
|
|
143207
143977
|
}
|
|
@@ -143274,7 +144044,7 @@ var placeholder_scan = createSwarmTool({
|
|
|
143274
144044
|
|
|
143275
144045
|
// src/tools/pre-check-batch.ts
|
|
143276
144046
|
import * as fs125 from "node:fs";
|
|
143277
|
-
import * as
|
|
144047
|
+
import * as path188 from "node:path";
|
|
143278
144048
|
init_zod();
|
|
143279
144049
|
init_manager2();
|
|
143280
144050
|
init_utils();
|
|
@@ -143415,7 +144185,7 @@ init_zod();
|
|
|
143415
144185
|
init_manager2();
|
|
143416
144186
|
init_detector();
|
|
143417
144187
|
import * as fs124 from "node:fs";
|
|
143418
|
-
import * as
|
|
144188
|
+
import * as path187 from "node:path";
|
|
143419
144189
|
import { extname as extname19 } from "node:path";
|
|
143420
144190
|
|
|
143421
144191
|
// src/sast/rules/c.ts
|
|
@@ -144125,7 +144895,7 @@ function executeRulesSync(filePath, content, language) {
|
|
|
144125
144895
|
// src/sast/semgrep.ts
|
|
144126
144896
|
import * as child_process14 from "node:child_process";
|
|
144127
144897
|
import * as fs122 from "node:fs";
|
|
144128
|
-
import * as
|
|
144898
|
+
import * as path185 from "node:path";
|
|
144129
144899
|
var semgrepAvailableCache = null;
|
|
144130
144900
|
var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
|
|
144131
144901
|
var DEFAULT_TIMEOUT_MS4 = 30000;
|
|
@@ -144210,7 +144980,7 @@ function mapSemgrepSeverity(severity) {
|
|
|
144210
144980
|
}
|
|
144211
144981
|
async function executeWithTimeout(command, args2, options) {
|
|
144212
144982
|
const maxOutputBytes = options.maxOutputBytes ?? MAX_OUTPUT_BYTES8;
|
|
144213
|
-
return new Promise((
|
|
144983
|
+
return new Promise((resolve68) => {
|
|
144214
144984
|
const child = child_process14.spawn(command, args2, {
|
|
144215
144985
|
shell: false,
|
|
144216
144986
|
cwd: options.cwd,
|
|
@@ -144255,7 +145025,7 @@ async function executeWithTimeout(command, args2, options) {
|
|
|
144255
145025
|
escalation.unref();
|
|
144256
145026
|
}
|
|
144257
145027
|
}
|
|
144258
|
-
|
|
145028
|
+
resolve68({ ...result, truncated });
|
|
144259
145029
|
};
|
|
144260
145030
|
timeout = setTimeout(() => {
|
|
144261
145031
|
settle({
|
|
@@ -144412,7 +145182,7 @@ async function runSemgrep(options) {
|
|
|
144412
145182
|
}
|
|
144413
145183
|
function getRulesDirectory(projectRoot) {
|
|
144414
145184
|
if (projectRoot) {
|
|
144415
|
-
return
|
|
145185
|
+
return path185.resolve(projectRoot, DEFAULT_RULES_DIR);
|
|
144416
145186
|
}
|
|
144417
145187
|
return DEFAULT_RULES_DIR;
|
|
144418
145188
|
}
|
|
@@ -144433,24 +145203,24 @@ init_create_tool();
|
|
|
144433
145203
|
init_utils2();
|
|
144434
145204
|
import * as crypto13 from "node:crypto";
|
|
144435
145205
|
import * as fs123 from "node:fs";
|
|
144436
|
-
import * as
|
|
145206
|
+
import * as path186 from "node:path";
|
|
144437
145207
|
var BASELINE_SCHEMA_VERSION = "1.0.0";
|
|
144438
145208
|
var MAX_BASELINE_FINDINGS = 2000;
|
|
144439
145209
|
var MAX_BASELINE_BYTES = 2 * 1048576;
|
|
144440
145210
|
var LOCK_RETRY_DELAYS_MS = [50, 100, 200, 400, 800];
|
|
144441
145211
|
function normalizeFindingPath(directory, file3) {
|
|
144442
|
-
const resolved =
|
|
144443
|
-
const rel =
|
|
145212
|
+
const resolved = path186.isAbsolute(file3) ? file3 : path186.resolve(directory, file3);
|
|
145213
|
+
const rel = path186.relative(path186.resolve(directory), resolved);
|
|
144444
145214
|
return rel.replace(/\\/g, "/");
|
|
144445
145215
|
}
|
|
144446
145216
|
function baselineRelPath(phase) {
|
|
144447
|
-
return
|
|
145217
|
+
return path186.join("evidence", String(phase), "sast-baseline.json");
|
|
144448
145218
|
}
|
|
144449
145219
|
function tempRelPath(phase) {
|
|
144450
|
-
return
|
|
145220
|
+
return path186.join("evidence", String(phase), `sast-baseline.json.tmp.${Date.now()}.${process.pid}`);
|
|
144451
145221
|
}
|
|
144452
145222
|
function lockRelPath(phase) {
|
|
144453
|
-
return
|
|
145223
|
+
return path186.join("evidence", String(phase), "sast-baseline.json.lock");
|
|
144454
145224
|
}
|
|
144455
145225
|
function getLine(lines, idx) {
|
|
144456
145226
|
if (idx < 0 || idx >= lines.length)
|
|
@@ -144536,7 +145306,7 @@ async function acquireLock2(lockPath) {
|
|
|
144536
145306
|
};
|
|
144537
145307
|
} catch {
|
|
144538
145308
|
if (attempt < LOCK_RETRY_DELAYS_MS.length) {
|
|
144539
|
-
await new Promise((
|
|
145309
|
+
await new Promise((resolve69) => setTimeout(resolve69, LOCK_RETRY_DELAYS_MS[attempt]));
|
|
144540
145310
|
}
|
|
144541
145311
|
}
|
|
144542
145312
|
}
|
|
@@ -144571,8 +145341,8 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
144571
145341
|
message: e instanceof Error ? e.message : "Path validation failed"
|
|
144572
145342
|
};
|
|
144573
145343
|
}
|
|
144574
|
-
fs123.mkdirSync(
|
|
144575
|
-
fs123.mkdirSync(
|
|
145344
|
+
fs123.mkdirSync(path186.dirname(baselinePath), { recursive: true });
|
|
145345
|
+
fs123.mkdirSync(path186.dirname(tempPath), { recursive: true });
|
|
144576
145346
|
const releaseLock = await acquireLock2(lockPath);
|
|
144577
145347
|
try {
|
|
144578
145348
|
let existing = null;
|
|
@@ -144845,9 +145615,9 @@ async function sastScan(input, directory, config3) {
|
|
|
144845
145615
|
_filesSkipped++;
|
|
144846
145616
|
continue;
|
|
144847
145617
|
}
|
|
144848
|
-
const resolvedPath =
|
|
144849
|
-
const resolvedDirectory =
|
|
144850
|
-
if (!resolvedPath.startsWith(resolvedDirectory +
|
|
145618
|
+
const resolvedPath = path187.isAbsolute(filePath) ? filePath : path187.resolve(directory, filePath);
|
|
145619
|
+
const resolvedDirectory = path187.resolve(directory);
|
|
145620
|
+
if (!resolvedPath.startsWith(resolvedDirectory + path187.sep) && resolvedPath !== resolvedDirectory) {
|
|
144851
145621
|
_filesSkipped++;
|
|
144852
145622
|
continue;
|
|
144853
145623
|
}
|
|
@@ -145162,20 +145932,20 @@ function validatePath(inputPath, baseDir, workspaceDir) {
|
|
|
145162
145932
|
let resolved;
|
|
145163
145933
|
const isWinAbs = isWindowsAbsolutePath(inputPath);
|
|
145164
145934
|
if (isWinAbs) {
|
|
145165
|
-
resolved =
|
|
145166
|
-
} else if (
|
|
145167
|
-
resolved =
|
|
145935
|
+
resolved = path188.win32.resolve(inputPath);
|
|
145936
|
+
} else if (path188.isAbsolute(inputPath)) {
|
|
145937
|
+
resolved = path188.resolve(inputPath);
|
|
145168
145938
|
} else {
|
|
145169
|
-
resolved =
|
|
145939
|
+
resolved = path188.resolve(baseDir, inputPath);
|
|
145170
145940
|
}
|
|
145171
|
-
const workspaceResolved =
|
|
145172
|
-
let
|
|
145941
|
+
const workspaceResolved = path188.resolve(workspaceDir);
|
|
145942
|
+
let relative38;
|
|
145173
145943
|
if (isWinAbs) {
|
|
145174
|
-
|
|
145944
|
+
relative38 = path188.win32.relative(workspaceResolved, resolved);
|
|
145175
145945
|
} else {
|
|
145176
|
-
|
|
145946
|
+
relative38 = path188.relative(workspaceResolved, resolved);
|
|
145177
145947
|
}
|
|
145178
|
-
if (
|
|
145948
|
+
if (relative38.startsWith("..")) {
|
|
145179
145949
|
return "path traversal detected";
|
|
145180
145950
|
}
|
|
145181
145951
|
return null;
|
|
@@ -145238,7 +146008,7 @@ async function runLintOnFiles(linter, files, workspaceDir) {
|
|
|
145238
146008
|
if (typeof file3 !== "string") {
|
|
145239
146009
|
continue;
|
|
145240
146010
|
}
|
|
145241
|
-
const resolvedPath =
|
|
146011
|
+
const resolvedPath = path188.resolve(file3);
|
|
145242
146012
|
const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
|
|
145243
146013
|
if (validationError) {
|
|
145244
146014
|
continue;
|
|
@@ -145395,7 +146165,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
145395
146165
|
skippedFiles++;
|
|
145396
146166
|
continue;
|
|
145397
146167
|
}
|
|
145398
|
-
const resolvedPath =
|
|
146168
|
+
const resolvedPath = path188.resolve(file3);
|
|
145399
146169
|
const validationError = validatePath(resolvedPath, directory, directory);
|
|
145400
146170
|
if (validationError) {
|
|
145401
146171
|
skippedFiles++;
|
|
@@ -145413,7 +146183,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
145413
146183
|
};
|
|
145414
146184
|
}
|
|
145415
146185
|
for (const file3 of validatedFiles) {
|
|
145416
|
-
const ext =
|
|
146186
|
+
const ext = path188.extname(file3).toLowerCase();
|
|
145417
146187
|
if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
|
|
145418
146188
|
skippedFiles++;
|
|
145419
146189
|
continue;
|
|
@@ -145632,7 +146402,7 @@ function classifySastFindings(findings, changedLineRanges, directory) {
|
|
|
145632
146402
|
const preexistingFindings = [];
|
|
145633
146403
|
for (const finding of findings) {
|
|
145634
146404
|
const filePath = finding.location.file;
|
|
145635
|
-
const normalised =
|
|
146405
|
+
const normalised = path188.relative(directory, filePath).replace(/\\/g, "/");
|
|
145636
146406
|
const changedLines = changedLineRanges.get(normalised);
|
|
145637
146407
|
if (changedLines?.has(finding.location.line)) {
|
|
145638
146408
|
newFindings.push(finding);
|
|
@@ -145683,7 +146453,7 @@ async function runPreCheckBatch(input, workspaceDir, contextDir) {
|
|
|
145683
146453
|
warn(`pre_check_batch: Invalid file path: ${file3}`);
|
|
145684
146454
|
continue;
|
|
145685
146455
|
}
|
|
145686
|
-
changedFiles.push(
|
|
146456
|
+
changedFiles.push(path188.resolve(directory, file3));
|
|
145687
146457
|
}
|
|
145688
146458
|
if (changedFiles.length === 0) {
|
|
145689
146459
|
warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
|
|
@@ -145884,9 +146654,9 @@ var pre_check_batch = createSwarmTool({
|
|
|
145884
146654
|
};
|
|
145885
146655
|
return JSON.stringify(errorResult, null, 2);
|
|
145886
146656
|
}
|
|
145887
|
-
const resolvedDirectory =
|
|
145888
|
-
const workspaceAnchor =
|
|
145889
|
-
if (resolvedDirectory !== workspaceAnchor && resolvedDirectory.startsWith(workspaceAnchor +
|
|
146657
|
+
const resolvedDirectory = path188.resolve(typedArgs.directory);
|
|
146658
|
+
const workspaceAnchor = path188.resolve(directory);
|
|
146659
|
+
if (resolvedDirectory !== workspaceAnchor && resolvedDirectory.startsWith(workspaceAnchor + path188.sep)) {
|
|
145890
146660
|
const subDirError = `directory "${typedArgs.directory}" is a subdirectory of the project root — pre_check_batch requires the project root directory "${workspaceAnchor}"`;
|
|
145891
146661
|
const subDirResult = {
|
|
145892
146662
|
gates_passed: false,
|
|
@@ -145940,7 +146710,7 @@ var pre_check_batch = createSwarmTool({
|
|
|
145940
146710
|
init_zod();
|
|
145941
146711
|
init_path_security();
|
|
145942
146712
|
init_create_tool();
|
|
145943
|
-
import * as
|
|
146713
|
+
import * as path189 from "node:path";
|
|
145944
146714
|
var VALID_ACTIONS = [
|
|
145945
146715
|
"build",
|
|
145946
146716
|
"importers",
|
|
@@ -145968,7 +146738,7 @@ function validateFile(p) {
|
|
|
145968
146738
|
return "file contains control characters";
|
|
145969
146739
|
if (containsPathTraversal(p))
|
|
145970
146740
|
return "file contains path traversal";
|
|
145971
|
-
if (
|
|
146741
|
+
if (path189.isAbsolute(p) || /^[a-zA-Z]:[\\/]/.test(p)) {
|
|
145972
146742
|
return "file must be a workspace-relative path, not absolute";
|
|
145973
146743
|
}
|
|
145974
146744
|
return null;
|
|
@@ -145991,8 +146761,8 @@ function ok(action, payload) {
|
|
|
145991
146761
|
}
|
|
145992
146762
|
function toRelativeGraphPath(input, workspaceRoot) {
|
|
145993
146763
|
const normalized = input.replace(/\\/g, "/");
|
|
145994
|
-
if (
|
|
145995
|
-
const rel =
|
|
146764
|
+
if (path189.isAbsolute(normalized)) {
|
|
146765
|
+
const rel = path189.relative(workspaceRoot, normalized).replace(/\\/g, "/");
|
|
145996
146766
|
return normalizeGraphPath(rel);
|
|
145997
146767
|
}
|
|
145998
146768
|
return normalizeGraphPath(normalized);
|
|
@@ -146206,7 +146976,7 @@ init_zod();
|
|
|
146206
146976
|
init_effective_spec();
|
|
146207
146977
|
init_create_tool();
|
|
146208
146978
|
import * as fs126 from "node:fs";
|
|
146209
|
-
import * as
|
|
146979
|
+
import * as path190 from "node:path";
|
|
146210
146980
|
var EVIDENCE_DIR4 = ".swarm/evidence";
|
|
146211
146981
|
var OBLIGATION_KEYWORDS2 = ["MUST", "SHOULD", "SHALL"];
|
|
146212
146982
|
var MAX_FILE_SIZE_BYTES8 = 1024 * 1024;
|
|
@@ -146274,7 +147044,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
146274
147044
|
return [];
|
|
146275
147045
|
}
|
|
146276
147046
|
for (const entry of entries) {
|
|
146277
|
-
const entryPath =
|
|
147047
|
+
const entryPath = path190.join(evidenceDir, entry);
|
|
146278
147048
|
try {
|
|
146279
147049
|
const stat14 = fs126.statSync(entryPath);
|
|
146280
147050
|
if (!stat14.isDirectory()) {
|
|
@@ -146290,11 +147060,11 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
146290
147060
|
if (entryPhase !== String(phase)) {
|
|
146291
147061
|
continue;
|
|
146292
147062
|
}
|
|
146293
|
-
const evidenceFilePath =
|
|
147063
|
+
const evidenceFilePath = path190.join(entryPath, "evidence.json");
|
|
146294
147064
|
try {
|
|
146295
|
-
const resolvedPath =
|
|
146296
|
-
const evidenceDirResolved =
|
|
146297
|
-
if (!resolvedPath.startsWith(evidenceDirResolved +
|
|
147065
|
+
const resolvedPath = path190.resolve(evidenceFilePath);
|
|
147066
|
+
const evidenceDirResolved = path190.resolve(evidenceDir);
|
|
147067
|
+
if (!resolvedPath.startsWith(evidenceDirResolved + path190.sep)) {
|
|
146298
147068
|
continue;
|
|
146299
147069
|
}
|
|
146300
147070
|
const stat14 = fs126.lstatSync(evidenceFilePath);
|
|
@@ -146328,7 +147098,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
146328
147098
|
if (Array.isArray(diffEntry.files_changed)) {
|
|
146329
147099
|
for (const file3 of diffEntry.files_changed) {
|
|
146330
147100
|
if (typeof file3 === "string") {
|
|
146331
|
-
touchedFiles.add(
|
|
147101
|
+
touchedFiles.add(path190.resolve(cwd, file3));
|
|
146332
147102
|
}
|
|
146333
147103
|
}
|
|
146334
147104
|
}
|
|
@@ -146341,8 +147111,8 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
146341
147111
|
}
|
|
146342
147112
|
function searchFileForKeywords(filePath, keywords, cwd) {
|
|
146343
147113
|
try {
|
|
146344
|
-
const resolvedPath =
|
|
146345
|
-
const cwdResolved =
|
|
147114
|
+
const resolvedPath = path190.resolve(filePath);
|
|
147115
|
+
const cwdResolved = path190.resolve(cwd);
|
|
146346
147116
|
if (!resolvedPath.startsWith(cwdResolved)) {
|
|
146347
147117
|
return false;
|
|
146348
147118
|
}
|
|
@@ -146501,7 +147271,7 @@ var req_coverage = createSwarmTool({
|
|
|
146501
147271
|
message: "No FR requirements found in spec.md"
|
|
146502
147272
|
}, null, 2);
|
|
146503
147273
|
}
|
|
146504
|
-
const evidenceDir =
|
|
147274
|
+
const evidenceDir = path190.join(cwd, EVIDENCE_DIR4);
|
|
146505
147275
|
const touchedFiles = readTouchedFiles(evidenceDir, phase, cwd);
|
|
146506
147276
|
const analyzedRequirements = [];
|
|
146507
147277
|
let coveredCount = 0;
|
|
@@ -146527,7 +147297,7 @@ var req_coverage = createSwarmTool({
|
|
|
146527
147297
|
requirements: analyzedRequirements
|
|
146528
147298
|
};
|
|
146529
147299
|
const reportFilename = `req-coverage-phase-${phase}.json`;
|
|
146530
|
-
const reportPath =
|
|
147300
|
+
const reportPath = path190.join(evidenceDir, reportFilename);
|
|
146531
147301
|
try {
|
|
146532
147302
|
if (!fs126.existsSync(evidenceDir)) {
|
|
146533
147303
|
fs126.mkdirSync(evidenceDir, { recursive: true });
|
|
@@ -146682,7 +147452,7 @@ init_plan_schema();
|
|
|
146682
147452
|
init_qa_gate_profile();
|
|
146683
147453
|
init_file_locks();
|
|
146684
147454
|
import * as fs127 from "node:fs";
|
|
146685
|
-
import * as
|
|
147455
|
+
import * as path191 from "node:path";
|
|
146686
147456
|
init_ledger();
|
|
146687
147457
|
init_manager();
|
|
146688
147458
|
init_effective_spec();
|
|
@@ -146764,8 +147534,8 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
146764
147534
|
};
|
|
146765
147535
|
}
|
|
146766
147536
|
if (args2.working_directory && fallbackDir) {
|
|
146767
|
-
const resolvedTarget =
|
|
146768
|
-
const resolvedRoot =
|
|
147537
|
+
const resolvedTarget = path191.resolve(args2.working_directory);
|
|
147538
|
+
const resolvedRoot = path191.resolve(fallbackDir);
|
|
146769
147539
|
let fallbackExists = false;
|
|
146770
147540
|
try {
|
|
146771
147541
|
fs127.accessSync(resolvedRoot, fs127.constants.F_OK);
|
|
@@ -146774,7 +147544,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
146774
147544
|
fallbackExists = false;
|
|
146775
147545
|
}
|
|
146776
147546
|
if (fallbackExists) {
|
|
146777
|
-
const isSubdirectory = resolvedTarget.startsWith(resolvedRoot +
|
|
147547
|
+
const isSubdirectory = resolvedTarget.startsWith(resolvedRoot + path191.sep);
|
|
146778
147548
|
if (isSubdirectory) {
|
|
146779
147549
|
return {
|
|
146780
147550
|
success: false,
|
|
@@ -146805,7 +147575,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
146805
147575
|
specHash = spec.hash;
|
|
146806
147576
|
}
|
|
146807
147577
|
if (process.env.SWARM_SKIP_GATE_SELECTION !== "1") {
|
|
146808
|
-
const contextPath =
|
|
147578
|
+
const contextPath = path191.join(targetWorkspace, ".swarm", "context.md");
|
|
146809
147579
|
let contextContent = "";
|
|
146810
147580
|
try {
|
|
146811
147581
|
contextContent = await fs127.promises.readFile(contextPath, "utf8");
|
|
@@ -147095,7 +147865,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
147095
147865
|
}
|
|
147096
147866
|
await writeCheckpoint(dir).catch(() => {});
|
|
147097
147867
|
try {
|
|
147098
|
-
const markerPath =
|
|
147868
|
+
const markerPath = path191.join(dir, ".swarm", ".plan-write-marker");
|
|
147099
147869
|
const marker = JSON.stringify({
|
|
147100
147870
|
source: "save_plan",
|
|
147101
147871
|
timestamp: new Date().toISOString(),
|
|
@@ -147118,7 +147888,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
147118
147888
|
return {
|
|
147119
147889
|
success: true,
|
|
147120
147890
|
message: "Plan saved successfully",
|
|
147121
|
-
plan_path:
|
|
147891
|
+
plan_path: path191.join(dir, ".swarm", "plan.json"),
|
|
147122
147892
|
phases_count: plan.phases.length,
|
|
147123
147893
|
tasks_count: tasksCount,
|
|
147124
147894
|
...resolvedProfile !== undefined ? { execution_profile: resolvedProfile } : {},
|
|
@@ -147186,7 +147956,7 @@ var save_plan = createSwarmTool({
|
|
|
147186
147956
|
init_zod();
|
|
147187
147957
|
init_manager2();
|
|
147188
147958
|
import * as fs128 from "node:fs";
|
|
147189
|
-
import * as
|
|
147959
|
+
import * as path192 from "node:path";
|
|
147190
147960
|
|
|
147191
147961
|
// src/sbom/detectors/index.ts
|
|
147192
147962
|
init_utils();
|
|
@@ -148036,7 +148806,7 @@ function findManifestFiles(rootDir) {
|
|
|
148036
148806
|
try {
|
|
148037
148807
|
const entries = fs128.readdirSync(dir, { withFileTypes: true });
|
|
148038
148808
|
for (const entry of entries) {
|
|
148039
|
-
const fullPath =
|
|
148809
|
+
const fullPath = path192.join(dir, entry.name);
|
|
148040
148810
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
|
|
148041
148811
|
continue;
|
|
148042
148812
|
}
|
|
@@ -148045,7 +148815,7 @@ function findManifestFiles(rootDir) {
|
|
|
148045
148815
|
} else if (entry.isFile()) {
|
|
148046
148816
|
for (const pattern of patterns) {
|
|
148047
148817
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
148048
|
-
manifestFiles.push(
|
|
148818
|
+
manifestFiles.push(path192.relative(rootDir, fullPath));
|
|
148049
148819
|
break;
|
|
148050
148820
|
}
|
|
148051
148821
|
}
|
|
@@ -148063,11 +148833,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
148063
148833
|
try {
|
|
148064
148834
|
const entries = fs128.readdirSync(dir, { withFileTypes: true });
|
|
148065
148835
|
for (const entry of entries) {
|
|
148066
|
-
const fullPath =
|
|
148836
|
+
const fullPath = path192.join(dir, entry.name);
|
|
148067
148837
|
if (entry.isFile()) {
|
|
148068
148838
|
for (const pattern of patterns) {
|
|
148069
148839
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
148070
|
-
found.push(
|
|
148840
|
+
found.push(path192.relative(workingDir, fullPath));
|
|
148071
148841
|
break;
|
|
148072
148842
|
}
|
|
148073
148843
|
}
|
|
@@ -148080,11 +148850,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
148080
148850
|
function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
|
|
148081
148851
|
const dirs = new Set;
|
|
148082
148852
|
for (const file3 of changedFiles) {
|
|
148083
|
-
let currentDir =
|
|
148853
|
+
let currentDir = path192.dirname(file3);
|
|
148084
148854
|
while (true) {
|
|
148085
|
-
if (currentDir && currentDir !== "." && currentDir !==
|
|
148086
|
-
dirs.add(
|
|
148087
|
-
const parent =
|
|
148855
|
+
if (currentDir && currentDir !== "." && currentDir !== path192.sep) {
|
|
148856
|
+
dirs.add(path192.join(workingDir, currentDir));
|
|
148857
|
+
const parent = path192.dirname(currentDir);
|
|
148088
148858
|
if (parent === currentDir)
|
|
148089
148859
|
break;
|
|
148090
148860
|
currentDir = parent;
|
|
@@ -148168,7 +148938,7 @@ var sbom_generate = createSwarmTool({
|
|
|
148168
148938
|
const changedFiles = obj.changed_files;
|
|
148169
148939
|
const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
|
|
148170
148940
|
const workingDir = directory;
|
|
148171
|
-
const outputDir =
|
|
148941
|
+
const outputDir = path192.isAbsolute(relativeOutputDir) ? relativeOutputDir : path192.join(workingDir, relativeOutputDir);
|
|
148172
148942
|
let manifestFiles = [];
|
|
148173
148943
|
if (scope === "all") {
|
|
148174
148944
|
manifestFiles = findManifestFiles(workingDir);
|
|
@@ -148191,7 +148961,7 @@ var sbom_generate = createSwarmTool({
|
|
|
148191
148961
|
const processedFiles = [];
|
|
148192
148962
|
for (const manifestFile of manifestFiles) {
|
|
148193
148963
|
try {
|
|
148194
|
-
const fullPath =
|
|
148964
|
+
const fullPath = path192.isAbsolute(manifestFile) ? manifestFile : path192.join(workingDir, manifestFile);
|
|
148195
148965
|
if (!fs128.existsSync(fullPath)) {
|
|
148196
148966
|
continue;
|
|
148197
148967
|
}
|
|
@@ -148208,7 +148978,7 @@ var sbom_generate = createSwarmTool({
|
|
|
148208
148978
|
const bom = generateCycloneDX(allComponents);
|
|
148209
148979
|
const bomJson = serializeCycloneDX(bom);
|
|
148210
148980
|
const filename = generateSbomFilename();
|
|
148211
|
-
const outputPath =
|
|
148981
|
+
const outputPath = path192.join(outputDir, filename);
|
|
148212
148982
|
fs128.writeFileSync(outputPath, bomJson, "utf-8");
|
|
148213
148983
|
const verdict = processedFiles.length > 0 ? "pass" : "pass";
|
|
148214
148984
|
try {
|
|
@@ -148253,7 +149023,7 @@ var sbom_generate = createSwarmTool({
|
|
|
148253
149023
|
init_zod();
|
|
148254
149024
|
init_create_tool();
|
|
148255
149025
|
import * as fs129 from "node:fs";
|
|
148256
|
-
import * as
|
|
149026
|
+
import * as path193 from "node:path";
|
|
148257
149027
|
var SPEC_CANDIDATES = [
|
|
148258
149028
|
"openapi.json",
|
|
148259
149029
|
"openapi.yaml",
|
|
@@ -148285,12 +149055,12 @@ function normalizePath5(p) {
|
|
|
148285
149055
|
}
|
|
148286
149056
|
function discoverSpecFile(cwd, specFileArg) {
|
|
148287
149057
|
if (specFileArg) {
|
|
148288
|
-
const resolvedPath =
|
|
148289
|
-
const normalizedCwd = cwd.endsWith(
|
|
149058
|
+
const resolvedPath = path193.resolve(cwd, specFileArg);
|
|
149059
|
+
const normalizedCwd = cwd.endsWith(path193.sep) ? cwd : cwd + path193.sep;
|
|
148290
149060
|
if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
|
|
148291
149061
|
throw new Error("Invalid spec_file: path traversal detected");
|
|
148292
149062
|
}
|
|
148293
|
-
const ext =
|
|
149063
|
+
const ext = path193.extname(resolvedPath).toLowerCase();
|
|
148294
149064
|
if (!ALLOWED_EXTENSIONS.includes(ext)) {
|
|
148295
149065
|
throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
|
|
148296
149066
|
}
|
|
@@ -148304,7 +149074,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
148304
149074
|
return resolvedPath;
|
|
148305
149075
|
}
|
|
148306
149076
|
for (const candidate of SPEC_CANDIDATES) {
|
|
148307
|
-
const candidatePath =
|
|
149077
|
+
const candidatePath = path193.resolve(cwd, candidate);
|
|
148308
149078
|
if (fs129.existsSync(candidatePath)) {
|
|
148309
149079
|
const stats2 = fs129.statSync(candidatePath);
|
|
148310
149080
|
if (stats2.size <= MAX_SPEC_SIZE) {
|
|
@@ -148316,7 +149086,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
148316
149086
|
}
|
|
148317
149087
|
function parseSpec(specFile) {
|
|
148318
149088
|
const content = fs129.readFileSync(specFile, "utf-8");
|
|
148319
|
-
const ext =
|
|
149089
|
+
const ext = path193.extname(specFile).toLowerCase();
|
|
148320
149090
|
if (ext === ".json") {
|
|
148321
149091
|
return parseJsonSpec(content);
|
|
148322
149092
|
}
|
|
@@ -148392,7 +149162,7 @@ function extractRoutes2(cwd) {
|
|
|
148392
149162
|
return;
|
|
148393
149163
|
}
|
|
148394
149164
|
for (const entry of entries) {
|
|
148395
|
-
const fullPath =
|
|
149165
|
+
const fullPath = path193.join(dir, entry.name);
|
|
148396
149166
|
if (entry.isSymbolicLink()) {
|
|
148397
149167
|
continue;
|
|
148398
149168
|
}
|
|
@@ -148402,7 +149172,7 @@ function extractRoutes2(cwd) {
|
|
|
148402
149172
|
}
|
|
148403
149173
|
walkDir2(fullPath);
|
|
148404
149174
|
} else if (entry.isFile()) {
|
|
148405
|
-
const ext =
|
|
149175
|
+
const ext = path193.extname(entry.name).toLowerCase();
|
|
148406
149176
|
const baseName = entry.name.toLowerCase();
|
|
148407
149177
|
if (![".ts", ".js", ".mjs"].includes(ext)) {
|
|
148408
149178
|
continue;
|
|
@@ -148571,7 +149341,7 @@ init_bun_compat();
|
|
|
148571
149341
|
init_path_security();
|
|
148572
149342
|
init_create_tool();
|
|
148573
149343
|
import * as fs130 from "node:fs";
|
|
148574
|
-
import * as
|
|
149344
|
+
import * as path194 from "node:path";
|
|
148575
149345
|
var DEFAULT_MAX_RESULTS = 100;
|
|
148576
149346
|
var DEFAULT_MAX_LINES = 200;
|
|
148577
149347
|
var REGEX_TIMEOUT_MS = 5000;
|
|
@@ -148607,11 +149377,11 @@ function containsWindowsAttacks4(str) {
|
|
|
148607
149377
|
}
|
|
148608
149378
|
function isPathInWorkspace3(filePath, workspace) {
|
|
148609
149379
|
try {
|
|
148610
|
-
const resolvedPath =
|
|
149380
|
+
const resolvedPath = path194.resolve(workspace, filePath);
|
|
148611
149381
|
const realWorkspace = fs130.realpathSync(workspace);
|
|
148612
149382
|
const realResolvedPath = fs130.realpathSync(resolvedPath);
|
|
148613
|
-
const relativePath =
|
|
148614
|
-
if (relativePath.startsWith("..") ||
|
|
149383
|
+
const relativePath = path194.relative(realWorkspace, realResolvedPath);
|
|
149384
|
+
if (relativePath.startsWith("..") || path194.isAbsolute(relativePath)) {
|
|
148615
149385
|
return false;
|
|
148616
149386
|
}
|
|
148617
149387
|
return true;
|
|
@@ -148624,11 +149394,11 @@ function validatePathForRead2(filePath, workspace) {
|
|
|
148624
149394
|
}
|
|
148625
149395
|
function findRgInEnvPath() {
|
|
148626
149396
|
const searchPath = process.env.PATH ?? "";
|
|
148627
|
-
for (const dir of searchPath.split(
|
|
149397
|
+
for (const dir of searchPath.split(path194.delimiter)) {
|
|
148628
149398
|
if (!dir)
|
|
148629
149399
|
continue;
|
|
148630
149400
|
const isWindows = process.platform === "win32";
|
|
148631
|
-
const candidate =
|
|
149401
|
+
const candidate = path194.join(dir, isWindows ? "rg.exe" : "rg");
|
|
148632
149402
|
if (fs130.existsSync(candidate))
|
|
148633
149403
|
return candidate;
|
|
148634
149404
|
}
|
|
@@ -148683,7 +149453,7 @@ async function ripgrepSearch(opts) {
|
|
|
148683
149453
|
stderr: "pipe",
|
|
148684
149454
|
cwd: opts.workspace
|
|
148685
149455
|
});
|
|
148686
|
-
const timeout = new Promise((
|
|
149456
|
+
const timeout = new Promise((resolve75) => setTimeout(() => resolve75("timeout"), REGEX_TIMEOUT_MS));
|
|
148687
149457
|
const exitPromise = proc.exited;
|
|
148688
149458
|
const result = await Promise.race([exitPromise, timeout]);
|
|
148689
149459
|
if (result === "timeout") {
|
|
@@ -148758,8 +149528,8 @@ function collectFiles(dir, workspace, includeGlobs, excludeGlobs) {
|
|
|
148758
149528
|
try {
|
|
148759
149529
|
const entries = fs130.readdirSync(dir, { withFileTypes: true });
|
|
148760
149530
|
for (const entry of entries) {
|
|
148761
|
-
const fullPath =
|
|
148762
|
-
const relativePath =
|
|
149531
|
+
const fullPath = path194.join(dir, entry.name);
|
|
149532
|
+
const relativePath = path194.relative(workspace, fullPath);
|
|
148763
149533
|
if (!validatePathForRead2(fullPath, workspace)) {
|
|
148764
149534
|
continue;
|
|
148765
149535
|
}
|
|
@@ -148800,7 +149570,7 @@ async function fallbackSearch(opts) {
|
|
|
148800
149570
|
const matches = [];
|
|
148801
149571
|
let total = 0;
|
|
148802
149572
|
for (const file3 of files) {
|
|
148803
|
-
const fullPath =
|
|
149573
|
+
const fullPath = path194.join(opts.workspace, file3);
|
|
148804
149574
|
if (!validatePathForRead2(fullPath, opts.workspace)) {
|
|
148805
149575
|
continue;
|
|
148806
149576
|
}
|
|
@@ -149232,7 +150002,7 @@ init_config();
|
|
|
149232
150002
|
init_schema();
|
|
149233
150003
|
init_create_tool();
|
|
149234
150004
|
import { mkdir as mkdir33, rename as rename14, writeFile as writeFile23 } from "node:fs/promises";
|
|
149235
|
-
import * as
|
|
150005
|
+
import * as path195 from "node:path";
|
|
149236
150006
|
var MAX_SPEC_BYTES2 = 256 * 1024;
|
|
149237
150007
|
var spec_write = createSwarmTool({
|
|
149238
150008
|
description: "Write the canonical project spec to .swarm/spec.md. Atomic write, size-bounded (256 KiB), heading-required. Honors spec_writer.allow_spec_write.",
|
|
@@ -149273,8 +150043,8 @@ var spec_write = createSwarmTool({
|
|
|
149273
150043
|
reason: 'spec must contain at least one top-level "# Heading"'
|
|
149274
150044
|
}, null, 2);
|
|
149275
150045
|
}
|
|
149276
|
-
const target =
|
|
149277
|
-
await mkdir33(
|
|
150046
|
+
const target = path195.join(directory, ".swarm", "spec.md");
|
|
150047
|
+
await mkdir33(path195.dirname(target), { recursive: true });
|
|
149278
150048
|
const tmp = `${target}.tmp-${process.pid}-${Date.now()}`;
|
|
149279
150049
|
let finalContent = content;
|
|
149280
150050
|
if (mode === "append") {
|
|
@@ -149303,14 +150073,14 @@ ${content}
|
|
|
149303
150073
|
init_zod();
|
|
149304
150074
|
init_loader();
|
|
149305
150075
|
import {
|
|
149306
|
-
existsSync as
|
|
149307
|
-
mkdirSync as
|
|
150076
|
+
existsSync as existsSync113,
|
|
150077
|
+
mkdirSync as mkdirSync50,
|
|
149308
150078
|
readFileSync as readFileSync89,
|
|
149309
150079
|
renameSync as renameSync32,
|
|
149310
150080
|
unlinkSync as unlinkSync29,
|
|
149311
150081
|
writeFileSync as writeFileSync36
|
|
149312
150082
|
} from "node:fs";
|
|
149313
|
-
import
|
|
150083
|
+
import path196 from "node:path";
|
|
149314
150084
|
init_create_tool();
|
|
149315
150085
|
init_resolve_working_directory();
|
|
149316
150086
|
var VerdictSchema2 = exports_external.object({
|
|
@@ -149477,7 +150247,7 @@ var submit_phase_council_verdicts = createSwarmTool({
|
|
|
149477
150247
|
}
|
|
149478
150248
|
});
|
|
149479
150249
|
function getPhaseMutationGapFinding(phaseNumber, workingDir) {
|
|
149480
|
-
const mutationGatePath =
|
|
150250
|
+
const mutationGatePath = path196.join(workingDir, ".swarm", "evidence", String(phaseNumber), "mutation-gate.json");
|
|
149481
150251
|
try {
|
|
149482
150252
|
const raw = readFileSync89(mutationGatePath, "utf-8");
|
|
149483
150253
|
const parsed = JSON.parse(raw);
|
|
@@ -149539,9 +150309,9 @@ function getPhaseMutationGapFinding(phaseNumber, workingDir) {
|
|
|
149539
150309
|
}
|
|
149540
150310
|
}
|
|
149541
150311
|
function writePhaseCouncilEvidence(workingDir, synthesis, provenance) {
|
|
149542
|
-
const evidenceDir =
|
|
149543
|
-
|
|
149544
|
-
const evidenceFile =
|
|
150312
|
+
const evidenceDir = path196.join(workingDir, ".swarm", "evidence", String(synthesis.phaseNumber));
|
|
150313
|
+
mkdirSync50(evidenceDir, { recursive: true });
|
|
150314
|
+
const evidenceFile = path196.join(evidenceDir, "phase-council.json");
|
|
149545
150315
|
const evidenceBundle = {
|
|
149546
150316
|
entries: [
|
|
149547
150317
|
{
|
|
@@ -149578,7 +150348,7 @@ function writePhaseCouncilEvidence(workingDir, synthesis, provenance) {
|
|
|
149578
150348
|
writeFileSync36(tempFile, JSON.stringify(evidenceBundle, null, 2), "utf-8");
|
|
149579
150349
|
renameSync32(tempFile, evidenceFile);
|
|
149580
150350
|
} finally {
|
|
149581
|
-
if (
|
|
150351
|
+
if (existsSync113(tempFile)) {
|
|
149582
150352
|
unlinkSync29(tempFile);
|
|
149583
150353
|
}
|
|
149584
150354
|
}
|
|
@@ -149604,7 +150374,7 @@ init_zod();
|
|
|
149604
150374
|
init_path_security();
|
|
149605
150375
|
init_create_tool();
|
|
149606
150376
|
import * as fs131 from "node:fs";
|
|
149607
|
-
import * as
|
|
150377
|
+
import * as path197 from "node:path";
|
|
149608
150378
|
var BINARY_EXTENSIONS2 = new Set([
|
|
149609
150379
|
".png",
|
|
149610
150380
|
".jpg",
|
|
@@ -149640,14 +150410,14 @@ function containsWindowsAttacks5(str) {
|
|
|
149640
150410
|
}
|
|
149641
150411
|
function isPathInWorkspace4(filePath, workspace) {
|
|
149642
150412
|
try {
|
|
149643
|
-
const resolvedPath =
|
|
150413
|
+
const resolvedPath = path197.resolve(workspace, filePath);
|
|
149644
150414
|
if (!fs131.existsSync(resolvedPath)) {
|
|
149645
150415
|
return true;
|
|
149646
150416
|
}
|
|
149647
150417
|
const realWorkspace = fs131.realpathSync(workspace);
|
|
149648
150418
|
const realResolvedPath = fs131.realpathSync(resolvedPath);
|
|
149649
|
-
const relativePath =
|
|
149650
|
-
if (relativePath.startsWith("..") ||
|
|
150419
|
+
const relativePath = path197.relative(realWorkspace, realResolvedPath);
|
|
150420
|
+
if (relativePath.startsWith("..") || path197.isAbsolute(relativePath)) {
|
|
149651
150421
|
return false;
|
|
149652
150422
|
}
|
|
149653
150423
|
return true;
|
|
@@ -149762,7 +150532,7 @@ function arraysEqual2(a, b) {
|
|
|
149762
150532
|
return true;
|
|
149763
150533
|
}
|
|
149764
150534
|
function isBinaryFile4(filePath) {
|
|
149765
|
-
const ext =
|
|
150535
|
+
const ext = path197.extname(filePath).toLowerCase();
|
|
149766
150536
|
return BINARY_EXTENSIONS2.has(ext);
|
|
149767
150537
|
}
|
|
149768
150538
|
function splitDiffLines(content) {
|
|
@@ -149967,7 +150737,7 @@ var suggestPatch = createSwarmTool({
|
|
|
149967
150737
|
});
|
|
149968
150738
|
continue;
|
|
149969
150739
|
}
|
|
149970
|
-
const fullPath =
|
|
150740
|
+
const fullPath = path197.resolve(directory, change.file);
|
|
149971
150741
|
if (!fs131.existsSync(fullPath)) {
|
|
149972
150742
|
errors5.push({
|
|
149973
150743
|
success: false,
|
|
@@ -150062,7 +150832,7 @@ var suggestPatch = createSwarmTool({
|
|
|
150062
150832
|
const unifiedParts = [];
|
|
150063
150833
|
for (const [file3, entries] of fileGroups) {
|
|
150064
150834
|
entries.sort((a, b) => a.contextMatch.startLineIndex - b.contextMatch.startLineIndex);
|
|
150065
|
-
const entryFullPath =
|
|
150835
|
+
const entryFullPath = path197.resolve(directory, file3);
|
|
150066
150836
|
let entryContent;
|
|
150067
150837
|
try {
|
|
150068
150838
|
entryContent = fs131.readFileSync(entryFullPath, "utf-8");
|
|
@@ -150404,7 +151174,7 @@ function getContextAgent4(ctx) {
|
|
|
150404
151174
|
|
|
150405
151175
|
// src/tools/syntax-check.ts
|
|
150406
151176
|
import * as fs132 from "node:fs";
|
|
150407
|
-
import * as
|
|
151177
|
+
import * as path198 from "node:path";
|
|
150408
151178
|
init_zod();
|
|
150409
151179
|
init_manager2();
|
|
150410
151180
|
init_detector();
|
|
@@ -150476,7 +151246,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
150476
151246
|
if (languages?.length) {
|
|
150477
151247
|
const lowerLangs = languages.map((l) => l.toLowerCase());
|
|
150478
151248
|
filesToCheck = filesToCheck.filter((file3) => {
|
|
150479
|
-
const ext =
|
|
151249
|
+
const ext = path198.extname(file3.path).toLowerCase();
|
|
150480
151250
|
const langDef = getLanguageForExtension(ext);
|
|
150481
151251
|
const fileProfile = getProfileForFile(file3.path);
|
|
150482
151252
|
const langId = fileProfile?.id || langDef?.id;
|
|
@@ -150486,7 +151256,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
150486
151256
|
const { loadGrammar: loadGrammar2 } = await Promise.resolve().then(() => (init_runtime(), exports_runtime));
|
|
150487
151257
|
async function checkOneFile(fileInfo) {
|
|
150488
151258
|
const { path: filePath } = fileInfo;
|
|
150489
|
-
const fullPath =
|
|
151259
|
+
const fullPath = path198.isAbsolute(filePath) ? filePath : path198.join(directory, filePath);
|
|
150490
151260
|
const result = {
|
|
150491
151261
|
path: filePath,
|
|
150492
151262
|
language: "",
|
|
@@ -150533,7 +151303,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
150533
151303
|
result.skipped_reason = "binary_file";
|
|
150534
151304
|
return { result, counted: false, failed: false, skipped: true };
|
|
150535
151305
|
}
|
|
150536
|
-
const ext =
|
|
151306
|
+
const ext = path198.extname(filePath).toLowerCase();
|
|
150537
151307
|
const langDef = getLanguageForExtension(ext);
|
|
150538
151308
|
result.language = profile?.id || langDef?.id || "unknown";
|
|
150539
151309
|
const errors5 = extractSyntaxErrors(parser, content);
|
|
@@ -150645,7 +151415,7 @@ init_utils();
|
|
|
150645
151415
|
init_create_tool();
|
|
150646
151416
|
init_path_security();
|
|
150647
151417
|
import * as fs133 from "node:fs";
|
|
150648
|
-
import * as
|
|
151418
|
+
import * as path199 from "node:path";
|
|
150649
151419
|
var MAX_TEXT_LENGTH = 200;
|
|
150650
151420
|
var MAX_FILE_SIZE_BYTES10 = 1024 * 1024;
|
|
150651
151421
|
var SUPPORTED_EXTENSIONS4 = new Set([
|
|
@@ -150711,9 +151481,9 @@ function validatePathsInput(paths, cwd) {
|
|
|
150711
151481
|
return { error: "paths contains path traversal", resolvedPath: null };
|
|
150712
151482
|
}
|
|
150713
151483
|
try {
|
|
150714
|
-
const resolvedPath =
|
|
150715
|
-
const normalizedCwd =
|
|
150716
|
-
const normalizedResolved =
|
|
151484
|
+
const resolvedPath = path199.resolve(paths);
|
|
151485
|
+
const normalizedCwd = path199.resolve(cwd);
|
|
151486
|
+
const normalizedResolved = path199.resolve(resolvedPath);
|
|
150717
151487
|
if (!normalizedResolved.startsWith(normalizedCwd)) {
|
|
150718
151488
|
return {
|
|
150719
151489
|
error: "paths must be within the current working directory",
|
|
@@ -150729,7 +151499,7 @@ function validatePathsInput(paths, cwd) {
|
|
|
150729
151499
|
}
|
|
150730
151500
|
}
|
|
150731
151501
|
function isSupportedExtension(filePath) {
|
|
150732
|
-
const ext =
|
|
151502
|
+
const ext = path199.extname(filePath).toLowerCase();
|
|
150733
151503
|
return SUPPORTED_EXTENSIONS4.has(ext);
|
|
150734
151504
|
}
|
|
150735
151505
|
function findSourceFiles3(dir, files = []) {
|
|
@@ -150744,7 +151514,7 @@ function findSourceFiles3(dir, files = []) {
|
|
|
150744
151514
|
if (SKIP_DIRECTORIES6.has(entry)) {
|
|
150745
151515
|
continue;
|
|
150746
151516
|
}
|
|
150747
|
-
const fullPath =
|
|
151517
|
+
const fullPath = path199.join(dir, entry);
|
|
150748
151518
|
let stat14;
|
|
150749
151519
|
try {
|
|
150750
151520
|
stat14 = fs133.statSync(fullPath);
|
|
@@ -150856,7 +151626,7 @@ var todo_extract = createSwarmTool({
|
|
|
150856
151626
|
filesToScan.push(scanPath);
|
|
150857
151627
|
} else {
|
|
150858
151628
|
const errorResult = {
|
|
150859
|
-
error: `unsupported file extension: ${
|
|
151629
|
+
error: `unsupported file extension: ${path199.extname(scanPath)}`,
|
|
150860
151630
|
total: 0,
|
|
150861
151631
|
byPriority: { high: 0, medium: 0, low: 0 },
|
|
150862
151632
|
entries: []
|
|
@@ -150906,17 +151676,17 @@ init_schema();
|
|
|
150906
151676
|
init_qa_gate_profile();
|
|
150907
151677
|
init_gate_evidence();
|
|
150908
151678
|
import * as fs137 from "node:fs";
|
|
150909
|
-
import * as
|
|
151679
|
+
import * as path203 from "node:path";
|
|
150910
151680
|
|
|
150911
151681
|
// src/hooks/diff-scope.ts
|
|
150912
151682
|
init_bun_compat();
|
|
150913
151683
|
import * as fs135 from "node:fs";
|
|
150914
|
-
import * as
|
|
151684
|
+
import * as path201 from "node:path";
|
|
150915
151685
|
|
|
150916
151686
|
// src/utils/gitignore-warning.ts
|
|
150917
151687
|
init_bun_compat();
|
|
150918
151688
|
import * as fs134 from "node:fs";
|
|
150919
|
-
import * as
|
|
151689
|
+
import * as path200 from "node:path";
|
|
150920
151690
|
var _internals118 = { bunSpawn };
|
|
150921
151691
|
var _swarmGitExcludedChecked = false;
|
|
150922
151692
|
function fileCoversSwarm(content) {
|
|
@@ -150990,10 +151760,10 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
150990
151760
|
const excludeRelPath = excludePathRaw.trim();
|
|
150991
151761
|
if (!excludeRelPath)
|
|
150992
151762
|
return;
|
|
150993
|
-
const excludePath =
|
|
151763
|
+
const excludePath = path200.isAbsolute(excludeRelPath) ? excludeRelPath : path200.join(directory, excludeRelPath);
|
|
150994
151764
|
if (checkIgnoreExitCode !== 0) {
|
|
150995
151765
|
try {
|
|
150996
|
-
fs134.mkdirSync(
|
|
151766
|
+
fs134.mkdirSync(path200.dirname(excludePath), { recursive: true });
|
|
150997
151767
|
let existing = "";
|
|
150998
151768
|
try {
|
|
150999
151769
|
existing = fs134.readFileSync(excludePath, "utf8");
|
|
@@ -151037,7 +151807,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
151037
151807
|
var _internals119 = { bunSpawn };
|
|
151038
151808
|
function getDeclaredScope(taskId, directory) {
|
|
151039
151809
|
try {
|
|
151040
|
-
const planPath =
|
|
151810
|
+
const planPath = path201.join(directory, ".swarm", "plan.json");
|
|
151041
151811
|
if (!fs135.existsSync(planPath))
|
|
151042
151812
|
return null;
|
|
151043
151813
|
const raw = fs135.readFileSync(planPath, "utf-8");
|
|
@@ -151143,7 +151913,7 @@ init_telemetry();
|
|
|
151143
151913
|
// src/turbo/lean/task-completion.ts
|
|
151144
151914
|
init_file_locks();
|
|
151145
151915
|
import * as fs136 from "node:fs";
|
|
151146
|
-
import * as
|
|
151916
|
+
import * as path202 from "node:path";
|
|
151147
151917
|
var _internals120 = {
|
|
151148
151918
|
listActiveLocks,
|
|
151149
151919
|
verifyLeanTurboTaskCompletion
|
|
@@ -151162,7 +151932,7 @@ var TIER_3_PATTERNS = [
|
|
|
151162
151932
|
];
|
|
151163
151933
|
function matchesTier3Pattern(files) {
|
|
151164
151934
|
for (const file3 of files) {
|
|
151165
|
-
const fileName =
|
|
151935
|
+
const fileName = path202.basename(file3);
|
|
151166
151936
|
for (const pattern of TIER_3_PATTERNS) {
|
|
151167
151937
|
if (pattern.test(fileName)) {
|
|
151168
151938
|
return true;
|
|
@@ -151174,7 +151944,7 @@ function matchesTier3Pattern(files) {
|
|
|
151174
151944
|
function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
151175
151945
|
let persisted = null;
|
|
151176
151946
|
try {
|
|
151177
|
-
const statePath =
|
|
151947
|
+
const statePath = path202.join(directory, ".swarm", "turbo-state.json");
|
|
151178
151948
|
if (!fs136.existsSync(statePath)) {
|
|
151179
151949
|
return {
|
|
151180
151950
|
ok: false,
|
|
@@ -151258,11 +152028,11 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
|
151258
152028
|
};
|
|
151259
152029
|
}
|
|
151260
152030
|
const phase = runState.phase ?? 0;
|
|
151261
|
-
const evidencePath =
|
|
151262
|
-
const expectedDir =
|
|
151263
|
-
const resolvedPath =
|
|
151264
|
-
const resolvedDir =
|
|
151265
|
-
if (!resolvedPath.startsWith(resolvedDir +
|
|
152031
|
+
const evidencePath = path202.join(directory, ".swarm", "evidence", String(phase), "lean-turbo", `${lane.laneId}.json`);
|
|
152032
|
+
const expectedDir = path202.join(directory, ".swarm", "evidence", String(phase), "lean-turbo");
|
|
152033
|
+
const resolvedPath = path202.resolve(evidencePath);
|
|
152034
|
+
const resolvedDir = path202.resolve(expectedDir);
|
|
152035
|
+
if (!resolvedPath.startsWith(resolvedDir + path202.sep) && resolvedPath !== resolvedDir) {
|
|
151266
152036
|
return {
|
|
151267
152037
|
ok: false,
|
|
151268
152038
|
reason: `Lane ID causes path traversal: ${lane.laneId}`,
|
|
@@ -151302,7 +152072,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
|
151302
152072
|
}
|
|
151303
152073
|
let filesTouched = [];
|
|
151304
152074
|
try {
|
|
151305
|
-
const planPath =
|
|
152075
|
+
const planPath = path202.join(directory, ".swarm", "plan.json");
|
|
151306
152076
|
const planRaw = fs136.readFileSync(planPath, "utf-8");
|
|
151307
152077
|
const plan = JSON.parse(planRaw);
|
|
151308
152078
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -151391,7 +152161,7 @@ var TIER_3_PATTERNS2 = [
|
|
|
151391
152161
|
];
|
|
151392
152162
|
function matchesTier3Pattern2(files) {
|
|
151393
152163
|
for (const file3 of files) {
|
|
151394
|
-
const fileName =
|
|
152164
|
+
const fileName = path203.basename(file3);
|
|
151395
152165
|
for (const pattern of TIER_3_PATTERNS2) {
|
|
151396
152166
|
if (pattern.test(fileName)) {
|
|
151397
152167
|
return true;
|
|
@@ -151430,7 +152200,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
151430
152200
|
if (!skipStandardTurboBypass && hasActiveTurboMode()) {
|
|
151431
152201
|
const resolvedDir2 = workingDirectory;
|
|
151432
152202
|
try {
|
|
151433
|
-
const planPath =
|
|
152203
|
+
const planPath = path203.join(resolvedDir2, ".swarm", "plan.json");
|
|
151434
152204
|
const planRaw = fs137.readFileSync(planPath, "utf-8");
|
|
151435
152205
|
const plan = JSON.parse(planRaw);
|
|
151436
152206
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -151508,7 +152278,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
151508
152278
|
}
|
|
151509
152279
|
if (resolvedDir) {
|
|
151510
152280
|
try {
|
|
151511
|
-
const planPath =
|
|
152281
|
+
const planPath = path203.join(resolvedDir, ".swarm", "plan.json");
|
|
151512
152282
|
const planRaw = fs137.readFileSync(planPath, "utf-8");
|
|
151513
152283
|
const plan = JSON.parse(planRaw);
|
|
151514
152284
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -151719,7 +152489,7 @@ function checkCouncilGate(workingDirectory, taskId) {
|
|
|
151719
152489
|
return { blocked: false, reason: "", active: false };
|
|
151720
152490
|
}
|
|
151721
152491
|
try {
|
|
151722
|
-
const planPath =
|
|
152492
|
+
const planPath = path203.join(workingDirectory, ".swarm", "plan.json");
|
|
151723
152493
|
const planRaw = fs137.readFileSync(planPath, "utf-8");
|
|
151724
152494
|
const planObj = JSON.parse(planRaw);
|
|
151725
152495
|
if (planObj.swarm && planObj.title) {
|
|
@@ -151806,7 +152576,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
151806
152576
|
};
|
|
151807
152577
|
}
|
|
151808
152578
|
directory = resolveResult.directory;
|
|
151809
|
-
const planPath =
|
|
152579
|
+
const planPath = path203.join(directory, ".swarm", "plan.json");
|
|
151810
152580
|
if (!fs137.existsSync(planPath)) {
|
|
151811
152581
|
return {
|
|
151812
152582
|
success: false,
|
|
@@ -151815,9 +152585,9 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
151815
152585
|
};
|
|
151816
152586
|
}
|
|
151817
152587
|
if (fallbackDir && directory !== fallbackDir) {
|
|
151818
|
-
const canonicalDir = fs137.realpathSync(
|
|
151819
|
-
const canonicalRoot = fs137.realpathSync(
|
|
151820
|
-
if (canonicalDir.startsWith(canonicalRoot +
|
|
152588
|
+
const canonicalDir = fs137.realpathSync(path203.resolve(directory));
|
|
152589
|
+
const canonicalRoot = fs137.realpathSync(path203.resolve(fallbackDir));
|
|
152590
|
+
if (canonicalDir.startsWith(canonicalRoot + path203.sep)) {
|
|
151821
152591
|
return {
|
|
151822
152592
|
success: false,
|
|
151823
152593
|
message: `Invalid working_directory: "${directory}" is a subdirectory of ` + `the project root "${fallbackDir}". Pass the project root path or ` + `omit working_directory entirely.`,
|
|
@@ -151829,8 +152599,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
151829
152599
|
}
|
|
151830
152600
|
if (args2.status === "in_progress") {
|
|
151831
152601
|
try {
|
|
151832
|
-
const evidencePath =
|
|
151833
|
-
fs137.mkdirSync(
|
|
152602
|
+
const evidencePath = path203.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
|
|
152603
|
+
fs137.mkdirSync(path203.dirname(evidencePath), { recursive: true });
|
|
151834
152604
|
const fd = fs137.openSync(evidencePath, "wx");
|
|
151835
152605
|
let writeOk = false;
|
|
151836
152606
|
try {
|
|
@@ -151854,7 +152624,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
151854
152624
|
recoverTaskStateFromDelegations(args2.task_id, directory);
|
|
151855
152625
|
let phaseRequiresReviewer = true;
|
|
151856
152626
|
try {
|
|
151857
|
-
const planPath2 =
|
|
152627
|
+
const planPath2 = path203.join(directory, ".swarm", "plan.json");
|
|
151858
152628
|
const planRaw = fs137.readFileSync(planPath2, "utf-8");
|
|
151859
152629
|
const plan = JSON.parse(planRaw);
|
|
151860
152630
|
const taskPhase = plan.phases.find((p) => p.tasks.some((t) => t.id === args2.task_id));
|
|
@@ -151971,9 +152741,9 @@ import * as zlib from "node:zlib";
|
|
|
151971
152741
|
// src/evidence/documents.ts
|
|
151972
152742
|
init_utils2();
|
|
151973
152743
|
init_redaction();
|
|
151974
|
-
import { createHash as
|
|
152744
|
+
import { createHash as createHash25 } from "node:crypto";
|
|
151975
152745
|
import { appendFile as appendFile17, mkdir as mkdir34 } from "node:fs/promises";
|
|
151976
|
-
import * as
|
|
152746
|
+
import * as path204 from "node:path";
|
|
151977
152747
|
var EVIDENCE_CACHE_FILE = "evidence-cache/documents.jsonl";
|
|
151978
152748
|
var MAX_EVIDENCE_TEXT_LENGTH = 4000;
|
|
151979
152749
|
async function writeEvidenceDocuments(directory, inputs, now = () => new Date) {
|
|
@@ -151981,7 +152751,7 @@ async function writeEvidenceDocuments(directory, inputs, now = () => new Date) {
|
|
|
151981
152751
|
const capturedAt = now().toISOString();
|
|
151982
152752
|
const records = inputs.map((input) => createEvidenceDocumentRecord(input, capturedAt)).filter((record3) => record3 !== null);
|
|
151983
152753
|
if (records.length > 0) {
|
|
151984
|
-
await mkdir34(
|
|
152754
|
+
await mkdir34(path204.dirname(filePath), { recursive: true });
|
|
151985
152755
|
await appendFile17(filePath, `${records.map((record3) => JSON.stringify(record3)).join(`
|
|
151986
152756
|
`)}
|
|
151987
152757
|
`, "utf-8");
|
|
@@ -152015,7 +152785,7 @@ function createEvidenceDocumentRecord(input, defaultCapturedAt) {
|
|
|
152015
152785
|
};
|
|
152016
152786
|
}
|
|
152017
152787
|
function createEvidenceDocumentId(input) {
|
|
152018
|
-
const hash4 =
|
|
152788
|
+
const hash4 = createHash25("sha256").update([
|
|
152019
152789
|
input.sourceType,
|
|
152020
152790
|
input.query ?? "",
|
|
152021
152791
|
input.title ?? "",
|
|
@@ -152351,7 +153121,7 @@ function performHttpRequest(args2) {
|
|
|
152351
153121
|
};
|
|
152352
153122
|
if (useSni)
|
|
152353
153123
|
options.servername = url3.hostname;
|
|
152354
|
-
return new Promise((
|
|
153124
|
+
return new Promise((resolve79, reject) => {
|
|
152355
153125
|
let req;
|
|
152356
153126
|
const onResponse = (res) => {
|
|
152357
153127
|
const normHeaders = {};
|
|
@@ -152359,7 +153129,7 @@ function performHttpRequest(args2) {
|
|
|
152359
153129
|
normHeaders[key] = Array.isArray(value) ? value[0] : value;
|
|
152360
153130
|
}
|
|
152361
153131
|
res.on("error", () => {});
|
|
152362
|
-
|
|
153132
|
+
resolve79({
|
|
152363
153133
|
status: res.statusCode ?? 0,
|
|
152364
153134
|
headers: normHeaders,
|
|
152365
153135
|
body: res,
|
|
@@ -152998,7 +153768,7 @@ init_schema3();
|
|
|
152998
153768
|
init_store();
|
|
152999
153769
|
init_create_tool();
|
|
153000
153770
|
init_resolve_working_directory();
|
|
153001
|
-
import * as
|
|
153771
|
+
import * as path205 from "node:path";
|
|
153002
153772
|
var FindingSchema2 = exports_external.object({
|
|
153003
153773
|
severity: exports_external.enum(["low", "medium", "high", "critical"]),
|
|
153004
153774
|
category: exports_external.string().min(1),
|
|
@@ -153074,7 +153844,7 @@ var write_architecture_supervisor_evidence = createSwarmTool({
|
|
|
153074
153844
|
if (config3.architectural_supervision?.persist_knowledge_recommendations && args2.knowledge_recommendations.length > 0) {
|
|
153075
153845
|
const knowledgeConfig = KnowledgeConfigSchema.parse(config3.knowledge ?? {});
|
|
153076
153846
|
const lessons = args2.knowledge_recommendations.map((r) => r.lesson);
|
|
153077
|
-
const result = await curateAndStoreSwarm(lessons,
|
|
153847
|
+
const result = await curateAndStoreSwarm(lessons, path205.basename(dirResult.directory), { phase_number: args2.phase }, dirResult.directory, knowledgeConfig, {
|
|
153078
153848
|
skipAutoPromotion: true,
|
|
153079
153849
|
llmDelegate: createCuratorLLMDelegate(dirResult.directory, "phase"),
|
|
153080
153850
|
enrichmentQuota: {
|
|
@@ -153121,7 +153891,7 @@ init_ledger();
|
|
|
153121
153891
|
init_manager();
|
|
153122
153892
|
init_create_tool();
|
|
153123
153893
|
import fs138 from "node:fs";
|
|
153124
|
-
import
|
|
153894
|
+
import path206 from "node:path";
|
|
153125
153895
|
function normalizeVerdict(verdict) {
|
|
153126
153896
|
switch (verdict) {
|
|
153127
153897
|
case "APPROVED":
|
|
@@ -153175,7 +153945,7 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
153175
153945
|
entries: [evidenceEntry]
|
|
153176
153946
|
};
|
|
153177
153947
|
const filename = "drift-verifier.json";
|
|
153178
|
-
const relativePath =
|
|
153948
|
+
const relativePath = path206.join("evidence", String(phase), filename);
|
|
153179
153949
|
let validatedPath;
|
|
153180
153950
|
try {
|
|
153181
153951
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -153186,10 +153956,10 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
153186
153956
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
153187
153957
|
}, null, 2);
|
|
153188
153958
|
}
|
|
153189
|
-
const evidenceDir =
|
|
153959
|
+
const evidenceDir = path206.dirname(validatedPath);
|
|
153190
153960
|
try {
|
|
153191
153961
|
await fs138.promises.mkdir(evidenceDir, { recursive: true });
|
|
153192
|
-
const tempPath =
|
|
153962
|
+
const tempPath = path206.join(evidenceDir, `.${filename}.tmp`);
|
|
153193
153963
|
await fs138.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
153194
153964
|
await fs138.promises.rename(tempPath, validatedPath);
|
|
153195
153965
|
let snapshotInfo;
|
|
@@ -153290,7 +154060,7 @@ var write_drift_evidence = createSwarmTool({
|
|
|
153290
154060
|
init_zod();
|
|
153291
154061
|
init_loader();
|
|
153292
154062
|
import fs139 from "node:fs";
|
|
153293
|
-
import
|
|
154063
|
+
import path207 from "node:path";
|
|
153294
154064
|
init_utils2();
|
|
153295
154065
|
init_manager();
|
|
153296
154066
|
init_create_tool();
|
|
@@ -153404,7 +154174,7 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
|
|
|
153404
154174
|
timestamp: synthesis.timestamp
|
|
153405
154175
|
};
|
|
153406
154176
|
const filename = "final-council.json";
|
|
153407
|
-
const relativePath =
|
|
154177
|
+
const relativePath = path207.join("evidence", filename);
|
|
153408
154178
|
let validatedPath;
|
|
153409
154179
|
try {
|
|
153410
154180
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -153418,10 +154188,10 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
|
|
|
153418
154188
|
const evidenceContent = {
|
|
153419
154189
|
entries: [evidenceEntry]
|
|
153420
154190
|
};
|
|
153421
|
-
const evidenceDir =
|
|
154191
|
+
const evidenceDir = path207.dirname(validatedPath);
|
|
153422
154192
|
try {
|
|
153423
154193
|
await fs139.promises.mkdir(evidenceDir, { recursive: true });
|
|
153424
|
-
const tempPath =
|
|
154194
|
+
const tempPath = path207.join(evidenceDir, `.${filename}.tmp`);
|
|
153425
154195
|
await fs139.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
153426
154196
|
await fs139.promises.rename(tempPath, validatedPath);
|
|
153427
154197
|
return JSON.stringify({
|
|
@@ -153481,7 +154251,7 @@ init_zod();
|
|
|
153481
154251
|
init_utils2();
|
|
153482
154252
|
init_create_tool();
|
|
153483
154253
|
import fs140 from "node:fs";
|
|
153484
|
-
import
|
|
154254
|
+
import path208 from "node:path";
|
|
153485
154255
|
function normalizeVerdict2(verdict) {
|
|
153486
154256
|
switch (verdict) {
|
|
153487
154257
|
case "APPROVED":
|
|
@@ -153529,7 +154299,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
153529
154299
|
entries: [evidenceEntry]
|
|
153530
154300
|
};
|
|
153531
154301
|
const filename = "hallucination-guard.json";
|
|
153532
|
-
const relativePath =
|
|
154302
|
+
const relativePath = path208.join("evidence", String(phase), filename);
|
|
153533
154303
|
let validatedPath;
|
|
153534
154304
|
try {
|
|
153535
154305
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -153540,10 +154310,10 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
153540
154310
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
153541
154311
|
}, null, 2);
|
|
153542
154312
|
}
|
|
153543
|
-
const evidenceDir =
|
|
154313
|
+
const evidenceDir = path208.dirname(validatedPath);
|
|
153544
154314
|
try {
|
|
153545
154315
|
await fs140.promises.mkdir(evidenceDir, { recursive: true });
|
|
153546
|
-
const tempPath =
|
|
154316
|
+
const tempPath = path208.join(evidenceDir, `.${filename}.tmp`);
|
|
153547
154317
|
await fs140.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
153548
154318
|
await fs140.promises.rename(tempPath, validatedPath);
|
|
153549
154319
|
return JSON.stringify({
|
|
@@ -153593,7 +154363,7 @@ init_zod();
|
|
|
153593
154363
|
init_utils2();
|
|
153594
154364
|
init_create_tool();
|
|
153595
154365
|
import fs141 from "node:fs";
|
|
153596
|
-
import
|
|
154366
|
+
import path209 from "node:path";
|
|
153597
154367
|
function normalizeVerdict3(verdict) {
|
|
153598
154368
|
switch (verdict) {
|
|
153599
154369
|
case "PASS":
|
|
@@ -153667,7 +154437,7 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
153667
154437
|
entries: [evidenceEntry]
|
|
153668
154438
|
};
|
|
153669
154439
|
const filename = "mutation-gate.json";
|
|
153670
|
-
const relativePath =
|
|
154440
|
+
const relativePath = path209.join("evidence", String(phase), filename);
|
|
153671
154441
|
let validatedPath;
|
|
153672
154442
|
try {
|
|
153673
154443
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -153678,10 +154448,10 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
153678
154448
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
153679
154449
|
}, null, 2);
|
|
153680
154450
|
}
|
|
153681
|
-
const evidenceDir =
|
|
154451
|
+
const evidenceDir = path209.dirname(validatedPath);
|
|
153682
154452
|
try {
|
|
153683
154453
|
await fs141.promises.mkdir(evidenceDir, { recursive: true });
|
|
153684
|
-
const tempPath =
|
|
154454
|
+
const tempPath = path209.join(evidenceDir, `.${filename}.tmp`);
|
|
153685
154455
|
await fs141.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
153686
154456
|
await fs141.promises.rename(tempPath, validatedPath);
|
|
153687
154457
|
return JSON.stringify({
|
|
@@ -153760,6 +154530,7 @@ var TOOL_MANIFEST = defineHandlers({
|
|
|
153760
154530
|
sbom_generate: () => sbom_generate,
|
|
153761
154531
|
checkpoint: () => checkpoint,
|
|
153762
154532
|
pkg_audit: () => pkg_audit,
|
|
154533
|
+
parse_lane_candidates: () => parse_lane_candidates,
|
|
153763
154534
|
test_runner: () => test_runner,
|
|
153764
154535
|
test_impact: () => test_impact,
|
|
153765
154536
|
mutation_test: () => mutation_test,
|
|
@@ -153895,7 +154666,7 @@ ${footerLines.join(`
|
|
|
153895
154666
|
init_warning_buffer();
|
|
153896
154667
|
var _heartbeatTimers = new Map;
|
|
153897
154668
|
var SWARM_COMMAND_SYSTEM_RULE_TAG = "[opencode-swarm:swarm-command-rule]";
|
|
153898
|
-
var PACKAGE_ROOT2 =
|
|
154669
|
+
var PACKAGE_ROOT2 = path211.resolve(path211.dirname(fileURLToPath5(import.meta.url)), "..");
|
|
153899
154670
|
var SYNC_BUNDLED_SKILLS_TIMEOUT_MS = 2000;
|
|
153900
154671
|
function createSwarmCommandSystemRuleHook(agentDefinitions, registeredAgents) {
|
|
153901
154672
|
return async (input, output) => {
|
|
@@ -154216,7 +154987,7 @@ async function initializeOpenCodeSwarm(ctx) {
|
|
|
154216
154987
|
const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
|
|
154217
154988
|
preflightTriggerManager = new PTM(automationConfig);
|
|
154218
154989
|
const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
|
|
154219
|
-
const swarmDir =
|
|
154990
|
+
const swarmDir = path211.resolve(ctx.directory, ".swarm");
|
|
154220
154991
|
statusArtifact = new ASA(swarmDir);
|
|
154221
154992
|
statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
|
|
154222
154993
|
if (automationConfig.capabilities?.evidence_auto_summaries === true) {
|
|
@@ -154880,7 +155651,7 @@ ${promptRaw}`;
|
|
|
154880
155651
|
const meta3 = readSkillMetadata(s.skillPath, ctx.directory);
|
|
154881
155652
|
let desc = meta3.description || "";
|
|
154882
155653
|
if (!desc || desc === "No description provided") {
|
|
154883
|
-
desc =
|
|
155654
|
+
desc = path211.basename(path211.dirname(s.skillPath));
|
|
154884
155655
|
}
|
|
154885
155656
|
desc = desc.replace(/,/g, ";");
|
|
154886
155657
|
return `file:${s.skillPath} (-- ${desc})`;
|
|
@@ -154890,7 +155661,7 @@ ${promptRaw}`;
|
|
|
154890
155661
|
|
|
154891
155662
|
${promptRaw}`;
|
|
154892
155663
|
argsRecord.prompt = newPrompt;
|
|
154893
|
-
const skillNames = topSkills.map((s) => `${
|
|
155664
|
+
const skillNames = topSkills.map((s) => `${path211.basename(s.skillPath)} (score: ${s.score.toFixed(2)})`).join(", ");
|
|
154894
155665
|
console.warn(`[skill-propagation-gate] Injected skills: ${skillNames}`);
|
|
154895
155666
|
for (const skill of topSkills) {
|
|
154896
155667
|
try {
|