@vectorize-io/hindsight-coding-agents 0.5.3 → 0.5.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 (46) hide show
  1. package/dist/antigravity-hook.js +67 -33
  2. package/dist/antigravity-stop-hook.js +61 -31
  3. package/dist/claude-hook.js +67 -33
  4. package/dist/claude-sessionstart-hook.js +239 -71
  5. package/dist/claude-stop-hook.js +61 -31
  6. package/dist/cline.js +213 -50
  7. package/dist/codex-hook.js +67 -33
  8. package/dist/codex-sessionstart-hook.js +239 -71
  9. package/dist/codex-stop-hook.js +61 -31
  10. package/dist/copilot-hook.js +67 -33
  11. package/dist/copilot-sessionstart-hook.js +239 -71
  12. package/dist/copilot-stop-hook.js +61 -31
  13. package/dist/cursor-hook.js +67 -33
  14. package/dist/cursor-sessionstart-hook.js +239 -71
  15. package/dist/cursor-stop-hook.js +61 -31
  16. package/dist/dcode-hook.js +67 -33
  17. package/dist/dcode-sessionstart-hook.js +239 -71
  18. package/dist/dcode-stop-hook.js +61 -31
  19. package/dist/deepen.js +40 -13
  20. package/dist/devin-hook.js +67 -33
  21. package/dist/devin-sessionstart-hook.js +239 -71
  22. package/dist/devin-stop-hook.js +61 -31
  23. package/dist/droid-hook.js +67 -33
  24. package/dist/droid-sessionstart-hook.js +239 -71
  25. package/dist/droid-stop-hook.js +61 -31
  26. package/dist/dsh.js +215 -52
  27. package/dist/grok-hook.js +67 -33
  28. package/dist/grok-sessionstart-hook.js +239 -71
  29. package/dist/grok-stop-hook.js +61 -31
  30. package/dist/index.js +215 -52
  31. package/dist/installer.js +1030 -268
  32. package/dist/kilo.js +215 -52
  33. package/dist/mcp-server.js +33 -6
  34. package/dist/opencode2.js +215 -52
  35. package/dist/pi.js +214 -51
  36. package/dist/prime-agent.js +214 -51
  37. package/dist/qwen-hook.js +67 -33
  38. package/dist/qwen-sessionstart-hook.js +239 -71
  39. package/dist/qwen-stop-hook.js +61 -31
  40. package/dist/status.js +31 -4
  41. package/dist/survey-supervisor.js +81 -0
  42. package/dist/zcode-hook.js +67 -33
  43. package/dist/zcode-sessionstart-hook.js +239 -71
  44. package/dist/zcode-stop-hook.js +61 -31
  45. package/package.json +2 -1
  46. package/plugin.json +1 -1
@@ -922,9 +922,16 @@ var HindsightClient = class {
922
922
  body: JSON.stringify({ query, budget: opts.budget ?? "high" }),
923
923
  signal: ctrl.signal
924
924
  });
925
- if (!resp.ok) throw new Error(`reflect ${resp.status}${this.authHint(resp.status)}`);
925
+ if (!resp.ok)
926
+ throw new Error(
927
+ `reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}`
928
+ );
926
929
  const data = await resp.json();
927
930
  return (data.text || "").trim();
931
+ } catch (e) {
932
+ if (ctrl.signal.aborted)
933
+ throw new Error(`reflect timed out after ${opts.timeoutMs}ms`, { cause: e });
934
+ throw e;
928
935
  } finally {
929
936
  clearTimeout(timer);
930
937
  }
@@ -2173,7 +2180,7 @@ async function runRetainHook(spec, makeClient = (o) => new HindsightClient(o)) {
2173
2180
  }
2174
2181
 
2175
2182
  // src/core/session-start.ts
2176
- import { readFileSync as readFileSync9 } from "fs";
2183
+ import { readFileSync as readFileSync10 } from "fs";
2177
2184
 
2178
2185
  // src/core/git.ts
2179
2186
  import { execFileSync as execFileSync2 } from "child_process";
@@ -2183,24 +2190,42 @@ import { resolve as resolve2 } from "path";
2183
2190
  import { execFileSync as execFileSync3 } from "child_process";
2184
2191
 
2185
2192
  // src/core/survey.ts
2186
- import { spawn as realSpawn3 } from "child_process";
2193
+ import { spawn as realSpawn4 } from "child_process";
2194
+ import { createHash as createHash4 } from "crypto";
2187
2195
  import { existsSync as existsSync3 } from "fs";
2188
- import { homedir as homedir3 } from "os";
2189
- import { dirname as dirname8, join as join10 } from "path";
2196
+ import { homedir as homedir3, tmpdir as tmpdir4 } from "os";
2197
+ import { dirname as dirname8, join as join11 } from "path";
2190
2198
  import { fileURLToPath as fileURLToPath3 } from "url";
2191
2199
 
2200
+ // src/core/survey-lease.ts
2201
+ import { spawn as realSpawn3 } from "child_process";
2202
+ import { randomUUID } from "crypto";
2203
+ import {
2204
+ mkdirSync as mkdirSync4,
2205
+ mkdtempSync,
2206
+ readdirSync,
2207
+ renameSync as renameSync2,
2208
+ rmdirSync,
2209
+ rmSync as rmSync2,
2210
+ statSync as statSync3,
2211
+ unlinkSync,
2212
+ utimesSync,
2213
+ writeFileSync as writeFileSync2
2214
+ } from "fs";
2215
+ import { join as join10 } from "path";
2216
+
2192
2217
  // src/core/auto-update.ts
2193
- import { spawn as realSpawn4 } from "child_process";
2218
+ import { spawn as realSpawn5 } from "child_process";
2194
2219
  import {
2195
2220
  existsSync as existsSync4,
2196
- mkdirSync as mkdirSync4,
2221
+ mkdirSync as mkdirSync5,
2197
2222
  readFileSync as readFileSync7,
2198
2223
  realpathSync as realpathSync2,
2199
- unlinkSync,
2200
- writeFileSync as writeFileSync2
2224
+ unlinkSync as unlinkSync2,
2225
+ writeFileSync as writeFileSync3
2201
2226
  } from "fs";
2202
- import { homedir as homedir4, tmpdir as tmpdir4 } from "os";
2203
- import { dirname as dirname9, join as join11 } from "path";
2227
+ import { homedir as homedir4, tmpdir as tmpdir5 } from "os";
2228
+ import { dirname as dirname9, join as join12 } from "path";
2204
2229
  import { fileURLToPath as fileURLToPath4 } from "url";
2205
2230
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
2206
2231
  var LOCK_STALE_MS = 10 * 60 * 1e3;
@@ -2208,9 +2233,14 @@ var LOCK_STALE_MS = 10 * 60 * 1e3;
2208
2233
  // src/core/skill-sync.ts
2209
2234
  import { cpSync, existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
2210
2235
  import { homedir as homedir5 } from "os";
2211
- import { dirname as dirname10, join as join12 } from "path";
2236
+ import { dirname as dirname10, join as join13 } from "path";
2212
2237
  import { fileURLToPath as fileURLToPath5 } from "url";
2213
2238
 
2239
+ // src/core/legacy.ts
2240
+ import { existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
2241
+ import { homedir as homedir6 } from "os";
2242
+ import { join as join14, relative, isAbsolute as isAbsolute2 } from "path";
2243
+
2214
2244
  // src/core/transcript-codex.ts
2215
2245
  function isSyntheticUserText(text) {
2216
2246
  const s = text.trimStart();
@@ -2341,19 +2371,19 @@ function readCopilotTranscript(path) {
2341
2371
  }
2342
2372
 
2343
2373
  // src/core/transcript-grok.ts
2344
- import { existsSync as existsSync6, readFileSync as readFileSync10, readdirSync } from "fs";
2345
- import { homedir as homedir6 } from "os";
2346
- import { join as join13 } from "path";
2374
+ import { existsSync as existsSync7, readFileSync as readFileSync11, readdirSync as readdirSync2 } from "fs";
2375
+ import { homedir as homedir7 } from "os";
2376
+ import { join as join15 } from "path";
2347
2377
  var CHAT_HISTORY = "chat_history.jsonl";
2348
- function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join13(homedir6(), ".grok")) {
2349
- const sessionsDir = join13(grokHome, "sessions");
2350
- const direct = join13(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2351
- if (existsSync6(direct)) return direct;
2378
+ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join15(homedir7(), ".grok")) {
2379
+ const sessionsDir = join15(grokHome, "sessions");
2380
+ const direct = join15(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2381
+ if (existsSync7(direct)) return direct;
2352
2382
  try {
2353
- for (const candidate of readdirSync(sessionsDir)) {
2354
- const directory = join13(sessionsDir, candidate);
2355
- if (readFileSync10(join13(directory, ".cwd"), "utf8").trim() === cwd) {
2356
- return join13(directory, sessionId, CHAT_HISTORY);
2383
+ for (const candidate of readdirSync2(sessionsDir)) {
2384
+ const directory = join15(sessionsDir, candidate);
2385
+ if (readFileSync11(join15(directory, ".cwd"), "utf8").trim() === cwd) {
2386
+ return join15(directory, sessionId, CHAT_HISTORY);
2357
2387
  }
2358
2388
  }
2359
2389
  } catch {
@@ -2388,12 +2418,12 @@ function readGrokTranscript(path) {
2388
2418
  }
2389
2419
 
2390
2420
  // src/core/transcript-devin.ts
2391
- import { existsSync as existsSync7 } from "fs";
2421
+ import { existsSync as existsSync8 } from "fs";
2392
2422
  import { createRequire } from "module";
2393
- import { homedir as homedir7 } from "os";
2394
- import { join as join14 } from "path";
2395
- function devinSessionDb(home = homedir7()) {
2396
- return join14(home, ".local", "share", "devin", "cli", "sessions.db");
2423
+ import { homedir as homedir8 } from "os";
2424
+ import { join as join16 } from "path";
2425
+ function devinSessionDb(home = homedir8()) {
2426
+ return join16(home, ".local", "share", "devin", "cli", "sessions.db");
2397
2427
  }
2398
2428
  function parseDevinMessages(nodes) {
2399
2429
  const messages = /* @__PURE__ */ new Map();
@@ -2430,7 +2460,7 @@ function readDevinTranscript(sessionId, dbPath = devinSessionDb()) {
2430
2460
  diag("devin-cli", "sqlite_unavailable", { node: process.version, dbPath });
2431
2461
  return [];
2432
2462
  }
2433
- if (!existsSync7(dbPath)) {
2463
+ if (!existsSync8(dbPath)) {
2434
2464
  diag("devin-cli", "session_db_missing", { dbPath });
2435
2465
  return [];
2436
2466
  }
@@ -2703,7 +2733,7 @@ function readDroidTranscript(path) {
2703
2733
  }
2704
2734
 
2705
2735
  // src/core/transcript-zcode.ts
2706
- import { readFileSync as readFileSync11 } from "fs";
2736
+ import { readFileSync as readFileSync12 } from "fs";
2707
2737
  function messageText2(content) {
2708
2738
  if (typeof content === "string") return content.trim();
2709
2739
  if (!Array.isArray(content)) return "";
@@ -2713,7 +2743,7 @@ function readZcodeTranscript(path) {
2713
2743
  if (!path) return [];
2714
2744
  let body;
2715
2745
  try {
2716
- body = readFileSync11(path, "utf8");
2746
+ body = readFileSync12(path, "utf8");
2717
2747
  } catch {
2718
2748
  return [];
2719
2749
  }
package/dist/deepen.js CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  // src/deepen.ts
4
4
  import { execFileSync as execFileSync3 } from "child_process";
5
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, unlinkSync, writeFileSync } from "fs";
6
- import { tmpdir as tmpdir2 } from "os";
7
- import { join as join8 } from "path";
5
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
6
+ import { tmpdir as tmpdir3 } from "os";
7
+ import { join as join9 } from "path";
8
8
 
9
9
  // src/core/bank.ts
10
10
  import { existsSync } from "fs";
@@ -927,9 +927,16 @@ var HindsightClient = class {
927
927
  body: JSON.stringify({ query, budget: opts.budget ?? "high" }),
928
928
  signal: ctrl.signal
929
929
  });
930
- if (!resp.ok) throw new Error(`reflect ${resp.status}${this.authHint(resp.status)}`);
930
+ if (!resp.ok)
931
+ throw new Error(
932
+ `reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}`
933
+ );
931
934
  const data = await resp.json();
932
935
  return (data.text || "").trim();
936
+ } catch (e) {
937
+ if (ctrl.signal.aborted)
938
+ throw new Error(`reflect timed out after ${opts.timeoutMs}ms`, { cause: e });
939
+ throw e;
933
940
  } finally {
934
941
  clearTimeout(timer);
935
942
  }
@@ -1681,11 +1688,31 @@ async function syncGitLog(client, repo, opts) {
1681
1688
  }
1682
1689
 
1683
1690
  // src/core/survey.ts
1684
- import { spawn as realSpawn2 } from "child_process";
1691
+ import { spawn as realSpawn3 } from "child_process";
1692
+ import { createHash as createHash4 } from "crypto";
1685
1693
  import { existsSync as existsSync2 } from "fs";
1686
- import { homedir as homedir3 } from "os";
1687
- import { dirname as dirname5, join as join7 } from "path";
1694
+ import { homedir as homedir3, tmpdir as tmpdir2 } from "os";
1695
+ import { dirname as dirname5, join as join8 } from "path";
1688
1696
  import { fileURLToPath as fileURLToPath2 } from "url";
1697
+
1698
+ // src/core/survey-lease.ts
1699
+ import { spawn as realSpawn2 } from "child_process";
1700
+ import { randomUUID } from "crypto";
1701
+ import {
1702
+ mkdirSync as mkdirSync2,
1703
+ mkdtempSync,
1704
+ readdirSync,
1705
+ renameSync,
1706
+ rmdirSync,
1707
+ rmSync,
1708
+ statSync,
1709
+ unlinkSync,
1710
+ utimesSync,
1711
+ writeFileSync
1712
+ } from "fs";
1713
+ import { join as join7 } from "path";
1714
+
1715
+ // src/core/survey.ts
1689
1716
  var SURVEY_DOC_IDS = [
1690
1717
  "repository-component-map",
1691
1718
  "repository-core-concepts",
@@ -1871,8 +1898,8 @@ var log2 = (m) => {
1871
1898
  console.log(`${(/* @__PURE__ */ new Date()).toISOString()} ${m}`);
1872
1899
  log.info("deepen", m);
1873
1900
  };
1874
- var LOCK_DIR = join8(tmpdir2(), "hindsight-coding-agent");
1875
- var LOCK = join8(LOCK_DIR, `deepen-${encodeURIComponent(FINAL_BANK ?? "")}.lock`);
1901
+ var LOCK_DIR = join9(tmpdir3(), "hindsight-coding-agent");
1902
+ var LOCK = join9(LOCK_DIR, `deepen-${encodeURIComponent(FINAL_BANK ?? "")}.lock`);
1876
1903
  function acquireLock() {
1877
1904
  try {
1878
1905
  const held = JSON.parse(readFileSync4(LOCK, "utf8"));
@@ -1890,8 +1917,8 @@ function acquireLock() {
1890
1917
  } catch {
1891
1918
  }
1892
1919
  try {
1893
- mkdirSync2(LOCK_DIR, { recursive: true });
1894
- writeFileSync(LOCK, JSON.stringify({ pid: process.pid, ts: Date.now() }));
1920
+ mkdirSync3(LOCK_DIR, { recursive: true });
1921
+ writeFileSync2(LOCK, JSON.stringify({ pid: process.pid, ts: Date.now() }));
1895
1922
  return true;
1896
1923
  } catch {
1897
1924
  return false;
@@ -2046,7 +2073,7 @@ async function main() {
2046
2073
  );
2047
2074
  } finally {
2048
2075
  try {
2049
- unlinkSync(LOCK);
2076
+ unlinkSync2(LOCK);
2050
2077
  } catch {
2051
2078
  }
2052
2079
  }
@@ -2058,7 +2085,7 @@ main().catch((e) => {
2058
2085
  });
2059
2086
  console.error("deepen failed:", e.message || e);
2060
2087
  try {
2061
- unlinkSync(LOCK);
2088
+ unlinkSync2(LOCK);
2062
2089
  } catch {
2063
2090
  }
2064
2091
  process.exit(1);
@@ -946,9 +946,16 @@ var HindsightClient = class {
946
946
  body: JSON.stringify({ query, budget: opts.budget ?? "high" }),
947
947
  signal: ctrl.signal
948
948
  });
949
- if (!resp.ok) throw new Error(`reflect ${resp.status}${this.authHint(resp.status)}`);
949
+ if (!resp.ok)
950
+ throw new Error(
951
+ `reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}`
952
+ );
950
953
  const data = await resp.json();
951
954
  return (data.text || "").trim();
955
+ } catch (e) {
956
+ if (ctrl.signal.aborted)
957
+ throw new Error(`reflect timed out after ${opts.timeoutMs}ms`, { cause: e });
958
+ throw e;
952
959
  } finally {
953
960
  clearTimeout(timer);
954
961
  }
@@ -1702,13 +1709,14 @@ async function buildHookOutput(args) {
1702
1709
  } else if (cfg.autoReflect && reflectAnswer === void 0) {
1703
1710
  reflectRanThisTurn = true;
1704
1711
  const t0 = Date.now();
1712
+ const timeoutMs = Math.min(cfg.reflectTimeoutMs, HOOK_REFLECT_CAP_MS);
1705
1713
  try {
1706
1714
  reflectAnswer = await client.reflect(buildReflectQuery(prompt), {
1707
1715
  // Automatic reflection runs inside a hard 25s hook window. Hindsight's low budget is the
1708
1716
  // supported default for bounded reflect calls; callers that explicitly invoke the MCP
1709
1717
  // tool still get the deeper high-budget path.
1710
1718
  budget: "low",
1711
- timeoutMs: Math.min(cfg.reflectTimeoutMs, HOOK_REFLECT_CAP_MS)
1719
+ timeoutMs
1712
1720
  });
1713
1721
  diag(harness, reflectAnswer ? "reflect_ok" : "reflect_empty", {
1714
1722
  ms: Date.now() - t0,
@@ -1726,7 +1734,10 @@ async function buildHookOutput(args) {
1726
1734
  });
1727
1735
  diag(harness, "reflect_failed", {
1728
1736
  ms: Date.now() - t0,
1729
- error: describeError(e),
1737
+ bank: client.bank,
1738
+ timeoutMs,
1739
+ // Wider than describeError's default: the server's error body is the useful part.
1740
+ error: describeError(e, 1500),
1730
1741
  query: prompt.slice(0, 80)
1731
1742
  });
1732
1743
  }
@@ -1905,7 +1916,7 @@ function* streamLines(path, start) {
1905
1916
  }
1906
1917
 
1907
1918
  // src/core/session-start.ts
1908
- import { readFileSync as readFileSync9 } from "fs";
1919
+ import { readFileSync as readFileSync10 } from "fs";
1909
1920
 
1910
1921
  // src/core/git.ts
1911
1922
  import { execFileSync as execFileSync2 } from "child_process";
@@ -1915,24 +1926,42 @@ import { resolve as resolve2 } from "path";
1915
1926
  import { execFileSync as execFileSync3 } from "child_process";
1916
1927
 
1917
1928
  // src/core/survey.ts
1918
- import { spawn as realSpawn3 } from "child_process";
1929
+ import { spawn as realSpawn4 } from "child_process";
1930
+ import { createHash as createHash4 } from "crypto";
1919
1931
  import { existsSync as existsSync3 } from "fs";
1920
- import { homedir as homedir3 } from "os";
1921
- import { dirname as dirname8, join as join10 } from "path";
1932
+ import { homedir as homedir3, tmpdir as tmpdir4 } from "os";
1933
+ import { dirname as dirname8, join as join11 } from "path";
1922
1934
  import { fileURLToPath as fileURLToPath3 } from "url";
1923
1935
 
1936
+ // src/core/survey-lease.ts
1937
+ import { spawn as realSpawn3 } from "child_process";
1938
+ import { randomUUID } from "crypto";
1939
+ import {
1940
+ mkdirSync as mkdirSync4,
1941
+ mkdtempSync,
1942
+ readdirSync,
1943
+ renameSync as renameSync2,
1944
+ rmdirSync,
1945
+ rmSync as rmSync2,
1946
+ statSync as statSync3,
1947
+ unlinkSync,
1948
+ utimesSync,
1949
+ writeFileSync as writeFileSync2
1950
+ } from "fs";
1951
+ import { join as join10 } from "path";
1952
+
1924
1953
  // src/core/auto-update.ts
1925
- import { spawn as realSpawn4 } from "child_process";
1954
+ import { spawn as realSpawn5 } from "child_process";
1926
1955
  import {
1927
1956
  existsSync as existsSync4,
1928
- mkdirSync as mkdirSync4,
1957
+ mkdirSync as mkdirSync5,
1929
1958
  readFileSync as readFileSync7,
1930
1959
  realpathSync as realpathSync2,
1931
- unlinkSync,
1932
- writeFileSync as writeFileSync2
1960
+ unlinkSync as unlinkSync2,
1961
+ writeFileSync as writeFileSync3
1933
1962
  } from "fs";
1934
- import { homedir as homedir4, tmpdir as tmpdir4 } from "os";
1935
- import { dirname as dirname9, join as join11 } from "path";
1963
+ import { homedir as homedir4, tmpdir as tmpdir5 } from "os";
1964
+ import { dirname as dirname9, join as join12 } from "path";
1936
1965
  import { fileURLToPath as fileURLToPath4 } from "url";
1937
1966
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
1938
1967
  var LOCK_STALE_MS = 10 * 60 * 1e3;
@@ -1940,9 +1969,14 @@ var LOCK_STALE_MS = 10 * 60 * 1e3;
1940
1969
  // src/core/skill-sync.ts
1941
1970
  import { cpSync, existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
1942
1971
  import { homedir as homedir5 } from "os";
1943
- import { dirname as dirname10, join as join12 } from "path";
1972
+ import { dirname as dirname10, join as join13 } from "path";
1944
1973
  import { fileURLToPath as fileURLToPath5 } from "url";
1945
1974
 
1975
+ // src/core/legacy.ts
1976
+ import { existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
1977
+ import { homedir as homedir6 } from "os";
1978
+ import { join as join14, relative, isAbsolute as isAbsolute2 } from "path";
1979
+
1946
1980
  // src/core/transcript-codex.ts
1947
1981
  function isSyntheticUserText(text) {
1948
1982
  const s = text.trimStart();
@@ -2073,19 +2107,19 @@ function readCopilotTranscript(path) {
2073
2107
  }
2074
2108
 
2075
2109
  // src/core/transcript-grok.ts
2076
- import { existsSync as existsSync6, readFileSync as readFileSync10, readdirSync } from "fs";
2077
- import { homedir as homedir6 } from "os";
2078
- import { join as join13 } from "path";
2110
+ import { existsSync as existsSync7, readFileSync as readFileSync11, readdirSync as readdirSync2 } from "fs";
2111
+ import { homedir as homedir7 } from "os";
2112
+ import { join as join15 } from "path";
2079
2113
  var CHAT_HISTORY = "chat_history.jsonl";
2080
- function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join13(homedir6(), ".grok")) {
2081
- const sessionsDir = join13(grokHome, "sessions");
2082
- const direct = join13(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2083
- if (existsSync6(direct)) return direct;
2114
+ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join15(homedir7(), ".grok")) {
2115
+ const sessionsDir = join15(grokHome, "sessions");
2116
+ const direct = join15(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2117
+ if (existsSync7(direct)) return direct;
2084
2118
  try {
2085
- for (const candidate of readdirSync(sessionsDir)) {
2086
- const directory = join13(sessionsDir, candidate);
2087
- if (readFileSync10(join13(directory, ".cwd"), "utf8").trim() === cwd) {
2088
- return join13(directory, sessionId, CHAT_HISTORY);
2119
+ for (const candidate of readdirSync2(sessionsDir)) {
2120
+ const directory = join15(sessionsDir, candidate);
2121
+ if (readFileSync11(join15(directory, ".cwd"), "utf8").trim() === cwd) {
2122
+ return join15(directory, sessionId, CHAT_HISTORY);
2089
2123
  }
2090
2124
  }
2091
2125
  } catch {
@@ -2120,12 +2154,12 @@ function readGrokTranscript(path) {
2120
2154
  }
2121
2155
 
2122
2156
  // src/core/transcript-devin.ts
2123
- import { existsSync as existsSync7 } from "fs";
2157
+ import { existsSync as existsSync8 } from "fs";
2124
2158
  import { createRequire } from "module";
2125
- import { homedir as homedir7 } from "os";
2126
- import { join as join14 } from "path";
2127
- function devinSessionDb(home = homedir7()) {
2128
- return join14(home, ".local", "share", "devin", "cli", "sessions.db");
2159
+ import { homedir as homedir8 } from "os";
2160
+ import { join as join16 } from "path";
2161
+ function devinSessionDb(home = homedir8()) {
2162
+ return join16(home, ".local", "share", "devin", "cli", "sessions.db");
2129
2163
  }
2130
2164
  function parseDevinMessages(nodes) {
2131
2165
  const messages = /* @__PURE__ */ new Map();
@@ -2162,7 +2196,7 @@ function readDevinTranscript(sessionId, dbPath = devinSessionDb()) {
2162
2196
  diag("devin-cli", "sqlite_unavailable", { node: process.version, dbPath });
2163
2197
  return [];
2164
2198
  }
2165
- if (!existsSync7(dbPath)) {
2199
+ if (!existsSync8(dbPath)) {
2166
2200
  diag("devin-cli", "session_db_missing", { dbPath });
2167
2201
  return [];
2168
2202
  }
@@ -2435,7 +2469,7 @@ function readDroidTranscript(path) {
2435
2469
  }
2436
2470
 
2437
2471
  // src/core/transcript-zcode.ts
2438
- import { readFileSync as readFileSync11 } from "fs";
2472
+ import { readFileSync as readFileSync12 } from "fs";
2439
2473
  function messageText2(content) {
2440
2474
  if (typeof content === "string") return content.trim();
2441
2475
  if (!Array.isArray(content)) return "";
@@ -2445,7 +2479,7 @@ function readZcodeTranscript(path) {
2445
2479
  if (!path) return [];
2446
2480
  let body;
2447
2481
  try {
2448
- body = readFileSync11(path, "utf8");
2482
+ body = readFileSync12(path, "utf8");
2449
2483
  } catch {
2450
2484
  return [];
2451
2485
  }