@cleocode/adapters 2026.4.62 → 2026.4.64
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 +282 -221
- package/dist/index.js.map +3 -3
- package/dist/providers/claude-code/hooks.d.ts +8 -4
- package/dist/providers/claude-code/hooks.d.ts.map +1 -1
- package/dist/providers/claude-sdk/spawn.d.ts +10 -4
- package/dist/providers/claude-sdk/spawn.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/providers/claude-code/__tests__/hooks-get-transcript.test.ts +183 -0
- package/src/providers/claude-code/hooks.ts +69 -32
- package/src/providers/claude-sdk/__tests__/spawn.test.ts +52 -3
- package/src/providers/claude-sdk/spawn.ts +69 -5
package/dist/index.js
CHANGED
|
@@ -19618,6 +19618,36 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
19618
19618
|
});
|
|
19619
19619
|
|
|
19620
19620
|
// packages/adapters/src/providers/claude-sdk/spawn.ts
|
|
19621
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "node:fs";
|
|
19622
|
+
import { homedir as homedir2 } from "node:os";
|
|
19623
|
+
import { join as join3 } from "node:path";
|
|
19624
|
+
function resolveAnthropicApiKey() {
|
|
19625
|
+
const envKey = process.env.ANTHROPIC_API_KEY;
|
|
19626
|
+
if (envKey?.trim()) return envKey;
|
|
19627
|
+
try {
|
|
19628
|
+
const xdg = process.env.XDG_DATA_HOME || join3(homedir2(), ".local", "share");
|
|
19629
|
+
const keyFile = join3(xdg, "cleo", "anthropic-key");
|
|
19630
|
+
if (existsSync4(keyFile)) {
|
|
19631
|
+
const stored = readFileSync3(keyFile, "utf-8").trim();
|
|
19632
|
+
if (stored) return stored;
|
|
19633
|
+
}
|
|
19634
|
+
} catch {
|
|
19635
|
+
}
|
|
19636
|
+
try {
|
|
19637
|
+
const credPath = join3(homedir2(), ".claude", ".credentials.json");
|
|
19638
|
+
if (!existsSync4(credPath)) return null;
|
|
19639
|
+
const raw = readFileSync3(credPath, "utf-8");
|
|
19640
|
+
const creds = JSON.parse(raw);
|
|
19641
|
+
const token = creds.claudeAiOauth?.accessToken;
|
|
19642
|
+
if (token?.trim()) {
|
|
19643
|
+
const expiresAt = creds.claudeAiOauth?.expiresAt;
|
|
19644
|
+
if (expiresAt && Date.now() > expiresAt) return null;
|
|
19645
|
+
return token;
|
|
19646
|
+
}
|
|
19647
|
+
} catch {
|
|
19648
|
+
}
|
|
19649
|
+
return null;
|
|
19650
|
+
}
|
|
19621
19651
|
var DEFAULT_MODEL, ClaudeSDKSpawnProvider;
|
|
19622
19652
|
var init_spawn = __esm({
|
|
19623
19653
|
"packages/adapters/src/providers/claude-sdk/spawn.ts"() {
|
|
@@ -19633,13 +19663,18 @@ var init_spawn = __esm({
|
|
|
19633
19663
|
/**
|
|
19634
19664
|
* Check whether the SDK can be used in the current environment.
|
|
19635
19665
|
*
|
|
19636
|
-
*
|
|
19637
|
-
*
|
|
19666
|
+
* Uses 3-tier key resolution so the provider works with:
|
|
19667
|
+
* - `ANTHROPIC_API_KEY` environment variable (explicit)
|
|
19668
|
+
* - `~/.local/share/cleo/anthropic-key` (user-stored via cleo config)
|
|
19669
|
+
* - Claude Code OAuth token (zero-config for Claude Code users)
|
|
19670
|
+
*
|
|
19671
|
+
* No binary check is needed because the SDK manages the Claude Code
|
|
19672
|
+
* subprocess internally.
|
|
19638
19673
|
*
|
|
19639
|
-
* @returns `true` when
|
|
19674
|
+
* @returns `true` when any Anthropic credential is available
|
|
19640
19675
|
*/
|
|
19641
19676
|
async canSpawn() {
|
|
19642
|
-
return !!
|
|
19677
|
+
return !!resolveAnthropicApiKey();
|
|
19643
19678
|
}
|
|
19644
19679
|
/**
|
|
19645
19680
|
* Spawn a subagent using the Claude Agent SDK.
|
|
@@ -19794,8 +19829,8 @@ var init_spawn = __esm({
|
|
|
19794
19829
|
});
|
|
19795
19830
|
|
|
19796
19831
|
// packages/adapters/src/providers/claude-code/paths.ts
|
|
19797
|
-
import { homedir as
|
|
19798
|
-
import { join as
|
|
19832
|
+
import { homedir as homedir3 } from "node:os";
|
|
19833
|
+
import { join as join4 } from "node:path";
|
|
19799
19834
|
var ClaudeCodePathProvider;
|
|
19800
19835
|
var init_paths = __esm({
|
|
19801
19836
|
"packages/adapters/src/providers/claude-code/paths.ts"() {
|
|
@@ -19803,29 +19838,29 @@ var init_paths = __esm({
|
|
|
19803
19838
|
ClaudeCodePathProvider = class {
|
|
19804
19839
|
/** Get the provider's root configuration directory. */
|
|
19805
19840
|
getProviderDir() {
|
|
19806
|
-
return process.env["CLAUDE_HOME"] ??
|
|
19841
|
+
return process.env["CLAUDE_HOME"] ?? join4(homedir3(), ".claude");
|
|
19807
19842
|
}
|
|
19808
19843
|
/** Get the path to the provider's settings file, or null if unavailable. */
|
|
19809
19844
|
getSettingsPath() {
|
|
19810
|
-
return process.env["CLAUDE_SETTINGS"] ??
|
|
19845
|
+
return process.env["CLAUDE_SETTINGS"] ?? join4(this.getProviderDir(), "settings.json");
|
|
19811
19846
|
}
|
|
19812
19847
|
/** Get the directory where agents are installed, or null if unsupported. */
|
|
19813
19848
|
getAgentInstallDir() {
|
|
19814
|
-
return
|
|
19849
|
+
return join4(this.getProviderDir(), "agents");
|
|
19815
19850
|
}
|
|
19816
19851
|
/** Get the path to the provider's memory database, or null if unsupported. */
|
|
19817
19852
|
getMemoryDbPath() {
|
|
19818
|
-
return process.env["CLAUDE_MEM_DB"] ??
|
|
19853
|
+
return process.env["CLAUDE_MEM_DB"] ?? join4(homedir3(), ".claude-mem", "claude-mem.db");
|
|
19819
19854
|
}
|
|
19820
19855
|
};
|
|
19821
19856
|
}
|
|
19822
19857
|
});
|
|
19823
19858
|
|
|
19824
19859
|
// packages/adapters/src/providers/claude-code/context-monitor.ts
|
|
19825
|
-
import { existsSync as
|
|
19860
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4, writeFileSync } from "node:fs";
|
|
19826
19861
|
import { mkdir } from "node:fs/promises";
|
|
19827
|
-
import { homedir as
|
|
19828
|
-
import { dirname, join as
|
|
19862
|
+
import { homedir as homedir4 } from "node:os";
|
|
19863
|
+
import { dirname, join as join5 } from "node:path";
|
|
19829
19864
|
function getContextStatusFromPercentage(percentage) {
|
|
19830
19865
|
if (percentage >= THRESHOLDS.EMERGENCY) return "emergency";
|
|
19831
19866
|
if (percentage >= THRESHOLDS.CRITICAL) return "critical";
|
|
@@ -19859,10 +19894,10 @@ var init_context_monitor = __esm({
|
|
|
19859
19894
|
const totalTokens = inputTokens + outputTokens + cacheCreate;
|
|
19860
19895
|
const percentage = Math.floor(totalTokens * 100 / contextSize);
|
|
19861
19896
|
const status = getContextStatusFromPercentage(percentage);
|
|
19862
|
-
const cleoDir = cwd ?
|
|
19863
|
-
if (
|
|
19864
|
-
const stateDir =
|
|
19865
|
-
const statePath =
|
|
19897
|
+
const cleoDir = cwd ? join5(cwd, ".cleo") : ".cleo";
|
|
19898
|
+
if (existsSync5(cleoDir)) {
|
|
19899
|
+
const stateDir = join5(cleoDir, "context-states");
|
|
19900
|
+
const statePath = join5(stateDir, ".context-state.json");
|
|
19866
19901
|
const state = {
|
|
19867
19902
|
$schema: "https://cleo-dev.com/schemas/v1/context-state.schema.json",
|
|
19868
19903
|
version: "1.0.0",
|
|
@@ -19899,9 +19934,9 @@ var init_context_monitor = __esm({
|
|
|
19899
19934
|
/** Check the current statusline integration status in Claude Code settings. */
|
|
19900
19935
|
checkStatuslineIntegration() {
|
|
19901
19936
|
const settingsPath = this.pathProvider.getSettingsPath();
|
|
19902
|
-
if (!settingsPath || !
|
|
19937
|
+
if (!settingsPath || !existsSync5(settingsPath)) return "no_settings";
|
|
19903
19938
|
try {
|
|
19904
|
-
const settings = JSON.parse(
|
|
19939
|
+
const settings = JSON.parse(readFileSync4(settingsPath, "utf-8"));
|
|
19905
19940
|
const statusLine = settings.statusLine;
|
|
19906
19941
|
if (!statusLine?.type) return "not_configured";
|
|
19907
19942
|
if (statusLine.type !== "command") return "custom_no_cleo";
|
|
@@ -19909,10 +19944,10 @@ var init_context_monitor = __esm({
|
|
|
19909
19944
|
if (cmd.includes("context-monitor.sh") || cmd.includes("cleo-statusline") || cmd.includes(".context-state.json") || cmd.includes("context-states")) {
|
|
19910
19945
|
return "configured";
|
|
19911
19946
|
}
|
|
19912
|
-
const scriptPath = cmd.startsWith("~") ? cmd.replace("~",
|
|
19913
|
-
if (
|
|
19947
|
+
const scriptPath = cmd.startsWith("~") ? cmd.replace("~", homedir4()) : cmd;
|
|
19948
|
+
if (existsSync5(scriptPath)) {
|
|
19914
19949
|
try {
|
|
19915
|
-
const content =
|
|
19950
|
+
const content = readFileSync4(scriptPath, "utf-8");
|
|
19916
19951
|
if (content.includes("context-state.json")) return "configured";
|
|
19917
19952
|
} catch {
|
|
19918
19953
|
}
|
|
@@ -19927,7 +19962,7 @@ var init_context_monitor = __esm({
|
|
|
19927
19962
|
return {
|
|
19928
19963
|
statusLine: {
|
|
19929
19964
|
type: "command",
|
|
19930
|
-
command:
|
|
19965
|
+
command: join5(homedir4(), ".cleo", "lib", "session", "context-monitor.sh")
|
|
19931
19966
|
}
|
|
19932
19967
|
};
|
|
19933
19968
|
}
|
|
@@ -19948,10 +19983,10 @@ var init_context_monitor = __esm({
|
|
|
19948
19983
|
});
|
|
19949
19984
|
|
|
19950
19985
|
// packages/adapters/src/providers/claude-code/hooks.ts
|
|
19951
|
-
import { existsSync as
|
|
19986
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
19952
19987
|
import { readdir, readFile } from "node:fs/promises";
|
|
19953
|
-
import { homedir as
|
|
19954
|
-
import { join as
|
|
19988
|
+
import { homedir as homedir5 } from "node:os";
|
|
19989
|
+
import { join as join6 } from "node:path";
|
|
19955
19990
|
var PROVIDER_ID, CLAUDE_CODE_EVENT_MAP, ClaudeCodeHookProvider;
|
|
19956
19991
|
var init_hooks = __esm({
|
|
19957
19992
|
"packages/adapters/src/providers/claude-code/hooks.ts"() {
|
|
@@ -20028,12 +20063,12 @@ var init_hooks = __esm({
|
|
|
20028
20063
|
this.projectDir = projectDir;
|
|
20029
20064
|
this.registered = true;
|
|
20030
20065
|
try {
|
|
20031
|
-
const home =
|
|
20032
|
-
const settingsPath =
|
|
20066
|
+
const home = homedir5();
|
|
20067
|
+
const settingsPath = join6(home, ".claude", "settings.json");
|
|
20033
20068
|
let settings = {};
|
|
20034
|
-
if (
|
|
20069
|
+
if (existsSync6(settingsPath)) {
|
|
20035
20070
|
try {
|
|
20036
|
-
settings = JSON.parse(
|
|
20071
|
+
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
20037
20072
|
} catch {
|
|
20038
20073
|
}
|
|
20039
20074
|
}
|
|
@@ -20075,7 +20110,7 @@ var init_hooks = __esm({
|
|
|
20075
20110
|
]
|
|
20076
20111
|
});
|
|
20077
20112
|
settings.hooks = hooks;
|
|
20078
|
-
mkdirSync2(
|
|
20113
|
+
mkdirSync2(join6(home, ".claude"), { recursive: true });
|
|
20079
20114
|
writeFileSync2(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
20080
20115
|
} catch {
|
|
20081
20116
|
}
|
|
@@ -20092,10 +20127,10 @@ var init_hooks = __esm({
|
|
|
20092
20127
|
this.registered = false;
|
|
20093
20128
|
this.projectDir = null;
|
|
20094
20129
|
try {
|
|
20095
|
-
const home =
|
|
20096
|
-
const settingsPath =
|
|
20097
|
-
if (!
|
|
20098
|
-
const settings = JSON.parse(
|
|
20130
|
+
const home = homedir5();
|
|
20131
|
+
const settingsPath = join6(home, ".claude", "settings.json");
|
|
20132
|
+
if (!existsSync6(settingsPath)) return;
|
|
20133
|
+
const settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
20099
20134
|
const hooks = settings.hooks;
|
|
20100
20135
|
if (!hooks) return;
|
|
20101
20136
|
let changed = false;
|
|
@@ -20205,32 +20240,50 @@ var init_hooks = __esm({
|
|
|
20205
20240
|
/**
|
|
20206
20241
|
* Extract a plain-text transcript from Claude Code session JSONL files.
|
|
20207
20242
|
*
|
|
20208
|
-
*
|
|
20243
|
+
* Claude Code stores session data under `~/.claude/projects/<project-slug>/`:
|
|
20244
|
+
* - Root-level session JSONLs: `<sessionId>.jsonl` (primary transcript)
|
|
20245
|
+
* - UUID subdirectories contain `subagents/agent-*.jsonl` (subagent turns)
|
|
20246
|
+
*
|
|
20247
|
+
* Reads the most-recent root-level JSONL plus all subagent JSONLs and
|
|
20209
20248
|
* extracts user/assistant turn text into a flat string for brain
|
|
20210
20249
|
* observation extraction.
|
|
20211
20250
|
*
|
|
20212
20251
|
* Returns null when no session data is found or on any read error.
|
|
20213
20252
|
*
|
|
20214
|
-
* @param
|
|
20253
|
+
* @param sessionId - CLEO session ID (available for future subagent filtering)
|
|
20215
20254
|
* @param _projectDir - Project directory (unused; Claude Code uses global paths)
|
|
20216
|
-
* @task T144 @epic T134
|
|
20255
|
+
* @task T729 @task T144 @epic T134
|
|
20217
20256
|
*/
|
|
20218
|
-
async getTranscript(
|
|
20257
|
+
async getTranscript(sessionId, _projectDir) {
|
|
20219
20258
|
try {
|
|
20220
20259
|
const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? "/root";
|
|
20221
|
-
const projectsDir =
|
|
20222
|
-
let
|
|
20260
|
+
const projectsDir = join6(homeDir, ".claude", "projects");
|
|
20261
|
+
let rootFiles = [];
|
|
20262
|
+
const subagentFiles = [];
|
|
20223
20263
|
try {
|
|
20224
20264
|
const projectDirs = await readdir(projectsDir, { withFileTypes: true });
|
|
20225
|
-
for (const
|
|
20226
|
-
if (!
|
|
20227
|
-
const
|
|
20265
|
+
for (const projectEntry of projectDirs) {
|
|
20266
|
+
if (!projectEntry.isDirectory()) continue;
|
|
20267
|
+
const projectDir = join6(projectsDir, projectEntry.name);
|
|
20228
20268
|
try {
|
|
20229
|
-
const
|
|
20230
|
-
for (const
|
|
20231
|
-
if (
|
|
20232
|
-
|
|
20233
|
-
|
|
20269
|
+
const projectContents = await readdir(projectDir, { withFileTypes: true });
|
|
20270
|
+
for (const entry of projectContents) {
|
|
20271
|
+
if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
20272
|
+
rootFiles.push({ path: join6(projectDir, entry.name) });
|
|
20273
|
+
continue;
|
|
20274
|
+
}
|
|
20275
|
+
if (entry.isDirectory()) {
|
|
20276
|
+
const subagentsDir = join6(projectDir, entry.name, "subagents");
|
|
20277
|
+
try {
|
|
20278
|
+
const subagentEntries = await readdir(subagentsDir);
|
|
20279
|
+
for (const sa of subagentEntries) {
|
|
20280
|
+
if (sa.startsWith("agent-") && sa.endsWith(".jsonl")) {
|
|
20281
|
+
subagentFiles.push({ path: join6(subagentsDir, sa) });
|
|
20282
|
+
}
|
|
20283
|
+
}
|
|
20284
|
+
} catch {
|
|
20285
|
+
}
|
|
20286
|
+
}
|
|
20234
20287
|
}
|
|
20235
20288
|
} catch {
|
|
20236
20289
|
}
|
|
@@ -20238,22 +20291,30 @@ var init_hooks = __esm({
|
|
|
20238
20291
|
} catch {
|
|
20239
20292
|
return null;
|
|
20240
20293
|
}
|
|
20241
|
-
if (
|
|
20242
|
-
|
|
20243
|
-
const
|
|
20244
|
-
|
|
20245
|
-
|
|
20246
|
-
|
|
20294
|
+
if (rootFiles.length === 0 && subagentFiles.length === 0) return null;
|
|
20295
|
+
rootFiles = rootFiles.sort((a3, b4) => b4.path.localeCompare(a3.path));
|
|
20296
|
+
const allPaths = [
|
|
20297
|
+
...rootFiles[0] ? [rootFiles[0].path] : [],
|
|
20298
|
+
...subagentFiles.map((f6) => f6.path)
|
|
20299
|
+
];
|
|
20300
|
+
void sessionId;
|
|
20247
20301
|
const turns = [];
|
|
20248
|
-
for (const
|
|
20302
|
+
for (const filePath of allPaths) {
|
|
20249
20303
|
try {
|
|
20250
|
-
const
|
|
20251
|
-
const
|
|
20252
|
-
const
|
|
20253
|
-
|
|
20254
|
-
|
|
20255
|
-
|
|
20256
|
-
|
|
20304
|
+
const raw = await readFile(filePath, "utf-8");
|
|
20305
|
+
const lines = raw.split("\n").filter((l3) => l3.trim());
|
|
20306
|
+
for (const line of lines) {
|
|
20307
|
+
try {
|
|
20308
|
+
const entry = JSON.parse(line);
|
|
20309
|
+
const role = entry.role;
|
|
20310
|
+
const content = entry.content;
|
|
20311
|
+
if (role === "assistant" && typeof content === "string") {
|
|
20312
|
+
turns.push(`assistant: ${content}`);
|
|
20313
|
+
} else if (role === "user" && typeof content === "string") {
|
|
20314
|
+
turns.push(`user: ${content}`);
|
|
20315
|
+
}
|
|
20316
|
+
} catch {
|
|
20317
|
+
}
|
|
20257
20318
|
}
|
|
20258
20319
|
} catch {
|
|
20259
20320
|
}
|
|
@@ -20270,18 +20331,18 @@ var init_hooks = __esm({
|
|
|
20270
20331
|
// packages/adapters/src/providers/claude-code/install.ts
|
|
20271
20332
|
import {
|
|
20272
20333
|
copyFileSync as copyFileSync2,
|
|
20273
|
-
existsSync as
|
|
20334
|
+
existsSync as existsSync7,
|
|
20274
20335
|
mkdirSync as mkdirSync3,
|
|
20275
20336
|
readdirSync as readdirSync3,
|
|
20276
|
-
readFileSync as
|
|
20337
|
+
readFileSync as readFileSync6,
|
|
20277
20338
|
writeFileSync as writeFileSync3
|
|
20278
20339
|
} from "node:fs";
|
|
20279
|
-
import { homedir as
|
|
20280
|
-
import { dirname as dirname2, join as
|
|
20340
|
+
import { homedir as homedir6 } from "node:os";
|
|
20341
|
+
import { dirname as dirname2, join as join7 } from "node:path";
|
|
20281
20342
|
import { fileURLToPath } from "node:url";
|
|
20282
20343
|
function getAdapterCommandsDir() {
|
|
20283
20344
|
const thisDir = dirname2(fileURLToPath(import.meta.url));
|
|
20284
|
-
return
|
|
20345
|
+
return join7(thisDir, "commands");
|
|
20285
20346
|
}
|
|
20286
20347
|
var INSTRUCTION_REFERENCES, ClaudeCodeInstallProvider;
|
|
20287
20348
|
var init_install = __esm({
|
|
@@ -20302,7 +20363,7 @@ var init_install = __esm({
|
|
|
20302
20363
|
const details = {};
|
|
20303
20364
|
instructionFileUpdated = this.updateInstructionFile(projectDir);
|
|
20304
20365
|
if (instructionFileUpdated) {
|
|
20305
|
-
details.instructionFile =
|
|
20366
|
+
details.instructionFile = join7(projectDir, "CLAUDE.md");
|
|
20306
20367
|
}
|
|
20307
20368
|
const commandsInstalled = this.installCommands(projectDir);
|
|
20308
20369
|
if (commandsInstalled.length > 0) {
|
|
@@ -20332,10 +20393,10 @@ var init_install = __esm({
|
|
|
20332
20393
|
* Checks for plugin enabled in ~/.claude/settings.json.
|
|
20333
20394
|
*/
|
|
20334
20395
|
async isInstalled() {
|
|
20335
|
-
const settingsPath =
|
|
20336
|
-
if (
|
|
20396
|
+
const settingsPath = join7(homedir6(), ".claude", "settings.json");
|
|
20397
|
+
if (existsSync7(settingsPath)) {
|
|
20337
20398
|
try {
|
|
20338
|
-
const settings = JSON.parse(
|
|
20399
|
+
const settings = JSON.parse(readFileSync6(settingsPath, "utf-8"));
|
|
20339
20400
|
const plugins = settings.enabledPlugins;
|
|
20340
20401
|
if (plugins && plugins["cleo@cleocode"] === true) {
|
|
20341
20402
|
return true;
|
|
@@ -20361,11 +20422,11 @@ var init_install = __esm({
|
|
|
20361
20422
|
* @returns true if the file was created or modified
|
|
20362
20423
|
*/
|
|
20363
20424
|
updateInstructionFile(projectDir) {
|
|
20364
|
-
const claudeMdPath =
|
|
20425
|
+
const claudeMdPath = join7(projectDir, "CLAUDE.md");
|
|
20365
20426
|
let content = "";
|
|
20366
20427
|
let existed = false;
|
|
20367
|
-
if (
|
|
20368
|
-
content =
|
|
20428
|
+
if (existsSync7(claudeMdPath)) {
|
|
20429
|
+
content = readFileSync6(claudeMdPath, "utf-8");
|
|
20369
20430
|
existed = true;
|
|
20370
20431
|
}
|
|
20371
20432
|
const missingRefs = INSTRUCTION_REFERENCES.filter((ref) => !content.includes(ref));
|
|
@@ -20393,16 +20454,16 @@ var init_install = __esm({
|
|
|
20393
20454
|
*/
|
|
20394
20455
|
installCommands(projectDir) {
|
|
20395
20456
|
const adapterCommandsDir = getAdapterCommandsDir();
|
|
20396
|
-
if (!
|
|
20457
|
+
if (!existsSync7(adapterCommandsDir)) {
|
|
20397
20458
|
return [];
|
|
20398
20459
|
}
|
|
20399
|
-
const targetDir =
|
|
20460
|
+
const targetDir = join7(projectDir, ".claude", "commands");
|
|
20400
20461
|
mkdirSync3(targetDir, { recursive: true });
|
|
20401
20462
|
const installed = [];
|
|
20402
20463
|
const files = readdirSync3(adapterCommandsDir).filter((f6) => f6.endsWith(".md"));
|
|
20403
20464
|
for (const file of files) {
|
|
20404
|
-
const src =
|
|
20405
|
-
const dest =
|
|
20465
|
+
const src = join7(adapterCommandsDir, file);
|
|
20466
|
+
const dest = join7(targetDir, file);
|
|
20406
20467
|
copyFileSync2(src, dest);
|
|
20407
20468
|
installed.push(file);
|
|
20408
20469
|
}
|
|
@@ -20414,12 +20475,12 @@ var init_install = __esm({
|
|
|
20414
20475
|
* @returns Description of what was registered, or null if no change needed
|
|
20415
20476
|
*/
|
|
20416
20477
|
registerPlugin() {
|
|
20417
|
-
const home =
|
|
20418
|
-
const settingsPath =
|
|
20478
|
+
const home = homedir6();
|
|
20479
|
+
const settingsPath = join7(home, ".claude", "settings.json");
|
|
20419
20480
|
let settings = {};
|
|
20420
|
-
if (
|
|
20481
|
+
if (existsSync7(settingsPath)) {
|
|
20421
20482
|
try {
|
|
20422
|
-
settings = JSON.parse(
|
|
20483
|
+
settings = JSON.parse(readFileSync6(settingsPath, "utf-8"));
|
|
20423
20484
|
} catch {
|
|
20424
20485
|
}
|
|
20425
20486
|
}
|
|
@@ -20433,7 +20494,7 @@ var init_install = __esm({
|
|
|
20433
20494
|
}
|
|
20434
20495
|
enabledPlugins[pluginKey] = true;
|
|
20435
20496
|
settings.enabledPlugins = enabledPlugins;
|
|
20436
|
-
mkdirSync3(
|
|
20497
|
+
mkdirSync3(join7(home, ".claude"), { recursive: true });
|
|
20437
20498
|
writeFileSync3(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
20438
20499
|
return `Enabled ${pluginKey} in ~/.claude/settings.json`;
|
|
20439
20500
|
}
|
|
@@ -20603,7 +20664,7 @@ var init_spawn2 = __esm({
|
|
|
20603
20664
|
|
|
20604
20665
|
// packages/adapters/src/providers/claude-code/task-sync.ts
|
|
20605
20666
|
import { readFile as readFile2, stat } from "node:fs/promises";
|
|
20606
|
-
import { join as
|
|
20667
|
+
import { join as join8 } from "node:path";
|
|
20607
20668
|
function parseTaskId(content) {
|
|
20608
20669
|
const match = content.match(/^\[T(\d+)\]/);
|
|
20609
20670
|
return match ? `T${match[1]}` : null;
|
|
@@ -20624,7 +20685,7 @@ function mapStatus(twStatus) {
|
|
|
20624
20685
|
}
|
|
20625
20686
|
}
|
|
20626
20687
|
function getTodoWriteFilePath(projectDir) {
|
|
20627
|
-
return
|
|
20688
|
+
return join8(projectDir, ".cleo", "sync", "todowrite-state.json");
|
|
20628
20689
|
}
|
|
20629
20690
|
var ClaudeCodeTaskSyncProvider;
|
|
20630
20691
|
var init_task_sync = __esm({
|
|
@@ -20696,9 +20757,9 @@ var init_transport = __esm({
|
|
|
20696
20757
|
|
|
20697
20758
|
// packages/adapters/src/providers/claude-code/adapter.ts
|
|
20698
20759
|
import { exec as exec2 } from "node:child_process";
|
|
20699
|
-
import { existsSync as
|
|
20700
|
-
import { homedir as
|
|
20701
|
-
import { join as
|
|
20760
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
20761
|
+
import { homedir as homedir7 } from "node:os";
|
|
20762
|
+
import { join as join9 } from "node:path";
|
|
20702
20763
|
import { promisify as promisify3 } from "node:util";
|
|
20703
20764
|
var execAsync2, ClaudeCodeAdapter;
|
|
20704
20765
|
var init_adapter = __esm({
|
|
@@ -20855,8 +20916,8 @@ var init_adapter = __esm({
|
|
|
20855
20916
|
} catch {
|
|
20856
20917
|
details.cliAvailable = false;
|
|
20857
20918
|
}
|
|
20858
|
-
const claudeConfigDir =
|
|
20859
|
-
const configExists =
|
|
20919
|
+
const claudeConfigDir = join9(homedir7(), ".claude");
|
|
20920
|
+
const configExists = existsSync8(claudeConfigDir);
|
|
20860
20921
|
details.configDirExists = configExists;
|
|
20861
20922
|
const entrypointSet = process.env.CLAUDE_CODE_ENTRYPOINT !== void 0;
|
|
20862
20923
|
details.entrypointEnvSet = entrypointSet;
|
|
@@ -20885,17 +20946,17 @@ var init_adapter = __esm({
|
|
|
20885
20946
|
});
|
|
20886
20947
|
|
|
20887
20948
|
// packages/adapters/src/providers/claude-code/statusline.ts
|
|
20888
|
-
import { existsSync as
|
|
20889
|
-
import { homedir as
|
|
20890
|
-
import { join as
|
|
20949
|
+
import { existsSync as existsSync9, readFileSync as readFileSync7 } from "node:fs";
|
|
20950
|
+
import { homedir as homedir8 } from "node:os";
|
|
20951
|
+
import { join as join10 } from "node:path";
|
|
20891
20952
|
function getClaudeSettingsPath() {
|
|
20892
|
-
return process.env["CLAUDE_SETTINGS"] ??
|
|
20953
|
+
return process.env["CLAUDE_SETTINGS"] ?? join10(process.env["CLAUDE_HOME"] ?? join10(homedir8(), ".claude"), "settings.json");
|
|
20893
20954
|
}
|
|
20894
20955
|
function checkStatuslineIntegration() {
|
|
20895
20956
|
const settingsPath = getClaudeSettingsPath();
|
|
20896
|
-
if (!
|
|
20957
|
+
if (!existsSync9(settingsPath)) return "no_settings";
|
|
20897
20958
|
try {
|
|
20898
|
-
const settings = JSON.parse(
|
|
20959
|
+
const settings = JSON.parse(readFileSync7(settingsPath, "utf-8"));
|
|
20899
20960
|
const statusLine = settings.statusLine;
|
|
20900
20961
|
if (!statusLine?.type) return "not_configured";
|
|
20901
20962
|
if (statusLine.type !== "command") return "custom_no_cleo";
|
|
@@ -20903,10 +20964,10 @@ function checkStatuslineIntegration() {
|
|
|
20903
20964
|
if (cmd.includes("context-monitor.sh") || cmd.includes("cleo-statusline") || cmd.includes(".context-state.json") || cmd.includes("context-states")) {
|
|
20904
20965
|
return "configured";
|
|
20905
20966
|
}
|
|
20906
|
-
const scriptPath = cmd.startsWith("~") ? cmd.replace("~",
|
|
20907
|
-
if (
|
|
20967
|
+
const scriptPath = cmd.startsWith("~") ? cmd.replace("~", homedir8()) : cmd;
|
|
20968
|
+
if (existsSync9(scriptPath)) {
|
|
20908
20969
|
try {
|
|
20909
|
-
const content =
|
|
20970
|
+
const content = readFileSync7(scriptPath, "utf-8");
|
|
20910
20971
|
if (content.includes("context-state.json")) return "configured";
|
|
20911
20972
|
} catch {
|
|
20912
20973
|
}
|
|
@@ -20920,7 +20981,7 @@ function getStatuslineConfig(cleoHome) {
|
|
|
20920
20981
|
return {
|
|
20921
20982
|
statusLine: {
|
|
20922
20983
|
type: "command",
|
|
20923
|
-
command:
|
|
20984
|
+
command: join10(cleoHome, "lib", "session", "context-monitor.sh")
|
|
20924
20985
|
}
|
|
20925
20986
|
};
|
|
20926
20987
|
}
|
|
@@ -21131,8 +21192,8 @@ var init_hooks2 = __esm({
|
|
|
21131
21192
|
});
|
|
21132
21193
|
|
|
21133
21194
|
// packages/adapters/src/providers/cursor/install.ts
|
|
21134
|
-
import { existsSync as
|
|
21135
|
-
import { join as
|
|
21195
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync4, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "node:fs";
|
|
21196
|
+
import { join as join15 } from "node:path";
|
|
21136
21197
|
var INSTRUCTION_REFERENCES3, CursorInstallProvider;
|
|
21137
21198
|
var init_install2 = __esm({
|
|
21138
21199
|
"packages/adapters/src/providers/cursor/install.ts"() {
|
|
@@ -21174,14 +21235,14 @@ var init_install2 = __esm({
|
|
|
21174
21235
|
* Checks for .cursor/rules/cleo.mdc or .cursorrules with CLEO references.
|
|
21175
21236
|
*/
|
|
21176
21237
|
async isInstalled() {
|
|
21177
|
-
const mdcPath =
|
|
21178
|
-
if (
|
|
21238
|
+
const mdcPath = join15(process.cwd(), ".cursor", "rules", "cleo.mdc");
|
|
21239
|
+
if (existsSync12(mdcPath)) {
|
|
21179
21240
|
return true;
|
|
21180
21241
|
}
|
|
21181
|
-
const rulesPath =
|
|
21182
|
-
if (
|
|
21242
|
+
const rulesPath = join15(process.cwd(), ".cursorrules");
|
|
21243
|
+
if (existsSync12(rulesPath)) {
|
|
21183
21244
|
try {
|
|
21184
|
-
const content =
|
|
21245
|
+
const content = readFileSync9(rulesPath, "utf-8");
|
|
21185
21246
|
if (INSTRUCTION_REFERENCES3.some((ref) => content.includes(ref))) {
|
|
21186
21247
|
return true;
|
|
21187
21248
|
}
|
|
@@ -21224,11 +21285,11 @@ var init_install2 = __esm({
|
|
|
21224
21285
|
* @returns true if the file was modified
|
|
21225
21286
|
*/
|
|
21226
21287
|
updateLegacyRules(projectDir) {
|
|
21227
|
-
const rulesPath =
|
|
21228
|
-
if (!
|
|
21288
|
+
const rulesPath = join15(projectDir, ".cursorrules");
|
|
21289
|
+
if (!existsSync12(rulesPath)) {
|
|
21229
21290
|
return false;
|
|
21230
21291
|
}
|
|
21231
|
-
let content =
|
|
21292
|
+
let content = readFileSync9(rulesPath, "utf-8");
|
|
21232
21293
|
const missingRefs = INSTRUCTION_REFERENCES3.filter((ref) => !content.includes(ref));
|
|
21233
21294
|
if (missingRefs.length === 0) {
|
|
21234
21295
|
return false;
|
|
@@ -21247,8 +21308,8 @@ var init_install2 = __esm({
|
|
|
21247
21308
|
* @returns true if the file was created or modified
|
|
21248
21309
|
*/
|
|
21249
21310
|
updateModernRules(projectDir) {
|
|
21250
|
-
const rulesDir =
|
|
21251
|
-
const mdcPath =
|
|
21311
|
+
const rulesDir = join15(projectDir, ".cursor", "rules");
|
|
21312
|
+
const mdcPath = join15(rulesDir, "cleo.mdc");
|
|
21252
21313
|
const expectedContent = [
|
|
21253
21314
|
"---",
|
|
21254
21315
|
"description: CLEO task management protocol references",
|
|
@@ -21259,8 +21320,8 @@ var init_install2 = __esm({
|
|
|
21259
21320
|
...INSTRUCTION_REFERENCES3,
|
|
21260
21321
|
""
|
|
21261
21322
|
].join("\n");
|
|
21262
|
-
if (
|
|
21263
|
-
const existing =
|
|
21323
|
+
if (existsSync12(mdcPath)) {
|
|
21324
|
+
const existing = readFileSync9(mdcPath, "utf-8");
|
|
21264
21325
|
if (existing === expectedContent) {
|
|
21265
21326
|
return false;
|
|
21266
21327
|
}
|
|
@@ -21274,10 +21335,10 @@ var init_install2 = __esm({
|
|
|
21274
21335
|
*/
|
|
21275
21336
|
getUpdatedFileList(projectDir) {
|
|
21276
21337
|
const files = [];
|
|
21277
|
-
if (
|
|
21278
|
-
files.push(
|
|
21338
|
+
if (existsSync12(join15(projectDir, ".cursorrules"))) {
|
|
21339
|
+
files.push(join15(projectDir, ".cursorrules"));
|
|
21279
21340
|
}
|
|
21280
|
-
files.push(
|
|
21341
|
+
files.push(join15(projectDir, ".cursor", "rules", "cleo.mdc"));
|
|
21281
21342
|
return files;
|
|
21282
21343
|
}
|
|
21283
21344
|
};
|
|
@@ -21285,8 +21346,8 @@ var init_install2 = __esm({
|
|
|
21285
21346
|
});
|
|
21286
21347
|
|
|
21287
21348
|
// packages/adapters/src/providers/cursor/adapter.ts
|
|
21288
|
-
import { existsSync as
|
|
21289
|
-
import { join as
|
|
21349
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
21350
|
+
import { join as join16 } from "node:path";
|
|
21290
21351
|
var CursorAdapter;
|
|
21291
21352
|
var init_adapter2 = __esm({
|
|
21292
21353
|
"packages/adapters/src/providers/cursor/adapter.ts"() {
|
|
@@ -21380,14 +21441,14 @@ var init_adapter2 = __esm({
|
|
|
21380
21441
|
}
|
|
21381
21442
|
let configExists = false;
|
|
21382
21443
|
if (this.projectDir) {
|
|
21383
|
-
const cursorConfigDir =
|
|
21384
|
-
configExists =
|
|
21444
|
+
const cursorConfigDir = join16(this.projectDir, ".cursor");
|
|
21445
|
+
configExists = existsSync13(cursorConfigDir);
|
|
21385
21446
|
details.configDirExists = configExists;
|
|
21386
21447
|
}
|
|
21387
21448
|
const editorEnvSet = process.env.CURSOR_EDITOR !== void 0;
|
|
21388
21449
|
details.editorEnvSet = editorEnvSet;
|
|
21389
21450
|
if (this.projectDir) {
|
|
21390
|
-
const legacyRulesExist =
|
|
21451
|
+
const legacyRulesExist = existsSync13(join16(this.projectDir, ".cursorrules"));
|
|
21391
21452
|
details.legacyRulesExist = legacyRulesExist;
|
|
21392
21453
|
}
|
|
21393
21454
|
const healthy = configExists || editorEnvSet;
|
|
@@ -21591,8 +21652,8 @@ var init_hooks3 = __esm({
|
|
|
21591
21652
|
});
|
|
21592
21653
|
|
|
21593
21654
|
// packages/adapters/src/providers/opencode/install.ts
|
|
21594
|
-
import { existsSync as
|
|
21595
|
-
import { join as
|
|
21655
|
+
import { existsSync as existsSync18, readFileSync as readFileSync12, writeFileSync as writeFileSync8 } from "node:fs";
|
|
21656
|
+
import { join as join22 } from "node:path";
|
|
21596
21657
|
var INSTRUCTION_REFERENCES6, OpenCodeInstallProvider;
|
|
21597
21658
|
var init_install3 = __esm({
|
|
21598
21659
|
"packages/adapters/src/providers/opencode/install.ts"() {
|
|
@@ -21612,7 +21673,7 @@ var init_install3 = __esm({
|
|
|
21612
21673
|
const details = {};
|
|
21613
21674
|
instructionFileUpdated = this.updateInstructionFile(projectDir);
|
|
21614
21675
|
if (instructionFileUpdated) {
|
|
21615
|
-
details.instructionFile =
|
|
21676
|
+
details.instructionFile = join22(projectDir, "AGENTS.md");
|
|
21616
21677
|
}
|
|
21617
21678
|
return {
|
|
21618
21679
|
success: true,
|
|
@@ -21634,10 +21695,10 @@ var init_install3 = __esm({
|
|
|
21634
21695
|
* Checks for CLEO references in AGENTS.md.
|
|
21635
21696
|
*/
|
|
21636
21697
|
async isInstalled() {
|
|
21637
|
-
const agentsMdPath =
|
|
21638
|
-
if (
|
|
21698
|
+
const agentsMdPath = join22(process.cwd(), "AGENTS.md");
|
|
21699
|
+
if (existsSync18(agentsMdPath)) {
|
|
21639
21700
|
try {
|
|
21640
|
-
const content =
|
|
21701
|
+
const content = readFileSync12(agentsMdPath, "utf-8");
|
|
21641
21702
|
if (INSTRUCTION_REFERENCES6.some((ref) => content.includes(ref))) {
|
|
21642
21703
|
return true;
|
|
21643
21704
|
}
|
|
@@ -21662,11 +21723,11 @@ var init_install3 = __esm({
|
|
|
21662
21723
|
* @returns true if the file was created or modified
|
|
21663
21724
|
*/
|
|
21664
21725
|
updateInstructionFile(projectDir) {
|
|
21665
|
-
const agentsMdPath =
|
|
21726
|
+
const agentsMdPath = join22(projectDir, "AGENTS.md");
|
|
21666
21727
|
let content = "";
|
|
21667
21728
|
let existed = false;
|
|
21668
|
-
if (
|
|
21669
|
-
content =
|
|
21729
|
+
if (existsSync18(agentsMdPath)) {
|
|
21730
|
+
content = readFileSync12(agentsMdPath, "utf-8");
|
|
21670
21731
|
existed = true;
|
|
21671
21732
|
}
|
|
21672
21733
|
const missingRefs = INSTRUCTION_REFERENCES6.filter((ref) => !content.includes(ref));
|
|
@@ -21690,7 +21751,7 @@ var init_install3 = __esm({
|
|
|
21690
21751
|
// packages/adapters/src/providers/opencode/spawn.ts
|
|
21691
21752
|
import { exec as exec6, spawn as nodeSpawn2 } from "node:child_process";
|
|
21692
21753
|
import { mkdir as mkdir2, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
|
|
21693
|
-
import { join as
|
|
21754
|
+
import { join as join23 } from "node:path";
|
|
21694
21755
|
import { promisify as promisify7 } from "node:util";
|
|
21695
21756
|
function buildOpenCodeAgentMarkdown(description, instructions) {
|
|
21696
21757
|
const normalizedDesc = description.replace(/\s+/g, " ").trim();
|
|
@@ -21706,8 +21767,8 @@ function buildOpenCodeAgentMarkdown(description, instructions) {
|
|
|
21706
21767
|
].join("\n");
|
|
21707
21768
|
}
|
|
21708
21769
|
async function ensureSubagentDefinition(workingDirectory, enrichedInstructions) {
|
|
21709
|
-
const agentDir =
|
|
21710
|
-
const agentPath =
|
|
21770
|
+
const agentDir = join23(workingDirectory, ".opencode", "agent");
|
|
21771
|
+
const agentPath = join23(agentDir, `${OPENCODE_SUBAGENT_NAME}.md`);
|
|
21711
21772
|
const description = "CLEO task executor with protocol compliance and CANT context.";
|
|
21712
21773
|
const instructions = enrichedInstructions ?? [
|
|
21713
21774
|
"# CLEO Subagent",
|
|
@@ -21880,8 +21941,8 @@ var init_spawn3 = __esm({
|
|
|
21880
21941
|
|
|
21881
21942
|
// packages/adapters/src/providers/opencode/adapter.ts
|
|
21882
21943
|
import { exec as exec7 } from "node:child_process";
|
|
21883
|
-
import { existsSync as
|
|
21884
|
-
import { join as
|
|
21944
|
+
import { existsSync as existsSync19 } from "node:fs";
|
|
21945
|
+
import { join as join24 } from "node:path";
|
|
21885
21946
|
import { promisify as promisify8 } from "node:util";
|
|
21886
21947
|
var execAsync7, OpenCodeAdapter;
|
|
21887
21948
|
var init_adapter3 = __esm({
|
|
@@ -21993,8 +22054,8 @@ var init_adapter3 = __esm({
|
|
|
21993
22054
|
details.cliAvailable = false;
|
|
21994
22055
|
}
|
|
21995
22056
|
if (this.projectDir) {
|
|
21996
|
-
const openCodeConfigDir =
|
|
21997
|
-
const configExists =
|
|
22057
|
+
const openCodeConfigDir = join24(this.projectDir, ".opencode");
|
|
22058
|
+
const configExists = existsSync19(openCodeConfigDir);
|
|
21998
22059
|
details.configDirExists = configExists;
|
|
21999
22060
|
}
|
|
22000
22061
|
const versionEnvSet = process.env.OPENCODE_VERSION !== void 0;
|
|
@@ -22203,21 +22264,21 @@ var init_hooks4 = __esm({
|
|
|
22203
22264
|
});
|
|
22204
22265
|
|
|
22205
22266
|
// packages/adapters/src/providers/pi/install.ts
|
|
22206
|
-
import { existsSync as
|
|
22207
|
-
import { homedir as
|
|
22208
|
-
import { join as
|
|
22267
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync5, readFileSync as readFileSync13, writeFileSync as writeFileSync9 } from "node:fs";
|
|
22268
|
+
import { homedir as homedir14 } from "node:os";
|
|
22269
|
+
import { join as join25 } from "node:path";
|
|
22209
22270
|
function getPiAgentDir() {
|
|
22210
22271
|
const env = process.env["PI_CODING_AGENT_DIR"];
|
|
22211
22272
|
if (env !== void 0 && env.length > 0) {
|
|
22212
|
-
if (env === "~") return
|
|
22213
|
-
if (env.startsWith("~/")) return
|
|
22273
|
+
if (env === "~") return homedir14();
|
|
22274
|
+
if (env.startsWith("~/")) return join25(homedir14(), env.slice(2));
|
|
22214
22275
|
return env;
|
|
22215
22276
|
}
|
|
22216
22277
|
const piHome = process.env["PI_HOME"];
|
|
22217
22278
|
if (piHome !== void 0 && piHome.length > 0) {
|
|
22218
|
-
return
|
|
22279
|
+
return join25(piHome, "agent");
|
|
22219
22280
|
}
|
|
22220
|
-
return
|
|
22281
|
+
return join25(homedir14(), ".pi", "agent");
|
|
22221
22282
|
}
|
|
22222
22283
|
var INSTRUCTION_REFERENCES7, PiInstallProvider;
|
|
22223
22284
|
var init_install4 = __esm({
|
|
@@ -22237,14 +22298,14 @@ var init_install4 = __esm({
|
|
|
22237
22298
|
const details = {};
|
|
22238
22299
|
const projectUpdated = this.updateInstructionFile(projectDir, "AGENTS.md");
|
|
22239
22300
|
if (projectUpdated) {
|
|
22240
|
-
details.instructionFile =
|
|
22301
|
+
details.instructionFile = join25(projectDir, "AGENTS.md");
|
|
22241
22302
|
}
|
|
22242
22303
|
let globalUpdated = false;
|
|
22243
22304
|
try {
|
|
22244
22305
|
const globalDir = getPiAgentDir();
|
|
22245
22306
|
globalUpdated = this.updateInstructionFile(globalDir, "AGENTS.md");
|
|
22246
22307
|
if (globalUpdated) {
|
|
22247
|
-
details.globalInstructionFile =
|
|
22308
|
+
details.globalInstructionFile = join25(globalDir, "AGENTS.md");
|
|
22248
22309
|
}
|
|
22249
22310
|
} catch {
|
|
22250
22311
|
}
|
|
@@ -22269,10 +22330,10 @@ var init_install4 = __esm({
|
|
|
22269
22330
|
* Checks for CLEO references in the project AGENTS.md.
|
|
22270
22331
|
*/
|
|
22271
22332
|
async isInstalled() {
|
|
22272
|
-
const agentsMdPath =
|
|
22273
|
-
if (
|
|
22333
|
+
const agentsMdPath = join25(process.cwd(), "AGENTS.md");
|
|
22334
|
+
if (existsSync20(agentsMdPath)) {
|
|
22274
22335
|
try {
|
|
22275
|
-
const content =
|
|
22336
|
+
const content = readFileSync13(agentsMdPath, "utf-8");
|
|
22276
22337
|
if (INSTRUCTION_REFERENCES7.some((ref) => content.includes(ref))) {
|
|
22277
22338
|
return true;
|
|
22278
22339
|
}
|
|
@@ -22280,9 +22341,9 @@ var init_install4 = __esm({
|
|
|
22280
22341
|
}
|
|
22281
22342
|
}
|
|
22282
22343
|
try {
|
|
22283
|
-
const globalPath =
|
|
22284
|
-
if (
|
|
22285
|
-
const content =
|
|
22344
|
+
const globalPath = join25(getPiAgentDir(), "AGENTS.md");
|
|
22345
|
+
if (existsSync20(globalPath)) {
|
|
22346
|
+
const content = readFileSync13(globalPath, "utf-8");
|
|
22286
22347
|
if (INSTRUCTION_REFERENCES7.some((ref) => content.includes(ref))) {
|
|
22287
22348
|
return true;
|
|
22288
22349
|
}
|
|
@@ -22309,11 +22370,11 @@ var init_install4 = __esm({
|
|
|
22309
22370
|
* @returns true if the file was created or modified
|
|
22310
22371
|
*/
|
|
22311
22372
|
updateInstructionFile(dir, filename) {
|
|
22312
|
-
const filePath =
|
|
22373
|
+
const filePath = join25(dir, filename);
|
|
22313
22374
|
let content = "";
|
|
22314
22375
|
let existed = false;
|
|
22315
|
-
if (
|
|
22316
|
-
content =
|
|
22376
|
+
if (existsSync20(filePath)) {
|
|
22377
|
+
content = readFileSync13(filePath, "utf-8");
|
|
22317
22378
|
existed = true;
|
|
22318
22379
|
}
|
|
22319
22380
|
const missingRefs = INSTRUCTION_REFERENCES7.filter((ref) => !content.includes(ref));
|
|
@@ -22488,22 +22549,22 @@ var init_spawn4 = __esm({
|
|
|
22488
22549
|
|
|
22489
22550
|
// packages/adapters/src/providers/pi/adapter.ts
|
|
22490
22551
|
import { exec as exec9 } from "node:child_process";
|
|
22491
|
-
import { existsSync as
|
|
22492
|
-
import { homedir as
|
|
22493
|
-
import { join as
|
|
22552
|
+
import { existsSync as existsSync21 } from "node:fs";
|
|
22553
|
+
import { homedir as homedir15 } from "node:os";
|
|
22554
|
+
import { join as join26 } from "node:path";
|
|
22494
22555
|
import { promisify as promisify10 } from "node:util";
|
|
22495
22556
|
function getPiAgentDir2() {
|
|
22496
22557
|
const env = process.env["PI_CODING_AGENT_DIR"];
|
|
22497
22558
|
if (env !== void 0 && env.length > 0) {
|
|
22498
|
-
if (env === "~") return
|
|
22499
|
-
if (env.startsWith("~/")) return
|
|
22559
|
+
if (env === "~") return homedir15();
|
|
22560
|
+
if (env.startsWith("~/")) return join26(homedir15(), env.slice(2));
|
|
22500
22561
|
return env;
|
|
22501
22562
|
}
|
|
22502
22563
|
const piHome = process.env["PI_HOME"];
|
|
22503
22564
|
if (piHome !== void 0 && piHome.length > 0) {
|
|
22504
|
-
return
|
|
22565
|
+
return join26(piHome, "agent");
|
|
22505
22566
|
}
|
|
22506
|
-
return
|
|
22567
|
+
return join26(homedir15(), ".pi", "agent");
|
|
22507
22568
|
}
|
|
22508
22569
|
var execAsync9, PiAdapter;
|
|
22509
22570
|
var init_adapter4 = __esm({
|
|
@@ -22621,12 +22682,12 @@ var init_adapter4 = __esm({
|
|
|
22621
22682
|
details.cliAvailable = false;
|
|
22622
22683
|
}
|
|
22623
22684
|
const agentDir = getPiAgentDir2();
|
|
22624
|
-
const agentDirExists =
|
|
22685
|
+
const agentDirExists = existsSync21(agentDir);
|
|
22625
22686
|
details.agentDirExists = agentDirExists;
|
|
22626
22687
|
details.agentDir = agentDir;
|
|
22627
22688
|
if (this.projectDir) {
|
|
22628
|
-
const projectPiDir =
|
|
22629
|
-
details.projectPiDirExists =
|
|
22689
|
+
const projectPiDir = join26(this.projectDir, ".pi");
|
|
22690
|
+
details.projectPiDirExists = existsSync21(projectPiDir);
|
|
22630
22691
|
}
|
|
22631
22692
|
details.piCodingAgentDirSet = process.env["PI_CODING_AGENT_DIR"] !== void 0;
|
|
22632
22693
|
details.piHomeSet = process.env["PI_HOME"] !== void 0;
|
|
@@ -22693,18 +22754,18 @@ init_tool_bridge();
|
|
|
22693
22754
|
|
|
22694
22755
|
// packages/adapters/src/providers/codex/adapter.ts
|
|
22695
22756
|
import { exec as exec3 } from "node:child_process";
|
|
22696
|
-
import { existsSync as
|
|
22697
|
-
import { homedir as
|
|
22698
|
-
import { join as
|
|
22757
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
22758
|
+
import { homedir as homedir10 } from "node:os";
|
|
22759
|
+
import { join as join14 } from "node:path";
|
|
22699
22760
|
import { promisify as promisify4 } from "node:util";
|
|
22700
22761
|
|
|
22701
22762
|
// packages/adapters/src/providers/codex/hooks.ts
|
|
22702
|
-
import { homedir as
|
|
22703
|
-
import { join as
|
|
22763
|
+
import { homedir as homedir9 } from "node:os";
|
|
22764
|
+
import { join as join12 } from "node:path";
|
|
22704
22765
|
|
|
22705
22766
|
// packages/adapters/src/providers/shared/transcript-reader.ts
|
|
22706
22767
|
import { readdir as readdir2, readFile as readFile3 } from "node:fs/promises";
|
|
22707
|
-
import { join as
|
|
22768
|
+
import { join as join11 } from "node:path";
|
|
22708
22769
|
function parseTranscriptLines(raw) {
|
|
22709
22770
|
const turns = [];
|
|
22710
22771
|
const lines = raw.split("\n").filter((l3) => l3.trim());
|
|
@@ -22729,7 +22790,7 @@ async function readLatestTranscript(providerDir) {
|
|
|
22729
22790
|
if (!entry.isFile()) continue;
|
|
22730
22791
|
const name = entry.name;
|
|
22731
22792
|
if (name.endsWith(".json") || name.endsWith(".jsonl")) {
|
|
22732
|
-
allFiles.push(
|
|
22793
|
+
allFiles.push(join11(providerDir, name));
|
|
22733
22794
|
}
|
|
22734
22795
|
}
|
|
22735
22796
|
} catch {
|
|
@@ -22819,13 +22880,13 @@ var CodexHookProvider = class {
|
|
|
22819
22880
|
* @task T162 @epic T134
|
|
22820
22881
|
*/
|
|
22821
22882
|
async getTranscript(_sessionId, _projectDir) {
|
|
22822
|
-
return readLatestTranscript(
|
|
22883
|
+
return readLatestTranscript(join12(homedir9(), ".codex"));
|
|
22823
22884
|
}
|
|
22824
22885
|
};
|
|
22825
22886
|
|
|
22826
22887
|
// packages/adapters/src/providers/codex/install.ts
|
|
22827
|
-
import { existsSync as
|
|
22828
|
-
import { join as
|
|
22888
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync4 } from "node:fs";
|
|
22889
|
+
import { join as join13 } from "node:path";
|
|
22829
22890
|
var INSTRUCTION_REFERENCES2 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
|
|
22830
22891
|
var CodexInstallProvider = class {
|
|
22831
22892
|
/**
|
|
@@ -22842,7 +22903,7 @@ var CodexInstallProvider = class {
|
|
|
22842
22903
|
const details = {};
|
|
22843
22904
|
instructionFileUpdated = this.updateInstructionFile(projectDir);
|
|
22844
22905
|
if (instructionFileUpdated) {
|
|
22845
|
-
details.instructionFile =
|
|
22906
|
+
details.instructionFile = join13(projectDir, "AGENTS.md");
|
|
22846
22907
|
}
|
|
22847
22908
|
return {
|
|
22848
22909
|
success: true,
|
|
@@ -22866,10 +22927,10 @@ var CodexInstallProvider = class {
|
|
|
22866
22927
|
* @task T162
|
|
22867
22928
|
*/
|
|
22868
22929
|
async isInstalled() {
|
|
22869
|
-
const agentsMdPath =
|
|
22870
|
-
if (
|
|
22930
|
+
const agentsMdPath = join13(process.cwd(), "AGENTS.md");
|
|
22931
|
+
if (existsSync10(agentsMdPath)) {
|
|
22871
22932
|
try {
|
|
22872
|
-
const content =
|
|
22933
|
+
const content = readFileSync8(agentsMdPath, "utf-8");
|
|
22873
22934
|
if (INSTRUCTION_REFERENCES2.some((ref) => content.includes(ref))) {
|
|
22874
22935
|
return true;
|
|
22875
22936
|
}
|
|
@@ -22896,11 +22957,11 @@ var CodexInstallProvider = class {
|
|
|
22896
22957
|
* @returns true if the file was created or modified
|
|
22897
22958
|
*/
|
|
22898
22959
|
updateInstructionFile(projectDir) {
|
|
22899
|
-
const agentsMdPath =
|
|
22960
|
+
const agentsMdPath = join13(projectDir, "AGENTS.md");
|
|
22900
22961
|
let content = "";
|
|
22901
22962
|
let existed = false;
|
|
22902
|
-
if (
|
|
22903
|
-
content =
|
|
22963
|
+
if (existsSync10(agentsMdPath)) {
|
|
22964
|
+
content = readFileSync8(agentsMdPath, "utf-8");
|
|
22904
22965
|
existed = true;
|
|
22905
22966
|
}
|
|
22906
22967
|
const missingRefs = INSTRUCTION_REFERENCES2.filter((ref) => !content.includes(ref));
|
|
@@ -23004,8 +23065,8 @@ var CodexAdapter = class {
|
|
|
23004
23065
|
} catch {
|
|
23005
23066
|
details.cliAvailable = false;
|
|
23006
23067
|
}
|
|
23007
|
-
const codexConfigDir =
|
|
23008
|
-
const configExists =
|
|
23068
|
+
const codexConfigDir = join14(homedir10(), ".codex");
|
|
23069
|
+
const configExists = existsSync11(codexConfigDir);
|
|
23009
23070
|
details.configDirExists = configExists;
|
|
23010
23071
|
const healthy = cliAvailable;
|
|
23011
23072
|
details.cliAvailable = cliAvailable;
|
|
@@ -23041,14 +23102,14 @@ init_cursor();
|
|
|
23041
23102
|
|
|
23042
23103
|
// packages/adapters/src/providers/gemini-cli/adapter.ts
|
|
23043
23104
|
import { exec as exec4 } from "node:child_process";
|
|
23044
|
-
import { existsSync as
|
|
23045
|
-
import { homedir as
|
|
23046
|
-
import { join as
|
|
23105
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
23106
|
+
import { homedir as homedir12 } from "node:os";
|
|
23107
|
+
import { join as join19 } from "node:path";
|
|
23047
23108
|
import { promisify as promisify5 } from "node:util";
|
|
23048
23109
|
|
|
23049
23110
|
// packages/adapters/src/providers/gemini-cli/hooks.ts
|
|
23050
|
-
import { homedir as
|
|
23051
|
-
import { join as
|
|
23111
|
+
import { homedir as homedir11 } from "node:os";
|
|
23112
|
+
import { join as join17 } from "node:path";
|
|
23052
23113
|
var GEMINI_CLI_EVENT_MAP = {
|
|
23053
23114
|
SessionStart: "SessionStart",
|
|
23054
23115
|
SessionEnd: "SessionEnd",
|
|
@@ -23126,13 +23187,13 @@ var GeminiCliHookProvider = class {
|
|
|
23126
23187
|
* @task T161 @epic T134
|
|
23127
23188
|
*/
|
|
23128
23189
|
async getTranscript(_sessionId, _projectDir) {
|
|
23129
|
-
return readLatestTranscript(
|
|
23190
|
+
return readLatestTranscript(join17(homedir11(), ".gemini"));
|
|
23130
23191
|
}
|
|
23131
23192
|
};
|
|
23132
23193
|
|
|
23133
23194
|
// packages/adapters/src/providers/gemini-cli/install.ts
|
|
23134
|
-
import { existsSync as
|
|
23135
|
-
import { join as
|
|
23195
|
+
import { existsSync as existsSync14, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "node:fs";
|
|
23196
|
+
import { join as join18 } from "node:path";
|
|
23136
23197
|
var INSTRUCTION_REFERENCES4 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
|
|
23137
23198
|
var GeminiCliInstallProvider = class {
|
|
23138
23199
|
/**
|
|
@@ -23149,7 +23210,7 @@ var GeminiCliInstallProvider = class {
|
|
|
23149
23210
|
const details = {};
|
|
23150
23211
|
instructionFileUpdated = this.updateInstructionFile(projectDir);
|
|
23151
23212
|
if (instructionFileUpdated) {
|
|
23152
|
-
details.instructionFile =
|
|
23213
|
+
details.instructionFile = join18(projectDir, "AGENTS.md");
|
|
23153
23214
|
}
|
|
23154
23215
|
return {
|
|
23155
23216
|
success: true,
|
|
@@ -23173,10 +23234,10 @@ var GeminiCliInstallProvider = class {
|
|
|
23173
23234
|
* @task T161
|
|
23174
23235
|
*/
|
|
23175
23236
|
async isInstalled() {
|
|
23176
|
-
const agentsMdPath =
|
|
23177
|
-
if (
|
|
23237
|
+
const agentsMdPath = join18(process.cwd(), "AGENTS.md");
|
|
23238
|
+
if (existsSync14(agentsMdPath)) {
|
|
23178
23239
|
try {
|
|
23179
|
-
const content =
|
|
23240
|
+
const content = readFileSync10(agentsMdPath, "utf-8");
|
|
23180
23241
|
if (INSTRUCTION_REFERENCES4.some((ref) => content.includes(ref))) {
|
|
23181
23242
|
return true;
|
|
23182
23243
|
}
|
|
@@ -23203,11 +23264,11 @@ var GeminiCliInstallProvider = class {
|
|
|
23203
23264
|
* @returns true if the file was created or modified
|
|
23204
23265
|
*/
|
|
23205
23266
|
updateInstructionFile(projectDir) {
|
|
23206
|
-
const agentsMdPath =
|
|
23267
|
+
const agentsMdPath = join18(projectDir, "AGENTS.md");
|
|
23207
23268
|
let content = "";
|
|
23208
23269
|
let existed = false;
|
|
23209
|
-
if (
|
|
23210
|
-
content =
|
|
23270
|
+
if (existsSync14(agentsMdPath)) {
|
|
23271
|
+
content = readFileSync10(agentsMdPath, "utf-8");
|
|
23211
23272
|
existed = true;
|
|
23212
23273
|
}
|
|
23213
23274
|
const missingRefs = INSTRUCTION_REFERENCES4.filter((ref) => !content.includes(ref));
|
|
@@ -23322,8 +23383,8 @@ var GeminiCliAdapter = class {
|
|
|
23322
23383
|
} catch {
|
|
23323
23384
|
details.cliAvailable = false;
|
|
23324
23385
|
}
|
|
23325
|
-
const geminiConfigDir =
|
|
23326
|
-
const configExists =
|
|
23386
|
+
const geminiConfigDir = join19(homedir12(), ".gemini");
|
|
23387
|
+
const configExists = existsSync15(geminiConfigDir);
|
|
23327
23388
|
details.configDirExists = configExists;
|
|
23328
23389
|
const healthy = cliAvailable;
|
|
23329
23390
|
details.cliAvailable = cliAvailable;
|
|
@@ -23356,9 +23417,9 @@ function createAdapter4() {
|
|
|
23356
23417
|
|
|
23357
23418
|
// packages/adapters/src/providers/kimi/adapter.ts
|
|
23358
23419
|
import { exec as exec5 } from "node:child_process";
|
|
23359
|
-
import { existsSync as
|
|
23360
|
-
import { homedir as
|
|
23361
|
-
import { join as
|
|
23420
|
+
import { existsSync as existsSync17 } from "node:fs";
|
|
23421
|
+
import { homedir as homedir13 } from "node:os";
|
|
23422
|
+
import { join as join21 } from "node:path";
|
|
23362
23423
|
import { promisify as promisify6 } from "node:util";
|
|
23363
23424
|
|
|
23364
23425
|
// packages/adapters/src/providers/kimi/hooks.ts
|
|
@@ -23417,8 +23478,8 @@ var KimiHookProvider = class {
|
|
|
23417
23478
|
};
|
|
23418
23479
|
|
|
23419
23480
|
// packages/adapters/src/providers/kimi/install.ts
|
|
23420
|
-
import { existsSync as
|
|
23421
|
-
import { join as
|
|
23481
|
+
import { existsSync as existsSync16, readFileSync as readFileSync11, writeFileSync as writeFileSync7 } from "node:fs";
|
|
23482
|
+
import { join as join20 } from "node:path";
|
|
23422
23483
|
var INSTRUCTION_REFERENCES5 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
|
|
23423
23484
|
var KimiInstallProvider = class {
|
|
23424
23485
|
/**
|
|
@@ -23435,7 +23496,7 @@ var KimiInstallProvider = class {
|
|
|
23435
23496
|
const details = {};
|
|
23436
23497
|
instructionFileUpdated = this.updateInstructionFile(projectDir);
|
|
23437
23498
|
if (instructionFileUpdated) {
|
|
23438
|
-
details.instructionFile =
|
|
23499
|
+
details.instructionFile = join20(projectDir, "AGENTS.md");
|
|
23439
23500
|
}
|
|
23440
23501
|
return {
|
|
23441
23502
|
success: true,
|
|
@@ -23459,10 +23520,10 @@ var KimiInstallProvider = class {
|
|
|
23459
23520
|
* @task T163
|
|
23460
23521
|
*/
|
|
23461
23522
|
async isInstalled() {
|
|
23462
|
-
const agentsMdPath =
|
|
23463
|
-
if (
|
|
23523
|
+
const agentsMdPath = join20(process.cwd(), "AGENTS.md");
|
|
23524
|
+
if (existsSync16(agentsMdPath)) {
|
|
23464
23525
|
try {
|
|
23465
|
-
const content =
|
|
23526
|
+
const content = readFileSync11(agentsMdPath, "utf-8");
|
|
23466
23527
|
if (INSTRUCTION_REFERENCES5.some((ref) => content.includes(ref))) {
|
|
23467
23528
|
return true;
|
|
23468
23529
|
}
|
|
@@ -23489,11 +23550,11 @@ var KimiInstallProvider = class {
|
|
|
23489
23550
|
* @returns true if the file was created or modified
|
|
23490
23551
|
*/
|
|
23491
23552
|
updateInstructionFile(projectDir) {
|
|
23492
|
-
const agentsMdPath =
|
|
23553
|
+
const agentsMdPath = join20(projectDir, "AGENTS.md");
|
|
23493
23554
|
let content = "";
|
|
23494
23555
|
let existed = false;
|
|
23495
|
-
if (
|
|
23496
|
-
content =
|
|
23556
|
+
if (existsSync16(agentsMdPath)) {
|
|
23557
|
+
content = readFileSync11(agentsMdPath, "utf-8");
|
|
23497
23558
|
existed = true;
|
|
23498
23559
|
}
|
|
23499
23560
|
const missingRefs = INSTRUCTION_REFERENCES5.filter((ref) => !content.includes(ref));
|
|
@@ -23595,8 +23656,8 @@ var KimiAdapter = class {
|
|
|
23595
23656
|
} catch {
|
|
23596
23657
|
details.cliAvailable = false;
|
|
23597
23658
|
}
|
|
23598
|
-
const kimiConfigDir =
|
|
23599
|
-
const configExists =
|
|
23659
|
+
const kimiConfigDir = join21(homedir13(), ".kimi");
|
|
23660
|
+
const configExists = existsSync17(kimiConfigDir);
|
|
23600
23661
|
details.configDirExists = configExists;
|
|
23601
23662
|
const healthy = cliAvailable;
|
|
23602
23663
|
details.cliAvailable = cliAvailable;
|
|
@@ -23631,8 +23692,8 @@ function createAdapter5() {
|
|
|
23631
23692
|
init_opencode();
|
|
23632
23693
|
|
|
23633
23694
|
// packages/adapters/src/registry.ts
|
|
23634
|
-
import { readFileSync as
|
|
23635
|
-
import { dirname as dirname3, join as
|
|
23695
|
+
import { readFileSync as readFileSync14 } from "node:fs";
|
|
23696
|
+
import { dirname as dirname3, join as join27, resolve } from "node:path";
|
|
23636
23697
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
23637
23698
|
var PROVIDER_IDS = ["claude-code", "opencode", "cursor", "pi"];
|
|
23638
23699
|
function getProviderManifests() {
|
|
@@ -23640,8 +23701,8 @@ function getProviderManifests() {
|
|
|
23640
23701
|
const baseDir = resolve(dirname3(fileURLToPath2(import.meta.url)), "providers");
|
|
23641
23702
|
for (const providerId of PROVIDER_IDS) {
|
|
23642
23703
|
try {
|
|
23643
|
-
const manifestPath =
|
|
23644
|
-
const raw =
|
|
23704
|
+
const manifestPath = join27(baseDir, providerId, "manifest.json");
|
|
23705
|
+
const raw = readFileSync14(manifestPath, "utf-8");
|
|
23645
23706
|
manifests.push(JSON.parse(raw));
|
|
23646
23707
|
} catch {
|
|
23647
23708
|
}
|