tamperward 2.39.8 → 2.39.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +139 -120
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -10697,7 +10697,6 @@ var init_engine = __esm({
|
|
|
10697
10697
|
});
|
|
10698
10698
|
|
|
10699
10699
|
// src/policy-load.ts
|
|
10700
|
-
import { readFileSync as readFileSync5, existsSync as existsSync5 } from "node:fs";
|
|
10701
10700
|
import { isAbsolute as isAbsolute7, join as join8, posix as posix3 } from "node:path";
|
|
10702
10701
|
function normalizeVersion(v, where = POLICY_FILE) {
|
|
10703
10702
|
if (v === void 0 || v === null) return 1;
|
|
@@ -10869,10 +10868,29 @@ function parseOrThrow(src, where) {
|
|
|
10869
10868
|
}
|
|
10870
10869
|
return parsePolicy(raw, where);
|
|
10871
10870
|
}
|
|
10871
|
+
function notARegularFile(e) {
|
|
10872
|
+
switch (e.kind) {
|
|
10873
|
+
case "symlink":
|
|
10874
|
+
return `is a symbolic link to ${escapeControl(e.detail)}`;
|
|
10875
|
+
case "directory":
|
|
10876
|
+
return "is a directory";
|
|
10877
|
+
case "irregular":
|
|
10878
|
+
return `is a ${e.detail}`;
|
|
10879
|
+
case "oversize":
|
|
10880
|
+
return `is ${e.detail}, above the ${READ_CAP / (1024 * 1024)} MiB the gate reads`;
|
|
10881
|
+
default:
|
|
10882
|
+
return `cannot be read (${e.detail})`;
|
|
10883
|
+
}
|
|
10884
|
+
}
|
|
10872
10885
|
function loadPolicy(cwd = process.cwd()) {
|
|
10873
|
-
const
|
|
10874
|
-
if (
|
|
10875
|
-
|
|
10886
|
+
const entry = inspectPath(join8(repoRoot(cwd), POLICY_FILE));
|
|
10887
|
+
if (entry.kind === "absent") return defaultPolicy();
|
|
10888
|
+
if (entry.kind !== "file") {
|
|
10889
|
+
throw new PolicyError(
|
|
10890
|
+
`${POLICY_FILE} ${notARegularFile(entry)}; the policy is read only as a regular file at the repository root \u2014 put one there (no symbolic link, FIFO, socket, device or directory) or remove it`
|
|
10891
|
+
);
|
|
10892
|
+
}
|
|
10893
|
+
return parseOrThrow(textOf2(entry) ?? "", POLICY_FILE);
|
|
10876
10894
|
}
|
|
10877
10895
|
function loadPolicyAt(rev2, cwd) {
|
|
10878
10896
|
const src = fileAt(rev2, POLICY_FILE, { cwd: cwd === void 0 ? void 0 : repoRoot(cwd) });
|
|
@@ -10886,6 +10904,7 @@ var init_policy_load = __esm({
|
|
|
10886
10904
|
init_lazy_deps();
|
|
10887
10905
|
init_policy();
|
|
10888
10906
|
init_build();
|
|
10907
|
+
init_disk();
|
|
10889
10908
|
init_narrow();
|
|
10890
10909
|
init_repo_context();
|
|
10891
10910
|
PolicyError = class extends Error {
|
|
@@ -10900,7 +10919,7 @@ var init_policy_load = __esm({
|
|
|
10900
10919
|
|
|
10901
10920
|
// src/signoff.ts
|
|
10902
10921
|
import { createHash as createHash3 } from "node:crypto";
|
|
10903
|
-
import { appendFileSync, closeSync as closeSync2, constants as constants3, fstatSync as fstatSync2, lstatSync as lstatSync3, mkdirSync, openSync as openSync2, readFileSync as
|
|
10922
|
+
import { appendFileSync, closeSync as closeSync2, constants as constants3, fstatSync as fstatSync2, lstatSync as lstatSync3, mkdirSync, openSync as openSync2, readFileSync as readFileSync5 } from "node:fs";
|
|
10904
10923
|
import { dirname as dirname2, join as join9, posix as posix4 } from "node:path";
|
|
10905
10924
|
function compactOobToken(want, head) {
|
|
10906
10925
|
const normalizedHead = head.trim().toLowerCase();
|
|
@@ -10983,7 +11002,7 @@ function readLedger(cwd, policy) {
|
|
|
10983
11002
|
const fd = openLedger(rel, path, constants3.O_RDONLY);
|
|
10984
11003
|
let text;
|
|
10985
11004
|
try {
|
|
10986
|
-
text =
|
|
11005
|
+
text = readFileSync5(fd, "utf8");
|
|
10987
11006
|
} finally {
|
|
10988
11007
|
closeSync2(fd);
|
|
10989
11008
|
}
|
|
@@ -11534,7 +11553,7 @@ var init_deny = __esm({
|
|
|
11534
11553
|
});
|
|
11535
11554
|
|
|
11536
11555
|
// src/session.ts
|
|
11537
|
-
import { existsSync as
|
|
11556
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync6, renameSync, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
11538
11557
|
import { dirname as dirname3, join as join10 } from "node:path";
|
|
11539
11558
|
function writeBaseline(p, sha3) {
|
|
11540
11559
|
mkdirSync2(dirname3(p), { recursive: true });
|
|
@@ -11560,8 +11579,8 @@ function turnBaseline(cwd, sessionId) {
|
|
|
11560
11579
|
const p = baselinePath(cwd, sessionId);
|
|
11561
11580
|
if (!p) return null;
|
|
11562
11581
|
try {
|
|
11563
|
-
if (
|
|
11564
|
-
const v =
|
|
11582
|
+
if (existsSync5(p)) {
|
|
11583
|
+
const v = readFileSync6(p, "utf8").trim();
|
|
11565
11584
|
if (SHA.test(v)) return v;
|
|
11566
11585
|
}
|
|
11567
11586
|
} catch {
|
|
@@ -11604,7 +11623,7 @@ var init_session = __esm({
|
|
|
11604
11623
|
|
|
11605
11624
|
// src/effect.ts
|
|
11606
11625
|
import { createHash as createHash4 } from "node:crypto";
|
|
11607
|
-
import { existsSync as
|
|
11626
|
+
import { existsSync as existsSync6, lstatSync as lstatSync4, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync7, renameSync as renameSync2, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
11608
11627
|
import { join as join11 } from "node:path";
|
|
11609
11628
|
function ptreeFrom(value) {
|
|
11610
11629
|
if (!isRecord(value)) return null;
|
|
@@ -11696,9 +11715,9 @@ function driftBetween(expected, current) {
|
|
|
11696
11715
|
return { changed, deleted, added };
|
|
11697
11716
|
}
|
|
11698
11717
|
function loadTree(p) {
|
|
11699
|
-
if (!p || !
|
|
11718
|
+
if (!p || !existsSync6(p)) return null;
|
|
11700
11719
|
try {
|
|
11701
|
-
return ptreeFrom(JSON.parse(
|
|
11720
|
+
return ptreeFrom(JSON.parse(readFileSync7(p, "utf8")));
|
|
11702
11721
|
} catch {
|
|
11703
11722
|
return null;
|
|
11704
11723
|
}
|
|
@@ -11751,7 +11770,7 @@ var init_effect = __esm({
|
|
|
11751
11770
|
});
|
|
11752
11771
|
|
|
11753
11772
|
// src/cli/watch.ts
|
|
11754
|
-
import { appendFileSync as appendFileSync3, lstatSync as lstatSync5, mkdirSync as mkdirSync4, readFileSync as
|
|
11773
|
+
import { appendFileSync as appendFileSync3, lstatSync as lstatSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync8, readdirSync as readdirSync2, watch, writeFileSync as writeFileSync4 } from "node:fs";
|
|
11755
11774
|
import { join as join12 } from "node:path";
|
|
11756
11775
|
import { createHash as createHash5 } from "node:crypto";
|
|
11757
11776
|
function snap(abs) {
|
|
@@ -11770,7 +11789,7 @@ function watcherHealthPath(log) {
|
|
|
11770
11789
|
}
|
|
11771
11790
|
function readWatcherHealth(log) {
|
|
11772
11791
|
try {
|
|
11773
|
-
const value = JSON.parse(
|
|
11792
|
+
const value = JSON.parse(readFileSync8(watcherHealthPath(log), "utf8"));
|
|
11774
11793
|
if (!isRecord(value)) return null;
|
|
11775
11794
|
const { state, backend, pid, started_at } = value;
|
|
11776
11795
|
if (value.version !== 1 || typeof pid !== "number" || typeof started_at !== "string") return null;
|
|
@@ -12298,7 +12317,7 @@ var init_fs_events = __esm({
|
|
|
12298
12317
|
|
|
12299
12318
|
// src/cli/audit.ts
|
|
12300
12319
|
import { createHash as createHash6, randomBytes } from "node:crypto";
|
|
12301
|
-
import { appendFileSync as appendFileSync4, closeSync as closeSync4, existsSync as
|
|
12320
|
+
import { appendFileSync as appendFileSync4, closeSync as closeSync4, existsSync as existsSync7, mkdirSync as mkdirSync5, openSync as openSync4, readSync as readSync3 } from "node:fs";
|
|
12302
12321
|
import { dirname as dirname4, isAbsolute as isAbsolute8, join as join13, resolve as resolve4 } from "node:path";
|
|
12303
12322
|
function sessionHash(sessionId) {
|
|
12304
12323
|
if (!sessionId) return void 0;
|
|
@@ -12557,7 +12576,7 @@ function runStats(opts = {}) {
|
|
|
12557
12576
|
const file = opts.file ? isAbsolute8(opts.file) ? opts.file : resolve4(cwd, opts.file) : configured && configured !== "auto" ? isAbsolute8(configured) ? configured : resolve4(cwd, configured) : defaultAuditPath(cwd);
|
|
12558
12577
|
const cutoff = opts.since ? parseSince(opts.since) : null;
|
|
12559
12578
|
if (!file) throw new Error("stats needs --file outside a Git repository");
|
|
12560
|
-
if (!
|
|
12579
|
+
if (!existsSync7(file)) {
|
|
12561
12580
|
if (explicitFile) throw new Error(`audit file not found: ${file}`);
|
|
12562
12581
|
const empty2 = summarizeAudit([]);
|
|
12563
12582
|
process.stdout.write(opts.json ? JSON.stringify(empty2) + "\n" : renderAuditStats(empty2));
|
|
@@ -12596,14 +12615,14 @@ var init_audit = __esm({
|
|
|
12596
12615
|
});
|
|
12597
12616
|
|
|
12598
12617
|
// src/cli/hook.ts
|
|
12599
|
-
import { readFileSync as
|
|
12618
|
+
import { readFileSync as readFileSync9, appendFileSync as appendFileSync5, writeFileSync as writeFileSync5, existsSync as existsSync8 } from "node:fs";
|
|
12600
12619
|
import { createHash as createHash7 } from "node:crypto";
|
|
12601
12620
|
function setSnapshotCache(cache3) {
|
|
12602
12621
|
snapshotCache = cache3;
|
|
12603
12622
|
}
|
|
12604
12623
|
function readStdin() {
|
|
12605
12624
|
try {
|
|
12606
|
-
return
|
|
12625
|
+
return readFileSync9(0, "utf8");
|
|
12607
12626
|
} catch (e) {
|
|
12608
12627
|
throw new HookInputError(`cannot read the hook payload on stdin: ${e instanceof Error ? e.message : String(e)}`);
|
|
12609
12628
|
}
|
|
@@ -12893,10 +12912,10 @@ function turnTransientBlocks(cwd, sessionId, policy, changes) {
|
|
|
12893
12912
|
recordObserverHealth(cwd, sessionId, telemetry.state, telemetry.reason);
|
|
12894
12913
|
}
|
|
12895
12914
|
const cp = cursorPath(cwd, sessionId);
|
|
12896
|
-
if (!
|
|
12915
|
+
if (!existsSync8(log)) return none;
|
|
12897
12916
|
let offset = 0;
|
|
12898
|
-
if (cp &&
|
|
12899
|
-
const n2 = Number(
|
|
12917
|
+
if (cp && existsSync8(cp)) {
|
|
12918
|
+
const n2 = Number(readFileSync9(cp, "utf8"));
|
|
12900
12919
|
offset = Number.isFinite(n2) ? n2 : 0;
|
|
12901
12920
|
}
|
|
12902
12921
|
const drained = drainEvents(log, offset);
|
|
@@ -13170,13 +13189,13 @@ var init_ptree_cache = __esm({
|
|
|
13170
13189
|
});
|
|
13171
13190
|
|
|
13172
13191
|
// src/cli/hook-service.ts
|
|
13173
|
-
import { chmodSync, existsSync as
|
|
13192
|
+
import { chmodSync, existsSync as existsSync9, lstatSync as lstatSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync10, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "node:fs";
|
|
13174
13193
|
import { createConnection as createConnection2, createServer } from "node:net";
|
|
13175
13194
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
13176
13195
|
import { sep } from "node:path";
|
|
13177
13196
|
function readServiceState(paths) {
|
|
13178
13197
|
try {
|
|
13179
|
-
const v = JSON.parse(
|
|
13198
|
+
const v = JSON.parse(readFileSync10(paths.state, "utf8"));
|
|
13180
13199
|
if (!isRecord(v)) return null;
|
|
13181
13200
|
const { pid, version, root, started_at } = v;
|
|
13182
13201
|
if (typeof pid !== "number" || typeof version !== "string" || typeof root !== "string" || typeof started_at !== "string") return null;
|
|
@@ -13258,7 +13277,7 @@ function removeQuietly(p) {
|
|
|
13258
13277
|
}
|
|
13259
13278
|
}
|
|
13260
13279
|
function ensurePrivateDir(dir, uid) {
|
|
13261
|
-
if (!
|
|
13280
|
+
if (!existsSync9(dir)) mkdirSync6(dir, { recursive: true, mode: 448 });
|
|
13262
13281
|
const st = lstatSync7(dir);
|
|
13263
13282
|
if (!st.isDirectory()) throw new Error(`${dir} is not a directory`);
|
|
13264
13283
|
if (st.uid !== uid) throw new Error(`${dir} is owned by uid ${st.uid}, not ${uid}; refusing to serve from it`);
|
|
@@ -13455,7 +13474,7 @@ async function stopHookService(paths, expectedRoot) {
|
|
|
13455
13474
|
process.kill(st.pid, "SIGTERM");
|
|
13456
13475
|
} catch {
|
|
13457
13476
|
}
|
|
13458
|
-
const gone = () => !pidAlive2(st.pid) || !
|
|
13477
|
+
const gone = () => !pidAlive2(st.pid) || !existsSync9(paths.socket);
|
|
13459
13478
|
const until = Date.now() + STOP_WAIT_MS;
|
|
13460
13479
|
while (!gone() && Date.now() < until) sleepSync(50);
|
|
13461
13480
|
if (!gone()) throw new Error(`hook service pid ${st.pid} did not exit within ${STOP_WAIT_MS / 1e3}s`);
|
|
@@ -13737,7 +13756,7 @@ var init_safe_write = __esm({
|
|
|
13737
13756
|
// src/cli/init.ts
|
|
13738
13757
|
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
13739
13758
|
import { createHash as createHash8 } from "node:crypto";
|
|
13740
|
-
import { existsSync as
|
|
13759
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync11, realpathSync as realpathSync5 } from "node:fs";
|
|
13741
13760
|
import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute9, join as join15, relative as relative4, resolve as resolve6 } from "node:path";
|
|
13742
13761
|
function gitConfig(cwd, key2) {
|
|
13743
13762
|
try {
|
|
@@ -13831,34 +13850,34 @@ function verifierCandidates(cwd) {
|
|
|
13831
13850
|
if (!candidates.includes(command)) candidates.push(command);
|
|
13832
13851
|
};
|
|
13833
13852
|
try {
|
|
13834
|
-
const pkg = JSON.parse(
|
|
13853
|
+
const pkg = JSON.parse(readFileSync11(join15(cwd, "package.json"), "utf8"));
|
|
13835
13854
|
const test = isRecord(pkg) && isRecord(pkg.scripts) ? pkg.scripts.test : void 0;
|
|
13836
13855
|
if (typeof test === "string" && test.trim() !== "" && !/error:\s*no test specified/i.test(test)) add("npm test");
|
|
13837
13856
|
} catch {
|
|
13838
13857
|
}
|
|
13839
13858
|
try {
|
|
13840
|
-
const pyproject =
|
|
13859
|
+
const pyproject = readFileSync11(join15(cwd, "pyproject.toml"), "utf8");
|
|
13841
13860
|
if (/^\s*\[tool\.pytest(?:\.ini_options)?\]\s*$/m.test(pyproject)) add("pytest");
|
|
13842
13861
|
} catch {
|
|
13843
13862
|
}
|
|
13844
|
-
if (
|
|
13863
|
+
if (existsSync10(join15(cwd, "pytest.ini"))) add("pytest");
|
|
13845
13864
|
try {
|
|
13846
|
-
const setupCfg =
|
|
13865
|
+
const setupCfg = readFileSync11(join15(cwd, "setup.cfg"), "utf8");
|
|
13847
13866
|
if (/^\s*\[tool:pytest\]\s*$/m.test(setupCfg)) add("pytest");
|
|
13848
13867
|
} catch {
|
|
13849
13868
|
}
|
|
13850
13869
|
try {
|
|
13851
|
-
const tox =
|
|
13870
|
+
const tox = readFileSync11(join15(cwd, "tox.ini"), "utf8");
|
|
13852
13871
|
if (/^\s*\[tox\]\s*$/m.test(tox)) add("tox");
|
|
13853
13872
|
} catch {
|
|
13854
13873
|
}
|
|
13855
13874
|
try {
|
|
13856
|
-
const cargo =
|
|
13875
|
+
const cargo = readFileSync11(join15(cwd, "Cargo.toml"), "utf8");
|
|
13857
13876
|
if (/^\s*\[(?:package|workspace)\]\s*(?:#.*)?$/m.test(cargo)) add("cargo test");
|
|
13858
13877
|
} catch {
|
|
13859
13878
|
}
|
|
13860
13879
|
try {
|
|
13861
|
-
const goMod =
|
|
13880
|
+
const goMod = readFileSync11(join15(cwd, "go.mod"), "utf8");
|
|
13862
13881
|
if (/^\s*module\s+\S+\s*(?:\/\/.*)?$/m.test(goMod)) add("go test ./...");
|
|
13863
13882
|
} catch {
|
|
13864
13883
|
}
|
|
@@ -13901,7 +13920,7 @@ function planPolicy(cwd) {
|
|
|
13901
13920
|
const path = join15(cwd, POLICY_FILE);
|
|
13902
13921
|
const refused = refuseNonRegular(path);
|
|
13903
13922
|
if (refused) return { item: "policy", path: POLICY_FILE, status: "error", detail: refused };
|
|
13904
|
-
if (
|
|
13923
|
+
if (existsSync10(path)) {
|
|
13905
13924
|
try {
|
|
13906
13925
|
loadPolicy(cwd);
|
|
13907
13926
|
} catch (e) {
|
|
@@ -13920,7 +13939,7 @@ function planPolicy(cwd) {
|
|
|
13920
13939
|
function planGitignore(cwd) {
|
|
13921
13940
|
const rel = ".gitignore";
|
|
13922
13941
|
const path = join15(cwd, rel);
|
|
13923
|
-
if (!
|
|
13942
|
+
if (!existsSync10(join15(cwd, "node_modules"))) return null;
|
|
13924
13943
|
let existing = "";
|
|
13925
13944
|
let kind;
|
|
13926
13945
|
try {
|
|
@@ -13930,7 +13949,7 @@ function planGitignore(cwd) {
|
|
|
13930
13949
|
}
|
|
13931
13950
|
const refused = refuseNonRegular(path);
|
|
13932
13951
|
if (refused) return { item: "gitignore", path: rel, status: "error", detail: refused };
|
|
13933
|
-
if (kind === "file") existing =
|
|
13952
|
+
if (kind === "file") existing = readFileSync11(path, "utf8");
|
|
13934
13953
|
try {
|
|
13935
13954
|
const tracked = execFileSync6("git", ["ls-files", "--cached", "--", "node_modules"], {
|
|
13936
13955
|
cwd,
|
|
@@ -13985,10 +14004,10 @@ function planClaudeHooks(cwd) {
|
|
|
13985
14004
|
const refused = refuseNonRegular(path);
|
|
13986
14005
|
if (refused) return { item: "agent", path: rel, status: "error", detail: refused };
|
|
13987
14006
|
let settings = {};
|
|
13988
|
-
if (
|
|
14007
|
+
if (existsSync10(path)) {
|
|
13989
14008
|
let parsed;
|
|
13990
14009
|
try {
|
|
13991
|
-
parsed = JSON.parse(
|
|
14010
|
+
parsed = JSON.parse(readFileSync11(path, "utf8"));
|
|
13992
14011
|
} catch {
|
|
13993
14012
|
return {
|
|
13994
14013
|
item: "agent",
|
|
@@ -14037,7 +14056,7 @@ function planClaudeHooks(cwd) {
|
|
|
14037
14056
|
return {
|
|
14038
14057
|
item: "agent",
|
|
14039
14058
|
path: rel,
|
|
14040
|
-
status:
|
|
14059
|
+
status: existsSync10(path) ? "update" : "create",
|
|
14041
14060
|
detail: [
|
|
14042
14061
|
needPre && "wire PreToolUse deny",
|
|
14043
14062
|
needStop && "wire Stop sweep",
|
|
@@ -14081,7 +14100,7 @@ function hooksDir(cwd) {
|
|
|
14081
14100
|
if (out3) return resolve6(cwd, out3);
|
|
14082
14101
|
} catch {
|
|
14083
14102
|
}
|
|
14084
|
-
return
|
|
14103
|
+
return existsSync10(join15(cwd, ".git")) ? join15(cwd, ".git", "hooks") : null;
|
|
14085
14104
|
}
|
|
14086
14105
|
function display(cwd, path) {
|
|
14087
14106
|
const rel = relative4(cwd, path);
|
|
@@ -14108,11 +14127,11 @@ function planPreCommit(cwd) {
|
|
|
14108
14127
|
const skip = (detail) => ({ item: "pre-commit", path: "(none)", status: "skip", detail });
|
|
14109
14128
|
let path;
|
|
14110
14129
|
let note;
|
|
14111
|
-
if (
|
|
14130
|
+
if (existsSync10(join15(cwd, ".husky"))) {
|
|
14112
14131
|
path = join15(cwd, ".husky", "pre-commit");
|
|
14113
14132
|
note = "husky";
|
|
14114
14133
|
} else {
|
|
14115
|
-
const managed = MANAGED_HOOKS.find((m) => m.configs.some((c) =>
|
|
14134
|
+
const managed = MANAGED_HOOKS.find((m) => m.configs.some((c) => existsSync10(join15(cwd, c))));
|
|
14116
14135
|
if (managed) {
|
|
14117
14136
|
return skip(`${managed.name} manages this repository's hooks and regenerates them on install, so a line in the hooks directory would not last \u2014 ${managed.hint}`);
|
|
14118
14137
|
}
|
|
@@ -14130,7 +14149,7 @@ function planPreCommit(cwd) {
|
|
|
14130
14149
|
const rel = display(cwd, path);
|
|
14131
14150
|
const refused = refuseNonRegular(path);
|
|
14132
14151
|
if (refused) return { item: "pre-commit", path: rel, status: "error", detail: refused };
|
|
14133
|
-
const existing =
|
|
14152
|
+
const existing = existsSync10(path) ? readFileSync11(path, "utf8") : null;
|
|
14134
14153
|
const hookMode = () => existingMode(path, 493) | 73;
|
|
14135
14154
|
if (existing === null) {
|
|
14136
14155
|
return {
|
|
@@ -14221,7 +14240,7 @@ function planCodeowners(cwd) {
|
|
|
14221
14240
|
const path = join15(cwd, existingRel ?? rel);
|
|
14222
14241
|
const refused = refuseNonRegular(path);
|
|
14223
14242
|
if (refused) return { item: "codeowners", path: existingRel ?? rel, status: "error", detail: refused };
|
|
14224
|
-
const existing = existingRel ?
|
|
14243
|
+
const existing = existingRel ? readFileSync11(path, "utf8") : null;
|
|
14225
14244
|
const missing = CODEOWNERS_PATHS.filter((p) => existing === null || !coveredBy(existing, p));
|
|
14226
14245
|
if (existingRel !== void 0 && missing.length === 0) {
|
|
14227
14246
|
return { item: "codeowners", path: existingRel, status: "ok", detail: "gate paths already have code owners" };
|
|
@@ -14261,7 +14280,7 @@ function planWorkflow(cwd, force) {
|
|
|
14261
14280
|
};
|
|
14262
14281
|
const refused = refuseNonRegular(path);
|
|
14263
14282
|
if (refused) return { item: "ci", path: rel, status: "error", detail: refused };
|
|
14264
|
-
if (!
|
|
14283
|
+
if (!existsSync10(path)) {
|
|
14265
14284
|
return {
|
|
14266
14285
|
item: "ci",
|
|
14267
14286
|
path: rel,
|
|
@@ -14272,7 +14291,7 @@ function planWorkflow(cwd, force) {
|
|
|
14272
14291
|
}
|
|
14273
14292
|
let src;
|
|
14274
14293
|
try {
|
|
14275
|
-
src =
|
|
14294
|
+
src = readFileSync11(path, "utf8");
|
|
14276
14295
|
} catch {
|
|
14277
14296
|
return { item: "ci", path: rel, status: "error", detail: "exists but cannot be read \u2014 refusing to overwrite" };
|
|
14278
14297
|
}
|
|
@@ -14619,10 +14638,10 @@ var init_fingerprint = __esm({
|
|
|
14619
14638
|
// src/dependency-env.ts
|
|
14620
14639
|
import { createHash as createHash10 } from "node:crypto";
|
|
14621
14640
|
import {
|
|
14622
|
-
existsSync as
|
|
14641
|
+
existsSync as existsSync11,
|
|
14623
14642
|
lstatSync as lstatSync9,
|
|
14624
14643
|
readdirSync as readdirSync3,
|
|
14625
|
-
readFileSync as
|
|
14644
|
+
readFileSync as readFileSync12,
|
|
14626
14645
|
readlinkSync as readlinkSync2,
|
|
14627
14646
|
realpathSync as realpathSync6,
|
|
14628
14647
|
statSync as statSync3
|
|
@@ -14680,7 +14699,7 @@ function fingerprintRoot(root, cwd, h) {
|
|
|
14680
14699
|
st = statSync3(path);
|
|
14681
14700
|
if (!st.isFile()) throw new Error("not a regular file");
|
|
14682
14701
|
h.update(label + "\0external-file\0" + path + "\0" + String(st.mode) + "\0");
|
|
14683
|
-
h.update(
|
|
14702
|
+
h.update(readFileSync12(path));
|
|
14684
14703
|
h.update("\0");
|
|
14685
14704
|
} catch (e) {
|
|
14686
14705
|
throw new Unattestable(
|
|
@@ -14714,7 +14733,7 @@ function fingerprintRoot(root, cwd, h) {
|
|
|
14714
14733
|
h.update(rel + "\0" + ident.kind + "\0" + String(ident.mode) + "\0");
|
|
14715
14734
|
if (ident.kind === "file") {
|
|
14716
14735
|
try {
|
|
14717
|
-
h.update(
|
|
14736
|
+
h.update(readFileSync12(path));
|
|
14718
14737
|
h.update("\0");
|
|
14719
14738
|
} catch (e) {
|
|
14720
14739
|
throw new Unattestable(
|
|
@@ -14773,7 +14792,7 @@ function snapshot(roots, probes, cwd) {
|
|
|
14773
14792
|
const h = createHash10("sha256");
|
|
14774
14793
|
for (const probe of probes) {
|
|
14775
14794
|
h.update(
|
|
14776
|
-
"probe\0" + probe.kind + "\0" + probe.path + "\0" + (
|
|
14795
|
+
"probe\0" + probe.kind + "\0" + probe.path + "\0" + (existsSync11(probe.path) ? "present" : "absent") + "\0"
|
|
14777
14796
|
);
|
|
14778
14797
|
}
|
|
14779
14798
|
for (const root of roots) fingerprintRoot(root, cwd, h);
|
|
@@ -14832,7 +14851,7 @@ function resolveExecutable(token, cwd, env) {
|
|
|
14832
14851
|
if (token.includes("/") || token.includes("\\")) {
|
|
14833
14852
|
const path = isAbsolute10(token) ? token : resolve7(cwd, token);
|
|
14834
14853
|
try {
|
|
14835
|
-
return
|
|
14854
|
+
return existsSync11(path) ? realpathSync6(path) : null;
|
|
14836
14855
|
} catch {
|
|
14837
14856
|
return null;
|
|
14838
14857
|
}
|
|
@@ -14840,7 +14859,7 @@ function resolveExecutable(token, cwd, env) {
|
|
|
14840
14859
|
for (const entry of (env.PATH ?? "").split(delimiter).filter(Boolean)) {
|
|
14841
14860
|
const candidate = resolve7(entry, token);
|
|
14842
14861
|
try {
|
|
14843
|
-
if (
|
|
14862
|
+
if (existsSync11(candidate) && statSync3(candidate).isFile()) return realpathSync6(candidate);
|
|
14844
14863
|
} catch {
|
|
14845
14864
|
}
|
|
14846
14865
|
}
|
|
@@ -14863,7 +14882,7 @@ function inferredVenvFromToken(token, cwd) {
|
|
|
14863
14882
|
const parentName = basename4(parent).toLowerCase();
|
|
14864
14883
|
if (parentName !== "bin" && parentName !== "scripts") return null;
|
|
14865
14884
|
const root = dirname6(parent);
|
|
14866
|
-
return
|
|
14885
|
+
return existsSync11(join16(root, "pyvenv.cfg")) ? root : null;
|
|
14867
14886
|
}
|
|
14868
14887
|
function unsupportedEcosystem(command, token) {
|
|
14869
14888
|
const name = token ? basename4(token).toLowerCase() : "";
|
|
@@ -14879,13 +14898,13 @@ function inferredVenv(executable) {
|
|
|
14879
14898
|
const parentName = basename4(parent).toLowerCase();
|
|
14880
14899
|
if (parentName !== "bin" && parentName !== "scripts") return null;
|
|
14881
14900
|
const root = dirname6(parent);
|
|
14882
|
-
return
|
|
14901
|
+
return existsSync11(join16(root, "pyvenv.cfg")) ? root : null;
|
|
14883
14902
|
}
|
|
14884
14903
|
function venvProblem(root) {
|
|
14885
14904
|
const cfg = join16(root, "pyvenv.cfg");
|
|
14886
|
-
if (!
|
|
14905
|
+
if (!existsSync11(cfg)) return "VIRTUAL_ENV " + JSON.stringify(root) + " has no pyvenv.cfg";
|
|
14887
14906
|
try {
|
|
14888
|
-
const body =
|
|
14907
|
+
const body = readFileSync12(cfg, "utf8");
|
|
14889
14908
|
if (/^\s*include-system-site-packages\s*=\s*true\s*$/im.test(body)) {
|
|
14890
14909
|
return "Python environment " + JSON.stringify(root) + " enables system site-packages; those external package roots are not bounded";
|
|
14891
14910
|
}
|
|
@@ -14910,7 +14929,7 @@ function discoverDependencyEnvironment(cwdInput, command, env = process.env) {
|
|
|
14910
14929
|
};
|
|
14911
14930
|
try {
|
|
14912
14931
|
const nodeModules = join16(cwd, "node_modules");
|
|
14913
|
-
if (
|
|
14932
|
+
if (existsSync11(nodeModules)) addRoot("node_modules", nodeModules);
|
|
14914
14933
|
else probes.push({ kind: "node_modules", path: nodeModules });
|
|
14915
14934
|
const token = firstExecutable(command);
|
|
14916
14935
|
const executable = resolveExecutable(token, cwd, env);
|
|
@@ -14922,7 +14941,7 @@ function discoverDependencyEnvironment(cwdInput, command, env = process.env) {
|
|
|
14922
14941
|
venv = resolve7(env.VIRTUAL_ENV);
|
|
14923
14942
|
} else {
|
|
14924
14943
|
venv = inferredVenv(executable) ?? inferredVenvFromToken(token, cwd);
|
|
14925
|
-
if (!venv && /(?:^|\s)uv\s+run(?:\s|$)/.test(command) &&
|
|
14944
|
+
if (!venv && /(?:^|\s)uv\s+run(?:\s|$)/.test(command) && existsSync11(join16(cwd, ".venv", "pyvenv.cfg"))) {
|
|
14926
14945
|
venv = join16(cwd, ".venv");
|
|
14927
14946
|
}
|
|
14928
14947
|
}
|
|
@@ -15401,7 +15420,7 @@ if (child) {
|
|
|
15401
15420
|
// src/verifier-backend.ts
|
|
15402
15421
|
import { createHash as createHash11, randomUUID } from "node:crypto";
|
|
15403
15422
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
15404
|
-
import { accessSync as accessSync2, constants as constants4, readFileSync as
|
|
15423
|
+
import { accessSync as accessSync2, constants as constants4, readFileSync as readFileSync13, realpathSync as realpathSync7, statSync as statSync4 } from "node:fs";
|
|
15405
15424
|
import { delimiter as delimiter2, dirname as dirname7, join as join18, resolve as resolve8 } from "node:path";
|
|
15406
15425
|
function identity() {
|
|
15407
15426
|
const uid = typeof process.getuid === "function" ? process.getuid() : null;
|
|
@@ -15446,7 +15465,7 @@ function findExecutable(name) {
|
|
|
15446
15465
|
return null;
|
|
15447
15466
|
}
|
|
15448
15467
|
function fileSha256(path) {
|
|
15449
|
-
return createHash11("sha256").update(
|
|
15468
|
+
return createHash11("sha256").update(readFileSync13(path)).digest("hex");
|
|
15450
15469
|
}
|
|
15451
15470
|
function engineClientEnv() {
|
|
15452
15471
|
return {
|
|
@@ -15880,7 +15899,7 @@ var init_verifier_backend = __esm({
|
|
|
15880
15899
|
// src/verification-state.ts
|
|
15881
15900
|
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
15882
15901
|
import { createHash as createHash12 } from "node:crypto";
|
|
15883
|
-
import { mkdirSync as mkdirSync8, readFileSync as
|
|
15902
|
+
import { mkdirSync as mkdirSync8, readFileSync as readFileSync14, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "node:fs";
|
|
15884
15903
|
import { dirname as dirname8, join as join19 } from "node:path";
|
|
15885
15904
|
function git2(args, cwd) {
|
|
15886
15905
|
return execFileSync8("git", args, {
|
|
@@ -15939,7 +15958,7 @@ function interventionWiring(cwd) {
|
|
|
15939
15958
|
return sources.map(([source, path]) => {
|
|
15940
15959
|
let parsed;
|
|
15941
15960
|
try {
|
|
15942
|
-
parsed = JSON.parse(
|
|
15961
|
+
parsed = JSON.parse(readFileSync14(path, "utf8"));
|
|
15943
15962
|
} catch {
|
|
15944
15963
|
return { source, present: false };
|
|
15945
15964
|
}
|
|
@@ -16092,7 +16111,7 @@ function readVerificationRecord(cwd) {
|
|
|
16092
16111
|
if (!path) return null;
|
|
16093
16112
|
let raw;
|
|
16094
16113
|
try {
|
|
16095
|
-
raw =
|
|
16114
|
+
raw = readFileSync14(path, "utf8");
|
|
16096
16115
|
} catch {
|
|
16097
16116
|
return null;
|
|
16098
16117
|
}
|
|
@@ -16141,7 +16160,7 @@ function readVerifyingMarker(cwd) {
|
|
|
16141
16160
|
if (!path) return null;
|
|
16142
16161
|
let parsed;
|
|
16143
16162
|
try {
|
|
16144
|
-
parsed = JSON.parse(
|
|
16163
|
+
parsed = JSON.parse(readFileSync14(path, "utf8"));
|
|
16145
16164
|
} catch {
|
|
16146
16165
|
return null;
|
|
16147
16166
|
}
|
|
@@ -16505,7 +16524,7 @@ var init_verification_receipt = __esm({
|
|
|
16505
16524
|
// src/cli/verify.ts
|
|
16506
16525
|
import { execFileSync as execFileSync9, spawnSync as spawnSync3 } from "node:child_process";
|
|
16507
16526
|
import { createHash as createHash14 } from "node:crypto";
|
|
16508
|
-
import { chmodSync as chmodSync2, cpSync, lstatSync as lstatSync10, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync3, readFileSync as
|
|
16527
|
+
import { chmodSync as chmodSync2, cpSync, lstatSync as lstatSync10, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync3, readFileSync as readFileSync15, readlinkSync as readlinkSync3, rmSync as rmSync9, symlinkSync, writeFileSync as writeFileSync11, existsSync as existsSync12 } from "node:fs";
|
|
16509
16528
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
16510
16529
|
import { dirname as dirname10, isAbsolute as isAbsolute11, join as join21, relative as relative6, resolve as resolve9, sep as sep4 } from "node:path";
|
|
16511
16530
|
function oracleAssuranceReport() {
|
|
@@ -16701,7 +16720,7 @@ function probeFilesystemCaseSensitivity(dir) {
|
|
|
16701
16720
|
const lower = join21(dir, ".tw-case-probe-a");
|
|
16702
16721
|
try {
|
|
16703
16722
|
writeFileSync11(upper, "", { flag: "wx" });
|
|
16704
|
-
return !
|
|
16723
|
+
return !existsSync12(lower);
|
|
16705
16724
|
} finally {
|
|
16706
16725
|
rmSync9(upper, { force: true });
|
|
16707
16726
|
}
|
|
@@ -16765,7 +16784,7 @@ function overlayDigest(dest, paths) {
|
|
|
16765
16784
|
try {
|
|
16766
16785
|
const st = lstatSync10(p);
|
|
16767
16786
|
h.update(String(st.mode));
|
|
16768
|
-
h.update(st.isSymbolicLink() ? readlinkSync3(p) :
|
|
16787
|
+
h.update(st.isSymbolicLink() ? readlinkSync3(p) : readFileSync15(p));
|
|
16769
16788
|
} catch {
|
|
16770
16789
|
h.update("<gone>");
|
|
16771
16790
|
}
|
|
@@ -17579,7 +17598,7 @@ var init_verify = __esm({
|
|
|
17579
17598
|
// src/cli/run.ts
|
|
17580
17599
|
import { execFileSync as execFileSync10, spawn, spawnSync as spawnSync4 } from "node:child_process";
|
|
17581
17600
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
17582
|
-
import { accessSync as accessSync3, constants as fsConstants, mkdtempSync as mkdtempSync4, readdirSync as readdirSync4, readFileSync as
|
|
17601
|
+
import { accessSync as accessSync3, constants as fsConstants, mkdtempSync as mkdtempSync4, readdirSync as readdirSync4, readFileSync as readFileSync16, readlinkSync as readlinkSync4, realpathSync as realpathSync8, rmSync as rmSync10, statSync as statSync5, writeFileSync as writeFileSync12 } from "node:fs";
|
|
17583
17602
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
17584
17603
|
import { dirname as dirname11, join as join22, resolve as resolve10 } from "node:path";
|
|
17585
17604
|
function authoritativeRunLifecyclePlatform(platform = process.platform) {
|
|
@@ -17733,7 +17752,7 @@ function runAgentSupervised(argv, cwd, budgetSecs, linuxPythonCandidates, lifecy
|
|
|
17733
17752
|
}
|
|
17734
17753
|
let state = {};
|
|
17735
17754
|
try {
|
|
17736
|
-
state = JSON.parse(
|
|
17755
|
+
state = JSON.parse(readFileSync16(resultFile, "utf8"));
|
|
17737
17756
|
} catch {
|
|
17738
17757
|
return {
|
|
17739
17758
|
exit: 1,
|
|
@@ -17777,7 +17796,7 @@ function observerExited(pid) {
|
|
|
17777
17796
|
if (!pidAlive4(pid)) return true;
|
|
17778
17797
|
if (process.platform !== "linux") return false;
|
|
17779
17798
|
try {
|
|
17780
|
-
const stat =
|
|
17799
|
+
const stat = readFileSync16(`/proc/${pid}/stat`, "utf8");
|
|
17781
17800
|
const state = stat.slice(stat.lastIndexOf(")") + 2).split(" ")[0];
|
|
17782
17801
|
return state === "Z" || state === "X";
|
|
17783
17802
|
} catch (e) {
|
|
@@ -17899,7 +17918,7 @@ function git4(args, cwd) {
|
|
|
17899
17918
|
}
|
|
17900
17919
|
function nowTicks() {
|
|
17901
17920
|
try {
|
|
17902
|
-
return Math.floor(parseFloat(
|
|
17921
|
+
return Math.floor(parseFloat(readFileSync16("/proc/uptime", "utf8").split(" ")[0]) * 100);
|
|
17903
17922
|
} catch {
|
|
17904
17923
|
return Number.POSITIVE_INFINITY;
|
|
17905
17924
|
}
|
|
@@ -17922,7 +17941,7 @@ function survivorsHoldingTree(cwd, spawnedAfterTicks) {
|
|
|
17922
17941
|
const n2 = Number(pid);
|
|
17923
17942
|
if (n2 === process.pid) continue;
|
|
17924
17943
|
try {
|
|
17925
|
-
const stat =
|
|
17944
|
+
const stat = readFileSync16(`/proc/${pid}/stat`, "utf8");
|
|
17926
17945
|
const startTicks = Number(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[19]);
|
|
17927
17946
|
if (!Number.isFinite(startTicks) || startTicks < spawnedAfterTicks) continue;
|
|
17928
17947
|
} catch {
|
|
@@ -18495,7 +18514,7 @@ raise SystemExit(0)
|
|
|
18495
18514
|
|
|
18496
18515
|
// src/cli/doctor.ts
|
|
18497
18516
|
import { execFileSync as execFileSync11 } from "node:child_process";
|
|
18498
|
-
import { existsSync as
|
|
18517
|
+
import { existsSync as existsSync13, readFileSync as readFileSync17, readdirSync as readdirSync5 } from "node:fs";
|
|
18499
18518
|
import { join as join23, resolve as resolve11 } from "node:path";
|
|
18500
18519
|
function lifecyclePlatformCheck(platform = process.platform, linuxPython = platform === "linux" ? trustedLinuxPython() : null) {
|
|
18501
18520
|
if (platform === "linux") {
|
|
@@ -18551,10 +18570,10 @@ function wiringState(status, authority) {
|
|
|
18551
18570
|
return authority ? "BROKEN" : "WARN";
|
|
18552
18571
|
}
|
|
18553
18572
|
function pinsInFile(path) {
|
|
18554
|
-
if (!
|
|
18573
|
+
if (!existsSync13(path)) return [];
|
|
18555
18574
|
let src = "";
|
|
18556
18575
|
try {
|
|
18557
|
-
src =
|
|
18576
|
+
src = readFileSync17(path, "utf8");
|
|
18558
18577
|
} catch {
|
|
18559
18578
|
return [];
|
|
18560
18579
|
}
|
|
@@ -18575,13 +18594,13 @@ function workflowPermissionCheck(cwd, workflowRels = [".github/workflows/tamperw
|
|
|
18575
18594
|
const warnings = [];
|
|
18576
18595
|
for (const rel of workflowRels) {
|
|
18577
18596
|
const path = resolve11(cwd, rel);
|
|
18578
|
-
if (!
|
|
18597
|
+
if (!existsSync13(path)) {
|
|
18579
18598
|
broken.push(`${rel} is missing`);
|
|
18580
18599
|
continue;
|
|
18581
18600
|
}
|
|
18582
18601
|
let doc;
|
|
18583
18602
|
try {
|
|
18584
|
-
doc = yaml.parse(
|
|
18603
|
+
doc = yaml.parse(readFileSync17(path, "utf8"));
|
|
18585
18604
|
} catch (e) {
|
|
18586
18605
|
broken.push(`${rel} is not valid YAML (${e instanceof Error ? e.message : String(e)})`);
|
|
18587
18606
|
continue;
|
|
@@ -18980,7 +18999,7 @@ function diagnose(opts = {}) {
|
|
|
18980
18999
|
} else {
|
|
18981
19000
|
const workflowDirRel = ".github/workflows";
|
|
18982
19001
|
const workflowDir = resolve11(cwd, workflowDirRel);
|
|
18983
|
-
if (!
|
|
19002
|
+
if (!existsSync13(workflowDir)) {
|
|
18984
19003
|
return fail("ci-verifier", `${workflowDirRel}: workflow directory does not exist`);
|
|
18985
19004
|
}
|
|
18986
19005
|
let entries;
|
|
@@ -19000,12 +19019,12 @@ function diagnose(opts = {}) {
|
|
|
19000
19019
|
const authorityWorkflows = [];
|
|
19001
19020
|
for (const workflowRel of workflowRels) {
|
|
19002
19021
|
const workflowPath = resolve11(cwd, workflowRel);
|
|
19003
|
-
if (!
|
|
19022
|
+
if (!existsSync13(workflowPath)) {
|
|
19004
19023
|
return fail("ci-verifier", `${workflowRel}: workflow does not exist`);
|
|
19005
19024
|
}
|
|
19006
19025
|
let doc;
|
|
19007
19026
|
try {
|
|
19008
|
-
doc = yaml.parse(
|
|
19027
|
+
doc = yaml.parse(readFileSync17(workflowPath, "utf8"));
|
|
19009
19028
|
} catch (e) {
|
|
19010
19029
|
return fail(
|
|
19011
19030
|
"ci-verifier",
|
|
@@ -19316,9 +19335,9 @@ var init_status2 = __esm({
|
|
|
19316
19335
|
// src/cli/trace-verify.ts
|
|
19317
19336
|
import { execFileSync as execFileSync12, spawnSync as spawnSync5 } from "node:child_process";
|
|
19318
19337
|
import {
|
|
19319
|
-
existsSync as
|
|
19338
|
+
existsSync as existsSync14,
|
|
19320
19339
|
mkdtempSync as mkdtempSync5,
|
|
19321
|
-
readFileSync as
|
|
19340
|
+
readFileSync as readFileSync18,
|
|
19322
19341
|
readdirSync as readdirSync6,
|
|
19323
19342
|
realpathSync as realpathSync9,
|
|
19324
19343
|
rmSync as rmSync11,
|
|
@@ -19575,7 +19594,7 @@ function materializeBase(base, cwd, dest) {
|
|
|
19575
19594
|
}
|
|
19576
19595
|
const hostModules = join24(cwd, "node_modules");
|
|
19577
19596
|
const tracedModules = join24(dest, "node_modules");
|
|
19578
|
-
if (
|
|
19597
|
+
if (existsSync14(hostModules) && !existsSync14(tracedModules)) {
|
|
19579
19598
|
symlinkSync2(resolve12(hostModules), tracedModules, "dir");
|
|
19580
19599
|
}
|
|
19581
19600
|
}
|
|
@@ -19632,7 +19651,7 @@ function straceOnce(root, command, budget) {
|
|
|
19632
19651
|
}
|
|
19633
19652
|
);
|
|
19634
19653
|
const logs = traced.error ? [] : traceFiles(prefix);
|
|
19635
|
-
const accesses = logs.flatMap((path) => parseStraceFileAccess(
|
|
19654
|
+
const accesses = logs.flatMap((path) => parseStraceFileAccess(readFileSync18(path, "utf8"), TRACE_ROOT));
|
|
19636
19655
|
const raw = {
|
|
19637
19656
|
spawnError: traced.error ? traced.error.message : null,
|
|
19638
19657
|
status: traced.status,
|
|
@@ -19887,7 +19906,7 @@ var init_immutable = __esm({
|
|
|
19887
19906
|
});
|
|
19888
19907
|
|
|
19889
19908
|
// src/runtimes.ts
|
|
19890
|
-
import { existsSync as
|
|
19909
|
+
import { existsSync as existsSync15, readFileSync as readFileSync19 } from "node:fs";
|
|
19891
19910
|
import { join as join25 } from "node:path";
|
|
19892
19911
|
function isRecord6(x) {
|
|
19893
19912
|
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
@@ -19917,8 +19936,8 @@ function claudeSettingsBeyondTamperward(cwd) {
|
|
|
19917
19936
|
const path = join25(cwd, ".claude", "settings.json");
|
|
19918
19937
|
let raw;
|
|
19919
19938
|
try {
|
|
19920
|
-
if (!
|
|
19921
|
-
raw =
|
|
19939
|
+
if (!existsSync15(path)) return false;
|
|
19940
|
+
raw = readFileSync19(path, "utf8");
|
|
19922
19941
|
} catch {
|
|
19923
19942
|
return false;
|
|
19924
19943
|
}
|
|
@@ -19944,7 +19963,7 @@ function detectRuntimes(cwd) {
|
|
|
19944
19963
|
for (const rt of KNOWN_RUNTIMES) {
|
|
19945
19964
|
const marker = rt.markers.find((m) => {
|
|
19946
19965
|
try {
|
|
19947
|
-
return
|
|
19966
|
+
return existsSync15(join25(cwd, m));
|
|
19948
19967
|
} catch {
|
|
19949
19968
|
return false;
|
|
19950
19969
|
}
|
|
@@ -20969,7 +20988,7 @@ var init_adapter3 = __esm({
|
|
|
20969
20988
|
|
|
20970
20989
|
// src/adapters/copilot-sdk/changes.ts
|
|
20971
20990
|
import { execFileSync as execFileSync13 } from "node:child_process";
|
|
20972
|
-
import { mkdtempSync as mkdtempSync6, writeFileSync as writeFileSync13, readFileSync as
|
|
20991
|
+
import { mkdtempSync as mkdtempSync6, writeFileSync as writeFileSync13, readFileSync as readFileSync20, rmSync as rmSync12, existsSync as existsSync16, realpathSync as realpathSync10 } from "node:fs";
|
|
20973
20992
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
20974
20993
|
import { basename as basename5, dirname as dirname12, isAbsolute as isAbsolute16, relative as relative11, resolve as resolve15, join as join26 } from "node:path";
|
|
20975
20994
|
function asStr4(v) {
|
|
@@ -20988,7 +21007,7 @@ function canonicalContainedTarget(abs, root) {
|
|
|
20988
21007
|
}
|
|
20989
21008
|
let dir = abs;
|
|
20990
21009
|
const tail = [];
|
|
20991
|
-
while (!
|
|
21010
|
+
while (!existsSync16(dir)) {
|
|
20992
21011
|
const parent = dirname12(dir);
|
|
20993
21012
|
if (parent === dir) break;
|
|
20994
21013
|
tail.unshift(basename5(dir));
|
|
@@ -21063,7 +21082,7 @@ function reconstructAfterViaGit(rawDiff, display2, before, isCreate) {
|
|
|
21063
21082
|
if (statPath !== TARGET) throw new Error(`write diff reconstructs a different file (${statPath}) than the bound target`);
|
|
21064
21083
|
git8(["--check"]);
|
|
21065
21084
|
git8([]);
|
|
21066
|
-
return op === "delete" ? null :
|
|
21085
|
+
return op === "delete" ? null : readFileSync20(targetPath, "utf8");
|
|
21067
21086
|
} catch (e) {
|
|
21068
21087
|
throw new Error(`could not reconstruct the write to ${display2} from its diff via git apply: ${e instanceof Error ? e.message : String(e)}`);
|
|
21069
21088
|
} finally {
|
|
@@ -21816,7 +21835,7 @@ var init_runtime_qualification = __esm({
|
|
|
21816
21835
|
|
|
21817
21836
|
// src/cli/runtime.ts
|
|
21818
21837
|
import { execFileSync as execFileSync14 } from "node:child_process";
|
|
21819
|
-
import { existsSync as
|
|
21838
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync14 } from "node:fs";
|
|
21820
21839
|
import { join as join27, dirname as dirname13 } from "node:path";
|
|
21821
21840
|
function storePath(cwd) {
|
|
21822
21841
|
const dir = gitDir(cwd);
|
|
@@ -21824,9 +21843,9 @@ function storePath(cwd) {
|
|
|
21824
21843
|
}
|
|
21825
21844
|
function readStore(cwd) {
|
|
21826
21845
|
const path = storePath(cwd);
|
|
21827
|
-
if (!path || !
|
|
21846
|
+
if (!path || !existsSync17(path)) return null;
|
|
21828
21847
|
try {
|
|
21829
|
-
const parsed = JSON.parse(
|
|
21848
|
+
const parsed = JSON.parse(readFileSync21(path, "utf8"));
|
|
21830
21849
|
if (parsed && typeof parsed === "object" && parsed.records && typeof parsed.records === "object") return parsed;
|
|
21831
21850
|
} catch {
|
|
21832
21851
|
return null;
|
|
@@ -21995,9 +22014,9 @@ function resolveHookConfigHash(canonicalId, cwd) {
|
|
|
21995
22014
|
"github-copilot-cli": join27(cwd, ".github", "hooks", "tamperward.json")
|
|
21996
22015
|
};
|
|
21997
22016
|
const file = files[canonicalId];
|
|
21998
|
-
if (!file || !
|
|
22017
|
+
if (!file || !existsSync17(file)) return null;
|
|
21999
22018
|
try {
|
|
22000
|
-
const raw =
|
|
22019
|
+
const raw = readFileSync21(file, "utf8");
|
|
22001
22020
|
let hooks = raw;
|
|
22002
22021
|
try {
|
|
22003
22022
|
const parsed = JSON.parse(raw);
|
|
@@ -22276,7 +22295,7 @@ var init_runtime = __esm({
|
|
|
22276
22295
|
|
|
22277
22296
|
// src/cli/onboard.ts
|
|
22278
22297
|
import { execFileSync as execFileSync15 } from "node:child_process";
|
|
22279
|
-
import { lstatSync as lstatSync11, mkdtempSync as mkdtempSync7, readFileSync as
|
|
22298
|
+
import { lstatSync as lstatSync11, mkdtempSync as mkdtempSync7, readFileSync as readFileSync22, realpathSync as realpathSync11, rmSync as rmSync13 } from "node:fs";
|
|
22280
22299
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
22281
22300
|
import { join as join28, relative as relative12, resolve as resolve16, sep as sep6 } from "node:path";
|
|
22282
22301
|
import { createInterface } from "node:readline";
|
|
@@ -22349,7 +22368,7 @@ function writeVerifyCommand(cwd, command) {
|
|
|
22349
22368
|
return `${POLICY_FILE} is not a regular file; refusing to follow or replace a symlink or special file`;
|
|
22350
22369
|
}
|
|
22351
22370
|
const mode = existingMode(path, 420);
|
|
22352
|
-
const original = kind === "file" ?
|
|
22371
|
+
const original = kind === "file" ? readFileSync22(path, "utf8") : null;
|
|
22353
22372
|
let next;
|
|
22354
22373
|
try {
|
|
22355
22374
|
const doc = parseDocument(original && original.trim() ? original : "version: 1\n");
|
|
@@ -23004,7 +23023,7 @@ var init_capture = __esm({
|
|
|
23004
23023
|
|
|
23005
23024
|
// src/research/manifest.ts
|
|
23006
23025
|
import { createHash as createHash16 } from "node:crypto";
|
|
23007
|
-
import { readFileSync as
|
|
23026
|
+
import { readFileSync as readFileSync23 } from "node:fs";
|
|
23008
23027
|
import { dirname as dirname14, resolve as resolve18 } from "node:path";
|
|
23009
23028
|
function taskFrom(raw, index, manifestDir) {
|
|
23010
23029
|
const where = `task #${index + 1}`;
|
|
@@ -23038,7 +23057,7 @@ function readManifest(path) {
|
|
|
23038
23057
|
const abs = resolve18(path);
|
|
23039
23058
|
let bytes;
|
|
23040
23059
|
try {
|
|
23041
|
-
bytes =
|
|
23060
|
+
bytes = readFileSync23(abs);
|
|
23042
23061
|
} catch (e) {
|
|
23043
23062
|
throw new ResearchError(`cannot read task manifest ${abs}: ${e instanceof Error ? e.message : String(e)}`);
|
|
23044
23063
|
}
|
|
@@ -23457,7 +23476,7 @@ var init_record = __esm({
|
|
|
23457
23476
|
// src/research/run.ts
|
|
23458
23477
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
23459
23478
|
import { execFileSync as execFileSync16 } from "node:child_process";
|
|
23460
|
-
import { closeSync as closeSync5, existsSync as
|
|
23479
|
+
import { closeSync as closeSync5, existsSync as existsSync18, linkSync, mkdirSync as mkdirSync12, openSync as openSync5, readFileSync as readFileSync24, renameSync as renameSync4, rmSync as rmSync14, unlinkSync, writeFileSync as writeFileSync15, writeSync } from "node:fs";
|
|
23461
23480
|
import { hostname } from "node:os";
|
|
23462
23481
|
import { join as join29, resolve as resolve19 } from "node:path";
|
|
23463
23482
|
function git7(args, cwd) {
|
|
@@ -23471,7 +23490,7 @@ function researchLockPath(ledger) {
|
|
|
23471
23490
|
}
|
|
23472
23491
|
function readLockOwner(path) {
|
|
23473
23492
|
try {
|
|
23474
|
-
const parsed = JSON.parse(
|
|
23493
|
+
const parsed = JSON.parse(readFileSync24(path, "utf8"));
|
|
23475
23494
|
if (!isRecord(parsed) || typeof parsed.pid !== "number" || !Number.isInteger(parsed.pid) || parsed.pid <= 0) return null;
|
|
23476
23495
|
if (typeof parsed.host !== "string" || typeof parsed.started_at !== "string" || typeof parsed.token !== "string") return null;
|
|
23477
23496
|
return { pid: parsed.pid, host: parsed.host, started_at: parsed.started_at, token: parsed.token };
|
|
@@ -23494,7 +23513,7 @@ function lockHolder(path) {
|
|
|
23494
23513
|
function acquireResearchLock(ledger, breakStaleLock = false) {
|
|
23495
23514
|
mkdirSync12(ledger, { recursive: true });
|
|
23496
23515
|
const path = researchLockPath(ledger);
|
|
23497
|
-
if (breakStaleLock &&
|
|
23516
|
+
if (breakStaleLock && existsSync18(path)) {
|
|
23498
23517
|
const owner2 = readLockOwner(path);
|
|
23499
23518
|
if (!owner2) {
|
|
23500
23519
|
throw new ResearchError(`research output ${ledger} has an unreadable lock at ${path}; verify no run is active, then remove it deliberately`);
|
|
@@ -23556,7 +23575,7 @@ function acquireResearchLock(ledger, breakStaleLock = false) {
|
|
|
23556
23575
|
if (released) return;
|
|
23557
23576
|
released = true;
|
|
23558
23577
|
try {
|
|
23559
|
-
if (
|
|
23578
|
+
if (readFileSync24(path, "utf8") === text) unlinkSync(path);
|
|
23560
23579
|
} catch {
|
|
23561
23580
|
}
|
|
23562
23581
|
}
|
|
@@ -23565,7 +23584,7 @@ function acquireResearchLock(ledger, breakStaleLock = false) {
|
|
|
23565
23584
|
function resumableRecord(path, expected) {
|
|
23566
23585
|
let raw;
|
|
23567
23586
|
try {
|
|
23568
|
-
raw = JSON.parse(
|
|
23587
|
+
raw = JSON.parse(readFileSync24(path, "utf8"));
|
|
23569
23588
|
} catch (e) {
|
|
23570
23589
|
throw new ResearchError(`ledger record ${path} is malformed (${errorMessage(e).split("\n")[0]}); remove it to regenerate the pair, or use a new --out`);
|
|
23571
23590
|
}
|
|
@@ -23867,7 +23886,7 @@ function runResearch(opts) {
|
|
|
23867
23886
|
try {
|
|
23868
23887
|
for (let pair = 1; pair <= pairs; pair++) {
|
|
23869
23888
|
const path = pairRecordPath(ledger, task.id, pair);
|
|
23870
|
-
if (!
|
|
23889
|
+
if (!existsSync18(path)) continue;
|
|
23871
23890
|
const existing = resumableRecord(path, {
|
|
23872
23891
|
task: task.id,
|
|
23873
23892
|
pair,
|
|
@@ -23987,7 +24006,7 @@ var init_run2 = __esm({
|
|
|
23987
24006
|
});
|
|
23988
24007
|
|
|
23989
24008
|
// src/research/ledger-files.ts
|
|
23990
|
-
import { closeSync as closeSync6, constants as constants5, fstatSync as fstatSync3, lstatSync as lstatSync12, openSync as openSync6, readFileSync as
|
|
24009
|
+
import { closeSync as closeSync6, constants as constants5, fstatSync as fstatSync3, lstatSync as lstatSync12, openSync as openSync6, readFileSync as readFileSync25, readdirSync as readdirSync7, realpathSync as realpathSync12 } from "node:fs";
|
|
23991
24010
|
import { join as join30, resolve as resolve20 } from "node:path";
|
|
23992
24011
|
function lstatOrNull(path) {
|
|
23993
24012
|
try {
|
|
@@ -24030,7 +24049,7 @@ function readRegularFile(path, realPairsDir, name) {
|
|
|
24030
24049
|
if (!opened.isFile() || !sameInode || opened.nlink !== 1) {
|
|
24031
24050
|
throw new ResearchError(`ledger record ${path} changed between listing and reading; refusing to read it`);
|
|
24032
24051
|
}
|
|
24033
|
-
return
|
|
24052
|
+
return readFileSync25(fd);
|
|
24034
24053
|
} finally {
|
|
24035
24054
|
closeSync6(fd);
|
|
24036
24055
|
}
|
|
@@ -24203,7 +24222,7 @@ var init_summarize = __esm({
|
|
|
24203
24222
|
|
|
24204
24223
|
// src/research/init.ts
|
|
24205
24224
|
import { createHash as createHash17 } from "node:crypto";
|
|
24206
|
-
import { existsSync as
|
|
24225
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync13, readFileSync as readFileSync26, writeFileSync as writeFileSync16 } from "node:fs";
|
|
24207
24226
|
import { basename as basename6, dirname as dirname15, resolve as resolve21 } from "node:path";
|
|
24208
24227
|
function idFrom(repo) {
|
|
24209
24228
|
const clean = repo.replace(/[\\/]$/, "").split(/[\\/]/).pop() || "task";
|
|
@@ -24215,7 +24234,7 @@ function createResearchManifest(opts) {
|
|
|
24215
24234
|
if (!opts.prompt) throw new ResearchError("research init requires --prompt");
|
|
24216
24235
|
if (!opts.verifyCommand) throw new ResearchError("research init requires --verify-command");
|
|
24217
24236
|
const out3 = resolve21(opts.out);
|
|
24218
|
-
if (
|
|
24237
|
+
if (existsSync19(out3)) throw new ResearchError(`research init refuses to overwrite ${out3}; choose a new path`);
|
|
24219
24238
|
const id = opts.id ?? idFrom(opts.repo);
|
|
24220
24239
|
if (!/^[A-Za-z0-9._-]+$/.test(id)) throw new ResearchError(`research init id must match [A-Za-z0-9._-] (got "${id}")`);
|
|
24221
24240
|
if (opts.verifyBudget !== void 0 && (!Number.isFinite(opts.verifyBudget) || opts.verifyBudget <= 0)) {
|
|
@@ -24255,7 +24274,7 @@ function runResearchInit(opts) {
|
|
|
24255
24274
|
}
|
|
24256
24275
|
}
|
|
24257
24276
|
function requireHash(path) {
|
|
24258
|
-
return createHash17("sha256").update(
|
|
24277
|
+
return createHash17("sha256").update(readFileSync26(path)).digest("hex");
|
|
24259
24278
|
}
|
|
24260
24279
|
var init_init2 = __esm({
|
|
24261
24280
|
"src/research/init.ts"() {
|
|
@@ -24323,7 +24342,7 @@ var init_report2 = __esm({
|
|
|
24323
24342
|
import { createHash as createHash18 } from "node:crypto";
|
|
24324
24343
|
import { isDeepStrictEqual } from "node:util";
|
|
24325
24344
|
import { gzipSync, gunzipSync } from "node:zlib";
|
|
24326
|
-
import { mkdirSync as mkdirSync14, readFileSync as
|
|
24345
|
+
import { mkdirSync as mkdirSync14, readFileSync as readFileSync27, writeFileSync as writeFileSync17 } from "node:fs";
|
|
24327
24346
|
import { dirname as dirname16, resolve as resolve22 } from "node:path";
|
|
24328
24347
|
function octal(value, width) {
|
|
24329
24348
|
return value.toString(8).padStart(width - 1, "0") + "\0";
|
|
@@ -24429,7 +24448,7 @@ function jsonBytes(value) {
|
|
|
24429
24448
|
function validateResearchBundle(path) {
|
|
24430
24449
|
let files;
|
|
24431
24450
|
try {
|
|
24432
|
-
files = parseTar(gunzipSync(
|
|
24451
|
+
files = parseTar(gunzipSync(readFileSync27(resolve22(path))));
|
|
24433
24452
|
} catch (e) {
|
|
24434
24453
|
throw new ResearchError(`cannot read research bundle ${path}: ${e instanceof Error ? e.message : String(e)}`);
|
|
24435
24454
|
}
|
|
@@ -24499,7 +24518,7 @@ function createResearchBundle(opts) {
|
|
|
24499
24518
|
const { records, entries } = packagedRecords(ledger);
|
|
24500
24519
|
const summary = summarizeRecords(records);
|
|
24501
24520
|
if (opts.manifest) {
|
|
24502
|
-
const manifest =
|
|
24521
|
+
const manifest = readFileSync27(resolve22(opts.manifest));
|
|
24503
24522
|
const sha3 = createHash18("sha256").update(manifest).digest("hex");
|
|
24504
24523
|
if (sha3 !== summary.manifest_sha256) throw new ResearchError(`manifest sha256 ${sha3} does not match ledger ${summary.manifest_sha256}`);
|
|
24505
24524
|
entries.push({ name: "manifest.json", bytes: manifest });
|
|
@@ -24670,7 +24689,7 @@ var init_research = __esm({
|
|
|
24670
24689
|
});
|
|
24671
24690
|
|
|
24672
24691
|
// src/cli/receipt.ts
|
|
24673
|
-
import { appendFileSync as appendFileSync6, readFileSync as
|
|
24692
|
+
import { appendFileSync as appendFileSync6, readFileSync as readFileSync28, writeFileSync as writeFileSync18 } from "node:fs";
|
|
24674
24693
|
function parseReceipt(args) {
|
|
24675
24694
|
const [sub, ...rest] = args;
|
|
24676
24695
|
const exportOpts = {};
|
|
@@ -24797,7 +24816,7 @@ function ciAdjudicate(cwd, opts) {
|
|
|
24797
24816
|
if (opts.ciResult !== void 0) {
|
|
24798
24817
|
let doc;
|
|
24799
24818
|
try {
|
|
24800
|
-
doc = JSON.parse(
|
|
24819
|
+
doc = JSON.parse(readFileSync28(opts.ciResult, "utf8"));
|
|
24801
24820
|
} catch (e) {
|
|
24802
24821
|
return {
|
|
24803
24822
|
ci: { verdict: "CANNOT_VERIFY", binding, binding_error: `unreadable CI verify result: ${e instanceof Error ? e.message : String(e)}` },
|
|
@@ -24943,7 +24962,7 @@ function loadClaimedReceipt(path) {
|
|
|
24943
24962
|
}
|
|
24944
24963
|
let raw;
|
|
24945
24964
|
try {
|
|
24946
|
-
raw =
|
|
24965
|
+
raw = readFileSync28(path, "utf8");
|
|
24947
24966
|
} catch (e) {
|
|
24948
24967
|
return { disposition: "MALFORMED", detail: `receipt file could not be read (${e instanceof Error ? e.message : String(e)})` };
|
|
24949
24968
|
}
|
|
@@ -25804,7 +25823,7 @@ var init_main = __esm({
|
|
|
25804
25823
|
// src/cli/index.ts
|
|
25805
25824
|
init_hook_client();
|
|
25806
25825
|
init_exit();
|
|
25807
|
-
import { readFileSync as
|
|
25826
|
+
import { readFileSync as readFileSync29 } from "node:fs";
|
|
25808
25827
|
function loadMain() {
|
|
25809
25828
|
return Promise.resolve().then(() => (init_main(), main_exports));
|
|
25810
25829
|
}
|
|
@@ -25817,7 +25836,7 @@ async function launch(argv) {
|
|
|
25817
25836
|
if (kind && hookServiceEnabled()) {
|
|
25818
25837
|
let raw = null;
|
|
25819
25838
|
try {
|
|
25820
|
-
raw =
|
|
25839
|
+
raw = readFileSync29(0, "utf8");
|
|
25821
25840
|
} catch {
|
|
25822
25841
|
raw = null;
|
|
25823
25842
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tamperward",
|
|
3
|
-
"version": "2.39.
|
|
3
|
+
"version": "2.39.9",
|
|
4
4
|
"description": "The deterministic agent-integrity gate. One ruleset, evaluated on the actual diff/commands as a verdict, enforced everywhere a change can be made.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "hexrift",
|