@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 {
@@ -46,12 +56,12 @@ var log = {
46
56
 
47
57
  // src/core/diag.ts
48
58
  function diagFilePath() {
49
- return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
59
+ return process.env.HINDSIGHT_DIAG_FILE || join2(logsDir(), "diag.jsonl");
50
60
  }
51
61
  function diag(harness, event, extra = {}) {
52
62
  log.debug(harness, `diag:${event}`, extra);
53
63
  try {
54
- appendFileSync2(
64
+ appendLogLine(
55
65
  diagFilePath(),
56
66
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
57
67
  );
@@ -61,7 +71,7 @@ function diag(harness, event, extra = {}) {
61
71
 
62
72
  // src/core/git-layout.ts
63
73
  import { lstatSync, readFileSync, realpathSync } from "fs";
64
- import { dirname as dirname2, isAbsolute, join as join2, resolve } from "path";
74
+ import { dirname as dirname2, isAbsolute, join as join3, resolve } from "path";
65
75
  var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
66
76
  var ATTEMPTS = 3;
67
77
  var BACKOFF_MS = 20;
@@ -97,16 +107,16 @@ function gitDirFromPointer(text, holder) {
97
107
  return isAbsolute(target) ? target : resolve(holder, target);
98
108
  }
99
109
  function commonDirOf(gitDir) {
100
- const pointer = entryKind(join2(gitDir, "commondir")) === "file" ? readTextOrNull(join2(gitDir, "commondir"))?.trim() : null;
110
+ const pointer = entryKind(join3(gitDir, "commondir")) === "file" ? readTextOrNull(join3(gitDir, "commondir"))?.trim() : null;
101
111
  if (!pointer) return gitDir;
102
112
  return isAbsolute(pointer) ? pointer : resolve(gitDir, pointer);
103
113
  }
104
114
  function isBare(commonDir) {
105
- const config = readTextOrNull(join2(commonDir, "config"));
115
+ const config = readTextOrNull(join3(commonDir, "config"));
106
116
  return config !== null && /^\s*bare\s*=\s*true\s*$/im.test(config);
107
117
  }
108
118
  function looksLikeBareRepository(directory) {
109
- return entryKind(join2(directory, "HEAD")) === "file" && entryKind(join2(directory, "objects")) === "dir" && entryKind(join2(directory, "refs")) === "dir";
119
+ return entryKind(join3(directory, "HEAD")) === "file" && entryKind(join3(directory, "objects")) === "dir" && entryKind(join3(directory, "refs")) === "dir";
110
120
  }
111
121
  function canonical(path) {
112
122
  try {
@@ -123,7 +133,7 @@ function resolved(commonDir) {
123
133
  function probeOnce(directory) {
124
134
  let current2 = resolve(directory);
125
135
  for (; ; ) {
126
- const dotGit = join2(current2, ".git");
136
+ const dotGit = join3(current2, ".git");
127
137
  const kind = entryKind(dotGit);
128
138
  if (kind === "dir") {
129
139
  const layout = resolved(commonDirOf(dotGit));
@@ -237,7 +247,7 @@ function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
237
247
  return dirName(sessionRoot || directory);
238
248
  }
239
249
  function configuredDir(dir) {
240
- const expanded = dir === "~" || dir.startsWith("~/") ? join3(homedir(), dir.slice(1)) : dir;
250
+ const expanded = dir === "~" || dir.startsWith("~/") ? join4(homedir2(), dir.slice(1)) : dir;
241
251
  return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
242
252
  }
243
253
  function isWithin(directory, configured) {
@@ -311,18 +321,18 @@ function deriveBankIdOrSkip(config, directory, harness = "coding", sessionRoot)
311
321
 
312
322
  // src/core/config.ts
313
323
  import { readFileSync as readFileSync2 } from "fs";
314
- import { homedir as homedir2 } from "os";
315
- import { join as join6 } from "path";
324
+ import { homedir as homedir3 } from "os";
325
+ import { join as join7 } from "path";
316
326
 
317
327
  // src/core/seed.ts
318
328
  import { spawn as realSpawn } from "child_process";
319
- import { dirname as dirname4, join as join4 } from "path";
329
+ import { dirname as dirname4, join as join5 } from "path";
320
330
  import { fileURLToPath } from "url";
321
331
  var DEFAULT_SEED_LIMIT = 300;
322
332
  function startBackgroundSeed(repoDir, opts = {}) {
323
333
  try {
324
334
  const spawnFn = opts.spawn ?? realSpawn;
325
- const enginePath = opts.enginePath ?? join4(dirname4(fileURLToPath(import.meta.url)), "deepen.js");
335
+ const enginePath = opts.enginePath ?? join5(dirname4(fileURLToPath(import.meta.url)), "deepen.js");
326
336
  const limit = opts.limit ?? DEFAULT_SEED_LIMIT;
327
337
  const child = spawnFn(
328
338
  "node",
@@ -579,7 +589,7 @@ function codingBankManifest(overrides) {
579
589
 
580
590
  // src/core/util.ts
581
591
  import { accessSync, constants } from "fs";
582
- import { delimiter, join as join5 } from "path";
592
+ import { delimiter, join as join6 } from "path";
583
593
  function binOnPath(bin) {
584
594
  try {
585
595
  if (bin.includes("/")) {
@@ -589,7 +599,7 @@ function binOnPath(bin) {
589
599
  for (const dir of (process.env.PATH || "").split(delimiter)) {
590
600
  if (!dir) continue;
591
601
  try {
592
- accessSync(join5(dir, bin), constants.X_OK);
602
+ accessSync(join6(dir, bin), constants.X_OK);
593
603
  return true;
594
604
  } catch {
595
605
  }
@@ -1270,7 +1280,7 @@ var HindsightClient = class {
1270
1280
  };
1271
1281
 
1272
1282
  // src/core/config.ts
1273
- var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join6(homedir2(), ".hindsight", "coding-agent.json");
1283
+ var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join7(homedir3(), ".hindsight", "coding-agent.json");
1274
1284
  var DEFAULT_DAEMON_PORT = 9077;
1275
1285
  var DEFAULT_DAEMON_PROFILE = "coding-agent";
1276
1286
  function resolvePageTrigger(raw) {
@@ -1577,18 +1587,18 @@ This tool guide and the page list are re-injected for you periodically as things
1577
1587
  }
1578
1588
 
1579
1589
  // src/core/session-cache.ts
1580
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync, rmSync, writeFileSync } from "fs";
1581
- import { tmpdir as tmpdir2 } from "os";
1582
- import { dirname as dirname5, join as join7 } from "path";
1590
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, rmSync, writeFileSync } from "fs";
1591
+ import { tmpdir } from "os";
1592
+ import { dirname as dirname5, join as join8 } from "path";
1583
1593
  function sessionCacheFile(harness, sessionId) {
1584
- return join7(tmpdir2(), `hindsight-${harness}`, `${sessionId}.json`);
1594
+ return join8(tmpdir(), `hindsight-${harness}`, `${sessionId}.json`);
1585
1595
  }
1586
1596
  function writeFileAtomic(path, body) {
1587
1597
  mkdirSync2(dirname5(path), { recursive: true });
1588
1598
  const tmp = `${path}.${process.pid}.tmp`;
1589
1599
  try {
1590
1600
  writeFileSync(tmp, body);
1591
- renameSync(tmp, path);
1601
+ renameSync2(tmp, path);
1592
1602
  } catch (e) {
1593
1603
  try {
1594
1604
  rmSync(tmp, { force: true });
@@ -1604,7 +1614,7 @@ function writeSessionCache(cacheFile, cache) {
1604
1614
  }
1605
1615
  }
1606
1616
  function sessionRootFile(harness, sessionId) {
1607
- return join7(tmpdir2(), `hindsight-${harness}`, `${sessionId}.root`);
1617
+ return join8(tmpdir(), `hindsight-${harness}`, `${sessionId}.root`);
1608
1618
  }
1609
1619
  function sessionRootDir(harness, sessionId, cwd) {
1610
1620
  if (!sessionId || !cwd) return cwd;
@@ -1622,9 +1632,9 @@ function sessionRootDir(harness, sessionId, cwd) {
1622
1632
  }
1623
1633
 
1624
1634
  // src/core/turn-journal.ts
1625
- import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, statSync } from "fs";
1626
- import { tmpdir as tmpdir3 } from "os";
1627
- import { dirname as dirname6, join as join8 } from "path";
1635
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync4, statSync as statSync2 } from "fs";
1636
+ import { tmpdir as tmpdir2 } from "os";
1637
+ import { dirname as dirname6, join as join9 } from "path";
1628
1638
 
1629
1639
  // src/core/transcript-util.ts
1630
1640
  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;
@@ -1665,7 +1675,7 @@ function actionLine(tool, input) {
1665
1675
  var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
1666
1676
 
1667
1677
  // src/core/retain-hook.ts
1668
- import { readFileSync as readFileSync6 } from "fs";
1678
+ import { readFileSync as readFileSync7 } from "fs";
1669
1679
 
1670
1680
  // src/core/retain-cursor.ts
1671
1681
  import { createHash as createHash2 } from "crypto";
@@ -1677,7 +1687,7 @@ import { createHash as createHash3 } from "crypto";
1677
1687
 
1678
1688
  // src/core/daemon.ts
1679
1689
  import { execFileSync, spawn as realSpawn2 } from "child_process";
1680
- import { dirname as dirname7, join as join9 } from "path";
1690
+ import { dirname as dirname7, join as join10 } from "path";
1681
1691
  import { fileURLToPath as fileURLToPath2 } from "url";
1682
1692
  var DAEMON_WAIT_SESSION_START_MS = 12e3;
1683
1693
  async function isServerHealthy(baseUrl, timeoutMs = 2e3) {
@@ -1751,7 +1761,7 @@ function onPath(bin) {
1751
1761
  }
1752
1762
  function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
1753
1763
  try {
1754
- const starter = join9(dirname7(fileURLToPath2(import.meta.url)), "daemon-start.js");
1764
+ const starter = join10(dirname7(fileURLToPath2(import.meta.url)), "daemon-start.js");
1755
1765
  const child = spawnFn("node", [starter, "--harness", harness], {
1756
1766
  detached: true,
1757
1767
  stdio: "ignore",
@@ -1852,7 +1862,7 @@ function buildRetainStamp(cfg, ctx) {
1852
1862
  }
1853
1863
 
1854
1864
  // src/core/jsonl.ts
1855
- import { closeSync, openSync, readSync, statSync as statSync2 } from "fs";
1865
+ import { closeSync, openSync, readSync, statSync as statSync3 } from "fs";
1856
1866
  import { StringDecoder } from "string_decoder";
1857
1867
  var CHUNK_BYTES = 64 * 1024;
1858
1868
  var MAX_TRANSCRIPT_BYTES = 32 * 1024 * 1024;
@@ -1860,7 +1870,7 @@ function readJsonlTail(path, opts) {
1860
1870
  const maxBytes = opts.maxBytes ?? MAX_TRANSCRIPT_BYTES;
1861
1871
  let size;
1862
1872
  try {
1863
- size = statSync2(path).size;
1873
+ size = statSync3(path).size;
1864
1874
  } catch {
1865
1875
  return { lines: emptyLines(), skippedBytes: 0 };
1866
1876
  }
@@ -1912,8 +1922,12 @@ function* streamLines(path, start) {
1912
1922
  }
1913
1923
  }
1914
1924
 
1925
+ // src/core/usage.ts
1926
+ import { readFileSync as readFileSync6 } from "fs";
1927
+ import { join as join11 } from "path";
1928
+
1915
1929
  // src/core/session-start.ts
1916
- import { readFileSync as readFileSync10 } from "fs";
1930
+ import { readFileSync as readFileSync11 } from "fs";
1917
1931
 
1918
1932
  // src/core/git.ts
1919
1933
  import { execFileSync as execFileSync2 } from "child_process";
@@ -1958,8 +1972,8 @@ import { execFileSync as execFileSync3 } from "child_process";
1958
1972
  import { spawn as realSpawn4 } from "child_process";
1959
1973
  import { createHash as createHash4 } from "crypto";
1960
1974
  import { existsSync as existsSync3 } from "fs";
1961
- import { homedir as homedir3, tmpdir as tmpdir4 } from "os";
1962
- import { dirname as dirname8, join as join11 } from "path";
1975
+ import { homedir as homedir4, tmpdir as tmpdir3 } from "os";
1976
+ import { dirname as dirname8, join as join13 } from "path";
1963
1977
  import { fileURLToPath as fileURLToPath3 } from "url";
1964
1978
 
1965
1979
  // src/core/host-client.ts
@@ -1978,20 +1992,20 @@ import {
1978
1992
  mkdirSync as mkdirSync4,
1979
1993
  mkdtempSync,
1980
1994
  readdirSync,
1981
- renameSync as renameSync2,
1995
+ renameSync as renameSync3,
1982
1996
  rmdirSync,
1983
1997
  rmSync as rmSync2,
1984
- statSync as statSync3,
1998
+ statSync as statSync4,
1985
1999
  unlinkSync,
1986
2000
  utimesSync,
1987
2001
  writeFileSync as writeFileSync2
1988
2002
  } from "fs";
1989
- import { join as join10 } from "path";
2003
+ import { join as join12 } from "path";
1990
2004
  var LEASE_STALE_MS = 3e4;
1991
2005
  var SURVEY_SPEC_ENV = "HINDSIGHT_SURVEY_SPEC";
1992
2006
  function tryRename(from, to) {
1993
2007
  try {
1994
- renameSync2(from, to);
2008
+ renameSync3(from, to);
1995
2009
  return true;
1996
2010
  } catch {
1997
2011
  return false;
@@ -1999,7 +2013,7 @@ function tryRename(from, to) {
1999
2013
  }
2000
2014
  function releaseLease(lease) {
2001
2015
  try {
2002
- unlinkSync(join10(lease.directory, lease.owner));
2016
+ unlinkSync(join12(lease.directory, lease.owner));
2003
2017
  } catch {
2004
2018
  return;
2005
2019
  }
@@ -2018,7 +2032,7 @@ function reclaimIfStale(directory, staleMs) {
2018
2032
  return true;
2019
2033
  }
2020
2034
  if (owners.length !== 1) return false;
2021
- const age = Date.now() - statSync3(join10(directory, owners[0])).mtimeMs;
2035
+ const age = Date.now() - statSync4(join12(directory, owners[0])).mtimeMs;
2022
2036
  if (Math.abs(age) <= staleMs) return false;
2023
2037
  releaseLease({ directory, owner: owners[0] });
2024
2038
  return true;
@@ -2027,10 +2041,10 @@ function acquireLease(root, key, staleMs = LEASE_STALE_MS) {
2027
2041
  let staging;
2028
2042
  try {
2029
2043
  mkdirSync4(root, { recursive: true, mode: 448 });
2030
- staging = mkdtempSync(join10(root, "claim-"));
2044
+ staging = mkdtempSync(join12(root, "claim-"));
2031
2045
  const owner = randomUUID();
2032
- writeFileSync2(join10(staging, owner), "", { flag: "wx", mode: 384 });
2033
- const directory = join10(root, `survey-${key}.lock`);
2046
+ writeFileSync2(join12(staging, owner), "", { flag: "wx", mode: 384 });
2047
+ const directory = join12(root, `survey-${key}.lock`);
2034
2048
  if (!tryRename(staging, directory)) {
2035
2049
  if (!reclaimIfStale(directory, staleMs)) return void 0;
2036
2050
  if (!tryRename(staging, directory)) return void 0;
@@ -2053,7 +2067,7 @@ var SURVEY_DOC_IDS = [
2053
2067
  function resolveClaudeBin(explicit) {
2054
2068
  if (explicit) return explicit;
2055
2069
  if (process.env.HINDSIGHT_CLAUDE_BIN) return process.env.HINDSIGHT_CLAUDE_BIN;
2056
- const nativeInstallPath = join11(homedir3(), ".claude", "local", "claude");
2070
+ const nativeInstallPath = join13(homedir4(), ".claude", "local", "claude");
2057
2071
  try {
2058
2072
  if (existsSync3(nativeInstallPath)) return nativeInstallPath;
2059
2073
  } catch {
@@ -2171,7 +2185,7 @@ async function startCodebaseSurvey(repoDir, opts = {}) {
2171
2185
  try {
2172
2186
  const spawnFn = opts.spawn ?? realSpawn4;
2173
2187
  const exists = opts.exists ?? binOnPath;
2174
- const mcpServerPath = opts.mcpServerPath ?? join11(dirname8(fileURLToPath3(import.meta.url)), "mcp-server.js");
2188
+ const mcpServerPath = opts.mcpServerPath ?? join13(dirname8(fileURLToPath3(import.meta.url)), "mcp-server.js");
2175
2189
  const preferred = opts.harness ?? "claude-code";
2176
2190
  const order = [
2177
2191
  preferred,
@@ -2195,7 +2209,7 @@ async function startCodebaseSurvey(repoDir, opts = {}) {
2195
2209
  if (cfg.disabled) return false;
2196
2210
  const key = createHash4("sha256").update(JSON.stringify([cfg.apiUrl.replace(/\/+$/, ""), cfg.apiToken ?? "", bankId])).digest("hex");
2197
2211
  const lease = acquireLease(
2198
- opts.lease?.dir ?? join11(tmpdir4(), "hindsight-coding-agent", "surveys"),
2212
+ opts.lease?.dir ?? join13(tmpdir3(), "hindsight-coding-agent", "surveys"),
2199
2213
  key,
2200
2214
  opts.lease?.staleMs ?? LEASE_STALE_MS
2201
2215
  );
@@ -2206,7 +2220,7 @@ async function startCodebaseSurvey(repoDir, opts = {}) {
2206
2220
  args: plan.args,
2207
2221
  ...opts.lease?.heartbeatMs ? { heartbeatMs: opts.lease.heartbeatMs } : {}
2208
2222
  };
2209
- const supervisorPath = opts.supervisorPath ?? join11(dirname8(fileURLToPath3(import.meta.url)), "survey-supervisor.js");
2223
+ const supervisorPath = opts.supervisorPath ?? join13(dirname8(fileURLToPath3(import.meta.url)), "survey-supervisor.js");
2210
2224
  return await new Promise((resolve3) => {
2211
2225
  try {
2212
2226
  const child = spawnFn("node", [supervisorPath], {
@@ -2246,25 +2260,25 @@ import { spawn as realSpawn5 } from "child_process";
2246
2260
  import {
2247
2261
  existsSync as existsSync4,
2248
2262
  mkdirSync as mkdirSync5,
2249
- readFileSync as readFileSync7,
2263
+ readFileSync as readFileSync8,
2250
2264
  realpathSync as realpathSync2,
2251
2265
  unlinkSync as unlinkSync2,
2252
2266
  writeFileSync as writeFileSync3
2253
2267
  } from "fs";
2254
- import { homedir as homedir4, tmpdir as tmpdir5 } from "os";
2255
- import { dirname as dirname9, join as join12 } from "path";
2268
+ import { homedir as homedir5, tmpdir as tmpdir4 } from "os";
2269
+ import { dirname as dirname9, join as join14 } from "path";
2256
2270
  import { fileURLToPath as fileURLToPath4 } from "url";
2257
2271
  var PACKAGE_NAME = "@vectorize-io/hindsight-coding-agents";
2258
2272
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
2259
2273
  var FETCH_TIMEOUT_MS = 5e3;
2260
2274
  function stateFile(runtimeDir) {
2261
- return join12(runtimeDir, ".update-check.json");
2275
+ return join14(runtimeDir, ".update-check.json");
2262
2276
  }
2263
2277
  function packageRoot() {
2264
- return join12(dirname9(fileURLToPath4(import.meta.url)), "..");
2278
+ return join14(dirname9(fileURLToPath4(import.meta.url)), "..");
2265
2279
  }
2266
2280
  function stagedRuntimeDir() {
2267
- return join12(homedir4(), ".hindsight", "coding-agents");
2281
+ return join14(homedir5(), ".hindsight", "coding-agents");
2268
2282
  }
2269
2283
  function sameDir(a, b) {
2270
2284
  try {
@@ -2275,7 +2289,7 @@ function sameDir(a, b) {
2275
2289
  }
2276
2290
  function stagedVersion(pkgRoot) {
2277
2291
  try {
2278
- const pkg = JSON.parse(readFileSync7(join12(pkgRoot, "package.json"), "utf8"));
2292
+ const pkg = JSON.parse(readFileSync8(join14(pkgRoot, "package.json"), "utf8"));
2279
2293
  return typeof pkg.version === "string" ? pkg.version : "";
2280
2294
  } catch {
2281
2295
  return "";
@@ -2300,7 +2314,7 @@ function isNewer(candidate, current2) {
2300
2314
  }
2301
2315
  function dueForCheck(file, now) {
2302
2316
  try {
2303
- const state = JSON.parse(readFileSync7(file, "utf8"));
2317
+ const state = JSON.parse(readFileSync8(file, "utf8"));
2304
2318
  return typeof state.lastCheck !== "number" || now - state.lastCheck >= CHECK_INTERVAL_MS;
2305
2319
  } catch {
2306
2320
  return true;
@@ -2309,7 +2323,7 @@ function dueForCheck(file, now) {
2309
2323
  var ORIGIN_FILE = ".install-origin.json";
2310
2324
  function selfUpdatable(runtimeDir) {
2311
2325
  try {
2312
- const origin = JSON.parse(readFileSync7(join12(runtimeDir, ORIGIN_FILE), "utf8"));
2326
+ const origin = JSON.parse(readFileSync8(join14(runtimeDir, ORIGIN_FILE), "utf8"));
2313
2327
  if (typeof origin.source !== "string" || !origin.source) return false;
2314
2328
  return origin.source.split(/[\\/]/).includes("_npx");
2315
2329
  } catch {
@@ -2318,11 +2332,11 @@ function selfUpdatable(runtimeDir) {
2318
2332
  }
2319
2333
  var LOCK_STALE_MS = 10 * 60 * 1e3;
2320
2334
  function lockFile() {
2321
- return join12(tmpdir5(), "hindsight-coding-agent", "auto-update.lock");
2335
+ return join14(tmpdir4(), "hindsight-coding-agent", "auto-update.lock");
2322
2336
  }
2323
2337
  function acquireUpdateLock(file, now) {
2324
2338
  try {
2325
- const held = JSON.parse(readFileSync7(file, "utf8"));
2339
+ const held = JSON.parse(readFileSync8(file, "utf8"));
2326
2340
  if (held.ts && now - held.ts < LOCK_STALE_MS) {
2327
2341
  let holderAlive = false;
2328
2342
  if (held.pid) {
@@ -2434,9 +2448,9 @@ async function maybeAutoUpdate(cfg, opts = {}) {
2434
2448
  }
2435
2449
 
2436
2450
  // src/core/skill-sync.ts
2437
- import { cpSync, existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
2438
- import { homedir as homedir5 } from "os";
2439
- import { dirname as dirname10, join as join13 } from "path";
2451
+ import { cpSync, existsSync as existsSync5, readFileSync as readFileSync9 } from "fs";
2452
+ import { homedir as homedir6 } from "os";
2453
+ import { dirname as dirname10, join as join15 } from "path";
2440
2454
  import { fileURLToPath as fileURLToPath5 } from "url";
2441
2455
 
2442
2456
  // src/core/skill-dirs.ts
@@ -2468,19 +2482,19 @@ var SKILL_DIRS = {
2468
2482
 
2469
2483
  // src/core/skill-sync.ts
2470
2484
  function packagedSkillDir() {
2471
- return join13(dirname10(fileURLToPath5(import.meta.url)), "..", "skill");
2485
+ return join15(dirname10(fileURLToPath5(import.meta.url)), "..", "skill");
2472
2486
  }
2473
2487
  function syncCompanionSkill(harness, opts = {}) {
2474
2488
  try {
2475
2489
  const parts = SKILL_DIRS[harness];
2476
2490
  if (!parts) return;
2477
2491
  const src = opts.srcDir ?? packagedSkillDir();
2478
- const srcMd = join13(src, "SKILL.md");
2492
+ const srcMd = join15(src, "SKILL.md");
2479
2493
  if (!existsSync5(srcMd)) return;
2480
- const dst = join13(opts.home ?? homedir5(), ...parts, "hindsight-coding-agent");
2481
- const dstMd = join13(dst, "SKILL.md");
2494
+ const dst = join15(opts.home ?? homedir6(), ...parts, "hindsight-coding-agent");
2495
+ const dstMd = join15(dst, "SKILL.md");
2482
2496
  if (!existsSync5(dstMd)) return;
2483
- if (readFileSync8(srcMd, "utf8") !== readFileSync8(dstMd, "utf8")) {
2497
+ if (readFileSync9(srcMd, "utf8") !== readFileSync9(dstMd, "utf8")) {
2484
2498
  cpSync(src, dst, { recursive: true });
2485
2499
  }
2486
2500
  } catch {
@@ -2488,15 +2502,15 @@ function syncCompanionSkill(harness, opts = {}) {
2488
2502
  }
2489
2503
 
2490
2504
  // src/core/legacy.ts
2491
- import { existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
2492
- import { homedir as homedir6 } from "os";
2493
- import { join as join14, relative, isAbsolute as isAbsolute2 } from "path";
2505
+ import { existsSync as existsSync6, readFileSync as readFileSync10 } from "fs";
2506
+ import { homedir as homedir7 } from "os";
2507
+ import { join as join16, relative, isAbsolute as isAbsolute2 } from "path";
2494
2508
  var LEGACY_CLAUDE_PLUGIN = "hindsight-memory";
2495
- function detectLegacyClaudePlugin(cwd, claudeDir = join14(homedir6(), ".claude")) {
2496
- const registry = readJson(join14(claudeDir, "plugins", "installed_plugins.json"));
2509
+ function detectLegacyClaudePlugin(cwd, claudeDir = join16(homedir7(), ".claude")) {
2510
+ const registry = readJson(join16(claudeDir, "plugins", "installed_plugins.json"));
2497
2511
  const plugins = registry?.plugins;
2498
2512
  if (!plugins || typeof plugins !== "object") return void 0;
2499
- const enabled = readJson(join14(claudeDir, "settings.json"))?.enabledPlugins;
2513
+ const enabled = readJson(join16(claudeDir, "settings.json"))?.enabledPlugins;
2500
2514
  for (const [key, raw] of Object.entries(plugins)) {
2501
2515
  if (key.split("@")[0] !== LEGACY_CLAUDE_PLUGIN) continue;
2502
2516
  if (enabled && enabled[key] === false) continue;
@@ -2513,7 +2527,7 @@ function detectLegacyClaudePlugin(cwd, claudeDir = join14(homedir6(), ".claude")
2513
2527
  }
2514
2528
  function readJson(path) {
2515
2529
  try {
2516
- const parsed = JSON.parse(readFileSync9(path, "utf8"));
2530
+ const parsed = JSON.parse(readFileSync10(path, "utf8"));
2517
2531
  return parsed && typeof parsed === "object" ? parsed : void 0;
2518
2532
  } catch {
2519
2533
  return void 0;
@@ -2687,7 +2701,7 @@ async function runSessionStartHook(spec, makeClient = (o) => new HindsightClient
2687
2701
  try {
2688
2702
  let ev = {};
2689
2703
  try {
2690
- ev = JSON.parse(readFileSync10(0, "utf8"));
2704
+ ev = JSON.parse(readFileSync11(0, "utf8"));
2691
2705
  } catch {
2692
2706
  return;
2693
2707
  }
@@ -2856,19 +2870,19 @@ function readCopilotTranscript(path) {
2856
2870
  }
2857
2871
 
2858
2872
  // src/core/transcript-grok.ts
2859
- import { existsSync as existsSync7, readFileSync as readFileSync11, readdirSync as readdirSync2 } from "fs";
2860
- import { homedir as homedir7 } from "os";
2861
- import { join as join15 } from "path";
2873
+ import { existsSync as existsSync7, readFileSync as readFileSync12, readdirSync as readdirSync2 } from "fs";
2874
+ import { homedir as homedir8 } from "os";
2875
+ import { join as join17 } from "path";
2862
2876
  var CHAT_HISTORY = "chat_history.jsonl";
2863
- function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join15(homedir7(), ".grok")) {
2864
- const sessionsDir = join15(grokHome, "sessions");
2865
- const direct = join15(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2877
+ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join17(homedir8(), ".grok")) {
2878
+ const sessionsDir = join17(grokHome, "sessions");
2879
+ const direct = join17(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2866
2880
  if (existsSync7(direct)) return direct;
2867
2881
  try {
2868
2882
  for (const candidate of readdirSync2(sessionsDir)) {
2869
- const directory = join15(sessionsDir, candidate);
2870
- if (readFileSync11(join15(directory, ".cwd"), "utf8").trim() === cwd) {
2871
- return join15(directory, sessionId, CHAT_HISTORY);
2883
+ const directory = join17(sessionsDir, candidate);
2884
+ if (readFileSync12(join17(directory, ".cwd"), "utf8").trim() === cwd) {
2885
+ return join17(directory, sessionId, CHAT_HISTORY);
2872
2886
  }
2873
2887
  }
2874
2888
  } catch {
@@ -2905,10 +2919,10 @@ function readGrokTranscript(path) {
2905
2919
  // src/core/transcript-devin.ts
2906
2920
  import { existsSync as existsSync8 } from "fs";
2907
2921
  import { createRequire } from "module";
2908
- import { homedir as homedir8 } from "os";
2909
- import { join as join16 } from "path";
2910
- function devinSessionDb(home = homedir8()) {
2911
- return join16(home, ".local", "share", "devin", "cli", "sessions.db");
2922
+ import { homedir as homedir9 } from "os";
2923
+ import { join as join18 } from "path";
2924
+ function devinSessionDb(home = homedir9()) {
2925
+ return join18(home, ".local", "share", "devin", "cli", "sessions.db");
2912
2926
  }
2913
2927
  function parseDevinMessages(nodes) {
2914
2928
  const messages = /* @__PURE__ */ new Map();
@@ -3218,7 +3232,7 @@ function readDroidTranscript(path) {
3218
3232
  }
3219
3233
 
3220
3234
  // src/core/transcript-zcode.ts
3221
- import { readFileSync as readFileSync12 } from "fs";
3235
+ import { readFileSync as readFileSync13 } from "fs";
3222
3236
  function messageText2(content) {
3223
3237
  if (typeof content === "string") return content.trim();
3224
3238
  if (!Array.isArray(content)) return "";
@@ -3228,7 +3242,7 @@ function readZcodeTranscript(path) {
3228
3242
  if (!path) return [];
3229
3243
  let body;
3230
3244
  try {
3231
- body = readFileSync12(path, "utf8");
3245
+ body = readFileSync13(path, "utf8");
3232
3246
  } catch {
3233
3247
  return [];
3234
3248
  }