@cleocode/core 2026.3.53 → 2026.3.55

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/dist/paths.d.ts CHANGED
@@ -145,6 +145,17 @@ export declare function getCleoTempDir(): string;
145
145
  * Linux: ~/.config/cleo | macOS: ~/Library/Preferences/cleo | Windows: %APPDATA%\cleo\Config
146
146
  */
147
147
  export declare function getCleoConfigDir(): string;
148
+ /**
149
+ * Get the CLEO templates directory as a tilde-prefixed path for use
150
+ * in `@` references (AGENTS.md, CLAUDE.md, etc.). Cross-platform:
151
+ * replaces the user's home directory with `~` so the reference works
152
+ * when loaded by LLM providers that resolve `~` at runtime.
153
+ *
154
+ * Linux: ~/.local/share/cleo/templates
155
+ * macOS: ~/Library/Application Support/cleo/templates
156
+ * Windows: ~/AppData/Local/cleo/Data/templates (approximate)
157
+ */
158
+ export declare function getCleoTemplatesTildePath(): string;
148
159
  /**
149
160
  * Get the global agents hub directory.
150
161
  * Respects AGENTS_HOME env var, defaults to ~/.agents.
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAIlE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED;;;;GAIG;AAC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1,6 @@
1
1
  {
2
2
  "name": "@cleocode/core",
3
- "version": "2026.3.53",
3
+ "version": "2026.3.55",
4
4
  "description": "CLEO core business logic kernel — tasks, sessions, memory, orchestration, lifecycle, with bundled SQLite store",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -36,10 +36,10 @@
36
36
  "write-file-atomic": "^6.0.0",
37
37
  "yaml": "^2.8.2",
38
38
  "zod": "^3.25.76",
39
- "@cleocode/adapters": "2026.3.53",
40
- "@cleocode/contracts": "2026.3.53",
41
- "@cleocode/agents": "2026.3.53",
42
- "@cleocode/skills": "2026.3.53"
39
+ "@cleocode/adapters": "2026.3.55",
40
+ "@cleocode/agents": "2026.3.55",
41
+ "@cleocode/contracts": "2026.3.55",
42
+ "@cleocode/skills": "2026.3.55"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=24.0.0"
@@ -50,18 +50,18 @@ describe('CLEO-INJECTION v2.1.0 minimal-only template', () => {
50
50
 
51
51
  it('includes Mandatory Efficiency Sequence', () => {
52
52
  expect(content).toContain('## Mandatory Efficiency Sequence');
53
- expect(content).toContain('query session status');
54
- expect(content).toContain('query admin dash');
55
- expect(content).toContain('query tasks current');
56
- expect(content).toContain('query tasks next');
57
- expect(content).toContain('query tasks show');
53
+ expect(content).toContain('cleo session status');
54
+ expect(content).toContain('cleo dash');
55
+ expect(content).toContain('cleo current');
56
+ expect(content).toContain('cleo next');
57
+ expect(content).toContain('cleo show');
58
58
  });
59
59
 
60
60
  it('includes Agent Work Loop', () => {
61
61
  expect(content).toContain('## Agent Work Loop');
62
- expect(content).toContain('tasks current');
63
- expect(content).toContain('tasks complete');
64
- expect(content).toContain('tasks next');
62
+ expect(content).toContain('cleo current');
63
+ expect(content).toContain('cleo complete');
64
+ expect(content).toContain('cleo next');
65
65
  });
66
66
 
67
67
  it('includes Context Ethics', () => {
@@ -173,9 +173,9 @@ describe('CLEO-INJECTION v2.1.0 minimal-only template', () => {
173
173
  });
174
174
 
175
175
  describe('Template size', () => {
176
- it('is under 120 lines', () => {
176
+ it('is under 160 lines', () => {
177
177
  const lines = content.split('\n').length;
178
- expect(lines).toBeLessThan(130);
178
+ expect(lines).toBeLessThan(160);
179
179
  });
180
180
 
181
181
  it('is at least 60 lines (not accidentally empty)', () => {
package/src/bootstrap.ts CHANGED
@@ -15,7 +15,7 @@ import { existsSync, readFileSync } from 'node:fs';
15
15
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
16
16
  import { homedir } from 'node:os';
17
17
  import { join } from 'node:path';
18
- import { getAgentsHome, getCleoTemplatesDir } from './paths.js';
18
+ import { getAgentsHome, getCleoTemplatesDir, getCleoTemplatesTildePath } from './paths.js';
19
19
  import { ensureGlobalHome, getPackageRoot } from './scaffold.js';
20
20
 
21
21
  // ── Types ────────────────────────────────────────────────────────────
@@ -155,8 +155,8 @@ async function injectAgentsHub(ctx: BootstrapContext): Promise<void> {
155
155
  }
156
156
 
157
157
  // CAAMP 1.8.1: inject() is idempotent AND consolidates duplicates
158
- const expectedContent = '@~/.cleo/templates/CLEO-INJECTION.md';
159
- const action = await inject(globalAgentsMd, expectedContent);
158
+ const templateRef = `@${getCleoTemplatesTildePath()}/CLEO-INJECTION.md`;
159
+ const action = await inject(globalAgentsMd, templateRef);
160
160
  ctx.created.push(`~/.agents/AGENTS.md (${action})`);
161
161
  } else {
162
162
  ctx.created.push('~/.agents/AGENTS.md (would create/update CAAMP block)');
package/src/injection.ts CHANGED
@@ -19,7 +19,7 @@ import { existsSync, readFileSync } from 'node:fs';
19
19
  import { mkdir, rm, writeFile } from 'node:fs/promises';
20
20
  import { homedir } from 'node:os';
21
21
  import { basename, join } from 'node:path';
22
- import { getAgentsHome, getCleoHome } from './paths.js';
22
+ import { getAgentsHome, getCleoHome, getCleoTemplatesTildePath } from './paths.js';
23
23
  import { getPackageRoot, stripCLEOBlocks } from './scaffold.js';
24
24
 
25
25
  // ── Types ────────────────────────────────────────────────────────────
@@ -169,7 +169,7 @@ export async function ensureInjection(projectRoot: string): Promise<ScaffoldResu
169
169
  try {
170
170
  const globalAgentsDir = getAgentsHome();
171
171
  const globalAgentsMd = join(globalAgentsDir, 'AGENTS.md');
172
- const globalHubContent = '@~/.cleo/templates/CLEO-INJECTION.md';
172
+ const globalHubContent = `@${getCleoTemplatesTildePath()}/CLEO-INJECTION.md`;
173
173
  await mkdir(globalAgentsDir, { recursive: true });
174
174
  // Direct call — CAAMP 1.8.0 handles idempotency
175
175
  await inject(globalAgentsMd, globalHubContent);
package/src/paths.ts CHANGED
@@ -322,6 +322,25 @@ export function getCleoConfigDir(): string {
322
322
  return getPlatformPaths().config;
323
323
  }
324
324
 
325
+ /**
326
+ * Get the CLEO templates directory as a tilde-prefixed path for use
327
+ * in `@` references (AGENTS.md, CLAUDE.md, etc.). Cross-platform:
328
+ * replaces the user's home directory with `~` so the reference works
329
+ * when loaded by LLM providers that resolve `~` at runtime.
330
+ *
331
+ * Linux: ~/.local/share/cleo/templates
332
+ * macOS: ~/Library/Application Support/cleo/templates
333
+ * Windows: ~/AppData/Local/cleo/Data/templates (approximate)
334
+ */
335
+ export function getCleoTemplatesTildePath(): string {
336
+ const absPath = getCleoTemplatesDir();
337
+ const home = homedir();
338
+ if (absPath.startsWith(home)) {
339
+ return `~${absPath.slice(home.length)}`;
340
+ }
341
+ return absPath;
342
+ }
343
+
325
344
  // ============================================================================
326
345
  // Third-Party Tool Paths (OS-aware)
327
346
  // ============================================================================
@@ -3,29 +3,53 @@
3
3
  Version: 2.1.0
4
4
  Status: ACTIVE
5
5
 
6
+ ## Runtime Environment
7
+
8
+ <!-- CleoOS injects CLEO_RUNTIME=cleoos when launching agents from a workspace -->
9
+ <!-- When this variable is absent, assume standalone CLI mode -->
10
+
11
+ **Mode**: `${CLEO_RUNTIME:-standalone}`
12
+
13
+ ### Channel Preference
14
+
15
+ | Runtime | Primary Channel | Fallback | Rationale |
16
+ |---------|----------------|----------|-----------|
17
+ | `standalone` | CLI (`cleo <command>`) | MCP (query/mutate) | CLI is cheaper (fewer tokens), more reliable, and baked into core |
18
+ | `cleoos` | Workspace-provided | CLI | CleoOS workspace manages channel routing via capability matrix |
19
+
20
+ When running in **standalone** mode (the default):
21
+ - Prefer CLI commands over MCP tool calls for all CLEO operations
22
+ - CLI commands are shorter, use fewer tokens, and bypass the MCP dispatch layer
23
+ - Use MCP only when the provider does not support shell execution
24
+
25
+ When running in **CleoOS** mode:
26
+ - Follow the workspace-provided channel routing preferences
27
+ - CleoOS manages the capability matrix and optimal channel selection
28
+ - This mode is a work-in-progress — fall back to CLI if unsure
29
+
6
30
  ## CLEO Identity
7
31
 
8
- You are a CLEO protocol agent. Use MCP-first operations:
9
- - `query` for reads
10
- - `mutate` for writes
32
+ You are a CLEO protocol agent. CLEO operations are available via CLI (primary) and MCP (fallback):
33
+ - CLI: `cleo <command> [args]` — preferred for token efficiency (flat commands, not domain-prefixed)
34
+ - MCP: `query`/`mutate` gateways with `{domain, operation, params}` — use when CLI is unavailable
11
35
 
12
36
  ## Mandatory Efficiency Sequence
13
37
 
14
38
  Run cheapest-first at session start:
15
- 1. `query session status` — resume existing? (~200 tokens)
16
- 2. `query admin dash` — project overview (~500 tokens)
17
- 3. `query tasks current` — active task? (~100 tokens)
18
- 4. `query tasks next` — what to work on (~300 tokens)
19
- 5. `query tasks show` — full details for chosen task (~400 tokens)
39
+ 1. `cleo session status` — resume existing? (~200 tokens)
40
+ 2. `cleo dash` — project overview (~500 tokens)
41
+ 3. `cleo current` — active task? (~100 tokens)
42
+ 4. `cleo next` — what to work on (~300 tokens)
43
+ 5. `cleo show {id}` — full details for chosen task (~400 tokens)
20
44
 
21
45
  ## Agent Work Loop
22
46
 
23
47
  Repeat until session ends:
24
- 1. `tasks current` or `tasks next` → pick task
25
- 2. `tasks show {id}` → read requirements
48
+ 1. `cleo current` or `cleo next` → pick task
49
+ 2. `cleo show {id}` → read requirements
26
50
  3. Do the work (code, test, document)
27
- 4. `tasks complete {id}` → mark done
28
- 5. `tasks next` → continue or end session
51
+ 4. `cleo complete {id}` → mark done
52
+ 5. `cleo next` → continue or end session
29
53
 
30
54
  ## Context Ethics
31
55
 
@@ -61,12 +85,12 @@ Agents MUST NOT provide hours/days/week estimates. Use `small`, `medium`, `large
61
85
 
62
86
  ## Session Quick Reference
63
87
 
64
- | Goal | Operation | Gateway |
65
- |------|-----------|---------|
66
- | Check active session | `session status` | query |
67
- | Resume context from last session | `session handoff.show` | query |
68
- | Start working | `session start` (scope required) | mutate |
69
- | Stop working | `session end` | mutate |
88
+ | Goal | CLI (Primary) | MCP (Fallback) |
89
+ |------|--------------|----------------|
90
+ | Check active session | `cleo session status` | `query session status` |
91
+ | Resume context | `cleo briefing` | `query session briefing.show` |
92
+ | Start working | `cleo session start --scope global` | `mutate session start {scope: "global"}` |
93
+ | Stop working | `cleo session end` | `mutate session end` |
70
94
 
71
95
  For advanced session ops (find, suspend, resume, debrief, decisions): see `.cleo/agent-outputs/T5124-session-decision-tree.md`
72
96
 
@@ -78,23 +102,23 @@ CLEO includes a native BRAIN memory system. Use the 3-layer retrieval pattern fo
78
102
 
79
103
  | Step | Operation | Gateway | ~Tokens | Purpose |
80
104
  |------|-----------|---------|---------|---------|
81
- | 1 | `memory brain.search` | query | 50/hit | Search index (IDs + titles) |
82
- | 2 | `memory brain.timeline` | query | 200-500 | Context around an anchor ID |
83
- | 3 | `memory brain.fetch` | query | 500/entry | Full details for filtered IDs |
84
- | Save | `memory brain.observe` | mutate | — | Save observation to brain.db |
105
+ | 1 | `memory find` | query | 50/hit | Search index (IDs + titles) |
106
+ | 2 | `memory timeline` | query | 200-500 | Context around an anchor ID |
107
+ | 3 | `memory fetch` | query | 500/entry | Full details for filtered IDs |
108
+ | Save | `memory observe` | mutate | — | Save observation to brain.db |
85
109
 
86
110
  **Workflow**: Search first (cheap) → filter interesting IDs → fetch only what you need.
87
111
 
88
- **Example**:
112
+ **Example** (CLI):
89
113
  ```
90
- query memory brain.search {query: "authentication"}
91
- query memory brain.fetch {ids: ["O-abc123"]}
92
- mutate memory brain.observe {text: "Found auth uses JWT", title: "Auth discovery"}
114
+ cleo memory find "authentication"
115
+ cleo memory fetch O-abc123
116
+ cleo observe "Found auth uses JWT" --title "Auth discovery"
93
117
  ```
94
118
 
95
119
  **Anti-patterns:**
96
120
  - Fetching all entries without searching first (expensive)
97
- - Skipping brain.search and going straight to brain.fetch
121
+ - Skipping memory find and going straight to memory fetch
98
122
 
99
123
  ## Memory Bridge
100
124