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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +19 -5
  2. package/dist/antigravity-hook.js +87 -83
  3. package/dist/antigravity-statusline.js +32 -22
  4. package/dist/antigravity-stop-hook.js +160 -71
  5. package/dist/claude-hook.js +87 -83
  6. package/dist/claude-sessionstart-hook.js +111 -97
  7. package/dist/claude-stop-hook.js +160 -71
  8. package/dist/cline.js +161 -88
  9. package/dist/codex-hook.js +87 -83
  10. package/dist/codex-sessionstart-hook.js +111 -97
  11. package/dist/codex-stop-hook.js +160 -71
  12. package/dist/copilot-hook.js +87 -83
  13. package/dist/copilot-sessionstart-hook.js +111 -97
  14. package/dist/copilot-stop-hook.js +160 -71
  15. package/dist/cursor-hook.js +87 -83
  16. package/dist/cursor-sessionstart-hook.js +111 -97
  17. package/dist/cursor-stop-hook.js +160 -71
  18. package/dist/daemon-start.js +28 -18
  19. package/dist/dcode-hook.js +87 -83
  20. package/dist/dcode-sessionstart-hook.js +111 -97
  21. package/dist/dcode-stop-hook.js +160 -71
  22. package/dist/deepen.js +42 -32
  23. package/dist/devin-hook.js +87 -83
  24. package/dist/devin-sessionstart-hook.js +111 -97
  25. package/dist/devin-stop-hook.js +160 -71
  26. package/dist/droid-hook.js +87 -83
  27. package/dist/droid-sessionstart-hook.js +111 -97
  28. package/dist/droid-stop-hook.js +160 -71
  29. package/dist/dsh.js +159 -87
  30. package/dist/grok-hook.js +87 -83
  31. package/dist/grok-sessionstart-hook.js +111 -97
  32. package/dist/grok-stop-hook.js +160 -71
  33. package/dist/hindsight-seed.js +32 -22
  34. package/dist/index.js +162 -90
  35. package/dist/installer.js +308 -214
  36. package/dist/kilo.js +162 -90
  37. package/dist/mcp-server.js +41 -31
  38. package/dist/opencode2.js +161 -89
  39. package/dist/pi.js +161 -89
  40. package/dist/prime-agent.js +161 -89
  41. package/dist/qwen-hook.js +87 -83
  42. package/dist/qwen-sessionstart-hook.js +111 -97
  43. package/dist/qwen-stop-hook.js +160 -71
  44. package/dist/status.js +38 -28
  45. package/dist/zcode-hook.js +87 -83
  46. package/dist/zcode-sessionstart-hook.js +111 -97
  47. package/dist/zcode-stop-hook.js +160 -71
  48. package/package.json +1 -1
  49. package/plugin.json +1 -1
  50. package/skill/SKILL.md +19 -5
package/dist/installer.js CHANGED
@@ -8,15 +8,15 @@ import {
8
8
  existsSync as existsSync10,
9
9
  mkdirSync as mkdirSync6,
10
10
  mkdtempSync as mkdtempSync2,
11
- readFileSync as readFileSync14,
11
+ readFileSync as readFileSync15,
12
12
  readSync as readSync4,
13
13
  realpathSync as realpathSync3,
14
14
  rmSync as rmSync3,
15
15
  writeFileSync as writeFileSync4
16
16
  } from "fs";
17
- import { homedir as homedir10, tmpdir as tmpdir6 } from "os";
17
+ import { homedir as homedir11, tmpdir as tmpdir5 } from "os";
18
18
  import { isatty } from "tty";
19
- import { dirname as dirname11, join as join18 } from "path";
19
+ import { dirname as dirname11, join as join20 } from "path";
20
20
  import { fileURLToPath as fileURLToPath6, pathToFileURL } from "url";
21
21
 
22
22
  // node_modules/jsonc-parser/lib/esm/impl/scanner.js
@@ -1997,30 +1997,40 @@ import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
1997
1997
 
1998
1998
  // src/core/bank.ts
1999
1999
  import { existsSync } from "fs";
2000
- import { homedir } from "os";
2001
- import { basename, dirname as dirname3, join as join3, normalize, sep } from "path";
2000
+ import { homedir as homedir2 } from "os";
2001
+ import { basename, dirname as dirname3, join as join4, normalize, sep } from "path";
2002
2002
 
2003
2003
  // src/core/diag.ts
2004
- import { appendFileSync as appendFileSync2 } from "fs";
2004
+ import { join as join2 } from "path";
2005
2005
 
2006
2006
  // src/core/log.ts
2007
- import { appendFileSync, mkdirSync } from "fs";
2008
- import { tmpdir } from "os";
2007
+ import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
2008
+ import { homedir } from "os";
2009
2009
  import { dirname, join } from "path";
2010
+ function logsDir() {
2011
+ return join(homedir(), ".hindsight", "coding-agents-logs");
2012
+ }
2013
+ var LOG_MAX_BYTES = 10 * 1024 * 1024;
2014
+ function appendLogLine(file, text) {
2015
+ mkdirSync(dirname(file), { recursive: true, mode: 448 });
2016
+ try {
2017
+ if (statSync(file).size >= LOG_MAX_BYTES) renameSync(file, `${file}.1`);
2018
+ } catch {
2019
+ }
2020
+ appendFileSync(file, text, { mode: 384 });
2021
+ }
2010
2022
  var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
2011
2023
  var current = ["debug", "info", "warn", "error"].find(
2012
2024
  (l) => l === process.env.HINDSIGHT_LOG_LEVEL
2013
2025
  ) ?? "info";
2014
2026
  function logFilePath() {
2015
- return process.env.HINDSIGHT_LOG_FILE || join(tmpdir(), "hindsight-coding-agent", "plugin.log");
2027
+ return process.env.HINDSIGHT_LOG_FILE || join(logsDir(), "plugin.log");
2016
2028
  }
2017
2029
  function write(level, scope, msg, extra) {
2018
2030
  if (WEIGHT[level] < WEIGHT[current]) return;
2019
2031
  try {
2020
- const file = logFilePath();
2021
- mkdirSync(dirname(file), { recursive: true });
2022
- appendFileSync(
2023
- file,
2032
+ appendLogLine(
2033
+ logFilePath(),
2024
2034
  `${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
2025
2035
  );
2026
2036
  } catch {
@@ -2035,12 +2045,12 @@ var log = {
2035
2045
 
2036
2046
  // src/core/diag.ts
2037
2047
  function diagFilePath() {
2038
- return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
2048
+ return process.env.HINDSIGHT_DIAG_FILE || join2(logsDir(), "diag.jsonl");
2039
2049
  }
2040
2050
  function diag(harness, event, extra = {}) {
2041
2051
  log.debug(harness, `diag:${event}`, extra);
2042
2052
  try {
2043
- appendFileSync2(
2053
+ appendLogLine(
2044
2054
  diagFilePath(),
2045
2055
  JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
2046
2056
  );
@@ -2050,16 +2060,16 @@ function diag(harness, event, extra = {}) {
2050
2060
 
2051
2061
  // src/core/git-layout.ts
2052
2062
  import { lstatSync, readFileSync, realpathSync } from "fs";
2053
- import { dirname as dirname2, isAbsolute, join as join2, resolve } from "path";
2063
+ import { dirname as dirname2, isAbsolute, join as join3, resolve } from "path";
2054
2064
 
2055
2065
  // src/core/config.ts
2056
2066
  import { readFileSync as readFileSync2 } from "fs";
2057
- import { homedir as homedir2 } from "os";
2058
- import { join as join6 } from "path";
2067
+ import { homedir as homedir3 } from "os";
2068
+ import { join as join7 } from "path";
2059
2069
 
2060
2070
  // src/core/seed.ts
2061
2071
  import { spawn as realSpawn } from "child_process";
2062
- import { dirname as dirname4, join as join4 } from "path";
2072
+ import { dirname as dirname4, join as join5 } from "path";
2063
2073
  import { fileURLToPath } from "url";
2064
2074
 
2065
2075
  // src/core/missions.ts
@@ -2067,14 +2077,14 @@ import { createHash } from "crypto";
2067
2077
 
2068
2078
  // src/core/util.ts
2069
2079
  import { accessSync, constants } from "fs";
2070
- import { delimiter, join as join5 } from "path";
2080
+ import { delimiter, join as join6 } from "path";
2071
2081
 
2072
2082
  // src/core/hindsight.ts
2073
2083
  var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
2074
2084
  var RETRY_AFTER_CEILING_MS = 60 * 1e3;
2075
2085
 
2076
2086
  // src/core/config.ts
2077
- var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join6(homedir2(), ".hindsight", "coding-agent.json");
2087
+ var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join7(homedir3(), ".hindsight", "coding-agent.json");
2078
2088
  var DEFAULT_DAEMON_PORT = 9077;
2079
2089
 
2080
2090
  // src/core/brand.ts
@@ -2092,14 +2102,14 @@ function brandWord() {
2092
2102
  }
2093
2103
 
2094
2104
  // src/core/session-cache.ts
2095
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync, rmSync, writeFileSync } from "fs";
2096
- import { tmpdir as tmpdir2 } from "os";
2097
- import { dirname as dirname5, join as join7 } from "path";
2105
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, rmSync, writeFileSync } from "fs";
2106
+ import { tmpdir } from "os";
2107
+ import { dirname as dirname5, join as join8 } from "path";
2098
2108
 
2099
2109
  // src/core/turn-journal.ts
2100
- import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, statSync } from "fs";
2101
- import { tmpdir as tmpdir3 } from "os";
2102
- import { dirname as dirname6, join as join8 } from "path";
2110
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync4, statSync as statSync2 } from "fs";
2111
+ import { tmpdir as tmpdir2 } from "os";
2112
+ import { dirname as dirname6, join as join9 } from "path";
2103
2113
 
2104
2114
  // src/core/transcript-util.ts
2105
2115
  var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
@@ -2140,7 +2150,7 @@ function actionLine(tool, input) {
2140
2150
  var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
2141
2151
 
2142
2152
  // src/core/retain-hook.ts
2143
- import { readFileSync as readFileSync6 } from "fs";
2153
+ import { readFileSync as readFileSync7 } from "fs";
2144
2154
 
2145
2155
  // src/core/retain-cursor.ts
2146
2156
  import { createHash as createHash2 } from "crypto";
@@ -2152,7 +2162,7 @@ import { createHash as createHash3 } from "crypto";
2152
2162
 
2153
2163
  // src/core/daemon.ts
2154
2164
  import { execFileSync, spawn as realSpawn2 } from "child_process";
2155
- import { dirname as dirname7, join as join9 } from "path";
2165
+ import { dirname as dirname7, join as join10 } from "path";
2156
2166
  import { fileURLToPath as fileURLToPath2 } from "url";
2157
2167
  function hasRustToolchain() {
2158
2168
  if (process.platform !== "darwin") return true;
@@ -2220,7 +2230,7 @@ function onPath(bin) {
2220
2230
  import { basename as basename2 } from "path";
2221
2231
 
2222
2232
  // src/core/jsonl.ts
2223
- import { closeSync, openSync, readSync, statSync as statSync2 } from "fs";
2233
+ import { closeSync, openSync, readSync, statSync as statSync3 } from "fs";
2224
2234
  import { StringDecoder } from "string_decoder";
2225
2235
  var CHUNK_BYTES = 64 * 1024;
2226
2236
  var MAX_TRANSCRIPT_BYTES = 32 * 1024 * 1024;
@@ -2228,7 +2238,7 @@ function readJsonlTail(path, opts) {
2228
2238
  const maxBytes = opts.maxBytes ?? MAX_TRANSCRIPT_BYTES;
2229
2239
  let size;
2230
2240
  try {
2231
- size = statSync2(path).size;
2241
+ size = statSync3(path).size;
2232
2242
  } catch {
2233
2243
  return { lines: emptyLines(), skippedBytes: 0 };
2234
2244
  }
@@ -2331,8 +2341,87 @@ function readClaudeTranscript(path) {
2331
2341
  return turns;
2332
2342
  }
2333
2343
 
2344
+ // src/core/usage.ts
2345
+ import { readFileSync as readFileSync6 } from "fs";
2346
+ import { join as join11 } from "path";
2347
+ function usageFilePath() {
2348
+ return process.env.HINDSIGHT_USAGE_FILE || join11(logsDir(), "usage.jsonl");
2349
+ }
2350
+ var RETRIEVAL_TOOLS = /* @__PURE__ */ new Set([
2351
+ "hindsight_search_knowledge_pages",
2352
+ "hindsight_list_knowledge_pages",
2353
+ "hindsight_read_knowledge_page",
2354
+ "hindsight_reflect"
2355
+ ]);
2356
+ function isUsageLine(v) {
2357
+ const r = v;
2358
+ return typeof r === "object" && r !== null && typeof r.harness === "string" && typeof r.session === "string" && typeof r.turn === "number" && Array.isArray(r.calls) && typeof r.credited === "boolean";
2359
+ }
2360
+ function readUsage(path = usageFilePath()) {
2361
+ const latest = /* @__PURE__ */ new Map();
2362
+ for (const file of [`${path}.1`, path]) {
2363
+ let text = "";
2364
+ try {
2365
+ text = readFileSync6(file, "utf8");
2366
+ } catch {
2367
+ continue;
2368
+ }
2369
+ for (const raw of text.split("\n")) {
2370
+ let parsed;
2371
+ try {
2372
+ parsed = JSON.parse(raw);
2373
+ } catch {
2374
+ continue;
2375
+ }
2376
+ if (!isUsageLine(parsed)) continue;
2377
+ latest.set(`${parsed.harness}
2378
+ ${parsed.session}
2379
+ ${parsed.turn}`, parsed);
2380
+ }
2381
+ }
2382
+ const byHarness = /* @__PURE__ */ new Map();
2383
+ for (const line of latest.values()) {
2384
+ let h = byHarness.get(line.harness);
2385
+ if (!h) {
2386
+ h = {
2387
+ harness: line.harness,
2388
+ turns: 0,
2389
+ turnsWithCalls: 0,
2390
+ calls: 0,
2391
+ turnsWithRetrieval: 0,
2392
+ creditedTurnsWithRetrieval: 0,
2393
+ byTool: {}
2394
+ };
2395
+ byHarness.set(line.harness, h);
2396
+ }
2397
+ h.turns++;
2398
+ h.calls += line.calls.length;
2399
+ for (const tool of line.calls) h.byTool[tool] = (h.byTool[tool] ?? 0) + 1;
2400
+ if (line.calls.length) h.turnsWithCalls++;
2401
+ if (line.calls.some((tool) => RETRIEVAL_TOOLS.has(tool))) {
2402
+ h.turnsWithRetrieval++;
2403
+ if (line.credited) h.creditedTurnsWithRetrieval++;
2404
+ }
2405
+ }
2406
+ return [...byHarness.values()].sort((a, b) => b.turns - a.turns);
2407
+ }
2408
+ var pct = (n, d) => d ? `${Math.round(100 * n / d)}%` : "-";
2409
+ function formatUsageReport(usage, path = usageFilePath()) {
2410
+ if (!usage.length) return `no Hindsight usage recorded yet (${path})`;
2411
+ const out = [`Hindsight tool usage (${path})`, ""];
2412
+ for (const h of usage) {
2413
+ out.push(
2414
+ `${h.harness}: ${h.turns} turns \xB7 ${h.turnsWithCalls} with a Hindsight call (${pct(h.turnsWithCalls, h.turns)}) \xB7 ${(h.calls / h.turns).toFixed(2)} calls/turn \xB7 credited after retrieval ${h.creditedTurnsWithRetrieval}/${h.turnsWithRetrieval} (${pct(h.creditedTurnsWithRetrieval, h.turnsWithRetrieval)})`
2415
+ );
2416
+ for (const [tool, n] of Object.entries(h.byTool).sort((a, b) => b[1] - a[1])) {
2417
+ out.push(` ${tool}: ${n}`);
2418
+ }
2419
+ }
2420
+ return out.join("\n");
2421
+ }
2422
+
2334
2423
  // src/core/session-start.ts
2335
- import { readFileSync as readFileSync10 } from "fs";
2424
+ import { readFileSync as readFileSync11 } from "fs";
2336
2425
 
2337
2426
  // src/core/git.ts
2338
2427
  import { execFileSync as execFileSync2 } from "child_process";
@@ -2345,8 +2434,8 @@ import { execFileSync as execFileSync3 } from "child_process";
2345
2434
  import { spawn as realSpawn4 } from "child_process";
2346
2435
  import { createHash as createHash4 } from "crypto";
2347
2436
  import { existsSync as existsSync3 } from "fs";
2348
- import { homedir as homedir3, tmpdir as tmpdir4 } from "os";
2349
- import { dirname as dirname8, join as join11 } from "path";
2437
+ import { homedir as homedir4, tmpdir as tmpdir3 } from "os";
2438
+ import { dirname as dirname8, join as join13 } from "path";
2350
2439
  import { fileURLToPath as fileURLToPath3 } from "url";
2351
2440
 
2352
2441
  // src/core/survey-lease.ts
@@ -2356,36 +2445,36 @@ import {
2356
2445
  mkdirSync as mkdirSync4,
2357
2446
  mkdtempSync,
2358
2447
  readdirSync,
2359
- renameSync as renameSync2,
2448
+ renameSync as renameSync3,
2360
2449
  rmdirSync,
2361
2450
  rmSync as rmSync2,
2362
- statSync as statSync3,
2451
+ statSync as statSync4,
2363
2452
  unlinkSync,
2364
2453
  utimesSync,
2365
2454
  writeFileSync as writeFileSync2
2366
2455
  } from "fs";
2367
- import { join as join10 } from "path";
2456
+ import { join as join12 } from "path";
2368
2457
 
2369
2458
  // src/core/auto-update.ts
2370
2459
  import { spawn as realSpawn5 } from "child_process";
2371
2460
  import {
2372
2461
  existsSync as existsSync4,
2373
2462
  mkdirSync as mkdirSync5,
2374
- readFileSync as readFileSync7,
2463
+ readFileSync as readFileSync8,
2375
2464
  realpathSync as realpathSync2,
2376
2465
  unlinkSync as unlinkSync2,
2377
2466
  writeFileSync as writeFileSync3
2378
2467
  } from "fs";
2379
- import { homedir as homedir4, tmpdir as tmpdir5 } from "os";
2380
- import { dirname as dirname9, join as join12 } from "path";
2468
+ import { homedir as homedir5, tmpdir as tmpdir4 } from "os";
2469
+ import { dirname as dirname9, join as join14 } from "path";
2381
2470
  import { fileURLToPath as fileURLToPath4 } from "url";
2382
2471
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
2383
2472
  var LOCK_STALE_MS = 10 * 60 * 1e3;
2384
2473
 
2385
2474
  // src/core/skill-sync.ts
2386
- import { cpSync, existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
2387
- import { homedir as homedir5 } from "os";
2388
- import { dirname as dirname10, join as join13 } from "path";
2475
+ import { cpSync, existsSync as existsSync5, readFileSync as readFileSync9 } from "fs";
2476
+ import { homedir as homedir6 } from "os";
2477
+ import { dirname as dirname10, join as join15 } from "path";
2389
2478
  import { fileURLToPath as fileURLToPath5 } from "url";
2390
2479
 
2391
2480
  // src/core/skill-dirs.ts
@@ -2416,18 +2505,18 @@ var SKILL_DIRS = {
2416
2505
  };
2417
2506
 
2418
2507
  // src/core/legacy.ts
2419
- import { existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
2420
- import { homedir as homedir6 } from "os";
2421
- import { join as join14, relative, isAbsolute as isAbsolute2 } from "path";
2508
+ import { existsSync as existsSync6, readFileSync as readFileSync10 } from "fs";
2509
+ import { homedir as homedir7 } from "os";
2510
+ import { join as join16, relative, isAbsolute as isAbsolute2 } from "path";
2422
2511
  var LEGACY_CONFIG_FILES = {
2423
2512
  "claude-code": "claude-code.json",
2424
2513
  codex: "codex.json"
2425
2514
  };
2426
- function legacyConfigPath(harness, home = homedir6()) {
2427
- return join14(home, ".hindsight", LEGACY_CONFIG_FILES[harness] ?? `${harness}.json`);
2515
+ function legacyConfigPath(harness, home = homedir7()) {
2516
+ return join16(home, ".hindsight", LEGACY_CONFIG_FILES[harness] ?? `${harness}.json`);
2428
2517
  }
2429
2518
  var CLOUD_URL = "https://api.hindsight.vectorize.io";
2430
- function readLegacyEndpoint(home = homedir6(), prefer = []) {
2519
+ function readLegacyEndpoint(home = homedir7(), prefer = []) {
2431
2520
  const order = [...prefer, ...Object.keys(LEGACY_CONFIG_FILES)].filter(
2432
2521
  (h, i, all) => h in LEGACY_CONFIG_FILES && all.indexOf(h) === i
2433
2522
  );
@@ -2442,7 +2531,7 @@ function readOne(harness, home) {
2442
2531
  if (!existsSync6(source)) return void 0;
2443
2532
  let raw;
2444
2533
  try {
2445
- raw = JSON.parse(readFileSync9(source, "utf8"));
2534
+ raw = JSON.parse(readFileSync10(source, "utf8"));
2446
2535
  } catch {
2447
2536
  return void 0;
2448
2537
  }
@@ -2598,19 +2687,19 @@ function readCopilotTranscript(path) {
2598
2687
  }
2599
2688
 
2600
2689
  // src/core/transcript-grok.ts
2601
- import { existsSync as existsSync7, readFileSync as readFileSync11, readdirSync as readdirSync2 } from "fs";
2602
- import { homedir as homedir7 } from "os";
2603
- import { join as join15 } from "path";
2690
+ import { existsSync as existsSync7, readFileSync as readFileSync12, readdirSync as readdirSync2 } from "fs";
2691
+ import { homedir as homedir8 } from "os";
2692
+ import { join as join17 } from "path";
2604
2693
  var CHAT_HISTORY = "chat_history.jsonl";
2605
- function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join15(homedir7(), ".grok")) {
2606
- const sessionsDir = join15(grokHome, "sessions");
2607
- const direct = join15(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2694
+ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join17(homedir8(), ".grok")) {
2695
+ const sessionsDir = join17(grokHome, "sessions");
2696
+ const direct = join17(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
2608
2697
  if (existsSync7(direct)) return direct;
2609
2698
  try {
2610
2699
  for (const candidate of readdirSync2(sessionsDir)) {
2611
- const directory = join15(sessionsDir, candidate);
2612
- if (readFileSync11(join15(directory, ".cwd"), "utf8").trim() === cwd) {
2613
- return join15(directory, sessionId, CHAT_HISTORY);
2700
+ const directory = join17(sessionsDir, candidate);
2701
+ if (readFileSync12(join17(directory, ".cwd"), "utf8").trim() === cwd) {
2702
+ return join17(directory, sessionId, CHAT_HISTORY);
2614
2703
  }
2615
2704
  }
2616
2705
  } catch {
@@ -2647,10 +2736,10 @@ function readGrokTranscript(path) {
2647
2736
  // src/core/transcript-devin.ts
2648
2737
  import { existsSync as existsSync8 } from "fs";
2649
2738
  import { createRequire } from "module";
2650
- import { homedir as homedir8 } from "os";
2651
- import { join as join16 } from "path";
2652
- function devinSessionDb(home = homedir8()) {
2653
- return join16(home, ".local", "share", "devin", "cli", "sessions.db");
2739
+ import { homedir as homedir9 } from "os";
2740
+ import { join as join18 } from "path";
2741
+ function devinSessionDb(home = homedir9()) {
2742
+ return join18(home, ".local", "share", "devin", "cli", "sessions.db");
2654
2743
  }
2655
2744
  function parseDevinMessages(nodes) {
2656
2745
  const messages = /* @__PURE__ */ new Map();
@@ -2960,7 +3049,7 @@ function readDroidTranscript(path) {
2960
3049
  }
2961
3050
 
2962
3051
  // src/core/transcript-zcode.ts
2963
- import { readFileSync as readFileSync12 } from "fs";
3052
+ import { readFileSync as readFileSync13 } from "fs";
2964
3053
  function messageText2(content) {
2965
3054
  if (typeof content === "string") return content.trim();
2966
3055
  if (!Array.isArray(content)) return "";
@@ -2970,7 +3059,7 @@ function readZcodeTranscript(path) {
2970
3059
  if (!path) return [];
2971
3060
  let body;
2972
3061
  try {
2973
- body = readFileSync12(path, "utf8");
3062
+ body = readFileSync13(path, "utf8");
2974
3063
  } catch {
2975
3064
  return [];
2976
3065
  }
@@ -3447,13 +3536,13 @@ import {
3447
3536
  existsSync as existsSync9,
3448
3537
  openSync as openSync2,
3449
3538
  readdirSync as readdirSync3,
3450
- readFileSync as readFileSync13,
3539
+ readFileSync as readFileSync14,
3451
3540
  readSync as readSync2,
3452
- statSync as statSync4
3541
+ statSync as statSync5
3453
3542
  } from "fs";
3454
3543
  import { createHash as createHash5 } from "crypto";
3455
- import { homedir as homedir9 } from "os";
3456
- import { join as join17 } from "path";
3544
+ import { homedir as homedir10 } from "os";
3545
+ import { join as join19 } from "path";
3457
3546
  import * as zlib2 from "zlib";
3458
3547
 
3459
3548
  // src/core/transcript-dsh.ts
@@ -3597,8 +3686,8 @@ function zstdDecompressFrames(buffer) {
3597
3686
  }
3598
3687
 
3599
3688
  // src/core/history.ts
3600
- function claudeProjectDir(repoDir, home = homedir9()) {
3601
- return join17(home, ".claude", "projects", repoDir.replace(/[^a-zA-Z0-9]/g, "-"));
3689
+ function claudeProjectDir(repoDir, home = homedir10()) {
3690
+ return join19(home, ".claude", "projects", repoDir.replace(/[^a-zA-Z0-9]/g, "-"));
3602
3691
  }
3603
3692
  function piSessionDir(repoDir) {
3604
3693
  return `--${repoDir.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
@@ -3608,7 +3697,7 @@ function withinRepo(dir, repoDir) {
3608
3697
  }
3609
3698
  function claudeSessionCwd(file) {
3610
3699
  try {
3611
- for (const line of readFileSync13(file, "utf8").split("\n", 400)) {
3700
+ for (const line of readFileSync14(file, "utf8").split("\n", 400)) {
3612
3701
  if (!line.includes('"cwd"')) continue;
3613
3702
  const cwd = JSON.parse(line).cwd;
3614
3703
  if (cwd) return cwd;
@@ -3650,13 +3739,13 @@ function listDir(dir) {
3650
3739
  }
3651
3740
  }
3652
3741
  function jsonlFiles(dir) {
3653
- return listDir(dir).filter((f) => f.endsWith(".jsonl")).map((f) => join17(dir, f));
3742
+ return listDir(dir).filter((f) => f.endsWith(".jsonl")).map((f) => join19(dir, f));
3654
3743
  }
3655
3744
  function claudeHistory(repoDir, home) {
3656
- const root = join17(home, ".claude", "projects");
3745
+ const root = join19(home, ".claude", "projects");
3657
3746
  const exact = claudeProjectDir(repoDir, home);
3658
3747
  const prefix = exact + "-";
3659
- const dirs = listDir(root).map((d) => join17(root, d)).filter((d) => d === exact || d.startsWith(prefix));
3748
+ const dirs = listDir(root).map((d) => join19(root, d)).filter((d) => d === exact || d.startsWith(prefix));
3660
3749
  const sessions = [];
3661
3750
  let unattributed = 0;
3662
3751
  for (const file of dirs.flatMap(jsonlFiles)) {
@@ -3676,13 +3765,13 @@ function claudeHistory(repoDir, home) {
3676
3765
  return { supported: true, sessions, unattributed };
3677
3766
  }
3678
3767
  function codexHistory(repoDir, home) {
3679
- const root = join17(home, ".codex", "sessions");
3768
+ const root = join19(home, ".codex", "sessions");
3680
3769
  if (!existsSync9(root)) return { supported: true, sessions: [] };
3681
3770
  const files = [];
3682
3771
  const walk = (dir) => {
3683
3772
  for (const entry of readdirSync3(dir)) {
3684
- const p = join17(dir, entry);
3685
- if (statSync4(p).isDirectory()) walk(p);
3773
+ const p = join19(dir, entry);
3774
+ if (statSync5(p).isDirectory()) walk(p);
3686
3775
  else if (entry.endsWith(".jsonl")) files.push(p);
3687
3776
  }
3688
3777
  };
@@ -3711,13 +3800,13 @@ function dcodeTranscriptPath(root, threadId) {
3711
3800
  const suffix = `--${digest}.jsonl`;
3712
3801
  try {
3713
3802
  const match = readdirSync3(root).find((entry) => entry.endsWith(suffix));
3714
- return match ? join17(root, match) : void 0;
3803
+ return match ? join19(root, match) : void 0;
3715
3804
  } catch {
3716
3805
  return void 0;
3717
3806
  }
3718
3807
  }
3719
3808
  function dcodeHistory(repoDir, home, runCli) {
3720
- const root = join17(process.env.DEEPAGENTS_HOME || join17(home, ".deepagents"), "transcripts");
3809
+ const root = join19(process.env.DEEPAGENTS_HOME || join19(home, ".deepagents"), "transcripts");
3721
3810
  if (!existsSync9(root)) return { supported: true, sessions: [] };
3722
3811
  let listed;
3723
3812
  try {
@@ -3758,7 +3847,7 @@ function dcodeHistory(repoDir, home, runCli) {
3758
3847
  return { supported: true, sessions, ...unattributed ? { unattributed } : {} };
3759
3848
  }
3760
3849
  function dshHistory(repoDir, home) {
3761
- const root = process.env.DSH_HOME ? join17(process.env.DSH_HOME, "sessions") : join17(home, ".dsh", "sessions");
3850
+ const root = process.env.DSH_HOME ? join19(process.env.DSH_HOME, "sessions") : join19(home, ".dsh", "sessions");
3762
3851
  if (!existsSync9(root)) return { supported: true, sessions: [] };
3763
3852
  if (typeof zlib2.zstdDecompressSync !== "function") {
3764
3853
  return {
@@ -3769,15 +3858,15 @@ function dshHistory(repoDir, home) {
3769
3858
  }
3770
3859
  const sessions = [];
3771
3860
  let unattributed = 0;
3772
- for (const dir of readdirSync3(root).map((project) => join17(root, project))) {
3861
+ for (const dir of readdirSync3(root).map((project) => join19(root, project))) {
3773
3862
  let sessionDirs;
3774
3863
  try {
3775
- sessionDirs = readdirSync3(dir).map((id) => join17(dir, id));
3864
+ sessionDirs = readdirSync3(dir).map((id) => join19(dir, id));
3776
3865
  } catch {
3777
3866
  continue;
3778
3867
  }
3779
3868
  for (const sessionDir of sessionDirs) {
3780
- const file = ["session.jsonl.zstd", "session.jsonl"].map((name) => join17(sessionDir, name)).find((candidate) => existsSync9(candidate));
3869
+ const file = ["session.jsonl.zstd", "session.jsonl"].map((name) => join19(sessionDir, name)).find((candidate) => existsSync9(candidate));
3781
3870
  if (!file) continue;
3782
3871
  try {
3783
3872
  const lines = readDshLog(file);
@@ -3803,7 +3892,7 @@ function dshHistory(repoDir, home) {
3803
3892
  return { supported: true, sessions, unattributed };
3804
3893
  }
3805
3894
  function readDshLog(file) {
3806
- const bytes = readFileSync13(file);
3895
+ const bytes = readFileSync14(file);
3807
3896
  const text = file.endsWith(".zstd") ? zstdDecompressFrames(bytes) : bytes.toString("utf8");
3808
3897
  return text.split("\n").filter((line) => line.trim());
3809
3898
  }
@@ -3829,23 +3918,23 @@ function piFamilySessions(files, repoDir) {
3829
3918
  return { supported: true, sessions, unattributed };
3830
3919
  }
3831
3920
  function piHistory(repoDir, home) {
3832
- const root = join17(home, ".pi", "agent", "sessions");
3921
+ const root = join19(home, ".pi", "agent", "sessions");
3833
3922
  if (!existsSync9(root)) return { supported: true, sessions: [] };
3834
3923
  const exact = piSessionDir(repoDir);
3835
3924
  const nested = `${exact.slice(0, -2)}-`;
3836
3925
  const files = [];
3837
3926
  for (const dir of listDir(root).filter((d) => d === exact || d.startsWith(nested))) {
3838
- files.push(...jsonlFiles(join17(root, dir)));
3927
+ files.push(...jsonlFiles(join19(root, dir)));
3839
3928
  }
3840
3929
  return piFamilySessions(files, repoDir);
3841
3930
  }
3842
3931
  function primeAgentHistory(repoDir, home) {
3843
- const root = join17(home, ".prime", "agent", "sessions");
3932
+ const root = join19(home, ".prime", "agent", "sessions");
3844
3933
  if (!existsSync9(root)) return { supported: true, sessions: [] };
3845
3934
  return piFamilySessions(jsonlFiles(root), repoDir);
3846
3935
  }
3847
3936
  var SQLITE_HISTORY = "keeps session history in an internal SQLite database, whose schema is unversioned and would break on any upstream change";
3848
- function importLocalHistory(harness, repoDir, home = homedir9(), runDcodeCli) {
3937
+ function importLocalHistory(harness, repoDir, home = homedir10(), runDcodeCli) {
3849
3938
  switch (harness) {
3850
3939
  case "claude-code":
3851
3940
  return claudeHistory(repoDir, home);
@@ -4088,10 +4177,10 @@ function createInstallerUi(o) {
4088
4177
  // src/installer.ts
4089
4178
  var MARKER = "coding-agents";
4090
4179
  var ZCODE_MAX_OUTPUT_BYTES = 32768;
4091
- var zcodeConfigPath = (c) => join18(c.home, ".zcode", "cli", "config.json");
4180
+ var zcodeConfigPath = (c) => join20(c.home, ".zcode", "cli", "config.json");
4092
4181
  function readJson(path) {
4093
4182
  try {
4094
- return JSON.parse(readFileSync14(path, "utf8"));
4183
+ return JSON.parse(readFileSync15(path, "utf8"));
4095
4184
  } catch {
4096
4185
  return {};
4097
4186
  }
@@ -4116,7 +4205,7 @@ function backupOnce(path) {
4116
4205
  }
4117
4206
  }
4118
4207
  function writeJsonc(path, key, value) {
4119
- const text = existsSync10(path) ? readFileSync14(path, "utf8") : "";
4208
+ const text = existsSync10(path) ? readFileSync15(path, "utf8") : "";
4120
4209
  const edits = modify(text, [key], value, {
4121
4210
  formattingOptions: {
4122
4211
  tabSize: 2,
@@ -4144,14 +4233,14 @@ function setOrDelete(obj, key, arr) {
4144
4233
  else delete obj[key];
4145
4234
  }
4146
4235
  var cmdHook = (dist, file, timeout) => ({
4147
- hooks: [{ type: "command", command: `node "${join18(dist, file)}"`, timeout }]
4236
+ hooks: [{ type: "command", command: `node "${join20(dist, file)}"`, timeout }]
4148
4237
  });
4149
4238
  var processHook = (dist, file, timeoutMs) => ({
4150
- hooks: [{ type: "process", command: "node", args: [join18(dist, file)], timeoutMs }]
4239
+ hooks: [{ type: "process", command: "node", args: [join20(dist, file)], timeoutMs }]
4151
4240
  });
4152
4241
  var mcpServerEntry = (dist, harness) => ({
4153
4242
  command: "node",
4154
- args: [join18(dist, "mcp-server.js")],
4243
+ args: [join20(dist, "mcp-server.js")],
4155
4244
  env: { HINDSIGHT_MCP_HARNESS: harness }
4156
4245
  });
4157
4246
  function isOurMcpEntry(entry) {
@@ -4170,7 +4259,7 @@ function mergeHarnessHooks(hooks, harness, dist) {
4170
4259
  if (installedEvents.has(hook.event)) continue;
4171
4260
  installedEvents.add(hook.event);
4172
4261
  const entry = spec.configStyle === "nested" ? cmdHook(dist, hook.entry, hook.timeout) : spec.configStyle === "process" ? processHook(dist, hook.entry, hook.timeout) : {
4173
- command: `node "${join18(dist, hook.entry)}"`,
4262
+ command: `node "${join20(dist, hook.entry)}"`,
4174
4263
  ...hook.timeout ? { timeout: hook.timeout } : {}
4175
4264
  };
4176
4265
  hooks[hook.event] = mergeHookEvent(hooks[hook.event], entry);
@@ -4188,19 +4277,19 @@ function stripHarnessHooks(hooks, harness) {
4188
4277
  function skillsBaseFor(c, harness) {
4189
4278
  const parts = SKILL_DIRS[harness];
4190
4279
  if (!parts) throw new Error(`${harness} installs a skill but names no directory in SKILL_DIRS`);
4191
- return join18(c.home, ...parts);
4280
+ return join20(c.home, ...parts);
4192
4281
  }
4193
4282
  function installSkill(c, harness) {
4194
- const src = join18(c.pkgRoot, "skill");
4195
- if (!existsSync10(join18(src, "SKILL.md"))) return;
4283
+ const src = join20(c.pkgRoot, "skill");
4284
+ if (!existsSync10(join20(src, "SKILL.md"))) return;
4196
4285
  const skillsBase = skillsBaseFor(c, harness);
4197
- const dst = join18(skillsBase, "hindsight-coding-agent");
4286
+ const dst = join20(skillsBase, "hindsight-coding-agent");
4198
4287
  mkdirSync6(skillsBase, { recursive: true });
4199
4288
  cpSync2(src, dst, { recursive: true });
4200
4289
  c.log?.(`${harness}: skill installed at ${dst}`);
4201
4290
  }
4202
4291
  function uninstallSkill(c, harness) {
4203
- rmSync3(join18(skillsBaseFor(c, harness), "hindsight-coding-agent"), {
4292
+ rmSync3(join20(skillsBaseFor(c, harness), "hindsight-coding-agent"), {
4204
4293
  recursive: true,
4205
4294
  force: true
4206
4295
  });
@@ -4223,9 +4312,9 @@ function runClinePlugin(args) {
4223
4312
  }
4224
4313
  var OPENCODE_CONFIG_CANDIDATES = ["opencode.jsonc", "opencode.json"];
4225
4314
  function opencodeConfigPath(c) {
4226
- const dir = join18(c.home, ".config", "opencode");
4227
- const existing = OPENCODE_CONFIG_CANDIDATES.map((f) => join18(dir, f)).find((p) => existsSync10(p));
4228
- return existing ?? join18(dir, "opencode.json");
4315
+ const dir = join20(c.home, ".config", "opencode");
4316
+ const existing = OPENCODE_CONFIG_CANDIDATES.map((f) => join20(dir, f)).find((p) => existsSync10(p));
4317
+ return existing ?? join20(dir, "opencode.json");
4229
4318
  }
4230
4319
  function runDcodePlugin(args) {
4231
4320
  try {
@@ -4239,7 +4328,7 @@ function registerOpencodePlugin(c, name) {
4239
4328
  const path = opencodeConfigPath(c);
4240
4329
  let cfg = {};
4241
4330
  if (existsSync10(path)) {
4242
- const parsed = parseJsonc(readFileSync14(path, "utf8"));
4331
+ const parsed = parseJsonc(readFileSync15(path, "utf8"));
4243
4332
  if (!parsed) {
4244
4333
  c.log?.(`${name}: SKIPPED \u2014 could not parse ${path}; add the plugin entry manually`);
4245
4334
  return;
@@ -4253,7 +4342,7 @@ function registerOpencodePlugin(c, name) {
4253
4342
  function unregisterOpencodePlugin(c, name) {
4254
4343
  const path = opencodeConfigPath(c);
4255
4344
  if (!existsSync10(path)) return;
4256
- const cfg = parseJsonc(readFileSync14(path, "utf8"));
4345
+ const cfg = parseJsonc(readFileSync15(path, "utf8"));
4257
4346
  if (!cfg || !Array.isArray(cfg.plugin)) return;
4258
4347
  const kept = cfg.plugin.filter((p) => !String(p).includes(MARKER));
4259
4348
  writeJsonc(path, "plugin", kept.length ? kept : void 0);
@@ -4261,7 +4350,7 @@ function unregisterOpencodePlugin(c, name) {
4261
4350
  }
4262
4351
  var opencode = {
4263
4352
  name: "opencode",
4264
- detect: (c) => onPath2("opencode") || existsSync10(join18(c.home, ".config", "opencode")),
4353
+ detect: (c) => onPath2("opencode") || existsSync10(join20(c.home, ".config", "opencode")),
4265
4354
  install: (c) => registerOpencodePlugin(c, "opencode"),
4266
4355
  uninstall: (c) => unregisterOpencodePlugin(c, "opencode")
4267
4356
  };
@@ -4272,16 +4361,16 @@ var opencode2 = {
4272
4361
  uninstall: (c) => unregisterOpencodePlugin(c, "opencode2")
4273
4362
  };
4274
4363
  function piFamilyInstaller(harness, configDir) {
4275
- const settings = (c) => join18(c.home, ...configDir, "settings.json");
4364
+ const settings = (c) => join20(c.home, ...configDir, "settings.json");
4276
4365
  return {
4277
4366
  name: harness,
4278
4367
  // Both hosts name their executable exactly as we name the harness, so the harness id doubles
4279
4368
  // as the PATH probe here — unlike, say, antigravity-cli, whose binary is `agy`.
4280
- detect: (c) => onPath2(harness) || existsSync10(join18(c.home, ...configDir)),
4369
+ detect: (c) => onPath2(harness) || existsSync10(join20(c.home, ...configDir)),
4281
4370
  install(c) {
4282
4371
  const path = settings(c);
4283
4372
  const cfg = readJson(path);
4284
- const entry = join18(c.pkgRoot, "dist", `${harness}.js`);
4373
+ const entry = join20(c.pkgRoot, "dist", `${harness}.js`);
4285
4374
  const exts = Array.isArray(cfg.extensions) ? cfg.extensions : [];
4286
4375
  cfg.extensions = [...exts.filter((p) => !String(p).includes(MARKER)), entry];
4287
4376
  writeJson(path, cfg);
@@ -4306,25 +4395,25 @@ var pi = piFamilyInstaller("pi", [".pi", "agent"]);
4306
4395
  var primeAgent = piFamilyInstaller("prime-agent", [".prime", "agent"]);
4307
4396
  var KILO_CONFIG_CANDIDATES = ["kilo.jsonc", "kilo.json", "opencode.json"];
4308
4397
  function kiloConfigPath(c) {
4309
- const dir = join18(c.home, ".config", "kilo");
4310
- const existing = KILO_CONFIG_CANDIDATES.map((f) => join18(dir, f)).find((p) => existsSync10(p));
4311
- return existing ?? join18(dir, "kilo.json");
4398
+ const dir = join20(c.home, ".config", "kilo");
4399
+ const existing = KILO_CONFIG_CANDIDATES.map((f) => join20(dir, f)).find((p) => existsSync10(p));
4400
+ return existing ?? join20(dir, "kilo.json");
4312
4401
  }
4313
4402
  var kilo = {
4314
4403
  name: "kilo",
4315
- detect: (c) => onPath2("kilo") || existsSync10(join18(c.home, ".config", "kilo")),
4404
+ detect: (c) => onPath2("kilo") || existsSync10(join20(c.home, ".config", "kilo")),
4316
4405
  install(c) {
4317
4406
  const path = kiloConfigPath(c);
4318
4407
  let cfg = {};
4319
4408
  if (existsSync10(path)) {
4320
- const parsed = parseJsonc(readFileSync14(path, "utf8"));
4409
+ const parsed = parseJsonc(readFileSync15(path, "utf8"));
4321
4410
  if (!parsed) {
4322
4411
  c.log?.(`kilo: SKIPPED \u2014 could not parse ${path}; add the plugin entry manually`);
4323
4412
  return;
4324
4413
  }
4325
4414
  cfg = parsed;
4326
4415
  }
4327
- const entry = pathToFileURL(join18(c.dist, "kilo.js")).href;
4416
+ const entry = pathToFileURL(join20(c.dist, "kilo.js")).href;
4328
4417
  const plugins = Array.isArray(cfg.plugin) ? cfg.plugin : [];
4329
4418
  writeJsonc(path, "plugin", [...plugins.filter((p) => !String(p).includes(MARKER)), entry]);
4330
4419
  c.log?.(`kilo: plugin registered in ${path}`);
@@ -4332,7 +4421,7 @@ var kilo = {
4332
4421
  uninstall(c) {
4333
4422
  const path = kiloConfigPath(c);
4334
4423
  if (!existsSync10(path)) return;
4335
- const cfg = parseJsonc(readFileSync14(path, "utf8"));
4424
+ const cfg = parseJsonc(readFileSync15(path, "utf8"));
4336
4425
  if (!cfg || !Array.isArray(cfg.plugin)) return;
4337
4426
  const kept = cfg.plugin.filter((p) => !String(p).includes(MARKER));
4338
4427
  writeJsonc(path, "plugin", kept.length ? kept : void 0);
@@ -4341,9 +4430,9 @@ var kilo = {
4341
4430
  };
4342
4431
  var claudeCode = {
4343
4432
  name: "claude-code",
4344
- detect: (c) => onPath2("claude") || existsSync10(join18(c.home, ".claude")),
4433
+ detect: (c) => onPath2("claude") || existsSync10(join20(c.home, ".claude")),
4345
4434
  install(c) {
4346
- const path = join18(c.home, ".claude", "settings.json");
4435
+ const path = join20(c.home, ".claude", "settings.json");
4347
4436
  const settings = readJson(path);
4348
4437
  settings.hooks = settings.hooks ?? {};
4349
4438
  mergeHarnessHooks(settings.hooks, "claude-code", c.dist);
@@ -4362,18 +4451,18 @@ var claudeCode = {
4362
4451
  "HINDSIGHT_MCP_HARNESS=claude-code",
4363
4452
  "--",
4364
4453
  "node",
4365
- join18(c.dist, "mcp-server.js")
4454
+ join20(c.dist, "mcp-server.js")
4366
4455
  ])) {
4367
4456
  c.log?.("claude-code: MCP server registered (claude mcp add, user scope)");
4368
4457
  } else {
4369
4458
  c.log?.(
4370
4459
  `claude-code: could not run \`claude mcp add\` \u2014 register the tools manually:
4371
- claude mcp add --scope user hindsight --env HINDSIGHT_MCP_HARNESS=claude-code -- node "${join18(c.dist, "mcp-server.js")}"`
4460
+ claude mcp add --scope user hindsight --env HINDSIGHT_MCP_HARNESS=claude-code -- node "${join20(c.dist, "mcp-server.js")}"`
4372
4461
  );
4373
4462
  }
4374
4463
  },
4375
4464
  uninstall(c) {
4376
- const path = join18(c.home, ".claude", "settings.json");
4465
+ const path = join20(c.home, ".claude", "settings.json");
4377
4466
  if (existsSync10(path)) {
4378
4467
  const settings = readJson(path);
4379
4468
  if (settings.hooks) {
@@ -4399,20 +4488,20 @@ function defaultClaudeMcp(args) {
4399
4488
  var CODEX_MCP_BLOCK_RE = /^\[mcp_servers\.hindsight(?:\.[^\]]+)?\][^\n]*\n(?:(?!\[)[^\n]*\n?)*/gm;
4400
4489
  var codexMcpBlock = (dist) => `[mcp_servers.hindsight]
4401
4490
  command = "node"
4402
- args = [${JSON.stringify(join18(dist, "mcp-server.js"))}]
4491
+ args = [${JSON.stringify(join20(dist, "mcp-server.js"))}]
4403
4492
  env = { HINDSIGHT_MCP_HARNESS = "codex" }`;
4404
4493
  var codex = {
4405
4494
  name: "codex",
4406
- detect: (c) => onPath2("codex") || existsSync10(join18(c.home, ".codex")),
4495
+ detect: (c) => onPath2("codex") || existsSync10(join20(c.home, ".codex")),
4407
4496
  install(c) {
4408
- const hooksPath = join18(c.home, ".codex", "hooks.json");
4497
+ const hooksPath = join20(c.home, ".codex", "hooks.json");
4409
4498
  const cfg = readJson(hooksPath);
4410
4499
  cfg.hooks = cfg.hooks ?? {};
4411
4500
  mergeHarnessHooks(cfg.hooks, "codex", c.dist);
4412
4501
  writeJson(hooksPath, cfg);
4413
4502
  c.log?.(`codex: hooks merged into ${hooksPath}`);
4414
- const tomlPath = join18(c.home, ".codex", "config.toml");
4415
- const existing = existsSync10(tomlPath) ? readFileSync14(tomlPath, "utf8") : "";
4503
+ const tomlPath = join20(c.home, ".codex", "config.toml");
4504
+ const existing = existsSync10(tomlPath) ? readFileSync15(tomlPath, "utf8") : "";
4416
4505
  const toml = existing.replace(CODEX_MCP_BLOCK_RE, "");
4417
4506
  const additions = [];
4418
4507
  if (!/^\s*(codex_hooks|hooks)\s*=/m.test(toml)) {
@@ -4438,7 +4527,7 @@ var codex = {
4438
4527
  installSkill(c, "codex");
4439
4528
  },
4440
4529
  uninstall(c) {
4441
- const hooksPath = join18(c.home, ".codex", "hooks.json");
4530
+ const hooksPath = join20(c.home, ".codex", "hooks.json");
4442
4531
  if (existsSync10(hooksPath)) {
4443
4532
  const cfg = readJson(hooksPath);
4444
4533
  if (cfg.hooks) {
@@ -4447,9 +4536,9 @@ var codex = {
4447
4536
  }
4448
4537
  }
4449
4538
  uninstallSkill(c, "codex");
4450
- const tomlPath = join18(c.home, ".codex", "config.toml");
4539
+ const tomlPath = join20(c.home, ".codex", "config.toml");
4451
4540
  if (existsSync10(tomlPath)) {
4452
- const toml = readFileSync14(tomlPath, "utf8");
4541
+ const toml = readFileSync15(tomlPath, "utf8");
4453
4542
  const cleaned = toml.replace(CODEX_MCP_BLOCK_RE, "");
4454
4543
  if (cleaned !== toml) writeFileSync4(tomlPath, cleaned);
4455
4544
  }
@@ -4465,7 +4554,7 @@ var antigravity = {
4465
4554
  // can consume this integration.
4466
4555
  detect: (c) => onPath2("agy"),
4467
4556
  install(c) {
4468
- const hooksPath = join18(c.home, ".gemini", "config", "hooks.json");
4557
+ const hooksPath = join20(c.home, ".gemini", "config", "hooks.json");
4469
4558
  const hooks = readJson(hooksPath);
4470
4559
  for (const key of Object.keys(hooks)) {
4471
4560
  if (key !== MARKER && key.includes(MARKER)) delete hooks[key];
@@ -4476,26 +4565,26 @@ var antigravity = {
4476
4565
  setOrDelete(hooks, event, stripOurs(hooks[event]));
4477
4566
  }
4478
4567
  writeJson(hooksPath, hooks);
4479
- const mcpPath = join18(c.home, ".gemini", "config", "mcp_config.json");
4568
+ const mcpPath = join20(c.home, ".gemini", "config", "mcp_config.json");
4480
4569
  const mcp = readJson(mcpPath);
4481
4570
  mcp.mcpServers = {
4482
4571
  ...mcp.mcpServers ?? {},
4483
4572
  hindsight: mcpServerEntry(c.dist, "antigravity-cli")
4484
4573
  };
4485
4574
  writeJson(mcpPath, mcp);
4486
- const settingsPath = join18(c.home, ".gemini", "antigravity-cli", "settings.json");
4575
+ const settingsPath = join20(c.home, ".gemini", "antigravity-cli", "settings.json");
4487
4576
  const settings = readJson(settingsPath);
4488
4577
  if (!settings.statusLine) {
4489
4578
  settings.statusLine = {
4490
4579
  type: "command",
4491
- command: `node "${join18(c.dist, "antigravity-statusline.js")}"`
4580
+ command: `node "${join20(c.dist, "antigravity-statusline.js")}"`
4492
4581
  };
4493
4582
  writeJson(settingsPath, settings);
4494
4583
  c.log?.(`antigravity-cli: Hindsight status line enabled in ${settingsPath}`);
4495
4584
  } else if (JSON.stringify(settings.statusLine).includes(MARKER)) {
4496
4585
  settings.statusLine = {
4497
4586
  type: "command",
4498
- command: `node "${join18(c.dist, "antigravity-statusline.js")}"`
4587
+ command: `node "${join20(c.dist, "antigravity-statusline.js")}"`
4499
4588
  };
4500
4589
  writeJson(settingsPath, settings);
4501
4590
  } else {
@@ -4507,7 +4596,7 @@ var antigravity = {
4507
4596
  installSkill(c, "antigravity-cli");
4508
4597
  },
4509
4598
  uninstall(c) {
4510
- const hooksPath = join18(c.home, ".gemini", "config", "hooks.json");
4599
+ const hooksPath = join20(c.home, ".gemini", "config", "hooks.json");
4511
4600
  if (existsSync10(hooksPath)) {
4512
4601
  const hooks = readJson(hooksPath);
4513
4602
  if (hooks[MARKER]) {
@@ -4519,7 +4608,7 @@ var antigravity = {
4519
4608
  }
4520
4609
  writeJson(hooksPath, hooks);
4521
4610
  }
4522
- const mcpPath = join18(c.home, ".gemini", "config", "mcp_config.json");
4611
+ const mcpPath = join20(c.home, ".gemini", "config", "mcp_config.json");
4523
4612
  if (existsSync10(mcpPath)) {
4524
4613
  const mcp = readJson(mcpPath);
4525
4614
  if (mcp.mcpServers?.hindsight) {
@@ -4527,7 +4616,7 @@ var antigravity = {
4527
4616
  writeJson(mcpPath, mcp);
4528
4617
  }
4529
4618
  }
4530
- const settingsPath = join18(c.home, ".gemini", "antigravity-cli", "settings.json");
4619
+ const settingsPath = join20(c.home, ".gemini", "antigravity-cli", "settings.json");
4531
4620
  if (existsSync10(settingsPath)) {
4532
4621
  const settings = readJson(settingsPath);
4533
4622
  if (JSON.stringify(settings.statusLine ?? {}).includes(MARKER)) {
@@ -4555,7 +4644,7 @@ function pathNodeVersion() {
4555
4644
  }
4556
4645
  }
4557
4646
  function runtimeDir(home) {
4558
- return join18(home, ".hindsight", "coding-agents");
4647
+ return join20(home, ".hindsight", "coding-agents");
4559
4648
  }
4560
4649
  var ORIGIN_FILE = ".install-origin.json";
4561
4650
  function stageRuntime(c) {
@@ -4568,25 +4657,25 @@ function stageRuntime(c) {
4568
4657
  }
4569
4658
  };
4570
4659
  if (same(c.pkgRoot, target)) return c;
4571
- if (!existsSync10(join18(c.dist, "installer.js"))) return c;
4660
+ if (!existsSync10(join20(c.dist, "installer.js"))) return c;
4572
4661
  try {
4573
- rmSync3(join18(target, "dist"), { recursive: true, force: true });
4662
+ rmSync3(join20(target, "dist"), { recursive: true, force: true });
4574
4663
  mkdirSync6(target, { recursive: true });
4575
- cpSync2(c.dist, join18(target, "dist"), { recursive: true });
4576
- const skill = join18(c.pkgRoot, "skill");
4577
- if (existsSync10(skill)) cpSync2(skill, join18(target, "skill"), { recursive: true });
4578
- const pkgJson = join18(c.pkgRoot, "package.json");
4579
- if (existsSync10(pkgJson)) copyFileSync(pkgJson, join18(target, "package.json"));
4664
+ cpSync2(c.dist, join20(target, "dist"), { recursive: true });
4665
+ const skill = join20(c.pkgRoot, "skill");
4666
+ if (existsSync10(skill)) cpSync2(skill, join20(target, "skill"), { recursive: true });
4667
+ const pkgJson = join20(c.pkgRoot, "package.json");
4668
+ if (existsSync10(pkgJson)) copyFileSync(pkgJson, join20(target, "package.json"));
4580
4669
  for (const resource of ["plugin.json", "hooks", "index.js"]) {
4581
- const source = join18(c.pkgRoot, resource);
4582
- if (existsSync10(source)) cpSync2(source, join18(target, resource), { recursive: true });
4670
+ const source = join20(c.pkgRoot, resource);
4671
+ if (existsSync10(source)) cpSync2(source, join20(target, resource), { recursive: true });
4583
4672
  }
4584
4673
  writeFileSync4(
4585
- join18(target, ORIGIN_FILE),
4674
+ join20(target, ORIGIN_FILE),
4586
4675
  JSON.stringify({ source: c.pkgRoot, stagedAt: (/* @__PURE__ */ new Date()).toISOString() })
4587
4676
  );
4588
4677
  c.log?.(`runtime staged at ${target}`);
4589
- return { ...c, pkgRoot: target, dist: join18(target, "dist") };
4678
+ return { ...c, pkgRoot: target, dist: join20(target, "dist") };
4590
4679
  } catch (error) {
4591
4680
  c.log?.(`could not stage the runtime at ${target}: ${String(error)}`);
4592
4681
  return c;
@@ -4664,7 +4753,7 @@ function configureServer(c, args, installing) {
4664
4753
  c.log?.(`unknown --server "${explicit}" \u2014 expected one of: ${SERVER_MODES.join(", ")}`);
4665
4754
  return false;
4666
4755
  }
4667
- const configPath = process.env.HINDSIGHT_CONFIG || join18(c.home, ...CONFIG_RELATIVE);
4756
+ const configPath = process.env.HINDSIGHT_CONFIG || join20(c.home, ...CONFIG_RELATIVE);
4668
4757
  const existing = readJson(configPath);
4669
4758
  const alreadyConfigured = !!(existing.serverMode || existing.apiUrl);
4670
4759
  let mode = explicit;
@@ -4760,7 +4849,7 @@ function reportDaemonPrereqs(c) {
4760
4849
  }
4761
4850
  var devin = {
4762
4851
  name: "devin-cli",
4763
- detect: (c) => onPath2("devin") || existsSync10(join18(c.home, ".config", "devin")),
4852
+ detect: (c) => onPath2("devin") || existsSync10(join20(c.home, ".config", "devin")),
4764
4853
  // Devin is the ONLY harness whose hooks never hand over a transcript: they carry a session id and
4765
4854
  // nothing else, so retain can only work by reading the CLI's own sessions.db. That makes SQLite
4766
4855
  // support a hard prerequisite here — and one worth checking now, because the alternative is an
@@ -4773,12 +4862,12 @@ var devin = {
4773
4862
  Upgrade to Node 22.5 or newer (24 LTS recommended) and re-run this command.`;
4774
4863
  },
4775
4864
  install(c) {
4776
- const configPath = join18(c.home, ".config", "devin", "config.json");
4865
+ const configPath = join20(c.home, ".config", "devin", "config.json");
4777
4866
  const config = readJson(configPath);
4778
4867
  config.hooks = config.hooks ?? {};
4779
4868
  mergeHarnessHooks(config.hooks, "devin-cli", c.dist);
4780
4869
  writeJson(configPath, config);
4781
- const mcpPath = join18(c.home, ".config", "devin", "mcp_config.json");
4870
+ const mcpPath = join20(c.home, ".config", "devin", "mcp_config.json");
4782
4871
  const mcp = readJson(mcpPath);
4783
4872
  mcp.mcpServers = {
4784
4873
  ...mcp.mcpServers ?? {},
@@ -4788,7 +4877,7 @@ var devin = {
4788
4877
  c.log?.(`devin-cli: hooks merged into ${configPath}, MCP into ${mcpPath}`);
4789
4878
  },
4790
4879
  uninstall(c) {
4791
- const configPath = join18(c.home, ".config", "devin", "config.json");
4880
+ const configPath = join20(c.home, ".config", "devin", "config.json");
4792
4881
  if (existsSync10(configPath)) {
4793
4882
  const config = readJson(configPath);
4794
4883
  if (config.hooks) {
@@ -4797,7 +4886,7 @@ var devin = {
4797
4886
  writeJson(configPath, config);
4798
4887
  }
4799
4888
  }
4800
- const mcpPath = join18(c.home, ".config", "devin", "mcp_config.json");
4889
+ const mcpPath = join20(c.home, ".config", "devin", "mcp_config.json");
4801
4890
  if (existsSync10(mcpPath)) {
4802
4891
  const mcp = readJson(mcpPath);
4803
4892
  if (mcp.mcpServers?.hindsight) {
@@ -4810,14 +4899,14 @@ var devin = {
4810
4899
  };
4811
4900
  var cursor = {
4812
4901
  name: "cursor-cli",
4813
- detect: (c) => onPath2("cursor-agent") || existsSync10(join18(c.home, ".cursor")),
4902
+ detect: (c) => onPath2("cursor-agent") || existsSync10(join20(c.home, ".cursor")),
4814
4903
  install(c) {
4815
- const hooksPath = join18(c.home, ".cursor", "hooks.json");
4904
+ const hooksPath = join20(c.home, ".cursor", "hooks.json");
4816
4905
  const cfg = readJson(hooksPath);
4817
4906
  cfg.hooks = cfg.hooks ?? {};
4818
4907
  mergeHarnessHooks(cfg.hooks, "cursor-cli", c.dist);
4819
4908
  writeJson(hooksPath, cfg);
4820
- const mcpPath = join18(c.home, ".cursor", "mcp.json");
4909
+ const mcpPath = join20(c.home, ".cursor", "mcp.json");
4821
4910
  const mcp = readJson(mcpPath);
4822
4911
  mcp.mcpServers = {
4823
4912
  ...mcp.mcpServers ?? {},
@@ -4828,7 +4917,7 @@ var cursor = {
4828
4917
  installSkill(c, "cursor-cli");
4829
4918
  },
4830
4919
  uninstall(c) {
4831
- const hooksPath = join18(c.home, ".cursor", "hooks.json");
4920
+ const hooksPath = join20(c.home, ".cursor", "hooks.json");
4832
4921
  if (existsSync10(hooksPath)) {
4833
4922
  const cfg = readJson(hooksPath);
4834
4923
  if (cfg.hooks) {
@@ -4837,7 +4926,7 @@ var cursor = {
4837
4926
  writeJson(hooksPath, cfg);
4838
4927
  }
4839
4928
  }
4840
- const mcpPath = join18(c.home, ".cursor", "mcp.json");
4929
+ const mcpPath = join20(c.home, ".cursor", "mcp.json");
4841
4930
  if (existsSync10(mcpPath)) {
4842
4931
  const mcp = readJson(mcpPath);
4843
4932
  if (mcp.mcpServers?.hindsight) {
@@ -4851,13 +4940,13 @@ var cursor = {
4851
4940
  };
4852
4941
  var copilot = {
4853
4942
  name: "copilot-cli",
4854
- detect: (c) => onPath2("copilot") || existsSync10(join18(c.home, ".copilot")),
4943
+ detect: (c) => onPath2("copilot") || existsSync10(join20(c.home, ".copilot")),
4855
4944
  install(c) {
4856
- const hooksPath = join18(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
4945
+ const hooksPath = join20(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
4857
4946
  const hooks = {};
4858
4947
  mergeHarnessHooks(hooks, "copilot-cli", c.dist);
4859
4948
  writeJson(hooksPath, { version: 1, hooks });
4860
- const mcpPath = join18(c.home, ".copilot", "mcp-config.json");
4949
+ const mcpPath = join20(c.home, ".copilot", "mcp-config.json");
4861
4950
  const mcp = readJson(mcpPath);
4862
4951
  mcp.mcpServers = {
4863
4952
  ...mcp.mcpServers ?? {},
@@ -4868,10 +4957,10 @@ var copilot = {
4868
4957
  c.log?.(`copilot-cli: hooks installed at ${hooksPath}, MCP into ${mcpPath}`);
4869
4958
  },
4870
4959
  uninstall(c) {
4871
- rmSync3(join18(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
4960
+ rmSync3(join20(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
4872
4961
  force: true
4873
4962
  });
4874
- const mcpPath = join18(c.home, ".copilot", "mcp-config.json");
4963
+ const mcpPath = join20(c.home, ".copilot", "mcp-config.json");
4875
4964
  if (existsSync10(mcpPath)) {
4876
4965
  const mcp = readJson(mcpPath);
4877
4966
  if (mcp.mcpServers?.hindsight) {
@@ -4938,13 +5027,13 @@ function stripUnmarkedGrokEntries(toml) {
4938
5027
  }
4939
5028
  var grok = {
4940
5029
  name: "grok-build",
4941
- detect: (c) => onPath2("grok") || existsSync10(join18(c.home, ".grok")),
5030
+ detect: (c) => onPath2("grok") || existsSync10(join20(c.home, ".grok")),
4942
5031
  install(c) {
4943
- const path = join18(c.home, ".grok", "config.toml");
4944
- const existing = existsSync10(path) ? readFileSync14(path, "utf8") : "";
5032
+ const path = join20(c.home, ".grok", "config.toml");
5033
+ const existing = existsSync10(path) ? readFileSync15(path, "utf8") : "";
4945
5034
  const stripped = existing.replace(GROK_BLOCK_RE, "\n");
4946
5035
  const withoutOurs = hasUnmarkedGrokEntries(stripped) ? stripUnmarkedGrokEntries(stripped) : stripped;
4947
- const command = (entry) => JSON.stringify(`node "${join18(c.dist, entry)}"`);
5036
+ const command = (entry) => JSON.stringify(`node "${join20(c.dist, entry)}"`);
4948
5037
  const tomlString = (value) => JSON.stringify(value);
4949
5038
  const block = `
4950
5039
  ${GROK_MARKER_START}
@@ -4968,7 +5057,7 @@ ${GROK_MARKER_START}
4968
5057
 
4969
5058
  [mcp_servers.hindsight]
4970
5059
  command = "node"
4971
- args = [${tomlString(join18(c.dist, "mcp-server.js"))}]
5060
+ args = [${tomlString(join20(c.dist, "mcp-server.js"))}]
4972
5061
  env = { HINDSIGHT_MCP_HARNESS = "grok-build" }
4973
5062
  ${GROK_MARKER_END}
4974
5063
  `;
@@ -4987,9 +5076,9 @@ ${GROK_MARKER_END}
4987
5076
  c.log?.(`grok-build: native hooks + MCP installed in ${path}`);
4988
5077
  },
4989
5078
  uninstall(c) {
4990
- const path = join18(c.home, ".grok", "config.toml");
5079
+ const path = join20(c.home, ".grok", "config.toml");
4991
5080
  if (existsSync10(path)) {
4992
- const existing = readFileSync14(path, "utf8");
5081
+ const existing = readFileSync15(path, "utf8");
4993
5082
  const stripped = existing.replace(GROK_BLOCK_RE, "\n");
4994
5083
  const cleaned = hasUnmarkedGrokEntries(stripped) ? stripUnmarkedGrokEntries(stripped) : stripped;
4995
5084
  const safe = parseGrokToml(cleaned) !== null || parseGrokToml(existing) === null;
@@ -5003,17 +5092,17 @@ var CLINE_HOOK_MARKER = "HINDSIGHT_CODING_AGENTS_CLINE";
5003
5092
  var CLINE_OLD_HOOK_EVENTS = ["TaskStart", "UserPromptSubmit", "TaskComplete"];
5004
5093
  var CLINE_PLUGIN_NAME = "@vectorize-io/hindsight-coding-agents";
5005
5094
  function removeLegacyClineHooks(c) {
5006
- const hooksDir = join18(c.home, "Documents", "Cline", "Hooks");
5095
+ const hooksDir = join20(c.home, "Documents", "Cline", "Hooks");
5007
5096
  for (const event of CLINE_OLD_HOOK_EVENTS) {
5008
- const path = join18(hooksDir, event);
5009
- if (existsSync10(path) && readFileSync14(path, "utf8").includes(CLINE_HOOK_MARKER)) {
5097
+ const path = join20(hooksDir, event);
5098
+ if (existsSync10(path) && readFileSync15(path, "utf8").includes(CLINE_HOOK_MARKER)) {
5010
5099
  rmSync3(path, { force: true });
5011
5100
  }
5012
5101
  }
5013
5102
  }
5014
5103
  var cline = {
5015
5104
  name: "cline-cli",
5016
- detect: (c) => onPath2("cline") || existsSync10(join18(c.home, ".cline")),
5105
+ detect: (c) => onPath2("cline") || existsSync10(join20(c.home, ".cline")),
5017
5106
  install(c) {
5018
5107
  removeLegacyClineHooks(c);
5019
5108
  const installed = (c.clinePlugin ?? runClinePlugin)([
@@ -5022,7 +5111,7 @@ var cline = {
5022
5111
  "--force",
5023
5112
  c.pkgRoot
5024
5113
  ]);
5025
- const mcpPath = join18(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
5114
+ const mcpPath = join20(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
5026
5115
  const mcp = readJson(mcpPath);
5027
5116
  mcp.mcpServers = {
5028
5117
  ...mcp.mcpServers ?? {},
@@ -5037,7 +5126,7 @@ var cline = {
5037
5126
  uninstall(c) {
5038
5127
  removeLegacyClineHooks(c);
5039
5128
  (c.clinePlugin ?? runClinePlugin)(["plugin", "uninstall", CLINE_PLUGIN_NAME]);
5040
- const mcpPath = join18(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
5129
+ const mcpPath = join20(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
5041
5130
  if (existsSync10(mcpPath)) {
5042
5131
  const mcp = readJson(mcpPath);
5043
5132
  if (mcp.mcpServers?.hindsight) {
@@ -5051,31 +5140,31 @@ var cline = {
5051
5140
  };
5052
5141
  var DCODE_MARKETPLACE = "hindsight-coding-agents";
5053
5142
  var DCODE_PLUGIN_ID = "hindsight-coding-agents@hindsight-coding-agents";
5054
- var DCODE_MARKETPLACE_RELATIVE_PATH = join18(".agents", "plugins", "marketplace.json");
5143
+ var DCODE_MARKETPLACE_RELATIVE_PATH = join20(".agents", "plugins", "marketplace.json");
5055
5144
  var DCODE_FALLBACK_MARKETPLACE = "hindsight-coding-agents-marketplace.json";
5056
5145
  function prepareDcodeMarketplace(c) {
5057
- const root = join18(c.home, ".hindsight");
5058
- const conventionalPath = join18(root, DCODE_MARKETPLACE_RELATIVE_PATH);
5146
+ const root = join20(c.home, ".hindsight");
5147
+ const conventionalPath = join20(root, DCODE_MARKETPLACE_RELATIVE_PATH);
5059
5148
  let path = conventionalPath;
5060
5149
  let registrationSource = root;
5061
5150
  let marketplace = { plugins: [] };
5062
5151
  if (existsSync10(conventionalPath)) {
5063
5152
  try {
5064
- const parsed = JSON.parse(readFileSync14(conventionalPath, "utf8"));
5153
+ const parsed = JSON.parse(readFileSync15(conventionalPath, "utf8"));
5065
5154
  if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.plugins)) {
5066
- path = join18(root, DCODE_FALLBACK_MARKETPLACE);
5155
+ path = join20(root, DCODE_FALLBACK_MARKETPLACE);
5067
5156
  } else if (typeof parsed.name === "string" && parsed.name !== DCODE_MARKETPLACE) {
5068
- path = join18(root, DCODE_FALLBACK_MARKETPLACE);
5157
+ path = join20(root, DCODE_FALLBACK_MARKETPLACE);
5069
5158
  } else {
5070
5159
  marketplace = parsed;
5071
5160
  }
5072
5161
  } catch {
5073
- path = join18(root, DCODE_FALLBACK_MARKETPLACE);
5162
+ path = join20(root, DCODE_FALLBACK_MARKETPLACE);
5074
5163
  }
5075
5164
  }
5076
5165
  if (path !== conventionalPath && existsSync10(path)) {
5077
5166
  try {
5078
- const parsed = JSON.parse(readFileSync14(path, "utf8"));
5167
+ const parsed = JSON.parse(readFileSync15(path, "utf8"));
5079
5168
  if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.plugins) || parsed.name !== DCODE_MARKETPLACE) {
5080
5169
  c.log?.(`dcode: refusing to replace malformed marketplace file ${path}`);
5081
5170
  return false;
@@ -5103,7 +5192,7 @@ function prepareDcodeMarketplace(c) {
5103
5192
  }
5104
5193
  var dcode = {
5105
5194
  name: "dcode",
5106
- detect: (c) => onPath2("dcode") || existsSync10(join18(c.home, ".deepagents")),
5195
+ detect: (c) => onPath2("dcode") || existsSync10(join20(c.home, ".deepagents")),
5107
5196
  preflight: (c) => c.dcodePlugin || onPath2("dcode") ? void 0 : "the `dcode` CLI is not on PATH",
5108
5197
  install(c) {
5109
5198
  const plugin = c.dcodePlugin ?? runDcodePlugin;
@@ -5112,7 +5201,7 @@ var dcode = {
5112
5201
  if (installed) {
5113
5202
  c.log?.(`dcode: native Agent Plugin installed (${DCODE_PLUGIN_ID})`);
5114
5203
  } else {
5115
- const source = marketplacePath === false ? join18(c.home, ".hindsight") : marketplacePath;
5204
+ const source = marketplacePath === false ? join20(c.home, ".hindsight") : marketplacePath;
5116
5205
  c.log?.(
5117
5206
  `dcode: could not install the native plugin \u2014 run dcode plugin marketplace add "${source}" && dcode plugin install ${DCODE_PLUGIN_ID}`
5118
5207
  );
@@ -5140,16 +5229,16 @@ var DSH_MARKER_START = "# HINDSIGHT_CODING_AGENTS_DSH_START";
5140
5229
  var DSH_MARKER_END = "# HINDSIGHT_CODING_AGENTS_DSH_END";
5141
5230
  var DSH_BLOCK_RE = new RegExp(`\\n?${DSH_MARKER_START}[\\s\\S]*?${DSH_MARKER_END}\\n?`);
5142
5231
  function dshHome(c) {
5143
- return process.env.DSH_HOME || join18(c.home, ".dsh");
5232
+ return process.env.DSH_HOME || join20(c.home, ".dsh");
5144
5233
  }
5145
5234
  var dsh = {
5146
5235
  name: "dsh",
5147
5236
  detect: (c) => onPath2("dsh") || existsSync10(dshHome(c)),
5148
5237
  install(c) {
5149
- const path = join18(dshHome(c), "cordis.patch.yml");
5150
- const existing = existsSync10(path) ? readFileSync14(path, "utf8") : "";
5238
+ const path = join20(dshHome(c), "cordis.patch.yml");
5239
+ const existing = existsSync10(path) ? readFileSync15(path, "utf8") : "";
5151
5240
  const others = existing.replace(DSH_BLOCK_RE, "\n").trim();
5152
- const entry = pathToFileURL(join18(c.dist, "dsh.js")).href;
5241
+ const entry = pathToFileURL(join20(c.dist, "dsh.js")).href;
5153
5242
  const block = `${DSH_MARKER_START}
5154
5243
  - insert:
5155
5244
  - id: hindsight
@@ -5166,9 +5255,9 @@ ${block}` : block);
5166
5255
  c.log?.(`dsh: plugin registered in ${path} (applies to every dsh profile)`);
5167
5256
  },
5168
5257
  uninstall(c) {
5169
- const path = join18(dshHome(c), "cordis.patch.yml");
5258
+ const path = join20(dshHome(c), "cordis.patch.yml");
5170
5259
  if (existsSync10(path)) {
5171
- const existing = readFileSync14(path, "utf8");
5260
+ const existing = readFileSync15(path, "utf8");
5172
5261
  const others = existing.replace(DSH_BLOCK_RE, "\n").trim();
5173
5262
  if (others !== existing.trim()) writeFileSync4(path, others ? `${others}
5174
5263
  ` : "[]\n");
@@ -5179,9 +5268,9 @@ ${block}` : block);
5179
5268
  };
5180
5269
  var qwen = {
5181
5270
  name: "qwen-code",
5182
- detect: (c) => onPath2("qwen") || existsSync10(join18(c.home, ".qwen")),
5271
+ detect: (c) => onPath2("qwen") || existsSync10(join20(c.home, ".qwen")),
5183
5272
  install(c) {
5184
- const path = join18(c.home, ".qwen", "settings.json");
5273
+ const path = join20(c.home, ".qwen", "settings.json");
5185
5274
  const settings = readJson(path);
5186
5275
  settings.hooks = settings.hooks ?? {};
5187
5276
  mergeHarnessHooks(settings.hooks, "qwen-code", c.dist);
@@ -5199,18 +5288,18 @@ var qwen = {
5199
5288
  "HINDSIGHT_MCP_HARNESS=qwen-code",
5200
5289
  "hindsight",
5201
5290
  "node",
5202
- join18(c.dist, "mcp-server.js")
5291
+ join20(c.dist, "mcp-server.js")
5203
5292
  ])) {
5204
5293
  c.log?.("qwen-code: MCP server registered (qwen mcp add, user scope)");
5205
5294
  } else {
5206
5295
  c.log?.(
5207
5296
  `qwen-code: could not run \`qwen mcp add\` \u2014 register the tools manually:
5208
- qwen mcp add -s user -e HINDSIGHT_MCP_HARNESS=qwen-code hindsight node "${join18(c.dist, "mcp-server.js")}"`
5297
+ qwen mcp add -s user -e HINDSIGHT_MCP_HARNESS=qwen-code hindsight node "${join20(c.dist, "mcp-server.js")}"`
5209
5298
  );
5210
5299
  }
5211
5300
  },
5212
5301
  uninstall(c) {
5213
- const path = join18(c.home, ".qwen", "settings.json");
5302
+ const path = join20(c.home, ".qwen", "settings.json");
5214
5303
  if (existsSync10(path)) {
5215
5304
  const settings = readJson(path);
5216
5305
  if (settings.hooks) {
@@ -5235,19 +5324,19 @@ function defaultQwenMcp(args) {
5235
5324
  }
5236
5325
  var factoryDroid = {
5237
5326
  name: "factory-droid",
5238
- detect: (c) => onPath2("droid") || existsSync10(join18(c.home, ".factory")),
5327
+ detect: (c) => onPath2("droid") || existsSync10(join20(c.home, ".factory")),
5239
5328
  preflight(c) {
5240
- const mcpPath = join18(c.home, ".factory", "mcp.json");
5329
+ const mcpPath = join20(c.home, ".factory", "mcp.json");
5241
5330
  const existing = readJson(mcpPath).mcpServers?.hindsight;
5242
5331
  if (existing && !isOurMcpEntry(existing)) {
5243
5332
  return `${mcpPath} already contains a user-managed MCP server named "hindsight". Rename or remove that entry, then re-run install.`;
5244
5333
  }
5245
5334
  },
5246
5335
  install(c) {
5247
- const hooksPath = join18(c.home, ".factory", "hooks.json");
5336
+ const hooksPath = join20(c.home, ".factory", "hooks.json");
5248
5337
  const hooks = readJson(hooksPath);
5249
5338
  if (!existsSync10(hooksPath)) {
5250
- const fallback = readJson(join18(c.home, ".factory", "settings.json")).hooks;
5339
+ const fallback = readJson(join20(c.home, ".factory", "settings.json")).hooks;
5251
5340
  if (fallback && typeof fallback === "object" && !Array.isArray(fallback)) {
5252
5341
  Object.assign(hooks, fallback);
5253
5342
  }
@@ -5256,7 +5345,7 @@ var factoryDroid = {
5256
5345
  writeJson(hooksPath, hooks);
5257
5346
  c.log?.(`factory-droid: hooks merged into ${hooksPath}`);
5258
5347
  installSkill(c, "factory-droid");
5259
- const mcpPath = join18(c.home, ".factory", "mcp.json");
5348
+ const mcpPath = join20(c.home, ".factory", "mcp.json");
5260
5349
  const mcp = readJson(mcpPath);
5261
5350
  mcp.mcpServers = mcp.mcpServers ?? {};
5262
5351
  mcp.mcpServers.hindsight = mcpServerEntry(c.dist, "factory-droid");
@@ -5264,14 +5353,14 @@ var factoryDroid = {
5264
5353
  c.log?.(`factory-droid: MCP server registered in ${mcpPath}`);
5265
5354
  },
5266
5355
  uninstall(c) {
5267
- const hooksPath = join18(c.home, ".factory", "hooks.json");
5356
+ const hooksPath = join20(c.home, ".factory", "hooks.json");
5268
5357
  if (existsSync10(hooksPath)) {
5269
5358
  const hooks = readJson(hooksPath);
5270
5359
  stripHarnessHooks(hooks, "factory-droid");
5271
5360
  if (Object.keys(hooks).length) writeJson(hooksPath, hooks);
5272
5361
  else rmSync3(hooksPath);
5273
5362
  }
5274
- const mcpPath = join18(c.home, ".factory", "mcp.json");
5363
+ const mcpPath = join20(c.home, ".factory", "mcp.json");
5275
5364
  if (existsSync10(mcpPath)) {
5276
5365
  const mcp = readJson(mcpPath);
5277
5366
  if (isOurMcpEntry(mcp.mcpServers?.hindsight)) {
@@ -5286,7 +5375,7 @@ var factoryDroid = {
5286
5375
  };
5287
5376
  var zcode = {
5288
5377
  name: "zcode",
5289
- detect: (c) => onPath2("zcode") || existsSync10(join18(c.home, ".zcode")),
5378
+ detect: (c) => onPath2("zcode") || existsSync10(join20(c.home, ".zcode")),
5290
5379
  preflight(c) {
5291
5380
  const configPath = zcodeConfigPath(c);
5292
5381
  const existing = readJson(configPath).mcp?.servers?.hindsight;
@@ -5366,18 +5455,18 @@ function importConversations(harness, ctx) {
5366
5455
  return;
5367
5456
  }
5368
5457
  const turns = found.sessions.reduce((n, s) => n + s.turns.length, 0);
5369
- const file = join18(mkdtempSync2(join18(tmpdir6(), "hindsight-import-")), "conversations.json");
5458
+ const file = join20(mkdtempSync2(join20(tmpdir5(), "hindsight-import-")), "conversations.json");
5370
5459
  writeFileSync4(file, JSON.stringify(found.sessions));
5371
5460
  ctx.log?.(
5372
5461
  `${harness}: importing ${found.sessions.length} past sessions (${turns} turns) from ${repo} \u2014 this runs extraction and may take a while`
5373
5462
  );
5374
5463
  try {
5375
- execFileSync6("node", [join18(ctx.dist, "deepen.js"), "--repo", repo, "--conversations", file], {
5464
+ execFileSync6("node", [join20(ctx.dist, "deepen.js"), "--repo", repo, "--conversations", file], {
5376
5465
  stdio: "inherit"
5377
5466
  });
5378
5467
  } catch {
5379
5468
  ctx.log?.(`${harness}: conversation import did not finish \u2014 re-run it any time with:`);
5380
- ctx.log?.(` node "${join18(ctx.dist, "deepen.js")}" --repo "${repo}" --conversations "${file}"`);
5469
+ ctx.log?.(` node "${join20(ctx.dist, "deepen.js")}" --repo "${repo}" --conversations "${file}"`);
5381
5470
  }
5382
5471
  }
5383
5472
  function run(argv, ctxIn) {
@@ -5386,6 +5475,10 @@ function run(argv, ctxIn) {
5386
5475
  const importHistory = rawArgs.includes("--import-conversations");
5387
5476
  const valueArgs = flagValueArgs(rawArgs, ["server", "api-url", "api-token"]);
5388
5477
  const names = rawArgs.filter((a) => !a.startsWith("--") && !valueArgs.has(a));
5478
+ if (command === "stats") {
5479
+ ctx.log?.(formatUsageReport(readUsage()));
5480
+ return 0;
5481
+ }
5389
5482
  if (command === "install" || command === "update") ctx = stageRuntime(ctx);
5390
5483
  if (command === "update") {
5391
5484
  ctx.log?.(
@@ -5397,6 +5490,7 @@ function run(argv, ctxIn) {
5397
5490
  ctx.log?.(
5398
5491
  `usage: hindsight-coding-agents <install|uninstall> <all|harness...>
5399
5492
  hindsight-coding-agents update
5493
+ hindsight-coding-agents stats
5400
5494
  [--server cloud|self-hosted|daemon] [--api-url <url>] [--api-token <token>]
5401
5495
  [--import-conversations]
5402
5496
  all every agent detected on this machine
@@ -5480,12 +5574,12 @@ if (isMain || mainPath?.endsWith("installer.js")) {
5480
5574
  const pkgRoot = dirname11(dist);
5481
5575
  let version;
5482
5576
  try {
5483
- version = JSON.parse(readFileSync14(join18(pkgRoot, "package.json"), "utf8")).version;
5577
+ version = JSON.parse(readFileSync15(join20(pkgRoot, "package.json"), "utf8")).version;
5484
5578
  } catch {
5485
5579
  version = void 0;
5486
5580
  }
5487
5581
  const ui = createInstallerUi({
5488
- home: homedir10(),
5582
+ home: homedir11(),
5489
5583
  command: process.argv[2],
5490
5584
  version,
5491
5585
  harnessNames: INSTALLERS.map((i) => i.name),
@@ -5495,7 +5589,7 @@ if (isMain || mainPath?.endsWith("installer.js")) {
5495
5589
  });
5496
5590
  ui.intro();
5497
5591
  const code = run(process.argv.slice(2), {
5498
- home: homedir10(),
5592
+ home: homedir11(),
5499
5593
  pkgRoot,
5500
5594
  dist,
5501
5595
  // Only a real terminal gets prompted; piped/CI installs take the documented default.