@cleocode/cleo 2026.4.46 → 2026.4.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/cli/index.js CHANGED
@@ -20589,6 +20589,27 @@ var init_intelligence = __esm({
20589
20589
  }
20590
20590
  });
20591
20591
 
20592
+ // packages/nexus/src/pipeline/suffix-index.ts
20593
+ var EMPTY_SUFFIX_INDEX;
20594
+ var init_suffix_index = __esm({
20595
+ "packages/nexus/src/pipeline/suffix-index.ts"() {
20596
+ "use strict";
20597
+ EMPTY_SUFFIX_INDEX = Object.freeze({
20598
+ get: () => void 0,
20599
+ getInsensitive: () => void 0,
20600
+ getFilesInDir: () => []
20601
+ });
20602
+ }
20603
+ });
20604
+
20605
+ // packages/nexus/src/pipeline/import-processor.ts
20606
+ var init_import_processor = __esm({
20607
+ "packages/nexus/src/pipeline/import-processor.ts"() {
20608
+ "use strict";
20609
+ init_suffix_index();
20610
+ }
20611
+ });
20612
+
20592
20613
  // packages/nexus/src/pipeline/symbol-table.ts
20593
20614
  var init_symbol_table = __esm({
20594
20615
  "packages/nexus/src/pipeline/symbol-table.ts"() {
@@ -20608,6 +20629,7 @@ var init_resolution_context = __esm({
20608
20629
  var init_call_processor = __esm({
20609
20630
  "packages/nexus/src/pipeline/call-processor.ts"() {
20610
20631
  "use strict";
20632
+ init_import_processor();
20611
20633
  init_resolution_context();
20612
20634
  }
20613
20635
  });
@@ -20663,27 +20685,6 @@ var init_heritage_processor = __esm({
20663
20685
  }
20664
20686
  });
20665
20687
 
20666
- // packages/nexus/src/pipeline/suffix-index.ts
20667
- var EMPTY_SUFFIX_INDEX;
20668
- var init_suffix_index = __esm({
20669
- "packages/nexus/src/pipeline/suffix-index.ts"() {
20670
- "use strict";
20671
- EMPTY_SUFFIX_INDEX = Object.freeze({
20672
- get: () => void 0,
20673
- getInsensitive: () => void 0,
20674
- getFilesInDir: () => []
20675
- });
20676
- }
20677
- });
20678
-
20679
- // packages/nexus/src/pipeline/import-processor.ts
20680
- var init_import_processor = __esm({
20681
- "packages/nexus/src/pipeline/import-processor.ts"() {
20682
- "use strict";
20683
- init_suffix_index();
20684
- }
20685
- });
20686
-
20687
20688
  // packages/nexus/src/pipeline/knowledge-graph.ts
20688
20689
  var init_knowledge_graph = __esm({
20689
20690
  "packages/nexus/src/pipeline/knowledge-graph.ts"() {
@@ -46433,13 +46434,16 @@ async function runTierPromotion(projectRoot) {
46433
46434
  try {
46434
46435
  shortToMedium = typedAll(
46435
46436
  nativeDb.prepare(`
46436
- SELECT id, citation_count, quality_score
46437
+ SELECT id, citation_count, quality_score, verified
46437
46438
  FROM ${table}
46438
46439
  WHERE memory_tier = 'short'
46439
46440
  AND invalid_at IS NULL
46440
46441
  AND ${dateCol} < ?
46441
- AND verified = 1
46442
- AND (citation_count >= 3 OR quality_score >= 0.7)
46442
+ AND (
46443
+ citation_count >= 3
46444
+ OR quality_score >= 0.7
46445
+ OR verified = 1
46446
+ )
46443
46447
  `),
46444
46448
  age24h
46445
46449
  );
@@ -46449,13 +46453,15 @@ async function runTierPromotion(projectRoot) {
46449
46453
  for (const row of shortToMedium) {
46450
46454
  try {
46451
46455
  nativeDb.prepare(`UPDATE ${table} SET memory_tier = 'medium', updated_at = ? WHERE id = ?`).run(now2, row.id);
46452
- promoted.push({
46453
- id: row.id,
46454
- table,
46455
- fromTier: "short",
46456
- toTier: "medium",
46457
- reason: row.citation_count >= 3 ? `citationCount=${row.citation_count} >= 3, verified, age > 24h` : `qualityScore=${row.quality_score?.toFixed(2)} >= 0.70, verified, age > 24h`
46458
- });
46456
+ let reason;
46457
+ if (row.citation_count >= 3) {
46458
+ reason = `citationCount=${row.citation_count} >= 3, age > 24h`;
46459
+ } else if ((row.quality_score ?? 0) >= 0.7) {
46460
+ reason = `qualityScore=${row.quality_score?.toFixed(2)} >= 0.70, age > 24h`;
46461
+ } else {
46462
+ reason = `verified=true, age > 24h`;
46463
+ }
46464
+ promoted.push({ id: row.id, table, fromTier: "short", toTier: "medium", reason });
46459
46465
  } catch {
46460
46466
  }
46461
46467
  }
@@ -46463,13 +46469,12 @@ async function runTierPromotion(projectRoot) {
46463
46469
  try {
46464
46470
  mediumToLong = typedAll(
46465
46471
  nativeDb.prepare(`
46466
- SELECT id, citation_count, quality_score
46472
+ SELECT id, citation_count, quality_score, verified
46467
46473
  FROM ${table}
46468
46474
  WHERE memory_tier = 'medium'
46469
46475
  AND invalid_at IS NULL
46470
46476
  AND ${dateCol} < ?
46471
- AND verified = 1
46472
- AND citation_count >= 5
46477
+ AND (citation_count >= 5 OR verified = 1)
46473
46478
  `),
46474
46479
  age7d
46475
46480
  );
@@ -46479,13 +46484,8 @@ async function runTierPromotion(projectRoot) {
46479
46484
  for (const row of mediumToLong) {
46480
46485
  try {
46481
46486
  nativeDb.prepare(`UPDATE ${table} SET memory_tier = 'long', updated_at = ? WHERE id = ?`).run(now2, row.id);
46482
- promoted.push({
46483
- id: row.id,
46484
- table,
46485
- fromTier: "medium",
46486
- toTier: "long",
46487
- reason: `citationCount=${row.citation_count} >= 5, verified, age > 7d`
46488
- });
46487
+ const reason = row.citation_count >= 5 ? `citationCount=${row.citation_count} >= 5, age > 7d` : `verified=true, age > 7d`;
46488
+ promoted.push({ id: row.id, table, fromTier: "medium", toTier: "long", reason });
46489
46489
  } catch {
46490
46490
  }
46491
46491
  }
@@ -87266,6 +87266,7 @@ var init_cleo = __esm({
87266
87266
  // packages/core/src/index.ts
87267
87267
  var init_src3 = __esm({
87268
87268
  "packages/core/src/index.ts"() {
87269
+ "use strict";
87269
87270
  init_src();
87270
87271
  init_adapters();
87271
87272
  init_admin();
@@ -90093,6 +90094,7 @@ async function runBrainMaintenance(projectRoot, options) {
90093
90094
  skipDecay = false,
90094
90095
  skipConsolidation = false,
90095
90096
  skipReconciliation = false,
90097
+ skipTierPromotion = false,
90096
90098
  skipEmbeddings = false,
90097
90099
  onProgress
90098
90100
  } = options ?? {};
@@ -90104,6 +90106,7 @@ async function runBrainMaintenance(projectRoot, options) {
90104
90106
  observationsFixed: 0,
90105
90107
  linksRemoved: 0
90106
90108
  };
90109
+ const tierPromotionResult = { promoted: 0, evicted: 0 };
90107
90110
  const embeddingsResult = {
90108
90111
  processed: 0,
90109
90112
  skipped: 0,
@@ -90130,6 +90133,13 @@ async function runBrainMaintenance(projectRoot, options) {
90130
90133
  reconciliationResult.linksRemoved = raw.linksRemoved;
90131
90134
  onProgress?.("reconciliation", 1, 1);
90132
90135
  }
90136
+ if (!skipTierPromotion) {
90137
+ onProgress?.("tier-promotion", 0, 1);
90138
+ const raw = await runTierPromotion(projectRoot);
90139
+ tierPromotionResult.promoted = raw.promoted.length;
90140
+ tierPromotionResult.evicted = raw.evicted.length;
90141
+ onProgress?.("tier-promotion", 1, 1);
90142
+ }
90133
90143
  if (!skipEmbeddings) {
90134
90144
  const raw = await populateEmbeddings(projectRoot, {
90135
90145
  onProgress: (current, total) => {
@@ -90144,6 +90154,7 @@ async function runBrainMaintenance(projectRoot, options) {
90144
90154
  decay: decayResult,
90145
90155
  consolidation: consolidationResult,
90146
90156
  reconciliation: reconciliationResult,
90157
+ tierPromotion: tierPromotionResult,
90147
90158
  embeddings: embeddingsResult,
90148
90159
  duration: Date.now() - startTime
90149
90160
  };
@@ -112997,9 +113008,11 @@ __export(internal_exports, {
112997
113008
  routing: () => routing_exports,
112998
113009
  runAllMigrations: () => runAllMigrations,
112999
113010
  runBrainMaintenance: () => runBrainMaintenance,
113011
+ runConsolidation: () => runConsolidation,
113000
113012
  runDoctorFixes: () => runDoctorFixes,
113001
113013
  runMigration: () => runMigration,
113002
113014
  runReleaseGates: () => runReleaseGates,
113015
+ runTierPromotion: () => runTierPromotion,
113003
113016
  runUpgrade: () => runUpgrade,
113004
113017
  safestop: () => safestop,
113005
113018
  sanitizeContent: () => sanitizeContent,
@@ -134883,6 +134896,9 @@ function registerBrainCommand(program) {
134883
134896
  "--skip-decay",
134884
134897
  "Skip the temporal decay step (confidence reduction on stale learnings)"
134885
134898
  ).option("--skip-consolidation", "Skip the memory consolidation step (merging old observations)").option("--skip-reconciliation", "Skip the cross-DB orphaned reference reconciliation step").option(
134899
+ "--skip-tier-promotion",
134900
+ "Skip the tier promotion step (short\u2192medium, medium\u2192long promotion)"
134901
+ ).option(
134886
134902
  "--skip-embeddings",
134887
134903
  "Skip the embedding backfill step (vector generation for observations)"
134888
134904
  ).option("--json", "Output results as JSON").action(
@@ -134897,6 +134913,7 @@ function registerBrainCommand(program) {
134897
134913
  skipDecay: !!opts.skipDecay,
134898
134914
  skipConsolidation: !!opts.skipConsolidation,
134899
134915
  skipReconciliation: !!opts.skipReconciliation,
134916
+ skipTierPromotion: !!opts.skipTierPromotion,
134900
134917
  skipEmbeddings: !!opts.skipEmbeddings,
134901
134918
  onProgress: isJson ? void 0 : (step, current, total) => {
134902
134919
  if (step === "embeddings" && total > 0) {
@@ -134931,6 +134948,11 @@ function registerBrainCommand(program) {
134931
134948
  ` Consolidation: ${result.consolidation.merged} merged, ${result.consolidation.removed} archived`
134932
134949
  );
134933
134950
  }
134951
+ if (!opts.skipTierPromotion) {
134952
+ console.log(
134953
+ ` Tier promotion: ${result.tierPromotion.promoted} promoted, ${result.tierPromotion.evicted} evicted`
134954
+ );
134955
+ }
134934
134956
  if (!opts.skipReconciliation) {
134935
134957
  console.log(
134936
134958
  ` Reconcile: ${result.reconciliation.decisionsFixed} decisions, ${result.reconciliation.observationsFixed} observations, ${result.reconciliation.linksRemoved} links`
@@ -137854,6 +137876,7 @@ function registerMapCommand(program) {
137854
137876
  }
137855
137877
 
137856
137878
  // packages/cleo/src/cli/commands/memory-brain.ts
137879
+ init_internal();
137857
137880
  init_cli();
137858
137881
  init_renderers();
137859
137882
  function registerMemoryBrainCommand(program) {
@@ -138216,6 +138239,61 @@ function registerMemoryBrainCommand(program) {
138216
138239
  { command: "memory", operation: "memory.code.for-memory" }
138217
138240
  );
138218
138241
  });
138242
+ memory.command("consolidate").description(
138243
+ "Run the full brain consolidation pipeline: dedup, quality recompute, tier promotion, contradiction detection, soft eviction, graph strengthening, summary generation. Equivalent to the session-end sleep-time consolidation but triggered on demand."
138244
+ ).option("--json", "Output results as JSON").action(async (opts) => {
138245
+ const root = getProjectRoot();
138246
+ const isJson = !!opts.json;
138247
+ if (!isJson) {
138248
+ console.log("Running memory consolidation (including tier promotion)...");
138249
+ }
138250
+ try {
138251
+ const result = await runConsolidation(root);
138252
+ if (isJson) {
138253
+ console.log(
138254
+ JSON.stringify(
138255
+ {
138256
+ success: true,
138257
+ data: result,
138258
+ meta: {
138259
+ operation: "memory.consolidate",
138260
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
138261
+ }
138262
+ },
138263
+ null,
138264
+ 2
138265
+ )
138266
+ );
138267
+ return;
138268
+ }
138269
+ console.log("\nConsolidation complete.");
138270
+ console.log(` Deduplicated: ${result.deduplicated}`);
138271
+ console.log(` Quality recomp: ${result.qualityRecomputed}`);
138272
+ console.log(` Tier promoted: ${result.tierPromotions.promoted.length} entries promoted`);
138273
+ console.log(` Tier evicted: ${result.tierPromotions.evicted.length} entries evicted`);
138274
+ console.log(` Contradictions: ${result.contradictions}`);
138275
+ console.log(` Soft evicted: ${result.softEvicted}`);
138276
+ console.log(` Edges strength: ${result.edgesStrengthened}`);
138277
+ console.log(` Summaries gen: ${result.summariesGenerated}`);
138278
+ if (result.graphLinksCreated !== void 0) {
138279
+ console.log(` Graph links: ${result.graphLinksCreated}`);
138280
+ }
138281
+ if (result.tierPromotions.promoted.length > 0) {
138282
+ console.log("\nTier promotions:");
138283
+ for (const p2 of result.tierPromotions.promoted) {
138284
+ console.log(` [${p2.table}] ${p2.id}: ${p2.fromTier} \u2192 ${p2.toTier} (${p2.reason})`);
138285
+ }
138286
+ }
138287
+ } catch (err) {
138288
+ const message = err instanceof Error ? err.message : String(err);
138289
+ if (isJson) {
138290
+ console.log(JSON.stringify({ success: false, error: message }));
138291
+ } else {
138292
+ console.error(`Memory consolidation failed: ${message}`);
138293
+ }
138294
+ process.exit(1);
138295
+ }
138296
+ });
138219
138297
  }
138220
138298
 
138221
138299
  // packages/cleo/src/cli/commands/migrate-claude-mem.ts
@@ -142543,7 +142621,7 @@ function registerWebCommand(program) {
142543
142621
  );
142544
142622
  }
142545
142623
  const projectRoot = process.env["CLEO_ROOT"] ?? process.cwd();
142546
- const distServerDir = join131(projectRoot, "dist", "cli");
142624
+ const studioDir = process.env["CLEO_STUDIO_DIR"] ?? join131(projectRoot, "packages", "studio", "build");
142547
142625
  await mkdir19(join131(getCleoHome(), "logs"), { recursive: true });
142548
142626
  await writeFile14(
142549
142627
  configFile,
@@ -142553,22 +142631,31 @@ function registerWebCommand(program) {
142553
142631
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
142554
142632
  })
142555
142633
  );
142556
- const webIndexPath = join131(distServerDir, "index.js");
142634
+ const webIndexPath = join131(studioDir, "index.js");
142557
142635
  try {
142558
142636
  await stat3(webIndexPath);
142559
142637
  } catch {
142560
142638
  try {
142561
- execFileSync18("npm", ["run", "build"], { cwd: projectRoot, stdio: "ignore" });
142639
+ execFileSync18("pnpm", ["--filter", "@cleocode/studio", "run", "build"], {
142640
+ cwd: projectRoot,
142641
+ stdio: "ignore"
142642
+ });
142562
142643
  } catch {
142563
- throw new CleoError(1 /* GENERAL_ERROR */, `Build failed. Check logs: ${logFile}`);
142644
+ throw new CleoError(
142645
+ 1 /* GENERAL_ERROR */,
142646
+ `Studio build failed. Run: pnpm --filter @cleocode/studio run build
142647
+ Logs: ${logFile}`
142648
+ );
142564
142649
  }
142565
142650
  }
142566
142651
  const serverProcess = spawn2("node", [webIndexPath], {
142567
- cwd: projectRoot,
142652
+ cwd: studioDir,
142568
142653
  env: {
142569
142654
  ...process.env,
142570
- CLEO_WEB_PORT: String(port),
142571
- CLEO_WEB_HOST: host
142655
+ HOST: host,
142656
+ PORT: String(port),
142657
+ // Pass CLEO paths through to the studio server
142658
+ CLEO_ROOT: projectRoot
142572
142659
  },
142573
142660
  detached: true,
142574
142661
  stdio: "ignore"