@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.
- package/README.md +23 -18
- package/dist/antigravity-hook.js +130 -135
- package/dist/antigravity-statusline.js +1 -1
- package/dist/antigravity-stop-hook.js +113 -114
- package/dist/claude-hook.js +130 -135
- package/dist/claude-sessionstart-hook.js +127 -128
- package/dist/claude-stop-hook.js +113 -114
- package/dist/cline.js +128 -124
- package/dist/codebuddy-hook.js +130 -135
- package/dist/codebuddy-sessionstart-hook.js +127 -128
- package/dist/codebuddy-stop-hook.js +113 -114
- package/dist/codex-hook.js +130 -135
- package/dist/codex-sessionstart-hook.js +127 -128
- package/dist/codex-stop-hook.js +113 -114
- package/dist/copilot-hook.js +130 -135
- package/dist/copilot-sessionstart-hook.js +127 -128
- package/dist/copilot-stop-hook.js +113 -114
- package/dist/cursor-hook.js +130 -135
- package/dist/cursor-sessionstart-hook.js +127 -128
- package/dist/cursor-stop-hook.js +113 -114
- package/dist/daemon-start.js +1 -1
- package/dist/dcode-hook.js +130 -135
- package/dist/dcode-sessionstart-hook.js +127 -128
- package/dist/dcode-stop-hook.js +113 -114
- package/dist/deepen.js +80 -79
- package/dist/devin-hook.js +130 -135
- package/dist/devin-sessionstart-hook.js +127 -128
- package/dist/devin-stop-hook.js +113 -114
- package/dist/droid-hook.js +130 -135
- package/dist/droid-sessionstart-hook.js +127 -128
- package/dist/droid-stop-hook.js +113 -114
- package/dist/dsh.js +157 -161
- package/dist/grok-hook.js +130 -135
- package/dist/grok-sessionstart-hook.js +127 -128
- package/dist/grok-stop-hook.js +113 -114
- package/dist/hindsight-seed.js +1 -1
- package/dist/index.js +158 -162
- package/dist/installer.js +30 -28
- package/dist/kilo.js +158 -162
- package/dist/kimi-hook.js +130 -135
- package/dist/kimi-sessionstart-hook.js +127 -128
- package/dist/kimi-stop-hook.js +113 -114
- package/dist/mcp-server.js +94 -93
- package/dist/opencode2.js +158 -162
- package/dist/pi.js +157 -161
- package/dist/prime-agent.js +157 -161
- package/dist/qwen-hook.js +130 -135
- package/dist/qwen-sessionstart-hook.js +127 -128
- package/dist/qwen-stop-hook.js +113 -114
- package/dist/status.js +80 -79
- package/dist/traecode-hook.js +130 -135
- package/dist/traecode-sessionstart-hook.js +127 -128
- package/dist/traecode-stop-hook.js +113 -114
- package/dist/workbuddy-hook.js +130 -135
- package/dist/workbuddy-sessionstart-hook.js +127 -128
- package/dist/workbuddy-stop-hook.js +113 -114
- package/dist/zcode-hook.js +130 -135
- package/dist/zcode-sessionstart-hook.js +127 -128
- package/dist/zcode-stop-hook.js +113 -114
- package/package.json +2 -1
- package/plugin.json +1 -1
- package/skill/SKILL.md +23 -23
package/dist/kilo.js
CHANGED
|
@@ -440,14 +440,14 @@ var RETAIN_STRATEGIES = {
|
|
|
440
440
|
retain_chunk_size: 12e3
|
|
441
441
|
}
|
|
442
442
|
};
|
|
443
|
-
var
|
|
443
|
+
var PAGE_LABELS = {
|
|
444
444
|
key: "knowledge",
|
|
445
445
|
type: "multi-values",
|
|
446
446
|
// 0, 1, or several — empty is normal
|
|
447
447
|
optional: true,
|
|
448
448
|
tag: true,
|
|
449
449
|
// emits knowledge:<value> onto the fact's tags
|
|
450
|
-
description: "Routing labels for this project's Hindsight
|
|
450
|
+
description: "Routing labels for this project's Hindsight PAGES \u2014 curated, human-readable summaries of the repo's DURABLE engineering knowledge (architecture, key decisions, conventions, ongoing initiatives), each page rebuilt automatically from the facts labeled for it. Mark a fact only when it is durable, reusable knowledge a developer would still want surfaced in future sessions. IMPORTANT: leave this EMPTY for routine, transient, or operational facts \u2014 a passing test, a one-off command, a status update, a debugging dead-end. MOST facts should get no label here. Assign more than one value only when the fact genuinely fits several.",
|
|
451
451
|
values: [
|
|
452
452
|
{
|
|
453
453
|
value: "feature-work",
|
|
@@ -604,7 +604,7 @@ var CODING_BANK_TEMPLATE = {
|
|
|
604
604
|
retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
|
|
605
605
|
retain_default_strategy: "git",
|
|
606
606
|
retain_strategies: RETAIN_STRATEGIES,
|
|
607
|
-
entity_labels: [
|
|
607
|
+
entity_labels: [PAGE_LABELS],
|
|
608
608
|
entities_allow_free_form: true
|
|
609
609
|
}
|
|
610
610
|
};
|
|
@@ -656,7 +656,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
656
656
|
}
|
|
657
657
|
|
|
658
658
|
// package.json
|
|
659
|
-
var version = "0.8.
|
|
659
|
+
var version = "0.8.7";
|
|
660
660
|
|
|
661
661
|
// src/core/util.ts
|
|
662
662
|
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
@@ -739,11 +739,11 @@ function retryAfterMs(header) {
|
|
|
739
739
|
const at = Date.parse(header);
|
|
740
740
|
return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
|
|
741
741
|
}
|
|
742
|
-
var
|
|
743
|
-
code = "
|
|
742
|
+
var PagesUnavailableError = class extends Error {
|
|
743
|
+
code = "pages_unavailable";
|
|
744
744
|
constructor() {
|
|
745
|
-
super("Hindsight server does not support
|
|
746
|
-
this.name = "
|
|
745
|
+
super("Hindsight server does not support pages");
|
|
746
|
+
this.name = "PagesUnavailableError";
|
|
747
747
|
}
|
|
748
748
|
};
|
|
749
749
|
async function isEndpointMissing(r) {
|
|
@@ -754,6 +754,10 @@ async function isEndpointMissing(r) {
|
|
|
754
754
|
return false;
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
+
function pagesPath(sub, legacy = false) {
|
|
758
|
+
if (!legacy) return `/pages${sub}`;
|
|
759
|
+
return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
|
|
760
|
+
}
|
|
757
761
|
var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
|
|
758
762
|
var ReflectError = class extends Error {
|
|
759
763
|
constructor(message, status, timedOut, options) {
|
|
@@ -822,7 +826,7 @@ var HindsightClient = class {
|
|
|
822
826
|
opIds = [];
|
|
823
827
|
// async operation ids collected by retain(), for drain()
|
|
824
828
|
/** Tri-state capability probe: unknown until the first page request, then cached. */
|
|
825
|
-
|
|
829
|
+
pagesSupported;
|
|
826
830
|
/** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
|
|
827
831
|
idempotentRetain;
|
|
828
832
|
log;
|
|
@@ -1051,7 +1055,7 @@ var HindsightClient = class {
|
|
|
1051
1055
|
return (j.total ?? j.items?.length ?? 0) > 0;
|
|
1052
1056
|
}
|
|
1053
1057
|
/** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
|
|
1054
|
-
* entity labels), then seed
|
|
1058
|
+
* entity labels), then seed pages when the server supports them. Both halves are
|
|
1055
1059
|
* idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
|
|
1056
1060
|
* extraction mode of the plugin's own strategies, which follows its config (#4560) — so
|
|
1057
1061
|
* the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
|
|
@@ -1233,29 +1237,45 @@ var HindsightClient = class {
|
|
|
1233
1237
|
const j = await r.json();
|
|
1234
1238
|
return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
|
|
1235
1239
|
}
|
|
1240
|
+
/** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
|
|
1241
|
+
* page routes moved to `/pages/...`. Remove in 2.x. */
|
|
1242
|
+
legacyPagesPaths = false;
|
|
1236
1243
|
/**
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1244
|
+
* Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
|
|
1245
|
+
*
|
|
1246
|
+
* Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
|
|
1247
|
+
* unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
|
|
1248
|
+
* older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
|
|
1249
|
+
* a capability verdict — it is the expected answer before the bank's first retain — so it is
|
|
1250
|
+
* returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
|
|
1240
1251
|
*
|
|
1241
1252
|
* Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
|
|
1242
1253
|
* the 405/501 this used to check for never reach a caller in the first place.
|
|
1243
1254
|
*/
|
|
1244
|
-
async
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
return
|
|
1255
|
+
async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
|
|
1256
|
+
const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
|
|
1257
|
+
let r = await send(this.legacyPagesPaths);
|
|
1258
|
+
if (r.status !== 404 || !await isEndpointMissing(r)) return r;
|
|
1259
|
+
if (!this.legacyPagesPaths) {
|
|
1260
|
+
r = await send(true);
|
|
1261
|
+
if (r.status !== 404 || !await isEndpointMissing(r)) {
|
|
1262
|
+
this.legacyPagesPaths = true;
|
|
1263
|
+
return r;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
this.pagesSupported = false;
|
|
1267
|
+
return null;
|
|
1248
1268
|
}
|
|
1249
1269
|
/**
|
|
1250
|
-
* The bank's
|
|
1270
|
+
* The bank's page tree (folders + pages, nested). The tree carries names, source
|
|
1251
1271
|
* queries and staleness but NOT synthesized content, so it is cheap enough to poll.
|
|
1252
1272
|
*/
|
|
1253
1273
|
async tree() {
|
|
1254
|
-
if (this.
|
|
1255
|
-
const r = await this.
|
|
1256
|
-
if (
|
|
1274
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
1275
|
+
const r = await this.pagesReq("GET", "/tree");
|
|
1276
|
+
if (!r) throw new PagesUnavailableError();
|
|
1257
1277
|
if (r.status === 404) return [];
|
|
1258
|
-
this.
|
|
1278
|
+
this.pagesSupported = true;
|
|
1259
1279
|
try {
|
|
1260
1280
|
return (await r.json()).roots ?? [];
|
|
1261
1281
|
} catch {
|
|
@@ -1263,13 +1283,13 @@ var HindsightClient = class {
|
|
|
1263
1283
|
}
|
|
1264
1284
|
}
|
|
1265
1285
|
/**
|
|
1266
|
-
* List
|
|
1286
|
+
* List pages (ids + names only — no synthesized content), flattened out of the tree
|
|
1267
1287
|
* and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
|
|
1268
1288
|
* to read, and a caller enumerating pages wants leaves, not structure.
|
|
1269
1289
|
*
|
|
1270
|
-
* NOTE the ids are
|
|
1271
|
-
* page read/update in this client goes through the same
|
|
1272
|
-
* here, from `
|
|
1290
|
+
* NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
|
|
1291
|
+
* page read/update in this client goes through the same page ids, so a page id from
|
|
1292
|
+
* here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
|
|
1273
1293
|
*/
|
|
1274
1294
|
async listPages() {
|
|
1275
1295
|
const items = [];
|
|
@@ -1291,34 +1311,26 @@ var HindsightClient = class {
|
|
|
1291
1311
|
return { items };
|
|
1292
1312
|
}
|
|
1293
1313
|
/**
|
|
1294
|
-
* Read one
|
|
1314
|
+
* Read one page's synthesized content by page id, shaped by `shapePage` so
|
|
1295
1315
|
* the body arrives once. The endpoint omits the internal reflect trace that built
|
|
1296
1316
|
* the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
|
|
1297
1317
|
* token cap.
|
|
1298
1318
|
*/
|
|
1299
1319
|
async getPage(pageId) {
|
|
1300
|
-
if (this.
|
|
1301
|
-
const r = await this.
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
);
|
|
1305
|
-
if (r.status === 404) throw new Error(`knowledge page not found: ${pageId}`);
|
|
1320
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
1321
|
+
const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
|
|
1322
|
+
if (!r) throw new PagesUnavailableError();
|
|
1323
|
+
if (r.status === 404) throw new Error(`page not found: ${pageId}`);
|
|
1306
1324
|
return shapePage(await r.json());
|
|
1307
1325
|
}
|
|
1308
|
-
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's
|
|
1326
|
+
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
|
|
1309
1327
|
* Returns page-level hits with a relevance snippet — the real search behind
|
|
1310
|
-
*
|
|
1311
|
-
async
|
|
1312
|
-
if (this.
|
|
1328
|
+
* hindsight_search_pages. */
|
|
1329
|
+
async searchPages(query, opts = {}) {
|
|
1330
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
1313
1331
|
const q = `?q=${encodeURIComponent(query)}&limit=${opts.limit ?? this.pageSearchLimit}`;
|
|
1314
|
-
const r = await this.
|
|
1315
|
-
|
|
1316
|
-
this.bankUrl(`/knowledge-base/search${q}`),
|
|
1317
|
-
void 0,
|
|
1318
|
-
[],
|
|
1319
|
-
opts.timeoutMs
|
|
1320
|
-
);
|
|
1321
|
-
if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
|
|
1332
|
+
const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
|
|
1333
|
+
if (!r) throw new PagesUnavailableError();
|
|
1322
1334
|
if (r.status === 404) return [];
|
|
1323
1335
|
const j = await r.json();
|
|
1324
1336
|
return (j.results ?? []).map((x) => ({
|
|
@@ -1330,9 +1342,9 @@ var HindsightClient = class {
|
|
|
1330
1342
|
}));
|
|
1331
1343
|
}
|
|
1332
1344
|
/**
|
|
1333
|
-
* Seed the fixed page taxonomy as
|
|
1345
|
+
* Seed the fixed page taxonomy as pages at the tree root, idempotently.
|
|
1334
1346
|
*
|
|
1335
|
-
* Matched by NAME, not id:
|
|
1347
|
+
* Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
|
|
1336
1348
|
* client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
|
|
1337
1349
|
* off a slug). Names are unique per folder server-side, which makes them a sound key.
|
|
1338
1350
|
*
|
|
@@ -1347,8 +1359,8 @@ var HindsightClient = class {
|
|
|
1347
1359
|
try {
|
|
1348
1360
|
roots = await this.tree();
|
|
1349
1361
|
} catch (e) {
|
|
1350
|
-
if (e instanceof
|
|
1351
|
-
this.log(`[bank]
|
|
1362
|
+
if (e instanceof PagesUnavailableError) {
|
|
1363
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
1352
1364
|
return;
|
|
1353
1365
|
}
|
|
1354
1366
|
throw e;
|
|
@@ -1371,11 +1383,9 @@ var HindsightClient = class {
|
|
|
1371
1383
|
trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
|
|
1372
1384
|
};
|
|
1373
1385
|
if (!hit) {
|
|
1374
|
-
const r = await this.
|
|
1375
|
-
if (
|
|
1376
|
-
this.log(
|
|
1377
|
-
`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
|
|
1378
|
-
);
|
|
1386
|
+
const r = await this.pagesReq("POST", "", body, [409]);
|
|
1387
|
+
if (!r) {
|
|
1388
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
1379
1389
|
return;
|
|
1380
1390
|
}
|
|
1381
1391
|
if (r.status === 404) {
|
|
@@ -1396,15 +1406,9 @@ var HindsightClient = class {
|
|
|
1396
1406
|
);
|
|
1397
1407
|
}
|
|
1398
1408
|
if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
|
|
1399
|
-
const r = await this.
|
|
1400
|
-
|
|
1401
|
-
this.
|
|
1402
|
-
patch
|
|
1403
|
-
);
|
|
1404
|
-
if (await this.pagesUnsupported(r)) {
|
|
1405
|
-
this.log(
|
|
1406
|
-
`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
|
|
1407
|
-
);
|
|
1409
|
+
const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
|
|
1410
|
+
if (!r) {
|
|
1411
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
1408
1412
|
return;
|
|
1409
1413
|
}
|
|
1410
1414
|
if (r.status === 404) {
|
|
@@ -1416,7 +1420,7 @@ var HindsightClient = class {
|
|
|
1416
1420
|
}
|
|
1417
1421
|
const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
|
|
1418
1422
|
this.log(
|
|
1419
|
-
`[bank]
|
|
1423
|
+
`[bank] pages seeded on ${this.bank} (scoped to ${this.project ?? "the shared bank"}): ${created} created, ${updated} re-synced, ${pages.length - created - updated - vanished} unchanged` + (vanished ? `, ${vanished} deleted under us` : "") + (initiatives ? `, ${initiatives} initiative pages re-synced` : "")
|
|
1420
1424
|
);
|
|
1421
1425
|
}
|
|
1422
1426
|
/**
|
|
@@ -1450,12 +1454,8 @@ var HindsightClient = class {
|
|
|
1450
1454
|
if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
|
|
1451
1455
|
}
|
|
1452
1456
|
if (!patch.trigger && !patch.source_query) continue;
|
|
1453
|
-
const r = await this.
|
|
1454
|
-
|
|
1455
|
-
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
|
|
1456
|
-
patch
|
|
1457
|
-
);
|
|
1458
|
-
if (r.status === 404) continue;
|
|
1457
|
+
const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
|
|
1458
|
+
if (!r || r.status === 404) continue;
|
|
1459
1459
|
updated++;
|
|
1460
1460
|
}
|
|
1461
1461
|
return updated;
|
|
@@ -1481,7 +1481,7 @@ var HindsightClient = class {
|
|
|
1481
1481
|
let pageId = args.relatesToPageId;
|
|
1482
1482
|
if (!pageId) {
|
|
1483
1483
|
const folderId = await this.ensureFolder("Initiatives");
|
|
1484
|
-
const r = await this.
|
|
1484
|
+
const r = await this.pagesReq("POST", "", {
|
|
1485
1485
|
name: args.title,
|
|
1486
1486
|
source_query: `Summarize the "${args.title}" initiative: what is being built or changed and why, and its current state \u2014 drawn from the project's memory.` + pageScopeRule(this.project),
|
|
1487
1487
|
parent_id: folderId,
|
|
@@ -1490,8 +1490,8 @@ var HindsightClient = class {
|
|
|
1490
1490
|
trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
|
|
1491
1491
|
});
|
|
1492
1492
|
try {
|
|
1493
|
-
const j = await r
|
|
1494
|
-
pageId = j
|
|
1493
|
+
const j = await r?.json();
|
|
1494
|
+
pageId = j?.page_id ?? j?.id;
|
|
1495
1495
|
} catch {
|
|
1496
1496
|
}
|
|
1497
1497
|
pageId ||= `initiative-${this.slugify(args.title)}`;
|
|
@@ -1509,16 +1509,17 @@ var HindsightClient = class {
|
|
|
1509
1509
|
/** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
|
|
1510
1510
|
async ensureFolder(name) {
|
|
1511
1511
|
try {
|
|
1512
|
-
const
|
|
1513
|
-
const
|
|
1512
|
+
const r = await this.pagesReq("GET", "/tree");
|
|
1513
|
+
const tree = await r?.json();
|
|
1514
|
+
const hit = (tree?.roots || []).find(
|
|
1514
1515
|
(n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
|
|
1515
1516
|
);
|
|
1516
1517
|
if (hit?.id) return hit.id;
|
|
1517
1518
|
} catch {
|
|
1518
1519
|
}
|
|
1519
1520
|
try {
|
|
1520
|
-
const r = await this.
|
|
1521
|
-
return (await r
|
|
1521
|
+
const r = await this.pagesReq("POST", "/folders", { name });
|
|
1522
|
+
return (await r?.json())?.id;
|
|
1522
1523
|
} catch {
|
|
1523
1524
|
return void 0;
|
|
1524
1525
|
}
|
|
@@ -2358,7 +2359,7 @@ function preflightDaemon(cfg, harness) {
|
|
|
2358
2359
|
return true;
|
|
2359
2360
|
}
|
|
2360
2361
|
|
|
2361
|
-
// src/core/
|
|
2362
|
+
// src/core/page-injection.ts
|
|
2362
2363
|
function parsePageList(raw) {
|
|
2363
2364
|
const items = raw?.items;
|
|
2364
2365
|
if (!Array.isArray(items)) return [];
|
|
@@ -2370,12 +2371,12 @@ function parsePageList(raw) {
|
|
|
2370
2371
|
}
|
|
2371
2372
|
return out;
|
|
2372
2373
|
}
|
|
2373
|
-
var EMPTY_STATE = "No
|
|
2374
|
+
var EMPTY_STATE = "No pages yet \u2014 Hindsight is still learning this repo; they'll appear as it processes.";
|
|
2374
2375
|
function indexLine(pages) {
|
|
2375
|
-
const count = pages.length === 1 ? "1
|
|
2376
|
-
return `${count} this repository \u2014 architecture, conventions, past decisions and in-flight initiatives. They are deliberately NOT listed here: call
|
|
2376
|
+
const count = pages.length === 1 ? "1 page covers" : `${pages.length} pages cover`;
|
|
2377
|
+
return `${count} this repository \u2014 architecture, conventions, past decisions and in-flight initiatives. They are deliberately NOT listed here: call hindsight_search_pages(query) to find the ones that bear on the current turn, then hindsight_read_page(<id>) on anything the results show is worth reading in full.`;
|
|
2377
2378
|
}
|
|
2378
|
-
var TOOL_GUIDE = `-
|
|
2379
|
+
var TOOL_GUIDE = `- hindsight_search_pages(query) \u2014 FIRST STOP, and the way IN to everything below. The code shows what is true today but not what was decided or why; memory shows what was decided or said back then but not whether it still holds. Work built from either alone goes wrong: from code alone it quietly re-litigates settled questions, from memory alone it acts on stale claims. Search BEFORE you act whenever the turn is one of these \u2014 they are the ones that go wrong silently:
|
|
2379
2380
|
\u2022 the user reports a bug or a wrong response (the intended behaviour, and the status code or value it should return, may already have been decided);
|
|
2380
2381
|
\u2022 you are about to write or change a test (what this project expects a change to ship with, and how it asserts, is a convention, not a preference);
|
|
2381
2382
|
\u2022 you are implementing something new, or two parts have to fit together;
|
|
@@ -2383,32 +2384,32 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP, a
|
|
|
2383
2384
|
\u2022 you are about to commit, and need to know what the change was supposed to honour.
|
|
2384
2385
|
It ranks the pages by relevance and returns the matching passage, which a page title cannot tell you. What it returns is a past record, not a live reading: a claim that something was fixed, passes, or works is what someone said then \u2014 check it against the code before you rely on it, and say so when the two disagree.
|
|
2385
2386
|
CREDITING IS NOT OPTIONAL AND NOT A JUDGEMENT CALL. If you called this tool and anything it returned reached your reply \u2014 quoted, paraphrased, or merely confirming what you were about to say \u2014 open that part with a markdown blockquote, exactly: "> \u{1F9E0} **From Hindsight memory (<page>)** \u2014 <the specific facts you drew on>". Rewriting a snippet in your own words does not make it yours. A search that turned up nothing useful needs no mention at all \u2014 just carry on.
|
|
2386
|
-
-
|
|
2387
|
+
- hindsight_list_pages / hindsight_read_page \u2014 BEFORE substantial work, list the pages and read the relevant ones to ground yourself in this repo's architecture, conventions, and past decisions instead of re-deriving them from the code; follow any [[page:<id>]] links you see.
|
|
2387
2388
|
- hindsight_reflect(query) \u2014 when pages are too shallow and you need the WHY: deep reasoning over the repo's full memory for the past decision and exact values that explain a behavior or bug (slower \u2014 use deliberately, and credit results with a blockquote header "> \u{1F9E0} **From Hindsight memory** \u2014 <summary>").
|
|
2388
2389
|
- hindsight_capture_initiative(title, summary) \u2014 right after the user approves a plan or finishes brainstorming a new feature/capability and you are about to start implementing (BEFORE you write any code), call this to record it as a tracked page; then call it AGAIN with relates_to_page_id set to that page whenever the goal, scope, or rationale materially changes mid-work, so the page tracks the current plan and not the opening one. Skip bug fixes, small tweaks, chores, and trivial course-corrections.
|
|
2389
2390
|
- hindsight_ingest_document(title, content) \u2014 save an external document or durable notes/findings you want remembered (not the current conversation \u2014 that is captured automatically at session end).`;
|
|
2390
|
-
var PAGES_FIRST_ON_GOALS = "- The user just set a NEW task or goal \u2192 search the
|
|
2391
|
+
var PAGES_FIRST_ON_GOALS = "- The user just set a NEW task or goal \u2192 search the pages FIRST with hindsight_search_pages. No synthesis is injected automatically in this configuration; call hindsight_reflect only when those pages are too shallow and deeper reasoning is needed.\n";
|
|
2391
2392
|
function toolGuide(opts) {
|
|
2392
2393
|
const extra = opts?.extra?.trim();
|
|
2393
2394
|
return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE + (extra ? `
|
|
2394
2395
|
${extra}` : "");
|
|
2395
2396
|
}
|
|
2396
|
-
function
|
|
2397
|
+
function buildPagesPreamble(pages, opts) {
|
|
2397
2398
|
const body = pages.length ? indexLine(pages) : EMPTY_STATE;
|
|
2398
|
-
return `<
|
|
2399
|
-
This repository has a Hindsight memory +
|
|
2399
|
+
return `<hindsight_pages>
|
|
2400
|
+
This repository has a Hindsight memory + pages (curated, continuously-updated pages plus the raw memory behind them). The tools below are registered, but you must actually CALL them at the right moments:
|
|
2400
2401
|
${toolGuide(opts)}
|
|
2401
2402
|
ALSO your correction tool: when you verify a Hindsight memory is wrong or stale, ingest a "Correction: <topic>" doc stating what memory claimed, what is true now, and the evidence \u2014 newer facts supersede older ones.
|
|
2402
2403
|
${body}
|
|
2403
2404
|
This tool guide and the page list are re-injected for you periodically as things change.
|
|
2404
|
-
</
|
|
2405
|
+
</hindsight_pages>`;
|
|
2405
2406
|
}
|
|
2406
2407
|
function buildRosterRefresh(pages, opts) {
|
|
2407
2408
|
const rosterBlock = pages.length ? `${indexLine(pages)}
|
|
2408
2409
|
` : "";
|
|
2409
|
-
return "<
|
|
2410
|
+
return "<hindsight_page_refresh>\n" + rosterBlock + `Reminder \u2014 this repo's Hindsight tools are available; call them at the right moments:
|
|
2410
2411
|
${toolGuide(opts)}
|
|
2411
|
-
</
|
|
2412
|
+
</hindsight_page_refresh>`;
|
|
2412
2413
|
}
|
|
2413
2414
|
|
|
2414
2415
|
// node_modules/zod/v4/classic/external.js
|
|
@@ -16925,7 +16926,7 @@ function date4(params) {
|
|
|
16925
16926
|
// node_modules/zod/v4/classic/external.js
|
|
16926
16927
|
config(en_default());
|
|
16927
16928
|
|
|
16928
|
-
// src/core/
|
|
16929
|
+
// src/core/page-tools.ts
|
|
16929
16930
|
import { createHash as createHash4 } from "crypto";
|
|
16930
16931
|
import { existsSync as existsSync4 } from "fs";
|
|
16931
16932
|
import { homedir as homedir6 } from "os";
|
|
@@ -17594,11 +17595,11 @@ async function syncStatus(client, bank, repoDir) {
|
|
|
17594
17595
|
activeOps,
|
|
17595
17596
|
// Older Hindsight servers have no page surface. They are still fully usable for the
|
|
17596
17597
|
// legacy bank/retain pipeline, so page absence must not make syncStatus permanently false.
|
|
17597
|
-
synced: gitlogPresent && (client.
|
|
17598
|
+
synced: gitlogPresent && (client.pagesSupported === false || pages.length > 0) && (activeOps ?? 0) === 0
|
|
17598
17599
|
};
|
|
17599
17600
|
}
|
|
17600
17601
|
|
|
17601
|
-
// src/core/
|
|
17602
|
+
// src/core/page-tools.ts
|
|
17602
17603
|
var READ_ONLY_ANNOTATIONS = {
|
|
17603
17604
|
readOnlyHint: true,
|
|
17604
17605
|
destructiveHint: false,
|
|
@@ -17628,13 +17629,13 @@ function guarded(fn) {
|
|
|
17628
17629
|
}
|
|
17629
17630
|
};
|
|
17630
17631
|
}
|
|
17631
|
-
function
|
|
17632
|
+
function buildPageTools(client, bankId, opts = {}) {
|
|
17632
17633
|
const extra = opts.toolGuideExtra?.trim();
|
|
17633
17634
|
const crediting = extra ? `${CREDIT_REMINDER} ${extra}` : CREDIT_REMINDER;
|
|
17634
17635
|
return [
|
|
17635
17636
|
{
|
|
17636
17637
|
name: "hindsight_sync_status",
|
|
17637
|
-
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,
|
|
17638
|
+
description: "Report whether this repo's memory bank is in sync: gitlog seed present, how much recent history has been deepened with full diffs, conversations ingested, pages created, and extractions still running. `synced: true` means the seeded memory is fully queryable. Ingestion is automatic and background \u2014 if not synced, it is in progress; nothing to run.",
|
|
17638
17639
|
inputSchema: {},
|
|
17639
17640
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
17640
17641
|
handler: async () => {
|
|
@@ -17689,13 +17690,13 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
17689
17690
|
}
|
|
17690
17691
|
},
|
|
17691
17692
|
{
|
|
17692
|
-
name: "
|
|
17693
|
-
description: "Search this repository's Hindsight
|
|
17693
|
+
name: "hindsight_search_pages",
|
|
17694
|
+
description: "Search this repository's Hindsight pages for content relevant to a query \u2014 hybrid full-text + semantic search, server-side. Call this when the user's question may be answered by the project's accumulated knowledge (architecture, conventions, decisions, initiatives) rather than by reading code. Returns ranked pages with a relevance snippet; read a full page with hindsight_read_page. " + crediting,
|
|
17694
17695
|
inputSchema: { query: external_exports.string().describe("what to look for") },
|
|
17695
17696
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
17696
17697
|
handler: async (args) => {
|
|
17697
17698
|
try {
|
|
17698
|
-
const hits = await client.
|
|
17699
|
+
const hits = await client.searchPages(args.query);
|
|
17699
17700
|
return ok({
|
|
17700
17701
|
pages: hits.map((h) => ({
|
|
17701
17702
|
page: h.name,
|
|
@@ -17713,22 +17714,22 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
17713
17714
|
}
|
|
17714
17715
|
},
|
|
17715
17716
|
{
|
|
17716
|
-
name: "
|
|
17717
|
-
description: "List this repository's Hindsight
|
|
17717
|
+
name: "hindsight_list_pages",
|
|
17718
|
+
description: "List this repository's Hindsight pages \u2014 curated, continuously-updated summaries of the project's durable knowledge (architecture, components, conventions, key decisions, and in-flight initiatives). Returns each page's id, title, and a one-line description of what it covers. Call this at the start of any non-trivial task, and again periodically in long sessions, to see what the project already knows before you read code or ask the user. The list changes as work is captured, so re-check it occasionally.",
|
|
17718
17719
|
inputSchema: {},
|
|
17719
17720
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
17720
17721
|
handler: guarded(async () => client.listPages())
|
|
17721
17722
|
},
|
|
17722
17723
|
{
|
|
17723
|
-
name: "
|
|
17724
|
-
description: "Read the full content of one
|
|
17724
|
+
name: "hindsight_read_page",
|
|
17725
|
+
description: "Read the full content of one page by its id (from hindsight_list_pages). Call this whenever a listed page is relevant to what you're about to do \u2014 e.g. read Conventions before writing new code, Component map before changing a subsystem, or an initiative's page before continuing that feature. A page may contain [[page:<id>]] links to related pages; follow one by calling this tool again with that id. Prefer reading a page over re-deriving the same understanding from source.",
|
|
17725
17726
|
inputSchema: { page_id: external_exports.string() },
|
|
17726
17727
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
17727
17728
|
handler: guarded(async ({ page_id }) => client.getPage(page_id))
|
|
17728
17729
|
},
|
|
17729
17730
|
{
|
|
17730
17731
|
name: "hindsight_reflect",
|
|
17731
|
-
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
|
|
17732
|
+
description: `Deep memory reasoning: an agentic synthesis over this repository's FULL memory (git decisions, past sessions, ingested knowledge) that answers WHY questions \u2014 the past decision and exact rule/values that explain a behavior, bug, or convention. Slower than hindsight_search_pages (several seconds): reach for it when pages are too shallow and you need the root cause or the decided literals. When the answer informs your reply, credit it visibly with a blockquote header: "> \u{1F9E0} **From Hindsight memory** \u2014 <summary>".`,
|
|
17732
17733
|
inputSchema: { query: external_exports.string().describe("the question to reason over memory about") },
|
|
17733
17734
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
17734
17735
|
handler: guarded(
|
|
@@ -17740,7 +17741,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
17740
17741
|
},
|
|
17741
17742
|
{
|
|
17742
17743
|
name: "hindsight_capture_initiative",
|
|
17743
|
-
description: "Record a new feature or initiative as a tracked
|
|
17744
|
+
description: "Record a new feature or initiative as a tracked page, so future sessions know it exists and can build on it \u2014 and keep that page tracking the plan as it moves.\n\nWHEN TO CALL:\n- Starting one: right after the user approves a plan or finishes brainstorming a new feature/capability and you are about to start implementing \u2014 BEFORE you write any code. Leave relates_to_page_id empty.\n- Plan changed: call it AGAIN \u2014 mid-implementation is fine and expected \u2014 whenever the goal, scope, or rationale of an initiative you already captured materially changes (an approach is dropped, scope grows or shrinks, the why is rewritten). Pass relates_to_page_id = that initiative's page id so the change lands on the existing page. Never mint a second page for the same initiative.\n\nWHEN TO SKIP: bug fixes, small tweaks, refactors, chores, and trivial course-corrections that leave the goal intact are not initiatives \u2014 skip them.\n\n- title: short, specific name (e.g. 'Newsletter refinement chat'). On a recapture, reuse the initiative's existing title.\n- summary: 2-3 sentences on what you're building and why \u2014 the CURRENT intent, not the originally approved plan (on a recapture, say what changed and why).\n- relates_to_page_id: leave empty for a new initiative. Set it to an existing initiative's page id \u2014 from hindsight_list_pages, or the id this tool returned earlier \u2014 to record a plan change or an enhancement to it.\n\nReturns the page id. The page is generated for you \u2014 you never format one yourself.",
|
|
17744
17745
|
inputSchema: {
|
|
17745
17746
|
title: external_exports.string(),
|
|
17746
17747
|
summary: external_exports.string(),
|
|
@@ -18477,11 +18478,11 @@ async function buildSessionStartContext(args) {
|
|
|
18477
18478
|
try {
|
|
18478
18479
|
pages = parsePageList(await client.listPages());
|
|
18479
18480
|
} catch {
|
|
18480
|
-
if (client.
|
|
18481
|
-
diag(harness, "
|
|
18481
|
+
if (client.pagesSupported === false) {
|
|
18482
|
+
diag(harness, "pages_unavailable", { bank: bankId });
|
|
18482
18483
|
}
|
|
18483
18484
|
}
|
|
18484
|
-
const additionalContext =
|
|
18485
|
+
const additionalContext = buildPagesPreamble(pages, {
|
|
18485
18486
|
reflectOnNewGoals: cfg.autoInject !== "reflect",
|
|
18486
18487
|
extra: cfg.toolGuideExtra
|
|
18487
18488
|
});
|
|
@@ -18511,6 +18512,41 @@ ${legacyClaudePluginWarning(legacyPlugin)}`;
|
|
|
18511
18512
|
// src/core/hook.ts
|
|
18512
18513
|
import { existsSync as existsSync8 } from "fs";
|
|
18513
18514
|
|
|
18515
|
+
// src/core/transcript-util.ts
|
|
18516
|
+
var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_pages|hindsight_page_refresh|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
|
|
18517
|
+
function stripInjectedMemory(s) {
|
|
18518
|
+
return s.replace(MEMORY_TAG_RE, "");
|
|
18519
|
+
}
|
|
18520
|
+
var TARGET_KEYS = [
|
|
18521
|
+
"file_path",
|
|
18522
|
+
"path",
|
|
18523
|
+
"notebook_path",
|
|
18524
|
+
"command",
|
|
18525
|
+
"pattern",
|
|
18526
|
+
"query",
|
|
18527
|
+
"url",
|
|
18528
|
+
"name",
|
|
18529
|
+
"id"
|
|
18530
|
+
];
|
|
18531
|
+
var ACTION_TARGET_CAP = 100;
|
|
18532
|
+
function actionLine(tool2, input) {
|
|
18533
|
+
let target = "";
|
|
18534
|
+
if (input && typeof input === "object") {
|
|
18535
|
+
const rec = input;
|
|
18536
|
+
for (const k of TARGET_KEYS) {
|
|
18537
|
+
const v = rec[k];
|
|
18538
|
+
if (typeof v === "string" && v.trim()) {
|
|
18539
|
+
target = v.trim().split("\n")[0];
|
|
18540
|
+
break;
|
|
18541
|
+
}
|
|
18542
|
+
}
|
|
18543
|
+
} else if (typeof input === "string") {
|
|
18544
|
+
target = input.trim().split("\n")[0];
|
|
18545
|
+
}
|
|
18546
|
+
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
18547
|
+
return target ? `${tool2} ${target}` : tool2;
|
|
18548
|
+
}
|
|
18549
|
+
|
|
18514
18550
|
// src/core/inject.ts
|
|
18515
18551
|
function buildReflectQuery(prompt) {
|
|
18516
18552
|
return `A developer is starting a coding session in this repository with this goal:
|
|
@@ -18527,8 +18563,8 @@ Report what this bank's history genuinely bears on that goal. Rendering rules, s
|
|
|
18527
18563
|
- Do not connect unrelated episodes into one narrative; if two facts are not explicitly linked in the record, report them separately or leave the weaker one out.
|
|
18528
18564
|
- If the bank holds nothing that bears on the goal, say so in one line.`;
|
|
18529
18565
|
}
|
|
18530
|
-
var PAGE_FALLBACK_LEAD = "(Hindsight's synthesis was unavailable this turn; these
|
|
18531
|
-
var PAGE_INJECT_LEAD = "(These
|
|
18566
|
+
var PAGE_FALLBACK_LEAD = "(Hindsight's synthesis was unavailable this turn; these pages matched the goal by search. Read one with hindsight_read_page(<id>) if it looks relevant.)";
|
|
18567
|
+
var PAGE_INJECT_LEAD = "(These pages matched the goal by search. Read one with hindsight_read_page(<id>) if it looks relevant.)";
|
|
18532
18568
|
function formatPageFallback(hits, lead = PAGE_FALLBACK_LEAD) {
|
|
18533
18569
|
return `${lead}
|
|
18534
18570
|
` + hits.map((h) => {
|
|
@@ -18559,43 +18595,6 @@ If you VERIFY this memory is wrong or outdated (the code or facts contradict it)
|
|
|
18559
18595
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync5, readFileSync as readFileSync10, statSync as statSync4 } from "fs";
|
|
18560
18596
|
import { tmpdir as tmpdir4 } from "os";
|
|
18561
18597
|
import { dirname as dirname10, join as join18 } from "path";
|
|
18562
|
-
|
|
18563
|
-
// src/core/transcript-util.ts
|
|
18564
|
-
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;
|
|
18565
|
-
function stripInjectedMemory(s) {
|
|
18566
|
-
return s.replace(MEMORY_TAG_RE, "");
|
|
18567
|
-
}
|
|
18568
|
-
var TARGET_KEYS = [
|
|
18569
|
-
"file_path",
|
|
18570
|
-
"path",
|
|
18571
|
-
"notebook_path",
|
|
18572
|
-
"command",
|
|
18573
|
-
"pattern",
|
|
18574
|
-
"query",
|
|
18575
|
-
"url",
|
|
18576
|
-
"name",
|
|
18577
|
-
"id"
|
|
18578
|
-
];
|
|
18579
|
-
var ACTION_TARGET_CAP = 100;
|
|
18580
|
-
function actionLine(tool2, input) {
|
|
18581
|
-
let target = "";
|
|
18582
|
-
if (input && typeof input === "object") {
|
|
18583
|
-
const rec = input;
|
|
18584
|
-
for (const k of TARGET_KEYS) {
|
|
18585
|
-
const v = rec[k];
|
|
18586
|
-
if (typeof v === "string" && v.trim()) {
|
|
18587
|
-
target = v.trim().split("\n")[0];
|
|
18588
|
-
break;
|
|
18589
|
-
}
|
|
18590
|
-
}
|
|
18591
|
-
} else if (typeof input === "string") {
|
|
18592
|
-
target = input.trim().split("\n")[0];
|
|
18593
|
-
}
|
|
18594
|
-
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
18595
|
-
return target ? `${tool2} ${target}` : tool2;
|
|
18596
|
-
}
|
|
18597
|
-
|
|
18598
|
-
// src/core/turn-journal.ts
|
|
18599
18598
|
var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
|
|
18600
18599
|
|
|
18601
18600
|
// src/core/hook.ts
|
|
@@ -18621,7 +18620,7 @@ function boundRecallQuery(prompt) {
|
|
|
18621
18620
|
async function injectPages(harness, prompt, client, timeoutMs, event, lead) {
|
|
18622
18621
|
const t0 = Date.now();
|
|
18623
18622
|
try {
|
|
18624
|
-
const hits = await client.
|
|
18623
|
+
const hits = await client.searchPages(prompt.slice(0, 500), { timeoutMs });
|
|
18625
18624
|
diag(harness, event, { ms: Date.now() - t0, count: hits.length });
|
|
18626
18625
|
return hits.length ? formatPageFallback(hits, lead) : null;
|
|
18627
18626
|
} catch (e) {
|
|
@@ -18735,14 +18734,10 @@ async function buildHookOutput(args) {
|
|
|
18735
18734
|
pages = parsePageList(await client.listPages());
|
|
18736
18735
|
diag(harness, "pages_ok", { ms: Date.now() - t0, count: pages.length });
|
|
18737
18736
|
} catch (e) {
|
|
18738
|
-
diag(
|
|
18739
|
-
|
|
18740
|
-
|
|
18741
|
-
|
|
18742
|
-
ms: Date.now() - t0,
|
|
18743
|
-
error: describeError(e)
|
|
18744
|
-
}
|
|
18745
|
-
);
|
|
18737
|
+
diag(harness, client.pagesSupported === false ? "pages_unavailable" : "pages_failed", {
|
|
18738
|
+
ms: Date.now() - t0,
|
|
18739
|
+
error: describeError(e)
|
|
18740
|
+
});
|
|
18746
18741
|
}
|
|
18747
18742
|
}
|
|
18748
18743
|
writeSessionCache(cacheFile, {
|
|
@@ -18821,9 +18816,9 @@ var RuntimeCore = class {
|
|
|
18821
18816
|
setTranscriptSource(fetch2) {
|
|
18822
18817
|
this.fetchTranscript = fetch2;
|
|
18823
18818
|
}
|
|
18824
|
-
/** The hindsight_*
|
|
18819
|
+
/** The hindsight_* page + recall tools, bound to this bank, for the harness to register natively. */
|
|
18825
18820
|
toolSpecs() {
|
|
18826
|
-
return
|
|
18821
|
+
return buildPageTools(this.client, this.bankId, {
|
|
18827
18822
|
repoDir: this.projectDir,
|
|
18828
18823
|
harness: this.harness,
|
|
18829
18824
|
pageTrigger: buildPageTrigger(this.cfg),
|
|
@@ -18845,7 +18840,7 @@ var RuntimeCore = class {
|
|
|
18845
18840
|
* git-log seed + codebase survey. Reuses the exact hook-harness logic
|
|
18846
18841
|
* (`buildSessionStartContext`) so opencode seeds identically. Never throws.
|
|
18847
18842
|
*
|
|
18848
|
-
* It deliberately does NOT keep that call's
|
|
18843
|
+
* It deliberately does NOT keep that call's pages preamble. This runs once per PROCESS and
|
|
18849
18844
|
* these hosts outlive every session, so a roster captured here is stale for every session but
|
|
18850
18845
|
* the first — `onPrompt` builds its own from the session's live page list (#4607).
|
|
18851
18846
|
*/
|
|
@@ -18876,10 +18871,11 @@ var RuntimeCore = class {
|
|
|
18876
18871
|
* intentionally replaces the old in-memory reflect/page state, keeping lifecycle behavior
|
|
18877
18872
|
* identical across hosts while this adapter retains only delivery-specific state.
|
|
18878
18873
|
*/
|
|
18879
|
-
async onPrompt(sessionId,
|
|
18874
|
+
async onPrompt(sessionId, rawPrompt) {
|
|
18880
18875
|
if (process.env.HINDSIGHT_DISABLE_HOOKS) return;
|
|
18881
18876
|
if (!sessionId) return;
|
|
18882
|
-
|
|
18877
|
+
const prompt = stripInjectedMemory(rawPrompt).trim();
|
|
18878
|
+
if (!prompt) {
|
|
18883
18879
|
this.injection.delete(sessionId);
|
|
18884
18880
|
return;
|
|
18885
18881
|
}
|
|
@@ -18900,7 +18896,7 @@ var RuntimeCore = class {
|
|
|
18900
18896
|
const blocks = [];
|
|
18901
18897
|
if (turns === 1) {
|
|
18902
18898
|
blocks.push(
|
|
18903
|
-
|
|
18899
|
+
buildPagesPreamble(output.pages, {
|
|
18904
18900
|
reflectOnNewGoals: this.cfg.autoInject !== "reflect",
|
|
18905
18901
|
extra: this.cfg.toolGuideExtra
|
|
18906
18902
|
})
|
|
@@ -31547,7 +31543,7 @@ function createRuntime(core) {
|
|
|
31547
31543
|
...surveyAgentHook,
|
|
31548
31544
|
tool: tools,
|
|
31549
31545
|
// Each user turn: recall on the prompt, then add this turn's injection (recalled memories +
|
|
31550
|
-
// attribution/user-feedback framing, plus the
|
|
31546
|
+
// attribution/user-feedback framing, plus the pages preamble on turn 1 and the roster
|
|
31551
31547
|
// refresh on cadence) to the user message as a synthetic text part. The host saves the parts
|
|
31552
31548
|
// this hook leaves behind, so the block stays in the turn it was made for and every later
|
|
31553
31549
|
// request repeats it byte for byte. It used to be pushed into the system prompt through
|