@vectorize-io/hindsight-coding-agents 0.5.2 → 0.5.3

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 +42 -8
  2. package/dist/antigravity-hook.js +286 -76
  3. package/dist/antigravity-statusline.js +17 -10
  4. package/dist/antigravity-stop-hook.js +297 -79
  5. package/dist/claude-hook.js +286 -76
  6. package/dist/claude-sessionstart-hook.js +252 -93
  7. package/dist/claude-stop-hook.js +297 -79
  8. package/dist/cline.js +74 -18
  9. package/dist/codex-hook.js +286 -76
  10. package/dist/codex-sessionstart-hook.js +252 -93
  11. package/dist/codex-stop-hook.js +297 -79
  12. package/dist/copilot-hook.js +286 -76
  13. package/dist/copilot-sessionstart-hook.js +252 -93
  14. package/dist/copilot-stop-hook.js +297 -79
  15. package/dist/cursor-hook.js +286 -76
  16. package/dist/cursor-sessionstart-hook.js +252 -93
  17. package/dist/cursor-stop-hook.js +297 -79
  18. package/dist/daemon-start.js +17 -10
  19. package/dist/dcode-hook.js +286 -76
  20. package/dist/dcode-sessionstart-hook.js +252 -93
  21. package/dist/dcode-stop-hook.js +297 -79
  22. package/dist/deepen.js +73 -19
  23. package/dist/devin-hook.js +286 -76
  24. package/dist/devin-sessionstart-hook.js +252 -93
  25. package/dist/devin-stop-hook.js +297 -79
  26. package/dist/droid-hook.js +286 -76
  27. package/dist/droid-sessionstart-hook.js +252 -93
  28. package/dist/droid-stop-hook.js +297 -79
  29. package/dist/dsh.js +111 -53
  30. package/dist/grok-hook.js +286 -76
  31. package/dist/grok-sessionstart-hook.js +252 -93
  32. package/dist/grok-stop-hook.js +297 -79
  33. package/dist/hindsight-seed.js +17 -10
  34. package/dist/index.js +113 -55
  35. package/dist/installer.js +383 -218
  36. package/dist/kilo.js +113 -55
  37. package/dist/mcp-server.js +67 -17
  38. package/dist/opencode2.js +113 -55
  39. package/dist/pi.js +112 -54
  40. package/dist/prime-agent.js +112 -54
  41. package/dist/qwen-hook.js +286 -76
  42. package/dist/qwen-sessionstart-hook.js +252 -93
  43. package/dist/qwen-stop-hook.js +297 -79
  44. package/dist/status.js +67 -17
  45. package/dist/zcode-hook.js +2920 -0
  46. package/dist/zcode-sessionstart-hook.js +3487 -0
  47. package/dist/zcode-stop-hook.js +3188 -0
  48. package/package.json +6 -3
  49. package/plugin.json +1 -1
  50. package/skill/SKILL.md +17 -7
package/dist/installer.js CHANGED
@@ -6,17 +6,17 @@ import {
6
6
  copyFileSync,
7
7
  cpSync as cpSync2,
8
8
  existsSync as existsSync10,
9
- mkdirSync as mkdirSync4,
9
+ mkdirSync as mkdirSync5,
10
10
  mkdtempSync,
11
- readFileSync as readFileSync12,
11
+ readFileSync as readFileSync14,
12
12
  readSync as readSync4,
13
13
  realpathSync as realpathSync3,
14
14
  rmSync as rmSync2,
15
15
  writeFileSync as writeFileSync3
16
16
  } from "fs";
17
- import { homedir as homedir10, tmpdir as tmpdir4 } from "os";
17
+ import { homedir as homedir10, tmpdir as tmpdir5 } from "os";
18
18
  import { isatty } from "tty";
19
- import { dirname as dirname10, join as join16 } from "path";
19
+ import { dirname as dirname11, join as join17 } from "path";
20
20
  import { fileURLToPath as fileURLToPath6, pathToFileURL } from "url";
21
21
 
22
22
  // node_modules/jsonc-parser/lib/esm/impl/scanner.js
@@ -1348,7 +1348,7 @@ function applyEdits(text, edits) {
1348
1348
  }
1349
1349
 
1350
1350
  // src/core/hook.ts
1351
- import { existsSync as existsSync2, readFileSync as readFileSync4 } from "fs";
1351
+ import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
1352
1352
 
1353
1353
  // src/core/bank.ts
1354
1354
  import { existsSync } from "fs";
@@ -1451,8 +1451,51 @@ import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync, rmS
1451
1451
  import { tmpdir as tmpdir2 } from "os";
1452
1452
  import { dirname as dirname5, join as join7 } from "path";
1453
1453
 
1454
+ // src/core/turn-journal.ts
1455
+ import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, statSync } from "fs";
1456
+ import { tmpdir as tmpdir3 } from "os";
1457
+ import { dirname as dirname6, join as join8 } from "path";
1458
+
1459
+ // src/core/transcript-util.ts
1460
+ 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;
1461
+ function stripInjectedMemory(s) {
1462
+ return s.replace(MEMORY_TAG_RE, "");
1463
+ }
1464
+ var TARGET_KEYS = [
1465
+ "file_path",
1466
+ "path",
1467
+ "notebook_path",
1468
+ "command",
1469
+ "pattern",
1470
+ "query",
1471
+ "url",
1472
+ "name",
1473
+ "id"
1474
+ ];
1475
+ var ACTION_TARGET_CAP = 100;
1476
+ function actionLine(tool, input) {
1477
+ let target = "";
1478
+ if (input && typeof input === "object") {
1479
+ const rec = input;
1480
+ for (const k of TARGET_KEYS) {
1481
+ const v = rec[k];
1482
+ if (typeof v === "string" && v.trim()) {
1483
+ target = v.trim().split("\n")[0];
1484
+ break;
1485
+ }
1486
+ }
1487
+ } else if (typeof input === "string") {
1488
+ target = input.trim().split("\n")[0];
1489
+ }
1490
+ if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
1491
+ return target ? `${tool} ${target}` : tool;
1492
+ }
1493
+
1494
+ // src/core/turn-journal.ts
1495
+ var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
1496
+
1454
1497
  // src/core/retain-hook.ts
1455
- import { readFileSync as readFileSync5 } from "fs";
1498
+ import { readFileSync as readFileSync6 } from "fs";
1456
1499
 
1457
1500
  // src/core/retain-cursor.ts
1458
1501
  import { createHash as createHash2 } from "crypto";
@@ -1464,7 +1507,7 @@ import { createHash as createHash3 } from "crypto";
1464
1507
 
1465
1508
  // src/core/daemon.ts
1466
1509
  import { execFileSync, spawn as realSpawn2 } from "child_process";
1467
- import { dirname as dirname6, join as join8 } from "path";
1510
+ import { dirname as dirname7, join as join9 } from "path";
1468
1511
  import { fileURLToPath as fileURLToPath2 } from "url";
1469
1512
  function hasRustToolchain() {
1470
1513
  if (process.platform !== "darwin") return true;
@@ -1532,7 +1575,7 @@ function onPath(bin) {
1532
1575
  import { basename as basename2 } from "path";
1533
1576
 
1534
1577
  // src/core/jsonl.ts
1535
- import { closeSync, openSync, readSync, statSync } from "fs";
1578
+ import { closeSync, openSync, readSync, statSync as statSync2 } from "fs";
1536
1579
  import { StringDecoder } from "string_decoder";
1537
1580
  var CHUNK_BYTES = 64 * 1024;
1538
1581
  var MAX_TRANSCRIPT_BYTES = 32 * 1024 * 1024;
@@ -1540,7 +1583,7 @@ function readJsonlTail(path, opts) {
1540
1583
  const maxBytes = opts.maxBytes ?? MAX_TRANSCRIPT_BYTES;
1541
1584
  let size;
1542
1585
  try {
1543
- size = statSync(path).size;
1586
+ size = statSync2(path).size;
1544
1587
  } catch {
1545
1588
  return { lines: emptyLines(), skippedBytes: 0 };
1546
1589
  }
@@ -1592,41 +1635,6 @@ function* streamLines(path, start) {
1592
1635
  }
1593
1636
  }
1594
1637
 
1595
- // src/core/transcript-util.ts
1596
- 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;
1597
- function stripInjectedMemory(s) {
1598
- return s.replace(MEMORY_TAG_RE, "");
1599
- }
1600
- var TARGET_KEYS = [
1601
- "file_path",
1602
- "path",
1603
- "notebook_path",
1604
- "command",
1605
- "pattern",
1606
- "query",
1607
- "url",
1608
- "name",
1609
- "id"
1610
- ];
1611
- var ACTION_TARGET_CAP = 100;
1612
- function actionLine(tool, input) {
1613
- let target = "";
1614
- if (input && typeof input === "object") {
1615
- const rec = input;
1616
- for (const k of TARGET_KEYS) {
1617
- const v = rec[k];
1618
- if (typeof v === "string" && v.trim()) {
1619
- target = v.trim().split("\n")[0];
1620
- break;
1621
- }
1622
- }
1623
- } else if (typeof input === "string") {
1624
- target = input.trim().split("\n")[0];
1625
- }
1626
- if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
1627
- return target ? `${tool} ${target}` : tool;
1628
- }
1629
-
1630
1638
  // src/core/transcript.ts
1631
1639
  function renderLine(content, type) {
1632
1640
  if (typeof content === "string") {
@@ -1679,7 +1687,7 @@ function readClaudeTranscript(path) {
1679
1687
  }
1680
1688
 
1681
1689
  // src/core/session-start.ts
1682
- import { readFileSync as readFileSync8 } from "fs";
1690
+ import { readFileSync as readFileSync9 } from "fs";
1683
1691
 
1684
1692
  // src/core/git.ts
1685
1693
  import { execFileSync as execFileSync2 } from "child_process";
@@ -1692,29 +1700,29 @@ import { execFileSync as execFileSync3 } from "child_process";
1692
1700
  import { spawn as realSpawn3 } from "child_process";
1693
1701
  import { existsSync as existsSync3 } from "fs";
1694
1702
  import { homedir as homedir3 } from "os";
1695
- import { dirname as dirname7, join as join9 } from "path";
1703
+ import { dirname as dirname8, join as join10 } from "path";
1696
1704
  import { fileURLToPath as fileURLToPath3 } from "url";
1697
1705
 
1698
1706
  // src/core/auto-update.ts
1699
1707
  import { spawn as realSpawn4 } from "child_process";
1700
1708
  import {
1701
1709
  existsSync as existsSync4,
1702
- mkdirSync as mkdirSync3,
1703
- readFileSync as readFileSync6,
1710
+ mkdirSync as mkdirSync4,
1711
+ readFileSync as readFileSync7,
1704
1712
  realpathSync as realpathSync2,
1705
1713
  unlinkSync,
1706
1714
  writeFileSync as writeFileSync2
1707
1715
  } from "fs";
1708
- import { homedir as homedir4, tmpdir as tmpdir3 } from "os";
1709
- import { dirname as dirname8, join as join10 } from "path";
1716
+ import { homedir as homedir4, tmpdir as tmpdir4 } from "os";
1717
+ import { dirname as dirname9, join as join11 } from "path";
1710
1718
  import { fileURLToPath as fileURLToPath4 } from "url";
1711
1719
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
1712
1720
  var LOCK_STALE_MS = 10 * 60 * 1e3;
1713
1721
 
1714
1722
  // src/core/skill-sync.ts
1715
- import { cpSync, existsSync as existsSync5, readFileSync as readFileSync7 } from "fs";
1723
+ import { cpSync, existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
1716
1724
  import { homedir as homedir5 } from "os";
1717
- import { dirname as dirname9, join as join11 } from "path";
1725
+ import { dirname as dirname10, join as join12 } from "path";
1718
1726
  import { fileURLToPath as fileURLToPath5 } from "url";
1719
1727
 
1720
1728
  // src/core/skill-dirs.ts
@@ -1732,6 +1740,11 @@ var SKILL_DIRS = {
1732
1740
  // Qwen's user-level skills root (Storage.getUserSkillsDirs)
1733
1741
  "factory-droid": [".factory", "skills"],
1734
1742
  // Droid's user-level skills root
1743
+ // ZCode scans TWO user roots by default (its resolveDefaultSkillRoots): `~/.zcode/skills` and the
1744
+ // shared agentskills `~/.agents/skills`. Write its OWN, for the same reason the pi family does —
1745
+ // skill removal is by fixed directory name, so installing into the shared root would make
1746
+ // `uninstall zcode` take Codex's and dsh's copy with it.
1747
+ zcode: [".zcode", "skills"],
1735
1748
  // The pi family reads the shared ~/.agents/skills too, but writes its OWN root: skill removal is
1736
1749
  // by fixed directory name, so installing to the shared one would make `uninstall pi` take Codex's
1737
1750
  // and dsh's copy with it.
@@ -1869,19 +1882,19 @@ function readCopilotTranscript(path) {
1869
1882
  }
1870
1883
 
1871
1884
  // src/core/transcript-grok.ts
1872
- import { existsSync as existsSync6, readFileSync as readFileSync9, readdirSync } from "fs";
1885
+ import { existsSync as existsSync6, readFileSync as readFileSync10, readdirSync } from "fs";
1873
1886
  import { homedir as homedir6 } from "os";
1874
- import { join as join12 } from "path";
1887
+ import { join as join13 } from "path";
1875
1888
  var CHAT_HISTORY = "chat_history.jsonl";
1876
- function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join12(homedir6(), ".grok")) {
1877
- const sessionsDir = join12(grokHome, "sessions");
1878
- const direct = join12(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
1889
+ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join13(homedir6(), ".grok")) {
1890
+ const sessionsDir = join13(grokHome, "sessions");
1891
+ const direct = join13(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
1879
1892
  if (existsSync6(direct)) return direct;
1880
1893
  try {
1881
1894
  for (const candidate of readdirSync(sessionsDir)) {
1882
- const directory = join12(sessionsDir, candidate);
1883
- if (readFileSync9(join12(directory, ".cwd"), "utf8").trim() === cwd) {
1884
- return join12(directory, sessionId, CHAT_HISTORY);
1895
+ const directory = join13(sessionsDir, candidate);
1896
+ if (readFileSync10(join13(directory, ".cwd"), "utf8").trim() === cwd) {
1897
+ return join13(directory, sessionId, CHAT_HISTORY);
1885
1898
  }
1886
1899
  }
1887
1900
  } catch {
@@ -1919,9 +1932,9 @@ function readGrokTranscript(path) {
1919
1932
  import { existsSync as existsSync7 } from "fs";
1920
1933
  import { createRequire } from "module";
1921
1934
  import { homedir as homedir7 } from "os";
1922
- import { join as join13 } from "path";
1935
+ import { join as join14 } from "path";
1923
1936
  function devinSessionDb(home = homedir7()) {
1924
- return join13(home, ".local", "share", "devin", "cli", "sessions.db");
1937
+ return join14(home, ".local", "share", "devin", "cli", "sessions.db");
1925
1938
  }
1926
1939
  function parseDevinMessages(nodes) {
1927
1940
  const messages = /* @__PURE__ */ new Map();
@@ -2230,6 +2243,51 @@ function readDroidTranscript(path) {
2230
2243
  return turns;
2231
2244
  }
2232
2245
 
2246
+ // src/core/transcript-zcode.ts
2247
+ import { readFileSync as readFileSync11 } from "fs";
2248
+ function messageText2(content) {
2249
+ if (typeof content === "string") return content.trim();
2250
+ if (!Array.isArray(content)) return "";
2251
+ return content.filter((block) => block && typeof block === "object" && typeof block.text === "string").map((block) => block.text.trim()).filter(Boolean).join("\n").trim();
2252
+ }
2253
+ function readZcodeTranscript(path) {
2254
+ if (!path) return [];
2255
+ let body;
2256
+ try {
2257
+ body = readFileSync11(path, "utf8");
2258
+ } catch {
2259
+ return [];
2260
+ }
2261
+ const turns = [];
2262
+ for (const line of body.split("\n")) {
2263
+ const trimmed = line.trim();
2264
+ if (!trimmed) continue;
2265
+ let parsed;
2266
+ try {
2267
+ parsed = JSON.parse(trimmed);
2268
+ } catch {
2269
+ continue;
2270
+ }
2271
+ if (typeof parsed !== "object" || parsed === null) continue;
2272
+ const record = parsed;
2273
+ const message = typeof record.message === "object" && record.message !== null ? record.message : void 0;
2274
+ const role = typeof message?.role === "string" ? message.role : record.type;
2275
+ if (role !== "user" && role !== "assistant") continue;
2276
+ const content = stripInjectedMemory(messageText2(message?.content)).trim();
2277
+ if (!content) continue;
2278
+ turns.push({
2279
+ role,
2280
+ content,
2281
+ ...typeof record.timestamp === "string" ? { timestamp: record.timestamp } : {}
2282
+ });
2283
+ }
2284
+ return turns;
2285
+ }
2286
+ function zcodeAssistantText(path) {
2287
+ if (!path) return "";
2288
+ return readZcodeTranscript(path).filter((turn) => turn.role === "assistant").at(-1)?.content ?? "";
2289
+ }
2290
+
2233
2291
  // src/harness/hook-lifecycle.ts
2234
2292
  var cursorCwd = (ev) => ev.cwd ?? ev.workspace_root ?? (Array.isArray(ev.workspace_roots) ? ev.workspace_roots[0] : void 0);
2235
2293
  var claudePrompt = {
@@ -2270,6 +2328,7 @@ var qwenPrompt = {
2270
2328
  sessionId: ev.session_id
2271
2329
  })
2272
2330
  };
2331
+ var zcodeSessionId = (ev) => ev.session_id ?? ev.sessionId;
2273
2332
  var antigravityCwd = (ev) => Array.isArray(ev.workspacePaths) ? ev.workspacePaths[0] : void 0;
2274
2333
  var antigravityPrompt = {
2275
2334
  harness: "antigravity-cli",
@@ -2612,6 +2671,56 @@ var HOOK_HARNESSES = {
2612
2671
  }),
2613
2672
  readTranscript: readDroidTranscript
2614
2673
  }
2674
+ },
2675
+ /**
2676
+ * ZCode (Z.ai's GLM coding agent) embeds the Claude Code agent runtime, so its hook PROTOCOL is
2677
+ * Claude's — `prompt`/`cwd` in, `hookSpecificOutput.additionalContext` + `systemMessage` out —
2678
+ * with `sessionId` accepted alongside `session_id`, which its Stop payload sends instead.
2679
+ *
2680
+ * What is not Claude's is the TRANSCRIPT, and that is the whole of the difference here. ZCode
2681
+ * keeps no durable session file: `Stop` carries the reply in `responseText` plus a temp,
2682
+ * assistant-only transcript it deletes as soon as the hook returns, and no user prompt at all.
2683
+ * So this is the one harness that retains from the plugin's own journal (core/turn-journal.ts) —
2684
+ * the prompt hook appends the user turn, `journal.assistantText` closes it with the reply — and
2685
+ * everything downstream (cursor, append, stamping) sees the same full conversation as any host
2686
+ * transcript.
2687
+ */
2688
+ zcode: {
2689
+ configStyle: "process",
2690
+ // ZCode's `timeoutMs`, so MILLISECONDS — see the qwen-code note above for the same trap. The
2691
+ // prompt budget must stay above core/hook.ts's HOOK_REFLECT_CAP_MS (25_000).
2692
+ timeoutUnit: "milliseconds",
2693
+ install: {
2694
+ sessionStart: { event: "SessionStart", entry: "zcode-sessionstart-hook.js", timeout: 3e4 },
2695
+ prompt: { event: "UserPromptSubmit", entry: "zcode-hook.js", timeout: 3e4 },
2696
+ stop: { event: "Stop", entry: "zcode-stop-hook.js", timeout: 6e4 }
2697
+ },
2698
+ sessionStart: {
2699
+ ...standardSessionStart("zcode"),
2700
+ parse: (ev) => ({ cwd: ev.cwd, sessionId: zcodeSessionId(ev) })
2701
+ },
2702
+ prompt: {
2703
+ ...claudePrompt,
2704
+ harness: "zcode",
2705
+ journalPrompt: true,
2706
+ parse: (ev) => ({
2707
+ prompt: ev.prompt ?? ev.user_prompt,
2708
+ cwd: ev.cwd,
2709
+ sessionId: zcodeSessionId(ev)
2710
+ })
2711
+ },
2712
+ retain: {
2713
+ hostTimeoutSec: 60,
2714
+ harness: "zcode",
2715
+ // No transcriptPath: the journal supplies it (see `journal` below).
2716
+ parse: (ev) => ({ sessionId: zcodeSessionId(ev), cwd: ev.cwd }),
2717
+ journal: {
2718
+ // `responseText` is the full reply and is what ZCode sends in practice. The ephemeral
2719
+ // transcript is the fallback when it is absent, and `responsePreview` — which is
2720
+ // TRUNCATED — is the last resort, preferred only over losing the turn entirely.
2721
+ assistantText: (ev) => (ev.responseText || zcodeAssistantText(ev.transcript_path) || ev.responsePreview || "").trim()
2722
+ }
2723
+ }
2615
2724
  }
2616
2725
  };
2617
2726
 
@@ -2622,13 +2731,13 @@ import {
2622
2731
  existsSync as existsSync8,
2623
2732
  openSync as openSync2,
2624
2733
  readdirSync as readdirSync2,
2625
- readFileSync as readFileSync10,
2734
+ readFileSync as readFileSync12,
2626
2735
  readSync as readSync2,
2627
- statSync as statSync2
2736
+ statSync as statSync3
2628
2737
  } from "fs";
2629
2738
  import { createHash as createHash4 } from "crypto";
2630
2739
  import { homedir as homedir8 } from "os";
2631
- import { join as join14 } from "path";
2740
+ import { join as join15 } from "path";
2632
2741
  import * as zlib2 from "zlib";
2633
2742
 
2634
2743
  // src/core/transcript-dsh.ts
@@ -2773,7 +2882,7 @@ function zstdDecompressFrames(buffer) {
2773
2882
 
2774
2883
  // src/core/history.ts
2775
2884
  function claudeProjectDir(repoDir, home = homedir8()) {
2776
- return join14(home, ".claude", "projects", repoDir.replace(/[^a-zA-Z0-9]/g, "-"));
2885
+ return join15(home, ".claude", "projects", repoDir.replace(/[^a-zA-Z0-9]/g, "-"));
2777
2886
  }
2778
2887
  function piSessionDir(repoDir) {
2779
2888
  return `--${repoDir.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
@@ -2783,7 +2892,7 @@ function withinRepo(dir, repoDir) {
2783
2892
  }
2784
2893
  function claudeSessionCwd(file) {
2785
2894
  try {
2786
- for (const line of readFileSync10(file, "utf8").split("\n", 400)) {
2895
+ for (const line of readFileSync12(file, "utf8").split("\n", 400)) {
2787
2896
  if (!line.includes('"cwd"')) continue;
2788
2897
  const cwd = JSON.parse(line).cwd;
2789
2898
  if (cwd) return cwd;
@@ -2825,13 +2934,13 @@ function listDir(dir) {
2825
2934
  }
2826
2935
  }
2827
2936
  function jsonlFiles(dir) {
2828
- return listDir(dir).filter((f) => f.endsWith(".jsonl")).map((f) => join14(dir, f));
2937
+ return listDir(dir).filter((f) => f.endsWith(".jsonl")).map((f) => join15(dir, f));
2829
2938
  }
2830
2939
  function claudeHistory(repoDir, home) {
2831
- const root = join14(home, ".claude", "projects");
2940
+ const root = join15(home, ".claude", "projects");
2832
2941
  const exact = claudeProjectDir(repoDir, home);
2833
2942
  const prefix = exact + "-";
2834
- const dirs = listDir(root).map((d) => join14(root, d)).filter((d) => d === exact || d.startsWith(prefix));
2943
+ const dirs = listDir(root).map((d) => join15(root, d)).filter((d) => d === exact || d.startsWith(prefix));
2835
2944
  const sessions = [];
2836
2945
  let unattributed = 0;
2837
2946
  for (const file of dirs.flatMap(jsonlFiles)) {
@@ -2851,13 +2960,13 @@ function claudeHistory(repoDir, home) {
2851
2960
  return { supported: true, sessions, unattributed };
2852
2961
  }
2853
2962
  function codexHistory(repoDir, home) {
2854
- const root = join14(home, ".codex", "sessions");
2963
+ const root = join15(home, ".codex", "sessions");
2855
2964
  if (!existsSync8(root)) return { supported: true, sessions: [] };
2856
2965
  const files = [];
2857
2966
  const walk = (dir) => {
2858
2967
  for (const entry of readdirSync2(dir)) {
2859
- const p = join14(dir, entry);
2860
- if (statSync2(p).isDirectory()) walk(p);
2968
+ const p = join15(dir, entry);
2969
+ if (statSync3(p).isDirectory()) walk(p);
2861
2970
  else if (entry.endsWith(".jsonl")) files.push(p);
2862
2971
  }
2863
2972
  };
@@ -2886,13 +2995,13 @@ function dcodeTranscriptPath(root, threadId) {
2886
2995
  const suffix = `--${digest}.jsonl`;
2887
2996
  try {
2888
2997
  const match = readdirSync2(root).find((entry) => entry.endsWith(suffix));
2889
- return match ? join14(root, match) : void 0;
2998
+ return match ? join15(root, match) : void 0;
2890
2999
  } catch {
2891
3000
  return void 0;
2892
3001
  }
2893
3002
  }
2894
3003
  function dcodeHistory(repoDir, home, runCli) {
2895
- const root = join14(process.env.DEEPAGENTS_HOME || join14(home, ".deepagents"), "transcripts");
3004
+ const root = join15(process.env.DEEPAGENTS_HOME || join15(home, ".deepagents"), "transcripts");
2896
3005
  if (!existsSync8(root)) return { supported: true, sessions: [] };
2897
3006
  let listed;
2898
3007
  try {
@@ -2933,7 +3042,7 @@ function dcodeHistory(repoDir, home, runCli) {
2933
3042
  return { supported: true, sessions, ...unattributed ? { unattributed } : {} };
2934
3043
  }
2935
3044
  function dshHistory(repoDir, home) {
2936
- const root = process.env.DSH_HOME ? join14(process.env.DSH_HOME, "sessions") : join14(home, ".dsh", "sessions");
3045
+ const root = process.env.DSH_HOME ? join15(process.env.DSH_HOME, "sessions") : join15(home, ".dsh", "sessions");
2937
3046
  if (!existsSync8(root)) return { supported: true, sessions: [] };
2938
3047
  if (typeof zlib2.zstdDecompressSync !== "function") {
2939
3048
  return {
@@ -2944,15 +3053,15 @@ function dshHistory(repoDir, home) {
2944
3053
  }
2945
3054
  const sessions = [];
2946
3055
  let unattributed = 0;
2947
- for (const dir of readdirSync2(root).map((project) => join14(root, project))) {
3056
+ for (const dir of readdirSync2(root).map((project) => join15(root, project))) {
2948
3057
  let sessionDirs;
2949
3058
  try {
2950
- sessionDirs = readdirSync2(dir).map((id) => join14(dir, id));
3059
+ sessionDirs = readdirSync2(dir).map((id) => join15(dir, id));
2951
3060
  } catch {
2952
3061
  continue;
2953
3062
  }
2954
3063
  for (const sessionDir of sessionDirs) {
2955
- const file = ["session.jsonl.zstd", "session.jsonl"].map((name) => join14(sessionDir, name)).find((candidate) => existsSync8(candidate));
3064
+ const file = ["session.jsonl.zstd", "session.jsonl"].map((name) => join15(sessionDir, name)).find((candidate) => existsSync8(candidate));
2956
3065
  if (!file) continue;
2957
3066
  try {
2958
3067
  const lines = readDshLog(file);
@@ -2978,7 +3087,7 @@ function dshHistory(repoDir, home) {
2978
3087
  return { supported: true, sessions, unattributed };
2979
3088
  }
2980
3089
  function readDshLog(file) {
2981
- const bytes = readFileSync10(file);
3090
+ const bytes = readFileSync12(file);
2982
3091
  const text = file.endsWith(".zstd") ? zstdDecompressFrames(bytes) : bytes.toString("utf8");
2983
3092
  return text.split("\n").filter((line) => line.trim());
2984
3093
  }
@@ -3004,18 +3113,18 @@ function piFamilySessions(files, repoDir) {
3004
3113
  return { supported: true, sessions, unattributed };
3005
3114
  }
3006
3115
  function piHistory(repoDir, home) {
3007
- const root = join14(home, ".pi", "agent", "sessions");
3116
+ const root = join15(home, ".pi", "agent", "sessions");
3008
3117
  if (!existsSync8(root)) return { supported: true, sessions: [] };
3009
3118
  const exact = piSessionDir(repoDir);
3010
3119
  const nested = `${exact.slice(0, -2)}-`;
3011
3120
  const files = [];
3012
3121
  for (const dir of listDir(root).filter((d) => d === exact || d.startsWith(nested))) {
3013
- files.push(...jsonlFiles(join14(root, dir)));
3122
+ files.push(...jsonlFiles(join15(root, dir)));
3014
3123
  }
3015
3124
  return piFamilySessions(files, repoDir);
3016
3125
  }
3017
3126
  function primeAgentHistory(repoDir, home) {
3018
- const root = join14(home, ".prime", "agent", "sessions");
3127
+ const root = join15(home, ".prime", "agent", "sessions");
3019
3128
  if (!existsSync8(root)) return { supported: true, sessions: [] };
3020
3129
  return piFamilySessions(jsonlFiles(root), repoDir);
3021
3130
  }
@@ -3047,21 +3156,27 @@ function importLocalHistory(harness, repoDir, home = homedir8(), runDcodeCli) {
3047
3156
  case "copilot-cli":
3048
3157
  case "devin-cli":
3049
3158
  return { supported: false, reason: `${harness} ${SQLITE_HISTORY}`, sessions: [] };
3159
+ case "zcode":
3160
+ return {
3161
+ supported: false,
3162
+ reason: "ZCode keeps no session transcripts on disk to import",
3163
+ sessions: []
3164
+ };
3050
3165
  default:
3051
3166
  return { supported: false, reason: `no local history reader for ${harness}`, sessions: [] };
3052
3167
  }
3053
3168
  }
3054
3169
 
3055
3170
  // src/core/legacy.ts
3056
- import { existsSync as existsSync9, readFileSync as readFileSync11 } from "fs";
3171
+ import { existsSync as existsSync9, readFileSync as readFileSync13 } from "fs";
3057
3172
  import { homedir as homedir9 } from "os";
3058
- import { join as join15 } from "path";
3173
+ import { join as join16 } from "path";
3059
3174
  var LEGACY_CONFIG_FILES = {
3060
3175
  "claude-code": "claude-code.json",
3061
3176
  codex: "codex.json"
3062
3177
  };
3063
3178
  function legacyConfigPath(harness, home = homedir9()) {
3064
- return join15(home, ".hindsight", LEGACY_CONFIG_FILES[harness] ?? `${harness}.json`);
3179
+ return join16(home, ".hindsight", LEGACY_CONFIG_FILES[harness] ?? `${harness}.json`);
3065
3180
  }
3066
3181
  var CLOUD_URL = "https://api.hindsight.vectorize.io";
3067
3182
  function readLegacyEndpoint(home = homedir9(), prefer = []) {
@@ -3079,7 +3194,7 @@ function readOne(harness, home) {
3079
3194
  if (!existsSync9(source)) return void 0;
3080
3195
  let raw;
3081
3196
  try {
3082
- raw = JSON.parse(readFileSync11(source, "utf8"));
3197
+ raw = JSON.parse(readFileSync13(source, "utf8"));
3083
3198
  } catch {
3084
3199
  return void 0;
3085
3200
  }
@@ -3309,9 +3424,11 @@ function createInstallerUi(o) {
3309
3424
 
3310
3425
  // src/installer.ts
3311
3426
  var MARKER = "coding-agents";
3427
+ var ZCODE_MAX_OUTPUT_BYTES = 32768;
3428
+ var zcodeConfigPath = (c) => join17(c.home, ".zcode", "cli", "config.json");
3312
3429
  function readJson(path) {
3313
3430
  try {
3314
- return JSON.parse(readFileSync12(path, "utf8"));
3431
+ return JSON.parse(readFileSync14(path, "utf8"));
3315
3432
  } catch {
3316
3433
  return {};
3317
3434
  }
@@ -3326,7 +3443,7 @@ function parseJsonc(text) {
3326
3443
  }
3327
3444
  }
3328
3445
  function writeJson(path, value) {
3329
- mkdirSync4(dirname10(path), { recursive: true });
3446
+ mkdirSync5(dirname11(path), { recursive: true });
3330
3447
  backupOnce(path);
3331
3448
  writeFileSync3(path, JSON.stringify(value, null, 2) + "\n");
3332
3449
  }
@@ -3336,7 +3453,7 @@ function backupOnce(path) {
3336
3453
  }
3337
3454
  }
3338
3455
  function writeJsonc(path, key, value) {
3339
- const text = existsSync10(path) ? readFileSync12(path, "utf8") : "";
3456
+ const text = existsSync10(path) ? readFileSync14(path, "utf8") : "";
3340
3457
  const edits = modify(text, [key], value, {
3341
3458
  formattingOptions: {
3342
3459
  tabSize: 2,
@@ -3347,7 +3464,7 @@ function writeJsonc(path, key, value) {
3347
3464
  }
3348
3465
  });
3349
3466
  const next = applyEdits(text, edits);
3350
- mkdirSync4(dirname10(path), { recursive: true });
3467
+ mkdirSync5(dirname11(path), { recursive: true });
3351
3468
  backupOnce(path);
3352
3469
  writeFileSync3(path, next.endsWith("\n") ? next : `${next}
3353
3470
  `);
@@ -3364,11 +3481,14 @@ function setOrDelete(obj, key, arr) {
3364
3481
  else delete obj[key];
3365
3482
  }
3366
3483
  var cmdHook = (dist, file, timeout) => ({
3367
- hooks: [{ type: "command", command: `node "${join16(dist, file)}"`, timeout }]
3484
+ hooks: [{ type: "command", command: `node "${join17(dist, file)}"`, timeout }]
3485
+ });
3486
+ var processHook = (dist, file, timeoutMs) => ({
3487
+ hooks: [{ type: "process", command: "node", args: [join17(dist, file)], timeoutMs }]
3368
3488
  });
3369
3489
  var mcpServerEntry = (dist, harness) => ({
3370
3490
  command: "node",
3371
- args: [join16(dist, "mcp-server.js")],
3491
+ args: [join17(dist, "mcp-server.js")],
3372
3492
  env: { HINDSIGHT_MCP_HARNESS: harness }
3373
3493
  });
3374
3494
  function isOurMcpEntry(entry) {
@@ -3386,8 +3506,8 @@ function mergeHarnessHooks(hooks, harness, dist) {
3386
3506
  for (const hook of [...Object.values(spec.install), ...spec.additionalHooks ?? []]) {
3387
3507
  if (installedEvents.has(hook.event)) continue;
3388
3508
  installedEvents.add(hook.event);
3389
- const entry = spec.configStyle === "nested" ? cmdHook(dist, hook.entry, hook.timeout) : {
3390
- command: `node "${join16(dist, hook.entry)}"`,
3509
+ const entry = spec.configStyle === "nested" ? cmdHook(dist, hook.entry, hook.timeout) : spec.configStyle === "process" ? processHook(dist, hook.entry, hook.timeout) : {
3510
+ command: `node "${join17(dist, hook.entry)}"`,
3391
3511
  ...hook.timeout ? { timeout: hook.timeout } : {}
3392
3512
  };
3393
3513
  hooks[hook.event] = mergeHookEvent(hooks[hook.event], entry);
@@ -3405,19 +3525,19 @@ function stripHarnessHooks(hooks, harness) {
3405
3525
  function skillsBaseFor(c, harness) {
3406
3526
  const parts = SKILL_DIRS[harness];
3407
3527
  if (!parts) throw new Error(`${harness} installs a skill but names no directory in SKILL_DIRS`);
3408
- return join16(c.home, ...parts);
3528
+ return join17(c.home, ...parts);
3409
3529
  }
3410
3530
  function installSkill(c, harness) {
3411
- const src = join16(c.pkgRoot, "skill");
3412
- if (!existsSync10(join16(src, "SKILL.md"))) return;
3531
+ const src = join17(c.pkgRoot, "skill");
3532
+ if (!existsSync10(join17(src, "SKILL.md"))) return;
3413
3533
  const skillsBase = skillsBaseFor(c, harness);
3414
- const dst = join16(skillsBase, "hindsight-coding-agent");
3415
- mkdirSync4(skillsBase, { recursive: true });
3534
+ const dst = join17(skillsBase, "hindsight-coding-agent");
3535
+ mkdirSync5(skillsBase, { recursive: true });
3416
3536
  cpSync2(src, dst, { recursive: true });
3417
3537
  c.log?.(`${harness}: skill installed at ${dst}`);
3418
3538
  }
3419
3539
  function uninstallSkill(c, harness) {
3420
- rmSync2(join16(skillsBaseFor(c, harness), "hindsight-coding-agent"), {
3540
+ rmSync2(join17(skillsBaseFor(c, harness), "hindsight-coding-agent"), {
3421
3541
  recursive: true,
3422
3542
  force: true
3423
3543
  });
@@ -3440,9 +3560,9 @@ function runClinePlugin(args) {
3440
3560
  }
3441
3561
  var OPENCODE_CONFIG_CANDIDATES = ["opencode.jsonc", "opencode.json"];
3442
3562
  function opencodeConfigPath(c) {
3443
- const dir = join16(c.home, ".config", "opencode");
3444
- const existing = OPENCODE_CONFIG_CANDIDATES.map((f) => join16(dir, f)).find((p) => existsSync10(p));
3445
- return existing ?? join16(dir, "opencode.json");
3563
+ const dir = join17(c.home, ".config", "opencode");
3564
+ const existing = OPENCODE_CONFIG_CANDIDATES.map((f) => join17(dir, f)).find((p) => existsSync10(p));
3565
+ return existing ?? join17(dir, "opencode.json");
3446
3566
  }
3447
3567
  function runDcodePlugin(args) {
3448
3568
  try {
@@ -3456,7 +3576,7 @@ function registerOpencodePlugin(c, name) {
3456
3576
  const path = opencodeConfigPath(c);
3457
3577
  let cfg = {};
3458
3578
  if (existsSync10(path)) {
3459
- const parsed = parseJsonc(readFileSync12(path, "utf8"));
3579
+ const parsed = parseJsonc(readFileSync14(path, "utf8"));
3460
3580
  if (!parsed) {
3461
3581
  c.log?.(`${name}: SKIPPED \u2014 could not parse ${path}; add the plugin entry manually`);
3462
3582
  return;
@@ -3470,7 +3590,7 @@ function registerOpencodePlugin(c, name) {
3470
3590
  function unregisterOpencodePlugin(c, name) {
3471
3591
  const path = opencodeConfigPath(c);
3472
3592
  if (!existsSync10(path)) return;
3473
- const cfg = parseJsonc(readFileSync12(path, "utf8"));
3593
+ const cfg = parseJsonc(readFileSync14(path, "utf8"));
3474
3594
  if (!cfg || !Array.isArray(cfg.plugin)) return;
3475
3595
  const kept = cfg.plugin.filter((p) => !String(p).includes(MARKER));
3476
3596
  writeJsonc(path, "plugin", kept.length ? kept : void 0);
@@ -3478,7 +3598,7 @@ function unregisterOpencodePlugin(c, name) {
3478
3598
  }
3479
3599
  var opencode = {
3480
3600
  name: "opencode",
3481
- detect: (c) => onPath2("opencode") || existsSync10(join16(c.home, ".config", "opencode")),
3601
+ detect: (c) => onPath2("opencode") || existsSync10(join17(c.home, ".config", "opencode")),
3482
3602
  install: (c) => registerOpencodePlugin(c, "opencode"),
3483
3603
  uninstall: (c) => unregisterOpencodePlugin(c, "opencode")
3484
3604
  };
@@ -3489,16 +3609,16 @@ var opencode2 = {
3489
3609
  uninstall: (c) => unregisterOpencodePlugin(c, "opencode2")
3490
3610
  };
3491
3611
  function piFamilyInstaller(harness, configDir) {
3492
- const settings = (c) => join16(c.home, ...configDir, "settings.json");
3612
+ const settings = (c) => join17(c.home, ...configDir, "settings.json");
3493
3613
  return {
3494
3614
  name: harness,
3495
3615
  // Both hosts name their executable exactly as we name the harness, so the harness id doubles
3496
3616
  // as the PATH probe here — unlike, say, antigravity-cli, whose binary is `agy`.
3497
- detect: (c) => onPath2(harness) || existsSync10(join16(c.home, ...configDir)),
3617
+ detect: (c) => onPath2(harness) || existsSync10(join17(c.home, ...configDir)),
3498
3618
  install(c) {
3499
3619
  const path = settings(c);
3500
3620
  const cfg = readJson(path);
3501
- const entry = join16(c.pkgRoot, "dist", `${harness}.js`);
3621
+ const entry = join17(c.pkgRoot, "dist", `${harness}.js`);
3502
3622
  const exts = Array.isArray(cfg.extensions) ? cfg.extensions : [];
3503
3623
  cfg.extensions = [...exts.filter((p) => !String(p).includes(MARKER)), entry];
3504
3624
  writeJson(path, cfg);
@@ -3523,25 +3643,25 @@ var pi = piFamilyInstaller("pi", [".pi", "agent"]);
3523
3643
  var primeAgent = piFamilyInstaller("prime-agent", [".prime", "agent"]);
3524
3644
  var KILO_CONFIG_CANDIDATES = ["kilo.jsonc", "kilo.json", "opencode.json"];
3525
3645
  function kiloConfigPath(c) {
3526
- const dir = join16(c.home, ".config", "kilo");
3527
- const existing = KILO_CONFIG_CANDIDATES.map((f) => join16(dir, f)).find((p) => existsSync10(p));
3528
- return existing ?? join16(dir, "kilo.json");
3646
+ const dir = join17(c.home, ".config", "kilo");
3647
+ const existing = KILO_CONFIG_CANDIDATES.map((f) => join17(dir, f)).find((p) => existsSync10(p));
3648
+ return existing ?? join17(dir, "kilo.json");
3529
3649
  }
3530
3650
  var kilo = {
3531
3651
  name: "kilo",
3532
- detect: (c) => onPath2("kilo") || existsSync10(join16(c.home, ".config", "kilo")),
3652
+ detect: (c) => onPath2("kilo") || existsSync10(join17(c.home, ".config", "kilo")),
3533
3653
  install(c) {
3534
3654
  const path = kiloConfigPath(c);
3535
3655
  let cfg = {};
3536
3656
  if (existsSync10(path)) {
3537
- const parsed = parseJsonc(readFileSync12(path, "utf8"));
3657
+ const parsed = parseJsonc(readFileSync14(path, "utf8"));
3538
3658
  if (!parsed) {
3539
3659
  c.log?.(`kilo: SKIPPED \u2014 could not parse ${path}; add the plugin entry manually`);
3540
3660
  return;
3541
3661
  }
3542
3662
  cfg = parsed;
3543
3663
  }
3544
- const entry = pathToFileURL(join16(c.dist, "kilo.js")).href;
3664
+ const entry = pathToFileURL(join17(c.dist, "kilo.js")).href;
3545
3665
  const plugins = Array.isArray(cfg.plugin) ? cfg.plugin : [];
3546
3666
  writeJsonc(path, "plugin", [...plugins.filter((p) => !String(p).includes(MARKER)), entry]);
3547
3667
  c.log?.(`kilo: plugin registered in ${path}`);
@@ -3549,7 +3669,7 @@ var kilo = {
3549
3669
  uninstall(c) {
3550
3670
  const path = kiloConfigPath(c);
3551
3671
  if (!existsSync10(path)) return;
3552
- const cfg = parseJsonc(readFileSync12(path, "utf8"));
3672
+ const cfg = parseJsonc(readFileSync14(path, "utf8"));
3553
3673
  if (!cfg || !Array.isArray(cfg.plugin)) return;
3554
3674
  const kept = cfg.plugin.filter((p) => !String(p).includes(MARKER));
3555
3675
  writeJsonc(path, "plugin", kept.length ? kept : void 0);
@@ -3558,9 +3678,9 @@ var kilo = {
3558
3678
  };
3559
3679
  var claudeCode = {
3560
3680
  name: "claude-code",
3561
- detect: (c) => onPath2("claude") || existsSync10(join16(c.home, ".claude")),
3681
+ detect: (c) => onPath2("claude") || existsSync10(join17(c.home, ".claude")),
3562
3682
  install(c) {
3563
- const path = join16(c.home, ".claude", "settings.json");
3683
+ const path = join17(c.home, ".claude", "settings.json");
3564
3684
  const settings = readJson(path);
3565
3685
  settings.hooks = settings.hooks ?? {};
3566
3686
  mergeHarnessHooks(settings.hooks, "claude-code", c.dist);
@@ -3579,18 +3699,18 @@ var claudeCode = {
3579
3699
  "HINDSIGHT_MCP_HARNESS=claude-code",
3580
3700
  "--",
3581
3701
  "node",
3582
- join16(c.dist, "mcp-server.js")
3702
+ join17(c.dist, "mcp-server.js")
3583
3703
  ])) {
3584
3704
  c.log?.("claude-code: MCP server registered (claude mcp add, user scope)");
3585
3705
  } else {
3586
3706
  c.log?.(
3587
3707
  `claude-code: could not run \`claude mcp add\` \u2014 register the tools manually:
3588
- claude mcp add --scope user hindsight --env HINDSIGHT_MCP_HARNESS=claude-code -- node "${join16(c.dist, "mcp-server.js")}"`
3708
+ claude mcp add --scope user hindsight --env HINDSIGHT_MCP_HARNESS=claude-code -- node "${join17(c.dist, "mcp-server.js")}"`
3589
3709
  );
3590
3710
  }
3591
3711
  },
3592
3712
  uninstall(c) {
3593
- const path = join16(c.home, ".claude", "settings.json");
3713
+ const path = join17(c.home, ".claude", "settings.json");
3594
3714
  if (existsSync10(path)) {
3595
3715
  const settings = readJson(path);
3596
3716
  if (settings.hooks) {
@@ -3616,20 +3736,20 @@ function defaultClaudeMcp(args) {
3616
3736
  var CODEX_MCP_BLOCK_RE = /^\[mcp_servers\.hindsight(?:\.[^\]]+)?\][^\n]*\n(?:(?!\[)[^\n]*\n?)*/gm;
3617
3737
  var codexMcpBlock = (dist) => `[mcp_servers.hindsight]
3618
3738
  command = "node"
3619
- args = [${JSON.stringify(join16(dist, "mcp-server.js"))}]
3739
+ args = [${JSON.stringify(join17(dist, "mcp-server.js"))}]
3620
3740
  env = { HINDSIGHT_MCP_HARNESS = "codex" }`;
3621
3741
  var codex = {
3622
3742
  name: "codex",
3623
- detect: (c) => onPath2("codex") || existsSync10(join16(c.home, ".codex")),
3743
+ detect: (c) => onPath2("codex") || existsSync10(join17(c.home, ".codex")),
3624
3744
  install(c) {
3625
- const hooksPath = join16(c.home, ".codex", "hooks.json");
3745
+ const hooksPath = join17(c.home, ".codex", "hooks.json");
3626
3746
  const cfg = readJson(hooksPath);
3627
3747
  cfg.hooks = cfg.hooks ?? {};
3628
3748
  mergeHarnessHooks(cfg.hooks, "codex", c.dist);
3629
3749
  writeJson(hooksPath, cfg);
3630
3750
  c.log?.(`codex: hooks merged into ${hooksPath}`);
3631
- const tomlPath = join16(c.home, ".codex", "config.toml");
3632
- const existing = existsSync10(tomlPath) ? readFileSync12(tomlPath, "utf8") : "";
3751
+ const tomlPath = join17(c.home, ".codex", "config.toml");
3752
+ const existing = existsSync10(tomlPath) ? readFileSync14(tomlPath, "utf8") : "";
3633
3753
  const toml = existing.replace(CODEX_MCP_BLOCK_RE, "");
3634
3754
  const additions = [];
3635
3755
  if (!/^\s*(codex_hooks|hooks)\s*=/m.test(toml)) {
@@ -3648,14 +3768,14 @@ var codex = {
3648
3768
  if (existsSync10(tomlPath) && !existsSync10(`${tomlPath}.hindsight-backup`)) {
3649
3769
  copyFileSync(tomlPath, `${tomlPath}.hindsight-backup`);
3650
3770
  }
3651
- mkdirSync4(dirname10(tomlPath), { recursive: true });
3771
+ mkdirSync5(dirname11(tomlPath), { recursive: true });
3652
3772
  writeFileSync3(tomlPath, next);
3653
3773
  c.log?.(`codex: wrote ${additions.length} section(s) to ${tomlPath}`);
3654
3774
  }
3655
3775
  installSkill(c, "codex");
3656
3776
  },
3657
3777
  uninstall(c) {
3658
- const hooksPath = join16(c.home, ".codex", "hooks.json");
3778
+ const hooksPath = join17(c.home, ".codex", "hooks.json");
3659
3779
  if (existsSync10(hooksPath)) {
3660
3780
  const cfg = readJson(hooksPath);
3661
3781
  if (cfg.hooks) {
@@ -3664,9 +3784,9 @@ var codex = {
3664
3784
  }
3665
3785
  }
3666
3786
  uninstallSkill(c, "codex");
3667
- const tomlPath = join16(c.home, ".codex", "config.toml");
3787
+ const tomlPath = join17(c.home, ".codex", "config.toml");
3668
3788
  if (existsSync10(tomlPath)) {
3669
- const toml = readFileSync12(tomlPath, "utf8");
3789
+ const toml = readFileSync14(tomlPath, "utf8");
3670
3790
  const cleaned = toml.replace(CODEX_MCP_BLOCK_RE, "");
3671
3791
  if (cleaned !== toml) writeFileSync3(tomlPath, cleaned);
3672
3792
  }
@@ -3682,7 +3802,7 @@ var antigravity = {
3682
3802
  // can consume this integration.
3683
3803
  detect: (c) => onPath2("agy"),
3684
3804
  install(c) {
3685
- const hooksPath = join16(c.home, ".gemini", "config", "hooks.json");
3805
+ const hooksPath = join17(c.home, ".gemini", "config", "hooks.json");
3686
3806
  const hooks = readJson(hooksPath);
3687
3807
  for (const key of Object.keys(hooks)) {
3688
3808
  if (key !== MARKER && key.includes(MARKER)) delete hooks[key];
@@ -3693,26 +3813,26 @@ var antigravity = {
3693
3813
  setOrDelete(hooks, event, stripOurs(hooks[event]));
3694
3814
  }
3695
3815
  writeJson(hooksPath, hooks);
3696
- const mcpPath = join16(c.home, ".gemini", "config", "mcp_config.json");
3816
+ const mcpPath = join17(c.home, ".gemini", "config", "mcp_config.json");
3697
3817
  const mcp = readJson(mcpPath);
3698
3818
  mcp.mcpServers = {
3699
3819
  ...mcp.mcpServers ?? {},
3700
3820
  hindsight: mcpServerEntry(c.dist, "antigravity-cli")
3701
3821
  };
3702
3822
  writeJson(mcpPath, mcp);
3703
- const settingsPath = join16(c.home, ".gemini", "antigravity-cli", "settings.json");
3823
+ const settingsPath = join17(c.home, ".gemini", "antigravity-cli", "settings.json");
3704
3824
  const settings = readJson(settingsPath);
3705
3825
  if (!settings.statusLine) {
3706
3826
  settings.statusLine = {
3707
3827
  type: "command",
3708
- command: `node "${join16(c.dist, "antigravity-statusline.js")}"`
3828
+ command: `node "${join17(c.dist, "antigravity-statusline.js")}"`
3709
3829
  };
3710
3830
  writeJson(settingsPath, settings);
3711
3831
  c.log?.(`antigravity-cli: Hindsight status line enabled in ${settingsPath}`);
3712
3832
  } else if (JSON.stringify(settings.statusLine).includes(MARKER)) {
3713
3833
  settings.statusLine = {
3714
3834
  type: "command",
3715
- command: `node "${join16(c.dist, "antigravity-statusline.js")}"`
3835
+ command: `node "${join17(c.dist, "antigravity-statusline.js")}"`
3716
3836
  };
3717
3837
  writeJson(settingsPath, settings);
3718
3838
  } else {
@@ -3724,7 +3844,7 @@ var antigravity = {
3724
3844
  installSkill(c, "antigravity-cli");
3725
3845
  },
3726
3846
  uninstall(c) {
3727
- const hooksPath = join16(c.home, ".gemini", "config", "hooks.json");
3847
+ const hooksPath = join17(c.home, ".gemini", "config", "hooks.json");
3728
3848
  if (existsSync10(hooksPath)) {
3729
3849
  const hooks = readJson(hooksPath);
3730
3850
  if (hooks[MARKER]) {
@@ -3736,7 +3856,7 @@ var antigravity = {
3736
3856
  }
3737
3857
  writeJson(hooksPath, hooks);
3738
3858
  }
3739
- const mcpPath = join16(c.home, ".gemini", "config", "mcp_config.json");
3859
+ const mcpPath = join17(c.home, ".gemini", "config", "mcp_config.json");
3740
3860
  if (existsSync10(mcpPath)) {
3741
3861
  const mcp = readJson(mcpPath);
3742
3862
  if (mcp.mcpServers?.hindsight) {
@@ -3744,7 +3864,7 @@ var antigravity = {
3744
3864
  writeJson(mcpPath, mcp);
3745
3865
  }
3746
3866
  }
3747
- const settingsPath = join16(c.home, ".gemini", "antigravity-cli", "settings.json");
3867
+ const settingsPath = join17(c.home, ".gemini", "antigravity-cli", "settings.json");
3748
3868
  if (existsSync10(settingsPath)) {
3749
3869
  const settings = readJson(settingsPath);
3750
3870
  if (JSON.stringify(settings.statusLine ?? {}).includes(MARKER)) {
@@ -3772,7 +3892,7 @@ function pathNodeVersion() {
3772
3892
  }
3773
3893
  }
3774
3894
  function runtimeDir(home) {
3775
- return join16(home, ".hindsight", "coding-agents");
3895
+ return join17(home, ".hindsight", "coding-agents");
3776
3896
  }
3777
3897
  var ORIGIN_FILE = ".install-origin.json";
3778
3898
  function stageRuntime(c) {
@@ -3785,25 +3905,25 @@ function stageRuntime(c) {
3785
3905
  }
3786
3906
  };
3787
3907
  if (same(c.pkgRoot, target)) return c;
3788
- if (!existsSync10(join16(c.dist, "installer.js"))) return c;
3908
+ if (!existsSync10(join17(c.dist, "installer.js"))) return c;
3789
3909
  try {
3790
- rmSync2(join16(target, "dist"), { recursive: true, force: true });
3791
- mkdirSync4(target, { recursive: true });
3792
- cpSync2(c.dist, join16(target, "dist"), { recursive: true });
3793
- const skill = join16(c.pkgRoot, "skill");
3794
- if (existsSync10(skill)) cpSync2(skill, join16(target, "skill"), { recursive: true });
3795
- const pkgJson = join16(c.pkgRoot, "package.json");
3796
- if (existsSync10(pkgJson)) copyFileSync(pkgJson, join16(target, "package.json"));
3910
+ rmSync2(join17(target, "dist"), { recursive: true, force: true });
3911
+ mkdirSync5(target, { recursive: true });
3912
+ cpSync2(c.dist, join17(target, "dist"), { recursive: true });
3913
+ const skill = join17(c.pkgRoot, "skill");
3914
+ if (existsSync10(skill)) cpSync2(skill, join17(target, "skill"), { recursive: true });
3915
+ const pkgJson = join17(c.pkgRoot, "package.json");
3916
+ if (existsSync10(pkgJson)) copyFileSync(pkgJson, join17(target, "package.json"));
3797
3917
  for (const resource of ["plugin.json", "hooks", "index.js"]) {
3798
- const source = join16(c.pkgRoot, resource);
3799
- if (existsSync10(source)) cpSync2(source, join16(target, resource), { recursive: true });
3918
+ const source = join17(c.pkgRoot, resource);
3919
+ if (existsSync10(source)) cpSync2(source, join17(target, resource), { recursive: true });
3800
3920
  }
3801
3921
  writeFileSync3(
3802
- join16(target, ORIGIN_FILE),
3922
+ join17(target, ORIGIN_FILE),
3803
3923
  JSON.stringify({ source: c.pkgRoot, stagedAt: (/* @__PURE__ */ new Date()).toISOString() })
3804
3924
  );
3805
3925
  c.log?.(`runtime staged at ${target}`);
3806
- return { ...c, pkgRoot: target, dist: join16(target, "dist") };
3926
+ return { ...c, pkgRoot: target, dist: join17(target, "dist") };
3807
3927
  } catch (error) {
3808
3928
  c.log?.(`could not stage the runtime at ${target}: ${String(error)}`);
3809
3929
  return c;
@@ -3881,7 +4001,7 @@ function configureServer(c, args, installing) {
3881
4001
  c.log?.(`unknown --server "${explicit}" \u2014 expected one of: ${SERVER_MODES.join(", ")}`);
3882
4002
  return false;
3883
4003
  }
3884
- const configPath = process.env.HINDSIGHT_CONFIG || join16(c.home, ...CONFIG_RELATIVE);
4004
+ const configPath = process.env.HINDSIGHT_CONFIG || join17(c.home, ...CONFIG_RELATIVE);
3885
4005
  const existing = readJson(configPath);
3886
4006
  const alreadyConfigured = !!(existing.serverMode || existing.apiUrl);
3887
4007
  let mode = explicit;
@@ -3977,7 +4097,7 @@ function reportDaemonPrereqs(c) {
3977
4097
  }
3978
4098
  var devin = {
3979
4099
  name: "devin-cli",
3980
- detect: (c) => onPath2("devin") || existsSync10(join16(c.home, ".config", "devin")),
4100
+ detect: (c) => onPath2("devin") || existsSync10(join17(c.home, ".config", "devin")),
3981
4101
  // Devin is the ONLY harness whose hooks never hand over a transcript: they carry a session id and
3982
4102
  // nothing else, so retain can only work by reading the CLI's own sessions.db. That makes SQLite
3983
4103
  // support a hard prerequisite here — and one worth checking now, because the alternative is an
@@ -3990,12 +4110,12 @@ var devin = {
3990
4110
  Upgrade to Node 22.5 or newer (24 LTS recommended) and re-run this command.`;
3991
4111
  },
3992
4112
  install(c) {
3993
- const configPath = join16(c.home, ".config", "devin", "config.json");
4113
+ const configPath = join17(c.home, ".config", "devin", "config.json");
3994
4114
  const config = readJson(configPath);
3995
4115
  config.hooks = config.hooks ?? {};
3996
4116
  mergeHarnessHooks(config.hooks, "devin-cli", c.dist);
3997
4117
  writeJson(configPath, config);
3998
- const mcpPath = join16(c.home, ".config", "devin", "mcp_config.json");
4118
+ const mcpPath = join17(c.home, ".config", "devin", "mcp_config.json");
3999
4119
  const mcp = readJson(mcpPath);
4000
4120
  mcp.mcpServers = {
4001
4121
  ...mcp.mcpServers ?? {},
@@ -4005,7 +4125,7 @@ var devin = {
4005
4125
  c.log?.(`devin-cli: hooks merged into ${configPath}, MCP into ${mcpPath}`);
4006
4126
  },
4007
4127
  uninstall(c) {
4008
- const configPath = join16(c.home, ".config", "devin", "config.json");
4128
+ const configPath = join17(c.home, ".config", "devin", "config.json");
4009
4129
  if (existsSync10(configPath)) {
4010
4130
  const config = readJson(configPath);
4011
4131
  if (config.hooks) {
@@ -4014,7 +4134,7 @@ var devin = {
4014
4134
  writeJson(configPath, config);
4015
4135
  }
4016
4136
  }
4017
- const mcpPath = join16(c.home, ".config", "devin", "mcp_config.json");
4137
+ const mcpPath = join17(c.home, ".config", "devin", "mcp_config.json");
4018
4138
  if (existsSync10(mcpPath)) {
4019
4139
  const mcp = readJson(mcpPath);
4020
4140
  if (mcp.mcpServers?.hindsight) {
@@ -4027,14 +4147,14 @@ var devin = {
4027
4147
  };
4028
4148
  var cursor = {
4029
4149
  name: "cursor-cli",
4030
- detect: (c) => onPath2("cursor-agent") || existsSync10(join16(c.home, ".cursor")),
4150
+ detect: (c) => onPath2("cursor-agent") || existsSync10(join17(c.home, ".cursor")),
4031
4151
  install(c) {
4032
- const hooksPath = join16(c.home, ".cursor", "hooks.json");
4152
+ const hooksPath = join17(c.home, ".cursor", "hooks.json");
4033
4153
  const cfg = readJson(hooksPath);
4034
4154
  cfg.hooks = cfg.hooks ?? {};
4035
4155
  mergeHarnessHooks(cfg.hooks, "cursor-cli", c.dist);
4036
4156
  writeJson(hooksPath, cfg);
4037
- const mcpPath = join16(c.home, ".cursor", "mcp.json");
4157
+ const mcpPath = join17(c.home, ".cursor", "mcp.json");
4038
4158
  const mcp = readJson(mcpPath);
4039
4159
  mcp.mcpServers = {
4040
4160
  ...mcp.mcpServers ?? {},
@@ -4045,7 +4165,7 @@ var cursor = {
4045
4165
  installSkill(c, "cursor-cli");
4046
4166
  },
4047
4167
  uninstall(c) {
4048
- const hooksPath = join16(c.home, ".cursor", "hooks.json");
4168
+ const hooksPath = join17(c.home, ".cursor", "hooks.json");
4049
4169
  if (existsSync10(hooksPath)) {
4050
4170
  const cfg = readJson(hooksPath);
4051
4171
  if (cfg.hooks) {
@@ -4054,7 +4174,7 @@ var cursor = {
4054
4174
  writeJson(hooksPath, cfg);
4055
4175
  }
4056
4176
  }
4057
- const mcpPath = join16(c.home, ".cursor", "mcp.json");
4177
+ const mcpPath = join17(c.home, ".cursor", "mcp.json");
4058
4178
  if (existsSync10(mcpPath)) {
4059
4179
  const mcp = readJson(mcpPath);
4060
4180
  if (mcp.mcpServers?.hindsight) {
@@ -4068,13 +4188,13 @@ var cursor = {
4068
4188
  };
4069
4189
  var copilot = {
4070
4190
  name: "copilot-cli",
4071
- detect: (c) => onPath2("copilot") || existsSync10(join16(c.home, ".copilot")),
4191
+ detect: (c) => onPath2("copilot") || existsSync10(join17(c.home, ".copilot")),
4072
4192
  install(c) {
4073
- const hooksPath = join16(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
4193
+ const hooksPath = join17(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
4074
4194
  const hooks = {};
4075
4195
  mergeHarnessHooks(hooks, "copilot-cli", c.dist);
4076
4196
  writeJson(hooksPath, { version: 1, hooks });
4077
- const mcpPath = join16(c.home, ".copilot", "mcp-config.json");
4197
+ const mcpPath = join17(c.home, ".copilot", "mcp-config.json");
4078
4198
  const mcp = readJson(mcpPath);
4079
4199
  mcp.mcpServers = {
4080
4200
  ...mcp.mcpServers ?? {},
@@ -4085,10 +4205,10 @@ var copilot = {
4085
4205
  c.log?.(`copilot-cli: hooks installed at ${hooksPath}, MCP into ${mcpPath}`);
4086
4206
  },
4087
4207
  uninstall(c) {
4088
- rmSync2(join16(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
4208
+ rmSync2(join17(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
4089
4209
  force: true
4090
4210
  });
4091
- const mcpPath = join16(c.home, ".copilot", "mcp-config.json");
4211
+ const mcpPath = join17(c.home, ".copilot", "mcp-config.json");
4092
4212
  if (existsSync10(mcpPath)) {
4093
4213
  const mcp = readJson(mcpPath);
4094
4214
  if (mcp.mcpServers?.hindsight) {
@@ -4105,12 +4225,12 @@ var GROK_MARKER_END = "# HINDSIGHT_CODING_AGENTS_GROK_END";
4105
4225
  var GROK_BLOCK_RE = new RegExp(`\\n?${GROK_MARKER_START}[\\s\\S]*?${GROK_MARKER_END}\\n?`);
4106
4226
  var grok = {
4107
4227
  name: "grok-build",
4108
- detect: (c) => onPath2("grok") || existsSync10(join16(c.home, ".grok")),
4228
+ detect: (c) => onPath2("grok") || existsSync10(join17(c.home, ".grok")),
4109
4229
  install(c) {
4110
- const path = join16(c.home, ".grok", "config.toml");
4111
- const existing = existsSync10(path) ? readFileSync12(path, "utf8") : "";
4230
+ const path = join17(c.home, ".grok", "config.toml");
4231
+ const existing = existsSync10(path) ? readFileSync14(path, "utf8") : "";
4112
4232
  const withoutOurs = existing.replace(GROK_BLOCK_RE, "\n");
4113
- const command = (entry) => JSON.stringify(`node "${join16(c.dist, entry)}"`);
4233
+ const command = (entry) => JSON.stringify(`node "${join17(c.dist, entry)}"`);
4114
4234
  const tomlString = (value) => JSON.stringify(value);
4115
4235
  const block = `
4116
4236
  ${GROK_MARKER_START}
@@ -4134,21 +4254,21 @@ ${GROK_MARKER_START}
4134
4254
 
4135
4255
  [mcp_servers.hindsight]
4136
4256
  command = "node"
4137
- args = [${tomlString(join16(c.dist, "mcp-server.js"))}]
4257
+ args = [${tomlString(join17(c.dist, "mcp-server.js"))}]
4138
4258
  env = { HINDSIGHT_MCP_HARNESS = "grok-build" }
4139
4259
  ${GROK_MARKER_END}
4140
4260
  `;
4141
4261
  if (existsSync10(path) && !existsSync10(`${path}.hindsight-backup`))
4142
4262
  copyFileSync(path, `${path}.hindsight-backup`);
4143
- mkdirSync4(dirname10(path), { recursive: true });
4263
+ mkdirSync5(dirname11(path), { recursive: true });
4144
4264
  writeFileSync3(path, `${withoutOurs.replace(/\n*$/, "\n")}${block}`);
4145
4265
  installSkill(c, "grok-build");
4146
4266
  c.log?.(`grok-build: native hooks + MCP installed in ${path}`);
4147
4267
  },
4148
4268
  uninstall(c) {
4149
- const path = join16(c.home, ".grok", "config.toml");
4269
+ const path = join17(c.home, ".grok", "config.toml");
4150
4270
  if (existsSync10(path)) {
4151
- const existing = readFileSync12(path, "utf8");
4271
+ const existing = readFileSync14(path, "utf8");
4152
4272
  const cleaned = existing.replace(GROK_BLOCK_RE, "\n");
4153
4273
  if (cleaned !== existing) writeFileSync3(path, cleaned);
4154
4274
  }
@@ -4160,17 +4280,17 @@ var CLINE_HOOK_MARKER = "HINDSIGHT_CODING_AGENTS_CLINE";
4160
4280
  var CLINE_OLD_HOOK_EVENTS = ["TaskStart", "UserPromptSubmit", "TaskComplete"];
4161
4281
  var CLINE_PLUGIN_NAME = "@vectorize-io/hindsight-coding-agents";
4162
4282
  function removeLegacyClineHooks(c) {
4163
- const hooksDir = join16(c.home, "Documents", "Cline", "Hooks");
4283
+ const hooksDir = join17(c.home, "Documents", "Cline", "Hooks");
4164
4284
  for (const event of CLINE_OLD_HOOK_EVENTS) {
4165
- const path = join16(hooksDir, event);
4166
- if (existsSync10(path) && readFileSync12(path, "utf8").includes(CLINE_HOOK_MARKER)) {
4285
+ const path = join17(hooksDir, event);
4286
+ if (existsSync10(path) && readFileSync14(path, "utf8").includes(CLINE_HOOK_MARKER)) {
4167
4287
  rmSync2(path, { force: true });
4168
4288
  }
4169
4289
  }
4170
4290
  }
4171
4291
  var cline = {
4172
4292
  name: "cline-cli",
4173
- detect: (c) => onPath2("cline") || existsSync10(join16(c.home, ".cline")),
4293
+ detect: (c) => onPath2("cline") || existsSync10(join17(c.home, ".cline")),
4174
4294
  install(c) {
4175
4295
  removeLegacyClineHooks(c);
4176
4296
  const installed = (c.clinePlugin ?? runClinePlugin)([
@@ -4179,7 +4299,7 @@ var cline = {
4179
4299
  "--force",
4180
4300
  c.pkgRoot
4181
4301
  ]);
4182
- const mcpPath = join16(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
4302
+ const mcpPath = join17(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
4183
4303
  const mcp = readJson(mcpPath);
4184
4304
  mcp.mcpServers = {
4185
4305
  ...mcp.mcpServers ?? {},
@@ -4194,7 +4314,7 @@ var cline = {
4194
4314
  uninstall(c) {
4195
4315
  removeLegacyClineHooks(c);
4196
4316
  (c.clinePlugin ?? runClinePlugin)(["plugin", "uninstall", CLINE_PLUGIN_NAME]);
4197
- const mcpPath = join16(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
4317
+ const mcpPath = join17(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
4198
4318
  if (existsSync10(mcpPath)) {
4199
4319
  const mcp = readJson(mcpPath);
4200
4320
  if (mcp.mcpServers?.hindsight) {
@@ -4208,31 +4328,31 @@ var cline = {
4208
4328
  };
4209
4329
  var DCODE_MARKETPLACE = "hindsight-coding-agents";
4210
4330
  var DCODE_PLUGIN_ID = "hindsight-coding-agents@hindsight-coding-agents";
4211
- var DCODE_MARKETPLACE_RELATIVE_PATH = join16(".agents", "plugins", "marketplace.json");
4331
+ var DCODE_MARKETPLACE_RELATIVE_PATH = join17(".agents", "plugins", "marketplace.json");
4212
4332
  var DCODE_FALLBACK_MARKETPLACE = "hindsight-coding-agents-marketplace.json";
4213
4333
  function prepareDcodeMarketplace(c) {
4214
- const root = join16(c.home, ".hindsight");
4215
- const conventionalPath = join16(root, DCODE_MARKETPLACE_RELATIVE_PATH);
4334
+ const root = join17(c.home, ".hindsight");
4335
+ const conventionalPath = join17(root, DCODE_MARKETPLACE_RELATIVE_PATH);
4216
4336
  let path = conventionalPath;
4217
4337
  let registrationSource = root;
4218
4338
  let marketplace = { plugins: [] };
4219
4339
  if (existsSync10(conventionalPath)) {
4220
4340
  try {
4221
- const parsed = JSON.parse(readFileSync12(conventionalPath, "utf8"));
4341
+ const parsed = JSON.parse(readFileSync14(conventionalPath, "utf8"));
4222
4342
  if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.plugins)) {
4223
- path = join16(root, DCODE_FALLBACK_MARKETPLACE);
4343
+ path = join17(root, DCODE_FALLBACK_MARKETPLACE);
4224
4344
  } else if (typeof parsed.name === "string" && parsed.name !== DCODE_MARKETPLACE) {
4225
- path = join16(root, DCODE_FALLBACK_MARKETPLACE);
4345
+ path = join17(root, DCODE_FALLBACK_MARKETPLACE);
4226
4346
  } else {
4227
4347
  marketplace = parsed;
4228
4348
  }
4229
4349
  } catch {
4230
- path = join16(root, DCODE_FALLBACK_MARKETPLACE);
4350
+ path = join17(root, DCODE_FALLBACK_MARKETPLACE);
4231
4351
  }
4232
4352
  }
4233
4353
  if (path !== conventionalPath && existsSync10(path)) {
4234
4354
  try {
4235
- const parsed = JSON.parse(readFileSync12(path, "utf8"));
4355
+ const parsed = JSON.parse(readFileSync14(path, "utf8"));
4236
4356
  if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.plugins) || parsed.name !== DCODE_MARKETPLACE) {
4237
4357
  c.log?.(`dcode: refusing to replace malformed marketplace file ${path}`);
4238
4358
  return false;
@@ -4260,7 +4380,7 @@ function prepareDcodeMarketplace(c) {
4260
4380
  }
4261
4381
  var dcode = {
4262
4382
  name: "dcode",
4263
- detect: (c) => onPath2("dcode") || existsSync10(join16(c.home, ".deepagents")),
4383
+ detect: (c) => onPath2("dcode") || existsSync10(join17(c.home, ".deepagents")),
4264
4384
  preflight: (c) => c.dcodePlugin || onPath2("dcode") ? void 0 : "the `dcode` CLI is not on PATH",
4265
4385
  install(c) {
4266
4386
  const plugin = c.dcodePlugin ?? runDcodePlugin;
@@ -4269,7 +4389,7 @@ var dcode = {
4269
4389
  if (installed) {
4270
4390
  c.log?.(`dcode: native Agent Plugin installed (${DCODE_PLUGIN_ID})`);
4271
4391
  } else {
4272
- const source = marketplacePath === false ? join16(c.home, ".hindsight") : marketplacePath;
4392
+ const source = marketplacePath === false ? join17(c.home, ".hindsight") : marketplacePath;
4273
4393
  c.log?.(
4274
4394
  `dcode: could not install the native plugin \u2014 run dcode plugin marketplace add "${source}" && dcode plugin install ${DCODE_PLUGIN_ID}`
4275
4395
  );
@@ -4297,16 +4417,16 @@ var DSH_MARKER_START = "# HINDSIGHT_CODING_AGENTS_DSH_START";
4297
4417
  var DSH_MARKER_END = "# HINDSIGHT_CODING_AGENTS_DSH_END";
4298
4418
  var DSH_BLOCK_RE = new RegExp(`\\n?${DSH_MARKER_START}[\\s\\S]*?${DSH_MARKER_END}\\n?`);
4299
4419
  function dshHome(c) {
4300
- return process.env.DSH_HOME || join16(c.home, ".dsh");
4420
+ return process.env.DSH_HOME || join17(c.home, ".dsh");
4301
4421
  }
4302
4422
  var dsh = {
4303
4423
  name: "dsh",
4304
4424
  detect: (c) => onPath2("dsh") || existsSync10(dshHome(c)),
4305
4425
  install(c) {
4306
- const path = join16(dshHome(c), "cordis.patch.yml");
4307
- const existing = existsSync10(path) ? readFileSync12(path, "utf8") : "";
4426
+ const path = join17(dshHome(c), "cordis.patch.yml");
4427
+ const existing = existsSync10(path) ? readFileSync14(path, "utf8") : "";
4308
4428
  const others = existing.replace(DSH_BLOCK_RE, "\n").trim();
4309
- const entry = pathToFileURL(join16(c.dist, "dsh.js")).href;
4429
+ const entry = pathToFileURL(join17(c.dist, "dsh.js")).href;
4310
4430
  const block = `${DSH_MARKER_START}
4311
4431
  - insert:
4312
4432
  - id: hindsight
@@ -4315,7 +4435,7 @@ ${DSH_MARKER_END}
4315
4435
  `;
4316
4436
  if (existsSync10(path) && !existsSync10(`${path}.hindsight-backup`))
4317
4437
  copyFileSync(path, `${path}.hindsight-backup`);
4318
- mkdirSync4(dirname10(path), { recursive: true });
4438
+ mkdirSync5(dirname11(path), { recursive: true });
4319
4439
  writeFileSync3(path, others ? `${others}
4320
4440
 
4321
4441
  ${block}` : block);
@@ -4323,9 +4443,9 @@ ${block}` : block);
4323
4443
  c.log?.(`dsh: plugin registered in ${path} (applies to every dsh profile)`);
4324
4444
  },
4325
4445
  uninstall(c) {
4326
- const path = join16(dshHome(c), "cordis.patch.yml");
4446
+ const path = join17(dshHome(c), "cordis.patch.yml");
4327
4447
  if (existsSync10(path)) {
4328
- const existing = readFileSync12(path, "utf8");
4448
+ const existing = readFileSync14(path, "utf8");
4329
4449
  const others = existing.replace(DSH_BLOCK_RE, "\n").trim();
4330
4450
  if (others !== existing.trim()) writeFileSync3(path, others ? `${others}
4331
4451
  ` : "[]\n");
@@ -4336,9 +4456,9 @@ ${block}` : block);
4336
4456
  };
4337
4457
  var qwen = {
4338
4458
  name: "qwen-code",
4339
- detect: (c) => onPath2("qwen") || existsSync10(join16(c.home, ".qwen")),
4459
+ detect: (c) => onPath2("qwen") || existsSync10(join17(c.home, ".qwen")),
4340
4460
  install(c) {
4341
- const path = join16(c.home, ".qwen", "settings.json");
4461
+ const path = join17(c.home, ".qwen", "settings.json");
4342
4462
  const settings = readJson(path);
4343
4463
  settings.hooks = settings.hooks ?? {};
4344
4464
  mergeHarnessHooks(settings.hooks, "qwen-code", c.dist);
@@ -4356,18 +4476,18 @@ var qwen = {
4356
4476
  "HINDSIGHT_MCP_HARNESS=qwen-code",
4357
4477
  "hindsight",
4358
4478
  "node",
4359
- join16(c.dist, "mcp-server.js")
4479
+ join17(c.dist, "mcp-server.js")
4360
4480
  ])) {
4361
4481
  c.log?.("qwen-code: MCP server registered (qwen mcp add, user scope)");
4362
4482
  } else {
4363
4483
  c.log?.(
4364
4484
  `qwen-code: could not run \`qwen mcp add\` \u2014 register the tools manually:
4365
- qwen mcp add -s user -e HINDSIGHT_MCP_HARNESS=qwen-code hindsight node "${join16(c.dist, "mcp-server.js")}"`
4485
+ qwen mcp add -s user -e HINDSIGHT_MCP_HARNESS=qwen-code hindsight node "${join17(c.dist, "mcp-server.js")}"`
4366
4486
  );
4367
4487
  }
4368
4488
  },
4369
4489
  uninstall(c) {
4370
- const path = join16(c.home, ".qwen", "settings.json");
4490
+ const path = join17(c.home, ".qwen", "settings.json");
4371
4491
  if (existsSync10(path)) {
4372
4492
  const settings = readJson(path);
4373
4493
  if (settings.hooks) {
@@ -4392,19 +4512,19 @@ function defaultQwenMcp(args) {
4392
4512
  }
4393
4513
  var factoryDroid = {
4394
4514
  name: "factory-droid",
4395
- detect: (c) => onPath2("droid") || existsSync10(join16(c.home, ".factory")),
4515
+ detect: (c) => onPath2("droid") || existsSync10(join17(c.home, ".factory")),
4396
4516
  preflight(c) {
4397
- const mcpPath = join16(c.home, ".factory", "mcp.json");
4517
+ const mcpPath = join17(c.home, ".factory", "mcp.json");
4398
4518
  const existing = readJson(mcpPath).mcpServers?.hindsight;
4399
4519
  if (existing && !isOurMcpEntry(existing)) {
4400
4520
  return `${mcpPath} already contains a user-managed MCP server named "hindsight". Rename or remove that entry, then re-run install.`;
4401
4521
  }
4402
4522
  },
4403
4523
  install(c) {
4404
- const hooksPath = join16(c.home, ".factory", "hooks.json");
4524
+ const hooksPath = join17(c.home, ".factory", "hooks.json");
4405
4525
  const hooks = readJson(hooksPath);
4406
4526
  if (!existsSync10(hooksPath)) {
4407
- const fallback = readJson(join16(c.home, ".factory", "settings.json")).hooks;
4527
+ const fallback = readJson(join17(c.home, ".factory", "settings.json")).hooks;
4408
4528
  if (fallback && typeof fallback === "object" && !Array.isArray(fallback)) {
4409
4529
  Object.assign(hooks, fallback);
4410
4530
  }
@@ -4413,7 +4533,7 @@ var factoryDroid = {
4413
4533
  writeJson(hooksPath, hooks);
4414
4534
  c.log?.(`factory-droid: hooks merged into ${hooksPath}`);
4415
4535
  installSkill(c, "factory-droid");
4416
- const mcpPath = join16(c.home, ".factory", "mcp.json");
4536
+ const mcpPath = join17(c.home, ".factory", "mcp.json");
4417
4537
  const mcp = readJson(mcpPath);
4418
4538
  mcp.mcpServers = mcp.mcpServers ?? {};
4419
4539
  mcp.mcpServers.hindsight = mcpServerEntry(c.dist, "factory-droid");
@@ -4421,14 +4541,14 @@ var factoryDroid = {
4421
4541
  c.log?.(`factory-droid: MCP server registered in ${mcpPath}`);
4422
4542
  },
4423
4543
  uninstall(c) {
4424
- const hooksPath = join16(c.home, ".factory", "hooks.json");
4544
+ const hooksPath = join17(c.home, ".factory", "hooks.json");
4425
4545
  if (existsSync10(hooksPath)) {
4426
4546
  const hooks = readJson(hooksPath);
4427
4547
  stripHarnessHooks(hooks, "factory-droid");
4428
4548
  if (Object.keys(hooks).length) writeJson(hooksPath, hooks);
4429
4549
  else rmSync2(hooksPath);
4430
4550
  }
4431
- const mcpPath = join16(c.home, ".factory", "mcp.json");
4551
+ const mcpPath = join17(c.home, ".factory", "mcp.json");
4432
4552
  if (existsSync10(mcpPath)) {
4433
4553
  const mcp = readJson(mcpPath);
4434
4554
  if (isOurMcpEntry(mcp.mcpServers?.hindsight)) {
@@ -4441,6 +4561,50 @@ var factoryDroid = {
4441
4561
  c.log?.("factory-droid: hooks + MCP registration + skill removed");
4442
4562
  }
4443
4563
  };
4564
+ var zcode = {
4565
+ name: "zcode",
4566
+ detect: (c) => onPath2("zcode") || existsSync10(join17(c.home, ".zcode")),
4567
+ preflight(c) {
4568
+ const configPath = zcodeConfigPath(c);
4569
+ const existing = readJson(configPath).mcp?.servers?.hindsight;
4570
+ if (existing && !isOurMcpEntry(existing)) {
4571
+ return `${configPath} already contains a user-managed MCP server named "hindsight". Rename or remove that entry, then re-run install.`;
4572
+ }
4573
+ },
4574
+ install(c) {
4575
+ const configPath = zcodeConfigPath(c);
4576
+ const config = readJson(configPath);
4577
+ const hooks = config.hooks = config.hooks ?? {};
4578
+ hooks.enabled = true;
4579
+ hooks.maxOutputBytes = hooks.maxOutputBytes ?? ZCODE_MAX_OUTPUT_BYTES;
4580
+ hooks.events = hooks.events ?? {};
4581
+ mergeHarnessHooks(hooks.events, "zcode", c.dist);
4582
+ config.mcp = config.mcp ?? {};
4583
+ config.mcp.servers = config.mcp.servers ?? {};
4584
+ config.mcp.servers.hindsight = mcpServerEntry(c.dist, "zcode");
4585
+ writeJson(configPath, config);
4586
+ c.log?.(`zcode: hooks + MCP server merged into ${configPath}`);
4587
+ installSkill(c, "zcode");
4588
+ },
4589
+ uninstall(c) {
4590
+ const configPath = zcodeConfigPath(c);
4591
+ if (existsSync10(configPath)) {
4592
+ const config = readJson(configPath);
4593
+ if (isOurMcpEntry(config.mcp?.servers?.hindsight)) {
4594
+ delete config.mcp.servers.hindsight;
4595
+ if (!Object.keys(config.mcp.servers).length) delete config.mcp;
4596
+ }
4597
+ const hooks = config.hooks;
4598
+ if (hooks?.events) {
4599
+ stripHarnessHooks(hooks.events, "zcode");
4600
+ if (!Object.keys(hooks.events).length) delete config.hooks;
4601
+ }
4602
+ writeJson(configPath, config);
4603
+ }
4604
+ uninstallSkill(c, "zcode");
4605
+ c.log?.(`zcode: hooks + MCP registration + skill removed`);
4606
+ }
4607
+ };
4444
4608
  var INSTALLERS = [
4445
4609
  opencode,
4446
4610
  opencode2,
@@ -4458,7 +4622,8 @@ var INSTALLERS = [
4458
4622
  cline,
4459
4623
  dcode,
4460
4624
  dsh,
4461
- factoryDroid
4625
+ factoryDroid,
4626
+ zcode
4462
4627
  ];
4463
4628
  var HARNESS_ALIASES = { agy: "antigravity-cli" };
4464
4629
  function importConversations(harness, ctx) {
@@ -4478,18 +4643,18 @@ function importConversations(harness, ctx) {
4478
4643
  return;
4479
4644
  }
4480
4645
  const turns = found.sessions.reduce((n, s) => n + s.turns.length, 0);
4481
- const file = join16(mkdtempSync(join16(tmpdir4(), "hindsight-import-")), "conversations.json");
4646
+ const file = join17(mkdtempSync(join17(tmpdir5(), "hindsight-import-")), "conversations.json");
4482
4647
  writeFileSync3(file, JSON.stringify(found.sessions));
4483
4648
  ctx.log?.(
4484
4649
  `${harness}: importing ${found.sessions.length} past sessions (${turns} turns) from ${repo} \u2014 this runs extraction and may take a while`
4485
4650
  );
4486
4651
  try {
4487
- execFileSync6("node", [join16(ctx.dist, "deepen.js"), "--repo", repo, "--conversations", file], {
4652
+ execFileSync6("node", [join17(ctx.dist, "deepen.js"), "--repo", repo, "--conversations", file], {
4488
4653
  stdio: "inherit"
4489
4654
  });
4490
4655
  } catch {
4491
4656
  ctx.log?.(`${harness}: conversation import did not finish \u2014 re-run it any time with:`);
4492
- ctx.log?.(` node "${join16(ctx.dist, "deepen.js")}" --repo "${repo}" --conversations "${file}"`);
4657
+ ctx.log?.(` node "${join17(ctx.dist, "deepen.js")}" --repo "${repo}" --conversations "${file}"`);
4493
4658
  }
4494
4659
  }
4495
4660
  function run(argv, ctxIn) {
@@ -4588,11 +4753,11 @@ var mainPath = process.argv[1] ? (() => {
4588
4753
  })() : void 0;
4589
4754
  var isMain = mainPath && import.meta.url === pathToFileURL(mainPath).href;
4590
4755
  if (isMain || mainPath?.endsWith("installer.js")) {
4591
- const dist = dirname10(fileURLToPath6(import.meta.url));
4592
- const pkgRoot = dirname10(dist);
4756
+ const dist = dirname11(fileURLToPath6(import.meta.url));
4757
+ const pkgRoot = dirname11(dist);
4593
4758
  let version;
4594
4759
  try {
4595
- version = JSON.parse(readFileSync12(join16(pkgRoot, "package.json"), "utf8")).version;
4760
+ version = JSON.parse(readFileSync14(join17(pkgRoot, "package.json"), "utf8")).version;
4596
4761
  } catch {
4597
4762
  version = void 0;
4598
4763
  }