opencode-swarm 6.29.6 → 6.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +150 -193
- package/dist/session/snapshot-reader.d.ts +0 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37604,11 +37604,11 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
37604
37604
|
throw toThrow;
|
|
37605
37605
|
}, "quit_");
|
|
37606
37606
|
var scriptDirectory = "";
|
|
37607
|
-
function locateFile(
|
|
37607
|
+
function locateFile(path46) {
|
|
37608
37608
|
if (Module["locateFile"]) {
|
|
37609
|
-
return Module["locateFile"](
|
|
37609
|
+
return Module["locateFile"](path46, scriptDirectory);
|
|
37610
37610
|
}
|
|
37611
|
-
return scriptDirectory +
|
|
37611
|
+
return scriptDirectory + path46;
|
|
37612
37612
|
}
|
|
37613
37613
|
__name(locateFile, "locateFile");
|
|
37614
37614
|
var readAsync, readBinary;
|
|
@@ -39356,7 +39356,7 @@ var init_runtime = __esm(() => {
|
|
|
39356
39356
|
});
|
|
39357
39357
|
|
|
39358
39358
|
// src/index.ts
|
|
39359
|
-
import * as
|
|
39359
|
+
import * as path56 from "path";
|
|
39360
39360
|
|
|
39361
39361
|
// src/agents/index.ts
|
|
39362
39362
|
init_config();
|
|
@@ -53858,7 +53858,6 @@ init_config_doctor();
|
|
|
53858
53858
|
|
|
53859
53859
|
// src/session/snapshot-reader.ts
|
|
53860
53860
|
init_utils2();
|
|
53861
|
-
import path37 from "path";
|
|
53862
53861
|
var VALID_TASK_WORKFLOW_STATES = [
|
|
53863
53862
|
"idle",
|
|
53864
53863
|
"coder_delegated",
|
|
@@ -53981,47 +53980,6 @@ function rehydrateState(snapshot) {
|
|
|
53981
53980
|
}
|
|
53982
53981
|
}
|
|
53983
53982
|
}
|
|
53984
|
-
async function reconcileTaskStatesFromPlan(directory) {
|
|
53985
|
-
let raw;
|
|
53986
|
-
try {
|
|
53987
|
-
raw = await Bun.file(path37.join(directory, ".swarm/plan.json")).text();
|
|
53988
|
-
} catch {
|
|
53989
|
-
return;
|
|
53990
|
-
}
|
|
53991
|
-
let plan;
|
|
53992
|
-
try {
|
|
53993
|
-
plan = JSON.parse(raw);
|
|
53994
|
-
} catch {
|
|
53995
|
-
return;
|
|
53996
|
-
}
|
|
53997
|
-
if (!plan?.phases || !Array.isArray(plan.phases)) {
|
|
53998
|
-
return;
|
|
53999
|
-
}
|
|
54000
|
-
for (const phase of plan.phases) {
|
|
54001
|
-
if (!phase?.tasks || !Array.isArray(phase.tasks)) {
|
|
54002
|
-
continue;
|
|
54003
|
-
}
|
|
54004
|
-
for (const task of phase.tasks) {
|
|
54005
|
-
if (!task?.id || typeof task.id !== "string") {
|
|
54006
|
-
continue;
|
|
54007
|
-
}
|
|
54008
|
-
const taskId = task.id;
|
|
54009
|
-
const planStatus = task.status;
|
|
54010
|
-
for (const session of swarmState.agentSessions.values()) {
|
|
54011
|
-
const currentState = getTaskState(session, taskId);
|
|
54012
|
-
if (planStatus === "completed" && currentState !== "tests_run" && currentState !== "complete") {
|
|
54013
|
-
try {
|
|
54014
|
-
advanceTaskState(session, taskId, "tests_run");
|
|
54015
|
-
} catch {}
|
|
54016
|
-
} else if (planStatus === "in_progress" && currentState === "idle") {
|
|
54017
|
-
try {
|
|
54018
|
-
advanceTaskState(session, taskId, "coder_delegated");
|
|
54019
|
-
} catch {}
|
|
54020
|
-
}
|
|
54021
|
-
}
|
|
54022
|
-
}
|
|
54023
|
-
}
|
|
54024
|
-
}
|
|
54025
53983
|
async function loadSnapshot(directory) {
|
|
54026
53984
|
try {
|
|
54027
53985
|
await buildRehydrationCache(directory);
|
|
@@ -54031,7 +53989,6 @@ async function loadSnapshot(directory) {
|
|
|
54031
53989
|
for (const session of swarmState.agentSessions.values()) {
|
|
54032
53990
|
applyRehydrationCache(session);
|
|
54033
53991
|
}
|
|
54034
|
-
await reconcileTaskStatesFromPlan(directory);
|
|
54035
53992
|
}
|
|
54036
53993
|
} catch {}
|
|
54037
53994
|
}
|
|
@@ -54211,7 +54168,7 @@ var build_check = createSwarmTool({
|
|
|
54211
54168
|
init_dist();
|
|
54212
54169
|
init_create_tool();
|
|
54213
54170
|
import * as fs24 from "fs";
|
|
54214
|
-
import * as
|
|
54171
|
+
import * as path37 from "path";
|
|
54215
54172
|
var EVIDENCE_DIR = ".swarm/evidence";
|
|
54216
54173
|
var TASK_ID_PATTERN2 = /^\d+\.\d+(\.\d+)*$/;
|
|
54217
54174
|
function isValidTaskId3(taskId) {
|
|
@@ -54228,9 +54185,9 @@ function isValidTaskId3(taskId) {
|
|
|
54228
54185
|
return TASK_ID_PATTERN2.test(taskId);
|
|
54229
54186
|
}
|
|
54230
54187
|
function isPathWithinSwarm(filePath, workspaceRoot) {
|
|
54231
|
-
const normalizedWorkspace =
|
|
54232
|
-
const swarmPath =
|
|
54233
|
-
const normalizedPath =
|
|
54188
|
+
const normalizedWorkspace = path37.resolve(workspaceRoot);
|
|
54189
|
+
const swarmPath = path37.join(normalizedWorkspace, ".swarm", "evidence");
|
|
54190
|
+
const normalizedPath = path37.resolve(filePath);
|
|
54234
54191
|
return normalizedPath.startsWith(swarmPath);
|
|
54235
54192
|
}
|
|
54236
54193
|
function readEvidenceFile(evidencePath) {
|
|
@@ -54291,7 +54248,7 @@ var check_gate_status = createSwarmTool({
|
|
|
54291
54248
|
};
|
|
54292
54249
|
return JSON.stringify(errorResult, null, 2);
|
|
54293
54250
|
}
|
|
54294
|
-
const evidencePath =
|
|
54251
|
+
const evidencePath = path37.join(directory, EVIDENCE_DIR, `${taskIdInput}.json`);
|
|
54295
54252
|
if (!isPathWithinSwarm(evidencePath, directory)) {
|
|
54296
54253
|
const errorResult = {
|
|
54297
54254
|
taskId: taskIdInput,
|
|
@@ -54352,7 +54309,7 @@ init_tool();
|
|
|
54352
54309
|
init_create_tool();
|
|
54353
54310
|
import { spawnSync } from "child_process";
|
|
54354
54311
|
import * as fs25 from "fs";
|
|
54355
|
-
import * as
|
|
54312
|
+
import * as path38 from "path";
|
|
54356
54313
|
var CHECKPOINT_LOG_PATH = ".swarm/checkpoints.json";
|
|
54357
54314
|
var MAX_LABEL_LENGTH = 100;
|
|
54358
54315
|
var GIT_TIMEOUT_MS = 30000;
|
|
@@ -54403,7 +54360,7 @@ function validateLabel(label) {
|
|
|
54403
54360
|
return null;
|
|
54404
54361
|
}
|
|
54405
54362
|
function getCheckpointLogPath(directory) {
|
|
54406
|
-
return
|
|
54363
|
+
return path38.join(directory, CHECKPOINT_LOG_PATH);
|
|
54407
54364
|
}
|
|
54408
54365
|
function readCheckpointLog(directory) {
|
|
54409
54366
|
const logPath = getCheckpointLogPath(directory);
|
|
@@ -54421,7 +54378,7 @@ function readCheckpointLog(directory) {
|
|
|
54421
54378
|
}
|
|
54422
54379
|
function writeCheckpointLog(log2, directory) {
|
|
54423
54380
|
const logPath = getCheckpointLogPath(directory);
|
|
54424
|
-
const dir =
|
|
54381
|
+
const dir = path38.dirname(logPath);
|
|
54425
54382
|
if (!fs25.existsSync(dir)) {
|
|
54426
54383
|
fs25.mkdirSync(dir, { recursive: true });
|
|
54427
54384
|
}
|
|
@@ -54629,7 +54586,7 @@ var checkpoint = createSwarmTool({
|
|
|
54629
54586
|
init_dist();
|
|
54630
54587
|
init_create_tool();
|
|
54631
54588
|
import * as fs26 from "fs";
|
|
54632
|
-
import * as
|
|
54589
|
+
import * as path39 from "path";
|
|
54633
54590
|
var MAX_FILE_SIZE_BYTES2 = 256 * 1024;
|
|
54634
54591
|
var DEFAULT_DAYS = 90;
|
|
54635
54592
|
var DEFAULT_TOP_N = 20;
|
|
@@ -54773,7 +54730,7 @@ async function analyzeHotspots(days, topN, extensions, directory) {
|
|
|
54773
54730
|
const extSet = new Set(extensions.map((e) => e.startsWith(".") ? e : `.${e}`));
|
|
54774
54731
|
const filteredChurn = new Map;
|
|
54775
54732
|
for (const [file3, count] of churnMap) {
|
|
54776
|
-
const ext =
|
|
54733
|
+
const ext = path39.extname(file3).toLowerCase();
|
|
54777
54734
|
if (extSet.has(ext)) {
|
|
54778
54735
|
filteredChurn.set(file3, count);
|
|
54779
54736
|
}
|
|
@@ -54784,7 +54741,7 @@ async function analyzeHotspots(days, topN, extensions, directory) {
|
|
|
54784
54741
|
for (const [file3, churnCount] of filteredChurn) {
|
|
54785
54742
|
let fullPath = file3;
|
|
54786
54743
|
if (!fs26.existsSync(fullPath)) {
|
|
54787
|
-
fullPath =
|
|
54744
|
+
fullPath = path39.join(cwd, file3);
|
|
54788
54745
|
}
|
|
54789
54746
|
const complexity = getComplexityForFile(fullPath);
|
|
54790
54747
|
if (complexity !== null) {
|
|
@@ -54932,7 +54889,7 @@ var complexity_hotspots = createSwarmTool({
|
|
|
54932
54889
|
// src/tools/declare-scope.ts
|
|
54933
54890
|
init_tool();
|
|
54934
54891
|
import * as fs27 from "fs";
|
|
54935
|
-
import * as
|
|
54892
|
+
import * as path40 from "path";
|
|
54936
54893
|
init_create_tool();
|
|
54937
54894
|
function validateTaskIdFormat(taskId) {
|
|
54938
54895
|
const taskIdPattern = /^\d+\.\d+(\.\d+)*$/;
|
|
@@ -55011,8 +54968,8 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
55011
54968
|
};
|
|
55012
54969
|
}
|
|
55013
54970
|
}
|
|
55014
|
-
normalizedDir =
|
|
55015
|
-
const pathParts = normalizedDir.split(
|
|
54971
|
+
normalizedDir = path40.normalize(args2.working_directory);
|
|
54972
|
+
const pathParts = normalizedDir.split(path40.sep);
|
|
55016
54973
|
if (pathParts.includes("..")) {
|
|
55017
54974
|
return {
|
|
55018
54975
|
success: false,
|
|
@@ -55022,10 +54979,10 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
55022
54979
|
]
|
|
55023
54980
|
};
|
|
55024
54981
|
}
|
|
55025
|
-
const resolvedDir =
|
|
54982
|
+
const resolvedDir = path40.resolve(normalizedDir);
|
|
55026
54983
|
try {
|
|
55027
54984
|
const realPath = fs27.realpathSync(resolvedDir);
|
|
55028
|
-
const planPath2 =
|
|
54985
|
+
const planPath2 = path40.join(realPath, ".swarm", "plan.json");
|
|
55029
54986
|
if (!fs27.existsSync(planPath2)) {
|
|
55030
54987
|
return {
|
|
55031
54988
|
success: false,
|
|
@@ -55046,7 +55003,7 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
55046
55003
|
}
|
|
55047
55004
|
}
|
|
55048
55005
|
const directory = normalizedDir ?? fallbackDir ?? process.cwd();
|
|
55049
|
-
const planPath =
|
|
55006
|
+
const planPath = path40.resolve(directory, ".swarm", "plan.json");
|
|
55050
55007
|
if (!fs27.existsSync(planPath)) {
|
|
55051
55008
|
return {
|
|
55052
55009
|
success: false,
|
|
@@ -55136,20 +55093,20 @@ function validateBase(base) {
|
|
|
55136
55093
|
function validatePaths(paths) {
|
|
55137
55094
|
if (!paths)
|
|
55138
55095
|
return null;
|
|
55139
|
-
for (const
|
|
55140
|
-
if (!
|
|
55096
|
+
for (const path41 of paths) {
|
|
55097
|
+
if (!path41 || path41.length === 0) {
|
|
55141
55098
|
return "empty path not allowed";
|
|
55142
55099
|
}
|
|
55143
|
-
if (
|
|
55100
|
+
if (path41.length > MAX_PATH_LENGTH) {
|
|
55144
55101
|
return `path exceeds maximum length of ${MAX_PATH_LENGTH}`;
|
|
55145
55102
|
}
|
|
55146
|
-
if (SHELL_METACHARACTERS2.test(
|
|
55103
|
+
if (SHELL_METACHARACTERS2.test(path41)) {
|
|
55147
55104
|
return "path contains shell metacharacters";
|
|
55148
55105
|
}
|
|
55149
|
-
if (
|
|
55106
|
+
if (path41.startsWith("-")) {
|
|
55150
55107
|
return 'path cannot start with "-" (option-like arguments not allowed)';
|
|
55151
55108
|
}
|
|
55152
|
-
if (CONTROL_CHAR_PATTERN2.test(
|
|
55109
|
+
if (CONTROL_CHAR_PATTERN2.test(path41)) {
|
|
55153
55110
|
return "path contains control characters";
|
|
55154
55111
|
}
|
|
55155
55112
|
}
|
|
@@ -55229,8 +55186,8 @@ var diff = tool({
|
|
|
55229
55186
|
if (parts2.length >= 3) {
|
|
55230
55187
|
const additions = parseInt(parts2[0], 10) || 0;
|
|
55231
55188
|
const deletions = parseInt(parts2[1], 10) || 0;
|
|
55232
|
-
const
|
|
55233
|
-
files.push({ path:
|
|
55189
|
+
const path41 = parts2[2];
|
|
55190
|
+
files.push({ path: path41, additions, deletions });
|
|
55234
55191
|
}
|
|
55235
55192
|
}
|
|
55236
55193
|
const contractChanges = [];
|
|
@@ -55460,7 +55417,7 @@ Use these as DOMAIN values when delegating to @sme.`;
|
|
|
55460
55417
|
init_dist();
|
|
55461
55418
|
init_create_tool();
|
|
55462
55419
|
import * as fs28 from "fs";
|
|
55463
|
-
import * as
|
|
55420
|
+
import * as path41 from "path";
|
|
55464
55421
|
var MAX_FILE_SIZE_BYTES3 = 1024 * 1024;
|
|
55465
55422
|
var MAX_EVIDENCE_FILES = 1000;
|
|
55466
55423
|
var EVIDENCE_DIR2 = ".swarm/evidence";
|
|
@@ -55490,9 +55447,9 @@ function validateRequiredTypes(input) {
|
|
|
55490
55447
|
return null;
|
|
55491
55448
|
}
|
|
55492
55449
|
function isPathWithinSwarm2(filePath, cwd) {
|
|
55493
|
-
const normalizedCwd =
|
|
55494
|
-
const swarmPath =
|
|
55495
|
-
const normalizedPath =
|
|
55450
|
+
const normalizedCwd = path41.resolve(cwd);
|
|
55451
|
+
const swarmPath = path41.join(normalizedCwd, ".swarm");
|
|
55452
|
+
const normalizedPath = path41.resolve(filePath);
|
|
55496
55453
|
return normalizedPath.startsWith(swarmPath);
|
|
55497
55454
|
}
|
|
55498
55455
|
function parseCompletedTasks(planContent) {
|
|
@@ -55522,10 +55479,10 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
55522
55479
|
if (!VALID_EVIDENCE_FILENAME_REGEX.test(filename)) {
|
|
55523
55480
|
continue;
|
|
55524
55481
|
}
|
|
55525
|
-
const filePath =
|
|
55482
|
+
const filePath = path41.join(evidenceDir, filename);
|
|
55526
55483
|
try {
|
|
55527
|
-
const resolvedPath =
|
|
55528
|
-
const evidenceDirResolved =
|
|
55484
|
+
const resolvedPath = path41.resolve(filePath);
|
|
55485
|
+
const evidenceDirResolved = path41.resolve(evidenceDir);
|
|
55529
55486
|
if (!resolvedPath.startsWith(evidenceDirResolved)) {
|
|
55530
55487
|
continue;
|
|
55531
55488
|
}
|
|
@@ -55643,7 +55600,7 @@ var evidence_check = createSwarmTool({
|
|
|
55643
55600
|
return JSON.stringify(errorResult, null, 2);
|
|
55644
55601
|
}
|
|
55645
55602
|
const requiredTypes = requiredTypesValue.split(",").map((t) => t.trim()).filter((t) => t.length > 0).map(normalizeEvidenceType);
|
|
55646
|
-
const planPath =
|
|
55603
|
+
const planPath = path41.join(cwd, PLAN_FILE);
|
|
55647
55604
|
if (!isPathWithinSwarm2(planPath, cwd)) {
|
|
55648
55605
|
const errorResult = {
|
|
55649
55606
|
error: "plan file path validation failed",
|
|
@@ -55675,7 +55632,7 @@ var evidence_check = createSwarmTool({
|
|
|
55675
55632
|
};
|
|
55676
55633
|
return JSON.stringify(result2, null, 2);
|
|
55677
55634
|
}
|
|
55678
|
-
const evidenceDir =
|
|
55635
|
+
const evidenceDir = path41.join(cwd, EVIDENCE_DIR2);
|
|
55679
55636
|
const evidence = readEvidenceFiles(evidenceDir, cwd);
|
|
55680
55637
|
const { tasksWithFullEvidence, gaps } = analyzeGaps(completedTasks, evidence, requiredTypes);
|
|
55681
55638
|
const completeness = completedTasks.length > 0 ? Math.round(tasksWithFullEvidence.length / completedTasks.length * 100) / 100 : 1;
|
|
@@ -55693,7 +55650,7 @@ var evidence_check = createSwarmTool({
|
|
|
55693
55650
|
init_tool();
|
|
55694
55651
|
init_create_tool();
|
|
55695
55652
|
import * as fs29 from "fs";
|
|
55696
|
-
import * as
|
|
55653
|
+
import * as path42 from "path";
|
|
55697
55654
|
var EXT_MAP = {
|
|
55698
55655
|
python: ".py",
|
|
55699
55656
|
py: ".py",
|
|
@@ -55774,12 +55731,12 @@ var extract_code_blocks = createSwarmTool({
|
|
|
55774
55731
|
if (prefix) {
|
|
55775
55732
|
filename = `${prefix}_${filename}`;
|
|
55776
55733
|
}
|
|
55777
|
-
let filepath =
|
|
55778
|
-
const base =
|
|
55779
|
-
const ext =
|
|
55734
|
+
let filepath = path42.join(targetDir, filename);
|
|
55735
|
+
const base = path42.basename(filepath, path42.extname(filepath));
|
|
55736
|
+
const ext = path42.extname(filepath);
|
|
55780
55737
|
let counter = 1;
|
|
55781
55738
|
while (fs29.existsSync(filepath)) {
|
|
55782
|
-
filepath =
|
|
55739
|
+
filepath = path42.join(targetDir, `${base}_${counter}${ext}`);
|
|
55783
55740
|
counter++;
|
|
55784
55741
|
}
|
|
55785
55742
|
try {
|
|
@@ -55897,7 +55854,7 @@ var gitingest = tool({
|
|
|
55897
55854
|
// src/tools/imports.ts
|
|
55898
55855
|
init_dist();
|
|
55899
55856
|
import * as fs30 from "fs";
|
|
55900
|
-
import * as
|
|
55857
|
+
import * as path43 from "path";
|
|
55901
55858
|
var MAX_FILE_PATH_LENGTH2 = 500;
|
|
55902
55859
|
var MAX_SYMBOL_LENGTH = 256;
|
|
55903
55860
|
var MAX_FILE_SIZE_BYTES4 = 1024 * 1024;
|
|
@@ -55951,7 +55908,7 @@ function validateSymbolInput(symbol3) {
|
|
|
55951
55908
|
return null;
|
|
55952
55909
|
}
|
|
55953
55910
|
function isBinaryFile2(filePath, buffer) {
|
|
55954
|
-
const ext =
|
|
55911
|
+
const ext = path43.extname(filePath).toLowerCase();
|
|
55955
55912
|
if (ext === ".json" || ext === ".md" || ext === ".txt") {
|
|
55956
55913
|
return false;
|
|
55957
55914
|
}
|
|
@@ -55975,15 +55932,15 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
55975
55932
|
const imports = [];
|
|
55976
55933
|
let _resolvedTarget;
|
|
55977
55934
|
try {
|
|
55978
|
-
_resolvedTarget =
|
|
55935
|
+
_resolvedTarget = path43.resolve(targetFile);
|
|
55979
55936
|
} catch {
|
|
55980
55937
|
_resolvedTarget = targetFile;
|
|
55981
55938
|
}
|
|
55982
|
-
const targetBasename =
|
|
55939
|
+
const targetBasename = path43.basename(targetFile, path43.extname(targetFile));
|
|
55983
55940
|
const targetWithExt = targetFile;
|
|
55984
55941
|
const targetWithoutExt = targetFile.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
55985
|
-
const normalizedTargetWithExt =
|
|
55986
|
-
const normalizedTargetWithoutExt =
|
|
55942
|
+
const normalizedTargetWithExt = path43.normalize(targetWithExt).replace(/\\/g, "/");
|
|
55943
|
+
const normalizedTargetWithoutExt = path43.normalize(targetWithoutExt).replace(/\\/g, "/");
|
|
55987
55944
|
const importRegex = /import\s+(?:\{[\s\S]*?\}|(?:\*\s+as\s+\w+)|\w+)\s+from\s+['"`]([^'"`]+)['"`]|import\s+['"`]([^'"`]+)['"`]|require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
55988
55945
|
for (let match = importRegex.exec(content);match !== null; match = importRegex.exec(content)) {
|
|
55989
55946
|
const modulePath = match[1] || match[2] || match[3];
|
|
@@ -56006,9 +55963,9 @@ function parseImports(content, targetFile, targetSymbol) {
|
|
|
56006
55963
|
}
|
|
56007
55964
|
const _normalizedModule = modulePath.replace(/^\.\//, "").replace(/^\.\.\\/, "../");
|
|
56008
55965
|
let isMatch = false;
|
|
56009
|
-
const _targetDir =
|
|
56010
|
-
const targetExt =
|
|
56011
|
-
const targetBasenameNoExt =
|
|
55966
|
+
const _targetDir = path43.dirname(targetFile);
|
|
55967
|
+
const targetExt = path43.extname(targetFile);
|
|
55968
|
+
const targetBasenameNoExt = path43.basename(targetFile, targetExt);
|
|
56012
55969
|
const moduleNormalized = modulePath.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
56013
55970
|
const moduleName = modulePath.split(/[/\\]/).pop() || "";
|
|
56014
55971
|
const moduleNameNoExt = moduleName.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
|
|
@@ -56076,10 +56033,10 @@ function findSourceFiles(dir, files = [], stats = { skippedDirs: [], skippedFile
|
|
|
56076
56033
|
entries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
56077
56034
|
for (const entry of entries) {
|
|
56078
56035
|
if (SKIP_DIRECTORIES2.has(entry)) {
|
|
56079
|
-
stats.skippedDirs.push(
|
|
56036
|
+
stats.skippedDirs.push(path43.join(dir, entry));
|
|
56080
56037
|
continue;
|
|
56081
56038
|
}
|
|
56082
|
-
const fullPath =
|
|
56039
|
+
const fullPath = path43.join(dir, entry);
|
|
56083
56040
|
let stat2;
|
|
56084
56041
|
try {
|
|
56085
56042
|
stat2 = fs30.statSync(fullPath);
|
|
@@ -56093,7 +56050,7 @@ function findSourceFiles(dir, files = [], stats = { skippedDirs: [], skippedFile
|
|
|
56093
56050
|
if (stat2.isDirectory()) {
|
|
56094
56051
|
findSourceFiles(fullPath, files, stats);
|
|
56095
56052
|
} else if (stat2.isFile()) {
|
|
56096
|
-
const ext =
|
|
56053
|
+
const ext = path43.extname(fullPath).toLowerCase();
|
|
56097
56054
|
if (SUPPORTED_EXTENSIONS.includes(ext)) {
|
|
56098
56055
|
files.push(fullPath);
|
|
56099
56056
|
}
|
|
@@ -56149,7 +56106,7 @@ var imports = tool({
|
|
|
56149
56106
|
return JSON.stringify(errorResult, null, 2);
|
|
56150
56107
|
}
|
|
56151
56108
|
try {
|
|
56152
|
-
const targetFile =
|
|
56109
|
+
const targetFile = path43.resolve(file3);
|
|
56153
56110
|
if (!fs30.existsSync(targetFile)) {
|
|
56154
56111
|
const errorResult = {
|
|
56155
56112
|
error: `target file not found: ${file3}`,
|
|
@@ -56171,7 +56128,7 @@ var imports = tool({
|
|
|
56171
56128
|
};
|
|
56172
56129
|
return JSON.stringify(errorResult, null, 2);
|
|
56173
56130
|
}
|
|
56174
|
-
const baseDir =
|
|
56131
|
+
const baseDir = path43.dirname(targetFile);
|
|
56175
56132
|
const scanStats = {
|
|
56176
56133
|
skippedDirs: [],
|
|
56177
56134
|
skippedFiles: 0,
|
|
@@ -56493,7 +56450,7 @@ init_config();
|
|
|
56493
56450
|
init_schema();
|
|
56494
56451
|
init_manager();
|
|
56495
56452
|
import * as fs31 from "fs";
|
|
56496
|
-
import * as
|
|
56453
|
+
import * as path44 from "path";
|
|
56497
56454
|
init_utils2();
|
|
56498
56455
|
init_create_tool();
|
|
56499
56456
|
function safeWarn(message, error93) {
|
|
@@ -56688,7 +56645,7 @@ async function executePhaseComplete(args2, workingDirectory) {
|
|
|
56688
56645
|
}
|
|
56689
56646
|
if (retroFound && retroEntry?.lessons_learned && retroEntry.lessons_learned.length > 0) {
|
|
56690
56647
|
try {
|
|
56691
|
-
const projectName =
|
|
56648
|
+
const projectName = path44.basename(dir);
|
|
56692
56649
|
const knowledgeConfig = {
|
|
56693
56650
|
enabled: true,
|
|
56694
56651
|
swarm_max_entries: 100,
|
|
@@ -56860,7 +56817,7 @@ init_discovery();
|
|
|
56860
56817
|
init_utils();
|
|
56861
56818
|
init_create_tool();
|
|
56862
56819
|
import * as fs32 from "fs";
|
|
56863
|
-
import * as
|
|
56820
|
+
import * as path45 from "path";
|
|
56864
56821
|
var MAX_OUTPUT_BYTES5 = 52428800;
|
|
56865
56822
|
var AUDIT_TIMEOUT_MS = 120000;
|
|
56866
56823
|
function isValidEcosystem(value) {
|
|
@@ -56878,16 +56835,16 @@ function validateArgs3(args2) {
|
|
|
56878
56835
|
function detectEcosystems(directory) {
|
|
56879
56836
|
const ecosystems = [];
|
|
56880
56837
|
const cwd = directory;
|
|
56881
|
-
if (fs32.existsSync(
|
|
56838
|
+
if (fs32.existsSync(path45.join(cwd, "package.json"))) {
|
|
56882
56839
|
ecosystems.push("npm");
|
|
56883
56840
|
}
|
|
56884
|
-
if (fs32.existsSync(
|
|
56841
|
+
if (fs32.existsSync(path45.join(cwd, "pyproject.toml")) || fs32.existsSync(path45.join(cwd, "requirements.txt"))) {
|
|
56885
56842
|
ecosystems.push("pip");
|
|
56886
56843
|
}
|
|
56887
|
-
if (fs32.existsSync(
|
|
56844
|
+
if (fs32.existsSync(path45.join(cwd, "Cargo.toml"))) {
|
|
56888
56845
|
ecosystems.push("cargo");
|
|
56889
56846
|
}
|
|
56890
|
-
if (fs32.existsSync(
|
|
56847
|
+
if (fs32.existsSync(path45.join(cwd, "go.mod"))) {
|
|
56891
56848
|
ecosystems.push("go");
|
|
56892
56849
|
}
|
|
56893
56850
|
try {
|
|
@@ -56896,10 +56853,10 @@ function detectEcosystems(directory) {
|
|
|
56896
56853
|
ecosystems.push("dotnet");
|
|
56897
56854
|
}
|
|
56898
56855
|
} catch {}
|
|
56899
|
-
if (fs32.existsSync(
|
|
56856
|
+
if (fs32.existsSync(path45.join(cwd, "Gemfile")) || fs32.existsSync(path45.join(cwd, "Gemfile.lock"))) {
|
|
56900
56857
|
ecosystems.push("ruby");
|
|
56901
56858
|
}
|
|
56902
|
-
if (fs32.existsSync(
|
|
56859
|
+
if (fs32.existsSync(path45.join(cwd, "pubspec.yaml"))) {
|
|
56903
56860
|
ecosystems.push("dart");
|
|
56904
56861
|
}
|
|
56905
56862
|
return ecosystems;
|
|
@@ -57962,7 +57919,7 @@ var SUPPORTED_PARSER_EXTENSIONS = new Set([
|
|
|
57962
57919
|
// src/tools/pre-check-batch.ts
|
|
57963
57920
|
init_dist();
|
|
57964
57921
|
import * as fs35 from "fs";
|
|
57965
|
-
import * as
|
|
57922
|
+
import * as path48 from "path";
|
|
57966
57923
|
|
|
57967
57924
|
// node_modules/yocto-queue/index.js
|
|
57968
57925
|
class Node2 {
|
|
@@ -58130,7 +58087,7 @@ init_manager();
|
|
|
58130
58087
|
|
|
58131
58088
|
// src/quality/metrics.ts
|
|
58132
58089
|
import * as fs33 from "fs";
|
|
58133
|
-
import * as
|
|
58090
|
+
import * as path46 from "path";
|
|
58134
58091
|
var MAX_FILE_SIZE_BYTES5 = 256 * 1024;
|
|
58135
58092
|
var MIN_DUPLICATION_LINES = 10;
|
|
58136
58093
|
function estimateCyclomaticComplexity(content) {
|
|
@@ -58182,7 +58139,7 @@ async function computeComplexityDelta(files, workingDir) {
|
|
|
58182
58139
|
let totalComplexity = 0;
|
|
58183
58140
|
const analyzedFiles = [];
|
|
58184
58141
|
for (const file3 of files) {
|
|
58185
|
-
const fullPath =
|
|
58142
|
+
const fullPath = path46.isAbsolute(file3) ? file3 : path46.join(workingDir, file3);
|
|
58186
58143
|
if (!fs33.existsSync(fullPath)) {
|
|
58187
58144
|
continue;
|
|
58188
58145
|
}
|
|
@@ -58305,7 +58262,7 @@ function countGoExports(content) {
|
|
|
58305
58262
|
function getExportCountForFile(filePath) {
|
|
58306
58263
|
try {
|
|
58307
58264
|
const content = fs33.readFileSync(filePath, "utf-8");
|
|
58308
|
-
const ext =
|
|
58265
|
+
const ext = path46.extname(filePath).toLowerCase();
|
|
58309
58266
|
switch (ext) {
|
|
58310
58267
|
case ".ts":
|
|
58311
58268
|
case ".tsx":
|
|
@@ -58331,7 +58288,7 @@ async function computePublicApiDelta(files, workingDir) {
|
|
|
58331
58288
|
let totalExports = 0;
|
|
58332
58289
|
const analyzedFiles = [];
|
|
58333
58290
|
for (const file3 of files) {
|
|
58334
|
-
const fullPath =
|
|
58291
|
+
const fullPath = path46.isAbsolute(file3) ? file3 : path46.join(workingDir, file3);
|
|
58335
58292
|
if (!fs33.existsSync(fullPath)) {
|
|
58336
58293
|
continue;
|
|
58337
58294
|
}
|
|
@@ -58365,7 +58322,7 @@ async function computeDuplicationRatio(files, workingDir) {
|
|
|
58365
58322
|
let duplicateLines = 0;
|
|
58366
58323
|
const analyzedFiles = [];
|
|
58367
58324
|
for (const file3 of files) {
|
|
58368
|
-
const fullPath =
|
|
58325
|
+
const fullPath = path46.isAbsolute(file3) ? file3 : path46.join(workingDir, file3);
|
|
58369
58326
|
if (!fs33.existsSync(fullPath)) {
|
|
58370
58327
|
continue;
|
|
58371
58328
|
}
|
|
@@ -58398,8 +58355,8 @@ function countCodeLines(content) {
|
|
|
58398
58355
|
return lines.length;
|
|
58399
58356
|
}
|
|
58400
58357
|
function isTestFile(filePath) {
|
|
58401
|
-
const basename8 =
|
|
58402
|
-
const _ext =
|
|
58358
|
+
const basename8 = path46.basename(filePath);
|
|
58359
|
+
const _ext = path46.extname(filePath).toLowerCase();
|
|
58403
58360
|
const testPatterns = [
|
|
58404
58361
|
".test.",
|
|
58405
58362
|
".spec.",
|
|
@@ -58480,8 +58437,8 @@ function matchGlobSegment(globSegments, pathSegments) {
|
|
|
58480
58437
|
}
|
|
58481
58438
|
return gIndex === globSegments.length && pIndex === pathSegments.length;
|
|
58482
58439
|
}
|
|
58483
|
-
function matchesGlobSegment(
|
|
58484
|
-
const normalizedPath =
|
|
58440
|
+
function matchesGlobSegment(path47, glob) {
|
|
58441
|
+
const normalizedPath = path47.replace(/\\/g, "/");
|
|
58485
58442
|
const normalizedGlob = glob.replace(/\\/g, "/");
|
|
58486
58443
|
if (normalizedPath.includes("//")) {
|
|
58487
58444
|
return false;
|
|
@@ -58512,8 +58469,8 @@ function simpleGlobToRegex2(glob) {
|
|
|
58512
58469
|
function hasGlobstar(glob) {
|
|
58513
58470
|
return glob.includes("**");
|
|
58514
58471
|
}
|
|
58515
|
-
function globMatches(
|
|
58516
|
-
const normalizedPath =
|
|
58472
|
+
function globMatches(path47, glob) {
|
|
58473
|
+
const normalizedPath = path47.replace(/\\/g, "/");
|
|
58517
58474
|
if (!glob || glob === "") {
|
|
58518
58475
|
if (normalizedPath.includes("//")) {
|
|
58519
58476
|
return false;
|
|
@@ -58549,7 +58506,7 @@ function shouldExcludeFile(filePath, excludeGlobs) {
|
|
|
58549
58506
|
async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
58550
58507
|
let testLines = 0;
|
|
58551
58508
|
let codeLines = 0;
|
|
58552
|
-
const srcDir =
|
|
58509
|
+
const srcDir = path46.join(workingDir, "src");
|
|
58553
58510
|
if (fs33.existsSync(srcDir)) {
|
|
58554
58511
|
await scanDirectoryForLines(srcDir, enforceGlobs, excludeGlobs, false, (lines) => {
|
|
58555
58512
|
codeLines += lines;
|
|
@@ -58557,14 +58514,14 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
58557
58514
|
}
|
|
58558
58515
|
const possibleSrcDirs = ["lib", "app", "source", "core"];
|
|
58559
58516
|
for (const dir of possibleSrcDirs) {
|
|
58560
|
-
const dirPath =
|
|
58517
|
+
const dirPath = path46.join(workingDir, dir);
|
|
58561
58518
|
if (fs33.existsSync(dirPath)) {
|
|
58562
58519
|
await scanDirectoryForLines(dirPath, enforceGlobs, excludeGlobs, false, (lines) => {
|
|
58563
58520
|
codeLines += lines;
|
|
58564
58521
|
});
|
|
58565
58522
|
}
|
|
58566
58523
|
}
|
|
58567
|
-
const testsDir =
|
|
58524
|
+
const testsDir = path46.join(workingDir, "tests");
|
|
58568
58525
|
if (fs33.existsSync(testsDir)) {
|
|
58569
58526
|
await scanDirectoryForLines(testsDir, ["**"], ["node_modules", "dist"], true, (lines) => {
|
|
58570
58527
|
testLines += lines;
|
|
@@ -58572,7 +58529,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
58572
58529
|
}
|
|
58573
58530
|
const possibleTestDirs = ["test", "__tests__", "specs"];
|
|
58574
58531
|
for (const dir of possibleTestDirs) {
|
|
58575
|
-
const dirPath =
|
|
58532
|
+
const dirPath = path46.join(workingDir, dir);
|
|
58576
58533
|
if (fs33.existsSync(dirPath) && dirPath !== testsDir) {
|
|
58577
58534
|
await scanDirectoryForLines(dirPath, ["**"], ["node_modules", "dist"], true, (lines) => {
|
|
58578
58535
|
testLines += lines;
|
|
@@ -58587,7 +58544,7 @@ async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTest
|
|
|
58587
58544
|
try {
|
|
58588
58545
|
const entries = fs33.readdirSync(dirPath, { withFileTypes: true });
|
|
58589
58546
|
for (const entry of entries) {
|
|
58590
|
-
const fullPath =
|
|
58547
|
+
const fullPath = path46.join(dirPath, entry.name);
|
|
58591
58548
|
if (entry.isDirectory()) {
|
|
58592
58549
|
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === ".git") {
|
|
58593
58550
|
continue;
|
|
@@ -58595,7 +58552,7 @@ async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTest
|
|
|
58595
58552
|
await scanDirectoryForLines(fullPath, includeGlobs, excludeGlobs, isTestScan, callback);
|
|
58596
58553
|
} else if (entry.isFile()) {
|
|
58597
58554
|
const relativePath = fullPath.replace(`${process.cwd()}/`, "");
|
|
58598
|
-
const ext =
|
|
58555
|
+
const ext = path46.extname(entry.name).toLowerCase();
|
|
58599
58556
|
const validExts = [
|
|
58600
58557
|
".ts",
|
|
58601
58558
|
".tsx",
|
|
@@ -58846,7 +58803,7 @@ init_dist();
|
|
|
58846
58803
|
init_manager();
|
|
58847
58804
|
init_detector();
|
|
58848
58805
|
import * as fs34 from "fs";
|
|
58849
|
-
import * as
|
|
58806
|
+
import * as path47 from "path";
|
|
58850
58807
|
import { extname as extname9 } from "path";
|
|
58851
58808
|
|
|
58852
58809
|
// src/sast/rules/c.ts
|
|
@@ -59809,7 +59766,7 @@ async function sastScan(input, directory, config3) {
|
|
|
59809
59766
|
_filesSkipped++;
|
|
59810
59767
|
continue;
|
|
59811
59768
|
}
|
|
59812
|
-
const resolvedPath =
|
|
59769
|
+
const resolvedPath = path47.isAbsolute(filePath) ? filePath : path47.resolve(directory, filePath);
|
|
59813
59770
|
if (!fs34.existsSync(resolvedPath)) {
|
|
59814
59771
|
_filesSkipped++;
|
|
59815
59772
|
continue;
|
|
@@ -60008,18 +59965,18 @@ function validatePath(inputPath, baseDir, workspaceDir) {
|
|
|
60008
59965
|
let resolved;
|
|
60009
59966
|
const isWinAbs = isWindowsAbsolutePath(inputPath);
|
|
60010
59967
|
if (isWinAbs) {
|
|
60011
|
-
resolved =
|
|
60012
|
-
} else if (
|
|
60013
|
-
resolved =
|
|
59968
|
+
resolved = path48.win32.resolve(inputPath);
|
|
59969
|
+
} else if (path48.isAbsolute(inputPath)) {
|
|
59970
|
+
resolved = path48.resolve(inputPath);
|
|
60014
59971
|
} else {
|
|
60015
|
-
resolved =
|
|
59972
|
+
resolved = path48.resolve(baseDir, inputPath);
|
|
60016
59973
|
}
|
|
60017
|
-
const workspaceResolved =
|
|
59974
|
+
const workspaceResolved = path48.resolve(workspaceDir);
|
|
60018
59975
|
let relative5;
|
|
60019
59976
|
if (isWinAbs) {
|
|
60020
|
-
relative5 =
|
|
59977
|
+
relative5 = path48.win32.relative(workspaceResolved, resolved);
|
|
60021
59978
|
} else {
|
|
60022
|
-
relative5 =
|
|
59979
|
+
relative5 = path48.relative(workspaceResolved, resolved);
|
|
60023
59980
|
}
|
|
60024
59981
|
if (relative5.startsWith("..")) {
|
|
60025
59982
|
return "path traversal detected";
|
|
@@ -60080,13 +60037,13 @@ async function runLintWrapped(files, directory, _config) {
|
|
|
60080
60037
|
}
|
|
60081
60038
|
async function runLintOnFiles(linter, files, workspaceDir) {
|
|
60082
60039
|
const isWindows = process.platform === "win32";
|
|
60083
|
-
const binDir =
|
|
60040
|
+
const binDir = path48.join(workspaceDir, "node_modules", ".bin");
|
|
60084
60041
|
const validatedFiles = [];
|
|
60085
60042
|
for (const file3 of files) {
|
|
60086
60043
|
if (typeof file3 !== "string") {
|
|
60087
60044
|
continue;
|
|
60088
60045
|
}
|
|
60089
|
-
const resolvedPath =
|
|
60046
|
+
const resolvedPath = path48.resolve(file3);
|
|
60090
60047
|
const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
|
|
60091
60048
|
if (validationError) {
|
|
60092
60049
|
continue;
|
|
@@ -60104,10 +60061,10 @@ async function runLintOnFiles(linter, files, workspaceDir) {
|
|
|
60104
60061
|
}
|
|
60105
60062
|
let command;
|
|
60106
60063
|
if (linter === "biome") {
|
|
60107
|
-
const biomeBin = isWindows ?
|
|
60064
|
+
const biomeBin = isWindows ? path48.join(binDir, "biome.EXE") : path48.join(binDir, "biome");
|
|
60108
60065
|
command = [biomeBin, "check", ...validatedFiles];
|
|
60109
60066
|
} else {
|
|
60110
|
-
const eslintBin = isWindows ?
|
|
60067
|
+
const eslintBin = isWindows ? path48.join(binDir, "eslint.cmd") : path48.join(binDir, "eslint");
|
|
60111
60068
|
command = [eslintBin, ...validatedFiles];
|
|
60112
60069
|
}
|
|
60113
60070
|
try {
|
|
@@ -60244,7 +60201,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
60244
60201
|
skippedFiles++;
|
|
60245
60202
|
continue;
|
|
60246
60203
|
}
|
|
60247
|
-
const resolvedPath =
|
|
60204
|
+
const resolvedPath = path48.resolve(file3);
|
|
60248
60205
|
const validationError = validatePath(resolvedPath, directory, directory);
|
|
60249
60206
|
if (validationError) {
|
|
60250
60207
|
skippedFiles++;
|
|
@@ -60262,7 +60219,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
60262
60219
|
};
|
|
60263
60220
|
}
|
|
60264
60221
|
for (const file3 of validatedFiles) {
|
|
60265
|
-
const ext =
|
|
60222
|
+
const ext = path48.extname(file3).toLowerCase();
|
|
60266
60223
|
if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
|
|
60267
60224
|
skippedFiles++;
|
|
60268
60225
|
continue;
|
|
@@ -60421,7 +60378,7 @@ async function runPreCheckBatch(input, workspaceDir) {
|
|
|
60421
60378
|
warn(`pre_check_batch: Invalid file path: ${file3}`);
|
|
60422
60379
|
continue;
|
|
60423
60380
|
}
|
|
60424
|
-
changedFiles.push(
|
|
60381
|
+
changedFiles.push(path48.resolve(directory, file3));
|
|
60425
60382
|
}
|
|
60426
60383
|
if (changedFiles.length === 0) {
|
|
60427
60384
|
warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
|
|
@@ -60572,7 +60529,7 @@ var pre_check_batch = createSwarmTool({
|
|
|
60572
60529
|
};
|
|
60573
60530
|
return JSON.stringify(errorResult, null, 2);
|
|
60574
60531
|
}
|
|
60575
|
-
const resolvedDirectory =
|
|
60532
|
+
const resolvedDirectory = path48.resolve(typedArgs.directory);
|
|
60576
60533
|
const workspaceAnchor = resolvedDirectory;
|
|
60577
60534
|
const dirError = validateDirectory3(resolvedDirectory, workspaceAnchor);
|
|
60578
60535
|
if (dirError) {
|
|
@@ -60680,7 +60637,7 @@ init_tool();
|
|
|
60680
60637
|
init_manager2();
|
|
60681
60638
|
init_create_tool();
|
|
60682
60639
|
import * as fs36 from "fs";
|
|
60683
|
-
import * as
|
|
60640
|
+
import * as path49 from "path";
|
|
60684
60641
|
function detectPlaceholderContent(args2) {
|
|
60685
60642
|
const issues = [];
|
|
60686
60643
|
const placeholderPattern = /^\[\w[\w\s]*\]$/;
|
|
@@ -60784,7 +60741,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
60784
60741
|
try {
|
|
60785
60742
|
await savePlan(dir, plan);
|
|
60786
60743
|
try {
|
|
60787
|
-
const markerPath =
|
|
60744
|
+
const markerPath = path49.join(dir, ".swarm", ".plan-write-marker");
|
|
60788
60745
|
const marker = JSON.stringify({
|
|
60789
60746
|
source: "save_plan",
|
|
60790
60747
|
timestamp: new Date().toISOString(),
|
|
@@ -60796,7 +60753,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
60796
60753
|
return {
|
|
60797
60754
|
success: true,
|
|
60798
60755
|
message: "Plan saved successfully",
|
|
60799
|
-
plan_path:
|
|
60756
|
+
plan_path: path49.join(dir, ".swarm", "plan.json"),
|
|
60800
60757
|
phases_count: plan.phases.length,
|
|
60801
60758
|
tasks_count: tasksCount
|
|
60802
60759
|
};
|
|
@@ -60835,7 +60792,7 @@ var save_plan = createSwarmTool({
|
|
|
60835
60792
|
init_dist();
|
|
60836
60793
|
init_manager();
|
|
60837
60794
|
import * as fs37 from "fs";
|
|
60838
|
-
import * as
|
|
60795
|
+
import * as path50 from "path";
|
|
60839
60796
|
|
|
60840
60797
|
// src/sbom/detectors/index.ts
|
|
60841
60798
|
init_utils();
|
|
@@ -61683,7 +61640,7 @@ function findManifestFiles(rootDir) {
|
|
|
61683
61640
|
try {
|
|
61684
61641
|
const entries = fs37.readdirSync(dir, { withFileTypes: true });
|
|
61685
61642
|
for (const entry of entries) {
|
|
61686
|
-
const fullPath =
|
|
61643
|
+
const fullPath = path50.join(dir, entry.name);
|
|
61687
61644
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
|
|
61688
61645
|
continue;
|
|
61689
61646
|
}
|
|
@@ -61692,7 +61649,7 @@ function findManifestFiles(rootDir) {
|
|
|
61692
61649
|
} else if (entry.isFile()) {
|
|
61693
61650
|
for (const pattern of patterns) {
|
|
61694
61651
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
61695
|
-
manifestFiles.push(
|
|
61652
|
+
manifestFiles.push(path50.relative(rootDir, fullPath));
|
|
61696
61653
|
break;
|
|
61697
61654
|
}
|
|
61698
61655
|
}
|
|
@@ -61710,11 +61667,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
61710
61667
|
try {
|
|
61711
61668
|
const entries = fs37.readdirSync(dir, { withFileTypes: true });
|
|
61712
61669
|
for (const entry of entries) {
|
|
61713
|
-
const fullPath =
|
|
61670
|
+
const fullPath = path50.join(dir, entry.name);
|
|
61714
61671
|
if (entry.isFile()) {
|
|
61715
61672
|
for (const pattern of patterns) {
|
|
61716
61673
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
61717
|
-
found.push(
|
|
61674
|
+
found.push(path50.relative(workingDir, fullPath));
|
|
61718
61675
|
break;
|
|
61719
61676
|
}
|
|
61720
61677
|
}
|
|
@@ -61727,11 +61684,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
61727
61684
|
function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
|
|
61728
61685
|
const dirs = new Set;
|
|
61729
61686
|
for (const file3 of changedFiles) {
|
|
61730
|
-
let currentDir =
|
|
61687
|
+
let currentDir = path50.dirname(file3);
|
|
61731
61688
|
while (true) {
|
|
61732
|
-
if (currentDir && currentDir !== "." && currentDir !==
|
|
61733
|
-
dirs.add(
|
|
61734
|
-
const parent =
|
|
61689
|
+
if (currentDir && currentDir !== "." && currentDir !== path50.sep) {
|
|
61690
|
+
dirs.add(path50.join(workingDir, currentDir));
|
|
61691
|
+
const parent = path50.dirname(currentDir);
|
|
61735
61692
|
if (parent === currentDir)
|
|
61736
61693
|
break;
|
|
61737
61694
|
currentDir = parent;
|
|
@@ -61815,7 +61772,7 @@ var sbom_generate = createSwarmTool({
|
|
|
61815
61772
|
const changedFiles = obj.changed_files;
|
|
61816
61773
|
const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
|
|
61817
61774
|
const workingDir = directory;
|
|
61818
|
-
const outputDir =
|
|
61775
|
+
const outputDir = path50.isAbsolute(relativeOutputDir) ? relativeOutputDir : path50.join(workingDir, relativeOutputDir);
|
|
61819
61776
|
let manifestFiles = [];
|
|
61820
61777
|
if (scope === "all") {
|
|
61821
61778
|
manifestFiles = findManifestFiles(workingDir);
|
|
@@ -61838,7 +61795,7 @@ var sbom_generate = createSwarmTool({
|
|
|
61838
61795
|
const processedFiles = [];
|
|
61839
61796
|
for (const manifestFile of manifestFiles) {
|
|
61840
61797
|
try {
|
|
61841
|
-
const fullPath =
|
|
61798
|
+
const fullPath = path50.isAbsolute(manifestFile) ? manifestFile : path50.join(workingDir, manifestFile);
|
|
61842
61799
|
if (!fs37.existsSync(fullPath)) {
|
|
61843
61800
|
continue;
|
|
61844
61801
|
}
|
|
@@ -61855,7 +61812,7 @@ var sbom_generate = createSwarmTool({
|
|
|
61855
61812
|
const bom = generateCycloneDX(allComponents);
|
|
61856
61813
|
const bomJson = serializeCycloneDX(bom);
|
|
61857
61814
|
const filename = generateSbomFilename();
|
|
61858
|
-
const outputPath =
|
|
61815
|
+
const outputPath = path50.join(outputDir, filename);
|
|
61859
61816
|
fs37.writeFileSync(outputPath, bomJson, "utf-8");
|
|
61860
61817
|
const verdict = processedFiles.length > 0 ? "pass" : "pass";
|
|
61861
61818
|
try {
|
|
@@ -61899,7 +61856,7 @@ var sbom_generate = createSwarmTool({
|
|
|
61899
61856
|
init_dist();
|
|
61900
61857
|
init_create_tool();
|
|
61901
61858
|
import * as fs38 from "fs";
|
|
61902
|
-
import * as
|
|
61859
|
+
import * as path51 from "path";
|
|
61903
61860
|
var SPEC_CANDIDATES = [
|
|
61904
61861
|
"openapi.json",
|
|
61905
61862
|
"openapi.yaml",
|
|
@@ -61931,12 +61888,12 @@ function normalizePath2(p) {
|
|
|
61931
61888
|
}
|
|
61932
61889
|
function discoverSpecFile(cwd, specFileArg) {
|
|
61933
61890
|
if (specFileArg) {
|
|
61934
|
-
const resolvedPath =
|
|
61935
|
-
const normalizedCwd = cwd.endsWith(
|
|
61891
|
+
const resolvedPath = path51.resolve(cwd, specFileArg);
|
|
61892
|
+
const normalizedCwd = cwd.endsWith(path51.sep) ? cwd : cwd + path51.sep;
|
|
61936
61893
|
if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
|
|
61937
61894
|
throw new Error("Invalid spec_file: path traversal detected");
|
|
61938
61895
|
}
|
|
61939
|
-
const ext =
|
|
61896
|
+
const ext = path51.extname(resolvedPath).toLowerCase();
|
|
61940
61897
|
if (!ALLOWED_EXTENSIONS.includes(ext)) {
|
|
61941
61898
|
throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
|
|
61942
61899
|
}
|
|
@@ -61950,7 +61907,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
61950
61907
|
return resolvedPath;
|
|
61951
61908
|
}
|
|
61952
61909
|
for (const candidate of SPEC_CANDIDATES) {
|
|
61953
|
-
const candidatePath =
|
|
61910
|
+
const candidatePath = path51.resolve(cwd, candidate);
|
|
61954
61911
|
if (fs38.existsSync(candidatePath)) {
|
|
61955
61912
|
const stats = fs38.statSync(candidatePath);
|
|
61956
61913
|
if (stats.size <= MAX_SPEC_SIZE) {
|
|
@@ -61962,7 +61919,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
61962
61919
|
}
|
|
61963
61920
|
function parseSpec(specFile) {
|
|
61964
61921
|
const content = fs38.readFileSync(specFile, "utf-8");
|
|
61965
|
-
const ext =
|
|
61922
|
+
const ext = path51.extname(specFile).toLowerCase();
|
|
61966
61923
|
if (ext === ".json") {
|
|
61967
61924
|
return parseJsonSpec(content);
|
|
61968
61925
|
}
|
|
@@ -62038,7 +61995,7 @@ function extractRoutes(cwd) {
|
|
|
62038
61995
|
return;
|
|
62039
61996
|
}
|
|
62040
61997
|
for (const entry of entries) {
|
|
62041
|
-
const fullPath =
|
|
61998
|
+
const fullPath = path51.join(dir, entry.name);
|
|
62042
61999
|
if (entry.isSymbolicLink()) {
|
|
62043
62000
|
continue;
|
|
62044
62001
|
}
|
|
@@ -62048,7 +62005,7 @@ function extractRoutes(cwd) {
|
|
|
62048
62005
|
}
|
|
62049
62006
|
walkDir(fullPath);
|
|
62050
62007
|
} else if (entry.isFile()) {
|
|
62051
|
-
const ext =
|
|
62008
|
+
const ext = path51.extname(entry.name).toLowerCase();
|
|
62052
62009
|
const baseName = entry.name.toLowerCase();
|
|
62053
62010
|
if (![".ts", ".js", ".mjs"].includes(ext)) {
|
|
62054
62011
|
continue;
|
|
@@ -62218,7 +62175,7 @@ init_secretscan();
|
|
|
62218
62175
|
init_tool();
|
|
62219
62176
|
init_create_tool();
|
|
62220
62177
|
import * as fs39 from "fs";
|
|
62221
|
-
import * as
|
|
62178
|
+
import * as path52 from "path";
|
|
62222
62179
|
var MAX_FILE_SIZE_BYTES7 = 1024 * 1024;
|
|
62223
62180
|
var WINDOWS_RESERVED_NAMES = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
62224
62181
|
function containsControlCharacters(str) {
|
|
@@ -62247,11 +62204,11 @@ function containsWindowsAttacks(str) {
|
|
|
62247
62204
|
}
|
|
62248
62205
|
function isPathInWorkspace(filePath, workspace) {
|
|
62249
62206
|
try {
|
|
62250
|
-
const resolvedPath =
|
|
62207
|
+
const resolvedPath = path52.resolve(workspace, filePath);
|
|
62251
62208
|
const realWorkspace = fs39.realpathSync(workspace);
|
|
62252
62209
|
const realResolvedPath = fs39.realpathSync(resolvedPath);
|
|
62253
|
-
const relativePath =
|
|
62254
|
-
if (relativePath.startsWith("..") ||
|
|
62210
|
+
const relativePath = path52.relative(realWorkspace, realResolvedPath);
|
|
62211
|
+
if (relativePath.startsWith("..") || path52.isAbsolute(relativePath)) {
|
|
62255
62212
|
return false;
|
|
62256
62213
|
}
|
|
62257
62214
|
return true;
|
|
@@ -62263,7 +62220,7 @@ function validatePathForRead(filePath, workspace) {
|
|
|
62263
62220
|
return isPathInWorkspace(filePath, workspace);
|
|
62264
62221
|
}
|
|
62265
62222
|
function extractTSSymbols(filePath, cwd) {
|
|
62266
|
-
const fullPath =
|
|
62223
|
+
const fullPath = path52.join(cwd, filePath);
|
|
62267
62224
|
if (!validatePathForRead(fullPath, cwd)) {
|
|
62268
62225
|
return [];
|
|
62269
62226
|
}
|
|
@@ -62415,7 +62372,7 @@ function extractTSSymbols(filePath, cwd) {
|
|
|
62415
62372
|
});
|
|
62416
62373
|
}
|
|
62417
62374
|
function extractPythonSymbols(filePath, cwd) {
|
|
62418
|
-
const fullPath =
|
|
62375
|
+
const fullPath = path52.join(cwd, filePath);
|
|
62419
62376
|
if (!validatePathForRead(fullPath, cwd)) {
|
|
62420
62377
|
return [];
|
|
62421
62378
|
}
|
|
@@ -62498,7 +62455,7 @@ var symbols = createSwarmTool({
|
|
|
62498
62455
|
}, null, 2);
|
|
62499
62456
|
}
|
|
62500
62457
|
const cwd = directory;
|
|
62501
|
-
const ext =
|
|
62458
|
+
const ext = path52.extname(file3);
|
|
62502
62459
|
if (containsControlCharacters(file3)) {
|
|
62503
62460
|
return JSON.stringify({
|
|
62504
62461
|
file: file3,
|
|
@@ -62570,7 +62527,7 @@ init_dist();
|
|
|
62570
62527
|
init_utils();
|
|
62571
62528
|
init_create_tool();
|
|
62572
62529
|
import * as fs40 from "fs";
|
|
62573
|
-
import * as
|
|
62530
|
+
import * as path53 from "path";
|
|
62574
62531
|
var MAX_TEXT_LENGTH = 200;
|
|
62575
62532
|
var MAX_FILE_SIZE_BYTES8 = 1024 * 1024;
|
|
62576
62533
|
var SUPPORTED_EXTENSIONS2 = new Set([
|
|
@@ -62641,9 +62598,9 @@ function validatePathsInput(paths, cwd) {
|
|
|
62641
62598
|
return { error: "paths contains path traversal", resolvedPath: null };
|
|
62642
62599
|
}
|
|
62643
62600
|
try {
|
|
62644
|
-
const resolvedPath =
|
|
62645
|
-
const normalizedCwd =
|
|
62646
|
-
const normalizedResolved =
|
|
62601
|
+
const resolvedPath = path53.resolve(paths);
|
|
62602
|
+
const normalizedCwd = path53.resolve(cwd);
|
|
62603
|
+
const normalizedResolved = path53.resolve(resolvedPath);
|
|
62647
62604
|
if (!normalizedResolved.startsWith(normalizedCwd)) {
|
|
62648
62605
|
return {
|
|
62649
62606
|
error: "paths must be within the current working directory",
|
|
@@ -62659,7 +62616,7 @@ function validatePathsInput(paths, cwd) {
|
|
|
62659
62616
|
}
|
|
62660
62617
|
}
|
|
62661
62618
|
function isSupportedExtension(filePath) {
|
|
62662
|
-
const ext =
|
|
62619
|
+
const ext = path53.extname(filePath).toLowerCase();
|
|
62663
62620
|
return SUPPORTED_EXTENSIONS2.has(ext);
|
|
62664
62621
|
}
|
|
62665
62622
|
function findSourceFiles2(dir, files = []) {
|
|
@@ -62674,7 +62631,7 @@ function findSourceFiles2(dir, files = []) {
|
|
|
62674
62631
|
if (SKIP_DIRECTORIES3.has(entry)) {
|
|
62675
62632
|
continue;
|
|
62676
62633
|
}
|
|
62677
|
-
const fullPath =
|
|
62634
|
+
const fullPath = path53.join(dir, entry);
|
|
62678
62635
|
let stat2;
|
|
62679
62636
|
try {
|
|
62680
62637
|
stat2 = fs40.statSync(fullPath);
|
|
@@ -62786,7 +62743,7 @@ var todo_extract = createSwarmTool({
|
|
|
62786
62743
|
filesToScan.push(scanPath);
|
|
62787
62744
|
} else {
|
|
62788
62745
|
const errorResult = {
|
|
62789
|
-
error: `unsupported file extension: ${
|
|
62746
|
+
error: `unsupported file extension: ${path53.extname(scanPath)}`,
|
|
62790
62747
|
total: 0,
|
|
62791
62748
|
byPriority: { high: 0, medium: 0, low: 0 },
|
|
62792
62749
|
entries: []
|
|
@@ -62832,14 +62789,14 @@ var todo_extract = createSwarmTool({
|
|
|
62832
62789
|
init_tool();
|
|
62833
62790
|
init_schema();
|
|
62834
62791
|
import * as fs42 from "fs";
|
|
62835
|
-
import * as
|
|
62792
|
+
import * as path55 from "path";
|
|
62836
62793
|
|
|
62837
62794
|
// src/hooks/diff-scope.ts
|
|
62838
62795
|
import * as fs41 from "fs";
|
|
62839
|
-
import * as
|
|
62796
|
+
import * as path54 from "path";
|
|
62840
62797
|
function getDeclaredScope(taskId, directory) {
|
|
62841
62798
|
try {
|
|
62842
|
-
const planPath =
|
|
62799
|
+
const planPath = path54.join(directory, ".swarm", "plan.json");
|
|
62843
62800
|
if (!fs41.existsSync(planPath))
|
|
62844
62801
|
return null;
|
|
62845
62802
|
const raw = fs41.readFileSync(planPath, "utf-8");
|
|
@@ -62954,7 +62911,7 @@ var TIER_3_PATTERNS = [
|
|
|
62954
62911
|
];
|
|
62955
62912
|
function matchesTier3Pattern(files) {
|
|
62956
62913
|
for (const file3 of files) {
|
|
62957
|
-
const fileName =
|
|
62914
|
+
const fileName = path55.basename(file3);
|
|
62958
62915
|
for (const pattern of TIER_3_PATTERNS) {
|
|
62959
62916
|
if (pattern.test(fileName)) {
|
|
62960
62917
|
return true;
|
|
@@ -62976,7 +62933,7 @@ function checkReviewerGate(taskId, workingDirectory) {
|
|
|
62976
62933
|
if (hasActiveTurboMode2()) {
|
|
62977
62934
|
const resolvedDir2 = workingDirectory ?? process.cwd();
|
|
62978
62935
|
try {
|
|
62979
|
-
const planPath =
|
|
62936
|
+
const planPath = path55.join(resolvedDir2, ".swarm", "plan.json");
|
|
62980
62937
|
const planRaw = fs42.readFileSync(planPath, "utf-8");
|
|
62981
62938
|
const plan = JSON.parse(planRaw);
|
|
62982
62939
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -62996,7 +62953,7 @@ function checkReviewerGate(taskId, workingDirectory) {
|
|
|
62996
62953
|
}
|
|
62997
62954
|
const resolvedDir = workingDirectory ?? process.cwd();
|
|
62998
62955
|
try {
|
|
62999
|
-
const evidencePath =
|
|
62956
|
+
const evidencePath = path55.join(resolvedDir, ".swarm", "evidence", `${taskId}.json`);
|
|
63000
62957
|
const raw = fs42.readFileSync(evidencePath, "utf-8");
|
|
63001
62958
|
const evidence = JSON.parse(raw);
|
|
63002
62959
|
if (evidence?.required_gates && Array.isArray(evidence.required_gates) && evidence?.gates) {
|
|
@@ -63037,7 +62994,7 @@ function checkReviewerGate(taskId, workingDirectory) {
|
|
|
63037
62994
|
}
|
|
63038
62995
|
try {
|
|
63039
62996
|
const resolvedDir2 = workingDirectory ?? process.cwd();
|
|
63040
|
-
const planPath =
|
|
62997
|
+
const planPath = path55.join(resolvedDir2, ".swarm", "plan.json");
|
|
63041
62998
|
const planRaw = fs42.readFileSync(planPath, "utf-8");
|
|
63042
62999
|
const plan = JSON.parse(planRaw);
|
|
63043
63000
|
for (const planPhase of plan.phases ?? []) {
|
|
@@ -63219,8 +63176,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
63219
63176
|
};
|
|
63220
63177
|
}
|
|
63221
63178
|
}
|
|
63222
|
-
normalizedDir =
|
|
63223
|
-
const pathParts = normalizedDir.split(
|
|
63179
|
+
normalizedDir = path55.normalize(args2.working_directory);
|
|
63180
|
+
const pathParts = normalizedDir.split(path55.sep);
|
|
63224
63181
|
if (pathParts.includes("..")) {
|
|
63225
63182
|
return {
|
|
63226
63183
|
success: false,
|
|
@@ -63230,10 +63187,10 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
63230
63187
|
]
|
|
63231
63188
|
};
|
|
63232
63189
|
}
|
|
63233
|
-
const resolvedDir =
|
|
63190
|
+
const resolvedDir = path55.resolve(normalizedDir);
|
|
63234
63191
|
try {
|
|
63235
63192
|
const realPath = fs42.realpathSync(resolvedDir);
|
|
63236
|
-
const planPath =
|
|
63193
|
+
const planPath = path55.join(realPath, ".swarm", "plan.json");
|
|
63237
63194
|
if (!fs42.existsSync(planPath)) {
|
|
63238
63195
|
return {
|
|
63239
63196
|
success: false,
|
|
@@ -63428,7 +63385,7 @@ var OpenCodeSwarm = async (ctx) => {
|
|
|
63428
63385
|
const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
|
|
63429
63386
|
preflightTriggerManager = new PTM(automationConfig);
|
|
63430
63387
|
const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
|
|
63431
|
-
const swarmDir =
|
|
63388
|
+
const swarmDir = path56.resolve(ctx.directory, ".swarm");
|
|
63432
63389
|
statusArtifact = new ASA(swarmDir);
|
|
63433
63390
|
statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
|
|
63434
63391
|
if (automationConfig.capabilities?.evidence_auto_summaries === true) {
|
|
@@ -21,14 +21,6 @@ export declare function readSnapshot(directory: string): Promise<SnapshotData |
|
|
|
21
21
|
* Does NOT touch activeToolCalls or pendingEvents (remain at defaults).
|
|
22
22
|
*/
|
|
23
23
|
export declare function rehydrateState(snapshot: SnapshotData): void;
|
|
24
|
-
/**
|
|
25
|
-
* Reconcile task workflow states from plan.json for all active sessions.
|
|
26
|
-
* Seeds completed plan tasks to 'tests_run' and in_progress tasks to 'coder_delegated'.
|
|
27
|
-
* Best-effort: returns silently on any file/parse error. NEVER throws.
|
|
28
|
-
*
|
|
29
|
-
* @param directory - The project root directory containing .swarm/plan.json
|
|
30
|
-
*/
|
|
31
|
-
export declare function reconcileTaskStatesFromPlan(directory: string): Promise<void>;
|
|
32
24
|
/**
|
|
33
25
|
* Load snapshot from disk and rehydrate swarmState.
|
|
34
26
|
* Called on plugin init to restore state from previous session.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.30.0",
|
|
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",
|