@cleocode/cleo 2026.3.46 → 2026.3.48

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/mcp/index.js CHANGED
@@ -34691,7 +34691,7 @@ function checkInjection2(projectRoot) {
34691
34691
  status: "warning",
34692
34692
  message: "AGENTS.md not found in project root",
34693
34693
  details: { path: agentsMdPath, exists: false },
34694
- fix: "cleo init --update-docs"
34694
+ fix: "cleo upgrade"
34695
34695
  };
34696
34696
  }
34697
34697
  let content;
@@ -34716,7 +34716,7 @@ function checkInjection2(projectRoot) {
34716
34716
  status: "warning",
34717
34717
  message: "AGENTS.md exists but has no CAAMP markers",
34718
34718
  details: { path: agentsMdPath, hasCaampMarker: false },
34719
- fix: "cleo init --update-docs"
34719
+ fix: "cleo upgrade"
34720
34720
  };
34721
34721
  }
34722
34722
  if (startCount !== endCount) {
@@ -34726,7 +34726,7 @@ function checkInjection2(projectRoot) {
34726
34726
  status: "warning",
34727
34727
  message: `CAAMP markers unbalanced: ${startCount} START vs ${endCount} END`,
34728
34728
  details: { path: agentsMdPath, startCount, endCount },
34729
- fix: "cleo init --update-docs"
34729
+ fix: "cleo upgrade"
34730
34730
  };
34731
34731
  }
34732
34732
  const caampMatch = content.match(/<!-- CAAMP:START -->([\s\S]*?)<!-- CAAMP:END -->/);
@@ -34748,7 +34748,7 @@ function checkInjection2(projectRoot) {
34748
34748
  status: "warning",
34749
34749
  message: `Missing @ reference targets: ${missing.join(", ")}`,
34750
34750
  details: { path: agentsMdPath, missing, totalRefs: refs.length },
34751
- fix: "cleo init --update-docs"
34751
+ fix: "cleo upgrade"
34752
34752
  };
34753
34753
  }
34754
34754
  }
@@ -34765,7 +34765,7 @@ function checkInjection2(projectRoot) {
34765
34765
  status: "warning",
34766
34766
  message: `CLAUDE.md CAAMP markers unbalanced: ${cStartCount} START vs ${cEndCount} END`,
34767
34767
  details: { file: "CLAUDE.md", startCount: cStartCount, endCount: cEndCount },
34768
- fix: "cleo init --update-docs"
34768
+ fix: "cleo upgrade"
34769
34769
  };
34770
34770
  }
34771
34771
  if (cStartCount === 0) {
@@ -34775,7 +34775,7 @@ function checkInjection2(projectRoot) {
34775
34775
  status: "warning",
34776
34776
  message: "CLAUDE.md has no CAAMP markers",
34777
34777
  details: { file: "CLAUDE.md", hasCaampMarker: false },
34778
- fix: "cleo init --update-docs"
34778
+ fix: "cleo upgrade"
34779
34779
  };
34780
34780
  }
34781
34781
  } catch {
@@ -34804,6 +34804,7 @@ __export(scaffold_exports, {
34804
34804
  CLEO_GITIGNORE_FALLBACK: () => CLEO_GITIGNORE_FALLBACK,
34805
34805
  REQUIRED_CLEO_SUBDIRS: () => REQUIRED_CLEO_SUBDIRS,
34806
34806
  REQUIRED_GLOBAL_SUBDIRS: () => REQUIRED_GLOBAL_SUBDIRS,
34807
+ STALE_GLOBAL_ENTRIES: () => STALE_GLOBAL_ENTRIES,
34807
34808
  checkBrainDb: () => checkBrainDb,
34808
34809
  checkCleoGitRepo: () => checkCleoGitRepo,
34809
34810
  checkCleoStructure: () => checkCleoStructure,
@@ -34840,7 +34841,7 @@ __export(scaffold_exports, {
34840
34841
  import { execFile as execFile3 } from "node:child_process";
34841
34842
  import { randomUUID } from "node:crypto";
34842
34843
  import { existsSync as existsSync34, constants as fsConstants3, readFileSync as readFileSync22, statSync as statSync8 } from "node:fs";
34843
- import { access as access3, mkdir as mkdir5, readFile as readFile6, writeFile as writeFile5 } from "node:fs/promises";
34844
+ import { access as access3, mkdir as mkdir5, readFile as readFile6, rm as rm2, writeFile as writeFile5 } from "node:fs/promises";
34844
34845
  import { dirname as dirname8, join as join37, resolve as resolve5 } from "node:path";
34845
34846
  import { fileURLToPath as fileURLToPath4 } from "node:url";
34846
34847
  import { promisify as promisify3 } from "node:util";
@@ -34855,7 +34856,7 @@ async function fileExists(path2) {
34855
34856
  async function stripCLEOBlocks(filePath) {
34856
34857
  if (!existsSync34(filePath)) return;
34857
34858
  const content = await readFile6(filePath, "utf8");
34858
- const stripped = content.replace(/\n?<!-- CLEO:START -->[\s\S]*?<!-- CLEO:END -->\n?/g, "");
34859
+ const stripped = content.replace(/\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g, "");
34859
34860
  if (stripped !== content) await writeFile5(filePath, stripped, "utf8");
34860
34861
  }
34861
34862
  async function removeCleoFromRootGitignore(projectRoot) {
@@ -35538,6 +35539,19 @@ async function ensureGlobalHome() {
35538
35539
  for (const subdir of REQUIRED_GLOBAL_SUBDIRS) {
35539
35540
  await mkdir5(join37(cleoHome, subdir), { recursive: true });
35540
35541
  }
35542
+ for (const stale of STALE_GLOBAL_ENTRIES) {
35543
+ const stalePath = join37(cleoHome, stale);
35544
+ if (existsSync34(stalePath)) {
35545
+ try {
35546
+ await rm2(stalePath, { recursive: true, force: true });
35547
+ console.warn(`[CLEO] Removed stale global entry: ${stalePath}`);
35548
+ } catch (err) {
35549
+ console.warn(
35550
+ `[CLEO] Could not remove stale global entry ${stalePath}: ${err instanceof Error ? err.message : String(err)}`
35551
+ );
35552
+ }
35553
+ }
35554
+ }
35541
35555
  return {
35542
35556
  action: alreadyExists ? "skipped" : "created",
35543
35557
  path: cleoHome,
@@ -35652,7 +35666,7 @@ function checkLogDir(projectRoot) {
35652
35666
  fix: null
35653
35667
  };
35654
35668
  }
35655
- var execFileAsync3, REQUIRED_CLEO_SUBDIRS, CLEO_GITIGNORE_FALLBACK, REQUIRED_GLOBAL_SUBDIRS;
35669
+ var execFileAsync3, REQUIRED_CLEO_SUBDIRS, CLEO_GITIGNORE_FALLBACK, REQUIRED_GLOBAL_SUBDIRS, STALE_GLOBAL_ENTRIES;
35656
35670
  var init_scaffold = __esm({
35657
35671
  "packages/core/src/scaffold.ts"() {
35658
35672
  "use strict";
@@ -35710,6 +35724,20 @@ metrics/
35710
35724
  backups/
35711
35725
  `;
35712
35726
  REQUIRED_GLOBAL_SUBDIRS = ["logs", "templates"];
35727
+ STALE_GLOBAL_ENTRIES = [
35728
+ "adrs",
35729
+ "rcasd",
35730
+ "agent-outputs",
35731
+ "backups",
35732
+ "sandbox",
35733
+ "tasks.db",
35734
+ "tasks.db-shm",
35735
+ "tasks.db-wal",
35736
+ "brain-worker.pid",
35737
+ "VERSION",
35738
+ "schemas",
35739
+ "bin"
35740
+ ];
35713
35741
  }
35714
35742
  });
35715
35743
 
@@ -39445,8 +39473,8 @@ function parseTokenMetrics(inputFile, cwd) {
39445
39473
  const raw = JSON.parse(readFileSync28(file2, "utf-8"));
39446
39474
  if (raw.resourceMetrics) {
39447
39475
  const points = [];
39448
- for (const rm2 of raw.resourceMetrics ?? []) {
39449
- for (const sm of rm2.scopeMetrics ?? []) {
39476
+ for (const rm3 of raw.resourceMetrics ?? []) {
39477
+ for (const sm of rm3.scopeMetrics ?? []) {
39450
39478
  for (const metric of sm.metrics ?? []) {
39451
39479
  if (metric.name !== "claude_code.token.usage") continue;
39452
39480
  for (const dp of metric.sum?.dataPoints ?? []) {
@@ -57649,7 +57677,7 @@ function checkAgentsMdHub(projectRoot) {
57649
57677
  status: "warning",
57650
57678
  message: "AGENTS.md not found in project root",
57651
57679
  details: { path: agentsMdPath, exists: false },
57652
- fix: "cleo init --update-docs"
57680
+ fix: "cleo upgrade"
57653
57681
  };
57654
57682
  }
57655
57683
  let content;
@@ -57672,7 +57700,7 @@ function checkAgentsMdHub(projectRoot) {
57672
57700
  status: "warning",
57673
57701
  message: "AGENTS.md exists but has no CAAMP:START marker",
57674
57702
  details: { path: agentsMdPath, hasCaampMarker: false },
57675
- fix: "cleo init --update-docs"
57703
+ fix: "cleo upgrade"
57676
57704
  };
57677
57705
  }
57678
57706
  return {
@@ -58011,7 +58039,7 @@ function checkCaampMarkerIntegrity(projectRoot) {
58011
58039
  status: "warning",
58012
58040
  message: `CAAMP marker issues: ${issues.join("; ")}`,
58013
58041
  details: { issues },
58014
- fix: "cleo init --update-docs"
58042
+ fix: "cleo upgrade"
58015
58043
  };
58016
58044
  }
58017
58045
  return {
@@ -58077,7 +58105,7 @@ function checkAtReferenceTargetExists(projectRoot) {
58077
58105
  status: "warning",
58078
58106
  message: `Missing @ reference targets: ${missing.join(", ")}`,
58079
58107
  details: { missing, totalRefs: refs.length },
58080
- fix: "cleo init --update-docs"
58108
+ fix: "cleo upgrade"
58081
58109
  };
58082
58110
  }
58083
58111
  return {
@@ -64483,9 +64511,6 @@ async function updateDocs() {
64483
64511
  };
64484
64512
  }
64485
64513
  async function initProject(opts = {}) {
64486
- if (opts.updateDocs) {
64487
- return updateDocs();
64488
- }
64489
64514
  const cleoDir = getCleoDirAbsolute();
64490
64515
  const projRoot = getProjectRoot();
64491
64516
  const alreadyInitialized = existsSync100(cleoDir) && (existsSync100(join100(cleoDir, "tasks.db")) || existsSync100(join100(cleoDir, "config.json")));
@@ -64852,7 +64877,13 @@ var init_output = __esm({
64852
64877
  });
64853
64878
 
64854
64879
  // packages/core/src/project-info.ts
64855
- import { existsSync as existsSync102, readFileSync as readFileSync75 } from "node:fs";
64880
+ var project_info_exports = {};
64881
+ __export(project_info_exports, {
64882
+ getProjectInfo: () => getProjectInfo,
64883
+ getProjectInfoSync: () => getProjectInfoSync,
64884
+ updateProjectName: () => updateProjectName
64885
+ });
64886
+ import { existsSync as existsSync102, readFileSync as readFileSync75, writeFileSync as writeFileSync19 } from "node:fs";
64856
64887
  import { readFile as readFile18 } from "node:fs/promises";
64857
64888
  import { join as join102 } from "node:path";
64858
64889
  async function getProjectInfo(cwd) {
@@ -64896,6 +64927,16 @@ function getProjectInfoSync(cwd) {
64896
64927
  return null;
64897
64928
  }
64898
64929
  }
64930
+ function updateProjectName(cwd, name2) {
64931
+ const cleoDir = getCleoDirAbsolute(cwd);
64932
+ const infoPath = join102(cleoDir, "project-info.json");
64933
+ if (!existsSync102(infoPath)) return;
64934
+ const data = JSON.parse(readFileSync75(infoPath, "utf-8"));
64935
+ data.projectName = name2;
64936
+ data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
64937
+ writeFileSync19(infoPath, `${JSON.stringify(data, null, 2)}
64938
+ `);
64939
+ }
64899
64940
  var init_project_info = __esm({
64900
64941
  "packages/core/src/project-info.ts"() {
64901
64942
  "use strict";
@@ -65171,7 +65212,6 @@ var init_cleo = __esm({
65171
65212
  // packages/core/src/index.ts
65172
65213
  var init_src2 = __esm({
65173
65214
  "packages/core/src/index.ts"() {
65174
- "use strict";
65175
65215
  init_src();
65176
65216
  init_adapters();
65177
65217
  init_admin();
@@ -65273,6 +65313,7 @@ async function bootstrapGlobalCleo(options) {
65273
65313
  await injectAgentsHub(ctx);
65274
65314
  await installMcpToProviders(ctx);
65275
65315
  await installSkillsGlobally(ctx);
65316
+ await installAgentDefinitionGlobally(ctx);
65276
65317
  await installProviderAdapters(ctx, options?.packageRoot);
65277
65318
  return ctx;
65278
65319
  }
@@ -65323,7 +65364,10 @@ async function injectAgentsHub(ctx) {
65323
65364
  await mkdir17(globalAgentsDir, { recursive: true });
65324
65365
  if (existsSync103(globalAgentsMd)) {
65325
65366
  const content = await readFile19(globalAgentsMd, "utf8");
65326
- const stripped = content.replace(/\n?<!-- CLEO:START -->[\s\S]*?<!-- CLEO:END -->\n?/g, "");
65367
+ const stripped = content.replace(
65368
+ /\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
65369
+ ""
65370
+ );
65327
65371
  if (stripped !== content) {
65328
65372
  await writeFile12(globalAgentsMd, stripped, "utf8");
65329
65373
  }
@@ -65347,7 +65391,7 @@ async function injectAgentsHub(ctx) {
65347
65391
  if (existsSync103(instructFilePath)) {
65348
65392
  const fileContent = await readFile19(instructFilePath, "utf8");
65349
65393
  const stripped = fileContent.replace(
65350
- /\n?<!-- CLEO:START -->[\s\S]*?<!-- CLEO:END -->\n?/g,
65394
+ /\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
65351
65395
  ""
65352
65396
  );
65353
65397
  if (stripped !== fileContent) {
@@ -65416,6 +65460,20 @@ async function installSkillsGlobally(ctx) {
65416
65460
  );
65417
65461
  }
65418
65462
  }
65463
+ async function installAgentDefinitionGlobally(ctx) {
65464
+ try {
65465
+ if (!ctx.isDryRun) {
65466
+ const { initAgentDefinition: initAgentDefinition2 } = await Promise.resolve().then(() => (init_init(), init_exports));
65467
+ await initAgentDefinition2(ctx.created, ctx.warnings);
65468
+ } else {
65469
+ ctx.created.push("agent: cleo-subagent (would symlink)");
65470
+ }
65471
+ } catch (err) {
65472
+ ctx.warnings.push(
65473
+ `Agent definition install: ${err instanceof Error ? err.message : String(err)}`
65474
+ );
65475
+ }
65476
+ }
65419
65477
  async function installProviderAdapters(ctx, packageRootOverride) {
65420
65478
  try {
65421
65479
  const { AdapterManager: AdapterManager2 } = await Promise.resolve().then(() => (init_adapters(), adapters_exports));
@@ -72085,7 +72143,7 @@ import {
72085
72143
  mkdirSync as mkdirSync23,
72086
72144
  readdirSync as readdirSync36,
72087
72145
  readFileSync as readFileSync82,
72088
- writeFileSync as writeFileSync19
72146
+ writeFileSync as writeFileSync20
72089
72147
  } from "node:fs";
72090
72148
  import { join as join108 } from "node:path";
72091
72149
  async function runUpgrade(options = {}) {
@@ -72231,7 +72289,7 @@ async function runUpgrade(options = {}) {
72231
72289
  if (totalImported === 0 && existsSync110(dbBackupPath)) {
72232
72290
  copyFileSync7(dbBackupPath, dbPath2);
72233
72291
  if (configBackup) {
72234
- writeFileSync19(configPath, configBackup);
72292
+ writeFileSync20(configPath, configBackup);
72235
72293
  }
72236
72294
  actions.push({
72237
72295
  action: "storage_migration",
@@ -72252,7 +72310,7 @@ async function runUpgrade(options = {}) {
72252
72310
  config2.storage = {};
72253
72311
  }
72254
72312
  config2.storage.engine = "sqlite";
72255
- writeFileSync19(configPath, JSON.stringify(config2, null, 2));
72313
+ writeFileSync20(configPath, JSON.stringify(config2, null, 2));
72256
72314
  actions.push({
72257
72315
  action: "storage_migration",
72258
72316
  status: "applied",
@@ -72274,7 +72332,7 @@ async function runUpgrade(options = {}) {
72274
72332
  copyFileSync7(dbBackupPath, dbPath2);
72275
72333
  }
72276
72334
  if (configBackup) {
72277
- writeFileSync19(configPath, configBackup);
72335
+ writeFileSync20(configPath, configBackup);
72278
72336
  }
72279
72337
  await updateMigrationPhase2(cleoDir2, "failed");
72280
72338
  for (const error40 of result.errors) {
@@ -72527,7 +72585,9 @@ async function runUpgrade(options = {}) {
72527
72585
  }
72528
72586
  }
72529
72587
  } else {
72530
- const contextResult = await ensureProjectContext(projectRootForContext, { staleDays: 30 });
72588
+ const contextResult = await ensureProjectContext(projectRootForContext, {
72589
+ staleDays: options.forceDetect ? 0 : 30
72590
+ });
72531
72591
  actions.push({
72532
72592
  action: "project_context_detection",
72533
72593
  status: contextResult.action === "skipped" ? "skipped" : "applied",
@@ -72725,6 +72785,35 @@ async function runUpgrade(options = {}) {
72725
72785
  }
72726
72786
  } catch {
72727
72787
  }
72788
+ if (options.mapCodebase) {
72789
+ try {
72790
+ const { mapCodebase: mapCodebase3 } = await Promise.resolve().then(() => (init_codebase_map(), codebase_map_exports));
72791
+ const mapResult = await mapCodebase3(projectRootForMaint, { storeToBrain: true });
72792
+ actions.push({
72793
+ action: "codebase_map",
72794
+ status: "applied",
72795
+ details: `Analyzed: ${mapResult.stack?.languages?.length ?? 0} languages, ${mapResult.concerns?.todos?.length ?? 0} TODOs found`
72796
+ });
72797
+ } catch (err) {
72798
+ actions.push({
72799
+ action: "codebase_map",
72800
+ status: "error",
72801
+ details: `Codebase mapping failed: ${err instanceof Error ? err.message : String(err)}`
72802
+ });
72803
+ }
72804
+ }
72805
+ if (options.projectName) {
72806
+ try {
72807
+ const { updateProjectName: updateProjectName2 } = await Promise.resolve().then(() => (init_project_info(), project_info_exports));
72808
+ await updateProjectName2(projectRootForMaint, options.projectName);
72809
+ actions.push({
72810
+ action: "project_name_update",
72811
+ status: "applied",
72812
+ details: `Project name set to "${options.projectName}"`
72813
+ });
72814
+ } catch {
72815
+ }
72816
+ }
72728
72817
  try {
72729
72818
  const { existsSync: fsExistsSync } = await import("node:fs");
72730
72819
  const { join: pathJoin } = await import("node:path");