@cleocode/adapters 2026.4.39 → 2026.4.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8,9 +8,174 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
- // packages/adapters/src/providers/claude-code/paths.ts
11
+ // packages/adapters/src/cant-context.ts
12
+ var cant_context_exports = {};
13
+ __export(cant_context_exports, {
14
+ buildCantEnrichedPrompt: () => buildCantEnrichedPrompt,
15
+ buildMemoryBridgeBlock: () => buildMemoryBridgeBlock,
16
+ buildMentalModelInjection: () => buildMentalModelInjection,
17
+ discoverCantFiles: () => discoverCantFiles,
18
+ discoverCantFilesMultiTier: () => discoverCantFilesMultiTier,
19
+ readMemoryBridge: () => readMemoryBridge,
20
+ resolveThreeTierPaths: () => resolveThreeTierPaths
21
+ });
22
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
12
23
  import { homedir } from "node:os";
13
- import { join } from "node:path";
24
+ import { basename, join } from "node:path";
25
+ function discoverCantFiles(dir) {
26
+ try {
27
+ const entries = readdirSync(dir, { recursive: true, withFileTypes: true });
28
+ const files = [];
29
+ for (const entry of entries) {
30
+ if (entry.isFile() && entry.name.endsWith(".cant")) {
31
+ const parent = entry.parentPath ?? dir;
32
+ files.push(join(parent, entry.name));
33
+ }
34
+ }
35
+ return files;
36
+ } catch {
37
+ return [];
38
+ }
39
+ }
40
+ function resolveThreeTierPaths(projectDir) {
41
+ const home = homedir();
42
+ const xdgData = process.env["XDG_DATA_HOME"] ?? join(home, ".local", "share");
43
+ const xdgConfig = process.env["XDG_CONFIG_HOME"] ?? join(home, ".config");
44
+ return {
45
+ global: join(xdgData, "cleo", "cant"),
46
+ user: join(xdgConfig, "cleo", "cant"),
47
+ project: join(projectDir, ".cleo", "cant")
48
+ };
49
+ }
50
+ function discoverCantFilesMultiTier(projectDir) {
51
+ const paths = resolveThreeTierPaths(projectDir);
52
+ const globalFiles = discoverCantFiles(paths.global);
53
+ const userFiles = discoverCantFiles(paths.user);
54
+ const projectFiles = discoverCantFiles(paths.project);
55
+ const fileMap = /* @__PURE__ */ new Map();
56
+ for (const file of globalFiles) {
57
+ fileMap.set(basename(file), file);
58
+ }
59
+ for (const file of userFiles) {
60
+ fileMap.set(basename(file), file);
61
+ }
62
+ for (const file of projectFiles) {
63
+ fileMap.set(basename(file), file);
64
+ }
65
+ const totalUniqueInputs = globalFiles.length + userFiles.length + projectFiles.length;
66
+ const overrides = totalUniqueInputs - fileMap.size;
67
+ return {
68
+ files: Array.from(fileMap.values()),
69
+ stats: {
70
+ global: globalFiles.length,
71
+ user: userFiles.length,
72
+ project: projectFiles.length,
73
+ overrides,
74
+ merged: fileMap.size
75
+ }
76
+ };
77
+ }
78
+ function readMemoryBridge(projectDir) {
79
+ try {
80
+ const bridgePath = join(projectDir, ".cleo", "memory-bridge.md");
81
+ if (!existsSync(bridgePath)) return null;
82
+ const content = readFileSync(bridgePath, "utf-8");
83
+ return content.length > 0 ? content : null;
84
+ } catch {
85
+ return null;
86
+ }
87
+ }
88
+ function buildMemoryBridgeBlock(content) {
89
+ return "\n\n===== CLEO MEMORY BRIDGE =====\nThis is your project memory context from .cleo/memory-bridge.md.\nUse it to understand recent decisions, handoff notes, and key patterns.\n\n" + content.trim() + "\n===== END MEMORY BRIDGE =====";
90
+ }
91
+ function buildMentalModelInjection(agentName, observations) {
92
+ if (observations.length === 0) return "";
93
+ const lines = ["", `// Agent: ${agentName}`, VALIDATE_ON_LOAD_PREAMBLE, ""];
94
+ for (let i = 0; i < observations.length; i++) {
95
+ const obs = observations[i];
96
+ const datePart = obs.date ? ` [${obs.date}]` : "";
97
+ lines.push(`${i + 1}. [${obs.id}] (${obs.type})${datePart}: ${obs.title}`);
98
+ }
99
+ lines.push("===== END MENTAL MODEL =====");
100
+ return lines.join("\n");
101
+ }
102
+ async function fetchMentalModelInjection(agentName, projectRoot) {
103
+ try {
104
+ const coreModule = await import(
105
+ /* webpackIgnore: true */
106
+ "@cleocode/core"
107
+ );
108
+ if (typeof coreModule.memoryFind !== "function") return "";
109
+ const result = await coreModule.memoryFind(
110
+ {
111
+ query: agentName,
112
+ agent: agentName,
113
+ limit: 10,
114
+ tables: ["observations"]
115
+ },
116
+ projectRoot
117
+ );
118
+ if (!result.success || !result.data?.results?.length) return "";
119
+ return buildMentalModelInjection(agentName, result.data.results);
120
+ } catch {
121
+ return "";
122
+ }
123
+ }
124
+ async function buildCantEnrichedPrompt(options) {
125
+ const { projectDir, basePrompt, agentName } = options;
126
+ let appendix = "";
127
+ try {
128
+ const { files } = discoverCantFilesMultiTier(projectDir);
129
+ if (files.length > 0) {
130
+ const cantModule = await import(
131
+ /* webpackIgnore: true */
132
+ "@cleocode/cant"
133
+ );
134
+ if (typeof cantModule.compileBundle === "function") {
135
+ const bundle = await cantModule.compileBundle(files);
136
+ if (bundle.valid) {
137
+ const rendered = bundle.renderSystemPrompt();
138
+ if (rendered) {
139
+ appendix += `
140
+
141
+ ${rendered}`;
142
+ }
143
+ }
144
+ }
145
+ }
146
+ } catch {
147
+ }
148
+ try {
149
+ const bridge = readMemoryBridge(projectDir);
150
+ if (bridge) {
151
+ appendix += buildMemoryBridgeBlock(bridge);
152
+ }
153
+ } catch {
154
+ }
155
+ if (agentName) {
156
+ try {
157
+ const mentalModel = await fetchMentalModelInjection(agentName, projectDir);
158
+ if (mentalModel) {
159
+ appendix += `
160
+
161
+ ${mentalModel}`;
162
+ }
163
+ } catch {
164
+ }
165
+ }
166
+ return appendix ? basePrompt + appendix : basePrompt;
167
+ }
168
+ var VALIDATE_ON_LOAD_PREAMBLE;
169
+ var init_cant_context = __esm({
170
+ "packages/adapters/src/cant-context.ts"() {
171
+ "use strict";
172
+ VALIDATE_ON_LOAD_PREAMBLE = "===== MENTAL MODEL (validate-on-load) =====\nThese are your prior observations, patterns, and learnings for this project.\nBefore acting, you MUST re-evaluate each entry against current project state.\nIf an entry is stale, note it and proceed with fresh understanding.";
173
+ }
174
+ });
175
+
176
+ // packages/adapters/src/providers/claude-code/paths.ts
177
+ import { homedir as homedir2 } from "node:os";
178
+ import { join as join2 } from "node:path";
14
179
  var ClaudeCodePathProvider;
15
180
  var init_paths = __esm({
16
181
  "packages/adapters/src/providers/claude-code/paths.ts"() {
@@ -18,29 +183,29 @@ var init_paths = __esm({
18
183
  ClaudeCodePathProvider = class {
19
184
  /** Get the provider's root configuration directory. */
20
185
  getProviderDir() {
21
- return process.env["CLAUDE_HOME"] ?? join(homedir(), ".claude");
186
+ return process.env["CLAUDE_HOME"] ?? join2(homedir2(), ".claude");
22
187
  }
23
188
  /** Get the path to the provider's settings file, or null if unavailable. */
24
189
  getSettingsPath() {
25
- return process.env["CLAUDE_SETTINGS"] ?? join(this.getProviderDir(), "settings.json");
190
+ return process.env["CLAUDE_SETTINGS"] ?? join2(this.getProviderDir(), "settings.json");
26
191
  }
27
192
  /** Get the directory where agents are installed, or null if unsupported. */
28
193
  getAgentInstallDir() {
29
- return join(this.getProviderDir(), "agents");
194
+ return join2(this.getProviderDir(), "agents");
30
195
  }
31
196
  /** Get the path to the provider's memory database, or null if unsupported. */
32
197
  getMemoryDbPath() {
33
- return process.env["CLAUDE_MEM_DB"] ?? join(homedir(), ".claude-mem", "claude-mem.db");
198
+ return process.env["CLAUDE_MEM_DB"] ?? join2(homedir2(), ".claude-mem", "claude-mem.db");
34
199
  }
35
200
  };
36
201
  }
37
202
  });
38
203
 
39
204
  // packages/adapters/src/providers/claude-code/context-monitor.ts
40
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
205
+ import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync } from "node:fs";
41
206
  import { mkdir } from "node:fs/promises";
42
- import { homedir as homedir2 } from "node:os";
43
- import { dirname, join as join2 } from "node:path";
207
+ import { homedir as homedir3 } from "node:os";
208
+ import { dirname, join as join3 } from "node:path";
44
209
  function getContextStatusFromPercentage(percentage) {
45
210
  if (percentage >= THRESHOLDS.EMERGENCY) return "emergency";
46
211
  if (percentage >= THRESHOLDS.CRITICAL) return "critical";
@@ -74,10 +239,10 @@ var init_context_monitor = __esm({
74
239
  const totalTokens = inputTokens + outputTokens + cacheCreate;
75
240
  const percentage = Math.floor(totalTokens * 100 / contextSize);
76
241
  const status = getContextStatusFromPercentage(percentage);
77
- const cleoDir = cwd ? join2(cwd, ".cleo") : ".cleo";
78
- if (existsSync(cleoDir)) {
79
- const stateDir = join2(cleoDir, "context-states");
80
- const statePath = join2(stateDir, ".context-state.json");
242
+ const cleoDir = cwd ? join3(cwd, ".cleo") : ".cleo";
243
+ if (existsSync2(cleoDir)) {
244
+ const stateDir = join3(cleoDir, "context-states");
245
+ const statePath = join3(stateDir, ".context-state.json");
81
246
  const state = {
82
247
  $schema: "https://cleo-dev.com/schemas/v1/context-state.schema.json",
83
248
  version: "1.0.0",
@@ -114,9 +279,9 @@ var init_context_monitor = __esm({
114
279
  /** Check the current statusline integration status in Claude Code settings. */
115
280
  checkStatuslineIntegration() {
116
281
  const settingsPath = this.pathProvider.getSettingsPath();
117
- if (!settingsPath || !existsSync(settingsPath)) return "no_settings";
282
+ if (!settingsPath || !existsSync2(settingsPath)) return "no_settings";
118
283
  try {
119
- const settings = JSON.parse(readFileSync(settingsPath, "utf-8"));
284
+ const settings = JSON.parse(readFileSync2(settingsPath, "utf-8"));
120
285
  const statusLine = settings.statusLine;
121
286
  if (!statusLine?.type) return "not_configured";
122
287
  if (statusLine.type !== "command") return "custom_no_cleo";
@@ -124,10 +289,10 @@ var init_context_monitor = __esm({
124
289
  if (cmd.includes("context-monitor.sh") || cmd.includes("cleo-statusline") || cmd.includes(".context-state.json") || cmd.includes("context-states")) {
125
290
  return "configured";
126
291
  }
127
- const scriptPath = cmd.startsWith("~") ? cmd.replace("~", homedir2()) : cmd;
128
- if (existsSync(scriptPath)) {
292
+ const scriptPath = cmd.startsWith("~") ? cmd.replace("~", homedir3()) : cmd;
293
+ if (existsSync2(scriptPath)) {
129
294
  try {
130
- const content = readFileSync(scriptPath, "utf-8");
295
+ const content = readFileSync2(scriptPath, "utf-8");
131
296
  if (content.includes("context-state.json")) return "configured";
132
297
  } catch {
133
298
  }
@@ -142,7 +307,7 @@ var init_context_monitor = __esm({
142
307
  return {
143
308
  statusLine: {
144
309
  type: "command",
145
- command: join2(homedir2(), ".cleo", "lib", "session", "context-monitor.sh")
310
+ command: join3(homedir3(), ".cleo", "lib", "session", "context-monitor.sh")
146
311
  }
147
312
  };
148
313
  }
@@ -163,10 +328,10 @@ var init_context_monitor = __esm({
163
328
  });
164
329
 
165
330
  // packages/adapters/src/providers/claude-code/hooks.ts
166
- import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
331
+ import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
167
332
  import { readdir, readFile } from "node:fs/promises";
168
- import { homedir as homedir3 } from "node:os";
169
- import { join as join3 } from "node:path";
333
+ import { homedir as homedir4 } from "node:os";
334
+ import { join as join4 } from "node:path";
170
335
  var PROVIDER_ID, CLAUDE_CODE_EVENT_MAP, ClaudeCodeHookProvider;
171
336
  var init_hooks = __esm({
172
337
  "packages/adapters/src/providers/claude-code/hooks.ts"() {
@@ -243,12 +408,12 @@ var init_hooks = __esm({
243
408
  this.projectDir = projectDir;
244
409
  this.registered = true;
245
410
  try {
246
- const home = homedir3();
247
- const settingsPath = join3(home, ".claude", "settings.json");
411
+ const home = homedir4();
412
+ const settingsPath = join4(home, ".claude", "settings.json");
248
413
  let settings = {};
249
- if (existsSync2(settingsPath)) {
414
+ if (existsSync3(settingsPath)) {
250
415
  try {
251
- settings = JSON.parse(readFileSync2(settingsPath, "utf-8"));
416
+ settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
252
417
  } catch {
253
418
  }
254
419
  }
@@ -284,7 +449,7 @@ var init_hooks = __esm({
284
449
  ]
285
450
  });
286
451
  settings.hooks = hooks;
287
- mkdirSync(join3(home, ".claude"), { recursive: true });
452
+ mkdirSync(join4(home, ".claude"), { recursive: true });
288
453
  writeFileSync2(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
289
454
  } catch {
290
455
  }
@@ -301,10 +466,10 @@ var init_hooks = __esm({
301
466
  this.registered = false;
302
467
  this.projectDir = null;
303
468
  try {
304
- const home = homedir3();
305
- const settingsPath = join3(home, ".claude", "settings.json");
306
- if (!existsSync2(settingsPath)) return;
307
- const settings = JSON.parse(readFileSync2(settingsPath, "utf-8"));
469
+ const home = homedir4();
470
+ const settingsPath = join4(home, ".claude", "settings.json");
471
+ if (!existsSync3(settingsPath)) return;
472
+ const settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
308
473
  const hooks = settings.hooks;
309
474
  if (!hooks) return;
310
475
  let changed = false;
@@ -427,18 +592,18 @@ var init_hooks = __esm({
427
592
  async getTranscript(_sessionId, _projectDir) {
428
593
  try {
429
594
  const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? "/root";
430
- const projectsDir = join3(homeDir, ".claude", "projects");
595
+ const projectsDir = join4(homeDir, ".claude", "projects");
431
596
  let allFiles = [];
432
597
  try {
433
598
  const projectDirs = await readdir(projectsDir, { withFileTypes: true });
434
599
  for (const entry of projectDirs) {
435
600
  if (!entry.isDirectory()) continue;
436
- const subDir = join3(projectsDir, entry.name);
601
+ const subDir = join4(projectsDir, entry.name);
437
602
  try {
438
603
  const files = await readdir(subDir);
439
604
  for (const file of files) {
440
605
  if (!file.endsWith(".jsonl")) continue;
441
- const filePath = join3(subDir, file);
606
+ const filePath = join4(subDir, file);
442
607
  allFiles.push({ path: filePath, mtime: 0 });
443
608
  }
444
609
  } catch {
@@ -479,18 +644,18 @@ var init_hooks = __esm({
479
644
  // packages/adapters/src/providers/claude-code/install.ts
480
645
  import {
481
646
  copyFileSync,
482
- existsSync as existsSync3,
647
+ existsSync as existsSync4,
483
648
  mkdirSync as mkdirSync2,
484
- readdirSync,
485
- readFileSync as readFileSync3,
649
+ readdirSync as readdirSync2,
650
+ readFileSync as readFileSync4,
486
651
  writeFileSync as writeFileSync3
487
652
  } from "node:fs";
488
- import { homedir as homedir4 } from "node:os";
489
- import { dirname as dirname2, join as join4 } from "node:path";
653
+ import { homedir as homedir5 } from "node:os";
654
+ import { dirname as dirname2, join as join5 } from "node:path";
490
655
  import { fileURLToPath } from "node:url";
491
656
  function getAdapterCommandsDir() {
492
657
  const thisDir = dirname2(fileURLToPath(import.meta.url));
493
- return join4(thisDir, "commands");
658
+ return join5(thisDir, "commands");
494
659
  }
495
660
  var INSTRUCTION_REFERENCES, ClaudeCodeInstallProvider;
496
661
  var init_install = __esm({
@@ -511,7 +676,7 @@ var init_install = __esm({
511
676
  const details = {};
512
677
  instructionFileUpdated = this.updateInstructionFile(projectDir);
513
678
  if (instructionFileUpdated) {
514
- details.instructionFile = join4(projectDir, "CLAUDE.md");
679
+ details.instructionFile = join5(projectDir, "CLAUDE.md");
515
680
  }
516
681
  const commandsInstalled = this.installCommands(projectDir);
517
682
  if (commandsInstalled.length > 0) {
@@ -541,10 +706,10 @@ var init_install = __esm({
541
706
  * Checks for plugin enabled in ~/.claude/settings.json.
542
707
  */
543
708
  async isInstalled() {
544
- const settingsPath = join4(homedir4(), ".claude", "settings.json");
545
- if (existsSync3(settingsPath)) {
709
+ const settingsPath = join5(homedir5(), ".claude", "settings.json");
710
+ if (existsSync4(settingsPath)) {
546
711
  try {
547
- const settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
712
+ const settings = JSON.parse(readFileSync4(settingsPath, "utf-8"));
548
713
  const plugins = settings.enabledPlugins;
549
714
  if (plugins && plugins["cleo@cleocode"] === true) {
550
715
  return true;
@@ -570,11 +735,11 @@ var init_install = __esm({
570
735
  * @returns true if the file was created or modified
571
736
  */
572
737
  updateInstructionFile(projectDir) {
573
- const claudeMdPath = join4(projectDir, "CLAUDE.md");
738
+ const claudeMdPath = join5(projectDir, "CLAUDE.md");
574
739
  let content = "";
575
740
  let existed = false;
576
- if (existsSync3(claudeMdPath)) {
577
- content = readFileSync3(claudeMdPath, "utf-8");
741
+ if (existsSync4(claudeMdPath)) {
742
+ content = readFileSync4(claudeMdPath, "utf-8");
578
743
  existed = true;
579
744
  }
580
745
  const missingRefs = INSTRUCTION_REFERENCES.filter((ref) => !content.includes(ref));
@@ -602,16 +767,16 @@ var init_install = __esm({
602
767
  */
603
768
  installCommands(projectDir) {
604
769
  const adapterCommandsDir = getAdapterCommandsDir();
605
- if (!existsSync3(adapterCommandsDir)) {
770
+ if (!existsSync4(adapterCommandsDir)) {
606
771
  return [];
607
772
  }
608
- const targetDir = join4(projectDir, ".claude", "commands");
773
+ const targetDir = join5(projectDir, ".claude", "commands");
609
774
  mkdirSync2(targetDir, { recursive: true });
610
775
  const installed = [];
611
- const files = readdirSync(adapterCommandsDir).filter((f) => f.endsWith(".md"));
776
+ const files = readdirSync2(adapterCommandsDir).filter((f) => f.endsWith(".md"));
612
777
  for (const file of files) {
613
- const src = join4(adapterCommandsDir, file);
614
- const dest = join4(targetDir, file);
778
+ const src = join5(adapterCommandsDir, file);
779
+ const dest = join5(targetDir, file);
615
780
  copyFileSync(src, dest);
616
781
  installed.push(file);
617
782
  }
@@ -623,12 +788,12 @@ var init_install = __esm({
623
788
  * @returns Description of what was registered, or null if no change needed
624
789
  */
625
790
  registerPlugin() {
626
- const home = homedir4();
627
- const settingsPath = join4(home, ".claude", "settings.json");
791
+ const home = homedir5();
792
+ const settingsPath = join5(home, ".claude", "settings.json");
628
793
  let settings = {};
629
- if (existsSync3(settingsPath)) {
794
+ if (existsSync4(settingsPath)) {
630
795
  try {
631
- settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
796
+ settings = JSON.parse(readFileSync4(settingsPath, "utf-8"));
632
797
  } catch {
633
798
  }
634
799
  }
@@ -642,7 +807,7 @@ var init_install = __esm({
642
807
  }
643
808
  enabledPlugins[pluginKey] = true;
644
809
  settings.enabledPlugins = enabledPlugins;
645
- mkdirSync2(join4(home, ".claude"), { recursive: true });
810
+ mkdirSync2(join5(home, ".claude"), { recursive: true });
646
811
  writeFileSync3(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
647
812
  return `Enabled ${pluginKey} in ~/.claude/settings.json`;
648
813
  }
@@ -852,12 +1017,28 @@ var init_spawn = __esm({
852
1017
  const startTime = (/* @__PURE__ */ new Date()).toISOString();
853
1018
  let tmpFile;
854
1019
  try {
1020
+ let enrichedPrompt = context.prompt;
1021
+ try {
1022
+ const { buildCantEnrichedPrompt: buildCantEnrichedPrompt2 } = await Promise.resolve().then(() => (init_cant_context(), cant_context_exports));
1023
+ enrichedPrompt = await buildCantEnrichedPrompt2({
1024
+ projectDir: context.workingDirectory ?? process.cwd(),
1025
+ basePrompt: context.prompt,
1026
+ agentName: context.options?.agentName ?? void 0
1027
+ });
1028
+ } catch {
1029
+ }
855
1030
  tmpFile = `/tmp/claude-spawn-${instanceId}.txt`;
856
- await writeFile(tmpFile, context.prompt, "utf-8");
857
- const args = ["--allow-insecure", "--no-upgrade-check", tmpFile];
1031
+ await writeFile(tmpFile, enrichedPrompt, "utf-8");
1032
+ const args = [
1033
+ "--print",
1034
+ "--dangerously-skip-permissions",
1035
+ "--output-format",
1036
+ "json",
1037
+ tmpFile
1038
+ ];
858
1039
  const spawnOpts = {
859
1040
  detached: true,
860
- stdio: "ignore"
1041
+ stdio: ["ignore", "pipe", "pipe"]
861
1042
  };
862
1043
  if (context.workingDirectory) {
863
1044
  spawnOpts.cwd = context.workingDirectory;
@@ -954,7 +1135,7 @@ var init_spawn = __esm({
954
1135
 
955
1136
  // packages/adapters/src/providers/claude-code/task-sync.ts
956
1137
  import { readFile as readFile2, stat } from "node:fs/promises";
957
- import { join as join5 } from "node:path";
1138
+ import { join as join6 } from "node:path";
958
1139
  function parseTaskId(content) {
959
1140
  const match = content.match(/^\[T(\d+)\]/);
960
1141
  return match ? `T${match[1]}` : null;
@@ -975,7 +1156,7 @@ function mapStatus(twStatus) {
975
1156
  }
976
1157
  }
977
1158
  function getTodoWriteFilePath(projectDir) {
978
- return join5(projectDir, ".cleo", "sync", "todowrite-state.json");
1159
+ return join6(projectDir, ".cleo", "sync", "todowrite-state.json");
979
1160
  }
980
1161
  var ClaudeCodeTaskSyncProvider;
981
1162
  var init_task_sync = __esm({
@@ -1047,9 +1228,9 @@ var init_transport = __esm({
1047
1228
 
1048
1229
  // packages/adapters/src/providers/claude-code/adapter.ts
1049
1230
  import { exec as exec2 } from "node:child_process";
1050
- import { existsSync as existsSync4 } from "node:fs";
1051
- import { homedir as homedir5 } from "node:os";
1052
- import { join as join6 } from "node:path";
1231
+ import { existsSync as existsSync5 } from "node:fs";
1232
+ import { homedir as homedir6 } from "node:os";
1233
+ import { join as join7 } from "node:path";
1053
1234
  import { promisify as promisify2 } from "node:util";
1054
1235
  var execAsync2, ClaudeCodeAdapter;
1055
1236
  var init_adapter = __esm({
@@ -1180,8 +1361,8 @@ var init_adapter = __esm({
1180
1361
  } catch {
1181
1362
  details.cliAvailable = false;
1182
1363
  }
1183
- const claudeConfigDir = join6(homedir5(), ".claude");
1184
- const configExists = existsSync4(claudeConfigDir);
1364
+ const claudeConfigDir = join7(homedir6(), ".claude");
1365
+ const configExists = existsSync5(claudeConfigDir);
1185
1366
  details.configDirExists = configExists;
1186
1367
  const entrypointSet = process.env.CLAUDE_CODE_ENTRYPOINT !== void 0;
1187
1368
  details.entrypointEnvSet = entrypointSet;
@@ -1210,17 +1391,17 @@ var init_adapter = __esm({
1210
1391
  });
1211
1392
 
1212
1393
  // packages/adapters/src/providers/claude-code/statusline.ts
1213
- import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
1214
- import { homedir as homedir6 } from "node:os";
1215
- import { join as join7 } from "node:path";
1394
+ import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
1395
+ import { homedir as homedir7 } from "node:os";
1396
+ import { join as join8 } from "node:path";
1216
1397
  function getClaudeSettingsPath() {
1217
- return process.env["CLAUDE_SETTINGS"] ?? join7(process.env["CLAUDE_HOME"] ?? join7(homedir6(), ".claude"), "settings.json");
1398
+ return process.env["CLAUDE_SETTINGS"] ?? join8(process.env["CLAUDE_HOME"] ?? join8(homedir7(), ".claude"), "settings.json");
1218
1399
  }
1219
1400
  function checkStatuslineIntegration() {
1220
1401
  const settingsPath = getClaudeSettingsPath();
1221
- if (!existsSync5(settingsPath)) return "no_settings";
1402
+ if (!existsSync6(settingsPath)) return "no_settings";
1222
1403
  try {
1223
- const settings = JSON.parse(readFileSync4(settingsPath, "utf-8"));
1404
+ const settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
1224
1405
  const statusLine = settings.statusLine;
1225
1406
  if (!statusLine?.type) return "not_configured";
1226
1407
  if (statusLine.type !== "command") return "custom_no_cleo";
@@ -1228,10 +1409,10 @@ function checkStatuslineIntegration() {
1228
1409
  if (cmd.includes("context-monitor.sh") || cmd.includes("cleo-statusline") || cmd.includes(".context-state.json") || cmd.includes("context-states")) {
1229
1410
  return "configured";
1230
1411
  }
1231
- const scriptPath = cmd.startsWith("~") ? cmd.replace("~", homedir6()) : cmd;
1232
- if (existsSync5(scriptPath)) {
1412
+ const scriptPath = cmd.startsWith("~") ? cmd.replace("~", homedir7()) : cmd;
1413
+ if (existsSync6(scriptPath)) {
1233
1414
  try {
1234
- const content = readFileSync4(scriptPath, "utf-8");
1415
+ const content = readFileSync5(scriptPath, "utf-8");
1235
1416
  if (content.includes("context-state.json")) return "configured";
1236
1417
  } catch {
1237
1418
  }
@@ -1245,7 +1426,7 @@ function getStatuslineConfig(cleoHome) {
1245
1426
  return {
1246
1427
  statusLine: {
1247
1428
  type: "command",
1248
- command: join7(cleoHome, "lib", "session", "context-monitor.sh")
1429
+ command: join8(cleoHome, "lib", "session", "context-monitor.sh")
1249
1430
  }
1250
1431
  };
1251
1432
  }
@@ -1456,8 +1637,8 @@ var init_hooks2 = __esm({
1456
1637
  });
1457
1638
 
1458
1639
  // packages/adapters/src/providers/cursor/install.ts
1459
- import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "node:fs";
1460
- import { join as join12 } from "node:path";
1640
+ import { existsSync as existsSync9, mkdirSync as mkdirSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "node:fs";
1641
+ import { join as join13 } from "node:path";
1461
1642
  var INSTRUCTION_REFERENCES3, CursorInstallProvider;
1462
1643
  var init_install2 = __esm({
1463
1644
  "packages/adapters/src/providers/cursor/install.ts"() {
@@ -1499,14 +1680,14 @@ var init_install2 = __esm({
1499
1680
  * Checks for .cursor/rules/cleo.mdc or .cursorrules with CLEO references.
1500
1681
  */
1501
1682
  async isInstalled() {
1502
- const mdcPath = join12(process.cwd(), ".cursor", "rules", "cleo.mdc");
1503
- if (existsSync8(mdcPath)) {
1683
+ const mdcPath = join13(process.cwd(), ".cursor", "rules", "cleo.mdc");
1684
+ if (existsSync9(mdcPath)) {
1504
1685
  return true;
1505
1686
  }
1506
- const rulesPath = join12(process.cwd(), ".cursorrules");
1507
- if (existsSync8(rulesPath)) {
1687
+ const rulesPath = join13(process.cwd(), ".cursorrules");
1688
+ if (existsSync9(rulesPath)) {
1508
1689
  try {
1509
- const content = readFileSync6(rulesPath, "utf-8");
1690
+ const content = readFileSync7(rulesPath, "utf-8");
1510
1691
  if (INSTRUCTION_REFERENCES3.some((ref) => content.includes(ref))) {
1511
1692
  return true;
1512
1693
  }
@@ -1549,11 +1730,11 @@ var init_install2 = __esm({
1549
1730
  * @returns true if the file was modified
1550
1731
  */
1551
1732
  updateLegacyRules(projectDir) {
1552
- const rulesPath = join12(projectDir, ".cursorrules");
1553
- if (!existsSync8(rulesPath)) {
1733
+ const rulesPath = join13(projectDir, ".cursorrules");
1734
+ if (!existsSync9(rulesPath)) {
1554
1735
  return false;
1555
1736
  }
1556
- let content = readFileSync6(rulesPath, "utf-8");
1737
+ let content = readFileSync7(rulesPath, "utf-8");
1557
1738
  const missingRefs = INSTRUCTION_REFERENCES3.filter((ref) => !content.includes(ref));
1558
1739
  if (missingRefs.length === 0) {
1559
1740
  return false;
@@ -1572,8 +1753,8 @@ var init_install2 = __esm({
1572
1753
  * @returns true if the file was created or modified
1573
1754
  */
1574
1755
  updateModernRules(projectDir) {
1575
- const rulesDir = join12(projectDir, ".cursor", "rules");
1576
- const mdcPath = join12(rulesDir, "cleo.mdc");
1756
+ const rulesDir = join13(projectDir, ".cursor", "rules");
1757
+ const mdcPath = join13(rulesDir, "cleo.mdc");
1577
1758
  const expectedContent = [
1578
1759
  "---",
1579
1760
  "description: CLEO task management protocol references",
@@ -1584,8 +1765,8 @@ var init_install2 = __esm({
1584
1765
  ...INSTRUCTION_REFERENCES3,
1585
1766
  ""
1586
1767
  ].join("\n");
1587
- if (existsSync8(mdcPath)) {
1588
- const existing = readFileSync6(mdcPath, "utf-8");
1768
+ if (existsSync9(mdcPath)) {
1769
+ const existing = readFileSync7(mdcPath, "utf-8");
1589
1770
  if (existing === expectedContent) {
1590
1771
  return false;
1591
1772
  }
@@ -1599,10 +1780,10 @@ var init_install2 = __esm({
1599
1780
  */
1600
1781
  getUpdatedFileList(projectDir) {
1601
1782
  const files = [];
1602
- if (existsSync8(join12(projectDir, ".cursorrules"))) {
1603
- files.push(join12(projectDir, ".cursorrules"));
1783
+ if (existsSync9(join13(projectDir, ".cursorrules"))) {
1784
+ files.push(join13(projectDir, ".cursorrules"));
1604
1785
  }
1605
- files.push(join12(projectDir, ".cursor", "rules", "cleo.mdc"));
1786
+ files.push(join13(projectDir, ".cursor", "rules", "cleo.mdc"));
1606
1787
  return files;
1607
1788
  }
1608
1789
  };
@@ -1610,8 +1791,8 @@ var init_install2 = __esm({
1610
1791
  });
1611
1792
 
1612
1793
  // packages/adapters/src/providers/cursor/adapter.ts
1613
- import { existsSync as existsSync9 } from "node:fs";
1614
- import { join as join13 } from "node:path";
1794
+ import { existsSync as existsSync10 } from "node:fs";
1795
+ import { join as join14 } from "node:path";
1615
1796
  var CursorAdapter;
1616
1797
  var init_adapter2 = __esm({
1617
1798
  "packages/adapters/src/providers/cursor/adapter.ts"() {
@@ -1705,14 +1886,14 @@ var init_adapter2 = __esm({
1705
1886
  }
1706
1887
  let configExists = false;
1707
1888
  if (this.projectDir) {
1708
- const cursorConfigDir = join13(this.projectDir, ".cursor");
1709
- configExists = existsSync9(cursorConfigDir);
1889
+ const cursorConfigDir = join14(this.projectDir, ".cursor");
1890
+ configExists = existsSync10(cursorConfigDir);
1710
1891
  details.configDirExists = configExists;
1711
1892
  }
1712
1893
  const editorEnvSet = process.env.CURSOR_EDITOR !== void 0;
1713
1894
  details.editorEnvSet = editorEnvSet;
1714
1895
  if (this.projectDir) {
1715
- const legacyRulesExist = existsSync9(join13(this.projectDir, ".cursorrules"));
1896
+ const legacyRulesExist = existsSync10(join14(this.projectDir, ".cursorrules"));
1716
1897
  details.legacyRulesExist = legacyRulesExist;
1717
1898
  }
1718
1899
  const healthy = configExists || editorEnvSet;
@@ -1916,8 +2097,8 @@ var init_hooks3 = __esm({
1916
2097
  });
1917
2098
 
1918
2099
  // packages/adapters/src/providers/opencode/install.ts
1919
- import { existsSync as existsSync14, readFileSync as readFileSync9, writeFileSync as writeFileSync8 } from "node:fs";
1920
- import { join as join19 } from "node:path";
2100
+ import { existsSync as existsSync15, readFileSync as readFileSync10, writeFileSync as writeFileSync8 } from "node:fs";
2101
+ import { join as join20 } from "node:path";
1921
2102
  var INSTRUCTION_REFERENCES6, OpenCodeInstallProvider;
1922
2103
  var init_install3 = __esm({
1923
2104
  "packages/adapters/src/providers/opencode/install.ts"() {
@@ -1937,7 +2118,7 @@ var init_install3 = __esm({
1937
2118
  const details = {};
1938
2119
  instructionFileUpdated = this.updateInstructionFile(projectDir);
1939
2120
  if (instructionFileUpdated) {
1940
- details.instructionFile = join19(projectDir, "AGENTS.md");
2121
+ details.instructionFile = join20(projectDir, "AGENTS.md");
1941
2122
  }
1942
2123
  return {
1943
2124
  success: true,
@@ -1959,10 +2140,10 @@ var init_install3 = __esm({
1959
2140
  * Checks for CLEO references in AGENTS.md.
1960
2141
  */
1961
2142
  async isInstalled() {
1962
- const agentsMdPath = join19(process.cwd(), "AGENTS.md");
1963
- if (existsSync14(agentsMdPath)) {
2143
+ const agentsMdPath = join20(process.cwd(), "AGENTS.md");
2144
+ if (existsSync15(agentsMdPath)) {
1964
2145
  try {
1965
- const content = readFileSync9(agentsMdPath, "utf-8");
2146
+ const content = readFileSync10(agentsMdPath, "utf-8");
1966
2147
  if (INSTRUCTION_REFERENCES6.some((ref) => content.includes(ref))) {
1967
2148
  return true;
1968
2149
  }
@@ -1987,11 +2168,11 @@ var init_install3 = __esm({
1987
2168
  * @returns true if the file was created or modified
1988
2169
  */
1989
2170
  updateInstructionFile(projectDir) {
1990
- const agentsMdPath = join19(projectDir, "AGENTS.md");
2171
+ const agentsMdPath = join20(projectDir, "AGENTS.md");
1991
2172
  let content = "";
1992
2173
  let existed = false;
1993
- if (existsSync14(agentsMdPath)) {
1994
- content = readFileSync9(agentsMdPath, "utf-8");
2174
+ if (existsSync15(agentsMdPath)) {
2175
+ content = readFileSync10(agentsMdPath, "utf-8");
1995
2176
  existed = true;
1996
2177
  }
1997
2178
  const missingRefs = INSTRUCTION_REFERENCES6.filter((ref) => !content.includes(ref));
@@ -2015,7 +2196,7 @@ var init_install3 = __esm({
2015
2196
  // packages/adapters/src/providers/opencode/spawn.ts
2016
2197
  import { exec as exec6, spawn as nodeSpawn2 } from "node:child_process";
2017
2198
  import { mkdir as mkdir2, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
2018
- import { join as join20 } from "node:path";
2199
+ import { join as join21 } from "node:path";
2019
2200
  import { promisify as promisify6 } from "node:util";
2020
2201
  function buildOpenCodeAgentMarkdown(description, instructions) {
2021
2202
  const normalizedDesc = description.replace(/\s+/g, " ").trim();
@@ -2030,11 +2211,11 @@ function buildOpenCodeAgentMarkdown(description, instructions) {
2030
2211
  ""
2031
2212
  ].join("\n");
2032
2213
  }
2033
- async function ensureSubagentDefinition(workingDirectory) {
2034
- const agentDir = join20(workingDirectory, ".opencode", "agent");
2035
- const agentPath = join20(agentDir, `${OPENCODE_SUBAGENT_NAME}.md`);
2036
- const description = "CLEO task executor with protocol compliance.";
2037
- const instructions = [
2214
+ async function ensureSubagentDefinition(workingDirectory, enrichedInstructions) {
2215
+ const agentDir = join21(workingDirectory, ".opencode", "agent");
2216
+ const agentPath = join21(agentDir, `${OPENCODE_SUBAGENT_NAME}.md`);
2217
+ const description = "CLEO task executor with protocol compliance and CANT context.";
2218
+ const instructions = enrichedInstructions ?? [
2038
2219
  "# CLEO Subagent",
2039
2220
  "",
2040
2221
  "You are a CLEO subagent executing a delegated task.",
@@ -2093,9 +2274,19 @@ var init_spawn2 = __esm({
2093
2274
  const startTime = (/* @__PURE__ */ new Date()).toISOString();
2094
2275
  const workingDirectory = context.workingDirectory ?? process.cwd();
2095
2276
  try {
2277
+ let enrichedInstructions;
2278
+ try {
2279
+ const { buildCantEnrichedPrompt: buildCantEnrichedPrompt2 } = await Promise.resolve().then(() => (init_cant_context(), cant_context_exports));
2280
+ enrichedInstructions = await buildCantEnrichedPrompt2({
2281
+ projectDir: workingDirectory,
2282
+ basePrompt: context.prompt,
2283
+ agentName: context.options?.agentName ?? void 0
2284
+ });
2285
+ } catch {
2286
+ }
2096
2287
  let agentName;
2097
2288
  try {
2098
- agentName = await ensureSubagentDefinition(workingDirectory);
2289
+ agentName = await ensureSubagentDefinition(workingDirectory, enrichedInstructions);
2099
2290
  } catch {
2100
2291
  agentName = OPENCODE_FALLBACK_AGENT;
2101
2292
  }
@@ -2195,8 +2386,8 @@ var init_spawn2 = __esm({
2195
2386
 
2196
2387
  // packages/adapters/src/providers/opencode/adapter.ts
2197
2388
  import { exec as exec7 } from "node:child_process";
2198
- import { existsSync as existsSync15 } from "node:fs";
2199
- import { join as join21 } from "node:path";
2389
+ import { existsSync as existsSync16 } from "node:fs";
2390
+ import { join as join22 } from "node:path";
2200
2391
  import { promisify as promisify7 } from "node:util";
2201
2392
  var execAsync7, OpenCodeAdapter;
2202
2393
  var init_adapter3 = __esm({
@@ -2308,8 +2499,8 @@ var init_adapter3 = __esm({
2308
2499
  details.cliAvailable = false;
2309
2500
  }
2310
2501
  if (this.projectDir) {
2311
- const openCodeConfigDir = join21(this.projectDir, ".opencode");
2312
- const configExists = existsSync15(openCodeConfigDir);
2502
+ const openCodeConfigDir = join22(this.projectDir, ".opencode");
2503
+ const configExists = existsSync16(openCodeConfigDir);
2313
2504
  details.configDirExists = configExists;
2314
2505
  }
2315
2506
  const versionEnvSet = process.env.OPENCODE_VERSION !== void 0;
@@ -2518,21 +2709,21 @@ var init_hooks4 = __esm({
2518
2709
  });
2519
2710
 
2520
2711
  // packages/adapters/src/providers/pi/install.ts
2521
- import { existsSync as existsSync16, mkdirSync as mkdirSync4, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "node:fs";
2522
- import { homedir as homedir12 } from "node:os";
2523
- import { join as join22 } from "node:path";
2712
+ import { existsSync as existsSync17, mkdirSync as mkdirSync4, readFileSync as readFileSync11, writeFileSync as writeFileSync9 } from "node:fs";
2713
+ import { homedir as homedir13 } from "node:os";
2714
+ import { join as join23 } from "node:path";
2524
2715
  function getPiAgentDir() {
2525
2716
  const env = process.env["PI_CODING_AGENT_DIR"];
2526
2717
  if (env !== void 0 && env.length > 0) {
2527
- if (env === "~") return homedir12();
2528
- if (env.startsWith("~/")) return join22(homedir12(), env.slice(2));
2718
+ if (env === "~") return homedir13();
2719
+ if (env.startsWith("~/")) return join23(homedir13(), env.slice(2));
2529
2720
  return env;
2530
2721
  }
2531
2722
  const piHome = process.env["PI_HOME"];
2532
2723
  if (piHome !== void 0 && piHome.length > 0) {
2533
- return join22(piHome, "agent");
2724
+ return join23(piHome, "agent");
2534
2725
  }
2535
- return join22(homedir12(), ".pi", "agent");
2726
+ return join23(homedir13(), ".pi", "agent");
2536
2727
  }
2537
2728
  var INSTRUCTION_REFERENCES7, PiInstallProvider;
2538
2729
  var init_install4 = __esm({
@@ -2552,14 +2743,14 @@ var init_install4 = __esm({
2552
2743
  const details = {};
2553
2744
  const projectUpdated = this.updateInstructionFile(projectDir, "AGENTS.md");
2554
2745
  if (projectUpdated) {
2555
- details.instructionFile = join22(projectDir, "AGENTS.md");
2746
+ details.instructionFile = join23(projectDir, "AGENTS.md");
2556
2747
  }
2557
2748
  let globalUpdated = false;
2558
2749
  try {
2559
2750
  const globalDir = getPiAgentDir();
2560
2751
  globalUpdated = this.updateInstructionFile(globalDir, "AGENTS.md");
2561
2752
  if (globalUpdated) {
2562
- details.globalInstructionFile = join22(globalDir, "AGENTS.md");
2753
+ details.globalInstructionFile = join23(globalDir, "AGENTS.md");
2563
2754
  }
2564
2755
  } catch {
2565
2756
  }
@@ -2584,10 +2775,10 @@ var init_install4 = __esm({
2584
2775
  * Checks for CLEO references in the project AGENTS.md.
2585
2776
  */
2586
2777
  async isInstalled() {
2587
- const agentsMdPath = join22(process.cwd(), "AGENTS.md");
2588
- if (existsSync16(agentsMdPath)) {
2778
+ const agentsMdPath = join23(process.cwd(), "AGENTS.md");
2779
+ if (existsSync17(agentsMdPath)) {
2589
2780
  try {
2590
- const content = readFileSync10(agentsMdPath, "utf-8");
2781
+ const content = readFileSync11(agentsMdPath, "utf-8");
2591
2782
  if (INSTRUCTION_REFERENCES7.some((ref) => content.includes(ref))) {
2592
2783
  return true;
2593
2784
  }
@@ -2595,9 +2786,9 @@ var init_install4 = __esm({
2595
2786
  }
2596
2787
  }
2597
2788
  try {
2598
- const globalPath = join22(getPiAgentDir(), "AGENTS.md");
2599
- if (existsSync16(globalPath)) {
2600
- const content = readFileSync10(globalPath, "utf-8");
2789
+ const globalPath = join23(getPiAgentDir(), "AGENTS.md");
2790
+ if (existsSync17(globalPath)) {
2791
+ const content = readFileSync11(globalPath, "utf-8");
2601
2792
  if (INSTRUCTION_REFERENCES7.some((ref) => content.includes(ref))) {
2602
2793
  return true;
2603
2794
  }
@@ -2624,11 +2815,11 @@ var init_install4 = __esm({
2624
2815
  * @returns true if the file was created or modified
2625
2816
  */
2626
2817
  updateInstructionFile(dir, filename) {
2627
- const filePath = join22(dir, filename);
2818
+ const filePath = join23(dir, filename);
2628
2819
  let content = "";
2629
2820
  let existed = false;
2630
- if (existsSync16(filePath)) {
2631
- content = readFileSync10(filePath, "utf-8");
2821
+ if (existsSync17(filePath)) {
2822
+ content = readFileSync11(filePath, "utf-8");
2632
2823
  existed = true;
2633
2824
  }
2634
2825
  const missingRefs = INSTRUCTION_REFERENCES7.filter((ref) => !content.includes(ref));
@@ -2803,22 +2994,22 @@ var init_spawn3 = __esm({
2803
2994
 
2804
2995
  // packages/adapters/src/providers/pi/adapter.ts
2805
2996
  import { exec as exec9 } from "node:child_process";
2806
- import { existsSync as existsSync17 } from "node:fs";
2807
- import { homedir as homedir13 } from "node:os";
2808
- import { join as join23 } from "node:path";
2997
+ import { existsSync as existsSync18 } from "node:fs";
2998
+ import { homedir as homedir14 } from "node:os";
2999
+ import { join as join24 } from "node:path";
2809
3000
  import { promisify as promisify9 } from "node:util";
2810
3001
  function getPiAgentDir2() {
2811
3002
  const env = process.env["PI_CODING_AGENT_DIR"];
2812
3003
  if (env !== void 0 && env.length > 0) {
2813
- if (env === "~") return homedir13();
2814
- if (env.startsWith("~/")) return join23(homedir13(), env.slice(2));
3004
+ if (env === "~") return homedir14();
3005
+ if (env.startsWith("~/")) return join24(homedir14(), env.slice(2));
2815
3006
  return env;
2816
3007
  }
2817
3008
  const piHome = process.env["PI_HOME"];
2818
3009
  if (piHome !== void 0 && piHome.length > 0) {
2819
- return join23(piHome, "agent");
3010
+ return join24(piHome, "agent");
2820
3011
  }
2821
- return join23(homedir13(), ".pi", "agent");
3012
+ return join24(homedir14(), ".pi", "agent");
2822
3013
  }
2823
3014
  var execAsync9, PiAdapter;
2824
3015
  var init_adapter4 = __esm({
@@ -2936,12 +3127,12 @@ var init_adapter4 = __esm({
2936
3127
  details.cliAvailable = false;
2937
3128
  }
2938
3129
  const agentDir = getPiAgentDir2();
2939
- const agentDirExists = existsSync17(agentDir);
3130
+ const agentDirExists = existsSync18(agentDir);
2940
3131
  details.agentDirExists = agentDirExists;
2941
3132
  details.agentDir = agentDir;
2942
3133
  if (this.projectDir) {
2943
- const projectPiDir = join23(this.projectDir, ".pi");
2944
- details.projectPiDirExists = existsSync17(projectPiDir);
3134
+ const projectPiDir = join24(this.projectDir, ".pi");
3135
+ details.projectPiDirExists = existsSync18(projectPiDir);
2945
3136
  }
2946
3137
  details.piCodingAgentDirSet = process.env["PI_CODING_AGENT_DIR"] !== void 0;
2947
3138
  details.piHomeSet = process.env["PI_HOME"] !== void 0;
@@ -2997,22 +3188,23 @@ var init_pi = __esm({
2997
3188
  });
2998
3189
 
2999
3190
  // packages/adapters/src/index.ts
3191
+ init_cant_context();
3000
3192
  init_claude_code();
3001
3193
 
3002
3194
  // packages/adapters/src/providers/codex/adapter.ts
3003
3195
  import { exec as exec3 } from "node:child_process";
3004
- import { existsSync as existsSync7 } from "node:fs";
3005
- import { homedir as homedir8 } from "node:os";
3006
- import { join as join11 } from "node:path";
3196
+ import { existsSync as existsSync8 } from "node:fs";
3197
+ import { homedir as homedir9 } from "node:os";
3198
+ import { join as join12 } from "node:path";
3007
3199
  import { promisify as promisify3 } from "node:util";
3008
3200
 
3009
3201
  // packages/adapters/src/providers/codex/hooks.ts
3010
- import { homedir as homedir7 } from "node:os";
3011
- import { join as join9 } from "node:path";
3202
+ import { homedir as homedir8 } from "node:os";
3203
+ import { join as join10 } from "node:path";
3012
3204
 
3013
3205
  // packages/adapters/src/providers/shared/transcript-reader.ts
3014
3206
  import { readdir as readdir2, readFile as readFile3 } from "node:fs/promises";
3015
- import { join as join8 } from "node:path";
3207
+ import { join as join9 } from "node:path";
3016
3208
  function parseTranscriptLines(raw) {
3017
3209
  const turns = [];
3018
3210
  const lines = raw.split("\n").filter((l) => l.trim());
@@ -3037,7 +3229,7 @@ async function readLatestTranscript(providerDir) {
3037
3229
  if (!entry.isFile()) continue;
3038
3230
  const name = entry.name;
3039
3231
  if (name.endsWith(".json") || name.endsWith(".jsonl")) {
3040
- allFiles.push(join8(providerDir, name));
3232
+ allFiles.push(join9(providerDir, name));
3041
3233
  }
3042
3234
  }
3043
3235
  } catch {
@@ -3127,13 +3319,13 @@ var CodexHookProvider = class {
3127
3319
  * @task T162 @epic T134
3128
3320
  */
3129
3321
  async getTranscript(_sessionId, _projectDir) {
3130
- return readLatestTranscript(join9(homedir7(), ".codex"));
3322
+ return readLatestTranscript(join10(homedir8(), ".codex"));
3131
3323
  }
3132
3324
  };
3133
3325
 
3134
3326
  // packages/adapters/src/providers/codex/install.ts
3135
- import { existsSync as existsSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
3136
- import { join as join10 } from "node:path";
3327
+ import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "node:fs";
3328
+ import { join as join11 } from "node:path";
3137
3329
  var INSTRUCTION_REFERENCES2 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
3138
3330
  var CodexInstallProvider = class {
3139
3331
  /**
@@ -3150,7 +3342,7 @@ var CodexInstallProvider = class {
3150
3342
  const details = {};
3151
3343
  instructionFileUpdated = this.updateInstructionFile(projectDir);
3152
3344
  if (instructionFileUpdated) {
3153
- details.instructionFile = join10(projectDir, "AGENTS.md");
3345
+ details.instructionFile = join11(projectDir, "AGENTS.md");
3154
3346
  }
3155
3347
  return {
3156
3348
  success: true,
@@ -3174,10 +3366,10 @@ var CodexInstallProvider = class {
3174
3366
  * @task T162
3175
3367
  */
3176
3368
  async isInstalled() {
3177
- const agentsMdPath = join10(process.cwd(), "AGENTS.md");
3178
- if (existsSync6(agentsMdPath)) {
3369
+ const agentsMdPath = join11(process.cwd(), "AGENTS.md");
3370
+ if (existsSync7(agentsMdPath)) {
3179
3371
  try {
3180
- const content = readFileSync5(agentsMdPath, "utf-8");
3372
+ const content = readFileSync6(agentsMdPath, "utf-8");
3181
3373
  if (INSTRUCTION_REFERENCES2.some((ref) => content.includes(ref))) {
3182
3374
  return true;
3183
3375
  }
@@ -3204,11 +3396,11 @@ var CodexInstallProvider = class {
3204
3396
  * @returns true if the file was created or modified
3205
3397
  */
3206
3398
  updateInstructionFile(projectDir) {
3207
- const agentsMdPath = join10(projectDir, "AGENTS.md");
3399
+ const agentsMdPath = join11(projectDir, "AGENTS.md");
3208
3400
  let content = "";
3209
3401
  let existed = false;
3210
- if (existsSync6(agentsMdPath)) {
3211
- content = readFileSync5(agentsMdPath, "utf-8");
3402
+ if (existsSync7(agentsMdPath)) {
3403
+ content = readFileSync6(agentsMdPath, "utf-8");
3212
3404
  existed = true;
3213
3405
  }
3214
3406
  const missingRefs = INSTRUCTION_REFERENCES2.filter((ref) => !content.includes(ref));
@@ -3312,8 +3504,8 @@ var CodexAdapter = class {
3312
3504
  } catch {
3313
3505
  details.cliAvailable = false;
3314
3506
  }
3315
- const codexConfigDir = join11(homedir8(), ".codex");
3316
- const configExists = existsSync7(codexConfigDir);
3507
+ const codexConfigDir = join12(homedir9(), ".codex");
3508
+ const configExists = existsSync8(codexConfigDir);
3317
3509
  details.configDirExists = configExists;
3318
3510
  const healthy = cliAvailable;
3319
3511
  details.cliAvailable = cliAvailable;
@@ -3349,14 +3541,14 @@ init_cursor();
3349
3541
 
3350
3542
  // packages/adapters/src/providers/gemini-cli/adapter.ts
3351
3543
  import { exec as exec4 } from "node:child_process";
3352
- import { existsSync as existsSync11 } from "node:fs";
3353
- import { homedir as homedir10 } from "node:os";
3354
- import { join as join16 } from "node:path";
3544
+ import { existsSync as existsSync12 } from "node:fs";
3545
+ import { homedir as homedir11 } from "node:os";
3546
+ import { join as join17 } from "node:path";
3355
3547
  import { promisify as promisify4 } from "node:util";
3356
3548
 
3357
3549
  // packages/adapters/src/providers/gemini-cli/hooks.ts
3358
- import { homedir as homedir9 } from "node:os";
3359
- import { join as join14 } from "node:path";
3550
+ import { homedir as homedir10 } from "node:os";
3551
+ import { join as join15 } from "node:path";
3360
3552
  var GEMINI_CLI_EVENT_MAP = {
3361
3553
  SessionStart: "SessionStart",
3362
3554
  SessionEnd: "SessionEnd",
@@ -3434,13 +3626,13 @@ var GeminiCliHookProvider = class {
3434
3626
  * @task T161 @epic T134
3435
3627
  */
3436
3628
  async getTranscript(_sessionId, _projectDir) {
3437
- return readLatestTranscript(join14(homedir9(), ".gemini"));
3629
+ return readLatestTranscript(join15(homedir10(), ".gemini"));
3438
3630
  }
3439
3631
  };
3440
3632
 
3441
3633
  // packages/adapters/src/providers/gemini-cli/install.ts
3442
- import { existsSync as existsSync10, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "node:fs";
3443
- import { join as join15 } from "node:path";
3634
+ import { existsSync as existsSync11, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "node:fs";
3635
+ import { join as join16 } from "node:path";
3444
3636
  var INSTRUCTION_REFERENCES4 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
3445
3637
  var GeminiCliInstallProvider = class {
3446
3638
  /**
@@ -3457,7 +3649,7 @@ var GeminiCliInstallProvider = class {
3457
3649
  const details = {};
3458
3650
  instructionFileUpdated = this.updateInstructionFile(projectDir);
3459
3651
  if (instructionFileUpdated) {
3460
- details.instructionFile = join15(projectDir, "AGENTS.md");
3652
+ details.instructionFile = join16(projectDir, "AGENTS.md");
3461
3653
  }
3462
3654
  return {
3463
3655
  success: true,
@@ -3481,10 +3673,10 @@ var GeminiCliInstallProvider = class {
3481
3673
  * @task T161
3482
3674
  */
3483
3675
  async isInstalled() {
3484
- const agentsMdPath = join15(process.cwd(), "AGENTS.md");
3485
- if (existsSync10(agentsMdPath)) {
3676
+ const agentsMdPath = join16(process.cwd(), "AGENTS.md");
3677
+ if (existsSync11(agentsMdPath)) {
3486
3678
  try {
3487
- const content = readFileSync7(agentsMdPath, "utf-8");
3679
+ const content = readFileSync8(agentsMdPath, "utf-8");
3488
3680
  if (INSTRUCTION_REFERENCES4.some((ref) => content.includes(ref))) {
3489
3681
  return true;
3490
3682
  }
@@ -3511,11 +3703,11 @@ var GeminiCliInstallProvider = class {
3511
3703
  * @returns true if the file was created or modified
3512
3704
  */
3513
3705
  updateInstructionFile(projectDir) {
3514
- const agentsMdPath = join15(projectDir, "AGENTS.md");
3706
+ const agentsMdPath = join16(projectDir, "AGENTS.md");
3515
3707
  let content = "";
3516
3708
  let existed = false;
3517
- if (existsSync10(agentsMdPath)) {
3518
- content = readFileSync7(agentsMdPath, "utf-8");
3709
+ if (existsSync11(agentsMdPath)) {
3710
+ content = readFileSync8(agentsMdPath, "utf-8");
3519
3711
  existed = true;
3520
3712
  }
3521
3713
  const missingRefs = INSTRUCTION_REFERENCES4.filter((ref) => !content.includes(ref));
@@ -3630,8 +3822,8 @@ var GeminiCliAdapter = class {
3630
3822
  } catch {
3631
3823
  details.cliAvailable = false;
3632
3824
  }
3633
- const geminiConfigDir = join16(homedir10(), ".gemini");
3634
- const configExists = existsSync11(geminiConfigDir);
3825
+ const geminiConfigDir = join17(homedir11(), ".gemini");
3826
+ const configExists = existsSync12(geminiConfigDir);
3635
3827
  details.configDirExists = configExists;
3636
3828
  const healthy = cliAvailable;
3637
3829
  details.cliAvailable = cliAvailable;
@@ -3664,9 +3856,9 @@ function createAdapter4() {
3664
3856
 
3665
3857
  // packages/adapters/src/providers/kimi/adapter.ts
3666
3858
  import { exec as exec5 } from "node:child_process";
3667
- import { existsSync as existsSync13 } from "node:fs";
3668
- import { homedir as homedir11 } from "node:os";
3669
- import { join as join18 } from "node:path";
3859
+ import { existsSync as existsSync14 } from "node:fs";
3860
+ import { homedir as homedir12 } from "node:os";
3861
+ import { join as join19 } from "node:path";
3670
3862
  import { promisify as promisify5 } from "node:util";
3671
3863
 
3672
3864
  // packages/adapters/src/providers/kimi/hooks.ts
@@ -3725,8 +3917,8 @@ var KimiHookProvider = class {
3725
3917
  };
3726
3918
 
3727
3919
  // packages/adapters/src/providers/kimi/install.ts
3728
- import { existsSync as existsSync12, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "node:fs";
3729
- import { join as join17 } from "node:path";
3920
+ import { existsSync as existsSync13, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "node:fs";
3921
+ import { join as join18 } from "node:path";
3730
3922
  var INSTRUCTION_REFERENCES5 = ["@~/.cleo/templates/CLEO-INJECTION.md", "@.cleo/memory-bridge.md"];
3731
3923
  var KimiInstallProvider = class {
3732
3924
  /**
@@ -3743,7 +3935,7 @@ var KimiInstallProvider = class {
3743
3935
  const details = {};
3744
3936
  instructionFileUpdated = this.updateInstructionFile(projectDir);
3745
3937
  if (instructionFileUpdated) {
3746
- details.instructionFile = join17(projectDir, "AGENTS.md");
3938
+ details.instructionFile = join18(projectDir, "AGENTS.md");
3747
3939
  }
3748
3940
  return {
3749
3941
  success: true,
@@ -3767,10 +3959,10 @@ var KimiInstallProvider = class {
3767
3959
  * @task T163
3768
3960
  */
3769
3961
  async isInstalled() {
3770
- const agentsMdPath = join17(process.cwd(), "AGENTS.md");
3771
- if (existsSync12(agentsMdPath)) {
3962
+ const agentsMdPath = join18(process.cwd(), "AGENTS.md");
3963
+ if (existsSync13(agentsMdPath)) {
3772
3964
  try {
3773
- const content = readFileSync8(agentsMdPath, "utf-8");
3965
+ const content = readFileSync9(agentsMdPath, "utf-8");
3774
3966
  if (INSTRUCTION_REFERENCES5.some((ref) => content.includes(ref))) {
3775
3967
  return true;
3776
3968
  }
@@ -3797,11 +3989,11 @@ var KimiInstallProvider = class {
3797
3989
  * @returns true if the file was created or modified
3798
3990
  */
3799
3991
  updateInstructionFile(projectDir) {
3800
- const agentsMdPath = join17(projectDir, "AGENTS.md");
3992
+ const agentsMdPath = join18(projectDir, "AGENTS.md");
3801
3993
  let content = "";
3802
3994
  let existed = false;
3803
- if (existsSync12(agentsMdPath)) {
3804
- content = readFileSync8(agentsMdPath, "utf-8");
3995
+ if (existsSync13(agentsMdPath)) {
3996
+ content = readFileSync9(agentsMdPath, "utf-8");
3805
3997
  existed = true;
3806
3998
  }
3807
3999
  const missingRefs = INSTRUCTION_REFERENCES5.filter((ref) => !content.includes(ref));
@@ -3903,8 +4095,8 @@ var KimiAdapter = class {
3903
4095
  } catch {
3904
4096
  details.cliAvailable = false;
3905
4097
  }
3906
- const kimiConfigDir = join18(homedir11(), ".kimi");
3907
- const configExists = existsSync13(kimiConfigDir);
4098
+ const kimiConfigDir = join19(homedir12(), ".kimi");
4099
+ const configExists = existsSync14(kimiConfigDir);
3908
4100
  details.configDirExists = configExists;
3909
4101
  const healthy = cliAvailable;
3910
4102
  details.cliAvailable = cliAvailable;
@@ -3939,8 +4131,8 @@ function createAdapter5() {
3939
4131
  init_opencode();
3940
4132
 
3941
4133
  // packages/adapters/src/registry.ts
3942
- import { readFileSync as readFileSync11 } from "node:fs";
3943
- import { dirname as dirname3, join as join24, resolve } from "node:path";
4134
+ import { readFileSync as readFileSync12 } from "node:fs";
4135
+ import { dirname as dirname3, join as join25, resolve } from "node:path";
3944
4136
  import { fileURLToPath as fileURLToPath2 } from "node:url";
3945
4137
  var PROVIDER_IDS = ["claude-code", "opencode", "cursor", "pi"];
3946
4138
  function getProviderManifests() {
@@ -3948,8 +4140,8 @@ function getProviderManifests() {
3948
4140
  const baseDir = resolve(dirname3(fileURLToPath2(import.meta.url)), "providers");
3949
4141
  for (const providerId of PROVIDER_IDS) {
3950
4142
  try {
3951
- const manifestPath = join24(baseDir, providerId, "manifest.json");
3952
- const raw = readFileSync11(manifestPath, "utf-8");
4143
+ const manifestPath = join25(baseDir, providerId, "manifest.json");
4144
+ const raw = readFileSync12(manifestPath, "utf-8");
3953
4145
  manifests.push(JSON.parse(raw));
3954
4146
  } catch {
3955
4147
  }
@@ -4000,6 +4192,7 @@ export {
4000
4192
  OpenCodeHookProvider,
4001
4193
  OpenCodeInstallProvider,
4002
4194
  OpenCodeSpawnProvider,
4195
+ buildCantEnrichedPrompt,
4003
4196
  checkStatuslineIntegration,
4004
4197
  createAdapter as createClaudeCodeAdapter,
4005
4198
  createAdapter2 as createCodexAdapter,