chainlesschain 0.132.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 (106) hide show
  1. package/package.json +1 -1
  2. package/src/commands/a2a.js +62 -0
  3. package/src/commands/activitypub.js +61 -0
  4. package/src/commands/agent.js +117 -0
  5. package/src/commands/bi.js +61 -0
  6. package/src/commands/bm25.js +78 -0
  7. package/src/commands/browse.js +64 -0
  8. package/src/commands/ccron.js +78 -0
  9. package/src/commands/compliance.js +40 -0
  10. package/src/commands/compt.js +78 -0
  11. package/src/commands/consol.js +231 -0
  12. package/src/commands/cowork.js +42 -0
  13. package/src/commands/crosschain.js +62 -0
  14. package/src/commands/dao.js +62 -0
  15. package/src/commands/dlp.js +61 -0
  16. package/src/commands/economy.js +56 -0
  17. package/src/commands/evolution.js +56 -0
  18. package/src/commands/evomap.js +61 -0
  19. package/src/commands/fflag.js +178 -0
  20. package/src/commands/git.js +45 -0
  21. package/src/commands/hmemory.js +56 -0
  22. package/src/commands/inference.js +42 -0
  23. package/src/commands/itbudget.js +45 -0
  24. package/src/commands/lowcode.js +44 -0
  25. package/src/commands/matrix.js +62 -0
  26. package/src/commands/mcpscaf.js +41 -0
  27. package/src/commands/meminj.js +41 -0
  28. package/src/commands/nostr.js +62 -0
  29. package/src/commands/orchgov.js +45 -0
  30. package/src/commands/pdfp.js +78 -0
  31. package/src/commands/perf.js +39 -0
  32. package/src/commands/perm.js +45 -0
  33. package/src/commands/pipeline.js +57 -1
  34. package/src/commands/planmode.js +45 -0
  35. package/src/commands/promcomp.js +82 -0
  36. package/src/commands/recommend.js +42 -0
  37. package/src/commands/seshhook.js +41 -0
  38. package/src/commands/seshsearch.js +41 -0
  39. package/src/commands/seshtail.js +41 -0
  40. package/src/commands/seshu.js +41 -0
  41. package/src/commands/sganal.js +78 -0
  42. package/src/commands/siem.js +40 -0
  43. package/src/commands/slotfill.js +41 -0
  44. package/src/commands/social.js +34 -0
  45. package/src/commands/svccont.js +45 -0
  46. package/src/commands/tms.js +45 -0
  47. package/src/commands/topiccls.js +45 -0
  48. package/src/commands/uprof.js +45 -0
  49. package/src/commands/vcheck.js +78 -0
  50. package/src/commands/webfetch.js +41 -0
  51. package/src/commands/zkp.js +62 -0
  52. package/src/harness/prompt-compressor.js +331 -0
  53. package/src/index.js +61 -1
  54. package/src/lib/a2a-protocol.js +105 -0
  55. package/src/lib/activitypub-bridge.js +105 -0
  56. package/src/lib/agent-economy.js +105 -0
  57. package/src/lib/app-builder.js +105 -0
  58. package/src/lib/autonomous-agent.js +105 -0
  59. package/src/lib/bi-engine.js +105 -0
  60. package/src/lib/bm25-search.js +81 -0
  61. package/src/lib/browser-automation.js +105 -0
  62. package/src/lib/compliance-framework-reporter.js +105 -0
  63. package/src/lib/compression-telemetry.js +81 -0
  64. package/src/lib/content-recommender.js +105 -0
  65. package/src/lib/cowork-cron.js +81 -0
  66. package/src/lib/cowork-task-runner.js +105 -0
  67. package/src/lib/cross-chain.js +105 -0
  68. package/src/lib/dao-governance.js +105 -0
  69. package/src/lib/dlp-engine.js +105 -0
  70. package/src/lib/evolution-system.js +105 -0
  71. package/src/lib/evomap-manager.js +105 -0
  72. package/src/lib/execution-backend.js +105 -0
  73. package/src/lib/feature-flags.js +85 -0
  74. package/src/lib/git-integration.js +105 -0
  75. package/src/lib/hierarchical-memory.js +105 -0
  76. package/src/lib/inference-network.js +105 -0
  77. package/src/lib/iteration-budget.js +105 -0
  78. package/src/lib/matrix-bridge.js +105 -0
  79. package/src/lib/mcp-scaffold.js +81 -0
  80. package/src/lib/memory-injection.js +81 -0
  81. package/src/lib/nostr-bridge.js +105 -0
  82. package/src/lib/orchestrator.js +105 -0
  83. package/src/lib/pdf-parser.js +81 -0
  84. package/src/lib/perf-tuning.js +105 -0
  85. package/src/lib/permission-engine.js +81 -0
  86. package/src/lib/pipeline-orchestrator.js +105 -0
  87. package/src/lib/plan-mode.js +81 -0
  88. package/src/lib/prompt-compressor.js +1 -10
  89. package/src/lib/service-container.js +81 -0
  90. package/src/lib/session-consolidator.js +105 -0
  91. package/src/lib/session-hooks.js +81 -0
  92. package/src/lib/session-search.js +81 -0
  93. package/src/lib/session-tail.js +81 -0
  94. package/src/lib/session-usage.js +83 -0
  95. package/src/lib/siem-exporter.js +105 -0
  96. package/src/lib/slot-filler.js +81 -0
  97. package/src/lib/social-graph-analytics.js +81 -0
  98. package/src/lib/social-graph.js +81 -0
  99. package/src/lib/sub-agent-registry.js +110 -0
  100. package/src/lib/task-model-selector.js +81 -0
  101. package/src/lib/todo-manager.js +105 -0
  102. package/src/lib/topic-classifier.js +105 -0
  103. package/src/lib/user-profile.js +81 -0
  104. package/src/lib/version-checker.js +81 -0
  105. package/src/lib/web-fetch.js +81 -0
  106. package/src/lib/zkp-engine.js +105 -0
@@ -688,4 +688,48 @@ export function registerLowcodeCommand(program) {
688
688
  if (ctx) await shutdown(ctx);
689
689
  }
690
690
  });
691
+
692
+ _registerAppBuilderV2Commands(lowcode);
693
+ }
694
+
695
+ function _registerAppBuilderV2Commands(parent) {
696
+ const L = async () => await import("../lib/app-builder.js");
697
+ parent.command("enums-v2").description("Show V2 enums (app maturity + build lifecycle)")
698
+ .action(async () => { const m = await L(); console.log(JSON.stringify({ appMaturity: m.APP_MATURITY_V2, buildLifecycle: m.APP_BUILD_LIFECYCLE_V2 }, null, 2)); });
699
+ parent.command("config-v2").description("Show V2 config thresholds")
700
+ .action(async () => { const m = await L(); console.log(JSON.stringify({ maxActiveAppsPerOwner: m.getMaxActiveAppsPerOwnerV2(), maxPendingAppBuildsPerApp: m.getMaxPendingAppBuildsPerAppV2(), appIdleMs: m.getAppIdleMsV2(), appBuildStuckMs: m.getAppBuildStuckMsV2() }, null, 2)); });
701
+ parent.command("set-max-active-apps-v2 <n>").description("Set max active apps per owner")
702
+ .action(async (n) => { const m = await L(); m.setMaxActiveAppsPerOwnerV2(Number(n)); console.log("ok"); });
703
+ parent.command("set-max-pending-builds-v2 <n>").description("Set max pending builds per app")
704
+ .action(async (n) => { const m = await L(); m.setMaxPendingAppBuildsPerAppV2(Number(n)); console.log("ok"); });
705
+ parent.command("set-app-idle-ms-v2 <n>").description("Set app idle threshold (ms)")
706
+ .action(async (n) => { const m = await L(); m.setAppIdleMsV2(Number(n)); console.log("ok"); });
707
+ parent.command("set-build-stuck-ms-v2 <n>").description("Set build stuck threshold (ms)")
708
+ .action(async (n) => { const m = await L(); m.setAppBuildStuckMsV2(Number(n)); console.log("ok"); });
709
+ parent.command("register-app-v2 <id> <owner>").description("Register V2 app")
710
+ .option("--name <n>", "App name").action(async (id, owner, o) => { const m = await L(); console.log(JSON.stringify(m.registerAppV2({ id, owner, name: o.name }), null, 2)); });
711
+ parent.command("activate-app-v2 <id>").description("Activate app")
712
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.activateAppV2(id), null, 2)); });
713
+ parent.command("pause-app-v2 <id>").description("Pause app")
714
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.pauseAppV2(id), null, 2)); });
715
+ parent.command("archive-app-v2 <id>").description("Archive app (terminal)")
716
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.archiveAppV2(id), null, 2)); });
717
+ parent.command("touch-app-v2 <id>").description("Touch app lastTouchedAt")
718
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.touchAppV2(id), null, 2)); });
719
+ parent.command("get-app-v2 <id>").description("Get V2 app").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.getAppV2(id), null, 2)); });
720
+ parent.command("list-apps-v2").description("List V2 apps").action(async () => { const m = await L(); console.log(JSON.stringify(m.listAppsV2(), null, 2)); });
721
+ parent.command("create-build-v2 <id> <appId>").description("Create V2 app build (queued)")
722
+ .option("--target <t>", "Target", "web").action(async (id, appId, o) => { const m = await L(); console.log(JSON.stringify(m.createAppBuildV2({ id, appId, target: o.target }), null, 2)); });
723
+ parent.command("start-build-v2 <id>").description("Start build").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.startAppBuildV2(id), null, 2)); });
724
+ parent.command("succeed-build-v2 <id>").description("Succeed build").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.succeedAppBuildV2(id), null, 2)); });
725
+ parent.command("fail-build-v2 <id> [reason]").description("Fail build").action(async (id, reason) => { const m = await L(); console.log(JSON.stringify(m.failAppBuildV2(id, reason), null, 2)); });
726
+ parent.command("cancel-build-v2 <id> [reason]").description("Cancel build").action(async (id, reason) => { const m = await L(); console.log(JSON.stringify(m.cancelAppBuildV2(id, reason), null, 2)); });
727
+ parent.command("get-build-v2 <id>").description("Get V2 build").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.getAppBuildV2(id), null, 2)); });
728
+ parent.command("list-builds-v2").description("List V2 builds").action(async () => { const m = await L(); console.log(JSON.stringify(m.listAppBuildsV2(), null, 2)); });
729
+ parent.command("auto-pause-idle-v2").description("Auto-pause idle active apps")
730
+ .action(async () => { const m = await L(); console.log(JSON.stringify(m.autoPauseIdleAppsV2(), null, 2)); });
731
+ parent.command("auto-fail-stuck-v2").description("Auto-fail stuck building builds")
732
+ .action(async () => { const m = await L(); console.log(JSON.stringify(m.autoFailStuckAppBuildsV2(), null, 2)); });
733
+ parent.command("gov-stats-v2").description("V2 governance aggregate stats")
734
+ .action(async () => { const m = await L(); console.log(JSON.stringify(m.getAppBuilderGovStatsV2(), null, 2)); });
691
735
  }
@@ -448,4 +448,66 @@ export function registerMatrixCommand(program) {
448
448
  process.exit(1);
449
449
  }
450
450
  });
451
+
452
+ registerMatrixV2Command(matrix);
453
+ }
454
+
455
+
456
+ import {
457
+ MX_ROOM_MATURITY_V2,
458
+ MX_MESSAGE_LIFECYCLE_V2,
459
+ registerMatrixRoomV2,
460
+ activateMatrixRoomV2,
461
+ muteMatrixRoomV2,
462
+ archiveMatrixRoomV2,
463
+ touchMatrixRoomV2,
464
+ getMatrixRoomV2,
465
+ listMatrixRoomsV2,
466
+ createMatrixMessageV2,
467
+ startMatrixMessageV2,
468
+ deliverMatrixMessageV2,
469
+ failMatrixMessageV2,
470
+ cancelMatrixMessageV2,
471
+ getMatrixMessageV2,
472
+ listMatrixMessagesV2,
473
+ setMaxActiveMatrixRoomsPerOwnerV2,
474
+ getMaxActiveMatrixRoomsPerOwnerV2,
475
+ setMaxPendingMatrixMessagesPerRoomV2,
476
+ getMaxPendingMatrixMessagesPerRoomV2,
477
+ setMatrixRoomIdleMsV2,
478
+ getMatrixRoomIdleMsV2,
479
+ setMatrixMessageStuckMsV2,
480
+ getMatrixMessageStuckMsV2,
481
+ autoMuteIdleMatrixRoomsV2,
482
+ autoFailStuckMatrixMessagesV2,
483
+ getMatrixBridgeStatsV2,
484
+ } from "../lib/matrix-bridge.js";
485
+
486
+ export function registerMatrixV2Command(matrix) {
487
+ matrix.command("enums-v2").description("Show V2 enums").action(() => { console.log(JSON.stringify({ MX_ROOM_MATURITY_V2, MX_MESSAGE_LIFECYCLE_V2 }, null, 2)); });
488
+ matrix.command("register-room-v2").description("Register a matrix room profile (pending)")
489
+ .requiredOption("--id <id>").requiredOption("--owner <owner>").option("--alias <alias>")
490
+ .action((o) => { console.log(JSON.stringify(registerMatrixRoomV2(o), null, 2)); });
491
+ matrix.command("activate-room-v2 <id>").description("Activate room").action((id) => { console.log(JSON.stringify(activateMatrixRoomV2(id), null, 2)); });
492
+ matrix.command("mute-room-v2 <id>").description("Mute room").action((id) => { console.log(JSON.stringify(muteMatrixRoomV2(id), null, 2)); });
493
+ matrix.command("archive-room-v2 <id>").description("Archive room (terminal)").action((id) => { console.log(JSON.stringify(archiveMatrixRoomV2(id), null, 2)); });
494
+ matrix.command("touch-room-v2 <id>").description("Refresh lastTouchedAt").action((id) => { console.log(JSON.stringify(touchMatrixRoomV2(id), null, 2)); });
495
+ matrix.command("get-room-v2 <id>").description("Get a room").action((id) => { console.log(JSON.stringify(getMatrixRoomV2(id), null, 2)); });
496
+ matrix.command("list-rooms-v2").description("List rooms").action(() => { console.log(JSON.stringify(listMatrixRoomsV2(), null, 2)); });
497
+ matrix.command("create-msg-v2").description("Create a matrix message (queued)")
498
+ .requiredOption("--id <id>").requiredOption("--room-id <roomId>").option("--body <body>")
499
+ .action((o) => { console.log(JSON.stringify(createMatrixMessageV2({ id: o.id, roomId: o.roomId, body: o.body }), null, 2)); });
500
+ matrix.command("start-msg-v2 <id>").description("Transition msg to sending").action((id) => { console.log(JSON.stringify(startMatrixMessageV2(id), null, 2)); });
501
+ matrix.command("deliver-msg-v2 <id>").description("Transition msg to delivered").action((id) => { console.log(JSON.stringify(deliverMatrixMessageV2(id), null, 2)); });
502
+ matrix.command("fail-msg-v2 <id>").description("Fail msg").option("--reason <r>").action((id, o) => { console.log(JSON.stringify(failMatrixMessageV2(id, o.reason), null, 2)); });
503
+ matrix.command("cancel-msg-v2 <id>").description("Cancel msg").option("--reason <r>").action((id, o) => { console.log(JSON.stringify(cancelMatrixMessageV2(id, o.reason), null, 2)); });
504
+ matrix.command("get-msg-v2 <id>").description("Get msg").action((id) => { console.log(JSON.stringify(getMatrixMessageV2(id), null, 2)); });
505
+ matrix.command("list-msgs-v2").description("List msgs").action(() => { console.log(JSON.stringify(listMatrixMessagesV2(), null, 2)); });
506
+ matrix.command("set-max-active-rooms-v2 <n>").description("Set per-owner active cap").action((n) => { setMaxActiveMatrixRoomsPerOwnerV2(Number(n)); console.log(JSON.stringify({ maxActiveMatrixRoomsPerOwner: getMaxActiveMatrixRoomsPerOwnerV2() }, null, 2)); });
507
+ matrix.command("set-max-pending-msgs-v2 <n>").description("Set per-room pending cap").action((n) => { setMaxPendingMatrixMessagesPerRoomV2(Number(n)); console.log(JSON.stringify({ maxPendingMatrixMessagesPerRoom: getMaxPendingMatrixMessagesPerRoomV2() }, null, 2)); });
508
+ matrix.command("set-room-idle-ms-v2 <n>").description("Set idle threshold").action((n) => { setMatrixRoomIdleMsV2(Number(n)); console.log(JSON.stringify({ matrixRoomIdleMs: getMatrixRoomIdleMsV2() }, null, 2)); });
509
+ matrix.command("set-msg-stuck-ms-v2 <n>").description("Set stuck threshold").action((n) => { setMatrixMessageStuckMsV2(Number(n)); console.log(JSON.stringify({ matrixMessageStuckMs: getMatrixMessageStuckMsV2() }, null, 2)); });
510
+ matrix.command("auto-mute-idle-rooms-v2").description("Auto-mute idle rooms").action(() => { console.log(JSON.stringify(autoMuteIdleMatrixRoomsV2(), null, 2)); });
511
+ matrix.command("auto-fail-stuck-msgs-v2").description("Auto-fail stuck sending msgs").action(() => { console.log(JSON.stringify(autoFailStuckMatrixMessagesV2(), null, 2)); });
512
+ matrix.command("stats-v2").description("V2 aggregate stats").action(() => { console.log(JSON.stringify(getMatrixBridgeStatsV2(), null, 2)); });
451
513
  }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `cc mcpscaf` — MCP Scaffold V2 governance overlay (in-memory, atop lib/mcp-scaffold.js).
3
+ */
4
+ import {
5
+ MSCAF_PROFILE_MATURITY_V2, MSCAF_GENERATION_LIFECYCLE_V2,
6
+ setMaxActiveMscafProfilesPerOwnerV2, getMaxActiveMscafProfilesPerOwnerV2,
7
+ setMaxPendingMscafGenerationsPerProfileV2, getMaxPendingMscafGenerationsPerProfileV2,
8
+ setMscafProfileIdleMsV2, getMscafProfileIdleMsV2,
9
+ setMscafGenerationStuckMsV2, getMscafGenerationStuckMsV2,
10
+ registerMscafProfileV2, activateMscafProfileV2, staleMscafProfileV2, archiveMscafProfileV2, touchMscafProfileV2, getMscafProfileV2, listMscafProfilesV2,
11
+ createMscafGenerationV2, generatingMscafGenerationV2, generateMscafGenerationV2, failMscafGenerationV2, cancelMscafGenerationV2, getMscafGenerationV2, listMscafGenerationsV2,
12
+ autoStaleIdleMscafProfilesV2, autoFailStuckMscafGenerationsV2, getMcpScaffoldGovStatsV2, _resetStateMcpScaffoldV2,
13
+ } from "../lib/mcp-scaffold.js";
14
+
15
+ export function registerMcpscafCommand(program) {
16
+ const ms = program.command("mcpscaf").description("MCP Scaffold V2 governance");
17
+ ms.command("enums-v2").action(() => console.log(JSON.stringify({ profileMaturity: MSCAF_PROFILE_MATURITY_V2, generationLifecycle: MSCAF_GENERATION_LIFECYCLE_V2 }, null, 2)));
18
+ ms.command("config-v2").action(() => console.log(JSON.stringify({ maxActiveMscafProfilesPerOwner: getMaxActiveMscafProfilesPerOwnerV2(), maxPendingMscafGenerationsPerProfile: getMaxPendingMscafGenerationsPerProfileV2(), mscafProfileIdleMs: getMscafProfileIdleMsV2(), mscafGenerationStuckMs: getMscafGenerationStuckMsV2() }, null, 2)));
19
+ ms.command("set-max-active-v2 <n>").action((n) => { setMaxActiveMscafProfilesPerOwnerV2(Number(n)); console.log("ok"); });
20
+ ms.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingMscafGenerationsPerProfileV2(Number(n)); console.log("ok"); });
21
+ ms.command("set-idle-ms-v2 <n>").action((n) => { setMscafProfileIdleMsV2(Number(n)); console.log("ok"); });
22
+ ms.command("set-stuck-ms-v2 <n>").action((n) => { setMscafGenerationStuckMsV2(Number(n)); console.log("ok"); });
23
+ ms.command("register-profile-v2 <id> <owner>").option("--transport <t>", "transport").action((id, owner, o) => console.log(JSON.stringify(registerMscafProfileV2({ id, owner, transport: o.transport }), null, 2)));
24
+ ms.command("activate-profile-v2 <id>").action((id) => console.log(JSON.stringify(activateMscafProfileV2(id), null, 2)));
25
+ ms.command("stale-profile-v2 <id>").action((id) => console.log(JSON.stringify(staleMscafProfileV2(id), null, 2)));
26
+ ms.command("archive-profile-v2 <id>").action((id) => console.log(JSON.stringify(archiveMscafProfileV2(id), null, 2)));
27
+ ms.command("touch-profile-v2 <id>").action((id) => console.log(JSON.stringify(touchMscafProfileV2(id), null, 2)));
28
+ ms.command("get-profile-v2 <id>").action((id) => console.log(JSON.stringify(getMscafProfileV2(id), null, 2)));
29
+ ms.command("list-profiles-v2").action(() => console.log(JSON.stringify(listMscafProfilesV2(), null, 2)));
30
+ ms.command("create-generation-v2 <id> <profileId>").option("--target <t>", "target").action((id, profileId, o) => console.log(JSON.stringify(createMscafGenerationV2({ id, profileId, target: o.target }), null, 2)));
31
+ ms.command("generating-generation-v2 <id>").action((id) => console.log(JSON.stringify(generatingMscafGenerationV2(id), null, 2)));
32
+ ms.command("generate-generation-v2 <id>").action((id) => console.log(JSON.stringify(generateMscafGenerationV2(id), null, 2)));
33
+ ms.command("fail-generation-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(failMscafGenerationV2(id, reason), null, 2)));
34
+ ms.command("cancel-generation-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelMscafGenerationV2(id, reason), null, 2)));
35
+ ms.command("get-generation-v2 <id>").action((id) => console.log(JSON.stringify(getMscafGenerationV2(id), null, 2)));
36
+ ms.command("list-generations-v2").action(() => console.log(JSON.stringify(listMscafGenerationsV2(), null, 2)));
37
+ ms.command("auto-stale-idle-v2").action(() => console.log(JSON.stringify(autoStaleIdleMscafProfilesV2(), null, 2)));
38
+ ms.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckMscafGenerationsV2(), null, 2)));
39
+ ms.command("gov-stats-v2").action(() => console.log(JSON.stringify(getMcpScaffoldGovStatsV2(), null, 2)));
40
+ ms.command("reset-state-v2").action(() => { _resetStateMcpScaffoldV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
41
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `cc meminj` — Memory Injection V2 governance overlay (in-memory, atop lib/memory-injection.js).
3
+ */
4
+ import {
5
+ MINJ_RULE_MATURITY_V2, MINJ_INJECTION_LIFECYCLE_V2,
6
+ setMaxActiveMinjRulesPerOwnerV2, getMaxActiveMinjRulesPerOwnerV2,
7
+ setMaxPendingMinjInjectionsPerRuleV2, getMaxPendingMinjInjectionsPerRuleV2,
8
+ setMinjRuleIdleMsV2, getMinjRuleIdleMsV2,
9
+ setMinjInjectionStuckMsV2, getMinjInjectionStuckMsV2,
10
+ registerMinjRuleV2, activateMinjRuleV2, pauseMinjRuleV2, archiveMinjRuleV2, touchMinjRuleV2, getMinjRuleV2, listMinjRulesV2,
11
+ createMinjInjectionV2, injectingMinjInjectionV2, applyMinjInjectionV2, failMinjInjectionV2, cancelMinjInjectionV2, getMinjInjectionV2, listMinjInjectionsV2,
12
+ autoPauseIdleMinjRulesV2, autoFailStuckMinjInjectionsV2, getMemoryInjectionGovStatsV2, _resetStateMemoryInjectionV2,
13
+ } from "../lib/memory-injection.js";
14
+
15
+ export function registerMeminjCommand(program) {
16
+ const mi = program.command("meminj").description("Memory Injection V2 governance");
17
+ mi.command("enums-v2").action(() => console.log(JSON.stringify({ ruleMaturity: MINJ_RULE_MATURITY_V2, injectionLifecycle: MINJ_INJECTION_LIFECYCLE_V2 }, null, 2)));
18
+ mi.command("config-v2").action(() => console.log(JSON.stringify({ maxActiveMinjRulesPerOwner: getMaxActiveMinjRulesPerOwnerV2(), maxPendingMinjInjectionsPerRule: getMaxPendingMinjInjectionsPerRuleV2(), minjRuleIdleMs: getMinjRuleIdleMsV2(), minjInjectionStuckMs: getMinjInjectionStuckMsV2() }, null, 2)));
19
+ mi.command("set-max-active-v2 <n>").action((n) => { setMaxActiveMinjRulesPerOwnerV2(Number(n)); console.log("ok"); });
20
+ mi.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingMinjInjectionsPerRuleV2(Number(n)); console.log("ok"); });
21
+ mi.command("set-idle-ms-v2 <n>").action((n) => { setMinjRuleIdleMsV2(Number(n)); console.log("ok"); });
22
+ mi.command("set-stuck-ms-v2 <n>").action((n) => { setMinjInjectionStuckMsV2(Number(n)); console.log("ok"); });
23
+ mi.command("register-rule-v2 <id> <owner>").option("--scope <s>", "scope").action((id, owner, o) => console.log(JSON.stringify(registerMinjRuleV2({ id, owner, scope: o.scope }), null, 2)));
24
+ mi.command("activate-rule-v2 <id>").action((id) => console.log(JSON.stringify(activateMinjRuleV2(id), null, 2)));
25
+ mi.command("pause-rule-v2 <id>").action((id) => console.log(JSON.stringify(pauseMinjRuleV2(id), null, 2)));
26
+ mi.command("archive-rule-v2 <id>").action((id) => console.log(JSON.stringify(archiveMinjRuleV2(id), null, 2)));
27
+ mi.command("touch-rule-v2 <id>").action((id) => console.log(JSON.stringify(touchMinjRuleV2(id), null, 2)));
28
+ mi.command("get-rule-v2 <id>").action((id) => console.log(JSON.stringify(getMinjRuleV2(id), null, 2)));
29
+ mi.command("list-rules-v2").action(() => console.log(JSON.stringify(listMinjRulesV2(), null, 2)));
30
+ mi.command("create-injection-v2 <id> <ruleId>").option("--payload <p>", "payload").action((id, ruleId, o) => console.log(JSON.stringify(createMinjInjectionV2({ id, ruleId, payload: o.payload }), null, 2)));
31
+ mi.command("injecting-injection-v2 <id>").action((id) => console.log(JSON.stringify(injectingMinjInjectionV2(id), null, 2)));
32
+ mi.command("apply-injection-v2 <id>").action((id) => console.log(JSON.stringify(applyMinjInjectionV2(id), null, 2)));
33
+ mi.command("fail-injection-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(failMinjInjectionV2(id, reason), null, 2)));
34
+ mi.command("cancel-injection-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelMinjInjectionV2(id, reason), null, 2)));
35
+ mi.command("get-injection-v2 <id>").action((id) => console.log(JSON.stringify(getMinjInjectionV2(id), null, 2)));
36
+ mi.command("list-injections-v2").action(() => console.log(JSON.stringify(listMinjInjectionsV2(), null, 2)));
37
+ mi.command("auto-pause-idle-v2").action(() => console.log(JSON.stringify(autoPauseIdleMinjRulesV2(), null, 2)));
38
+ mi.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckMinjInjectionsV2(), null, 2)));
39
+ mi.command("gov-stats-v2").action(() => console.log(JSON.stringify(getMemoryInjectionGovStatsV2(), null, 2)));
40
+ mi.command("reset-state-v2").action(() => { _resetStateMemoryInjectionV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
41
+ }
@@ -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
  }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `cc orchgov` — Orchestrator V2 governance overlay.
3
+ *
4
+ * In-memory governance for orchestrator profiles + task lifecycle, layered atop
5
+ * `lib/orchestrator.js`. Independent of the legacy `cc orchestrate` command.
6
+ */
7
+
8
+ import {
9
+ ORCH_PROFILE_MATURITY_V2, ORCH_TASK_LIFECYCLE_V2,
10
+ setMaxActiveOrchProfilesPerOwnerV2, getMaxActiveOrchProfilesPerOwnerV2,
11
+ setMaxPendingOrchTasksPerProfileV2, getMaxPendingOrchTasksPerProfileV2,
12
+ setOrchProfileIdleMsV2, getOrchProfileIdleMsV2,
13
+ setOrchTaskStuckMsV2, getOrchTaskStuckMsV2,
14
+ registerOrchProfileV2, activateOrchProfileV2, pauseOrchProfileV2, retireOrchProfileV2, touchOrchProfileV2, getOrchProfileV2, listOrchProfilesV2,
15
+ createOrchTaskV2, dispatchOrchTaskV2, completeOrchTaskV2, failOrchTaskV2, cancelOrchTaskV2, getOrchTaskV2, listOrchTasksV2,
16
+ autoPauseIdleOrchProfilesV2, autoFailStuckOrchTasksV2, getOrchestratorGovStatsV2, _resetStateOrchestratorV2,
17
+ } from "../lib/orchestrator.js";
18
+
19
+ export function registerOrchGovCommand(program) {
20
+ const og = program.command("orchgov").description("Orchestrator V2 governance");
21
+ og.command("enums-v2").action(() => console.log(JSON.stringify({ profileMaturity: ORCH_PROFILE_MATURITY_V2, taskLifecycle: ORCH_TASK_LIFECYCLE_V2 }, null, 2)));
22
+ og.command("config-v2").action(() => console.log(JSON.stringify({ maxActiveOrchProfilesPerOwner: getMaxActiveOrchProfilesPerOwnerV2(), maxPendingOrchTasksPerProfile: getMaxPendingOrchTasksPerProfileV2(), orchProfileIdleMs: getOrchProfileIdleMsV2(), orchTaskStuckMs: getOrchTaskStuckMsV2() }, null, 2)));
23
+ og.command("set-max-active-v2 <n>").action((n) => { setMaxActiveOrchProfilesPerOwnerV2(Number(n)); console.log("ok"); });
24
+ og.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingOrchTasksPerProfileV2(Number(n)); console.log("ok"); });
25
+ og.command("set-idle-ms-v2 <n>").action((n) => { setOrchProfileIdleMsV2(Number(n)); console.log("ok"); });
26
+ og.command("set-stuck-ms-v2 <n>").action((n) => { setOrchTaskStuckMsV2(Number(n)); console.log("ok"); });
27
+ og.command("register-profile-v2 <id> <owner>").option("--source <s>", "source").action((id, owner, o) => console.log(JSON.stringify(registerOrchProfileV2({ id, owner, source: o.source }), null, 2)));
28
+ og.command("activate-profile-v2 <id>").action((id) => console.log(JSON.stringify(activateOrchProfileV2(id), null, 2)));
29
+ og.command("pause-profile-v2 <id>").action((id) => console.log(JSON.stringify(pauseOrchProfileV2(id), null, 2)));
30
+ og.command("retire-profile-v2 <id>").action((id) => console.log(JSON.stringify(retireOrchProfileV2(id), null, 2)));
31
+ og.command("touch-profile-v2 <id>").action((id) => console.log(JSON.stringify(touchOrchProfileV2(id), null, 2)));
32
+ og.command("get-profile-v2 <id>").action((id) => console.log(JSON.stringify(getOrchProfileV2(id), null, 2)));
33
+ og.command("list-profiles-v2").action(() => console.log(JSON.stringify(listOrchProfilesV2(), null, 2)));
34
+ og.command("create-task-v2 <id> <profileId>").option("--prompt <p>", "prompt").action((id, profileId, o) => console.log(JSON.stringify(createOrchTaskV2({ id, profileId, prompt: o.prompt }), null, 2)));
35
+ og.command("dispatch-task-v2 <id>").action((id) => console.log(JSON.stringify(dispatchOrchTaskV2(id), null, 2)));
36
+ og.command("complete-task-v2 <id>").action((id) => console.log(JSON.stringify(completeOrchTaskV2(id), null, 2)));
37
+ og.command("fail-task-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(failOrchTaskV2(id, reason), null, 2)));
38
+ og.command("cancel-task-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelOrchTaskV2(id, reason), null, 2)));
39
+ og.command("get-task-v2 <id>").action((id) => console.log(JSON.stringify(getOrchTaskV2(id), null, 2)));
40
+ og.command("list-tasks-v2").action(() => console.log(JSON.stringify(listOrchTasksV2(), null, 2)));
41
+ og.command("auto-pause-idle-v2").action(() => console.log(JSON.stringify(autoPauseIdleOrchProfilesV2(), null, 2)));
42
+ og.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckOrchTasksV2(), null, 2)));
43
+ og.command("gov-stats-v2").action(() => console.log(JSON.stringify(getOrchestratorGovStatsV2(), null, 2)));
44
+ og.command("reset-state-v2").action(() => { _resetStateOrchestratorV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
45
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * PDF Parser V2 governance commands — `cc pdfp ...`
3
+ * 在内存中治理 PDFP profile (pending/active/stale/archived) + parse 生命周期。
4
+ */
5
+ import {
6
+ PDFP_PROFILE_MATURITY_V2,
7
+ PDFP_PARSE_LIFECYCLE_V2,
8
+ registerPdfpProfileV2,
9
+ activatePdfpProfileV2,
10
+ stalePdfpProfileV2,
11
+ archivePdfpProfileV2,
12
+ touchPdfpProfileV2,
13
+ getPdfpProfileV2,
14
+ listPdfpProfilesV2,
15
+ createPdfpParseV2,
16
+ parsingPdfpParseV2,
17
+ parsePdfpParseV2,
18
+ failPdfpParseV2,
19
+ cancelPdfpParseV2,
20
+ getPdfpParseV2,
21
+ listPdfpParsesV2,
22
+ setMaxActivePdfpProfilesPerOwnerV2,
23
+ getMaxActivePdfpProfilesPerOwnerV2,
24
+ setMaxPendingPdfpParsesPerProfileV2,
25
+ getMaxPendingPdfpParsesPerProfileV2,
26
+ setPdfpProfileIdleMsV2,
27
+ getPdfpProfileIdleMsV2,
28
+ setPdfpParseStuckMsV2,
29
+ getPdfpParseStuckMsV2,
30
+ autoStaleIdlePdfpProfilesV2,
31
+ autoFailStuckPdfpParsesV2,
32
+ getPdfParserGovStatsV2,
33
+ } from "../lib/pdf-parser.js";
34
+
35
+ export function registerPdfpCommand(program) {
36
+ const p = program
37
+ .command("pdfp")
38
+ .description("PDF Parser V2 governance (in-memory, CLI v0.143.0)");
39
+
40
+ p.command("enums-v2").action(() => console.log(JSON.stringify({ PDFP_PROFILE_MATURITY_V2, PDFP_PARSE_LIFECYCLE_V2 }, null, 2)));
41
+ p.command("register-profile-v2")
42
+ .requiredOption("--id <id>")
43
+ .requiredOption("--owner <owner>")
44
+ .option("--encoding <encoding>", "encoding", "utf-8")
45
+ .action((o) => console.log(JSON.stringify(registerPdfpProfileV2(o), null, 2)));
46
+ p.command("activate-profile-v2 <id>").action((id) => console.log(JSON.stringify(activatePdfpProfileV2(id), null, 2)));
47
+ p.command("stale-profile-v2 <id>").action((id) => console.log(JSON.stringify(stalePdfpProfileV2(id), null, 2)));
48
+ p.command("archive-profile-v2 <id>").action((id) => console.log(JSON.stringify(archivePdfpProfileV2(id), null, 2)));
49
+ p.command("touch-profile-v2 <id>").action((id) => console.log(JSON.stringify(touchPdfpProfileV2(id), null, 2)));
50
+ p.command("get-profile-v2 <id>").action((id) => console.log(JSON.stringify(getPdfpProfileV2(id), null, 2)));
51
+ p.command("list-profiles-v2").action(() => console.log(JSON.stringify(listPdfpProfilesV2(), null, 2)));
52
+
53
+ p.command("create-parse-v2")
54
+ .requiredOption("--id <id>")
55
+ .requiredOption("--profile-id <profileId>")
56
+ .option("--path <path>", "pdf path", "")
57
+ .action((o) => console.log(JSON.stringify(createPdfpParseV2(o), null, 2)));
58
+ p.command("parsing-parse-v2 <id>").action((id) => console.log(JSON.stringify(parsingPdfpParseV2(id), null, 2)));
59
+ p.command("parse-parse-v2 <id>").action((id) => console.log(JSON.stringify(parsePdfpParseV2(id), null, 2)));
60
+ p.command("fail-parse-v2 <id>").option("--reason <r>").action((id, o) => console.log(JSON.stringify(failPdfpParseV2(id, o.reason), null, 2)));
61
+ p.command("cancel-parse-v2 <id>").option("--reason <r>").action((id, o) => console.log(JSON.stringify(cancelPdfpParseV2(id, o.reason), null, 2)));
62
+ p.command("get-parse-v2 <id>").action((id) => console.log(JSON.stringify(getPdfpParseV2(id), null, 2)));
63
+ p.command("list-parses-v2").action(() => console.log(JSON.stringify(listPdfpParsesV2(), null, 2)));
64
+
65
+ p.command("config-v2").action(() => console.log(JSON.stringify({
66
+ maxActivePdfpProfilesPerOwner: getMaxActivePdfpProfilesPerOwnerV2(),
67
+ maxPendingPdfpParsesPerProfile: getMaxPendingPdfpParsesPerProfileV2(),
68
+ pdfpProfileIdleMs: getPdfpProfileIdleMsV2(),
69
+ pdfpParseStuckMs: getPdfpParseStuckMsV2(),
70
+ }, null, 2)));
71
+ p.command("set-max-active-profiles-v2 <n>").action((n) => { setMaxActivePdfpProfilesPerOwnerV2(Number(n)); console.log(JSON.stringify({ maxActivePdfpProfilesPerOwner: getMaxActivePdfpProfilesPerOwnerV2() }, null, 2)); });
72
+ p.command("set-max-pending-parses-v2 <n>").action((n) => { setMaxPendingPdfpParsesPerProfileV2(Number(n)); console.log(JSON.stringify({ maxPendingPdfpParsesPerProfile: getMaxPendingPdfpParsesPerProfileV2() }, null, 2)); });
73
+ p.command("set-profile-idle-ms-v2 <ms>").action((ms) => { setPdfpProfileIdleMsV2(Number(ms)); console.log(JSON.stringify({ pdfpProfileIdleMs: getPdfpProfileIdleMsV2() }, null, 2)); });
74
+ p.command("set-parse-stuck-ms-v2 <ms>").action((ms) => { setPdfpParseStuckMsV2(Number(ms)); console.log(JSON.stringify({ pdfpParseStuckMs: getPdfpParseStuckMsV2() }, null, 2)); });
75
+ p.command("auto-stale-idle-v2").action(() => console.log(JSON.stringify(autoStaleIdlePdfpProfilesV2(), null, 2)));
76
+ p.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckPdfpParsesV2(), null, 2)));
77
+ p.command("gov-stats-v2").action(() => console.log(JSON.stringify(getPdfParserGovStatsV2(), null, 2)));
78
+ }
@@ -429,5 +429,44 @@ export function registerPerfCommand(program) {
429
429
  console.log(`Recent history: ${r.recentHistory.length}`);
430
430
  });
431
431
 
432
+ _registerPerfV2(perf);
432
433
  program.addCommand(perf);
433
434
  }
435
+
436
+ import {
437
+ PERF_TUNING_PROFILE_MATURITY_V2, PERF_BENCH_LIFECYCLE_V2,
438
+ setMaxActivePerfTuningProfilesPerOwnerV2, getMaxActivePerfTuningProfilesPerOwnerV2,
439
+ setMaxPendingPerfBenchesPerProfileV2, getMaxPendingPerfBenchesPerProfileV2,
440
+ setPerfTuningProfileIdleMsV2, getPerfTuningProfileIdleMsV2,
441
+ setPerfBenchStuckMsV2, getPerfBenchStuckMsV2,
442
+ registerPerfTuningProfileV2, activatePerfTuningProfileV2, stalePerfTuningProfileV2, decommissionPerfTuningProfileV2, touchPerfTuningProfileV2, getPerfTuningProfileV2, listPerfTuningProfilesV2,
443
+ createPerfBenchV2, startPerfBenchV2, completePerfBenchV2, failPerfBenchV2, cancelPerfBenchV2, getPerfBenchV2, listPerfBenchesV2,
444
+ autoStaleIdlePerfTuningProfilesV2, autoFailStuckPerfBenchesV2, getPerfTuningGovStatsV2, _resetStatePerfTuningV2,
445
+ } from "../lib/perf-tuning.js";
446
+
447
+ function _registerPerfV2(parent) {
448
+ parent.command("enums-v2").action(() => console.log(JSON.stringify({ profileMaturity: PERF_TUNING_PROFILE_MATURITY_V2, benchLifecycle: PERF_BENCH_LIFECYCLE_V2 }, null, 2)));
449
+ parent.command("config-v2").action(() => console.log(JSON.stringify({ maxActivePerfTuningProfilesPerOwner: getMaxActivePerfTuningProfilesPerOwnerV2(), maxPendingPerfBenchesPerProfile: getMaxPendingPerfBenchesPerProfileV2(), perfTuningProfileIdleMs: getPerfTuningProfileIdleMsV2(), perfBenchStuckMs: getPerfBenchStuckMsV2() }, null, 2)));
450
+ parent.command("set-max-active-v2 <n>").action((n) => { setMaxActivePerfTuningProfilesPerOwnerV2(Number(n)); console.log("ok"); });
451
+ parent.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingPerfBenchesPerProfileV2(Number(n)); console.log("ok"); });
452
+ parent.command("set-idle-ms-v2 <n>").action((n) => { setPerfTuningProfileIdleMsV2(Number(n)); console.log("ok"); });
453
+ parent.command("set-stuck-ms-v2 <n>").action((n) => { setPerfBenchStuckMsV2(Number(n)); console.log("ok"); });
454
+ parent.command("register-profile-v2 <id> <owner>").option("--target <t>", "target").action((id, owner, o) => console.log(JSON.stringify(registerPerfTuningProfileV2({ id, owner, target: o.target }), null, 2)));
455
+ parent.command("activate-profile-v2 <id>").action((id) => console.log(JSON.stringify(activatePerfTuningProfileV2(id), null, 2)));
456
+ parent.command("stale-profile-v2 <id>").action((id) => console.log(JSON.stringify(stalePerfTuningProfileV2(id), null, 2)));
457
+ parent.command("decommission-profile-v2 <id>").action((id) => console.log(JSON.stringify(decommissionPerfTuningProfileV2(id), null, 2)));
458
+ parent.command("touch-profile-v2 <id>").action((id) => console.log(JSON.stringify(touchPerfTuningProfileV2(id), null, 2)));
459
+ parent.command("get-profile-v2 <id>").action((id) => console.log(JSON.stringify(getPerfTuningProfileV2(id), null, 2)));
460
+ parent.command("list-profiles-v2").action(() => console.log(JSON.stringify(listPerfTuningProfilesV2(), null, 2)));
461
+ parent.command("create-bench-v2 <id> <profileId>").option("--scenario <s>", "scenario").action((id, profileId, o) => console.log(JSON.stringify(createPerfBenchV2({ id, profileId, scenario: o.scenario }), null, 2)));
462
+ parent.command("start-bench-v2 <id>").action((id) => console.log(JSON.stringify(startPerfBenchV2(id), null, 2)));
463
+ parent.command("complete-bench-v2 <id>").action((id) => console.log(JSON.stringify(completePerfBenchV2(id), null, 2)));
464
+ parent.command("fail-bench-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(failPerfBenchV2(id, reason), null, 2)));
465
+ parent.command("cancel-bench-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelPerfBenchV2(id, reason), null, 2)));
466
+ parent.command("get-bench-v2 <id>").action((id) => console.log(JSON.stringify(getPerfBenchV2(id), null, 2)));
467
+ parent.command("list-benches-v2").action(() => console.log(JSON.stringify(listPerfBenchesV2(), null, 2)));
468
+ parent.command("auto-stale-idle-v2").action(() => console.log(JSON.stringify(autoStaleIdlePerfTuningProfilesV2(), null, 2)));
469
+ parent.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckPerfBenchesV2(), null, 2)));
470
+ parent.command("gov-stats-v2").action(() => console.log(JSON.stringify(getPerfTuningGovStatsV2(), null, 2)));
471
+ parent.command("reset-state-v2").action(() => { _resetStatePerfTuningV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
472
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `cc perm` — Permission Engine V2 governance overlay.
3
+ *
4
+ * In-memory governance for permission rules + check lifecycle, layered atop
5
+ * `lib/permission-engine.js`. Independent of legacy permission helpers.
6
+ */
7
+
8
+ import {
9
+ PERM_RULE_MATURITY_V2, PERM_CHECK_LIFECYCLE_V2,
10
+ setMaxActivePermRulesPerOwnerV2, getMaxActivePermRulesPerOwnerV2,
11
+ setMaxPendingPermChecksPerRuleV2, getMaxPendingPermChecksPerRuleV2,
12
+ setPermRuleIdleMsV2, getPermRuleIdleMsV2,
13
+ setPermCheckStuckMsV2, getPermCheckStuckMsV2,
14
+ registerPermRuleV2, activatePermRuleV2, disablePermRuleV2, retirePermRuleV2, touchPermRuleV2, getPermRuleV2, listPermRulesV2,
15
+ createPermCheckV2, evaluatePermCheckV2, allowPermCheckV2, denyPermCheckV2, cancelPermCheckV2, getPermCheckV2, listPermChecksV2,
16
+ autoDisableIdlePermRulesV2, autoDenyStuckPermChecksV2, getPermissionEngineGovStatsV2, _resetStatePermissionEngineV2,
17
+ } from "../lib/permission-engine.js";
18
+
19
+ export function registerPermCommand(program) {
20
+ const pe = program.command("perm").description("Permission Engine V2 governance");
21
+ pe.command("enums-v2").action(() => console.log(JSON.stringify({ ruleMaturity: PERM_RULE_MATURITY_V2, checkLifecycle: PERM_CHECK_LIFECYCLE_V2 }, null, 2)));
22
+ pe.command("config-v2").action(() => console.log(JSON.stringify({ maxActivePermRulesPerOwner: getMaxActivePermRulesPerOwnerV2(), maxPendingPermChecksPerRule: getMaxPendingPermChecksPerRuleV2(), permRuleIdleMs: getPermRuleIdleMsV2(), permCheckStuckMs: getPermCheckStuckMsV2() }, null, 2)));
23
+ pe.command("set-max-active-v2 <n>").action((n) => { setMaxActivePermRulesPerOwnerV2(Number(n)); console.log("ok"); });
24
+ pe.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingPermChecksPerRuleV2(Number(n)); console.log("ok"); });
25
+ pe.command("set-idle-ms-v2 <n>").action((n) => { setPermRuleIdleMsV2(Number(n)); console.log("ok"); });
26
+ pe.command("set-stuck-ms-v2 <n>").action((n) => { setPermCheckStuckMsV2(Number(n)); console.log("ok"); });
27
+ pe.command("register-rule-v2 <id> <owner>").option("--scope <s>", "scope").action((id, owner, o) => console.log(JSON.stringify(registerPermRuleV2({ id, owner, scope: o.scope }), null, 2)));
28
+ pe.command("activate-rule-v2 <id>").action((id) => console.log(JSON.stringify(activatePermRuleV2(id), null, 2)));
29
+ pe.command("disable-rule-v2 <id>").action((id) => console.log(JSON.stringify(disablePermRuleV2(id), null, 2)));
30
+ pe.command("retire-rule-v2 <id>").action((id) => console.log(JSON.stringify(retirePermRuleV2(id), null, 2)));
31
+ pe.command("touch-rule-v2 <id>").action((id) => console.log(JSON.stringify(touchPermRuleV2(id), null, 2)));
32
+ pe.command("get-rule-v2 <id>").action((id) => console.log(JSON.stringify(getPermRuleV2(id), null, 2)));
33
+ pe.command("list-rules-v2").action(() => console.log(JSON.stringify(listPermRulesV2(), null, 2)));
34
+ pe.command("create-check-v2 <id> <ruleId>").option("--subject <s>", "subject").action((id, ruleId, o) => console.log(JSON.stringify(createPermCheckV2({ id, ruleId, subject: o.subject }), null, 2)));
35
+ pe.command("evaluate-check-v2 <id>").action((id) => console.log(JSON.stringify(evaluatePermCheckV2(id), null, 2)));
36
+ pe.command("allow-check-v2 <id>").action((id) => console.log(JSON.stringify(allowPermCheckV2(id), null, 2)));
37
+ pe.command("deny-check-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(denyPermCheckV2(id, reason), null, 2)));
38
+ pe.command("cancel-check-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelPermCheckV2(id, reason), null, 2)));
39
+ pe.command("get-check-v2 <id>").action((id) => console.log(JSON.stringify(getPermCheckV2(id), null, 2)));
40
+ pe.command("list-checks-v2").action(() => console.log(JSON.stringify(listPermChecksV2(), null, 2)));
41
+ pe.command("auto-disable-idle-v2").action(() => console.log(JSON.stringify(autoDisableIdlePermRulesV2(), null, 2)));
42
+ pe.command("auto-deny-stuck-v2").action(() => console.log(JSON.stringify(autoDenyStuckPermChecksV2(), null, 2)));
43
+ pe.command("gov-stats-v2").action(() => console.log(JSON.stringify(getPermissionEngineGovStatsV2(), null, 2)));
44
+ pe.command("reset-state-v2").action(() => { _resetStatePermissionEngineV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
45
+ }
@@ -445,5 +445,61 @@ export function registerPipelineCommand(program) {
445
445
  _json(getStats(db));
446
446
  });
447
447
 
448
- program.addCommand(pipeline);
448
+
449
+ _registerPipelineV2Commands(pipeline);
450
+ program.addCommand(pipeline);
451
+ }
452
+ function _registerPipelineV2Commands(parent) {
453
+ const L = async () => await import("../lib/pipeline-orchestrator.js");
454
+
455
+ parent.command("enums-v2").description("Show V2 enums (pipeline maturity + run lifecycle)")
456
+ .action(async () => { const m = await L(); console.log(JSON.stringify({ pipelineMaturity: m.PIPELINE_MATURITY_V2, runLifecycle: m.PIPELINE_RUN_LIFECYCLE_V2 }, null, 2)); });
457
+ parent.command("config-v2").description("Show V2 config thresholds")
458
+ .action(async () => { const m = await L(); console.log(JSON.stringify({ maxActivePipelinesPerOwner: m.getMaxActivePipelinesPerOwnerV2(), maxPendingPipelineRunsPerPipeline: m.getMaxPendingPipelineRunsPerPipelineV2(), pipelineIdleMs: m.getPipelineIdleMsV2(), pipelineRunStuckMs: m.getPipelineRunStuckMsV2() }, null, 2)); });
459
+ parent.command("set-max-active-pipelines-v2 <n>").description("Set max active pipelines per owner")
460
+ .action(async (n) => { const m = await L(); m.setMaxActivePipelinesPerOwnerV2(Number(n)); console.log("ok"); });
461
+ parent.command("set-max-pending-runs-v2 <n>").description("Set max pending runs per pipeline")
462
+ .action(async (n) => { const m = await L(); m.setMaxPendingPipelineRunsPerPipelineV2(Number(n)); console.log("ok"); });
463
+ parent.command("set-pipeline-idle-ms-v2 <n>").description("Set pipeline idle threshold (ms)")
464
+ .action(async (n) => { const m = await L(); m.setPipelineIdleMsV2(Number(n)); console.log("ok"); });
465
+ parent.command("set-run-stuck-ms-v2 <n>").description("Set run stuck threshold (ms)")
466
+ .action(async (n) => { const m = await L(); m.setPipelineRunStuckMsV2(Number(n)); console.log("ok"); });
467
+
468
+ parent.command("register-pipeline-v2 <id> <owner>").description("Register V2 pipeline")
469
+ .option("--name <n>", "Pipeline name").action(async (id, owner, o) => { const m = await L(); console.log(JSON.stringify(m.registerPipelineV2({ id, owner, name: o.name }), null, 2)); });
470
+ parent.command("activate-pipeline-v2 <id>").description("Activate pipeline")
471
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.activatePipelineV2(id), null, 2)); });
472
+ parent.command("pause-pipeline-v2 <id>").description("Pause pipeline")
473
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.pausePipelineV2(id), null, 2)); });
474
+ parent.command("archive-pipeline-v2 <id>").description("Archive pipeline (terminal)")
475
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.archivePipelineV2(id), null, 2)); });
476
+ parent.command("touch-pipeline-v2 <id>").description("Touch pipeline lastTouchedAt")
477
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.touchPipelineV2(id), null, 2)); });
478
+ parent.command("get-pipeline-v2 <id>").description("Get V2 pipeline")
479
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.getPipelineV2(id), null, 2)); });
480
+ parent.command("list-pipelines-v2").description("List all V2 pipelines")
481
+ .action(async () => { const m = await L(); console.log(JSON.stringify(m.listPipelinesV2(), null, 2)); });
482
+
483
+ parent.command("create-run-v2 <id> <pipelineId>").description("Create V2 pipeline run (queued)")
484
+ .option("--trigger <t>", "Trigger", "manual").action(async (id, pipelineId, o) => { const m = await L(); console.log(JSON.stringify(m.createPipelineRunV2({ id, pipelineId, trigger: o.trigger }), null, 2)); });
485
+ parent.command("start-run-v2 <id>").description("Start run (queued→running)")
486
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.startPipelineRunV2(id), null, 2)); });
487
+ parent.command("complete-run-v2 <id>").description("Complete run (running→completed)")
488
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.completePipelineRunV2(id), null, 2)); });
489
+ parent.command("fail-run-v2 <id> [reason]").description("Fail run")
490
+ .action(async (id, reason) => { const m = await L(); console.log(JSON.stringify(m.failPipelineRunV2(id, reason), null, 2)); });
491
+ parent.command("cancel-run-v2 <id> [reason]").description("Cancel run")
492
+ .action(async (id, reason) => { const m = await L(); console.log(JSON.stringify(m.cancelPipelineRunV2(id, reason), null, 2)); });
493
+ parent.command("get-run-v2 <id>").description("Get V2 run")
494
+ .action(async (id) => { const m = await L(); console.log(JSON.stringify(m.getPipelineRunV2(id), null, 2)); });
495
+ parent.command("list-runs-v2").description("List all V2 runs")
496
+ .action(async () => { const m = await L(); console.log(JSON.stringify(m.listPipelineRunsV2(), null, 2)); });
497
+
498
+ parent.command("auto-pause-idle-v2").description("Auto-pause idle active pipelines")
499
+ .action(async () => { const m = await L(); console.log(JSON.stringify(m.autoPauseIdlePipelinesV2(), null, 2)); });
500
+ parent.command("auto-fail-stuck-v2").description("Auto-fail stuck running runs")
501
+ .action(async () => { const m = await L(); console.log(JSON.stringify(m.autoFailStuckPipelineRunsV2(), null, 2)); });
502
+
503
+ parent.command("gov-stats-v2").description("V2 governance aggregate stats")
504
+ .action(async () => { const m = await L(); console.log(JSON.stringify(m.getPipelineOrchestratorGovStatsV2(), null, 2)); });
449
505
  }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `cc planmode` — Plan Mode V2 governance overlay.
3
+ *
4
+ * In-memory governance for plan profiles + step lifecycle, layered atop
5
+ * `lib/plan-mode.js`. Independent of any legacy plan invocation.
6
+ */
7
+
8
+ import {
9
+ PLAN_PROFILE_MATURITY_V2, PLAN_STEP_LIFECYCLE_V2,
10
+ setMaxActivePlanProfilesPerOwnerV2, getMaxActivePlanProfilesPerOwnerV2,
11
+ setMaxPendingPlanStepsPerProfileV2, getMaxPendingPlanStepsPerProfileV2,
12
+ setPlanProfileIdleMsV2, getPlanProfileIdleMsV2,
13
+ setPlanStepStuckMsV2, getPlanStepStuckMsV2,
14
+ registerPlanProfileV2, activatePlanProfileV2, pausePlanProfileV2, archivePlanProfileV2, touchPlanProfileV2, getPlanProfileV2, listPlanProfilesV2,
15
+ createPlanStepV2, startPlanStepV2, completePlanStepV2, failPlanStepV2, cancelPlanStepV2, getPlanStepV2, listPlanStepsV2,
16
+ autoPauseIdlePlanProfilesV2, autoFailStuckPlanStepsV2, getPlanModeGovStatsV2, _resetStatePlanModeV2,
17
+ } from "../lib/plan-mode.js";
18
+
19
+ export function registerPlanModeCommand(program) {
20
+ const pm = program.command("planmode").description("Plan Mode V2 governance");
21
+ pm.command("enums-v2").action(() => console.log(JSON.stringify({ profileMaturity: PLAN_PROFILE_MATURITY_V2, stepLifecycle: PLAN_STEP_LIFECYCLE_V2 }, null, 2)));
22
+ pm.command("config-v2").action(() => console.log(JSON.stringify({ maxActivePlanProfilesPerOwner: getMaxActivePlanProfilesPerOwnerV2(), maxPendingPlanStepsPerProfile: getMaxPendingPlanStepsPerProfileV2(), planProfileIdleMs: getPlanProfileIdleMsV2(), planStepStuckMs: getPlanStepStuckMsV2() }, null, 2)));
23
+ pm.command("set-max-active-v2 <n>").action((n) => { setMaxActivePlanProfilesPerOwnerV2(Number(n)); console.log("ok"); });
24
+ pm.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingPlanStepsPerProfileV2(Number(n)); console.log("ok"); });
25
+ pm.command("set-idle-ms-v2 <n>").action((n) => { setPlanProfileIdleMsV2(Number(n)); console.log("ok"); });
26
+ pm.command("set-stuck-ms-v2 <n>").action((n) => { setPlanStepStuckMsV2(Number(n)); console.log("ok"); });
27
+ pm.command("register-profile-v2 <id> <owner>").option("--goal <g>", "goal").action((id, owner, o) => console.log(JSON.stringify(registerPlanProfileV2({ id, owner, goal: o.goal }), null, 2)));
28
+ pm.command("activate-profile-v2 <id>").action((id) => console.log(JSON.stringify(activatePlanProfileV2(id), null, 2)));
29
+ pm.command("pause-profile-v2 <id>").action((id) => console.log(JSON.stringify(pausePlanProfileV2(id), null, 2)));
30
+ pm.command("archive-profile-v2 <id>").action((id) => console.log(JSON.stringify(archivePlanProfileV2(id), null, 2)));
31
+ pm.command("touch-profile-v2 <id>").action((id) => console.log(JSON.stringify(touchPlanProfileV2(id), null, 2)));
32
+ pm.command("get-profile-v2 <id>").action((id) => console.log(JSON.stringify(getPlanProfileV2(id), null, 2)));
33
+ pm.command("list-profiles-v2").action(() => console.log(JSON.stringify(listPlanProfilesV2(), null, 2)));
34
+ pm.command("create-step-v2 <id> <profileId>").option("--action <a>", "action").action((id, profileId, o) => console.log(JSON.stringify(createPlanStepV2({ id, profileId, action: o.action }), null, 2)));
35
+ pm.command("start-step-v2 <id>").action((id) => console.log(JSON.stringify(startPlanStepV2(id), null, 2)));
36
+ pm.command("complete-step-v2 <id>").action((id) => console.log(JSON.stringify(completePlanStepV2(id), null, 2)));
37
+ pm.command("fail-step-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(failPlanStepV2(id, reason), null, 2)));
38
+ pm.command("cancel-step-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelPlanStepV2(id, reason), null, 2)));
39
+ pm.command("get-step-v2 <id>").action((id) => console.log(JSON.stringify(getPlanStepV2(id), null, 2)));
40
+ pm.command("list-steps-v2").action(() => console.log(JSON.stringify(listPlanStepsV2(), null, 2)));
41
+ pm.command("auto-pause-idle-v2").action(() => console.log(JSON.stringify(autoPauseIdlePlanProfilesV2(), null, 2)));
42
+ pm.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckPlanStepsV2(), null, 2)));
43
+ pm.command("gov-stats-v2").action(() => console.log(JSON.stringify(getPlanModeGovStatsV2(), null, 2)));
44
+ pm.command("reset-state-v2").action(() => { _resetStatePlanModeV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
45
+ }