@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/mcp-server.js
CHANGED
|
@@ -31809,14 +31809,14 @@ var RETAIN_STRATEGIES = {
|
|
|
31809
31809
|
retain_chunk_size: 12e3
|
|
31810
31810
|
}
|
|
31811
31811
|
};
|
|
31812
|
-
var
|
|
31812
|
+
var PAGE_LABELS = {
|
|
31813
31813
|
key: "knowledge",
|
|
31814
31814
|
type: "multi-values",
|
|
31815
31815
|
// 0, 1, or several — empty is normal
|
|
31816
31816
|
optional: true,
|
|
31817
31817
|
tag: true,
|
|
31818
31818
|
// emits knowledge:<value> onto the fact's tags
|
|
31819
|
-
description: "Routing labels for this project's Hindsight
|
|
31819
|
+
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.",
|
|
31820
31820
|
values: [
|
|
31821
31821
|
{
|
|
31822
31822
|
value: "feature-work",
|
|
@@ -31973,7 +31973,7 @@ var CODING_BANK_TEMPLATE = {
|
|
|
31973
31973
|
retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
|
|
31974
31974
|
retain_default_strategy: "git",
|
|
31975
31975
|
retain_strategies: RETAIN_STRATEGIES,
|
|
31976
|
-
entity_labels: [
|
|
31976
|
+
entity_labels: [PAGE_LABELS],
|
|
31977
31977
|
entities_allow_free_form: true
|
|
31978
31978
|
}
|
|
31979
31979
|
};
|
|
@@ -32025,7 +32025,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
32025
32025
|
}
|
|
32026
32026
|
|
|
32027
32027
|
// package.json
|
|
32028
|
-
var version2 = "0.8.
|
|
32028
|
+
var version2 = "0.8.7";
|
|
32029
32029
|
|
|
32030
32030
|
// src/core/util.ts
|
|
32031
32031
|
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
@@ -32085,11 +32085,11 @@ function retryAfterMs(header) {
|
|
|
32085
32085
|
const at = Date.parse(header);
|
|
32086
32086
|
return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
|
|
32087
32087
|
}
|
|
32088
|
-
var
|
|
32089
|
-
code = "
|
|
32088
|
+
var PagesUnavailableError = class extends Error {
|
|
32089
|
+
code = "pages_unavailable";
|
|
32090
32090
|
constructor() {
|
|
32091
|
-
super("Hindsight server does not support
|
|
32092
|
-
this.name = "
|
|
32091
|
+
super("Hindsight server does not support pages");
|
|
32092
|
+
this.name = "PagesUnavailableError";
|
|
32093
32093
|
}
|
|
32094
32094
|
};
|
|
32095
32095
|
async function isEndpointMissing(r) {
|
|
@@ -32100,6 +32100,10 @@ async function isEndpointMissing(r) {
|
|
|
32100
32100
|
return false;
|
|
32101
32101
|
}
|
|
32102
32102
|
}
|
|
32103
|
+
function pagesPath(sub, legacy = false) {
|
|
32104
|
+
if (!legacy) return `/pages${sub}`;
|
|
32105
|
+
return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
|
|
32106
|
+
}
|
|
32103
32107
|
var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
|
|
32104
32108
|
var ReflectError = class extends Error {
|
|
32105
32109
|
constructor(message, status, timedOut, options) {
|
|
@@ -32168,7 +32172,7 @@ var HindsightClient = class {
|
|
|
32168
32172
|
opIds = [];
|
|
32169
32173
|
// async operation ids collected by retain(), for drain()
|
|
32170
32174
|
/** Tri-state capability probe: unknown until the first page request, then cached. */
|
|
32171
|
-
|
|
32175
|
+
pagesSupported;
|
|
32172
32176
|
/** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
|
|
32173
32177
|
idempotentRetain;
|
|
32174
32178
|
log;
|
|
@@ -32397,7 +32401,7 @@ var HindsightClient = class {
|
|
|
32397
32401
|
return (j.total ?? j.items?.length ?? 0) > 0;
|
|
32398
32402
|
}
|
|
32399
32403
|
/** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
|
|
32400
|
-
* entity labels), then seed
|
|
32404
|
+
* entity labels), then seed pages when the server supports them. Both halves are
|
|
32401
32405
|
* idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
|
|
32402
32406
|
* extraction mode of the plugin's own strategies, which follows its config (#4560) — so
|
|
32403
32407
|
* the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
|
|
@@ -32579,29 +32583,45 @@ var HindsightClient = class {
|
|
|
32579
32583
|
const j = await r.json();
|
|
32580
32584
|
return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
|
|
32581
32585
|
}
|
|
32586
|
+
/** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
|
|
32587
|
+
* page routes moved to `/pages/...`. Remove in 2.x. */
|
|
32588
|
+
legacyPagesPaths = false;
|
|
32582
32589
|
/**
|
|
32583
|
-
*
|
|
32584
|
-
*
|
|
32585
|
-
*
|
|
32590
|
+
* Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
|
|
32591
|
+
*
|
|
32592
|
+
* Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
|
|
32593
|
+
* unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
|
|
32594
|
+
* older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
|
|
32595
|
+
* a capability verdict — it is the expected answer before the bank's first retain — so it is
|
|
32596
|
+
* returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
|
|
32586
32597
|
*
|
|
32587
32598
|
* Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
|
|
32588
32599
|
* the 405/501 this used to check for never reach a caller in the first place.
|
|
32589
32600
|
*/
|
|
32590
|
-
async
|
|
32591
|
-
|
|
32592
|
-
|
|
32593
|
-
return
|
|
32601
|
+
async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
|
|
32602
|
+
const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
|
|
32603
|
+
let r = await send(this.legacyPagesPaths);
|
|
32604
|
+
if (r.status !== 404 || !await isEndpointMissing(r)) return r;
|
|
32605
|
+
if (!this.legacyPagesPaths) {
|
|
32606
|
+
r = await send(true);
|
|
32607
|
+
if (r.status !== 404 || !await isEndpointMissing(r)) {
|
|
32608
|
+
this.legacyPagesPaths = true;
|
|
32609
|
+
return r;
|
|
32610
|
+
}
|
|
32611
|
+
}
|
|
32612
|
+
this.pagesSupported = false;
|
|
32613
|
+
return null;
|
|
32594
32614
|
}
|
|
32595
32615
|
/**
|
|
32596
|
-
* The bank's
|
|
32616
|
+
* The bank's page tree (folders + pages, nested). The tree carries names, source
|
|
32597
32617
|
* queries and staleness but NOT synthesized content, so it is cheap enough to poll.
|
|
32598
32618
|
*/
|
|
32599
32619
|
async tree() {
|
|
32600
|
-
if (this.
|
|
32601
|
-
const r = await this.
|
|
32602
|
-
if (
|
|
32620
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
32621
|
+
const r = await this.pagesReq("GET", "/tree");
|
|
32622
|
+
if (!r) throw new PagesUnavailableError();
|
|
32603
32623
|
if (r.status === 404) return [];
|
|
32604
|
-
this.
|
|
32624
|
+
this.pagesSupported = true;
|
|
32605
32625
|
try {
|
|
32606
32626
|
return (await r.json()).roots ?? [];
|
|
32607
32627
|
} catch {
|
|
@@ -32609,13 +32629,13 @@ var HindsightClient = class {
|
|
|
32609
32629
|
}
|
|
32610
32630
|
}
|
|
32611
32631
|
/**
|
|
32612
|
-
* List
|
|
32632
|
+
* List pages (ids + names only — no synthesized content), flattened out of the tree
|
|
32613
32633
|
* and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
|
|
32614
32634
|
* to read, and a caller enumerating pages wants leaves, not structure.
|
|
32615
32635
|
*
|
|
32616
|
-
* NOTE the ids are
|
|
32617
|
-
* page read/update in this client goes through the same
|
|
32618
|
-
* here, from `
|
|
32636
|
+
* NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
|
|
32637
|
+
* page read/update in this client goes through the same page ids, so a page id from
|
|
32638
|
+
* here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
|
|
32619
32639
|
*/
|
|
32620
32640
|
async listPages() {
|
|
32621
32641
|
const items = [];
|
|
@@ -32637,34 +32657,26 @@ var HindsightClient = class {
|
|
|
32637
32657
|
return { items };
|
|
32638
32658
|
}
|
|
32639
32659
|
/**
|
|
32640
|
-
* Read one
|
|
32660
|
+
* Read one page's synthesized content by page id, shaped by `shapePage` so
|
|
32641
32661
|
* the body arrives once. The endpoint omits the internal reflect trace that built
|
|
32642
32662
|
* the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
|
|
32643
32663
|
* token cap.
|
|
32644
32664
|
*/
|
|
32645
32665
|
async getPage(pageId) {
|
|
32646
|
-
if (this.
|
|
32647
|
-
const r = await this.
|
|
32648
|
-
|
|
32649
|
-
|
|
32650
|
-
);
|
|
32651
|
-
if (r.status === 404) throw new Error(`knowledge page not found: ${pageId}`);
|
|
32666
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
32667
|
+
const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
|
|
32668
|
+
if (!r) throw new PagesUnavailableError();
|
|
32669
|
+
if (r.status === 404) throw new Error(`page not found: ${pageId}`);
|
|
32652
32670
|
return shapePage(await r.json());
|
|
32653
32671
|
}
|
|
32654
|
-
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's
|
|
32672
|
+
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
|
|
32655
32673
|
* Returns page-level hits with a relevance snippet — the real search behind
|
|
32656
|
-
*
|
|
32657
|
-
async
|
|
32658
|
-
if (this.
|
|
32674
|
+
* hindsight_search_pages. */
|
|
32675
|
+
async searchPages(query, opts = {}) {
|
|
32676
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
32659
32677
|
const q = `?q=${encodeURIComponent(query)}&limit=${opts.limit ?? this.pageSearchLimit}`;
|
|
32660
|
-
const r = await this.
|
|
32661
|
-
|
|
32662
|
-
this.bankUrl(`/knowledge-base/search${q}`),
|
|
32663
|
-
void 0,
|
|
32664
|
-
[],
|
|
32665
|
-
opts.timeoutMs
|
|
32666
|
-
);
|
|
32667
|
-
if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
|
|
32678
|
+
const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
|
|
32679
|
+
if (!r) throw new PagesUnavailableError();
|
|
32668
32680
|
if (r.status === 404) return [];
|
|
32669
32681
|
const j = await r.json();
|
|
32670
32682
|
return (j.results ?? []).map((x) => ({
|
|
@@ -32676,9 +32688,9 @@ var HindsightClient = class {
|
|
|
32676
32688
|
}));
|
|
32677
32689
|
}
|
|
32678
32690
|
/**
|
|
32679
|
-
* Seed the fixed page taxonomy as
|
|
32691
|
+
* Seed the fixed page taxonomy as pages at the tree root, idempotently.
|
|
32680
32692
|
*
|
|
32681
|
-
* Matched by NAME, not id:
|
|
32693
|
+
* Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
|
|
32682
32694
|
* client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
|
|
32683
32695
|
* off a slug). Names are unique per folder server-side, which makes them a sound key.
|
|
32684
32696
|
*
|
|
@@ -32693,8 +32705,8 @@ var HindsightClient = class {
|
|
|
32693
32705
|
try {
|
|
32694
32706
|
roots = await this.tree();
|
|
32695
32707
|
} catch (e) {
|
|
32696
|
-
if (e instanceof
|
|
32697
|
-
this.log(`[bank]
|
|
32708
|
+
if (e instanceof PagesUnavailableError) {
|
|
32709
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
32698
32710
|
return;
|
|
32699
32711
|
}
|
|
32700
32712
|
throw e;
|
|
@@ -32717,11 +32729,9 @@ var HindsightClient = class {
|
|
|
32717
32729
|
trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
|
|
32718
32730
|
};
|
|
32719
32731
|
if (!hit) {
|
|
32720
|
-
const r = await this.
|
|
32721
|
-
if (
|
|
32722
|
-
this.log(
|
|
32723
|
-
`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
|
|
32724
|
-
);
|
|
32732
|
+
const r = await this.pagesReq("POST", "", body, [409]);
|
|
32733
|
+
if (!r) {
|
|
32734
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
32725
32735
|
return;
|
|
32726
32736
|
}
|
|
32727
32737
|
if (r.status === 404) {
|
|
@@ -32742,15 +32752,9 @@ var HindsightClient = class {
|
|
|
32742
32752
|
);
|
|
32743
32753
|
}
|
|
32744
32754
|
if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
|
|
32745
|
-
const r = await this.
|
|
32746
|
-
|
|
32747
|
-
this.
|
|
32748
|
-
patch
|
|
32749
|
-
);
|
|
32750
|
-
if (await this.pagesUnsupported(r)) {
|
|
32751
|
-
this.log(
|
|
32752
|
-
`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
|
|
32753
|
-
);
|
|
32755
|
+
const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
|
|
32756
|
+
if (!r) {
|
|
32757
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
32754
32758
|
return;
|
|
32755
32759
|
}
|
|
32756
32760
|
if (r.status === 404) {
|
|
@@ -32762,7 +32766,7 @@ var HindsightClient = class {
|
|
|
32762
32766
|
}
|
|
32763
32767
|
const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
|
|
32764
32768
|
this.log(
|
|
32765
|
-
`[bank]
|
|
32769
|
+
`[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` : "")
|
|
32766
32770
|
);
|
|
32767
32771
|
}
|
|
32768
32772
|
/**
|
|
@@ -32796,12 +32800,8 @@ var HindsightClient = class {
|
|
|
32796
32800
|
if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
|
|
32797
32801
|
}
|
|
32798
32802
|
if (!patch.trigger && !patch.source_query) continue;
|
|
32799
|
-
const r = await this.
|
|
32800
|
-
|
|
32801
|
-
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
|
|
32802
|
-
patch
|
|
32803
|
-
);
|
|
32804
|
-
if (r.status === 404) continue;
|
|
32803
|
+
const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
|
|
32804
|
+
if (!r || r.status === 404) continue;
|
|
32805
32805
|
updated++;
|
|
32806
32806
|
}
|
|
32807
32807
|
return updated;
|
|
@@ -32827,7 +32827,7 @@ var HindsightClient = class {
|
|
|
32827
32827
|
let pageId = args.relatesToPageId;
|
|
32828
32828
|
if (!pageId) {
|
|
32829
32829
|
const folderId = await this.ensureFolder("Initiatives");
|
|
32830
|
-
const r = await this.
|
|
32830
|
+
const r = await this.pagesReq("POST", "", {
|
|
32831
32831
|
name: args.title,
|
|
32832
32832
|
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),
|
|
32833
32833
|
parent_id: folderId,
|
|
@@ -32836,8 +32836,8 @@ var HindsightClient = class {
|
|
|
32836
32836
|
trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
|
|
32837
32837
|
});
|
|
32838
32838
|
try {
|
|
32839
|
-
const j = await r
|
|
32840
|
-
pageId = j
|
|
32839
|
+
const j = await r?.json();
|
|
32840
|
+
pageId = j?.page_id ?? j?.id;
|
|
32841
32841
|
} catch {
|
|
32842
32842
|
}
|
|
32843
32843
|
pageId ||= `initiative-${this.slugify(args.title)}`;
|
|
@@ -32855,16 +32855,17 @@ var HindsightClient = class {
|
|
|
32855
32855
|
/** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
|
|
32856
32856
|
async ensureFolder(name) {
|
|
32857
32857
|
try {
|
|
32858
|
-
const
|
|
32859
|
-
const
|
|
32858
|
+
const r = await this.pagesReq("GET", "/tree");
|
|
32859
|
+
const tree = await r?.json();
|
|
32860
|
+
const hit = (tree?.roots || []).find(
|
|
32860
32861
|
(n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
|
|
32861
32862
|
);
|
|
32862
32863
|
if (hit?.id) return hit.id;
|
|
32863
32864
|
} catch {
|
|
32864
32865
|
}
|
|
32865
32866
|
try {
|
|
32866
|
-
const r = await this.
|
|
32867
|
-
return (await r
|
|
32867
|
+
const r = await this.pagesReq("POST", "/folders", { name });
|
|
32868
|
+
return (await r?.json())?.id;
|
|
32868
32869
|
} catch {
|
|
32869
32870
|
return void 0;
|
|
32870
32871
|
}
|
|
@@ -33301,7 +33302,7 @@ function resolveHostMemory(harness, directory) {
|
|
|
33301
33302
|
};
|
|
33302
33303
|
}
|
|
33303
33304
|
|
|
33304
|
-
// src/core/
|
|
33305
|
+
// src/core/page-tools.ts
|
|
33305
33306
|
import { createHash as createHash4 } from "crypto";
|
|
33306
33307
|
import { existsSync as existsSync3 } from "fs";
|
|
33307
33308
|
import { homedir as homedir5 } from "os";
|
|
@@ -33348,7 +33349,7 @@ function commitsSince(dir, sinceSha) {
|
|
|
33348
33349
|
}
|
|
33349
33350
|
}
|
|
33350
33351
|
|
|
33351
|
-
// src/core/
|
|
33352
|
+
// src/core/page-injection.ts
|
|
33352
33353
|
function parsePageList(raw) {
|
|
33353
33354
|
const items = raw?.items;
|
|
33354
33355
|
if (!Array.isArray(items)) return [];
|
|
@@ -33455,11 +33456,11 @@ async function syncStatus(client, bank, repoDir) {
|
|
|
33455
33456
|
activeOps,
|
|
33456
33457
|
// Older Hindsight servers have no page surface. They are still fully usable for the
|
|
33457
33458
|
// legacy bank/retain pipeline, so page absence must not make syncStatus permanently false.
|
|
33458
|
-
synced: gitlogPresent && (client.
|
|
33459
|
+
synced: gitlogPresent && (client.pagesSupported === false || pages.length > 0) && (activeOps ?? 0) === 0
|
|
33459
33460
|
};
|
|
33460
33461
|
}
|
|
33461
33462
|
|
|
33462
|
-
// src/core/
|
|
33463
|
+
// src/core/page-tools.ts
|
|
33463
33464
|
var READ_ONLY_ANNOTATIONS = {
|
|
33464
33465
|
readOnlyHint: true,
|
|
33465
33466
|
destructiveHint: false,
|
|
@@ -33489,13 +33490,13 @@ function guarded(fn) {
|
|
|
33489
33490
|
}
|
|
33490
33491
|
};
|
|
33491
33492
|
}
|
|
33492
|
-
function
|
|
33493
|
+
function buildPageTools(client, bankId, opts = {}) {
|
|
33493
33494
|
const extra = opts.toolGuideExtra?.trim();
|
|
33494
33495
|
const crediting = extra ? `${CREDIT_REMINDER} ${extra}` : CREDIT_REMINDER;
|
|
33495
33496
|
return [
|
|
33496
33497
|
{
|
|
33497
33498
|
name: "hindsight_sync_status",
|
|
33498
|
-
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,
|
|
33499
|
+
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.",
|
|
33499
33500
|
inputSchema: {},
|
|
33500
33501
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
33501
33502
|
handler: async () => {
|
|
@@ -33550,13 +33551,13 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
33550
33551
|
}
|
|
33551
33552
|
},
|
|
33552
33553
|
{
|
|
33553
|
-
name: "
|
|
33554
|
-
description: "Search this repository's Hindsight
|
|
33554
|
+
name: "hindsight_search_pages",
|
|
33555
|
+
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,
|
|
33555
33556
|
inputSchema: { query: external_exports.string().describe("what to look for") },
|
|
33556
33557
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
33557
33558
|
handler: async (args) => {
|
|
33558
33559
|
try {
|
|
33559
|
-
const hits = await client.
|
|
33560
|
+
const hits = await client.searchPages(args.query);
|
|
33560
33561
|
return ok({
|
|
33561
33562
|
pages: hits.map((h) => ({
|
|
33562
33563
|
page: h.name,
|
|
@@ -33574,22 +33575,22 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
33574
33575
|
}
|
|
33575
33576
|
},
|
|
33576
33577
|
{
|
|
33577
|
-
name: "
|
|
33578
|
-
description: "List this repository's Hindsight
|
|
33578
|
+
name: "hindsight_list_pages",
|
|
33579
|
+
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.",
|
|
33579
33580
|
inputSchema: {},
|
|
33580
33581
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
33581
33582
|
handler: guarded(async () => client.listPages())
|
|
33582
33583
|
},
|
|
33583
33584
|
{
|
|
33584
|
-
name: "
|
|
33585
|
-
description: "Read the full content of one
|
|
33585
|
+
name: "hindsight_read_page",
|
|
33586
|
+
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.",
|
|
33586
33587
|
inputSchema: { page_id: external_exports.string() },
|
|
33587
33588
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
33588
33589
|
handler: guarded(async ({ page_id }) => client.getPage(page_id))
|
|
33589
33590
|
},
|
|
33590
33591
|
{
|
|
33591
33592
|
name: "hindsight_reflect",
|
|
33592
|
-
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
|
|
33593
|
+
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>".`,
|
|
33593
33594
|
inputSchema: { query: external_exports.string().describe("the question to reason over memory about") },
|
|
33594
33595
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
33595
33596
|
handler: guarded(
|
|
@@ -33601,7 +33602,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
33601
33602
|
},
|
|
33602
33603
|
{
|
|
33603
33604
|
name: "hindsight_capture_initiative",
|
|
33604
|
-
description: "Record a new feature or initiative as a tracked
|
|
33605
|
+
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.",
|
|
33605
33606
|
inputSchema: {
|
|
33606
33607
|
title: external_exports.string(),
|
|
33607
33608
|
summary: external_exports.string(),
|
|
@@ -33704,7 +33705,7 @@ function buildRetainStamp(cfg, ctx) {
|
|
|
33704
33705
|
function selectTools(cfg, client, bankId, opts = {}) {
|
|
33705
33706
|
const cwd = opts.cwd ?? process.cwd();
|
|
33706
33707
|
const harness = opts.harness ?? cfg.harness;
|
|
33707
|
-
return cfg.disabled ? [] :
|
|
33708
|
+
return cfg.disabled ? [] : buildPageTools(client, bankId, {
|
|
33708
33709
|
repoDir: cwd,
|
|
33709
33710
|
harness,
|
|
33710
33711
|
pageTrigger: buildPageTrigger(cfg),
|