@vectorize-io/hindsight-coding-agents 0.8.6 → 0.8.7

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.
Files changed (62) hide show
  1. package/README.md +23 -18
  2. package/dist/antigravity-hook.js +130 -135
  3. package/dist/antigravity-statusline.js +1 -1
  4. package/dist/antigravity-stop-hook.js +113 -114
  5. package/dist/claude-hook.js +130 -135
  6. package/dist/claude-sessionstart-hook.js +127 -128
  7. package/dist/claude-stop-hook.js +113 -114
  8. package/dist/cline.js +128 -124
  9. package/dist/codebuddy-hook.js +130 -135
  10. package/dist/codebuddy-sessionstart-hook.js +127 -128
  11. package/dist/codebuddy-stop-hook.js +113 -114
  12. package/dist/codex-hook.js +130 -135
  13. package/dist/codex-sessionstart-hook.js +127 -128
  14. package/dist/codex-stop-hook.js +113 -114
  15. package/dist/copilot-hook.js +130 -135
  16. package/dist/copilot-sessionstart-hook.js +127 -128
  17. package/dist/copilot-stop-hook.js +113 -114
  18. package/dist/cursor-hook.js +130 -135
  19. package/dist/cursor-sessionstart-hook.js +127 -128
  20. package/dist/cursor-stop-hook.js +113 -114
  21. package/dist/daemon-start.js +1 -1
  22. package/dist/dcode-hook.js +130 -135
  23. package/dist/dcode-sessionstart-hook.js +127 -128
  24. package/dist/dcode-stop-hook.js +113 -114
  25. package/dist/deepen.js +80 -79
  26. package/dist/devin-hook.js +130 -135
  27. package/dist/devin-sessionstart-hook.js +127 -128
  28. package/dist/devin-stop-hook.js +113 -114
  29. package/dist/droid-hook.js +130 -135
  30. package/dist/droid-sessionstart-hook.js +127 -128
  31. package/dist/droid-stop-hook.js +113 -114
  32. package/dist/dsh.js +157 -161
  33. package/dist/grok-hook.js +130 -135
  34. package/dist/grok-sessionstart-hook.js +127 -128
  35. package/dist/grok-stop-hook.js +113 -114
  36. package/dist/hindsight-seed.js +1 -1
  37. package/dist/index.js +158 -162
  38. package/dist/installer.js +30 -28
  39. package/dist/kilo.js +158 -162
  40. package/dist/kimi-hook.js +130 -135
  41. package/dist/kimi-sessionstart-hook.js +127 -128
  42. package/dist/kimi-stop-hook.js +113 -114
  43. package/dist/mcp-server.js +94 -93
  44. package/dist/opencode2.js +158 -162
  45. package/dist/pi.js +157 -161
  46. package/dist/prime-agent.js +157 -161
  47. package/dist/qwen-hook.js +130 -135
  48. package/dist/qwen-sessionstart-hook.js +127 -128
  49. package/dist/qwen-stop-hook.js +113 -114
  50. package/dist/status.js +80 -79
  51. package/dist/traecode-hook.js +130 -135
  52. package/dist/traecode-sessionstart-hook.js +127 -128
  53. package/dist/traecode-stop-hook.js +113 -114
  54. package/dist/workbuddy-hook.js +130 -135
  55. package/dist/workbuddy-sessionstart-hook.js +127 -128
  56. package/dist/workbuddy-stop-hook.js +113 -114
  57. package/dist/zcode-hook.js +130 -135
  58. package/dist/zcode-sessionstart-hook.js +127 -128
  59. package/dist/zcode-stop-hook.js +113 -114
  60. package/package.json +2 -1
  61. package/plugin.json +1 -1
  62. package/skill/SKILL.md +23 -23
@@ -417,14 +417,14 @@ var RETAIN_STRATEGIES = {
417
417
  retain_chunk_size: 12e3
418
418
  }
419
419
  };
420
- var KNOWLEDGE_LABELS = {
420
+ var PAGE_LABELS = {
421
421
  key: "knowledge",
422
422
  type: "multi-values",
423
423
  // 0, 1, or several — empty is normal
424
424
  optional: true,
425
425
  tag: true,
426
426
  // emits knowledge:<value> onto the fact's tags
427
- description: "Routing labels for this project's Hindsight KNOWLEDGE PAGES \u2014 curated, human-readable summaries of the repo's DURABLE engineering knowledge (architecture, key decisions, conventions, ongoing initiatives), each page rebuilt automatically from the facts labeled for it. Mark a fact only when it is durable, reusable knowledge a developer would still want surfaced in future sessions. IMPORTANT: leave this EMPTY for routine, transient, or operational facts \u2014 a passing test, a one-off command, a status update, a debugging dead-end. MOST facts should get no label here. Assign more than one value only when the fact genuinely fits several.",
427
+ description: "Routing labels for this project's Hindsight PAGES \u2014 curated, human-readable summaries of the repo's DURABLE engineering knowledge (architecture, key decisions, conventions, ongoing initiatives), each page rebuilt automatically from the facts labeled for it. Mark a fact only when it is durable, reusable knowledge a developer would still want surfaced in future sessions. IMPORTANT: leave this EMPTY for routine, transient, or operational facts \u2014 a passing test, a one-off command, a status update, a debugging dead-end. MOST facts should get no label here. Assign more than one value only when the fact genuinely fits several.",
428
428
  values: [
429
429
  {
430
430
  value: "feature-work",
@@ -581,7 +581,7 @@ var CODING_BANK_TEMPLATE = {
581
581
  retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
582
582
  retain_default_strategy: "git",
583
583
  retain_strategies: RETAIN_STRATEGIES,
584
- entity_labels: [KNOWLEDGE_LABELS],
584
+ entity_labels: [PAGE_LABELS],
585
585
  entities_allow_free_form: true
586
586
  }
587
587
  };
@@ -633,7 +633,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
633
633
  }
634
634
 
635
635
  // package.json
636
- var version = "0.8.6";
636
+ var version = "0.8.7";
637
637
 
638
638
  // src/core/util.ts
639
639
  import { accessSync, constants, statSync as statSync2 } from "fs";
@@ -702,11 +702,11 @@ function retryAfterMs(header) {
702
702
  const at = Date.parse(header);
703
703
  return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
704
704
  }
705
- var KnowledgePagesUnavailableError = class extends Error {
706
- code = "knowledge_pages_unavailable";
705
+ var PagesUnavailableError = class extends Error {
706
+ code = "pages_unavailable";
707
707
  constructor() {
708
- super("Hindsight server does not support knowledge pages");
709
- this.name = "KnowledgePagesUnavailableError";
708
+ super("Hindsight server does not support pages");
709
+ this.name = "PagesUnavailableError";
710
710
  }
711
711
  };
712
712
  async function isEndpointMissing(r) {
@@ -717,6 +717,10 @@ async function isEndpointMissing(r) {
717
717
  return false;
718
718
  }
719
719
  }
720
+ function pagesPath(sub, legacy = false) {
721
+ if (!legacy) return `/pages${sub}`;
722
+ return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
723
+ }
720
724
  var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
721
725
  var ReflectError = class extends Error {
722
726
  constructor(message, status, timedOut, options) {
@@ -785,7 +789,7 @@ var HindsightClient = class {
785
789
  opIds = [];
786
790
  // async operation ids collected by retain(), for drain()
787
791
  /** Tri-state capability probe: unknown until the first page request, then cached. */
788
- knowledgePagesSupported;
792
+ pagesSupported;
789
793
  /** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
790
794
  idempotentRetain;
791
795
  log;
@@ -1014,7 +1018,7 @@ var HindsightClient = class {
1014
1018
  return (j.total ?? j.items?.length ?? 0) > 0;
1015
1019
  }
1016
1020
  /** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
1017
- * entity labels), then seed knowledge pages when the server supports them. Both halves are
1021
+ * entity labels), then seed pages when the server supports them. Both halves are
1018
1022
  * idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
1019
1023
  * extraction mode of the plugin's own strategies, which follows its config (#4560) — so
1020
1024
  * the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
@@ -1196,29 +1200,45 @@ var HindsightClient = class {
1196
1200
  const j = await r.json();
1197
1201
  return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
1198
1202
  }
1203
+ /** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
1204
+ * page routes moved to `/pages/...`. Remove in 2.x. */
1205
+ legacyPagesPaths = false;
1199
1206
  /**
1200
- * Latch `knowledgePagesSupported = false` iff this response really means the endpoint is absent.
1201
- * Returns whether it latched. A bank-not-found 404 is NOT a capability verdict — it is the
1202
- * expected answer before the bank's first retain — so it must never cache a negative (#4607).
1207
+ * Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
1208
+ *
1209
+ * Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
1210
+ * unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
1211
+ * older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
1212
+ * a capability verdict — it is the expected answer before the bank's first retain — so it is
1213
+ * returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
1203
1214
  *
1204
1215
  * Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
1205
1216
  * the 405/501 this used to check for never reach a caller in the first place.
1206
1217
  */
1207
- async pagesUnsupported(r) {
1208
- if (r.status !== 404 || !await isEndpointMissing(r)) return false;
1209
- this.knowledgePagesSupported = false;
1210
- return true;
1218
+ async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
1219
+ const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
1220
+ let r = await send(this.legacyPagesPaths);
1221
+ if (r.status !== 404 || !await isEndpointMissing(r)) return r;
1222
+ if (!this.legacyPagesPaths) {
1223
+ r = await send(true);
1224
+ if (r.status !== 404 || !await isEndpointMissing(r)) {
1225
+ this.legacyPagesPaths = true;
1226
+ return r;
1227
+ }
1228
+ }
1229
+ this.pagesSupported = false;
1230
+ return null;
1211
1231
  }
1212
1232
  /**
1213
- * The bank's knowledge-base tree (folders + pages, nested). The tree carries names, source
1233
+ * The bank's page tree (folders + pages, nested). The tree carries names, source
1214
1234
  * queries and staleness but NOT synthesized content, so it is cheap enough to poll.
1215
1235
  */
1216
1236
  async tree() {
1217
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1218
- const r = await this.req("GET", this.bankUrl("/knowledge-base/tree"));
1219
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1237
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1238
+ const r = await this.pagesReq("GET", "/tree");
1239
+ if (!r) throw new PagesUnavailableError();
1220
1240
  if (r.status === 404) return [];
1221
- this.knowledgePagesSupported = true;
1241
+ this.pagesSupported = true;
1222
1242
  try {
1223
1243
  return (await r.json()).roots ?? [];
1224
1244
  } catch {
@@ -1226,13 +1246,13 @@ var HindsightClient = class {
1226
1246
  }
1227
1247
  }
1228
1248
  /**
1229
- * List knowledge pages (ids + names only — no synthesized content), flattened out of the tree
1249
+ * List pages (ids + names only — no synthesized content), flattened out of the tree
1230
1250
  * and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
1231
1251
  * to read, and a caller enumerating pages wants leaves, not structure.
1232
1252
  *
1233
- * NOTE the ids are knowledge-base node ids (`kp-…`), NOT the backing mental-model ids. Every
1234
- * page read/update in this client goes through the same knowledge-base ids, so a page id from
1235
- * here, from `searchKnowledgePages`, or from a `[[page:<id>]]` link all resolve identically.
1253
+ * NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
1254
+ * page read/update in this client goes through the same page ids, so a page id from
1255
+ * here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
1236
1256
  */
1237
1257
  async listPages() {
1238
1258
  const items = [];
@@ -1254,34 +1274,26 @@ var HindsightClient = class {
1254
1274
  return { items };
1255
1275
  }
1256
1276
  /**
1257
- * Read one knowledge page's synthesized content by knowledge-base id, shaped by `shapePage` so
1277
+ * Read one page's synthesized content by page id, shaped by `shapePage` so
1258
1278
  * the body arrives once. The endpoint omits the internal reflect trace that built
1259
1279
  * the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
1260
1280
  * token cap.
1261
1281
  */
1262
1282
  async getPage(pageId) {
1263
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1264
- const r = await this.req(
1265
- "GET",
1266
- this.bankUrl(`/knowledge-base/pages/${encodeURIComponent(pageId)}`)
1267
- );
1268
- if (r.status === 404) throw new Error(`knowledge page not found: ${pageId}`);
1283
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1284
+ const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
1285
+ if (!r) throw new PagesUnavailableError();
1286
+ if (r.status === 404) throw new Error(`page not found: ${pageId}`);
1269
1287
  return shapePage(await r.json());
1270
1288
  }
1271
- /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's knowledge pages.
1289
+ /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
1272
1290
  * Returns page-level hits with a relevance snippet — the real search behind
1273
- * hindsight_search_knowledge_pages. */
1274
- async searchKnowledgePages(query, opts = {}) {
1275
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1291
+ * hindsight_search_pages. */
1292
+ async searchPages(query, opts = {}) {
1293
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1276
1294
  const q = `?q=${encodeURIComponent(query)}&limit=${opts.limit ?? this.pageSearchLimit}`;
1277
- const r = await this.req(
1278
- "GET",
1279
- this.bankUrl(`/knowledge-base/search${q}`),
1280
- void 0,
1281
- [],
1282
- opts.timeoutMs
1283
- );
1284
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1295
+ const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
1296
+ if (!r) throw new PagesUnavailableError();
1285
1297
  if (r.status === 404) return [];
1286
1298
  const j = await r.json();
1287
1299
  return (j.results ?? []).map((x) => ({
@@ -1293,9 +1305,9 @@ var HindsightClient = class {
1293
1305
  }));
1294
1306
  }
1295
1307
  /**
1296
- * Seed the fixed page taxonomy as knowledge-base pages at the tree root, idempotently.
1308
+ * Seed the fixed page taxonomy as pages at the tree root, idempotently.
1297
1309
  *
1298
- * Matched by NAME, not id: `/knowledge-base/pages` mints its own `kp-…` id, so a stable
1310
+ * Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
1299
1311
  * client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
1300
1312
  * off a slug). Names are unique per folder server-side, which makes them a sound key.
1301
1313
  *
@@ -1310,8 +1322,8 @@ var HindsightClient = class {
1310
1322
  try {
1311
1323
  roots = await this.tree();
1312
1324
  } catch (e) {
1313
- if (e instanceof KnowledgePagesUnavailableError) {
1314
- this.log(`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`);
1325
+ if (e instanceof PagesUnavailableError) {
1326
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1315
1327
  return;
1316
1328
  }
1317
1329
  throw e;
@@ -1334,11 +1346,9 @@ var HindsightClient = class {
1334
1346
  trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
1335
1347
  };
1336
1348
  if (!hit) {
1337
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), body, [409]);
1338
- if (await this.pagesUnsupported(r)) {
1339
- this.log(
1340
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1341
- );
1349
+ const r = await this.pagesReq("POST", "", body, [409]);
1350
+ if (!r) {
1351
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1342
1352
  return;
1343
1353
  }
1344
1354
  if (r.status === 404) {
@@ -1359,15 +1369,9 @@ var HindsightClient = class {
1359
1369
  );
1360
1370
  }
1361
1371
  if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
1362
- const r = await this.req(
1363
- "PATCH",
1364
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
1365
- patch
1366
- );
1367
- if (await this.pagesUnsupported(r)) {
1368
- this.log(
1369
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1370
- );
1372
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
1373
+ if (!r) {
1374
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1371
1375
  return;
1372
1376
  }
1373
1377
  if (r.status === 404) {
@@ -1379,7 +1383,7 @@ var HindsightClient = class {
1379
1383
  }
1380
1384
  const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
1381
1385
  this.log(
1382
- `[bank] knowledge pages seeded on ${this.bank} (scoped to ${this.project ?? "the shared bank"}): ${created} created, ${updated} re-synced, ${pages.length - created - updated - vanished} unchanged` + (vanished ? `, ${vanished} deleted under us` : "") + (initiatives ? `, ${initiatives} initiative pages re-synced` : "")
1386
+ `[bank] pages seeded on ${this.bank} (scoped to ${this.project ?? "the shared bank"}): ${created} created, ${updated} re-synced, ${pages.length - created - updated - vanished} unchanged` + (vanished ? `, ${vanished} deleted under us` : "") + (initiatives ? `, ${initiatives} initiative pages re-synced` : "")
1383
1387
  );
1384
1388
  }
1385
1389
  /**
@@ -1413,12 +1417,8 @@ var HindsightClient = class {
1413
1417
  if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
1414
1418
  }
1415
1419
  if (!patch.trigger && !patch.source_query) continue;
1416
- const r = await this.req(
1417
- "PATCH",
1418
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
1419
- patch
1420
- );
1421
- if (r.status === 404) continue;
1420
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
1421
+ if (!r || r.status === 404) continue;
1422
1422
  updated++;
1423
1423
  }
1424
1424
  return updated;
@@ -1444,7 +1444,7 @@ var HindsightClient = class {
1444
1444
  let pageId = args.relatesToPageId;
1445
1445
  if (!pageId) {
1446
1446
  const folderId = await this.ensureFolder("Initiatives");
1447
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
1447
+ const r = await this.pagesReq("POST", "", {
1448
1448
  name: args.title,
1449
1449
  source_query: `Summarize the "${args.title}" initiative: what is being built or changed and why, and its current state \u2014 drawn from the project's memory.` + pageScopeRule(this.project),
1450
1450
  parent_id: folderId,
@@ -1453,8 +1453,8 @@ var HindsightClient = class {
1453
1453
  trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
1454
1454
  });
1455
1455
  try {
1456
- const j = await r.json();
1457
- pageId = j.page_id ?? j.id;
1456
+ const j = await r?.json();
1457
+ pageId = j?.page_id ?? j?.id;
1458
1458
  } catch {
1459
1459
  }
1460
1460
  pageId ||= `initiative-${this.slugify(args.title)}`;
@@ -1472,16 +1472,17 @@ var HindsightClient = class {
1472
1472
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
1473
1473
  async ensureFolder(name) {
1474
1474
  try {
1475
- const tree = await (await this.req("GET", this.bankUrl("/knowledge-base/tree"))).json();
1476
- const hit = (tree.roots || []).find(
1475
+ const r = await this.pagesReq("GET", "/tree");
1476
+ const tree = await r?.json();
1477
+ const hit = (tree?.roots || []).find(
1477
1478
  (n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
1478
1479
  );
1479
1480
  if (hit?.id) return hit.id;
1480
1481
  } catch {
1481
1482
  }
1482
1483
  try {
1483
- const r = await this.req("POST", this.bankUrl("/knowledge-base/folders"), { name });
1484
- return (await r.json()).id;
1484
+ const r = await this.pagesReq("POST", "/folders", { name });
1485
+ return (await r?.json())?.id;
1485
1486
  } catch {
1486
1487
  return void 0;
1487
1488
  }
@@ -1879,6 +1880,41 @@ function resolvePartial(cfg, patch) {
1879
1880
  return out;
1880
1881
  }
1881
1882
 
1883
+ // src/core/transcript-util.ts
1884
+ var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_pages|hindsight_page_refresh|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
1885
+ function stripInjectedMemory(s) {
1886
+ return s.replace(MEMORY_TAG_RE, "");
1887
+ }
1888
+ var TARGET_KEYS = [
1889
+ "file_path",
1890
+ "path",
1891
+ "notebook_path",
1892
+ "command",
1893
+ "pattern",
1894
+ "query",
1895
+ "url",
1896
+ "name",
1897
+ "id"
1898
+ ];
1899
+ var ACTION_TARGET_CAP = 100;
1900
+ function actionLine(tool, input) {
1901
+ let target = "";
1902
+ if (input && typeof input === "object") {
1903
+ const rec = input;
1904
+ for (const k of TARGET_KEYS) {
1905
+ const v = rec[k];
1906
+ if (typeof v === "string" && v.trim()) {
1907
+ target = v.trim().split("\n")[0];
1908
+ break;
1909
+ }
1910
+ }
1911
+ } else if (typeof input === "string") {
1912
+ target = input.trim().split("\n")[0];
1913
+ }
1914
+ if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
1915
+ return target ? `${tool} ${target}` : tool;
1916
+ }
1917
+
1882
1918
  // src/core/session-cache.ts
1883
1919
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, rmSync, writeFileSync } from "fs";
1884
1920
  import { tmpdir } from "os";
@@ -1958,43 +1994,6 @@ function fileCursorStore(harness) {
1958
1994
  import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
1959
1995
  import { tmpdir as tmpdir2 } from "os";
1960
1996
  import { dirname as dirname6, join as join9 } from "path";
1961
-
1962
- // src/core/transcript-util.ts
1963
- var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
1964
- function stripInjectedMemory(s) {
1965
- return s.replace(MEMORY_TAG_RE, "");
1966
- }
1967
- var TARGET_KEYS = [
1968
- "file_path",
1969
- "path",
1970
- "notebook_path",
1971
- "command",
1972
- "pattern",
1973
- "query",
1974
- "url",
1975
- "name",
1976
- "id"
1977
- ];
1978
- var ACTION_TARGET_CAP = 100;
1979
- function actionLine(tool, input) {
1980
- let target = "";
1981
- if (input && typeof input === "object") {
1982
- const rec = input;
1983
- for (const k of TARGET_KEYS) {
1984
- const v = rec[k];
1985
- if (typeof v === "string" && v.trim()) {
1986
- target = v.trim().split("\n")[0];
1987
- break;
1988
- }
1989
- }
1990
- } else if (typeof input === "string") {
1991
- target = input.trim().split("\n")[0];
1992
- }
1993
- if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
1994
- return target ? `${tool} ${target}` : tool;
1995
- }
1996
-
1997
- // src/core/turn-journal.ts
1998
1997
  var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
1999
1998
  function journalPath(harness, sessionId) {
2000
1999
  return join9(tmpdir2(), `hindsight-${harness}`, `${sessionId || "no-session"}.journal.jsonl`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectorize-io/hindsight-coding-agents",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/vectorize-io/hindsight.git",
@@ -107,6 +107,7 @@
107
107
  "smol-toml": "^1.8.0",
108
108
  "tsup": "^8.3.0",
109
109
  "typescript": "^5.6.0",
110
+ "undici": "^6.29.1",
110
111
  "vitest": "^4.1.12",
111
112
  "zod": "^4.4.3"
112
113
  },
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hindsight-coding-agents",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "description": "Long-term project memory for coding agents",
5
5
  "skills": "./skill",
6
6
  "hooks": "./hooks/hooks.json",
package/skill/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: hindsight-coding-agent
3
- description: How this machine's Hindsight coding-agent memory works — the plugin behind the 🧠 banner. Use when the user says "store/remember this in hindsight", asks what the memory/knowledge pages are, wants to configure per-repo memory (disable, rename banks, git depth), or something memory-related looks broken.
3
+ description: How this machine's Hindsight coding-agent memory works — the plugin behind the 🧠 banner. Use when the user says "store/remember this in hindsight", asks what the memory/pages are, wants to configure per-repo memory (disable, rename banks, git depth), or something memory-related looks broken.
4
4
  ---
5
5
 
6
6
  <!-- GENERATED from README.md (its skill:begin regions) + skill-src/preamble.md.
@@ -18,11 +18,11 @@ explains what happens automatically, which tools you have, and how to configure
18
18
  `↳ memory bank “coding-agent::<repo>”`). Worktrees share the main repo's bank.
19
19
  - **Ingestion builds itself**: on first open, the bank is seeded from recent commit messages and a
20
20
  read-only codebase survey; every session start, a background engine tops it up (new commits, new
21
- conversations) and keeps 5 knowledge pages current. There is NO ingest command to run.
21
+ conversations) and keeps 5 pages current. There is NO ingest command to run.
22
22
  - **Session synthesis**: by default, the first prompt of a session triggers one deep memory
23
- synthesis (`reflect`) injected into context. `autoInject` switches the source: `pages` (knowledge
24
- page search hits), `recall` (recalled observations), or `none` (nothing injected; the agent
25
- searches the knowledge pages first and reflects only when they are too shallow).
23
+ synthesis (`reflect`) injected into context. `autoInject` switches the source: `pages` (page
24
+ search hits), `recall` (recalled observations), or `none` (nothing injected; the agent
25
+ searches the pages first and reflects only when they are too shallow).
26
26
  - **Write-back**: the session transcript is retained into the bank automatically at session end
27
27
  (per-turn on opencode). The user never needs to "save" a conversation.
28
28
 
@@ -41,9 +41,9 @@ When the user says "store this in hindsight" / "remember this":
41
41
 
42
42
  ## Retrieving
43
43
 
44
- - `hindsight_search_knowledge_pages(query)` — FIRST STOP for project questions (components,
44
+ - `hindsight_search_pages(query)` — FIRST STOP for project questions (components,
45
45
  conventions, past decisions, initiatives). Server-side hybrid search, fast.
46
- - `hindsight_read_knowledge_page(page_id)` / `hindsight_list_knowledge_pages` — read pages fully.
46
+ - `hindsight_read_page(page_id)` / `hindsight_list_pages` — read pages fully.
47
47
  - `hindsight_reflect(query)` — deep reasoning over the whole memory for WHY questions and exact
48
48
  decided values; slower (seconds), use deliberately.
49
49
  - Credit visibly whenever memory informs an answer: start that part with
@@ -60,7 +60,7 @@ source contradicts it), FIX THE RECORD — don't just ignore it. Call
60
60
  checked (file/commit/output). Quote exact values verbatim.
61
61
 
62
62
  Newer facts supersede older ones in retrieval, so one clear correction permanently outranks the
63
- stale memory. Do this whenever you catch a wrong injected memory, a stale knowledge-page claim, or
63
+ stale memory. Do this whenever you catch a wrong injected memory, a stale page claim, or
64
64
  an outdated decision — silent disregard leaves the trap armed for the next session.
65
65
 
66
66
  ## Install / update
@@ -143,7 +143,7 @@ what reads it:
143
143
  authentication or rotating the key is picked up on the next call with nothing to restart —
144
144
  otherwise a rotation would leave a long-running agent failing every memory call until it was
145
145
  restarted. Everything else follows the table: `apiUrl`, `disabled`, bank routing, `gitIngest`, and
146
- the survey and knowledge-page settings.
146
+ the survey and page settings.
147
147
 
148
148
  `hindsight_diagnose` reports both sides of that gap — what the file says now, and what the running
149
149
  client is actually using.
@@ -211,20 +211,20 @@ hook by Codex...), so one shared config serves several agents side by side:
211
211
  | `defaultBankConfig` | — | bank-config fields of your own for the banks the plugin shapes, e.g. `{"enable_observations": false, "enable_auto_consolidation": false, "mental_model_min_refresh_interval_seconds": 21600}`. Keys are the bank-config API's own field names. Written under the same additive rule as the rest: only where the bank does not define the field, so a bank the plugin creates is born with these instead of the server's defaults and a value you set in the control plane is never overwritten. Wins over the template on a key both name (`enable_observations`); `retain_strategies`, `entity_labels` and `retain_extraction_mode` are refused, since the plugin governs them itself. Ignored with `manageBankConfig: false` — see **A bank you shape yourself** below. File-only, like `recallOptions`; in a `banks.<id>` section it replaces the global map rather than merging into it |
212
212
  | `observationScopes` | `"shared"` | how consolidation groups observations: `"shared"` (default) = ONE global scope per bank, so every agent on a repo builds one set of beliefs; also `"combined"` (the server default), `"per_tag"`, `"all_combinations"`, `[["t"]]`; `"per_source"` adds a scope per `source:` kind alongside the global one, so commit knowledge and conversation knowledge consolidate apart |
213
213
  | `disabled` | `false` | hard off-switch (inert plugin/hook — a no-memory baseline) |
214
- | `reflectTimeoutMs` | `20000` | **automatic** session-reflect timeout; on hook harnesses the installer registers a 30s prompt-hook timeout, so going above ~20s also means raising that hook's `timeout` in the host's config, or the host kills the hook mid-reflect; on timeout or a 5xx the hook falls back to knowledge-page search, then to a raw recall of observations (recorded) |
214
+ | `reflectTimeoutMs` | `20000` | **automatic** session-reflect timeout; on hook harnesses the installer registers a 30s prompt-hook timeout, so going above ~20s also means raising that hook's `timeout` in the host's config, or the host kills the hook mid-reflect; on timeout or a 5xx the hook falls back to page search, then to a raw recall of observations (recorded) |
215
215
  | `reflectToolTimeoutMs` | `330000` | timeout for the agent-invoked `hindsight_reflect` tool — a call the agent waits on, whose high-budget synthesis on a populated bank runs for minutes. Defaults above the server's own reflect wall timeout (`HINDSIGHT_API_REFLECT_WALL_TIMEOUT`, 300s) so the server decides when to give up. Unset, it inherits an explicitly raised `reflectTimeoutMs`, but a short one never lowers it |
216
216
  | `injectTimeoutMs` | `7000` | retrieval timeout in milliseconds for `autoInject: "pages"` and `autoInject: "recall"`; also the **shared** budget for page search then recall after a reflect timeout/5xx (recall gets only the time left after page search). Set e.g. `2000` to limit turn latency or `15000` for a slower self-hosted bank. Environment fallback: `HINDSIGHT_INJECT_TIMEOUT_MS`. On hook harnesses, injection must fit the host's prompt-hook timeout (30s by default); for reflect with fallback, allow for **`reflectTimeoutMs` + `injectTimeoutMs`**, and raise the host hook's `timeout` when needed |
217
217
  | `reflectBudget` | `"high"` | reflect budget for the `hindsight_reflect` tool: `"low"`, `"mid"` or `"high"`. Drop it on a large bank where high-budget synthesis exceeds the server's wall timeout. The automatic session-start reflect always uses `"low"` to fit its hook window and is unaffected |
218
- | `autoInject` | `"reflect"` | what to inject once, on the session's **first prompt**: `"reflect"` = a low-budget reflect synthesis (on timeout/5xx it falls back to page search, then recall); `"pages"` = the knowledge pages matching the prompt by search; `"recall"` = the bank's memories recalled for the prompt (what it asks for is `recallOptions`, observations by default); `"none"` = nothing — the agent searches knowledge pages first and reflects only when they are too shallow. `"pages"` and `"recall"` are retrieval only (no LLM), their time budget is `injectTimeoutMs`, and when one finds nothing for the prompt it tries again on the next one, up to 5 prompts |
218
+ | `autoInject` | `"reflect"` | what to inject once, on the session's **first prompt**: `"reflect"` = a low-budget reflect synthesis (on timeout/5xx it falls back to page search, then recall); `"pages"` = the pages matching the prompt by search; `"recall"` = the bank's memories recalled for the prompt (what it asks for is `recallOptions`, observations by default); `"none"` = nothing — the agent searches pages first and reflects only when they are too shallow. `"pages"` and `"recall"` are retrieval only (no LLM), their time budget is `injectTimeoutMs`, and when one finds nothing for the prompt it tries again on the next one, up to 5 prompts |
219
219
  | `autoReflect` | `true` | **deprecated** — use `autoInject`. Still honoured (`false` = `autoInject: "none"`), ignored when `autoInject` is set, and logs a deprecation warning |
220
- | `pageSearchLimit` | `3` | knowledge pages ONE search returns. Applies to every search of the bank — the `autoInject: "pages"` injection, the reflect fallback, and the agent's own `hindsight_search_knowledge_pages` tool — because the limit lives on the client they all share |
220
+ | `pageSearchLimit` | `3` | pages ONE search returns. Applies to every search of the bank — the `autoInject: "pages"` injection, the reflect fallback, and the agent's own `hindsight_search_pages` tool — because the limit lives on the client they all share |
221
221
  | `recallOptions` | see description | overrides merged key-by-key into the body of every recall — the `autoInject: "recall"` source and the reflect fallback. Keys are the API's own recall parameters, passed straight through, so anything recall accepts is settable without a new option here; `query` is the one field it cannot replace. The default body is `{"types": ["observation"], "budget": "low", "max_tokens": 2000, "include": {"entities": null}}`, and what you set is merged over it one key at a time — `{"max_tokens": 4000}` changes the budget and leaves the rest alone. Observations are the consolidated layer, so they answer best per token, but a bank with **consolidation disabled never grows any** and the default recall comes back empty on it: set `{"types": ["world", "experience"]}` there, or `{"types": null}` for every type. File-only, like `retainMetadata` — an object does not flatten into an env var |
222
- | `toolGuideExtra` | — | your own guidance on how the agent should treat memory, added **after** the built-in tool guide (at session start and on every refresh) and after the crediting note returned with `hindsight_search_knowledge_pages` results. It adds to the built-in text, never replaces it. Set it per harness or per bank like any other key, e.g. `"Memory is a past record, not current state: verify any claim against the code before acting on it."` |
223
- | `pageRefreshEveryTurns` | `1` | refetch the knowledge pages and re-inject the page roster + tool guide every N user turns (`0` also means 1) |
224
- | `pageTriggerType` | `"cron"` | when NEW knowledge pages refresh, i.e. what keeping them current costs — `"cron"` (default) on `pageTriggerCron` only and only when actually stale, `"auto-refresh"` after every consolidation that produced new material, `"manual"` never on their own. Auto-refresh is the most current and by far the most expensive: one synthesis per page per consolidation. Maps to the page's `trigger.refresh_cron`, or `trigger.refresh_after_consolidation` in the Hindsight API (`true` for auto-refresh, `false` for manual) |
222
+ | `toolGuideExtra` | — | your own guidance on how the agent should treat memory, added **after** the built-in tool guide (at session start and on every refresh) and after the crediting note returned with `hindsight_search_pages` results. It adds to the built-in text, never replaces it. Set it per harness or per bank like any other key, e.g. `"Memory is a past record, not current state: verify any claim against the code before acting on it."` |
223
+ | `pageRefreshEveryTurns` | `1` | refetch the pages and re-inject the page roster + tool guide every N user turns (`0` also means 1) |
224
+ | `pageTriggerType` | `"cron"` | when NEW pages refresh, i.e. what keeping them current costs — `"cron"` (default) on `pageTriggerCron` only and only when actually stale, `"auto-refresh"` after every consolidation that produced new material, `"manual"` never on their own. Auto-refresh is the most current and by far the most expensive: one synthesis per page per consolidation. Maps to the page's `trigger.refresh_cron`, or `trigger.refresh_after_consolidation` in the Hindsight API (`true` for auto-refresh, `false` for manual) |
225
225
  | `pageTriggerCron` | `"H * * * *"` | schedule for `pageTriggerType: "cron"` — UTC, standard 5-field cron, e.g. `"0 3 * * *"`. The default is hourly, each page on its own hashed minute. Sets the page's `trigger.refresh_cron`, which the API treats as mutually exclusive with `refresh_after_consolidation`; a scheduled refresh is skipped when nothing changed. Write a field as `H` to give each page its own value there — see **Spreading refreshes with `H`** below |
226
- | `pages` | every page | per-page configuration for the seeded knowledge pages, keyed by page name (case-insensitive): `false` skips a page entirely, `{"source_query": "..."}` seeds it with your question instead of the built-in one. Omitted, all five pages are seeded with their built-in queries. This is the supported way to own a page's wording — the plugin re-syncs a page whose live query differs from the one it is configured to have, so a query edited through the API or the control plane is replaced on the next session. A skipped page is **not deleted**: one already seeded keeps its content and stops being re-synced. The scoping clause is appended to your query too, so a reworded page cannot start reporting a dependency's decisions as this project's. File-only, like `recallOptions`; in a `banks.<id>` section it replaces the global map rather than merging into it |
227
- | `customPages` | — | knowledge pages of your own, seeded alongside the five above and keyed by the name they get: `{"Security posture": {"source_query": "...", "tags": ["knowledge:decision"]}}`. `source_query` is required; `tags` picks which facts feed the page and is optional — omitted, the page draws on everything the bank holds. A separate setting from `pages` on purpose, so that an unknown name there stays a typo warning rather than quietly creating a page. File-only, and replaced (not merged) by a `banks.<id>` section |
226
+ | `pages` | every page | per-page configuration for the seeded pages, keyed by page name (case-insensitive): `false` skips a page entirely, `{"source_query": "..."}` seeds it with your question instead of the built-in one. Omitted, all five pages are seeded with their built-in queries. This is the supported way to own a page's wording — the plugin re-syncs a page whose live query differs from the one it is configured to have, so a query edited through the API or the control plane is replaced on the next session. A skipped page is **not deleted**: one already seeded keeps its content and stops being re-synced. The scoping clause is appended to your query too, so a reworded page cannot start reporting a dependency's decisions as this project's. File-only, like `recallOptions`; in a `banks.<id>` section it replaces the global map rather than merging into it |
227
+ | `customPages` | — | pages of your own, seeded alongside the five above and keyed by the name they get: `{"Security posture": {"source_query": "...", "tags": ["knowledge:decision"]}}`. `source_query` is required; `tags` picks which facts feed the page and is optional — omitted, the page draws on everything the bank holds. A separate setting from `pages` on purpose, so that an unknown name there stays a typo warning rather than quietly creating a page. File-only, and replaced (not merged) by a `banks.<id>` section |
228
228
  | `autoSeed` | `true` | SessionStart: auto-seed a cold repo's bank from git history |
229
229
  | `seedLimit` | `300` | git-log document size: a full write keeps the newest commits, between half of this and this many (the window moves in steps of half), and logs how many older ones it drops |
230
230
  | `codebaseSurvey` | `true` | SessionStart: headless survey of a cold repo's structure, run only under the current harness's own CLI (Claude Code, Codex, Antigravity, opencode v1); other agents get no survey |
@@ -246,7 +246,7 @@ LLM synthesis per page per consolidation, on a repo that consolidates all day. S
246
246
  `pageTriggerType: "auto-refresh"` to go back to refreshing on every consolidation.
247
247
 
248
248
  `pageTriggerType`/`pageTriggerCron` decide only **when** a page refreshes. **How** it refreshes
249
- belongs to the server: Hindsight creates a knowledge page with a delta refresh (each pass edits the
249
+ belongs to the server: Hindsight creates a page with a delta refresh (each pass edits the
250
250
  page instead of rebuilding it) that doesn't reflect over sibling pages, and these settings merge
251
251
  over those defaults rather than replacing them.
252
252
 
@@ -284,7 +284,7 @@ file is the source of truth for these pages: to give one a different schedule, c
284
284
  page. Only the fields this plugin states are touched — a page's `mode`, its excluded siblings and
285
285
  its minimum refresh interval are left exactly as they are.
286
286
 
287
- ### Customize Knowledge Pages — `pages`
287
+ ### Customize Pages — `pages`
288
288
 
289
289
  Every repo gets the same five pages. They are a **taxonomy**, not a summary of your source: each one
290
290
  is synthesized from what the bank ingested — commit history and past conversations — and each is
@@ -405,7 +405,7 @@ it: the seed pass only visits the pages it is configured to own.
405
405
 
406
406
  Pointed at a bank, this plugin gives it the shape its ingestion needs: retain strategies for the
407
407
  kinds of document it writes (`git`, `gitlog`, `conversation`, `document`, `survey`), a `knowledge`
408
- entity-label group that routes facts to the knowledge pages, and — on a bank that has no missions of
408
+ entity-label group that routes facts to the pages, and — on a bank that has no missions of
409
409
  its own — the coding missions.
410
410
 
411
411
  **It only ever adds what is missing.** A strategy you defined, an edit you made to one of the
@@ -454,7 +454,7 @@ you configure yourself. That bank should then define the five strategies above i
454
454
  miss is **silent**: the server does not reject a retain naming a strategy the bank lacks, it logs a
455
455
  warning and extracts with the bank's own configuration — so a commit diff, a session transcript and
456
456
  a survey marker would all get the same generic treatment instead of the extraction each needs.
457
- Knowledge pages are seeded either way; `pageTriggerType` governs what they cost.
457
+ Pages are seeded either way; `pageTriggerType` governs what they cost.
458
458
 
459
459
  Like every field here it can be set per bank, which is usually where it belongs:
460
460
 
@@ -645,7 +645,7 @@ scope fills with beliefs built from chat transcripts. Only a per-document decisi
645
645
 
646
646
  It costs one extra consolidation pass per document, and it reads only `source:`, so a volatile
647
647
  provenance tag never becomes a scope. The global scope is still written first and unchanged, so the
648
- untagged observations knowledge pages read are unaffected.
648
+ untagged observations pages read are unaffected.
649
649
 
650
650
  `"per_tag"` and `"all_combinations"` split further still, and an explicit `[["project:demo"], …]`
651
651
  declares the scopes literally. `HINDSIGHT_OBSERVATION_SCOPES` sets the scalar modes; a scope list is
@@ -680,7 +680,7 @@ as a JSON line to `~/.hindsight/coding-agents-logs/diag.jsonl` (override with
680
680
 
681
681
  `reflect_failed` / `pages_failed` record the error; if you're comparing memory-on vs memory-off,
682
682
  check this file — a run whose reflects failed is a no-memory run. When the failure was a timeout or
683
- a 5xx, the hook falls back to knowledge-page search and, if no page matches, to a raw recall of the
683
+ a 5xx, the hook falls back to page search and, if no page matches, to a raw recall of the
684
684
  bank's memories: `reflect_fallback_pages` / `reflect_fallback_observations` record what each
685
685
  step returned (`*_failed` when it errored). Seed starts are logged as
686
686
  `seed_started`.