@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.
Files changed (62) hide show
  1. package/README.md +8 -3
  2. package/dist/antigravity-hook.js +150 -57
  3. package/dist/antigravity-statusline.js +30 -24
  4. package/dist/antigravity-stop-hook.js +160 -57
  5. package/dist/claude-hook.js +150 -57
  6. package/dist/claude-sessionstart-hook.js +176 -86
  7. package/dist/claude-stop-hook.js +160 -57
  8. package/dist/cline.js +132 -92
  9. package/dist/codebuddy-hook.js +150 -57
  10. package/dist/codebuddy-sessionstart-hook.js +176 -86
  11. package/dist/codebuddy-stop-hook.js +160 -57
  12. package/dist/codex-hook.js +150 -57
  13. package/dist/codex-sessionstart-hook.js +176 -86
  14. package/dist/codex-stop-hook.js +160 -57
  15. package/dist/copilot-hook.js +150 -57
  16. package/dist/copilot-sessionstart-hook.js +176 -86
  17. package/dist/copilot-stop-hook.js +160 -57
  18. package/dist/cursor-hook.js +150 -57
  19. package/dist/cursor-sessionstart-hook.js +176 -86
  20. package/dist/cursor-stop-hook.js +160 -57
  21. package/dist/daemon-start.js +20 -16
  22. package/dist/dcode-hook.js +150 -57
  23. package/dist/dcode-sessionstart-hook.js +176 -86
  24. package/dist/dcode-stop-hook.js +160 -57
  25. package/dist/deepen.js +19 -5
  26. package/dist/devin-hook.js +150 -57
  27. package/dist/devin-sessionstart-hook.js +176 -86
  28. package/dist/devin-stop-hook.js +160 -57
  29. package/dist/droid-hook.js +150 -57
  30. package/dist/droid-sessionstart-hook.js +176 -86
  31. package/dist/droid-stop-hook.js +160 -57
  32. package/dist/dsh.js +155 -93
  33. package/dist/grok-hook.js +150 -57
  34. package/dist/grok-sessionstart-hook.js +176 -86
  35. package/dist/grok-stop-hook.js +160 -57
  36. package/dist/hindsight-seed.js +35 -26
  37. package/dist/index.js +155 -93
  38. package/dist/installer.js +143 -41
  39. package/dist/kilo.js +155 -93
  40. package/dist/kimi-hook.js +150 -57
  41. package/dist/kimi-sessionstart-hook.js +176 -86
  42. package/dist/kimi-stop-hook.js +160 -57
  43. package/dist/mcp-server.js +73 -57
  44. package/dist/opencode2.js +155 -93
  45. package/dist/pi.js +155 -93
  46. package/dist/prime-agent.js +155 -93
  47. package/dist/qwen-hook.js +150 -57
  48. package/dist/qwen-sessionstart-hook.js +176 -86
  49. package/dist/qwen-stop-hook.js +160 -57
  50. package/dist/status.js +55 -39
  51. package/dist/traecode-hook.js +150 -57
  52. package/dist/traecode-sessionstart-hook.js +176 -86
  53. package/dist/traecode-stop-hook.js +160 -57
  54. package/dist/workbuddy-hook.js +150 -57
  55. package/dist/workbuddy-sessionstart-hook.js +176 -86
  56. package/dist/workbuddy-stop-hook.js +160 -57
  57. package/dist/zcode-hook.js +150 -57
  58. package/dist/zcode-sessionstart-hook.js +176 -86
  59. package/dist/zcode-stop-hook.js +160 -57
  60. package/package.json +1 -1
  61. package/plugin.json +1 -1
  62. package/skill/SKILL.md +8 -3
package/dist/cline.js CHANGED
@@ -11,16 +11,77 @@ import { join as join7 } from "path";
11
11
 
12
12
  // src/core/seed.ts
13
13
  import { spawn as realSpawn } from "child_process";
14
- import { dirname, join } from "path";
14
+ import { dirname, join as join2 } from "path";
15
15
  import { fileURLToPath } from "url";
16
+
17
+ // src/core/util.ts
18
+ import { accessSync, constants, statSync } from "fs";
19
+ import { delimiter, extname, isAbsolute, join, resolve } from "path";
20
+ function binOnPath(bin, opts = {}) {
21
+ const platform = opts.platform ?? process.platform;
22
+ const env = opts.env ?? process.env;
23
+ const runnable = (file2) => {
24
+ try {
25
+ if (!statSync(file2).isFile()) return false;
26
+ if (platform !== "win32") accessSync(file2, constants.X_OK);
27
+ return true;
28
+ } catch {
29
+ return false;
30
+ }
31
+ };
32
+ if (isAbsolute(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve(bin) : void 0;
33
+ const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
34
+ for (const dir of (env.PATH || "").split(delimiter)) {
35
+ if (!dir) continue;
36
+ for (const name of names) {
37
+ const file2 = join(dir, name);
38
+ if (runnable(file2)) return resolve(file2);
39
+ }
40
+ }
41
+ return void 0;
42
+ }
43
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
44
+ function semverGte(version3, min) {
45
+ const parts = (v) => {
46
+ const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
47
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
48
+ };
49
+ const a = version3 ? parts(version3) : void 0;
50
+ const b = parts(min);
51
+ if (!a || !b) return false;
52
+ for (let i = 0; i < 3; i++) {
53
+ if (a[i] !== b[i]) return a[i] > b[i];
54
+ }
55
+ return true;
56
+ }
57
+ async function pool(items, n, fn, onError, onProgress) {
58
+ let i = 0, done = 0;
59
+ async function worker() {
60
+ while (i < items.length) {
61
+ const idx = i++;
62
+ try {
63
+ await fn(items[idx], idx);
64
+ } catch (e) {
65
+ onError?.(idx, e);
66
+ }
67
+ onProgress?.(++done, items.length);
68
+ }
69
+ }
70
+ await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
71
+ }
72
+ function nodeBinary() {
73
+ return process.versions.bun || process.versions.electron ? "node" : process.execPath;
74
+ }
75
+
76
+ // src/core/seed.ts
16
77
  var DEFAULT_SEED_LIMIT = 300;
17
78
  function startBackgroundSeed(repoDir, opts = {}) {
18
79
  try {
19
80
  const spawnFn = opts.spawn ?? realSpawn;
20
- const enginePath = opts.enginePath ?? join(dirname(fileURLToPath(import.meta.url)), "deepen.js");
81
+ const enginePath = opts.enginePath ?? join2(dirname(fileURLToPath(import.meta.url)), "deepen.js");
21
82
  const limit = opts.limit ?? DEFAULT_SEED_LIMIT;
22
83
  const child = spawnFn(
23
- "node",
84
+ nodeBinary(),
24
85
  [
25
86
  enginePath,
26
87
  "--repo",
@@ -45,24 +106,24 @@ function startBackgroundSeed(repoDir, opts = {}) {
45
106
  // src/core/bank.ts
46
107
  import { existsSync } from "fs";
47
108
  import { homedir as homedir2 } from "os";
48
- import { basename, dirname as dirname4, join as join5, normalize, sep } from "path";
109
+ import { basename, dirname as dirname4, join as join6, normalize, sep } from "path";
49
110
 
50
111
  // src/core/diag.ts
51
112
  import { readFileSync } from "fs";
52
- import { join as join3 } from "path";
113
+ import { join as join4 } from "path";
53
114
 
54
115
  // src/core/log.ts
55
- import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
116
+ import { appendFileSync, mkdirSync, renameSync, statSync as statSync2 } from "fs";
56
117
  import { homedir } from "os";
57
- import { dirname as dirname2, join as join2 } from "path";
118
+ import { dirname as dirname2, join as join3 } from "path";
58
119
  function logsDir() {
59
- return join2(homedir(), ".hindsight", "coding-agents-logs");
120
+ return join3(homedir(), ".hindsight", "coding-agents-logs");
60
121
  }
61
122
  var LOG_MAX_BYTES = 10 * 1024 * 1024;
62
123
  function appendLogLine(file2, text) {
63
124
  mkdirSync(dirname2(file2), { recursive: true, mode: 448 });
64
125
  try {
65
- if (statSync(file2).size >= LOG_MAX_BYTES) renameSync(file2, `${file2}.1`);
126
+ if (statSync2(file2).size >= LOG_MAX_BYTES) renameSync(file2, `${file2}.1`);
66
127
  } catch {
67
128
  }
68
129
  appendFileSync(file2, text, { mode: 384 });
@@ -75,7 +136,7 @@ function setLogLevel(level) {
75
136
  if (!process.env.HINDSIGHT_LOG_LEVEL) current = level;
76
137
  }
77
138
  function logFilePath() {
78
- return process.env.HINDSIGHT_LOG_FILE || join2(logsDir(), "plugin.log");
139
+ return process.env.HINDSIGHT_LOG_FILE || join3(logsDir(), "plugin.log");
79
140
  }
80
141
  function write(level, scope, msg, extra) {
81
142
  if (WEIGHT[level] < WEIGHT[current]) return;
@@ -110,7 +171,7 @@ function describeError(value, maxChars = 200) {
110
171
 
111
172
  // src/core/diag.ts
112
173
  function diagFilePath() {
113
- return process.env.HINDSIGHT_DIAG_FILE || join3(logsDir(), "diag.jsonl");
174
+ return process.env.HINDSIGHT_DIAG_FILE || join4(logsDir(), "diag.jsonl");
114
175
  }
115
176
  function diag(harness, event, extra = {}) {
116
177
  log.debug(harness, `diag:${event}`, extra);
@@ -125,7 +186,7 @@ function diag(harness, event, extra = {}) {
125
186
 
126
187
  // src/core/git-layout.ts
127
188
  import { lstatSync, readFileSync as readFileSync2, realpathSync } from "fs";
128
- import { dirname as dirname3, isAbsolute, join as join4, resolve } from "path";
189
+ import { dirname as dirname3, isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "path";
129
190
  var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
130
191
  var ATTEMPTS = 3;
131
192
  var BACKOFF_MS = 20;
@@ -158,19 +219,19 @@ function gitDirFromPointer(text, holder) {
158
219
  const match = /^\s*gitdir:\s*(.+?)\s*$/m.exec(text);
159
220
  if (!match) return null;
160
221
  const target = match[1];
161
- return isAbsolute(target) ? target : resolve(holder, target);
222
+ return isAbsolute2(target) ? target : resolve2(holder, target);
162
223
  }
163
224
  function commonDirOf(gitDir) {
164
- const pointer = entryKind(join4(gitDir, "commondir")) === "file" ? readTextOrNull(join4(gitDir, "commondir"))?.trim() : null;
225
+ const pointer = entryKind(join5(gitDir, "commondir")) === "file" ? readTextOrNull(join5(gitDir, "commondir"))?.trim() : null;
165
226
  if (!pointer) return gitDir;
166
- return isAbsolute(pointer) ? pointer : resolve(gitDir, pointer);
227
+ return isAbsolute2(pointer) ? pointer : resolve2(gitDir, pointer);
167
228
  }
168
229
  function isBare(commonDir) {
169
- const config2 = readTextOrNull(join4(commonDir, "config"));
230
+ const config2 = readTextOrNull(join5(commonDir, "config"));
170
231
  return config2 !== null && /^\s*bare\s*=\s*true\s*$/im.test(config2);
171
232
  }
172
233
  function looksLikeBareRepository(directory) {
173
- return entryKind(join4(directory, "HEAD")) === "file" && entryKind(join4(directory, "objects")) === "dir" && entryKind(join4(directory, "refs")) === "dir";
234
+ return entryKind(join5(directory, "HEAD")) === "file" && entryKind(join5(directory, "objects")) === "dir" && entryKind(join5(directory, "refs")) === "dir";
174
235
  }
175
236
  function canonical(path) {
176
237
  try {
@@ -185,9 +246,9 @@ function resolved(commonDir) {
185
246
  return { status: "resolved", commonDir: canonicalDir, bare: isBare(canonicalDir) };
186
247
  }
187
248
  function probeOnce(directory) {
188
- let current2 = resolve(directory);
249
+ let current2 = resolve2(directory);
189
250
  for (; ; ) {
190
- const dotGit = join4(current2, ".git");
251
+ const dotGit = join5(current2, ".git");
191
252
  const kind = entryKind(dotGit);
192
253
  if (kind === "dir") {
193
254
  const layout = resolved(commonDirOf(dotGit));
@@ -301,10 +362,14 @@ function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
301
362
  return dirName(sessionRoot || directory);
302
363
  }
303
364
  function configuredDir(dir) {
304
- const expanded = dir === "~" || dir.startsWith("~/") ? join5(homedir2(), dir.slice(1)) : dir;
365
+ const expanded = dir === "~" || dir.startsWith("~/") ? join6(homedir2(), dir.slice(1)) : dir;
305
366
  return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
306
367
  }
307
- function isWithin(directory, configured) {
368
+ function isWithin(directory, configured, platform = process.platform) {
369
+ if (platform === "win32") {
370
+ directory = directory.toLowerCase();
371
+ configured = configured.toLowerCase();
372
+ }
308
373
  return directory === configured || directory.startsWith(configured + sep);
309
374
  }
310
375
  function mapLookup(map2, directory) {
@@ -394,7 +459,7 @@ function deriveBankIdOrSkip(config2, directory, harness = "coding", sessionRoot)
394
459
  import { createHash } from "crypto";
395
460
  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.";
396
461
  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.";
397
- 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.`;
462
+ 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.`;
398
463
  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.";
399
464
  var DOCUMENT_MISSION = "You are ingesting a standalone document (notes, docs, or structural findings). Extract the concrete facts, concepts, and structure it describes.";
400
465
  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.";
@@ -653,63 +718,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
653
718
  }
654
719
 
655
720
  // package.json
656
- var version = "0.8.7";
657
-
658
- // src/core/util.ts
659
- import { accessSync, constants, statSync as statSync2 } from "fs";
660
- import { delimiter, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "path";
661
- function binOnPath(bin, opts = {}) {
662
- const platform = opts.platform ?? process.platform;
663
- const env = opts.env ?? process.env;
664
- const runnable = (file2) => {
665
- try {
666
- if (!statSync2(file2).isFile()) return false;
667
- if (platform !== "win32") accessSync(file2, constants.X_OK);
668
- return true;
669
- } catch {
670
- return false;
671
- }
672
- };
673
- if (isAbsolute2(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve2(bin) : void 0;
674
- const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
675
- for (const dir of (env.PATH || "").split(delimiter)) {
676
- if (!dir) continue;
677
- for (const name of names) {
678
- const file2 = join6(dir, name);
679
- if (runnable(file2)) return resolve2(file2);
680
- }
681
- }
682
- return void 0;
683
- }
684
- var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
685
- function semverGte(version3, min) {
686
- const parts = (v) => {
687
- const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
688
- return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
689
- };
690
- const a = version3 ? parts(version3) : void 0;
691
- const b = parts(min);
692
- if (!a || !b) return false;
693
- for (let i = 0; i < 3; i++) {
694
- if (a[i] !== b[i]) return a[i] > b[i];
695
- }
696
- return true;
697
- }
698
- async function pool(items, n, fn, onError, onProgress) {
699
- let i = 0, done = 0;
700
- async function worker() {
701
- while (i < items.length) {
702
- const idx = i++;
703
- try {
704
- await fn(items[idx], idx);
705
- } catch (e) {
706
- onError?.(idx, e);
707
- }
708
- onProgress?.(++done, items.length);
709
- }
710
- }
711
- await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
712
- }
721
+ var version = "0.8.8";
713
722
 
714
723
  // src/core/hindsight.ts
715
724
  var USER_AGENT = `hindsight-coding-agents/${version}`;
@@ -921,7 +930,9 @@ var HindsightClient = class {
921
930
  }
922
931
  if (!r.ok && r.status !== 404 && !tolerate.includes(r.status))
923
932
  throw new Error(
924
- `${method} ${url2} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
933
+ // Query dropped: an encoded search query filled the 200-char error cap and pushed the
934
+ // status and the server's reason out of the tool error (#6341).
935
+ `${method} ${url2.split("?")[0]} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
925
936
  );
926
937
  return r;
927
938
  }
@@ -1067,6 +1078,15 @@ var HindsightClient = class {
1067
1078
  await this.req("DELETE", this.bankUrl());
1068
1079
  this.log(`[bank] reset ${this.bank}`);
1069
1080
  }
1081
+ await this.configureBankSettings(opts);
1082
+ await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
1083
+ }
1084
+ /** The config half of `configureBank` (missions, retain strategies, entity labels), without
1085
+ * seeding pages. Session start calls it directly when the deepen engine — the usual caller of
1086
+ * `configureBank` — will not run (`autoSeed: false`, or a directory with no git history):
1087
+ * without it such a bank never got the `conversation` strategy, and every session write-back
1088
+ * was extracted with the server's generic rules instead of the plugin's mission. */
1089
+ async configureBankSettings(opts = {}) {
1070
1090
  if (opts.manage === false) {
1071
1091
  this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
1072
1092
  } else {
@@ -1082,7 +1102,6 @@ var HindsightClient = class {
1082
1102
  this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
1083
1103
  }
1084
1104
  }
1085
- await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
1086
1105
  }
1087
1106
  /**
1088
1107
  * This bank's own config OVERRIDES, or undefined when there are none to read.
@@ -2267,13 +2286,18 @@ function onPath(bin) {
2267
2286
  return false;
2268
2287
  }
2269
2288
  }
2289
+ var DAEMON_CONFIG_ENV = "HINDSIGHT_CODING_AGENTS_DAEMON_CONFIG";
2270
2290
  function startDaemonDetached(cfg, harness, spawnFn = realSpawn3) {
2271
2291
  try {
2272
2292
  const starter = join9(dirname6(fileURLToPath3(import.meta.url)), "daemon-start.js");
2273
- const child = spawnFn("node", [starter, "--harness", harness], {
2293
+ const child = spawnFn(nodeBinary(), [starter, "--harness", harness], {
2274
2294
  detached: true,
2275
2295
  stdio: "ignore",
2276
- windowsHide: true
2296
+ windowsHide: true,
2297
+ // The caller's config is already resolved for its directory and bank. Re-reading the file in
2298
+ // the starter lost `paths` / `banks` overrides, so a daemon enabled only there never started
2299
+ // (#6334).
2300
+ env: { ...process.env, [DAEMON_CONFIG_ENV]: JSON.stringify(cfg) }
2277
2301
  });
2278
2302
  child.on("error", () => {
2279
2303
  });
@@ -2379,7 +2403,7 @@ var TOOL_GUIDE = `- hindsight_search_pages(query) \u2014 FIRST STOP, and the way
2379
2403
  \u2022 you are implementing something new, or two parts have to fit together;
2380
2404
  \u2022 the user asks why something is the way it is, or what is left to do;
2381
2405
  \u2022 you are about to commit, and need to know what the change was supposed to honour.
2382
- It ranks the pages by relevance and returns the matching passage, which a page title cannot tell you. 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.
2406
+ 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.
2383
2407
  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.
2384
2408
  - 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.
2385
2409
  - hindsight_reflect(query) \u2014 when pages are too shallow and you need the WHY: deep reasoning over the repo's full memory for the past decision and exact values that explain a behavior or bug (slower \u2014 use deliberately, and credit results with a blockquote header "> \u{1F9E0} **From Hindsight memory** \u2014 <summary>").
@@ -17355,7 +17379,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
17355
17379
  const mcpConfig = JSON.stringify({
17356
17380
  mcpServers: {
17357
17381
  hindsight: {
17358
- command: "node",
17382
+ command: nodeBinary(),
17359
17383
  args: [opts.mcpServerPath],
17360
17384
  // HINDSIGHT_MCP_HARNESS names the agent whose CLI this recipe drives — the survey's
17361
17385
  // ingests are its writes. mcp-server.js REQUIRES it (it used to default to
@@ -17396,7 +17420,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
17396
17420
  "--sandbox",
17397
17421
  "read-only",
17398
17422
  "-c",
17399
- `mcp_servers.hindsight.command="node"`,
17423
+ `mcp_servers.hindsight.command=${tomlValue(nodeBinary())}`,
17400
17424
  "-c",
17401
17425
  `mcp_servers.hindsight.args=${tomlValue([opts.mcpServerPath])}`,
17402
17426
  "-c",
@@ -17483,7 +17507,7 @@ async function startCodebaseSurvey(repoDir, opts = {}) {
17483
17507
  const supervisorPath = opts.supervisorPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "survey-supervisor.js");
17484
17508
  return await new Promise((resolve4) => {
17485
17509
  try {
17486
- const child = spawnFn("node", [supervisorPath], {
17510
+ const child = spawnFn(nodeBinary(), [supervisorPath], {
17487
17511
  cwd: repoDir,
17488
17512
  detached: true,
17489
17513
  stdio: "ignore",
@@ -17677,7 +17701,7 @@ function buildPageTools(client, bankId, opts = {}) {
17677
17701
  },
17678
17702
  {
17679
17703
  name: "hindsight_search_pages",
17680
- description: "Search this repository's Hindsight pages for content relevant to a query \u2014 hybrid full-text + semantic search, server-side. Call this when the user's question may be answered by the project's accumulated knowledge (architecture, conventions, decisions, initiatives) rather than by reading code. Returns ranked pages with a relevance snippet; read a full page with hindsight_read_page. " + crediting,
17704
+ description: "Search this repository's Hindsight pages for content relevant to a query \u2014 hybrid full-text + semantic search, server-side. Call this when the user's question may be answered by the project's accumulated knowledge (architecture, conventions, decisions, initiatives) rather than by reading code. Returns ranked pages, each with its opening text (not the passage that matched, and not filtered by relevance); read a full page with hindsight_read_page. " + crediting,
17681
17705
  inputSchema: { query: external_exports.string().describe("what to look for") },
17682
17706
  annotations: READ_ONLY_ANNOTATIONS,
17683
17707
  handler: async (args) => {
@@ -18257,10 +18281,15 @@ function detectLegacyClaudePlugin(cwd, claudeDir = join16(homedir8(), ".claude")
18257
18281
  const registry2 = readJson(join16(claudeDir, "plugins", "installed_plugins.json"));
18258
18282
  const plugins = registry2?.plugins;
18259
18283
  if (!plugins || typeof plugins !== "object") return void 0;
18260
- const enabled = readJson(join16(claudeDir, "settings.json"))?.enabledPlugins;
18284
+ const enabledMaps = [
18285
+ join16(cwd, ".claude", "settings.local.json"),
18286
+ join16(cwd, ".claude", "settings.json"),
18287
+ join16(claudeDir, "settings.json")
18288
+ ].map((path) => readJson(path)?.enabledPlugins);
18261
18289
  for (const [key, raw] of Object.entries(plugins)) {
18262
18290
  if (key.split("@")[0] !== LEGACY_CLAUDE_PLUGIN) continue;
18263
- if (enabled && enabled[key] === false) continue;
18291
+ const setting = enabledMaps.find((m) => m && typeof m[key] === "boolean")?.[key];
18292
+ if (setting === false) continue;
18264
18293
  const installs = Array.isArray(raw) ? raw : [raw];
18265
18294
  const active = installs.some((i) => {
18266
18295
  if (!i || typeof i !== "object") return false;
@@ -18358,6 +18387,7 @@ async function buildSessionStartContext(args) {
18358
18387
  let cold;
18359
18388
  let gitDocIds;
18360
18389
  let bankEmpty = false;
18390
+ let deepening = false;
18361
18391
  const harness = args.harness ?? "claude-code";
18362
18392
  const hasGit = args.hasGit ?? hasGitHistory;
18363
18393
  const startSeed = args.startSeed ?? startBackgroundSeed;
@@ -18411,6 +18441,7 @@ async function buildSessionStartContext(args) {
18411
18441
  }
18412
18442
  if (docIds !== void 0) {
18413
18443
  startSeed(cwd, { limit: cfg.seedLimit, harness });
18444
+ deepening = true;
18414
18445
  if (cold) {
18415
18446
  if (cfg.codebaseSurvey !== false) {
18416
18447
  const sha = resolveHeadSha(cwd);
@@ -18460,6 +18491,14 @@ async function buildSessionStartContext(args) {
18460
18491
  }
18461
18492
  }
18462
18493
  }
18494
+ if (!deepening) {
18495
+ await client.configureBankSettings?.({
18496
+ manage: cfg.manageBankConfig,
18497
+ extractionMode: cfg.retainExtractionMode,
18498
+ defaults: cfg.defaultBankConfig
18499
+ }).catch(() => {
18500
+ });
18501
+ }
18463
18502
  let pages = [];
18464
18503
  try {
18465
18504
  pages = parsePageList(await client.listPages());
@@ -18705,7 +18744,7 @@ async function buildHookOutput(args) {
18705
18744
  });
18706
18745
  const blocks = [];
18707
18746
  if (reflectAnswer && reflectRanThisTurn) blocks.push(buildSystemInjection(reflectAnswer));
18708
- if (cadence > 0 && turns % cadence === 0) {
18747
+ if (cadence > 0 && turns % cadence === 0 && !(turns === 1 && args.preambleOnFirstTurn)) {
18709
18748
  blocks.push(
18710
18749
  buildRosterRefresh(pages, {
18711
18750
  reflectOnNewGoals: cfg.autoInject !== "reflect",
@@ -18848,7 +18887,8 @@ var RuntimeCore = class {
18848
18887
  prompt,
18849
18888
  cfg: this.cfg,
18850
18889
  client: this.client,
18851
- cacheFile
18890
+ cacheFile,
18891
+ preambleOnFirstTurn: true
18852
18892
  });
18853
18893
  const blocks = [];
18854
18894
  if (turns === 1) {