@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/index.js CHANGED
@@ -440,14 +440,14 @@ var RETAIN_STRATEGIES = {
440
440
  retain_chunk_size: 12e3
441
441
  }
442
442
  };
443
- var KNOWLEDGE_LABELS = {
443
+ var PAGE_LABELS = {
444
444
  key: "knowledge",
445
445
  type: "multi-values",
446
446
  // 0, 1, or several — empty is normal
447
447
  optional: true,
448
448
  tag: true,
449
449
  // emits knowledge:<value> onto the fact's tags
450
- 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.",
450
+ 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.",
451
451
  values: [
452
452
  {
453
453
  value: "feature-work",
@@ -604,7 +604,7 @@ var CODING_BANK_TEMPLATE = {
604
604
  retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
605
605
  retain_default_strategy: "git",
606
606
  retain_strategies: RETAIN_STRATEGIES,
607
- entity_labels: [KNOWLEDGE_LABELS],
607
+ entity_labels: [PAGE_LABELS],
608
608
  entities_allow_free_form: true
609
609
  }
610
610
  };
@@ -656,7 +656,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
656
656
  }
657
657
 
658
658
  // package.json
659
- var version = "0.8.5";
659
+ var version = "0.8.7";
660
660
 
661
661
  // src/core/util.ts
662
662
  import { accessSync, constants, statSync as statSync2 } from "fs";
@@ -739,11 +739,11 @@ function retryAfterMs(header) {
739
739
  const at = Date.parse(header);
740
740
  return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
741
741
  }
742
- var KnowledgePagesUnavailableError = class extends Error {
743
- code = "knowledge_pages_unavailable";
742
+ var PagesUnavailableError = class extends Error {
743
+ code = "pages_unavailable";
744
744
  constructor() {
745
- super("Hindsight server does not support knowledge pages");
746
- this.name = "KnowledgePagesUnavailableError";
745
+ super("Hindsight server does not support pages");
746
+ this.name = "PagesUnavailableError";
747
747
  }
748
748
  };
749
749
  async function isEndpointMissing(r) {
@@ -754,6 +754,10 @@ async function isEndpointMissing(r) {
754
754
  return false;
755
755
  }
756
756
  }
757
+ function pagesPath(sub, legacy = false) {
758
+ if (!legacy) return `/pages${sub}`;
759
+ return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
760
+ }
757
761
  var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
758
762
  var ReflectError = class extends Error {
759
763
  constructor(message, status, timedOut, options) {
@@ -822,7 +826,7 @@ var HindsightClient = class {
822
826
  opIds = [];
823
827
  // async operation ids collected by retain(), for drain()
824
828
  /** Tri-state capability probe: unknown until the first page request, then cached. */
825
- knowledgePagesSupported;
829
+ pagesSupported;
826
830
  /** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
827
831
  idempotentRetain;
828
832
  log;
@@ -1051,7 +1055,7 @@ var HindsightClient = class {
1051
1055
  return (j.total ?? j.items?.length ?? 0) > 0;
1052
1056
  }
1053
1057
  /** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
1054
- * entity labels), then seed knowledge pages when the server supports them. Both halves are
1058
+ * entity labels), then seed pages when the server supports them. Both halves are
1055
1059
  * idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
1056
1060
  * extraction mode of the plugin's own strategies, which follows its config (#4560) — so
1057
1061
  * the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
@@ -1233,29 +1237,45 @@ var HindsightClient = class {
1233
1237
  const j = await r.json();
1234
1238
  return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
1235
1239
  }
1240
+ /** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
1241
+ * page routes moved to `/pages/...`. Remove in 2.x. */
1242
+ legacyPagesPaths = false;
1236
1243
  /**
1237
- * Latch `knowledgePagesSupported = false` iff this response really means the endpoint is absent.
1238
- * Returns whether it latched. A bank-not-found 404 is NOT a capability verdict — it is the
1239
- * expected answer before the bank's first retain — so it must never cache a negative (#4607).
1244
+ * Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
1245
+ *
1246
+ * Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
1247
+ * unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
1248
+ * older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
1249
+ * a capability verdict — it is the expected answer before the bank's first retain — so it is
1250
+ * returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
1240
1251
  *
1241
1252
  * Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
1242
1253
  * the 405/501 this used to check for never reach a caller in the first place.
1243
1254
  */
1244
- async pagesUnsupported(r) {
1245
- if (r.status !== 404 || !await isEndpointMissing(r)) return false;
1246
- this.knowledgePagesSupported = false;
1247
- return true;
1255
+ async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
1256
+ const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
1257
+ let r = await send(this.legacyPagesPaths);
1258
+ if (r.status !== 404 || !await isEndpointMissing(r)) return r;
1259
+ if (!this.legacyPagesPaths) {
1260
+ r = await send(true);
1261
+ if (r.status !== 404 || !await isEndpointMissing(r)) {
1262
+ this.legacyPagesPaths = true;
1263
+ return r;
1264
+ }
1265
+ }
1266
+ this.pagesSupported = false;
1267
+ return null;
1248
1268
  }
1249
1269
  /**
1250
- * The bank's knowledge-base tree (folders + pages, nested). The tree carries names, source
1270
+ * The bank's page tree (folders + pages, nested). The tree carries names, source
1251
1271
  * queries and staleness but NOT synthesized content, so it is cheap enough to poll.
1252
1272
  */
1253
1273
  async tree() {
1254
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1255
- const r = await this.req("GET", this.bankUrl("/knowledge-base/tree"));
1256
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1274
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1275
+ const r = await this.pagesReq("GET", "/tree");
1276
+ if (!r) throw new PagesUnavailableError();
1257
1277
  if (r.status === 404) return [];
1258
- this.knowledgePagesSupported = true;
1278
+ this.pagesSupported = true;
1259
1279
  try {
1260
1280
  return (await r.json()).roots ?? [];
1261
1281
  } catch {
@@ -1263,13 +1283,13 @@ var HindsightClient = class {
1263
1283
  }
1264
1284
  }
1265
1285
  /**
1266
- * List knowledge pages (ids + names only — no synthesized content), flattened out of the tree
1286
+ * List pages (ids + names only — no synthesized content), flattened out of the tree
1267
1287
  * and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
1268
1288
  * to read, and a caller enumerating pages wants leaves, not structure.
1269
1289
  *
1270
- * NOTE the ids are knowledge-base node ids (`kp-…`), NOT the backing mental-model ids. Every
1271
- * page read/update in this client goes through the same knowledge-base ids, so a page id from
1272
- * here, from `searchKnowledgePages`, or from a `[[page:<id>]]` link all resolve identically.
1290
+ * NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
1291
+ * page read/update in this client goes through the same page ids, so a page id from
1292
+ * here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
1273
1293
  */
1274
1294
  async listPages() {
1275
1295
  const items = [];
@@ -1291,34 +1311,26 @@ var HindsightClient = class {
1291
1311
  return { items };
1292
1312
  }
1293
1313
  /**
1294
- * Read one knowledge page's synthesized content by knowledge-base id, shaped by `shapePage` so
1314
+ * Read one page's synthesized content by page id, shaped by `shapePage` so
1295
1315
  * the body arrives once. The endpoint omits the internal reflect trace that built
1296
1316
  * the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
1297
1317
  * token cap.
1298
1318
  */
1299
1319
  async getPage(pageId) {
1300
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1301
- const r = await this.req(
1302
- "GET",
1303
- this.bankUrl(`/knowledge-base/pages/${encodeURIComponent(pageId)}`)
1304
- );
1305
- if (r.status === 404) throw new Error(`knowledge page not found: ${pageId}`);
1320
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1321
+ const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
1322
+ if (!r) throw new PagesUnavailableError();
1323
+ if (r.status === 404) throw new Error(`page not found: ${pageId}`);
1306
1324
  return shapePage(await r.json());
1307
1325
  }
1308
- /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's knowledge pages.
1326
+ /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
1309
1327
  * Returns page-level hits with a relevance snippet — the real search behind
1310
- * hindsight_search_knowledge_pages. */
1311
- async searchKnowledgePages(query, opts = {}) {
1312
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1328
+ * hindsight_search_pages. */
1329
+ async searchPages(query, opts = {}) {
1330
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1313
1331
  const q = `?q=${encodeURIComponent(query)}&limit=${opts.limit ?? this.pageSearchLimit}`;
1314
- const r = await this.req(
1315
- "GET",
1316
- this.bankUrl(`/knowledge-base/search${q}`),
1317
- void 0,
1318
- [],
1319
- opts.timeoutMs
1320
- );
1321
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1332
+ const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
1333
+ if (!r) throw new PagesUnavailableError();
1322
1334
  if (r.status === 404) return [];
1323
1335
  const j = await r.json();
1324
1336
  return (j.results ?? []).map((x) => ({
@@ -1330,9 +1342,9 @@ var HindsightClient = class {
1330
1342
  }));
1331
1343
  }
1332
1344
  /**
1333
- * Seed the fixed page taxonomy as knowledge-base pages at the tree root, idempotently.
1345
+ * Seed the fixed page taxonomy as pages at the tree root, idempotently.
1334
1346
  *
1335
- * Matched by NAME, not id: `/knowledge-base/pages` mints its own `kp-…` id, so a stable
1347
+ * Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
1336
1348
  * client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
1337
1349
  * off a slug). Names are unique per folder server-side, which makes them a sound key.
1338
1350
  *
@@ -1347,8 +1359,8 @@ var HindsightClient = class {
1347
1359
  try {
1348
1360
  roots = await this.tree();
1349
1361
  } catch (e) {
1350
- if (e instanceof KnowledgePagesUnavailableError) {
1351
- this.log(`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`);
1362
+ if (e instanceof PagesUnavailableError) {
1363
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1352
1364
  return;
1353
1365
  }
1354
1366
  throw e;
@@ -1371,11 +1383,9 @@ var HindsightClient = class {
1371
1383
  trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
1372
1384
  };
1373
1385
  if (!hit) {
1374
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), body, [409]);
1375
- if (await this.pagesUnsupported(r)) {
1376
- this.log(
1377
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1378
- );
1386
+ const r = await this.pagesReq("POST", "", body, [409]);
1387
+ if (!r) {
1388
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1379
1389
  return;
1380
1390
  }
1381
1391
  if (r.status === 404) {
@@ -1396,15 +1406,9 @@ var HindsightClient = class {
1396
1406
  );
1397
1407
  }
1398
1408
  if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
1399
- const r = await this.req(
1400
- "PATCH",
1401
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
1402
- patch
1403
- );
1404
- if (await this.pagesUnsupported(r)) {
1405
- this.log(
1406
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1407
- );
1409
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
1410
+ if (!r) {
1411
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1408
1412
  return;
1409
1413
  }
1410
1414
  if (r.status === 404) {
@@ -1416,7 +1420,7 @@ var HindsightClient = class {
1416
1420
  }
1417
1421
  const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
1418
1422
  this.log(
1419
- `[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` : "")
1423
+ `[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` : "")
1420
1424
  );
1421
1425
  }
1422
1426
  /**
@@ -1450,12 +1454,8 @@ var HindsightClient = class {
1450
1454
  if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
1451
1455
  }
1452
1456
  if (!patch.trigger && !patch.source_query) continue;
1453
- const r = await this.req(
1454
- "PATCH",
1455
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
1456
- patch
1457
- );
1458
- if (r.status === 404) continue;
1457
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
1458
+ if (!r || r.status === 404) continue;
1459
1459
  updated++;
1460
1460
  }
1461
1461
  return updated;
@@ -1481,7 +1481,7 @@ var HindsightClient = class {
1481
1481
  let pageId = args.relatesToPageId;
1482
1482
  if (!pageId) {
1483
1483
  const folderId = await this.ensureFolder("Initiatives");
1484
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
1484
+ const r = await this.pagesReq("POST", "", {
1485
1485
  name: args.title,
1486
1486
  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),
1487
1487
  parent_id: folderId,
@@ -1490,8 +1490,8 @@ var HindsightClient = class {
1490
1490
  trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
1491
1491
  });
1492
1492
  try {
1493
- const j = await r.json();
1494
- pageId = j.page_id ?? j.id;
1493
+ const j = await r?.json();
1494
+ pageId = j?.page_id ?? j?.id;
1495
1495
  } catch {
1496
1496
  }
1497
1497
  pageId ||= `initiative-${this.slugify(args.title)}`;
@@ -1509,16 +1509,17 @@ var HindsightClient = class {
1509
1509
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
1510
1510
  async ensureFolder(name) {
1511
1511
  try {
1512
- const tree = await (await this.req("GET", this.bankUrl("/knowledge-base/tree"))).json();
1513
- const hit = (tree.roots || []).find(
1512
+ const r = await this.pagesReq("GET", "/tree");
1513
+ const tree = await r?.json();
1514
+ const hit = (tree?.roots || []).find(
1514
1515
  (n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
1515
1516
  );
1516
1517
  if (hit?.id) return hit.id;
1517
1518
  } catch {
1518
1519
  }
1519
1520
  try {
1520
- const r = await this.req("POST", this.bankUrl("/knowledge-base/folders"), { name });
1521
- return (await r.json()).id;
1521
+ const r = await this.pagesReq("POST", "/folders", { name });
1522
+ return (await r?.json())?.id;
1522
1523
  } catch {
1523
1524
  return void 0;
1524
1525
  }
@@ -2358,7 +2359,7 @@ function preflightDaemon(cfg, harness) {
2358
2359
  return true;
2359
2360
  }
2360
2361
 
2361
- // src/core/knowledge-injection.ts
2362
+ // src/core/page-injection.ts
2362
2363
  function parsePageList(raw) {
2363
2364
  const items = raw?.items;
2364
2365
  if (!Array.isArray(items)) return [];
@@ -2370,12 +2371,12 @@ function parsePageList(raw) {
2370
2371
  }
2371
2372
  return out;
2372
2373
  }
2373
- var EMPTY_STATE = "No knowledge pages yet \u2014 Hindsight is still learning this repo; they'll appear as it processes.";
2374
+ var EMPTY_STATE = "No pages yet \u2014 Hindsight is still learning this repo; they'll appear as it processes.";
2374
2375
  function indexLine(pages) {
2375
- const count = pages.length === 1 ? "1 knowledge page covers" : `${pages.length} knowledge pages cover`;
2376
- 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.`;
2376
+ const count = pages.length === 1 ? "1 page covers" : `${pages.length} pages cover`;
2377
+ 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.`;
2377
2378
  }
2378
- 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:
2379
+ 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:
2379
2380
  \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);
2380
2381
  \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);
2381
2382
  \u2022 you are implementing something new, or two parts have to fit together;
@@ -2383,32 +2384,32 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP, a
2383
2384
  \u2022 you are about to commit, and need to know what the change was supposed to honour.
2384
2385
  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.
2385
2386
  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.
2386
- - 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.
2387
+ - 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.
2387
2388
  - 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>").
2388
2389
  - 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.
2389
2390
  - 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).`;
2390
- 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";
2391
+ 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";
2391
2392
  function toolGuide(opts) {
2392
2393
  const extra = opts?.extra?.trim();
2393
2394
  return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE + (extra ? `
2394
2395
  ${extra}` : "");
2395
2396
  }
2396
- function buildKnowledgePreamble(pages, opts) {
2397
+ function buildPagesPreamble(pages, opts) {
2397
2398
  const body = pages.length ? indexLine(pages) : EMPTY_STATE;
2398
- return `<hindsight_knowledge>
2399
- 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:
2399
+ return `<hindsight_pages>
2400
+ 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:
2400
2401
  ${toolGuide(opts)}
2401
2402
  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.
2402
2403
  ${body}
2403
2404
  This tool guide and the page list are re-injected for you periodically as things change.
2404
- </hindsight_knowledge>`;
2405
+ </hindsight_pages>`;
2405
2406
  }
2406
2407
  function buildRosterRefresh(pages, opts) {
2407
2408
  const rosterBlock = pages.length ? `${indexLine(pages)}
2408
2409
  ` : "";
2409
- return "<hindsight_knowledge_refresh>\n" + rosterBlock + `Reminder \u2014 this repo's Hindsight tools are available; call them at the right moments:
2410
+ return "<hindsight_page_refresh>\n" + rosterBlock + `Reminder \u2014 this repo's Hindsight tools are available; call them at the right moments:
2410
2411
  ${toolGuide(opts)}
2411
- </hindsight_knowledge_refresh>`;
2412
+ </hindsight_page_refresh>`;
2412
2413
  }
2413
2414
 
2414
2415
  // node_modules/zod/v4/classic/external.js
@@ -16925,7 +16926,7 @@ function date4(params) {
16925
16926
  // node_modules/zod/v4/classic/external.js
16926
16927
  config(en_default());
16927
16928
 
16928
- // src/core/knowledge-tools.ts
16929
+ // src/core/page-tools.ts
16929
16930
  import { createHash as createHash4 } from "crypto";
16930
16931
  import { existsSync as existsSync4 } from "fs";
16931
16932
  import { homedir as homedir6 } from "os";
@@ -17449,97 +17450,88 @@ function surveyAttempts(file3, sha) {
17449
17450
  async function startCodebaseSurvey(repoDir, opts = {}) {
17450
17451
  try {
17451
17452
  const spawnFn = opts.spawn ?? realSpawn5;
17452
- const resolveBin = opts.resolveBin ?? ((bin) => binOnPath(bin, { exts: [".exe"] }));
17453
+ const resolveBin = opts.resolveBin ?? ((bin2) => binOnPath(bin2, { exts: [".exe"] }));
17453
17454
  const mcpServerPath = opts.mcpServerPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "mcp-server.js");
17454
- const preferred = opts.harness ?? "claude-code";
17455
- const order = [
17456
- preferred,
17457
- "claude-code",
17458
- "codex",
17459
- "antigravity-cli",
17460
- "opencode"
17461
- ];
17462
- const seen = /* @__PURE__ */ new Set();
17463
- for (const harness of order) {
17464
- if (seen.has(harness)) continue;
17465
- seen.add(harness);
17466
- const name = resolveAgentBin(harness, opts.claudeBin);
17467
- if (!name) continue;
17468
- const bin = resolveBin(name);
17469
- if (!bin) {
17470
- log.info("survey", `${harness}: ${name} not found, trying the next agent`);
17471
- continue;
17472
- }
17473
- if (harness === "opencode" && !(opts.opencodeDefinesAgent ?? opencodeCanDefineSurveyAgent)(bin)) {
17474
- log.info("survey", `${harness}: ${bin} cannot define the survey agent, trying the next`);
17475
- continue;
17476
- }
17477
- const plan = buildSurveyPlan(harness, bin, repoDir, {
17478
- model: opts.model,
17479
- budgetUsd: opts.budgetUsd,
17480
- mcpServerPath
17481
- });
17482
- const { cfg, bankId } = resolveHostConfig(harness, repoDir);
17483
- if (cfg.disabled) return false;
17484
- const key = createHash3("sha256").update(JSON.stringify([cfg.apiUrl.replace(/\/+$/, ""), cfg.apiToken ?? "", bankId])).digest("hex");
17485
- const leaseDir = opts.lease?.dir ?? join11(tmpdir2(), "hindsight-coding-agent", "surveys");
17486
- const lease = acquireLease(leaseDir, key, opts.lease?.staleMs ?? LEASE_STALE_MS);
17487
- if (!lease) return false;
17488
- const attemptsFile = join11(
17489
- leaseDir,
17490
- `attempts-${createHash3("sha256").update(JSON.stringify([key, repoDir])).digest("hex")}.json`
17491
- );
17492
- const attempts = opts.sha ? surveyAttempts(attemptsFile, opts.sha) : 0;
17493
- if (attempts >= SURVEY_MAX_ATTEMPTS) {
17494
- log.info("survey", `${attempts} surveys already launched at ${opts.sha}, skipping`);
17495
- releaseLease(lease);
17496
- return false;
17497
- }
17498
- const spec = {
17499
- lease,
17500
- bin: plan.bin,
17501
- args: plan.args,
17502
- ...opts.lease?.heartbeatMs ? { heartbeatMs: opts.lease.heartbeatMs } : {}
17503
- };
17504
- const supervisorPath = opts.supervisorPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "survey-supervisor.js");
17505
- return await new Promise((resolve4) => {
17506
- try {
17507
- const child = spawnFn("node", [supervisorPath], {
17508
- cwd: repoDir,
17509
- detached: true,
17510
- stdio: "ignore",
17511
- windowsHide: true,
17512
- env: { ...plan.env, [SURVEY_SPEC_ENV]: JSON.stringify(spec) }
17513
- });
17514
- let spawned = false;
17515
- child.on("error", (e) => {
17516
- if (spawned) return;
17517
- log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
17518
- releaseLease(lease);
17519
- resolve4(false);
17520
- });
17521
- child.once("spawn", () => {
17522
- spawned = true;
17523
- child.unref();
17524
- if (opts.sha) {
17525
- try {
17526
- writeFileSync3(
17527
- attemptsFile,
17528
- JSON.stringify({ sha: opts.sha, attempts: attempts + 1 }),
17529
- { mode: 384 }
17530
- );
17531
- } catch {
17532
- }
17533
- }
17534
- resolve4(true);
17535
- });
17536
- } catch (e) {
17455
+ const harness = opts.harness ?? "claude-code";
17456
+ const name = resolveAgentBin(harness, opts.claudeBin);
17457
+ if (!name) {
17458
+ log.info("survey", `${harness}: no headless survey for this agent, skipping the survey`);
17459
+ return false;
17460
+ }
17461
+ const bin = resolveBin(name);
17462
+ if (!bin) {
17463
+ log.info("survey", `${harness}: ${name} not found, skipping the survey`);
17464
+ return false;
17465
+ }
17466
+ if (harness === "opencode" && !(opts.opencodeDefinesAgent ?? opencodeCanDefineSurveyAgent)(bin)) {
17467
+ log.info("survey", `${harness}: ${bin} cannot define the survey agent, skipping the survey`);
17468
+ return false;
17469
+ }
17470
+ const plan = buildSurveyPlan(harness, bin, repoDir, {
17471
+ model: opts.model,
17472
+ budgetUsd: opts.budgetUsd,
17473
+ mcpServerPath
17474
+ });
17475
+ const { cfg, bankId } = resolveHostConfig(harness, repoDir);
17476
+ if (cfg.disabled) return false;
17477
+ const key = createHash3("sha256").update(JSON.stringify([cfg.apiUrl.replace(/\/+$/, ""), cfg.apiToken ?? "", bankId])).digest("hex");
17478
+ const leaseDir = opts.lease?.dir ?? join11(tmpdir2(), "hindsight-coding-agent", "surveys");
17479
+ const lease = acquireLease(leaseDir, key, opts.lease?.staleMs ?? LEASE_STALE_MS);
17480
+ if (!lease) return false;
17481
+ const attemptsFile = join11(
17482
+ leaseDir,
17483
+ `attempts-${createHash3("sha256").update(JSON.stringify([key, repoDir])).digest("hex")}.json`
17484
+ );
17485
+ const attempts = opts.sha ? surveyAttempts(attemptsFile, opts.sha) : 0;
17486
+ if (attempts >= SURVEY_MAX_ATTEMPTS) {
17487
+ log.info("survey", `${attempts} surveys already launched at ${opts.sha}, skipping`);
17488
+ releaseLease(lease);
17489
+ return false;
17490
+ }
17491
+ const spec = {
17492
+ lease,
17493
+ bin: plan.bin,
17494
+ args: plan.args,
17495
+ ...opts.lease?.heartbeatMs ? { heartbeatMs: opts.lease.heartbeatMs } : {}
17496
+ };
17497
+ const supervisorPath = opts.supervisorPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "survey-supervisor.js");
17498
+ return await new Promise((resolve4) => {
17499
+ try {
17500
+ const child = spawnFn("node", [supervisorPath], {
17501
+ cwd: repoDir,
17502
+ detached: true,
17503
+ stdio: "ignore",
17504
+ windowsHide: true,
17505
+ env: { ...plan.env, [SURVEY_SPEC_ENV]: JSON.stringify(spec) }
17506
+ });
17507
+ let spawned = false;
17508
+ child.on("error", (e) => {
17509
+ if (spawned) return;
17537
17510
  log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
17538
17511
  releaseLease(lease);
17539
17512
  resolve4(false);
17540
- }
17541
- });
17542
- }
17513
+ });
17514
+ child.once("spawn", () => {
17515
+ spawned = true;
17516
+ child.unref();
17517
+ if (opts.sha) {
17518
+ try {
17519
+ writeFileSync3(
17520
+ attemptsFile,
17521
+ JSON.stringify({ sha: opts.sha, attempts: attempts + 1 }),
17522
+ { mode: 384 }
17523
+ );
17524
+ } catch {
17525
+ }
17526
+ }
17527
+ resolve4(true);
17528
+ });
17529
+ } catch (e) {
17530
+ log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
17531
+ releaseLease(lease);
17532
+ resolve4(false);
17533
+ }
17534
+ });
17543
17535
  } catch {
17544
17536
  }
17545
17537
  return false;
@@ -17603,11 +17595,11 @@ async function syncStatus(client, bank, repoDir) {
17603
17595
  activeOps,
17604
17596
  // Older Hindsight servers have no page surface. They are still fully usable for the
17605
17597
  // legacy bank/retain pipeline, so page absence must not make syncStatus permanently false.
17606
- synced: gitlogPresent && (client.knowledgePagesSupported === false || pages.length > 0) && (activeOps ?? 0) === 0
17598
+ synced: gitlogPresent && (client.pagesSupported === false || pages.length > 0) && (activeOps ?? 0) === 0
17607
17599
  };
17608
17600
  }
17609
17601
 
17610
- // src/core/knowledge-tools.ts
17602
+ // src/core/page-tools.ts
17611
17603
  var READ_ONLY_ANNOTATIONS = {
17612
17604
  readOnlyHint: true,
17613
17605
  destructiveHint: false,
@@ -17637,13 +17629,13 @@ function guarded(fn) {
17637
17629
  }
17638
17630
  };
17639
17631
  }
17640
- function buildKnowledgeTools(client, bankId, opts = {}) {
17632
+ function buildPageTools(client, bankId, opts = {}) {
17641
17633
  const extra = opts.toolGuideExtra?.trim();
17642
17634
  const crediting = extra ? `${CREDIT_REMINDER} ${extra}` : CREDIT_REMINDER;
17643
17635
  return [
17644
17636
  {
17645
17637
  name: "hindsight_sync_status",
17646
- 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.",
17638
+ 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.",
17647
17639
  inputSchema: {},
17648
17640
  annotations: READ_ONLY_ANNOTATIONS,
17649
17641
  handler: async () => {
@@ -17698,13 +17690,13 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
17698
17690
  }
17699
17691
  },
17700
17692
  {
17701
- name: "hindsight_search_knowledge_pages",
17702
- 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,
17693
+ name: "hindsight_search_pages",
17694
+ 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,
17703
17695
  inputSchema: { query: external_exports.string().describe("what to look for") },
17704
17696
  annotations: READ_ONLY_ANNOTATIONS,
17705
17697
  handler: async (args) => {
17706
17698
  try {
17707
- const hits = await client.searchKnowledgePages(args.query);
17699
+ const hits = await client.searchPages(args.query);
17708
17700
  return ok({
17709
17701
  pages: hits.map((h) => ({
17710
17702
  page: h.name,
@@ -17722,22 +17714,22 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
17722
17714
  }
17723
17715
  },
17724
17716
  {
17725
- name: "hindsight_list_knowledge_pages",
17726
- 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.",
17717
+ name: "hindsight_list_pages",
17718
+ 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.",
17727
17719
  inputSchema: {},
17728
17720
  annotations: READ_ONLY_ANNOTATIONS,
17729
17721
  handler: guarded(async () => client.listPages())
17730
17722
  },
17731
17723
  {
17732
- name: "hindsight_read_knowledge_page",
17733
- 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.",
17724
+ name: "hindsight_read_page",
17725
+ 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.",
17734
17726
  inputSchema: { page_id: external_exports.string() },
17735
17727
  annotations: READ_ONLY_ANNOTATIONS,
17736
17728
  handler: guarded(async ({ page_id }) => client.getPage(page_id))
17737
17729
  },
17738
17730
  {
17739
17731
  name: "hindsight_reflect",
17740
- 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>".`,
17732
+ 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>".`,
17741
17733
  inputSchema: { query: external_exports.string().describe("the question to reason over memory about") },
17742
17734
  annotations: READ_ONLY_ANNOTATIONS,
17743
17735
  handler: guarded(
@@ -17749,7 +17741,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
17749
17741
  },
17750
17742
  {
17751
17743
  name: "hindsight_capture_initiative",
17752
- 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.",
17744
+ 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.",
17753
17745
  inputSchema: {
17754
17746
  title: external_exports.string(),
17755
17747
  summary: external_exports.string(),
@@ -18486,11 +18478,11 @@ async function buildSessionStartContext(args) {
18486
18478
  try {
18487
18479
  pages = parsePageList(await client.listPages());
18488
18480
  } catch {
18489
- if (client.knowledgePagesSupported === false) {
18490
- diag(harness, "knowledge_pages_unavailable", { bank: bankId });
18481
+ if (client.pagesSupported === false) {
18482
+ diag(harness, "pages_unavailable", { bank: bankId });
18491
18483
  }
18492
18484
  }
18493
- const additionalContext = buildKnowledgePreamble(pages, {
18485
+ const additionalContext = buildPagesPreamble(pages, {
18494
18486
  reflectOnNewGoals: cfg.autoInject !== "reflect",
18495
18487
  extra: cfg.toolGuideExtra
18496
18488
  });
@@ -18520,6 +18512,41 @@ ${legacyClaudePluginWarning(legacyPlugin)}`;
18520
18512
  // src/core/hook.ts
18521
18513
  import { existsSync as existsSync8 } from "fs";
18522
18514
 
18515
+ // src/core/transcript-util.ts
18516
+ 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;
18517
+ function stripInjectedMemory(s) {
18518
+ return s.replace(MEMORY_TAG_RE, "");
18519
+ }
18520
+ var TARGET_KEYS = [
18521
+ "file_path",
18522
+ "path",
18523
+ "notebook_path",
18524
+ "command",
18525
+ "pattern",
18526
+ "query",
18527
+ "url",
18528
+ "name",
18529
+ "id"
18530
+ ];
18531
+ var ACTION_TARGET_CAP = 100;
18532
+ function actionLine(tool2, input) {
18533
+ let target = "";
18534
+ if (input && typeof input === "object") {
18535
+ const rec = input;
18536
+ for (const k of TARGET_KEYS) {
18537
+ const v = rec[k];
18538
+ if (typeof v === "string" && v.trim()) {
18539
+ target = v.trim().split("\n")[0];
18540
+ break;
18541
+ }
18542
+ }
18543
+ } else if (typeof input === "string") {
18544
+ target = input.trim().split("\n")[0];
18545
+ }
18546
+ if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
18547
+ return target ? `${tool2} ${target}` : tool2;
18548
+ }
18549
+
18523
18550
  // src/core/inject.ts
18524
18551
  function buildReflectQuery(prompt) {
18525
18552
  return `A developer is starting a coding session in this repository with this goal:
@@ -18536,8 +18563,8 @@ Report what this bank's history genuinely bears on that goal. Rendering rules, s
18536
18563
  - 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.
18537
18564
  - If the bank holds nothing that bears on the goal, say so in one line.`;
18538
18565
  }
18539
- 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.)";
18540
- var PAGE_INJECT_LEAD = "(These knowledge pages matched the goal by search. Read one with hindsight_read_knowledge_page(<id>) if it looks relevant.)";
18566
+ 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.)";
18567
+ var PAGE_INJECT_LEAD = "(These pages matched the goal by search. Read one with hindsight_read_page(<id>) if it looks relevant.)";
18541
18568
  function formatPageFallback(hits, lead = PAGE_FALLBACK_LEAD) {
18542
18569
  return `${lead}
18543
18570
  ` + hits.map((h) => {
@@ -18568,43 +18595,6 @@ If you VERIFY this memory is wrong or outdated (the code or facts contradict it)
18568
18595
  import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync5, readFileSync as readFileSync10, statSync as statSync4 } from "fs";
18569
18596
  import { tmpdir as tmpdir4 } from "os";
18570
18597
  import { dirname as dirname10, join as join18 } from "path";
18571
-
18572
- // src/core/transcript-util.ts
18573
- 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;
18574
- function stripInjectedMemory(s) {
18575
- return s.replace(MEMORY_TAG_RE, "");
18576
- }
18577
- var TARGET_KEYS = [
18578
- "file_path",
18579
- "path",
18580
- "notebook_path",
18581
- "command",
18582
- "pattern",
18583
- "query",
18584
- "url",
18585
- "name",
18586
- "id"
18587
- ];
18588
- var ACTION_TARGET_CAP = 100;
18589
- function actionLine(tool2, input) {
18590
- let target = "";
18591
- if (input && typeof input === "object") {
18592
- const rec = input;
18593
- for (const k of TARGET_KEYS) {
18594
- const v = rec[k];
18595
- if (typeof v === "string" && v.trim()) {
18596
- target = v.trim().split("\n")[0];
18597
- break;
18598
- }
18599
- }
18600
- } else if (typeof input === "string") {
18601
- target = input.trim().split("\n")[0];
18602
- }
18603
- if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
18604
- return target ? `${tool2} ${target}` : tool2;
18605
- }
18606
-
18607
- // src/core/turn-journal.ts
18608
18598
  var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
18609
18599
 
18610
18600
  // src/core/hook.ts
@@ -18630,7 +18620,7 @@ function boundRecallQuery(prompt) {
18630
18620
  async function injectPages(harness, prompt, client, timeoutMs, event, lead) {
18631
18621
  const t0 = Date.now();
18632
18622
  try {
18633
- const hits = await client.searchKnowledgePages(prompt.slice(0, 500), { timeoutMs });
18623
+ const hits = await client.searchPages(prompt.slice(0, 500), { timeoutMs });
18634
18624
  diag(harness, event, { ms: Date.now() - t0, count: hits.length });
18635
18625
  return hits.length ? formatPageFallback(hits, lead) : null;
18636
18626
  } catch (e) {
@@ -18744,14 +18734,10 @@ async function buildHookOutput(args) {
18744
18734
  pages = parsePageList(await client.listPages());
18745
18735
  diag(harness, "pages_ok", { ms: Date.now() - t0, count: pages.length });
18746
18736
  } catch (e) {
18747
- diag(
18748
- harness,
18749
- client.knowledgePagesSupported === false ? "knowledge_pages_unavailable" : "pages_failed",
18750
- {
18751
- ms: Date.now() - t0,
18752
- error: describeError(e)
18753
- }
18754
- );
18737
+ diag(harness, client.pagesSupported === false ? "pages_unavailable" : "pages_failed", {
18738
+ ms: Date.now() - t0,
18739
+ error: describeError(e)
18740
+ });
18755
18741
  }
18756
18742
  }
18757
18743
  writeSessionCache(cacheFile, {
@@ -18830,9 +18816,9 @@ var RuntimeCore = class {
18830
18816
  setTranscriptSource(fetch2) {
18831
18817
  this.fetchTranscript = fetch2;
18832
18818
  }
18833
- /** The hindsight_* knowledge + recall tools, bound to this bank, for the harness to register natively. */
18819
+ /** The hindsight_* page + recall tools, bound to this bank, for the harness to register natively. */
18834
18820
  toolSpecs() {
18835
- return buildKnowledgeTools(this.client, this.bankId, {
18821
+ return buildPageTools(this.client, this.bankId, {
18836
18822
  repoDir: this.projectDir,
18837
18823
  harness: this.harness,
18838
18824
  pageTrigger: buildPageTrigger(this.cfg),
@@ -18854,7 +18840,7 @@ var RuntimeCore = class {
18854
18840
  * git-log seed + codebase survey. Reuses the exact hook-harness logic
18855
18841
  * (`buildSessionStartContext`) so opencode seeds identically. Never throws.
18856
18842
  *
18857
- * It deliberately does NOT keep that call's knowledge preamble. This runs once per PROCESS and
18843
+ * It deliberately does NOT keep that call's pages preamble. This runs once per PROCESS and
18858
18844
  * these hosts outlive every session, so a roster captured here is stale for every session but
18859
18845
  * the first — `onPrompt` builds its own from the session's live page list (#4607).
18860
18846
  */
@@ -18885,10 +18871,11 @@ var RuntimeCore = class {
18885
18871
  * intentionally replaces the old in-memory reflect/page state, keeping lifecycle behavior
18886
18872
  * identical across hosts while this adapter retains only delivery-specific state.
18887
18873
  */
18888
- async onPrompt(sessionId, prompt) {
18874
+ async onPrompt(sessionId, rawPrompt) {
18889
18875
  if (process.env.HINDSIGHT_DISABLE_HOOKS) return;
18890
18876
  if (!sessionId) return;
18891
- if (!prompt.trim()) {
18877
+ const prompt = stripInjectedMemory(rawPrompt).trim();
18878
+ if (!prompt) {
18892
18879
  this.injection.delete(sessionId);
18893
18880
  return;
18894
18881
  }
@@ -18909,7 +18896,7 @@ var RuntimeCore = class {
18909
18896
  const blocks = [];
18910
18897
  if (turns === 1) {
18911
18898
  blocks.push(
18912
- buildKnowledgePreamble(output.pages, {
18899
+ buildPagesPreamble(output.pages, {
18913
18900
  reflectOnNewGoals: this.cfg.autoInject !== "reflect",
18914
18901
  extra: this.cfg.toolGuideExtra
18915
18902
  })
@@ -31556,7 +31543,7 @@ function createRuntime(core) {
31556
31543
  ...surveyAgentHook,
31557
31544
  tool: tools,
31558
31545
  // Each user turn: recall on the prompt, then add this turn's injection (recalled memories +
31559
- // attribution/user-feedback framing, plus the knowledge preamble on turn 1 and the roster
31546
+ // attribution/user-feedback framing, plus the pages preamble on turn 1 and the roster
31560
31547
  // refresh on cadence) to the user message as a synthetic text part. The host saves the parts
31561
31548
  // this hook leaves behind, so the block stays in the turn it was made for and every later
31562
31549
  // request repeats it byte for byte. It used to be pushed into the system prompt through