chainlesschain 0.81.0 → 0.132.0

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.
Files changed (110) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/agent-network.js +254 -1
  4. package/src/commands/audit.js +302 -0
  5. package/src/commands/automation.js +271 -1
  6. package/src/commands/codegen.js +224 -0
  7. package/src/commands/collab.js +341 -0
  8. package/src/commands/compliance.js +1035 -0
  9. package/src/commands/cowork.js +221 -0
  10. package/src/commands/dbevo.js +284 -0
  11. package/src/commands/dev.js +252 -0
  12. package/src/commands/did.js +358 -0
  13. package/src/commands/encrypt.js +341 -0
  14. package/src/commands/export.js +256 -1
  15. package/src/commands/fusion.js +258 -0
  16. package/src/commands/governance.js +325 -0
  17. package/src/commands/hardening.js +411 -0
  18. package/src/commands/hook.js +148 -0
  19. package/src/commands/import.js +252 -0
  20. package/src/commands/incentive.js +322 -0
  21. package/src/commands/infra.js +244 -0
  22. package/src/commands/instinct.js +260 -0
  23. package/src/commands/ipfs.js +318 -0
  24. package/src/commands/kg.js +387 -0
  25. package/src/commands/llm.js +263 -0
  26. package/src/commands/mcp.js +221 -0
  27. package/src/commands/memory.js +248 -0
  28. package/src/commands/multimodal.js +296 -0
  29. package/src/commands/nlprog.js +356 -0
  30. package/src/commands/note.js +244 -0
  31. package/src/commands/ops.js +354 -0
  32. package/src/commands/orchestrate.js +166 -0
  33. package/src/commands/org.js +277 -0
  34. package/src/commands/p2p.js +390 -0
  35. package/src/commands/perception.js +290 -0
  36. package/src/commands/permmem.js +251 -0
  37. package/src/commands/plugin-ecosystem.js +273 -0
  38. package/src/commands/pqc.js +393 -0
  39. package/src/commands/quantization.js +351 -0
  40. package/src/commands/rcache.js +271 -0
  41. package/src/commands/recommend.js +340 -0
  42. package/src/commands/runtime.js +307 -0
  43. package/src/commands/scim.js +262 -0
  44. package/src/commands/session.js +258 -0
  45. package/src/commands/skill.js +267 -1
  46. package/src/commands/social.js +256 -0
  47. package/src/commands/sso.js +186 -1
  48. package/src/commands/sync.js +256 -0
  49. package/src/commands/tech.js +338 -0
  50. package/src/commands/tenant.js +351 -0
  51. package/src/commands/tokens.js +269 -0
  52. package/src/commands/trust.js +249 -0
  53. package/src/commands/wallet.js +277 -0
  54. package/src/commands/workflow.js +171 -0
  55. package/src/index.js +4 -0
  56. package/src/lib/agent-coordinator.js +325 -0
  57. package/src/lib/agent-network.js +387 -0
  58. package/src/lib/agent-router.js +395 -0
  59. package/src/lib/aiops.js +478 -0
  60. package/src/lib/audit-logger.js +379 -0
  61. package/src/lib/automation-engine.js +330 -0
  62. package/src/lib/autonomous-developer.js +350 -0
  63. package/src/lib/code-agent.js +323 -0
  64. package/src/lib/collaboration-governance.js +364 -0
  65. package/src/lib/community-governance.js +436 -0
  66. package/src/lib/compliance-manager.js +434 -0
  67. package/src/lib/content-recommendation.js +469 -0
  68. package/src/lib/crypto-manager.js +350 -0
  69. package/src/lib/dbevo.js +338 -0
  70. package/src/lib/decentral-infra.js +340 -0
  71. package/src/lib/did-manager.js +367 -0
  72. package/src/lib/hardening-manager.js +348 -0
  73. package/src/lib/hook-manager.js +380 -0
  74. package/src/lib/instinct-manager.js +332 -0
  75. package/src/lib/ipfs-storage.js +334 -0
  76. package/src/lib/knowledge-exporter.js +381 -0
  77. package/src/lib/knowledge-graph.js +432 -0
  78. package/src/lib/knowledge-importer.js +379 -0
  79. package/src/lib/llm-providers.js +391 -0
  80. package/src/lib/mcp-registry.js +333 -0
  81. package/src/lib/memory-manager.js +330 -0
  82. package/src/lib/multimodal.js +346 -0
  83. package/src/lib/nl-programming.js +343 -0
  84. package/src/lib/note-versioning.js +327 -0
  85. package/src/lib/org-manager.js +323 -0
  86. package/src/lib/p2p-manager.js +387 -0
  87. package/src/lib/perception.js +346 -0
  88. package/src/lib/perf-tuning.js +4 -1
  89. package/src/lib/permanent-memory.js +320 -0
  90. package/src/lib/plugin-ecosystem.js +377 -0
  91. package/src/lib/pqc-manager.js +368 -0
  92. package/src/lib/protocol-fusion.js +417 -0
  93. package/src/lib/quantization.js +325 -0
  94. package/src/lib/response-cache.js +327 -0
  95. package/src/lib/scim-manager.js +329 -0
  96. package/src/lib/session-manager.js +329 -0
  97. package/src/lib/skill-loader.js +377 -0
  98. package/src/lib/social-manager.js +326 -0
  99. package/src/lib/sso-manager.js +332 -0
  100. package/src/lib/sync-manager.js +326 -0
  101. package/src/lib/tech-learning-engine.js +369 -0
  102. package/src/lib/tenant-saas.js +460 -0
  103. package/src/lib/threat-intel.js +335 -0
  104. package/src/lib/token-incentive.js +293 -0
  105. package/src/lib/token-tracker.js +329 -0
  106. package/src/lib/trust-security.js +390 -0
  107. package/src/lib/ueba.js +389 -0
  108. package/src/lib/universal-runtime.js +325 -0
  109. package/src/lib/wallet-manager.js +326 -0
  110. package/src/lib/workflow-engine.js +322 -0
@@ -1181,4 +1181,225 @@ export function registerCoworkCommand(program) {
1181
1181
  );
1182
1182
  logger.log("");
1183
1183
  });
1184
+
1185
+ // ===== V2 governance subcommands (agent-coordinator V2) =====
1186
+ cowork
1187
+ .command("coord-agent-maturities-v2")
1188
+ .description("List coord agent maturity states (V2)")
1189
+ .action(async () => {
1190
+ const m = await import("../lib/agent-coordinator.js");
1191
+ console.log(JSON.stringify(m.COORD_AGENT_MATURITY_V2, null, 2));
1192
+ });
1193
+ cowork
1194
+ .command("coord-assignment-lifecycle-v2")
1195
+ .description("List coord assignment lifecycle states (V2)")
1196
+ .action(async () => {
1197
+ const m = await import("../lib/agent-coordinator.js");
1198
+ console.log(JSON.stringify(m.COORD_ASSIGNMENT_LIFECYCLE_V2, null, 2));
1199
+ });
1200
+ cowork
1201
+ .command("coord-stats-v2")
1202
+ .description("Show agent-coordinator V2 stats")
1203
+ .action(async () => {
1204
+ const m = await import("../lib/agent-coordinator.js");
1205
+ console.log(JSON.stringify(m.getAgentCoordinatorStatsV2(), null, 2));
1206
+ });
1207
+ cowork
1208
+ .command("coord-config-v2")
1209
+ .description("Show agent-coordinator V2 config")
1210
+ .action(async () => {
1211
+ const m = await import("../lib/agent-coordinator.js");
1212
+ console.log(
1213
+ JSON.stringify(
1214
+ {
1215
+ maxActiveAgentsPerOwner: m.getMaxActiveAgentsPerOwnerCoordV2(),
1216
+ maxPendingAssignmentsPerAgent:
1217
+ m.getMaxPendingAssignmentsPerAgentV2(),
1218
+ agentIdleMs: m.getAgentIdleMsCoordV2(),
1219
+ assignmentStuckMs: m.getAssignmentStuckMsV2(),
1220
+ },
1221
+ null,
1222
+ 2,
1223
+ ),
1224
+ );
1225
+ });
1226
+ cowork
1227
+ .command("coord-register-agent-v2 <id> <owner>")
1228
+ .description("Register a coord agent (V2)")
1229
+ .action(async (id, owner) => {
1230
+ const m = await import("../lib/agent-coordinator.js");
1231
+ console.log(
1232
+ JSON.stringify(m.registerCoordAgentV2({ id, owner }), null, 2),
1233
+ );
1234
+ });
1235
+ cowork
1236
+ .command("coord-activate-agent-v2 <id>")
1237
+ .description("Activate a coord agent (V2)")
1238
+ .action(async (id) => {
1239
+ const m = await import("../lib/agent-coordinator.js");
1240
+ console.log(JSON.stringify(m.activateCoordAgentV2(id), null, 2));
1241
+ });
1242
+ cowork
1243
+ .command("coord-idle-agent-v2 <id>")
1244
+ .description("Mark coord agent as idle (V2)")
1245
+ .action(async (id) => {
1246
+ const m = await import("../lib/agent-coordinator.js");
1247
+ console.log(JSON.stringify(m.idleCoordAgentV2(id), null, 2));
1248
+ });
1249
+ cowork
1250
+ .command("coord-retire-agent-v2 <id>")
1251
+ .description("Retire a coord agent (V2)")
1252
+ .action(async (id) => {
1253
+ const m = await import("../lib/agent-coordinator.js");
1254
+ console.log(JSON.stringify(m.retireCoordAgentV2(id), null, 2));
1255
+ });
1256
+ cowork
1257
+ .command("coord-touch-agent-v2 <id>")
1258
+ .description("Touch a coord agent (V2)")
1259
+ .action(async (id) => {
1260
+ const m = await import("../lib/agent-coordinator.js");
1261
+ console.log(JSON.stringify(m.touchCoordAgentV2(id), null, 2));
1262
+ });
1263
+ cowork
1264
+ .command("coord-get-agent-v2 <id>")
1265
+ .description("Get a coord agent (V2)")
1266
+ .action(async (id) => {
1267
+ const m = await import("../lib/agent-coordinator.js");
1268
+ console.log(JSON.stringify(m.getCoordAgentV2(id), null, 2));
1269
+ });
1270
+ cowork
1271
+ .command("coord-list-agents-v2")
1272
+ .description("List coord agents (V2)")
1273
+ .action(async () => {
1274
+ const m = await import("../lib/agent-coordinator.js");
1275
+ console.log(JSON.stringify(m.listCoordAgentsV2(), null, 2));
1276
+ });
1277
+ cowork
1278
+ .command("coord-create-assignment-v2 <id> <agentId>")
1279
+ .description("Create a coord assignment (V2)")
1280
+ .action(async (id, agentId) => {
1281
+ const m = await import("../lib/agent-coordinator.js");
1282
+ console.log(
1283
+ JSON.stringify(m.createAssignmentV2({ id, agentId }), null, 2),
1284
+ );
1285
+ });
1286
+ cowork
1287
+ .command("coord-dispatch-assignment-v2 <id>")
1288
+ .description("Dispatch a coord assignment (V2)")
1289
+ .action(async (id) => {
1290
+ const m = await import("../lib/agent-coordinator.js");
1291
+ console.log(JSON.stringify(m.dispatchAssignmentV2(id), null, 2));
1292
+ });
1293
+ cowork
1294
+ .command("coord-complete-assignment-v2 <id>")
1295
+ .description("Complete a coord assignment (V2)")
1296
+ .action(async (id) => {
1297
+ const m = await import("../lib/agent-coordinator.js");
1298
+ console.log(JSON.stringify(m.completeAssignmentV2(id), null, 2));
1299
+ });
1300
+ cowork
1301
+ .command("coord-fail-assignment-v2 <id> [reason]")
1302
+ .description("Fail a coord assignment (V2)")
1303
+ .action(async (id, reason) => {
1304
+ const m = await import("../lib/agent-coordinator.js");
1305
+ console.log(JSON.stringify(m.failAssignmentV2(id, reason), null, 2));
1306
+ });
1307
+ cowork
1308
+ .command("coord-cancel-assignment-v2 <id> [reason]")
1309
+ .description("Cancel a coord assignment (V2)")
1310
+ .action(async (id, reason) => {
1311
+ const m = await import("../lib/agent-coordinator.js");
1312
+ console.log(JSON.stringify(m.cancelAssignmentV2(id, reason), null, 2));
1313
+ });
1314
+ cowork
1315
+ .command("coord-get-assignment-v2 <id>")
1316
+ .description("Get a coord assignment (V2)")
1317
+ .action(async (id) => {
1318
+ const m = await import("../lib/agent-coordinator.js");
1319
+ console.log(JSON.stringify(m.getAssignmentV2(id), null, 2));
1320
+ });
1321
+ cowork
1322
+ .command("coord-list-assignments-v2")
1323
+ .description("List coord assignments (V2)")
1324
+ .action(async () => {
1325
+ const m = await import("../lib/agent-coordinator.js");
1326
+ console.log(JSON.stringify(m.listAssignmentsV2(), null, 2));
1327
+ });
1328
+ cowork
1329
+ .command("coord-auto-idle-agents-v2")
1330
+ .description("Auto-idle coord agents (V2)")
1331
+ .action(async () => {
1332
+ const m = await import("../lib/agent-coordinator.js");
1333
+ console.log(JSON.stringify(m.autoIdleCoordAgentsV2(), null, 2));
1334
+ });
1335
+ cowork
1336
+ .command("coord-auto-fail-stuck-assignments-v2")
1337
+ .description("Auto-fail stuck coord assignments (V2)")
1338
+ .action(async () => {
1339
+ const m = await import("../lib/agent-coordinator.js");
1340
+ console.log(JSON.stringify(m.autoFailStuckAssignmentsV2(), null, 2));
1341
+ });
1342
+ cowork
1343
+ .command("coord-set-max-active-agents-v2 <n>")
1344
+ .description("Set max active coord agents per owner (V2)")
1345
+ .action(async (n) => {
1346
+ const m = await import("../lib/agent-coordinator.js");
1347
+ m.setMaxActiveAgentsPerOwnerCoordV2(parseInt(n, 10));
1348
+ console.log(
1349
+ JSON.stringify(
1350
+ { maxActiveAgentsPerOwner: m.getMaxActiveAgentsPerOwnerCoordV2() },
1351
+ null,
1352
+ 2,
1353
+ ),
1354
+ );
1355
+ });
1356
+ cowork
1357
+ .command("coord-set-max-pending-assignments-v2 <n>")
1358
+ .description("Set max pending coord assignments per agent (V2)")
1359
+ .action(async (n) => {
1360
+ const m = await import("../lib/agent-coordinator.js");
1361
+ m.setMaxPendingAssignmentsPerAgentV2(parseInt(n, 10));
1362
+ console.log(
1363
+ JSON.stringify(
1364
+ {
1365
+ maxPendingAssignmentsPerAgent:
1366
+ m.getMaxPendingAssignmentsPerAgentV2(),
1367
+ },
1368
+ null,
1369
+ 2,
1370
+ ),
1371
+ );
1372
+ });
1373
+ cowork
1374
+ .command("coord-set-agent-idle-ms-v2 <n>")
1375
+ .description("Set coord agent idle timeout ms (V2)")
1376
+ .action(async (n) => {
1377
+ const m = await import("../lib/agent-coordinator.js");
1378
+ m.setAgentIdleMsCoordV2(parseInt(n, 10));
1379
+ console.log(
1380
+ JSON.stringify({ agentIdleMs: m.getAgentIdleMsCoordV2() }, null, 2),
1381
+ );
1382
+ });
1383
+ cowork
1384
+ .command("coord-set-assignment-stuck-ms-v2 <n>")
1385
+ .description("Set coord assignment stuck timeout ms (V2)")
1386
+ .action(async (n) => {
1387
+ const m = await import("../lib/agent-coordinator.js");
1388
+ m.setAssignmentStuckMsV2(parseInt(n, 10));
1389
+ console.log(
1390
+ JSON.stringify(
1391
+ { assignmentStuckMs: m.getAssignmentStuckMsV2() },
1392
+ null,
1393
+ 2,
1394
+ ),
1395
+ );
1396
+ });
1397
+ cowork
1398
+ .command("coord-reset-state-v2")
1399
+ .description("Reset agent-coordinator V2 in-memory state")
1400
+ .action(async () => {
1401
+ const m = await import("../lib/agent-coordinator.js");
1402
+ m._resetStateAgentCoordinatorV2();
1403
+ console.log(JSON.stringify({ ok: true }, null, 2));
1404
+ });
1184
1405
  }
@@ -27,8 +27,53 @@ import {
27
27
  getSuggestion,
28
28
  applySuggestion,
29
29
  getDbEvoStats,
30
+
31
+ // Phase 80 V2
32
+ SCHEMA_BASELINE_V2,
33
+ MIGRATION_RUN_V2,
34
+ getDefaultMaxActiveBaselinesPerDbV2,
35
+ getMaxActiveBaselinesPerDbV2,
36
+ setMaxActiveBaselinesPerDbV2,
37
+ getDefaultMaxRunningMigrationsPerDbV2,
38
+ getMaxRunningMigrationsPerDbV2,
39
+ setMaxRunningMigrationsPerDbV2,
40
+ getDefaultBaselineIdleMsV2,
41
+ getBaselineIdleMsV2,
42
+ setBaselineIdleMsV2,
43
+ getDefaultMigrationStuckMsV2,
44
+ getMigrationStuckMsV2,
45
+ setMigrationStuckMsV2,
46
+ registerBaselineV2,
47
+ getBaselineV2,
48
+ setBaselineStatusV2,
49
+ validateBaseline,
50
+ activateBaseline,
51
+ deprecateBaseline,
52
+ retireBaseline,
53
+ touchBaselineActivity,
54
+ enqueueMigrationRunV2,
55
+ getMigrationRunV2,
56
+ setMigrationRunStatusV2,
57
+ startMigrationRun,
58
+ applyMigrationRun,
59
+ failMigrationRun,
60
+ rollbackMigrationRun,
61
+ getActiveBaselineCount,
62
+ getRunningMigrationCount,
63
+ autoRetireIdleBaselines,
64
+ autoFailStuckMigrationRuns,
65
+ getDbEvoStatsV2,
30
66
  } from "../lib/dbevo.js";
31
67
 
68
+ function _parseMetaV2(raw) {
69
+ if (!raw) return undefined;
70
+ try {
71
+ return JSON.parse(raw);
72
+ } catch {
73
+ throw new Error("--metadata must be valid JSON");
74
+ }
75
+ }
76
+
32
77
  function _dbFromCtx(cmd) {
33
78
  const root = cmd?.parent?.parent ?? cmd?.parent;
34
79
  return root?._db;
@@ -384,5 +429,244 @@ export function registerDbEvoCommand(program) {
384
429
  );
385
430
  });
386
431
 
432
+ /* ═══════════════════════════════════════════════════ *
433
+ * Phase 80 V2 — Schema Baseline + Migration Run
434
+ * ═══════════════════════════════════════════════════ */
435
+
436
+ dbevo
437
+ .command("schema-baselines-v2")
438
+ .description("List V2 baseline states")
439
+ .option("--json", "JSON output")
440
+ .action((opts) => {
441
+ const xs = Object.values(SCHEMA_BASELINE_V2);
442
+ if (opts.json) return console.log(JSON.stringify(xs, null, 2));
443
+ for (const x of xs) console.log(` ${x}`);
444
+ });
445
+
446
+ dbevo
447
+ .command("migration-runs-v2")
448
+ .description("List V2 migration-run states")
449
+ .option("--json", "JSON output")
450
+ .action((opts) => {
451
+ const xs = Object.values(MIGRATION_RUN_V2);
452
+ if (opts.json) return console.log(JSON.stringify(xs, null, 2));
453
+ for (const x of xs) console.log(` ${x}`);
454
+ });
455
+
456
+ dbevo
457
+ .command("default-max-active-baselines-per-db")
458
+ .description("Default active-baseline cap")
459
+ .action(() => console.log(getDefaultMaxActiveBaselinesPerDbV2()));
460
+ dbevo
461
+ .command("max-active-baselines-per-db")
462
+ .description("Current active-baseline cap")
463
+ .action(() => console.log(getMaxActiveBaselinesPerDbV2()));
464
+ dbevo
465
+ .command("set-max-active-baselines-per-db <n>")
466
+ .description("Set active-baseline cap")
467
+ .action((n) => console.log(setMaxActiveBaselinesPerDbV2(n)));
468
+
469
+ dbevo
470
+ .command("default-max-running-migrations-per-db")
471
+ .description("Default running-migration cap")
472
+ .action(() => console.log(getDefaultMaxRunningMigrationsPerDbV2()));
473
+ dbevo
474
+ .command("max-running-migrations-per-db")
475
+ .description("Current running-migration cap")
476
+ .action(() => console.log(getMaxRunningMigrationsPerDbV2()));
477
+ dbevo
478
+ .command("set-max-running-migrations-per-db <n>")
479
+ .description("Set running-migration cap")
480
+ .action((n) => console.log(setMaxRunningMigrationsPerDbV2(n)));
481
+
482
+ dbevo
483
+ .command("default-baseline-idle-ms")
484
+ .description("Default baseline idle ms")
485
+ .action(() => console.log(getDefaultBaselineIdleMsV2()));
486
+ dbevo
487
+ .command("baseline-idle-ms")
488
+ .description("Current baseline idle ms")
489
+ .action(() => console.log(getBaselineIdleMsV2()));
490
+ dbevo
491
+ .command("set-baseline-idle-ms <ms>")
492
+ .description("Set baseline idle ms")
493
+ .action((ms) => console.log(setBaselineIdleMsV2(ms)));
494
+
495
+ dbevo
496
+ .command("default-migration-stuck-ms")
497
+ .description("Default migration stuck ms")
498
+ .action(() => console.log(getDefaultMigrationStuckMsV2()));
499
+ dbevo
500
+ .command("migration-stuck-ms")
501
+ .description("Current migration stuck ms")
502
+ .action(() => console.log(getMigrationStuckMsV2()));
503
+ dbevo
504
+ .command("set-migration-stuck-ms <ms>")
505
+ .description("Set migration stuck ms")
506
+ .action((ms) => console.log(setMigrationStuckMsV2(ms)));
507
+
508
+ dbevo
509
+ .command("active-baseline-count")
510
+ .description("Count of ACTIVE baselines")
511
+ .option("-d, --database <id>", "filter by database")
512
+ .action((opts) => console.log(getActiveBaselineCount(opts.database)));
513
+
514
+ dbevo
515
+ .command("running-migration-count")
516
+ .description("Count of RUNNING migration runs")
517
+ .option("-d, --database <id>", "filter by database")
518
+ .action((opts) => console.log(getRunningMigrationCount(opts.database)));
519
+
520
+ // ── Baseline CRUD ──────────────────────────────────
521
+
522
+ dbevo
523
+ .command("register-baseline-v2 <baseline-id>")
524
+ .description("Register a V2 baseline")
525
+ .requiredOption("-d, --database <id>", "database id")
526
+ .requiredOption("-v, --version <ver>", "schema version")
527
+ .option("-i, --initial-status <s>", "initial status")
528
+ .option("--metadata <json>", "metadata JSON")
529
+ .action((id, opts) => {
530
+ const r = registerBaselineV2(null, {
531
+ baselineId: id,
532
+ databaseId: opts.database,
533
+ version: opts.version,
534
+ initialStatus: opts.initialStatus,
535
+ metadata: _parseMetaV2(opts.metadata),
536
+ });
537
+ console.log(JSON.stringify(r, null, 2));
538
+ });
539
+
540
+ dbevo
541
+ .command("baseline-v2 <baseline-id>")
542
+ .description("Get a V2 baseline")
543
+ .action((id) => {
544
+ const r = getBaselineV2(id);
545
+ if (!r) {
546
+ console.error(`Unknown baseline: ${id}`);
547
+ process.exitCode = 1;
548
+ return;
549
+ }
550
+ console.log(JSON.stringify(r, null, 2));
551
+ });
552
+
553
+ dbevo
554
+ .command("set-baseline-status-v2 <baseline-id> <status>")
555
+ .description("Transition baseline status")
556
+ .option("-r, --reason <text>", "reason")
557
+ .option("--metadata <json>", "metadata JSON")
558
+ .action((id, status, opts) => {
559
+ const r = setBaselineStatusV2(null, id, status, {
560
+ reason: opts.reason,
561
+ metadata: _parseMetaV2(opts.metadata),
562
+ });
563
+ console.log(JSON.stringify(r, null, 2));
564
+ });
565
+
566
+ for (const [name, fn] of [
567
+ ["validate-baseline", validateBaseline],
568
+ ["activate-baseline", activateBaseline],
569
+ ["deprecate-baseline", deprecateBaseline],
570
+ ["retire-baseline", retireBaseline],
571
+ ]) {
572
+ dbevo
573
+ .command(`${name} <baseline-id>`)
574
+ .description(`Transition baseline (${name})`)
575
+ .option("-r, --reason <text>", "reason")
576
+ .action((id, opts) => {
577
+ const r = fn(null, id, opts.reason);
578
+ console.log(JSON.stringify(r, null, 2));
579
+ });
580
+ }
581
+
582
+ dbevo
583
+ .command("touch-baseline-activity <baseline-id>")
584
+ .description("Bump lastTouchedAt")
585
+ .action((id) => {
586
+ const r = touchBaselineActivity(id);
587
+ console.log(JSON.stringify(r, null, 2));
588
+ });
589
+
590
+ // ── Migration Run CRUD ─────────────────────────────
591
+
592
+ dbevo
593
+ .command("enqueue-migration-run-v2 <run-id>")
594
+ .description("Enqueue a V2 migration run")
595
+ .requiredOption("-d, --database <id>", "database id")
596
+ .requiredOption("-m, --migration <id>", "migration id")
597
+ .requiredOption("--direction <up|down>", "direction")
598
+ .option("--metadata <json>", "metadata JSON")
599
+ .action((id, opts) => {
600
+ const r = enqueueMigrationRunV2(null, {
601
+ runId: id,
602
+ databaseId: opts.database,
603
+ migrationId: opts.migration,
604
+ direction: opts.direction,
605
+ metadata: _parseMetaV2(opts.metadata),
606
+ });
607
+ console.log(JSON.stringify(r, null, 2));
608
+ });
609
+
610
+ dbevo
611
+ .command("migration-run-v2 <run-id>")
612
+ .description("Get a V2 migration run")
613
+ .action((id) => {
614
+ const r = getMigrationRunV2(id);
615
+ if (!r) {
616
+ console.error(`Unknown run: ${id}`);
617
+ process.exitCode = 1;
618
+ return;
619
+ }
620
+ console.log(JSON.stringify(r, null, 2));
621
+ });
622
+
623
+ dbevo
624
+ .command("set-migration-run-status-v2 <run-id> <status>")
625
+ .description("Transition migration-run status")
626
+ .option("-r, --reason <text>", "reason")
627
+ .option("--metadata <json>", "metadata JSON")
628
+ .action((id, status, opts) => {
629
+ const r = setMigrationRunStatusV2(null, id, status, {
630
+ reason: opts.reason,
631
+ metadata: _parseMetaV2(opts.metadata),
632
+ });
633
+ console.log(JSON.stringify(r, null, 2));
634
+ });
635
+
636
+ for (const [name, fn] of [
637
+ ["start-migration-run", startMigrationRun],
638
+ ["apply-migration-run", applyMigrationRun],
639
+ ["fail-migration-run", failMigrationRun],
640
+ ["rollback-migration-run", rollbackMigrationRun],
641
+ ]) {
642
+ dbevo
643
+ .command(`${name} <run-id>`)
644
+ .description(`Transition migration run (${name})`)
645
+ .option("-r, --reason <text>", "reason")
646
+ .action((id, opts) => {
647
+ const r = fn(null, id, opts.reason);
648
+ console.log(JSON.stringify(r, null, 2));
649
+ });
650
+ }
651
+
652
+ dbevo
653
+ .command("auto-retire-idle-baselines")
654
+ .description("Flip idle draft/validated/deprecated → RETIRED")
655
+ .action(() =>
656
+ console.log(JSON.stringify(autoRetireIdleBaselines(null), null, 2)),
657
+ );
658
+
659
+ dbevo
660
+ .command("auto-fail-stuck-migration-runs")
661
+ .description("Flip stuck RUNNING → FAILED")
662
+ .action(() =>
663
+ console.log(JSON.stringify(autoFailStuckMigrationRuns(null), null, 2)),
664
+ );
665
+
666
+ dbevo
667
+ .command("stats-v2")
668
+ .description("V2 stats snapshot")
669
+ .action(() => console.log(JSON.stringify(getDbEvoStatsV2(), null, 2)));
670
+
387
671
  program.addCommand(dbevo);
388
672
  }