@codacy/verity-cli 0.34.0-experimental.b9e8508 → 0.34.0-experimental.dc0010f
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 +801 -747
- package/package.json +1 -1
package/bin/verity.js
CHANGED
|
@@ -17104,6 +17104,10 @@ async function applyMomentSelection(moments) {
|
|
|
17104
17104
|
}
|
|
17105
17105
|
|
|
17106
17106
|
// src/lib/project-config.ts
|
|
17107
|
+
var import_node_fs6 = require("node:fs");
|
|
17108
|
+
var import_node_path8 = require("node:path");
|
|
17109
|
+
|
|
17110
|
+
// src/lib/repo-controlled.ts
|
|
17107
17111
|
var import_node_fs5 = require("node:fs");
|
|
17108
17112
|
var import_node_path7 = require("node:path");
|
|
17109
17113
|
|
|
@@ -17180,6 +17184,26 @@ function runGit(cwd, args2, opts = {}) {
|
|
|
17180
17184
|
});
|
|
17181
17185
|
}
|
|
17182
17186
|
|
|
17187
|
+
// src/lib/repo-controlled.ts
|
|
17188
|
+
function repoControlled(worktree, rel) {
|
|
17189
|
+
const parts2 = rel.split("/").filter(Boolean);
|
|
17190
|
+
for (let i2 = 1; i2 <= parts2.length; i2++) {
|
|
17191
|
+
let st;
|
|
17192
|
+
try {
|
|
17193
|
+
st = (0, import_node_fs5.lstatSync)((0, import_node_path7.join)(worktree, ...parts2.slice(0, i2)));
|
|
17194
|
+
} catch (err2) {
|
|
17195
|
+
const code = err2?.code;
|
|
17196
|
+
if (code === "ENOENT" || code === "ENOTDIR") return null;
|
|
17197
|
+
return "unverified";
|
|
17198
|
+
}
|
|
17199
|
+
if (st.isSymbolicLink()) return "symlink";
|
|
17200
|
+
if (i2 === parts2.length && !st.isFile()) return "symlink";
|
|
17201
|
+
}
|
|
17202
|
+
const r = runGitSync(worktree, ["ls-files", "-z", "--", rel], { timeoutMs: 5e3 });
|
|
17203
|
+
if (!r.ok) return "unverified";
|
|
17204
|
+
return r.stdout.length > 0 ? "tracked" : null;
|
|
17205
|
+
}
|
|
17206
|
+
|
|
17183
17207
|
// src/lib/project-config.ts
|
|
17184
17208
|
var DEFAULTS = { git_moments: [] };
|
|
17185
17209
|
function isMoment(value) {
|
|
@@ -17190,8 +17214,8 @@ function parseMoments(raw) {
|
|
|
17190
17214
|
}
|
|
17191
17215
|
function readConfigFile(path) {
|
|
17192
17216
|
try {
|
|
17193
|
-
if (!(0,
|
|
17194
|
-
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"));
|
|
17195
17219
|
const moments = Array.isArray(raw.git_moments) ? raw.git_moments.filter(isMoment) : [];
|
|
17196
17220
|
const source2 = raw.git_moments_source === "user" || raw.git_moments_source === "init" ? raw.git_moments_source : void 0;
|
|
17197
17221
|
return {
|
|
@@ -17208,22 +17232,13 @@ function candidates() {
|
|
|
17208
17232
|
const out2 = [{ path: local, source: "local" }];
|
|
17209
17233
|
const main = mainWorktreeRoot();
|
|
17210
17234
|
if (main) {
|
|
17211
|
-
const inherited = (0,
|
|
17235
|
+
const inherited = (0, import_node_path8.join)(main, PROJECT_CONFIG_FILE);
|
|
17212
17236
|
if (inherited !== local) out2.push({ path: inherited, source: "main-worktree" });
|
|
17213
17237
|
}
|
|
17214
17238
|
return out2;
|
|
17215
17239
|
}
|
|
17216
17240
|
function formalRefusal(path) {
|
|
17217
|
-
|
|
17218
|
-
try {
|
|
17219
|
-
if ((0, import_node_fs5.lstatSync)((0, import_node_path7.join)(worktree, VERITY_DIR)).isSymbolicLink()) return "symlink";
|
|
17220
|
-
if (!(0, import_node_fs5.lstatSync)(path).isFile()) return "symlink";
|
|
17221
|
-
} catch {
|
|
17222
|
-
return "unverified";
|
|
17223
|
-
}
|
|
17224
|
-
const r = runGitSync(worktree, ["ls-files", "-z", "--", PROJECT_CONFIG_FILE], { timeoutMs: 5e3 });
|
|
17225
|
-
if (!r.ok) return "unverified";
|
|
17226
|
-
return r.stdout.length > 0 ? "tracked" : null;
|
|
17241
|
+
return repoControlled((0, import_node_path8.dirname)((0, import_node_path8.dirname)(path)), PROJECT_CONFIG_FILE);
|
|
17227
17242
|
}
|
|
17228
17243
|
function readProjectConfigRaw() {
|
|
17229
17244
|
for (const { path, source: source2 } of candidates()) {
|
|
@@ -17235,10 +17250,10 @@ function readProjectConfigRaw() {
|
|
|
17235
17250
|
function readProjectConfig() {
|
|
17236
17251
|
const cfg = readProjectConfigRaw();
|
|
17237
17252
|
if (cfg.formal !== "push" || !cfg.path) return cfg;
|
|
17238
|
-
const
|
|
17239
|
-
if (!
|
|
17253
|
+
const refused2 = formalRefusal(cfg.path);
|
|
17254
|
+
if (!refused2) return cfg;
|
|
17240
17255
|
const { formal: _dropped, ...rest } = cfg;
|
|
17241
|
-
return { ...rest, formal_refused:
|
|
17256
|
+
return { ...rest, formal_refused: refused2 };
|
|
17242
17257
|
}
|
|
17243
17258
|
function formalRefusalMessage(reason) {
|
|
17244
17259
|
switch (reason) {
|
|
@@ -17259,8 +17274,8 @@ function writeProjectConfig(patch) {
|
|
|
17259
17274
|
...patch
|
|
17260
17275
|
};
|
|
17261
17276
|
const target = projectPath(PROJECT_CONFIG_FILE);
|
|
17262
|
-
(0,
|
|
17263
|
-
(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");
|
|
17264
17279
|
return next;
|
|
17265
17280
|
}
|
|
17266
17281
|
function resolveGuardMoments(explicit) {
|
|
@@ -17269,11 +17284,11 @@ function resolveGuardMoments(explicit) {
|
|
|
17269
17284
|
}
|
|
17270
17285
|
|
|
17271
17286
|
// src/lib/plugin-ownership.ts
|
|
17272
|
-
var
|
|
17287
|
+
var import_node_fs9 = require("node:fs");
|
|
17273
17288
|
|
|
17274
17289
|
// src/lib/which.ts
|
|
17275
|
-
var
|
|
17276
|
-
var
|
|
17290
|
+
var import_node_fs7 = require("node:fs");
|
|
17291
|
+
var import_node_path9 = require("node:path");
|
|
17277
17292
|
function executableExtensions(platform4, pathext) {
|
|
17278
17293
|
if (platform4 !== "win32") return [""];
|
|
17279
17294
|
const raw = (pathext ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
@@ -17291,14 +17306,14 @@ function whichSync(bin, opts = {}) {
|
|
|
17291
17306
|
if (!rawPath) return null;
|
|
17292
17307
|
const exts = executableExtensions(platform4, opts.pathext ?? process.env.PATHEXT);
|
|
17293
17308
|
const real = opts.real ?? true;
|
|
17294
|
-
for (const dir of rawPath.split(
|
|
17309
|
+
for (const dir of rawPath.split(import_node_path9.delimiter)) {
|
|
17295
17310
|
if (!dir) continue;
|
|
17296
17311
|
for (const ext of exts) {
|
|
17297
|
-
const candidate = (0,
|
|
17312
|
+
const candidate = (0, import_node_path9.join)(dir, bin + ext);
|
|
17298
17313
|
try {
|
|
17299
|
-
if (!(0,
|
|
17300
|
-
if (platform4 !== "win32") (0,
|
|
17301
|
-
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;
|
|
17302
17317
|
} catch {
|
|
17303
17318
|
continue;
|
|
17304
17319
|
}
|
|
@@ -17309,10 +17324,10 @@ function whichSync(bin, opts = {}) {
|
|
|
17309
17324
|
|
|
17310
17325
|
// src/lib/plugin-ownership.ts
|
|
17311
17326
|
var import_node_os2 = require("node:os");
|
|
17312
|
-
var
|
|
17327
|
+
var import_node_path10 = require("node:path");
|
|
17313
17328
|
|
|
17314
17329
|
// src/lib/stderr-log.ts
|
|
17315
|
-
var
|
|
17330
|
+
var import_node_fs8 = require("node:fs");
|
|
17316
17331
|
var TOKEN_RE2 = /verity_[0-9a-f]{16,}/g;
|
|
17317
17332
|
var ANSI_RE = /\u001b\[[0-?]*[ -/]*[@-~]/g;
|
|
17318
17333
|
function scrub(s) {
|
|
@@ -17325,9 +17340,9 @@ function append(text) {
|
|
|
17325
17340
|
try {
|
|
17326
17341
|
const dir = projectPath(DEBUG_LOG_DIR);
|
|
17327
17342
|
const file = projectPath(STDERR_LOG_FILE);
|
|
17328
|
-
(0,
|
|
17343
|
+
(0, import_node_fs8.mkdirSync)(dir, { recursive: true });
|
|
17329
17344
|
rotateIfNeeded(file);
|
|
17330
|
-
(0,
|
|
17345
|
+
(0, import_node_fs8.appendFileSync)(file, text);
|
|
17331
17346
|
} catch {
|
|
17332
17347
|
}
|
|
17333
17348
|
}
|
|
@@ -17375,8 +17390,8 @@ function markerPath() {
|
|
|
17375
17390
|
}
|
|
17376
17391
|
function readMarker() {
|
|
17377
17392
|
try {
|
|
17378
|
-
if (!(0,
|
|
17379
|
-
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"));
|
|
17380
17395
|
const pluginRoot = typeof raw.plugin_root === "string" ? raw.plugin_root : "";
|
|
17381
17396
|
if (!pluginRoot || CONTROL_CHARS2.test(pluginRoot)) return null;
|
|
17382
17397
|
const version = typeof raw.version === "string" && !CONTROL_CHARS2.test(raw.version) ? raw.version : null;
|
|
@@ -17394,23 +17409,23 @@ function recordPluginOwnership(sessionId) {
|
|
|
17394
17409
|
const pluginRoot = process.env.VERITY_PLUGIN_ROOT;
|
|
17395
17410
|
if (!pluginRoot) return;
|
|
17396
17411
|
try {
|
|
17397
|
-
(0,
|
|
17412
|
+
(0, import_node_fs9.mkdirSync)(projectPath(VERITY_DIR), { recursive: true });
|
|
17398
17413
|
const marker = {
|
|
17399
17414
|
session_id: sessionId,
|
|
17400
17415
|
plugin_root: pluginRoot,
|
|
17401
17416
|
version: process.env.VERITY_PLUGIN_VERSION || null,
|
|
17402
17417
|
ts: Math.floor(Date.now() / 1e3)
|
|
17403
17418
|
};
|
|
17404
|
-
(0,
|
|
17419
|
+
(0, import_node_fs9.writeFileSync)(markerPath(), JSON.stringify(marker));
|
|
17405
17420
|
} catch {
|
|
17406
17421
|
}
|
|
17407
17422
|
}
|
|
17408
17423
|
function claudeConfigDir() {
|
|
17409
|
-
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");
|
|
17410
17425
|
}
|
|
17411
17426
|
function readJsonFile(path) {
|
|
17412
17427
|
try {
|
|
17413
|
-
const parsed = JSON.parse((0,
|
|
17428
|
+
const parsed = JSON.parse((0, import_node_fs9.readFileSync)(path, "utf-8"));
|
|
17414
17429
|
return parsed && typeof parsed === "object" ? parsed : null;
|
|
17415
17430
|
} catch {
|
|
17416
17431
|
return null;
|
|
@@ -17418,9 +17433,9 @@ function readJsonFile(path) {
|
|
|
17418
17433
|
}
|
|
17419
17434
|
function enabledPluginSetting(key) {
|
|
17420
17435
|
const files = [
|
|
17421
|
-
projectPath((0,
|
|
17422
|
-
projectPath((0,
|
|
17423
|
-
(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")
|
|
17424
17439
|
];
|
|
17425
17440
|
for (const file of files) {
|
|
17426
17441
|
const map = readJsonFile(file)?.enabledPlugins;
|
|
@@ -17432,11 +17447,11 @@ function enabledPluginSetting(key) {
|
|
|
17432
17447
|
}
|
|
17433
17448
|
function marketplaceLocations() {
|
|
17434
17449
|
const out2 = /* @__PURE__ */ new Map();
|
|
17435
|
-
const known = readJsonFile((0,
|
|
17450
|
+
const known = readJsonFile((0, import_node_path10.join)(claudeConfigDir(), "plugins", "known_marketplaces.json"));
|
|
17436
17451
|
if (!known) return out2;
|
|
17437
17452
|
for (const [name2, entry] of Object.entries(known)) {
|
|
17438
17453
|
const loc2 = entry?.installLocation;
|
|
17439
|
-
if (typeof loc2 === "string" && loc2) out2.set(name2, (0,
|
|
17454
|
+
if (typeof loc2 === "string" && loc2) out2.set(name2, (0, import_node_path10.resolve)(loc2));
|
|
17440
17455
|
}
|
|
17441
17456
|
return out2;
|
|
17442
17457
|
}
|
|
@@ -17450,7 +17465,7 @@ function globalVerityVersion() {
|
|
|
17450
17465
|
const entry = verityPathEntry();
|
|
17451
17466
|
if (!entry) return null;
|
|
17452
17467
|
try {
|
|
17453
|
-
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"));
|
|
17454
17469
|
if (pkg?.name !== "@codacy/verity-cli" || typeof pkg.version !== "string") return null;
|
|
17455
17470
|
return pkg.version;
|
|
17456
17471
|
} catch {
|
|
@@ -17467,7 +17482,7 @@ var VERITY_MARKETPLACE_REPO = "codacy/verity";
|
|
|
17467
17482
|
function marketplaceConflict() {
|
|
17468
17483
|
const wanted = VERITY_MARKETPLACE;
|
|
17469
17484
|
for (const file of ["settings.json", "settings.local.json"]) {
|
|
17470
|
-
const path = (0,
|
|
17485
|
+
const path = (0, import_node_path10.join)(claudeConfigDir(), file);
|
|
17471
17486
|
const declared = readJsonFile(path)?.extraKnownMarketplaces ?? null;
|
|
17472
17487
|
const entry2 = declared && typeof declared === "object" ? declared[wanted] : void 0;
|
|
17473
17488
|
if (entry2 && typeof entry2 === "object") {
|
|
@@ -17477,7 +17492,7 @@ function marketplaceConflict() {
|
|
|
17477
17492
|
}
|
|
17478
17493
|
}
|
|
17479
17494
|
}
|
|
17480
|
-
const known = readJsonFile((0,
|
|
17495
|
+
const known = readJsonFile((0, import_node_path10.join)(claudeConfigDir(), "plugins", "known_marketplaces.json"));
|
|
17481
17496
|
const entry = known?.[wanted];
|
|
17482
17497
|
if (entry && typeof entry === "object" && !pointsAtVerity(entry.source)) {
|
|
17483
17498
|
return { name: wanted, declaredAs: describeSource(entry.source) };
|
|
@@ -17498,7 +17513,7 @@ function describeSource(src) {
|
|
|
17498
17513
|
return target ? `${kind} \u2192 ${target}` : kind;
|
|
17499
17514
|
}
|
|
17500
17515
|
function legacyMarketplaceInstall() {
|
|
17501
|
-
const plugins = readJsonFile((0,
|
|
17516
|
+
const plugins = readJsonFile((0, import_node_path10.join)(claudeConfigDir(), "plugins", "installed_plugins.json"))?.plugins;
|
|
17502
17517
|
if (!plugins || typeof plugins !== "object") return null;
|
|
17503
17518
|
for (const key of Object.keys(plugins)) {
|
|
17504
17519
|
const at = key.lastIndexOf("@");
|
|
@@ -17510,13 +17525,13 @@ function legacyMarketplaceInstall() {
|
|
|
17510
17525
|
}
|
|
17511
17526
|
function realpathOr(p) {
|
|
17512
17527
|
try {
|
|
17513
|
-
return
|
|
17528
|
+
return import_node_fs9.realpathSync.native(p);
|
|
17514
17529
|
} catch {
|
|
17515
|
-
return (0,
|
|
17530
|
+
return (0, import_node_path10.resolve)(p);
|
|
17516
17531
|
}
|
|
17517
17532
|
}
|
|
17518
17533
|
function isWithin(want, dir) {
|
|
17519
|
-
return want === dir || want.startsWith(dir +
|
|
17534
|
+
return want === dir || want.startsWith(dir + import_node_path10.sep);
|
|
17520
17535
|
}
|
|
17521
17536
|
function entryAppliesHere(entry, here) {
|
|
17522
17537
|
const e = entry;
|
|
@@ -17526,9 +17541,9 @@ function entryAppliesHere(entry, here) {
|
|
|
17526
17541
|
return forProject === here;
|
|
17527
17542
|
}
|
|
17528
17543
|
function registrySays(pluginRoot) {
|
|
17529
|
-
const plugins = readJsonFile((0,
|
|
17544
|
+
const plugins = readJsonFile((0, import_node_path10.join)(claudeConfigDir(), "plugins", "installed_plugins.json"))?.plugins;
|
|
17530
17545
|
if (!plugins || typeof plugins !== "object") return "unverified";
|
|
17531
|
-
const want = (0,
|
|
17546
|
+
const want = (0, import_node_path10.resolve)(pluginRoot);
|
|
17532
17547
|
const here = realpathOr(repoRoot());
|
|
17533
17548
|
const markets = marketplaceLocations();
|
|
17534
17549
|
for (const [key, value] of Object.entries(plugins)) {
|
|
@@ -17537,15 +17552,15 @@ function registrySays(pluginRoot) {
|
|
|
17537
17552
|
const applicable = (Array.isArray(value) ? value : []).filter((entry) => entryAppliesHere(entry, here));
|
|
17538
17553
|
const claims = applicable.some((entry) => {
|
|
17539
17554
|
const installPath = entry?.installPath;
|
|
17540
|
-
return typeof installPath === "string" && (0,
|
|
17555
|
+
return typeof installPath === "string" && (0, import_node_path10.resolve)(installPath) === want;
|
|
17541
17556
|
}) || source2 !== void 0 && applicable.length > 0 && isWithin(want, source2);
|
|
17542
17557
|
if (claims) {
|
|
17543
17558
|
if (enabledPluginSetting(key) === false) return "gone";
|
|
17544
|
-
return (0,
|
|
17559
|
+
return (0, import_node_fs9.existsSync)(pluginRoot) ? "live" : "gone";
|
|
17545
17560
|
}
|
|
17546
17561
|
}
|
|
17547
|
-
const managed = (0,
|
|
17548
|
-
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";
|
|
17549
17564
|
}
|
|
17550
17565
|
var _live = /* @__PURE__ */ new Map();
|
|
17551
17566
|
function pluginLiveness(pluginRoot) {
|
|
@@ -17559,7 +17574,7 @@ function clearStalePluginMarker() {
|
|
|
17559
17574
|
const marker = readMarker();
|
|
17560
17575
|
if (!marker || pluginLiveness(marker.plugin_root) !== "gone") return null;
|
|
17561
17576
|
try {
|
|
17562
|
-
(0,
|
|
17577
|
+
(0, import_node_fs9.rmSync)(markerPath(), { force: true });
|
|
17563
17578
|
} catch {
|
|
17564
17579
|
return null;
|
|
17565
17580
|
}
|
|
@@ -17587,7 +17602,7 @@ function pluginActiveHere() {
|
|
|
17587
17602
|
return activePluginInstall() !== null;
|
|
17588
17603
|
}
|
|
17589
17604
|
function registeredVerityPlugin() {
|
|
17590
|
-
const plugins = readJsonFile((0,
|
|
17605
|
+
const plugins = readJsonFile((0, import_node_path10.join)(claudeConfigDir(), "plugins", "installed_plugins.json"))?.plugins;
|
|
17591
17606
|
if (!plugins || typeof plugins !== "object") return null;
|
|
17592
17607
|
const here = realpathOr(repoRoot());
|
|
17593
17608
|
for (const [key, value] of Object.entries(plugins)) {
|
|
@@ -17597,7 +17612,7 @@ function registeredVerityPlugin() {
|
|
|
17597
17612
|
for (const entry of Array.isArray(value) ? value : []) {
|
|
17598
17613
|
const e = entry;
|
|
17599
17614
|
const installPath = typeof e.installPath === "string" ? e.installPath : "";
|
|
17600
|
-
if (!installPath || !(0,
|
|
17615
|
+
if (!installPath || !(0, import_node_fs9.existsSync)(installPath)) continue;
|
|
17601
17616
|
if (!entryAppliesHere(entry, here)) continue;
|
|
17602
17617
|
return { pluginRoot: installPath, version: typeof e.version === "string" ? e.version : null };
|
|
17603
17618
|
}
|
|
@@ -17649,28 +17664,28 @@ async function resolveHookWiring() {
|
|
|
17649
17664
|
}
|
|
17650
17665
|
|
|
17651
17666
|
// src/lib/cli-provenance.ts
|
|
17652
|
-
var
|
|
17667
|
+
var import_node_fs10 = require("node:fs");
|
|
17653
17668
|
var import_node_os3 = require("node:os");
|
|
17654
|
-
var
|
|
17669
|
+
var import_node_path11 = require("node:path");
|
|
17655
17670
|
var CLI_PACKAGE = "@codacy/verity-cli";
|
|
17656
|
-
var CLI_ENTRY = (0,
|
|
17671
|
+
var CLI_ENTRY = (0, import_node_path11.join)("node_modules", CLI_PACKAGE, "bin", "verity.js");
|
|
17657
17672
|
function readJson(path) {
|
|
17658
17673
|
try {
|
|
17659
|
-
const parsed = JSON.parse((0,
|
|
17674
|
+
const parsed = JSON.parse((0, import_node_fs10.readFileSync)(path, "utf-8"));
|
|
17660
17675
|
return parsed && typeof parsed === "object" ? parsed : null;
|
|
17661
17676
|
} catch {
|
|
17662
17677
|
return null;
|
|
17663
17678
|
}
|
|
17664
17679
|
}
|
|
17665
17680
|
function versionUnder(base) {
|
|
17666
|
-
const entry = (0,
|
|
17667
|
-
if (!(0,
|
|
17668
|
-
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"));
|
|
17669
17684
|
return typeof pkg?.version === "string" ? pkg.version : null;
|
|
17670
17685
|
}
|
|
17671
17686
|
function versionForEntry(entry) {
|
|
17672
17687
|
try {
|
|
17673
|
-
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"));
|
|
17674
17689
|
return typeof pkg?.version === "string" ? pkg.version : null;
|
|
17675
17690
|
} catch {
|
|
17676
17691
|
return null;
|
|
@@ -17678,16 +17693,16 @@ function versionForEntry(entry) {
|
|
|
17678
17693
|
}
|
|
17679
17694
|
function resolveHooksCli(pluginRoot) {
|
|
17680
17695
|
const override = process.env.VERITY_CLI_PATH;
|
|
17681
|
-
if (override && (0,
|
|
17696
|
+
if (override && (0, import_node_fs10.existsSync)(override)) {
|
|
17682
17697
|
return { version: versionForEntry(override), rung: "override" };
|
|
17683
17698
|
}
|
|
17684
17699
|
const fromPlugin = versionUnder(pluginRoot);
|
|
17685
17700
|
if (fromPlugin !== null) return { version: fromPlugin, rung: "plugin" };
|
|
17686
|
-
if ((0,
|
|
17687
|
-
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");
|
|
17688
17703
|
const fromData = versionUnder(dataDir);
|
|
17689
17704
|
if (fromData !== null) return { version: fromData, rung: "plugin-data" };
|
|
17690
|
-
if ((0,
|
|
17705
|
+
if ((0, import_node_fs10.existsSync)((0, import_node_path11.join)(dataDir, CLI_ENTRY))) return { version: null, rung: "plugin-data" };
|
|
17691
17706
|
const global = globalVerityVersion();
|
|
17692
17707
|
if (global !== null) return { version: global, rung: "global" };
|
|
17693
17708
|
return null;
|
|
@@ -17789,7 +17804,7 @@ function pluginCliInvocation() {
|
|
|
17789
17804
|
return resolverCommand(root);
|
|
17790
17805
|
}
|
|
17791
17806
|
function resolverCommand(root) {
|
|
17792
|
-
return `node ${JSON.stringify((0,
|
|
17807
|
+
return `node ${JSON.stringify((0, import_node_path11.join)(root, "scripts", "verity.mjs"))}`;
|
|
17793
17808
|
}
|
|
17794
17809
|
|
|
17795
17810
|
// src/commands/hooks.ts
|
|
@@ -17929,7 +17944,7 @@ var import_node_crypto9 = require("node:crypto");
|
|
|
17929
17944
|
|
|
17930
17945
|
// src/lib/conversation-buffer.ts
|
|
17931
17946
|
var import_promises5 = require("node:fs/promises");
|
|
17932
|
-
var
|
|
17947
|
+
var import_node_fs11 = require("node:fs");
|
|
17933
17948
|
var import_node_child_process6 = require("node:child_process");
|
|
17934
17949
|
var import_node_crypto = require("node:crypto");
|
|
17935
17950
|
function stripImageReferences(text) {
|
|
@@ -17965,7 +17980,7 @@ async function appendToConversationBuffer(prompt, sessionId) {
|
|
|
17965
17980
|
}
|
|
17966
17981
|
async function readAndClearConversationBuffer(currentSessionId) {
|
|
17967
17982
|
try {
|
|
17968
|
-
if ((0,
|
|
17983
|
+
if ((0, import_node_fs11.existsSync)(CONVERSATION_BUFFER_FILE)) {
|
|
17969
17984
|
const entries = await readBufferEntries();
|
|
17970
17985
|
let mine = entries;
|
|
17971
17986
|
let others = [];
|
|
@@ -17989,7 +18004,7 @@ async function readAndClearConversationBuffer(currentSessionId) {
|
|
|
17989
18004
|
};
|
|
17990
18005
|
}
|
|
17991
18006
|
}
|
|
17992
|
-
if ((0,
|
|
18007
|
+
if ((0, import_node_fs11.existsSync)(INTENT_FILE)) {
|
|
17993
18008
|
try {
|
|
17994
18009
|
const content = await (0, import_promises5.readFile)(INTENT_FILE, "utf-8");
|
|
17995
18010
|
await (0, import_promises5.unlink)(INTENT_FILE).catch(() => {
|
|
@@ -18282,9 +18297,9 @@ function isCommandOnlyTurn(input) {
|
|
|
18282
18297
|
|
|
18283
18298
|
// src/lib/context-identity.ts
|
|
18284
18299
|
var import_node_crypto2 = require("node:crypto");
|
|
18285
|
-
var
|
|
18300
|
+
var import_node_fs12 = require("node:fs");
|
|
18286
18301
|
var import_node_os4 = require("node:os");
|
|
18287
|
-
var
|
|
18302
|
+
var import_node_path12 = require("node:path");
|
|
18288
18303
|
var SHARED_SENTINELS = /* @__PURE__ */ new Set([
|
|
18289
18304
|
"",
|
|
18290
18305
|
"-",
|
|
@@ -18322,7 +18337,7 @@ function contextIdentity(input) {
|
|
|
18322
18337
|
if (rawTree && !isSharedSentinel(rawTree)) {
|
|
18323
18338
|
let resolved = rawTree;
|
|
18324
18339
|
try {
|
|
18325
|
-
resolved =
|
|
18340
|
+
resolved = import_node_fs12.realpathSync.native(rawTree);
|
|
18326
18341
|
} catch {
|
|
18327
18342
|
}
|
|
18328
18343
|
treeKey = (0, import_node_crypto2.createHash)("sha256").update(resolved).digest("hex").slice(0, 12);
|
|
@@ -18338,13 +18353,13 @@ function contextIdentity(input) {
|
|
|
18338
18353
|
}
|
|
18339
18354
|
function verityHome() {
|
|
18340
18355
|
const override = process.env.VERITY_HOME;
|
|
18341
|
-
return override && override.trim() ? (0,
|
|
18356
|
+
return override && override.trim() ? (0, import_node_path12.resolve)(override) : (0, import_node_path12.join)((0, import_node_os4.homedir)(), ".verity");
|
|
18342
18357
|
}
|
|
18343
18358
|
function dossierDir(identity) {
|
|
18344
|
-
return (0,
|
|
18359
|
+
return (0, import_node_path12.join)(verityHome(), "sessions", identity.userKey, identity.treeKey, identity.sessionKey);
|
|
18345
18360
|
}
|
|
18346
18361
|
function treeDir(identity) {
|
|
18347
|
-
return (0,
|
|
18362
|
+
return (0, import_node_path12.join)(verityHome(), "sessions", identity.userKey, identity.treeKey);
|
|
18348
18363
|
}
|
|
18349
18364
|
function scopeIdentity(token, sessionId) {
|
|
18350
18365
|
const t = (token ?? "").trim();
|
|
@@ -18359,8 +18374,8 @@ function sessionScopeKey(token, sessionId) {
|
|
|
18359
18374
|
|
|
18360
18375
|
// src/lib/task-context-buffer.ts
|
|
18361
18376
|
var import_promises6 = require("node:fs/promises");
|
|
18362
|
-
var
|
|
18363
|
-
var
|
|
18377
|
+
var import_node_fs13 = require("node:fs");
|
|
18378
|
+
var import_node_path13 = require("node:path");
|
|
18364
18379
|
var TASK_CONTEXT_DIR = `${VERITY_DIR}/.task-context`;
|
|
18365
18380
|
var MAX_BUFFER_BYTES = 500 * 1024;
|
|
18366
18381
|
var MAX_PROMPT_CHARS = 2e3;
|
|
@@ -18399,7 +18414,7 @@ async function appendResponseToTaskBuffer(taskId, assistantResponse, actionSumma
|
|
|
18399
18414
|
}
|
|
18400
18415
|
async function readTaskContextBuffer(taskId) {
|
|
18401
18416
|
const filePath = bufferPath(taskId);
|
|
18402
|
-
if (!(0,
|
|
18417
|
+
if (!(0, import_node_fs13.existsSync)(filePath)) return null;
|
|
18403
18418
|
try {
|
|
18404
18419
|
const content = await (0, import_promises6.readFile)(filePath, "utf-8");
|
|
18405
18420
|
if (!content.trim()) return null;
|
|
@@ -18433,12 +18448,12 @@ async function readTaskContextBuffer(taskId) {
|
|
|
18433
18448
|
}
|
|
18434
18449
|
async function cleanupTaskContextBuffers() {
|
|
18435
18450
|
try {
|
|
18436
|
-
if (!(0,
|
|
18451
|
+
if (!(0, import_node_fs13.existsSync)(TASK_CONTEXT_DIR)) return;
|
|
18437
18452
|
const files = await (0, import_promises6.readdir)(TASK_CONTEXT_DIR);
|
|
18438
18453
|
const cutoffMs = Date.now() - RETENTION_DAYS * 24 * 60 * 60 * 1e3;
|
|
18439
18454
|
for (const file of files) {
|
|
18440
18455
|
if (!file.endsWith(".jsonl")) continue;
|
|
18441
|
-
const filePath = (0,
|
|
18456
|
+
const filePath = (0, import_node_path13.join)(TASK_CONTEXT_DIR, file);
|
|
18442
18457
|
try {
|
|
18443
18458
|
const stats = await (0, import_promises6.stat)(filePath);
|
|
18444
18459
|
if (stats.mtimeMs < cutoffMs) {
|
|
@@ -18452,13 +18467,13 @@ async function cleanupTaskContextBuffers() {
|
|
|
18452
18467
|
}
|
|
18453
18468
|
function bufferPath(taskId) {
|
|
18454
18469
|
const safe = taskId.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
18455
|
-
return (0,
|
|
18470
|
+
return (0, import_node_path13.join)(TASK_CONTEXT_DIR, `${safe}.jsonl`);
|
|
18456
18471
|
}
|
|
18457
18472
|
async function appendEntry(taskId, entry) {
|
|
18458
18473
|
try {
|
|
18459
18474
|
await (0, import_promises6.mkdir)(TASK_CONTEXT_DIR, { recursive: true });
|
|
18460
18475
|
const filePath = bufferPath(taskId);
|
|
18461
|
-
if ((0,
|
|
18476
|
+
if ((0, import_node_fs13.existsSync)(filePath)) {
|
|
18462
18477
|
const stats = await (0, import_promises6.stat)(filePath);
|
|
18463
18478
|
if (stats.size >= MAX_BUFFER_BYTES) {
|
|
18464
18479
|
const content = await (0, import_promises6.readFile)(filePath, "utf-8");
|
|
@@ -18469,7 +18484,7 @@ async function appendEntry(taskId, entry) {
|
|
|
18469
18484
|
}
|
|
18470
18485
|
}
|
|
18471
18486
|
const line2 = JSON.stringify(entry) + "\n";
|
|
18472
|
-
const existing = (0,
|
|
18487
|
+
const existing = (0, import_node_fs13.existsSync)(filePath) ? await (0, import_promises6.readFile)(filePath, "utf-8") : "";
|
|
18473
18488
|
await (0, import_promises6.writeFile)(filePath, existing + line2);
|
|
18474
18489
|
} catch {
|
|
18475
18490
|
}
|
|
@@ -18477,20 +18492,20 @@ async function appendEntry(taskId, entry) {
|
|
|
18477
18492
|
|
|
18478
18493
|
// src/lib/memory-retrieval.ts
|
|
18479
18494
|
var import_promises8 = require("node:fs/promises");
|
|
18480
|
-
var
|
|
18481
|
-
var
|
|
18495
|
+
var import_node_fs16 = require("node:fs");
|
|
18496
|
+
var import_node_path16 = require("node:path");
|
|
18482
18497
|
|
|
18483
18498
|
// src/lib/org-mirror.ts
|
|
18484
|
-
var
|
|
18499
|
+
var import_node_fs14 = require("node:fs");
|
|
18485
18500
|
var import_promises7 = require("node:fs/promises");
|
|
18486
|
-
var
|
|
18501
|
+
var import_node_path14 = require("node:path");
|
|
18487
18502
|
var ORG_KINDS = ["decision", "security", "gotcha", "pattern", "domain", "integration"];
|
|
18488
18503
|
var STATE_FILE = ".org-pull-state.json";
|
|
18489
18504
|
var BODY_MAX = 8192;
|
|
18490
18505
|
function orgMirrorDir(remote = requestRemote()) {
|
|
18491
18506
|
const parsed = parseRemote(remote);
|
|
18492
18507
|
if (!parsed) return null;
|
|
18493
|
-
return (0,
|
|
18508
|
+
return (0, import_node_path14.join)(verityHome(), "orgs", parsed.host, parsed.owner.toLowerCase(), "memory");
|
|
18494
18509
|
}
|
|
18495
18510
|
function slugify(s) {
|
|
18496
18511
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 60);
|
|
@@ -18556,7 +18571,7 @@ function parseOrgNode(content) {
|
|
|
18556
18571
|
}
|
|
18557
18572
|
async function readState(dir) {
|
|
18558
18573
|
try {
|
|
18559
|
-
const parsed = JSON.parse(await (0, import_promises7.readFile)((0,
|
|
18574
|
+
const parsed = JSON.parse(await (0, import_promises7.readFile)((0, import_node_path14.join)(dir, STATE_FILE), "utf-8"));
|
|
18560
18575
|
return {
|
|
18561
18576
|
version: typeof parsed?.version === "string" ? parsed.version : null,
|
|
18562
18577
|
organization: parsed?.organization && typeof parsed.organization.id === "string" ? parsed.organization : null,
|
|
@@ -18568,7 +18583,7 @@ async function readState(dir) {
|
|
|
18568
18583
|
}
|
|
18569
18584
|
async function writeState(dir, state) {
|
|
18570
18585
|
await (0, import_promises7.mkdir)(dir, { recursive: true });
|
|
18571
|
-
await (0, import_promises7.writeFile)((0,
|
|
18586
|
+
await (0, import_promises7.writeFile)((0, import_node_path14.join)(dir, STATE_FILE), JSON.stringify({
|
|
18572
18587
|
...state.version ? { version: state.version } : {},
|
|
18573
18588
|
organization: state.organization,
|
|
18574
18589
|
pulled_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -18633,24 +18648,24 @@ async function pullOrgKnowledge(opts) {
|
|
|
18633
18648
|
for (const n of nodes) {
|
|
18634
18649
|
const rel = orgNodePath(n);
|
|
18635
18650
|
if (written.has(rel)) continue;
|
|
18636
|
-
await (0, import_promises7.mkdir)((0,
|
|
18637
|
-
await (0, import_promises7.writeFile)((0,
|
|
18651
|
+
await (0, import_promises7.mkdir)((0, import_node_path14.join)(dir, rel.split("/")[0]), { recursive: true });
|
|
18652
|
+
await (0, import_promises7.writeFile)((0, import_node_path14.join)(dir, rel), renderOrgNode(n, org?.name ?? ""));
|
|
18638
18653
|
written.add(rel);
|
|
18639
18654
|
}
|
|
18640
18655
|
for (const rel of state.files) {
|
|
18641
|
-
if (!written.has(rel)) await (0, import_promises7.rm)((0,
|
|
18656
|
+
if (!written.has(rel)) await (0, import_promises7.rm)((0, import_node_path14.join)(dir, rel), { force: true });
|
|
18642
18657
|
}
|
|
18643
|
-
await (0, import_promises7.writeFile)((0,
|
|
18658
|
+
await (0, import_promises7.writeFile)((0, import_node_path14.join)(dir, "index.md"), renderIndex(org?.name ?? "no organization", nodes));
|
|
18644
18659
|
await writeState(dir, { version: org ? page.version : null, organization: org, files: [...written].sort() });
|
|
18645
18660
|
return { ok: true, status: org ? "pulled" : "none", received: nodes.length, dir };
|
|
18646
18661
|
}
|
|
18647
18662
|
async function readOrgMirror(remote = requestRemote()) {
|
|
18648
18663
|
const dir = orgMirrorDir(remote);
|
|
18649
|
-
if (!dir || !(0,
|
|
18664
|
+
if (!dir || !(0, import_node_fs14.existsSync)(dir)) return [];
|
|
18650
18665
|
const out2 = [];
|
|
18651
18666
|
for (const kind of ORG_KINDS) {
|
|
18652
|
-
const kindDir = (0,
|
|
18653
|
-
if (!(0,
|
|
18667
|
+
const kindDir = (0, import_node_path14.join)(dir, kind);
|
|
18668
|
+
if (!(0, import_node_fs14.existsSync)(kindDir)) continue;
|
|
18654
18669
|
let files;
|
|
18655
18670
|
try {
|
|
18656
18671
|
files = await (0, import_promises7.readdir)(kindDir);
|
|
@@ -18660,7 +18675,7 @@ async function readOrgMirror(remote = requestRemote()) {
|
|
|
18660
18675
|
for (const file of files) {
|
|
18661
18676
|
if (!file.endsWith(".md")) continue;
|
|
18662
18677
|
try {
|
|
18663
|
-
const node = parseOrgNode(await (0, import_promises7.readFile)((0,
|
|
18678
|
+
const node = parseOrgNode(await (0, import_promises7.readFile)((0, import_node_path14.join)(kindDir, file), "utf-8"));
|
|
18664
18679
|
if (node) out2.push(node);
|
|
18665
18680
|
} catch {
|
|
18666
18681
|
}
|
|
@@ -18670,29 +18685,29 @@ async function readOrgMirror(remote = requestRemote()) {
|
|
|
18670
18685
|
}
|
|
18671
18686
|
|
|
18672
18687
|
// src/lib/safe-read.ts
|
|
18673
|
-
var
|
|
18674
|
-
var
|
|
18675
|
-
var FLAGS =
|
|
18688
|
+
var import_node_fs15 = require("node:fs");
|
|
18689
|
+
var import_node_path15 = require("node:path");
|
|
18690
|
+
var FLAGS = import_node_fs15.constants;
|
|
18676
18691
|
var NOFOLLOW = FLAGS.O_NOFOLLOW;
|
|
18677
18692
|
var NONBLOCK = FLAGS.O_NONBLOCK;
|
|
18678
18693
|
function closeOpened(fd) {
|
|
18679
18694
|
try {
|
|
18680
|
-
(0,
|
|
18695
|
+
(0, import_node_fs15.closeSync)(fd);
|
|
18681
18696
|
} catch {
|
|
18682
18697
|
}
|
|
18683
18698
|
}
|
|
18684
18699
|
function isInsideRoot(realRoot, realPath) {
|
|
18685
|
-
return realPath === realRoot || realPath.startsWith(realRoot.endsWith(
|
|
18700
|
+
return realPath === realRoot || realPath.startsWith(realRoot.endsWith(import_node_path15.sep) ? realRoot : realRoot + import_node_path15.sep);
|
|
18686
18701
|
}
|
|
18687
18702
|
function sameOpenedFile(opened, current, nofollowAvailable) {
|
|
18688
18703
|
if (!nofollowAvailable && (opened.ino === 0n || current.ino === 0n)) return false;
|
|
18689
18704
|
return opened.ino === current.ino && opened.dev === current.dev;
|
|
18690
18705
|
}
|
|
18691
18706
|
function openRegularInRoot(root, path) {
|
|
18692
|
-
const full = (0,
|
|
18707
|
+
const full = (0, import_node_path15.isAbsolute)(path) ? path : (0, import_node_path15.join)(root, path);
|
|
18693
18708
|
let fd;
|
|
18694
18709
|
try {
|
|
18695
|
-
fd = (0,
|
|
18710
|
+
fd = (0, import_node_fs15.openSync)(full, import_node_fs15.constants.O_RDONLY | (NOFOLLOW ?? 0) | (NONBLOCK ?? 0));
|
|
18696
18711
|
} catch (err2) {
|
|
18697
18712
|
const code = err2.code;
|
|
18698
18713
|
if (code === "ELOOP" || code === "EMLINK" || code === "EFTYPE") return { ok: false, reason: "symlink" };
|
|
@@ -18700,18 +18715,18 @@ function openRegularInRoot(root, path) {
|
|
|
18700
18715
|
return { ok: false, reason: "unreadable" };
|
|
18701
18716
|
}
|
|
18702
18717
|
try {
|
|
18703
|
-
const opened = (0,
|
|
18718
|
+
const opened = (0, import_node_fs15.fstatSync)(fd, { bigint: true });
|
|
18704
18719
|
if (!opened.isFile()) {
|
|
18705
18720
|
closeOpened(fd);
|
|
18706
18721
|
return { ok: false, reason: "not-regular" };
|
|
18707
18722
|
}
|
|
18708
|
-
const realRoot =
|
|
18709
|
-
const realPath =
|
|
18723
|
+
const realRoot = import_node_fs15.realpathSync.native(root);
|
|
18724
|
+
const realPath = import_node_fs15.realpathSync.native(full);
|
|
18710
18725
|
if (!isInsideRoot(realRoot, realPath)) {
|
|
18711
18726
|
closeOpened(fd);
|
|
18712
18727
|
return { ok: false, reason: "outside-root" };
|
|
18713
18728
|
}
|
|
18714
|
-
const current = (0,
|
|
18729
|
+
const current = (0, import_node_fs15.statSync)(realPath, { bigint: true });
|
|
18715
18730
|
if (!sameOpenedFile(opened, current, NOFOLLOW !== void 0)) {
|
|
18716
18731
|
closeOpened(fd);
|
|
18717
18732
|
return { ok: false, reason: NOFOLLOW === void 0 ? "unreadable" : "outside-root" };
|
|
@@ -18733,7 +18748,7 @@ function readOpened(fd, size) {
|
|
|
18733
18748
|
const buffer = Buffer.alloc(size);
|
|
18734
18749
|
let offset = 0;
|
|
18735
18750
|
while (offset < size) {
|
|
18736
|
-
const n = (0,
|
|
18751
|
+
const n = (0, import_node_fs15.readSync)(fd, buffer, offset, size - offset, offset);
|
|
18737
18752
|
if (n === 0) break;
|
|
18738
18753
|
offset += n;
|
|
18739
18754
|
}
|
|
@@ -19048,14 +19063,14 @@ function parseFrontmatter(content) {
|
|
|
19048
19063
|
return { fm, body: match[2].trim() };
|
|
19049
19064
|
}
|
|
19050
19065
|
async function retrieveForInjection(promptText, taskFiles = [], budgetTokens = DEFAULT_BUDGET_TOKENS) {
|
|
19051
|
-
const hasRepoGraph = (0,
|
|
19066
|
+
const hasRepoGraph = (0, import_node_fs16.existsSync)(memoryDir());
|
|
19052
19067
|
const budget = Math.min(budgetTokens, MAX_BUDGET_TOKENS);
|
|
19053
19068
|
const promptTokens = tokenize(promptText);
|
|
19054
19069
|
const orgPromptTerms = orgTerms(promptText);
|
|
19055
19070
|
const nodes = [];
|
|
19056
19071
|
for (const domain of hasRepoGraph ? DOMAINS : []) {
|
|
19057
|
-
const domainDir = (0,
|
|
19058
|
-
if (!(0,
|
|
19072
|
+
const domainDir = (0, import_node_path16.join)(memoryDir(), domain);
|
|
19073
|
+
if (!(0, import_node_fs16.existsSync)(domainDir)) continue;
|
|
19059
19074
|
try {
|
|
19060
19075
|
const files = await (0, import_promises8.readdir)(domainDir);
|
|
19061
19076
|
for (const file of files) {
|
|
@@ -19129,27 +19144,27 @@ async function retrieveForInjection(promptText, taskFiles = [], budgetTokens = D
|
|
|
19129
19144
|
}
|
|
19130
19145
|
|
|
19131
19146
|
// src/lib/injection-record.ts
|
|
19132
|
-
var
|
|
19147
|
+
var import_node_fs18 = require("node:fs");
|
|
19133
19148
|
var import_node_crypto3 = require("node:crypto");
|
|
19134
19149
|
|
|
19135
19150
|
// src/lib/safe-write.ts
|
|
19136
|
-
var
|
|
19137
|
-
var
|
|
19138
|
-
var FLAGS2 =
|
|
19151
|
+
var import_node_fs17 = require("node:fs");
|
|
19152
|
+
var import_node_path17 = require("node:path");
|
|
19153
|
+
var FLAGS2 = import_node_fs17.constants;
|
|
19139
19154
|
var O_NOFOLLOW = FLAGS2.O_NOFOLLOW ?? 0;
|
|
19140
19155
|
var NOFOLLOW_AVAILABLE = O_NOFOLLOW !== 0;
|
|
19141
19156
|
function validateRoot(root) {
|
|
19142
19157
|
try {
|
|
19143
|
-
const parentReal = (0,
|
|
19144
|
-
const expected = (0,
|
|
19158
|
+
const parentReal = (0, import_node_fs17.realpathSync)((0, import_node_path17.dirname)(root));
|
|
19159
|
+
const expected = (0, import_node_path17.join)(parentReal, (0, import_node_path17.basename)(root));
|
|
19145
19160
|
try {
|
|
19146
|
-
(0,
|
|
19161
|
+
(0, import_node_fs17.mkdirSync)(expected);
|
|
19147
19162
|
} catch (e) {
|
|
19148
19163
|
if (e.code !== "EEXIST") return null;
|
|
19149
19164
|
}
|
|
19150
|
-
const st = (0,
|
|
19165
|
+
const st = (0, import_node_fs17.lstatSync)(expected, { bigint: true });
|
|
19151
19166
|
if (st.isSymbolicLink() || !st.isDirectory()) return null;
|
|
19152
|
-
if ((0,
|
|
19167
|
+
if ((0, import_node_fs17.realpathSync)(expected) !== expected) return null;
|
|
19153
19168
|
return { real: expected, dev: st.dev, ino: st.ino };
|
|
19154
19169
|
} catch {
|
|
19155
19170
|
return null;
|
|
@@ -19157,18 +19172,18 @@ function validateRoot(root) {
|
|
|
19157
19172
|
}
|
|
19158
19173
|
function rootUnchanged(root) {
|
|
19159
19174
|
try {
|
|
19160
|
-
const st = (0,
|
|
19175
|
+
const st = (0, import_node_fs17.lstatSync)(root.real, { bigint: true });
|
|
19161
19176
|
return !st.isSymbolicLink() && st.isDirectory() && st.dev === root.dev && st.ino === root.ino;
|
|
19162
19177
|
} catch {
|
|
19163
19178
|
return false;
|
|
19164
19179
|
}
|
|
19165
19180
|
}
|
|
19166
19181
|
function bareName(name2) {
|
|
19167
|
-
return !!name2 && name2 === (0,
|
|
19182
|
+
return !!name2 && name2 === (0, import_node_path17.basename)(name2) && name2 !== "." && name2 !== ".." && !name2.includes("\0");
|
|
19168
19183
|
}
|
|
19169
19184
|
function absentOrRegular(path) {
|
|
19170
19185
|
try {
|
|
19171
|
-
const st = (0,
|
|
19186
|
+
const st = (0, import_node_fs17.lstatSync)(path);
|
|
19172
19187
|
return st.isFile() && !st.isSymbolicLink();
|
|
19173
19188
|
} catch (e) {
|
|
19174
19189
|
return e.code === "ENOENT";
|
|
@@ -19176,11 +19191,11 @@ function absentOrRegular(path) {
|
|
|
19176
19191
|
}
|
|
19177
19192
|
function verifyOpened(fd, path, root) {
|
|
19178
19193
|
try {
|
|
19179
|
-
const opened = (0,
|
|
19194
|
+
const opened = (0, import_node_fs17.fstatSync)(fd, { bigint: true });
|
|
19180
19195
|
if (!opened.isFile() || opened.nlink !== 1n) return false;
|
|
19181
|
-
const real = (0,
|
|
19196
|
+
const real = (0, import_node_fs17.realpathSync)(path);
|
|
19182
19197
|
if (!isInsideRoot(root.real, real)) return false;
|
|
19183
|
-
const current = (0,
|
|
19198
|
+
const current = (0, import_node_fs17.statSync)(real, { bigint: true });
|
|
19184
19199
|
if (!sameOpenedFile(opened, current, NOFOLLOW_AVAILABLE)) return false;
|
|
19185
19200
|
return rootUnchanged(root);
|
|
19186
19201
|
} catch {
|
|
@@ -19189,21 +19204,21 @@ function verifyOpened(fd, path, root) {
|
|
|
19189
19204
|
}
|
|
19190
19205
|
function removeIfOurs(fd, path) {
|
|
19191
19206
|
try {
|
|
19192
|
-
const opened = (0,
|
|
19193
|
-
const at = (0,
|
|
19194
|
-
if (!at.isSymbolicLink() && at.dev === opened.dev && at.ino === opened.ino) (0,
|
|
19207
|
+
const opened = (0, import_node_fs17.fstatSync)(fd, { bigint: true });
|
|
19208
|
+
const at = (0, import_node_fs17.lstatSync)(path, { bigint: true });
|
|
19209
|
+
if (!at.isSymbolicLink() && at.dev === opened.dev && at.ino === opened.ino) (0, import_node_fs17.unlinkSync)(path);
|
|
19195
19210
|
} catch {
|
|
19196
19211
|
}
|
|
19197
19212
|
}
|
|
19198
19213
|
function openTarget(path, append2) {
|
|
19199
|
-
const base =
|
|
19214
|
+
const base = import_node_fs17.constants.O_WRONLY | (append2 ? import_node_fs17.constants.O_APPEND : 0) | O_NOFOLLOW;
|
|
19200
19215
|
try {
|
|
19201
|
-
return { fd: (0,
|
|
19216
|
+
return { fd: (0, import_node_fs17.openSync)(path, base), created: false };
|
|
19202
19217
|
} catch (e) {
|
|
19203
19218
|
if (e.code !== "ENOENT") return null;
|
|
19204
19219
|
}
|
|
19205
19220
|
try {
|
|
19206
|
-
return { fd: (0,
|
|
19221
|
+
return { fd: (0, import_node_fs17.openSync)(path, base | import_node_fs17.constants.O_CREAT | import_node_fs17.constants.O_EXCL, 384), created: true };
|
|
19207
19222
|
} catch {
|
|
19208
19223
|
return null;
|
|
19209
19224
|
}
|
|
@@ -19211,7 +19226,7 @@ function openTarget(path, append2) {
|
|
|
19211
19226
|
function writeVerified(root, name2, hooks, append2, write) {
|
|
19212
19227
|
const r = validateRoot(root);
|
|
19213
19228
|
if (!r || !bareName(name2)) return false;
|
|
19214
|
-
const path = (0,
|
|
19229
|
+
const path = (0, import_node_path17.join)(r.real, name2);
|
|
19215
19230
|
if (!absentOrRegular(path)) return false;
|
|
19216
19231
|
if (!runHook(hooks)) return false;
|
|
19217
19232
|
const opened = openTarget(path, append2);
|
|
@@ -19227,7 +19242,7 @@ function writeVerified(root, name2, hooks, append2, write) {
|
|
|
19227
19242
|
return false;
|
|
19228
19243
|
} finally {
|
|
19229
19244
|
try {
|
|
19230
|
-
(0,
|
|
19245
|
+
(0, import_node_fs17.closeSync)(opened.fd);
|
|
19231
19246
|
} catch {
|
|
19232
19247
|
}
|
|
19233
19248
|
}
|
|
@@ -19242,13 +19257,13 @@ function runHook(hooks) {
|
|
|
19242
19257
|
}
|
|
19243
19258
|
function appendInRoot(root, name2, text, hooks = {}) {
|
|
19244
19259
|
return writeVerified(root, name2, hooks, true, (fd) => {
|
|
19245
|
-
(0,
|
|
19260
|
+
(0, import_node_fs17.writeSync)(fd, text);
|
|
19246
19261
|
});
|
|
19247
19262
|
}
|
|
19248
19263
|
function replaceInRoot(root, name2, text, hooks = {}) {
|
|
19249
19264
|
return writeVerified(root, name2, hooks, false, (fd) => {
|
|
19250
|
-
(0,
|
|
19251
|
-
(0,
|
|
19265
|
+
(0, import_node_fs17.ftruncateSync)(fd, 0);
|
|
19266
|
+
(0, import_node_fs17.writeSync)(fd, text, 0);
|
|
19252
19267
|
});
|
|
19253
19268
|
}
|
|
19254
19269
|
|
|
@@ -19296,7 +19311,7 @@ function hashPrompt(prompt) {
|
|
|
19296
19311
|
function recordInjection(event) {
|
|
19297
19312
|
if (!appendInRoot(projectPath(VERITY_DIR), "injections.jsonl", JSON.stringify(event) + "\n")) return;
|
|
19298
19313
|
try {
|
|
19299
|
-
if ((0,
|
|
19314
|
+
if ((0, import_node_fs18.lstatSync)(recordPath()).size > COMPACT_AT_BYTES) writeEvents(readPendingInjections());
|
|
19300
19315
|
} catch {
|
|
19301
19316
|
}
|
|
19302
19317
|
}
|
|
@@ -19306,7 +19321,7 @@ function writeEvents(events) {
|
|
|
19306
19321
|
function readPendingInjections() {
|
|
19307
19322
|
try {
|
|
19308
19323
|
const p = recordPath();
|
|
19309
|
-
if (!(0,
|
|
19324
|
+
if (!(0, import_node_fs18.existsSync)(p)) return [];
|
|
19310
19325
|
const read2 = readRegularFileInRoot(projectPath(VERITY_DIR), "injections.jsonl", MAX_RECORD_BYTES);
|
|
19311
19326
|
if (!read2.ok) return [];
|
|
19312
19327
|
const out2 = [];
|
|
@@ -19326,13 +19341,13 @@ function readPendingInjections() {
|
|
|
19326
19341
|
|
|
19327
19342
|
// src/lib/memory-sync.ts
|
|
19328
19343
|
var import_promises9 = require("node:fs/promises");
|
|
19329
|
-
var
|
|
19330
|
-
var
|
|
19344
|
+
var import_node_fs21 = require("node:fs");
|
|
19345
|
+
var import_node_path19 = require("node:path");
|
|
19331
19346
|
var import_node_crypto4 = require("node:crypto");
|
|
19332
19347
|
|
|
19333
19348
|
// src/lib/gitignore.ts
|
|
19334
19349
|
var import_node_child_process7 = require("node:child_process");
|
|
19335
|
-
var
|
|
19350
|
+
var import_node_fs19 = require("node:fs");
|
|
19336
19351
|
var VERITY_GITIGNORE_MARKER = "# Verity \u2014 machine-local state.";
|
|
19337
19352
|
var SETTINGS_LOCAL_IGNORE_ENTRY = ".claude/settings.local.json";
|
|
19338
19353
|
var VERITY_GITIGNORE_BLOCK = [
|
|
@@ -19416,7 +19431,7 @@ function fenceMemoryLines(lines) {
|
|
|
19416
19431
|
function ensureVerityGitignore() {
|
|
19417
19432
|
let content = "";
|
|
19418
19433
|
try {
|
|
19419
|
-
content = (0,
|
|
19434
|
+
content = (0, import_node_fs19.readFileSync)(".gitignore", "utf-8");
|
|
19420
19435
|
} catch {
|
|
19421
19436
|
}
|
|
19422
19437
|
const hasMarker = content.includes(VERITY_GITIGNORE_MARKER);
|
|
@@ -19443,7 +19458,7 @@ function ensureVerityGitignore() {
|
|
|
19443
19458
|
const sep5 = text === "" ? "" : text.endsWith("\n") ? "\n" : "\n\n";
|
|
19444
19459
|
text = text + sep5 + VERITY_GITIGNORE_BLOCK;
|
|
19445
19460
|
}
|
|
19446
|
-
if (text !== content) (0,
|
|
19461
|
+
if (text !== content) (0, import_node_fs19.writeFileSync)(".gitignore", text);
|
|
19447
19462
|
return verified(
|
|
19448
19463
|
memoryIsCommitted ? "memory-tracked" : hasSupersededMemory ? "memory-fenced" : needsRepair ? "repaired" : "added"
|
|
19449
19464
|
);
|
|
@@ -19463,7 +19478,7 @@ function untrackMemory() {
|
|
|
19463
19478
|
function writeFencedBlock() {
|
|
19464
19479
|
let content = "";
|
|
19465
19480
|
try {
|
|
19466
|
-
content = (0,
|
|
19481
|
+
content = (0, import_node_fs19.readFileSync)(".gitignore", "utf-8");
|
|
19467
19482
|
} catch {
|
|
19468
19483
|
}
|
|
19469
19484
|
const hasMarker = content.includes(VERITY_GITIGNORE_MARKER);
|
|
@@ -19475,7 +19490,7 @@ function writeFencedBlock() {
|
|
|
19475
19490
|
text = text + sep5 + VERITY_GITIGNORE_BLOCK;
|
|
19476
19491
|
}
|
|
19477
19492
|
try {
|
|
19478
|
-
(0,
|
|
19493
|
+
(0, import_node_fs19.writeFileSync)(".gitignore", text);
|
|
19479
19494
|
return true;
|
|
19480
19495
|
} catch {
|
|
19481
19496
|
return false;
|
|
@@ -19484,14 +19499,14 @@ function writeFencedBlock() {
|
|
|
19484
19499
|
function fenceMemory() {
|
|
19485
19500
|
let original = null;
|
|
19486
19501
|
try {
|
|
19487
|
-
original = (0,
|
|
19502
|
+
original = (0, import_node_fs19.readFileSync)(".gitignore", "utf-8");
|
|
19488
19503
|
} catch {
|
|
19489
19504
|
original = null;
|
|
19490
19505
|
}
|
|
19491
19506
|
const restore = () => {
|
|
19492
19507
|
try {
|
|
19493
|
-
if (original === null) (0,
|
|
19494
|
-
else (0,
|
|
19508
|
+
if (original === null) (0, import_node_fs19.rmSync)(".gitignore", { force: true });
|
|
19509
|
+
else (0, import_node_fs19.writeFileSync)(".gitignore", original);
|
|
19495
19510
|
} catch {
|
|
19496
19511
|
}
|
|
19497
19512
|
};
|
|
@@ -19509,7 +19524,7 @@ function fenceMemory() {
|
|
|
19509
19524
|
}
|
|
19510
19525
|
function memoryOptOut() {
|
|
19511
19526
|
try {
|
|
19512
|
-
return (0,
|
|
19527
|
+
return (0, import_node_fs19.readFileSync)(".gitignore", "utf-8").includes(MEMORY_OPT_OUT_MARKER);
|
|
19513
19528
|
} catch {
|
|
19514
19529
|
return false;
|
|
19515
19530
|
}
|
|
@@ -19517,13 +19532,13 @@ function memoryOptOut() {
|
|
|
19517
19532
|
function keepMemoryTracked() {
|
|
19518
19533
|
let content = "";
|
|
19519
19534
|
try {
|
|
19520
|
-
content = (0,
|
|
19535
|
+
content = (0, import_node_fs19.readFileSync)(".gitignore", "utf-8");
|
|
19521
19536
|
} catch {
|
|
19522
19537
|
}
|
|
19523
19538
|
if (content.includes(MEMORY_OPT_OUT_MARKER)) return "already";
|
|
19524
19539
|
try {
|
|
19525
19540
|
const sep5 = content === "" ? "" : content.endsWith("\n") ? "\n" : "\n\n";
|
|
19526
|
-
(0,
|
|
19541
|
+
(0, import_node_fs19.writeFileSync)(".gitignore", content + sep5 + MEMORY_OPT_OUT_STANZA);
|
|
19527
19542
|
} catch {
|
|
19528
19543
|
return "failed";
|
|
19529
19544
|
}
|
|
@@ -19558,26 +19573,26 @@ function untrackVerityState() {
|
|
|
19558
19573
|
}
|
|
19559
19574
|
|
|
19560
19575
|
// src/lib/safe-path.ts
|
|
19561
|
-
var
|
|
19562
|
-
var
|
|
19576
|
+
var import_node_fs20 = require("node:fs");
|
|
19577
|
+
var import_node_path18 = require("node:path");
|
|
19563
19578
|
function resolveInside(baseDir, candidate) {
|
|
19564
19579
|
if (typeof candidate !== "string" || candidate.length === 0) return null;
|
|
19565
|
-
if ((0,
|
|
19566
|
-
const baseAbs = (0,
|
|
19567
|
-
const full = (0,
|
|
19568
|
-
const baseSep = baseAbs.endsWith(
|
|
19580
|
+
if ((0, import_node_path18.isAbsolute)(candidate)) return null;
|
|
19581
|
+
const baseAbs = (0, import_node_path18.resolve)(baseDir);
|
|
19582
|
+
const full = (0, import_node_path18.resolve)(baseAbs, candidate);
|
|
19583
|
+
const baseSep = baseAbs.endsWith(import_node_path18.sep) ? baseAbs : baseAbs + import_node_path18.sep;
|
|
19569
19584
|
if (full !== baseAbs && !full.startsWith(baseSep)) return null;
|
|
19570
19585
|
try {
|
|
19571
|
-
if ((0,
|
|
19572
|
-
const realBase = (0,
|
|
19573
|
-
const realBaseSep = realBase.endsWith(
|
|
19586
|
+
if ((0, import_node_fs20.existsSync)(baseAbs)) {
|
|
19587
|
+
const realBase = (0, import_node_fs20.realpathSync)(baseAbs);
|
|
19588
|
+
const realBaseSep = realBase.endsWith(import_node_path18.sep) ? realBase : realBase + import_node_path18.sep;
|
|
19574
19589
|
let probe = full;
|
|
19575
|
-
while (!(0,
|
|
19576
|
-
const parent = (0,
|
|
19590
|
+
while (!(0, import_node_fs20.existsSync)(probe)) {
|
|
19591
|
+
const parent = (0, import_node_path18.dirname)(probe);
|
|
19577
19592
|
if (parent === probe) break;
|
|
19578
19593
|
probe = parent;
|
|
19579
19594
|
}
|
|
19580
|
-
const realProbe = (0,
|
|
19595
|
+
const realProbe = (0, import_node_fs20.realpathSync)(probe);
|
|
19581
19596
|
if (realProbe !== realBase && !realProbe.startsWith(realBaseSep)) return null;
|
|
19582
19597
|
}
|
|
19583
19598
|
} catch {
|
|
@@ -19585,37 +19600,37 @@ function resolveInside(baseDir, candidate) {
|
|
|
19585
19600
|
}
|
|
19586
19601
|
return full;
|
|
19587
19602
|
}
|
|
19588
|
-
var O_NOFOLLOW2 = typeof
|
|
19603
|
+
var O_NOFOLLOW2 = typeof import_node_fs20.constants.O_NOFOLLOW === "number" ? import_node_fs20.constants.O_NOFOLLOW : 0;
|
|
19589
19604
|
function readFileInside(baseDir, candidate, maxBytes) {
|
|
19590
19605
|
const full = resolveInside(baseDir, candidate);
|
|
19591
19606
|
if (!full) return null;
|
|
19592
19607
|
let realParent;
|
|
19593
19608
|
let realBase;
|
|
19594
19609
|
try {
|
|
19595
|
-
realParent = (0,
|
|
19596
|
-
realBase = (0,
|
|
19610
|
+
realParent = (0, import_node_fs20.realpathSync)((0, import_node_path18.dirname)(full));
|
|
19611
|
+
realBase = (0, import_node_fs20.realpathSync)((0, import_node_path18.resolve)(baseDir));
|
|
19597
19612
|
} catch {
|
|
19598
19613
|
return null;
|
|
19599
19614
|
}
|
|
19600
|
-
const realBaseSep = realBase.endsWith(
|
|
19615
|
+
const realBaseSep = realBase.endsWith(import_node_path18.sep) ? realBase : realBase + import_node_path18.sep;
|
|
19601
19616
|
if (realParent !== realBase && !realParent.startsWith(realBaseSep)) return null;
|
|
19602
|
-
const target = (0,
|
|
19617
|
+
const target = (0, import_node_path18.join)(realParent, (0, import_node_path18.basename)(full));
|
|
19603
19618
|
let fd = null;
|
|
19604
19619
|
try {
|
|
19605
|
-
fd = (0,
|
|
19606
|
-
const st = (0,
|
|
19620
|
+
fd = (0, import_node_fs20.openSync)(target, import_node_fs20.constants.O_RDONLY | O_NOFOLLOW2);
|
|
19621
|
+
const st = (0, import_node_fs20.fstatSync)(fd);
|
|
19607
19622
|
if (!st.isFile()) return null;
|
|
19608
19623
|
const cap2 = Math.min(maxBytes, st.size);
|
|
19609
19624
|
if (cap2 <= 0) return "";
|
|
19610
19625
|
const buf = Buffer.alloc(cap2);
|
|
19611
|
-
const bytesRead = (0,
|
|
19626
|
+
const bytesRead = (0, import_node_fs20.readSync)(fd, buf, 0, cap2, 0);
|
|
19612
19627
|
return buf.subarray(0, bytesRead).toString("utf-8");
|
|
19613
19628
|
} catch {
|
|
19614
19629
|
return null;
|
|
19615
19630
|
} finally {
|
|
19616
19631
|
if (fd !== null) {
|
|
19617
19632
|
try {
|
|
19618
|
-
(0,
|
|
19633
|
+
(0, import_node_fs20.closeSync)(fd);
|
|
19619
19634
|
} catch {
|
|
19620
19635
|
}
|
|
19621
19636
|
}
|
|
@@ -19698,32 +19713,32 @@ var syncStateFile = () => projectPath(`${VERITY_DIR}/.memory-sync-state.json`);
|
|
|
19698
19713
|
async function ensureMemoryDir() {
|
|
19699
19714
|
await (0, import_promises9.mkdir)(memoryDir2(), { recursive: true });
|
|
19700
19715
|
for (const domain of DOMAINS2) {
|
|
19701
|
-
await (0, import_promises9.mkdir)((0,
|
|
19716
|
+
await (0, import_promises9.mkdir)((0, import_node_path19.join)(memoryDir2(), domain), { recursive: true });
|
|
19702
19717
|
}
|
|
19703
|
-
if (!(0,
|
|
19704
|
-
await (0, import_promises9.writeFile)((0,
|
|
19718
|
+
if (!(0, import_node_fs21.existsSync)((0, import_node_path19.join)(memoryDir2(), "SCHEMA.md"))) {
|
|
19719
|
+
await (0, import_promises9.writeFile)((0, import_node_path19.join)(memoryDir2(), "SCHEMA.md"), SCHEMA_TEMPLATE);
|
|
19705
19720
|
}
|
|
19706
|
-
if (!(0,
|
|
19707
|
-
await (0, import_promises9.writeFile)((0,
|
|
19721
|
+
if (!(0, import_node_fs21.existsSync)((0, import_node_path19.join)(memoryDir2(), "index.md"))) {
|
|
19722
|
+
await (0, import_promises9.writeFile)((0, import_node_path19.join)(memoryDir2(), "index.md"), "# Project Memory Index\n\nNo nodes yet. Run an analysis to start building the knowledge graph.\n");
|
|
19708
19723
|
}
|
|
19709
|
-
if (!(0,
|
|
19710
|
-
await (0, import_promises9.writeFile)((0,
|
|
19724
|
+
if (!(0, import_node_fs21.existsSync)((0, import_node_path19.join)(memoryDir2(), "log.md"))) {
|
|
19725
|
+
await (0, import_promises9.writeFile)((0, import_node_path19.join)(memoryDir2(), "log.md"), "# Memory Log\n\n");
|
|
19711
19726
|
}
|
|
19712
19727
|
}
|
|
19713
19728
|
async function buildManifest() {
|
|
19714
|
-
if (!(0,
|
|
19729
|
+
if (!(0, import_node_fs21.existsSync)(memoryDir2())) {
|
|
19715
19730
|
return { schema_version: 1, nodes: [], index_hash: null, log_length: 0 };
|
|
19716
19731
|
}
|
|
19717
19732
|
const nodes = [];
|
|
19718
19733
|
for (const domain of DOMAINS2) {
|
|
19719
|
-
const domainDir = (0,
|
|
19720
|
-
if (!(0,
|
|
19734
|
+
const domainDir = (0, import_node_path19.join)(memoryDir2(), domain);
|
|
19735
|
+
if (!(0, import_node_fs21.existsSync)(domainDir)) continue;
|
|
19721
19736
|
try {
|
|
19722
19737
|
const files = await (0, import_promises9.readdir)(domainDir);
|
|
19723
19738
|
for (const file of files) {
|
|
19724
19739
|
if (!file.endsWith(".md")) continue;
|
|
19725
19740
|
const filePath = `${domain}/${file}`;
|
|
19726
|
-
const fullPath = (0,
|
|
19741
|
+
const fullPath = (0, import_node_path19.join)(memoryDir2(), filePath);
|
|
19727
19742
|
try {
|
|
19728
19743
|
const content = await (0, import_promises9.readFile)(fullPath, "utf-8");
|
|
19729
19744
|
const hash = (0, import_node_crypto4.createHash)("sha256").update(content).digest("hex").slice(0, 16);
|
|
@@ -19736,13 +19751,13 @@ async function buildManifest() {
|
|
|
19736
19751
|
}
|
|
19737
19752
|
let indexHash = null;
|
|
19738
19753
|
try {
|
|
19739
|
-
const indexContent = await (0, import_promises9.readFile)((0,
|
|
19754
|
+
const indexContent = await (0, import_promises9.readFile)((0, import_node_path19.join)(memoryDir2(), "index.md"), "utf-8");
|
|
19740
19755
|
indexHash = `sha256:${(0, import_node_crypto4.createHash)("sha256").update(indexContent).digest("hex").slice(0, 16)}`;
|
|
19741
19756
|
} catch {
|
|
19742
19757
|
}
|
|
19743
19758
|
let logLength = 0;
|
|
19744
19759
|
try {
|
|
19745
|
-
const logContent = await (0, import_promises9.readFile)((0,
|
|
19760
|
+
const logContent = await (0, import_promises9.readFile)((0, import_node_path19.join)(memoryDir2(), "log.md"), "utf-8");
|
|
19746
19761
|
logLength = logContent.split("\n").length;
|
|
19747
19762
|
} catch {
|
|
19748
19763
|
}
|
|
@@ -19753,15 +19768,15 @@ function hashContent(content) {
|
|
|
19753
19768
|
}
|
|
19754
19769
|
async function readOnDiskNodes() {
|
|
19755
19770
|
const out2 = /* @__PURE__ */ new Map();
|
|
19756
|
-
if (!(0,
|
|
19771
|
+
if (!(0, import_node_fs21.existsSync)(memoryDir2())) return out2;
|
|
19757
19772
|
for (const domain of DOMAINS2) {
|
|
19758
|
-
const domainDir = (0,
|
|
19759
|
-
if (!(0,
|
|
19773
|
+
const domainDir = (0, import_node_path19.join)(memoryDir2(), domain);
|
|
19774
|
+
if (!(0, import_node_fs21.existsSync)(domainDir)) continue;
|
|
19760
19775
|
try {
|
|
19761
19776
|
for (const file of await (0, import_promises9.readdir)(domainDir)) {
|
|
19762
19777
|
if (!file.endsWith(".md")) continue;
|
|
19763
19778
|
try {
|
|
19764
|
-
out2.set(`${domain}/${file}`, hashContent(await (0, import_promises9.readFile)((0,
|
|
19779
|
+
out2.set(`${domain}/${file}`, hashContent(await (0, import_promises9.readFile)((0, import_node_path19.join)(domainDir, file), "utf-8")));
|
|
19765
19780
|
} catch {
|
|
19766
19781
|
}
|
|
19767
19782
|
}
|
|
@@ -19798,7 +19813,7 @@ async function recordSyncedNodePaths() {
|
|
|
19798
19813
|
}
|
|
19799
19814
|
}
|
|
19800
19815
|
async function writeFileAtomic(path, content) {
|
|
19801
|
-
await (0, import_promises9.mkdir)((0,
|
|
19816
|
+
await (0, import_promises9.mkdir)((0, import_node_path19.dirname)(path), { recursive: true });
|
|
19802
19817
|
const tmp = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
19803
19818
|
await (0, import_promises9.writeFile)(tmp, content);
|
|
19804
19819
|
await (0, import_promises9.rename)(tmp, path);
|
|
@@ -19812,8 +19827,8 @@ async function computeEditedNodeUploads() {
|
|
|
19812
19827
|
const uploads = [];
|
|
19813
19828
|
for (const [path, prevHash] of prev) {
|
|
19814
19829
|
if (prevHash == null) continue;
|
|
19815
|
-
const full = (0,
|
|
19816
|
-
if (!(0,
|
|
19830
|
+
const full = (0, import_node_path19.join)(memoryDir2(), path);
|
|
19831
|
+
if (!(0, import_node_fs21.existsSync)(full)) continue;
|
|
19817
19832
|
let content;
|
|
19818
19833
|
try {
|
|
19819
19834
|
content = await (0, import_promises9.readFile)(full, "utf-8");
|
|
@@ -19857,8 +19872,8 @@ async function applyMemoryWrites(writes, opts = {}) {
|
|
|
19857
19872
|
const logLines = [`- ${(/* @__PURE__ */ new Date()).toISOString().slice(0, 16)} \u2014 Applied ${count} write(s) from server`];
|
|
19858
19873
|
for (const n of notes) logLines.push(` - ${n}`);
|
|
19859
19874
|
try {
|
|
19860
|
-
const existing = (0,
|
|
19861
|
-
await (0, import_promises9.writeFile)((0,
|
|
19875
|
+
const existing = (0, import_node_fs21.existsSync)((0, import_node_path19.join)(memoryDir2(), "log.md")) ? await (0, import_promises9.readFile)((0, import_node_path19.join)(memoryDir2(), "log.md"), "utf-8") : "# Memory Log\n\n";
|
|
19876
|
+
await (0, import_promises9.writeFile)((0, import_node_path19.join)(memoryDir2(), "log.md"), existing + logLines.join("\n") + "\n");
|
|
19862
19877
|
} catch {
|
|
19863
19878
|
}
|
|
19864
19879
|
if (opts.baseline === "written") await mergeSyncBaseline(synced);
|
|
@@ -19868,7 +19883,7 @@ async function applyMemoryWrites(writes, opts = {}) {
|
|
|
19868
19883
|
async function mergeSyncBaseline(entries) {
|
|
19869
19884
|
if (entries.size === 0) return;
|
|
19870
19885
|
try {
|
|
19871
|
-
if ((0,
|
|
19886
|
+
if ((0, import_node_fs21.existsSync)(syncStateFile())) {
|
|
19872
19887
|
try {
|
|
19873
19888
|
JSON.parse(await (0, import_promises9.readFile)(syncStateFile(), "utf-8"));
|
|
19874
19889
|
} catch {
|
|
@@ -19896,7 +19911,7 @@ async function applyOneWrite(write, treePaths, lastServed) {
|
|
|
19896
19911
|
notes.push(`${write.path}: dropped unmatched file_globs [${grounded.dropped.join(", ")}]`);
|
|
19897
19912
|
}
|
|
19898
19913
|
}
|
|
19899
|
-
if ((0,
|
|
19914
|
+
if ((0, import_node_fs21.existsSync)(fullPath)) {
|
|
19900
19915
|
let existing = "";
|
|
19901
19916
|
try {
|
|
19902
19917
|
existing = await (0, import_promises9.readFile)(fullPath, "utf-8");
|
|
@@ -19912,7 +19927,7 @@ async function applyOneWrite(write, treePaths, lastServed) {
|
|
|
19912
19927
|
notes.push(`${write.path}: updated from server (untouched here since the server delivered it)`);
|
|
19913
19928
|
}
|
|
19914
19929
|
}
|
|
19915
|
-
await (0, import_promises9.mkdir)((0,
|
|
19930
|
+
await (0, import_promises9.mkdir)((0, import_node_path19.dirname)(fullPath), { recursive: true });
|
|
19916
19931
|
await (0, import_promises9.writeFile)(fullPath, content);
|
|
19917
19932
|
return { written: true, syncedHash: hashContent(content), notes };
|
|
19918
19933
|
}
|
|
@@ -19953,8 +19968,8 @@ async function regenerateIndex() {
|
|
|
19953
19968
|
];
|
|
19954
19969
|
let totalNodes = 0;
|
|
19955
19970
|
for (const domain of DOMAINS2.filter((d) => d !== "_archive")) {
|
|
19956
|
-
const domainDir = (0,
|
|
19957
|
-
if (!(0,
|
|
19971
|
+
const domainDir = (0, import_node_path19.join)(memoryDir2(), domain);
|
|
19972
|
+
if (!(0, import_node_fs21.existsSync)(domainDir)) continue;
|
|
19958
19973
|
try {
|
|
19959
19974
|
const files = await (0, import_promises9.readdir)(domainDir);
|
|
19960
19975
|
const mdFiles = files.filter((f) => f.endsWith(".md"));
|
|
@@ -19964,7 +19979,7 @@ async function regenerateIndex() {
|
|
|
19964
19979
|
for (const file of mdFiles.sort()) {
|
|
19965
19980
|
const slug = file.replace(/\.md$/, "");
|
|
19966
19981
|
try {
|
|
19967
|
-
const content = await (0, import_promises9.readFile)((0,
|
|
19982
|
+
const content = await (0, import_promises9.readFile)((0, import_node_path19.join)(domainDir, file), "utf-8");
|
|
19968
19983
|
const title = pickFrontmatter(content, "title") ?? slug;
|
|
19969
19984
|
const kind = pickFrontmatter(content, "kind") ?? "-";
|
|
19970
19985
|
const confidence = pickFrontmatter(content, "confidence");
|
|
@@ -19988,7 +20003,7 @@ async function regenerateIndex() {
|
|
|
19988
20003
|
lines.push("No nodes yet. Run an analysis to start building the knowledge graph.");
|
|
19989
20004
|
}
|
|
19990
20005
|
const next = lines.join("\n") + "\n";
|
|
19991
|
-
const indexPath = (0,
|
|
20006
|
+
const indexPath = (0, import_node_path19.join)(memoryDir2(), "index.md");
|
|
19992
20007
|
let existing = null;
|
|
19993
20008
|
try {
|
|
19994
20009
|
existing = await (0, import_promises9.readFile)(indexPath, "utf-8");
|
|
@@ -20385,9 +20400,9 @@ function hasLegacyMemoryBlock(text) {
|
|
|
20385
20400
|
return findMarker(text, LEGACY_MD_START) !== -1;
|
|
20386
20401
|
}
|
|
20387
20402
|
async function ensureClaudeMdPointer(cwd = repoRoot()) {
|
|
20388
|
-
const claudeMdPath = (0,
|
|
20403
|
+
const claudeMdPath = (0, import_node_path19.join)(cwd, "CLAUDE.md");
|
|
20389
20404
|
let existing = "";
|
|
20390
|
-
if ((0,
|
|
20405
|
+
if ((0, import_node_fs21.existsSync)(claudeMdPath)) {
|
|
20391
20406
|
existing = await (0, import_promises9.readFile)(claudeMdPath, "utf-8");
|
|
20392
20407
|
}
|
|
20393
20408
|
let startTag = CLAUDE_MD_START;
|
|
@@ -20528,9 +20543,9 @@ Body content (\u22648KB). Use [[node-id]] wikilinks for cross-references.
|
|
|
20528
20543
|
`;
|
|
20529
20544
|
|
|
20530
20545
|
// src/lib/dossier-session.ts
|
|
20531
|
-
var
|
|
20546
|
+
var import_node_fs26 = require("node:fs");
|
|
20532
20547
|
var import_node_crypto8 = require("node:crypto");
|
|
20533
|
-
var
|
|
20548
|
+
var import_node_path22 = require("node:path");
|
|
20534
20549
|
|
|
20535
20550
|
// src/lib/pending-repeat.ts
|
|
20536
20551
|
var STOP = /* @__PURE__ */ new Set([
|
|
@@ -20635,8 +20650,8 @@ function statementAnchorKey(file, patternId) {
|
|
|
20635
20650
|
|
|
20636
20651
|
// src/lib/dossier/log.ts
|
|
20637
20652
|
var import_node_crypto5 = require("node:crypto");
|
|
20638
|
-
var
|
|
20639
|
-
var
|
|
20653
|
+
var import_node_fs22 = require("node:fs");
|
|
20654
|
+
var import_node_path20 = require("node:path");
|
|
20640
20655
|
var CRC_TABLE = (() => {
|
|
20641
20656
|
const t = new Int32Array(256);
|
|
20642
20657
|
for (let i2 = 0; i2 < 256; i2++) {
|
|
@@ -20655,13 +20670,13 @@ function crc32(s) {
|
|
|
20655
20670
|
function openDossier(identity) {
|
|
20656
20671
|
try {
|
|
20657
20672
|
const dir = dossierDir(identity);
|
|
20658
|
-
(0,
|
|
20673
|
+
(0, import_node_fs22.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
20659
20674
|
return {
|
|
20660
20675
|
dir,
|
|
20661
20676
|
identity,
|
|
20662
|
-
eventsPath: (0,
|
|
20663
|
-
foldPath: (0,
|
|
20664
|
-
rotatedDir: (0,
|
|
20677
|
+
eventsPath: (0, import_node_path20.join)(dir, "events.jsonl"),
|
|
20678
|
+
foldPath: (0, import_node_path20.join)(dir, "fold.json"),
|
|
20679
|
+
rotatedDir: (0, import_node_path20.join)(dir, "rotated")
|
|
20665
20680
|
};
|
|
20666
20681
|
} catch {
|
|
20667
20682
|
return null;
|
|
@@ -20723,7 +20738,7 @@ function appendEvent(d, ev) {
|
|
|
20723
20738
|
at: ev.at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
20724
20739
|
...ev
|
|
20725
20740
|
});
|
|
20726
|
-
(0,
|
|
20741
|
+
(0, import_node_fs22.appendFileSync)(d.eventsPath, line2, { mode: 384 });
|
|
20727
20742
|
return true;
|
|
20728
20743
|
} catch {
|
|
20729
20744
|
return false;
|
|
@@ -20731,14 +20746,14 @@ function appendEvent(d, ev) {
|
|
|
20731
20746
|
}
|
|
20732
20747
|
function rotateIfNeeded2(d) {
|
|
20733
20748
|
try {
|
|
20734
|
-
if (!(0,
|
|
20735
|
-
if ((0,
|
|
20736
|
-
(0,
|
|
20737
|
-
(0,
|
|
20738
|
-
const kept = (0,
|
|
20749
|
+
if (!(0, import_node_fs22.existsSync)(d.eventsPath)) return;
|
|
20750
|
+
if ((0, import_node_fs22.statSync)(d.eventsPath).size < ROTATE_BYTES) return;
|
|
20751
|
+
(0, import_node_fs22.mkdirSync)(d.rotatedDir, { recursive: true, mode: 448 });
|
|
20752
|
+
(0, import_node_fs22.renameSync)(d.eventsPath, (0, import_node_path20.join)(d.rotatedDir, `events.${Date.now()}.jsonl`));
|
|
20753
|
+
const kept = (0, import_node_fs22.readdirSync)(d.rotatedDir).filter((f) => f.endsWith(".jsonl")).sort();
|
|
20739
20754
|
for (const stale of kept.slice(0, Math.max(0, kept.length - ROTATE_KEEP))) {
|
|
20740
20755
|
try {
|
|
20741
|
-
(0,
|
|
20756
|
+
(0, import_node_fs22.renameSync)((0, import_node_path20.join)(d.rotatedDir, stale), (0, import_node_path20.join)(d.rotatedDir, `${stale}.pruned`));
|
|
20742
20757
|
} catch {
|
|
20743
20758
|
}
|
|
20744
20759
|
}
|
|
@@ -20748,8 +20763,8 @@ function rotateIfNeeded2(d) {
|
|
|
20748
20763
|
|
|
20749
20764
|
// src/lib/dossier/fold-dossier.ts
|
|
20750
20765
|
var import_node_crypto6 = require("node:crypto");
|
|
20751
|
-
var
|
|
20752
|
-
var
|
|
20766
|
+
var import_node_fs23 = require("node:fs");
|
|
20767
|
+
var import_node_path21 = require("node:path");
|
|
20753
20768
|
var EMPTY_CAPABILITIES = () => ({
|
|
20754
20769
|
human_reachable: { value: "unknown", tier: "unknown" },
|
|
20755
20770
|
authorship_observability: { value: "unknown", tier: "unknown" },
|
|
@@ -20800,12 +20815,12 @@ function foldDossier(d, opts = {}) {
|
|
|
20800
20815
|
}
|
|
20801
20816
|
};
|
|
20802
20817
|
try {
|
|
20803
|
-
if ((0,
|
|
20804
|
-
const files = (0,
|
|
20818
|
+
if ((0, import_node_fs23.existsSync)(d.rotatedDir)) {
|
|
20819
|
+
const files = (0, import_node_fs23.readdirSync)(d.rotatedDir).filter((f) => f.endsWith(".jsonl")).sort();
|
|
20805
20820
|
state.meta.rotations = files.length;
|
|
20806
20821
|
for (const f of files) {
|
|
20807
20822
|
try {
|
|
20808
|
-
ingest((0,
|
|
20823
|
+
ingest((0, import_node_fs23.readFileSync)((0, import_node_path21.join)(d.rotatedDir, f), "utf8"));
|
|
20809
20824
|
} catch {
|
|
20810
20825
|
state.meta.dropped_lines++;
|
|
20811
20826
|
}
|
|
@@ -20814,9 +20829,9 @@ function foldDossier(d, opts = {}) {
|
|
|
20814
20829
|
} catch {
|
|
20815
20830
|
}
|
|
20816
20831
|
try {
|
|
20817
|
-
if ((0,
|
|
20818
|
-
state.meta.upto_offset = (0,
|
|
20819
|
-
ingest((0,
|
|
20832
|
+
if ((0, import_node_fs23.existsSync)(d.eventsPath)) {
|
|
20833
|
+
state.meta.upto_offset = (0, import_node_fs23.statSync)(d.eventsPath).size;
|
|
20834
|
+
ingest((0, import_node_fs23.readFileSync)(d.eventsPath, "utf8"));
|
|
20820
20835
|
}
|
|
20821
20836
|
} catch {
|
|
20822
20837
|
}
|
|
@@ -21087,7 +21102,7 @@ function applyBounds(state, input) {
|
|
|
21087
21102
|
}
|
|
21088
21103
|
|
|
21089
21104
|
// src/lib/dossier/cache.ts
|
|
21090
|
-
var
|
|
21105
|
+
var import_node_fs24 = require("node:fs");
|
|
21091
21106
|
function compactState(s) {
|
|
21092
21107
|
const ms = (iso) => Date.parse(iso) || 0;
|
|
21093
21108
|
return {
|
|
@@ -21216,20 +21231,20 @@ function encodeState(s) {
|
|
|
21216
21231
|
function writeFoldCache(d, state) {
|
|
21217
21232
|
try {
|
|
21218
21233
|
const tmp = `${d.foldPath}.${process.pid}.tmp`;
|
|
21219
|
-
(0,
|
|
21220
|
-
(0,
|
|
21234
|
+
(0, import_node_fs24.writeFileSync)(tmp, encodeState(state), { mode: 384 });
|
|
21235
|
+
(0, import_node_fs24.renameSync)(tmp, d.foldPath);
|
|
21221
21236
|
} catch {
|
|
21222
21237
|
}
|
|
21223
21238
|
}
|
|
21224
21239
|
function readFoldCache(d) {
|
|
21225
21240
|
try {
|
|
21226
|
-
if (!(0,
|
|
21227
|
-
const raw = JSON.parse((0,
|
|
21241
|
+
if (!(0, import_node_fs24.existsSync)(d.foldPath)) return null;
|
|
21242
|
+
const raw = JSON.parse((0, import_node_fs24.readFileSync)(d.foldPath, "utf8"));
|
|
21228
21243
|
if (raw?.v !== 1) return null;
|
|
21229
21244
|
const cached2 = expandState(raw);
|
|
21230
21245
|
if (!cached2?.meta) return null;
|
|
21231
|
-
const size = (0,
|
|
21232
|
-
const rotations = (0,
|
|
21246
|
+
const size = (0, import_node_fs24.existsSync)(d.eventsPath) ? (0, import_node_fs24.statSync)(d.eventsPath).size : 0;
|
|
21247
|
+
const rotations = (0, import_node_fs24.existsSync)(d.rotatedDir) ? (0, import_node_fs24.readdirSync)(d.rotatedDir).filter((f) => f.endsWith(".jsonl")).length : 0;
|
|
21233
21248
|
if (cached2.meta.upto_offset !== size || cached2.meta.rotations !== rotations) return null;
|
|
21234
21249
|
return cached2;
|
|
21235
21250
|
} catch {
|
|
@@ -21280,13 +21295,13 @@ function assessContinuity(i2) {
|
|
|
21280
21295
|
|
|
21281
21296
|
// src/lib/dossier/reanchor.ts
|
|
21282
21297
|
var import_node_crypto7 = require("node:crypto");
|
|
21283
|
-
var
|
|
21298
|
+
var import_node_fs25 = require("node:fs");
|
|
21284
21299
|
function lineSha(text) {
|
|
21285
21300
|
return (0, import_node_crypto7.createHash)("sha256").update(text.trim()).digest("hex").slice(0, HASH_WIDTH);
|
|
21286
21301
|
}
|
|
21287
21302
|
function fileHash(path) {
|
|
21288
21303
|
try {
|
|
21289
|
-
return (0, import_node_crypto7.createHash)("sha256").update((0,
|
|
21304
|
+
return (0, import_node_crypto7.createHash)("sha256").update((0, import_node_fs25.readFileSync)(path)).digest("hex").slice(0, HASH_WIDTH);
|
|
21290
21305
|
} catch {
|
|
21291
21306
|
return null;
|
|
21292
21307
|
}
|
|
@@ -21658,20 +21673,20 @@ function foreignAuthoredPaths(identity, opts = {}) {
|
|
|
21658
21673
|
let sessions = 0;
|
|
21659
21674
|
try {
|
|
21660
21675
|
const dir = treeDir(identity);
|
|
21661
|
-
if (!(0,
|
|
21662
|
-
for (const entry of (0,
|
|
21676
|
+
if (!(0, import_node_fs26.existsSync)(dir)) return { paths: [], sessions: 0 };
|
|
21677
|
+
for (const entry of (0, import_node_fs26.readdirSync)(dir, { withFileTypes: true })) {
|
|
21663
21678
|
if (!entry.isDirectory()) continue;
|
|
21664
21679
|
if (entry.name === identity.sessionKey) continue;
|
|
21665
|
-
const log = (0,
|
|
21680
|
+
const log = (0, import_node_path22.join)(dir, entry.name, "events.jsonl");
|
|
21666
21681
|
try {
|
|
21667
|
-
if (!(0,
|
|
21668
|
-
if (now - (0,
|
|
21682
|
+
if (!(0, import_node_fs26.existsSync)(log)) continue;
|
|
21683
|
+
if (now - (0, import_node_fs26.statSync)(log).mtimeMs > windowMs) continue;
|
|
21669
21684
|
const sib = {
|
|
21670
|
-
dir: (0,
|
|
21685
|
+
dir: (0, import_node_path22.join)(dir, entry.name),
|
|
21671
21686
|
identity,
|
|
21672
21687
|
eventsPath: log,
|
|
21673
|
-
foldPath: (0,
|
|
21674
|
-
rotatedDir: (0,
|
|
21688
|
+
foldPath: (0, import_node_path22.join)(dir, entry.name, "fold.json"),
|
|
21689
|
+
rotatedDir: (0, import_node_path22.join)(dir, entry.name, "rotated")
|
|
21675
21690
|
};
|
|
21676
21691
|
const state = readFoldCache(sib) ?? foldDossier(sib);
|
|
21677
21692
|
sessions++;
|
|
@@ -21699,25 +21714,25 @@ function pruneOldDossiers(identity, maxAgeMs = 7 * 24 * 60 * 60 * 1e3) {
|
|
|
21699
21714
|
let removed = 0;
|
|
21700
21715
|
try {
|
|
21701
21716
|
const mine = dossierDir(identity);
|
|
21702
|
-
const userDir = (0,
|
|
21703
|
-
if (!(0,
|
|
21717
|
+
const userDir = (0, import_node_path22.dirname)((0, import_node_path22.dirname)(mine));
|
|
21718
|
+
if (!(0, import_node_fs26.existsSync)(userDir)) return 0;
|
|
21704
21719
|
const cutoff = Date.now() - maxAgeMs;
|
|
21705
|
-
for (const tree of (0,
|
|
21720
|
+
for (const tree of (0, import_node_fs26.readdirSync)(userDir, { withFileTypes: true })) {
|
|
21706
21721
|
if (!tree.isDirectory()) continue;
|
|
21707
|
-
const treePath = (0,
|
|
21722
|
+
const treePath = (0, import_node_path22.join)(userDir, tree.name);
|
|
21708
21723
|
let live = 0;
|
|
21709
|
-
for (const entry of (0,
|
|
21724
|
+
for (const entry of (0, import_node_fs26.readdirSync)(treePath, { withFileTypes: true })) {
|
|
21710
21725
|
if (!entry.isDirectory()) continue;
|
|
21711
|
-
const dir = (0,
|
|
21726
|
+
const dir = (0, import_node_path22.join)(treePath, entry.name);
|
|
21712
21727
|
if (dir === mine) {
|
|
21713
21728
|
live++;
|
|
21714
21729
|
continue;
|
|
21715
21730
|
}
|
|
21716
21731
|
try {
|
|
21717
|
-
const log = (0,
|
|
21718
|
-
const at = (0,
|
|
21732
|
+
const log = (0, import_node_path22.join)(dir, "events.jsonl");
|
|
21733
|
+
const at = (0, import_node_fs26.existsSync)(log) ? (0, import_node_fs26.statSync)(log).mtimeMs : (0, import_node_fs26.statSync)(dir).mtimeMs;
|
|
21719
21734
|
if (at < cutoff) {
|
|
21720
|
-
(0,
|
|
21735
|
+
(0, import_node_fs26.rmSync)(dir, { recursive: true, force: true });
|
|
21721
21736
|
removed++;
|
|
21722
21737
|
} else {
|
|
21723
21738
|
live++;
|
|
@@ -21727,7 +21742,7 @@ function pruneOldDossiers(identity, maxAgeMs = 7 * 24 * 60 * 60 * 1e3) {
|
|
|
21727
21742
|
}
|
|
21728
21743
|
if (live === 0) {
|
|
21729
21744
|
try {
|
|
21730
|
-
(0,
|
|
21745
|
+
(0, import_node_fs26.rmSync)(treePath, { recursive: false, force: false });
|
|
21731
21746
|
} catch {
|
|
21732
21747
|
}
|
|
21733
21748
|
}
|
|
@@ -21744,8 +21759,8 @@ function sessionDossier(token, sessionId) {
|
|
|
21744
21759
|
}
|
|
21745
21760
|
function hasActiveGoal(d) {
|
|
21746
21761
|
try {
|
|
21747
|
-
if (!(0,
|
|
21748
|
-
return (0,
|
|
21762
|
+
if (!(0, import_node_fs26.existsSync)(d.eventsPath)) return false;
|
|
21763
|
+
return (0, import_node_fs26.readFileSync)(d.eventsPath, "utf8").includes('"k":"goal"');
|
|
21749
21764
|
} catch {
|
|
21750
21765
|
return false;
|
|
21751
21766
|
}
|
|
@@ -21769,7 +21784,7 @@ function recordTurn(d, t) {
|
|
|
21769
21784
|
for (const a of t.authored) {
|
|
21770
21785
|
const origin = a.owner === "subagent" ? "subagent" : "edit_tool";
|
|
21771
21786
|
const prior = t.known?.authored?.get(a.p);
|
|
21772
|
-
const hash = fileHash((0,
|
|
21787
|
+
const hash = fileHash((0, import_node_path22.join)(root, a.p));
|
|
21773
21788
|
const hunks = Math.max(0, a.h - (prior?.hunks ?? 0));
|
|
21774
21789
|
const adds = Math.max(0, a.a - (prior?.adds ?? 0));
|
|
21775
21790
|
const dels = Math.max(0, a.d - (prior?.dels ?? 0));
|
|
@@ -21802,7 +21817,7 @@ function recordTurn(d, t) {
|
|
|
21802
21817
|
}
|
|
21803
21818
|
const seenDivergence = t.known?.divergence ?? /* @__PURE__ */ new Set();
|
|
21804
21819
|
for (const u of t.unobserved) {
|
|
21805
|
-
const hash = fileHash((0,
|
|
21820
|
+
const hash = fileHash((0, import_node_path22.join)(root, u.p));
|
|
21806
21821
|
if (seenDivergence.has(divergenceKey(u.p, hash))) continue;
|
|
21807
21822
|
appendEvent(d, { k: "divergence", kind: "external_mutation", path: u.p, hash });
|
|
21808
21823
|
}
|
|
@@ -21837,8 +21852,8 @@ function recordVerdict(d, v) {
|
|
|
21837
21852
|
if (!sent.has(f.file)) continue;
|
|
21838
21853
|
if (!lines.has(f.file)) {
|
|
21839
21854
|
try {
|
|
21840
|
-
const abs = (0,
|
|
21841
|
-
lines.set(f.file, (0,
|
|
21855
|
+
const abs = (0, import_node_path22.join)(root, f.file);
|
|
21856
|
+
lines.set(f.file, (0, import_node_fs26.existsSync)(abs) ? (0, import_node_fs26.readFileSync)(abs, "utf8").split("\n") : null);
|
|
21842
21857
|
} catch {
|
|
21843
21858
|
lines.set(f.file, null);
|
|
21844
21859
|
}
|
|
@@ -21938,8 +21953,8 @@ function recallMemory(d, identity, opts) {
|
|
|
21938
21953
|
budgetBytes: opts.budgetBytes,
|
|
21939
21954
|
readFileLines: (file) => {
|
|
21940
21955
|
try {
|
|
21941
|
-
const abs = (0,
|
|
21942
|
-
return (0,
|
|
21956
|
+
const abs = (0, import_node_path22.join)(root, file);
|
|
21957
|
+
return (0, import_node_fs26.existsSync)(abs) ? (0, import_node_fs26.readFileSync)(abs, "utf8").split("\n") : null;
|
|
21943
21958
|
} catch {
|
|
21944
21959
|
return null;
|
|
21945
21960
|
}
|
|
@@ -22107,21 +22122,21 @@ async function fireClassify(prompt, sessionId, globals) {
|
|
|
22107
22122
|
}
|
|
22108
22123
|
|
|
22109
22124
|
// src/commands/lifecycle.ts
|
|
22110
|
-
var
|
|
22111
|
-
var
|
|
22125
|
+
var import_node_fs29 = require("node:fs");
|
|
22126
|
+
var import_node_path26 = require("node:path");
|
|
22112
22127
|
|
|
22113
22128
|
// src/lib/baseline.ts
|
|
22114
|
-
var
|
|
22115
|
-
var
|
|
22129
|
+
var import_node_fs28 = require("node:fs");
|
|
22130
|
+
var import_node_path25 = require("node:path");
|
|
22116
22131
|
var import_node_crypto10 = require("node:crypto");
|
|
22117
22132
|
|
|
22118
22133
|
// src/lib/snapshot.ts
|
|
22119
|
-
var
|
|
22120
|
-
var
|
|
22134
|
+
var import_node_fs27 = require("node:fs");
|
|
22135
|
+
var import_node_path24 = require("node:path");
|
|
22121
22136
|
var import_node_child_process8 = require("node:child_process");
|
|
22122
22137
|
|
|
22123
22138
|
// src/lib/files.ts
|
|
22124
|
-
var
|
|
22139
|
+
var import_node_path23 = require("node:path");
|
|
22125
22140
|
var LANG_MAP = {
|
|
22126
22141
|
// Analyzable (static analysis + Gemini)
|
|
22127
22142
|
ts: "typescript",
|
|
@@ -22189,7 +22204,7 @@ var LANG_MAP = {
|
|
|
22189
22204
|
mk: "make"
|
|
22190
22205
|
};
|
|
22191
22206
|
function detectLanguage(filepath) {
|
|
22192
|
-
const ext = (0,
|
|
22207
|
+
const ext = (0, import_node_path23.extname)(filepath).slice(1);
|
|
22193
22208
|
return LANG_MAP[ext] ?? ext;
|
|
22194
22209
|
}
|
|
22195
22210
|
function sortByMtime(files) {
|
|
@@ -22280,16 +22295,16 @@ function collectCodeDelta(files, opts) {
|
|
|
22280
22295
|
|
|
22281
22296
|
// src/lib/snapshot.ts
|
|
22282
22297
|
function generateSnapshotDiffs(files) {
|
|
22283
|
-
if (!(0,
|
|
22298
|
+
if (!(0, import_node_fs27.existsSync)(SNAPSHOT_DIR)) {
|
|
22284
22299
|
return { diffs: [], has_snapshots: false };
|
|
22285
22300
|
}
|
|
22286
22301
|
const diffs = [];
|
|
22287
22302
|
for (const file of files) {
|
|
22288
22303
|
if (!resolveInside(SNAPSHOT_DIR, file.path)) continue;
|
|
22289
|
-
const snapshotPath = (0,
|
|
22304
|
+
const snapshotPath = (0, import_node_path24.join)(SNAPSHOT_DIR, file.path);
|
|
22290
22305
|
const language = file.language ?? detectLanguage(file.path);
|
|
22291
|
-
if ((0,
|
|
22292
|
-
const oldContent = (0,
|
|
22306
|
+
if ((0, import_node_fs27.existsSync)(snapshotPath)) {
|
|
22307
|
+
const oldContent = (0, import_node_fs27.readFileSync)(snapshotPath, "utf-8");
|
|
22293
22308
|
if (oldContent === file.content) continue;
|
|
22294
22309
|
const diff = computeDiff(oldContent, file.content, file.path);
|
|
22295
22310
|
if (diff) {
|
|
@@ -22314,20 +22329,20 @@ function saveSnapshots(files) {
|
|
|
22314
22329
|
const snapshotPaths = /* @__PURE__ */ new Set();
|
|
22315
22330
|
for (const file of files) {
|
|
22316
22331
|
if (!resolveInside(SNAPSHOT_DIR, file.path)) continue;
|
|
22317
|
-
const snapshotPath = (0,
|
|
22332
|
+
const snapshotPath = (0, import_node_path24.join)(SNAPSHOT_DIR, file.path);
|
|
22318
22333
|
snapshotPaths.add(snapshotPath);
|
|
22319
|
-
(0,
|
|
22320
|
-
(0,
|
|
22334
|
+
(0, import_node_fs27.mkdirSync)((0, import_node_path24.dirname)(snapshotPath), { recursive: true });
|
|
22335
|
+
(0, import_node_fs27.writeFileSync)(snapshotPath, file.content);
|
|
22321
22336
|
}
|
|
22322
22337
|
cleanStaleSnapshots(SNAPSHOT_DIR, snapshotPaths);
|
|
22323
22338
|
}
|
|
22324
22339
|
function computeDiff(oldContent, newContent, filePath) {
|
|
22325
|
-
const tmpOld = (0,
|
|
22326
|
-
const tmpNew = (0,
|
|
22340
|
+
const tmpOld = (0, import_node_path24.join)(SNAPSHOT_DIR, ".diff-old.tmp");
|
|
22341
|
+
const tmpNew = (0, import_node_path24.join)(SNAPSHOT_DIR, ".diff-new.tmp");
|
|
22327
22342
|
try {
|
|
22328
|
-
(0,
|
|
22329
|
-
(0,
|
|
22330
|
-
(0,
|
|
22343
|
+
(0, import_node_fs27.mkdirSync)(SNAPSHOT_DIR, { recursive: true });
|
|
22344
|
+
(0, import_node_fs27.writeFileSync)(tmpOld, oldContent);
|
|
22345
|
+
(0, import_node_fs27.writeFileSync)(tmpNew, newContent);
|
|
22331
22346
|
const result = (0, import_node_child_process8.execSync)(
|
|
22332
22347
|
`git diff --no-index --unified=10 -- "${tmpOld}" "${tmpNew}"`,
|
|
22333
22348
|
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
@@ -22341,32 +22356,32 @@ function computeDiff(oldContent, newContent, filePath) {
|
|
|
22341
22356
|
return null;
|
|
22342
22357
|
} finally {
|
|
22343
22358
|
try {
|
|
22344
|
-
(0,
|
|
22359
|
+
(0, import_node_fs27.unlinkSync)(tmpOld);
|
|
22345
22360
|
} catch {
|
|
22346
22361
|
}
|
|
22347
22362
|
try {
|
|
22348
|
-
(0,
|
|
22363
|
+
(0, import_node_fs27.unlinkSync)(tmpNew);
|
|
22349
22364
|
} catch {
|
|
22350
22365
|
}
|
|
22351
22366
|
}
|
|
22352
22367
|
}
|
|
22353
22368
|
function cleanStaleSnapshots(dir, keepSet) {
|
|
22354
|
-
if (!(0,
|
|
22369
|
+
if (!(0, import_node_fs27.existsSync)(dir)) return;
|
|
22355
22370
|
try {
|
|
22356
|
-
const entries = (0,
|
|
22371
|
+
const entries = (0, import_node_fs27.readdirSync)(dir, { withFileTypes: true });
|
|
22357
22372
|
for (const entry of entries) {
|
|
22358
22373
|
if (dir === SNAPSHOT_DIR && (entry.name === ".diff-old.tmp" || entry.name === ".diff-new.tmp")) continue;
|
|
22359
|
-
const fullPath = (0,
|
|
22374
|
+
const fullPath = (0, import_node_path24.join)(dir, entry.name);
|
|
22360
22375
|
if (entry.isDirectory()) {
|
|
22361
22376
|
cleanStaleSnapshots(fullPath, keepSet);
|
|
22362
22377
|
try {
|
|
22363
|
-
const remaining = (0,
|
|
22364
|
-
if (remaining.length === 0) (0,
|
|
22378
|
+
const remaining = (0, import_node_fs27.readdirSync)(fullPath);
|
|
22379
|
+
if (remaining.length === 0) (0, import_node_fs27.rmdirSync)(fullPath);
|
|
22365
22380
|
} catch {
|
|
22366
22381
|
}
|
|
22367
22382
|
} else if (!keepSet.has(fullPath)) {
|
|
22368
22383
|
try {
|
|
22369
|
-
(0,
|
|
22384
|
+
(0, import_node_fs27.unlinkSync)(fullPath);
|
|
22370
22385
|
} catch {
|
|
22371
22386
|
}
|
|
22372
22387
|
}
|
|
@@ -22385,20 +22400,20 @@ function sessionKey(sessionId) {
|
|
|
22385
22400
|
return (0, import_node_crypto10.createHash)("sha256").update(sessionId).digest("hex").slice(0, 16);
|
|
22386
22401
|
}
|
|
22387
22402
|
function sessionDir(key) {
|
|
22388
|
-
return (0,
|
|
22403
|
+
return (0, import_node_path25.join)(projectPath(BASELINE_DIR), key);
|
|
22389
22404
|
}
|
|
22390
22405
|
function manifestPath(dir) {
|
|
22391
|
-
return (0,
|
|
22406
|
+
return (0, import_node_path25.join)(dir, "manifest.json");
|
|
22392
22407
|
}
|
|
22393
22408
|
function mirrorPath(dir, repoRelPath) {
|
|
22394
|
-
return (0,
|
|
22409
|
+
return (0, import_node_path25.join)(dir, "files", repoRelPath);
|
|
22395
22410
|
}
|
|
22396
22411
|
var CARRY_FILE = `${BASELINE_DIR}/.carry`;
|
|
22397
22412
|
var CARRY_WINDOW_MS = 12e4;
|
|
22398
22413
|
function writeCarry(sessionId, headSha) {
|
|
22399
22414
|
try {
|
|
22400
|
-
(0,
|
|
22401
|
-
(0,
|
|
22415
|
+
(0, import_node_fs28.mkdirSync)(projectPath(BASELINE_DIR), { recursive: true });
|
|
22416
|
+
(0, import_node_fs28.writeFileSync)(
|
|
22402
22417
|
projectPath(CARRY_FILE),
|
|
22403
22418
|
JSON.stringify({ from_key: sessionKey(sessionId), head_sha: headSha, ts: Date.now() })
|
|
22404
22419
|
);
|
|
@@ -22408,10 +22423,10 @@ function writeCarry(sessionId, headSha) {
|
|
|
22408
22423
|
function claimCarry(newKey) {
|
|
22409
22424
|
const carryPath = projectPath(CARRY_FILE);
|
|
22410
22425
|
try {
|
|
22411
|
-
if (!(0,
|
|
22412
|
-
const carry = JSON.parse((0,
|
|
22426
|
+
if (!(0, import_node_fs28.existsSync)(carryPath)) return null;
|
|
22427
|
+
const carry = JSON.parse((0, import_node_fs28.readFileSync)(carryPath, "utf-8"));
|
|
22413
22428
|
try {
|
|
22414
|
-
(0,
|
|
22429
|
+
(0, import_node_fs28.rmSync)(carryPath, { force: true });
|
|
22415
22430
|
} catch {
|
|
22416
22431
|
}
|
|
22417
22432
|
if (!carry?.from_key || typeof carry.ts !== "number") return null;
|
|
@@ -22422,11 +22437,11 @@ function claimCarry(newKey) {
|
|
|
22422
22437
|
if (!prior) return null;
|
|
22423
22438
|
const toDir = sessionDir(newKey);
|
|
22424
22439
|
try {
|
|
22425
|
-
(0,
|
|
22440
|
+
(0, import_node_fs28.rmSync)(toDir, { recursive: true, force: true });
|
|
22426
22441
|
} catch {
|
|
22427
22442
|
}
|
|
22428
|
-
(0,
|
|
22429
|
-
(0,
|
|
22443
|
+
(0, import_node_fs28.renameSync)(fromDir, toDir);
|
|
22444
|
+
(0, import_node_fs28.writeFileSync)(manifestPath(toDir), JSON.stringify({ ...prior, session_id: newKey }) + "\n");
|
|
22430
22445
|
return readManifest(toDir);
|
|
22431
22446
|
} catch {
|
|
22432
22447
|
return null;
|
|
@@ -22450,21 +22465,21 @@ function captureBaseline(opts = {}) {
|
|
|
22450
22465
|
const head_sha = getCurrentCommit();
|
|
22451
22466
|
const dirty = getDirtyFiles();
|
|
22452
22467
|
try {
|
|
22453
|
-
(0,
|
|
22468
|
+
(0, import_node_fs28.rmSync)(dir, { recursive: true, force: true });
|
|
22454
22469
|
} catch {
|
|
22455
22470
|
}
|
|
22456
|
-
const filesDir = (0,
|
|
22471
|
+
const filesDir = (0, import_node_path25.join)(dir, "files");
|
|
22457
22472
|
const mirrored = [];
|
|
22458
22473
|
try {
|
|
22459
|
-
(0,
|
|
22474
|
+
(0, import_node_fs28.mkdirSync)(filesDir, { recursive: true });
|
|
22460
22475
|
for (const p of dirty) {
|
|
22461
22476
|
if (p.includes("..")) continue;
|
|
22462
22477
|
const content = safeReadForMirror(projectPath(p));
|
|
22463
22478
|
if (content === null) continue;
|
|
22464
22479
|
const dest = mirrorPath(dir, p);
|
|
22465
22480
|
try {
|
|
22466
|
-
(0,
|
|
22467
|
-
(0,
|
|
22481
|
+
(0, import_node_fs28.mkdirSync)((0, import_node_path25.dirname)(dest), { recursive: true });
|
|
22482
|
+
(0, import_node_fs28.writeFileSync)(dest, content);
|
|
22468
22483
|
mirrored.push(p);
|
|
22469
22484
|
} catch {
|
|
22470
22485
|
}
|
|
@@ -22479,8 +22494,8 @@ function captureBaseline(opts = {}) {
|
|
|
22479
22494
|
version: BASELINE_VERSION
|
|
22480
22495
|
};
|
|
22481
22496
|
try {
|
|
22482
|
-
(0,
|
|
22483
|
-
(0,
|
|
22497
|
+
(0, import_node_fs28.mkdirSync)(dir, { recursive: true });
|
|
22498
|
+
(0, import_node_fs28.writeFileSync)(manifestPath(dir), JSON.stringify(baseline));
|
|
22484
22499
|
} catch {
|
|
22485
22500
|
}
|
|
22486
22501
|
pruneOldBaselines();
|
|
@@ -22491,9 +22506,9 @@ function readBaseline(sessionId) {
|
|
|
22491
22506
|
}
|
|
22492
22507
|
function readManifest(dir) {
|
|
22493
22508
|
const mp = manifestPath(dir);
|
|
22494
|
-
if (!(0,
|
|
22509
|
+
if (!(0, import_node_fs28.existsSync)(mp)) return null;
|
|
22495
22510
|
try {
|
|
22496
|
-
const parsed = JSON.parse((0,
|
|
22511
|
+
const parsed = JSON.parse((0, import_node_fs28.readFileSync)(mp, "utf-8"));
|
|
22497
22512
|
if (typeof parsed.head_sha !== "string" || typeof parsed.captured_at !== "number" || !Array.isArray(parsed.dirty_paths) || parsed.version !== BASELINE_VERSION) {
|
|
22498
22513
|
return null;
|
|
22499
22514
|
}
|
|
@@ -22524,9 +22539,9 @@ function preImage(repoRelPath, baseline) {
|
|
|
22524
22539
|
function resolvePreImage(repoRelPath, baseline) {
|
|
22525
22540
|
if (baseline.dirty_paths.includes(repoRelPath)) {
|
|
22526
22541
|
const mp = mirrorPath(sessionDir(sessionKey(baseline.session_id)), repoRelPath);
|
|
22527
|
-
if ((0,
|
|
22542
|
+
if ((0, import_node_fs28.existsSync)(mp)) {
|
|
22528
22543
|
try {
|
|
22529
|
-
return { content: (0,
|
|
22544
|
+
return { content: (0, import_node_fs28.readFileSync)(mp, "utf-8"), existed: true };
|
|
22530
22545
|
} catch {
|
|
22531
22546
|
}
|
|
22532
22547
|
}
|
|
@@ -22571,8 +22586,8 @@ function absorbIntoBaseline(paths, sessionId) {
|
|
|
22571
22586
|
const content = safeReadForMirror(projectPath(p));
|
|
22572
22587
|
if (content === null) continue;
|
|
22573
22588
|
const dest = mirrorPath(dir, p);
|
|
22574
|
-
(0,
|
|
22575
|
-
(0,
|
|
22589
|
+
(0, import_node_fs28.mkdirSync)((0, import_node_path25.dirname)(dest), { recursive: true });
|
|
22590
|
+
(0, import_node_fs28.writeFileSync)(dest, content);
|
|
22576
22591
|
dirty.add(p);
|
|
22577
22592
|
adopted++;
|
|
22578
22593
|
} catch {
|
|
@@ -22581,7 +22596,7 @@ function absorbIntoBaseline(paths, sessionId) {
|
|
|
22581
22596
|
if (adopted === 0) return 0;
|
|
22582
22597
|
try {
|
|
22583
22598
|
const updated = { ...baseline, dirty_paths: [...dirty] };
|
|
22584
|
-
(0,
|
|
22599
|
+
(0, import_node_fs28.writeFileSync)(manifestPath(dir), JSON.stringify(updated));
|
|
22585
22600
|
preImageCache.delete(baseline);
|
|
22586
22601
|
} catch {
|
|
22587
22602
|
return 0;
|
|
@@ -22592,7 +22607,7 @@ function changedSinceBaseline(repoRelPath, baseline) {
|
|
|
22592
22607
|
const pre = preImage(repoRelPath, baseline);
|
|
22593
22608
|
let current;
|
|
22594
22609
|
try {
|
|
22595
|
-
current = (0,
|
|
22610
|
+
current = (0, import_node_fs28.readFileSync)(projectPath(repoRelPath), "utf-8");
|
|
22596
22611
|
} catch {
|
|
22597
22612
|
return pre.existed;
|
|
22598
22613
|
}
|
|
@@ -22601,8 +22616,8 @@ function changedSinceBaseline(repoRelPath, baseline) {
|
|
|
22601
22616
|
}
|
|
22602
22617
|
function safeReadForMirror(absPath) {
|
|
22603
22618
|
try {
|
|
22604
|
-
if ((0,
|
|
22605
|
-
const buf = (0,
|
|
22619
|
+
if ((0, import_node_fs28.statSync)(absPath).size > MIRROR_MAX_BYTES) return null;
|
|
22620
|
+
const buf = (0, import_node_fs28.readFileSync)(absPath);
|
|
22606
22621
|
if (buf.includes(0)) return null;
|
|
22607
22622
|
return buf.toString("utf-8");
|
|
22608
22623
|
} catch {
|
|
@@ -22613,18 +22628,18 @@ function pruneOldBaselines() {
|
|
|
22613
22628
|
const root = projectPath(BASELINE_DIR);
|
|
22614
22629
|
let entries;
|
|
22615
22630
|
try {
|
|
22616
|
-
entries = (0,
|
|
22631
|
+
entries = (0, import_node_fs28.readdirSync)(root);
|
|
22617
22632
|
} catch {
|
|
22618
22633
|
return;
|
|
22619
22634
|
}
|
|
22620
22635
|
const now = Date.now();
|
|
22621
22636
|
for (const name2 of entries) {
|
|
22622
|
-
const dir = (0,
|
|
22637
|
+
const dir = (0, import_node_path25.join)(root, name2);
|
|
22623
22638
|
const manifest = readManifest(dir);
|
|
22624
22639
|
if (!manifest) {
|
|
22625
22640
|
try {
|
|
22626
|
-
if (now - (0,
|
|
22627
|
-
(0,
|
|
22641
|
+
if (now - (0, import_node_fs28.statSync)(dir).mtimeMs > BASELINE_TTL_MS) {
|
|
22642
|
+
(0, import_node_fs28.rmSync)(dir, { recursive: true, force: true });
|
|
22628
22643
|
}
|
|
22629
22644
|
} catch {
|
|
22630
22645
|
}
|
|
@@ -22632,7 +22647,7 @@ function pruneOldBaselines() {
|
|
|
22632
22647
|
}
|
|
22633
22648
|
if (now - manifest.captured_at <= BASELINE_TTL_MS) continue;
|
|
22634
22649
|
try {
|
|
22635
|
-
(0,
|
|
22650
|
+
(0, import_node_fs28.rmSync)(dir, { recursive: true, force: true });
|
|
22636
22651
|
} catch {
|
|
22637
22652
|
}
|
|
22638
22653
|
}
|
|
@@ -22807,8 +22822,8 @@ function buildCompactionContext(session) {
|
|
|
22807
22822
|
commitsSince: commitsSincePaths(watermark, (state.authored ?? []).map((a) => a.path)),
|
|
22808
22823
|
readFileLines: (file) => {
|
|
22809
22824
|
try {
|
|
22810
|
-
const abs = (0,
|
|
22811
|
-
return (0,
|
|
22825
|
+
const abs = (0, import_node_path26.join)(root, file);
|
|
22826
|
+
return (0, import_node_fs29.existsSync)(abs) ? (0, import_node_fs29.readFileSync)(abs, "utf8").split("\n") : null;
|
|
22812
22827
|
} catch {
|
|
22813
22828
|
return null;
|
|
22814
22829
|
}
|
|
@@ -22865,24 +22880,24 @@ async function readHookStdin() {
|
|
|
22865
22880
|
|
|
22866
22881
|
// src/commands/standard.ts
|
|
22867
22882
|
var import_promises13 = require("node:fs/promises");
|
|
22868
|
-
var
|
|
22883
|
+
var import_node_fs36 = require("node:fs");
|
|
22869
22884
|
var import_yaml3 = __toESM2(require_dist());
|
|
22870
22885
|
|
|
22871
22886
|
// src/lib/synthesize.ts
|
|
22872
22887
|
var import_node_child_process10 = require("node:child_process");
|
|
22873
|
-
var
|
|
22888
|
+
var import_node_fs32 = require("node:fs");
|
|
22874
22889
|
var import_promises10 = require("node:fs/promises");
|
|
22875
|
-
var
|
|
22890
|
+
var import_node_path29 = require("node:path");
|
|
22876
22891
|
var import_yaml = __toESM2(require_dist());
|
|
22877
22892
|
|
|
22878
22893
|
// src/lib/data-dir.ts
|
|
22879
|
-
var
|
|
22880
|
-
var
|
|
22894
|
+
var import_node_fs30 = require("node:fs");
|
|
22895
|
+
var import_node_path27 = require("node:path");
|
|
22881
22896
|
function resolveDataDir() {
|
|
22882
22897
|
const candidates2 = [
|
|
22883
|
-
(0,
|
|
22898
|
+
(0, import_node_path27.join)(__dirname, "..", "data"),
|
|
22884
22899
|
// installed: node_modules/@codacy/verity-cli/data
|
|
22885
|
-
(0,
|
|
22900
|
+
(0, import_node_path27.join)(__dirname, "..", "..", "data"),
|
|
22886
22901
|
// edge case: nested resolution
|
|
22887
22902
|
// THE COMMITTED SOURCE, for a source checkout that has not been built.
|
|
22888
22903
|
// cli/data/skills/ is a BUILD ARTIFACT (scripts/build.js copies client/skills
|
|
@@ -22891,14 +22906,14 @@ function resolveDataDir() {
|
|
|
22891
22906
|
// without this the synthesizer throws "Could not find Verity skill data"
|
|
22892
22907
|
// for every test and every `verity` run from source. Resolved from this
|
|
22893
22908
|
// module's own location, never the cwd: see the warning below.
|
|
22894
|
-
(0,
|
|
22909
|
+
(0, import_node_path27.join)(__dirname, "..", "..", "client"),
|
|
22895
22910
|
// bundled: cli/bin/ → ../../client
|
|
22896
|
-
(0,
|
|
22911
|
+
(0, import_node_path27.join)(__dirname, "..", "..", "..", "client"),
|
|
22897
22912
|
// tsx: cli/src/lib/ → ../../../client
|
|
22898
22913
|
...process.env.VERITY_DEV_DATA_DIR ? [process.env.VERITY_DEV_DATA_DIR] : []
|
|
22899
22914
|
];
|
|
22900
22915
|
for (const candidate of candidates2) {
|
|
22901
|
-
if ((0,
|
|
22916
|
+
if ((0, import_node_fs30.existsSync)((0, import_node_path27.join)(candidate, "skills"))) {
|
|
22902
22917
|
return candidate;
|
|
22903
22918
|
}
|
|
22904
22919
|
}
|
|
@@ -22907,13 +22922,13 @@ function resolveDataDir() {
|
|
|
22907
22922
|
);
|
|
22908
22923
|
}
|
|
22909
22924
|
function setupDataPath(file) {
|
|
22910
|
-
return (0,
|
|
22925
|
+
return (0, import_node_path27.join)(resolveDataDir(), "skills", "verity-setup", file);
|
|
22911
22926
|
}
|
|
22912
22927
|
|
|
22913
22928
|
// src/lib/detect.ts
|
|
22914
22929
|
var import_node_child_process9 = require("node:child_process");
|
|
22915
|
-
var
|
|
22916
|
-
var
|
|
22930
|
+
var import_node_fs31 = require("node:fs");
|
|
22931
|
+
var import_node_path28 = require("node:path");
|
|
22917
22932
|
var TOOLED_LANGUAGES = /* @__PURE__ */ new Set([
|
|
22918
22933
|
"typescript",
|
|
22919
22934
|
"javascript",
|
|
@@ -22970,25 +22985,25 @@ function walk(root) {
|
|
|
22970
22985
|
if (depth > WALK_MAX_DEPTH || found.length >= WALK_MAX_FILES) return;
|
|
22971
22986
|
let entries;
|
|
22972
22987
|
try {
|
|
22973
|
-
entries = (0,
|
|
22988
|
+
entries = (0, import_node_fs31.readdirSync)(dir, { withFileTypes: true });
|
|
22974
22989
|
} catch {
|
|
22975
22990
|
return;
|
|
22976
22991
|
}
|
|
22977
22992
|
for (const entry of entries) {
|
|
22978
22993
|
if (found.length >= WALK_MAX_FILES) return;
|
|
22979
22994
|
if (IGNORED_SEGMENTS.includes(entry.name)) continue;
|
|
22980
|
-
const full = (0,
|
|
22995
|
+
const full = (0, import_node_path28.join)(dir, entry.name);
|
|
22981
22996
|
if (entry.isDirectory()) visit(full, depth + 1);
|
|
22982
|
-
else if (entry.isFile()) found.push((0,
|
|
22997
|
+
else if (entry.isFile()) found.push((0, import_node_path28.relative)(root, full));
|
|
22983
22998
|
}
|
|
22984
22999
|
};
|
|
22985
23000
|
visit(root, 0);
|
|
22986
23001
|
return found;
|
|
22987
23002
|
}
|
|
22988
23003
|
function languageOf(path) {
|
|
22989
|
-
const name2 = (0,
|
|
23004
|
+
const name2 = (0, import_node_path28.basename)(path);
|
|
22990
23005
|
if (/^Dockerfile(\..+)?$/i.test(name2)) return "dockerfile";
|
|
22991
|
-
if (!(0,
|
|
23006
|
+
if (!(0, import_node_path28.extname)(name2)) return null;
|
|
22992
23007
|
const lang = detectLanguage(path);
|
|
22993
23008
|
return lang || null;
|
|
22994
23009
|
}
|
|
@@ -23045,7 +23060,7 @@ var TOOL_CONFIG_MARKERS = [
|
|
|
23045
23060
|
];
|
|
23046
23061
|
function readJson2(path) {
|
|
23047
23062
|
try {
|
|
23048
|
-
return JSON.parse((0,
|
|
23063
|
+
return JSON.parse((0, import_node_fs31.readFileSync)(path, "utf-8"));
|
|
23049
23064
|
} catch {
|
|
23050
23065
|
return null;
|
|
23051
23066
|
}
|
|
@@ -23070,17 +23085,17 @@ function declaredDependencies(root, files) {
|
|
|
23070
23085
|
if (deps && typeof deps === "object") names2.push(...Object.keys(deps));
|
|
23071
23086
|
}
|
|
23072
23087
|
};
|
|
23073
|
-
readPackageJson((0,
|
|
23074
|
-
const nested = files.filter((f) => f.includes("/") && (0,
|
|
23075
|
-
for (const rel of nested) readPackageJson((0,
|
|
23088
|
+
readPackageJson((0, import_node_path28.join)(root, "package.json"));
|
|
23089
|
+
const nested = files.filter((f) => f.includes("/") && (0, import_node_path28.basename)(f) === "package.json").slice(0, NESTED_MANIFEST_LIMIT);
|
|
23090
|
+
for (const rel of nested) readPackageJson((0, import_node_path28.join)(root, rel));
|
|
23076
23091
|
const pythonManifests = [
|
|
23077
|
-
...["pyproject.toml", "requirements.txt", "Pipfile", "setup.py"].map((f) => (0,
|
|
23078
|
-
...files.filter((f) => f.includes("/") && /(^|\/)(pyproject\.toml|requirements\.txt)$/.test(f)).slice(0, NESTED_MANIFEST_LIMIT).map((f) => (0,
|
|
23092
|
+
...["pyproject.toml", "requirements.txt", "Pipfile", "setup.py"].map((f) => (0, import_node_path28.join)(root, f)),
|
|
23093
|
+
...files.filter((f) => f.includes("/") && /(^|\/)(pyproject\.toml|requirements\.txt)$/.test(f)).slice(0, NESTED_MANIFEST_LIMIT).map((f) => (0, import_node_path28.join)(root, f))
|
|
23079
23094
|
];
|
|
23080
23095
|
for (const path of pythonManifests) {
|
|
23081
|
-
if (!(0,
|
|
23096
|
+
if (!(0, import_node_fs31.existsSync)(path)) continue;
|
|
23082
23097
|
try {
|
|
23083
|
-
const text = (0,
|
|
23098
|
+
const text = (0, import_node_fs31.readFileSync)(path, "utf-8");
|
|
23084
23099
|
for (const m of text.matchAll(/^\s*["']?([A-Za-z][A-Za-z0-9._-]+)/gm)) names2.push(m[1]);
|
|
23085
23100
|
for (const line2 of text.split("\n")) {
|
|
23086
23101
|
if (!/dependencies\s*=/.test(line2)) continue;
|
|
@@ -23090,13 +23105,13 @@ function declaredDependencies(root, files) {
|
|
|
23090
23105
|
}
|
|
23091
23106
|
}
|
|
23092
23107
|
const goMods = [
|
|
23093
|
-
(0,
|
|
23094
|
-
...files.filter((f) => f.includes("/") && (0,
|
|
23108
|
+
(0, import_node_path28.join)(root, "go.mod"),
|
|
23109
|
+
...files.filter((f) => f.includes("/") && (0, import_node_path28.basename)(f) === "go.mod").slice(0, NESTED_MANIFEST_LIMIT).map((f) => (0, import_node_path28.join)(root, f))
|
|
23095
23110
|
];
|
|
23096
23111
|
for (const path of goMods) {
|
|
23097
|
-
if (!(0,
|
|
23112
|
+
if (!(0, import_node_fs31.existsSync)(path)) continue;
|
|
23098
23113
|
try {
|
|
23099
|
-
const text = (0,
|
|
23114
|
+
const text = (0, import_node_fs31.readFileSync)(path, "utf-8");
|
|
23100
23115
|
for (const m of text.matchAll(/^\s+([\w.-]+\/[\w./-]+)\s+v/gm)) {
|
|
23101
23116
|
names2.push(m[1].replace(/^github\.com\//, ""));
|
|
23102
23117
|
}
|
|
@@ -23104,10 +23119,10 @@ function declaredDependencies(root, files) {
|
|
|
23104
23119
|
}
|
|
23105
23120
|
}
|
|
23106
23121
|
for (const file of ["pom.xml", "build.gradle", "build.gradle.kts", "Gemfile", "Cargo.toml"]) {
|
|
23107
|
-
const path = (0,
|
|
23108
|
-
if (!(0,
|
|
23122
|
+
const path = (0, import_node_path28.join)(root, file);
|
|
23123
|
+
if (!(0, import_node_fs31.existsSync)(path)) continue;
|
|
23109
23124
|
try {
|
|
23110
|
-
const text = (0,
|
|
23125
|
+
const text = (0, import_node_fs31.readFileSync)(path, "utf-8");
|
|
23111
23126
|
for (const m of text.matchAll(/["'<]([A-Za-z][A-Za-z0-9._-]{2,})["'>]/g)) names2.push(m[1]);
|
|
23112
23127
|
} catch {
|
|
23113
23128
|
}
|
|
@@ -23115,7 +23130,7 @@ function declaredDependencies(root, files) {
|
|
|
23115
23130
|
return names2;
|
|
23116
23131
|
}
|
|
23117
23132
|
function detectBuildSystem(root, files) {
|
|
23118
|
-
const has = (f) => (0,
|
|
23133
|
+
const has = (f) => (0, import_node_fs31.existsSync)((0, import_node_path28.join)(root, f)) || files.some((p) => (0, import_node_path28.basename)(p) === f);
|
|
23119
23134
|
if (has("pnpm-lock.yaml")) return "pnpm";
|
|
23120
23135
|
if (has("yarn.lock")) return "yarn";
|
|
23121
23136
|
if (has("bun.lock") || has("bun.lockb")) return "bun";
|
|
@@ -23132,8 +23147,8 @@ function detectBuildSystem(root, files) {
|
|
|
23132
23147
|
}
|
|
23133
23148
|
function detectArchitecture(root, files) {
|
|
23134
23149
|
const workspaceMarkers = ["lerna.json", "pnpm-workspace.yaml", "nx.json", "turbo.json", "rush.json"];
|
|
23135
|
-
if (workspaceMarkers.some((m) => (0,
|
|
23136
|
-
const pkg = readJson2((0,
|
|
23150
|
+
if (workspaceMarkers.some((m) => (0, import_node_fs31.existsSync)((0, import_node_path28.join)(root, m)))) return "monorepo";
|
|
23151
|
+
const pkg = readJson2((0, import_node_path28.join)(root, "package.json"));
|
|
23137
23152
|
if (pkg && "workspaces" in pkg) return "monorepo";
|
|
23138
23153
|
const manifests = files.filter((f) => /(^|\/)(package\.json|go\.mod|pyproject\.toml|Cargo\.toml|pom\.xml)$/.test(f));
|
|
23139
23154
|
const nested = manifests.filter((f) => f.includes("/"));
|
|
@@ -23155,10 +23170,10 @@ function measureAvgFileLength(root, files, languages) {
|
|
|
23155
23170
|
let total = 0;
|
|
23156
23171
|
let counted = 0;
|
|
23157
23172
|
for (let i2 = 0; i2 < candidates2.length; i2 += stride) {
|
|
23158
|
-
const path = (0,
|
|
23173
|
+
const path = (0, import_node_path28.join)(root, candidates2[i2]);
|
|
23159
23174
|
try {
|
|
23160
|
-
if ((0,
|
|
23161
|
-
total += (0,
|
|
23175
|
+
if ((0, import_node_fs31.statSync)(path).size > 2 * 1024 * 1024) continue;
|
|
23176
|
+
total += (0, import_node_fs31.readFileSync)(path, "utf-8").split("\n").length;
|
|
23162
23177
|
counted++;
|
|
23163
23178
|
} catch {
|
|
23164
23179
|
}
|
|
@@ -23188,14 +23203,14 @@ function detectProject(root = repoRoot()) {
|
|
|
23188
23203
|
const existingToolConfigs = [];
|
|
23189
23204
|
for (const [tool, markers] of TOOL_CONFIG_MARKERS) {
|
|
23190
23205
|
for (const marker of markers) {
|
|
23191
|
-
if ((0,
|
|
23206
|
+
if ((0, import_node_fs31.existsSync)((0, import_node_path28.join)(root, marker))) {
|
|
23192
23207
|
existingToolConfigs.push({ tool, path: `./${marker}` });
|
|
23193
23208
|
break;
|
|
23194
23209
|
}
|
|
23195
23210
|
}
|
|
23196
23211
|
}
|
|
23197
23212
|
return {
|
|
23198
|
-
projectName: (0,
|
|
23213
|
+
projectName: (0, import_node_path28.basename)(root),
|
|
23199
23214
|
languages,
|
|
23200
23215
|
languageCounts,
|
|
23201
23216
|
frameworks: matchAll(dependencies, FRAMEWORK_BY_DEPENDENCY),
|
|
@@ -23293,8 +23308,8 @@ ${closingNote(input.origin)}
|
|
|
23293
23308
|
|
|
23294
23309
|
// src/lib/synthesize.ts
|
|
23295
23310
|
function loadCatalog() {
|
|
23296
|
-
const catalog = (0, import_yaml.parse)((0,
|
|
23297
|
-
const template = (0, import_yaml.parse)((0,
|
|
23311
|
+
const catalog = (0, import_yaml.parse)((0, import_node_fs32.readFileSync)(setupDataPath("patterns-reference.yaml"), "utf-8"));
|
|
23312
|
+
const template = (0, import_yaml.parse)((0, import_node_fs32.readFileSync)(setupDataPath("standard-template.yaml"), "utf-8"));
|
|
23298
23313
|
return { catalog, template };
|
|
23299
23314
|
}
|
|
23300
23315
|
function selectTools(languages, intensity, catalog) {
|
|
@@ -23572,7 +23587,7 @@ function validatePatternIds() {
|
|
|
23572
23587
|
}
|
|
23573
23588
|
async function runSynthesis(opts) {
|
|
23574
23589
|
const standardPath = projectPath(STANDARD_FILE);
|
|
23575
|
-
if ((0,
|
|
23590
|
+
if ((0, import_node_fs32.existsSync)(standardPath) && !opts.force) {
|
|
23576
23591
|
return { refused: `${STANDARD_FILE} already exists \u2014 pass --force to replace it.` };
|
|
23577
23592
|
}
|
|
23578
23593
|
const detected = opts.detected ?? detectProject();
|
|
@@ -23641,7 +23656,7 @@ async function correctVerityMdVersion(opts) {
|
|
|
23641
23656
|
}
|
|
23642
23657
|
async function writeFileTo(relative6, body2) {
|
|
23643
23658
|
const target = projectPath(relative6);
|
|
23644
|
-
await (0, import_promises10.mkdir)((0,
|
|
23659
|
+
await (0, import_promises10.mkdir)((0, import_node_path29.dirname)(target), { recursive: true });
|
|
23645
23660
|
await (0, import_promises10.writeFile)(target, body2);
|
|
23646
23661
|
}
|
|
23647
23662
|
async function deriveConfigForStandard(standard) {
|
|
@@ -23700,11 +23715,11 @@ ${validation.detail}`);
|
|
|
23700
23715
|
|
|
23701
23716
|
// src/lib/setup-state.ts
|
|
23702
23717
|
var import_promises11 = require("node:fs/promises");
|
|
23703
|
-
var
|
|
23718
|
+
var import_node_fs33 = require("node:fs");
|
|
23704
23719
|
var SETUP_STATE_FILE = `${VERITY_DIR}/setup.json`;
|
|
23705
23720
|
async function readSetupState() {
|
|
23706
23721
|
const path = projectPath(SETUP_STATE_FILE);
|
|
23707
|
-
if (!(0,
|
|
23722
|
+
if (!(0, import_node_fs33.existsSync)(path)) return null;
|
|
23708
23723
|
try {
|
|
23709
23724
|
const parsed = JSON.parse(await (0, import_promises11.readFile)(path, "utf-8"));
|
|
23710
23725
|
return parsed && typeof parsed === "object" ? parsed : null;
|
|
@@ -23720,12 +23735,12 @@ async function writeSetupState(patch) {
|
|
|
23720
23735
|
}
|
|
23721
23736
|
|
|
23722
23737
|
// src/lib/push-setup.ts
|
|
23723
|
-
var
|
|
23738
|
+
var import_node_fs35 = require("node:fs");
|
|
23724
23739
|
var import_promises12 = require("node:fs/promises");
|
|
23725
23740
|
var import_yaml2 = __toESM2(require_dist());
|
|
23726
23741
|
|
|
23727
23742
|
// src/lib/verityignore.ts
|
|
23728
|
-
var
|
|
23743
|
+
var import_node_fs34 = require("node:fs");
|
|
23729
23744
|
var EMPTY = { rules: [], securityOverlap: [], problems: [] };
|
|
23730
23745
|
var SECURITY_PROBES = [
|
|
23731
23746
|
".env",
|
|
@@ -23818,9 +23833,9 @@ function isIgnored3(ig, path) {
|
|
|
23818
23833
|
}
|
|
23819
23834
|
function loadVerityIgnore() {
|
|
23820
23835
|
const file = projectPath(VERITYIGNORE_FILE);
|
|
23821
|
-
if (!(0,
|
|
23836
|
+
if (!(0, import_node_fs34.existsSync)(file)) return EMPTY;
|
|
23822
23837
|
try {
|
|
23823
|
-
return parseVerityIgnore((0,
|
|
23838
|
+
return parseVerityIgnore((0, import_node_fs34.readFileSync)(file, "utf-8"));
|
|
23824
23839
|
} catch {
|
|
23825
23840
|
return EMPTY;
|
|
23826
23841
|
}
|
|
@@ -23858,9 +23873,9 @@ function buildStandardUpload(standard, ignoreRaw) {
|
|
|
23858
23873
|
}
|
|
23859
23874
|
function readVerityIgnoreRaw() {
|
|
23860
23875
|
const file = projectPath(VERITYIGNORE_FILE);
|
|
23861
|
-
if (!(0,
|
|
23876
|
+
if (!(0, import_node_fs34.existsSync)(file)) return null;
|
|
23862
23877
|
try {
|
|
23863
|
-
return (0,
|
|
23878
|
+
return (0, import_node_fs34.readFileSync)(file, "utf-8");
|
|
23864
23879
|
} catch {
|
|
23865
23880
|
return null;
|
|
23866
23881
|
}
|
|
@@ -23888,7 +23903,7 @@ async function pushStandardAndConfig(globals, what = {}) {
|
|
|
23888
23903
|
}
|
|
23889
23904
|
let standardVersion = null;
|
|
23890
23905
|
const standardPath = projectPath(STANDARD_FILE);
|
|
23891
|
-
if (pushStandard && (0,
|
|
23906
|
+
if (pushStandard && (0, import_node_fs35.existsSync)(standardPath)) {
|
|
23892
23907
|
try {
|
|
23893
23908
|
const content = (0, import_yaml2.parse)(await (0, import_promises12.readFile)(standardPath, "utf-8"));
|
|
23894
23909
|
const upload = buildStandardUpload(content, readVerityIgnoreRaw());
|
|
@@ -23913,7 +23928,7 @@ async function pushStandardAndConfig(globals, what = {}) {
|
|
|
23913
23928
|
}
|
|
23914
23929
|
let configPushed = false;
|
|
23915
23930
|
const configPath = projectPath(CODACY_CONFIG_FILE);
|
|
23916
|
-
if (pushConfig && (0,
|
|
23931
|
+
if (pushConfig && (0, import_node_fs35.existsSync)(configPath)) {
|
|
23917
23932
|
try {
|
|
23918
23933
|
const content = JSON.parse(await (0, import_promises12.readFile)(configPath, "utf-8"));
|
|
23919
23934
|
const result = await apiRequest({
|
|
@@ -23945,7 +23960,7 @@ function registerStandardCommands(program2) {
|
|
|
23945
23960
|
const state = await readSetupState();
|
|
23946
23961
|
if (opts.configOnly) {
|
|
23947
23962
|
const standardPath = projectPath(STANDARD_FILE);
|
|
23948
|
-
if (!(0,
|
|
23963
|
+
if (!(0, import_node_fs36.existsSync)(standardPath)) {
|
|
23949
23964
|
printError(`No ${STANDARD_FILE} here \u2014 run "verity standard synthesize" to create one.`);
|
|
23950
23965
|
process.exit(1);
|
|
23951
23966
|
}
|
|
@@ -24146,9 +24161,9 @@ function registerConfigCommands(program2) {
|
|
|
24146
24161
|
process.exit(1);
|
|
24147
24162
|
}
|
|
24148
24163
|
writeProjectConfig({ formal: state === "push" ? "push" : void 0 });
|
|
24149
|
-
const
|
|
24150
|
-
if (
|
|
24151
|
-
printWarn(`Formal verification at push: still off \u2014 ${formalRefusalMessage(
|
|
24164
|
+
const refused2 = state === "push" ? readProjectConfig().formal_refused : void 0;
|
|
24165
|
+
if (refused2) {
|
|
24166
|
+
printWarn(`Formal verification at push: still off \u2014 ${formalRefusalMessage(refused2)}`);
|
|
24152
24167
|
return;
|
|
24153
24168
|
}
|
|
24154
24169
|
printInfo(state === "push" ? "Formal verification at push: on for this checkout (Lean must be installed \u2014 verity lean status)" : "Formal verification at push: off");
|
|
@@ -24298,10 +24313,10 @@ function formatRunDetail(run4) {
|
|
|
24298
24313
|
}
|
|
24299
24314
|
|
|
24300
24315
|
// src/lib/ignore-declaration.ts
|
|
24301
|
-
var
|
|
24316
|
+
var import_node_fs38 = require("node:fs");
|
|
24302
24317
|
|
|
24303
24318
|
// src/lib/debounce.ts
|
|
24304
|
-
var
|
|
24319
|
+
var import_node_fs37 = require("node:fs");
|
|
24305
24320
|
var import_node_crypto11 = require("node:crypto");
|
|
24306
24321
|
function scopedFile(base, sessionId) {
|
|
24307
24322
|
if (!sessionId) return base;
|
|
@@ -24309,9 +24324,9 @@ function scopedFile(base, sessionId) {
|
|
|
24309
24324
|
}
|
|
24310
24325
|
function checkDebounce(debounceSeconds = DEBOUNCE_SECONDS, sessionId) {
|
|
24311
24326
|
const file = scopedFile(DEBOUNCE_FILE, sessionId);
|
|
24312
|
-
if (!(0,
|
|
24327
|
+
if (!(0, import_node_fs37.existsSync)(file)) return null;
|
|
24313
24328
|
try {
|
|
24314
|
-
const lastTs = parseInt((0,
|
|
24329
|
+
const lastTs = parseInt((0, import_node_fs37.readFileSync)(file, "utf-8").trim(), 10);
|
|
24315
24330
|
const nowTs = Math.floor(Date.now() / 1e3);
|
|
24316
24331
|
const elapsed = nowTs - lastTs;
|
|
24317
24332
|
if (elapsed < debounceSeconds) {
|
|
@@ -24324,10 +24339,10 @@ function checkDebounce(debounceSeconds = DEBOUNCE_SECONDS, sessionId) {
|
|
|
24324
24339
|
function checkMtime(files, bypassForRecentCommits, sessionId) {
|
|
24325
24340
|
if (bypassForRecentCommits) return null;
|
|
24326
24341
|
const file = scopedFile(DEBOUNCE_FILE, sessionId);
|
|
24327
|
-
if (!(0,
|
|
24342
|
+
if (!(0, import_node_fs37.existsSync)(file)) return null;
|
|
24328
24343
|
let debounceTime;
|
|
24329
24344
|
try {
|
|
24330
|
-
debounceTime = (0,
|
|
24345
|
+
debounceTime = (0, import_node_fs37.statSync)(file).mtimeMs;
|
|
24331
24346
|
} catch {
|
|
24332
24347
|
return null;
|
|
24333
24348
|
}
|
|
@@ -24335,7 +24350,7 @@ function checkMtime(files, bypassForRecentCommits, sessionId) {
|
|
|
24335
24350
|
const resolved = resolveFile(f);
|
|
24336
24351
|
if (!resolved) continue;
|
|
24337
24352
|
try {
|
|
24338
|
-
const stat3 = (0,
|
|
24353
|
+
const stat3 = (0, import_node_fs37.statSync)(resolved);
|
|
24339
24354
|
if (stat3.mtimeMs > debounceTime) {
|
|
24340
24355
|
return null;
|
|
24341
24356
|
}
|
|
@@ -24351,8 +24366,8 @@ function computeContentHash(files) {
|
|
|
24351
24366
|
for (const f of sorted) {
|
|
24352
24367
|
const resolved = resolveFile(f) ?? f;
|
|
24353
24368
|
try {
|
|
24354
|
-
if ((0,
|
|
24355
|
-
hash.update((0,
|
|
24369
|
+
if ((0, import_node_fs37.existsSync)(resolved)) {
|
|
24370
|
+
hash.update((0, import_node_fs37.readFileSync)(resolved));
|
|
24356
24371
|
}
|
|
24357
24372
|
} catch {
|
|
24358
24373
|
}
|
|
@@ -24362,9 +24377,9 @@ function computeContentHash(files) {
|
|
|
24362
24377
|
function checkContentHash(files, sessionId) {
|
|
24363
24378
|
const hash = computeContentHash(files);
|
|
24364
24379
|
const file = scopedFile(HASH_FILE, sessionId);
|
|
24365
|
-
if ((0,
|
|
24380
|
+
if ((0, import_node_fs37.existsSync)(file)) {
|
|
24366
24381
|
try {
|
|
24367
|
-
const storedHash = (0,
|
|
24382
|
+
const storedHash = (0, import_node_fs37.readFileSync)(file, "utf-8").trim();
|
|
24368
24383
|
if (hash === storedHash) {
|
|
24369
24384
|
return { skip: "No source changes since last analysis", hash };
|
|
24370
24385
|
}
|
|
@@ -24374,24 +24389,24 @@ function checkContentHash(files, sessionId) {
|
|
|
24374
24389
|
return { skip: null, hash };
|
|
24375
24390
|
}
|
|
24376
24391
|
function recordAnalysisStart(sessionId) {
|
|
24377
|
-
(0,
|
|
24378
|
-
(0,
|
|
24392
|
+
(0, import_node_fs37.mkdirSync)(VERITY_DIR, { recursive: true });
|
|
24393
|
+
(0, import_node_fs37.writeFileSync)(scopedFile(DEBOUNCE_FILE, sessionId), String(Math.floor(Date.now() / 1e3)));
|
|
24379
24394
|
}
|
|
24380
24395
|
function recordPassHash(hash, sessionId) {
|
|
24381
|
-
(0,
|
|
24396
|
+
(0, import_node_fs37.writeFileSync)(scopedFile(HASH_FILE, sessionId), hash);
|
|
24382
24397
|
}
|
|
24383
24398
|
function narrowToRecent(files, sessionId) {
|
|
24384
24399
|
const file = scopedFile(DEBOUNCE_FILE, sessionId);
|
|
24385
|
-
if (!(0,
|
|
24400
|
+
if (!(0, import_node_fs37.existsSync)(file)) return files;
|
|
24386
24401
|
let debounceTime;
|
|
24387
24402
|
try {
|
|
24388
|
-
debounceTime = (0,
|
|
24403
|
+
debounceTime = (0, import_node_fs37.statSync)(file).mtimeMs;
|
|
24389
24404
|
} catch {
|
|
24390
24405
|
return files;
|
|
24391
24406
|
}
|
|
24392
24407
|
const recent = files.filter((f) => {
|
|
24393
24408
|
try {
|
|
24394
|
-
return (0,
|
|
24409
|
+
return (0, import_node_fs37.existsSync)(f) && (0, import_node_fs37.statSync)(f).mtimeMs > debounceTime;
|
|
24395
24410
|
} catch {
|
|
24396
24411
|
return false;
|
|
24397
24412
|
}
|
|
@@ -24404,9 +24419,9 @@ function readIteration(currentCommit, _contentHash) {
|
|
|
24404
24419
|
var NO_BLOCKS = { attempts: 0, blocks: 0, fingerprint: null };
|
|
24405
24420
|
function readBlockState(currentCommit, opts) {
|
|
24406
24421
|
if (opts?.newUserPrompt) return NO_BLOCKS;
|
|
24407
|
-
if (!(0,
|
|
24422
|
+
if (!(0, import_node_fs37.existsSync)(ITERATION_FILE)) return NO_BLOCKS;
|
|
24408
24423
|
try {
|
|
24409
|
-
const stored = (0,
|
|
24424
|
+
const stored = (0, import_node_fs37.readFileSync)(ITERATION_FILE, "utf-8").trim();
|
|
24410
24425
|
const parsed = stored.startsWith("{") ? parseJsonState(stored) : parseLegacyState(stored);
|
|
24411
24426
|
if (!parsed) return NO_BLOCKS;
|
|
24412
24427
|
if (parsed.commit !== currentCommit) return NO_BLOCKS;
|
|
@@ -24452,8 +24467,8 @@ function isSameProblem(previous, current) {
|
|
|
24452
24467
|
return current.split(",").some((k) => prev.has(k));
|
|
24453
24468
|
}
|
|
24454
24469
|
function writeBlockState(commit, state) {
|
|
24455
|
-
(0,
|
|
24456
|
-
(0,
|
|
24470
|
+
(0, import_node_fs37.mkdirSync)(VERITY_DIR, { recursive: true });
|
|
24471
|
+
(0, import_node_fs37.writeFileSync)(
|
|
24457
24472
|
ITERATION_FILE,
|
|
24458
24473
|
JSON.stringify({
|
|
24459
24474
|
v: 2,
|
|
@@ -24558,9 +24573,9 @@ function resolveIgnoreState(keys) {
|
|
|
24558
24573
|
}
|
|
24559
24574
|
function readIgnoreState(sessionId) {
|
|
24560
24575
|
const file = stateFile(sessionId);
|
|
24561
|
-
if (!(0,
|
|
24576
|
+
if (!(0, import_node_fs38.existsSync)(file)) return null;
|
|
24562
24577
|
try {
|
|
24563
|
-
const o = JSON.parse((0,
|
|
24578
|
+
const o = JSON.parse((0, import_node_fs38.readFileSync)(file, "utf-8")) ?? {};
|
|
24564
24579
|
const spent = typeof o.spent === "number" ? o.spent : 0;
|
|
24565
24580
|
const raw = o.active;
|
|
24566
24581
|
let active = null;
|
|
@@ -24584,8 +24599,8 @@ function readIgnoreState(sessionId) {
|
|
|
24584
24599
|
}
|
|
24585
24600
|
function writeIgnoreState(state, sessionId) {
|
|
24586
24601
|
try {
|
|
24587
|
-
(0,
|
|
24588
|
-
(0,
|
|
24602
|
+
(0, import_node_fs38.mkdirSync)(projectPath(VERITY_DIR), { recursive: true });
|
|
24603
|
+
(0, import_node_fs38.writeFileSync)(stateFile(sessionId), JSON.stringify({ v: 1, active: state.active, spent: state.spent }));
|
|
24589
24604
|
} catch {
|
|
24590
24605
|
}
|
|
24591
24606
|
}
|
|
@@ -24968,7 +24983,7 @@ function createRun(opts, globals) {
|
|
|
24968
24983
|
}
|
|
24969
24984
|
|
|
24970
24985
|
// src/commands/analyze/index.ts
|
|
24971
|
-
var
|
|
24986
|
+
var import_node_fs52 = require("node:fs");
|
|
24972
24987
|
|
|
24973
24988
|
// src/lib/repo-context.ts
|
|
24974
24989
|
var import_node_child_process11 = require("node:child_process");
|
|
@@ -25932,10 +25947,10 @@ function installRunEvidence(run4) {
|
|
|
25932
25947
|
}
|
|
25933
25948
|
|
|
25934
25949
|
// src/lib/git-frame.ts
|
|
25935
|
-
var
|
|
25950
|
+
var import_node_fs39 = require("node:fs");
|
|
25936
25951
|
var import_node_os6 = require("node:os");
|
|
25937
|
-
var import_node_path29 = require("node:path");
|
|
25938
25952
|
var import_node_path30 = require("node:path");
|
|
25953
|
+
var import_node_path31 = require("node:path");
|
|
25939
25954
|
var VALUE_TOKEN = `(?:'[^']*'|"[^"]*"|\\S+)`;
|
|
25940
25955
|
var GIT_GLOBAL_OPTS = `(?:\\s+(?:-[Cc]\\s+${VALUE_TOKEN}|--?[\\w-]+(?:=\\S+)?))*`;
|
|
25941
25956
|
var COMMIT_HEAD = `git${GIT_GLOBAL_OPTS}\\s+commit(?![\\w-])`;
|
|
@@ -26022,8 +26037,8 @@ function extractCommandTarget(command, segmentIndex, baseDir) {
|
|
|
26022
26037
|
if (SHELL_DYNAMIC.test(raw) || raw === "-") {
|
|
26023
26038
|
return { dir: null, named: true, unresolvable: `cd target not statically resolvable: ${raw}` };
|
|
26024
26039
|
}
|
|
26025
|
-
const expanded = raw === "~" ? (0, import_node_os6.homedir)() : raw.startsWith("~/") ? (0,
|
|
26026
|
-
dir = (0,
|
|
26040
|
+
const expanded = raw === "~" ? (0, import_node_os6.homedir)() : raw.startsWith("~/") ? (0, import_node_path31.join)((0, import_node_os6.homedir)(), raw.slice(2)) : raw;
|
|
26041
|
+
dir = (0, import_node_path30.isAbsolute)(expanded) ? expanded : (0, import_node_path30.resolve)(dir, expanded);
|
|
26027
26042
|
}
|
|
26028
26043
|
const seg = segments[segmentIndex];
|
|
26029
26044
|
const overrideMatch = /--(?:git-dir|work-tree)(?:=|\s)|\bGIT_(?:DIR|WORK_TREE|INDEX_FILE)=/.exec(seg);
|
|
@@ -26041,8 +26056,8 @@ function extractCommandTarget(command, segmentIndex, baseDir) {
|
|
|
26041
26056
|
if (SHELL_DYNAMIC.test(raw)) {
|
|
26042
26057
|
return { dir: null, named: true, unresolvable: `-C target not statically resolvable: ${raw}` };
|
|
26043
26058
|
}
|
|
26044
|
-
const expanded = raw === "~" ? (0, import_node_os6.homedir)() : raw.startsWith("~/") ? (0,
|
|
26045
|
-
dir = (0,
|
|
26059
|
+
const expanded = raw === "~" ? (0, import_node_os6.homedir)() : raw.startsWith("~/") ? (0, import_node_path31.join)((0, import_node_os6.homedir)(), raw.slice(2)) : raw;
|
|
26060
|
+
dir = (0, import_node_path30.isAbsolute)(expanded) ? expanded : (0, import_node_path30.resolve)(dir, expanded);
|
|
26046
26061
|
}
|
|
26047
26062
|
}
|
|
26048
26063
|
return { dir, named, unresolvable: null };
|
|
@@ -26102,14 +26117,14 @@ function gitAt(dir, args2) {
|
|
|
26102
26117
|
}
|
|
26103
26118
|
function realpathOr2(p) {
|
|
26104
26119
|
try {
|
|
26105
|
-
return
|
|
26120
|
+
return import_node_fs39.realpathSync.native(p);
|
|
26106
26121
|
} catch {
|
|
26107
|
-
return (0,
|
|
26122
|
+
return (0, import_node_path30.resolve)(p);
|
|
26108
26123
|
}
|
|
26109
26124
|
}
|
|
26110
26125
|
function resolveFrame(input) {
|
|
26111
26126
|
const found = findMomentSegment(input.command, input.on);
|
|
26112
|
-
const hookDirUsable = !!input.hookCwd && (0,
|
|
26127
|
+
const hookDirUsable = !!input.hookCwd && (0, import_node_fs39.existsSync)(input.hookCwd);
|
|
26113
26128
|
const baseDir = hookDirUsable ? input.hookCwd : process.cwd();
|
|
26114
26129
|
let anchor = hookDirUsable ? "hook-cwd" : "process-cwd";
|
|
26115
26130
|
const refuse = (refusal) => ({
|
|
@@ -26132,7 +26147,7 @@ function resolveFrame(input) {
|
|
|
26132
26147
|
if (dirs.size > 1) return refuse(`target:multiple ${found.moment} targets in one command`);
|
|
26133
26148
|
const targetDir = dirs.size === 1 ? [...dirs][0] : baseDir;
|
|
26134
26149
|
if (targetDir !== baseDir) {
|
|
26135
|
-
if (!(0,
|
|
26150
|
+
if (!(0, import_node_fs39.existsSync)(targetDir)) return refuse(`target:directory does not exist: ${targetDir}`);
|
|
26136
26151
|
dir = targetDir;
|
|
26137
26152
|
}
|
|
26138
26153
|
}
|
|
@@ -26143,7 +26158,7 @@ function resolveFrame(input) {
|
|
|
26143
26158
|
const gitDirRaw = gitAt(dir, ["rev-parse", "--absolute-git-dir"]);
|
|
26144
26159
|
const commonRaw = gitAt(dir, ["rev-parse", "--git-common-dir"]);
|
|
26145
26160
|
const gitDir = gitDirRaw ? realpathOr2(gitDirRaw) : null;
|
|
26146
|
-
const commonDir = commonRaw ? realpathOr2((0,
|
|
26161
|
+
const commonDir = commonRaw ? realpathOr2((0, import_node_path30.isAbsolute)(commonRaw) ? commonRaw : (0, import_node_path30.resolve)(dir, commonRaw)) : null;
|
|
26147
26162
|
const branchRaw = gitAt(dir, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
26148
26163
|
return {
|
|
26149
26164
|
moment: found?.moment ?? null,
|
|
@@ -26318,8 +26333,8 @@ function stagedRange(frame, command) {
|
|
|
26318
26333
|
if (plan.kind === "unpredictable") {
|
|
26319
26334
|
return { kind: "staged", base: "HEAD", head: "INDEX", via: "staged-in-command", refusal: plan.reason };
|
|
26320
26335
|
}
|
|
26321
|
-
const mergeHead = frame.gitDir ? (0,
|
|
26322
|
-
if (mergeHead && (0,
|
|
26336
|
+
const mergeHead = frame.gitDir ? (0, import_node_path31.join)(frame.gitDir, "MERGE_HEAD") : null;
|
|
26337
|
+
if (mergeHead && (0, import_node_fs39.existsSync)(mergeHead)) {
|
|
26323
26338
|
const vsHead = new Set(frameGit(frame, ["diff", "--cached", "--name-only", "HEAD"]).split("\n").filter(Boolean));
|
|
26324
26339
|
const vsMerge = new Set(frameGit(frame, ["diff", "--cached", "--name-only", "MERGE_HEAD"]).split("\n").filter(Boolean));
|
|
26325
26340
|
const resolutions = new Set([...vsHead].filter((f) => vsMerge.has(f) && !isVerityOwnedPath(f)));
|
|
@@ -26453,7 +26468,7 @@ function truthy(v) {
|
|
|
26453
26468
|
}
|
|
26454
26469
|
|
|
26455
26470
|
// src/lib/transcript.ts
|
|
26456
|
-
var
|
|
26471
|
+
var import_node_fs40 = require("node:fs");
|
|
26457
26472
|
var MAX_READ_BYTES = 256 * 1024;
|
|
26458
26473
|
var SMALL_FILE_BYTES = 64 * 1024;
|
|
26459
26474
|
var MAX_FILES_LIST = 20;
|
|
@@ -26480,7 +26495,7 @@ async function extractActionSummary(transcriptPath) {
|
|
|
26480
26495
|
function readTurnLines(transcriptPath) {
|
|
26481
26496
|
let size;
|
|
26482
26497
|
try {
|
|
26483
|
-
size = (0,
|
|
26498
|
+
size = (0, import_node_fs40.statSync)(transcriptPath).size;
|
|
26484
26499
|
} catch {
|
|
26485
26500
|
return null;
|
|
26486
26501
|
}
|
|
@@ -26488,7 +26503,7 @@ function readTurnLines(transcriptPath) {
|
|
|
26488
26503
|
let raw;
|
|
26489
26504
|
let windowed = false;
|
|
26490
26505
|
if (size <= SMALL_FILE_BYTES) {
|
|
26491
|
-
raw = (0,
|
|
26506
|
+
raw = (0, import_node_fs40.readFileSync)(transcriptPath, "utf-8");
|
|
26492
26507
|
} else {
|
|
26493
26508
|
windowed = true;
|
|
26494
26509
|
const buf = Buffer.alloc(Math.min(MAX_READ_BYTES, size));
|
|
@@ -27058,7 +27073,7 @@ function channelSilence(input) {
|
|
|
27058
27073
|
// src/lib/cli-version.ts
|
|
27059
27074
|
function cliVersion() {
|
|
27060
27075
|
try {
|
|
27061
|
-
return true ? "0.34.0-experimental.
|
|
27076
|
+
return true ? "0.34.0-experimental.dc0010f" : "dev";
|
|
27062
27077
|
} catch {
|
|
27063
27078
|
return "dev";
|
|
27064
27079
|
}
|
|
@@ -27099,7 +27114,7 @@ async function sendSkipBeacon(ctx, reason) {
|
|
|
27099
27114
|
|
|
27100
27115
|
// src/lib/static-analysis.ts
|
|
27101
27116
|
var import_node_child_process12 = require("node:child_process");
|
|
27102
|
-
var
|
|
27117
|
+
var import_node_fs41 = require("node:fs");
|
|
27103
27118
|
var SEVERITY_ORDER = {
|
|
27104
27119
|
Error: 0,
|
|
27105
27120
|
Critical: 0,
|
|
@@ -27155,7 +27170,7 @@ function runCodacyAnalysis(files) {
|
|
|
27155
27170
|
if (files.length === 0) return empty;
|
|
27156
27171
|
const existingFiles = files.filter((f) => {
|
|
27157
27172
|
try {
|
|
27158
|
-
return (0,
|
|
27173
|
+
return (0, import_node_fs41.existsSync)(f);
|
|
27159
27174
|
} catch {
|
|
27160
27175
|
return false;
|
|
27161
27176
|
}
|
|
@@ -27424,8 +27439,8 @@ async function scope(run4) {
|
|
|
27424
27439
|
}
|
|
27425
27440
|
|
|
27426
27441
|
// src/lib/specs.ts
|
|
27427
|
-
var
|
|
27428
|
-
var
|
|
27442
|
+
var import_node_fs42 = require("node:fs");
|
|
27443
|
+
var import_node_path32 = require("node:path");
|
|
27429
27444
|
var SPEC_CANDIDATES = [
|
|
27430
27445
|
"CLAUDE.md",
|
|
27431
27446
|
"AGENTS.md",
|
|
@@ -27447,7 +27462,7 @@ var UNCONSULTED_TOTAL_BYTES = 30720;
|
|
|
27447
27462
|
function readSpecFiles(specsOpt, root) {
|
|
27448
27463
|
const out2 = [];
|
|
27449
27464
|
for (const raw of specsOpt.split(",").map((f) => f.trim()).filter(Boolean)) {
|
|
27450
|
-
const candidate = (0,
|
|
27465
|
+
const candidate = (0, import_node_path32.isAbsolute)(raw) ? (0, import_node_path32.relative)(root, raw) : raw;
|
|
27451
27466
|
const content = readFileInside(root, candidate, MAX_EXPLICIT_SPEC_FILE_BYTES);
|
|
27452
27467
|
if (content === null) continue;
|
|
27453
27468
|
out2.push({ path: raw, content });
|
|
@@ -27466,7 +27481,7 @@ function discoverSpecs(consulted = []) {
|
|
|
27466
27481
|
const totalCap = relevant ? MAX_TOTAL_SPEC_BYTES : UNCONSULTED_TOTAL_BYTES;
|
|
27467
27482
|
if (totalBytes >= totalCap) return false;
|
|
27468
27483
|
if (seen.has(specPath)) return true;
|
|
27469
|
-
if (!(0,
|
|
27484
|
+
if (!(0, import_node_fs42.existsSync)(specPath)) return true;
|
|
27470
27485
|
seen.add(specPath);
|
|
27471
27486
|
const remaining = totalCap - totalBytes;
|
|
27472
27487
|
const fileCap = relevant ? MAX_SPEC_FILE_BYTES : UNCONSULTED_FILE_BYTES;
|
|
@@ -27489,7 +27504,7 @@ function discoverSpecs(consulted = []) {
|
|
|
27489
27504
|
if (!addSpec(candidate)) break;
|
|
27490
27505
|
}
|
|
27491
27506
|
for (const dir of ["spec", "docs"]) {
|
|
27492
|
-
if (!(0,
|
|
27507
|
+
if (!(0, import_node_fs42.existsSync)(dir)) continue;
|
|
27493
27508
|
try {
|
|
27494
27509
|
const mdFiles = findMdFiles(dir, 2).sort();
|
|
27495
27510
|
for (const mdFile of mdFiles) {
|
|
@@ -27504,9 +27519,9 @@ function findMdFiles(dir, maxDepth, depth = 0) {
|
|
|
27504
27519
|
if (depth >= maxDepth) return [];
|
|
27505
27520
|
const result = [];
|
|
27506
27521
|
try {
|
|
27507
|
-
const entries = (0,
|
|
27522
|
+
const entries = (0, import_node_fs42.readdirSync)(dir, { withFileTypes: true });
|
|
27508
27523
|
for (const entry of entries) {
|
|
27509
|
-
const fullPath = (0,
|
|
27524
|
+
const fullPath = (0, import_node_path32.join)(dir, entry.name);
|
|
27510
27525
|
if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
27511
27526
|
result.push(fullPath);
|
|
27512
27527
|
} else if (entry.isDirectory() && depth < maxDepth - 1) {
|
|
@@ -27519,25 +27534,25 @@ function findMdFiles(dir, maxDepth, depth = 0) {
|
|
|
27519
27534
|
}
|
|
27520
27535
|
function discoverPlans() {
|
|
27521
27536
|
const home = process.env.HOME ?? "";
|
|
27522
|
-
const homePlansDir = (0,
|
|
27537
|
+
const homePlansDir = (0, import_node_path32.join)(home, ".claude", "plans");
|
|
27523
27538
|
const sources = [];
|
|
27524
27539
|
if (isRealDirectoryChain(process.cwd(), [".claude", "plans"])) {
|
|
27525
|
-
sources.push({ root: process.cwd(), prefix: (0,
|
|
27540
|
+
sources.push({ root: process.cwd(), prefix: (0, import_node_path32.join)(".claude", "plans") });
|
|
27526
27541
|
}
|
|
27527
|
-
if (home && (0,
|
|
27542
|
+
if (home && (0, import_node_fs42.existsSync)(homePlansDir)) sources.push({ root: homePlansDir, prefix: "" });
|
|
27528
27543
|
const candidates2 = [];
|
|
27529
27544
|
const seen = /* @__PURE__ */ new Set();
|
|
27530
27545
|
for (const source2 of sources) {
|
|
27531
27546
|
let names2;
|
|
27532
27547
|
try {
|
|
27533
|
-
names2 = (0,
|
|
27548
|
+
names2 = (0, import_node_fs42.readdirSync)(source2.prefix ? (0, import_node_path32.join)(source2.root, source2.prefix) : source2.root);
|
|
27534
27549
|
} catch {
|
|
27535
27550
|
continue;
|
|
27536
27551
|
}
|
|
27537
27552
|
for (const f of names2) {
|
|
27538
27553
|
if (!f.endsWith(".md") || seen.has(f)) continue;
|
|
27539
27554
|
seen.add(f);
|
|
27540
|
-
const relPath = source2.prefix ? (0,
|
|
27555
|
+
const relPath = source2.prefix ? (0, import_node_path32.join)(source2.prefix, f) : f;
|
|
27541
27556
|
const stat3 = statRegularInRoot(source2.root, relPath);
|
|
27542
27557
|
if (!stat3.ok) continue;
|
|
27543
27558
|
candidates2.push({ name: f, root: source2.root, relPath, mtime: stat3.mtimeMs, size: stat3.size });
|
|
@@ -27555,9 +27570,9 @@ function discoverPlans() {
|
|
|
27555
27570
|
function isRealDirectoryChain(root, parts2) {
|
|
27556
27571
|
let current = root;
|
|
27557
27572
|
for (const part of parts2) {
|
|
27558
|
-
current = (0,
|
|
27573
|
+
current = (0, import_node_path32.join)(current, part);
|
|
27559
27574
|
try {
|
|
27560
|
-
if (!(0,
|
|
27575
|
+
if (!(0, import_node_fs42.lstatSync)(current).isDirectory()) return false;
|
|
27561
27576
|
} catch {
|
|
27562
27577
|
return false;
|
|
27563
27578
|
}
|
|
@@ -27572,7 +27587,7 @@ function discoverGuardDocs(rangeFiles2) {
|
|
|
27572
27587
|
if (result.length >= MAX_SPEC_FILES) break;
|
|
27573
27588
|
if (!GUARD_DOC_EXT.test(path)) continue;
|
|
27574
27589
|
if (path.startsWith("/") || path.includes("..")) continue;
|
|
27575
|
-
if (!(0,
|
|
27590
|
+
if (!(0, import_node_fs42.existsSync)(path)) continue;
|
|
27576
27591
|
const opened = openRegularInRoot(process.cwd(), path);
|
|
27577
27592
|
if (!opened.ok) continue;
|
|
27578
27593
|
if (opened.size > MAX_PLAN_FILE_BYTES || totalBytes + opened.size > MAX_TOTAL_SPEC_BYTES) {
|
|
@@ -27758,8 +27773,8 @@ async function mode(run4) {
|
|
|
27758
27773
|
}
|
|
27759
27774
|
|
|
27760
27775
|
// src/lib/fold.ts
|
|
27761
|
-
var
|
|
27762
|
-
var
|
|
27776
|
+
var import_node_fs43 = require("node:fs");
|
|
27777
|
+
var import_node_path33 = require("node:path");
|
|
27763
27778
|
var KNOWN_RECORD_TYPES = /* @__PURE__ */ new Set([
|
|
27764
27779
|
"user",
|
|
27765
27780
|
"assistant",
|
|
@@ -27896,7 +27911,7 @@ function candidateRoots(repoRoot2) {
|
|
|
27896
27911
|
const norm2 = repoRoot2.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
27897
27912
|
const out2 = [norm2];
|
|
27898
27913
|
try {
|
|
27899
|
-
const real =
|
|
27914
|
+
const real = import_node_fs43.realpathSync.native(norm2).replace(/\\/g, "/").replace(/\/+$/, "");
|
|
27900
27915
|
if (real !== norm2) out2.push(real);
|
|
27901
27916
|
} catch {
|
|
27902
27917
|
}
|
|
@@ -27984,31 +27999,31 @@ function fold(transcriptPath, opts = {}) {
|
|
|
27984
27999
|
}
|
|
27985
28000
|
};
|
|
27986
28001
|
try {
|
|
27987
|
-
if (!(0,
|
|
27988
|
-
ingest((0,
|
|
28002
|
+
if (!(0, import_node_fs43.existsSync)(transcriptPath)) return result;
|
|
28003
|
+
ingest((0, import_node_fs43.readFileSync)(transcriptPath, "utf8"), "agent");
|
|
27989
28004
|
result.coverage.complete = true;
|
|
27990
28005
|
} catch {
|
|
27991
28006
|
return result;
|
|
27992
28007
|
}
|
|
27993
28008
|
try {
|
|
27994
|
-
const sidecarDir = (0,
|
|
27995
|
-
(0,
|
|
27996
|
-
(0,
|
|
28009
|
+
const sidecarDir = (0, import_node_path33.join)(
|
|
28010
|
+
(0, import_node_path33.dirname)(transcriptPath),
|
|
28011
|
+
(0, import_node_path33.basename)(transcriptPath).replace(/\.jsonl$/, ""),
|
|
27997
28012
|
"subagents"
|
|
27998
28013
|
);
|
|
27999
|
-
if ((0,
|
|
28014
|
+
if ((0, import_node_fs43.existsSync)(sidecarDir)) {
|
|
28000
28015
|
const maxFiles = opts.maxSidecars ?? 200;
|
|
28001
28016
|
const maxBytes = opts.maxSidecarBytes ?? 16 * 1024 * 1024;
|
|
28002
28017
|
const found = [];
|
|
28003
28018
|
const walk2 = (d, depth) => {
|
|
28004
28019
|
if (depth > 4) return;
|
|
28005
|
-
for (const e of (0,
|
|
28006
|
-
const p = (0,
|
|
28020
|
+
for (const e of (0, import_node_fs43.readdirSync)(d, { withFileTypes: true })) {
|
|
28021
|
+
const p = (0, import_node_path33.join)(d, e.name);
|
|
28007
28022
|
if (e.isDirectory()) {
|
|
28008
28023
|
walk2(p, depth + 1);
|
|
28009
28024
|
} else if (e.name.startsWith("agent-") && e.name.endsWith(".jsonl")) {
|
|
28010
28025
|
try {
|
|
28011
|
-
const st = (0,
|
|
28026
|
+
const st = (0, import_node_fs43.statSync)(p);
|
|
28012
28027
|
found.push({ path: p, size: st.size, mtimeMs: st.mtimeMs });
|
|
28013
28028
|
} catch {
|
|
28014
28029
|
result.coverage.malformed++;
|
|
@@ -28025,7 +28040,7 @@ function fold(transcriptPath, opts = {}) {
|
|
|
28025
28040
|
continue;
|
|
28026
28041
|
}
|
|
28027
28042
|
try {
|
|
28028
|
-
ingest((0,
|
|
28043
|
+
ingest((0, import_node_fs43.readFileSync)(f.path, "utf8"), "subagent");
|
|
28029
28044
|
bytes += f.size;
|
|
28030
28045
|
result.coverage.subagentFiles++;
|
|
28031
28046
|
} catch {
|
|
@@ -28060,7 +28075,7 @@ function fold(transcriptPath, opts = {}) {
|
|
|
28060
28075
|
}
|
|
28061
28076
|
function classifyUnobserved(path) {
|
|
28062
28077
|
try {
|
|
28063
|
-
const st = (0,
|
|
28078
|
+
const st = (0, import_node_fs43.statSync)(path);
|
|
28064
28079
|
if (!st.isFile()) return "unreadable";
|
|
28065
28080
|
} catch {
|
|
28066
28081
|
return "unreadable";
|
|
@@ -28375,20 +28390,20 @@ async function evidence(run4) {
|
|
|
28375
28390
|
}
|
|
28376
28391
|
|
|
28377
28392
|
// src/lib/cache-cleanup.ts
|
|
28378
|
-
var
|
|
28379
|
-
var
|
|
28393
|
+
var import_node_fs44 = require("node:fs");
|
|
28394
|
+
var import_node_path34 = require("node:path");
|
|
28380
28395
|
var CACHE_TTL_DAYS = 7;
|
|
28381
28396
|
function pruneStaleCache() {
|
|
28382
28397
|
try {
|
|
28383
28398
|
const dir = projectPath(CACHE_DIR);
|
|
28384
28399
|
const cutoff = Date.now() - CACHE_TTL_DAYS * 24 * 3600 * 1e3;
|
|
28385
|
-
for (const entry of (0,
|
|
28400
|
+
for (const entry of (0, import_node_fs44.readdirSync)(dir)) {
|
|
28386
28401
|
if (!entry.startsWith("pending-")) continue;
|
|
28387
|
-
const path = (0,
|
|
28402
|
+
const path = (0, import_node_path34.join)(dir, entry);
|
|
28388
28403
|
try {
|
|
28389
|
-
const stat3 = (0,
|
|
28404
|
+
const stat3 = (0, import_node_fs44.statSync)(path);
|
|
28390
28405
|
if (stat3.mtimeMs < cutoff) {
|
|
28391
|
-
(0,
|
|
28406
|
+
(0, import_node_fs44.unlinkSync)(path);
|
|
28392
28407
|
logEvent("cache_entry_pruned", {
|
|
28393
28408
|
path: entry,
|
|
28394
28409
|
age_days: Math.round((Date.now() - stat3.mtimeMs) / 864e5)
|
|
@@ -28402,7 +28417,7 @@ function pruneStaleCache() {
|
|
|
28402
28417
|
}
|
|
28403
28418
|
|
|
28404
28419
|
// src/lib/context-files.ts
|
|
28405
|
-
var
|
|
28420
|
+
var import_node_fs45 = require("node:fs");
|
|
28406
28421
|
var import_node_os7 = require("node:os");
|
|
28407
28422
|
var MAX_CONTEXT_FILES = 10;
|
|
28408
28423
|
var MAX_CONTEXT_FILE_BYTES = 10240;
|
|
@@ -28460,7 +28475,7 @@ function gatherContextFiles(contextPaths, deltaFiles, opts) {
|
|
|
28460
28475
|
continue;
|
|
28461
28476
|
}
|
|
28462
28477
|
try {
|
|
28463
|
-
const content = (0,
|
|
28478
|
+
const content = (0, import_node_fs45.readFileSync)(safePath, "utf8");
|
|
28464
28479
|
const bytes = Buffer.byteLength(content);
|
|
28465
28480
|
if (bytes > MAX_CONTEXT_FILE_BYTES) {
|
|
28466
28481
|
logEvent("context_file_skipped", { path: filePath, reason: "too_large", bytes });
|
|
@@ -28618,8 +28633,8 @@ function languageOf2(path) {
|
|
|
28618
28633
|
}
|
|
28619
28634
|
|
|
28620
28635
|
// src/lib/code/runtime.ts
|
|
28621
|
-
var
|
|
28622
|
-
var
|
|
28636
|
+
var import_node_fs46 = require("node:fs");
|
|
28637
|
+
var import_node_path35 = require("node:path");
|
|
28623
28638
|
var import_web_tree_sitter2 = __toESM2(require_web_tree_sitter2());
|
|
28624
28639
|
|
|
28625
28640
|
// src/lib/code/grammars.json
|
|
@@ -28679,18 +28694,18 @@ var grammars_default = {
|
|
|
28679
28694
|
var MAX_PARSE_BYTES = 512 * 1024;
|
|
28680
28695
|
function grammarCandidates(file, pkg, env = process.env) {
|
|
28681
28696
|
return [
|
|
28682
|
-
...env.VERITY_GRAMMAR_DIR ? [(0,
|
|
28683
|
-
(0,
|
|
28697
|
+
...env.VERITY_GRAMMAR_DIR ? [(0, import_node_path35.join)(env.VERITY_GRAMMAR_DIR, file)] : [],
|
|
28698
|
+
(0, import_node_path35.join)(__dirname, "..", "data", "grammars", file),
|
|
28684
28699
|
// bundled: cli/bin/ → cli/data/grammars/
|
|
28685
|
-
(0,
|
|
28700
|
+
(0, import_node_path35.join)(__dirname, "..", "..", "..", "data", "grammars", file),
|
|
28686
28701
|
// tsx: cli/src/lib/code/ → cli/data/grammars/
|
|
28687
|
-
(0,
|
|
28702
|
+
(0, import_node_path35.join)(__dirname, "..", "..", "..", "node_modules", pkg, file)
|
|
28688
28703
|
// tsx, before a build: the pinned devDependency
|
|
28689
28704
|
];
|
|
28690
28705
|
}
|
|
28691
28706
|
function locateGrammar(id, env = process.env) {
|
|
28692
28707
|
const g = grammars_default[id];
|
|
28693
|
-
return grammarCandidates(g.file, g.package, env).find((p) => (0,
|
|
28708
|
+
return grammarCandidates(g.file, g.package, env).find((p) => (0, import_node_fs46.existsSync)(p)) ?? null;
|
|
28694
28709
|
}
|
|
28695
28710
|
var loading = null;
|
|
28696
28711
|
function loadRuntime(env = process.env) {
|
|
@@ -31019,8 +31034,8 @@ async function repoContext(run4) {
|
|
|
31019
31034
|
|
|
31020
31035
|
// src/lib/seed-runner.ts
|
|
31021
31036
|
var import_promises15 = require("node:fs/promises");
|
|
31022
|
-
var
|
|
31023
|
-
var
|
|
31037
|
+
var import_node_fs47 = require("node:fs");
|
|
31038
|
+
var import_node_path36 = require("node:path");
|
|
31024
31039
|
var import_yaml4 = __toESM2(require_dist());
|
|
31025
31040
|
|
|
31026
31041
|
// src/lib/seed.ts
|
|
@@ -31243,8 +31258,8 @@ function normalizeTitle(title) {
|
|
|
31243
31258
|
async function localSeedTitles(memoryDir3 = MEMORY_DIR) {
|
|
31244
31259
|
const titles = /* @__PURE__ */ new Set();
|
|
31245
31260
|
for (const dir of NODE_DIRS) {
|
|
31246
|
-
const full = (0,
|
|
31247
|
-
if (!(0,
|
|
31261
|
+
const full = (0, import_node_path36.join)(memoryDir3, dir);
|
|
31262
|
+
if (!(0, import_node_fs47.existsSync)(full)) continue;
|
|
31248
31263
|
let files;
|
|
31249
31264
|
try {
|
|
31250
31265
|
files = await (0, import_promises15.readdir)(full);
|
|
@@ -31255,7 +31270,7 @@ async function localSeedTitles(memoryDir3 = MEMORY_DIR) {
|
|
|
31255
31270
|
if (!file.endsWith(".md")) continue;
|
|
31256
31271
|
let content;
|
|
31257
31272
|
try {
|
|
31258
|
-
content = await (0, import_promises15.readFile)((0,
|
|
31273
|
+
content = await (0, import_promises15.readFile)((0, import_node_path36.join)(full, file), "utf-8");
|
|
31259
31274
|
} catch {
|
|
31260
31275
|
continue;
|
|
31261
31276
|
}
|
|
@@ -31326,7 +31341,7 @@ function renderNodeMarkdown(candidate, nodeId, createdAt) {
|
|
|
31326
31341
|
return fm;
|
|
31327
31342
|
}
|
|
31328
31343
|
async function runSeed(opts) {
|
|
31329
|
-
if (!(0,
|
|
31344
|
+
if (!(0, import_node_fs47.existsSync)(STANDARD_FILE)) {
|
|
31330
31345
|
return { created: 0, existing: 0, failed: 0, skipped: "no_standard", candidates: [] };
|
|
31331
31346
|
}
|
|
31332
31347
|
let standardDoc;
|
|
@@ -31338,7 +31353,7 @@ async function runSeed(opts) {
|
|
|
31338
31353
|
}
|
|
31339
31354
|
const knowledgeSpec = standardDoc.knowledge_spec ?? {};
|
|
31340
31355
|
let readmeContent;
|
|
31341
|
-
if ((0,
|
|
31356
|
+
if ((0, import_node_fs47.existsSync)("README.md")) {
|
|
31342
31357
|
try {
|
|
31343
31358
|
readmeContent = await (0, import_promises15.readFile)("README.md", "utf-8");
|
|
31344
31359
|
} catch {
|
|
@@ -31346,7 +31361,7 @@ async function runSeed(opts) {
|
|
|
31346
31361
|
}
|
|
31347
31362
|
let claudeMdContent;
|
|
31348
31363
|
for (const p of ["CLAUDE.md", ".claude/CLAUDE.md"]) {
|
|
31349
|
-
if ((0,
|
|
31364
|
+
if ((0, import_node_fs47.existsSync)(p)) {
|
|
31350
31365
|
try {
|
|
31351
31366
|
claudeMdContent = await (0, import_promises15.readFile)(p, "utf-8");
|
|
31352
31367
|
break;
|
|
@@ -31426,13 +31441,13 @@ async function runSeed(opts) {
|
|
|
31426
31441
|
continue;
|
|
31427
31442
|
}
|
|
31428
31443
|
const deduplicated = res.data.deduplicated === true;
|
|
31429
|
-
if (deduplicated && (0,
|
|
31444
|
+
if (deduplicated && (0, import_node_fs47.existsSync)(targetPath)) {
|
|
31430
31445
|
existing++;
|
|
31431
31446
|
continue;
|
|
31432
31447
|
}
|
|
31433
31448
|
const content = typeof res.data.content === "string" && res.data.content.length > 0 ? res.data.content : renderNodeMarkdown(c, nodeId, createdAt);
|
|
31434
31449
|
try {
|
|
31435
|
-
await (0, import_promises15.mkdir)((0,
|
|
31450
|
+
await (0, import_promises15.mkdir)((0, import_node_path36.dirname)(targetPath), { recursive: true });
|
|
31436
31451
|
await (0, import_promises15.writeFile)(targetPath, content);
|
|
31437
31452
|
if (deduplicated) existing++;
|
|
31438
31453
|
else {
|
|
@@ -31448,8 +31463,8 @@ async function runSeed(opts) {
|
|
|
31448
31463
|
}
|
|
31449
31464
|
|
|
31450
31465
|
// src/commands/analyze/phases/08-memory-manifest.ts
|
|
31451
|
-
var
|
|
31452
|
-
var
|
|
31466
|
+
var import_node_fs48 = require("node:fs");
|
|
31467
|
+
var import_node_path37 = require("node:path");
|
|
31453
31468
|
async function memoryManifest(run4) {
|
|
31454
31469
|
const { globals } = run4;
|
|
31455
31470
|
const { serviceUrl, token } = run4;
|
|
@@ -31459,9 +31474,9 @@ async function memoryManifest(run4) {
|
|
|
31459
31474
|
let autoSeedNotice = null;
|
|
31460
31475
|
try {
|
|
31461
31476
|
await ensureMemoryDir();
|
|
31462
|
-
const seedMarker = (0,
|
|
31463
|
-
const hasStandard = (0,
|
|
31464
|
-
const alreadyTried = (0,
|
|
31477
|
+
const seedMarker = (0, import_node_path37.join)(VERITY_DIR, ".seeded");
|
|
31478
|
+
const hasStandard = (0, import_node_fs48.existsSync)(STANDARD_FILE);
|
|
31479
|
+
const alreadyTried = (0, import_node_fs48.existsSync)(seedMarker);
|
|
31465
31480
|
if (hasStandard && !alreadyTried) {
|
|
31466
31481
|
const preManifest = await buildManifest();
|
|
31467
31482
|
if (preManifest.nodes.length === 0) {
|
|
@@ -31474,7 +31489,7 @@ async function memoryManifest(run4) {
|
|
|
31474
31489
|
dryRun: false
|
|
31475
31490
|
});
|
|
31476
31491
|
if (seedResult.created > 0 || seedResult.existing > 0) {
|
|
31477
|
-
(0,
|
|
31492
|
+
(0, import_node_fs48.writeFileSync)(seedMarker, `${(/* @__PURE__ */ new Date()).toISOString()} created=${seedResult.created} existing=${seedResult.existing}
|
|
31478
31493
|
`);
|
|
31479
31494
|
if (seedResult.created > 0) {
|
|
31480
31495
|
autoSeedNotice = `Seeded ${seedResult.created} knowledge node(s) from your existing Standard (one-time).`;
|
|
@@ -31485,7 +31500,7 @@ async function memoryManifest(run4) {
|
|
|
31485
31500
|
failed: seedResult.failed
|
|
31486
31501
|
});
|
|
31487
31502
|
} else if (seedResult.skipped === "already_seeded") {
|
|
31488
|
-
(0,
|
|
31503
|
+
(0, import_node_fs48.writeFileSync)(seedMarker, `${(/* @__PURE__ */ new Date()).toISOString()} skipped=already_seeded
|
|
31489
31504
|
`);
|
|
31490
31505
|
} else {
|
|
31491
31506
|
logEvent("auto_seed_noop", {
|
|
@@ -31580,7 +31595,7 @@ function computeIncrement(reviewedPaths, hashOf, priorAuthored) {
|
|
|
31580
31595
|
}
|
|
31581
31596
|
|
|
31582
31597
|
// src/commands/analyze/phases/10-working-memory.ts
|
|
31583
|
-
var
|
|
31598
|
+
var import_node_path38 = require("node:path");
|
|
31584
31599
|
async function workingMemory(run4) {
|
|
31585
31600
|
const { opts } = run4;
|
|
31586
31601
|
const { allForReview, baseline, conversation, foldResult, sessionId, token, transcriptPath } = run4;
|
|
@@ -31592,7 +31607,7 @@ async function workingMemory(run4) {
|
|
|
31592
31607
|
const priorState = foldForMarks(memorySession.d);
|
|
31593
31608
|
incrementReport = computeIncrement(
|
|
31594
31609
|
allForReview,
|
|
31595
|
-
(p) => fileHash((0,
|
|
31610
|
+
(p) => fileHash((0, import_node_path38.join)(repoRoot(), p)),
|
|
31596
31611
|
priorState.authored_all.map((a) => ({
|
|
31597
31612
|
path: a.path,
|
|
31598
31613
|
hash_at_last_verdict: a.hash_at_last_verdict
|
|
@@ -31674,7 +31689,7 @@ async function workingMemory(run4) {
|
|
|
31674
31689
|
}
|
|
31675
31690
|
|
|
31676
31691
|
// src/lib/note-budget.ts
|
|
31677
|
-
var
|
|
31692
|
+
var import_node_fs49 = require("node:fs");
|
|
31678
31693
|
var ADVISORY_BUDGET = { PASS: 1, WARN: 2 };
|
|
31679
31694
|
var EPISODE_STALE_SECONDS = 30 * 60;
|
|
31680
31695
|
var FRESH = { delivered: 0, tasksCompleted: 0, ts: 0 };
|
|
@@ -31696,9 +31711,9 @@ function advisoryBudgetSpent(episode, rawDecision) {
|
|
|
31696
31711
|
}
|
|
31697
31712
|
function readAdvisoryEpisode(sessionId) {
|
|
31698
31713
|
const file = scopedFile(ADVISORY_EPISODE_FILE, sessionId);
|
|
31699
|
-
if (!(0,
|
|
31714
|
+
if (!(0, import_node_fs49.existsSync)(file)) return null;
|
|
31700
31715
|
try {
|
|
31701
|
-
const o = JSON.parse((0,
|
|
31716
|
+
const o = JSON.parse((0, import_node_fs49.readFileSync)(file, "utf-8")) ?? {};
|
|
31702
31717
|
const delivered = typeof o.delivered === "number" ? o.delivered : NaN;
|
|
31703
31718
|
if (isNaN(delivered)) return null;
|
|
31704
31719
|
return {
|
|
@@ -31712,8 +31727,8 @@ function readAdvisoryEpisode(sessionId) {
|
|
|
31712
31727
|
}
|
|
31713
31728
|
function writeAdvisoryEpisode(episode, sessionId) {
|
|
31714
31729
|
try {
|
|
31715
|
-
(0,
|
|
31716
|
-
(0,
|
|
31730
|
+
(0, import_node_fs49.mkdirSync)(VERITY_DIR, { recursive: true });
|
|
31731
|
+
(0, import_node_fs49.writeFileSync)(
|
|
31717
31732
|
scopedFile(ADVISORY_EPISODE_FILE, sessionId),
|
|
31718
31733
|
JSON.stringify({ v: 1, ...episode })
|
|
31719
31734
|
);
|
|
@@ -32045,14 +32060,14 @@ async function buildRequest(run4) {
|
|
|
32045
32060
|
}
|
|
32046
32061
|
|
|
32047
32062
|
// src/lib/offline.ts
|
|
32048
|
-
var
|
|
32063
|
+
var import_node_fs50 = require("node:fs");
|
|
32049
32064
|
var import_node_crypto13 = require("node:crypto");
|
|
32050
32065
|
function cacheRequest(body2) {
|
|
32051
32066
|
try {
|
|
32052
|
-
(0,
|
|
32067
|
+
(0, import_node_fs50.mkdirSync)(CACHE_DIR, { recursive: true });
|
|
32053
32068
|
const suffix = (0, import_node_crypto13.randomBytes)(4).toString("hex");
|
|
32054
32069
|
const filename = `pending-${Math.floor(Date.now() / 1e3)}-${suffix}.json`;
|
|
32055
|
-
(0,
|
|
32070
|
+
(0, import_node_fs50.writeFileSync)(`${CACHE_DIR}/${filename}`, JSON.stringify(redactRequest(body2)));
|
|
32056
32071
|
} catch {
|
|
32057
32072
|
}
|
|
32058
32073
|
}
|
|
@@ -32171,8 +32186,8 @@ async function transmit(run4) {
|
|
|
32171
32186
|
}
|
|
32172
32187
|
|
|
32173
32188
|
// src/commands/analyze/phases/13-reconcile.ts
|
|
32174
|
-
var
|
|
32175
|
-
var
|
|
32189
|
+
var import_node_fs51 = require("node:fs");
|
|
32190
|
+
var import_node_path39 = require("node:path");
|
|
32176
32191
|
async function reconcile(run4) {
|
|
32177
32192
|
const { actionSummary, allChanged, analyzable, baseline, baselineSessionId, codeDelta, contentHash, conversation, decision, foldResult, memory: memory2, memorySession, response, reviewable, securityFiles, turnId } = run4;
|
|
32178
32193
|
const sentPaths = codeDelta.files.map((f) => f.path);
|
|
@@ -32201,7 +32216,7 @@ async function reconcile(run4) {
|
|
|
32201
32216
|
const st = foldDossier(memorySession.d);
|
|
32202
32217
|
openElsewhere = openBlockingElsewhere(st.statements, sentPaths, (file, line2) => {
|
|
32203
32218
|
try {
|
|
32204
|
-
const src = (0,
|
|
32219
|
+
const src = (0, import_node_fs51.readFileSync)((0, import_node_path39.join)(repoRoot(), file), "utf8").split("\n");
|
|
32205
32220
|
const at = src[line2 - 1];
|
|
32206
32221
|
return at === void 0 ? null : lineSha(at);
|
|
32207
32222
|
} catch {
|
|
@@ -33023,7 +33038,7 @@ function registerAnalyzeCommand(program2) {
|
|
|
33023
33038
|
var tracing = () => process.env.VERITY_TRACE_PHASES === "1";
|
|
33024
33039
|
async function runAnalyze(opts, globals) {
|
|
33025
33040
|
if (!verityConfigured()) {
|
|
33026
|
-
(0,
|
|
33041
|
+
(0, import_node_fs52.writeSync)(2, '[verity] not set up in this project \u2014 run "verity init" first.\n');
|
|
33027
33042
|
process.exit(0);
|
|
33028
33043
|
}
|
|
33029
33044
|
const run4 = createRun(opts, globals);
|
|
@@ -33044,11 +33059,11 @@ async function runAnalyze(opts, globals) {
|
|
|
33044
33059
|
}
|
|
33045
33060
|
|
|
33046
33061
|
// src/commands/baseline.ts
|
|
33047
|
-
var
|
|
33062
|
+
var import_node_fs54 = require("node:fs");
|
|
33048
33063
|
|
|
33049
33064
|
// src/lib/project-skills.ts
|
|
33050
|
-
var
|
|
33051
|
-
var
|
|
33065
|
+
var import_node_fs53 = require("node:fs");
|
|
33066
|
+
var import_node_path40 = require("node:path");
|
|
33052
33067
|
var PROJECT_SKILL_NAMES = [
|
|
33053
33068
|
"verity-setup",
|
|
33054
33069
|
"verity-analyze",
|
|
@@ -33074,14 +33089,14 @@ var LEGACY_SKILL_NAMES = [
|
|
|
33074
33089
|
var ALL = [...PROJECT_SKILL_NAMES, ...LEGACY_SKILL_NAMES];
|
|
33075
33090
|
function staleProjectSkills() {
|
|
33076
33091
|
const root = projectPath(".claude/skills");
|
|
33077
|
-
if (!(0,
|
|
33078
|
-
return ALL.filter((name2) => (0,
|
|
33092
|
+
if (!(0, import_node_fs53.existsSync)(root)) return [];
|
|
33093
|
+
return ALL.filter((name2) => (0, import_node_fs53.existsSync)((0, import_node_path40.join)(root, name2)));
|
|
33079
33094
|
}
|
|
33080
33095
|
function removeProjectSkills() {
|
|
33081
33096
|
const root = projectPath(".claude/skills");
|
|
33082
33097
|
const removed = [];
|
|
33083
33098
|
for (const name2 of staleProjectSkills()) {
|
|
33084
|
-
(0,
|
|
33099
|
+
(0, import_node_fs53.rmSync)((0, import_node_path40.join)(root, name2), { recursive: true, force: true });
|
|
33085
33100
|
removed.push(name2);
|
|
33086
33101
|
}
|
|
33087
33102
|
return removed;
|
|
@@ -33146,13 +33161,13 @@ function registerBaselineCommands(program2) {
|
|
|
33146
33161
|
let memoryMsg = null;
|
|
33147
33162
|
let memoryAgentLine = null;
|
|
33148
33163
|
const memoryNotice = projectPath(`${VERITY_DIR}/.memory-fence-notice`);
|
|
33149
|
-
if (realStart && !(0,
|
|
33164
|
+
if (realStart && !(0, import_node_fs54.existsSync)(memoryNotice)) {
|
|
33150
33165
|
const trackedGraph = memoryOptOut() ? 0 : committedMemoryFiles().length;
|
|
33151
33166
|
if (trackedGraph > 0) {
|
|
33152
33167
|
memoryMsg = `Verity: this project commits its knowledge base (${trackedGraph} files under .verity/memory/), so Verity's generated notes show up in every diff and pull request. Run \`verity memory untrack\` to keep them on disk but out of git, or \`verity memory track\` to keep committing them on purpose.`;
|
|
33153
33168
|
memoryAgentLine = `This project has ${trackedGraph} knowledge-graph files tracked in git under .verity/memory/. As of Verity 0.32.6 the graph is machine-local by default \u2014 it is rebuilt from the service, and committing it puts generated notes in every pull request. If the user wants that stopped, run \`verity memory untrack\` for them: it keeps every file on disk and stages their removal from the index, so they only need to commit \u2014 and their teammates' working copies will vanish on the next pull and re-sync from the service, which is expected. If they would rather keep committing it, \`verity memory track\` records that and nothing will offer again.`;
|
|
33154
33169
|
try {
|
|
33155
|
-
(0,
|
|
33170
|
+
(0, import_node_fs54.writeFileSync)(memoryNotice, (/* @__PURE__ */ new Date()).toISOString() + "\n");
|
|
33156
33171
|
} catch {
|
|
33157
33172
|
}
|
|
33158
33173
|
}
|
|
@@ -33253,7 +33268,7 @@ function hookSource(value) {
|
|
|
33253
33268
|
}
|
|
33254
33269
|
|
|
33255
33270
|
// src/commands/review.ts
|
|
33256
|
-
var
|
|
33271
|
+
var import_node_fs55 = require("node:fs");
|
|
33257
33272
|
function registerReviewCommand(program2) {
|
|
33258
33273
|
program2.command("review").description("Run on-demand Verity analysis (advisory, never blocks)").requiredOption("--files <paths>", "Comma-separated file list").option("--changed <paths>", "Subset of --files that were modified").option("--intent <text>", "User intent description (max 2000 chars)").option("--specs <paths>", "Comma-separated spec file paths").option("--json", "Output raw JSON response").action(async (opts) => {
|
|
33259
33274
|
const globals = program2.opts();
|
|
@@ -33270,7 +33285,7 @@ async function runReview(opts, globals) {
|
|
|
33270
33285
|
const changedFiles = opts.changed ? opts.changed.split(",").map((f) => f.trim()).filter(Boolean) : allFiles;
|
|
33271
33286
|
const analyzable = filterAnalyzable(allFiles);
|
|
33272
33287
|
const securityFiles = filterSecurity(allFiles);
|
|
33273
|
-
const scannable = Array.from(/* @__PURE__ */ new Set([...analyzable, ...securityFiles])).filter((f) => (0,
|
|
33288
|
+
const scannable = Array.from(/* @__PURE__ */ new Set([...analyzable, ...securityFiles])).filter((f) => (0, import_node_fs55.existsSync)(f) || resolveFile(f) !== null);
|
|
33274
33289
|
const staticResults = runCodacyAnalysisIfAvailable(scannable);
|
|
33275
33290
|
const codeDelta = collectCodeDelta(allFiles);
|
|
33276
33291
|
const tokenResult = await resolveToken(globals.token);
|
|
@@ -33336,8 +33351,8 @@ async function runReview(opts, globals) {
|
|
|
33336
33351
|
}
|
|
33337
33352
|
|
|
33338
33353
|
// src/commands/guard.ts
|
|
33339
|
-
var
|
|
33340
|
-
var
|
|
33354
|
+
var import_node_fs59 = require("node:fs");
|
|
33355
|
+
var import_node_path45 = require("node:path");
|
|
33341
33356
|
|
|
33342
33357
|
// src/lib/terminal-text.ts
|
|
33343
33358
|
var CONTROL = /[\x00-\x08\x0b-\x1f\x7f-\x9f\u061c\u200e\u200f\u2028-\u202e\u2066-\u2069]/g;
|
|
@@ -33445,7 +33460,7 @@ async function runAgentReview(options) {
|
|
|
33445
33460
|
}
|
|
33446
33461
|
|
|
33447
33462
|
// src/lib/prove/auto.ts
|
|
33448
|
-
var
|
|
33463
|
+
var import_node_path44 = require("node:path");
|
|
33449
33464
|
var import_node_crypto18 = require("node:crypto");
|
|
33450
33465
|
|
|
33451
33466
|
// src/lib/prove/signals.ts
|
|
@@ -35167,18 +35182,18 @@ function renderReplay(model, property, r) {
|
|
|
35167
35182
|
// src/lib/prove/runner.ts
|
|
35168
35183
|
var import_node_child_process15 = require("node:child_process");
|
|
35169
35184
|
var import_node_os8 = require("node:os");
|
|
35170
|
-
var
|
|
35185
|
+
var import_node_fs58 = require("node:fs");
|
|
35171
35186
|
var import_node_os9 = require("node:os");
|
|
35172
|
-
var
|
|
35187
|
+
var import_node_path43 = require("node:path");
|
|
35173
35188
|
|
|
35174
35189
|
// src/lib/prove/scaffold.ts
|
|
35175
|
-
var
|
|
35176
|
-
var
|
|
35190
|
+
var import_node_fs57 = require("node:fs");
|
|
35191
|
+
var import_node_path42 = require("node:path");
|
|
35177
35192
|
|
|
35178
35193
|
// src/lib/prove/safe-write.ts
|
|
35179
|
-
var
|
|
35194
|
+
var import_node_fs56 = require("node:fs");
|
|
35180
35195
|
var import_node_crypto14 = require("node:crypto");
|
|
35181
|
-
var
|
|
35196
|
+
var import_node_path41 = require("node:path");
|
|
35182
35197
|
var SafeWriteError = class extends Error {
|
|
35183
35198
|
constructor(reason, path) {
|
|
35184
35199
|
super(`refusing to write ${path}: ${reason}`);
|
|
@@ -35187,10 +35202,10 @@ var SafeWriteError = class extends Error {
|
|
|
35187
35202
|
this.name = "SafeWriteError";
|
|
35188
35203
|
}
|
|
35189
35204
|
};
|
|
35190
|
-
var FLAGS3 =
|
|
35205
|
+
var FLAGS3 = import_node_fs56.constants;
|
|
35191
35206
|
var NOFOLLOW2 = FLAGS3.O_NOFOLLOW ?? 0;
|
|
35192
35207
|
function assertPlainRelative(rel) {
|
|
35193
|
-
if (!rel || (0,
|
|
35208
|
+
if (!rel || (0, import_node_path41.isAbsolute)(rel)) throw new SafeWriteError("bad-path", rel);
|
|
35194
35209
|
for (const part of rel.split(/[\\/]/)) {
|
|
35195
35210
|
if (part === ".." || part === "" || part === ".") throw new SafeWriteError("bad-path", rel);
|
|
35196
35211
|
}
|
|
@@ -35199,34 +35214,34 @@ function ensureDirsNoFollow(root, rel) {
|
|
|
35199
35214
|
const parts2 = rel.split(/[\\/]/);
|
|
35200
35215
|
let cur = root;
|
|
35201
35216
|
for (const part of parts2.slice(0, -1)) {
|
|
35202
|
-
cur = (0,
|
|
35217
|
+
cur = (0, import_node_path41.join)(cur, part);
|
|
35203
35218
|
let st;
|
|
35204
35219
|
try {
|
|
35205
|
-
st = (0,
|
|
35220
|
+
st = (0, import_node_fs56.lstatSync)(cur);
|
|
35206
35221
|
} catch {
|
|
35207
|
-
(0,
|
|
35222
|
+
(0, import_node_fs56.mkdirSync)(cur);
|
|
35208
35223
|
continue;
|
|
35209
35224
|
}
|
|
35210
35225
|
if (st.isSymbolicLink()) throw new SafeWriteError("symlink", cur);
|
|
35211
35226
|
if (!st.isDirectory()) throw new SafeWriteError("not-regular", cur);
|
|
35212
35227
|
}
|
|
35213
|
-
return (0,
|
|
35228
|
+
return (0, import_node_path41.join)(root, rel);
|
|
35214
35229
|
}
|
|
35215
35230
|
function insideRoot(realRoot, realPath) {
|
|
35216
|
-
return realPath === realRoot || realPath.startsWith(realRoot.endsWith(
|
|
35231
|
+
return realPath === realRoot || realPath.startsWith(realRoot.endsWith(import_node_path41.sep) ? realRoot : realRoot + import_node_path41.sep);
|
|
35217
35232
|
}
|
|
35218
35233
|
function removeQuietly(path) {
|
|
35219
35234
|
try {
|
|
35220
|
-
(0,
|
|
35235
|
+
(0, import_node_fs56.unlinkSync)(path);
|
|
35221
35236
|
} catch {
|
|
35222
35237
|
}
|
|
35223
35238
|
}
|
|
35224
35239
|
function writeFileInRootNoFollow(root, rel, content) {
|
|
35225
35240
|
assertPlainRelative(rel);
|
|
35226
35241
|
const dest = ensureDirsNoFollow(root, rel);
|
|
35227
|
-
const dir = (0,
|
|
35242
|
+
const dir = (0, import_node_path41.dirname)(dest);
|
|
35228
35243
|
try {
|
|
35229
|
-
const st = (0,
|
|
35244
|
+
const st = (0, import_node_fs56.lstatSync)(dest);
|
|
35230
35245
|
if (st.isSymbolicLink()) throw new SafeWriteError("symlink", dest);
|
|
35231
35246
|
if (!st.isFile()) throw new SafeWriteError("not-regular", dest);
|
|
35232
35247
|
} catch (err2) {
|
|
@@ -35234,41 +35249,41 @@ function writeFileInRootNoFollow(root, rel, content) {
|
|
|
35234
35249
|
}
|
|
35235
35250
|
let realRoot;
|
|
35236
35251
|
try {
|
|
35237
|
-
realRoot = (0,
|
|
35252
|
+
realRoot = (0, import_node_fs56.realpathSync)(root);
|
|
35238
35253
|
} catch {
|
|
35239
35254
|
throw new SafeWriteError("unwritable", root);
|
|
35240
35255
|
}
|
|
35241
|
-
const tmp = (0,
|
|
35256
|
+
const tmp = (0, import_node_path41.join)(dir, `.${(0, import_node_path41.basename)(dest)}.${(0, import_node_crypto14.randomBytes)(6).toString("hex")}.tmp`);
|
|
35242
35257
|
let fd;
|
|
35243
35258
|
try {
|
|
35244
|
-
fd = (0,
|
|
35259
|
+
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);
|
|
35245
35260
|
} catch {
|
|
35246
35261
|
throw new SafeWriteError("unwritable", tmp);
|
|
35247
35262
|
}
|
|
35248
35263
|
try {
|
|
35249
|
-
const opened = (0,
|
|
35264
|
+
const opened = (0, import_node_fs56.fstatSync)(fd, { bigint: true });
|
|
35250
35265
|
let realTmp;
|
|
35251
35266
|
try {
|
|
35252
|
-
realTmp = (0,
|
|
35267
|
+
realTmp = (0, import_node_fs56.realpathSync)(tmp);
|
|
35253
35268
|
} catch {
|
|
35254
35269
|
throw new SafeWriteError("escaped", tmp);
|
|
35255
35270
|
}
|
|
35256
|
-
const there = (0,
|
|
35271
|
+
const there = (0, import_node_fs56.lstatSync)(realTmp, { bigint: true });
|
|
35257
35272
|
if (!opened.isFile() || there.ino !== opened.ino || there.dev !== opened.dev || !insideRoot(realRoot, realTmp)) {
|
|
35258
35273
|
throw new SafeWriteError("escaped", tmp);
|
|
35259
35274
|
}
|
|
35260
35275
|
const buf = Buffer.from(content, "utf-8");
|
|
35261
35276
|
let off = 0;
|
|
35262
|
-
while (off < buf.length) off += (0,
|
|
35277
|
+
while (off < buf.length) off += (0, import_node_fs56.writeSync)(fd, buf, off, buf.length - off);
|
|
35263
35278
|
} catch (err2) {
|
|
35264
|
-
(0,
|
|
35279
|
+
(0, import_node_fs56.closeSync)(fd);
|
|
35265
35280
|
removeQuietly(tmp);
|
|
35266
35281
|
throw err2 instanceof SafeWriteError ? err2 : new SafeWriteError("unwritable", tmp);
|
|
35267
35282
|
}
|
|
35268
|
-
(0,
|
|
35283
|
+
(0, import_node_fs56.closeSync)(fd);
|
|
35269
35284
|
try {
|
|
35270
|
-
if (!insideRoot(realRoot, (0,
|
|
35271
|
-
(0,
|
|
35285
|
+
if (!insideRoot(realRoot, (0, import_node_fs56.realpathSync)(dir)) || (0, import_node_fs56.lstatSync)(dir).isSymbolicLink()) throw new SafeWriteError("escaped", dir);
|
|
35286
|
+
(0, import_node_fs56.renameSync)(tmp, dest);
|
|
35272
35287
|
} catch (err2) {
|
|
35273
35288
|
removeQuietly(tmp);
|
|
35274
35289
|
throw err2 instanceof SafeWriteError ? err2 : new SafeWriteError("unwritable", dest);
|
|
@@ -35282,9 +35297,9 @@ function pathHasNoLink(root, rel) {
|
|
|
35282
35297
|
}
|
|
35283
35298
|
let cur = root;
|
|
35284
35299
|
for (const part of rel.split(/[\\/]/)) {
|
|
35285
|
-
cur = cur +
|
|
35300
|
+
cur = cur + import_node_path41.sep + part;
|
|
35286
35301
|
try {
|
|
35287
|
-
if ((0,
|
|
35302
|
+
if ((0, import_node_fs56.lstatSync)(cur).isSymbolicLink()) return false;
|
|
35288
35303
|
} catch {
|
|
35289
35304
|
return true;
|
|
35290
35305
|
}
|
|
@@ -35594,20 +35609,20 @@ This directory is machine-local and gitignored (see ../.gitignore). Models are
|
|
|
35594
35609
|
never committed; what reaches the team is the bug report and the fix.
|
|
35595
35610
|
`;
|
|
35596
35611
|
function scaffoldProofs(root) {
|
|
35597
|
-
const proofsDir = (0,
|
|
35612
|
+
const proofsDir = (0, import_node_path42.join)(root, PROOFS_DIR);
|
|
35598
35613
|
const written = [];
|
|
35599
35614
|
const kept = [];
|
|
35600
35615
|
for (const stray of ["lakefile.lean"]) {
|
|
35601
35616
|
const rel = `${PROOFS_DIR}/${stray}`;
|
|
35602
|
-
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0,
|
|
35617
|
+
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path42.join)(root, rel));
|
|
35603
35618
|
try {
|
|
35604
|
-
(0,
|
|
35619
|
+
(0, import_node_fs57.rmSync)((0, import_node_path42.join)(root, rel), { force: true });
|
|
35605
35620
|
} catch {
|
|
35606
35621
|
}
|
|
35607
35622
|
}
|
|
35608
35623
|
for (const f of PROOFS_TEMPLATE_FILES) {
|
|
35609
35624
|
const rel = `${PROOFS_DIR}/${f.path}`;
|
|
35610
|
-
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0,
|
|
35625
|
+
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path42.join)(root, rel));
|
|
35611
35626
|
const current = readRegularFileInRoot(root, rel, 4 * 1024 * 1024);
|
|
35612
35627
|
if (current.ok && current.content === f.content) {
|
|
35613
35628
|
kept.push(rel);
|
|
@@ -35620,8 +35635,8 @@ function scaffoldProofs(root) {
|
|
|
35620
35635
|
[`${PROOFS_DIR}/.gitignore`, LOCAL_GITIGNORE],
|
|
35621
35636
|
[`${MODELS_DIR}/README.md`, MODELS_README]
|
|
35622
35637
|
]) {
|
|
35623
|
-
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0,
|
|
35624
|
-
if (existsNoFollow((0,
|
|
35638
|
+
if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path42.join)(root, rel));
|
|
35639
|
+
if (existsNoFollow((0, import_node_path42.join)(root, rel))) {
|
|
35625
35640
|
kept.push(rel);
|
|
35626
35641
|
continue;
|
|
35627
35642
|
}
|
|
@@ -35632,7 +35647,7 @@ function scaffoldProofs(root) {
|
|
|
35632
35647
|
}
|
|
35633
35648
|
function existsNoFollow(abs) {
|
|
35634
35649
|
try {
|
|
35635
|
-
(0,
|
|
35650
|
+
(0, import_node_fs57.lstatSync)(abs);
|
|
35636
35651
|
return true;
|
|
35637
35652
|
} catch {
|
|
35638
35653
|
return false;
|
|
@@ -35890,16 +35905,16 @@ function renderReport(r) {
|
|
|
35890
35905
|
|
|
35891
35906
|
// src/lib/prove/runner.ts
|
|
35892
35907
|
function verityLeanHome(env = process.env) {
|
|
35893
|
-
return env.VERITY_LEAN_HOME ?? (0,
|
|
35908
|
+
return env.VERITY_LEAN_HOME ?? (0, import_node_path43.join)(env.HOME ?? (0, import_node_os9.homedir)(), ".verity", "lean");
|
|
35894
35909
|
}
|
|
35895
35910
|
function findToolchain(env = process.env) {
|
|
35896
|
-
const managedBin = (0,
|
|
35897
|
-
const elanBin = (0,
|
|
35898
|
-
const path = [managedBin, elanBin, env.PATH ?? ""].filter(Boolean).join(
|
|
35911
|
+
const managedBin = (0, import_node_path43.join)(verityLeanHome(env), LEAN_TOOLCHAIN.replace(/^leanprover\/lean4:/, ""), "bin");
|
|
35912
|
+
const elanBin = (0, import_node_path43.join)(env.HOME ?? (0, import_node_os9.homedir)(), ".elan", "bin");
|
|
35913
|
+
const path = [managedBin, elanBin, env.PATH ?? ""].filter(Boolean).join(import_node_path43.delimiter);
|
|
35899
35914
|
const merged = { ...env, PATH: path, ELAN_TOOLCHAIN: env.ELAN_TOOLCHAIN ?? LEAN_TOOLCHAIN };
|
|
35900
|
-
const elanHas = (0,
|
|
35915
|
+
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(":", "---")));
|
|
35901
35916
|
const exe = process.platform === "win32" ? "lake.exe" : "lake";
|
|
35902
|
-
const candidates2 = [(0,
|
|
35917
|
+
const candidates2 = [(0, import_node_path43.join)(managedBin, exe), ...elanHas ? [(0, import_node_path43.join)(elanBin, exe)] : [], exe];
|
|
35903
35918
|
for (const candidate of candidates2) {
|
|
35904
35919
|
try {
|
|
35905
35920
|
(0, import_node_child_process15.execFileSync)(candidate, ["--version"], { env: merged, stdio: ["ignore", "pipe", "pipe"], timeout: 1e4 });
|
|
@@ -35974,53 +35989,80 @@ function runAsync(tc, cwd, args2, timeoutMs) {
|
|
|
35974
35989
|
}
|
|
35975
35990
|
var DEFAULT_BUILD_TIMEOUT_MS = 10 * 6e4;
|
|
35976
35991
|
var DEFAULT_CHECK_TIMEOUT_MS = 12e4;
|
|
35992
|
+
function proofsWorkspaceProblem(root) {
|
|
35993
|
+
for (const rel of [".verity", PROOFS_DIR, `${PROOFS_DIR}/.lake`]) {
|
|
35994
|
+
let st;
|
|
35995
|
+
try {
|
|
35996
|
+
st = (0, import_node_fs58.lstatSync)((0, import_node_path43.join)(root, rel));
|
|
35997
|
+
} catch {
|
|
35998
|
+
break;
|
|
35999
|
+
}
|
|
36000
|
+
if (st.isSymbolicLink()) return `${rel} is a symlink; Lean is not run through it`;
|
|
36001
|
+
}
|
|
36002
|
+
const r = runGitSync(root, ["ls-files", "-z", "--", PROOFS_DIR], { timeoutMs: 5e3 });
|
|
36003
|
+
if (!r.ok) return `could not confirm with git that ${PROOFS_DIR} holds no committed files; Lean is not run`;
|
|
36004
|
+
const tracked = r.stdout.split("\0").filter(Boolean);
|
|
36005
|
+
if (tracked.length > 0) {
|
|
36006
|
+
return `${tracked.length} file(s) under ${PROOFS_DIR} are tracked in git (e.g. ${tracked[0]}); Lean is not run on a workspace the repository supplies \u2014 untrack them with: git rm -r --cached ${PROOFS_DIR}`;
|
|
36007
|
+
}
|
|
36008
|
+
return null;
|
|
36009
|
+
}
|
|
36010
|
+
function refused(problem) {
|
|
36011
|
+
return { ok: false, stdout: "", stderr: problem, durationMs: 0, timedOut: false };
|
|
36012
|
+
}
|
|
35977
36013
|
function buildLibrary(tc, root, timeoutMs = DEFAULT_BUILD_TIMEOUT_MS) {
|
|
35978
|
-
|
|
36014
|
+
const problem = proofsWorkspaceProblem(root);
|
|
36015
|
+
if (problem) return refused(problem);
|
|
36016
|
+
return run2(tc, (0, import_node_path43.join)(root, PROOFS_DIR), ["build"], timeoutMs);
|
|
35979
36017
|
}
|
|
35980
|
-
function buildLibraryAsync(tc, root, timeoutMs = DEFAULT_BUILD_TIMEOUT_MS) {
|
|
35981
|
-
|
|
36018
|
+
async function buildLibraryAsync(tc, root, timeoutMs = DEFAULT_BUILD_TIMEOUT_MS) {
|
|
36019
|
+
const problem = proofsWorkspaceProblem(root);
|
|
36020
|
+
if (problem) return refused(problem);
|
|
36021
|
+
return runAsync(tc, (0, import_node_path43.join)(root, PROOFS_DIR), ["build"], timeoutMs);
|
|
35982
36022
|
}
|
|
35983
36023
|
function isModelInRoot(modelsAbs, rel) {
|
|
35984
|
-
if (!rel.endsWith(".lean") || (0,
|
|
36024
|
+
if (!rel.endsWith(".lean") || (0, import_node_path43.isAbsolute)(rel) || rel.startsWith("..")) return false;
|
|
35985
36025
|
return statRegularInRoot(modelsAbs, rel).ok;
|
|
35986
36026
|
}
|
|
35987
36027
|
function resolveModelFile(root, arg) {
|
|
35988
|
-
const modelsAbs = (0,
|
|
35989
|
-
const asPath = (0,
|
|
36028
|
+
const modelsAbs = (0, import_node_path43.join)(root, MODELS_DIR);
|
|
36029
|
+
const asPath = (0, import_node_path43.relative)(modelsAbs, (0, import_node_path43.isAbsolute)(arg) ? arg : (0, import_node_path43.resolve)(root, arg));
|
|
35990
36030
|
const candidates2 = arg.includes("/") || arg.includes("\\") ? [asPath] : [arg, `${arg}.lean`];
|
|
35991
36031
|
for (const rel of candidates2) {
|
|
35992
|
-
if (isModelInRoot(modelsAbs, rel)) return (0,
|
|
36032
|
+
if (isModelInRoot(modelsAbs, rel)) return (0, import_node_path43.join)(modelsAbs, rel);
|
|
35993
36033
|
}
|
|
35994
36034
|
return null;
|
|
35995
36035
|
}
|
|
35996
36036
|
function listModelFiles(root) {
|
|
35997
|
-
const modelsAbs = (0,
|
|
35998
|
-
if (!(0,
|
|
35999
|
-
return (0,
|
|
36037
|
+
const modelsAbs = (0, import_node_path43.join)(root, MODELS_DIR);
|
|
36038
|
+
if (!(0, import_node_fs58.existsSync)(modelsAbs)) return [];
|
|
36039
|
+
return (0, import_node_fs58.readdirSync)(modelsAbs).filter((f) => isModelInRoot(modelsAbs, f)).sort().map((f) => (0, import_node_path43.join)(modelsAbs, f));
|
|
36000
36040
|
}
|
|
36001
36041
|
function trimDiagnostics(text) {
|
|
36002
36042
|
return text.split("\n").filter((l) => !l.startsWith("trace:")).join("\n").trim().slice(0, 4e3);
|
|
36003
36043
|
}
|
|
36004
36044
|
function checkModel(tc, root, modelFile, opts = {}) {
|
|
36005
|
-
const proofsAbs = (0,
|
|
36006
|
-
const rel = (0,
|
|
36007
|
-
const
|
|
36045
|
+
const proofsAbs = (0, import_node_path43.join)(root, PROOFS_DIR);
|
|
36046
|
+
const rel = (0, import_node_path43.relative)(proofsAbs, modelFile);
|
|
36047
|
+
const problem = proofsWorkspaceProblem(root);
|
|
36048
|
+
const res = problem ? refused(problem) : run2(tc, proofsAbs, ["env", "lean", rel], opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
|
|
36008
36049
|
return toReport(res, root, modelFile, opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
|
|
36009
36050
|
}
|
|
36010
36051
|
async function checkModelAsync(tc, root, modelFile, opts = {}) {
|
|
36011
|
-
const proofsAbs = (0,
|
|
36012
|
-
const rel = (0,
|
|
36013
|
-
const
|
|
36052
|
+
const proofsAbs = (0, import_node_path43.join)(root, PROOFS_DIR);
|
|
36053
|
+
const rel = (0, import_node_path43.relative)(proofsAbs, modelFile);
|
|
36054
|
+
const problem = proofsWorkspaceProblem(root);
|
|
36055
|
+
const res = problem ? refused(problem) : await runAsync(tc, proofsAbs, ["env", "lean", rel], opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
|
|
36014
36056
|
return toReport(res, root, modelFile, opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
|
|
36015
36057
|
}
|
|
36016
36058
|
function toReport(res, root, modelFile, timeoutMs) {
|
|
36017
36059
|
const parsed = parseVerityLines(res.stdout);
|
|
36018
36060
|
const combined = `${res.stdout}
|
|
36019
36061
|
${res.stderr}`;
|
|
36020
|
-
const name2 = parsed.header?.model ?? (0,
|
|
36062
|
+
const name2 = parsed.header?.model ?? (0, import_node_path43.basename)(modelFile, ".lean");
|
|
36021
36063
|
const report = {
|
|
36022
36064
|
model: name2,
|
|
36023
|
-
file: (0,
|
|
36065
|
+
file: (0, import_node_path43.relative)(root, modelFile),
|
|
36024
36066
|
ok: res.ok,
|
|
36025
36067
|
header: parsed.header,
|
|
36026
36068
|
properties: parsed.properties,
|
|
@@ -36274,20 +36316,28 @@ function isEligible(s, largePush) {
|
|
|
36274
36316
|
function intersects(a, ranges) {
|
|
36275
36317
|
return ranges.some((b) => a.from <= b.to && b.from <= a.to);
|
|
36276
36318
|
}
|
|
36319
|
+
function isLocalState(root, rel) {
|
|
36320
|
+
return repoControlled(root, rel) === null;
|
|
36321
|
+
}
|
|
36322
|
+
function nonNegative(v) {
|
|
36323
|
+
return typeof v === "number" && Number.isFinite(v) && v > 0 ? v : 0;
|
|
36324
|
+
}
|
|
36277
36325
|
function readLedger(root) {
|
|
36278
36326
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
36279
36327
|
const empty = { day: today, models: 0, costUsd: 0 };
|
|
36328
|
+
if (!isLocalState(root, AUTO_LEDGER)) return empty;
|
|
36280
36329
|
const read2 = readRegularFileInRoot(root, AUTO_LEDGER, 4096);
|
|
36281
36330
|
if (!read2.ok) return empty;
|
|
36282
36331
|
try {
|
|
36283
36332
|
const o = JSON.parse(read2.content);
|
|
36284
36333
|
if (o.day !== today || typeof o.models !== "number") return empty;
|
|
36285
|
-
return { day: today, models: o.models, costUsd:
|
|
36334
|
+
return { day: today, models: nonNegative(o.models), costUsd: nonNegative(o.costUsd) };
|
|
36286
36335
|
} catch {
|
|
36287
36336
|
return empty;
|
|
36288
36337
|
}
|
|
36289
36338
|
}
|
|
36290
36339
|
function writeLedger(root, l) {
|
|
36340
|
+
if (!isLocalState(root, AUTO_LEDGER)) return;
|
|
36291
36341
|
try {
|
|
36292
36342
|
writeFileInRootNoFollow(root, AUTO_LEDGER, JSON.stringify(l) + "\n");
|
|
36293
36343
|
} catch {
|
|
@@ -36300,6 +36350,7 @@ function addLedgerCost(root, usd) {
|
|
|
36300
36350
|
}
|
|
36301
36351
|
var FINDINGS_FILE = `${PROOFS_DIR}/.results/.findings.json`;
|
|
36302
36352
|
function readPersistedFindings(root) {
|
|
36353
|
+
if (!isLocalState(root, FINDINGS_FILE)) return [];
|
|
36303
36354
|
const read2 = readRegularFileInRoot(root, FINDINGS_FILE, 256 * 1024);
|
|
36304
36355
|
if (!read2.ok) return [];
|
|
36305
36356
|
try {
|
|
@@ -36323,6 +36374,7 @@ function waiveFormalFindings(root, file, reason) {
|
|
|
36323
36374
|
return n;
|
|
36324
36375
|
}
|
|
36325
36376
|
function writePersistedFindings(root, findings) {
|
|
36377
|
+
if (!isLocalState(root, FINDINGS_FILE)) return;
|
|
36326
36378
|
try {
|
|
36327
36379
|
writeFileInRootNoFollow(root, FINDINGS_FILE, JSON.stringify({ findings: findings.slice(0, 50) }, null, 2) + "\n");
|
|
36328
36380
|
} catch {
|
|
@@ -36597,7 +36649,7 @@ async function runFormalPhase(input) {
|
|
|
36597
36649
|
modelName = gen.name;
|
|
36598
36650
|
const rel = `${AUTO_MODELS_DIR}/${gen.name}.lean`;
|
|
36599
36651
|
writeFileInRootNoFollow(root, rel, gen.source);
|
|
36600
|
-
const abs = resolveModelFile(root, rel) ?? (0,
|
|
36652
|
+
const abs = resolveModelFile(root, rel) ?? (0, import_node_path44.join)(root, rel);
|
|
36601
36653
|
progress.model = { name: gen.name, file: rel, rounds: round };
|
|
36602
36654
|
progress.step = "check";
|
|
36603
36655
|
report = await deps.check(root, abs);
|
|
@@ -36719,7 +36771,7 @@ async function runFormalPhase(input) {
|
|
|
36719
36771
|
return done({
|
|
36720
36772
|
status: "checked",
|
|
36721
36773
|
target,
|
|
36722
|
-
model: { name: modelName, file: (0,
|
|
36774
|
+
model: { name: modelName, file: (0, import_node_path44.relative)(root, (0, import_node_path44.join)(root, modelFile)), rounds },
|
|
36723
36775
|
properties: report.properties,
|
|
36724
36776
|
findings
|
|
36725
36777
|
});
|
|
@@ -36782,7 +36834,7 @@ async function generateAndCheck(root, req, opts) {
|
|
|
36782
36834
|
}
|
|
36783
36835
|
const rel = `${dir}/${gen.name}.lean`;
|
|
36784
36836
|
writeFileInRootNoFollow(root, rel, gen.source);
|
|
36785
|
-
const abs = resolveModelFile(root, rel) ?? (0,
|
|
36837
|
+
const abs = resolveModelFile(root, rel) ?? (0, import_node_path44.join)(root, rel);
|
|
36786
36838
|
const report = await opts.deps.check(root, abs);
|
|
36787
36839
|
const abstracts = report.header?.abstracts ?? [];
|
|
36788
36840
|
const stray = abstracts.find((a) => !headerFiles.has(a.file)) ?? (abstracts[0] && abstracts[0].file !== req.file ? abstracts[0] : void 0);
|
|
@@ -36820,6 +36872,8 @@ async function prepareFormalPhase(root, env = process.env, auth2, readSource, co
|
|
|
36820
36872
|
const apiKey = direct ? env.OPENAI_API_KEY : void 0;
|
|
36821
36873
|
const toolchain = findToolchain(env);
|
|
36822
36874
|
if (!toolchain) return { ok: false, skip: "no-toolchain" };
|
|
36875
|
+
const untrusted = proofsWorkspaceProblem(root);
|
|
36876
|
+
if (untrusted) return { ok: false, skip: "workspace-untrusted", detail: untrusted.slice(0, 200) };
|
|
36823
36877
|
try {
|
|
36824
36878
|
scaffoldProofs(root);
|
|
36825
36879
|
} catch (err2) {
|
|
@@ -36909,7 +36963,7 @@ var EXCERPT_SOURCE_MAX_BYTES = 2 * 1024 * 1024;
|
|
|
36909
36963
|
var WRITERS_BUDGET_MS = 1500;
|
|
36910
36964
|
var EXCERPT_MAX_LINES2 = 30;
|
|
36911
36965
|
var GUARD_BLOCK_CAP = 2;
|
|
36912
|
-
var GUARD_ITER_FILE = (0,
|
|
36966
|
+
var GUARD_ITER_FILE = (0, import_node_path45.join)(VERITY_DIR, ".guard-iteration");
|
|
36913
36967
|
function readPreToolUseStdin() {
|
|
36914
36968
|
const empty = { command: "", cwd: null, sessionId: null };
|
|
36915
36969
|
return new Promise((resolve8) => {
|
|
@@ -36954,7 +37008,7 @@ function readPreToolUseStdin() {
|
|
|
36954
37008
|
}
|
|
36955
37009
|
function readIterMap() {
|
|
36956
37010
|
try {
|
|
36957
|
-
const raw = JSON.parse((0,
|
|
37011
|
+
const raw = JSON.parse((0, import_node_fs59.readFileSync)(GUARD_ITER_FILE, "utf-8"));
|
|
36958
37012
|
if (raw && typeof raw === "object") {
|
|
36959
37013
|
if (typeof raw.moment === "string" && typeof raw.count === "number") {
|
|
36960
37014
|
return { [raw.moment]: raw.count };
|
|
@@ -36974,10 +37028,10 @@ function readIter(moment) {
|
|
|
36974
37028
|
}
|
|
36975
37029
|
function writeIter(moment, count) {
|
|
36976
37030
|
try {
|
|
36977
|
-
(0,
|
|
37031
|
+
(0, import_node_fs59.mkdirSync)(VERITY_DIR, { recursive: true });
|
|
36978
37032
|
const map = readIterMap();
|
|
36979
37033
|
map[moment] = count;
|
|
36980
|
-
(0,
|
|
37034
|
+
(0, import_node_fs59.writeFileSync)(GUARD_ITER_FILE, JSON.stringify(map));
|
|
36981
37035
|
} catch {
|
|
36982
37036
|
}
|
|
36983
37037
|
}
|
|
@@ -36987,10 +37041,10 @@ function resetIter(moment) {
|
|
|
36987
37041
|
if (!(moment in map)) return;
|
|
36988
37042
|
delete map[moment];
|
|
36989
37043
|
if (Object.keys(map).length === 0) {
|
|
36990
|
-
if ((0,
|
|
37044
|
+
if ((0, import_node_fs59.existsSync)(GUARD_ITER_FILE)) (0, import_node_fs59.unlinkSync)(GUARD_ITER_FILE);
|
|
36991
37045
|
} else {
|
|
36992
|
-
(0,
|
|
36993
|
-
(0,
|
|
37046
|
+
(0, import_node_fs59.mkdirSync)(VERITY_DIR, { recursive: true });
|
|
37047
|
+
(0, import_node_fs59.writeFileSync)(GUARD_ITER_FILE, JSON.stringify(map));
|
|
36994
37048
|
}
|
|
36995
37049
|
} catch {
|
|
36996
37050
|
}
|
|
@@ -37060,7 +37114,7 @@ function hasBlockingFinding(response, sentFiles) {
|
|
|
37060
37114
|
function buildGuardRequest(moment, files, codeDelta, iter, sessionId, statedIntent, coverageTelemetry) {
|
|
37061
37115
|
const analyzable = filterAnalyzable(files);
|
|
37062
37116
|
const securityFiles = filterSecurity(files);
|
|
37063
|
-
const scannable = Array.from(/* @__PURE__ */ new Set([...analyzable, ...securityFiles])).map((f) => (0,
|
|
37117
|
+
const scannable = Array.from(/* @__PURE__ */ new Set([...analyzable, ...securityFiles])).map((f) => (0, import_node_fs59.existsSync)(f) ? f : resolveFile(f)).filter((f) => f !== null);
|
|
37064
37118
|
const staticResults = runCodacyAnalysisIfAvailable(scannable);
|
|
37065
37119
|
const trigger = moment === "pre-commit" ? "hook:pre-commit" : "hook:pre-push";
|
|
37066
37120
|
const requestBody = {
|
|
@@ -37680,7 +37734,7 @@ function registerIgnoreCommand(program2) {
|
|
|
37680
37734
|
|
|
37681
37735
|
// src/commands/waive.ts
|
|
37682
37736
|
var import_node_crypto19 = require("node:crypto");
|
|
37683
|
-
var
|
|
37737
|
+
var import_node_fs60 = require("node:fs");
|
|
37684
37738
|
function registerWaiveCommand(program2) {
|
|
37685
37739
|
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) => {
|
|
37686
37740
|
const globals = program2.opts();
|
|
@@ -37709,7 +37763,7 @@ function registerWaiveCommand(program2) {
|
|
|
37709
37763
|
if (opts.file) {
|
|
37710
37764
|
body2.file = opts.file;
|
|
37711
37765
|
try {
|
|
37712
|
-
body2.file_sha256 = (0, import_node_crypto19.createHash)("sha256").update((0,
|
|
37766
|
+
body2.file_sha256 = (0, import_node_crypto19.createHash)("sha256").update((0, import_node_fs60.readFileSync)(opts.file)).digest("hex");
|
|
37713
37767
|
} catch {
|
|
37714
37768
|
printError(`Cannot read ${opts.file} \u2014 run from the repo root, or omit --file to waive by pattern.`);
|
|
37715
37769
|
process.exit(1);
|
|
@@ -37734,10 +37788,10 @@ function registerWaiveCommand(program2) {
|
|
|
37734
37788
|
}
|
|
37735
37789
|
|
|
37736
37790
|
// src/commands/init.ts
|
|
37737
|
-
var
|
|
37791
|
+
var import_node_fs65 = require("node:fs");
|
|
37738
37792
|
var import_promises20 = require("node:fs/promises");
|
|
37739
37793
|
var import_yaml6 = __toESM2(require_dist());
|
|
37740
|
-
var
|
|
37794
|
+
var import_node_path49 = require("node:path");
|
|
37741
37795
|
var import_node_child_process19 = require("node:child_process");
|
|
37742
37796
|
|
|
37743
37797
|
// src/lib/banner.ts
|
|
@@ -37816,7 +37870,7 @@ function printPhase(n, of, title, subtitle) {
|
|
|
37816
37870
|
}
|
|
37817
37871
|
|
|
37818
37872
|
// src/commands/doctor.ts
|
|
37819
|
-
var
|
|
37873
|
+
var import_node_fs61 = require("node:fs");
|
|
37820
37874
|
|
|
37821
37875
|
// src/lib/prereqs.ts
|
|
37822
37876
|
var import_node_child_process16 = require("node:child_process");
|
|
@@ -38024,11 +38078,11 @@ async function buildReport() {
|
|
|
38024
38078
|
const hooks = wiring.status;
|
|
38025
38079
|
const provenance = cliProvenance();
|
|
38026
38080
|
const telemetry = await checkTelemetry();
|
|
38027
|
-
const hasConfig = (0,
|
|
38081
|
+
const hasConfig = (0, import_node_fs61.existsSync)(projectPath(CODACY_CONFIG_FILE));
|
|
38028
38082
|
const artifacts = {
|
|
38029
|
-
standard: (0,
|
|
38083
|
+
standard: (0, import_node_fs61.existsSync)(projectPath(STANDARD_FILE)),
|
|
38030
38084
|
analysisConfig: hasConfig,
|
|
38031
|
-
verityMd: (0,
|
|
38085
|
+
verityMd: (0, import_node_fs61.existsSync)(projectPath(VERITY_MD_FILE)),
|
|
38032
38086
|
analysisConfigIds: hasConfig ? validatePatternIds().status : "absent"
|
|
38033
38087
|
};
|
|
38034
38088
|
const next = [];
|
|
@@ -38187,8 +38241,8 @@ function registerDoctorCommand(program2) {
|
|
|
38187
38241
|
}
|
|
38188
38242
|
|
|
38189
38243
|
// src/commands/migrate.ts
|
|
38190
|
-
var
|
|
38191
|
-
var
|
|
38244
|
+
var import_node_fs62 = require("node:fs");
|
|
38245
|
+
var import_node_path46 = require("node:path");
|
|
38192
38246
|
var import_node_child_process17 = require("node:child_process");
|
|
38193
38247
|
var LEGACY_NPM_PACKAGE = "@codacy/gate-cli";
|
|
38194
38248
|
function defaultNpmRemover(pkg) {
|
|
@@ -38225,12 +38279,12 @@ async function runMigration(opts = {}) {
|
|
|
38225
38279
|
return { actions, migrated: actions.length > 0 };
|
|
38226
38280
|
}
|
|
38227
38281
|
function migrateProjectDir(root, actions) {
|
|
38228
|
-
const gateDir = (0,
|
|
38229
|
-
const verityDir = (0,
|
|
38230
|
-
if ((0,
|
|
38282
|
+
const gateDir = (0, import_node_path46.join)(root, ".gate");
|
|
38283
|
+
const verityDir = (0, import_node_path46.join)(root, ".verity");
|
|
38284
|
+
if ((0, import_node_fs62.existsSync)(gateDir) && !(0, import_node_fs62.existsSync)(verityDir)) {
|
|
38231
38285
|
return migrateProjectDirRename(root, gateDir, verityDir, actions);
|
|
38232
38286
|
}
|
|
38233
|
-
if ((0,
|
|
38287
|
+
if ((0, import_node_fs62.existsSync)(gateDir) && (0, import_node_fs62.existsSync)(verityDir)) {
|
|
38234
38288
|
return migrateProjectDirCarry(gateDir, verityDir, actions);
|
|
38235
38289
|
}
|
|
38236
38290
|
return false;
|
|
@@ -38251,13 +38305,13 @@ function migrateProjectDirRename(root, gateDir, verityDir, actions) {
|
|
|
38251
38305
|
}
|
|
38252
38306
|
}
|
|
38253
38307
|
if (moved) {
|
|
38254
|
-
if ((0,
|
|
38308
|
+
if ((0, import_node_fs62.existsSync)(gateDir)) {
|
|
38255
38309
|
const carried = carryLegacyContents(gateDir, verityDir);
|
|
38256
38310
|
if (carried > 0) {
|
|
38257
38311
|
actions.push(`Carried ${carried} untracked legacy file(s) from .gate/ into .verity/`);
|
|
38258
38312
|
}
|
|
38259
38313
|
try {
|
|
38260
|
-
(0,
|
|
38314
|
+
(0, import_node_fs62.rmSync)(gateDir, { recursive: true, force: true });
|
|
38261
38315
|
} catch {
|
|
38262
38316
|
}
|
|
38263
38317
|
}
|
|
@@ -38273,18 +38327,18 @@ function migrateProjectDirCarry(gateDir, verityDir, actions) {
|
|
|
38273
38327
|
actions.push(`Carried ${carried} legacy file(s) from .gate/ into .verity/`);
|
|
38274
38328
|
}
|
|
38275
38329
|
try {
|
|
38276
|
-
(0,
|
|
38330
|
+
(0, import_node_fs62.rmSync)(gateDir, { recursive: true, force: true });
|
|
38277
38331
|
} catch {
|
|
38278
38332
|
}
|
|
38279
38333
|
return carried > 0;
|
|
38280
38334
|
}
|
|
38281
38335
|
function migrateGlobalCredentials(home, actions) {
|
|
38282
38336
|
if (!home) return;
|
|
38283
|
-
const gateCreds = (0,
|
|
38284
|
-
const verityCreds = (0,
|
|
38285
|
-
if (!(0,
|
|
38286
|
-
if (!(0,
|
|
38287
|
-
(0,
|
|
38337
|
+
const gateCreds = (0, import_node_path46.join)(home, ".gate", "credentials");
|
|
38338
|
+
const verityCreds = (0, import_node_path46.join)(home, ".verity", "credentials");
|
|
38339
|
+
if (!(0, import_node_fs62.existsSync)(gateCreds)) return;
|
|
38340
|
+
if (!(0, import_node_fs62.existsSync)(verityCreds)) {
|
|
38341
|
+
(0, import_node_fs62.mkdirSync)((0, import_node_path46.join)(home, ".verity"), { recursive: true });
|
|
38288
38342
|
moveFile(gateCreds, verityCreds);
|
|
38289
38343
|
actions.push("Moved ~/.gate/credentials \u2192 ~/.verity/credentials");
|
|
38290
38344
|
return;
|
|
@@ -38306,8 +38360,8 @@ async function migrateLegacyHooks(root, actions) {
|
|
|
38306
38360
|
}
|
|
38307
38361
|
}
|
|
38308
38362
|
async function migrateClaudeMd(root, actions) {
|
|
38309
|
-
const claudeMd = (0,
|
|
38310
|
-
const hadLegacyBlock = (0,
|
|
38363
|
+
const claudeMd = (0, import_node_path46.join)(root, "CLAUDE.md");
|
|
38364
|
+
const hadLegacyBlock = (0, import_node_fs62.existsSync)(claudeMd) && hasLegacyMemoryBlock(readFileSyncSafe(claudeMd));
|
|
38311
38365
|
if (!hadLegacyBlock) return;
|
|
38312
38366
|
try {
|
|
38313
38367
|
await ensureClaudeMdPointer(root);
|
|
@@ -38317,9 +38371,9 @@ async function migrateClaudeMd(root, actions) {
|
|
|
38317
38371
|
}
|
|
38318
38372
|
}
|
|
38319
38373
|
function migrateStandardFile(root, actions) {
|
|
38320
|
-
const gateMd = (0,
|
|
38321
|
-
const verityMd = (0,
|
|
38322
|
-
if (!(0,
|
|
38374
|
+
const gateMd = (0, import_node_path46.join)(root, "GATE.md");
|
|
38375
|
+
const verityMd = (0, import_node_path46.join)(root, "VERITY.md");
|
|
38376
|
+
if (!(0, import_node_fs62.existsSync)(gateMd) || (0, import_node_fs62.existsSync)(verityMd)) return;
|
|
38323
38377
|
let moved = false;
|
|
38324
38378
|
if (isGitRepo(root) && isGitTracked(root, "GATE.md")) {
|
|
38325
38379
|
try {
|
|
@@ -38331,12 +38385,12 @@ function migrateStandardFile(root, actions) {
|
|
|
38331
38385
|
if (!moved) moveFile(gateMd, verityMd);
|
|
38332
38386
|
const content = readFileSyncSafe(verityMd);
|
|
38333
38387
|
const refreshed = content.split("GATE.md").join("VERITY.md");
|
|
38334
|
-
if (refreshed !== content) (0,
|
|
38388
|
+
if (refreshed !== content) (0, import_node_fs62.writeFileSync)(verityMd, refreshed);
|
|
38335
38389
|
actions.push("Renamed GATE.md \u2192 VERITY.md");
|
|
38336
38390
|
}
|
|
38337
38391
|
async function migrateTelemetryHeaders(root, actions) {
|
|
38338
|
-
const file = (0,
|
|
38339
|
-
if (!(0,
|
|
38392
|
+
const file = (0, import_node_path46.join)(root, ".claude", "settings.local.json");
|
|
38393
|
+
if (!(0, import_node_fs62.existsSync)(file)) return;
|
|
38340
38394
|
let settings;
|
|
38341
38395
|
try {
|
|
38342
38396
|
settings = JSON.parse(readFileSyncSafe(file) || "{}");
|
|
@@ -38384,14 +38438,14 @@ function mergeGlobalCredentials(gateCreds, verityCreds) {
|
|
|
38384
38438
|
}
|
|
38385
38439
|
if (toAppend.length > 0) {
|
|
38386
38440
|
const sep5 = verityContent.endsWith("\n") || verityContent === "" ? "" : "\n";
|
|
38387
|
-
(0,
|
|
38441
|
+
(0, import_node_fs62.writeFileSync)(verityCreds, verityContent + sep5 + toAppend.join("\n") + "\n");
|
|
38388
38442
|
}
|
|
38389
|
-
(0,
|
|
38443
|
+
(0, import_node_fs62.rmSync)(gateCreds, { force: true });
|
|
38390
38444
|
return toAppend.length;
|
|
38391
38445
|
}
|
|
38392
38446
|
function readFileSyncSafe(path) {
|
|
38393
38447
|
try {
|
|
38394
|
-
return (0,
|
|
38448
|
+
return (0, import_node_fs62.readFileSync)(path, "utf-8");
|
|
38395
38449
|
} catch {
|
|
38396
38450
|
return "";
|
|
38397
38451
|
}
|
|
@@ -38406,35 +38460,35 @@ function hasStagedChanges(root) {
|
|
|
38406
38460
|
}
|
|
38407
38461
|
function moveDir(from, to) {
|
|
38408
38462
|
try {
|
|
38409
|
-
(0,
|
|
38463
|
+
(0, import_node_fs62.renameSync)(from, to);
|
|
38410
38464
|
} catch (err2) {
|
|
38411
38465
|
if (err2.code !== "EXDEV") throw err2;
|
|
38412
|
-
(0,
|
|
38413
|
-
(0,
|
|
38466
|
+
(0, import_node_fs62.cpSync)(from, to, { recursive: true });
|
|
38467
|
+
(0, import_node_fs62.rmSync)(from, { recursive: true, force: true });
|
|
38414
38468
|
}
|
|
38415
38469
|
}
|
|
38416
38470
|
function moveFile(from, to) {
|
|
38417
38471
|
try {
|
|
38418
|
-
(0,
|
|
38472
|
+
(0, import_node_fs62.renameSync)(from, to);
|
|
38419
38473
|
} catch (err2) {
|
|
38420
38474
|
if (err2.code !== "EXDEV") throw err2;
|
|
38421
|
-
(0,
|
|
38422
|
-
(0,
|
|
38475
|
+
(0, import_node_fs62.cpSync)(from, to);
|
|
38476
|
+
(0, import_node_fs62.rmSync)(from, { force: true });
|
|
38423
38477
|
}
|
|
38424
38478
|
}
|
|
38425
38479
|
function carryLegacyContents(gateDir, verityDir) {
|
|
38426
38480
|
let copied = 0;
|
|
38427
38481
|
const walk2 = (relDir) => {
|
|
38428
|
-
const srcDir = (0,
|
|
38429
|
-
for (const entry of (0,
|
|
38430
|
-
const rel = relDir ? (0,
|
|
38431
|
-
const src = (0,
|
|
38432
|
-
const dest = (0,
|
|
38433
|
-
if ((0,
|
|
38482
|
+
const srcDir = (0, import_node_path46.join)(gateDir, relDir);
|
|
38483
|
+
for (const entry of (0, import_node_fs62.readdirSync)(srcDir)) {
|
|
38484
|
+
const rel = relDir ? (0, import_node_path46.join)(relDir, entry) : entry;
|
|
38485
|
+
const src = (0, import_node_path46.join)(gateDir, rel);
|
|
38486
|
+
const dest = (0, import_node_path46.join)(verityDir, rel);
|
|
38487
|
+
if ((0, import_node_fs62.statSync)(src).isDirectory()) {
|
|
38434
38488
|
walk2(rel);
|
|
38435
|
-
} else if (!(0,
|
|
38436
|
-
(0,
|
|
38437
|
-
(0,
|
|
38489
|
+
} else if (!(0, import_node_fs62.existsSync)(dest)) {
|
|
38490
|
+
(0, import_node_fs62.mkdirSync)((0, import_node_path46.dirname)(dest), { recursive: true });
|
|
38491
|
+
(0, import_node_fs62.cpSync)(src, dest);
|
|
38438
38492
|
copied++;
|
|
38439
38493
|
}
|
|
38440
38494
|
}
|
|
@@ -38443,22 +38497,22 @@ function carryLegacyContents(gateDir, verityDir) {
|
|
|
38443
38497
|
return copied;
|
|
38444
38498
|
}
|
|
38445
38499
|
async function needsMigration(root = repoRoot()) {
|
|
38446
|
-
const gateDir = (0,
|
|
38447
|
-
const verityDir = (0,
|
|
38448
|
-
if ((0,
|
|
38449
|
-
if ((0,
|
|
38450
|
-
if ((0,
|
|
38500
|
+
const gateDir = (0, import_node_path46.join)(root, ".gate");
|
|
38501
|
+
const verityDir = (0, import_node_path46.join)(root, ".verity");
|
|
38502
|
+
if ((0, import_node_fs62.existsSync)(gateDir) && !(0, import_node_fs62.existsSync)(verityDir)) return true;
|
|
38503
|
+
if ((0, import_node_fs62.existsSync)(gateDir) && (0, import_node_fs62.existsSync)(verityDir)) {
|
|
38504
|
+
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"))) {
|
|
38451
38505
|
return true;
|
|
38452
38506
|
}
|
|
38453
|
-
if ((0,
|
|
38507
|
+
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"))) {
|
|
38454
38508
|
return true;
|
|
38455
38509
|
}
|
|
38456
38510
|
}
|
|
38457
|
-
const claudeMd = (0,
|
|
38458
|
-
if ((0,
|
|
38511
|
+
const claudeMd = (0, import_node_path46.join)(root, "CLAUDE.md");
|
|
38512
|
+
if ((0, import_node_fs62.existsSync)(claudeMd) && hasLegacyMemoryBlock(readFileSyncSafe(claudeMd))) {
|
|
38459
38513
|
return true;
|
|
38460
38514
|
}
|
|
38461
|
-
if ((0,
|
|
38515
|
+
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"))) {
|
|
38462
38516
|
return true;
|
|
38463
38517
|
}
|
|
38464
38518
|
if (await hasLegacyHooksAt(root)) return true;
|
|
@@ -38739,11 +38793,11 @@ async function promptMultiSelect(question, choices, fallback) {
|
|
|
38739
38793
|
}
|
|
38740
38794
|
|
|
38741
38795
|
// src/lib/prove/lean-install.ts
|
|
38742
|
-
var
|
|
38796
|
+
var import_node_fs63 = require("node:fs");
|
|
38743
38797
|
var import_node_crypto20 = require("node:crypto");
|
|
38744
38798
|
var import_node_child_process18 = require("node:child_process");
|
|
38745
38799
|
var import_node_os10 = require("node:os");
|
|
38746
|
-
var
|
|
38800
|
+
var import_node_path47 = require("node:path");
|
|
38747
38801
|
var import_promises18 = require("node:stream/promises");
|
|
38748
38802
|
var import_node_stream = require("node:stream");
|
|
38749
38803
|
var RELEASES = "https://releases.lean-lang.org/lean4";
|
|
@@ -38763,7 +38817,7 @@ function expectedSha256(asset, version = pinnedVersion()) {
|
|
|
38763
38817
|
function sha256File(path) {
|
|
38764
38818
|
return new Promise((resolve8, reject) => {
|
|
38765
38819
|
const hash = (0, import_node_crypto20.createHash)("sha256");
|
|
38766
|
-
(0,
|
|
38820
|
+
(0, import_node_fs63.createReadStream)(path).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve8(hash.digest("hex"))).on("error", reject);
|
|
38767
38821
|
});
|
|
38768
38822
|
}
|
|
38769
38823
|
async function verifyDownload(zip, asset, version = pinnedVersion()) {
|
|
@@ -38783,7 +38837,7 @@ function leanAssetName(version = pinnedVersion()) {
|
|
|
38783
38837
|
return suffix ? `lean-${v}-${suffix}.zip` : null;
|
|
38784
38838
|
}
|
|
38785
38839
|
function pinnedVersionDir(env = process.env) {
|
|
38786
|
-
return (0,
|
|
38840
|
+
return (0, import_node_path47.join)(verityLeanHome(env), pinnedVersion());
|
|
38787
38841
|
}
|
|
38788
38842
|
function lakeBinary() {
|
|
38789
38843
|
return (0, import_node_os10.platform)() === "win32" ? "lake.exe" : "lake";
|
|
@@ -38794,12 +38848,12 @@ function unzip(zip, dest) {
|
|
|
38794
38848
|
for (const [cmd, args2] of attempts) {
|
|
38795
38849
|
try {
|
|
38796
38850
|
(0, import_node_child_process18.execFileSync)(cmd, args2, { stdio: ["ignore", "ignore", "pipe"], timeout: 15 * 6e4 });
|
|
38797
|
-
if ((0,
|
|
38851
|
+
if ((0, import_node_fs63.readdirSync)(dest).length > 0) return { ok: true, via: cmd };
|
|
38798
38852
|
errors.push(`${cmd}: produced nothing`);
|
|
38799
38853
|
} catch (err2) {
|
|
38800
38854
|
errors.push(`${cmd}: ${String(err2.message).split("\n")[0].slice(0, 120)}`);
|
|
38801
38855
|
try {
|
|
38802
|
-
for (const e of (0,
|
|
38856
|
+
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 });
|
|
38803
38857
|
} catch {
|
|
38804
38858
|
}
|
|
38805
38859
|
}
|
|
@@ -38816,7 +38870,7 @@ async function download(url, dest, onProgress) {
|
|
|
38816
38870
|
seen += chunk.length;
|
|
38817
38871
|
onProgress(seen, total);
|
|
38818
38872
|
});
|
|
38819
|
-
await (0, import_promises18.pipeline)(stream, (0,
|
|
38873
|
+
await (0, import_promises18.pipeline)(stream, (0, import_node_fs63.createWriteStream)(dest));
|
|
38820
38874
|
}
|
|
38821
38875
|
function inPlaceProgress(label2, write = (s) => process.stderr.write(s)) {
|
|
38822
38876
|
let active = false;
|
|
@@ -38854,10 +38908,10 @@ async function installLean(opts = {}) {
|
|
|
38854
38908
|
const dir = pinnedVersionDir(env);
|
|
38855
38909
|
const url = `${RELEASES}/${pinnedVersion()}/${asset}`;
|
|
38856
38910
|
const home = verityLeanHome(env);
|
|
38857
|
-
const tmp = (0,
|
|
38858
|
-
(0,
|
|
38859
|
-
(0,
|
|
38860
|
-
const zip = (0,
|
|
38911
|
+
const tmp = (0, import_node_path47.join)(home, ".tmp");
|
|
38912
|
+
(0, import_node_fs63.rmSync)(tmp, { recursive: true, force: true });
|
|
38913
|
+
(0, import_node_fs63.mkdirSync)(tmp, { recursive: true });
|
|
38914
|
+
const zip = (0, import_node_path47.join)(tmp, asset);
|
|
38861
38915
|
say(`downloading ${url}`);
|
|
38862
38916
|
let lastPct = -1;
|
|
38863
38917
|
try {
|
|
@@ -38870,40 +38924,40 @@ async function installLean(opts = {}) {
|
|
|
38870
38924
|
}
|
|
38871
38925
|
});
|
|
38872
38926
|
} catch (err2) {
|
|
38873
|
-
(0,
|
|
38927
|
+
(0, import_node_fs63.rmSync)(tmp, { recursive: true, force: true });
|
|
38874
38928
|
return { ok: false, error: err2.message };
|
|
38875
38929
|
}
|
|
38876
38930
|
say("verifying checksum");
|
|
38877
38931
|
const verified = await verifyDownload(zip, asset);
|
|
38878
38932
|
if (!verified.ok) {
|
|
38879
|
-
(0,
|
|
38933
|
+
(0, import_node_fs63.rmSync)(tmp, { recursive: true, force: true });
|
|
38880
38934
|
return { ok: false, error: verified.error };
|
|
38881
38935
|
}
|
|
38882
38936
|
say("unpacking (this takes a minute)");
|
|
38883
|
-
const unpack = (0,
|
|
38884
|
-
(0,
|
|
38937
|
+
const unpack = (0, import_node_path47.join)(tmp, "unpack");
|
|
38938
|
+
(0, import_node_fs63.mkdirSync)(unpack);
|
|
38885
38939
|
const unpacked = unzip(zip, unpack);
|
|
38886
38940
|
if (!unpacked.ok) {
|
|
38887
|
-
(0,
|
|
38941
|
+
(0, import_node_fs63.rmSync)(tmp, { recursive: true, force: true });
|
|
38888
38942
|
return { ok: false, error: `unpack failed: ${unpacked.error}` };
|
|
38889
38943
|
}
|
|
38890
|
-
const entries = (0,
|
|
38891
|
-
const top = entries.length === 1 && (0,
|
|
38892
|
-
if (!(0,
|
|
38893
|
-
(0,
|
|
38944
|
+
const entries = (0, import_node_fs63.readdirSync)(unpack);
|
|
38945
|
+
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;
|
|
38946
|
+
if (!(0, import_node_fs63.existsSync)((0, import_node_path47.join)(top, "bin", lakeBinary()))) {
|
|
38947
|
+
(0, import_node_fs63.rmSync)(tmp, { recursive: true, force: true });
|
|
38894
38948
|
return { ok: false, error: "the archive did not contain bin/lake" };
|
|
38895
38949
|
}
|
|
38896
|
-
(0,
|
|
38897
|
-
(0,
|
|
38898
|
-
(0,
|
|
38899
|
-
(0,
|
|
38950
|
+
(0, import_node_fs63.rmSync)(dir, { recursive: true, force: true });
|
|
38951
|
+
(0, import_node_fs63.mkdirSync)(home, { recursive: true });
|
|
38952
|
+
(0, import_node_fs63.renameSync)(top, dir);
|
|
38953
|
+
(0, import_node_fs63.rmSync)(tmp, { recursive: true, force: true });
|
|
38900
38954
|
return { ok: true, dir };
|
|
38901
38955
|
}
|
|
38902
38956
|
|
|
38903
38957
|
// src/lib/remote-config.ts
|
|
38904
|
-
var
|
|
38958
|
+
var import_node_fs64 = require("node:fs");
|
|
38905
38959
|
var import_promises19 = require("node:fs/promises");
|
|
38906
|
-
var
|
|
38960
|
+
var import_node_path48 = require("node:path");
|
|
38907
38961
|
var import_yaml5 = __toESM2(require_dist());
|
|
38908
38962
|
var IGNORE_RIDER = "verityignore";
|
|
38909
38963
|
async function fetchRemoteSetup(opts) {
|
|
@@ -38948,7 +39002,7 @@ async function adoptRemoteSetup(found, opts) {
|
|
|
38948
39002
|
written.push(STANDARD_FILE);
|
|
38949
39003
|
if (rider !== null) {
|
|
38950
39004
|
const localIgnore = projectPath(VERITYIGNORE_FILE);
|
|
38951
|
-
if (!(0,
|
|
39005
|
+
if (!(0, import_node_fs64.existsSync)(localIgnore)) {
|
|
38952
39006
|
await writeOut(VERITYIGNORE_FILE, rider);
|
|
38953
39007
|
written.push(VERITYIGNORE_FILE);
|
|
38954
39008
|
} else {
|
|
@@ -38981,7 +39035,7 @@ async function adoptRemoteSetup(found, opts) {
|
|
|
38981
39035
|
}
|
|
38982
39036
|
async function writeOut(relative6, body2) {
|
|
38983
39037
|
const target = projectPath(relative6);
|
|
38984
|
-
await (0, import_promises19.mkdir)((0,
|
|
39038
|
+
await (0, import_promises19.mkdir)((0, import_node_path48.dirname)(target), { recursive: true });
|
|
38985
39039
|
await (0, import_promises19.writeFile)(target, body2);
|
|
38986
39040
|
}
|
|
38987
39041
|
function describeRemote(found) {
|
|
@@ -39098,15 +39152,15 @@ async function runOptionalAuth(resolution, opts = {}) {
|
|
|
39098
39152
|
}
|
|
39099
39153
|
function resolveDataDir2() {
|
|
39100
39154
|
const candidates2 = [
|
|
39101
|
-
(0,
|
|
39155
|
+
(0, import_node_path49.join)(__dirname, "..", "data"),
|
|
39102
39156
|
// installed: node_modules/@codacy/verity-cli/data
|
|
39103
|
-
(0,
|
|
39157
|
+
(0, import_node_path49.join)(__dirname, "..", "..", "data"),
|
|
39104
39158
|
// edge case: nested resolution
|
|
39105
|
-
(0,
|
|
39159
|
+
(0, import_node_path49.join)(process.cwd(), "cli", "data")
|
|
39106
39160
|
// local dev: running from repo root
|
|
39107
39161
|
];
|
|
39108
39162
|
for (const candidate of candidates2) {
|
|
39109
|
-
if ((0,
|
|
39163
|
+
if ((0, import_node_fs65.existsSync)((0, import_node_path49.join)(candidate, "skills"))) {
|
|
39110
39164
|
return candidate;
|
|
39111
39165
|
}
|
|
39112
39166
|
}
|
|
@@ -39122,9 +39176,9 @@ async function skillIsCurrent(src, dest) {
|
|
|
39122
39176
|
const list2 = (dir) => {
|
|
39123
39177
|
const out2 = [];
|
|
39124
39178
|
const walk2 = (d, prefix) => {
|
|
39125
|
-
for (const e of (0,
|
|
39179
|
+
for (const e of (0, import_node_fs65.readdirSync)(d, { withFileTypes: true })) {
|
|
39126
39180
|
const rel = prefix ? `${prefix}/${e.name}` : e.name;
|
|
39127
|
-
if (e.isDirectory()) walk2((0,
|
|
39181
|
+
if (e.isDirectory()) walk2((0, import_node_path49.join)(d, e.name), rel);
|
|
39128
39182
|
else if (e.isFile()) out2.push(rel);
|
|
39129
39183
|
}
|
|
39130
39184
|
};
|
|
@@ -39135,8 +39189,8 @@ async function skillIsCurrent(src, dest) {
|
|
|
39135
39189
|
const shipped = list2(src);
|
|
39136
39190
|
if (JSON.stringify(shipped) !== JSON.stringify(list2(dest))) return false;
|
|
39137
39191
|
for (const rel of shipped) {
|
|
39138
|
-
const a = await (0, import_promises20.readFile)((0,
|
|
39139
|
-
const b = await (0, import_promises20.readFile)((0,
|
|
39192
|
+
const a = await (0, import_promises20.readFile)((0, import_node_path49.join)(src, rel), "utf-8");
|
|
39193
|
+
const b = await (0, import_promises20.readFile)((0, import_node_path49.join)(dest, rel), "utf-8");
|
|
39140
39194
|
if (a !== b) return false;
|
|
39141
39195
|
}
|
|
39142
39196
|
return true;
|
|
@@ -39337,7 +39391,7 @@ async function synthesizeLocally(opts) {
|
|
|
39337
39391
|
async function healStaleAnalysisConfig(globals) {
|
|
39338
39392
|
const configPath = projectPath(CODACY_CONFIG_FILE);
|
|
39339
39393
|
const standardPath = projectPath(STANDARD_FILE);
|
|
39340
|
-
if (!(0,
|
|
39394
|
+
if (!(0, import_node_fs65.existsSync)(configPath) || !(0, import_node_fs65.existsSync)(standardPath)) return;
|
|
39341
39395
|
const validation = validatePatternIds();
|
|
39342
39396
|
if (validation.status !== "invalid") return;
|
|
39343
39397
|
printWarn(" Your analysis config names pattern ids that no longer resolve \u2014 those tools were");
|
|
@@ -39434,17 +39488,17 @@ async function handoffToSetup(enabled, claudeInstalled) {
|
|
|
39434
39488
|
async function installSkills(force, step) {
|
|
39435
39489
|
step("Installing skills");
|
|
39436
39490
|
const dataDir = resolveDataDir2();
|
|
39437
|
-
const skillsSource = (0,
|
|
39491
|
+
const skillsSource = (0, import_node_path49.join)(dataDir, "skills");
|
|
39438
39492
|
const skillsDest = ".claude/skills";
|
|
39439
39493
|
let skillsInstalled = 0;
|
|
39440
39494
|
for (const skill of SKILLS) {
|
|
39441
|
-
const src = (0,
|
|
39442
|
-
const dest = (0,
|
|
39443
|
-
if (!(0,
|
|
39495
|
+
const src = (0, import_node_path49.join)(skillsSource, skill);
|
|
39496
|
+
const dest = (0, import_node_path49.join)(skillsDest, skill);
|
|
39497
|
+
if (!(0, import_node_fs65.existsSync)(src)) {
|
|
39444
39498
|
printWarn(` Skill data not found: ${skill}`);
|
|
39445
39499
|
continue;
|
|
39446
39500
|
}
|
|
39447
|
-
if ((0,
|
|
39501
|
+
if ((0, import_node_fs65.existsSync)(dest) && !force && await skillIsCurrent(src, dest)) {
|
|
39448
39502
|
skillsInstalled++;
|
|
39449
39503
|
continue;
|
|
39450
39504
|
}
|
|
@@ -39639,7 +39693,7 @@ function registerInitCommand(program2) {
|
|
|
39639
39693
|
const staleMarker = clearStalePluginMarker();
|
|
39640
39694
|
const pluginMode = opts.plugin === false ? false : opts.pluginMode ?? pluginActiveHere();
|
|
39641
39695
|
const projectMarkers = [".git", "package.json", "pyproject.toml", "go.mod", "Cargo.toml", "Gemfile", "pom.xml", "build.gradle"];
|
|
39642
|
-
const isProject = projectMarkers.some((m) => (0,
|
|
39696
|
+
const isProject = projectMarkers.some((m) => (0, import_node_fs65.existsSync)(m));
|
|
39643
39697
|
if (!isProject) {
|
|
39644
39698
|
printError("No project detected in the current directory.");
|
|
39645
39699
|
printInfo('Run "verity init" from your project root.');
|
|
@@ -39742,7 +39796,7 @@ function registerInitCommand(program2) {
|
|
|
39742
39796
|
untrackMemory: opts.untrackMemory === true,
|
|
39743
39797
|
untrackState: opts.untrackState === true
|
|
39744
39798
|
});
|
|
39745
|
-
const globalVerityDir = (0,
|
|
39799
|
+
const globalVerityDir = (0, import_node_path49.join)(process.env.HOME ?? "", ".verity");
|
|
39746
39800
|
await (0, import_promises20.mkdir)(globalVerityDir, { recursive: true });
|
|
39747
39801
|
console.log("");
|
|
39748
39802
|
step("Wiring Claude Code hooks");
|
|
@@ -39817,7 +39871,7 @@ function registerInitCommand(program2) {
|
|
|
39817
39871
|
}
|
|
39818
39872
|
step("Your project's Standard");
|
|
39819
39873
|
let haveStandard = false;
|
|
39820
|
-
if ((0,
|
|
39874
|
+
if ((0, import_node_fs65.existsSync)(projectPath(STANDARD_FILE))) {
|
|
39821
39875
|
printInfo(" This project already has .verity/standard.yaml \u2014 keeping it.");
|
|
39822
39876
|
haveStandard = true;
|
|
39823
39877
|
} else {
|
|
@@ -39847,7 +39901,7 @@ function registerInitCommand(program2) {
|
|
|
39847
39901
|
...telemetryChoice ? { telemetry: telemetryChoice } : {},
|
|
39848
39902
|
init: {
|
|
39849
39903
|
completed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
39850
|
-
cli_version: true ? "0.34.0-experimental.
|
|
39904
|
+
cli_version: true ? "0.34.0-experimental.dc0010f" : "dev"
|
|
39851
39905
|
}
|
|
39852
39906
|
});
|
|
39853
39907
|
} catch (err2) {
|
|
@@ -39897,8 +39951,8 @@ function registerInitCommand(program2) {
|
|
|
39897
39951
|
}
|
|
39898
39952
|
|
|
39899
39953
|
// src/commands/uninstall.ts
|
|
39900
|
-
var
|
|
39901
|
-
var
|
|
39954
|
+
var import_node_fs66 = require("node:fs");
|
|
39955
|
+
var import_node_path50 = require("node:path");
|
|
39902
39956
|
function registerUninstallCommand(program2) {
|
|
39903
39957
|
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) => {
|
|
39904
39958
|
const dryRun = opts.dryRun ?? false;
|
|
@@ -39907,11 +39961,11 @@ function registerUninstallCommand(program2) {
|
|
|
39907
39961
|
const actions = [];
|
|
39908
39962
|
const skillsRoot = projectPath(".claude/skills");
|
|
39909
39963
|
for (const name2 of PROJECT_SKILL_NAMES) {
|
|
39910
|
-
const dir = (0,
|
|
39911
|
-
if ((0,
|
|
39964
|
+
const dir = (0, import_node_path50.join)(skillsRoot, name2);
|
|
39965
|
+
if ((0, import_node_fs66.existsSync)(dir)) {
|
|
39912
39966
|
actions.push({
|
|
39913
39967
|
label: `Remove .claude/skills/${name2}/`,
|
|
39914
|
-
apply: () => (0,
|
|
39968
|
+
apply: () => (0, import_node_fs66.rmSync)(dir, { recursive: true, force: true })
|
|
39915
39969
|
});
|
|
39916
39970
|
}
|
|
39917
39971
|
}
|
|
@@ -39925,24 +39979,24 @@ function registerUninstallCommand(program2) {
|
|
|
39925
39979
|
});
|
|
39926
39980
|
}
|
|
39927
39981
|
const verityDir = projectPath(VERITY_DIR);
|
|
39928
|
-
if ((0,
|
|
39982
|
+
if ((0, import_node_fs66.existsSync)(verityDir)) {
|
|
39929
39983
|
actions.push({
|
|
39930
39984
|
label: `Remove ${VERITY_DIR}/`,
|
|
39931
|
-
apply: () => (0,
|
|
39985
|
+
apply: () => (0, import_node_fs66.rmSync)(verityDir, { recursive: true, force: true })
|
|
39932
39986
|
});
|
|
39933
39987
|
}
|
|
39934
39988
|
if (!keepVerityMd) {
|
|
39935
39989
|
const verityMd = projectPath(VERITY_MD_FILE);
|
|
39936
|
-
if ((0,
|
|
39990
|
+
if ((0, import_node_fs66.existsSync)(verityMd)) {
|
|
39937
39991
|
actions.push({
|
|
39938
39992
|
label: `Remove ${VERITY_MD_FILE}`,
|
|
39939
|
-
apply: () => (0,
|
|
39993
|
+
apply: () => (0, import_node_fs66.rmSync)(verityMd, { force: true })
|
|
39940
39994
|
});
|
|
39941
39995
|
}
|
|
39942
39996
|
}
|
|
39943
39997
|
const cleanupEmptyDir = (path) => {
|
|
39944
|
-
if ((0,
|
|
39945
|
-
(0,
|
|
39998
|
+
if ((0, import_node_fs66.existsSync)(path) && (0, import_node_fs66.statSync)(path).isDirectory() && (0, import_node_fs66.readdirSync)(path).length === 0) {
|
|
39999
|
+
(0, import_node_fs66.rmdirSync)(path);
|
|
39946
40000
|
}
|
|
39947
40001
|
};
|
|
39948
40002
|
actions.push({
|
|
@@ -39953,11 +40007,11 @@ function registerUninstallCommand(program2) {
|
|
|
39953
40007
|
}
|
|
39954
40008
|
});
|
|
39955
40009
|
const home = process.env.HOME ?? "";
|
|
39956
|
-
const globalVerityDir = (0,
|
|
39957
|
-
if (purgeGlobal && (0,
|
|
40010
|
+
const globalVerityDir = (0, import_node_path50.join)(home, ".verity");
|
|
40011
|
+
if (purgeGlobal && (0, import_node_fs66.existsSync)(globalVerityDir)) {
|
|
39958
40012
|
actions.push({
|
|
39959
40013
|
label: `Remove ~/.verity/ (global credentials \u2014 reconnect requires re-registration)`,
|
|
39960
|
-
apply: () => (0,
|
|
40014
|
+
apply: () => (0, import_node_fs66.rmSync)(globalVerityDir, { recursive: true, force: true })
|
|
39961
40015
|
});
|
|
39962
40016
|
}
|
|
39963
40017
|
if (actions.length === 0) {
|
|
@@ -40151,8 +40205,8 @@ function registerTaskCommands(program2) {
|
|
|
40151
40205
|
}
|
|
40152
40206
|
|
|
40153
40207
|
// src/commands/reset.ts
|
|
40154
|
-
var
|
|
40155
|
-
var
|
|
40208
|
+
var import_node_fs67 = require("node:fs");
|
|
40209
|
+
var import_node_path51 = require("node:path");
|
|
40156
40210
|
function registerResetCommand(program2) {
|
|
40157
40211
|
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) => {
|
|
40158
40212
|
const globals = program2.opts();
|
|
@@ -40189,11 +40243,11 @@ function registerResetCommand(program2) {
|
|
|
40189
40243
|
}
|
|
40190
40244
|
const cacheDir = projectPath(CACHE_DIR);
|
|
40191
40245
|
let purged = 0;
|
|
40192
|
-
if ((0,
|
|
40193
|
-
for (const entry of (0,
|
|
40246
|
+
if ((0, import_node_fs67.existsSync)(cacheDir)) {
|
|
40247
|
+
for (const entry of (0, import_node_fs67.readdirSync)(cacheDir)) {
|
|
40194
40248
|
if (entry.startsWith("pending-")) {
|
|
40195
40249
|
try {
|
|
40196
|
-
(0,
|
|
40250
|
+
(0, import_node_fs67.unlinkSync)((0, import_node_path51.join)(cacheDir, entry));
|
|
40197
40251
|
purged++;
|
|
40198
40252
|
} catch {
|
|
40199
40253
|
}
|
|
@@ -40208,19 +40262,19 @@ function registerResetCommand(program2) {
|
|
|
40208
40262
|
projectPath(`${VERITY_DIR}/.last-analysis`)
|
|
40209
40263
|
];
|
|
40210
40264
|
for (const file of filesToClear) {
|
|
40211
|
-
if ((0,
|
|
40265
|
+
if ((0, import_node_fs67.existsSync)(file)) {
|
|
40212
40266
|
try {
|
|
40213
|
-
(0,
|
|
40267
|
+
(0, import_node_fs67.writeFileSync)(file, "");
|
|
40214
40268
|
} catch {
|
|
40215
40269
|
}
|
|
40216
40270
|
}
|
|
40217
40271
|
}
|
|
40218
40272
|
if (opts.all) {
|
|
40219
40273
|
const logsDir = projectPath(`${VERITY_DIR}/.logs`);
|
|
40220
|
-
if ((0,
|
|
40221
|
-
for (const entry of (0,
|
|
40274
|
+
if ((0, import_node_fs67.existsSync)(logsDir)) {
|
|
40275
|
+
for (const entry of (0, import_node_fs67.readdirSync)(logsDir)) {
|
|
40222
40276
|
try {
|
|
40223
|
-
(0,
|
|
40277
|
+
(0, import_node_fs67.unlinkSync)((0, import_node_path51.join)(logsDir, entry));
|
|
40224
40278
|
} catch {
|
|
40225
40279
|
}
|
|
40226
40280
|
}
|
|
@@ -40232,7 +40286,7 @@ function registerResetCommand(program2) {
|
|
|
40232
40286
|
}
|
|
40233
40287
|
|
|
40234
40288
|
// src/commands/reflect.ts
|
|
40235
|
-
var
|
|
40289
|
+
var import_node_fs68 = require("node:fs");
|
|
40236
40290
|
|
|
40237
40291
|
// src/lib/reflection-globs.ts
|
|
40238
40292
|
var MAX_GLOBS = 6;
|
|
@@ -40270,7 +40324,7 @@ async function writeNodeToDisk(args2) {
|
|
|
40270
40324
|
{ treePaths: listTrackedFiles(), recordBaseline: false }
|
|
40271
40325
|
);
|
|
40272
40326
|
if (written === 0) return false;
|
|
40273
|
-
return (0,
|
|
40327
|
+
return (0, import_node_fs68.existsSync)(projectPath(`${VERITY_DIR}/memory/${args2.filePath}`));
|
|
40274
40328
|
} catch {
|
|
40275
40329
|
return false;
|
|
40276
40330
|
}
|
|
@@ -40702,9 +40756,9 @@ function registerRunCommand(program2) {
|
|
|
40702
40756
|
}
|
|
40703
40757
|
|
|
40704
40758
|
// src/commands/telemetry.ts
|
|
40705
|
-
var
|
|
40759
|
+
var import_node_fs69 = require("node:fs");
|
|
40706
40760
|
async function recordTelemetryChoice(choice) {
|
|
40707
|
-
if (!(0,
|
|
40761
|
+
if (!(0, import_node_fs69.existsSync)(projectPath(SETUP_STATE_FILE))) return;
|
|
40708
40762
|
try {
|
|
40709
40763
|
if ((await readSetupState())?.telemetry === choice) return;
|
|
40710
40764
|
await writeSetupState({ telemetry: choice });
|
|
@@ -40781,8 +40835,8 @@ function registerTelemetryCommands(program2) {
|
|
|
40781
40835
|
}
|
|
40782
40836
|
|
|
40783
40837
|
// src/commands/prove.ts
|
|
40784
|
-
var
|
|
40785
|
-
var
|
|
40838
|
+
var import_node_fs70 = require("node:fs");
|
|
40839
|
+
var import_node_path52 = require("node:path");
|
|
40786
40840
|
|
|
40787
40841
|
// src/lib/prove/hint-pool.ts
|
|
40788
40842
|
var STOP2 = /* @__PURE__ */ new Set([
|
|
@@ -40918,7 +40972,7 @@ function registerProveCommand(program2) {
|
|
|
40918
40972
|
process.exit(2);
|
|
40919
40973
|
}
|
|
40920
40974
|
const limit = Math.max(1, Math.min(50, Number(opts.limit) || 10));
|
|
40921
|
-
let signals = collectRiskSignals(root, { since: opts.since, limit, paths: paths.map((p) => (0,
|
|
40975
|
+
let signals = collectRiskSignals(root, { since: opts.since, limit, paths: paths.map((p) => (0, import_node_path52.relative)(root, (0, import_node_path52.resolve)(p)) || ".") });
|
|
40922
40976
|
if (opts.hint && paths.length === 0) {
|
|
40923
40977
|
const hit = hintMatches(root, opts.hint);
|
|
40924
40978
|
if (hit.files.length > 0) {
|
|
@@ -40972,7 +41026,7 @@ function registerProveCommand(program2) {
|
|
|
40972
41026
|
});
|
|
40973
41027
|
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) => {
|
|
40974
41028
|
const root = repoRoot();
|
|
40975
|
-
if (!(0,
|
|
41029
|
+
if (!(0, import_node_fs70.existsSync)((0, import_node_path52.join)(root, PROOFS_DIR, "lakefile.toml"))) {
|
|
40976
41030
|
printError(`No ${PROOFS_DIR}/ project here. Run \`verity prove init\` first.`);
|
|
40977
41031
|
process.exit(2);
|
|
40978
41032
|
}
|
|
@@ -40996,7 +41050,7 @@ ${build.stderr.split("\n").filter((l) => !l.startsWith("trace:")).slice(0, 20).j
|
|
|
40996
41050
|
const reports = [];
|
|
40997
41051
|
for (const f of files) {
|
|
40998
41052
|
const report = checkModel(tc, root, f, { timeoutMs: Math.max(1e3, Number(opts.timeout) || 12e4) });
|
|
40999
|
-
report.file = (0,
|
|
41053
|
+
report.file = (0, import_node_path52.relative)(root, f);
|
|
41000
41054
|
reports.push(report);
|
|
41001
41055
|
try {
|
|
41002
41056
|
writeResult(root, report);
|
|
@@ -41034,7 +41088,7 @@ ${build.stderr.split("\n").filter((l) => !l.startsWith("trace:")).slice(0, 20).j
|
|
|
41034
41088
|
printError("Not logged in \u2014 replays run on the Verity service. Run `verity login` first.");
|
|
41035
41089
|
process.exit(2);
|
|
41036
41090
|
}
|
|
41037
|
-
if (!(0,
|
|
41091
|
+
if (!(0, import_node_fs70.existsSync)((0, import_node_path52.join)(root, PROOFS_DIR, "lakefile.toml"))) {
|
|
41038
41092
|
printError(`No ${PROOFS_DIR}/ project here. Run \`verity prove init\` first.`);
|
|
41039
41093
|
process.exit(2);
|
|
41040
41094
|
}
|
|
@@ -41065,7 +41119,7 @@ ${report.error ?? ""}`);
|
|
|
41065
41119
|
printInfo(opts.property ? `${model} ${opts.property} has no counterexample to replay` : `${model} has no counterexample to replay`);
|
|
41066
41120
|
return;
|
|
41067
41121
|
}
|
|
41068
|
-
const modelSource = readRegularFileInRoot(root, (0,
|
|
41122
|
+
const modelSource = readRegularFileInRoot(root, (0, import_node_path52.relative)(root, file), 512 * 1024);
|
|
41069
41123
|
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`);
|
|
41070
41124
|
const outcomes = await mapPool(targets, REPLAY_CONCURRENCY, async (p) => {
|
|
41071
41125
|
const brief = buildReplayBrief(root, report, p, modelSource.ok ? modelSource.content : "");
|
|
@@ -41085,7 +41139,7 @@ ${report.error ?? ""}`);
|
|
|
41085
41139
|
});
|
|
41086
41140
|
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) => {
|
|
41087
41141
|
const root = repoRoot();
|
|
41088
|
-
let files = paths.map((p) => (0,
|
|
41142
|
+
let files = paths.map((p) => (0, import_node_path52.relative)(root, (0, import_node_path52.resolve)(p)));
|
|
41089
41143
|
if (files.length === 0) {
|
|
41090
41144
|
const ahead = runGitSync(root, ["diff", "--name-only", "@{upstream}...HEAD"]);
|
|
41091
41145
|
const fallback = ahead.ok ? ahead : runGitSync(root, ["diff", "--name-only", "HEAD~1..HEAD"]);
|
|
@@ -41145,7 +41199,7 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
|
|
|
41145
41199
|
let revise;
|
|
41146
41200
|
if (opts.revise) {
|
|
41147
41201
|
const existing = resolveModelFile(root, opts.revise);
|
|
41148
|
-
const src = existing ? readRegularFileInRoot(root, (0,
|
|
41202
|
+
const src = existing ? readRegularFileInRoot(root, (0, import_node_path52.relative)(root, existing), 64 * 1024) : null;
|
|
41149
41203
|
if (!src || !src.ok || !opts.note) {
|
|
41150
41204
|
printError('--revise needs an existing model under Models/ and --note "<what the replay showed>"');
|
|
41151
41205
|
process.exit(2);
|
|
@@ -41184,8 +41238,8 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
|
|
|
41184
41238
|
});
|
|
41185
41239
|
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) => {
|
|
41186
41240
|
const root = repoRoot();
|
|
41187
|
-
const rel0 = (0,
|
|
41188
|
-
const rel = rel0.startsWith("..") || (0,
|
|
41241
|
+
const rel0 = (0, import_node_path52.relative)(root, (0, import_node_path52.isAbsolute)(file) ? file : (0, import_node_path52.join)(root, file)).replace(/\\/g, "/");
|
|
41242
|
+
const rel = rel0.startsWith("..") || (0, import_node_path52.isAbsolute)(rel0) ? null : rel0;
|
|
41189
41243
|
if (!rel) {
|
|
41190
41244
|
printError(`${file} is not inside this repository`);
|
|
41191
41245
|
process.exit(2);
|
|
@@ -41201,8 +41255,8 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
|
|
|
41201
41255
|
});
|
|
41202
41256
|
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) => {
|
|
41203
41257
|
const root = repoRoot();
|
|
41204
|
-
const rel = (0,
|
|
41205
|
-
const digest = rel.startsWith("..") || (0,
|
|
41258
|
+
const rel = (0, import_node_path52.relative)(root, (0, import_node_path52.isAbsolute)(file) ? file : (0, import_node_path52.join)(root, file));
|
|
41259
|
+
const digest = rel.startsWith("..") || (0, import_node_path52.isAbsolute)(rel) ? null : sha256InRoot(root, rel);
|
|
41206
41260
|
if (!digest) {
|
|
41207
41261
|
printError(`Cannot hash ${file}: it must be a regular file inside this repository (not a symlink)`);
|
|
41208
41262
|
process.exit(2);
|
|
@@ -41236,10 +41290,10 @@ function refreshScaffold(root) {
|
|
|
41236
41290
|
}
|
|
41237
41291
|
|
|
41238
41292
|
// src/commands/lean.ts
|
|
41239
|
-
var
|
|
41293
|
+
var import_node_fs71 = require("node:fs");
|
|
41240
41294
|
var import_node_child_process20 = require("node:child_process");
|
|
41241
41295
|
var import_node_os11 = require("node:os");
|
|
41242
|
-
var
|
|
41296
|
+
var import_node_path53 = require("node:path");
|
|
41243
41297
|
function registerLeanCommand(program2) {
|
|
41244
41298
|
const lean = program2.command("lean").description("The Lean 4 toolchain formal verification needs (managed download, pinned by this CLI)");
|
|
41245
41299
|
lean.command("status").option("--json", "Machine-readable output").description("Which toolchain would run, and whether it matches the pinned version").action((opts) => {
|
|
@@ -41256,7 +41310,7 @@ function registerLeanCommand(program2) {
|
|
|
41256
41310
|
const managed = pinnedVersionDir();
|
|
41257
41311
|
const matches = version ? version.includes(pin) : false;
|
|
41258
41312
|
if (opts.json) {
|
|
41259
|
-
printJson({ pinned: LEAN_TOOLCHAIN, found: tc?.lake ?? null, version, matches_pin: matches, managed_dir: managed, managed_installed: (0,
|
|
41313
|
+
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() });
|
|
41260
41314
|
return;
|
|
41261
41315
|
}
|
|
41262
41316
|
printInfo(`pinned: ${LEAN_TOOLCHAIN}`);
|
|
@@ -41274,7 +41328,7 @@ function registerLeanCommand(program2) {
|
|
|
41274
41328
|
process.exit(2);
|
|
41275
41329
|
}
|
|
41276
41330
|
const dir = pinnedVersionDir();
|
|
41277
|
-
if ((0,
|
|
41331
|
+
if ((0, import_node_fs71.existsSync)((0, import_node_path53.join)(dir, "bin", "lake")) && !opts.force) {
|
|
41278
41332
|
printInfo(`already installed at ${dir}`);
|
|
41279
41333
|
return;
|
|
41280
41334
|
}
|
|
@@ -41310,18 +41364,18 @@ function registerLeanCommand(program2) {
|
|
|
41310
41364
|
});
|
|
41311
41365
|
lean.command("remove").description("Delete the Verity-managed toolchain for the pinned version").action(() => {
|
|
41312
41366
|
const dir = pinnedVersionDir();
|
|
41313
|
-
if (!(0,
|
|
41367
|
+
if (!(0, import_node_fs71.existsSync)(dir)) {
|
|
41314
41368
|
printInfo("nothing to remove");
|
|
41315
41369
|
return;
|
|
41316
41370
|
}
|
|
41317
|
-
(0,
|
|
41371
|
+
(0, import_node_fs71.rmSync)(dir, { recursive: true, force: true });
|
|
41318
41372
|
printInfo(`removed ${dir}`);
|
|
41319
41373
|
});
|
|
41320
41374
|
}
|
|
41321
41375
|
|
|
41322
41376
|
// src/cli.ts
|
|
41323
|
-
program.name("verity").description("CLI for Verity quality gate service").version("0.34.0-experimental.
|
|
41324
|
-
installStderrLog(actionCommand.name(), process.argv.slice(2), "0.34.0-experimental.
|
|
41377
|
+
program.name("verity").description("CLI for Verity quality gate service").version("0.34.0-experimental.dc0010f").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) => {
|
|
41378
|
+
installStderrLog(actionCommand.name(), process.argv.slice(2), "0.34.0-experimental.dc0010f");
|
|
41325
41379
|
setUserNamedServiceUrl(program.opts().serviceUrl);
|
|
41326
41380
|
try {
|
|
41327
41381
|
await foldLegacyLocalCredential();
|