@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/status.js CHANGED
@@ -376,14 +376,14 @@ var RETAIN_STRATEGIES = {
376
376
  retain_chunk_size: 12e3
377
377
  }
378
378
  };
379
- var KNOWLEDGE_LABELS = {
379
+ var PAGE_LABELS = {
380
380
  key: "knowledge",
381
381
  type: "multi-values",
382
382
  // 0, 1, or several — empty is normal
383
383
  optional: true,
384
384
  tag: true,
385
385
  // emits knowledge:<value> onto the fact's tags
386
- 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.",
386
+ 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.",
387
387
  values: [
388
388
  {
389
389
  value: "feature-work",
@@ -540,7 +540,7 @@ var CODING_BANK_TEMPLATE = {
540
540
  retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
541
541
  retain_default_strategy: "git",
542
542
  retain_strategies: RETAIN_STRATEGIES,
543
- entity_labels: [KNOWLEDGE_LABELS],
543
+ entity_labels: [PAGE_LABELS],
544
544
  entities_allow_free_form: true
545
545
  }
546
546
  };
@@ -592,7 +592,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
592
592
  }
593
593
 
594
594
  // package.json
595
- var version = "0.8.5";
595
+ var version = "0.8.7";
596
596
 
597
597
  // src/core/util.ts
598
598
  import { accessSync, constants, statSync as statSync2 } from "fs";
@@ -652,11 +652,11 @@ function retryAfterMs(header) {
652
652
  const at = Date.parse(header);
653
653
  return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
654
654
  }
655
- var KnowledgePagesUnavailableError = class extends Error {
656
- code = "knowledge_pages_unavailable";
655
+ var PagesUnavailableError = class extends Error {
656
+ code = "pages_unavailable";
657
657
  constructor() {
658
- super("Hindsight server does not support knowledge pages");
659
- this.name = "KnowledgePagesUnavailableError";
658
+ super("Hindsight server does not support pages");
659
+ this.name = "PagesUnavailableError";
660
660
  }
661
661
  };
662
662
  async function isEndpointMissing(r) {
@@ -667,6 +667,10 @@ async function isEndpointMissing(r) {
667
667
  return false;
668
668
  }
669
669
  }
670
+ function pagesPath(sub, legacy = false) {
671
+ if (!legacy) return `/pages${sub}`;
672
+ return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
673
+ }
670
674
  var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
671
675
  var ReflectError = class extends Error {
672
676
  constructor(message, status, timedOut, options) {
@@ -735,7 +739,7 @@ var HindsightClient = class {
735
739
  opIds = [];
736
740
  // async operation ids collected by retain(), for drain()
737
741
  /** Tri-state capability probe: unknown until the first page request, then cached. */
738
- knowledgePagesSupported;
742
+ pagesSupported;
739
743
  /** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
740
744
  idempotentRetain;
741
745
  log;
@@ -964,7 +968,7 @@ var HindsightClient = class {
964
968
  return (j.total ?? j.items?.length ?? 0) > 0;
965
969
  }
966
970
  /** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
967
- * entity labels), then seed knowledge pages when the server supports them. Both halves are
971
+ * entity labels), then seed pages when the server supports them. Both halves are
968
972
  * idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
969
973
  * extraction mode of the plugin's own strategies, which follows its config (#4560) — so
970
974
  * the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
@@ -1146,29 +1150,45 @@ var HindsightClient = class {
1146
1150
  const j = await r.json();
1147
1151
  return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
1148
1152
  }
1153
+ /** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
1154
+ * page routes moved to `/pages/...`. Remove in 2.x. */
1155
+ legacyPagesPaths = false;
1149
1156
  /**
1150
- * Latch `knowledgePagesSupported = false` iff this response really means the endpoint is absent.
1151
- * Returns whether it latched. A bank-not-found 404 is NOT a capability verdict — it is the
1152
- * expected answer before the bank's first retain — so it must never cache a negative (#4607).
1157
+ * Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
1158
+ *
1159
+ * Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
1160
+ * unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
1161
+ * older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
1162
+ * a capability verdict — it is the expected answer before the bank's first retain — so it is
1163
+ * returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
1153
1164
  *
1154
1165
  * Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
1155
1166
  * the 405/501 this used to check for never reach a caller in the first place.
1156
1167
  */
1157
- async pagesUnsupported(r) {
1158
- if (r.status !== 404 || !await isEndpointMissing(r)) return false;
1159
- this.knowledgePagesSupported = false;
1160
- return true;
1168
+ async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
1169
+ const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
1170
+ let r = await send(this.legacyPagesPaths);
1171
+ if (r.status !== 404 || !await isEndpointMissing(r)) return r;
1172
+ if (!this.legacyPagesPaths) {
1173
+ r = await send(true);
1174
+ if (r.status !== 404 || !await isEndpointMissing(r)) {
1175
+ this.legacyPagesPaths = true;
1176
+ return r;
1177
+ }
1178
+ }
1179
+ this.pagesSupported = false;
1180
+ return null;
1161
1181
  }
1162
1182
  /**
1163
- * The bank's knowledge-base tree (folders + pages, nested). The tree carries names, source
1183
+ * The bank's page tree (folders + pages, nested). The tree carries names, source
1164
1184
  * queries and staleness but NOT synthesized content, so it is cheap enough to poll.
1165
1185
  */
1166
1186
  async tree() {
1167
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1168
- const r = await this.req("GET", this.bankUrl("/knowledge-base/tree"));
1169
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1187
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1188
+ const r = await this.pagesReq("GET", "/tree");
1189
+ if (!r) throw new PagesUnavailableError();
1170
1190
  if (r.status === 404) return [];
1171
- this.knowledgePagesSupported = true;
1191
+ this.pagesSupported = true;
1172
1192
  try {
1173
1193
  return (await r.json()).roots ?? [];
1174
1194
  } catch {
@@ -1176,13 +1196,13 @@ var HindsightClient = class {
1176
1196
  }
1177
1197
  }
1178
1198
  /**
1179
- * List knowledge pages (ids + names only — no synthesized content), flattened out of the tree
1199
+ * List pages (ids + names only — no synthesized content), flattened out of the tree
1180
1200
  * and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
1181
1201
  * to read, and a caller enumerating pages wants leaves, not structure.
1182
1202
  *
1183
- * NOTE the ids are knowledge-base node ids (`kp-…`), NOT the backing mental-model ids. Every
1184
- * page read/update in this client goes through the same knowledge-base ids, so a page id from
1185
- * here, from `searchKnowledgePages`, or from a `[[page:<id>]]` link all resolve identically.
1203
+ * NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
1204
+ * page read/update in this client goes through the same page ids, so a page id from
1205
+ * here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
1186
1206
  */
1187
1207
  async listPages() {
1188
1208
  const items = [];
@@ -1204,34 +1224,26 @@ var HindsightClient = class {
1204
1224
  return { items };
1205
1225
  }
1206
1226
  /**
1207
- * Read one knowledge page's synthesized content by knowledge-base id, shaped by `shapePage` so
1227
+ * Read one page's synthesized content by page id, shaped by `shapePage` so
1208
1228
  * the body arrives once. The endpoint omits the internal reflect trace that built
1209
1229
  * the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
1210
1230
  * token cap.
1211
1231
  */
1212
1232
  async getPage(pageId) {
1213
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1214
- const r = await this.req(
1215
- "GET",
1216
- this.bankUrl(`/knowledge-base/pages/${encodeURIComponent(pageId)}`)
1217
- );
1218
- if (r.status === 404) throw new Error(`knowledge page not found: ${pageId}`);
1233
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1234
+ const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
1235
+ if (!r) throw new PagesUnavailableError();
1236
+ if (r.status === 404) throw new Error(`page not found: ${pageId}`);
1219
1237
  return shapePage(await r.json());
1220
1238
  }
1221
- /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's knowledge pages.
1239
+ /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
1222
1240
  * Returns page-level hits with a relevance snippet — the real search behind
1223
- * hindsight_search_knowledge_pages. */
1224
- async searchKnowledgePages(query, opts = {}) {
1225
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1241
+ * hindsight_search_pages. */
1242
+ async searchPages(query, opts = {}) {
1243
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1226
1244
  const q = `?q=${encodeURIComponent(query)}&limit=${opts.limit ?? this.pageSearchLimit}`;
1227
- const r = await this.req(
1228
- "GET",
1229
- this.bankUrl(`/knowledge-base/search${q}`),
1230
- void 0,
1231
- [],
1232
- opts.timeoutMs
1233
- );
1234
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1245
+ const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
1246
+ if (!r) throw new PagesUnavailableError();
1235
1247
  if (r.status === 404) return [];
1236
1248
  const j = await r.json();
1237
1249
  return (j.results ?? []).map((x) => ({
@@ -1243,9 +1255,9 @@ var HindsightClient = class {
1243
1255
  }));
1244
1256
  }
1245
1257
  /**
1246
- * Seed the fixed page taxonomy as knowledge-base pages at the tree root, idempotently.
1258
+ * Seed the fixed page taxonomy as pages at the tree root, idempotently.
1247
1259
  *
1248
- * Matched by NAME, not id: `/knowledge-base/pages` mints its own `kp-…` id, so a stable
1260
+ * Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
1249
1261
  * client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
1250
1262
  * off a slug). Names are unique per folder server-side, which makes them a sound key.
1251
1263
  *
@@ -1260,8 +1272,8 @@ var HindsightClient = class {
1260
1272
  try {
1261
1273
  roots = await this.tree();
1262
1274
  } catch (e) {
1263
- if (e instanceof KnowledgePagesUnavailableError) {
1264
- this.log(`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`);
1275
+ if (e instanceof PagesUnavailableError) {
1276
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1265
1277
  return;
1266
1278
  }
1267
1279
  throw e;
@@ -1284,11 +1296,9 @@ var HindsightClient = class {
1284
1296
  trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
1285
1297
  };
1286
1298
  if (!hit) {
1287
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), body, [409]);
1288
- if (await this.pagesUnsupported(r)) {
1289
- this.log(
1290
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1291
- );
1299
+ const r = await this.pagesReq("POST", "", body, [409]);
1300
+ if (!r) {
1301
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1292
1302
  return;
1293
1303
  }
1294
1304
  if (r.status === 404) {
@@ -1309,15 +1319,9 @@ var HindsightClient = class {
1309
1319
  );
1310
1320
  }
1311
1321
  if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
1312
- const r = await this.req(
1313
- "PATCH",
1314
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
1315
- patch
1316
- );
1317
- if (await this.pagesUnsupported(r)) {
1318
- this.log(
1319
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1320
- );
1322
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
1323
+ if (!r) {
1324
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1321
1325
  return;
1322
1326
  }
1323
1327
  if (r.status === 404) {
@@ -1329,7 +1333,7 @@ var HindsightClient = class {
1329
1333
  }
1330
1334
  const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
1331
1335
  this.log(
1332
- `[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` : "")
1336
+ `[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` : "")
1333
1337
  );
1334
1338
  }
1335
1339
  /**
@@ -1363,12 +1367,8 @@ var HindsightClient = class {
1363
1367
  if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
1364
1368
  }
1365
1369
  if (!patch.trigger && !patch.source_query) continue;
1366
- const r = await this.req(
1367
- "PATCH",
1368
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
1369
- patch
1370
- );
1371
- if (r.status === 404) continue;
1370
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
1371
+ if (!r || r.status === 404) continue;
1372
1372
  updated++;
1373
1373
  }
1374
1374
  return updated;
@@ -1394,7 +1394,7 @@ var HindsightClient = class {
1394
1394
  let pageId = args.relatesToPageId;
1395
1395
  if (!pageId) {
1396
1396
  const folderId = await this.ensureFolder("Initiatives");
1397
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
1397
+ const r = await this.pagesReq("POST", "", {
1398
1398
  name: args.title,
1399
1399
  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),
1400
1400
  parent_id: folderId,
@@ -1403,8 +1403,8 @@ var HindsightClient = class {
1403
1403
  trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
1404
1404
  });
1405
1405
  try {
1406
- const j = await r.json();
1407
- pageId = j.page_id ?? j.id;
1406
+ const j = await r?.json();
1407
+ pageId = j?.page_id ?? j?.id;
1408
1408
  } catch {
1409
1409
  }
1410
1410
  pageId ||= `initiative-${this.slugify(args.title)}`;
@@ -1422,16 +1422,17 @@ var HindsightClient = class {
1422
1422
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
1423
1423
  async ensureFolder(name) {
1424
1424
  try {
1425
- const tree = await (await this.req("GET", this.bankUrl("/knowledge-base/tree"))).json();
1426
- const hit = (tree.roots || []).find(
1425
+ const r = await this.pagesReq("GET", "/tree");
1426
+ const tree = await r?.json();
1427
+ const hit = (tree?.roots || []).find(
1427
1428
  (n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
1428
1429
  );
1429
1430
  if (hit?.id) return hit.id;
1430
1431
  } catch {
1431
1432
  }
1432
1433
  try {
1433
- const r = await this.req("POST", this.bankUrl("/knowledge-base/folders"), { name });
1434
- return (await r.json()).id;
1434
+ const r = await this.pagesReq("POST", "/folders", { name });
1435
+ return (await r?.json())?.id;
1435
1436
  } catch {
1436
1437
  return void 0;
1437
1438
  }
@@ -1870,7 +1871,7 @@ function commitsSince(dir, sinceSha) {
1870
1871
  }
1871
1872
  }
1872
1873
 
1873
- // src/core/knowledge-injection.ts
1874
+ // src/core/page-injection.ts
1874
1875
  function parsePageList(raw) {
1875
1876
  const items = raw?.items;
1876
1877
  if (!Array.isArray(items)) return [];
@@ -1977,7 +1978,7 @@ async function syncStatus(client2, bank, repoDir) {
1977
1978
  activeOps,
1978
1979
  // Older Hindsight servers have no page surface. They are still fully usable for the
1979
1980
  // legacy bank/retain pipeline, so page absence must not make syncStatus permanently false.
1980
- synced: gitlogPresent && (client2.knowledgePagesSupported === false || pages.length > 0) && (activeOps ?? 0) === 0
1981
+ synced: gitlogPresent && (client2.pagesSupported === false || pages.length > 0) && (activeOps ?? 0) === 0
1981
1982
  };
1982
1983
  }
1983
1984