@cleocode/adapters 2026.3.73 → 2026.3.76
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 +132 -154
- package/dist/index.js.map +4 -4
- package/dist/providers/codex/hooks.d.ts +2 -2
- package/dist/providers/codex/hooks.d.ts.map +1 -1
- package/dist/providers/gemini-cli/hooks.d.ts +2 -2
- package/dist/providers/gemini-cli/hooks.d.ts.map +1 -1
- package/dist/providers/shared/transcript-reader.d.ts +43 -0
- package/dist/providers/shared/transcript-reader.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/providers/codex/hooks.ts +5 -52
- package/src/providers/gemini-cli/hooks.ts +5 -52
- package/src/providers/shared/transcript-reader.ts +123 -0
- package/dist/providers/claude-code/adapter.js +0 -165
- package/dist/providers/claude-code/adapter.js.map +0 -1
- package/dist/providers/claude-code/context-monitor.js +0 -148
- package/dist/providers/claude-code/context-monitor.js.map +0 -1
- package/dist/providers/claude-code/hooks.js +0 -279
- package/dist/providers/claude-code/hooks.js.map +0 -1
- package/dist/providers/claude-code/index.js +0 -26
- package/dist/providers/claude-code/index.js.map +0 -1
- package/dist/providers/claude-code/install.js +0 -234
- package/dist/providers/claude-code/install.js.map +0 -1
- package/dist/providers/claude-code/paths.js +0 -33
- package/dist/providers/claude-code/paths.js.map +0 -1
- package/dist/providers/claude-code/spawn.js +0 -164
- package/dist/providers/claude-code/spawn.js.map +0 -1
- package/dist/providers/claude-code/statusline.js +0 -86
- package/dist/providers/claude-code/statusline.js.map +0 -1
- package/dist/providers/claude-code/task-sync.js +0 -111
- package/dist/providers/claude-code/task-sync.js.map +0 -1
- package/dist/providers/claude-code/transport.js +0 -18
- package/dist/providers/claude-code/transport.js.map +0 -1
- package/dist/providers/codex/adapter.js +0 -134
- package/dist/providers/codex/adapter.js.map +0 -1
- package/dist/providers/codex/hooks.js +0 -155
- package/dist/providers/codex/hooks.js.map +0 -1
- package/dist/providers/codex/index.js +0 -24
- package/dist/providers/codex/index.js.map +0 -1
- package/dist/providers/codex/install.js +0 -183
- package/dist/providers/codex/install.js.map +0 -1
- package/dist/providers/cursor/adapter.js +0 -138
- package/dist/providers/cursor/adapter.js.map +0 -1
- package/dist/providers/cursor/hooks.js +0 -201
- package/dist/providers/cursor/hooks.js.map +0 -1
- package/dist/providers/cursor/index.js +0 -21
- package/dist/providers/cursor/index.js.map +0 -1
- package/dist/providers/cursor/install.js +0 -238
- package/dist/providers/cursor/install.js.map +0 -1
- package/dist/providers/cursor/spawn.js +0 -59
- package/dist/providers/cursor/spawn.js.map +0 -1
- package/dist/providers/gemini-cli/adapter.js +0 -145
- package/dist/providers/gemini-cli/adapter.js.map +0 -1
- package/dist/providers/gemini-cli/hooks.js +0 -169
- package/dist/providers/gemini-cli/hooks.js.map +0 -1
- package/dist/providers/gemini-cli/index.js +0 -24
- package/dist/providers/gemini-cli/index.js.map +0 -1
- package/dist/providers/gemini-cli/install.js +0 -183
- package/dist/providers/gemini-cli/install.js.map +0 -1
- package/dist/providers/kimi/adapter.js +0 -133
- package/dist/providers/kimi/adapter.js.map +0 -1
- package/dist/providers/kimi/hooks.js +0 -73
- package/dist/providers/kimi/hooks.js.map +0 -1
- package/dist/providers/kimi/index.js +0 -24
- package/dist/providers/kimi/index.js.map +0 -1
- package/dist/providers/kimi/install.js +0 -189
- package/dist/providers/kimi/install.js.map +0 -1
- package/dist/providers/opencode/adapter.js +0 -151
- package/dist/providers/opencode/adapter.js.map +0 -1
- package/dist/providers/opencode/hooks.js +0 -197
- package/dist/providers/opencode/hooks.js.map +0 -1
- package/dist/providers/opencode/index.js +0 -22
- package/dist/providers/opencode/index.js.map +0 -1
- package/dist/providers/opencode/install.js +0 -180
- package/dist/providers/opencode/install.js.map +0 -1
- package/dist/providers/opencode/spawn.js +0 -219
- package/dist/providers/opencode/spawn.js.map +0 -1
- package/dist/registry.js +0 -55
- package/dist/registry.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -564,6 +564,13 @@ var init_status_registry = __esm({
|
|
|
564
564
|
}
|
|
565
565
|
});
|
|
566
566
|
|
|
567
|
+
// packages/contracts/src/wasm/index.ts
|
|
568
|
+
var init_wasm = __esm({
|
|
569
|
+
"packages/contracts/src/wasm/index.ts"() {
|
|
570
|
+
"use strict";
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
|
|
567
574
|
// packages/contracts/src/index.ts
|
|
568
575
|
var init_src = __esm({
|
|
569
576
|
"packages/contracts/src/index.ts"() {
|
|
@@ -574,6 +581,7 @@ var init_src = __esm({
|
|
|
574
581
|
init_operations();
|
|
575
582
|
init_session2();
|
|
576
583
|
init_status_registry();
|
|
584
|
+
init_wasm();
|
|
577
585
|
}
|
|
578
586
|
});
|
|
579
587
|
|
|
@@ -1100,7 +1108,7 @@ var init_hooks2 = __esm({
|
|
|
1100
1108
|
|
|
1101
1109
|
// packages/adapters/src/providers/cursor/install.js
|
|
1102
1110
|
import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
|
|
1103
|
-
import { join as
|
|
1111
|
+
import { join as join11 } from "node:path";
|
|
1104
1112
|
var INSTRUCTION_REFERENCES3, MCP_SERVER_KEY3, CursorInstallProvider;
|
|
1105
1113
|
var init_install2 = __esm({
|
|
1106
1114
|
"packages/adapters/src/providers/cursor/install.js"() {
|
|
@@ -1124,7 +1132,7 @@ var init_install2 = __esm({
|
|
|
1124
1132
|
if (mcpServerPath) {
|
|
1125
1133
|
mcpRegistered = this.registerMcpServer(projectDir, mcpServerPath);
|
|
1126
1134
|
if (mcpRegistered) {
|
|
1127
|
-
details.mcpConfigPath =
|
|
1135
|
+
details.mcpConfigPath = join11(projectDir, ".cursor", "mcp.json");
|
|
1128
1136
|
}
|
|
1129
1137
|
}
|
|
1130
1138
|
instructionFileUpdated = this.updateInstructionFiles(projectDir);
|
|
@@ -1149,7 +1157,7 @@ var init_install2 = __esm({
|
|
|
1149
1157
|
async uninstall() {
|
|
1150
1158
|
if (!this.installedProjectDir)
|
|
1151
1159
|
return;
|
|
1152
|
-
const mcpPath =
|
|
1160
|
+
const mcpPath = join11(this.installedProjectDir, ".cursor", "mcp.json");
|
|
1153
1161
|
if (existsSync7(mcpPath)) {
|
|
1154
1162
|
try {
|
|
1155
1163
|
const raw = readFileSync5(mcpPath, "utf-8");
|
|
@@ -1170,7 +1178,7 @@ var init_install2 = __esm({
|
|
|
1170
1178
|
* Checks for MCP server registered in .cursor/mcp.json.
|
|
1171
1179
|
*/
|
|
1172
1180
|
async isInstalled() {
|
|
1173
|
-
const mcpPath =
|
|
1181
|
+
const mcpPath = join11(process.cwd(), ".cursor", "mcp.json");
|
|
1174
1182
|
if (existsSync7(mcpPath)) {
|
|
1175
1183
|
try {
|
|
1176
1184
|
const config = JSON.parse(readFileSync5(mcpPath, "utf-8"));
|
|
@@ -1202,8 +1210,8 @@ var init_install2 = __esm({
|
|
|
1202
1210
|
* @returns true if registration was performed or updated
|
|
1203
1211
|
*/
|
|
1204
1212
|
registerMcpServer(projectDir, mcpServerPath) {
|
|
1205
|
-
const cursorDir =
|
|
1206
|
-
const mcpPath =
|
|
1213
|
+
const cursorDir = join11(projectDir, ".cursor");
|
|
1214
|
+
const mcpPath = join11(cursorDir, "mcp.json");
|
|
1207
1215
|
let config = {};
|
|
1208
1216
|
mkdirSync3(cursorDir, { recursive: true });
|
|
1209
1217
|
if (existsSync7(mcpPath)) {
|
|
@@ -1247,7 +1255,7 @@ var init_install2 = __esm({
|
|
|
1247
1255
|
* @returns true if the file was modified
|
|
1248
1256
|
*/
|
|
1249
1257
|
updateLegacyRules(projectDir) {
|
|
1250
|
-
const rulesPath =
|
|
1258
|
+
const rulesPath = join11(projectDir, ".cursorrules");
|
|
1251
1259
|
if (!existsSync7(rulesPath)) {
|
|
1252
1260
|
return false;
|
|
1253
1261
|
}
|
|
@@ -1270,8 +1278,8 @@ var init_install2 = __esm({
|
|
|
1270
1278
|
* @returns true if the file was created or modified
|
|
1271
1279
|
*/
|
|
1272
1280
|
updateModernRules(projectDir) {
|
|
1273
|
-
const rulesDir =
|
|
1274
|
-
const mdcPath =
|
|
1281
|
+
const rulesDir = join11(projectDir, ".cursor", "rules");
|
|
1282
|
+
const mdcPath = join11(rulesDir, "cleo.mdc");
|
|
1275
1283
|
const expectedContent = [
|
|
1276
1284
|
"---",
|
|
1277
1285
|
"description: CLEO task management protocol references",
|
|
@@ -1297,10 +1305,10 @@ var init_install2 = __esm({
|
|
|
1297
1305
|
*/
|
|
1298
1306
|
getUpdatedFileList(projectDir) {
|
|
1299
1307
|
const files = [];
|
|
1300
|
-
if (existsSync7(
|
|
1301
|
-
files.push(
|
|
1308
|
+
if (existsSync7(join11(projectDir, ".cursorrules"))) {
|
|
1309
|
+
files.push(join11(projectDir, ".cursorrules"));
|
|
1302
1310
|
}
|
|
1303
|
-
files.push(
|
|
1311
|
+
files.push(join11(projectDir, ".cursor", "rules", "cleo.mdc"));
|
|
1304
1312
|
return files;
|
|
1305
1313
|
}
|
|
1306
1314
|
};
|
|
@@ -1309,7 +1317,7 @@ var init_install2 = __esm({
|
|
|
1309
1317
|
|
|
1310
1318
|
// packages/adapters/src/providers/cursor/adapter.js
|
|
1311
1319
|
import { existsSync as existsSync8 } from "node:fs";
|
|
1312
|
-
import { join as
|
|
1320
|
+
import { join as join12 } from "node:path";
|
|
1313
1321
|
var CursorAdapter;
|
|
1314
1322
|
var init_adapter2 = __esm({
|
|
1315
1323
|
"packages/adapters/src/providers/cursor/adapter.js"() {
|
|
@@ -1382,14 +1390,14 @@ var init_adapter2 = __esm({
|
|
|
1382
1390
|
}
|
|
1383
1391
|
let configExists = false;
|
|
1384
1392
|
if (this.projectDir) {
|
|
1385
|
-
const cursorConfigDir =
|
|
1393
|
+
const cursorConfigDir = join12(this.projectDir, ".cursor");
|
|
1386
1394
|
configExists = existsSync8(cursorConfigDir);
|
|
1387
1395
|
details.configDirExists = configExists;
|
|
1388
1396
|
}
|
|
1389
1397
|
const editorEnvSet = process.env.CURSOR_EDITOR !== void 0;
|
|
1390
1398
|
details.editorEnvSet = editorEnvSet;
|
|
1391
1399
|
if (this.projectDir) {
|
|
1392
|
-
const legacyRulesExist = existsSync8(
|
|
1400
|
+
const legacyRulesExist = existsSync8(join12(this.projectDir, ".cursorrules"));
|
|
1393
1401
|
details.legacyRulesExist = legacyRulesExist;
|
|
1394
1402
|
}
|
|
1395
1403
|
const healthy = configExists || editorEnvSet;
|
|
@@ -1505,7 +1513,7 @@ var init_hooks3 = __esm({
|
|
|
1505
1513
|
|
|
1506
1514
|
// packages/adapters/src/providers/opencode/install.js
|
|
1507
1515
|
import { existsSync as existsSync13, mkdirSync as mkdirSync6, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "node:fs";
|
|
1508
|
-
import { join as
|
|
1516
|
+
import { join as join18 } from "node:path";
|
|
1509
1517
|
var INSTRUCTION_REFERENCES6, MCP_SERVER_KEY6, OpenCodeInstallProvider;
|
|
1510
1518
|
var init_install3 = __esm({
|
|
1511
1519
|
"packages/adapters/src/providers/opencode/install.js"() {
|
|
@@ -1529,12 +1537,12 @@ var init_install3 = __esm({
|
|
|
1529
1537
|
if (mcpServerPath) {
|
|
1530
1538
|
mcpRegistered = this.registerMcpServer(projectDir, mcpServerPath);
|
|
1531
1539
|
if (mcpRegistered) {
|
|
1532
|
-
details.mcpConfigPath =
|
|
1540
|
+
details.mcpConfigPath = join18(projectDir, ".opencode", "config.json");
|
|
1533
1541
|
}
|
|
1534
1542
|
}
|
|
1535
1543
|
instructionFileUpdated = this.updateInstructionFile(projectDir);
|
|
1536
1544
|
if (instructionFileUpdated) {
|
|
1537
|
-
details.instructionFile =
|
|
1545
|
+
details.instructionFile = join18(projectDir, "AGENTS.md");
|
|
1538
1546
|
}
|
|
1539
1547
|
this.installedProjectDir = projectDir;
|
|
1540
1548
|
return {
|
|
@@ -1554,7 +1562,7 @@ var init_install3 = __esm({
|
|
|
1554
1562
|
async uninstall() {
|
|
1555
1563
|
if (!this.installedProjectDir)
|
|
1556
1564
|
return;
|
|
1557
|
-
const configPath =
|
|
1565
|
+
const configPath = join18(this.installedProjectDir, ".opencode", "config.json");
|
|
1558
1566
|
if (existsSync13(configPath)) {
|
|
1559
1567
|
try {
|
|
1560
1568
|
const raw = readFileSync8(configPath, "utf-8");
|
|
@@ -1576,7 +1584,7 @@ var init_install3 = __esm({
|
|
|
1576
1584
|
* Returns true if the CLEO MCP server entry is found.
|
|
1577
1585
|
*/
|
|
1578
1586
|
async isInstalled() {
|
|
1579
|
-
const configPath =
|
|
1587
|
+
const configPath = join18(process.cwd(), ".opencode", "config.json");
|
|
1580
1588
|
if (existsSync13(configPath)) {
|
|
1581
1589
|
try {
|
|
1582
1590
|
const config = JSON.parse(readFileSync8(configPath, "utf-8"));
|
|
@@ -1608,8 +1616,8 @@ var init_install3 = __esm({
|
|
|
1608
1616
|
* @returns true if registration was performed or updated
|
|
1609
1617
|
*/
|
|
1610
1618
|
registerMcpServer(projectDir, mcpServerPath) {
|
|
1611
|
-
const openCodeDir =
|
|
1612
|
-
const configPath =
|
|
1619
|
+
const openCodeDir = join18(projectDir, ".opencode");
|
|
1620
|
+
const configPath = join18(openCodeDir, "config.json");
|
|
1613
1621
|
let config = {};
|
|
1614
1622
|
mkdirSync6(openCodeDir, { recursive: true });
|
|
1615
1623
|
if (existsSync13(configPath)) {
|
|
@@ -1635,7 +1643,7 @@ var init_install3 = __esm({
|
|
|
1635
1643
|
* @returns true if the file was created or modified
|
|
1636
1644
|
*/
|
|
1637
1645
|
updateInstructionFile(projectDir) {
|
|
1638
|
-
const agentsMdPath =
|
|
1646
|
+
const agentsMdPath = join18(projectDir, "AGENTS.md");
|
|
1639
1647
|
let content = "";
|
|
1640
1648
|
let existed = false;
|
|
1641
1649
|
if (existsSync13(agentsMdPath)) {
|
|
@@ -1662,8 +1670,8 @@ var init_install3 = __esm({
|
|
|
1662
1670
|
|
|
1663
1671
|
// packages/adapters/src/providers/opencode/spawn.js
|
|
1664
1672
|
import { exec as exec6, spawn as nodeSpawn2 } from "node:child_process";
|
|
1665
|
-
import { mkdir as mkdir2, readFile as
|
|
1666
|
-
import { join as
|
|
1673
|
+
import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
|
|
1674
|
+
import { join as join19 } from "node:path";
|
|
1667
1675
|
import { promisify as promisify6 } from "node:util";
|
|
1668
1676
|
function buildOpenCodeAgentMarkdown(description, instructions) {
|
|
1669
1677
|
const normalizedDesc = description.replace(/\s+/g, " ").trim();
|
|
@@ -1679,8 +1687,8 @@ function buildOpenCodeAgentMarkdown(description, instructions) {
|
|
|
1679
1687
|
].join("\n");
|
|
1680
1688
|
}
|
|
1681
1689
|
async function ensureSubagentDefinition(workingDirectory) {
|
|
1682
|
-
const agentDir =
|
|
1683
|
-
const agentPath =
|
|
1690
|
+
const agentDir = join19(workingDirectory, ".opencode", "agent");
|
|
1691
|
+
const agentPath = join19(agentDir, `${OPENCODE_SUBAGENT_NAME}.md`);
|
|
1684
1692
|
const description = "CLEO task executor with protocol compliance.";
|
|
1685
1693
|
const instructions = [
|
|
1686
1694
|
"# CLEO Subagent",
|
|
@@ -1694,7 +1702,7 @@ async function ensureSubagentDefinition(workingDirectory) {
|
|
|
1694
1702
|
await mkdir2(agentDir, { recursive: true });
|
|
1695
1703
|
let existing = null;
|
|
1696
1704
|
try {
|
|
1697
|
-
existing = await
|
|
1705
|
+
existing = await readFile3(agentPath, "utf-8");
|
|
1698
1706
|
} catch {
|
|
1699
1707
|
existing = null;
|
|
1700
1708
|
}
|
|
@@ -1841,7 +1849,7 @@ var init_spawn2 = __esm({
|
|
|
1841
1849
|
// packages/adapters/src/providers/opencode/adapter.js
|
|
1842
1850
|
import { exec as exec7 } from "node:child_process";
|
|
1843
1851
|
import { existsSync as existsSync14 } from "node:fs";
|
|
1844
|
-
import { join as
|
|
1852
|
+
import { join as join20 } from "node:path";
|
|
1845
1853
|
import { promisify as promisify7 } from "node:util";
|
|
1846
1854
|
var execAsync7, OpenCodeAdapter;
|
|
1847
1855
|
var init_adapter3 = __esm({
|
|
@@ -1938,7 +1946,7 @@ var init_adapter3 = __esm({
|
|
|
1938
1946
|
details.cliAvailable = false;
|
|
1939
1947
|
}
|
|
1940
1948
|
if (this.projectDir) {
|
|
1941
|
-
const openCodeConfigDir =
|
|
1949
|
+
const openCodeConfigDir = join20(this.projectDir, ".opencode");
|
|
1942
1950
|
const configExists = existsSync14(openCodeConfigDir);
|
|
1943
1951
|
details.configDirExists = configExists;
|
|
1944
1952
|
}
|
|
@@ -2000,13 +2008,61 @@ init_claude_code();
|
|
|
2000
2008
|
// packages/adapters/src/providers/codex/adapter.ts
|
|
2001
2009
|
import { exec as exec3 } from "node:child_process";
|
|
2002
2010
|
import { existsSync as existsSync6 } from "node:fs";
|
|
2003
|
-
import { homedir as
|
|
2004
|
-
import { join as
|
|
2011
|
+
import { homedir as homedir8 } from "node:os";
|
|
2012
|
+
import { join as join10 } from "node:path";
|
|
2005
2013
|
import { promisify as promisify3 } from "node:util";
|
|
2006
2014
|
|
|
2007
2015
|
// packages/adapters/src/providers/codex/hooks.ts
|
|
2016
|
+
import { homedir as homedir6 } from "node:os";
|
|
2017
|
+
import { join as join8 } from "node:path";
|
|
2018
|
+
|
|
2019
|
+
// packages/adapters/src/providers/shared/transcript-reader.ts
|
|
2008
2020
|
import { readdir, readFile as readFile2 } from "node:fs/promises";
|
|
2009
2021
|
import { join as join7 } from "node:path";
|
|
2022
|
+
function parseTranscriptLines(raw) {
|
|
2023
|
+
const turns = [];
|
|
2024
|
+
const lines = raw.split("\n").filter((l) => l.trim());
|
|
2025
|
+
for (const line of lines) {
|
|
2026
|
+
try {
|
|
2027
|
+
const entry = JSON.parse(line);
|
|
2028
|
+
const role = entry.role;
|
|
2029
|
+
const content = entry.content;
|
|
2030
|
+
if (typeof role === "string" && typeof content === "string") {
|
|
2031
|
+
turns.push({ role, content });
|
|
2032
|
+
}
|
|
2033
|
+
} catch {
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
return turns;
|
|
2037
|
+
}
|
|
2038
|
+
async function readLatestTranscript(providerDir) {
|
|
2039
|
+
let allFiles = [];
|
|
2040
|
+
try {
|
|
2041
|
+
const entries = await readdir(providerDir, { withFileTypes: true });
|
|
2042
|
+
for (const entry of entries) {
|
|
2043
|
+
if (!entry.isFile()) continue;
|
|
2044
|
+
const name = entry.name;
|
|
2045
|
+
if (name.endsWith(".json") || name.endsWith(".jsonl")) {
|
|
2046
|
+
allFiles.push(join7(providerDir, name));
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
} catch {
|
|
2050
|
+
return null;
|
|
2051
|
+
}
|
|
2052
|
+
if (allFiles.length === 0) return null;
|
|
2053
|
+
allFiles = allFiles.sort((a, b) => b.localeCompare(a));
|
|
2054
|
+
const mostRecent = allFiles[0];
|
|
2055
|
+
if (!mostRecent) return null;
|
|
2056
|
+
try {
|
|
2057
|
+
const raw = await readFile2(mostRecent, "utf-8");
|
|
2058
|
+
const turns = parseTranscriptLines(raw);
|
|
2059
|
+
return turns.length > 0 ? turns.map((t) => `${t.role}: ${t.content}`).join("\n") : null;
|
|
2060
|
+
} catch {
|
|
2061
|
+
return null;
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
// packages/adapters/src/providers/codex/hooks.ts
|
|
2010
2066
|
var CODEX_EVENT_MAP = {
|
|
2011
2067
|
SessionStart: "SessionStart",
|
|
2012
2068
|
PromptSubmit: "UserPromptSubmit",
|
|
@@ -2066,8 +2122,8 @@ var CodexHookProvider = class {
|
|
|
2066
2122
|
/**
|
|
2067
2123
|
* Extract a plain-text transcript from Codex CLI session data.
|
|
2068
2124
|
*
|
|
2069
|
-
* Reads the most recent session file under
|
|
2070
|
-
*
|
|
2125
|
+
* Reads the most recent JSON/JSONL session file under `~/.codex/`
|
|
2126
|
+
* and returns its turns as a flat string for brain observation extraction.
|
|
2071
2127
|
*
|
|
2072
2128
|
* Returns null when no session data is found or on any read error.
|
|
2073
2129
|
*
|
|
@@ -2076,53 +2132,14 @@ var CodexHookProvider = class {
|
|
|
2076
2132
|
* @task T162 @epic T134
|
|
2077
2133
|
*/
|
|
2078
2134
|
async getTranscript(_sessionId, _projectDir) {
|
|
2079
|
-
|
|
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
|
-
}
|
|
2135
|
+
return readLatestTranscript(join8(homedir6(), ".codex"));
|
|
2119
2136
|
}
|
|
2120
2137
|
};
|
|
2121
2138
|
|
|
2122
2139
|
// packages/adapters/src/providers/codex/install.ts
|
|
2123
2140
|
import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
2124
|
-
import { homedir as
|
|
2125
|
-
import { join as
|
|
2141
|
+
import { homedir as homedir7 } from "node:os";
|
|
2142
|
+
import { join as join9 } from "node:path";
|
|
2126
2143
|
var INSTRUCTION_REFERENCES2 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
|
|
2127
2144
|
var MCP_SERVER_KEY2 = "cleo";
|
|
2128
2145
|
var CodexInstallProvider = class {
|
|
@@ -2142,12 +2159,12 @@ var CodexInstallProvider = class {
|
|
|
2142
2159
|
if (mcpServerPath) {
|
|
2143
2160
|
mcpRegistered = this.registerMcpServer(mcpServerPath);
|
|
2144
2161
|
if (mcpRegistered) {
|
|
2145
|
-
details.mcpConfigPath =
|
|
2162
|
+
details.mcpConfigPath = join9(homedir7(), ".codex", "config.json");
|
|
2146
2163
|
}
|
|
2147
2164
|
}
|
|
2148
2165
|
instructionFileUpdated = this.updateInstructionFile(projectDir);
|
|
2149
2166
|
if (instructionFileUpdated) {
|
|
2150
|
-
details.instructionFile =
|
|
2167
|
+
details.instructionFile = join9(projectDir, "AGENTS.md");
|
|
2151
2168
|
}
|
|
2152
2169
|
return {
|
|
2153
2170
|
success: true,
|
|
@@ -2165,7 +2182,7 @@ var CodexInstallProvider = class {
|
|
|
2165
2182
|
* @task T162
|
|
2166
2183
|
*/
|
|
2167
2184
|
async uninstall() {
|
|
2168
|
-
const configPath =
|
|
2185
|
+
const configPath = join9(homedir7(), ".codex", "config.json");
|
|
2169
2186
|
if (existsSync5(configPath)) {
|
|
2170
2187
|
try {
|
|
2171
2188
|
const raw = readFileSync4(configPath, "utf-8");
|
|
@@ -2187,7 +2204,7 @@ var CodexInstallProvider = class {
|
|
|
2187
2204
|
* @task T162
|
|
2188
2205
|
*/
|
|
2189
2206
|
async isInstalled() {
|
|
2190
|
-
const configPath =
|
|
2207
|
+
const configPath = join9(homedir7(), ".codex", "config.json");
|
|
2191
2208
|
if (existsSync5(configPath)) {
|
|
2192
2209
|
try {
|
|
2193
2210
|
const config = JSON.parse(readFileSync4(configPath, "utf-8"));
|
|
@@ -2221,8 +2238,8 @@ var CodexInstallProvider = class {
|
|
|
2221
2238
|
* @returns true if registration was performed or updated
|
|
2222
2239
|
*/
|
|
2223
2240
|
registerMcpServer(mcpServerPath) {
|
|
2224
|
-
const codexDir =
|
|
2225
|
-
const configPath =
|
|
2241
|
+
const codexDir = join9(homedir7(), ".codex");
|
|
2242
|
+
const configPath = join9(codexDir, "config.json");
|
|
2226
2243
|
let config = {};
|
|
2227
2244
|
mkdirSync2(codexDir, { recursive: true });
|
|
2228
2245
|
if (existsSync5(configPath)) {
|
|
@@ -2249,7 +2266,7 @@ var CodexInstallProvider = class {
|
|
|
2249
2266
|
* @returns true if the file was created or modified
|
|
2250
2267
|
*/
|
|
2251
2268
|
updateInstructionFile(projectDir) {
|
|
2252
|
-
const agentsMdPath =
|
|
2269
|
+
const agentsMdPath = join9(projectDir, "AGENTS.md");
|
|
2253
2270
|
let content = "";
|
|
2254
2271
|
let existed = false;
|
|
2255
2272
|
if (existsSync5(agentsMdPath)) {
|
|
@@ -2350,7 +2367,7 @@ var CodexAdapter = class {
|
|
|
2350
2367
|
} catch {
|
|
2351
2368
|
details.cliAvailable = false;
|
|
2352
2369
|
}
|
|
2353
|
-
const codexConfigDir =
|
|
2370
|
+
const codexConfigDir = join10(homedir8(), ".codex");
|
|
2354
2371
|
const configExists = existsSync6(codexConfigDir);
|
|
2355
2372
|
details.configDirExists = configExists;
|
|
2356
2373
|
const healthy = cliAvailable;
|
|
@@ -2388,13 +2405,13 @@ init_cursor();
|
|
|
2388
2405
|
// packages/adapters/src/providers/gemini-cli/adapter.ts
|
|
2389
2406
|
import { exec as exec4 } from "node:child_process";
|
|
2390
2407
|
import { existsSync as existsSync10 } from "node:fs";
|
|
2391
|
-
import { homedir as
|
|
2392
|
-
import { join as
|
|
2408
|
+
import { homedir as homedir11 } from "node:os";
|
|
2409
|
+
import { join as join15 } from "node:path";
|
|
2393
2410
|
import { promisify as promisify4 } from "node:util";
|
|
2394
2411
|
|
|
2395
2412
|
// packages/adapters/src/providers/gemini-cli/hooks.ts
|
|
2396
|
-
import {
|
|
2397
|
-
import { join as
|
|
2413
|
+
import { homedir as homedir9 } from "node:os";
|
|
2414
|
+
import { join as join13 } from "node:path";
|
|
2398
2415
|
var GEMINI_CLI_EVENT_MAP = {
|
|
2399
2416
|
SessionStart: "SessionStart",
|
|
2400
2417
|
SessionEnd: "SessionEnd",
|
|
@@ -2461,8 +2478,8 @@ var GeminiCliHookProvider = class {
|
|
|
2461
2478
|
/**
|
|
2462
2479
|
* Extract a plain-text transcript from Gemini CLI session data.
|
|
2463
2480
|
*
|
|
2464
|
-
* Reads the most recent session file under
|
|
2465
|
-
*
|
|
2481
|
+
* Reads the most recent JSON/JSONL session file under `~/.gemini/`
|
|
2482
|
+
* and returns its turns as a flat string for brain observation extraction.
|
|
2466
2483
|
*
|
|
2467
2484
|
* Returns null when no session data is found or on any read error.
|
|
2468
2485
|
*
|
|
@@ -2471,53 +2488,14 @@ var GeminiCliHookProvider = class {
|
|
|
2471
2488
|
* @task T161 @epic T134
|
|
2472
2489
|
*/
|
|
2473
2490
|
async getTranscript(_sessionId, _projectDir) {
|
|
2474
|
-
|
|
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
|
-
}
|
|
2491
|
+
return readLatestTranscript(join13(homedir9(), ".gemini"));
|
|
2514
2492
|
}
|
|
2515
2493
|
};
|
|
2516
2494
|
|
|
2517
2495
|
// packages/adapters/src/providers/gemini-cli/install.ts
|
|
2518
2496
|
import { existsSync as existsSync9, mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
2519
|
-
import { homedir as
|
|
2520
|
-
import { join as
|
|
2497
|
+
import { homedir as homedir10 } from "node:os";
|
|
2498
|
+
import { join as join14 } from "node:path";
|
|
2521
2499
|
var INSTRUCTION_REFERENCES4 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
|
|
2522
2500
|
var MCP_SERVER_KEY4 = "cleo";
|
|
2523
2501
|
var GeminiCliInstallProvider = class {
|
|
@@ -2537,12 +2515,12 @@ var GeminiCliInstallProvider = class {
|
|
|
2537
2515
|
if (mcpServerPath) {
|
|
2538
2516
|
mcpRegistered = this.registerMcpServer(mcpServerPath);
|
|
2539
2517
|
if (mcpRegistered) {
|
|
2540
|
-
details.mcpConfigPath =
|
|
2518
|
+
details.mcpConfigPath = join14(homedir10(), ".gemini", "settings.json");
|
|
2541
2519
|
}
|
|
2542
2520
|
}
|
|
2543
2521
|
instructionFileUpdated = this.updateInstructionFile(projectDir);
|
|
2544
2522
|
if (instructionFileUpdated) {
|
|
2545
|
-
details.instructionFile =
|
|
2523
|
+
details.instructionFile = join14(projectDir, "AGENTS.md");
|
|
2546
2524
|
}
|
|
2547
2525
|
return {
|
|
2548
2526
|
success: true,
|
|
@@ -2560,7 +2538,7 @@ var GeminiCliInstallProvider = class {
|
|
|
2560
2538
|
* @task T161
|
|
2561
2539
|
*/
|
|
2562
2540
|
async uninstall() {
|
|
2563
|
-
const settingsPath =
|
|
2541
|
+
const settingsPath = join14(homedir10(), ".gemini", "settings.json");
|
|
2564
2542
|
if (existsSync9(settingsPath)) {
|
|
2565
2543
|
try {
|
|
2566
2544
|
const raw = readFileSync6(settingsPath, "utf-8");
|
|
@@ -2582,7 +2560,7 @@ var GeminiCliInstallProvider = class {
|
|
|
2582
2560
|
* @task T161
|
|
2583
2561
|
*/
|
|
2584
2562
|
async isInstalled() {
|
|
2585
|
-
const settingsPath =
|
|
2563
|
+
const settingsPath = join14(homedir10(), ".gemini", "settings.json");
|
|
2586
2564
|
if (existsSync9(settingsPath)) {
|
|
2587
2565
|
try {
|
|
2588
2566
|
const config = JSON.parse(readFileSync6(settingsPath, "utf-8"));
|
|
@@ -2616,8 +2594,8 @@ var GeminiCliInstallProvider = class {
|
|
|
2616
2594
|
* @returns true if registration was performed or updated
|
|
2617
2595
|
*/
|
|
2618
2596
|
registerMcpServer(mcpServerPath) {
|
|
2619
|
-
const geminiDir =
|
|
2620
|
-
const settingsPath =
|
|
2597
|
+
const geminiDir = join14(homedir10(), ".gemini");
|
|
2598
|
+
const settingsPath = join14(geminiDir, "settings.json");
|
|
2621
2599
|
let config = {};
|
|
2622
2600
|
mkdirSync4(geminiDir, { recursive: true });
|
|
2623
2601
|
if (existsSync9(settingsPath)) {
|
|
@@ -2644,7 +2622,7 @@ var GeminiCliInstallProvider = class {
|
|
|
2644
2622
|
* @returns true if the file was created or modified
|
|
2645
2623
|
*/
|
|
2646
2624
|
updateInstructionFile(projectDir) {
|
|
2647
|
-
const agentsMdPath =
|
|
2625
|
+
const agentsMdPath = join14(projectDir, "AGENTS.md");
|
|
2648
2626
|
let content = "";
|
|
2649
2627
|
let existed = false;
|
|
2650
2628
|
if (existsSync9(agentsMdPath)) {
|
|
@@ -2756,7 +2734,7 @@ var GeminiCliAdapter = class {
|
|
|
2756
2734
|
} catch {
|
|
2757
2735
|
details.cliAvailable = false;
|
|
2758
2736
|
}
|
|
2759
|
-
const geminiConfigDir =
|
|
2737
|
+
const geminiConfigDir = join15(homedir11(), ".gemini");
|
|
2760
2738
|
const configExists = existsSync10(geminiConfigDir);
|
|
2761
2739
|
details.configDirExists = configExists;
|
|
2762
2740
|
const healthy = cliAvailable;
|
|
@@ -2791,8 +2769,8 @@ function createAdapter4() {
|
|
|
2791
2769
|
// packages/adapters/src/providers/kimi/adapter.ts
|
|
2792
2770
|
import { exec as exec5 } from "node:child_process";
|
|
2793
2771
|
import { existsSync as existsSync12 } from "node:fs";
|
|
2794
|
-
import { homedir as
|
|
2795
|
-
import { join as
|
|
2772
|
+
import { homedir as homedir13 } from "node:os";
|
|
2773
|
+
import { join as join17 } from "node:path";
|
|
2796
2774
|
import { promisify as promisify5 } from "node:util";
|
|
2797
2775
|
|
|
2798
2776
|
// packages/adapters/src/providers/kimi/hooks.ts
|
|
@@ -2851,8 +2829,8 @@ var KimiHookProvider = class {
|
|
|
2851
2829
|
|
|
2852
2830
|
// packages/adapters/src/providers/kimi/install.ts
|
|
2853
2831
|
import { existsSync as existsSync11, mkdirSync as mkdirSync5, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "node:fs";
|
|
2854
|
-
import { homedir as
|
|
2855
|
-
import { join as
|
|
2832
|
+
import { homedir as homedir12 } from "node:os";
|
|
2833
|
+
import { join as join16 } from "node:path";
|
|
2856
2834
|
var INSTRUCTION_REFERENCES5 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
|
|
2857
2835
|
var MCP_SERVER_KEY5 = "cleo";
|
|
2858
2836
|
var KimiInstallProvider = class {
|
|
@@ -2872,12 +2850,12 @@ var KimiInstallProvider = class {
|
|
|
2872
2850
|
if (mcpServerPath) {
|
|
2873
2851
|
mcpRegistered = this.registerMcpServer(mcpServerPath);
|
|
2874
2852
|
if (mcpRegistered) {
|
|
2875
|
-
details.mcpConfigPath =
|
|
2853
|
+
details.mcpConfigPath = join16(homedir12(), ".kimi", "mcp.json");
|
|
2876
2854
|
}
|
|
2877
2855
|
}
|
|
2878
2856
|
instructionFileUpdated = this.updateInstructionFile(projectDir);
|
|
2879
2857
|
if (instructionFileUpdated) {
|
|
2880
|
-
details.instructionFile =
|
|
2858
|
+
details.instructionFile = join16(projectDir, "AGENTS.md");
|
|
2881
2859
|
}
|
|
2882
2860
|
return {
|
|
2883
2861
|
success: true,
|
|
@@ -2895,7 +2873,7 @@ var KimiInstallProvider = class {
|
|
|
2895
2873
|
* @task T163
|
|
2896
2874
|
*/
|
|
2897
2875
|
async uninstall() {
|
|
2898
|
-
const mcpPath =
|
|
2876
|
+
const mcpPath = join16(homedir12(), ".kimi", "mcp.json");
|
|
2899
2877
|
if (existsSync11(mcpPath)) {
|
|
2900
2878
|
try {
|
|
2901
2879
|
const raw = readFileSync7(mcpPath, "utf-8");
|
|
@@ -2917,7 +2895,7 @@ var KimiInstallProvider = class {
|
|
|
2917
2895
|
* @task T163
|
|
2918
2896
|
*/
|
|
2919
2897
|
async isInstalled() {
|
|
2920
|
-
const mcpPath =
|
|
2898
|
+
const mcpPath = join16(homedir12(), ".kimi", "mcp.json");
|
|
2921
2899
|
if (existsSync11(mcpPath)) {
|
|
2922
2900
|
try {
|
|
2923
2901
|
const config = JSON.parse(readFileSync7(mcpPath, "utf-8"));
|
|
@@ -2951,8 +2929,8 @@ var KimiInstallProvider = class {
|
|
|
2951
2929
|
* @returns true if registration was performed or updated
|
|
2952
2930
|
*/
|
|
2953
2931
|
registerMcpServer(mcpServerPath) {
|
|
2954
|
-
const kimiDir =
|
|
2955
|
-
const mcpPath =
|
|
2932
|
+
const kimiDir = join16(homedir12(), ".kimi");
|
|
2933
|
+
const mcpPath = join16(kimiDir, "mcp.json");
|
|
2956
2934
|
let config = {};
|
|
2957
2935
|
mkdirSync5(kimiDir, { recursive: true });
|
|
2958
2936
|
if (existsSync11(mcpPath)) {
|
|
@@ -2979,7 +2957,7 @@ var KimiInstallProvider = class {
|
|
|
2979
2957
|
* @returns true if the file was created or modified
|
|
2980
2958
|
*/
|
|
2981
2959
|
updateInstructionFile(projectDir) {
|
|
2982
|
-
const agentsMdPath =
|
|
2960
|
+
const agentsMdPath = join16(projectDir, "AGENTS.md");
|
|
2983
2961
|
let content = "";
|
|
2984
2962
|
let existed = false;
|
|
2985
2963
|
if (existsSync11(agentsMdPath)) {
|
|
@@ -3078,7 +3056,7 @@ var KimiAdapter = class {
|
|
|
3078
3056
|
} catch {
|
|
3079
3057
|
details.cliAvailable = false;
|
|
3080
3058
|
}
|
|
3081
|
-
const kimiConfigDir =
|
|
3059
|
+
const kimiConfigDir = join17(homedir13(), ".kimi");
|
|
3082
3060
|
const configExists = existsSync12(kimiConfigDir);
|
|
3083
3061
|
details.configDirExists = configExists;
|
|
3084
3062
|
const healthy = cliAvailable;
|
|
@@ -3115,7 +3093,7 @@ init_opencode();
|
|
|
3115
3093
|
|
|
3116
3094
|
// packages/adapters/src/registry.js
|
|
3117
3095
|
import { readFileSync as readFileSync9 } from "node:fs";
|
|
3118
|
-
import { dirname as dirname2, join as
|
|
3096
|
+
import { dirname as dirname2, join as join21, resolve } from "node:path";
|
|
3119
3097
|
import { fileURLToPath } from "node:url";
|
|
3120
3098
|
var PROVIDER_IDS = ["claude-code", "opencode", "cursor"];
|
|
3121
3099
|
function getProviderManifests() {
|
|
@@ -3123,7 +3101,7 @@ function getProviderManifests() {
|
|
|
3123
3101
|
const baseDir = resolve(dirname2(fileURLToPath(import.meta.url)), "providers");
|
|
3124
3102
|
for (const providerId of PROVIDER_IDS) {
|
|
3125
3103
|
try {
|
|
3126
|
-
const manifestPath =
|
|
3104
|
+
const manifestPath = join21(baseDir, providerId, "manifest.json");
|
|
3127
3105
|
const raw = readFileSync9(manifestPath, "utf-8");
|
|
3128
3106
|
manifests.push(JSON.parse(raw));
|
|
3129
3107
|
} catch {
|