@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/opencode2.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 = (file3) => {
|
|
14538
|
+
try {
|
|
14539
|
+
if (!statSync(file3).isFile()) return false;
|
|
14540
|
+
if (platform !== "win32") accessSync(file3, 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 file3 = join(dir, name);
|
|
14552
|
+
if (runnable(file3)) return resolve(file3);
|
|
14553
|
+
}
|
|
14554
|
+
}
|
|
14555
|
+
return void 0;
|
|
14556
|
+
}
|
|
14557
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
14558
|
+
function semverGte(version4, 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 = version4 ? parts(version4) : 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(file3, text) {
|
|
14577
14638
|
mkdirSync(dirname2(file3), { recursive: true, mode: 448 });
|
|
14578
14639
|
try {
|
|
14579
|
-
if (
|
|
14640
|
+
if (statSync2(file3).size >= LOG_MAX_BYTES) renameSync(file3, `${file3}.1`);
|
|
14580
14641
|
} catch {
|
|
14581
14642
|
}
|
|
14582
14643
|
appendFileSync(file3, 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 config3 = readTextOrNull(
|
|
14744
|
+
const config3 = readTextOrNull(join5(commonDir, "config"));
|
|
14684
14745
|
return config3 !== null && /^\s*bare\s*=\s*true\s*$/im.test(config3);
|
|
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(map3, directory) {
|
|
@@ -14908,7 +14973,7 @@ function deriveBankIdOrSkip(config3, 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 = (file3) => {
|
|
15179
|
-
try {
|
|
15180
|
-
if (!statSync2(file3).isFile()) return false;
|
|
15181
|
-
if (platform !== "win32") accessSync(file3, 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 file3 = join6(dir, name);
|
|
15193
|
-
if (runnable(file3)) return resolve2(file3);
|
|
15194
|
-
}
|
|
15195
|
-
}
|
|
15196
|
-
return void 0;
|
|
15197
|
-
}
|
|
15198
|
-
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
15199
|
-
function semverGte(version4, 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 = version4 ? parts(version4) : 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} ${url3.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>").
|
|
@@ -17366,7 +17390,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
|
|
|
17366
17390
|
const mcpConfig = JSON.stringify({
|
|
17367
17391
|
mcpServers: {
|
|
17368
17392
|
hindsight: {
|
|
17369
|
-
command:
|
|
17393
|
+
command: nodeBinary(),
|
|
17370
17394
|
args: [opts.mcpServerPath],
|
|
17371
17395
|
// HINDSIGHT_MCP_HARNESS names the agent whose CLI this recipe drives — the survey's
|
|
17372
17396
|
// ingests are its writes. mcp-server.js REQUIRES it (it used to default to
|
|
@@ -17407,7 +17431,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
|
|
|
17407
17431
|
"--sandbox",
|
|
17408
17432
|
"read-only",
|
|
17409
17433
|
"-c",
|
|
17410
|
-
`mcp_servers.hindsight.command
|
|
17434
|
+
`mcp_servers.hindsight.command=${tomlValue(nodeBinary())}`,
|
|
17411
17435
|
"-c",
|
|
17412
17436
|
`mcp_servers.hindsight.args=${tomlValue([opts.mcpServerPath])}`,
|
|
17413
17437
|
"-c",
|
|
@@ -17494,7 +17518,7 @@ async function startCodebaseSurvey(repoDir, opts = {}) {
|
|
|
17494
17518
|
const supervisorPath = opts.supervisorPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "survey-supervisor.js");
|
|
17495
17519
|
return await new Promise((resolve4) => {
|
|
17496
17520
|
try {
|
|
17497
|
-
const child = spawnFn(
|
|
17521
|
+
const child = spawnFn(nodeBinary(), [supervisorPath], {
|
|
17498
17522
|
cwd: repoDir,
|
|
17499
17523
|
detached: true,
|
|
17500
17524
|
stdio: "ignore",
|
|
@@ -17688,7 +17712,7 @@ function buildPageTools(client, bankId, opts = {}) {
|
|
|
17688
17712
|
},
|
|
17689
17713
|
{
|
|
17690
17714
|
name: "hindsight_search_pages",
|
|
17691
|
-
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
|
|
17715
|
+
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,
|
|
17692
17716
|
inputSchema: { query: external_exports.string().describe("what to look for") },
|
|
17693
17717
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
17694
17718
|
handler: async (args) => {
|
|
@@ -18283,10 +18307,15 @@ function detectLegacyClaudePlugin(cwd, claudeDir = join16(homedir8(), ".claude")
|
|
|
18283
18307
|
const registry3 = readJson(join16(claudeDir, "plugins", "installed_plugins.json"));
|
|
18284
18308
|
const plugins = registry3?.plugins;
|
|
18285
18309
|
if (!plugins || typeof plugins !== "object") return void 0;
|
|
18286
|
-
const
|
|
18310
|
+
const enabledMaps = [
|
|
18311
|
+
join16(cwd, ".claude", "settings.local.json"),
|
|
18312
|
+
join16(cwd, ".claude", "settings.json"),
|
|
18313
|
+
join16(claudeDir, "settings.json")
|
|
18314
|
+
].map((path) => readJson(path)?.enabledPlugins);
|
|
18287
18315
|
for (const [key, raw] of Object.entries(plugins)) {
|
|
18288
18316
|
if (key.split("@")[0] !== LEGACY_CLAUDE_PLUGIN) continue;
|
|
18289
|
-
|
|
18317
|
+
const setting = enabledMaps.find((m) => m && typeof m[key] === "boolean")?.[key];
|
|
18318
|
+
if (setting === false) continue;
|
|
18290
18319
|
const installs = Array.isArray(raw) ? raw : [raw];
|
|
18291
18320
|
const active = installs.some((i) => {
|
|
18292
18321
|
if (!i || typeof i !== "object") return false;
|
|
@@ -18384,6 +18413,7 @@ async function buildSessionStartContext(args) {
|
|
|
18384
18413
|
let cold;
|
|
18385
18414
|
let gitDocIds;
|
|
18386
18415
|
let bankEmpty = false;
|
|
18416
|
+
let deepening = false;
|
|
18387
18417
|
const harness = args.harness ?? "claude-code";
|
|
18388
18418
|
const hasGit = args.hasGit ?? hasGitHistory;
|
|
18389
18419
|
const startSeed = args.startSeed ?? startBackgroundSeed;
|
|
@@ -18437,6 +18467,7 @@ async function buildSessionStartContext(args) {
|
|
|
18437
18467
|
}
|
|
18438
18468
|
if (docIds !== void 0) {
|
|
18439
18469
|
startSeed(cwd, { limit: cfg.seedLimit, harness });
|
|
18470
|
+
deepening = true;
|
|
18440
18471
|
if (cold) {
|
|
18441
18472
|
if (cfg.codebaseSurvey !== false) {
|
|
18442
18473
|
const sha = resolveHeadSha(cwd);
|
|
@@ -18486,6 +18517,14 @@ async function buildSessionStartContext(args) {
|
|
|
18486
18517
|
}
|
|
18487
18518
|
}
|
|
18488
18519
|
}
|
|
18520
|
+
if (!deepening) {
|
|
18521
|
+
await client.configureBankSettings?.({
|
|
18522
|
+
manage: cfg.manageBankConfig,
|
|
18523
|
+
extractionMode: cfg.retainExtractionMode,
|
|
18524
|
+
defaults: cfg.defaultBankConfig
|
|
18525
|
+
}).catch(() => {
|
|
18526
|
+
});
|
|
18527
|
+
}
|
|
18489
18528
|
let pages = [];
|
|
18490
18529
|
try {
|
|
18491
18530
|
pages = parsePageList(await client.listPages());
|
|
@@ -18525,10 +18564,14 @@ ${legacyClaudePluginWarning(legacyPlugin)}`;
|
|
|
18525
18564
|
import { existsSync as existsSync8 } from "fs";
|
|
18526
18565
|
|
|
18527
18566
|
// src/core/transcript-util.ts
|
|
18567
|
+
var TOOL_TEXT_CAP = 2e3;
|
|
18528
18568
|
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;
|
|
18529
18569
|
function stripInjectedMemory(s) {
|
|
18530
18570
|
return s.replace(MEMORY_TAG_RE, "");
|
|
18531
18571
|
}
|
|
18572
|
+
function truncate(s, max = TOOL_TEXT_CAP) {
|
|
18573
|
+
return s.length > max ? `${s.slice(0, max)}\u2026 (truncated)` : s;
|
|
18574
|
+
}
|
|
18532
18575
|
var TARGET_KEYS = [
|
|
18533
18576
|
"file_path",
|
|
18534
18577
|
"path",
|
|
@@ -18556,7 +18599,25 @@ function actionLine(tool2, input) {
|
|
|
18556
18599
|
target = input.trim().split("\n")[0];
|
|
18557
18600
|
}
|
|
18558
18601
|
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
18559
|
-
|
|
18602
|
+
const line = target ? `${tool2} ${target}` : tool2;
|
|
18603
|
+
const note = memoryNoteText(input);
|
|
18604
|
+
return note ? `${line}
|
|
18605
|
+
${truncate(note, MEMORY_NOTE_CAP)}` : line;
|
|
18606
|
+
}
|
|
18607
|
+
var MEMORY_NOTE_CAP = 8e3;
|
|
18608
|
+
var MEMORY_NOTE_PATH_RE = /(^|[\\/])(memory|memories)[\\/]|(^|[\\/])MEMORY\.md$/i;
|
|
18609
|
+
var MEMORY_SHELL_WRITE_RE = /[\\/](memory|memories)([\\/\s"']|$)|MEMORY\.md/i;
|
|
18610
|
+
var SHELL_WRITE_RE = /(^|[^0-9&>])>>?(?!&)|\btee\b/;
|
|
18611
|
+
function memoryNoteText(input) {
|
|
18612
|
+
if (!input || typeof input !== "object") return "";
|
|
18613
|
+
const rec = input;
|
|
18614
|
+
const cmd = rec.command;
|
|
18615
|
+
if (typeof cmd === "string")
|
|
18616
|
+
return MEMORY_SHELL_WRITE_RE.test(cmd) && SHELL_WRITE_RE.test(cmd) ? cmd.trim() : "";
|
|
18617
|
+
const path = rec.file_path ?? rec.path;
|
|
18618
|
+
if (typeof path !== "string" || !MEMORY_NOTE_PATH_RE.test(path)) return "";
|
|
18619
|
+
const text = rec.content ?? rec.new_string;
|
|
18620
|
+
return typeof text === "string" ? text.trim() : "";
|
|
18560
18621
|
}
|
|
18561
18622
|
|
|
18562
18623
|
// src/core/inject.ts
|
|
@@ -18760,7 +18821,7 @@ async function buildHookOutput(args) {
|
|
|
18760
18821
|
});
|
|
18761
18822
|
const blocks = [];
|
|
18762
18823
|
if (reflectAnswer && reflectRanThisTurn) blocks.push(buildSystemInjection(reflectAnswer));
|
|
18763
|
-
if (cadence > 0 && turns % cadence === 0) {
|
|
18824
|
+
if (cadence > 0 && turns % cadence === 0 && !(turns === 1 && args.preambleOnFirstTurn)) {
|
|
18764
18825
|
blocks.push(
|
|
18765
18826
|
buildRosterRefresh(pages, {
|
|
18766
18827
|
reflectOnNewGoals: cfg.autoInject !== "reflect",
|
|
@@ -18903,7 +18964,8 @@ var RuntimeCore = class {
|
|
|
18903
18964
|
prompt,
|
|
18904
18965
|
cfg: this.cfg,
|
|
18905
18966
|
client: this.client,
|
|
18906
|
-
cacheFile
|
|
18967
|
+
cacheFile,
|
|
18968
|
+
preambleOnFirstTurn: true
|
|
18907
18969
|
});
|
|
18908
18970
|
const blocks = [];
|
|
18909
18971
|
if (turns === 1) {
|