opencode-swarm 6.40.5 → 6.40.7
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 +14 -7
- package/dist/index.js +159 -139
- package/dist/lang/grammars/tree-sitter.wasm +0 -0
- 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();
|
|
@@ -33149,25 +33150,31 @@ async function checkGrammarWasmFiles() {
|
|
|
33149
33150
|
const grammarFiles = [
|
|
33150
33151
|
"tree-sitter-javascript.wasm",
|
|
33151
33152
|
"tree-sitter-typescript.wasm",
|
|
33153
|
+
"tree-sitter-tsx.wasm",
|
|
33152
33154
|
"tree-sitter-python.wasm",
|
|
33153
33155
|
"tree-sitter-go.wasm",
|
|
33154
33156
|
"tree-sitter-rust.wasm",
|
|
33155
33157
|
"tree-sitter-cpp.wasm",
|
|
33156
33158
|
"tree-sitter-c-sharp.wasm",
|
|
33157
33159
|
"tree-sitter-css.wasm",
|
|
33158
|
-
"tree-sitter-html.wasm",
|
|
33159
|
-
"tree-sitter-json.wasm",
|
|
33160
33160
|
"tree-sitter-bash.wasm",
|
|
33161
33161
|
"tree-sitter-ruby.wasm",
|
|
33162
33162
|
"tree-sitter-php.wasm",
|
|
33163
33163
|
"tree-sitter-java.wasm",
|
|
33164
33164
|
"tree-sitter-kotlin.wasm",
|
|
33165
33165
|
"tree-sitter-swift.wasm",
|
|
33166
|
-
"tree-sitter-dart.wasm"
|
|
33166
|
+
"tree-sitter-dart.wasm",
|
|
33167
|
+
"tree-sitter-powershell.wasm",
|
|
33168
|
+
"tree-sitter-ini.wasm",
|
|
33169
|
+
"tree-sitter-regex.wasm"
|
|
33167
33170
|
];
|
|
33168
|
-
const
|
|
33169
|
-
const
|
|
33171
|
+
const thisDir = path12.dirname(fileURLToPath(import.meta.url));
|
|
33172
|
+
const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/services");
|
|
33173
|
+
const grammarDir = isSource ? path12.join(thisDir, "..", "lang", "grammars") : path12.join(thisDir, "lang", "grammars");
|
|
33170
33174
|
const missing = [];
|
|
33175
|
+
if (!existsSync4(path12.join(grammarDir, "tree-sitter.wasm"))) {
|
|
33176
|
+
missing.push("tree-sitter.wasm (core runtime)");
|
|
33177
|
+
}
|
|
33171
33178
|
for (const file3 of grammarFiles) {
|
|
33172
33179
|
if (!existsSync4(path12.join(grammarDir, file3))) {
|
|
33173
33180
|
missing.push(file3);
|
|
@@ -33177,13 +33184,13 @@ async function checkGrammarWasmFiles() {
|
|
|
33177
33184
|
return {
|
|
33178
33185
|
name: "Grammar WASM Files",
|
|
33179
33186
|
status: "\u2705",
|
|
33180
|
-
detail:
|
|
33187
|
+
detail: `Core runtime + all ${grammarFiles.length} grammar WASM files present`
|
|
33181
33188
|
};
|
|
33182
33189
|
}
|
|
33183
33190
|
return {
|
|
33184
33191
|
name: "Grammar WASM Files",
|
|
33185
33192
|
status: "\u274C",
|
|
33186
|
-
detail: `${missing.length}
|
|
33193
|
+
detail: `${missing.length} WASM file(s) missing: ${missing.join(", ")}`
|
|
33187
33194
|
};
|
|
33188
33195
|
}
|
|
33189
33196
|
async function checkCheckpointManifest(directory) {
|
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}
|
|
@@ -40748,6 +40757,7 @@ var init_runtime = __esm(() => {
|
|
|
40748
40757
|
LANGUAGE_WASM_MAP = {
|
|
40749
40758
|
javascript: "tree-sitter-javascript.wasm",
|
|
40750
40759
|
typescript: "tree-sitter-typescript.wasm",
|
|
40760
|
+
tsx: "tree-sitter-tsx.wasm",
|
|
40751
40761
|
python: "tree-sitter-python.wasm",
|
|
40752
40762
|
go: "tree-sitter-go.wasm",
|
|
40753
40763
|
rust: "tree-sitter-rust.wasm",
|
|
@@ -40761,12 +40771,15 @@ var init_runtime = __esm(() => {
|
|
|
40761
40771
|
java: "tree-sitter-java.wasm",
|
|
40762
40772
|
kotlin: "tree-sitter-kotlin.wasm",
|
|
40763
40773
|
swift: "tree-sitter-swift.wasm",
|
|
40764
|
-
dart: "tree-sitter-dart.wasm"
|
|
40774
|
+
dart: "tree-sitter-dart.wasm",
|
|
40775
|
+
powershell: "tree-sitter-powershell.wasm",
|
|
40776
|
+
ini: "tree-sitter-ini.wasm",
|
|
40777
|
+
regex: "tree-sitter-regex.wasm"
|
|
40765
40778
|
};
|
|
40766
40779
|
});
|
|
40767
40780
|
|
|
40768
40781
|
// src/index.ts
|
|
40769
|
-
import * as
|
|
40782
|
+
import * as path63 from "path";
|
|
40770
40783
|
|
|
40771
40784
|
// src/agents/index.ts
|
|
40772
40785
|
init_config();
|
|
@@ -46949,6 +46962,7 @@ init_manager2();
|
|
|
46949
46962
|
import { execSync } from "child_process";
|
|
46950
46963
|
import { existsSync as existsSync8, readdirSync as readdirSync2, readFileSync as readFileSync5, statSync as statSync5 } from "fs";
|
|
46951
46964
|
import path18 from "path";
|
|
46965
|
+
import { fileURLToPath } from "url";
|
|
46952
46966
|
function validateTaskDag(plan) {
|
|
46953
46967
|
const allTaskIds = new Set;
|
|
46954
46968
|
for (const phase of plan.phases) {
|
|
@@ -47270,25 +47284,31 @@ async function checkGrammarWasmFiles() {
|
|
|
47270
47284
|
const grammarFiles = [
|
|
47271
47285
|
"tree-sitter-javascript.wasm",
|
|
47272
47286
|
"tree-sitter-typescript.wasm",
|
|
47287
|
+
"tree-sitter-tsx.wasm",
|
|
47273
47288
|
"tree-sitter-python.wasm",
|
|
47274
47289
|
"tree-sitter-go.wasm",
|
|
47275
47290
|
"tree-sitter-rust.wasm",
|
|
47276
47291
|
"tree-sitter-cpp.wasm",
|
|
47277
47292
|
"tree-sitter-c-sharp.wasm",
|
|
47278
47293
|
"tree-sitter-css.wasm",
|
|
47279
|
-
"tree-sitter-html.wasm",
|
|
47280
|
-
"tree-sitter-json.wasm",
|
|
47281
47294
|
"tree-sitter-bash.wasm",
|
|
47282
47295
|
"tree-sitter-ruby.wasm",
|
|
47283
47296
|
"tree-sitter-php.wasm",
|
|
47284
47297
|
"tree-sitter-java.wasm",
|
|
47285
47298
|
"tree-sitter-kotlin.wasm",
|
|
47286
47299
|
"tree-sitter-swift.wasm",
|
|
47287
|
-
"tree-sitter-dart.wasm"
|
|
47300
|
+
"tree-sitter-dart.wasm",
|
|
47301
|
+
"tree-sitter-powershell.wasm",
|
|
47302
|
+
"tree-sitter-ini.wasm",
|
|
47303
|
+
"tree-sitter-regex.wasm"
|
|
47288
47304
|
];
|
|
47289
|
-
const
|
|
47290
|
-
const
|
|
47305
|
+
const thisDir = path18.dirname(fileURLToPath(import.meta.url));
|
|
47306
|
+
const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/services");
|
|
47307
|
+
const grammarDir = isSource ? path18.join(thisDir, "..", "lang", "grammars") : path18.join(thisDir, "lang", "grammars");
|
|
47291
47308
|
const missing = [];
|
|
47309
|
+
if (!existsSync8(path18.join(grammarDir, "tree-sitter.wasm"))) {
|
|
47310
|
+
missing.push("tree-sitter.wasm (core runtime)");
|
|
47311
|
+
}
|
|
47292
47312
|
for (const file3 of grammarFiles) {
|
|
47293
47313
|
if (!existsSync8(path18.join(grammarDir, file3))) {
|
|
47294
47314
|
missing.push(file3);
|
|
@@ -47298,13 +47318,13 @@ async function checkGrammarWasmFiles() {
|
|
|
47298
47318
|
return {
|
|
47299
47319
|
name: "Grammar WASM Files",
|
|
47300
47320
|
status: "\u2705",
|
|
47301
|
-
detail:
|
|
47321
|
+
detail: `Core runtime + all ${grammarFiles.length} grammar WASM files present`
|
|
47302
47322
|
};
|
|
47303
47323
|
}
|
|
47304
47324
|
return {
|
|
47305
47325
|
name: "Grammar WASM Files",
|
|
47306
47326
|
status: "\u274C",
|
|
47307
|
-
detail: `${missing.length}
|
|
47327
|
+
detail: `${missing.length} WASM file(s) missing: ${missing.join(", ")}`
|
|
47308
47328
|
};
|
|
47309
47329
|
}
|
|
47310
47330
|
async function checkCheckpointManifest(directory) {
|
|
@@ -59021,20 +59041,20 @@ function validateBase(base) {
|
|
|
59021
59041
|
function validatePaths(paths) {
|
|
59022
59042
|
if (!paths)
|
|
59023
59043
|
return null;
|
|
59024
|
-
for (const
|
|
59025
|
-
if (!
|
|
59044
|
+
for (const path48 of paths) {
|
|
59045
|
+
if (!path48 || path48.length === 0) {
|
|
59026
59046
|
return "empty path not allowed";
|
|
59027
59047
|
}
|
|
59028
|
-
if (
|
|
59048
|
+
if (path48.length > MAX_PATH_LENGTH) {
|
|
59029
59049
|
return `path exceeds maximum length of ${MAX_PATH_LENGTH}`;
|
|
59030
59050
|
}
|
|
59031
|
-
if (SHELL_METACHARACTERS2.test(
|
|
59051
|
+
if (SHELL_METACHARACTERS2.test(path48)) {
|
|
59032
59052
|
return "path contains shell metacharacters";
|
|
59033
59053
|
}
|
|
59034
|
-
if (
|
|
59054
|
+
if (path48.startsWith("-")) {
|
|
59035
59055
|
return 'path cannot start with "-" (option-like arguments not allowed)';
|
|
59036
59056
|
}
|
|
59037
|
-
if (CONTROL_CHAR_PATTERN2.test(
|
|
59057
|
+
if (CONTROL_CHAR_PATTERN2.test(path48)) {
|
|
59038
59058
|
return "path contains control characters";
|
|
59039
59059
|
}
|
|
59040
59060
|
}
|
|
@@ -59115,8 +59135,8 @@ var diff = createSwarmTool({
|
|
|
59115
59135
|
if (parts2.length >= 3) {
|
|
59116
59136
|
const additions = parseInt(parts2[0], 10) || 0;
|
|
59117
59137
|
const deletions = parseInt(parts2[1], 10) || 0;
|
|
59118
|
-
const
|
|
59119
|
-
files.push({ path:
|
|
59138
|
+
const path48 = parts2[2];
|
|
59139
|
+
files.push({ path: path48, additions, deletions });
|
|
59120
59140
|
}
|
|
59121
59141
|
}
|
|
59122
59142
|
const contractChanges = [];
|
|
@@ -59399,7 +59419,7 @@ Use these as DOMAIN values when delegating to @sme.`;
|
|
|
59399
59419
|
init_dist();
|
|
59400
59420
|
init_create_tool();
|
|
59401
59421
|
import * as fs36 from "fs";
|
|
59402
|
-
import * as
|
|
59422
|
+
import * as path48 from "path";
|
|
59403
59423
|
var MAX_FILE_SIZE_BYTES4 = 1024 * 1024;
|
|
59404
59424
|
var MAX_EVIDENCE_FILES = 1000;
|
|
59405
59425
|
var EVIDENCE_DIR2 = ".swarm/evidence";
|
|
@@ -59426,9 +59446,9 @@ function validateRequiredTypes(input) {
|
|
|
59426
59446
|
return null;
|
|
59427
59447
|
}
|
|
59428
59448
|
function isPathWithinSwarm2(filePath, cwd) {
|
|
59429
|
-
const normalizedCwd =
|
|
59430
|
-
const swarmPath =
|
|
59431
|
-
const normalizedPath =
|
|
59449
|
+
const normalizedCwd = path48.resolve(cwd);
|
|
59450
|
+
const swarmPath = path48.join(normalizedCwd, ".swarm");
|
|
59451
|
+
const normalizedPath = path48.resolve(filePath);
|
|
59432
59452
|
return normalizedPath.startsWith(swarmPath);
|
|
59433
59453
|
}
|
|
59434
59454
|
function parseCompletedTasks(planContent) {
|
|
@@ -59458,10 +59478,10 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
59458
59478
|
if (!VALID_EVIDENCE_FILENAME_REGEX.test(filename)) {
|
|
59459
59479
|
continue;
|
|
59460
59480
|
}
|
|
59461
|
-
const filePath =
|
|
59481
|
+
const filePath = path48.join(evidenceDir, filename);
|
|
59462
59482
|
try {
|
|
59463
|
-
const resolvedPath =
|
|
59464
|
-
const evidenceDirResolved =
|
|
59483
|
+
const resolvedPath = path48.resolve(filePath);
|
|
59484
|
+
const evidenceDirResolved = path48.resolve(evidenceDir);
|
|
59465
59485
|
if (!resolvedPath.startsWith(evidenceDirResolved)) {
|
|
59466
59486
|
continue;
|
|
59467
59487
|
}
|
|
@@ -59579,7 +59599,7 @@ var evidence_check = createSwarmTool({
|
|
|
59579
59599
|
return JSON.stringify(errorResult, null, 2);
|
|
59580
59600
|
}
|
|
59581
59601
|
const requiredTypes = requiredTypesValue.split(",").map((t) => t.trim()).filter((t) => t.length > 0).map(normalizeEvidenceType);
|
|
59582
|
-
const planPath =
|
|
59602
|
+
const planPath = path48.join(cwd, PLAN_FILE);
|
|
59583
59603
|
if (!isPathWithinSwarm2(planPath, cwd)) {
|
|
59584
59604
|
const errorResult = {
|
|
59585
59605
|
error: "plan file path validation failed",
|
|
@@ -59611,7 +59631,7 @@ var evidence_check = createSwarmTool({
|
|
|
59611
59631
|
};
|
|
59612
59632
|
return JSON.stringify(result2, null, 2);
|
|
59613
59633
|
}
|
|
59614
|
-
const evidenceDir =
|
|
59634
|
+
const evidenceDir = path48.join(cwd, EVIDENCE_DIR2);
|
|
59615
59635
|
const evidence = readEvidenceFiles(evidenceDir, cwd);
|
|
59616
59636
|
const { tasksWithFullEvidence, gaps } = analyzeGaps(completedTasks, evidence, requiredTypes);
|
|
59617
59637
|
const completeness = completedTasks.length > 0 ? Math.round(tasksWithFullEvidence.length / completedTasks.length * 100) / 100 : 1;
|
|
@@ -59629,7 +59649,7 @@ var evidence_check = createSwarmTool({
|
|
|
59629
59649
|
init_tool();
|
|
59630
59650
|
init_create_tool();
|
|
59631
59651
|
import * as fs37 from "fs";
|
|
59632
|
-
import * as
|
|
59652
|
+
import * as path49 from "path";
|
|
59633
59653
|
var EXT_MAP = {
|
|
59634
59654
|
python: ".py",
|
|
59635
59655
|
py: ".py",
|
|
@@ -59710,12 +59730,12 @@ var extract_code_blocks = createSwarmTool({
|
|
|
59710
59730
|
if (prefix) {
|
|
59711
59731
|
filename = `${prefix}_${filename}`;
|
|
59712
59732
|
}
|
|
59713
|
-
let filepath =
|
|
59714
|
-
const base =
|
|
59715
|
-
const ext =
|
|
59733
|
+
let filepath = path49.join(targetDir, filename);
|
|
59734
|
+
const base = path49.basename(filepath, path49.extname(filepath));
|
|
59735
|
+
const ext = path49.extname(filepath);
|
|
59716
59736
|
let counter = 1;
|
|
59717
59737
|
while (fs37.existsSync(filepath)) {
|
|
59718
|
-
filepath =
|
|
59738
|
+
filepath = path49.join(targetDir, `${base}_${counter}${ext}`);
|
|
59719
59739
|
counter++;
|
|
59720
59740
|
}
|
|
59721
59741
|
try {
|
|
@@ -59836,7 +59856,7 @@ var gitingest = createSwarmTool({
|
|
|
59836
59856
|
init_dist();
|
|
59837
59857
|
init_create_tool();
|
|
59838
59858
|
import * as fs38 from "fs";
|
|
59839
|
-
import * as
|
|
59859
|
+
import * as path50 from "path";
|
|
59840
59860
|
var MAX_FILE_PATH_LENGTH2 = 500;
|
|
59841
59861
|
var MAX_SYMBOL_LENGTH = 256;
|
|
59842
59862
|
var MAX_FILE_SIZE_BYTES5 = 1024 * 1024;
|
|
@@ -59884,7 +59904,7 @@ function validateSymbolInput(symbol3) {
|
|
|
59884
59904
|
return null;
|
|
59885
59905
|
}
|
|
59886
59906
|
function isBinaryFile2(filePath, buffer) {
|
|
59887
|
-
const ext =
|
|
59907
|
+
const ext = path50.extname(filePath).toLowerCase();
|
|
59888
59908
|
if (ext === ".json" || ext === ".md" || ext === ".txt") {
|
|
59889
59909
|
return false;
|
|
59890
59910
|
}
|
|
@@ -59908,15 +59928,15 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
59908
59928
|
const imports = [];
|
|
59909
59929
|
let _resolvedTarget;
|
|
59910
59930
|
try {
|
|
59911
|
-
_resolvedTarget =
|
|
59931
|
+
_resolvedTarget = path50.resolve(targetFile);
|
|
59912
59932
|
} catch {
|
|
59913
59933
|
_resolvedTarget = targetFile;
|
|
59914
59934
|
}
|
|
59915
|
-
const targetBasename =
|
|
59935
|
+
const targetBasename = path50.basename(targetFile, path50.extname(targetFile));
|
|
59916
59936
|
const targetWithExt = targetFile;
|
|
59917
59937
|
const targetWithoutExt = targetFile.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
59918
|
-
const normalizedTargetWithExt =
|
|
59919
|
-
const normalizedTargetWithoutExt =
|
|
59938
|
+
const normalizedTargetWithExt = path50.normalize(targetWithExt).replace(/\\/g, "/");
|
|
59939
|
+
const normalizedTargetWithoutExt = path50.normalize(targetWithoutExt).replace(/\\/g, "/");
|
|
59920
59940
|
const importRegex = /import\s+(?:\{[\s\S]*?\}|(?:\*\s+as\s+\w+)|\w+)\s+from\s+['"`]([^'"`]+)['"`]|import\s+['"`]([^'"`]+)['"`]|require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
59921
59941
|
for (let match = importRegex.exec(content);match !== null; match = importRegex.exec(content)) {
|
|
59922
59942
|
const modulePath = match[1] || match[2] || match[3];
|
|
@@ -59939,9 +59959,9 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
59939
59959
|
}
|
|
59940
59960
|
const _normalizedModule = modulePath.replace(/^\.\//, "").replace(/^\.\.\\/, "../");
|
|
59941
59961
|
let isMatch = false;
|
|
59942
|
-
const _targetDir =
|
|
59943
|
-
const targetExt =
|
|
59944
|
-
const targetBasenameNoExt =
|
|
59962
|
+
const _targetDir = path50.dirname(targetFile);
|
|
59963
|
+
const targetExt = path50.extname(targetFile);
|
|
59964
|
+
const targetBasenameNoExt = path50.basename(targetFile, targetExt);
|
|
59945
59965
|
const moduleNormalized = modulePath.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
59946
59966
|
const moduleName = modulePath.split(/[/\\]/).pop() || "";
|
|
59947
59967
|
const moduleNameNoExt = moduleName.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
@@ -60009,10 +60029,10 @@ function findSourceFiles(dir, files = [], stats = { skippedDirs: [], skippedFile
|
|
|
60009
60029
|
entries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
60010
60030
|
for (const entry of entries) {
|
|
60011
60031
|
if (SKIP_DIRECTORIES3.has(entry)) {
|
|
60012
|
-
stats.skippedDirs.push(
|
|
60032
|
+
stats.skippedDirs.push(path50.join(dir, entry));
|
|
60013
60033
|
continue;
|
|
60014
60034
|
}
|
|
60015
|
-
const fullPath =
|
|
60035
|
+
const fullPath = path50.join(dir, entry);
|
|
60016
60036
|
let stat2;
|
|
60017
60037
|
try {
|
|
60018
60038
|
stat2 = fs38.statSync(fullPath);
|
|
@@ -60026,7 +60046,7 @@ function findSourceFiles(dir, files = [], stats = { skippedDirs: [], skippedFile
|
|
|
60026
60046
|
if (stat2.isDirectory()) {
|
|
60027
60047
|
findSourceFiles(fullPath, files, stats);
|
|
60028
60048
|
} else if (stat2.isFile()) {
|
|
60029
|
-
const ext =
|
|
60049
|
+
const ext = path50.extname(fullPath).toLowerCase();
|
|
60030
60050
|
if (SUPPORTED_EXTENSIONS.includes(ext)) {
|
|
60031
60051
|
files.push(fullPath);
|
|
60032
60052
|
}
|
|
@@ -60083,7 +60103,7 @@ var imports = createSwarmTool({
|
|
|
60083
60103
|
return JSON.stringify(errorResult, null, 2);
|
|
60084
60104
|
}
|
|
60085
60105
|
try {
|
|
60086
|
-
const targetFile =
|
|
60106
|
+
const targetFile = path50.resolve(file3);
|
|
60087
60107
|
if (!fs38.existsSync(targetFile)) {
|
|
60088
60108
|
const errorResult = {
|
|
60089
60109
|
error: `target file not found: ${file3}`,
|
|
@@ -60105,7 +60125,7 @@ var imports = createSwarmTool({
|
|
|
60105
60125
|
};
|
|
60106
60126
|
return JSON.stringify(errorResult, null, 2);
|
|
60107
60127
|
}
|
|
60108
|
-
const baseDir =
|
|
60128
|
+
const baseDir = path50.dirname(targetFile);
|
|
60109
60129
|
const scanStats = {
|
|
60110
60130
|
skippedDirs: [],
|
|
60111
60131
|
skippedFiles: 0,
|
|
@@ -60715,7 +60735,7 @@ init_config();
|
|
|
60715
60735
|
init_schema();
|
|
60716
60736
|
init_manager();
|
|
60717
60737
|
import * as fs39 from "fs";
|
|
60718
|
-
import * as
|
|
60738
|
+
import * as path51 from "path";
|
|
60719
60739
|
init_utils2();
|
|
60720
60740
|
init_telemetry();
|
|
60721
60741
|
init_create_tool();
|
|
@@ -60935,7 +60955,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
60935
60955
|
safeWarn(`[phase_complete] Completion verify error (non-blocking):`, completionError);
|
|
60936
60956
|
}
|
|
60937
60957
|
try {
|
|
60938
|
-
const driftEvidencePath =
|
|
60958
|
+
const driftEvidencePath = path51.join(dir, ".swarm", "evidence", String(phase), "drift-verifier.json");
|
|
60939
60959
|
let driftVerdictFound = false;
|
|
60940
60960
|
let driftVerdictApproved = false;
|
|
60941
60961
|
try {
|
|
@@ -60969,7 +60989,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
60969
60989
|
driftVerdictFound = false;
|
|
60970
60990
|
}
|
|
60971
60991
|
if (!driftVerdictFound) {
|
|
60972
|
-
const specPath =
|
|
60992
|
+
const specPath = path51.join(dir, ".swarm", "spec.md");
|
|
60973
60993
|
const specExists = fs39.existsSync(specPath);
|
|
60974
60994
|
if (!specExists) {
|
|
60975
60995
|
let incompleteTaskCount = 0;
|
|
@@ -61043,7 +61063,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
61043
61063
|
};
|
|
61044
61064
|
if (retroFound && retroEntry?.lessons_learned && retroEntry.lessons_learned.length > 0) {
|
|
61045
61065
|
try {
|
|
61046
|
-
const projectName =
|
|
61066
|
+
const projectName = path51.basename(dir);
|
|
61047
61067
|
const curationResult = await curateAndStoreSwarm(retroEntry.lessons_learned, projectName, { phase_number: phase }, dir, knowledgeConfig);
|
|
61048
61068
|
if (curationResult) {
|
|
61049
61069
|
const sessionState = swarmState.agentSessions.get(sessionID);
|
|
@@ -61253,7 +61273,7 @@ init_discovery();
|
|
|
61253
61273
|
init_utils();
|
|
61254
61274
|
init_create_tool();
|
|
61255
61275
|
import * as fs40 from "fs";
|
|
61256
|
-
import * as
|
|
61276
|
+
import * as path52 from "path";
|
|
61257
61277
|
var MAX_OUTPUT_BYTES5 = 52428800;
|
|
61258
61278
|
var AUDIT_TIMEOUT_MS = 120000;
|
|
61259
61279
|
function isValidEcosystem(value) {
|
|
@@ -61271,16 +61291,16 @@ function validateArgs3(args2) {
|
|
|
61271
61291
|
function detectEcosystems(directory) {
|
|
61272
61292
|
const ecosystems = [];
|
|
61273
61293
|
const cwd = directory;
|
|
61274
|
-
if (fs40.existsSync(
|
|
61294
|
+
if (fs40.existsSync(path52.join(cwd, "package.json"))) {
|
|
61275
61295
|
ecosystems.push("npm");
|
|
61276
61296
|
}
|
|
61277
|
-
if (fs40.existsSync(
|
|
61297
|
+
if (fs40.existsSync(path52.join(cwd, "pyproject.toml")) || fs40.existsSync(path52.join(cwd, "requirements.txt"))) {
|
|
61278
61298
|
ecosystems.push("pip");
|
|
61279
61299
|
}
|
|
61280
|
-
if (fs40.existsSync(
|
|
61300
|
+
if (fs40.existsSync(path52.join(cwd, "Cargo.toml"))) {
|
|
61281
61301
|
ecosystems.push("cargo");
|
|
61282
61302
|
}
|
|
61283
|
-
if (fs40.existsSync(
|
|
61303
|
+
if (fs40.existsSync(path52.join(cwd, "go.mod"))) {
|
|
61284
61304
|
ecosystems.push("go");
|
|
61285
61305
|
}
|
|
61286
61306
|
try {
|
|
@@ -61289,10 +61309,10 @@ function detectEcosystems(directory) {
|
|
|
61289
61309
|
ecosystems.push("dotnet");
|
|
61290
61310
|
}
|
|
61291
61311
|
} catch {}
|
|
61292
|
-
if (fs40.existsSync(
|
|
61312
|
+
if (fs40.existsSync(path52.join(cwd, "Gemfile")) || fs40.existsSync(path52.join(cwd, "Gemfile.lock"))) {
|
|
61293
61313
|
ecosystems.push("ruby");
|
|
61294
61314
|
}
|
|
61295
|
-
if (fs40.existsSync(
|
|
61315
|
+
if (fs40.existsSync(path52.join(cwd, "pubspec.yaml"))) {
|
|
61296
61316
|
ecosystems.push("dart");
|
|
61297
61317
|
}
|
|
61298
61318
|
return ecosystems;
|
|
@@ -62314,7 +62334,7 @@ var SUPPORTED_PARSER_EXTENSIONS = new Set([
|
|
|
62314
62334
|
// src/tools/pre-check-batch.ts
|
|
62315
62335
|
init_dist();
|
|
62316
62336
|
import * as fs42 from "fs";
|
|
62317
|
-
import * as
|
|
62337
|
+
import * as path54 from "path";
|
|
62318
62338
|
|
|
62319
62339
|
// node_modules/yocto-queue/index.js
|
|
62320
62340
|
class Node2 {
|
|
@@ -62589,7 +62609,7 @@ init_dist();
|
|
|
62589
62609
|
init_manager();
|
|
62590
62610
|
init_detector();
|
|
62591
62611
|
import * as fs41 from "fs";
|
|
62592
|
-
import * as
|
|
62612
|
+
import * as path53 from "path";
|
|
62593
62613
|
import { extname as extname10 } from "path";
|
|
62594
62614
|
|
|
62595
62615
|
// src/sast/rules/c.ts
|
|
@@ -63555,7 +63575,7 @@ async function sastScan(input, directory, config3) {
|
|
|
63555
63575
|
_filesSkipped++;
|
|
63556
63576
|
continue;
|
|
63557
63577
|
}
|
|
63558
|
-
const resolvedPath =
|
|
63578
|
+
const resolvedPath = path53.isAbsolute(filePath) ? filePath : path53.resolve(directory, filePath);
|
|
63559
63579
|
if (!fs41.existsSync(resolvedPath)) {
|
|
63560
63580
|
_filesSkipped++;
|
|
63561
63581
|
continue;
|
|
@@ -63754,18 +63774,18 @@ function validatePath(inputPath, baseDir, workspaceDir) {
|
|
|
63754
63774
|
let resolved;
|
|
63755
63775
|
const isWinAbs = isWindowsAbsolutePath(inputPath);
|
|
63756
63776
|
if (isWinAbs) {
|
|
63757
|
-
resolved =
|
|
63758
|
-
} else if (
|
|
63759
|
-
resolved =
|
|
63777
|
+
resolved = path54.win32.resolve(inputPath);
|
|
63778
|
+
} else if (path54.isAbsolute(inputPath)) {
|
|
63779
|
+
resolved = path54.resolve(inputPath);
|
|
63760
63780
|
} else {
|
|
63761
|
-
resolved =
|
|
63781
|
+
resolved = path54.resolve(baseDir, inputPath);
|
|
63762
63782
|
}
|
|
63763
|
-
const workspaceResolved =
|
|
63783
|
+
const workspaceResolved = path54.resolve(workspaceDir);
|
|
63764
63784
|
let relative6;
|
|
63765
63785
|
if (isWinAbs) {
|
|
63766
|
-
relative6 =
|
|
63786
|
+
relative6 = path54.win32.relative(workspaceResolved, resolved);
|
|
63767
63787
|
} else {
|
|
63768
|
-
relative6 =
|
|
63788
|
+
relative6 = path54.relative(workspaceResolved, resolved);
|
|
63769
63789
|
}
|
|
63770
63790
|
if (relative6.startsWith("..")) {
|
|
63771
63791
|
return "path traversal detected";
|
|
@@ -63826,13 +63846,13 @@ async function runLintWrapped(files, directory, _config) {
|
|
|
63826
63846
|
}
|
|
63827
63847
|
async function runLintOnFiles(linter, files, workspaceDir) {
|
|
63828
63848
|
const isWindows = process.platform === "win32";
|
|
63829
|
-
const binDir =
|
|
63849
|
+
const binDir = path54.join(workspaceDir, "node_modules", ".bin");
|
|
63830
63850
|
const validatedFiles = [];
|
|
63831
63851
|
for (const file3 of files) {
|
|
63832
63852
|
if (typeof file3 !== "string") {
|
|
63833
63853
|
continue;
|
|
63834
63854
|
}
|
|
63835
|
-
const resolvedPath =
|
|
63855
|
+
const resolvedPath = path54.resolve(file3);
|
|
63836
63856
|
const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
|
|
63837
63857
|
if (validationError) {
|
|
63838
63858
|
continue;
|
|
@@ -63850,10 +63870,10 @@ async function runLintOnFiles(linter, files, workspaceDir) {
|
|
|
63850
63870
|
}
|
|
63851
63871
|
let command;
|
|
63852
63872
|
if (linter === "biome") {
|
|
63853
|
-
const biomeBin = isWindows ?
|
|
63873
|
+
const biomeBin = isWindows ? path54.join(binDir, "biome.EXE") : path54.join(binDir, "biome");
|
|
63854
63874
|
command = [biomeBin, "check", ...validatedFiles];
|
|
63855
63875
|
} else {
|
|
63856
|
-
const eslintBin = isWindows ?
|
|
63876
|
+
const eslintBin = isWindows ? path54.join(binDir, "eslint.cmd") : path54.join(binDir, "eslint");
|
|
63857
63877
|
command = [eslintBin, ...validatedFiles];
|
|
63858
63878
|
}
|
|
63859
63879
|
try {
|
|
@@ -63990,7 +64010,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
63990
64010
|
skippedFiles++;
|
|
63991
64011
|
continue;
|
|
63992
64012
|
}
|
|
63993
|
-
const resolvedPath =
|
|
64013
|
+
const resolvedPath = path54.resolve(file3);
|
|
63994
64014
|
const validationError = validatePath(resolvedPath, directory, directory);
|
|
63995
64015
|
if (validationError) {
|
|
63996
64016
|
skippedFiles++;
|
|
@@ -64008,7 +64028,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
64008
64028
|
};
|
|
64009
64029
|
}
|
|
64010
64030
|
for (const file3 of validatedFiles) {
|
|
64011
|
-
const ext =
|
|
64031
|
+
const ext = path54.extname(file3).toLowerCase();
|
|
64012
64032
|
if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
|
|
64013
64033
|
skippedFiles++;
|
|
64014
64034
|
continue;
|
|
@@ -64209,7 +64229,7 @@ function classifySastFindings(findings, changedLineRanges, directory) {
|
|
|
64209
64229
|
const preexistingFindings = [];
|
|
64210
64230
|
for (const finding of findings) {
|
|
64211
64231
|
const filePath = finding.location.file;
|
|
64212
|
-
const normalised =
|
|
64232
|
+
const normalised = path54.relative(directory, filePath).replace(/\\/g, "/");
|
|
64213
64233
|
const changedLines = changedLineRanges.get(normalised);
|
|
64214
64234
|
if (changedLines && changedLines.has(finding.location.line)) {
|
|
64215
64235
|
newFindings.push(finding);
|
|
@@ -64260,7 +64280,7 @@ async function runPreCheckBatch(input, workspaceDir, contextDir) {
|
|
|
64260
64280
|
warn(`pre_check_batch: Invalid file path: ${file3}`);
|
|
64261
64281
|
continue;
|
|
64262
64282
|
}
|
|
64263
|
-
changedFiles.push(
|
|
64283
|
+
changedFiles.push(path54.resolve(directory, file3));
|
|
64264
64284
|
}
|
|
64265
64285
|
if (changedFiles.length === 0) {
|
|
64266
64286
|
warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
|
|
@@ -64448,7 +64468,7 @@ var pre_check_batch = createSwarmTool({
|
|
|
64448
64468
|
};
|
|
64449
64469
|
return JSON.stringify(errorResult, null, 2);
|
|
64450
64470
|
}
|
|
64451
|
-
const resolvedDirectory =
|
|
64471
|
+
const resolvedDirectory = path54.resolve(typedArgs.directory);
|
|
64452
64472
|
const workspaceAnchor = resolvedDirectory;
|
|
64453
64473
|
const dirError = validateDirectory2(resolvedDirectory, workspaceAnchor);
|
|
64454
64474
|
if (dirError) {
|
|
@@ -64555,24 +64575,24 @@ ${paginatedContent}`;
|
|
|
64555
64575
|
// src/tools/save-plan.ts
|
|
64556
64576
|
init_tool();
|
|
64557
64577
|
import * as fs44 from "fs";
|
|
64558
|
-
import * as
|
|
64578
|
+
import * as path56 from "path";
|
|
64559
64579
|
|
|
64560
64580
|
// src/parallel/file-locks.ts
|
|
64561
64581
|
import * as fs43 from "fs";
|
|
64562
|
-
import * as
|
|
64582
|
+
import * as path55 from "path";
|
|
64563
64583
|
var LOCKS_DIR = ".swarm/locks";
|
|
64564
64584
|
var LOCK_TIMEOUT_MS = 5 * 60 * 1000;
|
|
64565
64585
|
function getLockFilePath(directory, filePath) {
|
|
64566
|
-
const normalized =
|
|
64567
|
-
if (!normalized.startsWith(
|
|
64586
|
+
const normalized = path55.resolve(directory, filePath);
|
|
64587
|
+
if (!normalized.startsWith(path55.resolve(directory))) {
|
|
64568
64588
|
throw new Error("Invalid file path: path traversal not allowed");
|
|
64569
64589
|
}
|
|
64570
64590
|
const hash3 = Buffer.from(normalized).toString("base64").replace(/[/+=]/g, "_");
|
|
64571
|
-
return
|
|
64591
|
+
return path55.join(directory, LOCKS_DIR, `${hash3}.lock`);
|
|
64572
64592
|
}
|
|
64573
64593
|
function tryAcquireLock(directory, filePath, agent, taskId) {
|
|
64574
64594
|
const lockPath = getLockFilePath(directory, filePath);
|
|
64575
|
-
const locksDir =
|
|
64595
|
+
const locksDir = path55.dirname(lockPath);
|
|
64576
64596
|
if (!fs43.existsSync(locksDir)) {
|
|
64577
64597
|
fs43.mkdirSync(locksDir, { recursive: true });
|
|
64578
64598
|
}
|
|
@@ -64738,7 +64758,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
64738
64758
|
try {
|
|
64739
64759
|
await savePlan(dir, plan);
|
|
64740
64760
|
try {
|
|
64741
|
-
const markerPath =
|
|
64761
|
+
const markerPath = path56.join(dir, ".swarm", ".plan-write-marker");
|
|
64742
64762
|
const marker = JSON.stringify({
|
|
64743
64763
|
source: "save_plan",
|
|
64744
64764
|
timestamp: new Date().toISOString(),
|
|
@@ -64761,7 +64781,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
64761
64781
|
return {
|
|
64762
64782
|
success: true,
|
|
64763
64783
|
message: "Plan saved successfully",
|
|
64764
|
-
plan_path:
|
|
64784
|
+
plan_path: path56.join(dir, ".swarm", "plan.json"),
|
|
64765
64785
|
phases_count: plan.phases.length,
|
|
64766
64786
|
tasks_count: tasksCount,
|
|
64767
64787
|
...warnings.length > 0 ? { warnings } : {}
|
|
@@ -64804,7 +64824,7 @@ var save_plan = createSwarmTool({
|
|
|
64804
64824
|
init_dist();
|
|
64805
64825
|
init_manager();
|
|
64806
64826
|
import * as fs45 from "fs";
|
|
64807
|
-
import * as
|
|
64827
|
+
import * as path57 from "path";
|
|
64808
64828
|
|
|
64809
64829
|
// src/sbom/detectors/index.ts
|
|
64810
64830
|
init_utils();
|
|
@@ -65654,7 +65674,7 @@ function findManifestFiles(rootDir) {
|
|
|
65654
65674
|
try {
|
|
65655
65675
|
const entries = fs45.readdirSync(dir, { withFileTypes: true });
|
|
65656
65676
|
for (const entry of entries) {
|
|
65657
|
-
const fullPath =
|
|
65677
|
+
const fullPath = path57.join(dir, entry.name);
|
|
65658
65678
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
|
|
65659
65679
|
continue;
|
|
65660
65680
|
}
|
|
@@ -65663,7 +65683,7 @@ function findManifestFiles(rootDir) {
|
|
|
65663
65683
|
} else if (entry.isFile()) {
|
|
65664
65684
|
for (const pattern of patterns) {
|
|
65665
65685
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
65666
|
-
manifestFiles.push(
|
|
65686
|
+
manifestFiles.push(path57.relative(rootDir, fullPath));
|
|
65667
65687
|
break;
|
|
65668
65688
|
}
|
|
65669
65689
|
}
|
|
@@ -65681,11 +65701,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
65681
65701
|
try {
|
|
65682
65702
|
const entries = fs45.readdirSync(dir, { withFileTypes: true });
|
|
65683
65703
|
for (const entry of entries) {
|
|
65684
|
-
const fullPath =
|
|
65704
|
+
const fullPath = path57.join(dir, entry.name);
|
|
65685
65705
|
if (entry.isFile()) {
|
|
65686
65706
|
for (const pattern of patterns) {
|
|
65687
65707
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
65688
|
-
found.push(
|
|
65708
|
+
found.push(path57.relative(workingDir, fullPath));
|
|
65689
65709
|
break;
|
|
65690
65710
|
}
|
|
65691
65711
|
}
|
|
@@ -65698,11 +65718,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
65698
65718
|
function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
|
|
65699
65719
|
const dirs = new Set;
|
|
65700
65720
|
for (const file3 of changedFiles) {
|
|
65701
|
-
let currentDir =
|
|
65721
|
+
let currentDir = path57.dirname(file3);
|
|
65702
65722
|
while (true) {
|
|
65703
|
-
if (currentDir && currentDir !== "." && currentDir !==
|
|
65704
|
-
dirs.add(
|
|
65705
|
-
const parent =
|
|
65723
|
+
if (currentDir && currentDir !== "." && currentDir !== path57.sep) {
|
|
65724
|
+
dirs.add(path57.join(workingDir, currentDir));
|
|
65725
|
+
const parent = path57.dirname(currentDir);
|
|
65706
65726
|
if (parent === currentDir)
|
|
65707
65727
|
break;
|
|
65708
65728
|
currentDir = parent;
|
|
@@ -65786,7 +65806,7 @@ var sbom_generate = createSwarmTool({
|
|
|
65786
65806
|
const changedFiles = obj.changed_files;
|
|
65787
65807
|
const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
|
|
65788
65808
|
const workingDir = directory;
|
|
65789
|
-
const outputDir =
|
|
65809
|
+
const outputDir = path57.isAbsolute(relativeOutputDir) ? relativeOutputDir : path57.join(workingDir, relativeOutputDir);
|
|
65790
65810
|
let manifestFiles = [];
|
|
65791
65811
|
if (scope === "all") {
|
|
65792
65812
|
manifestFiles = findManifestFiles(workingDir);
|
|
@@ -65809,7 +65829,7 @@ var sbom_generate = createSwarmTool({
|
|
|
65809
65829
|
const processedFiles = [];
|
|
65810
65830
|
for (const manifestFile of manifestFiles) {
|
|
65811
65831
|
try {
|
|
65812
|
-
const fullPath =
|
|
65832
|
+
const fullPath = path57.isAbsolute(manifestFile) ? manifestFile : path57.join(workingDir, manifestFile);
|
|
65813
65833
|
if (!fs45.existsSync(fullPath)) {
|
|
65814
65834
|
continue;
|
|
65815
65835
|
}
|
|
@@ -65826,7 +65846,7 @@ var sbom_generate = createSwarmTool({
|
|
|
65826
65846
|
const bom = generateCycloneDX(allComponents);
|
|
65827
65847
|
const bomJson = serializeCycloneDX(bom);
|
|
65828
65848
|
const filename = generateSbomFilename();
|
|
65829
|
-
const outputPath =
|
|
65849
|
+
const outputPath = path57.join(outputDir, filename);
|
|
65830
65850
|
fs45.writeFileSync(outputPath, bomJson, "utf-8");
|
|
65831
65851
|
const verdict = processedFiles.length > 0 ? "pass" : "pass";
|
|
65832
65852
|
try {
|
|
@@ -65870,7 +65890,7 @@ var sbom_generate = createSwarmTool({
|
|
|
65870
65890
|
init_dist();
|
|
65871
65891
|
init_create_tool();
|
|
65872
65892
|
import * as fs46 from "fs";
|
|
65873
|
-
import * as
|
|
65893
|
+
import * as path58 from "path";
|
|
65874
65894
|
var SPEC_CANDIDATES = [
|
|
65875
65895
|
"openapi.json",
|
|
65876
65896
|
"openapi.yaml",
|
|
@@ -65902,12 +65922,12 @@ function normalizePath2(p) {
|
|
|
65902
65922
|
}
|
|
65903
65923
|
function discoverSpecFile(cwd, specFileArg) {
|
|
65904
65924
|
if (specFileArg) {
|
|
65905
|
-
const resolvedPath =
|
|
65906
|
-
const normalizedCwd = cwd.endsWith(
|
|
65925
|
+
const resolvedPath = path58.resolve(cwd, specFileArg);
|
|
65926
|
+
const normalizedCwd = cwd.endsWith(path58.sep) ? cwd : cwd + path58.sep;
|
|
65907
65927
|
if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
|
|
65908
65928
|
throw new Error("Invalid spec_file: path traversal detected");
|
|
65909
65929
|
}
|
|
65910
|
-
const ext =
|
|
65930
|
+
const ext = path58.extname(resolvedPath).toLowerCase();
|
|
65911
65931
|
if (!ALLOWED_EXTENSIONS.includes(ext)) {
|
|
65912
65932
|
throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
|
|
65913
65933
|
}
|
|
@@ -65921,7 +65941,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
65921
65941
|
return resolvedPath;
|
|
65922
65942
|
}
|
|
65923
65943
|
for (const candidate of SPEC_CANDIDATES) {
|
|
65924
|
-
const candidatePath =
|
|
65944
|
+
const candidatePath = path58.resolve(cwd, candidate);
|
|
65925
65945
|
if (fs46.existsSync(candidatePath)) {
|
|
65926
65946
|
const stats = fs46.statSync(candidatePath);
|
|
65927
65947
|
if (stats.size <= MAX_SPEC_SIZE) {
|
|
@@ -65933,7 +65953,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
65933
65953
|
}
|
|
65934
65954
|
function parseSpec(specFile) {
|
|
65935
65955
|
const content = fs46.readFileSync(specFile, "utf-8");
|
|
65936
|
-
const ext =
|
|
65956
|
+
const ext = path58.extname(specFile).toLowerCase();
|
|
65937
65957
|
if (ext === ".json") {
|
|
65938
65958
|
return parseJsonSpec(content);
|
|
65939
65959
|
}
|
|
@@ -66009,7 +66029,7 @@ function extractRoutes(cwd) {
|
|
|
66009
66029
|
return;
|
|
66010
66030
|
}
|
|
66011
66031
|
for (const entry of entries) {
|
|
66012
|
-
const fullPath =
|
|
66032
|
+
const fullPath = path58.join(dir, entry.name);
|
|
66013
66033
|
if (entry.isSymbolicLink()) {
|
|
66014
66034
|
continue;
|
|
66015
66035
|
}
|
|
@@ -66019,7 +66039,7 @@ function extractRoutes(cwd) {
|
|
|
66019
66039
|
}
|
|
66020
66040
|
walkDir(fullPath);
|
|
66021
66041
|
} else if (entry.isFile()) {
|
|
66022
|
-
const ext =
|
|
66042
|
+
const ext = path58.extname(entry.name).toLowerCase();
|
|
66023
66043
|
const baseName = entry.name.toLowerCase();
|
|
66024
66044
|
if (![".ts", ".js", ".mjs"].includes(ext)) {
|
|
66025
66045
|
continue;
|
|
@@ -66189,7 +66209,7 @@ init_secretscan();
|
|
|
66189
66209
|
init_tool();
|
|
66190
66210
|
init_create_tool();
|
|
66191
66211
|
import * as fs47 from "fs";
|
|
66192
|
-
import * as
|
|
66212
|
+
import * as path59 from "path";
|
|
66193
66213
|
var MAX_FILE_SIZE_BYTES7 = 1024 * 1024;
|
|
66194
66214
|
var WINDOWS_RESERVED_NAMES = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
66195
66215
|
function containsWindowsAttacks(str) {
|
|
@@ -66206,11 +66226,11 @@ function containsWindowsAttacks(str) {
|
|
|
66206
66226
|
}
|
|
66207
66227
|
function isPathInWorkspace(filePath, workspace) {
|
|
66208
66228
|
try {
|
|
66209
|
-
const resolvedPath =
|
|
66229
|
+
const resolvedPath = path59.resolve(workspace, filePath);
|
|
66210
66230
|
const realWorkspace = fs47.realpathSync(workspace);
|
|
66211
66231
|
const realResolvedPath = fs47.realpathSync(resolvedPath);
|
|
66212
|
-
const relativePath =
|
|
66213
|
-
if (relativePath.startsWith("..") ||
|
|
66232
|
+
const relativePath = path59.relative(realWorkspace, realResolvedPath);
|
|
66233
|
+
if (relativePath.startsWith("..") || path59.isAbsolute(relativePath)) {
|
|
66214
66234
|
return false;
|
|
66215
66235
|
}
|
|
66216
66236
|
return true;
|
|
@@ -66222,7 +66242,7 @@ function validatePathForRead(filePath, workspace) {
|
|
|
66222
66242
|
return isPathInWorkspace(filePath, workspace);
|
|
66223
66243
|
}
|
|
66224
66244
|
function extractTSSymbols(filePath, cwd) {
|
|
66225
|
-
const fullPath =
|
|
66245
|
+
const fullPath = path59.join(cwd, filePath);
|
|
66226
66246
|
if (!validatePathForRead(fullPath, cwd)) {
|
|
66227
66247
|
return [];
|
|
66228
66248
|
}
|
|
@@ -66374,7 +66394,7 @@ function extractTSSymbols(filePath, cwd) {
|
|
|
66374
66394
|
});
|
|
66375
66395
|
}
|
|
66376
66396
|
function extractPythonSymbols(filePath, cwd) {
|
|
66377
|
-
const fullPath =
|
|
66397
|
+
const fullPath = path59.join(cwd, filePath);
|
|
66378
66398
|
if (!validatePathForRead(fullPath, cwd)) {
|
|
66379
66399
|
return [];
|
|
66380
66400
|
}
|
|
@@ -66457,7 +66477,7 @@ var symbols = createSwarmTool({
|
|
|
66457
66477
|
}, null, 2);
|
|
66458
66478
|
}
|
|
66459
66479
|
const cwd = directory;
|
|
66460
|
-
const ext =
|
|
66480
|
+
const ext = path59.extname(file3);
|
|
66461
66481
|
if (containsControlChars(file3)) {
|
|
66462
66482
|
return JSON.stringify({
|
|
66463
66483
|
file: file3,
|
|
@@ -66529,7 +66549,7 @@ init_dist();
|
|
|
66529
66549
|
init_utils();
|
|
66530
66550
|
init_create_tool();
|
|
66531
66551
|
import * as fs48 from "fs";
|
|
66532
|
-
import * as
|
|
66552
|
+
import * as path60 from "path";
|
|
66533
66553
|
var MAX_TEXT_LENGTH = 200;
|
|
66534
66554
|
var MAX_FILE_SIZE_BYTES8 = 1024 * 1024;
|
|
66535
66555
|
var SUPPORTED_EXTENSIONS2 = new Set([
|
|
@@ -66594,9 +66614,9 @@ function validatePathsInput(paths, cwd) {
|
|
|
66594
66614
|
return { error: "paths contains path traversal", resolvedPath: null };
|
|
66595
66615
|
}
|
|
66596
66616
|
try {
|
|
66597
|
-
const resolvedPath =
|
|
66598
|
-
const normalizedCwd =
|
|
66599
|
-
const normalizedResolved =
|
|
66617
|
+
const resolvedPath = path60.resolve(paths);
|
|
66618
|
+
const normalizedCwd = path60.resolve(cwd);
|
|
66619
|
+
const normalizedResolved = path60.resolve(resolvedPath);
|
|
66600
66620
|
if (!normalizedResolved.startsWith(normalizedCwd)) {
|
|
66601
66621
|
return {
|
|
66602
66622
|
error: "paths must be within the current working directory",
|
|
@@ -66612,7 +66632,7 @@ function validatePathsInput(paths, cwd) {
|
|
|
66612
66632
|
}
|
|
66613
66633
|
}
|
|
66614
66634
|
function isSupportedExtension(filePath) {
|
|
66615
|
-
const ext =
|
|
66635
|
+
const ext = path60.extname(filePath).toLowerCase();
|
|
66616
66636
|
return SUPPORTED_EXTENSIONS2.has(ext);
|
|
66617
66637
|
}
|
|
66618
66638
|
function findSourceFiles2(dir, files = []) {
|
|
@@ -66627,7 +66647,7 @@ function findSourceFiles2(dir, files = []) {
|
|
|
66627
66647
|
if (SKIP_DIRECTORIES4.has(entry)) {
|
|
66628
66648
|
continue;
|
|
66629
66649
|
}
|
|
66630
|
-
const fullPath =
|
|
66650
|
+
const fullPath = path60.join(dir, entry);
|
|
66631
66651
|
let stat2;
|
|
66632
66652
|
try {
|
|
66633
66653
|
stat2 = fs48.statSync(fullPath);
|
|
@@ -66739,7 +66759,7 @@ var todo_extract = createSwarmTool({
|
|
|
66739
66759
|
filesToScan.push(scanPath);
|
|
66740
66760
|
} else {
|
|
66741
66761
|
const errorResult = {
|
|
66742
|
-
error: `unsupported file extension: ${
|
|
66762
|
+
error: `unsupported file extension: ${path60.extname(scanPath)}`,
|
|
66743
66763
|
total: 0,
|
|
66744
66764
|
byPriority: { high: 0, medium: 0, low: 0 },
|
|
66745
66765
|
entries: []
|
|
@@ -66786,14 +66806,14 @@ init_tool();
|
|
|
66786
66806
|
init_schema();
|
|
66787
66807
|
init_gate_evidence();
|
|
66788
66808
|
import * as fs50 from "fs";
|
|
66789
|
-
import * as
|
|
66809
|
+
import * as path62 from "path";
|
|
66790
66810
|
|
|
66791
66811
|
// src/hooks/diff-scope.ts
|
|
66792
66812
|
import * as fs49 from "fs";
|
|
66793
|
-
import * as
|
|
66813
|
+
import * as path61 from "path";
|
|
66794
66814
|
function getDeclaredScope(taskId, directory) {
|
|
66795
66815
|
try {
|
|
66796
|
-
const planPath =
|
|
66816
|
+
const planPath = path61.join(directory, ".swarm", "plan.json");
|
|
66797
66817
|
if (!fs49.existsSync(planPath))
|
|
66798
66818
|
return null;
|
|
66799
66819
|
const raw = fs49.readFileSync(planPath, "utf-8");
|
|
@@ -66909,7 +66929,7 @@ var TIER_3_PATTERNS = [
|
|
|
66909
66929
|
];
|
|
66910
66930
|
function matchesTier3Pattern(files) {
|
|
66911
66931
|
for (const file3 of files) {
|
|
66912
|
-
const fileName =
|
|
66932
|
+
const fileName = path62.basename(file3);
|
|
66913
66933
|
for (const pattern of TIER_3_PATTERNS) {
|
|
66914
66934
|
if (pattern.test(fileName)) {
|
|
66915
66935
|
return true;
|
|
@@ -66923,7 +66943,7 @@ function checkReviewerGate(taskId, workingDirectory) {
|
|
|
66923
66943
|
if (hasActiveTurboMode()) {
|
|
66924
66944
|
const resolvedDir2 = workingDirectory;
|
|
66925
66945
|
try {
|
|
66926
|
-
const planPath =
|
|
66946
|
+
const planPath = path62.join(resolvedDir2, ".swarm", "plan.json");
|
|
66927
66947
|
const planRaw = fs50.readFileSync(planPath, "utf-8");
|
|
66928
66948
|
const plan = JSON.parse(planRaw);
|
|
66929
66949
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -66990,7 +67010,7 @@ function checkReviewerGate(taskId, workingDirectory) {
|
|
|
66990
67010
|
}
|
|
66991
67011
|
try {
|
|
66992
67012
|
const resolvedDir2 = workingDirectory;
|
|
66993
|
-
const planPath =
|
|
67013
|
+
const planPath = path62.join(resolvedDir2, ".swarm", "plan.json");
|
|
66994
67014
|
const planRaw = fs50.readFileSync(planPath, "utf-8");
|
|
66995
67015
|
const plan = JSON.parse(planRaw);
|
|
66996
67016
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -67173,8 +67193,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
67173
67193
|
};
|
|
67174
67194
|
}
|
|
67175
67195
|
}
|
|
67176
|
-
normalizedDir =
|
|
67177
|
-
const pathParts = normalizedDir.split(
|
|
67196
|
+
normalizedDir = path62.normalize(args2.working_directory);
|
|
67197
|
+
const pathParts = normalizedDir.split(path62.sep);
|
|
67178
67198
|
if (pathParts.includes("..")) {
|
|
67179
67199
|
return {
|
|
67180
67200
|
success: false,
|
|
@@ -67184,10 +67204,10 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
67184
67204
|
]
|
|
67185
67205
|
};
|
|
67186
67206
|
}
|
|
67187
|
-
const resolvedDir =
|
|
67207
|
+
const resolvedDir = path62.resolve(normalizedDir);
|
|
67188
67208
|
try {
|
|
67189
67209
|
const realPath = fs50.realpathSync(resolvedDir);
|
|
67190
|
-
const planPath =
|
|
67210
|
+
const planPath = path62.join(realPath, ".swarm", "plan.json");
|
|
67191
67211
|
if (!fs50.existsSync(planPath)) {
|
|
67192
67212
|
return {
|
|
67193
67213
|
success: false,
|
|
@@ -67221,7 +67241,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
67221
67241
|
recoverTaskStateFromDelegations(args2.task_id);
|
|
67222
67242
|
let phaseRequiresReviewer = true;
|
|
67223
67243
|
try {
|
|
67224
|
-
const planPath =
|
|
67244
|
+
const planPath = path62.join(directory, ".swarm", "plan.json");
|
|
67225
67245
|
const planRaw = fs50.readFileSync(planPath, "utf-8");
|
|
67226
67246
|
const plan = JSON.parse(planRaw);
|
|
67227
67247
|
const taskPhase = plan.phases.find((p) => p.tasks.some((t) => t.id === args2.task_id));
|
|
@@ -67429,7 +67449,7 @@ var OpenCodeSwarm = async (ctx) => {
|
|
|
67429
67449
|
const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
|
|
67430
67450
|
preflightTriggerManager = new PTM(automationConfig);
|
|
67431
67451
|
const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
|
|
67432
|
-
const swarmDir =
|
|
67452
|
+
const swarmDir = path63.resolve(ctx.directory, ".swarm");
|
|
67433
67453
|
statusArtifact = new ASA(swarmDir);
|
|
67434
67454
|
statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
|
|
67435
67455
|
if (automationConfig.capabilities?.evidence_auto_summaries === true) {
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "6.40.
|
|
3
|
+
"version": "6.40.7",
|
|
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",
|