@vectorize-io/hindsight-coding-agents 0.8.6 → 0.8.8
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 +31 -21
- package/dist/antigravity-hook.js +278 -190
- package/dist/antigravity-statusline.js +30 -24
- package/dist/antigravity-stop-hook.js +271 -169
- package/dist/claude-hook.js +278 -190
- package/dist/claude-sessionstart-hook.js +301 -212
- package/dist/claude-stop-hook.js +271 -169
- package/dist/cline.js +258 -214
- package/dist/codebuddy-hook.js +278 -190
- package/dist/codebuddy-sessionstart-hook.js +301 -212
- package/dist/codebuddy-stop-hook.js +271 -169
- package/dist/codex-hook.js +278 -190
- package/dist/codex-sessionstart-hook.js +301 -212
- package/dist/codex-stop-hook.js +271 -169
- package/dist/copilot-hook.js +278 -190
- package/dist/copilot-sessionstart-hook.js +301 -212
- package/dist/copilot-stop-hook.js +271 -169
- package/dist/cursor-hook.js +278 -190
- package/dist/cursor-sessionstart-hook.js +301 -212
- package/dist/cursor-stop-hook.js +271 -169
- package/dist/daemon-start.js +20 -16
- package/dist/dcode-hook.js +278 -190
- package/dist/dcode-sessionstart-hook.js +301 -212
- package/dist/dcode-stop-hook.js +271 -169
- package/dist/deepen.js +98 -83
- package/dist/devin-hook.js +278 -190
- package/dist/devin-sessionstart-hook.js +301 -212
- package/dist/devin-stop-hook.js +271 -169
- package/dist/droid-hook.js +278 -190
- package/dist/droid-sessionstart-hook.js +301 -212
- package/dist/droid-stop-hook.js +271 -169
- package/dist/dsh.js +309 -251
- package/dist/grok-hook.js +278 -190
- package/dist/grok-sessionstart-hook.js +301 -212
- package/dist/grok-stop-hook.js +271 -169
- package/dist/hindsight-seed.js +35 -26
- package/dist/index.js +310 -252
- package/dist/installer.js +172 -68
- package/dist/kilo.js +310 -252
- package/dist/kimi-hook.js +278 -190
- package/dist/kimi-sessionstart-hook.js +301 -212
- package/dist/kimi-stop-hook.js +271 -169
- package/dist/mcp-server.js +165 -148
- package/dist/opencode2.js +310 -252
- package/dist/pi.js +309 -251
- package/dist/prime-agent.js +309 -251
- package/dist/qwen-hook.js +278 -190
- package/dist/qwen-sessionstart-hook.js +301 -212
- package/dist/qwen-stop-hook.js +271 -169
- package/dist/status.js +134 -117
- package/dist/traecode-hook.js +278 -190
- package/dist/traecode-sessionstart-hook.js +301 -212
- package/dist/traecode-stop-hook.js +271 -169
- package/dist/workbuddy-hook.js +278 -190
- package/dist/workbuddy-sessionstart-hook.js +301 -212
- package/dist/workbuddy-stop-hook.js +271 -169
- package/dist/zcode-hook.js +278 -190
- package/dist/zcode-sessionstart-hook.js +301 -212
- package/dist/zcode-stop-hook.js +271 -169
- package/package.json +2 -1
- package/plugin.json +1 -1
- package/skill/SKILL.md +31 -26
package/dist/mcp-server.js
CHANGED
|
@@ -31413,31 +31413,66 @@ import { join as join7 } from "path";
|
|
|
31413
31413
|
|
|
31414
31414
|
// src/core/seed.ts
|
|
31415
31415
|
import { spawn as realSpawn } from "child_process";
|
|
31416
|
-
import { dirname, join } from "path";
|
|
31416
|
+
import { dirname, join as join2 } from "path";
|
|
31417
31417
|
import { fileURLToPath } from "url";
|
|
31418
|
+
|
|
31419
|
+
// src/core/util.ts
|
|
31420
|
+
import { accessSync, constants, statSync } from "fs";
|
|
31421
|
+
import { delimiter, extname, isAbsolute, join, resolve } from "path";
|
|
31422
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
31423
|
+
function semverGte(version3, min) {
|
|
31424
|
+
const parts = (v) => {
|
|
31425
|
+
const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
|
|
31426
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
|
|
31427
|
+
};
|
|
31428
|
+
const a = version3 ? parts(version3) : void 0;
|
|
31429
|
+
const b = parts(min);
|
|
31430
|
+
if (!a || !b) return false;
|
|
31431
|
+
for (let i = 0; i < 3; i++) {
|
|
31432
|
+
if (a[i] !== b[i]) return a[i] > b[i];
|
|
31433
|
+
}
|
|
31434
|
+
return true;
|
|
31435
|
+
}
|
|
31436
|
+
async function pool(items, n, fn, onError, onProgress) {
|
|
31437
|
+
let i = 0, done = 0;
|
|
31438
|
+
async function worker() {
|
|
31439
|
+
while (i < items.length) {
|
|
31440
|
+
const idx = i++;
|
|
31441
|
+
try {
|
|
31442
|
+
await fn(items[idx], idx);
|
|
31443
|
+
} catch (e) {
|
|
31444
|
+
onError?.(idx, e);
|
|
31445
|
+
}
|
|
31446
|
+
onProgress?.(++done, items.length);
|
|
31447
|
+
}
|
|
31448
|
+
}
|
|
31449
|
+
await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
|
|
31450
|
+
}
|
|
31451
|
+
|
|
31452
|
+
// src/core/seed.ts
|
|
31418
31453
|
var DEFAULT_SEED_LIMIT = 300;
|
|
31419
31454
|
|
|
31420
31455
|
// src/core/bank.ts
|
|
31421
31456
|
import { existsSync } from "fs";
|
|
31422
31457
|
import { homedir as homedir2 } from "os";
|
|
31423
|
-
import { basename, dirname as dirname4, join as
|
|
31458
|
+
import { basename, dirname as dirname4, join as join6, normalize, sep } from "path";
|
|
31424
31459
|
|
|
31425
31460
|
// src/core/diag.ts
|
|
31426
31461
|
import { readFileSync } from "fs";
|
|
31427
|
-
import { join as
|
|
31462
|
+
import { join as join4 } from "path";
|
|
31428
31463
|
|
|
31429
31464
|
// src/core/log.ts
|
|
31430
|
-
import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
|
|
31465
|
+
import { appendFileSync, mkdirSync, renameSync, statSync as statSync2 } from "fs";
|
|
31431
31466
|
import { homedir } from "os";
|
|
31432
|
-
import { dirname as dirname2, join as
|
|
31467
|
+
import { dirname as dirname2, join as join3 } from "path";
|
|
31433
31468
|
function logsDir() {
|
|
31434
|
-
return
|
|
31469
|
+
return join3(homedir(), ".hindsight", "coding-agents-logs");
|
|
31435
31470
|
}
|
|
31436
31471
|
var LOG_MAX_BYTES = 10 * 1024 * 1024;
|
|
31437
31472
|
function appendLogLine(file2, text) {
|
|
31438
31473
|
mkdirSync(dirname2(file2), { recursive: true, mode: 448 });
|
|
31439
31474
|
try {
|
|
31440
|
-
if (
|
|
31475
|
+
if (statSync2(file2).size >= LOG_MAX_BYTES) renameSync(file2, `${file2}.1`);
|
|
31441
31476
|
} catch {
|
|
31442
31477
|
}
|
|
31443
31478
|
appendFileSync(file2, text, { mode: 384 });
|
|
@@ -31447,7 +31482,7 @@ var current = ["debug", "info", "warn", "error"].find(
|
|
|
31447
31482
|
(l) => l === process.env.HINDSIGHT_LOG_LEVEL
|
|
31448
31483
|
) ?? "info";
|
|
31449
31484
|
function logFilePath() {
|
|
31450
|
-
return process.env.HINDSIGHT_LOG_FILE ||
|
|
31485
|
+
return process.env.HINDSIGHT_LOG_FILE || join3(logsDir(), "plugin.log");
|
|
31451
31486
|
}
|
|
31452
31487
|
function write(level, scope, msg, extra) {
|
|
31453
31488
|
if (WEIGHT[level] < WEIGHT[current]) return;
|
|
@@ -31482,7 +31517,7 @@ function describeError(value, maxChars = 200) {
|
|
|
31482
31517
|
|
|
31483
31518
|
// src/core/diag.ts
|
|
31484
31519
|
function diagFilePath() {
|
|
31485
|
-
return process.env.HINDSIGHT_DIAG_FILE ||
|
|
31520
|
+
return process.env.HINDSIGHT_DIAG_FILE || join4(logsDir(), "diag.jsonl");
|
|
31486
31521
|
}
|
|
31487
31522
|
function diag(harness, event, extra = {}) {
|
|
31488
31523
|
log.debug(harness, `diag:${event}`, extra);
|
|
@@ -31497,7 +31532,7 @@ function diag(harness, event, extra = {}) {
|
|
|
31497
31532
|
|
|
31498
31533
|
// src/core/git-layout.ts
|
|
31499
31534
|
import { lstatSync, readFileSync as readFileSync2, realpathSync } from "fs";
|
|
31500
|
-
import { dirname as dirname3, isAbsolute, join as
|
|
31535
|
+
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "path";
|
|
31501
31536
|
var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
|
|
31502
31537
|
var ATTEMPTS = 3;
|
|
31503
31538
|
var BACKOFF_MS = 20;
|
|
@@ -31530,19 +31565,19 @@ function gitDirFromPointer(text, holder) {
|
|
|
31530
31565
|
const match = /^\s*gitdir:\s*(.+?)\s*$/m.exec(text);
|
|
31531
31566
|
if (!match) return null;
|
|
31532
31567
|
const target = match[1];
|
|
31533
|
-
return
|
|
31568
|
+
return isAbsolute2(target) ? target : resolve2(holder, target);
|
|
31534
31569
|
}
|
|
31535
31570
|
function commonDirOf(gitDir) {
|
|
31536
|
-
const pointer = entryKind(
|
|
31571
|
+
const pointer = entryKind(join5(gitDir, "commondir")) === "file" ? readTextOrNull(join5(gitDir, "commondir"))?.trim() : null;
|
|
31537
31572
|
if (!pointer) return gitDir;
|
|
31538
|
-
return
|
|
31573
|
+
return isAbsolute2(pointer) ? pointer : resolve2(gitDir, pointer);
|
|
31539
31574
|
}
|
|
31540
31575
|
function isBare(commonDir) {
|
|
31541
|
-
const config2 = readTextOrNull(
|
|
31576
|
+
const config2 = readTextOrNull(join5(commonDir, "config"));
|
|
31542
31577
|
return config2 !== null && /^\s*bare\s*=\s*true\s*$/im.test(config2);
|
|
31543
31578
|
}
|
|
31544
31579
|
function looksLikeBareRepository(directory) {
|
|
31545
|
-
return entryKind(
|
|
31580
|
+
return entryKind(join5(directory, "HEAD")) === "file" && entryKind(join5(directory, "objects")) === "dir" && entryKind(join5(directory, "refs")) === "dir";
|
|
31546
31581
|
}
|
|
31547
31582
|
function canonical(path) {
|
|
31548
31583
|
try {
|
|
@@ -31557,9 +31592,9 @@ function resolved(commonDir) {
|
|
|
31557
31592
|
return { status: "resolved", commonDir: canonicalDir, bare: isBare(canonicalDir) };
|
|
31558
31593
|
}
|
|
31559
31594
|
function probeOnce(directory) {
|
|
31560
|
-
let current2 =
|
|
31595
|
+
let current2 = resolve2(directory);
|
|
31561
31596
|
for (; ; ) {
|
|
31562
|
-
const dotGit =
|
|
31597
|
+
const dotGit = join5(current2, ".git");
|
|
31563
31598
|
const kind = entryKind(dotGit);
|
|
31564
31599
|
if (kind === "dir") {
|
|
31565
31600
|
const layout = resolved(commonDirOf(dotGit));
|
|
@@ -31673,10 +31708,14 @@ function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
|
|
|
31673
31708
|
return dirName(sessionRoot || directory);
|
|
31674
31709
|
}
|
|
31675
31710
|
function configuredDir(dir) {
|
|
31676
|
-
const expanded = dir === "~" || dir.startsWith("~/") ?
|
|
31711
|
+
const expanded = dir === "~" || dir.startsWith("~/") ? join6(homedir2(), dir.slice(1)) : dir;
|
|
31677
31712
|
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
31678
31713
|
}
|
|
31679
|
-
function isWithin(directory, configured) {
|
|
31714
|
+
function isWithin(directory, configured, platform = process.platform) {
|
|
31715
|
+
if (platform === "win32") {
|
|
31716
|
+
directory = directory.toLowerCase();
|
|
31717
|
+
configured = configured.toLowerCase();
|
|
31718
|
+
}
|
|
31680
31719
|
return directory === configured || directory.startsWith(configured + sep);
|
|
31681
31720
|
}
|
|
31682
31721
|
function mapLookup(map2, directory) {
|
|
@@ -31766,7 +31805,7 @@ function deriveBankIdOrSkip(config2, directory, harness = "coding", sessionRoot)
|
|
|
31766
31805
|
import { createHash } from "crypto";
|
|
31767
31806
|
var GIT_MISSION = "You are ingesting a single git commit: its message and its full diff. Extract the concrete technical DECISION and the CAUSE/INVARIANT it encodes, bound to the specific code entities (functions, methods, files) and behaviors it changes. Preserve exact identifiers, paths, and literal values verbatim. Preserve the 'REF-ID: <token>' marker verbatim in every fact. Capture both WHAT changed and WHY. Issue/PR references (#123, GH-123, PROJ-123) are load-bearing: keep them VERBATIM in the fact text and emit each as an ENTITY, so a later question about that issue or PR retrieves this decision.";
|
|
31768
31807
|
var GITLOG_MISSION = "You are ingesting an aggregated block of git commit MESSAGES ONLY (no diffs) \u2014 the project's recent commit-message history, oldest first. Extract the project's INITIATIVES, FEATURES, ENHANCEMENTS, and notable changes or THEMES over time \u2014 what the project has been working on and how it has evolved. Do NOT extract per-line code detail (there is no diff to draw it from). Group related commits into a coherent initiative/theme where the messages make that clear; preserve exact identifiers and literal values verbatim when quoting a subject line. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY \u2014 they are how future sessions will ask about this work.";
|
|
31769
|
-
var CONVERSATION_MISSION = `You are ingesting a developer conversation as a JSONL transcript (one {role, content} turn per line): the user's requests, the assistant's narration, and compact 'action' turns naming each tool use and its target (e.g. "Edit boltons/strutils.py") with no arguments or outputs. It may be a SHORT decision chat or a LONG working session \u2014 scale the facts to the substance, never to the message count. Extract the FEWEST facts that capture the OUTCOME: the settled DECISIONS and their exact rules/values (quote literals VERBATIM); concrete CHANGES to specific code entities; problems and how they were resolved; conventions or invariants established; at most one fact for a notable REJECTED alternative ('initially proposed X, changed to Y because Z'). A short decision chat usually yields 1-2 facts; a substantial working session several. CRITICAL: a conversation REVISES itself \u2014 record ONLY the FINAL state as what is in effect; a superseded proposal appears ONLY inside the rejected fact, NEVER as its own 'decided' fact; if the same setting changes several times keep only the LAST, and make unmistakably clear which choice WON. Do NOT emit one fact per message, per intermediate proposal, or per action turn. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY. Preserve the 'REF-ID: <token>' marker verbatim in every fact. Do not invent; capture only what was actually settled.`;
|
|
31808
|
+
var CONVERSATION_MISSION = `You are ingesting a developer conversation as a JSONL transcript (one {role, content} turn per line): the user's requests, the assistant's narration, and compact 'action' turns naming each tool use and its target (e.g. "Edit boltons/strutils.py") with no arguments or outputs. It may be a SHORT decision chat or a LONG working session \u2014 scale the facts to the substance, never to the message count. Extract the FEWEST facts that capture the OUTCOME: the settled DECISIONS and their exact rules/values (quote literals VERBATIM); concrete CHANGES to specific code entities; problems and how they were resolved; conventions or invariants established; at most one fact for a notable REJECTED alternative ('initially proposed X, changed to Y because Z'). A short decision chat usually yields 1-2 facts; a substantial working session several. CRITICAL: a conversation REVISES itself \u2014 record ONLY the FINAL state as what is in effect; a superseded proposal appears ONLY inside the rejected fact, NEVER as its own 'decided' fact; if the same setting changes several times keep only the LAST, and make unmistakably clear which choice WON. Do NOT emit one fact per message, per intermediate proposal, or per action turn. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY. Preserve the 'REF-ID: <token>' marker verbatim in every fact. When the session checked its work (a test passed or failed, a result was judged right or wrong), record the exact METHOD behind that outcome \u2014 which file, table, column, command or formula \u2014 and any caveat the session found in the data or code (a column mostly empty, a value in other units), so the same work repeats what worked and avoids what failed. Do not invent; capture only what was actually settled.`;
|
|
31770
31809
|
var REFLECT_MISSION = "You are a debugging assistant with the project's past decisions in memory (git rationale and developer chats). Given a bug's SYMPTOM, find the past decision whose rationale explains the ROOT CAUSE \u2014 not one that merely shares vocabulary. Answer with the PRECISE fix: state the EXACT rule and the LITERAL values, identifiers, strings, numbers, or set members that were decided \u2014 quote them VERBATIM, never paraphrase, generalize, or omit them (give the actual decided value, not 'the project standard'). If memories CONFLICT on the same rule, the LATEST decision wins \u2014 prefer facts that explicitly amend or supersede an earlier one, state the superseded rule as no longer in effect, and never present it as the fix. Name the function/file to change and cite the REF-ID(s). If NOTHING in memory genuinely explains THIS symptom, say exactly that in one short sentence \u2014 a wrong-but-confident nearest match is worse than an honest miss; never stretch an unrelated decision to fit.";
|
|
31771
31810
|
var DOCUMENT_MISSION = "You are ingesting a standalone document (notes, docs, or structural findings). Extract the concrete facts, concepts, and structure it describes.";
|
|
31772
31811
|
var OBSERVATIONS_MISSION = "Consolidate durable knowledge about THIS codebase \u2014 recurring patterns, conventions, module responsibilities, and how components relate \u2014 from the ingested commits and conversations. Favor stable structural understanding over one-off details. When a new fact contradicts or supersedes an existing observation, UPDATE that observation to reflect the current state rather than creating a sibling alongside it; note that the rule was revised and when, so the superseded version is visible as history rather than as a competing claim.";
|
|
@@ -31809,14 +31848,14 @@ var RETAIN_STRATEGIES = {
|
|
|
31809
31848
|
retain_chunk_size: 12e3
|
|
31810
31849
|
}
|
|
31811
31850
|
};
|
|
31812
|
-
var
|
|
31851
|
+
var PAGE_LABELS = {
|
|
31813
31852
|
key: "knowledge",
|
|
31814
31853
|
type: "multi-values",
|
|
31815
31854
|
// 0, 1, or several — empty is normal
|
|
31816
31855
|
optional: true,
|
|
31817
31856
|
tag: true,
|
|
31818
31857
|
// emits knowledge:<value> onto the fact's tags
|
|
31819
|
-
description: "Routing labels for this project's Hindsight
|
|
31858
|
+
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
31859
|
values: [
|
|
31821
31860
|
{
|
|
31822
31861
|
value: "feature-work",
|
|
@@ -31973,7 +32012,7 @@ var CODING_BANK_TEMPLATE = {
|
|
|
31973
32012
|
retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
|
|
31974
32013
|
retain_default_strategy: "git",
|
|
31975
32014
|
retain_strategies: RETAIN_STRATEGIES,
|
|
31976
|
-
entity_labels: [
|
|
32015
|
+
entity_labels: [PAGE_LABELS],
|
|
31977
32016
|
entities_allow_free_form: true
|
|
31978
32017
|
}
|
|
31979
32018
|
};
|
|
@@ -32025,40 +32064,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
32025
32064
|
}
|
|
32026
32065
|
|
|
32027
32066
|
// package.json
|
|
32028
|
-
var version2 = "0.8.
|
|
32029
|
-
|
|
32030
|
-
// src/core/util.ts
|
|
32031
|
-
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
32032
|
-
import { delimiter, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "path";
|
|
32033
|
-
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
32034
|
-
function semverGte(version3, min) {
|
|
32035
|
-
const parts = (v) => {
|
|
32036
|
-
const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
|
|
32037
|
-
return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
|
|
32038
|
-
};
|
|
32039
|
-
const a = version3 ? parts(version3) : void 0;
|
|
32040
|
-
const b = parts(min);
|
|
32041
|
-
if (!a || !b) return false;
|
|
32042
|
-
for (let i = 0; i < 3; i++) {
|
|
32043
|
-
if (a[i] !== b[i]) return a[i] > b[i];
|
|
32044
|
-
}
|
|
32045
|
-
return true;
|
|
32046
|
-
}
|
|
32047
|
-
async function pool(items, n, fn, onError, onProgress) {
|
|
32048
|
-
let i = 0, done = 0;
|
|
32049
|
-
async function worker() {
|
|
32050
|
-
while (i < items.length) {
|
|
32051
|
-
const idx = i++;
|
|
32052
|
-
try {
|
|
32053
|
-
await fn(items[idx], idx);
|
|
32054
|
-
} catch (e) {
|
|
32055
|
-
onError?.(idx, e);
|
|
32056
|
-
}
|
|
32057
|
-
onProgress?.(++done, items.length);
|
|
32058
|
-
}
|
|
32059
|
-
}
|
|
32060
|
-
await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
|
|
32061
|
-
}
|
|
32067
|
+
var version2 = "0.8.8";
|
|
32062
32068
|
|
|
32063
32069
|
// src/core/hindsight.ts
|
|
32064
32070
|
var USER_AGENT = `hindsight-coding-agents/${version2}`;
|
|
@@ -32085,11 +32091,11 @@ function retryAfterMs(header) {
|
|
|
32085
32091
|
const at = Date.parse(header);
|
|
32086
32092
|
return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
|
|
32087
32093
|
}
|
|
32088
|
-
var
|
|
32089
|
-
code = "
|
|
32094
|
+
var PagesUnavailableError = class extends Error {
|
|
32095
|
+
code = "pages_unavailable";
|
|
32090
32096
|
constructor() {
|
|
32091
|
-
super("Hindsight server does not support
|
|
32092
|
-
this.name = "
|
|
32097
|
+
super("Hindsight server does not support pages");
|
|
32098
|
+
this.name = "PagesUnavailableError";
|
|
32093
32099
|
}
|
|
32094
32100
|
};
|
|
32095
32101
|
async function isEndpointMissing(r) {
|
|
@@ -32100,6 +32106,10 @@ async function isEndpointMissing(r) {
|
|
|
32100
32106
|
return false;
|
|
32101
32107
|
}
|
|
32102
32108
|
}
|
|
32109
|
+
function pagesPath(sub, legacy = false) {
|
|
32110
|
+
if (!legacy) return `/pages${sub}`;
|
|
32111
|
+
return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
|
|
32112
|
+
}
|
|
32103
32113
|
var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
|
|
32104
32114
|
var ReflectError = class extends Error {
|
|
32105
32115
|
constructor(message, status, timedOut, options) {
|
|
@@ -32168,7 +32178,7 @@ var HindsightClient = class {
|
|
|
32168
32178
|
opIds = [];
|
|
32169
32179
|
// async operation ids collected by retain(), for drain()
|
|
32170
32180
|
/** Tri-state capability probe: unknown until the first page request, then cached. */
|
|
32171
|
-
|
|
32181
|
+
pagesSupported;
|
|
32172
32182
|
/** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
|
|
32173
32183
|
idempotentRetain;
|
|
32174
32184
|
log;
|
|
@@ -32266,7 +32276,9 @@ var HindsightClient = class {
|
|
|
32266
32276
|
}
|
|
32267
32277
|
if (!r.ok && r.status !== 404 && !tolerate.includes(r.status))
|
|
32268
32278
|
throw new Error(
|
|
32269
|
-
|
|
32279
|
+
// Query dropped: an encoded search query filled the 200-char error cap and pushed the
|
|
32280
|
+
// status and the server's reason out of the tool error (#6341).
|
|
32281
|
+
`${method} ${url2.split("?")[0]} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
|
|
32270
32282
|
);
|
|
32271
32283
|
return r;
|
|
32272
32284
|
}
|
|
@@ -32397,7 +32409,7 @@ var HindsightClient = class {
|
|
|
32397
32409
|
return (j.total ?? j.items?.length ?? 0) > 0;
|
|
32398
32410
|
}
|
|
32399
32411
|
/** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
|
|
32400
|
-
* entity labels), then seed
|
|
32412
|
+
* entity labels), then seed pages when the server supports them. Both halves are
|
|
32401
32413
|
* idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
|
|
32402
32414
|
* extraction mode of the plugin's own strategies, which follows its config (#4560) — so
|
|
32403
32415
|
* the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
|
|
@@ -32412,6 +32424,15 @@ var HindsightClient = class {
|
|
|
32412
32424
|
await this.req("DELETE", this.bankUrl());
|
|
32413
32425
|
this.log(`[bank] reset ${this.bank}`);
|
|
32414
32426
|
}
|
|
32427
|
+
await this.configureBankSettings(opts);
|
|
32428
|
+
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
32429
|
+
}
|
|
32430
|
+
/** The config half of `configureBank` (missions, retain strategies, entity labels), without
|
|
32431
|
+
* seeding pages. Session start calls it directly when the deepen engine — the usual caller of
|
|
32432
|
+
* `configureBank` — will not run (`autoSeed: false`, or a directory with no git history):
|
|
32433
|
+
* without it such a bank never got the `conversation` strategy, and every session write-back
|
|
32434
|
+
* was extracted with the server's generic rules instead of the plugin's mission. */
|
|
32435
|
+
async configureBankSettings(opts = {}) {
|
|
32415
32436
|
if (opts.manage === false) {
|
|
32416
32437
|
this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
|
|
32417
32438
|
} else {
|
|
@@ -32427,7 +32448,6 @@ var HindsightClient = class {
|
|
|
32427
32448
|
this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
|
|
32428
32449
|
}
|
|
32429
32450
|
}
|
|
32430
|
-
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
32431
32451
|
}
|
|
32432
32452
|
/**
|
|
32433
32453
|
* This bank's own config OVERRIDES, or undefined when there are none to read.
|
|
@@ -32579,29 +32599,45 @@ var HindsightClient = class {
|
|
|
32579
32599
|
const j = await r.json();
|
|
32580
32600
|
return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
|
|
32581
32601
|
}
|
|
32602
|
+
/** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
|
|
32603
|
+
* page routes moved to `/pages/...`. Remove in 2.x. */
|
|
32604
|
+
legacyPagesPaths = false;
|
|
32582
32605
|
/**
|
|
32583
|
-
*
|
|
32584
|
-
*
|
|
32585
|
-
*
|
|
32606
|
+
* Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
|
|
32607
|
+
*
|
|
32608
|
+
* Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
|
|
32609
|
+
* unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
|
|
32610
|
+
* older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
|
|
32611
|
+
* a capability verdict — it is the expected answer before the bank's first retain — so it is
|
|
32612
|
+
* returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
|
|
32586
32613
|
*
|
|
32587
32614
|
* Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
|
|
32588
32615
|
* the 405/501 this used to check for never reach a caller in the first place.
|
|
32589
32616
|
*/
|
|
32590
|
-
async
|
|
32591
|
-
|
|
32592
|
-
|
|
32593
|
-
return
|
|
32617
|
+
async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
|
|
32618
|
+
const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
|
|
32619
|
+
let r = await send(this.legacyPagesPaths);
|
|
32620
|
+
if (r.status !== 404 || !await isEndpointMissing(r)) return r;
|
|
32621
|
+
if (!this.legacyPagesPaths) {
|
|
32622
|
+
r = await send(true);
|
|
32623
|
+
if (r.status !== 404 || !await isEndpointMissing(r)) {
|
|
32624
|
+
this.legacyPagesPaths = true;
|
|
32625
|
+
return r;
|
|
32626
|
+
}
|
|
32627
|
+
}
|
|
32628
|
+
this.pagesSupported = false;
|
|
32629
|
+
return null;
|
|
32594
32630
|
}
|
|
32595
32631
|
/**
|
|
32596
|
-
* The bank's
|
|
32632
|
+
* The bank's page tree (folders + pages, nested). The tree carries names, source
|
|
32597
32633
|
* queries and staleness but NOT synthesized content, so it is cheap enough to poll.
|
|
32598
32634
|
*/
|
|
32599
32635
|
async tree() {
|
|
32600
|
-
if (this.
|
|
32601
|
-
const r = await this.
|
|
32602
|
-
if (
|
|
32636
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
32637
|
+
const r = await this.pagesReq("GET", "/tree");
|
|
32638
|
+
if (!r) throw new PagesUnavailableError();
|
|
32603
32639
|
if (r.status === 404) return [];
|
|
32604
|
-
this.
|
|
32640
|
+
this.pagesSupported = true;
|
|
32605
32641
|
try {
|
|
32606
32642
|
return (await r.json()).roots ?? [];
|
|
32607
32643
|
} catch {
|
|
@@ -32609,13 +32645,13 @@ var HindsightClient = class {
|
|
|
32609
32645
|
}
|
|
32610
32646
|
}
|
|
32611
32647
|
/**
|
|
32612
|
-
* List
|
|
32648
|
+
* List pages (ids + names only — no synthesized content), flattened out of the tree
|
|
32613
32649
|
* and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
|
|
32614
32650
|
* to read, and a caller enumerating pages wants leaves, not structure.
|
|
32615
32651
|
*
|
|
32616
|
-
* NOTE the ids are
|
|
32617
|
-
* page read/update in this client goes through the same
|
|
32618
|
-
* here, from `
|
|
32652
|
+
* NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
|
|
32653
|
+
* page read/update in this client goes through the same page ids, so a page id from
|
|
32654
|
+
* here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
|
|
32619
32655
|
*/
|
|
32620
32656
|
async listPages() {
|
|
32621
32657
|
const items = [];
|
|
@@ -32637,34 +32673,26 @@ var HindsightClient = class {
|
|
|
32637
32673
|
return { items };
|
|
32638
32674
|
}
|
|
32639
32675
|
/**
|
|
32640
|
-
* Read one
|
|
32676
|
+
* Read one page's synthesized content by page id, shaped by `shapePage` so
|
|
32641
32677
|
* the body arrives once. The endpoint omits the internal reflect trace that built
|
|
32642
32678
|
* the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
|
|
32643
32679
|
* token cap.
|
|
32644
32680
|
*/
|
|
32645
32681
|
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}`);
|
|
32682
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
32683
|
+
const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
|
|
32684
|
+
if (!r) throw new PagesUnavailableError();
|
|
32685
|
+
if (r.status === 404) throw new Error(`page not found: ${pageId}`);
|
|
32652
32686
|
return shapePage(await r.json());
|
|
32653
32687
|
}
|
|
32654
|
-
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's
|
|
32688
|
+
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
|
|
32655
32689
|
* Returns page-level hits with a relevance snippet — the real search behind
|
|
32656
|
-
*
|
|
32657
|
-
async
|
|
32658
|
-
if (this.
|
|
32690
|
+
* hindsight_search_pages. */
|
|
32691
|
+
async searchPages(query, opts = {}) {
|
|
32692
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
32659
32693
|
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();
|
|
32694
|
+
const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
|
|
32695
|
+
if (!r) throw new PagesUnavailableError();
|
|
32668
32696
|
if (r.status === 404) return [];
|
|
32669
32697
|
const j = await r.json();
|
|
32670
32698
|
return (j.results ?? []).map((x) => ({
|
|
@@ -32676,9 +32704,9 @@ var HindsightClient = class {
|
|
|
32676
32704
|
}));
|
|
32677
32705
|
}
|
|
32678
32706
|
/**
|
|
32679
|
-
* Seed the fixed page taxonomy as
|
|
32707
|
+
* Seed the fixed page taxonomy as pages at the tree root, idempotently.
|
|
32680
32708
|
*
|
|
32681
|
-
* Matched by NAME, not id:
|
|
32709
|
+
* Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
|
|
32682
32710
|
* client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
|
|
32683
32711
|
* off a slug). Names are unique per folder server-side, which makes them a sound key.
|
|
32684
32712
|
*
|
|
@@ -32693,8 +32721,8 @@ var HindsightClient = class {
|
|
|
32693
32721
|
try {
|
|
32694
32722
|
roots = await this.tree();
|
|
32695
32723
|
} catch (e) {
|
|
32696
|
-
if (e instanceof
|
|
32697
|
-
this.log(`[bank]
|
|
32724
|
+
if (e instanceof PagesUnavailableError) {
|
|
32725
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
32698
32726
|
return;
|
|
32699
32727
|
}
|
|
32700
32728
|
throw e;
|
|
@@ -32717,11 +32745,9 @@ var HindsightClient = class {
|
|
|
32717
32745
|
trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
|
|
32718
32746
|
};
|
|
32719
32747
|
if (!hit) {
|
|
32720
|
-
const r = await this.
|
|
32721
|
-
if (
|
|
32722
|
-
this.log(
|
|
32723
|
-
`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
|
|
32724
|
-
);
|
|
32748
|
+
const r = await this.pagesReq("POST", "", body, [409]);
|
|
32749
|
+
if (!r) {
|
|
32750
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
32725
32751
|
return;
|
|
32726
32752
|
}
|
|
32727
32753
|
if (r.status === 404) {
|
|
@@ -32742,15 +32768,9 @@ var HindsightClient = class {
|
|
|
32742
32768
|
);
|
|
32743
32769
|
}
|
|
32744
32770
|
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
|
-
);
|
|
32771
|
+
const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
|
|
32772
|
+
if (!r) {
|
|
32773
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
32754
32774
|
return;
|
|
32755
32775
|
}
|
|
32756
32776
|
if (r.status === 404) {
|
|
@@ -32762,7 +32782,7 @@ var HindsightClient = class {
|
|
|
32762
32782
|
}
|
|
32763
32783
|
const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
|
|
32764
32784
|
this.log(
|
|
32765
|
-
`[bank]
|
|
32785
|
+
`[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
32786
|
);
|
|
32767
32787
|
}
|
|
32768
32788
|
/**
|
|
@@ -32796,12 +32816,8 @@ var HindsightClient = class {
|
|
|
32796
32816
|
if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
|
|
32797
32817
|
}
|
|
32798
32818
|
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;
|
|
32819
|
+
const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
|
|
32820
|
+
if (!r || r.status === 404) continue;
|
|
32805
32821
|
updated++;
|
|
32806
32822
|
}
|
|
32807
32823
|
return updated;
|
|
@@ -32827,7 +32843,7 @@ var HindsightClient = class {
|
|
|
32827
32843
|
let pageId = args.relatesToPageId;
|
|
32828
32844
|
if (!pageId) {
|
|
32829
32845
|
const folderId = await this.ensureFolder("Initiatives");
|
|
32830
|
-
const r = await this.
|
|
32846
|
+
const r = await this.pagesReq("POST", "", {
|
|
32831
32847
|
name: args.title,
|
|
32832
32848
|
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
32849
|
parent_id: folderId,
|
|
@@ -32836,8 +32852,8 @@ var HindsightClient = class {
|
|
|
32836
32852
|
trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
|
|
32837
32853
|
});
|
|
32838
32854
|
try {
|
|
32839
|
-
const j = await r
|
|
32840
|
-
pageId = j
|
|
32855
|
+
const j = await r?.json();
|
|
32856
|
+
pageId = j?.page_id ?? j?.id;
|
|
32841
32857
|
} catch {
|
|
32842
32858
|
}
|
|
32843
32859
|
pageId ||= `initiative-${this.slugify(args.title)}`;
|
|
@@ -32855,16 +32871,17 @@ var HindsightClient = class {
|
|
|
32855
32871
|
/** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
|
|
32856
32872
|
async ensureFolder(name) {
|
|
32857
32873
|
try {
|
|
32858
|
-
const
|
|
32859
|
-
const
|
|
32874
|
+
const r = await this.pagesReq("GET", "/tree");
|
|
32875
|
+
const tree = await r?.json();
|
|
32876
|
+
const hit = (tree?.roots || []).find(
|
|
32860
32877
|
(n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
|
|
32861
32878
|
);
|
|
32862
32879
|
if (hit?.id) return hit.id;
|
|
32863
32880
|
} catch {
|
|
32864
32881
|
}
|
|
32865
32882
|
try {
|
|
32866
|
-
const r = await this.
|
|
32867
|
-
return (await r
|
|
32883
|
+
const r = await this.pagesReq("POST", "/folders", { name });
|
|
32884
|
+
return (await r?.json())?.id;
|
|
32868
32885
|
} catch {
|
|
32869
32886
|
return void 0;
|
|
32870
32887
|
}
|
|
@@ -33301,7 +33318,7 @@ function resolveHostMemory(harness, directory) {
|
|
|
33301
33318
|
};
|
|
33302
33319
|
}
|
|
33303
33320
|
|
|
33304
|
-
// src/core/
|
|
33321
|
+
// src/core/page-tools.ts
|
|
33305
33322
|
import { createHash as createHash4 } from "crypto";
|
|
33306
33323
|
import { existsSync as existsSync3 } from "fs";
|
|
33307
33324
|
import { homedir as homedir5 } from "os";
|
|
@@ -33348,7 +33365,7 @@ function commitsSince(dir, sinceSha) {
|
|
|
33348
33365
|
}
|
|
33349
33366
|
}
|
|
33350
33367
|
|
|
33351
|
-
// src/core/
|
|
33368
|
+
// src/core/page-injection.ts
|
|
33352
33369
|
function parsePageList(raw) {
|
|
33353
33370
|
const items = raw?.items;
|
|
33354
33371
|
if (!Array.isArray(items)) return [];
|
|
@@ -33455,11 +33472,11 @@ async function syncStatus(client, bank, repoDir) {
|
|
|
33455
33472
|
activeOps,
|
|
33456
33473
|
// Older Hindsight servers have no page surface. They are still fully usable for the
|
|
33457
33474
|
// legacy bank/retain pipeline, so page absence must not make syncStatus permanently false.
|
|
33458
|
-
synced: gitlogPresent && (client.
|
|
33475
|
+
synced: gitlogPresent && (client.pagesSupported === false || pages.length > 0) && (activeOps ?? 0) === 0
|
|
33459
33476
|
};
|
|
33460
33477
|
}
|
|
33461
33478
|
|
|
33462
|
-
// src/core/
|
|
33479
|
+
// src/core/page-tools.ts
|
|
33463
33480
|
var READ_ONLY_ANNOTATIONS = {
|
|
33464
33481
|
readOnlyHint: true,
|
|
33465
33482
|
destructiveHint: false,
|
|
@@ -33489,13 +33506,13 @@ function guarded(fn) {
|
|
|
33489
33506
|
}
|
|
33490
33507
|
};
|
|
33491
33508
|
}
|
|
33492
|
-
function
|
|
33509
|
+
function buildPageTools(client, bankId, opts = {}) {
|
|
33493
33510
|
const extra = opts.toolGuideExtra?.trim();
|
|
33494
33511
|
const crediting = extra ? `${CREDIT_REMINDER} ${extra}` : CREDIT_REMINDER;
|
|
33495
33512
|
return [
|
|
33496
33513
|
{
|
|
33497
33514
|
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,
|
|
33515
|
+
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
33516
|
inputSchema: {},
|
|
33500
33517
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
33501
33518
|
handler: async () => {
|
|
@@ -33550,13 +33567,13 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
33550
33567
|
}
|
|
33551
33568
|
},
|
|
33552
33569
|
{
|
|
33553
|
-
name: "
|
|
33554
|
-
description: "Search this repository's Hindsight
|
|
33570
|
+
name: "hindsight_search_pages",
|
|
33571
|
+
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, each with its opening text (not the passage that matched, and not filtered by relevance); read a full page with hindsight_read_page. " + crediting,
|
|
33555
33572
|
inputSchema: { query: external_exports.string().describe("what to look for") },
|
|
33556
33573
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
33557
33574
|
handler: async (args) => {
|
|
33558
33575
|
try {
|
|
33559
|
-
const hits = await client.
|
|
33576
|
+
const hits = await client.searchPages(args.query);
|
|
33560
33577
|
return ok({
|
|
33561
33578
|
pages: hits.map((h) => ({
|
|
33562
33579
|
page: h.name,
|
|
@@ -33574,22 +33591,22 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
33574
33591
|
}
|
|
33575
33592
|
},
|
|
33576
33593
|
{
|
|
33577
|
-
name: "
|
|
33578
|
-
description: "List this repository's Hindsight
|
|
33594
|
+
name: "hindsight_list_pages",
|
|
33595
|
+
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
33596
|
inputSchema: {},
|
|
33580
33597
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
33581
33598
|
handler: guarded(async () => client.listPages())
|
|
33582
33599
|
},
|
|
33583
33600
|
{
|
|
33584
|
-
name: "
|
|
33585
|
-
description: "Read the full content of one
|
|
33601
|
+
name: "hindsight_read_page",
|
|
33602
|
+
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
33603
|
inputSchema: { page_id: external_exports.string() },
|
|
33587
33604
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
33588
33605
|
handler: guarded(async ({ page_id }) => client.getPage(page_id))
|
|
33589
33606
|
},
|
|
33590
33607
|
{
|
|
33591
33608
|
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
|
|
33609
|
+
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
33610
|
inputSchema: { query: external_exports.string().describe("the question to reason over memory about") },
|
|
33594
33611
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
33595
33612
|
handler: guarded(
|
|
@@ -33601,7 +33618,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
33601
33618
|
},
|
|
33602
33619
|
{
|
|
33603
33620
|
name: "hindsight_capture_initiative",
|
|
33604
|
-
description: "Record a new feature or initiative as a tracked
|
|
33621
|
+
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
33622
|
inputSchema: {
|
|
33606
33623
|
title: external_exports.string(),
|
|
33607
33624
|
summary: external_exports.string(),
|
|
@@ -33704,7 +33721,7 @@ function buildRetainStamp(cfg, ctx) {
|
|
|
33704
33721
|
function selectTools(cfg, client, bankId, opts = {}) {
|
|
33705
33722
|
const cwd = opts.cwd ?? process.cwd();
|
|
33706
33723
|
const harness = opts.harness ?? cfg.harness;
|
|
33707
|
-
return cfg.disabled ? [] :
|
|
33724
|
+
return cfg.disabled ? [] : buildPageTools(client, bankId, {
|
|
33708
33725
|
repoDir: cwd,
|
|
33709
33726
|
harness,
|
|
33710
33727
|
pageTrigger: buildPageTrigger(cfg),
|