@cleocode/cleo 2026.3.50 → 2026.3.52

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/mcp/index.js CHANGED
@@ -35539,16 +35539,24 @@ async function ensureGlobalHome() {
35539
35539
  for (const subdir of REQUIRED_GLOBAL_SUBDIRS) {
35540
35540
  await mkdir5(join37(cleoHome, subdir), { recursive: true });
35541
35541
  }
35542
- for (const stale of STALE_GLOBAL_ENTRIES) {
35543
- const stalePath = join37(cleoHome, stale);
35544
- if (existsSync34(stalePath)) {
35545
- try {
35546
- await rm2(stalePath, { recursive: true, force: true });
35547
- console.warn(`[CLEO] Removed stale global entry: ${stalePath}`);
35548
- } catch (err) {
35549
- console.warn(
35550
- `[CLEO] Could not remove stale global entry ${stalePath}: ${err instanceof Error ? err.message : String(err)}`
35551
- );
35542
+ const homedir7 = (await import("node:os")).homedir();
35543
+ const legacyCleoHome = join37(homedir7, ".cleo");
35544
+ const cleanupPaths = [cleoHome];
35545
+ if (legacyCleoHome !== cleoHome && existsSync34(legacyCleoHome)) {
35546
+ cleanupPaths.push(legacyCleoHome);
35547
+ }
35548
+ for (const homeDir of cleanupPaths) {
35549
+ for (const stale of STALE_GLOBAL_ENTRIES) {
35550
+ const stalePath = join37(homeDir, stale);
35551
+ if (existsSync34(stalePath)) {
35552
+ try {
35553
+ await rm2(stalePath, { recursive: true, force: true });
35554
+ console.warn(`[CLEO] Removed stale global entry: ${stalePath}`);
35555
+ } catch (err) {
35556
+ console.warn(
35557
+ `[CLEO] Could not remove stale global entry ${stalePath}: ${err instanceof Error ? err.message : String(err)}`
35558
+ );
35559
+ }
35552
35560
  }
35553
35561
  }
35554
35562
  }
@@ -64951,6 +64959,228 @@ var init_project_info = __esm({
64951
64959
  }
64952
64960
  });
64953
64961
 
64962
+ // packages/core/src/bootstrap.ts
64963
+ import { existsSync as existsSync103, readFileSync as readFileSync76 } from "node:fs";
64964
+ import { mkdir as mkdir17, readFile as readFile19, writeFile as writeFile12 } from "node:fs/promises";
64965
+ import { homedir as homedir6 } from "node:os";
64966
+ import { join as join103 } from "node:path";
64967
+ async function bootstrapGlobalCleo(options) {
64968
+ const ctx = {
64969
+ created: [],
64970
+ warnings: [],
64971
+ isDryRun: options?.dryRun ?? false
64972
+ };
64973
+ try {
64974
+ await ensureGlobalHome();
64975
+ } catch {
64976
+ }
64977
+ await ensureGlobalTemplatesBootstrap(ctx, options?.packageRoot);
64978
+ await injectAgentsHub(ctx);
64979
+ await installMcpToProviders(ctx);
64980
+ await installSkillsGlobally(ctx);
64981
+ await installAgentDefinitionGlobally(ctx);
64982
+ await installProviderAdapters(ctx, options?.packageRoot);
64983
+ return ctx;
64984
+ }
64985
+ async function ensureGlobalTemplatesBootstrap(ctx, packageRootOverride) {
64986
+ const globalTemplatesDir = getCleoTemplatesDir();
64987
+ if (!ctx.isDryRun) {
64988
+ await mkdir17(globalTemplatesDir, { recursive: true });
64989
+ }
64990
+ try {
64991
+ const pkgRoot = packageRootOverride ?? getPackageRoot();
64992
+ const templatePath = join103(pkgRoot, "templates", "CLEO-INJECTION.md");
64993
+ if (existsSync103(templatePath)) {
64994
+ const content = readFileSync76(templatePath, "utf-8");
64995
+ const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
64996
+ if (!ctx.isDryRun) {
64997
+ await writeFile12(destPath, content);
64998
+ }
64999
+ ctx.created.push(
65000
+ `~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"})`
65001
+ );
65002
+ } else {
65003
+ try {
65004
+ const { getInjectionTemplateContent: getInjectionTemplateContent2 } = await Promise.resolve().then(() => (init_injection(), injection_exports));
65005
+ const content = getInjectionTemplateContent2();
65006
+ if (content) {
65007
+ const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
65008
+ if (!ctx.isDryRun) {
65009
+ await writeFile12(destPath, content);
65010
+ }
65011
+ ctx.created.push(
65012
+ `~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"} from embedded)`
65013
+ );
65014
+ }
65015
+ } catch {
65016
+ ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
65017
+ }
65018
+ }
65019
+ } catch {
65020
+ ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
65021
+ }
65022
+ }
65023
+ async function injectAgentsHub(ctx) {
65024
+ const globalAgentsDir = getAgentsHome();
65025
+ const globalAgentsMd = join103(globalAgentsDir, "AGENTS.md");
65026
+ try {
65027
+ const { inject: inject2, getInstalledProviders: getInstalledProviders4, injectAll: injectAll3, buildInjectionContent: buildInjectionContent2 } = await import("@cleocode/caamp");
65028
+ if (!ctx.isDryRun) {
65029
+ await mkdir17(globalAgentsDir, { recursive: true });
65030
+ if (existsSync103(globalAgentsMd)) {
65031
+ const content = await readFile19(globalAgentsMd, "utf8");
65032
+ const stripped = content.replace(
65033
+ /\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
65034
+ ""
65035
+ );
65036
+ if (stripped !== content) {
65037
+ await writeFile12(globalAgentsMd, stripped, "utf8");
65038
+ }
65039
+ }
65040
+ const expectedContent = "@~/.cleo/templates/CLEO-INJECTION.md";
65041
+ const action = await inject2(globalAgentsMd, expectedContent);
65042
+ ctx.created.push(`~/.agents/AGENTS.md (${action})`);
65043
+ } else {
65044
+ ctx.created.push("~/.agents/AGENTS.md (would create/update CAAMP block)");
65045
+ }
65046
+ const providers = getInstalledProviders4();
65047
+ if (providers.length === 0) {
65048
+ ctx.warnings.push("No AI provider installations detected");
65049
+ } else {
65050
+ const injectionContent = buildInjectionContent2({
65051
+ references: ["@~/.agents/AGENTS.md"]
65052
+ });
65053
+ if (!ctx.isDryRun) {
65054
+ for (const provider of providers) {
65055
+ const instructFilePath = join103(provider.pathGlobal, provider.instructFile);
65056
+ if (existsSync103(instructFilePath)) {
65057
+ const fileContent = await readFile19(instructFilePath, "utf8");
65058
+ const stripped = fileContent.replace(
65059
+ /\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
65060
+ ""
65061
+ );
65062
+ if (stripped !== fileContent) {
65063
+ await writeFile12(instructFilePath, stripped, "utf8");
65064
+ }
65065
+ }
65066
+ }
65067
+ const results = await injectAll3(providers, homedir6(), "global", injectionContent);
65068
+ for (const [filePath, action] of results) {
65069
+ const displayPath = filePath.replace(homedir6(), "~");
65070
+ ctx.created.push(`${displayPath} (${action})`);
65071
+ }
65072
+ } else {
65073
+ for (const p of providers) {
65074
+ const displayPath = join103(p.pathGlobal, p.instructFile).replace(homedir6(), "~");
65075
+ ctx.created.push(`${displayPath} (would update CAAMP block)`);
65076
+ }
65077
+ }
65078
+ }
65079
+ } catch (err) {
65080
+ ctx.warnings.push(`CAAMP injection: ${err instanceof Error ? err.message : String(err)}`);
65081
+ }
65082
+ }
65083
+ async function installMcpToProviders(ctx) {
65084
+ try {
65085
+ const { detectEnvMode: detectEnvMode2, generateMcpServerEntry: generateMcpServerEntry2, getMcpServerName: getMcpServerName2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
65086
+ const { getInstalledProviders: getInstalledProviders4, installMcpServerToAll } = await import("@cleocode/caamp");
65087
+ const env = detectEnvMode2();
65088
+ const serverEntry = generateMcpServerEntry2(env);
65089
+ const serverName = getMcpServerName2(env);
65090
+ const providers = getInstalledProviders4();
65091
+ if (providers.length > 0) {
65092
+ if (!ctx.isDryRun) {
65093
+ const results = await installMcpServerToAll(
65094
+ providers,
65095
+ serverName,
65096
+ serverEntry,
65097
+ "global",
65098
+ homedir6()
65099
+ );
65100
+ const successes = results.filter((r) => r.success);
65101
+ if (successes.length > 0) {
65102
+ ctx.created.push(
65103
+ `MCP configs: ${successes.map((r) => r.provider.id).join(", ")}`
65104
+ );
65105
+ }
65106
+ } else {
65107
+ ctx.created.push("MCP configs (would update)");
65108
+ }
65109
+ }
65110
+ } catch {
65111
+ ctx.warnings.push("MCP config update skipped (non-critical)");
65112
+ }
65113
+ }
65114
+ async function installSkillsGlobally(ctx) {
65115
+ try {
65116
+ if (!ctx.isDryRun) {
65117
+ const { initCoreSkills: initCoreSkills2 } = await Promise.resolve().then(() => (init_init(), init_exports));
65118
+ await initCoreSkills2(ctx.created, ctx.warnings);
65119
+ } else {
65120
+ ctx.created.push("core skills (would install/update)");
65121
+ }
65122
+ } catch (err) {
65123
+ ctx.warnings.push(
65124
+ `Core skills installation failed: ${err instanceof Error ? err.message : String(err)}`
65125
+ );
65126
+ }
65127
+ }
65128
+ async function installAgentDefinitionGlobally(ctx) {
65129
+ try {
65130
+ if (!ctx.isDryRun) {
65131
+ const { initAgentDefinition: initAgentDefinition2 } = await Promise.resolve().then(() => (init_init(), init_exports));
65132
+ await initAgentDefinition2(ctx.created, ctx.warnings);
65133
+ } else {
65134
+ ctx.created.push("agent: cleo-subagent (would symlink)");
65135
+ }
65136
+ } catch (err) {
65137
+ ctx.warnings.push(
65138
+ `Agent definition install: ${err instanceof Error ? err.message : String(err)}`
65139
+ );
65140
+ }
65141
+ }
65142
+ async function installProviderAdapters(ctx, packageRootOverride) {
65143
+ try {
65144
+ const { AdapterManager: AdapterManager2 } = await Promise.resolve().then(() => (init_adapters(), adapters_exports));
65145
+ const pkgRoot = packageRootOverride ?? getPackageRoot();
65146
+ const manager = AdapterManager2.getInstance(pkgRoot);
65147
+ manager.discover();
65148
+ const detected = manager.detectActive();
65149
+ for (const adapterId of detected) {
65150
+ try {
65151
+ const adapter = await manager.activate(adapterId);
65152
+ if (adapter.install) {
65153
+ if (!ctx.isDryRun) {
65154
+ const installResult = await adapter.install.install({
65155
+ projectDir: process.cwd()
65156
+ });
65157
+ if (installResult.success) {
65158
+ ctx.created.push(`${adapterId} adapter (installed)`);
65159
+ }
65160
+ } else {
65161
+ ctx.created.push(`${adapterId} adapter (would install)`);
65162
+ }
65163
+ }
65164
+ } catch (activateErr) {
65165
+ ctx.warnings.push(
65166
+ `Adapter ${adapterId} skipped: ${activateErr instanceof Error ? activateErr.message : String(activateErr)}`
65167
+ );
65168
+ }
65169
+ }
65170
+ } catch (err) {
65171
+ ctx.warnings.push(
65172
+ `Adapter install skipped: ${err instanceof Error ? err.message : String(err)}`
65173
+ );
65174
+ }
65175
+ }
65176
+ var init_bootstrap = __esm({
65177
+ "packages/core/src/bootstrap.ts"() {
65178
+ "use strict";
65179
+ init_paths();
65180
+ init_scaffold();
65181
+ }
65182
+ });
65183
+
64954
65184
  // packages/core/src/cleo.ts
64955
65185
  import path from "node:path";
64956
65186
  var Cleo;
@@ -65284,6 +65514,7 @@ var init_src2 = __esm({
65284
65514
  init_project_info();
65285
65515
  init_scaffold();
65286
65516
  init_adapters();
65517
+ init_bootstrap();
65287
65518
  init_cleo();
65288
65519
  init_registry();
65289
65520
  init_brain_retrieval();
@@ -65306,224 +65537,6 @@ var init_src2 = __esm({
65306
65537
  }
65307
65538
  });
65308
65539
 
65309
- // packages/core/src/bootstrap.ts
65310
- import { existsSync as existsSync103, readFileSync as readFileSync76 } from "node:fs";
65311
- import { mkdir as mkdir17, readFile as readFile19, writeFile as writeFile12 } from "node:fs/promises";
65312
- import { homedir as homedir6 } from "node:os";
65313
- import { join as join103 } from "node:path";
65314
- async function bootstrapGlobalCleo(options) {
65315
- const ctx = {
65316
- created: [],
65317
- warnings: [],
65318
- isDryRun: options?.dryRun ?? false
65319
- };
65320
- try {
65321
- await ensureGlobalHome();
65322
- } catch {
65323
- }
65324
- await ensureGlobalTemplatesBootstrap(ctx, options?.packageRoot);
65325
- await injectAgentsHub(ctx);
65326
- await installMcpToProviders(ctx);
65327
- await installSkillsGlobally(ctx);
65328
- await installAgentDefinitionGlobally(ctx);
65329
- await installProviderAdapters(ctx, options?.packageRoot);
65330
- return ctx;
65331
- }
65332
- async function ensureGlobalTemplatesBootstrap(ctx, packageRootOverride) {
65333
- const globalTemplatesDir = getCleoTemplatesDir();
65334
- if (!ctx.isDryRun) {
65335
- await mkdir17(globalTemplatesDir, { recursive: true });
65336
- }
65337
- try {
65338
- const pkgRoot = packageRootOverride ?? getPackageRoot();
65339
- const templatePath = join103(pkgRoot, "templates", "CLEO-INJECTION.md");
65340
- if (existsSync103(templatePath)) {
65341
- const content = readFileSync76(templatePath, "utf-8");
65342
- const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
65343
- if (!ctx.isDryRun) {
65344
- await writeFile12(destPath, content);
65345
- }
65346
- ctx.created.push(
65347
- `~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"})`
65348
- );
65349
- } else {
65350
- try {
65351
- const { getInjectionTemplateContent: getInjectionTemplateContent2 } = await Promise.resolve().then(() => (init_injection(), injection_exports));
65352
- const content = getInjectionTemplateContent2();
65353
- if (content) {
65354
- const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
65355
- if (!ctx.isDryRun) {
65356
- await writeFile12(destPath, content);
65357
- }
65358
- ctx.created.push(
65359
- `~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"} from embedded)`
65360
- );
65361
- }
65362
- } catch {
65363
- ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
65364
- }
65365
- }
65366
- } catch {
65367
- ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
65368
- }
65369
- }
65370
- async function injectAgentsHub(ctx) {
65371
- const globalAgentsDir = getAgentsHome();
65372
- const globalAgentsMd = join103(globalAgentsDir, "AGENTS.md");
65373
- try {
65374
- const { inject: inject2, getInstalledProviders: getInstalledProviders4, injectAll: injectAll3, buildInjectionContent: buildInjectionContent2 } = await import("@cleocode/caamp");
65375
- if (!ctx.isDryRun) {
65376
- await mkdir17(globalAgentsDir, { recursive: true });
65377
- if (existsSync103(globalAgentsMd)) {
65378
- const content = await readFile19(globalAgentsMd, "utf8");
65379
- const stripped = content.replace(/\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g, "").replace(/\n?<!-- CAAMP:START -->[\s\S]*?<!-- CAAMP:END -->\n?/g, "").trim();
65380
- await writeFile12(globalAgentsMd, stripped ? `${stripped}
65381
- ` : "", "utf8");
65382
- }
65383
- const expectedContent = "@~/.cleo/templates/CLEO-INJECTION.md";
65384
- const action = await inject2(globalAgentsMd, expectedContent);
65385
- ctx.created.push(`~/.agents/AGENTS.md (${action})`);
65386
- } else {
65387
- ctx.created.push("~/.agents/AGENTS.md (would create/update CAAMP block)");
65388
- }
65389
- const providers = getInstalledProviders4();
65390
- if (providers.length === 0) {
65391
- ctx.warnings.push("No AI provider installations detected");
65392
- } else {
65393
- const injectionContent = buildInjectionContent2({
65394
- references: ["@~/.agents/AGENTS.md"]
65395
- });
65396
- if (!ctx.isDryRun) {
65397
- for (const provider of providers) {
65398
- const instructFilePath = join103(provider.pathGlobal, provider.instructFile);
65399
- if (existsSync103(instructFilePath)) {
65400
- const fileContent = await readFile19(instructFilePath, "utf8");
65401
- const stripped = fileContent.replace(
65402
- /\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
65403
- ""
65404
- );
65405
- if (stripped !== fileContent) {
65406
- await writeFile12(instructFilePath, stripped, "utf8");
65407
- }
65408
- }
65409
- }
65410
- const results = await injectAll3(providers, homedir6(), "global", injectionContent);
65411
- for (const [filePath, action] of results) {
65412
- const displayPath = filePath.replace(homedir6(), "~");
65413
- ctx.created.push(`${displayPath} (${action})`);
65414
- }
65415
- } else {
65416
- for (const p of providers) {
65417
- const displayPath = join103(p.pathGlobal, p.instructFile).replace(homedir6(), "~");
65418
- ctx.created.push(`${displayPath} (would update CAAMP block)`);
65419
- }
65420
- }
65421
- }
65422
- } catch (err) {
65423
- ctx.warnings.push(`CAAMP injection: ${err instanceof Error ? err.message : String(err)}`);
65424
- }
65425
- }
65426
- async function installMcpToProviders(ctx) {
65427
- try {
65428
- const { detectEnvMode: detectEnvMode2, generateMcpServerEntry: generateMcpServerEntry2, getMcpServerName: getMcpServerName2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
65429
- const { getInstalledProviders: getInstalledProviders4, installMcpServerToAll } = await import("@cleocode/caamp");
65430
- const env = detectEnvMode2();
65431
- const serverEntry = generateMcpServerEntry2(env);
65432
- const serverName = getMcpServerName2(env);
65433
- const providers = getInstalledProviders4();
65434
- if (providers.length > 0) {
65435
- if (!ctx.isDryRun) {
65436
- const results = await installMcpServerToAll(
65437
- providers,
65438
- serverName,
65439
- serverEntry,
65440
- "global",
65441
- homedir6()
65442
- );
65443
- const successes = results.filter((r) => r.success);
65444
- if (successes.length > 0) {
65445
- ctx.created.push(
65446
- `MCP configs: ${successes.map((r) => r.provider.id).join(", ")}`
65447
- );
65448
- }
65449
- } else {
65450
- ctx.created.push("MCP configs (would update)");
65451
- }
65452
- }
65453
- } catch {
65454
- ctx.warnings.push("MCP config update skipped (non-critical)");
65455
- }
65456
- }
65457
- async function installSkillsGlobally(ctx) {
65458
- try {
65459
- if (!ctx.isDryRun) {
65460
- const { initCoreSkills: initCoreSkills2 } = await Promise.resolve().then(() => (init_init(), init_exports));
65461
- await initCoreSkills2(ctx.created, ctx.warnings);
65462
- } else {
65463
- ctx.created.push("core skills (would install/update)");
65464
- }
65465
- } catch (err) {
65466
- ctx.warnings.push(
65467
- `Core skills installation failed: ${err instanceof Error ? err.message : String(err)}`
65468
- );
65469
- }
65470
- }
65471
- async function installAgentDefinitionGlobally(ctx) {
65472
- try {
65473
- if (!ctx.isDryRun) {
65474
- const { initAgentDefinition: initAgentDefinition2 } = await Promise.resolve().then(() => (init_init(), init_exports));
65475
- await initAgentDefinition2(ctx.created, ctx.warnings);
65476
- } else {
65477
- ctx.created.push("agent: cleo-subagent (would symlink)");
65478
- }
65479
- } catch (err) {
65480
- ctx.warnings.push(
65481
- `Agent definition install: ${err instanceof Error ? err.message : String(err)}`
65482
- );
65483
- }
65484
- }
65485
- async function installProviderAdapters(ctx, packageRootOverride) {
65486
- try {
65487
- const { AdapterManager: AdapterManager2 } = await Promise.resolve().then(() => (init_adapters(), adapters_exports));
65488
- const pkgRoot = packageRootOverride ?? getPackageRoot();
65489
- const manager = AdapterManager2.getInstance(pkgRoot);
65490
- manager.discover();
65491
- const detected = manager.detectActive();
65492
- for (const adapterId of detected) {
65493
- try {
65494
- const adapter = await manager.activate(adapterId);
65495
- if (adapter.install) {
65496
- if (!ctx.isDryRun) {
65497
- const installResult = await adapter.install.install({
65498
- projectDir: process.cwd()
65499
- });
65500
- if (installResult.success) {
65501
- ctx.created.push(`${adapterId} adapter (installed)`);
65502
- }
65503
- } else {
65504
- ctx.created.push(`${adapterId} adapter (would install)`);
65505
- }
65506
- }
65507
- } catch (activateErr) {
65508
- ctx.warnings.push(
65509
- `Adapter ${adapterId} skipped: ${activateErr instanceof Error ? activateErr.message : String(activateErr)}`
65510
- );
65511
- }
65512
- }
65513
- } catch (err) {
65514
- ctx.warnings.push(
65515
- `Adapter install skipped: ${err instanceof Error ? err.message : String(err)}`
65516
- );
65517
- }
65518
- }
65519
- var init_bootstrap = __esm({
65520
- "packages/core/src/bootstrap.ts"() {
65521
- "use strict";
65522
- init_paths();
65523
- init_scaffold();
65524
- }
65525
- });
65526
-
65527
65540
  // packages/core/src/compliance/protocol-rules.ts
65528
65541
  function hasField(obj, field) {
65529
65542
  const value = obj[field];