@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.
- package/README.md +36 -30
- 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 +205 -215
- package/dist/claude-stop-hook.js +113 -114
- package/dist/cline.js +206 -211
- package/dist/codebuddy-hook.js +130 -135
- package/dist/codebuddy-sessionstart-hook.js +205 -215
- package/dist/codebuddy-stop-hook.js +113 -114
- package/dist/codex-hook.js +130 -135
- package/dist/codex-sessionstart-hook.js +205 -215
- package/dist/codex-stop-hook.js +113 -114
- package/dist/copilot-hook.js +130 -135
- package/dist/copilot-sessionstart-hook.js +205 -215
- package/dist/copilot-stop-hook.js +113 -114
- package/dist/cursor-hook.js +130 -135
- package/dist/cursor-sessionstart-hook.js +205 -215
- 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 +205 -215
- 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 +205 -215
- package/dist/devin-stop-hook.js +113 -114
- package/dist/droid-hook.js +130 -135
- package/dist/droid-sessionstart-hook.js +205 -215
- package/dist/droid-stop-hook.js +113 -114
- package/dist/dsh.js +235 -248
- package/dist/grok-hook.js +130 -135
- package/dist/grok-sessionstart-hook.js +205 -215
- package/dist/grok-stop-hook.js +113 -114
- package/dist/hindsight-seed.js +1 -1
- package/dist/index.js +236 -249
- package/dist/installer.js +30 -28
- package/dist/kilo.js +236 -249
- package/dist/kimi-hook.js +130 -135
- package/dist/kimi-sessionstart-hook.js +205 -215
- package/dist/kimi-stop-hook.js +113 -114
- package/dist/mcp-server.js +94 -93
- package/dist/opencode2.js +236 -249
- package/dist/pi.js +235 -248
- package/dist/prime-agent.js +235 -248
- package/dist/qwen-hook.js +130 -135
- package/dist/qwen-sessionstart-hook.js +205 -215
- 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 +205 -215
- package/dist/traecode-stop-hook.js +113 -114
- package/dist/workbuddy-hook.js +130 -135
- package/dist/workbuddy-sessionstart-hook.js +205 -215
- package/dist/workbuddy-stop-hook.js +113 -114
- package/dist/zcode-hook.js +130 -135
- package/dist/zcode-sessionstart-hook.js +205 -215
- package/dist/zcode-stop-hook.js +113 -114
- package/package.json +2 -1
- package/plugin.json +1 -1
- package/skill/SKILL.md +26 -26
package/dist/droid-stop-hook.js
CHANGED
|
@@ -417,14 +417,14 @@ var RETAIN_STRATEGIES = {
|
|
|
417
417
|
retain_chunk_size: 12e3
|
|
418
418
|
}
|
|
419
419
|
};
|
|
420
|
-
var
|
|
420
|
+
var PAGE_LABELS = {
|
|
421
421
|
key: "knowledge",
|
|
422
422
|
type: "multi-values",
|
|
423
423
|
// 0, 1, or several — empty is normal
|
|
424
424
|
optional: true,
|
|
425
425
|
tag: true,
|
|
426
426
|
// emits knowledge:<value> onto the fact's tags
|
|
427
|
-
description: "Routing labels for this project's Hindsight
|
|
427
|
+
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.",
|
|
428
428
|
values: [
|
|
429
429
|
{
|
|
430
430
|
value: "feature-work",
|
|
@@ -581,7 +581,7 @@ var CODING_BANK_TEMPLATE = {
|
|
|
581
581
|
retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
|
|
582
582
|
retain_default_strategy: "git",
|
|
583
583
|
retain_strategies: RETAIN_STRATEGIES,
|
|
584
|
-
entity_labels: [
|
|
584
|
+
entity_labels: [PAGE_LABELS],
|
|
585
585
|
entities_allow_free_form: true
|
|
586
586
|
}
|
|
587
587
|
};
|
|
@@ -633,7 +633,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
633
633
|
}
|
|
634
634
|
|
|
635
635
|
// package.json
|
|
636
|
-
var version = "0.8.
|
|
636
|
+
var version = "0.8.7";
|
|
637
637
|
|
|
638
638
|
// src/core/util.ts
|
|
639
639
|
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
@@ -702,11 +702,11 @@ function retryAfterMs(header) {
|
|
|
702
702
|
const at = Date.parse(header);
|
|
703
703
|
return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
|
|
704
704
|
}
|
|
705
|
-
var
|
|
706
|
-
code = "
|
|
705
|
+
var PagesUnavailableError = class extends Error {
|
|
706
|
+
code = "pages_unavailable";
|
|
707
707
|
constructor() {
|
|
708
|
-
super("Hindsight server does not support
|
|
709
|
-
this.name = "
|
|
708
|
+
super("Hindsight server does not support pages");
|
|
709
|
+
this.name = "PagesUnavailableError";
|
|
710
710
|
}
|
|
711
711
|
};
|
|
712
712
|
async function isEndpointMissing(r) {
|
|
@@ -717,6 +717,10 @@ async function isEndpointMissing(r) {
|
|
|
717
717
|
return false;
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
|
+
function pagesPath(sub, legacy = false) {
|
|
721
|
+
if (!legacy) return `/pages${sub}`;
|
|
722
|
+
return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
|
|
723
|
+
}
|
|
720
724
|
var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
|
|
721
725
|
var ReflectError = class extends Error {
|
|
722
726
|
constructor(message, status, timedOut, options) {
|
|
@@ -785,7 +789,7 @@ var HindsightClient = class {
|
|
|
785
789
|
opIds = [];
|
|
786
790
|
// async operation ids collected by retain(), for drain()
|
|
787
791
|
/** Tri-state capability probe: unknown until the first page request, then cached. */
|
|
788
|
-
|
|
792
|
+
pagesSupported;
|
|
789
793
|
/** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
|
|
790
794
|
idempotentRetain;
|
|
791
795
|
log;
|
|
@@ -1014,7 +1018,7 @@ var HindsightClient = class {
|
|
|
1014
1018
|
return (j.total ?? j.items?.length ?? 0) > 0;
|
|
1015
1019
|
}
|
|
1016
1020
|
/** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
|
|
1017
|
-
* entity labels), then seed
|
|
1021
|
+
* entity labels), then seed pages when the server supports them. Both halves are
|
|
1018
1022
|
* idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
|
|
1019
1023
|
* extraction mode of the plugin's own strategies, which follows its config (#4560) — so
|
|
1020
1024
|
* the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
|
|
@@ -1196,29 +1200,45 @@ var HindsightClient = class {
|
|
|
1196
1200
|
const j = await r.json();
|
|
1197
1201
|
return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
|
|
1198
1202
|
}
|
|
1203
|
+
/** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
|
|
1204
|
+
* page routes moved to `/pages/...`. Remove in 2.x. */
|
|
1205
|
+
legacyPagesPaths = false;
|
|
1199
1206
|
/**
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1207
|
+
* Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
|
|
1208
|
+
*
|
|
1209
|
+
* Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
|
|
1210
|
+
* unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
|
|
1211
|
+
* older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
|
|
1212
|
+
* a capability verdict — it is the expected answer before the bank's first retain — so it is
|
|
1213
|
+
* returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
|
|
1203
1214
|
*
|
|
1204
1215
|
* Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
|
|
1205
1216
|
* the 405/501 this used to check for never reach a caller in the first place.
|
|
1206
1217
|
*/
|
|
1207
|
-
async
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
return
|
|
1218
|
+
async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
|
|
1219
|
+
const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
|
|
1220
|
+
let r = await send(this.legacyPagesPaths);
|
|
1221
|
+
if (r.status !== 404 || !await isEndpointMissing(r)) return r;
|
|
1222
|
+
if (!this.legacyPagesPaths) {
|
|
1223
|
+
r = await send(true);
|
|
1224
|
+
if (r.status !== 404 || !await isEndpointMissing(r)) {
|
|
1225
|
+
this.legacyPagesPaths = true;
|
|
1226
|
+
return r;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
this.pagesSupported = false;
|
|
1230
|
+
return null;
|
|
1211
1231
|
}
|
|
1212
1232
|
/**
|
|
1213
|
-
* The bank's
|
|
1233
|
+
* The bank's page tree (folders + pages, nested). The tree carries names, source
|
|
1214
1234
|
* queries and staleness but NOT synthesized content, so it is cheap enough to poll.
|
|
1215
1235
|
*/
|
|
1216
1236
|
async tree() {
|
|
1217
|
-
if (this.
|
|
1218
|
-
const r = await this.
|
|
1219
|
-
if (
|
|
1237
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
1238
|
+
const r = await this.pagesReq("GET", "/tree");
|
|
1239
|
+
if (!r) throw new PagesUnavailableError();
|
|
1220
1240
|
if (r.status === 404) return [];
|
|
1221
|
-
this.
|
|
1241
|
+
this.pagesSupported = true;
|
|
1222
1242
|
try {
|
|
1223
1243
|
return (await r.json()).roots ?? [];
|
|
1224
1244
|
} catch {
|
|
@@ -1226,13 +1246,13 @@ var HindsightClient = class {
|
|
|
1226
1246
|
}
|
|
1227
1247
|
}
|
|
1228
1248
|
/**
|
|
1229
|
-
* List
|
|
1249
|
+
* List pages (ids + names only — no synthesized content), flattened out of the tree
|
|
1230
1250
|
* and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
|
|
1231
1251
|
* to read, and a caller enumerating pages wants leaves, not structure.
|
|
1232
1252
|
*
|
|
1233
|
-
* NOTE the ids are
|
|
1234
|
-
* page read/update in this client goes through the same
|
|
1235
|
-
* here, from `
|
|
1253
|
+
* NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
|
|
1254
|
+
* page read/update in this client goes through the same page ids, so a page id from
|
|
1255
|
+
* here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
|
|
1236
1256
|
*/
|
|
1237
1257
|
async listPages() {
|
|
1238
1258
|
const items = [];
|
|
@@ -1254,34 +1274,26 @@ var HindsightClient = class {
|
|
|
1254
1274
|
return { items };
|
|
1255
1275
|
}
|
|
1256
1276
|
/**
|
|
1257
|
-
* Read one
|
|
1277
|
+
* Read one page's synthesized content by page id, shaped by `shapePage` so
|
|
1258
1278
|
* the body arrives once. The endpoint omits the internal reflect trace that built
|
|
1259
1279
|
* the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
|
|
1260
1280
|
* token cap.
|
|
1261
1281
|
*/
|
|
1262
1282
|
async getPage(pageId) {
|
|
1263
|
-
if (this.
|
|
1264
|
-
const r = await this.
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
);
|
|
1268
|
-
if (r.status === 404) throw new Error(`knowledge page not found: ${pageId}`);
|
|
1283
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
1284
|
+
const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
|
|
1285
|
+
if (!r) throw new PagesUnavailableError();
|
|
1286
|
+
if (r.status === 404) throw new Error(`page not found: ${pageId}`);
|
|
1269
1287
|
return shapePage(await r.json());
|
|
1270
1288
|
}
|
|
1271
|
-
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's
|
|
1289
|
+
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
|
|
1272
1290
|
* Returns page-level hits with a relevance snippet — the real search behind
|
|
1273
|
-
*
|
|
1274
|
-
async
|
|
1275
|
-
if (this.
|
|
1291
|
+
* hindsight_search_pages. */
|
|
1292
|
+
async searchPages(query, opts = {}) {
|
|
1293
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
1276
1294
|
const q = `?q=${encodeURIComponent(query)}&limit=${opts.limit ?? this.pageSearchLimit}`;
|
|
1277
|
-
const r = await this.
|
|
1278
|
-
|
|
1279
|
-
this.bankUrl(`/knowledge-base/search${q}`),
|
|
1280
|
-
void 0,
|
|
1281
|
-
[],
|
|
1282
|
-
opts.timeoutMs
|
|
1283
|
-
);
|
|
1284
|
-
if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
|
|
1295
|
+
const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
|
|
1296
|
+
if (!r) throw new PagesUnavailableError();
|
|
1285
1297
|
if (r.status === 404) return [];
|
|
1286
1298
|
const j = await r.json();
|
|
1287
1299
|
return (j.results ?? []).map((x) => ({
|
|
@@ -1293,9 +1305,9 @@ var HindsightClient = class {
|
|
|
1293
1305
|
}));
|
|
1294
1306
|
}
|
|
1295
1307
|
/**
|
|
1296
|
-
* Seed the fixed page taxonomy as
|
|
1308
|
+
* Seed the fixed page taxonomy as pages at the tree root, idempotently.
|
|
1297
1309
|
*
|
|
1298
|
-
* Matched by NAME, not id:
|
|
1310
|
+
* Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
|
|
1299
1311
|
* client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
|
|
1300
1312
|
* off a slug). Names are unique per folder server-side, which makes them a sound key.
|
|
1301
1313
|
*
|
|
@@ -1310,8 +1322,8 @@ var HindsightClient = class {
|
|
|
1310
1322
|
try {
|
|
1311
1323
|
roots = await this.tree();
|
|
1312
1324
|
} catch (e) {
|
|
1313
|
-
if (e instanceof
|
|
1314
|
-
this.log(`[bank]
|
|
1325
|
+
if (e instanceof PagesUnavailableError) {
|
|
1326
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
1315
1327
|
return;
|
|
1316
1328
|
}
|
|
1317
1329
|
throw e;
|
|
@@ -1334,11 +1346,9 @@ var HindsightClient = class {
|
|
|
1334
1346
|
trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
|
|
1335
1347
|
};
|
|
1336
1348
|
if (!hit) {
|
|
1337
|
-
const r = await this.
|
|
1338
|
-
if (
|
|
1339
|
-
this.log(
|
|
1340
|
-
`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
|
|
1341
|
-
);
|
|
1349
|
+
const r = await this.pagesReq("POST", "", body, [409]);
|
|
1350
|
+
if (!r) {
|
|
1351
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
1342
1352
|
return;
|
|
1343
1353
|
}
|
|
1344
1354
|
if (r.status === 404) {
|
|
@@ -1359,15 +1369,9 @@ var HindsightClient = class {
|
|
|
1359
1369
|
);
|
|
1360
1370
|
}
|
|
1361
1371
|
if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
|
|
1362
|
-
const r = await this.
|
|
1363
|
-
|
|
1364
|
-
this.
|
|
1365
|
-
patch
|
|
1366
|
-
);
|
|
1367
|
-
if (await this.pagesUnsupported(r)) {
|
|
1368
|
-
this.log(
|
|
1369
|
-
`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
|
|
1370
|
-
);
|
|
1372
|
+
const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
|
|
1373
|
+
if (!r) {
|
|
1374
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
1371
1375
|
return;
|
|
1372
1376
|
}
|
|
1373
1377
|
if (r.status === 404) {
|
|
@@ -1379,7 +1383,7 @@ var HindsightClient = class {
|
|
|
1379
1383
|
}
|
|
1380
1384
|
const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
|
|
1381
1385
|
this.log(
|
|
1382
|
-
`[bank]
|
|
1386
|
+
`[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` : "")
|
|
1383
1387
|
);
|
|
1384
1388
|
}
|
|
1385
1389
|
/**
|
|
@@ -1413,12 +1417,8 @@ var HindsightClient = class {
|
|
|
1413
1417
|
if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
|
|
1414
1418
|
}
|
|
1415
1419
|
if (!patch.trigger && !patch.source_query) continue;
|
|
1416
|
-
const r = await this.
|
|
1417
|
-
|
|
1418
|
-
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
|
|
1419
|
-
patch
|
|
1420
|
-
);
|
|
1421
|
-
if (r.status === 404) continue;
|
|
1420
|
+
const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
|
|
1421
|
+
if (!r || r.status === 404) continue;
|
|
1422
1422
|
updated++;
|
|
1423
1423
|
}
|
|
1424
1424
|
return updated;
|
|
@@ -1444,7 +1444,7 @@ var HindsightClient = class {
|
|
|
1444
1444
|
let pageId = args.relatesToPageId;
|
|
1445
1445
|
if (!pageId) {
|
|
1446
1446
|
const folderId = await this.ensureFolder("Initiatives");
|
|
1447
|
-
const r = await this.
|
|
1447
|
+
const r = await this.pagesReq("POST", "", {
|
|
1448
1448
|
name: args.title,
|
|
1449
1449
|
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),
|
|
1450
1450
|
parent_id: folderId,
|
|
@@ -1453,8 +1453,8 @@ var HindsightClient = class {
|
|
|
1453
1453
|
trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
|
|
1454
1454
|
});
|
|
1455
1455
|
try {
|
|
1456
|
-
const j = await r
|
|
1457
|
-
pageId = j
|
|
1456
|
+
const j = await r?.json();
|
|
1457
|
+
pageId = j?.page_id ?? j?.id;
|
|
1458
1458
|
} catch {
|
|
1459
1459
|
}
|
|
1460
1460
|
pageId ||= `initiative-${this.slugify(args.title)}`;
|
|
@@ -1472,16 +1472,17 @@ var HindsightClient = class {
|
|
|
1472
1472
|
/** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
|
|
1473
1473
|
async ensureFolder(name) {
|
|
1474
1474
|
try {
|
|
1475
|
-
const
|
|
1476
|
-
const
|
|
1475
|
+
const r = await this.pagesReq("GET", "/tree");
|
|
1476
|
+
const tree = await r?.json();
|
|
1477
|
+
const hit = (tree?.roots || []).find(
|
|
1477
1478
|
(n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
|
|
1478
1479
|
);
|
|
1479
1480
|
if (hit?.id) return hit.id;
|
|
1480
1481
|
} catch {
|
|
1481
1482
|
}
|
|
1482
1483
|
try {
|
|
1483
|
-
const r = await this.
|
|
1484
|
-
return (await r
|
|
1484
|
+
const r = await this.pagesReq("POST", "/folders", { name });
|
|
1485
|
+
return (await r?.json())?.id;
|
|
1485
1486
|
} catch {
|
|
1486
1487
|
return void 0;
|
|
1487
1488
|
}
|
|
@@ -1879,6 +1880,41 @@ function resolvePartial(cfg, patch) {
|
|
|
1879
1880
|
return out;
|
|
1880
1881
|
}
|
|
1881
1882
|
|
|
1883
|
+
// src/core/transcript-util.ts
|
|
1884
|
+
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;
|
|
1885
|
+
function stripInjectedMemory(s) {
|
|
1886
|
+
return s.replace(MEMORY_TAG_RE, "");
|
|
1887
|
+
}
|
|
1888
|
+
var TARGET_KEYS = [
|
|
1889
|
+
"file_path",
|
|
1890
|
+
"path",
|
|
1891
|
+
"notebook_path",
|
|
1892
|
+
"command",
|
|
1893
|
+
"pattern",
|
|
1894
|
+
"query",
|
|
1895
|
+
"url",
|
|
1896
|
+
"name",
|
|
1897
|
+
"id"
|
|
1898
|
+
];
|
|
1899
|
+
var ACTION_TARGET_CAP = 100;
|
|
1900
|
+
function actionLine(tool, input) {
|
|
1901
|
+
let target = "";
|
|
1902
|
+
if (input && typeof input === "object") {
|
|
1903
|
+
const rec = input;
|
|
1904
|
+
for (const k of TARGET_KEYS) {
|
|
1905
|
+
const v = rec[k];
|
|
1906
|
+
if (typeof v === "string" && v.trim()) {
|
|
1907
|
+
target = v.trim().split("\n")[0];
|
|
1908
|
+
break;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
} else if (typeof input === "string") {
|
|
1912
|
+
target = input.trim().split("\n")[0];
|
|
1913
|
+
}
|
|
1914
|
+
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
1915
|
+
return target ? `${tool} ${target}` : tool;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1882
1918
|
// src/core/session-cache.ts
|
|
1883
1919
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, rmSync, writeFileSync } from "fs";
|
|
1884
1920
|
import { tmpdir } from "os";
|
|
@@ -1958,43 +1994,6 @@ function fileCursorStore(harness) {
|
|
|
1958
1994
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
|
|
1959
1995
|
import { tmpdir as tmpdir2 } from "os";
|
|
1960
1996
|
import { dirname as dirname6, join as join9 } from "path";
|
|
1961
|
-
|
|
1962
|
-
// src/core/transcript-util.ts
|
|
1963
|
-
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;
|
|
1964
|
-
function stripInjectedMemory(s) {
|
|
1965
|
-
return s.replace(MEMORY_TAG_RE, "");
|
|
1966
|
-
}
|
|
1967
|
-
var TARGET_KEYS = [
|
|
1968
|
-
"file_path",
|
|
1969
|
-
"path",
|
|
1970
|
-
"notebook_path",
|
|
1971
|
-
"command",
|
|
1972
|
-
"pattern",
|
|
1973
|
-
"query",
|
|
1974
|
-
"url",
|
|
1975
|
-
"name",
|
|
1976
|
-
"id"
|
|
1977
|
-
];
|
|
1978
|
-
var ACTION_TARGET_CAP = 100;
|
|
1979
|
-
function actionLine(tool, input) {
|
|
1980
|
-
let target = "";
|
|
1981
|
-
if (input && typeof input === "object") {
|
|
1982
|
-
const rec = input;
|
|
1983
|
-
for (const k of TARGET_KEYS) {
|
|
1984
|
-
const v = rec[k];
|
|
1985
|
-
if (typeof v === "string" && v.trim()) {
|
|
1986
|
-
target = v.trim().split("\n")[0];
|
|
1987
|
-
break;
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
} else if (typeof input === "string") {
|
|
1991
|
-
target = input.trim().split("\n")[0];
|
|
1992
|
-
}
|
|
1993
|
-
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
1994
|
-
return target ? `${tool} ${target}` : tool;
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
// src/core/turn-journal.ts
|
|
1998
1997
|
var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
|
|
1999
1998
|
function journalPath(harness, sessionId) {
|
|
2000
1999
|
return join9(tmpdir2(), `hindsight-${harness}`, `${sessionId || "no-session"}.journal.jsonl`);
|