opencode-swarm 6.40.5 → 6.40.6
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 +4 -2
- package/dist/index.js +144 -133
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -32825,6 +32825,7 @@ async function handleDarkMatterCommand(directory, args) {
|
|
|
32825
32825
|
import { execSync } from "child_process";
|
|
32826
32826
|
import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync3, statSync as statSync3 } from "fs";
|
|
32827
32827
|
import path12 from "path";
|
|
32828
|
+
import { fileURLToPath } from "url";
|
|
32828
32829
|
init_manager();
|
|
32829
32830
|
init_utils2();
|
|
32830
32831
|
init_manager2();
|
|
@@ -33165,8 +33166,9 @@ async function checkGrammarWasmFiles() {
|
|
|
33165
33166
|
"tree-sitter-swift.wasm",
|
|
33166
33167
|
"tree-sitter-dart.wasm"
|
|
33167
33168
|
];
|
|
33168
|
-
const
|
|
33169
|
-
const
|
|
33169
|
+
const thisDir = path12.dirname(fileURLToPath(import.meta.url));
|
|
33170
|
+
const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/services");
|
|
33171
|
+
const grammarDir = isSource ? path12.join(thisDir, "..", "lang", "grammars") : path12.join(thisDir, "lang", "grammars");
|
|
33170
33172
|
const missing = [];
|
|
33171
33173
|
for (const file3 of grammarFiles) {
|
|
33172
33174
|
if (!existsSync4(path12.join(grammarDir, file3))) {
|
package/dist/index.js
CHANGED
|
@@ -40679,12 +40679,24 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
40679
40679
|
});
|
|
40680
40680
|
|
|
40681
40681
|
// src/lang/runtime.ts
|
|
40682
|
-
import
|
|
40682
|
+
import * as path47 from "path";
|
|
40683
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
40683
40684
|
async function initTreeSitter() {
|
|
40684
40685
|
if (treeSitterInitialized) {
|
|
40685
40686
|
return;
|
|
40686
40687
|
}
|
|
40687
|
-
|
|
40688
|
+
const thisDir = path47.dirname(fileURLToPath2(import.meta.url));
|
|
40689
|
+
const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/lang");
|
|
40690
|
+
if (isSource) {
|
|
40691
|
+
await Parser.init();
|
|
40692
|
+
} else {
|
|
40693
|
+
const grammarsDir = getGrammarsDirAbsolute();
|
|
40694
|
+
await Parser.init({
|
|
40695
|
+
locateFile(scriptName) {
|
|
40696
|
+
return path47.join(grammarsDir, scriptName);
|
|
40697
|
+
}
|
|
40698
|
+
});
|
|
40699
|
+
}
|
|
40688
40700
|
treeSitterInitialized = true;
|
|
40689
40701
|
}
|
|
40690
40702
|
function sanitizeLanguageId(languageId) {
|
|
@@ -40701,12 +40713,10 @@ function getWasmFileName(languageId) {
|
|
|
40701
40713
|
}
|
|
40702
40714
|
return `tree-sitter-${sanitized}.wasm`;
|
|
40703
40715
|
}
|
|
40704
|
-
function
|
|
40705
|
-
const
|
|
40706
|
-
|
|
40707
|
-
|
|
40708
|
-
}
|
|
40709
|
-
return "../../dist/lang/grammars/";
|
|
40716
|
+
function getGrammarsDirAbsolute() {
|
|
40717
|
+
const thisDir = path47.dirname(fileURLToPath2(import.meta.url));
|
|
40718
|
+
const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/lang");
|
|
40719
|
+
return isSource ? path47.join(thisDir, "grammars") : path47.join(thisDir, "lang", "grammars");
|
|
40710
40720
|
}
|
|
40711
40721
|
async function loadGrammar(languageId) {
|
|
40712
40722
|
if (typeof languageId !== "string" || languageId.length > 100) {
|
|
@@ -40722,8 +40732,7 @@ async function loadGrammar(languageId) {
|
|
|
40722
40732
|
await initTreeSitter();
|
|
40723
40733
|
const parser = new Parser;
|
|
40724
40734
|
const wasmFileName = getWasmFileName(normalizedId);
|
|
40725
|
-
const
|
|
40726
|
-
const wasmPath = fileURLToPath(new URL(`${grammarsPath}${wasmFileName}`, import.meta.url));
|
|
40735
|
+
const wasmPath = path47.join(getGrammarsDirAbsolute(), wasmFileName);
|
|
40727
40736
|
const { existsSync: existsSync29 } = await import("fs");
|
|
40728
40737
|
if (!existsSync29(wasmPath)) {
|
|
40729
40738
|
throw new Error(`Grammar file not found for ${languageId}: ${wasmPath}
|
|
@@ -40766,7 +40775,7 @@ var init_runtime = __esm(() => {
|
|
|
40766
40775
|
});
|
|
40767
40776
|
|
|
40768
40777
|
// src/index.ts
|
|
40769
|
-
import * as
|
|
40778
|
+
import * as path63 from "path";
|
|
40770
40779
|
|
|
40771
40780
|
// src/agents/index.ts
|
|
40772
40781
|
init_config();
|
|
@@ -46949,6 +46958,7 @@ init_manager2();
|
|
|
46949
46958
|
import { execSync } from "child_process";
|
|
46950
46959
|
import { existsSync as existsSync8, readdirSync as readdirSync2, readFileSync as readFileSync5, statSync as statSync5 } from "fs";
|
|
46951
46960
|
import path18 from "path";
|
|
46961
|
+
import { fileURLToPath } from "url";
|
|
46952
46962
|
function validateTaskDag(plan) {
|
|
46953
46963
|
const allTaskIds = new Set;
|
|
46954
46964
|
for (const phase of plan.phases) {
|
|
@@ -47286,8 +47296,9 @@ async function checkGrammarWasmFiles() {
|
|
|
47286
47296
|
"tree-sitter-swift.wasm",
|
|
47287
47297
|
"tree-sitter-dart.wasm"
|
|
47288
47298
|
];
|
|
47289
|
-
const
|
|
47290
|
-
const
|
|
47299
|
+
const thisDir = path18.dirname(fileURLToPath(import.meta.url));
|
|
47300
|
+
const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/services");
|
|
47301
|
+
const grammarDir = isSource ? path18.join(thisDir, "..", "lang", "grammars") : path18.join(thisDir, "lang", "grammars");
|
|
47291
47302
|
const missing = [];
|
|
47292
47303
|
for (const file3 of grammarFiles) {
|
|
47293
47304
|
if (!existsSync8(path18.join(grammarDir, file3))) {
|
|
@@ -59021,20 +59032,20 @@ function validateBase(base) {
|
|
|
59021
59032
|
function validatePaths(paths) {
|
|
59022
59033
|
if (!paths)
|
|
59023
59034
|
return null;
|
|
59024
|
-
for (const
|
|
59025
|
-
if (!
|
|
59035
|
+
for (const path48 of paths) {
|
|
59036
|
+
if (!path48 || path48.length === 0) {
|
|
59026
59037
|
return "empty path not allowed";
|
|
59027
59038
|
}
|
|
59028
|
-
if (
|
|
59039
|
+
if (path48.length > MAX_PATH_LENGTH) {
|
|
59029
59040
|
return `path exceeds maximum length of ${MAX_PATH_LENGTH}`;
|
|
59030
59041
|
}
|
|
59031
|
-
if (SHELL_METACHARACTERS2.test(
|
|
59042
|
+
if (SHELL_METACHARACTERS2.test(path48)) {
|
|
59032
59043
|
return "path contains shell metacharacters";
|
|
59033
59044
|
}
|
|
59034
|
-
if (
|
|
59045
|
+
if (path48.startsWith("-")) {
|
|
59035
59046
|
return 'path cannot start with "-" (option-like arguments not allowed)';
|
|
59036
59047
|
}
|
|
59037
|
-
if (CONTROL_CHAR_PATTERN2.test(
|
|
59048
|
+
if (CONTROL_CHAR_PATTERN2.test(path48)) {
|
|
59038
59049
|
return "path contains control characters";
|
|
59039
59050
|
}
|
|
59040
59051
|
}
|
|
@@ -59115,8 +59126,8 @@ var diff = createSwarmTool({
|
|
|
59115
59126
|
if (parts2.length >= 3) {
|
|
59116
59127
|
const additions = parseInt(parts2[0], 10) || 0;
|
|
59117
59128
|
const deletions = parseInt(parts2[1], 10) || 0;
|
|
59118
|
-
const
|
|
59119
|
-
files.push({ path:
|
|
59129
|
+
const path48 = parts2[2];
|
|
59130
|
+
files.push({ path: path48, additions, deletions });
|
|
59120
59131
|
}
|
|
59121
59132
|
}
|
|
59122
59133
|
const contractChanges = [];
|
|
@@ -59399,7 +59410,7 @@ Use these as DOMAIN values when delegating to @sme.`;
|
|
|
59399
59410
|
init_dist();
|
|
59400
59411
|
init_create_tool();
|
|
59401
59412
|
import * as fs36 from "fs";
|
|
59402
|
-
import * as
|
|
59413
|
+
import * as path48 from "path";
|
|
59403
59414
|
var MAX_FILE_SIZE_BYTES4 = 1024 * 1024;
|
|
59404
59415
|
var MAX_EVIDENCE_FILES = 1000;
|
|
59405
59416
|
var EVIDENCE_DIR2 = ".swarm/evidence";
|
|
@@ -59426,9 +59437,9 @@ function validateRequiredTypes(input) {
|
|
|
59426
59437
|
return null;
|
|
59427
59438
|
}
|
|
59428
59439
|
function isPathWithinSwarm2(filePath, cwd) {
|
|
59429
|
-
const normalizedCwd =
|
|
59430
|
-
const swarmPath =
|
|
59431
|
-
const normalizedPath =
|
|
59440
|
+
const normalizedCwd = path48.resolve(cwd);
|
|
59441
|
+
const swarmPath = path48.join(normalizedCwd, ".swarm");
|
|
59442
|
+
const normalizedPath = path48.resolve(filePath);
|
|
59432
59443
|
return normalizedPath.startsWith(swarmPath);
|
|
59433
59444
|
}
|
|
59434
59445
|
function parseCompletedTasks(planContent) {
|
|
@@ -59458,10 +59469,10 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
59458
59469
|
if (!VALID_EVIDENCE_FILENAME_REGEX.test(filename)) {
|
|
59459
59470
|
continue;
|
|
59460
59471
|
}
|
|
59461
|
-
const filePath =
|
|
59472
|
+
const filePath = path48.join(evidenceDir, filename);
|
|
59462
59473
|
try {
|
|
59463
|
-
const resolvedPath =
|
|
59464
|
-
const evidenceDirResolved =
|
|
59474
|
+
const resolvedPath = path48.resolve(filePath);
|
|
59475
|
+
const evidenceDirResolved = path48.resolve(evidenceDir);
|
|
59465
59476
|
if (!resolvedPath.startsWith(evidenceDirResolved)) {
|
|
59466
59477
|
continue;
|
|
59467
59478
|
}
|
|
@@ -59579,7 +59590,7 @@ var evidence_check = createSwarmTool({
|
|
|
59579
59590
|
return JSON.stringify(errorResult, null, 2);
|
|
59580
59591
|
}
|
|
59581
59592
|
const requiredTypes = requiredTypesValue.split(",").map((t) => t.trim()).filter((t) => t.length > 0).map(normalizeEvidenceType);
|
|
59582
|
-
const planPath =
|
|
59593
|
+
const planPath = path48.join(cwd, PLAN_FILE);
|
|
59583
59594
|
if (!isPathWithinSwarm2(planPath, cwd)) {
|
|
59584
59595
|
const errorResult = {
|
|
59585
59596
|
error: "plan file path validation failed",
|
|
@@ -59611,7 +59622,7 @@ var evidence_check = createSwarmTool({
|
|
|
59611
59622
|
};
|
|
59612
59623
|
return JSON.stringify(result2, null, 2);
|
|
59613
59624
|
}
|
|
59614
|
-
const evidenceDir =
|
|
59625
|
+
const evidenceDir = path48.join(cwd, EVIDENCE_DIR2);
|
|
59615
59626
|
const evidence = readEvidenceFiles(evidenceDir, cwd);
|
|
59616
59627
|
const { tasksWithFullEvidence, gaps } = analyzeGaps(completedTasks, evidence, requiredTypes);
|
|
59617
59628
|
const completeness = completedTasks.length > 0 ? Math.round(tasksWithFullEvidence.length / completedTasks.length * 100) / 100 : 1;
|
|
@@ -59629,7 +59640,7 @@ var evidence_check = createSwarmTool({
|
|
|
59629
59640
|
init_tool();
|
|
59630
59641
|
init_create_tool();
|
|
59631
59642
|
import * as fs37 from "fs";
|
|
59632
|
-
import * as
|
|
59643
|
+
import * as path49 from "path";
|
|
59633
59644
|
var EXT_MAP = {
|
|
59634
59645
|
python: ".py",
|
|
59635
59646
|
py: ".py",
|
|
@@ -59710,12 +59721,12 @@ var extract_code_blocks = createSwarmTool({
|
|
|
59710
59721
|
if (prefix) {
|
|
59711
59722
|
filename = `${prefix}_${filename}`;
|
|
59712
59723
|
}
|
|
59713
|
-
let filepath =
|
|
59714
|
-
const base =
|
|
59715
|
-
const ext =
|
|
59724
|
+
let filepath = path49.join(targetDir, filename);
|
|
59725
|
+
const base = path49.basename(filepath, path49.extname(filepath));
|
|
59726
|
+
const ext = path49.extname(filepath);
|
|
59716
59727
|
let counter = 1;
|
|
59717
59728
|
while (fs37.existsSync(filepath)) {
|
|
59718
|
-
filepath =
|
|
59729
|
+
filepath = path49.join(targetDir, `${base}_${counter}${ext}`);
|
|
59719
59730
|
counter++;
|
|
59720
59731
|
}
|
|
59721
59732
|
try {
|
|
@@ -59836,7 +59847,7 @@ var gitingest = createSwarmTool({
|
|
|
59836
59847
|
init_dist();
|
|
59837
59848
|
init_create_tool();
|
|
59838
59849
|
import * as fs38 from "fs";
|
|
59839
|
-
import * as
|
|
59850
|
+
import * as path50 from "path";
|
|
59840
59851
|
var MAX_FILE_PATH_LENGTH2 = 500;
|
|
59841
59852
|
var MAX_SYMBOL_LENGTH = 256;
|
|
59842
59853
|
var MAX_FILE_SIZE_BYTES5 = 1024 * 1024;
|
|
@@ -59884,7 +59895,7 @@ function validateSymbolInput(symbol3) {
|
|
|
59884
59895
|
return null;
|
|
59885
59896
|
}
|
|
59886
59897
|
function isBinaryFile2(filePath, buffer) {
|
|
59887
|
-
const ext =
|
|
59898
|
+
const ext = path50.extname(filePath).toLowerCase();
|
|
59888
59899
|
if (ext === ".json" || ext === ".md" || ext === ".txt") {
|
|
59889
59900
|
return false;
|
|
59890
59901
|
}
|
|
@@ -59908,15 +59919,15 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
59908
59919
|
const imports = [];
|
|
59909
59920
|
let _resolvedTarget;
|
|
59910
59921
|
try {
|
|
59911
|
-
_resolvedTarget =
|
|
59922
|
+
_resolvedTarget = path50.resolve(targetFile);
|
|
59912
59923
|
} catch {
|
|
59913
59924
|
_resolvedTarget = targetFile;
|
|
59914
59925
|
}
|
|
59915
|
-
const targetBasename =
|
|
59926
|
+
const targetBasename = path50.basename(targetFile, path50.extname(targetFile));
|
|
59916
59927
|
const targetWithExt = targetFile;
|
|
59917
59928
|
const targetWithoutExt = targetFile.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
59918
|
-
const normalizedTargetWithExt =
|
|
59919
|
-
const normalizedTargetWithoutExt =
|
|
59929
|
+
const normalizedTargetWithExt = path50.normalize(targetWithExt).replace(/\\/g, "/");
|
|
59930
|
+
const normalizedTargetWithoutExt = path50.normalize(targetWithoutExt).replace(/\\/g, "/");
|
|
59920
59931
|
const importRegex = /import\s+(?:\{[\s\S]*?\}|(?:\*\s+as\s+\w+)|\w+)\s+from\s+['"`]([^'"`]+)['"`]|import\s+['"`]([^'"`]+)['"`]|require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
59921
59932
|
for (let match = importRegex.exec(content);match !== null; match = importRegex.exec(content)) {
|
|
59922
59933
|
const modulePath = match[1] || match[2] || match[3];
|
|
@@ -59939,9 +59950,9 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
59939
59950
|
}
|
|
59940
59951
|
const _normalizedModule = modulePath.replace(/^\.\//, "").replace(/^\.\.\\/, "../");
|
|
59941
59952
|
let isMatch = false;
|
|
59942
|
-
const _targetDir =
|
|
59943
|
-
const targetExt =
|
|
59944
|
-
const targetBasenameNoExt =
|
|
59953
|
+
const _targetDir = path50.dirname(targetFile);
|
|
59954
|
+
const targetExt = path50.extname(targetFile);
|
|
59955
|
+
const targetBasenameNoExt = path50.basename(targetFile, targetExt);
|
|
59945
59956
|
const moduleNormalized = modulePath.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
59946
59957
|
const moduleName = modulePath.split(/[/\\]/).pop() || "";
|
|
59947
59958
|
const moduleNameNoExt = moduleName.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
@@ -60009,10 +60020,10 @@ function findSourceFiles(dir, files = [], stats = { skippedDirs: [], skippedFile
|
|
|
60009
60020
|
entries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
60010
60021
|
for (const entry of entries) {
|
|
60011
60022
|
if (SKIP_DIRECTORIES3.has(entry)) {
|
|
60012
|
-
stats.skippedDirs.push(
|
|
60023
|
+
stats.skippedDirs.push(path50.join(dir, entry));
|
|
60013
60024
|
continue;
|
|
60014
60025
|
}
|
|
60015
|
-
const fullPath =
|
|
60026
|
+
const fullPath = path50.join(dir, entry);
|
|
60016
60027
|
let stat2;
|
|
60017
60028
|
try {
|
|
60018
60029
|
stat2 = fs38.statSync(fullPath);
|
|
@@ -60026,7 +60037,7 @@ function findSourceFiles(dir, files = [], stats = { skippedDirs: [], skippedFile
|
|
|
60026
60037
|
if (stat2.isDirectory()) {
|
|
60027
60038
|
findSourceFiles(fullPath, files, stats);
|
|
60028
60039
|
} else if (stat2.isFile()) {
|
|
60029
|
-
const ext =
|
|
60040
|
+
const ext = path50.extname(fullPath).toLowerCase();
|
|
60030
60041
|
if (SUPPORTED_EXTENSIONS.includes(ext)) {
|
|
60031
60042
|
files.push(fullPath);
|
|
60032
60043
|
}
|
|
@@ -60083,7 +60094,7 @@ var imports = createSwarmTool({
|
|
|
60083
60094
|
return JSON.stringify(errorResult, null, 2);
|
|
60084
60095
|
}
|
|
60085
60096
|
try {
|
|
60086
|
-
const targetFile =
|
|
60097
|
+
const targetFile = path50.resolve(file3);
|
|
60087
60098
|
if (!fs38.existsSync(targetFile)) {
|
|
60088
60099
|
const errorResult = {
|
|
60089
60100
|
error: `target file not found: ${file3}`,
|
|
@@ -60105,7 +60116,7 @@ var imports = createSwarmTool({
|
|
|
60105
60116
|
};
|
|
60106
60117
|
return JSON.stringify(errorResult, null, 2);
|
|
60107
60118
|
}
|
|
60108
|
-
const baseDir =
|
|
60119
|
+
const baseDir = path50.dirname(targetFile);
|
|
60109
60120
|
const scanStats = {
|
|
60110
60121
|
skippedDirs: [],
|
|
60111
60122
|
skippedFiles: 0,
|
|
@@ -60715,7 +60726,7 @@ init_config();
|
|
|
60715
60726
|
init_schema();
|
|
60716
60727
|
init_manager();
|
|
60717
60728
|
import * as fs39 from "fs";
|
|
60718
|
-
import * as
|
|
60729
|
+
import * as path51 from "path";
|
|
60719
60730
|
init_utils2();
|
|
60720
60731
|
init_telemetry();
|
|
60721
60732
|
init_create_tool();
|
|
@@ -60935,7 +60946,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
60935
60946
|
safeWarn(`[phase_complete] Completion verify error (non-blocking):`, completionError);
|
|
60936
60947
|
}
|
|
60937
60948
|
try {
|
|
60938
|
-
const driftEvidencePath =
|
|
60949
|
+
const driftEvidencePath = path51.join(dir, ".swarm", "evidence", String(phase), "drift-verifier.json");
|
|
60939
60950
|
let driftVerdictFound = false;
|
|
60940
60951
|
let driftVerdictApproved = false;
|
|
60941
60952
|
try {
|
|
@@ -60969,7 +60980,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
60969
60980
|
driftVerdictFound = false;
|
|
60970
60981
|
}
|
|
60971
60982
|
if (!driftVerdictFound) {
|
|
60972
|
-
const specPath =
|
|
60983
|
+
const specPath = path51.join(dir, ".swarm", "spec.md");
|
|
60973
60984
|
const specExists = fs39.existsSync(specPath);
|
|
60974
60985
|
if (!specExists) {
|
|
60975
60986
|
let incompleteTaskCount = 0;
|
|
@@ -61043,7 +61054,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
61043
61054
|
};
|
|
61044
61055
|
if (retroFound && retroEntry?.lessons_learned && retroEntry.lessons_learned.length > 0) {
|
|
61045
61056
|
try {
|
|
61046
|
-
const projectName =
|
|
61057
|
+
const projectName = path51.basename(dir);
|
|
61047
61058
|
const curationResult = await curateAndStoreSwarm(retroEntry.lessons_learned, projectName, { phase_number: phase }, dir, knowledgeConfig);
|
|
61048
61059
|
if (curationResult) {
|
|
61049
61060
|
const sessionState = swarmState.agentSessions.get(sessionID);
|
|
@@ -61253,7 +61264,7 @@ init_discovery();
|
|
|
61253
61264
|
init_utils();
|
|
61254
61265
|
init_create_tool();
|
|
61255
61266
|
import * as fs40 from "fs";
|
|
61256
|
-
import * as
|
|
61267
|
+
import * as path52 from "path";
|
|
61257
61268
|
var MAX_OUTPUT_BYTES5 = 52428800;
|
|
61258
61269
|
var AUDIT_TIMEOUT_MS = 120000;
|
|
61259
61270
|
function isValidEcosystem(value) {
|
|
@@ -61271,16 +61282,16 @@ function validateArgs3(args2) {
|
|
|
61271
61282
|
function detectEcosystems(directory) {
|
|
61272
61283
|
const ecosystems = [];
|
|
61273
61284
|
const cwd = directory;
|
|
61274
|
-
if (fs40.existsSync(
|
|
61285
|
+
if (fs40.existsSync(path52.join(cwd, "package.json"))) {
|
|
61275
61286
|
ecosystems.push("npm");
|
|
61276
61287
|
}
|
|
61277
|
-
if (fs40.existsSync(
|
|
61288
|
+
if (fs40.existsSync(path52.join(cwd, "pyproject.toml")) || fs40.existsSync(path52.join(cwd, "requirements.txt"))) {
|
|
61278
61289
|
ecosystems.push("pip");
|
|
61279
61290
|
}
|
|
61280
|
-
if (fs40.existsSync(
|
|
61291
|
+
if (fs40.existsSync(path52.join(cwd, "Cargo.toml"))) {
|
|
61281
61292
|
ecosystems.push("cargo");
|
|
61282
61293
|
}
|
|
61283
|
-
if (fs40.existsSync(
|
|
61294
|
+
if (fs40.existsSync(path52.join(cwd, "go.mod"))) {
|
|
61284
61295
|
ecosystems.push("go");
|
|
61285
61296
|
}
|
|
61286
61297
|
try {
|
|
@@ -61289,10 +61300,10 @@ function detectEcosystems(directory) {
|
|
|
61289
61300
|
ecosystems.push("dotnet");
|
|
61290
61301
|
}
|
|
61291
61302
|
} catch {}
|
|
61292
|
-
if (fs40.existsSync(
|
|
61303
|
+
if (fs40.existsSync(path52.join(cwd, "Gemfile")) || fs40.existsSync(path52.join(cwd, "Gemfile.lock"))) {
|
|
61293
61304
|
ecosystems.push("ruby");
|
|
61294
61305
|
}
|
|
61295
|
-
if (fs40.existsSync(
|
|
61306
|
+
if (fs40.existsSync(path52.join(cwd, "pubspec.yaml"))) {
|
|
61296
61307
|
ecosystems.push("dart");
|
|
61297
61308
|
}
|
|
61298
61309
|
return ecosystems;
|
|
@@ -62314,7 +62325,7 @@ var SUPPORTED_PARSER_EXTENSIONS = new Set([
|
|
|
62314
62325
|
// src/tools/pre-check-batch.ts
|
|
62315
62326
|
init_dist();
|
|
62316
62327
|
import * as fs42 from "fs";
|
|
62317
|
-
import * as
|
|
62328
|
+
import * as path54 from "path";
|
|
62318
62329
|
|
|
62319
62330
|
// node_modules/yocto-queue/index.js
|
|
62320
62331
|
class Node2 {
|
|
@@ -62589,7 +62600,7 @@ init_dist();
|
|
|
62589
62600
|
init_manager();
|
|
62590
62601
|
init_detector();
|
|
62591
62602
|
import * as fs41 from "fs";
|
|
62592
|
-
import * as
|
|
62603
|
+
import * as path53 from "path";
|
|
62593
62604
|
import { extname as extname10 } from "path";
|
|
62594
62605
|
|
|
62595
62606
|
// src/sast/rules/c.ts
|
|
@@ -63555,7 +63566,7 @@ async function sastScan(input, directory, config3) {
|
|
|
63555
63566
|
_filesSkipped++;
|
|
63556
63567
|
continue;
|
|
63557
63568
|
}
|
|
63558
|
-
const resolvedPath =
|
|
63569
|
+
const resolvedPath = path53.isAbsolute(filePath) ? filePath : path53.resolve(directory, filePath);
|
|
63559
63570
|
if (!fs41.existsSync(resolvedPath)) {
|
|
63560
63571
|
_filesSkipped++;
|
|
63561
63572
|
continue;
|
|
@@ -63754,18 +63765,18 @@ function validatePath(inputPath, baseDir, workspaceDir) {
|
|
|
63754
63765
|
let resolved;
|
|
63755
63766
|
const isWinAbs = isWindowsAbsolutePath(inputPath);
|
|
63756
63767
|
if (isWinAbs) {
|
|
63757
|
-
resolved =
|
|
63758
|
-
} else if (
|
|
63759
|
-
resolved =
|
|
63768
|
+
resolved = path54.win32.resolve(inputPath);
|
|
63769
|
+
} else if (path54.isAbsolute(inputPath)) {
|
|
63770
|
+
resolved = path54.resolve(inputPath);
|
|
63760
63771
|
} else {
|
|
63761
|
-
resolved =
|
|
63772
|
+
resolved = path54.resolve(baseDir, inputPath);
|
|
63762
63773
|
}
|
|
63763
|
-
const workspaceResolved =
|
|
63774
|
+
const workspaceResolved = path54.resolve(workspaceDir);
|
|
63764
63775
|
let relative6;
|
|
63765
63776
|
if (isWinAbs) {
|
|
63766
|
-
relative6 =
|
|
63777
|
+
relative6 = path54.win32.relative(workspaceResolved, resolved);
|
|
63767
63778
|
} else {
|
|
63768
|
-
relative6 =
|
|
63779
|
+
relative6 = path54.relative(workspaceResolved, resolved);
|
|
63769
63780
|
}
|
|
63770
63781
|
if (relative6.startsWith("..")) {
|
|
63771
63782
|
return "path traversal detected";
|
|
@@ -63826,13 +63837,13 @@ async function runLintWrapped(files, directory, _config) {
|
|
|
63826
63837
|
}
|
|
63827
63838
|
async function runLintOnFiles(linter, files, workspaceDir) {
|
|
63828
63839
|
const isWindows = process.platform === "win32";
|
|
63829
|
-
const binDir =
|
|
63840
|
+
const binDir = path54.join(workspaceDir, "node_modules", ".bin");
|
|
63830
63841
|
const validatedFiles = [];
|
|
63831
63842
|
for (const file3 of files) {
|
|
63832
63843
|
if (typeof file3 !== "string") {
|
|
63833
63844
|
continue;
|
|
63834
63845
|
}
|
|
63835
|
-
const resolvedPath =
|
|
63846
|
+
const resolvedPath = path54.resolve(file3);
|
|
63836
63847
|
const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
|
|
63837
63848
|
if (validationError) {
|
|
63838
63849
|
continue;
|
|
@@ -63850,10 +63861,10 @@ async function runLintOnFiles(linter, files, workspaceDir) {
|
|
|
63850
63861
|
}
|
|
63851
63862
|
let command;
|
|
63852
63863
|
if (linter === "biome") {
|
|
63853
|
-
const biomeBin = isWindows ?
|
|
63864
|
+
const biomeBin = isWindows ? path54.join(binDir, "biome.EXE") : path54.join(binDir, "biome");
|
|
63854
63865
|
command = [biomeBin, "check", ...validatedFiles];
|
|
63855
63866
|
} else {
|
|
63856
|
-
const eslintBin = isWindows ?
|
|
63867
|
+
const eslintBin = isWindows ? path54.join(binDir, "eslint.cmd") : path54.join(binDir, "eslint");
|
|
63857
63868
|
command = [eslintBin, ...validatedFiles];
|
|
63858
63869
|
}
|
|
63859
63870
|
try {
|
|
@@ -63990,7 +64001,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
63990
64001
|
skippedFiles++;
|
|
63991
64002
|
continue;
|
|
63992
64003
|
}
|
|
63993
|
-
const resolvedPath =
|
|
64004
|
+
const resolvedPath = path54.resolve(file3);
|
|
63994
64005
|
const validationError = validatePath(resolvedPath, directory, directory);
|
|
63995
64006
|
if (validationError) {
|
|
63996
64007
|
skippedFiles++;
|
|
@@ -64008,7 +64019,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
64008
64019
|
};
|
|
64009
64020
|
}
|
|
64010
64021
|
for (const file3 of validatedFiles) {
|
|
64011
|
-
const ext =
|
|
64022
|
+
const ext = path54.extname(file3).toLowerCase();
|
|
64012
64023
|
if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
|
|
64013
64024
|
skippedFiles++;
|
|
64014
64025
|
continue;
|
|
@@ -64209,7 +64220,7 @@ function classifySastFindings(findings, changedLineRanges, directory) {
|
|
|
64209
64220
|
const preexistingFindings = [];
|
|
64210
64221
|
for (const finding of findings) {
|
|
64211
64222
|
const filePath = finding.location.file;
|
|
64212
|
-
const normalised =
|
|
64223
|
+
const normalised = path54.relative(directory, filePath).replace(/\\/g, "/");
|
|
64213
64224
|
const changedLines = changedLineRanges.get(normalised);
|
|
64214
64225
|
if (changedLines && changedLines.has(finding.location.line)) {
|
|
64215
64226
|
newFindings.push(finding);
|
|
@@ -64260,7 +64271,7 @@ async function runPreCheckBatch(input, workspaceDir, contextDir) {
|
|
|
64260
64271
|
warn(`pre_check_batch: Invalid file path: ${file3}`);
|
|
64261
64272
|
continue;
|
|
64262
64273
|
}
|
|
64263
|
-
changedFiles.push(
|
|
64274
|
+
changedFiles.push(path54.resolve(directory, file3));
|
|
64264
64275
|
}
|
|
64265
64276
|
if (changedFiles.length === 0) {
|
|
64266
64277
|
warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
|
|
@@ -64448,7 +64459,7 @@ var pre_check_batch = createSwarmTool({
|
|
|
64448
64459
|
};
|
|
64449
64460
|
return JSON.stringify(errorResult, null, 2);
|
|
64450
64461
|
}
|
|
64451
|
-
const resolvedDirectory =
|
|
64462
|
+
const resolvedDirectory = path54.resolve(typedArgs.directory);
|
|
64452
64463
|
const workspaceAnchor = resolvedDirectory;
|
|
64453
64464
|
const dirError = validateDirectory2(resolvedDirectory, workspaceAnchor);
|
|
64454
64465
|
if (dirError) {
|
|
@@ -64555,24 +64566,24 @@ ${paginatedContent}`;
|
|
|
64555
64566
|
// src/tools/save-plan.ts
|
|
64556
64567
|
init_tool();
|
|
64557
64568
|
import * as fs44 from "fs";
|
|
64558
|
-
import * as
|
|
64569
|
+
import * as path56 from "path";
|
|
64559
64570
|
|
|
64560
64571
|
// src/parallel/file-locks.ts
|
|
64561
64572
|
import * as fs43 from "fs";
|
|
64562
|
-
import * as
|
|
64573
|
+
import * as path55 from "path";
|
|
64563
64574
|
var LOCKS_DIR = ".swarm/locks";
|
|
64564
64575
|
var LOCK_TIMEOUT_MS = 5 * 60 * 1000;
|
|
64565
64576
|
function getLockFilePath(directory, filePath) {
|
|
64566
|
-
const normalized =
|
|
64567
|
-
if (!normalized.startsWith(
|
|
64577
|
+
const normalized = path55.resolve(directory, filePath);
|
|
64578
|
+
if (!normalized.startsWith(path55.resolve(directory))) {
|
|
64568
64579
|
throw new Error("Invalid file path: path traversal not allowed");
|
|
64569
64580
|
}
|
|
64570
64581
|
const hash3 = Buffer.from(normalized).toString("base64").replace(/[/+=]/g, "_");
|
|
64571
|
-
return
|
|
64582
|
+
return path55.join(directory, LOCKS_DIR, `${hash3}.lock`);
|
|
64572
64583
|
}
|
|
64573
64584
|
function tryAcquireLock(directory, filePath, agent, taskId) {
|
|
64574
64585
|
const lockPath = getLockFilePath(directory, filePath);
|
|
64575
|
-
const locksDir =
|
|
64586
|
+
const locksDir = path55.dirname(lockPath);
|
|
64576
64587
|
if (!fs43.existsSync(locksDir)) {
|
|
64577
64588
|
fs43.mkdirSync(locksDir, { recursive: true });
|
|
64578
64589
|
}
|
|
@@ -64738,7 +64749,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
64738
64749
|
try {
|
|
64739
64750
|
await savePlan(dir, plan);
|
|
64740
64751
|
try {
|
|
64741
|
-
const markerPath =
|
|
64752
|
+
const markerPath = path56.join(dir, ".swarm", ".plan-write-marker");
|
|
64742
64753
|
const marker = JSON.stringify({
|
|
64743
64754
|
source: "save_plan",
|
|
64744
64755
|
timestamp: new Date().toISOString(),
|
|
@@ -64761,7 +64772,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
64761
64772
|
return {
|
|
64762
64773
|
success: true,
|
|
64763
64774
|
message: "Plan saved successfully",
|
|
64764
|
-
plan_path:
|
|
64775
|
+
plan_path: path56.join(dir, ".swarm", "plan.json"),
|
|
64765
64776
|
phases_count: plan.phases.length,
|
|
64766
64777
|
tasks_count: tasksCount,
|
|
64767
64778
|
...warnings.length > 0 ? { warnings } : {}
|
|
@@ -64804,7 +64815,7 @@ var save_plan = createSwarmTool({
|
|
|
64804
64815
|
init_dist();
|
|
64805
64816
|
init_manager();
|
|
64806
64817
|
import * as fs45 from "fs";
|
|
64807
|
-
import * as
|
|
64818
|
+
import * as path57 from "path";
|
|
64808
64819
|
|
|
64809
64820
|
// src/sbom/detectors/index.ts
|
|
64810
64821
|
init_utils();
|
|
@@ -65654,7 +65665,7 @@ function findManifestFiles(rootDir) {
|
|
|
65654
65665
|
try {
|
|
65655
65666
|
const entries = fs45.readdirSync(dir, { withFileTypes: true });
|
|
65656
65667
|
for (const entry of entries) {
|
|
65657
|
-
const fullPath =
|
|
65668
|
+
const fullPath = path57.join(dir, entry.name);
|
|
65658
65669
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
|
|
65659
65670
|
continue;
|
|
65660
65671
|
}
|
|
@@ -65663,7 +65674,7 @@ function findManifestFiles(rootDir) {
|
|
|
65663
65674
|
} else if (entry.isFile()) {
|
|
65664
65675
|
for (const pattern of patterns) {
|
|
65665
65676
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
65666
|
-
manifestFiles.push(
|
|
65677
|
+
manifestFiles.push(path57.relative(rootDir, fullPath));
|
|
65667
65678
|
break;
|
|
65668
65679
|
}
|
|
65669
65680
|
}
|
|
@@ -65681,11 +65692,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
65681
65692
|
try {
|
|
65682
65693
|
const entries = fs45.readdirSync(dir, { withFileTypes: true });
|
|
65683
65694
|
for (const entry of entries) {
|
|
65684
|
-
const fullPath =
|
|
65695
|
+
const fullPath = path57.join(dir, entry.name);
|
|
65685
65696
|
if (entry.isFile()) {
|
|
65686
65697
|
for (const pattern of patterns) {
|
|
65687
65698
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
65688
|
-
found.push(
|
|
65699
|
+
found.push(path57.relative(workingDir, fullPath));
|
|
65689
65700
|
break;
|
|
65690
65701
|
}
|
|
65691
65702
|
}
|
|
@@ -65698,11 +65709,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
65698
65709
|
function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
|
|
65699
65710
|
const dirs = new Set;
|
|
65700
65711
|
for (const file3 of changedFiles) {
|
|
65701
|
-
let currentDir =
|
|
65712
|
+
let currentDir = path57.dirname(file3);
|
|
65702
65713
|
while (true) {
|
|
65703
|
-
if (currentDir && currentDir !== "." && currentDir !==
|
|
65704
|
-
dirs.add(
|
|
65705
|
-
const parent =
|
|
65714
|
+
if (currentDir && currentDir !== "." && currentDir !== path57.sep) {
|
|
65715
|
+
dirs.add(path57.join(workingDir, currentDir));
|
|
65716
|
+
const parent = path57.dirname(currentDir);
|
|
65706
65717
|
if (parent === currentDir)
|
|
65707
65718
|
break;
|
|
65708
65719
|
currentDir = parent;
|
|
@@ -65786,7 +65797,7 @@ var sbom_generate = createSwarmTool({
|
|
|
65786
65797
|
const changedFiles = obj.changed_files;
|
|
65787
65798
|
const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
|
|
65788
65799
|
const workingDir = directory;
|
|
65789
|
-
const outputDir =
|
|
65800
|
+
const outputDir = path57.isAbsolute(relativeOutputDir) ? relativeOutputDir : path57.join(workingDir, relativeOutputDir);
|
|
65790
65801
|
let manifestFiles = [];
|
|
65791
65802
|
if (scope === "all") {
|
|
65792
65803
|
manifestFiles = findManifestFiles(workingDir);
|
|
@@ -65809,7 +65820,7 @@ var sbom_generate = createSwarmTool({
|
|
|
65809
65820
|
const processedFiles = [];
|
|
65810
65821
|
for (const manifestFile of manifestFiles) {
|
|
65811
65822
|
try {
|
|
65812
|
-
const fullPath =
|
|
65823
|
+
const fullPath = path57.isAbsolute(manifestFile) ? manifestFile : path57.join(workingDir, manifestFile);
|
|
65813
65824
|
if (!fs45.existsSync(fullPath)) {
|
|
65814
65825
|
continue;
|
|
65815
65826
|
}
|
|
@@ -65826,7 +65837,7 @@ var sbom_generate = createSwarmTool({
|
|
|
65826
65837
|
const bom = generateCycloneDX(allComponents);
|
|
65827
65838
|
const bomJson = serializeCycloneDX(bom);
|
|
65828
65839
|
const filename = generateSbomFilename();
|
|
65829
|
-
const outputPath =
|
|
65840
|
+
const outputPath = path57.join(outputDir, filename);
|
|
65830
65841
|
fs45.writeFileSync(outputPath, bomJson, "utf-8");
|
|
65831
65842
|
const verdict = processedFiles.length > 0 ? "pass" : "pass";
|
|
65832
65843
|
try {
|
|
@@ -65870,7 +65881,7 @@ var sbom_generate = createSwarmTool({
|
|
|
65870
65881
|
init_dist();
|
|
65871
65882
|
init_create_tool();
|
|
65872
65883
|
import * as fs46 from "fs";
|
|
65873
|
-
import * as
|
|
65884
|
+
import * as path58 from "path";
|
|
65874
65885
|
var SPEC_CANDIDATES = [
|
|
65875
65886
|
"openapi.json",
|
|
65876
65887
|
"openapi.yaml",
|
|
@@ -65902,12 +65913,12 @@ function normalizePath2(p) {
|
|
|
65902
65913
|
}
|
|
65903
65914
|
function discoverSpecFile(cwd, specFileArg) {
|
|
65904
65915
|
if (specFileArg) {
|
|
65905
|
-
const resolvedPath =
|
|
65906
|
-
const normalizedCwd = cwd.endsWith(
|
|
65916
|
+
const resolvedPath = path58.resolve(cwd, specFileArg);
|
|
65917
|
+
const normalizedCwd = cwd.endsWith(path58.sep) ? cwd : cwd + path58.sep;
|
|
65907
65918
|
if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
|
|
65908
65919
|
throw new Error("Invalid spec_file: path traversal detected");
|
|
65909
65920
|
}
|
|
65910
|
-
const ext =
|
|
65921
|
+
const ext = path58.extname(resolvedPath).toLowerCase();
|
|
65911
65922
|
if (!ALLOWED_EXTENSIONS.includes(ext)) {
|
|
65912
65923
|
throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
|
|
65913
65924
|
}
|
|
@@ -65921,7 +65932,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
65921
65932
|
return resolvedPath;
|
|
65922
65933
|
}
|
|
65923
65934
|
for (const candidate of SPEC_CANDIDATES) {
|
|
65924
|
-
const candidatePath =
|
|
65935
|
+
const candidatePath = path58.resolve(cwd, candidate);
|
|
65925
65936
|
if (fs46.existsSync(candidatePath)) {
|
|
65926
65937
|
const stats = fs46.statSync(candidatePath);
|
|
65927
65938
|
if (stats.size <= MAX_SPEC_SIZE) {
|
|
@@ -65933,7 +65944,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
65933
65944
|
}
|
|
65934
65945
|
function parseSpec(specFile) {
|
|
65935
65946
|
const content = fs46.readFileSync(specFile, "utf-8");
|
|
65936
|
-
const ext =
|
|
65947
|
+
const ext = path58.extname(specFile).toLowerCase();
|
|
65937
65948
|
if (ext === ".json") {
|
|
65938
65949
|
return parseJsonSpec(content);
|
|
65939
65950
|
}
|
|
@@ -66009,7 +66020,7 @@ function extractRoutes(cwd) {
|
|
|
66009
66020
|
return;
|
|
66010
66021
|
}
|
|
66011
66022
|
for (const entry of entries) {
|
|
66012
|
-
const fullPath =
|
|
66023
|
+
const fullPath = path58.join(dir, entry.name);
|
|
66013
66024
|
if (entry.isSymbolicLink()) {
|
|
66014
66025
|
continue;
|
|
66015
66026
|
}
|
|
@@ -66019,7 +66030,7 @@ function extractRoutes(cwd) {
|
|
|
66019
66030
|
}
|
|
66020
66031
|
walkDir(fullPath);
|
|
66021
66032
|
} else if (entry.isFile()) {
|
|
66022
|
-
const ext =
|
|
66033
|
+
const ext = path58.extname(entry.name).toLowerCase();
|
|
66023
66034
|
const baseName = entry.name.toLowerCase();
|
|
66024
66035
|
if (![".ts", ".js", ".mjs"].includes(ext)) {
|
|
66025
66036
|
continue;
|
|
@@ -66189,7 +66200,7 @@ init_secretscan();
|
|
|
66189
66200
|
init_tool();
|
|
66190
66201
|
init_create_tool();
|
|
66191
66202
|
import * as fs47 from "fs";
|
|
66192
|
-
import * as
|
|
66203
|
+
import * as path59 from "path";
|
|
66193
66204
|
var MAX_FILE_SIZE_BYTES7 = 1024 * 1024;
|
|
66194
66205
|
var WINDOWS_RESERVED_NAMES = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
66195
66206
|
function containsWindowsAttacks(str) {
|
|
@@ -66206,11 +66217,11 @@ function containsWindowsAttacks(str) {
|
|
|
66206
66217
|
}
|
|
66207
66218
|
function isPathInWorkspace(filePath, workspace) {
|
|
66208
66219
|
try {
|
|
66209
|
-
const resolvedPath =
|
|
66220
|
+
const resolvedPath = path59.resolve(workspace, filePath);
|
|
66210
66221
|
const realWorkspace = fs47.realpathSync(workspace);
|
|
66211
66222
|
const realResolvedPath = fs47.realpathSync(resolvedPath);
|
|
66212
|
-
const relativePath =
|
|
66213
|
-
if (relativePath.startsWith("..") ||
|
|
66223
|
+
const relativePath = path59.relative(realWorkspace, realResolvedPath);
|
|
66224
|
+
if (relativePath.startsWith("..") || path59.isAbsolute(relativePath)) {
|
|
66214
66225
|
return false;
|
|
66215
66226
|
}
|
|
66216
66227
|
return true;
|
|
@@ -66222,7 +66233,7 @@ function validatePathForRead(filePath, workspace) {
|
|
|
66222
66233
|
return isPathInWorkspace(filePath, workspace);
|
|
66223
66234
|
}
|
|
66224
66235
|
function extractTSSymbols(filePath, cwd) {
|
|
66225
|
-
const fullPath =
|
|
66236
|
+
const fullPath = path59.join(cwd, filePath);
|
|
66226
66237
|
if (!validatePathForRead(fullPath, cwd)) {
|
|
66227
66238
|
return [];
|
|
66228
66239
|
}
|
|
@@ -66374,7 +66385,7 @@ function extractTSSymbols(filePath, cwd) {
|
|
|
66374
66385
|
});
|
|
66375
66386
|
}
|
|
66376
66387
|
function extractPythonSymbols(filePath, cwd) {
|
|
66377
|
-
const fullPath =
|
|
66388
|
+
const fullPath = path59.join(cwd, filePath);
|
|
66378
66389
|
if (!validatePathForRead(fullPath, cwd)) {
|
|
66379
66390
|
return [];
|
|
66380
66391
|
}
|
|
@@ -66457,7 +66468,7 @@ var symbols = createSwarmTool({
|
|
|
66457
66468
|
}, null, 2);
|
|
66458
66469
|
}
|
|
66459
66470
|
const cwd = directory;
|
|
66460
|
-
const ext =
|
|
66471
|
+
const ext = path59.extname(file3);
|
|
66461
66472
|
if (containsControlChars(file3)) {
|
|
66462
66473
|
return JSON.stringify({
|
|
66463
66474
|
file: file3,
|
|
@@ -66529,7 +66540,7 @@ init_dist();
|
|
|
66529
66540
|
init_utils();
|
|
66530
66541
|
init_create_tool();
|
|
66531
66542
|
import * as fs48 from "fs";
|
|
66532
|
-
import * as
|
|
66543
|
+
import * as path60 from "path";
|
|
66533
66544
|
var MAX_TEXT_LENGTH = 200;
|
|
66534
66545
|
var MAX_FILE_SIZE_BYTES8 = 1024 * 1024;
|
|
66535
66546
|
var SUPPORTED_EXTENSIONS2 = new Set([
|
|
@@ -66594,9 +66605,9 @@ function validatePathsInput(paths, cwd) {
|
|
|
66594
66605
|
return { error: "paths contains path traversal", resolvedPath: null };
|
|
66595
66606
|
}
|
|
66596
66607
|
try {
|
|
66597
|
-
const resolvedPath =
|
|
66598
|
-
const normalizedCwd =
|
|
66599
|
-
const normalizedResolved =
|
|
66608
|
+
const resolvedPath = path60.resolve(paths);
|
|
66609
|
+
const normalizedCwd = path60.resolve(cwd);
|
|
66610
|
+
const normalizedResolved = path60.resolve(resolvedPath);
|
|
66600
66611
|
if (!normalizedResolved.startsWith(normalizedCwd)) {
|
|
66601
66612
|
return {
|
|
66602
66613
|
error: "paths must be within the current working directory",
|
|
@@ -66612,7 +66623,7 @@ function validatePathsInput(paths, cwd) {
|
|
|
66612
66623
|
}
|
|
66613
66624
|
}
|
|
66614
66625
|
function isSupportedExtension(filePath) {
|
|
66615
|
-
const ext =
|
|
66626
|
+
const ext = path60.extname(filePath).toLowerCase();
|
|
66616
66627
|
return SUPPORTED_EXTENSIONS2.has(ext);
|
|
66617
66628
|
}
|
|
66618
66629
|
function findSourceFiles2(dir, files = []) {
|
|
@@ -66627,7 +66638,7 @@ function findSourceFiles2(dir, files = []) {
|
|
|
66627
66638
|
if (SKIP_DIRECTORIES4.has(entry)) {
|
|
66628
66639
|
continue;
|
|
66629
66640
|
}
|
|
66630
|
-
const fullPath =
|
|
66641
|
+
const fullPath = path60.join(dir, entry);
|
|
66631
66642
|
let stat2;
|
|
66632
66643
|
try {
|
|
66633
66644
|
stat2 = fs48.statSync(fullPath);
|
|
@@ -66739,7 +66750,7 @@ var todo_extract = createSwarmTool({
|
|
|
66739
66750
|
filesToScan.push(scanPath);
|
|
66740
66751
|
} else {
|
|
66741
66752
|
const errorResult = {
|
|
66742
|
-
error: `unsupported file extension: ${
|
|
66753
|
+
error: `unsupported file extension: ${path60.extname(scanPath)}`,
|
|
66743
66754
|
total: 0,
|
|
66744
66755
|
byPriority: { high: 0, medium: 0, low: 0 },
|
|
66745
66756
|
entries: []
|
|
@@ -66786,14 +66797,14 @@ init_tool();
|
|
|
66786
66797
|
init_schema();
|
|
66787
66798
|
init_gate_evidence();
|
|
66788
66799
|
import * as fs50 from "fs";
|
|
66789
|
-
import * as
|
|
66800
|
+
import * as path62 from "path";
|
|
66790
66801
|
|
|
66791
66802
|
// src/hooks/diff-scope.ts
|
|
66792
66803
|
import * as fs49 from "fs";
|
|
66793
|
-
import * as
|
|
66804
|
+
import * as path61 from "path";
|
|
66794
66805
|
function getDeclaredScope(taskId, directory) {
|
|
66795
66806
|
try {
|
|
66796
|
-
const planPath =
|
|
66807
|
+
const planPath = path61.join(directory, ".swarm", "plan.json");
|
|
66797
66808
|
if (!fs49.existsSync(planPath))
|
|
66798
66809
|
return null;
|
|
66799
66810
|
const raw = fs49.readFileSync(planPath, "utf-8");
|
|
@@ -66909,7 +66920,7 @@ var TIER_3_PATTERNS = [
|
|
|
66909
66920
|
];
|
|
66910
66921
|
function matchesTier3Pattern(files) {
|
|
66911
66922
|
for (const file3 of files) {
|
|
66912
|
-
const fileName =
|
|
66923
|
+
const fileName = path62.basename(file3);
|
|
66913
66924
|
for (const pattern of TIER_3_PATTERNS) {
|
|
66914
66925
|
if (pattern.test(fileName)) {
|
|
66915
66926
|
return true;
|
|
@@ -66923,7 +66934,7 @@ function checkReviewerGate(taskId, workingDirectory) {
|
|
|
66923
66934
|
if (hasActiveTurboMode()) {
|
|
66924
66935
|
const resolvedDir2 = workingDirectory;
|
|
66925
66936
|
try {
|
|
66926
|
-
const planPath =
|
|
66937
|
+
const planPath = path62.join(resolvedDir2, ".swarm", "plan.json");
|
|
66927
66938
|
const planRaw = fs50.readFileSync(planPath, "utf-8");
|
|
66928
66939
|
const plan = JSON.parse(planRaw);
|
|
66929
66940
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -66990,7 +67001,7 @@ function checkReviewerGate(taskId, workingDirectory) {
|
|
|
66990
67001
|
}
|
|
66991
67002
|
try {
|
|
66992
67003
|
const resolvedDir2 = workingDirectory;
|
|
66993
|
-
const planPath =
|
|
67004
|
+
const planPath = path62.join(resolvedDir2, ".swarm", "plan.json");
|
|
66994
67005
|
const planRaw = fs50.readFileSync(planPath, "utf-8");
|
|
66995
67006
|
const plan = JSON.parse(planRaw);
|
|
66996
67007
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -67173,8 +67184,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
67173
67184
|
};
|
|
67174
67185
|
}
|
|
67175
67186
|
}
|
|
67176
|
-
normalizedDir =
|
|
67177
|
-
const pathParts = normalizedDir.split(
|
|
67187
|
+
normalizedDir = path62.normalize(args2.working_directory);
|
|
67188
|
+
const pathParts = normalizedDir.split(path62.sep);
|
|
67178
67189
|
if (pathParts.includes("..")) {
|
|
67179
67190
|
return {
|
|
67180
67191
|
success: false,
|
|
@@ -67184,10 +67195,10 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
67184
67195
|
]
|
|
67185
67196
|
};
|
|
67186
67197
|
}
|
|
67187
|
-
const resolvedDir =
|
|
67198
|
+
const resolvedDir = path62.resolve(normalizedDir);
|
|
67188
67199
|
try {
|
|
67189
67200
|
const realPath = fs50.realpathSync(resolvedDir);
|
|
67190
|
-
const planPath =
|
|
67201
|
+
const planPath = path62.join(realPath, ".swarm", "plan.json");
|
|
67191
67202
|
if (!fs50.existsSync(planPath)) {
|
|
67192
67203
|
return {
|
|
67193
67204
|
success: false,
|
|
@@ -67221,7 +67232,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
67221
67232
|
recoverTaskStateFromDelegations(args2.task_id);
|
|
67222
67233
|
let phaseRequiresReviewer = true;
|
|
67223
67234
|
try {
|
|
67224
|
-
const planPath =
|
|
67235
|
+
const planPath = path62.join(directory, ".swarm", "plan.json");
|
|
67225
67236
|
const planRaw = fs50.readFileSync(planPath, "utf-8");
|
|
67226
67237
|
const plan = JSON.parse(planRaw);
|
|
67227
67238
|
const taskPhase = plan.phases.find((p) => p.tasks.some((t) => t.id === args2.task_id));
|
|
@@ -67429,7 +67440,7 @@ var OpenCodeSwarm = async (ctx) => {
|
|
|
67429
67440
|
const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
|
|
67430
67441
|
preflightTriggerManager = new PTM(automationConfig);
|
|
67431
67442
|
const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
|
|
67432
|
-
const swarmDir =
|
|
67443
|
+
const swarmDir = path63.resolve(ctx.directory, ".swarm");
|
|
67433
67444
|
statusArtifact = new ASA(swarmDir);
|
|
67434
67445
|
statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
|
|
67435
67446
|
if (automationConfig.capabilities?.evidence_auto_summaries === true) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "6.40.
|
|
3
|
+
"version": "6.40.6",
|
|
4
4
|
"description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|