@cleocode/cleo 2026.3.60 → 2026.3.62

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
@@ -11229,16 +11229,33 @@ function runMigrations(nativeDb, db) {
11229
11229
  );
11230
11230
  }
11231
11231
  }
11232
- let lastError;
11232
+ if (tableExists3(nativeDb, "__drizzle_migrations") && tableExists3(nativeDb, "tasks")) {
11233
+ const localMigrations = readMigrationFiles({ migrationsFolder });
11234
+ const localHashes = new Set(localMigrations.map((m) => m.hash));
11235
+ const dbEntries = nativeDb.prepare('SELECT hash FROM "__drizzle_migrations"').all();
11236
+ const hasOrphanedEntries = dbEntries.some((e) => !localHashes.has(e.hash));
11237
+ if (hasOrphanedEntries) {
11238
+ const log11 = getLogger("sqlite");
11239
+ log11.warn(
11240
+ { orphaned: dbEntries.filter((e) => !localHashes.has(e.hash)).length },
11241
+ "Detected stale migration journal entries from a previous CLEO version. Reconciling."
11242
+ );
11243
+ nativeDb.exec('DELETE FROM "__drizzle_migrations"');
11244
+ for (const m of localMigrations) {
11245
+ nativeDb.exec(
11246
+ `INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES ('${m.hash}', ${m.folderMillis})`
11247
+ );
11248
+ }
11249
+ }
11250
+ }
11233
11251
  for (let attempt = 1; attempt <= MAX_MIGRATION_RETRIES; attempt++) {
11234
11252
  try {
11235
11253
  migrate(db, { migrationsFolder });
11236
- return;
11254
+ break;
11237
11255
  } catch (err) {
11238
11256
  if (!isSqliteBusy(err) || attempt === MAX_MIGRATION_RETRIES) {
11239
11257
  throw err;
11240
11258
  }
11241
- lastError = err;
11242
11259
  const delay = Math.min(
11243
11260
  MIGRATION_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1) * (1 + Math.random() * 0.5),
11244
11261
  MIGRATION_RETRY_MAX_DELAY_MS
@@ -11246,7 +11263,19 @@ function runMigrations(nativeDb, db) {
11246
11263
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, Math.round(delay));
11247
11264
  }
11248
11265
  }
11249
- throw lastError;
11266
+ ensureRequiredColumns(nativeDb);
11267
+ }
11268
+ function ensureRequiredColumns(nativeDb) {
11269
+ if (!tableExists3(nativeDb, "tasks")) return;
11270
+ const columns = nativeDb.prepare("PRAGMA table_info(tasks)").all();
11271
+ const existingCols = new Set(columns.map((c) => c.name));
11272
+ for (const req of REQUIRED_TASK_COLUMNS) {
11273
+ if (!existingCols.has(req.name)) {
11274
+ const log11 = getLogger("sqlite");
11275
+ log11.warn({ column: req.name }, `Adding missing column tasks.${req.name} via ALTER TABLE`);
11276
+ nativeDb.exec(`ALTER TABLE tasks ADD COLUMN ${req.name} ${req.ddl}`);
11277
+ }
11278
+ }
11250
11279
  }
11251
11280
  function closeDb() {
11252
11281
  if (_nativeDb2) {
@@ -11303,7 +11332,7 @@ async function closeAllDatabases() {
11303
11332
  } catch {
11304
11333
  }
11305
11334
  }
11306
- var _require2, DatabaseSync2, DB_FILENAME3, SQLITE_SCHEMA_VERSION, SCHEMA_VERSION, _db2, _nativeDb2, _dbPath2, _initPromise2, _gitTrackingChecked, MIN_BACKUP_TASK_COUNT, MAX_MIGRATION_RETRIES, MIGRATION_RETRY_BASE_DELAY_MS, MIGRATION_RETRY_MAX_DELAY_MS;
11335
+ var _require2, DatabaseSync2, DB_FILENAME3, SQLITE_SCHEMA_VERSION, SCHEMA_VERSION, _db2, _nativeDb2, _dbPath2, _initPromise2, _gitTrackingChecked, MIN_BACKUP_TASK_COUNT, MAX_MIGRATION_RETRIES, MIGRATION_RETRY_BASE_DELAY_MS, MIGRATION_RETRY_MAX_DELAY_MS, REQUIRED_TASK_COLUMNS;
11307
11336
  var init_sqlite2 = __esm({
11308
11337
  "packages/core/src/store/sqlite.ts"() {
11309
11338
  "use strict";
@@ -11328,6 +11357,9 @@ var init_sqlite2 = __esm({
11328
11357
  MAX_MIGRATION_RETRIES = 5;
11329
11358
  MIGRATION_RETRY_BASE_DELAY_MS = 100;
11330
11359
  MIGRATION_RETRY_MAX_DELAY_MS = 2e3;
11360
+ REQUIRED_TASK_COLUMNS = [
11361
+ { name: "pipeline_stage", ddl: "text" }
11362
+ ];
11331
11363
  }
11332
11364
  });
11333
11365
 
@@ -13227,7 +13259,7 @@ async function showSequence(cwd) {
13227
13259
  counter: seq.counter,
13228
13260
  lastId: seq.lastId,
13229
13261
  checksum: seq.checksum,
13230
- nextId: `T${seq.counter + 1}`
13262
+ nextId: `T${String(seq.counter + 1).padStart(3, "0")}`
13231
13263
  };
13232
13264
  }
13233
13265
  async function loadAllTasks(cwd, accessor) {
@@ -41780,6 +41812,58 @@ async function addTask(options, cwd, accessor) {
41780
41812
  if (duplicate) {
41781
41813
  return { task: duplicate, duplicate: true };
41782
41814
  }
41815
+ if (options.dryRun) {
41816
+ const previewNow = (/* @__PURE__ */ new Date()).toISOString();
41817
+ let previewParentForStage = null;
41818
+ if (parentId) {
41819
+ const previewParentTask = await dataAccessor.loadSingleTask(parentId);
41820
+ previewParentForStage = previewParentTask ? { pipelineStage: previewParentTask.pipelineStage, type: previewParentTask.type } : null;
41821
+ }
41822
+ const previewPipelineStage = resolveDefaultPipelineStage({
41823
+ explicitStage: options.pipelineStage,
41824
+ taskType: taskType ?? null,
41825
+ parentTask: previewParentForStage
41826
+ });
41827
+ const previewPosition = options.position !== void 0 ? options.position : await dataAccessor.getNextPosition(parentId);
41828
+ const previewTask = {
41829
+ id: "T???",
41830
+ title: options.title,
41831
+ description: options.description,
41832
+ status,
41833
+ priority,
41834
+ type: taskType,
41835
+ parentId: parentId || null,
41836
+ position: previewPosition,
41837
+ positionVersion: 0,
41838
+ size,
41839
+ pipelineStage: previewPipelineStage,
41840
+ createdAt: previewNow,
41841
+ updatedAt: previewNow
41842
+ };
41843
+ if (phase) previewTask.phase = phase;
41844
+ if (options.labels?.length) previewTask.labels = options.labels.map((l) => l.trim());
41845
+ if (options.files?.length) previewTask.files = options.files.map((f) => f.trim());
41846
+ if (options.acceptance?.length)
41847
+ previewTask.acceptance = options.acceptance.map((a) => a.trim());
41848
+ if (options.depends?.length) previewTask.depends = options.depends.map((d) => d.trim());
41849
+ if (options.notes) {
41850
+ const previewNote = `${(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace(/\.\d+Z$/, " UTC")}: ${options.notes}`;
41851
+ previewTask.notes = [previewNote];
41852
+ }
41853
+ if (status === "blocked" && options.description) {
41854
+ previewTask.blockedBy = options.description;
41855
+ }
41856
+ if (status === "done") {
41857
+ previewTask.completedAt = previewNow;
41858
+ }
41859
+ if (taskType !== "epic") {
41860
+ const verificationEnabledRaw = await getRawConfigValue("verification.enabled", cwd);
41861
+ if (verificationEnabledRaw === true) {
41862
+ previewTask.verification = buildDefaultVerification(previewNow);
41863
+ }
41864
+ }
41865
+ return { task: previewTask, dryRun: true };
41866
+ }
41783
41867
  const taskId = await allocateNextTaskId(cwd);
41784
41868
  const now2 = (/* @__PURE__ */ new Date()).toISOString();
41785
41869
  let resolvedParentForStage = null;
@@ -41849,9 +41933,6 @@ async function addTask(options, cwd, accessor) {
41849
41933
  task.verification = buildDefaultVerification(now2);
41850
41934
  }
41851
41935
  }
41852
- if (options.dryRun) {
41853
- return { task, dryRun: true };
41854
- }
41855
41936
  await dataAccessor.transaction(async (tx) => {
41856
41937
  if (options.position !== void 0) {
41857
41938
  await dataAccessor.shiftPositions(parentId, options.position, 1);
@@ -47763,8 +47844,9 @@ var init_observability = __esm({
47763
47844
  });
47764
47845
 
47765
47846
  // packages/core/src/phases/deps.ts
47766
- async function loadAllTasks3(_cwd, accessor) {
47767
- const { tasks: tasks2 } = await accessor.queryTasks({});
47847
+ async function loadAllTasks3(cwd, accessor) {
47848
+ const acc = accessor ?? await getAccessor(cwd);
47849
+ const { tasks: tasks2 } = await acc.queryTasks({});
47768
47850
  return tasks2;
47769
47851
  }
47770
47852
  function buildGraph(tasks2) {
@@ -47840,11 +47922,45 @@ async function getExecutionWaves(epicId, cwd, accessor) {
47840
47922
  }
47841
47923
  return waves;
47842
47924
  }
47925
+ async function getCriticalPath2(taskId, cwd, accessor) {
47926
+ const allTasks = await loadAllTasks3(cwd, accessor);
47927
+ const task = allTasks.find((t) => t.id === taskId);
47928
+ if (!task) {
47929
+ throw new CleoError(4 /* NOT_FOUND */, `Task not found: ${taskId}`);
47930
+ }
47931
+ const graph = buildGraph(allTasks);
47932
+ const taskMap = new Map(allTasks.map((t) => [t.id, t]));
47933
+ function findLongestPath(id, visited) {
47934
+ if (visited.has(id)) return [];
47935
+ visited.add(id);
47936
+ const node = graph.get(id);
47937
+ if (!node || node.dependents.length === 0) {
47938
+ return [id];
47939
+ }
47940
+ let longest = [];
47941
+ for (const depId of node.dependents) {
47942
+ const path3 = findLongestPath(depId, new Set(visited));
47943
+ if (path3.length > longest.length) {
47944
+ longest = path3;
47945
+ }
47946
+ }
47947
+ return [id, ...longest];
47948
+ }
47949
+ const path2 = findLongestPath(taskId, /* @__PURE__ */ new Set());
47950
+ return {
47951
+ path: path2.map((id) => {
47952
+ const t = taskMap.get(id);
47953
+ return t ? { id: t.id, title: t.title, status: t.status } : { id, title: "Unknown", status: "unknown" };
47954
+ }),
47955
+ length: path2.length
47956
+ };
47957
+ }
47843
47958
  var init_deps2 = __esm({
47844
47959
  "packages/core/src/phases/deps.ts"() {
47845
47960
  "use strict";
47846
47961
  init_src();
47847
47962
  init_errors3();
47963
+ init_data_accessor();
47848
47964
  }
47849
47965
  });
47850
47966
 
@@ -52646,6 +52762,13 @@ var init_capability_matrix = __esm({
52646
52762
  mode: "native",
52647
52763
  preferredChannel: "either"
52648
52764
  },
52765
+ {
52766
+ domain: "admin",
52767
+ operation: "backup",
52768
+ gateway: "query",
52769
+ mode: "native",
52770
+ preferredChannel: "either"
52771
+ },
52649
52772
  {
52650
52773
  domain: "admin",
52651
52774
  operation: "backup",
@@ -57895,7 +58018,7 @@ async function getProjectStats(opts, accessor) {
57895
58018
  dbAnd(dbEq(tasksTable.status, "archived"), dbEq(tasksTable.archiveReason, "completed"))
57896
58019
  ).get();
57897
58020
  archivedCompleted = archivedDoneRow?.c ?? 0;
57898
- totalCompleted = (statusMap["done"] ?? 0) + archivedCompleted;
58021
+ totalCompleted = entries.filter(isComplete).length;
57899
58022
  } catch {
57900
58023
  totalCreated = entries.filter(isCreate).length;
57901
58024
  totalCompleted = entries.filter(isComplete).length;
@@ -58901,7 +59024,7 @@ var init_audit2 = __esm({
58901
59024
  });
58902
59025
 
58903
59026
  // packages/core/src/system/backup.ts
58904
- import { existsSync as existsSync82, mkdirSync as mkdirSync18, readFileSync as readFileSync59, writeFileSync as writeFileSync11 } from "node:fs";
59027
+ import { existsSync as existsSync82, mkdirSync as mkdirSync18, readdirSync as readdirSync27, readFileSync as readFileSync59, writeFileSync as writeFileSync11 } from "node:fs";
58905
59028
  import { join as join84 } from "node:path";
58906
59029
  function createBackup2(projectRoot, opts) {
58907
59030
  const cleoDir = join84(projectRoot, ".cleo");
@@ -58947,6 +59070,36 @@ function createBackup2(projectRoot, opts) {
58947
59070
  }
58948
59071
  return { backupId, path: backupDir, timestamp: timestamp2, type: btype, files: backedUp };
58949
59072
  }
59073
+ function listSystemBackups(projectRoot) {
59074
+ const cleoDir = join84(projectRoot, ".cleo");
59075
+ const backupTypes = ["snapshot", "safety", "migration"];
59076
+ const entries = [];
59077
+ for (const btype of backupTypes) {
59078
+ const backupDir = join84(cleoDir, "backups", btype);
59079
+ if (!existsSync82(backupDir)) continue;
59080
+ try {
59081
+ const files = readdirSync27(backupDir).filter((f) => f.endsWith(".meta.json"));
59082
+ for (const metaFile of files) {
59083
+ try {
59084
+ const raw = readFileSync59(join84(backupDir, metaFile), "utf-8");
59085
+ const meta = JSON.parse(raw);
59086
+ if (meta.backupId && meta.timestamp) {
59087
+ entries.push({
59088
+ backupId: meta.backupId,
59089
+ type: meta.type ?? btype,
59090
+ timestamp: meta.timestamp,
59091
+ note: meta.note,
59092
+ files: meta.files ?? []
59093
+ });
59094
+ }
59095
+ } catch {
59096
+ }
59097
+ }
59098
+ } catch {
59099
+ }
59100
+ }
59101
+ return entries.sort((a, b) => b.timestamp.localeCompare(a.timestamp));
59102
+ }
58950
59103
  function restoreBackup(projectRoot, params) {
58951
59104
  if (!params.backupId) {
58952
59105
  throw new CleoError(2 /* INVALID_INPUT */, "backupId is required");
@@ -59071,7 +59224,7 @@ var init_audit_prune = __esm({
59071
59224
  });
59072
59225
 
59073
59226
  // packages/core/src/system/cleanup.ts
59074
- import { existsSync as existsSync83, readdirSync as readdirSync27, readFileSync as readFileSync60, unlinkSync as unlinkSync5, writeFileSync as writeFileSync12 } from "node:fs";
59227
+ import { existsSync as existsSync83, readdirSync as readdirSync28, readFileSync as readFileSync60, unlinkSync as unlinkSync5, writeFileSync as writeFileSync12 } from "node:fs";
59075
59228
  import { join as join86 } from "node:path";
59076
59229
  async function cleanupSystem(projectRoot, params) {
59077
59230
  if (!params.target) {
@@ -59119,10 +59272,10 @@ async function cleanupSystem(projectRoot, params) {
59119
59272
  case "backups": {
59120
59273
  const backupBaseDir = join86(cleoDir, "backups");
59121
59274
  if (existsSync83(backupBaseDir)) {
59122
- for (const typeDir of readdirSync27(backupBaseDir)) {
59275
+ for (const typeDir of readdirSync28(backupBaseDir)) {
59123
59276
  const fullDir = join86(backupBaseDir, typeDir);
59124
59277
  try {
59125
- for (const file2 of readdirSync27(fullDir)) {
59278
+ for (const file2 of readdirSync28(fullDir)) {
59126
59279
  if (file2.endsWith(".meta.json")) {
59127
59280
  const metaFilePath = join86(fullDir, file2);
59128
59281
  try {
@@ -59131,7 +59284,7 @@ async function cleanupSystem(projectRoot, params) {
59131
59284
  items.push(file2.replace(".meta.json", ""));
59132
59285
  if (!dryRun) {
59133
59286
  unlinkSync5(metaFilePath);
59134
- for (const bf of readdirSync27(fullDir)) {
59287
+ for (const bf of readdirSync28(fullDir)) {
59135
59288
  if (bf.includes(meta.backupId)) {
59136
59289
  try {
59137
59290
  unlinkSync5(join86(fullDir, bf));
@@ -59161,7 +59314,7 @@ async function cleanupSystem(projectRoot, params) {
59161
59314
  }
59162
59315
  const auditPattern = /^audit-log-.*\.json$/;
59163
59316
  if (existsSync83(cleoDir)) {
59164
- for (const file2 of readdirSync27(cleoDir)) {
59317
+ for (const file2 of readdirSync28(cleoDir)) {
59165
59318
  if (auditPattern.test(file2)) {
59166
59319
  items.push(file2);
59167
59320
  if (!dryRun) {
@@ -59321,7 +59474,7 @@ import { randomBytes as randomBytes12 } from "node:crypto";
59321
59474
  import {
59322
59475
  existsSync as existsSync85,
59323
59476
  mkdirSync as mkdirSync20,
59324
- readdirSync as readdirSync28,
59477
+ readdirSync as readdirSync29,
59325
59478
  readFileSync as readFileSync61,
59326
59479
  renameSync as renameSync6,
59327
59480
  unlinkSync as unlinkSync6,
@@ -62389,7 +62542,7 @@ var init_tasks2 = __esm({
62389
62542
  });
62390
62543
 
62391
62544
  // packages/core/src/templates/parser.ts
62392
- import { existsSync as existsSync93, readdirSync as readdirSync29, readFileSync as readFileSync67 } from "fs";
62545
+ import { existsSync as existsSync93, readdirSync as readdirSync30, readFileSync as readFileSync67 } from "fs";
62393
62546
  import { join as join96 } from "path";
62394
62547
  import { parse as parseYaml } from "yaml";
62395
62548
  function deriveSubcommand(filename) {
@@ -62463,7 +62616,7 @@ function parseIssueTemplates2(projectRoot) {
62463
62616
  }
62464
62617
  let files;
62465
62618
  try {
62466
- files = readdirSync29(templateDir).filter((f) => /\.ya?ml$/i.test(f) && f !== "config.yml");
62619
+ files = readdirSync30(templateDir).filter((f) => /\.ya?ml$/i.test(f) && f !== "config.yml");
62467
62620
  } catch (error40) {
62468
62621
  return {
62469
62622
  success: false,
@@ -62876,7 +63029,7 @@ var init_changelog = __esm({
62876
63029
  });
62877
63030
 
62878
63031
  // packages/core/src/ui/command-registry.ts
62879
- import { existsSync as existsSync96, readdirSync as readdirSync30, readFileSync as readFileSync70 } from "node:fs";
63032
+ import { existsSync as existsSync96, readdirSync as readdirSync31, readFileSync as readFileSync70 } from "node:fs";
62880
63033
  import { basename as basename16, join as join98 } from "node:path";
62881
63034
  function parseCommandHeader(scriptPath) {
62882
63035
  if (!existsSync96(scriptPath)) return null;
@@ -62959,7 +63112,7 @@ function parseCommandHeader(scriptPath) {
62959
63112
  function scanAllCommands(scriptsDir) {
62960
63113
  const registry2 = /* @__PURE__ */ new Map();
62961
63114
  if (!existsSync96(scriptsDir)) return registry2;
62962
- for (const file2 of readdirSync30(scriptsDir)) {
63115
+ for (const file2 of readdirSync31(scriptsDir)) {
62963
63116
  if (!file2.endsWith(".sh") && !file2.endsWith(".ts")) continue;
62964
63117
  const meta = parseCommandHeader(join98(scriptsDir, file2));
62965
63118
  if (meta) {
@@ -63887,12 +64040,12 @@ var init_compliance2 = __esm({
63887
64040
  });
63888
64041
 
63889
64042
  // packages/core/src/validation/docs-sync.ts
63890
- import { existsSync as existsSync97, readdirSync as readdirSync31, readFileSync as readFileSync71 } from "node:fs";
64043
+ import { existsSync as existsSync97, readdirSync as readdirSync32, readFileSync as readFileSync71 } from "node:fs";
63891
64044
  import { join as join99 } from "node:path";
63892
64045
  function getScriptCommands(scriptsDir) {
63893
64046
  if (!existsSync97(scriptsDir)) return [];
63894
64047
  try {
63895
- return readdirSync31(scriptsDir).filter((f) => f.endsWith(".sh")).map((f) => f.replace(/\.sh$/, "")).sort();
64048
+ return readdirSync32(scriptsDir).filter((f) => f.endsWith(".sh")).map((f) => f.replace(/\.sh$/, "")).sort();
63896
64049
  } catch {
63897
64050
  return [];
63898
64051
  }
@@ -65314,12 +65467,12 @@ var init_manifest = __esm({
65314
65467
  });
65315
65468
 
65316
65469
  // packages/core/src/validation/protocol-common.ts
65317
- import { existsSync as existsSync100, readdirSync as readdirSync32, readFileSync as readFileSync73 } from "node:fs";
65470
+ import { existsSync as existsSync100, readdirSync as readdirSync33, readFileSync as readFileSync73 } from "node:fs";
65318
65471
  function checkOutputFileExists(taskId, expectedDir, pattern) {
65319
65472
  if (!existsSync100(expectedDir)) return false;
65320
65473
  const filePattern = pattern ?? `${taskId}`;
65321
65474
  try {
65322
- const files = readdirSync32(expectedDir);
65475
+ const files = readdirSync33(expectedDir);
65323
65476
  return files.some((f) => f.includes(filePattern) && f.endsWith(".md"));
65324
65477
  } catch {
65325
65478
  return false;
@@ -66298,7 +66451,7 @@ __export(init_exports, {
66298
66451
  isAutoInitEnabled: () => isAutoInitEnabled,
66299
66452
  updateDocs: () => updateDocs
66300
66453
  });
66301
- import { existsSync as existsSync101, readdirSync as readdirSync33, readFileSync as readFileSync74 } from "node:fs";
66454
+ import { existsSync as existsSync101, readdirSync as readdirSync34, readFileSync as readFileSync74 } from "node:fs";
66302
66455
  import { copyFile as copyFile3, lstat, mkdir as mkdir16, readFile as readFile17, symlink, unlink as unlink4, writeFile as writeFile11 } from "node:fs/promises";
66303
66456
  import { platform as platform4 } from "node:os";
66304
66457
  import { basename as basename17, dirname as dirname19, join as join101 } from "node:path";
@@ -66348,7 +66501,7 @@ async function initAgentDefinition(created, warnings) {
66348
66501
  } catch (_err) {
66349
66502
  try {
66350
66503
  await mkdir16(globalAgentsDir, { recursive: true });
66351
- const files = readdirSync33(agentSourceDir);
66504
+ const files = readdirSync34(agentSourceDir);
66352
66505
  for (const file2 of files) {
66353
66506
  await copyFile3(join101(agentSourceDir, file2), join101(globalAgentsDir, file2));
66354
66507
  }
@@ -66497,7 +66650,7 @@ async function installGitHubTemplates(projectRoot, created, skipped) {
66497
66650
  await mkdir16(issueTemplateDir, { recursive: true });
66498
66651
  const issueSrcDir = join101(templateSrcDir, "ISSUE_TEMPLATE");
66499
66652
  if (existsSync101(issueSrcDir)) {
66500
- const issueFiles = readdirSync33(issueSrcDir);
66653
+ const issueFiles = readdirSync34(issueSrcDir);
66501
66654
  for (const file2 of issueFiles) {
66502
66655
  const dest = join101(issueTemplateDir, file2);
66503
66656
  if (existsSync101(dest)) {
@@ -71530,7 +71683,7 @@ var init_model_provider_registry = __esm({
71530
71683
 
71531
71684
  // packages/core/src/metrics/token-service.ts
71532
71685
  import { createHash as createHash13, randomUUID as randomUUID8 } from "node:crypto";
71533
- import { existsSync as existsSync107, readdirSync as readdirSync34, readFileSync as readFileSync79 } from "node:fs";
71686
+ import { existsSync as existsSync107, readdirSync as readdirSync35, readFileSync as readFileSync79 } from "node:fs";
71534
71687
  import { join as join106 } from "node:path";
71535
71688
  function normalizeProvider(provider, model, runtimeProvider) {
71536
71689
  const value = (provider ?? "").trim().toLowerCase();
@@ -71615,7 +71768,7 @@ function getOtelDir2() {
71615
71768
  function readOtelJsonl(dir) {
71616
71769
  if (!existsSync107(dir)) return [];
71617
71770
  const entries = [];
71618
- for (const file2 of readdirSync34(dir)) {
71771
+ for (const file2 of readdirSync35(dir)) {
71619
71772
  if (!file2.endsWith(".json") && !file2.endsWith(".jsonl")) continue;
71620
71773
  const filePath = join106(dir, file2);
71621
71774
  const raw = readFileSync79(filePath, "utf-8").trim();
@@ -72007,7 +72160,7 @@ var init_parallel = __esm({
72007
72160
  });
72008
72161
 
72009
72162
  // packages/core/src/orchestration/skill-ops.ts
72010
- import { existsSync as existsSync108, readdirSync as readdirSync35, readFileSync as readFileSync80 } from "node:fs";
72163
+ import { existsSync as existsSync108, readdirSync as readdirSync36, readFileSync as readFileSync80 } from "node:fs";
72011
72164
  import { join as join107 } from "node:path";
72012
72165
  import { getCanonicalSkillsDir as getCanonicalSkillsDir3 } from "@cleocode/caamp";
72013
72166
  function getSkillContent(skillName, projectRoot) {
@@ -72032,7 +72185,7 @@ function getSkillContent(skillName, projectRoot) {
72032
72185
  let references = [];
72033
72186
  if (existsSync108(refsDir)) {
72034
72187
  try {
72035
- references = readdirSync35(refsDir).filter((f) => f.endsWith(".md") || f.endsWith(".txt")).map((f) => ({
72188
+ references = readdirSync36(refsDir).filter((f) => f.endsWith(".md") || f.endsWith(".txt")).map((f) => ({
72036
72189
  name: f,
72037
72190
  path: join107(skillDir, "references", f)
72038
72191
  }));
@@ -74633,6 +74786,7 @@ var init_migration_sqlite = __esm({
74633
74786
  // packages/core/src/repair.ts
74634
74787
  var repair_exports = {};
74635
74788
  __export(repair_exports, {
74789
+ repairMissingColumns: () => repairMissingColumns,
74636
74790
  repairMissingCompletedAt: () => repairMissingCompletedAt,
74637
74791
  repairMissingSizes: () => repairMissingSizes,
74638
74792
  runAllRepairs: () => runAllRepairs
@@ -74696,12 +74850,43 @@ async function repairMissingCompletedAt(cwd, dryRun) {
74696
74850
  details: `Set completedAt for ${affected.length} done/cancelled task(s)`
74697
74851
  };
74698
74852
  }
74853
+ async function repairMissingColumns(cwd, dryRun) {
74854
+ const { getDb: getDb4 } = await Promise.resolve().then(() => (init_sqlite2(), sqlite_exports));
74855
+ const db = await getDb4(cwd);
74856
+ const { sql: sql12 } = await import("drizzle-orm");
74857
+ const columns = db.all(sql12`PRAGMA table_info(tasks)`);
74858
+ const existingCols = new Set(columns.map((c) => c.name));
74859
+ const missingCols = ["pipeline_stage"].filter((c) => !existingCols.has(c));
74860
+ if (missingCols.length === 0) {
74861
+ return {
74862
+ action: "fix_missing_columns",
74863
+ status: "skipped",
74864
+ details: "All required columns present on tasks table"
74865
+ };
74866
+ }
74867
+ if (dryRun) {
74868
+ return {
74869
+ action: "fix_missing_columns",
74870
+ status: "preview",
74871
+ details: `Would add missing column(s): ${missingCols.join(", ")}`
74872
+ };
74873
+ }
74874
+ for (const col of missingCols) {
74875
+ db.run(sql12.raw(`ALTER TABLE tasks ADD COLUMN ${col} text`));
74876
+ }
74877
+ return {
74878
+ action: "fix_missing_columns",
74879
+ status: "applied",
74880
+ details: `Added missing column(s): ${missingCols.join(", ")}`
74881
+ };
74882
+ }
74699
74883
  async function runAllRepairs(cwd, dryRun) {
74700
- const [sizes, completedAt] = await Promise.all([
74884
+ const [sizes, completedAt, columns] = await Promise.all([
74701
74885
  repairMissingSizes(cwd, dryRun),
74702
- repairMissingCompletedAt(cwd, dryRun)
74886
+ repairMissingCompletedAt(cwd, dryRun),
74887
+ repairMissingColumns(cwd, dryRun)
74703
74888
  ]);
74704
- return [sizes, completedAt];
74889
+ return [sizes, completedAt, columns];
74705
74890
  }
74706
74891
  var init_repair = __esm({
74707
74892
  "packages/core/src/repair.ts"() {
@@ -74714,7 +74899,7 @@ import {
74714
74899
  copyFileSync as copyFileSync7,
74715
74900
  existsSync as existsSync111,
74716
74901
  mkdirSync as mkdirSync23,
74717
- readdirSync as readdirSync36,
74902
+ readdirSync as readdirSync37,
74718
74903
  readFileSync as readFileSync83,
74719
74904
  writeFileSync as writeFileSync20
74720
74905
  } from "node:fs";
@@ -74927,7 +75112,7 @@ async function runUpgrade(options = {}) {
74927
75112
  const dbPath2 = join109(cleoDir2, "tasks.db");
74928
75113
  const safetyDir = join109(cleoDir2, "backups", "safety");
74929
75114
  if (existsSync111(safetyDir)) {
74930
- const backups = readdirSync36(safetyDir).filter((f) => f.startsWith("tasks.db.pre-migration.")).sort().reverse();
75115
+ const backups = readdirSync37(safetyDir).filter((f) => f.startsWith("tasks.db.pre-migration.")).sort().reverse();
74931
75116
  if (backups.length > 0 && !existsSync111(dbPath2)) {
74932
75117
  copyFileSync7(join109(safetyDir, backups[0]), dbPath2);
74933
75118
  }
@@ -77854,7 +78039,7 @@ var init_bootstrap2 = __esm({
77854
78039
  });
77855
78040
 
77856
78041
  // packages/core/src/orchestration/critical-path.ts
77857
- async function getCriticalPath2(cwd, accessor) {
78042
+ async function getCriticalPath3(cwd, accessor) {
77858
78043
  const acc = accessor ?? await getAccessor(cwd);
77859
78044
  const { tasks: tasks2 } = await acc.queryTasks({});
77860
78045
  if (tasks2.length === 0) {
@@ -78317,6 +78502,7 @@ __export(internal_exports, {
78317
78502
  WorkflowGateTracker: () => WorkflowGateTracker,
78318
78503
  adapters: () => adapters_exports,
78319
78504
  addChain: () => addChain,
78505
+ addIssue: () => addIssue,
78320
78506
  addRemote: () => addRemote,
78321
78507
  addSticky: () => addSticky,
78322
78508
  addTask: () => addTask,
@@ -78474,6 +78660,7 @@ __export(internal_exports, {
78474
78660
  deletePhase: () => deletePhase,
78475
78661
  deleteTask: () => deleteTask,
78476
78662
  deleteTokenUsage: () => deleteTokenUsage,
78663
+ depsCriticalPath: () => getCriticalPath2,
78477
78664
  deregisterAgent: () => deregisterAgent,
78478
78665
  describeChannel: () => describeChannel,
78479
78666
  detectCrashedAgents: () => detectCrashedAgents,
@@ -78615,6 +78802,7 @@ __export(internal_exports, {
78615
78802
  getSystemInfo: () => getSystemInfo2,
78616
78803
  getSystemMetrics: () => getSystemMetrics,
78617
78804
  getSystemMigrationStatus: () => getMigrationStatus2,
78805
+ getTask: () => getTask,
78618
78806
  getTaskHistory: () => getTaskHistory,
78619
78807
  getTaskPath: () => getTaskPath,
78620
78808
  getTemplateForSubcommand: () => getTemplateForSubcommand2,
@@ -78690,6 +78878,7 @@ __export(internal_exports, {
78690
78878
  listSessions: () => listSessions,
78691
78879
  listStickies: () => listStickies,
78692
78880
  listStrictnessPresets: () => listStrictnessPresets,
78881
+ listSystemBackups: () => listSystemBackups,
78693
78882
  listTasks: () => listTasks,
78694
78883
  listTesseraTemplates: () => listTesseraTemplates,
78695
78884
  listTokenUsage: () => listTokenUsage,
@@ -78750,7 +78939,7 @@ __export(internal_exports, {
78750
78939
  ops: () => operations_exports,
78751
78940
  orchestration: () => orchestration_exports,
78752
78941
  orchestrationAnalyzeDependencies: () => analyzeDependencies,
78753
- orchestrationGetCriticalPath: () => getCriticalPath2,
78942
+ orchestrationGetCriticalPath: () => getCriticalPath3,
78754
78943
  orchestrationGetNextTask: () => getNextTask,
78755
78944
  orchestrationGetReadyTasks: () => getReadyTasks2,
78756
78945
  orphanDetection: () => orphanDetection,
@@ -78957,6 +79146,7 @@ var init_internal = __esm({
78957
79146
  init_impact();
78958
79147
  init_patterns2();
78959
79148
  init_prediction();
79149
+ init_create();
78960
79150
  init_diagnostics();
78961
79151
  init_retry2();
78962
79152
  init_chain_store();
@@ -78983,6 +79173,7 @@ var init_internal = __esm({
78983
79173
  init_waves();
78984
79174
  init_otel();
78985
79175
  init_paths();
79176
+ init_deps2();
78986
79177
  init_phases();
78987
79178
  init_pipeline2();
78988
79179
  init_platform();
@@ -82837,6 +83028,16 @@ var OPERATIONS = [
82837
83028
  }
82838
83029
  ]
82839
83030
  },
83031
+ {
83032
+ gateway: "query",
83033
+ domain: "admin",
83034
+ operation: "backup",
83035
+ description: "admin.backup (query) \u2014 list available backups (read-only)",
83036
+ tier: 1,
83037
+ idempotent: true,
83038
+ sessionRequired: false,
83039
+ requiredParams: []
83040
+ },
82840
83041
  {
82841
83042
  gateway: "mutate",
82842
83043
  domain: "admin",
@@ -84878,7 +85079,7 @@ async function orchestrateCriticalPath(projectRoot) {
84878
85079
  try {
84879
85080
  const root = projectRoot || resolveProjectRoot();
84880
85081
  const accessor = await getAccessor(root);
84881
- const result = await getCriticalPath2(root, accessor);
85082
+ const result = await getCriticalPath3(root, accessor);
84882
85083
  return { success: true, data: result };
84883
85084
  } catch (err) {
84884
85085
  return engineError("E_GENERAL", err.message);
@@ -85634,7 +85835,7 @@ async function releaseShip(params, projectRoot) {
85634
85835
  // packages/cleo/src/dispatch/engines/system-engine.ts
85635
85836
  init_internal();
85636
85837
  init_error();
85637
- import { existsSync as existsSync119, readdirSync as readdirSync37, readFileSync as readFileSync93 } from "node:fs";
85838
+ import { existsSync as existsSync119, readdirSync as readdirSync38, readFileSync as readFileSync93 } from "node:fs";
85638
85839
  import { basename as basename18, join as join112 } from "node:path";
85639
85840
  var HELP_TOPICS = {
85640
85841
  session: {
@@ -85941,7 +86142,7 @@ function systemContext(projectRoot, params) {
85941
86142
  const sessions2 = [];
85942
86143
  const statesDir = join112(cleoDir, "context-states");
85943
86144
  if (existsSync119(statesDir)) {
85944
- for (const file2 of readdirSync37(statesDir)) {
86145
+ for (const file2 of readdirSync38(statesDir)) {
85945
86146
  if (file2.startsWith("context-state-") && file2.endsWith(".json")) {
85946
86147
  try {
85947
86148
  const state = JSON.parse(readFileSync93(join112(statesDir, file2), "utf-8"));
@@ -86078,6 +86279,14 @@ function systemBackup(projectRoot, params) {
86078
86279
  return engineError("E_GENERAL", err.message);
86079
86280
  }
86080
86281
  }
86282
+ function systemListBackups(projectRoot) {
86283
+ try {
86284
+ const result = listSystemBackups(projectRoot);
86285
+ return { success: true, data: result };
86286
+ } catch (err) {
86287
+ return engineError("E_GENERAL", err.message);
86288
+ }
86289
+ }
86081
86290
  function systemRestore(projectRoot, params) {
86082
86291
  try {
86083
86292
  const result = restoreBackup(projectRoot, params);
@@ -87644,6 +87853,16 @@ var AdminHandler = class {
87644
87853
  data: result
87645
87854
  };
87646
87855
  }
87856
+ case "backup": {
87857
+ const result = systemListBackups(projectRoot);
87858
+ return wrapResult(
87859
+ { success: true, data: { backups: result, count: result.length } },
87860
+ "query",
87861
+ "admin",
87862
+ operation,
87863
+ startTime
87864
+ );
87865
+ }
87647
87866
  case "map": {
87648
87867
  const { mapCodebase: mapCodebase3 } = await Promise.resolve().then(() => (init_codebase_map_engine(), codebase_map_engine_exports));
87649
87868
  const result = await mapCodebase3(projectRoot, {
@@ -88133,6 +88352,7 @@ var AdminHandler = class {
88133
88352
  "token",
88134
88353
  "adr.show",
88135
88354
  "adr.find",
88355
+ "backup",
88136
88356
  "export",
88137
88357
  "map"
88138
88358
  ],
@@ -93675,7 +93895,7 @@ function registerBackupCommand(program) {
93675
93895
  });
93676
93896
  backup.command("list").description("List available backups").action(async () => {
93677
93897
  await dispatchFromCli(
93678
- "mutate",
93898
+ "query",
93679
93899
  "admin",
93680
93900
  "backup",
93681
93901
  {
@@ -94081,7 +94301,7 @@ function registerConsensusCommand(program) {
94081
94301
  // packages/cleo/src/cli/commands/context.ts
94082
94302
  function registerContextCommand(program) {
94083
94303
  const context = program.command("context").description("Monitor context window usage for agent safeguard system");
94084
- context.command("status").description("Show current context state (default)").option("--session <id>", "Check specific CLEO session").action(async (opts) => {
94304
+ context.command("status", { isDefault: true }).description("Show current context state (default)").option("--session <id>", "Check specific CLEO session").action(async (opts) => {
94085
94305
  await dispatchFromCli(
94086
94306
  "query",
94087
94307
  "admin",
@@ -94223,6 +94443,9 @@ function registerDeleteCommand(program) {
94223
94443
  }
94224
94444
 
94225
94445
  // packages/cleo/src/cli/commands/deps.ts
94446
+ init_src();
94447
+ init_internal();
94448
+ init_renderers();
94226
94449
  function registerDepsCommand(program) {
94227
94450
  const deps = program.command("deps").description("Dependency visualization and analysis");
94228
94451
  deps.command("overview").description("Overview of all dependencies").action(async () => {
@@ -94260,15 +94483,15 @@ function registerDepsCommand(program) {
94260
94483
  );
94261
94484
  });
94262
94485
  deps.command("critical-path <taskId>").description("Find longest dependency chain from task").action(async (taskId) => {
94263
- await dispatchFromCli(
94264
- "query",
94265
- "orchestrate",
94266
- "critical.path",
94267
- {
94268
- taskId
94269
- },
94270
- { command: "deps", operation: "tasks.depends" }
94271
- );
94486
+ const cwd = resolveProjectRoot();
94487
+ try {
94488
+ const result = await getCriticalPath2(taskId, cwd);
94489
+ cliOutput(result, { command: "deps", operation: "tasks.criticalPath" });
94490
+ } catch (err) {
94491
+ const msg = err instanceof Error ? err.message : String(err);
94492
+ console.error(`critical-path: ${msg}`);
94493
+ process.exit(4 /* NOT_FOUND */);
94494
+ }
94272
94495
  });
94273
94496
  deps.command("impact <taskId>").description("Find all tasks affected by changes to task").option("--depth <n>", "Maximum depth for impact analysis", "10").action(async (taskId, opts) => {
94274
94497
  await dispatchFromCli(
@@ -94330,7 +94553,7 @@ function registerDetectCommand(program) {
94330
94553
  // packages/cleo/src/cli/commands/detect-drift.ts
94331
94554
  init_src();
94332
94555
  init_renderers();
94333
- import { existsSync as existsSync121, readdirSync as readdirSync38, readFileSync as readFileSync95 } from "node:fs";
94556
+ import { existsSync as existsSync121, readdirSync as readdirSync39, readFileSync as readFileSync95 } from "node:fs";
94334
94557
  import { dirname as dirname22, join as join114 } from "node:path";
94335
94558
  import { fileURLToPath as fileURLToPath5 } from "node:url";
94336
94559
  function findProjectRoot() {
@@ -94482,7 +94705,7 @@ function registerDetectDriftCommand(program) {
94482
94705
  }
94483
94706
  ]);
94484
94707
  } else {
94485
- const files = readdirSync38(cliDir).filter(
94708
+ const files = readdirSync39(cliDir).filter(
94486
94709
  (f) => f.endsWith(".ts") && !f.includes(".test.")
94487
94710
  );
94488
94711
  addCheck("CLI-to-core sync", "pass", `Found ${files.length} CLI command implementations`);
@@ -94502,7 +94725,7 @@ function registerDetectDriftCommand(program) {
94502
94725
  }
94503
94726
  ]);
94504
94727
  } else {
94505
- const files = readdirSync38(domainsDir).filter((f) => f.endsWith(".ts"));
94728
+ const files = readdirSync39(domainsDir).filter((f) => f.endsWith(".ts"));
94506
94729
  addCheck("Domain handler coverage", "pass", `Found ${files.length} domain handlers`);
94507
94730
  }
94508
94731
  } catch (e) {
@@ -94996,24 +95219,29 @@ function registerEnvCommand(program) {
94996
95219
 
94997
95220
  // packages/cleo/src/cli/commands/exists.ts
94998
95221
  init_src();
95222
+ init_internal();
94999
95223
  init_renderers();
95000
95224
  function registerExistsCommand(program) {
95001
- program.command("exists <task-id>").description("Check if a task ID exists (exit 0=exists, 4=not found)").option("--include-archive", "Search archive file too").option("--verbose", "Show which file contains the task").action(async (taskId, opts) => {
95002
- const response = await dispatchRaw("query", "tasks", "exists", {
95003
- taskId,
95004
- includeArchive: opts["includeArchive"],
95005
- verbose: opts["verbose"]
95006
- });
95007
- if (!response.success) {
95008
- handleRawError(response, { command: "exists", operation: "tasks.exists" });
95225
+ program.command("exists <task-id>").description("Check if a task ID exists (exit 0=exists, 4=not found)").option("--verbose", "Show task title and status when found").action(async (taskId, opts) => {
95226
+ const cwd = resolveProjectRoot();
95227
+ let task;
95228
+ try {
95229
+ task = await getTask(taskId, cwd);
95230
+ } catch (err) {
95231
+ console.error(`exists: ${err instanceof Error ? err.message : String(err)}`);
95232
+ process.exit(1 /* GENERAL_ERROR */);
95009
95233
  }
95010
- const data = response.data;
95011
- if (data?.exists) {
95012
- cliOutput(data, { command: "exists" });
95013
- } else {
95014
- cliOutput(data, { command: "exists" });
95234
+ if (!task) {
95235
+ const data2 = { exists: false, taskId };
95236
+ cliOutput(data2, { command: "exists", operation: "tasks.exists" });
95015
95237
  process.exit(4 /* NOT_FOUND */);
95016
95238
  }
95239
+ const data = { exists: true, taskId };
95240
+ if (opts["verbose"]) {
95241
+ data["title"] = task.title;
95242
+ data["status"] = task.status;
95243
+ }
95244
+ cliOutput(data, { command: "exists", operation: "tasks.exists" });
95017
95245
  });
95018
95246
  }
95019
95247
 
@@ -95527,23 +95755,23 @@ function registerIssueCommand(program) {
95527
95755
  });
95528
95756
  }
95529
95757
  async function handleIssueType(issueType, opts) {
95530
- const params = {
95531
- issueType,
95532
- title: opts["title"],
95533
- body: opts["body"],
95534
- dryRun: !!opts["dryRun"]
95535
- };
95536
- if (opts["severity"]) params["severity"] = opts["severity"];
95537
- if (opts["area"]) params["area"] = opts["area"];
95538
- const opName = `issue.add.${issueType}`;
95539
- const response = await dispatchRaw("mutate", "tools", opName, params);
95540
- if (!response.success) {
95541
- handleRawError(response, { command: "issue", operation: `tools.${opName}` });
95758
+ let result;
95759
+ try {
95760
+ result = addIssue({
95761
+ issueType,
95762
+ title: opts["title"],
95763
+ body: opts["body"],
95764
+ severity: opts["severity"],
95765
+ area: opts["area"],
95766
+ dryRun: !!opts["dryRun"]
95767
+ });
95768
+ } catch (err) {
95769
+ console.error(`Failed to create issue: ${err instanceof Error ? err.message : String(err)}`);
95770
+ process.exitCode = 1;
95542
95771
  return;
95543
95772
  }
95544
- const result = response.data;
95545
- if (opts["open"] && typeof result["url"] === "string" && result["url"].startsWith("https://")) {
95546
- const issueNumber = result["url"].match(/(\d+)$/)?.[1] ?? "unknown";
95773
+ if (opts["open"] && typeof result.url === "string" && result.url.startsWith("https://")) {
95774
+ const issueNumber = result.url.match(/(\d+)$/)?.[1] ?? "unknown";
95547
95775
  try {
95548
95776
  execFileSync15("gh", ["issue", "view", issueNumber, "--repo", CLEO_REPO2, "--web"], {
95549
95777
  stdio: ["pipe", "pipe", "pipe"]
@@ -95551,13 +95779,13 @@ async function handleIssueType(issueType, opts) {
95551
95779
  } catch {
95552
95780
  }
95553
95781
  }
95554
- cliOutput(result, { command: "issue", operation: `tools.${opName}` });
95782
+ cliOutput(result, { command: "issue", operation: `tools.issue.add.${issueType}` });
95555
95783
  }
95556
95784
 
95557
95785
  // packages/cleo/src/cli/commands/labels.ts
95558
95786
  function registerLabelsCommand(program) {
95559
95787
  const labels = program.command("labels").description("List all labels with counts or show tasks with specific label");
95560
- labels.command("list").description("List all labels with task counts (default)").action(async () => {
95788
+ labels.command("list", { isDefault: true }).description("List all labels with task counts (default)").action(async () => {
95561
95789
  await dispatchFromCli("query", "tasks", "label.list", {}, { command: "labels" });
95562
95790
  });
95563
95791
  labels.command("show <label>").description("Show tasks with specific label").action(async (label) => {
@@ -96441,7 +96669,7 @@ function registerPhaseCommand(program) {
96441
96669
  // packages/cleo/src/cli/commands/phases.ts
96442
96670
  function registerPhasesCommand(program) {
96443
96671
  const phases = program.command("phases").description("List phases with progress bars and statistics");
96444
- phases.command("list").description("List all phases with progress (default)").action(async () => {
96672
+ phases.command("list", { isDefault: true }).description("List all phases with progress (default)").action(async () => {
96445
96673
  await dispatchFromCli("query", "pipeline", "phase.list", {}, { command: "phases" });
96446
96674
  });
96447
96675
  phases.command("show <phase>").description("Show phase details and task counts").action(async (phase) => {
@@ -98844,14 +99072,15 @@ function shimToCitty(shim) {
98844
99072
  subCommands2[alias] = shimToCitty(sub);
98845
99073
  }
98846
99074
  }
98847
- return defineCommand({
99075
+ const cittyDef = defineCommand({
98848
99076
  meta: {
98849
99077
  name: shim._name,
98850
99078
  description: shim._description
98851
99079
  },
98852
99080
  args: cittyArgs,
98853
99081
  ...Object.keys(subCommands2).length > 0 ? { subCommands: subCommands2 } : {},
98854
- async run({ args }) {
99082
+ async run(context) {
99083
+ const { args } = context;
98855
99084
  if (shim._action) {
98856
99085
  const positionalValues = [];
98857
99086
  for (const arg of shim._args) {
@@ -98869,9 +99098,17 @@ function shimToCitty(shim) {
98869
99098
  }
98870
99099
  }
98871
99100
  await shim._action(...positionalValues, opts, shim);
99101
+ } else if (shim._subcommands.length > 0) {
99102
+ const defaultSub = shim._subcommands.find((s) => s._isDefault);
99103
+ if (defaultSub?._action) {
99104
+ await defaultSub._action({}, defaultSub);
99105
+ } else {
99106
+ await showUsage(context.cmd);
99107
+ }
98872
99108
  }
98873
99109
  }
98874
99110
  });
99111
+ return cittyDef;
98875
99112
  }
98876
99113
  var subCommands = {};
98877
99114
  subCommands["version"] = defineCommand({