@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
@@ -286,7 +286,11 @@ function configuredDir(dir) {
286
286
  const expanded = dir === "~" || dir.startsWith("~/") ? join4(homedir2(), dir.slice(1)) : dir;
287
287
  return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
288
288
  }
289
- function isWithin(directory, configured) {
289
+ function isWithin(directory, configured, platform = process.platform) {
290
+ if (platform === "win32") {
291
+ directory = directory.toLowerCase();
292
+ configured = configured.toLowerCase();
293
+ }
290
294
  return directory === configured || directory.startsWith(configured + sep);
291
295
  }
292
296
  function mapLookup(map, directory) {
@@ -379,16 +383,93 @@ import { join as join7 } from "path";
379
383
 
380
384
  // src/core/seed.ts
381
385
  import { spawn as realSpawn } from "child_process";
382
- import { dirname as dirname4, join as join5 } from "path";
386
+ import { dirname as dirname4, join as join6 } from "path";
383
387
  import { fileURLToPath } from "url";
388
+
389
+ // src/core/util.ts
390
+ import { accessSync, constants, statSync as statSync2 } from "fs";
391
+ import { delimiter, extname, isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "path";
392
+ function binOnPath(bin, opts = {}) {
393
+ const platform = opts.platform ?? process.platform;
394
+ const env = opts.env ?? process.env;
395
+ const runnable = (file) => {
396
+ try {
397
+ if (!statSync2(file).isFile()) return false;
398
+ if (platform !== "win32") accessSync(file, constants.X_OK);
399
+ return true;
400
+ } catch {
401
+ return false;
402
+ }
403
+ };
404
+ if (isAbsolute2(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve2(bin) : void 0;
405
+ const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
406
+ for (const dir of (env.PATH || "").split(delimiter)) {
407
+ if (!dir) continue;
408
+ for (const name of names) {
409
+ const file = join5(dir, name);
410
+ if (runnable(file)) return resolve2(file);
411
+ }
412
+ }
413
+ return void 0;
414
+ }
415
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
416
+ function semverGte(version2, min) {
417
+ const parts = (v) => {
418
+ const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
419
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
420
+ };
421
+ const a = version2 ? parts(version2) : void 0;
422
+ const b = parts(min);
423
+ if (!a || !b) return false;
424
+ for (let i = 0; i < 3; i++) {
425
+ if (a[i] !== b[i]) return a[i] > b[i];
426
+ }
427
+ return true;
428
+ }
429
+ async function pool(items, n, fn, onError, onProgress) {
430
+ let i = 0, done = 0;
431
+ async function worker() {
432
+ while (i < items.length) {
433
+ const idx = i++;
434
+ try {
435
+ await fn(items[idx], idx);
436
+ } catch (e) {
437
+ onError?.(idx, e);
438
+ }
439
+ onProgress?.(++done, items.length);
440
+ }
441
+ }
442
+ await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
443
+ }
444
+ function nodeBinary() {
445
+ return process.versions.bun || process.versions.electron ? "node" : process.execPath;
446
+ }
447
+ function hookNode(opts = {}) {
448
+ const platform = opts.platform ?? process.platform;
449
+ if (platform === "win32" || binOnPath("node", opts)) return "node";
450
+ return nodeBinary();
451
+ }
452
+ function isOurMcpEntry(entry) {
453
+ if (!entry || typeof entry !== "object") return false;
454
+ const candidate = entry;
455
+ const command = typeof candidate.command === "string" ? candidate.command : "";
456
+ const bin = command.replaceAll("\\", "/").split("/").at(-1);
457
+ if (bin !== "node" && bin !== "node.exe" || !Array.isArray(candidate.args)) return false;
458
+ const script = candidate.args[0];
459
+ if (typeof script !== "string") return false;
460
+ const parts = script.replaceAll("\\", "/").split("/").filter(Boolean);
461
+ return parts.at(-1) === "mcp-server.js" && parts.at(-2) === "dist" && (parts.at(-3) === "coding-agents" || parts.at(-3) === "hindsight-coding-agents");
462
+ }
463
+
464
+ // src/core/seed.ts
384
465
  var DEFAULT_SEED_LIMIT = 300;
385
466
  function startBackgroundSeed(repoDir, opts = {}) {
386
467
  try {
387
468
  const spawnFn = opts.spawn ?? realSpawn;
388
- const enginePath = opts.enginePath ?? join5(dirname4(fileURLToPath(import.meta.url)), "deepen.js");
469
+ const enginePath = opts.enginePath ?? join6(dirname4(fileURLToPath(import.meta.url)), "deepen.js");
389
470
  const limit = opts.limit ?? DEFAULT_SEED_LIMIT;
390
471
  const child = spawnFn(
391
- "node",
472
+ nodeBinary(),
392
473
  [
393
474
  enginePath,
394
475
  "--repo",
@@ -414,7 +495,7 @@ function startBackgroundSeed(repoDir, opts = {}) {
414
495
  import { createHash } from "crypto";
415
496
  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.";
416
497
  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.";
417
- 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.`;
498
+ 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.`;
418
499
  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.";
419
500
  var DOCUMENT_MISSION = "You are ingesting a standalone document (notes, docs, or structural findings). Extract the concrete facts, concepts, and structure it describes.";
420
501
  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.";
@@ -673,72 +754,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
673
754
  }
674
755
 
675
756
  // package.json
676
- var version = "0.8.7";
677
-
678
- // src/core/util.ts
679
- import { accessSync, constants, statSync as statSync2 } from "fs";
680
- import { delimiter, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "path";
681
- function binOnPath(bin, opts = {}) {
682
- const platform = opts.platform ?? process.platform;
683
- const env = opts.env ?? process.env;
684
- const runnable = (file) => {
685
- try {
686
- if (!statSync2(file).isFile()) return false;
687
- if (platform !== "win32") accessSync(file, constants.X_OK);
688
- return true;
689
- } catch {
690
- return false;
691
- }
692
- };
693
- if (isAbsolute2(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve2(bin) : void 0;
694
- const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
695
- for (const dir of (env.PATH || "").split(delimiter)) {
696
- if (!dir) continue;
697
- for (const name of names) {
698
- const file = join6(dir, name);
699
- if (runnable(file)) return resolve2(file);
700
- }
701
- }
702
- return void 0;
703
- }
704
- var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
705
- function semverGte(version2, min) {
706
- const parts = (v) => {
707
- const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
708
- return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
709
- };
710
- const a = version2 ? parts(version2) : void 0;
711
- const b = parts(min);
712
- if (!a || !b) return false;
713
- for (let i = 0; i < 3; i++) {
714
- if (a[i] !== b[i]) return a[i] > b[i];
715
- }
716
- return true;
717
- }
718
- async function pool(items, n, fn, onError, onProgress) {
719
- let i = 0, done = 0;
720
- async function worker() {
721
- while (i < items.length) {
722
- const idx = i++;
723
- try {
724
- await fn(items[idx], idx);
725
- } catch (e) {
726
- onError?.(idx, e);
727
- }
728
- onProgress?.(++done, items.length);
729
- }
730
- }
731
- await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
732
- }
733
- function isOurMcpEntry(entry) {
734
- if (!entry || typeof entry !== "object") return false;
735
- const candidate = entry;
736
- if (candidate.command !== "node" || !Array.isArray(candidate.args)) return false;
737
- const script = candidate.args[0];
738
- if (typeof script !== "string") return false;
739
- const parts = script.replaceAll("\\", "/").split("/").filter(Boolean);
740
- return parts.at(-1) === "mcp-server.js" && parts.at(-2) === "dist" && (parts.at(-3) === "coding-agents" || parts.at(-3) === "hindsight-coding-agents");
741
- }
757
+ var version = "0.8.8";
742
758
 
743
759
  // src/core/hindsight.ts
744
760
  var USER_AGENT = `hindsight-coding-agents/${version}`;
@@ -950,7 +966,9 @@ var HindsightClient = class {
950
966
  }
951
967
  if (!r.ok && r.status !== 404 && !tolerate.includes(r.status))
952
968
  throw new Error(
953
- `${method} ${url} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
969
+ // Query dropped: an encoded search query filled the 200-char error cap and pushed the
970
+ // status and the server's reason out of the tool error (#6341).
971
+ `${method} ${url.split("?")[0]} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
954
972
  );
955
973
  return r;
956
974
  }
@@ -1096,6 +1114,15 @@ var HindsightClient = class {
1096
1114
  await this.req("DELETE", this.bankUrl());
1097
1115
  this.log(`[bank] reset ${this.bank}`);
1098
1116
  }
1117
+ await this.configureBankSettings(opts);
1118
+ await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
1119
+ }
1120
+ /** The config half of `configureBank` (missions, retain strategies, entity labels), without
1121
+ * seeding pages. Session start calls it directly when the deepen engine — the usual caller of
1122
+ * `configureBank` — will not run (`autoSeed: false`, or a directory with no git history):
1123
+ * without it such a bank never got the `conversation` strategy, and every session write-back
1124
+ * was extracted with the server's generic rules instead of the plugin's mission. */
1125
+ async configureBankSettings(opts = {}) {
1099
1126
  if (opts.manage === false) {
1100
1127
  this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
1101
1128
  } else {
@@ -1111,7 +1138,6 @@ var HindsightClient = class {
1111
1138
  this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
1112
1139
  }
1113
1140
  }
1114
- await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
1115
1141
  }
1116
1142
  /**
1117
1143
  * This bank's own config OVERRIDES, or undefined when there are none to read.
@@ -1944,10 +1970,14 @@ function resolvePartial(cfg, patch) {
1944
1970
  }
1945
1971
 
1946
1972
  // src/core/transcript-util.ts
1973
+ var TOOL_TEXT_CAP = 2e3;
1947
1974
  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;
1948
1975
  function stripInjectedMemory(s) {
1949
1976
  return s.replace(MEMORY_TAG_RE, "");
1950
1977
  }
1978
+ function truncate(s, max = TOOL_TEXT_CAP) {
1979
+ return s.length > max ? `${s.slice(0, max)}\u2026 (truncated)` : s;
1980
+ }
1951
1981
  var TARGET_KEYS = [
1952
1982
  "file_path",
1953
1983
  "path",
@@ -1975,7 +2005,25 @@ function actionLine(tool, input) {
1975
2005
  target = input.trim().split("\n")[0];
1976
2006
  }
1977
2007
  if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
1978
- return target ? `${tool} ${target}` : tool;
2008
+ const line = target ? `${tool} ${target}` : tool;
2009
+ const note = memoryNoteText(input);
2010
+ return note ? `${line}
2011
+ ${truncate(note, MEMORY_NOTE_CAP)}` : line;
2012
+ }
2013
+ var MEMORY_NOTE_CAP = 8e3;
2014
+ var MEMORY_NOTE_PATH_RE = /(^|[\\/])(memory|memories)[\\/]|(^|[\\/])MEMORY\.md$/i;
2015
+ var MEMORY_SHELL_WRITE_RE = /[\\/](memory|memories)([\\/\s"']|$)|MEMORY\.md/i;
2016
+ var SHELL_WRITE_RE = /(^|[^0-9&>])>>?(?!&)|\btee\b/;
2017
+ function memoryNoteText(input) {
2018
+ if (!input || typeof input !== "object") return "";
2019
+ const rec = input;
2020
+ const cmd = rec.command;
2021
+ if (typeof cmd === "string")
2022
+ return MEMORY_SHELL_WRITE_RE.test(cmd) && SHELL_WRITE_RE.test(cmd) ? cmd.trim() : "";
2023
+ const path = rec.file_path ?? rec.path;
2024
+ if (typeof path !== "string" || !MEMORY_NOTE_PATH_RE.test(path)) return "";
2025
+ const text = rec.content ?? rec.new_string;
2026
+ return typeof text === "string" ? text.trim() : "";
1979
2027
  }
1980
2028
 
1981
2029
  // src/core/brand.ts
@@ -2015,7 +2063,7 @@ var TOOL_GUIDE = `- hindsight_search_pages(query) \u2014 FIRST STOP, and the way
2015
2063
  \u2022 you are implementing something new, or two parts have to fit together;
2016
2064
  \u2022 the user asks why something is the way it is, or what is left to do;
2017
2065
  \u2022 you are about to commit, and need to know what the change was supposed to honour.
2018
- 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.
2066
+ 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.
2019
2067
  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.
2020
2068
  - 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.
2021
2069
  - 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>").
@@ -2192,13 +2240,18 @@ function onPath(bin) {
2192
2240
  return false;
2193
2241
  }
2194
2242
  }
2243
+ var DAEMON_CONFIG_ENV = "HINDSIGHT_CODING_AGENTS_DAEMON_CONFIG";
2195
2244
  function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
2196
2245
  try {
2197
2246
  const starter = join10(dirname7(fileURLToPath2(import.meta.url)), "daemon-start.js");
2198
- const child = spawnFn("node", [starter, "--harness", harness], {
2247
+ const child = spawnFn(nodeBinary(), [starter, "--harness", harness], {
2199
2248
  detached: true,
2200
2249
  stdio: "ignore",
2201
- windowsHide: true
2250
+ windowsHide: true,
2251
+ // The caller's config is already resolved for its directory and bank. Re-reading the file in
2252
+ // the starter lost `paths` / `banks` overrides, so a daemon enabled only there never started
2253
+ // (#6334).
2254
+ env: { ...process.env, [DAEMON_CONFIG_ENV]: JSON.stringify(cfg) }
2202
2255
  });
2203
2256
  child.on("error", () => {
2204
2257
  });
@@ -2782,7 +2835,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
2782
2835
  const mcpConfig = JSON.stringify({
2783
2836
  mcpServers: {
2784
2837
  hindsight: {
2785
- command: "node",
2838
+ command: nodeBinary(),
2786
2839
  args: [opts.mcpServerPath],
2787
2840
  // HINDSIGHT_MCP_HARNESS names the agent whose CLI this recipe drives — the survey's
2788
2841
  // ingests are its writes. mcp-server.js REQUIRES it (it used to default to
@@ -2823,7 +2876,7 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
2823
2876
  "--sandbox",
2824
2877
  "read-only",
2825
2878
  "-c",
2826
- `mcp_servers.hindsight.command="node"`,
2879
+ `mcp_servers.hindsight.command=${tomlValue(nodeBinary())}`,
2827
2880
  "-c",
2828
2881
  `mcp_servers.hindsight.args=${tomlValue([opts.mcpServerPath])}`,
2829
2882
  "-c",
@@ -2910,7 +2963,7 @@ async function startCodebaseSurvey(repoDir, opts = {}) {
2910
2963
  const supervisorPath = opts.supervisorPath ?? join13(dirname8(fileURLToPath3(import.meta.url)), "survey-supervisor.js");
2911
2964
  return await new Promise((resolve4) => {
2912
2965
  try {
2913
- const child = spawnFn("node", [supervisorPath], {
2966
+ const child = spawnFn(nodeBinary(), [supervisorPath], {
2914
2967
  cwd: repoDir,
2915
2968
  detached: true,
2916
2969
  stdio: "ignore",
@@ -3281,10 +3334,15 @@ function detectLegacyClaudePlugin(cwd, claudeDir = join17(homedir7(), ".claude")
3281
3334
  const registry = readJson(join17(claudeDir, "plugins", "installed_plugins.json"));
3282
3335
  const plugins = registry?.plugins;
3283
3336
  if (!plugins || typeof plugins !== "object") return void 0;
3284
- const enabled = readJson(join17(claudeDir, "settings.json"))?.enabledPlugins;
3337
+ const enabledMaps = [
3338
+ join17(cwd, ".claude", "settings.local.json"),
3339
+ join17(cwd, ".claude", "settings.json"),
3340
+ join17(claudeDir, "settings.json")
3341
+ ].map((path) => readJson(path)?.enabledPlugins);
3285
3342
  for (const [key, raw] of Object.entries(plugins)) {
3286
3343
  if (key.split("@")[0] !== LEGACY_CLAUDE_PLUGIN) continue;
3287
- if (enabled && enabled[key] === false) continue;
3344
+ const setting = enabledMaps.find((m) => m && typeof m[key] === "boolean")?.[key];
3345
+ if (setting === false) continue;
3288
3346
  const installs = Array.isArray(raw) ? raw : [raw];
3289
3347
  const active = installs.some((i) => {
3290
3348
  if (!i || typeof i !== "object") return false;
@@ -3347,6 +3405,7 @@ async function buildSessionStartContext(args) {
3347
3405
  let cold;
3348
3406
  let gitDocIds;
3349
3407
  let bankEmpty = false;
3408
+ let deepening = false;
3350
3409
  const harness = args.harness ?? "claude-code";
3351
3410
  const hasGit = args.hasGit ?? hasGitHistory;
3352
3411
  const startSeed = args.startSeed ?? startBackgroundSeed;
@@ -3400,6 +3459,7 @@ async function buildSessionStartContext(args) {
3400
3459
  }
3401
3460
  if (docIds !== void 0) {
3402
3461
  startSeed(cwd, { limit: cfg.seedLimit, harness });
3462
+ deepening = true;
3403
3463
  if (cold) {
3404
3464
  if (cfg.codebaseSurvey !== false) {
3405
3465
  const sha = resolveHeadSha(cwd);
@@ -3449,6 +3509,14 @@ async function buildSessionStartContext(args) {
3449
3509
  }
3450
3510
  }
3451
3511
  }
3512
+ if (!deepening) {
3513
+ await client.configureBankSettings?.({
3514
+ manage: cfg.manageBankConfig,
3515
+ extractionMode: cfg.retainExtractionMode,
3516
+ defaults: cfg.defaultBankConfig
3517
+ }).catch(() => {
3518
+ });
3519
+ }
3452
3520
  let pages = [];
3453
3521
  try {
3454
3522
  pages = parsePageList(await client.listPages());
@@ -3647,7 +3715,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
3647
3715
  }
3648
3716
  const servers = doc.mcpServers && typeof doc.mcpServers === "object" && !Array.isArray(doc.mcpServers) ? doc.mcpServers : doc.mcpServers = {};
3649
3717
  const entry = {
3650
- command: "node",
3718
+ command: hookNode(),
3651
3719
  args: [script],
3652
3720
  env: { HINDSIGHT_MCP_HARNESS: "traecode", HINDSIGHT_MCP_PROJECT_CWD: cwd }
3653
3721
  };
@@ -3958,6 +4026,27 @@ function readAntigravityTranscript(path) {
3958
4026
  }
3959
4027
  return turns;
3960
4028
  }
4029
+ function readAntigravityPromptTurn(path) {
4030
+ if (!path) return void 0;
4031
+ let lastRole;
4032
+ let lastUserPrompt;
4033
+ for (const line of readJsonl(path)) {
4034
+ try {
4035
+ const event = JSON.parse(line);
4036
+ const role = event.role ?? event.message?.role ?? event.type;
4037
+ if (!role || role === "CHECKPOINT" || role === "EPHEMERAL_MESSAGE") continue;
4038
+ lastRole = role;
4039
+ if (role === "user" || role === "USER_INPUT") {
4040
+ const content = event.content ?? event.text ?? event.message?.content ?? event.message?.text;
4041
+ const text = typeof content === "string" ? stripInjectedMemory(content) : "";
4042
+ const clean = unwrapUserRequest(text).trim();
4043
+ lastUserPrompt = clean || void 0;
4044
+ }
4045
+ } catch {
4046
+ }
4047
+ }
4048
+ return lastRole === "user" || lastRole === "USER_INPUT" ? lastUserPrompt : void 0;
4049
+ }
3961
4050
 
3962
4051
  // src/core/transcript-copilot.ts
3963
4052
  function readCopilotTranscript(path) {
@@ -4682,9 +4771,10 @@ var antigravityPrompt = {
4682
4771
  harness: "antigravity-cli",
4683
4772
  requireCwd: true,
4684
4773
  parse: (ev) => ({
4685
- // Antigravity's PreInvocation payload deliberately omits the prompt. Its transcript is already
4686
- // persisted at that point, so recover the latest real user turn from the supplied JSONL path.
4687
- prompt: readAntigravityTranscript(ev.transcriptPath).filter((turn) => turn.role === "user").at(-1)?.content,
4774
+ // Antigravity's PreInvocation payload omits the prompt and fires before EVERY planner step in
4775
+ // the agent loop (including after every tool call). Read the transcript's trailing record so
4776
+ // only a genuine user submission returns a prompt and tool-result continuations are suppressed.
4777
+ prompt: readAntigravityPromptTurn(ev.transcriptPath),
4688
4778
  cwd: antigravityCwd(ev),
4689
4779
  sessionId: ev.conversationId
4690
4780
  }),