@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
  }),
@@ -7,16 +7,25 @@ import { join as join7 } from "path";
7
7
 
8
8
  // src/core/seed.ts
9
9
  import { spawn as realSpawn } from "child_process";
10
- import { dirname, join } from "path";
10
+ import { dirname, join as join2 } from "path";
11
11
  import { fileURLToPath } from "url";
12
+
13
+ // src/core/util.ts
14
+ import { accessSync, constants, statSync } from "fs";
15
+ import { delimiter, extname, isAbsolute, join, resolve } from "path";
16
+ function nodeBinary() {
17
+ return process.versions.bun || process.versions.electron ? "node" : process.execPath;
18
+ }
19
+
20
+ // src/core/seed.ts
12
21
  var DEFAULT_SEED_LIMIT = 300;
13
22
  function startBackgroundSeed(repoDir, opts = {}) {
14
23
  try {
15
24
  const spawnFn = opts.spawn ?? realSpawn;
16
- const enginePath = opts.enginePath ?? join(dirname(fileURLToPath(import.meta.url)), "deepen.js");
25
+ const enginePath = opts.enginePath ?? join2(dirname(fileURLToPath(import.meta.url)), "deepen.js");
17
26
  const limit = opts.limit ?? DEFAULT_SEED_LIMIT;
18
27
  const child = spawnFn(
19
- "node",
28
+ nodeBinary(),
20
29
  [
21
30
  enginePath,
22
31
  "--repo",
@@ -51,24 +60,24 @@ function seedControl(command2, args) {
51
60
  // src/core/bank.ts
52
61
  import { existsSync } from "fs";
53
62
  import { homedir as homedir2 } from "os";
54
- import { basename, dirname as dirname4, join as join5, normalize, sep } from "path";
63
+ import { basename, dirname as dirname4, join as join6, normalize, sep } from "path";
55
64
 
56
65
  // src/core/diag.ts
57
66
  import { readFileSync } from "fs";
58
- import { join as join3 } from "path";
67
+ import { join as join4 } from "path";
59
68
 
60
69
  // src/core/log.ts
61
- import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
70
+ import { appendFileSync, mkdirSync, renameSync, statSync as statSync2 } from "fs";
62
71
  import { homedir } from "os";
63
- import { dirname as dirname2, join as join2 } from "path";
72
+ import { dirname as dirname2, join as join3 } from "path";
64
73
  function logsDir() {
65
- return join2(homedir(), ".hindsight", "coding-agents-logs");
74
+ return join3(homedir(), ".hindsight", "coding-agents-logs");
66
75
  }
67
76
  var LOG_MAX_BYTES = 10 * 1024 * 1024;
68
77
  function appendLogLine(file, text) {
69
78
  mkdirSync(dirname2(file), { recursive: true, mode: 448 });
70
79
  try {
71
- if (statSync(file).size >= LOG_MAX_BYTES) renameSync(file, `${file}.1`);
80
+ if (statSync2(file).size >= LOG_MAX_BYTES) renameSync(file, `${file}.1`);
72
81
  } catch {
73
82
  }
74
83
  appendFileSync(file, text, { mode: 384 });
@@ -78,7 +87,7 @@ var current = ["debug", "info", "warn", "error"].find(
78
87
  (l) => l === process.env.HINDSIGHT_LOG_LEVEL
79
88
  ) ?? "info";
80
89
  function logFilePath() {
81
- return process.env.HINDSIGHT_LOG_FILE || join2(logsDir(), "plugin.log");
90
+ return process.env.HINDSIGHT_LOG_FILE || join3(logsDir(), "plugin.log");
82
91
  }
83
92
  function write(level, scope, msg, extra) {
84
93
  if (WEIGHT[level] < WEIGHT[current]) return;
@@ -99,7 +108,7 @@ var log = {
99
108
 
100
109
  // src/core/diag.ts
101
110
  function diagFilePath() {
102
- return process.env.HINDSIGHT_DIAG_FILE || join3(logsDir(), "diag.jsonl");
111
+ return process.env.HINDSIGHT_DIAG_FILE || join4(logsDir(), "diag.jsonl");
103
112
  }
104
113
  function diag(harness, event, extra = {}) {
105
114
  log.debug(harness, `diag:${event}`, extra);
@@ -114,7 +123,7 @@ function diag(harness, event, extra = {}) {
114
123
 
115
124
  // src/core/git-layout.ts
116
125
  import { lstatSync, readFileSync as readFileSync2, realpathSync } from "fs";
117
- import { dirname as dirname3, isAbsolute, join as join4, resolve } from "path";
126
+ import { dirname as dirname3, isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "path";
118
127
  var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
119
128
  var ATTEMPTS = 3;
120
129
  var BACKOFF_MS = 20;
@@ -147,19 +156,19 @@ function gitDirFromPointer(text, holder) {
147
156
  const match = /^\s*gitdir:\s*(.+?)\s*$/m.exec(text);
148
157
  if (!match) return null;
149
158
  const target = match[1];
150
- return isAbsolute(target) ? target : resolve(holder, target);
159
+ return isAbsolute2(target) ? target : resolve2(holder, target);
151
160
  }
152
161
  function commonDirOf(gitDir) {
153
- const pointer = entryKind(join4(gitDir, "commondir")) === "file" ? readTextOrNull(join4(gitDir, "commondir"))?.trim() : null;
162
+ const pointer = entryKind(join5(gitDir, "commondir")) === "file" ? readTextOrNull(join5(gitDir, "commondir"))?.trim() : null;
154
163
  if (!pointer) return gitDir;
155
- return isAbsolute(pointer) ? pointer : resolve(gitDir, pointer);
164
+ return isAbsolute2(pointer) ? pointer : resolve2(gitDir, pointer);
156
165
  }
157
166
  function isBare(commonDir) {
158
- const config = readTextOrNull(join4(commonDir, "config"));
167
+ const config = readTextOrNull(join5(commonDir, "config"));
159
168
  return config !== null && /^\s*bare\s*=\s*true\s*$/im.test(config);
160
169
  }
161
170
  function looksLikeBareRepository(directory) {
162
- return entryKind(join4(directory, "HEAD")) === "file" && entryKind(join4(directory, "objects")) === "dir" && entryKind(join4(directory, "refs")) === "dir";
171
+ return entryKind(join5(directory, "HEAD")) === "file" && entryKind(join5(directory, "objects")) === "dir" && entryKind(join5(directory, "refs")) === "dir";
163
172
  }
164
173
  function canonical(path) {
165
174
  try {
@@ -174,9 +183,9 @@ function resolved(commonDir) {
174
183
  return { status: "resolved", commonDir: canonicalDir, bare: isBare(canonicalDir) };
175
184
  }
176
185
  function probeOnce(directory) {
177
- let current2 = resolve(directory);
186
+ let current2 = resolve2(directory);
178
187
  for (; ; ) {
179
- const dotGit = join4(current2, ".git");
188
+ const dotGit = join5(current2, ".git");
180
189
  const kind = entryKind(dotGit);
181
190
  if (kind === "dir") {
182
191
  const layout = resolved(commonDirOf(dotGit));
@@ -287,10 +296,14 @@ function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
287
296
  return dirName(sessionRoot || directory);
288
297
  }
289
298
  function configuredDir(dir) {
290
- const expanded = dir === "~" || dir.startsWith("~/") ? join5(homedir2(), dir.slice(1)) : dir;
299
+ const expanded = dir === "~" || dir.startsWith("~/") ? join6(homedir2(), dir.slice(1)) : dir;
291
300
  return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
292
301
  }
293
- function isWithin(directory, configured) {
302
+ function isWithin(directory, configured, platform = process.platform) {
303
+ if (platform === "win32") {
304
+ directory = directory.toLowerCase();
305
+ configured = configured.toLowerCase();
306
+ }
294
307
  return directory === configured || directory.startsWith(configured + sep);
295
308
  }
296
309
  function mapLookup(map, directory) {
@@ -416,11 +429,7 @@ var PLUGIN_GOVERNED_BANK_FIELDS = [
416
429
  ];
417
430
 
418
431
  // package.json
419
- var version = "0.8.7";
420
-
421
- // src/core/util.ts
422
- import { accessSync, constants, statSync as statSync2 } from "fs";
423
- import { delimiter, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "path";
432
+ var version = "0.8.8";
424
433
 
425
434
  // src/core/hindsight.ts
426
435
  var USER_AGENT = `hindsight-coding-agents/${version}`;