infraweaver 0.3.11 → 0.3.12
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/README.md +1 -1
- package/dist/cli.mjs +310 -231
- package/dist/index.js +289 -210
- package/dist/mcp/terraform/awsPrices.d.ts +1 -1
- package/dist/mcp/terraform/azurePrices.d.ts +1 -1
- package/dist/mcp/terraform/scanSession.d.ts +2 -0
- package/dist/mcp/terraform/verifySites.d.ts +48 -0
- package/package.json +1 -1
- package/src/mcp/terraform/awsPrices.ts +1 -1
- package/src/mcp/terraform/azurePrices.ts +23 -23
- package/src/mcp/terraform/concernResult.ts +2 -0
- package/src/mcp/terraform/scanSession.ts +6 -0
- package/src/mcp/terraform/tools/verifyRemediation.ts +23 -1
- package/src/mcp/terraform/verifySites.ts +106 -0
package/dist/cli.mjs
CHANGED
|
@@ -80148,7 +80148,7 @@ var require_polyfill = __commonJS({
|
|
|
80148
80148
|
var {
|
|
80149
80149
|
dirname: dirname16,
|
|
80150
80150
|
isAbsolute: isAbsolute10,
|
|
80151
|
-
join:
|
|
80151
|
+
join: join78,
|
|
80152
80152
|
parse: parse8,
|
|
80153
80153
|
resolve: resolve15,
|
|
80154
80154
|
sep: sep12,
|
|
@@ -80405,8 +80405,8 @@ var require_polyfill = __commonJS({
|
|
|
80405
80405
|
const dir = await readdir2(src);
|
|
80406
80406
|
for (let i = 0; i < dir.length; i++) {
|
|
80407
80407
|
const item = dir[i];
|
|
80408
|
-
const srcItem =
|
|
80409
|
-
const destItem =
|
|
80408
|
+
const srcItem = join78(src, item);
|
|
80409
|
+
const destItem = join78(dest, item);
|
|
80410
80410
|
const { destStat } = await checkPaths2(srcItem, destItem, opts);
|
|
80411
80411
|
await startCopy(destStat, srcItem, destItem, opts);
|
|
80412
80412
|
}
|
|
@@ -80479,7 +80479,7 @@ var require_cp = __commonJS({
|
|
|
80479
80479
|
// node_modules/.pnpm/@npmcli+fs@6.0.0/node_modules/@npmcli/fs/lib/with-temp-dir.js
|
|
80480
80480
|
var require_with_temp_dir = __commonJS({
|
|
80481
80481
|
"node_modules/.pnpm/@npmcli+fs@6.0.0/node_modules/@npmcli/fs/lib/with-temp-dir.js"(exports2, module) {
|
|
80482
|
-
var { join:
|
|
80482
|
+
var { join: join78, sep: sep12 } = __require("path");
|
|
80483
80483
|
var getOptions2 = require_get_options();
|
|
80484
80484
|
var { mkdir: mkdir5, mkdtemp, rm: rm2 } = __require("fs/promises");
|
|
80485
80485
|
var withTempDir = async (root, fn2, opts) => {
|
|
@@ -80487,7 +80487,7 @@ var require_with_temp_dir = __commonJS({
|
|
|
80487
80487
|
copy: ["tmpPrefix"]
|
|
80488
80488
|
});
|
|
80489
80489
|
await mkdir5(root, { recursive: true });
|
|
80490
|
-
const target = await mkdtemp(
|
|
80490
|
+
const target = await mkdtemp(join78(`${root}${sep12}`, options.tmpPrefix || ""));
|
|
80491
80491
|
let err;
|
|
80492
80492
|
let result;
|
|
80493
80493
|
try {
|
|
@@ -80512,13 +80512,13 @@ var require_with_temp_dir = __commonJS({
|
|
|
80512
80512
|
var require_readdir_scoped = __commonJS({
|
|
80513
80513
|
"node_modules/.pnpm/@npmcli+fs@6.0.0/node_modules/@npmcli/fs/lib/readdir-scoped.js"(exports2, module) {
|
|
80514
80514
|
var { readdir: readdir2 } = __require("fs/promises");
|
|
80515
|
-
var { join:
|
|
80515
|
+
var { join: join78 } = __require("path");
|
|
80516
80516
|
var readdirScoped = async (dir) => {
|
|
80517
80517
|
const results = [];
|
|
80518
80518
|
for (const item of await readdir2(dir)) {
|
|
80519
80519
|
if (item.startsWith("@")) {
|
|
80520
|
-
for (const scopedItem of await readdir2(
|
|
80521
|
-
results.push(
|
|
80520
|
+
for (const scopedItem of await readdir2(join78(dir, item))) {
|
|
80521
|
+
results.push(join78(item, scopedItem));
|
|
80522
80522
|
}
|
|
80523
80523
|
} else {
|
|
80524
80524
|
results.push(item);
|
|
@@ -80533,7 +80533,7 @@ var require_readdir_scoped = __commonJS({
|
|
|
80533
80533
|
// node_modules/.pnpm/@npmcli+fs@6.0.0/node_modules/@npmcli/fs/lib/move-file.js
|
|
80534
80534
|
var require_move_file = __commonJS({
|
|
80535
80535
|
"node_modules/.pnpm/@npmcli+fs@6.0.0/node_modules/@npmcli/fs/lib/move-file.js"(exports2, module) {
|
|
80536
|
-
var { dirname: dirname16, join:
|
|
80536
|
+
var { dirname: dirname16, join: join78, resolve: resolve15, relative: relative10, isAbsolute: isAbsolute10 } = __require("path");
|
|
80537
80537
|
var fs12 = __require("fs/promises");
|
|
80538
80538
|
var pathExists2 = async (path15) => {
|
|
80539
80539
|
try {
|
|
@@ -80563,7 +80563,7 @@ var require_move_file = __commonJS({
|
|
|
80563
80563
|
if (sourceStat.isDirectory()) {
|
|
80564
80564
|
const files = await fs12.readdir(source);
|
|
80565
80565
|
await Promise.all(files.map(
|
|
80566
|
-
(file2) => moveFile(
|
|
80566
|
+
(file2) => moveFile(join78(source, file2), join78(destination, file2), options, false, symlinks)
|
|
80567
80567
|
));
|
|
80568
80568
|
} else if (sourceStat.isSymbolicLink()) {
|
|
80569
80569
|
symlinks.push({ source, destination });
|
|
@@ -112581,14 +112581,14 @@ var require_turndown_cjs = __commonJS({
|
|
|
112581
112581
|
} else if (node3.nodeType === 1) {
|
|
112582
112582
|
replacement = replacementForNode.call(self2, node3);
|
|
112583
112583
|
}
|
|
112584
|
-
return
|
|
112584
|
+
return join78(output2, replacement);
|
|
112585
112585
|
}, "");
|
|
112586
112586
|
}
|
|
112587
112587
|
function postProcess(output2) {
|
|
112588
112588
|
var self2 = this;
|
|
112589
112589
|
this.rules.forEach(function(rule) {
|
|
112590
112590
|
if (typeof rule.append === "function") {
|
|
112591
|
-
output2 =
|
|
112591
|
+
output2 = join78(output2, rule.append(self2.options));
|
|
112592
112592
|
}
|
|
112593
112593
|
});
|
|
112594
112594
|
return output2.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
|
|
@@ -112600,7 +112600,7 @@ var require_turndown_cjs = __commonJS({
|
|
|
112600
112600
|
if (whitespace.leading || whitespace.trailing) content = content.trim();
|
|
112601
112601
|
return whitespace.leading + rule.replacement(content, node3, this.options) + whitespace.trailing;
|
|
112602
112602
|
}
|
|
112603
|
-
function
|
|
112603
|
+
function join78(output2, replacement) {
|
|
112604
112604
|
var s1 = trimTrailingNewlines(output2);
|
|
112605
112605
|
var s2 = trimLeadingNewlines(replacement);
|
|
112606
112606
|
var nls = Math.max(output2.length - s1.length, replacement.length - s2.length);
|
|
@@ -200490,7 +200490,7 @@ import { randomBytes } from "node:crypto";
|
|
|
200490
200490
|
// package.json
|
|
200491
200491
|
var package_default = {
|
|
200492
200492
|
name: "infraweaver",
|
|
200493
|
-
version: "0.3.
|
|
200493
|
+
version: "0.3.12",
|
|
200494
200494
|
description: "GitHub Action that remediates Terraform to best practices and opens one scoped pull request per concern.",
|
|
200495
200495
|
keywords: [
|
|
200496
200496
|
"ai-coding-agent",
|
|
@@ -214109,7 +214109,7 @@ function TerraformAssessTool(ctx) {
|
|
|
214109
214109
|
// src/mcp/localServer.ts
|
|
214110
214110
|
import { mkdtempSync as mkdtempSync4 } from "node:fs";
|
|
214111
214111
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
214112
|
-
import { join as
|
|
214112
|
+
import { join as join41 } from "node:path";
|
|
214113
214113
|
|
|
214114
214114
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/external.js
|
|
214115
214115
|
var external_exports = {};
|
|
@@ -275148,8 +275148,8 @@ function ConsolidationCandidatesTool(ctx) {
|
|
|
275148
275148
|
}
|
|
275149
275149
|
|
|
275150
275150
|
// src/mcp/terraform/tools/detectPlanDrift.ts
|
|
275151
|
-
import { readFileSync as
|
|
275152
|
-
import { join as
|
|
275151
|
+
import { readFileSync as readFileSync18 } from "node:fs";
|
|
275152
|
+
import { join as join28 } from "node:path";
|
|
275153
275153
|
|
|
275154
275154
|
// node_modules/.pnpm/@infraweaver-io+ci@0.1.8/node_modules/@infraweaver-io/ci/dist/progressComment.js
|
|
275155
275155
|
function parseProgressComment(raw2) {
|
|
@@ -276897,6 +276897,66 @@ function dedupeCrossScanner(concerns) {
|
|
|
276897
276897
|
return [...merged, ...passthrough];
|
|
276898
276898
|
}
|
|
276899
276899
|
|
|
276900
|
+
// src/mcp/terraform/verifySites.ts
|
|
276901
|
+
import { readFileSync as readFileSync17 } from "node:fs";
|
|
276902
|
+
import { join as join27 } from "node:path";
|
|
276903
|
+
function fileReader(cwd) {
|
|
276904
|
+
const cache3 = /* @__PURE__ */ new Map();
|
|
276905
|
+
return (file2) => {
|
|
276906
|
+
if (!cache3.has(file2)) {
|
|
276907
|
+
let text;
|
|
276908
|
+
try {
|
|
276909
|
+
text = readFileSync17(join27(cwd, file2), "utf8");
|
|
276910
|
+
} catch {
|
|
276911
|
+
text = null;
|
|
276912
|
+
}
|
|
276913
|
+
cache3.set(file2, text);
|
|
276914
|
+
}
|
|
276915
|
+
return cache3.get(file2) ?? null;
|
|
276916
|
+
};
|
|
276917
|
+
}
|
|
276918
|
+
function siteOf(c, read3) {
|
|
276919
|
+
const text = read3(c.location.file);
|
|
276920
|
+
return text === null ? null : resourceAddressAt(text, c.location.line);
|
|
276921
|
+
}
|
|
276922
|
+
function recordConcernSites(session, concerns, cwd) {
|
|
276923
|
+
const read3 = fileReader(cwd);
|
|
276924
|
+
session.siteById ??= /* @__PURE__ */ new Map();
|
|
276925
|
+
session.firstSitesByKey ??= /* @__PURE__ */ new Map();
|
|
276926
|
+
const first = session.firstSitesByKey;
|
|
276927
|
+
const fresh = /* @__PURE__ */ new Map();
|
|
276928
|
+
for (const c of concerns) {
|
|
276929
|
+
const site = siteOf(c, read3);
|
|
276930
|
+
session.siteById.set(c.id, site);
|
|
276931
|
+
const key = concernKeyOf(c);
|
|
276932
|
+
if (first.has(key)) continue;
|
|
276933
|
+
const sites = fresh.get(key) ?? /* @__PURE__ */ new Set();
|
|
276934
|
+
sites.add(site);
|
|
276935
|
+
fresh.set(key, sites);
|
|
276936
|
+
}
|
|
276937
|
+
for (const [key, sites] of fresh) first.set(key, sites);
|
|
276938
|
+
}
|
|
276939
|
+
function resolvedAtSite(params) {
|
|
276940
|
+
const firingByKey = /* @__PURE__ */ new Map();
|
|
276941
|
+
for (const c of params.current) {
|
|
276942
|
+
const list = firingByKey.get(c.key) ?? [];
|
|
276943
|
+
list.push(c.site);
|
|
276944
|
+
firingByKey.set(c.key, list);
|
|
276945
|
+
}
|
|
276946
|
+
const out = [];
|
|
276947
|
+
for (const r of params.requested) {
|
|
276948
|
+
if (r.site === null || r.file === void 0) continue;
|
|
276949
|
+
const firing = firingByKey.get(r.key) ?? [];
|
|
276950
|
+
const known = params.firstSites.get(r.key);
|
|
276951
|
+
if (known === void 0) continue;
|
|
276952
|
+
if (firing.some((s) => s === null || !known.has(s))) continue;
|
|
276953
|
+
if (firing.includes(r.site)) continue;
|
|
276954
|
+
if (!params.declared(r.file).has(r.site)) continue;
|
|
276955
|
+
out.push(r.id);
|
|
276956
|
+
}
|
|
276957
|
+
return out;
|
|
276958
|
+
}
|
|
276959
|
+
|
|
276900
276960
|
// src/mcp/terraform/concernResult.ts
|
|
276901
276961
|
function annotateConcerns(rawConcerns, opts) {
|
|
276902
276962
|
const inScope = opts.inScope ?? (() => true);
|
|
@@ -276923,6 +276983,7 @@ function buildConcernResult(ctx, rawConcerns, opts) {
|
|
|
276923
276983
|
fullBaseline.map((c) => concernKeyOf(c))
|
|
276924
276984
|
);
|
|
276925
276985
|
recordConcernKeys(session, fullBaseline);
|
|
276986
|
+
recordConcernSites(session, fullBaseline, opts.cwd);
|
|
276926
276987
|
session.baselineFmtDriftFiles = union3(
|
|
276927
276988
|
session.baselineFmtDriftFiles,
|
|
276928
276989
|
fullBaseline.filter((c) => c.source === "terraform-fmt").map((c) => c.location.file)
|
|
@@ -277373,7 +277434,7 @@ function readTfFiles(cwd) {
|
|
|
277373
277434
|
const out = [];
|
|
277374
277435
|
for (const file2 of walkTfFiles(cwd)) {
|
|
277375
277436
|
try {
|
|
277376
|
-
out.push({ file: file2, hcl:
|
|
277437
|
+
out.push({ file: file2, hcl: readFileSync18(join28(cwd, file2), "utf8") });
|
|
277377
277438
|
} catch {
|
|
277378
277439
|
}
|
|
277379
277440
|
}
|
|
@@ -277390,7 +277451,7 @@ function DetectPlanDriftTool(ctx) {
|
|
|
277390
277451
|
const planPath = path15 || !envPlanPath ? resolveWithinCwd(cwd, path15 ?? "plan.json") : envPlanPath;
|
|
277391
277452
|
let raw2;
|
|
277392
277453
|
try {
|
|
277393
|
-
raw2 =
|
|
277454
|
+
raw2 = readFileSync18(planPath, "utf8");
|
|
277394
277455
|
} catch {
|
|
277395
277456
|
return skipResult(
|
|
277396
277457
|
"plan_artifact_not_found",
|
|
@@ -277522,13 +277583,13 @@ function DetectPlanDriftTool(ctx) {
|
|
|
277522
277583
|
}
|
|
277523
277584
|
|
|
277524
277585
|
// src/mcp/terraform/tools/emitCost.ts
|
|
277525
|
-
import { readFileSync as
|
|
277526
|
-
import { join as
|
|
277586
|
+
import { readFileSync as readFileSync20, writeFileSync as writeFileSync4 } from "node:fs";
|
|
277587
|
+
import { join as join30 } from "node:path";
|
|
277527
277588
|
|
|
277528
277589
|
// src/mcp/guardrails.ts
|
|
277529
277590
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
277530
|
-
import { readFileSync as
|
|
277531
|
-
import { join as
|
|
277591
|
+
import { readFileSync as readFileSync19, rmSync as rmSync2 } from "node:fs";
|
|
277592
|
+
import { join as join29 } from "node:path";
|
|
277532
277593
|
|
|
277533
277594
|
// src/mcp/terraform/emittedArtefacts.ts
|
|
277534
277595
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -277830,7 +277891,7 @@ function parseGitleaksReport(json5) {
|
|
|
277830
277891
|
return hits;
|
|
277831
277892
|
}
|
|
277832
277893
|
function scanWithGitleaks(ctx, base) {
|
|
277833
|
-
const reportPath =
|
|
277894
|
+
const reportPath = join29(ctx.tmpdir, `gitleaks-report-${process.pid}.json`);
|
|
277834
277895
|
const cwd = ctx.payload.cwd ?? process.cwd();
|
|
277835
277896
|
const result = spawnSync5(
|
|
277836
277897
|
"gitleaks",
|
|
@@ -277864,7 +277925,7 @@ function scanWithGitleaks(ctx, base) {
|
|
|
277864
277925
|
return null;
|
|
277865
277926
|
}
|
|
277866
277927
|
try {
|
|
277867
|
-
const report2 =
|
|
277928
|
+
const report2 = readFileSync19(reportPath, "utf8");
|
|
277868
277929
|
return parseGitleaksReport(report2);
|
|
277869
277930
|
} catch {
|
|
277870
277931
|
return [];
|
|
@@ -277936,7 +277997,7 @@ function assertNoForeignDialectIntroduced(ctx) {
|
|
|
277936
277997
|
const file2 = rel.replace(/\\/g, "/");
|
|
277937
277998
|
if (changedSet.has(file2)) continue;
|
|
277938
277999
|
try {
|
|
277939
|
-
established.push(...findDialectMarkers(
|
|
278000
|
+
established.push(...findDialectMarkers(readFileSync19(join29(cwd, rel), "utf8"), file2));
|
|
277940
278001
|
} catch {
|
|
277941
278002
|
}
|
|
277942
278003
|
}
|
|
@@ -278310,7 +278371,7 @@ var OpenPrOverlapError = class extends Error {
|
|
|
278310
278371
|
// src/mcp/terraform/awsPrices.ts
|
|
278311
278372
|
var AWS_PRICE_REGION = "eu-west-2";
|
|
278312
278373
|
var AWS_PRICE_CURRENCY = "USD";
|
|
278313
|
-
var AWS_PRICE_FETCHED_AT = "2026-
|
|
278374
|
+
var AWS_PRICE_FETCHED_AT = "2026-10-03";
|
|
278314
278375
|
var AWS_HOURLY_PRICES = {
|
|
278315
278376
|
"eks-cluster-standard": 0.1,
|
|
278316
278377
|
"elb-application": 0.02646,
|
|
@@ -278328,30 +278389,30 @@ var AWS_PER_GB_PRICES = {
|
|
|
278328
278389
|
// src/mcp/terraform/azurePrices.ts
|
|
278329
278390
|
var AZURE_PRICE_REGION = "westeurope";
|
|
278330
278391
|
var AZURE_PRICE_CURRENCY = "EUR";
|
|
278331
|
-
var AZURE_PRICE_FETCHED_AT = "2026-
|
|
278392
|
+
var AZURE_PRICE_FETCHED_AT = "2026-10-03";
|
|
278332
278393
|
var AZURE_HOURLY_PRICES = {
|
|
278333
|
-
"app-service-p0v3": 0.
|
|
278334
|
-
"app-service-p1v3": 0.
|
|
278335
|
-
"app-service-p2v3": 0.
|
|
278336
|
-
"app-service-p3v3": 0.
|
|
278337
|
-
"bastion-basic": 0.
|
|
278338
|
-
"bastion-premium": 0.
|
|
278339
|
-
"bastion-standard": 0.
|
|
278340
|
-
"firewall-basic": 0.
|
|
278341
|
-
"firewall-premium": 1.
|
|
278342
|
-
"firewall-standard": 1.
|
|
278343
|
-
"redis-c0": 0.
|
|
278344
|
-
"redis-c1": 0.
|
|
278345
|
-
"redis-c2": 0.
|
|
278346
|
-
"redis-c3": 0.
|
|
278347
|
-
"redis-p1": 0.
|
|
278348
|
-
"redis-p2": 0.
|
|
278349
|
-
"redis-p3": 0.
|
|
278350
|
-
"vpn-gateway-vpngw1": 0.
|
|
278351
|
-
"vpn-gateway-vpngw2": 0.
|
|
278352
|
-
"vpn-gateway-vpngw3": 1.
|
|
278353
|
-
"vpn-gateway-vpngw4": 1.
|
|
278354
|
-
"vpn-gateway-vpngw5": 3.
|
|
278394
|
+
"app-service-p0v3": 0.0783,
|
|
278395
|
+
"app-service-p1v3": 0.1566,
|
|
278396
|
+
"app-service-p2v3": 0.3133,
|
|
278397
|
+
"app-service-p3v3": 0.6265,
|
|
278398
|
+
"bastion-basic": 0.1672,
|
|
278399
|
+
"bastion-premium": 0.396,
|
|
278400
|
+
"bastion-standard": 0.2552,
|
|
278401
|
+
"firewall-basic": 0.3476,
|
|
278402
|
+
"firewall-premium": 1.54,
|
|
278403
|
+
"firewall-standard": 1.1,
|
|
278404
|
+
"redis-c0": 0.0242,
|
|
278405
|
+
"redis-c1": 0.0607,
|
|
278406
|
+
"redis-c2": 0.0986,
|
|
278407
|
+
"redis-c3": 0.198,
|
|
278408
|
+
"redis-p1": 0.2438,
|
|
278409
|
+
"redis-p2": 0.4884,
|
|
278410
|
+
"redis-p3": 0.9759,
|
|
278411
|
+
"vpn-gateway-vpngw1": 0.1672,
|
|
278412
|
+
"vpn-gateway-vpngw2": 0.4312,
|
|
278413
|
+
"vpn-gateway-vpngw3": 1.1,
|
|
278414
|
+
"vpn-gateway-vpngw4": 1.8479,
|
|
278415
|
+
"vpn-gateway-vpngw5": 3.2119
|
|
278355
278416
|
};
|
|
278356
278417
|
|
|
278357
278418
|
// src/mcp/terraform/idleFloor.ts
|
|
@@ -278629,7 +278690,7 @@ function readTfFiles2(cwd) {
|
|
|
278629
278690
|
const out = [];
|
|
278630
278691
|
for (const file2 of walkTfFiles(cwd)) {
|
|
278631
278692
|
try {
|
|
278632
|
-
out.push({ file: file2, hcl:
|
|
278693
|
+
out.push({ file: file2, hcl: readFileSync20(join30(cwd, file2), "utf8") });
|
|
278633
278694
|
} catch {
|
|
278634
278695
|
}
|
|
278635
278696
|
}
|
|
@@ -279396,12 +279457,12 @@ import { writeFileSync as writeFileSync5 } from "node:fs";
|
|
|
279396
279457
|
|
|
279397
279458
|
// src/mcp/terraform/lineage.ts
|
|
279398
279459
|
import { createHash as createHash10 } from "node:crypto";
|
|
279399
|
-
import { readFileSync as
|
|
279400
|
-
import { join as
|
|
279460
|
+
import { readFileSync as readFileSync21 } from "node:fs";
|
|
279461
|
+
import { join as join31 } from "node:path";
|
|
279401
279462
|
function repoFileReader(cwd) {
|
|
279402
279463
|
return (rel) => {
|
|
279403
279464
|
try {
|
|
279404
|
-
return
|
|
279465
|
+
return readFileSync21(join31(cwd, rel), "utf-8");
|
|
279405
279466
|
} catch {
|
|
279406
279467
|
return null;
|
|
279407
279468
|
}
|
|
@@ -279954,11 +280015,11 @@ function TerraformEmitVexTool(ctx) {
|
|
|
279954
280015
|
// src/mcp/terraform/tools/equivalenceCheck.ts
|
|
279955
280016
|
import { mkdtempSync as mkdtempSync2, rmSync as rmSync4 } from "node:fs";
|
|
279956
280017
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
279957
|
-
import { join as
|
|
280018
|
+
import { join as join33 } from "node:path";
|
|
279958
280019
|
|
|
279959
280020
|
// src/mcp/terraform/initArtefacts.ts
|
|
279960
280021
|
import { rmSync as rmSync3 } from "node:fs";
|
|
279961
|
-
import { join as
|
|
280022
|
+
import { join as join32, posix as posix9 } from "node:path";
|
|
279962
280023
|
var INIT_ARTEFACTS = /* @__PURE__ */ new Set([".terraform", ".terraform.lock.hcl"]);
|
|
279963
280024
|
function initArtefacts(cwd) {
|
|
279964
280025
|
const r = run("git", ["status", "--porcelain=v1", "-z", "--untracked-files=normal"], cwd);
|
|
@@ -279981,7 +280042,7 @@ function removeNewInitArtefacts(cwd, before, by) {
|
|
|
279981
280042
|
const created = [...after?.untracked ?? []].filter((p) => !before.untracked.has(p));
|
|
279982
280043
|
const changed = [...after?.modifiedLocks ?? []].filter((p) => !before.modifiedLocks.has(p));
|
|
279983
280044
|
if (!top || created.length + changed.length === 0) return;
|
|
279984
|
-
for (const p of created) rmSync3(
|
|
280045
|
+
for (const p of created) rmSync3(join32(top, p), { recursive: true, force: true });
|
|
279985
280046
|
if (changed.length > 0) run("git", ["checkout", "--", ...changed], top);
|
|
279986
280047
|
resetTerraformInitCache();
|
|
279987
280048
|
log2.info(
|
|
@@ -281779,12 +281840,12 @@ async function baselineValidateErrors(cwd, base, env2, session) {
|
|
|
281779
281840
|
}
|
|
281780
281841
|
const prefix2 = run("git", ["rev-parse", "--show-prefix"], cwd);
|
|
281781
281842
|
if (prefix2.status !== 0) return null;
|
|
281782
|
-
const tree = mkdtempSync2(
|
|
281843
|
+
const tree = mkdtempSync2(join33(tmpdir2(), "iw-baseline-"));
|
|
281783
281844
|
try {
|
|
281784
281845
|
if (run("git", ["worktree", "add", "--detach", "--quiet", tree, base], cwd).status !== 0) {
|
|
281785
281846
|
return null;
|
|
281786
281847
|
}
|
|
281787
|
-
const outcome2 = await scanValidate(
|
|
281848
|
+
const outcome2 = await scanValidate(join33(tree, prefix2.stdout.trim()), env2);
|
|
281788
281849
|
if (!outcome2.ran || outcome2.unvalidated) return null;
|
|
281789
281850
|
const errors = outcome2.concerns.map(validateErrorKey);
|
|
281790
281851
|
session.baselineValidateErrors = { base, errors };
|
|
@@ -281885,7 +281946,7 @@ function TerraformGenerateMovedTool(ctx) {
|
|
|
281885
281946
|
|
|
281886
281947
|
// src/mcp/terraform/cost.ts
|
|
281887
281948
|
import { mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
|
|
281888
|
-
import { join as
|
|
281949
|
+
import { join as join34 } from "node:path";
|
|
281889
281950
|
function parseInfracostBreakdown(stdout) {
|
|
281890
281951
|
const parsed2 = parseScannerJson(InfracostBreakdownOutput, stdout, "infracost");
|
|
281891
281952
|
const raw2 = parsed2.totalMonthlyCost;
|
|
@@ -281967,15 +282028,15 @@ async function infracostBaseline(cwd, key, tmpdir6) {
|
|
|
281967
282028
|
if (!baseRef) return null;
|
|
281968
282029
|
const prefixResult = run("git", ["rev-parse", "--show-prefix"], cwd);
|
|
281969
282030
|
const prefix2 = prefixResult.status === 0 ? prefixResult.stdout.trim() : "";
|
|
281970
|
-
const baseDir = mkdtempSync3(
|
|
281971
|
-
const worktree =
|
|
282031
|
+
const baseDir = mkdtempSync3(join34(tmpdir6, "infracost-base-"));
|
|
282032
|
+
const worktree = join34(baseDir, "wt");
|
|
281972
282033
|
const add = run("git", ["worktree", "add", "--detach", worktree, baseRef], cwd);
|
|
281973
282034
|
if (add.status !== 0) {
|
|
281974
282035
|
rmSync5(baseDir, { recursive: true, force: true });
|
|
281975
282036
|
return null;
|
|
281976
282037
|
}
|
|
281977
282038
|
try {
|
|
281978
|
-
const scanCwd = prefix2 ?
|
|
282039
|
+
const scanCwd = prefix2 ? join34(worktree, prefix2) : worktree;
|
|
281979
282040
|
const r = await runInfracostBreakdown(scanCwd, key);
|
|
281980
282041
|
if (r.missing || r.status !== 0) return null;
|
|
281981
282042
|
return parseInfracostBreakdown(r.stdout);
|
|
@@ -282046,7 +282107,7 @@ function InfracostDiffTool(ctx) {
|
|
|
282046
282107
|
|
|
282047
282108
|
// src/mcp/terraform/tools/ingestExternalFindings.ts
|
|
282048
282109
|
import { statSync as statSync7 } from "node:fs";
|
|
282049
|
-
import { join as
|
|
282110
|
+
import { join as join35 } from "node:path";
|
|
282050
282111
|
|
|
282051
282112
|
// src/mcp/terraform/prowlerOcsf.ts
|
|
282052
282113
|
var DETECTION_FINDING_CREATE = 200401;
|
|
@@ -282272,7 +282333,7 @@ var MAX_FEED_BYTES = 100 * 1024 * 1024;
|
|
|
282272
282333
|
function readTfFiles3(cwd) {
|
|
282273
282334
|
const out = [];
|
|
282274
282335
|
for (const file2 of walkTfFiles(cwd)) {
|
|
282275
|
-
const hcl2 = readTextCapped(
|
|
282336
|
+
const hcl2 = readTextCapped(join35(cwd, file2));
|
|
282276
282337
|
if (hcl2 !== null) out.push({ file: file2, hcl: hcl2 });
|
|
282277
282338
|
}
|
|
282278
282339
|
return out;
|
|
@@ -282429,8 +282490,8 @@ function IngestExternalFindingsTool(ctx) {
|
|
|
282429
282490
|
}
|
|
282430
282491
|
|
|
282431
282492
|
// src/mcp/terraform/tools/moduleDocs.ts
|
|
282432
|
-
import { readFileSync as
|
|
282433
|
-
import { join as
|
|
282493
|
+
import { readFileSync as readFileSync22, writeFileSync as writeFileSync6 } from "node:fs";
|
|
282494
|
+
import { join as join36 } from "node:path";
|
|
282434
282495
|
|
|
282435
282496
|
// src/mcp/terraform/moduleDocs.ts
|
|
282436
282497
|
var VERDICT_CLAIM = {
|
|
@@ -282544,7 +282605,7 @@ function TerraformModuleDocsTool(ctx) {
|
|
|
282544
282605
|
);
|
|
282545
282606
|
}
|
|
282546
282607
|
const absDir = resolveWithinCwd(cwd, module_dir);
|
|
282547
|
-
const target =
|
|
282608
|
+
const target = join36(absDir, "README.md");
|
|
282548
282609
|
let gitHead = null;
|
|
282549
282610
|
try {
|
|
282550
282611
|
gitHead = $("git", ["rev-parse", "HEAD"], { cwd, log: false });
|
|
@@ -282552,7 +282613,7 @@ function TerraformModuleDocsTool(ctx) {
|
|
|
282552
282613
|
}
|
|
282553
282614
|
let existing = null;
|
|
282554
282615
|
try {
|
|
282555
|
-
existing =
|
|
282616
|
+
existing = readFileSync22(target, "utf8");
|
|
282556
282617
|
} catch {
|
|
282557
282618
|
}
|
|
282558
282619
|
const priorHead = readFooterGitHead(existing);
|
|
@@ -282876,7 +282937,7 @@ function NormalizationCandidatesTool(ctx) {
|
|
|
282876
282937
|
|
|
282877
282938
|
// src/mcp/terraform/tools/plan.ts
|
|
282878
282939
|
import { rmSync as rmSync6 } from "node:fs";
|
|
282879
|
-
import { join as
|
|
282940
|
+
import { join as join37 } from "node:path";
|
|
282880
282941
|
var PLAN_JSON_ARGS = ["plan", "-input=false", "-no-color", "-lock=false", "-json"];
|
|
282881
282942
|
var planFileSeq = 0;
|
|
282882
282943
|
async function capturePlanPairs(absDir, planFile, creds) {
|
|
@@ -282899,7 +282960,7 @@ async function planOneRoot(absDir, creds, tmpdir6) {
|
|
|
282899
282960
|
skipReason: `terraform init failed: ${init.stderr.trim().slice(0, 200) || "unknown error"}`
|
|
282900
282961
|
};
|
|
282901
282962
|
}
|
|
282902
|
-
const planFile = tmpdir6 ?
|
|
282963
|
+
const planFile = tmpdir6 ? join37(tmpdir6, `plan-${process.pid}-${planFileSeq++}.tfplan`) : void 0;
|
|
282903
282964
|
const plan = await runTfAsync(
|
|
282904
282965
|
planFile ? [...PLAN_JSON_ARGS, `-out=${planFile}`] : PLAN_JSON_ARGS,
|
|
282905
282966
|
absDir,
|
|
@@ -283269,8 +283330,8 @@ function TerraformProviderUpgradeTool(ctx) {
|
|
|
283269
283330
|
}
|
|
283270
283331
|
|
|
283271
283332
|
// src/mcp/terraform/tfquery.ts
|
|
283272
|
-
import { readFileSync as
|
|
283273
|
-
import { join as
|
|
283333
|
+
import { readFileSync as readFileSync23 } from "node:fs";
|
|
283334
|
+
import { join as join38 } from "node:path";
|
|
283274
283335
|
var TFQUERY_SUFFIX = ".tfquery.hcl";
|
|
283275
283336
|
function parseQueryFile(hcl2) {
|
|
283276
283337
|
return parseBlocks(hcl2, ["list"]).map((block) => {
|
|
@@ -283296,7 +283357,7 @@ function collectQueryInventory(cwd) {
|
|
|
283296
283357
|
for (const rel of walkFilesBySuffix(cwd, TFQUERY_SUFFIX)) {
|
|
283297
283358
|
let text;
|
|
283298
283359
|
try {
|
|
283299
|
-
text =
|
|
283360
|
+
text = readFileSync23(join38(cwd, rel), "utf8");
|
|
283300
283361
|
} catch {
|
|
283301
283362
|
continue;
|
|
283302
283363
|
}
|
|
@@ -283331,7 +283392,7 @@ function TerraformQueryInventoryTool(ctx) {
|
|
|
283331
283392
|
}
|
|
283332
283393
|
|
|
283333
283394
|
// src/mcp/terraform/tools/readFindings.ts
|
|
283334
|
-
import { readFileSync as
|
|
283395
|
+
import { readFileSync as readFileSync24 } from "node:fs";
|
|
283335
283396
|
var ReadFindingsParams = type({
|
|
283336
283397
|
"path?": type.string.describe(
|
|
283337
283398
|
"path to the Assessor's findings.json. Defaults to $INFRAWEAVER_FINDINGS_PATH, then ./findings.json in the workspace."
|
|
@@ -283356,7 +283417,7 @@ function ReadFindingsTool(ctx) {
|
|
|
283356
283417
|
const findingsPath = path15 || !envFindingsPath ? resolveWithinCwd(cwd, path15 ?? "findings.json") : envFindingsPath;
|
|
283357
283418
|
let raw2;
|
|
283358
283419
|
try {
|
|
283359
|
-
raw2 =
|
|
283420
|
+
raw2 = readFileSync24(findingsPath, "utf8");
|
|
283360
283421
|
} catch {
|
|
283361
283422
|
return skipResult(
|
|
283362
283423
|
"findings_not_found",
|
|
@@ -283755,8 +283816,8 @@ function describe3(f) {
|
|
|
283755
283816
|
}
|
|
283756
283817
|
|
|
283757
283818
|
// src/mcp/terraform/tools/scan.ts
|
|
283758
|
-
import { readFileSync as
|
|
283759
|
-
import { join as
|
|
283819
|
+
import { readFileSync as readFileSync25 } from "node:fs";
|
|
283820
|
+
import { join as join39 } from "node:path";
|
|
283760
283821
|
|
|
283761
283822
|
// src/mcp/terraform/noiseProfile.ts
|
|
283762
283823
|
var MIN_DISMISSAL_REPOS = 3;
|
|
@@ -283942,7 +284003,7 @@ async function runScan(ctx, {
|
|
|
283942
284003
|
outcomes.flatMap((o) => o.concerns),
|
|
283943
284004
|
(rel) => {
|
|
283944
284005
|
try {
|
|
283945
|
-
return
|
|
284006
|
+
return readFileSync25(join39(cwd, rel), "utf-8");
|
|
283946
284007
|
} catch {
|
|
283947
284008
|
return null;
|
|
283948
284009
|
}
|
|
@@ -284460,8 +284521,8 @@ function TerraformStandardsReportTool(ctx) {
|
|
|
284460
284521
|
|
|
284461
284522
|
// src/mcp/terraform/tools/tag.ts
|
|
284462
284523
|
import { createHash as createHash11 } from "node:crypto";
|
|
284463
|
-
import { existsSync as existsSync9, readdirSync as readdirSync8, readFileSync as
|
|
284464
|
-
import { isAbsolute as isAbsolute3, join as
|
|
284524
|
+
import { existsSync as existsSync9, readdirSync as readdirSync8, readFileSync as readFileSync26, realpathSync as realpathSync2, rmSync as rmSync7 } from "node:fs";
|
|
284525
|
+
import { isAbsolute as isAbsolute3, join as join40, relative as relative5, resolve as resolve6, sep as sep2 } from "node:path";
|
|
284465
284526
|
var TerraformTagParams = type({
|
|
284466
284527
|
tags: type({ "[string]": "string" }).describe(
|
|
284467
284528
|
'the tag set to apply, key \u2192 value (e.g. {"Owner":"platform","CostCentre":"1234"}); merged into every taggable resource\'s `tags`'
|
|
@@ -284482,24 +284543,24 @@ var TerraformTagParams = type({
|
|
|
284482
284543
|
var realRunners3 = { run };
|
|
284483
284544
|
function sha(path15) {
|
|
284484
284545
|
try {
|
|
284485
|
-
return createHash11("sha256").update(
|
|
284546
|
+
return createHash11("sha256").update(readFileSync26(path15)).digest("hex");
|
|
284486
284547
|
} catch {
|
|
284487
284548
|
return null;
|
|
284488
284549
|
}
|
|
284489
284550
|
}
|
|
284490
284551
|
function snapshot2(cwd, files) {
|
|
284491
|
-
return new Map(files.map((f) => [f, sha(
|
|
284552
|
+
return new Map(files.map((f) => [f, sha(join40(cwd, f))]));
|
|
284492
284553
|
}
|
|
284493
284554
|
function toPosix(p) {
|
|
284494
284555
|
return p.split(sep2).join("/");
|
|
284495
284556
|
}
|
|
284496
284557
|
function terratagFiles(dir) {
|
|
284497
284558
|
const dirs = [dir];
|
|
284498
|
-
const manifest =
|
|
284559
|
+
const manifest = join40(dir, ".terraform", "modules", "modules.json");
|
|
284499
284560
|
if (existsSync9(manifest)) {
|
|
284500
284561
|
let modules;
|
|
284501
284562
|
try {
|
|
284502
|
-
modules = JSON.parse(
|
|
284563
|
+
modules = JSON.parse(readFileSync26(manifest, "utf8")).Modules;
|
|
284503
284564
|
} catch {
|
|
284504
284565
|
throw new Error(`terraform_tag refused: cannot read ${manifest} (re-run terraform init)`);
|
|
284505
284566
|
}
|
|
@@ -284507,7 +284568,7 @@ function terratagFiles(dir) {
|
|
|
284507
284568
|
const moduleDir = m?.Dir;
|
|
284508
284569
|
if (typeof moduleDir !== "string") continue;
|
|
284509
284570
|
try {
|
|
284510
|
-
dirs.push(realpathSync2(
|
|
284571
|
+
dirs.push(realpathSync2(join40(dir, moduleDir)));
|
|
284511
284572
|
} catch {
|
|
284512
284573
|
}
|
|
284513
284574
|
}
|
|
@@ -284515,7 +284576,7 @@ function terratagFiles(dir) {
|
|
|
284515
284576
|
const files = /* @__PURE__ */ new Set();
|
|
284516
284577
|
for (const d of dirs) {
|
|
284517
284578
|
for (const name of readdirSync8(d)) {
|
|
284518
|
-
if (name.endsWith(".tf")) files.add(realpathSync2(
|
|
284579
|
+
if (name.endsWith(".tf")) files.add(realpathSync2(join40(d, name)));
|
|
284519
284580
|
}
|
|
284520
284581
|
}
|
|
284521
284582
|
return [...files];
|
|
@@ -284582,7 +284643,7 @@ function runTag(ctx, params, runners = realRunners3) {
|
|
|
284582
284643
|
if (params.filter) args2.push(`-filter=${params.filter}`);
|
|
284583
284644
|
if (params.skip) args2.push(`-skip=${params.skip}`);
|
|
284584
284645
|
const before = snapshot2(cwd, files);
|
|
284585
|
-
const priorBackups = new Set(files.filter((f) => existsSync9(
|
|
284646
|
+
const priorBackups = new Set(files.filter((f) => existsSync9(join40(cwd, `${f}.bak`))));
|
|
284586
284647
|
const r = runners.run("terratag", args2, cwd);
|
|
284587
284648
|
if (r.missing) {
|
|
284588
284649
|
return toolSkip(
|
|
@@ -284596,7 +284657,7 @@ function runTag(ctx, params, runners = realRunners3) {
|
|
|
284596
284657
|
${tail}` : ""}`);
|
|
284597
284658
|
}
|
|
284598
284659
|
for (const f of files) {
|
|
284599
|
-
if (!priorBackups.has(f)) rmSync7(
|
|
284660
|
+
if (!priorBackups.has(f)) rmSync7(join40(cwd, `${f}.bak`), { force: true });
|
|
284600
284661
|
}
|
|
284601
284662
|
const failed = [
|
|
284602
284663
|
...`${r.stderr}
|
|
@@ -284767,7 +284828,25 @@ async function runVerifyRemediation(ctx, { concern_ids, download_external_module
|
|
|
284767
284828
|
if (key !== void 0) keyed.push({ id, key });
|
|
284768
284829
|
else unkeyed.push(id);
|
|
284769
284830
|
}
|
|
284770
|
-
const
|
|
284831
|
+
const byKey = partitionByKey(keyed, currentKeys);
|
|
284832
|
+
const read3 = fileReader(cwd);
|
|
284833
|
+
const remainingKeyed = keyed.filter((k) => byKey.remaining.includes(k.id));
|
|
284834
|
+
const atSite = new Set(
|
|
284835
|
+
resolvedAtSite({
|
|
284836
|
+
requested: remainingKeyed.map((k) => ({
|
|
284837
|
+
...k,
|
|
284838
|
+
site: session.siteById?.get(k.id) ?? null,
|
|
284839
|
+
file: reported.get(k.id)?.location.file
|
|
284840
|
+
})),
|
|
284841
|
+
current: currentConcerns.map((c) => ({ key: concernKeyOf(c), site: siteOf(c, read3) })),
|
|
284842
|
+
firstSites: session.firstSitesByKey ?? /* @__PURE__ */ new Map(),
|
|
284843
|
+
declared: (file2) => new Set(declaredAddresses(read3(file2) ?? ""))
|
|
284844
|
+
})
|
|
284845
|
+
);
|
|
284846
|
+
const keyedVerdict = {
|
|
284847
|
+
resolved: [...byKey.resolved, ...byKey.remaining.filter((id) => atSite.has(id))],
|
|
284848
|
+
remaining: byKey.remaining.filter((id) => !atSite.has(id))
|
|
284849
|
+
};
|
|
284771
284850
|
const fallbackVerdict = computeRemediationVerdict(unkeyed, new Set(currentIds));
|
|
284772
284851
|
const resolved = [...keyedVerdict.resolved, ...fallbackVerdict.resolved];
|
|
284773
284852
|
const remaining = [...keyedVerdict.remaining, ...fallbackVerdict.remaining];
|
|
@@ -285117,7 +285196,7 @@ function buildLocalContext(options) {
|
|
|
285117
285196
|
registryHost: options.registryHost
|
|
285118
285197
|
},
|
|
285119
285198
|
toolState: initToolState({ progressComment: void 0 }),
|
|
285120
|
-
tmpdir: mkdtempSync4(
|
|
285199
|
+
tmpdir: mkdtempSync4(join41(tmpdir3(), `${PRODUCT_SLUG}-mcp-`))
|
|
285121
285200
|
};
|
|
285122
285201
|
}
|
|
285123
285202
|
function buildLocalTools(ctx) {
|
|
@@ -285160,7 +285239,7 @@ function buildLocalTools(ctx) {
|
|
|
285160
285239
|
];
|
|
285161
285240
|
}
|
|
285162
285241
|
function cliVersion() {
|
|
285163
|
-
const raw2 = "0.3.
|
|
285242
|
+
const raw2 = "0.3.12";
|
|
285164
285243
|
if (raw2 !== void 0 && /^\d+\.\d+\.\d+$/.test(raw2)) {
|
|
285165
285244
|
return raw2;
|
|
285166
285245
|
}
|
|
@@ -285391,15 +285470,15 @@ ${postureLine(scorecard.posture, scorecard.total)} \u2014 failing the gate (--fa
|
|
|
285391
285470
|
}
|
|
285392
285471
|
|
|
285393
285472
|
// src/commands/explain.ts
|
|
285394
|
-
import { readFileSync as
|
|
285395
|
-
import { join as
|
|
285473
|
+
import { readFileSync as readFileSync27 } from "node:fs";
|
|
285474
|
+
import { join as join42, relative as relative6, resolve as resolve8 } from "node:path";
|
|
285396
285475
|
var import_arg2 = __toESM(require_arg(), 1);
|
|
285397
285476
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
285398
285477
|
function readConfig(cwd) {
|
|
285399
285478
|
for (const name of INFRAWEAVER_CONFIG_FILENAMES) {
|
|
285400
285479
|
let raw2;
|
|
285401
285480
|
try {
|
|
285402
|
-
raw2 =
|
|
285481
|
+
raw2 = readFileSync27(join42(cwd, name), "utf-8");
|
|
285403
285482
|
} catch {
|
|
285404
285483
|
continue;
|
|
285405
285484
|
}
|
|
@@ -285574,7 +285653,7 @@ var import_arg3 = __toESM(require_arg(), 1);
|
|
|
285574
285653
|
// node_modules/.pnpm/@infraweaver-io+ci@0.1.8/node_modules/@infraweaver-io/ci/dist/gitAuth.js
|
|
285575
285654
|
import { execSync } from "node:child_process";
|
|
285576
285655
|
import { createHash as createHash12 } from "node:crypto";
|
|
285577
|
-
import { readFileSync as
|
|
285656
|
+
import { readFileSync as readFileSync28, realpathSync as realpathSync3, unlinkSync } from "node:fs";
|
|
285578
285657
|
|
|
285579
285658
|
// node_modules/.pnpm/@infraweaver-io+sandbox@0.1.8/node_modules/@infraweaver-io/sandbox/dist/subprocess.js
|
|
285580
285659
|
import { spawn as nodeSpawn } from "node:child_process";
|
|
@@ -285900,7 +285979,7 @@ ${errMsg}` : errMsg;
|
|
|
285900
285979
|
// node_modules/.pnpm/@infraweaver-io+ci@0.1.8/node_modules/@infraweaver-io/ci/dist/gitAuth.js
|
|
285901
285980
|
var gitBinary;
|
|
285902
285981
|
function hashFile(path15) {
|
|
285903
|
-
return createHash12("sha256").update(
|
|
285982
|
+
return createHash12("sha256").update(readFileSync28(path15)).digest("hex");
|
|
285904
285983
|
}
|
|
285905
285984
|
function resolveGit() {
|
|
285906
285985
|
const lookup3 = process.platform === "win32" ? "where git" : "which git";
|
|
@@ -286022,7 +286101,7 @@ async function $gitFetchWithDeepen(args2, options, label) {
|
|
|
286022
286101
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
286023
286102
|
import { writeFileSync as writeFileSync7 } from "node:fs";
|
|
286024
286103
|
import { createServer } from "node:http";
|
|
286025
|
-
import { join as
|
|
286104
|
+
import { join as join43 } from "node:path";
|
|
286026
286105
|
var REVOKED_TRAP_MS = 6e4;
|
|
286027
286106
|
function revokeGitHubToken(token, userAgent2) {
|
|
286028
286107
|
const apiBase = process.env.GITHUB_API_URL || "https://api.github.com";
|
|
@@ -286094,7 +286173,7 @@ async function startGitAuthServer(tmpdir6, options) {
|
|
|
286094
286173
|
function writeAskpassScript(code2) {
|
|
286095
286174
|
const scriptId = randomUUID3();
|
|
286096
286175
|
const scriptName = `askpass-${scriptId}.js`;
|
|
286097
|
-
const scriptPath =
|
|
286176
|
+
const scriptPath = join43(tmpdir6, scriptName);
|
|
286098
286177
|
const content = [
|
|
286099
286178
|
`#!/usr/bin/env node`,
|
|
286100
286179
|
`var a=process.argv[2]||"";`,
|
|
@@ -286275,7 +286354,7 @@ function TerraformChangeSummaryTool(ctx) {
|
|
|
286275
286354
|
// src/mcp/checkout.ts
|
|
286276
286355
|
import { createHash as createHash13 } from "node:crypto";
|
|
286277
286356
|
import { statSync as statSync9, unlinkSync as unlinkSync3, writeFileSync as writeFileSync13 } from "node:fs";
|
|
286278
|
-
import { join as
|
|
286357
|
+
import { join as join53 } from "node:path";
|
|
286279
286358
|
|
|
286280
286359
|
// node_modules/.pnpm/@infraweaver-io+ci@0.1.8/node_modules/@infraweaver-io/ci/dist/diffCoverage.js
|
|
286281
286360
|
import { isAbsolute as isAbsolute5, normalize as normalize4, resolve as resolve9 } from "node:path";
|
|
@@ -286571,7 +286650,7 @@ function readNumber(params) {
|
|
|
286571
286650
|
// src/mcp/git.ts
|
|
286572
286651
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
286573
286652
|
import { writeFileSync as writeFileSync9 } from "node:fs";
|
|
286574
|
-
import { join as
|
|
286653
|
+
import { join as join46 } from "node:path";
|
|
286575
286654
|
|
|
286576
286655
|
// src/modes/address-reviews.ts
|
|
286577
286656
|
function addressReviewsMode(t) {
|
|
@@ -288074,14 +288153,14 @@ import { spawn as spawn3, spawnSync as spawnSync6 } from "node:child_process";
|
|
|
288074
288153
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
288075
288154
|
import { closeSync as closeSync3, openSync as openSync3, writeFileSync as writeFileSync8 } from "node:fs";
|
|
288076
288155
|
import { constants as osConstants, userInfo } from "node:os";
|
|
288077
|
-
import { join as
|
|
288156
|
+
import { join as join45 } from "node:path";
|
|
288078
288157
|
import { setTimeout as sleep3 } from "node:timers/promises";
|
|
288079
288158
|
|
|
288080
288159
|
// node_modules/.pnpm/@infraweaver-io+core@0.1.5/node_modules/@infraweaver-io/core/dist/packageManager.js
|
|
288081
288160
|
var import_semver = __toESM(require_semver2(), 1);
|
|
288082
288161
|
import { existsSync as existsSync11 } from "node:fs";
|
|
288083
288162
|
import { mkdir as mkdir2, readFile } from "node:fs/promises";
|
|
288084
|
-
import { delimiter as delimiter2, join as
|
|
288163
|
+
import { delimiter as delimiter2, join as join44 } from "node:path";
|
|
288085
288164
|
var SUPPORTED_NAMES = ["npm", "pnpm", "yarn", "bun"];
|
|
288086
288165
|
var COREPACK_MANAGED = ["pnpm", "yarn"];
|
|
288087
288166
|
function isSupported(name) {
|
|
@@ -288121,7 +288200,7 @@ function parseDevEnginesField(field) {
|
|
|
288121
288200
|
};
|
|
288122
288201
|
}
|
|
288123
288202
|
async function resolvePackageManagerSpec(cwd) {
|
|
288124
|
-
const pkgPath =
|
|
288203
|
+
const pkgPath = join44(cwd, "package.json");
|
|
288125
288204
|
if (!existsSync11(pkgPath))
|
|
288126
288205
|
return null;
|
|
288127
288206
|
let pkg;
|
|
@@ -288180,7 +288259,7 @@ async function currentVersion(run4, name) {
|
|
|
288180
288259
|
return result.stdout.trim();
|
|
288181
288260
|
}
|
|
288182
288261
|
function packageManagerBinDir(tmpdir6) {
|
|
288183
|
-
return
|
|
288262
|
+
return join44(tmpdir6, "pm-bin");
|
|
288184
288263
|
}
|
|
288185
288264
|
async function ensurePackageManager(params) {
|
|
288186
288265
|
const spec = params.spec;
|
|
@@ -288421,7 +288500,7 @@ async function killProcessGroup(proc) {
|
|
|
288421
288500
|
var MAX_OUTPUT_CHARS = 5e3;
|
|
288422
288501
|
function capOutput(output2) {
|
|
288423
288502
|
if (output2.length <= MAX_OUTPUT_CHARS) return output2;
|
|
288424
|
-
const fullPath =
|
|
288503
|
+
const fullPath = join45(getTempDir(), `shell-${randomUUID4().slice(0, 8)}.log`);
|
|
288425
288504
|
writeFileSync8(fullPath, output2);
|
|
288426
288505
|
const elided = output2.length - MAX_OUTPUT_CHARS;
|
|
288427
288506
|
return `... [${elided} chars truncated; output saved to ${fullPath}] ...
|
|
@@ -288487,8 +288566,8 @@ Do NOT use this tool for git commands \u2014 use the dedicated git tools instead
|
|
|
288487
288566
|
if (params.background) {
|
|
288488
288567
|
const tempDir = getTempDir();
|
|
288489
288568
|
const handle = `bg-${randomUUID4().slice(0, 8)}`;
|
|
288490
|
-
const outputPath =
|
|
288491
|
-
const pidPath =
|
|
288569
|
+
const outputPath = join45(tempDir, `${handle}.log`);
|
|
288570
|
+
const pidPath = join45(tempDir, `${handle}.pid`);
|
|
288492
288571
|
const logFd = openSync3(outputPath, "a");
|
|
288493
288572
|
let proc;
|
|
288494
288573
|
try {
|
|
@@ -289193,7 +289272,7 @@ function countAhead(head, base) {
|
|
|
289193
289272
|
}
|
|
289194
289273
|
function spillGitOutput(params) {
|
|
289195
289274
|
const tempDir = getTempDir();
|
|
289196
|
-
const outputPath =
|
|
289275
|
+
const outputPath = join46(tempDir, `git-${params.command}-${randomUUID5().slice(0, 8)}.txt`);
|
|
289197
289276
|
writeFileSync9(outputPath, params.output);
|
|
289198
289277
|
const previewByLines = params.output.split("\n").slice(0, OVERFLOW_PREVIEW_LINES).join("\n");
|
|
289199
289278
|
const preview = previewByLines.length <= OVERFLOW_PREVIEW_MAX_CHARS ? previewByLines : `${previewByLines.slice(0, OVERFLOW_PREVIEW_MAX_CHARS)}\u2026`;
|
|
@@ -289408,7 +289487,7 @@ function PushTagsTool(ctx) {
|
|
|
289408
289487
|
}
|
|
289409
289488
|
|
|
289410
289489
|
// src/mcp/review.ts
|
|
289411
|
-
import { readFileSync as
|
|
289490
|
+
import { readFileSync as readFileSync33 } from "node:fs";
|
|
289412
289491
|
|
|
289413
289492
|
// src/mcp/findingAudit.ts
|
|
289414
289493
|
var COHERENCE_RULES = {
|
|
@@ -289807,7 +289886,7 @@ function validateCompatibility(payloadVersion, actionVersion) {
|
|
|
289807
289886
|
}
|
|
289808
289887
|
|
|
289809
289888
|
// src/utils/github/prCommentEvent.ts
|
|
289810
|
-
import { readFileSync as
|
|
289889
|
+
import { readFileSync as readFileSync29 } from "node:fs";
|
|
289811
289890
|
var obj = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : void 0;
|
|
289812
289891
|
function parsePrCommentEvent(eventName, raw2) {
|
|
289813
289892
|
if (eventName !== "issue_comment") return void 0;
|
|
@@ -289836,7 +289915,7 @@ function readPrCommentEvent(env2 = process.env) {
|
|
|
289836
289915
|
try {
|
|
289837
289916
|
return parsePrCommentEvent(
|
|
289838
289917
|
env2.GITHUB_EVENT_NAME,
|
|
289839
|
-
JSON.parse(
|
|
289918
|
+
JSON.parse(readFileSync29(env2.GITHUB_EVENT_PATH, "utf-8"))
|
|
289840
289919
|
);
|
|
289841
289920
|
} catch {
|
|
289842
289921
|
return void 0;
|
|
@@ -289844,7 +289923,7 @@ function readPrCommentEvent(env2 = process.env) {
|
|
|
289844
289923
|
}
|
|
289845
289924
|
|
|
289846
289925
|
// src/utils/github/pullRequestEvent.ts
|
|
289847
|
-
import { readFileSync as
|
|
289926
|
+
import { readFileSync as readFileSync30 } from "node:fs";
|
|
289848
289927
|
var obj2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : void 0;
|
|
289849
289928
|
var str = (v) => typeof v === "string" && v ? v : void 0;
|
|
289850
289929
|
function parsePullRequestEvent(eventName, raw2) {
|
|
@@ -289904,7 +289983,7 @@ function readPullRequestEvent(env2 = process.env) {
|
|
|
289904
289983
|
if (env2.GITHUB_EVENT_NAME !== "pull_request" || !env2.GITHUB_EVENT_PATH) return void 0;
|
|
289905
289984
|
let raw2;
|
|
289906
289985
|
try {
|
|
289907
|
-
raw2 = JSON.parse(
|
|
289986
|
+
raw2 = JSON.parse(readFileSync30(env2.GITHUB_EVENT_PATH, "utf-8"));
|
|
289908
289987
|
} catch {
|
|
289909
289988
|
return void 0;
|
|
289910
289989
|
}
|
|
@@ -291181,7 +291260,7 @@ function formatOverflowNote(overflow, limit) {
|
|
|
291181
291260
|
|
|
291182
291261
|
// src/mcp/reviewComments.ts
|
|
291183
291262
|
import { writeFileSync as writeFileSync10 } from "node:fs";
|
|
291184
|
-
import { join as
|
|
291263
|
+
import { join as join47 } from "node:path";
|
|
291185
291264
|
|
|
291186
291265
|
// src/utils/github/body.ts
|
|
291187
291266
|
var import_turndown = __toESM(require_turndown_cjs(), 1);
|
|
@@ -291865,7 +291944,7 @@ function GetReviewCommentsTool(ctx) {
|
|
|
291865
291944
|
const { threadBlocks, reviewer, formatted, truncated } = result;
|
|
291866
291945
|
const tempDir = getTempDir();
|
|
291867
291946
|
const filename = `review-${params.review_id}-threads.md`;
|
|
291868
|
-
const commentsPath =
|
|
291947
|
+
const commentsPath = join47(tempDir, filename);
|
|
291869
291948
|
writeFileSync10(commentsPath, formatted.content);
|
|
291870
291949
|
log2.debug(`wrote ${threadBlocks.length} threads to ${commentsPath}`);
|
|
291871
291950
|
const truncationNote = truncated ? ` WARNING: this PR has more review threads/comments than a single fetch returns, so the set above is INCOMPLETE \u2014 some threads or comments are not included. Address what's here, but do not treat the list as exhaustive.` : "";
|
|
@@ -292161,8 +292240,8 @@ function renderReviewSummarySection(input2) {
|
|
|
292161
292240
|
}
|
|
292162
292241
|
|
|
292163
292242
|
// src/mcp/suggestionProver.ts
|
|
292164
|
-
import { mkdtempSync as mkdtempSync5, readFileSync as
|
|
292165
|
-
import { join as
|
|
292243
|
+
import { mkdtempSync as mkdtempSync5, readFileSync as readFileSync31, rmSync as rmSync8, writeFileSync as writeFileSync11 } from "node:fs";
|
|
292244
|
+
import { join as join48, posix as posix14 } from "node:path";
|
|
292166
292245
|
var MAX_SINGLE_PROOFS = 4;
|
|
292167
292246
|
async function proveSuggestions(input2, deps) {
|
|
292168
292247
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -292174,8 +292253,8 @@ async function proveSuggestions(input2, deps) {
|
|
|
292174
292253
|
else ready.push(c);
|
|
292175
292254
|
}
|
|
292176
292255
|
if (ready.length === 0) return input2.candidates.map((c) => out.get(c.index));
|
|
292177
|
-
const parent = mkdtempSync5(
|
|
292178
|
-
const worktree =
|
|
292256
|
+
const parent = mkdtempSync5(join48(input2.tmpdir, "suggestion-proof-"));
|
|
292257
|
+
const worktree = join48(parent, "wt");
|
|
292179
292258
|
if (run("git", ["worktree", "add", "--detach", worktree, "HEAD"], input2.repoCwd).status !== 0) {
|
|
292180
292259
|
rmSync8(parent, { recursive: true, force: true });
|
|
292181
292260
|
for (const c of ready) {
|
|
@@ -292187,7 +292266,7 @@ async function proveSuggestions(input2, deps) {
|
|
|
292187
292266
|
}
|
|
292188
292267
|
return input2.candidates.map((c) => out.get(c.index));
|
|
292189
292268
|
}
|
|
292190
|
-
const scanCwd = prefix2 ?
|
|
292269
|
+
const scanCwd = prefix2 ? join48(worktree, prefix2) : worktree;
|
|
292191
292270
|
const files = [...new Set(ready.map((c) => c.path.slice(prefix2.length)))];
|
|
292192
292271
|
try {
|
|
292193
292272
|
const before = await deps.scan(scanCwd, files);
|
|
@@ -292283,16 +292362,16 @@ function snapshot3(worktree, prefix2, cs) {
|
|
|
292283
292362
|
const m = /* @__PURE__ */ new Map();
|
|
292284
292363
|
for (const c of cs) {
|
|
292285
292364
|
const rel = c.path.slice(prefix2.length);
|
|
292286
|
-
if (!m.has(rel)) m.set(rel,
|
|
292365
|
+
if (!m.has(rel)) m.set(rel, readFileSync31(join48(worktree, c.path), "utf-8"));
|
|
292287
292366
|
}
|
|
292288
292367
|
return m;
|
|
292289
292368
|
}
|
|
292290
292369
|
function restore(worktree, prefix2, pristine) {
|
|
292291
|
-
for (const [rel, text] of pristine) writeFileSync11(
|
|
292370
|
+
for (const [rel, text] of pristine) writeFileSync11(join48(worktree, prefix2, rel), text);
|
|
292292
292371
|
}
|
|
292293
292372
|
function apply(worktree, path15, cs) {
|
|
292294
|
-
const file2 =
|
|
292295
|
-
const text =
|
|
292373
|
+
const file2 = join48(worktree, path15);
|
|
292374
|
+
const text = readFileSync31(file2, "utf-8");
|
|
292296
292375
|
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
292297
292376
|
const lines = text.split(/\r?\n/);
|
|
292298
292377
|
for (const c of [...cs].sort((a, b) => b.startLine - a.startLine)) {
|
|
@@ -292303,11 +292382,11 @@ function apply(worktree, path15, cs) {
|
|
|
292303
292382
|
|
|
292304
292383
|
// src/mcp/terraform/gateScan.ts
|
|
292305
292384
|
import { existsSync as existsSync12, mkdtempSync as mkdtempSync6, rmSync as rmSync10 } from "node:fs";
|
|
292306
|
-
import { join as
|
|
292385
|
+
import { join as join50, posix as posix15 } from "node:path";
|
|
292307
292386
|
|
|
292308
292387
|
// src/mcp/terraform/secretScan.ts
|
|
292309
|
-
import { readFileSync as
|
|
292310
|
-
import { join as
|
|
292388
|
+
import { readFileSync as readFileSync32, rmSync as rmSync9 } from "node:fs";
|
|
292389
|
+
import { join as join49 } from "node:path";
|
|
292311
292390
|
function parseBetterleaksReport(json5, prefix2 = "") {
|
|
292312
292391
|
const doc = JSON.parse(json5);
|
|
292313
292392
|
if (Array.isArray(doc) || !doc || typeof doc !== "object" || !("findings" in doc)) {
|
|
@@ -292341,7 +292420,7 @@ async function scanAddedSecrets(cwd, mergeBase, tmp) {
|
|
|
292341
292420
|
const top = run("git", ["rev-parse", "--show-toplevel"], cwd).stdout.trim();
|
|
292342
292421
|
const prefix2 = run("git", ["rev-parse", "--show-prefix"], cwd).stdout.trim();
|
|
292343
292422
|
if (!top) return { ran: false, reason: "not a git checkout", concerns: [] };
|
|
292344
|
-
const report2 =
|
|
292423
|
+
const report2 = join49(tmp, `betterleaks-${process.pid}.json`);
|
|
292345
292424
|
try {
|
|
292346
292425
|
const r = await runAsync(
|
|
292347
292426
|
"betterleaks",
|
|
@@ -292364,7 +292443,7 @@ async function scanAddedSecrets(cwd, mergeBase, tmp) {
|
|
|
292364
292443
|
const why = (r.stderr || r.stdout).trim().split("\n").pop() ?? "";
|
|
292365
292444
|
let parsed2;
|
|
292366
292445
|
try {
|
|
292367
|
-
parsed2 = parseBetterleaksReport(
|
|
292446
|
+
parsed2 = parseBetterleaksReport(readFileSync32(report2, "utf-8"), prefix2);
|
|
292368
292447
|
} catch (error63) {
|
|
292369
292448
|
const reason = r.status !== 0 ? `betterleaks exited ${r.status}: ${why}` : `${error63}`;
|
|
292370
292449
|
return { ran: false, reason, concerns: [] };
|
|
@@ -292414,8 +292493,8 @@ function checkOutBase(cwd, pr, tmp) {
|
|
|
292414
292493
|
}
|
|
292415
292494
|
const mergeBase = run("git", ["merge-base", pr.baseSha, "HEAD"], cwd).stdout.trim() || pr.baseSha;
|
|
292416
292495
|
const prefix2 = run("git", ["rev-parse", "--show-prefix"], cwd).stdout.trim();
|
|
292417
|
-
const parent = mkdtempSync6(
|
|
292418
|
-
const worktree =
|
|
292496
|
+
const parent = mkdtempSync6(join50(tmp, "scan-delta-base-"));
|
|
292497
|
+
const worktree = join50(parent, "wt");
|
|
292419
292498
|
if (run("git", ["worktree", "add", "--detach", worktree, mergeBase], cwd).status !== 0) {
|
|
292420
292499
|
rmSync10(parent, { recursive: true, force: true });
|
|
292421
292500
|
log2.warning("\xBB scan delta: could not check out the base \u2014 every finding is treated as new.");
|
|
@@ -292423,7 +292502,7 @@ function checkOutBase(cwd, pr, tmp) {
|
|
|
292423
292502
|
}
|
|
292424
292503
|
return {
|
|
292425
292504
|
mergeBase,
|
|
292426
|
-
cwd: prefix2 ?
|
|
292505
|
+
cwd: prefix2 ? join50(worktree, prefix2) : worktree,
|
|
292427
292506
|
close: () => {
|
|
292428
292507
|
run("git", ["worktree", "remove", "--force", worktree], cwd);
|
|
292429
292508
|
rmSync10(parent, { recursive: true, force: true });
|
|
@@ -293358,7 +293437,7 @@ ${coverageState.lastBreakdown}`
|
|
|
293358
293437
|
}
|
|
293359
293438
|
function readReviewedFile(path15) {
|
|
293360
293439
|
try {
|
|
293361
|
-
return
|
|
293440
|
+
return readFileSync33(resolveWithinCwd(resolveRepoRoot(), path15), "utf-8");
|
|
293362
293441
|
} catch {
|
|
293363
293442
|
return null;
|
|
293364
293443
|
}
|
|
@@ -293673,7 +293752,7 @@ function fastForwardDiff(params, exec2) {
|
|
|
293673
293752
|
|
|
293674
293753
|
// src/utils/prompt/changeImpact.ts
|
|
293675
293754
|
import { writeFileSync as writeFileSync12 } from "node:fs";
|
|
293676
|
-
import { join as
|
|
293755
|
+
import { join as join51 } from "node:path";
|
|
293677
293756
|
var MAX_ATOMS = 20;
|
|
293678
293757
|
var MAX_REFS_PER_ATOM = 6;
|
|
293679
293758
|
var MAX_EXCERPT = 160;
|
|
@@ -293853,7 +293932,7 @@ function createChangeImpactArtifact(params) {
|
|
|
293853
293932
|
fileCount: params.files.length,
|
|
293854
293933
|
lookupError
|
|
293855
293934
|
});
|
|
293856
|
-
const path15 =
|
|
293935
|
+
const path15 = join51(
|
|
293857
293936
|
params.tmpdir,
|
|
293858
293937
|
`pr-${params.pullNumber}-${params.headSha.slice(0, 7)}-impact.md`
|
|
293859
293938
|
);
|
|
@@ -293873,7 +293952,7 @@ function createChangeImpactArtifact(params) {
|
|
|
293873
293952
|
import { execFileSync, execSync as execSync2 } from "node:child_process";
|
|
293874
293953
|
import { mkdtempSync as mkdtempSync7, readdirSync as readdirSync9, realpathSync as realpathSync5, unlinkSync as unlinkSync2 } from "node:fs";
|
|
293875
293954
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
293876
|
-
import { join as
|
|
293955
|
+
import { join as join52 } from "node:path";
|
|
293877
293956
|
|
|
293878
293957
|
// src/utils/github/ghaCore.ts
|
|
293879
293958
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
@@ -293896,7 +293975,7 @@ var TEMP_DIR_STATE_KEY = "infraweaver_temp_dir";
|
|
|
293896
293975
|
|
|
293897
293976
|
// src/utils/setup/setup.ts
|
|
293898
293977
|
function createTempDirectory() {
|
|
293899
|
-
const sharedTempDir = mkdtempSync7(
|
|
293978
|
+
const sharedTempDir = mkdtempSync7(join52(tmpdir4(), `${PRODUCT_SLUG}-`));
|
|
293900
293979
|
process.env.INFRAWEAVER_TEMP_DIR = sharedTempDir;
|
|
293901
293980
|
saveState2(TEMP_DIR_STATE_KEY, sharedTempDir);
|
|
293902
293981
|
log2.info(`\xBB created temp dir at ${sharedTempDir}`);
|
|
@@ -293942,13 +294021,13 @@ function wipeRunnerLeakSurface() {
|
|
|
293942
294021
|
return [];
|
|
293943
294022
|
}
|
|
293944
294023
|
};
|
|
293945
|
-
const fileCommandsDir =
|
|
294024
|
+
const fileCommandsDir = join52(runnerTemp, "_runner_file_commands");
|
|
293946
294025
|
for (const entry4 of listDir(fileCommandsDir)) {
|
|
293947
|
-
tryUnlink(
|
|
294026
|
+
tryUnlink(join52(fileCommandsDir, entry4));
|
|
293948
294027
|
}
|
|
293949
294028
|
for (const entry4 of listDir(runnerTemp)) {
|
|
293950
294029
|
if (entry4.endsWith(".sh") || /^git-credentials-.*\.config$/.test(entry4)) {
|
|
293951
|
-
tryUnlink(
|
|
294030
|
+
tryUnlink(join52(runnerTemp, entry4));
|
|
293952
294031
|
}
|
|
293953
294032
|
}
|
|
293954
294033
|
if (wiped.length > 0) {
|
|
@@ -294447,7 +294526,7 @@ function CheckoutPrTool(ctx) {
|
|
|
294447
294526
|
headSha: ctx.toolState.checkoutSha
|
|
294448
294527
|
});
|
|
294449
294528
|
if (incremental) {
|
|
294450
|
-
incrementalDiffPath =
|
|
294529
|
+
incrementalDiffPath = join53(
|
|
294451
294530
|
tempDir,
|
|
294452
294531
|
`pr-${pull_number}-${beforeShort}-${headShort}-incremental.diff`
|
|
294453
294532
|
);
|
|
@@ -294461,7 +294540,7 @@ function CheckoutPrTool(ctx) {
|
|
|
294461
294540
|
const diffPreview = formatResult.content.split("\n").slice(0, 100).join("\n");
|
|
294462
294541
|
log2.debug(`formatted diff preview (first 100 lines):
|
|
294463
294542
|
${diffPreview}`);
|
|
294464
|
-
const diffPath =
|
|
294543
|
+
const diffPath = join53(tempDir, `pr-${pull_number}-${headShort}.diff`);
|
|
294465
294544
|
writeFileSync13(diffPath, formatResult.content);
|
|
294466
294545
|
log2.debug(`wrote diff to ${diffPath} (${formatResult.content.length} bytes)`);
|
|
294467
294546
|
ctx.toolState.diffCoverage = createDiffCoverageState({
|
|
@@ -294602,7 +294681,7 @@ ${dirty}`
|
|
|
294602
294681
|
|
|
294603
294682
|
// src/mcp/checkSuite.ts
|
|
294604
294683
|
import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync14 } from "node:fs";
|
|
294605
|
-
import { join as
|
|
294684
|
+
import { join as join54 } from "node:path";
|
|
294606
294685
|
import { stripVTControlCharacters } from "node:util";
|
|
294607
294686
|
var GetCheckSuiteLogs = type({
|
|
294608
294687
|
check_suite_id: type.number.describe("the id from check_suite.id")
|
|
@@ -294697,7 +294776,7 @@ function GetCheckSuiteLogsTool(ctx) {
|
|
|
294697
294776
|
};
|
|
294698
294777
|
}
|
|
294699
294778
|
const tempDir = getTempDir();
|
|
294700
|
-
const logsDir =
|
|
294779
|
+
const logsDir = join54(tempDir, "ci-logs");
|
|
294701
294780
|
mkdirSync6(logsDir, { recursive: true });
|
|
294702
294781
|
const jobLists = await mapWithConcurrency(
|
|
294703
294782
|
failedRuns,
|
|
@@ -294721,7 +294800,7 @@ function GetCheckSuiteLogsTool(ctx) {
|
|
|
294721
294800
|
request: { signal: AbortSignal.timeout(1e4) }
|
|
294722
294801
|
});
|
|
294723
294802
|
const logsText = typeof data === "string" ? data : Buffer.from(data).toString("utf8");
|
|
294724
|
-
const logPath =
|
|
294803
|
+
const logPath = join54(logsDir, `job-${job.id}.log`);
|
|
294725
294804
|
writeFileSync14(logPath, logsText);
|
|
294726
294805
|
const analysis = analyzeLog(logsText, 80);
|
|
294727
294806
|
const failedSteps = job.steps?.filter((s) => s.conclusion === "failure").map((s) => `Step ${s.number}: ${s.name}`) ?? [];
|
|
@@ -294783,7 +294862,7 @@ function GetCheckSuiteLogsTool(ctx) {
|
|
|
294783
294862
|
|
|
294784
294863
|
// src/mcp/commitInfo.ts
|
|
294785
294864
|
import { writeFileSync as writeFileSync15 } from "node:fs";
|
|
294786
|
-
import { join as
|
|
294865
|
+
import { join as join55 } from "node:path";
|
|
294787
294866
|
var CommitInfo = type({
|
|
294788
294867
|
sha: type.string.describe("the commit SHA (full or abbreviated) to fetch")
|
|
294789
294868
|
});
|
|
@@ -294802,7 +294881,7 @@ function CommitInfoTool(ctx) {
|
|
|
294802
294881
|
const files = data.files ?? [];
|
|
294803
294882
|
const formatResult = formatFilesWithLineNumbers(files);
|
|
294804
294883
|
const tempDir = getTempDir("get_commit_info");
|
|
294805
|
-
const diffFile =
|
|
294884
|
+
const diffFile = join55(tempDir, `commit-${sha2.slice(0, 7)}.diff`);
|
|
294806
294885
|
writeFileSync15(diffFile, formatResult.content);
|
|
294807
294886
|
log2.debug(`wrote commit diff to ${diffFile} (${formatResult.content.length} bytes)`);
|
|
294808
294887
|
return {
|
|
@@ -294964,7 +295043,7 @@ import { performance as performance3 } from "node:perf_hooks";
|
|
|
294964
295043
|
|
|
294965
295044
|
// src/prep/installNodeDependencies.ts
|
|
294966
295045
|
import { existsSync as existsSync13 } from "node:fs";
|
|
294967
|
-
import { join as
|
|
295046
|
+
import { join as join56 } from "node:path";
|
|
294968
295047
|
|
|
294969
295048
|
// node_modules/.pnpm/package-manager-detector@1.8.0/node_modules/package-manager-detector/dist/commands.mjs
|
|
294970
295049
|
function splitRunArgs(args2, valueFlags = []) {
|
|
@@ -295350,7 +295429,7 @@ async function installFallback(name, installSpec) {
|
|
|
295350
295429
|
return result.stderr || `failed to install ${name}`;
|
|
295351
295430
|
}
|
|
295352
295431
|
if (name === "deno") {
|
|
295353
|
-
const denoPath =
|
|
295432
|
+
const denoPath = join56(process.env.HOME || "", ".deno", "bin");
|
|
295354
295433
|
process.env.PATH = `${denoPath}:${process.env.PATH}`;
|
|
295355
295434
|
}
|
|
295356
295435
|
log2.info(`\xBB installed ${name}`);
|
|
@@ -295359,7 +295438,7 @@ async function installFallback(name, installSpec) {
|
|
|
295359
295438
|
var installNodeDependencies = {
|
|
295360
295439
|
name: "installNodeDependencies",
|
|
295361
295440
|
shouldRun: () => {
|
|
295362
|
-
const packageJsonPath =
|
|
295441
|
+
const packageJsonPath = join56(process.cwd(), "package.json");
|
|
295363
295442
|
return existsSync13(packageJsonPath);
|
|
295364
295443
|
},
|
|
295365
295444
|
run: async (options) => {
|
|
@@ -295468,8 +295547,8 @@ ${errorMessage2}`]
|
|
|
295468
295547
|
};
|
|
295469
295548
|
|
|
295470
295549
|
// src/prep/installPythonDependencies.ts
|
|
295471
|
-
import { existsSync as existsSync14, readFileSync as
|
|
295472
|
-
import { join as
|
|
295550
|
+
import { existsSync as existsSync14, readFileSync as readFileSync34 } from "node:fs";
|
|
295551
|
+
import { join as join57 } from "node:path";
|
|
295473
295552
|
var PYTHON_CONFIGS = [
|
|
295474
295553
|
{
|
|
295475
295554
|
file: "requirements.txt",
|
|
@@ -295504,7 +295583,7 @@ var PYTHON_CONFIGS = [
|
|
|
295504
295583
|
];
|
|
295505
295584
|
function pyprojectDeclaresBuildSystem(cwd) {
|
|
295506
295585
|
try {
|
|
295507
|
-
const content =
|
|
295586
|
+
const content = readFileSync34(join57(cwd, "pyproject.toml"), "utf8");
|
|
295508
295587
|
return /^\s*\[build-system\]/m.test(content);
|
|
295509
295588
|
} catch {
|
|
295510
295589
|
return false;
|
|
@@ -295554,13 +295633,13 @@ var installPythonDependencies = {
|
|
|
295554
295633
|
}
|
|
295555
295634
|
const cwd = process.cwd();
|
|
295556
295635
|
return PYTHON_CONFIGS.some(
|
|
295557
|
-
(config3) => existsSync14(
|
|
295636
|
+
(config3) => existsSync14(join57(cwd, config3.file)) && configApplies(config3, cwd)
|
|
295558
295637
|
);
|
|
295559
295638
|
},
|
|
295560
295639
|
run: async (options) => {
|
|
295561
295640
|
const cwd = process.cwd();
|
|
295562
295641
|
const config3 = PYTHON_CONFIGS.find(
|
|
295563
|
-
(c) => existsSync14(
|
|
295642
|
+
(c) => existsSync14(join57(cwd, c.file)) && configApplies(c, cwd)
|
|
295564
295643
|
);
|
|
295565
295644
|
if (!config3) {
|
|
295566
295645
|
return {
|
|
@@ -296141,8 +296220,8 @@ function SetOutputTool(ctx, outputSchema) {
|
|
|
296141
296220
|
|
|
296142
296221
|
// src/mcp/policy.ts
|
|
296143
296222
|
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
296144
|
-
import { existsSync as existsSync15, readFileSync as
|
|
296145
|
-
import { join as
|
|
296223
|
+
import { existsSync as existsSync15, readFileSync as readFileSync35 } from "node:fs";
|
|
296224
|
+
import { join as join58 } from "node:path";
|
|
296146
296225
|
function parseConftestOutput(stdout) {
|
|
296147
296226
|
let parsed2;
|
|
296148
296227
|
try {
|
|
@@ -296176,7 +296255,7 @@ var CONFTEST_CONFIG = "conftest.toml";
|
|
|
296176
296255
|
function conftestSelectsNamespaces(conftestCwd) {
|
|
296177
296256
|
let raw2;
|
|
296178
296257
|
try {
|
|
296179
|
-
raw2 =
|
|
296258
|
+
raw2 = readFileSync35(join58(conftestCwd, CONFTEST_CONFIG), "utf-8");
|
|
296180
296259
|
} catch {
|
|
296181
296260
|
return false;
|
|
296182
296261
|
}
|
|
@@ -296192,7 +296271,7 @@ function namespaceArgs(conftestCwd) {
|
|
|
296192
296271
|
}
|
|
296193
296272
|
function findPlanJson(cwd) {
|
|
296194
296273
|
for (const candidate of PLAN_JSON_NAMES) {
|
|
296195
|
-
const abs =
|
|
296274
|
+
const abs = join58(cwd, candidate);
|
|
296196
296275
|
if (existsSync15(abs)) return abs;
|
|
296197
296276
|
}
|
|
296198
296277
|
return null;
|
|
@@ -296237,7 +296316,7 @@ function resolvePolicyDir(cwd, explicit) {
|
|
|
296237
296316
|
return existsSync15(abs) ? abs : null;
|
|
296238
296317
|
}
|
|
296239
296318
|
for (const d of DEFAULT_POLICY_DIRS) {
|
|
296240
|
-
const abs =
|
|
296319
|
+
const abs = join58(cwd, d);
|
|
296241
296320
|
if (existsSync15(abs)) return abs;
|
|
296242
296321
|
}
|
|
296243
296322
|
return null;
|
|
@@ -296545,9 +296624,9 @@ function PullRequestInfoTool(ctx) {
|
|
|
296545
296624
|
|
|
296546
296625
|
// node_modules/.pnpm/@infraweaver-io+sandbox@0.1.8/node_modules/@infraweaver-io/sandbox/dist/writePolicy.js
|
|
296547
296626
|
import { renameSync, writeFileSync as writeFileSync16 } from "node:fs";
|
|
296548
|
-
import { join as
|
|
296627
|
+
import { join as join59 } from "node:path";
|
|
296549
296628
|
function writePolicyPath(tmpdir6, filename) {
|
|
296550
|
-
return
|
|
296629
|
+
return join59(tmpdir6, filename);
|
|
296551
296630
|
}
|
|
296552
296631
|
function publishWritePolicy(params) {
|
|
296553
296632
|
try {
|
|
@@ -299867,11 +299946,11 @@ import {
|
|
|
299867
299946
|
mkdirSync as mkdirSync7,
|
|
299868
299947
|
mkdtempSync as mkdtempSync8,
|
|
299869
299948
|
readdirSync as readdirSync10,
|
|
299870
|
-
readFileSync as
|
|
299949
|
+
readFileSync as readFileSync37,
|
|
299871
299950
|
writeFileSync as writeFileSync17
|
|
299872
299951
|
} from "node:fs";
|
|
299873
299952
|
import { tmpdir as osTmpdir } from "node:os";
|
|
299874
|
-
import { dirname as dirname8, isAbsolute as isAbsolute8, join as
|
|
299953
|
+
import { dirname as dirname8, isAbsolute as isAbsolute8, join as join61, relative as relative8, resolve as resolve11 } from "node:path";
|
|
299875
299954
|
function coercePolicyRules(raw2) {
|
|
299876
299955
|
const rules = [];
|
|
299877
299956
|
const rejected = [];
|
|
@@ -300123,7 +300202,7 @@ function evaluateRulesStatically(cwd, rules, scope2 = { kind: "all", reason: ""
|
|
|
300123
300202
|
const files = [];
|
|
300124
300203
|
for (const rel of walk.files) {
|
|
300125
300204
|
try {
|
|
300126
|
-
files.push({ rel, text:
|
|
300205
|
+
files.push({ rel, text: readFileSync37(join61(cwd, rel), "utf-8") });
|
|
300127
300206
|
} catch {
|
|
300128
300207
|
}
|
|
300129
300208
|
}
|
|
@@ -300238,16 +300317,16 @@ function cloudEmittedRego(rules) {
|
|
|
300238
300317
|
}
|
|
300239
300318
|
function readOrEmpty(path15) {
|
|
300240
300319
|
try {
|
|
300241
|
-
return
|
|
300320
|
+
return readFileSync37(path15, "utf-8");
|
|
300242
300321
|
} catch {
|
|
300243
300322
|
return "";
|
|
300244
300323
|
}
|
|
300245
300324
|
}
|
|
300246
300325
|
function regoDirIn(root, skip) {
|
|
300247
300326
|
for (const dir of DEFAULT_POLICY_DIRS) {
|
|
300248
|
-
const abs =
|
|
300327
|
+
const abs = join61(root, dir);
|
|
300249
300328
|
if (existsSync16(abs) && walkFilesBySuffix(abs, ".rego").some(
|
|
300250
|
-
(rel) => !skip(
|
|
300329
|
+
(rel) => !skip(join61(dir, rel), readOrEmpty(join61(abs, rel)))
|
|
300251
300330
|
)) {
|
|
300252
300331
|
return dir;
|
|
300253
300332
|
}
|
|
@@ -300255,14 +300334,14 @@ function regoDirIn(root, skip) {
|
|
|
300255
300334
|
return null;
|
|
300256
300335
|
}
|
|
300257
300336
|
function withoutSkipped(root, dir, skip, tmpdir6) {
|
|
300258
|
-
const abs =
|
|
300259
|
-
const files = readdirSync10(abs, { recursive: true, withFileTypes: true }).filter((e) => e.isFile()).map((e) => relative8(abs,
|
|
300260
|
-
const kept = files.filter((rel) => !skip(
|
|
300337
|
+
const abs = join61(root, dir);
|
|
300338
|
+
const files = readdirSync10(abs, { recursive: true, withFileTypes: true }).filter((e) => e.isFile()).map((e) => relative8(abs, join61(e.parentPath, e.name)));
|
|
300339
|
+
const kept = files.filter((rel) => !skip(join61(dir, rel), readOrEmpty(join61(abs, rel))));
|
|
300261
300340
|
if (kept.length === files.length) return abs;
|
|
300262
|
-
const copy =
|
|
300341
|
+
const copy = join61(mkdtempSync8(join61(tmpdir6 ?? osTmpdir(), "policy-own-")), dir);
|
|
300263
300342
|
for (const rel of kept) {
|
|
300264
|
-
mkdirSync7(dirname8(
|
|
300265
|
-
writeFileSync17(
|
|
300343
|
+
mkdirSync7(dirname8(join61(copy, rel)), { recursive: true });
|
|
300344
|
+
writeFileSync17(join61(copy, rel), readFileSync37(join61(abs, rel)));
|
|
300266
300345
|
}
|
|
300267
300346
|
return copy;
|
|
300268
300347
|
}
|
|
@@ -300284,18 +300363,18 @@ function resolveRepoPolicy(cwd, baseRef, tmpdir6, notes, skip) {
|
|
|
300284
300363
|
}
|
|
300285
300364
|
const own2 = tree.files.filter((f) => !skip(f.path, f.raw));
|
|
300286
300365
|
if (!own2.some((f) => f.path.endsWith(".rego"))) continue;
|
|
300287
|
-
const root = mkdtempSync8(
|
|
300366
|
+
const root = mkdtempSync8(join61(tmpdir6 ?? osTmpdir(), "policy-base-"));
|
|
300288
300367
|
for (const f of own2) {
|
|
300289
|
-
mkdirSync7(dirname8(
|
|
300290
|
-
writeFileSync17(
|
|
300368
|
+
mkdirSync7(dirname8(join61(root, f.path)), { recursive: true });
|
|
300369
|
+
writeFileSync17(join61(root, f.path), f.raw);
|
|
300291
300370
|
}
|
|
300292
300371
|
const toml = readFileAtBaseRef(cwd, baseRef, CONFTEST_CONFIG);
|
|
300293
|
-
if (toml.kind === "file") writeFileSync17(
|
|
300294
|
-
const same = head === dir && readdirSync10(
|
|
300372
|
+
if (toml.kind === "file") writeFileSync17(join61(root, CONFTEST_CONFIG), toml.raw);
|
|
300373
|
+
const same = head === dir && readdirSync10(join61(cwd, dir), { recursive: true, withFileTypes: true }).filter(
|
|
300295
300374
|
(e) => e.isFile()
|
|
300296
300375
|
).length === tree.files.length && tree.files.every((f) => {
|
|
300297
300376
|
try {
|
|
300298
|
-
return
|
|
300377
|
+
return readFileSync37(join61(cwd, f.path), "utf-8") === f.raw;
|
|
300299
300378
|
} catch {
|
|
300300
300379
|
return false;
|
|
300301
300380
|
}
|
|
@@ -300305,7 +300384,7 @@ function resolveRepoPolicy(cwd, baseRef, tmpdir6, notes, skip) {
|
|
|
300305
300384
|
`the Rego policy differs from the base ref (${tree.ref}) \u2014 applying the BASE ${dir}/ so this change cannot relax the policy reviewing it. It takes effect once merged.`
|
|
300306
300385
|
);
|
|
300307
300386
|
}
|
|
300308
|
-
return { policyDir:
|
|
300387
|
+
return { policyDir: join61(root, dir), conftestCwd: root };
|
|
300309
300388
|
}
|
|
300310
300389
|
if (head) {
|
|
300311
300390
|
notes.push(
|
|
@@ -300315,7 +300394,7 @@ function resolveRepoPolicy(cwd, baseRef, tmpdir6, notes, skip) {
|
|
|
300315
300394
|
return null;
|
|
300316
300395
|
}
|
|
300317
300396
|
function findWorkflowPlanJson(cwd, notes) {
|
|
300318
|
-
const present = PLAN_JSON_NAMES.filter((name) => existsSync16(
|
|
300397
|
+
const present = PLAN_JSON_NAMES.filter((name) => existsSync16(join61(cwd, name)));
|
|
300319
300398
|
if (present.length === 0) return null;
|
|
300320
300399
|
const listing = run("git", ["ls-files", "-z"], cwd);
|
|
300321
300400
|
if (listing.status !== 0) {
|
|
@@ -300332,7 +300411,7 @@ function findWorkflowPlanJson(cwd, notes) {
|
|
|
300332
300411
|
);
|
|
300333
300412
|
continue;
|
|
300334
300413
|
}
|
|
300335
|
-
return
|
|
300414
|
+
return join61(cwd, name);
|
|
300336
300415
|
}
|
|
300337
300416
|
return null;
|
|
300338
300417
|
}
|
|
@@ -300362,7 +300441,7 @@ function evaluatePolicyGate(cwd, rawRules, opts = {}) {
|
|
|
300362
300441
|
let plan;
|
|
300363
300442
|
if (planPath) {
|
|
300364
300443
|
try {
|
|
300365
|
-
plan = asPlan(JSON.parse(
|
|
300444
|
+
plan = asPlan(JSON.parse(readFileSync37(planPath, "utf-8")));
|
|
300366
300445
|
} catch {
|
|
300367
300446
|
}
|
|
300368
300447
|
if (!plan) notes.push(`${planPath} is not a Terraform plan JSON \u2014 ignored`);
|
|
@@ -300465,7 +300544,7 @@ function capturePolicyGate(ctx) {
|
|
|
300465
300544
|
if (!result) return;
|
|
300466
300545
|
const workspace = process.env.GITHUB_WORKSPACE ?? cwd;
|
|
300467
300546
|
for (const o of [...result.violations, ...result.inconclusive]) {
|
|
300468
|
-
if (o.file) o.file = posix16(relative8(workspace,
|
|
300547
|
+
if (o.file) o.file = posix16(relative8(workspace, join61(cwd, o.file)));
|
|
300469
300548
|
}
|
|
300470
300549
|
session.policyGate = result;
|
|
300471
300550
|
for (const n of result.notes) log2.warning(`\xBB policy gate: ${n}`);
|
|
@@ -300800,7 +300879,7 @@ var ThinkingTimer = class {
|
|
|
300800
300879
|
// src/agents/claude.ts
|
|
300801
300880
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
300802
300881
|
import { chmodSync as chmodSync3, mkdirSync as mkdirSync10, writeFileSync as writeFileSync22 } from "node:fs";
|
|
300803
|
-
import { join as
|
|
300882
|
+
import { join as join70 } from "node:path";
|
|
300804
300883
|
import { performance as performance6 } from "node:perf_hooks";
|
|
300805
300884
|
import { setTimeout as sleep6 } from "node:timers/promises";
|
|
300806
300885
|
|
|
@@ -301160,7 +301239,7 @@ import { readFile as readFile2 } from "node:fs/promises";
|
|
|
301160
301239
|
|
|
301161
301240
|
// src/agents/shared.ts
|
|
301162
301241
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
301163
|
-
import { join as
|
|
301242
|
+
import { join as join62 } from "node:path";
|
|
301164
301243
|
var MAX_STDERR_LINES = 20;
|
|
301165
301244
|
var MAX_POST_RUN_RETRIES = 3;
|
|
301166
301245
|
function getGitStatus() {
|
|
@@ -301197,7 +301276,7 @@ var agent = (input2) => {
|
|
|
301197
301276
|
};
|
|
301198
301277
|
};
|
|
301199
301278
|
function agentHomeEnv(tmpdir6) {
|
|
301200
|
-
return { HOME: tmpdir6, XDG_CONFIG_HOME:
|
|
301279
|
+
return { HOME: tmpdir6, XDG_CONFIG_HOME: join62(tmpdir6, ".config") };
|
|
301201
301280
|
}
|
|
301202
301281
|
function baseAgentEnv(homeEnv, repoDir) {
|
|
301203
301282
|
return { ...process.env, ...homeEnv, PWD: repoDir };
|
|
@@ -301905,7 +301984,7 @@ function matchesRouteSentinel(envVar, model) {
|
|
|
301905
301984
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
301906
301985
|
import { mkdirSync as mkdirSync8, rmSync as rmSync11, writeFileSync as writeFileSync18 } from "node:fs";
|
|
301907
301986
|
import { homedir } from "node:os";
|
|
301908
|
-
import { join as
|
|
301987
|
+
import { join as join63 } from "node:path";
|
|
301909
301988
|
var VERTEX_SERVICE_ACCOUNT_JSON_ENV = "VERTEX_SERVICE_ACCOUNT_JSON";
|
|
301910
301989
|
var GOOGLE_APPLICATION_CREDENTIALS_ENV = "GOOGLE_APPLICATION_CREDENTIALS";
|
|
301911
301990
|
var GOOGLE_CLOUD_PROJECT_ENV = "GOOGLE_CLOUD_PROJECT";
|
|
@@ -301929,7 +302008,7 @@ function readProjectIdFromVertexServiceAccountJson() {
|
|
|
301929
302008
|
}
|
|
301930
302009
|
function createSecretDir() {
|
|
301931
302010
|
const base = process.env.INFRAWEAVER_SECRET_HOME || process.env.HOME || homedir();
|
|
301932
|
-
const secretDir =
|
|
302011
|
+
const secretDir = join63(base, `.${PRODUCT_SLUG}`, "secrets", randomUUID9());
|
|
301933
302012
|
mkdirSync8(secretDir, { recursive: true, mode: 448 });
|
|
301934
302013
|
return secretDir;
|
|
301935
302014
|
}
|
|
@@ -301938,7 +302017,7 @@ function materializeVertexCredentials(params) {
|
|
|
301938
302017
|
const blob = process.env[VERTEX_SERVICE_ACCOUNT_JSON_ENV];
|
|
301939
302018
|
if (!blob) return void 0;
|
|
301940
302019
|
const secretDir = createSecretDir();
|
|
301941
|
-
const credentialsPath =
|
|
302020
|
+
const credentialsPath = join63(secretDir, "vertex-sa.json");
|
|
301942
302021
|
writeFileSync18(credentialsPath, blob, { mode: 384 });
|
|
301943
302022
|
process.env[GOOGLE_APPLICATION_CREDENTIALS_ENV] = credentialsPath;
|
|
301944
302023
|
const projectId = readProjectIdFromVertexServiceAccountJson();
|
|
@@ -302074,15 +302153,15 @@ function createProcessOutputActivityTimeout(ctx) {
|
|
|
302074
302153
|
}
|
|
302075
302154
|
|
|
302076
302155
|
// src/utils/prompt/skills.ts
|
|
302077
|
-
import { existsSync as existsSync17, mkdirSync as mkdirSync9, readFileSync as
|
|
302078
|
-
import { dirname as dirname9, join as
|
|
302156
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync9, readFileSync as readFileSync38, writeFileSync as writeFileSync19 } from "node:fs";
|
|
302157
|
+
import { dirname as dirname9, join as join64 } from "node:path";
|
|
302079
302158
|
import { fileURLToPath } from "node:url";
|
|
302080
302159
|
var BUNDLED_SKILL_NAMES = ["terraform-best-practices"];
|
|
302081
302160
|
function resolveSkillPath(name) {
|
|
302082
302161
|
const here = dirname9(fileURLToPath(import.meta.url));
|
|
302083
302162
|
const candidates = [
|
|
302084
|
-
|
|
302085
|
-
|
|
302163
|
+
join64(here, "..", "..", "skills", name, "SKILL.md"),
|
|
302164
|
+
join64(here, "skills", name, "SKILL.md")
|
|
302086
302165
|
];
|
|
302087
302166
|
for (const candidate of candidates) {
|
|
302088
302167
|
if (existsSync17(candidate)) return candidate;
|
|
@@ -302092,11 +302171,11 @@ function resolveSkillPath(name) {
|
|
|
302092
302171
|
var SKILL_TARGET_DIRS = [".opencode/skills", ".claude/skills", ".agents/skills"];
|
|
302093
302172
|
function installBundledSkills(params) {
|
|
302094
302173
|
for (const name of BUNDLED_SKILL_NAMES) {
|
|
302095
|
-
const content =
|
|
302174
|
+
const content = readFileSync38(resolveSkillPath(name), "utf8");
|
|
302096
302175
|
for (const targetDir of SKILL_TARGET_DIRS) {
|
|
302097
|
-
const skillDir =
|
|
302176
|
+
const skillDir = join64(params.home, targetDir, name);
|
|
302098
302177
|
mkdirSync9(skillDir, { recursive: true });
|
|
302099
|
-
writeFileSync19(
|
|
302178
|
+
writeFileSync19(join64(skillDir, "SKILL.md"), content);
|
|
302100
302179
|
}
|
|
302101
302180
|
}
|
|
302102
302181
|
log2.success(`installed bundled skills: ${BUNDLED_SKILL_NAMES.join(", ")}`);
|
|
@@ -302105,8 +302184,8 @@ function installBundledSkills(params) {
|
|
|
302105
302184
|
// src/utils/setup/install.ts
|
|
302106
302185
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
302107
302186
|
import { createHash as createHash15 } from "node:crypto";
|
|
302108
|
-
import { chmodSync as chmodSync2, createWriteStream as createWriteStream2, existsSync as existsSync20, readFileSync as
|
|
302109
|
-
import { join as
|
|
302187
|
+
import { chmodSync as chmodSync2, createWriteStream as createWriteStream2, existsSync as existsSync20, readFileSync as readFileSync39 } from "node:fs";
|
|
302188
|
+
import { join as join69 } from "node:path";
|
|
302110
302189
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
302111
302190
|
|
|
302112
302191
|
// src/utils/setup/tarballCache.ts
|
|
@@ -302161,7 +302240,7 @@ function verifyTarballIntegrity(tarballPath, dist, descriptor) {
|
|
|
302161
302240
|
`Refusing to install ${descriptor}: the registry published no integrity digest (neither dist.integrity nor dist.shasum), so the download cannot be verified.`
|
|
302162
302241
|
);
|
|
302163
302242
|
}
|
|
302164
|
-
const bytes =
|
|
302243
|
+
const bytes = readFileSync39(tarballPath);
|
|
302165
302244
|
if (integrity2) {
|
|
302166
302245
|
const candidates = integrity2.trim().split(/\s+/).filter(Boolean);
|
|
302167
302246
|
for (const candidate of candidates) {
|
|
@@ -302190,8 +302269,8 @@ function verifyTarballIntegrity(tarballPath, dist, descriptor) {
|
|
|
302190
302269
|
}
|
|
302191
302270
|
async function installFromNpmTarball(params) {
|
|
302192
302271
|
const tempDir = getTempDir();
|
|
302193
|
-
const extractedDir =
|
|
302194
|
-
const cliPath =
|
|
302272
|
+
const extractedDir = join69(tempDir, "package");
|
|
302273
|
+
const cliPath = join69(extractedDir, params.executablePath);
|
|
302195
302274
|
if (existsSync20(cliPath)) {
|
|
302196
302275
|
log2.debug(`\xBB using cached binary at ${cliPath}`);
|
|
302197
302276
|
return cliPath;
|
|
@@ -302243,7 +302322,7 @@ async function installFromNpmTarball(params) {
|
|
|
302243
302322
|
dist = (await manifestResponse.json()).dist;
|
|
302244
302323
|
}
|
|
302245
302324
|
log2.debug(`\xBB installing ${params.packageName}@${resolvedVersion}...`);
|
|
302246
|
-
const tarballPath =
|
|
302325
|
+
const tarballPath = join69(tempDir, "package.tgz");
|
|
302247
302326
|
const tarballFileName = params.packageName.startsWith("@") ? params.packageName.split("/")[1] : params.packageName;
|
|
302248
302327
|
const tarballUrl = `${npmRegistry}/${encodedName}/-/${tarballFileName}-${resolvedVersion}.tgz`;
|
|
302249
302328
|
const restored = await restoreTarball({
|
|
@@ -302394,9 +302473,9 @@ var CLAUDE_DISALLOWED_TOOLS = CLAUDE_EXEC_TOOL_DENY_RULES.join(",");
|
|
|
302394
302473
|
var INFRAWEAVER_MCP_AUTH_HEADER = `Bearer \${${MCP_SERVER_TOKEN_ENV}}`;
|
|
302395
302474
|
var CLAUDE_MAX_CONCURRENT_SUBAGENTS_DEFAULT = "4";
|
|
302396
302475
|
function writeMcpConfig(ctx) {
|
|
302397
|
-
const configDir =
|
|
302476
|
+
const configDir = join70(ctx.tmpdir, ".claude");
|
|
302398
302477
|
mkdirSync10(configDir, { recursive: true });
|
|
302399
|
-
const configPath =
|
|
302478
|
+
const configPath = join70(configDir, "mcp.json");
|
|
302400
302479
|
const terraformMcp = resolveTerraformMcp(ctx.payload);
|
|
302401
302480
|
if (terraformMcp.kind === "docker_missing") log2.info(`\xBB ${terraformMcp.note}`);
|
|
302402
302481
|
const opentofuMcp = resolveOpenTofuMcp(ctx.payload);
|
|
@@ -302428,13 +302507,13 @@ function writeMcpConfig(ctx) {
|
|
|
302428
302507
|
return configPath;
|
|
302429
302508
|
}
|
|
302430
302509
|
function writePretoolGateAssets(ctx, stopHookPath) {
|
|
302431
|
-
const scriptPath =
|
|
302510
|
+
const scriptPath = join70(ctx.tmpdir, CLAUDE_PRETOOL_GATE_FILENAME);
|
|
302432
302511
|
writeFileSync22(
|
|
302433
302512
|
scriptPath,
|
|
302434
302513
|
buildClaudePretoolGateSource(ctx.subagentDeniedTools, writePolicyPath2(ctx.tmpdir))
|
|
302435
302514
|
);
|
|
302436
302515
|
chmodSync3(scriptPath, 493);
|
|
302437
|
-
const settingsPath =
|
|
302516
|
+
const settingsPath = join70(ctx.tmpdir, "infraweaver-claude-settings.json");
|
|
302438
302517
|
const settings = buildClaudePretoolGateSettings(scriptPath, CLAUDE_EXEC_TOOL_DENY_RULES);
|
|
302439
302518
|
settings.permissions.deny.push(...harnessTmpdirWriteDenyClaude(ctx.tmpdir));
|
|
302440
302519
|
if (stopHookPath) {
|
|
@@ -303059,11 +303138,11 @@ var claude = agent({
|
|
|
303059
303138
|
const onVertex = matchesRouteSentinel(VERTEX_MODEL_ID_ENV, specifier) && specifier !== void 0 && isVertexAnthropicId(specifier);
|
|
303060
303139
|
const model = !specifier ? void 0 : onBedrock ? specifier : onVertex ? void 0 : stripProviderPrefix(specifier);
|
|
303061
303140
|
const homeEnv = agentHomeEnv(ctx.tmpdir);
|
|
303062
|
-
mkdirSync10(
|
|
303141
|
+
mkdirSync10(join70(homeEnv.XDG_CONFIG_HOME, "claude"), { recursive: true });
|
|
303063
303142
|
installBundledSkills({ home: homeEnv.HOME });
|
|
303064
303143
|
const mcpConfigPath = writeMcpConfig(ctx);
|
|
303065
303144
|
const effort = resolveEffort(model);
|
|
303066
|
-
const stopHookPath =
|
|
303145
|
+
const stopHookPath = join70(ctx.tmpdir, "infraweaver-stop-hook.sh");
|
|
303067
303146
|
writeFileSync22(stopHookPath, buildStopHookScript(), { mode: 493 });
|
|
303068
303147
|
const pretoolGate = writePretoolGateAssets(ctx, stopHookPath);
|
|
303069
303148
|
installManagedSettings({
|
|
@@ -303229,7 +303308,7 @@ var claude = agent({
|
|
|
303229
303308
|
init_core();
|
|
303230
303309
|
import { spawn as nodeSpawn2 } from "node:child_process";
|
|
303231
303310
|
import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync24 } from "node:fs";
|
|
303232
|
-
import { join as
|
|
303311
|
+
import { join as join72 } from "node:path";
|
|
303233
303312
|
import { performance as performance7 } from "node:perf_hooks";
|
|
303234
303313
|
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
303235
303314
|
import { setTimeout as sleep7 } from "node:timers/promises";
|
|
@@ -308912,7 +308991,7 @@ function autoSelectModel() {
|
|
|
308912
308991
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
308913
308992
|
import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync23 } from "node:fs";
|
|
308914
308993
|
import { homedir as homedir3, userInfo as userInfo2 } from "node:os";
|
|
308915
|
-
import { join as
|
|
308994
|
+
import { join as join71 } from "node:path";
|
|
308916
308995
|
|
|
308917
308996
|
// src/utils/agent/codexOAuth.ts
|
|
308918
308997
|
init_webapi();
|
|
@@ -308966,8 +309045,8 @@ function installCodexAuth() {
|
|
|
308966
309045
|
}
|
|
308967
309046
|
const expiresMs = decodeJwtExpMs(body2.tokens.access_token) ?? 0;
|
|
308968
309047
|
const xdgDataHome = resolveDataHome();
|
|
308969
|
-
const opencodeDir =
|
|
308970
|
-
const authPath =
|
|
309048
|
+
const opencodeDir = join71(xdgDataHome, "opencode");
|
|
309049
|
+
const authPath = join71(opencodeDir, "auth.json");
|
|
308971
309050
|
const opencodeAuth = {
|
|
308972
309051
|
openai: {
|
|
308973
309052
|
type: "oauth",
|
|
@@ -308991,7 +309070,7 @@ function installCodexAuth() {
|
|
|
308991
309070
|
};
|
|
308992
309071
|
}
|
|
308993
309072
|
function resolveDataHome() {
|
|
308994
|
-
if (process.env.CI !== "true") return
|
|
309073
|
+
if (process.env.CI !== "true") return join71(homedir3(), ".local", "share");
|
|
308995
309074
|
bootstrapInfraweaverDataDir();
|
|
308996
309075
|
return INFRAWEAVER_DATA_DIR;
|
|
308997
309076
|
}
|
|
@@ -309732,10 +309811,10 @@ var opencode = agent({
|
|
|
309732
309811
|
const openAiCompatModel = resolveOpenAiCompatibleOpenCodeModel(rawModel);
|
|
309733
309812
|
const model = isBedrockRoute ? `amazon-bedrock/${rawModel}` : vertexModel ?? openAiCompatModel ?? rawModel;
|
|
309734
309813
|
const homeEnv = agentHomeEnv(ctx.tmpdir);
|
|
309735
|
-
const opencodePluginDir =
|
|
309814
|
+
const opencodePluginDir = join72(homeEnv.XDG_CONFIG_HOME, "opencode", "plugin");
|
|
309736
309815
|
mkdirSync12(opencodePluginDir, { recursive: true });
|
|
309737
309816
|
writeFileSync24(
|
|
309738
|
-
|
|
309817
|
+
join72(opencodePluginDir, INFRAWEAVER_OPENCODE_GATE_PLUGIN_FILENAME),
|
|
309739
309818
|
buildOpencodeSubagentGateSource(ctx.subagentDeniedTools, writePolicyPath2(ctx.tmpdir))
|
|
309740
309819
|
);
|
|
309741
309820
|
installBundledSkills({ home: homeEnv.HOME });
|
|
@@ -310671,7 +310750,7 @@ async function fetchRunContext(params) {
|
|
|
310671
310750
|
// src/utils/github/github.ts
|
|
310672
310751
|
init_core();
|
|
310673
310752
|
import { rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
|
|
310674
|
-
import { dirname as dirname12, join as
|
|
310753
|
+
import { dirname as dirname12, join as join73 } from "node:path";
|
|
310675
310754
|
|
|
310676
310755
|
// node_modules/.pnpm/universal-user-agent@7.0.3/node_modules/universal-user-agent/index.js
|
|
310677
310756
|
function getUserAgent2() {
|
|
@@ -316487,7 +316566,7 @@ function getGitHubUsageSummary() {
|
|
|
316487
316566
|
}
|
|
316488
316567
|
async function writeGitHubUsageSummaryToFile(path15) {
|
|
316489
316568
|
const summary2 = getGitHubUsageSummary();
|
|
316490
|
-
const tmpPath =
|
|
316569
|
+
const tmpPath = join73(dirname12(path15), `.usage-summary-${process.pid}.tmp`);
|
|
316491
316570
|
await writeFile2(tmpPath, JSON.stringify(summary2));
|
|
316492
316571
|
await rename2(tmpPath, path15);
|
|
316493
316572
|
}
|
|
@@ -317032,7 +317111,7 @@ async function resolveModelAndAuth(params) {
|
|
|
317032
317111
|
// src/utils/run/runLifecycle.ts
|
|
317033
317112
|
init_core();
|
|
317034
317113
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
317035
|
-
import { join as
|
|
317114
|
+
import { join as join76, resolve as resolve13 } from "node:path";
|
|
317036
317115
|
|
|
317037
317116
|
// src/utils/cloud/cloudReport.ts
|
|
317038
317117
|
init_core();
|
|
@@ -317426,7 +317505,7 @@ async function reportToCloud(input2) {
|
|
|
317426
317505
|
|
|
317427
317506
|
// src/utils/cloud/learnings.ts
|
|
317428
317507
|
import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
|
|
317429
|
-
import { dirname as dirname13, join as
|
|
317508
|
+
import { dirname as dirname13, join as join74 } from "node:path";
|
|
317430
317509
|
|
|
317431
317510
|
// src/utils/cloud/learningsTruncate.ts
|
|
317432
317511
|
var MAX_LEARNINGS_LENGTH = 1e5;
|
|
@@ -317443,7 +317522,7 @@ function truncateAtLineBoundary(body2, cap2) {
|
|
|
317443
317522
|
// src/utils/cloud/learnings.ts
|
|
317444
317523
|
var LEARNINGS_FILE_NAME = LEARNINGS_FILE;
|
|
317445
317524
|
function learningsFilePath(tmpdir6) {
|
|
317446
|
-
return
|
|
317525
|
+
return join74(tmpdir6, LEARNINGS_FILE_NAME);
|
|
317447
317526
|
}
|
|
317448
317527
|
async function seedLearningsFile(params) {
|
|
317449
317528
|
const path15 = learningsFilePath(params.tmpdir);
|
|
@@ -317574,7 +317653,7 @@ ${ctx.error}` : ctx.error;
|
|
|
317574
317653
|
|
|
317575
317654
|
// src/utils/github/prSummary.ts
|
|
317576
317655
|
import { mkdir as mkdir4, readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
|
|
317577
|
-
import { dirname as dirname14, join as
|
|
317656
|
+
import { dirname as dirname14, join as join75 } from "node:path";
|
|
317578
317657
|
var SUMMARY_FILE_NAME = SUMMARY_FILE;
|
|
317579
317658
|
var SUMMARY_SCAFFOLD = `# PR summary
|
|
317580
317659
|
|
|
@@ -317584,7 +317663,7 @@ var SUMMARY_SCAFFOLD = `# PR summary
|
|
|
317584
317663
|
var MIN_SNAPSHOT_LENGTH = 60;
|
|
317585
317664
|
var MAX_SNAPSHOT_LENGTH = 32768;
|
|
317586
317665
|
function summaryFilePath(tmpdir6) {
|
|
317587
|
-
return
|
|
317666
|
+
return join75(tmpdir6, SUMMARY_FILE_NAME);
|
|
317588
317667
|
}
|
|
317589
317668
|
async function seedSummaryFile(params) {
|
|
317590
317669
|
const path15 = summaryFilePath(params.tmpdir);
|
|
@@ -318118,7 +318197,7 @@ async function emitFindingsOutputs(toolState, requiredControls) {
|
|
|
318118
318197
|
if (a.level === "error") error(a.message, props);
|
|
318119
318198
|
else warning(a.message, props);
|
|
318120
318199
|
}
|
|
318121
|
-
const sarifPath =
|
|
318200
|
+
const sarifPath = join76(workspace, SARIF_FILE);
|
|
318122
318201
|
if (session.emittedSarifPath && resolve13(session.emittedSarifPath) === resolve13(sarifPath)) {
|
|
318123
318202
|
log2.info(`\xBB findings output: replacing the agent-emitted ${SARIF_FILE} with the gate's`);
|
|
318124
318203
|
}
|
|
@@ -318550,7 +318629,7 @@ async function runAgentWithWatchdogs(params) {
|
|
|
318550
318629
|
// src/phases/startToolPlane.ts
|
|
318551
318630
|
import { existsSync as existsSync21, readdirSync as readdirSync11 } from "node:fs";
|
|
318552
318631
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
318553
|
-
import { join as
|
|
318632
|
+
import { join as join77 } from "node:path";
|
|
318554
318633
|
|
|
318555
318634
|
// src/utils/cloud/runTerminalStatus.ts
|
|
318556
318635
|
var TERMINAL_STATE_KEY = "run_terminal";
|
|
@@ -319378,7 +319457,7 @@ ${instructions.user}` : null,
|
|
|
319378
319457
|
log2.info(instructions.full);
|
|
319379
319458
|
});
|
|
319380
319459
|
if (toolContext.agentId === "opencode") {
|
|
319381
|
-
const pluginDir =
|
|
319460
|
+
const pluginDir = join77(process.cwd(), ".opencode", "plugin");
|
|
319382
319461
|
const hasPlugins = existsSync21(pluginDir) && readdirSync11(pluginDir).some((f) => /\.[jt]sx?$/.test(f));
|
|
319383
319462
|
if (hasPlugins && toolState.dependencyInstallation?.promise) {
|
|
319384
319463
|
log2.info(
|
|
@@ -319971,7 +320050,7 @@ async function runMcpCli(params) {
|
|
|
319971
320050
|
}
|
|
319972
320051
|
|
|
319973
320052
|
// node_modules/.pnpm/@infraweaver-io+attest@0.1.7_supports-color@7.2.0/node_modules/@infraweaver-io/attest/dist/verifyEvidence.js
|
|
319974
|
-
import { readFileSync as
|
|
320053
|
+
import { readFileSync as readFileSync40 } from "node:fs";
|
|
319975
320054
|
function usageLine(params) {
|
|
319976
320055
|
const command = params.command ? `${params.command} ` : "";
|
|
319977
320056
|
return `usage: ${params.prog} ${command}<bundle> <sig> <pubkey>`;
|
|
@@ -319989,7 +320068,7 @@ function printUsage(params, stream2) {
|
|
|
319989
320068
|
}
|
|
319990
320069
|
function readFileOrExit(path15, what) {
|
|
319991
320070
|
try {
|
|
319992
|
-
return
|
|
320071
|
+
return readFileSync40(path15);
|
|
319993
320072
|
} catch (e) {
|
|
319994
320073
|
console.error(`could not read the ${what} at ${path15}: ${errorMessage(e)}`);
|
|
319995
320074
|
process.exit(1);
|
|
@@ -320037,7 +320116,7 @@ async function runVerifyEvidenceCli2(params) {
|
|
|
320037
320116
|
}
|
|
320038
320117
|
|
|
320039
320118
|
// src/cli.ts
|
|
320040
|
-
var VERSION14 = "0.3.
|
|
320119
|
+
var VERSION14 = "0.3.12";
|
|
320041
320120
|
var bin = basename9(process.argv[1] || "");
|
|
320042
320121
|
var PROG = bin === "pf" || bin === PRODUCT_SLUG ? bin : PRODUCT_SLUG;
|
|
320043
320122
|
var rawArgs = process.argv.slice(2);
|