@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) {
@@ -366,15 +370,92 @@ import { join as join7 } from "path";
366
370
 
367
371
  // src/core/seed.ts
368
372
  import { spawn as realSpawn } from "child_process";
369
- import { dirname as dirname4, join as join5 } from "path";
373
+ import { dirname as dirname4, join as join6 } from "path";
370
374
  import { fileURLToPath } from "url";
375
+
376
+ // src/core/util.ts
377
+ import { accessSync, constants, statSync as statSync2 } from "fs";
378
+ import { delimiter, extname, isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "path";
379
+ function binOnPath(bin, opts = {}) {
380
+ const platform = opts.platform ?? process.platform;
381
+ const env = opts.env ?? process.env;
382
+ const runnable = (file) => {
383
+ try {
384
+ if (!statSync2(file).isFile()) return false;
385
+ if (platform !== "win32") accessSync(file, constants.X_OK);
386
+ return true;
387
+ } catch {
388
+ return false;
389
+ }
390
+ };
391
+ if (isAbsolute2(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve2(bin) : void 0;
392
+ const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
393
+ for (const dir of (env.PATH || "").split(delimiter)) {
394
+ if (!dir) continue;
395
+ for (const name of names) {
396
+ const file = join5(dir, name);
397
+ if (runnable(file)) return resolve2(file);
398
+ }
399
+ }
400
+ return void 0;
401
+ }
402
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
403
+ function semverGte(version2, min) {
404
+ const parts = (v) => {
405
+ const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
406
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
407
+ };
408
+ const a = version2 ? parts(version2) : void 0;
409
+ const b = parts(min);
410
+ if (!a || !b) return false;
411
+ for (let i = 0; i < 3; i++) {
412
+ if (a[i] !== b[i]) return a[i] > b[i];
413
+ }
414
+ return true;
415
+ }
416
+ async function pool(items, n, fn, onError, onProgress) {
417
+ let i = 0, done = 0;
418
+ async function worker() {
419
+ while (i < items.length) {
420
+ const idx = i++;
421
+ try {
422
+ await fn(items[idx], idx);
423
+ } catch (e) {
424
+ onError?.(idx, e);
425
+ }
426
+ onProgress?.(++done, items.length);
427
+ }
428
+ }
429
+ await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
430
+ }
431
+ function nodeBinary() {
432
+ return process.versions.bun || process.versions.electron ? "node" : process.execPath;
433
+ }
434
+ function hookNode(opts = {}) {
435
+ const platform = opts.platform ?? process.platform;
436
+ if (platform === "win32" || binOnPath("node", opts)) return "node";
437
+ return nodeBinary();
438
+ }
439
+ function isOurMcpEntry(entry) {
440
+ if (!entry || typeof entry !== "object") return false;
441
+ const candidate = entry;
442
+ const command = typeof candidate.command === "string" ? candidate.command : "";
443
+ const bin = command.replaceAll("\\", "/").split("/").at(-1);
444
+ if (bin !== "node" && bin !== "node.exe" || !Array.isArray(candidate.args)) return false;
445
+ const script = candidate.args[0];
446
+ if (typeof script !== "string") return false;
447
+ const parts = script.replaceAll("\\", "/").split("/").filter(Boolean);
448
+ return parts.at(-1) === "mcp-server.js" && parts.at(-2) === "dist" && (parts.at(-3) === "coding-agents" || parts.at(-3) === "hindsight-coding-agents");
449
+ }
450
+
451
+ // src/core/seed.ts
371
452
  var DEFAULT_SEED_LIMIT = 300;
372
453
 
373
454
  // src/core/missions.ts
374
455
  import { createHash } from "crypto";
375
456
  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.";
376
457
  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.";
377
- 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.`;
458
+ 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.`;
378
459
  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.";
379
460
  var DOCUMENT_MISSION = "You are ingesting a standalone document (notes, docs, or structural findings). Extract the concrete facts, concepts, and structure it describes.";
380
461
  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.";
@@ -633,49 +714,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
633
714
  }
634
715
 
635
716
  // package.json
636
- var version = "0.8.7";
637
-
638
- // src/core/util.ts
639
- import { accessSync, constants, statSync as statSync2 } from "fs";
640
- import { delimiter, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "path";
641
- var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
642
- function semverGte(version2, min) {
643
- const parts = (v) => {
644
- const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
645
- return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
646
- };
647
- const a = version2 ? parts(version2) : void 0;
648
- const b = parts(min);
649
- if (!a || !b) return false;
650
- for (let i = 0; i < 3; i++) {
651
- if (a[i] !== b[i]) return a[i] > b[i];
652
- }
653
- return true;
654
- }
655
- async function pool(items, n, fn, onError, onProgress) {
656
- let i = 0, done = 0;
657
- async function worker() {
658
- while (i < items.length) {
659
- const idx = i++;
660
- try {
661
- await fn(items[idx], idx);
662
- } catch (e) {
663
- onError?.(idx, e);
664
- }
665
- onProgress?.(++done, items.length);
666
- }
667
- }
668
- await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
669
- }
670
- function isOurMcpEntry(entry) {
671
- if (!entry || typeof entry !== "object") return false;
672
- const candidate = entry;
673
- if (candidate.command !== "node" || !Array.isArray(candidate.args)) return false;
674
- const script = candidate.args[0];
675
- if (typeof script !== "string") return false;
676
- const parts = script.replaceAll("\\", "/").split("/").filter(Boolean);
677
- return parts.at(-1) === "mcp-server.js" && parts.at(-2) === "dist" && (parts.at(-3) === "coding-agents" || parts.at(-3) === "hindsight-coding-agents");
678
- }
717
+ var version = "0.8.8";
679
718
 
680
719
  // src/core/hindsight.ts
681
720
  var USER_AGENT = `hindsight-coding-agents/${version}`;
@@ -887,7 +926,9 @@ var HindsightClient = class {
887
926
  }
888
927
  if (!r.ok && r.status !== 404 && !tolerate.includes(r.status))
889
928
  throw new Error(
890
- `${method} ${url} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
929
+ // Query dropped: an encoded search query filled the 200-char error cap and pushed the
930
+ // status and the server's reason out of the tool error (#6341).
931
+ `${method} ${url.split("?")[0]} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
891
932
  );
892
933
  return r;
893
934
  }
@@ -1033,6 +1074,15 @@ var HindsightClient = class {
1033
1074
  await this.req("DELETE", this.bankUrl());
1034
1075
  this.log(`[bank] reset ${this.bank}`);
1035
1076
  }
1077
+ await this.configureBankSettings(opts);
1078
+ await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
1079
+ }
1080
+ /** The config half of `configureBank` (missions, retain strategies, entity labels), without
1081
+ * seeding pages. Session start calls it directly when the deepen engine — the usual caller of
1082
+ * `configureBank` — will not run (`autoSeed: false`, or a directory with no git history):
1083
+ * without it such a bank never got the `conversation` strategy, and every session write-back
1084
+ * was extracted with the server's generic rules instead of the plugin's mission. */
1085
+ async configureBankSettings(opts = {}) {
1036
1086
  if (opts.manage === false) {
1037
1087
  this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
1038
1088
  } else {
@@ -1048,7 +1098,6 @@ var HindsightClient = class {
1048
1098
  this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
1049
1099
  }
1050
1100
  }
1051
- await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
1052
1101
  }
1053
1102
  /**
1054
1103
  * This bank's own config OVERRIDES, or undefined when there are none to read.
@@ -1881,10 +1930,14 @@ function resolvePartial(cfg, patch) {
1881
1930
  }
1882
1931
 
1883
1932
  // src/core/transcript-util.ts
1933
+ var TOOL_TEXT_CAP = 2e3;
1884
1934
  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;
1885
1935
  function stripInjectedMemory(s) {
1886
1936
  return s.replace(MEMORY_TAG_RE, "");
1887
1937
  }
1938
+ function truncate(s, max = TOOL_TEXT_CAP) {
1939
+ return s.length > max ? `${s.slice(0, max)}\u2026 (truncated)` : s;
1940
+ }
1888
1941
  var TARGET_KEYS = [
1889
1942
  "file_path",
1890
1943
  "path",
@@ -1912,7 +1965,25 @@ function actionLine(tool, input) {
1912
1965
  target = input.trim().split("\n")[0];
1913
1966
  }
1914
1967
  if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
1915
- return target ? `${tool} ${target}` : tool;
1968
+ const line = target ? `${tool} ${target}` : tool;
1969
+ const note = memoryNoteText(input);
1970
+ return note ? `${line}
1971
+ ${truncate(note, MEMORY_NOTE_CAP)}` : line;
1972
+ }
1973
+ var MEMORY_NOTE_CAP = 8e3;
1974
+ var MEMORY_NOTE_PATH_RE = /(^|[\\/])(memory|memories)[\\/]|(^|[\\/])MEMORY\.md$/i;
1975
+ var MEMORY_SHELL_WRITE_RE = /[\\/](memory|memories)([\\/\s"']|$)|MEMORY\.md/i;
1976
+ var SHELL_WRITE_RE = /(^|[^0-9&>])>>?(?!&)|\btee\b/;
1977
+ function memoryNoteText(input) {
1978
+ if (!input || typeof input !== "object") return "";
1979
+ const rec = input;
1980
+ const cmd = rec.command;
1981
+ if (typeof cmd === "string")
1982
+ return MEMORY_SHELL_WRITE_RE.test(cmd) && SHELL_WRITE_RE.test(cmd) ? cmd.trim() : "";
1983
+ const path = rec.file_path ?? rec.path;
1984
+ if (typeof path !== "string" || !MEMORY_NOTE_PATH_RE.test(path)) return "";
1985
+ const text = rec.content ?? rec.new_string;
1986
+ return typeof text === "string" ? text.trim() : "";
1916
1987
  }
1917
1988
 
1918
1989
  // src/core/session-cache.ts
@@ -2406,13 +2477,18 @@ function onPath(bin) {
2406
2477
  return false;
2407
2478
  }
2408
2479
  }
2480
+ var DAEMON_CONFIG_ENV = "HINDSIGHT_CODING_AGENTS_DAEMON_CONFIG";
2409
2481
  function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
2410
2482
  try {
2411
2483
  const starter = join10(dirname7(fileURLToPath2(import.meta.url)), "daemon-start.js");
2412
- const child = spawnFn("node", [starter, "--harness", harness], {
2484
+ const child = spawnFn(nodeBinary(), [starter, "--harness", harness], {
2413
2485
  detached: true,
2414
2486
  stdio: "ignore",
2415
- windowsHide: true
2487
+ windowsHide: true,
2488
+ // The caller's config is already resolved for its directory and bank. Re-reading the file in
2489
+ // the starter lost `paths` / `banks` overrides, so a daemon enabled only there never started
2490
+ // (#6334).
2491
+ env: { ...process.env, [DAEMON_CONFIG_ENV]: JSON.stringify(cfg) }
2416
2492
  });
2417
2493
  child.on("error", () => {
2418
2494
  });
@@ -2579,7 +2655,7 @@ function* readJsonl(path) {
2579
2655
  }
2580
2656
 
2581
2657
  // src/core/transcript.ts
2582
- function renderLine(content, type) {
2658
+ function renderLine(content, type, questionIds) {
2583
2659
  if (typeof content === "string") {
2584
2660
  const text = stripInjectedMemory(content).trim();
2585
2661
  return text ? [{ role: type, content: text }] : [];
@@ -2593,7 +2669,11 @@ function renderLine(content, type) {
2593
2669
  const t = stripInjectedMemory(b.text).trim();
2594
2670
  if (t) texts.push(t);
2595
2671
  } else if (b.type === "tool_use" && typeof b.name === "string") {
2672
+ if (b.name === "AskUserQuestion" && typeof b.id === "string") questionIds.add(b.id);
2596
2673
  actions.push({ role: "action", content: actionLine(b.name, b.input) });
2674
+ } else if (b.type === "tool_result" && b.tool_use_id && questionIds.has(b.tool_use_id)) {
2675
+ const answer = renderLine(b.content, type, questionIds).map((r) => r.content).join("\n");
2676
+ if (answer) texts.push(answer);
2597
2677
  }
2598
2678
  }
2599
2679
  const out = [];
@@ -2604,6 +2684,7 @@ function renderLine(content, type) {
2604
2684
  }
2605
2685
  function readClaudeTranscript(path) {
2606
2686
  const turns = [];
2687
+ const questionIds = /* @__PURE__ */ new Set();
2607
2688
  for (const rawLine of readJsonl(path)) {
2608
2689
  const trimmed = rawLine.trim();
2609
2690
  if (!trimmed) continue;
@@ -2620,7 +2701,7 @@ function readClaudeTranscript(path) {
2620
2701
  if (line.isSidechain === true) continue;
2621
2702
  if (line.isCompactSummary === true) continue;
2622
2703
  if (typeof line.message !== "object" || line.message === null) continue;
2623
- for (const rendered of renderLine(line.message.content, line.type)) {
2704
+ for (const rendered of renderLine(line.message.content, line.type, questionIds)) {
2624
2705
  const turn = { role: rendered.role, content: rendered.content };
2625
2706
  if (typeof line.timestamp === "string") turn.timestamp = line.timestamp;
2626
2707
  turns.push(turn);
@@ -2980,7 +3061,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
2980
3061
  }
2981
3062
  const servers = doc.mcpServers && typeof doc.mcpServers === "object" && !Array.isArray(doc.mcpServers) ? doc.mcpServers : doc.mcpServers = {};
2982
3063
  const entry = {
2983
- command: "node",
3064
+ command: hookNode(),
2984
3065
  args: [script],
2985
3066
  env: { HINDSIGHT_MCP_HARNESS: "traecode", HINDSIGHT_MCP_PROJECT_CWD: cwd }
2986
3067
  };
@@ -3291,6 +3372,27 @@ function readAntigravityTranscript(path) {
3291
3372
  }
3292
3373
  return turns;
3293
3374
  }
3375
+ function readAntigravityPromptTurn(path) {
3376
+ if (!path) return void 0;
3377
+ let lastRole;
3378
+ let lastUserPrompt;
3379
+ for (const line of readJsonl(path)) {
3380
+ try {
3381
+ const event = JSON.parse(line);
3382
+ const role = event.role ?? event.message?.role ?? event.type;
3383
+ if (!role || role === "CHECKPOINT" || role === "EPHEMERAL_MESSAGE") continue;
3384
+ lastRole = role;
3385
+ if (role === "user" || role === "USER_INPUT") {
3386
+ const content = event.content ?? event.text ?? event.message?.content ?? event.message?.text;
3387
+ const text = typeof content === "string" ? stripInjectedMemory(content) : "";
3388
+ const clean = unwrapUserRequest(text).trim();
3389
+ lastUserPrompt = clean || void 0;
3390
+ }
3391
+ } catch {
3392
+ }
3393
+ }
3394
+ return lastRole === "user" || lastRole === "USER_INPUT" ? lastUserPrompt : void 0;
3395
+ }
3294
3396
 
3295
3397
  // src/core/transcript-copilot.ts
3296
3398
  function readCopilotTranscript(path) {
@@ -4015,9 +4117,10 @@ var antigravityPrompt = {
4015
4117
  harness: "antigravity-cli",
4016
4118
  requireCwd: true,
4017
4119
  parse: (ev) => ({
4018
- // Antigravity's PreInvocation payload deliberately omits the prompt. Its transcript is already
4019
- // persisted at that point, so recover the latest real user turn from the supplied JSONL path.
4020
- prompt: readAntigravityTranscript(ev.transcriptPath).filter((turn) => turn.role === "user").at(-1)?.content,
4120
+ // Antigravity's PreInvocation payload omits the prompt and fires before EVERY planner step in
4121
+ // the agent loop (including after every tool call). Read the transcript's trailing record so
4122
+ // only a genuine user submission returns a prompt and tool-result continuations are suppressed.
4123
+ prompt: readAntigravityPromptTurn(ev.transcriptPath),
4021
4124
  cwd: antigravityCwd(ev),
4022
4125
  sessionId: ev.conversationId
4023
4126
  }),
@@ -31413,31 +31413,66 @@ import { join as join7 } from "path";
31413
31413
 
31414
31414
  // src/core/seed.ts
31415
31415
  import { spawn as realSpawn } from "child_process";
31416
- import { dirname, join } from "path";
31416
+ import { dirname, join as join2 } from "path";
31417
31417
  import { fileURLToPath } from "url";
31418
+
31419
+ // src/core/util.ts
31420
+ import { accessSync, constants, statSync } from "fs";
31421
+ import { delimiter, extname, isAbsolute, join, resolve } from "path";
31422
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
31423
+ function semverGte(version3, min) {
31424
+ const parts = (v) => {
31425
+ const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
31426
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
31427
+ };
31428
+ const a = version3 ? parts(version3) : void 0;
31429
+ const b = parts(min);
31430
+ if (!a || !b) return false;
31431
+ for (let i = 0; i < 3; i++) {
31432
+ if (a[i] !== b[i]) return a[i] > b[i];
31433
+ }
31434
+ return true;
31435
+ }
31436
+ async function pool(items, n, fn, onError, onProgress) {
31437
+ let i = 0, done = 0;
31438
+ async function worker() {
31439
+ while (i < items.length) {
31440
+ const idx = i++;
31441
+ try {
31442
+ await fn(items[idx], idx);
31443
+ } catch (e) {
31444
+ onError?.(idx, e);
31445
+ }
31446
+ onProgress?.(++done, items.length);
31447
+ }
31448
+ }
31449
+ await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
31450
+ }
31451
+
31452
+ // src/core/seed.ts
31418
31453
  var DEFAULT_SEED_LIMIT = 300;
31419
31454
 
31420
31455
  // src/core/bank.ts
31421
31456
  import { existsSync } from "fs";
31422
31457
  import { homedir as homedir2 } from "os";
31423
- import { basename, dirname as dirname4, join as join5, normalize, sep } from "path";
31458
+ import { basename, dirname as dirname4, join as join6, normalize, sep } from "path";
31424
31459
 
31425
31460
  // src/core/diag.ts
31426
31461
  import { readFileSync } from "fs";
31427
- import { join as join3 } from "path";
31462
+ import { join as join4 } from "path";
31428
31463
 
31429
31464
  // src/core/log.ts
31430
- import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
31465
+ import { appendFileSync, mkdirSync, renameSync, statSync as statSync2 } from "fs";
31431
31466
  import { homedir } from "os";
31432
- import { dirname as dirname2, join as join2 } from "path";
31467
+ import { dirname as dirname2, join as join3 } from "path";
31433
31468
  function logsDir() {
31434
- return join2(homedir(), ".hindsight", "coding-agents-logs");
31469
+ return join3(homedir(), ".hindsight", "coding-agents-logs");
31435
31470
  }
31436
31471
  var LOG_MAX_BYTES = 10 * 1024 * 1024;
31437
31472
  function appendLogLine(file2, text) {
31438
31473
  mkdirSync(dirname2(file2), { recursive: true, mode: 448 });
31439
31474
  try {
31440
- if (statSync(file2).size >= LOG_MAX_BYTES) renameSync(file2, `${file2}.1`);
31475
+ if (statSync2(file2).size >= LOG_MAX_BYTES) renameSync(file2, `${file2}.1`);
31441
31476
  } catch {
31442
31477
  }
31443
31478
  appendFileSync(file2, text, { mode: 384 });
@@ -31447,7 +31482,7 @@ var current = ["debug", "info", "warn", "error"].find(
31447
31482
  (l) => l === process.env.HINDSIGHT_LOG_LEVEL
31448
31483
  ) ?? "info";
31449
31484
  function logFilePath() {
31450
- return process.env.HINDSIGHT_LOG_FILE || join2(logsDir(), "plugin.log");
31485
+ return process.env.HINDSIGHT_LOG_FILE || join3(logsDir(), "plugin.log");
31451
31486
  }
31452
31487
  function write(level, scope, msg, extra) {
31453
31488
  if (WEIGHT[level] < WEIGHT[current]) return;
@@ -31482,7 +31517,7 @@ function describeError(value, maxChars = 200) {
31482
31517
 
31483
31518
  // src/core/diag.ts
31484
31519
  function diagFilePath() {
31485
- return process.env.HINDSIGHT_DIAG_FILE || join3(logsDir(), "diag.jsonl");
31520
+ return process.env.HINDSIGHT_DIAG_FILE || join4(logsDir(), "diag.jsonl");
31486
31521
  }
31487
31522
  function diag(harness, event, extra = {}) {
31488
31523
  log.debug(harness, `diag:${event}`, extra);
@@ -31497,7 +31532,7 @@ function diag(harness, event, extra = {}) {
31497
31532
 
31498
31533
  // src/core/git-layout.ts
31499
31534
  import { lstatSync, readFileSync as readFileSync2, realpathSync } from "fs";
31500
- import { dirname as dirname3, isAbsolute, join as join4, resolve } from "path";
31535
+ import { dirname as dirname3, isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "path";
31501
31536
  var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
31502
31537
  var ATTEMPTS = 3;
31503
31538
  var BACKOFF_MS = 20;
@@ -31530,19 +31565,19 @@ function gitDirFromPointer(text, holder) {
31530
31565
  const match = /^\s*gitdir:\s*(.+?)\s*$/m.exec(text);
31531
31566
  if (!match) return null;
31532
31567
  const target = match[1];
31533
- return isAbsolute(target) ? target : resolve(holder, target);
31568
+ return isAbsolute2(target) ? target : resolve2(holder, target);
31534
31569
  }
31535
31570
  function commonDirOf(gitDir) {
31536
- const pointer = entryKind(join4(gitDir, "commondir")) === "file" ? readTextOrNull(join4(gitDir, "commondir"))?.trim() : null;
31571
+ const pointer = entryKind(join5(gitDir, "commondir")) === "file" ? readTextOrNull(join5(gitDir, "commondir"))?.trim() : null;
31537
31572
  if (!pointer) return gitDir;
31538
- return isAbsolute(pointer) ? pointer : resolve(gitDir, pointer);
31573
+ return isAbsolute2(pointer) ? pointer : resolve2(gitDir, pointer);
31539
31574
  }
31540
31575
  function isBare(commonDir) {
31541
- const config2 = readTextOrNull(join4(commonDir, "config"));
31576
+ const config2 = readTextOrNull(join5(commonDir, "config"));
31542
31577
  return config2 !== null && /^\s*bare\s*=\s*true\s*$/im.test(config2);
31543
31578
  }
31544
31579
  function looksLikeBareRepository(directory) {
31545
- return entryKind(join4(directory, "HEAD")) === "file" && entryKind(join4(directory, "objects")) === "dir" && entryKind(join4(directory, "refs")) === "dir";
31580
+ return entryKind(join5(directory, "HEAD")) === "file" && entryKind(join5(directory, "objects")) === "dir" && entryKind(join5(directory, "refs")) === "dir";
31546
31581
  }
31547
31582
  function canonical(path) {
31548
31583
  try {
@@ -31557,9 +31592,9 @@ function resolved(commonDir) {
31557
31592
  return { status: "resolved", commonDir: canonicalDir, bare: isBare(canonicalDir) };
31558
31593
  }
31559
31594
  function probeOnce(directory) {
31560
- let current2 = resolve(directory);
31595
+ let current2 = resolve2(directory);
31561
31596
  for (; ; ) {
31562
- const dotGit = join4(current2, ".git");
31597
+ const dotGit = join5(current2, ".git");
31563
31598
  const kind = entryKind(dotGit);
31564
31599
  if (kind === "dir") {
31565
31600
  const layout = resolved(commonDirOf(dotGit));
@@ -31673,10 +31708,14 @@ function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
31673
31708
  return dirName(sessionRoot || directory);
31674
31709
  }
31675
31710
  function configuredDir(dir) {
31676
- const expanded = dir === "~" || dir.startsWith("~/") ? join5(homedir2(), dir.slice(1)) : dir;
31711
+ const expanded = dir === "~" || dir.startsWith("~/") ? join6(homedir2(), dir.slice(1)) : dir;
31677
31712
  return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
31678
31713
  }
31679
- function isWithin(directory, configured) {
31714
+ function isWithin(directory, configured, platform = process.platform) {
31715
+ if (platform === "win32") {
31716
+ directory = directory.toLowerCase();
31717
+ configured = configured.toLowerCase();
31718
+ }
31680
31719
  return directory === configured || directory.startsWith(configured + sep);
31681
31720
  }
31682
31721
  function mapLookup(map2, directory) {
@@ -31766,7 +31805,7 @@ function deriveBankIdOrSkip(config2, directory, harness = "coding", sessionRoot)
31766
31805
  import { createHash } from "crypto";
31767
31806
  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.";
31768
31807
  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.";
31769
- 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.`;
31808
+ 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.`;
31770
31809
  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.";
31771
31810
  var DOCUMENT_MISSION = "You are ingesting a standalone document (notes, docs, or structural findings). Extract the concrete facts, concepts, and structure it describes.";
31772
31811
  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.";
@@ -32025,40 +32064,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
32025
32064
  }
32026
32065
 
32027
32066
  // package.json
32028
- var version2 = "0.8.7";
32029
-
32030
- // src/core/util.ts
32031
- import { accessSync, constants, statSync as statSync2 } from "fs";
32032
- import { delimiter, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "path";
32033
- var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
32034
- function semverGte(version3, min) {
32035
- const parts = (v) => {
32036
- const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
32037
- return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
32038
- };
32039
- const a = version3 ? parts(version3) : void 0;
32040
- const b = parts(min);
32041
- if (!a || !b) return false;
32042
- for (let i = 0; i < 3; i++) {
32043
- if (a[i] !== b[i]) return a[i] > b[i];
32044
- }
32045
- return true;
32046
- }
32047
- async function pool(items, n, fn, onError, onProgress) {
32048
- let i = 0, done = 0;
32049
- async function worker() {
32050
- while (i < items.length) {
32051
- const idx = i++;
32052
- try {
32053
- await fn(items[idx], idx);
32054
- } catch (e) {
32055
- onError?.(idx, e);
32056
- }
32057
- onProgress?.(++done, items.length);
32058
- }
32059
- }
32060
- await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
32061
- }
32067
+ var version2 = "0.8.8";
32062
32068
 
32063
32069
  // src/core/hindsight.ts
32064
32070
  var USER_AGENT = `hindsight-coding-agents/${version2}`;
@@ -32270,7 +32276,9 @@ var HindsightClient = class {
32270
32276
  }
32271
32277
  if (!r.ok && r.status !== 404 && !tolerate.includes(r.status))
32272
32278
  throw new Error(
32273
- `${method} ${url2} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
32279
+ // Query dropped: an encoded search query filled the 200-char error cap and pushed the
32280
+ // status and the server's reason out of the tool error (#6341).
32281
+ `${method} ${url2.split("?")[0]} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
32274
32282
  );
32275
32283
  return r;
32276
32284
  }
@@ -32416,6 +32424,15 @@ var HindsightClient = class {
32416
32424
  await this.req("DELETE", this.bankUrl());
32417
32425
  this.log(`[bank] reset ${this.bank}`);
32418
32426
  }
32427
+ await this.configureBankSettings(opts);
32428
+ await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
32429
+ }
32430
+ /** The config half of `configureBank` (missions, retain strategies, entity labels), without
32431
+ * seeding pages. Session start calls it directly when the deepen engine — the usual caller of
32432
+ * `configureBank` — will not run (`autoSeed: false`, or a directory with no git history):
32433
+ * without it such a bank never got the `conversation` strategy, and every session write-back
32434
+ * was extracted with the server's generic rules instead of the plugin's mission. */
32435
+ async configureBankSettings(opts = {}) {
32419
32436
  if (opts.manage === false) {
32420
32437
  this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
32421
32438
  } else {
@@ -32431,7 +32448,6 @@ var HindsightClient = class {
32431
32448
  this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
32432
32449
  }
32433
32450
  }
32434
- await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
32435
32451
  }
32436
32452
  /**
32437
32453
  * This bank's own config OVERRIDES, or undefined when there are none to read.
@@ -33552,7 +33568,7 @@ function buildPageTools(client, bankId, opts = {}) {
33552
33568
  },
33553
33569
  {
33554
33570
  name: "hindsight_search_pages",
33555
- 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,
33571
+ 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,
33556
33572
  inputSchema: { query: external_exports.string().describe("what to look for") },
33557
33573
  annotations: READ_ONLY_ANNOTATIONS,
33558
33574
  handler: async (args) => {