opencode-swarm 6.86.8 → 6.86.9
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/dist/cli/index.js +277 -217
- package/dist/config/cache-paths.d.ts +11 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +688 -640
- package/dist/services/diagnose-service.d.ts +1 -1
- package/package.json +1 -1
- package/dist/tools/check-gate-status.prefix.test.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var package_default;
|
|
|
33
33
|
var init_package = __esm(() => {
|
|
34
34
|
package_default = {
|
|
35
35
|
name: "opencode-swarm",
|
|
36
|
-
version: "6.86.
|
|
36
|
+
version: "6.86.9",
|
|
37
37
|
description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
38
38
|
main: "dist/index.js",
|
|
39
39
|
types: "dist/index.d.ts",
|
|
@@ -43890,24 +43890,41 @@ var init_dark_matter = __esm(() => {
|
|
|
43890
43890
|
init_co_change_analyzer();
|
|
43891
43891
|
});
|
|
43892
43892
|
|
|
43893
|
+
// src/config/cache-paths.ts
|
|
43894
|
+
import * as os5 from "node:os";
|
|
43895
|
+
import * as path24 from "node:path";
|
|
43896
|
+
function getPluginConfigDir() {
|
|
43897
|
+
return path24.join(process.env.XDG_CONFIG_HOME || path24.join(os5.homedir(), ".config"), "opencode");
|
|
43898
|
+
}
|
|
43899
|
+
function getPluginCachePaths() {
|
|
43900
|
+
const cacheBase = process.env.XDG_CACHE_HOME || path24.join(os5.homedir(), ".cache");
|
|
43901
|
+
const configDir = getPluginConfigDir();
|
|
43902
|
+
return [
|
|
43903
|
+
path24.join(cacheBase, "opencode", "packages", "opencode-swarm@latest"),
|
|
43904
|
+
path24.join(configDir, "node_modules", "opencode-swarm"),
|
|
43905
|
+
path24.join(cacheBase, "opencode", "node_modules", "opencode-swarm")
|
|
43906
|
+
];
|
|
43907
|
+
}
|
|
43908
|
+
var init_cache_paths = () => {};
|
|
43909
|
+
|
|
43893
43910
|
// src/services/version-check.ts
|
|
43894
43911
|
import { existsSync as existsSync11, mkdirSync as mkdirSync11, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "node:fs";
|
|
43895
|
-
import { homedir as
|
|
43896
|
-
import { join as
|
|
43912
|
+
import { homedir as homedir5 } from "node:os";
|
|
43913
|
+
import { join as join22 } from "node:path";
|
|
43897
43914
|
function cacheDir() {
|
|
43898
43915
|
const xdg = process.env.XDG_CACHE_HOME;
|
|
43899
|
-
const base = xdg && xdg.length > 0 ? xdg :
|
|
43900
|
-
return
|
|
43916
|
+
const base = xdg && xdg.length > 0 ? xdg : join22(homedir5(), ".cache");
|
|
43917
|
+
return join22(base, "opencode-swarm");
|
|
43901
43918
|
}
|
|
43902
43919
|
function cacheFile() {
|
|
43903
|
-
return
|
|
43920
|
+
return join22(cacheDir(), "version-check.json");
|
|
43904
43921
|
}
|
|
43905
43922
|
function readVersionCache() {
|
|
43906
43923
|
try {
|
|
43907
|
-
const
|
|
43908
|
-
if (!existsSync11(
|
|
43924
|
+
const path25 = cacheFile();
|
|
43925
|
+
if (!existsSync11(path25))
|
|
43909
43926
|
return null;
|
|
43910
|
-
const raw = readFileSync6(
|
|
43927
|
+
const raw = readFileSync6(path25, "utf-8");
|
|
43911
43928
|
const parsed = JSON.parse(raw);
|
|
43912
43929
|
if (typeof parsed?.checkedAt !== "number")
|
|
43913
43930
|
return null;
|
|
@@ -44005,7 +44022,7 @@ var init_version_check = __esm(() => {
|
|
|
44005
44022
|
// src/services/diagnose-service.ts
|
|
44006
44023
|
import * as child_process4 from "node:child_process";
|
|
44007
44024
|
import { existsSync as existsSync12, readdirSync as readdirSync4, readFileSync as readFileSync7, statSync as statSync6 } from "node:fs";
|
|
44008
|
-
import
|
|
44025
|
+
import path25 from "node:path";
|
|
44009
44026
|
import { fileURLToPath } from "node:url";
|
|
44010
44027
|
function validateTaskDag(plan) {
|
|
44011
44028
|
const allTaskIds = new Set;
|
|
@@ -44302,7 +44319,7 @@ async function checkSpecStaleness(directory, plan) {
|
|
|
44302
44319
|
};
|
|
44303
44320
|
}
|
|
44304
44321
|
async function checkConfigParseability(directory) {
|
|
44305
|
-
const configPath =
|
|
44322
|
+
const configPath = path25.join(directory, ".opencode/opencode-swarm.json");
|
|
44306
44323
|
if (!existsSync12(configPath)) {
|
|
44307
44324
|
return {
|
|
44308
44325
|
name: "Config Parseability",
|
|
@@ -44331,7 +44348,7 @@ function resolveGrammarDir(thisDir) {
|
|
|
44331
44348
|
const normalized = thisDir.replace(/\\/g, "/");
|
|
44332
44349
|
const isSource = normalized.endsWith("/src/services");
|
|
44333
44350
|
const isCliBundle = normalized.endsWith("/cli");
|
|
44334
|
-
return isSource || isCliBundle ?
|
|
44351
|
+
return isSource || isCliBundle ? path25.join(thisDir, "..", "lang", "grammars") : path25.join(thisDir, "lang", "grammars");
|
|
44335
44352
|
}
|
|
44336
44353
|
async function checkGrammarWasmFiles() {
|
|
44337
44354
|
const grammarFiles = [
|
|
@@ -44355,14 +44372,14 @@ async function checkGrammarWasmFiles() {
|
|
|
44355
44372
|
"tree-sitter-ini.wasm",
|
|
44356
44373
|
"tree-sitter-regex.wasm"
|
|
44357
44374
|
];
|
|
44358
|
-
const thisDir =
|
|
44375
|
+
const thisDir = path25.dirname(fileURLToPath(import.meta.url));
|
|
44359
44376
|
const grammarDir = resolveGrammarDir(thisDir);
|
|
44360
44377
|
const missing = [];
|
|
44361
|
-
if (!existsSync12(
|
|
44378
|
+
if (!existsSync12(path25.join(grammarDir, "tree-sitter.wasm"))) {
|
|
44362
44379
|
missing.push("tree-sitter.wasm (core runtime)");
|
|
44363
44380
|
}
|
|
44364
44381
|
for (const file3 of grammarFiles) {
|
|
44365
|
-
if (!existsSync12(
|
|
44382
|
+
if (!existsSync12(path25.join(grammarDir, file3))) {
|
|
44366
44383
|
missing.push(file3);
|
|
44367
44384
|
}
|
|
44368
44385
|
}
|
|
@@ -44380,7 +44397,7 @@ async function checkGrammarWasmFiles() {
|
|
|
44380
44397
|
};
|
|
44381
44398
|
}
|
|
44382
44399
|
async function checkCheckpointManifest(directory) {
|
|
44383
|
-
const manifestPath =
|
|
44400
|
+
const manifestPath = path25.join(directory, ".swarm/checkpoints.json");
|
|
44384
44401
|
if (!existsSync12(manifestPath)) {
|
|
44385
44402
|
return {
|
|
44386
44403
|
name: "Checkpoint Manifest",
|
|
@@ -44432,7 +44449,7 @@ async function checkCheckpointManifest(directory) {
|
|
|
44432
44449
|
}
|
|
44433
44450
|
}
|
|
44434
44451
|
async function checkEventStreamIntegrity(directory) {
|
|
44435
|
-
const eventsPath =
|
|
44452
|
+
const eventsPath = path25.join(directory, ".swarm/events.jsonl");
|
|
44436
44453
|
if (!existsSync12(eventsPath)) {
|
|
44437
44454
|
return {
|
|
44438
44455
|
name: "Event Stream",
|
|
@@ -44473,7 +44490,7 @@ async function checkEventStreamIntegrity(directory) {
|
|
|
44473
44490
|
}
|
|
44474
44491
|
}
|
|
44475
44492
|
async function checkSteeringDirectives(directory) {
|
|
44476
|
-
const eventsPath =
|
|
44493
|
+
const eventsPath = path25.join(directory, ".swarm/events.jsonl");
|
|
44477
44494
|
if (!existsSync12(eventsPath)) {
|
|
44478
44495
|
return {
|
|
44479
44496
|
name: "Steering Directives",
|
|
@@ -44529,7 +44546,7 @@ async function checkCurator(directory) {
|
|
|
44529
44546
|
detail: "Disabled (enable via curator.enabled)"
|
|
44530
44547
|
};
|
|
44531
44548
|
}
|
|
44532
|
-
const summaryPath =
|
|
44549
|
+
const summaryPath = path25.join(directory, ".swarm/curator-summary.json");
|
|
44533
44550
|
if (!existsSync12(summaryPath)) {
|
|
44534
44551
|
return {
|
|
44535
44552
|
name: "Curator",
|
|
@@ -44695,7 +44712,7 @@ async function getDiagnoseData(directory) {
|
|
|
44695
44712
|
checks5.push(await checkSteeringDirectives(directory));
|
|
44696
44713
|
checks5.push(await checkCurator(directory));
|
|
44697
44714
|
try {
|
|
44698
|
-
const evidenceDir =
|
|
44715
|
+
const evidenceDir = path25.join(directory, ".swarm", "evidence");
|
|
44699
44716
|
const snapshotFiles = existsSync12(evidenceDir) ? readdirSync4(evidenceDir).filter((f) => f.startsWith("agent-tools-") && f.endsWith(".json")) : [];
|
|
44700
44717
|
if (snapshotFiles.length > 0) {
|
|
44701
44718
|
const latest = snapshotFiles.sort().pop();
|
|
@@ -44725,7 +44742,36 @@ async function getDiagnoseData(directory) {
|
|
|
44725
44742
|
detail: `${deferredWarnings.length} warning(s) deferred from init (run with verbose logs for details)`
|
|
44726
44743
|
});
|
|
44727
44744
|
}
|
|
44728
|
-
const
|
|
44745
|
+
const cachePaths = getPluginCachePaths();
|
|
44746
|
+
const cacheRows = [];
|
|
44747
|
+
for (const cachePath of cachePaths) {
|
|
44748
|
+
try {
|
|
44749
|
+
if (!existsSync12(cachePath)) {
|
|
44750
|
+
cacheRows.push(`⬜ ${cachePath} — absent`);
|
|
44751
|
+
continue;
|
|
44752
|
+
}
|
|
44753
|
+
const pkgJsonPath = path25.join(cachePath, "package.json");
|
|
44754
|
+
try {
|
|
44755
|
+
const raw = readFileSync7(pkgJsonPath, "utf-8");
|
|
44756
|
+
const parsed = JSON.parse(raw);
|
|
44757
|
+
const installedVersion = typeof parsed.version === "string" ? parsed.version : "?";
|
|
44758
|
+
cacheRows.push(`✅ ${cachePath} — v${installedVersion}`);
|
|
44759
|
+
} catch {
|
|
44760
|
+
cacheRows.push(`⚠️ ${cachePath} — present (package.json unreadable)`);
|
|
44761
|
+
}
|
|
44762
|
+
} catch {
|
|
44763
|
+
cacheRows.push(`⚠️ ${cachePath} — status unknown (read error)`);
|
|
44764
|
+
}
|
|
44765
|
+
}
|
|
44766
|
+
const hasCacheEntry = cacheRows.some((r) => r.startsWith("✅"));
|
|
44767
|
+
const hasCacheWarning = cacheRows.some((r) => r.startsWith("⚠️"));
|
|
44768
|
+
const cacheStatus = hasCacheWarning ? "⚠️" : hasCacheEntry ? "✅" : "⬜";
|
|
44769
|
+
checks5.push({
|
|
44770
|
+
name: "Plugin Caches",
|
|
44771
|
+
status: cacheStatus,
|
|
44772
|
+
detail: cacheRows.join(" | ")
|
|
44773
|
+
});
|
|
44774
|
+
const passCount = checks5.filter((c) => c.status === "✅" || c.status === "⬜").length;
|
|
44729
44775
|
const totalCount = checks5.length;
|
|
44730
44776
|
const allPassed = passCount === totalCount;
|
|
44731
44777
|
return {
|
|
@@ -44761,6 +44807,7 @@ async function handleDiagnoseCommand(directory, _args) {
|
|
|
44761
44807
|
var version3;
|
|
44762
44808
|
var init_diagnose_service = __esm(() => {
|
|
44763
44809
|
init_package();
|
|
44810
|
+
init_cache_paths();
|
|
44764
44811
|
init_loader();
|
|
44765
44812
|
init_manager2();
|
|
44766
44813
|
init_utils2();
|
|
@@ -44790,14 +44837,14 @@ __export(exports_config_doctor, {
|
|
|
44790
44837
|
});
|
|
44791
44838
|
import * as crypto3 from "node:crypto";
|
|
44792
44839
|
import * as fs14 from "node:fs";
|
|
44793
|
-
import * as
|
|
44794
|
-
import * as
|
|
44840
|
+
import * as os6 from "node:os";
|
|
44841
|
+
import * as path26 from "node:path";
|
|
44795
44842
|
function getUserConfigDir3() {
|
|
44796
|
-
return process.env.XDG_CONFIG_HOME ||
|
|
44843
|
+
return process.env.XDG_CONFIG_HOME || path26.join(os6.homedir(), ".config");
|
|
44797
44844
|
}
|
|
44798
44845
|
function getConfigPaths(directory) {
|
|
44799
|
-
const userConfigPath =
|
|
44800
|
-
const projectConfigPath =
|
|
44846
|
+
const userConfigPath = path26.join(getUserConfigDir3(), "opencode", "opencode-swarm.json");
|
|
44847
|
+
const projectConfigPath = path26.join(directory, ".opencode", "opencode-swarm.json");
|
|
44801
44848
|
return { userConfigPath, projectConfigPath };
|
|
44802
44849
|
}
|
|
44803
44850
|
function computeHash(content) {
|
|
@@ -44822,9 +44869,9 @@ function isValidConfigPath(configPath, directory) {
|
|
|
44822
44869
|
const normalizedUser = userConfigPath.replace(/\\/g, "/");
|
|
44823
44870
|
const normalizedProject = projectConfigPath.replace(/\\/g, "/");
|
|
44824
44871
|
try {
|
|
44825
|
-
const resolvedConfig =
|
|
44826
|
-
const resolvedUser =
|
|
44827
|
-
const resolvedProject =
|
|
44872
|
+
const resolvedConfig = path26.resolve(configPath);
|
|
44873
|
+
const resolvedUser = path26.resolve(normalizedUser);
|
|
44874
|
+
const resolvedProject = path26.resolve(normalizedProject);
|
|
44828
44875
|
return resolvedConfig === resolvedUser || resolvedConfig === resolvedProject;
|
|
44829
44876
|
} catch {
|
|
44830
44877
|
return false;
|
|
@@ -44864,12 +44911,12 @@ function createConfigBackup(directory) {
|
|
|
44864
44911
|
};
|
|
44865
44912
|
}
|
|
44866
44913
|
function writeBackupArtifact(directory, backup) {
|
|
44867
|
-
const swarmDir =
|
|
44914
|
+
const swarmDir = path26.join(directory, ".swarm");
|
|
44868
44915
|
if (!fs14.existsSync(swarmDir)) {
|
|
44869
44916
|
fs14.mkdirSync(swarmDir, { recursive: true });
|
|
44870
44917
|
}
|
|
44871
44918
|
const backupFilename = `config-backup-${backup.createdAt}.json`;
|
|
44872
|
-
const backupPath =
|
|
44919
|
+
const backupPath = path26.join(swarmDir, backupFilename);
|
|
44873
44920
|
const artifact = {
|
|
44874
44921
|
createdAt: backup.createdAt,
|
|
44875
44922
|
configPath: backup.configPath,
|
|
@@ -44899,7 +44946,7 @@ function restoreFromBackup(backupPath, directory) {
|
|
|
44899
44946
|
return null;
|
|
44900
44947
|
}
|
|
44901
44948
|
const targetPath = artifact.configPath;
|
|
44902
|
-
const targetDir =
|
|
44949
|
+
const targetDir = path26.dirname(targetPath);
|
|
44903
44950
|
if (!fs14.existsSync(targetDir)) {
|
|
44904
44951
|
fs14.mkdirSync(targetDir, { recursive: true });
|
|
44905
44952
|
}
|
|
@@ -44930,9 +44977,9 @@ function readConfigFromFile(directory) {
|
|
|
44930
44977
|
return null;
|
|
44931
44978
|
}
|
|
44932
44979
|
}
|
|
44933
|
-
function validateConfigKey(
|
|
44980
|
+
function validateConfigKey(path27, value, _config) {
|
|
44934
44981
|
const findings = [];
|
|
44935
|
-
switch (
|
|
44982
|
+
switch (path27) {
|
|
44936
44983
|
case "agents": {
|
|
44937
44984
|
if (value !== undefined) {
|
|
44938
44985
|
findings.push({
|
|
@@ -45179,27 +45226,27 @@ function validateConfigKey(path26, value, _config) {
|
|
|
45179
45226
|
}
|
|
45180
45227
|
return findings;
|
|
45181
45228
|
}
|
|
45182
|
-
function walkConfigAndValidate(obj,
|
|
45229
|
+
function walkConfigAndValidate(obj, path27, config3, findings) {
|
|
45183
45230
|
if (obj === null || obj === undefined) {
|
|
45184
45231
|
return;
|
|
45185
45232
|
}
|
|
45186
|
-
if (
|
|
45187
|
-
const keyFindings = validateConfigKey(
|
|
45233
|
+
if (path27 && typeof obj === "object" && !Array.isArray(obj)) {
|
|
45234
|
+
const keyFindings = validateConfigKey(path27, obj, config3);
|
|
45188
45235
|
findings.push(...keyFindings);
|
|
45189
45236
|
}
|
|
45190
45237
|
if (typeof obj !== "object") {
|
|
45191
|
-
const keyFindings = validateConfigKey(
|
|
45238
|
+
const keyFindings = validateConfigKey(path27, obj, config3);
|
|
45192
45239
|
findings.push(...keyFindings);
|
|
45193
45240
|
return;
|
|
45194
45241
|
}
|
|
45195
45242
|
if (Array.isArray(obj)) {
|
|
45196
45243
|
obj.forEach((item, index) => {
|
|
45197
|
-
walkConfigAndValidate(item, `${
|
|
45244
|
+
walkConfigAndValidate(item, `${path27}[${index}]`, config3, findings);
|
|
45198
45245
|
});
|
|
45199
45246
|
return;
|
|
45200
45247
|
}
|
|
45201
45248
|
for (const [key, value] of Object.entries(obj)) {
|
|
45202
|
-
const newPath =
|
|
45249
|
+
const newPath = path27 ? `${path27}.${key}` : key;
|
|
45203
45250
|
walkConfigAndValidate(value, newPath, config3, findings);
|
|
45204
45251
|
}
|
|
45205
45252
|
}
|
|
@@ -45319,7 +45366,7 @@ function applySafeAutoFixes(directory, result) {
|
|
|
45319
45366
|
}
|
|
45320
45367
|
}
|
|
45321
45368
|
if (appliedFixes.length > 0) {
|
|
45322
|
-
const configDir =
|
|
45369
|
+
const configDir = path26.dirname(configPath);
|
|
45323
45370
|
if (!fs14.existsSync(configDir)) {
|
|
45324
45371
|
fs14.mkdirSync(configDir, { recursive: true });
|
|
45325
45372
|
}
|
|
@@ -45329,12 +45376,12 @@ function applySafeAutoFixes(directory, result) {
|
|
|
45329
45376
|
return { appliedFixes, updatedConfigPath };
|
|
45330
45377
|
}
|
|
45331
45378
|
function writeDoctorArtifact(directory, result) {
|
|
45332
|
-
const swarmDir =
|
|
45379
|
+
const swarmDir = path26.join(directory, ".swarm");
|
|
45333
45380
|
if (!fs14.existsSync(swarmDir)) {
|
|
45334
45381
|
fs14.mkdirSync(swarmDir, { recursive: true });
|
|
45335
45382
|
}
|
|
45336
45383
|
const artifactFilename = "config-doctor.json";
|
|
45337
|
-
const artifactPath =
|
|
45384
|
+
const artifactPath = path26.join(swarmDir, artifactFilename);
|
|
45338
45385
|
const guiOutput = {
|
|
45339
45386
|
timestamp: result.timestamp,
|
|
45340
45387
|
summary: result.summary,
|
|
@@ -46381,7 +46428,7 @@ var init_profiles = __esm(() => {
|
|
|
46381
46428
|
|
|
46382
46429
|
// src/lang/detector.ts
|
|
46383
46430
|
import { access as access2, readdir as readdir3 } from "node:fs/promises";
|
|
46384
|
-
import { extname as extname2, join as
|
|
46431
|
+
import { extname as extname2, join as join24 } from "node:path";
|
|
46385
46432
|
function getProfileForFile(filePath) {
|
|
46386
46433
|
const ext = extname2(filePath);
|
|
46387
46434
|
if (!ext)
|
|
@@ -46403,7 +46450,7 @@ async function detectProjectLanguages(projectDir) {
|
|
|
46403
46450
|
if (detectFile.includes("*") || detectFile.includes("?"))
|
|
46404
46451
|
continue;
|
|
46405
46452
|
try {
|
|
46406
|
-
await access2(
|
|
46453
|
+
await access2(join24(dir, detectFile));
|
|
46407
46454
|
detected.add(profile.id);
|
|
46408
46455
|
break;
|
|
46409
46456
|
} catch {}
|
|
@@ -46424,7 +46471,7 @@ async function detectProjectLanguages(projectDir) {
|
|
|
46424
46471
|
const topEntries = await readdir3(projectDir, { withFileTypes: true });
|
|
46425
46472
|
for (const entry of topEntries) {
|
|
46426
46473
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
|
|
46427
|
-
await scanDir(
|
|
46474
|
+
await scanDir(join24(projectDir, entry.name));
|
|
46428
46475
|
}
|
|
46429
46476
|
}
|
|
46430
46477
|
} catch {}
|
|
@@ -46443,7 +46490,7 @@ var init_detector = __esm(() => {
|
|
|
46443
46490
|
|
|
46444
46491
|
// src/build/discovery.ts
|
|
46445
46492
|
import * as fs15 from "node:fs";
|
|
46446
|
-
import * as
|
|
46493
|
+
import * as path27 from "node:path";
|
|
46447
46494
|
function isCommandAvailable(command) {
|
|
46448
46495
|
if (toolchainCache.has(command)) {
|
|
46449
46496
|
return toolchainCache.get(command);
|
|
@@ -46476,11 +46523,11 @@ function findBuildFiles(workingDir, patterns) {
|
|
|
46476
46523
|
const regex = simpleGlobToRegex(pattern);
|
|
46477
46524
|
const matches = files.filter((f) => regex.test(f));
|
|
46478
46525
|
if (matches.length > 0) {
|
|
46479
|
-
return
|
|
46526
|
+
return path27.join(dir, matches[0]);
|
|
46480
46527
|
}
|
|
46481
46528
|
} catch {}
|
|
46482
46529
|
} else {
|
|
46483
|
-
const filePath =
|
|
46530
|
+
const filePath = path27.join(workingDir, pattern);
|
|
46484
46531
|
if (fs15.existsSync(filePath)) {
|
|
46485
46532
|
return filePath;
|
|
46486
46533
|
}
|
|
@@ -46489,7 +46536,7 @@ function findBuildFiles(workingDir, patterns) {
|
|
|
46489
46536
|
return null;
|
|
46490
46537
|
}
|
|
46491
46538
|
function getRepoDefinedScripts(workingDir, scripts) {
|
|
46492
|
-
const packageJsonPath =
|
|
46539
|
+
const packageJsonPath = path27.join(workingDir, "package.json");
|
|
46493
46540
|
if (!fs15.existsSync(packageJsonPath)) {
|
|
46494
46541
|
return [];
|
|
46495
46542
|
}
|
|
@@ -46530,7 +46577,7 @@ function findAllBuildFiles(workingDir) {
|
|
|
46530
46577
|
const regex = simpleGlobToRegex(pattern);
|
|
46531
46578
|
findFilesRecursive(workingDir, regex, allBuildFiles);
|
|
46532
46579
|
} else {
|
|
46533
|
-
const filePath =
|
|
46580
|
+
const filePath = path27.join(workingDir, pattern);
|
|
46534
46581
|
if (fs15.existsSync(filePath)) {
|
|
46535
46582
|
allBuildFiles.add(filePath);
|
|
46536
46583
|
}
|
|
@@ -46543,7 +46590,7 @@ function findFilesRecursive(dir, regex, results) {
|
|
|
46543
46590
|
try {
|
|
46544
46591
|
const entries = fs15.readdirSync(dir, { withFileTypes: true });
|
|
46545
46592
|
for (const entry of entries) {
|
|
46546
|
-
const fullPath =
|
|
46593
|
+
const fullPath = path27.join(dir, entry.name);
|
|
46547
46594
|
if (entry.isDirectory() && !["node_modules", ".git", "dist", "build", "target"].includes(entry.name)) {
|
|
46548
46595
|
findFilesRecursive(fullPath, regex, results);
|
|
46549
46596
|
} else if (entry.isFile() && regex.test(entry.name)) {
|
|
@@ -46566,7 +46613,7 @@ async function discoverBuildCommandsFromProfiles(workingDir) {
|
|
|
46566
46613
|
let foundCommand = false;
|
|
46567
46614
|
for (const cmd of sortedCommands) {
|
|
46568
46615
|
if (cmd.detectFile) {
|
|
46569
|
-
const detectFilePath =
|
|
46616
|
+
const detectFilePath = path27.join(workingDir, cmd.detectFile);
|
|
46570
46617
|
if (!fs15.existsSync(detectFilePath)) {
|
|
46571
46618
|
continue;
|
|
46572
46619
|
}
|
|
@@ -46797,7 +46844,7 @@ __export(exports_tool_doctor, {
|
|
|
46797
46844
|
getBinaryReadinessAdvisory: () => getBinaryReadinessAdvisory
|
|
46798
46845
|
});
|
|
46799
46846
|
import * as fs16 from "node:fs";
|
|
46800
|
-
import * as
|
|
46847
|
+
import * as path28 from "node:path";
|
|
46801
46848
|
function extractRegisteredToolKeys(indexPath) {
|
|
46802
46849
|
const registeredKeys = new Set;
|
|
46803
46850
|
try {
|
|
@@ -46864,8 +46911,8 @@ function getBinaryReadinessAdvisory() {
|
|
|
46864
46911
|
}
|
|
46865
46912
|
function runToolDoctor(_directory, pluginRoot) {
|
|
46866
46913
|
const findings = [];
|
|
46867
|
-
const resolvedPluginRoot = pluginRoot ??
|
|
46868
|
-
const indexPath =
|
|
46914
|
+
const resolvedPluginRoot = pluginRoot ?? path28.resolve(import.meta.dir, "..", "..");
|
|
46915
|
+
const indexPath = path28.join(resolvedPluginRoot, "src", "index.ts");
|
|
46869
46916
|
if (!fs16.existsSync(indexPath)) {
|
|
46870
46917
|
return {
|
|
46871
46918
|
findings: [
|
|
@@ -48123,10 +48170,10 @@ var init_history = __esm(() => {
|
|
|
48123
48170
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
48124
48171
|
import { existsSync as existsSync16, readFileSync as readFileSync11 } from "node:fs";
|
|
48125
48172
|
import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile5 } from "node:fs/promises";
|
|
48126
|
-
import * as
|
|
48173
|
+
import * as path29 from "node:path";
|
|
48127
48174
|
async function migrateContextToKnowledge(directory, config3) {
|
|
48128
|
-
const sentinelPath =
|
|
48129
|
-
const contextPath =
|
|
48175
|
+
const sentinelPath = path29.join(directory, ".swarm", ".knowledge-migrated");
|
|
48176
|
+
const contextPath = path29.join(directory, ".swarm", "context.md");
|
|
48130
48177
|
const knowledgePath = resolveSwarmKnowledgePath(directory);
|
|
48131
48178
|
if (existsSync16(sentinelPath)) {
|
|
48132
48179
|
return {
|
|
@@ -48322,7 +48369,7 @@ function truncateLesson(text) {
|
|
|
48322
48369
|
return `${text.slice(0, 277)}...`;
|
|
48323
48370
|
}
|
|
48324
48371
|
function inferProjectName(directory) {
|
|
48325
|
-
const packageJsonPath =
|
|
48372
|
+
const packageJsonPath = path29.join(directory, "package.json");
|
|
48326
48373
|
if (existsSync16(packageJsonPath)) {
|
|
48327
48374
|
try {
|
|
48328
48375
|
const pkg = JSON.parse(readFileSync11(packageJsonPath, "utf-8"));
|
|
@@ -48331,7 +48378,7 @@ function inferProjectName(directory) {
|
|
|
48331
48378
|
}
|
|
48332
48379
|
} catch {}
|
|
48333
48380
|
}
|
|
48334
|
-
return
|
|
48381
|
+
return path29.basename(directory);
|
|
48335
48382
|
}
|
|
48336
48383
|
async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
48337
48384
|
const sentinel = {
|
|
@@ -48343,7 +48390,7 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
|
48343
48390
|
schema_version: 1,
|
|
48344
48391
|
migration_tool: "knowledge-migrator.ts"
|
|
48345
48392
|
};
|
|
48346
|
-
await mkdir5(
|
|
48393
|
+
await mkdir5(path29.dirname(sentinelPath), { recursive: true });
|
|
48347
48394
|
await writeFile5(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
|
|
48348
48395
|
}
|
|
48349
48396
|
var init_knowledge_migrator = __esm(() => {
|
|
@@ -48596,7 +48643,7 @@ var init_plan = __esm(() => {
|
|
|
48596
48643
|
|
|
48597
48644
|
// src/utils/path-security.ts
|
|
48598
48645
|
import * as fs17 from "node:fs";
|
|
48599
|
-
import * as
|
|
48646
|
+
import * as path30 from "node:path";
|
|
48600
48647
|
function containsPathTraversal(str) {
|
|
48601
48648
|
if (/\.\.[/\\]/.test(str))
|
|
48602
48649
|
return true;
|
|
@@ -48647,17 +48694,17 @@ function validateSymlinkBoundary(targetPath, rootPath) {
|
|
|
48647
48694
|
try {
|
|
48648
48695
|
realTarget = fs17.realpathSync(targetPath);
|
|
48649
48696
|
} catch {
|
|
48650
|
-
realTarget =
|
|
48697
|
+
realTarget = path30.normalize(targetPath);
|
|
48651
48698
|
}
|
|
48652
48699
|
let realRoot;
|
|
48653
48700
|
try {
|
|
48654
48701
|
realRoot = fs17.realpathSync(rootPath);
|
|
48655
48702
|
} catch {
|
|
48656
|
-
realRoot =
|
|
48703
|
+
realRoot = path30.normalize(rootPath);
|
|
48657
48704
|
}
|
|
48658
|
-
const normalizedTarget =
|
|
48659
|
-
const normalizedRoot =
|
|
48660
|
-
if (!normalizedTarget.startsWith(normalizedRoot +
|
|
48705
|
+
const normalizedTarget = path30.normalize(realTarget);
|
|
48706
|
+
const normalizedRoot = path30.normalize(realRoot);
|
|
48707
|
+
if (!normalizedTarget.startsWith(normalizedRoot + path30.sep) && normalizedTarget !== normalizedRoot) {
|
|
48661
48708
|
throw new Error(`Symlink resolution escaped boundary: ${realTarget} is not within ${realRoot}`);
|
|
48662
48709
|
}
|
|
48663
48710
|
}
|
|
@@ -48665,7 +48712,7 @@ var init_path_security = () => {};
|
|
|
48665
48712
|
|
|
48666
48713
|
// src/tools/lint.ts
|
|
48667
48714
|
import * as fs18 from "node:fs";
|
|
48668
|
-
import * as
|
|
48715
|
+
import * as path31 from "node:path";
|
|
48669
48716
|
function validateArgs(args2) {
|
|
48670
48717
|
if (typeof args2 !== "object" || args2 === null)
|
|
48671
48718
|
return false;
|
|
@@ -48676,9 +48723,9 @@ function validateArgs(args2) {
|
|
|
48676
48723
|
}
|
|
48677
48724
|
function getLinterCommand(linter, mode, projectDir) {
|
|
48678
48725
|
const isWindows = process.platform === "win32";
|
|
48679
|
-
const binDir =
|
|
48680
|
-
const biomeBin = isWindows ?
|
|
48681
|
-
const eslintBin = isWindows ?
|
|
48726
|
+
const binDir = path31.join(projectDir, "node_modules", ".bin");
|
|
48727
|
+
const biomeBin = isWindows ? path31.join(binDir, "biome.EXE") : path31.join(binDir, "biome");
|
|
48728
|
+
const eslintBin = isWindows ? path31.join(binDir, "eslint.cmd") : path31.join(binDir, "eslint");
|
|
48682
48729
|
switch (linter) {
|
|
48683
48730
|
case "biome":
|
|
48684
48731
|
if (mode === "fix") {
|
|
@@ -48694,7 +48741,7 @@ function getLinterCommand(linter, mode, projectDir) {
|
|
|
48694
48741
|
}
|
|
48695
48742
|
function getAdditionalLinterCommand(linter, mode, cwd) {
|
|
48696
48743
|
const gradlewName = process.platform === "win32" ? "gradlew.bat" : "gradlew";
|
|
48697
|
-
const gradlew = fs18.existsSync(
|
|
48744
|
+
const gradlew = fs18.existsSync(path31.join(cwd, gradlewName)) ? path31.join(cwd, gradlewName) : null;
|
|
48698
48745
|
switch (linter) {
|
|
48699
48746
|
case "ruff":
|
|
48700
48747
|
return mode === "fix" ? ["ruff", "check", "--fix", "."] : ["ruff", "check", "."];
|
|
@@ -48728,10 +48775,10 @@ function getAdditionalLinterCommand(linter, mode, cwd) {
|
|
|
48728
48775
|
}
|
|
48729
48776
|
}
|
|
48730
48777
|
function detectRuff(cwd) {
|
|
48731
|
-
if (fs18.existsSync(
|
|
48778
|
+
if (fs18.existsSync(path31.join(cwd, "ruff.toml")))
|
|
48732
48779
|
return isCommandAvailable("ruff");
|
|
48733
48780
|
try {
|
|
48734
|
-
const pyproject =
|
|
48781
|
+
const pyproject = path31.join(cwd, "pyproject.toml");
|
|
48735
48782
|
if (fs18.existsSync(pyproject)) {
|
|
48736
48783
|
const content = fs18.readFileSync(pyproject, "utf-8");
|
|
48737
48784
|
if (content.includes("[tool.ruff]"))
|
|
@@ -48741,19 +48788,19 @@ function detectRuff(cwd) {
|
|
|
48741
48788
|
return false;
|
|
48742
48789
|
}
|
|
48743
48790
|
function detectClippy(cwd) {
|
|
48744
|
-
return fs18.existsSync(
|
|
48791
|
+
return fs18.existsSync(path31.join(cwd, "Cargo.toml")) && isCommandAvailable("cargo");
|
|
48745
48792
|
}
|
|
48746
48793
|
function detectGolangciLint(cwd) {
|
|
48747
|
-
return fs18.existsSync(
|
|
48794
|
+
return fs18.existsSync(path31.join(cwd, "go.mod")) && isCommandAvailable("golangci-lint");
|
|
48748
48795
|
}
|
|
48749
48796
|
function detectCheckstyle(cwd) {
|
|
48750
|
-
const hasMaven = fs18.existsSync(
|
|
48751
|
-
const hasGradle = fs18.existsSync(
|
|
48752
|
-
const hasBinary = hasMaven && isCommandAvailable("mvn") || hasGradle && (fs18.existsSync(
|
|
48797
|
+
const hasMaven = fs18.existsSync(path31.join(cwd, "pom.xml"));
|
|
48798
|
+
const hasGradle = fs18.existsSync(path31.join(cwd, "build.gradle")) || fs18.existsSync(path31.join(cwd, "build.gradle.kts"));
|
|
48799
|
+
const hasBinary = hasMaven && isCommandAvailable("mvn") || hasGradle && (fs18.existsSync(path31.join(cwd, "gradlew")) || isCommandAvailable("gradle"));
|
|
48753
48800
|
return (hasMaven || hasGradle) && hasBinary;
|
|
48754
48801
|
}
|
|
48755
48802
|
function detectKtlint(cwd) {
|
|
48756
|
-
const hasKotlin = fs18.existsSync(
|
|
48803
|
+
const hasKotlin = fs18.existsSync(path31.join(cwd, "build.gradle.kts")) || fs18.existsSync(path31.join(cwd, "build.gradle")) || (() => {
|
|
48757
48804
|
try {
|
|
48758
48805
|
return fs18.readdirSync(cwd).some((f) => f.endsWith(".kt") || f.endsWith(".kts"));
|
|
48759
48806
|
} catch {
|
|
@@ -48772,11 +48819,11 @@ function detectDotnetFormat(cwd) {
|
|
|
48772
48819
|
}
|
|
48773
48820
|
}
|
|
48774
48821
|
function detectCppcheck(cwd) {
|
|
48775
|
-
if (fs18.existsSync(
|
|
48822
|
+
if (fs18.existsSync(path31.join(cwd, "CMakeLists.txt"))) {
|
|
48776
48823
|
return isCommandAvailable("cppcheck");
|
|
48777
48824
|
}
|
|
48778
48825
|
try {
|
|
48779
|
-
const dirsToCheck = [cwd,
|
|
48826
|
+
const dirsToCheck = [cwd, path31.join(cwd, "src")];
|
|
48780
48827
|
const hasCpp = dirsToCheck.some((dir) => {
|
|
48781
48828
|
try {
|
|
48782
48829
|
return fs18.readdirSync(dir).some((f) => /\.(c|cpp|cc|cxx|h|hpp)$/.test(f));
|
|
@@ -48790,13 +48837,13 @@ function detectCppcheck(cwd) {
|
|
|
48790
48837
|
}
|
|
48791
48838
|
}
|
|
48792
48839
|
function detectSwiftlint(cwd) {
|
|
48793
|
-
return fs18.existsSync(
|
|
48840
|
+
return fs18.existsSync(path31.join(cwd, "Package.swift")) && isCommandAvailable("swiftlint");
|
|
48794
48841
|
}
|
|
48795
48842
|
function detectDartAnalyze(cwd) {
|
|
48796
|
-
return fs18.existsSync(
|
|
48843
|
+
return fs18.existsSync(path31.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
|
|
48797
48844
|
}
|
|
48798
48845
|
function detectRubocop(cwd) {
|
|
48799
|
-
return (fs18.existsSync(
|
|
48846
|
+
return (fs18.existsSync(path31.join(cwd, "Gemfile")) || fs18.existsSync(path31.join(cwd, "gems.rb")) || fs18.existsSync(path31.join(cwd, ".rubocop.yml"))) && (isCommandAvailable("rubocop") || isCommandAvailable("bundle"));
|
|
48800
48847
|
}
|
|
48801
48848
|
function detectAdditionalLinter(cwd) {
|
|
48802
48849
|
if (detectRuff(cwd))
|
|
@@ -48824,10 +48871,10 @@ function detectAdditionalLinter(cwd) {
|
|
|
48824
48871
|
function resolveLinterBinPath(linter, projectDir) {
|
|
48825
48872
|
const isWindows = process.platform === "win32";
|
|
48826
48873
|
const binName = linter === "biome" ? isWindows ? "biome.EXE" : "biome" : isWindows ? "eslint.cmd" : "eslint";
|
|
48827
|
-
const localBin =
|
|
48874
|
+
const localBin = path31.join(projectDir, "node_modules", ".bin", binName);
|
|
48828
48875
|
if (fs18.existsSync(localBin))
|
|
48829
48876
|
return localBin;
|
|
48830
|
-
const ancestor = findBinInAncestors(
|
|
48877
|
+
const ancestor = findBinInAncestors(path31.dirname(projectDir), binName);
|
|
48831
48878
|
if (ancestor)
|
|
48832
48879
|
return ancestor;
|
|
48833
48880
|
const fromPath = findBinInEnvPath(binName);
|
|
@@ -48838,10 +48885,10 @@ function resolveLinterBinPath(linter, projectDir) {
|
|
|
48838
48885
|
function findBinInAncestors(startDir, binName) {
|
|
48839
48886
|
let dir = startDir;
|
|
48840
48887
|
while (true) {
|
|
48841
|
-
const candidate =
|
|
48888
|
+
const candidate = path31.join(dir, "node_modules", ".bin", binName);
|
|
48842
48889
|
if (fs18.existsSync(candidate))
|
|
48843
48890
|
return candidate;
|
|
48844
|
-
const parent =
|
|
48891
|
+
const parent = path31.dirname(dir);
|
|
48845
48892
|
if (parent === dir)
|
|
48846
48893
|
break;
|
|
48847
48894
|
dir = parent;
|
|
@@ -48850,10 +48897,10 @@ function findBinInAncestors(startDir, binName) {
|
|
|
48850
48897
|
}
|
|
48851
48898
|
function findBinInEnvPath(binName) {
|
|
48852
48899
|
const searchPath = process.env.PATH ?? "";
|
|
48853
|
-
for (const dir of searchPath.split(
|
|
48900
|
+
for (const dir of searchPath.split(path31.delimiter)) {
|
|
48854
48901
|
if (!dir)
|
|
48855
48902
|
continue;
|
|
48856
|
-
const candidate =
|
|
48903
|
+
const candidate = path31.join(dir, binName);
|
|
48857
48904
|
if (fs18.existsSync(candidate))
|
|
48858
48905
|
return candidate;
|
|
48859
48906
|
}
|
|
@@ -48866,13 +48913,13 @@ async function detectAvailableLinter(directory) {
|
|
|
48866
48913
|
return null;
|
|
48867
48914
|
const projectDir = directory;
|
|
48868
48915
|
const isWindows = process.platform === "win32";
|
|
48869
|
-
const biomeBin = isWindows ?
|
|
48870
|
-
const eslintBin = isWindows ?
|
|
48916
|
+
const biomeBin = isWindows ? path31.join(projectDir, "node_modules", ".bin", "biome.EXE") : path31.join(projectDir, "node_modules", ".bin", "biome");
|
|
48917
|
+
const eslintBin = isWindows ? path31.join(projectDir, "node_modules", ".bin", "eslint.cmd") : path31.join(projectDir, "node_modules", ".bin", "eslint");
|
|
48871
48918
|
const localResult = await _detectAvailableLinter(projectDir, biomeBin, eslintBin);
|
|
48872
48919
|
if (localResult)
|
|
48873
48920
|
return localResult;
|
|
48874
|
-
const biomeAncestor = findBinInAncestors(
|
|
48875
|
-
const eslintAncestor = findBinInAncestors(
|
|
48921
|
+
const biomeAncestor = findBinInAncestors(path31.dirname(projectDir), isWindows ? "biome.EXE" : "biome");
|
|
48922
|
+
const eslintAncestor = findBinInAncestors(path31.dirname(projectDir), isWindows ? "eslint.cmd" : "eslint");
|
|
48876
48923
|
if (biomeAncestor || eslintAncestor) {
|
|
48877
48924
|
return _detectAvailableLinter(projectDir, biomeAncestor ?? biomeBin, eslintAncestor ?? eslintBin);
|
|
48878
48925
|
}
|
|
@@ -49088,7 +49135,7 @@ For Rust: rustup component add clippy`
|
|
|
49088
49135
|
|
|
49089
49136
|
// src/tools/secretscan.ts
|
|
49090
49137
|
import * as fs19 from "node:fs";
|
|
49091
|
-
import * as
|
|
49138
|
+
import * as path32 from "node:path";
|
|
49092
49139
|
function calculateShannonEntropy(str) {
|
|
49093
49140
|
if (str.length === 0)
|
|
49094
49141
|
return 0;
|
|
@@ -49136,7 +49183,7 @@ function isGlobOrPathPattern(pattern) {
|
|
|
49136
49183
|
return pattern.includes("/") || pattern.includes("\\") || /[*?[\]{}]/.test(pattern);
|
|
49137
49184
|
}
|
|
49138
49185
|
function loadSecretScanIgnore(scanDir) {
|
|
49139
|
-
const ignorePath =
|
|
49186
|
+
const ignorePath = path32.join(scanDir, ".secretscanignore");
|
|
49140
49187
|
try {
|
|
49141
49188
|
if (!fs19.existsSync(ignorePath))
|
|
49142
49189
|
return [];
|
|
@@ -49159,7 +49206,7 @@ function isExcluded(entry, relPath, exactNames, globPatterns) {
|
|
|
49159
49206
|
if (exactNames.has(entry))
|
|
49160
49207
|
return true;
|
|
49161
49208
|
for (const pattern of globPatterns) {
|
|
49162
|
-
if (
|
|
49209
|
+
if (path32.matchesGlob(relPath, pattern))
|
|
49163
49210
|
return true;
|
|
49164
49211
|
}
|
|
49165
49212
|
return false;
|
|
@@ -49180,7 +49227,7 @@ function validateDirectoryInput(dir) {
|
|
|
49180
49227
|
return null;
|
|
49181
49228
|
}
|
|
49182
49229
|
function isBinaryFile(filePath, buffer) {
|
|
49183
|
-
const ext =
|
|
49230
|
+
const ext = path32.extname(filePath).toLowerCase();
|
|
49184
49231
|
if (DEFAULT_EXCLUDE_EXTENSIONS.has(ext)) {
|
|
49185
49232
|
return true;
|
|
49186
49233
|
}
|
|
@@ -49316,9 +49363,9 @@ function isSymlinkLoop(realPath, visited) {
|
|
|
49316
49363
|
return false;
|
|
49317
49364
|
}
|
|
49318
49365
|
function isPathWithinScope(realPath, scanDir) {
|
|
49319
|
-
const resolvedScanDir =
|
|
49320
|
-
const resolvedRealPath =
|
|
49321
|
-
return resolvedRealPath === resolvedScanDir || resolvedRealPath.startsWith(resolvedScanDir +
|
|
49366
|
+
const resolvedScanDir = path32.resolve(scanDir);
|
|
49367
|
+
const resolvedRealPath = path32.resolve(realPath);
|
|
49368
|
+
return resolvedRealPath === resolvedScanDir || resolvedRealPath.startsWith(resolvedScanDir + path32.sep) || resolvedRealPath.startsWith(`${resolvedScanDir}/`) || resolvedRealPath.startsWith(`${resolvedScanDir}\\`);
|
|
49322
49369
|
}
|
|
49323
49370
|
function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, stats = {
|
|
49324
49371
|
skippedDirs: 0,
|
|
@@ -49344,8 +49391,8 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
49344
49391
|
return a.localeCompare(b);
|
|
49345
49392
|
});
|
|
49346
49393
|
for (const entry of entries) {
|
|
49347
|
-
const fullPath =
|
|
49348
|
-
const relPath =
|
|
49394
|
+
const fullPath = path32.join(dir, entry);
|
|
49395
|
+
const relPath = path32.relative(scanDir, fullPath).replace(/\\/g, "/");
|
|
49349
49396
|
if (isExcluded(entry, relPath, excludeExact, excludeGlobs)) {
|
|
49350
49397
|
stats.skippedDirs++;
|
|
49351
49398
|
continue;
|
|
@@ -49380,7 +49427,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
49380
49427
|
const subFiles = findScannableFiles(fullPath, excludeExact, excludeGlobs, scanDir, visited, stats);
|
|
49381
49428
|
files.push(...subFiles);
|
|
49382
49429
|
} else if (lstat.isFile()) {
|
|
49383
|
-
const ext =
|
|
49430
|
+
const ext = path32.extname(fullPath).toLowerCase();
|
|
49384
49431
|
if (!DEFAULT_EXCLUDE_EXTENSIONS.has(ext)) {
|
|
49385
49432
|
files.push(fullPath);
|
|
49386
49433
|
} else {
|
|
@@ -49640,7 +49687,7 @@ var init_secretscan = __esm(() => {
|
|
|
49640
49687
|
}
|
|
49641
49688
|
}
|
|
49642
49689
|
try {
|
|
49643
|
-
const _scanDirRaw =
|
|
49690
|
+
const _scanDirRaw = path32.resolve(directory);
|
|
49644
49691
|
const scanDir = (() => {
|
|
49645
49692
|
try {
|
|
49646
49693
|
return fs19.realpathSync(_scanDirRaw);
|
|
@@ -49783,7 +49830,7 @@ var init_secretscan = __esm(() => {
|
|
|
49783
49830
|
|
|
49784
49831
|
// src/test-impact/analyzer.ts
|
|
49785
49832
|
import fs20 from "node:fs";
|
|
49786
|
-
import
|
|
49833
|
+
import path33 from "node:path";
|
|
49787
49834
|
function normalizePath(p) {
|
|
49788
49835
|
return p.replace(/\\/g, "/");
|
|
49789
49836
|
}
|
|
@@ -49804,8 +49851,8 @@ function resolveRelativeImport(fromDir, importPath) {
|
|
|
49804
49851
|
if (!importPath.startsWith(".")) {
|
|
49805
49852
|
return null;
|
|
49806
49853
|
}
|
|
49807
|
-
const resolved =
|
|
49808
|
-
if (
|
|
49854
|
+
const resolved = path33.resolve(fromDir, importPath);
|
|
49855
|
+
if (path33.extname(resolved)) {
|
|
49809
49856
|
if (fs20.existsSync(resolved) && fs20.statSync(resolved).isFile()) {
|
|
49810
49857
|
return normalizePath(resolved);
|
|
49811
49858
|
}
|
|
@@ -49850,12 +49897,12 @@ function findTestFilesSync(cwd) {
|
|
|
49850
49897
|
for (const entry of entries) {
|
|
49851
49898
|
if (entry.isDirectory()) {
|
|
49852
49899
|
if (!skipDirs.has(entry.name)) {
|
|
49853
|
-
walk(
|
|
49900
|
+
walk(path33.join(dir, entry.name), visitedInodes);
|
|
49854
49901
|
}
|
|
49855
49902
|
} else if (entry.isFile()) {
|
|
49856
49903
|
const name2 = entry.name;
|
|
49857
49904
|
if (/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(name2) || dir.includes("__tests__") && /\.(ts|tsx|js|jsx)$/.test(name2)) {
|
|
49858
|
-
testFiles.push(normalizePath(
|
|
49905
|
+
testFiles.push(normalizePath(path33.join(dir, entry.name)));
|
|
49859
49906
|
}
|
|
49860
49907
|
}
|
|
49861
49908
|
}
|
|
@@ -49893,7 +49940,7 @@ async function buildImpactMapInternal(cwd) {
|
|
|
49893
49940
|
continue;
|
|
49894
49941
|
}
|
|
49895
49942
|
const imports = extractImports(content);
|
|
49896
|
-
const testDir =
|
|
49943
|
+
const testDir = path33.dirname(testFile);
|
|
49897
49944
|
for (const importPath of imports) {
|
|
49898
49945
|
const resolvedSource = resolveRelativeImport(testDir, importPath);
|
|
49899
49946
|
if (resolvedSource === null) {
|
|
@@ -49915,7 +49962,7 @@ async function buildImpactMap(cwd) {
|
|
|
49915
49962
|
return impactMap;
|
|
49916
49963
|
}
|
|
49917
49964
|
async function loadImpactMap(cwd) {
|
|
49918
|
-
const cachePath =
|
|
49965
|
+
const cachePath = path33.join(cwd, ".swarm", "cache", "impact-map.json");
|
|
49919
49966
|
if (fs20.existsSync(cachePath)) {
|
|
49920
49967
|
try {
|
|
49921
49968
|
const content = fs20.readFileSync(cachePath, "utf-8");
|
|
@@ -49930,8 +49977,8 @@ async function loadImpactMap(cwd) {
|
|
|
49930
49977
|
return buildImpactMap(cwd);
|
|
49931
49978
|
}
|
|
49932
49979
|
async function saveImpactMap(cwd, impactMap) {
|
|
49933
|
-
const cacheDir2 =
|
|
49934
|
-
const cachePath =
|
|
49980
|
+
const cacheDir2 = path33.join(cwd, ".swarm", "cache");
|
|
49981
|
+
const cachePath = path33.join(cacheDir2, "impact-map.json");
|
|
49935
49982
|
if (!fs20.existsSync(cacheDir2)) {
|
|
49936
49983
|
fs20.mkdirSync(cacheDir2, { recursive: true });
|
|
49937
49984
|
}
|
|
@@ -49957,7 +50004,7 @@ async function analyzeImpact(changedFiles, cwd) {
|
|
|
49957
50004
|
const impactedTestsSet = new Set;
|
|
49958
50005
|
const untestedFiles = [];
|
|
49959
50006
|
for (const changedFile of validFiles) {
|
|
49960
|
-
const normalizedChanged = normalizePath(
|
|
50007
|
+
const normalizedChanged = normalizePath(path33.resolve(changedFile));
|
|
49961
50008
|
const tests = impactMap[normalizedChanged];
|
|
49962
50009
|
if (tests && tests.length > 0) {
|
|
49963
50010
|
for (const test of tests) {
|
|
@@ -50209,9 +50256,9 @@ var FLAKY_THRESHOLD = 0.3, MIN_RUNS_FOR_QUARANTINE = 5, MAX_HISTORY_RUNS = 20;
|
|
|
50209
50256
|
|
|
50210
50257
|
// src/test-impact/history-store.ts
|
|
50211
50258
|
import fs21 from "node:fs";
|
|
50212
|
-
import
|
|
50259
|
+
import path34 from "node:path";
|
|
50213
50260
|
function getHistoryPath(workingDir) {
|
|
50214
|
-
return
|
|
50261
|
+
return path34.join(workingDir || process.cwd(), ".swarm", "cache", "test-history.jsonl");
|
|
50215
50262
|
}
|
|
50216
50263
|
function sanitizeErrorMessage(errorMessage) {
|
|
50217
50264
|
if (errorMessage === undefined) {
|
|
@@ -50266,7 +50313,7 @@ function appendTestRun(record3, workingDir) {
|
|
|
50266
50313
|
changedFiles: sanitizeChangedFiles(record3.changedFiles || [])
|
|
50267
50314
|
};
|
|
50268
50315
|
const historyPath = getHistoryPath(workingDir);
|
|
50269
|
-
const historyDir =
|
|
50316
|
+
const historyDir = path34.dirname(historyPath);
|
|
50270
50317
|
if (!fs21.existsSync(historyDir)) {
|
|
50271
50318
|
fs21.mkdirSync(historyDir, { recursive: true });
|
|
50272
50319
|
}
|
|
@@ -50348,7 +50395,7 @@ var init_history_store = __esm(() => {
|
|
|
50348
50395
|
|
|
50349
50396
|
// src/tools/resolve-working-directory.ts
|
|
50350
50397
|
import * as fs22 from "node:fs";
|
|
50351
|
-
import * as
|
|
50398
|
+
import * as path35 from "node:path";
|
|
50352
50399
|
function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
|
|
50353
50400
|
if (workingDirectory == null || workingDirectory === "") {
|
|
50354
50401
|
return { success: true, directory: fallbackDirectory };
|
|
@@ -50368,15 +50415,15 @@ function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
|
|
|
50368
50415
|
};
|
|
50369
50416
|
}
|
|
50370
50417
|
}
|
|
50371
|
-
const normalizedDir =
|
|
50372
|
-
const pathParts = normalizedDir.split(
|
|
50418
|
+
const normalizedDir = path35.normalize(workingDirectory);
|
|
50419
|
+
const pathParts = normalizedDir.split(path35.sep);
|
|
50373
50420
|
if (pathParts.includes("..")) {
|
|
50374
50421
|
return {
|
|
50375
50422
|
success: false,
|
|
50376
50423
|
message: "Invalid working_directory: path traversal sequences (..) are not allowed"
|
|
50377
50424
|
};
|
|
50378
50425
|
}
|
|
50379
|
-
const resolvedDir =
|
|
50426
|
+
const resolvedDir = path35.resolve(normalizedDir);
|
|
50380
50427
|
let statResult;
|
|
50381
50428
|
try {
|
|
50382
50429
|
statResult = fs22.statSync(resolvedDir);
|
|
@@ -50392,7 +50439,7 @@ function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
|
|
|
50392
50439
|
message: `Invalid working_directory: path "${resolvedDir}" is not a directory`
|
|
50393
50440
|
};
|
|
50394
50441
|
}
|
|
50395
|
-
const resolvedFallback =
|
|
50442
|
+
const resolvedFallback = path35.resolve(fallbackDirectory);
|
|
50396
50443
|
let fallbackExists = false;
|
|
50397
50444
|
try {
|
|
50398
50445
|
fs22.statSync(resolvedFallback);
|
|
@@ -50402,7 +50449,7 @@ function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
|
|
|
50402
50449
|
}
|
|
50403
50450
|
if (workingDirectory != null && workingDirectory !== "") {
|
|
50404
50451
|
if (fallbackExists) {
|
|
50405
|
-
const isSubdirectory = resolvedDir.startsWith(resolvedFallback +
|
|
50452
|
+
const isSubdirectory = resolvedDir.startsWith(resolvedFallback + path35.sep);
|
|
50406
50453
|
if (isSubdirectory) {
|
|
50407
50454
|
return {
|
|
50408
50455
|
success: false,
|
|
@@ -50424,7 +50471,7 @@ var init_resolve_working_directory = () => {};
|
|
|
50424
50471
|
|
|
50425
50472
|
// src/tools/test-runner.ts
|
|
50426
50473
|
import * as fs23 from "node:fs";
|
|
50427
|
-
import * as
|
|
50474
|
+
import * as path36 from "node:path";
|
|
50428
50475
|
function isAbsolutePath(str) {
|
|
50429
50476
|
if (str.startsWith("/"))
|
|
50430
50477
|
return true;
|
|
@@ -50489,14 +50536,14 @@ function hasDevDependency(devDeps, ...patterns) {
|
|
|
50489
50536
|
return hasPackageJsonDependency(devDeps, ...patterns);
|
|
50490
50537
|
}
|
|
50491
50538
|
function detectGoTest(cwd) {
|
|
50492
|
-
return fs23.existsSync(
|
|
50539
|
+
return fs23.existsSync(path36.join(cwd, "go.mod")) && isCommandAvailable("go");
|
|
50493
50540
|
}
|
|
50494
50541
|
function detectJavaMaven(cwd) {
|
|
50495
|
-
return fs23.existsSync(
|
|
50542
|
+
return fs23.existsSync(path36.join(cwd, "pom.xml")) && isCommandAvailable("mvn");
|
|
50496
50543
|
}
|
|
50497
50544
|
function detectGradle(cwd) {
|
|
50498
|
-
const hasBuildFile = fs23.existsSync(
|
|
50499
|
-
const hasGradlew = fs23.existsSync(
|
|
50545
|
+
const hasBuildFile = fs23.existsSync(path36.join(cwd, "build.gradle")) || fs23.existsSync(path36.join(cwd, "build.gradle.kts"));
|
|
50546
|
+
const hasGradlew = fs23.existsSync(path36.join(cwd, "gradlew")) || fs23.existsSync(path36.join(cwd, "gradlew.bat"));
|
|
50500
50547
|
return hasBuildFile && (hasGradlew || isCommandAvailable("gradle"));
|
|
50501
50548
|
}
|
|
50502
50549
|
function detectDotnetTest(cwd) {
|
|
@@ -50509,30 +50556,30 @@ function detectDotnetTest(cwd) {
|
|
|
50509
50556
|
}
|
|
50510
50557
|
}
|
|
50511
50558
|
function detectCTest(cwd) {
|
|
50512
|
-
const hasSource = fs23.existsSync(
|
|
50513
|
-
const hasBuildCache = fs23.existsSync(
|
|
50559
|
+
const hasSource = fs23.existsSync(path36.join(cwd, "CMakeLists.txt"));
|
|
50560
|
+
const hasBuildCache = fs23.existsSync(path36.join(cwd, "CMakeCache.txt")) || fs23.existsSync(path36.join(cwd, "build", "CMakeCache.txt"));
|
|
50514
50561
|
return (hasSource || hasBuildCache) && isCommandAvailable("ctest");
|
|
50515
50562
|
}
|
|
50516
50563
|
function detectSwiftTest(cwd) {
|
|
50517
|
-
return fs23.existsSync(
|
|
50564
|
+
return fs23.existsSync(path36.join(cwd, "Package.swift")) && isCommandAvailable("swift");
|
|
50518
50565
|
}
|
|
50519
50566
|
function detectDartTest(cwd) {
|
|
50520
|
-
return fs23.existsSync(
|
|
50567
|
+
return fs23.existsSync(path36.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
|
|
50521
50568
|
}
|
|
50522
50569
|
function detectRSpec(cwd) {
|
|
50523
|
-
const hasRSpecFile = fs23.existsSync(
|
|
50524
|
-
const hasGemfile = fs23.existsSync(
|
|
50525
|
-
const hasSpecDir = fs23.existsSync(
|
|
50570
|
+
const hasRSpecFile = fs23.existsSync(path36.join(cwd, ".rspec"));
|
|
50571
|
+
const hasGemfile = fs23.existsSync(path36.join(cwd, "Gemfile"));
|
|
50572
|
+
const hasSpecDir = fs23.existsSync(path36.join(cwd, "spec"));
|
|
50526
50573
|
const hasRSpec = hasRSpecFile || hasGemfile && hasSpecDir;
|
|
50527
50574
|
return hasRSpec && (isCommandAvailable("bundle") || isCommandAvailable("rspec"));
|
|
50528
50575
|
}
|
|
50529
50576
|
function detectMinitest(cwd) {
|
|
50530
|
-
return fs23.existsSync(
|
|
50577
|
+
return fs23.existsSync(path36.join(cwd, "test")) && (fs23.existsSync(path36.join(cwd, "Gemfile")) || fs23.existsSync(path36.join(cwd, "Rakefile"))) && isCommandAvailable("ruby");
|
|
50531
50578
|
}
|
|
50532
50579
|
async function detectTestFramework(cwd) {
|
|
50533
50580
|
const baseDir = cwd;
|
|
50534
50581
|
try {
|
|
50535
|
-
const packageJsonPath =
|
|
50582
|
+
const packageJsonPath = path36.join(baseDir, "package.json");
|
|
50536
50583
|
if (fs23.existsSync(packageJsonPath)) {
|
|
50537
50584
|
const content = fs23.readFileSync(packageJsonPath, "utf-8");
|
|
50538
50585
|
const pkg = JSON.parse(content);
|
|
@@ -50553,16 +50600,16 @@ async function detectTestFramework(cwd) {
|
|
|
50553
50600
|
return "jest";
|
|
50554
50601
|
if (hasDevDependency(devDeps, "mocha", "@types/mocha"))
|
|
50555
50602
|
return "mocha";
|
|
50556
|
-
if (fs23.existsSync(
|
|
50603
|
+
if (fs23.existsSync(path36.join(baseDir, "bun.lockb")) || fs23.existsSync(path36.join(baseDir, "bun.lock"))) {
|
|
50557
50604
|
if (scripts.test?.includes("bun"))
|
|
50558
50605
|
return "bun";
|
|
50559
50606
|
}
|
|
50560
50607
|
}
|
|
50561
50608
|
} catch {}
|
|
50562
50609
|
try {
|
|
50563
|
-
const pyprojectTomlPath =
|
|
50564
|
-
const setupCfgPath =
|
|
50565
|
-
const requirementsTxtPath =
|
|
50610
|
+
const pyprojectTomlPath = path36.join(baseDir, "pyproject.toml");
|
|
50611
|
+
const setupCfgPath = path36.join(baseDir, "setup.cfg");
|
|
50612
|
+
const requirementsTxtPath = path36.join(baseDir, "requirements.txt");
|
|
50566
50613
|
if (fs23.existsSync(pyprojectTomlPath)) {
|
|
50567
50614
|
const content = fs23.readFileSync(pyprojectTomlPath, "utf-8");
|
|
50568
50615
|
if (content.includes("[tool.pytest"))
|
|
@@ -50582,7 +50629,7 @@ async function detectTestFramework(cwd) {
|
|
|
50582
50629
|
}
|
|
50583
50630
|
} catch {}
|
|
50584
50631
|
try {
|
|
50585
|
-
const cargoTomlPath =
|
|
50632
|
+
const cargoTomlPath = path36.join(baseDir, "Cargo.toml");
|
|
50586
50633
|
if (fs23.existsSync(cargoTomlPath)) {
|
|
50587
50634
|
const content = fs23.readFileSync(cargoTomlPath, "utf-8");
|
|
50588
50635
|
if (content.includes("[dev-dependencies]")) {
|
|
@@ -50593,9 +50640,9 @@ async function detectTestFramework(cwd) {
|
|
|
50593
50640
|
}
|
|
50594
50641
|
} catch {}
|
|
50595
50642
|
try {
|
|
50596
|
-
const pesterConfigPath =
|
|
50597
|
-
const pesterConfigJsonPath =
|
|
50598
|
-
const pesterPs1Path =
|
|
50643
|
+
const pesterConfigPath = path36.join(baseDir, "pester.config.ps1");
|
|
50644
|
+
const pesterConfigJsonPath = path36.join(baseDir, "pester.config.ps1.json");
|
|
50645
|
+
const pesterPs1Path = path36.join(baseDir, "tests.ps1");
|
|
50599
50646
|
if (fs23.existsSync(pesterConfigPath) || fs23.existsSync(pesterConfigJsonPath) || fs23.existsSync(pesterPs1Path)) {
|
|
50600
50647
|
return "pester";
|
|
50601
50648
|
}
|
|
@@ -50624,12 +50671,12 @@ function isTestDirectoryPath(normalizedPath) {
|
|
|
50624
50671
|
return normalizedPath.split("/").some((segment) => TEST_DIRECTORY_NAMES.includes(segment));
|
|
50625
50672
|
}
|
|
50626
50673
|
function resolveWorkspacePath(file3, workingDir) {
|
|
50627
|
-
return
|
|
50674
|
+
return path36.isAbsolute(file3) ? path36.resolve(file3) : path36.resolve(workingDir, file3);
|
|
50628
50675
|
}
|
|
50629
50676
|
function toWorkspaceOutputPath(absolutePath, workingDir, preferRelative) {
|
|
50630
50677
|
if (!preferRelative)
|
|
50631
50678
|
return absolutePath;
|
|
50632
|
-
return
|
|
50679
|
+
return path36.relative(workingDir, absolutePath);
|
|
50633
50680
|
}
|
|
50634
50681
|
function dedupePush(target, value) {
|
|
50635
50682
|
if (!target.includes(value)) {
|
|
@@ -50666,18 +50713,18 @@ function buildLanguageSpecificTestNames(nameWithoutExt, ext) {
|
|
|
50666
50713
|
}
|
|
50667
50714
|
}
|
|
50668
50715
|
function getRepoLevelCandidateDirectories(workingDir, relativePath, ext) {
|
|
50669
|
-
const relativeDir =
|
|
50716
|
+
const relativeDir = path36.dirname(relativePath);
|
|
50670
50717
|
const nestedRelativeDir = relativeDir === "." ? "" : relativeDir;
|
|
50671
50718
|
const directories = TEST_DIRECTORY_NAMES.flatMap((dirName) => {
|
|
50672
|
-
const rootDir =
|
|
50673
|
-
return nestedRelativeDir ? [rootDir,
|
|
50719
|
+
const rootDir = path36.join(workingDir, dirName);
|
|
50720
|
+
return nestedRelativeDir ? [rootDir, path36.join(rootDir, nestedRelativeDir)] : [rootDir];
|
|
50674
50721
|
});
|
|
50675
50722
|
const normalizedRelativePath = relativePath.replace(/\\/g, "/");
|
|
50676
50723
|
if (ext === ".java" && normalizedRelativePath.startsWith("src/main/java/")) {
|
|
50677
|
-
directories.push(
|
|
50724
|
+
directories.push(path36.join(workingDir, "src/test/java", path36.dirname(normalizedRelativePath.slice("src/main/java/".length))));
|
|
50678
50725
|
}
|
|
50679
50726
|
if ((ext === ".kt" || ext === ".java") && normalizedRelativePath.startsWith("src/main/kotlin/")) {
|
|
50680
|
-
directories.push(
|
|
50727
|
+
directories.push(path36.join(workingDir, "src/test/kotlin", path36.dirname(normalizedRelativePath.slice("src/main/kotlin/".length))));
|
|
50681
50728
|
}
|
|
50682
50729
|
return [...new Set(directories)];
|
|
50683
50730
|
}
|
|
@@ -50705,23 +50752,23 @@ function isLanguageSpecificTestFile(basename6) {
|
|
|
50705
50752
|
}
|
|
50706
50753
|
function isConventionTestFilePath(filePath) {
|
|
50707
50754
|
const normalizedPath = filePath.replace(/\\/g, "/");
|
|
50708
|
-
const basename6 =
|
|
50755
|
+
const basename6 = path36.basename(filePath);
|
|
50709
50756
|
return hasCompoundTestExtension(basename6) || basename6.includes(".spec.") || basename6.includes(".test.") || isLanguageSpecificTestFile(basename6) || isTestDirectoryPath(normalizedPath);
|
|
50710
50757
|
}
|
|
50711
50758
|
function getTestFilesFromConvention(sourceFiles, workingDir = process.cwd()) {
|
|
50712
50759
|
const testFiles = [];
|
|
50713
50760
|
for (const file3 of sourceFiles) {
|
|
50714
50761
|
const absoluteFile = resolveWorkspacePath(file3, workingDir);
|
|
50715
|
-
const relativeFile =
|
|
50716
|
-
const basename6 =
|
|
50717
|
-
const dirname14 =
|
|
50718
|
-
const preferRelativeOutput = !
|
|
50762
|
+
const relativeFile = path36.relative(workingDir, absoluteFile);
|
|
50763
|
+
const basename6 = path36.basename(absoluteFile);
|
|
50764
|
+
const dirname14 = path36.dirname(absoluteFile);
|
|
50765
|
+
const preferRelativeOutput = !path36.isAbsolute(file3);
|
|
50719
50766
|
if (isConventionTestFilePath(relativeFile) || isConventionTestFilePath(file3)) {
|
|
50720
50767
|
dedupePush(testFiles, toWorkspaceOutputPath(absoluteFile, workingDir, preferRelativeOutput));
|
|
50721
50768
|
continue;
|
|
50722
50769
|
}
|
|
50723
50770
|
const nameWithoutExt = basename6.replace(/\.[^.]+$/, "");
|
|
50724
|
-
const ext =
|
|
50771
|
+
const ext = path36.extname(basename6);
|
|
50725
50772
|
const genericTestNames = [
|
|
50726
50773
|
`${nameWithoutExt}.spec${ext}`,
|
|
50727
50774
|
`${nameWithoutExt}.test${ext}`
|
|
@@ -50730,7 +50777,7 @@ function getTestFilesFromConvention(sourceFiles, workingDir = process.cwd()) {
|
|
|
50730
50777
|
const colocatedCandidates = [
|
|
50731
50778
|
...genericTestNames,
|
|
50732
50779
|
...languageSpecificTestNames
|
|
50733
|
-
].map((candidateName) =>
|
|
50780
|
+
].map((candidateName) => path36.join(dirname14, candidateName));
|
|
50734
50781
|
const testDirectoryNames = [
|
|
50735
50782
|
basename6,
|
|
50736
50783
|
...genericTestNames,
|
|
@@ -50739,8 +50786,8 @@ function getTestFilesFromConvention(sourceFiles, workingDir = process.cwd()) {
|
|
|
50739
50786
|
const repoLevelDirectories = getRepoLevelCandidateDirectories(workingDir, relativeFile, ext);
|
|
50740
50787
|
const possibleTestFiles = [
|
|
50741
50788
|
...colocatedCandidates,
|
|
50742
|
-
...TEST_DIRECTORY_NAMES.flatMap((dirName) => testDirectoryNames.map((candidateName) =>
|
|
50743
|
-
...repoLevelDirectories.flatMap((candidateDir) => testDirectoryNames.map((candidateName) =>
|
|
50789
|
+
...TEST_DIRECTORY_NAMES.flatMap((dirName) => testDirectoryNames.map((candidateName) => path36.join(dirname14, dirName, candidateName))),
|
|
50790
|
+
...repoLevelDirectories.flatMap((candidateDir) => testDirectoryNames.map((candidateName) => path36.join(candidateDir, candidateName)))
|
|
50744
50791
|
];
|
|
50745
50792
|
for (const testFile of possibleTestFiles) {
|
|
50746
50793
|
if (fs23.existsSync(testFile)) {
|
|
@@ -50761,7 +50808,7 @@ async function getTestFilesFromGraph(sourceFiles, workingDir) {
|
|
|
50761
50808
|
try {
|
|
50762
50809
|
const absoluteTestFile = resolveWorkspacePath(testFile, workingDir);
|
|
50763
50810
|
const content = fs23.readFileSync(absoluteTestFile, "utf-8");
|
|
50764
|
-
const testDir =
|
|
50811
|
+
const testDir = path36.dirname(absoluteTestFile);
|
|
50765
50812
|
const importRegex = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
|
|
50766
50813
|
let match;
|
|
50767
50814
|
match = importRegex.exec(content);
|
|
@@ -50769,8 +50816,8 @@ async function getTestFilesFromGraph(sourceFiles, workingDir) {
|
|
|
50769
50816
|
const importPath = match[1];
|
|
50770
50817
|
let resolvedImport;
|
|
50771
50818
|
if (importPath.startsWith(".")) {
|
|
50772
|
-
resolvedImport =
|
|
50773
|
-
const existingExt =
|
|
50819
|
+
resolvedImport = path36.resolve(testDir, importPath);
|
|
50820
|
+
const existingExt = path36.extname(resolvedImport);
|
|
50774
50821
|
if (!existingExt) {
|
|
50775
50822
|
for (const extToTry of [
|
|
50776
50823
|
".ts",
|
|
@@ -50790,12 +50837,12 @@ async function getTestFilesFromGraph(sourceFiles, workingDir) {
|
|
|
50790
50837
|
} else {
|
|
50791
50838
|
continue;
|
|
50792
50839
|
}
|
|
50793
|
-
const importBasename =
|
|
50794
|
-
const importDir =
|
|
50840
|
+
const importBasename = path36.basename(resolvedImport, path36.extname(resolvedImport));
|
|
50841
|
+
const importDir = path36.dirname(resolvedImport);
|
|
50795
50842
|
for (const sourceFile of absoluteSourceFiles) {
|
|
50796
|
-
const sourceDir =
|
|
50797
|
-
const sourceBasename =
|
|
50798
|
-
const isRelatedDir = importDir === sourceDir || importDir ===
|
|
50843
|
+
const sourceDir = path36.dirname(sourceFile);
|
|
50844
|
+
const sourceBasename = path36.basename(sourceFile, path36.extname(sourceFile));
|
|
50845
|
+
const isRelatedDir = importDir === sourceDir || importDir === path36.join(sourceDir, "__tests__") || importDir === path36.join(sourceDir, "tests") || importDir === path36.join(sourceDir, "test") || importDir === path36.join(sourceDir, "spec");
|
|
50799
50846
|
if (resolvedImport === sourceFile || importBasename === sourceBasename && isRelatedDir) {
|
|
50800
50847
|
dedupePush(testFiles, testFile);
|
|
50801
50848
|
break;
|
|
@@ -50808,8 +50855,8 @@ async function getTestFilesFromGraph(sourceFiles, workingDir) {
|
|
|
50808
50855
|
while (match !== null) {
|
|
50809
50856
|
const importPath = match[1];
|
|
50810
50857
|
if (importPath.startsWith(".")) {
|
|
50811
|
-
let resolvedImport =
|
|
50812
|
-
const existingExt =
|
|
50858
|
+
let resolvedImport = path36.resolve(testDir, importPath);
|
|
50859
|
+
const existingExt = path36.extname(resolvedImport);
|
|
50813
50860
|
if (!existingExt) {
|
|
50814
50861
|
for (const extToTry of [
|
|
50815
50862
|
".ts",
|
|
@@ -50826,12 +50873,12 @@ async function getTestFilesFromGraph(sourceFiles, workingDir) {
|
|
|
50826
50873
|
}
|
|
50827
50874
|
}
|
|
50828
50875
|
}
|
|
50829
|
-
const importDir =
|
|
50830
|
-
const importBasename =
|
|
50876
|
+
const importDir = path36.dirname(resolvedImport);
|
|
50877
|
+
const importBasename = path36.basename(resolvedImport, path36.extname(resolvedImport));
|
|
50831
50878
|
for (const sourceFile of absoluteSourceFiles) {
|
|
50832
|
-
const sourceDir =
|
|
50833
|
-
const sourceBasename =
|
|
50834
|
-
const isRelatedDir = importDir === sourceDir || importDir ===
|
|
50879
|
+
const sourceDir = path36.dirname(sourceFile);
|
|
50880
|
+
const sourceBasename = path36.basename(sourceFile, path36.extname(sourceFile));
|
|
50881
|
+
const isRelatedDir = importDir === sourceDir || importDir === path36.join(sourceDir, "__tests__") || importDir === path36.join(sourceDir, "tests") || importDir === path36.join(sourceDir, "test") || importDir === path36.join(sourceDir, "spec");
|
|
50835
50882
|
if (resolvedImport === sourceFile || importBasename === sourceBasename && isRelatedDir) {
|
|
50836
50883
|
dedupePush(testFiles, testFile);
|
|
50837
50884
|
break;
|
|
@@ -50934,8 +50981,8 @@ function buildTestCommand(framework, scope, files, coverage, baseDir) {
|
|
|
50934
50981
|
return ["mvn", "test"];
|
|
50935
50982
|
case "gradle": {
|
|
50936
50983
|
const isWindows = process.platform === "win32";
|
|
50937
|
-
const hasGradlewBat = fs23.existsSync(
|
|
50938
|
-
const hasGradlew = fs23.existsSync(
|
|
50984
|
+
const hasGradlewBat = fs23.existsSync(path36.join(baseDir, "gradlew.bat"));
|
|
50985
|
+
const hasGradlew = fs23.existsSync(path36.join(baseDir, "gradlew"));
|
|
50939
50986
|
if (hasGradlewBat && isWindows)
|
|
50940
50987
|
return ["gradlew.bat", "test"];
|
|
50941
50988
|
if (hasGradlew)
|
|
@@ -50952,7 +50999,7 @@ function buildTestCommand(framework, scope, files, coverage, baseDir) {
|
|
|
50952
50999
|
"cmake-build-release",
|
|
50953
51000
|
"out"
|
|
50954
51001
|
];
|
|
50955
|
-
const actualBuildDir = buildDirCandidates.find((d) => fs23.existsSync(
|
|
51002
|
+
const actualBuildDir = buildDirCandidates.find((d) => fs23.existsSync(path36.join(baseDir, d, "CMakeCache.txt"))) ?? "build";
|
|
50956
51003
|
return ["ctest", "--test-dir", actualBuildDir];
|
|
50957
51004
|
}
|
|
50958
51005
|
case "swift-test":
|
|
@@ -51604,7 +51651,7 @@ var init_test_runner = __esm(() => {
|
|
|
51604
51651
|
const sourceFiles = args2.files.filter((file3) => {
|
|
51605
51652
|
if (directTestFiles.includes(file3))
|
|
51606
51653
|
return false;
|
|
51607
|
-
const ext =
|
|
51654
|
+
const ext = path36.extname(file3).toLowerCase();
|
|
51608
51655
|
return SOURCE_EXTENSIONS.has(ext);
|
|
51609
51656
|
});
|
|
51610
51657
|
const invalidFiles = args2.files.filter((file3) => !directTestFiles.includes(file3) && !sourceFiles.includes(file3));
|
|
@@ -51639,7 +51686,7 @@ var init_test_runner = __esm(() => {
|
|
|
51639
51686
|
if (isConventionTestFilePath(f)) {
|
|
51640
51687
|
return false;
|
|
51641
51688
|
}
|
|
51642
|
-
const ext =
|
|
51689
|
+
const ext = path36.extname(f).toLowerCase();
|
|
51643
51690
|
return SOURCE_EXTENSIONS.has(ext);
|
|
51644
51691
|
});
|
|
51645
51692
|
if (sourceFiles.length === 0) {
|
|
@@ -51666,7 +51713,7 @@ var init_test_runner = __esm(() => {
|
|
|
51666
51713
|
if (isConventionTestFilePath(f)) {
|
|
51667
51714
|
return false;
|
|
51668
51715
|
}
|
|
51669
|
-
const ext =
|
|
51716
|
+
const ext = path36.extname(f).toLowerCase();
|
|
51670
51717
|
return SOURCE_EXTENSIONS.has(ext);
|
|
51671
51718
|
});
|
|
51672
51719
|
if (sourceFiles.length === 0) {
|
|
@@ -51684,8 +51731,8 @@ var init_test_runner = __esm(() => {
|
|
|
51684
51731
|
const impactResult = await analyzeImpact(sourceFiles, workingDir);
|
|
51685
51732
|
if (impactResult.impactedTests.length > 0) {
|
|
51686
51733
|
testFiles = impactResult.impactedTests.map((absPath) => {
|
|
51687
|
-
const relativePath =
|
|
51688
|
-
return
|
|
51734
|
+
const relativePath = path36.relative(workingDir, absPath);
|
|
51735
|
+
return path36.isAbsolute(relativePath) ? absPath : relativePath;
|
|
51689
51736
|
});
|
|
51690
51737
|
} else {
|
|
51691
51738
|
graphFallbackReason = "no impacted tests found via impact analysis, falling back to graph";
|
|
@@ -51761,7 +51808,7 @@ var init_test_runner = __esm(() => {
|
|
|
51761
51808
|
|
|
51762
51809
|
// src/services/preflight-service.ts
|
|
51763
51810
|
import * as fs24 from "node:fs";
|
|
51764
|
-
import * as
|
|
51811
|
+
import * as path37 from "node:path";
|
|
51765
51812
|
function validateDirectoryPath(dir) {
|
|
51766
51813
|
if (!dir || typeof dir !== "string") {
|
|
51767
51814
|
throw new Error("Directory path is required");
|
|
@@ -51769,8 +51816,8 @@ function validateDirectoryPath(dir) {
|
|
|
51769
51816
|
if (dir.includes("..")) {
|
|
51770
51817
|
throw new Error("Directory path must not contain path traversal sequences");
|
|
51771
51818
|
}
|
|
51772
|
-
const normalized =
|
|
51773
|
-
const absolutePath =
|
|
51819
|
+
const normalized = path37.normalize(dir);
|
|
51820
|
+
const absolutePath = path37.isAbsolute(normalized) ? normalized : path37.resolve(normalized);
|
|
51774
51821
|
return absolutePath;
|
|
51775
51822
|
}
|
|
51776
51823
|
function validateTimeout(timeoutMs, defaultValue) {
|
|
@@ -51793,7 +51840,7 @@ function validateTimeout(timeoutMs, defaultValue) {
|
|
|
51793
51840
|
}
|
|
51794
51841
|
function getPackageVersion(dir) {
|
|
51795
51842
|
try {
|
|
51796
|
-
const packagePath =
|
|
51843
|
+
const packagePath = path37.join(dir, "package.json");
|
|
51797
51844
|
if (fs24.existsSync(packagePath)) {
|
|
51798
51845
|
const content = fs24.readFileSync(packagePath, "utf-8");
|
|
51799
51846
|
const pkg = JSON.parse(content);
|
|
@@ -51804,7 +51851,7 @@ function getPackageVersion(dir) {
|
|
|
51804
51851
|
}
|
|
51805
51852
|
function getChangelogVersion(dir) {
|
|
51806
51853
|
try {
|
|
51807
|
-
const changelogPath =
|
|
51854
|
+
const changelogPath = path37.join(dir, "CHANGELOG.md");
|
|
51808
51855
|
if (fs24.existsSync(changelogPath)) {
|
|
51809
51856
|
const content = fs24.readFileSync(changelogPath, "utf-8");
|
|
51810
51857
|
const match = content.match(/^##\s*\[?(\d+\.\d+\.\d+)\]?/m);
|
|
@@ -51818,7 +51865,7 @@ function getChangelogVersion(dir) {
|
|
|
51818
51865
|
function getVersionFileVersion(dir) {
|
|
51819
51866
|
const possibleFiles = ["VERSION.txt", "version.txt", "VERSION", "version"];
|
|
51820
51867
|
for (const file3 of possibleFiles) {
|
|
51821
|
-
const filePath =
|
|
51868
|
+
const filePath = path37.join(dir, file3);
|
|
51822
51869
|
if (fs24.existsSync(filePath)) {
|
|
51823
51870
|
try {
|
|
51824
51871
|
const content = fs24.readFileSync(filePath, "utf-8").trim();
|
|
@@ -52145,7 +52192,7 @@ async function runEvidenceCheck(dir) {
|
|
|
52145
52192
|
async function runRequirementCoverageCheck(dir, currentPhase) {
|
|
52146
52193
|
const startTime = Date.now();
|
|
52147
52194
|
try {
|
|
52148
|
-
const specPath =
|
|
52195
|
+
const specPath = path37.join(dir, ".swarm", "spec.md");
|
|
52149
52196
|
if (!fs24.existsSync(specPath)) {
|
|
52150
52197
|
return {
|
|
52151
52198
|
type: "req_coverage",
|
|
@@ -53330,7 +53377,7 @@ var init_reset = __esm(() => {
|
|
|
53330
53377
|
|
|
53331
53378
|
// src/commands/reset-session.ts
|
|
53332
53379
|
import * as fs26 from "node:fs";
|
|
53333
|
-
import * as
|
|
53380
|
+
import * as path38 from "node:path";
|
|
53334
53381
|
async function handleResetSessionCommand(directory, _args) {
|
|
53335
53382
|
const results = [];
|
|
53336
53383
|
try {
|
|
@@ -53345,13 +53392,13 @@ async function handleResetSessionCommand(directory, _args) {
|
|
|
53345
53392
|
results.push("❌ Failed to delete state.json");
|
|
53346
53393
|
}
|
|
53347
53394
|
try {
|
|
53348
|
-
const sessionDir =
|
|
53395
|
+
const sessionDir = path38.dirname(validateSwarmPath(directory, "session/state.json"));
|
|
53349
53396
|
if (fs26.existsSync(sessionDir)) {
|
|
53350
53397
|
const files = fs26.readdirSync(sessionDir);
|
|
53351
53398
|
const otherFiles = files.filter((f) => f !== "state.json");
|
|
53352
53399
|
let deletedCount = 0;
|
|
53353
53400
|
for (const file3 of otherFiles) {
|
|
53354
|
-
const filePath =
|
|
53401
|
+
const filePath = path38.join(sessionDir, file3);
|
|
53355
53402
|
if (fs26.lstatSync(filePath).isFile()) {
|
|
53356
53403
|
fs26.unlinkSync(filePath);
|
|
53357
53404
|
deletedCount++;
|
|
@@ -53384,7 +53431,7 @@ var init_reset_session = __esm(() => {
|
|
|
53384
53431
|
|
|
53385
53432
|
// src/summaries/manager.ts
|
|
53386
53433
|
import { mkdirSync as mkdirSync13, readdirSync as readdirSync10, renameSync as renameSync10, rmSync as rmSync4, statSync as statSync10 } from "node:fs";
|
|
53387
|
-
import * as
|
|
53434
|
+
import * as path39 from "node:path";
|
|
53388
53435
|
function sanitizeSummaryId(id) {
|
|
53389
53436
|
if (!id || id.length === 0) {
|
|
53390
53437
|
throw new Error("Invalid summary ID: empty string");
|
|
@@ -53418,9 +53465,9 @@ async function storeSummary(directory, id, fullOutput, summaryText, maxStoredByt
|
|
|
53418
53465
|
if (serializedSize > maxStoredBytes) {
|
|
53419
53466
|
throw new Error(`Summary entry size (${serializedSize} bytes) exceeds maximum (${maxStoredBytes} bytes)`);
|
|
53420
53467
|
}
|
|
53421
|
-
const relativePath =
|
|
53468
|
+
const relativePath = path39.join("summaries", `${sanitizedId}.json`);
|
|
53422
53469
|
const summaryPath = validateSwarmPath(directory, relativePath);
|
|
53423
|
-
const summaryDir =
|
|
53470
|
+
const summaryDir = path39.dirname(summaryPath);
|
|
53424
53471
|
const entry = {
|
|
53425
53472
|
id: sanitizedId,
|
|
53426
53473
|
summaryText,
|
|
@@ -53430,7 +53477,7 @@ async function storeSummary(directory, id, fullOutput, summaryText, maxStoredByt
|
|
|
53430
53477
|
};
|
|
53431
53478
|
const entryJson = JSON.stringify(entry);
|
|
53432
53479
|
mkdirSync13(summaryDir, { recursive: true });
|
|
53433
|
-
const tempPath =
|
|
53480
|
+
const tempPath = path39.join(summaryDir, `${sanitizedId}.json.tmp.${Date.now()}.${process.pid}`);
|
|
53434
53481
|
try {
|
|
53435
53482
|
await Bun.write(tempPath, entryJson);
|
|
53436
53483
|
renameSync10(tempPath, summaryPath);
|
|
@@ -53443,7 +53490,7 @@ async function storeSummary(directory, id, fullOutput, summaryText, maxStoredByt
|
|
|
53443
53490
|
}
|
|
53444
53491
|
async function loadFullOutput(directory, id) {
|
|
53445
53492
|
const sanitizedId = sanitizeSummaryId(id);
|
|
53446
|
-
const relativePath =
|
|
53493
|
+
const relativePath = path39.join("summaries", `${sanitizedId}.json`);
|
|
53447
53494
|
validateSwarmPath(directory, relativePath);
|
|
53448
53495
|
const content = await readSwarmFileAsync(directory, relativePath);
|
|
53449
53496
|
if (content === null) {
|
|
@@ -53505,7 +53552,7 @@ var init_retrieve = __esm(() => {
|
|
|
53505
53552
|
|
|
53506
53553
|
// src/commands/rollback.ts
|
|
53507
53554
|
import * as fs27 from "node:fs";
|
|
53508
|
-
import * as
|
|
53555
|
+
import * as path40 from "node:path";
|
|
53509
53556
|
async function handleRollbackCommand(directory, args2) {
|
|
53510
53557
|
const phaseArg = args2[0];
|
|
53511
53558
|
if (!phaseArg) {
|
|
@@ -53570,8 +53617,8 @@ async function handleRollbackCommand(directory, args2) {
|
|
|
53570
53617
|
if (EXCLUDE_FILES.has(file3) || file3.startsWith("plan-ledger.archived-")) {
|
|
53571
53618
|
continue;
|
|
53572
53619
|
}
|
|
53573
|
-
const src =
|
|
53574
|
-
const dest =
|
|
53620
|
+
const src = path40.join(checkpointDir, file3);
|
|
53621
|
+
const dest = path40.join(swarmDir, file3);
|
|
53575
53622
|
try {
|
|
53576
53623
|
fs27.cpSync(src, dest, { recursive: true, force: true });
|
|
53577
53624
|
successes.push(file3);
|
|
@@ -53590,12 +53637,12 @@ async function handleRollbackCommand(directory, args2) {
|
|
|
53590
53637
|
].join(`
|
|
53591
53638
|
`);
|
|
53592
53639
|
}
|
|
53593
|
-
const existingLedgerPath =
|
|
53640
|
+
const existingLedgerPath = path40.join(swarmDir, "plan-ledger.jsonl");
|
|
53594
53641
|
if (fs27.existsSync(existingLedgerPath)) {
|
|
53595
53642
|
fs27.unlinkSync(existingLedgerPath);
|
|
53596
53643
|
}
|
|
53597
53644
|
try {
|
|
53598
|
-
const planJsonPath =
|
|
53645
|
+
const planJsonPath = path40.join(swarmDir, "plan.json");
|
|
53599
53646
|
if (fs27.existsSync(planJsonPath)) {
|
|
53600
53647
|
const planRaw = fs27.readFileSync(planJsonPath, "utf-8");
|
|
53601
53648
|
const plan = PlanSchema.parse(JSON.parse(planRaw));
|
|
@@ -53673,9 +53720,9 @@ async function handleSimulateCommand(directory, args2) {
|
|
|
53673
53720
|
const report = reportLines.filter(Boolean).join(`
|
|
53674
53721
|
`);
|
|
53675
53722
|
const fs28 = await import("node:fs/promises");
|
|
53676
|
-
const
|
|
53677
|
-
const reportPath =
|
|
53678
|
-
await fs28.mkdir(
|
|
53723
|
+
const path41 = await import("node:path");
|
|
53724
|
+
const reportPath = path41.join(directory, ".swarm", "simulate-report.md");
|
|
53725
|
+
await fs28.mkdir(path41.dirname(reportPath), { recursive: true });
|
|
53679
53726
|
await fs28.writeFile(reportPath, report, "utf-8");
|
|
53680
53727
|
return `${darkMatterPairs.length} hidden coupling pairs detected`;
|
|
53681
53728
|
}
|
|
@@ -53694,7 +53741,7 @@ async function handleSpecifyCommand(_directory, args2) {
|
|
|
53694
53741
|
|
|
53695
53742
|
// src/services/compaction-service.ts
|
|
53696
53743
|
import * as fs28 from "node:fs";
|
|
53697
|
-
import * as
|
|
53744
|
+
import * as path41 from "node:path";
|
|
53698
53745
|
function makeInitialState() {
|
|
53699
53746
|
return {
|
|
53700
53747
|
lastObservationAt: 0,
|
|
@@ -53716,7 +53763,7 @@ function getSessionState(sessionId) {
|
|
|
53716
53763
|
}
|
|
53717
53764
|
function appendSnapshot(directory, tier, budgetPct, message) {
|
|
53718
53765
|
try {
|
|
53719
|
-
const snapshotPath =
|
|
53766
|
+
const snapshotPath = path41.join(directory, ".swarm", "context-snapshot.md");
|
|
53720
53767
|
const timestamp = new Date().toISOString();
|
|
53721
53768
|
const entry = `
|
|
53722
53769
|
## [${tier.toUpperCase()}] ${timestamp} — ${budgetPct.toFixed(1)}% used
|
|
@@ -58025,7 +58072,7 @@ COVERAGE REPORTING:
|
|
|
58025
58072
|
|
|
58026
58073
|
// src/agents/index.ts
|
|
58027
58074
|
import { mkdir as mkdir6, writeFile as writeFile6 } from "node:fs/promises";
|
|
58028
|
-
import * as
|
|
58075
|
+
import * as path42 from "node:path";
|
|
58029
58076
|
function stripSwarmPrefix(agentName, swarmPrefix) {
|
|
58030
58077
|
if (!swarmPrefix || !agentName)
|
|
58031
58078
|
return agentName;
|
|
@@ -58336,14 +58383,14 @@ function getAgentConfigs(config3, directory, sessionId) {
|
|
|
58336
58383
|
}));
|
|
58337
58384
|
if (directory) {
|
|
58338
58385
|
const sid = sessionId ?? `init-${Date.now()}`;
|
|
58339
|
-
const evidenceDir =
|
|
58386
|
+
const evidenceDir = path42.join(directory, ".swarm", "evidence");
|
|
58340
58387
|
const filename = `agent-tools-${sid}.json`;
|
|
58341
58388
|
const snapshotData = JSON.stringify({
|
|
58342
58389
|
sessionId: sid,
|
|
58343
58390
|
generatedAt: new Date().toISOString(),
|
|
58344
58391
|
agents: agentToolSnapshot
|
|
58345
58392
|
}, null, 2);
|
|
58346
|
-
mkdir6(evidenceDir, { recursive: true }).then(() => writeFile6(
|
|
58393
|
+
mkdir6(evidenceDir, { recursive: true }).then(() => writeFile6(path42.join(evidenceDir, filename), snapshotData)).catch(() => {});
|
|
58347
58394
|
}
|
|
58348
58395
|
return result;
|
|
58349
58396
|
}
|
|
@@ -58369,13 +58416,13 @@ __export(exports_evidence_summary_integration, {
|
|
|
58369
58416
|
EvidenceSummaryIntegration: () => EvidenceSummaryIntegration
|
|
58370
58417
|
});
|
|
58371
58418
|
import { existsSync as existsSync24, mkdirSync as mkdirSync14, writeFileSync as writeFileSync6 } from "node:fs";
|
|
58372
|
-
import * as
|
|
58419
|
+
import * as path43 from "node:path";
|
|
58373
58420
|
function persistSummary(projectDir, artifact, filename) {
|
|
58374
|
-
const swarmPath =
|
|
58421
|
+
const swarmPath = path43.join(projectDir, ".swarm");
|
|
58375
58422
|
if (!existsSync24(swarmPath)) {
|
|
58376
58423
|
mkdirSync14(swarmPath, { recursive: true });
|
|
58377
58424
|
}
|
|
58378
|
-
const artifactPath =
|
|
58425
|
+
const artifactPath = path43.join(swarmPath, filename);
|
|
58379
58426
|
const content = JSON.stringify(artifact, null, 2);
|
|
58380
58427
|
writeFileSync6(artifactPath, content, "utf-8");
|
|
58381
58428
|
log("[EvidenceSummaryIntegration] Summary persisted", {
|
|
@@ -58494,7 +58541,7 @@ __export(exports_status_artifact, {
|
|
|
58494
58541
|
AutomationStatusArtifact: () => AutomationStatusArtifact
|
|
58495
58542
|
});
|
|
58496
58543
|
import * as fs30 from "node:fs";
|
|
58497
|
-
import * as
|
|
58544
|
+
import * as path45 from "node:path";
|
|
58498
58545
|
function createEmptySnapshot(mode, capabilities) {
|
|
58499
58546
|
return {
|
|
58500
58547
|
timestamp: Date.now(),
|
|
@@ -58553,7 +58600,7 @@ class AutomationStatusArtifact {
|
|
|
58553
58600
|
});
|
|
58554
58601
|
}
|
|
58555
58602
|
getFilePath() {
|
|
58556
|
-
return
|
|
58603
|
+
return path45.join(this.swarmDir, this.filename);
|
|
58557
58604
|
}
|
|
58558
58605
|
load() {
|
|
58559
58606
|
const filePath = this.getFilePath();
|
|
@@ -58966,12 +59013,12 @@ __export(exports_review_receipt, {
|
|
|
58966
59013
|
});
|
|
58967
59014
|
import * as crypto5 from "node:crypto";
|
|
58968
59015
|
import * as fs34 from "node:fs";
|
|
58969
|
-
import * as
|
|
59016
|
+
import * as path46 from "node:path";
|
|
58970
59017
|
function resolveReceiptsDir(directory) {
|
|
58971
|
-
return
|
|
59018
|
+
return path46.join(directory, ".swarm", "review-receipts");
|
|
58972
59019
|
}
|
|
58973
59020
|
function resolveReceiptIndexPath(directory) {
|
|
58974
|
-
return
|
|
59021
|
+
return path46.join(resolveReceiptsDir(directory), "index.json");
|
|
58975
59022
|
}
|
|
58976
59023
|
function buildReceiptFilename(id, date9) {
|
|
58977
59024
|
const dateStr = date9.toISOString().slice(0, 10);
|
|
@@ -59010,7 +59057,7 @@ async function readReceiptIndex(directory) {
|
|
|
59010
59057
|
}
|
|
59011
59058
|
async function writeReceiptIndex(directory, index) {
|
|
59012
59059
|
const indexPath = resolveReceiptIndexPath(directory);
|
|
59013
|
-
const dir =
|
|
59060
|
+
const dir = path46.dirname(indexPath);
|
|
59014
59061
|
await fs34.promises.mkdir(dir, { recursive: true });
|
|
59015
59062
|
const tmpPath = `${indexPath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2)}`;
|
|
59016
59063
|
await fs34.promises.writeFile(tmpPath, JSON.stringify(index, null, 2), "utf-8");
|
|
@@ -59021,7 +59068,7 @@ async function persistReviewReceipt(directory, receipt) {
|
|
|
59021
59068
|
await fs34.promises.mkdir(receiptsDir, { recursive: true });
|
|
59022
59069
|
const now = new Date(receipt.reviewed_at);
|
|
59023
59070
|
const filename = buildReceiptFilename(receipt.id, now);
|
|
59024
|
-
const receiptPath =
|
|
59071
|
+
const receiptPath = path46.join(receiptsDir, filename);
|
|
59025
59072
|
const tmpPath = `${receiptPath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2)}`;
|
|
59026
59073
|
await fs34.promises.writeFile(tmpPath, JSON.stringify(receipt, null, 2), "utf-8");
|
|
59027
59074
|
fs34.renameSync(tmpPath, receiptPath);
|
|
@@ -59043,7 +59090,7 @@ async function readReceiptById(directory, receiptId) {
|
|
|
59043
59090
|
const entry = index.entries.find((e) => e.id === receiptId);
|
|
59044
59091
|
if (!entry)
|
|
59045
59092
|
return null;
|
|
59046
|
-
const receiptPath =
|
|
59093
|
+
const receiptPath = path46.join(resolveReceiptsDir(directory), entry.filename);
|
|
59047
59094
|
try {
|
|
59048
59095
|
const content = await fs34.promises.readFile(receiptPath, "utf-8");
|
|
59049
59096
|
return JSON.parse(content);
|
|
@@ -59056,7 +59103,7 @@ async function readReceiptsByScopeHash(directory, scopeHash) {
|
|
|
59056
59103
|
const matching = index.entries.filter((e) => e.scope_hash === scopeHash).sort((a, b) => b.reviewed_at.localeCompare(a.reviewed_at));
|
|
59057
59104
|
const receipts = [];
|
|
59058
59105
|
for (const entry of matching) {
|
|
59059
|
-
const receiptPath =
|
|
59106
|
+
const receiptPath = path46.join(resolveReceiptsDir(directory), entry.filename);
|
|
59060
59107
|
try {
|
|
59061
59108
|
const content = await fs34.promises.readFile(receiptPath, "utf-8");
|
|
59062
59109
|
receipts.push(JSON.parse(content));
|
|
@@ -59069,7 +59116,7 @@ async function readAllReceipts(directory) {
|
|
|
59069
59116
|
const sorted = [...index.entries].sort((a, b) => b.reviewed_at.localeCompare(a.reviewed_at));
|
|
59070
59117
|
const receipts = [];
|
|
59071
59118
|
for (const entry of sorted) {
|
|
59072
|
-
const receiptPath =
|
|
59119
|
+
const receiptPath = path46.join(resolveReceiptsDir(directory), entry.filename);
|
|
59073
59120
|
try {
|
|
59074
59121
|
const content = await fs34.promises.readFile(receiptPath, "utf-8");
|
|
59075
59122
|
receipts.push(JSON.parse(content));
|
|
@@ -60656,11 +60703,11 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
60656
60703
|
throw toThrow;
|
|
60657
60704
|
}, "quit_");
|
|
60658
60705
|
var scriptDirectory = "";
|
|
60659
|
-
function locateFile(
|
|
60706
|
+
function locateFile(path57) {
|
|
60660
60707
|
if (Module["locateFile"]) {
|
|
60661
|
-
return Module["locateFile"](
|
|
60708
|
+
return Module["locateFile"](path57, scriptDirectory);
|
|
60662
60709
|
}
|
|
60663
|
-
return scriptDirectory +
|
|
60710
|
+
return scriptDirectory + path57;
|
|
60664
60711
|
}
|
|
60665
60712
|
__name(locateFile, "locateFile");
|
|
60666
60713
|
var readAsync, readBinary;
|
|
@@ -62409,13 +62456,13 @@ __export(exports_runtime, {
|
|
|
62409
62456
|
getInitializedLanguages: () => getInitializedLanguages,
|
|
62410
62457
|
clearParserCache: () => clearParserCache
|
|
62411
62458
|
});
|
|
62412
|
-
import * as
|
|
62459
|
+
import * as path57 from "node:path";
|
|
62413
62460
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
62414
62461
|
async function initTreeSitter() {
|
|
62415
62462
|
if (treeSitterInitialized) {
|
|
62416
62463
|
return;
|
|
62417
62464
|
}
|
|
62418
|
-
const thisDir =
|
|
62465
|
+
const thisDir = path57.dirname(fileURLToPath2(import.meta.url));
|
|
62419
62466
|
const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/lang");
|
|
62420
62467
|
if (isSource) {
|
|
62421
62468
|
await Parser.init();
|
|
@@ -62423,7 +62470,7 @@ async function initTreeSitter() {
|
|
|
62423
62470
|
const grammarsDir = getGrammarsDirAbsolute();
|
|
62424
62471
|
await Parser.init({
|
|
62425
62472
|
locateFile(scriptName) {
|
|
62426
|
-
return
|
|
62473
|
+
return path57.join(grammarsDir, scriptName);
|
|
62427
62474
|
}
|
|
62428
62475
|
});
|
|
62429
62476
|
}
|
|
@@ -62444,11 +62491,11 @@ function getWasmFileName(languageId) {
|
|
|
62444
62491
|
return `tree-sitter-${sanitized}.wasm`;
|
|
62445
62492
|
}
|
|
62446
62493
|
function getGrammarsDirAbsolute() {
|
|
62447
|
-
const thisDir =
|
|
62494
|
+
const thisDir = path57.dirname(fileURLToPath2(import.meta.url));
|
|
62448
62495
|
const normalized = thisDir.replace(/\\/g, "/");
|
|
62449
62496
|
const isSource = normalized.endsWith("/src/lang");
|
|
62450
62497
|
const isCliBundle = normalized.endsWith("/cli");
|
|
62451
|
-
return isSource ?
|
|
62498
|
+
return isSource ? path57.join(thisDir, "grammars") : isCliBundle ? path57.join(thisDir, "..", "lang", "grammars") : path57.join(thisDir, "lang", "grammars");
|
|
62452
62499
|
}
|
|
62453
62500
|
async function loadGrammar(languageId) {
|
|
62454
62501
|
if (typeof languageId !== "string" || languageId.length > 100) {
|
|
@@ -62464,7 +62511,7 @@ async function loadGrammar(languageId) {
|
|
|
62464
62511
|
await initTreeSitter();
|
|
62465
62512
|
const parser = new Parser;
|
|
62466
62513
|
const wasmFileName = getWasmFileName(normalizedId);
|
|
62467
|
-
const wasmPath =
|
|
62514
|
+
const wasmPath = path57.join(getGrammarsDirAbsolute(), wasmFileName);
|
|
62468
62515
|
const { existsSync: existsSync30 } = await import("node:fs");
|
|
62469
62516
|
if (!existsSync30(wasmPath)) {
|
|
62470
62517
|
throw new Error(`Grammar file not found for ${languageId}: ${wasmPath}
|
|
@@ -62499,7 +62546,7 @@ async function isGrammarAvailable(languageId) {
|
|
|
62499
62546
|
}
|
|
62500
62547
|
try {
|
|
62501
62548
|
const wasmFileName = getWasmFileName(normalizedId);
|
|
62502
|
-
const wasmPath =
|
|
62549
|
+
const wasmPath = path57.join(getGrammarsDirAbsolute(), wasmFileName);
|
|
62503
62550
|
const { statSync: statSync18 } = await import("node:fs");
|
|
62504
62551
|
statSync18(wasmPath);
|
|
62505
62552
|
return true;
|
|
@@ -62558,13 +62605,13 @@ __export(exports_doc_scan, {
|
|
|
62558
62605
|
import * as crypto7 from "node:crypto";
|
|
62559
62606
|
import * as fs43 from "node:fs";
|
|
62560
62607
|
import { mkdir as mkdir9, readFile as readFile8, writeFile as writeFile8 } from "node:fs/promises";
|
|
62561
|
-
import * as
|
|
62608
|
+
import * as path59 from "node:path";
|
|
62562
62609
|
function normalizeSeparators(filePath) {
|
|
62563
62610
|
return filePath.replace(/\\/g, "/");
|
|
62564
62611
|
}
|
|
62565
62612
|
function matchesDocPattern(filePath, patterns) {
|
|
62566
62613
|
const normalizedPath = normalizeSeparators(filePath);
|
|
62567
|
-
const basename8 =
|
|
62614
|
+
const basename8 = path59.basename(filePath);
|
|
62568
62615
|
for (const pattern of patterns) {
|
|
62569
62616
|
if (!pattern.includes("/") && !pattern.includes("\\")) {
|
|
62570
62617
|
if (basename8 === pattern) {
|
|
@@ -62620,7 +62667,7 @@ function stripMarkdown(text) {
|
|
|
62620
62667
|
return text.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/`([^`]+)`/g, "$1").replace(/^\s*[-*•]\s+/gm, "").replace(/^\s*\d+\.\s+/gm, "").trim();
|
|
62621
62668
|
}
|
|
62622
62669
|
async function scanDocIndex(directory) {
|
|
62623
|
-
const manifestPath =
|
|
62670
|
+
const manifestPath = path59.join(directory, ".swarm", "doc-manifest.json");
|
|
62624
62671
|
const defaultPatterns = DocsConfigSchema.parse({}).doc_patterns;
|
|
62625
62672
|
const extraPatterns = [
|
|
62626
62673
|
"ARCHITECTURE.md",
|
|
@@ -62637,7 +62684,7 @@ async function scanDocIndex(directory) {
|
|
|
62637
62684
|
let cacheValid = true;
|
|
62638
62685
|
for (const file3 of existingManifest.files) {
|
|
62639
62686
|
try {
|
|
62640
|
-
const fullPath =
|
|
62687
|
+
const fullPath = path59.join(directory, file3.path);
|
|
62641
62688
|
const stat3 = fs43.statSync(fullPath);
|
|
62642
62689
|
if (stat3.mtimeMs > file3.mtime) {
|
|
62643
62690
|
cacheValid = false;
|
|
@@ -62667,7 +62714,7 @@ async function scanDocIndex(directory) {
|
|
|
62667
62714
|
}
|
|
62668
62715
|
const entries = rawEntries.filter((e) => typeof e === "string");
|
|
62669
62716
|
for (const entry of entries) {
|
|
62670
|
-
const fullPath =
|
|
62717
|
+
const fullPath = path59.join(directory, entry);
|
|
62671
62718
|
let stat3;
|
|
62672
62719
|
try {
|
|
62673
62720
|
stat3 = fs43.statSync(fullPath);
|
|
@@ -62703,7 +62750,7 @@ async function scanDocIndex(directory) {
|
|
|
62703
62750
|
} catch {
|
|
62704
62751
|
continue;
|
|
62705
62752
|
}
|
|
62706
|
-
const { title, summary } = extractTitleAndSummary(content,
|
|
62753
|
+
const { title, summary } = extractTitleAndSummary(content, path59.basename(entry));
|
|
62707
62754
|
const lineCount = content.split(`
|
|
62708
62755
|
`).length;
|
|
62709
62756
|
discoveredFiles.push({
|
|
@@ -62729,7 +62776,7 @@ async function scanDocIndex(directory) {
|
|
|
62729
62776
|
files: discoveredFiles
|
|
62730
62777
|
};
|
|
62731
62778
|
try {
|
|
62732
|
-
await mkdir9(
|
|
62779
|
+
await mkdir9(path59.dirname(manifestPath), { recursive: true });
|
|
62733
62780
|
await writeFile8(manifestPath, JSON.stringify(manifest, null, 2), "utf-8");
|
|
62734
62781
|
} catch {}
|
|
62735
62782
|
return { manifest, cached: false };
|
|
@@ -62768,7 +62815,7 @@ function extractConstraintsFromContent(content) {
|
|
|
62768
62815
|
return constraints;
|
|
62769
62816
|
}
|
|
62770
62817
|
async function extractDocConstraints(directory, taskFiles, taskDescription) {
|
|
62771
|
-
const manifestPath =
|
|
62818
|
+
const manifestPath = path59.join(directory, ".swarm", "doc-manifest.json");
|
|
62772
62819
|
let manifest;
|
|
62773
62820
|
try {
|
|
62774
62821
|
const content = await readFile8(manifestPath, "utf-8");
|
|
@@ -62794,7 +62841,7 @@ async function extractDocConstraints(directory, taskFiles, taskDescription) {
|
|
|
62794
62841
|
}
|
|
62795
62842
|
let fullContent;
|
|
62796
62843
|
try {
|
|
62797
|
-
fullContent = await readFile8(
|
|
62844
|
+
fullContent = await readFile8(path59.join(directory, docFile.path), "utf-8");
|
|
62798
62845
|
} catch {
|
|
62799
62846
|
skippedCount++;
|
|
62800
62847
|
continue;
|
|
@@ -62817,7 +62864,7 @@ async function extractDocConstraints(directory, taskFiles, taskDescription) {
|
|
|
62817
62864
|
tier: "swarm",
|
|
62818
62865
|
lesson: constraint,
|
|
62819
62866
|
category: "architecture",
|
|
62820
|
-
tags: ["doc-scan",
|
|
62867
|
+
tags: ["doc-scan", path59.basename(docFile.path)],
|
|
62821
62868
|
scope: "global",
|
|
62822
62869
|
confidence: 0.5,
|
|
62823
62870
|
status: "candidate",
|
|
@@ -62890,7 +62937,7 @@ var init_doc_scan = __esm(() => {
|
|
|
62890
62937
|
}
|
|
62891
62938
|
} catch {}
|
|
62892
62939
|
if (force) {
|
|
62893
|
-
const manifestPath =
|
|
62940
|
+
const manifestPath = path59.join(directory, ".swarm", "doc-manifest.json");
|
|
62894
62941
|
try {
|
|
62895
62942
|
fs43.unlinkSync(manifestPath);
|
|
62896
62943
|
} catch {}
|
|
@@ -63081,9 +63128,9 @@ __export(exports_curator_drift, {
|
|
|
63081
63128
|
buildDriftInjectionText: () => buildDriftInjectionText
|
|
63082
63129
|
});
|
|
63083
63130
|
import * as fs46 from "node:fs";
|
|
63084
|
-
import * as
|
|
63131
|
+
import * as path62 from "node:path";
|
|
63085
63132
|
async function readPriorDriftReports(directory) {
|
|
63086
|
-
const swarmDir =
|
|
63133
|
+
const swarmDir = path62.join(directory, ".swarm");
|
|
63087
63134
|
const entries = await fs46.promises.readdir(swarmDir).catch(() => null);
|
|
63088
63135
|
if (entries === null)
|
|
63089
63136
|
return [];
|
|
@@ -63110,7 +63157,7 @@ async function readPriorDriftReports(directory) {
|
|
|
63110
63157
|
async function writeDriftReport(directory, report) {
|
|
63111
63158
|
const filename = `${DRIFT_REPORT_PREFIX}${report.phase}.json`;
|
|
63112
63159
|
const filePath = validateSwarmPath(directory, filename);
|
|
63113
|
-
const swarmDir =
|
|
63160
|
+
const swarmDir = path62.dirname(filePath);
|
|
63114
63161
|
await fs46.promises.mkdir(swarmDir, { recursive: true });
|
|
63115
63162
|
try {
|
|
63116
63163
|
await fs46.promises.writeFile(filePath, JSON.stringify(report, null, 2), "utf-8");
|
|
@@ -63245,7 +63292,7 @@ var init_curator_drift = __esm(() => {
|
|
|
63245
63292
|
init_package();
|
|
63246
63293
|
init_agents2();
|
|
63247
63294
|
import * as fs87 from "node:fs";
|
|
63248
|
-
import * as
|
|
63295
|
+
import * as path105 from "node:path";
|
|
63249
63296
|
|
|
63250
63297
|
// src/background/index.ts
|
|
63251
63298
|
init_event_bus();
|
|
@@ -63256,7 +63303,7 @@ init_manager3();
|
|
|
63256
63303
|
init_manager();
|
|
63257
63304
|
init_utils();
|
|
63258
63305
|
import * as fs29 from "node:fs";
|
|
63259
|
-
import * as
|
|
63306
|
+
import * as path44 from "node:path";
|
|
63260
63307
|
|
|
63261
63308
|
class PlanSyncWorker {
|
|
63262
63309
|
directory;
|
|
@@ -63280,10 +63327,10 @@ class PlanSyncWorker {
|
|
|
63280
63327
|
this.onSyncComplete = options.onSyncComplete;
|
|
63281
63328
|
}
|
|
63282
63329
|
getSwarmDir() {
|
|
63283
|
-
return
|
|
63330
|
+
return path44.resolve(this.directory, ".swarm");
|
|
63284
63331
|
}
|
|
63285
63332
|
getPlanJsonPath() {
|
|
63286
|
-
return
|
|
63333
|
+
return path44.join(this.getSwarmDir(), "plan.json");
|
|
63287
63334
|
}
|
|
63288
63335
|
start() {
|
|
63289
63336
|
if (this.disposed) {
|
|
@@ -63502,8 +63549,8 @@ class PlanSyncWorker {
|
|
|
63502
63549
|
checkForUnauthorizedWrite() {
|
|
63503
63550
|
try {
|
|
63504
63551
|
const swarmDir = this.getSwarmDir();
|
|
63505
|
-
const planJsonPath =
|
|
63506
|
-
const markerPath =
|
|
63552
|
+
const planJsonPath = path44.join(swarmDir, "plan.json");
|
|
63553
|
+
const markerPath = path44.join(swarmDir, ".plan-write-marker");
|
|
63507
63554
|
const planStats = fs29.statSync(planJsonPath);
|
|
63508
63555
|
const planMtimeMs = Math.floor(planStats.mtimeMs);
|
|
63509
63556
|
const markerContent = fs29.readFileSync(markerPath, "utf8");
|
|
@@ -63740,11 +63787,11 @@ async function doFlush(directory) {
|
|
|
63740
63787
|
const activitySection = renderActivitySection();
|
|
63741
63788
|
const updated = replaceOrAppendSection(existing, "## Agent Activity", activitySection);
|
|
63742
63789
|
const flushedCount = swarmState.pendingEvents;
|
|
63743
|
-
const
|
|
63744
|
-
const tempPath = `${
|
|
63790
|
+
const path46 = nodePath2.join(directory, ".swarm", "context.md");
|
|
63791
|
+
const tempPath = `${path46}.tmp`;
|
|
63745
63792
|
try {
|
|
63746
63793
|
await Bun.write(tempPath, updated);
|
|
63747
|
-
renameSync11(tempPath,
|
|
63794
|
+
renameSync11(tempPath, path46);
|
|
63748
63795
|
} catch (writeError) {
|
|
63749
63796
|
try {
|
|
63750
63797
|
unlinkSync8(tempPath);
|
|
@@ -63795,7 +63842,7 @@ ${content.substring(endIndex + 1)}`;
|
|
|
63795
63842
|
init_manager();
|
|
63796
63843
|
init_utils2();
|
|
63797
63844
|
import * as fs31 from "node:fs";
|
|
63798
|
-
import { join as
|
|
63845
|
+
import { join as join41 } from "node:path";
|
|
63799
63846
|
function createCompactionCustomizerHook(config3, directory) {
|
|
63800
63847
|
const enabled = config3.hooks?.compaction !== false;
|
|
63801
63848
|
if (!enabled) {
|
|
@@ -63840,7 +63887,7 @@ function createCompactionCustomizerHook(config3, directory) {
|
|
|
63840
63887
|
}
|
|
63841
63888
|
}
|
|
63842
63889
|
try {
|
|
63843
|
-
const summariesDir =
|
|
63890
|
+
const summariesDir = join41(directory, ".swarm", "summaries");
|
|
63844
63891
|
const files = await fs31.promises.readdir(summariesDir);
|
|
63845
63892
|
if (files.length > 0) {
|
|
63846
63893
|
const count = files.length;
|
|
@@ -65104,7 +65151,7 @@ init_schema();
|
|
|
65104
65151
|
init_manager();
|
|
65105
65152
|
init_curator();
|
|
65106
65153
|
init_utils2();
|
|
65107
|
-
import * as
|
|
65154
|
+
import * as path47 from "node:path";
|
|
65108
65155
|
function createPhaseMonitorHook(directory, preflightManager, curatorRunner, delegateFactory) {
|
|
65109
65156
|
let lastKnownPhase = null;
|
|
65110
65157
|
const handler = async (input, _output) => {
|
|
@@ -65124,9 +65171,9 @@ function createPhaseMonitorHook(directory, preflightManager, curatorRunner, dele
|
|
|
65124
65171
|
const llmDelegate = delegateFactory?.(sessionId);
|
|
65125
65172
|
const initResult = await runner(directory, curatorConfig, llmDelegate);
|
|
65126
65173
|
if (initResult.briefing) {
|
|
65127
|
-
const briefingPath =
|
|
65174
|
+
const briefingPath = path47.join(directory, ".swarm", "curator-briefing.md");
|
|
65128
65175
|
const { mkdir: mkdir7, writeFile: writeFile7 } = await import("node:fs/promises");
|
|
65129
|
-
await mkdir7(
|
|
65176
|
+
await mkdir7(path47.dirname(briefingPath), { recursive: true });
|
|
65130
65177
|
await writeFile7(briefingPath, initResult.briefing, "utf-8");
|
|
65131
65178
|
const { buildApprovedReceipt: buildApprovedReceipt2, persistReviewReceipt: persistReviewReceipt2 } = await Promise.resolve().then(() => (init_review_receipt(), exports_review_receipt));
|
|
65132
65179
|
const initReceipt = buildApprovedReceipt2({
|
|
@@ -65251,7 +65298,7 @@ ${originalText}`;
|
|
|
65251
65298
|
}
|
|
65252
65299
|
// src/hooks/repo-graph-builder.ts
|
|
65253
65300
|
init_constants();
|
|
65254
|
-
import * as
|
|
65301
|
+
import * as path50 from "node:path";
|
|
65255
65302
|
|
|
65256
65303
|
// src/tools/repo-graph.ts
|
|
65257
65304
|
init_utils2();
|
|
@@ -65260,14 +65307,14 @@ init_path_security();
|
|
|
65260
65307
|
import * as fsSync2 from "node:fs";
|
|
65261
65308
|
import { constants as constants3, existsSync as existsSync28, realpathSync as realpathSync6 } from "node:fs";
|
|
65262
65309
|
import * as fsPromises3 from "node:fs/promises";
|
|
65263
|
-
import * as
|
|
65310
|
+
import * as path49 from "node:path";
|
|
65264
65311
|
|
|
65265
65312
|
// src/tools/symbols.ts
|
|
65266
65313
|
init_zod();
|
|
65267
65314
|
init_create_tool();
|
|
65268
65315
|
init_path_security();
|
|
65269
65316
|
import * as fs35 from "node:fs";
|
|
65270
|
-
import * as
|
|
65317
|
+
import * as path48 from "node:path";
|
|
65271
65318
|
var MAX_FILE_SIZE_BYTES2 = 1024 * 1024;
|
|
65272
65319
|
var WINDOWS_RESERVED_NAMES = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
65273
65320
|
function containsWindowsAttacks(str) {
|
|
@@ -65284,11 +65331,11 @@ function containsWindowsAttacks(str) {
|
|
|
65284
65331
|
}
|
|
65285
65332
|
function isPathInWorkspace(filePath, workspace) {
|
|
65286
65333
|
try {
|
|
65287
|
-
const resolvedPath =
|
|
65334
|
+
const resolvedPath = path48.resolve(workspace, filePath);
|
|
65288
65335
|
const realWorkspace = fs35.realpathSync(workspace);
|
|
65289
65336
|
const realResolvedPath = fs35.realpathSync(resolvedPath);
|
|
65290
|
-
const relativePath =
|
|
65291
|
-
if (relativePath.startsWith("..") ||
|
|
65337
|
+
const relativePath = path48.relative(realWorkspace, realResolvedPath);
|
|
65338
|
+
if (relativePath.startsWith("..") || path48.isAbsolute(relativePath)) {
|
|
65292
65339
|
return false;
|
|
65293
65340
|
}
|
|
65294
65341
|
return true;
|
|
@@ -65300,7 +65347,7 @@ function validatePathForRead(filePath, workspace) {
|
|
|
65300
65347
|
return isPathInWorkspace(filePath, workspace);
|
|
65301
65348
|
}
|
|
65302
65349
|
function extractTSSymbols(filePath, cwd) {
|
|
65303
|
-
const fullPath =
|
|
65350
|
+
const fullPath = path48.join(cwd, filePath);
|
|
65304
65351
|
if (!validatePathForRead(fullPath, cwd)) {
|
|
65305
65352
|
return [];
|
|
65306
65353
|
}
|
|
@@ -65452,7 +65499,7 @@ function extractTSSymbols(filePath, cwd) {
|
|
|
65452
65499
|
});
|
|
65453
65500
|
}
|
|
65454
65501
|
function extractPythonSymbols(filePath, cwd) {
|
|
65455
|
-
const fullPath =
|
|
65502
|
+
const fullPath = path48.join(cwd, filePath);
|
|
65456
65503
|
if (!validatePathForRead(fullPath, cwd)) {
|
|
65457
65504
|
return [];
|
|
65458
65505
|
}
|
|
@@ -65535,7 +65582,7 @@ var symbols = createSwarmTool({
|
|
|
65535
65582
|
}, null, 2);
|
|
65536
65583
|
}
|
|
65537
65584
|
const cwd = directory;
|
|
65538
|
-
const ext =
|
|
65585
|
+
const ext = path48.extname(file3);
|
|
65539
65586
|
if (containsControlChars(file3)) {
|
|
65540
65587
|
return JSON.stringify({
|
|
65541
65588
|
file: file3,
|
|
@@ -65599,7 +65646,7 @@ var symbols = createSwarmTool({
|
|
|
65599
65646
|
var WINDOWS_RENAME_MAX_RETRIES = 3;
|
|
65600
65647
|
var WINDOWS_RENAME_RETRY_DELAY_MS = 50;
|
|
65601
65648
|
function normalizeGraphPath(filePath) {
|
|
65602
|
-
return
|
|
65649
|
+
return path49.normalize(filePath).replace(/\\/g, "/");
|
|
65603
65650
|
}
|
|
65604
65651
|
var REPO_GRAPH_FILENAME = "repo-graph.json";
|
|
65605
65652
|
var GRAPH_SCHEMA_VERSION = "1.0.0";
|
|
@@ -65708,8 +65755,8 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
|
|
|
65708
65755
|
}
|
|
65709
65756
|
try {
|
|
65710
65757
|
if (specifier.startsWith(".")) {
|
|
65711
|
-
const sourceDir =
|
|
65712
|
-
let resolved =
|
|
65758
|
+
const sourceDir = path49.dirname(sourceFile);
|
|
65759
|
+
let resolved = path49.resolve(sourceDir, specifier);
|
|
65713
65760
|
let realResolved;
|
|
65714
65761
|
try {
|
|
65715
65762
|
realResolved = realpathSync6(resolved);
|
|
@@ -65720,7 +65767,7 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
|
|
|
65720
65767
|
try {
|
|
65721
65768
|
realRoot = realpathSync6(workspaceRoot);
|
|
65722
65769
|
} catch {
|
|
65723
|
-
realRoot =
|
|
65770
|
+
realRoot = path49.normalize(workspaceRoot);
|
|
65724
65771
|
}
|
|
65725
65772
|
if (!existsSync28(resolved)) {
|
|
65726
65773
|
const EXTENSIONS = [
|
|
@@ -65752,9 +65799,9 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
|
|
|
65752
65799
|
return null;
|
|
65753
65800
|
}
|
|
65754
65801
|
}
|
|
65755
|
-
const normalizedResolved =
|
|
65756
|
-
const normalizedRoot =
|
|
65757
|
-
if (!normalizedResolved.startsWith(normalizedRoot +
|
|
65802
|
+
const normalizedResolved = path49.normalize(realResolved);
|
|
65803
|
+
const normalizedRoot = path49.normalize(realRoot);
|
|
65804
|
+
if (!normalizedResolved.startsWith(normalizedRoot + path49.sep) && normalizedResolved !== normalizedRoot) {
|
|
65758
65805
|
return null;
|
|
65759
65806
|
}
|
|
65760
65807
|
return resolved;
|
|
@@ -65767,7 +65814,7 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
|
|
|
65767
65814
|
function createEmptyGraph(workspaceRoot) {
|
|
65768
65815
|
return {
|
|
65769
65816
|
schema_version: GRAPH_SCHEMA_VERSION,
|
|
65770
|
-
workspaceRoot:
|
|
65817
|
+
workspaceRoot: path49.normalize(workspaceRoot),
|
|
65771
65818
|
nodes: {},
|
|
65772
65819
|
edges: [],
|
|
65773
65820
|
metadata: {
|
|
@@ -65801,10 +65848,10 @@ function addEdge(graph, edge) {
|
|
|
65801
65848
|
}
|
|
65802
65849
|
}
|
|
65803
65850
|
function getCachedGraph(workspace) {
|
|
65804
|
-
return graphCache.get(
|
|
65851
|
+
return graphCache.get(path49.normalize(workspace));
|
|
65805
65852
|
}
|
|
65806
65853
|
function setCachedGraph(workspace, graph, mtime) {
|
|
65807
|
-
const normalized =
|
|
65854
|
+
const normalized = path49.normalize(workspace);
|
|
65808
65855
|
graphCache.set(normalized, graph);
|
|
65809
65856
|
dirtyFlags.set(normalized, false);
|
|
65810
65857
|
if (mtime !== undefined) {
|
|
@@ -65812,10 +65859,10 @@ function setCachedGraph(workspace, graph, mtime) {
|
|
|
65812
65859
|
}
|
|
65813
65860
|
}
|
|
65814
65861
|
function isDirty(workspace) {
|
|
65815
|
-
return dirtyFlags.get(
|
|
65862
|
+
return dirtyFlags.get(path49.normalize(workspace)) ?? false;
|
|
65816
65863
|
}
|
|
65817
65864
|
function clearCache(workspace) {
|
|
65818
|
-
const normalized =
|
|
65865
|
+
const normalized = path49.normalize(workspace);
|
|
65819
65866
|
graphCache.delete(normalized);
|
|
65820
65867
|
dirtyFlags.delete(normalized);
|
|
65821
65868
|
mtimeCache.delete(normalized);
|
|
@@ -65828,7 +65875,7 @@ function getGraphPath(workspace) {
|
|
|
65828
65875
|
}
|
|
65829
65876
|
async function loadGraph(workspace) {
|
|
65830
65877
|
validateWorkspace(workspace);
|
|
65831
|
-
const normalized =
|
|
65878
|
+
const normalized = path49.normalize(workspace);
|
|
65832
65879
|
const cached3 = getCachedGraph(normalized);
|
|
65833
65880
|
if (cached3 && !isDirty(normalized)) {
|
|
65834
65881
|
try {
|
|
@@ -65922,28 +65969,28 @@ async function saveGraph(workspace, graph, options) {
|
|
|
65922
65969
|
if (!Array.isArray(graph.edges)) {
|
|
65923
65970
|
throw new Error("Graph must have edges array");
|
|
65924
65971
|
}
|
|
65925
|
-
const normalizedWorkspace =
|
|
65972
|
+
const normalizedWorkspace = path49.normalize(workspace);
|
|
65926
65973
|
let realWorkspace;
|
|
65927
65974
|
try {
|
|
65928
65975
|
realWorkspace = realpathSync6(workspace);
|
|
65929
65976
|
} catch {
|
|
65930
65977
|
realWorkspace = normalizedWorkspace;
|
|
65931
65978
|
}
|
|
65932
|
-
const normalizedGraphRoot =
|
|
65979
|
+
const normalizedGraphRoot = path49.normalize(graph.workspaceRoot);
|
|
65933
65980
|
let realGraphRoot;
|
|
65934
65981
|
try {
|
|
65935
65982
|
realGraphRoot = realpathSync6(graph.workspaceRoot);
|
|
65936
65983
|
} catch {
|
|
65937
65984
|
realGraphRoot = normalizedGraphRoot;
|
|
65938
65985
|
}
|
|
65939
|
-
if (
|
|
65986
|
+
if (path49.normalize(realWorkspace) !== path49.normalize(realGraphRoot)) {
|
|
65940
65987
|
throw new Error(`Graph workspaceRoot mismatch: graph was built for "${graph.workspaceRoot}" but save was called for "${workspace}"`);
|
|
65941
65988
|
}
|
|
65942
65989
|
const normalized = normalizedWorkspace;
|
|
65943
65990
|
const graphPath = getGraphPath(workspace);
|
|
65944
65991
|
updateGraphMetadata(graph);
|
|
65945
65992
|
const tempPath = `${graphPath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
65946
|
-
await fsPromises3.mkdir(
|
|
65993
|
+
await fsPromises3.mkdir(path49.dirname(tempPath), { recursive: true });
|
|
65947
65994
|
let lastError = null;
|
|
65948
65995
|
try {
|
|
65949
65996
|
if (options?.createAtomic) {
|
|
@@ -66074,7 +66121,7 @@ function findSourceFiles(dir, stats) {
|
|
|
66074
66121
|
stats.skippedDirs++;
|
|
66075
66122
|
continue;
|
|
66076
66123
|
}
|
|
66077
|
-
const fullPath =
|
|
66124
|
+
const fullPath = path49.join(dir, entry);
|
|
66078
66125
|
let stat3;
|
|
66079
66126
|
try {
|
|
66080
66127
|
stat3 = fsSync2.statSync(fullPath);
|
|
@@ -66085,7 +66132,7 @@ function findSourceFiles(dir, stats) {
|
|
|
66085
66132
|
const subFiles = findSourceFiles(fullPath, stats);
|
|
66086
66133
|
files.push(...subFiles);
|
|
66087
66134
|
} else if (stat3.isFile()) {
|
|
66088
|
-
const ext =
|
|
66135
|
+
const ext = path49.extname(fullPath).toLowerCase();
|
|
66089
66136
|
if (SUPPORTED_EXTENSIONS.includes(ext)) {
|
|
66090
66137
|
files.push(fullPath);
|
|
66091
66138
|
}
|
|
@@ -66094,11 +66141,11 @@ function findSourceFiles(dir, stats) {
|
|
|
66094
66141
|
return files;
|
|
66095
66142
|
}
|
|
66096
66143
|
function toModuleName(filePath, workspaceRoot) {
|
|
66097
|
-
const relative9 =
|
|
66098
|
-
return relative9.split(
|
|
66144
|
+
const relative9 = path49.relative(workspaceRoot, filePath);
|
|
66145
|
+
return relative9.split(path49.sep).join("/");
|
|
66099
66146
|
}
|
|
66100
66147
|
function getLanguage(filePath) {
|
|
66101
|
-
const ext =
|
|
66148
|
+
const ext = path49.extname(filePath).toLowerCase();
|
|
66102
66149
|
return EXTENSION_TO_LANGUAGE[ext] ?? "unknown";
|
|
66103
66150
|
}
|
|
66104
66151
|
function isBinaryContent(content) {
|
|
@@ -66111,7 +66158,7 @@ function buildWorkspaceGraph(workspaceRoot, options) {
|
|
|
66111
66158
|
validateWorkspace(workspaceRoot);
|
|
66112
66159
|
const maxFileSize = options?.maxFileSizeBytes ?? 1024 * 1024;
|
|
66113
66160
|
const maxFiles = options?.maxFiles ?? 1e4;
|
|
66114
|
-
const absoluteRoot =
|
|
66161
|
+
const absoluteRoot = path49.resolve(workspaceRoot);
|
|
66115
66162
|
if (!existsSync28(absoluteRoot)) {
|
|
66116
66163
|
throw new Error(`Workspace directory does not exist: ${workspaceRoot}`);
|
|
66117
66164
|
}
|
|
@@ -66152,16 +66199,16 @@ function buildWorkspaceGraph(workspaceRoot, options) {
|
|
|
66152
66199
|
continue;
|
|
66153
66200
|
}
|
|
66154
66201
|
stats.filesScanned++;
|
|
66155
|
-
const ext =
|
|
66202
|
+
const ext = path49.extname(filePath).toLowerCase();
|
|
66156
66203
|
let exports = [];
|
|
66157
66204
|
let parsedImports = [];
|
|
66158
66205
|
try {
|
|
66159
66206
|
if ([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"].includes(ext)) {
|
|
66160
|
-
const relativePath =
|
|
66207
|
+
const relativePath = path49.relative(absoluteRoot, filePath);
|
|
66161
66208
|
const symbols2 = extractTSSymbols(relativePath, absoluteRoot);
|
|
66162
66209
|
exports = symbols2.filter((s) => s.exported).map((s) => s.name);
|
|
66163
66210
|
} else if (ext === ".py") {
|
|
66164
|
-
const relativePath =
|
|
66211
|
+
const relativePath = path49.relative(absoluteRoot, filePath);
|
|
66165
66212
|
const symbols2 = extractPythonSymbols(relativePath, absoluteRoot);
|
|
66166
66213
|
exports = symbols2.filter((s) => s.exported).map((s) => s.name);
|
|
66167
66214
|
}
|
|
@@ -66218,15 +66265,15 @@ function scanFile(filePath, absoluteRoot, maxFileSize) {
|
|
|
66218
66265
|
if (isBinaryContent(content)) {
|
|
66219
66266
|
return { node: null, edges: [] };
|
|
66220
66267
|
}
|
|
66221
|
-
const ext =
|
|
66268
|
+
const ext = path49.extname(filePath).toLowerCase();
|
|
66222
66269
|
let exports = [];
|
|
66223
66270
|
try {
|
|
66224
66271
|
if ([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"].includes(ext)) {
|
|
66225
|
-
const relativePath =
|
|
66272
|
+
const relativePath = path49.relative(absoluteRoot, filePath);
|
|
66226
66273
|
const symbols2 = extractTSSymbols(relativePath, absoluteRoot);
|
|
66227
66274
|
exports = symbols2.filter((s) => s.exported).map((s) => s.name);
|
|
66228
66275
|
} else if (ext === ".py") {
|
|
66229
|
-
const relativePath =
|
|
66276
|
+
const relativePath = path49.relative(absoluteRoot, filePath);
|
|
66230
66277
|
const symbols2 = extractPythonSymbols(relativePath, absoluteRoot);
|
|
66231
66278
|
exports = symbols2.filter((s) => s.exported).map((s) => s.name);
|
|
66232
66279
|
}
|
|
@@ -66270,7 +66317,7 @@ async function updateGraphForFiles(workspaceRoot, filePaths, options) {
|
|
|
66270
66317
|
return graph2;
|
|
66271
66318
|
}
|
|
66272
66319
|
const graph = existingGraph;
|
|
66273
|
-
const absoluteRoot =
|
|
66320
|
+
const absoluteRoot = path49.resolve(workspaceRoot);
|
|
66274
66321
|
const maxFileSize = 1024 * 1024;
|
|
66275
66322
|
const updatedPaths = new Set;
|
|
66276
66323
|
for (const rawFilePath of filePaths) {
|
|
@@ -66383,7 +66430,7 @@ function createRepoGraphBuilderHook(workspaceRoot, deps) {
|
|
|
66383
66430
|
if (!isSupportedSourceFile(filePath)) {
|
|
66384
66431
|
return;
|
|
66385
66432
|
}
|
|
66386
|
-
const absoluteFilePath =
|
|
66433
|
+
const absoluteFilePath = path50.isAbsolute(filePath) ? filePath : path50.resolve(workspaceRoot, filePath);
|
|
66387
66434
|
const normalizedAbsolute = absoluteFilePath.replace(/\\/g, "/");
|
|
66388
66435
|
const normalizedWorkspace = workspaceRoot.replace(/\\/g, "/");
|
|
66389
66436
|
if (!normalizedAbsolute.startsWith(`${normalizedWorkspace}/`) && normalizedAbsolute !== normalizedWorkspace) {
|
|
@@ -66391,7 +66438,7 @@ function createRepoGraphBuilderHook(workspaceRoot, deps) {
|
|
|
66391
66438
|
}
|
|
66392
66439
|
try {
|
|
66393
66440
|
await _updateGraphForFiles(workspaceRoot, [absoluteFilePath]);
|
|
66394
|
-
log(`[repo-graph] Incremental update for ${
|
|
66441
|
+
log(`[repo-graph] Incremental update for ${path50.basename(filePath)}`);
|
|
66395
66442
|
} catch (error93) {
|
|
66396
66443
|
const message = error93 instanceof Error ? error93.message : String(error93);
|
|
66397
66444
|
error48(`[repo-graph] Incremental update failed: ${message}`);
|
|
@@ -66410,14 +66457,14 @@ init_manager2();
|
|
|
66410
66457
|
init_detector();
|
|
66411
66458
|
init_manager();
|
|
66412
66459
|
import * as fs44 from "node:fs";
|
|
66413
|
-
import * as
|
|
66460
|
+
import * as path60 from "node:path";
|
|
66414
66461
|
|
|
66415
66462
|
// src/services/decision-drift-analyzer.ts
|
|
66416
66463
|
init_utils2();
|
|
66417
66464
|
init_manager();
|
|
66418
66465
|
init_utils();
|
|
66419
66466
|
import * as fs36 from "node:fs";
|
|
66420
|
-
import * as
|
|
66467
|
+
import * as path51 from "node:path";
|
|
66421
66468
|
var DEFAULT_DRIFT_CONFIG = {
|
|
66422
66469
|
staleThresholdPhases: 1,
|
|
66423
66470
|
detectContradictions: true,
|
|
@@ -66571,7 +66618,7 @@ async function analyzeDecisionDrift(directory, config3 = {}) {
|
|
|
66571
66618
|
currentPhase = legacyPhase;
|
|
66572
66619
|
}
|
|
66573
66620
|
}
|
|
66574
|
-
const contextPath =
|
|
66621
|
+
const contextPath = path51.join(directory, ".swarm", "context.md");
|
|
66575
66622
|
let contextContent = "";
|
|
66576
66623
|
try {
|
|
66577
66624
|
if (fs36.existsSync(contextPath)) {
|
|
@@ -66710,7 +66757,7 @@ init_utils();
|
|
|
66710
66757
|
init_constants();
|
|
66711
66758
|
init_schema();
|
|
66712
66759
|
import * as fs37 from "node:fs/promises";
|
|
66713
|
-
import * as
|
|
66760
|
+
import * as path52 from "node:path";
|
|
66714
66761
|
function safeGet(obj, key) {
|
|
66715
66762
|
if (!obj || !Object.hasOwn(obj, key))
|
|
66716
66763
|
return;
|
|
@@ -66942,9 +66989,9 @@ async function handleDebuggingSpiral(match, taskId, directory) {
|
|
|
66942
66989
|
let eventLogged = false;
|
|
66943
66990
|
let checkpointCreated = false;
|
|
66944
66991
|
try {
|
|
66945
|
-
const swarmDir =
|
|
66992
|
+
const swarmDir = path52.join(directory, ".swarm");
|
|
66946
66993
|
await fs37.mkdir(swarmDir, { recursive: true });
|
|
66947
|
-
const eventsPath =
|
|
66994
|
+
const eventsPath = path52.join(swarmDir, "events.jsonl");
|
|
66948
66995
|
await fs37.appendFile(eventsPath, `${formatDebuggingSpiralEvent(match, taskId)}
|
|
66949
66996
|
`);
|
|
66950
66997
|
eventLogged = true;
|
|
@@ -67084,7 +67131,7 @@ import * as fs41 from "node:fs";
|
|
|
67084
67131
|
|
|
67085
67132
|
// src/graph/graph-builder.ts
|
|
67086
67133
|
import * as fs39 from "node:fs";
|
|
67087
|
-
import * as
|
|
67134
|
+
import * as path55 from "node:path";
|
|
67088
67135
|
|
|
67089
67136
|
// node_modules/yocto-queue/index.js
|
|
67090
67137
|
class Node {
|
|
@@ -67245,7 +67292,7 @@ function validateConcurrency(concurrency) {
|
|
|
67245
67292
|
// src/graph/import-extractor.ts
|
|
67246
67293
|
init_path_security();
|
|
67247
67294
|
import * as fs38 from "node:fs";
|
|
67248
|
-
import * as
|
|
67295
|
+
import * as path53 from "node:path";
|
|
67249
67296
|
var SOURCE_EXTENSIONS2 = [
|
|
67250
67297
|
".ts",
|
|
67251
67298
|
".tsx",
|
|
@@ -67290,14 +67337,14 @@ function getLanguageFromExtension(ext) {
|
|
|
67290
67337
|
return null;
|
|
67291
67338
|
}
|
|
67292
67339
|
function toRelForwardSlash(absPath, root) {
|
|
67293
|
-
return
|
|
67340
|
+
return path53.relative(root, absPath).replace(/\\/g, "/");
|
|
67294
67341
|
}
|
|
67295
67342
|
function tryResolveTSJS(rawModule, sourceFileAbs) {
|
|
67296
67343
|
if (!rawModule.startsWith(".") && !rawModule.startsWith("/")) {
|
|
67297
67344
|
return null;
|
|
67298
67345
|
}
|
|
67299
|
-
const sourceDir =
|
|
67300
|
-
const baseAbs =
|
|
67346
|
+
const sourceDir = path53.dirname(sourceFileAbs);
|
|
67347
|
+
const baseAbs = path53.resolve(sourceDir, rawModule);
|
|
67301
67348
|
const probe = (basePath) => {
|
|
67302
67349
|
for (const ext of RESOLVE_EXTENSION_CANDIDATES) {
|
|
67303
67350
|
const test = basePath + ext;
|
|
@@ -67308,7 +67355,7 @@ function tryResolveTSJS(rawModule, sourceFileAbs) {
|
|
|
67308
67355
|
} catch {}
|
|
67309
67356
|
}
|
|
67310
67357
|
for (const indexFile of RESOLVE_INDEX_CANDIDATES) {
|
|
67311
|
-
const test =
|
|
67358
|
+
const test = path53.join(basePath, indexFile);
|
|
67312
67359
|
try {
|
|
67313
67360
|
const stat3 = fs38.statSync(test);
|
|
67314
67361
|
if (stat3.isFile())
|
|
@@ -67338,13 +67385,13 @@ function tryResolvePython(rawModule, sourceFileAbs, workspaceRoot) {
|
|
|
67338
67385
|
}
|
|
67339
67386
|
const remainder = rawModule.slice(leadingDots).replace(/\./g, "/");
|
|
67340
67387
|
const upDirs = "../".repeat(Math.max(0, leadingDots - 1));
|
|
67341
|
-
const sourceDir =
|
|
67342
|
-
const baseAbs =
|
|
67388
|
+
const sourceDir = path53.dirname(sourceFileAbs);
|
|
67389
|
+
const baseAbs = path53.resolve(sourceDir, upDirs + remainder);
|
|
67343
67390
|
const accept = (test) => {
|
|
67344
67391
|
try {
|
|
67345
67392
|
const stat3 = fs38.statSync(test);
|
|
67346
67393
|
if (stat3.isFile()) {
|
|
67347
|
-
const rel =
|
|
67394
|
+
const rel = path53.relative(workspaceRoot, test).replace(/\\/g, "/");
|
|
67348
67395
|
if (rel.startsWith(".."))
|
|
67349
67396
|
return null;
|
|
67350
67397
|
return test;
|
|
@@ -67358,7 +67405,7 @@ function tryResolvePython(rawModule, sourceFileAbs, workspaceRoot) {
|
|
|
67358
67405
|
return hit;
|
|
67359
67406
|
}
|
|
67360
67407
|
for (const indexFile of PY_INDEX_CANDIDATES) {
|
|
67361
|
-
const hit = accept(
|
|
67408
|
+
const hit = accept(path53.join(baseAbs, indexFile));
|
|
67362
67409
|
if (hit)
|
|
67363
67410
|
return hit;
|
|
67364
67411
|
}
|
|
@@ -67729,7 +67776,7 @@ function parseRustUses(content) {
|
|
|
67729
67776
|
}
|
|
67730
67777
|
function extractImports2(opts) {
|
|
67731
67778
|
const { absoluteFilePath, workspaceRoot } = opts;
|
|
67732
|
-
const ext =
|
|
67779
|
+
const ext = path53.extname(absoluteFilePath).toLowerCase();
|
|
67733
67780
|
const language = getLanguageFromExtension(ext);
|
|
67734
67781
|
if (!language)
|
|
67735
67782
|
return [];
|
|
@@ -67780,9 +67827,9 @@ function extractImports2(opts) {
|
|
|
67780
67827
|
}
|
|
67781
67828
|
|
|
67782
67829
|
// src/graph/symbol-extractor.ts
|
|
67783
|
-
import * as
|
|
67830
|
+
import * as path54 from "node:path";
|
|
67784
67831
|
function extractExportedSymbols(relativeFilePath, workspaceRoot) {
|
|
67785
|
-
const ext =
|
|
67832
|
+
const ext = path54.extname(relativeFilePath).toLowerCase();
|
|
67786
67833
|
const language = getLanguageFromExtension(ext);
|
|
67787
67834
|
if (!language)
|
|
67788
67835
|
return [];
|
|
@@ -67871,15 +67918,15 @@ function findSourceFiles2(workspaceRoot, skipDirs = DEFAULT_SKIP_DIRS) {
|
|
|
67871
67918
|
if (entry.isDirectory()) {
|
|
67872
67919
|
if (skipDirs.has(entry.name))
|
|
67873
67920
|
continue;
|
|
67874
|
-
stack.push(
|
|
67921
|
+
stack.push(path55.join(dir, entry.name));
|
|
67875
67922
|
continue;
|
|
67876
67923
|
}
|
|
67877
67924
|
if (!entry.isFile())
|
|
67878
67925
|
continue;
|
|
67879
|
-
const ext =
|
|
67926
|
+
const ext = path55.extname(entry.name).toLowerCase();
|
|
67880
67927
|
if (!SOURCE_EXT_SET.has(ext))
|
|
67881
67928
|
continue;
|
|
67882
|
-
out2.push(
|
|
67929
|
+
out2.push(path55.join(dir, entry.name));
|
|
67883
67930
|
}
|
|
67884
67931
|
}
|
|
67885
67932
|
return out2;
|
|
@@ -67907,7 +67954,7 @@ async function buildRepoGraph(workspaceRoot, options = {}) {
|
|
|
67907
67954
|
};
|
|
67908
67955
|
}
|
|
67909
67956
|
async function processFile(absoluteFilePath, workspaceRoot) {
|
|
67910
|
-
const ext =
|
|
67957
|
+
const ext = path55.extname(absoluteFilePath).toLowerCase();
|
|
67911
67958
|
const language = getLanguageFromExtension(ext);
|
|
67912
67959
|
if (!language)
|
|
67913
67960
|
return null;
|
|
@@ -67927,7 +67974,7 @@ async function processFile(absoluteFilePath, workspaceRoot) {
|
|
|
67927
67974
|
} catch {
|
|
67928
67975
|
return null;
|
|
67929
67976
|
}
|
|
67930
|
-
const relPath =
|
|
67977
|
+
const relPath = path55.relative(workspaceRoot, absoluteFilePath).replace(/\\/g, "/");
|
|
67931
67978
|
const imports = extractImports2({
|
|
67932
67979
|
absoluteFilePath,
|
|
67933
67980
|
workspaceRoot,
|
|
@@ -68169,10 +68216,10 @@ function formatSummary(opts) {
|
|
|
68169
68216
|
// src/graph/graph-store.ts
|
|
68170
68217
|
import * as crypto6 from "node:crypto";
|
|
68171
68218
|
import * as fs40 from "node:fs";
|
|
68172
|
-
import * as
|
|
68219
|
+
import * as path56 from "node:path";
|
|
68173
68220
|
var SWARM_DIR = ".swarm";
|
|
68174
68221
|
function getGraphPath2(workspaceRoot) {
|
|
68175
|
-
return
|
|
68222
|
+
return path56.join(workspaceRoot, SWARM_DIR, REPO_GRAPH_FILENAME2);
|
|
68176
68223
|
}
|
|
68177
68224
|
function loadGraph2(workspaceRoot) {
|
|
68178
68225
|
const file3 = getGraphPath2(workspaceRoot);
|
|
@@ -68194,7 +68241,7 @@ function loadGraph2(workspaceRoot) {
|
|
|
68194
68241
|
}
|
|
68195
68242
|
function saveGraph2(workspaceRoot, graph) {
|
|
68196
68243
|
const file3 = getGraphPath2(workspaceRoot);
|
|
68197
|
-
const dir =
|
|
68244
|
+
const dir = path56.dirname(file3);
|
|
68198
68245
|
try {
|
|
68199
68246
|
const stat3 = fs40.lstatSync(dir);
|
|
68200
68247
|
if (stat3.isSymbolicLink()) {
|
|
@@ -68300,7 +68347,7 @@ function buildReviewerBlastRadiusBlock(directory, changedFiles) {
|
|
|
68300
68347
|
// src/hooks/semantic-diff-injection.ts
|
|
68301
68348
|
import * as child_process5 from "node:child_process";
|
|
68302
68349
|
import * as fs42 from "node:fs";
|
|
68303
|
-
import * as
|
|
68350
|
+
import * as path58 from "node:path";
|
|
68304
68351
|
|
|
68305
68352
|
// src/diff/ast-diff.ts
|
|
68306
68353
|
init_tree_sitter();
|
|
@@ -69047,17 +69094,17 @@ async function buildSemanticDiffBlock(directory, changedFiles, maxFiles = 10) {
|
|
|
69047
69094
|
const fileConsumers = {};
|
|
69048
69095
|
if (graph) {
|
|
69049
69096
|
for (const f of filesToProcess) {
|
|
69050
|
-
const relativePath =
|
|
69097
|
+
const relativePath = path58.isAbsolute(f) ? path58.relative(directory, f) : f;
|
|
69051
69098
|
const normalized = normalizeGraphPath2(relativePath);
|
|
69052
69099
|
fileConsumers[normalized] = getImporters(graph, normalized).length;
|
|
69053
69100
|
fileConsumers[f] = fileConsumers[normalized];
|
|
69054
69101
|
}
|
|
69055
69102
|
}
|
|
69056
69103
|
for (const filePath of filesToProcess) {
|
|
69057
|
-
const normalizedPath =
|
|
69058
|
-
const resolvedPath =
|
|
69059
|
-
const relativeToDir =
|
|
69060
|
-
if (relativeToDir.startsWith("..") ||
|
|
69104
|
+
const normalizedPath = path58.normalize(filePath);
|
|
69105
|
+
const resolvedPath = path58.resolve(directory, normalizedPath);
|
|
69106
|
+
const relativeToDir = path58.relative(directory, resolvedPath);
|
|
69107
|
+
if (relativeToDir.startsWith("..") || path58.isAbsolute(relativeToDir)) {
|
|
69061
69108
|
continue;
|
|
69062
69109
|
}
|
|
69063
69110
|
try {
|
|
@@ -69084,7 +69131,7 @@ async function buildSemanticDiffBlock(directory, changedFiles, maxFiles = 10) {
|
|
|
69084
69131
|
stdio: "pipe",
|
|
69085
69132
|
maxBuffer: 5 * 1024 * 1024
|
|
69086
69133
|
}) : "";
|
|
69087
|
-
const newContent = fs42.readFileSync(
|
|
69134
|
+
const newContent = fs42.readFileSync(path58.join(directory, filePath), "utf-8");
|
|
69088
69135
|
const astResult = await computeASTDiff(filePath, oldContent, newContent);
|
|
69089
69136
|
if (astResult && (astResult.changes.length > 0 || astResult.error !== undefined)) {
|
|
69090
69137
|
astDiffs.push(astResult);
|
|
@@ -69426,7 +69473,7 @@ function createSystemEnhancerHook(config3, directory) {
|
|
|
69426
69473
|
await fs44.promises.writeFile(darkMatterPath, darkMatterReport, "utf-8");
|
|
69427
69474
|
warn(`[system-enhancer] Dark matter scan complete: ${darkMatter.length} co-change patterns found`);
|
|
69428
69475
|
try {
|
|
69429
|
-
const projectName =
|
|
69476
|
+
const projectName = path60.basename(path60.resolve(directory));
|
|
69430
69477
|
const knowledgeEntries = darkMatterToKnowledgeEntries2(darkMatter, projectName);
|
|
69431
69478
|
const knowledgePath = resolveSwarmKnowledgePath(directory);
|
|
69432
69479
|
const existingEntries = await readKnowledge(knowledgePath);
|
|
@@ -69625,7 +69672,7 @@ ${lines.join(`
|
|
|
69625
69672
|
try {
|
|
69626
69673
|
const taskId_ccp = ccpSession?.currentTaskId;
|
|
69627
69674
|
if (taskId_ccp && !taskId_ccp.includes("..") && !taskId_ccp.includes("/") && !taskId_ccp.includes("\\") && !taskId_ccp.includes("\x00")) {
|
|
69628
|
-
const evidencePath =
|
|
69675
|
+
const evidencePath = path60.join(directory, ".swarm", "evidence", `${taskId_ccp}.json`);
|
|
69629
69676
|
if (fs44.existsSync(evidencePath)) {
|
|
69630
69677
|
const evidenceContent = fs44.readFileSync(evidencePath, "utf-8");
|
|
69631
69678
|
const evidenceData = JSON.parse(evidenceContent);
|
|
@@ -70771,7 +70818,7 @@ init_hive_promoter();
|
|
|
70771
70818
|
|
|
70772
70819
|
// src/hooks/incremental-verify.ts
|
|
70773
70820
|
import * as fs45 from "node:fs";
|
|
70774
|
-
import * as
|
|
70821
|
+
import * as path61 from "node:path";
|
|
70775
70822
|
|
|
70776
70823
|
// src/hooks/spawn-helper.ts
|
|
70777
70824
|
import * as child_process6 from "node:child_process";
|
|
@@ -70849,18 +70896,18 @@ function spawnAsync(command, cwd, timeoutMs) {
|
|
|
70849
70896
|
// src/hooks/incremental-verify.ts
|
|
70850
70897
|
var emittedSkipAdvisories = new Set;
|
|
70851
70898
|
function detectPackageManager(projectDir) {
|
|
70852
|
-
if (fs45.existsSync(
|
|
70899
|
+
if (fs45.existsSync(path61.join(projectDir, "bun.lockb")))
|
|
70853
70900
|
return "bun";
|
|
70854
|
-
if (fs45.existsSync(
|
|
70901
|
+
if (fs45.existsSync(path61.join(projectDir, "pnpm-lock.yaml")))
|
|
70855
70902
|
return "pnpm";
|
|
70856
|
-
if (fs45.existsSync(
|
|
70903
|
+
if (fs45.existsSync(path61.join(projectDir, "yarn.lock")))
|
|
70857
70904
|
return "yarn";
|
|
70858
|
-
if (fs45.existsSync(
|
|
70905
|
+
if (fs45.existsSync(path61.join(projectDir, "package-lock.json")))
|
|
70859
70906
|
return "npm";
|
|
70860
70907
|
return "bun";
|
|
70861
70908
|
}
|
|
70862
70909
|
function detectTypecheckCommand(projectDir) {
|
|
70863
|
-
const pkgPath =
|
|
70910
|
+
const pkgPath = path61.join(projectDir, "package.json");
|
|
70864
70911
|
if (fs45.existsSync(pkgPath)) {
|
|
70865
70912
|
try {
|
|
70866
70913
|
const pkg = JSON.parse(fs45.readFileSync(pkgPath, "utf8"));
|
|
@@ -70877,8 +70924,8 @@ function detectTypecheckCommand(projectDir) {
|
|
|
70877
70924
|
...pkg.dependencies,
|
|
70878
70925
|
...pkg.devDependencies
|
|
70879
70926
|
};
|
|
70880
|
-
if (!deps?.typescript && !fs45.existsSync(
|
|
70881
|
-
const hasTSMarkers = deps?.typescript || fs45.existsSync(
|
|
70927
|
+
if (!deps?.typescript && !fs45.existsSync(path61.join(projectDir, "tsconfig.json"))) {}
|
|
70928
|
+
const hasTSMarkers = deps?.typescript || fs45.existsSync(path61.join(projectDir, "tsconfig.json"));
|
|
70882
70929
|
if (hasTSMarkers) {
|
|
70883
70930
|
return { command: ["npx", "tsc", "--noEmit"], language: "typescript" };
|
|
70884
70931
|
}
|
|
@@ -70886,13 +70933,13 @@ function detectTypecheckCommand(projectDir) {
|
|
|
70886
70933
|
return null;
|
|
70887
70934
|
}
|
|
70888
70935
|
}
|
|
70889
|
-
if (fs45.existsSync(
|
|
70936
|
+
if (fs45.existsSync(path61.join(projectDir, "go.mod"))) {
|
|
70890
70937
|
return { command: ["go", "vet", "./..."], language: "go" };
|
|
70891
70938
|
}
|
|
70892
|
-
if (fs45.existsSync(
|
|
70939
|
+
if (fs45.existsSync(path61.join(projectDir, "Cargo.toml"))) {
|
|
70893
70940
|
return { command: ["cargo", "check"], language: "rust" };
|
|
70894
70941
|
}
|
|
70895
|
-
if (fs45.existsSync(
|
|
70942
|
+
if (fs45.existsSync(path61.join(projectDir, "pyproject.toml")) || fs45.existsSync(path61.join(projectDir, "requirements.txt")) || fs45.existsSync(path61.join(projectDir, "setup.py"))) {
|
|
70896
70943
|
return { command: null, language: "python" };
|
|
70897
70944
|
}
|
|
70898
70945
|
try {
|
|
@@ -71242,7 +71289,7 @@ init_scope_persistence();
|
|
|
71242
71289
|
init_state();
|
|
71243
71290
|
init_delegation_gate();
|
|
71244
71291
|
init_normalize_tool_name();
|
|
71245
|
-
import * as
|
|
71292
|
+
import * as path63 from "node:path";
|
|
71246
71293
|
var WRITE_TOOLS = new Set(WRITE_TOOL_NAMES);
|
|
71247
71294
|
function createScopeGuardHook(config3, directory, injectAdvisory) {
|
|
71248
71295
|
const enabled = config3.enabled ?? true;
|
|
@@ -71300,13 +71347,13 @@ function createScopeGuardHook(config3, directory, injectAdvisory) {
|
|
|
71300
71347
|
}
|
|
71301
71348
|
function isFileInScope(filePath, scopeEntries, directory) {
|
|
71302
71349
|
const dir = directory ?? process.cwd();
|
|
71303
|
-
const resolvedFile =
|
|
71350
|
+
const resolvedFile = path63.resolve(dir, filePath);
|
|
71304
71351
|
return scopeEntries.some((scope) => {
|
|
71305
|
-
const resolvedScope =
|
|
71352
|
+
const resolvedScope = path63.resolve(dir, scope);
|
|
71306
71353
|
if (resolvedFile === resolvedScope)
|
|
71307
71354
|
return true;
|
|
71308
|
-
const rel =
|
|
71309
|
-
return rel.length > 0 && !rel.startsWith("..") && !
|
|
71355
|
+
const rel = path63.relative(resolvedScope, resolvedFile);
|
|
71356
|
+
return rel.length > 0 && !rel.startsWith("..") && !path63.isAbsolute(rel);
|
|
71310
71357
|
});
|
|
71311
71358
|
}
|
|
71312
71359
|
|
|
@@ -71358,7 +71405,7 @@ function createSelfReviewHook(config3, injectAdvisory) {
|
|
|
71358
71405
|
|
|
71359
71406
|
// src/hooks/slop-detector.ts
|
|
71360
71407
|
import * as fs47 from "node:fs";
|
|
71361
|
-
import * as
|
|
71408
|
+
import * as path64 from "node:path";
|
|
71362
71409
|
var WRITE_EDIT_TOOLS = new Set([
|
|
71363
71410
|
"write",
|
|
71364
71411
|
"edit",
|
|
@@ -71408,7 +71455,7 @@ function walkFiles(dir, exts, deadline) {
|
|
|
71408
71455
|
break;
|
|
71409
71456
|
if (entry.isSymbolicLink())
|
|
71410
71457
|
continue;
|
|
71411
|
-
const full =
|
|
71458
|
+
const full = path64.join(dir, entry.name);
|
|
71412
71459
|
if (entry.isDirectory()) {
|
|
71413
71460
|
if (entry.name === "node_modules" || entry.name === ".git")
|
|
71414
71461
|
continue;
|
|
@@ -71423,7 +71470,7 @@ function walkFiles(dir, exts, deadline) {
|
|
|
71423
71470
|
return results;
|
|
71424
71471
|
}
|
|
71425
71472
|
function checkDeadExports(content, projectDir, startTime) {
|
|
71426
|
-
const hasPackageJson = fs47.existsSync(
|
|
71473
|
+
const hasPackageJson = fs47.existsSync(path64.join(projectDir, "package.json"));
|
|
71427
71474
|
if (!hasPackageJson)
|
|
71428
71475
|
return null;
|
|
71429
71476
|
const exportMatches = content.matchAll(/^\+(?:export)\s+(?:function|class|const|type|interface)\s+(\w{3,})/gm);
|
|
@@ -71631,14 +71678,14 @@ function createSteeringConsumedHook(directory) {
|
|
|
71631
71678
|
// src/hooks/trajectory-logger.ts
|
|
71632
71679
|
init_manager2();
|
|
71633
71680
|
import * as fs50 from "node:fs/promises";
|
|
71634
|
-
import * as
|
|
71681
|
+
import * as path66 from "node:path";
|
|
71635
71682
|
|
|
71636
71683
|
// src/prm/trajectory-store.ts
|
|
71637
71684
|
init_utils2();
|
|
71638
71685
|
import * as fs49 from "node:fs/promises";
|
|
71639
|
-
import * as
|
|
71686
|
+
import * as path65 from "node:path";
|
|
71640
71687
|
function getTrajectoryPath(sessionId, directory) {
|
|
71641
|
-
const relativePath =
|
|
71688
|
+
const relativePath = path65.join("trajectories", `${sessionId}.jsonl`);
|
|
71642
71689
|
return validateSwarmPath(directory, relativePath);
|
|
71643
71690
|
}
|
|
71644
71691
|
var _inMemoryTrajectoryCache = new Map;
|
|
@@ -71657,7 +71704,7 @@ async function appendTrajectoryEntry(sessionId, entry, directory, maxLines = 100
|
|
|
71657
71704
|
_inMemoryTrajectoryCache.set(sessionId, cached3);
|
|
71658
71705
|
}
|
|
71659
71706
|
const trajectoryPath = getTrajectoryPath(sessionId, directory);
|
|
71660
|
-
await fs49.mkdir(
|
|
71707
|
+
await fs49.mkdir(path65.dirname(trajectoryPath), { recursive: true });
|
|
71661
71708
|
const line = `${JSON.stringify(entry)}
|
|
71662
71709
|
`;
|
|
71663
71710
|
await fs49.appendFile(trajectoryPath, line, "utf-8");
|
|
@@ -71696,7 +71743,7 @@ async function cleanupOldTrajectoryFiles(directory, maxAgeDays = 7) {
|
|
|
71696
71743
|
for (const entry of entries) {
|
|
71697
71744
|
if (!entry.isFile())
|
|
71698
71745
|
continue;
|
|
71699
|
-
const filePath =
|
|
71746
|
+
const filePath = path65.join(dirPath, entry.name);
|
|
71700
71747
|
try {
|
|
71701
71748
|
const stat4 = await fs49.stat(filePath);
|
|
71702
71749
|
if (now - stat4.mtimeMs > cutoffMs) {
|
|
@@ -71888,10 +71935,10 @@ function createTrajectoryLoggerHook(config3, _directory) {
|
|
|
71888
71935
|
elapsed_ms
|
|
71889
71936
|
};
|
|
71890
71937
|
const sanitized = sanitizeTaskId2(taskId);
|
|
71891
|
-
const relativePath =
|
|
71938
|
+
const relativePath = path66.join("evidence", sanitized, "trajectory.jsonl");
|
|
71892
71939
|
const trajectoryPath = validateSwarmPath(_directory, relativePath);
|
|
71893
71940
|
try {
|
|
71894
|
-
await fs50.mkdir(
|
|
71941
|
+
await fs50.mkdir(path66.dirname(trajectoryPath), { recursive: true });
|
|
71895
71942
|
const line = `${JSON.stringify(entry)}
|
|
71896
71943
|
`;
|
|
71897
71944
|
await fs50.appendFile(trajectoryPath, line, "utf-8");
|
|
@@ -72442,16 +72489,16 @@ init_telemetry();
|
|
|
72442
72489
|
|
|
72443
72490
|
// src/prm/replay.ts
|
|
72444
72491
|
import { promises as fs51 } from "node:fs";
|
|
72445
|
-
import
|
|
72492
|
+
import path67 from "node:path";
|
|
72446
72493
|
function isPathSafe2(targetPath, basePath) {
|
|
72447
|
-
const resolvedTarget =
|
|
72448
|
-
const resolvedBase =
|
|
72449
|
-
const rel =
|
|
72450
|
-
return !rel.startsWith("..") && !
|
|
72494
|
+
const resolvedTarget = path67.resolve(targetPath);
|
|
72495
|
+
const resolvedBase = path67.resolve(basePath);
|
|
72496
|
+
const rel = path67.relative(resolvedBase, resolvedTarget);
|
|
72497
|
+
return !rel.startsWith("..") && !path67.isAbsolute(rel);
|
|
72451
72498
|
}
|
|
72452
72499
|
function isWithinReplaysDir(targetPath) {
|
|
72453
|
-
const resolved =
|
|
72454
|
-
const parts2 = resolved.split(
|
|
72500
|
+
const resolved = path67.resolve(targetPath);
|
|
72501
|
+
const parts2 = resolved.split(path67.sep);
|
|
72455
72502
|
for (let i2 = 0;i2 < parts2.length - 1; i2++) {
|
|
72456
72503
|
if (parts2[i2] === ".swarm" && parts2[i2 + 1] === "replays") {
|
|
72457
72504
|
return true;
|
|
@@ -72464,10 +72511,10 @@ function sanitizeFilename(input) {
|
|
|
72464
72511
|
}
|
|
72465
72512
|
async function startReplayRecording(sessionID, directory) {
|
|
72466
72513
|
try {
|
|
72467
|
-
const replayDir =
|
|
72514
|
+
const replayDir = path67.join(directory, ".swarm", "replays");
|
|
72468
72515
|
const safeSessionID = sanitizeFilename(sessionID);
|
|
72469
72516
|
const filename = `${safeSessionID}-${Date.now()}.jsonl`;
|
|
72470
|
-
const filepath =
|
|
72517
|
+
const filepath = path67.join(replayDir, filename);
|
|
72471
72518
|
if (!isPathSafe2(filepath, replayDir)) {
|
|
72472
72519
|
console.warn(`[replay] Invalid path detected - path traversal attempt blocked for session ${sessionID}`);
|
|
72473
72520
|
return null;
|
|
@@ -72833,7 +72880,7 @@ init_telemetry();
|
|
|
72833
72880
|
init_dist();
|
|
72834
72881
|
init_create_tool();
|
|
72835
72882
|
import * as fs52 from "node:fs";
|
|
72836
|
-
import * as
|
|
72883
|
+
import * as path68 from "node:path";
|
|
72837
72884
|
init_path_security();
|
|
72838
72885
|
var WINDOWS_RESERVED_NAMES2 = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
72839
72886
|
function containsWindowsAttacks2(str) {
|
|
@@ -72850,14 +72897,14 @@ function containsWindowsAttacks2(str) {
|
|
|
72850
72897
|
}
|
|
72851
72898
|
function isPathInWorkspace2(filePath, workspace) {
|
|
72852
72899
|
try {
|
|
72853
|
-
const resolvedPath =
|
|
72900
|
+
const resolvedPath = path68.resolve(workspace, filePath);
|
|
72854
72901
|
if (!fs52.existsSync(resolvedPath)) {
|
|
72855
72902
|
return true;
|
|
72856
72903
|
}
|
|
72857
72904
|
const realWorkspace = fs52.realpathSync(workspace);
|
|
72858
72905
|
const realResolvedPath = fs52.realpathSync(resolvedPath);
|
|
72859
|
-
const relativePath =
|
|
72860
|
-
if (relativePath.startsWith("..") ||
|
|
72906
|
+
const relativePath = path68.relative(realWorkspace, realResolvedPath);
|
|
72907
|
+
if (relativePath.startsWith("..") || path68.isAbsolute(relativePath)) {
|
|
72861
72908
|
return false;
|
|
72862
72909
|
}
|
|
72863
72910
|
return true;
|
|
@@ -72866,7 +72913,7 @@ function isPathInWorkspace2(filePath, workspace) {
|
|
|
72866
72913
|
}
|
|
72867
72914
|
}
|
|
72868
72915
|
function processFile2(file3, cwd, exportedOnly) {
|
|
72869
|
-
const ext =
|
|
72916
|
+
const ext = path68.extname(file3);
|
|
72870
72917
|
if (containsControlChars(file3)) {
|
|
72871
72918
|
return {
|
|
72872
72919
|
file: file3,
|
|
@@ -72899,7 +72946,7 @@ function processFile2(file3, cwd, exportedOnly) {
|
|
|
72899
72946
|
errorType: "path-outside-workspace"
|
|
72900
72947
|
};
|
|
72901
72948
|
}
|
|
72902
|
-
const fullPath =
|
|
72949
|
+
const fullPath = path68.join(cwd, file3);
|
|
72903
72950
|
if (!fs52.existsSync(fullPath)) {
|
|
72904
72951
|
return {
|
|
72905
72952
|
file: file3,
|
|
@@ -73191,15 +73238,15 @@ init_task_id();
|
|
|
73191
73238
|
init_create_tool();
|
|
73192
73239
|
init_resolve_working_directory();
|
|
73193
73240
|
import * as fs53 from "node:fs";
|
|
73194
|
-
import * as
|
|
73241
|
+
import * as path69 from "node:path";
|
|
73195
73242
|
var EVIDENCE_DIR = ".swarm/evidence";
|
|
73196
73243
|
function isValidTaskId3(taskId) {
|
|
73197
73244
|
return isStrictTaskId(taskId);
|
|
73198
73245
|
}
|
|
73199
73246
|
function isPathWithinSwarm(filePath, workspaceRoot) {
|
|
73200
|
-
const normalizedWorkspace =
|
|
73201
|
-
const swarmPath =
|
|
73202
|
-
const normalizedPath =
|
|
73247
|
+
const normalizedWorkspace = path69.resolve(workspaceRoot);
|
|
73248
|
+
const swarmPath = path69.join(normalizedWorkspace, ".swarm", "evidence");
|
|
73249
|
+
const normalizedPath = path69.resolve(filePath);
|
|
73203
73250
|
return normalizedPath.startsWith(swarmPath);
|
|
73204
73251
|
}
|
|
73205
73252
|
function readEvidenceFile(evidencePath) {
|
|
@@ -73280,7 +73327,7 @@ var check_gate_status = createSwarmTool({
|
|
|
73280
73327
|
};
|
|
73281
73328
|
return JSON.stringify(errorResult, null, 2);
|
|
73282
73329
|
}
|
|
73283
|
-
const evidencePath =
|
|
73330
|
+
const evidencePath = path69.join(directory, EVIDENCE_DIR, `${taskIdInput}.json`);
|
|
73284
73331
|
if (!isPathWithinSwarm(evidencePath, directory)) {
|
|
73285
73332
|
const errorResult = {
|
|
73286
73333
|
taskId: taskIdInput,
|
|
@@ -73377,7 +73424,7 @@ init_state();
|
|
|
73377
73424
|
init_create_tool();
|
|
73378
73425
|
init_resolve_working_directory();
|
|
73379
73426
|
import * as fs54 from "node:fs";
|
|
73380
|
-
import * as
|
|
73427
|
+
import * as path70 from "node:path";
|
|
73381
73428
|
function extractMatches(regex, text) {
|
|
73382
73429
|
return Array.from(text.matchAll(regex));
|
|
73383
73430
|
}
|
|
@@ -73529,10 +73576,10 @@ async function executeCompletionVerify(args2, directory) {
|
|
|
73529
73576
|
let hasFileReadFailure = false;
|
|
73530
73577
|
for (const filePath of fileTargets) {
|
|
73531
73578
|
const normalizedPath = filePath.replace(/\\/g, "/");
|
|
73532
|
-
const resolvedPath =
|
|
73533
|
-
const projectRoot =
|
|
73534
|
-
const relative16 =
|
|
73535
|
-
const withinProject = relative16 === "" || !relative16.startsWith("..") && !
|
|
73579
|
+
const resolvedPath = path70.resolve(directory, normalizedPath);
|
|
73580
|
+
const projectRoot = path70.resolve(directory);
|
|
73581
|
+
const relative16 = path70.relative(projectRoot, resolvedPath);
|
|
73582
|
+
const withinProject = relative16 === "" || !relative16.startsWith("..") && !path70.isAbsolute(relative16);
|
|
73536
73583
|
if (!withinProject) {
|
|
73537
73584
|
blockedTasks.push({
|
|
73538
73585
|
task_id: task.id,
|
|
@@ -73587,8 +73634,8 @@ async function executeCompletionVerify(args2, directory) {
|
|
|
73587
73634
|
blockedTasks
|
|
73588
73635
|
};
|
|
73589
73636
|
try {
|
|
73590
|
-
const evidenceDir =
|
|
73591
|
-
const evidencePath =
|
|
73637
|
+
const evidenceDir = path70.join(directory, ".swarm", "evidence", `${phase}`);
|
|
73638
|
+
const evidencePath = path70.join(evidenceDir, "completion-verify.json");
|
|
73592
73639
|
fs54.mkdirSync(evidenceDir, { recursive: true });
|
|
73593
73640
|
const evidenceBundle = {
|
|
73594
73641
|
schema_version: "1.0.0",
|
|
@@ -73665,11 +73712,11 @@ var completion_verify = createSwarmTool({
|
|
|
73665
73712
|
// src/tools/complexity-hotspots.ts
|
|
73666
73713
|
init_zod();
|
|
73667
73714
|
import * as fs56 from "node:fs";
|
|
73668
|
-
import * as
|
|
73715
|
+
import * as path72 from "node:path";
|
|
73669
73716
|
|
|
73670
73717
|
// src/quality/metrics.ts
|
|
73671
73718
|
import * as fs55 from "node:fs";
|
|
73672
|
-
import * as
|
|
73719
|
+
import * as path71 from "node:path";
|
|
73673
73720
|
var MAX_FILE_SIZE_BYTES4 = 256 * 1024;
|
|
73674
73721
|
var MIN_DUPLICATION_LINES = 10;
|
|
73675
73722
|
function estimateCyclomaticComplexity(content) {
|
|
@@ -73721,7 +73768,7 @@ async function computeComplexityDelta(files, workingDir) {
|
|
|
73721
73768
|
let totalComplexity = 0;
|
|
73722
73769
|
const analyzedFiles = [];
|
|
73723
73770
|
for (const file3 of files) {
|
|
73724
|
-
const fullPath =
|
|
73771
|
+
const fullPath = path71.isAbsolute(file3) ? file3 : path71.join(workingDir, file3);
|
|
73725
73772
|
if (!fs55.existsSync(fullPath)) {
|
|
73726
73773
|
continue;
|
|
73727
73774
|
}
|
|
@@ -73844,7 +73891,7 @@ function countGoExports(content) {
|
|
|
73844
73891
|
function getExportCountForFile(filePath) {
|
|
73845
73892
|
try {
|
|
73846
73893
|
const content = fs55.readFileSync(filePath, "utf-8");
|
|
73847
|
-
const ext =
|
|
73894
|
+
const ext = path71.extname(filePath).toLowerCase();
|
|
73848
73895
|
switch (ext) {
|
|
73849
73896
|
case ".ts":
|
|
73850
73897
|
case ".tsx":
|
|
@@ -73870,7 +73917,7 @@ async function computePublicApiDelta(files, workingDir) {
|
|
|
73870
73917
|
let totalExports = 0;
|
|
73871
73918
|
const analyzedFiles = [];
|
|
73872
73919
|
for (const file3 of files) {
|
|
73873
|
-
const fullPath =
|
|
73920
|
+
const fullPath = path71.isAbsolute(file3) ? file3 : path71.join(workingDir, file3);
|
|
73874
73921
|
if (!fs55.existsSync(fullPath)) {
|
|
73875
73922
|
continue;
|
|
73876
73923
|
}
|
|
@@ -73904,7 +73951,7 @@ async function computeDuplicationRatio(files, workingDir) {
|
|
|
73904
73951
|
let duplicateLines = 0;
|
|
73905
73952
|
const analyzedFiles = [];
|
|
73906
73953
|
for (const file3 of files) {
|
|
73907
|
-
const fullPath =
|
|
73954
|
+
const fullPath = path71.isAbsolute(file3) ? file3 : path71.join(workingDir, file3);
|
|
73908
73955
|
if (!fs55.existsSync(fullPath)) {
|
|
73909
73956
|
continue;
|
|
73910
73957
|
}
|
|
@@ -73937,8 +73984,8 @@ function countCodeLines(content) {
|
|
|
73937
73984
|
return lines.length;
|
|
73938
73985
|
}
|
|
73939
73986
|
function isTestFile(filePath) {
|
|
73940
|
-
const basename10 =
|
|
73941
|
-
const _ext =
|
|
73987
|
+
const basename10 = path71.basename(filePath);
|
|
73988
|
+
const _ext = path71.extname(filePath).toLowerCase();
|
|
73942
73989
|
const testPatterns = [
|
|
73943
73990
|
".test.",
|
|
73944
73991
|
".spec.",
|
|
@@ -74019,8 +74066,8 @@ function matchGlobSegment(globSegments, pathSegments) {
|
|
|
74019
74066
|
}
|
|
74020
74067
|
return gIndex === globSegments.length && pIndex === pathSegments.length;
|
|
74021
74068
|
}
|
|
74022
|
-
function matchesGlobSegment(
|
|
74023
|
-
const normalizedPath =
|
|
74069
|
+
function matchesGlobSegment(path72, glob) {
|
|
74070
|
+
const normalizedPath = path72.replace(/\\/g, "/");
|
|
74024
74071
|
const normalizedGlob = glob.replace(/\\/g, "/");
|
|
74025
74072
|
if (normalizedPath.includes("//")) {
|
|
74026
74073
|
return false;
|
|
@@ -74051,8 +74098,8 @@ function simpleGlobToRegex2(glob) {
|
|
|
74051
74098
|
function hasGlobstar(glob) {
|
|
74052
74099
|
return glob.includes("**");
|
|
74053
74100
|
}
|
|
74054
|
-
function globMatches(
|
|
74055
|
-
const normalizedPath =
|
|
74101
|
+
function globMatches(path72, glob) {
|
|
74102
|
+
const normalizedPath = path72.replace(/\\/g, "/");
|
|
74056
74103
|
if (!glob || glob === "") {
|
|
74057
74104
|
if (normalizedPath.includes("//")) {
|
|
74058
74105
|
return false;
|
|
@@ -74088,7 +74135,7 @@ function shouldExcludeFile(filePath, excludeGlobs) {
|
|
|
74088
74135
|
async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
74089
74136
|
let testLines = 0;
|
|
74090
74137
|
let codeLines = 0;
|
|
74091
|
-
const srcDir =
|
|
74138
|
+
const srcDir = path71.join(workingDir, "src");
|
|
74092
74139
|
if (fs55.existsSync(srcDir)) {
|
|
74093
74140
|
await scanDirectoryForLines(srcDir, enforceGlobs, excludeGlobs, false, (lines) => {
|
|
74094
74141
|
codeLines += lines;
|
|
@@ -74096,14 +74143,14 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
74096
74143
|
}
|
|
74097
74144
|
const possibleSrcDirs = ["lib", "app", "source", "core"];
|
|
74098
74145
|
for (const dir of possibleSrcDirs) {
|
|
74099
|
-
const dirPath =
|
|
74146
|
+
const dirPath = path71.join(workingDir, dir);
|
|
74100
74147
|
if (fs55.existsSync(dirPath)) {
|
|
74101
74148
|
await scanDirectoryForLines(dirPath, enforceGlobs, excludeGlobs, false, (lines) => {
|
|
74102
74149
|
codeLines += lines;
|
|
74103
74150
|
});
|
|
74104
74151
|
}
|
|
74105
74152
|
}
|
|
74106
|
-
const testsDir =
|
|
74153
|
+
const testsDir = path71.join(workingDir, "tests");
|
|
74107
74154
|
if (fs55.existsSync(testsDir)) {
|
|
74108
74155
|
await scanDirectoryForLines(testsDir, ["**"], ["node_modules", "dist"], true, (lines) => {
|
|
74109
74156
|
testLines += lines;
|
|
@@ -74111,7 +74158,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
74111
74158
|
}
|
|
74112
74159
|
const possibleTestDirs = ["test", "__tests__", "specs"];
|
|
74113
74160
|
for (const dir of possibleTestDirs) {
|
|
74114
|
-
const dirPath =
|
|
74161
|
+
const dirPath = path71.join(workingDir, dir);
|
|
74115
74162
|
if (fs55.existsSync(dirPath) && dirPath !== testsDir) {
|
|
74116
74163
|
await scanDirectoryForLines(dirPath, ["**"], ["node_modules", "dist"], true, (lines) => {
|
|
74117
74164
|
testLines += lines;
|
|
@@ -74126,7 +74173,7 @@ async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTest
|
|
|
74126
74173
|
try {
|
|
74127
74174
|
const entries = fs55.readdirSync(dirPath, { withFileTypes: true });
|
|
74128
74175
|
for (const entry of entries) {
|
|
74129
|
-
const fullPath =
|
|
74176
|
+
const fullPath = path71.join(dirPath, entry.name);
|
|
74130
74177
|
if (entry.isDirectory()) {
|
|
74131
74178
|
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === ".git") {
|
|
74132
74179
|
continue;
|
|
@@ -74134,7 +74181,7 @@ async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTest
|
|
|
74134
74181
|
await scanDirectoryForLines(fullPath, includeGlobs, excludeGlobs, isTestScan, callback);
|
|
74135
74182
|
} else if (entry.isFile()) {
|
|
74136
74183
|
const relativePath = fullPath.replace(`${dirPath}/`, "");
|
|
74137
|
-
const ext =
|
|
74184
|
+
const ext = path71.extname(entry.name).toLowerCase();
|
|
74138
74185
|
const validExts = [
|
|
74139
74186
|
".ts",
|
|
74140
74187
|
".tsx",
|
|
@@ -74387,7 +74434,7 @@ async function analyzeHotspots(days, topN, extensions, directory) {
|
|
|
74387
74434
|
const extSet = new Set(extensions.map((e) => e.startsWith(".") ? e : `.${e}`));
|
|
74388
74435
|
const filteredChurn = new Map;
|
|
74389
74436
|
for (const [file3, count] of churnMap) {
|
|
74390
|
-
const ext =
|
|
74437
|
+
const ext = path72.extname(file3).toLowerCase();
|
|
74391
74438
|
if (extSet.has(ext)) {
|
|
74392
74439
|
filteredChurn.set(file3, count);
|
|
74393
74440
|
}
|
|
@@ -74398,7 +74445,7 @@ async function analyzeHotspots(days, topN, extensions, directory) {
|
|
|
74398
74445
|
for (const [file3, churnCount] of filteredChurn) {
|
|
74399
74446
|
let fullPath = file3;
|
|
74400
74447
|
if (!fs56.existsSync(fullPath)) {
|
|
74401
|
-
fullPath =
|
|
74448
|
+
fullPath = path72.join(cwd, file3);
|
|
74402
74449
|
}
|
|
74403
74450
|
const complexity = getComplexityForFile2(fullPath);
|
|
74404
74451
|
if (complexity !== null) {
|
|
@@ -74572,7 +74619,7 @@ import {
|
|
|
74572
74619
|
readFileSync as readFileSync36,
|
|
74573
74620
|
writeFileSync as writeFileSync11
|
|
74574
74621
|
} from "node:fs";
|
|
74575
|
-
import { join as
|
|
74622
|
+
import { join as join65 } from "node:path";
|
|
74576
74623
|
var EVIDENCE_DIR2 = ".swarm/evidence";
|
|
74577
74624
|
var VALID_TASK_ID = /^\d+\.\d+(\.\d+)*$/;
|
|
74578
74625
|
var COUNCIL_GATE_NAME = "council";
|
|
@@ -74606,9 +74653,9 @@ function writeCouncilEvidence(workingDir, synthesis) {
|
|
|
74606
74653
|
if (!VALID_TASK_ID.test(synthesis.taskId)) {
|
|
74607
74654
|
throw new Error(`writeCouncilEvidence: invalid taskId "${synthesis.taskId}" — must match N.M or N.M.P format`);
|
|
74608
74655
|
}
|
|
74609
|
-
const dir =
|
|
74656
|
+
const dir = join65(workingDir, EVIDENCE_DIR2);
|
|
74610
74657
|
mkdirSync18(dir, { recursive: true });
|
|
74611
|
-
const filePath =
|
|
74658
|
+
const filePath = join65(dir, `${synthesis.taskId}.json`);
|
|
74612
74659
|
const existingRoot = Object.create(null);
|
|
74613
74660
|
if (existsSync37(filePath)) {
|
|
74614
74661
|
try {
|
|
@@ -74642,7 +74689,7 @@ function writeCouncilEvidence(workingDir, synthesis) {
|
|
|
74642
74689
|
updated.required_gates = [];
|
|
74643
74690
|
writeFileSync11(filePath, JSON.stringify(updated, null, 2));
|
|
74644
74691
|
try {
|
|
74645
|
-
const councilDir =
|
|
74692
|
+
const councilDir = join65(workingDir, ".swarm", "council");
|
|
74646
74693
|
mkdirSync18(councilDir, { recursive: true });
|
|
74647
74694
|
const auditLine = JSON.stringify({
|
|
74648
74695
|
round: synthesis.roundNumber,
|
|
@@ -74650,7 +74697,7 @@ function writeCouncilEvidence(workingDir, synthesis) {
|
|
|
74650
74697
|
timestamp: synthesis.timestamp,
|
|
74651
74698
|
vetoedBy: synthesis.vetoedBy
|
|
74652
74699
|
});
|
|
74653
|
-
appendFileSync6(
|
|
74700
|
+
appendFileSync6(join65(councilDir, `${synthesis.taskId}.rounds.jsonl`), `${auditLine}
|
|
74654
74701
|
`);
|
|
74655
74702
|
} catch (auditError) {
|
|
74656
74703
|
console.warn(`writeCouncilEvidence: failed to append round-history audit log: ${auditError instanceof Error ? auditError.message : String(auditError)}`);
|
|
@@ -74783,20 +74830,20 @@ function buildUnifiedFeedback(taskId, verdict, vetoedBy, requiredFixes, advisory
|
|
|
74783
74830
|
|
|
74784
74831
|
// src/council/criteria-store.ts
|
|
74785
74832
|
import { existsSync as existsSync38, mkdirSync as mkdirSync19, readFileSync as readFileSync37, writeFileSync as writeFileSync12 } from "node:fs";
|
|
74786
|
-
import { join as
|
|
74833
|
+
import { join as join66 } from "node:path";
|
|
74787
74834
|
var COUNCIL_DIR = ".swarm/council";
|
|
74788
74835
|
function writeCriteria(workingDir, taskId, criteria) {
|
|
74789
|
-
const dir =
|
|
74836
|
+
const dir = join66(workingDir, COUNCIL_DIR);
|
|
74790
74837
|
mkdirSync19(dir, { recursive: true });
|
|
74791
74838
|
const payload = {
|
|
74792
74839
|
taskId,
|
|
74793
74840
|
criteria,
|
|
74794
74841
|
declaredAt: new Date().toISOString()
|
|
74795
74842
|
};
|
|
74796
|
-
writeFileSync12(
|
|
74843
|
+
writeFileSync12(join66(dir, `${safeId(taskId)}.json`), JSON.stringify(payload, null, 2));
|
|
74797
74844
|
}
|
|
74798
74845
|
function readCriteria(workingDir, taskId) {
|
|
74799
|
-
const filePath =
|
|
74846
|
+
const filePath = join66(workingDir, COUNCIL_DIR, `${safeId(taskId)}.json`);
|
|
74800
74847
|
if (!existsSync38(filePath))
|
|
74801
74848
|
return null;
|
|
74802
74849
|
try {
|
|
@@ -74949,7 +74996,7 @@ var submit_council_verdicts = createSwarmTool({
|
|
|
74949
74996
|
init_zod();
|
|
74950
74997
|
init_loader();
|
|
74951
74998
|
import * as fs57 from "node:fs";
|
|
74952
|
-
import * as
|
|
74999
|
+
import * as path73 from "node:path";
|
|
74953
75000
|
|
|
74954
75001
|
// src/council/general-council-advisory.ts
|
|
74955
75002
|
var ADVISORY_HEADER = "[general_council] (advisory; not blocking)";
|
|
@@ -75397,10 +75444,10 @@ var convene_general_council = createSwarmTool({
|
|
|
75397
75444
|
const round1 = input.round1Responses;
|
|
75398
75445
|
const round2 = input.round2Responses ?? [];
|
|
75399
75446
|
const result = synthesizeGeneralCouncil(input.question, input.mode, round1, round2);
|
|
75400
|
-
const evidenceDir =
|
|
75447
|
+
const evidenceDir = path73.join(workingDir, ".swarm", "council", "general");
|
|
75401
75448
|
const safeTimestamp = result.timestamp.replace(/[:.]/g, "-");
|
|
75402
75449
|
const evidenceFile = `${safeTimestamp}-${input.mode}.json`;
|
|
75403
|
-
const evidencePath =
|
|
75450
|
+
const evidencePath = path73.join(evidenceDir, evidenceFile);
|
|
75404
75451
|
try {
|
|
75405
75452
|
await fs57.promises.mkdir(evidenceDir, { recursive: true });
|
|
75406
75453
|
await fs57.promises.writeFile(evidencePath, JSON.stringify(result, null, 2));
|
|
@@ -75637,7 +75684,7 @@ init_state();
|
|
|
75637
75684
|
init_task_id();
|
|
75638
75685
|
init_create_tool();
|
|
75639
75686
|
import * as fs58 from "node:fs";
|
|
75640
|
-
import * as
|
|
75687
|
+
import * as path74 from "node:path";
|
|
75641
75688
|
function validateTaskIdFormat2(taskId) {
|
|
75642
75689
|
return validateTaskIdFormat(taskId);
|
|
75643
75690
|
}
|
|
@@ -75711,8 +75758,8 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
75711
75758
|
};
|
|
75712
75759
|
}
|
|
75713
75760
|
}
|
|
75714
|
-
normalizedDir =
|
|
75715
|
-
const pathParts = normalizedDir.split(
|
|
75761
|
+
normalizedDir = path74.normalize(args2.working_directory);
|
|
75762
|
+
const pathParts = normalizedDir.split(path74.sep);
|
|
75716
75763
|
if (pathParts.includes("..")) {
|
|
75717
75764
|
return {
|
|
75718
75765
|
success: false,
|
|
@@ -75722,10 +75769,10 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
75722
75769
|
]
|
|
75723
75770
|
};
|
|
75724
75771
|
}
|
|
75725
|
-
const resolvedDir =
|
|
75772
|
+
const resolvedDir = path74.resolve(normalizedDir);
|
|
75726
75773
|
try {
|
|
75727
75774
|
const realPath = fs58.realpathSync(resolvedDir);
|
|
75728
|
-
const planPath2 =
|
|
75775
|
+
const planPath2 = path74.join(realPath, ".swarm", "plan.json");
|
|
75729
75776
|
if (!fs58.existsSync(planPath2)) {
|
|
75730
75777
|
return {
|
|
75731
75778
|
success: false,
|
|
@@ -75749,7 +75796,7 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
75749
75796
|
console.warn("[declare-scope] fallbackDir is undefined, falling back to process.cwd()");
|
|
75750
75797
|
}
|
|
75751
75798
|
const directory = normalizedDir || fallbackDir;
|
|
75752
|
-
const planPath =
|
|
75799
|
+
const planPath = path74.resolve(directory, ".swarm", "plan.json");
|
|
75753
75800
|
if (!fs58.existsSync(planPath)) {
|
|
75754
75801
|
return {
|
|
75755
75802
|
success: false,
|
|
@@ -75789,8 +75836,8 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
75789
75836
|
const normalizeErrors = [];
|
|
75790
75837
|
const dir = normalizedDir || fallbackDir || process.cwd();
|
|
75791
75838
|
const mergedFiles = rawMergedFiles.map((file3) => {
|
|
75792
|
-
if (
|
|
75793
|
-
const relativePath =
|
|
75839
|
+
if (path74.isAbsolute(file3)) {
|
|
75840
|
+
const relativePath = path74.relative(dir, file3).replace(/\\/g, "/");
|
|
75794
75841
|
if (relativePath.startsWith("..")) {
|
|
75795
75842
|
normalizeErrors.push(`Path '${file3}' resolves outside the project directory`);
|
|
75796
75843
|
return file3;
|
|
@@ -75851,7 +75898,7 @@ var declare_scope = createSwarmTool({
|
|
|
75851
75898
|
init_zod();
|
|
75852
75899
|
import * as child_process7 from "node:child_process";
|
|
75853
75900
|
import * as fs59 from "node:fs";
|
|
75854
|
-
import * as
|
|
75901
|
+
import * as path75 from "node:path";
|
|
75855
75902
|
init_create_tool();
|
|
75856
75903
|
var MAX_DIFF_LINES = 500;
|
|
75857
75904
|
var DIFF_TIMEOUT_MS = 30000;
|
|
@@ -75880,20 +75927,20 @@ function validateBase(base) {
|
|
|
75880
75927
|
function validatePaths(paths) {
|
|
75881
75928
|
if (!paths)
|
|
75882
75929
|
return null;
|
|
75883
|
-
for (const
|
|
75884
|
-
if (!
|
|
75930
|
+
for (const path76 of paths) {
|
|
75931
|
+
if (!path76 || path76.length === 0) {
|
|
75885
75932
|
return "empty path not allowed";
|
|
75886
75933
|
}
|
|
75887
|
-
if (
|
|
75934
|
+
if (path76.length > MAX_PATH_LENGTH) {
|
|
75888
75935
|
return `path exceeds maximum length of ${MAX_PATH_LENGTH}`;
|
|
75889
75936
|
}
|
|
75890
|
-
if (SHELL_METACHARACTERS2.test(
|
|
75937
|
+
if (SHELL_METACHARACTERS2.test(path76)) {
|
|
75891
75938
|
return "path contains shell metacharacters";
|
|
75892
75939
|
}
|
|
75893
|
-
if (
|
|
75940
|
+
if (path76.startsWith("-")) {
|
|
75894
75941
|
return 'path cannot start with "-" (option-like arguments not allowed)';
|
|
75895
75942
|
}
|
|
75896
|
-
if (CONTROL_CHAR_PATTERN2.test(
|
|
75943
|
+
if (CONTROL_CHAR_PATTERN2.test(path76)) {
|
|
75897
75944
|
return "path contains control characters";
|
|
75898
75945
|
}
|
|
75899
75946
|
}
|
|
@@ -75999,8 +76046,8 @@ var diff = createSwarmTool({
|
|
|
75999
76046
|
if (parts2.length >= 3) {
|
|
76000
76047
|
const additions = parseInt(parts2[0], 10) || 0;
|
|
76001
76048
|
const deletions = parseInt(parts2[1], 10) || 0;
|
|
76002
|
-
const
|
|
76003
|
-
files.push({ path:
|
|
76049
|
+
const path76 = parts2[2];
|
|
76050
|
+
files.push({ path: path76, additions, deletions });
|
|
76004
76051
|
}
|
|
76005
76052
|
}
|
|
76006
76053
|
const contractChanges = [];
|
|
@@ -76040,7 +76087,7 @@ var diff = createSwarmTool({
|
|
|
76040
76087
|
} else if (base === "unstaged") {
|
|
76041
76088
|
const oldRef = `:${file3.path}`;
|
|
76042
76089
|
oldContent = fileExistsInRef(oldRef) ? getContentFromRef(oldRef) : "";
|
|
76043
|
-
newContent = fs59.readFileSync(
|
|
76090
|
+
newContent = fs59.readFileSync(path75.join(directory, file3.path), "utf-8");
|
|
76044
76091
|
} else {
|
|
76045
76092
|
const oldRef = `${base}:${file3.path}`;
|
|
76046
76093
|
oldContent = fileExistsInRef(oldRef) ? getContentFromRef(oldRef) : "";
|
|
@@ -76115,7 +76162,7 @@ var diff = createSwarmTool({
|
|
|
76115
76162
|
init_zod();
|
|
76116
76163
|
import * as child_process8 from "node:child_process";
|
|
76117
76164
|
import * as fs60 from "node:fs";
|
|
76118
|
-
import * as
|
|
76165
|
+
import * as path76 from "node:path";
|
|
76119
76166
|
init_create_tool();
|
|
76120
76167
|
var diff_summary = createSwarmTool({
|
|
76121
76168
|
description: "Generate a filtered semantic diff summary from AST analysis. Returns SemanticDiffSummary with optional filtering by classification or riskLevel.",
|
|
@@ -76163,7 +76210,7 @@ var diff_summary = createSwarmTool({
|
|
|
76163
76210
|
}
|
|
76164
76211
|
try {
|
|
76165
76212
|
let oldContent;
|
|
76166
|
-
const newContent = fs60.readFileSync(
|
|
76213
|
+
const newContent = fs60.readFileSync(path76.join(workingDir, filePath), "utf-8");
|
|
76167
76214
|
if (fileExistsInHead) {
|
|
76168
76215
|
oldContent = child_process8.execFileSync("git", ["show", `HEAD:${filePath}`], {
|
|
76169
76216
|
encoding: "utf-8",
|
|
@@ -76392,7 +76439,7 @@ init_zod();
|
|
|
76392
76439
|
init_create_tool();
|
|
76393
76440
|
init_path_security();
|
|
76394
76441
|
import * as fs61 from "node:fs";
|
|
76395
|
-
import * as
|
|
76442
|
+
import * as path77 from "node:path";
|
|
76396
76443
|
var MAX_FILE_SIZE_BYTES6 = 1024 * 1024;
|
|
76397
76444
|
var MAX_EVIDENCE_FILES = 1000;
|
|
76398
76445
|
var EVIDENCE_DIR3 = ".swarm/evidence";
|
|
@@ -76419,9 +76466,9 @@ function validateRequiredTypes(input) {
|
|
|
76419
76466
|
return null;
|
|
76420
76467
|
}
|
|
76421
76468
|
function isPathWithinSwarm2(filePath, cwd) {
|
|
76422
|
-
const normalizedCwd =
|
|
76423
|
-
const swarmPath =
|
|
76424
|
-
const normalizedPath =
|
|
76469
|
+
const normalizedCwd = path77.resolve(cwd);
|
|
76470
|
+
const swarmPath = path77.join(normalizedCwd, ".swarm");
|
|
76471
|
+
const normalizedPath = path77.resolve(filePath);
|
|
76425
76472
|
return normalizedPath.startsWith(swarmPath);
|
|
76426
76473
|
}
|
|
76427
76474
|
function parseCompletedTasks(planContent) {
|
|
@@ -76451,10 +76498,10 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
76451
76498
|
if (!VALID_EVIDENCE_FILENAME_REGEX.test(filename)) {
|
|
76452
76499
|
continue;
|
|
76453
76500
|
}
|
|
76454
|
-
const filePath =
|
|
76501
|
+
const filePath = path77.join(evidenceDir, filename);
|
|
76455
76502
|
try {
|
|
76456
|
-
const resolvedPath =
|
|
76457
|
-
const evidenceDirResolved =
|
|
76503
|
+
const resolvedPath = path77.resolve(filePath);
|
|
76504
|
+
const evidenceDirResolved = path77.resolve(evidenceDir);
|
|
76458
76505
|
if (!resolvedPath.startsWith(evidenceDirResolved)) {
|
|
76459
76506
|
continue;
|
|
76460
76507
|
}
|
|
@@ -76572,7 +76619,7 @@ var evidence_check = createSwarmTool({
|
|
|
76572
76619
|
return JSON.stringify(errorResult, null, 2);
|
|
76573
76620
|
}
|
|
76574
76621
|
const requiredTypes = requiredTypesValue.split(",").map((t) => t.trim()).filter((t) => t.length > 0).map(normalizeEvidenceType);
|
|
76575
|
-
const planPath =
|
|
76622
|
+
const planPath = path77.join(cwd, PLAN_FILE);
|
|
76576
76623
|
if (!isPathWithinSwarm2(planPath, cwd)) {
|
|
76577
76624
|
const errorResult = {
|
|
76578
76625
|
error: "plan file path validation failed",
|
|
@@ -76604,7 +76651,7 @@ var evidence_check = createSwarmTool({
|
|
|
76604
76651
|
};
|
|
76605
76652
|
return JSON.stringify(result2, null, 2);
|
|
76606
76653
|
}
|
|
76607
|
-
const evidenceDir =
|
|
76654
|
+
const evidenceDir = path77.join(cwd, EVIDENCE_DIR3);
|
|
76608
76655
|
const evidence = readEvidenceFiles(evidenceDir, cwd);
|
|
76609
76656
|
const { tasksWithFullEvidence, gaps } = analyzeGaps(completedTasks, evidence, requiredTypes);
|
|
76610
76657
|
const completeness = completedTasks.length > 0 ? Math.round(tasksWithFullEvidence.length / completedTasks.length * 100) / 100 : 1;
|
|
@@ -76622,7 +76669,7 @@ var evidence_check = createSwarmTool({
|
|
|
76622
76669
|
init_zod();
|
|
76623
76670
|
init_create_tool();
|
|
76624
76671
|
import * as fs62 from "node:fs";
|
|
76625
|
-
import * as
|
|
76672
|
+
import * as path78 from "node:path";
|
|
76626
76673
|
var EXT_MAP = {
|
|
76627
76674
|
python: ".py",
|
|
76628
76675
|
py: ".py",
|
|
@@ -76703,12 +76750,12 @@ var extract_code_blocks = createSwarmTool({
|
|
|
76703
76750
|
if (prefix) {
|
|
76704
76751
|
filename = `${prefix}_${filename}`;
|
|
76705
76752
|
}
|
|
76706
|
-
let filepath =
|
|
76707
|
-
const base =
|
|
76708
|
-
const ext =
|
|
76753
|
+
let filepath = path78.join(targetDir, filename);
|
|
76754
|
+
const base = path78.basename(filepath, path78.extname(filepath));
|
|
76755
|
+
const ext = path78.extname(filepath);
|
|
76709
76756
|
let counter = 1;
|
|
76710
76757
|
while (fs62.existsSync(filepath)) {
|
|
76711
|
-
filepath =
|
|
76758
|
+
filepath = path78.join(targetDir, `${base}_${counter}${ext}`);
|
|
76712
76759
|
counter++;
|
|
76713
76760
|
}
|
|
76714
76761
|
try {
|
|
@@ -76972,7 +77019,7 @@ init_zod();
|
|
|
76972
77019
|
init_create_tool();
|
|
76973
77020
|
init_path_security();
|
|
76974
77021
|
import * as fs63 from "node:fs";
|
|
76975
|
-
import * as
|
|
77022
|
+
import * as path79 from "node:path";
|
|
76976
77023
|
var MAX_FILE_PATH_LENGTH2 = 500;
|
|
76977
77024
|
var MAX_SYMBOL_LENGTH = 256;
|
|
76978
77025
|
var MAX_FILE_SIZE_BYTES7 = 1024 * 1024;
|
|
@@ -77020,7 +77067,7 @@ function validateSymbolInput(symbol3) {
|
|
|
77020
77067
|
return null;
|
|
77021
77068
|
}
|
|
77022
77069
|
function isBinaryFile2(filePath, buffer) {
|
|
77023
|
-
const ext =
|
|
77070
|
+
const ext = path79.extname(filePath).toLowerCase();
|
|
77024
77071
|
if (ext === ".json" || ext === ".md" || ext === ".txt") {
|
|
77025
77072
|
return false;
|
|
77026
77073
|
}
|
|
@@ -77044,15 +77091,15 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
77044
77091
|
const imports = [];
|
|
77045
77092
|
let _resolvedTarget;
|
|
77046
77093
|
try {
|
|
77047
|
-
_resolvedTarget =
|
|
77094
|
+
_resolvedTarget = path79.resolve(targetFile);
|
|
77048
77095
|
} catch {
|
|
77049
77096
|
_resolvedTarget = targetFile;
|
|
77050
77097
|
}
|
|
77051
|
-
const targetBasename =
|
|
77098
|
+
const targetBasename = path79.basename(targetFile, path79.extname(targetFile));
|
|
77052
77099
|
const targetWithExt = targetFile;
|
|
77053
77100
|
const targetWithoutExt = targetFile.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
77054
|
-
const normalizedTargetWithExt =
|
|
77055
|
-
const normalizedTargetWithoutExt =
|
|
77101
|
+
const normalizedTargetWithExt = path79.normalize(targetWithExt).replace(/\\/g, "/");
|
|
77102
|
+
const normalizedTargetWithoutExt = path79.normalize(targetWithoutExt).replace(/\\/g, "/");
|
|
77056
77103
|
const importRegex = /import\s+(?:\{[\s\S]*?\}|(?:\*\s+as\s+\w+)|\w+)\s+from\s+['"`]([^'"`]+)['"`]|import\s+['"`]([^'"`]+)['"`]|require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
77057
77104
|
for (let match = importRegex.exec(content);match !== null; match = importRegex.exec(content)) {
|
|
77058
77105
|
const modulePath = match[1] || match[2] || match[3];
|
|
@@ -77075,9 +77122,9 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
77075
77122
|
}
|
|
77076
77123
|
const _normalizedModule = modulePath.replace(/^\.\//, "").replace(/^\.\.\\/, "../");
|
|
77077
77124
|
let isMatch = false;
|
|
77078
|
-
const _targetDir =
|
|
77079
|
-
const targetExt =
|
|
77080
|
-
const targetBasenameNoExt =
|
|
77125
|
+
const _targetDir = path79.dirname(targetFile);
|
|
77126
|
+
const targetExt = path79.extname(targetFile);
|
|
77127
|
+
const targetBasenameNoExt = path79.basename(targetFile, targetExt);
|
|
77081
77128
|
const moduleNormalized = modulePath.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
77082
77129
|
const moduleName = modulePath.split(/[/\\]/).pop() || "";
|
|
77083
77130
|
const moduleNameNoExt = moduleName.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
@@ -77145,10 +77192,10 @@ function findSourceFiles3(dir, files = [], stats = { skippedDirs: [], skippedFil
|
|
|
77145
77192
|
entries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
77146
77193
|
for (const entry of entries) {
|
|
77147
77194
|
if (SKIP_DIRECTORIES4.has(entry)) {
|
|
77148
|
-
stats.skippedDirs.push(
|
|
77195
|
+
stats.skippedDirs.push(path79.join(dir, entry));
|
|
77149
77196
|
continue;
|
|
77150
77197
|
}
|
|
77151
|
-
const fullPath =
|
|
77198
|
+
const fullPath = path79.join(dir, entry);
|
|
77152
77199
|
let stat4;
|
|
77153
77200
|
try {
|
|
77154
77201
|
stat4 = fs63.statSync(fullPath);
|
|
@@ -77162,7 +77209,7 @@ function findSourceFiles3(dir, files = [], stats = { skippedDirs: [], skippedFil
|
|
|
77162
77209
|
if (stat4.isDirectory()) {
|
|
77163
77210
|
findSourceFiles3(fullPath, files, stats);
|
|
77164
77211
|
} else if (stat4.isFile()) {
|
|
77165
|
-
const ext =
|
|
77212
|
+
const ext = path79.extname(fullPath).toLowerCase();
|
|
77166
77213
|
if (SUPPORTED_EXTENSIONS3.includes(ext)) {
|
|
77167
77214
|
files.push(fullPath);
|
|
77168
77215
|
}
|
|
@@ -77219,7 +77266,7 @@ var imports = createSwarmTool({
|
|
|
77219
77266
|
return JSON.stringify(errorResult, null, 2);
|
|
77220
77267
|
}
|
|
77221
77268
|
try {
|
|
77222
|
-
const targetFile =
|
|
77269
|
+
const targetFile = path79.resolve(file3);
|
|
77223
77270
|
if (!fs63.existsSync(targetFile)) {
|
|
77224
77271
|
const errorResult = {
|
|
77225
77272
|
error: `target file not found: ${file3}`,
|
|
@@ -77241,7 +77288,7 @@ var imports = createSwarmTool({
|
|
|
77241
77288
|
};
|
|
77242
77289
|
return JSON.stringify(errorResult, null, 2);
|
|
77243
77290
|
}
|
|
77244
|
-
const baseDir =
|
|
77291
|
+
const baseDir = path79.dirname(targetFile);
|
|
77245
77292
|
const scanStats = {
|
|
77246
77293
|
skippedDirs: [],
|
|
77247
77294
|
skippedFiles: 0,
|
|
@@ -77785,7 +77832,7 @@ init_qa_gate_profile();
|
|
|
77785
77832
|
init_manager2();
|
|
77786
77833
|
init_curator();
|
|
77787
77834
|
import * as fs65 from "node:fs";
|
|
77788
|
-
import * as
|
|
77835
|
+
import * as path81 from "node:path";
|
|
77789
77836
|
init_knowledge_curator();
|
|
77790
77837
|
init_knowledge_reader();
|
|
77791
77838
|
init_knowledge_store();
|
|
@@ -77798,14 +77845,14 @@ init_plan_schema();
|
|
|
77798
77845
|
init_ledger();
|
|
77799
77846
|
init_manager();
|
|
77800
77847
|
import * as fs64 from "node:fs";
|
|
77801
|
-
import * as
|
|
77848
|
+
import * as path80 from "node:path";
|
|
77802
77849
|
async function writeCheckpoint(directory) {
|
|
77803
77850
|
try {
|
|
77804
77851
|
const plan = await loadPlan(directory);
|
|
77805
77852
|
if (!plan)
|
|
77806
77853
|
return;
|
|
77807
|
-
const jsonPath =
|
|
77808
|
-
const mdPath =
|
|
77854
|
+
const jsonPath = path80.join(directory, "SWARM_PLAN.json");
|
|
77855
|
+
const mdPath = path80.join(directory, "SWARM_PLAN.md");
|
|
77809
77856
|
fs64.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
|
|
77810
77857
|
const md = derivePlanMarkdown(plan);
|
|
77811
77858
|
fs64.writeFileSync(mdPath, md, "utf8");
|
|
@@ -78038,7 +78085,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
78038
78085
|
safeWarn(`[phase_complete] Completion verify error (non-blocking):`, completionError);
|
|
78039
78086
|
}
|
|
78040
78087
|
try {
|
|
78041
|
-
const driftEvidencePath =
|
|
78088
|
+
const driftEvidencePath = path81.join(dir, ".swarm", "evidence", String(phase), "drift-verifier.json");
|
|
78042
78089
|
let driftVerdictFound = false;
|
|
78043
78090
|
let driftVerdictApproved = false;
|
|
78044
78091
|
try {
|
|
@@ -78072,7 +78119,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
78072
78119
|
driftVerdictFound = false;
|
|
78073
78120
|
}
|
|
78074
78121
|
if (!driftVerdictFound) {
|
|
78075
|
-
const specPath =
|
|
78122
|
+
const specPath = path81.join(dir, ".swarm", "spec.md");
|
|
78076
78123
|
const specExists = fs65.existsSync(specPath);
|
|
78077
78124
|
if (!specExists) {
|
|
78078
78125
|
let incompleteTaskCount = 0;
|
|
@@ -78130,7 +78177,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
78130
78177
|
const overrides = session2?.qaGateSessionOverrides ?? {};
|
|
78131
78178
|
const effective = getEffectiveGates(profile, overrides);
|
|
78132
78179
|
if (effective.hallucination_guard === true) {
|
|
78133
|
-
const hgPath =
|
|
78180
|
+
const hgPath = path81.join(dir, ".swarm", "evidence", String(phase), "hallucination-guard.json");
|
|
78134
78181
|
let hgVerdictFound = false;
|
|
78135
78182
|
let hgVerdictApproved = false;
|
|
78136
78183
|
try {
|
|
@@ -78202,7 +78249,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
78202
78249
|
const overrides = session2?.qaGateSessionOverrides ?? {};
|
|
78203
78250
|
const effective = getEffectiveGates(profile, overrides);
|
|
78204
78251
|
if (effective.mutation_test === true) {
|
|
78205
|
-
const mgPath =
|
|
78252
|
+
const mgPath = path81.join(dir, ".swarm", "evidence", String(phase), "mutation-gate.json");
|
|
78206
78253
|
let mgVerdictFound = false;
|
|
78207
78254
|
let mgVerdict;
|
|
78208
78255
|
try {
|
|
@@ -78274,7 +78321,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
78274
78321
|
}
|
|
78275
78322
|
if (retroFound && retroEntry?.lessons_learned && retroEntry.lessons_learned.length > 0) {
|
|
78276
78323
|
try {
|
|
78277
|
-
const projectName =
|
|
78324
|
+
const projectName = path81.basename(dir);
|
|
78278
78325
|
const curationResult = await curateAndStoreSwarm(retroEntry.lessons_learned, projectName, { phase_number: phase }, dir, knowledgeConfig);
|
|
78279
78326
|
if (curationResult) {
|
|
78280
78327
|
const sessionState = swarmState.agentSessions.get(sessionID);
|
|
@@ -78643,7 +78690,7 @@ init_discovery();
|
|
|
78643
78690
|
init_utils();
|
|
78644
78691
|
init_create_tool();
|
|
78645
78692
|
import * as fs66 from "node:fs";
|
|
78646
|
-
import * as
|
|
78693
|
+
import * as path82 from "node:path";
|
|
78647
78694
|
var MAX_OUTPUT_BYTES5 = 52428800;
|
|
78648
78695
|
var AUDIT_TIMEOUT_MS = 120000;
|
|
78649
78696
|
function isValidEcosystem(value) {
|
|
@@ -78671,16 +78718,16 @@ function validateArgs3(args2) {
|
|
|
78671
78718
|
function detectEcosystems(directory) {
|
|
78672
78719
|
const ecosystems = [];
|
|
78673
78720
|
const cwd = directory;
|
|
78674
|
-
if (fs66.existsSync(
|
|
78721
|
+
if (fs66.existsSync(path82.join(cwd, "package.json"))) {
|
|
78675
78722
|
ecosystems.push("npm");
|
|
78676
78723
|
}
|
|
78677
|
-
if (fs66.existsSync(
|
|
78724
|
+
if (fs66.existsSync(path82.join(cwd, "pyproject.toml")) || fs66.existsSync(path82.join(cwd, "requirements.txt"))) {
|
|
78678
78725
|
ecosystems.push("pip");
|
|
78679
78726
|
}
|
|
78680
|
-
if (fs66.existsSync(
|
|
78727
|
+
if (fs66.existsSync(path82.join(cwd, "Cargo.toml"))) {
|
|
78681
78728
|
ecosystems.push("cargo");
|
|
78682
78729
|
}
|
|
78683
|
-
if (fs66.existsSync(
|
|
78730
|
+
if (fs66.existsSync(path82.join(cwd, "go.mod"))) {
|
|
78684
78731
|
ecosystems.push("go");
|
|
78685
78732
|
}
|
|
78686
78733
|
try {
|
|
@@ -78689,13 +78736,13 @@ function detectEcosystems(directory) {
|
|
|
78689
78736
|
ecosystems.push("dotnet");
|
|
78690
78737
|
}
|
|
78691
78738
|
} catch {}
|
|
78692
|
-
if (fs66.existsSync(
|
|
78739
|
+
if (fs66.existsSync(path82.join(cwd, "Gemfile")) || fs66.existsSync(path82.join(cwd, "Gemfile.lock"))) {
|
|
78693
78740
|
ecosystems.push("ruby");
|
|
78694
78741
|
}
|
|
78695
|
-
if (fs66.existsSync(
|
|
78742
|
+
if (fs66.existsSync(path82.join(cwd, "pubspec.yaml"))) {
|
|
78696
78743
|
ecosystems.push("dart");
|
|
78697
78744
|
}
|
|
78698
|
-
if (fs66.existsSync(
|
|
78745
|
+
if (fs66.existsSync(path82.join(cwd, "composer.lock"))) {
|
|
78699
78746
|
ecosystems.push("composer");
|
|
78700
78747
|
}
|
|
78701
78748
|
return ecosystems;
|
|
@@ -79855,7 +79902,7 @@ var pkg_audit = createSwarmTool({
|
|
|
79855
79902
|
init_zod();
|
|
79856
79903
|
init_manager2();
|
|
79857
79904
|
import * as fs67 from "node:fs";
|
|
79858
|
-
import * as
|
|
79905
|
+
import * as path83 from "node:path";
|
|
79859
79906
|
init_utils();
|
|
79860
79907
|
init_create_tool();
|
|
79861
79908
|
var MAX_FILE_SIZE = 1024 * 1024;
|
|
@@ -79978,7 +80025,7 @@ function isScaffoldFile(filePath) {
|
|
|
79978
80025
|
if (SCAFFOLD_PATH_PATTERNS.some((pattern) => pattern.test(normalizedPath))) {
|
|
79979
80026
|
return true;
|
|
79980
80027
|
}
|
|
79981
|
-
const filename =
|
|
80028
|
+
const filename = path83.basename(filePath);
|
|
79982
80029
|
if (SCAFFOLD_FILENAME_PATTERNS.some((pattern) => pattern.test(filename))) {
|
|
79983
80030
|
return true;
|
|
79984
80031
|
}
|
|
@@ -79995,7 +80042,7 @@ function isAllowedByGlobs(filePath, allowGlobs) {
|
|
|
79995
80042
|
if (regex.test(normalizedPath)) {
|
|
79996
80043
|
return true;
|
|
79997
80044
|
}
|
|
79998
|
-
const filename =
|
|
80045
|
+
const filename = path83.basename(filePath);
|
|
79999
80046
|
const filenameRegex = new RegExp(`^${regexPattern}$`, "i");
|
|
80000
80047
|
if (filenameRegex.test(filename)) {
|
|
80001
80048
|
return true;
|
|
@@ -80004,7 +80051,7 @@ function isAllowedByGlobs(filePath, allowGlobs) {
|
|
|
80004
80051
|
return false;
|
|
80005
80052
|
}
|
|
80006
80053
|
function isParserSupported(filePath) {
|
|
80007
|
-
const ext =
|
|
80054
|
+
const ext = path83.extname(filePath).toLowerCase();
|
|
80008
80055
|
return SUPPORTED_PARSER_EXTENSIONS.has(ext);
|
|
80009
80056
|
}
|
|
80010
80057
|
function isPlanFile(filePath) {
|
|
@@ -80251,9 +80298,9 @@ async function placeholderScan(input, directory) {
|
|
|
80251
80298
|
let filesScanned = 0;
|
|
80252
80299
|
const filesWithFindings = new Set;
|
|
80253
80300
|
for (const filePath of changed_files) {
|
|
80254
|
-
const fullPath =
|
|
80255
|
-
const resolvedDirectory =
|
|
80256
|
-
if (!fullPath.startsWith(resolvedDirectory +
|
|
80301
|
+
const fullPath = path83.isAbsolute(filePath) ? filePath : path83.resolve(directory, filePath);
|
|
80302
|
+
const resolvedDirectory = path83.resolve(directory);
|
|
80303
|
+
if (!fullPath.startsWith(resolvedDirectory + path83.sep) && fullPath !== resolvedDirectory) {
|
|
80257
80304
|
continue;
|
|
80258
80305
|
}
|
|
80259
80306
|
if (!fs67.existsSync(fullPath)) {
|
|
@@ -80262,7 +80309,7 @@ async function placeholderScan(input, directory) {
|
|
|
80262
80309
|
if (isAllowedByGlobs(filePath, allow_globs)) {
|
|
80263
80310
|
continue;
|
|
80264
80311
|
}
|
|
80265
|
-
const relativeFilePath =
|
|
80312
|
+
const relativeFilePath = path83.relative(directory, fullPath).replace(/\\/g, "/");
|
|
80266
80313
|
if (FILE_ALLOWLIST.some((allowed) => relativeFilePath.endsWith(allowed))) {
|
|
80267
80314
|
continue;
|
|
80268
80315
|
}
|
|
@@ -80334,7 +80381,7 @@ var placeholder_scan = createSwarmTool({
|
|
|
80334
80381
|
});
|
|
80335
80382
|
// src/tools/pre-check-batch.ts
|
|
80336
80383
|
import * as fs70 from "node:fs";
|
|
80337
|
-
import * as
|
|
80384
|
+
import * as path86 from "node:path";
|
|
80338
80385
|
init_zod();
|
|
80339
80386
|
init_manager2();
|
|
80340
80387
|
init_utils();
|
|
@@ -80471,7 +80518,7 @@ init_zod();
|
|
|
80471
80518
|
init_manager2();
|
|
80472
80519
|
init_detector();
|
|
80473
80520
|
import * as fs69 from "node:fs";
|
|
80474
|
-
import * as
|
|
80521
|
+
import * as path85 from "node:path";
|
|
80475
80522
|
import { extname as extname18 } from "node:path";
|
|
80476
80523
|
|
|
80477
80524
|
// src/sast/rules/c.ts
|
|
@@ -81365,24 +81412,24 @@ init_create_tool();
|
|
|
81365
81412
|
init_utils2();
|
|
81366
81413
|
import * as crypto8 from "node:crypto";
|
|
81367
81414
|
import * as fs68 from "node:fs";
|
|
81368
|
-
import * as
|
|
81415
|
+
import * as path84 from "node:path";
|
|
81369
81416
|
var BASELINE_SCHEMA_VERSION = "1.0.0";
|
|
81370
81417
|
var MAX_BASELINE_FINDINGS = 2000;
|
|
81371
81418
|
var MAX_BASELINE_BYTES = 2 * 1048576;
|
|
81372
81419
|
var LOCK_RETRY_DELAYS_MS = [50, 100, 200, 400, 800];
|
|
81373
81420
|
function normalizeFindingPath(directory, file3) {
|
|
81374
|
-
const resolved =
|
|
81375
|
-
const rel =
|
|
81421
|
+
const resolved = path84.isAbsolute(file3) ? file3 : path84.resolve(directory, file3);
|
|
81422
|
+
const rel = path84.relative(path84.resolve(directory), resolved);
|
|
81376
81423
|
return rel.replace(/\\/g, "/");
|
|
81377
81424
|
}
|
|
81378
81425
|
function baselineRelPath(phase) {
|
|
81379
|
-
return
|
|
81426
|
+
return path84.join("evidence", String(phase), "sast-baseline.json");
|
|
81380
81427
|
}
|
|
81381
81428
|
function tempRelPath(phase) {
|
|
81382
|
-
return
|
|
81429
|
+
return path84.join("evidence", String(phase), `sast-baseline.json.tmp.${Date.now()}.${process.pid}`);
|
|
81383
81430
|
}
|
|
81384
81431
|
function lockRelPath(phase) {
|
|
81385
|
-
return
|
|
81432
|
+
return path84.join("evidence", String(phase), "sast-baseline.json.lock");
|
|
81386
81433
|
}
|
|
81387
81434
|
function getLine(lines, idx) {
|
|
81388
81435
|
if (idx < 0 || idx >= lines.length)
|
|
@@ -81503,8 +81550,8 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
81503
81550
|
message: e instanceof Error ? e.message : "Path validation failed"
|
|
81504
81551
|
};
|
|
81505
81552
|
}
|
|
81506
|
-
fs68.mkdirSync(
|
|
81507
|
-
fs68.mkdirSync(
|
|
81553
|
+
fs68.mkdirSync(path84.dirname(baselinePath), { recursive: true });
|
|
81554
|
+
fs68.mkdirSync(path84.dirname(tempPath), { recursive: true });
|
|
81508
81555
|
const releaseLock = await acquireLock(lockPath);
|
|
81509
81556
|
try {
|
|
81510
81557
|
let existing = null;
|
|
@@ -81771,9 +81818,9 @@ async function sastScan(input, directory, config3) {
|
|
|
81771
81818
|
_filesSkipped++;
|
|
81772
81819
|
continue;
|
|
81773
81820
|
}
|
|
81774
|
-
const resolvedPath =
|
|
81775
|
-
const resolvedDirectory =
|
|
81776
|
-
if (!resolvedPath.startsWith(resolvedDirectory +
|
|
81821
|
+
const resolvedPath = path85.isAbsolute(filePath) ? filePath : path85.resolve(directory, filePath);
|
|
81822
|
+
const resolvedDirectory = path85.resolve(directory);
|
|
81823
|
+
if (!resolvedPath.startsWith(resolvedDirectory + path85.sep) && resolvedPath !== resolvedDirectory) {
|
|
81777
81824
|
_filesSkipped++;
|
|
81778
81825
|
continue;
|
|
81779
81826
|
}
|
|
@@ -82084,18 +82131,18 @@ function validatePath(inputPath, baseDir, workspaceDir) {
|
|
|
82084
82131
|
let resolved;
|
|
82085
82132
|
const isWinAbs = isWindowsAbsolutePath(inputPath);
|
|
82086
82133
|
if (isWinAbs) {
|
|
82087
|
-
resolved =
|
|
82088
|
-
} else if (
|
|
82089
|
-
resolved =
|
|
82134
|
+
resolved = path86.win32.resolve(inputPath);
|
|
82135
|
+
} else if (path86.isAbsolute(inputPath)) {
|
|
82136
|
+
resolved = path86.resolve(inputPath);
|
|
82090
82137
|
} else {
|
|
82091
|
-
resolved =
|
|
82138
|
+
resolved = path86.resolve(baseDir, inputPath);
|
|
82092
82139
|
}
|
|
82093
|
-
const workspaceResolved =
|
|
82140
|
+
const workspaceResolved = path86.resolve(workspaceDir);
|
|
82094
82141
|
let relative20;
|
|
82095
82142
|
if (isWinAbs) {
|
|
82096
|
-
relative20 =
|
|
82143
|
+
relative20 = path86.win32.relative(workspaceResolved, resolved);
|
|
82097
82144
|
} else {
|
|
82098
|
-
relative20 =
|
|
82145
|
+
relative20 = path86.relative(workspaceResolved, resolved);
|
|
82099
82146
|
}
|
|
82100
82147
|
if (relative20.startsWith("..")) {
|
|
82101
82148
|
return "path traversal detected";
|
|
@@ -82160,7 +82207,7 @@ async function runLintOnFiles(linter, files, workspaceDir) {
|
|
|
82160
82207
|
if (typeof file3 !== "string") {
|
|
82161
82208
|
continue;
|
|
82162
82209
|
}
|
|
82163
|
-
const resolvedPath =
|
|
82210
|
+
const resolvedPath = path86.resolve(file3);
|
|
82164
82211
|
const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
|
|
82165
82212
|
if (validationError) {
|
|
82166
82213
|
continue;
|
|
@@ -82317,7 +82364,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
82317
82364
|
skippedFiles++;
|
|
82318
82365
|
continue;
|
|
82319
82366
|
}
|
|
82320
|
-
const resolvedPath =
|
|
82367
|
+
const resolvedPath = path86.resolve(file3);
|
|
82321
82368
|
const validationError = validatePath(resolvedPath, directory, directory);
|
|
82322
82369
|
if (validationError) {
|
|
82323
82370
|
skippedFiles++;
|
|
@@ -82335,7 +82382,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
82335
82382
|
};
|
|
82336
82383
|
}
|
|
82337
82384
|
for (const file3 of validatedFiles) {
|
|
82338
|
-
const ext =
|
|
82385
|
+
const ext = path86.extname(file3).toLowerCase();
|
|
82339
82386
|
if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
|
|
82340
82387
|
skippedFiles++;
|
|
82341
82388
|
continue;
|
|
@@ -82554,7 +82601,7 @@ function classifySastFindings(findings, changedLineRanges, directory) {
|
|
|
82554
82601
|
const preexistingFindings = [];
|
|
82555
82602
|
for (const finding of findings) {
|
|
82556
82603
|
const filePath = finding.location.file;
|
|
82557
|
-
const normalised =
|
|
82604
|
+
const normalised = path86.relative(directory, filePath).replace(/\\/g, "/");
|
|
82558
82605
|
const changedLines = changedLineRanges.get(normalised);
|
|
82559
82606
|
if (changedLines?.has(finding.location.line)) {
|
|
82560
82607
|
newFindings.push(finding);
|
|
@@ -82605,7 +82652,7 @@ async function runPreCheckBatch(input, workspaceDir, contextDir) {
|
|
|
82605
82652
|
warn(`pre_check_batch: Invalid file path: ${file3}`);
|
|
82606
82653
|
continue;
|
|
82607
82654
|
}
|
|
82608
|
-
changedFiles.push(
|
|
82655
|
+
changedFiles.push(path86.resolve(directory, file3));
|
|
82609
82656
|
}
|
|
82610
82657
|
if (changedFiles.length === 0) {
|
|
82611
82658
|
warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
|
|
@@ -82806,7 +82853,7 @@ var pre_check_batch = createSwarmTool({
|
|
|
82806
82853
|
};
|
|
82807
82854
|
return JSON.stringify(errorResult, null, 2);
|
|
82808
82855
|
}
|
|
82809
|
-
const resolvedDirectory =
|
|
82856
|
+
const resolvedDirectory = path86.resolve(typedArgs.directory);
|
|
82810
82857
|
const workspaceAnchor = resolvedDirectory;
|
|
82811
82858
|
const dirError = validateDirectory2(resolvedDirectory, workspaceAnchor);
|
|
82812
82859
|
if (dirError) {
|
|
@@ -82847,7 +82894,7 @@ var pre_check_batch = createSwarmTool({
|
|
|
82847
82894
|
});
|
|
82848
82895
|
// src/tools/repo-map.ts
|
|
82849
82896
|
init_zod();
|
|
82850
|
-
import * as
|
|
82897
|
+
import * as path87 from "node:path";
|
|
82851
82898
|
init_path_security();
|
|
82852
82899
|
init_create_tool();
|
|
82853
82900
|
var VALID_ACTIONS = [
|
|
@@ -82872,7 +82919,7 @@ function validateFile(p) {
|
|
|
82872
82919
|
return "file contains control characters";
|
|
82873
82920
|
if (containsPathTraversal(p))
|
|
82874
82921
|
return "file contains path traversal";
|
|
82875
|
-
if (
|
|
82922
|
+
if (path87.isAbsolute(p) || /^[a-zA-Z]:[\\/]/.test(p)) {
|
|
82876
82923
|
return "file must be a workspace-relative path, not absolute";
|
|
82877
82924
|
}
|
|
82878
82925
|
return null;
|
|
@@ -82895,8 +82942,8 @@ function ok(action, payload) {
|
|
|
82895
82942
|
}
|
|
82896
82943
|
function toRelativeGraphPath(input, workspaceRoot) {
|
|
82897
82944
|
const normalized = input.replace(/\\/g, "/");
|
|
82898
|
-
if (
|
|
82899
|
-
const rel =
|
|
82945
|
+
if (path87.isAbsolute(normalized)) {
|
|
82946
|
+
const rel = path87.relative(workspaceRoot, normalized).replace(/\\/g, "/");
|
|
82900
82947
|
return normalizeGraphPath2(rel);
|
|
82901
82948
|
}
|
|
82902
82949
|
return normalizeGraphPath2(normalized);
|
|
@@ -83041,7 +83088,7 @@ var repo_map = createSwarmTool({
|
|
|
83041
83088
|
init_zod();
|
|
83042
83089
|
init_create_tool();
|
|
83043
83090
|
import * as fs71 from "node:fs";
|
|
83044
|
-
import * as
|
|
83091
|
+
import * as path88 from "node:path";
|
|
83045
83092
|
var SPEC_FILE = ".swarm/spec.md";
|
|
83046
83093
|
var EVIDENCE_DIR4 = ".swarm/evidence";
|
|
83047
83094
|
var OBLIGATION_KEYWORDS = ["MUST", "SHOULD", "SHALL"];
|
|
@@ -83110,7 +83157,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
83110
83157
|
return [];
|
|
83111
83158
|
}
|
|
83112
83159
|
for (const entry of entries) {
|
|
83113
|
-
const entryPath =
|
|
83160
|
+
const entryPath = path88.join(evidenceDir, entry);
|
|
83114
83161
|
try {
|
|
83115
83162
|
const stat4 = fs71.statSync(entryPath);
|
|
83116
83163
|
if (!stat4.isDirectory()) {
|
|
@@ -83126,11 +83173,11 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
83126
83173
|
if (entryPhase !== String(phase)) {
|
|
83127
83174
|
continue;
|
|
83128
83175
|
}
|
|
83129
|
-
const evidenceFilePath =
|
|
83176
|
+
const evidenceFilePath = path88.join(entryPath, "evidence.json");
|
|
83130
83177
|
try {
|
|
83131
|
-
const resolvedPath =
|
|
83132
|
-
const evidenceDirResolved =
|
|
83133
|
-
if (!resolvedPath.startsWith(evidenceDirResolved +
|
|
83178
|
+
const resolvedPath = path88.resolve(evidenceFilePath);
|
|
83179
|
+
const evidenceDirResolved = path88.resolve(evidenceDir);
|
|
83180
|
+
if (!resolvedPath.startsWith(evidenceDirResolved + path88.sep)) {
|
|
83134
83181
|
continue;
|
|
83135
83182
|
}
|
|
83136
83183
|
const stat4 = fs71.lstatSync(evidenceFilePath);
|
|
@@ -83164,7 +83211,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
83164
83211
|
if (Array.isArray(diffEntry.files_changed)) {
|
|
83165
83212
|
for (const file3 of diffEntry.files_changed) {
|
|
83166
83213
|
if (typeof file3 === "string") {
|
|
83167
|
-
touchedFiles.add(
|
|
83214
|
+
touchedFiles.add(path88.resolve(cwd, file3));
|
|
83168
83215
|
}
|
|
83169
83216
|
}
|
|
83170
83217
|
}
|
|
@@ -83177,8 +83224,8 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
83177
83224
|
}
|
|
83178
83225
|
function searchFileForKeywords(filePath, keywords, cwd) {
|
|
83179
83226
|
try {
|
|
83180
|
-
const resolvedPath =
|
|
83181
|
-
const cwdResolved =
|
|
83227
|
+
const resolvedPath = path88.resolve(filePath);
|
|
83228
|
+
const cwdResolved = path88.resolve(cwd);
|
|
83182
83229
|
if (!resolvedPath.startsWith(cwdResolved)) {
|
|
83183
83230
|
return false;
|
|
83184
83231
|
}
|
|
@@ -83312,7 +83359,7 @@ var req_coverage = createSwarmTool({
|
|
|
83312
83359
|
}, null, 2);
|
|
83313
83360
|
}
|
|
83314
83361
|
const cwd = inputDirectory || directory;
|
|
83315
|
-
const specPath =
|
|
83362
|
+
const specPath = path88.join(cwd, SPEC_FILE);
|
|
83316
83363
|
let specContent;
|
|
83317
83364
|
try {
|
|
83318
83365
|
specContent = fs71.readFileSync(specPath, "utf-8");
|
|
@@ -83339,7 +83386,7 @@ var req_coverage = createSwarmTool({
|
|
|
83339
83386
|
message: "No FR requirements found in spec.md"
|
|
83340
83387
|
}, null, 2);
|
|
83341
83388
|
}
|
|
83342
|
-
const evidenceDir =
|
|
83389
|
+
const evidenceDir = path88.join(cwd, EVIDENCE_DIR4);
|
|
83343
83390
|
const touchedFiles = readTouchedFiles(evidenceDir, phase, cwd);
|
|
83344
83391
|
const analyzedRequirements = [];
|
|
83345
83392
|
let coveredCount = 0;
|
|
@@ -83365,7 +83412,7 @@ var req_coverage = createSwarmTool({
|
|
|
83365
83412
|
requirements: analyzedRequirements
|
|
83366
83413
|
};
|
|
83367
83414
|
const reportFilename = `req-coverage-phase-${phase}.json`;
|
|
83368
|
-
const reportPath =
|
|
83415
|
+
const reportPath = path88.join(evidenceDir, reportFilename);
|
|
83369
83416
|
try {
|
|
83370
83417
|
if (!fs71.existsSync(evidenceDir)) {
|
|
83371
83418
|
fs71.mkdirSync(evidenceDir, { recursive: true });
|
|
@@ -83453,7 +83500,7 @@ init_qa_gate_profile();
|
|
|
83453
83500
|
init_file_locks();
|
|
83454
83501
|
import * as crypto9 from "node:crypto";
|
|
83455
83502
|
import * as fs72 from "node:fs";
|
|
83456
|
-
import * as
|
|
83503
|
+
import * as path89 from "node:path";
|
|
83457
83504
|
init_ledger();
|
|
83458
83505
|
init_manager();
|
|
83459
83506
|
init_state();
|
|
@@ -83531,8 +83578,8 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
83531
83578
|
};
|
|
83532
83579
|
}
|
|
83533
83580
|
if (args2.working_directory && fallbackDir) {
|
|
83534
|
-
const resolvedTarget =
|
|
83535
|
-
const resolvedRoot =
|
|
83581
|
+
const resolvedTarget = path89.resolve(args2.working_directory);
|
|
83582
|
+
const resolvedRoot = path89.resolve(fallbackDir);
|
|
83536
83583
|
let fallbackExists = false;
|
|
83537
83584
|
try {
|
|
83538
83585
|
fs72.accessSync(resolvedRoot, fs72.constants.F_OK);
|
|
@@ -83541,7 +83588,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
83541
83588
|
fallbackExists = false;
|
|
83542
83589
|
}
|
|
83543
83590
|
if (fallbackExists) {
|
|
83544
|
-
const isSubdirectory = resolvedTarget.startsWith(resolvedRoot +
|
|
83591
|
+
const isSubdirectory = resolvedTarget.startsWith(resolvedRoot + path89.sep);
|
|
83545
83592
|
if (isSubdirectory) {
|
|
83546
83593
|
return {
|
|
83547
83594
|
success: false,
|
|
@@ -83557,7 +83604,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
83557
83604
|
let specMtime;
|
|
83558
83605
|
let specHash;
|
|
83559
83606
|
if (process.env.SWARM_SKIP_SPEC_GATE !== "1") {
|
|
83560
|
-
const specPath =
|
|
83607
|
+
const specPath = path89.join(targetWorkspace, ".swarm", "spec.md");
|
|
83561
83608
|
try {
|
|
83562
83609
|
const stat4 = await fs72.promises.stat(specPath);
|
|
83563
83610
|
specMtime = stat4.mtime.toISOString();
|
|
@@ -83573,7 +83620,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
83573
83620
|
}
|
|
83574
83621
|
}
|
|
83575
83622
|
if (process.env.SWARM_SKIP_GATE_SELECTION !== "1") {
|
|
83576
|
-
const contextPath =
|
|
83623
|
+
const contextPath = path89.join(targetWorkspace, ".swarm", "context.md");
|
|
83577
83624
|
let contextContent = "";
|
|
83578
83625
|
try {
|
|
83579
83626
|
contextContent = await fs72.promises.readFile(contextPath, "utf8");
|
|
@@ -83723,7 +83770,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
83723
83770
|
}
|
|
83724
83771
|
await writeCheckpoint(dir).catch(() => {});
|
|
83725
83772
|
try {
|
|
83726
|
-
const markerPath =
|
|
83773
|
+
const markerPath = path89.join(dir, ".swarm", ".plan-write-marker");
|
|
83727
83774
|
const marker = JSON.stringify({
|
|
83728
83775
|
source: "save_plan",
|
|
83729
83776
|
timestamp: new Date().toISOString(),
|
|
@@ -83746,7 +83793,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
83746
83793
|
return {
|
|
83747
83794
|
success: true,
|
|
83748
83795
|
message: "Plan saved successfully",
|
|
83749
|
-
plan_path:
|
|
83796
|
+
plan_path: path89.join(dir, ".swarm", "plan.json"),
|
|
83750
83797
|
phases_count: plan.phases.length,
|
|
83751
83798
|
tasks_count: tasksCount,
|
|
83752
83799
|
...resolvedProfile !== undefined ? { execution_profile: resolvedProfile } : {},
|
|
@@ -83799,7 +83846,7 @@ var save_plan = createSwarmTool({
|
|
|
83799
83846
|
init_zod();
|
|
83800
83847
|
init_manager2();
|
|
83801
83848
|
import * as fs73 from "node:fs";
|
|
83802
|
-
import * as
|
|
83849
|
+
import * as path90 from "node:path";
|
|
83803
83850
|
|
|
83804
83851
|
// src/sbom/detectors/index.ts
|
|
83805
83852
|
init_utils();
|
|
@@ -84649,7 +84696,7 @@ function findManifestFiles(rootDir) {
|
|
|
84649
84696
|
try {
|
|
84650
84697
|
const entries = fs73.readdirSync(dir, { withFileTypes: true });
|
|
84651
84698
|
for (const entry of entries) {
|
|
84652
|
-
const fullPath =
|
|
84699
|
+
const fullPath = path90.join(dir, entry.name);
|
|
84653
84700
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
|
|
84654
84701
|
continue;
|
|
84655
84702
|
}
|
|
@@ -84658,7 +84705,7 @@ function findManifestFiles(rootDir) {
|
|
|
84658
84705
|
} else if (entry.isFile()) {
|
|
84659
84706
|
for (const pattern of patterns) {
|
|
84660
84707
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
84661
|
-
manifestFiles.push(
|
|
84708
|
+
manifestFiles.push(path90.relative(rootDir, fullPath));
|
|
84662
84709
|
break;
|
|
84663
84710
|
}
|
|
84664
84711
|
}
|
|
@@ -84676,11 +84723,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
84676
84723
|
try {
|
|
84677
84724
|
const entries = fs73.readdirSync(dir, { withFileTypes: true });
|
|
84678
84725
|
for (const entry of entries) {
|
|
84679
|
-
const fullPath =
|
|
84726
|
+
const fullPath = path90.join(dir, entry.name);
|
|
84680
84727
|
if (entry.isFile()) {
|
|
84681
84728
|
for (const pattern of patterns) {
|
|
84682
84729
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
84683
|
-
found.push(
|
|
84730
|
+
found.push(path90.relative(workingDir, fullPath));
|
|
84684
84731
|
break;
|
|
84685
84732
|
}
|
|
84686
84733
|
}
|
|
@@ -84693,11 +84740,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
84693
84740
|
function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
|
|
84694
84741
|
const dirs = new Set;
|
|
84695
84742
|
for (const file3 of changedFiles) {
|
|
84696
|
-
let currentDir =
|
|
84743
|
+
let currentDir = path90.dirname(file3);
|
|
84697
84744
|
while (true) {
|
|
84698
|
-
if (currentDir && currentDir !== "." && currentDir !==
|
|
84699
|
-
dirs.add(
|
|
84700
|
-
const parent =
|
|
84745
|
+
if (currentDir && currentDir !== "." && currentDir !== path90.sep) {
|
|
84746
|
+
dirs.add(path90.join(workingDir, currentDir));
|
|
84747
|
+
const parent = path90.dirname(currentDir);
|
|
84701
84748
|
if (parent === currentDir)
|
|
84702
84749
|
break;
|
|
84703
84750
|
currentDir = parent;
|
|
@@ -84781,7 +84828,7 @@ var sbom_generate = createSwarmTool({
|
|
|
84781
84828
|
const changedFiles = obj.changed_files;
|
|
84782
84829
|
const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
|
|
84783
84830
|
const workingDir = directory;
|
|
84784
|
-
const outputDir =
|
|
84831
|
+
const outputDir = path90.isAbsolute(relativeOutputDir) ? relativeOutputDir : path90.join(workingDir, relativeOutputDir);
|
|
84785
84832
|
let manifestFiles = [];
|
|
84786
84833
|
if (scope === "all") {
|
|
84787
84834
|
manifestFiles = findManifestFiles(workingDir);
|
|
@@ -84804,7 +84851,7 @@ var sbom_generate = createSwarmTool({
|
|
|
84804
84851
|
const processedFiles = [];
|
|
84805
84852
|
for (const manifestFile of manifestFiles) {
|
|
84806
84853
|
try {
|
|
84807
|
-
const fullPath =
|
|
84854
|
+
const fullPath = path90.isAbsolute(manifestFile) ? manifestFile : path90.join(workingDir, manifestFile);
|
|
84808
84855
|
if (!fs73.existsSync(fullPath)) {
|
|
84809
84856
|
continue;
|
|
84810
84857
|
}
|
|
@@ -84821,7 +84868,7 @@ var sbom_generate = createSwarmTool({
|
|
|
84821
84868
|
const bom = generateCycloneDX(allComponents);
|
|
84822
84869
|
const bomJson = serializeCycloneDX(bom);
|
|
84823
84870
|
const filename = generateSbomFilename();
|
|
84824
|
-
const outputPath =
|
|
84871
|
+
const outputPath = path90.join(outputDir, filename);
|
|
84825
84872
|
fs73.writeFileSync(outputPath, bomJson, "utf-8");
|
|
84826
84873
|
const verdict = processedFiles.length > 0 ? "pass" : "pass";
|
|
84827
84874
|
try {
|
|
@@ -84865,7 +84912,7 @@ var sbom_generate = createSwarmTool({
|
|
|
84865
84912
|
init_zod();
|
|
84866
84913
|
init_create_tool();
|
|
84867
84914
|
import * as fs74 from "node:fs";
|
|
84868
|
-
import * as
|
|
84915
|
+
import * as path91 from "node:path";
|
|
84869
84916
|
var SPEC_CANDIDATES = [
|
|
84870
84917
|
"openapi.json",
|
|
84871
84918
|
"openapi.yaml",
|
|
@@ -84897,12 +84944,12 @@ function normalizePath3(p) {
|
|
|
84897
84944
|
}
|
|
84898
84945
|
function discoverSpecFile(cwd, specFileArg) {
|
|
84899
84946
|
if (specFileArg) {
|
|
84900
|
-
const resolvedPath =
|
|
84901
|
-
const normalizedCwd = cwd.endsWith(
|
|
84947
|
+
const resolvedPath = path91.resolve(cwd, specFileArg);
|
|
84948
|
+
const normalizedCwd = cwd.endsWith(path91.sep) ? cwd : cwd + path91.sep;
|
|
84902
84949
|
if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
|
|
84903
84950
|
throw new Error("Invalid spec_file: path traversal detected");
|
|
84904
84951
|
}
|
|
84905
|
-
const ext =
|
|
84952
|
+
const ext = path91.extname(resolvedPath).toLowerCase();
|
|
84906
84953
|
if (!ALLOWED_EXTENSIONS.includes(ext)) {
|
|
84907
84954
|
throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
|
|
84908
84955
|
}
|
|
@@ -84916,7 +84963,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
84916
84963
|
return resolvedPath;
|
|
84917
84964
|
}
|
|
84918
84965
|
for (const candidate of SPEC_CANDIDATES) {
|
|
84919
|
-
const candidatePath =
|
|
84966
|
+
const candidatePath = path91.resolve(cwd, candidate);
|
|
84920
84967
|
if (fs74.existsSync(candidatePath)) {
|
|
84921
84968
|
const stats = fs74.statSync(candidatePath);
|
|
84922
84969
|
if (stats.size <= MAX_SPEC_SIZE) {
|
|
@@ -84928,7 +84975,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
84928
84975
|
}
|
|
84929
84976
|
function parseSpec(specFile) {
|
|
84930
84977
|
const content = fs74.readFileSync(specFile, "utf-8");
|
|
84931
|
-
const ext =
|
|
84978
|
+
const ext = path91.extname(specFile).toLowerCase();
|
|
84932
84979
|
if (ext === ".json") {
|
|
84933
84980
|
return parseJsonSpec(content);
|
|
84934
84981
|
}
|
|
@@ -85004,7 +85051,7 @@ function extractRoutes(cwd) {
|
|
|
85004
85051
|
return;
|
|
85005
85052
|
}
|
|
85006
85053
|
for (const entry of entries) {
|
|
85007
|
-
const fullPath =
|
|
85054
|
+
const fullPath = path91.join(dir, entry.name);
|
|
85008
85055
|
if (entry.isSymbolicLink()) {
|
|
85009
85056
|
continue;
|
|
85010
85057
|
}
|
|
@@ -85014,7 +85061,7 @@ function extractRoutes(cwd) {
|
|
|
85014
85061
|
}
|
|
85015
85062
|
walkDir(fullPath);
|
|
85016
85063
|
} else if (entry.isFile()) {
|
|
85017
|
-
const ext =
|
|
85064
|
+
const ext = path91.extname(entry.name).toLowerCase();
|
|
85018
85065
|
const baseName = entry.name.toLowerCase();
|
|
85019
85066
|
if (![".ts", ".js", ".mjs"].includes(ext)) {
|
|
85020
85067
|
continue;
|
|
@@ -85181,7 +85228,7 @@ init_zod();
|
|
|
85181
85228
|
init_path_security();
|
|
85182
85229
|
init_create_tool();
|
|
85183
85230
|
import * as fs75 from "node:fs";
|
|
85184
|
-
import * as
|
|
85231
|
+
import * as path92 from "node:path";
|
|
85185
85232
|
var DEFAULT_MAX_RESULTS = 100;
|
|
85186
85233
|
var DEFAULT_MAX_LINES = 200;
|
|
85187
85234
|
var REGEX_TIMEOUT_MS = 5000;
|
|
@@ -85217,11 +85264,11 @@ function containsWindowsAttacks3(str) {
|
|
|
85217
85264
|
}
|
|
85218
85265
|
function isPathInWorkspace3(filePath, workspace) {
|
|
85219
85266
|
try {
|
|
85220
|
-
const resolvedPath =
|
|
85267
|
+
const resolvedPath = path92.resolve(workspace, filePath);
|
|
85221
85268
|
const realWorkspace = fs75.realpathSync(workspace);
|
|
85222
85269
|
const realResolvedPath = fs75.realpathSync(resolvedPath);
|
|
85223
|
-
const relativePath =
|
|
85224
|
-
if (relativePath.startsWith("..") ||
|
|
85270
|
+
const relativePath = path92.relative(realWorkspace, realResolvedPath);
|
|
85271
|
+
if (relativePath.startsWith("..") || path92.isAbsolute(relativePath)) {
|
|
85225
85272
|
return false;
|
|
85226
85273
|
}
|
|
85227
85274
|
return true;
|
|
@@ -85234,11 +85281,11 @@ function validatePathForRead2(filePath, workspace) {
|
|
|
85234
85281
|
}
|
|
85235
85282
|
function findRgInEnvPath() {
|
|
85236
85283
|
const searchPath = process.env.PATH ?? "";
|
|
85237
|
-
for (const dir of searchPath.split(
|
|
85284
|
+
for (const dir of searchPath.split(path92.delimiter)) {
|
|
85238
85285
|
if (!dir)
|
|
85239
85286
|
continue;
|
|
85240
85287
|
const isWindows = process.platform === "win32";
|
|
85241
|
-
const candidate =
|
|
85288
|
+
const candidate = path92.join(dir, isWindows ? "rg.exe" : "rg");
|
|
85242
85289
|
if (fs75.existsSync(candidate))
|
|
85243
85290
|
return candidate;
|
|
85244
85291
|
}
|
|
@@ -85368,8 +85415,8 @@ function collectFiles(dir, workspace, includeGlobs, excludeGlobs) {
|
|
|
85368
85415
|
try {
|
|
85369
85416
|
const entries = fs75.readdirSync(dir, { withFileTypes: true });
|
|
85370
85417
|
for (const entry of entries) {
|
|
85371
|
-
const fullPath =
|
|
85372
|
-
const relativePath =
|
|
85418
|
+
const fullPath = path92.join(dir, entry.name);
|
|
85419
|
+
const relativePath = path92.relative(workspace, fullPath);
|
|
85373
85420
|
if (!validatePathForRead2(fullPath, workspace)) {
|
|
85374
85421
|
continue;
|
|
85375
85422
|
}
|
|
@@ -85410,7 +85457,7 @@ async function fallbackSearch(opts) {
|
|
|
85410
85457
|
const matches = [];
|
|
85411
85458
|
let total = 0;
|
|
85412
85459
|
for (const file3 of files) {
|
|
85413
|
-
const fullPath =
|
|
85460
|
+
const fullPath = path92.join(opts.workspace, file3);
|
|
85414
85461
|
if (!validatePathForRead2(fullPath, opts.workspace)) {
|
|
85415
85462
|
continue;
|
|
85416
85463
|
}
|
|
@@ -85665,7 +85712,7 @@ init_zod();
|
|
|
85665
85712
|
init_path_security();
|
|
85666
85713
|
init_create_tool();
|
|
85667
85714
|
import * as fs76 from "node:fs";
|
|
85668
|
-
import * as
|
|
85715
|
+
import * as path93 from "node:path";
|
|
85669
85716
|
var WINDOWS_RESERVED_NAMES4 = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
85670
85717
|
function containsWindowsAttacks4(str) {
|
|
85671
85718
|
if (/:[^\\/]/.test(str))
|
|
@@ -85679,14 +85726,14 @@ function containsWindowsAttacks4(str) {
|
|
|
85679
85726
|
}
|
|
85680
85727
|
function isPathInWorkspace4(filePath, workspace) {
|
|
85681
85728
|
try {
|
|
85682
|
-
const resolvedPath =
|
|
85729
|
+
const resolvedPath = path93.resolve(workspace, filePath);
|
|
85683
85730
|
if (!fs76.existsSync(resolvedPath)) {
|
|
85684
85731
|
return true;
|
|
85685
85732
|
}
|
|
85686
85733
|
const realWorkspace = fs76.realpathSync(workspace);
|
|
85687
85734
|
const realResolvedPath = fs76.realpathSync(resolvedPath);
|
|
85688
|
-
const relativePath =
|
|
85689
|
-
if (relativePath.startsWith("..") ||
|
|
85735
|
+
const relativePath = path93.relative(realWorkspace, realResolvedPath);
|
|
85736
|
+
if (relativePath.startsWith("..") || path93.isAbsolute(relativePath)) {
|
|
85690
85737
|
return false;
|
|
85691
85738
|
}
|
|
85692
85739
|
return true;
|
|
@@ -85894,7 +85941,7 @@ var suggestPatch = createSwarmTool({
|
|
|
85894
85941
|
});
|
|
85895
85942
|
continue;
|
|
85896
85943
|
}
|
|
85897
|
-
const fullPath =
|
|
85944
|
+
const fullPath = path93.resolve(directory, change.file);
|
|
85898
85945
|
if (!fs76.existsSync(fullPath)) {
|
|
85899
85946
|
errors5.push({
|
|
85900
85947
|
success: false,
|
|
@@ -86157,7 +86204,7 @@ var generate_mutants = createSwarmTool({
|
|
|
86157
86204
|
init_spec_schema();
|
|
86158
86205
|
init_create_tool();
|
|
86159
86206
|
import * as fs77 from "node:fs";
|
|
86160
|
-
import * as
|
|
86207
|
+
import * as path94 from "node:path";
|
|
86161
86208
|
var SPEC_FILE_NAME = "spec.md";
|
|
86162
86209
|
var SWARM_DIR2 = ".swarm";
|
|
86163
86210
|
var OBLIGATION_KEYWORDS2 = ["MUST", "SHALL", "SHOULD", "MAY"];
|
|
@@ -86210,7 +86257,7 @@ var lint_spec = createSwarmTool({
|
|
|
86210
86257
|
async execute(_args, directory) {
|
|
86211
86258
|
const errors5 = [];
|
|
86212
86259
|
const warnings = [];
|
|
86213
|
-
const specPath =
|
|
86260
|
+
const specPath = path94.join(directory, SWARM_DIR2, SPEC_FILE_NAME);
|
|
86214
86261
|
if (!fs77.existsSync(specPath)) {
|
|
86215
86262
|
const result2 = {
|
|
86216
86263
|
valid: false,
|
|
@@ -86281,12 +86328,12 @@ var lint_spec = createSwarmTool({
|
|
|
86281
86328
|
// src/tools/mutation-test.ts
|
|
86282
86329
|
init_zod();
|
|
86283
86330
|
import * as fs78 from "node:fs";
|
|
86284
|
-
import * as
|
|
86331
|
+
import * as path96 from "node:path";
|
|
86285
86332
|
|
|
86286
86333
|
// src/mutation/engine.ts
|
|
86287
86334
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
86288
86335
|
import { unlinkSync as unlinkSync13, writeFileSync as writeFileSync19 } from "node:fs";
|
|
86289
|
-
import * as
|
|
86336
|
+
import * as path95 from "node:path";
|
|
86290
86337
|
|
|
86291
86338
|
// src/mutation/equivalence.ts
|
|
86292
86339
|
function isStaticallyEquivalent(originalCode, mutatedCode) {
|
|
@@ -86421,7 +86468,7 @@ async function executeMutation(patch, testCommand, _testFiles, workingDir) {
|
|
|
86421
86468
|
let patchFile;
|
|
86422
86469
|
try {
|
|
86423
86470
|
const safeId2 = patch.id.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
86424
|
-
patchFile =
|
|
86471
|
+
patchFile = path95.join(workingDir, `.mutation_patch_${safeId2}.diff`);
|
|
86425
86472
|
try {
|
|
86426
86473
|
writeFileSync19(patchFile, patch.patch);
|
|
86427
86474
|
} catch (writeErr) {
|
|
@@ -86815,7 +86862,7 @@ var mutation_test = createSwarmTool({
|
|
|
86815
86862
|
];
|
|
86816
86863
|
for (const filePath of uniquePaths) {
|
|
86817
86864
|
try {
|
|
86818
|
-
const resolvedPath =
|
|
86865
|
+
const resolvedPath = path96.resolve(cwd, filePath);
|
|
86819
86866
|
sourceFiles.set(filePath, fs78.readFileSync(resolvedPath, "utf-8"));
|
|
86820
86867
|
} catch {}
|
|
86821
86868
|
}
|
|
@@ -86835,7 +86882,7 @@ init_zod();
|
|
|
86835
86882
|
init_manager2();
|
|
86836
86883
|
init_detector();
|
|
86837
86884
|
import * as fs79 from "node:fs";
|
|
86838
|
-
import * as
|
|
86885
|
+
import * as path97 from "node:path";
|
|
86839
86886
|
init_create_tool();
|
|
86840
86887
|
var MAX_FILE_SIZE2 = 2 * 1024 * 1024;
|
|
86841
86888
|
var BINARY_CHECK_BYTES = 8192;
|
|
@@ -86901,7 +86948,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
86901
86948
|
if (languages?.length) {
|
|
86902
86949
|
const lowerLangs = languages.map((l) => l.toLowerCase());
|
|
86903
86950
|
filesToCheck = filesToCheck.filter((file3) => {
|
|
86904
|
-
const ext =
|
|
86951
|
+
const ext = path97.extname(file3.path).toLowerCase();
|
|
86905
86952
|
const langDef = getLanguageForExtension(ext);
|
|
86906
86953
|
const fileProfile = getProfileForFile(file3.path);
|
|
86907
86954
|
const langId = fileProfile?.id || langDef?.id;
|
|
@@ -86914,7 +86961,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
86914
86961
|
let skippedCount = 0;
|
|
86915
86962
|
for (const fileInfo of filesToCheck) {
|
|
86916
86963
|
const { path: filePath } = fileInfo;
|
|
86917
|
-
const fullPath =
|
|
86964
|
+
const fullPath = path97.isAbsolute(filePath) ? filePath : path97.join(directory, filePath);
|
|
86918
86965
|
const result = {
|
|
86919
86966
|
path: filePath,
|
|
86920
86967
|
language: "",
|
|
@@ -86963,7 +87010,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
86963
87010
|
results.push(result);
|
|
86964
87011
|
continue;
|
|
86965
87012
|
}
|
|
86966
|
-
const ext =
|
|
87013
|
+
const ext = path97.extname(filePath).toLowerCase();
|
|
86967
87014
|
const langDef = getLanguageForExtension(ext);
|
|
86968
87015
|
result.language = profile?.id || langDef?.id || "unknown";
|
|
86969
87016
|
const errors5 = extractSyntaxErrors(parser, content);
|
|
@@ -87056,7 +87103,7 @@ init_utils();
|
|
|
87056
87103
|
init_create_tool();
|
|
87057
87104
|
init_path_security();
|
|
87058
87105
|
import * as fs80 from "node:fs";
|
|
87059
|
-
import * as
|
|
87106
|
+
import * as path98 from "node:path";
|
|
87060
87107
|
var MAX_TEXT_LENGTH = 200;
|
|
87061
87108
|
var MAX_FILE_SIZE_BYTES11 = 1024 * 1024;
|
|
87062
87109
|
var SUPPORTED_EXTENSIONS4 = new Set([
|
|
@@ -87122,9 +87169,9 @@ function validatePathsInput(paths, cwd) {
|
|
|
87122
87169
|
return { error: "paths contains path traversal", resolvedPath: null };
|
|
87123
87170
|
}
|
|
87124
87171
|
try {
|
|
87125
|
-
const resolvedPath =
|
|
87126
|
-
const normalizedCwd =
|
|
87127
|
-
const normalizedResolved =
|
|
87172
|
+
const resolvedPath = path98.resolve(paths);
|
|
87173
|
+
const normalizedCwd = path98.resolve(cwd);
|
|
87174
|
+
const normalizedResolved = path98.resolve(resolvedPath);
|
|
87128
87175
|
if (!normalizedResolved.startsWith(normalizedCwd)) {
|
|
87129
87176
|
return {
|
|
87130
87177
|
error: "paths must be within the current working directory",
|
|
@@ -87140,7 +87187,7 @@ function validatePathsInput(paths, cwd) {
|
|
|
87140
87187
|
}
|
|
87141
87188
|
}
|
|
87142
87189
|
function isSupportedExtension(filePath) {
|
|
87143
|
-
const ext =
|
|
87190
|
+
const ext = path98.extname(filePath).toLowerCase();
|
|
87144
87191
|
return SUPPORTED_EXTENSIONS4.has(ext);
|
|
87145
87192
|
}
|
|
87146
87193
|
function findSourceFiles4(dir, files = []) {
|
|
@@ -87155,7 +87202,7 @@ function findSourceFiles4(dir, files = []) {
|
|
|
87155
87202
|
if (SKIP_DIRECTORIES5.has(entry)) {
|
|
87156
87203
|
continue;
|
|
87157
87204
|
}
|
|
87158
|
-
const fullPath =
|
|
87205
|
+
const fullPath = path98.join(dir, entry);
|
|
87159
87206
|
let stat4;
|
|
87160
87207
|
try {
|
|
87161
87208
|
stat4 = fs80.statSync(fullPath);
|
|
@@ -87267,7 +87314,7 @@ var todo_extract = createSwarmTool({
|
|
|
87267
87314
|
filesToScan.push(scanPath);
|
|
87268
87315
|
} else {
|
|
87269
87316
|
const errorResult = {
|
|
87270
|
-
error: `unsupported file extension: ${
|
|
87317
|
+
error: `unsupported file extension: ${path98.extname(scanPath)}`,
|
|
87271
87318
|
total: 0,
|
|
87272
87319
|
byPriority: { high: 0, medium: 0, low: 0 },
|
|
87273
87320
|
entries: []
|
|
@@ -87316,14 +87363,14 @@ init_schema();
|
|
|
87316
87363
|
init_qa_gate_profile();
|
|
87317
87364
|
init_gate_evidence();
|
|
87318
87365
|
import * as fs82 from "node:fs";
|
|
87319
|
-
import * as
|
|
87366
|
+
import * as path100 from "node:path";
|
|
87320
87367
|
|
|
87321
87368
|
// src/hooks/diff-scope.ts
|
|
87322
87369
|
import * as fs81 from "node:fs";
|
|
87323
|
-
import * as
|
|
87370
|
+
import * as path99 from "node:path";
|
|
87324
87371
|
function getDeclaredScope(taskId, directory) {
|
|
87325
87372
|
try {
|
|
87326
|
-
const planPath =
|
|
87373
|
+
const planPath = path99.join(directory, ".swarm", "plan.json");
|
|
87327
87374
|
if (!fs81.existsSync(planPath))
|
|
87328
87375
|
return null;
|
|
87329
87376
|
const raw = fs81.readFileSync(planPath, "utf-8");
|
|
@@ -87442,7 +87489,7 @@ var TIER_3_PATTERNS = [
|
|
|
87442
87489
|
];
|
|
87443
87490
|
function matchesTier3Pattern(files) {
|
|
87444
87491
|
for (const file3 of files) {
|
|
87445
|
-
const fileName =
|
|
87492
|
+
const fileName = path100.basename(file3);
|
|
87446
87493
|
for (const pattern of TIER_3_PATTERNS) {
|
|
87447
87494
|
if (pattern.test(fileName)) {
|
|
87448
87495
|
return true;
|
|
@@ -87456,7 +87503,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
87456
87503
|
if (hasActiveTurboMode()) {
|
|
87457
87504
|
const resolvedDir2 = workingDirectory;
|
|
87458
87505
|
try {
|
|
87459
|
-
const planPath =
|
|
87506
|
+
const planPath = path100.join(resolvedDir2, ".swarm", "plan.json");
|
|
87460
87507
|
const planRaw = fs82.readFileSync(planPath, "utf-8");
|
|
87461
87508
|
const plan = JSON.parse(planRaw);
|
|
87462
87509
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -87526,7 +87573,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
87526
87573
|
}
|
|
87527
87574
|
try {
|
|
87528
87575
|
const resolvedDir2 = workingDirectory;
|
|
87529
|
-
const planPath =
|
|
87576
|
+
const planPath = path100.join(resolvedDir2, ".swarm", "plan.json");
|
|
87530
87577
|
const planRaw = fs82.readFileSync(planPath, "utf-8");
|
|
87531
87578
|
const plan = JSON.parse(planRaw);
|
|
87532
87579
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -87684,7 +87731,7 @@ function checkCouncilGate(workingDirectory, taskId) {
|
|
|
87684
87731
|
return { blocked: false, reason: "" };
|
|
87685
87732
|
}
|
|
87686
87733
|
try {
|
|
87687
|
-
const planPath =
|
|
87734
|
+
const planPath = path100.join(workingDirectory, ".swarm", "plan.json");
|
|
87688
87735
|
const planRaw = fs82.readFileSync(planPath, "utf-8");
|
|
87689
87736
|
const planObj = JSON.parse(planRaw);
|
|
87690
87737
|
if (planObj.swarm && planObj.title) {
|
|
@@ -87775,8 +87822,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
87775
87822
|
};
|
|
87776
87823
|
}
|
|
87777
87824
|
}
|
|
87778
|
-
normalizedDir =
|
|
87779
|
-
const pathParts = normalizedDir.split(
|
|
87825
|
+
normalizedDir = path100.normalize(args2.working_directory);
|
|
87826
|
+
const pathParts = normalizedDir.split(path100.sep);
|
|
87780
87827
|
if (pathParts.includes("..")) {
|
|
87781
87828
|
return {
|
|
87782
87829
|
success: false,
|
|
@@ -87786,10 +87833,10 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
87786
87833
|
]
|
|
87787
87834
|
};
|
|
87788
87835
|
}
|
|
87789
|
-
const resolvedDir =
|
|
87836
|
+
const resolvedDir = path100.resolve(normalizedDir);
|
|
87790
87837
|
try {
|
|
87791
87838
|
const realPath = fs82.realpathSync(resolvedDir);
|
|
87792
|
-
const planPath =
|
|
87839
|
+
const planPath = path100.join(realPath, ".swarm", "plan.json");
|
|
87793
87840
|
if (!fs82.existsSync(planPath)) {
|
|
87794
87841
|
return {
|
|
87795
87842
|
success: false,
|
|
@@ -87821,8 +87868,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
87821
87868
|
}
|
|
87822
87869
|
if (args2.status === "in_progress") {
|
|
87823
87870
|
try {
|
|
87824
|
-
const evidencePath =
|
|
87825
|
-
fs82.mkdirSync(
|
|
87871
|
+
const evidencePath = path100.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
|
|
87872
|
+
fs82.mkdirSync(path100.dirname(evidencePath), { recursive: true });
|
|
87826
87873
|
const fd = fs82.openSync(evidencePath, "wx");
|
|
87827
87874
|
let writeOk = false;
|
|
87828
87875
|
try {
|
|
@@ -87846,7 +87893,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
87846
87893
|
recoverTaskStateFromDelegations(args2.task_id);
|
|
87847
87894
|
let phaseRequiresReviewer = true;
|
|
87848
87895
|
try {
|
|
87849
|
-
const planPath =
|
|
87896
|
+
const planPath = path100.join(directory, ".swarm", "plan.json");
|
|
87850
87897
|
const planRaw = fs82.readFileSync(planPath, "utf-8");
|
|
87851
87898
|
const plan = JSON.parse(planRaw);
|
|
87852
87899
|
const taskPhase = plan.phases.find((p) => p.tasks.some((t) => t.id === args2.task_id));
|
|
@@ -88166,7 +88213,7 @@ init_ledger();
|
|
|
88166
88213
|
init_manager();
|
|
88167
88214
|
init_create_tool();
|
|
88168
88215
|
import fs83 from "node:fs";
|
|
88169
|
-
import
|
|
88216
|
+
import path101 from "node:path";
|
|
88170
88217
|
function derivePlanId5(plan) {
|
|
88171
88218
|
return `${plan.swarm}-${plan.title}`.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
88172
88219
|
}
|
|
@@ -88217,7 +88264,7 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
88217
88264
|
entries: [evidenceEntry]
|
|
88218
88265
|
};
|
|
88219
88266
|
const filename = "drift-verifier.json";
|
|
88220
|
-
const relativePath =
|
|
88267
|
+
const relativePath = path101.join("evidence", String(phase), filename);
|
|
88221
88268
|
let validatedPath;
|
|
88222
88269
|
try {
|
|
88223
88270
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -88228,10 +88275,10 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
88228
88275
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
88229
88276
|
}, null, 2);
|
|
88230
88277
|
}
|
|
88231
|
-
const evidenceDir =
|
|
88278
|
+
const evidenceDir = path101.dirname(validatedPath);
|
|
88232
88279
|
try {
|
|
88233
88280
|
await fs83.promises.mkdir(evidenceDir, { recursive: true });
|
|
88234
|
-
const tempPath =
|
|
88281
|
+
const tempPath = path101.join(evidenceDir, `.${filename}.tmp`);
|
|
88235
88282
|
await fs83.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
88236
88283
|
await fs83.promises.rename(tempPath, validatedPath);
|
|
88237
88284
|
let snapshotInfo;
|
|
@@ -88328,7 +88375,7 @@ init_zod();
|
|
|
88328
88375
|
init_utils2();
|
|
88329
88376
|
init_create_tool();
|
|
88330
88377
|
import fs84 from "node:fs";
|
|
88331
|
-
import
|
|
88378
|
+
import path102 from "node:path";
|
|
88332
88379
|
function normalizeVerdict2(verdict) {
|
|
88333
88380
|
switch (verdict) {
|
|
88334
88381
|
case "APPROVED":
|
|
@@ -88376,7 +88423,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
88376
88423
|
entries: [evidenceEntry]
|
|
88377
88424
|
};
|
|
88378
88425
|
const filename = "hallucination-guard.json";
|
|
88379
|
-
const relativePath =
|
|
88426
|
+
const relativePath = path102.join("evidence", String(phase), filename);
|
|
88380
88427
|
let validatedPath;
|
|
88381
88428
|
try {
|
|
88382
88429
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -88387,10 +88434,10 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
88387
88434
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
88388
88435
|
}, null, 2);
|
|
88389
88436
|
}
|
|
88390
|
-
const evidenceDir =
|
|
88437
|
+
const evidenceDir = path102.dirname(validatedPath);
|
|
88391
88438
|
try {
|
|
88392
88439
|
await fs84.promises.mkdir(evidenceDir, { recursive: true });
|
|
88393
|
-
const tempPath =
|
|
88440
|
+
const tempPath = path102.join(evidenceDir, `.${filename}.tmp`);
|
|
88394
88441
|
await fs84.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
88395
88442
|
await fs84.promises.rename(tempPath, validatedPath);
|
|
88396
88443
|
return JSON.stringify({
|
|
@@ -88439,7 +88486,7 @@ init_zod();
|
|
|
88439
88486
|
init_utils2();
|
|
88440
88487
|
init_create_tool();
|
|
88441
88488
|
import fs85 from "node:fs";
|
|
88442
|
-
import
|
|
88489
|
+
import path103 from "node:path";
|
|
88443
88490
|
function normalizeVerdict3(verdict) {
|
|
88444
88491
|
switch (verdict) {
|
|
88445
88492
|
case "PASS":
|
|
@@ -88513,7 +88560,7 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
88513
88560
|
entries: [evidenceEntry]
|
|
88514
88561
|
};
|
|
88515
88562
|
const filename = "mutation-gate.json";
|
|
88516
|
-
const relativePath =
|
|
88563
|
+
const relativePath = path103.join("evidence", String(phase), filename);
|
|
88517
88564
|
let validatedPath;
|
|
88518
88565
|
try {
|
|
88519
88566
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -88524,10 +88571,10 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
88524
88571
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
88525
88572
|
}, null, 2);
|
|
88526
88573
|
}
|
|
88527
|
-
const evidenceDir =
|
|
88574
|
+
const evidenceDir = path103.dirname(validatedPath);
|
|
88528
88575
|
try {
|
|
88529
88576
|
await fs85.promises.mkdir(evidenceDir, { recursive: true });
|
|
88530
|
-
const tempPath =
|
|
88577
|
+
const tempPath = path103.join(evidenceDir, `.${filename}.tmp`);
|
|
88531
88578
|
await fs85.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
88532
88579
|
await fs85.promises.rename(tempPath, validatedPath);
|
|
88533
88580
|
return JSON.stringify({
|
|
@@ -88584,19 +88631,19 @@ init_utils();
|
|
|
88584
88631
|
|
|
88585
88632
|
// src/utils/gitignore-warning.ts
|
|
88586
88633
|
import * as fs86 from "node:fs";
|
|
88587
|
-
import * as
|
|
88634
|
+
import * as path104 from "node:path";
|
|
88588
88635
|
var _gitignoreWarningEmitted = false;
|
|
88589
88636
|
function findGitRoot(startDir) {
|
|
88590
88637
|
let current = startDir;
|
|
88591
88638
|
while (true) {
|
|
88592
88639
|
try {
|
|
88593
|
-
const gitPath =
|
|
88640
|
+
const gitPath = path104.join(current, ".git");
|
|
88594
88641
|
const stat4 = fs86.statSync(gitPath);
|
|
88595
88642
|
if (stat4.isDirectory()) {
|
|
88596
88643
|
return current;
|
|
88597
88644
|
}
|
|
88598
88645
|
} catch {}
|
|
88599
|
-
const parent =
|
|
88646
|
+
const parent = path104.dirname(current);
|
|
88600
88647
|
if (parent === current) {
|
|
88601
88648
|
return null;
|
|
88602
88649
|
}
|
|
@@ -88628,12 +88675,12 @@ function warnIfSwarmNotGitignored(directory) {
|
|
|
88628
88675
|
const gitRoot = findGitRoot(directory);
|
|
88629
88676
|
if (!gitRoot)
|
|
88630
88677
|
return;
|
|
88631
|
-
const gitignoreContent = readFileSafe(
|
|
88678
|
+
const gitignoreContent = readFileSafe(path104.join(gitRoot, ".gitignore"));
|
|
88632
88679
|
if (gitignoreContent !== null && fileCoversSwarm(gitignoreContent)) {
|
|
88633
88680
|
_gitignoreWarningEmitted = true;
|
|
88634
88681
|
return;
|
|
88635
88682
|
}
|
|
88636
|
-
const excludeContent = readFileSafe(
|
|
88683
|
+
const excludeContent = readFileSafe(path104.join(gitRoot, ".git", "info", "exclude"));
|
|
88637
88684
|
if (excludeContent !== null && fileCoversSwarm(excludeContent)) {
|
|
88638
88685
|
_gitignoreWarningEmitted = true;
|
|
88639
88686
|
return;
|
|
@@ -88679,8 +88726,8 @@ init_warning_buffer();
|
|
|
88679
88726
|
var _heartbeatTimers = new Map;
|
|
88680
88727
|
function writeSwarmConfigExampleIfNew(projectDirectory) {
|
|
88681
88728
|
try {
|
|
88682
|
-
const swarmDir =
|
|
88683
|
-
const dest =
|
|
88729
|
+
const swarmDir = path105.join(projectDirectory, ".swarm");
|
|
88730
|
+
const dest = path105.join(swarmDir, "config.example.json");
|
|
88684
88731
|
if (fs87.existsSync(dest))
|
|
88685
88732
|
return;
|
|
88686
88733
|
const example = {
|
|
@@ -88856,7 +88903,7 @@ async function initializeOpenCodeSwarm(ctx) {
|
|
|
88856
88903
|
const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
|
|
88857
88904
|
preflightTriggerManager = new PTM(automationConfig);
|
|
88858
88905
|
const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
|
|
88859
|
-
const swarmDir =
|
|
88906
|
+
const swarmDir = path105.resolve(ctx.directory, ".swarm");
|
|
88860
88907
|
statusArtifact = new ASA(swarmDir);
|
|
88861
88908
|
statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
|
|
88862
88909
|
if (automationConfig.capabilities?.evidence_auto_summaries === true) {
|
|
@@ -89449,9 +89496,10 @@ async function initializeOpenCodeSwarm(ctx) {
|
|
|
89449
89496
|
automation: automationManager
|
|
89450
89497
|
};
|
|
89451
89498
|
}
|
|
89452
|
-
var src_default =
|
|
89499
|
+
var src_default = {
|
|
89500
|
+
id: "opencode-swarm",
|
|
89501
|
+
server: OpenCodeSwarm
|
|
89502
|
+
};
|
|
89453
89503
|
export {
|
|
89454
|
-
|
|
89455
|
-
src_default as default,
|
|
89456
|
-
addDeferredWarning
|
|
89504
|
+
src_default as default
|
|
89457
89505
|
};
|