@vectorize-io/hindsight-coding-agents 0.0.3 → 0.0.5

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
@@ -5,16 +5,18 @@ import { execFileSync as execFileSync5 } from "child_process";
5
5
  import {
6
6
  copyFileSync,
7
7
  cpSync as cpSync2,
8
- existsSync as existsSync5,
8
+ existsSync as existsSync8,
9
9
  mkdirSync as mkdirSync3,
10
- readFileSync as readFileSync13,
10
+ mkdtempSync,
11
+ readFileSync as readFileSync15,
12
+ readSync as readSync2,
11
13
  realpathSync,
12
14
  rmSync,
13
15
  writeFileSync as writeFileSync2
14
16
  } from "fs";
15
- import { homedir as homedir7 } from "os";
16
- import { dirname as dirname7, join as join10 } from "path";
17
- import { fileURLToPath as fileURLToPath4, pathToFileURL } from "url";
17
+ import { homedir as homedir9, tmpdir as tmpdir3 } from "os";
18
+ import { dirname as dirname8, join as join13 } from "path";
19
+ import { fileURLToPath as fileURLToPath5, pathToFileURL } from "url";
18
20
 
19
21
  // src/core/hook.ts
20
22
  import { existsSync, readFileSync as readFileSync3 } from "fs";
@@ -36,6 +38,7 @@ import { fileURLToPath } from "url";
36
38
 
37
39
  // src/core/config.ts
38
40
  var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join3(homedir2(), ".hindsight", "coding-agent.json");
41
+ var DEFAULT_DAEMON_PORT = 9077;
39
42
 
40
43
  // src/core/diag.ts
41
44
  import { appendFileSync as appendFileSync2 } from "fs";
@@ -44,9 +47,43 @@ import { appendFileSync as appendFileSync2 } from "fs";
44
47
  import { appendFileSync, mkdirSync } from "fs";
45
48
  import { tmpdir } from "os";
46
49
  import { dirname as dirname3, join as join4 } from "path";
50
+ var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
47
51
  var current = ["debug", "info", "warn", "error"].find(
48
52
  (l) => l === process.env.HINDSIGHT_LOG_LEVEL
49
53
  ) ?? "info";
54
+ function logFilePath() {
55
+ return process.env.HINDSIGHT_LOG_FILE || join4(tmpdir(), "hindsight-coding-agent", "plugin.log");
56
+ }
57
+ function write(level, scope, msg, extra) {
58
+ if (WEIGHT[level] < WEIGHT[current]) return;
59
+ try {
60
+ const file = logFilePath();
61
+ mkdirSync(dirname3(file), { recursive: true });
62
+ appendFileSync(
63
+ file,
64
+ `${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
65
+ );
66
+ } catch {
67
+ }
68
+ }
69
+ var log = {
70
+ debug: (scope, msg, extra) => write("debug", scope, msg, extra),
71
+ info: (scope, msg, extra) => write("info", scope, msg, extra),
72
+ warn: (scope, msg, extra) => write("warn", scope, msg, extra),
73
+ error: (scope, msg, extra) => write("error", scope, msg, extra)
74
+ };
75
+
76
+ // src/core/diag.ts
77
+ function diag(harness, event, extra = {}) {
78
+ log.debug(harness, `diag:${event}`, extra);
79
+ try {
80
+ appendFileSync2(
81
+ process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log",
82
+ JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
83
+ );
84
+ } catch {
85
+ }
86
+ }
50
87
 
51
88
  // src/core/session-cache.ts
52
89
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
@@ -56,6 +93,60 @@ import { dirname as dirname4, join as join5 } from "path";
56
93
  // src/core/retain-hook.ts
57
94
  import { readFileSync as readFileSync5 } from "fs";
58
95
 
96
+ // src/core/daemon.ts
97
+ import { execFileSync as execFileSync2, spawn as realSpawn2 } from "child_process";
98
+ import { dirname as dirname5, join as join6 } from "path";
99
+ import { fileURLToPath as fileURLToPath2 } from "url";
100
+ function hasRustToolchain() {
101
+ if (process.platform !== "darwin") return true;
102
+ try {
103
+ execFileSync2("cargo", ["--version"], { stdio: "pipe", timeout: 1e4 });
104
+ return true;
105
+ } catch {
106
+ return false;
107
+ }
108
+ }
109
+ function hasUvx() {
110
+ try {
111
+ execFileSync2("uvx", ["--version"], { stdio: "pipe", timeout: 1e4 });
112
+ return true;
113
+ } catch {
114
+ return false;
115
+ }
116
+ }
117
+ var PROVIDER_PROBES = [
118
+ { provider: "openai", keyEnv: "OPENAI_API_KEY" },
119
+ { provider: "anthropic", keyEnv: "ANTHROPIC_API_KEY" },
120
+ { provider: "gemini", keyEnv: "GEMINI_API_KEY" },
121
+ { provider: "groq", keyEnv: "GROQ_API_KEY" }
122
+ ];
123
+ function detectLlm(env = process.env) {
124
+ const explicit = env.HINDSIGHT_API_LLM_PROVIDER?.trim();
125
+ if (explicit) {
126
+ return {
127
+ provider: explicit,
128
+ apiKey: env.HINDSIGHT_API_LLM_API_KEY?.trim() || void 0,
129
+ source: "HINDSIGHT_API_LLM_PROVIDER"
130
+ };
131
+ }
132
+ for (const probe of PROVIDER_PROBES) {
133
+ const key = env[probe.keyEnv]?.trim();
134
+ if (key) return { provider: probe.provider, apiKey: key, source: probe.keyEnv };
135
+ }
136
+ if (onPath("claude")) {
137
+ return { provider: "claude-code", source: "the Claude Code CLI on PATH (no API key needed)" };
138
+ }
139
+ return void 0;
140
+ }
141
+ function onPath(bin) {
142
+ try {
143
+ execFileSync2("which", [bin], { stdio: "pipe", timeout: 5e3 });
144
+ return true;
145
+ } catch {
146
+ return false;
147
+ }
148
+ }
149
+
59
150
  // src/core/transcript.ts
60
151
  import { readFileSync as readFileSync4 } from "fs";
61
152
 
@@ -94,28 +185,84 @@ function actionLine(tool, input) {
94
185
  return target ? `${tool} ${target}` : tool;
95
186
  }
96
187
 
188
+ // src/core/transcript.ts
189
+ function renderLine(content, type) {
190
+ if (typeof content === "string") {
191
+ const text = stripInjectedMemory(content).trim();
192
+ return text ? [{ role: type, content: text }] : [];
193
+ }
194
+ if (!Array.isArray(content)) return [];
195
+ const texts = [];
196
+ const actions = [];
197
+ for (const b of content) {
198
+ if (!b || typeof b !== "object") continue;
199
+ if (b.type === "text" && typeof b.text === "string") {
200
+ const t = stripInjectedMemory(b.text).trim();
201
+ if (t) texts.push(t);
202
+ } else if (b.type === "tool_use" && typeof b.name === "string") {
203
+ actions.push({ role: "action", content: actionLine(b.name, b.input) });
204
+ }
205
+ }
206
+ const out = [];
207
+ const joined = texts.join("\n").trim();
208
+ if (joined) out.push({ role: type, content: joined });
209
+ out.push(...actions);
210
+ return out;
211
+ }
212
+ function readClaudeTranscript(path) {
213
+ let raw;
214
+ try {
215
+ raw = readFileSync4(path, "utf8");
216
+ } catch {
217
+ return [];
218
+ }
219
+ const turns = [];
220
+ for (const rawLine of raw.split("\n")) {
221
+ const trimmed = rawLine.trim();
222
+ if (!trimmed) continue;
223
+ let parsed;
224
+ try {
225
+ parsed = JSON.parse(trimmed);
226
+ } catch {
227
+ continue;
228
+ }
229
+ if (typeof parsed !== "object" || parsed === null) continue;
230
+ const line = parsed;
231
+ if (line.type !== "user" && line.type !== "assistant") continue;
232
+ if (line.isMeta === true) continue;
233
+ if (line.isSidechain === true) continue;
234
+ if (typeof line.message !== "object" || line.message === null) continue;
235
+ for (const rendered of renderLine(line.message.content, line.type)) {
236
+ const turn = { role: rendered.role, content: rendered.content };
237
+ if (typeof line.timestamp === "string") turn.timestamp = line.timestamp;
238
+ turns.push(turn);
239
+ }
240
+ }
241
+ return turns;
242
+ }
243
+
97
244
  // src/core/session-start.ts
98
245
  import { readFileSync as readFileSync7 } from "fs";
99
246
 
100
247
  // src/core/git.ts
101
- import { execFileSync as execFileSync2 } from "child_process";
248
+ import { execFileSync as execFileSync3 } from "child_process";
102
249
  import { resolve } from "path";
103
250
 
104
251
  // src/core/status.ts
105
- import { execFileSync as execFileSync3 } from "child_process";
252
+ import { execFileSync as execFileSync4 } from "child_process";
106
253
 
107
254
  // src/core/survey.ts
108
- import { spawn as realSpawn2 } from "child_process";
255
+ import { spawn as realSpawn3 } from "child_process";
109
256
  import { accessSync, constants, existsSync as existsSync2 } from "fs";
110
257
  import { homedir as homedir3 } from "os";
111
- import { delimiter, dirname as dirname5, join as join6 } from "path";
112
- import { fileURLToPath as fileURLToPath2 } from "url";
258
+ import { delimiter, dirname as dirname6, join as join7 } from "path";
259
+ import { fileURLToPath as fileURLToPath3 } from "url";
113
260
 
114
261
  // src/core/skill-sync.ts
115
262
  import { cpSync, existsSync as existsSync3, readFileSync as readFileSync6 } from "fs";
116
263
  import { homedir as homedir4 } from "os";
117
- import { dirname as dirname6, join as join7 } from "path";
118
- import { fileURLToPath as fileURLToPath3 } from "url";
264
+ import { dirname as dirname7, join as join8 } from "path";
265
+ import { fileURLToPath as fileURLToPath4 } from "url";
119
266
 
120
267
  // src/core/transcript-codex.ts
121
268
  import { readFileSync as readFileSync8 } from "fs";
@@ -277,17 +424,17 @@ function readCopilotTranscript(path) {
277
424
  // src/core/transcript-grok.ts
278
425
  import { existsSync as existsSync4, readFileSync as readFileSync12, readdirSync } from "fs";
279
426
  import { homedir as homedir5 } from "os";
280
- import { join as join8 } from "path";
427
+ import { join as join9 } from "path";
281
428
  var CHAT_HISTORY = "chat_history.jsonl";
282
- function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join8(homedir5(), ".grok")) {
283
- const sessionsDir = join8(grokHome, "sessions");
284
- const direct = join8(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
429
+ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join9(homedir5(), ".grok")) {
430
+ const sessionsDir = join9(grokHome, "sessions");
431
+ const direct = join9(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
285
432
  if (existsSync4(direct)) return direct;
286
433
  try {
287
434
  for (const candidate of readdirSync(sessionsDir)) {
288
- const directory = join8(sessionsDir, candidate);
289
- if (readFileSync12(join8(directory, ".cwd"), "utf8").trim() === cwd) {
290
- return join8(directory, sessionId, CHAT_HISTORY);
435
+ const directory = join9(sessionsDir, candidate);
436
+ if (readFileSync12(join9(directory, ".cwd"), "utf8").trim() === cwd) {
437
+ return join9(directory, sessionId, CHAT_HISTORY);
291
438
  }
292
439
  }
293
440
  } catch {
@@ -328,10 +475,13 @@ function readGrokTranscript(path) {
328
475
  }
329
476
 
330
477
  // src/core/transcript-devin.ts
331
- import { execFileSync as execFileSync4 } from "child_process";
478
+ import { existsSync as existsSync5 } from "fs";
479
+ import { createRequire } from "module";
332
480
  import { homedir as homedir6 } from "os";
333
- import { join as join9 } from "path";
334
- var sessionDb = join9(homedir6(), ".local", "share", "devin", "cli", "sessions.db");
481
+ import { join as join10 } from "path";
482
+ function devinSessionDb(home = homedir6()) {
483
+ return join10(home, ".local", "share", "devin", "cli", "sessions.db");
484
+ }
335
485
  function parseDevinMessages(nodes) {
336
486
  const messages = /* @__PURE__ */ new Map();
337
487
  for (const node of nodes) {
@@ -352,23 +502,41 @@ function parseDevinMessages(nodes) {
352
502
  }
353
503
  return [...messages.values()].sort((a, b) => a.index - b.index).map(({ role, content }) => ({ role, content }));
354
504
  }
355
- function readDevinTranscript(sessionId) {
356
- if (!sessionId) return [];
505
+ var requireBuiltin = createRequire(import.meta.url);
506
+ function loadSqlite() {
357
507
  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));
508
+ return requireBuiltin("node:sqlite").DatabaseSync;
369
509
  } catch {
510
+ return void 0;
511
+ }
512
+ }
513
+ function readDevinTranscript(sessionId, dbPath = devinSessionDb()) {
514
+ if (!sessionId) return [];
515
+ const Database = loadSqlite();
516
+ if (!Database) {
517
+ diag("devin-cli", "sqlite_unavailable", { node: process.version, dbPath });
370
518
  return [];
371
519
  }
520
+ if (!existsSync5(dbPath)) {
521
+ diag("devin-cli", "session_db_missing", { dbPath });
522
+ return [];
523
+ }
524
+ let db;
525
+ try {
526
+ db = new Database(dbPath, { readOnly: true });
527
+ const rows = db.prepare(
528
+ "SELECT node_id, chat_message FROM message_nodes WHERE session_id = ? ORDER BY node_id"
529
+ ).all(sessionId);
530
+ return parseDevinMessages(rows);
531
+ } catch (error) {
532
+ diag("devin-cli", "session_db_read_failed", { dbPath, error: String(error) });
533
+ return [];
534
+ } finally {
535
+ try {
536
+ db?.close();
537
+ } catch {
538
+ }
539
+ }
372
540
  }
373
541
 
374
542
  // src/harness/hook-lifecycle.ts
@@ -654,11 +822,194 @@ var HOOK_HARNESSES = {
654
822
  }
655
823
  };
656
824
 
825
+ // src/core/history.ts
826
+ import {
827
+ closeSync,
828
+ existsSync as existsSync6,
829
+ openSync,
830
+ readdirSync as readdirSync2,
831
+ readFileSync as readFileSync13,
832
+ readSync,
833
+ statSync
834
+ } from "fs";
835
+ import { homedir as homedir7 } from "os";
836
+ import { join as join11 } from "path";
837
+ function claudeProjectDir(repoDir, home = homedir7()) {
838
+ return join11(home, ".claude", "projects", repoDir.replace(/[/.]/g, "-"));
839
+ }
840
+ function withinRepo(dir, repoDir) {
841
+ return !!dir && (dir === repoDir || dir.startsWith(repoDir.endsWith("/") ? repoDir : repoDir + "/"));
842
+ }
843
+ function claudeSessionCwd(file) {
844
+ try {
845
+ for (const line of readFileSync13(file, "utf8").split("\n", 400)) {
846
+ if (!line.includes('"cwd"')) continue;
847
+ const cwd = JSON.parse(line).cwd;
848
+ if (cwd) return cwd;
849
+ }
850
+ } catch {
851
+ }
852
+ return void 0;
853
+ }
854
+ function toSession(id, turns) {
855
+ const prose = turns.filter((t) => t.role === "user" || t.role === "assistant").map((t) => ({
856
+ role: t.role,
857
+ text: t.content,
858
+ ...t.timestamp ? { timestamp: t.timestamp } : {}
859
+ }));
860
+ return prose.length ? { id, turns: prose } : void 0;
861
+ }
862
+ function firstLine(path, cap = 1e6) {
863
+ const fd = openSync(path, "r");
864
+ try {
865
+ const chunk = Buffer.alloc(64 * 1024);
866
+ let acc = "";
867
+ while (acc.length < cap) {
868
+ const n = readSync(fd, chunk, 0, chunk.length, null);
869
+ if (n <= 0) break;
870
+ acc += chunk.subarray(0, n).toString("utf8");
871
+ const nl = acc.indexOf("\n");
872
+ if (nl !== -1) return acc.slice(0, nl);
873
+ }
874
+ return acc.length && acc.length < cap ? acc : void 0;
875
+ } finally {
876
+ closeSync(fd);
877
+ }
878
+ }
879
+ function jsonlFiles(dir) {
880
+ if (!existsSync6(dir)) return [];
881
+ return readdirSync2(dir).filter((f) => f.endsWith(".jsonl")).map((f) => join11(dir, f));
882
+ }
883
+ function claudeHistory(repoDir, home) {
884
+ const root = join11(home, ".claude", "projects");
885
+ const exact = claudeProjectDir(repoDir, home);
886
+ const prefix = exact + "-";
887
+ const dirs = existsSync6(root) ? readdirSync2(root).map((d) => join11(root, d)).filter((d) => d === exact || d.startsWith(prefix)) : [];
888
+ const sessions = [];
889
+ let unattributed = 0;
890
+ for (const file of dirs.flatMap(jsonlFiles)) {
891
+ const cwd = claudeSessionCwd(file);
892
+ if (!cwd) {
893
+ unattributed++;
894
+ continue;
895
+ }
896
+ if (!withinRepo(cwd, repoDir)) continue;
897
+ try {
898
+ const id = file.split("/").pop().replace(/\.jsonl$/, "");
899
+ const s = toSession(id, readClaudeTranscript(file));
900
+ if (s) sessions.push(s);
901
+ } catch {
902
+ }
903
+ }
904
+ return { supported: true, sessions, unattributed };
905
+ }
906
+ function codexHistory(repoDir, home) {
907
+ const root = join11(home, ".codex", "sessions");
908
+ if (!existsSync6(root)) return { supported: true, sessions: [] };
909
+ const files = [];
910
+ const walk = (dir) => {
911
+ for (const entry of readdirSync2(dir)) {
912
+ const p = join11(dir, entry);
913
+ if (statSync(p).isDirectory()) walk(p);
914
+ else if (entry.endsWith(".jsonl")) files.push(p);
915
+ }
916
+ };
917
+ try {
918
+ walk(root);
919
+ } catch {
920
+ return { supported: true, sessions: [] };
921
+ }
922
+ const sessions = [];
923
+ for (const file of files) {
924
+ try {
925
+ const head = firstLine(file);
926
+ if (!head) continue;
927
+ const meta = JSON.parse(head);
928
+ if (!withinRepo(meta?.payload?.cwd, repoDir)) continue;
929
+ const s = toSession(meta.payload?.id ?? file, readCodexTranscript(file));
930
+ if (s) sessions.push(s);
931
+ } catch {
932
+ }
933
+ }
934
+ return { supported: true, sessions };
935
+ }
936
+ var SQLITE_HISTORY = "keeps session history in an internal SQLite database, whose schema is unversioned and would break on any upstream change";
937
+ function importLocalHistory(harness, repoDir, home = homedir7()) {
938
+ switch (harness) {
939
+ case "claude-code":
940
+ return claudeHistory(repoDir, home);
941
+ case "codex":
942
+ return codexHistory(repoDir, home);
943
+ case "opencode":
944
+ case "kilo":
945
+ case "cursor-cli":
946
+ case "cline-cli":
947
+ case "copilot-cli":
948
+ case "devin-cli":
949
+ return { supported: false, reason: `${harness} ${SQLITE_HISTORY}`, sessions: [] };
950
+ default:
951
+ return { supported: false, reason: `no local history reader for ${harness}`, sessions: [] };
952
+ }
953
+ }
954
+
955
+ // src/core/legacy.ts
956
+ import { existsSync as existsSync7, readFileSync as readFileSync14 } from "fs";
957
+ import { homedir as homedir8 } from "os";
958
+ import { join as join12 } from "path";
959
+ var LEGACY_CONFIG_FILES = {
960
+ "claude-code": "claude-code.json",
961
+ codex: "codex.json"
962
+ };
963
+ function legacyConfigPath(harness, home = homedir8()) {
964
+ return join12(home, ".hindsight", LEGACY_CONFIG_FILES[harness] ?? `${harness}.json`);
965
+ }
966
+ var CLOUD_URL = "https://api.hindsight.vectorize.io";
967
+ function readLegacyEndpoint(home = homedir8(), prefer = []) {
968
+ const order = [...prefer, ...Object.keys(LEGACY_CONFIG_FILES)].filter(
969
+ (h, i, all) => h in LEGACY_CONFIG_FILES && all.indexOf(h) === i
970
+ );
971
+ for (const harness of order) {
972
+ const found = readOne(harness, home);
973
+ if (found) return found;
974
+ }
975
+ return void 0;
976
+ }
977
+ function readOne(harness, home) {
978
+ const source = legacyConfigPath(harness, home);
979
+ if (!existsSync7(source)) return void 0;
980
+ let raw;
981
+ try {
982
+ raw = JSON.parse(readFileSync14(source, "utf8"));
983
+ } catch {
984
+ return void 0;
985
+ }
986
+ if (!raw || typeof raw !== "object") return void 0;
987
+ const apiToken = typeof raw.hindsightApiToken === "string" ? raw.hindsightApiToken : void 0;
988
+ const url = typeof raw.hindsightApiUrl === "string" ? raw.hindsightApiUrl.trim() : "";
989
+ if (url) {
990
+ return {
991
+ harness,
992
+ serverMode: url.replace(/\/+$/, "") === CLOUD_URL ? "cloud" : "self-hosted",
993
+ apiUrl: url,
994
+ ...apiToken ? { apiToken } : {},
995
+ source
996
+ };
997
+ }
998
+ const port = typeof raw.apiPort === "number" ? raw.apiPort : void 0;
999
+ return {
1000
+ harness,
1001
+ serverMode: "daemon",
1002
+ ...apiToken ? { apiToken } : {},
1003
+ ...port && port !== DEFAULT_DAEMON_PORT ? { apiPort: port } : {},
1004
+ source
1005
+ };
1006
+ }
1007
+
657
1008
  // src/installer.ts
658
1009
  var MARKER = "coding-agents";
659
1010
  function readJson(path) {
660
1011
  try {
661
- return JSON.parse(readFileSync13(path, "utf8"));
1012
+ return JSON.parse(readFileSync15(path, "utf8"));
662
1013
  } catch {
663
1014
  return {};
664
1015
  }
@@ -673,8 +1024,8 @@ function parseJsonc(text) {
673
1024
  }
674
1025
  }
675
1026
  function writeJson(path, value) {
676
- mkdirSync3(dirname7(path), { recursive: true });
677
- if (existsSync5(path) && !existsSync5(`${path}.hindsight-backup`)) {
1027
+ mkdirSync3(dirname8(path), { recursive: true });
1028
+ if (existsSync8(path) && !existsSync8(`${path}.hindsight-backup`)) {
678
1029
  copyFileSync(path, `${path}.hindsight-backup`);
679
1030
  }
680
1031
  writeFileSync2(path, JSON.stringify(value, null, 2) + "\n");
@@ -691,7 +1042,7 @@ function setOrDelete(obj, key, arr) {
691
1042
  else delete obj[key];
692
1043
  }
693
1044
  var cmdHook = (dist, file, timeout) => ({
694
- hooks: [{ type: "command", command: `node "${join10(dist, file)}"`, timeout }]
1045
+ hooks: [{ type: "command", command: `node "${join13(dist, file)}"`, timeout }]
695
1046
  });
696
1047
  function mergeHarnessHooks(hooks, harness, dist) {
697
1048
  const spec = HOOK_HARNESSES[harness];
@@ -700,7 +1051,7 @@ function mergeHarnessHooks(hooks, harness, dist) {
700
1051
  if (installedEvents.has(hook.event)) continue;
701
1052
  installedEvents.add(hook.event);
702
1053
  const entry = spec.configStyle === "nested" ? cmdHook(dist, hook.entry, hook.timeout) : {
703
- command: `node "${join10(dist, hook.entry)}"`,
1054
+ command: `node "${join13(dist, hook.entry)}"`,
704
1055
  ...hook.timeout ? { timeout: hook.timeout } : {}
705
1056
  };
706
1057
  hooks[hook.event] = mergeHookEvent(hooks[hook.event], entry);
@@ -715,17 +1066,17 @@ function stripHarnessHooks(hooks, harness) {
715
1066
  }
716
1067
  }
717
1068
  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");
1069
+ const src = join13(c.pkgRoot, "skill");
1070
+ if (!existsSync8(join13(src, "SKILL.md"))) return;
1071
+ const dst = join13(skillsBase, "hindsight-coding-agent");
721
1072
  mkdirSync3(skillsBase, { recursive: true });
722
1073
  cpSync2(src, dst, { recursive: true });
723
1074
  c.log?.(`skill installed at ${dst}`);
724
1075
  }
725
1076
  function uninstallSkill(c, skillsBase) {
726
- rmSync(join10(skillsBase, "hindsight-coding-agent"), { recursive: true, force: true });
1077
+ rmSync(join13(skillsBase, "hindsight-coding-agent"), { recursive: true, force: true });
727
1078
  }
728
- function onPath(bin) {
1079
+ function onPath2(bin) {
729
1080
  try {
730
1081
  execFileSync5("which", [bin], { stdio: "pipe" });
731
1082
  return true;
@@ -743,9 +1094,9 @@ function runClinePlugin(args) {
743
1094
  }
744
1095
  var opencode = {
745
1096
  name: "opencode",
746
- detect: (c) => onPath("opencode") || existsSync5(join10(c.home, ".config", "opencode")),
1097
+ detect: (c) => onPath2("opencode") || existsSync8(join13(c.home, ".config", "opencode")),
747
1098
  install(c) {
748
- const path = join10(c.home, ".config", "opencode", "opencode.json");
1099
+ const path = join13(c.home, ".config", "opencode", "opencode.json");
749
1100
  const cfg = readJson(path);
750
1101
  const plugins = Array.isArray(cfg.plugin) ? cfg.plugin : [];
751
1102
  cfg.plugin = [...plugins.filter((p) => !String(p).includes(MARKER)), c.pkgRoot];
@@ -753,8 +1104,8 @@ var opencode = {
753
1104
  c.log?.(`opencode: plugin registered in ${path}`);
754
1105
  },
755
1106
  uninstall(c) {
756
- const path = join10(c.home, ".config", "opencode", "opencode.json");
757
- if (!existsSync5(path)) return;
1107
+ const path = join13(c.home, ".config", "opencode", "opencode.json");
1108
+ if (!existsSync8(path)) return;
758
1109
  const cfg = readJson(path);
759
1110
  if (Array.isArray(cfg.plugin)) {
760
1111
  cfg.plugin = cfg.plugin.filter((p) => !String(p).includes(MARKER));
@@ -766,25 +1117,25 @@ var opencode = {
766
1117
  };
767
1118
  var KILO_CONFIG_CANDIDATES = ["kilo.jsonc", "kilo.json", "opencode.json"];
768
1119
  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");
1120
+ const dir = join13(c.home, ".config", "kilo");
1121
+ const existing = KILO_CONFIG_CANDIDATES.map((f) => join13(dir, f)).find((p) => existsSync8(p));
1122
+ return existing ?? join13(dir, "kilo.json");
772
1123
  }
773
1124
  var kilo = {
774
1125
  name: "kilo",
775
- detect: (c) => onPath("kilo") || existsSync5(join10(c.home, ".config", "kilo")),
1126
+ detect: (c) => onPath2("kilo") || existsSync8(join13(c.home, ".config", "kilo")),
776
1127
  install(c) {
777
1128
  const path = kiloConfigPath(c);
778
1129
  let cfg = {};
779
- if (existsSync5(path)) {
780
- const parsed = parseJsonc(readFileSync13(path, "utf8"));
1130
+ if (existsSync8(path)) {
1131
+ const parsed = parseJsonc(readFileSync15(path, "utf8"));
781
1132
  if (!parsed) {
782
1133
  c.log?.(`kilo: SKIPPED \u2014 could not parse ${path}; add the plugin entry manually`);
783
1134
  return;
784
1135
  }
785
1136
  cfg = parsed;
786
1137
  }
787
- const entry = pathToFileURL(join10(c.dist, "kilo.js")).href;
1138
+ const entry = pathToFileURL(join13(c.dist, "kilo.js")).href;
788
1139
  const plugins = Array.isArray(cfg.plugin) ? cfg.plugin : [];
789
1140
  cfg.plugin = [...plugins.filter((p) => !String(p).includes(MARKER)), entry];
790
1141
  writeJson(path, cfg);
@@ -792,8 +1143,8 @@ var kilo = {
792
1143
  },
793
1144
  uninstall(c) {
794
1145
  const path = kiloConfigPath(c);
795
- if (!existsSync5(path)) return;
796
- const cfg = parseJsonc(readFileSync13(path, "utf8"));
1146
+ if (!existsSync8(path)) return;
1147
+ const cfg = parseJsonc(readFileSync15(path, "utf8"));
797
1148
  if (!cfg || !Array.isArray(cfg.plugin)) return;
798
1149
  cfg.plugin = cfg.plugin.filter((p) => !String(p).includes(MARKER));
799
1150
  if (!cfg.plugin.length) delete cfg.plugin;
@@ -803,15 +1154,15 @@ var kilo = {
803
1154
  };
804
1155
  var claudeCode = {
805
1156
  name: "claude-code",
806
- detect: (c) => onPath("claude") || existsSync5(join10(c.home, ".claude")),
1157
+ detect: (c) => onPath2("claude") || existsSync8(join13(c.home, ".claude")),
807
1158
  install(c) {
808
- const path = join10(c.home, ".claude", "settings.json");
1159
+ const path = join13(c.home, ".claude", "settings.json");
809
1160
  const settings = readJson(path);
810
1161
  settings.hooks = settings.hooks ?? {};
811
1162
  mergeHarnessHooks(settings.hooks, "claude-code", c.dist);
812
1163
  writeJson(path, settings);
813
1164
  c.log?.(`claude-code: hooks merged into ${path}`);
814
- installSkill(c, join10(c.home, ".claude", "skills"));
1165
+ installSkill(c, join13(c.home, ".claude", "skills"));
815
1166
  const mcp = c.claudeMcp ?? defaultClaudeMcp;
816
1167
  mcp(["mcp", "remove", "--scope", "user", "hindsight"]);
817
1168
  if (mcp([
@@ -822,19 +1173,19 @@ var claudeCode = {
822
1173
  "hindsight",
823
1174
  "--",
824
1175
  "node",
825
- join10(c.dist, "mcp-server.js")
1176
+ join13(c.dist, "mcp-server.js")
826
1177
  ])) {
827
1178
  c.log?.("claude-code: MCP server registered (claude mcp add, user scope)");
828
1179
  } else {
829
1180
  c.log?.(
830
1181
  `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")}"`
1182
+ claude mcp add --scope user hindsight -- node "${join13(c.dist, "mcp-server.js")}"`
832
1183
  );
833
1184
  }
834
1185
  },
835
1186
  uninstall(c) {
836
- const path = join10(c.home, ".claude", "settings.json");
837
- if (existsSync5(path)) {
1187
+ const path = join13(c.home, ".claude", "settings.json");
1188
+ if (existsSync8(path)) {
838
1189
  const settings = readJson(path);
839
1190
  if (settings.hooks) {
840
1191
  stripHarnessHooks(settings.hooks, "claude-code");
@@ -844,7 +1195,7 @@ var claudeCode = {
844
1195
  }
845
1196
  const mcp = c.claudeMcp ?? defaultClaudeMcp;
846
1197
  mcp(["mcp", "remove", "--scope", "user", "hindsight"]);
847
- uninstallSkill(c, join10(c.home, ".claude", "skills"));
1198
+ uninstallSkill(c, join13(c.home, ".claude", "skills"));
848
1199
  c.log?.("claude-code: hooks + MCP registration + skill removed");
849
1200
  }
850
1201
  };
@@ -858,16 +1209,16 @@ function defaultClaudeMcp(args) {
858
1209
  }
859
1210
  var codex = {
860
1211
  name: "codex",
861
- detect: (c) => onPath("codex") || existsSync5(join10(c.home, ".codex")),
1212
+ detect: (c) => onPath2("codex") || existsSync8(join13(c.home, ".codex")),
862
1213
  install(c) {
863
- const hooksPath = join10(c.home, ".codex", "hooks.json");
1214
+ const hooksPath = join13(c.home, ".codex", "hooks.json");
864
1215
  const cfg = readJson(hooksPath);
865
1216
  cfg.hooks = cfg.hooks ?? {};
866
1217
  mergeHarnessHooks(cfg.hooks, "codex", c.dist);
867
1218
  writeJson(hooksPath, cfg);
868
1219
  c.log?.(`codex: hooks merged into ${hooksPath}`);
869
- const tomlPath = join10(c.home, ".codex", "config.toml");
870
- let toml = existsSync5(tomlPath) ? readFileSync13(tomlPath, "utf8") : "";
1220
+ const tomlPath = join13(c.home, ".codex", "config.toml");
1221
+ let toml = existsSync8(tomlPath) ? readFileSync15(tomlPath, "utf8") : "";
871
1222
  const additions = [];
872
1223
  if (!/^\s*(codex_hooks|hooks)\s*=/m.test(toml)) {
873
1224
  if (/^\[features\]/m.test(toml)) {
@@ -882,33 +1233,33 @@ var codex = {
882
1233
  additions.push(
883
1234
  `[mcp_servers.hindsight]
884
1235
  command = "node"
885
- args = ["${join10(c.dist, "mcp-server.js")}"]`
1236
+ args = ["${join13(c.dist, "mcp-server.js")}"]`
886
1237
  );
887
1238
  }
888
1239
  if (additions.length) {
889
- if (existsSync5(tomlPath) && !existsSync5(`${tomlPath}.hindsight-backup`)) {
1240
+ if (existsSync8(tomlPath) && !existsSync8(`${tomlPath}.hindsight-backup`)) {
890
1241
  copyFileSync(tomlPath, `${tomlPath}.hindsight-backup`);
891
1242
  }
892
- mkdirSync3(dirname7(tomlPath), { recursive: true });
1243
+ mkdirSync3(dirname8(tomlPath), { recursive: true });
893
1244
  writeFileSync2(tomlPath, `${toml.replace(/\n*$/, "\n\n")}${additions.join("\n\n")}
894
1245
  `);
895
1246
  c.log?.(`codex: appended ${additions.length} section(s) to ${tomlPath}`);
896
1247
  }
897
- installSkill(c, join10(c.home, ".agents", "skills"));
1248
+ installSkill(c, join13(c.home, ".agents", "skills"));
898
1249
  },
899
1250
  uninstall(c) {
900
- const hooksPath = join10(c.home, ".codex", "hooks.json");
901
- if (existsSync5(hooksPath)) {
1251
+ const hooksPath = join13(c.home, ".codex", "hooks.json");
1252
+ if (existsSync8(hooksPath)) {
902
1253
  const cfg = readJson(hooksPath);
903
1254
  if (cfg.hooks) {
904
1255
  stripHarnessHooks(cfg.hooks, "codex");
905
1256
  writeJson(hooksPath, cfg);
906
1257
  }
907
1258
  }
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");
1259
+ uninstallSkill(c, join13(c.home, ".agents", "skills"));
1260
+ const tomlPath = join13(c.home, ".codex", "config.toml");
1261
+ if (existsSync8(tomlPath)) {
1262
+ const toml = readFileSync15(tomlPath, "utf8");
912
1263
  const cleaned = toml.replace(
913
1264
  /\n?\[mcp_servers\.hindsight\]\ncommand = "node"\nargs = \[[^\]]*\]\n?/g,
914
1265
  "\n"
@@ -925,9 +1276,9 @@ var antigravity = {
925
1276
  // `agy` is the supported Antigravity CLI executable. Do not infer support from the
926
1277
  // legacy Gemini CLI's ~/.gemini state: both clients may leave files there, but only agy
927
1278
  // can consume this integration.
928
- detect: (c) => onPath("agy"),
1279
+ detect: (c) => onPath2("agy"),
929
1280
  install(c) {
930
- const hooksPath = join10(c.home, ".gemini", "config", "hooks.json");
1281
+ const hooksPath = join13(c.home, ".gemini", "config", "hooks.json");
931
1282
  const hooks = readJson(hooksPath);
932
1283
  for (const key of Object.keys(hooks)) {
933
1284
  if (key !== MARKER && key.includes(MARKER)) delete hooks[key];
@@ -938,30 +1289,30 @@ var antigravity = {
938
1289
  setOrDelete(hooks, event, stripOurs(hooks[event]));
939
1290
  }
940
1291
  writeJson(hooksPath, hooks);
941
- const mcpPath = join10(c.home, ".gemini", "config", "mcp_config.json");
1292
+ const mcpPath = join13(c.home, ".gemini", "config", "mcp_config.json");
942
1293
  const mcp = readJson(mcpPath);
943
1294
  mcp.mcpServers = {
944
1295
  ...mcp.mcpServers ?? {},
945
1296
  hindsight: {
946
1297
  command: "node",
947
- args: [join10(c.dist, "mcp-server.js")],
1298
+ args: [join13(c.dist, "mcp-server.js")],
948
1299
  env: { HINDSIGHT_MCP_HARNESS: "antigravity-cli" }
949
1300
  }
950
1301
  };
951
1302
  writeJson(mcpPath, mcp);
952
- const settingsPath = join10(c.home, ".gemini", "antigravity-cli", "settings.json");
1303
+ const settingsPath = join13(c.home, ".gemini", "antigravity-cli", "settings.json");
953
1304
  const settings = readJson(settingsPath);
954
1305
  if (!settings.statusLine) {
955
1306
  settings.statusLine = {
956
1307
  type: "command",
957
- command: `node "${join10(c.dist, "antigravity-statusline.js")}"`
1308
+ command: `node "${join13(c.dist, "antigravity-statusline.js")}"`
958
1309
  };
959
1310
  writeJson(settingsPath, settings);
960
1311
  c.log?.(`antigravity-cli: Hindsight status line enabled in ${settingsPath}`);
961
1312
  } else if (JSON.stringify(settings.statusLine).includes(MARKER)) {
962
1313
  settings.statusLine = {
963
1314
  type: "command",
964
- command: `node "${join10(c.dist, "antigravity-statusline.js")}"`
1315
+ command: `node "${join13(c.dist, "antigravity-statusline.js")}"`
965
1316
  };
966
1317
  writeJson(settingsPath, settings);
967
1318
  } else {
@@ -970,11 +1321,11 @@ var antigravity = {
970
1321
  );
971
1322
  }
972
1323
  c.log?.(`antigravity-cli: hooks merged into ${hooksPath}, MCP into ${mcpPath}`);
973
- installSkill(c, join10(c.home, ".gemini", "config", "skills"));
1324
+ installSkill(c, join13(c.home, ".gemini", "config", "skills"));
974
1325
  },
975
1326
  uninstall(c) {
976
- const hooksPath = join10(c.home, ".gemini", "config", "hooks.json");
977
- if (existsSync5(hooksPath)) {
1327
+ const hooksPath = join13(c.home, ".gemini", "config", "hooks.json");
1328
+ if (existsSync8(hooksPath)) {
978
1329
  const hooks = readJson(hooksPath);
979
1330
  if (hooks[MARKER]) {
980
1331
  stripHarnessHooks(hooks[MARKER], "antigravity-cli");
@@ -985,42 +1336,201 @@ var antigravity = {
985
1336
  }
986
1337
  writeJson(hooksPath, hooks);
987
1338
  }
988
- const mcpPath = join10(c.home, ".gemini", "config", "mcp_config.json");
989
- if (existsSync5(mcpPath)) {
1339
+ const mcpPath = join13(c.home, ".gemini", "config", "mcp_config.json");
1340
+ if (existsSync8(mcpPath)) {
990
1341
  const mcp = readJson(mcpPath);
991
1342
  if (mcp.mcpServers?.hindsight) {
992
1343
  delete mcp.mcpServers.hindsight;
993
1344
  writeJson(mcpPath, mcp);
994
1345
  }
995
1346
  }
996
- const settingsPath = join10(c.home, ".gemini", "antigravity-cli", "settings.json");
997
- if (existsSync5(settingsPath)) {
1347
+ const settingsPath = join13(c.home, ".gemini", "antigravity-cli", "settings.json");
1348
+ if (existsSync8(settingsPath)) {
998
1349
  const settings = readJson(settingsPath);
999
1350
  if (JSON.stringify(settings.statusLine ?? {}).includes(MARKER)) {
1000
1351
  delete settings.statusLine;
1001
1352
  writeJson(settingsPath, settings);
1002
1353
  }
1003
1354
  }
1004
- uninstallSkill(c, join10(c.home, ".gemini", "config", "skills"));
1355
+ uninstallSkill(c, join13(c.home, ".gemini", "config", "skills"));
1005
1356
  c.log?.("antigravity-cli: hooks + MCP entry + status line + skill removed");
1006
1357
  }
1007
1358
  };
1359
+ function pathNodeHasSqlite() {
1360
+ try {
1361
+ execFileSync5("node", ["-e", "require('node:sqlite')"], { stdio: "pipe", timeout: 1e4 });
1362
+ return true;
1363
+ } catch {
1364
+ return false;
1365
+ }
1366
+ }
1367
+ function pathNodeVersion() {
1368
+ try {
1369
+ return execFileSync5("node", ["-v"], { encoding: "utf8", stdio: "pipe" }).trim();
1370
+ } catch {
1371
+ return "not found";
1372
+ }
1373
+ }
1374
+ var SERVER_MODES = ["cloud", "self-hosted", "daemon"];
1375
+ function flagValue(args, name) {
1376
+ const inline = args.find((a) => a.startsWith(`--${name}=`));
1377
+ if (inline) return inline.slice(name.length + 3);
1378
+ const i = args.indexOf(`--${name}`);
1379
+ return i >= 0 ? args[i + 1] : void 0;
1380
+ }
1381
+ function flagValueArgs(args, names) {
1382
+ const taken = /* @__PURE__ */ new Set();
1383
+ for (const name of names) {
1384
+ const i = args.indexOf(`--${name}`);
1385
+ if (i >= 0 && args[i + 1] && !args[i + 1].startsWith("--")) taken.add(args[i + 1]);
1386
+ }
1387
+ return taken;
1388
+ }
1389
+ var CONFIG_RELATIVE = [".hindsight", "coding-agent.json"];
1390
+ function promptServerMode(c) {
1391
+ c.log?.(
1392
+ `
1393
+ Where should memory live?
1394
+ 1) Hindsight Cloud \u2014 hosted, needs an API token
1395
+ 2) Self-hosted server \u2014 a Hindsight server you already run
1396
+ 3) Local daemon (on-device) \u2014 runs hindsight-embed here; no account, needs uv + an LLM key
1397
+ `
1398
+ );
1399
+ const answer = readLineSync("Choose [1-3] (default 1): ").trim();
1400
+ if (answer === "" || answer === "1") return "cloud";
1401
+ if (answer === "2") return "self-hosted";
1402
+ if (answer === "3") return "daemon";
1403
+ c.log?.(`unrecognised choice "${answer}" \u2014 leaving the server config unchanged`);
1404
+ return void 0;
1405
+ }
1406
+ function readLineSync(prompt) {
1407
+ process.stdout.write(prompt);
1408
+ const buf = Buffer.alloc(1024);
1409
+ try {
1410
+ const n = readSync2(0, buf, 0, buf.length, null);
1411
+ return buf.subarray(0, n).toString("utf8");
1412
+ } catch {
1413
+ return "";
1414
+ }
1415
+ }
1416
+ function configureServer(c, args, installing) {
1417
+ const explicit = flagValue(args, "server");
1418
+ if (explicit && !SERVER_MODES.includes(explicit)) {
1419
+ c.log?.(`unknown --server "${explicit}" \u2014 expected one of: ${SERVER_MODES.join(", ")}`);
1420
+ return false;
1421
+ }
1422
+ const configPath = join13(c.home, ...CONFIG_RELATIVE);
1423
+ const existing = readJson(configPath);
1424
+ const alreadyConfigured = !!(existing.serverMode || existing.apiUrl);
1425
+ let mode = explicit;
1426
+ if (!mode) {
1427
+ if (alreadyConfigured) return true;
1428
+ const legacy = (c.readLegacy ?? readLegacyEndpoint)(c.home, installing);
1429
+ if (legacy) {
1430
+ const carried = { ...existing, serverMode: legacy.serverMode };
1431
+ if (legacy.apiUrl) carried.apiUrl = legacy.apiUrl;
1432
+ if (legacy.apiToken) carried.apiToken = legacy.apiToken;
1433
+ if (legacy.apiPort) carried.apiPort = legacy.apiPort;
1434
+ writeJson(configPath, carried);
1435
+ c.log?.(
1436
+ `server: ${legacy.serverMode}${legacy.apiUrl ? ` (${legacy.apiUrl})` : ""} \u2014 carried over from the ${legacy.harness} plugin (${legacy.source})
1437
+ Only the endpoint moves; conversations do not. To bring this repo's history
1438
+ across, re-run here with --import-conversations.`
1439
+ );
1440
+ if (legacy.serverMode === "daemon") reportDaemonPrereqs(c);
1441
+ return true;
1442
+ }
1443
+ if (!c.interactive) {
1444
+ c.log?.(
1445
+ `
1446
+ server: defaulting to Hindsight Cloud. Re-run with --server self-hosted|daemon to change,
1447
+ or edit ${configPath}.`
1448
+ );
1449
+ return true;
1450
+ }
1451
+ mode = promptServerMode(c);
1452
+ if (!mode) return true;
1453
+ }
1454
+ const next = { ...existing, serverMode: mode };
1455
+ if (mode === "cloud") {
1456
+ delete next.apiUrl;
1457
+ const token = flagValue(args, "api-token") ?? (c.interactive ? askToken(c) : void 0);
1458
+ if (token) next.apiToken = token;
1459
+ } else if (mode === "self-hosted") {
1460
+ const url = flagValue(args, "api-url") ?? (c.interactive ? readLineSync("Server URL (e.g. http://localhost:8888): ").trim() : void 0);
1461
+ if (!url) {
1462
+ c.log?.(
1463
+ `\u274C self-hosted mode needs a server URL \u2014 pass --api-url <url> (or set apiUrl in ${configPath}).`
1464
+ );
1465
+ return false;
1466
+ }
1467
+ next.apiUrl = url;
1468
+ const token = flagValue(args, "api-token");
1469
+ if (token) next.apiToken = token;
1470
+ } else {
1471
+ delete next.apiUrl;
1472
+ reportDaemonPrereqs(c);
1473
+ }
1474
+ writeJson(configPath, next);
1475
+ c.log?.(`server: ${mode} (${configPath})`);
1476
+ return true;
1477
+ }
1478
+ function askToken(c) {
1479
+ const token = readLineSync("API token (blank to set later): ").trim();
1480
+ if (!token) c.log?.(" no token set \u2014 add apiToken later if the server needs one");
1481
+ return token || void 0;
1482
+ }
1483
+ function reportDaemonPrereqs(c) {
1484
+ if (!(c.hasUvx ?? hasUvx)()) {
1485
+ c.log?.(
1486
+ `\u26A0\uFE0F \`uv\` is not on PATH. The daemon is fetched and run with it, so memory stays inert
1487
+ until you install it: https://docs.astral.sh/uv/`
1488
+ );
1489
+ }
1490
+ if (!(c.hasRust ?? hasRustToolchain)()) {
1491
+ c.log?.(
1492
+ `\u26A0\uFE0F macOS needs a current Rust toolchain to build the daemon's dependencies (litellm
1493
+ publishes no macOS wheel). Install from https://rustup.rs, then
1494
+ \`rustup default stable && rustup update\` \u2014 an OUT-OF-DATE toolchain fails too.`
1495
+ );
1496
+ }
1497
+ const llm = (c.detectLlm ?? detectLlm)();
1498
+ if (llm) {
1499
+ c.log?.(` local extraction will use ${llm.provider} (from ${llm.source})`);
1500
+ } else {
1501
+ c.log?.(
1502
+ `\u26A0\uFE0F No LLM available for local fact extraction. Set OPENAI_API_KEY, ANTHROPIC_API_KEY or
1503
+ GEMINI_API_KEY (or install the Claude Code CLI, which needs no key).`
1504
+ );
1505
+ }
1506
+ }
1008
1507
  var devin = {
1009
1508
  name: "devin-cli",
1010
- detect: (c) => onPath("devin") || existsSync5(join10(c.home, ".config", "devin")),
1509
+ detect: (c) => onPath2("devin") || existsSync8(join13(c.home, ".config", "devin")),
1510
+ // Devin is the ONLY harness whose hooks never hand over a transcript: they carry a session id and
1511
+ // nothing else, so retain can only work by reading the CLI's own sessions.db. That makes SQLite
1512
+ // support a hard prerequisite here — and one worth checking now, because the alternative is an
1513
+ // install that looks perfectly healthy and stores nothing, forever (#3125).
1514
+ preflight(c) {
1515
+ if ((c.nodeSqlite ?? pathNodeHasSqlite)()) return void 0;
1516
+ return `\`node:sqlite\` is unavailable in the \`node\` on PATH (${pathNodeVersion()}).
1517
+ Devin keeps its conversations in ~/.local/share/devin/cli/sessions.db and its hooks pass
1518
+ only a session id, so without SQLite nothing could ever be retained.
1519
+ Upgrade to Node 22.5 or newer (24 LTS recommended) and re-run this command.`;
1520
+ },
1011
1521
  install(c) {
1012
- const configPath = join10(c.home, ".config", "devin", "config.json");
1522
+ const configPath = join13(c.home, ".config", "devin", "config.json");
1013
1523
  const config = readJson(configPath);
1014
1524
  config.hooks = config.hooks ?? {};
1015
1525
  mergeHarnessHooks(config.hooks, "devin-cli", c.dist);
1016
1526
  writeJson(configPath, config);
1017
- const mcpPath = join10(c.home, ".config", "devin", "mcp_config.json");
1527
+ const mcpPath = join13(c.home, ".config", "devin", "mcp_config.json");
1018
1528
  const mcp = readJson(mcpPath);
1019
1529
  mcp.mcpServers = {
1020
1530
  ...mcp.mcpServers ?? {},
1021
1531
  hindsight: {
1022
1532
  command: "node",
1023
- args: [join10(c.dist, "mcp-server.js")],
1533
+ args: [join13(c.dist, "mcp-server.js")],
1024
1534
  env: { HINDSIGHT_MCP_HARNESS: "devin-cli" }
1025
1535
  }
1026
1536
  };
@@ -1028,8 +1538,8 @@ var devin = {
1028
1538
  c.log?.(`devin-cli: hooks merged into ${configPath}, MCP into ${mcpPath}`);
1029
1539
  },
1030
1540
  uninstall(c) {
1031
- const configPath = join10(c.home, ".config", "devin", "config.json");
1032
- if (existsSync5(configPath)) {
1541
+ const configPath = join13(c.home, ".config", "devin", "config.json");
1542
+ if (existsSync8(configPath)) {
1033
1543
  const config = readJson(configPath);
1034
1544
  if (config.hooks) {
1035
1545
  stripHarnessHooks(config.hooks, "devin-cli");
@@ -1037,8 +1547,8 @@ var devin = {
1037
1547
  writeJson(configPath, config);
1038
1548
  }
1039
1549
  }
1040
- const mcpPath = join10(c.home, ".config", "devin", "mcp_config.json");
1041
- if (existsSync5(mcpPath)) {
1550
+ const mcpPath = join13(c.home, ".config", "devin", "mcp_config.json");
1551
+ if (existsSync8(mcpPath)) {
1042
1552
  const mcp = readJson(mcpPath);
1043
1553
  if (mcp.mcpServers?.hindsight) {
1044
1554
  delete mcp.mcpServers.hindsight;
@@ -1050,26 +1560,26 @@ var devin = {
1050
1560
  };
1051
1561
  var cursor = {
1052
1562
  name: "cursor-cli",
1053
- detect: (c) => onPath("cursor-agent") || existsSync5(join10(c.home, ".cursor")),
1563
+ detect: (c) => onPath2("cursor-agent") || existsSync8(join13(c.home, ".cursor")),
1054
1564
  install(c) {
1055
- const hooksPath = join10(c.home, ".cursor", "hooks.json");
1565
+ const hooksPath = join13(c.home, ".cursor", "hooks.json");
1056
1566
  const cfg = readJson(hooksPath);
1057
1567
  cfg.hooks = cfg.hooks ?? {};
1058
1568
  mergeHarnessHooks(cfg.hooks, "cursor-cli", c.dist);
1059
1569
  writeJson(hooksPath, cfg);
1060
- const mcpPath = join10(c.home, ".cursor", "mcp.json");
1570
+ const mcpPath = join13(c.home, ".cursor", "mcp.json");
1061
1571
  const mcp = readJson(mcpPath);
1062
1572
  mcp.mcpServers = {
1063
1573
  ...mcp.mcpServers ?? {},
1064
- hindsight: { command: "node", args: [join10(c.dist, "mcp-server.js")] }
1574
+ hindsight: { command: "node", args: [join13(c.dist, "mcp-server.js")] }
1065
1575
  };
1066
1576
  writeJson(mcpPath, mcp);
1067
1577
  c.log?.(`cursor-cli: hooks merged into ${hooksPath}, MCP into ${mcpPath}`);
1068
- installSkill(c, join10(c.home, ".cursor", "skills"));
1578
+ installSkill(c, join13(c.home, ".cursor", "skills"));
1069
1579
  },
1070
1580
  uninstall(c) {
1071
- const hooksPath = join10(c.home, ".cursor", "hooks.json");
1072
- if (existsSync5(hooksPath)) {
1581
+ const hooksPath = join13(c.home, ".cursor", "hooks.json");
1582
+ if (existsSync8(hooksPath)) {
1073
1583
  const cfg = readJson(hooksPath);
1074
1584
  if (cfg.hooks) {
1075
1585
  stripHarnessHooks(cfg.hooks, "cursor-cli");
@@ -1077,49 +1587,49 @@ var cursor = {
1077
1587
  writeJson(hooksPath, cfg);
1078
1588
  }
1079
1589
  }
1080
- const mcpPath = join10(c.home, ".cursor", "mcp.json");
1081
- if (existsSync5(mcpPath)) {
1590
+ const mcpPath = join13(c.home, ".cursor", "mcp.json");
1591
+ if (existsSync8(mcpPath)) {
1082
1592
  const mcp = readJson(mcpPath);
1083
1593
  if (mcp.mcpServers?.hindsight) {
1084
1594
  delete mcp.mcpServers.hindsight;
1085
1595
  writeJson(mcpPath, mcp);
1086
1596
  }
1087
1597
  }
1088
- uninstallSkill(c, join10(c.home, ".cursor", "skills"));
1598
+ uninstallSkill(c, join13(c.home, ".cursor", "skills"));
1089
1599
  c.log?.("cursor-cli: hooks + MCP entry + skill removed");
1090
1600
  }
1091
1601
  };
1092
1602
  var copilot = {
1093
1603
  name: "copilot-cli",
1094
- detect: (c) => onPath("copilot") || existsSync5(join10(c.home, ".copilot")),
1604
+ detect: (c) => onPath2("copilot") || existsSync8(join13(c.home, ".copilot")),
1095
1605
  install(c) {
1096
- const hooksPath = join10(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
1606
+ const hooksPath = join13(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
1097
1607
  const hooks = {};
1098
1608
  mergeHarnessHooks(hooks, "copilot-cli", c.dist);
1099
1609
  writeJson(hooksPath, { version: 1, hooks });
1100
- const mcpPath = join10(c.home, ".copilot", "mcp-config.json");
1610
+ const mcpPath = join13(c.home, ".copilot", "mcp-config.json");
1101
1611
  const mcp = readJson(mcpPath);
1102
1612
  mcp.mcpServers = {
1103
1613
  ...mcp.mcpServers ?? {},
1104
- hindsight: { command: "node", args: [join10(c.dist, "mcp-server.js")] }
1614
+ hindsight: { command: "node", args: [join13(c.dist, "mcp-server.js")] }
1105
1615
  };
1106
1616
  writeJson(mcpPath, mcp);
1107
- installSkill(c, join10(c.home, ".copilot", "skills"));
1617
+ installSkill(c, join13(c.home, ".copilot", "skills"));
1108
1618
  c.log?.(`copilot-cli: hooks installed at ${hooksPath}, MCP into ${mcpPath}`);
1109
1619
  },
1110
1620
  uninstall(c) {
1111
- rmSync(join10(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
1621
+ rmSync(join13(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
1112
1622
  force: true
1113
1623
  });
1114
- const mcpPath = join10(c.home, ".copilot", "mcp-config.json");
1115
- if (existsSync5(mcpPath)) {
1624
+ const mcpPath = join13(c.home, ".copilot", "mcp-config.json");
1625
+ if (existsSync8(mcpPath)) {
1116
1626
  const mcp = readJson(mcpPath);
1117
1627
  if (mcp.mcpServers?.hindsight) {
1118
1628
  delete mcp.mcpServers.hindsight;
1119
1629
  writeJson(mcpPath, mcp);
1120
1630
  }
1121
1631
  }
1122
- uninstallSkill(c, join10(c.home, ".copilot", "skills"));
1632
+ uninstallSkill(c, join13(c.home, ".copilot", "skills"));
1123
1633
  c.log?.("copilot-cli: hooks + MCP entry + skill removed");
1124
1634
  }
1125
1635
  };
@@ -1128,12 +1638,12 @@ var GROK_MARKER_END = "# HINDSIGHT_CODING_AGENTS_GROK_END";
1128
1638
  var GROK_BLOCK_RE = new RegExp(`\\n?${GROK_MARKER_START}[\\s\\S]*?${GROK_MARKER_END}\\n?`);
1129
1639
  var grok = {
1130
1640
  name: "grok-build",
1131
- detect: (c) => onPath("grok") || existsSync5(join10(c.home, ".grok")),
1641
+ detect: (c) => onPath2("grok") || existsSync8(join13(c.home, ".grok")),
1132
1642
  install(c) {
1133
- const path = join10(c.home, ".grok", "config.toml");
1134
- const existing = existsSync5(path) ? readFileSync13(path, "utf8") : "";
1643
+ const path = join13(c.home, ".grok", "config.toml");
1644
+ const existing = existsSync8(path) ? readFileSync15(path, "utf8") : "";
1135
1645
  const withoutOurs = existing.replace(GROK_BLOCK_RE, "\n");
1136
- const command = (entry) => JSON.stringify(`node "${join10(c.dist, entry)}"`);
1646
+ const command = (entry) => JSON.stringify(`node "${join13(c.dist, entry)}"`);
1137
1647
  const tomlString = (value) => JSON.stringify(value);
1138
1648
  const block = `
1139
1649
  ${GROK_MARKER_START}
@@ -1157,24 +1667,24 @@ ${GROK_MARKER_START}
1157
1667
 
1158
1668
  [mcp_servers.hindsight]
1159
1669
  command = "node"
1160
- args = [${tomlString(join10(c.dist, "mcp-server.js"))}]
1670
+ args = [${tomlString(join13(c.dist, "mcp-server.js"))}]
1161
1671
  ${GROK_MARKER_END}
1162
1672
  `;
1163
- if (existsSync5(path) && !existsSync5(`${path}.hindsight-backup`))
1673
+ if (existsSync8(path) && !existsSync8(`${path}.hindsight-backup`))
1164
1674
  copyFileSync(path, `${path}.hindsight-backup`);
1165
- mkdirSync3(dirname7(path), { recursive: true });
1675
+ mkdirSync3(dirname8(path), { recursive: true });
1166
1676
  writeFileSync2(path, `${withoutOurs.replace(/\n*$/, "\n")}${block}`);
1167
- installSkill(c, join10(c.home, ".grok", "skills"));
1677
+ installSkill(c, join13(c.home, ".grok", "skills"));
1168
1678
  c.log?.(`grok-build: native hooks + MCP installed in ${path}`);
1169
1679
  },
1170
1680
  uninstall(c) {
1171
- const path = join10(c.home, ".grok", "config.toml");
1172
- if (existsSync5(path)) {
1173
- const existing = readFileSync13(path, "utf8");
1681
+ const path = join13(c.home, ".grok", "config.toml");
1682
+ if (existsSync8(path)) {
1683
+ const existing = readFileSync15(path, "utf8");
1174
1684
  const cleaned = existing.replace(GROK_BLOCK_RE, "\n");
1175
1685
  if (cleaned !== existing) writeFileSync2(path, cleaned);
1176
1686
  }
1177
- uninstallSkill(c, join10(c.home, ".grok", "skills"));
1687
+ uninstallSkill(c, join13(c.home, ".grok", "skills"));
1178
1688
  c.log?.("grok-build: native hooks + MCP + skill removed");
1179
1689
  }
1180
1690
  };
@@ -1182,17 +1692,17 @@ var CLINE_HOOK_MARKER = "HINDSIGHT_CODING_AGENTS_CLINE";
1182
1692
  var CLINE_OLD_HOOK_EVENTS = ["TaskStart", "UserPromptSubmit", "TaskComplete"];
1183
1693
  var CLINE_PLUGIN_NAME = "@vectorize-io/hindsight-coding-agents";
1184
1694
  function removeLegacyClineHooks(c) {
1185
- const hooksDir = join10(c.home, "Documents", "Cline", "Hooks");
1695
+ const hooksDir = join13(c.home, "Documents", "Cline", "Hooks");
1186
1696
  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)) {
1697
+ const path = join13(hooksDir, event);
1698
+ if (existsSync8(path) && readFileSync15(path, "utf8").includes(CLINE_HOOK_MARKER)) {
1189
1699
  rmSync(path, { force: true });
1190
1700
  }
1191
1701
  }
1192
1702
  }
1193
1703
  var cline = {
1194
1704
  name: "cline-cli",
1195
- detect: (c) => onPath("cline") || existsSync5(join10(c.home, ".cline")),
1705
+ detect: (c) => onPath2("cline") || existsSync8(join13(c.home, ".cline")),
1196
1706
  install(c) {
1197
1707
  removeLegacyClineHooks(c);
1198
1708
  const installed = (c.clinePlugin ?? runClinePlugin)([
@@ -1201,18 +1711,18 @@ var cline = {
1201
1711
  "--force",
1202
1712
  c.pkgRoot
1203
1713
  ]);
1204
- const mcpPath = join10(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
1714
+ const mcpPath = join13(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
1205
1715
  const mcp = readJson(mcpPath);
1206
1716
  mcp.mcpServers = {
1207
1717
  ...mcp.mcpServers ?? {},
1208
1718
  hindsight: {
1209
1719
  command: "node",
1210
- args: [join10(c.dist, "mcp-server.js")],
1720
+ args: [join13(c.dist, "mcp-server.js")],
1211
1721
  env: { HINDSIGHT_MCP_HARNESS: "cline-cli" }
1212
1722
  }
1213
1723
  };
1214
1724
  writeJson(mcpPath, mcp);
1215
- installSkill(c, join10(c.home, ".cline", "data", "settings", "skills"));
1725
+ installSkill(c, join13(c.home, ".cline", "data", "settings", "skills"));
1216
1726
  c.log?.(
1217
1727
  installed ? "cline-cli: native plugin + MCP + skill installed" : `cline-cli: MCP + skill installed; run: cline plugin install --force "${c.pkgRoot}"`
1218
1728
  );
@@ -1220,15 +1730,15 @@ var cline = {
1220
1730
  uninstall(c) {
1221
1731
  removeLegacyClineHooks(c);
1222
1732
  (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)) {
1733
+ const mcpPath = join13(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
1734
+ if (existsSync8(mcpPath)) {
1225
1735
  const mcp = readJson(mcpPath);
1226
1736
  if (mcp.mcpServers?.hindsight) {
1227
1737
  delete mcp.mcpServers.hindsight;
1228
1738
  writeJson(mcpPath, mcp);
1229
1739
  }
1230
1740
  }
1231
- uninstallSkill(c, join10(c.home, ".cline", "data", "settings", "skills"));
1741
+ uninstallSkill(c, join13(c.home, ".cline", "data", "settings", "skills"));
1232
1742
  c.log?.("cline-cli: native plugin + MCP + skill removed");
1233
1743
  }
1234
1744
  };
@@ -1245,17 +1755,53 @@ var INSTALLERS = [
1245
1755
  cline
1246
1756
  ];
1247
1757
  var HARNESS_ALIASES = { agy: "antigravity-cli" };
1758
+ function importConversations(harness, ctx) {
1759
+ const repo = process.cwd();
1760
+ const found = importLocalHistory(harness, repo);
1761
+ if (!found.supported) {
1762
+ ctx.log?.(`${harness}: --import-conversations skipped \u2014 ${found.reason}`);
1763
+ return;
1764
+ }
1765
+ if (found.unattributed) {
1766
+ ctx.log?.(
1767
+ `${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`
1768
+ );
1769
+ }
1770
+ if (!found.sessions.length) {
1771
+ ctx.log?.(`${harness}: no past sessions found on disk for ${repo}`);
1772
+ return;
1773
+ }
1774
+ const turns = found.sessions.reduce((n, s) => n + s.turns.length, 0);
1775
+ const file = join13(mkdtempSync(join13(tmpdir3(), "hindsight-import-")), "conversations.json");
1776
+ writeFileSync2(file, JSON.stringify(found.sessions));
1777
+ ctx.log?.(
1778
+ `${harness}: importing ${found.sessions.length} past sessions (${turns} turns) from ${repo} \u2014 this runs extraction and may take a while`
1779
+ );
1780
+ try {
1781
+ execFileSync5("node", [join13(ctx.dist, "deepen.js"), "--repo", repo, "--conversations", file], {
1782
+ stdio: "inherit"
1783
+ });
1784
+ } catch {
1785
+ ctx.log?.(`${harness}: conversation import did not finish \u2014 re-run it any time with:`);
1786
+ ctx.log?.(` node "${join13(ctx.dist, "deepen.js")}" --repo "${repo}" --conversations "${file}"`);
1787
+ }
1788
+ }
1248
1789
  function run(argv, ctx) {
1249
- const [command, ...names] = argv;
1790
+ const [command, ...rawArgs] = argv;
1791
+ const importHistory = rawArgs.includes("--import-conversations");
1792
+ const valueArgs = flagValueArgs(rawArgs, ["server", "api-url", "api-token"]);
1793
+ const names = rawArgs.filter((a) => !a.startsWith("--") && !valueArgs.has(a));
1250
1794
  if (command === "install" && /\/(_npx|\.npm\/_npx|dlx-)\/|\/_cacache\//.test(ctx.pkgRoot)) {
1251
1795
  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"
1796
+ "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
1797
  );
1254
1798
  return 1;
1255
1799
  }
1256
1800
  if (command !== "install" && command !== "uninstall") {
1257
1801
  ctx.log?.(
1258
1802
  `usage: hindsight-coding-agents <install|uninstall> <all|harness...>
1803
+ [--server cloud|self-hosted|daemon] [--api-url <url>] [--api-token <token>]
1804
+ [--import-conversations]
1259
1805
  all every agent detected on this machine
1260
1806
  harness ${INSTALLERS.map((i) => i.name).join(", ")} (agy aliases antigravity-cli)`
1261
1807
  );
@@ -1290,10 +1836,37 @@ harnesses: ${INSTALLERS.map((i) => i.name).join(", ")} (agy aliases antigravity-
1290
1836
  );
1291
1837
  return 1;
1292
1838
  }
1293
- for (const t of targets) t[command](ctx);
1839
+ if (command === "install" && !configureServer(
1840
+ ctx,
1841
+ rawArgs,
1842
+ targets.map((t) => t.name)
1843
+ ))
1844
+ return 1;
1845
+ const blocked = /* @__PURE__ */ new Set();
1846
+ if (command === "install") {
1847
+ for (const t of targets) {
1848
+ const problem = t.preflight?.(ctx);
1849
+ if (!problem) continue;
1850
+ ctx.log?.(`
1851
+ \u274C ${t.name}: ${problem}`);
1852
+ blocked.add(t.name);
1853
+ }
1854
+ }
1855
+ const runnable = targets.filter((t) => !blocked.has(t.name));
1856
+ for (const t of runnable) t[command](ctx);
1857
+ if (command === "install" && importHistory) {
1858
+ for (const t of runnable) importConversations(t.name, ctx);
1859
+ }
1860
+ if (blocked.size) {
1861
+ ctx.log?.(
1862
+ `
1863
+ \u274C not installed: ${[...blocked].join(", ")} \u2014 this machine can't run ${blocked.size > 1 ? "them" : "it"} (see above).`
1864
+ );
1865
+ return 1;
1866
+ }
1294
1867
  ctx.log?.(
1295
1868
  command === "install" ? `
1296
- \u2705 installed. Configure the server in ~/.hindsight/coding-agent.json (apiUrl/apiToken) and start a session.` : `
1869
+ \u2705 installed. Start a session \u2014 settings live in ~/.hindsight/coding-agent.json.` : `
1297
1870
  \u2705 uninstalled.`
1298
1871
  );
1299
1872
  return 0;
@@ -1307,12 +1880,14 @@ var mainPath = process.argv[1] ? (() => {
1307
1880
  })() : void 0;
1308
1881
  var isMain = mainPath && import.meta.url === pathToFileURL(mainPath).href;
1309
1882
  if (isMain || mainPath?.endsWith("installer.js")) {
1310
- const dist = dirname7(fileURLToPath4(import.meta.url));
1883
+ const dist = dirname8(fileURLToPath5(import.meta.url));
1311
1884
  process.exit(
1312
1885
  run(process.argv.slice(2), {
1313
- home: homedir7(),
1314
- pkgRoot: dirname7(dist),
1886
+ home: homedir9(),
1887
+ pkgRoot: dirname8(dist),
1315
1888
  dist,
1889
+ // Only a real terminal gets prompted; piped/CI installs take the documented default.
1890
+ interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),
1316
1891
  log: (m) => console.log(m)
1317
1892
  })
1318
1893
  );
@@ -1321,6 +1896,8 @@ export {
1321
1896
  INSTALLERS,
1322
1897
  KILO_CONFIG_CANDIDATES,
1323
1898
  MARKER,
1899
+ flagValue,
1900
+ flagValueArgs,
1324
1901
  parseJsonc,
1325
1902
  run
1326
1903
  };