chainlesschain 0.66.0 → 0.132.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/a2a.js +380 -0
  4. package/src/commands/agent-network.js +254 -1
  5. package/src/commands/audit.js +302 -0
  6. package/src/commands/automation.js +271 -1
  7. package/src/commands/bi.js +348 -0
  8. package/src/commands/codegen.js +224 -0
  9. package/src/commands/collab.js +341 -0
  10. package/src/commands/compliance.js +1035 -0
  11. package/src/commands/cowork.js +221 -0
  12. package/src/commands/crosschain.js +218 -0
  13. package/src/commands/dbevo.js +284 -0
  14. package/src/commands/dev.js +252 -0
  15. package/src/commands/did.js +358 -0
  16. package/src/commands/dlp.js +341 -0
  17. package/src/commands/encrypt.js +341 -0
  18. package/src/commands/evomap.js +394 -0
  19. package/src/commands/export.js +256 -1
  20. package/src/commands/federation.js +283 -0
  21. package/src/commands/fusion.js +258 -0
  22. package/src/commands/governance.js +325 -0
  23. package/src/commands/hardening.js +411 -0
  24. package/src/commands/hook.js +148 -0
  25. package/src/commands/import.js +252 -0
  26. package/src/commands/incentive.js +322 -0
  27. package/src/commands/inference.js +318 -0
  28. package/src/commands/infra.js +244 -0
  29. package/src/commands/instinct.js +260 -0
  30. package/src/commands/ipfs.js +318 -0
  31. package/src/commands/kg.js +387 -0
  32. package/src/commands/llm.js +263 -0
  33. package/src/commands/lowcode.js +356 -0
  34. package/src/commands/marketplace.js +256 -0
  35. package/src/commands/mcp.js +221 -0
  36. package/src/commands/memory.js +248 -0
  37. package/src/commands/multimodal.js +296 -0
  38. package/src/commands/nlprog.js +356 -0
  39. package/src/commands/note.js +244 -0
  40. package/src/commands/ops.js +354 -0
  41. package/src/commands/orchestrate.js +166 -0
  42. package/src/commands/org.js +277 -0
  43. package/src/commands/p2p.js +390 -0
  44. package/src/commands/perception.js +290 -0
  45. package/src/commands/permmem.js +251 -0
  46. package/src/commands/plugin-ecosystem.js +273 -0
  47. package/src/commands/pqc.js +393 -0
  48. package/src/commands/privacy.js +321 -0
  49. package/src/commands/quantization.js +351 -0
  50. package/src/commands/rcache.js +271 -0
  51. package/src/commands/recommend.js +340 -0
  52. package/src/commands/reputation.js +261 -0
  53. package/src/commands/runtime.js +307 -0
  54. package/src/commands/scim.js +262 -0
  55. package/src/commands/session.js +258 -0
  56. package/src/commands/siem.js +246 -0
  57. package/src/commands/skill.js +267 -1
  58. package/src/commands/sla.js +259 -0
  59. package/src/commands/social.js +256 -0
  60. package/src/commands/sso.js +186 -1
  61. package/src/commands/stress.js +230 -0
  62. package/src/commands/sync.js +256 -0
  63. package/src/commands/tech.js +338 -0
  64. package/src/commands/tenant.js +351 -0
  65. package/src/commands/terraform.js +245 -0
  66. package/src/commands/tokens.js +269 -0
  67. package/src/commands/trust.js +249 -0
  68. package/src/commands/wallet.js +277 -0
  69. package/src/commands/workflow.js +171 -0
  70. package/src/commands/zkp.js +335 -0
  71. package/src/index.js +4 -0
  72. package/src/lib/a2a-protocol.js +451 -0
  73. package/src/lib/agent-coordinator.js +325 -0
  74. package/src/lib/agent-network.js +387 -0
  75. package/src/lib/agent-router.js +395 -0
  76. package/src/lib/aiops.js +478 -0
  77. package/src/lib/app-builder.js +239 -0
  78. package/src/lib/audit-logger.js +379 -0
  79. package/src/lib/automation-engine.js +330 -0
  80. package/src/lib/autonomous-developer.js +350 -0
  81. package/src/lib/bi-engine.js +338 -0
  82. package/src/lib/code-agent.js +323 -0
  83. package/src/lib/collaboration-governance.js +364 -0
  84. package/src/lib/community-governance.js +436 -0
  85. package/src/lib/compliance-manager.js +434 -0
  86. package/src/lib/content-recommendation.js +469 -0
  87. package/src/lib/cross-chain.js +345 -0
  88. package/src/lib/crypto-manager.js +350 -0
  89. package/src/lib/dbevo.js +338 -0
  90. package/src/lib/decentral-infra.js +340 -0
  91. package/src/lib/did-manager.js +367 -0
  92. package/src/lib/dlp-engine.js +389 -0
  93. package/src/lib/evomap-federation.js +177 -0
  94. package/src/lib/evomap-governance.js +276 -0
  95. package/src/lib/federation-hardening.js +259 -0
  96. package/src/lib/hardening-manager.js +348 -0
  97. package/src/lib/hook-manager.js +380 -0
  98. package/src/lib/inference-network.js +330 -0
  99. package/src/lib/instinct-manager.js +332 -0
  100. package/src/lib/ipfs-storage.js +334 -0
  101. package/src/lib/knowledge-exporter.js +381 -0
  102. package/src/lib/knowledge-graph.js +432 -0
  103. package/src/lib/knowledge-importer.js +379 -0
  104. package/src/lib/llm-providers.js +391 -0
  105. package/src/lib/mcp-registry.js +333 -0
  106. package/src/lib/memory-manager.js +330 -0
  107. package/src/lib/multimodal.js +346 -0
  108. package/src/lib/nl-programming.js +343 -0
  109. package/src/lib/note-versioning.js +327 -0
  110. package/src/lib/org-manager.js +323 -0
  111. package/src/lib/p2p-manager.js +387 -0
  112. package/src/lib/perception.js +346 -0
  113. package/src/lib/perf-tuning.js +4 -1
  114. package/src/lib/permanent-memory.js +320 -0
  115. package/src/lib/plugin-ecosystem.js +377 -0
  116. package/src/lib/pqc-manager.js +368 -0
  117. package/src/lib/privacy-computing.js +427 -0
  118. package/src/lib/protocol-fusion.js +417 -0
  119. package/src/lib/quantization.js +325 -0
  120. package/src/lib/reputation-optimizer.js +299 -0
  121. package/src/lib/response-cache.js +327 -0
  122. package/src/lib/scim-manager.js +329 -0
  123. package/src/lib/session-manager.js +329 -0
  124. package/src/lib/siem-exporter.js +333 -0
  125. package/src/lib/skill-loader.js +377 -0
  126. package/src/lib/skill-marketplace.js +325 -0
  127. package/src/lib/sla-manager.js +275 -0
  128. package/src/lib/social-manager.js +326 -0
  129. package/src/lib/sso-manager.js +332 -0
  130. package/src/lib/stress-tester.js +330 -0
  131. package/src/lib/sync-manager.js +326 -0
  132. package/src/lib/tech-learning-engine.js +369 -0
  133. package/src/lib/tenant-saas.js +460 -0
  134. package/src/lib/terraform-manager.js +363 -0
  135. package/src/lib/threat-intel.js +335 -0
  136. package/src/lib/token-incentive.js +293 -0
  137. package/src/lib/token-tracker.js +329 -0
  138. package/src/lib/trust-security.js +390 -0
  139. package/src/lib/ueba.js +389 -0
  140. package/src/lib/universal-runtime.js +325 -0
  141. package/src/lib/wallet-manager.js +326 -0
  142. package/src/lib/workflow-engine.js +322 -0
  143. package/src/lib/zkp-engine.js +274 -0
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Response Cache V2 commands
3
+ * `cc rcache ...` — in-memory governance layer for cache profiles
4
+ * + refresh jobs, independent of SQLite llm_cache table.
5
+ */
6
+
7
+ import { logger } from "../lib/logger.js";
8
+ import {
9
+ PROFILE_MATURITY_V2,
10
+ REFRESH_JOB_LIFECYCLE_V2,
11
+ getMaxActiveProfilesPerOwnerV2,
12
+ setMaxActiveProfilesPerOwnerV2,
13
+ getMaxPendingRefreshJobsPerProfileV2,
14
+ setMaxPendingRefreshJobsPerProfileV2,
15
+ getProfileIdleMsV2,
16
+ setProfileIdleMsV2,
17
+ getRefreshStuckMsV2,
18
+ setRefreshStuckMsV2,
19
+ registerProfileV2,
20
+ getProfileV2,
21
+ listProfilesV2,
22
+ setProfileStatusV2,
23
+ activateProfileV2,
24
+ suspendProfileV2,
25
+ archiveProfileV2,
26
+ touchProfileV2,
27
+ getActiveProfileCountV2,
28
+ createRefreshJobV2,
29
+ getRefreshJobV2,
30
+ listRefreshJobsV2,
31
+ setRefreshJobStatusV2,
32
+ startRefreshJobV2,
33
+ completeRefreshJobV2,
34
+ failRefreshJobV2,
35
+ cancelRefreshJobV2,
36
+ getPendingRefreshJobCountV2,
37
+ autoSuspendIdleProfilesV2,
38
+ autoFailStuckRefreshJobsV2,
39
+ getResponseCacheStatsV2,
40
+ } from "../lib/response-cache.js";
41
+
42
+ const out = (obj) => console.log(JSON.stringify(obj, null, 2));
43
+ const tryRun = (fn) => {
44
+ try {
45
+ fn();
46
+ } catch (err) {
47
+ logger.error(err.message);
48
+ process.exit(1);
49
+ }
50
+ };
51
+
52
+ export function registerRCacheCommand(program) {
53
+ const root = program
54
+ .command("rcache")
55
+ .description("Response cache V2 — profile maturity + refresh jobs");
56
+
57
+ root
58
+ .command("profile-maturities-v2")
59
+ .description("List V2 profile maturity states")
60
+ .action(() => out(Object.values(PROFILE_MATURITY_V2)));
61
+
62
+ root
63
+ .command("refresh-job-lifecycles-v2")
64
+ .description("List V2 refresh-job lifecycle states")
65
+ .action(() => out(Object.values(REFRESH_JOB_LIFECYCLE_V2)));
66
+
67
+ root
68
+ .command("stats-v2")
69
+ .description("V2 response cache stats")
70
+ .action(() => out(getResponseCacheStatsV2()));
71
+
72
+ root
73
+ .command("get-max-active-profiles-v2")
74
+ .description("Get max active profiles per owner (V2)")
75
+ .action(() =>
76
+ out({ maxActiveProfilesPerOwner: getMaxActiveProfilesPerOwnerV2() }),
77
+ );
78
+
79
+ root
80
+ .command("set-max-active-profiles-v2 <n>")
81
+ .description("Set max active profiles per owner (V2)")
82
+ .action((n) =>
83
+ tryRun(() => {
84
+ setMaxActiveProfilesPerOwnerV2(Number(n));
85
+ out({ maxActiveProfilesPerOwner: getMaxActiveProfilesPerOwnerV2() });
86
+ }),
87
+ );
88
+
89
+ root
90
+ .command("get-max-pending-refresh-jobs-v2")
91
+ .description("Get max pending refresh jobs per profile (V2)")
92
+ .action(() =>
93
+ out({
94
+ maxPendingRefreshJobsPerProfile: getMaxPendingRefreshJobsPerProfileV2(),
95
+ }),
96
+ );
97
+
98
+ root
99
+ .command("set-max-pending-refresh-jobs-v2 <n>")
100
+ .description("Set max pending refresh jobs per profile (V2)")
101
+ .action((n) =>
102
+ tryRun(() => {
103
+ setMaxPendingRefreshJobsPerProfileV2(Number(n));
104
+ out({
105
+ maxPendingRefreshJobsPerProfile:
106
+ getMaxPendingRefreshJobsPerProfileV2(),
107
+ });
108
+ }),
109
+ );
110
+
111
+ root
112
+ .command("get-profile-idle-ms-v2")
113
+ .description("Get profile idle threshold (V2)")
114
+ .action(() => out({ profileIdleMs: getProfileIdleMsV2() }));
115
+
116
+ root
117
+ .command("set-profile-idle-ms-v2 <ms>")
118
+ .description("Set profile idle threshold (V2)")
119
+ .action((ms) =>
120
+ tryRun(() => {
121
+ setProfileIdleMsV2(Number(ms));
122
+ out({ profileIdleMs: getProfileIdleMsV2() });
123
+ }),
124
+ );
125
+
126
+ root
127
+ .command("get-refresh-stuck-ms-v2")
128
+ .description("Get refresh-job stuck threshold (V2)")
129
+ .action(() => out({ refreshStuckMs: getRefreshStuckMsV2() }));
130
+
131
+ root
132
+ .command("set-refresh-stuck-ms-v2 <ms>")
133
+ .description("Set refresh-job stuck threshold (V2)")
134
+ .action((ms) =>
135
+ tryRun(() => {
136
+ setRefreshStuckMsV2(Number(ms));
137
+ out({ refreshStuckMs: getRefreshStuckMsV2() });
138
+ }),
139
+ );
140
+
141
+ root
142
+ .command("active-profile-count-v2 <ownerId>")
143
+ .description("Active profile count for owner (V2)")
144
+ .action((ownerId) =>
145
+ out({ ownerId, count: getActiveProfileCountV2(ownerId) }),
146
+ );
147
+
148
+ root
149
+ .command("pending-refresh-job-count-v2 <profileId>")
150
+ .description("Pending refresh-job count for profile (V2)")
151
+ .action((profileId) =>
152
+ out({ profileId, count: getPendingRefreshJobCountV2(profileId) }),
153
+ );
154
+
155
+ root
156
+ .command("register-profile-v2 <id>")
157
+ .description("Register a V2 profile")
158
+ .requiredOption("-o, --owner <id>", "owner id")
159
+ .requiredOption("-l, --label <label>", "profile label")
160
+ .action((id, opts) =>
161
+ tryRun(() =>
162
+ out(registerProfileV2(id, { ownerId: opts.owner, label: opts.label })),
163
+ ),
164
+ );
165
+
166
+ root
167
+ .command("get-profile-v2 <id>")
168
+ .description("Get a V2 profile")
169
+ .action((id) => out(getProfileV2(id)));
170
+
171
+ root
172
+ .command("list-profiles-v2")
173
+ .description("List V2 profiles")
174
+ .option("-o, --owner <id>", "filter by owner")
175
+ .option("-s, --status <status>", "filter by status")
176
+ .action((opts) =>
177
+ out(listProfilesV2({ ownerId: opts.owner, status: opts.status })),
178
+ );
179
+
180
+ root
181
+ .command("set-profile-status-v2 <id> <next>")
182
+ .description("Set V2 profile status")
183
+ .action((id, next) => tryRun(() => out(setProfileStatusV2(id, next))));
184
+
185
+ root
186
+ .command("activate-profile-v2 <id>")
187
+ .description("Activate a V2 profile")
188
+ .action((id) => tryRun(() => out(activateProfileV2(id))));
189
+
190
+ root
191
+ .command("suspend-profile-v2 <id>")
192
+ .description("Suspend a V2 profile")
193
+ .action((id) => tryRun(() => out(suspendProfileV2(id))));
194
+
195
+ root
196
+ .command("archive-profile-v2 <id>")
197
+ .description("Archive a V2 profile")
198
+ .action((id) => tryRun(() => out(archiveProfileV2(id))));
199
+
200
+ root
201
+ .command("touch-profile-v2 <id>")
202
+ .description("Touch a V2 profile")
203
+ .action((id) => tryRun(() => out(touchProfileV2(id))));
204
+
205
+ root
206
+ .command("create-refresh-job-v2 <id>")
207
+ .description("Create a V2 refresh job")
208
+ .requiredOption("-p, --profile <id>", "profile id")
209
+ .option("-k, --kind <kind>", "job kind", "warm")
210
+ .action((id, opts) =>
211
+ tryRun(() =>
212
+ out(
213
+ createRefreshJobV2(id, { profileId: opts.profile, kind: opts.kind }),
214
+ ),
215
+ ),
216
+ );
217
+
218
+ root
219
+ .command("get-refresh-job-v2 <id>")
220
+ .description("Get a V2 refresh job")
221
+ .action((id) => out(getRefreshJobV2(id)));
222
+
223
+ root
224
+ .command("list-refresh-jobs-v2")
225
+ .description("List V2 refresh jobs")
226
+ .option("-p, --profile <id>", "filter by profile")
227
+ .option("-s, --status <status>", "filter by status")
228
+ .action((opts) =>
229
+ out(
230
+ listRefreshJobsV2({
231
+ profileId: opts.profile,
232
+ status: opts.status,
233
+ }),
234
+ ),
235
+ );
236
+
237
+ root
238
+ .command("set-refresh-job-status-v2 <id> <next>")
239
+ .description("Set V2 refresh-job status")
240
+ .action((id, next) => tryRun(() => out(setRefreshJobStatusV2(id, next))));
241
+
242
+ root
243
+ .command("start-refresh-job-v2 <id>")
244
+ .description("Start a V2 refresh job")
245
+ .action((id) => tryRun(() => out(startRefreshJobV2(id))));
246
+
247
+ root
248
+ .command("complete-refresh-job-v2 <id>")
249
+ .description("Complete a V2 refresh job")
250
+ .action((id) => tryRun(() => out(completeRefreshJobV2(id))));
251
+
252
+ root
253
+ .command("fail-refresh-job-v2 <id>")
254
+ .description("Fail a V2 refresh job")
255
+ .action((id) => tryRun(() => out(failRefreshJobV2(id))));
256
+
257
+ root
258
+ .command("cancel-refresh-job-v2 <id>")
259
+ .description("Cancel a V2 refresh job")
260
+ .action((id) => tryRun(() => out(cancelRefreshJobV2(id))));
261
+
262
+ root
263
+ .command("auto-suspend-idle-profiles-v2")
264
+ .description("Auto-suspend idle V2 profiles")
265
+ .action(() => out(autoSuspendIdleProfilesV2()));
266
+
267
+ root
268
+ .command("auto-fail-stuck-refresh-jobs-v2")
269
+ .description("Auto-fail stuck V2 refresh jobs")
270
+ .action(() => out(autoFailStuckRefreshJobsV2()));
271
+ }
@@ -26,6 +26,44 @@ import {
26
26
  getRecommendationStats,
27
27
  getTopInterests,
28
28
  suggestTopics,
29
+ // V2 (Phase 48 V2)
30
+ PROFILE_MATURITY_V2,
31
+ FEED_LIFECYCLE_V2,
32
+ REC_DEFAULT_MAX_ACTIVE_PROFILES_PER_SEGMENT,
33
+ REC_DEFAULT_MAX_ACTIVE_FEEDS_PER_CURATOR,
34
+ REC_DEFAULT_PROFILE_IDLE_MS,
35
+ REC_DEFAULT_FEED_STALE_MS,
36
+ getDefaultMaxActiveProfilesPerSegmentV2,
37
+ getMaxActiveProfilesPerSegmentV2,
38
+ setMaxActiveProfilesPerSegmentV2,
39
+ getDefaultMaxActiveFeedsPerCuratorV2,
40
+ getMaxActiveFeedsPerCuratorV2,
41
+ setMaxActiveFeedsPerCuratorV2,
42
+ getDefaultProfileIdleMsV2,
43
+ getProfileIdleMsV2,
44
+ setProfileIdleMsV2,
45
+ getDefaultFeedStaleMsV2,
46
+ getFeedStaleMsV2,
47
+ setFeedStaleMsV2,
48
+ registerProfileV2,
49
+ getProfileV2,
50
+ setProfileMaturityV2,
51
+ activateProfile,
52
+ dormantProfile,
53
+ retireProfile,
54
+ touchProfileActivity,
55
+ registerFeedV2,
56
+ getFeedV2,
57
+ setFeedStatusV2,
58
+ activateFeed,
59
+ pauseFeed,
60
+ archiveFeed,
61
+ touchFeedPublish,
62
+ getActiveProfileCount,
63
+ getActiveFeedCount,
64
+ autoDormantIdleProfiles,
65
+ autoArchiveStaleFeeds,
66
+ getRecommendationStatsV2,
29
67
  } from "../lib/content-recommendation.js";
30
68
 
31
69
  function _dbFromCtx(cmd) {
@@ -332,5 +370,307 @@ export function registerRecommendCommand(program) {
332
370
  console.log(` ${s.action.padEnd(8)} ${s.topic} by ${s.amount}`);
333
371
  });
334
372
 
373
+ /* ── V2 (Phase 48 V2) ────────────────────────────── */
374
+
375
+ function _parseJsonFlag(value, label) {
376
+ if (value === undefined) return undefined;
377
+ try {
378
+ return JSON.parse(value);
379
+ } catch {
380
+ throw new Error(`Invalid JSON for ${label}`);
381
+ }
382
+ }
383
+
384
+ rec
385
+ .command("profile-maturities-v2")
386
+ .description("List V2 profile maturity states")
387
+ .option("--json", "JSON output")
388
+ .action((opts) => {
389
+ const out = Object.values(PROFILE_MATURITY_V2);
390
+ if (opts.json) return console.log(JSON.stringify(out, null, 2));
391
+ for (const s of out) console.log(` ${s}`);
392
+ });
393
+
394
+ rec
395
+ .command("feed-lifecycles-v2")
396
+ .description("List V2 feed lifecycle states")
397
+ .option("--json", "JSON output")
398
+ .action((opts) => {
399
+ const out = Object.values(FEED_LIFECYCLE_V2);
400
+ if (opts.json) return console.log(JSON.stringify(out, null, 2));
401
+ for (const s of out) console.log(` ${s}`);
402
+ });
403
+
404
+ rec
405
+ .command("default-max-active-profiles-per-segment")
406
+ .description("Show V2 default per-segment active-profile cap")
407
+ .action(() =>
408
+ console.log(String(getDefaultMaxActiveProfilesPerSegmentV2())),
409
+ );
410
+
411
+ rec
412
+ .command("max-active-profiles-per-segment")
413
+ .description("Show current V2 per-segment active-profile cap")
414
+ .action(() => console.log(String(getMaxActiveProfilesPerSegmentV2())));
415
+
416
+ rec
417
+ .command("set-max-active-profiles-per-segment <n>")
418
+ .description("Set V2 per-segment active-profile cap")
419
+ .action((n) =>
420
+ console.log(String(setMaxActiveProfilesPerSegmentV2(Number(n)))),
421
+ );
422
+
423
+ rec
424
+ .command("default-max-active-feeds-per-curator")
425
+ .description("Show V2 default per-curator active-feed cap")
426
+ .action(() => console.log(String(getDefaultMaxActiveFeedsPerCuratorV2())));
427
+
428
+ rec
429
+ .command("max-active-feeds-per-curator")
430
+ .description("Show current V2 per-curator active-feed cap")
431
+ .action(() => console.log(String(getMaxActiveFeedsPerCuratorV2())));
432
+
433
+ rec
434
+ .command("set-max-active-feeds-per-curator <n>")
435
+ .description("Set V2 per-curator active-feed cap")
436
+ .action((n) =>
437
+ console.log(String(setMaxActiveFeedsPerCuratorV2(Number(n)))),
438
+ );
439
+
440
+ rec
441
+ .command("default-profile-idle-ms")
442
+ .description("Show V2 default profile-idle window (ms)")
443
+ .action(() => console.log(String(getDefaultProfileIdleMsV2())));
444
+
445
+ rec
446
+ .command("profile-idle-ms")
447
+ .description("Show current V2 profile-idle window (ms)")
448
+ .action(() => console.log(String(getProfileIdleMsV2())));
449
+
450
+ rec
451
+ .command("set-profile-idle-ms <ms>")
452
+ .description("Set V2 profile-idle window (ms)")
453
+ .action((ms) => console.log(String(setProfileIdleMsV2(Number(ms)))));
454
+
455
+ rec
456
+ .command("default-feed-stale-ms")
457
+ .description("Show V2 default feed-stale window (ms)")
458
+ .action(() => console.log(String(getDefaultFeedStaleMsV2())));
459
+
460
+ rec
461
+ .command("feed-stale-ms")
462
+ .description("Show current V2 feed-stale window (ms)")
463
+ .action(() => console.log(String(getFeedStaleMsV2())));
464
+
465
+ rec
466
+ .command("set-feed-stale-ms <ms>")
467
+ .description("Set V2 feed-stale window (ms)")
468
+ .action((ms) => console.log(String(setFeedStaleMsV2(Number(ms)))));
469
+
470
+ rec
471
+ .command("active-profile-count")
472
+ .description("Count active V2 profiles (optionally scoped by segment)")
473
+ .option("-s, --segment <segment>", "Scope by segment")
474
+ .action((opts) => console.log(String(getActiveProfileCount(opts.segment))));
475
+
476
+ rec
477
+ .command("active-feed-count")
478
+ .description("Count active V2 feeds (optionally scoped by curator)")
479
+ .option("-c, --curator <curator>", "Scope by curator")
480
+ .action((opts) => console.log(String(getActiveFeedCount(opts.curator))));
481
+
482
+ rec
483
+ .command("register-profile-v2 <profile-id>")
484
+ .description("Register a V2 profile")
485
+ .requiredOption("-s, --segment <segment>", "Segment bucket")
486
+ .option("-u, --user-id <user-id>", "User id")
487
+ .option("-i, --initial-status <status>", "Initial maturity status")
488
+ .option("-m, --metadata <json>", "Metadata JSON")
489
+ .action((profileId, opts) => {
490
+ const db = _dbFromCtx(rec);
491
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
492
+ const out = registerProfileV2(db, {
493
+ profileId,
494
+ segment: opts.segment,
495
+ userId: opts.userId,
496
+ initialStatus: opts.initialStatus,
497
+ metadata,
498
+ });
499
+ console.log(JSON.stringify(out, null, 2));
500
+ });
501
+
502
+ rec
503
+ .command("profile-v2 <profile-id>")
504
+ .description("Show a V2 profile")
505
+ .action((profileId) => {
506
+ const out = getProfileV2(profileId);
507
+ console.log(out ? JSON.stringify(out, null, 2) : "null");
508
+ });
509
+
510
+ rec
511
+ .command("set-profile-maturity-v2 <profile-id> <status>")
512
+ .description("Set V2 profile maturity status")
513
+ .option("-r, --reason <reason>", "Reason")
514
+ .option("-m, --metadata <json>", "Metadata JSON (merged)")
515
+ .action((profileId, status, opts) => {
516
+ const db = _dbFromCtx(rec);
517
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
518
+ const out = setProfileMaturityV2(db, profileId, status, {
519
+ reason: opts.reason,
520
+ metadata,
521
+ });
522
+ console.log(JSON.stringify(out, null, 2));
523
+ });
524
+
525
+ rec
526
+ .command("activate-profile <profile-id>")
527
+ .description("Activate a V2 profile")
528
+ .option("-r, --reason <reason>", "Reason")
529
+ .action((profileId, opts) => {
530
+ const db = _dbFromCtx(rec);
531
+ console.log(
532
+ JSON.stringify(activateProfile(db, profileId, opts.reason), null, 2),
533
+ );
534
+ });
535
+
536
+ rec
537
+ .command("dormant-profile <profile-id>")
538
+ .description("Mark a V2 profile dormant")
539
+ .option("-r, --reason <reason>", "Reason")
540
+ .action((profileId, opts) => {
541
+ const db = _dbFromCtx(rec);
542
+ console.log(
543
+ JSON.stringify(dormantProfile(db, profileId, opts.reason), null, 2),
544
+ );
545
+ });
546
+
547
+ rec
548
+ .command("retire-profile <profile-id>")
549
+ .description("Retire a V2 profile")
550
+ .option("-r, --reason <reason>", "Reason")
551
+ .action((profileId, opts) => {
552
+ const db = _dbFromCtx(rec);
553
+ console.log(
554
+ JSON.stringify(retireProfile(db, profileId, opts.reason), null, 2),
555
+ );
556
+ });
557
+
558
+ rec
559
+ .command("touch-profile-activity <profile-id>")
560
+ .description("Bump lastActivityAt on a V2 profile")
561
+ .action((profileId) => {
562
+ console.log(JSON.stringify(touchProfileActivity(profileId), null, 2));
563
+ });
564
+
565
+ rec
566
+ .command("register-feed-v2 <feed-id>")
567
+ .description("Register a V2 feed")
568
+ .requiredOption("-c, --curator-id <curator>", "Curator id")
569
+ .option("-t, --topics <csv>", "Comma-separated topics")
570
+ .option("-i, --initial-status <status>", "Initial lifecycle status")
571
+ .option("-m, --metadata <json>", "Metadata JSON")
572
+ .action((feedId, opts) => {
573
+ const db = _dbFromCtx(rec);
574
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
575
+ const topics = opts.topics
576
+ ? opts.topics
577
+ .split(",")
578
+ .map((s) => s.trim())
579
+ .filter(Boolean)
580
+ : [];
581
+ const out = registerFeedV2(db, {
582
+ feedId,
583
+ curatorId: opts.curatorId,
584
+ topics,
585
+ initialStatus: opts.initialStatus,
586
+ metadata,
587
+ });
588
+ console.log(JSON.stringify(out, null, 2));
589
+ });
590
+
591
+ rec
592
+ .command("feed-v2 <feed-id>")
593
+ .description("Show a V2 feed")
594
+ .action((feedId) => {
595
+ const out = getFeedV2(feedId);
596
+ console.log(out ? JSON.stringify(out, null, 2) : "null");
597
+ });
598
+
599
+ rec
600
+ .command("set-feed-status-v2 <feed-id> <status>")
601
+ .description("Set V2 feed lifecycle status")
602
+ .option("-r, --reason <reason>", "Reason")
603
+ .option("-m, --metadata <json>", "Metadata JSON (merged)")
604
+ .action((feedId, status, opts) => {
605
+ const db = _dbFromCtx(rec);
606
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
607
+ const out = setFeedStatusV2(db, feedId, status, {
608
+ reason: opts.reason,
609
+ metadata,
610
+ });
611
+ console.log(JSON.stringify(out, null, 2));
612
+ });
613
+
614
+ rec
615
+ .command("activate-feed <feed-id>")
616
+ .description("Activate a V2 feed")
617
+ .option("-r, --reason <reason>", "Reason")
618
+ .action((feedId, opts) => {
619
+ const db = _dbFromCtx(rec);
620
+ console.log(
621
+ JSON.stringify(activateFeed(db, feedId, opts.reason), null, 2),
622
+ );
623
+ });
624
+
625
+ rec
626
+ .command("pause-feed <feed-id>")
627
+ .description("Pause a V2 feed")
628
+ .option("-r, --reason <reason>", "Reason")
629
+ .action((feedId, opts) => {
630
+ const db = _dbFromCtx(rec);
631
+ console.log(JSON.stringify(pauseFeed(db, feedId, opts.reason), null, 2));
632
+ });
633
+
634
+ rec
635
+ .command("archive-feed <feed-id>")
636
+ .description("Archive a V2 feed")
637
+ .option("-r, --reason <reason>", "Reason")
638
+ .action((feedId, opts) => {
639
+ const db = _dbFromCtx(rec);
640
+ console.log(
641
+ JSON.stringify(archiveFeed(db, feedId, opts.reason), null, 2),
642
+ );
643
+ });
644
+
645
+ rec
646
+ .command("touch-feed-publish <feed-id>")
647
+ .description("Bump lastPublishAt on a V2 feed")
648
+ .action((feedId) => {
649
+ console.log(JSON.stringify(touchFeedPublish(feedId), null, 2));
650
+ });
651
+
652
+ rec
653
+ .command("auto-dormant-idle-profiles")
654
+ .description("Auto-flip idle ACTIVE V2 profiles to DORMANT")
655
+ .action(() => {
656
+ const db = _dbFromCtx(rec);
657
+ console.log(JSON.stringify(autoDormantIdleProfiles(db), null, 2));
658
+ });
659
+
660
+ rec
661
+ .command("auto-archive-stale-feeds")
662
+ .description("Auto-flip stale ACTIVE/PAUSED V2 feeds to ARCHIVED")
663
+ .action(() => {
664
+ const db = _dbFromCtx(rec);
665
+ console.log(JSON.stringify(autoArchiveStaleFeeds(db), null, 2));
666
+ });
667
+
668
+ rec
669
+ .command("stats-v2")
670
+ .description("V2 recommendation stats (counts by state + config)")
671
+ .action(() => {
672
+ console.log(JSON.stringify(getRecommendationStatsV2(), null, 2));
673
+ });
674
+
335
675
  program.addCommand(rec);
336
676
  }