@vectorize-io/hindsight-coding-agents 0.8.2 → 0.8.4

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 (64) hide show
  1. package/README.md +13 -3
  2. package/dist/antigravity-hook.js +95 -42
  3. package/dist/antigravity-statusline.js +6 -6
  4. package/dist/antigravity-stop-hook.js +132 -51
  5. package/dist/claude-hook.js +95 -42
  6. package/dist/claude-sessionstart-hook.js +385 -100
  7. package/dist/claude-stop-hook.js +132 -51
  8. package/dist/cline.js +403 -92
  9. package/dist/codebuddy-hook.js +95 -42
  10. package/dist/codebuddy-sessionstart-hook.js +385 -100
  11. package/dist/codebuddy-stop-hook.js +132 -51
  12. package/dist/codex-hook.js +95 -42
  13. package/dist/codex-sessionstart-hook.js +385 -100
  14. package/dist/codex-stop-hook.js +132 -51
  15. package/dist/copilot-hook.js +95 -42
  16. package/dist/copilot-sessionstart-hook.js +385 -100
  17. package/dist/copilot-stop-hook.js +132 -51
  18. package/dist/cursor-hook.js +95 -42
  19. package/dist/cursor-sessionstart-hook.js +385 -100
  20. package/dist/cursor-stop-hook.js +132 -51
  21. package/dist/daemon-start.js +10 -10
  22. package/dist/dcode-hook.js +95 -42
  23. package/dist/dcode-sessionstart-hook.js +385 -100
  24. package/dist/dcode-stop-hook.js +132 -51
  25. package/dist/deepen.js +82 -23
  26. package/dist/devin-hook.js +95 -42
  27. package/dist/devin-sessionstart-hook.js +385 -100
  28. package/dist/devin-stop-hook.js +132 -51
  29. package/dist/droid-hook.js +95 -42
  30. package/dist/droid-sessionstart-hook.js +385 -100
  31. package/dist/droid-stop-hook.js +132 -51
  32. package/dist/dsh.js +422 -99
  33. package/dist/grok-hook.js +95 -42
  34. package/dist/grok-sessionstart-hook.js +385 -100
  35. package/dist/grok-stop-hook.js +132 -51
  36. package/dist/hindsight-seed.js +6 -6
  37. package/dist/index.js +427 -111
  38. package/dist/installer.js +89 -80
  39. package/dist/kilo.js +427 -111
  40. package/dist/kimi-hook.js +95 -42
  41. package/dist/kimi-sessionstart-hook.js +385 -100
  42. package/dist/kimi-stop-hook.js +132 -51
  43. package/dist/mcp-server.js +169 -62
  44. package/dist/opencode2.js +583 -105
  45. package/dist/pi.js +403 -99
  46. package/dist/prime-agent.js +403 -99
  47. package/dist/qwen-hook.js +95 -42
  48. package/dist/qwen-sessionstart-hook.js +385 -100
  49. package/dist/qwen-stop-hook.js +132 -51
  50. package/dist/status.js +67 -17
  51. package/dist/survey-supervisor.js +73 -9
  52. package/dist/traecode-hook.js +95 -42
  53. package/dist/traecode-sessionstart-hook.js +385 -100
  54. package/dist/traecode-stop-hook.js +132 -51
  55. package/dist/workbuddy-hook.js +95 -42
  56. package/dist/workbuddy-sessionstart-hook.js +385 -100
  57. package/dist/workbuddy-stop-hook.js +132 -51
  58. package/dist/zcode-hook.js +95 -42
  59. package/dist/zcode-sessionstart-hook.js +385 -100
  60. package/dist/zcode-stop-hook.js +132 -51
  61. package/index.js +4 -1
  62. package/package.json +7 -4
  63. package/plugin.json +1 -1
  64. package/skill/SKILL.md +10 -2
@@ -207,14 +207,14 @@ function probeGitLayout(directory) {
207
207
  var PLACEHOLDER = /\{([a-zA-Z_]+)\}/g;
208
208
  function applyTemplate(template, resolvers, what) {
209
209
  return template.replace(PLACEHOLDER, (_, name) => {
210
- const resolve3 = resolvers[name];
211
- if (!resolve3) {
210
+ const resolve4 = resolvers[name];
211
+ if (!resolve4) {
212
212
  console.error(
213
213
  `hindsight: unknown ${what} placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
214
214
  );
215
215
  return "unknown";
216
216
  }
217
- return resolve3();
217
+ return resolve4();
218
218
  });
219
219
  }
220
220
 
@@ -633,11 +633,11 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
633
633
  }
634
634
 
635
635
  // package.json
636
- var version = "0.8.2";
636
+ var version = "0.8.4";
637
637
 
638
638
  // src/core/util.ts
639
- import { accessSync, constants } from "fs";
640
- import { delimiter, join as join6 } from "path";
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
641
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
642
642
  function semverGte(version2, min) {
643
643
  const parts = (v) => {
@@ -915,15 +915,19 @@ var HindsightClient = class {
915
915
  }
916
916
  /**
917
917
  * Whether this server honours `operation_id` on an async retain, and can therefore be appended to
918
- * safely (see MIN_IDEMPOTENT_RETAIN_VERSION). Probed once per client via the version endpoint; anything
918
+ * safely (see MIN_IDEMPOTENT_RETAIN_VERSION). Probed via the version endpoint; anything
919
919
  * unreachable, unparseable or older answers "no", which costs efficiency, never correctness.
920
+ * Only a "yes" is cached: a long-lived plugin client would otherwise keep replacing for the rest
921
+ * of the process after one probe that hit a restarting server (#5735).
920
922
  */
921
923
  async supportsIdempotentRetain() {
922
- if (this.idempotentRetain === void 0) {
923
- this.idempotentRetain = await this.probeIdempotentRetain();
924
- this.log(`server retain idempotency: ${this.idempotentRetain ? "supported" : "unavailable"}`);
924
+ if (this.idempotentRetain) return true;
925
+ const supported = await this.probeIdempotentRetain();
926
+ if (supported || this.idempotentRetain === void 0) {
927
+ this.log(`server retain idempotency: ${supported ? "supported" : "unavailable"}`);
925
928
  }
926
- return this.idempotentRetain;
929
+ this.idempotentRetain = supported;
930
+ return supported;
927
931
  }
928
932
  /** `/v1/version` first: an ingress that routes only `/v1` to the API (the Helm chart's default)
929
933
  * hands a bare `/version` to the control plane, whose HTML 404 or login redirect read as "no",
@@ -1951,7 +1955,7 @@ function fileCursorStore(harness) {
1951
1955
  }
1952
1956
 
1953
1957
  // src/core/turn-journal.ts
1954
- import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
1958
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
1955
1959
  import { tmpdir as tmpdir2 } from "os";
1956
1960
  import { dirname as dirname6, join as join9 } from "path";
1957
1961
 
@@ -1999,7 +2003,7 @@ function appendJournalTurn(path, turn) {
1999
2003
  const content = stripInjectedMemory(turn.content ?? "").trim();
2000
2004
  if (!content) return;
2001
2005
  try {
2002
- if (statSync2(path).size >= JOURNAL_MAX_BYTES) return;
2006
+ if (statSync3(path).size >= JOURNAL_MAX_BYTES) return;
2003
2007
  } catch {
2004
2008
  }
2005
2009
  const last = readJournalTranscript(path).at(-1);
@@ -2061,6 +2065,18 @@ function pendingReplayable(cursor, now) {
2061
2065
  if (pending.some((p) => now - p.at > PENDING_MAX_AGE_MS)) return false;
2062
2066
  return pending.reduce((n, p) => n + p.content.length, 0) <= PENDING_MAX_BYTES;
2063
2067
  }
2068
+ function advanceSegments(cursor, bank) {
2069
+ if (!cursor || cursor.bank === bank) return cursor?.segments;
2070
+ return [...cursor.segments ?? [{ bank: cursor.bank, from: 0 }], { bank, from: cursor.turns }];
2071
+ }
2072
+ function bankTurns(turns, segments, bank) {
2073
+ if (!segments) return turns;
2074
+ return turns.filter((_, i) => {
2075
+ let owner;
2076
+ for (const s of segments) if (s.from <= i) owner = s.bank;
2077
+ return owner === bank;
2078
+ });
2079
+ }
2064
2080
  var MAX_CURSOR_OPS = 8;
2065
2081
  function fingerprintTurns(turns, count) {
2066
2082
  const h = createHash2("sha1").update(String(count));
@@ -2071,7 +2087,8 @@ function planRetain(turns, cursor, opts) {
2071
2087
  if (!turns.length) return { mode: "skip" };
2072
2088
  if (!opts.appendSupported || !cursor || cursor.dirty) return { mode: "replace" };
2073
2089
  if (!pendingReplayable(cursor, opts.now ?? Date.now())) return { mode: "replace" };
2074
- if (cursor.bank !== opts.bank) return { mode: "replace" };
2090
+ if (cursor.bank !== opts.bank && !cursor.segments?.some((s) => s.bank === opts.bank))
2091
+ return { mode: "replace" };
2075
2092
  const seen = cursor.paths ?? [];
2076
2093
  const newFile = Boolean(opts.path && seen.length && !seen.includes(opts.path));
2077
2094
  const continues = cursor.turns <= turns.length && fingerprintTurns(turns, cursor.turns) === cursor.fingerprint;
@@ -2206,8 +2223,17 @@ async function writeSession(client, sessionId, turns, startTs, harness, stamp, c
2206
2223
  let cursor = cursors?.read(sessionId);
2207
2224
  const probed = Boolean(cursors) && cursor?.appendSupported !== true;
2208
2225
  const appendSupported = Boolean(cursors) && (cursor?.appendSupported === true || await supportsAppend(client));
2226
+ const moved = Boolean(cursor && cursor.bank !== client.bank);
2227
+ if (moved)
2228
+ log.warn(harness ?? "", "session moved to another bank mid-session", {
2229
+ session: sessionId,
2230
+ from: cursor?.bank,
2231
+ to: client.bank,
2232
+ atTurn: cursor?.turns
2233
+ });
2234
+ const segments = advanceSegments(cursor, client.bank);
2209
2235
  let ops = [];
2210
- if (appendSupported && cursor?.ops?.length && !cursor.dirty)
2236
+ if (appendSupported && cursor?.ops?.length && !cursor.dirty && !moved)
2211
2237
  ({ cursor, ops } = await settleOps(client, cursor));
2212
2238
  const plan = planRetain(turns, cursor, {
2213
2239
  appendSupported,
@@ -2216,7 +2242,7 @@ async function writeSession(client, sessionId, turns, startTs, harness, stamp, c
2216
2242
  });
2217
2243
  if (probed) diag(harness ?? "", "retain_mode", { mode: plan.mode, appendSupported });
2218
2244
  const paths = plan.mode === "replace" ? transcriptPath ? [transcriptPath] : void 0 : advancePaths(cursor?.paths, transcriptPath);
2219
- const outbox = plan.mode === "replace" ? [] : cursor?.pending ?? [];
2245
+ const outbox = plan.mode === "replace" || moved ? [] : cursor?.pending ?? [];
2220
2246
  if (plan.mode === "skip" && !outbox.length) return;
2221
2247
  const opId = (mode, content) => uuidV5(`${client.bank}
2222
2248
  ${refId}
@@ -2258,6 +2284,7 @@ ${content}`);
2258
2284
  fingerprint: fingerprintTurns(turns, turns.length),
2259
2285
  bank: client.bank,
2260
2286
  ...paths ? { paths } : {},
2287
+ ...segments ? { segments } : {},
2261
2288
  ...appendSupported ? { appendSupported: true } : {}
2262
2289
  };
2263
2290
  const accepted = (id) => {
@@ -2270,9 +2297,14 @@ ${content}`);
2270
2297
  return now?.turns === next.turns && now?.fingerprint === next.fingerprint;
2271
2298
  };
2272
2299
  if (plan.mode === "replace") {
2273
- const content = renderSessionJsonl(refId, turns, startTs);
2300
+ const share = bankTurns(turns, segments, client.bank);
2301
+ if (!share.length) return;
2302
+ const content = renderSessionJsonl(refId, share, startTs);
2303
+ const base = cursor ? `${cursor.turns}
2304
+ ${cursor.fingerprint}` : "";
2274
2305
  cursors?.write(sessionId, { ...next, dirty: true });
2275
- const operationId = opId("replace", content);
2306
+ const operationId = opId("replace", `${base}
2307
+ ${content}`);
2276
2308
  await submitWithRetry(() => submit(content, operationId, false), stillOurs, retryUntil);
2277
2309
  ops = [];
2278
2310
  cursors?.write(sessionId, accepted(operationId));
@@ -2396,8 +2428,8 @@ async function waitBounded(p, ms) {
2396
2428
  try {
2397
2429
  await Promise.race([
2398
2430
  p,
2399
- new Promise((resolve3) => {
2400
- timer = setTimeout(resolve3, Math.max(ms, 0));
2431
+ new Promise((resolve4) => {
2432
+ timer = setTimeout(resolve4, Math.max(ms, 0));
2401
2433
  })
2402
2434
  ]);
2403
2435
  } finally {
@@ -2489,12 +2521,12 @@ function buildRetainStamp(cfg, ctx) {
2489
2521
  const base = resolversFor(ctx);
2490
2522
  const cache = /* @__PURE__ */ new Map();
2491
2523
  const resolvers = Object.fromEntries(
2492
- Object.entries(base).map(([name, resolve3]) => [
2524
+ Object.entries(base).map(([name, resolve4]) => [
2493
2525
  name,
2494
2526
  () => {
2495
2527
  const hit = cache.get(name);
2496
2528
  if (hit !== void 0) return hit;
2497
- const value = resolve3();
2529
+ const value = resolve4();
2498
2530
  cache.set(name, value);
2499
2531
  return value;
2500
2532
  }
@@ -2765,7 +2797,7 @@ async function runRetainHook(spec, makeClient = (o) => new HindsightClient(o)) {
2765
2797
 
2766
2798
  // src/core/git.ts
2767
2799
  import { execFileSync as execFileSync2 } from "child_process";
2768
- import { resolve as resolve2 } from "path";
2800
+ import { resolve as resolve3 } from "path";
2769
2801
  var US = "";
2770
2802
  var RS = "";
2771
2803
  var GITLOG_FORMAT = `--format=%h${US}%ad${US}%an${US}%s${US}%b${RS}`;
@@ -2776,11 +2808,14 @@ import { execFileSync as execFileSync4 } from "child_process";
2776
2808
  // src/core/survey.ts
2777
2809
  import { execFileSync as execFileSync3, spawn as realSpawn4 } from "child_process";
2778
2810
  import { createHash as createHash4 } from "crypto";
2779
- import { existsSync as existsSync3 } from "fs";
2811
+ import { existsSync as existsSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync3 } from "fs";
2780
2812
  import { homedir as homedir4, tmpdir as tmpdir3 } from "os";
2781
2813
  import { dirname as dirname8, join as join13 } from "path";
2782
2814
  import { fileURLToPath as fileURLToPath3 } from "url";
2783
2815
 
2816
+ // node_modules/smol-toml/dist/stringify.js
2817
+ var HAS_WELLFORMED = !!"".isWellFormed;
2818
+
2784
2819
  // src/core/survey-lease.ts
2785
2820
  import { spawn as realSpawn3 } from "child_process";
2786
2821
  import { randomUUID } from "crypto";
@@ -2791,7 +2826,7 @@ import {
2791
2826
  renameSync as renameSync3,
2792
2827
  rmdirSync,
2793
2828
  rmSync as rmSync2,
2794
- statSync as statSync3,
2829
+ statSync as statSync4,
2795
2830
  unlinkSync,
2796
2831
  utimesSync,
2797
2832
  writeFileSync as writeFileSync2
@@ -2803,10 +2838,10 @@ import { spawn as realSpawn5 } from "child_process";
2803
2838
  import {
2804
2839
  existsSync as existsSync4,
2805
2840
  mkdirSync as mkdirSync5,
2806
- readFileSync as readFileSync7,
2841
+ readFileSync as readFileSync8,
2807
2842
  realpathSync as realpathSync2,
2808
2843
  unlinkSync as unlinkSync2,
2809
- writeFileSync as writeFileSync3
2844
+ writeFileSync as writeFileSync4
2810
2845
  } from "fs";
2811
2846
  import { homedir as homedir5, tmpdir as tmpdir4 } from "os";
2812
2847
  import { dirname as dirname9, join as join14 } from "path";
@@ -2817,7 +2852,7 @@ var NPM_VIEW_HARD_DEADLINE_MS = NPM_VIEW_TIMEOUT_MS + 1e3;
2817
2852
  var LOCK_STALE_MS = 10 * 60 * 1e3;
2818
2853
 
2819
2854
  // src/core/skill-sync.ts
2820
- import { cpSync, existsSync as existsSync6, readFileSync as readFileSync8 } from "fs";
2855
+ import { cpSync, existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
2821
2856
  import { homedir as homedir6 } from "os";
2822
2857
  import { dirname as dirname10, join as join16 } from "path";
2823
2858
  import { fileURLToPath as fileURLToPath5 } from "url";
@@ -2827,15 +2862,15 @@ import { existsSync as existsSync5 } from "fs";
2827
2862
  import { join as join15 } from "path";
2828
2863
 
2829
2864
  // src/core/legacy.ts
2830
- import { existsSync as existsSync7, readFileSync as readFileSync9 } from "fs";
2865
+ import { existsSync as existsSync7, readFileSync as readFileSync10 } from "fs";
2831
2866
  import { homedir as homedir7 } from "os";
2832
- import { join as join17, relative, isAbsolute as isAbsolute2 } from "path";
2867
+ import { join as join17, relative, isAbsolute as isAbsolute3 } from "path";
2833
2868
 
2834
2869
  // src/core/traecode-mcp.ts
2835
2870
  import { execFileSync as execFileSync5 } from "child_process";
2836
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync10, readdirSync as readdirSync2, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "fs";
2871
+ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync11, readdirSync as readdirSync2, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "fs";
2837
2872
  import { homedir as homedir8 } from "os";
2838
- import { dirname as dirname11, isAbsolute as isAbsolute3, join as join18 } from "path";
2873
+ import { dirname as dirname11, isAbsolute as isAbsolute4, join as join18 } from "path";
2839
2874
  import { fileURLToPath as fileURLToPath6 } from "url";
2840
2875
  var MCP_SERVER_NAME = "hindsight";
2841
2876
  var MCP_FILE_REL = join18(".trae", "mcp.json");
@@ -2870,7 +2905,7 @@ function gateStateFile() {
2870
2905
  }
2871
2906
  function readGateState(opts = {}) {
2872
2907
  try {
2873
- return JSON.parse(readFileSync10(opts.stateFile ?? gateStateFile(), "utf8"));
2908
+ return JSON.parse(readFileSync11(opts.stateFile ?? gateStateFile(), "utf8"));
2874
2909
  } catch {
2875
2910
  return {};
2876
2911
  }
@@ -2878,7 +2913,7 @@ function readGateState(opts = {}) {
2878
2913
  function workspaceMcpGateState(settingsPath) {
2879
2914
  let raw;
2880
2915
  try {
2881
- raw = readFileSync10(settingsPath, "utf8");
2916
+ raw = readFileSync11(settingsPath, "utf8");
2882
2917
  } catch {
2883
2918
  return "unknown";
2884
2919
  }
@@ -2900,7 +2935,7 @@ function workspaceMcpHint(opts = {}) {
2900
2935
  if (typeof state.lastHint === "number" && now - state.lastHint < HINT_MIN_INTERVAL_MS) {
2901
2936
  return void 0;
2902
2937
  }
2903
- writeFileSync4(
2938
+ writeFileSync5(
2904
2939
  opts.stateFile ?? gateStateFile(),
2905
2940
  JSON.stringify({ ...state, lastHint: now }, null, 2) + "\n"
2906
2941
  );
@@ -2918,10 +2953,10 @@ function gitignoreCovers(lines) {
2918
2953
  function ensureGitignored(repo) {
2919
2954
  const gitignore = join18(repo, ".gitignore");
2920
2955
  if (!existsSync8(gitignore)) return;
2921
- const current2 = readFileSync10(gitignore, "utf8");
2956
+ const current2 = readFileSync11(gitignore, "utf8");
2922
2957
  if (gitignoreCovers(current2.split("\n"))) return;
2923
2958
  const addition = (current2.endsWith("\n") || current2 === "" ? "" : "\n") + "# hindsight MCP registration (machine-specific)\n.trae/mcp.json\n";
2924
- writeFileSync4(gitignore, current2 + addition);
2959
+ writeFileSync5(gitignore, current2 + addition);
2925
2960
  }
2926
2961
  function ensureTraecodeWorkspaceMcp(cwd, opts = {}) {
2927
2962
  registerTraecodeWorkspaceMcp(cwd, opts);
@@ -2931,7 +2966,7 @@ function ensureTraecodeWorkspaceMcp(cwd, opts = {}) {
2931
2966
  function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
2932
2967
  try {
2933
2968
  const home = opts.home ?? homedir8();
2934
- if (!cwd || !isAbsolute3(cwd) || dirname11(cwd) === cwd || cwd === home) return "skipped";
2969
+ if (!cwd || !isAbsolute4(cwd) || dirname11(cwd) === cwd || cwd === home) return "skipped";
2935
2970
  const dist = opts.dist ?? bundledDistDir();
2936
2971
  const script = join18(dist, "mcp-server.js");
2937
2972
  if (!existsSync8(script)) return "skipped";
@@ -2939,7 +2974,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
2939
2974
  let doc = {};
2940
2975
  let exists = false;
2941
2976
  try {
2942
- doc = JSON.parse(readFileSync10(file, "utf8"));
2977
+ doc = JSON.parse(readFileSync11(file, "utf8"));
2943
2978
  exists = true;
2944
2979
  } catch {
2945
2980
  if (existsSync8(file)) return "skipped";
@@ -2969,7 +3004,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
2969
3004
  if (existing !== void 0 && canon(merged) === canon(existing)) return "current";
2970
3005
  servers[MCP_SERVER_NAME] = merged;
2971
3006
  mkdirSync6(dirname11(file), { recursive: true });
2972
- writeFileSync4(file, JSON.stringify(doc, null, 2) + "\n");
3007
+ writeFileSync5(file, JSON.stringify(doc, null, 2) + "\n");
2973
3008
  if (!exists) ensureGitignored(cwd);
2974
3009
  diag("traecode", "workspace_mcp_registered", { cwd, file });
2975
3010
  return "registered";
@@ -2995,7 +3030,7 @@ function findWorkspaceStorageDir(storage, repo) {
2995
3030
  }
2996
3031
  for (const name of entries) {
2997
3032
  try {
2998
- const doc = JSON.parse(readFileSync10(join18(storage, name, "workspace.json"), "utf8"));
3033
+ const doc = JSON.parse(readFileSync11(join18(storage, name, "workspace.json"), "utf8"));
2999
3034
  if (typeof doc.folder !== "string") continue;
3000
3035
  let folder;
3001
3036
  try {
@@ -3013,7 +3048,7 @@ function findWorkspaceStorageDir(storage, repo) {
3013
3048
  function ensureWorkspaceMcpEnabled(cwd, opts = {}) {
3014
3049
  try {
3015
3050
  const home = opts.home ?? homedir8();
3016
- if (!cwd || !isAbsolute3(cwd) || dirname11(cwd) === cwd || cwd === home) return "failed";
3051
+ if (!cwd || !isAbsolute4(cwd) || dirname11(cwd) === cwd || cwd === home) return "failed";
3017
3052
  const dir = findWorkspaceStorageDir(traecodeWorkspaceStorageDir(home), cwd);
3018
3053
  if (!dir) return "failed";
3019
3054
  const db = join18(dir, "state.vscdb");
@@ -3048,7 +3083,7 @@ function workspaceEnableHint(opts = {}) {
3048
3083
  if (typeof state.lastEnableHint === "number" && now - state.lastEnableHint < HINT_MIN_INTERVAL_MS) {
3049
3084
  return void 0;
3050
3085
  }
3051
- writeFileSync4(
3086
+ writeFileSync5(
3052
3087
  opts.stateFile ?? gateStateFile(),
3053
3088
  JSON.stringify({ ...state, lastEnableHint: now }, null, 2) + "\n"
3054
3089
  );
@@ -3230,6 +3265,10 @@ function readCursorTranscript(path) {
3230
3265
  }
3231
3266
 
3232
3267
  // src/core/transcript-antigravity.ts
3268
+ function unwrapUserRequest(text) {
3269
+ const request = /<USER_REQUEST>([\s\S]*?)<\/USER_REQUEST>/.exec(text);
3270
+ return request ? request[1] : text.replace(/<ADDITIONAL_METADATA>[\s\S]*?<\/ADDITIONAL_METADATA>/g, "");
3271
+ }
3233
3272
  function readAntigravityTranscript(path) {
3234
3273
  if (!path) return [];
3235
3274
  const turns = [];
@@ -3239,7 +3278,8 @@ function readAntigravityTranscript(path) {
3239
3278
  const role = event.role ?? event.message?.role ?? event.type;
3240
3279
  const normalizedRole = role === "user" || role === "USER_INPUT" ? "user" : role === "assistant" || role === "model" || role === "PLANNER_RESPONSE" ? "assistant" : void 0;
3241
3280
  const content = event.content ?? event.text ?? event.message?.content ?? event.message?.text;
3242
- const clean = typeof content === "string" ? stripInjectedMemory(content).trim() : "";
3281
+ const text = typeof content === "string" ? stripInjectedMemory(content) : "";
3282
+ const clean = (normalizedRole === "user" ? unwrapUserRequest(text) : text).trim();
3243
3283
  if (normalizedRole && clean) {
3244
3284
  turns.push({
3245
3285
  role: normalizedRole,
@@ -3270,7 +3310,7 @@ function readCopilotTranscript(path) {
3270
3310
  }
3271
3311
 
3272
3312
  // src/core/transcript-grok.ts
3273
- import { existsSync as existsSync9, readFileSync as readFileSync11, readdirSync as readdirSync3 } from "fs";
3313
+ import { existsSync as existsSync9, readFileSync as readFileSync12, readdirSync as readdirSync3 } from "fs";
3274
3314
  import { homedir as homedir9 } from "os";
3275
3315
  import { join as join19 } from "path";
3276
3316
  var CHAT_HISTORY = "chat_history.jsonl";
@@ -3281,7 +3321,7 @@ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME ||
3281
3321
  try {
3282
3322
  for (const candidate of readdirSync3(sessionsDir)) {
3283
3323
  const directory = join19(sessionsDir, candidate);
3284
- if (readFileSync11(join19(directory, ".cwd"), "utf8").trim() === cwd) {
3324
+ if (readFileSync12(join19(directory, ".cwd"), "utf8").trim() === cwd) {
3285
3325
  return join19(directory, sessionId, CHAT_HISTORY);
3286
3326
  }
3287
3327
  }
@@ -3632,7 +3672,7 @@ function readDroidTranscript(path) {
3632
3672
  }
3633
3673
 
3634
3674
  // src/core/transcript-zcode.ts
3635
- import { readFileSync as readFileSync12 } from "fs";
3675
+ import { readFileSync as readFileSync13 } from "fs";
3636
3676
  function messageText(content) {
3637
3677
  if (typeof content === "string") return content.trim();
3638
3678
  if (!Array.isArray(content)) return "";
@@ -3642,7 +3682,7 @@ function readZcodeTranscript(path) {
3642
3682
  if (!path) return [];
3643
3683
  let body;
3644
3684
  try {
3645
- body = readFileSync12(path, "utf8");
3685
+ body = readFileSync13(path, "utf8");
3646
3686
  } catch {
3647
3687
  return [];
3648
3688
  }
@@ -3863,12 +3903,12 @@ function readWorkbuddyTranscript(path) {
3863
3903
  }
3864
3904
 
3865
3905
  // src/core/transcript-codebuddy-ide.ts
3866
- import { readFileSync as readFileSync13 } from "fs";
3906
+ import { readFileSync as readFileSync14 } from "fs";
3867
3907
  import { basename as basename3, dirname as dirname12, join as join22 } from "path";
3868
3908
  var IDE_CONTEXT_RE = /<(user_info|git_status|additional_data|system_reminder)\b[\s\S]*?<\/\1>/g;
3869
3909
  function readJson(path) {
3870
3910
  try {
3871
- return JSON.parse(readFileSync13(path, "utf8"));
3911
+ return JSON.parse(readFileSync14(path, "utf8"));
3872
3912
  } catch {
3873
3913
  return void 0;
3874
3914
  }
@@ -4082,7 +4122,9 @@ var HOOK_HARNESSES = {
4082
4122
  parse: (ev) => ({
4083
4123
  sessionId: ev.session_id,
4084
4124
  transcriptPath: ev.transcript_path,
4085
- cwd: ev.cwd
4125
+ cwd: ev.cwd,
4126
+ // The transcript may not hold the final reply yet when Stop fires after a tool call (#5790).
4127
+ lastAssistantMessage: ev.last_assistant_message
4086
4128
  })
4087
4129
  }
4088
4130
  },
@@ -4565,3 +4607,42 @@ var runHarnessRetain = (harness) => runRetainHook(HOOK_HARNESSES[harness].retain
4565
4607
 
4566
4608
  // src/workbuddy-stop-hook.ts
4567
4609
  void runHarnessRetain("workbuddy");
4610
+ /*! Bundled license information:
4611
+
4612
+ smol-toml/dist/error.js:
4613
+ smol-toml/dist/primitive.js:
4614
+ smol-toml/dist/date.js:
4615
+ smol-toml/dist/extract.js:
4616
+ smol-toml/dist/util.js:
4617
+ smol-toml/dist/struct.js:
4618
+ smol-toml/dist/parse.js:
4619
+ smol-toml/dist/stringify.js:
4620
+ smol-toml/dist/index.js:
4621
+ (*!
4622
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
4623
+ * SPDX-License-Identifier: BSD-3-Clause
4624
+ *
4625
+ * Redistribution and use in source and binary forms, with or without
4626
+ * modification, are permitted provided that the following conditions are met:
4627
+ *
4628
+ * 1. Redistributions of source code must retain the above copyright notice, this
4629
+ * list of conditions and the following disclaimer.
4630
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
4631
+ * this list of conditions and the following disclaimer in the
4632
+ * documentation and/or other materials provided with the distribution.
4633
+ * 3. Neither the name of the copyright holder nor the names of its contributors
4634
+ * may be used to endorse or promote products derived from this software without
4635
+ * specific prior written permission.
4636
+ *
4637
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
4638
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
4639
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4640
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
4641
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4642
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
4643
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
4644
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
4645
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4646
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4647
+ *)
4648
+ */