@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/bin/postinstall.js +41 -32
- package/dist/cli/index.js +220 -219
- package/dist/cli/index.js.map +4 -4
- package/dist/mcp/index.js +219 -219
- package/dist/mcp/index.js.map +4 -4
- package/package.json +3 -3
package/bin/postinstall.js
CHANGED
|
@@ -2,57 +2,68 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* NPM Postinstall Hook - Bootstrap Global CLEO System
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* both postinstall and `cleo install-global` use the same logic.
|
|
5
|
+
* Runs automatically after `npm install -g @cleocode/cleo`.
|
|
6
|
+
* Delegates to @cleocode/core's bootstrapGlobalCleo().
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - Global templates (CLEO-INJECTION.md)
|
|
12
|
-
* - CAAMP provider configs
|
|
13
|
-
* - MCP server to detected providers
|
|
14
|
-
* - Core skills globally
|
|
15
|
-
* - Provider adapters
|
|
8
|
+
* Detection: runs bootstrap when installed in a global node_modules path.
|
|
9
|
+
* Skips for workspace/dev installs (no global prefix in path).
|
|
16
10
|
*
|
|
17
11
|
* @task T5267
|
|
18
12
|
*/
|
|
19
13
|
|
|
20
|
-
import {
|
|
14
|
+
import { existsSync } from 'node:fs';
|
|
15
|
+
import { dirname, join, resolve } from 'node:path';
|
|
21
16
|
import { fileURLToPath } from 'node:url';
|
|
22
17
|
|
|
23
18
|
const __filename = fileURLToPath(import.meta.url);
|
|
24
19
|
const __dirname = dirname(__filename);
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
)
|
|
21
|
+
/**
|
|
22
|
+
* Detect if this is a global npm install (not a workspace/dev install).
|
|
23
|
+
* Checks multiple signals since npm staging paths vary by version.
|
|
24
|
+
*/
|
|
25
|
+
function isGlobalInstall() {
|
|
26
|
+
const pkgRoot = resolve(__dirname, '..');
|
|
27
|
+
|
|
28
|
+
// Signal 1: npm_config_global env var (set by npm during global installs)
|
|
29
|
+
if (process.env.npm_config_global === 'true') return true;
|
|
30
|
+
|
|
31
|
+
// Signal 2: path contains a global node_modules (npm, pnpm, yarn)
|
|
32
|
+
if (/[/\\]lib[/\\]node_modules[/\\]/.test(pkgRoot)) return true;
|
|
33
|
+
|
|
34
|
+
// Signal 3: npm_config_prefix matches the package path
|
|
35
|
+
const prefix = process.env.npm_config_prefix;
|
|
36
|
+
if (prefix && pkgRoot.startsWith(prefix)) return true;
|
|
37
|
+
|
|
38
|
+
// Signal 4: not inside a pnpm workspace (no workspace root marker)
|
|
39
|
+
const workspaceMarker = join(pkgRoot, '..', '..', 'pnpm-workspace.yaml');
|
|
40
|
+
if (existsSync(workspaceMarker)) return false;
|
|
41
|
+
|
|
42
|
+
return false;
|
|
34
43
|
}
|
|
35
44
|
|
|
36
|
-
// Get package root (bin/ is one level below package root)
|
|
37
45
|
function getPackageRoot() {
|
|
38
46
|
return resolve(__dirname, '..');
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
async function runPostinstall() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
console.log('CLEO: Skipping global bootstrap (not npm global install)');
|
|
50
|
+
if (!isGlobalInstall()) {
|
|
51
|
+
console.log('CLEO: Skipping global bootstrap (not global install)');
|
|
45
52
|
return;
|
|
46
53
|
}
|
|
47
54
|
|
|
48
55
|
console.log('CLEO: Bootstrapping global system...');
|
|
49
56
|
|
|
50
57
|
try {
|
|
51
|
-
// Import
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
+
}
|
|
56
67
|
|
|
57
68
|
const result = await bootstrapGlobalCleo({
|
|
58
69
|
packageRoot: getPackageRoot(),
|
|
@@ -68,16 +79,14 @@ async function runPostinstall() {
|
|
|
68
79
|
console.log('CLEO: Global bootstrap complete!');
|
|
69
80
|
console.log('CLEO: Run "cleo init" in any project to set up local CLEO.');
|
|
70
81
|
} catch (err) {
|
|
71
|
-
|
|
72
|
-
console.log('CLEO: CAAMP/MCP setup deferred (will complete on first use)');
|
|
82
|
+
console.log('CLEO: Bootstrap deferred (will complete on first "cleo install-global")');
|
|
73
83
|
if (process.env.CLEO_DEBUG) {
|
|
74
84
|
console.error('CLEO: Bootstrap detail:', err);
|
|
75
85
|
}
|
|
76
86
|
}
|
|
77
87
|
}
|
|
78
88
|
|
|
79
|
-
// Run bootstrap — never fail npm install
|
|
80
89
|
runPostinstall().catch((err) => {
|
|
81
90
|
console.error('CLEO: Bootstrap error (non-fatal):', err.message);
|
|
82
|
-
process.exit(0);
|
|
91
|
+
process.exit(0);
|
|
83
92
|
});
|
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,225 +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
|
-
const { ensureGlobalHome: ensureGlobalHome2 } = await Promise.resolve().then(() => (init_scaffold(), scaffold_exports));
|
|
65572
|
-
await ensureGlobalHome2();
|
|
65573
|
-
} catch {
|
|
65574
|
-
}
|
|
65575
|
-
await ensureGlobalTemplatesBootstrap(ctx, options?.packageRoot);
|
|
65576
|
-
await injectAgentsHub(ctx);
|
|
65577
|
-
await installMcpToProviders(ctx);
|
|
65578
|
-
await installSkillsGlobally(ctx);
|
|
65579
|
-
await installAgentDefinitionGlobally(ctx);
|
|
65580
|
-
await installProviderAdapters(ctx, options?.packageRoot);
|
|
65581
|
-
return ctx;
|
|
65582
|
-
}
|
|
65583
|
-
async function ensureGlobalTemplatesBootstrap(ctx, packageRootOverride) {
|
|
65584
|
-
const globalTemplatesDir = getCleoTemplatesDir();
|
|
65585
|
-
if (!ctx.isDryRun) {
|
|
65586
|
-
await mkdir17(globalTemplatesDir, { recursive: true });
|
|
65587
|
-
}
|
|
65588
|
-
try {
|
|
65589
|
-
const pkgRoot = packageRootOverride ?? getPackageRoot();
|
|
65590
|
-
const templatePath = join103(pkgRoot, "templates", "CLEO-INJECTION.md");
|
|
65591
|
-
if (existsSync103(templatePath)) {
|
|
65592
|
-
const content = readFileSync76(templatePath, "utf-8");
|
|
65593
|
-
const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
|
|
65594
|
-
if (!ctx.isDryRun) {
|
|
65595
|
-
await writeFile12(destPath, content);
|
|
65596
|
-
}
|
|
65597
|
-
ctx.created.push(
|
|
65598
|
-
`~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"})`
|
|
65599
|
-
);
|
|
65600
|
-
} else {
|
|
65601
|
-
try {
|
|
65602
|
-
const { getInjectionTemplateContent: getInjectionTemplateContent2 } = await Promise.resolve().then(() => (init_injection(), injection_exports));
|
|
65603
|
-
const content = getInjectionTemplateContent2();
|
|
65604
|
-
if (content) {
|
|
65605
|
-
const destPath = join103(globalTemplatesDir, "CLEO-INJECTION.md");
|
|
65606
|
-
if (!ctx.isDryRun) {
|
|
65607
|
-
await writeFile12(destPath, content);
|
|
65608
|
-
}
|
|
65609
|
-
ctx.created.push(
|
|
65610
|
-
`~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? "would refresh" : "refreshed"} from embedded)`
|
|
65611
|
-
);
|
|
65612
|
-
}
|
|
65613
|
-
} catch {
|
|
65614
|
-
ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
|
|
65615
|
-
}
|
|
65616
|
-
}
|
|
65617
|
-
} catch {
|
|
65618
|
-
ctx.warnings.push("Could not refresh CLEO-INJECTION.md template");
|
|
65619
|
-
}
|
|
65620
|
-
}
|
|
65621
|
-
async function injectAgentsHub(ctx) {
|
|
65622
|
-
const globalAgentsDir = getAgentsHome();
|
|
65623
|
-
const globalAgentsMd = join103(globalAgentsDir, "AGENTS.md");
|
|
65624
|
-
try {
|
|
65625
|
-
const { inject: inject2, getInstalledProviders: getInstalledProviders5, injectAll: injectAll3, buildInjectionContent: buildInjectionContent2 } = await import("@cleocode/caamp");
|
|
65626
|
-
if (!ctx.isDryRun) {
|
|
65627
|
-
await mkdir17(globalAgentsDir, { recursive: true });
|
|
65628
|
-
if (existsSync103(globalAgentsMd)) {
|
|
65629
|
-
const content = await readFile19(globalAgentsMd, "utf8");
|
|
65630
|
-
const stripped = content.replace(/\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g, "").replace(/\n?<!-- CAAMP:START -->[\s\S]*?<!-- CAAMP:END -->\n?/g, "").trim();
|
|
65631
|
-
await writeFile12(globalAgentsMd, stripped ? `${stripped}
|
|
65632
|
-
` : "", "utf8");
|
|
65633
|
-
}
|
|
65634
|
-
const expectedContent = "@~/.cleo/templates/CLEO-INJECTION.md";
|
|
65635
|
-
const action = await inject2(globalAgentsMd, expectedContent);
|
|
65636
|
-
ctx.created.push(`~/.agents/AGENTS.md (${action})`);
|
|
65637
|
-
} else {
|
|
65638
|
-
ctx.created.push("~/.agents/AGENTS.md (would create/update CAAMP block)");
|
|
65639
|
-
}
|
|
65640
|
-
const providers = getInstalledProviders5();
|
|
65641
|
-
if (providers.length === 0) {
|
|
65642
|
-
ctx.warnings.push("No AI provider installations detected");
|
|
65643
|
-
} else {
|
|
65644
|
-
const injectionContent = buildInjectionContent2({
|
|
65645
|
-
references: ["@~/.agents/AGENTS.md"]
|
|
65646
|
-
});
|
|
65647
|
-
if (!ctx.isDryRun) {
|
|
65648
|
-
for (const provider of providers) {
|
|
65649
|
-
const instructFilePath = join103(provider.pathGlobal, provider.instructFile);
|
|
65650
|
-
if (existsSync103(instructFilePath)) {
|
|
65651
|
-
const fileContent = await readFile19(instructFilePath, "utf8");
|
|
65652
|
-
const stripped = fileContent.replace(
|
|
65653
|
-
/\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
|
|
65654
|
-
""
|
|
65655
|
-
);
|
|
65656
|
-
if (stripped !== fileContent) {
|
|
65657
|
-
await writeFile12(instructFilePath, stripped, "utf8");
|
|
65658
|
-
}
|
|
65659
|
-
}
|
|
65660
|
-
}
|
|
65661
|
-
const results = await injectAll3(providers, homedir6(), "global", injectionContent);
|
|
65662
|
-
for (const [filePath, action] of results) {
|
|
65663
|
-
const displayPath = filePath.replace(homedir6(), "~");
|
|
65664
|
-
ctx.created.push(`${displayPath} (${action})`);
|
|
65665
|
-
}
|
|
65666
|
-
} else {
|
|
65667
|
-
for (const p of providers) {
|
|
65668
|
-
const displayPath = join103(p.pathGlobal, p.instructFile).replace(homedir6(), "~");
|
|
65669
|
-
ctx.created.push(`${displayPath} (would update CAAMP block)`);
|
|
65670
|
-
}
|
|
65671
|
-
}
|
|
65672
|
-
}
|
|
65673
|
-
} catch (err) {
|
|
65674
|
-
ctx.warnings.push(`CAAMP injection: ${err instanceof Error ? err.message : String(err)}`);
|
|
65675
|
-
}
|
|
65676
|
-
}
|
|
65677
|
-
async function installMcpToProviders(ctx) {
|
|
65678
|
-
try {
|
|
65679
|
-
const { detectEnvMode: detectEnvMode2, generateMcpServerEntry: generateMcpServerEntry2, getMcpServerName: getMcpServerName2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
|
|
65680
|
-
const { getInstalledProviders: getInstalledProviders5, installMcpServerToAll: installMcpServerToAll2 } = await import("@cleocode/caamp");
|
|
65681
|
-
const env = detectEnvMode2();
|
|
65682
|
-
const serverEntry = generateMcpServerEntry2(env);
|
|
65683
|
-
const serverName = getMcpServerName2(env);
|
|
65684
|
-
const providers = getInstalledProviders5();
|
|
65685
|
-
if (providers.length > 0) {
|
|
65686
|
-
if (!ctx.isDryRun) {
|
|
65687
|
-
const results = await installMcpServerToAll2(
|
|
65688
|
-
providers,
|
|
65689
|
-
serverName,
|
|
65690
|
-
serverEntry,
|
|
65691
|
-
"global",
|
|
65692
|
-
homedir6()
|
|
65693
|
-
);
|
|
65694
|
-
const successes = results.filter((r) => r.success);
|
|
65695
|
-
if (successes.length > 0) {
|
|
65696
|
-
ctx.created.push(
|
|
65697
|
-
`MCP configs: ${successes.map((r) => r.provider.id).join(", ")}`
|
|
65698
|
-
);
|
|
65699
|
-
}
|
|
65700
|
-
} else {
|
|
65701
|
-
ctx.created.push("MCP configs (would update)");
|
|
65702
|
-
}
|
|
65703
|
-
}
|
|
65704
|
-
} catch {
|
|
65705
|
-
ctx.warnings.push("MCP config update skipped (non-critical)");
|
|
65706
|
-
}
|
|
65707
|
-
}
|
|
65708
|
-
async function installSkillsGlobally(ctx) {
|
|
65709
|
-
try {
|
|
65710
|
-
if (!ctx.isDryRun) {
|
|
65711
|
-
const { initCoreSkills: initCoreSkills2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
65712
|
-
await initCoreSkills2(ctx.created, ctx.warnings);
|
|
65713
|
-
} else {
|
|
65714
|
-
ctx.created.push("core skills (would install/update)");
|
|
65715
|
-
}
|
|
65716
|
-
} catch (err) {
|
|
65717
|
-
ctx.warnings.push(
|
|
65718
|
-
`Core skills installation failed: ${err instanceof Error ? err.message : String(err)}`
|
|
65719
|
-
);
|
|
65720
|
-
}
|
|
65721
|
-
}
|
|
65722
|
-
async function installAgentDefinitionGlobally(ctx) {
|
|
65723
|
-
try {
|
|
65724
|
-
if (!ctx.isDryRun) {
|
|
65725
|
-
const { initAgentDefinition: initAgentDefinition2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
65726
|
-
await initAgentDefinition2(ctx.created, ctx.warnings);
|
|
65727
|
-
} else {
|
|
65728
|
-
ctx.created.push("agent: cleo-subagent (would symlink)");
|
|
65729
|
-
}
|
|
65730
|
-
} catch (err) {
|
|
65731
|
-
ctx.warnings.push(
|
|
65732
|
-
`Agent definition install: ${err instanceof Error ? err.message : String(err)}`
|
|
65733
|
-
);
|
|
65734
|
-
}
|
|
65735
|
-
}
|
|
65736
|
-
async function installProviderAdapters(ctx, packageRootOverride) {
|
|
65737
|
-
try {
|
|
65738
|
-
const { AdapterManager: AdapterManager2 } = await Promise.resolve().then(() => (init_adapters(), adapters_exports));
|
|
65739
|
-
const pkgRoot = packageRootOverride ?? getPackageRoot();
|
|
65740
|
-
const manager = AdapterManager2.getInstance(pkgRoot);
|
|
65741
|
-
manager.discover();
|
|
65742
|
-
const detected = manager.detectActive();
|
|
65743
|
-
for (const adapterId of detected) {
|
|
65744
|
-
try {
|
|
65745
|
-
const adapter = await manager.activate(adapterId);
|
|
65746
|
-
if (adapter.install) {
|
|
65747
|
-
if (!ctx.isDryRun) {
|
|
65748
|
-
const installResult = await adapter.install.install({
|
|
65749
|
-
projectDir: process.cwd()
|
|
65750
|
-
});
|
|
65751
|
-
if (installResult.success) {
|
|
65752
|
-
ctx.created.push(`${adapterId} adapter (installed)`);
|
|
65753
|
-
}
|
|
65754
|
-
} else {
|
|
65755
|
-
ctx.created.push(`${adapterId} adapter (would install)`);
|
|
65756
|
-
}
|
|
65757
|
-
}
|
|
65758
|
-
} catch (activateErr) {
|
|
65759
|
-
ctx.warnings.push(
|
|
65760
|
-
`Adapter ${adapterId} skipped: ${activateErr instanceof Error ? activateErr.message : String(activateErr)}`
|
|
65761
|
-
);
|
|
65762
|
-
}
|
|
65763
|
-
}
|
|
65764
|
-
} catch (err) {
|
|
65765
|
-
ctx.warnings.push(
|
|
65766
|
-
`Adapter install skipped: ${err instanceof Error ? err.message : String(err)}`
|
|
65767
|
-
);
|
|
65768
|
-
}
|
|
65769
|
-
}
|
|
65770
|
-
var init_bootstrap = __esm({
|
|
65771
|
-
"packages/core/src/bootstrap.ts"() {
|
|
65772
|
-
"use strict";
|
|
65773
|
-
init_paths();
|
|
65774
|
-
init_scaffold();
|
|
65775
|
-
}
|
|
65776
|
-
});
|
|
65777
|
-
|
|
65778
65779
|
// packages/core/src/compliance/protocol-rules.ts
|
|
65779
65780
|
function hasField(obj, field) {
|
|
65780
65781
|
const value = obj[field];
|