@cleocode/cleo 2026.5.50 → 2026.5.53

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
@@ -30320,7 +30320,7 @@ function capitalizeFirst(str3) {
30320
30320
  if (str3.length === 0) return str3;
30321
30321
  return str3.charAt(0).toUpperCase() + str3.slice(1);
30322
30322
  }
30323
- var registerCommand, signinCommand, startCommand, stopCommand, statusCommand, assignCommand, wakeCommand, spawnCommand, reassignCommand, stopAllCommand, workCommand, listCommand3, getCommand, attachCommand, detachCommand, removeCommand, rotateKeyCommand, claimCodeCommand, watchCommand, pollCommand, sendCommand, healthCommand3, installCommand, packCommand, createCommand, mintCommand, doctorCommand, agentCommand;
30323
+ var registerCommand, signinCommand, startCommand, stopCommand, statusCommand, assignCommand, wakeCommand, spawnCommand, reassignCommand, stopAllCommand, workCommand, listCommand3, getCommand, attachCommand, detachCommand, removeCommand, rotateKeyCommand, claimCodeCommand, watchCommand, pollCommand, sendCommand, healthCommand3, installCommand, packCommand, createCommand, mintCommand, pruneOrphansCommand, doctorCommand, agentCommand;
30324
30324
  var init_agent = __esm({
30325
30325
  "packages/cleo/src/cli/commands/agent.ts"() {
30326
30326
  "use strict";
@@ -32646,6 +32646,67 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32646
32646
  }
32647
32647
  }
32648
32648
  });
32649
+ pruneOrphansCommand = defineCommand({
32650
+ meta: {
32651
+ name: "prune-orphans",
32652
+ description: "Delete orphan registry rows whose .cant path no longer exists (cross-project safe)"
32653
+ },
32654
+ args: {
32655
+ json: { type: "boolean", description: "Emit raw JSON" },
32656
+ "dry-run": { type: "boolean", description: "Report without making changes" }
32657
+ },
32658
+ async run({ args }) {
32659
+ try {
32660
+ const {
32661
+ buildDoctorReport,
32662
+ reconcileDoctor,
32663
+ ensureGlobalSignaldockDb: ensureGlobalSignaldockDb2,
32664
+ getGlobalSignaldockDbPath: getGlobalSignaldockDbPath2
32665
+ } = await import("@cleocode/core/internal");
32666
+ const { createRequire: createRequire2 } = await import("node:module");
32667
+ const { DatabaseSync: DatabaseSync2 } = createRequire2(import.meta.url)(
32668
+ "node:sqlite"
32669
+ );
32670
+ await ensureGlobalSignaldockDb2();
32671
+ const db = new DatabaseSync2(getGlobalSignaldockDbPath2());
32672
+ db.exec("PRAGMA foreign_keys = ON");
32673
+ try {
32674
+ const report = await buildDoctorReport(db, {});
32675
+ const d002 = report.findings.filter((f) => f.code === "D-002");
32676
+ const dryRun = args["dry-run"] === true;
32677
+ let repaired = [], skipped = [];
32678
+ if (!dryRun && d002.length > 0) {
32679
+ const r = await reconcileDoctor(db, d002, {});
32680
+ repaired = r.repaired;
32681
+ skipped = r.skipped;
32682
+ }
32683
+ const msg = d002.length === 0 ? "No orphan rows found." : `Found ${d002.length} orphan(s)${dryRun ? " (dry-run)" : ": pruned=" + repaired.length}`;
32684
+ cliOutput(
32685
+ {
32686
+ success: true,
32687
+ data: {
32688
+ message: msg,
32689
+ found: d002.length,
32690
+ repaired: dryRun ? 0 : repaired.length,
32691
+ skipped: dryRun ? 0 : skipped.length,
32692
+ dryRun
32693
+ }
32694
+ },
32695
+ { command: "agent prune-orphans" }
32696
+ );
32697
+ if (!dryRun && skipped.length > 0) process.exitCode = 1;
32698
+ } finally {
32699
+ db.close();
32700
+ }
32701
+ } catch (err) {
32702
+ cliOutput(
32703
+ { success: false, error: { code: "E_PRUNE_ORPHANS", message: String(err) } },
32704
+ { command: "agent prune-orphans" }
32705
+ );
32706
+ process.exitCode = 1;
32707
+ }
32708
+ }
32709
+ });
32649
32710
  doctorCommand = defineCommand({
32650
32711
  meta: {
32651
32712
  name: "doctor",
@@ -32758,6 +32819,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32758
32819
  meta: { name: "agent", description: "Agent lifecycle, credentials, and messaging" },
32759
32820
  subCommands: {
32760
32821
  doctor: doctorCommand,
32822
+ "prune-orphans": pruneOrphansCommand,
32761
32823
  register: registerCommand,
32762
32824
  signin: signinCommand,
32763
32825
  start: startCommand,
@@ -56545,55 +56607,57 @@ async function runStartupMaintenance() {
56545
56607
  const {
56546
56608
  detectAndRemoveLegacyGlobalFiles,
56547
56609
  detectAndRemoveStrayProjectNexus,
56548
- ensureConduitDb,
56549
- ensureGlobalSignaldockDb: ensureGlobalSignaldockDb2,
56550
56610
  getGlobalSalt,
56551
56611
  getLogger: getLogger17,
56552
56612
  getProjectRoot: getProjectRoot33,
56613
+ isCleanupMarkerSet,
56553
56614
  migrateSignaldockToConduit,
56554
56615
  needsSignaldockToConduitMigration,
56616
+ setCleanupMarker,
56555
56617
  validateGlobalSalt
56556
56618
  } = await import("@cleocode/core/internal");
56619
+ let projectRootForCleanup = "";
56557
56620
  try {
56558
- detectAndRemoveLegacyGlobalFiles();
56621
+ projectRootForCleanup = getProjectRoot33();
56559
56622
  } catch {
56560
56623
  }
56561
- try {
56562
- detectAndRemoveStrayProjectNexus(getProjectRoot33());
56563
- } catch {
56624
+ if (!isCleanupMarkerSet(CLI_VERSION, projectRootForCleanup)) {
56625
+ try {
56626
+ detectAndRemoveLegacyGlobalFiles();
56627
+ } catch {
56628
+ }
56629
+ try {
56630
+ if (projectRootForCleanup) {
56631
+ detectAndRemoveStrayProjectNexus(projectRootForCleanup);
56632
+ }
56633
+ } catch {
56634
+ }
56635
+ setCleanupMarker(CLI_VERSION, projectRootForCleanup);
56564
56636
  }
56565
56637
  const _startupLog = getLogger17("cli-startup");
56566
- try {
56567
- const _projectRootForMigration = getProjectRoot33();
56568
- if (needsSignaldockToConduitMigration(_projectRootForMigration)) {
56569
- const migrationResult = migrateSignaldockToConduit(_projectRootForMigration);
56570
- if (migrationResult.status === "failed") {
56571
- _startupLog.error(
56572
- { errors: migrationResult.errors, projectRoot: _projectRootForMigration },
56573
- "T310 migration: signaldock \u2192 conduit failed \u2014 CLI continues, run `cleo doctor` to diagnose"
56638
+ const isInitInvocation = process.argv.slice(2).some((a) => a === "init");
56639
+ if (!isInitInvocation) {
56640
+ try {
56641
+ const _projectRootForMigration = getProjectRoot33();
56642
+ if (needsSignaldockToConduitMigration(_projectRootForMigration)) {
56643
+ const migrationResult = migrateSignaldockToConduit(_projectRootForMigration);
56644
+ if (migrationResult.status === "failed") {
56645
+ _startupLog.error(
56646
+ { errors: migrationResult.errors, projectRoot: _projectRootForMigration },
56647
+ "T310 migration: signaldock \u2192 conduit failed \u2014 CLI continues, run `cleo doctor` to diagnose"
56648
+ );
56649
+ }
56650
+ }
56651
+ } catch (err) {
56652
+ const msg = err instanceof Error ? err.message : String(err);
56653
+ if (msg.includes("E_NO_PROJECT") || msg.startsWith("Run cleo init")) {
56654
+ } else {
56655
+ _startupLog.warn(
56656
+ { error: msg },
56657
+ "T310 migration startup check threw unexpectedly \u2014 CLI continues"
56574
56658
  );
56575
56659
  }
56576
56660
  }
56577
- } catch (err) {
56578
- if (err instanceof Error && err.message.includes("E_NO_PROJECT")) {
56579
- } else {
56580
- _startupLog.warn(
56581
- { error: err instanceof Error ? err.message : String(err) },
56582
- "T310 migration startup check threw unexpectedly \u2014 CLI continues"
56583
- );
56584
- }
56585
- }
56586
- try {
56587
- ensureConduitDb(getProjectRoot33());
56588
- } catch {
56589
- }
56590
- try {
56591
- await ensureGlobalSignaldockDb2();
56592
- } catch (err) {
56593
- _startupLog.warn(
56594
- { error: err instanceof Error ? err.message : String(err) },
56595
- "T310 startup: ensureGlobalSignaldockDb failed \u2014 CLI continues"
56596
- );
56597
56661
  }
56598
56662
  try {
56599
56663
  validateGlobalSalt();