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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +23 -18
  2. package/dist/antigravity-hook.js +130 -135
  3. package/dist/antigravity-statusline.js +1 -1
  4. package/dist/antigravity-stop-hook.js +113 -114
  5. package/dist/claude-hook.js +130 -135
  6. package/dist/claude-sessionstart-hook.js +127 -128
  7. package/dist/claude-stop-hook.js +113 -114
  8. package/dist/cline.js +128 -124
  9. package/dist/codebuddy-hook.js +130 -135
  10. package/dist/codebuddy-sessionstart-hook.js +127 -128
  11. package/dist/codebuddy-stop-hook.js +113 -114
  12. package/dist/codex-hook.js +130 -135
  13. package/dist/codex-sessionstart-hook.js +127 -128
  14. package/dist/codex-stop-hook.js +113 -114
  15. package/dist/copilot-hook.js +130 -135
  16. package/dist/copilot-sessionstart-hook.js +127 -128
  17. package/dist/copilot-stop-hook.js +113 -114
  18. package/dist/cursor-hook.js +130 -135
  19. package/dist/cursor-sessionstart-hook.js +127 -128
  20. package/dist/cursor-stop-hook.js +113 -114
  21. package/dist/daemon-start.js +1 -1
  22. package/dist/dcode-hook.js +130 -135
  23. package/dist/dcode-sessionstart-hook.js +127 -128
  24. package/dist/dcode-stop-hook.js +113 -114
  25. package/dist/deepen.js +80 -79
  26. package/dist/devin-hook.js +130 -135
  27. package/dist/devin-sessionstart-hook.js +127 -128
  28. package/dist/devin-stop-hook.js +113 -114
  29. package/dist/droid-hook.js +130 -135
  30. package/dist/droid-sessionstart-hook.js +127 -128
  31. package/dist/droid-stop-hook.js +113 -114
  32. package/dist/dsh.js +157 -161
  33. package/dist/grok-hook.js +130 -135
  34. package/dist/grok-sessionstart-hook.js +127 -128
  35. package/dist/grok-stop-hook.js +113 -114
  36. package/dist/hindsight-seed.js +1 -1
  37. package/dist/index.js +158 -162
  38. package/dist/installer.js +30 -28
  39. package/dist/kilo.js +158 -162
  40. package/dist/kimi-hook.js +130 -135
  41. package/dist/kimi-sessionstart-hook.js +127 -128
  42. package/dist/kimi-stop-hook.js +113 -114
  43. package/dist/mcp-server.js +94 -93
  44. package/dist/opencode2.js +158 -162
  45. package/dist/pi.js +157 -161
  46. package/dist/prime-agent.js +157 -161
  47. package/dist/qwen-hook.js +130 -135
  48. package/dist/qwen-sessionstart-hook.js +127 -128
  49. package/dist/qwen-stop-hook.js +113 -114
  50. package/dist/status.js +80 -79
  51. package/dist/traecode-hook.js +130 -135
  52. package/dist/traecode-sessionstart-hook.js +127 -128
  53. package/dist/traecode-stop-hook.js +113 -114
  54. package/dist/workbuddy-hook.js +130 -135
  55. package/dist/workbuddy-sessionstart-hook.js +127 -128
  56. package/dist/workbuddy-stop-hook.js +113 -114
  57. package/dist/zcode-hook.js +130 -135
  58. package/dist/zcode-sessionstart-hook.js +127 -128
  59. package/dist/zcode-stop-hook.js +113 -114
  60. package/package.json +2 -1
  61. package/plugin.json +1 -1
  62. package/skill/SKILL.md +23 -23
package/dist/opencode2.js CHANGED
@@ -14951,14 +14951,14 @@ var RETAIN_STRATEGIES = {
14951
14951
  retain_chunk_size: 12e3
14952
14952
  }
14953
14953
  };
14954
- var KNOWLEDGE_LABELS = {
14954
+ var PAGE_LABELS = {
14955
14955
  key: "knowledge",
14956
14956
  type: "multi-values",
14957
14957
  // 0, 1, or several — empty is normal
14958
14958
  optional: true,
14959
14959
  tag: true,
14960
14960
  // emits knowledge:<value> onto the fact's tags
14961
- 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.",
14961
+ 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.",
14962
14962
  values: [
14963
14963
  {
14964
14964
  value: "feature-work",
@@ -15115,7 +15115,7 @@ var CODING_BANK_TEMPLATE = {
15115
15115
  retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
15116
15116
  retain_default_strategy: "git",
15117
15117
  retain_strategies: RETAIN_STRATEGIES,
15118
- entity_labels: [KNOWLEDGE_LABELS],
15118
+ entity_labels: [PAGE_LABELS],
15119
15119
  entities_allow_free_form: true
15120
15120
  }
15121
15121
  };
@@ -15167,7 +15167,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
15167
15167
  }
15168
15168
 
15169
15169
  // package.json
15170
- var version2 = "0.8.6";
15170
+ var version2 = "0.8.7";
15171
15171
 
15172
15172
  // src/core/util.ts
15173
15173
  import { accessSync, constants, statSync as statSync2 } from "fs";
@@ -15250,11 +15250,11 @@ function retryAfterMs(header) {
15250
15250
  const at = Date.parse(header);
15251
15251
  return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
15252
15252
  }
15253
- var KnowledgePagesUnavailableError = class extends Error {
15254
- code = "knowledge_pages_unavailable";
15253
+ var PagesUnavailableError = class extends Error {
15254
+ code = "pages_unavailable";
15255
15255
  constructor() {
15256
- super("Hindsight server does not support knowledge pages");
15257
- this.name = "KnowledgePagesUnavailableError";
15256
+ super("Hindsight server does not support pages");
15257
+ this.name = "PagesUnavailableError";
15258
15258
  }
15259
15259
  };
15260
15260
  async function isEndpointMissing(r) {
@@ -15265,6 +15265,10 @@ async function isEndpointMissing(r) {
15265
15265
  return false;
15266
15266
  }
15267
15267
  }
15268
+ function pagesPath(sub, legacy = false) {
15269
+ if (!legacy) return `/pages${sub}`;
15270
+ return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
15271
+ }
15268
15272
  var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
15269
15273
  var ReflectError = class extends Error {
15270
15274
  constructor(message, status, timedOut, options) {
@@ -15333,7 +15337,7 @@ var HindsightClient = class {
15333
15337
  opIds = [];
15334
15338
  // async operation ids collected by retain(), for drain()
15335
15339
  /** Tri-state capability probe: unknown until the first page request, then cached. */
15336
- knowledgePagesSupported;
15340
+ pagesSupported;
15337
15341
  /** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
15338
15342
  idempotentRetain;
15339
15343
  log;
@@ -15562,7 +15566,7 @@ var HindsightClient = class {
15562
15566
  return (j.total ?? j.items?.length ?? 0) > 0;
15563
15567
  }
15564
15568
  /** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
15565
- * entity labels), then seed knowledge pages when the server supports them. Both halves are
15569
+ * entity labels), then seed pages when the server supports them. Both halves are
15566
15570
  * idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
15567
15571
  * extraction mode of the plugin's own strategies, which follows its config (#4560) — so
15568
15572
  * the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
@@ -15744,29 +15748,45 @@ var HindsightClient = class {
15744
15748
  const j = await r.json();
15745
15749
  return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
15746
15750
  }
15751
+ /** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
15752
+ * page routes moved to `/pages/...`. Remove in 2.x. */
15753
+ legacyPagesPaths = false;
15747
15754
  /**
15748
- * Latch `knowledgePagesSupported = false` iff this response really means the endpoint is absent.
15749
- * Returns whether it latched. A bank-not-found 404 is NOT a capability verdict — it is the
15750
- * expected answer before the bank's first retain — so it must never cache a negative (#4607).
15755
+ * Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
15756
+ *
15757
+ * Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
15758
+ * unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
15759
+ * older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
15760
+ * a capability verdict — it is the expected answer before the bank's first retain — so it is
15761
+ * returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
15751
15762
  *
15752
15763
  * Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
15753
15764
  * the 405/501 this used to check for never reach a caller in the first place.
15754
15765
  */
15755
- async pagesUnsupported(r) {
15756
- if (r.status !== 404 || !await isEndpointMissing(r)) return false;
15757
- this.knowledgePagesSupported = false;
15758
- return true;
15766
+ async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
15767
+ const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
15768
+ let r = await send(this.legacyPagesPaths);
15769
+ if (r.status !== 404 || !await isEndpointMissing(r)) return r;
15770
+ if (!this.legacyPagesPaths) {
15771
+ r = await send(true);
15772
+ if (r.status !== 404 || !await isEndpointMissing(r)) {
15773
+ this.legacyPagesPaths = true;
15774
+ return r;
15775
+ }
15776
+ }
15777
+ this.pagesSupported = false;
15778
+ return null;
15759
15779
  }
15760
15780
  /**
15761
- * The bank's knowledge-base tree (folders + pages, nested). The tree carries names, source
15781
+ * The bank's page tree (folders + pages, nested). The tree carries names, source
15762
15782
  * queries and staleness but NOT synthesized content, so it is cheap enough to poll.
15763
15783
  */
15764
15784
  async tree() {
15765
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
15766
- const r = await this.req("GET", this.bankUrl("/knowledge-base/tree"));
15767
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
15785
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
15786
+ const r = await this.pagesReq("GET", "/tree");
15787
+ if (!r) throw new PagesUnavailableError();
15768
15788
  if (r.status === 404) return [];
15769
- this.knowledgePagesSupported = true;
15789
+ this.pagesSupported = true;
15770
15790
  try {
15771
15791
  return (await r.json()).roots ?? [];
15772
15792
  } catch {
@@ -15774,13 +15794,13 @@ var HindsightClient = class {
15774
15794
  }
15775
15795
  }
15776
15796
  /**
15777
- * List knowledge pages (ids + names only — no synthesized content), flattened out of the tree
15797
+ * List pages (ids + names only — no synthesized content), flattened out of the tree
15778
15798
  * and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
15779
15799
  * to read, and a caller enumerating pages wants leaves, not structure.
15780
15800
  *
15781
- * NOTE the ids are knowledge-base node ids (`kp-…`), NOT the backing mental-model ids. Every
15782
- * page read/update in this client goes through the same knowledge-base ids, so a page id from
15783
- * here, from `searchKnowledgePages`, or from a `[[page:<id>]]` link all resolve identically.
15801
+ * NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
15802
+ * page read/update in this client goes through the same page ids, so a page id from
15803
+ * here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
15784
15804
  */
15785
15805
  async listPages() {
15786
15806
  const items = [];
@@ -15802,34 +15822,26 @@ var HindsightClient = class {
15802
15822
  return { items };
15803
15823
  }
15804
15824
  /**
15805
- * Read one knowledge page's synthesized content by knowledge-base id, shaped by `shapePage` so
15825
+ * Read one page's synthesized content by page id, shaped by `shapePage` so
15806
15826
  * the body arrives once. The endpoint omits the internal reflect trace that built
15807
15827
  * the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
15808
15828
  * token cap.
15809
15829
  */
15810
15830
  async getPage(pageId) {
15811
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
15812
- const r = await this.req(
15813
- "GET",
15814
- this.bankUrl(`/knowledge-base/pages/${encodeURIComponent(pageId)}`)
15815
- );
15816
- if (r.status === 404) throw new Error(`knowledge page not found: ${pageId}`);
15831
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
15832
+ const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
15833
+ if (!r) throw new PagesUnavailableError();
15834
+ if (r.status === 404) throw new Error(`page not found: ${pageId}`);
15817
15835
  return shapePage(await r.json());
15818
15836
  }
15819
- /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's knowledge pages.
15837
+ /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
15820
15838
  * Returns page-level hits with a relevance snippet — the real search behind
15821
- * hindsight_search_knowledge_pages. */
15822
- async searchKnowledgePages(query, opts = {}) {
15823
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
15839
+ * hindsight_search_pages. */
15840
+ async searchPages(query, opts = {}) {
15841
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
15824
15842
  const q = `?q=${encodeURIComponent(query)}&limit=${opts.limit ?? this.pageSearchLimit}`;
15825
- const r = await this.req(
15826
- "GET",
15827
- this.bankUrl(`/knowledge-base/search${q}`),
15828
- void 0,
15829
- [],
15830
- opts.timeoutMs
15831
- );
15832
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
15843
+ const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
15844
+ if (!r) throw new PagesUnavailableError();
15833
15845
  if (r.status === 404) return [];
15834
15846
  const j = await r.json();
15835
15847
  return (j.results ?? []).map((x) => ({
@@ -15841,9 +15853,9 @@ var HindsightClient = class {
15841
15853
  }));
15842
15854
  }
15843
15855
  /**
15844
- * Seed the fixed page taxonomy as knowledge-base pages at the tree root, idempotently.
15856
+ * Seed the fixed page taxonomy as pages at the tree root, idempotently.
15845
15857
  *
15846
- * Matched by NAME, not id: `/knowledge-base/pages` mints its own `kp-…` id, so a stable
15858
+ * Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
15847
15859
  * client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
15848
15860
  * off a slug). Names are unique per folder server-side, which makes them a sound key.
15849
15861
  *
@@ -15858,8 +15870,8 @@ var HindsightClient = class {
15858
15870
  try {
15859
15871
  roots = await this.tree();
15860
15872
  } catch (e) {
15861
- if (e instanceof KnowledgePagesUnavailableError) {
15862
- this.log(`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`);
15873
+ if (e instanceof PagesUnavailableError) {
15874
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
15863
15875
  return;
15864
15876
  }
15865
15877
  throw e;
@@ -15882,11 +15894,9 @@ var HindsightClient = class {
15882
15894
  trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
15883
15895
  };
15884
15896
  if (!hit) {
15885
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), body, [409]);
15886
- if (await this.pagesUnsupported(r)) {
15887
- this.log(
15888
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
15889
- );
15897
+ const r = await this.pagesReq("POST", "", body, [409]);
15898
+ if (!r) {
15899
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
15890
15900
  return;
15891
15901
  }
15892
15902
  if (r.status === 404) {
@@ -15907,15 +15917,9 @@ var HindsightClient = class {
15907
15917
  );
15908
15918
  }
15909
15919
  if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
15910
- const r = await this.req(
15911
- "PATCH",
15912
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
15913
- patch
15914
- );
15915
- if (await this.pagesUnsupported(r)) {
15916
- this.log(
15917
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
15918
- );
15920
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
15921
+ if (!r) {
15922
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
15919
15923
  return;
15920
15924
  }
15921
15925
  if (r.status === 404) {
@@ -15927,7 +15931,7 @@ var HindsightClient = class {
15927
15931
  }
15928
15932
  const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
15929
15933
  this.log(
15930
- `[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` : "")
15934
+ `[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` : "")
15931
15935
  );
15932
15936
  }
15933
15937
  /**
@@ -15961,12 +15965,8 @@ var HindsightClient = class {
15961
15965
  if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
15962
15966
  }
15963
15967
  if (!patch.trigger && !patch.source_query) continue;
15964
- const r = await this.req(
15965
- "PATCH",
15966
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
15967
- patch
15968
- );
15969
- if (r.status === 404) continue;
15968
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
15969
+ if (!r || r.status === 404) continue;
15970
15970
  updated++;
15971
15971
  }
15972
15972
  return updated;
@@ -15992,7 +15992,7 @@ var HindsightClient = class {
15992
15992
  let pageId = args.relatesToPageId;
15993
15993
  if (!pageId) {
15994
15994
  const folderId = await this.ensureFolder("Initiatives");
15995
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
15995
+ const r = await this.pagesReq("POST", "", {
15996
15996
  name: args.title,
15997
15997
  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),
15998
15998
  parent_id: folderId,
@@ -16001,8 +16001,8 @@ var HindsightClient = class {
16001
16001
  trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
16002
16002
  });
16003
16003
  try {
16004
- const j = await r.json();
16005
- pageId = j.page_id ?? j.id;
16004
+ const j = await r?.json();
16005
+ pageId = j?.page_id ?? j?.id;
16006
16006
  } catch {
16007
16007
  }
16008
16008
  pageId ||= `initiative-${this.slugify(args.title)}`;
@@ -16020,16 +16020,17 @@ var HindsightClient = class {
16020
16020
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
16021
16021
  async ensureFolder(name) {
16022
16022
  try {
16023
- const tree = await (await this.req("GET", this.bankUrl("/knowledge-base/tree"))).json();
16024
- const hit = (tree.roots || []).find(
16023
+ const r = await this.pagesReq("GET", "/tree");
16024
+ const tree = await r?.json();
16025
+ const hit = (tree?.roots || []).find(
16025
16026
  (n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
16026
16027
  );
16027
16028
  if (hit?.id) return hit.id;
16028
16029
  } catch {
16029
16030
  }
16030
16031
  try {
16031
- const r = await this.req("POST", this.bankUrl("/knowledge-base/folders"), { name });
16032
- return (await r.json()).id;
16032
+ const r = await this.pagesReq("POST", "/folders", { name });
16033
+ return (await r?.json())?.id;
16033
16034
  } catch {
16034
16035
  return void 0;
16035
16036
  }
@@ -16869,7 +16870,7 @@ function preflightDaemon(cfg, harness) {
16869
16870
  return true;
16870
16871
  }
16871
16872
 
16872
- // src/core/knowledge-injection.ts
16873
+ // src/core/page-injection.ts
16873
16874
  function parsePageList(raw) {
16874
16875
  const items = raw?.items;
16875
16876
  if (!Array.isArray(items)) return [];
@@ -16881,12 +16882,12 @@ function parsePageList(raw) {
16881
16882
  }
16882
16883
  return out;
16883
16884
  }
16884
- var EMPTY_STATE = "No knowledge pages yet \u2014 Hindsight is still learning this repo; they'll appear as it processes.";
16885
+ var EMPTY_STATE = "No pages yet \u2014 Hindsight is still learning this repo; they'll appear as it processes.";
16885
16886
  function indexLine(pages) {
16886
- const count = pages.length === 1 ? "1 knowledge page covers" : `${pages.length} knowledge pages cover`;
16887
- 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.`;
16887
+ const count = pages.length === 1 ? "1 page covers" : `${pages.length} pages cover`;
16888
+ 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.`;
16888
16889
  }
16889
- 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:
16890
+ 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:
16890
16891
  \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);
16891
16892
  \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);
16892
16893
  \u2022 you are implementing something new, or two parts have to fit together;
@@ -16894,35 +16895,35 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP, a
16894
16895
  \u2022 you are about to commit, and need to know what the change was supposed to honour.
16895
16896
  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.
16896
16897
  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.
16897
- - 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.
16898
+ - 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.
16898
16899
  - 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>").
16899
16900
  - 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.
16900
16901
  - 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).`;
16901
- 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";
16902
+ 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";
16902
16903
  function toolGuide(opts) {
16903
16904
  const extra = opts?.extra?.trim();
16904
16905
  return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE + (extra ? `
16905
16906
  ${extra}` : "");
16906
16907
  }
16907
- function buildKnowledgePreamble(pages, opts) {
16908
+ function buildPagesPreamble(pages, opts) {
16908
16909
  const body = pages.length ? indexLine(pages) : EMPTY_STATE;
16909
- return `<hindsight_knowledge>
16910
- 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:
16910
+ return `<hindsight_pages>
16911
+ 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:
16911
16912
  ${toolGuide(opts)}
16912
16913
  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.
16913
16914
  ${body}
16914
16915
  This tool guide and the page list are re-injected for you periodically as things change.
16915
- </hindsight_knowledge>`;
16916
+ </hindsight_pages>`;
16916
16917
  }
16917
16918
  function buildRosterRefresh(pages, opts) {
16918
16919
  const rosterBlock = pages.length ? `${indexLine(pages)}
16919
16920
  ` : "";
16920
- return "<hindsight_knowledge_refresh>\n" + rosterBlock + `Reminder \u2014 this repo's Hindsight tools are available; call them at the right moments:
16921
+ return "<hindsight_page_refresh>\n" + rosterBlock + `Reminder \u2014 this repo's Hindsight tools are available; call them at the right moments:
16921
16922
  ${toolGuide(opts)}
16922
- </hindsight_knowledge_refresh>`;
16923
+ </hindsight_page_refresh>`;
16923
16924
  }
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";
@@ -17591,11 +17592,11 @@ async function syncStatus(client, bank, repoDir) {
17591
17592
  activeOps,
17592
17593
  // Older Hindsight servers have no page surface. They are still fully usable for the
17593
17594
  // legacy bank/retain pipeline, so page absence must not make syncStatus permanently false.
17594
- synced: gitlogPresent && (client.knowledgePagesSupported === false || pages.length > 0) && (activeOps ?? 0) === 0
17595
+ synced: gitlogPresent && (client.pagesSupported === false || pages.length > 0) && (activeOps ?? 0) === 0
17595
17596
  };
17596
17597
  }
17597
17598
 
17598
- // src/core/knowledge-tools.ts
17599
+ // src/core/page-tools.ts
17599
17600
  var READ_ONLY_ANNOTATIONS = {
17600
17601
  readOnlyHint: true,
17601
17602
  destructiveHint: false,
@@ -17625,13 +17626,13 @@ function guarded(fn) {
17625
17626
  }
17626
17627
  };
17627
17628
  }
17628
- function buildKnowledgeTools(client, bankId, opts = {}) {
17629
+ function buildPageTools(client, bankId, opts = {}) {
17629
17630
  const extra = opts.toolGuideExtra?.trim();
17630
17631
  const crediting = extra ? `${CREDIT_REMINDER} ${extra}` : CREDIT_REMINDER;
17631
17632
  return [
17632
17633
  {
17633
17634
  name: "hindsight_sync_status",
17634
- 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.",
17635
+ 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.",
17635
17636
  inputSchema: {},
17636
17637
  annotations: READ_ONLY_ANNOTATIONS,
17637
17638
  handler: async () => {
@@ -17686,13 +17687,13 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
17686
17687
  }
17687
17688
  },
17688
17689
  {
17689
- name: "hindsight_search_knowledge_pages",
17690
- 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,
17690
+ name: "hindsight_search_pages",
17691
+ 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,
17691
17692
  inputSchema: { query: external_exports.string().describe("what to look for") },
17692
17693
  annotations: READ_ONLY_ANNOTATIONS,
17693
17694
  handler: async (args) => {
17694
17695
  try {
17695
- const hits = await client.searchKnowledgePages(args.query);
17696
+ const hits = await client.searchPages(args.query);
17696
17697
  return ok({
17697
17698
  pages: hits.map((h) => ({
17698
17699
  page: h.name,
@@ -17710,22 +17711,22 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
17710
17711
  }
17711
17712
  },
17712
17713
  {
17713
- name: "hindsight_list_knowledge_pages",
17714
- 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.",
17714
+ name: "hindsight_list_pages",
17715
+ 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.",
17715
17716
  inputSchema: {},
17716
17717
  annotations: READ_ONLY_ANNOTATIONS,
17717
17718
  handler: guarded(async () => client.listPages())
17718
17719
  },
17719
17720
  {
17720
- name: "hindsight_read_knowledge_page",
17721
- 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.",
17721
+ name: "hindsight_read_page",
17722
+ 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.",
17722
17723
  inputSchema: { page_id: external_exports.string() },
17723
17724
  annotations: READ_ONLY_ANNOTATIONS,
17724
17725
  handler: guarded(async ({ page_id }) => client.getPage(page_id))
17725
17726
  },
17726
17727
  {
17727
17728
  name: "hindsight_reflect",
17728
- 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>".`,
17729
+ 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>".`,
17729
17730
  inputSchema: { query: external_exports.string().describe("the question to reason over memory about") },
17730
17731
  annotations: READ_ONLY_ANNOTATIONS,
17731
17732
  handler: guarded(
@@ -17737,7 +17738,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
17737
17738
  },
17738
17739
  {
17739
17740
  name: "hindsight_capture_initiative",
17740
- 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.",
17741
+ 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.",
17741
17742
  inputSchema: {
17742
17743
  title: external_exports.string(),
17743
17744
  summary: external_exports.string(),
@@ -18489,11 +18490,11 @@ async function buildSessionStartContext(args) {
18489
18490
  try {
18490
18491
  pages = parsePageList(await client.listPages());
18491
18492
  } catch {
18492
- if (client.knowledgePagesSupported === false) {
18493
- diag(harness, "knowledge_pages_unavailable", { bank: bankId });
18493
+ if (client.pagesSupported === false) {
18494
+ diag(harness, "pages_unavailable", { bank: bankId });
18494
18495
  }
18495
18496
  }
18496
- const additionalContext = buildKnowledgePreamble(pages, {
18497
+ const additionalContext = buildPagesPreamble(pages, {
18497
18498
  reflectOnNewGoals: cfg.autoInject !== "reflect",
18498
18499
  extra: cfg.toolGuideExtra
18499
18500
  });
@@ -18523,6 +18524,41 @@ ${legacyClaudePluginWarning(legacyPlugin)}`;
18523
18524
  // src/core/hook.ts
18524
18525
  import { existsSync as existsSync8 } from "fs";
18525
18526
 
18527
+ // src/core/transcript-util.ts
18528
+ 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;
18529
+ function stripInjectedMemory(s) {
18530
+ return s.replace(MEMORY_TAG_RE, "");
18531
+ }
18532
+ var TARGET_KEYS = [
18533
+ "file_path",
18534
+ "path",
18535
+ "notebook_path",
18536
+ "command",
18537
+ "pattern",
18538
+ "query",
18539
+ "url",
18540
+ "name",
18541
+ "id"
18542
+ ];
18543
+ var ACTION_TARGET_CAP = 100;
18544
+ function actionLine(tool2, input) {
18545
+ let target = "";
18546
+ if (input && typeof input === "object") {
18547
+ const rec = input;
18548
+ for (const k of TARGET_KEYS) {
18549
+ const v = rec[k];
18550
+ if (typeof v === "string" && v.trim()) {
18551
+ target = v.trim().split("\n")[0];
18552
+ break;
18553
+ }
18554
+ }
18555
+ } else if (typeof input === "string") {
18556
+ target = input.trim().split("\n")[0];
18557
+ }
18558
+ if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
18559
+ return target ? `${tool2} ${target}` : tool2;
18560
+ }
18561
+
18526
18562
  // src/core/inject.ts
18527
18563
  function buildReflectQuery(prompt) {
18528
18564
  return `A developer is starting a coding session in this repository with this goal:
@@ -18539,8 +18575,8 @@ Report what this bank's history genuinely bears on that goal. Rendering rules, s
18539
18575
  - 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.
18540
18576
  - If the bank holds nothing that bears on the goal, say so in one line.`;
18541
18577
  }
18542
- 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.)";
18543
- var PAGE_INJECT_LEAD = "(These knowledge pages matched the goal by search. Read one with hindsight_read_knowledge_page(<id>) if it looks relevant.)";
18578
+ 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.)";
18579
+ var PAGE_INJECT_LEAD = "(These pages matched the goal by search. Read one with hindsight_read_page(<id>) if it looks relevant.)";
18544
18580
  function formatPageFallback(hits, lead = PAGE_FALLBACK_LEAD) {
18545
18581
  return `${lead}
18546
18582
  ` + hits.map((h) => {
@@ -18571,43 +18607,6 @@ If you VERIFY this memory is wrong or outdated (the code or facts contradict it)
18571
18607
  import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync5, readFileSync as readFileSync10, statSync as statSync4 } from "fs";
18572
18608
  import { tmpdir as tmpdir4 } from "os";
18573
18609
  import { dirname as dirname10, join as join18 } from "path";
18574
-
18575
- // src/core/transcript-util.ts
18576
- 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;
18577
- function stripInjectedMemory(s) {
18578
- return s.replace(MEMORY_TAG_RE, "");
18579
- }
18580
- var TARGET_KEYS = [
18581
- "file_path",
18582
- "path",
18583
- "notebook_path",
18584
- "command",
18585
- "pattern",
18586
- "query",
18587
- "url",
18588
- "name",
18589
- "id"
18590
- ];
18591
- var ACTION_TARGET_CAP = 100;
18592
- function actionLine(tool2, input) {
18593
- let target = "";
18594
- if (input && typeof input === "object") {
18595
- const rec = input;
18596
- for (const k of TARGET_KEYS) {
18597
- const v = rec[k];
18598
- if (typeof v === "string" && v.trim()) {
18599
- target = v.trim().split("\n")[0];
18600
- break;
18601
- }
18602
- }
18603
- } else if (typeof input === "string") {
18604
- target = input.trim().split("\n")[0];
18605
- }
18606
- if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
18607
- return target ? `${tool2} ${target}` : tool2;
18608
- }
18609
-
18610
- // src/core/turn-journal.ts
18611
18610
  var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
18612
18611
 
18613
18612
  // src/core/hook.ts
@@ -18633,7 +18632,7 @@ function boundRecallQuery(prompt) {
18633
18632
  async function injectPages(harness, prompt, client, timeoutMs, event, lead) {
18634
18633
  const t0 = Date.now();
18635
18634
  try {
18636
- const hits = await client.searchKnowledgePages(prompt.slice(0, 500), { timeoutMs });
18635
+ const hits = await client.searchPages(prompt.slice(0, 500), { timeoutMs });
18637
18636
  diag(harness, event, { ms: Date.now() - t0, count: hits.length });
18638
18637
  return hits.length ? formatPageFallback(hits, lead) : null;
18639
18638
  } catch (e) {
@@ -18747,14 +18746,10 @@ async function buildHookOutput(args) {
18747
18746
  pages = parsePageList(await client.listPages());
18748
18747
  diag(harness, "pages_ok", { ms: Date.now() - t0, count: pages.length });
18749
18748
  } catch (e) {
18750
- diag(
18751
- harness,
18752
- client.knowledgePagesSupported === false ? "knowledge_pages_unavailable" : "pages_failed",
18753
- {
18754
- ms: Date.now() - t0,
18755
- error: describeError(e)
18756
- }
18757
- );
18749
+ diag(harness, client.pagesSupported === false ? "pages_unavailable" : "pages_failed", {
18750
+ ms: Date.now() - t0,
18751
+ error: describeError(e)
18752
+ });
18758
18753
  }
18759
18754
  }
18760
18755
  writeSessionCache(cacheFile, {
@@ -18833,9 +18828,9 @@ var RuntimeCore = class {
18833
18828
  setTranscriptSource(fetch2) {
18834
18829
  this.fetchTranscript = fetch2;
18835
18830
  }
18836
- /** The hindsight_* knowledge + recall tools, bound to this bank, for the harness to register natively. */
18831
+ /** The hindsight_* page + recall tools, bound to this bank, for the harness to register natively. */
18837
18832
  toolSpecs() {
18838
- return buildKnowledgeTools(this.client, this.bankId, {
18833
+ return buildPageTools(this.client, this.bankId, {
18839
18834
  repoDir: this.projectDir,
18840
18835
  harness: this.harness,
18841
18836
  pageTrigger: buildPageTrigger(this.cfg),
@@ -18857,7 +18852,7 @@ var RuntimeCore = class {
18857
18852
  * git-log seed + codebase survey. Reuses the exact hook-harness logic
18858
18853
  * (`buildSessionStartContext`) so opencode seeds identically. Never throws.
18859
18854
  *
18860
- * It deliberately does NOT keep that call's knowledge preamble. This runs once per PROCESS and
18855
+ * It deliberately does NOT keep that call's pages preamble. This runs once per PROCESS and
18861
18856
  * these hosts outlive every session, so a roster captured here is stale for every session but
18862
18857
  * the first — `onPrompt` builds its own from the session's live page list (#4607).
18863
18858
  */
@@ -18888,10 +18883,11 @@ var RuntimeCore = class {
18888
18883
  * intentionally replaces the old in-memory reflect/page state, keeping lifecycle behavior
18889
18884
  * identical across hosts while this adapter retains only delivery-specific state.
18890
18885
  */
18891
- async onPrompt(sessionId, prompt) {
18886
+ async onPrompt(sessionId, rawPrompt) {
18892
18887
  if (process.env.HINDSIGHT_DISABLE_HOOKS) return;
18893
18888
  if (!sessionId) return;
18894
- if (!prompt.trim()) {
18889
+ const prompt = stripInjectedMemory(rawPrompt).trim();
18890
+ if (!prompt) {
18895
18891
  this.injection.delete(sessionId);
18896
18892
  return;
18897
18893
  }
@@ -18912,7 +18908,7 @@ var RuntimeCore = class {
18912
18908
  const blocks = [];
18913
18909
  if (turns === 1) {
18914
18910
  blocks.push(
18915
- buildKnowledgePreamble(output.pages, {
18911
+ buildPagesPreamble(output.pages, {
18916
18912
  reflectOnNewGoals: this.cfg.autoInject !== "reflect",
18917
18913
  extra: this.cfg.toolGuideExtra
18918
18914
  })
@@ -31587,7 +31583,7 @@ function createRuntime(core) {
31587
31583
  ...surveyAgentHook,
31588
31584
  tool: tools,
31589
31585
  // Each user turn: recall on the prompt, then add this turn's injection (recalled memories +
31590
- // attribution/user-feedback framing, plus the knowledge preamble on turn 1 and the roster
31586
+ // attribution/user-feedback framing, plus the pages preamble on turn 1 and the roster
31591
31587
  // refresh on cadence) to the user message as a synthetic text part. The host saves the parts
31592
31588
  // this hook leaves behind, so the block stays in the turn it was made for and every later
31593
31589
  // request repeats it byte for byte. It used to be pushed into the system prompt through