@cleocode/cleo 2026.3.49 → 2026.3.51

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