@vectorize-io/hindsight-coding-agents 0.5.5 → 0.6.0

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 (50) hide show
  1. package/README.md +19 -5
  2. package/dist/antigravity-hook.js +84 -70
  3. package/dist/antigravity-statusline.js +32 -22
  4. package/dist/antigravity-stop-hook.js +160 -71
  5. package/dist/claude-hook.js +84 -70
  6. package/dist/claude-sessionstart-hook.js +111 -97
  7. package/dist/claude-stop-hook.js +160 -71
  8. package/dist/cline.js +158 -75
  9. package/dist/codex-hook.js +84 -70
  10. package/dist/codex-sessionstart-hook.js +111 -97
  11. package/dist/codex-stop-hook.js +160 -71
  12. package/dist/copilot-hook.js +84 -70
  13. package/dist/copilot-sessionstart-hook.js +111 -97
  14. package/dist/copilot-stop-hook.js +160 -71
  15. package/dist/cursor-hook.js +84 -70
  16. package/dist/cursor-sessionstart-hook.js +111 -97
  17. package/dist/cursor-stop-hook.js +160 -71
  18. package/dist/daemon-start.js +28 -18
  19. package/dist/dcode-hook.js +84 -70
  20. package/dist/dcode-sessionstart-hook.js +111 -97
  21. package/dist/dcode-stop-hook.js +160 -71
  22. package/dist/deepen.js +42 -32
  23. package/dist/devin-hook.js +84 -70
  24. package/dist/devin-sessionstart-hook.js +111 -97
  25. package/dist/devin-stop-hook.js +160 -71
  26. package/dist/droid-hook.js +84 -70
  27. package/dist/droid-sessionstart-hook.js +111 -97
  28. package/dist/droid-stop-hook.js +160 -71
  29. package/dist/dsh.js +156 -74
  30. package/dist/grok-hook.js +84 -70
  31. package/dist/grok-sessionstart-hook.js +111 -97
  32. package/dist/grok-stop-hook.js +160 -71
  33. package/dist/hindsight-seed.js +32 -22
  34. package/dist/index.js +159 -77
  35. package/dist/installer.js +308 -214
  36. package/dist/kilo.js +159 -77
  37. package/dist/mcp-server.js +41 -31
  38. package/dist/opencode2.js +158 -76
  39. package/dist/pi.js +158 -76
  40. package/dist/prime-agent.js +158 -76
  41. package/dist/qwen-hook.js +84 -70
  42. package/dist/qwen-sessionstart-hook.js +111 -97
  43. package/dist/qwen-stop-hook.js +160 -71
  44. package/dist/status.js +38 -28
  45. package/dist/zcode-hook.js +84 -70
  46. package/dist/zcode-sessionstart-hook.js +111 -97
  47. package/dist/zcode-stop-hook.js +160 -71
  48. package/package.json +1 -1
  49. package/plugin.json +1 -1
  50. package/skill/SKILL.md +19 -5
@@ -5,16 +5,28 @@ import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
5
5
 
6
6
  // src/core/bank.ts
7
7
  import { existsSync } from "fs";
8
- import { homedir } from "os";
9
- import { basename, dirname as dirname3, join as join3, normalize, sep } from "path";
8
+ import { homedir as homedir2 } from "os";
9
+ import { basename, dirname as dirname3, join as join4, normalize, sep } from "path";
10
10
 
11
11
  // src/core/diag.ts
12
- import { appendFileSync as appendFileSync2 } from "fs";
12
+ import { join as join2 } from "path";
13
13
 
14
14
  // src/core/log.ts
15
- import { appendFileSync, mkdirSync } from "fs";
16
- import { tmpdir } from "os";
15
+ import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
16
+ import { homedir } from "os";
17
17
  import { dirname, join } from "path";
18
+ function logsDir() {
19
+ return join(homedir(), ".hindsight", "coding-agents-logs");
20
+ }
21
+ var LOG_MAX_BYTES = 10 * 1024 * 1024;
22
+ function appendLogLine(file, text) {
23
+ mkdirSync(dirname(file), { recursive: true, mode: 448 });
24
+ try {
25
+ if (statSync(file).size >= LOG_MAX_BYTES) renameSync(file, `${file}.1`);
26
+ } catch {
27
+ }
28
+ appendFileSync(file, text, { mode: 384 });
29
+ }
18
30
  var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
19
31
  var current = ["debug", "info", "warn", "error"].find(
20
32
  (l) => l === process.env.HINDSIGHT_LOG_LEVEL
@@ -23,15 +35,13 @@ function setLogLevel(level) {
23
35
  if (!process.env.HINDSIGHT_LOG_LEVEL) current = level;
24
36
  }
25
37
  function logFilePath() {
26
- return process.env.HINDSIGHT_LOG_FILE || join(tmpdir(), "hindsight-coding-agent", "plugin.log");
38
+ return process.env.HINDSIGHT_LOG_FILE || join(logsDir(), "plugin.log");
27
39
  }
28
40
  function write(level, scope, msg, extra) {
29
41
  if (WEIGHT[level] < WEIGHT[current]) return;
30
42
  try {
31
- const file = logFilePath();
32
- mkdirSync(dirname(file), { recursive: true });
33
- appendFileSync(
34
- file,
43
+ appendLogLine(
44
+ logFilePath(),
35
45
  `${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
36
46
  );
37
47
  } catch {
@@ -60,12 +70,12 @@ function describeError(value, maxChars = 200) {
60
70
 
61
71
  // src/core/diag.ts
62
72
  function diagFilePath() {
63
- return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
73
+ return process.env.HINDSIGHT_DIAG_FILE || join2(logsDir(), "diag.jsonl");
64
74
  }
65
75
  function diag(harness, event, extra = {}) {
66
76
  log.debug(harness, `diag:${event}`, extra);
67
77
  try {
68
- appendFileSync2(
78
+ appendLogLine(
69
79
  diagFilePath(),
70
80
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
71
81
  );
@@ -75,7 +85,7 @@ function diag(harness, event, extra = {}) {
75
85
 
76
86
  // src/core/git-layout.ts
77
87
  import { lstatSync, readFileSync, realpathSync } from "fs";
78
- import { dirname as dirname2, isAbsolute, join as join2, resolve } from "path";
88
+ import { dirname as dirname2, isAbsolute, join as join3, resolve } from "path";
79
89
  var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
80
90
  var ATTEMPTS = 3;
81
91
  var BACKOFF_MS = 20;
@@ -111,16 +121,16 @@ function gitDirFromPointer(text, holder) {
111
121
  return isAbsolute(target) ? target : resolve(holder, target);
112
122
  }
113
123
  function commonDirOf(gitDir) {
114
- const pointer = entryKind(join2(gitDir, "commondir")) === "file" ? readTextOrNull(join2(gitDir, "commondir"))?.trim() : null;
124
+ const pointer = entryKind(join3(gitDir, "commondir")) === "file" ? readTextOrNull(join3(gitDir, "commondir"))?.trim() : null;
115
125
  if (!pointer) return gitDir;
116
126
  return isAbsolute(pointer) ? pointer : resolve(gitDir, pointer);
117
127
  }
118
128
  function isBare(commonDir) {
119
- const config = readTextOrNull(join2(commonDir, "config"));
129
+ const config = readTextOrNull(join3(commonDir, "config"));
120
130
  return config !== null && /^\s*bare\s*=\s*true\s*$/im.test(config);
121
131
  }
122
132
  function looksLikeBareRepository(directory) {
123
- return entryKind(join2(directory, "HEAD")) === "file" && entryKind(join2(directory, "objects")) === "dir" && entryKind(join2(directory, "refs")) === "dir";
133
+ return entryKind(join3(directory, "HEAD")) === "file" && entryKind(join3(directory, "objects")) === "dir" && entryKind(join3(directory, "refs")) === "dir";
124
134
  }
125
135
  function canonical(path) {
126
136
  try {
@@ -137,7 +147,7 @@ function resolved(commonDir) {
137
147
  function probeOnce(directory) {
138
148
  let current2 = resolve(directory);
139
149
  for (; ; ) {
140
- const dotGit = join2(current2, ".git");
150
+ const dotGit = join3(current2, ".git");
141
151
  const kind = entryKind(dotGit);
142
152
  if (kind === "dir") {
143
153
  const layout = resolved(commonDirOf(dotGit));
@@ -251,7 +261,7 @@ function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
251
261
  return dirName(sessionRoot || directory);
252
262
  }
253
263
  function configuredDir(dir) {
254
- const expanded = dir === "~" || dir.startsWith("~/") ? join3(homedir(), dir.slice(1)) : dir;
264
+ const expanded = dir === "~" || dir.startsWith("~/") ? join4(homedir2(), dir.slice(1)) : dir;
255
265
  return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
256
266
  }
257
267
  function isWithin(directory, configured) {
@@ -325,12 +335,12 @@ function deriveBankIdOrSkip(config, directory, harness = "coding", sessionRoot)
325
335
 
326
336
  // src/core/config.ts
327
337
  import { readFileSync as readFileSync2 } from "fs";
328
- import { homedir as homedir2 } from "os";
329
- import { join as join6 } from "path";
338
+ import { homedir as homedir3 } from "os";
339
+ import { join as join7 } from "path";
330
340
 
331
341
  // src/core/seed.ts
332
342
  import { spawn as realSpawn } from "child_process";
333
- import { dirname as dirname4, join as join4 } from "path";
343
+ import { dirname as dirname4, join as join5 } from "path";
334
344
  import { fileURLToPath } from "url";
335
345
  var DEFAULT_SEED_LIMIT = 300;
336
346
 
@@ -566,7 +576,7 @@ function codingBankManifest(overrides) {
566
576
 
567
577
  // src/core/util.ts
568
578
  import { accessSync, constants } from "fs";
569
- import { delimiter, join as join5 } from "path";
579
+ import { delimiter, join as join6 } from "path";
570
580
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
571
581
  function semverGte(version, min) {
572
582
  const parts = (v) => {
@@ -1238,7 +1248,7 @@ var HindsightClient = class {
1238
1248
  };
1239
1249
 
1240
1250
  // src/core/config.ts
1241
- var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join6(homedir2(), ".hindsight", "coding-agent.json");
1251
+ var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join7(homedir3(), ".hindsight", "coding-agent.json");
1242
1252
  var DEFAULT_DAEMON_PORT = 9077;
1243
1253
  var DEFAULT_DAEMON_PROFILE = "coding-agent";
1244
1254
  function resolvePageTrigger(raw) {
@@ -1495,15 +1505,15 @@ function resolvePartial(cfg, patch) {
1495
1505
  }
1496
1506
 
1497
1507
  // src/core/session-cache.ts
1498
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync, rmSync, writeFileSync } from "fs";
1499
- import { tmpdir as tmpdir2 } from "os";
1500
- import { dirname as dirname5, join as join7 } from "path";
1508
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, rmSync, writeFileSync } from "fs";
1509
+ import { tmpdir } from "os";
1510
+ import { dirname as dirname5, join as join8 } from "path";
1501
1511
  function writeFileAtomic(path, body) {
1502
1512
  mkdirSync2(dirname5(path), { recursive: true });
1503
1513
  const tmp = `${path}.${process.pid}.tmp`;
1504
1514
  try {
1505
1515
  writeFileSync(tmp, body);
1506
- renameSync(tmp, path);
1516
+ renameSync2(tmp, path);
1507
1517
  } catch (e) {
1508
1518
  try {
1509
1519
  rmSync(tmp, { force: true });
@@ -1513,7 +1523,7 @@ function writeFileAtomic(path, body) {
1513
1523
  }
1514
1524
  }
1515
1525
  function sessionRootFile(harness, sessionId) {
1516
- return join7(tmpdir2(), `hindsight-${harness}`, `${sessionId}.root`);
1526
+ return join8(tmpdir(), `hindsight-${harness}`, `${sessionId}.root`);
1517
1527
  }
1518
1528
  function sessionRootDir(harness, sessionId, cwd) {
1519
1529
  if (!sessionId || !cwd) return cwd;
@@ -1529,8 +1539,27 @@ function sessionRootDir(harness, sessionId, cwd) {
1529
1539
  }
1530
1540
  return cwd;
1531
1541
  }
1542
+ function fileUsageCursorStore(harness) {
1543
+ const file = (sessionId) => join8(tmpdir(), `hindsight-${harness}`, `${sessionId}.usage.json`);
1544
+ return {
1545
+ read: (sessionId) => {
1546
+ try {
1547
+ const turns = JSON.parse(readFileSync3(file(sessionId), "utf8")).turns;
1548
+ return typeof turns === "number" ? turns : void 0;
1549
+ } catch {
1550
+ return void 0;
1551
+ }
1552
+ },
1553
+ write: (sessionId, turns) => {
1554
+ try {
1555
+ writeFileAtomic(file(sessionId), JSON.stringify({ turns }));
1556
+ } catch {
1557
+ }
1558
+ }
1559
+ };
1560
+ }
1532
1561
  function cursorFile(harness, sessionId) {
1533
- return join7(tmpdir2(), `hindsight-${harness}`, `${sessionId}.retain.json`);
1562
+ return join8(tmpdir(), `hindsight-${harness}`, `${sessionId}.retain.json`);
1534
1563
  }
1535
1564
  function fileCursorStore(harness) {
1536
1565
  return {
@@ -1551,9 +1580,9 @@ function fileCursorStore(harness) {
1551
1580
  }
1552
1581
 
1553
1582
  // src/core/turn-journal.ts
1554
- import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, statSync } from "fs";
1555
- import { tmpdir as tmpdir3 } from "os";
1556
- import { dirname as dirname6, join as join8 } from "path";
1583
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync4, statSync as statSync2 } from "fs";
1584
+ import { tmpdir as tmpdir2 } from "os";
1585
+ import { dirname as dirname6, join as join9 } from "path";
1557
1586
 
1558
1587
  // src/core/transcript-util.ts
1559
1588
  var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
@@ -1593,20 +1622,20 @@ function actionLine(tool, input) {
1593
1622
  // src/core/turn-journal.ts
1594
1623
  var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
1595
1624
  function journalPath(harness, sessionId) {
1596
- return join8(tmpdir3(), `hindsight-${harness}`, `${sessionId || "no-session"}.journal.jsonl`);
1625
+ return join9(tmpdir2(), `hindsight-${harness}`, `${sessionId || "no-session"}.journal.jsonl`);
1597
1626
  }
1598
1627
  function appendJournalTurn(path, turn) {
1599
1628
  const content = stripInjectedMemory(turn.content ?? "").trim();
1600
1629
  if (!content) return;
1601
1630
  try {
1602
- if (statSync(path).size >= JOURNAL_MAX_BYTES) return;
1631
+ if (statSync2(path).size >= JOURNAL_MAX_BYTES) return;
1603
1632
  } catch {
1604
1633
  }
1605
1634
  const last = readJournalTranscript(path).at(-1);
1606
1635
  if (last && last.role === turn.role && last.content === content) return;
1607
1636
  try {
1608
1637
  mkdirSync3(dirname6(path), { recursive: true });
1609
- appendFileSync3(
1638
+ appendFileSync2(
1610
1639
  path,
1611
1640
  JSON.stringify({
1612
1641
  role: turn.role,
@@ -1647,7 +1676,7 @@ function readJournalTranscript(path) {
1647
1676
  }
1648
1677
 
1649
1678
  // src/core/retain-hook.ts
1650
- import { readFileSync as readFileSync6 } from "fs";
1679
+ import { readFileSync as readFileSync7 } from "fs";
1651
1680
 
1652
1681
  // src/core/retain-cursor.ts
1653
1682
  import { createHash as createHash2 } from "crypto";
@@ -1840,7 +1869,7 @@ ${content}`);
1840
1869
 
1841
1870
  // src/core/daemon.ts
1842
1871
  import { execFileSync, spawn as realSpawn2 } from "child_process";
1843
- import { dirname as dirname7, join as join9 } from "path";
1872
+ import { dirname as dirname7, join as join10 } from "path";
1844
1873
  import { fileURLToPath as fileURLToPath2 } from "url";
1845
1874
  var DAEMON_WAIT_RETAIN_MS = 4e4;
1846
1875
  async function isServerHealthy(baseUrl, timeoutMs = 2e3) {
@@ -1914,7 +1943,7 @@ function onPath(bin) {
1914
1943
  }
1915
1944
  function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
1916
1945
  try {
1917
- const starter = join9(dirname7(fileURLToPath2(import.meta.url)), "daemon-start.js");
1946
+ const starter = join10(dirname7(fileURLToPath2(import.meta.url)), "daemon-start.js");
1918
1947
  const child = spawnFn("node", [starter, "--harness", harness], {
1919
1948
  detached: true,
1920
1949
  stdio: "ignore",
@@ -2015,7 +2044,7 @@ function buildRetainStamp(cfg, ctx) {
2015
2044
  }
2016
2045
 
2017
2046
  // src/core/jsonl.ts
2018
- import { closeSync, openSync, readSync, statSync as statSync2 } from "fs";
2047
+ import { closeSync, openSync, readSync, statSync as statSync3 } from "fs";
2019
2048
  import { StringDecoder } from "string_decoder";
2020
2049
  var CHUNK_BYTES = 64 * 1024;
2021
2050
  var MAX_TRANSCRIPT_BYTES = 32 * 1024 * 1024;
@@ -2023,7 +2052,7 @@ function readJsonlTail(path, opts) {
2023
2052
  const maxBytes = opts.maxBytes ?? MAX_TRANSCRIPT_BYTES;
2024
2053
  let size;
2025
2054
  try {
2026
- size = statSync2(path).size;
2055
+ size = statSync3(path).size;
2027
2056
  } catch {
2028
2057
  return { lines: emptyLines(), skippedBytes: 0 };
2029
2058
  }
@@ -2126,6 +2155,57 @@ function readClaudeTranscript(path) {
2126
2155
  return turns;
2127
2156
  }
2128
2157
 
2158
+ // src/core/usage.ts
2159
+ import { readFileSync as readFileSync6 } from "fs";
2160
+ import { join as join11 } from "path";
2161
+ function usageFilePath() {
2162
+ return process.env.HINDSIGHT_USAGE_FILE || join11(logsDir(), "usage.jsonl");
2163
+ }
2164
+ var HINDSIGHT_TOOL_RE = /hindsight_(?:[a-z]+_)*[a-z]+$/;
2165
+ var CREDIT_RE = /from hindsight memory/i;
2166
+ var ASSISTANT_ROLES = /* @__PURE__ */ new Set(["assistant", "model"]);
2167
+ function summarizeTurns(turns) {
2168
+ const out = [];
2169
+ for (const t of turns) {
2170
+ if (t.role === "user") {
2171
+ out.push({ turn: out.length + 1, calls: [], credited: false });
2172
+ continue;
2173
+ }
2174
+ const current2 = out.at(-1);
2175
+ if (!current2) continue;
2176
+ if (t.role === "action") {
2177
+ const tool = t.content.split(" ", 1)[0].match(HINDSIGHT_TOOL_RE)?.[0];
2178
+ if (tool) current2.calls.push(tool);
2179
+ } else if (ASSISTANT_ROLES.has(t.role) && CREDIT_RE.test(t.content)) {
2180
+ current2.credited = true;
2181
+ }
2182
+ }
2183
+ return out;
2184
+ }
2185
+ function recordUsage(args) {
2186
+ const summary = summarizeTurns(args.turns);
2187
+ const finished = args.lastTurnComplete ? summary : summary.slice(0, -1);
2188
+ const from = args.cursors.read(args.sessionId) ?? 0;
2189
+ if (finished.length <= from) return;
2190
+ const ts = (/* @__PURE__ */ new Date()).toISOString();
2191
+ const lines = finished.slice(from).map(
2192
+ (u) => JSON.stringify({
2193
+ ts,
2194
+ harness: args.harness,
2195
+ session: args.sessionId,
2196
+ bank: args.bankId,
2197
+ turn: u.turn,
2198
+ calls: u.calls,
2199
+ credited: u.credited
2200
+ }) + "\n"
2201
+ ).join("");
2202
+ try {
2203
+ appendLogLine(usageFilePath(), lines);
2204
+ args.cursors.write(args.sessionId, finished.length);
2205
+ } catch {
2206
+ }
2207
+ }
2208
+
2129
2209
  // src/core/retain-hook.ts
2130
2210
  var HOST_DEADLINE_MARGIN_MS = 2e3;
2131
2211
  async function buildRetain(args) {
@@ -2142,6 +2222,14 @@ async function buildRetain(args) {
2142
2222
  });
2143
2223
  }
2144
2224
  if (turns.length === 0) return;
2225
+ recordUsage({
2226
+ harness,
2227
+ sessionId,
2228
+ bankId: args.bankId ?? "",
2229
+ turns,
2230
+ cursors: args.usageCursors ?? fileUsageCursorStore(harness),
2231
+ lastTurnComplete: true
2232
+ });
2145
2233
  const startTs = turns[0]?.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
2146
2234
  const t0 = Date.now();
2147
2235
  try {
@@ -2167,7 +2255,7 @@ async function runRetainHook(spec, makeClient = (o) => new HindsightClient(o)) {
2167
2255
  const hostDeadline = Date.now() + spec.hostTimeoutSec * 1e3 - HOST_DEADLINE_MARGIN_MS;
2168
2256
  let ev = {};
2169
2257
  try {
2170
- ev = JSON.parse(readFileSync6(0, "utf8"));
2258
+ ev = JSON.parse(readFileSync7(0, "utf8"));
2171
2259
  } catch {
2172
2260
  return;
2173
2261
  }
@@ -2217,6 +2305,7 @@ async function runRetainHook(spec, makeClient = (o) => new HindsightClient(o)) {
2217
2305
  lastAssistantMessage,
2218
2306
  readLastMessage: spec.readLastMessage,
2219
2307
  retryUntil: hostDeadline,
2308
+ bankId,
2220
2309
  stamp: buildRetainStamp(cfg, {
2221
2310
  directory: cwd,
2222
2311
  sessionRoot,
@@ -2228,7 +2317,7 @@ async function runRetainHook(spec, makeClient = (o) => new HindsightClient(o)) {
2228
2317
  }
2229
2318
 
2230
2319
  // src/core/session-start.ts
2231
- import { readFileSync as readFileSync10 } from "fs";
2320
+ import { readFileSync as readFileSync11 } from "fs";
2232
2321
 
2233
2322
  // src/core/git.ts
2234
2323
  import { execFileSync as execFileSync2 } from "child_process";
@@ -2241,8 +2330,8 @@ import { execFileSync as execFileSync3 } from "child_process";
2241
2330
  import { spawn as realSpawn4 } from "child_process";
2242
2331
  import { createHash as createHash4 } from "crypto";
2243
2332
  import { existsSync as existsSync3 } from "fs";
2244
- import { homedir as homedir3, tmpdir as tmpdir4 } from "os";
2245
- import { dirname as dirname8, join as join11 } from "path";
2333
+ import { homedir as homedir4, tmpdir as tmpdir3 } from "os";
2334
+ import { dirname as dirname8, join as join13 } from "path";
2246
2335
  import { fileURLToPath as fileURLToPath3 } from "url";
2247
2336
 
2248
2337
  // src/core/survey-lease.ts
@@ -2252,42 +2341,42 @@ import {
2252
2341
  mkdirSync as mkdirSync4,
2253
2342
  mkdtempSync,
2254
2343
  readdirSync,
2255
- renameSync as renameSync2,
2344
+ renameSync as renameSync3,
2256
2345
  rmdirSync,
2257
2346
  rmSync as rmSync2,
2258
- statSync as statSync3,
2347
+ statSync as statSync4,
2259
2348
  unlinkSync,
2260
2349
  utimesSync,
2261
2350
  writeFileSync as writeFileSync2
2262
2351
  } from "fs";
2263
- import { join as join10 } from "path";
2352
+ import { join as join12 } from "path";
2264
2353
 
2265
2354
  // src/core/auto-update.ts
2266
2355
  import { spawn as realSpawn5 } from "child_process";
2267
2356
  import {
2268
2357
  existsSync as existsSync4,
2269
2358
  mkdirSync as mkdirSync5,
2270
- readFileSync as readFileSync7,
2359
+ readFileSync as readFileSync8,
2271
2360
  realpathSync as realpathSync2,
2272
2361
  unlinkSync as unlinkSync2,
2273
2362
  writeFileSync as writeFileSync3
2274
2363
  } from "fs";
2275
- import { homedir as homedir4, tmpdir as tmpdir5 } from "os";
2276
- import { dirname as dirname9, join as join12 } from "path";
2364
+ import { homedir as homedir5, tmpdir as tmpdir4 } from "os";
2365
+ import { dirname as dirname9, join as join14 } from "path";
2277
2366
  import { fileURLToPath as fileURLToPath4 } from "url";
2278
2367
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
2279
2368
  var LOCK_STALE_MS = 10 * 60 * 1e3;
2280
2369
 
2281
2370
  // src/core/skill-sync.ts
2282
- import { cpSync, existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
2283
- import { homedir as homedir5 } from "os";
2284
- import { dirname as dirname10, join as join13 } from "path";
2371
+ import { cpSync, existsSync as existsSync5, readFileSync as readFileSync9 } from "fs";
2372
+ import { homedir as homedir6 } from "os";
2373
+ import { dirname as dirname10, join as join15 } from "path";
2285
2374
  import { fileURLToPath as fileURLToPath5 } from "url";
2286
2375
 
2287
2376
  // src/core/legacy.ts
2288
- import { existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
2289
- import { homedir as homedir6 } from "os";
2290
- import { join as join14, relative, isAbsolute as isAbsolute2 } from "path";
2377
+ import { existsSync as existsSync6, readFileSync as readFileSync10 } from "fs";
2378
+ import { homedir as homedir7 } from "os";
2379
+ import { join as join16, relative, isAbsolute as isAbsolute2 } from "path";
2291
2380
 
2292
2381
  // src/core/transcript-codex.ts
2293
2382
  function isSyntheticUserText(text) {
@@ -2419,19 +2508,19 @@ function readCopilotTranscript(path) {
2419
2508
  }
2420
2509
 
2421
2510
  // src/core/transcript-grok.ts
2422
- import { existsSync as existsSync7, readFileSync as readFileSync11, readdirSync as readdirSync2 } from "fs";
2423
- import { homedir as homedir7 } from "os";
2424
- import { join as join15 } from "path";
2511
+ import { existsSync as existsSync7, readFileSync as readFileSync12, readdirSync as readdirSync2 } from "fs";
2512
+ import { homedir as homedir8 } from "os";
2513
+ import { join as join17 } from "path";
2425
2514
  var CHAT_HISTORY = "chat_history.jsonl";
2426
- function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join15(homedir7(), ".grok")) {
2427
- const sessionsDir = join15(grokHome, "sessions");
2428
- const direct = join15(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2515
+ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join17(homedir8(), ".grok")) {
2516
+ const sessionsDir = join17(grokHome, "sessions");
2517
+ const direct = join17(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2429
2518
  if (existsSync7(direct)) return direct;
2430
2519
  try {
2431
2520
  for (const candidate of readdirSync2(sessionsDir)) {
2432
- const directory = join15(sessionsDir, candidate);
2433
- if (readFileSync11(join15(directory, ".cwd"), "utf8").trim() === cwd) {
2434
- return join15(directory, sessionId, CHAT_HISTORY);
2521
+ const directory = join17(sessionsDir, candidate);
2522
+ if (readFileSync12(join17(directory, ".cwd"), "utf8").trim() === cwd) {
2523
+ return join17(directory, sessionId, CHAT_HISTORY);
2435
2524
  }
2436
2525
  }
2437
2526
  } catch {
@@ -2468,10 +2557,10 @@ function readGrokTranscript(path) {
2468
2557
  // src/core/transcript-devin.ts
2469
2558
  import { existsSync as existsSync8 } from "fs";
2470
2559
  import { createRequire } from "module";
2471
- import { homedir as homedir8 } from "os";
2472
- import { join as join16 } from "path";
2473
- function devinSessionDb(home = homedir8()) {
2474
- return join16(home, ".local", "share", "devin", "cli", "sessions.db");
2560
+ import { homedir as homedir9 } from "os";
2561
+ import { join as join18 } from "path";
2562
+ function devinSessionDb(home = homedir9()) {
2563
+ return join18(home, ".local", "share", "devin", "cli", "sessions.db");
2475
2564
  }
2476
2565
  function parseDevinMessages(nodes) {
2477
2566
  const messages = /* @__PURE__ */ new Map();
@@ -2781,7 +2870,7 @@ function readDroidTranscript(path) {
2781
2870
  }
2782
2871
 
2783
2872
  // src/core/transcript-zcode.ts
2784
- import { readFileSync as readFileSync12 } from "fs";
2873
+ import { readFileSync as readFileSync13 } from "fs";
2785
2874
  function messageText2(content) {
2786
2875
  if (typeof content === "string") return content.trim();
2787
2876
  if (!Array.isArray(content)) return "";
@@ -2791,7 +2880,7 @@ function readZcodeTranscript(path) {
2791
2880
  if (!path) return [];
2792
2881
  let body;
2793
2882
  try {
2794
- body = readFileSync12(path, "utf8");
2883
+ body = readFileSync13(path, "utf8");
2795
2884
  } catch {
2796
2885
  return [];
2797
2886
  }