caveat-cli 0.16.3 → 0.17.0
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-PD5E6TFL.js → chunk-7FEOFAMA.js} +107 -58
- package/dist/{chunk-PD5E6TFL.js.map → chunk-7FEOFAMA.js.map} +1 -1
- package/dist/index.js +73 -64
- package/dist/index.js.map +1 -1
- package/dist/{server-ZMIRSFMH.js → server-STR2EAWZ.js} +2 -2
- package/package.json +3 -3
- /package/dist/{server-ZMIRSFMH.js.map → server-STR2EAWZ.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createRequire as __caveat_createRequire } from 'node:module';
|
|
|
3
3
|
const require = __caveat_createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
AUTO_SYNC_DEBOUNCE_MS,
|
|
6
|
+
AUTO_SYNC_RECORD_DEBOUNCE_MS,
|
|
6
7
|
CAVEAT_AUTO_SYNC_ENV,
|
|
7
8
|
KNOWLEDGE_GITIGNORE,
|
|
8
9
|
PublishScanError,
|
|
@@ -66,11 +67,12 @@ import {
|
|
|
66
67
|
struggleSearchText,
|
|
67
68
|
syncOwn,
|
|
68
69
|
toolErrorReminderText,
|
|
70
|
+
triggerAutoSync,
|
|
69
71
|
updateEntry,
|
|
70
72
|
userPromptSubmitReminderText,
|
|
71
73
|
writeDigestMarker,
|
|
72
74
|
writeUserConfigPatch
|
|
73
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-7FEOFAMA.js";
|
|
74
76
|
|
|
75
77
|
// ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js
|
|
76
78
|
var require_code = __commonJS({
|
|
@@ -8288,7 +8290,7 @@ function runStats(ctx) {
|
|
|
8288
8290
|
|
|
8289
8291
|
// src/commands/serve.ts
|
|
8290
8292
|
async function runServe(opts) {
|
|
8291
|
-
const { startServer } = await import("./server-
|
|
8293
|
+
const { startServer } = await import("./server-STR2EAWZ.js");
|
|
8292
8294
|
const { port, host } = startServer({ port: opts.port });
|
|
8293
8295
|
process.stdout.write(`[caveat] web portal: http://${host}:${port}/
|
|
8294
8296
|
`);
|
|
@@ -32361,6 +32363,21 @@ var StdioServerTransport = class {
|
|
|
32361
32363
|
// ../mcp/dist/context.js
|
|
32362
32364
|
import { homedir as homedir2 } from "node:os";
|
|
32363
32365
|
import { join as join9 } from "node:path";
|
|
32366
|
+
|
|
32367
|
+
// ../mcp/dist/autoSyncTrigger.js
|
|
32368
|
+
function triggerAutoSyncAfterWrite(caveatHome, logger) {
|
|
32369
|
+
try {
|
|
32370
|
+
triggerAutoSync({
|
|
32371
|
+
caveatHome,
|
|
32372
|
+
cliScript: process.argv[1] ?? "",
|
|
32373
|
+
debounceMs: AUTO_SYNC_RECORD_DEBOUNCE_MS
|
|
32374
|
+
});
|
|
32375
|
+
} catch (err) {
|
|
32376
|
+
logger.warn(`auto sync trigger failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
32377
|
+
}
|
|
32378
|
+
}
|
|
32379
|
+
|
|
32380
|
+
// ../mcp/dist/context.js
|
|
32364
32381
|
function buildMcpContext(overrides = {}) {
|
|
32365
32382
|
const userHome = overrides.userHome ?? homedir2();
|
|
32366
32383
|
const caveatHome = overrides.caveatHome ?? findCaveatHome(userHome);
|
|
@@ -32369,7 +32386,8 @@ function buildMcpContext(overrides = {}) {
|
|
|
32369
32386
|
const config2 = loadConfig(userConfigPath);
|
|
32370
32387
|
const paths = resolvePaths(caveatHome, config2.knowledgeRepo, userHome);
|
|
32371
32388
|
const db = openDb({ path: paths.dbPath, logger });
|
|
32372
|
-
|
|
32389
|
+
const onEntryWritten = overrides.onEntryWritten ?? (() => triggerAutoSyncAfterWrite(caveatHome, logger));
|
|
32390
|
+
return { caveatHome, userHome, userConfigPath, config: config2, paths, logger, db, onEntryWritten };
|
|
32373
32391
|
}
|
|
32374
32392
|
|
|
32375
32393
|
// ../mcp/dist/tools/search.js
|
|
@@ -32452,10 +32470,12 @@ var recordInputShape = {
|
|
|
32452
32470
|
category: external_exports.string().optional().describe("Directory under entries/ (e.g., gpu, claude-code). Default: misc")
|
|
32453
32471
|
};
|
|
32454
32472
|
function handleRecord(ctx, args) {
|
|
32455
|
-
|
|
32473
|
+
const result = recordEntry(args, {
|
|
32456
32474
|
db: ctx.db,
|
|
32457
32475
|
entriesRoot: ctx.paths.entriesDir
|
|
32458
32476
|
});
|
|
32477
|
+
ctx.onEntryWritten();
|
|
32478
|
+
return result;
|
|
32459
32479
|
}
|
|
32460
32480
|
|
|
32461
32481
|
// ../mcp/dist/tools/update.js
|
|
@@ -32492,11 +32512,13 @@ function handleUpdate(ctx, args) {
|
|
|
32492
32512
|
if (source !== "own") {
|
|
32493
32513
|
throw new Error("community \u30A8\u30F3\u30C8\u30EA\u306F\u8CFC\u8AAD\u7269\u3067\u3059; \u7DE8\u96C6\u306F\u4E0A\u6D41\u3067\u884C\u3063\u3066\u304F\u3060\u3055\u3044");
|
|
32494
32514
|
}
|
|
32495
|
-
|
|
32515
|
+
const result = updateEntry(args.id, args.patch, {
|
|
32496
32516
|
db: ctx.db,
|
|
32497
32517
|
entriesRoot: ctx.paths.entriesDir,
|
|
32498
32518
|
source
|
|
32499
32519
|
});
|
|
32520
|
+
ctx.onEntryWritten();
|
|
32521
|
+
return result;
|
|
32500
32522
|
}
|
|
32501
32523
|
|
|
32502
32524
|
// ../mcp/dist/tools/listRecent.js
|
|
@@ -32666,10 +32688,10 @@ async function runMcpServer() {
|
|
|
32666
32688
|
}
|
|
32667
32689
|
|
|
32668
32690
|
// src/commands/hookCmd.ts
|
|
32669
|
-
import { spawn as
|
|
32691
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
32670
32692
|
import {
|
|
32671
32693
|
chmodSync,
|
|
32672
|
-
existsSync as
|
|
32694
|
+
existsSync as existsSync9,
|
|
32673
32695
|
lstatSync,
|
|
32674
32696
|
mkdtempSync as mkdtempSync2,
|
|
32675
32697
|
mkdirSync as mkdirSync5,
|
|
@@ -32680,7 +32702,7 @@ import {
|
|
|
32680
32702
|
writeFileSync as writeFileSync5
|
|
32681
32703
|
} from "node:fs";
|
|
32682
32704
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
32683
|
-
import { basename, dirname as dirname6, join as
|
|
32705
|
+
import { basename, dirname as dirname6, join as join11 } from "node:path";
|
|
32684
32706
|
import { createHash, randomBytes } from "node:crypto";
|
|
32685
32707
|
|
|
32686
32708
|
// src/autoReindexTrigger.ts
|
|
@@ -32707,25 +32729,12 @@ function maybeTriggerAutoReindex(ctx) {
|
|
|
32707
32729
|
}
|
|
32708
32730
|
|
|
32709
32731
|
// src/autoSyncTrigger.ts
|
|
32710
|
-
|
|
32711
|
-
|
|
32712
|
-
|
|
32713
|
-
|
|
32714
|
-
|
|
32715
|
-
|
|
32716
|
-
const debounceMs = Number(process.env.CAVEAT_AUTO_SYNC_DEBOUNCE_MS ?? AUTO_SYNC_DEBOUNCE_MS);
|
|
32717
|
-
try {
|
|
32718
|
-
if (existsSync9(statePath) && Date.now() - statSync3(statePath).mtimeMs < debounceMs) return;
|
|
32719
|
-
} catch {
|
|
32720
|
-
}
|
|
32721
|
-
const cliScript = process.argv[1];
|
|
32722
|
-
if (!cliScript) throw new Error("current Caveat CLI script path is unavailable");
|
|
32723
|
-
const child = spawn2(
|
|
32724
|
-
process.execPath,
|
|
32725
|
-
[...process.execArgv, "--disable-warning=ExperimentalWarning", cliScript, "hook", "autosync"],
|
|
32726
|
-
{ detached: true, stdio: "ignore", windowsHide: true }
|
|
32727
|
-
);
|
|
32728
|
-
child.unref();
|
|
32732
|
+
function maybeTriggerAutoSync(ctx, debounceMs = AUTO_SYNC_DEBOUNCE_MS) {
|
|
32733
|
+
triggerAutoSync({
|
|
32734
|
+
caveatHome: ctx.caveatHome,
|
|
32735
|
+
cliScript: process.argv[1] ?? "",
|
|
32736
|
+
debounceMs
|
|
32737
|
+
});
|
|
32729
32738
|
}
|
|
32730
32739
|
|
|
32731
32740
|
// src/commands/hookCmd.ts
|
|
@@ -32783,7 +32792,7 @@ function searchCaveatsSafely(input) {
|
|
|
32783
32792
|
let hits;
|
|
32784
32793
|
try {
|
|
32785
32794
|
const ctx = buildContextSafely();
|
|
32786
|
-
if (!ctx || !
|
|
32795
|
+
if (!ctx || !existsSync9(ctx.paths.dbPath)) return [];
|
|
32787
32796
|
caveatHome = ctx.caveatHome;
|
|
32788
32797
|
db = openDb({ path: ctx.paths.dbPath });
|
|
32789
32798
|
const searchOptions = {
|
|
@@ -32891,7 +32900,7 @@ function stopSignalKey(signals, related) {
|
|
|
32891
32900
|
return createHash("sha256").update(body).digest("hex");
|
|
32892
32901
|
}
|
|
32893
32902
|
function stopStatePath(caveatHome, sessionId) {
|
|
32894
|
-
return
|
|
32903
|
+
return join11(caveatHome, CLAUDE_STOP_STATE_DIR, `${sanitizeClaudeStateId(sessionId)}.txt`);
|
|
32895
32904
|
}
|
|
32896
32905
|
function wasStopReminderQueued(caveatHome, sessionId, key) {
|
|
32897
32906
|
const path = stopStatePath(caveatHome, sessionId);
|
|
@@ -32903,7 +32912,7 @@ function wasStopReminderQueued(caveatHome, sessionId, key) {
|
|
|
32903
32912
|
}
|
|
32904
32913
|
function markStopReminderQueued(caveatHome, sessionId, key) {
|
|
32905
32914
|
const path = stopStatePath(caveatHome, sessionId);
|
|
32906
|
-
mkdirSync5(
|
|
32915
|
+
mkdirSync5(join11(caveatHome, CLAUDE_STOP_STATE_DIR), { recursive: true });
|
|
32907
32916
|
writeFileSync5(path, key, "utf-8");
|
|
32908
32917
|
}
|
|
32909
32918
|
function queueStopForSession(sessionId, signals, related) {
|
|
@@ -32989,9 +32998,9 @@ function spawnWorker(job) {
|
|
|
32989
32998
|
try {
|
|
32990
32999
|
root = workerRoot();
|
|
32991
33000
|
sweepStaleWorkerDirs(Date.now(), root);
|
|
32992
|
-
workDir = mkdtempSync2(
|
|
33001
|
+
workDir = mkdtempSync2(join11(root, "job-"));
|
|
32993
33002
|
chmodSync(workDir, 448);
|
|
32994
|
-
workFile =
|
|
33003
|
+
workFile = join11(workDir, `${randomBytes(4).toString("hex")}.json`);
|
|
32995
33004
|
writeFileSync5(workFile, JSON.stringify({ ...job, schemaVersion: "caveat-worker-job/v2" }), { encoding: "utf-8", mode: 384, flag: "wx" });
|
|
32996
33005
|
} catch (err) {
|
|
32997
33006
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -33006,7 +33015,7 @@ function spawnWorker(job) {
|
|
|
33006
33015
|
return;
|
|
33007
33016
|
}
|
|
33008
33017
|
try {
|
|
33009
|
-
const child =
|
|
33018
|
+
const child = spawn2(
|
|
33010
33019
|
process.execPath,
|
|
33011
33020
|
["--disable-warning=ExperimentalWarning", cliScript, "hook", "worker", workFile],
|
|
33012
33021
|
{ detached: true, stdio: "ignore", windowsHide: true }
|
|
@@ -33089,7 +33098,7 @@ function sweepStaleWorkerDirs(now = Date.now(), root = workerRoot()) {
|
|
|
33089
33098
|
}
|
|
33090
33099
|
for (const entry of entries) {
|
|
33091
33100
|
if (!entry.startsWith("job-")) continue;
|
|
33092
|
-
const path =
|
|
33101
|
+
const path = join11(root, entry);
|
|
33093
33102
|
try {
|
|
33094
33103
|
if (!isOwnedWorkerDir(path, root)) continue;
|
|
33095
33104
|
const stat = lstatSync(path);
|
|
@@ -33101,12 +33110,12 @@ function sweepStaleWorkerDirs(now = Date.now(), root = workerRoot()) {
|
|
|
33101
33110
|
}
|
|
33102
33111
|
}
|
|
33103
33112
|
function workerRoot(base = tmpdir2()) {
|
|
33104
|
-
const root =
|
|
33113
|
+
const root = join11(base, WORKER_ROOT);
|
|
33105
33114
|
mkdirSync5(root, { recursive: true, mode: 448 });
|
|
33106
33115
|
const stat = lstatSync(root);
|
|
33107
33116
|
const uid = typeof process.getuid === "function" ? process.getuid() : void 0;
|
|
33108
33117
|
if (!stat.isDirectory() || stat.isSymbolicLink() || !hasPrivateOwnership(stat, uid)) throw new Error("worker root is unsafe");
|
|
33109
|
-
const marker =
|
|
33118
|
+
const marker = join11(root, WORKER_MARKER);
|
|
33110
33119
|
try {
|
|
33111
33120
|
writeFileSync5(marker, "caveat-worker/v1\n", { mode: 384, flag: "wx" });
|
|
33112
33121
|
} catch (error51) {
|
|
@@ -33119,7 +33128,7 @@ function workerRoot(base = tmpdir2()) {
|
|
|
33119
33128
|
function isStaleWorkerJobDir(path) {
|
|
33120
33129
|
const entries = readdirSync2(path);
|
|
33121
33130
|
if (entries.length !== 1 || !entries[0].endsWith(".json")) return false;
|
|
33122
|
-
const file2 =
|
|
33131
|
+
const file2 = join11(path, entries[0]);
|
|
33123
33132
|
const stat = lstatSync(file2);
|
|
33124
33133
|
const uid = typeof process.getuid === "function" ? process.getuid() : void 0;
|
|
33125
33134
|
if (!stat.isFile() || stat.isSymbolicLink() || !hasPrivateOwnership(stat, uid)) return false;
|
|
@@ -33145,7 +33154,7 @@ function isKnownStaleWorkerJob(value) {
|
|
|
33145
33154
|
}
|
|
33146
33155
|
function writeLastReindex(caveatHome, value) {
|
|
33147
33156
|
try {
|
|
33148
|
-
writeFileSync5(
|
|
33157
|
+
writeFileSync5(join11(caveatHome, "index", ".last-reindex.json"), JSON.stringify(value), "utf-8");
|
|
33149
33158
|
} catch (err) {
|
|
33150
33159
|
const msg = err instanceof Error ? err.message : String(err);
|
|
33151
33160
|
process.stderr.write(`[caveat:hook] reindex status write error: ${msg}
|
|
@@ -33161,7 +33170,7 @@ async function runReindexWorker() {
|
|
|
33161
33170
|
return;
|
|
33162
33171
|
}
|
|
33163
33172
|
const ctx = buildContextSafely();
|
|
33164
|
-
if (!ctx || !
|
|
33173
|
+
if (!ctx || !existsSync9(ctx.paths.dbPath)) {
|
|
33165
33174
|
process.stderr.write("[caveat:hook] auto reindex skipped: index database does not exist\n");
|
|
33166
33175
|
return;
|
|
33167
33176
|
}
|
|
@@ -33229,7 +33238,7 @@ function buildToolErrorReminder(job, hits) {
|
|
|
33229
33238
|
const mode = hookCodexSidecarMode();
|
|
33230
33239
|
if (mode === "off") return base;
|
|
33231
33240
|
const projectRoot = process.cwd();
|
|
33232
|
-
const hasSidecarConfig =
|
|
33241
|
+
const hasSidecarConfig = existsSync9(join11(projectRoot, ".codex-sidecar.yml"));
|
|
33233
33242
|
if (mode === "auto" && !hasSidecarConfig) return base;
|
|
33234
33243
|
const advisory = runCodexSidecarAdvisory({
|
|
33235
33244
|
searchText: job.failureText,
|
|
@@ -33265,7 +33274,7 @@ function buildStopReminder(signals, related) {
|
|
|
33265
33274
|
const mode = hookCodexSidecarMode();
|
|
33266
33275
|
if (mode === "off") return base;
|
|
33267
33276
|
const projectRoot = process.cwd();
|
|
33268
|
-
const hasSidecarConfig =
|
|
33277
|
+
const hasSidecarConfig = existsSync9(join11(projectRoot, ".codex-sidecar.yml"));
|
|
33269
33278
|
if (mode === "auto" && !hasSidecarConfig) return base;
|
|
33270
33279
|
const advisory = runCodexSidecarAdvisory({
|
|
33271
33280
|
searchText: struggleSearchText(signals),
|
|
@@ -33408,10 +33417,10 @@ async function runHook(name, arg) {
|
|
|
33408
33417
|
}
|
|
33409
33418
|
|
|
33410
33419
|
// src/commands/codexHookCmd.ts
|
|
33411
|
-
import { spawn as
|
|
33412
|
-
import { existsSync as
|
|
33420
|
+
import { spawn as spawn3, spawnSync as spawnSync5 } from "node:child_process";
|
|
33421
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync6, readFileSync as readFileSync6, unlinkSync, writeFileSync as writeFileSync6 } from "node:fs";
|
|
33413
33422
|
import { homedir as homedir3, tmpdir as tmpdir3 } from "node:os";
|
|
33414
|
-
import { join as
|
|
33423
|
+
import { join as join12 } from "node:path";
|
|
33415
33424
|
import { createHash as createHash2, randomBytes as randomBytes2 } from "node:crypto";
|
|
33416
33425
|
var silentLogger2 = {
|
|
33417
33426
|
info: () => {
|
|
@@ -33463,7 +33472,7 @@ function searchCaveatsSafely2(input) {
|
|
|
33463
33472
|
let hits;
|
|
33464
33473
|
try {
|
|
33465
33474
|
const ctx = buildContextSafely2();
|
|
33466
|
-
if (!ctx || !
|
|
33475
|
+
if (!ctx || !existsSync10(ctx.paths.dbPath)) return [];
|
|
33467
33476
|
caveatHome = ctx.caveatHome;
|
|
33468
33477
|
db = openDb({ path: ctx.paths.dbPath });
|
|
33469
33478
|
const searchOptions = {
|
|
@@ -33547,7 +33556,7 @@ function processExitCodeFromText(text) {
|
|
|
33547
33556
|
return m ? Number(m[1]) : null;
|
|
33548
33557
|
}
|
|
33549
33558
|
function transcriptToolOutput(transcriptPath, toolUseId) {
|
|
33550
|
-
if (!transcriptPath || !toolUseId || !
|
|
33559
|
+
if (!transcriptPath || !toolUseId || !existsSync10(transcriptPath)) return null;
|
|
33551
33560
|
let raw = "";
|
|
33552
33561
|
try {
|
|
33553
33562
|
raw = readFileSync6(transcriptPath, "utf-8");
|
|
@@ -33699,7 +33708,7 @@ function stopSignalKey2(signals, related) {
|
|
|
33699
33708
|
return createHash2("sha256").update(body).digest("hex");
|
|
33700
33709
|
}
|
|
33701
33710
|
function stopStatePath2(caveatHome, sessionId) {
|
|
33702
|
-
return
|
|
33711
|
+
return join12(caveatHome, CODEX_STOP_STATE_DIR, `${sanitizeCodexStateId(sessionId)}.txt`);
|
|
33703
33712
|
}
|
|
33704
33713
|
function wasStopReminderQueued2(caveatHome, sessionId, key) {
|
|
33705
33714
|
const path = stopStatePath2(caveatHome, sessionId);
|
|
@@ -33711,7 +33720,7 @@ function wasStopReminderQueued2(caveatHome, sessionId, key) {
|
|
|
33711
33720
|
}
|
|
33712
33721
|
function markStopReminderQueued2(caveatHome, sessionId, key) {
|
|
33713
33722
|
const path = stopStatePath2(caveatHome, sessionId);
|
|
33714
|
-
mkdirSync6(
|
|
33723
|
+
mkdirSync6(join12(caveatHome, CODEX_STOP_STATE_DIR), { recursive: true });
|
|
33715
33724
|
writeFileSync6(path, key, "utf-8");
|
|
33716
33725
|
}
|
|
33717
33726
|
function queueStopForSession2(sessionId, signals, related) {
|
|
@@ -33806,7 +33815,7 @@ async function runCodexWorker(workFile) {
|
|
|
33806
33815
|
await processCodexWorkerJob(job);
|
|
33807
33816
|
process.exit(0);
|
|
33808
33817
|
}
|
|
33809
|
-
function runDiagnostics(codexHome = process.env.CODEX_HOME ??
|
|
33818
|
+
function runDiagnostics(codexHome = process.env.CODEX_HOME ?? join12(homedir3(), ".codex")) {
|
|
33810
33819
|
const features = spawnSync5("codex", ["features", "list"], {
|
|
33811
33820
|
encoding: "utf-8",
|
|
33812
33821
|
maxBuffer: 1024 * 1024,
|
|
@@ -33915,9 +33924,9 @@ async function runCodexHook(name, arg) {
|
|
|
33915
33924
|
}
|
|
33916
33925
|
|
|
33917
33926
|
// src/commands/pull.ts
|
|
33918
|
-
import { existsSync as
|
|
33927
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
33919
33928
|
async function runPull(ctx) {
|
|
33920
|
-
const hasCommunityDir =
|
|
33929
|
+
const hasCommunityDir = existsSync11(ctx.paths.communityDir);
|
|
33921
33930
|
if (!hasCommunityDir) {
|
|
33922
33931
|
ctx.logger.info(
|
|
33923
33932
|
"no community repos yet \u2014 add one with `caveat community add <github-url>`."
|
|
@@ -34019,7 +34028,7 @@ async function runSync(ctx, opts, dependencies = {}) {
|
|
|
34019
34028
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
34020
34029
|
import { closeSync, constants as constants3, fstatSync, lstatSync as lstatSync2, mkdirSync as mkdirSync7, mkdtempSync as mkdtempSync3, openSync, readSync as readSync2, realpathSync as realpathSync5, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
34021
34030
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
34022
|
-
import { basename as basename2, dirname as dirname7, join as
|
|
34031
|
+
import { basename as basename2, dirname as dirname7, join as join13 } from "node:path";
|
|
34023
34032
|
import { cwd, exit } from "node:process";
|
|
34024
34033
|
function runCodexSidecarDiagnostics(logger, opts) {
|
|
34025
34034
|
const plan = buildCodexSidecarDiagnosticsCommand({
|
|
@@ -34051,8 +34060,8 @@ function runCodexSidecarWithCaveats(ctx, workflow, prompt, opts) {
|
|
|
34051
34060
|
process.stdout.write(JSON.stringify({ status: "skipped", decision }, null, 2) + "\n");
|
|
34052
34061
|
exit(0);
|
|
34053
34062
|
}
|
|
34054
|
-
const contextDir = mkdtempSync3(
|
|
34055
|
-
const contextFile =
|
|
34063
|
+
const contextDir = mkdtempSync3(join13(tmpdir4(), "caveat-sidecar-context-"));
|
|
34064
|
+
const contextFile = join13(contextDir, "context.json");
|
|
34056
34065
|
let status2 = 1;
|
|
34057
34066
|
try {
|
|
34058
34067
|
const blocks = collectCaveatContextBlocks(ctx, {
|
|
@@ -34304,8 +34313,8 @@ function runCommunityRemove(ctx, handle, opts) {
|
|
|
34304
34313
|
|
|
34305
34314
|
// src/commands/factoryDiagnostics.ts
|
|
34306
34315
|
import { execFileSync } from "node:child_process";
|
|
34307
|
-
import { existsSync as
|
|
34308
|
-
import { join as
|
|
34316
|
+
import { existsSync as existsSync12, readFileSync as readFileSync7 } from "node:fs";
|
|
34317
|
+
import { join as join14 } from "node:path";
|
|
34309
34318
|
import { DatabaseSync } from "node:sqlite";
|
|
34310
34319
|
import { parse as parseToml2 } from "smol-toml";
|
|
34311
34320
|
var status = (ok, reason) => ({ status: ok ? "ready" : "not_ready", reason_code: ok ? "ready" : reason });
|
|
@@ -34317,8 +34326,8 @@ function isRecord2(value) {
|
|
|
34317
34326
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34318
34327
|
}
|
|
34319
34328
|
function claudeRegistration(home, nodePath, cliScriptPath) {
|
|
34320
|
-
const path =
|
|
34321
|
-
if (!
|
|
34329
|
+
const path = join14(home, ".claude.json");
|
|
34330
|
+
if (!existsSync12(path)) return status(false, "not_registered");
|
|
34322
34331
|
try {
|
|
34323
34332
|
const value = JSON.parse(readFileSync7(path, "utf8"));
|
|
34324
34333
|
if (!isRecord2(value) || !isRecord2(value.mcpServers)) return status(false, "not_registered");
|
|
@@ -34329,7 +34338,7 @@ function claudeRegistration(home, nodePath, cliScriptPath) {
|
|
|
34329
34338
|
}
|
|
34330
34339
|
function claudeHooks(home, nodePath, cliScriptPath) {
|
|
34331
34340
|
try {
|
|
34332
|
-
const settings = JSON.parse(readFileSync7(
|
|
34341
|
+
const settings = JSON.parse(readFileSync7(join14(home, ".claude", "settings.json"), "utf8"));
|
|
34333
34342
|
const present = (event, subcommand) => settings.hooks?.[event]?.some((entry) => entry.hooks?.some((item) => typeof item.command === "string" && isCanonicalCaveatClaudeHookCommand(item.command, subcommand, nodePath, cliScriptPath))) ?? false;
|
|
34334
34343
|
return { user_prompt_submit: hook(present("UserPromptSubmit", "user-prompt-submit")), post_tool_use: hook(present("PostToolUse", "post-tool-use")), post_tool_use_failure: hook(present("PostToolUseFailure", "post-tool-use")), stop: hook(present("Stop", "stop")) };
|
|
34335
34344
|
} catch {
|
|
@@ -34351,7 +34360,7 @@ function strictSearchSchema(db) {
|
|
|
34351
34360
|
return columns.map((column) => `${column.name}:${column.hidden}`).join(",") === "id:0,title:0,body:0,tags:0,entries_fts:1,rank:1";
|
|
34352
34361
|
}
|
|
34353
34362
|
function database(path) {
|
|
34354
|
-
if (!
|
|
34363
|
+
if (!existsSync12(path)) return { status: "not_ready", reason_code: "missing", schema_version: null, supported_schema_version: 3, migration_status: "unverified" };
|
|
34355
34364
|
try {
|
|
34356
34365
|
const db = new DatabaseSync(path, { readOnly: true });
|
|
34357
34366
|
try {
|
|
@@ -34376,8 +34385,8 @@ function database(path) {
|
|
|
34376
34385
|
}
|
|
34377
34386
|
}
|
|
34378
34387
|
function codexFeature(codexHome) {
|
|
34379
|
-
const path =
|
|
34380
|
-
if (!
|
|
34388
|
+
const path = join14(codexHome, "config.toml");
|
|
34389
|
+
if (!existsSync12(path)) return status(false, "feature_disabled");
|
|
34381
34390
|
try {
|
|
34382
34391
|
const config2 = parseToml2(readFileSync7(path, "utf8"));
|
|
34383
34392
|
if (!isRecord2(config2.features)) return status(false, "feature_disabled");
|
|
@@ -34388,7 +34397,7 @@ function codexFeature(codexHome) {
|
|
|
34388
34397
|
}
|
|
34389
34398
|
}
|
|
34390
34399
|
function codexHooks(codexHome, nodePath, cliScriptPath) {
|
|
34391
|
-
const value = JSON.parse(readFileSync7(
|
|
34400
|
+
const value = JSON.parse(readFileSync7(join14(codexHome, "hooks.json"), "utf8"));
|
|
34392
34401
|
if (!isRecord2(value) || !isRecord2(value.hooks)) throw Error("config_unreadable");
|
|
34393
34402
|
const hooks = value.hooks;
|
|
34394
34403
|
const present = (event, subcommand) => Array.isArray(hooks[event]) && hooks[event].some((entry) => isRecord2(entry) && Array.isArray(entry.hooks) && entry.hooks.some((item) => isRecord2(item) && typeof item.command === "string" && isCanonicalCaveatCodexHookCommand(item.command, subcommand, nodePath, cliScriptPath)));
|
|
@@ -34423,7 +34432,7 @@ function sync(own) {
|
|
|
34423
34432
|
return unverified("upstream_unavailable");
|
|
34424
34433
|
}
|
|
34425
34434
|
}
|
|
34426
|
-
function factoryDiagnostics(ctx, codexHome = process.env.CODEX_HOME ??
|
|
34435
|
+
function factoryDiagnostics(ctx, codexHome = process.env.CODEX_HOME ?? join14(ctx.userHome, ".codex")) {
|
|
34427
34436
|
const nodePath = process.execPath;
|
|
34428
34437
|
const cliScriptPath = process.argv[1] ?? "";
|
|
34429
34438
|
const db = database(ctx.paths.dbPath);
|