@vectorize-io/hindsight-coding-agents 0.8.7 → 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 +8 -3
- package/dist/antigravity-hook.js +150 -57
- package/dist/antigravity-statusline.js +30 -24
- package/dist/antigravity-stop-hook.js +160 -57
- package/dist/claude-hook.js +150 -57
- package/dist/claude-sessionstart-hook.js +176 -86
- package/dist/claude-stop-hook.js +160 -57
- package/dist/cline.js +132 -92
- package/dist/codebuddy-hook.js +150 -57
- package/dist/codebuddy-sessionstart-hook.js +176 -86
- package/dist/codebuddy-stop-hook.js +160 -57
- package/dist/codex-hook.js +150 -57
- package/dist/codex-sessionstart-hook.js +176 -86
- package/dist/codex-stop-hook.js +160 -57
- package/dist/copilot-hook.js +150 -57
- package/dist/copilot-sessionstart-hook.js +176 -86
- package/dist/copilot-stop-hook.js +160 -57
- package/dist/cursor-hook.js +150 -57
- package/dist/cursor-sessionstart-hook.js +176 -86
- package/dist/cursor-stop-hook.js +160 -57
- package/dist/daemon-start.js +20 -16
- package/dist/dcode-hook.js +150 -57
- package/dist/dcode-sessionstart-hook.js +176 -86
- package/dist/dcode-stop-hook.js +160 -57
- package/dist/deepen.js +19 -5
- package/dist/devin-hook.js +150 -57
- package/dist/devin-sessionstart-hook.js +176 -86
- package/dist/devin-stop-hook.js +160 -57
- package/dist/droid-hook.js +150 -57
- package/dist/droid-sessionstart-hook.js +176 -86
- package/dist/droid-stop-hook.js +160 -57
- package/dist/dsh.js +155 -93
- package/dist/grok-hook.js +150 -57
- package/dist/grok-sessionstart-hook.js +176 -86
- package/dist/grok-stop-hook.js +160 -57
- package/dist/hindsight-seed.js +35 -26
- package/dist/index.js +155 -93
- package/dist/installer.js +143 -41
- package/dist/kilo.js +155 -93
- package/dist/kimi-hook.js +150 -57
- package/dist/kimi-sessionstart-hook.js +176 -86
- package/dist/kimi-stop-hook.js +160 -57
- package/dist/mcp-server.js +73 -57
- package/dist/opencode2.js +155 -93
- package/dist/pi.js +155 -93
- package/dist/prime-agent.js +155 -93
- package/dist/qwen-hook.js +150 -57
- package/dist/qwen-sessionstart-hook.js +176 -86
- package/dist/qwen-stop-hook.js +160 -57
- package/dist/status.js +55 -39
- package/dist/traecode-hook.js +150 -57
- package/dist/traecode-sessionstart-hook.js +176 -86
- package/dist/traecode-stop-hook.js +160 -57
- package/dist/workbuddy-hook.js +150 -57
- package/dist/workbuddy-sessionstart-hook.js +176 -86
- package/dist/workbuddy-stop-hook.js +160 -57
- package/dist/zcode-hook.js +150 -57
- package/dist/zcode-sessionstart-hook.js +176 -86
- package/dist/zcode-stop-hook.js +160 -57
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skill/SKILL.md +8 -3
package/dist/prime-agent.js
CHANGED
|
@@ -14525,16 +14525,77 @@ import { join as join7 } from "path";
|
|
|
14525
14525
|
|
|
14526
14526
|
// src/core/seed.ts
|
|
14527
14527
|
import { spawn as realSpawn } from "child_process";
|
|
14528
|
-
import { dirname, join } from "path";
|
|
14528
|
+
import { dirname, join as join2 } from "path";
|
|
14529
14529
|
import { fileURLToPath } from "url";
|
|
14530
|
+
|
|
14531
|
+
// src/core/util.ts
|
|
14532
|
+
import { accessSync, constants, statSync } from "fs";
|
|
14533
|
+
import { delimiter, extname, isAbsolute, join, resolve } from "path";
|
|
14534
|
+
function binOnPath(bin, opts = {}) {
|
|
14535
|
+
const platform = opts.platform ?? process.platform;
|
|
14536
|
+
const env = opts.env ?? process.env;
|
|
14537
|
+
const runnable = (file2) => {
|
|
14538
|
+
try {
|
|
14539
|
+
if (!statSync(file2).isFile()) return false;
|
|
14540
|
+
if (platform !== "win32") accessSync(file2, constants.X_OK);
|
|
14541
|
+
return true;
|
|
14542
|
+
} catch {
|
|
14543
|
+
return false;
|
|
14544
|
+
}
|
|
14545
|
+
};
|
|
14546
|
+
if (isAbsolute(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve(bin) : void 0;
|
|
14547
|
+
const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
|
|
14548
|
+
for (const dir of (env.PATH || "").split(delimiter)) {
|
|
14549
|
+
if (!dir) continue;
|
|
14550
|
+
for (const name of names) {
|
|
14551
|
+
const file2 = join(dir, name);
|
|
14552
|
+
if (runnable(file2)) return resolve(file2);
|
|
14553
|
+
}
|
|
14554
|
+
}
|
|
14555
|
+
return void 0;
|
|
14556
|
+
}
|
|
14557
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
14558
|
+
function semverGte(version3, min) {
|
|
14559
|
+
const parts = (v) => {
|
|
14560
|
+
const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
|
|
14561
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
|
|
14562
|
+
};
|
|
14563
|
+
const a = version3 ? parts(version3) : void 0;
|
|
14564
|
+
const b = parts(min);
|
|
14565
|
+
if (!a || !b) return false;
|
|
14566
|
+
for (let i = 0; i < 3; i++) {
|
|
14567
|
+
if (a[i] !== b[i]) return a[i] > b[i];
|
|
14568
|
+
}
|
|
14569
|
+
return true;
|
|
14570
|
+
}
|
|
14571
|
+
async function pool(items, n, fn, onError, onProgress) {
|
|
14572
|
+
let i = 0, done = 0;
|
|
14573
|
+
async function worker() {
|
|
14574
|
+
while (i < items.length) {
|
|
14575
|
+
const idx = i++;
|
|
14576
|
+
try {
|
|
14577
|
+
await fn(items[idx], idx);
|
|
14578
|
+
} catch (e) {
|
|
14579
|
+
onError?.(idx, e);
|
|
14580
|
+
}
|
|
14581
|
+
onProgress?.(++done, items.length);
|
|
14582
|
+
}
|
|
14583
|
+
}
|
|
14584
|
+
await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
|
|
14585
|
+
}
|
|
14586
|
+
function nodeBinary() {
|
|
14587
|
+
return process.versions.bun || process.versions.electron ? "node" : process.execPath;
|
|
14588
|
+
}
|
|
14589
|
+
|
|
14590
|
+
// src/core/seed.ts
|
|
14530
14591
|
var DEFAULT_SEED_LIMIT = 300;
|
|
14531
14592
|
function startBackgroundSeed(repoDir, opts = {}) {
|
|
14532
14593
|
try {
|
|
14533
14594
|
const spawnFn = opts.spawn ?? realSpawn;
|
|
14534
|
-
const enginePath = opts.enginePath ??
|
|
14595
|
+
const enginePath = opts.enginePath ?? join2(dirname(fileURLToPath(import.meta.url)), "deepen.js");
|
|
14535
14596
|
const limit = opts.limit ?? DEFAULT_SEED_LIMIT;
|
|
14536
14597
|
const child = spawnFn(
|
|
14537
|
-
|
|
14598
|
+
nodeBinary(),
|
|
14538
14599
|
[
|
|
14539
14600
|
enginePath,
|
|
14540
14601
|
"--repo",
|
|
@@ -14559,24 +14620,24 @@ function startBackgroundSeed(repoDir, opts = {}) {
|
|
|
14559
14620
|
// src/core/bank.ts
|
|
14560
14621
|
import { existsSync } from "fs";
|
|
14561
14622
|
import { homedir as homedir2 } from "os";
|
|
14562
|
-
import { basename, dirname as dirname4, join as
|
|
14623
|
+
import { basename, dirname as dirname4, join as join6, normalize, sep } from "path";
|
|
14563
14624
|
|
|
14564
14625
|
// src/core/diag.ts
|
|
14565
14626
|
import { readFileSync } from "fs";
|
|
14566
|
-
import { join as
|
|
14627
|
+
import { join as join4 } from "path";
|
|
14567
14628
|
|
|
14568
14629
|
// src/core/log.ts
|
|
14569
|
-
import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
|
|
14630
|
+
import { appendFileSync, mkdirSync, renameSync, statSync as statSync2 } from "fs";
|
|
14570
14631
|
import { homedir } from "os";
|
|
14571
|
-
import { dirname as dirname2, join as
|
|
14632
|
+
import { dirname as dirname2, join as join3 } from "path";
|
|
14572
14633
|
function logsDir() {
|
|
14573
|
-
return
|
|
14634
|
+
return join3(homedir(), ".hindsight", "coding-agents-logs");
|
|
14574
14635
|
}
|
|
14575
14636
|
var LOG_MAX_BYTES = 10 * 1024 * 1024;
|
|
14576
14637
|
function appendLogLine(file2, text) {
|
|
14577
14638
|
mkdirSync(dirname2(file2), { recursive: true, mode: 448 });
|
|
14578
14639
|
try {
|
|
14579
|
-
if (
|
|
14640
|
+
if (statSync2(file2).size >= LOG_MAX_BYTES) renameSync(file2, `${file2}.1`);
|
|
14580
14641
|
} catch {
|
|
14581
14642
|
}
|
|
14582
14643
|
appendFileSync(file2, text, { mode: 384 });
|
|
@@ -14589,7 +14650,7 @@ function setLogLevel(level) {
|
|
|
14589
14650
|
if (!process.env.HINDSIGHT_LOG_LEVEL) current = level;
|
|
14590
14651
|
}
|
|
14591
14652
|
function logFilePath() {
|
|
14592
|
-
return process.env.HINDSIGHT_LOG_FILE ||
|
|
14653
|
+
return process.env.HINDSIGHT_LOG_FILE || join3(logsDir(), "plugin.log");
|
|
14593
14654
|
}
|
|
14594
14655
|
function write(level, scope, msg, extra) {
|
|
14595
14656
|
if (WEIGHT[level] < WEIGHT[current]) return;
|
|
@@ -14624,7 +14685,7 @@ function describeError(value, maxChars = 200) {
|
|
|
14624
14685
|
|
|
14625
14686
|
// src/core/diag.ts
|
|
14626
14687
|
function diagFilePath() {
|
|
14627
|
-
return process.env.HINDSIGHT_DIAG_FILE ||
|
|
14688
|
+
return process.env.HINDSIGHT_DIAG_FILE || join4(logsDir(), "diag.jsonl");
|
|
14628
14689
|
}
|
|
14629
14690
|
function diag(harness, event, extra = {}) {
|
|
14630
14691
|
log.debug(harness, `diag:${event}`, extra);
|
|
@@ -14639,7 +14700,7 @@ function diag(harness, event, extra = {}) {
|
|
|
14639
14700
|
|
|
14640
14701
|
// src/core/git-layout.ts
|
|
14641
14702
|
import { lstatSync, readFileSync as readFileSync2, realpathSync } from "fs";
|
|
14642
|
-
import { dirname as dirname3, isAbsolute, join as
|
|
14703
|
+
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "path";
|
|
14643
14704
|
var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
|
|
14644
14705
|
var ATTEMPTS = 3;
|
|
14645
14706
|
var BACKOFF_MS = 20;
|
|
@@ -14672,19 +14733,19 @@ function gitDirFromPointer(text, holder) {
|
|
|
14672
14733
|
const match = /^\s*gitdir:\s*(.+?)\s*$/m.exec(text);
|
|
14673
14734
|
if (!match) return null;
|
|
14674
14735
|
const target = match[1];
|
|
14675
|
-
return
|
|
14736
|
+
return isAbsolute2(target) ? target : resolve2(holder, target);
|
|
14676
14737
|
}
|
|
14677
14738
|
function commonDirOf(gitDir) {
|
|
14678
|
-
const pointer = entryKind(
|
|
14739
|
+
const pointer = entryKind(join5(gitDir, "commondir")) === "file" ? readTextOrNull(join5(gitDir, "commondir"))?.trim() : null;
|
|
14679
14740
|
if (!pointer) return gitDir;
|
|
14680
|
-
return
|
|
14741
|
+
return isAbsolute2(pointer) ? pointer : resolve2(gitDir, pointer);
|
|
14681
14742
|
}
|
|
14682
14743
|
function isBare(commonDir) {
|
|
14683
|
-
const config2 = readTextOrNull(
|
|
14744
|
+
const config2 = readTextOrNull(join5(commonDir, "config"));
|
|
14684
14745
|
return config2 !== null && /^\s*bare\s*=\s*true\s*$/im.test(config2);
|
|
14685
14746
|
}
|
|
14686
14747
|
function looksLikeBareRepository(directory) {
|
|
14687
|
-
return entryKind(
|
|
14748
|
+
return entryKind(join5(directory, "HEAD")) === "file" && entryKind(join5(directory, "objects")) === "dir" && entryKind(join5(directory, "refs")) === "dir";
|
|
14688
14749
|
}
|
|
14689
14750
|
function canonical(path) {
|
|
14690
14751
|
try {
|
|
@@ -14699,9 +14760,9 @@ function resolved(commonDir) {
|
|
|
14699
14760
|
return { status: "resolved", commonDir: canonicalDir, bare: isBare(canonicalDir) };
|
|
14700
14761
|
}
|
|
14701
14762
|
function probeOnce(directory) {
|
|
14702
|
-
let current2 =
|
|
14763
|
+
let current2 = resolve2(directory);
|
|
14703
14764
|
for (; ; ) {
|
|
14704
|
-
const dotGit =
|
|
14765
|
+
const dotGit = join5(current2, ".git");
|
|
14705
14766
|
const kind = entryKind(dotGit);
|
|
14706
14767
|
if (kind === "dir") {
|
|
14707
14768
|
const layout = resolved(commonDirOf(dotGit));
|
|
@@ -14815,10 +14876,14 @@ function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
|
|
|
14815
14876
|
return dirName(sessionRoot || directory);
|
|
14816
14877
|
}
|
|
14817
14878
|
function configuredDir(dir) {
|
|
14818
|
-
const expanded = dir === "~" || dir.startsWith("~/") ?
|
|
14879
|
+
const expanded = dir === "~" || dir.startsWith("~/") ? join6(homedir2(), dir.slice(1)) : dir;
|
|
14819
14880
|
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
14820
14881
|
}
|
|
14821
|
-
function isWithin(directory, configured) {
|
|
14882
|
+
function isWithin(directory, configured, platform = process.platform) {
|
|
14883
|
+
if (platform === "win32") {
|
|
14884
|
+
directory = directory.toLowerCase();
|
|
14885
|
+
configured = configured.toLowerCase();
|
|
14886
|
+
}
|
|
14822
14887
|
return directory === configured || directory.startsWith(configured + sep);
|
|
14823
14888
|
}
|
|
14824
14889
|
function mapLookup(map2, directory) {
|
|
@@ -14908,7 +14973,7 @@ function deriveBankIdOrSkip(config2, directory, harness = "coding", sessionRoot)
|
|
|
14908
14973
|
import { createHash } from "crypto";
|
|
14909
14974
|
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.";
|
|
14910
14975
|
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.";
|
|
14911
|
-
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.`;
|
|
14976
|
+
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.`;
|
|
14912
14977
|
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.";
|
|
14913
14978
|
var DOCUMENT_MISSION = "You are ingesting a standalone document (notes, docs, or structural findings). Extract the concrete facts, concepts, and structure it describes.";
|
|
14914
14979
|
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.";
|
|
@@ -15167,63 +15232,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
15167
15232
|
}
|
|
15168
15233
|
|
|
15169
15234
|
// package.json
|
|
15170
|
-
var version2 = "0.8.
|
|
15171
|
-
|
|
15172
|
-
// src/core/util.ts
|
|
15173
|
-
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
15174
|
-
import { delimiter, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "path";
|
|
15175
|
-
function binOnPath(bin, opts = {}) {
|
|
15176
|
-
const platform = opts.platform ?? process.platform;
|
|
15177
|
-
const env = opts.env ?? process.env;
|
|
15178
|
-
const runnable = (file2) => {
|
|
15179
|
-
try {
|
|
15180
|
-
if (!statSync2(file2).isFile()) return false;
|
|
15181
|
-
if (platform !== "win32") accessSync(file2, constants.X_OK);
|
|
15182
|
-
return true;
|
|
15183
|
-
} catch {
|
|
15184
|
-
return false;
|
|
15185
|
-
}
|
|
15186
|
-
};
|
|
15187
|
-
if (isAbsolute2(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve2(bin) : void 0;
|
|
15188
|
-
const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
|
|
15189
|
-
for (const dir of (env.PATH || "").split(delimiter)) {
|
|
15190
|
-
if (!dir) continue;
|
|
15191
|
-
for (const name of names) {
|
|
15192
|
-
const file2 = join6(dir, name);
|
|
15193
|
-
if (runnable(file2)) return resolve2(file2);
|
|
15194
|
-
}
|
|
15195
|
-
}
|
|
15196
|
-
return void 0;
|
|
15197
|
-
}
|
|
15198
|
-
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
15199
|
-
function semverGte(version3, min) {
|
|
15200
|
-
const parts = (v) => {
|
|
15201
|
-
const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
|
|
15202
|
-
return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
|
|
15203
|
-
};
|
|
15204
|
-
const a = version3 ? parts(version3) : void 0;
|
|
15205
|
-
const b = parts(min);
|
|
15206
|
-
if (!a || !b) return false;
|
|
15207
|
-
for (let i = 0; i < 3; i++) {
|
|
15208
|
-
if (a[i] !== b[i]) return a[i] > b[i];
|
|
15209
|
-
}
|
|
15210
|
-
return true;
|
|
15211
|
-
}
|
|
15212
|
-
async function pool(items, n, fn, onError, onProgress) {
|
|
15213
|
-
let i = 0, done = 0;
|
|
15214
|
-
async function worker() {
|
|
15215
|
-
while (i < items.length) {
|
|
15216
|
-
const idx = i++;
|
|
15217
|
-
try {
|
|
15218
|
-
await fn(items[idx], idx);
|
|
15219
|
-
} catch (e) {
|
|
15220
|
-
onError?.(idx, e);
|
|
15221
|
-
}
|
|
15222
|
-
onProgress?.(++done, items.length);
|
|
15223
|
-
}
|
|
15224
|
-
}
|
|
15225
|
-
await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
|
|
15226
|
-
}
|
|
15235
|
+
var version2 = "0.8.8";
|
|
15227
15236
|
|
|
15228
15237
|
// src/core/hindsight.ts
|
|
15229
15238
|
var USER_AGENT = `hindsight-coding-agents/${version2}`;
|
|
@@ -15435,7 +15444,9 @@ var HindsightClient = class {
|
|
|
15435
15444
|
}
|
|
15436
15445
|
if (!r.ok && r.status !== 404 && !tolerate.includes(r.status))
|
|
15437
15446
|
throw new Error(
|
|
15438
|
-
|
|
15447
|
+
// Query dropped: an encoded search query filled the 200-char error cap and pushed the
|
|
15448
|
+
// status and the server's reason out of the tool error (#6341).
|
|
15449
|
+
`${method} ${url2.split("?")[0]} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
|
|
15439
15450
|
);
|
|
15440
15451
|
return r;
|
|
15441
15452
|
}
|
|
@@ -15581,6 +15592,15 @@ var HindsightClient = class {
|
|
|
15581
15592
|
await this.req("DELETE", this.bankUrl());
|
|
15582
15593
|
this.log(`[bank] reset ${this.bank}`);
|
|
15583
15594
|
}
|
|
15595
|
+
await this.configureBankSettings(opts);
|
|
15596
|
+
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
15597
|
+
}
|
|
15598
|
+
/** The config half of `configureBank` (missions, retain strategies, entity labels), without
|
|
15599
|
+
* seeding pages. Session start calls it directly when the deepen engine — the usual caller of
|
|
15600
|
+
* `configureBank` — will not run (`autoSeed: false`, or a directory with no git history):
|
|
15601
|
+
* without it such a bank never got the `conversation` strategy, and every session write-back
|
|
15602
|
+
* was extracted with the server's generic rules instead of the plugin's mission. */
|
|
15603
|
+
async configureBankSettings(opts = {}) {
|
|
15584
15604
|
if (opts.manage === false) {
|
|
15585
15605
|
this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
|
|
15586
15606
|
} else {
|
|
@@ -15596,7 +15616,6 @@ var HindsightClient = class {
|
|
|
15596
15616
|
this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
|
|
15597
15617
|
}
|
|
15598
15618
|
}
|
|
15599
|
-
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
15600
15619
|
}
|
|
15601
15620
|
/**
|
|
15602
15621
|
* This bank's own config OVERRIDES, or undefined when there are none to read.
|
|
@@ -16781,13 +16800,18 @@ function onPath(bin) {
|
|
|
16781
16800
|
return false;
|
|
16782
16801
|
}
|
|
16783
16802
|
}
|
|
16803
|
+
var DAEMON_CONFIG_ENV = "HINDSIGHT_CODING_AGENTS_DAEMON_CONFIG";
|
|
16784
16804
|
function startDaemonDetached(cfg, harness, spawnFn = realSpawn3) {
|
|
16785
16805
|
try {
|
|
16786
16806
|
const starter = join9(dirname6(fileURLToPath3(import.meta.url)), "daemon-start.js");
|
|
16787
|
-
const child = spawnFn(
|
|
16807
|
+
const child = spawnFn(nodeBinary(), [starter, "--harness", harness], {
|
|
16788
16808
|
detached: true,
|
|
16789
16809
|
stdio: "ignore",
|
|
16790
|
-
windowsHide: true
|
|
16810
|
+
windowsHide: true,
|
|
16811
|
+
// The caller's config is already resolved for its directory and bank. Re-reading the file in
|
|
16812
|
+
// the starter lost `paths` / `banks` overrides, so a daemon enabled only there never started
|
|
16813
|
+
// (#6334).
|
|
16814
|
+
env: { ...process.env, [DAEMON_CONFIG_ENV]: JSON.stringify(cfg) }
|
|
16791
16815
|
});
|
|
16792
16816
|
child.on("error", () => {
|
|
16793
16817
|
});
|
|
@@ -16893,7 +16917,7 @@ var TOOL_GUIDE = `- hindsight_search_pages(query) \u2014 FIRST STOP, and the way
|
|
|
16893
16917
|
\u2022 you are implementing something new, or two parts have to fit together;
|
|
16894
16918
|
\u2022 the user asks why something is the way it is, or what is left to do;
|
|
16895
16919
|
\u2022 you are about to commit, and need to know what the change was supposed to honour.
|
|
16896
|
-
It ranks the pages by relevance and
|
|
16920
|
+
It ranks the pages by relevance and shows the opening of each; every page can come back, so the ranking, not the list, is the signal. Read the top page with hindsight_read_page before you rely on it \u2014 the opening is not the passage that matched. What it returns is a past record, not a live reading: a claim that something was fixed, passes, or works is what someone said then \u2014 check it against the code before you rely on it, and say so when the two disagree.
|
|
16897
16921
|
CREDITING IS NOT OPTIONAL AND NOT A JUDGEMENT CALL. If you called this tool and anything it returned reached your reply \u2014 quoted, paraphrased, or merely confirming what you were about to say \u2014 open that part with a markdown blockquote, exactly: "> \u{1F9E0} **From Hindsight memory (<page>)** \u2014 <the specific facts you drew on>". Rewriting a snippet in your own words does not make it yours. A search that turned up nothing useful needs no mention at all \u2014 just carry on.
|
|
16898
16922
|
- hindsight_list_pages / hindsight_read_page \u2014 BEFORE substantial work, list the pages and read the relevant ones to ground yourself in this repo's architecture, conventions, and past decisions instead of re-deriving them from the code; follow any [[page:<id>]] links you see.
|
|
16899
16923
|
- hindsight_reflect(query) \u2014 when pages are too shallow and you need the WHY: deep reasoning over the repo's full memory for the past decision and exact values that explain a behavior or bug (slower \u2014 use deliberately, and credit results with a blockquote header "> \u{1F9E0} **From Hindsight memory** \u2014 <summary>").
|
|
@@ -17355,7 +17379,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
|
|
|
17355
17379
|
const mcpConfig = JSON.stringify({
|
|
17356
17380
|
mcpServers: {
|
|
17357
17381
|
hindsight: {
|
|
17358
|
-
command:
|
|
17382
|
+
command: nodeBinary(),
|
|
17359
17383
|
args: [opts.mcpServerPath],
|
|
17360
17384
|
// HINDSIGHT_MCP_HARNESS names the agent whose CLI this recipe drives — the survey's
|
|
17361
17385
|
// ingests are its writes. mcp-server.js REQUIRES it (it used to default to
|
|
@@ -17396,7 +17420,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
|
|
|
17396
17420
|
"--sandbox",
|
|
17397
17421
|
"read-only",
|
|
17398
17422
|
"-c",
|
|
17399
|
-
`mcp_servers.hindsight.command
|
|
17423
|
+
`mcp_servers.hindsight.command=${tomlValue(nodeBinary())}`,
|
|
17400
17424
|
"-c",
|
|
17401
17425
|
`mcp_servers.hindsight.args=${tomlValue([opts.mcpServerPath])}`,
|
|
17402
17426
|
"-c",
|
|
@@ -17483,7 +17507,7 @@ async function startCodebaseSurvey(repoDir, opts = {}) {
|
|
|
17483
17507
|
const supervisorPath = opts.supervisorPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "survey-supervisor.js");
|
|
17484
17508
|
return await new Promise((resolve4) => {
|
|
17485
17509
|
try {
|
|
17486
|
-
const child = spawnFn(
|
|
17510
|
+
const child = spawnFn(nodeBinary(), [supervisorPath], {
|
|
17487
17511
|
cwd: repoDir,
|
|
17488
17512
|
detached: true,
|
|
17489
17513
|
stdio: "ignore",
|
|
@@ -17677,7 +17701,7 @@ function buildPageTools(client, bankId, opts = {}) {
|
|
|
17677
17701
|
},
|
|
17678
17702
|
{
|
|
17679
17703
|
name: "hindsight_search_pages",
|
|
17680
|
-
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
|
|
17704
|
+
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,
|
|
17681
17705
|
inputSchema: { query: external_exports.string().describe("what to look for") },
|
|
17682
17706
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
17683
17707
|
handler: async (args) => {
|
|
@@ -18257,10 +18281,15 @@ function detectLegacyClaudePlugin(cwd, claudeDir = join16(homedir8(), ".claude")
|
|
|
18257
18281
|
const registry2 = readJson(join16(claudeDir, "plugins", "installed_plugins.json"));
|
|
18258
18282
|
const plugins = registry2?.plugins;
|
|
18259
18283
|
if (!plugins || typeof plugins !== "object") return void 0;
|
|
18260
|
-
const
|
|
18284
|
+
const enabledMaps = [
|
|
18285
|
+
join16(cwd, ".claude", "settings.local.json"),
|
|
18286
|
+
join16(cwd, ".claude", "settings.json"),
|
|
18287
|
+
join16(claudeDir, "settings.json")
|
|
18288
|
+
].map((path) => readJson(path)?.enabledPlugins);
|
|
18261
18289
|
for (const [key, raw] of Object.entries(plugins)) {
|
|
18262
18290
|
if (key.split("@")[0] !== LEGACY_CLAUDE_PLUGIN) continue;
|
|
18263
|
-
|
|
18291
|
+
const setting = enabledMaps.find((m) => m && typeof m[key] === "boolean")?.[key];
|
|
18292
|
+
if (setting === false) continue;
|
|
18264
18293
|
const installs = Array.isArray(raw) ? raw : [raw];
|
|
18265
18294
|
const active = installs.some((i) => {
|
|
18266
18295
|
if (!i || typeof i !== "object") return false;
|
|
@@ -18358,6 +18387,7 @@ async function buildSessionStartContext(args) {
|
|
|
18358
18387
|
let cold;
|
|
18359
18388
|
let gitDocIds;
|
|
18360
18389
|
let bankEmpty = false;
|
|
18390
|
+
let deepening = false;
|
|
18361
18391
|
const harness = args.harness ?? "claude-code";
|
|
18362
18392
|
const hasGit = args.hasGit ?? hasGitHistory;
|
|
18363
18393
|
const startSeed = args.startSeed ?? startBackgroundSeed;
|
|
@@ -18411,6 +18441,7 @@ async function buildSessionStartContext(args) {
|
|
|
18411
18441
|
}
|
|
18412
18442
|
if (docIds !== void 0) {
|
|
18413
18443
|
startSeed(cwd, { limit: cfg.seedLimit, harness });
|
|
18444
|
+
deepening = true;
|
|
18414
18445
|
if (cold) {
|
|
18415
18446
|
if (cfg.codebaseSurvey !== false) {
|
|
18416
18447
|
const sha = resolveHeadSha(cwd);
|
|
@@ -18460,6 +18491,14 @@ async function buildSessionStartContext(args) {
|
|
|
18460
18491
|
}
|
|
18461
18492
|
}
|
|
18462
18493
|
}
|
|
18494
|
+
if (!deepening) {
|
|
18495
|
+
await client.configureBankSettings?.({
|
|
18496
|
+
manage: cfg.manageBankConfig,
|
|
18497
|
+
extractionMode: cfg.retainExtractionMode,
|
|
18498
|
+
defaults: cfg.defaultBankConfig
|
|
18499
|
+
}).catch(() => {
|
|
18500
|
+
});
|
|
18501
|
+
}
|
|
18463
18502
|
let pages = [];
|
|
18464
18503
|
try {
|
|
18465
18504
|
pages = parsePageList(await client.listPages());
|
|
@@ -18499,10 +18538,14 @@ ${legacyClaudePluginWarning(legacyPlugin)}`;
|
|
|
18499
18538
|
import { existsSync as existsSync8 } from "fs";
|
|
18500
18539
|
|
|
18501
18540
|
// src/core/transcript-util.ts
|
|
18541
|
+
var TOOL_TEXT_CAP = 2e3;
|
|
18502
18542
|
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;
|
|
18503
18543
|
function stripInjectedMemory(s) {
|
|
18504
18544
|
return s.replace(MEMORY_TAG_RE, "");
|
|
18505
18545
|
}
|
|
18546
|
+
function truncate(s, max = TOOL_TEXT_CAP) {
|
|
18547
|
+
return s.length > max ? `${s.slice(0, max)}\u2026 (truncated)` : s;
|
|
18548
|
+
}
|
|
18506
18549
|
var TARGET_KEYS = [
|
|
18507
18550
|
"file_path",
|
|
18508
18551
|
"path",
|
|
@@ -18530,7 +18573,25 @@ function actionLine(tool, input) {
|
|
|
18530
18573
|
target = input.trim().split("\n")[0];
|
|
18531
18574
|
}
|
|
18532
18575
|
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
18533
|
-
|
|
18576
|
+
const line = target ? `${tool} ${target}` : tool;
|
|
18577
|
+
const note = memoryNoteText(input);
|
|
18578
|
+
return note ? `${line}
|
|
18579
|
+
${truncate(note, MEMORY_NOTE_CAP)}` : line;
|
|
18580
|
+
}
|
|
18581
|
+
var MEMORY_NOTE_CAP = 8e3;
|
|
18582
|
+
var MEMORY_NOTE_PATH_RE = /(^|[\\/])(memory|memories)[\\/]|(^|[\\/])MEMORY\.md$/i;
|
|
18583
|
+
var MEMORY_SHELL_WRITE_RE = /[\\/](memory|memories)([\\/\s"']|$)|MEMORY\.md/i;
|
|
18584
|
+
var SHELL_WRITE_RE = /(^|[^0-9&>])>>?(?!&)|\btee\b/;
|
|
18585
|
+
function memoryNoteText(input) {
|
|
18586
|
+
if (!input || typeof input !== "object") return "";
|
|
18587
|
+
const rec = input;
|
|
18588
|
+
const cmd = rec.command;
|
|
18589
|
+
if (typeof cmd === "string")
|
|
18590
|
+
return MEMORY_SHELL_WRITE_RE.test(cmd) && SHELL_WRITE_RE.test(cmd) ? cmd.trim() : "";
|
|
18591
|
+
const path = rec.file_path ?? rec.path;
|
|
18592
|
+
if (typeof path !== "string" || !MEMORY_NOTE_PATH_RE.test(path)) return "";
|
|
18593
|
+
const text = rec.content ?? rec.new_string;
|
|
18594
|
+
return typeof text === "string" ? text.trim() : "";
|
|
18534
18595
|
}
|
|
18535
18596
|
|
|
18536
18597
|
// src/core/inject.ts
|
|
@@ -18734,7 +18795,7 @@ async function buildHookOutput(args) {
|
|
|
18734
18795
|
});
|
|
18735
18796
|
const blocks = [];
|
|
18736
18797
|
if (reflectAnswer && reflectRanThisTurn) blocks.push(buildSystemInjection(reflectAnswer));
|
|
18737
|
-
if (cadence > 0 && turns % cadence === 0) {
|
|
18798
|
+
if (cadence > 0 && turns % cadence === 0 && !(turns === 1 && args.preambleOnFirstTurn)) {
|
|
18738
18799
|
blocks.push(
|
|
18739
18800
|
buildRosterRefresh(pages, {
|
|
18740
18801
|
reflectOnNewGoals: cfg.autoInject !== "reflect",
|
|
@@ -18877,7 +18938,8 @@ var RuntimeCore = class {
|
|
|
18877
18938
|
prompt,
|
|
18878
18939
|
cfg: this.cfg,
|
|
18879
18940
|
client: this.client,
|
|
18880
|
-
cacheFile
|
|
18941
|
+
cacheFile,
|
|
18942
|
+
preambleOnFirstTurn: true
|
|
18881
18943
|
});
|
|
18882
18944
|
const blocks = [];
|
|
18883
18945
|
if (turns === 1) {
|