@cleocode/agents 2026.11.11 → 2026.11.12
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/README.md +144 -102
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,23 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
> Part of [CLEO](https://github.com/kryptobaseddev/cleo#readme). Start with the root README; run `cleo <command> --help` for any command.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
CLEO
|
|
5
|
+
The universal subagent protocol, canonical lead and worker definitions, worker
|
|
6
|
+
templates, and meta-agents for CLEO.
|
|
7
7
|
|
|
8
|
-
## Scope (ADR-068
|
|
8
|
+
## Scope (ADR-068)
|
|
9
9
|
|
|
10
|
-
Per [ADR-068](../../docs/adr/adr-068-canonical-agent-system.md), this package
|
|
11
|
-
|
|
10
|
+
Per [ADR-068](../../docs/adr/adr-068-canonical-agent-system.md), this package
|
|
11
|
+
ships four surfaces (the `files` list in `package.json`):
|
|
12
12
|
|
|
13
|
-
1. **`cleo-subagent.cant
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
1. **`cleo-subagent.cant`**: the universal protocol base, and the last tier of
|
|
14
|
+
the agent resolver.
|
|
15
|
+
2. **`definitions/`**: the canonical `cleo-lead` and `cleo-worker` agents that
|
|
16
|
+
`cleo init` and `cleo upgrade` render into each detected provider's
|
|
17
|
+
project agent files (T14378).
|
|
18
|
+
3. **`templates/`**: five project worker templates with `{{variable}}`
|
|
19
|
+
placeholders. Each filename basename equals its declared `agent <name>:`.
|
|
20
|
+
4. **`meta/`**: meta-agents that synthesize other agents and playbooks from
|
|
21
|
+
project context.
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
`cleo-historian`, `cleo-rust-lead`, `cleo-db-lead
|
|
20
|
-
|
|
21
|
-
users.
|
|
23
|
+
The cleocode repository's own dogfood personas (`cleo-prime`, `cleo-dev`,
|
|
24
|
+
`cleo-historian`, `cleo-rust-lead`, `cleo-db-lead`) live in
|
|
25
|
+
`.cleo/cant/agents/` in that repository and are not shipped to users.
|
|
22
26
|
|
|
23
27
|
## Package Tree
|
|
24
28
|
|
|
@@ -27,104 +31,128 @@ packages/agents/
|
|
|
27
31
|
├── package.json
|
|
28
32
|
├── README.md # this file
|
|
29
33
|
├── cleo-subagent.cant # universal protocol base
|
|
34
|
+
├── definitions/
|
|
35
|
+
│ ├── cleo-lead.cant # plans and dispatches; no shell, no edits
|
|
36
|
+
│ └── cleo-worker.cant # executes one task, returns a short report
|
|
30
37
|
├── templates/
|
|
38
|
+
│ ├── README.md
|
|
31
39
|
│ ├── project-orchestrator.cant # coordinates the starter team
|
|
32
40
|
│ ├── project-dev-lead.cant # decides HOW, reviews workers
|
|
33
41
|
│ ├── project-code-worker.cant # writes code within globs
|
|
34
42
|
│ ├── project-docs-worker.cant # writes/edits documentation
|
|
35
43
|
│ └── project-security-worker.cant # security review and audits
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
├── meta/
|
|
45
|
+
│ ├── README.md
|
|
46
|
+
│ ├── agent-architect.cant # meta-agent: synthesizes agents
|
|
47
|
+
│ └── playbook-architect.cant # meta-agent: synthesizes playbooks
|
|
48
|
+
└── tests/
|
|
49
|
+
└── templates.test.ts
|
|
40
50
|
```
|
|
41
51
|
|
|
42
52
|
## The Universal Protocol Base: `cleo-subagent.cant`
|
|
43
53
|
|
|
44
|
-
|
|
54
|
+
`cleo-subagent.cant` declares the `cleo-subagent` agent (role `subagent`,
|
|
55
|
+
skills `ct-cleo` and `ct-task-executor`). It defines:
|
|
45
56
|
|
|
46
|
-
- **RFC 2119 constraints
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
- **RFC 2119 constraints**: output rules OUT-001…OUT-004 (write findings to the
|
|
58
|
+
output path, append a manifest entry before returning, return a summary
|
|
59
|
+
only) and BASE-001…BASE-008 (one manifest entry, no content in responses,
|
|
60
|
+
complete the task, output file before manifest entry, start the task before
|
|
61
|
+
work, no fabrication, link memory observations to the task, check `success`
|
|
62
|
+
on every LAFS response).
|
|
63
|
+
- **Tool, domain and permission declarations**, plus required, optional and
|
|
64
|
+
computed tokens (`TASK_ID`, `DATE`, `TOPIC_SLUG`, `OUTPUT_PATH`, …).
|
|
65
|
+
- **Anti-patterns** with their fixes, and `SessionStart` / `PostToolUse` hooks.
|
|
55
66
|
|
|
56
|
-
## Canonical Worker
|
|
67
|
+
## Canonical Lead and Worker (`definitions/`)
|
|
57
68
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
`cleo init` and `cleo upgrade` call `ensureAgentDefinitions`
|
|
70
|
+
(`packages/core/src/agents/ensure-agent-definitions.ts`), which renders these
|
|
71
|
+
files through CAAMP into every detected provider that loads project agent
|
|
72
|
+
files (for example `.claude/agents/cleo-lead.md`). A file without CAAMP's
|
|
73
|
+
generated marker belongs to the user and is never overwritten.
|
|
74
|
+
|
|
75
|
+
| Definition | Role | Purpose |
|
|
76
|
+
|------------|------|---------|
|
|
77
|
+
| `cleo-lead.cant` | lead | Talks to the owner and dispatches `cleo-worker` agents. Denied Bash/Edit/Write/web tools; runs allow-listed `cleo`/`gh` argv through the lead runner MCP tool. Not installed for OpenCode, whose agent files cannot hold a tool allow-list. |
|
|
78
|
+
| `cleo-worker.cant` | worker | Owns one CLEO task end to end, runs in the background, and returns a three-line report (conclusion, blocker, proof). |
|
|
79
|
+
|
|
80
|
+
## Worker Templates (`templates/`)
|
|
81
|
+
|
|
82
|
+
The five templates are parameterized blueprints with `{{variable}}`
|
|
83
|
+
placeholders. They stay project-agnostic: no CLEO-internal references and no
|
|
84
|
+
tool-chain assumptions beyond what each template parameterizes.
|
|
61
85
|
|
|
62
86
|
| Template | Role | Purpose |
|
|
63
87
|
|----------|------|---------|
|
|
64
|
-
| `project-orchestrator.cant` | orchestrator | Reads
|
|
65
|
-
| `project-dev-lead.cant` | lead | Decomposes work, reviews output, decides technical direction.
|
|
66
|
-
| `project-code-worker.cant` | worker | Writes code within declared globs
|
|
67
|
-
| `project-docs-worker.cant` | worker | Writes documentation
|
|
68
|
-
| `project-security-worker.cant` | worker | Security review, OWASP threat modelling, dependency audits. Read-only
|
|
88
|
+
| `project-orchestrator.cant` | orchestrator | Reads task context, classifies work, dispatches to the dev-lead, synthesizes results. Does not execute code. |
|
|
89
|
+
| `project-dev-lead.cant` | lead | Decomposes work, reviews output, decides technical direction. Must not hold Edit/Write/Bash (TEAM-002). |
|
|
90
|
+
| `project-code-worker.cant` | worker | Writes code within declared globs; runs `{{build_command}}` and `{{test_command}}`. |
|
|
91
|
+
| `project-docs-worker.cant` | worker | Writes documentation within documentation globs. |
|
|
92
|
+
| `project-security-worker.cant` | worker | Security review, OWASP threat modelling, dependency audits. Read-only; escalates findings. |
|
|
69
93
|
|
|
70
|
-
|
|
71
|
-
workers. For
|
|
72
|
-
|
|
94
|
+
Together they form a starter team: one orchestrator, one lead and three
|
|
95
|
+
workers. For richer topologies, the `agent-architect` meta-agent synthesizes
|
|
96
|
+
additional personas.
|
|
73
97
|
|
|
74
98
|
### Naming Contract (ADR-068 Decision 1)
|
|
75
99
|
|
|
76
|
-
Every `.cant` filename basename MUST equal the `agent <name>:` declaration
|
|
77
|
-
it. Templates use the `project-<role>` prefix to match the classifier
|
|
78
|
-
(`packages/core/src/orchestration/classify.ts`).
|
|
79
|
-
|
|
100
|
+
Every `.cant` filename basename MUST equal the `agent <name>:` declaration
|
|
101
|
+
inside it. Templates use the `project-<role>` prefix to match the classifier
|
|
102
|
+
output (`packages/core/src/orchestration/classify.ts`). The install pipeline
|
|
103
|
+
(`packages/core/src/store/agent-install.ts`) enforces this.
|
|
80
104
|
|
|
81
105
|
## How Variables Work
|
|
82
106
|
|
|
83
|
-
|
|
84
|
-
[ADR-055
|
|
107
|
+
Templates use mustache `{{var}}` syntax, per
|
|
108
|
+
[ADR-055](../../docs/adr/adr-055-agents-architecture-and-meta-agents.md).
|
|
109
|
+
The engine is `packages/core/src/agents/variable-substitution.ts`.
|
|
85
110
|
|
|
86
111
|
### Syntax
|
|
87
112
|
|
|
88
|
-
- `{{name}}
|
|
89
|
-
- `{{object.key}}
|
|
90
|
-
- `{{inputs.taskId}}
|
|
113
|
+
- `{{name}}`: simple variable
|
|
114
|
+
- `{{object.key}}`: dot-notation into the project context
|
|
115
|
+
- `{{inputs.taskId}}`: already used in `.cantbook` playbooks
|
|
91
116
|
|
|
92
|
-
|
|
117
|
+
Resolved values are never re-scanned, so a value containing `{{...}}` stays
|
|
118
|
+
literal.
|
|
93
119
|
|
|
94
|
-
|
|
120
|
+
### Resolution Order
|
|
95
121
|
|
|
96
|
-
|
|
97
|
-
2. **Playbook bindings** — top-level `bindings:` field.
|
|
98
|
-
3. **Session context** — `playbook_runs.bindings`, task + epic identifiers, user.
|
|
99
|
-
4. **Project context** — `.cleo/project-context.json`, traversed via dot-notation.
|
|
100
|
-
5. **Environment variables** — `CLEO_*` or `CANT_*` prefix.
|
|
101
|
-
6. **Default value** — when `SubstitutionOptions.defaultValue` is set.
|
|
102
|
-
7. **Missing** — strict mode throws `E_TEMPLATE_RESOLUTION`.
|
|
122
|
+
Each placeholder resolves from the first source that has it:
|
|
103
123
|
|
|
104
|
-
|
|
124
|
+
1. **Bindings**: a flat key map supplied by the caller.
|
|
125
|
+
2. **Session context**: at spawn time `taskId`, `sessionId`, `protocol`,
|
|
126
|
+
`agentId`, `role`, `tier`, `harnessHint` (and `spawnTaskId`).
|
|
127
|
+
3. **Project context**: `.cleo/project-context.json`, read with dot-notation.
|
|
128
|
+
4. **Environment**: `CLEO_<NAME>` then `CANT_<NAME>` (name upper-cased, dots
|
|
129
|
+
become underscores).
|
|
130
|
+
5. **Default**: `SubstitutionOptions.defaultValue`, when set.
|
|
131
|
+
6. **Missing**: lenient mode leaves the placeholder and reports it; strict mode
|
|
132
|
+
returns the text unchanged with `success: false`.
|
|
105
133
|
|
|
106
|
-
|
|
107
|
-
`orchestrateSpawnExecute` right before `composeSpawnPayload`, which means:
|
|
134
|
+
### Spawn-Time Resolution
|
|
108
135
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
136
|
+
`cleo init` copies templates with their placeholders intact. At spawn,
|
|
137
|
+
`orchestrateSpawnExecute` (`packages/core/src/orchestrate/spawn-ops.ts`) reads
|
|
138
|
+
the resolved agent's `.cant` body and substitutes it in lenient mode after
|
|
139
|
+
`composeSpawnPayload` resolves the agent and before the adapter receives the
|
|
140
|
+
prompt. Missing variables are reported under `data.meta.templateSubstitution`.
|
|
141
|
+
So the same template can spawn differently per task, and project-context
|
|
142
|
+
changes apply on the next spawn without reinstalling.
|
|
113
143
|
|
|
114
|
-
## Auto-
|
|
144
|
+
## Auto-Registration on `cleo init`
|
|
115
145
|
|
|
116
|
-
Per ADR-068 Decision 3, plain `cleo init`
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
`tier='project'
|
|
121
|
-
|
|
146
|
+
Per ADR-068 Decision 3, plain `cleo init` walks `@cleocode/agents/templates/`
|
|
147
|
+
and calls `installAgentFromCant()` for each `.cant` template
|
|
148
|
+
(`installTemplatesAtProjectTier` in `packages/core/src/init.ts`). Each install
|
|
149
|
+
copies the file to `<project>/.cleo/cant/agents/` and writes an
|
|
150
|
+
`agent_registry_agents` row with `tier='project'` in the **global** `cleo.db`
|
|
151
|
+
(schema: `packages/core/src/store/schema/cleo-global/agent-registry.ts`).
|
|
152
|
+
Re-running init overwrites stale rows instead of duplicating them.
|
|
122
153
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
The `--install-seed-agents` flag is preserved as a deprecated no-op alias with
|
|
127
|
-
a deprecation notice.
|
|
154
|
+
`--install-seed-agents` is a deprecated no-op: init emits a
|
|
155
|
+
`W_DEPRECATED_AGENT_PATH` warning when it is passed.
|
|
128
156
|
|
|
129
157
|
## Authoring a New Agent
|
|
130
158
|
|
|
@@ -135,9 +163,10 @@ cp packages/agents/templates/project-code-worker.cant \
|
|
|
135
163
|
my-project/.cleo/cant/agents/my-worker.cant
|
|
136
164
|
```
|
|
137
165
|
|
|
138
|
-
|
|
139
|
-
`{{variable}}` placeholders with
|
|
140
|
-
leave them for
|
|
166
|
+
Rename the agent (the filename must match), tune the description, skills and
|
|
167
|
+
tools, and either replace `{{variable}}` placeholders with literal values or
|
|
168
|
+
leave them for spawn-time resolution. `cleo agent create --name <n> --role <r>`
|
|
169
|
+
scaffolds a new agent package instead.
|
|
141
170
|
|
|
142
171
|
### 2. Validate the CANT syntax
|
|
143
172
|
|
|
@@ -151,7 +180,7 @@ cleo cant validate my-project/.cleo/cant/agents/my-worker.cant
|
|
|
151
180
|
cleo agent install my-project/.cleo/cant/agents/my-worker.cant
|
|
152
181
|
```
|
|
153
182
|
|
|
154
|
-
### 4.
|
|
183
|
+
### 4. Check registry drift
|
|
155
184
|
|
|
156
185
|
```bash
|
|
157
186
|
cleo agent doctor --json
|
|
@@ -159,36 +188,49 @@ cleo agent doctor --json
|
|
|
159
188
|
|
|
160
189
|
## Tier Precedence (Resolver Chain)
|
|
161
190
|
|
|
162
|
-
|
|
191
|
+
`resolveAgent` (`packages/core/src/store/agent-resolver.ts`) walks five tiers
|
|
192
|
+
in order. Tiers 1–3 are `agent_registry_agents` rows with that `tier` value
|
|
193
|
+
whose `cant_path` still exists on disk; an orphan row is skipped, not fatal.
|
|
194
|
+
|
|
195
|
+
1. **project**: rows attached from `<project>/.cleo/cant/agents/`
|
|
196
|
+
2. **global**: rows installed from the global agents directory
|
|
197
|
+
3. **packaged**: rows installed from `@cleocode/agents/templates/`
|
|
198
|
+
4. **fallback**: no row, but `templates/<agentId>.cant` exists on disk
|
|
199
|
+
5. **universal**: an envelope synthesized from `cleo-subagent.cant`
|
|
200
|
+
(ADR-068 Decision 6)
|
|
163
201
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
3. **packaged** — `packages/agents/templates/{agentId}.cant`
|
|
167
|
-
4. **fallback** — seed file on disk with no registry row
|
|
168
|
-
5. **universal** — `cleo-subagent.cant` synthesized envelope (ADR-068 Decision 6)
|
|
202
|
+
`E_AGENT_NOT_FOUND` is thrown only when every tier misses, which means
|
|
203
|
+
`cleo-subagent.cant` itself is unreachable.
|
|
169
204
|
|
|
170
|
-
|
|
171
|
-
|
|
205
|
+
**Global directory caveat (T14588):** `cleo agent create --global` and the
|
|
206
|
+
seed installer use `<cleoHome>/cant/agents/`, but
|
|
207
|
+
`cleo agent install --global` writes to `<cleoHome>/agents/`
|
|
208
|
+
(`getCleoGlobalAgentsDir`). `<cleoHome>` is `~/.local/share/cleo` on Linux and
|
|
209
|
+
`~/Library/Application Support/cleo` on macOS.
|
|
172
210
|
|
|
173
211
|
## Contract Guarantees
|
|
174
212
|
|
|
175
|
-
- **Atomic install
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
-
|
|
182
|
-
|
|
183
|
-
|
|
213
|
+
- **Atomic install**: `installAgentFromCant` copies the `.cant` file, upserts
|
|
214
|
+
the `agent_registry_agents` row and rewrites its
|
|
215
|
+
`agent_registry_agent_skills` junctions in one `BEGIN IMMEDIATE`
|
|
216
|
+
transaction. An existing row without `force` fails with
|
|
217
|
+
`E_AGENT_ALREADY_INSTALLED`.
|
|
218
|
+
- **Idempotent seed install**: `packages/core/src/agents/seed-install.ts`
|
|
219
|
+
compares `<cleoHome>/.seed-version` against the bundled version and returns
|
|
220
|
+
early when they match.
|
|
221
|
+
- **Doctor drift reporting**: `packages/core/src/store/agent-doctor.ts` emits
|
|
222
|
+
D-001…D-010 (orphan file, orphan row, SHA mismatch, unattached global,
|
|
223
|
+
missing or extra skills, parse error, legacy path, deprecated agent still
|
|
224
|
+
live, legacy JSON registry). `cleo agent doctor --repair` applies the safe
|
|
225
|
+
repairs (D-002 orphan-row delete, D-003 hash refresh).
|
|
184
226
|
|
|
185
227
|
## See Also
|
|
186
228
|
|
|
187
|
-
- [ADR-055
|
|
188
|
-
- [ADR-068
|
|
189
|
-
- [Package boundary contract](../../AGENTS.md)
|
|
190
|
-
- [Meta-agents guide](../../docs/guide/meta-agents.md)
|
|
229
|
+
- [ADR-055: Agents Architecture + Meta-Agents](../../docs/adr/adr-055-agents-architecture-and-meta-agents.md) (partially superseded by ADR-068)
|
|
230
|
+
- [ADR-068: Canonical Agent System](../../docs/adr/adr-068-canonical-agent-system.md)
|
|
231
|
+
- [Package boundary contract](../../AGENTS.md): layering for every CLEO package
|
|
232
|
+
- [Meta-agents guide](../../docs/guide/meta-agents.md): authoring meta-agents
|
|
191
233
|
|
|
192
234
|
## License
|
|
193
235
|
|
|
194
|
-
MIT
|
|
236
|
+
MIT. See [LICENSE](../../LICENSE).
|