scene-capability-engine 3.6.65 → 3.6.67

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 (121) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +17 -6
  3. package/README.zh.md +18 -6
  4. package/bin/scene-capability-engine.js +4 -0
  5. package/docs/README.md +2 -2
  6. package/docs/command-reference.md +382 -6
  7. package/docs/document-governance.md +3 -2
  8. package/docs/integration-modes.md +62 -478
  9. package/docs/integration-philosophy.md +56 -263
  10. package/docs/magicball-project-portfolio-contract.md +114 -2
  11. package/docs/project-management/README.md +14 -0
  12. package/docs/project-management/assurance/backup.md +3 -0
  13. package/docs/project-management/assurance/config.md +3 -0
  14. package/docs/project-management/assurance/evidence/README.md +3 -0
  15. package/docs/project-management/assurance/incidents/README.md +3 -0
  16. package/docs/project-management/assurance/logs.md +3 -0
  17. package/docs/project-management/assurance/overview.md +3 -0
  18. package/docs/project-management/assurance/recovery/README.md +3 -0
  19. package/docs/project-management/assurance/resource.md +3 -0
  20. package/docs/project-management/assurance/runbooks/README.md +3 -0
  21. package/docs/project-management/delivery/acceptance/README.md +3 -0
  22. package/docs/project-management/delivery/acceptance/evidence/README.md +3 -0
  23. package/docs/project-management/delivery/acceptance/exceptions/README.md +3 -0
  24. package/docs/project-management/delivery/acceptance/reports/README.md +3 -0
  25. package/docs/project-management/delivery/documents/changes.md +3 -0
  26. package/docs/project-management/delivery/documents/issues.md +3 -0
  27. package/docs/project-management/delivery/documents/overview.md +3 -0
  28. package/docs/project-management/delivery/documents/planning.md +3 -0
  29. package/docs/project-management/delivery/documents/requirements.md +3 -0
  30. package/docs/project-management/delivery/documents/tracking.md +3 -0
  31. package/docs/project-management/delivery/handoffs/README.md +3 -0
  32. package/docs/project-management/delivery/handoffs/evidence/README.md +3 -0
  33. package/docs/project-management/delivery/handoffs/records/README.md +3 -0
  34. package/docs/project-management/delivery/overview.md +10 -0
  35. package/docs/project-management/delivery/releases/README.md +3 -0
  36. package/docs/project-management/delivery/releases/baselines/README.md +3 -0
  37. package/docs/project-management/delivery/releases/evidence/README.md +3 -0
  38. package/docs/project-management/delivery/tables/changes.md +3 -0
  39. package/docs/project-management/delivery/tables/issues.md +3 -0
  40. package/docs/project-management/delivery/tables/planning.md +3 -0
  41. package/docs/project-management/delivery/tables/requirements.md +3 -0
  42. package/docs/project-management/delivery/tables/tracking.md +3 -0
  43. package/docs/project-management/environment/agent-discovery.md +3 -0
  44. package/docs/project-management/environment/development.md +3 -0
  45. package/docs/project-management/environment/overview.md +10 -0
  46. package/docs/project-management/environment/testing.md +3 -0
  47. package/docs/project-management/environment/version-alignment.md +3 -0
  48. package/docs/quick-start-with-ai-tools.md +68 -308
  49. package/docs/releases/README.md +2 -0
  50. package/docs/releases/v3.6.66.md +23 -0
  51. package/docs/releases/v3.6.67.md +23 -0
  52. package/docs/steering-governance.md +64 -2
  53. package/docs/zh/README.md +2 -2
  54. package/docs/zh/releases/README.md +2 -0
  55. package/docs/zh/releases/v3.6.66.md +23 -0
  56. package/docs/zh/releases/v3.6.67.md +23 -0
  57. package/lib/commands/adopt.js +24 -0
  58. package/lib/commands/native.js +158 -0
  59. package/lib/commands/project.js +95 -0
  60. package/lib/commands/semantic.js +1459 -0
  61. package/lib/commands/session.js +74 -3
  62. package/lib/commands/spec-bootstrap.js +10 -1
  63. package/lib/commands/spec-gate.js +10 -1
  64. package/lib/commands/spec-pipeline.js +10 -1
  65. package/lib/commands/studio.js +405 -30
  66. package/lib/commands/task.js +141 -7
  67. package/lib/governance/supreme-principles.js +530 -0
  68. package/lib/problem/problem-evaluator.js +4 -0
  69. package/lib/project/candidate-inspection-service.js +24 -1
  70. package/lib/project/portfolio-projection-service.js +315 -5
  71. package/lib/project/project-channel-output.js +94 -0
  72. package/lib/project/project-channel-projection.js +181 -0
  73. package/lib/project/root-onboarding-service.js +60 -8
  74. package/lib/project/semantic-shared-source-projection.js +150 -0
  75. package/lib/project/supervision-action-model.js +277 -0
  76. package/lib/project/supervision-projection-service.js +305 -5
  77. package/lib/project/target-resolution-service.js +70 -5
  78. package/lib/project/visibility-policy.js +93 -0
  79. package/lib/runtime/multi-spec-scene-session.js +8 -1
  80. package/lib/runtime/project-channel-context-store.js +387 -0
  81. package/lib/runtime/project-channel-context.js +406 -0
  82. package/lib/runtime/scene-session-binding.js +46 -0
  83. package/lib/runtime/session-store.js +186 -0
  84. package/lib/runtime/steering-contract.js +7 -1
  85. package/lib/semantic/archive-report.js +283 -0
  86. package/lib/semantic/archive-routing.js +67 -0
  87. package/lib/semantic/backflow-report.js +245 -0
  88. package/lib/semantic/capability-contract.js +30 -0
  89. package/lib/semantic/delta-export.js +145 -0
  90. package/lib/semantic/interaction-observer.js +254 -0
  91. package/lib/semantic/kernel-loader.js +881 -0
  92. package/lib/semantic/native-runtime.js +359 -0
  93. package/lib/semantic/progress-ledger.js +433 -0
  94. package/lib/semantic/replay-evaluator.js +382 -0
  95. package/lib/semantic/shared-publication.js +592 -0
  96. package/lib/semantic/shared-source-config.js +183 -0
  97. package/lib/semantic/shared-source-connect.js +139 -0
  98. package/lib/semantic/shared-source-discovery.js +98 -0
  99. package/lib/semantic/shared-sync-export.js +413 -0
  100. package/lib/semantic/shared-sync-intake.js +592 -0
  101. package/lib/semantic/shared-sync-merge.js +547 -0
  102. package/lib/semantic/shared-sync-release.js +463 -0
  103. package/lib/semantic/supreme-intent-report.js +300 -0
  104. package/lib/state/sce-state-store.js +1360 -0
  105. package/lib/steering/context-sync-manager.js +276 -25
  106. package/lib/studio/spec-intake-governor.js +39 -3
  107. package/lib/studio/task-envelope.js +35 -2
  108. package/lib/workspace/takeover-baseline.js +342 -83
  109. package/package.json +7 -2
  110. package/scripts/agent-governance-baseline-audit.js +395 -0
  111. package/scripts/clarification-first-audit.js +9 -9
  112. package/scripts/deprecated-entry-audit.js +240 -0
  113. package/scripts/release-posture-report.js +262 -0
  114. package/template/.sce/README.md +62 -228
  115. package/template/.sce/config/semantic-shared-sources.json +5 -0
  116. package/template/.sce/config/supreme-principles-policy.json +105 -0
  117. package/template/.sce/config/takeover-baseline.json +7 -0
  118. package/template/.sce/steering/CORE_PRINCIPLES.md +23 -63
  119. package/template/.sce/steering/CURRENT_CONTEXT.md +4 -0
  120. package/template/.sce/steering/RULES_GUIDE.md +17 -9
  121. package/template/README.md +32 -96
@@ -0,0 +1,1459 @@
1
+ const fs = require('fs-extra');
2
+ const chalk = require('chalk');
3
+ const { getSceStateStore } = require('../state/sce-state-store');
4
+ const { observeSemanticInteraction } = require('../semantic/interaction-observer');
5
+ const {
6
+ collectSemanticReplayInputs,
7
+ evaluateSemanticCandidate
8
+ } = require('../semantic/replay-evaluator');
9
+ const {
10
+ syncSemanticCapabilityLedger,
11
+ listPromotedSemanticBehaviors,
12
+ promoteSemanticLessonCandidate,
13
+ rollbackPromotedSemanticLesson
14
+ } = require('../semantic/kernel-loader');
15
+ const { buildSemanticProgressReport } = require('../semantic/progress-ledger');
16
+ const { buildSupremeIntentGovernanceReport } = require('../semantic/supreme-intent-report');
17
+ const { buildSemanticBackflowReport } = require('../semantic/backflow-report');
18
+ const { buildSemanticArchiveReport } = require('../semantic/archive-report');
19
+ const { exportSemanticLibraryDelta } = require('../semantic/delta-export');
20
+ const { publishSemanticLibraryDelta } = require('../semantic/shared-publication');
21
+ const { exportSemanticSharedSyncBundle } = require('../semantic/shared-sync-export');
22
+ const { syncSemanticSharedBundle, inspectSemanticSharedSource } = require('../semantic/shared-sync-intake');
23
+ const { listSemanticSharedSources, upsertSemanticSharedSource } = require('../semantic/shared-source-config');
24
+ const { connectSemanticSharedSource } = require('../semantic/shared-source-connect');
25
+ const { mergeSemanticSharedBundles } = require('../semantic/shared-sync-merge');
26
+ const { publishSemanticSharedRegistry } = require('../semantic/shared-sync-release');
27
+
28
+ function normalizeString(value) {
29
+ if (typeof value !== 'string') {
30
+ return '';
31
+ }
32
+ return value.trim();
33
+ }
34
+
35
+ function normalizeInteger(value, fallback = 0) {
36
+ const parsed = Number.parseInt(`${value}`, 10);
37
+ if (!Number.isFinite(parsed) || parsed <= 0) {
38
+ return fallback;
39
+ }
40
+ return parsed;
41
+ }
42
+
43
+ async function loadInputPayload(options = {}, fileSystem = fs) {
44
+ const inputFile = normalizeString(options.inputFile);
45
+ if (!inputFile) {
46
+ return {};
47
+ }
48
+ return fileSystem.readJson(inputFile);
49
+ }
50
+
51
+ function printPayload(payload, options = {}) {
52
+ if (options.json) {
53
+ console.log(JSON.stringify(payload, null, 2));
54
+ return;
55
+ }
56
+
57
+ if (payload.mode === 'semantic-observe') {
58
+ console.log(chalk.blue(`Semantic observation: ${payload.observation.observation_id}`));
59
+ console.log(` Runtime: ${payload.observation.source_runtime}`);
60
+ console.log(` Event: ${payload.observation.event_kind}`);
61
+ console.log(` Intent: ${payload.observation.intent}`);
62
+ console.log(` Outcome: ${payload.observation.outcome}`);
63
+ if (payload.lesson_candidate) {
64
+ console.log(` Lesson: ${payload.lesson_candidate.lesson_id} (${payload.lesson_candidate.lesson_type})`);
65
+ }
66
+ return;
67
+ }
68
+
69
+ if (payload.mode === 'semantic-list') {
70
+ console.log(chalk.blue(`Semantic observations: ${payload.total}`));
71
+ for (const item of payload.items) {
72
+ console.log(` - ${item.observation_id} | ${item.source_runtime} | ${item.event_kind} | ${item.intent} | ${item.outcome}`);
73
+ }
74
+ return;
75
+ }
76
+
77
+ if (payload.mode === 'semantic-lessons') {
78
+ console.log(chalk.blue(`Semantic lesson candidates: ${payload.total}`));
79
+ for (const item of payload.items) {
80
+ console.log(` - ${item.lesson_id} | ${item.lesson_type} | ${item.status} | ${item.title}`);
81
+ }
82
+ return;
83
+ }
84
+
85
+ if (payload.mode === 'semantic-replay') {
86
+ console.log(chalk.blue(`Semantic replay dataset: ${payload.replay_dataset.total_observations}`));
87
+ console.log(` Expected terms: ${payload.replay_dataset.expected_terms.join(', ') || 'none'}`);
88
+ console.log(` Specs: ${payload.replay_dataset.context.spec_ids.join(', ') || 'unknown'}`);
89
+ return;
90
+ }
91
+
92
+ if (payload.mode === 'semantic-eval') {
93
+ console.log(chalk.blue(`Semantic evaluation: ${payload.evaluation_run.evaluation_run_id}`));
94
+ console.log(` Verdict: ${payload.evaluation_run.verdict}`);
95
+ console.log(` Score: ${payload.evaluation_run.score}/${payload.evaluation_run.threshold}`);
96
+ console.log(` Drift: ${payload.evaluation_run.drift_level}`);
97
+ if (payload.evaluation_run.regression_reasons.length > 0) {
98
+ console.log(` Reasons: ${payload.evaluation_run.regression_reasons.join(', ')}`);
99
+ }
100
+ return;
101
+ }
102
+
103
+ if (payload.mode === 'semantic-eval-runs') {
104
+ console.log(chalk.blue(`Semantic evaluation runs: ${payload.total}`));
105
+ for (const item of payload.items) {
106
+ console.log(` - ${item.evaluation_run_id} | ${item.verdict} | ${item.score} | ${item.drift_level}`);
107
+ }
108
+ return;
109
+ }
110
+
111
+ if (payload.mode === 'semantic-promoted') {
112
+ console.log(chalk.blue(`Promoted semantic behaviors: ${payload.total}`));
113
+ for (const item of payload.items) {
114
+ console.log(` - ${item.lesson_id} | ${item.lesson_type} | ${item.status} | ${item.title}`);
115
+ }
116
+ return;
117
+ }
118
+
119
+ if (payload.mode === 'semantic-promote') {
120
+ console.log(chalk.blue(`Semantic lesson promoted: ${payload.lesson.lesson_id}`));
121
+ console.log(` Status: ${payload.lesson.status}`);
122
+ console.log(` Evidence run: ${payload.evaluation_run_id}`);
123
+ if (payload.lesson.auto_publication && payload.lesson.auto_publication.totals) {
124
+ console.log(` Publication: ${payload.lesson.auto_publication.totals.published}/${payload.lesson.auto_publication.totals.matched || payload.lesson.auto_publication.totals.entries}`);
125
+ }
126
+ return;
127
+ }
128
+
129
+ if (payload.mode === 'semantic-rollback') {
130
+ console.log(chalk.blue(`Semantic lesson rolled back: ${payload.lesson.lesson_id}`));
131
+ console.log(` Status: ${payload.lesson.status}`);
132
+ return;
133
+ }
134
+
135
+ if (payload.mode === 'semantic-progress') {
136
+ console.log(chalk.blue(`Semantic progress snapshot`));
137
+ console.log(` Observations: ${payload.observations.total}`);
138
+ console.log(` Lessons: ${payload.lesson_candidates.total} | promoted=${payload.lesson_candidates.promoted}`);
139
+ console.log(` Evaluations: ${payload.evaluation.total} | pass_rate=${payload.evaluation.pass_rate_percent}%`);
140
+ console.log(` Capability ledger: ${payload.capability_ledger.total} | quarantined=${payload.capability_ledger.quarantined}`);
141
+ console.log(` Archive: libraries=${payload.archive.totals.library_count} | missing=${payload.archive.totals.missing_archive_count}`);
142
+ console.log(` Shared sources: pending_connect=${payload.shared_sources.pendingApprovedDescriptors || 0}`);
143
+ console.log(` Supreme intent: ${payload.supreme_intent.total} | refuse=${payload.supreme_intent.refuse} | governed_rate=${payload.supreme_intent.governed_action_rate_percent}%`);
144
+ console.log(` Native activated replies: ${payload.native_backflow.activated_reply_count} | hit_rate=${payload.native_backflow.activation_hit_rate_percent}%`);
145
+ console.log(` Operator control: severity=${payload.operator_control_plane.highestSeverity || 'none'} | actionable=${payload.operator_control_plane.actionableCount || 0}`);
146
+ if (payload.operator_control_plane.primaryRecommendedCommand) {
147
+ console.log(` Next: ${payload.operator_control_plane.primaryRecommendedCommand}`);
148
+ }
149
+ return;
150
+ }
151
+
152
+ if (payload.mode === 'semantic-supreme-intent-list') {
153
+ console.log(chalk.blue(`Supreme intent assessments: ${payload.total}`));
154
+ for (const item of payload.items) {
155
+ console.log(` - ${item.assessment_id} | ${item.source_kind} | ${item.action} | ${item.scene_id || 'n/a'} | ${item.spec_id || 'n/a'}`);
156
+ }
157
+ return;
158
+ }
159
+
160
+ if (payload.mode === 'semantic-supreme-intent-show') {
161
+ console.log(chalk.blue(`Supreme intent assessment: ${payload.item.assessment_id}`));
162
+ console.log(` Source: ${payload.item.source_kind}`);
163
+ console.log(` Action: ${payload.item.action}`);
164
+ console.log(` Scene: ${payload.item.scene_id || 'n/a'}`);
165
+ console.log(` Spec: ${payload.item.spec_id || 'n/a'}`);
166
+ console.log(` Session: ${payload.item.session_id || 'n/a'}`);
167
+ return;
168
+ }
169
+
170
+ if (payload.mode === 'semantic-governance-report') {
171
+ console.log(chalk.blue('Semantic governance report'));
172
+ console.log(` Assessments: ${payload.totals.total}`);
173
+ console.log(` Governed: ${payload.totals.governed} | rewrite=${payload.totals.rewrite} | refuse=${payload.totals.refuse}`);
174
+ console.log(` Blocked: planning=${payload.totals.planning_blocked} | execution=${payload.totals.execution_blocked}`);
175
+ for (const item of payload.top_scope_hotspots) {
176
+ console.log(` Hotspot: ${item.project_id || 'n/a'} | ${item.channel_id || 'n/a'} | ${item.spec_id || 'n/a'} | governed=${item.governed_count}`);
177
+ }
178
+ for (const item of payload.top_matched_rules) {
179
+ console.log(` Rule: ${item.rule_id} | count=${item.count}`);
180
+ }
181
+ return;
182
+ }
183
+
184
+ if (payload.mode === 'semantic-backflow-report') {
185
+ console.log(chalk.blue('Semantic backflow report'));
186
+ console.log(` Local blocked: ${payload.totals.local_publish_blocked}`);
187
+ console.log(` Central merge blocked: ${payload.totals.central_merge_blocked}`);
188
+ console.log(` Central release blocked: ${payload.totals.central_release_blocked}`);
189
+ for (const item of payload.local.blocked_by_reason) {
190
+ console.log(` Local reason: ${item.reason} | count=${item.count}`);
191
+ }
192
+ for (const item of payload.central_merge.blocked_by_reason) {
193
+ console.log(` Merge reason: ${item.reason} | count=${item.count}`);
194
+ }
195
+ for (const item of payload.central_release.blocked_by_reason) {
196
+ console.log(` Release reason: ${item.reason} | count=${item.count}`);
197
+ }
198
+ return;
199
+ }
200
+
201
+ if (payload.mode === 'semantic-archive-report') {
202
+ console.log(chalk.blue('Semantic archive report'));
203
+ console.log(` Lessons: ${payload.totals.lesson_total}`);
204
+ console.log(` Ledgers: ${payload.totals.ledger_total}`);
205
+ console.log(` Libraries: ${payload.totals.library_count} | missing=${payload.totals.missing_archive_count}`);
206
+ for (const item of payload.by_library) {
207
+ console.log(` Library: ${item.target_library} | lessons=${item.lesson_count} | ledgers=${item.ledger_count} | shared=${item.published_shared_count}`);
208
+ }
209
+ return;
210
+ }
211
+
212
+ if (payload.mode === 'semantic-delta-export') {
213
+ console.log(chalk.blue(`Semantic delta export: ${payload.total}`));
214
+ if (payload.out_file) {
215
+ console.log(` File: ${payload.out_file}`);
216
+ }
217
+ for (const item of payload.entries) {
218
+ console.log(` - ${item.capability_id} | ${item.target_library} | ${item.publication.publish_state}`);
219
+ }
220
+ return;
221
+ }
222
+
223
+ if (payload.mode === 'semantic-publish-delta') {
224
+ console.log(chalk.blue(`Semantic delta publication: ${payload.totals.published}/${payload.totals.entries}`));
225
+ if (payload.source_manifest) {
226
+ console.log(` Manifest: ${payload.source_manifest}`);
227
+ }
228
+ if (payload.out_file) {
229
+ console.log(` Report: ${payload.out_file}`);
230
+ }
231
+ console.log(` Mirror root: ${payload.mirror_root}`);
232
+ for (const item of payload.published) {
233
+ console.log(` - ${item.capability_id} | ${item.target_library} | ${item.entry_file}`);
234
+ }
235
+ if (payload.blocked.length > 0) {
236
+ for (const item of payload.blocked) {
237
+ console.log(` ! ${item.capability_id || item.lesson_id || 'unknown'} | ${item.reason}`);
238
+ }
239
+ }
240
+ return;
241
+ }
242
+
243
+ if (payload.mode === 'semantic-export-shared-sync') {
244
+ console.log(chalk.blue(`Semantic shared sync export: ${payload.totals.entries_exported}/${payload.totals.entries_matched}`));
245
+ if (payload.out_file) {
246
+ console.log(` Bundle: ${payload.out_file}`);
247
+ }
248
+ if (payload.index_file) {
249
+ console.log(` Index: ${payload.index_file}`);
250
+ }
251
+ if (payload.receipt_file) {
252
+ console.log(` Receipt: ${payload.receipt_file}`);
253
+ }
254
+ console.log(` Mirror root: ${payload.mirror_root}`);
255
+ for (const item of payload.libraries) {
256
+ console.log(` - ${item.target_library} | ${item.entry_count} | ${item.shard_file || 'memory-only'}`);
257
+ }
258
+ if (payload.blocked.length > 0) {
259
+ for (const item of payload.blocked) {
260
+ console.log(` ! ${item.capability_id || item.lesson_id || 'unknown'} | ${item.reason}`);
261
+ }
262
+ }
263
+ return;
264
+ }
265
+
266
+ if (payload.mode === 'semantic-sync-shared') {
267
+ console.log(chalk.blue(`Semantic shared sync intake: ${payload.totals.imported}/${payload.totals.libraries}`));
268
+ console.log(` Source: ${payload.source}`);
269
+ if (payload.required_release_state) {
270
+ console.log(` Release: ${payload.release_state || 'unreleased'} (required=${payload.required_release_state})`);
271
+ }
272
+ if (payload.out_file) {
273
+ console.log(` Receipt: ${payload.out_file}`);
274
+ }
275
+ console.log(` Mirror root: ${payload.mirror_root}`);
276
+ for (const item of payload.imported) {
277
+ console.log(` - ${item.capability_id} | ${item.target_library} | ${item.entry_file}`);
278
+ }
279
+ for (const item of payload.skipped) {
280
+ console.log(` ~ ${item.capability_id || item.lesson_id || 'unknown'} | ${item.reason}`);
281
+ }
282
+ for (const item of payload.blocked) {
283
+ console.log(` ! ${item.capability_id || item.target_library || 'unknown'} | ${item.reason}`);
284
+ }
285
+ return;
286
+ }
287
+
288
+ if (payload.mode === 'semantic-health-shared-source') {
289
+ console.log(chalk.blue(`Semantic shared source health: ${payload.success ? 'ok' : 'issues'}`));
290
+ console.log(` Source: ${payload.source || 'unconfigured'}`);
291
+ console.log(` Bundle: ${payload.bundle_ok ? 'ok' : 'failed'}`);
292
+ if (payload.required_release_state) {
293
+ console.log(` Release: ${payload.release_state || 'unreleased'} (required=${payload.required_release_state})`);
294
+ }
295
+ console.log(` Shards: ${payload.shard_sources_ok}/${payload.shard_sources_checked}`);
296
+ console.log(` Entries: ${payload.total_entries}`);
297
+ for (const item of payload.warnings) {
298
+ console.log(` ~ ${item}`);
299
+ }
300
+ for (const item of payload.errors) {
301
+ console.log(` ! ${item}`);
302
+ }
303
+ return;
304
+ }
305
+
306
+ if (payload.mode === 'semantic-list-shared-sources') {
307
+ console.log(chalk.blue(`Semantic shared sources: ${payload.total}`));
308
+ console.log(` Config: ${payload.config_file}`);
309
+ for (const item of payload.items) {
310
+ console.log(` - ${item.name} | ${item.enabled ? 'enabled' : 'disabled'} | ${item.bundle}`);
311
+ }
312
+ return;
313
+ }
314
+
315
+ if (payload.mode === 'semantic-set-shared-source') {
316
+ console.log(chalk.blue(`Semantic shared source upserted: ${payload.source.name}`));
317
+ console.log(` Config: ${payload.config_file}`);
318
+ if (payload.descriptor_file) {
319
+ console.log(` Descriptor: ${payload.descriptor_file}`);
320
+ }
321
+ console.log(` Bundle: ${payload.source.bundle}`);
322
+ if (payload.source.required_release_state) {
323
+ console.log(` Required release: ${payload.source.required_release_state}`);
324
+ }
325
+ return;
326
+ }
327
+
328
+ if (payload.mode === 'semantic-connect-shared-source') {
329
+ console.log(chalk.blue(`Semantic shared source connect: ${payload.success ? 'ok' : 'blocked'}`));
330
+ console.log(` Descriptor: ${payload.descriptor_file}`);
331
+ console.log(` Release: ${payload.descriptor_release_state || 'unreleased'}`);
332
+ if (payload.config_file) {
333
+ console.log(` Config: ${payload.config_file}`);
334
+ }
335
+ if (payload.sync && payload.sync.out_file) {
336
+ console.log(` Sync receipt: ${payload.sync.out_file}`);
337
+ }
338
+ for (const item of payload.blocked) {
339
+ console.log(` ! ${item.reason}`);
340
+ }
341
+ return;
342
+ }
343
+
344
+ if (payload.mode === 'semantic-merge-shared') {
345
+ console.log(chalk.blue(`Semantic shared merge: ${payload.totals.merged_entries}/${payload.totals.candidate_entries}`));
346
+ if (payload.out_file) {
347
+ console.log(` Bundle: ${payload.out_file}`);
348
+ }
349
+ if (payload.index_file) {
350
+ console.log(` Index: ${payload.index_file}`);
351
+ }
352
+ if (payload.receipt_file) {
353
+ console.log(` Receipt: ${payload.receipt_file}`);
354
+ }
355
+ if (payload.source_descriptor_file) {
356
+ console.log(` Source descriptor: ${payload.source_descriptor_file}`);
357
+ }
358
+ console.log(` Sources: ${payload.totals.sources}`);
359
+ for (const item of payload.libraries) {
360
+ console.log(` - ${item.target_library} | ${item.entry_count} | ${item.shard_file || 'memory-only'}`);
361
+ }
362
+ for (const item of payload.superseded || []) {
363
+ console.log(` ~ ${item.capability_id || 'unknown'} | kept=${item.kept_source || 'unknown'} | dropped=${item.dropped_source || 'unknown'}`);
364
+ }
365
+ for (const item of payload.blocked) {
366
+ console.log(` ! ${item.source || item.target_library || 'unknown'} | ${item.reason}`);
367
+ }
368
+ return;
369
+ }
370
+
371
+ if (payload.mode === 'semantic-publish-shared-registry') {
372
+ console.log(chalk.blue(`Semantic shared registry publish: ${payload.success ? 'approved' : 'blocked'}`));
373
+ if (payload.out_file) {
374
+ console.log(` Bundle: ${payload.out_file}`);
375
+ }
376
+ if (payload.index_file) {
377
+ console.log(` Index: ${payload.index_file}`);
378
+ }
379
+ if (payload.receipt_file) {
380
+ console.log(` Receipt: ${payload.receipt_file}`);
381
+ }
382
+ console.log(` Sources: ${payload.totals.sources}`);
383
+ console.log(` Entries: ${payload.totals.merged_entries}`);
384
+ for (const item of payload.libraries) {
385
+ console.log(` - ${item.target_library} | ${item.entry_count} | ${item.shard_file || 'memory-only'}`);
386
+ }
387
+ for (const item of payload.blocked) {
388
+ console.log(` ! ${item.reason} | ${item.required_sources || item.required_entries || item.blocked_entries || 'n/a'}`);
389
+ }
390
+ return;
391
+ }
392
+ }
393
+
394
+ async function runSemanticObserveCommand(options = {}, dependencies = {}) {
395
+ const projectPath = dependencies.projectPath || process.cwd();
396
+ const fileSystem = dependencies.fileSystem || fs;
397
+ const payloadFromFile = await loadInputPayload(options, fileSystem);
398
+ const payload = {
399
+ ...payloadFromFile,
400
+ project_id: options.projectId || payloadFromFile.project_id,
401
+ channel_id: options.channelId || payloadFromFile.channel_id,
402
+ session_id: options.sessionId || payloadFromFile.session_id,
403
+ scene_id: options.scene || payloadFromFile.scene_id,
404
+ spec_id: options.spec || payloadFromFile.spec_id,
405
+ task_ref: options.taskRef || payloadFromFile.task_ref,
406
+ source_runtime: options.runtime || payloadFromFile.source_runtime,
407
+ host_session_id: options.hostSession || payloadFromFile.host_session_id,
408
+ event_kind: options.event || payloadFromFile.event_kind,
409
+ role: options.role || payloadFromFile.role,
410
+ intent: options.intent || payloadFromFile.intent,
411
+ outcome: options.outcome || payloadFromFile.outcome,
412
+ quality_signal: options.quality || payloadFromFile.quality_signal,
413
+ summary: options.summary || payloadFromFile.summary,
414
+ text: options.text || payloadFromFile.text,
415
+ raw_ref: options.rawRef || payloadFromFile.raw_ref
416
+ };
417
+
418
+ const result = await observeSemanticInteraction(payload, {
419
+ projectPath,
420
+ fileSystem,
421
+ stateStore: dependencies.stateStore
422
+ });
423
+
424
+ const response = {
425
+ mode: 'semantic-observe',
426
+ success: true,
427
+ observation: result.observation,
428
+ lesson_candidate: result.lesson_candidate
429
+ };
430
+ printPayload(response, options);
431
+ return response;
432
+ }
433
+
434
+ async function runSemanticListCommand(options = {}, dependencies = {}) {
435
+ const projectPath = dependencies.projectPath || process.cwd();
436
+ const store = dependencies.stateStore || getSceStateStore(projectPath, {
437
+ fileSystem: dependencies.fileSystem || fs
438
+ });
439
+ const items = await store.listSemanticObservations({
440
+ project_id: options.projectId,
441
+ source_runtime: options.runtime,
442
+ session_id: options.sessionId,
443
+ limit: options.limit
444
+ });
445
+ const response = {
446
+ mode: 'semantic-list',
447
+ success: true,
448
+ total: Array.isArray(items) ? items.length : 0,
449
+ items: Array.isArray(items) ? items : []
450
+ };
451
+ printPayload(response, options);
452
+ return response;
453
+ }
454
+
455
+ async function runSemanticLessonsCommand(options = {}, dependencies = {}) {
456
+ const projectPath = dependencies.projectPath || process.cwd();
457
+ const store = dependencies.stateStore || getSceStateStore(projectPath, {
458
+ fileSystem: dependencies.fileSystem || fs
459
+ });
460
+ const items = await store.listSemanticLessonCandidates({
461
+ project_id: options.projectId,
462
+ status: options.status,
463
+ limit: options.limit
464
+ });
465
+ const response = {
466
+ mode: 'semantic-lessons',
467
+ success: true,
468
+ total: Array.isArray(items) ? items.length : 0,
469
+ items: Array.isArray(items) ? items : []
470
+ };
471
+ printPayload(response, options);
472
+ return response;
473
+ }
474
+
475
+ async function runSemanticReplayCommand(options = {}, dependencies = {}) {
476
+ const payloadFromFile = await loadInputPayload(options, dependencies.fileSystem || fs);
477
+ const response = await collectSemanticReplayInputs({
478
+ ...payloadFromFile,
479
+ project_id: options.projectId || payloadFromFile.project_id,
480
+ channel_id: options.channelId || payloadFromFile.channel_id,
481
+ session_id: options.sessionId || payloadFromFile.session_id,
482
+ scene_id: options.scene || payloadFromFile.scene_id,
483
+ spec_id: options.spec || payloadFromFile.spec_id,
484
+ source_runtime: options.runtime || payloadFromFile.source_runtime,
485
+ observation_ids: payloadFromFile.observation_ids,
486
+ limit: options.limit || payloadFromFile.limit
487
+ }, {
488
+ ...dependencies,
489
+ projectPath: dependencies.projectPath || process.cwd(),
490
+ fileSystem: dependencies.fileSystem || fs
491
+ });
492
+
493
+ const result = {
494
+ mode: 'semantic-replay',
495
+ success: true,
496
+ total: response.observations.length,
497
+ replay_dataset: response.replay_dataset,
498
+ observations: response.observations
499
+ };
500
+ printPayload(result, options);
501
+ return result;
502
+ }
503
+
504
+ async function runSemanticEvalCommand(options = {}, dependencies = {}) {
505
+ const payloadFromFile = await loadInputPayload(options, dependencies.fileSystem || fs);
506
+ const response = await evaluateSemanticCandidate({
507
+ ...payloadFromFile,
508
+ project_id: options.projectId || payloadFromFile.project_id,
509
+ channel_id: options.channelId || payloadFromFile.channel_id,
510
+ session_id: options.sessionId || payloadFromFile.session_id,
511
+ scene_id: options.scene || payloadFromFile.scene_id,
512
+ spec_id: options.spec || payloadFromFile.spec_id,
513
+ source_runtime: options.runtime || payloadFromFile.source_runtime,
514
+ lesson_id: options.lessonId || payloadFromFile.lesson_id,
515
+ release_gate: options.releaseGate || payloadFromFile.release_gate,
516
+ baseline_evaluation_run_id: options.baselineRunId || payloadFromFile.baseline_evaluation_run_id,
517
+ candidate_label: options.candidateLabel || payloadFromFile.candidate_label,
518
+ candidate_reply: options.candidateReply || payloadFromFile.candidate_reply,
519
+ candidate_plan: options.candidatePlan || payloadFromFile.candidate_plan,
520
+ observation_ids: payloadFromFile.observation_ids,
521
+ threshold: options.threshold || payloadFromFile.threshold,
522
+ limit: options.limit || payloadFromFile.limit
523
+ }, {
524
+ ...dependencies,
525
+ projectPath: dependencies.projectPath || process.cwd(),
526
+ fileSystem: dependencies.fileSystem || fs
527
+ });
528
+
529
+ const result = {
530
+ mode: 'semantic-eval',
531
+ success: true,
532
+ evaluation_run: response.evaluation_run,
533
+ replay_dataset: response.replay_dataset,
534
+ observations: response.observations
535
+ };
536
+ printPayload(result, options);
537
+ return result;
538
+ }
539
+
540
+ async function runSemanticEvalRunsCommand(options = {}, dependencies = {}) {
541
+ const projectPath = dependencies.projectPath || process.cwd();
542
+ const store = dependencies.stateStore || getSceStateStore(projectPath, {
543
+ fileSystem: dependencies.fileSystem || fs
544
+ });
545
+ const items = await store.listSemanticEvaluationRuns({
546
+ project_id: options.projectId,
547
+ session_id: options.sessionId,
548
+ spec_id: options.spec,
549
+ verdict: options.verdict,
550
+ limit: options.limit
551
+ });
552
+ const response = {
553
+ mode: 'semantic-eval-runs',
554
+ success: true,
555
+ total: Array.isArray(items) ? items.length : 0,
556
+ items: Array.isArray(items) ? items : []
557
+ };
558
+ printPayload(response, options);
559
+ return response;
560
+ }
561
+
562
+ async function runSemanticPromotedCommand(options = {}, dependencies = {}) {
563
+ const payloadFromFile = await loadInputPayload(options, dependencies.fileSystem || fs);
564
+ const items = await listPromotedSemanticBehaviors({
565
+ ...payloadFromFile,
566
+ project_id: options.projectId || payloadFromFile.project_id,
567
+ channel_id: options.channelId || payloadFromFile.channel_id,
568
+ scene_id: options.scene || payloadFromFile.scene_id,
569
+ spec_id: options.spec || payloadFromFile.spec_id,
570
+ limit: options.limit || payloadFromFile.limit
571
+ }, {
572
+ ...dependencies,
573
+ projectPath: dependencies.projectPath || process.cwd(),
574
+ fileSystem: dependencies.fileSystem || fs
575
+ });
576
+ const response = {
577
+ mode: 'semantic-promoted',
578
+ success: true,
579
+ total: Array.isArray(items) ? items.length : 0,
580
+ items: Array.isArray(items) ? items : []
581
+ };
582
+ printPayload(response, options);
583
+ return response;
584
+ }
585
+
586
+ async function runSemanticPromoteCommand(options = {}, dependencies = {}) {
587
+ const lesson = await promoteSemanticLessonCandidate({
588
+ lesson_id: options.lessonId,
589
+ evaluation_run_id: options.evalRunId,
590
+ actor: options.actor,
591
+ release_gate: options.releaseGate
592
+ }, {
593
+ ...dependencies,
594
+ projectPath: dependencies.projectPath || process.cwd(),
595
+ fileSystem: dependencies.fileSystem || fs
596
+ });
597
+
598
+ const response = {
599
+ mode: 'semantic-promote',
600
+ success: true,
601
+ evaluation_run_id: options.evalRunId,
602
+ lesson
603
+ };
604
+ printPayload(response, options);
605
+ return response;
606
+ }
607
+
608
+ async function runSemanticRollbackCommand(options = {}, dependencies = {}) {
609
+ const lesson = await rollbackPromotedSemanticLesson({
610
+ lesson_id: options.lessonId,
611
+ actor: options.actor,
612
+ reason: options.reason
613
+ }, {
614
+ ...dependencies,
615
+ projectPath: dependencies.projectPath || process.cwd(),
616
+ fileSystem: dependencies.fileSystem || fs
617
+ });
618
+
619
+ const response = {
620
+ mode: 'semantic-rollback',
621
+ success: true,
622
+ lesson
623
+ };
624
+ printPayload(response, options);
625
+ return response;
626
+ }
627
+
628
+ async function runSemanticProgressCommand(options = {}, dependencies = {}) {
629
+ const payload = await buildSemanticProgressReport({
630
+ project_id: options.projectId,
631
+ spec_id: options.spec,
632
+ session_id: options.sessionId,
633
+ limit: options.limit
634
+ }, {
635
+ ...dependencies,
636
+ projectPath: dependencies.projectPath || process.cwd(),
637
+ fileSystem: dependencies.fileSystem || fs
638
+ });
639
+ printPayload(payload, options);
640
+ return payload;
641
+ }
642
+
643
+ async function runSemanticSupremeIntentListCommand(options = {}, dependencies = {}) {
644
+ const projectPath = dependencies.projectPath || process.cwd();
645
+ const store = dependencies.stateStore || getSceStateStore(projectPath, {
646
+ fileSystem: dependencies.fileSystem || fs,
647
+ env: dependencies.env,
648
+ sqliteModule: dependencies.sqliteModule
649
+ });
650
+ const limit = normalizeInteger(options.limit, 20);
651
+ const items = await store.listSupremeIntentAssessments({
652
+ project_id: options.projectId,
653
+ channel_id: options.channelId,
654
+ session_id: options.sessionId,
655
+ scene_id: options.scene,
656
+ spec_id: options.spec,
657
+ job_id: options.jobId,
658
+ source_kind: options.sourceKind,
659
+ action: options.action,
660
+ limit
661
+ });
662
+ const response = {
663
+ mode: 'semantic-supreme-intent-list',
664
+ success: true,
665
+ filters: {
666
+ project_id: normalizeString(options.projectId) || null,
667
+ channel_id: normalizeString(options.channelId) || null,
668
+ session_id: normalizeString(options.sessionId) || null,
669
+ scene_id: normalizeString(options.scene) || null,
670
+ spec_id: normalizeString(options.spec) || null,
671
+ job_id: normalizeString(options.jobId) || null,
672
+ source_kind: normalizeString(options.sourceKind) || null,
673
+ action: normalizeString(options.action) || null,
674
+ limit
675
+ },
676
+ total: Array.isArray(items) ? items.length : 0,
677
+ items: Array.isArray(items) ? items : []
678
+ };
679
+ printPayload(response, options);
680
+ return response;
681
+ }
682
+
683
+ async function runSemanticSupremeIntentShowCommand(assessmentId, options = {}, dependencies = {}) {
684
+ const normalizedAssessmentId = normalizeString(assessmentId || options.assessmentId);
685
+ if (!normalizedAssessmentId) {
686
+ throw new Error('assessment id is required');
687
+ }
688
+ const projectPath = dependencies.projectPath || process.cwd();
689
+ const store = dependencies.stateStore || getSceStateStore(projectPath, {
690
+ fileSystem: dependencies.fileSystem || fs,
691
+ env: dependencies.env,
692
+ sqliteModule: dependencies.sqliteModule
693
+ });
694
+ const item = await store.getSupremeIntentAssessment(normalizedAssessmentId);
695
+ if (!item) {
696
+ throw new Error(`Supreme intent assessment not found: ${normalizedAssessmentId}`);
697
+ }
698
+ const response = {
699
+ mode: 'semantic-supreme-intent-show',
700
+ success: true,
701
+ item
702
+ };
703
+ printPayload(response, options);
704
+ return response;
705
+ }
706
+
707
+ async function runSemanticGovernanceReportCommand(options = {}, dependencies = {}) {
708
+ const payload = await buildSupremeIntentGovernanceReport({
709
+ project_id: options.projectId,
710
+ channel_id: options.channelId,
711
+ session_id: options.sessionId,
712
+ scene_id: options.scene,
713
+ spec_id: options.spec,
714
+ job_id: options.jobId,
715
+ source_kind: options.sourceKind,
716
+ action: options.action,
717
+ limit: options.limit,
718
+ hotspot_limit: options.hotspotLimit,
719
+ recent_limit: options.recentLimit
720
+ }, {
721
+ ...dependencies,
722
+ projectPath: dependencies.projectPath || process.cwd(),
723
+ fileSystem: dependencies.fileSystem || fs
724
+ });
725
+ printPayload(payload, options);
726
+ return payload;
727
+ }
728
+
729
+ async function runSemanticBackflowReportCommand(options = {}, dependencies = {}) {
730
+ const payload = await buildSemanticBackflowReport({
731
+ project_id: options.projectId,
732
+ spec_id: options.spec,
733
+ limit: options.limit,
734
+ recent_limit: options.recentLimit
735
+ }, {
736
+ ...dependencies,
737
+ projectPath: dependencies.projectPath || process.cwd(),
738
+ fileSystem: dependencies.fileSystem || fs
739
+ });
740
+ printPayload(payload, options);
741
+ return payload;
742
+ }
743
+
744
+ async function runSemanticArchiveReportCommand(options = {}, dependencies = {}) {
745
+ const payload = await buildSemanticArchiveReport({
746
+ project_id: options.projectId,
747
+ spec_id: options.spec,
748
+ session_id: options.sessionId,
749
+ limit: options.limit,
750
+ recent_limit: options.recentLimit
751
+ }, {
752
+ ...dependencies,
753
+ projectPath: dependencies.projectPath || process.cwd(),
754
+ fileSystem: dependencies.fileSystem || fs
755
+ });
756
+ printPayload(payload, options);
757
+ return payload;
758
+ }
759
+
760
+ async function runSemanticDeltaExportCommand(options = {}, dependencies = {}) {
761
+ const payload = await exportSemanticLibraryDelta({
762
+ project_id: options.projectId,
763
+ spec_id: options.spec,
764
+ limit: options.limit,
765
+ out_file: options.outFile
766
+ }, {
767
+ ...dependencies,
768
+ projectPath: dependencies.projectPath || process.cwd(),
769
+ fileSystem: dependencies.fileSystem || fs
770
+ });
771
+ printPayload(payload, options);
772
+ return payload;
773
+ }
774
+
775
+ async function runSemanticPublishDeltaCommand(options = {}, dependencies = {}) {
776
+ const payload = await publishSemanticLibraryDelta({
777
+ project_id: options.projectId,
778
+ spec_id: options.spec,
779
+ input_file: options.inputFile,
780
+ out_file: options.outFile,
781
+ limit: options.limit
782
+ }, {
783
+ ...dependencies,
784
+ projectPath: dependencies.projectPath || process.cwd(),
785
+ fileSystem: dependencies.fileSystem || fs,
786
+ syncSemanticCapabilityLedger
787
+ });
788
+ printPayload(payload, options);
789
+ return payload;
790
+ }
791
+
792
+ async function runSemanticExportSharedSyncCommand(options = {}, dependencies = {}) {
793
+ const payload = await exportSemanticSharedSyncBundle({
794
+ project_id: options.projectId,
795
+ spec_id: options.spec,
796
+ lesson_id: options.lessonId,
797
+ capability_id: options.capabilityId,
798
+ target_library: options.targetLibrary,
799
+ out_file: options.outFile,
800
+ limit: options.limit
801
+ }, {
802
+ ...dependencies,
803
+ projectPath: dependencies.projectPath || process.cwd(),
804
+ fileSystem: dependencies.fileSystem || fs
805
+ });
806
+ printPayload(payload, options);
807
+ return payload;
808
+ }
809
+
810
+ async function runSemanticSyncSharedCommand(options = {}, dependencies = {}) {
811
+ const payload = await syncSemanticSharedBundle({
812
+ source: options.source,
813
+ sourceName: options.sourceName,
814
+ sourceRoot: options.sourceRoot,
815
+ requiredReleaseState: options.requiredReleaseState,
816
+ config: options.config,
817
+ spec: options.spec,
818
+ outFile: options.outFile,
819
+ limit: options.limit
820
+ }, {
821
+ ...dependencies,
822
+ projectPath: dependencies.projectPath || process.cwd(),
823
+ fileSystem: dependencies.fileSystem || fs
824
+ });
825
+ printPayload(payload, options);
826
+ return payload;
827
+ }
828
+
829
+ async function runSemanticHealthSharedSourceCommand(options = {}, dependencies = {}) {
830
+ const payload = await inspectSemanticSharedSource({
831
+ source: options.source,
832
+ sourceName: options.sourceName,
833
+ sourceRoot: options.sourceRoot,
834
+ requiredReleaseState: options.requiredReleaseState,
835
+ config: options.config
836
+ }, {
837
+ ...dependencies,
838
+ projectPath: dependencies.projectPath || process.cwd(),
839
+ fileSystem: dependencies.fileSystem || fs
840
+ });
841
+ printPayload(payload, options);
842
+ return payload;
843
+ }
844
+
845
+ async function runSemanticListSharedSourcesCommand(options = {}, dependencies = {}) {
846
+ const payload = await listSemanticSharedSources({
847
+ config: options.config
848
+ }, {
849
+ ...dependencies,
850
+ projectPath: dependencies.projectPath || process.cwd(),
851
+ fileSystem: dependencies.fileSystem || fs
852
+ });
853
+ printPayload(payload, options);
854
+ return payload;
855
+ }
856
+
857
+ async function runSemanticSetSharedSourceCommand(options = {}, dependencies = {}) {
858
+ const payload = await upsertSemanticSharedSource({
859
+ inputFile: options.inputFile,
860
+ name: options.name,
861
+ bundle: options.bundle,
862
+ root: options.root,
863
+ enabled: options.enabled,
864
+ requiredReleaseState: options.requiredReleaseState,
865
+ config: options.config
866
+ }, {
867
+ ...dependencies,
868
+ projectPath: dependencies.projectPath || process.cwd(),
869
+ fileSystem: dependencies.fileSystem || fs
870
+ });
871
+ printPayload(payload, options);
872
+ return payload;
873
+ }
874
+
875
+ async function runSemanticConnectSharedSourceCommand(options = {}, dependencies = {}) {
876
+ const payload = await connectSemanticSharedSource({
877
+ inputFile: options.inputFile,
878
+ spec: options.spec,
879
+ name: options.name,
880
+ bundle: options.bundle,
881
+ root: options.root,
882
+ enabled: options.enabled,
883
+ requiredReleaseState: options.requiredReleaseState,
884
+ config: options.config,
885
+ healthCheck: options.healthCheck,
886
+ syncNow: options.syncNow,
887
+ allowNonApproved: options.allowNonApproved
888
+ }, {
889
+ ...dependencies,
890
+ projectPath: dependencies.projectPath || process.cwd(),
891
+ fileSystem: dependencies.fileSystem || fs
892
+ });
893
+ printPayload(payload, options);
894
+ return payload;
895
+ }
896
+
897
+ async function runSemanticMergeSharedCommand(options = {}, dependencies = {}) {
898
+ const payload = await mergeSemanticSharedBundles({
899
+ source: options.source,
900
+ sources: options.sources,
901
+ config: options.config,
902
+ spec: options.spec,
903
+ outFile: options.outFile,
904
+ limit: options.limit
905
+ }, {
906
+ ...dependencies,
907
+ projectPath: dependencies.projectPath || process.cwd(),
908
+ fileSystem: dependencies.fileSystem || fs
909
+ });
910
+ printPayload(payload, options);
911
+ return payload;
912
+ }
913
+
914
+ async function runSemanticPublishSharedRegistryCommand(options = {}, dependencies = {}) {
915
+ const payload = await publishSemanticSharedRegistry({
916
+ spec: options.spec,
917
+ input_file: options.inputFile,
918
+ out_file: options.outFile,
919
+ index_file: options.indexFile,
920
+ receipt_file: options.receiptFile,
921
+ source_name: options.sourceName,
922
+ source_descriptor_file: options.sourceDescriptorFile,
923
+ public_bundle: options.publicBundle,
924
+ public_root: options.publicRoot,
925
+ min_sources: options.minSources,
926
+ min_entries: options.minEntries,
927
+ require_zero_blocked: options.requireZeroBlocked
928
+ }, {
929
+ ...dependencies,
930
+ projectPath: dependencies.projectPath || process.cwd(),
931
+ fileSystem: dependencies.fileSystem || fs
932
+ });
933
+ printPayload(payload, options);
934
+ return payload;
935
+ }
936
+
937
+ function registerSemanticCommands(program) {
938
+ const semantic = program
939
+ .command('semantic')
940
+ .description('Manage semantic observation, lesson distillation, and candidate review');
941
+
942
+ semantic
943
+ .command('observe')
944
+ .description('Record one embedded-host semantic observation')
945
+ .option('--input-file <path>', 'JSON file containing observation payload')
946
+ .option('--project-id <project-id>', 'Project identifier')
947
+ .option('--channel-id <channel-id>', 'Collaboration channel identifier')
948
+ .option('--session-id <session-id>', 'Session identifier')
949
+ .option('--scene <scene-id>', 'Scene identifier')
950
+ .option('--spec <spec-id>', 'Spec identifier')
951
+ .option('--task-ref <task-ref>', 'Task reference')
952
+ .option('--runtime <runtime>', 'Source runtime, e.g. codex-cli')
953
+ .option('--host-session <host-session-id>', 'Embedded-host session identifier')
954
+ .option('--event <event-kind>', 'Observed event kind, e.g. reply')
955
+ .option('--role <role>', 'Role, e.g. assistant')
956
+ .option('--intent <intent>', 'Intent label override')
957
+ .option('--outcome <outcome>', 'Outcome override')
958
+ .option('--quality <signal>', 'Quality signal override')
959
+ .option('--summary <summary>', 'Summary override')
960
+ .option('--text <text>', 'Observed text preview')
961
+ .option('--raw-ref <ref>', 'Reference to raw trace')
962
+ .option('--json', 'Print machine-readable JSON output')
963
+ .action(async (options) => {
964
+ try {
965
+ await runSemanticObserveCommand(options);
966
+ } catch (error) {
967
+ console.error(chalk.red(`Semantic observe failed: ${error.message}`));
968
+ process.exitCode = 1;
969
+ }
970
+ });
971
+
972
+ semantic
973
+ .command('list')
974
+ .description('List semantic observations')
975
+ .option('--project-id <project-id>', 'Filter by project')
976
+ .option('--runtime <runtime>', 'Filter by runtime')
977
+ .option('--session-id <session-id>', 'Filter by session')
978
+ .option('--limit <n>', 'Limit result count', parseInt)
979
+ .option('--json', 'Print machine-readable JSON output')
980
+ .action(async (options) => {
981
+ try {
982
+ await runSemanticListCommand(options);
983
+ } catch (error) {
984
+ console.error(chalk.red(`Semantic list failed: ${error.message}`));
985
+ process.exitCode = 1;
986
+ }
987
+ });
988
+
989
+ semantic
990
+ .command('lessons')
991
+ .description('List semantic lesson candidates')
992
+ .option('--project-id <project-id>', 'Filter by project')
993
+ .option('--status <status>', 'Filter by lesson status')
994
+ .option('--limit <n>', 'Limit result count', parseInt)
995
+ .option('--json', 'Print machine-readable JSON output')
996
+ .action(async (options) => {
997
+ try {
998
+ await runSemanticLessonsCommand(options);
999
+ } catch (error) {
1000
+ console.error(chalk.red(`Semantic lessons failed: ${error.message}`));
1001
+ process.exitCode = 1;
1002
+ }
1003
+ });
1004
+
1005
+ semantic
1006
+ .command('replay')
1007
+ .description('Build replay dataset from recorded semantic observations')
1008
+ .option('--input-file <path>', 'JSON file containing replay filters')
1009
+ .option('--project-id <project-id>', 'Filter by project')
1010
+ .option('--channel-id <channel-id>', 'Filter by collaboration channel')
1011
+ .option('--session-id <session-id>', 'Filter by session')
1012
+ .option('--scene <scene-id>', 'Filter by scene')
1013
+ .option('--spec <spec-id>', 'Filter by spec')
1014
+ .option('--runtime <runtime>', 'Filter by runtime')
1015
+ .option('--limit <n>', 'Limit observation count', parseInt)
1016
+ .option('--json', 'Print machine-readable JSON output')
1017
+ .action(async (options) => {
1018
+ try {
1019
+ await runSemanticReplayCommand(options);
1020
+ } catch (error) {
1021
+ console.error(chalk.red(`Semantic replay failed: ${error.message}`));
1022
+ process.exitCode = 1;
1023
+ }
1024
+ });
1025
+
1026
+ semantic
1027
+ .command('eval')
1028
+ .description('Replay semantic observations against a candidate reply or plan')
1029
+ .option('--input-file <path>', 'JSON file containing evaluation payload')
1030
+ .option('--project-id <project-id>', 'Project identifier')
1031
+ .option('--channel-id <channel-id>', 'Collaboration channel identifier')
1032
+ .option('--session-id <session-id>', 'Session identifier')
1033
+ .option('--scene <scene-id>', 'Scene identifier')
1034
+ .option('--spec <spec-id>', 'Spec identifier')
1035
+ .option('--runtime <runtime>', 'Runtime identifier')
1036
+ .option('--lesson-id <lesson-id>', 'Associated lesson candidate identifier')
1037
+ .option('--release-gate <release-gate>', 'Release gate or promotion lane')
1038
+ .option('--baseline-run-id <evaluation-run-id>', 'Compare against an earlier evaluation run')
1039
+ .option('--candidate-label <label>', 'Human-readable candidate label')
1040
+ .option('--candidate-reply <text>', 'Candidate reply text')
1041
+ .option('--candidate-plan <text>', 'Candidate action-plan text')
1042
+ .option('--threshold <score>', 'Pass threshold', parseFloat)
1043
+ .option('--limit <n>', 'Limit replay observation count', parseInt)
1044
+ .option('--json', 'Print machine-readable JSON output')
1045
+ .action(async (options) => {
1046
+ try {
1047
+ await runSemanticEvalCommand(options);
1048
+ } catch (error) {
1049
+ console.error(chalk.red(`Semantic eval failed: ${error.message}`));
1050
+ process.exitCode = 1;
1051
+ }
1052
+ });
1053
+
1054
+ semantic
1055
+ .command('eval-runs')
1056
+ .description('List semantic evaluation runs')
1057
+ .option('--project-id <project-id>', 'Filter by project')
1058
+ .option('--session-id <session-id>', 'Filter by session')
1059
+ .option('--spec <spec-id>', 'Filter by spec')
1060
+ .option('--verdict <verdict>', 'Filter by verdict')
1061
+ .option('--limit <n>', 'Limit result count', parseInt)
1062
+ .option('--json', 'Print machine-readable JSON output')
1063
+ .action(async (options) => {
1064
+ try {
1065
+ await runSemanticEvalRunsCommand(options);
1066
+ } catch (error) {
1067
+ console.error(chalk.red(`Semantic eval-runs failed: ${error.message}`));
1068
+ process.exitCode = 1;
1069
+ }
1070
+ });
1071
+
1072
+ semantic
1073
+ .command('promoted')
1074
+ .description('List promoted semantic behaviors')
1075
+ .option('--input-file <path>', 'JSON file containing filters')
1076
+ .option('--project-id <project-id>', 'Filter by project')
1077
+ .option('--channel-id <channel-id>', 'Filter by collaboration channel')
1078
+ .option('--scene <scene-id>', 'Filter by scene')
1079
+ .option('--spec <spec-id>', 'Filter by spec')
1080
+ .option('--limit <n>', 'Limit result count', parseInt)
1081
+ .option('--json', 'Print machine-readable JSON output')
1082
+ .action(async (options) => {
1083
+ try {
1084
+ await runSemanticPromotedCommand(options);
1085
+ } catch (error) {
1086
+ console.error(chalk.red(`Semantic promoted failed: ${error.message}`));
1087
+ process.exitCode = 1;
1088
+ }
1089
+ });
1090
+
1091
+ semantic
1092
+ .command('promote')
1093
+ .description('Promote a semantic lesson after it passes evaluation gates')
1094
+ .requiredOption('--lesson-id <lesson-id>', 'Lesson candidate id')
1095
+ .requiredOption('--eval-run-id <evaluation-run-id>', 'Evidence evaluation run id')
1096
+ .option('--actor <actor>', 'Audit actor')
1097
+ .option('--release-gate <release-gate>', 'Promotion gate or lane')
1098
+ .option('--json', 'Print machine-readable JSON output')
1099
+ .action(async (options) => {
1100
+ try {
1101
+ await runSemanticPromoteCommand(options);
1102
+ } catch (error) {
1103
+ console.error(chalk.red(`Semantic promote failed: ${error.message}`));
1104
+ process.exitCode = 1;
1105
+ }
1106
+ });
1107
+
1108
+ semantic
1109
+ .command('rollback')
1110
+ .description('Rollback one promoted semantic behavior')
1111
+ .requiredOption('--lesson-id <lesson-id>', 'Lesson candidate id')
1112
+ .option('--actor <actor>', 'Audit actor')
1113
+ .option('--reason <reason>', 'Rollback reason')
1114
+ .option('--json', 'Print machine-readable JSON output')
1115
+ .action(async (options) => {
1116
+ try {
1117
+ await runSemanticRollbackCommand(options);
1118
+ } catch (error) {
1119
+ console.error(chalk.red(`Semantic rollback failed: ${error.message}`));
1120
+ process.exitCode = 1;
1121
+ }
1122
+ });
1123
+
1124
+ semantic
1125
+ .command('progress')
1126
+ .description('Summarize semantic learning, evaluation, promotion, and native backflow progress')
1127
+ .option('--project-id <project-id>', 'Filter by project')
1128
+ .option('--spec <spec-id>', 'Filter by spec')
1129
+ .option('--session-id <session-id>', 'Filter by session')
1130
+ .option('--limit <n>', 'Scan limit', parseInt)
1131
+ .option('--json', 'Print machine-readable JSON output')
1132
+ .action(async (options) => {
1133
+ try {
1134
+ await runSemanticProgressCommand(options);
1135
+ } catch (error) {
1136
+ console.error(chalk.red(`Semantic progress failed: ${error.message}`));
1137
+ process.exitCode = 1;
1138
+ }
1139
+ });
1140
+
1141
+ semantic
1142
+ .command('supreme-intent')
1143
+ .description('List supreme-intent governance assessments from the SQLite/state ledger')
1144
+ .option('--project-id <project-id>', 'Filter by project')
1145
+ .option('--channel-id <channel-id>', 'Filter by channel')
1146
+ .option('--session-id <session-id>', 'Filter by session')
1147
+ .option('--scene <scene-id>', 'Filter by scene')
1148
+ .option('--spec <spec-id>', 'Filter by spec')
1149
+ .option('--job-id <job-id>', 'Filter by studio job id')
1150
+ .option('--source-kind <source-kind>', 'Filter by source kind, e.g. studio-plan or native-ask')
1151
+ .option('--action <action>', 'Filter by governance action')
1152
+ .option('--limit <n>', 'Limit result count', parseInt)
1153
+ .option('--json', 'Print machine-readable JSON output')
1154
+ .action(async (options) => {
1155
+ try {
1156
+ await runSemanticSupremeIntentListCommand(options);
1157
+ } catch (error) {
1158
+ console.error(chalk.red(`Semantic supreme-intent failed: ${error.message}`));
1159
+ process.exitCode = 1;
1160
+ }
1161
+ });
1162
+
1163
+ semantic
1164
+ .command('supreme-intent-show <assessment-id>')
1165
+ .description('Show one supreme-intent governance assessment from the SQLite/state ledger')
1166
+ .option('--json', 'Print machine-readable JSON output')
1167
+ .action(async (assessmentId, options) => {
1168
+ try {
1169
+ await runSemanticSupremeIntentShowCommand(assessmentId, options);
1170
+ } catch (error) {
1171
+ console.error(chalk.red(`Semantic supreme-intent-show failed: ${error.message}`));
1172
+ process.exitCode = 1;
1173
+ }
1174
+ });
1175
+
1176
+ semantic
1177
+ .command('governance-report')
1178
+ .description('Summarize supreme-intent governance hotspots from the SQLite/state ledger')
1179
+ .option('--project-id <project-id>', 'Filter by project')
1180
+ .option('--channel-id <channel-id>', 'Filter by channel')
1181
+ .option('--session-id <session-id>', 'Filter by session')
1182
+ .option('--scene <scene-id>', 'Filter by scene')
1183
+ .option('--spec <spec-id>', 'Filter by spec')
1184
+ .option('--job-id <job-id>', 'Filter by studio job id')
1185
+ .option('--source-kind <source-kind>', 'Filter by source kind')
1186
+ .option('--action <action>', 'Filter by governance action')
1187
+ .option('--limit <n>', 'Maximum assessments to scan', parseInt)
1188
+ .option('--hotspot-limit <n>', 'Maximum hotspot groups to return', parseInt)
1189
+ .option('--recent-limit <n>', 'Maximum recent governed items to return', parseInt)
1190
+ .option('--json', 'Print machine-readable JSON output')
1191
+ .action(async (options) => {
1192
+ try {
1193
+ await runSemanticGovernanceReportCommand(options);
1194
+ } catch (error) {
1195
+ console.error(chalk.red(`Semantic governance-report failed: ${error.message}`));
1196
+ process.exitCode = 1;
1197
+ }
1198
+ });
1199
+
1200
+ semantic
1201
+ .command('backflow-report')
1202
+ .description('Summarize local and central semantic backflow blockers across publication and registry gates')
1203
+ .option('--project-id <project-id>', 'Filter by project')
1204
+ .option('--spec <spec-id>', 'Filter by spec')
1205
+ .option('--limit <n>', 'Maximum lessons/ledgers to scan', parseInt)
1206
+ .option('--recent-limit <n>', 'Maximum recent blocked items/receipts to return', parseInt)
1207
+ .option('--json', 'Print machine-readable JSON output')
1208
+ .action(async (options) => {
1209
+ try {
1210
+ await runSemanticBackflowReportCommand(options);
1211
+ } catch (error) {
1212
+ console.error(chalk.red(`Semantic backflow-report failed: ${error.message}`));
1213
+ process.exitCode = 1;
1214
+ }
1215
+ });
1216
+
1217
+ semantic
1218
+ .command('archive-report')
1219
+ .description('Summarize how training value is routed and accumulated across the three semantic libraries')
1220
+ .option('--project-id <project-id>', 'Filter by project')
1221
+ .option('--spec <spec-id>', 'Filter by spec')
1222
+ .option('--session-id <session-id>', 'Filter by session')
1223
+ .option('--limit <n>', 'Maximum lessons/ledgers to scan', parseInt)
1224
+ .option('--recent-limit <n>', 'Maximum recent archived items to return', parseInt)
1225
+ .option('--json', 'Print machine-readable JSON output')
1226
+ .action(async (options) => {
1227
+ try {
1228
+ await runSemanticArchiveReportCommand(options);
1229
+ } catch (error) {
1230
+ console.error(chalk.red(`Semantic archive-report failed: ${error.message}`));
1231
+ process.exitCode = 1;
1232
+ }
1233
+ });
1234
+
1235
+ semantic
1236
+ .command('export-delta')
1237
+ .description('Export governed publish-pending semantic deltas for shared libraries')
1238
+ .option('--project-id <project-id>', 'Filter by project')
1239
+ .option('--spec <spec-id>', 'Filter by spec')
1240
+ .option('--limit <n>', 'Export limit', parseInt)
1241
+ .option('--out-file <path>', 'Optional output file path')
1242
+ .option('--json', 'Print machine-readable JSON output')
1243
+ .action(async (options) => {
1244
+ try {
1245
+ await runSemanticDeltaExportCommand(options);
1246
+ } catch (error) {
1247
+ console.error(chalk.red(`Semantic export-delta failed: ${error.message}`));
1248
+ process.exitCode = 1;
1249
+ }
1250
+ });
1251
+
1252
+ semantic
1253
+ .command('publish-delta')
1254
+ .description('Publish governed semantic deltas into the shared-library mirror and advance publish state')
1255
+ .option('--project-id <project-id>', 'Filter by project')
1256
+ .option('--spec <spec-id>', 'Filter by spec')
1257
+ .option('--input-file <path>', 'Existing delta manifest to publish')
1258
+ .option('--out-file <path>', 'Optional publication report output path')
1259
+ .option('--limit <n>', 'Publish limit', parseInt)
1260
+ .option('--json', 'Print machine-readable JSON output')
1261
+ .action(async (options) => {
1262
+ try {
1263
+ await runSemanticPublishDeltaCommand(options);
1264
+ } catch (error) {
1265
+ console.error(chalk.red(`Semantic publish-delta failed: ${error.message}`));
1266
+ process.exitCode = 1;
1267
+ }
1268
+ });
1269
+
1270
+ semantic
1271
+ .command('export-shared-sync')
1272
+ .description('Export the local semantic shared-library mirror into a governed spec-scoped sync bundle')
1273
+ .option('--project-id <project-id>', 'Filter by project')
1274
+ .option('--spec <spec-id>', 'Filter by spec and default output scope')
1275
+ .option('--lesson-id <lesson-id>', 'Filter by lesson id')
1276
+ .option('--capability-id <capability-id>', 'Filter by capability id')
1277
+ .option('--target-library <library>', 'Filter by target shared library')
1278
+ .option('--out-file <path>', 'Optional bundle output path')
1279
+ .option('--limit <n>', 'Export limit', parseInt)
1280
+ .option('--json', 'Print machine-readable JSON output')
1281
+ .action(async (options) => {
1282
+ try {
1283
+ await runSemanticExportSharedSyncCommand(options);
1284
+ } catch (error) {
1285
+ console.error(chalk.red(`Semantic export-shared-sync failed: ${error.message}`));
1286
+ process.exitCode = 1;
1287
+ }
1288
+ });
1289
+
1290
+ semantic
1291
+ .command('sync-shared')
1292
+ .description('Sync a governed semantic shared-sync bundle into the local shared-library mirror')
1293
+ .option('--source <url-or-path>', 'Shared-sync bundle source JSON')
1294
+ .option('--source-name <name>', 'Shared-sync source label')
1295
+ .option('--source-root <path-or-url>', 'Optional root path/url used to resolve shard files')
1296
+ .option('--required-release-state <state>', 'Require the bundle governance release state to match before intake')
1297
+ .option('--config <path>', 'Semantic shared source config path')
1298
+ .option('--spec <spec-id>', 'Spec id used for default receipt output')
1299
+ .option('--out-file <path>', 'Optional intake receipt output path')
1300
+ .option('--limit <n>', 'Maximum libraries to scan', parseInt)
1301
+ .option('--json', 'Print machine-readable JSON output')
1302
+ .action(async (options) => {
1303
+ try {
1304
+ await runSemanticSyncSharedCommand(options);
1305
+ } catch (error) {
1306
+ console.error(chalk.red(`Semantic sync-shared failed: ${error.message}`));
1307
+ process.exitCode = 1;
1308
+ }
1309
+ });
1310
+
1311
+ semantic
1312
+ .command('health-shared-source')
1313
+ .description('Validate one configured or explicit semantic shared-sync source without intaking it')
1314
+ .option('--source <url-or-path>', 'Shared-sync bundle source JSON')
1315
+ .option('--source-name <name>', 'Configured source name to inspect')
1316
+ .option('--source-root <path-or-url>', 'Optional root path/url used to resolve shard files')
1317
+ .option('--required-release-state <state>', 'Require the bundle governance release state to match during health checks')
1318
+ .option('--config <path>', 'Semantic shared source config path')
1319
+ .option('--json', 'Print machine-readable JSON output')
1320
+ .action(async (options) => {
1321
+ try {
1322
+ await runSemanticHealthSharedSourceCommand(options);
1323
+ } catch (error) {
1324
+ console.error(chalk.red(`Semantic health-shared-source failed: ${error.message}`));
1325
+ process.exitCode = 1;
1326
+ }
1327
+ });
1328
+
1329
+ semantic
1330
+ .command('list-shared-sources')
1331
+ .description('List configured semantic shared sources and their release-state policy')
1332
+ .option('--config <path>', 'Semantic shared source config path')
1333
+ .option('--json', 'Print machine-readable JSON output')
1334
+ .action(async (options) => {
1335
+ try {
1336
+ await runSemanticListSharedSourcesCommand(options);
1337
+ } catch (error) {
1338
+ console.error(chalk.red(`Semantic list-shared-sources failed: ${error.message}`));
1339
+ process.exitCode = 1;
1340
+ }
1341
+ });
1342
+
1343
+ semantic
1344
+ .command('set-shared-source')
1345
+ .description('Upsert one configured semantic shared source into .sce/config/semantic-shared-sources.json')
1346
+ .option('--input-file <path>', 'Optional published shared source descriptor JSON')
1347
+ .option('--name <name>', 'Configured source name')
1348
+ .option('--bundle <url-or-path>', 'Bundle file/url for the shared source')
1349
+ .option('--root <path-or-url>', 'Optional root path/url used to resolve shard files')
1350
+ .option('--enabled <true|false>', 'Whether the source should be enabled')
1351
+ .option('--required-release-state <state>', 'Optional required governance release state for this source')
1352
+ .option('--config <path>', 'Semantic shared source config path')
1353
+ .option('--json', 'Print machine-readable JSON output')
1354
+ .action(async (options) => {
1355
+ try {
1356
+ await runSemanticSetSharedSourceCommand(options);
1357
+ } catch (error) {
1358
+ console.error(chalk.red(`Semantic set-shared-source failed: ${error.message}`));
1359
+ process.exitCode = 1;
1360
+ }
1361
+ });
1362
+
1363
+ semantic
1364
+ .command('connect-shared-source')
1365
+ .description('Consume one approved source descriptor, register the source, run health gate, and sync it into the local mirror')
1366
+ .option('--input-file <path>', 'Published shared source descriptor JSON')
1367
+ .option('--spec <spec-id>', 'Use the default published descriptor under this spec')
1368
+ .option('--name <name>', 'Optional source name override')
1369
+ .option('--bundle <url-or-path>', 'Optional bundle override')
1370
+ .option('--root <path-or-url>', 'Optional root override')
1371
+ .option('--enabled <true|false>', 'Optional enabled override')
1372
+ .option('--required-release-state <state>', 'Optional required release state override')
1373
+ .option('--config <path>', 'Semantic shared source config path')
1374
+ .option('--no-health-check', 'Skip health gate after source registration')
1375
+ .option('--no-sync-now', 'Register the source but do not sync immediately')
1376
+ .option('--allow-non-approved', 'Allow descriptors whose release state is not approved-central')
1377
+ .option('--json', 'Print machine-readable JSON output')
1378
+ .action(async (options) => {
1379
+ try {
1380
+ await runSemanticConnectSharedSourceCommand(options);
1381
+ } catch (error) {
1382
+ console.error(chalk.red(`Semantic connect-shared-source failed: ${error.message}`));
1383
+ process.exitCode = 1;
1384
+ }
1385
+ });
1386
+
1387
+ semantic
1388
+ .command('merge-shared')
1389
+ .description('Merge multiple governed semantic shared-sync bundles into one central/shared-truth candidate bundle')
1390
+ .option('--source <url-or-path>', 'Shared-sync bundle source (repeat to accumulate)', (value, previous = []) => [...previous, value], [])
1391
+ .option('--sources <csv>', 'Shared-sync bundle sources as csv')
1392
+ .option('--config <path>', 'Semantic shared source config path')
1393
+ .option('--spec <spec-id>', 'Spec id used for default registry output paths')
1394
+ .option('--out-file <path>', 'Optional merged bundle output path')
1395
+ .option('--limit <n>', 'Maximum merged entries retained', parseInt)
1396
+ .option('--json', 'Print machine-readable JSON output')
1397
+ .action(async (options) => {
1398
+ try {
1399
+ await runSemanticMergeSharedCommand(options);
1400
+ } catch (error) {
1401
+ console.error(chalk.red(`Semantic merge-shared failed: ${error.message}`));
1402
+ process.exitCode = 1;
1403
+ }
1404
+ });
1405
+
1406
+ semantic
1407
+ .command('publish-shared-registry')
1408
+ .description('Promote one merged semantic shared candidate bundle into the approved central registry after release gates pass')
1409
+ .option('--spec <spec-id>', 'Spec id used for default candidate input and published output paths')
1410
+ .option('--input-file <path>', 'Candidate bundle input path')
1411
+ .option('--out-file <path>', 'Optional approved bundle output path')
1412
+ .option('--index-file <path>', 'Optional approved index output path')
1413
+ .option('--receipt-file <path>', 'Optional publish receipt output path')
1414
+ .option('--source-name <name>', 'Descriptor source name emitted alongside the approved bundle')
1415
+ .option('--source-descriptor-file <path>', 'Optional output path for the published source descriptor')
1416
+ .option('--public-bundle <url-or-path>', 'Optional public bundle url/path written into the source descriptor')
1417
+ .option('--public-root <url-or-path>', 'Optional public root url/path written into the source descriptor')
1418
+ .option('--min-sources <n>', 'Minimum required merged source count', parseInt)
1419
+ .option('--min-entries <n>', 'Minimum required merged entry count', parseInt)
1420
+ .option('--no-require-zero-blocked', 'Allow publishing candidates that still carry blocked merge items')
1421
+ .option('--json', 'Print machine-readable JSON output')
1422
+ .action(async (options) => {
1423
+ try {
1424
+ await runSemanticPublishSharedRegistryCommand(options);
1425
+ } catch (error) {
1426
+ console.error(chalk.red(`Semantic publish-shared-registry failed: ${error.message}`));
1427
+ process.exitCode = 1;
1428
+ }
1429
+ });
1430
+ }
1431
+
1432
+ module.exports = {
1433
+ runSemanticObserveCommand,
1434
+ runSemanticListCommand,
1435
+ runSemanticLessonsCommand,
1436
+ runSemanticReplayCommand,
1437
+ runSemanticEvalCommand,
1438
+ runSemanticEvalRunsCommand,
1439
+ runSemanticPromotedCommand,
1440
+ runSemanticPromoteCommand,
1441
+ runSemanticRollbackCommand,
1442
+ runSemanticProgressCommand,
1443
+ runSemanticSupremeIntentListCommand,
1444
+ runSemanticSupremeIntentShowCommand,
1445
+ runSemanticGovernanceReportCommand,
1446
+ runSemanticBackflowReportCommand,
1447
+ runSemanticArchiveReportCommand,
1448
+ runSemanticDeltaExportCommand,
1449
+ runSemanticPublishDeltaCommand,
1450
+ runSemanticExportSharedSyncCommand,
1451
+ runSemanticSyncSharedCommand,
1452
+ runSemanticHealthSharedSourceCommand,
1453
+ runSemanticListSharedSourcesCommand,
1454
+ runSemanticSetSharedSourceCommand,
1455
+ runSemanticConnectSharedSourceCommand,
1456
+ runSemanticMergeSharedCommand,
1457
+ runSemanticPublishSharedRegistryCommand,
1458
+ registerSemanticCommands
1459
+ };