@cleocode/core 2026.3.48 → 2026.3.50

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.
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AA8BH,sCAAsC;AACtC,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,oCAAoC;AACpC,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAaD;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8D9F;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA+FzF;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EAC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AE,WAAW,EAAE,OAAO,CAAA;CAAE,CAAC,CAiB/F;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAyBnF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleocode/core",
3
- "version": "2026.3.48",
3
+ "version": "2026.3.50",
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.48",
40
- "@cleocode/agents": "2026.3.48",
41
- "@cleocode/contracts": "2026.3.48",
42
- "@cleocode/skills": "2026.3.48"
39
+ "@cleocode/adapters": "2026.3.50",
40
+ "@cleocode/agents": "2026.3.50",
41
+ "@cleocode/skills": "2026.3.50",
42
+ "@cleocode/contracts": "2026.3.50"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=24.0.0"
package/src/bootstrap.ts CHANGED
@@ -16,7 +16,7 @@ import { mkdir, readFile, writeFile } from 'node:fs/promises';
16
16
  import { homedir } from 'node:os';
17
17
  import { join } from 'node:path';
18
18
  import { getAgentsHome, getCleoTemplatesDir } from './paths.js';
19
- import { getPackageRoot } from './scaffold.js';
19
+ import { ensureGlobalHome, getPackageRoot } from './scaffold.js';
20
20
 
21
21
  // ── Types ────────────────────────────────────────────────────────────
22
22
 
@@ -53,6 +53,13 @@ export async function bootstrapGlobalCleo(options?: BootstrapOptions): Promise<B
53
53
  isDryRun: options?.dryRun ?? false,
54
54
  };
55
55
 
56
+ // Step 0: Ensure global home structure and clean stale artifacts
57
+ try {
58
+ await ensureGlobalHome();
59
+ } catch {
60
+ // Best-effort — don't fail bootstrap if cleanup fails
61
+ }
62
+
56
63
  // Step 1: Ensure global templates
57
64
  await ensureGlobalTemplatesBootstrap(ctx, options?.packageRoot);
58
65
 
@@ -135,19 +142,20 @@ async function injectAgentsHub(ctx: BootstrapContext): Promise<void> {
135
142
  if (!ctx.isDryRun) {
136
143
  await mkdir(globalAgentsDir, { recursive: true });
137
144
 
138
- // Strip any legacy CLEO blocks first (handles bare and versioned markers)
145
+ // Consolidate: strip ALL legacy CLEO blocks AND duplicate CAAMP blocks,
146
+ // then inject a single clean block. CAAMP 1.8.0 idempotency doesn't
147
+ // consolidate pre-existing duplicates — it only prevents new ones.
139
148
  if (existsSync(globalAgentsMd)) {
140
149
  const content = await readFile(globalAgentsMd, 'utf8');
141
- const stripped = content.replace(
142
- /\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
143
- '',
144
- );
145
- if (stripped !== content) {
146
- await writeFile(globalAgentsMd, stripped, 'utf8');
147
- }
150
+ const stripped = content
151
+ .replace(/\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g, '')
152
+ .replace(/\n?<!-- CAAMP:START -->[\s\S]*?<!-- CAAMP:END -->\n?/g, '')
153
+ .trim();
154
+ // Write clean file (empty or user content only)
155
+ await writeFile(globalAgentsMd, stripped ? `${stripped}\n` : '', 'utf8');
148
156
  }
149
157
 
150
- // Direct call — CAAMP 1.8.0 handles idempotency
158
+ // Single inject call on a clean file no duplicates possible
151
159
  const expectedContent = '@~/.cleo/templates/CLEO-INJECTION.md';
152
160
  const action = await inject(globalAgentsMd, expectedContent);
153
161
  ctx.created.push(`~/.agents/AGENTS.md (${action})`);
package/src/init.ts CHANGED
@@ -130,12 +130,19 @@ export async function initAgentDefinition(created: string[], warnings: string[])
130
130
  await mkdir(dirname(globalAgentsDir), { recursive: true });
131
131
 
132
132
  try {
133
- // Check if symlink already exists
133
+ // Check if symlink already exists and points to correct target
134
134
  try {
135
135
  const stat = await lstat(globalAgentsDir);
136
- if (stat.isSymbolicLink() || stat.isDirectory()) {
137
- // Already installed
138
- return;
136
+ if (stat.isSymbolicLink()) {
137
+ const { readlink } = await import('node:fs/promises');
138
+ const currentTarget = await readlink(globalAgentsDir);
139
+ if (currentTarget === agentSourceDir) {
140
+ return; // Symlink intact and pointing to correct location
141
+ }
142
+ // Stale symlink — remove and recreate
143
+ await unlink(globalAgentsDir);
144
+ } else if (stat.isDirectory()) {
145
+ return; // Copied dir, leave as-is
139
146
  }
140
147
  } catch {
141
148
  // Doesn't exist, proceed to create