caveat-cli 0.14.7 → 0.14.8

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/index.js CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  buildCodexSidecarReadOnlySmokeCommand,
11
11
  buildCodexSidecarRunCommand,
12
12
  caveatEntriesToSidecarContextBlocks,
13
+ cleanupStalePendingDirs,
13
14
  communityAdd,
14
15
  communityList,
15
16
  communityPull,
@@ -26,6 +27,7 @@ import {
26
27
  listStale,
27
28
  loadConfig,
28
29
  markHit,
30
+ maybeSweepPendingDirs,
29
31
  openDb,
30
32
  readCodexSessionSignals,
31
33
  readSessionSignals,
@@ -40,7 +42,7 @@ import {
40
42
  toolErrorReminderText,
41
43
  updateEntry,
42
44
  userPromptSubmitReminderText
43
- } from "./chunk-EH3S6X6X.js";
45
+ } from "./chunk-ECC5LJZF.js";
44
46
 
45
47
  // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js
46
48
  var require_code = __commonJS({
@@ -7070,6 +7072,17 @@ async function runInit(ctx, opts = { skipClaude: false, dryRun: false }) {
7070
7072
  } else {
7071
7073
  ctx.logger.info(`[dry-run] db path: ${ctx.paths.dbPath}`);
7072
7074
  }
7075
+ const staleDays = opts.pendingStaleDays ?? 7;
7076
+ if (opts.dryRun) {
7077
+ ctx.logger.info(`[dry-run] would sweep pending dirs older than ${staleDays}d`);
7078
+ } else {
7079
+ const swept = cleanupStalePendingDirs(ctx.caveatHome, { staleDays });
7080
+ if (swept.removed.length > 0) {
7081
+ ctx.logger.info(
7082
+ `pending dirs swept: removed ${swept.removed.length} (kept ${swept.kept}, threshold ${staleDays}d)`
7083
+ );
7084
+ }
7085
+ }
7073
7086
  ctx.logger.info(
7074
7087
  "tip: subscribe to a group repo with `caveat community add <github-url>`, then `caveat pull`."
7075
7088
  );
@@ -7345,7 +7358,7 @@ function runStats(ctx) {
7345
7358
 
7346
7359
  // src/commands/serve.ts
7347
7360
  async function runServe(opts) {
7348
- const { startServer } = await import("./server-RWVXGVXK.js");
7361
+ const { startServer } = await import("./server-YQ4DJ2H7.js");
7349
7362
  const { port, host } = startServer({ port: opts.port });
7350
7363
  process.stdout.write(`[caveat] web portal: http://${host}:${port}/
7351
7364
  `);
@@ -32164,6 +32177,11 @@ async function runHook(name, arg) {
32164
32177
  process.exit(0);
32165
32178
  }
32166
32179
  if (name === "stop") {
32180
+ try {
32181
+ const ctx = buildContextSafely();
32182
+ if (ctx) maybeSweepPendingDirs(ctx.caveatHome);
32183
+ } catch {
32184
+ }
32167
32185
  if (payload.stop_hook_active === true) process.exit(0);
32168
32186
  const transcriptPath = typeof payload.transcript_path === "string" ? payload.transcript_path : "";
32169
32187
  const signals = transcriptPath ? loadSignalsSafely(transcriptPath) : null;
@@ -33049,13 +33067,26 @@ var program = new Command();
33049
33067
  program.name("caveat").description("External spec gotcha knowledge base CLI").version(CAVEAT_VERSION);
33050
33068
  program.command("init").description(
33051
33069
  "Initialize ~/.caveatrc.json, ~/.caveat/, and register Claude Code integration. Add knowledge sources later with `caveat community add <github-url>`."
33052
- ).option("--skip-claude", "skip Claude Code MCP + hook registration", false).option("--dry-run", "show planned changes without writing", false).action(async (opts) => {
33053
- const ctx = buildContext(stdoutLogger);
33054
- await runInit(ctx, {
33055
- skipClaude: opts.skipClaude,
33056
- dryRun: opts.dryRun
33057
- });
33058
- });
33070
+ ).option("--skip-claude", "skip Claude Code MCP + hook registration", false).option("--dry-run", "show planned changes without writing", false).option(
33071
+ "--pending-stale-days <days>",
33072
+ "sweep `<caveatHome>/pending/<sessionId>/` whose newest entry is older than this (default 7)",
33073
+ (raw) => {
33074
+ const n = Number.parseInt(raw, 10);
33075
+ if (!Number.isFinite(n) || n < 0) {
33076
+ throw new Error(`--pending-stale-days expects a non-negative integer (got "${raw}")`);
33077
+ }
33078
+ return n;
33079
+ }
33080
+ ).action(
33081
+ async (opts) => {
33082
+ const ctx = buildContext(stdoutLogger);
33083
+ await runInit(ctx, {
33084
+ skipClaude: opts.skipClaude,
33085
+ dryRun: opts.dryRun,
33086
+ pendingStaleDays: opts.pendingStaleDays
33087
+ });
33088
+ }
33089
+ );
33059
33090
  program.command("uninstall").description("Remove Claude Code MCP server and hooks registered by `caveat init`").option("--dry-run", "show planned changes without writing", false).action((opts) => {
33060
33091
  const ctx = buildContext(stdoutLogger);
33061
33092
  runUninstall(ctx, { dryRun: opts.dryRun });