@cleocode/agents

中文文档
2026.11.1发布于 2026/11/12MITES Module零依赖构建来源已验证近 30 天下载 1.3万

CLEO agent protocols and templates

原始使用文档
文档目录19 节
  1. Scope (ADR-068 — v2026.5.30 and later)
  2. Package Tree
  3. The Universal Protocol Base: cleo-subagent.cant
  4. Canonical Worker Templates
  5. Naming Contract (ADR-068 Decision 1)
  6. How Variables Work
  7. Syntax
  8. Resolver Chain (ADR-068 Decision 5)
  9. Why Lazy (Spawn-Time)?
  10. Auto-Installation on cleo init
  11. Authoring a New Agent
  12. 1. Start from a template or from cleo-subagent.cant
  13. 2. Validate the CANT syntax
  14. 3. Install into the registry
  15. 4. Verify resolver coverage
  16. Tier Precedence (Resolver Chain)
  17. Contract Guarantees
  18. See Also
  19. License

@cleocode/agents

Part of CLEO. Start with the root README; run cleo <command> --help for any command.

Universal subagent protocol, canonical worker templates, and meta-agents for the CLEO ecosystem.

Scope (ADR-068 — v2026.5.30 and later)

Per ADR-068, this package ships exactly three surfaces:

  1. cleo-subagent.cant — the universal protocol base every agent extends.
  2. templates/ — five named worker templates with {{variable}} placeholders. Filename basename equals declared agent <name>: per the install-validator contract.
  3. meta/ — meta-agents that synthesize other agents from project context.

CleoCode-team dogfood personas (the former cleo-prime, cleo-dev, cleo-historian, cleo-rust-lead, cleo-db-lead, cleoos-opus-orchestrator) live in .cleo/cant/agents/ in the cleocode repository and are NOT shipped to users.

Package Tree

packages/agents/
├── package.json
├── README.md                                 # this file
├── cleo-subagent.cant                        # universal protocol base
├── templates/
│   ├── project-orchestrator.cant             # coordinates the starter team
│   ├── project-dev-lead.cant                 # decides HOW, reviews workers
│   ├── project-code-worker.cant              # writes code within globs
│   ├── project-docs-worker.cant              # writes/edits documentation
│   └── project-security-worker.cant          # security review and audits
└── meta/
    ├── README.md
    ├── agent-architect.cant                  # meta-agent: synthesizes agents
    └── playbook-architect.cant               # meta-agent: synthesizes playbooks

The Universal Protocol Base: cleo-subagent.cant

Every CLEO agent extends cleo-subagent.cant. It defines:

  • RFC 2119 constraints (BASE-001…BASE-007) — manifest append, no content in responses, cleo complete as the terminal, output-before-manifest ordering, focus before work, no fabrication, research linking.
  • LOOM lifecycle — Spawn → Execute → Output → Return, with explicit stage-specific guidance injected at spawn time.
  • Return format contract — three allowed response strings, everything else goes to files and the manifest.
  • Error handling — status classification, retryable exit codes, staleness and evidence rules (ADR-051).

Canonical Worker Templates

The five worker templates are parameterized blueprints with {{variable}} placeholders. They MUST remain project-agnostic — no CLEO-internal references, no tool-chain assumptions beyond what the template explicitly parameterizes.

TemplateRolePurpose
project-orchestrator.cantorchestratorReads tasks, routes to the dev-lead, synthesizes results. Does not execute code.
project-dev-lead.cantleadDecomposes work, reviews output, decides technical direction. Dispatch-only authority; no Edit/Write/Bash (TEAM-002).
project-code-worker.cantworkerWrites code within declared globs. Runs {{test_command}} and {{build_command}}. Holds Edit/Write/Bash.
project-docs-worker.cantworkerWrites documentation (README, TSDoc, guides) within doc globs. Holds Edit/Write/Bash scoped to docs.
project-security-worker.cantworkerSecurity review, OWASP threat modelling, dependency audits. Read-only — escalates findings.

These five make a complete starter team: one orchestrator + one lead + three workers. For projects that need richer topologies, the agent-architect meta-agent (see below) synthesizes additional personas.

Naming Contract (ADR-068 Decision 1)

Every .cant filename basename MUST equal the agent <name>: declaration inside it. Templates use the project-<role> prefix to match the classifier output (packages/core/src/orchestration/classify.ts). This is enforced by the install validator at packages/core/src/store/agent-install.ts.

How Variables Work

CLEO uses mustache {{var}} syntax for template substitution, per ADR-055 D033.

Syntax

  • {{name}} — simple variable
  • {{object.key}} — dot-notation for nested values
  • {{inputs.taskId}} — already used in starter .cantbook playbooks

Resolver Chain (ADR-068 Decision 5)

Variables resolve in priority order at spawn time (not install time):

  1. Step bindings — highest priority; step-level bindings: shadow playbook bindings.
  2. Playbook bindings — top-level bindings: field.
  3. Session context — playbook_runs.bindings, task + epic identifiers, user.
  4. Project context — .cleo/project-context.json, traversed via dot-notation.
  5. Environment variables — CLEO_* or CANT_* prefix.
  6. Default value — when SubstitutionOptions.defaultValue is set.
  7. Missing — strict mode throws E_TEMPLATE_RESOLUTION.

Why Lazy (Spawn-Time)?

Templates install with {{...}} placeholders intact. Resolution happens inside orchestrateSpawnExecute right before composeSpawnPayload, which means:

  • The same template can spawn differently under different bindings.
  • BRAIN-provided context (mental-model slices, memory queries) can feed the resolver.
  • Project context changes are picked up on the next spawn without reinstalling.

Auto-Installation on cleo init

Per ADR-068 Decision 3, plain cleo init (no flags) automatically walks @cleocode/agents/templates/ and calls installAgentFromCant() for each of the 5 worker templates. Each template is registered in signaldock.db.agents with tier='project'.

A fresh cleo init followed by cleo orchestrate spawn for any of the 5 worker roles succeeds without E_AGENT_NOT_FOUND.

The --install-seed-agents flag is preserved as a deprecated no-op alias with a deprecation notice.

Authoring a New Agent

1. Start from a template or from cleo-subagent.cant

cp packages/agents/templates/project-code-worker.cant \
   my-project/.cleo/cant/agents/my-worker.cant

Edit the agent name, tune the description + skills + tool list, replace {{variable}} placeholders with either literal values (if project-specific) or leave them for lazy resolution at spawn time.

2. Validate the CANT syntax

cleo cant validate my-project/.cleo/cant/agents/my-worker.cant

3. Install into the registry

cleo agent install my-project/.cleo/cant/agents/my-worker.cant

4. Verify resolver coverage

cleo agent doctor --json

Tier Precedence (Resolver Chain)

Agent resolution at spawn time walks tiers in order (ADR-055 / ADR-068):

  1. project — {projectRoot}/.cleo/cant/agents/{agentId}.cant
  2. global — ~/.local/share/cleo/cant/agents/{agentId}.cant
  3. packaged — packages/agents/templates/{agentId}.cant
  4. fallback — seed file on disk with no registry row
  5. universal — cleo-subagent.cant synthesized envelope (ADR-068 Decision 6)

E_AGENT_NOT_FOUND is only thrown when cleo-subagent.cant itself is unreachable, indicating a corrupt installation.

Contract Guarantees

  • Atomic install — packages/core/src/store/agent-install.ts wraps the .cant copy, agents row upsert, and agent_skills junction rewrite in a single BEGIN IMMEDIATE TRANSACTION.
  • Idempotent seed install — packages/core/src/agents/seed-install.ts compares .seed-version against the bundled package.json version and returns early when they match.
  • Doctor drift reporting — packages/core/src/store/agent-doctor.ts emits D-001…D-010 codes for orphan files, SHA mismatch, legacy paths, missing skills, and legacy JSON registries.

See Also

License

MIT — see LICENSE.

版本与发布记录

@cleocode/agents 共发布 410 个版本,首次发布于 2026/03/19;过去 12 个月发布了 410 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2026.11.1latest2026/11/12今天
2026.11.1-rc.ci.711canary2026/11/12今天
2026.11.1-canary.122026/11/12今天
2026.11.1-canary.112026/11/12今天
2026.11.1-canary.102026/11/12今天
2026.11.1-canary.92026/11/111 天前

关于 @cleocode/agents 的常见问题

@cleocode/agents 是什么?

CLEO agent protocols and templates

如何安装 @cleocode/agents?

在项目目录运行 npm install @cleocode/agents,或使用 pnpm add / yarn add / bun add。

@cleocode/agents 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cleocode__agents 是否存在。

@cleocode/agents 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cleocode/agents 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24.16.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cleocode/agents 可以商用吗?

@cleocode/agents 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cleocode/agents 的下载量有多少?

根据 npm 官方下载统计,@cleocode/agents 在 2026/10/10 – 2026/11/08 这 30 天内被下载 13,083 次,日均约 436 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cleocode/agents 还在维护吗?

最新版本 2026.11.1 发布于 2026/11/12(今天);至今共发布 410 个版本,其中过去 12 个月发布了 410 个;首次发布于 2026/03/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。