@vectorize-io/hindsight-coding-agents 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/installer.js CHANGED
@@ -1,19 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/installer.ts
4
- import { execFileSync as execFileSync5 } from "child_process";
4
+ import { execFileSync as execFileSync4 } from "child_process";
5
5
  import {
6
6
  copyFileSync,
7
7
  cpSync as cpSync2,
8
- existsSync as existsSync5,
8
+ existsSync as existsSync7,
9
9
  mkdirSync as mkdirSync3,
10
- readFileSync as readFileSync13,
10
+ mkdtempSync,
11
+ readFileSync as readFileSync14,
11
12
  realpathSync,
12
13
  rmSync,
13
14
  writeFileSync as writeFileSync2
14
15
  } from "fs";
15
- import { homedir as homedir7 } from "os";
16
- import { dirname as dirname7, join as join10 } from "path";
16
+ import { homedir as homedir8, tmpdir as tmpdir3 } from "os";
17
+ import { dirname as dirname7, join as join11 } from "path";
17
18
  import { fileURLToPath as fileURLToPath4, pathToFileURL } from "url";
18
19
 
19
20
  // src/core/hook.ts
@@ -44,9 +45,43 @@ import { appendFileSync as appendFileSync2 } from "fs";
44
45
  import { appendFileSync, mkdirSync } from "fs";
45
46
  import { tmpdir } from "os";
46
47
  import { dirname as dirname3, join as join4 } from "path";
48
+ var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
47
49
  var current = ["debug", "info", "warn", "error"].find(
48
50
  (l) => l === process.env.HINDSIGHT_LOG_LEVEL
49
51
  ) ?? "info";
52
+ function logFilePath() {
53
+ return process.env.HINDSIGHT_LOG_FILE || join4(tmpdir(), "hindsight-coding-agent", "plugin.log");
54
+ }
55
+ function write(level, scope, msg, extra) {
56
+ if (WEIGHT[level] < WEIGHT[current]) return;
57
+ try {
58
+ const file = logFilePath();
59
+ mkdirSync(dirname3(file), { recursive: true });
60
+ appendFileSync(
61
+ file,
62
+ `${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
63
+ );
64
+ } catch {
65
+ }
66
+ }
67
+ var log = {
68
+ debug: (scope, msg, extra) => write("debug", scope, msg, extra),
69
+ info: (scope, msg, extra) => write("info", scope, msg, extra),
70
+ warn: (scope, msg, extra) => write("warn", scope, msg, extra),
71
+ error: (scope, msg, extra) => write("error", scope, msg, extra)
72
+ };
73
+
74
+ // src/core/diag.ts
75
+ function diag(harness, event, extra = {}) {
76
+ log.debug(harness, `diag:${event}`, extra);
77
+ try {
78
+ appendFileSync2(
79
+ process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
80
+ JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
81
+ );
82
+ } catch {
83
+ }
84
+ }
50
85
 
51
86
  // src/core/session-cache.ts
52
87
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
@@ -94,6 +129,62 @@ function actionLine(tool, input) {
94
129
  return target ? `${tool} ${target}` : tool;
95
130
  }
96
131
 
132
+ // src/core/transcript.ts
133
+ function renderLine(content, type) {
134
+ if (typeof content === "string") {
135
+ const text = stripInjectedMemory(content).trim();
136
+ return text ? [{ role: type, content: text }] : [];
137
+ }
138
+ if (!Array.isArray(content)) return [];
139
+ const texts = [];
140
+ const actions = [];
141
+ for (const b of content) {
142
+ if (!b || typeof b !== "object") continue;
143
+ if (b.type === "text" && typeof b.text === "string") {
144
+ const t = stripInjectedMemory(b.text).trim();
145
+ if (t) texts.push(t);
146
+ } else if (b.type === "tool_use" && typeof b.name === "string") {
147
+ actions.push({ role: "action", content: actionLine(b.name, b.input) });
148
+ }
149
+ }
150
+ const out = [];
151
+ const joined = texts.join("\n").trim();
152
+ if (joined) out.push({ role: type, content: joined });
153
+ out.push(...actions);
154
+ return out;
155
+ }
156
+ function readClaudeTranscript(path) {
157
+ let raw;
158
+ try {
159
+ raw = readFileSync4(path, "utf8");
160
+ } catch {
161
+ return [];
162
+ }
163
+ const turns = [];
164
+ for (const rawLine of raw.split("\n")) {
165
+ const trimmed = rawLine.trim();
166
+ if (!trimmed) continue;
167
+ let parsed;
168
+ try {
169
+ parsed = JSON.parse(trimmed);
170
+ } catch {
171
+ continue;
172
+ }
173
+ if (typeof parsed !== "object" || parsed === null) continue;
174
+ const line = parsed;
175
+ if (line.type !== "user" && line.type !== "assistant") continue;
176
+ if (line.isMeta === true) continue;
177
+ if (line.isSidechain === true) continue;
178
+ if (typeof line.message !== "object" || line.message === null) continue;
179
+ for (const rendered of renderLine(line.message.content, line.type)) {
180
+ const turn = { role: rendered.role, content: rendered.content };
181
+ if (typeof line.timestamp === "string") turn.timestamp = line.timestamp;
182
+ turns.push(turn);
183
+ }
184
+ }
185
+ return turns;
186
+ }
187
+
97
188
  // src/core/session-start.ts
98
189
  import { readFileSync as readFileSync7 } from "fs";
99
190
 
@@ -328,10 +419,13 @@ function readGrokTranscript(path) {
328
419
  }
329
420
 
330
421
  // src/core/transcript-devin.ts
331
- import { execFileSync as execFileSync4 } from "child_process";
422
+ import { existsSync as existsSync5 } from "fs";
423
+ import { createRequire } from "module";
332
424
  import { homedir as homedir6 } from "os";
333
425
  import { join as join9 } from "path";
334
- var sessionDb = join9(homedir6(), ".local", "share", "devin", "cli", "sessions.db");
426
+ function devinSessionDb(home = homedir6()) {
427
+ return join9(home, ".local", "share", "devin", "cli", "sessions.db");
428
+ }
335
429
  function parseDevinMessages(nodes) {
336
430
  const messages = /* @__PURE__ */ new Map();
337
431
  for (const node of nodes) {
@@ -352,23 +446,41 @@ function parseDevinMessages(nodes) {
352
446
  }
353
447
  return [...messages.values()].sort((a, b) => a.index - b.index).map(({ role, content }) => ({ role, content }));
354
448
  }
355
- function readDevinTranscript(sessionId) {
356
- if (!sessionId) return [];
449
+ var requireBuiltin = createRequire(import.meta.url);
450
+ function loadSqlite() {
357
451
  try {
358
- const quotedId = sessionId.replace(/'/g, "''");
359
- const raw = execFileSync4(
360
- "sqlite3",
361
- [
362
- "-json",
363
- sessionDb,
364
- `SELECT node_id, chat_message FROM message_nodes WHERE session_id = '${quotedId}' ORDER BY node_id`
365
- ],
366
- { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 2e3 }
367
- );
368
- return parseDevinMessages(JSON.parse(raw));
452
+ return requireBuiltin("node:sqlite").DatabaseSync;
369
453
  } catch {
454
+ return void 0;
455
+ }
456
+ }
457
+ function readDevinTranscript(sessionId, dbPath = devinSessionDb()) {
458
+ if (!sessionId) return [];
459
+ const Database = loadSqlite();
460
+ if (!Database) {
461
+ diag("devin-cli", "sqlite_unavailable", { node: process.version, dbPath });
370
462
  return [];
371
463
  }
464
+ if (!existsSync5(dbPath)) {
465
+ diag("devin-cli", "session_db_missing", { dbPath });
466
+ return [];
467
+ }
468
+ let db;
469
+ try {
470
+ db = new Database(dbPath, { readOnly: true });
471
+ const rows = db.prepare(
472
+ "SELECT node_id, chat_message FROM message_nodes WHERE session_id = ? ORDER BY node_id"
473
+ ).all(sessionId);
474
+ return parseDevinMessages(rows);
475
+ } catch (error) {
476
+ diag("devin-cli", "session_db_read_failed", { dbPath, error: String(error) });
477
+ return [];
478
+ } finally {
479
+ try {
480
+ db?.close();
481
+ } catch {
482
+ }
483
+ }
372
484
  }
373
485
 
374
486
  // src/harness/hook-lifecycle.ts
@@ -654,11 +766,141 @@ var HOOK_HARNESSES = {
654
766
  }
655
767
  };
656
768
 
769
+ // src/core/history.ts
770
+ import {
771
+ closeSync,
772
+ existsSync as existsSync6,
773
+ openSync,
774
+ readdirSync as readdirSync2,
775
+ readFileSync as readFileSync13,
776
+ readSync,
777
+ statSync
778
+ } from "fs";
779
+ import { homedir as homedir7 } from "os";
780
+ import { join as join10 } from "path";
781
+ function claudeProjectDir(repoDir, home = homedir7()) {
782
+ return join10(home, ".claude", "projects", repoDir.replace(/[/.]/g, "-"));
783
+ }
784
+ function withinRepo(dir, repoDir) {
785
+ return !!dir && (dir === repoDir || dir.startsWith(repoDir.endsWith("/") ? repoDir : repoDir + "/"));
786
+ }
787
+ function claudeSessionCwd(file) {
788
+ try {
789
+ for (const line of readFileSync13(file, "utf8").split("\n", 400)) {
790
+ if (!line.includes('"cwd"')) continue;
791
+ const cwd = JSON.parse(line).cwd;
792
+ if (cwd) return cwd;
793
+ }
794
+ } catch {
795
+ }
796
+ return void 0;
797
+ }
798
+ function toSession(id, turns) {
799
+ const prose = turns.filter((t) => t.role === "user" || t.role === "assistant").map((t) => ({
800
+ role: t.role,
801
+ text: t.content,
802
+ ...t.timestamp ? { timestamp: t.timestamp } : {}
803
+ }));
804
+ return prose.length ? { id, turns: prose } : void 0;
805
+ }
806
+ function firstLine(path, cap = 1e6) {
807
+ const fd = openSync(path, "r");
808
+ try {
809
+ const chunk = Buffer.alloc(64 * 1024);
810
+ let acc = "";
811
+ while (acc.length < cap) {
812
+ const n = readSync(fd, chunk, 0, chunk.length, null);
813
+ if (n <= 0) break;
814
+ acc += chunk.subarray(0, n).toString("utf8");
815
+ const nl = acc.indexOf("\n");
816
+ if (nl !== -1) return acc.slice(0, nl);
817
+ }
818
+ return acc.length && acc.length < cap ? acc : void 0;
819
+ } finally {
820
+ closeSync(fd);
821
+ }
822
+ }
823
+ function jsonlFiles(dir) {
824
+ if (!existsSync6(dir)) return [];
825
+ return readdirSync2(dir).filter((f) => f.endsWith(".jsonl")).map((f) => join10(dir, f));
826
+ }
827
+ function claudeHistory(repoDir, home) {
828
+ const root = join10(home, ".claude", "projects");
829
+ const exact = claudeProjectDir(repoDir, home);
830
+ const prefix = exact + "-";
831
+ const dirs = existsSync6(root) ? readdirSync2(root).map((d) => join10(root, d)).filter((d) => d === exact || d.startsWith(prefix)) : [];
832
+ const sessions = [];
833
+ let unattributed = 0;
834
+ for (const file of dirs.flatMap(jsonlFiles)) {
835
+ const cwd = claudeSessionCwd(file);
836
+ if (!cwd) {
837
+ unattributed++;
838
+ continue;
839
+ }
840
+ if (!withinRepo(cwd, repoDir)) continue;
841
+ try {
842
+ const id = file.split("/").pop().replace(/\.jsonl$/, "");
843
+ const s = toSession(id, readClaudeTranscript(file));
844
+ if (s) sessions.push(s);
845
+ } catch {
846
+ }
847
+ }
848
+ return { supported: true, sessions, unattributed };
849
+ }
850
+ function codexHistory(repoDir, home) {
851
+ const root = join10(home, ".codex", "sessions");
852
+ if (!existsSync6(root)) return { supported: true, sessions: [] };
853
+ const files = [];
854
+ const walk = (dir) => {
855
+ for (const entry of readdirSync2(dir)) {
856
+ const p = join10(dir, entry);
857
+ if (statSync(p).isDirectory()) walk(p);
858
+ else if (entry.endsWith(".jsonl")) files.push(p);
859
+ }
860
+ };
861
+ try {
862
+ walk(root);
863
+ } catch {
864
+ return { supported: true, sessions: [] };
865
+ }
866
+ const sessions = [];
867
+ for (const file of files) {
868
+ try {
869
+ const head = firstLine(file);
870
+ if (!head) continue;
871
+ const meta = JSON.parse(head);
872
+ if (!withinRepo(meta?.payload?.cwd, repoDir)) continue;
873
+ const s = toSession(meta.payload?.id ?? file, readCodexTranscript(file));
874
+ if (s) sessions.push(s);
875
+ } catch {
876
+ }
877
+ }
878
+ return { supported: true, sessions };
879
+ }
880
+ var SQLITE_HISTORY = "keeps session history in an internal SQLite database, whose schema is unversioned and would break on any upstream change";
881
+ function importLocalHistory(harness, repoDir, home = homedir7()) {
882
+ switch (harness) {
883
+ case "claude-code":
884
+ return claudeHistory(repoDir, home);
885
+ case "codex":
886
+ return codexHistory(repoDir, home);
887
+ case "opencode":
888
+ case "kilo":
889
+ case "cursor-cli":
890
+ case "cline-cli":
891
+ case "copilot-cli":
892
+ case "devin-cli":
893
+ return { supported: false, reason: `${harness} ${SQLITE_HISTORY}`, sessions: [] };
894
+ default:
895
+ return { supported: false, reason: `no local history reader for ${harness}`, sessions: [] };
896
+ }
897
+ }
898
+
657
899
  // src/installer.ts
658
900
  var MARKER = "coding-agents";
659
901
  function readJson(path) {
660
902
  try {
661
- return JSON.parse(readFileSync13(path, "utf8"));
903
+ return JSON.parse(readFileSync14(path, "utf8"));
662
904
  } catch {
663
905
  return {};
664
906
  }
@@ -674,7 +916,7 @@ function parseJsonc(text) {
674
916
  }
675
917
  function writeJson(path, value) {
676
918
  mkdirSync3(dirname7(path), { recursive: true });
677
- if (existsSync5(path) && !existsSync5(`${path}.hindsight-backup`)) {
919
+ if (existsSync7(path) && !existsSync7(`${path}.hindsight-backup`)) {
678
920
  copyFileSync(path, `${path}.hindsight-backup`);
679
921
  }
680
922
  writeFileSync2(path, JSON.stringify(value, null, 2) + "\n");
@@ -691,7 +933,7 @@ function setOrDelete(obj, key, arr) {
691
933
  else delete obj[key];
692
934
  }
693
935
  var cmdHook = (dist, file, timeout) => ({
694
- hooks: [{ type: "command", command: `node "${join10(dist, file)}"`, timeout }]
936
+ hooks: [{ type: "command", command: `node "${join11(dist, file)}"`, timeout }]
695
937
  });
696
938
  function mergeHarnessHooks(hooks, harness, dist) {
697
939
  const spec = HOOK_HARNESSES[harness];
@@ -700,7 +942,7 @@ function mergeHarnessHooks(hooks, harness, dist) {
700
942
  if (installedEvents.has(hook.event)) continue;
701
943
  installedEvents.add(hook.event);
702
944
  const entry = spec.configStyle === "nested" ? cmdHook(dist, hook.entry, hook.timeout) : {
703
- command: `node "${join10(dist, hook.entry)}"`,
945
+ command: `node "${join11(dist, hook.entry)}"`,
704
946
  ...hook.timeout ? { timeout: hook.timeout } : {}
705
947
  };
706
948
  hooks[hook.event] = mergeHookEvent(hooks[hook.event], entry);
@@ -715,19 +957,19 @@ function stripHarnessHooks(hooks, harness) {
715
957
  }
716
958
  }
717
959
  function installSkill(c, skillsBase) {
718
- const src = join10(c.pkgRoot, "skill");
719
- if (!existsSync5(join10(src, "SKILL.md"))) return;
720
- const dst = join10(skillsBase, "hindsight-coding-agent");
960
+ const src = join11(c.pkgRoot, "skill");
961
+ if (!existsSync7(join11(src, "SKILL.md"))) return;
962
+ const dst = join11(skillsBase, "hindsight-coding-agent");
721
963
  mkdirSync3(skillsBase, { recursive: true });
722
964
  cpSync2(src, dst, { recursive: true });
723
965
  c.log?.(`skill installed at ${dst}`);
724
966
  }
725
967
  function uninstallSkill(c, skillsBase) {
726
- rmSync(join10(skillsBase, "hindsight-coding-agent"), { recursive: true, force: true });
968
+ rmSync(join11(skillsBase, "hindsight-coding-agent"), { recursive: true, force: true });
727
969
  }
728
970
  function onPath(bin) {
729
971
  try {
730
- execFileSync5("which", [bin], { stdio: "pipe" });
972
+ execFileSync4("which", [bin], { stdio: "pipe" });
731
973
  return true;
732
974
  } catch {
733
975
  return false;
@@ -735,7 +977,7 @@ function onPath(bin) {
735
977
  }
736
978
  function runClinePlugin(args) {
737
979
  try {
738
- execFileSync5("cline", args, { stdio: "pipe" });
980
+ execFileSync4("cline", args, { stdio: "pipe" });
739
981
  return true;
740
982
  } catch {
741
983
  return false;
@@ -743,9 +985,9 @@ function runClinePlugin(args) {
743
985
  }
744
986
  var opencode = {
745
987
  name: "opencode",
746
- detect: (c) => onPath("opencode") || existsSync5(join10(c.home, ".config", "opencode")),
988
+ detect: (c) => onPath("opencode") || existsSync7(join11(c.home, ".config", "opencode")),
747
989
  install(c) {
748
- const path = join10(c.home, ".config", "opencode", "opencode.json");
990
+ const path = join11(c.home, ".config", "opencode", "opencode.json");
749
991
  const cfg = readJson(path);
750
992
  const plugins = Array.isArray(cfg.plugin) ? cfg.plugin : [];
751
993
  cfg.plugin = [...plugins.filter((p) => !String(p).includes(MARKER)), c.pkgRoot];
@@ -753,8 +995,8 @@ var opencode = {
753
995
  c.log?.(`opencode: plugin registered in ${path}`);
754
996
  },
755
997
  uninstall(c) {
756
- const path = join10(c.home, ".config", "opencode", "opencode.json");
757
- if (!existsSync5(path)) return;
998
+ const path = join11(c.home, ".config", "opencode", "opencode.json");
999
+ if (!existsSync7(path)) return;
758
1000
  const cfg = readJson(path);
759
1001
  if (Array.isArray(cfg.plugin)) {
760
1002
  cfg.plugin = cfg.plugin.filter((p) => !String(p).includes(MARKER));
@@ -766,25 +1008,25 @@ var opencode = {
766
1008
  };
767
1009
  var KILO_CONFIG_CANDIDATES = ["kilo.jsonc", "kilo.json", "opencode.json"];
768
1010
  function kiloConfigPath(c) {
769
- const dir = join10(c.home, ".config", "kilo");
770
- const existing = KILO_CONFIG_CANDIDATES.map((f) => join10(dir, f)).find((p) => existsSync5(p));
771
- return existing ?? join10(dir, "kilo.json");
1011
+ const dir = join11(c.home, ".config", "kilo");
1012
+ const existing = KILO_CONFIG_CANDIDATES.map((f) => join11(dir, f)).find((p) => existsSync7(p));
1013
+ return existing ?? join11(dir, "kilo.json");
772
1014
  }
773
1015
  var kilo = {
774
1016
  name: "kilo",
775
- detect: (c) => onPath("kilo") || existsSync5(join10(c.home, ".config", "kilo")),
1017
+ detect: (c) => onPath("kilo") || existsSync7(join11(c.home, ".config", "kilo")),
776
1018
  install(c) {
777
1019
  const path = kiloConfigPath(c);
778
1020
  let cfg = {};
779
- if (existsSync5(path)) {
780
- const parsed = parseJsonc(readFileSync13(path, "utf8"));
1021
+ if (existsSync7(path)) {
1022
+ const parsed = parseJsonc(readFileSync14(path, "utf8"));
781
1023
  if (!parsed) {
782
1024
  c.log?.(`kilo: SKIPPED \u2014 could not parse ${path}; add the plugin entry manually`);
783
1025
  return;
784
1026
  }
785
1027
  cfg = parsed;
786
1028
  }
787
- const entry = pathToFileURL(join10(c.dist, "kilo.js")).href;
1029
+ const entry = pathToFileURL(join11(c.dist, "kilo.js")).href;
788
1030
  const plugins = Array.isArray(cfg.plugin) ? cfg.plugin : [];
789
1031
  cfg.plugin = [...plugins.filter((p) => !String(p).includes(MARKER)), entry];
790
1032
  writeJson(path, cfg);
@@ -792,8 +1034,8 @@ var kilo = {
792
1034
  },
793
1035
  uninstall(c) {
794
1036
  const path = kiloConfigPath(c);
795
- if (!existsSync5(path)) return;
796
- const cfg = parseJsonc(readFileSync13(path, "utf8"));
1037
+ if (!existsSync7(path)) return;
1038
+ const cfg = parseJsonc(readFileSync14(path, "utf8"));
797
1039
  if (!cfg || !Array.isArray(cfg.plugin)) return;
798
1040
  cfg.plugin = cfg.plugin.filter((p) => !String(p).includes(MARKER));
799
1041
  if (!cfg.plugin.length) delete cfg.plugin;
@@ -803,15 +1045,15 @@ var kilo = {
803
1045
  };
804
1046
  var claudeCode = {
805
1047
  name: "claude-code",
806
- detect: (c) => onPath("claude") || existsSync5(join10(c.home, ".claude")),
1048
+ detect: (c) => onPath("claude") || existsSync7(join11(c.home, ".claude")),
807
1049
  install(c) {
808
- const path = join10(c.home, ".claude", "settings.json");
1050
+ const path = join11(c.home, ".claude", "settings.json");
809
1051
  const settings = readJson(path);
810
1052
  settings.hooks = settings.hooks ?? {};
811
1053
  mergeHarnessHooks(settings.hooks, "claude-code", c.dist);
812
1054
  writeJson(path, settings);
813
1055
  c.log?.(`claude-code: hooks merged into ${path}`);
814
- installSkill(c, join10(c.home, ".claude", "skills"));
1056
+ installSkill(c, join11(c.home, ".claude", "skills"));
815
1057
  const mcp = c.claudeMcp ?? defaultClaudeMcp;
816
1058
  mcp(["mcp", "remove", "--scope", "user", "hindsight"]);
817
1059
  if (mcp([
@@ -822,19 +1064,19 @@ var claudeCode = {
822
1064
  "hindsight",
823
1065
  "--",
824
1066
  "node",
825
- join10(c.dist, "mcp-server.js")
1067
+ join11(c.dist, "mcp-server.js")
826
1068
  ])) {
827
1069
  c.log?.("claude-code: MCP server registered (claude mcp add, user scope)");
828
1070
  } else {
829
1071
  c.log?.(
830
1072
  `claude-code: could not run \`claude mcp add\` \u2014 register the tools manually:
831
- claude mcp add --scope user hindsight -- node "${join10(c.dist, "mcp-server.js")}"`
1073
+ claude mcp add --scope user hindsight -- node "${join11(c.dist, "mcp-server.js")}"`
832
1074
  );
833
1075
  }
834
1076
  },
835
1077
  uninstall(c) {
836
- const path = join10(c.home, ".claude", "settings.json");
837
- if (existsSync5(path)) {
1078
+ const path = join11(c.home, ".claude", "settings.json");
1079
+ if (existsSync7(path)) {
838
1080
  const settings = readJson(path);
839
1081
  if (settings.hooks) {
840
1082
  stripHarnessHooks(settings.hooks, "claude-code");
@@ -844,13 +1086,13 @@ var claudeCode = {
844
1086
  }
845
1087
  const mcp = c.claudeMcp ?? defaultClaudeMcp;
846
1088
  mcp(["mcp", "remove", "--scope", "user", "hindsight"]);
847
- uninstallSkill(c, join10(c.home, ".claude", "skills"));
1089
+ uninstallSkill(c, join11(c.home, ".claude", "skills"));
848
1090
  c.log?.("claude-code: hooks + MCP registration + skill removed");
849
1091
  }
850
1092
  };
851
1093
  function defaultClaudeMcp(args) {
852
1094
  try {
853
- execFileSync5("claude", args, { stdio: "pipe" });
1095
+ execFileSync4("claude", args, { stdio: "pipe" });
854
1096
  return true;
855
1097
  } catch {
856
1098
  return false;
@@ -858,16 +1100,16 @@ function defaultClaudeMcp(args) {
858
1100
  }
859
1101
  var codex = {
860
1102
  name: "codex",
861
- detect: (c) => onPath("codex") || existsSync5(join10(c.home, ".codex")),
1103
+ detect: (c) => onPath("codex") || existsSync7(join11(c.home, ".codex")),
862
1104
  install(c) {
863
- const hooksPath = join10(c.home, ".codex", "hooks.json");
1105
+ const hooksPath = join11(c.home, ".codex", "hooks.json");
864
1106
  const cfg = readJson(hooksPath);
865
1107
  cfg.hooks = cfg.hooks ?? {};
866
1108
  mergeHarnessHooks(cfg.hooks, "codex", c.dist);
867
1109
  writeJson(hooksPath, cfg);
868
1110
  c.log?.(`codex: hooks merged into ${hooksPath}`);
869
- const tomlPath = join10(c.home, ".codex", "config.toml");
870
- let toml = existsSync5(tomlPath) ? readFileSync13(tomlPath, "utf8") : "";
1111
+ const tomlPath = join11(c.home, ".codex", "config.toml");
1112
+ let toml = existsSync7(tomlPath) ? readFileSync14(tomlPath, "utf8") : "";
871
1113
  const additions = [];
872
1114
  if (!/^\s*(codex_hooks|hooks)\s*=/m.test(toml)) {
873
1115
  if (/^\[features\]/m.test(toml)) {
@@ -882,11 +1124,11 @@ var codex = {
882
1124
  additions.push(
883
1125
  `[mcp_servers.hindsight]
884
1126
  command = "node"
885
- args = ["${join10(c.dist, "mcp-server.js")}"]`
1127
+ args = ["${join11(c.dist, "mcp-server.js")}"]`
886
1128
  );
887
1129
  }
888
1130
  if (additions.length) {
889
- if (existsSync5(tomlPath) && !existsSync5(`${tomlPath}.hindsight-backup`)) {
1131
+ if (existsSync7(tomlPath) && !existsSync7(`${tomlPath}.hindsight-backup`)) {
890
1132
  copyFileSync(tomlPath, `${tomlPath}.hindsight-backup`);
891
1133
  }
892
1134
  mkdirSync3(dirname7(tomlPath), { recursive: true });
@@ -894,21 +1136,21 @@ args = ["${join10(c.dist, "mcp-server.js")}"]`
894
1136
  `);
895
1137
  c.log?.(`codex: appended ${additions.length} section(s) to ${tomlPath}`);
896
1138
  }
897
- installSkill(c, join10(c.home, ".agents", "skills"));
1139
+ installSkill(c, join11(c.home, ".agents", "skills"));
898
1140
  },
899
1141
  uninstall(c) {
900
- const hooksPath = join10(c.home, ".codex", "hooks.json");
901
- if (existsSync5(hooksPath)) {
1142
+ const hooksPath = join11(c.home, ".codex", "hooks.json");
1143
+ if (existsSync7(hooksPath)) {
902
1144
  const cfg = readJson(hooksPath);
903
1145
  if (cfg.hooks) {
904
1146
  stripHarnessHooks(cfg.hooks, "codex");
905
1147
  writeJson(hooksPath, cfg);
906
1148
  }
907
1149
  }
908
- uninstallSkill(c, join10(c.home, ".agents", "skills"));
909
- const tomlPath = join10(c.home, ".codex", "config.toml");
910
- if (existsSync5(tomlPath)) {
911
- const toml = readFileSync13(tomlPath, "utf8");
1150
+ uninstallSkill(c, join11(c.home, ".agents", "skills"));
1151
+ const tomlPath = join11(c.home, ".codex", "config.toml");
1152
+ if (existsSync7(tomlPath)) {
1153
+ const toml = readFileSync14(tomlPath, "utf8");
912
1154
  const cleaned = toml.replace(
913
1155
  /\n?\[mcp_servers\.hindsight\]\ncommand = "node"\nargs = \[[^\]]*\]\n?/g,
914
1156
  "\n"
@@ -927,7 +1169,7 @@ var antigravity = {
927
1169
  // can consume this integration.
928
1170
  detect: (c) => onPath("agy"),
929
1171
  install(c) {
930
- const hooksPath = join10(c.home, ".gemini", "config", "hooks.json");
1172
+ const hooksPath = join11(c.home, ".gemini", "config", "hooks.json");
931
1173
  const hooks = readJson(hooksPath);
932
1174
  for (const key of Object.keys(hooks)) {
933
1175
  if (key !== MARKER && key.includes(MARKER)) delete hooks[key];
@@ -938,30 +1180,30 @@ var antigravity = {
938
1180
  setOrDelete(hooks, event, stripOurs(hooks[event]));
939
1181
  }
940
1182
  writeJson(hooksPath, hooks);
941
- const mcpPath = join10(c.home, ".gemini", "config", "mcp_config.json");
1183
+ const mcpPath = join11(c.home, ".gemini", "config", "mcp_config.json");
942
1184
  const mcp = readJson(mcpPath);
943
1185
  mcp.mcpServers = {
944
1186
  ...mcp.mcpServers ?? {},
945
1187
  hindsight: {
946
1188
  command: "node",
947
- args: [join10(c.dist, "mcp-server.js")],
1189
+ args: [join11(c.dist, "mcp-server.js")],
948
1190
  env: { HINDSIGHT_MCP_HARNESS: "antigravity-cli" }
949
1191
  }
950
1192
  };
951
1193
  writeJson(mcpPath, mcp);
952
- const settingsPath = join10(c.home, ".gemini", "antigravity-cli", "settings.json");
1194
+ const settingsPath = join11(c.home, ".gemini", "antigravity-cli", "settings.json");
953
1195
  const settings = readJson(settingsPath);
954
1196
  if (!settings.statusLine) {
955
1197
  settings.statusLine = {
956
1198
  type: "command",
957
- command: `node "${join10(c.dist, "antigravity-statusline.js")}"`
1199
+ command: `node "${join11(c.dist, "antigravity-statusline.js")}"`
958
1200
  };
959
1201
  writeJson(settingsPath, settings);
960
1202
  c.log?.(`antigravity-cli: Hindsight status line enabled in ${settingsPath}`);
961
1203
  } else if (JSON.stringify(settings.statusLine).includes(MARKER)) {
962
1204
  settings.statusLine = {
963
1205
  type: "command",
964
- command: `node "${join10(c.dist, "antigravity-statusline.js")}"`
1206
+ command: `node "${join11(c.dist, "antigravity-statusline.js")}"`
965
1207
  };
966
1208
  writeJson(settingsPath, settings);
967
1209
  } else {
@@ -970,11 +1212,11 @@ var antigravity = {
970
1212
  );
971
1213
  }
972
1214
  c.log?.(`antigravity-cli: hooks merged into ${hooksPath}, MCP into ${mcpPath}`);
973
- installSkill(c, join10(c.home, ".gemini", "config", "skills"));
1215
+ installSkill(c, join11(c.home, ".gemini", "config", "skills"));
974
1216
  },
975
1217
  uninstall(c) {
976
- const hooksPath = join10(c.home, ".gemini", "config", "hooks.json");
977
- if (existsSync5(hooksPath)) {
1218
+ const hooksPath = join11(c.home, ".gemini", "config", "hooks.json");
1219
+ if (existsSync7(hooksPath)) {
978
1220
  const hooks = readJson(hooksPath);
979
1221
  if (hooks[MARKER]) {
980
1222
  stripHarnessHooks(hooks[MARKER], "antigravity-cli");
@@ -985,42 +1227,68 @@ var antigravity = {
985
1227
  }
986
1228
  writeJson(hooksPath, hooks);
987
1229
  }
988
- const mcpPath = join10(c.home, ".gemini", "config", "mcp_config.json");
989
- if (existsSync5(mcpPath)) {
1230
+ const mcpPath = join11(c.home, ".gemini", "config", "mcp_config.json");
1231
+ if (existsSync7(mcpPath)) {
990
1232
  const mcp = readJson(mcpPath);
991
1233
  if (mcp.mcpServers?.hindsight) {
992
1234
  delete mcp.mcpServers.hindsight;
993
1235
  writeJson(mcpPath, mcp);
994
1236
  }
995
1237
  }
996
- const settingsPath = join10(c.home, ".gemini", "antigravity-cli", "settings.json");
997
- if (existsSync5(settingsPath)) {
1238
+ const settingsPath = join11(c.home, ".gemini", "antigravity-cli", "settings.json");
1239
+ if (existsSync7(settingsPath)) {
998
1240
  const settings = readJson(settingsPath);
999
1241
  if (JSON.stringify(settings.statusLine ?? {}).includes(MARKER)) {
1000
1242
  delete settings.statusLine;
1001
1243
  writeJson(settingsPath, settings);
1002
1244
  }
1003
1245
  }
1004
- uninstallSkill(c, join10(c.home, ".gemini", "config", "skills"));
1246
+ uninstallSkill(c, join11(c.home, ".gemini", "config", "skills"));
1005
1247
  c.log?.("antigravity-cli: hooks + MCP entry + status line + skill removed");
1006
1248
  }
1007
1249
  };
1250
+ function pathNodeHasSqlite() {
1251
+ try {
1252
+ execFileSync4("node", ["-e", "require('node:sqlite')"], { stdio: "pipe", timeout: 1e4 });
1253
+ return true;
1254
+ } catch {
1255
+ return false;
1256
+ }
1257
+ }
1258
+ function pathNodeVersion() {
1259
+ try {
1260
+ return execFileSync4("node", ["-v"], { encoding: "utf8", stdio: "pipe" }).trim();
1261
+ } catch {
1262
+ return "not found";
1263
+ }
1264
+ }
1008
1265
  var devin = {
1009
1266
  name: "devin-cli",
1010
- detect: (c) => onPath("devin") || existsSync5(join10(c.home, ".config", "devin")),
1267
+ detect: (c) => onPath("devin") || existsSync7(join11(c.home, ".config", "devin")),
1268
+ // Devin is the ONLY harness whose hooks never hand over a transcript: they carry a session id and
1269
+ // nothing else, so retain can only work by reading the CLI's own sessions.db. That makes SQLite
1270
+ // support a hard prerequisite here — and one worth checking now, because the alternative is an
1271
+ // install that looks perfectly healthy and stores nothing, forever (#3125).
1272
+ preflight(c) {
1273
+ if ((c.nodeSqlite ?? pathNodeHasSqlite)()) return void 0;
1274
+ return `\`node:sqlite\` is unavailable in the \`node\` on PATH (${pathNodeVersion()}).
1275
+ Devin keeps its conversations in ~/.local/share/devin/cli/sessions.db and its hooks pass
1276
+ only a session id, so without SQLite nothing could ever be retained.
1277
+ Upgrade to Node 22.5 or newer (24 LTS recommended) and re-run this command.`;
1278
+ },
1011
1279
  install(c) {
1012
- const configPath = join10(c.home, ".config", "devin", "config.json");
1280
+ const configPath = join11(c.home, ".config", "devin", "config.json");
1013
1281
  const config = readJson(configPath);
1014
1282
  config.hooks = config.hooks ?? {};
1015
1283
  mergeHarnessHooks(config.hooks, "devin-cli", c.dist);
1016
1284
  writeJson(configPath, config);
1017
- const mcpPath = join10(c.home, ".config", "devin", "mcp_config.json");
1285
+ const mcpPath = join11(c.home, ".config", "devin", "mcp_config.json");
1018
1286
  const mcp = readJson(mcpPath);
1019
1287
  mcp.mcpServers = {
1020
1288
  ...mcp.mcpServers ?? {},
1021
1289
  hindsight: {
1022
1290
  command: "node",
1023
- args: [join10(c.dist, "mcp-server.js")],
1291
+ args: [join11(c.dist, "mcp-server.js")],
1024
1292
  env: { HINDSIGHT_MCP_HARNESS: "devin-cli" }
1025
1293
  }
1026
1294
  };
@@ -1028,8 +1296,8 @@ var devin = {
1028
1296
  c.log?.(`devin-cli: hooks merged into ${configPath}, MCP into ${mcpPath}`);
1029
1297
  },
1030
1298
  uninstall(c) {
1031
- const configPath = join10(c.home, ".config", "devin", "config.json");
1032
- if (existsSync5(configPath)) {
1299
+ const configPath = join11(c.home, ".config", "devin", "config.json");
1300
+ if (existsSync7(configPath)) {
1033
1301
  const config = readJson(configPath);
1034
1302
  if (config.hooks) {
1035
1303
  stripHarnessHooks(config.hooks, "devin-cli");
@@ -1037,8 +1305,8 @@ var devin = {
1037
1305
  writeJson(configPath, config);
1038
1306
  }
1039
1307
  }
1040
- const mcpPath = join10(c.home, ".config", "devin", "mcp_config.json");
1041
- if (existsSync5(mcpPath)) {
1308
+ const mcpPath = join11(c.home, ".config", "devin", "mcp_config.json");
1309
+ if (existsSync7(mcpPath)) {
1042
1310
  const mcp = readJson(mcpPath);
1043
1311
  if (mcp.mcpServers?.hindsight) {
1044
1312
  delete mcp.mcpServers.hindsight;
@@ -1050,26 +1318,26 @@ var devin = {
1050
1318
  };
1051
1319
  var cursor = {
1052
1320
  name: "cursor-cli",
1053
- detect: (c) => onPath("cursor-agent") || existsSync5(join10(c.home, ".cursor")),
1321
+ detect: (c) => onPath("cursor-agent") || existsSync7(join11(c.home, ".cursor")),
1054
1322
  install(c) {
1055
- const hooksPath = join10(c.home, ".cursor", "hooks.json");
1323
+ const hooksPath = join11(c.home, ".cursor", "hooks.json");
1056
1324
  const cfg = readJson(hooksPath);
1057
1325
  cfg.hooks = cfg.hooks ?? {};
1058
1326
  mergeHarnessHooks(cfg.hooks, "cursor-cli", c.dist);
1059
1327
  writeJson(hooksPath, cfg);
1060
- const mcpPath = join10(c.home, ".cursor", "mcp.json");
1328
+ const mcpPath = join11(c.home, ".cursor", "mcp.json");
1061
1329
  const mcp = readJson(mcpPath);
1062
1330
  mcp.mcpServers = {
1063
1331
  ...mcp.mcpServers ?? {},
1064
- hindsight: { command: "node", args: [join10(c.dist, "mcp-server.js")] }
1332
+ hindsight: { command: "node", args: [join11(c.dist, "mcp-server.js")] }
1065
1333
  };
1066
1334
  writeJson(mcpPath, mcp);
1067
1335
  c.log?.(`cursor-cli: hooks merged into ${hooksPath}, MCP into ${mcpPath}`);
1068
- installSkill(c, join10(c.home, ".cursor", "skills"));
1336
+ installSkill(c, join11(c.home, ".cursor", "skills"));
1069
1337
  },
1070
1338
  uninstall(c) {
1071
- const hooksPath = join10(c.home, ".cursor", "hooks.json");
1072
- if (existsSync5(hooksPath)) {
1339
+ const hooksPath = join11(c.home, ".cursor", "hooks.json");
1340
+ if (existsSync7(hooksPath)) {
1073
1341
  const cfg = readJson(hooksPath);
1074
1342
  if (cfg.hooks) {
1075
1343
  stripHarnessHooks(cfg.hooks, "cursor-cli");
@@ -1077,49 +1345,49 @@ var cursor = {
1077
1345
  writeJson(hooksPath, cfg);
1078
1346
  }
1079
1347
  }
1080
- const mcpPath = join10(c.home, ".cursor", "mcp.json");
1081
- if (existsSync5(mcpPath)) {
1348
+ const mcpPath = join11(c.home, ".cursor", "mcp.json");
1349
+ if (existsSync7(mcpPath)) {
1082
1350
  const mcp = readJson(mcpPath);
1083
1351
  if (mcp.mcpServers?.hindsight) {
1084
1352
  delete mcp.mcpServers.hindsight;
1085
1353
  writeJson(mcpPath, mcp);
1086
1354
  }
1087
1355
  }
1088
- uninstallSkill(c, join10(c.home, ".cursor", "skills"));
1356
+ uninstallSkill(c, join11(c.home, ".cursor", "skills"));
1089
1357
  c.log?.("cursor-cli: hooks + MCP entry + skill removed");
1090
1358
  }
1091
1359
  };
1092
1360
  var copilot = {
1093
1361
  name: "copilot-cli",
1094
- detect: (c) => onPath("copilot") || existsSync5(join10(c.home, ".copilot")),
1362
+ detect: (c) => onPath("copilot") || existsSync7(join11(c.home, ".copilot")),
1095
1363
  install(c) {
1096
- const hooksPath = join10(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
1364
+ const hooksPath = join11(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
1097
1365
  const hooks = {};
1098
1366
  mergeHarnessHooks(hooks, "copilot-cli", c.dist);
1099
1367
  writeJson(hooksPath, { version: 1, hooks });
1100
- const mcpPath = join10(c.home, ".copilot", "mcp-config.json");
1368
+ const mcpPath = join11(c.home, ".copilot", "mcp-config.json");
1101
1369
  const mcp = readJson(mcpPath);
1102
1370
  mcp.mcpServers = {
1103
1371
  ...mcp.mcpServers ?? {},
1104
- hindsight: { command: "node", args: [join10(c.dist, "mcp-server.js")] }
1372
+ hindsight: { command: "node", args: [join11(c.dist, "mcp-server.js")] }
1105
1373
  };
1106
1374
  writeJson(mcpPath, mcp);
1107
- installSkill(c, join10(c.home, ".copilot", "skills"));
1375
+ installSkill(c, join11(c.home, ".copilot", "skills"));
1108
1376
  c.log?.(`copilot-cli: hooks installed at ${hooksPath}, MCP into ${mcpPath}`);
1109
1377
  },
1110
1378
  uninstall(c) {
1111
- rmSync(join10(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
1379
+ rmSync(join11(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
1112
1380
  force: true
1113
1381
  });
1114
- const mcpPath = join10(c.home, ".copilot", "mcp-config.json");
1115
- if (existsSync5(mcpPath)) {
1382
+ const mcpPath = join11(c.home, ".copilot", "mcp-config.json");
1383
+ if (existsSync7(mcpPath)) {
1116
1384
  const mcp = readJson(mcpPath);
1117
1385
  if (mcp.mcpServers?.hindsight) {
1118
1386
  delete mcp.mcpServers.hindsight;
1119
1387
  writeJson(mcpPath, mcp);
1120
1388
  }
1121
1389
  }
1122
- uninstallSkill(c, join10(c.home, ".copilot", "skills"));
1390
+ uninstallSkill(c, join11(c.home, ".copilot", "skills"));
1123
1391
  c.log?.("copilot-cli: hooks + MCP entry + skill removed");
1124
1392
  }
1125
1393
  };
@@ -1128,12 +1396,12 @@ var GROK_MARKER_END = "# HINDSIGHT_CODING_AGENTS_GROK_END";
1128
1396
  var GROK_BLOCK_RE = new RegExp(`\\n?${GROK_MARKER_START}[\\s\\S]*?${GROK_MARKER_END}\\n?`);
1129
1397
  var grok = {
1130
1398
  name: "grok-build",
1131
- detect: (c) => onPath("grok") || existsSync5(join10(c.home, ".grok")),
1399
+ detect: (c) => onPath("grok") || existsSync7(join11(c.home, ".grok")),
1132
1400
  install(c) {
1133
- const path = join10(c.home, ".grok", "config.toml");
1134
- const existing = existsSync5(path) ? readFileSync13(path, "utf8") : "";
1401
+ const path = join11(c.home, ".grok", "config.toml");
1402
+ const existing = existsSync7(path) ? readFileSync14(path, "utf8") : "";
1135
1403
  const withoutOurs = existing.replace(GROK_BLOCK_RE, "\n");
1136
- const command = (entry) => JSON.stringify(`node "${join10(c.dist, entry)}"`);
1404
+ const command = (entry) => JSON.stringify(`node "${join11(c.dist, entry)}"`);
1137
1405
  const tomlString = (value) => JSON.stringify(value);
1138
1406
  const block = `
1139
1407
  ${GROK_MARKER_START}
@@ -1157,24 +1425,24 @@ ${GROK_MARKER_START}
1157
1425
 
1158
1426
  [mcp_servers.hindsight]
1159
1427
  command = "node"
1160
- args = [${tomlString(join10(c.dist, "mcp-server.js"))}]
1428
+ args = [${tomlString(join11(c.dist, "mcp-server.js"))}]
1161
1429
  ${GROK_MARKER_END}
1162
1430
  `;
1163
- if (existsSync5(path) && !existsSync5(`${path}.hindsight-backup`))
1431
+ if (existsSync7(path) && !existsSync7(`${path}.hindsight-backup`))
1164
1432
  copyFileSync(path, `${path}.hindsight-backup`);
1165
1433
  mkdirSync3(dirname7(path), { recursive: true });
1166
1434
  writeFileSync2(path, `${withoutOurs.replace(/\n*$/, "\n")}${block}`);
1167
- installSkill(c, join10(c.home, ".grok", "skills"));
1435
+ installSkill(c, join11(c.home, ".grok", "skills"));
1168
1436
  c.log?.(`grok-build: native hooks + MCP installed in ${path}`);
1169
1437
  },
1170
1438
  uninstall(c) {
1171
- const path = join10(c.home, ".grok", "config.toml");
1172
- if (existsSync5(path)) {
1173
- const existing = readFileSync13(path, "utf8");
1439
+ const path = join11(c.home, ".grok", "config.toml");
1440
+ if (existsSync7(path)) {
1441
+ const existing = readFileSync14(path, "utf8");
1174
1442
  const cleaned = existing.replace(GROK_BLOCK_RE, "\n");
1175
1443
  if (cleaned !== existing) writeFileSync2(path, cleaned);
1176
1444
  }
1177
- uninstallSkill(c, join10(c.home, ".grok", "skills"));
1445
+ uninstallSkill(c, join11(c.home, ".grok", "skills"));
1178
1446
  c.log?.("grok-build: native hooks + MCP + skill removed");
1179
1447
  }
1180
1448
  };
@@ -1182,17 +1450,17 @@ var CLINE_HOOK_MARKER = "HINDSIGHT_CODING_AGENTS_CLINE";
1182
1450
  var CLINE_OLD_HOOK_EVENTS = ["TaskStart", "UserPromptSubmit", "TaskComplete"];
1183
1451
  var CLINE_PLUGIN_NAME = "@vectorize-io/hindsight-coding-agents";
1184
1452
  function removeLegacyClineHooks(c) {
1185
- const hooksDir = join10(c.home, "Documents", "Cline", "Hooks");
1453
+ const hooksDir = join11(c.home, "Documents", "Cline", "Hooks");
1186
1454
  for (const event of CLINE_OLD_HOOK_EVENTS) {
1187
- const path = join10(hooksDir, event);
1188
- if (existsSync5(path) && readFileSync13(path, "utf8").includes(CLINE_HOOK_MARKER)) {
1455
+ const path = join11(hooksDir, event);
1456
+ if (existsSync7(path) && readFileSync14(path, "utf8").includes(CLINE_HOOK_MARKER)) {
1189
1457
  rmSync(path, { force: true });
1190
1458
  }
1191
1459
  }
1192
1460
  }
1193
1461
  var cline = {
1194
1462
  name: "cline-cli",
1195
- detect: (c) => onPath("cline") || existsSync5(join10(c.home, ".cline")),
1463
+ detect: (c) => onPath("cline") || existsSync7(join11(c.home, ".cline")),
1196
1464
  install(c) {
1197
1465
  removeLegacyClineHooks(c);
1198
1466
  const installed = (c.clinePlugin ?? runClinePlugin)([
@@ -1201,18 +1469,18 @@ var cline = {
1201
1469
  "--force",
1202
1470
  c.pkgRoot
1203
1471
  ]);
1204
- const mcpPath = join10(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
1472
+ const mcpPath = join11(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
1205
1473
  const mcp = readJson(mcpPath);
1206
1474
  mcp.mcpServers = {
1207
1475
  ...mcp.mcpServers ?? {},
1208
1476
  hindsight: {
1209
1477
  command: "node",
1210
- args: [join10(c.dist, "mcp-server.js")],
1478
+ args: [join11(c.dist, "mcp-server.js")],
1211
1479
  env: { HINDSIGHT_MCP_HARNESS: "cline-cli" }
1212
1480
  }
1213
1481
  };
1214
1482
  writeJson(mcpPath, mcp);
1215
- installSkill(c, join10(c.home, ".cline", "data", "settings", "skills"));
1483
+ installSkill(c, join11(c.home, ".cline", "data", "settings", "skills"));
1216
1484
  c.log?.(
1217
1485
  installed ? "cline-cli: native plugin + MCP + skill installed" : `cline-cli: MCP + skill installed; run: cline plugin install --force "${c.pkgRoot}"`
1218
1486
  );
@@ -1220,15 +1488,15 @@ var cline = {
1220
1488
  uninstall(c) {
1221
1489
  removeLegacyClineHooks(c);
1222
1490
  (c.clinePlugin ?? runClinePlugin)(["plugin", "uninstall", CLINE_PLUGIN_NAME]);
1223
- const mcpPath = join10(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
1224
- if (existsSync5(mcpPath)) {
1491
+ const mcpPath = join11(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
1492
+ if (existsSync7(mcpPath)) {
1225
1493
  const mcp = readJson(mcpPath);
1226
1494
  if (mcp.mcpServers?.hindsight) {
1227
1495
  delete mcp.mcpServers.hindsight;
1228
1496
  writeJson(mcpPath, mcp);
1229
1497
  }
1230
1498
  }
1231
- uninstallSkill(c, join10(c.home, ".cline", "data", "settings", "skills"));
1499
+ uninstallSkill(c, join11(c.home, ".cline", "data", "settings", "skills"));
1232
1500
  c.log?.("cline-cli: native plugin + MCP + skill removed");
1233
1501
  }
1234
1502
  };
@@ -1245,43 +1513,106 @@ var INSTALLERS = [
1245
1513
  cline
1246
1514
  ];
1247
1515
  var HARNESS_ALIASES = { agy: "antigravity-cli" };
1516
+ function importConversations(harness, ctx) {
1517
+ const repo = process.cwd();
1518
+ const found = importLocalHistory(harness, repo);
1519
+ if (!found.supported) {
1520
+ ctx.log?.(`${harness}: --import-conversations skipped \u2014 ${found.reason}`);
1521
+ return;
1522
+ }
1523
+ if (found.unattributed) {
1524
+ ctx.log?.(
1525
+ `${harness}: skipped ${found.unattributed} session(s) that do not record which directory they ran in \u2014 importing them could file another repo's conversation into this bank`
1526
+ );
1527
+ }
1528
+ if (!found.sessions.length) {
1529
+ ctx.log?.(`${harness}: no past sessions found on disk for ${repo}`);
1530
+ return;
1531
+ }
1532
+ const turns = found.sessions.reduce((n, s) => n + s.turns.length, 0);
1533
+ const file = join11(mkdtempSync(join11(tmpdir3(), "hindsight-import-")), "conversations.json");
1534
+ writeFileSync2(file, JSON.stringify(found.sessions));
1535
+ ctx.log?.(
1536
+ `${harness}: importing ${found.sessions.length} past sessions (${turns} turns) from ${repo} \u2014 this runs extraction and may take a while`
1537
+ );
1538
+ try {
1539
+ execFileSync4("node", [join11(ctx.dist, "deepen.js"), "--repo", repo, "--conversations", file], {
1540
+ stdio: "inherit"
1541
+ });
1542
+ } catch {
1543
+ ctx.log?.(`${harness}: conversation import did not finish \u2014 re-run it any time with:`);
1544
+ ctx.log?.(` node "${join11(ctx.dist, "deepen.js")}" --repo "${repo}" --conversations "${file}"`);
1545
+ }
1546
+ }
1248
1547
  function run(argv, ctx) {
1249
- const [command, ...names] = argv;
1548
+ const [command, ...rawArgs] = argv;
1549
+ const importHistory = rawArgs.includes("--import-conversations");
1550
+ const names = rawArgs.filter((a) => !a.startsWith("--"));
1250
1551
  if (command === "install" && /\/(_npx|\.npm\/_npx|dlx-)\/|\/_cacache\//.test(ctx.pkgRoot)) {
1251
1552
  ctx.log?.(
1252
- "refusing to install from an npx/dlx cache: the hook wiring would point into a cache npm can evict, silently breaking every session.\nInstall the package permanently, then re-run:\n npm install -g hindsight-coding-agents && hindsight-coding-agents install"
1553
+ "refusing to install from an npx/dlx cache: the hook wiring would point into a cache npm can evict, silently breaking every session.\nInstall the package permanently, then re-run:\n npm install -g @vectorize-io/hindsight-coding-agents\n hindsight-coding-agents install all"
1253
1554
  );
1254
1555
  return 1;
1255
1556
  }
1256
1557
  if (command !== "install" && command !== "uninstall") {
1257
1558
  ctx.log?.(
1258
- `usage: hindsight-coding-agents <install|uninstall> [harness...]
1259
- harnesses: ${INSTALLERS.map((i) => i.name).join(", ")} (agy is an alias for antigravity-cli; default: every one detected on this machine)`
1559
+ `usage: hindsight-coding-agents <install|uninstall> <all|harness...> [--import-conversations]
1560
+ all every agent detected on this machine
1561
+ harness ${INSTALLERS.map((i) => i.name).join(", ")} (agy aliases antigravity-cli)`
1260
1562
  );
1261
1563
  return command ? 1 : 0;
1262
1564
  }
1263
1565
  let targets;
1264
- if (names.length) {
1566
+ if (names.includes("all")) {
1567
+ targets = INSTALLERS.filter((i) => i.detect(ctx));
1568
+ if (!targets.length) {
1569
+ ctx.log?.("no supported coding agents detected \u2014 name one explicitly to wire it anyway");
1570
+ return 1;
1571
+ }
1572
+ ctx.log?.(`detected: ${targets.map((t) => t.name).join(", ")}`);
1573
+ } else if (names.length) {
1265
1574
  targets = [];
1266
1575
  for (const n of names) {
1267
1576
  const hit = INSTALLERS.find((i) => i.name === (HARNESS_ALIASES[n] ?? n));
1268
1577
  if (!hit) {
1269
1578
  ctx.log?.(
1270
- `unknown harness "${n}" \u2014 expected one of: ${INSTALLERS.map((i) => i.name).join(", ")} (agy aliases antigravity-cli)`
1579
+ `unknown harness "${n}" \u2014 expected "all" or one of: ${INSTALLERS.map((i) => i.name).join(", ")} (agy aliases antigravity-cli)`
1271
1580
  );
1272
1581
  return 1;
1273
1582
  }
1274
1583
  targets.push(hit);
1275
1584
  }
1276
1585
  } else {
1277
- targets = INSTALLERS.filter((i) => i.detect(ctx));
1278
- if (!targets.length) {
1279
- ctx.log?.("no supported coding agents detected \u2014 pass harness names explicitly");
1280
- return 1;
1586
+ ctx.log?.(
1587
+ `${command}: name a harness, or "all" for every agent detected on this machine.
1588
+ hindsight-coding-agents ${command} claude-code
1589
+ hindsight-coding-agents ${command} all
1590
+ harnesses: ${INSTALLERS.map((i) => i.name).join(", ")} (agy aliases antigravity-cli)`
1591
+ );
1592
+ return 1;
1593
+ }
1594
+ const blocked = /* @__PURE__ */ new Set();
1595
+ if (command === "install") {
1596
+ for (const t of targets) {
1597
+ const problem = t.preflight?.(ctx);
1598
+ if (!problem) continue;
1599
+ ctx.log?.(`
1600
+ \u274C ${t.name}: ${problem}`);
1601
+ blocked.add(t.name);
1281
1602
  }
1282
- ctx.log?.(`detected: ${targets.map((t) => t.name).join(", ")}`);
1283
1603
  }
1284
- for (const t of targets) t[command](ctx);
1604
+ const runnable = targets.filter((t) => !blocked.has(t.name));
1605
+ for (const t of runnable) t[command](ctx);
1606
+ if (command === "install" && importHistory) {
1607
+ for (const t of runnable) importConversations(t.name, ctx);
1608
+ }
1609
+ if (blocked.size) {
1610
+ ctx.log?.(
1611
+ `
1612
+ \u274C not installed: ${[...blocked].join(", ")} \u2014 this machine can't run ${blocked.size > 1 ? "them" : "it"} (see above).`
1613
+ );
1614
+ return 1;
1615
+ }
1285
1616
  ctx.log?.(
1286
1617
  command === "install" ? `
1287
1618
  \u2705 installed. Configure the server in ~/.hindsight/coding-agent.json (apiUrl/apiToken) and start a session.` : `
@@ -1301,7 +1632,7 @@ if (isMain || mainPath?.endsWith("installer.js")) {
1301
1632
  const dist = dirname7(fileURLToPath4(import.meta.url));
1302
1633
  process.exit(
1303
1634
  run(process.argv.slice(2), {
1304
- home: homedir7(),
1635
+ home: homedir8(),
1305
1636
  pkgRoot: dirname7(dist),
1306
1637
  dist,
1307
1638
  log: (m) => console.log(m)