@cleocode/adapters 2026.4.39 → 2026.4.40
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/cant-context.d.ts +130 -0
- package/dist/cant-context.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +386 -199
- package/dist/index.js.map +4 -4
- package/dist/providers/claude-code/hooks.d.ts.map +1 -1
- package/dist/providers/claude-code/spawn.d.ts.map +1 -1
- package/dist/providers/opencode/spawn.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/cant-context.test.ts +248 -0
- package/src/cant-context.ts +379 -0
- package/src/index.ts +3 -0
- package/src/providers/claude-code/hooks.ts +12 -11
- package/src/providers/claude-code/spawn.ts +15 -1
- package/src/providers/opencode/spawn.ts +30 -11
|
@@ -150,17 +150,18 @@ export class ClaudeCodeHookProvider implements AdapterHookProvider {
|
|
|
150
150
|
const hooks = (settings.hooks ?? {}) as Record<string, unknown[]>;
|
|
151
151
|
|
|
152
152
|
// Check if CLEO hooks already registered (look for our marker comment in commands)
|
|
153
|
-
const alreadyRegistered = Object.values(hooks).some(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
(
|
|
162
|
-
|
|
163
|
-
|
|
153
|
+
const alreadyRegistered = Object.values(hooks).some(
|
|
154
|
+
(entries) =>
|
|
155
|
+
Array.isArray(entries) &&
|
|
156
|
+
entries.some(
|
|
157
|
+
(e) =>
|
|
158
|
+
typeof e === 'object' &&
|
|
159
|
+
e !== null &&
|
|
160
|
+
Array.isArray((e as Record<string, unknown>).hooks) &&
|
|
161
|
+
((e as Record<string, unknown>).hooks as Array<Record<string, string>>).some(
|
|
162
|
+
(h) => typeof h.command === 'string' && h.command.includes('# cleo-hook'),
|
|
163
|
+
),
|
|
164
|
+
),
|
|
164
165
|
);
|
|
165
166
|
|
|
166
167
|
if (alreadyRegistered) {
|
|
@@ -74,8 +74,22 @@ export class ClaudeCodeSpawnProvider implements AdapterSpawnProvider {
|
|
|
74
74
|
let tmpFile: string | undefined;
|
|
75
75
|
|
|
76
76
|
try {
|
|
77
|
+
// Enrich prompt with CANT bundle, memory bridge, and mental model (T555).
|
|
78
|
+
// Best-effort: if CANT context is unavailable, the raw prompt is used.
|
|
79
|
+
let enrichedPrompt = context.prompt;
|
|
80
|
+
try {
|
|
81
|
+
const { buildCantEnrichedPrompt } = await import('../../cant-context.js');
|
|
82
|
+
enrichedPrompt = await buildCantEnrichedPrompt({
|
|
83
|
+
projectDir: context.workingDirectory ?? process.cwd(),
|
|
84
|
+
basePrompt: context.prompt,
|
|
85
|
+
agentName: (context.options?.agentName as string) ?? undefined,
|
|
86
|
+
});
|
|
87
|
+
} catch {
|
|
88
|
+
// CANT enrichment unavailable — use raw prompt
|
|
89
|
+
}
|
|
90
|
+
|
|
77
91
|
tmpFile = `/tmp/claude-spawn-${instanceId}.txt`;
|
|
78
|
-
await writeFile(tmpFile,
|
|
92
|
+
await writeFile(tmpFile, enrichedPrompt, 'utf-8');
|
|
79
93
|
|
|
80
94
|
const args = ['--allow-insecure', '--no-upgrade-check', tmpFile];
|
|
81
95
|
const spawnOpts: Parameters<typeof nodeSpawn>[2] = {
|
|
@@ -80,18 +80,23 @@ export function buildOpenCodeAgentMarkdown(description: string, instructions: st
|
|
|
80
80
|
* @param workingDirectory - Project root directory
|
|
81
81
|
* @returns The agent name to use for spawning
|
|
82
82
|
*/
|
|
83
|
-
async function ensureSubagentDefinition(
|
|
83
|
+
async function ensureSubagentDefinition(
|
|
84
|
+
workingDirectory: string,
|
|
85
|
+
enrichedInstructions?: string,
|
|
86
|
+
): Promise<string> {
|
|
84
87
|
const agentDir = join(workingDirectory, '.opencode', 'agent');
|
|
85
88
|
const agentPath = join(agentDir, `${OPENCODE_SUBAGENT_NAME}.md`);
|
|
86
|
-
const description = 'CLEO task executor with protocol compliance.';
|
|
87
|
-
const instructions =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
const description = 'CLEO task executor with protocol compliance and CANT context.';
|
|
90
|
+
const instructions =
|
|
91
|
+
enrichedInstructions ??
|
|
92
|
+
[
|
|
93
|
+
'# CLEO Subagent',
|
|
94
|
+
'',
|
|
95
|
+
'You are a CLEO subagent executing a delegated task.',
|
|
96
|
+
'Follow the CLEO protocol and complete the assigned work.',
|
|
97
|
+
'',
|
|
98
|
+
'@~/.cleo/templates/CLEO-INJECTION.md',
|
|
99
|
+
].join('\n');
|
|
95
100
|
|
|
96
101
|
const content = buildOpenCodeAgentMarkdown(description, instructions);
|
|
97
102
|
|
|
@@ -160,9 +165,23 @@ export class OpenCodeSpawnProvider implements AdapterSpawnProvider {
|
|
|
160
165
|
const workingDirectory = context.workingDirectory ?? process.cwd();
|
|
161
166
|
|
|
162
167
|
try {
|
|
168
|
+
// Enrich prompt with CANT bundle, memory bridge, and mental model (T555).
|
|
169
|
+
// Best-effort: if CANT context is unavailable, the raw prompt is used.
|
|
170
|
+
let enrichedInstructions: string | undefined;
|
|
171
|
+
try {
|
|
172
|
+
const { buildCantEnrichedPrompt } = await import('../../cant-context.js');
|
|
173
|
+
enrichedInstructions = await buildCantEnrichedPrompt({
|
|
174
|
+
projectDir: workingDirectory,
|
|
175
|
+
basePrompt: context.prompt,
|
|
176
|
+
agentName: (context.options?.agentName as string) ?? undefined,
|
|
177
|
+
});
|
|
178
|
+
} catch {
|
|
179
|
+
// CANT enrichment unavailable — use raw prompt
|
|
180
|
+
}
|
|
181
|
+
|
|
163
182
|
let agentName: string;
|
|
164
183
|
try {
|
|
165
|
-
agentName = await ensureSubagentDefinition(workingDirectory);
|
|
184
|
+
agentName = await ensureSubagentDefinition(workingDirectory, enrichedInstructions);
|
|
166
185
|
} catch {
|
|
167
186
|
agentName = OPENCODE_FALLBACK_AGENT;
|
|
168
187
|
}
|