@codacy/verity-cli 0.34.0-experimental.3d4888f → 0.34.0-experimental.5235853
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/bin/verity.js +388 -434
- package/package.json +1 -1
package/bin/verity.js
CHANGED
|
@@ -10435,13 +10435,13 @@ var require_web_tree_sitter2 = __commonJS2({
|
|
|
10435
10435
|
}
|
|
10436
10436
|
readAsync = /* @__PURE__ */ __name(async (url) => {
|
|
10437
10437
|
if (isFileURI(url)) {
|
|
10438
|
-
return new Promise((
|
|
10438
|
+
return new Promise((resolve8, reject) => {
|
|
10439
10439
|
var xhr = new XMLHttpRequest();
|
|
10440
10440
|
xhr.open("GET", url, true);
|
|
10441
10441
|
xhr.responseType = "arraybuffer";
|
|
10442
10442
|
xhr.onload = () => {
|
|
10443
10443
|
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
10444
|
-
|
|
10444
|
+
resolve8(xhr.response);
|
|
10445
10445
|
return;
|
|
10446
10446
|
}
|
|
10447
10447
|
reject(xhr.status);
|
|
@@ -10634,9 +10634,9 @@ var require_web_tree_sitter2 = __commonJS2({
|
|
|
10634
10634
|
__name(receiveInstantiationResult, "receiveInstantiationResult");
|
|
10635
10635
|
var info2 = getWasmImports();
|
|
10636
10636
|
if (Module["instantiateWasm"]) {
|
|
10637
|
-
return new Promise((
|
|
10637
|
+
return new Promise((resolve8, reject) => {
|
|
10638
10638
|
Module["instantiateWasm"](info2, (mod, inst) => {
|
|
10639
|
-
|
|
10639
|
+
resolve8(receiveInstance(mod, inst));
|
|
10640
10640
|
});
|
|
10641
10641
|
});
|
|
10642
10642
|
}
|
|
@@ -11969,8 +11969,8 @@ var require_web_tree_sitter2 = __commonJS2({
|
|
|
11969
11969
|
if (runtimeInitialized) {
|
|
11970
11970
|
moduleRtn = Module;
|
|
11971
11971
|
} else {
|
|
11972
|
-
moduleRtn = new Promise((
|
|
11973
|
-
readyPromiseResolve =
|
|
11972
|
+
moduleRtn = new Promise((resolve8, reject) => {
|
|
11973
|
+
readyPromiseResolve = resolve8;
|
|
11974
11974
|
readyPromiseReject = reject;
|
|
11975
11975
|
});
|
|
11976
11976
|
}
|
|
@@ -14447,87 +14447,8 @@ var import_node_child_process4 = require("node:child_process");
|
|
|
14447
14447
|
|
|
14448
14448
|
// src/constants.ts
|
|
14449
14449
|
var import_node_child_process = require("node:child_process");
|
|
14450
|
-
var import_node_fs2 = require("node:fs");
|
|
14451
|
-
var import_node_path2 = require("node:path");
|
|
14452
|
-
|
|
14453
|
-
// src/lib/context-identity.ts
|
|
14454
|
-
var import_node_crypto = require("node:crypto");
|
|
14455
14450
|
var import_node_fs = require("node:fs");
|
|
14456
|
-
var import_node_os = require("node:os");
|
|
14457
14451
|
var import_node_path = require("node:path");
|
|
14458
|
-
var SHARED_SENTINELS = /* @__PURE__ */ new Set([
|
|
14459
|
-
"",
|
|
14460
|
-
"-",
|
|
14461
|
-
"n/a",
|
|
14462
|
-
"na",
|
|
14463
|
-
"none",
|
|
14464
|
-
"null",
|
|
14465
|
-
"undefined",
|
|
14466
|
-
"unknown",
|
|
14467
|
-
"anon",
|
|
14468
|
-
"anonymous",
|
|
14469
|
-
"default",
|
|
14470
|
-
"_default"
|
|
14471
|
-
]);
|
|
14472
|
-
function isSharedSentinel(value) {
|
|
14473
|
-
if (value == null) return true;
|
|
14474
|
-
return SHARED_SENTINELS.has(value.trim().toLowerCase());
|
|
14475
|
-
}
|
|
14476
|
-
var ephemeral = /* @__PURE__ */ new Map();
|
|
14477
|
-
function ephemeralId(slot, width) {
|
|
14478
|
-
let id = ephemeral.get(slot);
|
|
14479
|
-
if (!id) {
|
|
14480
|
-
id = `eph-${(0, import_node_crypto.randomBytes)(Math.ceil(width / 2)).toString("hex").slice(0, width - 4)}`;
|
|
14481
|
-
ephemeral.set(slot, id);
|
|
14482
|
-
}
|
|
14483
|
-
return id;
|
|
14484
|
-
}
|
|
14485
|
-
function contextIdentity(input) {
|
|
14486
|
-
const tokenUsable = !isSharedSentinel(input.token ?? null);
|
|
14487
|
-
const sessionUsable = !isSharedSentinel(input.sessionId ?? null);
|
|
14488
|
-
const userKey = tokenUsable ? (0, import_node_crypto.createHash)("sha256").update(String(input.token)).digest("hex").slice(0, 12) : ephemeralId("user", 12);
|
|
14489
|
-
const sessionKey2 = sessionUsable ? (0, import_node_crypto.createHash)("sha256").update(String(input.sessionId)).digest("hex").slice(0, 16) : ephemeralId("session", 16);
|
|
14490
|
-
let treeKey = "no-tree";
|
|
14491
|
-
const rawTree = input.treeRoot;
|
|
14492
|
-
if (rawTree && !isSharedSentinel(rawTree)) {
|
|
14493
|
-
let resolved = rawTree;
|
|
14494
|
-
try {
|
|
14495
|
-
resolved = import_node_fs.realpathSync.native(rawTree);
|
|
14496
|
-
} catch {
|
|
14497
|
-
}
|
|
14498
|
-
treeKey = (0, import_node_crypto.createHash)("sha256").update(resolved).digest("hex").slice(0, 12);
|
|
14499
|
-
}
|
|
14500
|
-
return {
|
|
14501
|
-
userKey,
|
|
14502
|
-
treeKey,
|
|
14503
|
-
sessionKey: sessionKey2,
|
|
14504
|
-
userKeySource: tokenUsable ? "token" : "ephemeral",
|
|
14505
|
-
sessionKeySource: sessionUsable ? "session_id" : "ephemeral",
|
|
14506
|
-
ephemeral: !tokenUsable || !sessionUsable
|
|
14507
|
-
};
|
|
14508
|
-
}
|
|
14509
|
-
function verityHome() {
|
|
14510
|
-
const override = process.env.VERITY_HOME;
|
|
14511
|
-
return override && override.trim() ? (0, import_node_path.resolve)(override) : (0, import_node_path.join)((0, import_node_os.homedir)(), ".verity");
|
|
14512
|
-
}
|
|
14513
|
-
function dossierDir(identity) {
|
|
14514
|
-
return (0, import_node_path.join)(verityHome(), "sessions", identity.userKey, identity.treeKey, identity.sessionKey);
|
|
14515
|
-
}
|
|
14516
|
-
function treeDir(identity) {
|
|
14517
|
-
return (0, import_node_path.join)(verityHome(), "sessions", identity.userKey, identity.treeKey);
|
|
14518
|
-
}
|
|
14519
|
-
function scopeIdentity(token, sessionId) {
|
|
14520
|
-
const t = (token ?? "").trim();
|
|
14521
|
-
const s = (sessionId ?? "").trim();
|
|
14522
|
-
const userKey = t.length > 0 ? (0, import_node_crypto.createHash)("sha256").update(t).digest("hex").slice(0, 12) : "anon";
|
|
14523
|
-
const sessionKey2 = s.length > 0 ? (0, import_node_crypto.createHash)("sha256").update(s).digest("hex").slice(0, 16) : "_default";
|
|
14524
|
-
return { userKey, sessionKey: sessionKey2, bucket: `${userKey}/${sessionKey2}` };
|
|
14525
|
-
}
|
|
14526
|
-
function sessionScopeKey(token, sessionId) {
|
|
14527
|
-
return scopeIdentity(token, sessionId).bucket;
|
|
14528
|
-
}
|
|
14529
|
-
|
|
14530
|
-
// src/constants.ts
|
|
14531
14452
|
var _repoRoot = null;
|
|
14532
14453
|
function repoRoot() {
|
|
14533
14454
|
if (_repoRoot === null) {
|
|
@@ -14555,36 +14476,17 @@ function mainWorktreeRoot() {
|
|
|
14555
14476
|
_mainRoot = null;
|
|
14556
14477
|
return _mainRoot;
|
|
14557
14478
|
}
|
|
14558
|
-
const abs = common.startsWith("/") ? common : (0,
|
|
14559
|
-
_mainRoot = (0,
|
|
14479
|
+
const abs = common.startsWith("/") ? common : (0, import_node_path.join)(repoRoot(), common);
|
|
14480
|
+
_mainRoot = (0, import_node_path.dirname)(abs);
|
|
14560
14481
|
} catch {
|
|
14561
14482
|
_mainRoot = null;
|
|
14562
14483
|
}
|
|
14563
14484
|
return _mainRoot;
|
|
14564
14485
|
}
|
|
14565
14486
|
function verityConfigured() {
|
|
14566
|
-
if (
|
|
14487
|
+
if ((0, import_node_fs.existsSync)((0, import_node_path.join)(repoRoot(), VERITY_DIR))) return true;
|
|
14567
14488
|
const main = mainWorktreeRoot();
|
|
14568
|
-
return !!main &&
|
|
14569
|
-
}
|
|
14570
|
-
function isProjectVerityDir(dir) {
|
|
14571
|
-
return (0, import_node_fs2.existsSync)(dir) && !isMachineStore(dir);
|
|
14572
|
-
}
|
|
14573
|
-
function isMachineStore(dir) {
|
|
14574
|
-
const here = canonicalPath(dir);
|
|
14575
|
-
const stores = [process.env.HOME ? (0, import_node_path2.join)(process.env.HOME, VERITY_DIR) : null, verityHome()];
|
|
14576
|
-
return stores.some((s) => s !== null && canonicalPath(s) === here);
|
|
14577
|
-
}
|
|
14578
|
-
function canonicalPath(p) {
|
|
14579
|
-
try {
|
|
14580
|
-
return import_node_fs2.realpathSync.native(p);
|
|
14581
|
-
} catch {
|
|
14582
|
-
}
|
|
14583
|
-
try {
|
|
14584
|
-
return (0, import_node_path2.join)(import_node_fs2.realpathSync.native((0, import_node_path2.dirname)(p)), (0, import_node_path2.basename)(p));
|
|
14585
|
-
} catch {
|
|
14586
|
-
return (0, import_node_path2.resolve)(p);
|
|
14587
|
-
}
|
|
14489
|
+
return !!main && (0, import_node_fs.existsSync)((0, import_node_path.join)(main, VERITY_DIR));
|
|
14588
14490
|
}
|
|
14589
14491
|
var VERITY_DIR = ".verity";
|
|
14590
14492
|
var CREDENTIALS_FILE = `${VERITY_DIR}/credentials`;
|
|
@@ -14605,7 +14507,7 @@ var MEMORY_DIR = `${VERITY_DIR}/memory`;
|
|
|
14605
14507
|
var CODACY_CONFIG_FILE = ".codacy/codacy.config.json";
|
|
14606
14508
|
var VERITYIGNORE_FILE = ".verityignore";
|
|
14607
14509
|
function projectPath(relativePath) {
|
|
14608
|
-
return (0,
|
|
14510
|
+
return (0, import_node_path.join)(repoRoot(), relativePath);
|
|
14609
14511
|
}
|
|
14610
14512
|
var MAX_DELTA_BYTES = 194560;
|
|
14611
14513
|
var MAX_FILES = 40;
|
|
@@ -14779,7 +14681,7 @@ function printVerbose(msg, verbose) {
|
|
|
14779
14681
|
}
|
|
14780
14682
|
|
|
14781
14683
|
// src/lib/debug-log.ts
|
|
14782
|
-
var
|
|
14684
|
+
var import_node_fs2 = require("node:fs");
|
|
14783
14685
|
function isDebugEnabled() {
|
|
14784
14686
|
const v = process.env.VERITY_DEBUG;
|
|
14785
14687
|
if (v === "0" || v === "false" || v === "off") return false;
|
|
@@ -14797,24 +14699,24 @@ function writeLine(obj) {
|
|
|
14797
14699
|
try {
|
|
14798
14700
|
const dir = projectPath(DEBUG_LOG_DIR);
|
|
14799
14701
|
const file = projectPath(DEBUG_LOG_FILE);
|
|
14800
|
-
(0,
|
|
14702
|
+
(0, import_node_fs2.mkdirSync)(dir, { recursive: true });
|
|
14801
14703
|
rotateIfNeeded(file);
|
|
14802
|
-
(0,
|
|
14704
|
+
(0, import_node_fs2.appendFileSync)(file, JSON.stringify(obj) + "\n");
|
|
14803
14705
|
} catch {
|
|
14804
14706
|
}
|
|
14805
14707
|
}
|
|
14806
14708
|
function rotateIfNeeded(file) {
|
|
14807
14709
|
try {
|
|
14808
|
-
const s = (0,
|
|
14710
|
+
const s = (0, import_node_fs2.statSync)(file);
|
|
14809
14711
|
if (s.size < DEBUG_LOG_MAX_BYTES) return;
|
|
14810
|
-
(0,
|
|
14712
|
+
(0, import_node_fs2.renameSync)(file, `${file}.1`);
|
|
14811
14713
|
} catch {
|
|
14812
14714
|
}
|
|
14813
14715
|
}
|
|
14814
14716
|
|
|
14815
14717
|
// src/lib/credentials.ts
|
|
14816
14718
|
var import_promises = require("node:fs/promises");
|
|
14817
|
-
var
|
|
14719
|
+
var import_node_path2 = require("node:path");
|
|
14818
14720
|
var import_node_child_process2 = require("node:child_process");
|
|
14819
14721
|
function globalCredentialsPath() {
|
|
14820
14722
|
return `${process.env.HOME}/.verity/credentials`;
|
|
@@ -14889,7 +14791,7 @@ async function readGlobalCredential(remote) {
|
|
|
14889
14791
|
}
|
|
14890
14792
|
async function upsertGlobalCredential(remote, rec) {
|
|
14891
14793
|
const path = globalCredentialsPath();
|
|
14892
|
-
await (0, import_promises.mkdir)((0,
|
|
14794
|
+
await (0, import_promises.mkdir)((0, import_node_path2.dirname)(path), { recursive: true });
|
|
14893
14795
|
let content = "";
|
|
14894
14796
|
try {
|
|
14895
14797
|
content = await (0, import_promises.readFile)(path, "utf-8");
|
|
@@ -15033,10 +14935,10 @@ async function foldLegacyLocalCredential(remoteArg) {
|
|
|
15033
14935
|
|
|
15034
14936
|
// src/lib/git.ts
|
|
15035
14937
|
var import_node_child_process3 = require("node:child_process");
|
|
15036
|
-
var
|
|
15037
|
-
var
|
|
14938
|
+
var import_node_fs3 = require("node:fs");
|
|
14939
|
+
var import_node_path3 = require("node:path");
|
|
15038
14940
|
function resolveFile(relpath) {
|
|
15039
|
-
return (0,
|
|
14941
|
+
return (0, import_node_fs3.existsSync)(relpath) ? relpath : null;
|
|
15040
14942
|
}
|
|
15041
14943
|
function execGit(cmd) {
|
|
15042
14944
|
try {
|
|
@@ -15054,7 +14956,7 @@ function readBaselineSha() {
|
|
|
15054
14956
|
if (sha === null) return null;
|
|
15055
14957
|
if (!commitResolves(sha)) {
|
|
15056
14958
|
try {
|
|
15057
|
-
(0,
|
|
14959
|
+
(0, import_node_fs3.unlinkSync)(BASELINE_SHA_FILE);
|
|
15058
14960
|
} catch {
|
|
15059
14961
|
}
|
|
15060
14962
|
return null;
|
|
@@ -15062,10 +14964,10 @@ function readBaselineSha() {
|
|
|
15062
14964
|
return sha;
|
|
15063
14965
|
}
|
|
15064
14966
|
function readRawBaselineSha() {
|
|
15065
|
-
if (!(0,
|
|
14967
|
+
if (!(0, import_node_fs3.existsSync)(BASELINE_SHA_FILE)) return null;
|
|
15066
14968
|
let sha;
|
|
15067
14969
|
try {
|
|
15068
|
-
sha = (0,
|
|
14970
|
+
sha = (0, import_node_fs3.readFileSync)(BASELINE_SHA_FILE, "utf-8").trim();
|
|
15069
14971
|
} catch {
|
|
15070
14972
|
return null;
|
|
15071
14973
|
}
|
|
@@ -15074,8 +14976,8 @@ function readRawBaselineSha() {
|
|
|
15074
14976
|
function writeBaselineSha(sha) {
|
|
15075
14977
|
if (!SHA_RE.test(sha)) return;
|
|
15076
14978
|
try {
|
|
15077
|
-
(0,
|
|
15078
|
-
(0,
|
|
14979
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path3.dirname)(BASELINE_SHA_FILE), { recursive: true });
|
|
14980
|
+
(0, import_node_fs3.writeFileSync)(BASELINE_SHA_FILE, sha);
|
|
15079
14981
|
} catch {
|
|
15080
14982
|
}
|
|
15081
14983
|
}
|
|
@@ -15163,17 +15065,17 @@ function showContentAtRef(ref, repoRelPath) {
|
|
|
15163
15065
|
}
|
|
15164
15066
|
function filterAnalyzable(files) {
|
|
15165
15067
|
return files.filter((f) => {
|
|
15166
|
-
const ext = (0,
|
|
15068
|
+
const ext = (0, import_node_path3.extname)(f).slice(1);
|
|
15167
15069
|
return ANALYZABLE_EXTENSIONS.has(ext);
|
|
15168
15070
|
});
|
|
15169
15071
|
}
|
|
15170
15072
|
function filterReviewable(files) {
|
|
15171
15073
|
return files.filter((f) => {
|
|
15172
|
-
const ext = (0,
|
|
15074
|
+
const ext = (0, import_node_path3.extname)(f).slice(1);
|
|
15173
15075
|
if (ANALYZABLE_EXTENSIONS.has(ext)) return false;
|
|
15174
15076
|
if (REVIEWABLE_EXTENSIONS.has(ext)) return true;
|
|
15175
|
-
const
|
|
15176
|
-
if (REVIEWABLE_FILENAMES.has(
|
|
15077
|
+
const basename8 = f.split("/").pop() ?? "";
|
|
15078
|
+
if (REVIEWABLE_FILENAMES.has(basename8)) return true;
|
|
15177
15079
|
if (REVIEWABLE_PATH_PATTERNS.some((p) => p.test(f))) return true;
|
|
15178
15080
|
return false;
|
|
15179
15081
|
});
|
|
@@ -15648,7 +15550,7 @@ async function maybeHealServiceUrl(resolution, verbose) {
|
|
|
15648
15550
|
|
|
15649
15551
|
// src/lib/register.ts
|
|
15650
15552
|
var readline = __toESM2(require("node:readline/promises"));
|
|
15651
|
-
var
|
|
15553
|
+
var import_node_os = require("node:os");
|
|
15652
15554
|
|
|
15653
15555
|
// src/lib/spinner.ts
|
|
15654
15556
|
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
@@ -15736,7 +15638,7 @@ function startSpinner(label2, opts = {}) {
|
|
|
15736
15638
|
}
|
|
15737
15639
|
|
|
15738
15640
|
// src/lib/provider-auth.ts
|
|
15739
|
-
var sleep = (ms) => new Promise((
|
|
15641
|
+
var sleep = (ms) => new Promise((resolve8) => setTimeout(resolve8, ms));
|
|
15740
15642
|
var form = (fields) => new URLSearchParams(fields).toString();
|
|
15741
15643
|
async function githubAccountId(owner) {
|
|
15742
15644
|
try {
|
|
@@ -16001,7 +15903,7 @@ function deviceLabel() {
|
|
|
16001
15903
|
const override = process.env.VERITY_DEVICE_LABEL?.trim();
|
|
16002
15904
|
if (override) return override;
|
|
16003
15905
|
try {
|
|
16004
|
-
return (0,
|
|
15906
|
+
return (0, import_node_os.hostname)() || void 0;
|
|
16005
15907
|
} catch {
|
|
16006
15908
|
return void 0;
|
|
16007
15909
|
}
|
|
@@ -16159,8 +16061,8 @@ function registerAuthCommands(program2) {
|
|
|
16159
16061
|
}
|
|
16160
16062
|
|
|
16161
16063
|
// src/lib/pending-login.ts
|
|
16162
|
-
var
|
|
16163
|
-
var
|
|
16064
|
+
var import_node_fs4 = require("node:fs");
|
|
16065
|
+
var import_node_path4 = require("node:path");
|
|
16164
16066
|
function pendingLoginPath() {
|
|
16165
16067
|
return `${process.env.HOME}/.verity/pending-login.json`;
|
|
16166
16068
|
}
|
|
@@ -16176,26 +16078,26 @@ function savePendingLogin(dc, serviceUrl, now = Date.now()) {
|
|
|
16176
16078
|
created_at: new Date(now).toISOString()
|
|
16177
16079
|
};
|
|
16178
16080
|
const path = pendingLoginPath();
|
|
16179
|
-
(0,
|
|
16081
|
+
(0, import_node_fs4.mkdirSync)((0, import_node_path4.dirname)(path), { recursive: true });
|
|
16180
16082
|
clearPendingLogin();
|
|
16181
|
-
(0,
|
|
16083
|
+
(0, import_node_fs4.writeFileSync)(path, JSON.stringify(record, null, 2) + "\n", { mode: 384, flag: "wx" });
|
|
16182
16084
|
try {
|
|
16183
|
-
(0,
|
|
16085
|
+
(0, import_node_fs4.chmodSync)(path, 384);
|
|
16184
16086
|
} catch {
|
|
16185
16087
|
}
|
|
16186
16088
|
return record;
|
|
16187
16089
|
}
|
|
16188
16090
|
function readPendingLogin(now = Date.now()) {
|
|
16189
16091
|
const path = pendingLoginPath();
|
|
16190
|
-
if (!(0,
|
|
16092
|
+
if (!(0, import_node_fs4.existsSync)(path)) return { status: "none" };
|
|
16191
16093
|
try {
|
|
16192
|
-
if ((0,
|
|
16094
|
+
if ((0, import_node_fs4.lstatSync)(path).isSymbolicLink()) return { status: "invalid", reason: "it is a symlink" };
|
|
16193
16095
|
} catch {
|
|
16194
16096
|
return { status: "none" };
|
|
16195
16097
|
}
|
|
16196
16098
|
let parsed;
|
|
16197
16099
|
try {
|
|
16198
|
-
parsed = JSON.parse((0,
|
|
16100
|
+
parsed = JSON.parse((0, import_node_fs4.readFileSync)(path, "utf-8"));
|
|
16199
16101
|
} catch {
|
|
16200
16102
|
return { status: "invalid", reason: "it is not valid JSON" };
|
|
16201
16103
|
}
|
|
@@ -16216,7 +16118,7 @@ function readPendingLogin(now = Date.now()) {
|
|
|
16216
16118
|
}
|
|
16217
16119
|
function clearPendingLogin() {
|
|
16218
16120
|
try {
|
|
16219
|
-
(0,
|
|
16121
|
+
(0, import_node_fs4.unlinkSync)(pendingLoginPath());
|
|
16220
16122
|
return true;
|
|
16221
16123
|
} catch {
|
|
16222
16124
|
return false;
|
|
@@ -16772,11 +16674,11 @@ function registerLogoutCommand(program2) {
|
|
|
16772
16674
|
|
|
16773
16675
|
// src/lib/hooks.ts
|
|
16774
16676
|
var import_promises4 = require("node:fs/promises");
|
|
16775
|
-
var
|
|
16677
|
+
var import_node_path6 = require("node:path");
|
|
16776
16678
|
|
|
16777
16679
|
// src/lib/json-file.ts
|
|
16778
16680
|
var import_promises3 = require("node:fs/promises");
|
|
16779
|
-
var
|
|
16681
|
+
var import_node_path5 = require("node:path");
|
|
16780
16682
|
function jsonSemanticEqual(a, b) {
|
|
16781
16683
|
if (a === b) return true;
|
|
16782
16684
|
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
|
|
@@ -16822,7 +16724,7 @@ async function writeJsonFilePreservingStyle(file, value) {
|
|
|
16822
16724
|
const indent = currentRaw !== null ? detectJsonIndent(currentRaw) : 2;
|
|
16823
16725
|
const next = JSON.stringify(value, null, indent) + "\n";
|
|
16824
16726
|
if (next === currentRaw) return false;
|
|
16825
|
-
await (0, import_promises3.mkdir)((0,
|
|
16727
|
+
await (0, import_promises3.mkdir)((0, import_node_path5.dirname)(file), { recursive: true });
|
|
16826
16728
|
await (0, import_promises3.writeFile)(file, next);
|
|
16827
16729
|
return true;
|
|
16828
16730
|
}
|
|
@@ -17007,13 +16909,13 @@ async function writeSettings(settings) {
|
|
|
17007
16909
|
}
|
|
17008
16910
|
async function readSettingsAt(root) {
|
|
17009
16911
|
try {
|
|
17010
|
-
return JSON.parse(await (0, import_promises4.readFile)((0,
|
|
16912
|
+
return JSON.parse(await (0, import_promises4.readFile)((0, import_node_path6.join)(root, CLAUDE_SETTINGS_FILE), "utf-8"));
|
|
17011
16913
|
} catch {
|
|
17012
16914
|
return {};
|
|
17013
16915
|
}
|
|
17014
16916
|
}
|
|
17015
16917
|
async function writeSettingsAt(root, settings) {
|
|
17016
|
-
await writeJsonFilePreservingStyle((0,
|
|
16918
|
+
await writeJsonFilePreservingStyle((0, import_node_path6.join)(root, CLAUDE_SETTINGS_FILE), settings);
|
|
17017
16919
|
}
|
|
17018
16920
|
async function hasLegacyHooksAt(root) {
|
|
17019
16921
|
const settings = await readSettingsAt(root);
|
|
@@ -17202,13 +17104,13 @@ async function applyMomentSelection(moments) {
|
|
|
17202
17104
|
}
|
|
17203
17105
|
|
|
17204
17106
|
// src/lib/project-config.ts
|
|
17205
|
-
var import_node_fs7 = require("node:fs");
|
|
17206
|
-
var import_node_path9 = require("node:path");
|
|
17207
|
-
|
|
17208
|
-
// src/lib/repo-controlled.ts
|
|
17209
17107
|
var import_node_fs6 = require("node:fs");
|
|
17210
17108
|
var import_node_path8 = require("node:path");
|
|
17211
17109
|
|
|
17110
|
+
// src/lib/repo-controlled.ts
|
|
17111
|
+
var import_node_fs5 = require("node:fs");
|
|
17112
|
+
var import_node_path7 = require("node:path");
|
|
17113
|
+
|
|
17212
17114
|
// src/lib/hardened-git.ts
|
|
17213
17115
|
var import_node_child_process5 = require("node:child_process");
|
|
17214
17116
|
var HARDENED_CONFIG_ARGS = [
|
|
@@ -17288,7 +17190,7 @@ function repoControlled(worktree, rel) {
|
|
|
17288
17190
|
for (let i2 = 1; i2 <= parts2.length; i2++) {
|
|
17289
17191
|
let st;
|
|
17290
17192
|
try {
|
|
17291
|
-
st = (0,
|
|
17193
|
+
st = (0, import_node_fs5.lstatSync)((0, import_node_path7.join)(worktree, ...parts2.slice(0, i2)));
|
|
17292
17194
|
} catch (err2) {
|
|
17293
17195
|
const code = err2?.code;
|
|
17294
17196
|
if (code === "ENOENT" || code === "ENOTDIR") return null;
|
|
@@ -17312,8 +17214,8 @@ function parseMoments(raw) {
|
|
|
17312
17214
|
}
|
|
17313
17215
|
function readConfigFile(path) {
|
|
17314
17216
|
try {
|
|
17315
|
-
if (!(0,
|
|
17316
|
-
const raw = JSON.parse((0,
|
|
17217
|
+
if (!(0, import_node_fs6.existsSync)(path)) return null;
|
|
17218
|
+
const raw = JSON.parse((0, import_node_fs6.readFileSync)(path, "utf-8"));
|
|
17317
17219
|
const moments = Array.isArray(raw.git_moments) ? raw.git_moments.filter(isMoment) : [];
|
|
17318
17220
|
const source2 = raw.git_moments_source === "user" || raw.git_moments_source === "init" ? raw.git_moments_source : void 0;
|
|
17319
17221
|
return {
|
|
@@ -17330,13 +17232,13 @@ function candidates() {
|
|
|
17330
17232
|
const out2 = [{ path: local, source: "local" }];
|
|
17331
17233
|
const main = mainWorktreeRoot();
|
|
17332
17234
|
if (main) {
|
|
17333
|
-
const inherited = (0,
|
|
17235
|
+
const inherited = (0, import_node_path8.join)(main, PROJECT_CONFIG_FILE);
|
|
17334
17236
|
if (inherited !== local) out2.push({ path: inherited, source: "main-worktree" });
|
|
17335
17237
|
}
|
|
17336
17238
|
return out2;
|
|
17337
17239
|
}
|
|
17338
17240
|
function formalRefusal(path) {
|
|
17339
|
-
return repoControlled((0,
|
|
17241
|
+
return repoControlled((0, import_node_path8.dirname)((0, import_node_path8.dirname)(path)), PROJECT_CONFIG_FILE);
|
|
17340
17242
|
}
|
|
17341
17243
|
function readProjectConfigRaw() {
|
|
17342
17244
|
for (const { path, source: source2 } of candidates()) {
|
|
@@ -17372,8 +17274,8 @@ function writeProjectConfig(patch) {
|
|
|
17372
17274
|
...patch
|
|
17373
17275
|
};
|
|
17374
17276
|
const target = projectPath(PROJECT_CONFIG_FILE);
|
|
17375
|
-
(0,
|
|
17376
|
-
(0,
|
|
17277
|
+
(0, import_node_fs6.mkdirSync)((0, import_node_path8.dirname)(target), { recursive: true });
|
|
17278
|
+
(0, import_node_fs6.writeFileSync)(target, JSON.stringify(next, null, 2) + "\n");
|
|
17377
17279
|
return next;
|
|
17378
17280
|
}
|
|
17379
17281
|
function resolveGuardMoments(explicit) {
|
|
@@ -17382,11 +17284,11 @@ function resolveGuardMoments(explicit) {
|
|
|
17382
17284
|
}
|
|
17383
17285
|
|
|
17384
17286
|
// src/lib/plugin-ownership.ts
|
|
17385
|
-
var
|
|
17287
|
+
var import_node_fs9 = require("node:fs");
|
|
17386
17288
|
|
|
17387
17289
|
// src/lib/which.ts
|
|
17388
|
-
var
|
|
17389
|
-
var
|
|
17290
|
+
var import_node_fs7 = require("node:fs");
|
|
17291
|
+
var import_node_path9 = require("node:path");
|
|
17390
17292
|
function executableExtensions(platform4, pathext) {
|
|
17391
17293
|
if (platform4 !== "win32") return [""];
|
|
17392
17294
|
const raw = (pathext ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
@@ -17404,14 +17306,14 @@ function whichSync(bin, opts = {}) {
|
|
|
17404
17306
|
if (!rawPath) return null;
|
|
17405
17307
|
const exts = executableExtensions(platform4, opts.pathext ?? process.env.PATHEXT);
|
|
17406
17308
|
const real = opts.real ?? true;
|
|
17407
|
-
for (const dir of rawPath.split(
|
|
17309
|
+
for (const dir of rawPath.split(import_node_path9.delimiter)) {
|
|
17408
17310
|
if (!dir) continue;
|
|
17409
17311
|
for (const ext of exts) {
|
|
17410
|
-
const candidate = (0,
|
|
17312
|
+
const candidate = (0, import_node_path9.join)(dir, bin + ext);
|
|
17411
17313
|
try {
|
|
17412
|
-
if (!(0,
|
|
17413
|
-
if (platform4 !== "win32") (0,
|
|
17414
|
-
return real ? (0,
|
|
17314
|
+
if (!(0, import_node_fs7.statSync)(candidate).isFile()) continue;
|
|
17315
|
+
if (platform4 !== "win32") (0, import_node_fs7.accessSync)(candidate, import_node_fs7.constants.X_OK);
|
|
17316
|
+
return real ? (0, import_node_fs7.realpathSync)(candidate) : candidate;
|
|
17415
17317
|
} catch {
|
|
17416
17318
|
continue;
|
|
17417
17319
|
}
|
|
@@ -17421,11 +17323,11 @@ function whichSync(bin, opts = {}) {
|
|
|
17421
17323
|
}
|
|
17422
17324
|
|
|
17423
17325
|
// src/lib/plugin-ownership.ts
|
|
17424
|
-
var
|
|
17425
|
-
var
|
|
17326
|
+
var import_node_os2 = require("node:os");
|
|
17327
|
+
var import_node_path10 = require("node:path");
|
|
17426
17328
|
|
|
17427
17329
|
// src/lib/stderr-log.ts
|
|
17428
|
-
var
|
|
17330
|
+
var import_node_fs8 = require("node:fs");
|
|
17429
17331
|
var TOKEN_RE2 = /verity_[0-9a-f]{16,}/g;
|
|
17430
17332
|
var ANSI_RE = /\u001b\[[0-?]*[ -/]*[@-~]/g;
|
|
17431
17333
|
function scrub(s) {
|
|
@@ -17438,9 +17340,9 @@ function append(text) {
|
|
|
17438
17340
|
try {
|
|
17439
17341
|
const dir = projectPath(DEBUG_LOG_DIR);
|
|
17440
17342
|
const file = projectPath(STDERR_LOG_FILE);
|
|
17441
|
-
(0,
|
|
17343
|
+
(0, import_node_fs8.mkdirSync)(dir, { recursive: true });
|
|
17442
17344
|
rotateIfNeeded(file);
|
|
17443
|
-
(0,
|
|
17345
|
+
(0, import_node_fs8.appendFileSync)(file, text);
|
|
17444
17346
|
} catch {
|
|
17445
17347
|
}
|
|
17446
17348
|
}
|
|
@@ -17488,8 +17390,8 @@ function markerPath() {
|
|
|
17488
17390
|
}
|
|
17489
17391
|
function readMarker() {
|
|
17490
17392
|
try {
|
|
17491
|
-
if (!(0,
|
|
17492
|
-
const raw = JSON.parse((0,
|
|
17393
|
+
if (!(0, import_node_fs9.existsSync)(markerPath())) return null;
|
|
17394
|
+
const raw = JSON.parse((0, import_node_fs9.readFileSync)(markerPath(), "utf-8"));
|
|
17493
17395
|
const pluginRoot = typeof raw.plugin_root === "string" ? raw.plugin_root : "";
|
|
17494
17396
|
if (!pluginRoot || CONTROL_CHARS2.test(pluginRoot)) return null;
|
|
17495
17397
|
const version = typeof raw.version === "string" && !CONTROL_CHARS2.test(raw.version) ? raw.version : null;
|
|
@@ -17507,23 +17409,23 @@ function recordPluginOwnership(sessionId) {
|
|
|
17507
17409
|
const pluginRoot = process.env.VERITY_PLUGIN_ROOT;
|
|
17508
17410
|
if (!pluginRoot) return;
|
|
17509
17411
|
try {
|
|
17510
|
-
(0,
|
|
17412
|
+
(0, import_node_fs9.mkdirSync)(projectPath(VERITY_DIR), { recursive: true });
|
|
17511
17413
|
const marker = {
|
|
17512
17414
|
session_id: sessionId,
|
|
17513
17415
|
plugin_root: pluginRoot,
|
|
17514
17416
|
version: process.env.VERITY_PLUGIN_VERSION || null,
|
|
17515
17417
|
ts: Math.floor(Date.now() / 1e3)
|
|
17516
17418
|
};
|
|
17517
|
-
(0,
|
|
17419
|
+
(0, import_node_fs9.writeFileSync)(markerPath(), JSON.stringify(marker));
|
|
17518
17420
|
} catch {
|
|
17519
17421
|
}
|
|
17520
17422
|
}
|
|
17521
17423
|
function claudeConfigDir() {
|
|
17522
|
-
return process.env.CLAUDE_CONFIG_DIR || (0,
|
|
17424
|
+
return process.env.CLAUDE_CONFIG_DIR || (0, import_node_path10.join)((0, import_node_os2.homedir)(), ".claude");
|
|
17523
17425
|
}
|
|
17524
17426
|
function readJsonFile(path) {
|
|
17525
17427
|
try {
|
|
17526
|
-
const parsed = JSON.parse((0,
|
|
17428
|
+
const parsed = JSON.parse((0, import_node_fs9.readFileSync)(path, "utf-8"));
|
|
17527
17429
|
return parsed && typeof parsed === "object" ? parsed : null;
|
|
17528
17430
|
} catch {
|
|
17529
17431
|
return null;
|
|
@@ -17531,9 +17433,9 @@ function readJsonFile(path) {
|
|
|
17531
17433
|
}
|
|
17532
17434
|
function enabledPluginSetting(key) {
|
|
17533
17435
|
const files = [
|
|
17534
|
-
projectPath((0,
|
|
17535
|
-
projectPath((0,
|
|
17536
|
-
(0,
|
|
17436
|
+
projectPath((0, import_node_path10.join)(".claude", "settings.local.json")),
|
|
17437
|
+
projectPath((0, import_node_path10.join)(".claude", "settings.json")),
|
|
17438
|
+
(0, import_node_path10.join)(claudeConfigDir(), "settings.json")
|
|
17537
17439
|
];
|
|
17538
17440
|
for (const file of files) {
|
|
17539
17441
|
const map = readJsonFile(file)?.enabledPlugins;
|
|
@@ -17545,11 +17447,11 @@ function enabledPluginSetting(key) {
|
|
|
17545
17447
|
}
|
|
17546
17448
|
function marketplaceLocations() {
|
|
17547
17449
|
const out2 = /* @__PURE__ */ new Map();
|
|
17548
|
-
const known = readJsonFile((0,
|
|
17450
|
+
const known = readJsonFile((0, import_node_path10.join)(claudeConfigDir(), "plugins", "known_marketplaces.json"));
|
|
17549
17451
|
if (!known) return out2;
|
|
17550
17452
|
for (const [name2, entry] of Object.entries(known)) {
|
|
17551
17453
|
const loc2 = entry?.installLocation;
|
|
17552
|
-
if (typeof loc2 === "string" && loc2) out2.set(name2, (0,
|
|
17454
|
+
if (typeof loc2 === "string" && loc2) out2.set(name2, (0, import_node_path10.resolve)(loc2));
|
|
17553
17455
|
}
|
|
17554
17456
|
return out2;
|
|
17555
17457
|
}
|
|
@@ -17563,7 +17465,7 @@ function globalVerityVersion() {
|
|
|
17563
17465
|
const entry = verityPathEntry();
|
|
17564
17466
|
if (!entry) return null;
|
|
17565
17467
|
try {
|
|
17566
|
-
const pkg = readJsonFile((0,
|
|
17468
|
+
const pkg = readJsonFile((0, import_node_path10.join)((0, import_node_path10.dirname)((0, import_node_fs9.realpathSync)(entry)), "..", "package.json"));
|
|
17567
17469
|
if (pkg?.name !== "@codacy/verity-cli" || typeof pkg.version !== "string") return null;
|
|
17568
17470
|
return pkg.version;
|
|
17569
17471
|
} catch {
|
|
@@ -17580,7 +17482,7 @@ var VERITY_MARKETPLACE_REPO = "codacy/verity";
|
|
|
17580
17482
|
function marketplaceConflict() {
|
|
17581
17483
|
const wanted = VERITY_MARKETPLACE;
|
|
17582
17484
|
for (const file of ["settings.json", "settings.local.json"]) {
|
|
17583
|
-
const path = (0,
|
|
17485
|
+
const path = (0, import_node_path10.join)(claudeConfigDir(), file);
|
|
17584
17486
|
const declared = readJsonFile(path)?.extraKnownMarketplaces ?? null;
|
|
17585
17487
|
const entry2 = declared && typeof declared === "object" ? declared[wanted] : void 0;
|
|
17586
17488
|
if (entry2 && typeof entry2 === "object") {
|
|
@@ -17590,7 +17492,7 @@ function marketplaceConflict() {
|
|
|
17590
17492
|
}
|
|
17591
17493
|
}
|
|
17592
17494
|
}
|
|
17593
|
-
const known = readJsonFile((0,
|
|
17495
|
+
const known = readJsonFile((0, import_node_path10.join)(claudeConfigDir(), "plugins", "known_marketplaces.json"));
|
|
17594
17496
|
const entry = known?.[wanted];
|
|
17595
17497
|
if (entry && typeof entry === "object" && !pointsAtVerity(entry.source)) {
|
|
17596
17498
|
return { name: wanted, declaredAs: describeSource(entry.source) };
|
|
@@ -17611,7 +17513,7 @@ function describeSource(src) {
|
|
|
17611
17513
|
return target ? `${kind} \u2192 ${target}` : kind;
|
|
17612
17514
|
}
|
|
17613
17515
|
function legacyMarketplaceInstall() {
|
|
17614
|
-
const plugins = readJsonFile((0,
|
|
17516
|
+
const plugins = readJsonFile((0, import_node_path10.join)(claudeConfigDir(), "plugins", "installed_plugins.json"))?.plugins;
|
|
17615
17517
|
if (!plugins || typeof plugins !== "object") return null;
|
|
17616
17518
|
for (const key of Object.keys(plugins)) {
|
|
17617
17519
|
const at = key.lastIndexOf("@");
|
|
@@ -17623,13 +17525,13 @@ function legacyMarketplaceInstall() {
|
|
|
17623
17525
|
}
|
|
17624
17526
|
function realpathOr(p) {
|
|
17625
17527
|
try {
|
|
17626
|
-
return
|
|
17528
|
+
return import_node_fs9.realpathSync.native(p);
|
|
17627
17529
|
} catch {
|
|
17628
|
-
return (0,
|
|
17530
|
+
return (0, import_node_path10.resolve)(p);
|
|
17629
17531
|
}
|
|
17630
17532
|
}
|
|
17631
17533
|
function isWithin(want, dir) {
|
|
17632
|
-
return want === dir || want.startsWith(dir +
|
|
17534
|
+
return want === dir || want.startsWith(dir + import_node_path10.sep);
|
|
17633
17535
|
}
|
|
17634
17536
|
function entryAppliesHere(entry, here) {
|
|
17635
17537
|
const e = entry;
|
|
@@ -17639,9 +17541,9 @@ function entryAppliesHere(entry, here) {
|
|
|
17639
17541
|
return forProject === here;
|
|
17640
17542
|
}
|
|
17641
17543
|
function registrySays(pluginRoot) {
|
|
17642
|
-
const plugins = readJsonFile((0,
|
|
17544
|
+
const plugins = readJsonFile((0, import_node_path10.join)(claudeConfigDir(), "plugins", "installed_plugins.json"))?.plugins;
|
|
17643
17545
|
if (!plugins || typeof plugins !== "object") return "unverified";
|
|
17644
|
-
const want = (0,
|
|
17546
|
+
const want = (0, import_node_path10.resolve)(pluginRoot);
|
|
17645
17547
|
const here = realpathOr(repoRoot());
|
|
17646
17548
|
const markets = marketplaceLocations();
|
|
17647
17549
|
for (const [key, value] of Object.entries(plugins)) {
|
|
@@ -17650,15 +17552,15 @@ function registrySays(pluginRoot) {
|
|
|
17650
17552
|
const applicable = (Array.isArray(value) ? value : []).filter((entry) => entryAppliesHere(entry, here));
|
|
17651
17553
|
const claims = applicable.some((entry) => {
|
|
17652
17554
|
const installPath = entry?.installPath;
|
|
17653
|
-
return typeof installPath === "string" && (0,
|
|
17555
|
+
return typeof installPath === "string" && (0, import_node_path10.resolve)(installPath) === want;
|
|
17654
17556
|
}) || source2 !== void 0 && applicable.length > 0 && isWithin(want, source2);
|
|
17655
17557
|
if (claims) {
|
|
17656
17558
|
if (enabledPluginSetting(key) === false) return "gone";
|
|
17657
|
-
return (0,
|
|
17559
|
+
return (0, import_node_fs9.existsSync)(pluginRoot) ? "live" : "gone";
|
|
17658
17560
|
}
|
|
17659
17561
|
}
|
|
17660
|
-
const managed = (0,
|
|
17661
|
-
return want === managed || want.startsWith(managed +
|
|
17562
|
+
const managed = (0, import_node_path10.resolve)((0, import_node_path10.join)(claudeConfigDir(), "plugins", "cache"));
|
|
17563
|
+
return want === managed || want.startsWith(managed + import_node_path10.sep) ? "gone" : "unverified";
|
|
17662
17564
|
}
|
|
17663
17565
|
var _live = /* @__PURE__ */ new Map();
|
|
17664
17566
|
function pluginLiveness(pluginRoot) {
|
|
@@ -17672,7 +17574,7 @@ function clearStalePluginMarker() {
|
|
|
17672
17574
|
const marker = readMarker();
|
|
17673
17575
|
if (!marker || pluginLiveness(marker.plugin_root) !== "gone") return null;
|
|
17674
17576
|
try {
|
|
17675
|
-
(0,
|
|
17577
|
+
(0, import_node_fs9.rmSync)(markerPath(), { force: true });
|
|
17676
17578
|
} catch {
|
|
17677
17579
|
return null;
|
|
17678
17580
|
}
|
|
@@ -17700,7 +17602,7 @@ function pluginActiveHere() {
|
|
|
17700
17602
|
return activePluginInstall() !== null;
|
|
17701
17603
|
}
|
|
17702
17604
|
function registeredVerityPlugin() {
|
|
17703
|
-
const plugins = readJsonFile((0,
|
|
17605
|
+
const plugins = readJsonFile((0, import_node_path10.join)(claudeConfigDir(), "plugins", "installed_plugins.json"))?.plugins;
|
|
17704
17606
|
if (!plugins || typeof plugins !== "object") return null;
|
|
17705
17607
|
const here = realpathOr(repoRoot());
|
|
17706
17608
|
for (const [key, value] of Object.entries(plugins)) {
|
|
@@ -17710,7 +17612,7 @@ function registeredVerityPlugin() {
|
|
|
17710
17612
|
for (const entry of Array.isArray(value) ? value : []) {
|
|
17711
17613
|
const e = entry;
|
|
17712
17614
|
const installPath = typeof e.installPath === "string" ? e.installPath : "";
|
|
17713
|
-
if (!installPath || !(0,
|
|
17615
|
+
if (!installPath || !(0, import_node_fs9.existsSync)(installPath)) continue;
|
|
17714
17616
|
if (!entryAppliesHere(entry, here)) continue;
|
|
17715
17617
|
return { pluginRoot: installPath, version: typeof e.version === "string" ? e.version : null };
|
|
17716
17618
|
}
|
|
@@ -17762,28 +17664,28 @@ async function resolveHookWiring() {
|
|
|
17762
17664
|
}
|
|
17763
17665
|
|
|
17764
17666
|
// src/lib/cli-provenance.ts
|
|
17765
|
-
var
|
|
17766
|
-
var
|
|
17767
|
-
var
|
|
17667
|
+
var import_node_fs10 = require("node:fs");
|
|
17668
|
+
var import_node_os3 = require("node:os");
|
|
17669
|
+
var import_node_path11 = require("node:path");
|
|
17768
17670
|
var CLI_PACKAGE = "@codacy/verity-cli";
|
|
17769
|
-
var CLI_ENTRY = (0,
|
|
17671
|
+
var CLI_ENTRY = (0, import_node_path11.join)("node_modules", CLI_PACKAGE, "bin", "verity.js");
|
|
17770
17672
|
function readJson(path) {
|
|
17771
17673
|
try {
|
|
17772
|
-
const parsed = JSON.parse((0,
|
|
17674
|
+
const parsed = JSON.parse((0, import_node_fs10.readFileSync)(path, "utf-8"));
|
|
17773
17675
|
return parsed && typeof parsed === "object" ? parsed : null;
|
|
17774
17676
|
} catch {
|
|
17775
17677
|
return null;
|
|
17776
17678
|
}
|
|
17777
17679
|
}
|
|
17778
17680
|
function versionUnder(base) {
|
|
17779
|
-
const entry = (0,
|
|
17780
|
-
if (!(0,
|
|
17781
|
-
const pkg = readJson((0,
|
|
17681
|
+
const entry = (0, import_node_path11.join)(base, CLI_ENTRY);
|
|
17682
|
+
if (!(0, import_node_fs10.existsSync)(entry)) return null;
|
|
17683
|
+
const pkg = readJson((0, import_node_path11.join)(base, "node_modules", CLI_PACKAGE, "package.json"));
|
|
17782
17684
|
return typeof pkg?.version === "string" ? pkg.version : null;
|
|
17783
17685
|
}
|
|
17784
17686
|
function versionForEntry(entry) {
|
|
17785
17687
|
try {
|
|
17786
|
-
const pkg = readJson((0,
|
|
17688
|
+
const pkg = readJson((0, import_node_path11.join)((0, import_node_path11.dirname)((0, import_node_fs10.realpathSync)(entry)), "..", "package.json"));
|
|
17787
17689
|
return typeof pkg?.version === "string" ? pkg.version : null;
|
|
17788
17690
|
} catch {
|
|
17789
17691
|
return null;
|
|
@@ -17791,16 +17693,16 @@ function versionForEntry(entry) {
|
|
|
17791
17693
|
}
|
|
17792
17694
|
function resolveHooksCli(pluginRoot) {
|
|
17793
17695
|
const override = process.env.VERITY_CLI_PATH;
|
|
17794
|
-
if (override && (0,
|
|
17696
|
+
if (override && (0, import_node_fs10.existsSync)(override)) {
|
|
17795
17697
|
return { version: versionForEntry(override), rung: "override" };
|
|
17796
17698
|
}
|
|
17797
17699
|
const fromPlugin = versionUnder(pluginRoot);
|
|
17798
17700
|
if (fromPlugin !== null) return { version: fromPlugin, rung: "plugin" };
|
|
17799
|
-
if ((0,
|
|
17800
|
-
const dataDir = process.env.CLAUDE_PLUGIN_DATA || (0,
|
|
17701
|
+
if ((0, import_node_fs10.existsSync)((0, import_node_path11.join)(pluginRoot, CLI_ENTRY))) return { version: null, rung: "plugin" };
|
|
17702
|
+
const dataDir = process.env.CLAUDE_PLUGIN_DATA || (0, import_node_path11.join)((0, import_node_os3.homedir)(), ".verity", "plugin-cli");
|
|
17801
17703
|
const fromData = versionUnder(dataDir);
|
|
17802
17704
|
if (fromData !== null) return { version: fromData, rung: "plugin-data" };
|
|
17803
|
-
if ((0,
|
|
17705
|
+
if ((0, import_node_fs10.existsSync)((0, import_node_path11.join)(dataDir, CLI_ENTRY))) return { version: null, rung: "plugin-data" };
|
|
17804
17706
|
const global = globalVerityVersion();
|
|
17805
17707
|
if (global !== null) return { version: global, rung: "global" };
|
|
17806
17708
|
return null;
|
|
@@ -17902,7 +17804,7 @@ function pluginCliInvocation() {
|
|
|
17902
17804
|
return resolverCommand(root);
|
|
17903
17805
|
}
|
|
17904
17806
|
function resolverCommand(root) {
|
|
17905
|
-
return `node ${JSON.stringify((0,
|
|
17807
|
+
return `node ${JSON.stringify((0, import_node_path11.join)(root, "scripts", "verity.mjs"))}`;
|
|
17906
17808
|
}
|
|
17907
17809
|
|
|
17908
17810
|
// src/commands/hooks.ts
|
|
@@ -18038,18 +17940,18 @@ function registerHooksCommands(program2) {
|
|
|
18038
17940
|
}
|
|
18039
17941
|
|
|
18040
17942
|
// src/commands/intent.ts
|
|
18041
|
-
var
|
|
17943
|
+
var import_node_crypto9 = require("node:crypto");
|
|
18042
17944
|
|
|
18043
17945
|
// src/lib/conversation-buffer.ts
|
|
18044
17946
|
var import_promises5 = require("node:fs/promises");
|
|
18045
|
-
var
|
|
17947
|
+
var import_node_fs11 = require("node:fs");
|
|
18046
17948
|
var import_node_child_process6 = require("node:child_process");
|
|
18047
|
-
var
|
|
17949
|
+
var import_node_crypto = require("node:crypto");
|
|
18048
17950
|
function stripImageReferences(text) {
|
|
18049
17951
|
return text.replace(/\[Image #\d+\]/g, "[screenshot \u2014 not available for review]");
|
|
18050
17952
|
}
|
|
18051
17953
|
function bufferTmpPath() {
|
|
18052
|
-
return `${CONVERSATION_BUFFER_FILE}.${process.pid}.${(0,
|
|
17954
|
+
return `${CONVERSATION_BUFFER_FILE}.${process.pid}.${(0, import_node_crypto.randomBytes)(4).toString("hex")}.tmp`;
|
|
18053
17955
|
}
|
|
18054
17956
|
async function appendToConversationBuffer(prompt, sessionId) {
|
|
18055
17957
|
try {
|
|
@@ -18078,7 +17980,7 @@ async function appendToConversationBuffer(prompt, sessionId) {
|
|
|
18078
17980
|
}
|
|
18079
17981
|
async function readAndClearConversationBuffer(currentSessionId) {
|
|
18080
17982
|
try {
|
|
18081
|
-
if ((0,
|
|
17983
|
+
if ((0, import_node_fs11.existsSync)(CONVERSATION_BUFFER_FILE)) {
|
|
18082
17984
|
const entries = await readBufferEntries();
|
|
18083
17985
|
let mine = entries;
|
|
18084
17986
|
let others = [];
|
|
@@ -18102,7 +18004,7 @@ async function readAndClearConversationBuffer(currentSessionId) {
|
|
|
18102
18004
|
};
|
|
18103
18005
|
}
|
|
18104
18006
|
}
|
|
18105
|
-
if ((0,
|
|
18007
|
+
if ((0, import_node_fs11.existsSync)(INTENT_FILE)) {
|
|
18106
18008
|
try {
|
|
18107
18009
|
const content = await (0, import_promises5.readFile)(INTENT_FILE, "utf-8");
|
|
18108
18010
|
await (0, import_promises5.unlink)(INTENT_FILE).catch(() => {
|
|
@@ -18393,6 +18295,83 @@ function isCommandOnlyTurn(input) {
|
|
|
18393
18295
|
return commands.every(isNonAuthoringCommand);
|
|
18394
18296
|
}
|
|
18395
18297
|
|
|
18298
|
+
// src/lib/context-identity.ts
|
|
18299
|
+
var import_node_crypto2 = require("node:crypto");
|
|
18300
|
+
var import_node_fs12 = require("node:fs");
|
|
18301
|
+
var import_node_os4 = require("node:os");
|
|
18302
|
+
var import_node_path12 = require("node:path");
|
|
18303
|
+
var SHARED_SENTINELS = /* @__PURE__ */ new Set([
|
|
18304
|
+
"",
|
|
18305
|
+
"-",
|
|
18306
|
+
"n/a",
|
|
18307
|
+
"na",
|
|
18308
|
+
"none",
|
|
18309
|
+
"null",
|
|
18310
|
+
"undefined",
|
|
18311
|
+
"unknown",
|
|
18312
|
+
"anon",
|
|
18313
|
+
"anonymous",
|
|
18314
|
+
"default",
|
|
18315
|
+
"_default"
|
|
18316
|
+
]);
|
|
18317
|
+
function isSharedSentinel(value) {
|
|
18318
|
+
if (value == null) return true;
|
|
18319
|
+
return SHARED_SENTINELS.has(value.trim().toLowerCase());
|
|
18320
|
+
}
|
|
18321
|
+
var ephemeral = /* @__PURE__ */ new Map();
|
|
18322
|
+
function ephemeralId(slot, width) {
|
|
18323
|
+
let id = ephemeral.get(slot);
|
|
18324
|
+
if (!id) {
|
|
18325
|
+
id = `eph-${(0, import_node_crypto2.randomBytes)(Math.ceil(width / 2)).toString("hex").slice(0, width - 4)}`;
|
|
18326
|
+
ephemeral.set(slot, id);
|
|
18327
|
+
}
|
|
18328
|
+
return id;
|
|
18329
|
+
}
|
|
18330
|
+
function contextIdentity(input) {
|
|
18331
|
+
const tokenUsable = !isSharedSentinel(input.token ?? null);
|
|
18332
|
+
const sessionUsable = !isSharedSentinel(input.sessionId ?? null);
|
|
18333
|
+
const userKey = tokenUsable ? (0, import_node_crypto2.createHash)("sha256").update(String(input.token)).digest("hex").slice(0, 12) : ephemeralId("user", 12);
|
|
18334
|
+
const sessionKey2 = sessionUsable ? (0, import_node_crypto2.createHash)("sha256").update(String(input.sessionId)).digest("hex").slice(0, 16) : ephemeralId("session", 16);
|
|
18335
|
+
let treeKey = "no-tree";
|
|
18336
|
+
const rawTree = input.treeRoot;
|
|
18337
|
+
if (rawTree && !isSharedSentinel(rawTree)) {
|
|
18338
|
+
let resolved = rawTree;
|
|
18339
|
+
try {
|
|
18340
|
+
resolved = import_node_fs12.realpathSync.native(rawTree);
|
|
18341
|
+
} catch {
|
|
18342
|
+
}
|
|
18343
|
+
treeKey = (0, import_node_crypto2.createHash)("sha256").update(resolved).digest("hex").slice(0, 12);
|
|
18344
|
+
}
|
|
18345
|
+
return {
|
|
18346
|
+
userKey,
|
|
18347
|
+
treeKey,
|
|
18348
|
+
sessionKey: sessionKey2,
|
|
18349
|
+
userKeySource: tokenUsable ? "token" : "ephemeral",
|
|
18350
|
+
sessionKeySource: sessionUsable ? "session_id" : "ephemeral",
|
|
18351
|
+
ephemeral: !tokenUsable || !sessionUsable
|
|
18352
|
+
};
|
|
18353
|
+
}
|
|
18354
|
+
function verityHome() {
|
|
18355
|
+
const override = process.env.VERITY_HOME;
|
|
18356
|
+
return override && override.trim() ? (0, import_node_path12.resolve)(override) : (0, import_node_path12.join)((0, import_node_os4.homedir)(), ".verity");
|
|
18357
|
+
}
|
|
18358
|
+
function dossierDir(identity) {
|
|
18359
|
+
return (0, import_node_path12.join)(verityHome(), "sessions", identity.userKey, identity.treeKey, identity.sessionKey);
|
|
18360
|
+
}
|
|
18361
|
+
function treeDir(identity) {
|
|
18362
|
+
return (0, import_node_path12.join)(verityHome(), "sessions", identity.userKey, identity.treeKey);
|
|
18363
|
+
}
|
|
18364
|
+
function scopeIdentity(token, sessionId) {
|
|
18365
|
+
const t = (token ?? "").trim();
|
|
18366
|
+
const s = (sessionId ?? "").trim();
|
|
18367
|
+
const userKey = t.length > 0 ? (0, import_node_crypto2.createHash)("sha256").update(t).digest("hex").slice(0, 12) : "anon";
|
|
18368
|
+
const sessionKey2 = s.length > 0 ? (0, import_node_crypto2.createHash)("sha256").update(s).digest("hex").slice(0, 16) : "_default";
|
|
18369
|
+
return { userKey, sessionKey: sessionKey2, bucket: `${userKey}/${sessionKey2}` };
|
|
18370
|
+
}
|
|
18371
|
+
function sessionScopeKey(token, sessionId) {
|
|
18372
|
+
return scopeIdentity(token, sessionId).bucket;
|
|
18373
|
+
}
|
|
18374
|
+
|
|
18396
18375
|
// src/lib/task-context-buffer.ts
|
|
18397
18376
|
var import_promises6 = require("node:fs/promises");
|
|
18398
18377
|
var import_node_fs13 = require("node:fs");
|
|
@@ -20565,7 +20544,7 @@ Body content (\u22648KB). Use [[node-id]] wikilinks for cross-references.
|
|
|
20565
20544
|
|
|
20566
20545
|
// src/lib/dossier-session.ts
|
|
20567
20546
|
var import_node_fs26 = require("node:fs");
|
|
20568
|
-
var
|
|
20547
|
+
var import_node_crypto8 = require("node:crypto");
|
|
20569
20548
|
var import_node_path22 = require("node:path");
|
|
20570
20549
|
|
|
20571
20550
|
// src/lib/pending-repeat.ts
|
|
@@ -20642,7 +20621,6 @@ function isRepeatOfAny(text, priorFingerprints, threshold = REPEAT_THRESHOLD) {
|
|
|
20642
20621
|
}
|
|
20643
20622
|
|
|
20644
20623
|
// src/lib/dossier/bounds.ts
|
|
20645
|
-
var import_node_crypto5 = require("node:crypto");
|
|
20646
20624
|
var MAX_LINE_BYTES = 4096;
|
|
20647
20625
|
var MAX_GOAL_CHARS = 2e3;
|
|
20648
20626
|
var GOAL_KEEP = 8;
|
|
@@ -20654,17 +20632,10 @@ var NOT_MINE_CAP = 300;
|
|
|
20654
20632
|
var STATEMENTS_OPEN_CAP = 40;
|
|
20655
20633
|
var COMMANDS_CAP = 12;
|
|
20656
20634
|
var DIVERGENCE_CAP = 10;
|
|
20657
|
-
var
|
|
20658
|
-
var DIVERGENCE_KEYS_PER_LINE = 200;
|
|
20635
|
+
var DIVERGENCE_SEEN_CAP = 300;
|
|
20659
20636
|
function divergenceKey(path, hash) {
|
|
20660
20637
|
return `${path}@${hash ?? "unknown"}`;
|
|
20661
20638
|
}
|
|
20662
|
-
function packedDivergenceDigest(key) {
|
|
20663
|
-
return (0, import_node_crypto5.createHash)("sha256").update(key).digest("hex").slice(0, 12);
|
|
20664
|
-
}
|
|
20665
|
-
function packedDivergenceKey(digest) {
|
|
20666
|
-
return `#${digest}`;
|
|
20667
|
-
}
|
|
20668
20639
|
var MARKS_CAP = 50;
|
|
20669
20640
|
var ROTATE_BYTES = 1048576;
|
|
20670
20641
|
var ROTATE_KEEP = 2;
|
|
@@ -20678,7 +20649,7 @@ function statementAnchorKey(file, patternId) {
|
|
|
20678
20649
|
}
|
|
20679
20650
|
|
|
20680
20651
|
// src/lib/dossier/log.ts
|
|
20681
|
-
var
|
|
20652
|
+
var import_node_crypto5 = require("node:crypto");
|
|
20682
20653
|
var import_node_fs22 = require("node:fs");
|
|
20683
20654
|
var import_node_path20 = require("node:path");
|
|
20684
20655
|
var CRC_TABLE = (() => {
|
|
@@ -20720,7 +20691,7 @@ function nextSeq() {
|
|
|
20720
20691
|
function encodeEvent(ev) {
|
|
20721
20692
|
const full = {
|
|
20722
20693
|
v: 1,
|
|
20723
|
-
id: (0,
|
|
20694
|
+
id: (0, import_node_crypto5.randomBytes)(4).toString("hex"),
|
|
20724
20695
|
...ev
|
|
20725
20696
|
};
|
|
20726
20697
|
let body2 = JSON.stringify(full);
|
|
@@ -20791,7 +20762,7 @@ function rotateIfNeeded2(d) {
|
|
|
20791
20762
|
}
|
|
20792
20763
|
|
|
20793
20764
|
// src/lib/dossier/fold-dossier.ts
|
|
20794
|
-
var
|
|
20765
|
+
var import_node_crypto6 = require("node:crypto");
|
|
20795
20766
|
var import_node_fs23 = require("node:fs");
|
|
20796
20767
|
var import_node_path21 = require("node:path");
|
|
20797
20768
|
var EMPTY_CAPABILITIES = () => ({
|
|
@@ -20883,7 +20854,7 @@ function reduce(state, events, now) {
|
|
|
20883
20854
|
state.meta.seq = Math.max(state.meta.seq, ev.seq);
|
|
20884
20855
|
switch (ev.k) {
|
|
20885
20856
|
case "goal": {
|
|
20886
|
-
const hash = (0,
|
|
20857
|
+
const hash = (0, import_node_crypto6.createHash)("sha256").update(ev.text).digest("hex").slice(0, 16);
|
|
20887
20858
|
const prev = state.goal[state.goal.length - 1];
|
|
20888
20859
|
if (prev && prev.hash === hash) {
|
|
20889
20860
|
prev.repeats = (prev.repeats ?? 0) + 1;
|
|
@@ -21011,13 +20982,12 @@ function reduce(state, events, now) {
|
|
|
21011
20982
|
break;
|
|
21012
20983
|
}
|
|
21013
20984
|
case "divergence": {
|
|
20985
|
+
state.divergence.counts[ev.kind] = (state.divergence.counts[ev.kind] ?? 0) + 1;
|
|
21014
20986
|
state.divergence.events.push({ kind: ev.kind, path: ev.path, at: ev.at });
|
|
21015
|
-
const
|
|
21016
|
-
|
|
21017
|
-
if (seenDivergence.has(key)) continue;
|
|
20987
|
+
const key = divergenceKey(ev.path, ev.hash ?? null);
|
|
20988
|
+
if (!seenDivergence.has(key)) {
|
|
21018
20989
|
seenDivergence.add(key);
|
|
21019
|
-
state.divergence.seen.push(key);
|
|
21020
|
-
state.divergence.counts[ev.kind] = (state.divergence.counts[ev.kind] ?? 0) + 1;
|
|
20990
|
+
if (state.divergence.seen.length < DIVERGENCE_SEEN_CAP) state.divergence.seen.push(key);
|
|
21021
20991
|
}
|
|
21022
20992
|
break;
|
|
21023
20993
|
}
|
|
@@ -21324,14 +21294,14 @@ function assessContinuity(i2) {
|
|
|
21324
21294
|
}
|
|
21325
21295
|
|
|
21326
21296
|
// src/lib/dossier/reanchor.ts
|
|
21327
|
-
var
|
|
21297
|
+
var import_node_crypto7 = require("node:crypto");
|
|
21328
21298
|
var import_node_fs25 = require("node:fs");
|
|
21329
21299
|
function lineSha(text) {
|
|
21330
|
-
return (0,
|
|
21300
|
+
return (0, import_node_crypto7.createHash)("sha256").update(text.trim()).digest("hex").slice(0, HASH_WIDTH);
|
|
21331
21301
|
}
|
|
21332
21302
|
function fileHash(path) {
|
|
21333
21303
|
try {
|
|
21334
|
-
return (0,
|
|
21304
|
+
return (0, import_node_crypto7.createHash)("sha256").update((0, import_node_fs25.readFileSync)(path)).digest("hex").slice(0, HASH_WIDTH);
|
|
21335
21305
|
} catch {
|
|
21336
21306
|
return null;
|
|
21337
21307
|
}
|
|
@@ -21828,7 +21798,7 @@ function recordTurn(d, t) {
|
|
|
21828
21798
|
// Identity is the COMMAND, not its category — otherwise `npm test -- a` and
|
|
21829
21799
|
// `npm test -- b` are one row and the streak counts two different commands
|
|
21830
21800
|
// as a run of one.
|
|
21831
|
-
cmd_hash: (0,
|
|
21801
|
+
cmd_hash: (0, import_node_crypto8.createHash)("sha256").update(c.head || c.class).digest("hex").slice(0, 12),
|
|
21832
21802
|
head: c.head || c.class,
|
|
21833
21803
|
status: toStatus(c.last_status)
|
|
21834
21804
|
});
|
|
@@ -21846,23 +21816,10 @@ function recordTurn(d, t) {
|
|
|
21846
21816
|
}
|
|
21847
21817
|
}
|
|
21848
21818
|
const seenDivergence = t.known?.divergence ?? /* @__PURE__ */ new Set();
|
|
21849
|
-
const fresh = [];
|
|
21850
21819
|
for (const u of t.unobserved) {
|
|
21851
21820
|
const hash = fileHash((0, import_node_path22.join)(root, u.p));
|
|
21852
|
-
|
|
21853
|
-
|
|
21854
|
-
if (seenDivergence.has(key) || seenDivergence.has(packedDivergenceKey(digest))) continue;
|
|
21855
|
-
fresh.push({ path: u.p, hash, digest });
|
|
21856
|
-
}
|
|
21857
|
-
if (fresh.length > DIVERGENCE_BULK_AT) {
|
|
21858
|
-
for (let i2 = 0; i2 < fresh.length; i2 += DIVERGENCE_KEYS_PER_LINE) {
|
|
21859
|
-
const slice2 = fresh.slice(i2, i2 + DIVERGENCE_KEYS_PER_LINE);
|
|
21860
|
-
appendEvent(d, { k: "divergence", kind: "external_mutation", path: slice2[0].path, keys: slice2.map((f) => f.digest) });
|
|
21861
|
-
}
|
|
21862
|
-
} else {
|
|
21863
|
-
for (const f of fresh) {
|
|
21864
|
-
appendEvent(d, { k: "divergence", kind: "external_mutation", path: f.path, hash: f.hash });
|
|
21865
|
-
}
|
|
21821
|
+
if (seenDivergence.has(divergenceKey(u.p, hash))) continue;
|
|
21822
|
+
appendEvent(d, { k: "divergence", kind: "external_mutation", path: u.p, hash });
|
|
21866
21823
|
}
|
|
21867
21824
|
const newCompactions = (t.compactions ?? 0) - (t.known?.compactions ?? 0);
|
|
21868
21825
|
for (let i2 = 0; i2 < newCompactions; i2++) {
|
|
@@ -22127,7 +22084,7 @@ async function fireClassify(prompt, sessionId, globals) {
|
|
|
22127
22084
|
logEvent("classify_skipped", { reason: "no_service_url", detail: urlResult.error });
|
|
22128
22085
|
return;
|
|
22129
22086
|
}
|
|
22130
|
-
const promptHash = (0,
|
|
22087
|
+
const promptHash = (0, import_node_crypto9.createHash)("sha256").update(prompt).digest("hex");
|
|
22131
22088
|
const result = await apiRequest({
|
|
22132
22089
|
method: "POST",
|
|
22133
22090
|
path: "/classify-task",
|
|
@@ -22171,7 +22128,7 @@ var import_node_path26 = require("node:path");
|
|
|
22171
22128
|
// src/lib/baseline.ts
|
|
22172
22129
|
var import_node_fs28 = require("node:fs");
|
|
22173
22130
|
var import_node_path25 = require("node:path");
|
|
22174
|
-
var
|
|
22131
|
+
var import_node_crypto10 = require("node:crypto");
|
|
22175
22132
|
|
|
22176
22133
|
// src/lib/snapshot.ts
|
|
22177
22134
|
var import_node_fs27 = require("node:fs");
|
|
@@ -22440,7 +22397,7 @@ var MIRROR_MAX_BYTES = 2 * 1024 * 1024;
|
|
|
22440
22397
|
var DEFAULT_SESSION_KEY = "_default";
|
|
22441
22398
|
function sessionKey(sessionId) {
|
|
22442
22399
|
if (!sessionId) return DEFAULT_SESSION_KEY;
|
|
22443
|
-
return (0,
|
|
22400
|
+
return (0, import_node_crypto10.createHash)("sha256").update(sessionId).digest("hex").slice(0, 16);
|
|
22444
22401
|
}
|
|
22445
22402
|
function sessionDir(key) {
|
|
22446
22403
|
return (0, import_node_path25.join)(projectPath(BASELINE_DIR), key);
|
|
@@ -22902,17 +22859,17 @@ async function readHookStdin() {
|
|
|
22902
22859
|
try {
|
|
22903
22860
|
if (process.stdin.isTTY) return {};
|
|
22904
22861
|
const chunks = [];
|
|
22905
|
-
const timeout = new Promise((
|
|
22906
|
-
const read2 = new Promise((
|
|
22862
|
+
const timeout = new Promise((resolve8) => setTimeout(() => resolve8({}), 500));
|
|
22863
|
+
const read2 = new Promise((resolve8) => {
|
|
22907
22864
|
process.stdin.on("data", (c) => chunks.push(c));
|
|
22908
22865
|
process.stdin.on("end", () => {
|
|
22909
22866
|
try {
|
|
22910
|
-
|
|
22867
|
+
resolve8(JSON.parse(Buffer.concat(chunks).toString("utf-8").trim() || "{}"));
|
|
22911
22868
|
} catch {
|
|
22912
|
-
|
|
22869
|
+
resolve8({});
|
|
22913
22870
|
}
|
|
22914
22871
|
});
|
|
22915
|
-
process.stdin.on("error", () =>
|
|
22872
|
+
process.stdin.on("error", () => resolve8({}));
|
|
22916
22873
|
process.stdin.resume();
|
|
22917
22874
|
});
|
|
22918
22875
|
return await Promise.race([read2, timeout]);
|
|
@@ -24360,10 +24317,10 @@ var import_node_fs38 = require("node:fs");
|
|
|
24360
24317
|
|
|
24361
24318
|
// src/lib/debounce.ts
|
|
24362
24319
|
var import_node_fs37 = require("node:fs");
|
|
24363
|
-
var
|
|
24320
|
+
var import_node_crypto11 = require("node:crypto");
|
|
24364
24321
|
function scopedFile(base, sessionId) {
|
|
24365
24322
|
if (!sessionId) return base;
|
|
24366
|
-
return `${base}.${(0,
|
|
24323
|
+
return `${base}.${(0, import_node_crypto11.createHash)("sha1").update(sessionId).digest("hex").slice(0, 12)}`;
|
|
24367
24324
|
}
|
|
24368
24325
|
function checkDebounce(debounceSeconds = DEBOUNCE_SECONDS, sessionId) {
|
|
24369
24326
|
const file = scopedFile(DEBOUNCE_FILE, sessionId);
|
|
@@ -24404,7 +24361,7 @@ function checkMtime(files, bypassForRecentCommits, sessionId) {
|
|
|
24404
24361
|
return "No files modified since last analysis";
|
|
24405
24362
|
}
|
|
24406
24363
|
function computeContentHash(files) {
|
|
24407
|
-
const hash = (0,
|
|
24364
|
+
const hash = (0, import_node_crypto11.createHash)("sha1");
|
|
24408
24365
|
const sorted = [...files].sort();
|
|
24409
24366
|
for (const f of sorted) {
|
|
24410
24367
|
const resolved = resolveFile(f) ?? f;
|
|
@@ -25027,7 +24984,6 @@ function createRun(opts, globals) {
|
|
|
25027
24984
|
|
|
25028
24985
|
// src/commands/analyze/index.ts
|
|
25029
24986
|
var import_node_fs52 = require("node:fs");
|
|
25030
|
-
var import_node_path40 = require("node:path");
|
|
25031
24987
|
|
|
25032
24988
|
// src/lib/repo-context.ts
|
|
25033
24989
|
var import_node_child_process11 = require("node:child_process");
|
|
@@ -26830,28 +26786,28 @@ async function readStopHookStdin() {
|
|
|
26830
26786
|
try {
|
|
26831
26787
|
if (process.stdin.isTTY) return empty;
|
|
26832
26788
|
const chunks = [];
|
|
26833
|
-
const timeout = new Promise((
|
|
26834
|
-
const read2 = new Promise((
|
|
26789
|
+
const timeout = new Promise((resolve8) => setTimeout(() => resolve8(empty), 500));
|
|
26790
|
+
const read2 = new Promise((resolve8) => {
|
|
26835
26791
|
process.stdin.on("data", (chunk) => chunks.push(chunk));
|
|
26836
26792
|
process.stdin.on("end", () => {
|
|
26837
26793
|
const raw = Buffer.concat(chunks).toString("utf-8").trim();
|
|
26838
26794
|
if (!raw) {
|
|
26839
|
-
|
|
26795
|
+
resolve8(empty);
|
|
26840
26796
|
return;
|
|
26841
26797
|
}
|
|
26842
26798
|
try {
|
|
26843
26799
|
const data = JSON.parse(raw);
|
|
26844
|
-
|
|
26800
|
+
resolve8({
|
|
26845
26801
|
assistantMessage: typeof data.last_assistant_message === "string" ? data.last_assistant_message : null,
|
|
26846
26802
|
stopReason: typeof data.stop_reason === "string" ? data.stop_reason : null,
|
|
26847
26803
|
transcriptPath: typeof data.transcript_path === "string" ? data.transcript_path : null,
|
|
26848
26804
|
sessionId: typeof data.session_id === "string" ? data.session_id : null
|
|
26849
26805
|
});
|
|
26850
26806
|
} catch {
|
|
26851
|
-
|
|
26807
|
+
resolve8(empty);
|
|
26852
26808
|
}
|
|
26853
26809
|
});
|
|
26854
|
-
process.stdin.on("error", () =>
|
|
26810
|
+
process.stdin.on("error", () => resolve8(empty));
|
|
26855
26811
|
process.stdin.resume();
|
|
26856
26812
|
});
|
|
26857
26813
|
return await Promise.race([read2, timeout]);
|
|
@@ -27117,7 +27073,7 @@ function channelSilence(input) {
|
|
|
27117
27073
|
// src/lib/cli-version.ts
|
|
27118
27074
|
function cliVersion() {
|
|
27119
27075
|
try {
|
|
27120
|
-
return true ? "0.34.0-experimental.
|
|
27076
|
+
return true ? "0.34.0-experimental.5235853" : "dev";
|
|
27121
27077
|
} catch {
|
|
27122
27078
|
return "dev";
|
|
27123
27079
|
}
|
|
@@ -28585,7 +28541,7 @@ async function contextFiles(run4) {
|
|
|
28585
28541
|
}
|
|
28586
28542
|
|
|
28587
28543
|
// src/lib/code/index.ts
|
|
28588
|
-
var
|
|
28544
|
+
var import_node_crypto12 = require("node:crypto");
|
|
28589
28545
|
|
|
28590
28546
|
// src/lib/code/languages.ts
|
|
28591
28547
|
var JS_LIKE = {
|
|
@@ -30363,7 +30319,7 @@ function byPath(fns, name2) {
|
|
|
30363
30319
|
function makeCodeMap(rt) {
|
|
30364
30320
|
const cache = /* @__PURE__ */ new Map();
|
|
30365
30321
|
const outline = (path, content, deadlineAt = Date.now() + DEFAULT_PARSE_MS) => {
|
|
30366
|
-
const key = `${path}\0${(0,
|
|
30322
|
+
const key = `${path}\0${(0, import_node_crypto12.createHash)("sha1").update(content).digest("hex")}`;
|
|
30367
30323
|
const hit = cache.get(key);
|
|
30368
30324
|
if (hit) return { source: "tree-sitter", value: hit, elapsedMs: 0 };
|
|
30369
30325
|
let r;
|
|
@@ -32126,11 +32082,11 @@ async function buildRequest(run4) {
|
|
|
32126
32082
|
|
|
32127
32083
|
// src/lib/offline.ts
|
|
32128
32084
|
var import_node_fs50 = require("node:fs");
|
|
32129
|
-
var
|
|
32085
|
+
var import_node_crypto13 = require("node:crypto");
|
|
32130
32086
|
function cacheRequest(body2) {
|
|
32131
32087
|
try {
|
|
32132
32088
|
(0, import_node_fs50.mkdirSync)(CACHE_DIR, { recursive: true });
|
|
32133
|
-
const suffix = (0,
|
|
32089
|
+
const suffix = (0, import_node_crypto13.randomBytes)(4).toString("hex");
|
|
32134
32090
|
const filename = `pending-${Math.floor(Date.now() / 1e3)}-${suffix}.json`;
|
|
32135
32091
|
(0, import_node_fs50.writeFileSync)(`${CACHE_DIR}/${filename}`, JSON.stringify(redactRequest(body2)));
|
|
32136
32092
|
} catch {
|
|
@@ -33106,7 +33062,7 @@ function registerAnalyzeCommand(program2) {
|
|
|
33106
33062
|
var tracing = () => process.env.VERITY_TRACE_PHASES === "1";
|
|
33107
33063
|
async function runAnalyze(opts, globals) {
|
|
33108
33064
|
if (!verityConfigured()) {
|
|
33109
|
-
(0, import_node_fs52.writeSync)(2,
|
|
33065
|
+
(0, import_node_fs52.writeSync)(2, '[verity] not set up in this project \u2014 run "verity init" first.\n');
|
|
33110
33066
|
process.exit(0);
|
|
33111
33067
|
}
|
|
33112
33068
|
const run4 = createRun(opts, globals);
|
|
@@ -33128,11 +33084,10 @@ async function runAnalyze(opts, globals) {
|
|
|
33128
33084
|
|
|
33129
33085
|
// src/commands/baseline.ts
|
|
33130
33086
|
var import_node_fs54 = require("node:fs");
|
|
33131
|
-
var import_node_path42 = require("node:path");
|
|
33132
33087
|
|
|
33133
33088
|
// src/lib/project-skills.ts
|
|
33134
33089
|
var import_node_fs53 = require("node:fs");
|
|
33135
|
-
var
|
|
33090
|
+
var import_node_path40 = require("node:path");
|
|
33136
33091
|
var PROJECT_SKILL_NAMES = [
|
|
33137
33092
|
"verity-setup",
|
|
33138
33093
|
"verity-analyze",
|
|
@@ -33159,13 +33114,13 @@ var ALL = [...PROJECT_SKILL_NAMES, ...LEGACY_SKILL_NAMES];
|
|
|
33159
33114
|
function staleProjectSkills() {
|
|
33160
33115
|
const root = projectPath(".claude/skills");
|
|
33161
33116
|
if (!(0, import_node_fs53.existsSync)(root)) return [];
|
|
33162
|
-
return ALL.filter((name2) => (0, import_node_fs53.existsSync)((0,
|
|
33117
|
+
return ALL.filter((name2) => (0, import_node_fs53.existsSync)((0, import_node_path40.join)(root, name2)));
|
|
33163
33118
|
}
|
|
33164
33119
|
function removeProjectSkills() {
|
|
33165
33120
|
const root = projectPath(".claude/skills");
|
|
33166
33121
|
const removed = [];
|
|
33167
33122
|
for (const name2 of staleProjectSkills()) {
|
|
33168
|
-
(0, import_node_fs53.rmSync)((0,
|
|
33123
|
+
(0, import_node_fs53.rmSync)((0, import_node_path40.join)(root, name2), { recursive: true, force: true });
|
|
33169
33124
|
removed.push(name2);
|
|
33170
33125
|
}
|
|
33171
33126
|
return removed;
|
|
@@ -33198,7 +33153,6 @@ function registerBaselineCommands(program2) {
|
|
|
33198
33153
|
const skewMsg = skew ? `Verity: your global \`verity\` CLI is ${skew.global} but the hooks run ${skew.hooks}. Fix it before using \`verity\` in a terminal: ${skew.remedy}` : null;
|
|
33199
33154
|
const skewNote = skew ? `Before anything else, including /verity:init's questions, tell the user their global \`verity\` is ${skew.global}, the hooks run ${skew.hooks}, and \`${skew.remedy}\` fixes it. Until they have, do not send them to run \`verity login\` in a terminal: that runs the global one, which can sign this machine in to a different server.` : null;
|
|
33200
33155
|
if (!verityConfigured()) {
|
|
33201
|
-
if (isMachineStore((0, import_node_path42.join)(repoRoot(), VERITY_DIR))) process.exit(0);
|
|
33202
33156
|
const how = isPluginInvocation() ? "Tell the user to run /verity:init \u2014 they type it; you cannot invoke it." : "Tell the user to run `verity init` in their terminal.";
|
|
33203
33157
|
const lines = [
|
|
33204
33158
|
`Verity is installed but this project is not set up yet, so the quality gate will not review anything here. ${how}`
|
|
@@ -33422,7 +33376,7 @@ async function runReview(opts, globals) {
|
|
|
33422
33376
|
|
|
33423
33377
|
// src/commands/guard.ts
|
|
33424
33378
|
var import_node_fs59 = require("node:fs");
|
|
33425
|
-
var
|
|
33379
|
+
var import_node_path45 = require("node:path");
|
|
33426
33380
|
|
|
33427
33381
|
// src/lib/terminal-text.ts
|
|
33428
33382
|
var CONTROL = /[\x00-\x08\x0b-\x1f\x7f-\x9f\u061c\u200e\u200f\u2028-\u202e\u2066-\u2069]/g;
|
|
@@ -33515,7 +33469,7 @@ async function runAgentReview(options) {
|
|
|
33515
33469
|
}
|
|
33516
33470
|
if (!settled) {
|
|
33517
33471
|
const wait = Math.max(0, remaining() - FINISH_TIMEOUT_MS);
|
|
33518
|
-
await Promise.race([oneShotDone, new Promise((
|
|
33472
|
+
await Promise.race([oneShotDone, new Promise((resolve8) => setTimeout(resolve8, wait))]);
|
|
33519
33473
|
}
|
|
33520
33474
|
const finished = await options.http.post(
|
|
33521
33475
|
"/agent-review/finish",
|
|
@@ -33530,8 +33484,8 @@ async function runAgentReview(options) {
|
|
|
33530
33484
|
}
|
|
33531
33485
|
|
|
33532
33486
|
// src/lib/prove/auto.ts
|
|
33533
|
-
var
|
|
33534
|
-
var
|
|
33487
|
+
var import_node_path44 = require("node:path");
|
|
33488
|
+
var import_node_crypto18 = require("node:crypto");
|
|
33535
33489
|
|
|
33536
33490
|
// src/lib/prove/signals.ts
|
|
33537
33491
|
var DEFAULT_SINCE = "180 days ago";
|
|
@@ -35259,16 +35213,16 @@ var import_node_child_process15 = require("node:child_process");
|
|
|
35259
35213
|
var import_node_os8 = require("node:os");
|
|
35260
35214
|
var import_node_fs58 = require("node:fs");
|
|
35261
35215
|
var import_node_os9 = require("node:os");
|
|
35262
|
-
var
|
|
35216
|
+
var import_node_path43 = require("node:path");
|
|
35263
35217
|
|
|
35264
35218
|
// src/lib/prove/scaffold.ts
|
|
35265
35219
|
var import_node_fs57 = require("node:fs");
|
|
35266
|
-
var
|
|
35220
|
+
var import_node_path42 = require("node:path");
|
|
35267
35221
|
|
|
35268
35222
|
// src/lib/prove/safe-write.ts
|
|
35269
35223
|
var import_node_fs56 = require("node:fs");
|
|
35270
|
-
var
|
|
35271
|
-
var
|
|
35224
|
+
var import_node_crypto14 = require("node:crypto");
|
|
35225
|
+
var import_node_path41 = require("node:path");
|
|
35272
35226
|
var SafeWriteError = class extends Error {
|
|
35273
35227
|
constructor(reason, path) {
|
|
35274
35228
|
super(`refusing to write ${path}: ${reason}`);
|
|
@@ -35280,7 +35234,7 @@ var SafeWriteError = class extends Error {
|
|
|
35280
35234
|
var FLAGS3 = import_node_fs56.constants;
|
|
35281
35235
|
var NOFOLLOW2 = FLAGS3.O_NOFOLLOW ?? 0;
|
|
35282
35236
|
function assertPlainRelative(rel) {
|
|
35283
|
-
if (!rel || (0,
|
|
35237
|
+
if (!rel || (0, import_node_path41.isAbsolute)(rel)) throw new SafeWriteError("bad-path", rel);
|
|
35284
35238
|
for (const part of rel.split(/[\\/]/)) {
|
|
35285
35239
|
if (part === ".." || part === "" || part === ".") throw new SafeWriteError("bad-path", rel);
|
|
35286
35240
|
}
|
|
@@ -35289,7 +35243,7 @@ function ensureDirsNoFollow(root, rel) {
|
|
|
35289
35243
|
const parts2 = rel.split(/[\\/]/);
|
|
35290
35244
|
let cur = root;
|
|
35291
35245
|
for (const part of parts2.slice(0, -1)) {
|
|
35292
|
-
cur = (0,
|
|
35246
|
+
cur = (0, import_node_path41.join)(cur, part);
|
|
35293
35247
|
let st;
|
|
35294
35248
|
try {
|
|
35295
35249
|
st = (0, import_node_fs56.lstatSync)(cur);
|
|
@@ -35300,10 +35254,10 @@ function ensureDirsNoFollow(root, rel) {
|
|
|
35300
35254
|
if (st.isSymbolicLink()) throw new SafeWriteError("symlink", cur);
|
|
35301
35255
|
if (!st.isDirectory()) throw new SafeWriteError("not-regular", cur);
|
|
35302
35256
|
}
|
|
35303
|
-
return (0,
|
|
35257
|
+
return (0, import_node_path41.join)(root, rel);
|
|
35304
35258
|
}
|
|
35305
35259
|
function insideRoot(realRoot, realPath) {
|
|
35306
|
-
return realPath === realRoot || realPath.startsWith(realRoot.endsWith(
|
|
35260
|
+
return realPath === realRoot || realPath.startsWith(realRoot.endsWith(import_node_path41.sep) ? realRoot : realRoot + import_node_path41.sep);
|
|
35307
35261
|
}
|
|
35308
35262
|
function removeQuietly(path) {
|
|
35309
35263
|
try {
|
|
@@ -35314,7 +35268,7 @@ function removeQuietly(path) {
|
|
|
35314
35268
|
function writeFileInRootNoFollow(root, rel, content) {
|
|
35315
35269
|
assertPlainRelative(rel);
|
|
35316
35270
|
const dest = ensureDirsNoFollow(root, rel);
|
|
35317
|
-
const dir = (0,
|
|
35271
|
+
const dir = (0, import_node_path41.dirname)(dest);
|
|
35318
35272
|
try {
|
|
35319
35273
|
const st = (0, import_node_fs56.lstatSync)(dest);
|
|
35320
35274
|
if (st.isSymbolicLink()) throw new SafeWriteError("symlink", dest);
|
|
@@ -35328,7 +35282,7 @@ function writeFileInRootNoFollow(root, rel, content) {
|
|
|
35328
35282
|
} catch {
|
|
35329
35283
|
throw new SafeWriteError("unwritable", root);
|
|
35330
35284
|
}
|
|
35331
|
-
const tmp = (0,
|
|
35285
|
+
const tmp = (0, import_node_path41.join)(dir, `.${(0, import_node_path41.basename)(dest)}.${(0, import_node_crypto14.randomBytes)(6).toString("hex")}.tmp`);
|
|
35332
35286
|
let fd;
|
|
35333
35287
|
try {
|
|
35334
35288
|
fd = (0, import_node_fs56.openSync)(tmp, import_node_fs56.constants.O_WRONLY | import_node_fs56.constants.O_CREAT | import_node_fs56.constants.O_EXCL | NOFOLLOW2, 420);
|
|
@@ -35372,7 +35326,7 @@ function pathHasNoLink(root, rel) {
|
|
|
35372
35326
|
}
|
|
35373
35327
|
let cur = root;
|
|
35374
35328
|
for (const part of rel.split(/[\\/]/)) {
|
|
35375
|
-
cur = cur +
|
|
35329
|
+
cur = cur + import_node_path41.sep + part;
|
|
35376
35330
|
try {
|
|
35377
35331
|
if ((0, import_node_fs56.lstatSync)(cur).isSymbolicLink()) return false;
|
|
35378
35332
|
} catch {
|
|
@@ -35684,20 +35638,20 @@ This directory is machine-local and gitignored (see ../.gitignore). Models are
|
|
|
35684
35638
|
never committed; what reaches the team is the bug report and the fix.
|
|
35685
35639
|
`;
|
|
35686
35640
|
function scaffoldProofs(root) {
|
|
35687
|
-
const proofsDir = (0,
|
|
35641
|
+
const proofsDir = (0, import_node_path42.join)(root, PROOFS_DIR);
|
|
35688
35642
|
const written = [];
|
|
35689
35643
|
const kept = [];
|
|
35690
35644
|
for (const stray of ["lakefile.lean"]) {
|
|
35691
35645
|
const rel = `${PROOFS_DIR}/${stray}`;
|
|
35692
|
-
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0,
|
|
35646
|
+
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path42.join)(root, rel));
|
|
35693
35647
|
try {
|
|
35694
|
-
(0, import_node_fs57.rmSync)((0,
|
|
35648
|
+
(0, import_node_fs57.rmSync)((0, import_node_path42.join)(root, rel), { force: true });
|
|
35695
35649
|
} catch {
|
|
35696
35650
|
}
|
|
35697
35651
|
}
|
|
35698
35652
|
for (const f of PROOFS_TEMPLATE_FILES) {
|
|
35699
35653
|
const rel = `${PROOFS_DIR}/${f.path}`;
|
|
35700
|
-
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0,
|
|
35654
|
+
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path42.join)(root, rel));
|
|
35701
35655
|
const current = readRegularFileInRoot(root, rel, 4 * 1024 * 1024);
|
|
35702
35656
|
if (current.ok && current.content === f.content) {
|
|
35703
35657
|
kept.push(rel);
|
|
@@ -35710,8 +35664,8 @@ function scaffoldProofs(root) {
|
|
|
35710
35664
|
[`${PROOFS_DIR}/.gitignore`, LOCAL_GITIGNORE],
|
|
35711
35665
|
[`${MODELS_DIR}/README.md`, MODELS_README]
|
|
35712
35666
|
]) {
|
|
35713
|
-
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0,
|
|
35714
|
-
if (existsNoFollow((0,
|
|
35667
|
+
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path42.join)(root, rel));
|
|
35668
|
+
if (existsNoFollow((0, import_node_path42.join)(root, rel))) {
|
|
35715
35669
|
kept.push(rel);
|
|
35716
35670
|
continue;
|
|
35717
35671
|
}
|
|
@@ -35730,7 +35684,7 @@ function existsNoFollow(abs) {
|
|
|
35730
35684
|
}
|
|
35731
35685
|
|
|
35732
35686
|
// src/lib/prove/report.ts
|
|
35733
|
-
var
|
|
35687
|
+
var import_node_crypto15 = require("node:crypto");
|
|
35734
35688
|
var IDENT2 = /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,63}$/;
|
|
35735
35689
|
var SHA256 = /^(sha256:)?[0-9a-f]{64}$/;
|
|
35736
35690
|
var KINDS2 = /* @__PURE__ */ new Set(["structural", "intent"]);
|
|
@@ -35878,7 +35832,7 @@ function sha256InRoot(root, file) {
|
|
|
35878
35832
|
const opened = openRegularInRoot(root, file);
|
|
35879
35833
|
if (!opened.ok) return null;
|
|
35880
35834
|
try {
|
|
35881
|
-
return (0,
|
|
35835
|
+
return (0, import_node_crypto15.createHash)("sha256").update(readOpened(opened.fd, opened.size)).digest("hex");
|
|
35882
35836
|
} catch {
|
|
35883
35837
|
return null;
|
|
35884
35838
|
}
|
|
@@ -35980,17 +35934,17 @@ function renderReport(r) {
|
|
|
35980
35934
|
|
|
35981
35935
|
// src/lib/prove/runner.ts
|
|
35982
35936
|
function verityLeanHome(env = process.env) {
|
|
35983
|
-
return env.VERITY_LEAN_HOME ?? (0,
|
|
35937
|
+
return env.VERITY_LEAN_HOME ?? (0, import_node_path43.join)(env.HOME ?? (0, import_node_os9.homedir)(), ".verity", "lean");
|
|
35984
35938
|
}
|
|
35985
35939
|
function findToolchain(env = process.env) {
|
|
35986
|
-
const managedBin = (0,
|
|
35987
|
-
const elanBin = (0,
|
|
35988
|
-
const elanHas = (0, import_node_fs58.existsSync)((0,
|
|
35989
|
-
const userPath = (env.PATH ?? "").split(
|
|
35990
|
-
const path = [managedBin, ...elanHas ? [elanBin] : [], ...userPath].join(
|
|
35940
|
+
const managedBin = (0, import_node_path43.join)(verityLeanHome(env), LEAN_TOOLCHAIN.replace(/^leanprover\/lean4:/, ""), "bin");
|
|
35941
|
+
const elanBin = (0, import_node_path43.join)(env.HOME ?? (0, import_node_os9.homedir)(), ".elan", "bin");
|
|
35942
|
+
const elanHas = (0, import_node_fs58.existsSync)((0, import_node_path43.join)(env.HOME ?? (0, import_node_os9.homedir)(), ".elan", "toolchains", LEAN_TOOLCHAIN.replace("/", "--").replace(":", "---")));
|
|
35943
|
+
const userPath = (env.PATH ?? "").split(import_node_path43.delimiter).filter((d) => d && (elanHas || (0, import_node_path43.resolve)(d) !== (0, import_node_path43.resolve)(elanBin)));
|
|
35944
|
+
const path = [managedBin, ...elanHas ? [elanBin] : [], ...userPath].join(import_node_path43.delimiter);
|
|
35991
35945
|
const merged = { ...env, PATH: path, ELAN_TOOLCHAIN: env.ELAN_TOOLCHAIN ?? LEAN_TOOLCHAIN };
|
|
35992
35946
|
const exe = process.platform === "win32" ? "lake.exe" : "lake";
|
|
35993
|
-
const candidates2 = [(0,
|
|
35947
|
+
const candidates2 = [(0, import_node_path43.join)(managedBin, exe), ...elanHas ? [(0, import_node_path43.join)(elanBin, exe)] : [], exe];
|
|
35994
35948
|
for (const candidate of candidates2) {
|
|
35995
35949
|
try {
|
|
35996
35950
|
(0, import_node_child_process15.execFileSync)(candidate, ["--version"], { env: merged, stdio: ["ignore", "pipe", "pipe"], timeout: 1e4 });
|
|
@@ -36028,7 +35982,7 @@ function run2(tc, cwd, args2, timeoutMs) {
|
|
|
36028
35982
|
function runAsync(tc, cwd, args2, timeoutMs) {
|
|
36029
35983
|
const started = Date.now();
|
|
36030
35984
|
const MAX = 16 * 1024 * 1024;
|
|
36031
|
-
return new Promise((
|
|
35985
|
+
return new Promise((resolve8) => {
|
|
36032
35986
|
const posix = (0, import_node_os8.platform)() !== "win32";
|
|
36033
35987
|
const child = (0, import_node_child_process15.spawn)(tc.lake, args2, { cwd, env: tc.env, stdio: ["ignore", "pipe", "pipe"], detached: posix });
|
|
36034
35988
|
let stdout = "";
|
|
@@ -36056,8 +36010,8 @@ function runAsync(tc, cwd, args2, timeoutMs) {
|
|
|
36056
36010
|
if (settled) return;
|
|
36057
36011
|
settled = true;
|
|
36058
36012
|
clearTimeout(timer);
|
|
36059
|
-
if (ok)
|
|
36060
|
-
else
|
|
36013
|
+
if (ok) resolve8({ ok: true, stdout, stderr: "", durationMs: Date.now() - started, timedOut: false });
|
|
36014
|
+
else resolve8({ ok: false, stdout, stderr: stderr || message || "", durationMs: Date.now() - started, timedOut });
|
|
36061
36015
|
};
|
|
36062
36016
|
child.on("error", (err2) => finish(false, err2.message));
|
|
36063
36017
|
child.on("close", (code) => finish(code === 0 && !timedOut));
|
|
@@ -36069,7 +36023,7 @@ function proofsWorkspaceProblem(root) {
|
|
|
36069
36023
|
for (const rel of [".verity", PROOFS_DIR, `${PROOFS_DIR}/.lake`]) {
|
|
36070
36024
|
let st;
|
|
36071
36025
|
try {
|
|
36072
|
-
st = (0, import_node_fs58.lstatSync)((0,
|
|
36026
|
+
st = (0, import_node_fs58.lstatSync)((0, import_node_path43.join)(root, rel));
|
|
36073
36027
|
} catch {
|
|
36074
36028
|
break;
|
|
36075
36029
|
}
|
|
@@ -36089,44 +36043,44 @@ function refused(problem) {
|
|
|
36089
36043
|
function buildLibrary(tc, root, timeoutMs = DEFAULT_BUILD_TIMEOUT_MS) {
|
|
36090
36044
|
const problem = proofsWorkspaceProblem(root);
|
|
36091
36045
|
if (problem) return refused(problem);
|
|
36092
|
-
return run2(tc, (0,
|
|
36046
|
+
return run2(tc, (0, import_node_path43.join)(root, PROOFS_DIR), ["build"], timeoutMs);
|
|
36093
36047
|
}
|
|
36094
36048
|
async function buildLibraryAsync(tc, root, timeoutMs = DEFAULT_BUILD_TIMEOUT_MS) {
|
|
36095
36049
|
const problem = proofsWorkspaceProblem(root);
|
|
36096
36050
|
if (problem) return refused(problem);
|
|
36097
|
-
return runAsync(tc, (0,
|
|
36051
|
+
return runAsync(tc, (0, import_node_path43.join)(root, PROOFS_DIR), ["build"], timeoutMs);
|
|
36098
36052
|
}
|
|
36099
36053
|
function isModelInRoot(modelsAbs, rel) {
|
|
36100
|
-
if (!rel.endsWith(".lean") || (0,
|
|
36054
|
+
if (!rel.endsWith(".lean") || (0, import_node_path43.isAbsolute)(rel) || rel.startsWith("..")) return false;
|
|
36101
36055
|
return statRegularInRoot(modelsAbs, rel).ok;
|
|
36102
36056
|
}
|
|
36103
36057
|
function resolveModelFile(root, arg) {
|
|
36104
|
-
const modelsAbs = (0,
|
|
36105
|
-
const asPath = (0,
|
|
36058
|
+
const modelsAbs = (0, import_node_path43.join)(root, MODELS_DIR);
|
|
36059
|
+
const asPath = (0, import_node_path43.relative)(modelsAbs, (0, import_node_path43.isAbsolute)(arg) ? arg : (0, import_node_path43.resolve)(root, arg));
|
|
36106
36060
|
const candidates2 = arg.includes("/") || arg.includes("\\") ? [asPath] : [arg, `${arg}.lean`];
|
|
36107
36061
|
for (const rel of candidates2) {
|
|
36108
|
-
if (isModelInRoot(modelsAbs, rel)) return (0,
|
|
36062
|
+
if (isModelInRoot(modelsAbs, rel)) return (0, import_node_path43.join)(modelsAbs, rel);
|
|
36109
36063
|
}
|
|
36110
36064
|
return null;
|
|
36111
36065
|
}
|
|
36112
36066
|
function listModelFiles(root) {
|
|
36113
|
-
const modelsAbs = (0,
|
|
36067
|
+
const modelsAbs = (0, import_node_path43.join)(root, MODELS_DIR);
|
|
36114
36068
|
if (!(0, import_node_fs58.existsSync)(modelsAbs)) return [];
|
|
36115
|
-
return (0, import_node_fs58.readdirSync)(modelsAbs).filter((f) => isModelInRoot(modelsAbs, f)).sort().map((f) => (0,
|
|
36069
|
+
return (0, import_node_fs58.readdirSync)(modelsAbs).filter((f) => isModelInRoot(modelsAbs, f)).sort().map((f) => (0, import_node_path43.join)(modelsAbs, f));
|
|
36116
36070
|
}
|
|
36117
36071
|
function trimDiagnostics(text) {
|
|
36118
36072
|
return text.split("\n").filter((l) => !l.startsWith("trace:")).join("\n").trim().slice(0, 4e3);
|
|
36119
36073
|
}
|
|
36120
36074
|
function checkModel(tc, root, modelFile, opts = {}) {
|
|
36121
|
-
const proofsAbs = (0,
|
|
36122
|
-
const rel = (0,
|
|
36075
|
+
const proofsAbs = (0, import_node_path43.join)(root, PROOFS_DIR);
|
|
36076
|
+
const rel = (0, import_node_path43.relative)(proofsAbs, modelFile);
|
|
36123
36077
|
const problem = proofsWorkspaceProblem(root);
|
|
36124
36078
|
const res = problem ? refused(problem) : run2(tc, proofsAbs, ["env", "lean", rel], opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
|
|
36125
36079
|
return toReport(res, root, modelFile, opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
|
|
36126
36080
|
}
|
|
36127
36081
|
async function checkModelAsync(tc, root, modelFile, opts = {}) {
|
|
36128
|
-
const proofsAbs = (0,
|
|
36129
|
-
const rel = (0,
|
|
36082
|
+
const proofsAbs = (0, import_node_path43.join)(root, PROOFS_DIR);
|
|
36083
|
+
const rel = (0, import_node_path43.relative)(proofsAbs, modelFile);
|
|
36130
36084
|
const problem = proofsWorkspaceProblem(root);
|
|
36131
36085
|
const res = problem ? refused(problem) : await runAsync(tc, proofsAbs, ["env", "lean", rel], opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
|
|
36132
36086
|
return toReport(res, root, modelFile, opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
|
|
@@ -36135,10 +36089,10 @@ function toReport(res, root, modelFile, timeoutMs) {
|
|
|
36135
36089
|
const parsed = parseVerityLines(res.stdout);
|
|
36136
36090
|
const combined = `${res.stdout}
|
|
36137
36091
|
${res.stderr}`;
|
|
36138
|
-
const name2 = parsed.header?.model ?? (0,
|
|
36092
|
+
const name2 = parsed.header?.model ?? (0, import_node_path43.basename)(modelFile, ".lean");
|
|
36139
36093
|
const report = {
|
|
36140
36094
|
model: name2,
|
|
36141
|
-
file: (0,
|
|
36095
|
+
file: (0, import_node_path43.relative)(root, modelFile),
|
|
36142
36096
|
ok: res.ok,
|
|
36143
36097
|
header: parsed.header,
|
|
36144
36098
|
properties: parsed.properties,
|
|
@@ -36213,7 +36167,7 @@ function mergeFormalFindings(response, outcome, pushedFiles) {
|
|
|
36213
36167
|
}
|
|
36214
36168
|
|
|
36215
36169
|
// src/lib/prove/scalpel.ts
|
|
36216
|
-
var
|
|
36170
|
+
var import_node_crypto16 = require("node:crypto");
|
|
36217
36171
|
var ARITHMETIC = /Math\.(?:round|floor|ceil|trunc)\(|\bround\(|\bdivmod\(|[\w)\]]\s*(?:\*|\/(?!\/)|%)\s*[\w(]/;
|
|
36218
36172
|
function functionHazard(numbered2) {
|
|
36219
36173
|
const sites = effectSites(numbered2);
|
|
@@ -36243,7 +36197,7 @@ function semanticFingerprint(numbered2) {
|
|
|
36243
36197
|
if (LOG_LINE.test(t)) continue;
|
|
36244
36198
|
kept.push(t.replace(/\s+/g, " "));
|
|
36245
36199
|
}
|
|
36246
|
-
return (0,
|
|
36200
|
+
return (0, import_node_crypto16.createHash)("sha256").update(kept.join("\n")).digest("hex");
|
|
36247
36201
|
}
|
|
36248
36202
|
function readVerified(root, now = Date.now()) {
|
|
36249
36203
|
const read2 = readRegularFileInRoot(root, VERIFIED_FILE, 256 * 1024);
|
|
@@ -36266,9 +36220,9 @@ function recordVerified(root, rec, now = Date.now()) {
|
|
|
36266
36220
|
}
|
|
36267
36221
|
|
|
36268
36222
|
// src/lib/prove/context.ts
|
|
36269
|
-
var
|
|
36223
|
+
var import_node_crypto17 = require("node:crypto");
|
|
36270
36224
|
var CONTEXT_BUDGET_MS = 2e3;
|
|
36271
|
-
var sha256 = (s) => (0,
|
|
36225
|
+
var sha256 = (s) => (0, import_node_crypto17.createHash)("sha256").update(s).digest("hex");
|
|
36272
36226
|
var TEST_PATH4 = /(^|\/)(tests?|__tests__|spec)\/|\.(test|spec)\.[a-z]+$/;
|
|
36273
36227
|
function slice(content, f, maxLines) {
|
|
36274
36228
|
const all = content.split("\n");
|
|
@@ -36457,7 +36411,7 @@ function workingTreeReader(root) {
|
|
|
36457
36411
|
};
|
|
36458
36412
|
}
|
|
36459
36413
|
function sha256Of(content) {
|
|
36460
|
-
return (0,
|
|
36414
|
+
return (0, import_node_crypto18.createHash)("sha256").update(content).digest("hex");
|
|
36461
36415
|
}
|
|
36462
36416
|
function defaultDeps(opts) {
|
|
36463
36417
|
const env = opts.env ?? process.env;
|
|
@@ -36708,7 +36662,7 @@ async function runFormalPhase(input) {
|
|
|
36708
36662
|
modelName = gen.name;
|
|
36709
36663
|
const rel = `${AUTO_MODELS_DIR}/${gen.name}.lean`;
|
|
36710
36664
|
writeFileInRootNoFollow(root, rel, gen.source);
|
|
36711
|
-
const abs = resolveModelFile(root, rel) ?? (0,
|
|
36665
|
+
const abs = resolveModelFile(root, rel) ?? (0, import_node_path44.join)(root, rel);
|
|
36712
36666
|
progress.model = { name: gen.name, file: rel, rounds: round };
|
|
36713
36667
|
progress.step = "check";
|
|
36714
36668
|
report = await deps.check(root, abs);
|
|
@@ -36769,11 +36723,11 @@ async function runFormalPhase(input) {
|
|
|
36769
36723
|
const budget = Math.max(2e4, timeLeft() - 5e3);
|
|
36770
36724
|
const byId = /* @__PURE__ */ new Map();
|
|
36771
36725
|
let stoppedEarly = false;
|
|
36772
|
-
await new Promise((
|
|
36726
|
+
await new Promise((resolve8) => {
|
|
36773
36727
|
let left = toReplay.length;
|
|
36774
|
-
if (left === 0) return
|
|
36728
|
+
if (left === 0) return resolve8();
|
|
36775
36729
|
const settle = () => {
|
|
36776
|
-
if (--left === 0)
|
|
36730
|
+
if (--left === 0) resolve8();
|
|
36777
36731
|
};
|
|
36778
36732
|
for (const p of toReplay) {
|
|
36779
36733
|
void (async () => {
|
|
@@ -36786,7 +36740,7 @@ async function runFormalPhase(input) {
|
|
|
36786
36740
|
if (!stoppedEarly) byId.set(p.id, r);
|
|
36787
36741
|
if (r.verdict === "reproduced" && !stoppedEarly && !isCrash(p)) {
|
|
36788
36742
|
stoppedEarly = true;
|
|
36789
|
-
|
|
36743
|
+
resolve8();
|
|
36790
36744
|
}
|
|
36791
36745
|
})().catch(() => {
|
|
36792
36746
|
byId.set(p.id, null);
|
|
@@ -36830,7 +36784,7 @@ async function runFormalPhase(input) {
|
|
|
36830
36784
|
return done({
|
|
36831
36785
|
status: "checked",
|
|
36832
36786
|
target,
|
|
36833
|
-
model: { name: modelName, file: (0,
|
|
36787
|
+
model: { name: modelName, file: (0, import_node_path44.relative)(root, (0, import_node_path44.join)(root, modelFile)), rounds },
|
|
36834
36788
|
properties: report.properties,
|
|
36835
36789
|
findings
|
|
36836
36790
|
});
|
|
@@ -36893,7 +36847,7 @@ async function generateAndCheck(root, req, opts) {
|
|
|
36893
36847
|
}
|
|
36894
36848
|
const rel = `${dir}/${gen.name}.lean`;
|
|
36895
36849
|
writeFileInRootNoFollow(root, rel, gen.source);
|
|
36896
|
-
const abs = resolveModelFile(root, rel) ?? (0,
|
|
36850
|
+
const abs = resolveModelFile(root, rel) ?? (0, import_node_path44.join)(root, rel);
|
|
36897
36851
|
const report = await opts.deps.check(root, abs);
|
|
36898
36852
|
const abstracts = report.header?.abstracts ?? [];
|
|
36899
36853
|
const stray = abstracts.find((a) => !headerFiles.has(a.file)) ?? (abstracts[0] && abstracts[0].file !== req.file ? abstracts[0] : void 0);
|
|
@@ -36981,10 +36935,10 @@ function runFormalPhaseWithin(input) {
|
|
|
36981
36935
|
if (left <= 0) return Promise.resolve(skippedOutcome("deadline", "no time left"));
|
|
36982
36936
|
const progress = input.progress ?? {};
|
|
36983
36937
|
let timer = null;
|
|
36984
|
-
const cutoff = new Promise((
|
|
36938
|
+
const cutoff = new Promise((resolve8) => {
|
|
36985
36939
|
timer = setTimeout(() => {
|
|
36986
36940
|
progress.cancelled = true;
|
|
36987
|
-
|
|
36941
|
+
resolve8(cutOffOutcome(progress, `hard stop after ${Math.round(left / 1e3)} s during ${progress.step ?? "setup"}`, left));
|
|
36988
36942
|
}, left);
|
|
36989
36943
|
});
|
|
36990
36944
|
return Promise.race([runFormalPhase({ ...input, progress }), cutoff]).finally(() => {
|
|
@@ -37022,12 +36976,12 @@ var EXCERPT_SOURCE_MAX_BYTES = 2 * 1024 * 1024;
|
|
|
37022
36976
|
var WRITERS_BUDGET_MS = 1500;
|
|
37023
36977
|
var EXCERPT_MAX_LINES2 = 30;
|
|
37024
36978
|
var GUARD_BLOCK_CAP = 2;
|
|
37025
|
-
var GUARD_ITER_FILE = (0,
|
|
36979
|
+
var GUARD_ITER_FILE = (0, import_node_path45.join)(VERITY_DIR, ".guard-iteration");
|
|
37026
36980
|
function readPreToolUseStdin() {
|
|
37027
36981
|
const empty = { command: "", cwd: null, sessionId: null };
|
|
37028
|
-
return new Promise((
|
|
36982
|
+
return new Promise((resolve8) => {
|
|
37029
36983
|
try {
|
|
37030
|
-
if (process.stdin.isTTY) return
|
|
36984
|
+
if (process.stdin.isTTY) return resolve8(empty);
|
|
37031
36985
|
const chunks = [];
|
|
37032
36986
|
let timer;
|
|
37033
36987
|
let settled = false;
|
|
@@ -37040,7 +36994,7 @@ function readPreToolUseStdin() {
|
|
|
37040
36994
|
process.stdin.removeListener("end", onEnd);
|
|
37041
36995
|
process.stdin.removeListener("error", onError);
|
|
37042
36996
|
process.stdin.pause();
|
|
37043
|
-
|
|
36997
|
+
resolve8(value);
|
|
37044
36998
|
};
|
|
37045
36999
|
const onEnd = () => {
|
|
37046
37000
|
try {
|
|
@@ -37061,7 +37015,7 @@ function readPreToolUseStdin() {
|
|
|
37061
37015
|
process.stdin.on("error", onError);
|
|
37062
37016
|
process.stdin.resume();
|
|
37063
37017
|
} catch {
|
|
37064
|
-
|
|
37018
|
+
resolve8(empty);
|
|
37065
37019
|
}
|
|
37066
37020
|
});
|
|
37067
37021
|
}
|
|
@@ -37790,7 +37744,7 @@ function registerIgnoreCommand(program2) {
|
|
|
37790
37744
|
}
|
|
37791
37745
|
|
|
37792
37746
|
// src/commands/waive.ts
|
|
37793
|
-
var
|
|
37747
|
+
var import_node_crypto19 = require("node:crypto");
|
|
37794
37748
|
var import_node_fs60 = require("node:fs");
|
|
37795
37749
|
function registerWaiveCommand(program2) {
|
|
37796
37750
|
program2.command("waive <pattern-id>").description("Record an accepted-risk disposition for an open finding (voids when the file changes)").option("--file <path>", "File the finding is anchored to, REPO-RELATIVE (recommended \u2014 narrows the waive)").requiredOption("--reason <text>", "The human disposition this records (reviewer finding, ADR, \u2026)").action(async (patternId, opts) => {
|
|
@@ -37820,7 +37774,7 @@ function registerWaiveCommand(program2) {
|
|
|
37820
37774
|
if (opts.file) {
|
|
37821
37775
|
body2.file = opts.file;
|
|
37822
37776
|
try {
|
|
37823
|
-
body2.file_sha256 = (0,
|
|
37777
|
+
body2.file_sha256 = (0, import_node_crypto19.createHash)("sha256").update((0, import_node_fs60.readFileSync)(opts.file)).digest("hex");
|
|
37824
37778
|
} catch {
|
|
37825
37779
|
printError(`Cannot read ${opts.file} \u2014 run from the repo root, or omit --file to waive by pattern.`);
|
|
37826
37780
|
process.exit(1);
|
|
@@ -37848,7 +37802,7 @@ function registerWaiveCommand(program2) {
|
|
|
37848
37802
|
var import_node_fs65 = require("node:fs");
|
|
37849
37803
|
var import_promises20 = require("node:fs/promises");
|
|
37850
37804
|
var import_yaml6 = __toESM2(require_dist());
|
|
37851
|
-
var
|
|
37805
|
+
var import_node_path49 = require("node:path");
|
|
37852
37806
|
var import_node_child_process19 = require("node:child_process");
|
|
37853
37807
|
|
|
37854
37808
|
// src/lib/banner.ts
|
|
@@ -37988,13 +37942,13 @@ function checkAnalysisCli() {
|
|
|
37988
37942
|
}
|
|
37989
37943
|
var INSTALL_TIMEOUT_MS = 12e4;
|
|
37990
37944
|
function run3(command, args2, opts = {}) {
|
|
37991
|
-
return new Promise((
|
|
37945
|
+
return new Promise((resolve8) => {
|
|
37992
37946
|
const child = (0, import_node_child_process16.spawn)(command, args2, {
|
|
37993
37947
|
stdio: opts.inherit ? "inherit" : "pipe",
|
|
37994
37948
|
timeout: INSTALL_TIMEOUT_MS
|
|
37995
37949
|
});
|
|
37996
|
-
child.on("error", () =>
|
|
37997
|
-
child.on("close", (code) =>
|
|
37950
|
+
child.on("error", () => resolve8(false));
|
|
37951
|
+
child.on("close", (code) => resolve8(code === 0));
|
|
37998
37952
|
});
|
|
37999
37953
|
}
|
|
38000
37954
|
async function installAnalysisCli() {
|
|
@@ -38299,7 +38253,7 @@ function registerDoctorCommand(program2) {
|
|
|
38299
38253
|
|
|
38300
38254
|
// src/commands/migrate.ts
|
|
38301
38255
|
var import_node_fs62 = require("node:fs");
|
|
38302
|
-
var
|
|
38256
|
+
var import_node_path46 = require("node:path");
|
|
38303
38257
|
var import_node_child_process17 = require("node:child_process");
|
|
38304
38258
|
var LEGACY_NPM_PACKAGE = "@codacy/gate-cli";
|
|
38305
38259
|
function defaultNpmRemover(pkg) {
|
|
@@ -38336,8 +38290,8 @@ async function runMigration(opts = {}) {
|
|
|
38336
38290
|
return { actions, migrated: actions.length > 0 };
|
|
38337
38291
|
}
|
|
38338
38292
|
function migrateProjectDir(root, actions) {
|
|
38339
|
-
const gateDir = (0,
|
|
38340
|
-
const verityDir = (0,
|
|
38293
|
+
const gateDir = (0, import_node_path46.join)(root, ".gate");
|
|
38294
|
+
const verityDir = (0, import_node_path46.join)(root, ".verity");
|
|
38341
38295
|
if ((0, import_node_fs62.existsSync)(gateDir) && !(0, import_node_fs62.existsSync)(verityDir)) {
|
|
38342
38296
|
return migrateProjectDirRename(root, gateDir, verityDir, actions);
|
|
38343
38297
|
}
|
|
@@ -38391,11 +38345,11 @@ function migrateProjectDirCarry(gateDir, verityDir, actions) {
|
|
|
38391
38345
|
}
|
|
38392
38346
|
function migrateGlobalCredentials(home, actions) {
|
|
38393
38347
|
if (!home) return;
|
|
38394
|
-
const gateCreds = (0,
|
|
38395
|
-
const verityCreds = (0,
|
|
38348
|
+
const gateCreds = (0, import_node_path46.join)(home, ".gate", "credentials");
|
|
38349
|
+
const verityCreds = (0, import_node_path46.join)(home, ".verity", "credentials");
|
|
38396
38350
|
if (!(0, import_node_fs62.existsSync)(gateCreds)) return;
|
|
38397
38351
|
if (!(0, import_node_fs62.existsSync)(verityCreds)) {
|
|
38398
|
-
(0, import_node_fs62.mkdirSync)((0,
|
|
38352
|
+
(0, import_node_fs62.mkdirSync)((0, import_node_path46.join)(home, ".verity"), { recursive: true });
|
|
38399
38353
|
moveFile(gateCreds, verityCreds);
|
|
38400
38354
|
actions.push("Moved ~/.gate/credentials \u2192 ~/.verity/credentials");
|
|
38401
38355
|
return;
|
|
@@ -38417,7 +38371,7 @@ async function migrateLegacyHooks(root, actions) {
|
|
|
38417
38371
|
}
|
|
38418
38372
|
}
|
|
38419
38373
|
async function migrateClaudeMd(root, actions) {
|
|
38420
|
-
const claudeMd = (0,
|
|
38374
|
+
const claudeMd = (0, import_node_path46.join)(root, "CLAUDE.md");
|
|
38421
38375
|
const hadLegacyBlock = (0, import_node_fs62.existsSync)(claudeMd) && hasLegacyMemoryBlock(readFileSyncSafe(claudeMd));
|
|
38422
38376
|
if (!hadLegacyBlock) return;
|
|
38423
38377
|
try {
|
|
@@ -38428,8 +38382,8 @@ async function migrateClaudeMd(root, actions) {
|
|
|
38428
38382
|
}
|
|
38429
38383
|
}
|
|
38430
38384
|
function migrateStandardFile(root, actions) {
|
|
38431
|
-
const gateMd = (0,
|
|
38432
|
-
const verityMd = (0,
|
|
38385
|
+
const gateMd = (0, import_node_path46.join)(root, "GATE.md");
|
|
38386
|
+
const verityMd = (0, import_node_path46.join)(root, "VERITY.md");
|
|
38433
38387
|
if (!(0, import_node_fs62.existsSync)(gateMd) || (0, import_node_fs62.existsSync)(verityMd)) return;
|
|
38434
38388
|
let moved = false;
|
|
38435
38389
|
if (isGitRepo(root) && isGitTracked(root, "GATE.md")) {
|
|
@@ -38446,7 +38400,7 @@ function migrateStandardFile(root, actions) {
|
|
|
38446
38400
|
actions.push("Renamed GATE.md \u2192 VERITY.md");
|
|
38447
38401
|
}
|
|
38448
38402
|
async function migrateTelemetryHeaders(root, actions) {
|
|
38449
|
-
const file = (0,
|
|
38403
|
+
const file = (0, import_node_path46.join)(root, ".claude", "settings.local.json");
|
|
38450
38404
|
if (!(0, import_node_fs62.existsSync)(file)) return;
|
|
38451
38405
|
let settings;
|
|
38452
38406
|
try {
|
|
@@ -38536,15 +38490,15 @@ function moveFile(from, to) {
|
|
|
38536
38490
|
function carryLegacyContents(gateDir, verityDir) {
|
|
38537
38491
|
let copied = 0;
|
|
38538
38492
|
const walk2 = (relDir) => {
|
|
38539
|
-
const srcDir = (0,
|
|
38493
|
+
const srcDir = (0, import_node_path46.join)(gateDir, relDir);
|
|
38540
38494
|
for (const entry of (0, import_node_fs62.readdirSync)(srcDir)) {
|
|
38541
|
-
const rel = relDir ? (0,
|
|
38542
|
-
const src = (0,
|
|
38543
|
-
const dest = (0,
|
|
38495
|
+
const rel = relDir ? (0, import_node_path46.join)(relDir, entry) : entry;
|
|
38496
|
+
const src = (0, import_node_path46.join)(gateDir, rel);
|
|
38497
|
+
const dest = (0, import_node_path46.join)(verityDir, rel);
|
|
38544
38498
|
if ((0, import_node_fs62.statSync)(src).isDirectory()) {
|
|
38545
38499
|
walk2(rel);
|
|
38546
38500
|
} else if (!(0, import_node_fs62.existsSync)(dest)) {
|
|
38547
|
-
(0, import_node_fs62.mkdirSync)((0,
|
|
38501
|
+
(0, import_node_fs62.mkdirSync)((0, import_node_path46.dirname)(dest), { recursive: true });
|
|
38548
38502
|
(0, import_node_fs62.cpSync)(src, dest);
|
|
38549
38503
|
copied++;
|
|
38550
38504
|
}
|
|
@@ -38554,22 +38508,22 @@ function carryLegacyContents(gateDir, verityDir) {
|
|
|
38554
38508
|
return copied;
|
|
38555
38509
|
}
|
|
38556
38510
|
async function needsMigration(root = repoRoot()) {
|
|
38557
|
-
const gateDir = (0,
|
|
38558
|
-
const verityDir = (0,
|
|
38511
|
+
const gateDir = (0, import_node_path46.join)(root, ".gate");
|
|
38512
|
+
const verityDir = (0, import_node_path46.join)(root, ".verity");
|
|
38559
38513
|
if ((0, import_node_fs62.existsSync)(gateDir) && !(0, import_node_fs62.existsSync)(verityDir)) return true;
|
|
38560
38514
|
if ((0, import_node_fs62.existsSync)(gateDir) && (0, import_node_fs62.existsSync)(verityDir)) {
|
|
38561
|
-
if ((0, import_node_fs62.existsSync)((0,
|
|
38515
|
+
if ((0, import_node_fs62.existsSync)((0, import_node_path46.join)(gateDir, "credentials")) && !(0, import_node_fs62.existsSync)((0, import_node_path46.join)(verityDir, "credentials"))) {
|
|
38562
38516
|
return true;
|
|
38563
38517
|
}
|
|
38564
|
-
if ((0, import_node_fs62.existsSync)((0,
|
|
38518
|
+
if ((0, import_node_fs62.existsSync)((0, import_node_path46.join)(gateDir, "memory")) && !(0, import_node_fs62.existsSync)((0, import_node_path46.join)(verityDir, "memory"))) {
|
|
38565
38519
|
return true;
|
|
38566
38520
|
}
|
|
38567
38521
|
}
|
|
38568
|
-
const claudeMd = (0,
|
|
38522
|
+
const claudeMd = (0, import_node_path46.join)(root, "CLAUDE.md");
|
|
38569
38523
|
if ((0, import_node_fs62.existsSync)(claudeMd) && hasLegacyMemoryBlock(readFileSyncSafe(claudeMd))) {
|
|
38570
38524
|
return true;
|
|
38571
38525
|
}
|
|
38572
|
-
if ((0, import_node_fs62.existsSync)((0,
|
|
38526
|
+
if ((0, import_node_fs62.existsSync)((0, import_node_path46.join)(root, "GATE.md")) && !(0, import_node_fs62.existsSync)((0, import_node_path46.join)(root, "VERITY.md"))) {
|
|
38573
38527
|
return true;
|
|
38574
38528
|
}
|
|
38575
38529
|
if (await hasLegacyHooksAt(root)) return true;
|
|
@@ -38698,7 +38652,7 @@ function runSelect(opts) {
|
|
|
38698
38652
|
cursor: initialIdx[0] ?? 0,
|
|
38699
38653
|
chosen: new Set(mode2 === "single" ? [initialIdx[0] ?? 0] : initialIdx)
|
|
38700
38654
|
};
|
|
38701
|
-
return new Promise((
|
|
38655
|
+
return new Promise((resolve8) => {
|
|
38702
38656
|
let painted = 0;
|
|
38703
38657
|
let settled = false;
|
|
38704
38658
|
const draw = () => {
|
|
@@ -38746,7 +38700,7 @@ function runSelect(opts) {
|
|
|
38746
38700
|
if (settled) return;
|
|
38747
38701
|
settled = true;
|
|
38748
38702
|
restore();
|
|
38749
|
-
|
|
38703
|
+
resolve8(value);
|
|
38750
38704
|
};
|
|
38751
38705
|
readline2.emitKeypressEvents(input);
|
|
38752
38706
|
input.setRawMode(true);
|
|
@@ -38767,9 +38721,9 @@ async function askLine(question, io = {}) {
|
|
|
38767
38721
|
output: io.output ?? process.stdout
|
|
38768
38722
|
});
|
|
38769
38723
|
try {
|
|
38770
|
-
return await new Promise((
|
|
38771
|
-
rl.question(question).then((a) =>
|
|
38772
|
-
rl.once("close", () => setImmediate(() =>
|
|
38724
|
+
return await new Promise((resolve8) => {
|
|
38725
|
+
rl.question(question).then((a) => resolve8(a.trim())).catch(() => resolve8(null));
|
|
38726
|
+
rl.once("close", () => setImmediate(() => resolve8(null)));
|
|
38773
38727
|
});
|
|
38774
38728
|
} finally {
|
|
38775
38729
|
rl.close();
|
|
@@ -38851,10 +38805,10 @@ async function promptMultiSelect(question, choices, fallback) {
|
|
|
38851
38805
|
|
|
38852
38806
|
// src/lib/prove/lean-install.ts
|
|
38853
38807
|
var import_node_fs63 = require("node:fs");
|
|
38854
|
-
var
|
|
38808
|
+
var import_node_crypto20 = require("node:crypto");
|
|
38855
38809
|
var import_node_child_process18 = require("node:child_process");
|
|
38856
38810
|
var import_node_os10 = require("node:os");
|
|
38857
|
-
var
|
|
38811
|
+
var import_node_path47 = require("node:path");
|
|
38858
38812
|
var import_promises18 = require("node:stream/promises");
|
|
38859
38813
|
var import_node_stream = require("node:stream");
|
|
38860
38814
|
var RELEASES = "https://releases.lean-lang.org/lean4";
|
|
@@ -38868,7 +38822,7 @@ function freeBytes(dir) {
|
|
|
38868
38822
|
const st = (0, import_node_fs63.statfsSync)(d);
|
|
38869
38823
|
return Number(st.bavail) * Number(st.bsize);
|
|
38870
38824
|
} catch {
|
|
38871
|
-
const up = (0,
|
|
38825
|
+
const up = (0, import_node_path47.join)(d, "..");
|
|
38872
38826
|
if (up === d) return null;
|
|
38873
38827
|
d = up;
|
|
38874
38828
|
}
|
|
@@ -38888,9 +38842,9 @@ function expectedSha256(asset, version = pinnedVersion()) {
|
|
|
38888
38842
|
return LEAN_ASSET_SHA256[version]?.[asset] ?? null;
|
|
38889
38843
|
}
|
|
38890
38844
|
function sha256File(path) {
|
|
38891
|
-
return new Promise((
|
|
38892
|
-
const hash = (0,
|
|
38893
|
-
(0, import_node_fs63.createReadStream)(path).on("data", (chunk) => hash.update(chunk)).on("end", () =>
|
|
38845
|
+
return new Promise((resolve8, reject) => {
|
|
38846
|
+
const hash = (0, import_node_crypto20.createHash)("sha256");
|
|
38847
|
+
(0, import_node_fs63.createReadStream)(path).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve8(hash.digest("hex"))).on("error", reject);
|
|
38894
38848
|
});
|
|
38895
38849
|
}
|
|
38896
38850
|
async function verifyDownload(zip, asset, version = pinnedVersion()) {
|
|
@@ -38910,7 +38864,7 @@ function leanAssetName(version = pinnedVersion()) {
|
|
|
38910
38864
|
return suffix ? `lean-${v}-${suffix}.zip` : null;
|
|
38911
38865
|
}
|
|
38912
38866
|
function pinnedVersionDir(env = process.env) {
|
|
38913
|
-
return (0,
|
|
38867
|
+
return (0, import_node_path47.join)(verityLeanHome(env), pinnedVersion());
|
|
38914
38868
|
}
|
|
38915
38869
|
function lakeBinary() {
|
|
38916
38870
|
return (0, import_node_os10.platform)() === "win32" ? "lake.exe" : "lake";
|
|
@@ -38926,7 +38880,7 @@ function unzip(zip, dest) {
|
|
|
38926
38880
|
} catch (err2) {
|
|
38927
38881
|
errors.push(`${cmd}: ${String(err2.message).split("\n")[0].slice(0, 120)}`);
|
|
38928
38882
|
try {
|
|
38929
|
-
for (const e of (0, import_node_fs63.readdirSync)(dest)) (0, import_node_fs63.rmSync)((0,
|
|
38883
|
+
for (const e of (0, import_node_fs63.readdirSync)(dest)) (0, import_node_fs63.rmSync)((0, import_node_path47.join)(dest, e), { recursive: true, force: true });
|
|
38930
38884
|
} catch {
|
|
38931
38885
|
}
|
|
38932
38886
|
}
|
|
@@ -39002,10 +38956,10 @@ async function installLean(opts = {}) {
|
|
|
39002
38956
|
const gb = (n) => (n / 1024 ** 3).toFixed(1);
|
|
39003
38957
|
return { ok: false, error: `not enough disk space for Lean: ${gb(free)} GB free where ${home} lives, needs about ${gb(needed)} GB` };
|
|
39004
38958
|
}
|
|
39005
|
-
const tmp = (0,
|
|
38959
|
+
const tmp = (0, import_node_path47.join)(home, ".tmp");
|
|
39006
38960
|
(0, import_node_fs63.rmSync)(tmp, { recursive: true, force: true });
|
|
39007
38961
|
(0, import_node_fs63.mkdirSync)(tmp, { recursive: true });
|
|
39008
|
-
const zip = (0,
|
|
38962
|
+
const zip = (0, import_node_path47.join)(tmp, asset);
|
|
39009
38963
|
say(`downloading ${url}`);
|
|
39010
38964
|
let lastPct = -1;
|
|
39011
38965
|
try {
|
|
@@ -39028,7 +38982,7 @@ async function installLean(opts = {}) {
|
|
|
39028
38982
|
return { ok: false, error: verified.error };
|
|
39029
38983
|
}
|
|
39030
38984
|
say("unpacking (this takes a minute)");
|
|
39031
|
-
const unpack = (0,
|
|
38985
|
+
const unpack = (0, import_node_path47.join)(tmp, "unpack");
|
|
39032
38986
|
(0, import_node_fs63.mkdirSync)(unpack);
|
|
39033
38987
|
const unpacked = unzip(zip, unpack);
|
|
39034
38988
|
if (!unpacked.ok) {
|
|
@@ -39036,8 +38990,8 @@ async function installLean(opts = {}) {
|
|
|
39036
38990
|
return { ok: false, error: `unpack failed: ${unpacked.error}` };
|
|
39037
38991
|
}
|
|
39038
38992
|
const entries = (0, import_node_fs63.readdirSync)(unpack);
|
|
39039
|
-
const top = entries.length === 1 && (0, import_node_fs63.statSync)((0,
|
|
39040
|
-
if (!(0, import_node_fs63.existsSync)((0,
|
|
38993
|
+
const top = entries.length === 1 && (0, import_node_fs63.statSync)((0, import_node_path47.join)(unpack, entries[0])).isDirectory() ? (0, import_node_path47.join)(unpack, entries[0]) : unpack;
|
|
38994
|
+
if (!(0, import_node_fs63.existsSync)((0, import_node_path47.join)(top, "bin", lakeBinary()))) {
|
|
39041
38995
|
(0, import_node_fs63.rmSync)(tmp, { recursive: true, force: true });
|
|
39042
38996
|
return { ok: false, error: "the archive did not contain bin/lake" };
|
|
39043
38997
|
}
|
|
@@ -39051,7 +39005,7 @@ async function installLean(opts = {}) {
|
|
|
39051
39005
|
// src/lib/remote-config.ts
|
|
39052
39006
|
var import_node_fs64 = require("node:fs");
|
|
39053
39007
|
var import_promises19 = require("node:fs/promises");
|
|
39054
|
-
var
|
|
39008
|
+
var import_node_path48 = require("node:path");
|
|
39055
39009
|
var import_yaml5 = __toESM2(require_dist());
|
|
39056
39010
|
var IGNORE_RIDER = "verityignore";
|
|
39057
39011
|
async function fetchRemoteSetup(opts) {
|
|
@@ -39129,7 +39083,7 @@ async function adoptRemoteSetup(found, opts) {
|
|
|
39129
39083
|
}
|
|
39130
39084
|
async function writeOut(relative6, body2) {
|
|
39131
39085
|
const target = projectPath(relative6);
|
|
39132
|
-
await (0, import_promises19.mkdir)((0,
|
|
39086
|
+
await (0, import_promises19.mkdir)((0, import_node_path48.dirname)(target), { recursive: true });
|
|
39133
39087
|
await (0, import_promises19.writeFile)(target, body2);
|
|
39134
39088
|
}
|
|
39135
39089
|
function describeRemote(found) {
|
|
@@ -39246,15 +39200,15 @@ async function runOptionalAuth(resolution, opts = {}) {
|
|
|
39246
39200
|
}
|
|
39247
39201
|
function resolveDataDir2() {
|
|
39248
39202
|
const candidates2 = [
|
|
39249
|
-
(0,
|
|
39203
|
+
(0, import_node_path49.join)(__dirname, "..", "data"),
|
|
39250
39204
|
// installed: node_modules/@codacy/verity-cli/data
|
|
39251
|
-
(0,
|
|
39205
|
+
(0, import_node_path49.join)(__dirname, "..", "..", "data"),
|
|
39252
39206
|
// edge case: nested resolution
|
|
39253
|
-
(0,
|
|
39207
|
+
(0, import_node_path49.join)(process.cwd(), "cli", "data")
|
|
39254
39208
|
// local dev: running from repo root
|
|
39255
39209
|
];
|
|
39256
39210
|
for (const candidate of candidates2) {
|
|
39257
|
-
if ((0, import_node_fs65.existsSync)((0,
|
|
39211
|
+
if ((0, import_node_fs65.existsSync)((0, import_node_path49.join)(candidate, "skills"))) {
|
|
39258
39212
|
return candidate;
|
|
39259
39213
|
}
|
|
39260
39214
|
}
|
|
@@ -39272,7 +39226,7 @@ async function skillIsCurrent(src, dest) {
|
|
|
39272
39226
|
const walk2 = (d, prefix) => {
|
|
39273
39227
|
for (const e of (0, import_node_fs65.readdirSync)(d, { withFileTypes: true })) {
|
|
39274
39228
|
const rel = prefix ? `${prefix}/${e.name}` : e.name;
|
|
39275
|
-
if (e.isDirectory()) walk2((0,
|
|
39229
|
+
if (e.isDirectory()) walk2((0, import_node_path49.join)(d, e.name), rel);
|
|
39276
39230
|
else if (e.isFile()) out2.push(rel);
|
|
39277
39231
|
}
|
|
39278
39232
|
};
|
|
@@ -39283,8 +39237,8 @@ async function skillIsCurrent(src, dest) {
|
|
|
39283
39237
|
const shipped = list2(src);
|
|
39284
39238
|
if (JSON.stringify(shipped) !== JSON.stringify(list2(dest))) return false;
|
|
39285
39239
|
for (const rel of shipped) {
|
|
39286
|
-
const a = await (0, import_promises20.readFile)((0,
|
|
39287
|
-
const b = await (0, import_promises20.readFile)((0,
|
|
39240
|
+
const a = await (0, import_promises20.readFile)((0, import_node_path49.join)(src, rel), "utf-8");
|
|
39241
|
+
const b = await (0, import_promises20.readFile)((0, import_node_path49.join)(dest, rel), "utf-8");
|
|
39288
39242
|
if (a !== b) return false;
|
|
39289
39243
|
}
|
|
39290
39244
|
return true;
|
|
@@ -39584,12 +39538,12 @@ async function handoffToSetup(enabled, claudeInstalled) {
|
|
|
39584
39538
|
async function installSkills(force, step) {
|
|
39585
39539
|
step("Installing skills");
|
|
39586
39540
|
const dataDir = resolveDataDir2();
|
|
39587
|
-
const skillsSource = (0,
|
|
39541
|
+
const skillsSource = (0, import_node_path49.join)(dataDir, "skills");
|
|
39588
39542
|
const skillsDest = ".claude/skills";
|
|
39589
39543
|
let skillsInstalled = 0;
|
|
39590
39544
|
for (const skill of SKILLS) {
|
|
39591
|
-
const src = (0,
|
|
39592
|
-
const dest = (0,
|
|
39545
|
+
const src = (0, import_node_path49.join)(skillsSource, skill);
|
|
39546
|
+
const dest = (0, import_node_path49.join)(skillsDest, skill);
|
|
39593
39547
|
if (!(0, import_node_fs65.existsSync)(src)) {
|
|
39594
39548
|
printWarn(` Skill data not found: ${skill}`);
|
|
39595
39549
|
continue;
|
|
@@ -39897,7 +39851,7 @@ function registerInitCommand(program2) {
|
|
|
39897
39851
|
untrackMemory: opts.untrackMemory === true,
|
|
39898
39852
|
untrackState: opts.untrackState === true
|
|
39899
39853
|
});
|
|
39900
|
-
const globalVerityDir = (0,
|
|
39854
|
+
const globalVerityDir = (0, import_node_path49.join)(process.env.HOME ?? "", ".verity");
|
|
39901
39855
|
await (0, import_promises20.mkdir)(globalVerityDir, { recursive: true });
|
|
39902
39856
|
console.log("");
|
|
39903
39857
|
step("Wiring Claude Code hooks");
|
|
@@ -40002,7 +39956,7 @@ function registerInitCommand(program2) {
|
|
|
40002
39956
|
...telemetryChoice ? { telemetry: telemetryChoice } : {},
|
|
40003
39957
|
init: {
|
|
40004
39958
|
completed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
40005
|
-
cli_version: true ? "0.34.0-experimental.
|
|
39959
|
+
cli_version: true ? "0.34.0-experimental.5235853" : "dev"
|
|
40006
39960
|
}
|
|
40007
39961
|
});
|
|
40008
39962
|
} catch (err2) {
|
|
@@ -40053,7 +40007,7 @@ function registerInitCommand(program2) {
|
|
|
40053
40007
|
|
|
40054
40008
|
// src/commands/uninstall.ts
|
|
40055
40009
|
var import_node_fs66 = require("node:fs");
|
|
40056
|
-
var
|
|
40010
|
+
var import_node_path50 = require("node:path");
|
|
40057
40011
|
function registerUninstallCommand(program2) {
|
|
40058
40012
|
program2.command("uninstall").description("Remove Verity from this project (skills, hooks, .verity/, VERITY.md)").option("--dry-run", "Show what would be removed without doing it").option("--purge-global", "Also remove ~/.verity/ (deletes saved tokens \u2014 reconnect requires re-registration)").option("--keep-verity-md", "Keep the project root VERITY.md file").action(async (opts) => {
|
|
40059
40013
|
const dryRun = opts.dryRun ?? false;
|
|
@@ -40062,7 +40016,7 @@ function registerUninstallCommand(program2) {
|
|
|
40062
40016
|
const actions = [];
|
|
40063
40017
|
const skillsRoot = projectPath(".claude/skills");
|
|
40064
40018
|
for (const name2 of PROJECT_SKILL_NAMES) {
|
|
40065
|
-
const dir = (0,
|
|
40019
|
+
const dir = (0, import_node_path50.join)(skillsRoot, name2);
|
|
40066
40020
|
if ((0, import_node_fs66.existsSync)(dir)) {
|
|
40067
40021
|
actions.push({
|
|
40068
40022
|
label: `Remove .claude/skills/${name2}/`,
|
|
@@ -40108,7 +40062,7 @@ function registerUninstallCommand(program2) {
|
|
|
40108
40062
|
}
|
|
40109
40063
|
});
|
|
40110
40064
|
const home = process.env.HOME ?? "";
|
|
40111
|
-
const globalVerityDir = (0,
|
|
40065
|
+
const globalVerityDir = (0, import_node_path50.join)(home, ".verity");
|
|
40112
40066
|
if (purgeGlobal && (0, import_node_fs66.existsSync)(globalVerityDir)) {
|
|
40113
40067
|
actions.push({
|
|
40114
40068
|
label: `Remove ~/.verity/ (global credentials \u2014 reconnect requires re-registration)`,
|
|
@@ -40307,7 +40261,7 @@ function registerTaskCommands(program2) {
|
|
|
40307
40261
|
|
|
40308
40262
|
// src/commands/reset.ts
|
|
40309
40263
|
var import_node_fs67 = require("node:fs");
|
|
40310
|
-
var
|
|
40264
|
+
var import_node_path51 = require("node:path");
|
|
40311
40265
|
function registerResetCommand(program2) {
|
|
40312
40266
|
program2.command("reset").description("Close the current task and clear transient state").option("--keep-task", "Only purge caches; leave the current task open").option("--all", "Also purge diagnostic logs (.verity/.logs/)").action(async (opts) => {
|
|
40313
40267
|
const globals = program2.opts();
|
|
@@ -40348,7 +40302,7 @@ function registerResetCommand(program2) {
|
|
|
40348
40302
|
for (const entry of (0, import_node_fs67.readdirSync)(cacheDir)) {
|
|
40349
40303
|
if (entry.startsWith("pending-")) {
|
|
40350
40304
|
try {
|
|
40351
|
-
(0, import_node_fs67.unlinkSync)((0,
|
|
40305
|
+
(0, import_node_fs67.unlinkSync)((0, import_node_path51.join)(cacheDir, entry));
|
|
40352
40306
|
purged++;
|
|
40353
40307
|
} catch {
|
|
40354
40308
|
}
|
|
@@ -40375,7 +40329,7 @@ function registerResetCommand(program2) {
|
|
|
40375
40329
|
if ((0, import_node_fs67.existsSync)(logsDir)) {
|
|
40376
40330
|
for (const entry of (0, import_node_fs67.readdirSync)(logsDir)) {
|
|
40377
40331
|
try {
|
|
40378
|
-
(0, import_node_fs67.unlinkSync)((0,
|
|
40332
|
+
(0, import_node_fs67.unlinkSync)((0, import_node_path51.join)(logsDir, entry));
|
|
40379
40333
|
} catch {
|
|
40380
40334
|
}
|
|
40381
40335
|
}
|
|
@@ -40395,7 +40349,7 @@ var PATH_TOKEN = /[A-Za-z0-9_./-]*[A-Za-z0-9_-]\.[A-Za-z0-9]{1,8}(?::\d+(?::\d+)
|
|
|
40395
40349
|
function clean(token) {
|
|
40396
40350
|
return token.replace(/:\d+(?::\d+)?$/, "").replace(/^[`'"(\[]+/, "").replace(/[`'"),\].;!?]+$/, "").replace(/^\.\//, "");
|
|
40397
40351
|
}
|
|
40398
|
-
function
|
|
40352
|
+
function resolve6(token, treePaths) {
|
|
40399
40353
|
if (treePaths.includes(token)) return token;
|
|
40400
40354
|
const suffix = token.startsWith("/") ? token : `/${token}`;
|
|
40401
40355
|
const matches = treePaths.filter((p) => p.endsWith(suffix));
|
|
@@ -40408,7 +40362,7 @@ function deriveFileGlobs(text, treePaths) {
|
|
|
40408
40362
|
for (const raw of text.match(PATH_TOKEN) ?? []) {
|
|
40409
40363
|
const token = clean(raw);
|
|
40410
40364
|
if (!token) continue;
|
|
40411
|
-
const path =
|
|
40365
|
+
const path = resolve6(token, treePaths);
|
|
40412
40366
|
if (!path || seen.has(path)) continue;
|
|
40413
40367
|
seen.add(path);
|
|
40414
40368
|
out2.push(path);
|
|
@@ -40937,7 +40891,7 @@ function registerTelemetryCommands(program2) {
|
|
|
40937
40891
|
|
|
40938
40892
|
// src/commands/prove.ts
|
|
40939
40893
|
var import_node_fs70 = require("node:fs");
|
|
40940
|
-
var
|
|
40894
|
+
var import_node_path52 = require("node:path");
|
|
40941
40895
|
|
|
40942
40896
|
// src/lib/prove/hint-pool.ts
|
|
40943
40897
|
var STOP2 = /* @__PURE__ */ new Set([
|
|
@@ -41073,7 +41027,7 @@ function registerProveCommand(program2) {
|
|
|
41073
41027
|
process.exit(2);
|
|
41074
41028
|
}
|
|
41075
41029
|
const limit = Math.max(1, Math.min(50, Number(opts.limit) || 10));
|
|
41076
|
-
let signals = collectRiskSignals(root, { since: opts.since, limit, paths: paths.map((p) => (0,
|
|
41030
|
+
let signals = collectRiskSignals(root, { since: opts.since, limit, paths: paths.map((p) => (0, import_node_path52.relative)(root, (0, import_node_path52.resolve)(p)) || ".") });
|
|
41077
41031
|
if (opts.hint && paths.length === 0) {
|
|
41078
41032
|
const hit = hintMatches(root, opts.hint);
|
|
41079
41033
|
if (hit.files.length > 0) {
|
|
@@ -41127,7 +41081,7 @@ function registerProveCommand(program2) {
|
|
|
41127
41081
|
});
|
|
41128
41082
|
prove.command("check [model]").description("Elaborate a model (or every model) with the local Lean toolchain and report each property").option("--timeout <ms>", "Per-model timeout in ms", "120000").option("--json", "Machine-readable output").action((model, opts) => {
|
|
41129
41083
|
const root = repoRoot();
|
|
41130
|
-
if (!(0, import_node_fs70.existsSync)((0,
|
|
41084
|
+
if (!(0, import_node_fs70.existsSync)((0, import_node_path52.join)(root, PROOFS_DIR, "lakefile.toml"))) {
|
|
41131
41085
|
printError(`No ${PROOFS_DIR}/ project here. Run \`verity prove init\` first.`);
|
|
41132
41086
|
process.exit(2);
|
|
41133
41087
|
}
|
|
@@ -41151,7 +41105,7 @@ ${build.stderr.split("\n").filter((l) => !l.startsWith("trace:")).slice(0, 20).j
|
|
|
41151
41105
|
const reports = [];
|
|
41152
41106
|
for (const f of files) {
|
|
41153
41107
|
const report = checkModel(tc, root, f, { timeoutMs: Math.max(1e3, Number(opts.timeout) || 12e4) });
|
|
41154
|
-
report.file = (0,
|
|
41108
|
+
report.file = (0, import_node_path52.relative)(root, f);
|
|
41155
41109
|
reports.push(report);
|
|
41156
41110
|
try {
|
|
41157
41111
|
writeResult(root, report);
|
|
@@ -41189,7 +41143,7 @@ ${build.stderr.split("\n").filter((l) => !l.startsWith("trace:")).slice(0, 20).j
|
|
|
41189
41143
|
printError("Not logged in \u2014 replays run on the Verity service. Run `verity login` first.");
|
|
41190
41144
|
process.exit(2);
|
|
41191
41145
|
}
|
|
41192
|
-
if (!(0, import_node_fs70.existsSync)((0,
|
|
41146
|
+
if (!(0, import_node_fs70.existsSync)((0, import_node_path52.join)(root, PROOFS_DIR, "lakefile.toml"))) {
|
|
41193
41147
|
printError(`No ${PROOFS_DIR}/ project here. Run \`verity prove init\` first.`);
|
|
41194
41148
|
process.exit(2);
|
|
41195
41149
|
}
|
|
@@ -41220,7 +41174,7 @@ ${report.error ?? ""}`);
|
|
|
41220
41174
|
printInfo(opts.property ? `${model} ${opts.property} has no counterexample to replay` : `${model} has no counterexample to replay`);
|
|
41221
41175
|
return;
|
|
41222
41176
|
}
|
|
41223
|
-
const modelSource = readRegularFileInRoot(root, (0,
|
|
41177
|
+
const modelSource = readRegularFileInRoot(root, (0, import_node_path52.relative)(root, file), 512 * 1024);
|
|
41224
41178
|
if (!opts.json) printInfo(`replaying ${targets.length} counterexample(s) of ${model} in network-less containers (${Math.min(targets.length, REPLAY_CONCURRENCY)} at a time)\u2026`);
|
|
41225
41179
|
const outcomes = await mapPool(targets, REPLAY_CONCURRENCY, async (p) => {
|
|
41226
41180
|
const brief = buildReplayBrief(root, report, p, modelSource.ok ? modelSource.content : "");
|
|
@@ -41240,7 +41194,7 @@ ${report.error ?? ""}`);
|
|
|
41240
41194
|
});
|
|
41241
41195
|
prove.command("auto [files...]").description("The formal phase the pre-push guard runs: select one risky symbol among changed files, generate a model, check it, replay counterexamples (default files: the commits ahead of upstream)").option("--deadline <ms>", "Budget for the whole phase", "170000").option("--json", "Machine-readable output").action(async (paths, opts) => {
|
|
41242
41196
|
const root = repoRoot();
|
|
41243
|
-
let files = paths.map((p) => (0,
|
|
41197
|
+
let files = paths.map((p) => (0, import_node_path52.relative)(root, (0, import_node_path52.resolve)(p)));
|
|
41244
41198
|
if (files.length === 0) {
|
|
41245
41199
|
const ahead = runGitSync(root, ["diff", "--name-only", "@{upstream}...HEAD"]);
|
|
41246
41200
|
const fallback = ahead.ok ? ahead : runGitSync(root, ["diff", "--name-only", "HEAD~1..HEAD"]);
|
|
@@ -41300,7 +41254,7 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
|
|
|
41300
41254
|
let revise;
|
|
41301
41255
|
if (opts.revise) {
|
|
41302
41256
|
const existing = resolveModelFile(root, opts.revise);
|
|
41303
|
-
const src = existing ? readRegularFileInRoot(root, (0,
|
|
41257
|
+
const src = existing ? readRegularFileInRoot(root, (0, import_node_path52.relative)(root, existing), 64 * 1024) : null;
|
|
41304
41258
|
if (!src || !src.ok || !opts.note) {
|
|
41305
41259
|
printError('--revise needs an existing model under Models/ and --note "<what the replay showed>"');
|
|
41306
41260
|
process.exit(2);
|
|
@@ -41339,8 +41293,8 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
|
|
|
41339
41293
|
});
|
|
41340
41294
|
prove.command("waive <file>").description("Dismiss the remembered formal finding(s) on a file for its current bytes \u2014 the accepted-risk path for a formal block").requiredOption("--reason <text>", "The human disposition this records (reviewer finding, ADR, \u2026)").action((file, opts) => {
|
|
41341
41295
|
const root = repoRoot();
|
|
41342
|
-
const rel0 = (0,
|
|
41343
|
-
const rel = rel0.startsWith("..") || (0,
|
|
41296
|
+
const rel0 = (0, import_node_path52.relative)(root, (0, import_node_path52.isAbsolute)(file) ? file : (0, import_node_path52.join)(root, file)).replace(/\\/g, "/");
|
|
41297
|
+
const rel = rel0.startsWith("..") || (0, import_node_path52.isAbsolute)(rel0) ? null : rel0;
|
|
41344
41298
|
if (!rel) {
|
|
41345
41299
|
printError(`${file} is not inside this repository`);
|
|
41346
41300
|
process.exit(2);
|
|
@@ -41356,8 +41310,8 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
|
|
|
41356
41310
|
});
|
|
41357
41311
|
prove.command("hash <file>").description("Print the sha256 of a file, for a model header (Verity.model \u2026 sha256). Path is REPO-relative, as in the header").action((file) => {
|
|
41358
41312
|
const root = repoRoot();
|
|
41359
|
-
const rel = (0,
|
|
41360
|
-
const digest = rel.startsWith("..") || (0,
|
|
41313
|
+
const rel = (0, import_node_path52.relative)(root, (0, import_node_path52.isAbsolute)(file) ? file : (0, import_node_path52.join)(root, file));
|
|
41314
|
+
const digest = rel.startsWith("..") || (0, import_node_path52.isAbsolute)(rel) ? null : sha256InRoot(root, rel);
|
|
41361
41315
|
if (!digest) {
|
|
41362
41316
|
printError(`Cannot hash ${file}: it must be a regular file inside this repository (not a symlink)`);
|
|
41363
41317
|
process.exit(2);
|
|
@@ -41394,7 +41348,7 @@ function refreshScaffold(root) {
|
|
|
41394
41348
|
var import_node_fs71 = require("node:fs");
|
|
41395
41349
|
var import_node_child_process20 = require("node:child_process");
|
|
41396
41350
|
var import_node_os11 = require("node:os");
|
|
41397
|
-
var
|
|
41351
|
+
var import_node_path53 = require("node:path");
|
|
41398
41352
|
function registerLeanCommand(program2) {
|
|
41399
41353
|
const lean = program2.command("lean").description("The Lean 4 toolchain formal verification needs (managed download, pinned by this CLI)");
|
|
41400
41354
|
lean.command("status").option("--json", "Machine-readable output").description("Which toolchain would run, and whether it matches the pinned version").action((opts) => {
|
|
@@ -41411,7 +41365,7 @@ function registerLeanCommand(program2) {
|
|
|
41411
41365
|
const managed = pinnedVersionDir();
|
|
41412
41366
|
const matches = version ? version.includes(pin) : false;
|
|
41413
41367
|
if (opts.json) {
|
|
41414
|
-
printJson({ pinned: LEAN_TOOLCHAIN, found: tc?.lake ?? null, version, matches_pin: matches, managed_dir: managed, managed_installed: (0, import_node_fs71.existsSync)((0,
|
|
41368
|
+
printJson({ pinned: LEAN_TOOLCHAIN, found: tc?.lake ?? null, version, matches_pin: matches, managed_dir: managed, managed_installed: (0, import_node_fs71.existsSync)((0, import_node_path53.join)(managed, "bin")), asset: leanAssetName() });
|
|
41415
41369
|
return;
|
|
41416
41370
|
}
|
|
41417
41371
|
printInfo(`pinned: ${LEAN_TOOLCHAIN}`);
|
|
@@ -41429,7 +41383,7 @@ function registerLeanCommand(program2) {
|
|
|
41429
41383
|
process.exit(2);
|
|
41430
41384
|
}
|
|
41431
41385
|
const dir = pinnedVersionDir();
|
|
41432
|
-
if ((0, import_node_fs71.existsSync)((0,
|
|
41386
|
+
if ((0, import_node_fs71.existsSync)((0, import_node_path53.join)(dir, "bin", "lake")) && !opts.force) {
|
|
41433
41387
|
printInfo(`already installed at ${dir}`);
|
|
41434
41388
|
return;
|
|
41435
41389
|
}
|
|
@@ -41475,8 +41429,8 @@ function registerLeanCommand(program2) {
|
|
|
41475
41429
|
}
|
|
41476
41430
|
|
|
41477
41431
|
// src/cli.ts
|
|
41478
|
-
program.name("verity").description("CLI for Verity quality gate service").version("0.34.0-experimental.
|
|
41479
|
-
installStderrLog(actionCommand.name(), process.argv.slice(2), "0.34.0-experimental.
|
|
41432
|
+
program.name("verity").description("CLI for Verity quality gate service").version("0.34.0-experimental.5235853").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr").hook("preAction", async (_thisCommand, actionCommand) => {
|
|
41433
|
+
installStderrLog(actionCommand.name(), process.argv.slice(2), "0.34.0-experimental.5235853");
|
|
41480
41434
|
setUserNamedServiceUrl(program.opts().serviceUrl);
|
|
41481
41435
|
try {
|
|
41482
41436
|
await foldLegacyLocalCredential();
|