cc-hindsight 1.1.0 → 1.3.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/cli.js CHANGED
@@ -10,7 +10,7 @@ import { stripVTControlCharacters, styleText } from "node:util";
10
10
  import readline from "node:readline";
11
11
  import { spinner } from "@clack/prompts";
12
12
  //#region package.json
13
- var version = "1.1.0";
13
+ var version = "1.3.0";
14
14
  var description = "Mine your coding-agent session history (Claude Code, kiro-cli) into a oneshot prompt library and CLAUDE.md/AGENTS.md preferences. The prompt you'd write if you knew then what you know now.";
15
15
  //#endregion
16
16
  //#region src/commands/_shared.ts
@@ -317,27 +317,52 @@ const defaultSpawn$1 = (cmd, args, input) => new Promise((resolve) => {
317
317
  "ignore",
318
318
  "ignore"
319
319
  ] });
320
- child.on("error", (err) => resolve({
320
+ child.unref();
321
+ let settled = false;
322
+ const settle = (v) => {
323
+ if (settled) return;
324
+ settled = true;
325
+ child.stdin?.destroy();
326
+ resolve(v);
327
+ };
328
+ child.on("error", (err) => settle({
321
329
  code: null,
322
330
  error: err.message
323
331
  }));
324
- child.on("close", (code) => resolve({ code }));
332
+ child.on("close", (code) => settle({ code }));
333
+ child.on("exit", (code) => settle({ code }));
334
+ child.stdin?.on("error", () => {});
335
+ child.stdin?.once("finish", () => child.stdin?.unref?.());
325
336
  child.stdin?.write(input);
326
337
  child.stdin?.end();
327
338
  });
328
339
  /** Copy text to the system clipboard. Reports which tool was used, or why not. */
329
340
  async function copyToClipboard(text, io = {}) {
330
341
  const { cmd, args } = clipboardCommand(io.platform, io.env);
331
- const result = await (io.spawn ?? defaultSpawn$1)(cmd, args, text);
332
- if (result.code === 0) return {
333
- ok: true,
334
- tool: cmd
335
- };
336
- return {
337
- ok: false,
338
- tool: cmd,
339
- error: result.error ?? `${cmd} exited with code ${result.code}`
340
- };
342
+ const spawn = io.spawn ?? defaultSpawn$1;
343
+ const timeoutMs = io.timeoutMs ?? 5e3;
344
+ let timer;
345
+ const timeout = new Promise((resolve) => {
346
+ timer = setTimeout(() => resolve({
347
+ code: null,
348
+ error: `${cmd} timed out after ${timeoutMs}ms`
349
+ }), timeoutMs);
350
+ timer.unref?.();
351
+ });
352
+ try {
353
+ const result = await Promise.race([spawn(cmd, args, text), timeout]);
354
+ if (result.code === 0) return {
355
+ ok: true,
356
+ tool: cmd
357
+ };
358
+ return {
359
+ ok: false,
360
+ tool: cmd,
361
+ error: result.error ?? `${cmd} exited with code ${result.code}`
362
+ };
363
+ } finally {
364
+ if (timer) clearTimeout(timer);
365
+ }
341
366
  }
342
367
  //#endregion
343
368
  //#region src/ui/style.ts
@@ -533,6 +558,11 @@ function renderPlan(plan) {
533
558
  }
534
559
  function ask(question, input, output) {
535
560
  if (input.readableEnded) return Promise.resolve("");
561
+ let raw = "";
562
+ const tap = (chunk) => {
563
+ raw += chunk.toString();
564
+ };
565
+ input.on("data", tap);
536
566
  const rl = readline.createInterface({
537
567
  input,
538
568
  output
@@ -542,11 +572,12 @@ function ask(question, input, output) {
542
572
  const done = (answer) => {
543
573
  if (answered) return;
544
574
  answered = true;
575
+ input.off("data", tap);
545
576
  rl.close();
546
577
  resolve(answer);
547
578
  };
548
579
  rl.question(question, done);
549
- rl.on("close", () => done(""));
580
+ rl.on("close", () => done(raw.split(/\r?\n/)[0] ?? ""));
550
581
  });
551
582
  }
552
583
  /**
@@ -1017,6 +1048,42 @@ function buildClusterPrompt(digests, origins) {
1017
1048
  "=== END SESSION DIGESTS ==="
1018
1049
  ].join("\n");
1019
1050
  }
1051
+ /**
1052
+ * Build the stage-2b merge prompt (windowed clustering only). When the corpus
1053
+ * exceeds the input budget, digests are clustered in windows; each window
1054
+ * produces tasks that cannot see the other windows' sessions, so the same
1055
+ * underlying goal can surface as two tasks. This prompt shows every task's
1056
+ * identity card and asks ONLY for cross-task unification, never re-grouping
1057
+ * of members.
1058
+ */
1059
+ function buildMergePrompt(tasks) {
1060
+ const blocks = tasks.map((t) => [
1061
+ `- slug: ${t.slug}`,
1062
+ ` title: ${t.title}`,
1063
+ ` rationale: ${t.rationale}`,
1064
+ ` sessions: ${t.members.length}`
1065
+ ].join("\n"));
1066
+ return [
1067
+ "You are unifying tasks that were produced by clustering a large corpus of",
1068
+ "coding-agent sessions in independent windows. Tasks from different windows",
1069
+ "may describe the SAME underlying goal. Below is every task's identity.",
1070
+ "",
1071
+ "Identify groups of two or more tasks that pursue the same underlying goal:",
1072
+ "- For each group output one entry in \"merges\" with:",
1073
+ " - \"slugs\": the existing slugs to unify (copied VERBATIM, two or more);",
1074
+ " - \"slug\": a unique kebab-case identifier of 2-5 words for the unified task;",
1075
+ " - \"title\": a short human-readable title;",
1076
+ " - \"rationale\": one or two sentences on why these are one task.",
1077
+ "- Use ONLY the slugs listed below; never invent slugs in \"slugs\".",
1078
+ "- List each existing slug in AT MOST one merge group.",
1079
+ "- Tasks you do not mention stay unchanged. If nothing overlaps, return",
1080
+ " { \"merges\": [] }.",
1081
+ "",
1082
+ `=== TASKS (${tasks.length}) ===`,
1083
+ ...blocks,
1084
+ "=== END TASKS ==="
1085
+ ].join("\n");
1086
+ }
1020
1087
  //#endregion
1021
1088
  //#region src/claude/prompts/digest.ts
1022
1089
  /** Human-facing name of a session's source backend. */
@@ -1075,6 +1142,19 @@ const ClusterSchema = z.object({
1075
1142
  /** Low-substance / trivia sessions that author no oneshot. */
1076
1143
  misc: z.array(z.string())
1077
1144
  });
1145
+ /**
1146
+ * Stage 2b, windowed clustering only: which window-local tasks are really the
1147
+ * same task. `merges` lists groups of existing slugs to unify; tasks not
1148
+ * mentioned stay as they are. Empty `merges` means nothing overlaps.
1149
+ */
1150
+ const ClusterMergeSchema = z.object({ merges: z.array(z.object({
1151
+ /** Slugs of the existing tasks to unify (two or more). */
1152
+ slugs: z.array(z.string()),
1153
+ /** Replacement identity for the unified task. */
1154
+ slug: z.string(),
1155
+ title: z.string(),
1156
+ rationale: z.string()
1157
+ })) });
1078
1158
  /** Stage 3 — author: one realistic oneshot + observed preferences per task. */
1079
1159
  const AuthorSchema = z.object({
1080
1160
  slug: z.string(),
@@ -1173,12 +1253,14 @@ function defaultSpawn(bin, args, opts) {
1173
1253
  child.stderr?.on("data", (d) => {
1174
1254
  stderr += d.toString();
1175
1255
  });
1176
- child.on("error", (err) => {
1177
- clearTimers();
1178
- reject(err);
1179
- });
1180
- child.on("close", (code, signal) => {
1256
+ let settled = false;
1257
+ const settle = (code, signal) => {
1258
+ if (settled) return;
1259
+ settled = true;
1181
1260
  clearTimers();
1261
+ child.stdout?.destroy();
1262
+ child.stderr?.destroy();
1263
+ child.stdin?.destroy();
1182
1264
  resolve({
1183
1265
  code,
1184
1266
  signal,
@@ -1186,6 +1268,20 @@ function defaultSpawn(bin, args, opts) {
1186
1268
  stderr,
1187
1269
  timedOut
1188
1270
  });
1271
+ };
1272
+ child.on("error", (err) => {
1273
+ if (settled) return;
1274
+ settled = true;
1275
+ clearTimers();
1276
+ child.stdout?.destroy();
1277
+ child.stderr?.destroy();
1278
+ child.stdin?.destroy();
1279
+ reject(err);
1280
+ });
1281
+ child.on("close", (code, signal) => settle(code, signal));
1282
+ child.on("exit", (code, signal) => {
1283
+ if (settled) return;
1284
+ setImmediate(() => settle(code, signal));
1189
1285
  });
1190
1286
  child.stdin?.on("error", () => {});
1191
1287
  child.stdin?.write(opts.input);
@@ -1202,11 +1298,27 @@ function snippet$2(s, max = 500) {
1202
1298
  const t = s.trim();
1203
1299
  return t.length > max ? `${t.slice(0, max)}…` : t;
1204
1300
  }
1205
- /** Strip a Markdown code fence if the model wrapped its JSON in one. */
1301
+ /**
1302
+ * Strip a Markdown code fence if the model wrapped its JSON in one.
1303
+ *
1304
+ * This is the last line of defense on the schema-in-prompt path (no
1305
+ * `--json-schema`, and the kiro runner always): the model's raw text is all we
1306
+ * get, and a fence we fail to strip becomes a JSON parse error that burns the
1307
+ * one corrective retry. Verified against the live CLI on that path: the model
1308
+ * really does answer with a ```json fence even when told to respond ONLY with
1309
+ * JSON, so the neighboring shapes are worth tolerating too.
1310
+ *
1311
+ * The anchored form only matched a fence that was the WHOLE string, so a single
1312
+ * "Here you go:" preamble or "Hope that helps!" sign-off defeated it, as did an
1313
+ * uppercase ```JSON tag (which got captured into the body). Now: find the first
1314
+ * fenced block anywhere in the text, case-insensitively; fall back to the
1315
+ * trimmed text so non-fenced input and unterminated fences pass through
1316
+ * unchanged and the caller can report the real content in its snippet.
1317
+ */
1206
1318
  function stripFence(text) {
1207
1319
  const trimmed = text.trim();
1208
- const fence = trimmed.match(/^```(?:json)?\s*\n?([\s\S]*?)\n?```$/);
1209
- return fence?.[1] ? fence[1].trim() : trimmed;
1320
+ const body = trimmed.match(/```[a-z]*[ \t]*\r?\n?([\s\S]*?)\r?\n?```/i)?.[1]?.trim();
1321
+ return body ? body : trimmed;
1210
1322
  }
1211
1323
  /**
1212
1324
  * Append the JSON schema to a prompt for backends that cannot validate
@@ -1251,10 +1363,12 @@ async function runWithCorrectiveRetry(basePrompt, schema, attemptFn, makeExhaust
1251
1363
  * runners/shared.ts. A shim at src/claude/runner.ts re-exports both halves,
1252
1364
  * including a `ClaudeRunnerError` class alias so `instanceof` keeps working.)
1253
1365
  *
1254
- * Verified against Claude Code CLI 2.1.207 (macOS):
1366
+ * Verified against Claude Code CLI 2.1.207 (macOS) and 2.1.220 (Linux):
1255
1367
  * - `claude -p --output-format json` → single JSON envelope on stdout
1256
1368
  * ({ type, subtype, is_error, result, session_id, total_cost_usd, usage, ... });
1257
- * `result` carries the model's text output.
1369
+ * `result` carries the model's text output. With verbose mode ON stdout is
1370
+ * instead a JSON ARRAY of stream events terminated by the `type: "result"`
1371
+ * event; both shapes are accepted (see `selectEnvelope`).
1258
1372
  * - `--json-schema <json>` → server-side structured-output validation.
1259
1373
  * - `--tools ""` → disable all built-in tools.
1260
1374
  * - `--model <name>` → model pass-through.
@@ -1265,8 +1379,44 @@ async function runWithCorrectiveRetry(basePrompt, schema, attemptFn, makeExhaust
1265
1379
  const CLAUDE_INSTALL_HINT = "`claude` CLI not found on PATH. Install it with `npm install -g @anthropic-ai/claude-code` (docs: https://docs.claude.com/en/docs/claude-code). Deterministic commands (scan/export) work without it — only distill needs claude.";
1266
1380
  let capabilitiesCache = null;
1267
1381
  /**
1382
+ * Fallback help flag, tried when the first `--help` looks like a WRAPPER's own
1383
+ * help rather than the native binary's. A distribution wrapper (one observed in
1384
+ * the wild resolves credentials and model routing, then execs the native binary)
1385
+ * documents only its own options and forwards everything else through; this flag
1386
+ * is its documented escape hatch to the real help.
1387
+ */
1388
+ const NATIVE_HELP_FLAG = "--claude-help";
1389
+ /** Derive the capability flags from a `--help` text. */
1390
+ function parseCapabilities(text) {
1391
+ const disableTools = text.includes("--tools") ? "tools-empty" : /--disallowed-?[tT]ools/.test(text) ? "disallowed" : "none";
1392
+ return {
1393
+ jsonSchema: text.includes("--json-schema"),
1394
+ disableTools
1395
+ };
1396
+ }
1397
+ /**
1398
+ * Does this help text plausibly come from the native Claude Code binary?
1399
+ *
1400
+ * `--output-format` is the signal we key on: distill cannot work without that
1401
+ * flag, so any native help that matters here documents it. Its absence means we
1402
+ * are reading someone else's help text (a wrapper's), and the capability answers
1403
+ * drawn from it are not about the binary we will actually invoke.
1404
+ */
1405
+ function looksLikeNativeHelp(text) {
1406
+ return text.includes("--output-format");
1407
+ }
1408
+ /**
1268
1409
  * Probe the installed CLI's `--help` once and cache the result. `--help` is a
1269
1410
  * local, deterministic, no-API invocation, so this never costs anything.
1411
+ *
1412
+ * A wrapper distribution can HIDE natively-supported flags from `--help` while
1413
+ * still forwarding them (observed in the wild: a wrapper whose `--help` lists 5
1414
+ * wrapper options and advertises neither `--json-schema` nor `--tools`, though
1415
+ * both work; the native 69-flag help is behind `--claude-help`). Probing only
1416
+ * the wrapper help silently degrades EVERY distill stage to the prompt-embedded
1417
+ * schema with tools disabled by instruction alone. So when the help does not
1418
+ * look native, re-probe once via {@link NATIVE_HELP_FLAG} and prefer that
1419
+ * answer if it finds more. Worst case this costs one extra local `--help`.
1270
1420
  */
1271
1421
  async function probeCapabilities(bin, io) {
1272
1422
  if (capabilitiesCache) return capabilitiesCache;
@@ -1275,23 +1425,51 @@ async function probeCapabilities(bin, io) {
1275
1425
  timeoutMs: 15e3
1276
1426
  });
1277
1427
  const text = `${help.stdout}\n${help.stderr}`;
1278
- const disableTools = text.includes("--tools") ? "tools-empty" : /--disallowed-?[tT]ools/.test(text) ? "disallowed" : "none";
1279
- const caps = {
1280
- jsonSchema: text.includes("--json-schema"),
1281
- disableTools
1282
- };
1428
+ let caps = parseCapabilities(text);
1429
+ if (!looksLikeNativeHelp(text)) try {
1430
+ const native = await io.spawn(bin, [NATIVE_HELP_FLAG], {
1431
+ input: "",
1432
+ timeoutMs: 15e3
1433
+ });
1434
+ const nativeText = `${native.stdout}\n${native.stderr}`;
1435
+ if (looksLikeNativeHelp(nativeText)) caps = parseCapabilities(nativeText);
1436
+ } catch {}
1283
1437
  capabilitiesCache = caps;
1284
1438
  return caps;
1285
1439
  }
1286
1440
  /**
1441
+ * Reduce a verbose-mode payload to the single envelope carrying the result.
1442
+ *
1443
+ * With verbose mode ON (`--verbose`, or `"verbose": true` in settings.json)
1444
+ * `claude -p --output-format json` emits a JSON ARRAY of stream events
1445
+ * (`system`/init, `assistant`, …) terminated by the `type: "result"` event,
1446
+ * instead of the single result object it emits when verbose is off. Only the
1447
+ * terminal event has `result`/`is_error`, so reading the array as an object
1448
+ * finds no `result` field and every call fails. The CLI has no `--no-verbose`
1449
+ * to force the object shape, so both shapes must be accepted.
1450
+ *
1451
+ * The result event is located by its `type` field (its key ORDER is not stable:
1452
+ * on a real 2.1.220 run `type` is the 19th key), with a positional
1453
+ * last-element fallback for a future stream that renames the type tag.
1454
+ */
1455
+ function selectEnvelope(parsed) {
1456
+ if (!Array.isArray(parsed)) return parsed;
1457
+ const events = parsed;
1458
+ const resultEvent = events.findLast((e) => e?.type === "result");
1459
+ if (resultEvent) return resultEvent;
1460
+ const last = events.at(-1);
1461
+ if (last && (Object.hasOwn(last, "result") || Object.hasOwn(last, "is_error"))) return last;
1462
+ return null;
1463
+ }
1464
+ /**
1287
1465
  * Parse the CLI envelope and pull out the structured result. Throws
1288
1466
  * {@link AgentRunnerError} for fatal CLI errors (no point retrying) and
1289
1467
  * {@link RetryableError} for parse/validation problems (retry may help).
1290
1468
  */
1291
1469
  function extractResult(result) {
1292
- let envelope;
1470
+ let parsed;
1293
1471
  try {
1294
- envelope = JSON.parse(result.stdout);
1472
+ parsed = JSON.parse(result.stdout);
1295
1473
  } catch {
1296
1474
  const detail = snippet$2(result.stdout || result.stderr) || "no output";
1297
1475
  if (result.code !== 0) throw new AgentRunnerError("cli-error", `claude exited ${result.code}: ${detail}`, {
@@ -1300,12 +1478,14 @@ function extractResult(result) {
1300
1478
  });
1301
1479
  throw new RetryableError(`could not parse claude JSON envelope: ${detail}`);
1302
1480
  }
1481
+ const envelope = selectEnvelope(parsed);
1482
+ if (!envelope) throw new RetryableError(`claude verbose stream carried no 'result' event: ${snippet$2(result.stdout) || "empty array"}`);
1303
1483
  if (envelope.is_error) throw new AgentRunnerError("cli-error", `claude reported an error: ${typeof envelope.result === "string" ? envelope.result : "unknown error"}`, {
1304
1484
  stderr: result.stderr,
1305
1485
  output: result.stdout
1306
1486
  });
1307
1487
  const r = envelope.result;
1308
- if (r === null || r === void 0) throw new RetryableError("claude envelope missing a 'result' field");
1488
+ if (r === null || r === void 0) throw new RetryableError(`claude envelope missing a 'result' field: ${snippet$2(result.stdout, 200) || "no output"}`);
1309
1489
  if (typeof r === "object") return r;
1310
1490
  if (typeof r === "string") {
1311
1491
  const jsonText = stripFence(r);
@@ -1510,6 +1690,12 @@ async function runDigestStage(opts) {
1510
1690
  let completed = 0;
1511
1691
  let skipped = 0;
1512
1692
  const total = opts.entries.length;
1693
+ const breakerEnabled = opts.breaker !== false;
1694
+ let streakMessage = null;
1695
+ let streakCount = 0;
1696
+ let aborted = false;
1697
+ let abortReason;
1698
+ const attempted = /* @__PURE__ */ new Set();
1513
1699
  /** Digest one session end-to-end (skip / read / budget / call / checkpoint). */
1514
1700
  const digestOne = async (entry, i) => {
1515
1701
  const label = `[${i + 1}/${total}] ${entry.export}`;
@@ -1559,6 +1745,8 @@ async function runDigestStage(opts) {
1559
1745
  checkpoint.digests[entry.export] = digest;
1560
1746
  saveDigests(opts.home, checkpoint);
1561
1747
  completed++;
1748
+ streakMessage = null;
1749
+ streakCount = 0;
1562
1750
  write(` ${label} → ${green(digest.outcome)}: ${truncate(digest.goal, 70)}`);
1563
1751
  } catch (err) {
1564
1752
  const message = err instanceof Error ? err.message : String(err);
@@ -1567,23 +1755,47 @@ async function runDigestStage(opts) {
1567
1755
  error: message
1568
1756
  });
1569
1757
  write(` ${label} ${fail(`failed: ${truncate(message, 120)}`)}`);
1758
+ if (message === streakMessage) streakCount++;
1759
+ else {
1760
+ streakMessage = message;
1761
+ streakCount = 1;
1762
+ }
1763
+ if (breakerEnabled && !aborted && streakCount >= 5 && total > 5) {
1764
+ aborted = true;
1765
+ abortReason = `${streakCount} consecutive sessions failed with the identical error, which points at the environment rather than these sessions. Stopping before spending more calls`;
1766
+ write("");
1767
+ write(fail(` ⚠ ${abortReason}:`));
1768
+ write(` ${truncate(message, 160)}`);
1769
+ write(dim(" Nothing already digested is lost; fix the cause and re-run to resume.\n Re-run with --no-breaker to attempt every session anyway."));
1770
+ }
1570
1771
  }
1571
1772
  };
1572
1773
  let nextIndex = 0;
1573
1774
  const worker = async () => {
1574
1775
  while (nextIndex < opts.entries.length) {
1776
+ if (aborted) return;
1575
1777
  const i = nextIndex++;
1576
1778
  const entry = opts.entries[i];
1577
- if (entry) await digestOne(entry, i);
1779
+ if (entry) {
1780
+ attempted.add(entry.export);
1781
+ await digestOne(entry, i);
1782
+ }
1578
1783
  }
1579
1784
  };
1580
1785
  await Promise.all(Array.from({ length: Math.min(concurrency, Math.max(total, 1)) }, () => worker()));
1786
+ const notAttempted = opts.entries.map((e) => e.export).filter((name) => !attempted.has(name));
1787
+ if (aborted && notAttempted.length > 0) write(dim(` ${notAttempted.length} session(s) not attempted.`));
1581
1788
  return {
1582
1789
  generation: checkpoint.generation,
1583
1790
  completed,
1584
1791
  skipped,
1585
1792
  failed,
1586
- blocked
1793
+ blocked,
1794
+ notAttempted,
1795
+ ...aborted ? {
1796
+ aborted,
1797
+ abortReason
1798
+ } : {}
1587
1799
  };
1588
1800
  }
1589
1801
  function tasksPath(home) {
@@ -1695,7 +1907,118 @@ function synthesizeNoGroupTasks(digests) {
1695
1907
  };
1696
1908
  }
1697
1909
  /**
1698
- * Stage 2 — cluster all digests into semantic tasks (one call total).
1910
+ * Split the corpus into clustering windows whose prompts each fit the input
1911
+ * budget. Returns one window (all ids, sorted) when the whole prompt fits or
1912
+ * no budget is known; otherwise greedily packs sorted ids so every window's
1913
+ * prompt stays within budget (a single oversized digest still gets its own
1914
+ * window rather than being dropped). Sorted, deterministic, order-preserving:
1915
+ * re-running the same corpus plans the same windows.
1916
+ */
1917
+ function planClusterWindows(digests, origins, budget) {
1918
+ const ids = Object.keys(digests).sort();
1919
+ if (budget === void 0 || buildClusterPrompt(digests, origins).length <= budget) return [ids];
1920
+ const overhead = buildClusterPrompt({}, origins).length;
1921
+ const cost = (id) => {
1922
+ const d = digests[id];
1923
+ return buildClusterPrompt(d ? { [id]: d } : {}, origins).length - overhead;
1924
+ };
1925
+ const windows = [];
1926
+ let current = [];
1927
+ let used = overhead;
1928
+ for (const id of ids) {
1929
+ const c = cost(id);
1930
+ if (current.length > 0 && used + c > budget) {
1931
+ windows.push(current);
1932
+ current = [];
1933
+ used = overhead;
1934
+ }
1935
+ current.push(id);
1936
+ used += c;
1937
+ }
1938
+ if (current.length > 0) windows.push(current);
1939
+ return windows;
1940
+ }
1941
+ /**
1942
+ * Suffix a slug for uniqueness WITHOUT breaking the 2-5 word slug rule.
1943
+ *
1944
+ * Appending to a 5-word slug would produce a 6-word slug, which
1945
+ * {@link validateCluster} rejects; since a slug is also a path component, the
1946
+ * task would be unwritable. So append only while there is room, and otherwise
1947
+ * replace the final word with the counter, keeping the word count fixed.
1948
+ */
1949
+ function suffixSlug(slug, n) {
1950
+ const words = slug.split("-");
1951
+ return words.length < 5 ? `${slug}-${n}` : [...words.slice(0, 4), String(n)].join("-");
1952
+ }
1953
+ /**
1954
+ * Apply a merge response to the combined window tasks. Deterministic and
1955
+ * defensive: an entry is applied only when every referenced slug exists, it
1956
+ * names at least two tasks, no slug was already consumed by an earlier entry,
1957
+ * and its replacement slug is well-formed; anything else is skipped with a note
1958
+ * (the unmerged union is still a fully valid grouping). Members of merged tasks
1959
+ * are unioned and deduped.
1960
+ *
1961
+ * The slug check is what keeps this path safe to write. Every other cluster
1962
+ * response passes {@link validateCluster} before anything is saved, but the
1963
+ * merge call runs AFTER per-window validation and `ClusterMergeSchema` types
1964
+ * the replacement slug as a bare string. A task slug is also a path component
1965
+ * (`library/<slug>/…`), so a response of `"Payments Work"` or `"../../escaped"`
1966
+ * would otherwise become a directory name.
1967
+ */
1968
+ function applyClusterMerges(tasks, merges) {
1969
+ const bySlug = new Map(tasks.map((t) => [t.slug, t]));
1970
+ const consumed = /* @__PURE__ */ new Set();
1971
+ const merged = [];
1972
+ const notes = [];
1973
+ for (const entry of merges) {
1974
+ const missing = entry.slugs.filter((s) => !bySlug.has(s));
1975
+ if (missing.length > 0) {
1976
+ notes.push(`merge skipped: unknown slug(s) ${missing.join(", ")}`);
1977
+ continue;
1978
+ }
1979
+ if (entry.slugs.length < 2) {
1980
+ notes.push(`merge skipped: fewer than two slugs (${entry.slugs.join(", ") || "none"})`);
1981
+ continue;
1982
+ }
1983
+ const doubly = entry.slugs.filter((s) => consumed.has(s));
1984
+ if (doubly.length > 0) {
1985
+ notes.push(`merge skipped: slug(s) already merged ${doubly.join(", ")}`);
1986
+ continue;
1987
+ }
1988
+ if (!SLUG_PATTERN.test(entry.slug)) {
1989
+ notes.push(`merge skipped: slug "${entry.slug}" is not 2-5 kebab-case words`);
1990
+ continue;
1991
+ }
1992
+ for (const s of entry.slugs) consumed.add(s);
1993
+ const members = [...new Set(entry.slugs.flatMap((s) => bySlug.get(s).members))];
1994
+ merged.push({
1995
+ slug: entry.slug,
1996
+ title: entry.title,
1997
+ rationale: entry.rationale,
1998
+ members
1999
+ });
2000
+ }
2001
+ const kept = tasks.filter((t) => !consumed.has(t.slug));
2002
+ const finalTasks = [...kept];
2003
+ const seen = new Set(kept.map((t) => t.slug));
2004
+ for (const m of merged) {
2005
+ let slug = m.slug;
2006
+ for (let n = 2; seen.has(slug); n++) slug = suffixSlug(m.slug, n);
2007
+ seen.add(slug);
2008
+ finalTasks.push(slug === m.slug ? m : {
2009
+ ...m,
2010
+ slug
2011
+ });
2012
+ }
2013
+ return {
2014
+ tasks: finalTasks,
2015
+ notes
2016
+ };
2017
+ }
2018
+ /**
2019
+ * Stage 2 — cluster all digests into semantic tasks. One call when the corpus
2020
+ * prompt fits the input budget; otherwise windowed: one call per window plus
2021
+ * one best-effort merge call that unifies cross-window duplicates.
1699
2022
  *
1700
2023
  * Resumable: a tasks.json from the same generation covering the same input set
1701
2024
  * is reused without a call. Semantic validation failures (duplicate slugs,
@@ -1704,7 +2027,6 @@ function synthesizeNoGroupTasks(digests) {
1704
2027
  * the command reports and exits non-zero, re-running resumes.
1705
2028
  */
1706
2029
  async function runClusterStage(opts) {
1707
- const runner = opts.runner ?? runClaude;
1708
2030
  const out = opts.output ?? process.stdout;
1709
2031
  const write = (s) => out.write(`${s}\n`);
1710
2032
  const inputIds = Object.keys(opts.digests).sort();
@@ -1728,27 +2050,29 @@ async function runClusterStage(opts) {
1728
2050
  cluster = synthesizeNoGroupTasks(opts.digests);
1729
2051
  write(` --no-group: synthesized ${cluster.tasks.length} task(s) deterministically (no claude call)`);
1730
2052
  } else {
1731
- write(` clustering ${inputIds.length} digest(s)…`);
1732
- const basePrompt = buildClusterPrompt(opts.digests, opts.origins);
1733
- if (opts.budget !== void 0 && basePrompt.length > opts.budget) write(` ⚠ clustering ${inputIds.length} digests is ${basePrompt.length} chars (> budget ${opts.budget}); this may hit a model/context limit. Consider --project to narrow scope.`);
1734
- cluster = canonicalizeClusterIds(await withSpinner(out, `clustering ${inputIds.length} digest(s)`, () => runner({
1735
- prompt: basePrompt,
1736
- schema: ClusterSchema,
1737
- model: opts.model,
1738
- timeoutMs: opts.timeoutMs
1739
- })), inputIds);
1740
- let problems = validateCluster(cluster, inputIds);
1741
- if (problems.length > 0) {
1742
- write(` response failed validation (${problems.length} problem(s)); retrying once…`);
1743
- const corrective = `${basePrompt}\n\nYour previous grouping had these problems:\n${problems.map((p) => `- ${p}`).join("\n")}\nProduce a corrected grouping that fixes every problem. Remember: every id in at least one task or misc, unique 2-5-word kebab-case slugs, only the listed ids.`;
1744
- cluster = canonicalizeClusterIds(await withSpinner(out, "retrying with corrections", () => runner({
1745
- prompt: corrective,
1746
- schema: ClusterSchema,
1747
- model: opts.model,
1748
- timeoutMs: opts.timeoutMs
1749
- })), inputIds);
1750
- problems = validateCluster(cluster, inputIds);
1751
- if (problems.length > 0) throw new Error(`clustering failed validation after one retry: ${problems.join("; ")}`);
2053
+ const windows = planClusterWindows(opts.digests, opts.origins, opts.budget);
2054
+ if (windows.length === 1) {
2055
+ write(` clustering ${inputIds.length} digest(s)…`);
2056
+ cluster = await clusterWindow(windows[0], opts, out, "");
2057
+ } else {
2058
+ write(` clustering ${inputIds.length} digest(s) in ${windows.length} windows (corpus exceeds the input budget of ${opts.budget} chars)…`);
2059
+ const combined = [];
2060
+ const misc = [];
2061
+ const usedSlugs = /* @__PURE__ */ new Set();
2062
+ for (const [i, windowIds] of windows.entries()) {
2063
+ const windowCluster = await clusterWindow(windowIds, opts, out, ` [window ${i + 1}/${windows.length}]`);
2064
+ for (const task of windowCluster.tasks) {
2065
+ let slug = task.slug;
2066
+ for (let n = 2; usedSlugs.has(slug); n++) slug = suffixSlug(task.slug, n);
2067
+ usedSlugs.add(slug);
2068
+ combined.push(slug === task.slug ? task : {
2069
+ ...task,
2070
+ slug
2071
+ });
2072
+ }
2073
+ misc.push(...windowCluster.misc);
2074
+ }
2075
+ cluster = await mergeWindowTasks(combined, misc, opts, out);
1752
2076
  }
1753
2077
  }
1754
2078
  const checkpoint = {
@@ -1766,6 +2090,81 @@ async function runClusterStage(opts) {
1766
2090
  resumed: false
1767
2091
  };
1768
2092
  }
2093
+ /**
2094
+ * Cluster one window of ids: one call plus one corrective retry when the
2095
+ * response fails semantic validation (against THIS window's ids). The default
2096
+ * timeout scales with the window's digest count; an explicit --timeout wins.
2097
+ */
2098
+ async function clusterWindow(windowIds, opts, out, label) {
2099
+ const runner = opts.runner ?? runClaude;
2100
+ const write = (s) => out.write(`${s}\n`);
2101
+ const digests = {};
2102
+ for (const id of windowIds) {
2103
+ const d = opts.digests[id];
2104
+ if (d) digests[id] = d;
2105
+ }
2106
+ const timeoutMs = opts.timeoutMs ?? 3e5 + 5e3 * windowIds.length;
2107
+ const basePrompt = buildClusterPrompt(digests, opts.origins);
2108
+ let cluster = canonicalizeClusterIds(await withSpinner(out, `clustering ${windowIds.length} digest(s)${label}`, () => runner({
2109
+ prompt: basePrompt,
2110
+ schema: ClusterSchema,
2111
+ model: opts.model,
2112
+ timeoutMs
2113
+ })), windowIds);
2114
+ let problems = validateCluster(cluster, windowIds);
2115
+ if (problems.length > 0) {
2116
+ write(` response failed validation (${problems.length} problem(s)); retrying once…`);
2117
+ const corrective = `${basePrompt}\n\nYour previous grouping had these problems:\n${problems.map((p) => `- ${p}`).join("\n")}\nProduce a corrected grouping that fixes every problem. Remember: every id in at least one task or misc, unique 2-5-word kebab-case slugs, only the listed ids.`;
2118
+ cluster = canonicalizeClusterIds(await withSpinner(out, `retrying with corrections${label}`, () => runner({
2119
+ prompt: corrective,
2120
+ schema: ClusterSchema,
2121
+ model: opts.model,
2122
+ timeoutMs
2123
+ })), windowIds);
2124
+ problems = validateCluster(cluster, windowIds);
2125
+ if (problems.length > 0) throw new Error(`clustering failed validation after one retry: ${problems.join("; ")}`);
2126
+ }
2127
+ return cluster;
2128
+ }
2129
+ /**
2130
+ * Unify cross-window duplicate tasks with one merge call over the combined
2131
+ * task identities. Best-effort by design: window clustering already produced
2132
+ * a fully valid grouping, so a failed or partially invalid merge response
2133
+ * degrades to (parts of) the unmerged union with a note instead of failing
2134
+ * the stage.
2135
+ */
2136
+ async function mergeWindowTasks(combined, misc, opts, out) {
2137
+ const runner = opts.runner ?? runClaude;
2138
+ const write = (s) => out.write(`${s}\n`);
2139
+ const uniqueMisc = [...new Set(misc)];
2140
+ if (combined.length < 2) return {
2141
+ tasks: combined,
2142
+ misc: uniqueMisc
2143
+ };
2144
+ const timeoutMs = opts.timeoutMs ?? 3e5 + 5e3 * combined.length;
2145
+ let merge;
2146
+ try {
2147
+ merge = await withSpinner(out, `merging ${combined.length} window task(s) into a unified grouping`, () => runner({
2148
+ prompt: buildMergePrompt(combined),
2149
+ schema: ClusterMergeSchema,
2150
+ model: opts.model,
2151
+ timeoutMs
2152
+ }));
2153
+ } catch (err) {
2154
+ write(` merge call failed (${err instanceof Error ? err.message : String(err)}); keeping the per-window tasks unmerged.`);
2155
+ return {
2156
+ tasks: combined,
2157
+ misc: uniqueMisc
2158
+ };
2159
+ }
2160
+ const { tasks, notes } = applyClusterMerges(combined, merge.merges);
2161
+ for (const note of notes) write(` ⚠ ${note}`);
2162
+ if (merge.merges.length - notes.length > 0) write(` merged ${combined.length} window task(s) → ${tasks.length}`);
2163
+ return {
2164
+ tasks,
2165
+ misc: uniqueMisc
2166
+ };
2167
+ }
1769
2168
  /** Read `exports/anaphora.json` ({export → records}); absent/invalid → {}. */
1770
2169
  function readAnaphora(home) {
1771
2170
  try {
@@ -2014,9 +2413,65 @@ const KIRO_DISTILL_SENTINEL = "[cc-hindsight distill]";
2014
2413
  const BRACKET_MARKERS = [
2015
2414
  "[AGENT SYSTEM PROMPT]",
2016
2415
  "[Recent channel messages for context:]",
2017
- "[Subagent completion event]"
2416
+ "[Subagent completion event]",
2417
+ "[LIVE STEERING - New message from user]"
2018
2418
  ];
2019
2419
  /**
2420
+ * K14 — live-steering recovery. A message the human types WHILE the agent is
2421
+ * working arrives wrapped in a harness envelope, not as its own Prompt:
2422
+ *
2423
+ * [LIVE STEERING - New message from user]
2424
+ * The user sent a new message while you are working. …
2425
+ * <user_message id="steer-…">
2426
+ * the words the human actually typed
2427
+ * </user_message>
2428
+ * IMPORTANT: After completing your work, … [STEERING steer-…: …]
2429
+ *
2430
+ * The envelope leads with a bracket marker, so K6 would drop the whole thing and
2431
+ * the human's words with it. Recover the `<user_message>` body FIRST (the same
2432
+ * ordering trick R10 uses for slash-commands on the Claude side), and keep the
2433
+ * surrounding harness instructions out: they are machine text and would
2434
+ * otherwise dominate the digest prompt.
2435
+ *
2436
+ * These are the highest-value turns in a corpus, since steering is where the
2437
+ * human corrects course mid-run. Measured on a real 306-session store: 112
2438
+ * messages, ~13.6k chars.
2439
+ */
2440
+ const LIVE_STEERING_MARKER = "[LIVE STEERING - New message from user]";
2441
+ const USER_MESSAGE_RE = /<user_message\b[^>]*>([\s\S]*?)<\/user_message>/;
2442
+ /** Pull the human words out of a live-steering envelope; null if there are none. */
2443
+ function recoverSteeringText(text) {
2444
+ if (!text.startsWith(LIVE_STEERING_MARKER)) return null;
2445
+ const body = USER_MESSAGE_RE.exec(text)?.[1]?.trim();
2446
+ return body ? body : null;
2447
+ }
2448
+ /**
2449
+ * K14 — steering messages recovered from a `ToolResults` entry.
2450
+ *
2451
+ * In real sessions the harness delivers a mid-run steering message by appending
2452
+ * it to the NEXT `ToolResults` entry's `content`, not as its own `Prompt`. Since
2453
+ * K1 only admits `Prompt`, all of them were invisible: on a real 306-session
2454
+ * store, 100 of the 112 steering messages arrive this way (12 more only in a
2455
+ * `Compaction` snapshot, which K12 already reports as a drop).
2456
+ *
2457
+ * Only `kind: "text"` blocks whose text opens with the steering marker are
2458
+ * admitted. That is deliberately narrow: the same content arrays hold 5630
2459
+ * `toolResult` blocks of pure machine output, and nothing else in a
2460
+ * `ToolResults` entry is human. Shared by extract and timeline so the
2461
+ * SessionSource law holds.
2462
+ */
2463
+ function steeringFromToolResults(data) {
2464
+ const content = isRecord$1(data) ? data.content : void 0;
2465
+ if (!Array.isArray(content)) return [];
2466
+ const out = [];
2467
+ for (const block of content) {
2468
+ if (!isRecord$1(block) || block.kind !== "text" || typeof block.data !== "string") continue;
2469
+ const recovered = recoverSteeringText(block.data.trim());
2470
+ if (recovered !== null) out.push(recovered);
2471
+ }
2472
+ return out;
2473
+ }
2474
+ /**
2020
2475
  * K6 / K2 — harness nudge strings. As a leading substring they mark a
2021
2476
  * machine-injected retry prompt (drop the piece); as a whole-session's only
2022
2477
  * "human-looking" prompt they are the sole false-positive class the `.history`
@@ -2094,6 +2549,11 @@ function promptText(data, drops, ts) {
2094
2549
  });
2095
2550
  continue;
2096
2551
  }
2552
+ const steered = recoverSteeringText(text);
2553
+ if (steered !== null) {
2554
+ pieces.push(steered);
2555
+ continue;
2556
+ }
2097
2557
  if (text.startsWith("<")) {
2098
2558
  drops.push({
2099
2559
  reason: "K6: machine block (leading <)",
@@ -2177,6 +2637,17 @@ function extractKiroMessages(lines) {
2177
2637
  }
2178
2638
  continue;
2179
2639
  }
2640
+ if (parsed.kind === "ToolResults") {
2641
+ const ts = normalizeTimestamp(isRecord$1(data) ? data.meta : void 0);
2642
+ for (const steered of steeringFromToolResults(data)) {
2643
+ messages.push({
2644
+ timestamp: ts,
2645
+ text: steered
2646
+ });
2647
+ liveKeys.add(`${ts}\u0000${steered}`);
2648
+ }
2649
+ continue;
2650
+ }
2180
2651
  if (parsed.kind !== "Prompt") continue;
2181
2652
  const ts = normalizeTimestamp(isRecord$1(data) ? data.meta : void 0);
2182
2653
  const text = promptText(data, drops, ts);
@@ -2236,6 +2707,13 @@ function kiroTimeline(lines) {
2236
2707
  timestamp: "",
2237
2708
  text
2238
2709
  });
2710
+ } else if (kind === "ToolResults") {
2711
+ const ts = normalizeTimestamp(isRecord$1(data) ? data.meta : void 0);
2712
+ for (const steered of steeringFromToolResults(data)) events.push({
2713
+ kind: "human",
2714
+ timestamp: ts,
2715
+ text: steered
2716
+ });
2239
2717
  } else if (kind === "Clear" || kind === "Compaction") events.push({
2240
2718
  kind: "boundary",
2241
2719
  timestamp: "",
@@ -2883,20 +3361,31 @@ function rejectReason(entry) {
2883
3361
  return null;
2884
3362
  }
2885
3363
  /**
2886
- * R3 — attachments hold messages typed while the agent was busy. Assumed shape
2887
- * (pinned by r3-queued-command.jsonl):
3364
+ * R3 — attachments hold messages typed while the agent was busy. Real shape
3365
+ * (pinned by r3-queued-command-prompt-field.jsonl, copied from a live
3366
+ * transcript):
2888
3367
  * { "type": "attachment",
2889
3368
  * "attachment": { "type": "queued_command",
2890
3369
  * "origin": { "kind": "human" },
2891
3370
  * "commandMode": "prompt",
2892
- * "text": "the queued prompt text" } }
3371
+ * "prompt": "the queued prompt text",
3372
+ * "timestamp": "..." } }
2893
3373
  * Admit ONLY queued_command + origin.kind==="human" + commandMode==="prompt";
2894
- * anything else is recorded as a Drop for observability.
3374
+ * anything else is recorded as a Drop for observability. In particular
3375
+ * `commandMode: "task-notification"` is the agent reporting a finished
3376
+ * background task, not typed input.
3377
+ *
3378
+ * The text lives in `prompt`. An earlier version read `text`, which no shipped
3379
+ * CLI writes here: the original fixture was hand-authored with that spelling, so
3380
+ * the suite pinned a shape that never existed and R3 dropped EVERY genuinely
3381
+ * queued human message (measured on a real 286-session store: 253 messages,
3382
+ * ~42.9k chars). `text` is still read as a fallback so the older fixture's
3383
+ * contract holds and any variant CLI that uses it keeps working.
2895
3384
  */
2896
3385
  function collectAttachment(entry, pieces, drops, ts) {
2897
3386
  const att = entry.attachment;
2898
3387
  if (isRecord(att) && att.type === "queued_command" && isRecord(att.origin) && att.origin.kind === "human" && att.commandMode === "prompt") {
2899
- cleanPiece(typeof att.text === "string" ? att.text : "", pieces, drops, ts);
3388
+ cleanPiece(typeof att.prompt === "string" ? att.prompt : typeof att.text === "string" ? att.text : "", pieces, drops, ts);
2900
3389
  return;
2901
3390
  }
2902
3391
  drops.push({
@@ -2947,7 +3436,11 @@ function entrySnippet(entry) {
2947
3436
  }
2948
3437
  }
2949
3438
  const att = entry.attachment;
2950
- if (isRecord(att) && typeof att.text === "string") return snippet(att.text);
3439
+ if (isRecord(att)) {
3440
+ if (typeof att.prompt === "string") return snippet(att.prompt);
3441
+ if (typeof att.text === "string") return snippet(att.text);
3442
+ if (typeof att.type === "string") return snippet(`<attachment ${att.type}>`);
3443
+ }
2951
3444
  return snippet(JSON.stringify(entry));
2952
3445
  }
2953
3446
  /**
@@ -3930,6 +4423,7 @@ async function runPreferences(args, deps = {}) {
3930
4423
  target,
3931
4424
  runner,
3932
4425
  model: args.model,
4426
+ timeoutMs: resolveTimeoutMs(args.timeout),
3933
4427
  output: out
3934
4428
  });
3935
4429
  if (merged !== null && block !== null) await offerCopyBlock({
@@ -3952,12 +4446,14 @@ async function runPreferences(args, deps = {}) {
3952
4446
  async function runConsolidation(opts) {
3953
4447
  const { prefs, taskCount, target, runner, model, output } = opts;
3954
4448
  const write = (s = "") => output.write(`${s}\n`);
4449
+ const timeoutMs = opts.timeoutMs ?? 3e5 + 5e3 * prefs.length;
3955
4450
  let consolidated;
3956
4451
  try {
3957
4452
  consolidated = await withSpinner(output, `consolidating ${prefs.length} preference(s)`, () => runner({
3958
4453
  prompt: buildConsolidatePrompt(prefs),
3959
4454
  schema: ConsolidateSchema,
3960
- model
4455
+ model,
4456
+ timeoutMs
3961
4457
  }));
3962
4458
  } catch (err) {
3963
4459
  write(`consolidation failed: ${err instanceof Error ? err.message : String(err)}`);
@@ -4064,6 +4560,10 @@ var preferences_default = defineCommand({
4064
4560
  type: "string",
4065
4561
  description: "Model to pass through to the runner's --model for --consolidate"
4066
4562
  },
4563
+ timeout: {
4564
+ type: "string",
4565
+ description: "Consolidation call timeout in seconds (default scales with the preference count)"
4566
+ },
4067
4567
  yes: {
4068
4568
  type: "boolean",
4069
4569
  description: "Skip the consent prompt (for scripting)"
@@ -4305,9 +4805,10 @@ async function runDistill(args, deps = {}) {
4305
4805
  concurrency: parseClampedInt(args.concurrency, {
4306
4806
  fallback: 3,
4307
4807
  min: 1
4308
- })
4808
+ }),
4809
+ breaker: args.breaker !== false
4309
4810
  });
4310
- const digestSummary = `digest stage: ${digestResult.completed + digestResult.skipped}/${plan.digests} done` + (digestResult.skipped ? ` (${digestResult.skipped} resumed from checkpoint)` : "") + (digestResult.failed.length ? `, ${digestResult.failed.length} failed` : "");
4811
+ const digestSummary = `digest stage: ${digestResult.completed + digestResult.skipped}/${plan.digests} done` + (digestResult.skipped ? ` (${digestResult.skipped} resumed from checkpoint)` : "") + (digestResult.failed.length ? `, ${digestResult.failed.length} failed` : "") + (digestResult.aborted ? `, ${digestResult.notAttempted.length} not attempted (stopped)` : "");
4311
4812
  write(digestResult.failed.length ? digestSummary : green(digestSummary));
4312
4813
  if (digestResult.failed.length > 0) {
4313
4814
  write();
@@ -4406,6 +4907,7 @@ async function runDistill(args, deps = {}) {
4406
4907
  canPrompt,
4407
4908
  sourceMode,
4408
4909
  model: args.model,
4910
+ timeoutMs,
4409
4911
  deps,
4410
4912
  output: out
4411
4913
  });
@@ -4431,7 +4933,7 @@ async function runDistill(args, deps = {}) {
4431
4933
  * distill exit code is never affected by this cascade (best-effort tail).
4432
4934
  */
4433
4935
  async function offerPreferencesCascade(opts) {
4434
- const { home, runner, runnerName, yes, canPrompt, sourceMode, model, deps, output } = opts;
4936
+ const { home, runner, runnerName, yes, canPrompt, sourceMode, model, timeoutMs, deps, output } = opts;
4435
4937
  const write = (s = "") => output.write(`${s}\n`);
4436
4938
  const entries = readLibrary(home);
4437
4939
  const prefs = aggregatePreferences(entries);
@@ -4450,6 +4952,7 @@ async function offerPreferencesCascade(opts) {
4450
4952
  target,
4451
4953
  runner,
4452
4954
  model,
4955
+ timeoutMs,
4453
4956
  output
4454
4957
  });
4455
4958
  if (merged === null || block === null) return;
@@ -4482,6 +4985,11 @@ var distill_default = defineCommand({
4482
4985
  default: true,
4483
4986
  description: "Group sessions into tasks (use --no-group for 1 session = 1 task)"
4484
4987
  },
4988
+ breaker: {
4989
+ type: "boolean",
4990
+ default: true,
4991
+ description: "Stop the digest stage after 5 consecutive identical failures (use --no-breaker to attempt every session)"
4992
+ },
4485
4993
  "min-substance": {
4486
4994
  type: "string",
4487
4995
  default: "2",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "cc-hindsight",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "cc-hindsight",
9
- "version": "1.1.0",
9
+ "version": "1.3.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@clack/prompts": "1.7.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-hindsight",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Mine your coding-agent session history (Claude Code, kiro-cli) into a oneshot prompt library and CLAUDE.md/AGENTS.md preferences. The prompt you'd write if you knew then what you know now.",
5
5
  "type": "module",
6
6
  "author": "Aditya Singhal (https://adityasinghal.com)",