caveat-cli 0.20.1 → 0.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-G52CLPRY.js → chunk-JYXVT46B.js} +134 -55
- package/dist/chunk-JYXVT46B.js.map +1 -0
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/{server-2D6JIHWY.js → server-XI7ZOMPY.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-G52CLPRY.js.map +0 -1
- /package/dist/{server-2D6JIHWY.js.map → server-XI7ZOMPY.js.map} +0 -0
|
@@ -8976,16 +8976,22 @@ function openDb(opts) {
|
|
|
8976
8976
|
const parent = dirname(opts.path);
|
|
8977
8977
|
if (!existsSync(parent)) mkdirSync(parent, { recursive: true });
|
|
8978
8978
|
const db = new DatabaseSync(opts.path);
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
db.
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8979
|
+
try {
|
|
8980
|
+
db.exec("PRAGMA busy_timeout = 1000");
|
|
8981
|
+
db.exec("PRAGMA journal_mode = WAL");
|
|
8982
|
+
db.exec("PRAGMA foreign_keys = ON");
|
|
8983
|
+
const { user_version } = db.prepare("PRAGMA user_version").get();
|
|
8984
|
+
if (user_version === 0) {
|
|
8985
|
+
db.exec(readFileSync(SCHEMA_PATH, "utf-8"));
|
|
8986
|
+
} else {
|
|
8987
|
+
applyMigrations(db, user_version);
|
|
8988
|
+
backfillRoleTexts(db);
|
|
8989
|
+
}
|
|
8990
|
+
return db;
|
|
8991
|
+
} catch (error) {
|
|
8992
|
+
db.close();
|
|
8993
|
+
throw error;
|
|
8987
8994
|
}
|
|
8988
|
-
return db;
|
|
8989
8995
|
}
|
|
8990
8996
|
function backfillRoleTexts(db) {
|
|
8991
8997
|
let rows;
|
|
@@ -17379,11 +17385,82 @@ function compactRuntimeErrors(options2 = {}) {
|
|
|
17379
17385
|
}
|
|
17380
17386
|
var runtimeErrorsInternal = { validate, definitions, collectionEnabled, optionsFor, lock, readStore, ensureSafeDir, ensureSafeFile, secureWindowsAcl, assertPosix, now, validVersion };
|
|
17381
17387
|
|
|
17388
|
+
// ../../packages/core/dist/hookDiagnostics.js
|
|
17389
|
+
import { existsSync as existsSync17, readFileSync as readFileSync15, renameSync as renameSync5, rmSync as rmSync7, writeFileSync as writeFileSync10 } from "node:fs";
|
|
17390
|
+
import { dirname as dirname9, join as join14 } from "node:path";
|
|
17391
|
+
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
17392
|
+
var phases = ["json parse error", "context error", "search error", "markHit error", "query log error"];
|
|
17393
|
+
var kinds = ["invalid_json", "sqlite_busy", "sqlite_readonly", "sqlite_corrupt", "permission_denied", "missing_path", "other"];
|
|
17394
|
+
var codes = ["CAVEAT.CLAUDE_HOOK_FAILED", "CAVEAT.CODEX_HOOK_FAILED", "CAVEAT.CURSOR_HOOK_FAILED"];
|
|
17395
|
+
var SCHEMA = "caveat.local_hook_diagnostics.v1";
|
|
17396
|
+
var MAX_DETAILS = 64;
|
|
17397
|
+
function hookDiagnosticKind(error) {
|
|
17398
|
+
if (error instanceof SyntaxError) return "invalid_json";
|
|
17399
|
+
if (typeof error !== "object" || error === null) return "other";
|
|
17400
|
+
const err = error;
|
|
17401
|
+
if (err.code === "ERR_SQLITE_ERROR" && Number.isInteger(err.errcode)) {
|
|
17402
|
+
const code = err.errcode & 255;
|
|
17403
|
+
if (code === 5 || code === 6) return "sqlite_busy";
|
|
17404
|
+
if (code === 8) return "sqlite_readonly";
|
|
17405
|
+
if (code === 11 || code === 26) return "sqlite_corrupt";
|
|
17406
|
+
}
|
|
17407
|
+
if (err.code === "EACCES" || err.code === "EPERM") return "permission_denied";
|
|
17408
|
+
if (err.code === "ENOENT") return "missing_path";
|
|
17409
|
+
return "other";
|
|
17410
|
+
}
|
|
17411
|
+
function readDetails(path, isWin, options2) {
|
|
17412
|
+
if (!existsSync17(path)) return [];
|
|
17413
|
+
runtimeErrorsInternal.ensureSafeFile(path, isWin, options2);
|
|
17414
|
+
const value = JSON.parse(readFileSync15(path, "utf8"));
|
|
17415
|
+
if (!value || Object.keys(value).sort().join(",") !== "records,schema" || value.schema !== SCHEMA || !Array.isArray(value.records) || value.records.length > MAX_DETAILS) throw Error("hook_diagnostics_invalid");
|
|
17416
|
+
for (const record of value.records) {
|
|
17417
|
+
if (!record || Object.keys(record).sort().join(",") !== "at,error_code,kind,phase,version" || !Number.isFinite(Date.parse(record.at)) || new Date(record.at).toISOString() !== record.at || !runtimeErrorsInternal.validVersion(record.version) || !codes.includes(record.error_code) || !phases.includes(record.phase) || !kinds.includes(record.kind)) throw Error("hook_diagnostics_invalid");
|
|
17418
|
+
}
|
|
17419
|
+
return value.records;
|
|
17420
|
+
}
|
|
17421
|
+
function observeHookDiagnostic(errorCode, phase, error, options2 = {}) {
|
|
17422
|
+
if (!runtimeErrorsInternal.collectionEnabled(options2)) return;
|
|
17423
|
+
try {
|
|
17424
|
+
if (!codes.includes(errorCode) || !phases.includes(phase)) throw Error("hook_diagnostics_invalid");
|
|
17425
|
+
const { path: storePath, isWin } = runtimeErrorsInternal.optionsFor(options2);
|
|
17426
|
+
const path = join14(dirname9(storePath), "hook-diagnostics.json");
|
|
17427
|
+
runtimeErrorsInternal.lock(path, isWin, () => {
|
|
17428
|
+
const records = readDetails(path, isWin, options2);
|
|
17429
|
+
const version = options2.version ?? "0.0.0";
|
|
17430
|
+
if (!runtimeErrorsInternal.validVersion(version)) throw Error("hook_diagnostics_invalid");
|
|
17431
|
+
records.push({ at: runtimeErrorsInternal.now(options2), version, error_code: errorCode, phase, kind: hookDiagnosticKind(error) });
|
|
17432
|
+
const temporary = join14(dirname9(path), `.hook-diagnostics-${process.pid}-${randomBytes4(6).toString("hex")}`);
|
|
17433
|
+
try {
|
|
17434
|
+
writeFileSync10(temporary, JSON.stringify({ schema: SCHEMA, records: records.slice(-MAX_DETAILS) }) + "\n", { mode: 384, flag: "wx" });
|
|
17435
|
+
if (isWin) runtimeErrorsInternal.secureWindowsAcl(temporary, options2.aclRunner, false, true);
|
|
17436
|
+
runtimeErrorsInternal.ensureSafeFile(temporary, isWin, options2);
|
|
17437
|
+
renameSync5(temporary, path);
|
|
17438
|
+
} finally {
|
|
17439
|
+
rmSync7(temporary, { force: true });
|
|
17440
|
+
}
|
|
17441
|
+
}, options2);
|
|
17442
|
+
} catch {
|
|
17443
|
+
try {
|
|
17444
|
+
process.stderr.write("[caveat:hook-diagnostics] unavailable\n");
|
|
17445
|
+
} catch {
|
|
17446
|
+
}
|
|
17447
|
+
}
|
|
17448
|
+
}
|
|
17449
|
+
function localHookDiagnostics(options2 = {}) {
|
|
17450
|
+
if (!runtimeErrorsInternal.collectionEnabled(options2)) return { schema: SCHEMA, status: "disabled", records: [] };
|
|
17451
|
+
try {
|
|
17452
|
+
const { path: storePath, isWin } = runtimeErrorsInternal.optionsFor(options2);
|
|
17453
|
+
return { schema: SCHEMA, status: "ready", records: readDetails(join14(dirname9(storePath), "hook-diagnostics.json"), isWin, options2) };
|
|
17454
|
+
} catch {
|
|
17455
|
+
return { schema: SCHEMA, status: "unavailable", records: [] };
|
|
17456
|
+
}
|
|
17457
|
+
}
|
|
17458
|
+
|
|
17382
17459
|
// ../../packages/core/dist/runtimeErrorReport.js
|
|
17383
17460
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
17384
|
-
import { createHash as createHash8, createHmac as createHmac2, randomBytes as
|
|
17385
|
-
import { closeSync as closeSync2, constants, existsSync as
|
|
17386
|
-
import { dirname as
|
|
17461
|
+
import { createHash as createHash8, createHmac as createHmac2, randomBytes as randomBytes5, randomUUID, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
17462
|
+
import { closeSync as closeSync2, constants, existsSync as existsSync18, fstatSync, lstatSync as lstatSync2, openSync as openSync2, readFileSync as readFileSync16, renameSync as renameSync6, rmSync as rmSync8, writeFileSync as writeFileSync11 } from "node:fs";
|
|
17463
|
+
import { dirname as dirname10, isAbsolute as isAbsolute2, join as join15 } from "node:path";
|
|
17387
17464
|
var RUNTIME_ERROR_REPORT_SCHEMA_VERSION = "1.0";
|
|
17388
17465
|
var REPORT_STATE_SCHEMA = "caveat.runtime_error_report_state.v1";
|
|
17389
17466
|
var REPORT_STATUS_SCHEMA = "caveat.runtime_error_report_status.v1";
|
|
@@ -17426,7 +17503,7 @@ var validTime2 = (v) => typeof v === "string" && Number.isFinite(Date.parse(v))
|
|
|
17426
17503
|
var emptyState = () => ({ schema: REPORT_STATE_SCHEMA, last_attempt_at: null, last_outcome: null, last_accepted_at: null, next_attempt_at: null });
|
|
17427
17504
|
var result = (status, outcome = null, counts = {}) => ({ schema: REPORT_RESULT_SCHEMA, status, outcome, runtime_error_count: counts.errors ?? 0, resolution_count: counts.resolutions ?? 0, acknowledged_through: counts.acknowledged ?? null });
|
|
17428
17505
|
function reportStatePath(storePath) {
|
|
17429
|
-
return
|
|
17506
|
+
return join15(dirname10(storePath), "runtime-error-report.json");
|
|
17430
17507
|
}
|
|
17431
17508
|
function configuredCredentialPath(options2) {
|
|
17432
17509
|
try {
|
|
@@ -17460,7 +17537,7 @@ function loadCredential(path, isWin, options2) {
|
|
|
17460
17537
|
try {
|
|
17461
17538
|
const after = fstatSync(fd);
|
|
17462
17539
|
if (before.dev !== after.dev || before.ino !== after.ino || after.size > MAX_CREDENTIAL_BYTES) throw new ReportFailure("credential_unsafe");
|
|
17463
|
-
text =
|
|
17540
|
+
text = readFileSync16(fd, "utf8");
|
|
17464
17541
|
} finally {
|
|
17465
17542
|
closeSync2(fd);
|
|
17466
17543
|
}
|
|
@@ -17499,7 +17576,7 @@ function sameHex(expected, actual) {
|
|
|
17499
17576
|
}
|
|
17500
17577
|
function readReportState(path) {
|
|
17501
17578
|
try {
|
|
17502
|
-
const value = JSON.parse(
|
|
17579
|
+
const value = JSON.parse(readFileSync16(path, "utf8"));
|
|
17503
17580
|
if (!plain2(value) || value.schema !== REPORT_STATE_SCHEMA) return emptyState();
|
|
17504
17581
|
const time = (v) => validTime2(v) ? v : null;
|
|
17505
17582
|
const outcome = typeof value.last_outcome === "string" && Object.hasOwn(OUTCOME_RETRY_MS, value.last_outcome) ? value.last_outcome : null;
|
|
@@ -17509,23 +17586,23 @@ function readReportState(path) {
|
|
|
17509
17586
|
}
|
|
17510
17587
|
}
|
|
17511
17588
|
function writeReportState(path, state, isWin, options2) {
|
|
17512
|
-
ensureSafeDir2(
|
|
17513
|
-
const temporary =
|
|
17589
|
+
ensureSafeDir2(dirname10(path), isWin, options2);
|
|
17590
|
+
const temporary = join15(dirname10(path), `.runtime-error-report-${process.pid}-${randomBytes5(6).toString("hex")}`);
|
|
17514
17591
|
try {
|
|
17515
|
-
|
|
17592
|
+
writeFileSync11(temporary, `${JSON.stringify(state)}
|
|
17516
17593
|
`, { mode: 384, flag: "wx" });
|
|
17517
17594
|
if (isWin) secureWindowsAcl2(temporary, options2.aclRunner, false, true);
|
|
17518
17595
|
else assertPosix2(lstatSync2(temporary), 384);
|
|
17519
|
-
|
|
17596
|
+
renameSync6(temporary, path);
|
|
17520
17597
|
} finally {
|
|
17521
|
-
|
|
17598
|
+
rmSync8(temporary, { force: true });
|
|
17522
17599
|
}
|
|
17523
17600
|
}
|
|
17524
17601
|
function nextState(previous, outcome, at) {
|
|
17525
17602
|
return { schema: REPORT_STATE_SCHEMA, last_attempt_at: at, last_outcome: outcome, last_accepted_at: outcome === "accepted" ? at : previous.last_accepted_at, next_attempt_at: new Date(Date.parse(at) + OUTCOME_RETRY_MS[outcome]).toISOString() };
|
|
17526
17603
|
}
|
|
17527
17604
|
function claimPending(storePath, isWin, at, options2) {
|
|
17528
|
-
if (!
|
|
17605
|
+
if (!existsSync18(storePath)) return "nothing_pending";
|
|
17529
17606
|
return lock2(storePath, isWin, () => {
|
|
17530
17607
|
const statePath = reportStatePath(storePath);
|
|
17531
17608
|
const state = readReportState(statePath);
|
|
@@ -17629,8 +17706,8 @@ function runtimeErrorReportDue(options2 = {}) {
|
|
|
17629
17706
|
try {
|
|
17630
17707
|
if (!collectionEnabled2(options2) || configuredCredentialPath(options2) === null) return false;
|
|
17631
17708
|
const { path: storePath } = optionsFor2(options2);
|
|
17632
|
-
if (!
|
|
17633
|
-
const store = JSON.parse(
|
|
17709
|
+
if (!existsSync18(storePath)) return false;
|
|
17710
|
+
const store = JSON.parse(readFileSync16(storePath, "utf8"));
|
|
17634
17711
|
if (!plain2(store) || typeof store.next_sequence !== "number" || typeof store.acknowledged_through !== "number" || store.next_sequence - 1 <= store.acknowledged_through) return false;
|
|
17635
17712
|
const next = readReportState(reportStatePath(storePath)).next_attempt_at;
|
|
17636
17713
|
return next === null || Date.parse(now2(options2)) >= Date.parse(next);
|
|
@@ -17644,7 +17721,7 @@ function runtimeErrorReportStatus(options2 = {}) {
|
|
|
17644
17721
|
if (configuredCredentialPath(options2) === null) return { ...base, reporting: "not_configured", status: "not_applicable" };
|
|
17645
17722
|
try {
|
|
17646
17723
|
const { path: storePath, isWin } = optionsFor2(options2);
|
|
17647
|
-
const store =
|
|
17724
|
+
const store = existsSync18(storePath) ? readStore2(storePath, isWin, options2) : null;
|
|
17648
17725
|
const state = readReportState(reportStatePath(storePath));
|
|
17649
17726
|
return { schema: REPORT_STATUS_SCHEMA, reporting: "enabled", status: "ready", pending_count: store ? store.records.filter((record) => record.sequence > store.acknowledged_through).length : 0, last_attempt_at: state.last_attempt_at, last_outcome: state.last_outcome, last_accepted_at: state.last_accepted_at, next_attempt_at: state.next_attempt_at };
|
|
17650
17727
|
} catch {
|
|
@@ -17653,14 +17730,14 @@ function runtimeErrorReportStatus(options2 = {}) {
|
|
|
17653
17730
|
}
|
|
17654
17731
|
|
|
17655
17732
|
// ../../packages/core/dist/jevObservations.js
|
|
17656
|
-
import { createHash as createHash9, randomBytes as
|
|
17657
|
-
import { existsSync as
|
|
17658
|
-
import { join as
|
|
17733
|
+
import { createHash as createHash9, randomBytes as randomBytes6 } from "node:crypto";
|
|
17734
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync9, readFileSync as readFileSync17, readdirSync as readdirSync9, renameSync as renameSync7, rmSync as rmSync9, writeFileSync as writeFileSync12 } from "node:fs";
|
|
17735
|
+
import { join as join16 } from "node:path";
|
|
17659
17736
|
var JEV_OBSERVATION_SCHEMA = "caveat.jev_observation.v1";
|
|
17660
|
-
var directory = (home) =>
|
|
17737
|
+
var directory = (home) => join16(home, "jev-observations");
|
|
17661
17738
|
var pathFor = (home, id) => {
|
|
17662
17739
|
if (!/^[0-9a-f]{64}$/.test(id)) throw new Error("jev_observation_id_invalid");
|
|
17663
|
-
return
|
|
17740
|
+
return join16(directory(home), `${id}.json`);
|
|
17664
17741
|
};
|
|
17665
17742
|
function jevObservationId(host, sessionId, turnKey) {
|
|
17666
17743
|
return createHash9("sha256").update(`${host}\0${sessionId}\0${turnKey}`).digest("hex");
|
|
@@ -17671,14 +17748,14 @@ function validate2(value) {
|
|
|
17671
17748
|
if (item.schema !== JEV_OBSERVATION_SCHEMA || typeof item.id !== "string" || !/^[0-9a-f]{64}$/.test(item.id) || !["claude", "codex"].includes(item.host) || typeof item.observedAt !== "string" || typeof item.sessionId !== "string" || typeof item.projectRoot !== "string" || typeof item.transcriptPath !== "string" || !Array.isArray(item.turns) || item.turns.some((turn) => typeof turn.originSessionId !== "string" || !Number.isSafeInteger(turn.turnNumber) || typeof turn.truncated !== "boolean") || typeof item.thinkingAvailable !== "boolean" || typeof item.model !== "string" || ![item.repeatedProblem, item.clearlyStuck, item.struggleThreshold, item.matchThreshold].every((score) => typeof score === "number" && Number.isFinite(score) && score >= 0 && score <= 1) || typeof item.struggling !== "boolean" || !Array.isArray(item.termChoices) || item.termChoices.some((choice) => typeof choice.term !== "string" || typeof choice.probability !== "number") || item.noneProbability !== null && typeof item.noneProbability !== "number" || !Array.isArray(item.selectedTerms) || item.selectedTerms.some((term) => typeof term !== "string") || typeof item.query !== "string" || !Array.isArray(item.ftsHits) || item.ftsHits.some((ref) => typeof ref !== "string") || !Array.isArray(item.candidates) || item.candidates.some((candidate) => typeof candidate.ref !== "string" || typeof candidate.score !== "number" || !Number.isFinite(candidate.score)) || item.selectedRef !== null && typeof item.selectedRef !== "string" || item.noticeText !== null && typeof item.noticeText !== "string" || !["below_struggle_threshold", "no_terms", "no_candidates", "below_match_threshold", "matched"].includes(item.decision) || !["none", "pending", "delivered", "suppressed"].includes(item.delivery) || item.review !== null && (!item.review || typeof item.review !== "object" || !["correct", "incorrect", "missed", "none", "unclear"].includes(item.review.verdict) || typeof item.review.note !== "string" || typeof item.review.reviewedAt !== "string")) throw new Error("jev_observation_invalid");
|
|
17672
17749
|
}
|
|
17673
17750
|
function readJevObservation(home, id) {
|
|
17674
|
-
const value = JSON.parse(
|
|
17751
|
+
const value = JSON.parse(readFileSync17(pathFor(home, id), "utf8"));
|
|
17675
17752
|
validate2(value);
|
|
17676
17753
|
if (value.id !== id) throw new Error("jev_observation_id_mismatch");
|
|
17677
17754
|
return value;
|
|
17678
17755
|
}
|
|
17679
17756
|
function listJevObservations(home) {
|
|
17680
17757
|
const dir = directory(home);
|
|
17681
|
-
if (!
|
|
17758
|
+
if (!existsSync19(dir)) return [];
|
|
17682
17759
|
return readdirSync9(dir).filter((name) => /^[0-9a-f]{64}\.json$/.test(name)).map((name) => readJevObservation(home, name.slice(0, -5))).sort((a, b2) => b2.observedAt.localeCompare(a.observedAt) || b2.id.localeCompare(a.id));
|
|
17683
17760
|
}
|
|
17684
17761
|
function writeJevObservation(home, item) {
|
|
@@ -17686,13 +17763,13 @@ function writeJevObservation(home, item) {
|
|
|
17686
17763
|
const dir = directory(home);
|
|
17687
17764
|
mkdirSync9(dir, { recursive: true, mode: 448 });
|
|
17688
17765
|
const path = pathFor(home, item.id);
|
|
17689
|
-
const temporary = `${path}.${
|
|
17766
|
+
const temporary = `${path}.${randomBytes6(6).toString("hex")}.tmp`;
|
|
17690
17767
|
try {
|
|
17691
|
-
|
|
17768
|
+
writeFileSync12(temporary, `${JSON.stringify(item)}
|
|
17692
17769
|
`, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
17693
|
-
|
|
17770
|
+
renameSync7(temporary, path);
|
|
17694
17771
|
} finally {
|
|
17695
|
-
|
|
17772
|
+
rmSync9(temporary, { force: true });
|
|
17696
17773
|
}
|
|
17697
17774
|
}
|
|
17698
17775
|
function updateJevDelivery(home, id) {
|
|
@@ -17742,10 +17819,10 @@ function environmentAppliesToTask(environment, taskText, hostPlatform2) {
|
|
|
17742
17819
|
}
|
|
17743
17820
|
|
|
17744
17821
|
// ../../packages/core/dist/id.js
|
|
17745
|
-
import { randomBytes as
|
|
17822
|
+
import { randomBytes as randomBytes7 } from "node:crypto";
|
|
17746
17823
|
function randomHex(hexChars) {
|
|
17747
17824
|
const bytes = Math.ceil(hexChars / 2);
|
|
17748
|
-
return
|
|
17825
|
+
return randomBytes7(bytes).toString("hex").slice(0, hexChars);
|
|
17749
17826
|
}
|
|
17750
17827
|
function slugify(title, now3 = () => /* @__PURE__ */ new Date()) {
|
|
17751
17828
|
const lowered = title.toLowerCase();
|
|
@@ -17770,8 +17847,8 @@ function generateSourceSession(now3 = () => /* @__PURE__ */ new Date()) {
|
|
|
17770
17847
|
}
|
|
17771
17848
|
|
|
17772
17849
|
// ../../packages/core/dist/writer.js
|
|
17773
|
-
import { existsSync as
|
|
17774
|
-
import { dirname as
|
|
17850
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync10, writeFileSync as writeFileSync13 } from "node:fs";
|
|
17851
|
+
import { dirname as dirname11 } from "node:path";
|
|
17775
17852
|
function buildEntry(frontmatter, sections) {
|
|
17776
17853
|
const bodyParts = [];
|
|
17777
17854
|
for (const [heading, content2] of Object.entries(sections)) {
|
|
@@ -17789,14 +17866,14 @@ ${body}${body ? "\n" : ""}`;
|
|
|
17789
17866
|
return { content, body };
|
|
17790
17867
|
}
|
|
17791
17868
|
function writeEntryFile(filePath, content) {
|
|
17792
|
-
const dir =
|
|
17793
|
-
if (!
|
|
17794
|
-
|
|
17869
|
+
const dir = dirname11(filePath);
|
|
17870
|
+
if (!existsSync20(dir)) mkdirSync10(dir, { recursive: true });
|
|
17871
|
+
writeFileSync13(filePath, content, "utf-8");
|
|
17795
17872
|
}
|
|
17796
17873
|
|
|
17797
17874
|
// ../../packages/core/dist/record.js
|
|
17798
17875
|
import { statSync as statSync8 } from "node:fs";
|
|
17799
|
-
import { join as
|
|
17876
|
+
import { join as join17 } from "node:path";
|
|
17800
17877
|
var DEFAULT_CATEGORY = "misc";
|
|
17801
17878
|
function recordEntry(input, opts) {
|
|
17802
17879
|
const now3 = opts.now ?? (() => /* @__PURE__ */ new Date());
|
|
@@ -17832,7 +17909,7 @@ function recordEntry(input, opts) {
|
|
|
17832
17909
|
const built = buildEntry(frontmatter, sections);
|
|
17833
17910
|
const category = input.category ?? DEFAULT_CATEGORY;
|
|
17834
17911
|
const relPath = `${category}/${id}.md`;
|
|
17835
|
-
const filePath =
|
|
17912
|
+
const filePath = join17(opts.entriesRoot, relPath);
|
|
17836
17913
|
writeEntryFile(filePath, built.content);
|
|
17837
17914
|
const stat = statSync8(filePath);
|
|
17838
17915
|
upsertEntry(opts.db, {
|
|
@@ -17862,8 +17939,8 @@ function formatYmd(d) {
|
|
|
17862
17939
|
}
|
|
17863
17940
|
|
|
17864
17941
|
// ../../packages/core/dist/update.js
|
|
17865
|
-
import { readFileSync as
|
|
17866
|
-
import { join as
|
|
17942
|
+
import { readFileSync as readFileSync18, statSync as statSync9, writeFileSync as writeFileSync14 } from "node:fs";
|
|
17943
|
+
import { join as join18 } from "node:path";
|
|
17867
17944
|
var IMMUTABLE_KEYS = /* @__PURE__ */ new Set([
|
|
17868
17945
|
"id",
|
|
17869
17946
|
"created_at",
|
|
@@ -17882,8 +17959,8 @@ function updateEntry(id, patch, opts) {
|
|
|
17882
17959
|
throw new Error(`caveat not found: id=${id} source=${source}`);
|
|
17883
17960
|
}
|
|
17884
17961
|
const relPath = row.path;
|
|
17885
|
-
const filePath =
|
|
17886
|
-
const raw =
|
|
17962
|
+
const filePath = join18(opts.entriesRoot, relPath);
|
|
17963
|
+
const raw = readFileSync18(filePath, "utf-8");
|
|
17887
17964
|
const parsed = parseMarkdown(raw);
|
|
17888
17965
|
if (patch.frontmatter) {
|
|
17889
17966
|
for (const key of Object.keys(patch.frontmatter)) {
|
|
@@ -17924,7 +18001,7 @@ function updateEntry(id, patch, opts) {
|
|
|
17924
18001
|
}
|
|
17925
18002
|
}
|
|
17926
18003
|
const built = buildEntry(mergedFrontmatter, mergedSections);
|
|
17927
|
-
|
|
18004
|
+
writeFileSync14(filePath, built.content, "utf-8");
|
|
17928
18005
|
const stat = statSync9(filePath);
|
|
17929
18006
|
upsertEntry(opts.db, {
|
|
17930
18007
|
id,
|
|
@@ -17961,8 +18038,8 @@ function markHit(db, keys, now3 = () => (/* @__PURE__ */ new Date()).toISOString
|
|
|
17961
18038
|
}
|
|
17962
18039
|
|
|
17963
18040
|
// ../../packages/core/dist/hookQueryLog.js
|
|
17964
|
-
import { appendFileSync, chmodSync as chmodSync2, mkdirSync as mkdirSync11, renameSync as
|
|
17965
|
-
import { join as
|
|
18041
|
+
import { appendFileSync, chmodSync as chmodSync2, mkdirSync as mkdirSync11, renameSync as renameSync8, statSync as statSync10, unlinkSync as unlinkSync3 } from "node:fs";
|
|
18042
|
+
import { join as join19, resolve as resolve3 } from "node:path";
|
|
17966
18043
|
var CAVEAT_HOOK_QUERY_LOG_ENV = "CAVEAT_HOOK_QUERY_LOG";
|
|
17967
18044
|
var HOOK_QUERY_LOG_MAX_BYTES = 1024 * 1024;
|
|
17968
18045
|
var HOOK_QUERY_LOG_MAX_QUERY_CODE_UNITS = 1e3;
|
|
@@ -17970,7 +18047,7 @@ var fsDependencies = {
|
|
|
17970
18047
|
appendFileSync,
|
|
17971
18048
|
chmodSync: chmodSync2,
|
|
17972
18049
|
mkdirSync: mkdirSync11,
|
|
17973
|
-
renameSync:
|
|
18050
|
+
renameSync: renameSync8,
|
|
17974
18051
|
statSync: statSync10,
|
|
17975
18052
|
unlinkSync: unlinkSync3
|
|
17976
18053
|
};
|
|
@@ -17986,8 +18063,8 @@ function chmodExistingFile(path, dependencies) {
|
|
|
17986
18063
|
}
|
|
17987
18064
|
function logHookQueryMiss(miss, dependencies = fsDependencies) {
|
|
17988
18065
|
if (process.env[CAVEAT_HOOK_QUERY_LOG_ENV] !== "on") return;
|
|
17989
|
-
const metricsDir =
|
|
17990
|
-
const activePath =
|
|
18066
|
+
const metricsDir = join19(resolve3(miss.caveatHome), "metrics");
|
|
18067
|
+
const activePath = join19(metricsDir, "hook-search-misses.jsonl");
|
|
17991
18068
|
const backupPath = `${activePath}.1`;
|
|
17992
18069
|
const record = JSON.stringify({
|
|
17993
18070
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -18111,6 +18188,8 @@ export {
|
|
|
18111
18188
|
acknowledgeRuntimeErrors,
|
|
18112
18189
|
setRuntimeErrorStatus,
|
|
18113
18190
|
compactRuntimeErrors,
|
|
18191
|
+
observeHookDiagnostic,
|
|
18192
|
+
localHookDiagnostics,
|
|
18114
18193
|
sendRuntimeErrorReport,
|
|
18115
18194
|
runtimeErrorReportDue,
|
|
18116
18195
|
runtimeErrorReportStatus,
|
|
@@ -18141,4 +18220,4 @@ strip-bom-string/index.js:
|
|
|
18141
18220
|
js-yaml/dist/js-yaml.mjs:
|
|
18142
18221
|
(*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
|
|
18143
18222
|
*/
|
|
18144
|
-
//# sourceMappingURL=chunk-
|
|
18223
|
+
//# sourceMappingURL=chunk-JYXVT46B.js.map
|