@cleocode/adapters 2026.4.37 → 2026.4.39

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/index.js CHANGED
@@ -163,7 +163,9 @@ var init_context_monitor = __esm({
163
163
  });
164
164
 
165
165
  // packages/adapters/src/providers/claude-code/hooks.ts
166
+ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
166
167
  import { readdir, readFile } from "node:fs/promises";
168
+ import { homedir as homedir3 } from "node:os";
167
169
  import { join as join3 } from "node:path";
168
170
  var PROVIDER_ID, CLAUDE_CODE_EVENT_MAP, ClaudeCodeHookProvider;
169
171
  var init_hooks = __esm({
@@ -218,32 +220,112 @@ var init_hooks = __esm({
218
220
  mapProviderEvent(providerEvent) {
219
221
  return CLAUDE_CODE_EVENT_MAP[providerEvent] ?? null;
220
222
  }
223
+ /** Project directory this hook provider was registered for. */
224
+ projectDir = null;
221
225
  /**
222
226
  * Register native hooks for a project.
223
227
  *
224
- * For Claude Code, hooks are registered via the config system
225
- * (`~/.claude/settings.json`), managed by the install provider.
226
- * This method marks hooks as registered without performing filesystem operations.
228
+ * Writes CLEO hook entries to `~/.claude/settings.json` so that Claude Code's
229
+ * native event system calls cleo CLI commands when events fire. This bridges
230
+ * Claude Code's event loop to CLEO's internal hook dispatch.
227
231
  *
228
- * Iterating supported events is handled at install time using
229
- * `getSupportedCanonicalEvents()` to enumerate all 14 supported hooks.
232
+ * Idempotent: skips writing if CLEO hooks already exist in settings.json.
230
233
  *
231
- * @param _projectDir - Project directory (unused; Claude Code uses global config)
232
- * @task T164
234
+ * Hook entries registered:
235
+ * - `Stop` → `cleo session end --quiet` (triggers LLM extraction, reflector, consolidation)
236
+ * - `PostToolUse` (Write|Edit) → brain observation for file modifications
237
+ * - `SubagentStop` → brain observation for agent completion
238
+ *
239
+ * @param projectDir - Project directory for context-scoped hook commands
240
+ * @task T164 @task T555
233
241
  */
234
- async registerNativeHooks(_projectDir) {
242
+ async registerNativeHooks(projectDir) {
243
+ this.projectDir = projectDir;
235
244
  this.registered = true;
245
+ try {
246
+ const home = homedir3();
247
+ const settingsPath = join3(home, ".claude", "settings.json");
248
+ let settings = {};
249
+ if (existsSync2(settingsPath)) {
250
+ try {
251
+ settings = JSON.parse(readFileSync2(settingsPath, "utf-8"));
252
+ } catch {
253
+ }
254
+ }
255
+ const hooks = settings.hooks ?? {};
256
+ const alreadyRegistered = Object.values(hooks).some(
257
+ (entries) => Array.isArray(entries) && entries.some(
258
+ (e) => typeof e === "object" && e !== null && Array.isArray(e.hooks) && e.hooks.some(
259
+ (h) => typeof h.command === "string" && h.command.includes("# cleo-hook")
260
+ )
261
+ )
262
+ );
263
+ if (alreadyRegistered) {
264
+ return;
265
+ }
266
+ if (!hooks.Stop) hooks.Stop = [];
267
+ hooks.Stop.push({
268
+ matcher: "",
269
+ hooks: [
270
+ {
271
+ type: "command",
272
+ command: `cleo session end --quiet # cleo-hook`
273
+ }
274
+ ]
275
+ });
276
+ if (!hooks.PostToolUse) hooks.PostToolUse = [];
277
+ hooks.PostToolUse.push({
278
+ matcher: "Write|Edit",
279
+ hooks: [
280
+ {
281
+ type: "command",
282
+ command: `cleo observe "File modified via $TOOL_NAME" --title "tool-use" --quiet # cleo-hook`
283
+ }
284
+ ]
285
+ });
286
+ settings.hooks = hooks;
287
+ mkdirSync(join3(home, ".claude"), { recursive: true });
288
+ writeFileSync2(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
289
+ } catch {
290
+ }
236
291
  }
237
292
  /**
238
293
  * Unregister native hooks.
239
294
  *
240
- * For Claude Code, this is a no-op since hooks are managed through the config
241
- * system. Unregistration happens via the install provider's uninstall method.
295
+ * Removes CLEO hook entries from `~/.claude/settings.json` by filtering out
296
+ * entries containing the `# cleo-hook` marker.
242
297
  *
243
- * @task T164
298
+ * @task T164 @task T555
244
299
  */
245
300
  async unregisterNativeHooks() {
246
301
  this.registered = false;
302
+ this.projectDir = null;
303
+ try {
304
+ const home = homedir3();
305
+ const settingsPath = join3(home, ".claude", "settings.json");
306
+ if (!existsSync2(settingsPath)) return;
307
+ const settings = JSON.parse(readFileSync2(settingsPath, "utf-8"));
308
+ const hooks = settings.hooks;
309
+ if (!hooks) return;
310
+ let changed = false;
311
+ for (const [event, entries] of Object.entries(hooks)) {
312
+ if (!Array.isArray(entries)) continue;
313
+ const filtered = entries.filter(
314
+ (e) => !(typeof e === "object" && e !== null && Array.isArray(e.hooks) && e.hooks.some(
315
+ (h) => typeof h.command === "string" && h.command.includes("# cleo-hook")
316
+ ))
317
+ );
318
+ if (filtered.length !== entries.length) {
319
+ hooks[event] = filtered;
320
+ changed = true;
321
+ }
322
+ }
323
+ if (changed) {
324
+ settings.hooks = hooks;
325
+ writeFileSync2(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
326
+ }
327
+ } catch {
328
+ }
247
329
  }
248
330
  /**
249
331
  * Check whether hooks have been registered via `registerNativeHooks`.
@@ -251,6 +333,14 @@ var init_hooks = __esm({
251
333
  isRegistered() {
252
334
  return this.registered;
253
335
  }
336
+ /**
337
+ * Get the project directory this hook provider was registered for.
338
+ *
339
+ * Returns null if hooks have not been registered yet.
340
+ */
341
+ getProjectDir() {
342
+ return this.projectDir;
343
+ }
254
344
  /**
255
345
  * Get the native→canonical event mapping for introspection and debugging.
256
346
  *
@@ -389,13 +479,13 @@ var init_hooks = __esm({
389
479
  // packages/adapters/src/providers/claude-code/install.ts
390
480
  import {
391
481
  copyFileSync,
392
- existsSync as existsSync2,
393
- mkdirSync,
482
+ existsSync as existsSync3,
483
+ mkdirSync as mkdirSync2,
394
484
  readdirSync,
395
- readFileSync as readFileSync2,
396
- writeFileSync as writeFileSync2
485
+ readFileSync as readFileSync3,
486
+ writeFileSync as writeFileSync3
397
487
  } from "node:fs";
398
- import { homedir as homedir3 } from "node:os";
488
+ import { homedir as homedir4 } from "node:os";
399
489
  import { dirname as dirname2, join as join4 } from "node:path";
400
490
  import { fileURLToPath } from "node:url";
401
491
  function getAdapterCommandsDir() {
@@ -451,10 +541,10 @@ var init_install = __esm({
451
541
  * Checks for plugin enabled in ~/.claude/settings.json.
452
542
  */
453
543
  async isInstalled() {
454
- const settingsPath = join4(homedir3(), ".claude", "settings.json");
455
- if (existsSync2(settingsPath)) {
544
+ const settingsPath = join4(homedir4(), ".claude", "settings.json");
545
+ if (existsSync3(settingsPath)) {
456
546
  try {
457
- const settings = JSON.parse(readFileSync2(settingsPath, "utf-8"));
547
+ const settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
458
548
  const plugins = settings.enabledPlugins;
459
549
  if (plugins && plugins["cleo@cleocode"] === true) {
460
550
  return true;
@@ -483,8 +573,8 @@ var init_install = __esm({
483
573
  const claudeMdPath = join4(projectDir, "CLAUDE.md");
484
574
  let content = "";
485
575
  let existed = false;
486
- if (existsSync2(claudeMdPath)) {
487
- content = readFileSync2(claudeMdPath, "utf-8");
576
+ if (existsSync3(claudeMdPath)) {
577
+ content = readFileSync3(claudeMdPath, "utf-8");
488
578
  existed = true;
489
579
  }
490
580
  const missingRefs = INSTRUCTION_REFERENCES.filter((ref) => !content.includes(ref));
@@ -498,7 +588,7 @@ var init_install = __esm({
498
588
  } else {
499
589
  content = refsBlock + "\n";
500
590
  }
501
- writeFileSync2(claudeMdPath, content, "utf-8");
591
+ writeFileSync3(claudeMdPath, content, "utf-8");
502
592
  return true;
503
593
  }
504
594
  /**
@@ -512,11 +602,11 @@ var init_install = __esm({
512
602
  */
513
603
  installCommands(projectDir) {
514
604
  const adapterCommandsDir = getAdapterCommandsDir();
515
- if (!existsSync2(adapterCommandsDir)) {
605
+ if (!existsSync3(adapterCommandsDir)) {
516
606
  return [];
517
607
  }
518
608
  const targetDir = join4(projectDir, ".claude", "commands");
519
- mkdirSync(targetDir, { recursive: true });
609
+ mkdirSync2(targetDir, { recursive: true });
520
610
  const installed = [];
521
611
  const files = readdirSync(adapterCommandsDir).filter((f) => f.endsWith(".md"));
522
612
  for (const file of files) {
@@ -533,12 +623,12 @@ var init_install = __esm({
533
623
  * @returns Description of what was registered, or null if no change needed
534
624
  */
535
625
  registerPlugin() {
536
- const home = homedir3();
626
+ const home = homedir4();
537
627
  const settingsPath = join4(home, ".claude", "settings.json");
538
628
  let settings = {};
539
- if (existsSync2(settingsPath)) {
629
+ if (existsSync3(settingsPath)) {
540
630
  try {
541
- settings = JSON.parse(readFileSync2(settingsPath, "utf-8"));
631
+ settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
542
632
  } catch {
543
633
  }
544
634
  }
@@ -552,8 +642,8 @@ var init_install = __esm({
552
642
  }
553
643
  enabledPlugins[pluginKey] = true;
554
644
  settings.enabledPlugins = enabledPlugins;
555
- mkdirSync(join4(home, ".claude"), { recursive: true });
556
- writeFileSync2(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
645
+ mkdirSync2(join4(home, ".claude"), { recursive: true });
646
+ writeFileSync3(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
557
647
  return `Enabled ${pluginKey} in ~/.claude/settings.json`;
558
648
  }
559
649
  };
@@ -957,8 +1047,8 @@ var init_transport = __esm({
957
1047
 
958
1048
  // packages/adapters/src/providers/claude-code/adapter.ts
959
1049
  import { exec as exec2 } from "node:child_process";
960
- import { existsSync as existsSync3 } from "node:fs";
961
- import { homedir as homedir4 } from "node:os";
1050
+ import { existsSync as existsSync4 } from "node:fs";
1051
+ import { homedir as homedir5 } from "node:os";
962
1052
  import { join as join6 } from "node:path";
963
1053
  import { promisify as promisify2 } from "node:util";
964
1054
  var execAsync2, ClaudeCodeAdapter;
@@ -1049,6 +1139,7 @@ var init_adapter = __esm({
1049
1139
  async initialize(projectDir) {
1050
1140
  this.projectDir = projectDir;
1051
1141
  this.initialized = true;
1142
+ await this.hooks.registerNativeHooks(projectDir);
1052
1143
  }
1053
1144
  /**
1054
1145
  * Dispose the adapter and clean up resources.
@@ -1089,8 +1180,8 @@ var init_adapter = __esm({
1089
1180
  } catch {
1090
1181
  details.cliAvailable = false;
1091
1182
  }
1092
- const claudeConfigDir = join6(homedir4(), ".claude");
1093
- const configExists = existsSync3(claudeConfigDir);
1183
+ const claudeConfigDir = join6(homedir5(), ".claude");
1184
+ const configExists = existsSync4(claudeConfigDir);
1094
1185
  details.configDirExists = configExists;
1095
1186
  const entrypointSet = process.env.CLAUDE_CODE_ENTRYPOINT !== void 0;
1096
1187
  details.entrypointEnvSet = entrypointSet;
@@ -1119,17 +1210,17 @@ var init_adapter = __esm({
1119
1210
  });
1120
1211
 
1121
1212
  // packages/adapters/src/providers/claude-code/statusline.ts
1122
- import { existsSync as existsSync4, readFileSync as readFileSync3 } from "node:fs";
1123
- import { homedir as homedir5 } from "node:os";
1213
+ import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
1214
+ import { homedir as homedir6 } from "node:os";
1124
1215
  import { join as join7 } from "node:path";
1125
1216
  function getClaudeSettingsPath() {
1126
- return process.env["CLAUDE_SETTINGS"] ?? join7(process.env["CLAUDE_HOME"] ?? join7(homedir5(), ".claude"), "settings.json");
1217
+ return process.env["CLAUDE_SETTINGS"] ?? join7(process.env["CLAUDE_HOME"] ?? join7(homedir6(), ".claude"), "settings.json");
1127
1218
  }
1128
1219
  function checkStatuslineIntegration() {
1129
1220
  const settingsPath = getClaudeSettingsPath();
1130
- if (!existsSync4(settingsPath)) return "no_settings";
1221
+ if (!existsSync5(settingsPath)) return "no_settings";
1131
1222
  try {
1132
- const settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
1223
+ const settings = JSON.parse(readFileSync4(settingsPath, "utf-8"));
1133
1224
  const statusLine = settings.statusLine;
1134
1225
  if (!statusLine?.type) return "not_configured";
1135
1226
  if (statusLine.type !== "command") return "custom_no_cleo";
@@ -1137,10 +1228,10 @@ function checkStatuslineIntegration() {
1137
1228
  if (cmd.includes("context-monitor.sh") || cmd.includes("cleo-statusline") || cmd.includes(".context-state.json") || cmd.includes("context-states")) {
1138
1229
  return "configured";
1139
1230
  }
1140
- const scriptPath = cmd.startsWith("~") ? cmd.replace("~", homedir5()) : cmd;
1141
- if (existsSync4(scriptPath)) {
1231
+ const scriptPath = cmd.startsWith("~") ? cmd.replace("~", homedir6()) : cmd;
1232
+ if (existsSync5(scriptPath)) {
1142
1233
  try {
1143
- const content = readFileSync3(scriptPath, "utf-8");
1234
+ const content = readFileSync4(scriptPath, "utf-8");
1144
1235
  if (content.includes("context-state.json")) return "configured";
1145
1236
  } catch {
1146
1237
  }
@@ -1365,7 +1456,7 @@ var init_hooks2 = __esm({
1365
1456
  });
1366
1457
 
1367
1458
  // packages/adapters/src/providers/cursor/install.ts
1368
- import { existsSync as existsSync7, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
1459
+ import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "node:fs";
1369
1460
  import { join as join12 } from "node:path";
1370
1461
  var INSTRUCTION_REFERENCES3, CursorInstallProvider;
1371
1462
  var init_install2 = __esm({
@@ -1409,13 +1500,13 @@ var init_install2 = __esm({
1409
1500
  */
1410
1501
  async isInstalled() {
1411
1502
  const mdcPath = join12(process.cwd(), ".cursor", "rules", "cleo.mdc");
1412
- if (existsSync7(mdcPath)) {
1503
+ if (existsSync8(mdcPath)) {
1413
1504
  return true;
1414
1505
  }
1415
1506
  const rulesPath = join12(process.cwd(), ".cursorrules");
1416
- if (existsSync7(rulesPath)) {
1507
+ if (existsSync8(rulesPath)) {
1417
1508
  try {
1418
- const content = readFileSync5(rulesPath, "utf-8");
1509
+ const content = readFileSync6(rulesPath, "utf-8");
1419
1510
  if (INSTRUCTION_REFERENCES3.some((ref) => content.includes(ref))) {
1420
1511
  return true;
1421
1512
  }
@@ -1459,17 +1550,17 @@ var init_install2 = __esm({
1459
1550
  */
1460
1551
  updateLegacyRules(projectDir) {
1461
1552
  const rulesPath = join12(projectDir, ".cursorrules");
1462
- if (!existsSync7(rulesPath)) {
1553
+ if (!existsSync8(rulesPath)) {
1463
1554
  return false;
1464
1555
  }
1465
- let content = readFileSync5(rulesPath, "utf-8");
1556
+ let content = readFileSync6(rulesPath, "utf-8");
1466
1557
  const missingRefs = INSTRUCTION_REFERENCES3.filter((ref) => !content.includes(ref));
1467
1558
  if (missingRefs.length === 0) {
1468
1559
  return false;
1469
1560
  }
1470
1561
  const separator = content.endsWith("\n") ? "" : "\n";
1471
1562
  content = content + separator + missingRefs.join("\n") + "\n";
1472
- writeFileSync4(rulesPath, content, "utf-8");
1563
+ writeFileSync5(rulesPath, content, "utf-8");
1473
1564
  return true;
1474
1565
  }
1475
1566
  /**
@@ -1493,14 +1584,14 @@ var init_install2 = __esm({
1493
1584
  ...INSTRUCTION_REFERENCES3,
1494
1585
  ""
1495
1586
  ].join("\n");
1496
- if (existsSync7(mdcPath)) {
1497
- const existing = readFileSync5(mdcPath, "utf-8");
1587
+ if (existsSync8(mdcPath)) {
1588
+ const existing = readFileSync6(mdcPath, "utf-8");
1498
1589
  if (existing === expectedContent) {
1499
1590
  return false;
1500
1591
  }
1501
1592
  }
1502
- mkdirSync2(rulesDir, { recursive: true });
1503
- writeFileSync4(mdcPath, expectedContent, "utf-8");
1593
+ mkdirSync3(rulesDir, { recursive: true });
1594
+ writeFileSync5(mdcPath, expectedContent, "utf-8");
1504
1595
  return true;
1505
1596
  }
1506
1597
  /**
@@ -1508,7 +1599,7 @@ var init_install2 = __esm({
1508
1599
  */
1509
1600
  getUpdatedFileList(projectDir) {
1510
1601
  const files = [];
1511
- if (existsSync7(join12(projectDir, ".cursorrules"))) {
1602
+ if (existsSync8(join12(projectDir, ".cursorrules"))) {
1512
1603
  files.push(join12(projectDir, ".cursorrules"));
1513
1604
  }
1514
1605
  files.push(join12(projectDir, ".cursor", "rules", "cleo.mdc"));
@@ -1519,7 +1610,7 @@ var init_install2 = __esm({
1519
1610
  });
1520
1611
 
1521
1612
  // packages/adapters/src/providers/cursor/adapter.ts
1522
- import { existsSync as existsSync8 } from "node:fs";
1613
+ import { existsSync as existsSync9 } from "node:fs";
1523
1614
  import { join as join13 } from "node:path";
1524
1615
  var CursorAdapter;
1525
1616
  var init_adapter2 = __esm({
@@ -1615,13 +1706,13 @@ var init_adapter2 = __esm({
1615
1706
  let configExists = false;
1616
1707
  if (this.projectDir) {
1617
1708
  const cursorConfigDir = join13(this.projectDir, ".cursor");
1618
- configExists = existsSync8(cursorConfigDir);
1709
+ configExists = existsSync9(cursorConfigDir);
1619
1710
  details.configDirExists = configExists;
1620
1711
  }
1621
1712
  const editorEnvSet = process.env.CURSOR_EDITOR !== void 0;
1622
1713
  details.editorEnvSet = editorEnvSet;
1623
1714
  if (this.projectDir) {
1624
- const legacyRulesExist = existsSync8(join13(this.projectDir, ".cursorrules"));
1715
+ const legacyRulesExist = existsSync9(join13(this.projectDir, ".cursorrules"));
1625
1716
  details.legacyRulesExist = legacyRulesExist;
1626
1717
  }
1627
1718
  const healthy = configExists || editorEnvSet;
@@ -1825,7 +1916,7 @@ var init_hooks3 = __esm({
1825
1916
  });
1826
1917
 
1827
1918
  // packages/adapters/src/providers/opencode/install.ts
1828
- import { existsSync as existsSync13, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "node:fs";
1919
+ import { existsSync as existsSync14, readFileSync as readFileSync9, writeFileSync as writeFileSync8 } from "node:fs";
1829
1920
  import { join as join19 } from "node:path";
1830
1921
  var INSTRUCTION_REFERENCES6, OpenCodeInstallProvider;
1831
1922
  var init_install3 = __esm({
@@ -1869,9 +1960,9 @@ var init_install3 = __esm({
1869
1960
  */
1870
1961
  async isInstalled() {
1871
1962
  const agentsMdPath = join19(process.cwd(), "AGENTS.md");
1872
- if (existsSync13(agentsMdPath)) {
1963
+ if (existsSync14(agentsMdPath)) {
1873
1964
  try {
1874
- const content = readFileSync8(agentsMdPath, "utf-8");
1965
+ const content = readFileSync9(agentsMdPath, "utf-8");
1875
1966
  if (INSTRUCTION_REFERENCES6.some((ref) => content.includes(ref))) {
1876
1967
  return true;
1877
1968
  }
@@ -1899,8 +1990,8 @@ var init_install3 = __esm({
1899
1990
  const agentsMdPath = join19(projectDir, "AGENTS.md");
1900
1991
  let content = "";
1901
1992
  let existed = false;
1902
- if (existsSync13(agentsMdPath)) {
1903
- content = readFileSync8(agentsMdPath, "utf-8");
1993
+ if (existsSync14(agentsMdPath)) {
1994
+ content = readFileSync9(agentsMdPath, "utf-8");
1904
1995
  existed = true;
1905
1996
  }
1906
1997
  const missingRefs = INSTRUCTION_REFERENCES6.filter((ref) => !content.includes(ref));
@@ -1914,7 +2005,7 @@ var init_install3 = __esm({
1914
2005
  } else {
1915
2006
  content = refsBlock + "\n";
1916
2007
  }
1917
- writeFileSync7(agentsMdPath, content, "utf-8");
2008
+ writeFileSync8(agentsMdPath, content, "utf-8");
1918
2009
  return true;
1919
2010
  }
1920
2011
  };
@@ -2104,7 +2195,7 @@ var init_spawn2 = __esm({
2104
2195
 
2105
2196
  // packages/adapters/src/providers/opencode/adapter.ts
2106
2197
  import { exec as exec7 } from "node:child_process";
2107
- import { existsSync as existsSync14 } from "node:fs";
2198
+ import { existsSync as existsSync15 } from "node:fs";
2108
2199
  import { join as join21 } from "node:path";
2109
2200
  import { promisify as promisify7 } from "node:util";
2110
2201
  var execAsync7, OpenCodeAdapter;
@@ -2218,7 +2309,7 @@ var init_adapter3 = __esm({
2218
2309
  }
2219
2310
  if (this.projectDir) {
2220
2311
  const openCodeConfigDir = join21(this.projectDir, ".opencode");
2221
- const configExists = existsSync14(openCodeConfigDir);
2312
+ const configExists = existsSync15(openCodeConfigDir);
2222
2313
  details.configDirExists = configExists;
2223
2314
  }
2224
2315
  const versionEnvSet = process.env.OPENCODE_VERSION !== void 0;
@@ -2427,21 +2518,21 @@ var init_hooks4 = __esm({
2427
2518
  });
2428
2519
 
2429
2520
  // packages/adapters/src/providers/pi/install.ts
2430
- import { existsSync as existsSync15, mkdirSync as mkdirSync3, readFileSync as readFileSync9, writeFileSync as writeFileSync8 } from "node:fs";
2431
- import { homedir as homedir11 } from "node:os";
2521
+ import { existsSync as existsSync16, mkdirSync as mkdirSync4, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "node:fs";
2522
+ import { homedir as homedir12 } from "node:os";
2432
2523
  import { join as join22 } from "node:path";
2433
2524
  function getPiAgentDir() {
2434
2525
  const env = process.env["PI_CODING_AGENT_DIR"];
2435
2526
  if (env !== void 0 && env.length > 0) {
2436
- if (env === "~") return homedir11();
2437
- if (env.startsWith("~/")) return join22(homedir11(), env.slice(2));
2527
+ if (env === "~") return homedir12();
2528
+ if (env.startsWith("~/")) return join22(homedir12(), env.slice(2));
2438
2529
  return env;
2439
2530
  }
2440
2531
  const piHome = process.env["PI_HOME"];
2441
2532
  if (piHome !== void 0 && piHome.length > 0) {
2442
2533
  return join22(piHome, "agent");
2443
2534
  }
2444
- return join22(homedir11(), ".pi", "agent");
2535
+ return join22(homedir12(), ".pi", "agent");
2445
2536
  }
2446
2537
  var INSTRUCTION_REFERENCES7, PiInstallProvider;
2447
2538
  var init_install4 = __esm({
@@ -2494,9 +2585,9 @@ var init_install4 = __esm({
2494
2585
  */
2495
2586
  async isInstalled() {
2496
2587
  const agentsMdPath = join22(process.cwd(), "AGENTS.md");
2497
- if (existsSync15(agentsMdPath)) {
2588
+ if (existsSync16(agentsMdPath)) {
2498
2589
  try {
2499
- const content = readFileSync9(agentsMdPath, "utf-8");
2590
+ const content = readFileSync10(agentsMdPath, "utf-8");
2500
2591
  if (INSTRUCTION_REFERENCES7.some((ref) => content.includes(ref))) {
2501
2592
  return true;
2502
2593
  }
@@ -2505,8 +2596,8 @@ var init_install4 = __esm({
2505
2596
  }
2506
2597
  try {
2507
2598
  const globalPath = join22(getPiAgentDir(), "AGENTS.md");
2508
- if (existsSync15(globalPath)) {
2509
- const content = readFileSync9(globalPath, "utf-8");
2599
+ if (existsSync16(globalPath)) {
2600
+ const content = readFileSync10(globalPath, "utf-8");
2510
2601
  if (INSTRUCTION_REFERENCES7.some((ref) => content.includes(ref))) {
2511
2602
  return true;
2512
2603
  }
@@ -2536,8 +2627,8 @@ var init_install4 = __esm({
2536
2627
  const filePath = join22(dir, filename);
2537
2628
  let content = "";
2538
2629
  let existed = false;
2539
- if (existsSync15(filePath)) {
2540
- content = readFileSync9(filePath, "utf-8");
2630
+ if (existsSync16(filePath)) {
2631
+ content = readFileSync10(filePath, "utf-8");
2541
2632
  existed = true;
2542
2633
  }
2543
2634
  const missingRefs = INSTRUCTION_REFERENCES7.filter((ref) => !content.includes(ref));
@@ -2549,10 +2640,10 @@ var init_install4 = __esm({
2549
2640
  const separator = content.endsWith("\n") ? "" : "\n";
2550
2641
  content = content + separator + refsBlock + "\n";
2551
2642
  } else {
2552
- mkdirSync3(dir, { recursive: true });
2643
+ mkdirSync4(dir, { recursive: true });
2553
2644
  content = refsBlock + "\n";
2554
2645
  }
2555
- writeFileSync8(filePath, content, "utf-8");
2646
+ writeFileSync9(filePath, content, "utf-8");
2556
2647
  return true;
2557
2648
  }
2558
2649
  };
@@ -2712,22 +2803,22 @@ var init_spawn3 = __esm({
2712
2803
 
2713
2804
  // packages/adapters/src/providers/pi/adapter.ts
2714
2805
  import { exec as exec9 } from "node:child_process";
2715
- import { existsSync as existsSync16 } from "node:fs";
2716
- import { homedir as homedir12 } from "node:os";
2806
+ import { existsSync as existsSync17 } from "node:fs";
2807
+ import { homedir as homedir13 } from "node:os";
2717
2808
  import { join as join23 } from "node:path";
2718
2809
  import { promisify as promisify9 } from "node:util";
2719
2810
  function getPiAgentDir2() {
2720
2811
  const env = process.env["PI_CODING_AGENT_DIR"];
2721
2812
  if (env !== void 0 && env.length > 0) {
2722
- if (env === "~") return homedir12();
2723
- if (env.startsWith("~/")) return join23(homedir12(), env.slice(2));
2813
+ if (env === "~") return homedir13();
2814
+ if (env.startsWith("~/")) return join23(homedir13(), env.slice(2));
2724
2815
  return env;
2725
2816
  }
2726
2817
  const piHome = process.env["PI_HOME"];
2727
2818
  if (piHome !== void 0 && piHome.length > 0) {
2728
2819
  return join23(piHome, "agent");
2729
2820
  }
2730
- return join23(homedir12(), ".pi", "agent");
2821
+ return join23(homedir13(), ".pi", "agent");
2731
2822
  }
2732
2823
  var execAsync9, PiAdapter;
2733
2824
  var init_adapter4 = __esm({
@@ -2845,12 +2936,12 @@ var init_adapter4 = __esm({
2845
2936
  details.cliAvailable = false;
2846
2937
  }
2847
2938
  const agentDir = getPiAgentDir2();
2848
- const agentDirExists = existsSync16(agentDir);
2939
+ const agentDirExists = existsSync17(agentDir);
2849
2940
  details.agentDirExists = agentDirExists;
2850
2941
  details.agentDir = agentDir;
2851
2942
  if (this.projectDir) {
2852
2943
  const projectPiDir = join23(this.projectDir, ".pi");
2853
- details.projectPiDirExists = existsSync16(projectPiDir);
2944
+ details.projectPiDirExists = existsSync17(projectPiDir);
2854
2945
  }
2855
2946
  details.piCodingAgentDirSet = process.env["PI_CODING_AGENT_DIR"] !== void 0;
2856
2947
  details.piHomeSet = process.env["PI_HOME"] !== void 0;
@@ -2910,13 +3001,13 @@ init_claude_code();
2910
3001
 
2911
3002
  // packages/adapters/src/providers/codex/adapter.ts
2912
3003
  import { exec as exec3 } from "node:child_process";
2913
- import { existsSync as existsSync6 } from "node:fs";
2914
- import { homedir as homedir7 } from "node:os";
3004
+ import { existsSync as existsSync7 } from "node:fs";
3005
+ import { homedir as homedir8 } from "node:os";
2915
3006
  import { join as join11 } from "node:path";
2916
3007
  import { promisify as promisify3 } from "node:util";
2917
3008
 
2918
3009
  // packages/adapters/src/providers/codex/hooks.ts
2919
- import { homedir as homedir6 } from "node:os";
3010
+ import { homedir as homedir7 } from "node:os";
2920
3011
  import { join as join9 } from "node:path";
2921
3012
 
2922
3013
  // packages/adapters/src/providers/shared/transcript-reader.ts
@@ -3036,12 +3127,12 @@ var CodexHookProvider = class {
3036
3127
  * @task T162 @epic T134
3037
3128
  */
3038
3129
  async getTranscript(_sessionId, _projectDir) {
3039
- return readLatestTranscript(join9(homedir6(), ".codex"));
3130
+ return readLatestTranscript(join9(homedir7(), ".codex"));
3040
3131
  }
3041
3132
  };
3042
3133
 
3043
3134
  // packages/adapters/src/providers/codex/install.ts
3044
- import { existsSync as existsSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
3135
+ import { existsSync as existsSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
3045
3136
  import { join as join10 } from "node:path";
3046
3137
  var INSTRUCTION_REFERENCES2 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
3047
3138
  var CodexInstallProvider = class {
@@ -3084,9 +3175,9 @@ var CodexInstallProvider = class {
3084
3175
  */
3085
3176
  async isInstalled() {
3086
3177
  const agentsMdPath = join10(process.cwd(), "AGENTS.md");
3087
- if (existsSync5(agentsMdPath)) {
3178
+ if (existsSync6(agentsMdPath)) {
3088
3179
  try {
3089
- const content = readFileSync4(agentsMdPath, "utf-8");
3180
+ const content = readFileSync5(agentsMdPath, "utf-8");
3090
3181
  if (INSTRUCTION_REFERENCES2.some((ref) => content.includes(ref))) {
3091
3182
  return true;
3092
3183
  }
@@ -3116,8 +3207,8 @@ var CodexInstallProvider = class {
3116
3207
  const agentsMdPath = join10(projectDir, "AGENTS.md");
3117
3208
  let content = "";
3118
3209
  let existed = false;
3119
- if (existsSync5(agentsMdPath)) {
3120
- content = readFileSync4(agentsMdPath, "utf-8");
3210
+ if (existsSync6(agentsMdPath)) {
3211
+ content = readFileSync5(agentsMdPath, "utf-8");
3121
3212
  existed = true;
3122
3213
  }
3123
3214
  const missingRefs = INSTRUCTION_REFERENCES2.filter((ref) => !content.includes(ref));
@@ -3131,7 +3222,7 @@ var CodexInstallProvider = class {
3131
3222
  } else {
3132
3223
  content = refsBlock + "\n";
3133
3224
  }
3134
- writeFileSync3(agentsMdPath, content, "utf-8");
3225
+ writeFileSync4(agentsMdPath, content, "utf-8");
3135
3226
  return true;
3136
3227
  }
3137
3228
  };
@@ -3221,8 +3312,8 @@ var CodexAdapter = class {
3221
3312
  } catch {
3222
3313
  details.cliAvailable = false;
3223
3314
  }
3224
- const codexConfigDir = join11(homedir7(), ".codex");
3225
- const configExists = existsSync6(codexConfigDir);
3315
+ const codexConfigDir = join11(homedir8(), ".codex");
3316
+ const configExists = existsSync7(codexConfigDir);
3226
3317
  details.configDirExists = configExists;
3227
3318
  const healthy = cliAvailable;
3228
3319
  details.cliAvailable = cliAvailable;
@@ -3258,13 +3349,13 @@ init_cursor();
3258
3349
 
3259
3350
  // packages/adapters/src/providers/gemini-cli/adapter.ts
3260
3351
  import { exec as exec4 } from "node:child_process";
3261
- import { existsSync as existsSync10 } from "node:fs";
3262
- import { homedir as homedir9 } from "node:os";
3352
+ import { existsSync as existsSync11 } from "node:fs";
3353
+ import { homedir as homedir10 } from "node:os";
3263
3354
  import { join as join16 } from "node:path";
3264
3355
  import { promisify as promisify4 } from "node:util";
3265
3356
 
3266
3357
  // packages/adapters/src/providers/gemini-cli/hooks.ts
3267
- import { homedir as homedir8 } from "node:os";
3358
+ import { homedir as homedir9 } from "node:os";
3268
3359
  import { join as join14 } from "node:path";
3269
3360
  var GEMINI_CLI_EVENT_MAP = {
3270
3361
  SessionStart: "SessionStart",
@@ -3343,12 +3434,12 @@ var GeminiCliHookProvider = class {
3343
3434
  * @task T161 @epic T134
3344
3435
  */
3345
3436
  async getTranscript(_sessionId, _projectDir) {
3346
- return readLatestTranscript(join14(homedir8(), ".gemini"));
3437
+ return readLatestTranscript(join14(homedir9(), ".gemini"));
3347
3438
  }
3348
3439
  };
3349
3440
 
3350
3441
  // packages/adapters/src/providers/gemini-cli/install.ts
3351
- import { existsSync as existsSync9, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "node:fs";
3442
+ import { existsSync as existsSync10, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "node:fs";
3352
3443
  import { join as join15 } from "node:path";
3353
3444
  var INSTRUCTION_REFERENCES4 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
3354
3445
  var GeminiCliInstallProvider = class {
@@ -3391,9 +3482,9 @@ var GeminiCliInstallProvider = class {
3391
3482
  */
3392
3483
  async isInstalled() {
3393
3484
  const agentsMdPath = join15(process.cwd(), "AGENTS.md");
3394
- if (existsSync9(agentsMdPath)) {
3485
+ if (existsSync10(agentsMdPath)) {
3395
3486
  try {
3396
- const content = readFileSync6(agentsMdPath, "utf-8");
3487
+ const content = readFileSync7(agentsMdPath, "utf-8");
3397
3488
  if (INSTRUCTION_REFERENCES4.some((ref) => content.includes(ref))) {
3398
3489
  return true;
3399
3490
  }
@@ -3423,8 +3514,8 @@ var GeminiCliInstallProvider = class {
3423
3514
  const agentsMdPath = join15(projectDir, "AGENTS.md");
3424
3515
  let content = "";
3425
3516
  let existed = false;
3426
- if (existsSync9(agentsMdPath)) {
3427
- content = readFileSync6(agentsMdPath, "utf-8");
3517
+ if (existsSync10(agentsMdPath)) {
3518
+ content = readFileSync7(agentsMdPath, "utf-8");
3428
3519
  existed = true;
3429
3520
  }
3430
3521
  const missingRefs = INSTRUCTION_REFERENCES4.filter((ref) => !content.includes(ref));
@@ -3438,7 +3529,7 @@ var GeminiCliInstallProvider = class {
3438
3529
  } else {
3439
3530
  content = refsBlock + "\n";
3440
3531
  }
3441
- writeFileSync5(agentsMdPath, content, "utf-8");
3532
+ writeFileSync6(agentsMdPath, content, "utf-8");
3442
3533
  return true;
3443
3534
  }
3444
3535
  };
@@ -3539,8 +3630,8 @@ var GeminiCliAdapter = class {
3539
3630
  } catch {
3540
3631
  details.cliAvailable = false;
3541
3632
  }
3542
- const geminiConfigDir = join16(homedir9(), ".gemini");
3543
- const configExists = existsSync10(geminiConfigDir);
3633
+ const geminiConfigDir = join16(homedir10(), ".gemini");
3634
+ const configExists = existsSync11(geminiConfigDir);
3544
3635
  details.configDirExists = configExists;
3545
3636
  const healthy = cliAvailable;
3546
3637
  details.cliAvailable = cliAvailable;
@@ -3573,8 +3664,8 @@ function createAdapter4() {
3573
3664
 
3574
3665
  // packages/adapters/src/providers/kimi/adapter.ts
3575
3666
  import { exec as exec5 } from "node:child_process";
3576
- import { existsSync as existsSync12 } from "node:fs";
3577
- import { homedir as homedir10 } from "node:os";
3667
+ import { existsSync as existsSync13 } from "node:fs";
3668
+ import { homedir as homedir11 } from "node:os";
3578
3669
  import { join as join18 } from "node:path";
3579
3670
  import { promisify as promisify5 } from "node:util";
3580
3671
 
@@ -3634,7 +3725,7 @@ var KimiHookProvider = class {
3634
3725
  };
3635
3726
 
3636
3727
  // packages/adapters/src/providers/kimi/install.ts
3637
- import { existsSync as existsSync11, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "node:fs";
3728
+ import { existsSync as existsSync12, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "node:fs";
3638
3729
  import { join as join17 } from "node:path";
3639
3730
  var INSTRUCTION_REFERENCES5 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
3640
3731
  var KimiInstallProvider = class {
@@ -3677,9 +3768,9 @@ var KimiInstallProvider = class {
3677
3768
  */
3678
3769
  async isInstalled() {
3679
3770
  const agentsMdPath = join17(process.cwd(), "AGENTS.md");
3680
- if (existsSync11(agentsMdPath)) {
3771
+ if (existsSync12(agentsMdPath)) {
3681
3772
  try {
3682
- const content = readFileSync7(agentsMdPath, "utf-8");
3773
+ const content = readFileSync8(agentsMdPath, "utf-8");
3683
3774
  if (INSTRUCTION_REFERENCES5.some((ref) => content.includes(ref))) {
3684
3775
  return true;
3685
3776
  }
@@ -3709,8 +3800,8 @@ var KimiInstallProvider = class {
3709
3800
  const agentsMdPath = join17(projectDir, "AGENTS.md");
3710
3801
  let content = "";
3711
3802
  let existed = false;
3712
- if (existsSync11(agentsMdPath)) {
3713
- content = readFileSync7(agentsMdPath, "utf-8");
3803
+ if (existsSync12(agentsMdPath)) {
3804
+ content = readFileSync8(agentsMdPath, "utf-8");
3714
3805
  existed = true;
3715
3806
  }
3716
3807
  const missingRefs = INSTRUCTION_REFERENCES5.filter((ref) => !content.includes(ref));
@@ -3724,7 +3815,7 @@ var KimiInstallProvider = class {
3724
3815
  } else {
3725
3816
  content = refsBlock + "\n";
3726
3817
  }
3727
- writeFileSync6(agentsMdPath, content, "utf-8");
3818
+ writeFileSync7(agentsMdPath, content, "utf-8");
3728
3819
  return true;
3729
3820
  }
3730
3821
  };
@@ -3812,8 +3903,8 @@ var KimiAdapter = class {
3812
3903
  } catch {
3813
3904
  details.cliAvailable = false;
3814
3905
  }
3815
- const kimiConfigDir = join18(homedir10(), ".kimi");
3816
- const configExists = existsSync12(kimiConfigDir);
3906
+ const kimiConfigDir = join18(homedir11(), ".kimi");
3907
+ const configExists = existsSync13(kimiConfigDir);
3817
3908
  details.configDirExists = configExists;
3818
3909
  const healthy = cliAvailable;
3819
3910
  details.cliAvailable = cliAvailable;
@@ -3848,7 +3939,7 @@ function createAdapter5() {
3848
3939
  init_opencode();
3849
3940
 
3850
3941
  // packages/adapters/src/registry.ts
3851
- import { readFileSync as readFileSync10 } from "node:fs";
3942
+ import { readFileSync as readFileSync11 } from "node:fs";
3852
3943
  import { dirname as dirname3, join as join24, resolve } from "node:path";
3853
3944
  import { fileURLToPath as fileURLToPath2 } from "node:url";
3854
3945
  var PROVIDER_IDS = ["claude-code", "opencode", "cursor", "pi"];
@@ -3858,7 +3949,7 @@ function getProviderManifests() {
3858
3949
  for (const providerId of PROVIDER_IDS) {
3859
3950
  try {
3860
3951
  const manifestPath = join24(baseDir, providerId, "manifest.json");
3861
- const raw = readFileSync10(manifestPath, "utf-8");
3952
+ const raw = readFileSync11(manifestPath, "utf-8");
3862
3953
  manifests.push(JSON.parse(raw));
3863
3954
  } catch {
3864
3955
  }