@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/kilo.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 = (file3) => {
|
|
27
|
+
try {
|
|
28
|
+
if (!statSync(file3).isFile()) return false;
|
|
29
|
+
if (platform !== "win32") accessSync(file3, 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 name of names) {
|
|
40
|
+
const file3 = join(dir, name);
|
|
41
|
+
if (runnable(file3)) return resolve(file3);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
47
|
+
function semverGte(version4, 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 = version4 ? parts(version4) : 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(file3, text) {
|
|
66
127
|
mkdirSync(dirname2(file3), { recursive: true, mode: 448 });
|
|
67
128
|
try {
|
|
68
|
-
if (
|
|
129
|
+
if (statSync2(file3).size >= LOG_MAX_BYTES) renameSync(file3, `${file3}.1`);
|
|
69
130
|
} catch {
|
|
70
131
|
}
|
|
71
132
|
appendFileSync(file3, 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 config3 = readTextOrNull(
|
|
233
|
+
const config3 = readTextOrNull(join5(commonDir, "config"));
|
|
173
234
|
return config3 !== null && /^\s*bare\s*=\s*true\s*$/im.test(config3);
|
|
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(map3, directory) {
|
|
@@ -397,7 +462,7 @@ function deriveBankIdOrSkip(config3, 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 = (file3) => {
|
|
668
|
-
try {
|
|
669
|
-
if (!statSync2(file3).isFile()) return false;
|
|
670
|
-
if (platform !== "win32") accessSync(file3, 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 name of names) {
|
|
681
|
-
const file3 = join6(dir, name);
|
|
682
|
-
if (runnable(file3)) return resolve2(file3);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
return void 0;
|
|
686
|
-
}
|
|
687
|
-
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
688
|
-
function semverGte(version4, 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 = version4 ? parts(version4) : 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} ${url3.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>").
|
|
@@ -17369,7 +17393,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
|
|
|
17369
17393
|
const mcpConfig = JSON.stringify({
|
|
17370
17394
|
mcpServers: {
|
|
17371
17395
|
hindsight: {
|
|
17372
|
-
command:
|
|
17396
|
+
command: nodeBinary(),
|
|
17373
17397
|
args: [opts.mcpServerPath],
|
|
17374
17398
|
// HINDSIGHT_MCP_HARNESS names the agent whose CLI this recipe drives — the survey's
|
|
17375
17399
|
// ingests are its writes. mcp-server.js REQUIRES it (it used to default to
|
|
@@ -17410,7 +17434,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
|
|
|
17410
17434
|
"--sandbox",
|
|
17411
17435
|
"read-only",
|
|
17412
17436
|
"-c",
|
|
17413
|
-
`mcp_servers.hindsight.command
|
|
17437
|
+
`mcp_servers.hindsight.command=${tomlValue(nodeBinary())}`,
|
|
17414
17438
|
"-c",
|
|
17415
17439
|
`mcp_servers.hindsight.args=${tomlValue([opts.mcpServerPath])}`,
|
|
17416
17440
|
"-c",
|
|
@@ -17497,7 +17521,7 @@ async function startCodebaseSurvey(repoDir, opts = {}) {
|
|
|
17497
17521
|
const supervisorPath = opts.supervisorPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "survey-supervisor.js");
|
|
17498
17522
|
return await new Promise((resolve4) => {
|
|
17499
17523
|
try {
|
|
17500
|
-
const child = spawnFn(
|
|
17524
|
+
const child = spawnFn(nodeBinary(), [supervisorPath], {
|
|
17501
17525
|
cwd: repoDir,
|
|
17502
17526
|
detached: true,
|
|
17503
17527
|
stdio: "ignore",
|
|
@@ -17691,7 +17715,7 @@ function buildPageTools(client, bankId, opts = {}) {
|
|
|
17691
17715
|
},
|
|
17692
17716
|
{
|
|
17693
17717
|
name: "hindsight_search_pages",
|
|
17694
|
-
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
|
|
17718
|
+
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,
|
|
17695
17719
|
inputSchema: { query: external_exports.string().describe("what to look for") },
|
|
17696
17720
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
17697
17721
|
handler: async (args) => {
|
|
@@ -18271,10 +18295,15 @@ function detectLegacyClaudePlugin(cwd, claudeDir = join16(homedir8(), ".claude")
|
|
|
18271
18295
|
const registry3 = readJson(join16(claudeDir, "plugins", "installed_plugins.json"));
|
|
18272
18296
|
const plugins = registry3?.plugins;
|
|
18273
18297
|
if (!plugins || typeof plugins !== "object") return void 0;
|
|
18274
|
-
const
|
|
18298
|
+
const enabledMaps = [
|
|
18299
|
+
join16(cwd, ".claude", "settings.local.json"),
|
|
18300
|
+
join16(cwd, ".claude", "settings.json"),
|
|
18301
|
+
join16(claudeDir, "settings.json")
|
|
18302
|
+
].map((path) => readJson(path)?.enabledPlugins);
|
|
18275
18303
|
for (const [key, raw] of Object.entries(plugins)) {
|
|
18276
18304
|
if (key.split("@")[0] !== LEGACY_CLAUDE_PLUGIN) continue;
|
|
18277
|
-
|
|
18305
|
+
const setting = enabledMaps.find((m) => m && typeof m[key] === "boolean")?.[key];
|
|
18306
|
+
if (setting === false) continue;
|
|
18278
18307
|
const installs = Array.isArray(raw) ? raw : [raw];
|
|
18279
18308
|
const active = installs.some((i) => {
|
|
18280
18309
|
if (!i || typeof i !== "object") return false;
|
|
@@ -18372,6 +18401,7 @@ async function buildSessionStartContext(args) {
|
|
|
18372
18401
|
let cold;
|
|
18373
18402
|
let gitDocIds;
|
|
18374
18403
|
let bankEmpty = false;
|
|
18404
|
+
let deepening = false;
|
|
18375
18405
|
const harness = args.harness ?? "claude-code";
|
|
18376
18406
|
const hasGit = args.hasGit ?? hasGitHistory;
|
|
18377
18407
|
const startSeed = args.startSeed ?? startBackgroundSeed;
|
|
@@ -18425,6 +18455,7 @@ async function buildSessionStartContext(args) {
|
|
|
18425
18455
|
}
|
|
18426
18456
|
if (docIds !== void 0) {
|
|
18427
18457
|
startSeed(cwd, { limit: cfg.seedLimit, harness });
|
|
18458
|
+
deepening = true;
|
|
18428
18459
|
if (cold) {
|
|
18429
18460
|
if (cfg.codebaseSurvey !== false) {
|
|
18430
18461
|
const sha = resolveHeadSha(cwd);
|
|
@@ -18474,6 +18505,14 @@ async function buildSessionStartContext(args) {
|
|
|
18474
18505
|
}
|
|
18475
18506
|
}
|
|
18476
18507
|
}
|
|
18508
|
+
if (!deepening) {
|
|
18509
|
+
await client.configureBankSettings?.({
|
|
18510
|
+
manage: cfg.manageBankConfig,
|
|
18511
|
+
extractionMode: cfg.retainExtractionMode,
|
|
18512
|
+
defaults: cfg.defaultBankConfig
|
|
18513
|
+
}).catch(() => {
|
|
18514
|
+
});
|
|
18515
|
+
}
|
|
18477
18516
|
let pages = [];
|
|
18478
18517
|
try {
|
|
18479
18518
|
pages = parsePageList(await client.listPages());
|
|
@@ -18513,10 +18552,14 @@ ${legacyClaudePluginWarning(legacyPlugin)}`;
|
|
|
18513
18552
|
import { existsSync as existsSync8 } from "fs";
|
|
18514
18553
|
|
|
18515
18554
|
// src/core/transcript-util.ts
|
|
18555
|
+
var TOOL_TEXT_CAP = 2e3;
|
|
18516
18556
|
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;
|
|
18517
18557
|
function stripInjectedMemory(s) {
|
|
18518
18558
|
return s.replace(MEMORY_TAG_RE, "");
|
|
18519
18559
|
}
|
|
18560
|
+
function truncate(s, max = TOOL_TEXT_CAP) {
|
|
18561
|
+
return s.length > max ? `${s.slice(0, max)}\u2026 (truncated)` : s;
|
|
18562
|
+
}
|
|
18520
18563
|
var TARGET_KEYS = [
|
|
18521
18564
|
"file_path",
|
|
18522
18565
|
"path",
|
|
@@ -18544,7 +18587,25 @@ function actionLine(tool2, input) {
|
|
|
18544
18587
|
target = input.trim().split("\n")[0];
|
|
18545
18588
|
}
|
|
18546
18589
|
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
18547
|
-
|
|
18590
|
+
const line = target ? `${tool2} ${target}` : tool2;
|
|
18591
|
+
const note = memoryNoteText(input);
|
|
18592
|
+
return note ? `${line}
|
|
18593
|
+
${truncate(note, MEMORY_NOTE_CAP)}` : line;
|
|
18594
|
+
}
|
|
18595
|
+
var MEMORY_NOTE_CAP = 8e3;
|
|
18596
|
+
var MEMORY_NOTE_PATH_RE = /(^|[\\/])(memory|memories)[\\/]|(^|[\\/])MEMORY\.md$/i;
|
|
18597
|
+
var MEMORY_SHELL_WRITE_RE = /[\\/](memory|memories)([\\/\s"']|$)|MEMORY\.md/i;
|
|
18598
|
+
var SHELL_WRITE_RE = /(^|[^0-9&>])>>?(?!&)|\btee\b/;
|
|
18599
|
+
function memoryNoteText(input) {
|
|
18600
|
+
if (!input || typeof input !== "object") return "";
|
|
18601
|
+
const rec = input;
|
|
18602
|
+
const cmd = rec.command;
|
|
18603
|
+
if (typeof cmd === "string")
|
|
18604
|
+
return MEMORY_SHELL_WRITE_RE.test(cmd) && SHELL_WRITE_RE.test(cmd) ? cmd.trim() : "";
|
|
18605
|
+
const path = rec.file_path ?? rec.path;
|
|
18606
|
+
if (typeof path !== "string" || !MEMORY_NOTE_PATH_RE.test(path)) return "";
|
|
18607
|
+
const text = rec.content ?? rec.new_string;
|
|
18608
|
+
return typeof text === "string" ? text.trim() : "";
|
|
18548
18609
|
}
|
|
18549
18610
|
|
|
18550
18611
|
// src/core/inject.ts
|
|
@@ -18748,7 +18809,7 @@ async function buildHookOutput(args) {
|
|
|
18748
18809
|
});
|
|
18749
18810
|
const blocks = [];
|
|
18750
18811
|
if (reflectAnswer && reflectRanThisTurn) blocks.push(buildSystemInjection(reflectAnswer));
|
|
18751
|
-
if (cadence > 0 && turns % cadence === 0) {
|
|
18812
|
+
if (cadence > 0 && turns % cadence === 0 && !(turns === 1 && args.preambleOnFirstTurn)) {
|
|
18752
18813
|
blocks.push(
|
|
18753
18814
|
buildRosterRefresh(pages, {
|
|
18754
18815
|
reflectOnNewGoals: cfg.autoInject !== "reflect",
|
|
@@ -18891,7 +18952,8 @@ var RuntimeCore = class {
|
|
|
18891
18952
|
prompt,
|
|
18892
18953
|
cfg: this.cfg,
|
|
18893
18954
|
client: this.client,
|
|
18894
|
-
cacheFile
|
|
18955
|
+
cacheFile,
|
|
18956
|
+
preambleOnFirstTurn: true
|
|
18895
18957
|
});
|
|
18896
18958
|
const blocks = [];
|
|
18897
18959
|
if (turns === 1) {
|