chainlesschain 0.81.0 → 0.143.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 (209) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/a2a.js +62 -0
  4. package/src/commands/activitypub.js +61 -0
  5. package/src/commands/agent-network.js +254 -1
  6. package/src/commands/agent.js +117 -0
  7. package/src/commands/audit.js +302 -0
  8. package/src/commands/automation.js +271 -1
  9. package/src/commands/bi.js +61 -0
  10. package/src/commands/bm25.js +78 -0
  11. package/src/commands/browse.js +64 -0
  12. package/src/commands/ccron.js +78 -0
  13. package/src/commands/codegen.js +224 -0
  14. package/src/commands/collab.js +341 -0
  15. package/src/commands/compliance.js +1075 -0
  16. package/src/commands/compt.js +78 -0
  17. package/src/commands/consol.js +231 -0
  18. package/src/commands/cowork.js +263 -0
  19. package/src/commands/crosschain.js +62 -0
  20. package/src/commands/dao.js +62 -0
  21. package/src/commands/dbevo.js +284 -0
  22. package/src/commands/dev.js +252 -0
  23. package/src/commands/did.js +358 -0
  24. package/src/commands/dlp.js +61 -0
  25. package/src/commands/economy.js +56 -0
  26. package/src/commands/encrypt.js +341 -0
  27. package/src/commands/evolution.js +56 -0
  28. package/src/commands/evomap.js +61 -0
  29. package/src/commands/export.js +256 -1
  30. package/src/commands/fflag.js +178 -0
  31. package/src/commands/fusion.js +258 -0
  32. package/src/commands/git.js +45 -0
  33. package/src/commands/governance.js +325 -0
  34. package/src/commands/hardening.js +411 -0
  35. package/src/commands/hmemory.js +56 -0
  36. package/src/commands/hook.js +148 -0
  37. package/src/commands/import.js +252 -0
  38. package/src/commands/incentive.js +322 -0
  39. package/src/commands/inference.js +42 -0
  40. package/src/commands/infra.js +244 -0
  41. package/src/commands/instinct.js +260 -0
  42. package/src/commands/ipfs.js +318 -0
  43. package/src/commands/itbudget.js +45 -0
  44. package/src/commands/kg.js +387 -0
  45. package/src/commands/llm.js +263 -0
  46. package/src/commands/lowcode.js +44 -0
  47. package/src/commands/matrix.js +62 -0
  48. package/src/commands/mcp.js +221 -0
  49. package/src/commands/mcpscaf.js +41 -0
  50. package/src/commands/meminj.js +41 -0
  51. package/src/commands/memory.js +248 -0
  52. package/src/commands/multimodal.js +296 -0
  53. package/src/commands/nlprog.js +356 -0
  54. package/src/commands/nostr.js +62 -0
  55. package/src/commands/note.js +244 -0
  56. package/src/commands/ops.js +354 -0
  57. package/src/commands/orchestrate.js +166 -0
  58. package/src/commands/orchgov.js +45 -0
  59. package/src/commands/org.js +277 -0
  60. package/src/commands/p2p.js +390 -0
  61. package/src/commands/pdfp.js +78 -0
  62. package/src/commands/perception.js +290 -0
  63. package/src/commands/perf.js +39 -0
  64. package/src/commands/perm.js +45 -0
  65. package/src/commands/permmem.js +251 -0
  66. package/src/commands/pipeline.js +57 -1
  67. package/src/commands/planmode.js +45 -0
  68. package/src/commands/plugin-ecosystem.js +273 -0
  69. package/src/commands/pqc.js +393 -0
  70. package/src/commands/promcomp.js +82 -0
  71. package/src/commands/quantization.js +351 -0
  72. package/src/commands/rcache.js +271 -0
  73. package/src/commands/recommend.js +382 -0
  74. package/src/commands/runtime.js +307 -0
  75. package/src/commands/scim.js +262 -0
  76. package/src/commands/seshhook.js +41 -0
  77. package/src/commands/seshsearch.js +41 -0
  78. package/src/commands/seshtail.js +41 -0
  79. package/src/commands/seshu.js +41 -0
  80. package/src/commands/session.js +258 -0
  81. package/src/commands/sganal.js +78 -0
  82. package/src/commands/siem.js +40 -0
  83. package/src/commands/skill.js +267 -1
  84. package/src/commands/slotfill.js +41 -0
  85. package/src/commands/social.js +290 -0
  86. package/src/commands/sso.js +186 -1
  87. package/src/commands/svccont.js +45 -0
  88. package/src/commands/sync.js +256 -0
  89. package/src/commands/tech.js +338 -0
  90. package/src/commands/tenant.js +351 -0
  91. package/src/commands/tms.js +45 -0
  92. package/src/commands/tokens.js +269 -0
  93. package/src/commands/topiccls.js +45 -0
  94. package/src/commands/trust.js +249 -0
  95. package/src/commands/uprof.js +45 -0
  96. package/src/commands/vcheck.js +78 -0
  97. package/src/commands/wallet.js +277 -0
  98. package/src/commands/webfetch.js +41 -0
  99. package/src/commands/workflow.js +171 -0
  100. package/src/commands/zkp.js +62 -0
  101. package/src/harness/prompt-compressor.js +331 -0
  102. package/src/index.js +65 -1
  103. package/src/lib/a2a-protocol.js +105 -0
  104. package/src/lib/activitypub-bridge.js +105 -0
  105. package/src/lib/agent-coordinator.js +325 -0
  106. package/src/lib/agent-economy.js +105 -0
  107. package/src/lib/agent-network.js +387 -0
  108. package/src/lib/agent-router.js +395 -0
  109. package/src/lib/aiops.js +478 -0
  110. package/src/lib/app-builder.js +105 -0
  111. package/src/lib/audit-logger.js +379 -0
  112. package/src/lib/automation-engine.js +330 -0
  113. package/src/lib/autonomous-agent.js +105 -0
  114. package/src/lib/autonomous-developer.js +350 -0
  115. package/src/lib/bi-engine.js +105 -0
  116. package/src/lib/bm25-search.js +81 -0
  117. package/src/lib/browser-automation.js +105 -0
  118. package/src/lib/code-agent.js +323 -0
  119. package/src/lib/collaboration-governance.js +364 -0
  120. package/src/lib/community-governance.js +436 -0
  121. package/src/lib/compliance-framework-reporter.js +105 -0
  122. package/src/lib/compliance-manager.js +434 -0
  123. package/src/lib/compression-telemetry.js +81 -0
  124. package/src/lib/content-recommendation.js +469 -0
  125. package/src/lib/content-recommender.js +105 -0
  126. package/src/lib/cowork-cron.js +81 -0
  127. package/src/lib/cowork-task-runner.js +105 -0
  128. package/src/lib/cross-chain.js +105 -0
  129. package/src/lib/crypto-manager.js +350 -0
  130. package/src/lib/dao-governance.js +105 -0
  131. package/src/lib/dbevo.js +338 -0
  132. package/src/lib/decentral-infra.js +340 -0
  133. package/src/lib/did-manager.js +367 -0
  134. package/src/lib/dlp-engine.js +105 -0
  135. package/src/lib/evolution-system.js +105 -0
  136. package/src/lib/evomap-manager.js +105 -0
  137. package/src/lib/execution-backend.js +105 -0
  138. package/src/lib/feature-flags.js +85 -0
  139. package/src/lib/git-integration.js +105 -0
  140. package/src/lib/hardening-manager.js +348 -0
  141. package/src/lib/hierarchical-memory.js +105 -0
  142. package/src/lib/hook-manager.js +380 -0
  143. package/src/lib/inference-network.js +105 -0
  144. package/src/lib/instinct-manager.js +332 -0
  145. package/src/lib/ipfs-storage.js +334 -0
  146. package/src/lib/iteration-budget.js +105 -0
  147. package/src/lib/knowledge-exporter.js +381 -0
  148. package/src/lib/knowledge-graph.js +432 -0
  149. package/src/lib/knowledge-importer.js +379 -0
  150. package/src/lib/llm-providers.js +391 -0
  151. package/src/lib/matrix-bridge.js +105 -0
  152. package/src/lib/mcp-registry.js +333 -0
  153. package/src/lib/mcp-scaffold.js +81 -0
  154. package/src/lib/memory-injection.js +81 -0
  155. package/src/lib/memory-manager.js +330 -0
  156. package/src/lib/multimodal.js +346 -0
  157. package/src/lib/nl-programming.js +343 -0
  158. package/src/lib/nostr-bridge.js +105 -0
  159. package/src/lib/note-versioning.js +327 -0
  160. package/src/lib/orchestrator.js +105 -0
  161. package/src/lib/org-manager.js +323 -0
  162. package/src/lib/p2p-manager.js +387 -0
  163. package/src/lib/pdf-parser.js +81 -0
  164. package/src/lib/perception.js +346 -0
  165. package/src/lib/perf-tuning.js +109 -1
  166. package/src/lib/permanent-memory.js +320 -0
  167. package/src/lib/permission-engine.js +81 -0
  168. package/src/lib/pipeline-orchestrator.js +105 -0
  169. package/src/lib/plan-mode.js +81 -0
  170. package/src/lib/plugin-ecosystem.js +377 -0
  171. package/src/lib/pqc-manager.js +368 -0
  172. package/src/lib/prompt-compressor.js +1 -10
  173. package/src/lib/protocol-fusion.js +417 -0
  174. package/src/lib/quantization.js +325 -0
  175. package/src/lib/response-cache.js +327 -0
  176. package/src/lib/scim-manager.js +329 -0
  177. package/src/lib/service-container.js +81 -0
  178. package/src/lib/session-consolidator.js +105 -0
  179. package/src/lib/session-hooks.js +81 -0
  180. package/src/lib/session-manager.js +329 -0
  181. package/src/lib/session-search.js +81 -0
  182. package/src/lib/session-tail.js +81 -0
  183. package/src/lib/session-usage.js +83 -0
  184. package/src/lib/siem-exporter.js +105 -0
  185. package/src/lib/skill-loader.js +377 -0
  186. package/src/lib/slot-filler.js +81 -0
  187. package/src/lib/social-graph-analytics.js +81 -0
  188. package/src/lib/social-graph.js +81 -0
  189. package/src/lib/social-manager.js +326 -0
  190. package/src/lib/sso-manager.js +332 -0
  191. package/src/lib/sub-agent-registry.js +110 -0
  192. package/src/lib/sync-manager.js +326 -0
  193. package/src/lib/task-model-selector.js +81 -0
  194. package/src/lib/tech-learning-engine.js +369 -0
  195. package/src/lib/tenant-saas.js +460 -0
  196. package/src/lib/threat-intel.js +335 -0
  197. package/src/lib/todo-manager.js +105 -0
  198. package/src/lib/token-incentive.js +293 -0
  199. package/src/lib/token-tracker.js +329 -0
  200. package/src/lib/topic-classifier.js +105 -0
  201. package/src/lib/trust-security.js +390 -0
  202. package/src/lib/ueba.js +389 -0
  203. package/src/lib/universal-runtime.js +325 -0
  204. package/src/lib/user-profile.js +81 -0
  205. package/src/lib/version-checker.js +81 -0
  206. package/src/lib/wallet-manager.js +326 -0
  207. package/src/lib/web-fetch.js +81 -0
  208. package/src/lib/workflow-engine.js +322 -0
  209. package/src/lib/zkp-engine.js +105 -0
@@ -24,8 +24,51 @@ import {
24
24
  listConventions,
25
25
  removeConvention,
26
26
  getNlProgrammingStats,
27
+ /* V2 (Phase 28) */
28
+ SPEC_MATURITY_V2,
29
+ DIALOGUE_TURN_V2,
30
+ getDefaultMaxActiveSpecsPerAuthorV2,
31
+ getMaxActiveSpecsPerAuthorV2,
32
+ setMaxActiveSpecsPerAuthorV2,
33
+ getDefaultMaxPendingTurnsPerSpecV2,
34
+ getMaxPendingTurnsPerSpecV2,
35
+ setMaxPendingTurnsPerSpecV2,
36
+ getDefaultSpecIdleMsV2,
37
+ getSpecIdleMsV2,
38
+ setSpecIdleMsV2,
39
+ getDefaultTurnPendingMsV2,
40
+ getTurnPendingMsV2,
41
+ setTurnPendingMsV2,
42
+ registerSpecV2,
43
+ getSpecV2,
44
+ setSpecMaturityV2,
45
+ refineSpec,
46
+ approveSpec,
47
+ implementSpec,
48
+ archiveSpec,
49
+ touchSpecActivity,
50
+ registerDialogueTurnV2,
51
+ getDialogueTurnV2,
52
+ setDialogueTurnStatusV2,
53
+ answerTurn,
54
+ dismissTurn,
55
+ escalateTurn,
56
+ getActiveSpecCount,
57
+ getPendingTurnCount,
58
+ autoArchiveIdleSpecs,
59
+ autoDismissStalePendingTurns,
60
+ getNlProgrammingStatsV2,
27
61
  } from "../lib/nl-programming.js";
28
62
 
63
+ function _parseMetaV2(s) {
64
+ if (!s) return undefined;
65
+ try {
66
+ return JSON.parse(s);
67
+ } catch {
68
+ throw new Error(`--metadata must be valid JSON`);
69
+ }
70
+ }
71
+
29
72
  function _dbFromCtx(cmd) {
30
73
  const root = cmd?.parent?.parent ?? cmd?.parent;
31
74
  return root?._db;
@@ -325,5 +368,318 @@ export function registerNlProgCommand(program) {
325
368
  }
326
369
  });
327
370
 
371
+ /* ═════════════════════════════════════════════════════ *
372
+ * Phase 28 V2 — Spec Maturity + Dialogue Lifecycle
373
+ * ═════════════════════════════════════════════════════ */
374
+
375
+ nlp
376
+ .command("spec-maturities-v2")
377
+ .description("List Phase 28 V2 spec maturity states")
378
+ .option("--json", "JSON output")
379
+ .action((opts) => {
380
+ const v = Object.values(SPEC_MATURITY_V2);
381
+ if (opts.json) return console.log(JSON.stringify(v, null, 2));
382
+ for (const s of v) console.log(s);
383
+ });
384
+
385
+ nlp
386
+ .command("dialogue-turn-lifecycles-v2")
387
+ .description("List Phase 28 V2 dialogue-turn lifecycle states")
388
+ .option("--json", "JSON output")
389
+ .action((opts) => {
390
+ const v = Object.values(DIALOGUE_TURN_V2);
391
+ if (opts.json) return console.log(JSON.stringify(v, null, 2));
392
+ for (const s of v) console.log(s);
393
+ });
394
+
395
+ nlp
396
+ .command("default-max-active-specs-per-author")
397
+ .description("Show default V2 per-author active-spec cap")
398
+ .action(() => console.log(getDefaultMaxActiveSpecsPerAuthorV2()));
399
+
400
+ nlp
401
+ .command("max-active-specs-per-author")
402
+ .description("Show current V2 per-author active-spec cap")
403
+ .action(() => console.log(getMaxActiveSpecsPerAuthorV2()));
404
+
405
+ nlp
406
+ .command("set-max-active-specs-per-author <n>")
407
+ .description("Set V2 per-author active-spec cap")
408
+ .action((n) => console.log(setMaxActiveSpecsPerAuthorV2(n)));
409
+
410
+ nlp
411
+ .command("default-max-pending-turns-per-spec")
412
+ .description("Show default V2 per-spec pending-turn cap")
413
+ .action(() => console.log(getDefaultMaxPendingTurnsPerSpecV2()));
414
+
415
+ nlp
416
+ .command("max-pending-turns-per-spec")
417
+ .description("Show current V2 per-spec pending-turn cap")
418
+ .action(() => console.log(getMaxPendingTurnsPerSpecV2()));
419
+
420
+ nlp
421
+ .command("set-max-pending-turns-per-spec <n>")
422
+ .description("Set V2 per-spec pending-turn cap")
423
+ .action((n) => console.log(setMaxPendingTurnsPerSpecV2(n)));
424
+
425
+ nlp
426
+ .command("default-spec-idle-ms")
427
+ .description("Show default V2 spec idle threshold")
428
+ .action(() => console.log(getDefaultSpecIdleMsV2()));
429
+
430
+ nlp
431
+ .command("spec-idle-ms")
432
+ .description("Show current V2 spec idle threshold")
433
+ .action(() => console.log(getSpecIdleMsV2()));
434
+
435
+ nlp
436
+ .command("set-spec-idle-ms <ms>")
437
+ .description("Set V2 spec idle threshold (ms)")
438
+ .action((ms) => console.log(setSpecIdleMsV2(ms)));
439
+
440
+ nlp
441
+ .command("default-turn-pending-ms")
442
+ .description("Show default V2 turn-pending threshold")
443
+ .action(() => console.log(getDefaultTurnPendingMsV2()));
444
+
445
+ nlp
446
+ .command("turn-pending-ms")
447
+ .description("Show current V2 turn-pending threshold")
448
+ .action(() => console.log(getTurnPendingMsV2()));
449
+
450
+ nlp
451
+ .command("set-turn-pending-ms <ms>")
452
+ .description("Set V2 turn-pending threshold (ms)")
453
+ .action((ms) => console.log(setTurnPendingMsV2(ms)));
454
+
455
+ nlp
456
+ .command("active-spec-count")
457
+ .description("Count active V2 specs (optionally scoped by author)")
458
+ .option("-a, --author <id>", "Author ID")
459
+ .action((opts) => console.log(getActiveSpecCount(opts.author)));
460
+
461
+ nlp
462
+ .command("pending-turn-count")
463
+ .description("Count pending V2 turns (optionally scoped by spec)")
464
+ .option("-s, --spec <id>", "Spec ID")
465
+ .action((opts) => console.log(getPendingTurnCount(opts.spec)));
466
+
467
+ nlp
468
+ .command("register-spec-v2 <spec-id>")
469
+ .description("Register a V2 spec")
470
+ .requiredOption("-a, --author <id>", "Author ID")
471
+ .option("-t, --title <text>", "Title")
472
+ .option("-i, --initial-status <status>", "Initial status")
473
+ .option("-m, --metadata <json>", "Metadata JSON")
474
+ .option("--json", "JSON output")
475
+ .action((specId, opts) => {
476
+ const db = _dbFromCtx(nlp);
477
+ const rec = registerSpecV2(db, {
478
+ specId,
479
+ authorId: opts.author,
480
+ title: opts.title,
481
+ initialStatus: opts.initialStatus,
482
+ metadata: _parseMetaV2(opts.metadata),
483
+ });
484
+ if (opts.json) return console.log(JSON.stringify(rec, null, 2));
485
+ console.log(`Registered spec ${specId} (${rec.status})`);
486
+ });
487
+
488
+ nlp
489
+ .command("spec-v2 <spec-id>")
490
+ .description("Show a V2 spec")
491
+ .option("--json", "JSON output")
492
+ .action((id, opts) => {
493
+ const rec = getSpecV2(id);
494
+ if (!rec) {
495
+ console.error(`Unknown spec: ${id}`);
496
+ process.exitCode = 1;
497
+ return;
498
+ }
499
+ if (opts.json) return console.log(JSON.stringify(rec, null, 2));
500
+ console.log(`${rec.specId} [${rec.status}] author=${rec.authorId}`);
501
+ });
502
+
503
+ nlp
504
+ .command("set-spec-maturity-v2 <spec-id> <status>")
505
+ .description("Transition V2 spec maturity")
506
+ .option("-r, --reason <text>", "Reason")
507
+ .option("-m, --metadata <json>", "Metadata patch (JSON)")
508
+ .action((id, status, opts) => {
509
+ const db = _dbFromCtx(nlp);
510
+ const rec = setSpecMaturityV2(db, id, status, {
511
+ reason: opts.reason,
512
+ metadata: _parseMetaV2(opts.metadata),
513
+ });
514
+ console.log(`${id} → ${rec.status}`);
515
+ });
516
+
517
+ nlp
518
+ .command("refine-spec <spec-id>")
519
+ .description("Transition a V2 spec to REFINING")
520
+ .option("-r, --reason <text>", "Reason")
521
+ .action((id, opts) => {
522
+ const rec = refineSpec(_dbFromCtx(nlp), id, opts.reason);
523
+ console.log(`${id} → ${rec.status}`);
524
+ });
525
+
526
+ nlp
527
+ .command("approve-spec <spec-id>")
528
+ .description("Transition a V2 spec to APPROVED")
529
+ .option("-r, --reason <text>", "Reason")
530
+ .action((id, opts) => {
531
+ const rec = approveSpec(_dbFromCtx(nlp), id, opts.reason);
532
+ console.log(`${id} → ${rec.status}`);
533
+ });
534
+
535
+ nlp
536
+ .command("implement-spec <spec-id>")
537
+ .description("Transition a V2 spec to IMPLEMENTED")
538
+ .option("-r, --reason <text>", "Reason")
539
+ .action((id, opts) => {
540
+ const rec = implementSpec(_dbFromCtx(nlp), id, opts.reason);
541
+ console.log(`${id} → ${rec.status}`);
542
+ });
543
+
544
+ nlp
545
+ .command("archive-spec <spec-id>")
546
+ .description("Transition a V2 spec to ARCHIVED")
547
+ .option("-r, --reason <text>", "Reason")
548
+ .action((id, opts) => {
549
+ const rec = archiveSpec(_dbFromCtx(nlp), id, opts.reason);
550
+ console.log(`${id} → ${rec.status}`);
551
+ });
552
+
553
+ nlp
554
+ .command("touch-spec-activity <spec-id>")
555
+ .description("Bump lastActivityAt for a V2 spec")
556
+ .action((id) => {
557
+ const rec = touchSpecActivity(id);
558
+ console.log(`${id} lastActivityAt=${rec.lastActivityAt}`);
559
+ });
560
+
561
+ nlp
562
+ .command("register-dialogue-turn-v2 <turn-id>")
563
+ .description("Register a V2 dialogue turn")
564
+ .requiredOption("-s, --spec <id>", "Spec ID")
565
+ .option("-R, --role <role>", "Role (user/assistant)")
566
+ .option("-q, --question <text>", "Question text")
567
+ .option("-i, --initial-status <status>", "Initial status")
568
+ .option("-m, --metadata <json>", "Metadata JSON")
569
+ .option("--json", "JSON output")
570
+ .action((turnId, opts) => {
571
+ const db = _dbFromCtx(nlp);
572
+ const rec = registerDialogueTurnV2(db, {
573
+ turnId,
574
+ specId: opts.spec,
575
+ role: opts.role,
576
+ question: opts.question,
577
+ initialStatus: opts.initialStatus,
578
+ metadata: _parseMetaV2(opts.metadata),
579
+ });
580
+ if (opts.json) return console.log(JSON.stringify(rec, null, 2));
581
+ console.log(`Registered turn ${turnId} (${rec.status})`);
582
+ });
583
+
584
+ nlp
585
+ .command("dialogue-turn-v2 <turn-id>")
586
+ .description("Show a V2 dialogue turn")
587
+ .option("--json", "JSON output")
588
+ .action((id, opts) => {
589
+ const rec = getDialogueTurnV2(id);
590
+ if (!rec) {
591
+ console.error(`Unknown turn: ${id}`);
592
+ process.exitCode = 1;
593
+ return;
594
+ }
595
+ if (opts.json) return console.log(JSON.stringify(rec, null, 2));
596
+ console.log(`${rec.turnId} [${rec.status}] spec=${rec.specId}`);
597
+ });
598
+
599
+ nlp
600
+ .command("set-dialogue-turn-status-v2 <turn-id> <status>")
601
+ .description("Transition V2 dialogue turn status")
602
+ .option("-a, --answer <text>", "Answer text")
603
+ .option("-r, --reason <text>", "Reason")
604
+ .option("-m, --metadata <json>", "Metadata patch (JSON)")
605
+ .action((id, status, opts) => {
606
+ const db = _dbFromCtx(nlp);
607
+ const rec = setDialogueTurnStatusV2(db, id, status, {
608
+ answer: opts.answer,
609
+ reason: opts.reason,
610
+ metadata: _parseMetaV2(opts.metadata),
611
+ });
612
+ console.log(`${id} → ${rec.status}`);
613
+ });
614
+
615
+ nlp
616
+ .command("answer-turn <turn-id>")
617
+ .description("Transition a V2 turn to ANSWERED (with answer)")
618
+ .requiredOption("-a, --answer <text>", "Answer text")
619
+ .option("-r, --reason <text>", "Reason")
620
+ .action((id, opts) => {
621
+ const rec = answerTurn(_dbFromCtx(nlp), id, opts.answer, opts.reason);
622
+ console.log(`${id} → ${rec.status}`);
623
+ });
624
+
625
+ nlp
626
+ .command("dismiss-turn <turn-id>")
627
+ .description("Transition a V2 turn to DISMISSED")
628
+ .option("-r, --reason <text>", "Reason")
629
+ .action((id, opts) => {
630
+ const rec = dismissTurn(_dbFromCtx(nlp), id, opts.reason);
631
+ console.log(`${id} → ${rec.status}`);
632
+ });
633
+
634
+ nlp
635
+ .command("escalate-turn <turn-id>")
636
+ .description("Transition a V2 turn to ESCALATED")
637
+ .option("-r, --reason <text>", "Reason")
638
+ .action((id, opts) => {
639
+ const rec = escalateTurn(_dbFromCtx(nlp), id, opts.reason);
640
+ console.log(`${id} → ${rec.status}`);
641
+ });
642
+
643
+ nlp
644
+ .command("auto-archive-idle-specs")
645
+ .description(
646
+ "Flip idle V2 specs (draft/refining/approved/implemented) → ARCHIVED",
647
+ )
648
+ .option("--json", "JSON output")
649
+ .action((opts) => {
650
+ const r = autoArchiveIdleSpecs(_dbFromCtx(nlp));
651
+ if (opts.json) return console.log(JSON.stringify(r, null, 2));
652
+ console.log(`Archived ${r.count} idle spec(s)`);
653
+ });
654
+
655
+ nlp
656
+ .command("auto-dismiss-stale-pending-turns")
657
+ .description("Flip stale PENDING V2 turns → DISMISSED")
658
+ .option("--json", "JSON output")
659
+ .action((opts) => {
660
+ const r = autoDismissStalePendingTurns(_dbFromCtx(nlp));
661
+ if (opts.json) return console.log(JSON.stringify(r, null, 2));
662
+ console.log(`Dismissed ${r.count} stale turn(s)`);
663
+ });
664
+
665
+ nlp
666
+ .command("stats-v2")
667
+ .description("Phase 28 V2 statistics")
668
+ .option("--json", "JSON output")
669
+ .action((opts) => {
670
+ const s = getNlProgrammingStatsV2();
671
+ if (opts.json) return console.log(JSON.stringify(s, null, 2));
672
+ console.log(
673
+ `Specs(V2)=${s.totalSpecsV2} Turns(V2)=${s.totalTurnsV2} ` +
674
+ `caps: active-specs/author=${s.maxActiveSpecsPerAuthor} pending-turns/spec=${s.maxPendingTurnsPerSpec}`,
675
+ );
676
+ console.log("specs-by-status:");
677
+ for (const [k, v] of Object.entries(s.specsByStatus))
678
+ console.log(` ${k.padEnd(12)} ${v}`);
679
+ console.log("turns-by-status:");
680
+ for (const [k, v] of Object.entries(s.turnsByStatus))
681
+ console.log(` ${k.padEnd(12)} ${v}`);
682
+ });
683
+
328
684
  program.addCommand(nlp);
329
685
  }
@@ -371,4 +371,66 @@ export function registerNostrCommand(program) {
371
371
  process.exit(1);
372
372
  }
373
373
  });
374
+
375
+ registerNostrV2Command(nostr);
376
+ }
377
+
378
+
379
+ import {
380
+ NOSTR_RELAY_MATURITY_V2,
381
+ NOSTR_EVENT_LIFECYCLE_V2,
382
+ registerNostrRelayV2,
383
+ activateNostrRelayV2,
384
+ offlineNostrRelayV2,
385
+ retireNostrRelayV2,
386
+ touchNostrRelayV2,
387
+ getNostrRelayV2,
388
+ listNostrRelaysV2,
389
+ createNostrEventV2,
390
+ startNostrEventV2,
391
+ publishNostrEventV2,
392
+ failNostrEventV2,
393
+ cancelNostrEventV2,
394
+ getNostrEventV2,
395
+ listNostrEventsV2,
396
+ setMaxActiveNostrRelaysPerOwnerV2,
397
+ getMaxActiveNostrRelaysPerOwnerV2,
398
+ setMaxPendingNostrEventsPerRelayV2,
399
+ getMaxPendingNostrEventsPerRelayV2,
400
+ setNostrRelayIdleMsV2,
401
+ getNostrRelayIdleMsV2,
402
+ setNostrEventStuckMsV2,
403
+ getNostrEventStuckMsV2,
404
+ autoOfflineIdleNostrRelaysV2,
405
+ autoFailStuckNostrEventsV2,
406
+ getNostrBridgeStatsV2,
407
+ } from "../lib/nostr-bridge.js";
408
+
409
+ export function registerNostrV2Command(nostr) {
410
+ nostr.command("enums-v2").description("Show V2 enums").action(() => { console.log(JSON.stringify({ NOSTR_RELAY_MATURITY_V2, NOSTR_EVENT_LIFECYCLE_V2 }, null, 2)); });
411
+ nostr.command("register-relay-v2").description("Register a nostr relay profile (pending)")
412
+ .requiredOption("--id <id>").requiredOption("--owner <owner>").option("--url <url>")
413
+ .action((o) => { console.log(JSON.stringify(registerNostrRelayV2(o), null, 2)); });
414
+ nostr.command("activate-relay-v2 <id>").description("Activate relay").action((id) => { console.log(JSON.stringify(activateNostrRelayV2(id), null, 2)); });
415
+ nostr.command("offline-relay-v2 <id>").description("Mark relay offline").action((id) => { console.log(JSON.stringify(offlineNostrRelayV2(id), null, 2)); });
416
+ nostr.command("retire-relay-v2 <id>").description("Retire relay (terminal)").action((id) => { console.log(JSON.stringify(retireNostrRelayV2(id), null, 2)); });
417
+ nostr.command("touch-relay-v2 <id>").description("Refresh lastTouchedAt").action((id) => { console.log(JSON.stringify(touchNostrRelayV2(id), null, 2)); });
418
+ nostr.command("get-relay-v2 <id>").description("Get a relay").action((id) => { console.log(JSON.stringify(getNostrRelayV2(id), null, 2)); });
419
+ nostr.command("list-relays-v2").description("List relays").action(() => { console.log(JSON.stringify(listNostrRelaysV2(), null, 2)); });
420
+ nostr.command("create-event-v2").description("Create a nostr event (queued)")
421
+ .requiredOption("--id <id>").requiredOption("--relay-id <relayId>").option("--kind <kind>", "event kind", (v) => Number(v))
422
+ .action((o) => { console.log(JSON.stringify(createNostrEventV2({ id: o.id, relayId: o.relayId, kind: o.kind }), null, 2)); });
423
+ nostr.command("start-event-v2 <id>").description("Transition event to publishing").action((id) => { console.log(JSON.stringify(startNostrEventV2(id), null, 2)); });
424
+ nostr.command("publish-event-v2 <id>").description("Transition event to published").action((id) => { console.log(JSON.stringify(publishNostrEventV2(id), null, 2)); });
425
+ nostr.command("fail-event-v2 <id>").description("Fail event").option("--reason <r>").action((id, o) => { console.log(JSON.stringify(failNostrEventV2(id, o.reason), null, 2)); });
426
+ nostr.command("cancel-event-v2 <id>").description("Cancel event").option("--reason <r>").action((id, o) => { console.log(JSON.stringify(cancelNostrEventV2(id, o.reason), null, 2)); });
427
+ nostr.command("get-event-v2 <id>").description("Get event").action((id) => { console.log(JSON.stringify(getNostrEventV2(id), null, 2)); });
428
+ nostr.command("list-events-v2").description("List events").action(() => { console.log(JSON.stringify(listNostrEventsV2(), null, 2)); });
429
+ nostr.command("set-max-active-relays-v2 <n>").description("Set per-owner active cap").action((n) => { setMaxActiveNostrRelaysPerOwnerV2(Number(n)); console.log(JSON.stringify({ maxActiveNostrRelaysPerOwner: getMaxActiveNostrRelaysPerOwnerV2() }, null, 2)); });
430
+ nostr.command("set-max-pending-events-v2 <n>").description("Set per-relay pending cap").action((n) => { setMaxPendingNostrEventsPerRelayV2(Number(n)); console.log(JSON.stringify({ maxPendingNostrEventsPerRelay: getMaxPendingNostrEventsPerRelayV2() }, null, 2)); });
431
+ nostr.command("set-relay-idle-ms-v2 <n>").description("Set idle threshold").action((n) => { setNostrRelayIdleMsV2(Number(n)); console.log(JSON.stringify({ nostrRelayIdleMs: getNostrRelayIdleMsV2() }, null, 2)); });
432
+ nostr.command("set-event-stuck-ms-v2 <n>").description("Set stuck threshold").action((n) => { setNostrEventStuckMsV2(Number(n)); console.log(JSON.stringify({ nostrEventStuckMs: getNostrEventStuckMsV2() }, null, 2)); });
433
+ nostr.command("auto-offline-idle-relays-v2").description("Auto-offline idle relays").action(() => { console.log(JSON.stringify(autoOfflineIdleNostrRelaysV2(), null, 2)); });
434
+ nostr.command("auto-fail-stuck-events-v2").description("Auto-fail stuck publishing events").action(() => { console.log(JSON.stringify(autoFailStuckNostrEventsV2(), null, 2)); });
435
+ nostr.command("stats-v2").description("V2 aggregate stats").action(() => { console.log(JSON.stringify(getNostrBridgeStatsV2(), null, 2)); });
374
436
  }
@@ -14,6 +14,35 @@ import {
14
14
  simpleDiff,
15
15
  formatDiff,
16
16
  revertToVersion,
17
+ NOTE_MATURITY_V2,
18
+ REVISION_LIFECYCLE_V2,
19
+ getMaxActiveNotesPerAuthorV2,
20
+ setMaxActiveNotesPerAuthorV2,
21
+ getMaxOpenRevsPerNoteV2,
22
+ setMaxOpenRevsPerNoteV2,
23
+ getNoteIdleMsV2,
24
+ setNoteIdleMsV2,
25
+ getRevStuckMsV2,
26
+ setRevStuckMsV2,
27
+ getActiveNoteCountV2,
28
+ getOpenRevCountV2,
29
+ registerNoteV2,
30
+ getNoteV2,
31
+ listNotesV2,
32
+ activateNoteV2,
33
+ lockNoteV2,
34
+ archiveNoteV2,
35
+ touchNoteV2,
36
+ createRevisionV2,
37
+ getRevisionV2,
38
+ listRevisionsV2,
39
+ reviewRevisionV2,
40
+ applyRevisionV2,
41
+ supersedeRevisionV2,
42
+ discardRevisionV2,
43
+ autoLockIdleNotesV2,
44
+ autoDiscardStaleRevisionsV2,
45
+ getNoteVersioningStatsV2,
17
46
  } from "../lib/note-versioning.js";
18
47
 
19
48
  /**
@@ -486,4 +515,219 @@ export function registerNoteCommand(program) {
486
515
  process.exit(1);
487
516
  }
488
517
  });
518
+
519
+ // ─── V2 governance surface ─────────────────────────────────
520
+
521
+ note
522
+ .command("note-maturities-v2")
523
+ .description("List V2 note maturity states")
524
+ .action(() => {
525
+ console.log(JSON.stringify(Object.values(NOTE_MATURITY_V2), null, 2));
526
+ });
527
+
528
+ note
529
+ .command("revision-lifecycles-v2")
530
+ .description("List V2 revision lifecycle states")
531
+ .action(() => {
532
+ console.log(
533
+ JSON.stringify(Object.values(REVISION_LIFECYCLE_V2), null, 2),
534
+ );
535
+ });
536
+
537
+ note
538
+ .command("stats-v2")
539
+ .description("Show V2 governance stats")
540
+ .action(() => {
541
+ console.log(JSON.stringify(getNoteVersioningStatsV2(), null, 2));
542
+ });
543
+
544
+ note
545
+ .command("get-max-active-notes-v2")
546
+ .description("Get max active notes per author")
547
+ .action(() => console.log(getMaxActiveNotesPerAuthorV2()));
548
+
549
+ note
550
+ .command("set-max-active-notes-v2 <n>")
551
+ .description("Set max active notes per author")
552
+ .action((n) => {
553
+ setMaxActiveNotesPerAuthorV2(Number(n));
554
+ console.log(getMaxActiveNotesPerAuthorV2());
555
+ });
556
+
557
+ note
558
+ .command("get-max-open-revs-v2")
559
+ .description("Get max open revisions per note")
560
+ .action(() => console.log(getMaxOpenRevsPerNoteV2()));
561
+
562
+ note
563
+ .command("set-max-open-revs-v2 <n>")
564
+ .description("Set max open revisions per note")
565
+ .action((n) => {
566
+ setMaxOpenRevsPerNoteV2(Number(n));
567
+ console.log(getMaxOpenRevsPerNoteV2());
568
+ });
569
+
570
+ note
571
+ .command("get-note-idle-ms-v2")
572
+ .description("Get note idle threshold (ms)")
573
+ .action(() => console.log(getNoteIdleMsV2()));
574
+
575
+ note
576
+ .command("set-note-idle-ms-v2 <n>")
577
+ .description("Set note idle threshold (ms)")
578
+ .action((n) => {
579
+ setNoteIdleMsV2(Number(n));
580
+ console.log(getNoteIdleMsV2());
581
+ });
582
+
583
+ note
584
+ .command("get-rev-stuck-ms-v2")
585
+ .description("Get revision stuck threshold (ms)")
586
+ .action(() => console.log(getRevStuckMsV2()));
587
+
588
+ note
589
+ .command("set-rev-stuck-ms-v2 <n>")
590
+ .description("Set revision stuck threshold (ms)")
591
+ .action((n) => {
592
+ setRevStuckMsV2(Number(n));
593
+ console.log(getRevStuckMsV2());
594
+ });
595
+
596
+ note
597
+ .command("active-note-count-v2 <authorId>")
598
+ .description("Count active notes for an author")
599
+ .action((authorId) => console.log(getActiveNoteCountV2(authorId)));
600
+
601
+ note
602
+ .command("open-rev-count-v2 <noteId>")
603
+ .description("Count open revisions for a note")
604
+ .action((noteId) => console.log(getOpenRevCountV2(noteId)));
605
+
606
+ note
607
+ .command("register-note-v2 <id>")
608
+ .description("Register a V2 note")
609
+ .requiredOption("-a, --author <authorId>", "Author id")
610
+ .requiredOption("-t, --title <title>", "Title")
611
+ .action((id, opts) => {
612
+ const n = registerNoteV2(id, {
613
+ authorId: opts.author,
614
+ title: opts.title,
615
+ });
616
+ console.log(JSON.stringify(n, null, 2));
617
+ });
618
+
619
+ note
620
+ .command("get-note-v2 <id>")
621
+ .description("Get a V2 note")
622
+ .action((id) => {
623
+ const n = getNoteV2(id);
624
+ console.log(n ? JSON.stringify(n, null, 2) : "null");
625
+ });
626
+
627
+ note
628
+ .command("list-notes-v2")
629
+ .description("List V2 notes")
630
+ .option("-a, --author <authorId>", "Filter by author")
631
+ .option("-s, --status <status>", "Filter by status")
632
+ .action((opts) => {
633
+ console.log(
634
+ JSON.stringify(
635
+ listNotesV2({ authorId: opts.author, status: opts.status }),
636
+ null,
637
+ 2,
638
+ ),
639
+ );
640
+ });
641
+
642
+ note
643
+ .command("activate-note-v2 <id>")
644
+ .description("draft|locked → active")
645
+ .action((id) => console.log(JSON.stringify(activateNoteV2(id), null, 2)));
646
+
647
+ note
648
+ .command("lock-note-v2 <id>")
649
+ .description("active → locked")
650
+ .action((id) => console.log(JSON.stringify(lockNoteV2(id), null, 2)));
651
+
652
+ note
653
+ .command("archive-note-v2 <id>")
654
+ .description("→ archived (terminal)")
655
+ .action((id) => console.log(JSON.stringify(archiveNoteV2(id), null, 2)));
656
+
657
+ note
658
+ .command("touch-note-v2 <id>")
659
+ .description("Update lastSeenAt")
660
+ .action((id) => console.log(JSON.stringify(touchNoteV2(id), null, 2)));
661
+
662
+ note
663
+ .command("create-revision-v2 <id>")
664
+ .description("Create a V2 revision")
665
+ .requiredOption("-n, --note <noteId>", "Note id")
666
+ .requiredOption("-s, --summary <summary>", "Summary")
667
+ .action((id, opts) => {
668
+ const r = createRevisionV2(id, {
669
+ noteId: opts.note,
670
+ summary: opts.summary,
671
+ });
672
+ console.log(JSON.stringify(r, null, 2));
673
+ });
674
+
675
+ note
676
+ .command("get-revision-v2 <id>")
677
+ .description("Get a V2 revision")
678
+ .action((id) => {
679
+ const r = getRevisionV2(id);
680
+ console.log(r ? JSON.stringify(r, null, 2) : "null");
681
+ });
682
+
683
+ note
684
+ .command("list-revisions-v2")
685
+ .description("List V2 revisions")
686
+ .option("-n, --note <noteId>", "Filter by note")
687
+ .option("-s, --status <status>", "Filter by status")
688
+ .action((opts) => {
689
+ console.log(
690
+ JSON.stringify(
691
+ listRevisionsV2({ noteId: opts.note, status: opts.status }),
692
+ null,
693
+ 2,
694
+ ),
695
+ );
696
+ });
697
+
698
+ note
699
+ .command("review-revision-v2 <id>")
700
+ .description("proposed → reviewed")
701
+ .action((id) => console.log(JSON.stringify(reviewRevisionV2(id), null, 2)));
702
+
703
+ note
704
+ .command("apply-revision-v2 <id>")
705
+ .description("reviewed → applied (non-terminal)")
706
+ .action((id) => console.log(JSON.stringify(applyRevisionV2(id), null, 2)));
707
+
708
+ note
709
+ .command("supersede-revision-v2 <id>")
710
+ .description("reviewed|applied → superseded (terminal)")
711
+ .action((id) =>
712
+ console.log(JSON.stringify(supersedeRevisionV2(id), null, 2)),
713
+ );
714
+
715
+ note
716
+ .command("discard-revision-v2 <id>")
717
+ .description("→ discarded (terminal)")
718
+ .action((id) =>
719
+ console.log(JSON.stringify(discardRevisionV2(id), null, 2)),
720
+ );
721
+
722
+ note
723
+ .command("auto-lock-idle-notes-v2")
724
+ .description("Flip idle active notes → locked")
725
+ .action(() => console.log(JSON.stringify(autoLockIdleNotesV2(), null, 2)));
726
+
727
+ note
728
+ .command("auto-discard-stale-revisions-v2")
729
+ .description("Flip stale proposed/reviewed → discarded")
730
+ .action(() =>
731
+ console.log(JSON.stringify(autoDiscardStaleRevisionsV2(), null, 2)),
732
+ );
489
733
  }