@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/bin/postinstall.js +9 -2
- package/dist/cli/index.js +242 -228
- package/dist/cli/index.js.map +4 -4
- package/dist/mcp/index.js +241 -228
- package/dist/mcp/index.js.map +4 -4
- package/package.json +4 -4
package/bin/postinstall.js
CHANGED
|
@@ -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
|
|
59
|
-
|
|
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
|
@@ -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
|
-
|
|
35543
|
-
|
|
35544
|
-
|
|
35545
|
-
|
|
35546
|
-
|
|
35547
|
-
|
|
35548
|
-
|
|
35549
|
-
|
|
35550
|
-
|
|
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
|
}
|
|
@@ -64979,6 +64987,228 @@ var init_project_info = __esm({
|
|
|
64979
64987
|
}
|
|
64980
64988
|
});
|
|
64981
64989
|
|
|
64990
|
+
// packages/core/src/bootstrap.ts
|
|
64991
|
+
import { existsSync as existsSync103, readFileSync as readFileSync76 } from "node:fs";
|
|
64992
|
+
import { mkdir as mkdir17, readFile as readFile19, writeFile as writeFile12 } from "node:fs/promises";
|
|
64993
|
+
import { homedir as homedir6 } from "node:os";
|
|
64994
|
+
import { join as join103 } from "node:path";
|
|
64995
|
+
async function bootstrapGlobalCleo(options) {
|
|
64996
|
+
const ctx = {
|
|
64997
|
+
created: [],
|
|
64998
|
+
warnings: [],
|
|
64999
|
+
isDryRun: options?.dryRun ?? false
|
|
65000
|
+
};
|
|
65001
|
+
try {
|
|
65002
|
+
await ensureGlobalHome();
|
|
65003
|
+
} catch {
|
|
65004
|
+
}
|
|
65005
|
+
await ensureGlobalTemplatesBootstrap(ctx, options?.packageRoot);
|
|
65006
|
+
await injectAgentsHub(ctx);
|
|
65007
|
+
await installMcpToProviders(ctx);
|
|
65008
|
+
await installSkillsGlobally(ctx);
|
|
65009
|
+
await installAgentDefinitionGlobally(ctx);
|
|
65010
|
+
await installProviderAdapters(ctx, options?.packageRoot);
|
|
65011
|
+
return ctx;
|
|
65012
|
+
}
|
|
65013
|
+
async function ensureGlobalTemplatesBootstrap(ctx, packageRootOverride) {
|
|
65014
|
+
const globalTemplatesDir = getCleoTemplatesDir();
|
|
65015
|
+
if (!ctx.isDryRun) {
|
|
65016
|
+
await mkdir17(globalTemplatesDir, { recursive: true });
|
|
65017
|
+
}
|
|
65018
|
+
try {
|
|
65019
|
+
const pkgRoot = packageRootOverride ?? getPackageRoot();
|
|
65020
|
+
const templatePath = join103(pkgRoot, "templates", "CLEO-INJECTION.md");
|
|
65021
|
+
if (existsSync103(templatePath)) {
|
|
65022
|
+
const content = readFileSync76(templatePath, "utf-8");
|
|
65023
|
+
const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
|
|
65024
|
+
if (!ctx.isDryRun) {
|
|
65025
|
+
await writeFile12(destPath, content);
|
|
65026
|
+
}
|
|
65027
|
+
ctx.created.push(
|
|
65028
|
+
`~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"})`
|
|
65029
|
+
);
|
|
65030
|
+
} else {
|
|
65031
|
+
try {
|
|
65032
|
+
const { getInjectionTemplateContent: getInjectionTemplateContent2 } = await Promise.resolve().then(() => (init_injection(), injection_exports));
|
|
65033
|
+
const content = getInjectionTemplateContent2();
|
|
65034
|
+
if (content) {
|
|
65035
|
+
const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
|
|
65036
|
+
if (!ctx.isDryRun) {
|
|
65037
|
+
await writeFile12(destPath, content);
|
|
65038
|
+
}
|
|
65039
|
+
ctx.created.push(
|
|
65040
|
+
`~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"} from embedded)`
|
|
65041
|
+
);
|
|
65042
|
+
}
|
|
65043
|
+
} catch {
|
|
65044
|
+
ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
|
|
65045
|
+
}
|
|
65046
|
+
}
|
|
65047
|
+
} catch {
|
|
65048
|
+
ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
|
|
65049
|
+
}
|
|
65050
|
+
}
|
|
65051
|
+
async function injectAgentsHub(ctx) {
|
|
65052
|
+
const globalAgentsDir = getAgentsHome();
|
|
65053
|
+
const globalAgentsMd = join103(globalAgentsDir, "AGENTS.md");
|
|
65054
|
+
try {
|
|
65055
|
+
const { inject: inject2, getInstalledProviders: getInstalledProviders5, injectAll: injectAll3, buildInjectionContent: buildInjectionContent2 } = await import("@cleocode/caamp");
|
|
65056
|
+
if (!ctx.isDryRun) {
|
|
65057
|
+
await mkdir17(globalAgentsDir, { recursive: true });
|
|
65058
|
+
if (existsSync103(globalAgentsMd)) {
|
|
65059
|
+
const content = await readFile19(globalAgentsMd, "utf8");
|
|
65060
|
+
const stripped = content.replace(
|
|
65061
|
+
/\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
|
|
65062
|
+
""
|
|
65063
|
+
);
|
|
65064
|
+
if (stripped !== content) {
|
|
65065
|
+
await writeFile12(globalAgentsMd, stripped, "utf8");
|
|
65066
|
+
}
|
|
65067
|
+
}
|
|
65068
|
+
const expectedContent = "@~/.cleo/templates/CLEO-INJECTION.md";
|
|
65069
|
+
const action = await inject2(globalAgentsMd, expectedContent);
|
|
65070
|
+
ctx.created.push(`~/.agents/AGENTS.md (${action})`);
|
|
65071
|
+
} else {
|
|
65072
|
+
ctx.created.push("~/.agents/AGENTS.md (would create/update CAAMP block)");
|
|
65073
|
+
}
|
|
65074
|
+
const providers = getInstalledProviders5();
|
|
65075
|
+
if (providers.length === 0) {
|
|
65076
|
+
ctx.warnings.push("No AI provider installations detected");
|
|
65077
|
+
} else {
|
|
65078
|
+
const injectionContent = buildInjectionContent2({
|
|
65079
|
+
references: ["@~/.agents/AGENTS.md"]
|
|
65080
|
+
});
|
|
65081
|
+
if (!ctx.isDryRun) {
|
|
65082
|
+
for (const provider of providers) {
|
|
65083
|
+
const instructFilePath = join103(provider.pathGlobal, provider.instructFile);
|
|
65084
|
+
if (existsSync103(instructFilePath)) {
|
|
65085
|
+
const fileContent = await readFile19(instructFilePath, "utf8");
|
|
65086
|
+
const stripped = fileContent.replace(
|
|
65087
|
+
/\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
|
|
65088
|
+
""
|
|
65089
|
+
);
|
|
65090
|
+
if (stripped !== fileContent) {
|
|
65091
|
+
await writeFile12(instructFilePath, stripped, "utf8");
|
|
65092
|
+
}
|
|
65093
|
+
}
|
|
65094
|
+
}
|
|
65095
|
+
const results = await injectAll3(providers, homedir6(), "global", injectionContent);
|
|
65096
|
+
for (const [filePath, action] of results) {
|
|
65097
|
+
const displayPath = filePath.replace(homedir6(), "~");
|
|
65098
|
+
ctx.created.push(`${displayPath} (${action})`);
|
|
65099
|
+
}
|
|
65100
|
+
} else {
|
|
65101
|
+
for (const p of providers) {
|
|
65102
|
+
const displayPath = join103(p.pathGlobal, p.instructFile).replace(homedir6(), "~");
|
|
65103
|
+
ctx.created.push(`${displayPath} (would update CAAMP block)`);
|
|
65104
|
+
}
|
|
65105
|
+
}
|
|
65106
|
+
}
|
|
65107
|
+
} catch (err) {
|
|
65108
|
+
ctx.warnings.push(`CAAMP injection: ${err instanceof Error ? err.message : String(err)}`);
|
|
65109
|
+
}
|
|
65110
|
+
}
|
|
65111
|
+
async function installMcpToProviders(ctx) {
|
|
65112
|
+
try {
|
|
65113
|
+
const { detectEnvMode: detectEnvMode2, generateMcpServerEntry: generateMcpServerEntry2, getMcpServerName: getMcpServerName2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
|
|
65114
|
+
const { getInstalledProviders: getInstalledProviders5, installMcpServerToAll: installMcpServerToAll2 } = await import("@cleocode/caamp");
|
|
65115
|
+
const env = detectEnvMode2();
|
|
65116
|
+
const serverEntry = generateMcpServerEntry2(env);
|
|
65117
|
+
const serverName = getMcpServerName2(env);
|
|
65118
|
+
const providers = getInstalledProviders5();
|
|
65119
|
+
if (providers.length > 0) {
|
|
65120
|
+
if (!ctx.isDryRun) {
|
|
65121
|
+
const results = await installMcpServerToAll2(
|
|
65122
|
+
providers,
|
|
65123
|
+
serverName,
|
|
65124
|
+
serverEntry,
|
|
65125
|
+
"global",
|
|
65126
|
+
homedir6()
|
|
65127
|
+
);
|
|
65128
|
+
const successes = results.filter((r) => r.success);
|
|
65129
|
+
if (successes.length > 0) {
|
|
65130
|
+
ctx.created.push(
|
|
65131
|
+
`MCP configs: ${successes.map((r) => r.provider.id).join(", ")}`
|
|
65132
|
+
);
|
|
65133
|
+
}
|
|
65134
|
+
} else {
|
|
65135
|
+
ctx.created.push("MCP configs (would update)");
|
|
65136
|
+
}
|
|
65137
|
+
}
|
|
65138
|
+
} catch {
|
|
65139
|
+
ctx.warnings.push("MCP config update skipped (non-critical)");
|
|
65140
|
+
}
|
|
65141
|
+
}
|
|
65142
|
+
async function installSkillsGlobally(ctx) {
|
|
65143
|
+
try {
|
|
65144
|
+
if (!ctx.isDryRun) {
|
|
65145
|
+
const { initCoreSkills: initCoreSkills2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
65146
|
+
await initCoreSkills2(ctx.created, ctx.warnings);
|
|
65147
|
+
} else {
|
|
65148
|
+
ctx.created.push("core skills (would install/update)");
|
|
65149
|
+
}
|
|
65150
|
+
} catch (err) {
|
|
65151
|
+
ctx.warnings.push(
|
|
65152
|
+
`Core skills installation failed: ${err instanceof Error ? err.message : String(err)}`
|
|
65153
|
+
);
|
|
65154
|
+
}
|
|
65155
|
+
}
|
|
65156
|
+
async function installAgentDefinitionGlobally(ctx) {
|
|
65157
|
+
try {
|
|
65158
|
+
if (!ctx.isDryRun) {
|
|
65159
|
+
const { initAgentDefinition: initAgentDefinition2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
65160
|
+
await initAgentDefinition2(ctx.created, ctx.warnings);
|
|
65161
|
+
} else {
|
|
65162
|
+
ctx.created.push("agent: cleo-subagent (would symlink)");
|
|
65163
|
+
}
|
|
65164
|
+
} catch (err) {
|
|
65165
|
+
ctx.warnings.push(
|
|
65166
|
+
`Agent definition install: ${err instanceof Error ? err.message : String(err)}`
|
|
65167
|
+
);
|
|
65168
|
+
}
|
|
65169
|
+
}
|
|
65170
|
+
async function installProviderAdapters(ctx, packageRootOverride) {
|
|
65171
|
+
try {
|
|
65172
|
+
const { AdapterManager: AdapterManager2 } = await Promise.resolve().then(() => (init_adapters(), adapters_exports));
|
|
65173
|
+
const pkgRoot = packageRootOverride ?? getPackageRoot();
|
|
65174
|
+
const manager = AdapterManager2.getInstance(pkgRoot);
|
|
65175
|
+
manager.discover();
|
|
65176
|
+
const detected = manager.detectActive();
|
|
65177
|
+
for (const adapterId of detected) {
|
|
65178
|
+
try {
|
|
65179
|
+
const adapter = await manager.activate(adapterId);
|
|
65180
|
+
if (adapter.install) {
|
|
65181
|
+
if (!ctx.isDryRun) {
|
|
65182
|
+
const installResult = await adapter.install.install({
|
|
65183
|
+
projectDir: process.cwd()
|
|
65184
|
+
});
|
|
65185
|
+
if (installResult.success) {
|
|
65186
|
+
ctx.created.push(`${adapterId} adapter (installed)`);
|
|
65187
|
+
}
|
|
65188
|
+
} else {
|
|
65189
|
+
ctx.created.push(`${adapterId} adapter (would install)`);
|
|
65190
|
+
}
|
|
65191
|
+
}
|
|
65192
|
+
} catch (activateErr) {
|
|
65193
|
+
ctx.warnings.push(
|
|
65194
|
+
`Adapter ${adapterId} skipped: ${activateErr instanceof Error ? activateErr.message : String(activateErr)}`
|
|
65195
|
+
);
|
|
65196
|
+
}
|
|
65197
|
+
}
|
|
65198
|
+
} catch (err) {
|
|
65199
|
+
ctx.warnings.push(
|
|
65200
|
+
`Adapter install skipped: ${err instanceof Error ? err.message : String(err)}`
|
|
65201
|
+
);
|
|
65202
|
+
}
|
|
65203
|
+
}
|
|
65204
|
+
var init_bootstrap = __esm({
|
|
65205
|
+
"packages/core/src/bootstrap.ts"() {
|
|
65206
|
+
"use strict";
|
|
65207
|
+
init_paths();
|
|
65208
|
+
init_scaffold();
|
|
65209
|
+
}
|
|
65210
|
+
});
|
|
65211
|
+
|
|
64982
65212
|
// packages/core/src/cleo.ts
|
|
64983
65213
|
import path from "node:path";
|
|
64984
65214
|
var Cleo;
|
|
@@ -65281,6 +65511,7 @@ __export(src_exports, {
|
|
|
65281
65511
|
agentTypeSchema: () => agentTypeSchema,
|
|
65282
65512
|
agents: () => agents_exports,
|
|
65283
65513
|
archiveTasks: () => archiveTasks,
|
|
65514
|
+
bootstrapGlobalCleo: () => bootstrapGlobalCleo,
|
|
65284
65515
|
brainConfidenceLevelSchema: () => brainConfidenceLevelSchema,
|
|
65285
65516
|
brainDecisionTypeSchema: () => brainDecisionTypeSchema,
|
|
65286
65517
|
brainEdgeTypeSchema: () => brainEdgeTypeSchema,
|
|
@@ -65534,6 +65765,7 @@ var init_src2 = __esm({
|
|
|
65534
65765
|
init_project_info();
|
|
65535
65766
|
init_scaffold();
|
|
65536
65767
|
init_adapters();
|
|
65768
|
+
init_bootstrap();
|
|
65537
65769
|
init_cleo();
|
|
65538
65770
|
init_registry();
|
|
65539
65771
|
init_brain_retrieval();
|
|
@@ -65556,224 +65788,6 @@ var init_src2 = __esm({
|
|
|
65556
65788
|
}
|
|
65557
65789
|
});
|
|
65558
65790
|
|
|
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
65791
|
// packages/core/src/compliance/protocol-rules.ts
|
|
65778
65792
|
function hasField(obj, field) {
|
|
65779
65793
|
const value = obj[field];
|