@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/deepen.js CHANGED
@@ -400,14 +400,14 @@ var RETAIN_STRATEGIES = {
400
400
  retain_chunk_size: 12e3
401
401
  }
402
402
  };
403
- var KNOWLEDGE_LABELS = {
403
+ var PAGE_LABELS = {
404
404
  key: "knowledge",
405
405
  type: "multi-values",
406
406
  // 0, 1, or several — empty is normal
407
407
  optional: true,
408
408
  tag: true,
409
409
  // emits knowledge:<value> onto the fact's tags
410
- 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.",
410
+ 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.",
411
411
  values: [
412
412
  {
413
413
  value: "feature-work",
@@ -564,7 +564,7 @@ var CODING_BANK_TEMPLATE = {
564
564
  retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
565
565
  retain_default_strategy: "git",
566
566
  retain_strategies: RETAIN_STRATEGIES,
567
- entity_labels: [KNOWLEDGE_LABELS],
567
+ entity_labels: [PAGE_LABELS],
568
568
  entities_allow_free_form: true
569
569
  }
570
570
  };
@@ -616,7 +616,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
616
616
  }
617
617
 
618
618
  // package.json
619
- var version = "0.8.5";
619
+ var version = "0.8.7";
620
620
 
621
621
  // src/core/util.ts
622
622
  import { accessSync, constants, statSync as statSync2 } from "fs";
@@ -676,11 +676,11 @@ function retryAfterMs(header) {
676
676
  const at = Date.parse(header);
677
677
  return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
678
678
  }
679
- var KnowledgePagesUnavailableError = class extends Error {
680
- code = "knowledge_pages_unavailable";
679
+ var PagesUnavailableError = class extends Error {
680
+ code = "pages_unavailable";
681
681
  constructor() {
682
- super("Hindsight server does not support knowledge pages");
683
- this.name = "KnowledgePagesUnavailableError";
682
+ super("Hindsight server does not support pages");
683
+ this.name = "PagesUnavailableError";
684
684
  }
685
685
  };
686
686
  async function isEndpointMissing(r) {
@@ -691,6 +691,10 @@ async function isEndpointMissing(r) {
691
691
  return false;
692
692
  }
693
693
  }
694
+ function pagesPath(sub, legacy = false) {
695
+ if (!legacy) return `/pages${sub}`;
696
+ return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
697
+ }
694
698
  var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
695
699
  var ReflectError = class extends Error {
696
700
  constructor(message, status, timedOut, options) {
@@ -759,7 +763,7 @@ var HindsightClient = class {
759
763
  opIds = [];
760
764
  // async operation ids collected by retain(), for drain()
761
765
  /** Tri-state capability probe: unknown until the first page request, then cached. */
762
- knowledgePagesSupported;
766
+ pagesSupported;
763
767
  /** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
764
768
  idempotentRetain;
765
769
  log;
@@ -988,7 +992,7 @@ var HindsightClient = class {
988
992
  return (j.total ?? j.items?.length ?? 0) > 0;
989
993
  }
990
994
  /** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
991
- * entity labels), then seed knowledge pages when the server supports them. Both halves are
995
+ * entity labels), then seed pages when the server supports them. Both halves are
992
996
  * idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
993
997
  * extraction mode of the plugin's own strategies, which follows its config (#4560) — so
994
998
  * the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
@@ -1170,29 +1174,45 @@ var HindsightClient = class {
1170
1174
  const j = await r.json();
1171
1175
  return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
1172
1176
  }
1177
+ /** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
1178
+ * page routes moved to `/pages/...`. Remove in 2.x. */
1179
+ legacyPagesPaths = false;
1173
1180
  /**
1174
- * Latch `knowledgePagesSupported = false` iff this response really means the endpoint is absent.
1175
- * Returns whether it latched. A bank-not-found 404 is NOT a capability verdict — it is the
1176
- * expected answer before the bank's first retain — so it must never cache a negative (#4607).
1181
+ * Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
1182
+ *
1183
+ * Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
1184
+ * unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
1185
+ * older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
1186
+ * a capability verdict — it is the expected answer before the bank's first retain — so it is
1187
+ * returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
1177
1188
  *
1178
1189
  * Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
1179
1190
  * the 405/501 this used to check for never reach a caller in the first place.
1180
1191
  */
1181
- async pagesUnsupported(r) {
1182
- if (r.status !== 404 || !await isEndpointMissing(r)) return false;
1183
- this.knowledgePagesSupported = false;
1184
- return true;
1192
+ async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
1193
+ const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
1194
+ let r = await send(this.legacyPagesPaths);
1195
+ if (r.status !== 404 || !await isEndpointMissing(r)) return r;
1196
+ if (!this.legacyPagesPaths) {
1197
+ r = await send(true);
1198
+ if (r.status !== 404 || !await isEndpointMissing(r)) {
1199
+ this.legacyPagesPaths = true;
1200
+ return r;
1201
+ }
1202
+ }
1203
+ this.pagesSupported = false;
1204
+ return null;
1185
1205
  }
1186
1206
  /**
1187
- * The bank's knowledge-base tree (folders + pages, nested). The tree carries names, source
1207
+ * The bank's page tree (folders + pages, nested). The tree carries names, source
1188
1208
  * queries and staleness but NOT synthesized content, so it is cheap enough to poll.
1189
1209
  */
1190
1210
  async tree() {
1191
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1192
- const r = await this.req("GET", this.bankUrl("/knowledge-base/tree"));
1193
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1211
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1212
+ const r = await this.pagesReq("GET", "/tree");
1213
+ if (!r) throw new PagesUnavailableError();
1194
1214
  if (r.status === 404) return [];
1195
- this.knowledgePagesSupported = true;
1215
+ this.pagesSupported = true;
1196
1216
  try {
1197
1217
  return (await r.json()).roots ?? [];
1198
1218
  } catch {
@@ -1200,13 +1220,13 @@ var HindsightClient = class {
1200
1220
  }
1201
1221
  }
1202
1222
  /**
1203
- * List knowledge pages (ids + names only — no synthesized content), flattened out of the tree
1223
+ * List pages (ids + names only — no synthesized content), flattened out of the tree
1204
1224
  * and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
1205
1225
  * to read, and a caller enumerating pages wants leaves, not structure.
1206
1226
  *
1207
- * NOTE the ids are knowledge-base node ids (`kp-…`), NOT the backing mental-model ids. Every
1208
- * page read/update in this client goes through the same knowledge-base ids, so a page id from
1209
- * here, from `searchKnowledgePages`, or from a `[[page:<id>]]` link all resolve identically.
1227
+ * NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
1228
+ * page read/update in this client goes through the same page ids, so a page id from
1229
+ * here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
1210
1230
  */
1211
1231
  async listPages() {
1212
1232
  const items = [];
@@ -1228,34 +1248,26 @@ var HindsightClient = class {
1228
1248
  return { items };
1229
1249
  }
1230
1250
  /**
1231
- * Read one knowledge page's synthesized content by knowledge-base id, shaped by `shapePage` so
1251
+ * Read one page's synthesized content by page id, shaped by `shapePage` so
1232
1252
  * the body arrives once. The endpoint omits the internal reflect trace that built
1233
1253
  * the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
1234
1254
  * token cap.
1235
1255
  */
1236
1256
  async getPage(pageId) {
1237
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1238
- const r = await this.req(
1239
- "GET",
1240
- this.bankUrl(`/knowledge-base/pages/${encodeURIComponent(pageId)}`)
1241
- );
1242
- if (r.status === 404) throw new Error(`knowledge page not found: ${pageId}`);
1257
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1258
+ const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
1259
+ if (!r) throw new PagesUnavailableError();
1260
+ if (r.status === 404) throw new Error(`page not found: ${pageId}`);
1243
1261
  return shapePage(await r.json());
1244
1262
  }
1245
- /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's knowledge pages.
1263
+ /** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
1246
1264
  * Returns page-level hits with a relevance snippet — the real search behind
1247
- * hindsight_search_knowledge_pages. */
1248
- async searchKnowledgePages(query, opts = {}) {
1249
- if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
1265
+ * hindsight_search_pages. */
1266
+ async searchPages(query, opts = {}) {
1267
+ if (this.pagesSupported === false) throw new PagesUnavailableError();
1250
1268
  const q = `?q=${encodeURIComponent(query)}&limit=${opts.limit ?? this.pageSearchLimit}`;
1251
- const r = await this.req(
1252
- "GET",
1253
- this.bankUrl(`/knowledge-base/search${q}`),
1254
- void 0,
1255
- [],
1256
- opts.timeoutMs
1257
- );
1258
- if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
1269
+ const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
1270
+ if (!r) throw new PagesUnavailableError();
1259
1271
  if (r.status === 404) return [];
1260
1272
  const j = await r.json();
1261
1273
  return (j.results ?? []).map((x) => ({
@@ -1267,9 +1279,9 @@ var HindsightClient = class {
1267
1279
  }));
1268
1280
  }
1269
1281
  /**
1270
- * Seed the fixed page taxonomy as knowledge-base pages at the tree root, idempotently.
1282
+ * Seed the fixed page taxonomy as pages at the tree root, idempotently.
1271
1283
  *
1272
- * Matched by NAME, not id: `/knowledge-base/pages` mints its own `kp-…` id, so a stable
1284
+ * Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
1273
1285
  * client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
1274
1286
  * off a slug). Names are unique per folder server-side, which makes them a sound key.
1275
1287
  *
@@ -1284,8 +1296,8 @@ var HindsightClient = class {
1284
1296
  try {
1285
1297
  roots = await this.tree();
1286
1298
  } catch (e) {
1287
- if (e instanceof KnowledgePagesUnavailableError) {
1288
- this.log(`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`);
1299
+ if (e instanceof PagesUnavailableError) {
1300
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1289
1301
  return;
1290
1302
  }
1291
1303
  throw e;
@@ -1308,11 +1320,9 @@ var HindsightClient = class {
1308
1320
  trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
1309
1321
  };
1310
1322
  if (!hit) {
1311
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), body, [409]);
1312
- if (await this.pagesUnsupported(r)) {
1313
- this.log(
1314
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1315
- );
1323
+ const r = await this.pagesReq("POST", "", body, [409]);
1324
+ if (!r) {
1325
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1316
1326
  return;
1317
1327
  }
1318
1328
  if (r.status === 404) {
@@ -1333,15 +1343,9 @@ var HindsightClient = class {
1333
1343
  );
1334
1344
  }
1335
1345
  if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
1336
- const r = await this.req(
1337
- "PATCH",
1338
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
1339
- patch
1340
- );
1341
- if (await this.pagesUnsupported(r)) {
1342
- this.log(
1343
- `[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
1344
- );
1346
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
1347
+ if (!r) {
1348
+ this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
1345
1349
  return;
1346
1350
  }
1347
1351
  if (r.status === 404) {
@@ -1353,7 +1357,7 @@ var HindsightClient = class {
1353
1357
  }
1354
1358
  const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
1355
1359
  this.log(
1356
- `[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` : "")
1360
+ `[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` : "")
1357
1361
  );
1358
1362
  }
1359
1363
  /**
@@ -1387,12 +1391,8 @@ var HindsightClient = class {
1387
1391
  if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
1388
1392
  }
1389
1393
  if (!patch.trigger && !patch.source_query) continue;
1390
- const r = await this.req(
1391
- "PATCH",
1392
- this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
1393
- patch
1394
- );
1395
- if (r.status === 404) continue;
1394
+ const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
1395
+ if (!r || r.status === 404) continue;
1396
1396
  updated++;
1397
1397
  }
1398
1398
  return updated;
@@ -1418,7 +1418,7 @@ var HindsightClient = class {
1418
1418
  let pageId = args.relatesToPageId;
1419
1419
  if (!pageId) {
1420
1420
  const folderId = await this.ensureFolder("Initiatives");
1421
- const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
1421
+ const r = await this.pagesReq("POST", "", {
1422
1422
  name: args.title,
1423
1423
  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),
1424
1424
  parent_id: folderId,
@@ -1427,8 +1427,8 @@ var HindsightClient = class {
1427
1427
  trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
1428
1428
  });
1429
1429
  try {
1430
- const j = await r.json();
1431
- pageId = j.page_id ?? j.id;
1430
+ const j = await r?.json();
1431
+ pageId = j?.page_id ?? j?.id;
1432
1432
  } catch {
1433
1433
  }
1434
1434
  pageId ||= `initiative-${this.slugify(args.title)}`;
@@ -1446,16 +1446,17 @@ var HindsightClient = class {
1446
1446
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
1447
1447
  async ensureFolder(name) {
1448
1448
  try {
1449
- const tree = await (await this.req("GET", this.bankUrl("/knowledge-base/tree"))).json();
1450
- const hit = (tree.roots || []).find(
1449
+ const r = await this.pagesReq("GET", "/tree");
1450
+ const tree = await r?.json();
1451
+ const hit = (tree?.roots || []).find(
1451
1452
  (n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
1452
1453
  );
1453
1454
  if (hit?.id) return hit.id;
1454
1455
  } catch {
1455
1456
  }
1456
1457
  try {
1457
- const r = await this.req("POST", this.bankUrl("/knowledge-base/folders"), { name });
1458
- return (await r.json()).id;
1458
+ const r = await this.pagesReq("POST", "/folders", { name });
1459
+ return (await r?.json())?.id;
1459
1460
  } catch {
1460
1461
  return void 0;
1461
1462
  }
@@ -2549,8 +2550,8 @@ async function main() {
2549
2550
  extractionMode: cfg.retainExtractionMode,
2550
2551
  defaults: cfg.defaultBankConfig
2551
2552
  });
2552
- if (client.knowledgePagesSupported === false) {
2553
- diag(harness.name, "knowledge_pages_unavailable", {
2553
+ if (client.pagesSupported === false) {
2554
+ diag(harness.name, "pages_unavailable", {
2554
2555
  bank: FINAL_BANK,
2555
2556
  apiUrl: client.apiUrl
2556
2557
  });