@cleocode/adapters 2026.3.74 → 2026.4.0

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
@@ -550,6 +550,13 @@ var init_operations = __esm({
550
550
  }
551
551
  });
552
552
 
553
+ // packages/contracts/src/orchestration-hierarchy.ts
554
+ var init_orchestration_hierarchy = __esm({
555
+ "packages/contracts/src/orchestration-hierarchy.ts"() {
556
+ "use strict";
557
+ }
558
+ });
559
+
553
560
  // packages/contracts/src/session.ts
554
561
  var init_session2 = __esm({
555
562
  "packages/contracts/src/session.ts"() {
@@ -564,6 +571,13 @@ var init_status_registry = __esm({
564
571
  }
565
572
  });
566
573
 
574
+ // packages/contracts/src/wasm/index.ts
575
+ var init_wasm = __esm({
576
+ "packages/contracts/src/wasm/index.ts"() {
577
+ "use strict";
578
+ }
579
+ });
580
+
567
581
  // packages/contracts/src/index.ts
568
582
  var init_src = __esm({
569
583
  "packages/contracts/src/index.ts"() {
@@ -572,8 +586,10 @@ var init_src = __esm({
572
586
  init_facade();
573
587
  init_lafs();
574
588
  init_operations();
589
+ init_orchestration_hierarchy();
575
590
  init_session2();
576
591
  init_status_registry();
592
+ init_wasm();
577
593
  }
578
594
  });
579
595
 
@@ -1100,7 +1116,7 @@ var init_hooks2 = __esm({
1100
1116
 
1101
1117
  // packages/adapters/src/providers/cursor/install.js
1102
1118
  import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
1103
- import { join as join10 } from "node:path";
1119
+ import { join as join11 } from "node:path";
1104
1120
  var INSTRUCTION_REFERENCES3, MCP_SERVER_KEY3, CursorInstallProvider;
1105
1121
  var init_install2 = __esm({
1106
1122
  "packages/adapters/src/providers/cursor/install.js"() {
@@ -1124,7 +1140,7 @@ var init_install2 = __esm({
1124
1140
  if (mcpServerPath) {
1125
1141
  mcpRegistered = this.registerMcpServer(projectDir, mcpServerPath);
1126
1142
  if (mcpRegistered) {
1127
- details.mcpConfigPath = join10(projectDir, ".cursor", "mcp.json");
1143
+ details.mcpConfigPath = join11(projectDir, ".cursor", "mcp.json");
1128
1144
  }
1129
1145
  }
1130
1146
  instructionFileUpdated = this.updateInstructionFiles(projectDir);
@@ -1149,7 +1165,7 @@ var init_install2 = __esm({
1149
1165
  async uninstall() {
1150
1166
  if (!this.installedProjectDir)
1151
1167
  return;
1152
- const mcpPath = join10(this.installedProjectDir, ".cursor", "mcp.json");
1168
+ const mcpPath = join11(this.installedProjectDir, ".cursor", "mcp.json");
1153
1169
  if (existsSync7(mcpPath)) {
1154
1170
  try {
1155
1171
  const raw = readFileSync5(mcpPath, "utf-8");
@@ -1170,7 +1186,7 @@ var init_install2 = __esm({
1170
1186
  * Checks for MCP server registered in .cursor/mcp.json.
1171
1187
  */
1172
1188
  async isInstalled() {
1173
- const mcpPath = join10(process.cwd(), ".cursor", "mcp.json");
1189
+ const mcpPath = join11(process.cwd(), ".cursor", "mcp.json");
1174
1190
  if (existsSync7(mcpPath)) {
1175
1191
  try {
1176
1192
  const config = JSON.parse(readFileSync5(mcpPath, "utf-8"));
@@ -1202,8 +1218,8 @@ var init_install2 = __esm({
1202
1218
  * @returns true if registration was performed or updated
1203
1219
  */
1204
1220
  registerMcpServer(projectDir, mcpServerPath) {
1205
- const cursorDir = join10(projectDir, ".cursor");
1206
- const mcpPath = join10(cursorDir, "mcp.json");
1221
+ const cursorDir = join11(projectDir, ".cursor");
1222
+ const mcpPath = join11(cursorDir, "mcp.json");
1207
1223
  let config = {};
1208
1224
  mkdirSync3(cursorDir, { recursive: true });
1209
1225
  if (existsSync7(mcpPath)) {
@@ -1247,7 +1263,7 @@ var init_install2 = __esm({
1247
1263
  * @returns true if the file was modified
1248
1264
  */
1249
1265
  updateLegacyRules(projectDir) {
1250
- const rulesPath = join10(projectDir, ".cursorrules");
1266
+ const rulesPath = join11(projectDir, ".cursorrules");
1251
1267
  if (!existsSync7(rulesPath)) {
1252
1268
  return false;
1253
1269
  }
@@ -1270,8 +1286,8 @@ var init_install2 = __esm({
1270
1286
  * @returns true if the file was created or modified
1271
1287
  */
1272
1288
  updateModernRules(projectDir) {
1273
- const rulesDir = join10(projectDir, ".cursor", "rules");
1274
- const mdcPath = join10(rulesDir, "cleo.mdc");
1289
+ const rulesDir = join11(projectDir, ".cursor", "rules");
1290
+ const mdcPath = join11(rulesDir, "cleo.mdc");
1275
1291
  const expectedContent = [
1276
1292
  "---",
1277
1293
  "description: CLEO task management protocol references",
@@ -1297,10 +1313,10 @@ var init_install2 = __esm({
1297
1313
  */
1298
1314
  getUpdatedFileList(projectDir) {
1299
1315
  const files = [];
1300
- if (existsSync7(join10(projectDir, ".cursorrules"))) {
1301
- files.push(join10(projectDir, ".cursorrules"));
1316
+ if (existsSync7(join11(projectDir, ".cursorrules"))) {
1317
+ files.push(join11(projectDir, ".cursorrules"));
1302
1318
  }
1303
- files.push(join10(projectDir, ".cursor", "rules", "cleo.mdc"));
1319
+ files.push(join11(projectDir, ".cursor", "rules", "cleo.mdc"));
1304
1320
  return files;
1305
1321
  }
1306
1322
  };
@@ -1309,7 +1325,7 @@ var init_install2 = __esm({
1309
1325
 
1310
1326
  // packages/adapters/src/providers/cursor/adapter.js
1311
1327
  import { existsSync as existsSync8 } from "node:fs";
1312
- import { join as join11 } from "node:path";
1328
+ import { join as join12 } from "node:path";
1313
1329
  var CursorAdapter;
1314
1330
  var init_adapter2 = __esm({
1315
1331
  "packages/adapters/src/providers/cursor/adapter.js"() {
@@ -1382,14 +1398,14 @@ var init_adapter2 = __esm({
1382
1398
  }
1383
1399
  let configExists = false;
1384
1400
  if (this.projectDir) {
1385
- const cursorConfigDir = join11(this.projectDir, ".cursor");
1401
+ const cursorConfigDir = join12(this.projectDir, ".cursor");
1386
1402
  configExists = existsSync8(cursorConfigDir);
1387
1403
  details.configDirExists = configExists;
1388
1404
  }
1389
1405
  const editorEnvSet = process.env.CURSOR_EDITOR !== void 0;
1390
1406
  details.editorEnvSet = editorEnvSet;
1391
1407
  if (this.projectDir) {
1392
- const legacyRulesExist = existsSync8(join11(this.projectDir, ".cursorrules"));
1408
+ const legacyRulesExist = existsSync8(join12(this.projectDir, ".cursorrules"));
1393
1409
  details.legacyRulesExist = legacyRulesExist;
1394
1410
  }
1395
1411
  const healthy = configExists || editorEnvSet;
@@ -1505,7 +1521,7 @@ var init_hooks3 = __esm({
1505
1521
 
1506
1522
  // packages/adapters/src/providers/opencode/install.js
1507
1523
  import { existsSync as existsSync13, mkdirSync as mkdirSync6, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "node:fs";
1508
- import { join as join17 } from "node:path";
1524
+ import { join as join18 } from "node:path";
1509
1525
  var INSTRUCTION_REFERENCES6, MCP_SERVER_KEY6, OpenCodeInstallProvider;
1510
1526
  var init_install3 = __esm({
1511
1527
  "packages/adapters/src/providers/opencode/install.js"() {
@@ -1529,12 +1545,12 @@ var init_install3 = __esm({
1529
1545
  if (mcpServerPath) {
1530
1546
  mcpRegistered = this.registerMcpServer(projectDir, mcpServerPath);
1531
1547
  if (mcpRegistered) {
1532
- details.mcpConfigPath = join17(projectDir, ".opencode", "config.json");
1548
+ details.mcpConfigPath = join18(projectDir, ".opencode", "config.json");
1533
1549
  }
1534
1550
  }
1535
1551
  instructionFileUpdated = this.updateInstructionFile(projectDir);
1536
1552
  if (instructionFileUpdated) {
1537
- details.instructionFile = join17(projectDir, "AGENTS.md");
1553
+ details.instructionFile = join18(projectDir, "AGENTS.md");
1538
1554
  }
1539
1555
  this.installedProjectDir = projectDir;
1540
1556
  return {
@@ -1554,7 +1570,7 @@ var init_install3 = __esm({
1554
1570
  async uninstall() {
1555
1571
  if (!this.installedProjectDir)
1556
1572
  return;
1557
- const configPath = join17(this.installedProjectDir, ".opencode", "config.json");
1573
+ const configPath = join18(this.installedProjectDir, ".opencode", "config.json");
1558
1574
  if (existsSync13(configPath)) {
1559
1575
  try {
1560
1576
  const raw = readFileSync8(configPath, "utf-8");
@@ -1576,7 +1592,7 @@ var init_install3 = __esm({
1576
1592
  * Returns true if the CLEO MCP server entry is found.
1577
1593
  */
1578
1594
  async isInstalled() {
1579
- const configPath = join17(process.cwd(), ".opencode", "config.json");
1595
+ const configPath = join18(process.cwd(), ".opencode", "config.json");
1580
1596
  if (existsSync13(configPath)) {
1581
1597
  try {
1582
1598
  const config = JSON.parse(readFileSync8(configPath, "utf-8"));
@@ -1608,8 +1624,8 @@ var init_install3 = __esm({
1608
1624
  * @returns true if registration was performed or updated
1609
1625
  */
1610
1626
  registerMcpServer(projectDir, mcpServerPath) {
1611
- const openCodeDir = join17(projectDir, ".opencode");
1612
- const configPath = join17(openCodeDir, "config.json");
1627
+ const openCodeDir = join18(projectDir, ".opencode");
1628
+ const configPath = join18(openCodeDir, "config.json");
1613
1629
  let config = {};
1614
1630
  mkdirSync6(openCodeDir, { recursive: true });
1615
1631
  if (existsSync13(configPath)) {
@@ -1635,7 +1651,7 @@ var init_install3 = __esm({
1635
1651
  * @returns true if the file was created or modified
1636
1652
  */
1637
1653
  updateInstructionFile(projectDir) {
1638
- const agentsMdPath = join17(projectDir, "AGENTS.md");
1654
+ const agentsMdPath = join18(projectDir, "AGENTS.md");
1639
1655
  let content = "";
1640
1656
  let existed = false;
1641
1657
  if (existsSync13(agentsMdPath)) {
@@ -1662,8 +1678,8 @@ var init_install3 = __esm({
1662
1678
 
1663
1679
  // packages/adapters/src/providers/opencode/spawn.js
1664
1680
  import { exec as exec6, spawn as nodeSpawn2 } from "node:child_process";
1665
- import { mkdir as mkdir2, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
1666
- import { join as join18 } from "node:path";
1681
+ import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
1682
+ import { join as join19 } from "node:path";
1667
1683
  import { promisify as promisify6 } from "node:util";
1668
1684
  function buildOpenCodeAgentMarkdown(description, instructions) {
1669
1685
  const normalizedDesc = description.replace(/\s+/g, " ").trim();
@@ -1679,8 +1695,8 @@ function buildOpenCodeAgentMarkdown(description, instructions) {
1679
1695
  ].join("\n");
1680
1696
  }
1681
1697
  async function ensureSubagentDefinition(workingDirectory) {
1682
- const agentDir = join18(workingDirectory, ".opencode", "agent");
1683
- const agentPath = join18(agentDir, `${OPENCODE_SUBAGENT_NAME}.md`);
1698
+ const agentDir = join19(workingDirectory, ".opencode", "agent");
1699
+ const agentPath = join19(agentDir, `${OPENCODE_SUBAGENT_NAME}.md`);
1684
1700
  const description = "CLEO task executor with protocol compliance.";
1685
1701
  const instructions = [
1686
1702
  "# CLEO Subagent",
@@ -1694,7 +1710,7 @@ async function ensureSubagentDefinition(workingDirectory) {
1694
1710
  await mkdir2(agentDir, { recursive: true });
1695
1711
  let existing = null;
1696
1712
  try {
1697
- existing = await readFile4(agentPath, "utf-8");
1713
+ existing = await readFile3(agentPath, "utf-8");
1698
1714
  } catch {
1699
1715
  existing = null;
1700
1716
  }
@@ -1841,7 +1857,7 @@ var init_spawn2 = __esm({
1841
1857
  // packages/adapters/src/providers/opencode/adapter.js
1842
1858
  import { exec as exec7 } from "node:child_process";
1843
1859
  import { existsSync as existsSync14 } from "node:fs";
1844
- import { join as join19 } from "node:path";
1860
+ import { join as join20 } from "node:path";
1845
1861
  import { promisify as promisify7 } from "node:util";
1846
1862
  var execAsync7, OpenCodeAdapter;
1847
1863
  var init_adapter3 = __esm({
@@ -1938,7 +1954,7 @@ var init_adapter3 = __esm({
1938
1954
  details.cliAvailable = false;
1939
1955
  }
1940
1956
  if (this.projectDir) {
1941
- const openCodeConfigDir = join19(this.projectDir, ".opencode");
1957
+ const openCodeConfigDir = join20(this.projectDir, ".opencode");
1942
1958
  const configExists = existsSync14(openCodeConfigDir);
1943
1959
  details.configDirExists = configExists;
1944
1960
  }
@@ -2000,13 +2016,61 @@ init_claude_code();
2000
2016
  // packages/adapters/src/providers/codex/adapter.ts
2001
2017
  import { exec as exec3 } from "node:child_process";
2002
2018
  import { existsSync as existsSync6 } from "node:fs";
2003
- import { homedir as homedir7 } from "node:os";
2004
- import { join as join9 } from "node:path";
2019
+ import { homedir as homedir8 } from "node:os";
2020
+ import { join as join10 } from "node:path";
2005
2021
  import { promisify as promisify3 } from "node:util";
2006
2022
 
2007
2023
  // packages/adapters/src/providers/codex/hooks.ts
2024
+ import { homedir as homedir6 } from "node:os";
2025
+ import { join as join8 } from "node:path";
2026
+
2027
+ // packages/adapters/src/providers/shared/transcript-reader.ts
2008
2028
  import { readdir, readFile as readFile2 } from "node:fs/promises";
2009
2029
  import { join as join7 } from "node:path";
2030
+ function parseTranscriptLines(raw) {
2031
+ const turns = [];
2032
+ const lines = raw.split("\n").filter((l) => l.trim());
2033
+ for (const line of lines) {
2034
+ try {
2035
+ const entry = JSON.parse(line);
2036
+ const role = entry.role;
2037
+ const content = entry.content;
2038
+ if (typeof role === "string" && typeof content === "string") {
2039
+ turns.push({ role, content });
2040
+ }
2041
+ } catch {
2042
+ }
2043
+ }
2044
+ return turns;
2045
+ }
2046
+ async function readLatestTranscript(providerDir) {
2047
+ let allFiles = [];
2048
+ try {
2049
+ const entries = await readdir(providerDir, { withFileTypes: true });
2050
+ for (const entry of entries) {
2051
+ if (!entry.isFile()) continue;
2052
+ const name = entry.name;
2053
+ if (name.endsWith(".json") || name.endsWith(".jsonl")) {
2054
+ allFiles.push(join7(providerDir, name));
2055
+ }
2056
+ }
2057
+ } catch {
2058
+ return null;
2059
+ }
2060
+ if (allFiles.length === 0) return null;
2061
+ allFiles = allFiles.sort((a, b) => b.localeCompare(a));
2062
+ const mostRecent = allFiles[0];
2063
+ if (!mostRecent) return null;
2064
+ try {
2065
+ const raw = await readFile2(mostRecent, "utf-8");
2066
+ const turns = parseTranscriptLines(raw);
2067
+ return turns.length > 0 ? turns.map((t) => `${t.role}: ${t.content}`).join("\n") : null;
2068
+ } catch {
2069
+ return null;
2070
+ }
2071
+ }
2072
+
2073
+ // packages/adapters/src/providers/codex/hooks.ts
2010
2074
  var CODEX_EVENT_MAP = {
2011
2075
  SessionStart: "SessionStart",
2012
2076
  PromptSubmit: "UserPromptSubmit",
@@ -2066,8 +2130,8 @@ var CodexHookProvider = class {
2066
2130
  /**
2067
2131
  * Extract a plain-text transcript from Codex CLI session data.
2068
2132
  *
2069
- * Reads the most recent session file under ~/.codex/ and extracts
2070
- * turn text into a flat string for brain observation extraction.
2133
+ * Reads the most recent JSON/JSONL session file under `~/.codex/`
2134
+ * and returns its turns as a flat string for brain observation extraction.
2071
2135
  *
2072
2136
  * Returns null when no session data is found or on any read error.
2073
2137
  *
@@ -2076,53 +2140,14 @@ var CodexHookProvider = class {
2076
2140
  * @task T162 @epic T134
2077
2141
  */
2078
2142
  async getTranscript(_sessionId, _projectDir) {
2079
- try {
2080
- const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? "/root";
2081
- const codexDir = join7(homeDir, ".codex");
2082
- let allFiles = [];
2083
- try {
2084
- const entries = await readdir(codexDir, { withFileTypes: true });
2085
- for (const entry of entries) {
2086
- if (!entry.isFile()) continue;
2087
- const name = entry.name;
2088
- if (name.endsWith(".json") || name.endsWith(".jsonl")) {
2089
- allFiles.push(join7(codexDir, name));
2090
- }
2091
- }
2092
- } catch {
2093
- return null;
2094
- }
2095
- if (allFiles.length === 0) return null;
2096
- allFiles = allFiles.sort((a, b) => b.localeCompare(a));
2097
- const mostRecent = allFiles[0];
2098
- if (!mostRecent) return null;
2099
- const raw = await readFile2(mostRecent, "utf-8");
2100
- const turns = [];
2101
- const lines = raw.split("\n").filter((l) => l.trim());
2102
- for (const line of lines) {
2103
- try {
2104
- const entry = JSON.parse(line);
2105
- const role = entry.role;
2106
- const content = entry.content;
2107
- if (role === "assistant" && typeof content === "string") {
2108
- turns.push(`assistant: ${content}`);
2109
- } else if (role === "user" && typeof content === "string") {
2110
- turns.push(`user: ${content}`);
2111
- }
2112
- } catch {
2113
- }
2114
- }
2115
- return turns.length > 0 ? turns.join("\n") : null;
2116
- } catch {
2117
- return null;
2118
- }
2143
+ return readLatestTranscript(join8(homedir6(), ".codex"));
2119
2144
  }
2120
2145
  };
2121
2146
 
2122
2147
  // packages/adapters/src/providers/codex/install.ts
2123
2148
  import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
2124
- import { homedir as homedir6 } from "node:os";
2125
- import { join as join8 } from "node:path";
2149
+ import { homedir as homedir7 } from "node:os";
2150
+ import { join as join9 } from "node:path";
2126
2151
  var INSTRUCTION_REFERENCES2 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
2127
2152
  var MCP_SERVER_KEY2 = "cleo";
2128
2153
  var CodexInstallProvider = class {
@@ -2142,12 +2167,12 @@ var CodexInstallProvider = class {
2142
2167
  if (mcpServerPath) {
2143
2168
  mcpRegistered = this.registerMcpServer(mcpServerPath);
2144
2169
  if (mcpRegistered) {
2145
- details.mcpConfigPath = join8(homedir6(), ".codex", "config.json");
2170
+ details.mcpConfigPath = join9(homedir7(), ".codex", "config.json");
2146
2171
  }
2147
2172
  }
2148
2173
  instructionFileUpdated = this.updateInstructionFile(projectDir);
2149
2174
  if (instructionFileUpdated) {
2150
- details.instructionFile = join8(projectDir, "AGENTS.md");
2175
+ details.instructionFile = join9(projectDir, "AGENTS.md");
2151
2176
  }
2152
2177
  return {
2153
2178
  success: true,
@@ -2165,7 +2190,7 @@ var CodexInstallProvider = class {
2165
2190
  * @task T162
2166
2191
  */
2167
2192
  async uninstall() {
2168
- const configPath = join8(homedir6(), ".codex", "config.json");
2193
+ const configPath = join9(homedir7(), ".codex", "config.json");
2169
2194
  if (existsSync5(configPath)) {
2170
2195
  try {
2171
2196
  const raw = readFileSync4(configPath, "utf-8");
@@ -2187,7 +2212,7 @@ var CodexInstallProvider = class {
2187
2212
  * @task T162
2188
2213
  */
2189
2214
  async isInstalled() {
2190
- const configPath = join8(homedir6(), ".codex", "config.json");
2215
+ const configPath = join9(homedir7(), ".codex", "config.json");
2191
2216
  if (existsSync5(configPath)) {
2192
2217
  try {
2193
2218
  const config = JSON.parse(readFileSync4(configPath, "utf-8"));
@@ -2221,8 +2246,8 @@ var CodexInstallProvider = class {
2221
2246
  * @returns true if registration was performed or updated
2222
2247
  */
2223
2248
  registerMcpServer(mcpServerPath) {
2224
- const codexDir = join8(homedir6(), ".codex");
2225
- const configPath = join8(codexDir, "config.json");
2249
+ const codexDir = join9(homedir7(), ".codex");
2250
+ const configPath = join9(codexDir, "config.json");
2226
2251
  let config = {};
2227
2252
  mkdirSync2(codexDir, { recursive: true });
2228
2253
  if (existsSync5(configPath)) {
@@ -2249,7 +2274,7 @@ var CodexInstallProvider = class {
2249
2274
  * @returns true if the file was created or modified
2250
2275
  */
2251
2276
  updateInstructionFile(projectDir) {
2252
- const agentsMdPath = join8(projectDir, "AGENTS.md");
2277
+ const agentsMdPath = join9(projectDir, "AGENTS.md");
2253
2278
  let content = "";
2254
2279
  let existed = false;
2255
2280
  if (existsSync5(agentsMdPath)) {
@@ -2350,7 +2375,7 @@ var CodexAdapter = class {
2350
2375
  } catch {
2351
2376
  details.cliAvailable = false;
2352
2377
  }
2353
- const codexConfigDir = join9(homedir7(), ".codex");
2378
+ const codexConfigDir = join10(homedir8(), ".codex");
2354
2379
  const configExists = existsSync6(codexConfigDir);
2355
2380
  details.configDirExists = configExists;
2356
2381
  const healthy = cliAvailable;
@@ -2388,13 +2413,13 @@ init_cursor();
2388
2413
  // packages/adapters/src/providers/gemini-cli/adapter.ts
2389
2414
  import { exec as exec4 } from "node:child_process";
2390
2415
  import { existsSync as existsSync10 } from "node:fs";
2391
- import { homedir as homedir9 } from "node:os";
2392
- import { join as join14 } from "node:path";
2416
+ import { homedir as homedir11 } from "node:os";
2417
+ import { join as join15 } from "node:path";
2393
2418
  import { promisify as promisify4 } from "node:util";
2394
2419
 
2395
2420
  // packages/adapters/src/providers/gemini-cli/hooks.ts
2396
- import { readdir as readdir2, readFile as readFile3 } from "node:fs/promises";
2397
- import { join as join12 } from "node:path";
2421
+ import { homedir as homedir9 } from "node:os";
2422
+ import { join as join13 } from "node:path";
2398
2423
  var GEMINI_CLI_EVENT_MAP = {
2399
2424
  SessionStart: "SessionStart",
2400
2425
  SessionEnd: "SessionEnd",
@@ -2461,8 +2486,8 @@ var GeminiCliHookProvider = class {
2461
2486
  /**
2462
2487
  * Extract a plain-text transcript from Gemini CLI session data.
2463
2488
  *
2464
- * Reads the most recent session file under ~/.gemini/ and extracts
2465
- * turn text into a flat string for brain observation extraction.
2489
+ * Reads the most recent JSON/JSONL session file under `~/.gemini/`
2490
+ * and returns its turns as a flat string for brain observation extraction.
2466
2491
  *
2467
2492
  * Returns null when no session data is found or on any read error.
2468
2493
  *
@@ -2471,53 +2496,14 @@ var GeminiCliHookProvider = class {
2471
2496
  * @task T161 @epic T134
2472
2497
  */
2473
2498
  async getTranscript(_sessionId, _projectDir) {
2474
- try {
2475
- const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? "/root";
2476
- const geminiDir = join12(homeDir, ".gemini");
2477
- let allFiles = [];
2478
- try {
2479
- const entries = await readdir2(geminiDir, { withFileTypes: true });
2480
- for (const entry of entries) {
2481
- if (!entry.isFile()) continue;
2482
- const name = entry.name;
2483
- if (name.endsWith(".json") || name.endsWith(".jsonl")) {
2484
- allFiles.push(join12(geminiDir, name));
2485
- }
2486
- }
2487
- } catch {
2488
- return null;
2489
- }
2490
- if (allFiles.length === 0) return null;
2491
- allFiles = allFiles.sort((a, b) => b.localeCompare(a));
2492
- const mostRecent = allFiles[0];
2493
- if (!mostRecent) return null;
2494
- const raw = await readFile3(mostRecent, "utf-8");
2495
- const turns = [];
2496
- const lines = raw.split("\n").filter((l) => l.trim());
2497
- for (const line of lines) {
2498
- try {
2499
- const entry = JSON.parse(line);
2500
- const role = entry.role;
2501
- const content = entry.content;
2502
- if (role === "assistant" && typeof content === "string") {
2503
- turns.push(`assistant: ${content}`);
2504
- } else if (role === "user" && typeof content === "string") {
2505
- turns.push(`user: ${content}`);
2506
- }
2507
- } catch {
2508
- }
2509
- }
2510
- return turns.length > 0 ? turns.join("\n") : null;
2511
- } catch {
2512
- return null;
2513
- }
2499
+ return readLatestTranscript(join13(homedir9(), ".gemini"));
2514
2500
  }
2515
2501
  };
2516
2502
 
2517
2503
  // packages/adapters/src/providers/gemini-cli/install.ts
2518
2504
  import { existsSync as existsSync9, mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "node:fs";
2519
- import { homedir as homedir8 } from "node:os";
2520
- import { join as join13 } from "node:path";
2505
+ import { homedir as homedir10 } from "node:os";
2506
+ import { join as join14 } from "node:path";
2521
2507
  var INSTRUCTION_REFERENCES4 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
2522
2508
  var MCP_SERVER_KEY4 = "cleo";
2523
2509
  var GeminiCliInstallProvider = class {
@@ -2537,12 +2523,12 @@ var GeminiCliInstallProvider = class {
2537
2523
  if (mcpServerPath) {
2538
2524
  mcpRegistered = this.registerMcpServer(mcpServerPath);
2539
2525
  if (mcpRegistered) {
2540
- details.mcpConfigPath = join13(homedir8(), ".gemini", "settings.json");
2526
+ details.mcpConfigPath = join14(homedir10(), ".gemini", "settings.json");
2541
2527
  }
2542
2528
  }
2543
2529
  instructionFileUpdated = this.updateInstructionFile(projectDir);
2544
2530
  if (instructionFileUpdated) {
2545
- details.instructionFile = join13(projectDir, "AGENTS.md");
2531
+ details.instructionFile = join14(projectDir, "AGENTS.md");
2546
2532
  }
2547
2533
  return {
2548
2534
  success: true,
@@ -2560,7 +2546,7 @@ var GeminiCliInstallProvider = class {
2560
2546
  * @task T161
2561
2547
  */
2562
2548
  async uninstall() {
2563
- const settingsPath = join13(homedir8(), ".gemini", "settings.json");
2549
+ const settingsPath = join14(homedir10(), ".gemini", "settings.json");
2564
2550
  if (existsSync9(settingsPath)) {
2565
2551
  try {
2566
2552
  const raw = readFileSync6(settingsPath, "utf-8");
@@ -2582,7 +2568,7 @@ var GeminiCliInstallProvider = class {
2582
2568
  * @task T161
2583
2569
  */
2584
2570
  async isInstalled() {
2585
- const settingsPath = join13(homedir8(), ".gemini", "settings.json");
2571
+ const settingsPath = join14(homedir10(), ".gemini", "settings.json");
2586
2572
  if (existsSync9(settingsPath)) {
2587
2573
  try {
2588
2574
  const config = JSON.parse(readFileSync6(settingsPath, "utf-8"));
@@ -2616,8 +2602,8 @@ var GeminiCliInstallProvider = class {
2616
2602
  * @returns true if registration was performed or updated
2617
2603
  */
2618
2604
  registerMcpServer(mcpServerPath) {
2619
- const geminiDir = join13(homedir8(), ".gemini");
2620
- const settingsPath = join13(geminiDir, "settings.json");
2605
+ const geminiDir = join14(homedir10(), ".gemini");
2606
+ const settingsPath = join14(geminiDir, "settings.json");
2621
2607
  let config = {};
2622
2608
  mkdirSync4(geminiDir, { recursive: true });
2623
2609
  if (existsSync9(settingsPath)) {
@@ -2644,7 +2630,7 @@ var GeminiCliInstallProvider = class {
2644
2630
  * @returns true if the file was created or modified
2645
2631
  */
2646
2632
  updateInstructionFile(projectDir) {
2647
- const agentsMdPath = join13(projectDir, "AGENTS.md");
2633
+ const agentsMdPath = join14(projectDir, "AGENTS.md");
2648
2634
  let content = "";
2649
2635
  let existed = false;
2650
2636
  if (existsSync9(agentsMdPath)) {
@@ -2756,7 +2742,7 @@ var GeminiCliAdapter = class {
2756
2742
  } catch {
2757
2743
  details.cliAvailable = false;
2758
2744
  }
2759
- const geminiConfigDir = join14(homedir9(), ".gemini");
2745
+ const geminiConfigDir = join15(homedir11(), ".gemini");
2760
2746
  const configExists = existsSync10(geminiConfigDir);
2761
2747
  details.configDirExists = configExists;
2762
2748
  const healthy = cliAvailable;
@@ -2791,8 +2777,8 @@ function createAdapter4() {
2791
2777
  // packages/adapters/src/providers/kimi/adapter.ts
2792
2778
  import { exec as exec5 } from "node:child_process";
2793
2779
  import { existsSync as existsSync12 } from "node:fs";
2794
- import { homedir as homedir11 } from "node:os";
2795
- import { join as join16 } from "node:path";
2780
+ import { homedir as homedir13 } from "node:os";
2781
+ import { join as join17 } from "node:path";
2796
2782
  import { promisify as promisify5 } from "node:util";
2797
2783
 
2798
2784
  // packages/adapters/src/providers/kimi/hooks.ts
@@ -2851,8 +2837,8 @@ var KimiHookProvider = class {
2851
2837
 
2852
2838
  // packages/adapters/src/providers/kimi/install.ts
2853
2839
  import { existsSync as existsSync11, mkdirSync as mkdirSync5, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "node:fs";
2854
- import { homedir as homedir10 } from "node:os";
2855
- import { join as join15 } from "node:path";
2840
+ import { homedir as homedir12 } from "node:os";
2841
+ import { join as join16 } from "node:path";
2856
2842
  var INSTRUCTION_REFERENCES5 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
2857
2843
  var MCP_SERVER_KEY5 = "cleo";
2858
2844
  var KimiInstallProvider = class {
@@ -2872,12 +2858,12 @@ var KimiInstallProvider = class {
2872
2858
  if (mcpServerPath) {
2873
2859
  mcpRegistered = this.registerMcpServer(mcpServerPath);
2874
2860
  if (mcpRegistered) {
2875
- details.mcpConfigPath = join15(homedir10(), ".kimi", "mcp.json");
2861
+ details.mcpConfigPath = join16(homedir12(), ".kimi", "mcp.json");
2876
2862
  }
2877
2863
  }
2878
2864
  instructionFileUpdated = this.updateInstructionFile(projectDir);
2879
2865
  if (instructionFileUpdated) {
2880
- details.instructionFile = join15(projectDir, "AGENTS.md");
2866
+ details.instructionFile = join16(projectDir, "AGENTS.md");
2881
2867
  }
2882
2868
  return {
2883
2869
  success: true,
@@ -2895,7 +2881,7 @@ var KimiInstallProvider = class {
2895
2881
  * @task T163
2896
2882
  */
2897
2883
  async uninstall() {
2898
- const mcpPath = join15(homedir10(), ".kimi", "mcp.json");
2884
+ const mcpPath = join16(homedir12(), ".kimi", "mcp.json");
2899
2885
  if (existsSync11(mcpPath)) {
2900
2886
  try {
2901
2887
  const raw = readFileSync7(mcpPath, "utf-8");
@@ -2917,7 +2903,7 @@ var KimiInstallProvider = class {
2917
2903
  * @task T163
2918
2904
  */
2919
2905
  async isInstalled() {
2920
- const mcpPath = join15(homedir10(), ".kimi", "mcp.json");
2906
+ const mcpPath = join16(homedir12(), ".kimi", "mcp.json");
2921
2907
  if (existsSync11(mcpPath)) {
2922
2908
  try {
2923
2909
  const config = JSON.parse(readFileSync7(mcpPath, "utf-8"));
@@ -2951,8 +2937,8 @@ var KimiInstallProvider = class {
2951
2937
  * @returns true if registration was performed or updated
2952
2938
  */
2953
2939
  registerMcpServer(mcpServerPath) {
2954
- const kimiDir = join15(homedir10(), ".kimi");
2955
- const mcpPath = join15(kimiDir, "mcp.json");
2940
+ const kimiDir = join16(homedir12(), ".kimi");
2941
+ const mcpPath = join16(kimiDir, "mcp.json");
2956
2942
  let config = {};
2957
2943
  mkdirSync5(kimiDir, { recursive: true });
2958
2944
  if (existsSync11(mcpPath)) {
@@ -2979,7 +2965,7 @@ var KimiInstallProvider = class {
2979
2965
  * @returns true if the file was created or modified
2980
2966
  */
2981
2967
  updateInstructionFile(projectDir) {
2982
- const agentsMdPath = join15(projectDir, "AGENTS.md");
2968
+ const agentsMdPath = join16(projectDir, "AGENTS.md");
2983
2969
  let content = "";
2984
2970
  let existed = false;
2985
2971
  if (existsSync11(agentsMdPath)) {
@@ -3078,7 +3064,7 @@ var KimiAdapter = class {
3078
3064
  } catch {
3079
3065
  details.cliAvailable = false;
3080
3066
  }
3081
- const kimiConfigDir = join16(homedir11(), ".kimi");
3067
+ const kimiConfigDir = join17(homedir13(), ".kimi");
3082
3068
  const configExists = existsSync12(kimiConfigDir);
3083
3069
  details.configDirExists = configExists;
3084
3070
  const healthy = cliAvailable;
@@ -3115,7 +3101,7 @@ init_opencode();
3115
3101
 
3116
3102
  // packages/adapters/src/registry.js
3117
3103
  import { readFileSync as readFileSync9 } from "node:fs";
3118
- import { dirname as dirname2, join as join20, resolve } from "node:path";
3104
+ import { dirname as dirname2, join as join21, resolve } from "node:path";
3119
3105
  import { fileURLToPath } from "node:url";
3120
3106
  var PROVIDER_IDS = ["claude-code", "opencode", "cursor"];
3121
3107
  function getProviderManifests() {
@@ -3123,7 +3109,7 @@ function getProviderManifests() {
3123
3109
  const baseDir = resolve(dirname2(fileURLToPath(import.meta.url)), "providers");
3124
3110
  for (const providerId of PROVIDER_IDS) {
3125
3111
  try {
3126
- const manifestPath = join20(baseDir, providerId, "manifest.json");
3112
+ const manifestPath = join21(baseDir, providerId, "manifest.json");
3127
3113
  const raw = readFileSync9(manifestPath, "utf-8");
3128
3114
  manifests.push(JSON.parse(raw));
3129
3115
  } catch {