opencode-swarm 6.70.0 → 6.71.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/cli/index.js +3 -1
- package/dist/config/schema.d.ts +4 -0
- package/dist/hooks/guardrails.d.ts +7 -0
- package/dist/index.js +725 -670
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15030,7 +15030,9 @@ var init_schema = __esm(() => {
|
|
|
15030
15030
|
require_reviewer_test_engineer: exports_external.boolean().default(true)
|
|
15031
15031
|
}).optional(),
|
|
15032
15032
|
profiles: exports_external.record(exports_external.string(), GuardrailsProfileSchema).optional(),
|
|
15033
|
-
block_destructive_commands: exports_external.boolean().default(true)
|
|
15033
|
+
block_destructive_commands: exports_external.boolean().default(true),
|
|
15034
|
+
interpreter_allowed_agents: exports_external.array(exports_external.string().min(1)).optional(),
|
|
15035
|
+
shell_audit_log: exports_external.boolean().default(true)
|
|
15034
15036
|
});
|
|
15035
15037
|
WatchdogConfigSchema = exports_external.object({
|
|
15036
15038
|
scope_guard: exports_external.boolean().default(true),
|
|
@@ -20442,6 +20444,7 @@ var init_normalize_tool_name = __esm(() => {
|
|
|
20442
20444
|
|
|
20443
20445
|
// src/hooks/guardrails.ts
|
|
20444
20446
|
import * as fsSync from "fs";
|
|
20447
|
+
import * as fs6 from "fs/promises";
|
|
20445
20448
|
import * as path7 from "path";
|
|
20446
20449
|
function getStoredInputArgs(callID) {
|
|
20447
20450
|
return storedInputArgs.get(callID);
|
|
@@ -20823,6 +20826,16 @@ function dcExtractPowerShellTargets(segment) {
|
|
|
20823
20826
|
}
|
|
20824
20827
|
return targets;
|
|
20825
20828
|
}
|
|
20829
|
+
function redactShellCommand(cmd) {
|
|
20830
|
+
if (typeof cmd !== "string")
|
|
20831
|
+
return "";
|
|
20832
|
+
let out2 = cmd.replace(/\b([A-Z_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|API[_]?KEY|APIKEY|AUTH|CREDENTIAL|PRIVATE[_]?KEY|ACCESS[_]?KEY)[A-Z_0-9]*)\s*=\s*(\S+)/gi, "$1=[REDACTED]");
|
|
20833
|
+
out2 = out2.replace(/--([a-zA-Z-]*(?:token|secret|password|passwd|api[_-]?key|apikey|auth|credential|private[_-]?key|access[_-]?key)[a-zA-Z-]*)=(\S+)/gi, "--$1=[REDACTED]");
|
|
20834
|
+
out2 = out2.replace(/(--[a-zA-Z-]*(?:token|secret|password|passwd|api[_-]?key|apikey|auth|credential|private[_-]?key|access[_-]?key)[a-zA-Z-]*)(\s+)(?!--)(\S+)/gi, "$1$2[REDACTED]");
|
|
20835
|
+
out2 = out2.replace(/\b(Bearer|Basic)\s+[A-Za-z0-9+/=._-]{4,}/gi, "$1 [REDACTED]");
|
|
20836
|
+
out2 = out2.replace(/(-H\s+['"]?(?:Authorization|X-API-Key|X-Auth-Token):\s*)([^'">\s][^'">\n]*)(['"]?)/gi, "$1[REDACTED]$3");
|
|
20837
|
+
return out2;
|
|
20838
|
+
}
|
|
20826
20839
|
function createGuardrailsHooks(directory, directoryOrConfig, config2, authorityConfig) {
|
|
20827
20840
|
let guardrailsConfig;
|
|
20828
20841
|
if (directory && typeof directory === "object" && "enabled" in directory) {
|
|
@@ -20852,6 +20865,46 @@ function createGuardrailsHooks(directory, directoryOrConfig, config2, authorityC
|
|
|
20852
20865
|
"pre_check_batch"
|
|
20853
20866
|
];
|
|
20854
20867
|
const requireReviewerAndTestEngineer = cfg.qa_gates?.require_reviewer_test_engineer ?? true;
|
|
20868
|
+
const interpreterAllowedAgents = cfg.interpreter_allowed_agents;
|
|
20869
|
+
const shellAuditEnabled = cfg.shell_audit_log ?? true;
|
|
20870
|
+
const shellAuditPath = path7.join(effectiveDirectory, ".swarm", "session", "shell-audit.jsonl");
|
|
20871
|
+
function handleInterpreterGating(sessionID, tool) {
|
|
20872
|
+
const normalizedTool = normalizeToolName(tool).toLowerCase();
|
|
20873
|
+
if (normalizedTool !== "bash" && normalizedTool !== "shell")
|
|
20874
|
+
return;
|
|
20875
|
+
if (!interpreterAllowedAgents)
|
|
20876
|
+
return;
|
|
20877
|
+
const rawAgent = swarmState.activeAgent.get(sessionID);
|
|
20878
|
+
const agentRole = rawAgent ? stripKnownSwarmPrefix(rawAgent).toLowerCase() : "unknown";
|
|
20879
|
+
const allowed = interpreterAllowedAgents.some((a) => a.toLowerCase() === agentRole);
|
|
20880
|
+
if (!allowed) {
|
|
20881
|
+
throw new Error(`BLOCKED: Agent "${agentRole}" is not permitted to use the bash/shell interpreter. ` + `Allowed agents: [${interpreterAllowedAgents.map((a) => `"${a}"`).join(", ")}]`);
|
|
20882
|
+
}
|
|
20883
|
+
}
|
|
20884
|
+
async function appendShellAuditLog(sessionID, tool, args2) {
|
|
20885
|
+
if (!shellAuditEnabled)
|
|
20886
|
+
return;
|
|
20887
|
+
const normalizedAuditTool = normalizeToolName(tool).toLowerCase();
|
|
20888
|
+
if (normalizedAuditTool !== "bash" && normalizedAuditTool !== "shell")
|
|
20889
|
+
return;
|
|
20890
|
+
const bashArgs = args2;
|
|
20891
|
+
const rawCmd = typeof bashArgs?.command === "string" ? bashArgs.command : "";
|
|
20892
|
+
const redacted = redactShellCommand(rawCmd);
|
|
20893
|
+
const rawAgent = swarmState.activeAgent.get(sessionID);
|
|
20894
|
+
const agentRole = rawAgent ? stripKnownSwarmPrefix(rawAgent) : "unknown";
|
|
20895
|
+
const entry = JSON.stringify({
|
|
20896
|
+
ts: new Date().toISOString(),
|
|
20897
|
+
sessionID,
|
|
20898
|
+
agent: agentRole,
|
|
20899
|
+
tool,
|
|
20900
|
+
command: redacted
|
|
20901
|
+
});
|
|
20902
|
+
try {
|
|
20903
|
+
await fs6.mkdir(path7.dirname(shellAuditPath), { recursive: true });
|
|
20904
|
+
await fs6.appendFile(shellAuditPath, `${entry}
|
|
20905
|
+
`, "utf-8");
|
|
20906
|
+
} catch {}
|
|
20907
|
+
}
|
|
20855
20908
|
function checkDestructiveCommand(tool, args2) {
|
|
20856
20909
|
if (tool !== "bash" && tool !== "shell")
|
|
20857
20910
|
return;
|
|
@@ -21366,6 +21419,8 @@ function createGuardrailsHooks(directory, directoryOrConfig, config2, authorityC
|
|
|
21366
21419
|
handleDelegatedWriteTracking(input.sessionID, input.tool, output.args);
|
|
21367
21420
|
handleLoopDetection(input.sessionID, input.tool, output.args);
|
|
21368
21421
|
handleTestSuiteBlocking(input.tool, output.args);
|
|
21422
|
+
await appendShellAuditLog(input.sessionID, input.tool, output.args);
|
|
21423
|
+
handleInterpreterGating(input.sessionID, input.tool);
|
|
21369
21424
|
checkDestructiveCommand(input.tool, output.args);
|
|
21370
21425
|
if (isArchitect(input.sessionID) && isWriteTool(input.tool)) {
|
|
21371
21426
|
handlePlanAndScopeProtection(input.sessionID, input.tool, output.args);
|
|
@@ -22427,7 +22482,7 @@ var init_gate_evidence = __esm(() => {
|
|
|
22427
22482
|
});
|
|
22428
22483
|
|
|
22429
22484
|
// src/hooks/delegation-gate.ts
|
|
22430
|
-
import * as
|
|
22485
|
+
import * as fs7 from "fs";
|
|
22431
22486
|
import * as path9 from "path";
|
|
22432
22487
|
function clearPendingCoderScope() {
|
|
22433
22488
|
pendingCoderScopeByTaskId.clear();
|
|
@@ -22467,7 +22522,7 @@ async function getEvidenceTaskId(session, directory) {
|
|
|
22467
22522
|
if (!resolvedPlanPath.startsWith(resolvedDirectory + path9.sep) && resolvedPlanPath !== resolvedDirectory) {
|
|
22468
22523
|
return null;
|
|
22469
22524
|
}
|
|
22470
|
-
const planContent = await
|
|
22525
|
+
const planContent = await fs7.promises.readFile(resolvedPlanPath, "utf-8");
|
|
22471
22526
|
const plan = JSON.parse(planContent);
|
|
22472
22527
|
if (!plan || !Array.isArray(plan.phases)) {
|
|
22473
22528
|
return null;
|
|
@@ -23030,7 +23085,7 @@ __export(exports_state, {
|
|
|
23030
23085
|
applyRehydrationCache: () => applyRehydrationCache,
|
|
23031
23086
|
advanceTaskState: () => advanceTaskState
|
|
23032
23087
|
});
|
|
23033
|
-
import * as
|
|
23088
|
+
import * as fs8 from "fs/promises";
|
|
23034
23089
|
import * as path10 from "path";
|
|
23035
23090
|
function resetSwarmState() {
|
|
23036
23091
|
swarmState.activeToolCalls.clear();
|
|
@@ -23401,7 +23456,7 @@ function evidenceToWorkflowState(evidence) {
|
|
|
23401
23456
|
async function readPlanFromDisk(directory) {
|
|
23402
23457
|
try {
|
|
23403
23458
|
const planPath = path10.join(directory, ".swarm", "plan.json");
|
|
23404
|
-
const content = await
|
|
23459
|
+
const content = await fs8.readFile(planPath, "utf-8");
|
|
23405
23460
|
const parsed = JSON.parse(content);
|
|
23406
23461
|
return PlanSchema.parse(parsed);
|
|
23407
23462
|
} catch {
|
|
@@ -23412,7 +23467,7 @@ async function readGateEvidenceFromDisk(directory) {
|
|
|
23412
23467
|
const evidenceMap = new Map;
|
|
23413
23468
|
try {
|
|
23414
23469
|
const evidenceDir = path10.join(directory, ".swarm", "evidence");
|
|
23415
|
-
const entries = await
|
|
23470
|
+
const entries = await fs8.readdir(evidenceDir, { withFileTypes: true });
|
|
23416
23471
|
for (const entry of entries) {
|
|
23417
23472
|
if (!entry.isFile() || !entry.name.endsWith(".json")) {
|
|
23418
23473
|
continue;
|
|
@@ -23423,7 +23478,7 @@ async function readGateEvidenceFromDisk(directory) {
|
|
|
23423
23478
|
}
|
|
23424
23479
|
try {
|
|
23425
23480
|
const filePath = path10.join(evidenceDir, entry.name);
|
|
23426
|
-
const content = await
|
|
23481
|
+
const content = await fs8.readFile(filePath, "utf-8");
|
|
23427
23482
|
const parsed = JSON.parse(content);
|
|
23428
23483
|
if (parsed && typeof parsed.taskId === "string" && Array.isArray(parsed.required_gates)) {
|
|
23429
23484
|
evidenceMap.set(taskId, parsed);
|
|
@@ -36594,7 +36649,7 @@ __export(exports_checkpoint, {
|
|
|
36594
36649
|
checkpoint: () => checkpoint
|
|
36595
36650
|
});
|
|
36596
36651
|
import * as child_process from "child_process";
|
|
36597
|
-
import * as
|
|
36652
|
+
import * as fs9 from "fs";
|
|
36598
36653
|
import * as path11 from "path";
|
|
36599
36654
|
function containsNonAsciiChars(label) {
|
|
36600
36655
|
for (let i2 = 0;i2 < label.length; i2++) {
|
|
@@ -36644,8 +36699,8 @@ function getCheckpointLogPath(directory) {
|
|
|
36644
36699
|
function readCheckpointLog(directory) {
|
|
36645
36700
|
const logPath = getCheckpointLogPath(directory);
|
|
36646
36701
|
try {
|
|
36647
|
-
if (
|
|
36648
|
-
const content =
|
|
36702
|
+
if (fs9.existsSync(logPath)) {
|
|
36703
|
+
const content = fs9.readFileSync(logPath, "utf-8");
|
|
36649
36704
|
const parsed = JSON.parse(content);
|
|
36650
36705
|
if (!parsed.checkpoints || !Array.isArray(parsed.checkpoints)) {
|
|
36651
36706
|
return { version: 1, checkpoints: [] };
|
|
@@ -36658,12 +36713,12 @@ function readCheckpointLog(directory) {
|
|
|
36658
36713
|
function writeCheckpointLog(log2, directory) {
|
|
36659
36714
|
const logPath = getCheckpointLogPath(directory);
|
|
36660
36715
|
const dir = path11.dirname(logPath);
|
|
36661
|
-
if (!
|
|
36662
|
-
|
|
36716
|
+
if (!fs9.existsSync(dir)) {
|
|
36717
|
+
fs9.mkdirSync(dir, { recursive: true });
|
|
36663
36718
|
}
|
|
36664
36719
|
const tempPath = `${logPath}.tmp`;
|
|
36665
|
-
|
|
36666
|
-
|
|
36720
|
+
fs9.writeFileSync(tempPath, JSON.stringify(log2, null, 2), "utf-8");
|
|
36721
|
+
fs9.renameSync(tempPath, logPath);
|
|
36667
36722
|
}
|
|
36668
36723
|
function gitExec(args2) {
|
|
36669
36724
|
const result = child_process.spawnSync("git", args2, {
|
|
@@ -37083,54 +37138,54 @@ var require_polyfills = __commonJS((exports, module2) => {
|
|
|
37083
37138
|
}
|
|
37084
37139
|
var chdir;
|
|
37085
37140
|
module2.exports = patch;
|
|
37086
|
-
function patch(
|
|
37141
|
+
function patch(fs10) {
|
|
37087
37142
|
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
37088
|
-
patchLchmod(
|
|
37089
|
-
}
|
|
37090
|
-
if (!
|
|
37091
|
-
patchLutimes(
|
|
37092
|
-
}
|
|
37093
|
-
|
|
37094
|
-
|
|
37095
|
-
|
|
37096
|
-
|
|
37097
|
-
|
|
37098
|
-
|
|
37099
|
-
|
|
37100
|
-
|
|
37101
|
-
|
|
37102
|
-
|
|
37103
|
-
|
|
37104
|
-
|
|
37105
|
-
|
|
37106
|
-
|
|
37107
|
-
|
|
37108
|
-
|
|
37109
|
-
|
|
37110
|
-
|
|
37111
|
-
if (
|
|
37112
|
-
|
|
37143
|
+
patchLchmod(fs10);
|
|
37144
|
+
}
|
|
37145
|
+
if (!fs10.lutimes) {
|
|
37146
|
+
patchLutimes(fs10);
|
|
37147
|
+
}
|
|
37148
|
+
fs10.chown = chownFix(fs10.chown);
|
|
37149
|
+
fs10.fchown = chownFix(fs10.fchown);
|
|
37150
|
+
fs10.lchown = chownFix(fs10.lchown);
|
|
37151
|
+
fs10.chmod = chmodFix(fs10.chmod);
|
|
37152
|
+
fs10.fchmod = chmodFix(fs10.fchmod);
|
|
37153
|
+
fs10.lchmod = chmodFix(fs10.lchmod);
|
|
37154
|
+
fs10.chownSync = chownFixSync(fs10.chownSync);
|
|
37155
|
+
fs10.fchownSync = chownFixSync(fs10.fchownSync);
|
|
37156
|
+
fs10.lchownSync = chownFixSync(fs10.lchownSync);
|
|
37157
|
+
fs10.chmodSync = chmodFixSync(fs10.chmodSync);
|
|
37158
|
+
fs10.fchmodSync = chmodFixSync(fs10.fchmodSync);
|
|
37159
|
+
fs10.lchmodSync = chmodFixSync(fs10.lchmodSync);
|
|
37160
|
+
fs10.stat = statFix(fs10.stat);
|
|
37161
|
+
fs10.fstat = statFix(fs10.fstat);
|
|
37162
|
+
fs10.lstat = statFix(fs10.lstat);
|
|
37163
|
+
fs10.statSync = statFixSync(fs10.statSync);
|
|
37164
|
+
fs10.fstatSync = statFixSync(fs10.fstatSync);
|
|
37165
|
+
fs10.lstatSync = statFixSync(fs10.lstatSync);
|
|
37166
|
+
if (fs10.chmod && !fs10.lchmod) {
|
|
37167
|
+
fs10.lchmod = function(path12, mode, cb) {
|
|
37113
37168
|
if (cb)
|
|
37114
37169
|
process.nextTick(cb);
|
|
37115
37170
|
};
|
|
37116
|
-
|
|
37171
|
+
fs10.lchmodSync = function() {};
|
|
37117
37172
|
}
|
|
37118
|
-
if (
|
|
37119
|
-
|
|
37173
|
+
if (fs10.chown && !fs10.lchown) {
|
|
37174
|
+
fs10.lchown = function(path12, uid, gid, cb) {
|
|
37120
37175
|
if (cb)
|
|
37121
37176
|
process.nextTick(cb);
|
|
37122
37177
|
};
|
|
37123
|
-
|
|
37178
|
+
fs10.lchownSync = function() {};
|
|
37124
37179
|
}
|
|
37125
37180
|
if (platform === "win32") {
|
|
37126
|
-
|
|
37181
|
+
fs10.rename = typeof fs10.rename !== "function" ? fs10.rename : function(fs$rename) {
|
|
37127
37182
|
function rename2(from, to, cb) {
|
|
37128
37183
|
var start2 = Date.now();
|
|
37129
37184
|
var backoff = 0;
|
|
37130
37185
|
fs$rename(from, to, function CB(er) {
|
|
37131
37186
|
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start2 < 60000) {
|
|
37132
37187
|
setTimeout(function() {
|
|
37133
|
-
|
|
37188
|
+
fs10.stat(to, function(stater, st) {
|
|
37134
37189
|
if (stater && stater.code === "ENOENT")
|
|
37135
37190
|
fs$rename(from, to, CB);
|
|
37136
37191
|
else
|
|
@@ -37148,9 +37203,9 @@ var require_polyfills = __commonJS((exports, module2) => {
|
|
|
37148
37203
|
if (Object.setPrototypeOf)
|
|
37149
37204
|
Object.setPrototypeOf(rename2, fs$rename);
|
|
37150
37205
|
return rename2;
|
|
37151
|
-
}(
|
|
37206
|
+
}(fs10.rename);
|
|
37152
37207
|
}
|
|
37153
|
-
|
|
37208
|
+
fs10.read = typeof fs10.read !== "function" ? fs10.read : function(fs$read) {
|
|
37154
37209
|
function read(fd, buffer, offset, length, position, callback_) {
|
|
37155
37210
|
var callback;
|
|
37156
37211
|
if (callback_ && typeof callback_ === "function") {
|
|
@@ -37158,23 +37213,23 @@ var require_polyfills = __commonJS((exports, module2) => {
|
|
|
37158
37213
|
callback = function(er, _, __) {
|
|
37159
37214
|
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
37160
37215
|
eagCounter++;
|
|
37161
|
-
return fs$read.call(
|
|
37216
|
+
return fs$read.call(fs10, fd, buffer, offset, length, position, callback);
|
|
37162
37217
|
}
|
|
37163
37218
|
callback_.apply(this, arguments);
|
|
37164
37219
|
};
|
|
37165
37220
|
}
|
|
37166
|
-
return fs$read.call(
|
|
37221
|
+
return fs$read.call(fs10, fd, buffer, offset, length, position, callback);
|
|
37167
37222
|
}
|
|
37168
37223
|
if (Object.setPrototypeOf)
|
|
37169
37224
|
Object.setPrototypeOf(read, fs$read);
|
|
37170
37225
|
return read;
|
|
37171
|
-
}(
|
|
37172
|
-
|
|
37226
|
+
}(fs10.read);
|
|
37227
|
+
fs10.readSync = typeof fs10.readSync !== "function" ? fs10.readSync : function(fs$readSync) {
|
|
37173
37228
|
return function(fd, buffer, offset, length, position) {
|
|
37174
37229
|
var eagCounter = 0;
|
|
37175
37230
|
while (true) {
|
|
37176
37231
|
try {
|
|
37177
|
-
return fs$readSync.call(
|
|
37232
|
+
return fs$readSync.call(fs10, fd, buffer, offset, length, position);
|
|
37178
37233
|
} catch (er) {
|
|
37179
37234
|
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
37180
37235
|
eagCounter++;
|
|
@@ -37184,90 +37239,90 @@ var require_polyfills = __commonJS((exports, module2) => {
|
|
|
37184
37239
|
}
|
|
37185
37240
|
}
|
|
37186
37241
|
};
|
|
37187
|
-
}(
|
|
37188
|
-
function patchLchmod(
|
|
37189
|
-
|
|
37190
|
-
|
|
37242
|
+
}(fs10.readSync);
|
|
37243
|
+
function patchLchmod(fs11) {
|
|
37244
|
+
fs11.lchmod = function(path12, mode, callback) {
|
|
37245
|
+
fs11.open(path12, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err2, fd) {
|
|
37191
37246
|
if (err2) {
|
|
37192
37247
|
if (callback)
|
|
37193
37248
|
callback(err2);
|
|
37194
37249
|
return;
|
|
37195
37250
|
}
|
|
37196
|
-
|
|
37197
|
-
|
|
37251
|
+
fs11.fchmod(fd, mode, function(err3) {
|
|
37252
|
+
fs11.close(fd, function(err22) {
|
|
37198
37253
|
if (callback)
|
|
37199
37254
|
callback(err3 || err22);
|
|
37200
37255
|
});
|
|
37201
37256
|
});
|
|
37202
37257
|
});
|
|
37203
37258
|
};
|
|
37204
|
-
|
|
37205
|
-
var fd =
|
|
37259
|
+
fs11.lchmodSync = function(path12, mode) {
|
|
37260
|
+
var fd = fs11.openSync(path12, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
37206
37261
|
var threw = true;
|
|
37207
37262
|
var ret;
|
|
37208
37263
|
try {
|
|
37209
|
-
ret =
|
|
37264
|
+
ret = fs11.fchmodSync(fd, mode);
|
|
37210
37265
|
threw = false;
|
|
37211
37266
|
} finally {
|
|
37212
37267
|
if (threw) {
|
|
37213
37268
|
try {
|
|
37214
|
-
|
|
37269
|
+
fs11.closeSync(fd);
|
|
37215
37270
|
} catch (er) {}
|
|
37216
37271
|
} else {
|
|
37217
|
-
|
|
37272
|
+
fs11.closeSync(fd);
|
|
37218
37273
|
}
|
|
37219
37274
|
}
|
|
37220
37275
|
return ret;
|
|
37221
37276
|
};
|
|
37222
37277
|
}
|
|
37223
|
-
function patchLutimes(
|
|
37224
|
-
if (constants.hasOwnProperty("O_SYMLINK") &&
|
|
37225
|
-
|
|
37226
|
-
|
|
37278
|
+
function patchLutimes(fs11) {
|
|
37279
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs11.futimes) {
|
|
37280
|
+
fs11.lutimes = function(path12, at, mt, cb) {
|
|
37281
|
+
fs11.open(path12, constants.O_SYMLINK, function(er, fd) {
|
|
37227
37282
|
if (er) {
|
|
37228
37283
|
if (cb)
|
|
37229
37284
|
cb(er);
|
|
37230
37285
|
return;
|
|
37231
37286
|
}
|
|
37232
|
-
|
|
37233
|
-
|
|
37287
|
+
fs11.futimes(fd, at, mt, function(er2) {
|
|
37288
|
+
fs11.close(fd, function(er22) {
|
|
37234
37289
|
if (cb)
|
|
37235
37290
|
cb(er2 || er22);
|
|
37236
37291
|
});
|
|
37237
37292
|
});
|
|
37238
37293
|
});
|
|
37239
37294
|
};
|
|
37240
|
-
|
|
37241
|
-
var fd =
|
|
37295
|
+
fs11.lutimesSync = function(path12, at, mt) {
|
|
37296
|
+
var fd = fs11.openSync(path12, constants.O_SYMLINK);
|
|
37242
37297
|
var ret;
|
|
37243
37298
|
var threw = true;
|
|
37244
37299
|
try {
|
|
37245
|
-
ret =
|
|
37300
|
+
ret = fs11.futimesSync(fd, at, mt);
|
|
37246
37301
|
threw = false;
|
|
37247
37302
|
} finally {
|
|
37248
37303
|
if (threw) {
|
|
37249
37304
|
try {
|
|
37250
|
-
|
|
37305
|
+
fs11.closeSync(fd);
|
|
37251
37306
|
} catch (er) {}
|
|
37252
37307
|
} else {
|
|
37253
|
-
|
|
37308
|
+
fs11.closeSync(fd);
|
|
37254
37309
|
}
|
|
37255
37310
|
}
|
|
37256
37311
|
return ret;
|
|
37257
37312
|
};
|
|
37258
|
-
} else if (
|
|
37259
|
-
|
|
37313
|
+
} else if (fs11.futimes) {
|
|
37314
|
+
fs11.lutimes = function(_a2, _b, _c, cb) {
|
|
37260
37315
|
if (cb)
|
|
37261
37316
|
process.nextTick(cb);
|
|
37262
37317
|
};
|
|
37263
|
-
|
|
37318
|
+
fs11.lutimesSync = function() {};
|
|
37264
37319
|
}
|
|
37265
37320
|
}
|
|
37266
37321
|
function chmodFix(orig) {
|
|
37267
37322
|
if (!orig)
|
|
37268
37323
|
return orig;
|
|
37269
37324
|
return function(target, mode, cb) {
|
|
37270
|
-
return orig.call(
|
|
37325
|
+
return orig.call(fs10, target, mode, function(er) {
|
|
37271
37326
|
if (chownErOk(er))
|
|
37272
37327
|
er = null;
|
|
37273
37328
|
if (cb)
|
|
@@ -37280,7 +37335,7 @@ var require_polyfills = __commonJS((exports, module2) => {
|
|
|
37280
37335
|
return orig;
|
|
37281
37336
|
return function(target, mode) {
|
|
37282
37337
|
try {
|
|
37283
|
-
return orig.call(
|
|
37338
|
+
return orig.call(fs10, target, mode);
|
|
37284
37339
|
} catch (er) {
|
|
37285
37340
|
if (!chownErOk(er))
|
|
37286
37341
|
throw er;
|
|
@@ -37291,7 +37346,7 @@ var require_polyfills = __commonJS((exports, module2) => {
|
|
|
37291
37346
|
if (!orig)
|
|
37292
37347
|
return orig;
|
|
37293
37348
|
return function(target, uid, gid, cb) {
|
|
37294
|
-
return orig.call(
|
|
37349
|
+
return orig.call(fs10, target, uid, gid, function(er) {
|
|
37295
37350
|
if (chownErOk(er))
|
|
37296
37351
|
er = null;
|
|
37297
37352
|
if (cb)
|
|
@@ -37304,7 +37359,7 @@ var require_polyfills = __commonJS((exports, module2) => {
|
|
|
37304
37359
|
return orig;
|
|
37305
37360
|
return function(target, uid, gid) {
|
|
37306
37361
|
try {
|
|
37307
|
-
return orig.call(
|
|
37362
|
+
return orig.call(fs10, target, uid, gid);
|
|
37308
37363
|
} catch (er) {
|
|
37309
37364
|
if (!chownErOk(er))
|
|
37310
37365
|
throw er;
|
|
@@ -37329,14 +37384,14 @@ var require_polyfills = __commonJS((exports, module2) => {
|
|
|
37329
37384
|
if (cb)
|
|
37330
37385
|
cb.apply(this, arguments);
|
|
37331
37386
|
}
|
|
37332
|
-
return options ? orig.call(
|
|
37387
|
+
return options ? orig.call(fs10, target, options, callback) : orig.call(fs10, target, callback);
|
|
37333
37388
|
};
|
|
37334
37389
|
}
|
|
37335
37390
|
function statFixSync(orig) {
|
|
37336
37391
|
if (!orig)
|
|
37337
37392
|
return orig;
|
|
37338
37393
|
return function(target, options) {
|
|
37339
|
-
var stats = options ? orig.call(
|
|
37394
|
+
var stats = options ? orig.call(fs10, target, options) : orig.call(fs10, target);
|
|
37340
37395
|
if (stats) {
|
|
37341
37396
|
if (stats.uid < 0)
|
|
37342
37397
|
stats.uid += 4294967296;
|
|
@@ -37365,7 +37420,7 @@ var require_polyfills = __commonJS((exports, module2) => {
|
|
|
37365
37420
|
var require_legacy_streams = __commonJS((exports, module2) => {
|
|
37366
37421
|
var Stream = __require("stream").Stream;
|
|
37367
37422
|
module2.exports = legacy;
|
|
37368
|
-
function legacy(
|
|
37423
|
+
function legacy(fs10) {
|
|
37369
37424
|
return {
|
|
37370
37425
|
ReadStream,
|
|
37371
37426
|
WriteStream
|
|
@@ -37410,7 +37465,7 @@ var require_legacy_streams = __commonJS((exports, module2) => {
|
|
|
37410
37465
|
});
|
|
37411
37466
|
return;
|
|
37412
37467
|
}
|
|
37413
|
-
|
|
37468
|
+
fs10.open(this.path, this.flags, this.mode, function(err2, fd) {
|
|
37414
37469
|
if (err2) {
|
|
37415
37470
|
self2.emit("error", err2);
|
|
37416
37471
|
self2.readable = false;
|
|
@@ -37450,7 +37505,7 @@ var require_legacy_streams = __commonJS((exports, module2) => {
|
|
|
37450
37505
|
this.busy = false;
|
|
37451
37506
|
this._queue = [];
|
|
37452
37507
|
if (this.fd === null) {
|
|
37453
|
-
this._open =
|
|
37508
|
+
this._open = fs10.open;
|
|
37454
37509
|
this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
|
|
37455
37510
|
this.flush();
|
|
37456
37511
|
}
|
|
@@ -37480,7 +37535,7 @@ var require_clone = __commonJS((exports, module2) => {
|
|
|
37480
37535
|
|
|
37481
37536
|
// node_modules/graceful-fs/graceful-fs.js
|
|
37482
37537
|
var require_graceful_fs = __commonJS((exports, module2) => {
|
|
37483
|
-
var
|
|
37538
|
+
var fs10 = __require("fs");
|
|
37484
37539
|
var polyfills = require_polyfills();
|
|
37485
37540
|
var legacy = require_legacy_streams();
|
|
37486
37541
|
var clone3 = require_clone();
|
|
@@ -37512,12 +37567,12 @@ var require_graceful_fs = __commonJS((exports, module2) => {
|
|
|
37512
37567
|
GFS4: `);
|
|
37513
37568
|
console.error(m);
|
|
37514
37569
|
};
|
|
37515
|
-
if (!
|
|
37570
|
+
if (!fs10[gracefulQueue]) {
|
|
37516
37571
|
queue = global[gracefulQueue] || [];
|
|
37517
|
-
publishQueue(
|
|
37518
|
-
|
|
37572
|
+
publishQueue(fs10, queue);
|
|
37573
|
+
fs10.close = function(fs$close) {
|
|
37519
37574
|
function close(fd, cb) {
|
|
37520
|
-
return fs$close.call(
|
|
37575
|
+
return fs$close.call(fs10, fd, function(err2) {
|
|
37521
37576
|
if (!err2) {
|
|
37522
37577
|
resetQueue();
|
|
37523
37578
|
}
|
|
@@ -37529,40 +37584,40 @@ GFS4: `);
|
|
|
37529
37584
|
value: fs$close
|
|
37530
37585
|
});
|
|
37531
37586
|
return close;
|
|
37532
|
-
}(
|
|
37533
|
-
|
|
37587
|
+
}(fs10.close);
|
|
37588
|
+
fs10.closeSync = function(fs$closeSync) {
|
|
37534
37589
|
function closeSync(fd) {
|
|
37535
|
-
fs$closeSync.apply(
|
|
37590
|
+
fs$closeSync.apply(fs10, arguments);
|
|
37536
37591
|
resetQueue();
|
|
37537
37592
|
}
|
|
37538
37593
|
Object.defineProperty(closeSync, previousSymbol, {
|
|
37539
37594
|
value: fs$closeSync
|
|
37540
37595
|
});
|
|
37541
37596
|
return closeSync;
|
|
37542
|
-
}(
|
|
37597
|
+
}(fs10.closeSync);
|
|
37543
37598
|
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
37544
37599
|
process.on("exit", function() {
|
|
37545
|
-
debug(
|
|
37546
|
-
__require("assert").equal(
|
|
37600
|
+
debug(fs10[gracefulQueue]);
|
|
37601
|
+
__require("assert").equal(fs10[gracefulQueue].length, 0);
|
|
37547
37602
|
});
|
|
37548
37603
|
}
|
|
37549
37604
|
}
|
|
37550
37605
|
var queue;
|
|
37551
37606
|
if (!global[gracefulQueue]) {
|
|
37552
|
-
publishQueue(global,
|
|
37553
|
-
}
|
|
37554
|
-
module2.exports = patch(clone3(
|
|
37555
|
-
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !
|
|
37556
|
-
module2.exports = patch(
|
|
37557
|
-
|
|
37558
|
-
}
|
|
37559
|
-
function patch(
|
|
37560
|
-
polyfills(
|
|
37561
|
-
|
|
37562
|
-
|
|
37563
|
-
|
|
37564
|
-
var fs$readFile =
|
|
37565
|
-
|
|
37607
|
+
publishQueue(global, fs10[gracefulQueue]);
|
|
37608
|
+
}
|
|
37609
|
+
module2.exports = patch(clone3(fs10));
|
|
37610
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs10.__patched) {
|
|
37611
|
+
module2.exports = patch(fs10);
|
|
37612
|
+
fs10.__patched = true;
|
|
37613
|
+
}
|
|
37614
|
+
function patch(fs11) {
|
|
37615
|
+
polyfills(fs11);
|
|
37616
|
+
fs11.gracefulify = patch;
|
|
37617
|
+
fs11.createReadStream = createReadStream;
|
|
37618
|
+
fs11.createWriteStream = createWriteStream2;
|
|
37619
|
+
var fs$readFile = fs11.readFile;
|
|
37620
|
+
fs11.readFile = readFile3;
|
|
37566
37621
|
function readFile3(path12, options, cb) {
|
|
37567
37622
|
if (typeof options === "function")
|
|
37568
37623
|
cb = options, options = null;
|
|
@@ -37578,8 +37633,8 @@ GFS4: `);
|
|
|
37578
37633
|
});
|
|
37579
37634
|
}
|
|
37580
37635
|
}
|
|
37581
|
-
var fs$writeFile =
|
|
37582
|
-
|
|
37636
|
+
var fs$writeFile = fs11.writeFile;
|
|
37637
|
+
fs11.writeFile = writeFile2;
|
|
37583
37638
|
function writeFile2(path12, data, options, cb) {
|
|
37584
37639
|
if (typeof options === "function")
|
|
37585
37640
|
cb = options, options = null;
|
|
@@ -37595,10 +37650,10 @@ GFS4: `);
|
|
|
37595
37650
|
});
|
|
37596
37651
|
}
|
|
37597
37652
|
}
|
|
37598
|
-
var fs$appendFile =
|
|
37653
|
+
var fs$appendFile = fs11.appendFile;
|
|
37599
37654
|
if (fs$appendFile)
|
|
37600
|
-
|
|
37601
|
-
function
|
|
37655
|
+
fs11.appendFile = appendFile3;
|
|
37656
|
+
function appendFile3(path12, data, options, cb) {
|
|
37602
37657
|
if (typeof options === "function")
|
|
37603
37658
|
cb = options, options = null;
|
|
37604
37659
|
return go$appendFile(path12, data, options, cb);
|
|
@@ -37613,9 +37668,9 @@ GFS4: `);
|
|
|
37613
37668
|
});
|
|
37614
37669
|
}
|
|
37615
37670
|
}
|
|
37616
|
-
var fs$copyFile =
|
|
37671
|
+
var fs$copyFile = fs11.copyFile;
|
|
37617
37672
|
if (fs$copyFile)
|
|
37618
|
-
|
|
37673
|
+
fs11.copyFile = copyFile;
|
|
37619
37674
|
function copyFile(src, dest, flags2, cb) {
|
|
37620
37675
|
if (typeof flags2 === "function") {
|
|
37621
37676
|
cb = flags2;
|
|
@@ -37633,8 +37688,8 @@ GFS4: `);
|
|
|
37633
37688
|
});
|
|
37634
37689
|
}
|
|
37635
37690
|
}
|
|
37636
|
-
var fs$readdir =
|
|
37637
|
-
|
|
37691
|
+
var fs$readdir = fs11.readdir;
|
|
37692
|
+
fs11.readdir = readdir2;
|
|
37638
37693
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
37639
37694
|
function readdir2(path12, options, cb) {
|
|
37640
37695
|
if (typeof options === "function")
|
|
@@ -37665,21 +37720,21 @@ GFS4: `);
|
|
|
37665
37720
|
}
|
|
37666
37721
|
}
|
|
37667
37722
|
if (process.version.substr(0, 4) === "v0.8") {
|
|
37668
|
-
var legStreams = legacy(
|
|
37723
|
+
var legStreams = legacy(fs11);
|
|
37669
37724
|
ReadStream = legStreams.ReadStream;
|
|
37670
37725
|
WriteStream = legStreams.WriteStream;
|
|
37671
37726
|
}
|
|
37672
|
-
var fs$ReadStream =
|
|
37727
|
+
var fs$ReadStream = fs11.ReadStream;
|
|
37673
37728
|
if (fs$ReadStream) {
|
|
37674
37729
|
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
37675
37730
|
ReadStream.prototype.open = ReadStream$open;
|
|
37676
37731
|
}
|
|
37677
|
-
var fs$WriteStream =
|
|
37732
|
+
var fs$WriteStream = fs11.WriteStream;
|
|
37678
37733
|
if (fs$WriteStream) {
|
|
37679
37734
|
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
37680
37735
|
WriteStream.prototype.open = WriteStream$open;
|
|
37681
37736
|
}
|
|
37682
|
-
Object.defineProperty(
|
|
37737
|
+
Object.defineProperty(fs11, "ReadStream", {
|
|
37683
37738
|
get: function() {
|
|
37684
37739
|
return ReadStream;
|
|
37685
37740
|
},
|
|
@@ -37689,7 +37744,7 @@ GFS4: `);
|
|
|
37689
37744
|
enumerable: true,
|
|
37690
37745
|
configurable: true
|
|
37691
37746
|
});
|
|
37692
|
-
Object.defineProperty(
|
|
37747
|
+
Object.defineProperty(fs11, "WriteStream", {
|
|
37693
37748
|
get: function() {
|
|
37694
37749
|
return WriteStream;
|
|
37695
37750
|
},
|
|
@@ -37700,7 +37755,7 @@ GFS4: `);
|
|
|
37700
37755
|
configurable: true
|
|
37701
37756
|
});
|
|
37702
37757
|
var FileReadStream = ReadStream;
|
|
37703
|
-
Object.defineProperty(
|
|
37758
|
+
Object.defineProperty(fs11, "FileReadStream", {
|
|
37704
37759
|
get: function() {
|
|
37705
37760
|
return FileReadStream;
|
|
37706
37761
|
},
|
|
@@ -37711,7 +37766,7 @@ GFS4: `);
|
|
|
37711
37766
|
configurable: true
|
|
37712
37767
|
});
|
|
37713
37768
|
var FileWriteStream = WriteStream;
|
|
37714
|
-
Object.defineProperty(
|
|
37769
|
+
Object.defineProperty(fs11, "FileWriteStream", {
|
|
37715
37770
|
get: function() {
|
|
37716
37771
|
return FileWriteStream;
|
|
37717
37772
|
},
|
|
@@ -37760,13 +37815,13 @@ GFS4: `);
|
|
|
37760
37815
|
});
|
|
37761
37816
|
}
|
|
37762
37817
|
function createReadStream(path12, options) {
|
|
37763
|
-
return new
|
|
37818
|
+
return new fs11.ReadStream(path12, options);
|
|
37764
37819
|
}
|
|
37765
37820
|
function createWriteStream2(path12, options) {
|
|
37766
|
-
return new
|
|
37821
|
+
return new fs11.WriteStream(path12, options);
|
|
37767
37822
|
}
|
|
37768
|
-
var fs$open =
|
|
37769
|
-
|
|
37823
|
+
var fs$open = fs11.open;
|
|
37824
|
+
fs11.open = open;
|
|
37770
37825
|
function open(path12, flags2, mode, cb) {
|
|
37771
37826
|
if (typeof mode === "function")
|
|
37772
37827
|
cb = mode, mode = null;
|
|
@@ -37782,20 +37837,20 @@ GFS4: `);
|
|
|
37782
37837
|
});
|
|
37783
37838
|
}
|
|
37784
37839
|
}
|
|
37785
|
-
return
|
|
37840
|
+
return fs11;
|
|
37786
37841
|
}
|
|
37787
37842
|
function enqueue(elem) {
|
|
37788
37843
|
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
37789
|
-
|
|
37844
|
+
fs10[gracefulQueue].push(elem);
|
|
37790
37845
|
retry();
|
|
37791
37846
|
}
|
|
37792
37847
|
var retryTimer;
|
|
37793
37848
|
function resetQueue() {
|
|
37794
37849
|
var now = Date.now();
|
|
37795
|
-
for (var i2 = 0;i2 <
|
|
37796
|
-
if (
|
|
37797
|
-
|
|
37798
|
-
|
|
37850
|
+
for (var i2 = 0;i2 < fs10[gracefulQueue].length; ++i2) {
|
|
37851
|
+
if (fs10[gracefulQueue][i2].length > 2) {
|
|
37852
|
+
fs10[gracefulQueue][i2][3] = now;
|
|
37853
|
+
fs10[gracefulQueue][i2][4] = now;
|
|
37799
37854
|
}
|
|
37800
37855
|
}
|
|
37801
37856
|
retry();
|
|
@@ -37803,9 +37858,9 @@ GFS4: `);
|
|
|
37803
37858
|
function retry() {
|
|
37804
37859
|
clearTimeout(retryTimer);
|
|
37805
37860
|
retryTimer = undefined;
|
|
37806
|
-
if (
|
|
37861
|
+
if (fs10[gracefulQueue].length === 0)
|
|
37807
37862
|
return;
|
|
37808
|
-
var elem =
|
|
37863
|
+
var elem = fs10[gracefulQueue].shift();
|
|
37809
37864
|
var fn = elem[0];
|
|
37810
37865
|
var args2 = elem[1];
|
|
37811
37866
|
var err2 = elem[2];
|
|
@@ -37827,7 +37882,7 @@ GFS4: `);
|
|
|
37827
37882
|
debug("RETRY", fn.name, args2);
|
|
37828
37883
|
fn.apply(null, args2.concat([startTime]));
|
|
37829
37884
|
} else {
|
|
37830
|
-
|
|
37885
|
+
fs10[gracefulQueue].push(elem);
|
|
37831
37886
|
}
|
|
37832
37887
|
}
|
|
37833
37888
|
if (retryTimer === undefined) {
|
|
@@ -38222,10 +38277,10 @@ var require_signal_exit = __commonJS((exports, module2) => {
|
|
|
38222
38277
|
// node_modules/proper-lockfile/lib/mtime-precision.js
|
|
38223
38278
|
var require_mtime_precision = __commonJS((exports, module2) => {
|
|
38224
38279
|
var cacheSymbol = Symbol();
|
|
38225
|
-
function probe(file3,
|
|
38226
|
-
const cachedPrecision =
|
|
38280
|
+
function probe(file3, fs10, callback) {
|
|
38281
|
+
const cachedPrecision = fs10[cacheSymbol];
|
|
38227
38282
|
if (cachedPrecision) {
|
|
38228
|
-
return
|
|
38283
|
+
return fs10.stat(file3, (err2, stat) => {
|
|
38229
38284
|
if (err2) {
|
|
38230
38285
|
return callback(err2);
|
|
38231
38286
|
}
|
|
@@ -38233,16 +38288,16 @@ var require_mtime_precision = __commonJS((exports, module2) => {
|
|
|
38233
38288
|
});
|
|
38234
38289
|
}
|
|
38235
38290
|
const mtime = new Date(Math.ceil(Date.now() / 1000) * 1000 + 5);
|
|
38236
|
-
|
|
38291
|
+
fs10.utimes(file3, mtime, mtime, (err2) => {
|
|
38237
38292
|
if (err2) {
|
|
38238
38293
|
return callback(err2);
|
|
38239
38294
|
}
|
|
38240
|
-
|
|
38295
|
+
fs10.stat(file3, (err3, stat) => {
|
|
38241
38296
|
if (err3) {
|
|
38242
38297
|
return callback(err3);
|
|
38243
38298
|
}
|
|
38244
38299
|
const precision = stat.mtime.getTime() % 1000 === 0 ? "s" : "ms";
|
|
38245
|
-
Object.defineProperty(
|
|
38300
|
+
Object.defineProperty(fs10, cacheSymbol, { value: precision });
|
|
38246
38301
|
callback(null, stat.mtime, precision);
|
|
38247
38302
|
});
|
|
38248
38303
|
});
|
|
@@ -38261,7 +38316,7 @@ var require_mtime_precision = __commonJS((exports, module2) => {
|
|
|
38261
38316
|
// node_modules/proper-lockfile/lib/lockfile.js
|
|
38262
38317
|
var require_lockfile = __commonJS((exports, module2) => {
|
|
38263
38318
|
var path12 = __require("path");
|
|
38264
|
-
var
|
|
38319
|
+
var fs10 = require_graceful_fs();
|
|
38265
38320
|
var retry = require_retry();
|
|
38266
38321
|
var onExit = require_signal_exit();
|
|
38267
38322
|
var mtimePrecision = require_mtime_precision();
|
|
@@ -38384,7 +38439,7 @@ var require_lockfile = __commonJS((exports, module2) => {
|
|
|
38384
38439
|
update: null,
|
|
38385
38440
|
realpath: true,
|
|
38386
38441
|
retries: 0,
|
|
38387
|
-
fs:
|
|
38442
|
+
fs: fs10,
|
|
38388
38443
|
onCompromised: (err2) => {
|
|
38389
38444
|
throw err2;
|
|
38390
38445
|
},
|
|
@@ -38428,7 +38483,7 @@ var require_lockfile = __commonJS((exports, module2) => {
|
|
|
38428
38483
|
}
|
|
38429
38484
|
function unlock(file3, options, callback) {
|
|
38430
38485
|
options = {
|
|
38431
|
-
fs:
|
|
38486
|
+
fs: fs10,
|
|
38432
38487
|
realpath: true,
|
|
38433
38488
|
...options
|
|
38434
38489
|
};
|
|
@@ -38450,7 +38505,7 @@ var require_lockfile = __commonJS((exports, module2) => {
|
|
|
38450
38505
|
options = {
|
|
38451
38506
|
stale: 1e4,
|
|
38452
38507
|
realpath: true,
|
|
38453
|
-
fs:
|
|
38508
|
+
fs: fs10,
|
|
38454
38509
|
...options
|
|
38455
38510
|
};
|
|
38456
38511
|
options.stale = Math.max(options.stale || 0, 2000);
|
|
@@ -38485,16 +38540,16 @@ var require_lockfile = __commonJS((exports, module2) => {
|
|
|
38485
38540
|
|
|
38486
38541
|
// node_modules/proper-lockfile/lib/adapter.js
|
|
38487
38542
|
var require_adapter = __commonJS((exports, module2) => {
|
|
38488
|
-
var
|
|
38489
|
-
function createSyncFs(
|
|
38543
|
+
var fs10 = require_graceful_fs();
|
|
38544
|
+
function createSyncFs(fs11) {
|
|
38490
38545
|
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
38491
|
-
const newFs = { ...
|
|
38546
|
+
const newFs = { ...fs11 };
|
|
38492
38547
|
methods.forEach((method) => {
|
|
38493
38548
|
newFs[method] = (...args2) => {
|
|
38494
38549
|
const callback = args2.pop();
|
|
38495
38550
|
let ret;
|
|
38496
38551
|
try {
|
|
38497
|
-
ret =
|
|
38552
|
+
ret = fs11[`${method}Sync`](...args2);
|
|
38498
38553
|
} catch (err2) {
|
|
38499
38554
|
return callback(err2);
|
|
38500
38555
|
}
|
|
@@ -38532,7 +38587,7 @@ var require_adapter = __commonJS((exports, module2) => {
|
|
|
38532
38587
|
}
|
|
38533
38588
|
function toSyncOptions(options) {
|
|
38534
38589
|
options = { ...options };
|
|
38535
|
-
options.fs = createSyncFs(options.fs ||
|
|
38590
|
+
options.fs = createSyncFs(options.fs || fs10);
|
|
38536
38591
|
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
38537
38592
|
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
38538
38593
|
}
|
|
@@ -38580,7 +38635,7 @@ var require_proper_lockfile = __commonJS((exports, module2) => {
|
|
|
38580
38635
|
|
|
38581
38636
|
// src/hooks/knowledge-store.ts
|
|
38582
38637
|
import { existsSync as existsSync7 } from "fs";
|
|
38583
|
-
import { appendFile as
|
|
38638
|
+
import { appendFile as appendFile3, mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
|
|
38584
38639
|
import * as os3 from "os";
|
|
38585
38640
|
import * as path12 from "path";
|
|
38586
38641
|
function resolveSwarmKnowledgePath(directory) {
|
|
@@ -38628,13 +38683,13 @@ async function readRejectedLessons(directory) {
|
|
|
38628
38683
|
return readKnowledge(resolveSwarmRejectedPath(directory));
|
|
38629
38684
|
}
|
|
38630
38685
|
async function appendKnowledge(filePath, entry) {
|
|
38631
|
-
await
|
|
38632
|
-
await
|
|
38686
|
+
await mkdir2(path12.dirname(filePath), { recursive: true });
|
|
38687
|
+
await appendFile3(filePath, `${JSON.stringify(entry)}
|
|
38633
38688
|
`, "utf-8");
|
|
38634
38689
|
}
|
|
38635
38690
|
async function rewriteKnowledge(filePath, entries) {
|
|
38636
38691
|
const dir = path12.dirname(filePath);
|
|
38637
|
-
await
|
|
38692
|
+
await mkdir2(dir, { recursive: true });
|
|
38638
38693
|
let release = null;
|
|
38639
38694
|
try {
|
|
38640
38695
|
release = await import_proper_lockfile.default.lock(dir, {
|
|
@@ -38744,7 +38799,7 @@ var init_knowledge_store = __esm(() => {
|
|
|
38744
38799
|
|
|
38745
38800
|
// src/hooks/knowledge-reader.ts
|
|
38746
38801
|
import { existsSync as existsSync8 } from "fs";
|
|
38747
|
-
import { mkdir as
|
|
38802
|
+
import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
|
|
38748
38803
|
import * as path13 from "path";
|
|
38749
38804
|
function inferCategoriesFromPhase(phaseDescription) {
|
|
38750
38805
|
const lower = phaseDescription.toLowerCase();
|
|
@@ -38800,7 +38855,7 @@ async function recordLessonsShown(directory, lessonIds, currentPhase) {
|
|
|
38800
38855
|
const phaseMatch = /^Phase\s+(\d+)/i.exec(currentPhase);
|
|
38801
38856
|
const canonicalKey = phaseMatch ? `Phase ${phaseMatch[1]}` : currentPhase;
|
|
38802
38857
|
shownData[canonicalKey] = lessonIds;
|
|
38803
|
-
await
|
|
38858
|
+
await mkdir3(path13.dirname(shownFile), { recursive: true });
|
|
38804
38859
|
await writeFile3(shownFile, JSON.stringify(shownData, null, 2), "utf-8");
|
|
38805
38860
|
} catch {
|
|
38806
38861
|
console.warn("[swarm] Knowledge: failed to record shown lessons");
|
|
@@ -38962,7 +39017,7 @@ var init_knowledge_reader = __esm(() => {
|
|
|
38962
39017
|
});
|
|
38963
39018
|
|
|
38964
39019
|
// src/hooks/knowledge-validator.ts
|
|
38965
|
-
import { appendFile as
|
|
39020
|
+
import { appendFile as appendFile4, mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
|
|
38966
39021
|
import * as path14 from "path";
|
|
38967
39022
|
function normalizeText(text) {
|
|
38968
39023
|
return text.normalize("NFKC").toLowerCase().replace(/[^\w\s]/g, " ").replace(/\s+/g, " ").trim();
|
|
@@ -39121,7 +39176,7 @@ async function quarantineEntry(directory, entryId, reason, reportedBy) {
|
|
|
39121
39176
|
const quarantinePath = path14.join(directory, ".swarm", "knowledge-quarantined.jsonl");
|
|
39122
39177
|
const rejectedPath = path14.join(directory, ".swarm", "knowledge-rejected.jsonl");
|
|
39123
39178
|
const swarmDir = path14.join(directory, ".swarm");
|
|
39124
|
-
await
|
|
39179
|
+
await mkdir4(swarmDir, { recursive: true });
|
|
39125
39180
|
let release;
|
|
39126
39181
|
try {
|
|
39127
39182
|
release = await import_proper_lockfile2.default.lock(swarmDir, {
|
|
@@ -39143,7 +39198,7 @@ async function quarantineEntry(directory, entryId, reason, reportedBy) {
|
|
|
39143
39198
|
`)}
|
|
39144
39199
|
` : "";
|
|
39145
39200
|
await writeFile4(knowledgePath, jsonlContent, "utf-8");
|
|
39146
|
-
await
|
|
39201
|
+
await appendFile4(quarantinePath, `${JSON.stringify(quarantined)}
|
|
39147
39202
|
`, "utf-8");
|
|
39148
39203
|
const quarantinedEntries = await readKnowledge(quarantinePath);
|
|
39149
39204
|
if (quarantinedEntries.length > 100) {
|
|
@@ -39181,7 +39236,7 @@ async function restoreEntry(directory, entryId) {
|
|
|
39181
39236
|
const quarantinePath = path14.join(directory, ".swarm", "knowledge-quarantined.jsonl");
|
|
39182
39237
|
const rejectedPath = path14.join(directory, ".swarm", "knowledge-rejected.jsonl");
|
|
39183
39238
|
const swarmDir = path14.join(directory, ".swarm");
|
|
39184
|
-
await
|
|
39239
|
+
await mkdir4(swarmDir, { recursive: true });
|
|
39185
39240
|
let release;
|
|
39186
39241
|
try {
|
|
39187
39242
|
release = await import_proper_lockfile2.default.lock(swarmDir, {
|
|
@@ -39198,7 +39253,7 @@ async function restoreEntry(directory, entryId) {
|
|
|
39198
39253
|
`)}
|
|
39199
39254
|
` : "";
|
|
39200
39255
|
await writeFile4(quarantinePath, jsonlContent, "utf-8");
|
|
39201
|
-
await
|
|
39256
|
+
await appendFile4(knowledgePath, `${JSON.stringify(original)}
|
|
39202
39257
|
`, "utf-8");
|
|
39203
39258
|
const rejectedEntries = await readKnowledge(rejectedPath);
|
|
39204
39259
|
const filtered = rejectedEntries.filter((e) => e.id !== entryId);
|
|
@@ -39647,7 +39702,7 @@ var init_knowledge_curator = __esm(() => {
|
|
|
39647
39702
|
});
|
|
39648
39703
|
|
|
39649
39704
|
// src/plan/checkpoint.ts
|
|
39650
|
-
import * as
|
|
39705
|
+
import * as fs10 from "fs";
|
|
39651
39706
|
import * as path15 from "path";
|
|
39652
39707
|
async function writeCheckpoint(directory) {
|
|
39653
39708
|
try {
|
|
@@ -39656,9 +39711,9 @@ async function writeCheckpoint(directory) {
|
|
|
39656
39711
|
return;
|
|
39657
39712
|
const jsonPath = path15.join(directory, "SWARM_PLAN.json");
|
|
39658
39713
|
const mdPath = path15.join(directory, "SWARM_PLAN.md");
|
|
39659
|
-
|
|
39714
|
+
fs10.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
|
|
39660
39715
|
const md = derivePlanMarkdown(plan);
|
|
39661
|
-
|
|
39716
|
+
fs10.writeFileSync(mdPath, md, "utf8");
|
|
39662
39717
|
} catch (error93) {
|
|
39663
39718
|
console.warn(`[checkpoint] Failed to write SWARM_PLAN checkpoint: ${error93 instanceof Error ? error93.message : String(error93)}`);
|
|
39664
39719
|
}
|
|
@@ -40147,7 +40202,7 @@ var init_write_retro = __esm(() => {
|
|
|
40147
40202
|
|
|
40148
40203
|
// src/commands/close.ts
|
|
40149
40204
|
import { execFileSync } from "child_process";
|
|
40150
|
-
import { promises as
|
|
40205
|
+
import { promises as fs11 } from "fs";
|
|
40151
40206
|
import path17 from "path";
|
|
40152
40207
|
async function handleCloseCommand(directory, args2) {
|
|
40153
40208
|
const planPath = validateSwarmPath(directory, "plan.json");
|
|
@@ -40158,14 +40213,14 @@ async function handleCloseCommand(directory, args2) {
|
|
|
40158
40213
|
phases: []
|
|
40159
40214
|
};
|
|
40160
40215
|
try {
|
|
40161
|
-
const content = await
|
|
40216
|
+
const content = await fs11.readFile(planPath, "utf-8");
|
|
40162
40217
|
planData = JSON.parse(content);
|
|
40163
40218
|
planExists = true;
|
|
40164
40219
|
} catch (error93) {
|
|
40165
40220
|
if (error93?.code !== "ENOENT") {
|
|
40166
40221
|
return `\u274C Failed to read plan.json: ${error93 instanceof Error ? error93.message : String(error93)}`;
|
|
40167
40222
|
}
|
|
40168
|
-
const swarmDirExists = await
|
|
40223
|
+
const swarmDirExists = await fs11.access(swarmDir).then(() => true).catch(() => false);
|
|
40169
40224
|
if (!swarmDirExists) {
|
|
40170
40225
|
return `\u274C No .swarm/ directory found in ${directory}. Run /swarm close from the project root, or run /swarm plan first.`;
|
|
40171
40226
|
}
|
|
@@ -40262,7 +40317,7 @@ async function handleCloseCommand(directory, args2) {
|
|
|
40262
40317
|
const lessonsFilePath = path17.join(swarmDir, "close-lessons.md");
|
|
40263
40318
|
let explicitLessons = [];
|
|
40264
40319
|
try {
|
|
40265
|
-
const lessonsText = await
|
|
40320
|
+
const lessonsText = await fs11.readFile(lessonsFilePath, "utf-8");
|
|
40266
40321
|
explicitLessons = lessonsText.split(`
|
|
40267
40322
|
`).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
40268
40323
|
} catch {}
|
|
@@ -40276,7 +40331,7 @@ async function handleCloseCommand(directory, args2) {
|
|
|
40276
40331
|
console.warn("[close-command] curateAndStoreSwarm error:", error93);
|
|
40277
40332
|
}
|
|
40278
40333
|
if (curationSucceeded && explicitLessons.length > 0) {
|
|
40279
|
-
await
|
|
40334
|
+
await fs11.unlink(lessonsFilePath).catch(() => {});
|
|
40280
40335
|
}
|
|
40281
40336
|
if (planExists && !planAlreadyDone) {
|
|
40282
40337
|
for (const phase of phases) {
|
|
@@ -40296,7 +40351,7 @@ async function handleCloseCommand(directory, args2) {
|
|
|
40296
40351
|
}
|
|
40297
40352
|
}
|
|
40298
40353
|
try {
|
|
40299
|
-
await
|
|
40354
|
+
await fs11.writeFile(planPath, JSON.stringify(planData, null, 2), "utf-8");
|
|
40300
40355
|
} catch (error93) {
|
|
40301
40356
|
const msg = error93 instanceof Error ? error93.message : String(error93);
|
|
40302
40357
|
warnings.push(`Failed to persist terminal plan.json state: ${msg}`);
|
|
@@ -40310,12 +40365,12 @@ async function handleCloseCommand(directory, args2) {
|
|
|
40310
40365
|
let archivedFileCount = 0;
|
|
40311
40366
|
const archivedActiveStateFiles = new Set;
|
|
40312
40367
|
try {
|
|
40313
|
-
await
|
|
40368
|
+
await fs11.mkdir(archiveDir, { recursive: true });
|
|
40314
40369
|
for (const artifact of ARCHIVE_ARTIFACTS) {
|
|
40315
40370
|
const srcPath = path17.join(swarmDir, artifact);
|
|
40316
40371
|
const destPath = path17.join(archiveDir, artifact);
|
|
40317
40372
|
try {
|
|
40318
|
-
await
|
|
40373
|
+
await fs11.copyFile(srcPath, destPath);
|
|
40319
40374
|
archivedFileCount++;
|
|
40320
40375
|
if (ACTIVE_STATE_TO_CLEAN.includes(artifact)) {
|
|
40321
40376
|
archivedActiveStateFiles.add(artifact);
|
|
@@ -40325,22 +40380,22 @@ async function handleCloseCommand(directory, args2) {
|
|
|
40325
40380
|
const evidenceDir = path17.join(swarmDir, "evidence");
|
|
40326
40381
|
const archiveEvidenceDir = path17.join(archiveDir, "evidence");
|
|
40327
40382
|
try {
|
|
40328
|
-
const evidenceEntries = await
|
|
40383
|
+
const evidenceEntries = await fs11.readdir(evidenceDir);
|
|
40329
40384
|
if (evidenceEntries.length > 0) {
|
|
40330
|
-
await
|
|
40385
|
+
await fs11.mkdir(archiveEvidenceDir, { recursive: true });
|
|
40331
40386
|
for (const entry of evidenceEntries) {
|
|
40332
40387
|
const srcEntry = path17.join(evidenceDir, entry);
|
|
40333
40388
|
const destEntry = path17.join(archiveEvidenceDir, entry);
|
|
40334
40389
|
try {
|
|
40335
|
-
const stat = await
|
|
40390
|
+
const stat = await fs11.stat(srcEntry);
|
|
40336
40391
|
if (stat.isDirectory()) {
|
|
40337
|
-
await
|
|
40338
|
-
const subEntries = await
|
|
40392
|
+
await fs11.mkdir(destEntry, { recursive: true });
|
|
40393
|
+
const subEntries = await fs11.readdir(srcEntry);
|
|
40339
40394
|
for (const sub of subEntries) {
|
|
40340
|
-
await
|
|
40395
|
+
await fs11.copyFile(path17.join(srcEntry, sub), path17.join(destEntry, sub)).catch(() => {});
|
|
40341
40396
|
}
|
|
40342
40397
|
} else {
|
|
40343
|
-
await
|
|
40398
|
+
await fs11.copyFile(srcEntry, destEntry);
|
|
40344
40399
|
}
|
|
40345
40400
|
archivedFileCount++;
|
|
40346
40401
|
} catch {}
|
|
@@ -40350,8 +40405,8 @@ async function handleCloseCommand(directory, args2) {
|
|
|
40350
40405
|
const sessionStatePath = path17.join(swarmDir, "session", "state.json");
|
|
40351
40406
|
try {
|
|
40352
40407
|
const archiveSessionDir = path17.join(archiveDir, "session");
|
|
40353
|
-
await
|
|
40354
|
-
await
|
|
40408
|
+
await fs11.mkdir(archiveSessionDir, { recursive: true });
|
|
40409
|
+
await fs11.copyFile(sessionStatePath, path17.join(archiveSessionDir, "state.json"));
|
|
40355
40410
|
archivedFileCount++;
|
|
40356
40411
|
} catch {}
|
|
40357
40412
|
archiveResult = `Archived ${archivedFileCount} artifact(s) to .swarm/archive/swarm-${timestamp}/`;
|
|
@@ -40376,7 +40431,7 @@ async function handleCloseCommand(directory, args2) {
|
|
|
40376
40431
|
}
|
|
40377
40432
|
const filePath = path17.join(swarmDir, artifact);
|
|
40378
40433
|
try {
|
|
40379
|
-
await
|
|
40434
|
+
await fs11.unlink(filePath);
|
|
40380
40435
|
cleanedFiles.push(artifact);
|
|
40381
40436
|
} catch {}
|
|
40382
40437
|
}
|
|
@@ -40384,18 +40439,18 @@ async function handleCloseCommand(directory, args2) {
|
|
|
40384
40439
|
warnings.push("Skipped active-state cleanup because no active-state files were archived. Files preserved to prevent data loss.");
|
|
40385
40440
|
}
|
|
40386
40441
|
try {
|
|
40387
|
-
const swarmFiles = await
|
|
40442
|
+
const swarmFiles = await fs11.readdir(swarmDir);
|
|
40388
40443
|
const configBackups = swarmFiles.filter((f) => f.startsWith("config-backup-") && f.endsWith(".json"));
|
|
40389
40444
|
for (const backup of configBackups) {
|
|
40390
40445
|
try {
|
|
40391
|
-
await
|
|
40446
|
+
await fs11.unlink(path17.join(swarmDir, backup));
|
|
40392
40447
|
configBackupsRemoved++;
|
|
40393
40448
|
} catch {}
|
|
40394
40449
|
}
|
|
40395
40450
|
const ledgerSiblings = swarmFiles.filter((f) => (f.startsWith("plan-ledger.archived-") || f.startsWith("plan-ledger.backup-")) && f.endsWith(".jsonl"));
|
|
40396
40451
|
for (const sibling of ledgerSiblings) {
|
|
40397
40452
|
try {
|
|
40398
|
-
await
|
|
40453
|
+
await fs11.unlink(path17.join(swarmDir, sibling));
|
|
40399
40454
|
} catch {}
|
|
40400
40455
|
}
|
|
40401
40456
|
} catch {}
|
|
@@ -40412,7 +40467,7 @@ async function handleCloseCommand(directory, args2) {
|
|
|
40412
40467
|
].join(`
|
|
40413
40468
|
`);
|
|
40414
40469
|
try {
|
|
40415
|
-
await
|
|
40470
|
+
await fs11.writeFile(contextPath, contextContent, "utf-8");
|
|
40416
40471
|
} catch (error93) {
|
|
40417
40472
|
const msg = error93 instanceof Error ? error93.message : String(error93);
|
|
40418
40473
|
warnings.push(`Failed to reset context.md: ${msg}`);
|
|
@@ -40543,7 +40598,7 @@ async function handleCloseCommand(directory, args2) {
|
|
|
40543
40598
|
].join(`
|
|
40544
40599
|
`);
|
|
40545
40600
|
try {
|
|
40546
|
-
await
|
|
40601
|
+
await fs11.writeFile(closeSummaryPath, summaryContent, "utf-8");
|
|
40547
40602
|
} catch (error93) {
|
|
40548
40603
|
const msg = error93 instanceof Error ? error93.message : String(error93);
|
|
40549
40604
|
warnings.push(`Failed to write close-summary.md: ${msg}`);
|
|
@@ -41003,7 +41058,7 @@ var init_event_bus = __esm(() => {
|
|
|
41003
41058
|
|
|
41004
41059
|
// src/hooks/curator.ts
|
|
41005
41060
|
import { randomUUID } from "crypto";
|
|
41006
|
-
import * as
|
|
41061
|
+
import * as fs12 from "fs";
|
|
41007
41062
|
import * as path19 from "path";
|
|
41008
41063
|
function parseKnowledgeRecommendations(llmOutput) {
|
|
41009
41064
|
const recommendations = [];
|
|
@@ -41098,10 +41153,10 @@ async function readCuratorSummary(directory) {
|
|
|
41098
41153
|
}
|
|
41099
41154
|
async function writeCuratorSummary(directory, summary) {
|
|
41100
41155
|
const resolvedPath = validateSwarmPath(directory, "curator-summary.json");
|
|
41101
|
-
|
|
41156
|
+
fs12.mkdirSync(path19.dirname(resolvedPath), { recursive: true });
|
|
41102
41157
|
const tempPath = `${resolvedPath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2)}`;
|
|
41103
41158
|
await Bun.write(tempPath, JSON.stringify(summary, null, 2));
|
|
41104
|
-
|
|
41159
|
+
fs12.renameSync(tempPath, resolvedPath);
|
|
41105
41160
|
}
|
|
41106
41161
|
function normalizeAgentName(name2) {
|
|
41107
41162
|
return name2.toLowerCase().replace(/^(mega|paid|local|lowtier|modelrelay)_/, "");
|
|
@@ -43037,7 +43092,7 @@ __export(exports_config_doctor, {
|
|
|
43037
43092
|
applySafeAutoFixes: () => applySafeAutoFixes
|
|
43038
43093
|
});
|
|
43039
43094
|
import * as crypto3 from "crypto";
|
|
43040
|
-
import * as
|
|
43095
|
+
import * as fs13 from "fs";
|
|
43041
43096
|
import * as os5 from "os";
|
|
43042
43097
|
import * as path23 from "path";
|
|
43043
43098
|
function getUserConfigDir3() {
|
|
@@ -43082,19 +43137,19 @@ function createConfigBackup(directory) {
|
|
|
43082
43137
|
const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
|
|
43083
43138
|
let configPath = projectConfigPath;
|
|
43084
43139
|
let content = null;
|
|
43085
|
-
if (
|
|
43140
|
+
if (fs13.existsSync(projectConfigPath)) {
|
|
43086
43141
|
try {
|
|
43087
|
-
content =
|
|
43142
|
+
content = fs13.readFileSync(projectConfigPath, "utf-8");
|
|
43088
43143
|
} catch (error93) {
|
|
43089
43144
|
log("[ConfigDoctor] project config read failed", {
|
|
43090
43145
|
error: error93 instanceof Error ? error93.message : String(error93)
|
|
43091
43146
|
});
|
|
43092
43147
|
}
|
|
43093
43148
|
}
|
|
43094
|
-
if (content === null &&
|
|
43149
|
+
if (content === null && fs13.existsSync(userConfigPath)) {
|
|
43095
43150
|
configPath = userConfigPath;
|
|
43096
43151
|
try {
|
|
43097
|
-
content =
|
|
43152
|
+
content = fs13.readFileSync(userConfigPath, "utf-8");
|
|
43098
43153
|
} catch (error93) {
|
|
43099
43154
|
log("[ConfigDoctor] user config read failed", {
|
|
43100
43155
|
error: error93 instanceof Error ? error93.message : String(error93)
|
|
@@ -43113,8 +43168,8 @@ function createConfigBackup(directory) {
|
|
|
43113
43168
|
}
|
|
43114
43169
|
function writeBackupArtifact(directory, backup) {
|
|
43115
43170
|
const swarmDir = path23.join(directory, ".swarm");
|
|
43116
|
-
if (!
|
|
43117
|
-
|
|
43171
|
+
if (!fs13.existsSync(swarmDir)) {
|
|
43172
|
+
fs13.mkdirSync(swarmDir, { recursive: true });
|
|
43118
43173
|
}
|
|
43119
43174
|
const backupFilename = `config-backup-${backup.createdAt}.json`;
|
|
43120
43175
|
const backupPath = path23.join(swarmDir, backupFilename);
|
|
@@ -43125,15 +43180,15 @@ function writeBackupArtifact(directory, backup) {
|
|
|
43125
43180
|
content: backup.content,
|
|
43126
43181
|
preview: backup.content.substring(0, 500) + (backup.content.length > 500 ? "..." : "")
|
|
43127
43182
|
};
|
|
43128
|
-
|
|
43183
|
+
fs13.writeFileSync(backupPath, JSON.stringify(artifact, null, 2), "utf-8");
|
|
43129
43184
|
return backupPath;
|
|
43130
43185
|
}
|
|
43131
43186
|
function restoreFromBackup(backupPath, directory) {
|
|
43132
|
-
if (!
|
|
43187
|
+
if (!fs13.existsSync(backupPath)) {
|
|
43133
43188
|
return null;
|
|
43134
43189
|
}
|
|
43135
43190
|
try {
|
|
43136
|
-
const artifact = JSON.parse(
|
|
43191
|
+
const artifact = JSON.parse(fs13.readFileSync(backupPath, "utf-8"));
|
|
43137
43192
|
if (!artifact.content || !artifact.configPath || !artifact.contentHash) {
|
|
43138
43193
|
return null;
|
|
43139
43194
|
}
|
|
@@ -43148,10 +43203,10 @@ function restoreFromBackup(backupPath, directory) {
|
|
|
43148
43203
|
}
|
|
43149
43204
|
const targetPath = artifact.configPath;
|
|
43150
43205
|
const targetDir = path23.dirname(targetPath);
|
|
43151
|
-
if (!
|
|
43152
|
-
|
|
43206
|
+
if (!fs13.existsSync(targetDir)) {
|
|
43207
|
+
fs13.mkdirSync(targetDir, { recursive: true });
|
|
43153
43208
|
}
|
|
43154
|
-
|
|
43209
|
+
fs13.writeFileSync(targetPath, artifact.content, "utf-8");
|
|
43155
43210
|
return targetPath;
|
|
43156
43211
|
} catch {
|
|
43157
43212
|
return null;
|
|
@@ -43161,12 +43216,12 @@ function readConfigFromFile(directory) {
|
|
|
43161
43216
|
const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
|
|
43162
43217
|
let configPath = projectConfigPath;
|
|
43163
43218
|
let configContent = null;
|
|
43164
|
-
if (
|
|
43219
|
+
if (fs13.existsSync(projectConfigPath)) {
|
|
43165
43220
|
configPath = projectConfigPath;
|
|
43166
|
-
configContent =
|
|
43167
|
-
} else if (
|
|
43221
|
+
configContent = fs13.readFileSync(projectConfigPath, "utf-8");
|
|
43222
|
+
} else if (fs13.existsSync(userConfigPath)) {
|
|
43168
43223
|
configPath = userConfigPath;
|
|
43169
|
-
configContent =
|
|
43224
|
+
configContent = fs13.readFileSync(userConfigPath, "utf-8");
|
|
43170
43225
|
}
|
|
43171
43226
|
if (configContent === null) {
|
|
43172
43227
|
return null;
|
|
@@ -43462,9 +43517,9 @@ function runConfigDoctor(config3, directory) {
|
|
|
43462
43517
|
const hasAutoFixableIssues = findings.some((f) => f.autoFixable && f.proposedFix?.risk === "low");
|
|
43463
43518
|
const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
|
|
43464
43519
|
let configSource = "defaults";
|
|
43465
|
-
if (
|
|
43520
|
+
if (fs13.existsSync(projectConfigPath)) {
|
|
43466
43521
|
configSource = projectConfigPath;
|
|
43467
|
-
} else if (
|
|
43522
|
+
} else if (fs13.existsSync(userConfigPath)) {
|
|
43468
43523
|
configSource = userConfigPath;
|
|
43469
43524
|
}
|
|
43470
43525
|
return {
|
|
@@ -43493,12 +43548,12 @@ function applySafeAutoFixes(directory, result) {
|
|
|
43493
43548
|
const { userConfigPath, projectConfigPath } = getConfigPaths(directory);
|
|
43494
43549
|
let configPath = projectConfigPath;
|
|
43495
43550
|
let configContent;
|
|
43496
|
-
if (
|
|
43551
|
+
if (fs13.existsSync(projectConfigPath)) {
|
|
43497
43552
|
configPath = projectConfigPath;
|
|
43498
|
-
configContent =
|
|
43499
|
-
} else if (
|
|
43553
|
+
configContent = fs13.readFileSync(projectConfigPath, "utf-8");
|
|
43554
|
+
} else if (fs13.existsSync(userConfigPath)) {
|
|
43500
43555
|
configPath = userConfigPath;
|
|
43501
|
-
configContent =
|
|
43556
|
+
configContent = fs13.readFileSync(userConfigPath, "utf-8");
|
|
43502
43557
|
} else {
|
|
43503
43558
|
return { appliedFixes, updatedConfigPath: null };
|
|
43504
43559
|
}
|
|
@@ -43568,18 +43623,18 @@ function applySafeAutoFixes(directory, result) {
|
|
|
43568
43623
|
}
|
|
43569
43624
|
if (appliedFixes.length > 0) {
|
|
43570
43625
|
const configDir = path23.dirname(configPath);
|
|
43571
|
-
if (!
|
|
43572
|
-
|
|
43626
|
+
if (!fs13.existsSync(configDir)) {
|
|
43627
|
+
fs13.mkdirSync(configDir, { recursive: true });
|
|
43573
43628
|
}
|
|
43574
|
-
|
|
43629
|
+
fs13.writeFileSync(configPath, JSON.stringify(config3, null, 2), "utf-8");
|
|
43575
43630
|
updatedConfigPath = configPath;
|
|
43576
43631
|
}
|
|
43577
43632
|
return { appliedFixes, updatedConfigPath };
|
|
43578
43633
|
}
|
|
43579
43634
|
function writeDoctorArtifact(directory, result) {
|
|
43580
43635
|
const swarmDir = path23.join(directory, ".swarm");
|
|
43581
|
-
if (!
|
|
43582
|
-
|
|
43636
|
+
if (!fs13.existsSync(swarmDir)) {
|
|
43637
|
+
fs13.mkdirSync(swarmDir, { recursive: true });
|
|
43583
43638
|
}
|
|
43584
43639
|
const artifactFilename = "config-doctor.json";
|
|
43585
43640
|
const artifactPath = path23.join(swarmDir, artifactFilename);
|
|
@@ -43603,7 +43658,7 @@ function writeDoctorArtifact(directory, result) {
|
|
|
43603
43658
|
} : null
|
|
43604
43659
|
}))
|
|
43605
43660
|
};
|
|
43606
|
-
|
|
43661
|
+
fs13.writeFileSync(artifactPath, JSON.stringify(guiOutput, null, 2), "utf-8");
|
|
43607
43662
|
return artifactPath;
|
|
43608
43663
|
}
|
|
43609
43664
|
function shouldRunOnStartup(automationConfig) {
|
|
@@ -44690,7 +44745,7 @@ var init_detector = __esm(() => {
|
|
|
44690
44745
|
});
|
|
44691
44746
|
|
|
44692
44747
|
// src/build/discovery.ts
|
|
44693
|
-
import * as
|
|
44748
|
+
import * as fs14 from "fs";
|
|
44694
44749
|
import * as path24 from "path";
|
|
44695
44750
|
function isCommandAvailable(command) {
|
|
44696
44751
|
if (toolchainCache.has(command)) {
|
|
@@ -44720,7 +44775,7 @@ function findBuildFiles(workingDir, patterns) {
|
|
|
44720
44775
|
if (pattern.includes("*")) {
|
|
44721
44776
|
const dir = workingDir;
|
|
44722
44777
|
try {
|
|
44723
|
-
const files =
|
|
44778
|
+
const files = fs14.readdirSync(dir);
|
|
44724
44779
|
const regex = simpleGlobToRegex(pattern);
|
|
44725
44780
|
const matches = files.filter((f) => regex.test(f));
|
|
44726
44781
|
if (matches.length > 0) {
|
|
@@ -44729,7 +44784,7 @@ function findBuildFiles(workingDir, patterns) {
|
|
|
44729
44784
|
} catch {}
|
|
44730
44785
|
} else {
|
|
44731
44786
|
const filePath = path24.join(workingDir, pattern);
|
|
44732
|
-
if (
|
|
44787
|
+
if (fs14.existsSync(filePath)) {
|
|
44733
44788
|
return filePath;
|
|
44734
44789
|
}
|
|
44735
44790
|
}
|
|
@@ -44738,11 +44793,11 @@ function findBuildFiles(workingDir, patterns) {
|
|
|
44738
44793
|
}
|
|
44739
44794
|
function getRepoDefinedScripts(workingDir, scripts) {
|
|
44740
44795
|
const packageJsonPath = path24.join(workingDir, "package.json");
|
|
44741
|
-
if (!
|
|
44796
|
+
if (!fs14.existsSync(packageJsonPath)) {
|
|
44742
44797
|
return [];
|
|
44743
44798
|
}
|
|
44744
44799
|
try {
|
|
44745
|
-
const content =
|
|
44800
|
+
const content = fs14.readFileSync(packageJsonPath, "utf-8");
|
|
44746
44801
|
const pkg = JSON.parse(content);
|
|
44747
44802
|
if (!pkg.scripts || typeof pkg.scripts !== "object") {
|
|
44748
44803
|
return [];
|
|
@@ -44779,7 +44834,7 @@ function findAllBuildFiles(workingDir) {
|
|
|
44779
44834
|
findFilesRecursive(workingDir, regex, allBuildFiles);
|
|
44780
44835
|
} else {
|
|
44781
44836
|
const filePath = path24.join(workingDir, pattern);
|
|
44782
|
-
if (
|
|
44837
|
+
if (fs14.existsSync(filePath)) {
|
|
44783
44838
|
allBuildFiles.add(filePath);
|
|
44784
44839
|
}
|
|
44785
44840
|
}
|
|
@@ -44789,7 +44844,7 @@ function findAllBuildFiles(workingDir) {
|
|
|
44789
44844
|
}
|
|
44790
44845
|
function findFilesRecursive(dir, regex, results) {
|
|
44791
44846
|
try {
|
|
44792
|
-
const entries =
|
|
44847
|
+
const entries = fs14.readdirSync(dir, { withFileTypes: true });
|
|
44793
44848
|
for (const entry of entries) {
|
|
44794
44849
|
const fullPath = path24.join(dir, entry.name);
|
|
44795
44850
|
if (entry.isDirectory() && !["node_modules", ".git", "dist", "build", "target"].includes(entry.name)) {
|
|
@@ -44815,7 +44870,7 @@ async function discoverBuildCommandsFromProfiles(workingDir) {
|
|
|
44815
44870
|
for (const cmd of sortedCommands) {
|
|
44816
44871
|
if (cmd.detectFile) {
|
|
44817
44872
|
const detectFilePath = path24.join(workingDir, cmd.detectFile);
|
|
44818
|
-
if (!
|
|
44873
|
+
if (!fs14.existsSync(detectFilePath)) {
|
|
44819
44874
|
continue;
|
|
44820
44875
|
}
|
|
44821
44876
|
}
|
|
@@ -45044,12 +45099,12 @@ __export(exports_tool_doctor, {
|
|
|
45044
45099
|
runToolDoctor: () => runToolDoctor,
|
|
45045
45100
|
getBinaryReadinessAdvisory: () => getBinaryReadinessAdvisory
|
|
45046
45101
|
});
|
|
45047
|
-
import * as
|
|
45102
|
+
import * as fs15 from "fs";
|
|
45048
45103
|
import * as path25 from "path";
|
|
45049
45104
|
function extractRegisteredToolKeys(indexPath) {
|
|
45050
45105
|
const registeredKeys = new Set;
|
|
45051
45106
|
try {
|
|
45052
|
-
const content =
|
|
45107
|
+
const content = fs15.readFileSync(indexPath, "utf-8");
|
|
45053
45108
|
const toolBlockMatch = content.match(/tool:\s*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}/s);
|
|
45054
45109
|
if (!toolBlockMatch) {
|
|
45055
45110
|
return registeredKeys;
|
|
@@ -45114,7 +45169,7 @@ function runToolDoctor(_directory, pluginRoot) {
|
|
|
45114
45169
|
const findings = [];
|
|
45115
45170
|
const resolvedPluginRoot = pluginRoot ?? path25.resolve(import.meta.dir, "..", "..");
|
|
45116
45171
|
const indexPath = path25.join(resolvedPluginRoot, "src", "index.ts");
|
|
45117
|
-
if (!
|
|
45172
|
+
if (!fs15.existsSync(indexPath)) {
|
|
45118
45173
|
return {
|
|
45119
45174
|
findings: [
|
|
45120
45175
|
{
|
|
@@ -46360,7 +46415,7 @@ var init_history = __esm(() => {
|
|
|
46360
46415
|
// src/hooks/knowledge-migrator.ts
|
|
46361
46416
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
46362
46417
|
import { existsSync as existsSync13, readFileSync as readFileSync10 } from "fs";
|
|
46363
|
-
import { mkdir as
|
|
46418
|
+
import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
|
|
46364
46419
|
import * as path26 from "path";
|
|
46365
46420
|
async function migrateContextToKnowledge(directory, config3) {
|
|
46366
46421
|
const sentinelPath = path26.join(directory, ".swarm", ".knowledge-migrated");
|
|
@@ -46581,7 +46636,7 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
|
46581
46636
|
schema_version: 1,
|
|
46582
46637
|
migration_tool: "knowledge-migrator.ts"
|
|
46583
46638
|
};
|
|
46584
|
-
await
|
|
46639
|
+
await mkdir5(path26.dirname(sentinelPath), { recursive: true });
|
|
46585
46640
|
await writeFile5(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
|
|
46586
46641
|
}
|
|
46587
46642
|
var init_knowledge_migrator = __esm(() => {
|
|
@@ -46833,7 +46888,7 @@ var init_plan = __esm(() => {
|
|
|
46833
46888
|
});
|
|
46834
46889
|
|
|
46835
46890
|
// src/utils/path-security.ts
|
|
46836
|
-
import * as
|
|
46891
|
+
import * as fs16 from "fs";
|
|
46837
46892
|
import * as path27 from "path";
|
|
46838
46893
|
function containsPathTraversal(str) {
|
|
46839
46894
|
if (/\.\.[/\\]/.test(str))
|
|
@@ -46883,13 +46938,13 @@ function validateDirectory(directory) {
|
|
|
46883
46938
|
function validateSymlinkBoundary(targetPath, rootPath) {
|
|
46884
46939
|
let realTarget;
|
|
46885
46940
|
try {
|
|
46886
|
-
realTarget =
|
|
46941
|
+
realTarget = fs16.realpathSync(targetPath);
|
|
46887
46942
|
} catch {
|
|
46888
46943
|
realTarget = path27.normalize(targetPath);
|
|
46889
46944
|
}
|
|
46890
46945
|
let realRoot;
|
|
46891
46946
|
try {
|
|
46892
|
-
realRoot =
|
|
46947
|
+
realRoot = fs16.realpathSync(rootPath);
|
|
46893
46948
|
} catch {
|
|
46894
46949
|
realRoot = path27.normalize(rootPath);
|
|
46895
46950
|
}
|
|
@@ -46902,7 +46957,7 @@ function validateSymlinkBoundary(targetPath, rootPath) {
|
|
|
46902
46957
|
var init_path_security = () => {};
|
|
46903
46958
|
|
|
46904
46959
|
// src/tools/lint.ts
|
|
46905
|
-
import * as
|
|
46960
|
+
import * as fs17 from "fs";
|
|
46906
46961
|
import * as path28 from "path";
|
|
46907
46962
|
function validateArgs(args2) {
|
|
46908
46963
|
if (typeof args2 !== "object" || args2 === null)
|
|
@@ -46932,7 +46987,7 @@ function getLinterCommand(linter, mode, projectDir) {
|
|
|
46932
46987
|
}
|
|
46933
46988
|
function getAdditionalLinterCommand(linter, mode, cwd) {
|
|
46934
46989
|
const gradlewName = process.platform === "win32" ? "gradlew.bat" : "gradlew";
|
|
46935
|
-
const gradlew =
|
|
46990
|
+
const gradlew = fs17.existsSync(path28.join(cwd, gradlewName)) ? path28.join(cwd, gradlewName) : null;
|
|
46936
46991
|
switch (linter) {
|
|
46937
46992
|
case "ruff":
|
|
46938
46993
|
return mode === "fix" ? ["ruff", "check", "--fix", "."] : ["ruff", "check", "."];
|
|
@@ -46966,12 +47021,12 @@ function getAdditionalLinterCommand(linter, mode, cwd) {
|
|
|
46966
47021
|
}
|
|
46967
47022
|
}
|
|
46968
47023
|
function detectRuff(cwd) {
|
|
46969
|
-
if (
|
|
47024
|
+
if (fs17.existsSync(path28.join(cwd, "ruff.toml")))
|
|
46970
47025
|
return isCommandAvailable("ruff");
|
|
46971
47026
|
try {
|
|
46972
47027
|
const pyproject = path28.join(cwd, "pyproject.toml");
|
|
46973
|
-
if (
|
|
46974
|
-
const content =
|
|
47028
|
+
if (fs17.existsSync(pyproject)) {
|
|
47029
|
+
const content = fs17.readFileSync(pyproject, "utf-8");
|
|
46975
47030
|
if (content.includes("[tool.ruff]"))
|
|
46976
47031
|
return isCommandAvailable("ruff");
|
|
46977
47032
|
}
|
|
@@ -46979,21 +47034,21 @@ function detectRuff(cwd) {
|
|
|
46979
47034
|
return false;
|
|
46980
47035
|
}
|
|
46981
47036
|
function detectClippy(cwd) {
|
|
46982
|
-
return
|
|
47037
|
+
return fs17.existsSync(path28.join(cwd, "Cargo.toml")) && isCommandAvailable("cargo");
|
|
46983
47038
|
}
|
|
46984
47039
|
function detectGolangciLint(cwd) {
|
|
46985
|
-
return
|
|
47040
|
+
return fs17.existsSync(path28.join(cwd, "go.mod")) && isCommandAvailable("golangci-lint");
|
|
46986
47041
|
}
|
|
46987
47042
|
function detectCheckstyle(cwd) {
|
|
46988
|
-
const hasMaven =
|
|
46989
|
-
const hasGradle =
|
|
46990
|
-
const hasBinary = hasMaven && isCommandAvailable("mvn") || hasGradle && (
|
|
47043
|
+
const hasMaven = fs17.existsSync(path28.join(cwd, "pom.xml"));
|
|
47044
|
+
const hasGradle = fs17.existsSync(path28.join(cwd, "build.gradle")) || fs17.existsSync(path28.join(cwd, "build.gradle.kts"));
|
|
47045
|
+
const hasBinary = hasMaven && isCommandAvailable("mvn") || hasGradle && (fs17.existsSync(path28.join(cwd, "gradlew")) || isCommandAvailable("gradle"));
|
|
46991
47046
|
return (hasMaven || hasGradle) && hasBinary;
|
|
46992
47047
|
}
|
|
46993
47048
|
function detectKtlint(cwd) {
|
|
46994
|
-
const hasKotlin =
|
|
47049
|
+
const hasKotlin = fs17.existsSync(path28.join(cwd, "build.gradle.kts")) || fs17.existsSync(path28.join(cwd, "build.gradle")) || (() => {
|
|
46995
47050
|
try {
|
|
46996
|
-
return
|
|
47051
|
+
return fs17.readdirSync(cwd).some((f) => f.endsWith(".kt") || f.endsWith(".kts"));
|
|
46997
47052
|
} catch {
|
|
46998
47053
|
return false;
|
|
46999
47054
|
}
|
|
@@ -47002,7 +47057,7 @@ function detectKtlint(cwd) {
|
|
|
47002
47057
|
}
|
|
47003
47058
|
function detectDotnetFormat(cwd) {
|
|
47004
47059
|
try {
|
|
47005
|
-
const files =
|
|
47060
|
+
const files = fs17.readdirSync(cwd);
|
|
47006
47061
|
const hasCsproj = files.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"));
|
|
47007
47062
|
return hasCsproj && isCommandAvailable("dotnet");
|
|
47008
47063
|
} catch {
|
|
@@ -47010,14 +47065,14 @@ function detectDotnetFormat(cwd) {
|
|
|
47010
47065
|
}
|
|
47011
47066
|
}
|
|
47012
47067
|
function detectCppcheck(cwd) {
|
|
47013
|
-
if (
|
|
47068
|
+
if (fs17.existsSync(path28.join(cwd, "CMakeLists.txt"))) {
|
|
47014
47069
|
return isCommandAvailable("cppcheck");
|
|
47015
47070
|
}
|
|
47016
47071
|
try {
|
|
47017
47072
|
const dirsToCheck = [cwd, path28.join(cwd, "src")];
|
|
47018
47073
|
const hasCpp = dirsToCheck.some((dir) => {
|
|
47019
47074
|
try {
|
|
47020
|
-
return
|
|
47075
|
+
return fs17.readdirSync(dir).some((f) => /\.(c|cpp|cc|cxx|h|hpp)$/.test(f));
|
|
47021
47076
|
} catch {
|
|
47022
47077
|
return false;
|
|
47023
47078
|
}
|
|
@@ -47028,13 +47083,13 @@ function detectCppcheck(cwd) {
|
|
|
47028
47083
|
}
|
|
47029
47084
|
}
|
|
47030
47085
|
function detectSwiftlint(cwd) {
|
|
47031
|
-
return
|
|
47086
|
+
return fs17.existsSync(path28.join(cwd, "Package.swift")) && isCommandAvailable("swiftlint");
|
|
47032
47087
|
}
|
|
47033
47088
|
function detectDartAnalyze(cwd) {
|
|
47034
|
-
return
|
|
47089
|
+
return fs17.existsSync(path28.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
|
|
47035
47090
|
}
|
|
47036
47091
|
function detectRubocop(cwd) {
|
|
47037
|
-
return (
|
|
47092
|
+
return (fs17.existsSync(path28.join(cwd, "Gemfile")) || fs17.existsSync(path28.join(cwd, "gems.rb")) || fs17.existsSync(path28.join(cwd, ".rubocop.yml"))) && (isCommandAvailable("rubocop") || isCommandAvailable("bundle"));
|
|
47038
47093
|
}
|
|
47039
47094
|
function detectAdditionalLinter(cwd) {
|
|
47040
47095
|
if (detectRuff(cwd))
|
|
@@ -47063,7 +47118,7 @@ function resolveLinterBinPath(linter, projectDir) {
|
|
|
47063
47118
|
const isWindows = process.platform === "win32";
|
|
47064
47119
|
const binName = linter === "biome" ? isWindows ? "biome.EXE" : "biome" : isWindows ? "eslint.cmd" : "eslint";
|
|
47065
47120
|
const localBin = path28.join(projectDir, "node_modules", ".bin", binName);
|
|
47066
|
-
if (
|
|
47121
|
+
if (fs17.existsSync(localBin))
|
|
47067
47122
|
return localBin;
|
|
47068
47123
|
const ancestor = findBinInAncestors(path28.dirname(projectDir), binName);
|
|
47069
47124
|
if (ancestor)
|
|
@@ -47077,7 +47132,7 @@ function findBinInAncestors(startDir, binName) {
|
|
|
47077
47132
|
let dir = startDir;
|
|
47078
47133
|
while (true) {
|
|
47079
47134
|
const candidate = path28.join(dir, "node_modules", ".bin", binName);
|
|
47080
|
-
if (
|
|
47135
|
+
if (fs17.existsSync(candidate))
|
|
47081
47136
|
return candidate;
|
|
47082
47137
|
const parent = path28.dirname(dir);
|
|
47083
47138
|
if (parent === dir)
|
|
@@ -47092,7 +47147,7 @@ function findBinInEnvPath(binName) {
|
|
|
47092
47147
|
if (!dir)
|
|
47093
47148
|
continue;
|
|
47094
47149
|
const candidate = path28.join(dir, binName);
|
|
47095
|
-
if (
|
|
47150
|
+
if (fs17.existsSync(candidate))
|
|
47096
47151
|
return candidate;
|
|
47097
47152
|
}
|
|
47098
47153
|
return null;
|
|
@@ -47100,7 +47155,7 @@ function findBinInEnvPath(binName) {
|
|
|
47100
47155
|
async function detectAvailableLinter(directory) {
|
|
47101
47156
|
if (!directory)
|
|
47102
47157
|
return null;
|
|
47103
|
-
if (!
|
|
47158
|
+
if (!fs17.existsSync(directory))
|
|
47104
47159
|
return null;
|
|
47105
47160
|
const projectDir = directory;
|
|
47106
47161
|
const isWindows = process.platform === "win32";
|
|
@@ -47133,7 +47188,7 @@ async function _detectAvailableLinter(_projectDir, biomeBin, eslintBin) {
|
|
|
47133
47188
|
const result = await Promise.race([biomeExit, timeout]);
|
|
47134
47189
|
if (result === "timeout") {
|
|
47135
47190
|
biomeProc.kill();
|
|
47136
|
-
} else if (biomeProc.exitCode === 0 &&
|
|
47191
|
+
} else if (biomeProc.exitCode === 0 && fs17.existsSync(biomeBin)) {
|
|
47137
47192
|
return "biome";
|
|
47138
47193
|
}
|
|
47139
47194
|
} catch {}
|
|
@@ -47147,7 +47202,7 @@ async function _detectAvailableLinter(_projectDir, biomeBin, eslintBin) {
|
|
|
47147
47202
|
const result = await Promise.race([eslintExit, timeout]);
|
|
47148
47203
|
if (result === "timeout") {
|
|
47149
47204
|
eslintProc.kill();
|
|
47150
|
-
} else if (eslintProc.exitCode === 0 &&
|
|
47205
|
+
} else if (eslintProc.exitCode === 0 && fs17.existsSync(eslintBin)) {
|
|
47151
47206
|
return "eslint";
|
|
47152
47207
|
}
|
|
47153
47208
|
} catch {}
|
|
@@ -47325,7 +47380,7 @@ For Rust: rustup component add clippy`
|
|
|
47325
47380
|
});
|
|
47326
47381
|
|
|
47327
47382
|
// src/tools/secretscan.ts
|
|
47328
|
-
import * as
|
|
47383
|
+
import * as fs18 from "fs";
|
|
47329
47384
|
import * as path29 from "path";
|
|
47330
47385
|
function calculateShannonEntropy(str) {
|
|
47331
47386
|
if (str.length === 0)
|
|
@@ -47376,9 +47431,9 @@ function isGlobOrPathPattern(pattern) {
|
|
|
47376
47431
|
function loadSecretScanIgnore(scanDir) {
|
|
47377
47432
|
const ignorePath = path29.join(scanDir, ".secretscanignore");
|
|
47378
47433
|
try {
|
|
47379
|
-
if (!
|
|
47434
|
+
if (!fs18.existsSync(ignorePath))
|
|
47380
47435
|
return [];
|
|
47381
|
-
const content =
|
|
47436
|
+
const content = fs18.readFileSync(ignorePath, "utf8");
|
|
47382
47437
|
const patterns = [];
|
|
47383
47438
|
for (const rawLine of content.split(/\r?\n/)) {
|
|
47384
47439
|
const line = rawLine.trim();
|
|
@@ -47496,7 +47551,7 @@ function createRedactedContext(line, findings) {
|
|
|
47496
47551
|
function scanFileForSecrets(filePath) {
|
|
47497
47552
|
const findings = [];
|
|
47498
47553
|
try {
|
|
47499
|
-
const lstat =
|
|
47554
|
+
const lstat = fs18.lstatSync(filePath);
|
|
47500
47555
|
if (lstat.isSymbolicLink()) {
|
|
47501
47556
|
return findings;
|
|
47502
47557
|
}
|
|
@@ -47505,14 +47560,14 @@ function scanFileForSecrets(filePath) {
|
|
|
47505
47560
|
}
|
|
47506
47561
|
let buffer;
|
|
47507
47562
|
if (O_NOFOLLOW !== undefined) {
|
|
47508
|
-
const fd =
|
|
47563
|
+
const fd = fs18.openSync(filePath, "r", O_NOFOLLOW);
|
|
47509
47564
|
try {
|
|
47510
|
-
buffer =
|
|
47565
|
+
buffer = fs18.readFileSync(fd);
|
|
47511
47566
|
} finally {
|
|
47512
|
-
|
|
47567
|
+
fs18.closeSync(fd);
|
|
47513
47568
|
}
|
|
47514
47569
|
} else {
|
|
47515
|
-
buffer =
|
|
47570
|
+
buffer = fs18.readFileSync(filePath);
|
|
47516
47571
|
}
|
|
47517
47572
|
if (isBinaryFile(filePath, buffer)) {
|
|
47518
47573
|
return findings;
|
|
@@ -47567,7 +47622,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
47567
47622
|
const files = [];
|
|
47568
47623
|
let entries;
|
|
47569
47624
|
try {
|
|
47570
|
-
entries =
|
|
47625
|
+
entries = fs18.readdirSync(dir);
|
|
47571
47626
|
} catch {
|
|
47572
47627
|
stats.fileErrors++;
|
|
47573
47628
|
return files;
|
|
@@ -47590,7 +47645,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
47590
47645
|
}
|
|
47591
47646
|
let lstat;
|
|
47592
47647
|
try {
|
|
47593
|
-
lstat =
|
|
47648
|
+
lstat = fs18.lstatSync(fullPath);
|
|
47594
47649
|
} catch {
|
|
47595
47650
|
stats.fileErrors++;
|
|
47596
47651
|
continue;
|
|
@@ -47602,7 +47657,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
47602
47657
|
if (lstat.isDirectory()) {
|
|
47603
47658
|
let realPath;
|
|
47604
47659
|
try {
|
|
47605
|
-
realPath =
|
|
47660
|
+
realPath = fs18.realpathSync(fullPath);
|
|
47606
47661
|
} catch {
|
|
47607
47662
|
stats.fileErrors++;
|
|
47608
47663
|
continue;
|
|
@@ -47820,7 +47875,7 @@ var init_secretscan = __esm(() => {
|
|
|
47820
47875
|
redactTemplate: () => "SK[REDACTED]"
|
|
47821
47876
|
}
|
|
47822
47877
|
];
|
|
47823
|
-
O_NOFOLLOW = process.platform !== "win32" ?
|
|
47878
|
+
O_NOFOLLOW = process.platform !== "win32" ? fs18.constants.O_NOFOLLOW : undefined;
|
|
47824
47879
|
secretscan = createSwarmTool({
|
|
47825
47880
|
description: "Scan directory for potential secrets (API keys, tokens, passwords) using regex patterns and entropy heuristics. Returns metadata-only findings with redacted previews - NEVER returns raw secrets. Excludes common directories (node_modules, .git, dist, etc.) by default. Supports glob patterns (e.g. **/.svelte-kit/**, **/*.test.ts) and reads .secretscanignore at the scan root.",
|
|
47826
47881
|
args: {
|
|
@@ -47880,12 +47935,12 @@ var init_secretscan = __esm(() => {
|
|
|
47880
47935
|
const _scanDirRaw = path29.resolve(directory);
|
|
47881
47936
|
const scanDir = (() => {
|
|
47882
47937
|
try {
|
|
47883
|
-
return
|
|
47938
|
+
return fs18.realpathSync(_scanDirRaw);
|
|
47884
47939
|
} catch {
|
|
47885
47940
|
return _scanDirRaw;
|
|
47886
47941
|
}
|
|
47887
47942
|
})();
|
|
47888
|
-
if (!
|
|
47943
|
+
if (!fs18.existsSync(scanDir)) {
|
|
47889
47944
|
const errorResult = {
|
|
47890
47945
|
error: "directory not found",
|
|
47891
47946
|
scan_dir: directory,
|
|
@@ -47896,7 +47951,7 @@ var init_secretscan = __esm(() => {
|
|
|
47896
47951
|
};
|
|
47897
47952
|
return JSON.stringify(errorResult, null, 2);
|
|
47898
47953
|
}
|
|
47899
|
-
const dirStat =
|
|
47954
|
+
const dirStat = fs18.statSync(scanDir);
|
|
47900
47955
|
if (!dirStat.isDirectory()) {
|
|
47901
47956
|
const errorResult = {
|
|
47902
47957
|
error: "target must be a directory, not a file",
|
|
@@ -47947,7 +48002,7 @@ var init_secretscan = __esm(() => {
|
|
|
47947
48002
|
break;
|
|
47948
48003
|
const fileFindings = scanFileForSecrets(filePath);
|
|
47949
48004
|
try {
|
|
47950
|
-
const stat2 =
|
|
48005
|
+
const stat2 = fs18.statSync(filePath);
|
|
47951
48006
|
if (stat2.size > MAX_FILE_SIZE_BYTES) {
|
|
47952
48007
|
skippedFiles++;
|
|
47953
48008
|
continue;
|
|
@@ -48019,7 +48074,7 @@ var init_secretscan = __esm(() => {
|
|
|
48019
48074
|
});
|
|
48020
48075
|
|
|
48021
48076
|
// src/test-impact/analyzer.ts
|
|
48022
|
-
import
|
|
48077
|
+
import fs19 from "fs";
|
|
48023
48078
|
import path30 from "path";
|
|
48024
48079
|
function normalizePath(p) {
|
|
48025
48080
|
return p.replace(/\\/g, "/");
|
|
@@ -48027,7 +48082,7 @@ function normalizePath(p) {
|
|
|
48027
48082
|
function isCacheStale(impactMap, generatedAtMs) {
|
|
48028
48083
|
for (const sourcePath of Object.keys(impactMap)) {
|
|
48029
48084
|
try {
|
|
48030
|
-
const stat2 =
|
|
48085
|
+
const stat2 = fs19.statSync(sourcePath);
|
|
48031
48086
|
if (stat2.mtimeMs > generatedAtMs) {
|
|
48032
48087
|
return true;
|
|
48033
48088
|
}
|
|
@@ -48043,13 +48098,13 @@ function resolveRelativeImport(fromDir, importPath) {
|
|
|
48043
48098
|
}
|
|
48044
48099
|
const resolved = path30.resolve(fromDir, importPath);
|
|
48045
48100
|
if (path30.extname(resolved)) {
|
|
48046
|
-
if (
|
|
48101
|
+
if (fs19.existsSync(resolved) && fs19.statSync(resolved).isFile()) {
|
|
48047
48102
|
return normalizePath(resolved);
|
|
48048
48103
|
}
|
|
48049
48104
|
} else {
|
|
48050
48105
|
for (const ext of EXTENSIONS_TO_TRY) {
|
|
48051
48106
|
const withExt = resolved + ext;
|
|
48052
|
-
if (
|
|
48107
|
+
if (fs19.existsSync(withExt) && fs19.statSync(withExt).isFile()) {
|
|
48053
48108
|
return normalizePath(withExt);
|
|
48054
48109
|
}
|
|
48055
48110
|
}
|
|
@@ -48068,13 +48123,13 @@ function findTestFilesSync(cwd) {
|
|
|
48068
48123
|
function walk(dir, visitedInodes) {
|
|
48069
48124
|
let entries;
|
|
48070
48125
|
try {
|
|
48071
|
-
entries =
|
|
48126
|
+
entries = fs19.readdirSync(dir, { withFileTypes: true });
|
|
48072
48127
|
} catch {
|
|
48073
48128
|
return;
|
|
48074
48129
|
}
|
|
48075
48130
|
let dirInode;
|
|
48076
48131
|
try {
|
|
48077
|
-
dirInode =
|
|
48132
|
+
dirInode = fs19.statSync(dir).ino;
|
|
48078
48133
|
} catch {
|
|
48079
48134
|
return;
|
|
48080
48135
|
}
|
|
@@ -48122,7 +48177,7 @@ async function buildImpactMapInternal(cwd) {
|
|
|
48122
48177
|
for (const testFile of testFiles) {
|
|
48123
48178
|
let content;
|
|
48124
48179
|
try {
|
|
48125
|
-
content =
|
|
48180
|
+
content = fs19.readFileSync(testFile, "utf-8");
|
|
48126
48181
|
} catch {
|
|
48127
48182
|
continue;
|
|
48128
48183
|
}
|
|
@@ -48153,9 +48208,9 @@ async function buildImpactMap(cwd) {
|
|
|
48153
48208
|
}
|
|
48154
48209
|
async function loadImpactMap(cwd) {
|
|
48155
48210
|
const cachePath = path30.join(cwd, ".swarm", "cache", "impact-map.json");
|
|
48156
|
-
if (
|
|
48211
|
+
if (fs19.existsSync(cachePath)) {
|
|
48157
48212
|
try {
|
|
48158
|
-
const content =
|
|
48213
|
+
const content = fs19.readFileSync(cachePath, "utf-8");
|
|
48159
48214
|
const data = JSON.parse(content);
|
|
48160
48215
|
const map3 = data.map;
|
|
48161
48216
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
@@ -48169,15 +48224,15 @@ async function loadImpactMap(cwd) {
|
|
|
48169
48224
|
async function saveImpactMap(cwd, impactMap) {
|
|
48170
48225
|
const cacheDir = path30.join(cwd, ".swarm", "cache");
|
|
48171
48226
|
const cachePath = path30.join(cacheDir, "impact-map.json");
|
|
48172
|
-
if (!
|
|
48173
|
-
|
|
48227
|
+
if (!fs19.existsSync(cacheDir)) {
|
|
48228
|
+
fs19.mkdirSync(cacheDir, { recursive: true });
|
|
48174
48229
|
}
|
|
48175
48230
|
const data = {
|
|
48176
48231
|
generatedAt: new Date().toISOString(),
|
|
48177
48232
|
fileCount: Object.keys(impactMap).length,
|
|
48178
48233
|
map: impactMap
|
|
48179
48234
|
};
|
|
48180
|
-
|
|
48235
|
+
fs19.writeFileSync(cachePath, JSON.stringify(data, null, 2), "utf-8");
|
|
48181
48236
|
}
|
|
48182
48237
|
async function analyzeImpact(changedFiles, cwd) {
|
|
48183
48238
|
if (!Array.isArray(changedFiles)) {
|
|
@@ -48445,7 +48500,7 @@ function detectFlakyTests(allHistory) {
|
|
|
48445
48500
|
var FLAKY_THRESHOLD = 0.3, MIN_RUNS_FOR_QUARANTINE = 5, MAX_HISTORY_RUNS = 20;
|
|
48446
48501
|
|
|
48447
48502
|
// src/test-impact/history-store.ts
|
|
48448
|
-
import
|
|
48503
|
+
import fs20 from "fs";
|
|
48449
48504
|
import path31 from "path";
|
|
48450
48505
|
function getHistoryPath(workingDir) {
|
|
48451
48506
|
return path31.join(workingDir || process.cwd(), ".swarm", "cache", "test-history.jsonl");
|
|
@@ -48504,8 +48559,8 @@ function appendTestRun(record3, workingDir) {
|
|
|
48504
48559
|
};
|
|
48505
48560
|
const historyPath = getHistoryPath(workingDir);
|
|
48506
48561
|
const historyDir = path31.dirname(historyPath);
|
|
48507
|
-
if (!
|
|
48508
|
-
|
|
48562
|
+
if (!fs20.existsSync(historyDir)) {
|
|
48563
|
+
fs20.mkdirSync(historyDir, { recursive: true });
|
|
48509
48564
|
}
|
|
48510
48565
|
const existingRecords = readAllRecords(historyPath);
|
|
48511
48566
|
existingRecords.push(sanitizedRecord);
|
|
@@ -48530,24 +48585,24 @@ function appendTestRun(record3, workingDir) {
|
|
|
48530
48585
|
`) + `
|
|
48531
48586
|
`;
|
|
48532
48587
|
const tempPath = historyPath + ".tmp";
|
|
48533
|
-
|
|
48534
|
-
|
|
48588
|
+
fs20.writeFileSync(tempPath, content, "utf-8");
|
|
48589
|
+
fs20.renameSync(tempPath, historyPath);
|
|
48535
48590
|
} catch (err2) {
|
|
48536
48591
|
try {
|
|
48537
48592
|
const tempPath = historyPath + ".tmp";
|
|
48538
|
-
if (
|
|
48539
|
-
|
|
48593
|
+
if (fs20.existsSync(tempPath)) {
|
|
48594
|
+
fs20.unlinkSync(tempPath);
|
|
48540
48595
|
}
|
|
48541
48596
|
} catch {}
|
|
48542
48597
|
throw new Error(`Failed to write test history: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
48543
48598
|
}
|
|
48544
48599
|
}
|
|
48545
48600
|
function readAllRecords(historyPath) {
|
|
48546
|
-
if (!
|
|
48601
|
+
if (!fs20.existsSync(historyPath)) {
|
|
48547
48602
|
return [];
|
|
48548
48603
|
}
|
|
48549
48604
|
try {
|
|
48550
|
-
const content =
|
|
48605
|
+
const content = fs20.readFileSync(historyPath, "utf-8");
|
|
48551
48606
|
const lines = content.split(`
|
|
48552
48607
|
`);
|
|
48553
48608
|
const records = [];
|
|
@@ -48584,7 +48639,7 @@ var init_history_store = __esm(() => {
|
|
|
48584
48639
|
});
|
|
48585
48640
|
|
|
48586
48641
|
// src/tools/resolve-working-directory.ts
|
|
48587
|
-
import * as
|
|
48642
|
+
import * as fs21 from "fs";
|
|
48588
48643
|
import * as path32 from "path";
|
|
48589
48644
|
function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
|
|
48590
48645
|
if (workingDirectory == null || workingDirectory === "") {
|
|
@@ -48615,7 +48670,7 @@ function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
|
|
|
48615
48670
|
}
|
|
48616
48671
|
const resolvedDir = path32.resolve(normalizedDir);
|
|
48617
48672
|
try {
|
|
48618
|
-
const realPath =
|
|
48673
|
+
const realPath = fs21.realpathSync(resolvedDir);
|
|
48619
48674
|
return { success: true, directory: realPath };
|
|
48620
48675
|
} catch {
|
|
48621
48676
|
return {
|
|
@@ -48627,7 +48682,7 @@ function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
|
|
|
48627
48682
|
var init_resolve_working_directory = () => {};
|
|
48628
48683
|
|
|
48629
48684
|
// src/tools/test-runner.ts
|
|
48630
|
-
import * as
|
|
48685
|
+
import * as fs22 from "fs";
|
|
48631
48686
|
import * as path33 from "path";
|
|
48632
48687
|
function isAbsolutePath(str) {
|
|
48633
48688
|
if (str.startsWith("/"))
|
|
@@ -48693,19 +48748,19 @@ function hasDevDependency(devDeps, ...patterns) {
|
|
|
48693
48748
|
return hasPackageJsonDependency(devDeps, ...patterns);
|
|
48694
48749
|
}
|
|
48695
48750
|
function detectGoTest(cwd) {
|
|
48696
|
-
return
|
|
48751
|
+
return fs22.existsSync(path33.join(cwd, "go.mod")) && isCommandAvailable("go");
|
|
48697
48752
|
}
|
|
48698
48753
|
function detectJavaMaven(cwd) {
|
|
48699
|
-
return
|
|
48754
|
+
return fs22.existsSync(path33.join(cwd, "pom.xml")) && isCommandAvailable("mvn");
|
|
48700
48755
|
}
|
|
48701
48756
|
function detectGradle(cwd) {
|
|
48702
|
-
const hasBuildFile =
|
|
48703
|
-
const hasGradlew =
|
|
48757
|
+
const hasBuildFile = fs22.existsSync(path33.join(cwd, "build.gradle")) || fs22.existsSync(path33.join(cwd, "build.gradle.kts"));
|
|
48758
|
+
const hasGradlew = fs22.existsSync(path33.join(cwd, "gradlew")) || fs22.existsSync(path33.join(cwd, "gradlew.bat"));
|
|
48704
48759
|
return hasBuildFile && (hasGradlew || isCommandAvailable("gradle"));
|
|
48705
48760
|
}
|
|
48706
48761
|
function detectDotnetTest(cwd) {
|
|
48707
48762
|
try {
|
|
48708
|
-
const files =
|
|
48763
|
+
const files = fs22.readdirSync(cwd);
|
|
48709
48764
|
const hasCsproj = files.some((f) => f.endsWith(".csproj"));
|
|
48710
48765
|
return hasCsproj && isCommandAvailable("dotnet");
|
|
48711
48766
|
} catch {
|
|
@@ -48713,32 +48768,32 @@ function detectDotnetTest(cwd) {
|
|
|
48713
48768
|
}
|
|
48714
48769
|
}
|
|
48715
48770
|
function detectCTest(cwd) {
|
|
48716
|
-
const hasSource =
|
|
48717
|
-
const hasBuildCache =
|
|
48771
|
+
const hasSource = fs22.existsSync(path33.join(cwd, "CMakeLists.txt"));
|
|
48772
|
+
const hasBuildCache = fs22.existsSync(path33.join(cwd, "CMakeCache.txt")) || fs22.existsSync(path33.join(cwd, "build", "CMakeCache.txt"));
|
|
48718
48773
|
return (hasSource || hasBuildCache) && isCommandAvailable("ctest");
|
|
48719
48774
|
}
|
|
48720
48775
|
function detectSwiftTest(cwd) {
|
|
48721
|
-
return
|
|
48776
|
+
return fs22.existsSync(path33.join(cwd, "Package.swift")) && isCommandAvailable("swift");
|
|
48722
48777
|
}
|
|
48723
48778
|
function detectDartTest(cwd) {
|
|
48724
|
-
return
|
|
48779
|
+
return fs22.existsSync(path33.join(cwd, "pubspec.yaml")) && (isCommandAvailable("dart") || isCommandAvailable("flutter"));
|
|
48725
48780
|
}
|
|
48726
48781
|
function detectRSpec(cwd) {
|
|
48727
|
-
const hasRSpecFile =
|
|
48728
|
-
const hasGemfile =
|
|
48729
|
-
const hasSpecDir =
|
|
48782
|
+
const hasRSpecFile = fs22.existsSync(path33.join(cwd, ".rspec"));
|
|
48783
|
+
const hasGemfile = fs22.existsSync(path33.join(cwd, "Gemfile"));
|
|
48784
|
+
const hasSpecDir = fs22.existsSync(path33.join(cwd, "spec"));
|
|
48730
48785
|
const hasRSpec = hasRSpecFile || hasGemfile && hasSpecDir;
|
|
48731
48786
|
return hasRSpec && (isCommandAvailable("bundle") || isCommandAvailable("rspec"));
|
|
48732
48787
|
}
|
|
48733
48788
|
function detectMinitest(cwd) {
|
|
48734
|
-
return
|
|
48789
|
+
return fs22.existsSync(path33.join(cwd, "test")) && (fs22.existsSync(path33.join(cwd, "Gemfile")) || fs22.existsSync(path33.join(cwd, "Rakefile"))) && isCommandAvailable("ruby");
|
|
48735
48790
|
}
|
|
48736
48791
|
async function detectTestFramework(cwd) {
|
|
48737
48792
|
const baseDir = cwd;
|
|
48738
48793
|
try {
|
|
48739
48794
|
const packageJsonPath = path33.join(baseDir, "package.json");
|
|
48740
|
-
if (
|
|
48741
|
-
const content =
|
|
48795
|
+
if (fs22.existsSync(packageJsonPath)) {
|
|
48796
|
+
const content = fs22.readFileSync(packageJsonPath, "utf-8");
|
|
48742
48797
|
const pkg = JSON.parse(content);
|
|
48743
48798
|
const _deps = pkg.dependencies || {};
|
|
48744
48799
|
const devDeps = pkg.devDependencies || {};
|
|
@@ -48757,7 +48812,7 @@ async function detectTestFramework(cwd) {
|
|
|
48757
48812
|
return "jest";
|
|
48758
48813
|
if (hasDevDependency(devDeps, "mocha", "@types/mocha"))
|
|
48759
48814
|
return "mocha";
|
|
48760
|
-
if (
|
|
48815
|
+
if (fs22.existsSync(path33.join(baseDir, "bun.lockb")) || fs22.existsSync(path33.join(baseDir, "bun.lock"))) {
|
|
48761
48816
|
if (scripts.test?.includes("bun"))
|
|
48762
48817
|
return "bun";
|
|
48763
48818
|
}
|
|
@@ -48767,28 +48822,28 @@ async function detectTestFramework(cwd) {
|
|
|
48767
48822
|
const pyprojectTomlPath = path33.join(baseDir, "pyproject.toml");
|
|
48768
48823
|
const setupCfgPath = path33.join(baseDir, "setup.cfg");
|
|
48769
48824
|
const requirementsTxtPath = path33.join(baseDir, "requirements.txt");
|
|
48770
|
-
if (
|
|
48771
|
-
const content =
|
|
48825
|
+
if (fs22.existsSync(pyprojectTomlPath)) {
|
|
48826
|
+
const content = fs22.readFileSync(pyprojectTomlPath, "utf-8");
|
|
48772
48827
|
if (content.includes("[tool.pytest"))
|
|
48773
48828
|
return "pytest";
|
|
48774
48829
|
if (content.includes("pytest"))
|
|
48775
48830
|
return "pytest";
|
|
48776
48831
|
}
|
|
48777
|
-
if (
|
|
48778
|
-
const content =
|
|
48832
|
+
if (fs22.existsSync(setupCfgPath)) {
|
|
48833
|
+
const content = fs22.readFileSync(setupCfgPath, "utf-8");
|
|
48779
48834
|
if (content.includes("[pytest]"))
|
|
48780
48835
|
return "pytest";
|
|
48781
48836
|
}
|
|
48782
|
-
if (
|
|
48783
|
-
const content =
|
|
48837
|
+
if (fs22.existsSync(requirementsTxtPath)) {
|
|
48838
|
+
const content = fs22.readFileSync(requirementsTxtPath, "utf-8");
|
|
48784
48839
|
if (content.includes("pytest"))
|
|
48785
48840
|
return "pytest";
|
|
48786
48841
|
}
|
|
48787
48842
|
} catch {}
|
|
48788
48843
|
try {
|
|
48789
48844
|
const cargoTomlPath = path33.join(baseDir, "Cargo.toml");
|
|
48790
|
-
if (
|
|
48791
|
-
const content =
|
|
48845
|
+
if (fs22.existsSync(cargoTomlPath)) {
|
|
48846
|
+
const content = fs22.readFileSync(cargoTomlPath, "utf-8");
|
|
48792
48847
|
if (content.includes("[dev-dependencies]")) {
|
|
48793
48848
|
if (content.includes("tokio") || content.includes("mockall") || content.includes("pretty_assertions")) {
|
|
48794
48849
|
return "cargo";
|
|
@@ -48800,7 +48855,7 @@ async function detectTestFramework(cwd) {
|
|
|
48800
48855
|
const pesterConfigPath = path33.join(baseDir, "pester.config.ps1");
|
|
48801
48856
|
const pesterConfigJsonPath = path33.join(baseDir, "pester.config.ps1.json");
|
|
48802
48857
|
const pesterPs1Path = path33.join(baseDir, "tests.ps1");
|
|
48803
|
-
if (
|
|
48858
|
+
if (fs22.existsSync(pesterConfigPath) || fs22.existsSync(pesterConfigJsonPath) || fs22.existsSync(pesterPs1Path)) {
|
|
48804
48859
|
return "pester";
|
|
48805
48860
|
}
|
|
48806
48861
|
} catch {}
|
|
@@ -48851,7 +48906,7 @@ function getTestFilesFromConvention(sourceFiles) {
|
|
|
48851
48906
|
path33.join(dirname13, "test", `${nameWithoutExt}${ext}`)
|
|
48852
48907
|
];
|
|
48853
48908
|
for (const testFile of possibleTestFiles) {
|
|
48854
|
-
if (
|
|
48909
|
+
if (fs22.existsSync(testFile) && !testFiles.includes(testFile)) {
|
|
48855
48910
|
testFiles.push(testFile);
|
|
48856
48911
|
}
|
|
48857
48912
|
}
|
|
@@ -48867,7 +48922,7 @@ async function getTestFilesFromGraph(sourceFiles) {
|
|
|
48867
48922
|
}
|
|
48868
48923
|
for (const testFile of candidateTestFiles) {
|
|
48869
48924
|
try {
|
|
48870
|
-
const content =
|
|
48925
|
+
const content = fs22.readFileSync(testFile, "utf-8");
|
|
48871
48926
|
const testDir = path33.dirname(testFile);
|
|
48872
48927
|
const importRegex = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
|
|
48873
48928
|
let match;
|
|
@@ -48888,7 +48943,7 @@ async function getTestFilesFromGraph(sourceFiles) {
|
|
|
48888
48943
|
".cjs"
|
|
48889
48944
|
]) {
|
|
48890
48945
|
const withExt = resolvedImport + extToTry;
|
|
48891
|
-
if (sourceFiles.includes(withExt) ||
|
|
48946
|
+
if (sourceFiles.includes(withExt) || fs22.existsSync(withExt)) {
|
|
48892
48947
|
resolvedImport = withExt;
|
|
48893
48948
|
break;
|
|
48894
48949
|
}
|
|
@@ -48929,7 +48984,7 @@ async function getTestFilesFromGraph(sourceFiles) {
|
|
|
48929
48984
|
".cjs"
|
|
48930
48985
|
]) {
|
|
48931
48986
|
const withExt = resolvedImport + extToTry;
|
|
48932
|
-
if (sourceFiles.includes(withExt) ||
|
|
48987
|
+
if (sourceFiles.includes(withExt) || fs22.existsSync(withExt)) {
|
|
48933
48988
|
resolvedImport = withExt;
|
|
48934
48989
|
break;
|
|
48935
48990
|
}
|
|
@@ -49025,8 +49080,8 @@ function buildTestCommand(framework, scope, files, coverage, baseDir) {
|
|
|
49025
49080
|
return ["mvn", "test"];
|
|
49026
49081
|
case "gradle": {
|
|
49027
49082
|
const isWindows = process.platform === "win32";
|
|
49028
|
-
const hasGradlewBat =
|
|
49029
|
-
const hasGradlew =
|
|
49083
|
+
const hasGradlewBat = fs22.existsSync(path33.join(baseDir, "gradlew.bat"));
|
|
49084
|
+
const hasGradlew = fs22.existsSync(path33.join(baseDir, "gradlew"));
|
|
49030
49085
|
if (hasGradlewBat && isWindows)
|
|
49031
49086
|
return ["gradlew.bat", "test"];
|
|
49032
49087
|
if (hasGradlew)
|
|
@@ -49043,7 +49098,7 @@ function buildTestCommand(framework, scope, files, coverage, baseDir) {
|
|
|
49043
49098
|
"cmake-build-release",
|
|
49044
49099
|
"out"
|
|
49045
49100
|
];
|
|
49046
|
-
const actualBuildDir = buildDirCandidates.find((d) =>
|
|
49101
|
+
const actualBuildDir = buildDirCandidates.find((d) => fs22.existsSync(path33.join(baseDir, d, "CMakeCache.txt"))) ?? "build";
|
|
49047
49102
|
return ["ctest", "--test-dir", actualBuildDir];
|
|
49048
49103
|
}
|
|
49049
49104
|
case "swift-test":
|
|
@@ -49810,7 +49865,7 @@ var init_test_runner = __esm(() => {
|
|
|
49810
49865
|
});
|
|
49811
49866
|
|
|
49812
49867
|
// src/services/preflight-service.ts
|
|
49813
|
-
import * as
|
|
49868
|
+
import * as fs23 from "fs";
|
|
49814
49869
|
import * as path34 from "path";
|
|
49815
49870
|
function validateDirectoryPath(dir) {
|
|
49816
49871
|
if (!dir || typeof dir !== "string") {
|
|
@@ -49844,8 +49899,8 @@ function validateTimeout(timeoutMs, defaultValue) {
|
|
|
49844
49899
|
function getPackageVersion(dir) {
|
|
49845
49900
|
try {
|
|
49846
49901
|
const packagePath = path34.join(dir, "package.json");
|
|
49847
|
-
if (
|
|
49848
|
-
const content =
|
|
49902
|
+
if (fs23.existsSync(packagePath)) {
|
|
49903
|
+
const content = fs23.readFileSync(packagePath, "utf-8");
|
|
49849
49904
|
const pkg = JSON.parse(content);
|
|
49850
49905
|
return pkg.version ?? null;
|
|
49851
49906
|
}
|
|
@@ -49855,8 +49910,8 @@ function getPackageVersion(dir) {
|
|
|
49855
49910
|
function getChangelogVersion(dir) {
|
|
49856
49911
|
try {
|
|
49857
49912
|
const changelogPath = path34.join(dir, "CHANGELOG.md");
|
|
49858
|
-
if (
|
|
49859
|
-
const content =
|
|
49913
|
+
if (fs23.existsSync(changelogPath)) {
|
|
49914
|
+
const content = fs23.readFileSync(changelogPath, "utf-8");
|
|
49860
49915
|
const match = content.match(/^##\s*\[?(\d+\.\d+\.\d+)\]?/m);
|
|
49861
49916
|
if (match) {
|
|
49862
49917
|
return match[1];
|
|
@@ -49869,9 +49924,9 @@ function getVersionFileVersion(dir) {
|
|
|
49869
49924
|
const possibleFiles = ["VERSION.txt", "version.txt", "VERSION", "version"];
|
|
49870
49925
|
for (const file3 of possibleFiles) {
|
|
49871
49926
|
const filePath = path34.join(dir, file3);
|
|
49872
|
-
if (
|
|
49927
|
+
if (fs23.existsSync(filePath)) {
|
|
49873
49928
|
try {
|
|
49874
|
-
const content =
|
|
49929
|
+
const content = fs23.readFileSync(filePath, "utf-8").trim();
|
|
49875
49930
|
const match = content.match(/(\d+\.\d+\.\d+)/);
|
|
49876
49931
|
if (match) {
|
|
49877
49932
|
return match[1];
|
|
@@ -50196,7 +50251,7 @@ async function runRequirementCoverageCheck(dir, currentPhase) {
|
|
|
50196
50251
|
const startTime = Date.now();
|
|
50197
50252
|
try {
|
|
50198
50253
|
const specPath = path34.join(dir, ".swarm", "spec.md");
|
|
50199
|
-
if (!
|
|
50254
|
+
if (!fs23.existsSync(specPath)) {
|
|
50200
50255
|
return {
|
|
50201
50256
|
type: "req_coverage",
|
|
50202
50257
|
status: "skip",
|
|
@@ -50433,7 +50488,7 @@ var init_preflight = __esm(() => {
|
|
|
50433
50488
|
});
|
|
50434
50489
|
|
|
50435
50490
|
// src/knowledge/hive-promoter.ts
|
|
50436
|
-
import * as
|
|
50491
|
+
import * as fs24 from "fs";
|
|
50437
50492
|
import * as os6 from "os";
|
|
50438
50493
|
import * as path35 from "path";
|
|
50439
50494
|
function validateLesson2(text) {
|
|
@@ -50484,8 +50539,8 @@ async function promoteToHive(_directory, lesson, category) {
|
|
|
50484
50539
|
}
|
|
50485
50540
|
const hivePath = getHiveFilePath();
|
|
50486
50541
|
const hiveDir = path35.dirname(hivePath);
|
|
50487
|
-
if (!
|
|
50488
|
-
|
|
50542
|
+
if (!fs24.existsSync(hiveDir)) {
|
|
50543
|
+
fs24.mkdirSync(hiveDir, { recursive: true });
|
|
50489
50544
|
}
|
|
50490
50545
|
const now = new Date;
|
|
50491
50546
|
const entry = {
|
|
@@ -50499,7 +50554,7 @@ async function promoteToHive(_directory, lesson, category) {
|
|
|
50499
50554
|
promotedAt: now.toISOString(),
|
|
50500
50555
|
retrievalOutcomes: { applied: 0, succeededAfter: 0, failedAfter: 0 }
|
|
50501
50556
|
};
|
|
50502
|
-
|
|
50557
|
+
fs24.appendFileSync(hivePath, `${JSON.stringify(entry)}
|
|
50503
50558
|
`, "utf-8");
|
|
50504
50559
|
const preview = `${trimmed.slice(0, 50)}${trimmed.length > 50 ? "..." : ""}`;
|
|
50505
50560
|
return `Promoted to hive: "${preview}" (confidence: 1.0, source: manual)`;
|
|
@@ -50507,8 +50562,8 @@ async function promoteToHive(_directory, lesson, category) {
|
|
|
50507
50562
|
async function promoteFromSwarm(directory, lessonId) {
|
|
50508
50563
|
const knowledgePath = path35.join(directory, ".swarm", "knowledge.jsonl");
|
|
50509
50564
|
const entries = [];
|
|
50510
|
-
if (
|
|
50511
|
-
const content =
|
|
50565
|
+
if (fs24.existsSync(knowledgePath)) {
|
|
50566
|
+
const content = fs24.readFileSync(knowledgePath, "utf-8");
|
|
50512
50567
|
for (const line of content.split(`
|
|
50513
50568
|
`)) {
|
|
50514
50569
|
const t = line.trim();
|
|
@@ -50533,8 +50588,8 @@ async function promoteFromSwarm(directory, lessonId) {
|
|
|
50533
50588
|
}
|
|
50534
50589
|
const hivePath = getHiveFilePath();
|
|
50535
50590
|
const hiveDir = path35.dirname(hivePath);
|
|
50536
|
-
if (!
|
|
50537
|
-
|
|
50591
|
+
if (!fs24.existsSync(hiveDir)) {
|
|
50592
|
+
fs24.mkdirSync(hiveDir, { recursive: true });
|
|
50538
50593
|
}
|
|
50539
50594
|
const now = new Date;
|
|
50540
50595
|
const hiveEntry = {
|
|
@@ -50548,7 +50603,7 @@ async function promoteFromSwarm(directory, lessonId) {
|
|
|
50548
50603
|
promotedAt: now.toISOString(),
|
|
50549
50604
|
retrievalOutcomes: { applied: 0, succeededAfter: 0, failedAfter: 0 }
|
|
50550
50605
|
};
|
|
50551
|
-
|
|
50606
|
+
fs24.appendFileSync(hivePath, `${JSON.stringify(hiveEntry)}
|
|
50552
50607
|
`, "utf-8");
|
|
50553
50608
|
const preview = `${lessonText.slice(0, 50)}${lessonText.length > 50 ? "..." : ""}`;
|
|
50554
50609
|
return `Promoted to hive: "${preview}" (confidence: 1.0, source: manual)`;
|
|
@@ -51676,7 +51731,7 @@ var init_manager3 = __esm(() => {
|
|
|
51676
51731
|
});
|
|
51677
51732
|
|
|
51678
51733
|
// src/commands/reset.ts
|
|
51679
|
-
import * as
|
|
51734
|
+
import * as fs25 from "fs";
|
|
51680
51735
|
async function handleResetCommand(directory, args2) {
|
|
51681
51736
|
const hasConfirm = args2.includes("--confirm");
|
|
51682
51737
|
if (!hasConfirm) {
|
|
@@ -51696,8 +51751,8 @@ async function handleResetCommand(directory, args2) {
|
|
|
51696
51751
|
for (const filename of filesToReset) {
|
|
51697
51752
|
try {
|
|
51698
51753
|
const resolvedPath = validateSwarmPath(directory, filename);
|
|
51699
|
-
if (
|
|
51700
|
-
|
|
51754
|
+
if (fs25.existsSync(resolvedPath)) {
|
|
51755
|
+
fs25.unlinkSync(resolvedPath);
|
|
51701
51756
|
results.push(`- \u2705 Deleted ${filename}`);
|
|
51702
51757
|
} else {
|
|
51703
51758
|
results.push(`- \u23ED\uFE0F ${filename} not found (skipped)`);
|
|
@@ -51714,8 +51769,8 @@ async function handleResetCommand(directory, args2) {
|
|
|
51714
51769
|
}
|
|
51715
51770
|
try {
|
|
51716
51771
|
const summariesPath = validateSwarmPath(directory, "summaries");
|
|
51717
|
-
if (
|
|
51718
|
-
|
|
51772
|
+
if (fs25.existsSync(summariesPath)) {
|
|
51773
|
+
fs25.rmSync(summariesPath, { recursive: true, force: true });
|
|
51719
51774
|
results.push("- \u2705 Deleted summaries/ directory");
|
|
51720
51775
|
} else {
|
|
51721
51776
|
results.push("- \u23ED\uFE0F summaries/ not found (skipped)");
|
|
@@ -51738,14 +51793,14 @@ var init_reset = __esm(() => {
|
|
|
51738
51793
|
});
|
|
51739
51794
|
|
|
51740
51795
|
// src/commands/reset-session.ts
|
|
51741
|
-
import * as
|
|
51796
|
+
import * as fs26 from "fs";
|
|
51742
51797
|
import * as path36 from "path";
|
|
51743
51798
|
async function handleResetSessionCommand(directory, _args) {
|
|
51744
51799
|
const results = [];
|
|
51745
51800
|
try {
|
|
51746
51801
|
const statePath = validateSwarmPath(directory, "session/state.json");
|
|
51747
|
-
if (
|
|
51748
|
-
|
|
51802
|
+
if (fs26.existsSync(statePath)) {
|
|
51803
|
+
fs26.unlinkSync(statePath);
|
|
51749
51804
|
results.push("\u2705 Deleted .swarm/session/state.json");
|
|
51750
51805
|
} else {
|
|
51751
51806
|
results.push("\u23ED\uFE0F state.json not found (already clean)");
|
|
@@ -51755,14 +51810,14 @@ async function handleResetSessionCommand(directory, _args) {
|
|
|
51755
51810
|
}
|
|
51756
51811
|
try {
|
|
51757
51812
|
const sessionDir = path36.dirname(validateSwarmPath(directory, "session/state.json"));
|
|
51758
|
-
if (
|
|
51759
|
-
const files =
|
|
51813
|
+
if (fs26.existsSync(sessionDir)) {
|
|
51814
|
+
const files = fs26.readdirSync(sessionDir);
|
|
51760
51815
|
const otherFiles = files.filter((f) => f !== "state.json");
|
|
51761
51816
|
let deletedCount = 0;
|
|
51762
51817
|
for (const file3 of otherFiles) {
|
|
51763
51818
|
const filePath = path36.join(sessionDir, file3);
|
|
51764
|
-
if (
|
|
51765
|
-
|
|
51819
|
+
if (fs26.lstatSync(filePath).isFile()) {
|
|
51820
|
+
fs26.unlinkSync(filePath);
|
|
51766
51821
|
deletedCount++;
|
|
51767
51822
|
}
|
|
51768
51823
|
}
|
|
@@ -51913,18 +51968,18 @@ var init_retrieve = __esm(() => {
|
|
|
51913
51968
|
});
|
|
51914
51969
|
|
|
51915
51970
|
// src/commands/rollback.ts
|
|
51916
|
-
import * as
|
|
51971
|
+
import * as fs27 from "fs";
|
|
51917
51972
|
import * as path38 from "path";
|
|
51918
51973
|
async function handleRollbackCommand(directory, args2) {
|
|
51919
51974
|
const phaseArg = args2[0];
|
|
51920
51975
|
if (!phaseArg) {
|
|
51921
51976
|
const manifestPath2 = validateSwarmPath(directory, "checkpoints/manifest.json");
|
|
51922
|
-
if (!
|
|
51977
|
+
if (!fs27.existsSync(manifestPath2)) {
|
|
51923
51978
|
return "No checkpoints found. Use `/swarm checkpoint` to create checkpoints.";
|
|
51924
51979
|
}
|
|
51925
51980
|
let manifest2;
|
|
51926
51981
|
try {
|
|
51927
|
-
manifest2 = JSON.parse(
|
|
51982
|
+
manifest2 = JSON.parse(fs27.readFileSync(manifestPath2, "utf-8"));
|
|
51928
51983
|
} catch {
|
|
51929
51984
|
return "Error: Checkpoint manifest is corrupted. Delete .swarm/checkpoints/manifest.json and re-checkpoint.";
|
|
51930
51985
|
}
|
|
@@ -51946,12 +52001,12 @@ async function handleRollbackCommand(directory, args2) {
|
|
|
51946
52001
|
return "Error: Phase number must be a positive integer.";
|
|
51947
52002
|
}
|
|
51948
52003
|
const manifestPath = validateSwarmPath(directory, "checkpoints/manifest.json");
|
|
51949
|
-
if (!
|
|
52004
|
+
if (!fs27.existsSync(manifestPath)) {
|
|
51950
52005
|
return `Error: No checkpoints found. Cannot rollback to phase ${targetPhase}.`;
|
|
51951
52006
|
}
|
|
51952
52007
|
let manifest;
|
|
51953
52008
|
try {
|
|
51954
|
-
manifest = JSON.parse(
|
|
52009
|
+
manifest = JSON.parse(fs27.readFileSync(manifestPath, "utf-8"));
|
|
51955
52010
|
} catch {
|
|
51956
52011
|
return `Error: Checkpoint manifest is corrupted. Delete .swarm/checkpoints/manifest.json and re-checkpoint.`;
|
|
51957
52012
|
}
|
|
@@ -51961,10 +52016,10 @@ async function handleRollbackCommand(directory, args2) {
|
|
|
51961
52016
|
return `Error: Checkpoint for phase ${targetPhase} not found. Available phases: ${available}`;
|
|
51962
52017
|
}
|
|
51963
52018
|
const checkpointDir = validateSwarmPath(directory, `checkpoints/phase-${targetPhase}`);
|
|
51964
|
-
if (!
|
|
52019
|
+
if (!fs27.existsSync(checkpointDir)) {
|
|
51965
52020
|
return `Error: Checkpoint directory for phase ${targetPhase} does not exist.`;
|
|
51966
52021
|
}
|
|
51967
|
-
const checkpointFiles =
|
|
52022
|
+
const checkpointFiles = fs27.readdirSync(checkpointDir);
|
|
51968
52023
|
if (checkpointFiles.length === 0) {
|
|
51969
52024
|
return `Error: Checkpoint for phase ${targetPhase} is empty. Cannot rollback.`;
|
|
51970
52025
|
}
|
|
@@ -51975,7 +52030,7 @@ async function handleRollbackCommand(directory, args2) {
|
|
|
51975
52030
|
const src = path38.join(checkpointDir, file3);
|
|
51976
52031
|
const dest = path38.join(swarmDir, file3);
|
|
51977
52032
|
try {
|
|
51978
|
-
|
|
52033
|
+
fs27.cpSync(src, dest, { recursive: true, force: true });
|
|
51979
52034
|
successes.push(file3);
|
|
51980
52035
|
} catch (error93) {
|
|
51981
52036
|
failures.push({ file: file3, error: error93.message });
|
|
@@ -51992,7 +52047,7 @@ async function handleRollbackCommand(directory, args2) {
|
|
|
51992
52047
|
timestamp: new Date().toISOString()
|
|
51993
52048
|
};
|
|
51994
52049
|
try {
|
|
51995
|
-
|
|
52050
|
+
fs27.appendFileSync(eventsPath, `${JSON.stringify(rollbackEvent)}
|
|
51996
52051
|
`);
|
|
51997
52052
|
} catch (error93) {
|
|
51998
52053
|
console.error("Failed to write rollback event:", error93 instanceof Error ? error93.message : String(error93));
|
|
@@ -52038,11 +52093,11 @@ async function handleSimulateCommand(directory, args2) {
|
|
|
52038
52093
|
];
|
|
52039
52094
|
const report = reportLines.filter(Boolean).join(`
|
|
52040
52095
|
`);
|
|
52041
|
-
const
|
|
52096
|
+
const fs28 = await import("fs/promises");
|
|
52042
52097
|
const path39 = await import("path");
|
|
52043
52098
|
const reportPath = path39.join(directory, ".swarm", "simulate-report.md");
|
|
52044
|
-
await
|
|
52045
|
-
await
|
|
52099
|
+
await fs28.mkdir(path39.dirname(reportPath), { recursive: true });
|
|
52100
|
+
await fs28.writeFile(reportPath, report, "utf-8");
|
|
52046
52101
|
return `${darkMatterPairs.length} hidden coupling pairs detected`;
|
|
52047
52102
|
}
|
|
52048
52103
|
var init_simulate = __esm(() => {
|
|
@@ -52059,7 +52114,7 @@ async function handleSpecifyCommand(_directory, args2) {
|
|
|
52059
52114
|
}
|
|
52060
52115
|
|
|
52061
52116
|
// src/services/compaction-service.ts
|
|
52062
|
-
import * as
|
|
52117
|
+
import * as fs28 from "fs";
|
|
52063
52118
|
import * as path39 from "path";
|
|
52064
52119
|
function makeInitialState() {
|
|
52065
52120
|
return {
|
|
@@ -52088,7 +52143,7 @@ function appendSnapshot(directory, tier, budgetPct, message) {
|
|
|
52088
52143
|
## [${tier.toUpperCase()}] ${timestamp} \u2014 ${budgetPct.toFixed(1)}% used
|
|
52089
52144
|
${message}
|
|
52090
52145
|
`;
|
|
52091
|
-
|
|
52146
|
+
fs28.appendFileSync(snapshotPath, entry, "utf-8");
|
|
52092
52147
|
} catch {}
|
|
52093
52148
|
}
|
|
52094
52149
|
function buildObservationMessage(budgetPct) {
|
|
@@ -55703,7 +55758,7 @@ COVERAGE REPORTING:
|
|
|
55703
55758
|
`;
|
|
55704
55759
|
|
|
55705
55760
|
// src/agents/index.ts
|
|
55706
|
-
import { mkdir as
|
|
55761
|
+
import { mkdir as mkdir6, writeFile as writeFile6 } from "fs/promises";
|
|
55707
55762
|
import * as path40 from "path";
|
|
55708
55763
|
function stripSwarmPrefix(agentName, swarmPrefix) {
|
|
55709
55764
|
if (!swarmPrefix || !agentName)
|
|
@@ -55961,7 +56016,7 @@ function getAgentConfigs(config3, directory, sessionId) {
|
|
|
55961
56016
|
generatedAt: new Date().toISOString(),
|
|
55962
56017
|
agents: agentToolSnapshot
|
|
55963
56018
|
}, null, 2);
|
|
55964
|
-
|
|
56019
|
+
mkdir6(evidenceDir, { recursive: true }).then(() => writeFile6(path40.join(evidenceDir, filename), snapshotData)).catch(() => {});
|
|
55965
56020
|
}
|
|
55966
56021
|
return result;
|
|
55967
56022
|
}
|
|
@@ -56110,7 +56165,7 @@ var exports_status_artifact = {};
|
|
|
56110
56165
|
__export(exports_status_artifact, {
|
|
56111
56166
|
AutomationStatusArtifact: () => AutomationStatusArtifact
|
|
56112
56167
|
});
|
|
56113
|
-
import * as
|
|
56168
|
+
import * as fs30 from "fs";
|
|
56114
56169
|
import * as path43 from "path";
|
|
56115
56170
|
function createEmptySnapshot(mode, capabilities) {
|
|
56116
56171
|
return {
|
|
@@ -56175,8 +56230,8 @@ class AutomationStatusArtifact {
|
|
|
56175
56230
|
load() {
|
|
56176
56231
|
const filePath = this.getFilePath();
|
|
56177
56232
|
try {
|
|
56178
|
-
if (
|
|
56179
|
-
const content =
|
|
56233
|
+
if (fs30.existsSync(filePath)) {
|
|
56234
|
+
const content = fs30.readFileSync(filePath, "utf-8");
|
|
56180
56235
|
return JSON.parse(content);
|
|
56181
56236
|
}
|
|
56182
56237
|
} catch {}
|
|
@@ -56184,10 +56239,10 @@ class AutomationStatusArtifact {
|
|
|
56184
56239
|
}
|
|
56185
56240
|
write() {
|
|
56186
56241
|
const filePath = this.getFilePath();
|
|
56187
|
-
if (!
|
|
56188
|
-
|
|
56242
|
+
if (!fs30.existsSync(this.swarmDir)) {
|
|
56243
|
+
fs30.mkdirSync(this.swarmDir, { recursive: true });
|
|
56189
56244
|
}
|
|
56190
|
-
|
|
56245
|
+
fs30.writeFileSync(filePath, JSON.stringify(this.currentSnapshot, null, 2), "utf-8");
|
|
56191
56246
|
}
|
|
56192
56247
|
getSnapshot() {
|
|
56193
56248
|
return { ...this.currentSnapshot };
|
|
@@ -56582,7 +56637,7 @@ __export(exports_review_receipt, {
|
|
|
56582
56637
|
buildApprovedReceipt: () => buildApprovedReceipt
|
|
56583
56638
|
});
|
|
56584
56639
|
import * as crypto5 from "crypto";
|
|
56585
|
-
import * as
|
|
56640
|
+
import * as fs35 from "fs";
|
|
56586
56641
|
import * as path45 from "path";
|
|
56587
56642
|
function resolveReceiptsDir(directory) {
|
|
56588
56643
|
return path45.join(directory, ".swarm", "review-receipts");
|
|
@@ -56611,11 +56666,11 @@ function isScopeStale(receipt, currentContent) {
|
|
|
56611
56666
|
}
|
|
56612
56667
|
async function readReceiptIndex(directory) {
|
|
56613
56668
|
const indexPath = resolveReceiptIndexPath(directory);
|
|
56614
|
-
if (!
|
|
56669
|
+
if (!fs35.existsSync(indexPath)) {
|
|
56615
56670
|
return { schema_version: 1, entries: [] };
|
|
56616
56671
|
}
|
|
56617
56672
|
try {
|
|
56618
|
-
const content = await
|
|
56673
|
+
const content = await fs35.promises.readFile(indexPath, "utf-8");
|
|
56619
56674
|
const parsed = JSON.parse(content);
|
|
56620
56675
|
if (parsed.schema_version !== 1 || !Array.isArray(parsed.entries)) {
|
|
56621
56676
|
return { schema_version: 1, entries: [] };
|
|
@@ -56628,20 +56683,20 @@ async function readReceiptIndex(directory) {
|
|
|
56628
56683
|
async function writeReceiptIndex(directory, index) {
|
|
56629
56684
|
const indexPath = resolveReceiptIndexPath(directory);
|
|
56630
56685
|
const dir = path45.dirname(indexPath);
|
|
56631
|
-
await
|
|
56686
|
+
await fs35.promises.mkdir(dir, { recursive: true });
|
|
56632
56687
|
const tmpPath = `${indexPath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2)}`;
|
|
56633
|
-
await
|
|
56634
|
-
|
|
56688
|
+
await fs35.promises.writeFile(tmpPath, JSON.stringify(index, null, 2), "utf-8");
|
|
56689
|
+
fs35.renameSync(tmpPath, indexPath);
|
|
56635
56690
|
}
|
|
56636
56691
|
async function persistReviewReceipt(directory, receipt) {
|
|
56637
56692
|
const receiptsDir = resolveReceiptsDir(directory);
|
|
56638
|
-
await
|
|
56693
|
+
await fs35.promises.mkdir(receiptsDir, { recursive: true });
|
|
56639
56694
|
const now = new Date(receipt.reviewed_at);
|
|
56640
56695
|
const filename = buildReceiptFilename(receipt.id, now);
|
|
56641
56696
|
const receiptPath = path45.join(receiptsDir, filename);
|
|
56642
56697
|
const tmpPath = `${receiptPath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2)}`;
|
|
56643
|
-
await
|
|
56644
|
-
|
|
56698
|
+
await fs35.promises.writeFile(tmpPath, JSON.stringify(receipt, null, 2), "utf-8");
|
|
56699
|
+
fs35.renameSync(tmpPath, receiptPath);
|
|
56645
56700
|
const index = await readReceiptIndex(directory);
|
|
56646
56701
|
const entry = {
|
|
56647
56702
|
id: receipt.id,
|
|
@@ -56662,7 +56717,7 @@ async function readReceiptById(directory, receiptId) {
|
|
|
56662
56717
|
return null;
|
|
56663
56718
|
const receiptPath = path45.join(resolveReceiptsDir(directory), entry.filename);
|
|
56664
56719
|
try {
|
|
56665
|
-
const content = await
|
|
56720
|
+
const content = await fs35.promises.readFile(receiptPath, "utf-8");
|
|
56666
56721
|
return JSON.parse(content);
|
|
56667
56722
|
} catch {
|
|
56668
56723
|
return null;
|
|
@@ -56675,7 +56730,7 @@ async function readReceiptsByScopeHash(directory, scopeHash) {
|
|
|
56675
56730
|
for (const entry of matching) {
|
|
56676
56731
|
const receiptPath = path45.join(resolveReceiptsDir(directory), entry.filename);
|
|
56677
56732
|
try {
|
|
56678
|
-
const content = await
|
|
56733
|
+
const content = await fs35.promises.readFile(receiptPath, "utf-8");
|
|
56679
56734
|
receipts.push(JSON.parse(content));
|
|
56680
56735
|
} catch {}
|
|
56681
56736
|
}
|
|
@@ -56688,7 +56743,7 @@ async function readAllReceipts(directory) {
|
|
|
56688
56743
|
for (const entry of sorted) {
|
|
56689
56744
|
const receiptPath = path45.join(resolveReceiptsDir(directory), entry.filename);
|
|
56690
56745
|
try {
|
|
56691
|
-
const content = await
|
|
56746
|
+
const content = await fs35.promises.readFile(receiptPath, "utf-8");
|
|
56692
56747
|
receipts.push(JSON.parse(content));
|
|
56693
56748
|
} catch {}
|
|
56694
56749
|
}
|
|
@@ -56820,8 +56875,8 @@ __export(exports_doc_scan, {
|
|
|
56820
56875
|
doc_extract: () => doc_extract
|
|
56821
56876
|
});
|
|
56822
56877
|
import * as crypto7 from "crypto";
|
|
56823
|
-
import * as
|
|
56824
|
-
import { mkdir as
|
|
56878
|
+
import * as fs43 from "fs";
|
|
56879
|
+
import { mkdir as mkdir8, readFile as readFile8, writeFile as writeFile8 } from "fs/promises";
|
|
56825
56880
|
import * as path56 from "path";
|
|
56826
56881
|
function normalizeSeparators(filePath) {
|
|
56827
56882
|
return filePath.replace(/\\/g, "/");
|
|
@@ -56902,7 +56957,7 @@ async function scanDocIndex(directory) {
|
|
|
56902
56957
|
for (const file3 of existingManifest.files) {
|
|
56903
56958
|
try {
|
|
56904
56959
|
const fullPath = path56.join(directory, file3.path);
|
|
56905
|
-
const stat3 =
|
|
56960
|
+
const stat3 = fs43.statSync(fullPath);
|
|
56906
56961
|
if (stat3.mtimeMs > file3.mtime) {
|
|
56907
56962
|
cacheValid = false;
|
|
56908
56963
|
break;
|
|
@@ -56920,7 +56975,7 @@ async function scanDocIndex(directory) {
|
|
|
56920
56975
|
const discoveredFiles = [];
|
|
56921
56976
|
let rawEntries;
|
|
56922
56977
|
try {
|
|
56923
|
-
rawEntries =
|
|
56978
|
+
rawEntries = fs43.readdirSync(directory, { recursive: true });
|
|
56924
56979
|
} catch {
|
|
56925
56980
|
const manifest2 = {
|
|
56926
56981
|
schema_version: 1,
|
|
@@ -56934,7 +56989,7 @@ async function scanDocIndex(directory) {
|
|
|
56934
56989
|
const fullPath = path56.join(directory, entry);
|
|
56935
56990
|
let stat3;
|
|
56936
56991
|
try {
|
|
56937
|
-
stat3 =
|
|
56992
|
+
stat3 = fs43.statSync(fullPath);
|
|
56938
56993
|
} catch {
|
|
56939
56994
|
continue;
|
|
56940
56995
|
}
|
|
@@ -56963,7 +57018,7 @@ async function scanDocIndex(directory) {
|
|
|
56963
57018
|
}
|
|
56964
57019
|
let content;
|
|
56965
57020
|
try {
|
|
56966
|
-
content =
|
|
57021
|
+
content = fs43.readFileSync(fullPath, "utf-8");
|
|
56967
57022
|
} catch {
|
|
56968
57023
|
continue;
|
|
56969
57024
|
}
|
|
@@ -56993,7 +57048,7 @@ async function scanDocIndex(directory) {
|
|
|
56993
57048
|
files: discoveredFiles
|
|
56994
57049
|
};
|
|
56995
57050
|
try {
|
|
56996
|
-
await
|
|
57051
|
+
await mkdir8(path56.dirname(manifestPath), { recursive: true });
|
|
56997
57052
|
await writeFile8(manifestPath, JSON.stringify(manifest, null, 2), "utf-8");
|
|
56998
57053
|
} catch {}
|
|
56999
57054
|
return { manifest, cached: false };
|
|
@@ -57156,7 +57211,7 @@ var init_doc_scan = __esm(() => {
|
|
|
57156
57211
|
if (force) {
|
|
57157
57212
|
const manifestPath = path56.join(directory, ".swarm", "doc-manifest.json");
|
|
57158
57213
|
try {
|
|
57159
|
-
|
|
57214
|
+
fs43.unlinkSync(manifestPath);
|
|
57160
57215
|
} catch {}
|
|
57161
57216
|
}
|
|
57162
57217
|
const { manifest, cached: cached3 } = await scanDocIndex(directory);
|
|
@@ -57343,11 +57398,11 @@ __export(exports_curator_drift, {
|
|
|
57343
57398
|
readPriorDriftReports: () => readPriorDriftReports,
|
|
57344
57399
|
buildDriftInjectionText: () => buildDriftInjectionText
|
|
57345
57400
|
});
|
|
57346
|
-
import * as
|
|
57401
|
+
import * as fs46 from "fs";
|
|
57347
57402
|
import * as path59 from "path";
|
|
57348
57403
|
async function readPriorDriftReports(directory) {
|
|
57349
57404
|
const swarmDir = path59.join(directory, ".swarm");
|
|
57350
|
-
const entries = await
|
|
57405
|
+
const entries = await fs46.promises.readdir(swarmDir).catch(() => null);
|
|
57351
57406
|
if (entries === null)
|
|
57352
57407
|
return [];
|
|
57353
57408
|
const reportFiles = entries.filter((name2) => name2.startsWith(DRIFT_REPORT_PREFIX) && name2.endsWith(".json")).sort();
|
|
@@ -57374,9 +57429,9 @@ async function writeDriftReport(directory, report) {
|
|
|
57374
57429
|
const filename = `${DRIFT_REPORT_PREFIX}${report.phase}.json`;
|
|
57375
57430
|
const filePath = validateSwarmPath(directory, filename);
|
|
57376
57431
|
const swarmDir = path59.dirname(filePath);
|
|
57377
|
-
await
|
|
57432
|
+
await fs46.promises.mkdir(swarmDir, { recursive: true });
|
|
57378
57433
|
try {
|
|
57379
|
-
await
|
|
57434
|
+
await fs46.promises.writeFile(filePath, JSON.stringify(report, null, 2), "utf-8");
|
|
57380
57435
|
} catch (err2) {
|
|
57381
57436
|
throw new Error(`[curator-drift] Failed to write drift report to ${filePath}: ${String(err2)}`);
|
|
57382
57437
|
}
|
|
@@ -60867,7 +60922,7 @@ init_manager3();
|
|
|
60867
60922
|
// src/background/plan-sync-worker.ts
|
|
60868
60923
|
init_manager();
|
|
60869
60924
|
init_utils();
|
|
60870
|
-
import * as
|
|
60925
|
+
import * as fs29 from "fs";
|
|
60871
60926
|
import * as path42 from "path";
|
|
60872
60927
|
|
|
60873
60928
|
class PlanSyncWorker {
|
|
@@ -60950,7 +61005,7 @@ class PlanSyncWorker {
|
|
|
60950
61005
|
}
|
|
60951
61006
|
initializeStat() {
|
|
60952
61007
|
try {
|
|
60953
|
-
const stats =
|
|
61008
|
+
const stats = fs29.statSync(this.getPlanJsonPath());
|
|
60954
61009
|
this.lastStat = { mtimeMs: stats.mtimeMs, size: stats.size };
|
|
60955
61010
|
} catch {
|
|
60956
61011
|
this.lastStat = null;
|
|
@@ -60959,11 +61014,11 @@ class PlanSyncWorker {
|
|
|
60959
61014
|
setupNativeWatcher() {
|
|
60960
61015
|
const swarmDir = this.getSwarmDir();
|
|
60961
61016
|
try {
|
|
60962
|
-
if (!
|
|
61017
|
+
if (!fs29.existsSync(swarmDir)) {
|
|
60963
61018
|
log("[PlanSyncWorker] Swarm directory does not exist yet");
|
|
60964
61019
|
return false;
|
|
60965
61020
|
}
|
|
60966
|
-
this.watcher =
|
|
61021
|
+
this.watcher = fs29.watch(swarmDir, { persistent: false }, (_eventType, filename) => {
|
|
60967
61022
|
if (this.disposed || this.status !== "running") {
|
|
60968
61023
|
return;
|
|
60969
61024
|
}
|
|
@@ -61013,14 +61068,14 @@ class PlanSyncWorker {
|
|
|
61013
61068
|
pollCheck() {
|
|
61014
61069
|
try {
|
|
61015
61070
|
const planPath = this.getPlanJsonPath();
|
|
61016
|
-
if (!
|
|
61071
|
+
if (!fs29.existsSync(planPath)) {
|
|
61017
61072
|
if (this.lastStat !== null) {
|
|
61018
61073
|
this.lastStat = null;
|
|
61019
61074
|
log("[PlanSyncWorker] plan.json deleted");
|
|
61020
61075
|
}
|
|
61021
61076
|
return;
|
|
61022
61077
|
}
|
|
61023
|
-
const stats =
|
|
61078
|
+
const stats = fs29.statSync(planPath);
|
|
61024
61079
|
const currentStat = { mtimeMs: stats.mtimeMs, size: stats.size };
|
|
61025
61080
|
if (this.lastStat === null || currentStat.mtimeMs !== this.lastStat.mtimeMs || currentStat.size !== this.lastStat.size) {
|
|
61026
61081
|
this.lastStat = currentStat;
|
|
@@ -61116,9 +61171,9 @@ class PlanSyncWorker {
|
|
|
61116
61171
|
const swarmDir = this.getSwarmDir();
|
|
61117
61172
|
const planJsonPath = path42.join(swarmDir, "plan.json");
|
|
61118
61173
|
const markerPath = path42.join(swarmDir, ".plan-write-marker");
|
|
61119
|
-
const planStats =
|
|
61174
|
+
const planStats = fs29.statSync(planJsonPath);
|
|
61120
61175
|
const planMtimeMs = Math.floor(planStats.mtimeMs);
|
|
61121
|
-
const markerContent =
|
|
61176
|
+
const markerContent = fs29.readFileSync(markerPath, "utf8");
|
|
61122
61177
|
const marker = JSON.parse(markerContent);
|
|
61123
61178
|
const markerTimestampMs = new Date(marker.timestamp).getTime();
|
|
61124
61179
|
if (planMtimeMs > markerTimestampMs + 5000) {
|
|
@@ -61398,7 +61453,7 @@ ${content.substring(endIndex + 1)}`;
|
|
|
61398
61453
|
// src/hooks/compaction-customizer.ts
|
|
61399
61454
|
init_manager();
|
|
61400
61455
|
init_utils2();
|
|
61401
|
-
import * as
|
|
61456
|
+
import * as fs31 from "fs";
|
|
61402
61457
|
import { join as join39 } from "path";
|
|
61403
61458
|
function createCompactionCustomizerHook(config3, directory) {
|
|
61404
61459
|
const enabled = config3.hooks?.compaction !== false;
|
|
@@ -61445,7 +61500,7 @@ function createCompactionCustomizerHook(config3, directory) {
|
|
|
61445
61500
|
}
|
|
61446
61501
|
try {
|
|
61447
61502
|
const summariesDir = join39(directory, ".swarm", "summaries");
|
|
61448
|
-
const files = await
|
|
61503
|
+
const files = await fs31.promises.readdir(summariesDir);
|
|
61449
61504
|
if (files.length > 0) {
|
|
61450
61505
|
const count = files.length;
|
|
61451
61506
|
output.context.push(`[CONTEXT OPTIMIZATION] Tool outputs from earlier in this session have been stored to disk. When compacting, replace any large tool output blocks (bash, test_runner, lint, diff results) with a one-line reference: "[Output stored \u2014 use /swarm retrieve to access full content]". Preserve the tool name, exit status, and any error messages. Discard raw output lines.`);
|
|
@@ -61931,7 +61986,7 @@ init_delegation_gate();
|
|
|
61931
61986
|
|
|
61932
61987
|
// src/hooks/delegation-sanitizer.ts
|
|
61933
61988
|
init_utils2();
|
|
61934
|
-
import * as
|
|
61989
|
+
import * as fs32 from "fs";
|
|
61935
61990
|
var SANITIZATION_PATTERNS = [
|
|
61936
61991
|
/\b\d+(st|nd|rd|th)\s+(attempt|try|time)\b/gi,
|
|
61937
61992
|
/\b(5th|fifth|final|last)\s+attempt\b/gi,
|
|
@@ -62002,7 +62057,7 @@ function createDelegationSanitizerHook(directory) {
|
|
|
62002
62057
|
stripped_patterns: result.stripped,
|
|
62003
62058
|
timestamp: new Date().toISOString()
|
|
62004
62059
|
};
|
|
62005
|
-
|
|
62060
|
+
fs32.appendFileSync(eventsPath, `${JSON.stringify(event)}
|
|
62006
62061
|
`, "utf-8");
|
|
62007
62062
|
} catch {}
|
|
62008
62063
|
}
|
|
@@ -62065,11 +62120,11 @@ function createDelegationTrackerHook(config3, guardrailsEnabled = true) {
|
|
|
62065
62120
|
}
|
|
62066
62121
|
// src/hooks/full-auto-intercept.ts
|
|
62067
62122
|
init_schema();
|
|
62068
|
-
import * as
|
|
62123
|
+
import * as fs34 from "fs";
|
|
62069
62124
|
|
|
62070
62125
|
// src/parallel/file-locks.ts
|
|
62071
62126
|
var import_proper_lockfile3 = __toESM(require_proper_lockfile(), 1);
|
|
62072
|
-
import * as
|
|
62127
|
+
import * as fs33 from "fs";
|
|
62073
62128
|
import * as path44 from "path";
|
|
62074
62129
|
var LOCKS_DIR = ".swarm/locks";
|
|
62075
62130
|
var LOCK_TIMEOUT_MS = 5 * 60 * 1000;
|
|
@@ -62084,11 +62139,11 @@ function getLockFilePath(directory, filePath) {
|
|
|
62084
62139
|
async function tryAcquireLock(directory, filePath, agent, taskId) {
|
|
62085
62140
|
const lockPath = getLockFilePath(directory, filePath);
|
|
62086
62141
|
const locksDir = path44.dirname(lockPath);
|
|
62087
|
-
if (!
|
|
62088
|
-
|
|
62142
|
+
if (!fs33.existsSync(locksDir)) {
|
|
62143
|
+
fs33.mkdirSync(locksDir, { recursive: true });
|
|
62089
62144
|
}
|
|
62090
|
-
if (!
|
|
62091
|
-
|
|
62145
|
+
if (!fs33.existsSync(lockPath)) {
|
|
62146
|
+
fs33.writeFileSync(lockPath, "", "utf-8");
|
|
62092
62147
|
}
|
|
62093
62148
|
let release;
|
|
62094
62149
|
try {
|
|
@@ -62312,7 +62367,7 @@ async function writeAutoOversightEvent(directory, architectOutput, criticVerdict
|
|
|
62312
62367
|
}
|
|
62313
62368
|
try {
|
|
62314
62369
|
const eventsPath = validateSwarmPath(dir, "events.jsonl");
|
|
62315
|
-
|
|
62370
|
+
fs34.appendFileSync(eventsPath, `${JSON.stringify(event)}
|
|
62316
62371
|
`, "utf-8");
|
|
62317
62372
|
} catch (writeError) {
|
|
62318
62373
|
console.error(`[full-auto-intercept] Warning: failed to write auto_oversight event: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
|
|
@@ -62624,7 +62679,7 @@ async function writeEscalationReport(directory, reason, architectOutput, interac
|
|
|
62624
62679
|
if (currentPhase === undefined) {
|
|
62625
62680
|
try {
|
|
62626
62681
|
const planPath = validateSwarmPath(directory, "plan.json");
|
|
62627
|
-
const planContent =
|
|
62682
|
+
const planContent = fs34.readFileSync(planPath, "utf-8");
|
|
62628
62683
|
const plan = JSON.parse(planContent);
|
|
62629
62684
|
const incompletePhases = plan.phases.filter((p) => p.status !== "complete").sort((a, b) => b.id - a.id);
|
|
62630
62685
|
currentPhase = incompletePhases[0]?.id;
|
|
@@ -62663,7 +62718,7 @@ ${currentPhase !== undefined ? `- **Phase Status**: Pending completion` : ""}
|
|
|
62663
62718
|
This escalation requires human intervention. The swarm has been paused.
|
|
62664
62719
|
Please review the architect's output above and provide guidance.
|
|
62665
62720
|
`;
|
|
62666
|
-
|
|
62721
|
+
fs34.writeFileSync(reportPath, reportContent, "utf-8");
|
|
62667
62722
|
console.log(`[full-auto-intercept] Escalation report written to: ${reportPath}`);
|
|
62668
62723
|
} catch (error93) {
|
|
62669
62724
|
console.error(`[full-auto-intercept] Failed to write escalation report:`, error93 instanceof Error ? error93.message : String(error93));
|
|
@@ -62778,8 +62833,8 @@ function createPhaseMonitorHook(directory, preflightManager, curatorRunner, dele
|
|
|
62778
62833
|
const initResult = await runner(directory, curatorConfig, llmDelegate);
|
|
62779
62834
|
if (initResult.briefing) {
|
|
62780
62835
|
const briefingPath = path46.join(directory, ".swarm", "curator-briefing.md");
|
|
62781
|
-
const { mkdir:
|
|
62782
|
-
await
|
|
62836
|
+
const { mkdir: mkdir7, writeFile: writeFile7 } = await import("fs/promises");
|
|
62837
|
+
await mkdir7(path46.dirname(briefingPath), { recursive: true });
|
|
62783
62838
|
await writeFile7(briefingPath, initResult.briefing, "utf-8");
|
|
62784
62839
|
const { buildApprovedReceipt: buildApprovedReceipt2, persistReviewReceipt: persistReviewReceipt2 } = await Promise.resolve().then(() => (init_review_receipt(), exports_review_receipt));
|
|
62785
62840
|
const initReceipt = buildApprovedReceipt2({
|
|
@@ -62918,7 +62973,7 @@ import * as path48 from "path";
|
|
|
62918
62973
|
init_tool();
|
|
62919
62974
|
init_create_tool();
|
|
62920
62975
|
init_path_security();
|
|
62921
|
-
import * as
|
|
62976
|
+
import * as fs36 from "fs";
|
|
62922
62977
|
import * as path47 from "path";
|
|
62923
62978
|
var MAX_FILE_SIZE_BYTES2 = 1024 * 1024;
|
|
62924
62979
|
var WINDOWS_RESERVED_NAMES = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
@@ -62937,8 +62992,8 @@ function containsWindowsAttacks(str) {
|
|
|
62937
62992
|
function isPathInWorkspace(filePath, workspace) {
|
|
62938
62993
|
try {
|
|
62939
62994
|
const resolvedPath = path47.resolve(workspace, filePath);
|
|
62940
|
-
const realWorkspace =
|
|
62941
|
-
const realResolvedPath =
|
|
62995
|
+
const realWorkspace = fs36.realpathSync(workspace);
|
|
62996
|
+
const realResolvedPath = fs36.realpathSync(resolvedPath);
|
|
62942
62997
|
const relativePath = path47.relative(realWorkspace, realResolvedPath);
|
|
62943
62998
|
if (relativePath.startsWith("..") || path47.isAbsolute(relativePath)) {
|
|
62944
62999
|
return false;
|
|
@@ -62958,11 +63013,11 @@ function extractTSSymbols(filePath, cwd) {
|
|
|
62958
63013
|
}
|
|
62959
63014
|
let content;
|
|
62960
63015
|
try {
|
|
62961
|
-
const stats =
|
|
63016
|
+
const stats = fs36.statSync(fullPath);
|
|
62962
63017
|
if (stats.size > MAX_FILE_SIZE_BYTES2) {
|
|
62963
63018
|
throw new Error(`File too large: ${stats.size} bytes (max: ${MAX_FILE_SIZE_BYTES2})`);
|
|
62964
63019
|
}
|
|
62965
|
-
content =
|
|
63020
|
+
content = fs36.readFileSync(fullPath, "utf-8");
|
|
62966
63021
|
} catch {
|
|
62967
63022
|
return [];
|
|
62968
63023
|
}
|
|
@@ -63110,11 +63165,11 @@ function extractPythonSymbols(filePath, cwd) {
|
|
|
63110
63165
|
}
|
|
63111
63166
|
let content;
|
|
63112
63167
|
try {
|
|
63113
|
-
const stats =
|
|
63168
|
+
const stats = fs36.statSync(fullPath);
|
|
63114
63169
|
if (stats.size > MAX_FILE_SIZE_BYTES2) {
|
|
63115
63170
|
throw new Error(`File too large: ${stats.size} bytes (max: ${MAX_FILE_SIZE_BYTES2})`);
|
|
63116
63171
|
}
|
|
63117
|
-
content =
|
|
63172
|
+
content = fs36.readFileSync(fullPath, "utf-8");
|
|
63118
63173
|
} catch {
|
|
63119
63174
|
return [];
|
|
63120
63175
|
}
|
|
@@ -64031,14 +64086,14 @@ init_schema();
|
|
|
64031
64086
|
init_manager2();
|
|
64032
64087
|
init_detector();
|
|
64033
64088
|
init_manager();
|
|
64034
|
-
import * as
|
|
64089
|
+
import * as fs44 from "fs";
|
|
64035
64090
|
import * as path57 from "path";
|
|
64036
64091
|
|
|
64037
64092
|
// src/services/decision-drift-analyzer.ts
|
|
64038
64093
|
init_utils2();
|
|
64039
64094
|
init_manager();
|
|
64040
64095
|
init_utils();
|
|
64041
|
-
import * as
|
|
64096
|
+
import * as fs37 from "fs";
|
|
64042
64097
|
import * as path50 from "path";
|
|
64043
64098
|
var DEFAULT_DRIFT_CONFIG = {
|
|
64044
64099
|
staleThresholdPhases: 1,
|
|
@@ -64196,8 +64251,8 @@ async function analyzeDecisionDrift(directory, config3 = {}) {
|
|
|
64196
64251
|
const contextPath = path50.join(directory, ".swarm", "context.md");
|
|
64197
64252
|
let contextContent = "";
|
|
64198
64253
|
try {
|
|
64199
|
-
if (
|
|
64200
|
-
contextContent =
|
|
64254
|
+
if (fs37.existsSync(contextPath)) {
|
|
64255
|
+
contextContent = fs37.readFileSync(contextPath, "utf-8");
|
|
64201
64256
|
}
|
|
64202
64257
|
} catch (error93) {
|
|
64203
64258
|
log("[DecisionDriftAnalyzer] context file read failed", {
|
|
@@ -64331,7 +64386,7 @@ init_utils();
|
|
|
64331
64386
|
// src/hooks/adversarial-detector.ts
|
|
64332
64387
|
init_constants();
|
|
64333
64388
|
init_schema();
|
|
64334
|
-
import * as
|
|
64389
|
+
import * as fs38 from "fs/promises";
|
|
64335
64390
|
import * as path51 from "path";
|
|
64336
64391
|
function safeGet(obj, key) {
|
|
64337
64392
|
if (!obj || !Object.hasOwn(obj, key))
|
|
@@ -64565,9 +64620,9 @@ async function handleDebuggingSpiral(match, taskId, directory) {
|
|
|
64565
64620
|
let checkpointCreated = false;
|
|
64566
64621
|
try {
|
|
64567
64622
|
const swarmDir = path51.join(directory, ".swarm");
|
|
64568
|
-
await
|
|
64623
|
+
await fs38.mkdir(swarmDir, { recursive: true });
|
|
64569
64624
|
const eventsPath = path51.join(swarmDir, "events.jsonl");
|
|
64570
|
-
await
|
|
64625
|
+
await fs38.appendFile(eventsPath, `${formatDebuggingSpiralEvent(match, taskId)}
|
|
64571
64626
|
`);
|
|
64572
64627
|
eventLogged = true;
|
|
64573
64628
|
} catch {}
|
|
@@ -64679,10 +64734,10 @@ function rankCandidates(candidates, config3) {
|
|
|
64679
64734
|
init_knowledge_store();
|
|
64680
64735
|
|
|
64681
64736
|
// src/hooks/repo-graph-injection.ts
|
|
64682
|
-
import * as
|
|
64737
|
+
import * as fs42 from "fs";
|
|
64683
64738
|
|
|
64684
64739
|
// src/graph/graph-builder.ts
|
|
64685
|
-
import * as
|
|
64740
|
+
import * as fs40 from "fs";
|
|
64686
64741
|
import * as path54 from "path";
|
|
64687
64742
|
|
|
64688
64743
|
// node_modules/yocto-queue/index.js
|
|
@@ -64842,7 +64897,7 @@ function validateConcurrency(concurrency) {
|
|
|
64842
64897
|
}
|
|
64843
64898
|
|
|
64844
64899
|
// src/graph/import-extractor.ts
|
|
64845
|
-
import * as
|
|
64900
|
+
import * as fs39 from "fs";
|
|
64846
64901
|
import * as path52 from "path";
|
|
64847
64902
|
var SOURCE_EXTENSIONS2 = [
|
|
64848
64903
|
".ts",
|
|
@@ -64900,7 +64955,7 @@ function tryResolveTSJS(rawModule, sourceFileAbs) {
|
|
|
64900
64955
|
for (const ext of RESOLVE_EXTENSION_CANDIDATES) {
|
|
64901
64956
|
const test = basePath + ext;
|
|
64902
64957
|
try {
|
|
64903
|
-
const stat3 =
|
|
64958
|
+
const stat3 = fs39.statSync(test);
|
|
64904
64959
|
if (stat3.isFile())
|
|
64905
64960
|
return test;
|
|
64906
64961
|
} catch {}
|
|
@@ -64908,7 +64963,7 @@ function tryResolveTSJS(rawModule, sourceFileAbs) {
|
|
|
64908
64963
|
for (const indexFile of RESOLVE_INDEX_CANDIDATES) {
|
|
64909
64964
|
const test = path52.join(basePath, indexFile);
|
|
64910
64965
|
try {
|
|
64911
|
-
const stat3 =
|
|
64966
|
+
const stat3 = fs39.statSync(test);
|
|
64912
64967
|
if (stat3.isFile())
|
|
64913
64968
|
return test;
|
|
64914
64969
|
} catch {}
|
|
@@ -64940,7 +64995,7 @@ function tryResolvePython(rawModule, sourceFileAbs, workspaceRoot) {
|
|
|
64940
64995
|
const baseAbs = path52.resolve(sourceDir, upDirs + remainder);
|
|
64941
64996
|
const accept = (test) => {
|
|
64942
64997
|
try {
|
|
64943
|
-
const stat3 =
|
|
64998
|
+
const stat3 = fs39.statSync(test);
|
|
64944
64999
|
if (stat3.isFile()) {
|
|
64945
65000
|
const rel = path52.relative(workspaceRoot, test).replace(/\\/g, "/");
|
|
64946
65001
|
if (rel.startsWith(".."))
|
|
@@ -65334,7 +65389,7 @@ function extractImports2(opts) {
|
|
|
65334
65389
|
let content = opts.content;
|
|
65335
65390
|
if (content === undefined) {
|
|
65336
65391
|
try {
|
|
65337
|
-
content =
|
|
65392
|
+
content = fs39.readFileSync(absoluteFilePath, "utf-8");
|
|
65338
65393
|
} catch {
|
|
65339
65394
|
return [];
|
|
65340
65395
|
}
|
|
@@ -65452,7 +65507,7 @@ function findSourceFiles2(workspaceRoot, skipDirs = DEFAULT_SKIP_DIRS) {
|
|
|
65452
65507
|
const dir = stack.pop();
|
|
65453
65508
|
let entries;
|
|
65454
65509
|
try {
|
|
65455
|
-
entries =
|
|
65510
|
+
entries = fs40.readdirSync(dir, { withFileTypes: true });
|
|
65456
65511
|
} catch {
|
|
65457
65512
|
continue;
|
|
65458
65513
|
}
|
|
@@ -65509,7 +65564,7 @@ async function processFile(absoluteFilePath, workspaceRoot) {
|
|
|
65509
65564
|
return null;
|
|
65510
65565
|
let stats;
|
|
65511
65566
|
try {
|
|
65512
|
-
stats =
|
|
65567
|
+
stats = fs40.statSync(absoluteFilePath);
|
|
65513
65568
|
} catch {
|
|
65514
65569
|
return null;
|
|
65515
65570
|
}
|
|
@@ -65519,7 +65574,7 @@ async function processFile(absoluteFilePath, workspaceRoot) {
|
|
|
65519
65574
|
return null;
|
|
65520
65575
|
let content;
|
|
65521
65576
|
try {
|
|
65522
|
-
content =
|
|
65577
|
+
content = fs40.readFileSync(absoluteFilePath, "utf-8");
|
|
65523
65578
|
} catch {
|
|
65524
65579
|
return null;
|
|
65525
65580
|
}
|
|
@@ -65764,7 +65819,7 @@ function formatSummary(opts) {
|
|
|
65764
65819
|
}
|
|
65765
65820
|
// src/graph/graph-store.ts
|
|
65766
65821
|
import * as crypto6 from "crypto";
|
|
65767
|
-
import * as
|
|
65822
|
+
import * as fs41 from "fs";
|
|
65768
65823
|
import * as path55 from "path";
|
|
65769
65824
|
var SWARM_DIR = ".swarm";
|
|
65770
65825
|
function getGraphPath2(workspaceRoot) {
|
|
@@ -65774,7 +65829,7 @@ function loadGraph2(workspaceRoot) {
|
|
|
65774
65829
|
const file3 = getGraphPath2(workspaceRoot);
|
|
65775
65830
|
let raw;
|
|
65776
65831
|
try {
|
|
65777
|
-
raw =
|
|
65832
|
+
raw = fs41.readFileSync(file3, "utf-8");
|
|
65778
65833
|
} catch {
|
|
65779
65834
|
return null;
|
|
65780
65835
|
}
|
|
@@ -65792,7 +65847,7 @@ function saveGraph2(workspaceRoot, graph) {
|
|
|
65792
65847
|
const file3 = getGraphPath2(workspaceRoot);
|
|
65793
65848
|
const dir = path55.dirname(file3);
|
|
65794
65849
|
try {
|
|
65795
|
-
const stat3 =
|
|
65850
|
+
const stat3 = fs41.lstatSync(dir);
|
|
65796
65851
|
if (stat3.isSymbolicLink()) {
|
|
65797
65852
|
throw new Error(`refusing to write graph: ${SWARM_DIR}/ is a symbolic link`);
|
|
65798
65853
|
}
|
|
@@ -65800,14 +65855,14 @@ function saveGraph2(workspaceRoot, graph) {
|
|
|
65800
65855
|
if (err2.code !== "ENOENT")
|
|
65801
65856
|
throw err2;
|
|
65802
65857
|
}
|
|
65803
|
-
|
|
65858
|
+
fs41.mkdirSync(dir, { recursive: true });
|
|
65804
65859
|
const tmp = `${file3}.tmp.${crypto6.randomUUID()}`;
|
|
65805
|
-
|
|
65860
|
+
fs41.writeFileSync(tmp, JSON.stringify(graph), "utf-8");
|
|
65806
65861
|
try {
|
|
65807
|
-
|
|
65862
|
+
fs41.renameSync(tmp, file3);
|
|
65808
65863
|
} catch (renameErr) {
|
|
65809
65864
|
try {
|
|
65810
|
-
|
|
65865
|
+
fs41.unlinkSync(tmp);
|
|
65811
65866
|
} catch {}
|
|
65812
65867
|
throw renameErr;
|
|
65813
65868
|
}
|
|
@@ -65831,7 +65886,7 @@ function getCachedGraph2(directory) {
|
|
|
65831
65886
|
const file3 = getGraphPath2(directory);
|
|
65832
65887
|
let stat3;
|
|
65833
65888
|
try {
|
|
65834
|
-
stat3 =
|
|
65889
|
+
stat3 = fs42.statSync(file3);
|
|
65835
65890
|
} catch {
|
|
65836
65891
|
cache.delete(directory);
|
|
65837
65892
|
return null;
|
|
@@ -66195,7 +66250,7 @@ function createSystemEnhancerHook(config3, directory) {
|
|
|
66195
66250
|
} catch {}
|
|
66196
66251
|
try {
|
|
66197
66252
|
const darkMatterPath = validateSwarmPath(directory, "dark-matter.md");
|
|
66198
|
-
if (!
|
|
66253
|
+
if (!fs44.existsSync(darkMatterPath)) {
|
|
66199
66254
|
const {
|
|
66200
66255
|
detectDarkMatter: detectDarkMatter2,
|
|
66201
66256
|
formatDarkMatterOutput: formatDarkMatterOutput2,
|
|
@@ -66207,7 +66262,7 @@ function createSystemEnhancerHook(config3, directory) {
|
|
|
66207
66262
|
});
|
|
66208
66263
|
if (darkMatter && darkMatter.length > 0) {
|
|
66209
66264
|
const darkMatterReport = formatDarkMatterOutput2(darkMatter);
|
|
66210
|
-
await
|
|
66265
|
+
await fs44.promises.writeFile(darkMatterPath, darkMatterReport, "utf-8");
|
|
66211
66266
|
warn(`[system-enhancer] Dark matter scan complete: ${darkMatter.length} co-change patterns found`);
|
|
66212
66267
|
try {
|
|
66213
66268
|
const projectName = path57.basename(path57.resolve(directory));
|
|
@@ -66274,14 +66329,14 @@ function createSystemEnhancerHook(config3, directory) {
|
|
|
66274
66329
|
if (handoffContent) {
|
|
66275
66330
|
const handoffPath = validateSwarmPath(directory, "handoff.md");
|
|
66276
66331
|
const consumedPath = validateSwarmPath(directory, "handoff-consumed.md");
|
|
66277
|
-
if (
|
|
66332
|
+
if (fs44.existsSync(consumedPath)) {
|
|
66278
66333
|
warn("Duplicate handoff detected: handoff-consumed.md already exists");
|
|
66279
|
-
|
|
66334
|
+
fs44.unlinkSync(consumedPath);
|
|
66280
66335
|
}
|
|
66281
|
-
|
|
66336
|
+
fs44.renameSync(handoffPath, consumedPath);
|
|
66282
66337
|
try {
|
|
66283
66338
|
const promptPath = validateSwarmPath(directory, "handoff-prompt.md");
|
|
66284
|
-
|
|
66339
|
+
fs44.unlinkSync(promptPath);
|
|
66285
66340
|
} catch {}
|
|
66286
66341
|
const handoffBlock = `## HANDOFF \u2014 Resuming from model switch
|
|
66287
66342
|
The previous model's session ended. Here is your starting context:
|
|
@@ -66410,8 +66465,8 @@ ${lines.join(`
|
|
|
66410
66465
|
const taskId_ccp = ccpSession?.currentTaskId;
|
|
66411
66466
|
if (taskId_ccp && !taskId_ccp.includes("..") && !taskId_ccp.includes("/") && !taskId_ccp.includes("\\") && !taskId_ccp.includes("\x00")) {
|
|
66412
66467
|
const evidencePath = path57.join(directory, ".swarm", "evidence", `${taskId_ccp}.json`);
|
|
66413
|
-
if (
|
|
66414
|
-
const evidenceContent =
|
|
66468
|
+
if (fs44.existsSync(evidencePath)) {
|
|
66469
|
+
const evidenceContent = fs44.readFileSync(evidencePath, "utf-8");
|
|
66415
66470
|
const evidenceData = JSON.parse(evidenceContent);
|
|
66416
66471
|
const rejections = (evidenceData.bundle?.entries ?? []).filter((e) => e.type === "gate" && e.gate_type === "reviewer" && e.verdict === "reject");
|
|
66417
66472
|
if (rejections.length > 0) {
|
|
@@ -66664,11 +66719,11 @@ ${budgetWarning}`);
|
|
|
66664
66719
|
if (handoffContent) {
|
|
66665
66720
|
const handoffPath = validateSwarmPath(directory, "handoff.md");
|
|
66666
66721
|
const consumedPath = validateSwarmPath(directory, "handoff-consumed.md");
|
|
66667
|
-
if (
|
|
66722
|
+
if (fs44.existsSync(consumedPath)) {
|
|
66668
66723
|
warn("Duplicate handoff detected: handoff-consumed.md already exists");
|
|
66669
|
-
|
|
66724
|
+
fs44.unlinkSync(consumedPath);
|
|
66670
66725
|
}
|
|
66671
|
-
|
|
66726
|
+
fs44.renameSync(handoffPath, consumedPath);
|
|
66672
66727
|
const handoffBlock = `## HANDOFF \u2014 Resuming from model switch
|
|
66673
66728
|
The previous model's session ended. Here is your starting context:
|
|
66674
66729
|
|
|
@@ -67523,7 +67578,7 @@ init_guardrails();
|
|
|
67523
67578
|
init_hive_promoter();
|
|
67524
67579
|
|
|
67525
67580
|
// src/hooks/incremental-verify.ts
|
|
67526
|
-
import * as
|
|
67581
|
+
import * as fs45 from "fs";
|
|
67527
67582
|
import * as path58 from "path";
|
|
67528
67583
|
|
|
67529
67584
|
// src/hooks/spawn-helper.ts
|
|
@@ -67602,21 +67657,21 @@ function spawnAsync(command, cwd, timeoutMs) {
|
|
|
67602
67657
|
// src/hooks/incremental-verify.ts
|
|
67603
67658
|
var emittedSkipAdvisories = new Set;
|
|
67604
67659
|
function detectPackageManager(projectDir) {
|
|
67605
|
-
if (
|
|
67660
|
+
if (fs45.existsSync(path58.join(projectDir, "bun.lockb")))
|
|
67606
67661
|
return "bun";
|
|
67607
|
-
if (
|
|
67662
|
+
if (fs45.existsSync(path58.join(projectDir, "pnpm-lock.yaml")))
|
|
67608
67663
|
return "pnpm";
|
|
67609
|
-
if (
|
|
67664
|
+
if (fs45.existsSync(path58.join(projectDir, "yarn.lock")))
|
|
67610
67665
|
return "yarn";
|
|
67611
|
-
if (
|
|
67666
|
+
if (fs45.existsSync(path58.join(projectDir, "package-lock.json")))
|
|
67612
67667
|
return "npm";
|
|
67613
67668
|
return "bun";
|
|
67614
67669
|
}
|
|
67615
67670
|
function detectTypecheckCommand(projectDir) {
|
|
67616
67671
|
const pkgPath = path58.join(projectDir, "package.json");
|
|
67617
|
-
if (
|
|
67672
|
+
if (fs45.existsSync(pkgPath)) {
|
|
67618
67673
|
try {
|
|
67619
|
-
const pkg = JSON.parse(
|
|
67674
|
+
const pkg = JSON.parse(fs45.readFileSync(pkgPath, "utf8"));
|
|
67620
67675
|
const scripts = pkg.scripts;
|
|
67621
67676
|
if (scripts?.typecheck) {
|
|
67622
67677
|
const pm = detectPackageManager(projectDir);
|
|
@@ -67630,8 +67685,8 @@ function detectTypecheckCommand(projectDir) {
|
|
|
67630
67685
|
...pkg.dependencies,
|
|
67631
67686
|
...pkg.devDependencies
|
|
67632
67687
|
};
|
|
67633
|
-
if (!deps?.typescript && !
|
|
67634
|
-
const hasTSMarkers = deps?.typescript ||
|
|
67688
|
+
if (!deps?.typescript && !fs45.existsSync(path58.join(projectDir, "tsconfig.json"))) {}
|
|
67689
|
+
const hasTSMarkers = deps?.typescript || fs45.existsSync(path58.join(projectDir, "tsconfig.json"));
|
|
67635
67690
|
if (hasTSMarkers) {
|
|
67636
67691
|
return { command: ["npx", "tsc", "--noEmit"], language: "typescript" };
|
|
67637
67692
|
}
|
|
@@ -67639,17 +67694,17 @@ function detectTypecheckCommand(projectDir) {
|
|
|
67639
67694
|
return null;
|
|
67640
67695
|
}
|
|
67641
67696
|
}
|
|
67642
|
-
if (
|
|
67697
|
+
if (fs45.existsSync(path58.join(projectDir, "go.mod"))) {
|
|
67643
67698
|
return { command: ["go", "vet", "./..."], language: "go" };
|
|
67644
67699
|
}
|
|
67645
|
-
if (
|
|
67700
|
+
if (fs45.existsSync(path58.join(projectDir, "Cargo.toml"))) {
|
|
67646
67701
|
return { command: ["cargo", "check"], language: "rust" };
|
|
67647
67702
|
}
|
|
67648
|
-
if (
|
|
67703
|
+
if (fs45.existsSync(path58.join(projectDir, "pyproject.toml")) || fs45.existsSync(path58.join(projectDir, "requirements.txt")) || fs45.existsSync(path58.join(projectDir, "setup.py"))) {
|
|
67649
67704
|
return { command: null, language: "python" };
|
|
67650
67705
|
}
|
|
67651
67706
|
try {
|
|
67652
|
-
const entries =
|
|
67707
|
+
const entries = fs45.readdirSync(projectDir);
|
|
67653
67708
|
if (entries.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"))) {
|
|
67654
67709
|
return {
|
|
67655
67710
|
command: ["dotnet", "build", "--no-restore"],
|
|
@@ -68103,7 +68158,7 @@ function createSelfReviewHook(config3, injectAdvisory) {
|
|
|
68103
68158
|
}
|
|
68104
68159
|
|
|
68105
68160
|
// src/hooks/slop-detector.ts
|
|
68106
|
-
import * as
|
|
68161
|
+
import * as fs47 from "fs";
|
|
68107
68162
|
import * as path61 from "path";
|
|
68108
68163
|
var WRITE_EDIT_TOOLS = new Set([
|
|
68109
68164
|
"write",
|
|
@@ -68149,7 +68204,7 @@ function checkBoilerplateExplosion(content, taskDescription, threshold) {
|
|
|
68149
68204
|
function walkFiles(dir, exts, deadline) {
|
|
68150
68205
|
const results = [];
|
|
68151
68206
|
try {
|
|
68152
|
-
for (const entry of
|
|
68207
|
+
for (const entry of fs47.readdirSync(dir, { withFileTypes: true })) {
|
|
68153
68208
|
if (deadline !== undefined && Date.now() > deadline)
|
|
68154
68209
|
break;
|
|
68155
68210
|
if (entry.isSymbolicLink())
|
|
@@ -68169,7 +68224,7 @@ function walkFiles(dir, exts, deadline) {
|
|
|
68169
68224
|
return results;
|
|
68170
68225
|
}
|
|
68171
68226
|
function checkDeadExports(content, projectDir, startTime) {
|
|
68172
|
-
const hasPackageJson =
|
|
68227
|
+
const hasPackageJson = fs47.existsSync(path61.join(projectDir, "package.json"));
|
|
68173
68228
|
if (!hasPackageJson)
|
|
68174
68229
|
return null;
|
|
68175
68230
|
const exportMatches = content.matchAll(/^\+(?:export)\s+(?:function|class|const|type|interface)\s+(\w{3,})/gm);
|
|
@@ -68192,7 +68247,7 @@ function checkDeadExports(content, projectDir, startTime) {
|
|
|
68192
68247
|
if (found || Date.now() - startTime > 480)
|
|
68193
68248
|
break;
|
|
68194
68249
|
try {
|
|
68195
|
-
const text =
|
|
68250
|
+
const text = fs47.readFileSync(file3, "utf-8");
|
|
68196
68251
|
if (importPattern.test(text))
|
|
68197
68252
|
found = true;
|
|
68198
68253
|
importPattern.lastIndex = 0;
|
|
@@ -68325,7 +68380,7 @@ Review before proceeding.`;
|
|
|
68325
68380
|
|
|
68326
68381
|
// src/hooks/steering-consumed.ts
|
|
68327
68382
|
init_utils2();
|
|
68328
|
-
import * as
|
|
68383
|
+
import * as fs48 from "fs";
|
|
68329
68384
|
function recordSteeringConsumed(directory, directiveId) {
|
|
68330
68385
|
try {
|
|
68331
68386
|
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
@@ -68334,7 +68389,7 @@ function recordSteeringConsumed(directory, directiveId) {
|
|
|
68334
68389
|
directiveId,
|
|
68335
68390
|
timestamp: new Date().toISOString()
|
|
68336
68391
|
};
|
|
68337
|
-
|
|
68392
|
+
fs48.appendFileSync(eventsPath, `${JSON.stringify(event)}
|
|
68338
68393
|
`, "utf-8");
|
|
68339
68394
|
} catch {}
|
|
68340
68395
|
}
|
|
@@ -68582,7 +68637,7 @@ init_telemetry();
|
|
|
68582
68637
|
// src/tools/batch-symbols.ts
|
|
68583
68638
|
init_tool();
|
|
68584
68639
|
init_create_tool();
|
|
68585
|
-
import * as
|
|
68640
|
+
import * as fs49 from "fs";
|
|
68586
68641
|
import * as path62 from "path";
|
|
68587
68642
|
init_path_security();
|
|
68588
68643
|
var WINDOWS_RESERVED_NAMES2 = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
@@ -68601,11 +68656,11 @@ function containsWindowsAttacks2(str) {
|
|
|
68601
68656
|
function isPathInWorkspace2(filePath, workspace) {
|
|
68602
68657
|
try {
|
|
68603
68658
|
const resolvedPath = path62.resolve(workspace, filePath);
|
|
68604
|
-
if (!
|
|
68659
|
+
if (!fs49.existsSync(resolvedPath)) {
|
|
68605
68660
|
return true;
|
|
68606
68661
|
}
|
|
68607
|
-
const realWorkspace =
|
|
68608
|
-
const realResolvedPath =
|
|
68662
|
+
const realWorkspace = fs49.realpathSync(workspace);
|
|
68663
|
+
const realResolvedPath = fs49.realpathSync(resolvedPath);
|
|
68609
68664
|
const relativePath = path62.relative(realWorkspace, realResolvedPath);
|
|
68610
68665
|
if (relativePath.startsWith("..") || path62.isAbsolute(relativePath)) {
|
|
68611
68666
|
return false;
|
|
@@ -68650,7 +68705,7 @@ function processFile2(file3, cwd, exportedOnly) {
|
|
|
68650
68705
|
};
|
|
68651
68706
|
}
|
|
68652
68707
|
const fullPath = path62.join(cwd, file3);
|
|
68653
|
-
if (!
|
|
68708
|
+
if (!fs49.existsSync(fullPath)) {
|
|
68654
68709
|
return {
|
|
68655
68710
|
file: file3,
|
|
68656
68711
|
success: false,
|
|
@@ -68681,14 +68736,14 @@ function processFile2(file3, cwd, exportedOnly) {
|
|
|
68681
68736
|
}
|
|
68682
68737
|
let isEmptyFile = false;
|
|
68683
68738
|
try {
|
|
68684
|
-
const stats =
|
|
68739
|
+
const stats = fs49.statSync(fullPath);
|
|
68685
68740
|
if (stats.size === 0) {
|
|
68686
68741
|
isEmptyFile = true;
|
|
68687
68742
|
}
|
|
68688
68743
|
} catch {}
|
|
68689
68744
|
if (syms.length === 0) {
|
|
68690
68745
|
try {
|
|
68691
|
-
const content =
|
|
68746
|
+
const content = fs49.readFileSync(fullPath, "utf-8");
|
|
68692
68747
|
if (content.trim().length === 0) {
|
|
68693
68748
|
isEmptyFile = true;
|
|
68694
68749
|
}
|
|
@@ -68940,7 +68995,7 @@ init_manager2();
|
|
|
68940
68995
|
init_task_id();
|
|
68941
68996
|
init_create_tool();
|
|
68942
68997
|
init_resolve_working_directory();
|
|
68943
|
-
import * as
|
|
68998
|
+
import * as fs50 from "fs";
|
|
68944
68999
|
import * as path63 from "path";
|
|
68945
69000
|
var EVIDENCE_DIR = ".swarm/evidence";
|
|
68946
69001
|
function isValidTaskId3(taskId) {
|
|
@@ -68953,12 +69008,12 @@ function isPathWithinSwarm(filePath, workspaceRoot) {
|
|
|
68953
69008
|
return normalizedPath.startsWith(swarmPath);
|
|
68954
69009
|
}
|
|
68955
69010
|
function readEvidenceFile(evidencePath) {
|
|
68956
|
-
if (!
|
|
69011
|
+
if (!fs50.existsSync(evidencePath)) {
|
|
68957
69012
|
return null;
|
|
68958
69013
|
}
|
|
68959
69014
|
let content;
|
|
68960
69015
|
try {
|
|
68961
|
-
content =
|
|
69016
|
+
content = fs50.readFileSync(evidencePath, "utf-8");
|
|
68962
69017
|
} catch {
|
|
68963
69018
|
return null;
|
|
68964
69019
|
}
|
|
@@ -69126,7 +69181,7 @@ init_utils2();
|
|
|
69126
69181
|
init_state();
|
|
69127
69182
|
init_create_tool();
|
|
69128
69183
|
init_resolve_working_directory();
|
|
69129
|
-
import * as
|
|
69184
|
+
import * as fs51 from "fs";
|
|
69130
69185
|
import * as path64 from "path";
|
|
69131
69186
|
function extractMatches(regex, text) {
|
|
69132
69187
|
return Array.from(text.matchAll(regex));
|
|
@@ -69221,7 +69276,7 @@ async function executeCompletionVerify(args2, directory) {
|
|
|
69221
69276
|
let plan;
|
|
69222
69277
|
try {
|
|
69223
69278
|
const planPath = validateSwarmPath(directory, "plan.json");
|
|
69224
|
-
const planRaw =
|
|
69279
|
+
const planRaw = fs51.readFileSync(planPath, "utf-8");
|
|
69225
69280
|
plan = JSON.parse(planRaw);
|
|
69226
69281
|
} catch {
|
|
69227
69282
|
const result2 = {
|
|
@@ -69295,7 +69350,7 @@ async function executeCompletionVerify(args2, directory) {
|
|
|
69295
69350
|
}
|
|
69296
69351
|
let fileContent;
|
|
69297
69352
|
try {
|
|
69298
|
-
fileContent =
|
|
69353
|
+
fileContent = fs51.readFileSync(resolvedPath, "utf-8");
|
|
69299
69354
|
} catch {
|
|
69300
69355
|
blockedTasks.push({
|
|
69301
69356
|
task_id: task.id,
|
|
@@ -69339,7 +69394,7 @@ async function executeCompletionVerify(args2, directory) {
|
|
|
69339
69394
|
try {
|
|
69340
69395
|
const evidenceDir = path64.join(directory, ".swarm", "evidence", `${phase}`);
|
|
69341
69396
|
const evidencePath = path64.join(evidenceDir, "completion-verify.json");
|
|
69342
|
-
|
|
69397
|
+
fs51.mkdirSync(evidenceDir, { recursive: true });
|
|
69343
69398
|
const evidenceBundle = {
|
|
69344
69399
|
schema_version: "1.0.0",
|
|
69345
69400
|
task_id: "completion-verify",
|
|
@@ -69360,7 +69415,7 @@ async function executeCompletionVerify(args2, directory) {
|
|
|
69360
69415
|
}
|
|
69361
69416
|
]
|
|
69362
69417
|
};
|
|
69363
|
-
|
|
69418
|
+
fs51.writeFileSync(evidencePath, JSON.stringify(evidenceBundle, null, 2), "utf-8");
|
|
69364
69419
|
} catch {}
|
|
69365
69420
|
return JSON.stringify(result, null, 2);
|
|
69366
69421
|
}
|
|
@@ -69414,11 +69469,11 @@ var completion_verify = createSwarmTool({
|
|
|
69414
69469
|
});
|
|
69415
69470
|
// src/tools/complexity-hotspots.ts
|
|
69416
69471
|
init_dist();
|
|
69417
|
-
import * as
|
|
69472
|
+
import * as fs53 from "fs";
|
|
69418
69473
|
import * as path66 from "path";
|
|
69419
69474
|
|
|
69420
69475
|
// src/quality/metrics.ts
|
|
69421
|
-
import * as
|
|
69476
|
+
import * as fs52 from "fs";
|
|
69422
69477
|
import * as path65 from "path";
|
|
69423
69478
|
var MAX_FILE_SIZE_BYTES4 = 256 * 1024;
|
|
69424
69479
|
var MIN_DUPLICATION_LINES = 10;
|
|
@@ -69457,11 +69512,11 @@ function estimateCyclomaticComplexity(content) {
|
|
|
69457
69512
|
}
|
|
69458
69513
|
function getComplexityForFile(filePath) {
|
|
69459
69514
|
try {
|
|
69460
|
-
const stat3 =
|
|
69515
|
+
const stat3 = fs52.statSync(filePath);
|
|
69461
69516
|
if (stat3.size > MAX_FILE_SIZE_BYTES4) {
|
|
69462
69517
|
return null;
|
|
69463
69518
|
}
|
|
69464
|
-
const content =
|
|
69519
|
+
const content = fs52.readFileSync(filePath, "utf-8");
|
|
69465
69520
|
return estimateCyclomaticComplexity(content);
|
|
69466
69521
|
} catch {
|
|
69467
69522
|
return null;
|
|
@@ -69472,7 +69527,7 @@ async function computeComplexityDelta(files, workingDir) {
|
|
|
69472
69527
|
const analyzedFiles = [];
|
|
69473
69528
|
for (const file3 of files) {
|
|
69474
69529
|
const fullPath = path65.isAbsolute(file3) ? file3 : path65.join(workingDir, file3);
|
|
69475
|
-
if (!
|
|
69530
|
+
if (!fs52.existsSync(fullPath)) {
|
|
69476
69531
|
continue;
|
|
69477
69532
|
}
|
|
69478
69533
|
const complexity = getComplexityForFile(fullPath);
|
|
@@ -69593,7 +69648,7 @@ function countGoExports(content) {
|
|
|
69593
69648
|
}
|
|
69594
69649
|
function getExportCountForFile(filePath) {
|
|
69595
69650
|
try {
|
|
69596
|
-
const content =
|
|
69651
|
+
const content = fs52.readFileSync(filePath, "utf-8");
|
|
69597
69652
|
const ext = path65.extname(filePath).toLowerCase();
|
|
69598
69653
|
switch (ext) {
|
|
69599
69654
|
case ".ts":
|
|
@@ -69621,7 +69676,7 @@ async function computePublicApiDelta(files, workingDir) {
|
|
|
69621
69676
|
const analyzedFiles = [];
|
|
69622
69677
|
for (const file3 of files) {
|
|
69623
69678
|
const fullPath = path65.isAbsolute(file3) ? file3 : path65.join(workingDir, file3);
|
|
69624
|
-
if (!
|
|
69679
|
+
if (!fs52.existsSync(fullPath)) {
|
|
69625
69680
|
continue;
|
|
69626
69681
|
}
|
|
69627
69682
|
const exports = getExportCountForFile(fullPath);
|
|
@@ -69655,15 +69710,15 @@ async function computeDuplicationRatio(files, workingDir) {
|
|
|
69655
69710
|
const analyzedFiles = [];
|
|
69656
69711
|
for (const file3 of files) {
|
|
69657
69712
|
const fullPath = path65.isAbsolute(file3) ? file3 : path65.join(workingDir, file3);
|
|
69658
|
-
if (!
|
|
69713
|
+
if (!fs52.existsSync(fullPath)) {
|
|
69659
69714
|
continue;
|
|
69660
69715
|
}
|
|
69661
69716
|
try {
|
|
69662
|
-
const stat3 =
|
|
69717
|
+
const stat3 = fs52.statSync(fullPath);
|
|
69663
69718
|
if (stat3.size > MAX_FILE_SIZE_BYTES4) {
|
|
69664
69719
|
continue;
|
|
69665
69720
|
}
|
|
69666
|
-
const content =
|
|
69721
|
+
const content = fs52.readFileSync(fullPath, "utf-8");
|
|
69667
69722
|
const lines = content.split(`
|
|
69668
69723
|
`).filter((line) => line.trim().length > 0);
|
|
69669
69724
|
if (lines.length < MIN_DUPLICATION_LINES) {
|
|
@@ -69839,7 +69894,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
69839
69894
|
let testLines = 0;
|
|
69840
69895
|
let codeLines = 0;
|
|
69841
69896
|
const srcDir = path65.join(workingDir, "src");
|
|
69842
|
-
if (
|
|
69897
|
+
if (fs52.existsSync(srcDir)) {
|
|
69843
69898
|
await scanDirectoryForLines(srcDir, enforceGlobs, excludeGlobs, false, (lines) => {
|
|
69844
69899
|
codeLines += lines;
|
|
69845
69900
|
});
|
|
@@ -69847,14 +69902,14 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
69847
69902
|
const possibleSrcDirs = ["lib", "app", "source", "core"];
|
|
69848
69903
|
for (const dir of possibleSrcDirs) {
|
|
69849
69904
|
const dirPath = path65.join(workingDir, dir);
|
|
69850
|
-
if (
|
|
69905
|
+
if (fs52.existsSync(dirPath)) {
|
|
69851
69906
|
await scanDirectoryForLines(dirPath, enforceGlobs, excludeGlobs, false, (lines) => {
|
|
69852
69907
|
codeLines += lines;
|
|
69853
69908
|
});
|
|
69854
69909
|
}
|
|
69855
69910
|
}
|
|
69856
69911
|
const testsDir = path65.join(workingDir, "tests");
|
|
69857
|
-
if (
|
|
69912
|
+
if (fs52.existsSync(testsDir)) {
|
|
69858
69913
|
await scanDirectoryForLines(testsDir, ["**"], ["node_modules", "dist"], true, (lines) => {
|
|
69859
69914
|
testLines += lines;
|
|
69860
69915
|
});
|
|
@@ -69862,7 +69917,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
69862
69917
|
const possibleTestDirs = ["test", "__tests__", "specs"];
|
|
69863
69918
|
for (const dir of possibleTestDirs) {
|
|
69864
69919
|
const dirPath = path65.join(workingDir, dir);
|
|
69865
|
-
if (
|
|
69920
|
+
if (fs52.existsSync(dirPath) && dirPath !== testsDir) {
|
|
69866
69921
|
await scanDirectoryForLines(dirPath, ["**"], ["node_modules", "dist"], true, (lines) => {
|
|
69867
69922
|
testLines += lines;
|
|
69868
69923
|
});
|
|
@@ -69874,7 +69929,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
69874
69929
|
}
|
|
69875
69930
|
async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTestScan, callback) {
|
|
69876
69931
|
try {
|
|
69877
|
-
const entries =
|
|
69932
|
+
const entries = fs52.readdirSync(dirPath, { withFileTypes: true });
|
|
69878
69933
|
for (const entry of entries) {
|
|
69879
69934
|
const fullPath = path65.join(dirPath, entry.name);
|
|
69880
69935
|
if (entry.isDirectory()) {
|
|
@@ -69920,7 +69975,7 @@ async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTest
|
|
|
69920
69975
|
continue;
|
|
69921
69976
|
}
|
|
69922
69977
|
try {
|
|
69923
|
-
const content =
|
|
69978
|
+
const content = fs52.readFileSync(fullPath, "utf-8");
|
|
69924
69979
|
const lines = countCodeLines(content);
|
|
69925
69980
|
callback(lines);
|
|
69926
69981
|
} catch {}
|
|
@@ -70122,11 +70177,11 @@ async function getGitChurn(days, directory) {
|
|
|
70122
70177
|
}
|
|
70123
70178
|
function getComplexityForFile2(filePath) {
|
|
70124
70179
|
try {
|
|
70125
|
-
const stat3 =
|
|
70180
|
+
const stat3 = fs53.statSync(filePath);
|
|
70126
70181
|
if (stat3.size > MAX_FILE_SIZE_BYTES5) {
|
|
70127
70182
|
return null;
|
|
70128
70183
|
}
|
|
70129
|
-
const content =
|
|
70184
|
+
const content = fs53.readFileSync(filePath, "utf-8");
|
|
70130
70185
|
return estimateCyclomaticComplexity(content);
|
|
70131
70186
|
} catch {
|
|
70132
70187
|
return null;
|
|
@@ -70147,7 +70202,7 @@ async function analyzeHotspots(days, topN, extensions, directory) {
|
|
|
70147
70202
|
let analyzedFiles = 0;
|
|
70148
70203
|
for (const [file3, churnCount] of filteredChurn) {
|
|
70149
70204
|
let fullPath = file3;
|
|
70150
|
-
if (!
|
|
70205
|
+
if (!fs53.existsSync(fullPath)) {
|
|
70151
70206
|
fullPath = path66.join(cwd, file3);
|
|
70152
70207
|
}
|
|
70153
70208
|
const complexity = getComplexityForFile2(fullPath);
|
|
@@ -70875,7 +70930,7 @@ init_guardrails();
|
|
|
70875
70930
|
init_state();
|
|
70876
70931
|
init_task_id();
|
|
70877
70932
|
init_create_tool();
|
|
70878
|
-
import * as
|
|
70933
|
+
import * as fs54 from "fs";
|
|
70879
70934
|
import * as path67 from "path";
|
|
70880
70935
|
function validateTaskIdFormat2(taskId) {
|
|
70881
70936
|
return validateTaskIdFormat(taskId);
|
|
@@ -70963,9 +71018,9 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
70963
71018
|
}
|
|
70964
71019
|
const resolvedDir = path67.resolve(normalizedDir);
|
|
70965
71020
|
try {
|
|
70966
|
-
const realPath =
|
|
71021
|
+
const realPath = fs54.realpathSync(resolvedDir);
|
|
70967
71022
|
const planPath2 = path67.join(realPath, ".swarm", "plan.json");
|
|
70968
|
-
if (!
|
|
71023
|
+
if (!fs54.existsSync(planPath2)) {
|
|
70969
71024
|
return {
|
|
70970
71025
|
success: false,
|
|
70971
71026
|
message: `Invalid working_directory: plan not found in "${realPath}"`,
|
|
@@ -70989,7 +71044,7 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
70989
71044
|
}
|
|
70990
71045
|
const directory = normalizedDir || fallbackDir;
|
|
70991
71046
|
const planPath = path67.resolve(directory, ".swarm", "plan.json");
|
|
70992
|
-
if (!
|
|
71047
|
+
if (!fs54.existsSync(planPath)) {
|
|
70993
71048
|
return {
|
|
70994
71049
|
success: false,
|
|
70995
71050
|
message: "No plan found",
|
|
@@ -70998,7 +71053,7 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
70998
71053
|
}
|
|
70999
71054
|
let planContent;
|
|
71000
71055
|
try {
|
|
71001
|
-
planContent = JSON.parse(
|
|
71056
|
+
planContent = JSON.parse(fs54.readFileSync(planPath, "utf-8"));
|
|
71002
71057
|
} catch {
|
|
71003
71058
|
return {
|
|
71004
71059
|
success: false,
|
|
@@ -71786,7 +71841,7 @@ var diff = createSwarmTool({
|
|
|
71786
71841
|
// src/tools/diff-summary.ts
|
|
71787
71842
|
init_dist();
|
|
71788
71843
|
import * as child_process7 from "child_process";
|
|
71789
|
-
import * as
|
|
71844
|
+
import * as fs55 from "fs";
|
|
71790
71845
|
import * as path69 from "path";
|
|
71791
71846
|
init_create_tool();
|
|
71792
71847
|
var MAX_BUFFER_BYTES2 = 5 * 1024 * 1024;
|
|
@@ -71816,7 +71871,7 @@ var diff_summary = createSwarmTool({
|
|
|
71816
71871
|
timeout: 5000,
|
|
71817
71872
|
cwd: workingDir
|
|
71818
71873
|
});
|
|
71819
|
-
const newContent =
|
|
71874
|
+
const newContent = fs55.readFileSync(path69.join(workingDir, filePath), "utf-8");
|
|
71820
71875
|
const astResult = await computeASTDiff(filePath, oldContent, newContent);
|
|
71821
71876
|
if (astResult && astResult.changes.length > 0) {
|
|
71822
71877
|
astDiffs.push(astResult);
|
|
@@ -72030,7 +72085,7 @@ Use these as DOMAIN values when delegating to @sme.`;
|
|
|
72030
72085
|
init_dist();
|
|
72031
72086
|
init_create_tool();
|
|
72032
72087
|
init_path_security();
|
|
72033
|
-
import * as
|
|
72088
|
+
import * as fs56 from "fs";
|
|
72034
72089
|
import * as path70 from "path";
|
|
72035
72090
|
var MAX_FILE_SIZE_BYTES6 = 1024 * 1024;
|
|
72036
72091
|
var MAX_EVIDENCE_FILES = 1000;
|
|
@@ -72076,12 +72131,12 @@ function parseCompletedTasks(planContent) {
|
|
|
72076
72131
|
}
|
|
72077
72132
|
function readEvidenceFiles(evidenceDir, _cwd) {
|
|
72078
72133
|
const evidence = [];
|
|
72079
|
-
if (!
|
|
72134
|
+
if (!fs56.existsSync(evidenceDir) || !fs56.statSync(evidenceDir).isDirectory()) {
|
|
72080
72135
|
return evidence;
|
|
72081
72136
|
}
|
|
72082
72137
|
let files;
|
|
72083
72138
|
try {
|
|
72084
|
-
files =
|
|
72139
|
+
files = fs56.readdirSync(evidenceDir);
|
|
72085
72140
|
} catch {
|
|
72086
72141
|
return evidence;
|
|
72087
72142
|
}
|
|
@@ -72097,7 +72152,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
72097
72152
|
if (!resolvedPath.startsWith(evidenceDirResolved)) {
|
|
72098
72153
|
continue;
|
|
72099
72154
|
}
|
|
72100
|
-
const stat3 =
|
|
72155
|
+
const stat3 = fs56.lstatSync(filePath);
|
|
72101
72156
|
if (!stat3.isFile()) {
|
|
72102
72157
|
continue;
|
|
72103
72158
|
}
|
|
@@ -72106,7 +72161,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
72106
72161
|
}
|
|
72107
72162
|
let fileStat;
|
|
72108
72163
|
try {
|
|
72109
|
-
fileStat =
|
|
72164
|
+
fileStat = fs56.statSync(filePath);
|
|
72110
72165
|
if (fileStat.size > MAX_FILE_SIZE_BYTES6) {
|
|
72111
72166
|
continue;
|
|
72112
72167
|
}
|
|
@@ -72115,7 +72170,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
72115
72170
|
}
|
|
72116
72171
|
let content;
|
|
72117
72172
|
try {
|
|
72118
|
-
content =
|
|
72173
|
+
content = fs56.readFileSync(filePath, "utf-8");
|
|
72119
72174
|
} catch {
|
|
72120
72175
|
continue;
|
|
72121
72176
|
}
|
|
@@ -72225,7 +72280,7 @@ var evidence_check = createSwarmTool({
|
|
|
72225
72280
|
}
|
|
72226
72281
|
let planContent;
|
|
72227
72282
|
try {
|
|
72228
|
-
planContent =
|
|
72283
|
+
planContent = fs56.readFileSync(planPath, "utf-8");
|
|
72229
72284
|
} catch {
|
|
72230
72285
|
const result2 = {
|
|
72231
72286
|
message: "No completed tasks found in plan.",
|
|
@@ -72260,7 +72315,7 @@ var evidence_check = createSwarmTool({
|
|
|
72260
72315
|
// src/tools/file-extractor.ts
|
|
72261
72316
|
init_tool();
|
|
72262
72317
|
init_create_tool();
|
|
72263
|
-
import * as
|
|
72318
|
+
import * as fs57 from "fs";
|
|
72264
72319
|
import * as path71 from "path";
|
|
72265
72320
|
var EXT_MAP = {
|
|
72266
72321
|
python: ".py",
|
|
@@ -72323,8 +72378,8 @@ var extract_code_blocks = createSwarmTool({
|
|
|
72323
72378
|
execute: async (args2, directory) => {
|
|
72324
72379
|
const { content, output_dir, prefix } = args2;
|
|
72325
72380
|
const targetDir = output_dir || directory;
|
|
72326
|
-
if (!
|
|
72327
|
-
|
|
72381
|
+
if (!fs57.existsSync(targetDir)) {
|
|
72382
|
+
fs57.mkdirSync(targetDir, { recursive: true });
|
|
72328
72383
|
}
|
|
72329
72384
|
if (!content) {
|
|
72330
72385
|
return "Error: content is required";
|
|
@@ -72346,12 +72401,12 @@ var extract_code_blocks = createSwarmTool({
|
|
|
72346
72401
|
const base = path71.basename(filepath, path71.extname(filepath));
|
|
72347
72402
|
const ext = path71.extname(filepath);
|
|
72348
72403
|
let counter = 1;
|
|
72349
|
-
while (
|
|
72404
|
+
while (fs57.existsSync(filepath)) {
|
|
72350
72405
|
filepath = path71.join(targetDir, `${base}_${counter}${ext}`);
|
|
72351
72406
|
counter++;
|
|
72352
72407
|
}
|
|
72353
72408
|
try {
|
|
72354
|
-
|
|
72409
|
+
fs57.writeFileSync(filepath, code.trim(), "utf-8");
|
|
72355
72410
|
savedFiles.push(filepath);
|
|
72356
72411
|
} catch (error93) {
|
|
72357
72412
|
errors5.push(`Failed to save ${filename}: ${error93 instanceof Error ? error93.message : String(error93)}`);
|
|
@@ -72609,7 +72664,7 @@ var gitingest = createSwarmTool({
|
|
|
72609
72664
|
init_dist();
|
|
72610
72665
|
init_create_tool();
|
|
72611
72666
|
init_path_security();
|
|
72612
|
-
import * as
|
|
72667
|
+
import * as fs58 from "fs";
|
|
72613
72668
|
import * as path72 from "path";
|
|
72614
72669
|
var MAX_FILE_PATH_LENGTH2 = 500;
|
|
72615
72670
|
var MAX_SYMBOL_LENGTH = 256;
|
|
@@ -72772,7 +72827,7 @@ var SKIP_DIRECTORIES4 = new Set([
|
|
|
72772
72827
|
function findSourceFiles3(dir, files = [], stats = { skippedDirs: [], skippedFiles: 0, fileErrors: [] }) {
|
|
72773
72828
|
let entries;
|
|
72774
72829
|
try {
|
|
72775
|
-
entries =
|
|
72830
|
+
entries = fs58.readdirSync(dir);
|
|
72776
72831
|
} catch (e) {
|
|
72777
72832
|
stats.fileErrors.push({
|
|
72778
72833
|
path: dir,
|
|
@@ -72789,7 +72844,7 @@ function findSourceFiles3(dir, files = [], stats = { skippedDirs: [], skippedFil
|
|
|
72789
72844
|
const fullPath = path72.join(dir, entry);
|
|
72790
72845
|
let stat3;
|
|
72791
72846
|
try {
|
|
72792
|
-
stat3 =
|
|
72847
|
+
stat3 = fs58.statSync(fullPath);
|
|
72793
72848
|
} catch (e) {
|
|
72794
72849
|
stats.fileErrors.push({
|
|
72795
72850
|
path: fullPath,
|
|
@@ -72858,7 +72913,7 @@ var imports = createSwarmTool({
|
|
|
72858
72913
|
}
|
|
72859
72914
|
try {
|
|
72860
72915
|
const targetFile = path72.resolve(file3);
|
|
72861
|
-
if (!
|
|
72916
|
+
if (!fs58.existsSync(targetFile)) {
|
|
72862
72917
|
const errorResult = {
|
|
72863
72918
|
error: `target file not found: ${file3}`,
|
|
72864
72919
|
target: file3,
|
|
@@ -72868,7 +72923,7 @@ var imports = createSwarmTool({
|
|
|
72868
72923
|
};
|
|
72869
72924
|
return JSON.stringify(errorResult, null, 2);
|
|
72870
72925
|
}
|
|
72871
|
-
const targetStat =
|
|
72926
|
+
const targetStat = fs58.statSync(targetFile);
|
|
72872
72927
|
if (!targetStat.isFile()) {
|
|
72873
72928
|
const errorResult = {
|
|
72874
72929
|
error: "target must be a file, not a directory",
|
|
@@ -72894,12 +72949,12 @@ var imports = createSwarmTool({
|
|
|
72894
72949
|
if (consumers.length >= MAX_CONSUMERS)
|
|
72895
72950
|
break;
|
|
72896
72951
|
try {
|
|
72897
|
-
const stat3 =
|
|
72952
|
+
const stat3 = fs58.statSync(filePath);
|
|
72898
72953
|
if (stat3.size > MAX_FILE_SIZE_BYTES7) {
|
|
72899
72954
|
skippedFileCount++;
|
|
72900
72955
|
continue;
|
|
72901
72956
|
}
|
|
72902
|
-
const buffer =
|
|
72957
|
+
const buffer = fs58.readFileSync(filePath);
|
|
72903
72958
|
if (isBinaryFile2(filePath, buffer)) {
|
|
72904
72959
|
skippedFileCount++;
|
|
72905
72960
|
continue;
|
|
@@ -73410,7 +73465,7 @@ init_config();
|
|
|
73410
73465
|
init_schema();
|
|
73411
73466
|
init_manager2();
|
|
73412
73467
|
init_curator();
|
|
73413
|
-
import * as
|
|
73468
|
+
import * as fs59 from "fs";
|
|
73414
73469
|
import * as path73 from "path";
|
|
73415
73470
|
init_knowledge_curator();
|
|
73416
73471
|
init_knowledge_reader();
|
|
@@ -73644,7 +73699,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
73644
73699
|
let driftVerdictFound = false;
|
|
73645
73700
|
let driftVerdictApproved = false;
|
|
73646
73701
|
try {
|
|
73647
|
-
const driftEvidenceContent =
|
|
73702
|
+
const driftEvidenceContent = fs59.readFileSync(driftEvidencePath, "utf-8");
|
|
73648
73703
|
const driftEvidence = JSON.parse(driftEvidenceContent);
|
|
73649
73704
|
const entries = driftEvidence.entries ?? [];
|
|
73650
73705
|
for (const entry of entries) {
|
|
@@ -73675,13 +73730,13 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
73675
73730
|
}
|
|
73676
73731
|
if (!driftVerdictFound) {
|
|
73677
73732
|
const specPath = path73.join(dir, ".swarm", "spec.md");
|
|
73678
|
-
const specExists =
|
|
73733
|
+
const specExists = fs59.existsSync(specPath);
|
|
73679
73734
|
if (!specExists) {
|
|
73680
73735
|
let incompleteTaskCount = 0;
|
|
73681
73736
|
let planPhaseFound = false;
|
|
73682
73737
|
try {
|
|
73683
73738
|
const planPath = validateSwarmPath(dir, "plan.json");
|
|
73684
|
-
const planRaw =
|
|
73739
|
+
const planRaw = fs59.readFileSync(planPath, "utf-8");
|
|
73685
73740
|
const plan = JSON.parse(planRaw);
|
|
73686
73741
|
const targetPhase = plan.phases.find((p) => p.id === phase);
|
|
73687
73742
|
if (targetPhase) {
|
|
@@ -73806,7 +73861,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
73806
73861
|
let phaseRequiredAgents;
|
|
73807
73862
|
try {
|
|
73808
73863
|
const planPath = validateSwarmPath(dir, "plan.json");
|
|
73809
|
-
const planRaw =
|
|
73864
|
+
const planRaw = fs59.readFileSync(planPath, "utf-8");
|
|
73810
73865
|
const plan = JSON.parse(planRaw);
|
|
73811
73866
|
const phaseObj = plan.phases.find((p) => p.id === phase);
|
|
73812
73867
|
phaseRequiredAgents = phaseObj?.required_agents;
|
|
@@ -73821,7 +73876,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
73821
73876
|
if (agentsMissing.length > 0) {
|
|
73822
73877
|
try {
|
|
73823
73878
|
const planPath = validateSwarmPath(dir, "plan.json");
|
|
73824
|
-
const planRaw =
|
|
73879
|
+
const planRaw = fs59.readFileSync(planPath, "utf-8");
|
|
73825
73880
|
const plan = JSON.parse(planRaw);
|
|
73826
73881
|
const targetPhase = plan.phases.find((p) => p.id === phase);
|
|
73827
73882
|
if (targetPhase && targetPhase.tasks.length > 0 && targetPhase.tasks.every((t) => t.status === "completed")) {
|
|
@@ -73861,7 +73916,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
73861
73916
|
if (phaseCompleteConfig.regression_sweep?.enforce) {
|
|
73862
73917
|
try {
|
|
73863
73918
|
const planPath = validateSwarmPath(dir, "plan.json");
|
|
73864
|
-
const planRaw =
|
|
73919
|
+
const planRaw = fs59.readFileSync(planPath, "utf-8");
|
|
73865
73920
|
const plan = JSON.parse(planRaw);
|
|
73866
73921
|
const targetPhase = plan.phases.find((p) => p.id === phase);
|
|
73867
73922
|
if (targetPhase) {
|
|
@@ -73915,7 +73970,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
73915
73970
|
}
|
|
73916
73971
|
try {
|
|
73917
73972
|
const eventsPath = validateSwarmPath(dir, "events.jsonl");
|
|
73918
|
-
|
|
73973
|
+
fs59.appendFileSync(eventsPath, `${JSON.stringify(event)}
|
|
73919
73974
|
`, "utf-8");
|
|
73920
73975
|
} catch (writeError) {
|
|
73921
73976
|
warnings.push(`Warning: failed to write phase complete event: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
|
|
@@ -73968,12 +74023,12 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
73968
74023
|
warnings.push(`Warning: failed to update plan.json phase status`);
|
|
73969
74024
|
try {
|
|
73970
74025
|
const planPath = validateSwarmPath(dir, "plan.json");
|
|
73971
|
-
const planRaw =
|
|
74026
|
+
const planRaw = fs59.readFileSync(planPath, "utf-8");
|
|
73972
74027
|
const plan2 = JSON.parse(planRaw);
|
|
73973
74028
|
const phaseObj = plan2.phases.find((p) => p.id === phase);
|
|
73974
74029
|
if (phaseObj) {
|
|
73975
74030
|
phaseObj.status = "complete";
|
|
73976
|
-
|
|
74031
|
+
fs59.writeFileSync(planPath, JSON.stringify(plan2, null, 2), "utf-8");
|
|
73977
74032
|
}
|
|
73978
74033
|
} catch {}
|
|
73979
74034
|
} else if (plan) {
|
|
@@ -74010,12 +74065,12 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
74010
74065
|
warnings.push(`Warning: failed to update plan.json phase status`);
|
|
74011
74066
|
try {
|
|
74012
74067
|
const planPath = validateSwarmPath(dir, "plan.json");
|
|
74013
|
-
const planRaw =
|
|
74068
|
+
const planRaw = fs59.readFileSync(planPath, "utf-8");
|
|
74014
74069
|
const plan = JSON.parse(planRaw);
|
|
74015
74070
|
const phaseObj = plan.phases.find((p) => p.id === phase);
|
|
74016
74071
|
if (phaseObj) {
|
|
74017
74072
|
phaseObj.status = "complete";
|
|
74018
|
-
|
|
74073
|
+
fs59.writeFileSync(planPath, JSON.stringify(plan, null, 2), "utf-8");
|
|
74019
74074
|
}
|
|
74020
74075
|
} catch {}
|
|
74021
74076
|
}
|
|
@@ -74072,7 +74127,7 @@ init_dist();
|
|
|
74072
74127
|
init_discovery();
|
|
74073
74128
|
init_utils();
|
|
74074
74129
|
init_create_tool();
|
|
74075
|
-
import * as
|
|
74130
|
+
import * as fs60 from "fs";
|
|
74076
74131
|
import * as path74 from "path";
|
|
74077
74132
|
var MAX_OUTPUT_BYTES5 = 52428800;
|
|
74078
74133
|
var AUDIT_TIMEOUT_MS = 120000;
|
|
@@ -74101,31 +74156,31 @@ function validateArgs3(args2) {
|
|
|
74101
74156
|
function detectEcosystems(directory) {
|
|
74102
74157
|
const ecosystems = [];
|
|
74103
74158
|
const cwd = directory;
|
|
74104
|
-
if (
|
|
74159
|
+
if (fs60.existsSync(path74.join(cwd, "package.json"))) {
|
|
74105
74160
|
ecosystems.push("npm");
|
|
74106
74161
|
}
|
|
74107
|
-
if (
|
|
74162
|
+
if (fs60.existsSync(path74.join(cwd, "pyproject.toml")) || fs60.existsSync(path74.join(cwd, "requirements.txt"))) {
|
|
74108
74163
|
ecosystems.push("pip");
|
|
74109
74164
|
}
|
|
74110
|
-
if (
|
|
74165
|
+
if (fs60.existsSync(path74.join(cwd, "Cargo.toml"))) {
|
|
74111
74166
|
ecosystems.push("cargo");
|
|
74112
74167
|
}
|
|
74113
|
-
if (
|
|
74168
|
+
if (fs60.existsSync(path74.join(cwd, "go.mod"))) {
|
|
74114
74169
|
ecosystems.push("go");
|
|
74115
74170
|
}
|
|
74116
74171
|
try {
|
|
74117
|
-
const files =
|
|
74172
|
+
const files = fs60.readdirSync(cwd);
|
|
74118
74173
|
if (files.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"))) {
|
|
74119
74174
|
ecosystems.push("dotnet");
|
|
74120
74175
|
}
|
|
74121
74176
|
} catch {}
|
|
74122
|
-
if (
|
|
74177
|
+
if (fs60.existsSync(path74.join(cwd, "Gemfile")) || fs60.existsSync(path74.join(cwd, "Gemfile.lock"))) {
|
|
74123
74178
|
ecosystems.push("ruby");
|
|
74124
74179
|
}
|
|
74125
|
-
if (
|
|
74180
|
+
if (fs60.existsSync(path74.join(cwd, "pubspec.yaml"))) {
|
|
74126
74181
|
ecosystems.push("dart");
|
|
74127
74182
|
}
|
|
74128
|
-
if (
|
|
74183
|
+
if (fs60.existsSync(path74.join(cwd, "composer.lock"))) {
|
|
74129
74184
|
ecosystems.push("composer");
|
|
74130
74185
|
}
|
|
74131
74186
|
return ecosystems;
|
|
@@ -75284,7 +75339,7 @@ var pkg_audit = createSwarmTool({
|
|
|
75284
75339
|
// src/tools/placeholder-scan.ts
|
|
75285
75340
|
init_dist();
|
|
75286
75341
|
init_manager2();
|
|
75287
|
-
import * as
|
|
75342
|
+
import * as fs61 from "fs";
|
|
75288
75343
|
import * as path75 from "path";
|
|
75289
75344
|
init_utils();
|
|
75290
75345
|
init_create_tool();
|
|
@@ -75686,7 +75741,7 @@ async function placeholderScan(input, directory) {
|
|
|
75686
75741
|
if (!fullPath.startsWith(resolvedDirectory + path75.sep) && fullPath !== resolvedDirectory) {
|
|
75687
75742
|
continue;
|
|
75688
75743
|
}
|
|
75689
|
-
if (!
|
|
75744
|
+
if (!fs61.existsSync(fullPath)) {
|
|
75690
75745
|
continue;
|
|
75691
75746
|
}
|
|
75692
75747
|
if (isAllowedByGlobs(filePath, allow_globs)) {
|
|
@@ -75698,11 +75753,11 @@ async function placeholderScan(input, directory) {
|
|
|
75698
75753
|
}
|
|
75699
75754
|
let content;
|
|
75700
75755
|
try {
|
|
75701
|
-
const stat3 =
|
|
75756
|
+
const stat3 = fs61.statSync(fullPath);
|
|
75702
75757
|
if (stat3.size > MAX_FILE_SIZE) {
|
|
75703
75758
|
continue;
|
|
75704
75759
|
}
|
|
75705
|
-
content =
|
|
75760
|
+
content = fs61.readFileSync(fullPath, "utf-8");
|
|
75706
75761
|
} catch {
|
|
75707
75762
|
continue;
|
|
75708
75763
|
}
|
|
@@ -75764,7 +75819,7 @@ var placeholder_scan = createSwarmTool({
|
|
|
75764
75819
|
});
|
|
75765
75820
|
// src/tools/pre-check-batch.ts
|
|
75766
75821
|
init_dist();
|
|
75767
|
-
import * as
|
|
75822
|
+
import * as fs63 from "fs";
|
|
75768
75823
|
import * as path77 from "path";
|
|
75769
75824
|
init_manager2();
|
|
75770
75825
|
init_utils();
|
|
@@ -75900,7 +75955,7 @@ var quality_budget = createSwarmTool({
|
|
|
75900
75955
|
init_dist();
|
|
75901
75956
|
init_manager2();
|
|
75902
75957
|
init_detector();
|
|
75903
|
-
import * as
|
|
75958
|
+
import * as fs62 from "fs";
|
|
75904
75959
|
import * as path76 from "path";
|
|
75905
75960
|
import { extname as extname18 } from "path";
|
|
75906
75961
|
|
|
@@ -76801,17 +76856,17 @@ var SEVERITY_ORDER = {
|
|
|
76801
76856
|
};
|
|
76802
76857
|
function shouldSkipFile(filePath) {
|
|
76803
76858
|
try {
|
|
76804
|
-
const stats =
|
|
76859
|
+
const stats = fs62.statSync(filePath);
|
|
76805
76860
|
if (stats.size > MAX_FILE_SIZE_BYTES8) {
|
|
76806
76861
|
return { skip: true, reason: "file too large" };
|
|
76807
76862
|
}
|
|
76808
76863
|
if (stats.size === 0) {
|
|
76809
76864
|
return { skip: true, reason: "empty file" };
|
|
76810
76865
|
}
|
|
76811
|
-
const fd =
|
|
76866
|
+
const fd = fs62.openSync(filePath, "r");
|
|
76812
76867
|
const buffer = Buffer.alloc(8192);
|
|
76813
|
-
const bytesRead =
|
|
76814
|
-
|
|
76868
|
+
const bytesRead = fs62.readSync(fd, buffer, 0, 8192, 0);
|
|
76869
|
+
fs62.closeSync(fd);
|
|
76815
76870
|
if (bytesRead > 0) {
|
|
76816
76871
|
let nullCount = 0;
|
|
76817
76872
|
for (let i2 = 0;i2 < bytesRead; i2++) {
|
|
@@ -76850,7 +76905,7 @@ function countBySeverity(findings) {
|
|
|
76850
76905
|
}
|
|
76851
76906
|
function scanFileWithTierA(filePath, language) {
|
|
76852
76907
|
try {
|
|
76853
|
-
const content =
|
|
76908
|
+
const content = fs62.readFileSync(filePath, "utf-8");
|
|
76854
76909
|
const findings = executeRulesSync(filePath, content, language);
|
|
76855
76910
|
return findings.map((f) => ({
|
|
76856
76911
|
rule_id: f.rule_id,
|
|
@@ -76903,7 +76958,7 @@ async function sastScan(input, directory, config3) {
|
|
|
76903
76958
|
_filesSkipped++;
|
|
76904
76959
|
continue;
|
|
76905
76960
|
}
|
|
76906
|
-
if (!
|
|
76961
|
+
if (!fs62.existsSync(resolvedPath)) {
|
|
76907
76962
|
_filesSkipped++;
|
|
76908
76963
|
continue;
|
|
76909
76964
|
}
|
|
@@ -77359,7 +77414,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
77359
77414
|
}
|
|
77360
77415
|
let stat3;
|
|
77361
77416
|
try {
|
|
77362
|
-
stat3 =
|
|
77417
|
+
stat3 = fs63.statSync(file3);
|
|
77363
77418
|
} catch {
|
|
77364
77419
|
skippedFiles++;
|
|
77365
77420
|
continue;
|
|
@@ -77370,7 +77425,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
77370
77425
|
}
|
|
77371
77426
|
let content;
|
|
77372
77427
|
try {
|
|
77373
|
-
const buffer =
|
|
77428
|
+
const buffer = fs63.readFileSync(file3);
|
|
77374
77429
|
if (buffer.includes(0)) {
|
|
77375
77430
|
skippedFiles++;
|
|
77376
77431
|
continue;
|
|
@@ -78028,7 +78083,7 @@ var repo_map = createSwarmTool({
|
|
|
78028
78083
|
// src/tools/req-coverage.ts
|
|
78029
78084
|
init_dist();
|
|
78030
78085
|
init_create_tool();
|
|
78031
|
-
import * as
|
|
78086
|
+
import * as fs64 from "fs";
|
|
78032
78087
|
import * as path79 from "path";
|
|
78033
78088
|
var SPEC_FILE = ".swarm/spec.md";
|
|
78034
78089
|
var EVIDENCE_DIR4 = ".swarm/evidence";
|
|
@@ -78088,19 +78143,19 @@ function extractObligationAndText(id, lineText) {
|
|
|
78088
78143
|
var PHASE_TASK_ID_REGEX = /^\d+\.\d+(\.\d+)*$/;
|
|
78089
78144
|
function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
78090
78145
|
const touchedFiles = new Set;
|
|
78091
|
-
if (!
|
|
78146
|
+
if (!fs64.existsSync(evidenceDir) || !fs64.statSync(evidenceDir).isDirectory()) {
|
|
78092
78147
|
return [];
|
|
78093
78148
|
}
|
|
78094
78149
|
let entries;
|
|
78095
78150
|
try {
|
|
78096
|
-
entries =
|
|
78151
|
+
entries = fs64.readdirSync(evidenceDir);
|
|
78097
78152
|
} catch {
|
|
78098
78153
|
return [];
|
|
78099
78154
|
}
|
|
78100
78155
|
for (const entry of entries) {
|
|
78101
78156
|
const entryPath = path79.join(evidenceDir, entry);
|
|
78102
78157
|
try {
|
|
78103
|
-
const stat3 =
|
|
78158
|
+
const stat3 = fs64.statSync(entryPath);
|
|
78104
78159
|
if (!stat3.isDirectory()) {
|
|
78105
78160
|
continue;
|
|
78106
78161
|
}
|
|
@@ -78121,7 +78176,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
78121
78176
|
if (!resolvedPath.startsWith(evidenceDirResolved + path79.sep)) {
|
|
78122
78177
|
continue;
|
|
78123
78178
|
}
|
|
78124
|
-
const stat3 =
|
|
78179
|
+
const stat3 = fs64.lstatSync(evidenceFilePath);
|
|
78125
78180
|
if (!stat3.isFile()) {
|
|
78126
78181
|
continue;
|
|
78127
78182
|
}
|
|
@@ -78133,7 +78188,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
78133
78188
|
}
|
|
78134
78189
|
let content;
|
|
78135
78190
|
try {
|
|
78136
|
-
content =
|
|
78191
|
+
content = fs64.readFileSync(evidenceFilePath, "utf-8");
|
|
78137
78192
|
} catch {
|
|
78138
78193
|
continue;
|
|
78139
78194
|
}
|
|
@@ -78170,7 +78225,7 @@ function searchFileForKeywords(filePath, keywords, cwd) {
|
|
|
78170
78225
|
if (!resolvedPath.startsWith(cwdResolved)) {
|
|
78171
78226
|
return false;
|
|
78172
78227
|
}
|
|
78173
|
-
const content =
|
|
78228
|
+
const content = fs64.readFileSync(resolvedPath, "utf-8");
|
|
78174
78229
|
for (const keyword of keywords) {
|
|
78175
78230
|
const regex = new RegExp(`\\b${keyword}\\b`, "i");
|
|
78176
78231
|
if (regex.test(content)) {
|
|
@@ -78303,7 +78358,7 @@ var req_coverage = createSwarmTool({
|
|
|
78303
78358
|
const specPath = path79.join(cwd, SPEC_FILE);
|
|
78304
78359
|
let specContent;
|
|
78305
78360
|
try {
|
|
78306
|
-
specContent =
|
|
78361
|
+
specContent = fs64.readFileSync(specPath, "utf-8");
|
|
78307
78362
|
} catch (readError) {
|
|
78308
78363
|
return JSON.stringify({
|
|
78309
78364
|
success: false,
|
|
@@ -78355,10 +78410,10 @@ var req_coverage = createSwarmTool({
|
|
|
78355
78410
|
const reportFilename = `req-coverage-phase-${phase}.json`;
|
|
78356
78411
|
const reportPath = path79.join(evidenceDir, reportFilename);
|
|
78357
78412
|
try {
|
|
78358
|
-
if (!
|
|
78359
|
-
|
|
78413
|
+
if (!fs64.existsSync(evidenceDir)) {
|
|
78414
|
+
fs64.mkdirSync(evidenceDir, { recursive: true });
|
|
78360
78415
|
}
|
|
78361
|
-
|
|
78416
|
+
fs64.writeFileSync(reportPath, JSON.stringify(result, null, 2), "utf-8");
|
|
78362
78417
|
} catch (writeError) {
|
|
78363
78418
|
console.warn(`Failed to write coverage report: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
|
|
78364
78419
|
}
|
|
@@ -78437,7 +78492,7 @@ ${paginatedContent}`;
|
|
|
78437
78492
|
// src/tools/save-plan.ts
|
|
78438
78493
|
init_tool();
|
|
78439
78494
|
import * as crypto8 from "crypto";
|
|
78440
|
-
import * as
|
|
78495
|
+
import * as fs65 from "fs";
|
|
78441
78496
|
import * as path80 from "path";
|
|
78442
78497
|
init_checkpoint3();
|
|
78443
78498
|
init_ledger();
|
|
@@ -78521,9 +78576,9 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
78521
78576
|
if (process.env.SWARM_SKIP_SPEC_GATE !== "1") {
|
|
78522
78577
|
const specPath = path80.join(targetWorkspace, ".swarm", "spec.md");
|
|
78523
78578
|
try {
|
|
78524
|
-
const stat3 = await
|
|
78579
|
+
const stat3 = await fs65.promises.stat(specPath);
|
|
78525
78580
|
specMtime = stat3.mtime.toISOString();
|
|
78526
|
-
const content = await
|
|
78581
|
+
const content = await fs65.promises.readFile(specPath, "utf8");
|
|
78527
78582
|
specHash = crypto8.createHash("sha256").update(content).digest("hex");
|
|
78528
78583
|
} catch {
|
|
78529
78584
|
return {
|
|
@@ -78604,7 +78659,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
78604
78659
|
phases_count: plan.phases.length,
|
|
78605
78660
|
tasks_count: tasksCount
|
|
78606
78661
|
});
|
|
78607
|
-
await
|
|
78662
|
+
await fs65.promises.writeFile(markerPath, marker, "utf8");
|
|
78608
78663
|
} catch {}
|
|
78609
78664
|
const warnings = [];
|
|
78610
78665
|
let criticReviewFound = false;
|
|
@@ -78664,7 +78719,7 @@ var save_plan = createSwarmTool({
|
|
|
78664
78719
|
// src/tools/sbom-generate.ts
|
|
78665
78720
|
init_dist();
|
|
78666
78721
|
init_manager2();
|
|
78667
|
-
import * as
|
|
78722
|
+
import * as fs66 from "fs";
|
|
78668
78723
|
import * as path81 from "path";
|
|
78669
78724
|
|
|
78670
78725
|
// src/sbom/detectors/index.ts
|
|
@@ -79513,7 +79568,7 @@ function findManifestFiles(rootDir) {
|
|
|
79513
79568
|
const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
|
|
79514
79569
|
function searchDir(dir) {
|
|
79515
79570
|
try {
|
|
79516
|
-
const entries =
|
|
79571
|
+
const entries = fs66.readdirSync(dir, { withFileTypes: true });
|
|
79517
79572
|
for (const entry of entries) {
|
|
79518
79573
|
const fullPath = path81.join(dir, entry.name);
|
|
79519
79574
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
|
|
@@ -79540,7 +79595,7 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
79540
79595
|
const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
|
|
79541
79596
|
for (const dir of directories) {
|
|
79542
79597
|
try {
|
|
79543
|
-
const entries =
|
|
79598
|
+
const entries = fs66.readdirSync(dir, { withFileTypes: true });
|
|
79544
79599
|
for (const entry of entries) {
|
|
79545
79600
|
const fullPath = path81.join(dir, entry.name);
|
|
79546
79601
|
if (entry.isFile()) {
|
|
@@ -79577,7 +79632,7 @@ function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
|
|
|
79577
79632
|
}
|
|
79578
79633
|
function ensureOutputDir(outputDir) {
|
|
79579
79634
|
try {
|
|
79580
|
-
|
|
79635
|
+
fs66.mkdirSync(outputDir, { recursive: true });
|
|
79581
79636
|
} catch (error93) {
|
|
79582
79637
|
if (!error93 || error93.code !== "EEXIST") {
|
|
79583
79638
|
throw error93;
|
|
@@ -79671,10 +79726,10 @@ var sbom_generate = createSwarmTool({
|
|
|
79671
79726
|
for (const manifestFile of manifestFiles) {
|
|
79672
79727
|
try {
|
|
79673
79728
|
const fullPath = path81.isAbsolute(manifestFile) ? manifestFile : path81.join(workingDir, manifestFile);
|
|
79674
|
-
if (!
|
|
79729
|
+
if (!fs66.existsSync(fullPath)) {
|
|
79675
79730
|
continue;
|
|
79676
79731
|
}
|
|
79677
|
-
const content =
|
|
79732
|
+
const content = fs66.readFileSync(fullPath, "utf-8");
|
|
79678
79733
|
const components = detectComponents(manifestFile, content);
|
|
79679
79734
|
processedFiles.push(manifestFile);
|
|
79680
79735
|
if (components.length > 0) {
|
|
@@ -79688,7 +79743,7 @@ var sbom_generate = createSwarmTool({
|
|
|
79688
79743
|
const bomJson = serializeCycloneDX(bom);
|
|
79689
79744
|
const filename = generateSbomFilename();
|
|
79690
79745
|
const outputPath = path81.join(outputDir, filename);
|
|
79691
|
-
|
|
79746
|
+
fs66.writeFileSync(outputPath, bomJson, "utf-8");
|
|
79692
79747
|
const verdict = processedFiles.length > 0 ? "pass" : "pass";
|
|
79693
79748
|
try {
|
|
79694
79749
|
const timestamp = new Date().toISOString();
|
|
@@ -79730,7 +79785,7 @@ var sbom_generate = createSwarmTool({
|
|
|
79730
79785
|
// src/tools/schema-drift.ts
|
|
79731
79786
|
init_dist();
|
|
79732
79787
|
init_create_tool();
|
|
79733
|
-
import * as
|
|
79788
|
+
import * as fs67 from "fs";
|
|
79734
79789
|
import * as path82 from "path";
|
|
79735
79790
|
var SPEC_CANDIDATES = [
|
|
79736
79791
|
"openapi.json",
|
|
@@ -79772,19 +79827,19 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
79772
79827
|
if (!ALLOWED_EXTENSIONS.includes(ext)) {
|
|
79773
79828
|
throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
|
|
79774
79829
|
}
|
|
79775
|
-
const stats =
|
|
79830
|
+
const stats = fs67.statSync(resolvedPath);
|
|
79776
79831
|
if (stats.size > MAX_SPEC_SIZE) {
|
|
79777
79832
|
throw new Error(`Invalid spec_file: file exceeds ${MAX_SPEC_SIZE / 1024 / 1024}MB limit`);
|
|
79778
79833
|
}
|
|
79779
|
-
if (!
|
|
79834
|
+
if (!fs67.existsSync(resolvedPath)) {
|
|
79780
79835
|
throw new Error(`Spec file not found: ${resolvedPath}`);
|
|
79781
79836
|
}
|
|
79782
79837
|
return resolvedPath;
|
|
79783
79838
|
}
|
|
79784
79839
|
for (const candidate of SPEC_CANDIDATES) {
|
|
79785
79840
|
const candidatePath = path82.resolve(cwd, candidate);
|
|
79786
|
-
if (
|
|
79787
|
-
const stats =
|
|
79841
|
+
if (fs67.existsSync(candidatePath)) {
|
|
79842
|
+
const stats = fs67.statSync(candidatePath);
|
|
79788
79843
|
if (stats.size <= MAX_SPEC_SIZE) {
|
|
79789
79844
|
return candidatePath;
|
|
79790
79845
|
}
|
|
@@ -79793,7 +79848,7 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
79793
79848
|
return null;
|
|
79794
79849
|
}
|
|
79795
79850
|
function parseSpec(specFile) {
|
|
79796
|
-
const content =
|
|
79851
|
+
const content = fs67.readFileSync(specFile, "utf-8");
|
|
79797
79852
|
const ext = path82.extname(specFile).toLowerCase();
|
|
79798
79853
|
if (ext === ".json") {
|
|
79799
79854
|
return parseJsonSpec(content);
|
|
@@ -79865,7 +79920,7 @@ function extractRoutes(cwd) {
|
|
|
79865
79920
|
function walkDir(dir) {
|
|
79866
79921
|
let entries;
|
|
79867
79922
|
try {
|
|
79868
|
-
entries =
|
|
79923
|
+
entries = fs67.readdirSync(dir, { withFileTypes: true });
|
|
79869
79924
|
} catch {
|
|
79870
79925
|
return;
|
|
79871
79926
|
}
|
|
@@ -79898,7 +79953,7 @@ function extractRoutes(cwd) {
|
|
|
79898
79953
|
}
|
|
79899
79954
|
function extractRoutesFromFile(filePath) {
|
|
79900
79955
|
const routes = [];
|
|
79901
|
-
const content =
|
|
79956
|
+
const content = fs67.readFileSync(filePath, "utf-8");
|
|
79902
79957
|
const lines = content.split(/\r?\n/);
|
|
79903
79958
|
const expressRegex = /(?:app|router|server|express)\.(get|post|put|patch|delete|options|head)\s*\(\s*['"`]([^'"`]+)['"`]/g;
|
|
79904
79959
|
const flaskRegex = /@(?:app|blueprint|bp)\.route\s*\(\s*['"]([^'"]+)['"]/g;
|
|
@@ -80046,7 +80101,7 @@ var schema_drift = createSwarmTool({
|
|
|
80046
80101
|
init_tool();
|
|
80047
80102
|
init_path_security();
|
|
80048
80103
|
init_create_tool();
|
|
80049
|
-
import * as
|
|
80104
|
+
import * as fs68 from "fs";
|
|
80050
80105
|
import * as path83 from "path";
|
|
80051
80106
|
var DEFAULT_MAX_RESULTS = 100;
|
|
80052
80107
|
var DEFAULT_MAX_LINES = 200;
|
|
@@ -80084,8 +80139,8 @@ function containsWindowsAttacks3(str) {
|
|
|
80084
80139
|
function isPathInWorkspace3(filePath, workspace) {
|
|
80085
80140
|
try {
|
|
80086
80141
|
const resolvedPath = path83.resolve(workspace, filePath);
|
|
80087
|
-
const realWorkspace =
|
|
80088
|
-
const realResolvedPath =
|
|
80142
|
+
const realWorkspace = fs68.realpathSync(workspace);
|
|
80143
|
+
const realResolvedPath = fs68.realpathSync(resolvedPath);
|
|
80089
80144
|
const relativePath = path83.relative(realWorkspace, realResolvedPath);
|
|
80090
80145
|
if (relativePath.startsWith("..") || path83.isAbsolute(relativePath)) {
|
|
80091
80146
|
return false;
|
|
@@ -80105,7 +80160,7 @@ function findRgInEnvPath() {
|
|
|
80105
80160
|
continue;
|
|
80106
80161
|
const isWindows = process.platform === "win32";
|
|
80107
80162
|
const candidate = path83.join(dir, isWindows ? "rg.exe" : "rg");
|
|
80108
|
-
if (
|
|
80163
|
+
if (fs68.existsSync(candidate))
|
|
80109
80164
|
return candidate;
|
|
80110
80165
|
}
|
|
80111
80166
|
return null;
|
|
@@ -80232,7 +80287,7 @@ function collectFiles(dir, workspace, includeGlobs, excludeGlobs) {
|
|
|
80232
80287
|
return files;
|
|
80233
80288
|
}
|
|
80234
80289
|
try {
|
|
80235
|
-
const entries =
|
|
80290
|
+
const entries = fs68.readdirSync(dir, { withFileTypes: true });
|
|
80236
80291
|
for (const entry of entries) {
|
|
80237
80292
|
const fullPath = path83.join(dir, entry.name);
|
|
80238
80293
|
const relativePath = path83.relative(workspace, fullPath);
|
|
@@ -80282,7 +80337,7 @@ async function fallbackSearch(opts) {
|
|
|
80282
80337
|
}
|
|
80283
80338
|
let stats;
|
|
80284
80339
|
try {
|
|
80285
|
-
stats =
|
|
80340
|
+
stats = fs68.statSync(fullPath);
|
|
80286
80341
|
if (stats.size > MAX_FILE_SIZE_BYTES10) {
|
|
80287
80342
|
continue;
|
|
80288
80343
|
}
|
|
@@ -80291,7 +80346,7 @@ async function fallbackSearch(opts) {
|
|
|
80291
80346
|
}
|
|
80292
80347
|
let content;
|
|
80293
80348
|
try {
|
|
80294
|
-
content =
|
|
80349
|
+
content = fs68.readFileSync(fullPath, "utf-8");
|
|
80295
80350
|
} catch {
|
|
80296
80351
|
continue;
|
|
80297
80352
|
}
|
|
@@ -80403,7 +80458,7 @@ var search = createSwarmTool({
|
|
|
80403
80458
|
message: "Exclude pattern contains invalid Windows-specific sequence"
|
|
80404
80459
|
}, null, 2);
|
|
80405
80460
|
}
|
|
80406
|
-
if (!
|
|
80461
|
+
if (!fs68.existsSync(directory)) {
|
|
80407
80462
|
return JSON.stringify({
|
|
80408
80463
|
error: true,
|
|
80409
80464
|
type: "unknown",
|
|
@@ -80526,7 +80581,7 @@ var set_qa_gates = createSwarmTool({
|
|
|
80526
80581
|
init_tool();
|
|
80527
80582
|
init_path_security();
|
|
80528
80583
|
init_create_tool();
|
|
80529
|
-
import * as
|
|
80584
|
+
import * as fs69 from "fs";
|
|
80530
80585
|
import * as path84 from "path";
|
|
80531
80586
|
var WINDOWS_RESERVED_NAMES4 = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
80532
80587
|
function containsWindowsAttacks4(str) {
|
|
@@ -80542,11 +80597,11 @@ function containsWindowsAttacks4(str) {
|
|
|
80542
80597
|
function isPathInWorkspace4(filePath, workspace) {
|
|
80543
80598
|
try {
|
|
80544
80599
|
const resolvedPath = path84.resolve(workspace, filePath);
|
|
80545
|
-
if (!
|
|
80600
|
+
if (!fs69.existsSync(resolvedPath)) {
|
|
80546
80601
|
return true;
|
|
80547
80602
|
}
|
|
80548
|
-
const realWorkspace =
|
|
80549
|
-
const realResolvedPath =
|
|
80603
|
+
const realWorkspace = fs69.realpathSync(workspace);
|
|
80604
|
+
const realResolvedPath = fs69.realpathSync(resolvedPath);
|
|
80550
80605
|
const relativePath = path84.relative(realWorkspace, realResolvedPath);
|
|
80551
80606
|
if (relativePath.startsWith("..") || path84.isAbsolute(relativePath)) {
|
|
80552
80607
|
return false;
|
|
@@ -80720,7 +80775,7 @@ var suggestPatch = createSwarmTool({
|
|
|
80720
80775
|
message: "changes cannot be empty"
|
|
80721
80776
|
}, null, 2);
|
|
80722
80777
|
}
|
|
80723
|
-
if (!
|
|
80778
|
+
if (!fs69.existsSync(directory)) {
|
|
80724
80779
|
return JSON.stringify({
|
|
80725
80780
|
success: false,
|
|
80726
80781
|
error: true,
|
|
@@ -80757,7 +80812,7 @@ var suggestPatch = createSwarmTool({
|
|
|
80757
80812
|
continue;
|
|
80758
80813
|
}
|
|
80759
80814
|
const fullPath = path84.resolve(directory, change.file);
|
|
80760
|
-
if (!
|
|
80815
|
+
if (!fs69.existsSync(fullPath)) {
|
|
80761
80816
|
errors5.push({
|
|
80762
80817
|
success: false,
|
|
80763
80818
|
error: true,
|
|
@@ -80771,7 +80826,7 @@ var suggestPatch = createSwarmTool({
|
|
|
80771
80826
|
}
|
|
80772
80827
|
let content;
|
|
80773
80828
|
try {
|
|
80774
|
-
content =
|
|
80829
|
+
content = fs69.readFileSync(fullPath, "utf-8");
|
|
80775
80830
|
} catch (err3) {
|
|
80776
80831
|
errors5.push({
|
|
80777
80832
|
success: false,
|
|
@@ -80850,7 +80905,7 @@ var suggestPatch = createSwarmTool({
|
|
|
80850
80905
|
// src/tools/lint-spec.ts
|
|
80851
80906
|
init_spec_schema();
|
|
80852
80907
|
init_create_tool();
|
|
80853
|
-
import * as
|
|
80908
|
+
import * as fs70 from "fs";
|
|
80854
80909
|
import * as path85 from "path";
|
|
80855
80910
|
var SPEC_FILE_NAME = "spec.md";
|
|
80856
80911
|
var SWARM_DIR2 = ".swarm";
|
|
@@ -80905,7 +80960,7 @@ var lint_spec = createSwarmTool({
|
|
|
80905
80960
|
const errors5 = [];
|
|
80906
80961
|
const warnings = [];
|
|
80907
80962
|
const specPath = path85.join(directory, SWARM_DIR2, SPEC_FILE_NAME);
|
|
80908
|
-
if (!
|
|
80963
|
+
if (!fs70.existsSync(specPath)) {
|
|
80909
80964
|
const result2 = {
|
|
80910
80965
|
valid: false,
|
|
80911
80966
|
specMtime: null,
|
|
@@ -80924,12 +80979,12 @@ var lint_spec = createSwarmTool({
|
|
|
80924
80979
|
}
|
|
80925
80980
|
let specMtime = null;
|
|
80926
80981
|
try {
|
|
80927
|
-
const stats =
|
|
80982
|
+
const stats = fs70.statSync(specPath);
|
|
80928
80983
|
specMtime = stats.mtime.toISOString();
|
|
80929
80984
|
} catch {}
|
|
80930
80985
|
let content;
|
|
80931
80986
|
try {
|
|
80932
|
-
content =
|
|
80987
|
+
content = fs70.readFileSync(specPath, "utf-8");
|
|
80933
80988
|
} catch (e) {
|
|
80934
80989
|
const result2 = {
|
|
80935
80990
|
valid: false,
|
|
@@ -80974,7 +81029,7 @@ var lint_spec = createSwarmTool({
|
|
|
80974
81029
|
});
|
|
80975
81030
|
// src/tools/mutation-test.ts
|
|
80976
81031
|
init_dist();
|
|
80977
|
-
import * as
|
|
81032
|
+
import * as fs71 from "fs";
|
|
80978
81033
|
import * as path87 from "path";
|
|
80979
81034
|
|
|
80980
81035
|
// src/mutation/engine.ts
|
|
@@ -81510,7 +81565,7 @@ var mutation_test = createSwarmTool({
|
|
|
81510
81565
|
for (const filePath of uniquePaths) {
|
|
81511
81566
|
try {
|
|
81512
81567
|
const resolvedPath = path87.resolve(cwd, filePath);
|
|
81513
|
-
sourceFiles.set(filePath,
|
|
81568
|
+
sourceFiles.set(filePath, fs71.readFileSync(resolvedPath, "utf-8"));
|
|
81514
81569
|
} catch {}
|
|
81515
81570
|
}
|
|
81516
81571
|
const report = await executeMutationSuite(typedArgs.patches, typedArgs.test_command, typedArgs.files, cwd, undefined, undefined, sourceFiles.size > 0 ? sourceFiles : undefined);
|
|
@@ -81528,7 +81583,7 @@ var mutation_test = createSwarmTool({
|
|
|
81528
81583
|
init_dist();
|
|
81529
81584
|
init_manager2();
|
|
81530
81585
|
init_detector();
|
|
81531
|
-
import * as
|
|
81586
|
+
import * as fs72 from "fs";
|
|
81532
81587
|
import * as path88 from "path";
|
|
81533
81588
|
init_create_tool();
|
|
81534
81589
|
var MAX_FILE_SIZE2 = 2 * 1024 * 1024;
|
|
@@ -81638,7 +81693,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
81638
81693
|
}
|
|
81639
81694
|
let content;
|
|
81640
81695
|
try {
|
|
81641
|
-
content =
|
|
81696
|
+
content = fs72.readFileSync(fullPath, "utf8");
|
|
81642
81697
|
} catch {
|
|
81643
81698
|
result.skipped_reason = "file_read_error";
|
|
81644
81699
|
skippedCount++;
|
|
@@ -81749,7 +81804,7 @@ init_dist();
|
|
|
81749
81804
|
init_utils();
|
|
81750
81805
|
init_create_tool();
|
|
81751
81806
|
init_path_security();
|
|
81752
|
-
import * as
|
|
81807
|
+
import * as fs73 from "fs";
|
|
81753
81808
|
import * as path89 from "path";
|
|
81754
81809
|
var MAX_TEXT_LENGTH = 200;
|
|
81755
81810
|
var MAX_FILE_SIZE_BYTES11 = 1024 * 1024;
|
|
@@ -81840,7 +81895,7 @@ function isSupportedExtension(filePath) {
|
|
|
81840
81895
|
function findSourceFiles4(dir, files = []) {
|
|
81841
81896
|
let entries;
|
|
81842
81897
|
try {
|
|
81843
|
-
entries =
|
|
81898
|
+
entries = fs73.readdirSync(dir);
|
|
81844
81899
|
} catch {
|
|
81845
81900
|
return files;
|
|
81846
81901
|
}
|
|
@@ -81852,7 +81907,7 @@ function findSourceFiles4(dir, files = []) {
|
|
|
81852
81907
|
const fullPath = path89.join(dir, entry);
|
|
81853
81908
|
let stat3;
|
|
81854
81909
|
try {
|
|
81855
|
-
stat3 =
|
|
81910
|
+
stat3 = fs73.statSync(fullPath);
|
|
81856
81911
|
} catch {
|
|
81857
81912
|
continue;
|
|
81858
81913
|
}
|
|
@@ -81945,7 +82000,7 @@ var todo_extract = createSwarmTool({
|
|
|
81945
82000
|
return JSON.stringify(errorResult, null, 2);
|
|
81946
82001
|
}
|
|
81947
82002
|
const scanPath = resolvedPath;
|
|
81948
|
-
if (!
|
|
82003
|
+
if (!fs73.existsSync(scanPath)) {
|
|
81949
82004
|
const errorResult = {
|
|
81950
82005
|
error: `path not found: ${pathsInput}`,
|
|
81951
82006
|
total: 0,
|
|
@@ -81955,7 +82010,7 @@ var todo_extract = createSwarmTool({
|
|
|
81955
82010
|
return JSON.stringify(errorResult, null, 2);
|
|
81956
82011
|
}
|
|
81957
82012
|
const filesToScan = [];
|
|
81958
|
-
const stat3 =
|
|
82013
|
+
const stat3 = fs73.statSync(scanPath);
|
|
81959
82014
|
if (stat3.isFile()) {
|
|
81960
82015
|
if (isSupportedExtension(scanPath)) {
|
|
81961
82016
|
filesToScan.push(scanPath);
|
|
@@ -81974,11 +82029,11 @@ var todo_extract = createSwarmTool({
|
|
|
81974
82029
|
const allEntries = [];
|
|
81975
82030
|
for (const filePath of filesToScan) {
|
|
81976
82031
|
try {
|
|
81977
|
-
const fileStat =
|
|
82032
|
+
const fileStat = fs73.statSync(filePath);
|
|
81978
82033
|
if (fileStat.size > MAX_FILE_SIZE_BYTES11) {
|
|
81979
82034
|
continue;
|
|
81980
82035
|
}
|
|
81981
|
-
const content =
|
|
82036
|
+
const content = fs73.readFileSync(filePath, "utf-8");
|
|
81982
82037
|
const entries = parseTodoComments(content, filePath, tagsSet);
|
|
81983
82038
|
allEntries.push(...entries);
|
|
81984
82039
|
} catch {}
|
|
@@ -82008,18 +82063,18 @@ init_tool();
|
|
|
82008
82063
|
init_loader();
|
|
82009
82064
|
init_schema();
|
|
82010
82065
|
init_gate_evidence();
|
|
82011
|
-
import * as
|
|
82066
|
+
import * as fs75 from "fs";
|
|
82012
82067
|
import * as path91 from "path";
|
|
82013
82068
|
|
|
82014
82069
|
// src/hooks/diff-scope.ts
|
|
82015
|
-
import * as
|
|
82070
|
+
import * as fs74 from "fs";
|
|
82016
82071
|
import * as path90 from "path";
|
|
82017
82072
|
function getDeclaredScope(taskId, directory) {
|
|
82018
82073
|
try {
|
|
82019
82074
|
const planPath = path90.join(directory, ".swarm", "plan.json");
|
|
82020
|
-
if (!
|
|
82075
|
+
if (!fs74.existsSync(planPath))
|
|
82021
82076
|
return null;
|
|
82022
|
-
const raw =
|
|
82077
|
+
const raw = fs74.readFileSync(planPath, "utf-8");
|
|
82023
82078
|
const plan = JSON.parse(raw);
|
|
82024
82079
|
for (const phase of plan.phases ?? []) {
|
|
82025
82080
|
for (const task of phase.tasks ?? []) {
|
|
@@ -82149,7 +82204,7 @@ function checkReviewerGate(taskId, workingDirectory) {
|
|
|
82149
82204
|
const resolvedDir2 = workingDirectory;
|
|
82150
82205
|
try {
|
|
82151
82206
|
const planPath = path91.join(resolvedDir2, ".swarm", "plan.json");
|
|
82152
|
-
const planRaw =
|
|
82207
|
+
const planRaw = fs75.readFileSync(planPath, "utf-8");
|
|
82153
82208
|
const plan = JSON.parse(planRaw);
|
|
82154
82209
|
for (const planPhase of plan.phases ?? []) {
|
|
82155
82210
|
for (const task of planPhase.tasks ?? []) {
|
|
@@ -82216,7 +82271,7 @@ function checkReviewerGate(taskId, workingDirectory) {
|
|
|
82216
82271
|
try {
|
|
82217
82272
|
const resolvedDir2 = workingDirectory;
|
|
82218
82273
|
const planPath = path91.join(resolvedDir2, ".swarm", "plan.json");
|
|
82219
|
-
const planRaw =
|
|
82274
|
+
const planRaw = fs75.readFileSync(planPath, "utf-8");
|
|
82220
82275
|
const plan = JSON.parse(planRaw);
|
|
82221
82276
|
for (const planPhase of plan.phases ?? []) {
|
|
82222
82277
|
for (const task of planPhase.tasks ?? []) {
|
|
@@ -82446,9 +82501,9 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
82446
82501
|
}
|
|
82447
82502
|
const resolvedDir = path91.resolve(normalizedDir);
|
|
82448
82503
|
try {
|
|
82449
|
-
const realPath =
|
|
82504
|
+
const realPath = fs75.realpathSync(resolvedDir);
|
|
82450
82505
|
const planPath = path91.join(realPath, ".swarm", "plan.json");
|
|
82451
|
-
if (!
|
|
82506
|
+
if (!fs75.existsSync(planPath)) {
|
|
82452
82507
|
return {
|
|
82453
82508
|
success: false,
|
|
82454
82509
|
message: `Invalid working_directory: plan not found in "${realPath}"`,
|
|
@@ -82480,11 +82535,11 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
82480
82535
|
if (args2.status === "in_progress") {
|
|
82481
82536
|
try {
|
|
82482
82537
|
const evidencePath = path91.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
|
|
82483
|
-
|
|
82484
|
-
const fd =
|
|
82538
|
+
fs75.mkdirSync(path91.dirname(evidencePath), { recursive: true });
|
|
82539
|
+
const fd = fs75.openSync(evidencePath, "wx");
|
|
82485
82540
|
let writeOk = false;
|
|
82486
82541
|
try {
|
|
82487
|
-
|
|
82542
|
+
fs75.writeSync(fd, JSON.stringify({
|
|
82488
82543
|
task_id: args2.task_id,
|
|
82489
82544
|
required_gates: ["reviewer", "test_engineer"],
|
|
82490
82545
|
gates: {},
|
|
@@ -82492,10 +82547,10 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
82492
82547
|
}, null, 2));
|
|
82493
82548
|
writeOk = true;
|
|
82494
82549
|
} finally {
|
|
82495
|
-
|
|
82550
|
+
fs75.closeSync(fd);
|
|
82496
82551
|
if (!writeOk) {
|
|
82497
82552
|
try {
|
|
82498
|
-
|
|
82553
|
+
fs75.unlinkSync(evidencePath);
|
|
82499
82554
|
} catch {}
|
|
82500
82555
|
}
|
|
82501
82556
|
}
|
|
@@ -82506,7 +82561,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
82506
82561
|
let phaseRequiresReviewer = true;
|
|
82507
82562
|
try {
|
|
82508
82563
|
const planPath = path91.join(directory, ".swarm", "plan.json");
|
|
82509
|
-
const planRaw =
|
|
82564
|
+
const planRaw = fs75.readFileSync(planPath, "utf-8");
|
|
82510
82565
|
const plan = JSON.parse(planRaw);
|
|
82511
82566
|
const taskPhase = plan.phases.find((p) => p.tasks.some((t) => t.id === args2.task_id));
|
|
82512
82567
|
if (taskPhase?.required_agents && !taskPhase.required_agents.includes("reviewer")) {
|
|
@@ -82615,7 +82670,7 @@ init_utils2();
|
|
|
82615
82670
|
init_ledger();
|
|
82616
82671
|
init_manager();
|
|
82617
82672
|
init_create_tool();
|
|
82618
|
-
import
|
|
82673
|
+
import fs76 from "fs";
|
|
82619
82674
|
import path92 from "path";
|
|
82620
82675
|
function derivePlanId5(plan) {
|
|
82621
82676
|
return `${plan.swarm}-${plan.title}`.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
@@ -82680,10 +82735,10 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
82680
82735
|
}
|
|
82681
82736
|
const evidenceDir = path92.dirname(validatedPath);
|
|
82682
82737
|
try {
|
|
82683
|
-
await
|
|
82738
|
+
await fs76.promises.mkdir(evidenceDir, { recursive: true });
|
|
82684
82739
|
const tempPath = path92.join(evidenceDir, `.${filename}.tmp`);
|
|
82685
|
-
await
|
|
82686
|
-
await
|
|
82740
|
+
await fs76.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
82741
|
+
await fs76.promises.rename(tempPath, validatedPath);
|
|
82687
82742
|
let snapshotInfo;
|
|
82688
82743
|
let snapshotError;
|
|
82689
82744
|
let qaProfileLocked;
|