@cleocode/cleo 2026.3.49 → 2026.3.50

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.
@@ -2,57 +2,61 @@
2
2
  /**
3
3
  * NPM Postinstall Hook - Bootstrap Global CLEO System
4
4
  *
5
- * This script runs automatically after `npm install -g @cleocode/cleo`.
6
- * It delegates to the shared bootstrap module in @cleocode/core so that
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
- * Bootstraps:
10
- * - ~/.cleo/ directory structure
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 { dirname, resolve } from 'node:path';
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
- // Determine if we're running from npm global install
27
- function isNpmGlobalInstall() {
28
- const execPath = process.argv[1] || '';
29
- // Check if running from node_modules/@cleocode/cleo/
30
- return (
31
- execPath.includes('node_modules/@cleocode/cleo/') ||
32
- execPath.includes('node_modules\\@cleocode\\cleo\\')
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
- // Only run for npm global installs, not local dev or other contexts
43
- if (!isNpmGlobalInstall()) {
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 the shared bootstrap from the built core dist.
52
- // At postinstall time, dist/ should already be present in the published package.
53
- const { bootstrapGlobalCleo } = await import(
54
- '../dist/core/bootstrap.js'
55
- );
58
+ // Import bootstrap from @cleocode/core (installed as dependency)
59
+ const { bootstrapGlobalCleo } = await import('@cleocode/core/internal');
56
60
 
57
61
  const result = await bootstrapGlobalCleo({
58
62
  packageRoot: getPackageRoot(),
@@ -68,16 +72,14 @@ async function runPostinstall() {
68
72
  console.log('CLEO: Global bootstrap complete!');
69
73
  console.log('CLEO: Run "cleo init" in any project to set up local CLEO.');
70
74
  } catch (err) {
71
- // Bootstrap is best-effort CAAMP/MCP may not be configured yet
72
- console.log('CLEO: CAAMP/MCP setup deferred (will complete on first use)');
75
+ console.log('CLEO: Bootstrap deferred (will complete on first "cleo install-global")');
73
76
  if (process.env.CLEO_DEBUG) {
74
77
  console.error('CLEO: Bootstrap detail:', err);
75
78
  }
76
79
  }
77
80
  }
78
81
 
79
- // Run bootstrap — never fail npm install
80
82
  runPostinstall().catch((err) => {
81
83
  console.error('CLEO: Bootstrap error (non-fatal):', err.message);
82
- process.exit(0); // Never fail npm install
84
+ process.exit(0);
83
85
  });
package/dist/cli/index.js CHANGED
@@ -65568,8 +65568,7 @@ async function bootstrapGlobalCleo(options) {
65568
65568
  isDryRun: options?.dryRun ?? false
65569
65569
  };
65570
65570
  try {
65571
- const { ensureGlobalHome: ensureGlobalHome2 } = await Promise.resolve().then(() => (init_scaffold(), scaffold_exports));
65572
- await ensureGlobalHome2();
65571
+ await ensureGlobalHome();
65573
65572
  } catch {
65574
65573
  }
65575
65574
  await ensureGlobalTemplatesBootstrap(ctx, options?.packageRoot);