chainlesschain 0.66.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 (143) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/a2a.js +380 -0
  4. package/src/commands/agent-network.js +254 -1
  5. package/src/commands/audit.js +302 -0
  6. package/src/commands/automation.js +271 -1
  7. package/src/commands/bi.js +348 -0
  8. package/src/commands/codegen.js +224 -0
  9. package/src/commands/collab.js +341 -0
  10. package/src/commands/compliance.js +1035 -0
  11. package/src/commands/cowork.js +221 -0
  12. package/src/commands/crosschain.js +218 -0
  13. package/src/commands/dbevo.js +284 -0
  14. package/src/commands/dev.js +252 -0
  15. package/src/commands/did.js +358 -0
  16. package/src/commands/dlp.js +341 -0
  17. package/src/commands/encrypt.js +341 -0
  18. package/src/commands/evomap.js +394 -0
  19. package/src/commands/export.js +256 -1
  20. package/src/commands/federation.js +283 -0
  21. package/src/commands/fusion.js +258 -0
  22. package/src/commands/governance.js +325 -0
  23. package/src/commands/hardening.js +411 -0
  24. package/src/commands/hook.js +148 -0
  25. package/src/commands/import.js +252 -0
  26. package/src/commands/incentive.js +322 -0
  27. package/src/commands/inference.js +318 -0
  28. package/src/commands/infra.js +244 -0
  29. package/src/commands/instinct.js +260 -0
  30. package/src/commands/ipfs.js +318 -0
  31. package/src/commands/kg.js +387 -0
  32. package/src/commands/llm.js +263 -0
  33. package/src/commands/lowcode.js +356 -0
  34. package/src/commands/marketplace.js +256 -0
  35. package/src/commands/mcp.js +221 -0
  36. package/src/commands/memory.js +248 -0
  37. package/src/commands/multimodal.js +296 -0
  38. package/src/commands/nlprog.js +356 -0
  39. package/src/commands/note.js +244 -0
  40. package/src/commands/ops.js +354 -0
  41. package/src/commands/orchestrate.js +166 -0
  42. package/src/commands/org.js +277 -0
  43. package/src/commands/p2p.js +390 -0
  44. package/src/commands/perception.js +290 -0
  45. package/src/commands/permmem.js +251 -0
  46. package/src/commands/plugin-ecosystem.js +273 -0
  47. package/src/commands/pqc.js +393 -0
  48. package/src/commands/privacy.js +321 -0
  49. package/src/commands/quantization.js +351 -0
  50. package/src/commands/rcache.js +271 -0
  51. package/src/commands/recommend.js +340 -0
  52. package/src/commands/reputation.js +261 -0
  53. package/src/commands/runtime.js +307 -0
  54. package/src/commands/scim.js +262 -0
  55. package/src/commands/session.js +258 -0
  56. package/src/commands/siem.js +246 -0
  57. package/src/commands/skill.js +267 -1
  58. package/src/commands/sla.js +259 -0
  59. package/src/commands/social.js +256 -0
  60. package/src/commands/sso.js +186 -1
  61. package/src/commands/stress.js +230 -0
  62. package/src/commands/sync.js +256 -0
  63. package/src/commands/tech.js +338 -0
  64. package/src/commands/tenant.js +351 -0
  65. package/src/commands/terraform.js +245 -0
  66. package/src/commands/tokens.js +269 -0
  67. package/src/commands/trust.js +249 -0
  68. package/src/commands/wallet.js +277 -0
  69. package/src/commands/workflow.js +171 -0
  70. package/src/commands/zkp.js +335 -0
  71. package/src/index.js +4 -0
  72. package/src/lib/a2a-protocol.js +451 -0
  73. package/src/lib/agent-coordinator.js +325 -0
  74. package/src/lib/agent-network.js +387 -0
  75. package/src/lib/agent-router.js +395 -0
  76. package/src/lib/aiops.js +478 -0
  77. package/src/lib/app-builder.js +239 -0
  78. package/src/lib/audit-logger.js +379 -0
  79. package/src/lib/automation-engine.js +330 -0
  80. package/src/lib/autonomous-developer.js +350 -0
  81. package/src/lib/bi-engine.js +338 -0
  82. package/src/lib/code-agent.js +323 -0
  83. package/src/lib/collaboration-governance.js +364 -0
  84. package/src/lib/community-governance.js +436 -0
  85. package/src/lib/compliance-manager.js +434 -0
  86. package/src/lib/content-recommendation.js +469 -0
  87. package/src/lib/cross-chain.js +345 -0
  88. package/src/lib/crypto-manager.js +350 -0
  89. package/src/lib/dbevo.js +338 -0
  90. package/src/lib/decentral-infra.js +340 -0
  91. package/src/lib/did-manager.js +367 -0
  92. package/src/lib/dlp-engine.js +389 -0
  93. package/src/lib/evomap-federation.js +177 -0
  94. package/src/lib/evomap-governance.js +276 -0
  95. package/src/lib/federation-hardening.js +259 -0
  96. package/src/lib/hardening-manager.js +348 -0
  97. package/src/lib/hook-manager.js +380 -0
  98. package/src/lib/inference-network.js +330 -0
  99. package/src/lib/instinct-manager.js +332 -0
  100. package/src/lib/ipfs-storage.js +334 -0
  101. package/src/lib/knowledge-exporter.js +381 -0
  102. package/src/lib/knowledge-graph.js +432 -0
  103. package/src/lib/knowledge-importer.js +379 -0
  104. package/src/lib/llm-providers.js +391 -0
  105. package/src/lib/mcp-registry.js +333 -0
  106. package/src/lib/memory-manager.js +330 -0
  107. package/src/lib/multimodal.js +346 -0
  108. package/src/lib/nl-programming.js +343 -0
  109. package/src/lib/note-versioning.js +327 -0
  110. package/src/lib/org-manager.js +323 -0
  111. package/src/lib/p2p-manager.js +387 -0
  112. package/src/lib/perception.js +346 -0
  113. package/src/lib/perf-tuning.js +4 -1
  114. package/src/lib/permanent-memory.js +320 -0
  115. package/src/lib/plugin-ecosystem.js +377 -0
  116. package/src/lib/pqc-manager.js +368 -0
  117. package/src/lib/privacy-computing.js +427 -0
  118. package/src/lib/protocol-fusion.js +417 -0
  119. package/src/lib/quantization.js +325 -0
  120. package/src/lib/reputation-optimizer.js +299 -0
  121. package/src/lib/response-cache.js +327 -0
  122. package/src/lib/scim-manager.js +329 -0
  123. package/src/lib/session-manager.js +329 -0
  124. package/src/lib/siem-exporter.js +333 -0
  125. package/src/lib/skill-loader.js +377 -0
  126. package/src/lib/skill-marketplace.js +325 -0
  127. package/src/lib/sla-manager.js +275 -0
  128. package/src/lib/social-manager.js +326 -0
  129. package/src/lib/sso-manager.js +332 -0
  130. package/src/lib/stress-tester.js +330 -0
  131. package/src/lib/sync-manager.js +326 -0
  132. package/src/lib/tech-learning-engine.js +369 -0
  133. package/src/lib/tenant-saas.js +460 -0
  134. package/src/lib/terraform-manager.js +363 -0
  135. package/src/lib/threat-intel.js +335 -0
  136. package/src/lib/token-incentive.js +293 -0
  137. package/src/lib/token-tracker.js +329 -0
  138. package/src/lib/trust-security.js +390 -0
  139. package/src/lib/ueba.js +389 -0
  140. package/src/lib/universal-runtime.js +325 -0
  141. package/src/lib/wallet-manager.js +326 -0
  142. package/src/lib/workflow-engine.js +322 -0
  143. package/src/lib/zkp-engine.js +274 -0
@@ -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
  }
@@ -25,8 +25,47 @@ import {
25
25
  listADRs,
26
26
  renderADR,
27
27
  AUTONOMY_LEVELS,
28
+ ADR_MATURITY_V2,
29
+ DEV_SESSION_V2,
30
+ getMaxActiveAdrsPerAuthor,
31
+ setMaxActiveAdrsPerAuthor,
32
+ getMaxRunningSessionsPerDeveloper,
33
+ setMaxRunningSessionsPerDeveloper,
34
+ getAdrStaleMs,
35
+ setAdrStaleMs,
36
+ getSessionStuckMs,
37
+ setSessionStuckMs,
38
+ getActiveAdrCount,
39
+ getRunningSessionCount,
40
+ createAdrV2,
41
+ getAdrV2,
42
+ listAdrsV2,
43
+ setAdrMaturityV2,
44
+ acceptAdr,
45
+ deprecateAdr,
46
+ supersedeAdr,
47
+ enqueueSessionV2,
48
+ getSessionV2,
49
+ listSessionsV2,
50
+ setSessionStatusV2,
51
+ startSessionV2,
52
+ completeSessionV2,
53
+ failSessionV2,
54
+ cancelSessionV2,
55
+ autoSupersedeStaleDrafts,
56
+ autoFailStuckSessions,
57
+ getAutonomousDeveloperStatsV2,
28
58
  } from "../lib/autonomous-developer.js";
29
59
 
60
+ function _parseJsonV2(s) {
61
+ if (!s) return undefined;
62
+ try {
63
+ return JSON.parse(s);
64
+ } catch {
65
+ throw new Error(`invalid JSON: ${s}`);
66
+ }
67
+ }
68
+
30
69
  function _dbFromCtx(ctx) {
31
70
  if (!ctx.db) {
32
71
  logger.error("Database not available");
@@ -408,4 +447,217 @@ export function registerDevCommand(program) {
408
447
 
409
448
  // silence unused import lints (AUTONOMY_LEVELS re-exported for consumers)
410
449
  void AUTONOMY_LEVELS;
450
+
451
+ /* ── V2 Surface (Autonomous Developer) ─────────────────── */
452
+
453
+ dev
454
+ .command("adr-maturities-v2")
455
+ .description("List ADR_MATURITY_V2 enum")
456
+ .action(() => {
457
+ for (const v of Object.values(ADR_MATURITY_V2)) console.log(` ${v}`);
458
+ });
459
+
460
+ dev
461
+ .command("dev-sessions-v2")
462
+ .description("List DEV_SESSION_V2 enum")
463
+ .action(() => {
464
+ for (const v of Object.values(DEV_SESSION_V2)) console.log(` ${v}`);
465
+ });
466
+
467
+ dev
468
+ .command("max-active-adrs-per-author")
469
+ .description("Get max-active-adrs-per-author cap")
470
+ .action(() => console.log(getMaxActiveAdrsPerAuthor()));
471
+ dev
472
+ .command("set-max-active-adrs-per-author <n>")
473
+ .action((n) => console.log(setMaxActiveAdrsPerAuthor(Number(n))));
474
+
475
+ dev
476
+ .command("max-running-sessions-per-developer")
477
+ .description("Get max-running-sessions-per-developer cap")
478
+ .action(() => console.log(getMaxRunningSessionsPerDeveloper()));
479
+ dev
480
+ .command("set-max-running-sessions-per-developer <n>")
481
+ .action((n) => console.log(setMaxRunningSessionsPerDeveloper(Number(n))));
482
+
483
+ dev
484
+ .command("adr-stale-ms")
485
+ .description("Get adr-stale-ms threshold")
486
+ .action(() => console.log(getAdrStaleMs()));
487
+ dev
488
+ .command("set-adr-stale-ms <n>")
489
+ .action((n) => console.log(setAdrStaleMs(Number(n))));
490
+
491
+ dev
492
+ .command("session-stuck-ms")
493
+ .description("Get session-stuck-ms threshold")
494
+ .action(() => console.log(getSessionStuckMs()));
495
+ dev
496
+ .command("set-session-stuck-ms <n>")
497
+ .action((n) => console.log(setSessionStuckMs(Number(n))));
498
+
499
+ dev
500
+ .command("active-adr-count")
501
+ .description("Count non-superseded ADRs (optionally by author)")
502
+ .option("-a, --author <author>")
503
+ .action((opts) => console.log(getActiveAdrCount(opts.author)));
504
+
505
+ dev
506
+ .command("running-session-count")
507
+ .description("Count RUNNING sessions (optionally by developer)")
508
+ .option("-d, --developer <developer>")
509
+ .action((opts) => console.log(getRunningSessionCount(opts.developer)));
510
+
511
+ dev
512
+ .command("create-adr-v2 <adr-id>")
513
+ .description("Create V2 ADR")
514
+ .requiredOption("-a, --author <author>", "author")
515
+ .requiredOption("-t, --title <title>", "title")
516
+ .option("-i, --initial <status>", "initial status", ADR_MATURITY_V2.DRAFT)
517
+ .option("--metadata <json>", "metadata JSON")
518
+ .action((id, opts) => {
519
+ const a = createAdrV2({
520
+ id,
521
+ author: opts.author,
522
+ title: opts.title,
523
+ initialStatus: opts.initial,
524
+ metadata: _parseJsonV2(opts.metadata),
525
+ });
526
+ console.log(JSON.stringify(a, null, 2));
527
+ });
528
+
529
+ dev
530
+ .command("adr-v2 <adr-id>")
531
+ .description("Show V2 ADR")
532
+ .action((id) => {
533
+ const a = getAdrV2(id);
534
+ if (!a) return console.error(`ADR ${id} not found`);
535
+ console.log(JSON.stringify(a, null, 2));
536
+ });
537
+
538
+ dev
539
+ .command("list-adrs-v2")
540
+ .description("List V2 ADRs")
541
+ .option("-a, --author <author>")
542
+ .option("-s, --status <status>")
543
+ .action((opts) => console.log(JSON.stringify(listAdrsV2(opts), null, 2)));
544
+
545
+ dev
546
+ .command("set-adr-maturity-v2 <adr-id> <status>")
547
+ .description("Transition V2 ADR maturity")
548
+ .option("-r, --reason <reason>")
549
+ .option("--metadata <json>")
550
+ .action((id, status, opts) => {
551
+ const a = setAdrMaturityV2(id, status, {
552
+ reason: opts.reason,
553
+ metadata: _parseJsonV2(opts.metadata),
554
+ });
555
+ console.log(JSON.stringify(a, null, 2));
556
+ });
557
+
558
+ for (const [name, fn] of [
559
+ ["accept-adr", acceptAdr],
560
+ ["deprecate-adr", deprecateAdr],
561
+ ["supersede-adr", supersedeAdr],
562
+ ]) {
563
+ dev
564
+ .command(`${name} <adr-id>`)
565
+ .description(`Shortcut for ${name.replace("-adr", "")} transition`)
566
+ .option("-r, --reason <reason>")
567
+ .action((id, opts) => {
568
+ const a = fn(id, { reason: opts.reason });
569
+ console.log(JSON.stringify(a, null, 2));
570
+ });
571
+ }
572
+
573
+ dev
574
+ .command("enqueue-session-v2 <session-id>")
575
+ .description("Enqueue V2 dev session")
576
+ .requiredOption("-d, --developer <developer>")
577
+ .requiredOption("-g, --goal <goal>")
578
+ .option("--metadata <json>")
579
+ .action((id, opts) => {
580
+ const s = enqueueSessionV2({
581
+ id,
582
+ developer: opts.developer,
583
+ goal: opts.goal,
584
+ metadata: _parseJsonV2(opts.metadata),
585
+ });
586
+ console.log(JSON.stringify(s, null, 2));
587
+ });
588
+
589
+ dev
590
+ .command("session-v2 <session-id>")
591
+ .description("Show V2 session")
592
+ .action((id) => {
593
+ const s = getSessionV2(id);
594
+ if (!s) return console.error(`session ${id} not found`);
595
+ console.log(JSON.stringify(s, null, 2));
596
+ });
597
+
598
+ dev
599
+ .command("list-sessions-v2")
600
+ .description("List V2 sessions")
601
+ .option("-d, --developer <developer>")
602
+ .option("-s, --status <status>")
603
+ .action((opts) =>
604
+ console.log(JSON.stringify(listSessionsV2(opts), null, 2)),
605
+ );
606
+
607
+ dev
608
+ .command("set-session-status-v2 <session-id> <status>")
609
+ .option("-r, --reason <reason>")
610
+ .option("--metadata <json>")
611
+ .action((id, status, opts) => {
612
+ const s = setSessionStatusV2(id, status, {
613
+ reason: opts.reason,
614
+ metadata: _parseJsonV2(opts.metadata),
615
+ });
616
+ console.log(JSON.stringify(s, null, 2));
617
+ });
618
+
619
+ for (const [name, fn] of [
620
+ ["start-session-v2", startSessionV2],
621
+ ["complete-session-v2", completeSessionV2],
622
+ ["fail-session-v2", failSessionV2],
623
+ ["cancel-session-v2", cancelSessionV2],
624
+ ]) {
625
+ dev
626
+ .command(`${name} <session-id>`)
627
+ .description(`Shortcut for ${name.replace("-session-v2", "")} transition`)
628
+ .option("-r, --reason <reason>")
629
+ .action((id, opts) => {
630
+ const s = fn(id, { reason: opts.reason });
631
+ console.log(JSON.stringify(s, null, 2));
632
+ });
633
+ }
634
+
635
+ dev
636
+ .command("auto-supersede-stale-drafts")
637
+ .description(
638
+ "Bulk-supersede DRAFT ADRs whose updatedAt is older than adrStaleMs",
639
+ )
640
+ .action(() =>
641
+ console.log(
642
+ JSON.stringify({ flipped: autoSupersedeStaleDrafts() }, null, 2),
643
+ ),
644
+ );
645
+
646
+ dev
647
+ .command("auto-fail-stuck-sessions")
648
+ .description(
649
+ "Bulk-fail RUNNING sessions whose startedAt is older than sessionStuckMs",
650
+ )
651
+ .action(() =>
652
+ console.log(
653
+ JSON.stringify({ flipped: autoFailStuckSessions() }, null, 2),
654
+ ),
655
+ );
656
+
657
+ dev
658
+ .command("stats-v2")
659
+ .description("Show V2 autonomous-developer stats")
660
+ .action(() =>
661
+ console.log(JSON.stringify(getAutonomousDeveloperStatsV2(), null, 2)),
662
+ );
411
663
  }