@cleocode/cleo 2026.3.7 → 2026.3.11
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 +98 -84
- package/bin/postinstall.js +117 -0
- package/dist/cli/index.js +30167 -28866
- package/dist/cli/index.js.map +4 -4
- package/dist/mcp/index.js +26765 -24105
- package/dist/mcp/index.js.map +4 -4
- package/drizzle/20260302163443_free_silk_fever/migration.sql +1 -0
- package/drizzle/20260302163443_free_silk_fever/snapshot.json +2618 -0
- package/drizzle/20260302163457_robust_johnny_storm/migration.sql +1 -0
- package/drizzle/20260302163457_robust_johnny_storm/snapshot.json +2628 -0
- package/drizzle/20260302163511_late_sphinx/migration.sql +1 -0
- package/drizzle/20260302163511_late_sphinx/snapshot.json +2638 -0
- package/package.json +9 -4
- package/packages/ct-skills/profiles/core.json +2 -2
- package/packages/ct-skills/profiles/recommended.json +2 -2
- package/packages/ct-skills/skills/_shared/subagent-protocol-base.md +3 -1
- package/packages/ct-skills/skills/ct-cleo/SKILL.md +6 -4
- package/packages/ct-skills/skills/ct-cleo/references/{rcsd-lifecycle.md → loom-lifecycle.md} +23 -14
- package/packages/ct-skills/skills/ct-orchestrator/SKILL.md +8 -6
- package/packages/ct-skills/skills/manifest.json +1 -1
- package/packages/ct-skills/skills.json +20 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p alis|version-[0-9]\+\.[0-9]\+\.[0-9]\+-|version-2026.3.11-|g|version-[0-9]\+\.[0-9]\+\.[0-9]\+-|version-2026.3.10-|g|version-[0-9]\+\.[0-9]\+\.[0-9]\+-|version-2025.3.10-|gn="center">
|
|
2
2
|
<img src="docs/images/banner.png" alt="CLEO banner" width="900">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
13
|
<img src="https://img.shields.io/badge/License-BSL%201.1-blue" alt="License: Business Source License 1.1">
|
|
14
|
-
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-
|
|
14
|
+
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-2025.3.10-blue.svg" alt="Version"></a>
|
|
15
15
|
<a href="docs/mintlify/developer/specifications/LLM-AGENT-FIRST.mdx"><img src="https://img.shields.io/badge/design-LLM--Agent--First-purple.svg" alt="LLM-Agent-First"></a>
|
|
16
16
|
<a href="tests/"><img src="https://img.shields.io/badge/tests-passing-brightgreen.svg" alt="Tests"></a>
|
|
17
17
|
</p>
|
|
@@ -98,8 +98,8 @@ CLEO is composed of four interdependent systems:
|
|
|
98
98
|
|
|
99
99
|
| State | What It Means |
|
|
100
100
|
|------|----------------|
|
|
101
|
-
| **Shipped** | TypeScript CLI + MCP server, SQLite storage (`tasks.db`), atomic operations, four-layer anti-hallucination, RCASD-IVTR+C lifecycle gates, session management,
|
|
102
|
-
| **
|
|
101
|
+
| **Shipped** | TypeScript CLI + MCP server, SQLite storage (`tasks.db` + `brain.db`), atomic operations, four-layer anti-hallucination, RCASD-IVTR+C lifecycle gates, session management, 3-layer BRAIN retrieval (`brain.search/timeline/fetch`), BRAIN observe writes, NEXUS dispatch domain wiring (12 operations), LAFS envelopes |
|
|
102
|
+
| **In Progress / Planned** | Embedding generation + vector similarity pipeline (`T5158`/`T5159`), PageIndex traversal/query API (`T5161`), reasoning/session integration (`T5153`), `nexus.db` migration from JSON registry, full claude-mem automation retirement hooks (`T5145`) |
|
|
103
103
|
|
|
104
104
|
### MCP Server
|
|
105
105
|
|
|
@@ -142,7 +142,7 @@ Or if installed globally (`npm install -g @cleocode/cleo`):
|
|
|
142
142
|
|
|
143
143
|
Supports: Claude Code, Claude Desktop, Cursor, Gemini CLI, Kimi, Antigravity, Windsurf, Goose, OpenCode, VS Code, Zed, Codex
|
|
144
144
|
|
|
145
|
-
- Canonical MCP contract: [`docs/
|
|
145
|
+
- Canonical MCP contract: [`docs/specs/MCP-SERVER-SPECIFICATION.md`](docs/specs/MCP-SERVER-SPECIFICATION.md)
|
|
146
146
|
- MCP source: [`src/mcp/`](src/mcp/) (gateways, domains, engine)
|
|
147
147
|
- Operation matrix: `src/mcp/gateways/query.ts` and `src/mcp/gateways/mutate.ts`
|
|
148
148
|
|
|
@@ -153,7 +153,7 @@ Your AI agent gets two tools: `cleo_query` (read) and `cleo_mutate` (write). Eac
|
|
|
153
153
|
```bash
|
|
154
154
|
# Read operations (never changes anything)
|
|
155
155
|
cleo_query domain=tasks operation=find params={"query": "auth"}
|
|
156
|
-
cleo_query domain=
|
|
156
|
+
cleo_query domain=admin operation=dash
|
|
157
157
|
cleo_query domain=tasks operation=next
|
|
158
158
|
|
|
159
159
|
# Write operations (creates or modifies data)
|
|
@@ -162,15 +162,15 @@ cleo_mutate domain=tasks operation=complete params={"taskId": "T1234", "notes"
|
|
|
162
162
|
cleo_mutate domain=issues operation=add.bug params={"title": "...", "body": "...", "dryRun": true}
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
-
10 canonical domains,
|
|
165
|
+
10 canonical domains, 198 operations (110 query + 88 mutate) across tasks, sessions, memory, check, pipeline, orchestration, tools, admin, nexus, and sharing. See the [MCP Usage Guide](docs/guides/mcp-usage-guide.mdx) for beginner-friendly walkthroughs.
|
|
166
166
|
|
|
167
167
|
### Source of Truth Hierarchy
|
|
168
168
|
|
|
169
169
|
1. [`docs/concepts/vision.md`](docs/concepts/vision.md) - immutable product vision
|
|
170
|
-
2. [`docs/
|
|
170
|
+
2. [`docs/specs/PORTABLE-BRAIN-SPEC.md`](docs/specs/PORTABLE-BRAIN-SPEC.md) - canonical normative contract
|
|
171
171
|
3. [`README.md`](README.md) - operational public contract
|
|
172
|
-
4. [`docs/
|
|
173
|
-
5. [`docs/
|
|
172
|
+
4. [`docs/specs/CLEO-STRATEGIC-ROADMAP-SPEC.md`](docs/specs/CLEO-STRATEGIC-ROADMAP-SPEC.md) - phased execution plan
|
|
173
|
+
5. [`docs/specs/CLEO-BRAIN-SPECIFICATION.md`](docs/specs/CLEO-BRAIN-SPECIFICATION.md) - detailed capability model
|
|
174
174
|
|
|
175
175
|
---
|
|
176
176
|
|
|
@@ -204,7 +204,7 @@ cleo list | jq '.tasks[0].id' # Parse with jq
|
|
|
204
204
|
# Human-readable when you need it (developer-friendly)
|
|
205
205
|
cleo list --human # Formatted text output
|
|
206
206
|
|
|
207
|
-
# Exit codes for programmatic branching (
|
|
207
|
+
# Exit codes for programmatic branching (82 unique codes across 13 ranges)
|
|
208
208
|
cleo exists T042 --quiet && echo "Found"
|
|
209
209
|
```
|
|
210
210
|
|
|
@@ -269,36 +269,36 @@ cleo-dev env info --json
|
|
|
269
269
|
|
|
270
270
|
### TL;DR - Just Install It
|
|
271
271
|
|
|
272
|
-
**Option 1:
|
|
272
|
+
**Option 1: NPM (Recommended)**
|
|
273
273
|
|
|
274
274
|
```bash
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
# Reinstalling over existing installation? Use --force:
|
|
278
|
-
curl -fsSL https://github.com/kryptobaseddev/cleo/releases/latest/download/install.sh | bash -s -- --force
|
|
275
|
+
npm install -g @cleocode/cleo
|
|
279
276
|
```
|
|
280
277
|
|
|
281
|
-
|
|
278
|
+
This automatically bootstraps the global CLEO system:
|
|
279
|
+
- Sets up `~/.cleo/` with templates and configuration
|
|
280
|
+
- Installs MCP server to detected AI providers (Claude Code, Cursor, etc.)
|
|
281
|
+
- Creates `~/.agents/AGENTS.md` hub for agent instructions
|
|
282
282
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
283
|
+
Then initialize in any project:
|
|
284
|
+
```bash
|
|
285
|
+
cd /path/to/your/project && cleo init
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Option 2: One-liner Bash (Legacy/Offline)**
|
|
288
289
|
|
|
289
|
-
|
|
290
|
+
For systems without npm or offline installs:
|
|
290
291
|
```bash
|
|
291
|
-
|
|
292
|
-
bash ~/Downloads/install.sh
|
|
292
|
+
curl -fsSL https://github.com/kryptobaseddev/cleo/releases/latest/download/install.sh | bash
|
|
293
293
|
```
|
|
294
294
|
|
|
295
|
-
**Option 3: From source (
|
|
295
|
+
**Option 3: From source (Contributors)**
|
|
296
296
|
|
|
297
297
|
```bash
|
|
298
298
|
git clone https://github.com/kryptobaseddev/cleo.git && cd cleo && ./installer/install.sh --dev
|
|
299
299
|
```
|
|
300
300
|
|
|
301
|
-
Then
|
|
301
|
+
Then use `cleo-dev` for isolated development:
|
|
302
302
|
```bash
|
|
303
303
|
cd /path/to/your/project && cleo-dev init
|
|
304
304
|
```
|
|
@@ -327,25 +327,43 @@ cd /path/to/your/project && cleo-dev init
|
|
|
327
327
|
<details>
|
|
328
328
|
<summary><strong>Detailed Installation Options</strong></summary>
|
|
329
329
|
|
|
330
|
-
####
|
|
330
|
+
#### NPM Install (Recommended for Users)
|
|
331
|
+
|
|
332
|
+
The NPM package auto-bootstraps the global CLEO system on install:
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
# Install from npm registry
|
|
336
|
+
npm install -g @cleocode/cleo
|
|
337
|
+
|
|
338
|
+
# Or install specific version
|
|
339
|
+
npm install -g @cleocode/cleo@2026.3.10
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
What happens during install:
|
|
343
|
+
1. Creates `~/.cleo/` directory structure
|
|
344
|
+
2. Installs global templates (`CLEO-INJECTION.md`)
|
|
345
|
+
3. Detects AI providers and installs MCP server configs
|
|
346
|
+
4. Creates `~/.agents/AGENTS.md` hub
|
|
331
347
|
|
|
332
|
-
|
|
333
|
-
2. Download `cleo-X.Y.Z.tar.gz`
|
|
334
|
-
3. Extract and install:
|
|
335
|
-
```bash
|
|
336
|
-
tar xzf cleo-*.tar.gz
|
|
337
|
-
cd cleo-*
|
|
338
|
-
./installer/install.sh
|
|
339
|
-
```
|
|
348
|
+
#### Initialize in Your Project
|
|
340
349
|
|
|
341
|
-
|
|
350
|
+
After global install, initialize each project:
|
|
342
351
|
|
|
343
352
|
```bash
|
|
344
|
-
|
|
353
|
+
cd /path/to/your/project
|
|
354
|
+
cleo init
|
|
345
355
|
```
|
|
346
356
|
|
|
357
|
+
This creates only the local project structure:
|
|
358
|
+
- `./.cleo/` directory with `config.json` and `tasks.db`
|
|
359
|
+
- Registers project with NEXUS
|
|
360
|
+
- Sets up git hooks
|
|
361
|
+
- Injects CLEO references into local `AGENTS.md`
|
|
362
|
+
|
|
347
363
|
#### From Source (for Contributors)
|
|
348
364
|
|
|
365
|
+
For CLEO development or testing unreleased changes:
|
|
366
|
+
|
|
349
367
|
```bash
|
|
350
368
|
# Clone repository
|
|
351
369
|
git clone https://github.com/kryptobaseddev/cleo.git
|
|
@@ -356,38 +374,37 @@ cd cleo
|
|
|
356
374
|
|
|
357
375
|
# Verify isolated runtime
|
|
358
376
|
cleo-dev env info --json
|
|
359
|
-
|
|
360
|
-
# Or install as release (copies files)
|
|
361
|
-
./installer/install.sh --release
|
|
362
377
|
```
|
|
363
378
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
379
|
+
The dev channel uses:
|
|
380
|
+
- Isolated commands: `cleo-dev` (no `ct` alias)
|
|
381
|
+
- Isolated home: `~/.cleo-dev/`
|
|
382
|
+
- Symlinks to repo for rapid iteration
|
|
367
383
|
|
|
368
|
-
|
|
369
|
-
cleo version
|
|
370
|
-
cleo env info --json
|
|
371
|
-
```
|
|
384
|
+
`npm link` caveat: raw `npm link` follows package bin mappings and can expose `cleo`/`ct`. Use `./installer/install.sh --dev` when you need strict `cleo-dev` isolation.
|
|
372
385
|
|
|
373
|
-
|
|
386
|
+
#### Legacy Bash Installer (Offline/Restricted Systems)
|
|
374
387
|
|
|
375
|
-
|
|
388
|
+
For systems without npm access:
|
|
376
389
|
|
|
377
390
|
```bash
|
|
378
|
-
|
|
379
|
-
cleo
|
|
391
|
+
# One-liner install
|
|
392
|
+
curl -fsSL https://github.com/kryptobaseddev/cleo/releases/latest/download/install.sh | bash
|
|
393
|
+
|
|
394
|
+
# Or download and run manually
|
|
395
|
+
bash install.sh
|
|
380
396
|
```
|
|
381
397
|
|
|
382
|
-
|
|
398
|
+
This copies files (not symlinks) and provides the same functionality as npm install.
|
|
399
|
+
|
|
400
|
+
#### Verify Installation
|
|
383
401
|
|
|
384
402
|
```bash
|
|
385
|
-
|
|
386
|
-
cleo
|
|
403
|
+
cleo version
|
|
404
|
+
cleo env info --json
|
|
405
|
+
cleo doctor
|
|
387
406
|
```
|
|
388
407
|
|
|
389
|
-
> **Note**: The installer creates symlinks in `~/.local/bin/`, which works immediately with Claude Code and most modern shells.
|
|
390
|
-
|
|
391
408
|
</details>
|
|
392
409
|
|
|
393
410
|
<details>
|
|
@@ -516,7 +533,7 @@ cleo start <TAB> # Shows pending/active task IDs
|
|
|
516
533
|
<details>
|
|
517
534
|
<summary><h2>Command Reference</h2></summary>
|
|
518
535
|
|
|
519
|
-
###
|
|
536
|
+
### 86 Commands Across 5 Categories
|
|
520
537
|
|
|
521
538
|
| Category | Commands | Purpose |
|
|
522
539
|
|----------|----------|---------|
|
|
@@ -772,7 +789,7 @@ cleo list --format text # Same as --human
|
|
|
772
789
|
|
|
773
790
|
### Exit Codes
|
|
774
791
|
|
|
775
|
-
|
|
792
|
+
82 unique exit codes across 13 ranges for programmatic handling:
|
|
776
793
|
|
|
777
794
|
| Range | Purpose | Examples |
|
|
778
795
|
|-------|---------|----------|
|
|
@@ -912,17 +929,17 @@ CLEO_FORMAT=json # Force output format
|
|
|
912
929
|
~/.cleo/ # Global installation
|
|
913
930
|
├── nexus.db # Cross-project network: registry, graph, permissions (gated)
|
|
914
931
|
├── config.json # Global CLEO configuration
|
|
915
|
-
├── skills/ # Modular agent skills (
|
|
932
|
+
├── skills/ # Modular agent skills (15 skills)
|
|
916
933
|
│ ├── manifest.json # Skill registry with versions
|
|
917
934
|
│ ├── ct-epic-architect/ # Epic creation skill
|
|
918
935
|
│ ├── ct-orchestrator/ # Workflow coordination
|
|
919
|
-
│ └── ... #
|
|
936
|
+
│ └── ... # 13 more skills
|
|
920
937
|
├── templates/ # Starter templates
|
|
921
938
|
└── docs/ # Documentation
|
|
922
939
|
|
|
923
940
|
your-project/.cleo/ # Per-project instance
|
|
924
941
|
├── tasks.db # Project work: tasks, sessions, lifecycle, audit (SQLite)
|
|
925
|
-
├── brain.db # Memory & cognition: observations, patterns, learnings (
|
|
942
|
+
├── brain.db # Memory & cognition: observations, patterns, learnings, decisions, links (shipped)
|
|
926
943
|
├── config.json # Runtime settings: policies, validation, session behavior
|
|
927
944
|
├── project-info.json # Project identity: projectHash, schema versions, health
|
|
928
945
|
├── project-context.json # LLM agent metadata: language, framework, conventions
|
|
@@ -1030,7 +1047,7 @@ CLEO uses a **2-tier subagent architecture** for multi-agent coordination:
|
|
|
1030
1047
|
|
|
1031
1048
|
> **Architecture Reference**: See [CLEO-SUBAGENT.md](docs/architecture/CLEO-SUBAGENT.md) for complete documentation.
|
|
1032
1049
|
|
|
1033
|
-
CLEO includes
|
|
1050
|
+
CLEO includes 15 modular skills for AI agent workflows:
|
|
1034
1051
|
|
|
1035
1052
|
### Token Injection System (v0.60.0+)
|
|
1036
1053
|
|
|
@@ -1045,21 +1062,17 @@ The token injection system provides validated placeholder replacement for skill
|
|
|
1045
1062
|
|
|
1046
1063
|
Token validation prevents hallucinated or malformed values from reaching skill templates.
|
|
1047
1064
|
|
|
1048
|
-
### Orchestrator Automation
|
|
1049
|
-
|
|
1050
|
-
The `orchestrator_spawn_for_task()` function consolidates subagent spawning into a single call:
|
|
1065
|
+
### Orchestrator Automation
|
|
1051
1066
|
|
|
1052
|
-
|
|
1053
|
-
# Programmatic spawning (from lib/orchestrator-spawn.sh)
|
|
1054
|
-
source lib/orchestrator-spawn.sh
|
|
1055
|
-
prompt=$(orchestrator_spawn_for_task "T1234") # Default protocol
|
|
1056
|
-
prompt=$(orchestrator_spawn_for_task "T1234" "ct-research-agent") # Specific protocol
|
|
1067
|
+
Subagent spawning is handled via the MCP orchestration domain:
|
|
1057
1068
|
|
|
1058
|
-
|
|
1059
|
-
#
|
|
1069
|
+
```
|
|
1070
|
+
# Spawn a subagent for a task (via MCP)
|
|
1071
|
+
cleo_mutate orchestrate.spawn { taskId: "T1234" }
|
|
1072
|
+
cleo_mutate orchestrate.spawn { taskId: "T1234", skill: "ct-research-agent" }
|
|
1060
1073
|
```
|
|
1061
1074
|
|
|
1062
|
-
|
|
1075
|
+
The spawn pipeline (implemented in `src/core/skills/orchestrator/spawn.ts`) automates: task validation, context loading, token injection, template rendering, and prompt generation.
|
|
1063
1076
|
|
|
1064
1077
|
### Installed Skills (Protocol Identifiers)
|
|
1065
1078
|
|
|
@@ -1067,20 +1080,21 @@ Automates: task validation, context loading, token injection, template rendering
|
|
|
1067
1080
|
|
|
1068
1081
|
| Skill Protocol | Purpose |
|
|
1069
1082
|
|----------------|---------|
|
|
1070
|
-
| `ct-
|
|
1071
|
-
| `ct-
|
|
1083
|
+
| `ct-cleo` | Core CLEO protocol and session management |
|
|
1084
|
+
| `ct-contribution` | Contribution workflow protocol |
|
|
1085
|
+
| `ct-dev-workflow` | Developer workflow automation |
|
|
1072
1086
|
| `ct-docs-lookup` | Documentation search via Context7 |
|
|
1073
|
-
| `ct-docs-write` | Documentation generation |
|
|
1074
1087
|
| `ct-docs-review` | Documentation compliance review |
|
|
1088
|
+
| `ct-docs-write` | Documentation generation |
|
|
1089
|
+
| `ct-documentor` | Documentation orchestration |
|
|
1090
|
+
| `ct-epic-architect` | Create epics with task decomposition |
|
|
1091
|
+
| `ct-grade` | Quality grading and assessment |
|
|
1092
|
+
| `ct-orchestrator` | Multi-agent workflow coordination |
|
|
1075
1093
|
| `ct-research-agent` | Multi-source research protocol |
|
|
1076
|
-
| `ct-
|
|
1094
|
+
| `ct-skill-creator` | Create new skills |
|
|
1077
1095
|
| `ct-spec-writer` | Technical specification writing |
|
|
1078
|
-
| `ct-
|
|
1096
|
+
| `ct-task-executor` | Generic task execution protocol |
|
|
1079
1097
|
| `ct-validator` | Compliance validation |
|
|
1080
|
-
| `ct-skill-creator` | Create new skills |
|
|
1081
|
-
| `ct-skill-lookup` | Search prompts.chat skills |
|
|
1082
|
-
| `ct-library-implementer-bash` | Bash library creation |
|
|
1083
|
-
| `ct-documentor` | Documentation orchestration |
|
|
1084
1098
|
|
|
1085
1099
|
### Skills Installation
|
|
1086
1100
|
|
|
@@ -1176,7 +1190,7 @@ See [docs/PLUGINS.md](docs/PLUGINS.md) for extension development.
|
|
|
1176
1190
|
| Problem | Solution |
|
|
1177
1191
|
|---------|----------|
|
|
1178
1192
|
| `command not found` | Check `~/.local/bin` in PATH, run `source ~/.bashrc` |
|
|
1179
|
-
| `Permission denied` |
|
|
1193
|
+
| `Permission denied` | Check `~/.local/bin` permissions, ensure CLEO binaries are executable |
|
|
1180
1194
|
| `Invalid JSON` | `cleo validate --fix` or `cleo restore` |
|
|
1181
1195
|
| `Duplicate ID` | `cleo validate --fix` or `cleo restore` |
|
|
1182
1196
|
| `Checksum mismatch` | `cleo validate --fix` |
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* NPM Postinstall Hook - Bootstrap Global CLEO System
|
|
4
|
+
*
|
|
5
|
+
* This script runs automatically after `npm install -g @cleocode/cleo`.
|
|
6
|
+
* It bootstraps the global CLEO system:
|
|
7
|
+
* - Creates ~/.cleo/ directory structure
|
|
8
|
+
* - Installs global templates (CLEO-INJECTION.md)
|
|
9
|
+
* - Sets up CAAMP provider configs
|
|
10
|
+
* - Installs MCP server to detected providers
|
|
11
|
+
* - Creates ~/.agents/AGENTS.md hub
|
|
12
|
+
*
|
|
13
|
+
* This is the ONLY place global setup should happen. Project `cleo init`
|
|
14
|
+
* only creates local ./.cleo/ and registers with NEXUS.
|
|
15
|
+
*
|
|
16
|
+
* @task T5267
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { existsSync } from 'node:fs';
|
|
20
|
+
import { mkdir, writeFile, readFile, copyFile } from 'node:fs/promises';
|
|
21
|
+
import { join, dirname, resolve } from 'node:path';
|
|
22
|
+
import { homedir } from 'node:os';
|
|
23
|
+
import { fileURLToPath } from 'node:url';
|
|
24
|
+
|
|
25
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
26
|
+
const __dirname = dirname(__filename);
|
|
27
|
+
|
|
28
|
+
// Determine if we're running from npm global install or local dev
|
|
29
|
+
function isNpmGlobalInstall() {
|
|
30
|
+
const execPath = process.argv[1] || '';
|
|
31
|
+
// Check if running from node_modules/@cleocode/cleo/
|
|
32
|
+
return execPath.includes('node_modules/@cleocode/cleo/') ||
|
|
33
|
+
execPath.includes('node_modules\\@cleocode\\cleo\\');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Get package root
|
|
37
|
+
function getPackageRoot() {
|
|
38
|
+
// When running from bin/, go up to package root
|
|
39
|
+
return resolve(__dirname, '..');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function bootstrapGlobalCleo() {
|
|
43
|
+
// Only run for npm global installs, not local dev or other contexts
|
|
44
|
+
if (!isNpmGlobalInstall()) {
|
|
45
|
+
console.log('CLEO: Skipping global bootstrap (not npm global install)');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
console.log('CLEO: Bootstrapping global system...');
|
|
50
|
+
|
|
51
|
+
const cleoHome = join(homedir(), '.cleo');
|
|
52
|
+
const globalTemplatesDir = join(cleoHome, 'templates');
|
|
53
|
+
const globalAgentsDir = join(homedir(), '.agents');
|
|
54
|
+
|
|
55
|
+
// Create directories
|
|
56
|
+
await mkdir(globalTemplatesDir, { recursive: true });
|
|
57
|
+
await mkdir(globalAgentsDir, { recursive: true });
|
|
58
|
+
|
|
59
|
+
// Copy CLEO-INJECTION.md template
|
|
60
|
+
const packageRoot = getPackageRoot();
|
|
61
|
+
const templateSource = join(packageRoot, 'templates', 'CLEO-INJECTION.md');
|
|
62
|
+
const templateDest = join(globalTemplatesDir, 'CLEO-INJECTION.md');
|
|
63
|
+
|
|
64
|
+
if (existsSync(templateSource)) {
|
|
65
|
+
await copyFile(templateSource, templateDest);
|
|
66
|
+
console.log('CLEO: Installed global template (CLEO-INJECTION.md)');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Setup CAAMP and MCP (these may fail gracefully if CAAMP isn't fully configured yet)
|
|
70
|
+
try {
|
|
71
|
+
const { getInstalledProviders, inject, buildInjectionContent } = await import('@cleocode/caamp');
|
|
72
|
+
|
|
73
|
+
// Create ~/.agents/AGENTS.md with CLEO block
|
|
74
|
+
const globalAgentsMd = join(globalAgentsDir, 'AGENTS.md');
|
|
75
|
+
let agentsContent = '';
|
|
76
|
+
|
|
77
|
+
if (existsSync(globalAgentsMd)) {
|
|
78
|
+
agentsContent = await readFile(globalAgentsMd, 'utf-8');
|
|
79
|
+
// Strip old CLEO blocks
|
|
80
|
+
agentsContent = agentsContent.replace(/\n?<!-- CLEO:START -->[\s\S]*?<!-- CLEO:END -->\n?/g, '');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Inject CLEO reference
|
|
84
|
+
await inject(globalAgentsMd, '@~/.cleo/templates/CLEO-INJECTION.md');
|
|
85
|
+
console.log('CLEO: Updated ~/.agents/AGENTS.md');
|
|
86
|
+
|
|
87
|
+
// Install MCP server to detected providers
|
|
88
|
+
const providers = getInstalledProviders();
|
|
89
|
+
if (providers.length > 0) {
|
|
90
|
+
const { generateMcpServerEntry, getMcpServerName } = await import('../dist/core/mcp/index.js');
|
|
91
|
+
const { installMcpServerToAll } = await import('@cleocode/caamp');
|
|
92
|
+
|
|
93
|
+
// Detect environment (stable/beta/dev)
|
|
94
|
+
const env = generateMcpServerEntry.length === 1
|
|
95
|
+
? { mode: 'stable', source: 'npm' }
|
|
96
|
+
: { mode: 'stable', source: 'npm' };
|
|
97
|
+
|
|
98
|
+
const serverEntry = generateMcpServerEntry(env);
|
|
99
|
+
const serverName = getMcpServerName(env);
|
|
100
|
+
|
|
101
|
+
await installMcpServerToAll(providers, serverName, serverEntry, 'global', process.cwd());
|
|
102
|
+
console.log(`CLEO: Installed MCP server to ${providers.length} provider(s)`);
|
|
103
|
+
}
|
|
104
|
+
} catch (err) {
|
|
105
|
+
// CAAMP/MCP setup is optional at install time - will be set up on first use
|
|
106
|
+
console.log('CLEO: CAAMP/MCP setup deferred (will complete on first use)');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
console.log('CLEO: Global bootstrap complete!');
|
|
110
|
+
console.log('CLEO: Run "cleo init" in any project to set up local CLEO.');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Run bootstrap
|
|
114
|
+
bootstrapGlobalCleo().catch(err => {
|
|
115
|
+
console.error('CLEO: Bootstrap error (non-fatal):', err.message);
|
|
116
|
+
process.exit(0); // Never fail npm install
|
|
117
|
+
});
|