@vectorize-io/hindsight-coding-agents 0.8.5 → 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 +36 -30
  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 +205 -215
  7. package/dist/claude-stop-hook.js +113 -114
  8. package/dist/cline.js +206 -211
  9. package/dist/codebuddy-hook.js +130 -135
  10. package/dist/codebuddy-sessionstart-hook.js +205 -215
  11. package/dist/codebuddy-stop-hook.js +113 -114
  12. package/dist/codex-hook.js +130 -135
  13. package/dist/codex-sessionstart-hook.js +205 -215
  14. package/dist/codex-stop-hook.js +113 -114
  15. package/dist/copilot-hook.js +130 -135
  16. package/dist/copilot-sessionstart-hook.js +205 -215
  17. package/dist/copilot-stop-hook.js +113 -114
  18. package/dist/cursor-hook.js +130 -135
  19. package/dist/cursor-sessionstart-hook.js +205 -215
  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 +205 -215
  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 +205 -215
  28. package/dist/devin-stop-hook.js +113 -114
  29. package/dist/droid-hook.js +130 -135
  30. package/dist/droid-sessionstart-hook.js +205 -215
  31. package/dist/droid-stop-hook.js +113 -114
  32. package/dist/dsh.js +235 -248
  33. package/dist/grok-hook.js +130 -135
  34. package/dist/grok-sessionstart-hook.js +205 -215
  35. package/dist/grok-stop-hook.js +113 -114
  36. package/dist/hindsight-seed.js +1 -1
  37. package/dist/index.js +236 -249
  38. package/dist/installer.js +30 -28
  39. package/dist/kilo.js +236 -249
  40. package/dist/kimi-hook.js +130 -135
  41. package/dist/kimi-sessionstart-hook.js +205 -215
  42. package/dist/kimi-stop-hook.js +113 -114
  43. package/dist/mcp-server.js +94 -93
  44. package/dist/opencode2.js +236 -249
  45. package/dist/pi.js +235 -248
  46. package/dist/prime-agent.js +235 -248
  47. package/dist/qwen-hook.js +130 -135
  48. package/dist/qwen-sessionstart-hook.js +205 -215
  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 +205 -215
  53. package/dist/traecode-stop-hook.js +113 -114
  54. package/dist/workbuddy-hook.js +130 -135
  55. package/dist/workbuddy-sessionstart-hook.js +205 -215
  56. package/dist/workbuddy-stop-hook.js +113 -114
  57. package/dist/zcode-hook.js +130 -135
  58. package/dist/zcode-sessionstart-hook.js +205 -215
  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 +26 -26
package/dist/cline.js CHANGED
@@ -437,14 +437,14 @@ var RETAIN_STRATEGIES = {
437
437
  retain_chunk_size: 12e3
438
438
  }
439
439
  };
440
- var KNOWLEDGE_LABELS = {
440
+ var PAGE_LABELS = {
441
441
  key: "knowledge",
442
442
  type: "multi-values",
443
443
  // 0, 1, or several — empty is normal
444
444
  optional: true,
445
445
  tag: true,
446
446
  // emits knowledge:<value> onto the fact's tags
447
- 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.",
447
+ 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.",
448
448
  values: [
449
449
  {
450
450
  value: "feature-work",
@@ -601,7 +601,7 @@ var CODING_BANK_TEMPLATE = {
601
601
  retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
602
602
  retain_default_strategy: "git",
603
603
  retain_strategies: RETAIN_STRATEGIES,
604
- entity_labels: [KNOWLEDGE_LABELS],
604
+ entity_labels: [PAGE_LABELS],
605
605
  entities_allow_free_form: true
606
606
  }
607
607
  };
@@ -653,7 +653,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
653
653
  }
654
654
 
655
655
  // package.json
656
- var version = "0.8.5";
656
+ var version = "0.8.7";
657
657
 
658
658
  // src/core/util.ts
659
659
  import { accessSync, constants, statSync as statSync2 } from "fs";
@@ -736,11 +736,11 @@ function retryAfterMs(header) {
736
736
  const at = Date.parse(header);
737
737
  return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
738
738
  }
739
- var KnowledgePagesUnavailableError = class extends Error {
740
- code = "knowledge_pages_unavailable";
739
+ var PagesUnavailableError = class extends Error {
740
+ code = "pages_unavailable";
741
741
  constructor() {
742
- super("Hindsight server does not support knowledge pages");
743
- this.name = "KnowledgePagesUnavailableError";
742
+ super("Hindsight server does not support pages");
743
+ this.name = "PagesUnavailableError";
744
744
  }
745
745
  };
746
746
  async function isEndpointMissing(r) {
@@ -751,6 +751,10 @@ async function isEndpointMissing(r) {
751
751
  return false;
752
752
  }
753
753
  }
754
+ function pagesPath(sub, legacy = false) {
755
+ if (!legacy) return `/pages${sub}`;
756
+ return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
757
+ }
754
758
  var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
755
759
  var ReflectError = class extends Error {
756
760
  constructor(message, status, timedOut, options) {
@@ -819,7 +823,7 @@ var HindsightClient = class {
819
823
  opIds = [];
820
824
  // async operation ids collected by retain(), for drain()
821
825
  /** Tri-state capability probe: unknown until the first page request, then cached. */
822
- knowledgePagesSupported;
826
+ pagesSupported;
823
827
  /** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
824
828
  idempotentRetain;
825
829
  log;
@@ -1048,7 +1052,7 @@ var HindsightClient = class {
1048
1052
  return (j.total ?? j.items?.length ?? 0) > 0;
1049
1053
  }
1050
1054
  /** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
1051
- * entity labels), then seed knowledge pages when the server supports them. Both halves are
1055
+ * entity labels), then seed pages when the server supports them. Both halves are
1052
1056
  * idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
1053
1057
  * extraction mode of the plugin's own strategies, which follows its config (#4560) — so
1054
1058
  * the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
@@ -1230,29 +1234,45 @@ var HindsightClient = class {
1230
1234
  const j = await r.json();
1231
1235
  return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
1232
1236
  }
1237
+ /** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
1238
+ * page routes moved to `/pages/...`. Remove in 2.x. */
1239
+ legacyPagesPaths = false;
1233
1240
  /**
1234
- * Latch `knowledgePagesSupported = false` iff this response really means the endpoint is absent.
1235
- * Returns whether it latched. A bank-not-found 404 is NOT a capability verdict — it is the
1236
- * expected answer before the bank's first retain — so it must never cache a negative (#4607).
1241
+ * Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
1242
+ *
1243
+ * Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
1244
+ * unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
1245
+ * older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
1246
+ * a capability verdict — it is the expected answer before the bank's first retain — so it is
1247
+ * returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
1237
1248
  *
1238
1249
  * Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
1239
1250
  * the 405/501 this used to check for never reach a caller in the first place.
1240
1251
  */
1241
- async pagesUnsupported(r) {
1242
- if (r.status !== 404 || !await isEndpointMissing(r)) return false;
1243
- this.knowledgePagesSupported = false;
1244
- return true;
1252
+ async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
1253
+ const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
1254
+ let r = await send(this.legacyPagesPaths);
1255
+ if (r.status !== 404 || !await isEndpointMissing(r)) return r;
1256
+ if (!this.legacyPagesPaths) {
1257
+ r = await send(true);
1258
+ if (r.status !== 404 || !await isEndpointMissing(r)) {
1259
+ this.legacyPagesPaths = true;
1260
+ return r;
1261
+ }
1262
+ }
1263
+ this.pagesSupported = false;
1264
+ return null;
1245
1265
  }
1246
1266
  /**
1247
- * The bank's knowledge-base tree (folders + pages, nested). The tree carries names, source
1267
+ * The bank's page tree (folders + pages, nested). The tree carries names, source
1248
1268
  * queries and staleness but NOT synthesized content, so it is cheap enough to poll.
1249
1269
  */
1250
1270
  async tree() {
1251
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1252
- const r = await this.req("GET", this.bankUrl("/knowledge-base/tree"));
1253
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1271
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1272
+ const r = await this.pagesReq("GET", "/tree");
1273
+ if (!r) throw new PagesUnavailableError();
1254
1274
  if (r.status === 404) return [];
1255
- this.knowledgePagesSupported = true;
1275
+ this.pagesSupported = true;
1256
1276
  try {
1257
1277
  return (await r.json()).roots ?? [];
1258
1278
  } catch {
@@ -1260,13 +1280,13 @@ var HindsightClient = class {
1260
1280
  }
1261
1281
  }
1262
1282
  /**
1263
- * List knowledge pages (ids + names only — no synthesized content), flattened out of the tree
1283
+ * List pages (ids + names only — no synthesized content), flattened out of the tree
1264
1284
  * and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
1265
1285
  * to read, and a caller enumerating pages wants leaves, not structure.
1266
1286
  *
1267
- * NOTE the ids are knowledge-base node ids (`kp-…`), NOT the backing mental-model ids. Every
1268
- * page read/update in this client goes through the same knowledge-base ids, so a page id from
1269
- * here, from `searchKnowledgePages`, or from a `[[page:<id>]]` link all resolve identically.
1287
+ * NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
1288
+ * page read/update in this client goes through the same page ids, so a page id from
1289
+ * here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
1270
1290
  */
1271
1291
  async listPages() {
1272
1292
  const items = [];
@@ -1288,34 +1308,26 @@ var HindsightClient = class {
1288
1308
  return { items };
1289
1309
  }
1290
1310
  /**
1291
- * Read one knowledge page's synthesized content by knowledge-base id, shaped by `shapePage` so
1311
+ * Read one page's synthesized content by page id, shaped by `shapePage` so
1292
1312
  * the body arrives once. The endpoint omits the internal reflect trace that built
1293
1313
  * the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
1294
1314
  * token cap.
1295
1315
  */
1296
1316
  async getPage(pageId) {
1297
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1298
- const r = await this.req(
1299
- "GET",
1300
- this.bankUrl(`/knowledge-base/pages/${encodeURIComponent(pageId)}`)
1301
- );
1302
- if (r.status === 404) throw new Error(`knowledge page not found: ${pageId}`);
1317
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1318
+ const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
1319
+ if (!r) throw new PagesUnavailableError();
1320
+ if (r.status === 404) throw new Error(`page not found: ${pageId}`);
1303
1321
  return shapePage(await r.json());
1304
1322
  }
1305
- /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's knowledge pages.
1323
+ /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
1306
1324
  * Returns page-level hits with a relevance snippet — the real search behind
1307
- * hindsight_search_knowledge_pages. */
1308
- async searchKnowledgePages(query, opts = {}) {
1309
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1325
+ * hindsight_search_pages. */
1326
+ async searchPages(query, opts = {}) {
1327
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1310
1328
  const q = `?q=${encodeURIComponent(query)}&limit=${opts.limit ?? this.pageSearchLimit}`;
1311
- const r = await this.req(
1312
- "GET",
1313
- this.bankUrl(`/knowledge-base/search${q}`),
1314
- void 0,
1315
- [],
1316
- opts.timeoutMs
1317
- );
1318
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1329
+ const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
1330
+ if (!r) throw new PagesUnavailableError();
1319
1331
  if (r.status === 404) return [];
1320
1332
  const j = await r.json();
1321
1333
  return (j.results ?? []).map((x) => ({
@@ -1327,9 +1339,9 @@ var HindsightClient = class {
1327
1339
  }));
1328
1340
  }
1329
1341
  /**
1330
- * Seed the fixed page taxonomy as knowledge-base pages at the tree root, idempotently.
1342
+ * Seed the fixed page taxonomy as pages at the tree root, idempotently.
1331
1343
  *
1332
- * Matched by NAME, not id: `/knowledge-base/pages` mints its own `kp-…` id, so a stable
1344
+ * Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
1333
1345
  * client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
1334
1346
  * off a slug). Names are unique per folder server-side, which makes them a sound key.
1335
1347
  *
@@ -1344,8 +1356,8 @@ var HindsightClient = class {
1344
1356
  try {
1345
1357
  roots = await this.tree();
1346
1358
  } catch (e) {
1347
- if (e instanceof KnowledgePagesUnavailableError) {
1348
- this.log(`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`);
1359
+ if (e instanceof PagesUnavailableError) {
1360
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1349
1361
  return;
1350
1362
  }
1351
1363
  throw e;
@@ -1368,11 +1380,9 @@ var HindsightClient = class {
1368
1380
  trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
1369
1381
  };
1370
1382
  if (!hit) {
1371
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), body, [409]);
1372
- if (await this.pagesUnsupported(r)) {
1373
- this.log(
1374
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1375
- );
1383
+ const r = await this.pagesReq("POST", "", body, [409]);
1384
+ if (!r) {
1385
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1376
1386
  return;
1377
1387
  }
1378
1388
  if (r.status === 404) {
@@ -1393,15 +1403,9 @@ var HindsightClient = class {
1393
1403
  );
1394
1404
  }
1395
1405
  if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
1396
- const r = await this.req(
1397
- "PATCH",
1398
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
1399
- patch
1400
- );
1401
- if (await this.pagesUnsupported(r)) {
1402
- this.log(
1403
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1404
- );
1406
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
1407
+ if (!r) {
1408
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1405
1409
  return;
1406
1410
  }
1407
1411
  if (r.status === 404) {
@@ -1413,7 +1417,7 @@ var HindsightClient = class {
1413
1417
  }
1414
1418
  const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
1415
1419
  this.log(
1416
- `[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` : "")
1420
+ `[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` : "")
1417
1421
  );
1418
1422
  }
1419
1423
  /**
@@ -1447,12 +1451,8 @@ var HindsightClient = class {
1447
1451
  if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
1448
1452
  }
1449
1453
  if (!patch.trigger && !patch.source_query) continue;
1450
- const r = await this.req(
1451
- "PATCH",
1452
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
1453
- patch
1454
- );
1455
- if (r.status === 404) continue;
1454
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
1455
+ if (!r || r.status === 404) continue;
1456
1456
  updated++;
1457
1457
  }
1458
1458
  return updated;
@@ -1478,7 +1478,7 @@ var HindsightClient = class {
1478
1478
  let pageId = args.relatesToPageId;
1479
1479
  if (!pageId) {
1480
1480
  const folderId = await this.ensureFolder("Initiatives");
1481
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
1481
+ const r = await this.pagesReq("POST", "", {
1482
1482
  name: args.title,
1483
1483
  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),
1484
1484
  parent_id: folderId,
@@ -1487,8 +1487,8 @@ var HindsightClient = class {
1487
1487
  trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
1488
1488
  });
1489
1489
  try {
1490
- const j = await r.json();
1491
- pageId = j.page_id ?? j.id;
1490
+ const j = await r?.json();
1491
+ pageId = j?.page_id ?? j?.id;
1492
1492
  } catch {
1493
1493
  }
1494
1494
  pageId ||= `initiative-${this.slugify(args.title)}`;
@@ -1506,16 +1506,17 @@ var HindsightClient = class {
1506
1506
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
1507
1507
  async ensureFolder(name) {
1508
1508
  try {
1509
- const tree = await (await this.req("GET", this.bankUrl("/knowledge-base/tree"))).json();
1510
- const hit = (tree.roots || []).find(
1509
+ const r = await this.pagesReq("GET", "/tree");
1510
+ const tree = await r?.json();
1511
+ const hit = (tree?.roots || []).find(
1511
1512
  (n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
1512
1513
  );
1513
1514
  if (hit?.id) return hit.id;
1514
1515
  } catch {
1515
1516
  }
1516
1517
  try {
1517
- const r = await this.req("POST", this.bankUrl("/knowledge-base/folders"), { name });
1518
- return (await r.json()).id;
1518
+ const r = await this.pagesReq("POST", "/folders", { name });
1519
+ return (await r?.json())?.id;
1519
1520
  } catch {
1520
1521
  return void 0;
1521
1522
  }
@@ -2355,7 +2356,7 @@ function preflightDaemon(cfg, harness) {
2355
2356
  return true;
2356
2357
  }
2357
2358
 
2358
- // src/core/knowledge-injection.ts
2359
+ // src/core/page-injection.ts
2359
2360
  function parsePageList(raw) {
2360
2361
  const items = raw?.items;
2361
2362
  if (!Array.isArray(items)) return [];
@@ -2367,12 +2368,12 @@ function parsePageList(raw) {
2367
2368
  }
2368
2369
  return out;
2369
2370
  }
2370
- var EMPTY_STATE = "No knowledge pages yet \u2014 Hindsight is still learning this repo; they'll appear as it processes.";
2371
+ var EMPTY_STATE = "No pages yet \u2014 Hindsight is still learning this repo; they'll appear as it processes.";
2371
2372
  function indexLine(pages) {
2372
- const count = pages.length === 1 ? "1 knowledge page covers" : `${pages.length} knowledge pages cover`;
2373
- 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.`;
2373
+ const count = pages.length === 1 ? "1 page covers" : `${pages.length} pages cover`;
2374
+ 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.`;
2374
2375
  }
2375
- 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:
2376
+ 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:
2376
2377
  \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);
2377
2378
  \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);
2378
2379
  \u2022 you are implementing something new, or two parts have to fit together;
@@ -2380,32 +2381,32 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP, a
2380
2381
  \u2022 you are about to commit, and need to know what the change was supposed to honour.
2381
2382
  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.
2382
2383
  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.
2383
- - 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.
2384
+ - 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.
2384
2385
  - 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>").
2385
2386
  - 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.
2386
2387
  - 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).`;
2387
- 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";
2388
+ 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";
2388
2389
  function toolGuide(opts) {
2389
2390
  const extra = opts?.extra?.trim();
2390
2391
  return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE + (extra ? `
2391
2392
  ${extra}` : "");
2392
2393
  }
2393
- function buildKnowledgePreamble(pages, opts) {
2394
+ function buildPagesPreamble(pages, opts) {
2394
2395
  const body = pages.length ? indexLine(pages) : EMPTY_STATE;
2395
- return `<hindsight_knowledge>
2396
- 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:
2396
+ return `<hindsight_pages>
2397
+ 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:
2397
2398
  ${toolGuide(opts)}
2398
2399
  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.
2399
2400
  ${body}
2400
2401
  This tool guide and the page list are re-injected for you periodically as things change.
2401
- </hindsight_knowledge>`;
2402
+ </hindsight_pages>`;
2402
2403
  }
2403
2404
  function buildRosterRefresh(pages, opts) {
2404
2405
  const rosterBlock = pages.length ? `${indexLine(pages)}
2405
2406
  ` : "";
2406
- return "<hindsight_knowledge_refresh>\n" + rosterBlock + `Reminder \u2014 this repo's Hindsight tools are available; call them at the right moments:
2407
+ return "<hindsight_page_refresh>\n" + rosterBlock + `Reminder \u2014 this repo's Hindsight tools are available; call them at the right moments:
2407
2408
  ${toolGuide(opts)}
2408
- </hindsight_knowledge_refresh>`;
2409
+ </hindsight_page_refresh>`;
2409
2410
  }
2410
2411
 
2411
2412
  // node_modules/zod/v4/classic/external.js
@@ -16922,7 +16923,7 @@ function date4(params) {
16922
16923
  // node_modules/zod/v4/classic/external.js
16923
16924
  config(en_default());
16924
16925
 
16925
- // src/core/knowledge-tools.ts
16926
+ // src/core/page-tools.ts
16926
16927
  import { createHash as createHash4 } from "crypto";
16927
16928
  import { existsSync as existsSync4 } from "fs";
16928
16929
  import { homedir as homedir6 } from "os";
@@ -17435,97 +17436,88 @@ function surveyAttempts(file2, sha) {
17435
17436
  async function startCodebaseSurvey(repoDir, opts = {}) {
17436
17437
  try {
17437
17438
  const spawnFn = opts.spawn ?? realSpawn5;
17438
- const resolveBin = opts.resolveBin ?? ((bin) => binOnPath(bin, { exts: [".exe"] }));
17439
+ const resolveBin = opts.resolveBin ?? ((bin2) => binOnPath(bin2, { exts: [".exe"] }));
17439
17440
  const mcpServerPath = opts.mcpServerPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "mcp-server.js");
17440
- const preferred = opts.harness ?? "claude-code";
17441
- const order = [
17442
- preferred,
17443
- "claude-code",
17444
- "codex",
17445
- "antigravity-cli",
17446
- "opencode"
17447
- ];
17448
- const seen = /* @__PURE__ */ new Set();
17449
- for (const harness of order) {
17450
- if (seen.has(harness)) continue;
17451
- seen.add(harness);
17452
- const name = resolveAgentBin(harness, opts.claudeBin);
17453
- if (!name) continue;
17454
- const bin = resolveBin(name);
17455
- if (!bin) {
17456
- log.info("survey", `${harness}: ${name} not found, trying the next agent`);
17457
- continue;
17458
- }
17459
- if (harness === "opencode" && !(opts.opencodeDefinesAgent ?? opencodeCanDefineSurveyAgent)(bin)) {
17460
- log.info("survey", `${harness}: ${bin} cannot define the survey agent, trying the next`);
17461
- continue;
17462
- }
17463
- const plan = buildSurveyPlan(harness, bin, repoDir, {
17464
- model: opts.model,
17465
- budgetUsd: opts.budgetUsd,
17466
- mcpServerPath
17467
- });
17468
- const { cfg, bankId } = resolveHostConfig(harness, repoDir);
17469
- if (cfg.disabled) return false;
17470
- const key = createHash3("sha256").update(JSON.stringify([cfg.apiUrl.replace(/\/+$/, ""), cfg.apiToken ?? "", bankId])).digest("hex");
17471
- const leaseDir = opts.lease?.dir ?? join11(tmpdir2(), "hindsight-coding-agent", "surveys");
17472
- const lease = acquireLease(leaseDir, key, opts.lease?.staleMs ?? LEASE_STALE_MS);
17473
- if (!lease) return false;
17474
- const attemptsFile = join11(
17475
- leaseDir,
17476
- `attempts-${createHash3("sha256").update(JSON.stringify([key, repoDir])).digest("hex")}.json`
17477
- );
17478
- const attempts = opts.sha ? surveyAttempts(attemptsFile, opts.sha) : 0;
17479
- if (attempts >= SURVEY_MAX_ATTEMPTS) {
17480
- log.info("survey", `${attempts} surveys already launched at ${opts.sha}, skipping`);
17481
- releaseLease(lease);
17482
- return false;
17483
- }
17484
- const spec = {
17485
- lease,
17486
- bin: plan.bin,
17487
- args: plan.args,
17488
- ...opts.lease?.heartbeatMs ? { heartbeatMs: opts.lease.heartbeatMs } : {}
17489
- };
17490
- const supervisorPath = opts.supervisorPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "survey-supervisor.js");
17491
- return await new Promise((resolve4) => {
17492
- try {
17493
- const child = spawnFn("node", [supervisorPath], {
17494
- cwd: repoDir,
17495
- detached: true,
17496
- stdio: "ignore",
17497
- windowsHide: true,
17498
- env: { ...plan.env, [SURVEY_SPEC_ENV]: JSON.stringify(spec) }
17499
- });
17500
- let spawned = false;
17501
- child.on("error", (e) => {
17502
- if (spawned) return;
17503
- log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
17504
- releaseLease(lease);
17505
- resolve4(false);
17506
- });
17507
- child.once("spawn", () => {
17508
- spawned = true;
17509
- child.unref();
17510
- if (opts.sha) {
17511
- try {
17512
- writeFileSync3(
17513
- attemptsFile,
17514
- JSON.stringify({ sha: opts.sha, attempts: attempts + 1 }),
17515
- { mode: 384 }
17516
- );
17517
- } catch {
17518
- }
17519
- }
17520
- resolve4(true);
17521
- });
17522
- } catch (e) {
17441
+ const harness = opts.harness ?? "claude-code";
17442
+ const name = resolveAgentBin(harness, opts.claudeBin);
17443
+ if (!name) {
17444
+ log.info("survey", `${harness}: no headless survey for this agent, skipping the survey`);
17445
+ return false;
17446
+ }
17447
+ const bin = resolveBin(name);
17448
+ if (!bin) {
17449
+ log.info("survey", `${harness}: ${name} not found, skipping the survey`);
17450
+ return false;
17451
+ }
17452
+ if (harness === "opencode" && !(opts.opencodeDefinesAgent ?? opencodeCanDefineSurveyAgent)(bin)) {
17453
+ log.info("survey", `${harness}: ${bin} cannot define the survey agent, skipping the survey`);
17454
+ return false;
17455
+ }
17456
+ const plan = buildSurveyPlan(harness, bin, repoDir, {
17457
+ model: opts.model,
17458
+ budgetUsd: opts.budgetUsd,
17459
+ mcpServerPath
17460
+ });
17461
+ const { cfg, bankId } = resolveHostConfig(harness, repoDir);
17462
+ if (cfg.disabled) return false;
17463
+ const key = createHash3("sha256").update(JSON.stringify([cfg.apiUrl.replace(/\/+$/, ""), cfg.apiToken ?? "", bankId])).digest("hex");
17464
+ const leaseDir = opts.lease?.dir ?? join11(tmpdir2(), "hindsight-coding-agent", "surveys");
17465
+ const lease = acquireLease(leaseDir, key, opts.lease?.staleMs ?? LEASE_STALE_MS);
17466
+ if (!lease) return false;
17467
+ const attemptsFile = join11(
17468
+ leaseDir,
17469
+ `attempts-${createHash3("sha256").update(JSON.stringify([key, repoDir])).digest("hex")}.json`
17470
+ );
17471
+ const attempts = opts.sha ? surveyAttempts(attemptsFile, opts.sha) : 0;
17472
+ if (attempts >= SURVEY_MAX_ATTEMPTS) {
17473
+ log.info("survey", `${attempts} surveys already launched at ${opts.sha}, skipping`);
17474
+ releaseLease(lease);
17475
+ return false;
17476
+ }
17477
+ const spec = {
17478
+ lease,
17479
+ bin: plan.bin,
17480
+ args: plan.args,
17481
+ ...opts.lease?.heartbeatMs ? { heartbeatMs: opts.lease.heartbeatMs } : {}
17482
+ };
17483
+ const supervisorPath = opts.supervisorPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "survey-supervisor.js");
17484
+ return await new Promise((resolve4) => {
17485
+ try {
17486
+ const child = spawnFn("node", [supervisorPath], {
17487
+ cwd: repoDir,
17488
+ detached: true,
17489
+ stdio: "ignore",
17490
+ windowsHide: true,
17491
+ env: { ...plan.env, [SURVEY_SPEC_ENV]: JSON.stringify(spec) }
17492
+ });
17493
+ let spawned = false;
17494
+ child.on("error", (e) => {
17495
+ if (spawned) return;
17523
17496
  log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
17524
17497
  releaseLease(lease);
17525
17498
  resolve4(false);
17526
- }
17527
- });
17528
- }
17499
+ });
17500
+ child.once("spawn", () => {
17501
+ spawned = true;
17502
+ child.unref();
17503
+ if (opts.sha) {
17504
+ try {
17505
+ writeFileSync3(
17506
+ attemptsFile,
17507
+ JSON.stringify({ sha: opts.sha, attempts: attempts + 1 }),
17508
+ { mode: 384 }
17509
+ );
17510
+ } catch {
17511
+ }
17512
+ }
17513
+ resolve4(true);
17514
+ });
17515
+ } catch (e) {
17516
+ log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
17517
+ releaseLease(lease);
17518
+ resolve4(false);
17519
+ }
17520
+ });
17529
17521
  } catch {
17530
17522
  }
17531
17523
  return false;
@@ -17589,11 +17581,11 @@ async function syncStatus(client, bank, repoDir) {
17589
17581
  activeOps,
17590
17582
  // Older Hindsight servers have no page surface. They are still fully usable for the
17591
17583
  // legacy bank/retain pipeline, so page absence must not make syncStatus permanently false.
17592
- synced: gitlogPresent && (client.knowledgePagesSupported === false || pages.length > 0) && (activeOps ?? 0) === 0
17584
+ synced: gitlogPresent && (client.pagesSupported === false || pages.length > 0) && (activeOps ?? 0) === 0
17593
17585
  };
17594
17586
  }
17595
17587
 
17596
- // src/core/knowledge-tools.ts
17588
+ // src/core/page-tools.ts
17597
17589
  var READ_ONLY_ANNOTATIONS = {
17598
17590
  readOnlyHint: true,
17599
17591
  destructiveHint: false,
@@ -17623,13 +17615,13 @@ function guarded(fn) {
17623
17615
  }
17624
17616
  };
17625
17617
  }
17626
- function buildKnowledgeTools(client, bankId, opts = {}) {
17618
+ function buildPageTools(client, bankId, opts = {}) {
17627
17619
  const extra = opts.toolGuideExtra?.trim();
17628
17620
  const crediting = extra ? `${CREDIT_REMINDER} ${extra}` : CREDIT_REMINDER;
17629
17621
  return [
17630
17622
  {
17631
17623
  name: "hindsight_sync_status",
17632
- description: "Report whether this repo's memory bank is in sync: gitlog seed present, how much recent history has been deepened with full diffs, conversations ingested, knowledge pages created, and extractions still running. `synced: true` means the seeded memory is fully queryable. Ingestion is automatic and background \u2014 if not synced, it is in progress; nothing to run.",
17624
+ description: "Report whether this repo's memory bank is in sync: gitlog seed present, how much recent history has been deepened with full diffs, conversations ingested, pages created, and extractions still running. `synced: true` means the seeded memory is fully queryable. Ingestion is automatic and background \u2014 if not synced, it is in progress; nothing to run.",
17633
17625
  inputSchema: {},
17634
17626
  annotations: READ_ONLY_ANNOTATIONS,
17635
17627
  handler: async () => {
@@ -17684,13 +17676,13 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
17684
17676
  }
17685
17677
  },
17686
17678
  {
17687
- name: "hindsight_search_knowledge_pages",
17688
- description: "Search this repository's Hindsight knowledge pages for content relevant to a query \u2014 hybrid full-text + semantic search, server-side. Call this when the user's question may be answered by the project's accumulated knowledge (architecture, conventions, decisions, initiatives) rather than by reading code. Returns ranked pages with a relevance snippet; read a full page with hindsight_read_knowledge_page. " + crediting,
17679
+ name: "hindsight_search_pages",
17680
+ description: "Search this repository's Hindsight pages for content relevant to a query \u2014 hybrid full-text + semantic search, server-side. Call this when the user's question may be answered by the project's accumulated knowledge (architecture, conventions, decisions, initiatives) rather than by reading code. Returns ranked pages with a relevance snippet; read a full page with hindsight_read_page. " + crediting,
17689
17681
  inputSchema: { query: external_exports.string().describe("what to look for") },
17690
17682
  annotations: READ_ONLY_ANNOTATIONS,
17691
17683
  handler: async (args) => {
17692
17684
  try {
17693
- const hits = await client.searchKnowledgePages(args.query);
17685
+ const hits = await client.searchPages(args.query);
17694
17686
  return ok({
17695
17687
  pages: hits.map((h) => ({
17696
17688
  page: h.name,
@@ -17708,22 +17700,22 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
17708
17700
  }
17709
17701
  },
17710
17702
  {
17711
- name: "hindsight_list_knowledge_pages",
17712
- description: "List this repository's Hindsight knowledge pages \u2014 curated, continuously-updated summaries of the project's durable knowledge (architecture, components, conventions, key decisions, and in-flight initiatives). Returns each page's id, title, and a one-line description of what it covers. Call this at the start of any non-trivial task, and again periodically in long sessions, to see what the project already knows before you read code or ask the user. The list changes as work is captured, so re-check it occasionally.",
17703
+ name: "hindsight_list_pages",
17704
+ description: "List this repository's Hindsight pages \u2014 curated, continuously-updated summaries of the project's durable knowledge (architecture, components, conventions, key decisions, and in-flight initiatives). Returns each page's id, title, and a one-line description of what it covers. Call this at the start of any non-trivial task, and again periodically in long sessions, to see what the project already knows before you read code or ask the user. The list changes as work is captured, so re-check it occasionally.",
17713
17705
  inputSchema: {},
17714
17706
  annotations: READ_ONLY_ANNOTATIONS,
17715
17707
  handler: guarded(async () => client.listPages())
17716
17708
  },
17717
17709
  {
17718
- name: "hindsight_read_knowledge_page",
17719
- description: "Read the full content of one knowledge page by its id (from hindsight_list_knowledge_pages). Call this whenever a listed page is relevant to what you're about to do \u2014 e.g. read Conventions before writing new code, Component map before changing a subsystem, or an initiative's page before continuing that feature. A page may contain [[page:<id>]] links to related pages; follow one by calling this tool again with that id. Prefer reading a page over re-deriving the same understanding from source.",
17710
+ name: "hindsight_read_page",
17711
+ description: "Read the full content of one page by its id (from hindsight_list_pages). Call this whenever a listed page is relevant to what you're about to do \u2014 e.g. read Conventions before writing new code, Component map before changing a subsystem, or an initiative's page before continuing that feature. A page may contain [[page:<id>]] links to related pages; follow one by calling this tool again with that id. Prefer reading a page over re-deriving the same understanding from source.",
17720
17712
  inputSchema: { page_id: external_exports.string() },
17721
17713
  annotations: READ_ONLY_ANNOTATIONS,
17722
17714
  handler: guarded(async ({ page_id }) => client.getPage(page_id))
17723
17715
  },
17724
17716
  {
17725
17717
  name: "hindsight_reflect",
17726
- description: `Deep memory reasoning: an agentic synthesis over this repository's FULL memory (git decisions, past sessions, ingested knowledge) that answers WHY questions \u2014 the past decision and exact rule/values that explain a behavior, bug, or convention. Slower than hindsight_search_knowledge_pages (several seconds): reach for it when pages are too shallow and you need the root cause or the decided literals. When the answer informs your reply, credit it visibly with a blockquote header: "> \u{1F9E0} **From Hindsight memory** \u2014 <summary>".`,
17718
+ description: `Deep memory reasoning: an agentic synthesis over this repository's FULL memory (git decisions, past sessions, ingested knowledge) that answers WHY questions \u2014 the past decision and exact rule/values that explain a behavior, bug, or convention. Slower than hindsight_search_pages (several seconds): reach for it when pages are too shallow and you need the root cause or the decided literals. When the answer informs your reply, credit it visibly with a blockquote header: "> \u{1F9E0} **From Hindsight memory** \u2014 <summary>".`,
17727
17719
  inputSchema: { query: external_exports.string().describe("the question to reason over memory about") },
17728
17720
  annotations: READ_ONLY_ANNOTATIONS,
17729
17721
  handler: guarded(
@@ -17735,7 +17727,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
17735
17727
  },
17736
17728
  {
17737
17729
  name: "hindsight_capture_initiative",
17738
- description: "Record a new feature or initiative as a tracked knowledge page, so future sessions know it exists and can build on it \u2014 and keep that page tracking the plan as it moves.\n\nWHEN TO CALL:\n- Starting one: right after the user approves a plan or finishes brainstorming a new feature/capability and you are about to start implementing \u2014 BEFORE you write any code. Leave relates_to_page_id empty.\n- Plan changed: call it AGAIN \u2014 mid-implementation is fine and expected \u2014 whenever the goal, scope, or rationale of an initiative you already captured materially changes (an approach is dropped, scope grows or shrinks, the why is rewritten). Pass relates_to_page_id = that initiative's page id so the change lands on the existing page. Never mint a second page for the same initiative.\n\nWHEN TO SKIP: bug fixes, small tweaks, refactors, chores, and trivial course-corrections that leave the goal intact are not initiatives \u2014 skip them.\n\n- title: short, specific name (e.g. 'Newsletter refinement chat'). On a recapture, reuse the initiative's existing title.\n- summary: 2-3 sentences on what you're building and why \u2014 the CURRENT intent, not the originally approved plan (on a recapture, say what changed and why).\n- relates_to_page_id: leave empty for a new initiative. Set it to an existing initiative's page id \u2014 from hindsight_list_knowledge_pages, or the id this tool returned earlier \u2014 to record a plan change or an enhancement to it.\n\nReturns the page id. The page is generated for you \u2014 you never format one yourself.",
17730
+ description: "Record a new feature or initiative as a tracked page, so future sessions know it exists and can build on it \u2014 and keep that page tracking the plan as it moves.\n\nWHEN TO CALL:\n- Starting one: right after the user approves a plan or finishes brainstorming a new feature/capability and you are about to start implementing \u2014 BEFORE you write any code. Leave relates_to_page_id empty.\n- Plan changed: call it AGAIN \u2014 mid-implementation is fine and expected \u2014 whenever the goal, scope, or rationale of an initiative you already captured materially changes (an approach is dropped, scope grows or shrinks, the why is rewritten). Pass relates_to_page_id = that initiative's page id so the change lands on the existing page. Never mint a second page for the same initiative.\n\nWHEN TO SKIP: bug fixes, small tweaks, refactors, chores, and trivial course-corrections that leave the goal intact are not initiatives \u2014 skip them.\n\n- title: short, specific name (e.g. 'Newsletter refinement chat'). On a recapture, reuse the initiative's existing title.\n- summary: 2-3 sentences on what you're building and why \u2014 the CURRENT intent, not the originally approved plan (on a recapture, say what changed and why).\n- relates_to_page_id: leave empty for a new initiative. Set it to an existing initiative's page id \u2014 from hindsight_list_pages, or the id this tool returned earlier \u2014 to record a plan change or an enhancement to it.\n\nReturns the page id. The page is generated for you \u2014 you never format one yourself.",
17739
17731
  inputSchema: {
17740
17732
  title: external_exports.string(),
17741
17733
  summary: external_exports.string(),
@@ -18472,11 +18464,11 @@ async function buildSessionStartContext(args) {
18472
18464
  try {
18473
18465
  pages = parsePageList(await client.listPages());
18474
18466
  } catch {
18475
- if (client.knowledgePagesSupported === false) {
18476
- diag(harness, "knowledge_pages_unavailable", { bank: bankId });
18467
+ if (client.pagesSupported === false) {
18468
+ diag(harness, "pages_unavailable", { bank: bankId });
18477
18469
  }
18478
18470
  }
18479
- const additionalContext = buildKnowledgePreamble(pages, {
18471
+ const additionalContext = buildPagesPreamble(pages, {
18480
18472
  reflectOnNewGoals: cfg.autoInject !== "reflect",
18481
18473
  extra: cfg.toolGuideExtra
18482
18474
  });
@@ -18506,6 +18498,12 @@ ${legacyClaudePluginWarning(legacyPlugin)}`;
18506
18498
  // src/core/hook.ts
18507
18499
  import { existsSync as existsSync8 } from "fs";
18508
18500
 
18501
+ // src/core/transcript-util.ts
18502
+ 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;
18503
+ function stripInjectedMemory(s) {
18504
+ return s.replace(MEMORY_TAG_RE, "");
18505
+ }
18506
+
18509
18507
  // src/core/inject.ts
18510
18508
  function buildReflectQuery(prompt) {
18511
18509
  return `A developer is starting a coding session in this repository with this goal:
@@ -18522,8 +18520,8 @@ Report what this bank's history genuinely bears on that goal. Rendering rules, s
18522
18520
  - Do not connect unrelated episodes into one narrative; if two facts are not explicitly linked in the record, report them separately or leave the weaker one out.
18523
18521
  - If the bank holds nothing that bears on the goal, say so in one line.`;
18524
18522
  }
18525
- var PAGE_FALLBACK_LEAD = "(Hindsight's synthesis was unavailable this turn; these knowledge pages matched the goal by search. Read one with hindsight_read_knowledge_page(<id>) if it looks relevant.)";
18526
- var PAGE_INJECT_LEAD = "(These knowledge pages matched the goal by search. Read one with hindsight_read_knowledge_page(<id>) if it looks relevant.)";
18523
+ var PAGE_FALLBACK_LEAD = "(Hindsight's synthesis was unavailable this turn; these pages matched the goal by search. Read one with hindsight_read_page(<id>) if it looks relevant.)";
18524
+ var PAGE_INJECT_LEAD = "(These pages matched the goal by search. Read one with hindsight_read_page(<id>) if it looks relevant.)";
18527
18525
  function formatPageFallback(hits, lead = PAGE_FALLBACK_LEAD) {
18528
18526
  return `${lead}
18529
18527
  ` + hits.map((h) => {
@@ -18579,7 +18577,7 @@ function boundRecallQuery(prompt) {
18579
18577
  async function injectPages(harness, prompt, client, timeoutMs, event, lead) {
18580
18578
  const t0 = Date.now();
18581
18579
  try {
18582
- const hits = await client.searchKnowledgePages(prompt.slice(0, 500), { timeoutMs });
18580
+ const hits = await client.searchPages(prompt.slice(0, 500), { timeoutMs });
18583
18581
  diag(harness, event, { ms: Date.now() - t0, count: hits.length });
18584
18582
  return hits.length ? formatPageFallback(hits, lead) : null;
18585
18583
  } catch (e) {
@@ -18693,14 +18691,10 @@ async function buildHookOutput(args) {
18693
18691
  pages = parsePageList(await client.listPages());
18694
18692
  diag(harness, "pages_ok", { ms: Date.now() - t0, count: pages.length });
18695
18693
  } catch (e) {
18696
- diag(
18697
- harness,
18698
- client.knowledgePagesSupported === false ? "knowledge_pages_unavailable" : "pages_failed",
18699
- {
18700
- ms: Date.now() - t0,
18701
- error: describeError(e)
18702
- }
18703
- );
18694
+ diag(harness, client.pagesSupported === false ? "pages_unavailable" : "pages_failed", {
18695
+ ms: Date.now() - t0,
18696
+ error: describeError(e)
18697
+ });
18704
18698
  }
18705
18699
  }
18706
18700
  writeSessionCache(cacheFile, {
@@ -18779,9 +18773,9 @@ var RuntimeCore = class {
18779
18773
  setTranscriptSource(fetch2) {
18780
18774
  this.fetchTranscript = fetch2;
18781
18775
  }
18782
- /** The hindsight_* knowledge + recall tools, bound to this bank, for the harness to register natively. */
18776
+ /** The hindsight_* page + recall tools, bound to this bank, for the harness to register natively. */
18783
18777
  toolSpecs() {
18784
- return buildKnowledgeTools(this.client, this.bankId, {
18778
+ return buildPageTools(this.client, this.bankId, {
18785
18779
  repoDir: this.projectDir,
18786
18780
  harness: this.harness,
18787
18781
  pageTrigger: buildPageTrigger(this.cfg),
@@ -18803,7 +18797,7 @@ var RuntimeCore = class {
18803
18797
  * git-log seed + codebase survey. Reuses the exact hook-harness logic
18804
18798
  * (`buildSessionStartContext`) so opencode seeds identically. Never throws.
18805
18799
  *
18806
- * It deliberately does NOT keep that call's knowledge preamble. This runs once per PROCESS and
18800
+ * It deliberately does NOT keep that call's pages preamble. This runs once per PROCESS and
18807
18801
  * these hosts outlive every session, so a roster captured here is stale for every session but
18808
18802
  * the first — `onPrompt` builds its own from the session's live page list (#4607).
18809
18803
  */
@@ -18834,10 +18828,11 @@ var RuntimeCore = class {
18834
18828
  * intentionally replaces the old in-memory reflect/page state, keeping lifecycle behavior
18835
18829
  * identical across hosts while this adapter retains only delivery-specific state.
18836
18830
  */
18837
- async onPrompt(sessionId2, prompt) {
18831
+ async onPrompt(sessionId2, rawPrompt) {
18838
18832
  if (process.env.HINDSIGHT_DISABLE_HOOKS) return;
18839
18833
  if (!sessionId2) return;
18840
- if (!prompt.trim()) {
18834
+ const prompt = stripInjectedMemory(rawPrompt).trim();
18835
+ if (!prompt) {
18841
18836
  this.injection.delete(sessionId2);
18842
18837
  return;
18843
18838
  }
@@ -18858,7 +18853,7 @@ var RuntimeCore = class {
18858
18853
  const blocks = [];
18859
18854
  if (turns === 1) {
18860
18855
  blocks.push(
18861
- buildKnowledgePreamble(output.pages, {
18856
+ buildPagesPreamble(output.pages, {
18862
18857
  reflectOnNewGoals: this.cfg.autoInject !== "reflect",
18863
18858
  extra: this.cfg.toolGuideExtra
18864
18859
  })