@cleocode/cleo 2026.3.10 → 2026.3.12

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/cli/index.js CHANGED
@@ -14959,8 +14959,8 @@ async function getSystemDiagnostics(projectRoot, opts) {
14959
14959
  }
14960
14960
  async function commandExists2(cmd) {
14961
14961
  try {
14962
- const { stdout } = await execAsync("which", [cmd]);
14963
- return stdout.trim();
14962
+ const { stdout: stdout2 } = await execAsync("which", [cmd]);
14963
+ return stdout2.trim();
14964
14964
  } catch {
14965
14965
  return null;
14966
14966
  }
@@ -15612,8 +15612,8 @@ async function resolveBinaryPath(name) {
15612
15612
  const execFileAsync5 = promisify5(execFile5);
15613
15613
  const resolver = process.platform === "win32" ? "where" : "which";
15614
15614
  try {
15615
- const { stdout } = await execFileAsync5(resolver, [name]);
15616
- const first = stdout.trim().split(/\r?\n/)[0] ?? "";
15615
+ const { stdout: stdout2 } = await execFileAsync5(resolver, [name]);
15616
+ const first = stdout2.trim().split(/\r?\n/)[0] ?? "";
15617
15617
  return first || null;
15618
15618
  } catch {
15619
15619
  return null;
@@ -16265,6 +16265,20 @@ function getMcpServerName(env) {
16265
16265
  return "cleo";
16266
16266
  }
16267
16267
  function detectEnvMode() {
16268
+ const scriptPath = (process.argv[1] ?? "").replace(/\\/g, "/");
16269
+ const marker = "/node_modules/@cleocode/cleo/";
16270
+ const markerIdx = scriptPath.indexOf(marker);
16271
+ if (markerIdx >= 0) {
16272
+ const pkgRoot = scriptPath.slice(0, markerIdx + marker.length);
16273
+ let channel2 = "stable";
16274
+ try {
16275
+ const pkg = JSON.parse(readFileSync19(join29(pkgRoot, "package.json"), "utf-8"));
16276
+ channel2 = (pkg.version ?? "").includes("-beta") ? "beta" : "stable";
16277
+ } catch {
16278
+ channel2 = "stable";
16279
+ }
16280
+ return { mode: "prod-npm", source: "npm", channel: channel2 };
16281
+ }
16268
16282
  const versionPath = join29(
16269
16283
  process.env["CLEO_HOME"] ?? join29(homedir6(), ".cleo"),
16270
16284
  "VERSION"
@@ -16644,7 +16658,7 @@ async function initMcpServer(projectRoot, created, warnings) {
16644
16658
  providers,
16645
16659
  serverName,
16646
16660
  serverEntry,
16647
- "project",
16661
+ "global",
16648
16662
  projectRoot
16649
16663
  );
16650
16664
  const successes = results.filter((r) => r.success);
@@ -16871,7 +16885,6 @@ async function initProject(opts = {}) {
16871
16885
  warnings.push(`CAAMP injection: ${err instanceof Error ? err.message : String(err)}`);
16872
16886
  }
16873
16887
  await initAgentDefinition(created, warnings);
16874
- await initMcpServer(projRoot, created, warnings);
16875
16888
  await initCoreSkills(created, warnings);
16876
16889
  await initNexusRegistration(projRoot, projectName, created, warnings);
16877
16890
  const rootGitignoreResult = await removeCleoFromRootGitignore(projRoot);
@@ -31284,7 +31297,7 @@ import {
31284
31297
  getProvider
31285
31298
  } from "@cleocode/caamp";
31286
31299
  function registerMcpInstallCommand(program2) {
31287
- program2.command("mcp-install").description("Configure CLEO MCP server integration (env-aware, via CAAMP)").option("--tool <name>", "Configure a single tool/provider (claude-code, cursor, windsurf, etc.)").option("--global", "Use global/user config scope").option("--project", "Use project-level config scope").option("--all", "Configure all detected providers").option("--dry-run", "Preview changes without writing files").option("--force", "Overwrite existing cleo config entries").option("--list-tools", "List detected AI tools/providers").action(async (opts) => {
31300
+ program2.command("mcp-install").description("Configure CLEO MCP server integration (env-aware, global by default, via CAAMP)").option("--tool <name>", "Configure a single tool/provider (claude-code, cursor, windsurf, etc.)").option("--global", "Use global/user config scope (default)").option("--project", "Use project-level config scope (opt-in)").option("--all", "Configure all detected providers").option("--dry-run", "Preview changes without writing files").option("--force", "Overwrite existing cleo config entries").option("--list-tools", "List detected AI tools/providers").action(async (opts) => {
31288
31301
  try {
31289
31302
  if (opts["listTools"]) {
31290
31303
  const providers2 = getInstalledProviders2();
@@ -31305,7 +31318,7 @@ function registerMcpInstallCommand(program2) {
31305
31318
  const env = detectEnvMode();
31306
31319
  const serverEntry = generateMcpServerEntry(env);
31307
31320
  const serverName = getMcpServerName(env);
31308
- const scope = opts["global"] ? "global" : "project";
31321
+ const scope = opts["project"] ? "project" : "global";
31309
31322
  const projectDir = process.cwd();
31310
31323
  if (opts["tool"]) {
31311
31324
  const provider = getProvider(opts["tool"]);
@@ -34665,16 +34678,143 @@ function registerDecompositionCommand(program2) {
34665
34678
 
34666
34679
  // src/cli/commands/doctor.ts
34667
34680
  init_cli();
34668
- function registerDoctorCommand(program2) {
34669
- program2.command("doctor").description("Run system diagnostics and health checks").option("--detailed", "Show detailed health check results").option("--comprehensive", "Run comprehensive doctor report").option("--fix", "Auto-fix failed checks").action(async (opts) => {
34670
- if (opts["fix"]) {
34671
- await dispatchFromCli("mutate", "admin", "fix", {}, { command: "doctor", operation: "admin.fix" });
34672
- } else if (opts["comprehensive"]) {
34673
- await dispatchFromCli("query", "admin", "doctor", {}, { command: "doctor", operation: "admin.doctor" });
34681
+
34682
+ // src/cli/progress.ts
34683
+ import { stderr, stdout } from "node:process";
34684
+ var ProgressTracker = class {
34685
+ enabled;
34686
+ prefix;
34687
+ currentStep = 0;
34688
+ totalSteps;
34689
+ steps;
34690
+ constructor(options) {
34691
+ this.enabled = options.enabled;
34692
+ this.prefix = options.prefix ?? "CLEO";
34693
+ this.steps = options.steps;
34694
+ this.totalSteps = options.steps.length;
34695
+ }
34696
+ /**
34697
+ * Start the progress tracker.
34698
+ */
34699
+ start() {
34700
+ if (!this.enabled) return;
34701
+ this.currentStep = 0;
34702
+ stderr.write(`
34703
+ ${this.prefix}: Starting...
34704
+ `);
34705
+ }
34706
+ /**
34707
+ * Update to a specific step.
34708
+ */
34709
+ step(index3, message) {
34710
+ if (!this.enabled) return;
34711
+ this.currentStep = index3;
34712
+ const stepName = this.steps[index3] ?? message ?? "Working...";
34713
+ const progress = `[${index3 + 1}/${this.totalSteps}]`;
34714
+ stderr.write(` ${progress} ${stepName}...
34715
+ `);
34716
+ }
34717
+ /**
34718
+ * Move to next step.
34719
+ */
34720
+ next(message) {
34721
+ this.step(this.currentStep + 1, message);
34722
+ }
34723
+ /**
34724
+ * Mark as complete with optional summary.
34725
+ */
34726
+ complete(summary) {
34727
+ if (!this.enabled) return;
34728
+ if (summary) {
34729
+ stdout.write(`
34730
+ ${this.prefix}: \u2713 ${summary}
34731
+
34732
+ `);
34674
34733
  } else {
34675
- await dispatchFromCli("query", "admin", "health", {
34676
- detailed: opts["detailed"]
34677
- }, { command: "doctor", operation: "admin.health" });
34734
+ stdout.write(`
34735
+ ${this.prefix}: \u2713 Complete
34736
+
34737
+ `);
34738
+ }
34739
+ }
34740
+ /**
34741
+ * Report an error.
34742
+ */
34743
+ error(message) {
34744
+ if (!this.enabled) return;
34745
+ stderr.write(`
34746
+ ${this.prefix}: \u2717 ${message}
34747
+
34748
+ `);
34749
+ }
34750
+ };
34751
+ function createSelfUpdateProgress(enabled) {
34752
+ return new ProgressTracker({
34753
+ enabled,
34754
+ prefix: "CLEO",
34755
+ steps: [
34756
+ "Detecting installation type",
34757
+ "Checking current version",
34758
+ "Querying npm registry",
34759
+ "Comparing versions",
34760
+ "Running post-update checks",
34761
+ "Finalizing"
34762
+ ]
34763
+ });
34764
+ }
34765
+ function createDoctorProgress(enabled) {
34766
+ return new ProgressTracker({
34767
+ enabled,
34768
+ prefix: "CLEO Doctor",
34769
+ steps: [
34770
+ "Checking CLEO directory",
34771
+ "Verifying tasks database",
34772
+ "Checking configuration",
34773
+ "Validating schemas",
34774
+ "Running health checks"
34775
+ ]
34776
+ });
34777
+ }
34778
+ function createUpgradeProgress(enabled) {
34779
+ return new ProgressTracker({
34780
+ enabled,
34781
+ prefix: "CLEO Upgrade",
34782
+ steps: [
34783
+ "Analyzing current state",
34784
+ "Checking storage migration needs",
34785
+ "Validating schemas",
34786
+ "Applying fixes",
34787
+ "Verifying results"
34788
+ ]
34789
+ });
34790
+ }
34791
+
34792
+ // src/cli/commands/doctor.ts
34793
+ function registerDoctorCommand(program2) {
34794
+ program2.command("doctor").description("Run system diagnostics and health checks").option("--detailed", "Show detailed health check results").option("--comprehensive", "Run comprehensive doctor report").option("--fix", "Auto-fix failed checks").action(async (_opts, command) => {
34795
+ const opts = command.optsWithGlobals ? command.optsWithGlobals() : command.opts();
34796
+ const isHuman = opts["human"] === true || !!process.stdout.isTTY && opts["json"] !== true;
34797
+ const progress = createDoctorProgress(isHuman);
34798
+ progress.start();
34799
+ try {
34800
+ if (opts["fix"]) {
34801
+ progress.step(4, "Applying fixes");
34802
+ await dispatchFromCli("mutate", "admin", "fix", {}, { command: "doctor", operation: "admin.fix" });
34803
+ progress.complete("Fixes applied");
34804
+ } else if (opts["comprehensive"]) {
34805
+ progress.step(0, "Checking CLEO directory");
34806
+ await dispatchFromCli("query", "admin", "doctor", {}, { command: "doctor", operation: "admin.doctor" });
34807
+ progress.complete("Comprehensive diagnostics complete");
34808
+ } else {
34809
+ progress.step(0, "Checking CLEO directory");
34810
+ await dispatchFromCli("query", "admin", "health", {
34811
+ detailed: opts["detailed"]
34812
+ }, { command: "doctor", operation: "admin.health" });
34813
+ progress.complete("Health check complete");
34814
+ }
34815
+ } catch (err) {
34816
+ progress.error("Health check failed");
34817
+ throw err;
34678
34818
  }
34679
34819
  });
34680
34820
  }
@@ -36717,8 +36857,8 @@ async function getCurrentVersion() {
36717
36857
  }
36718
36858
  async function getNpmInstalledVersion() {
36719
36859
  try {
36720
- const { stdout } = await execAsync2("npm", ["ls", "-g", "@cleocode/cleo", "--depth=0", "--json"]);
36721
- const data = JSON.parse(stdout);
36860
+ const { stdout: stdout2 } = await execAsync2("npm", ["ls", "-g", "@cleocode/cleo", "--depth=0", "--json"]);
36861
+ const data = JSON.parse(stdout2);
36722
36862
  return data.dependencies?.["@cleocode/cleo"]?.version ?? null;
36723
36863
  } catch {
36724
36864
  return null;
@@ -36726,19 +36866,19 @@ async function getNpmInstalledVersion() {
36726
36866
  }
36727
36867
  async function getDistTagVersion(tag) {
36728
36868
  try {
36729
- const { stdout } = await execAsync2("npm", ["view", `@cleocode/cleo@${tag}`, "version"]);
36730
- const v = stdout.trim();
36869
+ const { stdout: stdout2 } = await execAsync2("npm", ["view", `@cleocode/cleo@${tag}`, "version"]);
36870
+ const v = stdout2.trim();
36731
36871
  return v || null;
36732
36872
  } catch {
36733
36873
  if (tag === "latest") {
36734
36874
  try {
36735
- const { stdout } = await execAsync2("curl", [
36875
+ const { stdout: stdout2 } = await execAsync2("curl", [
36736
36876
  "-sL",
36737
36877
  "--max-time",
36738
36878
  "10",
36739
36879
  `https://api.github.com/repos/${GITHUB_REPO}/releases/latest`
36740
36880
  ]);
36741
- const data = JSON.parse(stdout);
36881
+ const data = JSON.parse(stdout2);
36742
36882
  return data.tag_name?.replace(/^v/, "") ?? null;
36743
36883
  } catch {
36744
36884
  return null;
@@ -36761,17 +36901,26 @@ async function writeRuntimeVersionMetadata(mode, source, version) {
36761
36901
  );
36762
36902
  }
36763
36903
  function registerSelfUpdateCommand(program2) {
36764
- program2.command("self-update").description("Check for and install CLEO updates, then run post-update diagnostics").option("--check", "Only check if update is available").option("--status", "Show current vs latest version").option("--version <ver>", "Update to specific version").option("--channel <channel>", "Update channel: stable|beta").option("--beta", "Shortcut for --channel beta").option("--force", "Force update even if same version").option("--post-update", "Run post-update diagnostics and migration only").option("--no-auto-upgrade", "Skip automatic upgrade after update").option("--auto-migrate", "Automatically migrate storage without prompting").action(async (opts) => {
36904
+ program2.command("self-update").description("Check for and install CLEO updates, then run post-update diagnostics").option("--check", "Only check if update is available").option("--status", "Show current vs latest version").option("--version <ver>", "Update to specific version").option("--channel <channel>", "Update channel: stable|beta").option("--beta", "Shortcut for --channel beta").option("--force", "Force update even if same version").option("--post-update", "Run post-update diagnostics and migration only").option("--no-auto-upgrade", "Skip automatic upgrade after update").option("--auto-migrate", "Automatically migrate storage without prompting").action(async (_opts, command) => {
36905
+ const opts = command.optsWithGlobals ? command.optsWithGlobals() : command.opts();
36906
+ const isHuman = opts["human"] === true || !!process.stdout.isTTY && opts["json"] !== true;
36907
+ const progress = createSelfUpdateProgress(isHuman);
36765
36908
  try {
36766
36909
  const noAutoUpgrade = opts["autoUpgrade"] === false;
36767
36910
  if (opts["postUpdate"]) {
36911
+ progress.start();
36912
+ progress.step(4, "Running post-update diagnostics");
36768
36913
  await runPostUpdateDiagnostics({ skipUpgrade: noAutoUpgrade, autoMigrate: !!opts["autoMigrate"] || !!opts["force"] });
36914
+ progress.complete("Post-update diagnostics complete");
36769
36915
  return;
36770
36916
  }
36917
+ progress.start();
36918
+ progress.step(0, "Detecting installation type");
36771
36919
  const runtime = await getRuntimeDiagnostics();
36772
36920
  const script = runtime.invocation.script;
36773
36921
  const fromNodeModules = script.includes("/node_modules/@cleocode/cleo/") || script.includes("\\node_modules\\@cleocode\\cleo\\");
36774
36922
  const isDev = runtime.channel === "dev" && !fromNodeModules;
36923
+ progress.step(1, "Checking current version");
36775
36924
  const currentVersion = isDev ? await getCurrentVersion() : await getNpmInstalledVersion() ?? await getCurrentVersion();
36776
36925
  const rawChannel = opts["channel"]?.toLowerCase();
36777
36926
  if (rawChannel && rawChannel !== "stable" && rawChannel !== "beta") {
@@ -36779,6 +36928,7 @@ function registerSelfUpdateCommand(program2) {
36779
36928
  }
36780
36929
  const requestedChannel = opts["beta"] ? "beta" : rawChannel ?? (runtime.channel === "beta" ? "beta" : "stable");
36781
36930
  if (isDev && !opts["force"]) {
36931
+ progress.step(4, "Running post-update checks");
36782
36932
  const preflight = checkStorageMigration();
36783
36933
  cliOutput({
36784
36934
  devMode: true,
@@ -36792,6 +36942,7 @@ function registerSelfUpdateCommand(program2) {
36792
36942
  }
36793
36943
  }, { command: "self-update" });
36794
36944
  if (preflight.migrationNeeded) {
36945
+ progress.error(`Storage migration needed: ${preflight.summary}`);
36795
36946
  process.stderr.write(
36796
36947
  `
36797
36948
  \u26A0 Storage migration needed: ${preflight.summary}
@@ -36800,15 +36951,19 @@ function registerSelfUpdateCommand(program2) {
36800
36951
 
36801
36952
  `
36802
36953
  );
36954
+ } else {
36955
+ progress.complete("Dev environment check complete");
36803
36956
  }
36804
36957
  process.exit(100 /* NO_DATA */);
36805
36958
  return;
36806
36959
  }
36807
36960
  if (opts["status"] || opts["check"]) {
36961
+ progress.step(2, "Querying npm registry");
36808
36962
  const latest2 = await getDistTagVersion(requestedChannel === "beta" ? "beta" : "latest");
36809
36963
  if (!latest2) {
36810
36964
  throw new CleoError(5 /* DEPENDENCY_ERROR */, "Failed to check latest version from GitHub");
36811
36965
  }
36966
+ progress.step(3, "Comparing versions");
36812
36967
  const updateAvailable = latest2 !== currentVersion;
36813
36968
  const preflight = checkStorageMigration();
36814
36969
  cliOutput({
@@ -36827,12 +36982,16 @@ function registerSelfUpdateCommand(program2) {
36827
36982
  }
36828
36983
  return;
36829
36984
  }
36985
+ progress.step(2, "Querying npm registry");
36830
36986
  const latest = opts["version"] ?? await getDistTagVersion(requestedChannel === "beta" ? "beta" : "latest");
36831
36987
  if (!latest) {
36832
36988
  throw new CleoError(5 /* DEPENDENCY_ERROR */, "Failed to check latest version from GitHub");
36833
36989
  }
36990
+ progress.step(3, "Comparing versions");
36834
36991
  if (latest === currentVersion && !opts["force"]) {
36992
+ progress.step(4, "Running post-update checks");
36835
36993
  await runPostUpdateDiagnostics({ skipUpgrade: noAutoUpgrade, autoMigrate: !!opts["autoMigrate"] || !!opts["force"] });
36994
+ progress.complete("Already up to date");
36836
36995
  cliOutput({
36837
36996
  currentVersion,
36838
36997
  upToDate: true
@@ -36840,8 +36999,10 @@ function registerSelfUpdateCommand(program2) {
36840
36999
  return;
36841
37000
  }
36842
37001
  const spec = opts["version"] ? `@cleocode/cleo@${latest}` : requestedChannel === "beta" ? "@cleocode/cleo@beta" : "@cleocode/cleo@latest";
37002
+ progress.step(4, `Installing ${spec}`);
36843
37003
  await execAsync2("npm", ["install", "-g", spec], { maxBuffer: 10 * 1024 * 1024 });
36844
37004
  await writeRuntimeVersionMetadata("prod-npm", "npm", latest);
37005
+ progress.step(5, "Finalizing");
36845
37006
  cliOutput({
36846
37007
  currentVersion,
36847
37008
  targetVersion: latest,
@@ -36850,11 +37011,14 @@ function registerSelfUpdateCommand(program2) {
36850
37011
  command: `npm install -g ${spec}`
36851
37012
  }, { command: "self-update", message: `Updated to ${latest}` });
36852
37013
  await runPostUpdateDiagnostics({ skipUpgrade: noAutoUpgrade, autoMigrate: !!opts["autoMigrate"] || !!opts["force"] });
37014
+ progress.complete(`Updated to ${latest}`);
36853
37015
  } catch (err) {
36854
37016
  if (err instanceof CleoError) {
37017
+ progress.error(err.message);
36855
37018
  console.error(formatError(err));
36856
37019
  process.exit(err.code);
36857
37020
  }
37021
+ progress.error("Unexpected error during update");
36858
37022
  throw err;
36859
37023
  }
36860
37024
  });
@@ -37104,16 +37268,29 @@ init_output();
37104
37268
  init_renderers();
37105
37269
  init_errors();
37106
37270
  function registerUpgradeCommand(program2) {
37107
- program2.command("upgrade").description("Unified project maintenance (storage migration, schema repair, structural fixes)").option("--status", "Show what needs updating without making changes").option("--dry-run", "Preview changes without applying").option("--include-global", "Also check global ~/.cleo data").option("--no-auto-migrate", "Skip automatic JSON\u2192SQLite migration").action(async (opts) => {
37271
+ program2.command("upgrade").description("Unified project maintenance (storage migration, schema repair, structural fixes)").option("--status", "Show what needs updating without making changes").option("--dry-run", "Preview changes without applying").option("--include-global", "Also check global ~/.cleo data").option("--no-auto-migrate", "Skip automatic JSON\u2192SQLite migration").action(async (_opts, command) => {
37272
+ const opts = command.optsWithGlobals ? command.optsWithGlobals() : command.opts();
37273
+ const isHuman = opts["human"] === true || !!process.stdout.isTTY && opts["json"] !== true;
37274
+ const progress = createUpgradeProgress(isHuman);
37108
37275
  try {
37109
37276
  const isDryRun = !!opts["dryRun"] || !!opts["status"];
37110
37277
  const includeGlobal = !!opts["includeGlobal"];
37111
37278
  const autoMigrate = opts["autoMigrate"] !== false;
37279
+ progress.start();
37280
+ progress.step(0, "Analyzing current state");
37281
+ if (includeGlobal) {
37282
+ progress.step(1, "Checking global ~/.cleo data");
37283
+ } else {
37284
+ progress.step(1, "Checking storage migration needs");
37285
+ }
37286
+ progress.step(2, "Validating schemas");
37287
+ progress.step(3, isDryRun ? "Previewing changes" : "Applying fixes");
37112
37288
  const result = await runUpgrade({
37113
37289
  dryRun: isDryRun,
37114
37290
  includeGlobal,
37115
37291
  autoMigrate
37116
37292
  });
37293
+ progress.step(4, "Verifying results");
37117
37294
  cliOutput({
37118
37295
  upToDate: result.upToDate,
37119
37296
  dryRun: result.dryRun,
@@ -37123,13 +37300,17 @@ function registerUpgradeCommand(program2) {
37123
37300
  storageMigration: result.storageMigration
37124
37301
  }, { command: "upgrade" });
37125
37302
  if (!result.success) {
37303
+ progress.error("Upgrade failed with errors");
37126
37304
  process.exit(1);
37127
37305
  }
37306
+ progress.complete(isDryRun ? "Preview complete" : "Upgrade complete");
37128
37307
  } catch (err) {
37129
37308
  if (err instanceof CleoError) {
37309
+ progress.error(err.message);
37130
37310
  console.error(formatError(err));
37131
37311
  process.exit(err.code);
37132
37312
  }
37313
+ progress.error("Unexpected error during upgrade");
37133
37314
  throw err;
37134
37315
  }
37135
37316
  });