@cleocode/cleo 2026.3.50 → 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.
@@ -55,8 +55,15 @@ async function runPostinstall() {
55
55
  console.log('CLEO: Bootstrapping global system...');
56
56
 
57
57
  try {
58
- // Import bootstrap from @cleocode/core (installed as dependency)
59
- const { bootstrapGlobalCleo } = await import('@cleocode/core/internal');
58
+ // Import bootstrap from @cleocode/core.
59
+ // Try the internal subpath first (multi-file tsc build), fall back to main
60
+ // barrel (esbuild single-file bundle where internal.js doesn't exist).
61
+ let bootstrapGlobalCleo;
62
+ try {
63
+ ({ bootstrapGlobalCleo } = await import('@cleocode/core/internal'));
64
+ } catch {
65
+ ({ bootstrapGlobalCleo } = await import('@cleocode/core'));
66
+ }
60
67
 
61
68
  const result = await bootstrapGlobalCleo({
62
69
  packageRoot: getPackageRoot(),
package/dist/cli/index.js CHANGED
@@ -64979,6 +64979,224 @@ var init_project_info = __esm({
64979
64979
  }
64980
64980
  });
64981
64981
 
64982
+ // packages/core/src/bootstrap.ts
64983
+ import { existsSync as existsSync103, readFileSync as readFileSync76 } from "node:fs";
64984
+ import { mkdir as mkdir17, readFile as readFile19, writeFile as writeFile12 } from "node:fs/promises";
64985
+ import { homedir as homedir6 } from "node:os";
64986
+ import { join as join103 } from "node:path";
64987
+ async function bootstrapGlobalCleo(options) {
64988
+ const ctx = {
64989
+ created: [],
64990
+ warnings: [],
64991
+ isDryRun: options?.dryRun ?? false
64992
+ };
64993
+ try {
64994
+ await ensureGlobalHome();
64995
+ } catch {
64996
+ }
64997
+ await ensureGlobalTemplatesBootstrap(ctx, options?.packageRoot);
64998
+ await injectAgentsHub(ctx);
64999
+ await installMcpToProviders(ctx);
65000
+ await installSkillsGlobally(ctx);
65001
+ await installAgentDefinitionGlobally(ctx);
65002
+ await installProviderAdapters(ctx, options?.packageRoot);
65003
+ return ctx;
65004
+ }
65005
+ async function ensureGlobalTemplatesBootstrap(ctx, packageRootOverride) {
65006
+ const globalTemplatesDir = getCleoTemplatesDir();
65007
+ if (!ctx.isDryRun) {
65008
+ await mkdir17(globalTemplatesDir, { recursive: true });
65009
+ }
65010
+ try {
65011
+ const pkgRoot = packageRootOverride ?? getPackageRoot();
65012
+ const templatePath = join103(pkgRoot, "templates", "CLEO-INJECTION.md");
65013
+ if (existsSync103(templatePath)) {
65014
+ const content = readFileSync76(templatePath, "utf-8");
65015
+ const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
65016
+ if (!ctx.isDryRun) {
65017
+ await writeFile12(destPath, content);
65018
+ }
65019
+ ctx.created.push(
65020
+ `~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"})`
65021
+ );
65022
+ } else {
65023
+ try {
65024
+ const { getInjectionTemplateContent: getInjectionTemplateContent2 } = await Promise.resolve().then(() => (init_injection(), injection_exports));
65025
+ const content = getInjectionTemplateContent2();
65026
+ if (content) {
65027
+ const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
65028
+ if (!ctx.isDryRun) {
65029
+ await writeFile12(destPath, content);
65030
+ }
65031
+ ctx.created.push(
65032
+ `~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"} from embedded)`
65033
+ );
65034
+ }
65035
+ } catch {
65036
+ ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
65037
+ }
65038
+ }
65039
+ } catch {
65040
+ ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
65041
+ }
65042
+ }
65043
+ async function injectAgentsHub(ctx) {
65044
+ const globalAgentsDir = getAgentsHome();
65045
+ const globalAgentsMd = join103(globalAgentsDir, "AGENTS.md");
65046
+ try {
65047
+ const { inject: inject2, getInstalledProviders: getInstalledProviders5, injectAll: injectAll3, buildInjectionContent: buildInjectionContent2 } = await import("@cleocode/caamp");
65048
+ if (!ctx.isDryRun) {
65049
+ await mkdir17(globalAgentsDir, { recursive: true });
65050
+ if (existsSync103(globalAgentsMd)) {
65051
+ const content = await readFile19(globalAgentsMd, "utf8");
65052
+ const stripped = content.replace(/\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g, "").replace(/\n?<!-- CAAMP:START -->[\s\S]*?<!-- CAAMP:END -->\n?/g, "").trim();
65053
+ await writeFile12(globalAgentsMd, stripped ? `${stripped}
65054
+ ` : "", "utf8");
65055
+ }
65056
+ const expectedContent = "@~/.cleo/templates/CLEO-INJECTION.md";
65057
+ const action = await inject2(globalAgentsMd, expectedContent);
65058
+ ctx.created.push(`~/.agents/AGENTS.md (${action})`);
65059
+ } else {
65060
+ ctx.created.push("~/.agents/AGENTS.md (would create/update CAAMP block)");
65061
+ }
65062
+ const providers = getInstalledProviders5();
65063
+ if (providers.length === 0) {
65064
+ ctx.warnings.push("No AI provider installations detected");
65065
+ } else {
65066
+ const injectionContent = buildInjectionContent2({
65067
+ references: ["@~/.agents/AGENTS.md"]
65068
+ });
65069
+ if (!ctx.isDryRun) {
65070
+ for (const provider of providers) {
65071
+ const instructFilePath = join103(provider.pathGlobal, provider.instructFile);
65072
+ if (existsSync103(instructFilePath)) {
65073
+ const fileContent = await readFile19(instructFilePath, "utf8");
65074
+ const stripped = fileContent.replace(
65075
+ /\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
65076
+ ""
65077
+ );
65078
+ if (stripped !== fileContent) {
65079
+ await writeFile12(instructFilePath, stripped, "utf8");
65080
+ }
65081
+ }
65082
+ }
65083
+ const results = await injectAll3(providers, homedir6(), "global", injectionContent);
65084
+ for (const [filePath, action] of results) {
65085
+ const displayPath = filePath.replace(homedir6(), "~");
65086
+ ctx.created.push(`${displayPath} (${action})`);
65087
+ }
65088
+ } else {
65089
+ for (const p of providers) {
65090
+ const displayPath = join103(p.pathGlobal, p.instructFile).replace(homedir6(), "~");
65091
+ ctx.created.push(`${displayPath} (would update CAAMP block)`);
65092
+ }
65093
+ }
65094
+ }
65095
+ } catch (err) {
65096
+ ctx.warnings.push(`CAAMP injection: ${err instanceof Error ? err.message : String(err)}`);
65097
+ }
65098
+ }
65099
+ async function installMcpToProviders(ctx) {
65100
+ try {
65101
+ const { detectEnvMode: detectEnvMode2, generateMcpServerEntry: generateMcpServerEntry2, getMcpServerName: getMcpServerName2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
65102
+ const { getInstalledProviders: getInstalledProviders5, installMcpServerToAll: installMcpServerToAll2 } = await import("@cleocode/caamp");
65103
+ const env = detectEnvMode2();
65104
+ const serverEntry = generateMcpServerEntry2(env);
65105
+ const serverName = getMcpServerName2(env);
65106
+ const providers = getInstalledProviders5();
65107
+ if (providers.length > 0) {
65108
+ if (!ctx.isDryRun) {
65109
+ const results = await installMcpServerToAll2(
65110
+ providers,
65111
+ serverName,
65112
+ serverEntry,
65113
+ "global",
65114
+ homedir6()
65115
+ );
65116
+ const successes = results.filter((r) => r.success);
65117
+ if (successes.length > 0) {
65118
+ ctx.created.push(
65119
+ `MCP configs: ${successes.map((r) => r.provider.id).join(", ")}`
65120
+ );
65121
+ }
65122
+ } else {
65123
+ ctx.created.push("MCP configs (would update)");
65124
+ }
65125
+ }
65126
+ } catch {
65127
+ ctx.warnings.push("MCP config update skipped (non-critical)");
65128
+ }
65129
+ }
65130
+ async function installSkillsGlobally(ctx) {
65131
+ try {
65132
+ if (!ctx.isDryRun) {
65133
+ const { initCoreSkills: initCoreSkills2 } = await Promise.resolve().then(() => (init_init(), init_exports));
65134
+ await initCoreSkills2(ctx.created, ctx.warnings);
65135
+ } else {
65136
+ ctx.created.push("core skills (would install/update)");
65137
+ }
65138
+ } catch (err) {
65139
+ ctx.warnings.push(
65140
+ `Core skills installation failed: ${err instanceof Error ? err.message : String(err)}`
65141
+ );
65142
+ }
65143
+ }
65144
+ async function installAgentDefinitionGlobally(ctx) {
65145
+ try {
65146
+ if (!ctx.isDryRun) {
65147
+ const { initAgentDefinition: initAgentDefinition2 } = await Promise.resolve().then(() => (init_init(), init_exports));
65148
+ await initAgentDefinition2(ctx.created, ctx.warnings);
65149
+ } else {
65150
+ ctx.created.push("agent: cleo-subagent (would symlink)");
65151
+ }
65152
+ } catch (err) {
65153
+ ctx.warnings.push(
65154
+ `Agent definition install: ${err instanceof Error ? err.message : String(err)}`
65155
+ );
65156
+ }
65157
+ }
65158
+ async function installProviderAdapters(ctx, packageRootOverride) {
65159
+ try {
65160
+ const { AdapterManager: AdapterManager2 } = await Promise.resolve().then(() => (init_adapters(), adapters_exports));
65161
+ const pkgRoot = packageRootOverride ?? getPackageRoot();
65162
+ const manager = AdapterManager2.getInstance(pkgRoot);
65163
+ manager.discover();
65164
+ const detected = manager.detectActive();
65165
+ for (const adapterId of detected) {
65166
+ try {
65167
+ const adapter = await manager.activate(adapterId);
65168
+ if (adapter.install) {
65169
+ if (!ctx.isDryRun) {
65170
+ const installResult = await adapter.install.install({
65171
+ projectDir: process.cwd()
65172
+ });
65173
+ if (installResult.success) {
65174
+ ctx.created.push(`${adapterId} adapter (installed)`);
65175
+ }
65176
+ } else {
65177
+ ctx.created.push(`${adapterId} adapter (would install)`);
65178
+ }
65179
+ }
65180
+ } catch (activateErr) {
65181
+ ctx.warnings.push(
65182
+ `Adapter ${adapterId} skipped: ${activateErr instanceof Error ? activateErr.message : String(activateErr)}`
65183
+ );
65184
+ }
65185
+ }
65186
+ } catch (err) {
65187
+ ctx.warnings.push(
65188
+ `Adapter install skipped: ${err instanceof Error ? err.message : String(err)}`
65189
+ );
65190
+ }
65191
+ }
65192
+ var init_bootstrap = __esm({
65193
+ "packages/core/src/bootstrap.ts"() {
65194
+ "use strict";
65195
+ init_paths();
65196
+ init_scaffold();
65197
+ }
65198
+ });
65199
+
64982
65200
  // packages/core/src/cleo.ts
64983
65201
  import path from "node:path";
64984
65202
  var Cleo;
@@ -65281,6 +65499,7 @@ __export(src_exports, {
65281
65499
  agentTypeSchema: () => agentTypeSchema,
65282
65500
  agents: () => agents_exports,
65283
65501
  archiveTasks: () => archiveTasks,
65502
+ bootstrapGlobalCleo: () => bootstrapGlobalCleo,
65284
65503
  brainConfidenceLevelSchema: () => brainConfidenceLevelSchema,
65285
65504
  brainDecisionTypeSchema: () => brainDecisionTypeSchema,
65286
65505
  brainEdgeTypeSchema: () => brainEdgeTypeSchema,
@@ -65534,6 +65753,7 @@ var init_src2 = __esm({
65534
65753
  init_project_info();
65535
65754
  init_scaffold();
65536
65755
  init_adapters();
65756
+ init_bootstrap();
65537
65757
  init_cleo();
65538
65758
  init_registry();
65539
65759
  init_brain_retrieval();
@@ -65556,224 +65776,6 @@ var init_src2 = __esm({
65556
65776
  }
65557
65777
  });
65558
65778
 
65559
- // packages/core/src/bootstrap.ts
65560
- import { existsSync as existsSync103, readFileSync as readFileSync76 } from "node:fs";
65561
- import { mkdir as mkdir17, readFile as readFile19, writeFile as writeFile12 } from "node:fs/promises";
65562
- import { homedir as homedir6 } from "node:os";
65563
- import { join as join103 } from "node:path";
65564
- async function bootstrapGlobalCleo(options) {
65565
- const ctx = {
65566
- created: [],
65567
- warnings: [],
65568
- isDryRun: options?.dryRun ?? false
65569
- };
65570
- try {
65571
- await ensureGlobalHome();
65572
- } catch {
65573
- }
65574
- await ensureGlobalTemplatesBootstrap(ctx, options?.packageRoot);
65575
- await injectAgentsHub(ctx);
65576
- await installMcpToProviders(ctx);
65577
- await installSkillsGlobally(ctx);
65578
- await installAgentDefinitionGlobally(ctx);
65579
- await installProviderAdapters(ctx, options?.packageRoot);
65580
- return ctx;
65581
- }
65582
- async function ensureGlobalTemplatesBootstrap(ctx, packageRootOverride) {
65583
- const globalTemplatesDir = getCleoTemplatesDir();
65584
- if (!ctx.isDryRun) {
65585
- await mkdir17(globalTemplatesDir, { recursive: true });
65586
- }
65587
- try {
65588
- const pkgRoot = packageRootOverride ?? getPackageRoot();
65589
- const templatePath = join103(pkgRoot, "templates", "CLEO-INJECTION.md");
65590
- if (existsSync103(templatePath)) {
65591
- const content = readFileSync76(templatePath, "utf-8");
65592
- const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
65593
- if (!ctx.isDryRun) {
65594
- await writeFile12(destPath, content);
65595
- }
65596
- ctx.created.push(
65597
- `~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"})`
65598
- );
65599
- } else {
65600
- try {
65601
- const { getInjectionTemplateContent: getInjectionTemplateContent2 } = await Promise.resolve().then(() => (init_injection(), injection_exports));
65602
- const content = getInjectionTemplateContent2();
65603
- if (content) {
65604
- const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
65605
- if (!ctx.isDryRun) {
65606
- await writeFile12(destPath, content);
65607
- }
65608
- ctx.created.push(
65609
- `~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"} from embedded)`
65610
- );
65611
- }
65612
- } catch {
65613
- ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
65614
- }
65615
- }
65616
- } catch {
65617
- ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
65618
- }
65619
- }
65620
- async function injectAgentsHub(ctx) {
65621
- const globalAgentsDir = getAgentsHome();
65622
- const globalAgentsMd = join103(globalAgentsDir, "AGENTS.md");
65623
- try {
65624
- const { inject: inject2, getInstalledProviders: getInstalledProviders5, injectAll: injectAll3, buildInjectionContent: buildInjectionContent2 } = await import("@cleocode/caamp");
65625
- if (!ctx.isDryRun) {
65626
- await mkdir17(globalAgentsDir, { recursive: true });
65627
- if (existsSync103(globalAgentsMd)) {
65628
- const content = await readFile19(globalAgentsMd, "utf8");
65629
- const stripped = content.replace(/\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g, "").replace(/\n?<!-- CAAMP:START -->[\s\S]*?<!-- CAAMP:END -->\n?/g, "").trim();
65630
- await writeFile12(globalAgentsMd, stripped ? `${stripped}
65631
- ` : "", "utf8");
65632
- }
65633
- const expectedContent = "@~/.cleo/templates/CLEO-INJECTION.md";
65634
- const action = await inject2(globalAgentsMd, expectedContent);
65635
- ctx.created.push(`~/.agents/AGENTS.md (${action})`);
65636
- } else {
65637
- ctx.created.push("~/.agents/AGENTS.md (would create/update CAAMP block)");
65638
- }
65639
- const providers = getInstalledProviders5();
65640
- if (providers.length === 0) {
65641
- ctx.warnings.push("No AI provider installations detected");
65642
- } else {
65643
- const injectionContent = buildInjectionContent2({
65644
- references: ["@~/.agents/AGENTS.md"]
65645
- });
65646
- if (!ctx.isDryRun) {
65647
- for (const provider of providers) {
65648
- const instructFilePath = join103(provider.pathGlobal, provider.instructFile);
65649
- if (existsSync103(instructFilePath)) {
65650
- const fileContent = await readFile19(instructFilePath, "utf8");
65651
- const stripped = fileContent.replace(
65652
- /\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
65653
- ""
65654
- );
65655
- if (stripped !== fileContent) {
65656
- await writeFile12(instructFilePath, stripped, "utf8");
65657
- }
65658
- }
65659
- }
65660
- const results = await injectAll3(providers, homedir6(), "global", injectionContent);
65661
- for (const [filePath, action] of results) {
65662
- const displayPath = filePath.replace(homedir6(), "~");
65663
- ctx.created.push(`${displayPath} (${action})`);
65664
- }
65665
- } else {
65666
- for (const p of providers) {
65667
- const displayPath = join103(p.pathGlobal, p.instructFile).replace(homedir6(), "~");
65668
- ctx.created.push(`${displayPath} (would update CAAMP block)`);
65669
- }
65670
- }
65671
- }
65672
- } catch (err) {
65673
- ctx.warnings.push(`CAAMP injection: ${err instanceof Error ? err.message : String(err)}`);
65674
- }
65675
- }
65676
- async function installMcpToProviders(ctx) {
65677
- try {
65678
- const { detectEnvMode: detectEnvMode2, generateMcpServerEntry: generateMcpServerEntry2, getMcpServerName: getMcpServerName2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
65679
- const { getInstalledProviders: getInstalledProviders5, installMcpServerToAll: installMcpServerToAll2 } = await import("@cleocode/caamp");
65680
- const env = detectEnvMode2();
65681
- const serverEntry = generateMcpServerEntry2(env);
65682
- const serverName = getMcpServerName2(env);
65683
- const providers = getInstalledProviders5();
65684
- if (providers.length > 0) {
65685
- if (!ctx.isDryRun) {
65686
- const results = await installMcpServerToAll2(
65687
- providers,
65688
- serverName,
65689
- serverEntry,
65690
- "global",
65691
- homedir6()
65692
- );
65693
- const successes = results.filter((r) => r.success);
65694
- if (successes.length > 0) {
65695
- ctx.created.push(
65696
- `MCP configs: ${successes.map((r) => r.provider.id).join(", ")}`
65697
- );
65698
- }
65699
- } else {
65700
- ctx.created.push("MCP configs (would update)");
65701
- }
65702
- }
65703
- } catch {
65704
- ctx.warnings.push("MCP config update skipped (non-critical)");
65705
- }
65706
- }
65707
- async function installSkillsGlobally(ctx) {
65708
- try {
65709
- if (!ctx.isDryRun) {
65710
- const { initCoreSkills: initCoreSkills2 } = await Promise.resolve().then(() => (init_init(), init_exports));
65711
- await initCoreSkills2(ctx.created, ctx.warnings);
65712
- } else {
65713
- ctx.created.push("core skills (would install/update)");
65714
- }
65715
- } catch (err) {
65716
- ctx.warnings.push(
65717
- `Core skills installation failed: ${err instanceof Error ? err.message : String(err)}`
65718
- );
65719
- }
65720
- }
65721
- async function installAgentDefinitionGlobally(ctx) {
65722
- try {
65723
- if (!ctx.isDryRun) {
65724
- const { initAgentDefinition: initAgentDefinition2 } = await Promise.resolve().then(() => (init_init(), init_exports));
65725
- await initAgentDefinition2(ctx.created, ctx.warnings);
65726
- } else {
65727
- ctx.created.push("agent: cleo-subagent (would symlink)");
65728
- }
65729
- } catch (err) {
65730
- ctx.warnings.push(
65731
- `Agent definition install: ${err instanceof Error ? err.message : String(err)}`
65732
- );
65733
- }
65734
- }
65735
- async function installProviderAdapters(ctx, packageRootOverride) {
65736
- try {
65737
- const { AdapterManager: AdapterManager2 } = await Promise.resolve().then(() => (init_adapters(), adapters_exports));
65738
- const pkgRoot = packageRootOverride ?? getPackageRoot();
65739
- const manager = AdapterManager2.getInstance(pkgRoot);
65740
- manager.discover();
65741
- const detected = manager.detectActive();
65742
- for (const adapterId of detected) {
65743
- try {
65744
- const adapter = await manager.activate(adapterId);
65745
- if (adapter.install) {
65746
- if (!ctx.isDryRun) {
65747
- const installResult = await adapter.install.install({
65748
- projectDir: process.cwd()
65749
- });
65750
- if (installResult.success) {
65751
- ctx.created.push(`${adapterId} adapter (installed)`);
65752
- }
65753
- } else {
65754
- ctx.created.push(`${adapterId} adapter (would install)`);
65755
- }
65756
- }
65757
- } catch (activateErr) {
65758
- ctx.warnings.push(
65759
- `Adapter ${adapterId} skipped: ${activateErr instanceof Error ? activateErr.message : String(activateErr)}`
65760
- );
65761
- }
65762
- }
65763
- } catch (err) {
65764
- ctx.warnings.push(
65765
- `Adapter install skipped: ${err instanceof Error ? err.message : String(err)}`
65766
- );
65767
- }
65768
- }
65769
- var init_bootstrap = __esm({
65770
- "packages/core/src/bootstrap.ts"() {
65771
- "use strict";
65772
- init_paths();
65773
- init_scaffold();
65774
- }
65775
- });
65776
-
65777
65779
  // packages/core/src/compliance/protocol-rules.ts
65778
65780
  function hasField(obj, field) {
65779
65781
  const value = obj[field];