@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/dsh.js
CHANGED
|
@@ -14,16 +14,77 @@ import { join as join7 } from "path";
|
|
|
14
14
|
|
|
15
15
|
// src/core/seed.ts
|
|
16
16
|
import { spawn as realSpawn } from "child_process";
|
|
17
|
-
import { dirname, join } from "path";
|
|
17
|
+
import { dirname, join as join2 } from "path";
|
|
18
18
|
import { fileURLToPath } from "url";
|
|
19
|
+
|
|
20
|
+
// src/core/util.ts
|
|
21
|
+
import { accessSync, constants, statSync } from "fs";
|
|
22
|
+
import { delimiter, extname, isAbsolute, join, resolve } from "path";
|
|
23
|
+
function binOnPath(bin, opts = {}) {
|
|
24
|
+
const platform = opts.platform ?? process.platform;
|
|
25
|
+
const env = opts.env ?? process.env;
|
|
26
|
+
const runnable = (file2) => {
|
|
27
|
+
try {
|
|
28
|
+
if (!statSync(file2).isFile()) return false;
|
|
29
|
+
if (platform !== "win32") accessSync(file2, constants.X_OK);
|
|
30
|
+
return true;
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
if (isAbsolute(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve(bin) : void 0;
|
|
36
|
+
const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
|
|
37
|
+
for (const dir of (env.PATH || "").split(delimiter)) {
|
|
38
|
+
if (!dir) continue;
|
|
39
|
+
for (const name2 of names) {
|
|
40
|
+
const file2 = join(dir, name2);
|
|
41
|
+
if (runnable(file2)) return resolve(file2);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
47
|
+
function semverGte(version3, min) {
|
|
48
|
+
const parts = (v) => {
|
|
49
|
+
const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
|
|
50
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
|
|
51
|
+
};
|
|
52
|
+
const a = version3 ? parts(version3) : void 0;
|
|
53
|
+
const b = parts(min);
|
|
54
|
+
if (!a || !b) return false;
|
|
55
|
+
for (let i = 0; i < 3; i++) {
|
|
56
|
+
if (a[i] !== b[i]) return a[i] > b[i];
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
async function pool(items, n, fn, onError, onProgress) {
|
|
61
|
+
let i = 0, done = 0;
|
|
62
|
+
async function worker() {
|
|
63
|
+
while (i < items.length) {
|
|
64
|
+
const idx = i++;
|
|
65
|
+
try {
|
|
66
|
+
await fn(items[idx], idx);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
onError?.(idx, e);
|
|
69
|
+
}
|
|
70
|
+
onProgress?.(++done, items.length);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
|
|
74
|
+
}
|
|
75
|
+
function nodeBinary() {
|
|
76
|
+
return process.versions.bun || process.versions.electron ? "node" : process.execPath;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/core/seed.ts
|
|
19
80
|
var DEFAULT_SEED_LIMIT = 300;
|
|
20
81
|
function startBackgroundSeed(repoDir, opts = {}) {
|
|
21
82
|
try {
|
|
22
83
|
const spawnFn = opts.spawn ?? realSpawn;
|
|
23
|
-
const enginePath = opts.enginePath ??
|
|
84
|
+
const enginePath = opts.enginePath ?? join2(dirname(fileURLToPath(import.meta.url)), "deepen.js");
|
|
24
85
|
const limit = opts.limit ?? DEFAULT_SEED_LIMIT;
|
|
25
86
|
const child = spawnFn(
|
|
26
|
-
|
|
87
|
+
nodeBinary(),
|
|
27
88
|
[
|
|
28
89
|
enginePath,
|
|
29
90
|
"--repo",
|
|
@@ -48,24 +109,24 @@ function startBackgroundSeed(repoDir, opts = {}) {
|
|
|
48
109
|
// src/core/bank.ts
|
|
49
110
|
import { existsSync } from "fs";
|
|
50
111
|
import { homedir as homedir2 } from "os";
|
|
51
|
-
import { basename, dirname as dirname4, join as
|
|
112
|
+
import { basename, dirname as dirname4, join as join6, normalize, sep } from "path";
|
|
52
113
|
|
|
53
114
|
// src/core/diag.ts
|
|
54
115
|
import { readFileSync } from "fs";
|
|
55
|
-
import { join as
|
|
116
|
+
import { join as join4 } from "path";
|
|
56
117
|
|
|
57
118
|
// src/core/log.ts
|
|
58
|
-
import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
|
|
119
|
+
import { appendFileSync, mkdirSync, renameSync, statSync as statSync2 } from "fs";
|
|
59
120
|
import { homedir } from "os";
|
|
60
|
-
import { dirname as dirname2, join as
|
|
121
|
+
import { dirname as dirname2, join as join3 } from "path";
|
|
61
122
|
function logsDir() {
|
|
62
|
-
return
|
|
123
|
+
return join3(homedir(), ".hindsight", "coding-agents-logs");
|
|
63
124
|
}
|
|
64
125
|
var LOG_MAX_BYTES = 10 * 1024 * 1024;
|
|
65
126
|
function appendLogLine(file2, text) {
|
|
66
127
|
mkdirSync(dirname2(file2), { recursive: true, mode: 448 });
|
|
67
128
|
try {
|
|
68
|
-
if (
|
|
129
|
+
if (statSync2(file2).size >= LOG_MAX_BYTES) renameSync(file2, `${file2}.1`);
|
|
69
130
|
} catch {
|
|
70
131
|
}
|
|
71
132
|
appendFileSync(file2, text, { mode: 384 });
|
|
@@ -78,7 +139,7 @@ function setLogLevel(level) {
|
|
|
78
139
|
if (!process.env.HINDSIGHT_LOG_LEVEL) current = level;
|
|
79
140
|
}
|
|
80
141
|
function logFilePath() {
|
|
81
|
-
return process.env.HINDSIGHT_LOG_FILE ||
|
|
142
|
+
return process.env.HINDSIGHT_LOG_FILE || join3(logsDir(), "plugin.log");
|
|
82
143
|
}
|
|
83
144
|
function write(level, scope, msg, extra) {
|
|
84
145
|
if (WEIGHT[level] < WEIGHT[current]) return;
|
|
@@ -113,7 +174,7 @@ function describeError(value, maxChars = 200) {
|
|
|
113
174
|
|
|
114
175
|
// src/core/diag.ts
|
|
115
176
|
function diagFilePath() {
|
|
116
|
-
return process.env.HINDSIGHT_DIAG_FILE ||
|
|
177
|
+
return process.env.HINDSIGHT_DIAG_FILE || join4(logsDir(), "diag.jsonl");
|
|
117
178
|
}
|
|
118
179
|
function diag(harness, event, extra = {}) {
|
|
119
180
|
log.debug(harness, `diag:${event}`, extra);
|
|
@@ -128,7 +189,7 @@ function diag(harness, event, extra = {}) {
|
|
|
128
189
|
|
|
129
190
|
// src/core/git-layout.ts
|
|
130
191
|
import { lstatSync, readFileSync as readFileSync2, realpathSync } from "fs";
|
|
131
|
-
import { dirname as dirname3, isAbsolute, join as
|
|
192
|
+
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "path";
|
|
132
193
|
var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
|
|
133
194
|
var ATTEMPTS = 3;
|
|
134
195
|
var BACKOFF_MS = 20;
|
|
@@ -161,19 +222,19 @@ function gitDirFromPointer(text, holder) {
|
|
|
161
222
|
const match = /^\s*gitdir:\s*(.+?)\s*$/m.exec(text);
|
|
162
223
|
if (!match) return null;
|
|
163
224
|
const target = match[1];
|
|
164
|
-
return
|
|
225
|
+
return isAbsolute2(target) ? target : resolve2(holder, target);
|
|
165
226
|
}
|
|
166
227
|
function commonDirOf(gitDir) {
|
|
167
|
-
const pointer = entryKind(
|
|
228
|
+
const pointer = entryKind(join5(gitDir, "commondir")) === "file" ? readTextOrNull(join5(gitDir, "commondir"))?.trim() : null;
|
|
168
229
|
if (!pointer) return gitDir;
|
|
169
|
-
return
|
|
230
|
+
return isAbsolute2(pointer) ? pointer : resolve2(gitDir, pointer);
|
|
170
231
|
}
|
|
171
232
|
function isBare(commonDir) {
|
|
172
|
-
const config2 = readTextOrNull(
|
|
233
|
+
const config2 = readTextOrNull(join5(commonDir, "config"));
|
|
173
234
|
return config2 !== null && /^\s*bare\s*=\s*true\s*$/im.test(config2);
|
|
174
235
|
}
|
|
175
236
|
function looksLikeBareRepository(directory) {
|
|
176
|
-
return entryKind(
|
|
237
|
+
return entryKind(join5(directory, "HEAD")) === "file" && entryKind(join5(directory, "objects")) === "dir" && entryKind(join5(directory, "refs")) === "dir";
|
|
177
238
|
}
|
|
178
239
|
function canonical(path) {
|
|
179
240
|
try {
|
|
@@ -188,9 +249,9 @@ function resolved(commonDir) {
|
|
|
188
249
|
return { status: "resolved", commonDir: canonicalDir, bare: isBare(canonicalDir) };
|
|
189
250
|
}
|
|
190
251
|
function probeOnce(directory) {
|
|
191
|
-
let current2 =
|
|
252
|
+
let current2 = resolve2(directory);
|
|
192
253
|
for (; ; ) {
|
|
193
|
-
const dotGit =
|
|
254
|
+
const dotGit = join5(current2, ".git");
|
|
194
255
|
const kind = entryKind(dotGit);
|
|
195
256
|
if (kind === "dir") {
|
|
196
257
|
const layout = resolved(commonDirOf(dotGit));
|
|
@@ -304,10 +365,14 @@ function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
|
|
|
304
365
|
return dirName(sessionRoot || directory);
|
|
305
366
|
}
|
|
306
367
|
function configuredDir(dir) {
|
|
307
|
-
const expanded = dir === "~" || dir.startsWith("~/") ?
|
|
368
|
+
const expanded = dir === "~" || dir.startsWith("~/") ? join6(homedir2(), dir.slice(1)) : dir;
|
|
308
369
|
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
309
370
|
}
|
|
310
|
-
function isWithin(directory, configured) {
|
|
371
|
+
function isWithin(directory, configured, platform = process.platform) {
|
|
372
|
+
if (platform === "win32") {
|
|
373
|
+
directory = directory.toLowerCase();
|
|
374
|
+
configured = configured.toLowerCase();
|
|
375
|
+
}
|
|
311
376
|
return directory === configured || directory.startsWith(configured + sep);
|
|
312
377
|
}
|
|
313
378
|
function mapLookup(map2, directory) {
|
|
@@ -397,7 +462,7 @@ function deriveBankIdOrSkip(config2, directory, harness = "coding", sessionRoot)
|
|
|
397
462
|
import { createHash } from "crypto";
|
|
398
463
|
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.";
|
|
399
464
|
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.";
|
|
400
|
-
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.`;
|
|
465
|
+
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.`;
|
|
401
466
|
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.";
|
|
402
467
|
var DOCUMENT_MISSION = "You are ingesting a standalone document (notes, docs, or structural findings). Extract the concrete facts, concepts, and structure it describes.";
|
|
403
468
|
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.";
|
|
@@ -656,63 +721,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
656
721
|
}
|
|
657
722
|
|
|
658
723
|
// package.json
|
|
659
|
-
var version = "0.8.
|
|
660
|
-
|
|
661
|
-
// src/core/util.ts
|
|
662
|
-
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
663
|
-
import { delimiter, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "path";
|
|
664
|
-
function binOnPath(bin, opts = {}) {
|
|
665
|
-
const platform = opts.platform ?? process.platform;
|
|
666
|
-
const env = opts.env ?? process.env;
|
|
667
|
-
const runnable = (file2) => {
|
|
668
|
-
try {
|
|
669
|
-
if (!statSync2(file2).isFile()) return false;
|
|
670
|
-
if (platform !== "win32") accessSync(file2, constants.X_OK);
|
|
671
|
-
return true;
|
|
672
|
-
} catch {
|
|
673
|
-
return false;
|
|
674
|
-
}
|
|
675
|
-
};
|
|
676
|
-
if (isAbsolute2(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve2(bin) : void 0;
|
|
677
|
-
const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
|
|
678
|
-
for (const dir of (env.PATH || "").split(delimiter)) {
|
|
679
|
-
if (!dir) continue;
|
|
680
|
-
for (const name2 of names) {
|
|
681
|
-
const file2 = join6(dir, name2);
|
|
682
|
-
if (runnable(file2)) return resolve2(file2);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
return void 0;
|
|
686
|
-
}
|
|
687
|
-
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
688
|
-
function semverGte(version3, min) {
|
|
689
|
-
const parts = (v) => {
|
|
690
|
-
const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
|
|
691
|
-
return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
|
|
692
|
-
};
|
|
693
|
-
const a = version3 ? parts(version3) : void 0;
|
|
694
|
-
const b = parts(min);
|
|
695
|
-
if (!a || !b) return false;
|
|
696
|
-
for (let i = 0; i < 3; i++) {
|
|
697
|
-
if (a[i] !== b[i]) return a[i] > b[i];
|
|
698
|
-
}
|
|
699
|
-
return true;
|
|
700
|
-
}
|
|
701
|
-
async function pool(items, n, fn, onError, onProgress) {
|
|
702
|
-
let i = 0, done = 0;
|
|
703
|
-
async function worker() {
|
|
704
|
-
while (i < items.length) {
|
|
705
|
-
const idx = i++;
|
|
706
|
-
try {
|
|
707
|
-
await fn(items[idx], idx);
|
|
708
|
-
} catch (e) {
|
|
709
|
-
onError?.(idx, e);
|
|
710
|
-
}
|
|
711
|
-
onProgress?.(++done, items.length);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
|
|
715
|
-
}
|
|
724
|
+
var version = "0.8.8";
|
|
716
725
|
|
|
717
726
|
// src/core/hindsight.ts
|
|
718
727
|
var USER_AGENT = `hindsight-coding-agents/${version}`;
|
|
@@ -924,7 +933,9 @@ var HindsightClient = class {
|
|
|
924
933
|
}
|
|
925
934
|
if (!r.ok && r.status !== 404 && !tolerate.includes(r.status))
|
|
926
935
|
throw new Error(
|
|
927
|
-
|
|
936
|
+
// Query dropped: an encoded search query filled the 200-char error cap and pushed the
|
|
937
|
+
// status and the server's reason out of the tool error (#6341).
|
|
938
|
+
`${method} ${url2.split("?")[0]} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
|
|
928
939
|
);
|
|
929
940
|
return r;
|
|
930
941
|
}
|
|
@@ -1070,6 +1081,15 @@ var HindsightClient = class {
|
|
|
1070
1081
|
await this.req("DELETE", this.bankUrl());
|
|
1071
1082
|
this.log(`[bank] reset ${this.bank}`);
|
|
1072
1083
|
}
|
|
1084
|
+
await this.configureBankSettings(opts);
|
|
1085
|
+
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
1086
|
+
}
|
|
1087
|
+
/** The config half of `configureBank` (missions, retain strategies, entity labels), without
|
|
1088
|
+
* seeding pages. Session start calls it directly when the deepen engine — the usual caller of
|
|
1089
|
+
* `configureBank` — will not run (`autoSeed: false`, or a directory with no git history):
|
|
1090
|
+
* without it such a bank never got the `conversation` strategy, and every session write-back
|
|
1091
|
+
* was extracted with the server's generic rules instead of the plugin's mission. */
|
|
1092
|
+
async configureBankSettings(opts = {}) {
|
|
1073
1093
|
if (opts.manage === false) {
|
|
1074
1094
|
this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
|
|
1075
1095
|
} else {
|
|
@@ -1085,7 +1105,6 @@ var HindsightClient = class {
|
|
|
1085
1105
|
this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
|
|
1086
1106
|
}
|
|
1087
1107
|
}
|
|
1088
|
-
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
1089
1108
|
}
|
|
1090
1109
|
/**
|
|
1091
1110
|
* This bank's own config OVERRIDES, or undefined when there are none to read.
|
|
@@ -2270,13 +2289,18 @@ function onPath(bin) {
|
|
|
2270
2289
|
return false;
|
|
2271
2290
|
}
|
|
2272
2291
|
}
|
|
2292
|
+
var DAEMON_CONFIG_ENV = "HINDSIGHT_CODING_AGENTS_DAEMON_CONFIG";
|
|
2273
2293
|
function startDaemonDetached(cfg, harness, spawnFn = realSpawn3) {
|
|
2274
2294
|
try {
|
|
2275
2295
|
const starter = join9(dirname6(fileURLToPath3(import.meta.url)), "daemon-start.js");
|
|
2276
|
-
const child = spawnFn(
|
|
2296
|
+
const child = spawnFn(nodeBinary(), [starter, "--harness", harness], {
|
|
2277
2297
|
detached: true,
|
|
2278
2298
|
stdio: "ignore",
|
|
2279
|
-
windowsHide: true
|
|
2299
|
+
windowsHide: true,
|
|
2300
|
+
// The caller's config is already resolved for its directory and bank. Re-reading the file in
|
|
2301
|
+
// the starter lost `paths` / `banks` overrides, so a daemon enabled only there never started
|
|
2302
|
+
// (#6334).
|
|
2303
|
+
env: { ...process.env, [DAEMON_CONFIG_ENV]: JSON.stringify(cfg) }
|
|
2280
2304
|
});
|
|
2281
2305
|
child.on("error", () => {
|
|
2282
2306
|
});
|
|
@@ -2382,7 +2406,7 @@ var TOOL_GUIDE = `- hindsight_search_pages(query) \u2014 FIRST STOP, and the way
|
|
|
2382
2406
|
\u2022 you are implementing something new, or two parts have to fit together;
|
|
2383
2407
|
\u2022 the user asks why something is the way it is, or what is left to do;
|
|
2384
2408
|
\u2022 you are about to commit, and need to know what the change was supposed to honour.
|
|
2385
|
-
It ranks the pages by relevance and
|
|
2409
|
+
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.
|
|
2386
2410
|
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.
|
|
2387
2411
|
- 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.
|
|
2388
2412
|
- 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>").
|
|
@@ -17358,7 +17382,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
|
|
|
17358
17382
|
const mcpConfig = JSON.stringify({
|
|
17359
17383
|
mcpServers: {
|
|
17360
17384
|
hindsight: {
|
|
17361
|
-
command:
|
|
17385
|
+
command: nodeBinary(),
|
|
17362
17386
|
args: [opts.mcpServerPath],
|
|
17363
17387
|
// HINDSIGHT_MCP_HARNESS names the agent whose CLI this recipe drives — the survey's
|
|
17364
17388
|
// ingests are its writes. mcp-server.js REQUIRES it (it used to default to
|
|
@@ -17399,7 +17423,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
|
|
|
17399
17423
|
"--sandbox",
|
|
17400
17424
|
"read-only",
|
|
17401
17425
|
"-c",
|
|
17402
|
-
`mcp_servers.hindsight.command
|
|
17426
|
+
`mcp_servers.hindsight.command=${tomlValue(nodeBinary())}`,
|
|
17403
17427
|
"-c",
|
|
17404
17428
|
`mcp_servers.hindsight.args=${tomlValue([opts.mcpServerPath])}`,
|
|
17405
17429
|
"-c",
|
|
@@ -17486,7 +17510,7 @@ async function startCodebaseSurvey(repoDir, opts = {}) {
|
|
|
17486
17510
|
const supervisorPath = opts.supervisorPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "survey-supervisor.js");
|
|
17487
17511
|
return await new Promise((resolve4) => {
|
|
17488
17512
|
try {
|
|
17489
|
-
const child = spawnFn(
|
|
17513
|
+
const child = spawnFn(nodeBinary(), [supervisorPath], {
|
|
17490
17514
|
cwd: repoDir,
|
|
17491
17515
|
detached: true,
|
|
17492
17516
|
stdio: "ignore",
|
|
@@ -17680,7 +17704,7 @@ function buildPageTools(client, bankId, opts = {}) {
|
|
|
17680
17704
|
},
|
|
17681
17705
|
{
|
|
17682
17706
|
name: "hindsight_search_pages",
|
|
17683
|
-
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
|
|
17707
|
+
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,
|
|
17684
17708
|
inputSchema: { query: external_exports.string().describe("what to look for") },
|
|
17685
17709
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
17686
17710
|
handler: async (args) => {
|
|
@@ -18260,10 +18284,15 @@ function detectLegacyClaudePlugin(cwd, claudeDir = join16(homedir8(), ".claude")
|
|
|
18260
18284
|
const registry2 = readJson(join16(claudeDir, "plugins", "installed_plugins.json"));
|
|
18261
18285
|
const plugins = registry2?.plugins;
|
|
18262
18286
|
if (!plugins || typeof plugins !== "object") return void 0;
|
|
18263
|
-
const
|
|
18287
|
+
const enabledMaps = [
|
|
18288
|
+
join16(cwd, ".claude", "settings.local.json"),
|
|
18289
|
+
join16(cwd, ".claude", "settings.json"),
|
|
18290
|
+
join16(claudeDir, "settings.json")
|
|
18291
|
+
].map((path) => readJson(path)?.enabledPlugins);
|
|
18264
18292
|
for (const [key, raw] of Object.entries(plugins)) {
|
|
18265
18293
|
if (key.split("@")[0] !== LEGACY_CLAUDE_PLUGIN) continue;
|
|
18266
|
-
|
|
18294
|
+
const setting = enabledMaps.find((m) => m && typeof m[key] === "boolean")?.[key];
|
|
18295
|
+
if (setting === false) continue;
|
|
18267
18296
|
const installs = Array.isArray(raw) ? raw : [raw];
|
|
18268
18297
|
const active = installs.some((i) => {
|
|
18269
18298
|
if (!i || typeof i !== "object") return false;
|
|
@@ -18361,6 +18390,7 @@ async function buildSessionStartContext(args) {
|
|
|
18361
18390
|
let cold;
|
|
18362
18391
|
let gitDocIds;
|
|
18363
18392
|
let bankEmpty = false;
|
|
18393
|
+
let deepening = false;
|
|
18364
18394
|
const harness = args.harness ?? "claude-code";
|
|
18365
18395
|
const hasGit = args.hasGit ?? hasGitHistory;
|
|
18366
18396
|
const startSeed = args.startSeed ?? startBackgroundSeed;
|
|
@@ -18414,6 +18444,7 @@ async function buildSessionStartContext(args) {
|
|
|
18414
18444
|
}
|
|
18415
18445
|
if (docIds !== void 0) {
|
|
18416
18446
|
startSeed(cwd, { limit: cfg.seedLimit, harness });
|
|
18447
|
+
deepening = true;
|
|
18417
18448
|
if (cold) {
|
|
18418
18449
|
if (cfg.codebaseSurvey !== false) {
|
|
18419
18450
|
const sha = resolveHeadSha(cwd);
|
|
@@ -18463,6 +18494,14 @@ async function buildSessionStartContext(args) {
|
|
|
18463
18494
|
}
|
|
18464
18495
|
}
|
|
18465
18496
|
}
|
|
18497
|
+
if (!deepening) {
|
|
18498
|
+
await client.configureBankSettings?.({
|
|
18499
|
+
manage: cfg.manageBankConfig,
|
|
18500
|
+
extractionMode: cfg.retainExtractionMode,
|
|
18501
|
+
defaults: cfg.defaultBankConfig
|
|
18502
|
+
}).catch(() => {
|
|
18503
|
+
});
|
|
18504
|
+
}
|
|
18466
18505
|
let pages = [];
|
|
18467
18506
|
try {
|
|
18468
18507
|
pages = parsePageList(await client.listPages());
|
|
@@ -18502,10 +18541,14 @@ ${legacyClaudePluginWarning(legacyPlugin)}`;
|
|
|
18502
18541
|
import { existsSync as existsSync8 } from "fs";
|
|
18503
18542
|
|
|
18504
18543
|
// src/core/transcript-util.ts
|
|
18544
|
+
var TOOL_TEXT_CAP = 2e3;
|
|
18505
18545
|
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;
|
|
18506
18546
|
function stripInjectedMemory(s) {
|
|
18507
18547
|
return s.replace(MEMORY_TAG_RE, "");
|
|
18508
18548
|
}
|
|
18549
|
+
function truncate(s, max = TOOL_TEXT_CAP) {
|
|
18550
|
+
return s.length > max ? `${s.slice(0, max)}\u2026 (truncated)` : s;
|
|
18551
|
+
}
|
|
18509
18552
|
var TARGET_KEYS = [
|
|
18510
18553
|
"file_path",
|
|
18511
18554
|
"path",
|
|
@@ -18533,7 +18576,25 @@ function actionLine(tool, input) {
|
|
|
18533
18576
|
target = input.trim().split("\n")[0];
|
|
18534
18577
|
}
|
|
18535
18578
|
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
18536
|
-
|
|
18579
|
+
const line = target ? `${tool} ${target}` : tool;
|
|
18580
|
+
const note = memoryNoteText(input);
|
|
18581
|
+
return note ? `${line}
|
|
18582
|
+
${truncate(note, MEMORY_NOTE_CAP)}` : line;
|
|
18583
|
+
}
|
|
18584
|
+
var MEMORY_NOTE_CAP = 8e3;
|
|
18585
|
+
var MEMORY_NOTE_PATH_RE = /(^|[\\/])(memory|memories)[\\/]|(^|[\\/])MEMORY\.md$/i;
|
|
18586
|
+
var MEMORY_SHELL_WRITE_RE = /[\\/](memory|memories)([\\/\s"']|$)|MEMORY\.md/i;
|
|
18587
|
+
var SHELL_WRITE_RE = /(^|[^0-9&>])>>?(?!&)|\btee\b/;
|
|
18588
|
+
function memoryNoteText(input) {
|
|
18589
|
+
if (!input || typeof input !== "object") return "";
|
|
18590
|
+
const rec = input;
|
|
18591
|
+
const cmd = rec.command;
|
|
18592
|
+
if (typeof cmd === "string")
|
|
18593
|
+
return MEMORY_SHELL_WRITE_RE.test(cmd) && SHELL_WRITE_RE.test(cmd) ? cmd.trim() : "";
|
|
18594
|
+
const path = rec.file_path ?? rec.path;
|
|
18595
|
+
if (typeof path !== "string" || !MEMORY_NOTE_PATH_RE.test(path)) return "";
|
|
18596
|
+
const text = rec.content ?? rec.new_string;
|
|
18597
|
+
return typeof text === "string" ? text.trim() : "";
|
|
18537
18598
|
}
|
|
18538
18599
|
|
|
18539
18600
|
// src/core/inject.ts
|
|
@@ -18737,7 +18798,7 @@ async function buildHookOutput(args) {
|
|
|
18737
18798
|
});
|
|
18738
18799
|
const blocks = [];
|
|
18739
18800
|
if (reflectAnswer && reflectRanThisTurn) blocks.push(buildSystemInjection(reflectAnswer));
|
|
18740
|
-
if (cadence > 0 && turns % cadence === 0) {
|
|
18801
|
+
if (cadence > 0 && turns % cadence === 0 && !(turns === 1 && args.preambleOnFirstTurn)) {
|
|
18741
18802
|
blocks.push(
|
|
18742
18803
|
buildRosterRefresh(pages, {
|
|
18743
18804
|
reflectOnNewGoals: cfg.autoInject !== "reflect",
|
|
@@ -18880,7 +18941,8 @@ var RuntimeCore = class {
|
|
|
18880
18941
|
prompt,
|
|
18881
18942
|
cfg: this.cfg,
|
|
18882
18943
|
client: this.client,
|
|
18883
|
-
cacheFile
|
|
18944
|
+
cacheFile,
|
|
18945
|
+
preambleOnFirstTurn: true
|
|
18884
18946
|
});
|
|
18885
18947
|
const blocks = [];
|
|
18886
18948
|
if (turns === 1) {
|