@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
@@ -457,14 +457,14 @@ var RETAIN_STRATEGIES = {
457
457
  retain_chunk_size: 12e3
458
458
  }
459
459
  };
460
- var KNOWLEDGE_LABELS = {
460
+ var PAGE_LABELS = {
461
461
  key: "knowledge",
462
462
  type: "multi-values",
463
463
  // 0, 1, or several — empty is normal
464
464
  optional: true,
465
465
  tag: true,
466
466
  // emits knowledge:<value> onto the fact's tags
467
- 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.",
467
+ 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.",
468
468
  values: [
469
469
  {
470
470
  value: "feature-work",
@@ -621,7 +621,7 @@ var CODING_BANK_TEMPLATE = {
621
621
  retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
622
622
  retain_default_strategy: "git",
623
623
  retain_strategies: RETAIN_STRATEGIES,
624
- entity_labels: [KNOWLEDGE_LABELS],
624
+ entity_labels: [PAGE_LABELS],
625
625
  entities_allow_free_form: true
626
626
  }
627
627
  };
@@ -673,7 +673,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
673
673
  }
674
674
 
675
675
  // package.json
676
- var version = "0.8.6";
676
+ var version = "0.8.7";
677
677
 
678
678
  // src/core/util.ts
679
679
  import { accessSync, constants, statSync as statSync2 } from "fs";
@@ -765,11 +765,11 @@ function retryAfterMs(header) {
765
765
  const at = Date.parse(header);
766
766
  return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
767
767
  }
768
- var KnowledgePagesUnavailableError = class extends Error {
769
- code = "knowledge_pages_unavailable";
768
+ var PagesUnavailableError = class extends Error {
769
+ code = "pages_unavailable";
770
770
  constructor() {
771
- super("Hindsight server does not support knowledge pages");
772
- this.name = "KnowledgePagesUnavailableError";
771
+ super("Hindsight server does not support pages");
772
+ this.name = "PagesUnavailableError";
773
773
  }
774
774
  };
775
775
  async function isEndpointMissing(r) {
@@ -780,6 +780,10 @@ async function isEndpointMissing(r) {
780
780
  return false;
781
781
  }
782
782
  }
783
+ function pagesPath(sub, legacy = false) {
784
+ if (!legacy) return `/pages${sub}`;
785
+ return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
786
+ }
783
787
  var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
784
788
  var ReflectError = class extends Error {
785
789
  constructor(message, status, timedOut, options) {
@@ -848,7 +852,7 @@ var HindsightClient = class {
848
852
  opIds = [];
849
853
  // async operation ids collected by retain(), for drain()
850
854
  /** Tri-state capability probe: unknown until the first page request, then cached. */
851
- knowledgePagesSupported;
855
+ pagesSupported;
852
856
  /** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
853
857
  idempotentRetain;
854
858
  log;
@@ -1077,7 +1081,7 @@ var HindsightClient = class {
1077
1081
  return (j.total ?? j.items?.length ?? 0) > 0;
1078
1082
  }
1079
1083
  /** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
1080
- * entity labels), then seed knowledge pages when the server supports them. Both halves are
1084
+ * entity labels), then seed pages when the server supports them. Both halves are
1081
1085
  * idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
1082
1086
  * extraction mode of the plugin's own strategies, which follows its config (#4560) — so
1083
1087
  * the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
@@ -1259,29 +1263,45 @@ var HindsightClient = class {
1259
1263
  const j = await r.json();
1260
1264
  return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
1261
1265
  }
1266
+ /** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
1267
+ * page routes moved to `/pages/...`. Remove in 2.x. */
1268
+ legacyPagesPaths = false;
1262
1269
  /**
1263
- * Latch `knowledgePagesSupported = false` iff this response really means the endpoint is absent.
1264
- * Returns whether it latched. A bank-not-found 404 is NOT a capability verdict — it is the
1265
- * expected answer before the bank's first retain — so it must never cache a negative (#4607).
1270
+ * Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
1271
+ *
1272
+ * Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
1273
+ * unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
1274
+ * older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
1275
+ * a capability verdict — it is the expected answer before the bank's first retain — so it is
1276
+ * returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
1266
1277
  *
1267
1278
  * Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
1268
1279
  * the 405/501 this used to check for never reach a caller in the first place.
1269
1280
  */
1270
- async pagesUnsupported(r) {
1271
- if (r.status !== 404 || !await isEndpointMissing(r)) return false;
1272
- this.knowledgePagesSupported = false;
1273
- return true;
1281
+ async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
1282
+ const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
1283
+ let r = await send(this.legacyPagesPaths);
1284
+ if (r.status !== 404 || !await isEndpointMissing(r)) return r;
1285
+ if (!this.legacyPagesPaths) {
1286
+ r = await send(true);
1287
+ if (r.status !== 404 || !await isEndpointMissing(r)) {
1288
+ this.legacyPagesPaths = true;
1289
+ return r;
1290
+ }
1291
+ }
1292
+ this.pagesSupported = false;
1293
+ return null;
1274
1294
  }
1275
1295
  /**
1276
- * The bank's knowledge-base tree (folders + pages, nested). The tree carries names, source
1296
+ * The bank's page tree (folders + pages, nested). The tree carries names, source
1277
1297
  * queries and staleness but NOT synthesized content, so it is cheap enough to poll.
1278
1298
  */
1279
1299
  async tree() {
1280
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1281
- const r = await this.req("GET", this.bankUrl("/knowledge-base/tree"));
1282
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1300
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1301
+ const r = await this.pagesReq("GET", "/tree");
1302
+ if (!r) throw new PagesUnavailableError();
1283
1303
  if (r.status === 404) return [];
1284
- this.knowledgePagesSupported = true;
1304
+ this.pagesSupported = true;
1285
1305
  try {
1286
1306
  return (await r.json()).roots ?? [];
1287
1307
  } catch {
@@ -1289,13 +1309,13 @@ var HindsightClient = class {
1289
1309
  }
1290
1310
  }
1291
1311
  /**
1292
- * List knowledge pages (ids + names only — no synthesized content), flattened out of the tree
1312
+ * List pages (ids + names only — no synthesized content), flattened out of the tree
1293
1313
  * and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
1294
1314
  * to read, and a caller enumerating pages wants leaves, not structure.
1295
1315
  *
1296
- * NOTE the ids are knowledge-base node ids (`kp-…`), NOT the backing mental-model ids. Every
1297
- * page read/update in this client goes through the same knowledge-base ids, so a page id from
1298
- * here, from `searchKnowledgePages`, or from a `[[page:<id>]]` link all resolve identically.
1316
+ * NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
1317
+ * page read/update in this client goes through the same page ids, so a page id from
1318
+ * here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
1299
1319
  */
1300
1320
  async listPages() {
1301
1321
  const items = [];
@@ -1317,34 +1337,26 @@ var HindsightClient = class {
1317
1337
  return { items };
1318
1338
  }
1319
1339
  /**
1320
- * Read one knowledge page's synthesized content by knowledge-base id, shaped by `shapePage` so
1340
+ * Read one page's synthesized content by page id, shaped by `shapePage` so
1321
1341
  * the body arrives once. The endpoint omits the internal reflect trace that built
1322
1342
  * the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
1323
1343
  * token cap.
1324
1344
  */
1325
1345
  async getPage(pageId) {
1326
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1327
- const r = await this.req(
1328
- "GET",
1329
- this.bankUrl(`/knowledge-base/pages/${encodeURIComponent(pageId)}`)
1330
- );
1331
- if (r.status === 404) throw new Error(`knowledge page not found: ${pageId}`);
1346
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1347
+ const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
1348
+ if (!r) throw new PagesUnavailableError();
1349
+ if (r.status === 404) throw new Error(`page not found: ${pageId}`);
1332
1350
  return shapePage(await r.json());
1333
1351
  }
1334
- /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's knowledge pages.
1352
+ /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
1335
1353
  * Returns page-level hits with a relevance snippet — the real search behind
1336
- * hindsight_search_knowledge_pages. */
1337
- async searchKnowledgePages(query, opts = {}) {
1338
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1354
+ * hindsight_search_pages. */
1355
+ async searchPages(query, opts = {}) {
1356
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1339
1357
  const q = `?q=${encodeURIComponent(query)}&limit=${opts.limit ?? this.pageSearchLimit}`;
1340
- const r = await this.req(
1341
- "GET",
1342
- this.bankUrl(`/knowledge-base/search${q}`),
1343
- void 0,
1344
- [],
1345
- opts.timeoutMs
1346
- );
1347
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1358
+ const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
1359
+ if (!r) throw new PagesUnavailableError();
1348
1360
  if (r.status === 404) return [];
1349
1361
  const j = await r.json();
1350
1362
  return (j.results ?? []).map((x) => ({
@@ -1356,9 +1368,9 @@ var HindsightClient = class {
1356
1368
  }));
1357
1369
  }
1358
1370
  /**
1359
- * Seed the fixed page taxonomy as knowledge-base pages at the tree root, idempotently.
1371
+ * Seed the fixed page taxonomy as pages at the tree root, idempotently.
1360
1372
  *
1361
- * Matched by NAME, not id: `/knowledge-base/pages` mints its own `kp-…` id, so a stable
1373
+ * Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
1362
1374
  * client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
1363
1375
  * off a slug). Names are unique per folder server-side, which makes them a sound key.
1364
1376
  *
@@ -1373,8 +1385,8 @@ var HindsightClient = class {
1373
1385
  try {
1374
1386
  roots = await this.tree();
1375
1387
  } catch (e) {
1376
- if (e instanceof KnowledgePagesUnavailableError) {
1377
- this.log(`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`);
1388
+ if (e instanceof PagesUnavailableError) {
1389
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1378
1390
  return;
1379
1391
  }
1380
1392
  throw e;
@@ -1397,11 +1409,9 @@ var HindsightClient = class {
1397
1409
  trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
1398
1410
  };
1399
1411
  if (!hit) {
1400
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), body, [409]);
1401
- if (await this.pagesUnsupported(r)) {
1402
- this.log(
1403
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1404
- );
1412
+ const r = await this.pagesReq("POST", "", body, [409]);
1413
+ if (!r) {
1414
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1405
1415
  return;
1406
1416
  }
1407
1417
  if (r.status === 404) {
@@ -1422,15 +1432,9 @@ var HindsightClient = class {
1422
1432
  );
1423
1433
  }
1424
1434
  if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
1425
- const r = await this.req(
1426
- "PATCH",
1427
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
1428
- patch
1429
- );
1430
- if (await this.pagesUnsupported(r)) {
1431
- this.log(
1432
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1433
- );
1435
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
1436
+ if (!r) {
1437
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1434
1438
  return;
1435
1439
  }
1436
1440
  if (r.status === 404) {
@@ -1442,7 +1446,7 @@ var HindsightClient = class {
1442
1446
  }
1443
1447
  const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
1444
1448
  this.log(
1445
- `[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` : "")
1449
+ `[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` : "")
1446
1450
  );
1447
1451
  }
1448
1452
  /**
@@ -1476,12 +1480,8 @@ var HindsightClient = class {
1476
1480
  if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
1477
1481
  }
1478
1482
  if (!patch.trigger && !patch.source_query) continue;
1479
- const r = await this.req(
1480
- "PATCH",
1481
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
1482
- patch
1483
- );
1484
- if (r.status === 404) continue;
1483
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
1484
+ if (!r || r.status === 404) continue;
1485
1485
  updated++;
1486
1486
  }
1487
1487
  return updated;
@@ -1507,7 +1507,7 @@ var HindsightClient = class {
1507
1507
  let pageId = args.relatesToPageId;
1508
1508
  if (!pageId) {
1509
1509
  const folderId = await this.ensureFolder("Initiatives");
1510
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
1510
+ const r = await this.pagesReq("POST", "", {
1511
1511
  name: args.title,
1512
1512
  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),
1513
1513
  parent_id: folderId,
@@ -1516,8 +1516,8 @@ var HindsightClient = class {
1516
1516
  trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
1517
1517
  });
1518
1518
  try {
1519
- const j = await r.json();
1520
- pageId = j.page_id ?? j.id;
1519
+ const j = await r?.json();
1520
+ pageId = j?.page_id ?? j?.id;
1521
1521
  } catch {
1522
1522
  }
1523
1523
  pageId ||= `initiative-${this.slugify(args.title)}`;
@@ -1535,16 +1535,17 @@ var HindsightClient = class {
1535
1535
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
1536
1536
  async ensureFolder(name) {
1537
1537
  try {
1538
- const tree = await (await this.req("GET", this.bankUrl("/knowledge-base/tree"))).json();
1539
- const hit = (tree.roots || []).find(
1538
+ const r = await this.pagesReq("GET", "/tree");
1539
+ const tree = await r?.json();
1540
+ const hit = (tree?.roots || []).find(
1540
1541
  (n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
1541
1542
  );
1542
1543
  if (hit?.id) return hit.id;
1543
1544
  } catch {
1544
1545
  }
1545
1546
  try {
1546
- const r = await this.req("POST", this.bankUrl("/knowledge-base/folders"), { name });
1547
- return (await r.json()).id;
1547
+ const r = await this.pagesReq("POST", "/folders", { name });
1548
+ return (await r?.json())?.id;
1548
1549
  } catch {
1549
1550
  return void 0;
1550
1551
  }
@@ -1942,6 +1943,41 @@ function resolvePartial(cfg, patch) {
1942
1943
  return out;
1943
1944
  }
1944
1945
 
1946
+ // src/core/transcript-util.ts
1947
+ 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;
1948
+ function stripInjectedMemory(s) {
1949
+ return s.replace(MEMORY_TAG_RE, "");
1950
+ }
1951
+ var TARGET_KEYS = [
1952
+ "file_path",
1953
+ "path",
1954
+ "notebook_path",
1955
+ "command",
1956
+ "pattern",
1957
+ "query",
1958
+ "url",
1959
+ "name",
1960
+ "id"
1961
+ ];
1962
+ var ACTION_TARGET_CAP = 100;
1963
+ function actionLine(tool, input) {
1964
+ let target = "";
1965
+ if (input && typeof input === "object") {
1966
+ const rec = input;
1967
+ for (const k of TARGET_KEYS) {
1968
+ const v = rec[k];
1969
+ if (typeof v === "string" && v.trim()) {
1970
+ target = v.trim().split("\n")[0];
1971
+ break;
1972
+ }
1973
+ }
1974
+ } else if (typeof input === "string") {
1975
+ target = input.trim().split("\n")[0];
1976
+ }
1977
+ if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
1978
+ return target ? `${tool} ${target}` : tool;
1979
+ }
1980
+
1945
1981
  // src/core/brand.ts
1946
1982
  function brandWord() {
1947
1983
  const start = [0, 116, 217];
@@ -1956,7 +1992,7 @@ function brandWord() {
1956
1992
  return `${out}\x1B[0m`;
1957
1993
  }
1958
1994
 
1959
- // src/core/knowledge-injection.ts
1995
+ // src/core/page-injection.ts
1960
1996
  function parsePageList(raw) {
1961
1997
  const items = raw?.items;
1962
1998
  if (!Array.isArray(items)) return [];
@@ -1968,12 +2004,12 @@ function parsePageList(raw) {
1968
2004
  }
1969
2005
  return out;
1970
2006
  }
1971
- var EMPTY_STATE = "No knowledge pages yet \u2014 Hindsight is still learning this repo; they'll appear as it processes.";
2007
+ var EMPTY_STATE = "No pages yet \u2014 Hindsight is still learning this repo; they'll appear as it processes.";
1972
2008
  function indexLine(pages) {
1973
- const count = pages.length === 1 ? "1 knowledge page covers" : `${pages.length} knowledge pages cover`;
1974
- return `${count} this repository \u2014 architecture, conventions, past decisions and in-flight initiatives. They are deliberately NOT listed here: call hindsight_search_knowledge_pages(query) to find the ones that bear on the current turn, then hindsight_read_knowledge_page(<id>) on anything the results show is worth reading in full.`;
2009
+ const count = pages.length === 1 ? "1 page covers" : `${pages.length} pages cover`;
2010
+ return `${count} this repository \u2014 architecture, conventions, past decisions and in-flight initiatives. They are deliberately NOT listed here: call hindsight_search_pages(query) to find the ones that bear on the current turn, then hindsight_read_page(<id>) on anything the results show is worth reading in full.`;
1975
2011
  }
1976
- var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP, and the way IN to everything below. The code shows what is true today but not what was decided or why; memory shows what was decided or said back then but not whether it still holds. Work built from either alone goes wrong: from code alone it quietly re-litigates settled questions, from memory alone it acts on stale claims. Search BEFORE you act whenever the turn is one of these \u2014 they are the ones that go wrong silently:
2012
+ var TOOL_GUIDE = `- hindsight_search_pages(query) \u2014 FIRST STOP, and the way IN to everything below. The code shows what is true today but not what was decided or why; memory shows what was decided or said back then but not whether it still holds. Work built from either alone goes wrong: from code alone it quietly re-litigates settled questions, from memory alone it acts on stale claims. Search BEFORE you act whenever the turn is one of these \u2014 they are the ones that go wrong silently:
1977
2013
  \u2022 the user reports a bug or a wrong response (the intended behaviour, and the status code or value it should return, may already have been decided);
1978
2014
  \u2022 you are about to write or change a test (what this project expects a change to ship with, and how it asserts, is a convention, not a preference);
1979
2015
  \u2022 you are implementing something new, or two parts have to fit together;
@@ -1981,25 +2017,25 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP, a
1981
2017
  \u2022 you are about to commit, and need to know what the change was supposed to honour.
1982
2018
  It ranks the pages by relevance and returns the matching passage, which a page title cannot tell you. What it returns is a past record, not a live reading: a claim that something was fixed, passes, or works is what someone said then \u2014 check it against the code before you rely on it, and say so when the two disagree.
1983
2019
  CREDITING IS NOT OPTIONAL AND NOT A JUDGEMENT CALL. If you called this tool and anything it returned reached your reply \u2014 quoted, paraphrased, or merely confirming what you were about to say \u2014 open that part with a markdown blockquote, exactly: "> \u{1F9E0} **From Hindsight memory (<page>)** \u2014 <the specific facts you drew on>". Rewriting a snippet in your own words does not make it yours. A search that turned up nothing useful needs no mention at all \u2014 just carry on.
1984
- - hindsight_list_knowledge_pages / hindsight_read_knowledge_page \u2014 BEFORE substantial work, list the pages and read the relevant ones to ground yourself in this repo's architecture, conventions, and past decisions instead of re-deriving them from the code; follow any [[page:<id>]] links you see.
2020
+ - hindsight_list_pages / hindsight_read_page \u2014 BEFORE substantial work, list the pages and read the relevant ones to ground yourself in this repo's architecture, conventions, and past decisions instead of re-deriving them from the code; follow any [[page:<id>]] links you see.
1985
2021
  - hindsight_reflect(query) \u2014 when pages are too shallow and you need the WHY: deep reasoning over the repo's full memory for the past decision and exact values that explain a behavior or bug (slower \u2014 use deliberately, and credit results with a blockquote header "> \u{1F9E0} **From Hindsight memory** \u2014 <summary>").
1986
2022
  - hindsight_capture_initiative(title, summary) \u2014 right after the user approves a plan or finishes brainstorming a new feature/capability and you are about to start implementing (BEFORE you write any code), call this to record it as a tracked page; then call it AGAIN with relates_to_page_id set to that page whenever the goal, scope, or rationale materially changes mid-work, so the page tracks the current plan and not the opening one. Skip bug fixes, small tweaks, chores, and trivial course-corrections.
1987
2023
  - hindsight_ingest_document(title, content) \u2014 save an external document or durable notes/findings you want remembered (not the current conversation \u2014 that is captured automatically at session end).`;
1988
- var PAGES_FIRST_ON_GOALS = "- The user just set a NEW task or goal \u2192 search the knowledge pages FIRST with hindsight_search_knowledge_pages. No synthesis is injected automatically in this configuration; call hindsight_reflect only when those pages are too shallow and deeper reasoning is needed.\n";
2024
+ var PAGES_FIRST_ON_GOALS = "- The user just set a NEW task or goal \u2192 search the pages FIRST with hindsight_search_pages. No synthesis is injected automatically in this configuration; call hindsight_reflect only when those pages are too shallow and deeper reasoning is needed.\n";
1989
2025
  function toolGuide(opts) {
1990
2026
  const extra = opts?.extra?.trim();
1991
2027
  return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE + (extra ? `
1992
2028
  ${extra}` : "");
1993
2029
  }
1994
- function buildKnowledgePreamble(pages, opts) {
2030
+ function buildPagesPreamble(pages, opts) {
1995
2031
  const body = pages.length ? indexLine(pages) : EMPTY_STATE;
1996
- return `<hindsight_knowledge>
1997
- This repository has a Hindsight memory + knowledge base (curated, continuously-updated pages plus the raw memory behind them). The tools below are registered, but you must actually CALL them at the right moments:
2032
+ return `<hindsight_pages>
2033
+ This repository has a Hindsight memory + pages (curated, continuously-updated pages plus the raw memory behind them). The tools below are registered, but you must actually CALL them at the right moments:
1998
2034
  ${toolGuide(opts)}
1999
2035
  ALSO your correction tool: when you verify a Hindsight memory is wrong or stale, ingest a "Correction: <topic>" doc stating what memory claimed, what is true now, and the evidence \u2014 newer facts supersede older ones.
2000
2036
  ${body}
2001
2037
  This tool guide and the page list are re-injected for you periodically as things change.
2002
- </hindsight_knowledge>`;
2038
+ </hindsight_pages>`;
2003
2039
  }
2004
2040
 
2005
2041
  // src/core/session-cache.ts
@@ -2069,43 +2105,6 @@ function sessionRootDir(harness, sessionId, cwd) {
2069
2105
  import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
2070
2106
  import { tmpdir as tmpdir2 } from "os";
2071
2107
  import { dirname as dirname6, join as join9 } from "path";
2072
-
2073
- // src/core/transcript-util.ts
2074
- 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;
2075
- function stripInjectedMemory(s) {
2076
- return s.replace(MEMORY_TAG_RE, "");
2077
- }
2078
- var TARGET_KEYS = [
2079
- "file_path",
2080
- "path",
2081
- "notebook_path",
2082
- "command",
2083
- "pattern",
2084
- "query",
2085
- "url",
2086
- "name",
2087
- "id"
2088
- ];
2089
- var ACTION_TARGET_CAP = 100;
2090
- function actionLine(tool, input) {
2091
- let target = "";
2092
- if (input && typeof input === "object") {
2093
- const rec = input;
2094
- for (const k of TARGET_KEYS) {
2095
- const v = rec[k];
2096
- if (typeof v === "string" && v.trim()) {
2097
- target = v.trim().split("\n")[0];
2098
- break;
2099
- }
2100
- }
2101
- } else if (typeof input === "string") {
2102
- target = input.trim().split("\n")[0];
2103
- }
2104
- if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
2105
- return target ? `${tool} ${target}` : tool;
2106
- }
2107
-
2108
- // src/core/turn-journal.ts
2109
2108
  var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
2110
2109
 
2111
2110
  // src/core/retain-cursor.ts
@@ -3454,11 +3453,11 @@ async function buildSessionStartContext(args) {
3454
3453
  try {
3455
3454
  pages = parsePageList(await client.listPages());
3456
3455
  } catch {
3457
- if (client.knowledgePagesSupported === false) {
3458
- diag(harness, "knowledge_pages_unavailable", { bank: bankId });
3456
+ if (client.pagesSupported === false) {
3457
+ diag(harness, "pages_unavailable", { bank: bankId });
3459
3458
  }
3460
3459
  }
3461
- const additionalContext = buildKnowledgePreamble(pages, {
3460
+ const additionalContext = buildPagesPreamble(pages, {
3462
3461
  reflectOnNewGoals: cfg.autoInject !== "reflect",
3463
3462
  extra: cfg.toolGuideExtra
3464
3463
  });