@cleocode/adapters 2026.4.40 → 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.
@@ -0,0 +1,284 @@
1
+ /**
2
+ * Shared CANT context builder for all spawn providers.
3
+ *
4
+ * Extracts the Pi bridge's CANT discovery/compile/inject logic into a reusable
5
+ * module that any spawn provider (Claude Code, OpenCode, Cursor, etc.) can call
6
+ * to enrich agent prompts with:
7
+ *
8
+ * 1. Compiled CANT bundle (team topology, agent personas, tool ACLs)
9
+ * 2. Memory bridge (recent decisions, handoff notes, key patterns)
10
+ * 3. Mental model injection (validate-on-load agent-specific observations)
11
+ *
12
+ * All operations are best-effort: if any step fails (missing packages, empty
13
+ * directories, compilation errors), the base prompt is returned unchanged.
14
+ * This guarantees agents always spawn — CANT context is an enrichment, not a gate.
15
+ *
16
+ * Reference implementation: packages/cleo-os/extensions/cleo-cant-bridge.ts
17
+ * (Pi-only; this module generalizes the same logic for all providers)
18
+ *
19
+ * @task T555
20
+ */
21
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
22
+ import { homedir } from 'node:os';
23
+ import { basename, join } from 'node:path';
24
+ // ---------------------------------------------------------------------------
25
+ // Constants
26
+ // ---------------------------------------------------------------------------
27
+ /**
28
+ * Preamble text injected when an agent has mental model observations.
29
+ * The agent MUST re-evaluate each observation against current project state.
30
+ */
31
+ const VALIDATE_ON_LOAD_PREAMBLE = '===== MENTAL MODEL (validate-on-load) =====\n' +
32
+ 'These are your prior observations, patterns, and learnings for this project.\n' +
33
+ 'Before acting, you MUST re-evaluate each entry against current project state.\n' +
34
+ 'If an entry is stale, note it and proceed with fresh understanding.';
35
+ // ---------------------------------------------------------------------------
36
+ // Discovery functions (ported from cleo-cant-bridge.ts lines 418-526)
37
+ // ---------------------------------------------------------------------------
38
+ /**
39
+ * Recursively discover `.cant` files in a directory.
40
+ *
41
+ * @param dir - The directory to scan recursively.
42
+ * @returns An array of absolute paths to `.cant` files found.
43
+ */
44
+ export function discoverCantFiles(dir) {
45
+ try {
46
+ const entries = readdirSync(dir, { recursive: true, withFileTypes: true });
47
+ const files = [];
48
+ for (const entry of entries) {
49
+ if (entry.isFile() && entry.name.endsWith('.cant')) {
50
+ const parent = entry.parentPath ?? dir;
51
+ files.push(join(parent, entry.name));
52
+ }
53
+ }
54
+ return files;
55
+ }
56
+ catch {
57
+ return [];
58
+ }
59
+ }
60
+ /**
61
+ * Resolve XDG-compliant paths for the 3-tier CANT hierarchy.
62
+ *
63
+ * Respects `XDG_DATA_HOME` and `XDG_CONFIG_HOME` environment variables.
64
+ * Falls back to XDG defaults (`~/.local/share/` and `~/.config/`).
65
+ *
66
+ * @param projectDir - The project root directory (for the project tier).
67
+ * @returns An object with `global`, `user`, and `project` CANT directory paths.
68
+ */
69
+ export function resolveThreeTierPaths(projectDir) {
70
+ const home = homedir();
71
+ const xdgData = process.env['XDG_DATA_HOME'] ?? join(home, '.local', 'share');
72
+ const xdgConfig = process.env['XDG_CONFIG_HOME'] ?? join(home, '.config');
73
+ return {
74
+ global: join(xdgData, 'cleo', 'cant'),
75
+ user: join(xdgConfig, 'cleo', 'cant'),
76
+ project: join(projectDir, '.cleo', 'cant'),
77
+ };
78
+ }
79
+ /**
80
+ * Discover `.cant` files across all three tiers with override semantics.
81
+ *
82
+ * Scans global, user, and project tiers. Files in higher-precedence tiers
83
+ * override files in lower-precedence tiers that share the same basename.
84
+ * The precedence order is: project > user > global.
85
+ *
86
+ * @param projectDir - The project root directory.
87
+ * @returns An object containing the merged file list and per-tier statistics.
88
+ */
89
+ export function discoverCantFilesMultiTier(projectDir) {
90
+ const paths = resolveThreeTierPaths(projectDir);
91
+ const globalFiles = discoverCantFiles(paths.global);
92
+ const userFiles = discoverCantFiles(paths.user);
93
+ const projectFiles = discoverCantFiles(paths.project);
94
+ // Build basename-keyed map; lowest precedence first so higher tiers override
95
+ const fileMap = new Map();
96
+ for (const file of globalFiles) {
97
+ fileMap.set(basename(file), file);
98
+ }
99
+ for (const file of userFiles) {
100
+ fileMap.set(basename(file), file);
101
+ }
102
+ for (const file of projectFiles) {
103
+ fileMap.set(basename(file), file);
104
+ }
105
+ const totalUniqueInputs = globalFiles.length + userFiles.length + projectFiles.length;
106
+ const overrides = totalUniqueInputs - fileMap.size;
107
+ return {
108
+ files: Array.from(fileMap.values()),
109
+ stats: {
110
+ global: globalFiles.length,
111
+ user: userFiles.length,
112
+ project: projectFiles.length,
113
+ overrides,
114
+ merged: fileMap.size,
115
+ },
116
+ };
117
+ }
118
+ // ---------------------------------------------------------------------------
119
+ // Memory bridge (ported from cleo-cant-bridge.ts lines 376-404)
120
+ // ---------------------------------------------------------------------------
121
+ /**
122
+ * Read the memory bridge file from a project's .cleo/ directory.
123
+ *
124
+ * @param projectDir - The project root directory.
125
+ * @returns The memory bridge content, or null if not found or empty.
126
+ */
127
+ export function readMemoryBridge(projectDir) {
128
+ try {
129
+ const bridgePath = join(projectDir, '.cleo', 'memory-bridge.md');
130
+ if (!existsSync(bridgePath))
131
+ return null;
132
+ const content = readFileSync(bridgePath, 'utf-8');
133
+ return content.length > 0 ? content : null;
134
+ }
135
+ catch {
136
+ return null;
137
+ }
138
+ }
139
+ /**
140
+ * Build the memory-bridge system-prompt block appended to every agent.
141
+ *
142
+ * Wraps the raw memory-bridge.md content in a clearly labeled section
143
+ * so the agent knows this is the CLEO project memory context.
144
+ *
145
+ * @param content - The raw memory-bridge.md content.
146
+ * @returns The formatted memory-bridge block for system prompt injection.
147
+ */
148
+ export function buildMemoryBridgeBlock(content) {
149
+ return ('\n\n===== CLEO MEMORY BRIDGE =====\n' +
150
+ 'This is your project memory context from .cleo/memory-bridge.md.\n' +
151
+ 'Use it to understand recent decisions, handoff notes, and key patterns.\n\n' +
152
+ content.trim() +
153
+ '\n===== END MEMORY BRIDGE =====');
154
+ }
155
+ // ---------------------------------------------------------------------------
156
+ // Mental model injection (ported from cleo-cant-bridge.ts lines 113-135, 543-589)
157
+ // ---------------------------------------------------------------------------
158
+ /**
159
+ * Build the validate-on-load mental-model injection string.
160
+ *
161
+ * Pure function — no I/O, safe to call in tests without a real DB.
162
+ *
163
+ * @param agentName - Name of the spawned agent (used in the header line).
164
+ * @param observations - Prior mental-model observations to list.
165
+ * @returns System-prompt block with preamble and numbered observations,
166
+ * or empty string when `observations` is empty.
167
+ */
168
+ export function buildMentalModelInjection(agentName, observations) {
169
+ if (observations.length === 0)
170
+ return '';
171
+ const lines = ['', `// Agent: ${agentName}`, VALIDATE_ON_LOAD_PREAMBLE, ''];
172
+ for (let i = 0; i < observations.length; i++) {
173
+ const obs = observations[i];
174
+ const datePart = obs.date ? ` [${obs.date}]` : '';
175
+ lines.push(`${i + 1}. [${obs.id}] (${obs.type})${datePart}: ${obs.title}`);
176
+ }
177
+ lines.push('===== END MENTAL MODEL =====');
178
+ return lines.join('\n');
179
+ }
180
+ /**
181
+ * Fetch mental model observations for an agent from brain.db.
182
+ *
183
+ * Uses dynamic import of `@cleocode/core` to avoid circular dependencies.
184
+ * Returns empty string on any failure (best-effort, never throws).
185
+ *
186
+ * @param agentName - The agent's name for scoped observation lookup.
187
+ * @param projectRoot - Project root directory for brain.db access.
188
+ * @returns The validate-on-load system-prompt block, or "" on failure/empty.
189
+ */
190
+ async function fetchMentalModelInjection(agentName, projectRoot) {
191
+ try {
192
+ // Dynamic import — @cleocode/core is NOT a compile-time dependency of adapters.
193
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
194
+ const coreModule = (await import(/* webpackIgnore: true */ '@cleocode/core'));
195
+ if (typeof coreModule.memoryFind !== 'function')
196
+ return '';
197
+ const result = await coreModule.memoryFind({
198
+ query: agentName,
199
+ agent: agentName,
200
+ limit: 10,
201
+ tables: ['observations'],
202
+ }, projectRoot);
203
+ if (!result.success || !result.data?.results?.length)
204
+ return '';
205
+ return buildMentalModelInjection(agentName, result.data.results);
206
+ }
207
+ catch {
208
+ return '';
209
+ }
210
+ }
211
+ // ---------------------------------------------------------------------------
212
+ // Main entry point
213
+ // ---------------------------------------------------------------------------
214
+ /**
215
+ * Build an enriched prompt with CANT context, memory bridge, and mental model.
216
+ *
217
+ * This is the universal entry point for all spawn providers. It performs the
218
+ * same operations as the Pi bridge (cleo-cant-bridge.ts) but returns a string
219
+ * rather than hooking into Pi events:
220
+ *
221
+ * 1. Discovers `.cant` files across 3 tiers (global → user → project)
222
+ * 2. Compiles the CANT bundle via `@cleocode/cant`'s `compileBundle()`
223
+ * 3. Renders the compiled system prompt
224
+ * 4. Reads the memory bridge from `.cleo/memory-bridge.md`
225
+ * 5. Fetches mental model observations for the named agent
226
+ * 6. Concatenates: basePrompt + CANT bundle + memory bridge + mental model
227
+ *
228
+ * All operations are best-effort. If any step fails, the base prompt is
229
+ * returned unchanged. CANT context is an enrichment, not a gate — agents
230
+ * always spawn regardless of CANT availability.
231
+ *
232
+ * @param options - Project dir, base prompt, and optional agent name.
233
+ * @returns The enriched prompt string, or basePrompt unchanged on failure.
234
+ */
235
+ export async function buildCantEnrichedPrompt(options) {
236
+ const { projectDir, basePrompt, agentName } = options;
237
+ let appendix = '';
238
+ // Step 1-3: Discover and compile CANT bundle
239
+ try {
240
+ const { files } = discoverCantFilesMultiTier(projectDir);
241
+ if (files.length > 0) {
242
+ // Dynamic import — @cleocode/cant is NOT a compile-time dependency of adapters.
243
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
244
+ const cantModule = (await import(/* webpackIgnore: true */ '@cleocode/cant'));
245
+ if (typeof cantModule.compileBundle === 'function') {
246
+ const bundle = await cantModule.compileBundle(files);
247
+ if (bundle.valid) {
248
+ const rendered = bundle.renderSystemPrompt();
249
+ if (rendered) {
250
+ appendix += `\n\n${rendered}`;
251
+ }
252
+ }
253
+ }
254
+ }
255
+ }
256
+ catch {
257
+ // CANT compilation failure — continue without bundle context
258
+ }
259
+ // Step 4: Append memory bridge
260
+ try {
261
+ const bridge = readMemoryBridge(projectDir);
262
+ if (bridge) {
263
+ appendix += buildMemoryBridgeBlock(bridge);
264
+ }
265
+ }
266
+ catch {
267
+ // Memory bridge read failure — non-fatal
268
+ }
269
+ // Step 5: Append mental model for named agent
270
+ if (agentName) {
271
+ try {
272
+ const mentalModel = await fetchMentalModelInjection(agentName, projectDir);
273
+ if (mentalModel) {
274
+ appendix += `\n\n${mentalModel}`;
275
+ }
276
+ }
277
+ catch {
278
+ // Mental model fetch failure — non-fatal
279
+ }
280
+ }
281
+ // Step 6: Return enriched prompt (or unchanged basePrompt if no context found)
282
+ return appendix ? basePrompt + appendix : basePrompt;
283
+ }
284
+ //# sourceMappingURL=cant-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cant-context.js","sourceRoot":"","sources":["../src/cant-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAiC3C,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,yBAAyB,GAC7B,+CAA+C;IAC/C,gFAAgF;IAChF,iFAAiF;IACjF,qEAAqE,CAAC;AAExE,8EAA8E;AAC9E,sEAAsE;AACtE,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3E,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;g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Aa,KAAK,UAAU,EAAE,CAAC;gBACnD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACrD,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;oBACjB,MAAM,QAAQ,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;oBAC7C,IAAI,QAAQ,EAAE,CAAC;wBACb,QAAQ,IAAI,OAAO,QAAQ,EAAE,CAAC;oBAChC,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,6DAA6D;IAC/D,CAAC;IAED,+BAA+B;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAC5C,IAAI,MAAM,EAAE,CAAC;YACX,QAAQ,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,yCAAyC;IAC3C,CAAC;IAED,8CAA8C;IAC9C,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,MAAM,yBAAyB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YAC3E,IAAI,WAAW,EAAE,CAAC;gBAChB,QAAQ,IAAI,OAAO,WAAW,EAAE,CAAC;YACnC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,yCAAyC;QAC3C,CAAC;IACH,CAAC;IAED,+EAA+E;IAC/E,OAAO,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC;AACvD,CAAC"}
package/dist/index.js CHANGED
@@ -132,7 +132,7 @@ async function buildCantEnrichedPrompt(options) {
132
132
  "@cleocode/cant"
133
133
  );
134
134
  if (typeof cantModule.compileBundle === "function") {
135
- const bundle = cantModule.compileBundle(files);
135
+ const bundle = await cantModule.compileBundle(files);
136
136
  if (bundle.valid) {
137
137
  const rendered = bundle.renderSystemPrompt();
138
138
  if (rendered) {
@@ -1029,10 +1029,16 @@ var init_spawn = __esm({
1029
1029
  }
1030
1030
  tmpFile = `/tmp/claude-spawn-${instanceId}.txt`;
1031
1031
  await writeFile(tmpFile, enrichedPrompt, "utf-8");
1032
- const args = ["--allow-insecure", "--no-upgrade-check", tmpFile];
1032
+ const args = [
1033
+ "--print",
1034
+ "--dangerously-skip-permissions",
1035
+ "--output-format",
1036
+ "json",
1037
+ tmpFile
1038
+ ];
1033
1039
  const spawnOpts = {
1034
1040
  detached: true,
1035
- stdio: "ignore"
1041
+ stdio: ["ignore", "pipe", "pipe"]
1036
1042
  };
1037
1043
  if (context.workingDirectory) {
1038
1044
  spawnOpts.cwd = context.workingDirectory;