@cleocode/adapters 2026.4.24 → 2026.4.25

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.
@@ -15,7 +15,8 @@ import type { AdapterInstallProvider, InstallOptions, InstallResult } from '@cle
15
15
  *
16
16
  * Manages CLEO's integration with Claude Code by:
17
17
  * 1. Ensuring CLAUDE.md contains @-references to CLEO instruction files
18
- * 2. Registering the brain observation plugin in ~/.claude/settings.json
18
+ * 2. Installing adapter-provided commands to .claude/commands/
19
+ * 3. Registering the brain observation plugin in ~/.claude/settings.json
19
20
  *
20
21
  * @remarks
21
22
  * Installation is idempotent -- running install multiple times on the same
@@ -57,6 +58,16 @@ export declare class ClaudeCodeInstallProvider implements AdapterInstallProvider
57
58
  * @returns true if the file was created or modified
58
59
  */
59
60
  private updateInstructionFile;
61
+ /**
62
+ * Install Claude Code-specific commands to .claude/commands/ in the project.
63
+ *
64
+ * These commands extend CLEO's provider-neutral skills with Claude Code-specific
65
+ * operational patterns (Agent tool spawn templates, model assignment, context guardrails).
66
+ *
67
+ * @param projectDir - Project root directory
68
+ * @returns Array of installed command filenames
69
+ */
70
+ private installCommands;
60
71
  /**
61
72
  * Register the CLEO brain plugin in ~/.claude/settings.json.
62
73
  *
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKjG;;;;;;;;;;;;GAYG;AACH,qBAAa,yBAA0B,YAAW,sBAAsB;IACtE;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IA0B9D;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAEhC;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAkBrC;;;;;;OAMG;IACG,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IA+B7B;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAiCvB"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAYjG;;;;;;;;;;;;;GAaG;AACH,qBAAa,yBAA0B,YAAW,sBAAsB;IACtE;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAgC9D;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAEhC;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAkBrC;;;;;;OAMG;IACG,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IA+B7B;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;IAsBvB;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAiCvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleocode/adapters",
3
- "version": "2026.4.24",
3
+ "version": "2026.4.25",
4
4
  "description": "Unified provider adapters for CLEO (Claude Code, OpenCode, Cursor)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,8 +12,8 @@
12
12
  }
13
13
  },
14
14
  "dependencies": {
15
- "@cleocode/contracts": "2026.4.24",
16
- "@cleocode/caamp": "2026.4.24"
15
+ "@cleocode/caamp": "2026.4.25",
16
+ "@cleocode/contracts": "2026.4.25"
17
17
  },
18
18
  "license": "MIT",
19
19
  "engines": {
@@ -0,0 +1,132 @@
1
+ # Orchestrator Mode (Claude Code)
2
+
3
+ Load the `/ct-orchestrator` skill. You are now the Orchestrator.
4
+
5
+ This command extends ct-orchestrator with **Claude Code-specific** operational guidance for spawning subagents via the Agent tool.
6
+
7
+ ## Session Startup
8
+
9
+ ```bash
10
+ cleo session status # Resume existing?
11
+ cleo dash # Project overview
12
+ cleo current # Active task?
13
+ cleo orchestrate start --epic TXXX # Full state + pipeline + next task
14
+ ```
15
+
16
+ Then ask the human what they want to focus on today. Follow LOOM (RCASD -> IVTR) lifecycle for all work.
17
+
18
+ ## Agent Tool — Spawn Patterns
19
+
20
+ In Claude Code, subagent execution uses the **Agent tool**. The prompt comes from `cleo orchestrate spawn`.
21
+
22
+ ### Team Lead (RCASD planning, validation, complex reasoning)
23
+
24
+ ```
25
+ Agent({
26
+ description: "Team Lead: [epic domain] (T####)",
27
+ subagent_type: "cleo-subagent",
28
+ model: "sonnet",
29
+ prompt: "<resolved prompt from cleo orchestrate spawn T####>"
30
+ })
31
+ ```
32
+
33
+ ### Worker (focused implementation, testing)
34
+
35
+ ```
36
+ Agent({
37
+ description: "Worker: [task title] (T####)",
38
+ subagent_type: "cleo-subagent",
39
+ model: "haiku",
40
+ prompt: "<resolved prompt from cleo orchestrate spawn T####>"
41
+ })
42
+ ```
43
+
44
+ ### Explorer (quick research, codebase investigation)
45
+
46
+ ```
47
+ Agent({
48
+ description: "Explorer: [research topic] (T####)",
49
+ subagent_type: "cleo-subagent",
50
+ model: "haiku",
51
+ prompt: "<resolved prompt from cleo orchestrate spawn T####>"
52
+ })
53
+ ```
54
+
55
+ ### Parallel Spawn (independent tasks in same wave)
56
+
57
+ ```
58
+ // Spawn multiple agents in a single message for parallel execution
59
+ Agent({
60
+ description: "Worker: Task A (T1001)",
61
+ subagent_type: "cleo-subagent",
62
+ model: "haiku",
63
+ run_in_background: true,
64
+ prompt: "<prompt A>"
65
+ })
66
+ Agent({
67
+ description: "Worker: Task B (T1002)",
68
+ subagent_type: "cleo-subagent",
69
+ model: "haiku",
70
+ run_in_background: true,
71
+ prompt: "<prompt B>"
72
+ })
73
+ ```
74
+
75
+ ## Model Assignment
76
+
77
+ | Role | Model | Rationale |
78
+ |------|-------|-----------|
79
+ | Orchestrator (you) | opus | Strategic coordination, HITL interface |
80
+ | Team Leads | sonnet | Architecture, specs, validation |
81
+ | Workers | haiku | Implementation, testing, focused changes |
82
+ | Explorers | haiku | Quick research, codebase reads |
83
+
84
+ Model assignment is an **optimization** — if a model tier is unavailable, use whatever is available. Never block on model selection.
85
+
86
+ ## Two-Step Spawn Flow
87
+
88
+ ```
89
+ 1. cleo orchestrate spawn T#### --json → Get fully-resolved prompt
90
+ 2. Agent({ ..., prompt: <resolved> }) → Execute via Agent tool
91
+ 3. Wait for return message → "[Type] complete/partial/blocked..."
92
+ 4. cleo manifest show <id> → Read key_findings from manifest
93
+ 5. Next spawn or report to human
94
+ ```
95
+
96
+ ## Quality Gates
97
+
98
+ ### Before marking ANY task done:
99
+ 1. Manifest entry exists with key_findings
100
+ 2. Return message matches valid format
101
+ 3. Acceptance criteria explicitly verified (not assumed)
102
+ 4. No regressions in existing functionality
103
+
104
+ ### On failure (IVTR loop):
105
+ 1. Read manifest for failure details
106
+ 2. Add feedback to next spawn prompt
107
+ 3. Re-spawn worker with: original prompt + failure context + explicit checklist
108
+ 4. Max 2 retries — then escalate to HITL
109
+
110
+ ## Guardrails (Claude Code-Specific)
111
+
112
+ | Rule | Enforcement |
113
+ |------|-------------|
114
+ | NEVER write code yourself | All code via Agent() spawns |
115
+ | NEVER read full source files | Only manifests, task outputs, and spawn results |
116
+ | NEVER use `run_in_background: false` for heavy work | Background workers protect your context |
117
+ | NEVER call TaskOutput on subagent results | Read MANIFEST.jsonl via `cleo manifest show` |
118
+ | ALWAYS use `subagent_type: "cleo-subagent"` | Ensures protocol injection |
119
+ | ALWAYS include task ID in description | Traceability: "Worker: Auth module (T1586)" |
120
+ | ALWAYS check `cleo orchestrate ready` before spawning | Dependency order enforcement |
121
+
122
+ ## Context Protection
123
+
124
+ Your context window is precious. Protect it:
125
+
126
+ | Strategy | How |
127
+ |----------|-----|
128
+ | Read manifests, not files | `cleo manifest show <id>` over reading source |
129
+ | Keep task state in CLEO | `cleo show T####` to recall details on demand |
130
+ | Background heavy workers | `run_in_background: true` for implementation tasks |
131
+ | End sessions with notes | `cleo session end --note "handoff summary"` |
132
+ | Delegate investigation | Spawn Explore agents for codebase questions |
@@ -10,20 +10,29 @@
10
10
  * @task T5240
11
11
  */
12
12
 
13
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
13
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
14
14
  import { homedir } from 'node:os';
15
- import { join } from 'node:path';
15
+ import { dirname, join } from 'node:path';
16
+ import { fileURLToPath } from 'node:url';
16
17
  import type { AdapterInstallProvider, InstallOptions, InstallResult } from '@cleocode/contracts';
17
18
 
18
19
  /** Lines that should appear in CLAUDE.md to reference CLEO. */
19
20
  const INSTRUCTION_REFERENCES = ['@~/.cleo/templates/CLEO-INJECTION.md', '@.cleo/memory-bridge.md'];
20
21
 
22
+ /** Resolve the commands directory bundled with this adapter. */
23
+ function getAdapterCommandsDir(): string {
24
+ // Works in both ESM (import.meta.url) and compiled output
25
+ const thisDir = dirname(fileURLToPath(import.meta.url));
26
+ return join(thisDir, 'commands');
27
+ }
28
+
21
29
  /**
22
30
  * Install provider for Claude Code.
23
31
  *
24
32
  * Manages CLEO's integration with Claude Code by:
25
33
  * 1. Ensuring CLAUDE.md contains @-references to CLEO instruction files
26
- * 2. Registering the brain observation plugin in ~/.claude/settings.json
34
+ * 2. Installing adapter-provided commands to .claude/commands/
35
+ * 3. Registering the brain observation plugin in ~/.claude/settings.json
27
36
  *
28
37
  * @remarks
29
38
  * Installation is idempotent -- running install multiple times on the same
@@ -50,7 +59,13 @@ export class ClaudeCodeInstallProvider implements AdapterInstallProvider {
50
59
  details.instructionFile = join(projectDir, 'CLAUDE.md');
51
60
  }
52
61
 
53
- // Step 2: Register plugin in ~/.claude/settings.json
62
+ // Step 2: Install adapter-provided commands to .claude/commands/
63
+ const commandsInstalled = this.installCommands(projectDir);
64
+ if (commandsInstalled.length > 0) {
65
+ details.commands = commandsInstalled;
66
+ }
67
+
68
+ // Step 3: Register plugin in ~/.claude/settings.json
54
69
  const pluginResult = this.registerPlugin();
55
70
  if (pluginResult) {
56
71
  details.plugin = pluginResult;
@@ -141,6 +156,37 @@ export class ClaudeCodeInstallProvider implements AdapterInstallProvider {
141
156
  return true;
142
157
  }
143
158
 
159
+ /**
160
+ * Install Claude Code-specific commands to .claude/commands/ in the project.
161
+ *
162
+ * These commands extend CLEO's provider-neutral skills with Claude Code-specific
163
+ * operational patterns (Agent tool spawn templates, model assignment, context guardrails).
164
+ *
165
+ * @param projectDir - Project root directory
166
+ * @returns Array of installed command filenames
167
+ */
168
+ private installCommands(projectDir: string): string[] {
169
+ const adapterCommandsDir = getAdapterCommandsDir();
170
+ if (!existsSync(adapterCommandsDir)) {
171
+ return [];
172
+ }
173
+
174
+ const targetDir = join(projectDir, '.claude', 'commands');
175
+ mkdirSync(targetDir, { recursive: true });
176
+
177
+ const installed: string[] = [];
178
+ const files = readdirSync(adapterCommandsDir).filter((f) => f.endsWith('.md'));
179
+
180
+ for (const file of files) {
181
+ const src = join(adapterCommandsDir, file);
182
+ const dest = join(targetDir, file);
183
+ copyFileSync(src, dest);
184
+ installed.push(file);
185
+ }
186
+
187
+ return installed;
188
+ }
189
+
144
190
  /**
145
191
  * Register the CLEO brain plugin in ~/.claude/settings.json.
146
192
  *