@cleocode/agents 2026.11.11 → 2026.11.12-rc.ci.729

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.
Files changed (2) hide show
  1. package/README.md +144 -102
  2. 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
- Universal subagent protocol, canonical worker templates, and meta-agents for the
6
- CLEO ecosystem.
5
+ The universal subagent protocol, canonical lead and worker definitions, worker
6
+ templates, and meta-agents for CLEO.
7
7
 
8
- ## Scope (ADR-068 — v2026.5.30 and later)
8
+ ## Scope (ADR-068)
9
9
 
10
- Per [ADR-068](../../docs/adr/adr-068-canonical-agent-system.md), this package ships
11
- exactly three surfaces:
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`** — the universal protocol base every agent extends.
14
- 2. **`templates/`** — five named worker templates with `{{variable}}` placeholders.
15
- Filename basename equals declared `agent <name>:` per the install-validator contract.
16
- 3. **`meta/`** — meta-agents that synthesize other agents from project context.
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
- CleoCode-team dogfood personas (the former `cleo-prime`, `cleo-dev`,
19
- `cleo-historian`, `cleo-rust-lead`, `cleo-db-lead`, `cleoos-opus-orchestrator`)
20
- live in `.cleo/cant/agents/` in the cleocode repository and are NOT shipped to
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
- └── meta/
37
- ├── README.md
38
- ├── agent-architect.cant # meta-agent: synthesizes agents
39
- └── playbook-architect.cant # meta-agent: synthesizes playbooks
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
- Every CLEO agent extends `cleo-subagent.cant`. It defines:
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** (BASE-001…BASE-007) — manifest append, no content in
47
- responses, `cleo complete` as the terminal, output-before-manifest ordering,
48
- focus before work, no fabrication, research linking.
49
- - **LOOM lifecycle** — Spawn → Execute → Output → Return, with explicit
50
- stage-specific guidance injected at spawn time.
51
- - **Return format contract** — three allowed response strings, everything else
52
- goes to files and the manifest.
53
- - **Error handling** — status classification, retryable exit codes, staleness
54
- and evidence rules (ADR-051).
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 Templates
67
+ ## Canonical Lead and Worker (`definitions/`)
57
68
 
58
- The five worker templates are parameterized blueprints with `{{variable}}`
59
- placeholders. They MUST remain project-agnostic — no CLEO-internal references,
60
- no tool-chain assumptions beyond what the template explicitly parameterizes.
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 tasks, routes to the dev-lead, synthesizes results. Does not execute code. |
65
- | `project-dev-lead.cant` | lead | Decomposes work, reviews output, decides technical direction. Dispatch-only authority; no Edit/Write/Bash (TEAM-002). |
66
- | `project-code-worker.cant` | worker | Writes code within declared globs. Runs `{{test_command}}` and `{{build_command}}`. Holds Edit/Write/Bash. |
67
- | `project-docs-worker.cant` | worker | Writes documentation (README, TSDoc, guides) within doc globs. Holds Edit/Write/Bash scoped to docs. |
68
- | `project-security-worker.cant` | worker | Security review, OWASP threat modelling, dependency audits. Read-only — escalates findings. |
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
- These five make a complete starter team: one orchestrator + one lead + three
71
- workers. For projects that need richer topologies, the `agent-architect`
72
- meta-agent (see below) synthesizes additional personas.
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 inside
77
- it. Templates use the `project-<role>` prefix to match the classifier output
78
- (`packages/core/src/orchestration/classify.ts`). This is enforced by the install
79
- validator at `packages/core/src/store/agent-install.ts`.
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
- CLEO uses mustache `{{var}}` syntax for template substitution, per
84
- [ADR-055 D033](../../docs/adr/adr-055-agents-architecture-and-meta-agents.md).
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}}` — simple variable
89
- - `{{object.key}}` — dot-notation for nested values
90
- - `{{inputs.taskId}}` — already used in starter `.cantbook` playbooks
113
+ - `{{name}}`: simple variable
114
+ - `{{object.key}}`: dot-notation into the project context
115
+ - `{{inputs.taskId}}`: already used in `.cantbook` playbooks
91
116
 
92
- ### Resolver Chain (ADR-068 Decision 5)
117
+ Resolved values are never re-scanned, so a value containing `{{...}}` stays
118
+ literal.
93
119
 
94
- Variables resolve in priority order at **spawn time** (not install time):
120
+ ### Resolution Order
95
121
 
96
- 1. **Step bindings** — highest priority; step-level `bindings:` shadow playbook bindings.
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
- ### Why Lazy (Spawn-Time)?
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
- Templates install with `{{...}}` placeholders intact. Resolution happens inside
107
- `orchestrateSpawnExecute` right before `composeSpawnPayload`, which means:
134
+ ### Spawn-Time Resolution
108
135
 
109
- - The same template can spawn differently under different bindings.
110
- - BRAIN-provided context (mental-model slices, memory queries) can feed the
111
- resolver.
112
- - Project context changes are picked up on the next spawn without reinstalling.
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-Installation on `cleo init`
144
+ ## Auto-Registration on `cleo init`
115
145
 
116
- Per ADR-068 Decision 3, plain `cleo init` (no flags) automatically walks
117
- `@cleocode/agents/templates/` and calls `installAgentFromCant()` for each of the
118
- 5 worker templates. Each template is registered as an `agent_registry_agents`
119
- row in the global `cleo.db` (`packages/core/src/store/agent-install.ts`) with
120
- `tier='project'`. (`signaldock.db` is retired; its tables moved into the global
121
- store with the `agent_registry_` prefix.)
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
- A fresh `cleo init` followed by `cleo orchestrate spawn` for any of the 5 worker
124
- roles succeeds without `E_AGENT_NOT_FOUND`.
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
- Edit the agent name, tune the description + skills + tool list, replace
139
- `{{variable}}` placeholders with either literal values (if project-specific) or
140
- leave them for lazy resolution at spawn time.
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. Verify resolver coverage
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
- Agent resolution at spawn time walks tiers in order (ADR-055 / ADR-068):
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
- 1. **project** — `{projectRoot}/.cleo/cant/agents/{agentId}.cant`
165
- 2. **global** — `~/.local/share/cleo/cant/agents/{agentId}.cant`
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
- `E_AGENT_NOT_FOUND` is only thrown when `cleo-subagent.cant` itself is
171
- unreachable, indicating a corrupt installation.
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** — `packages/core/src/store/agent-install.ts` wraps the
176
- `.cant` copy, `agents` row upsert, and `agent_skills` junction rewrite in a
177
- single `BEGIN IMMEDIATE TRANSACTION`.
178
- - **Idempotent seed install** — `packages/core/src/agents/seed-install.ts`
179
- compares `.seed-version` against the bundled `package.json` version and
180
- returns early when they match.
181
- - **Doctor drift reporting** — `packages/core/src/store/agent-doctor.ts` emits
182
- D-001…D-010 codes for orphan files, SHA mismatch, legacy paths, missing
183
- skills, and legacy JSON registries.
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 — Agents Architecture + Meta-Agents](../../docs/adr/adr-055-agents-architecture-and-meta-agents.md) (partially superseded by ADR-068)
188
- - [ADR-068 — Canonical Agent System](../../docs/adr/adr-068-canonical-agent-system.md) (active canonical reference)
189
- - [Package boundary contract](../../AGENTS.md) — canonical layering for every CLEO package
190
- - [Meta-agents guide](../../docs/guide/meta-agents.md) — authoring meta-agents
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 — see [LICENSE](../../LICENSE).
236
+ MIT. See [LICENSE](../../LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleocode/agents",
3
- "version": "2026.11.11",
3
+ "version": "2026.11.12-rc.ci.729",
4
4
  "description": "CLEO agent protocols and templates",
5
5
  "type": "module",
6
6
  "license": "MIT",