@devilsdev/rag-pipeline-utils 2.4.4 โ†’ 2.5.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 (225) hide show
  1. package/.ragrc.schema.json +83 -192
  2. package/CHANGELOG.md +345 -0
  3. package/README.md +418 -117
  4. package/SECURITY.md +5 -5
  5. package/dist/experimental.cjs +2 -0
  6. package/dist/experimental.d.ts +1 -0
  7. package/dist/experimental.mjs +5 -0
  8. package/dist/index.cjs +4992 -1242
  9. package/dist/index.d.ts +80 -2
  10. package/dist/index.mjs +1 -1
  11. package/dist/types/agentic/agentic-pipeline.d.ts +103 -0
  12. package/dist/types/agentic/iterative-retriever.d.ts +85 -0
  13. package/dist/types/agentic/query-planner.d.ts +145 -0
  14. package/dist/types/agentic/self-critique.d.ts +45 -0
  15. package/dist/types/ai/adaptive-retrieval.d.ts +44 -0
  16. package/dist/types/ai/federation/federated-learning-coordinator.d.ts +62 -0
  17. package/dist/types/ai/multimodal-processing.d.ts +32 -0
  18. package/dist/types/ai/multimodal.d.ts +39 -0
  19. package/dist/types/ai/retrieval-engine.d.ts +37 -0
  20. package/dist/types/ai/training/model-training-orchestrator.d.ts +31 -0
  21. package/dist/types/chunking/chunking-engine.d.ts +70 -0
  22. package/dist/types/chunking/strategies/fixed-size.d.ts +17 -0
  23. package/dist/types/chunking/strategies/recursive.d.ts +20 -0
  24. package/dist/types/chunking/strategies/semantic.d.ts +19 -0
  25. package/dist/types/chunking/strategies/sentence.d.ts +13 -0
  26. package/dist/types/chunking/strategies/structure-aware.d.ts +19 -0
  27. package/dist/types/citation/citation-tracker.d.ts +64 -0
  28. package/dist/types/citation/hallucination-detector.d.ts +40 -0
  29. package/dist/types/citation/source-mapper.d.ts +37 -0
  30. package/dist/types/connectors/anthropic-connector.d.ts +92 -0
  31. package/dist/types/connectors/base-connector.d.ts +87 -0
  32. package/dist/types/connectors/cohere-connector.d.ts +89 -0
  33. package/dist/types/connectors/connector-utils.d.ts +110 -0
  34. package/dist/types/connectors/local-embedder.d.ts +86 -0
  35. package/dist/types/connectors/memory-retriever.d.ts +91 -0
  36. package/dist/types/connectors/ollama-connector.d.ts +110 -0
  37. package/dist/types/connectors/openai-connector.d.ts +114 -0
  38. package/dist/types/connectors/rag-prompt.d.ts +40 -0
  39. package/dist/types/cost/cost-calculator.d.ts +152 -0
  40. package/dist/types/cost/cost-tracker.d.ts +126 -0
  41. package/dist/types/cost/token-budget.d.ts +110 -0
  42. package/dist/types/dag/core/error-context.d.ts +239 -0
  43. package/dist/types/dag/core/execution-scheduler.d.ts +191 -0
  44. package/dist/types/dag/core/topology-validation.d.ts +226 -0
  45. package/dist/types/dag/dag-engine.d.ts +156 -0
  46. package/dist/types/dag/dag-node.d.ts +37 -0
  47. package/dist/types/dashboard/dashboard-generator.d.ts +127 -0
  48. package/dist/types/dashboard/metrics-aggregator.d.ts +218 -0
  49. package/dist/types/debug/execution-tracer.d.ts +57 -0
  50. package/dist/types/debug/trace-inspector.d.ts +31 -0
  51. package/dist/types/ecosystem/plugin-certification.d.ts +169 -0
  52. package/dist/types/enterprise/data-governance.d.ts +203 -0
  53. package/dist/types/enterprise/multi-tenancy.d.ts +137 -0
  54. package/dist/types/enterprise/sso-integration.d.ts +420 -0
  55. package/dist/types/evaluate/context-metrics.d.ts +55 -0
  56. package/dist/types/evaluate/faithfulness.d.ts +41 -0
  57. package/dist/types/evaluate/groundedness.d.ts +60 -0
  58. package/dist/types/evaluate/pipeline-evaluator.d.ts +88 -0
  59. package/dist/types/evaluate/relevance.d.ts +21 -0
  60. package/dist/types/evaluate/scoring.d.ts +123 -0
  61. package/dist/types/experimental.d.ts +15 -0
  62. package/dist/types/graph/entity-extractor.d.ts +84 -0
  63. package/dist/types/graph/graph-index.d.ts +49 -0
  64. package/dist/types/graph/graph-retriever.d.ts +81 -0
  65. package/dist/types/graph/knowledge-graph.d.ts +129 -0
  66. package/dist/types/guardrails/guardrails-pipeline.d.ts +63 -0
  67. package/dist/types/guardrails/injection-detector.d.ts +47 -0
  68. package/dist/types/guardrails/post-generation-guard.d.ts +61 -0
  69. package/dist/types/guardrails/pre-retrieval-guard.d.ts +64 -0
  70. package/dist/types/guardrails/retrieval-guard.d.ts +57 -0
  71. package/dist/types/mcp/mcp-server.d.ts +85 -0
  72. package/dist/types/mcp/mcp-tool-builder.d.ts +55 -0
  73. package/dist/types/reranker/cascade-reranker.d.ts +40 -0
  74. package/dist/types/reranker/embedding-reranker.d.ts +77 -0
  75. package/dist/types/reranker/scoring-reranker.d.ts +41 -0
  76. package/dist/types/retrieval/bm25-search.d.ts +43 -0
  77. package/dist/types/retrieval/file-vector-store.d.ts +87 -0
  78. package/dist/types/retrieval/hybrid-retriever.d.ts +35 -0
  79. package/dist/types/retrieval/rank-fusion.d.ts +10 -0
  80. package/dist/types/security/jwt-config.d.ts +80 -0
  81. package/dist/types/security/jwt-validator.d.ts +195 -0
  82. package/dist/types/security/plugin-sandbox.d.ts +158 -0
  83. package/dist/types/security/plugin-signature-verifier.d.ts +139 -0
  84. package/dist/types/security/validator.d.ts +5 -0
  85. package/dist/types/streaming/embedding-stream.d.ts +65 -0
  86. package/dist/types/streaming/sse-adapter.d.ts +59 -0
  87. package/dist/types/streaming/stream-router.d.ts +88 -0
  88. package/dist/types/streaming/streaming-embedder.d.ts +99 -0
  89. package/dist/types/streaming/websocket-adapter.d.ts +71 -0
  90. package/dist/types/templates/scaffold.d.ts +55 -0
  91. package/dist/types/templates/template-registry.d.ts +63 -0
  92. package/dist/types/utils/embed-query.d.ts +20 -0
  93. package/dist/types/utils/logger.d.ts +50 -0
  94. package/dist/types/utils/rate-limiter.d.ts +66 -0
  95. package/dist/types/utils/retry.d.ts +27 -0
  96. package/dist/types/utils/run-abort.d.ts +34 -0
  97. package/dist/types/utils/secure-logging.d.ts +51 -0
  98. package/dist/types/utils/structured-logger.d.ts +126 -0
  99. package/package.json +53 -29
  100. package/src/agentic/agentic-pipeline.js +75 -7
  101. package/src/agentic/iterative-retriever.js +47 -10
  102. package/src/agentic/query-planner.js +329 -78
  103. package/src/citation/citation-tracker.js +6 -4
  104. package/src/citation/hallucination-detector.js +2 -2
  105. package/src/citation/source-mapper.js +15 -28
  106. package/src/cli/commands/ai.js +101 -0
  107. package/src/cli/commands/plugin-hub/event-handlers.js +6 -0
  108. package/src/cli/commands/plugin-hub/hub-commands.js +0 -74
  109. package/src/cli/commands/plugin-hub/local-commands.js +143 -0
  110. package/src/cli/commands/plugin-hub.js +96 -36
  111. package/src/cli/diagnostics/config-checker.js +76 -63
  112. package/src/cli/diagnostics/environment-checker.js +62 -31
  113. package/src/cli/diagnostics/plugin-checker.js +36 -89
  114. package/src/cli/doctor-command.js +39 -5
  115. package/src/cli/enhanced-cli-commands.js +72 -217
  116. package/src/cli/handlers/ai-handler.js +364 -0
  117. package/src/cli/handlers/diagnostics-handler.js +78 -31
  118. package/src/cli/handlers/ingest-handler.js +28 -22
  119. package/src/cli/handlers/init-handler.js +148 -25
  120. package/src/cli/handlers/query-handler.js +41 -26
  121. package/src/cli/handlers/run-handler.js +16 -167
  122. package/src/cli/handlers/serve-handler.js +60 -0
  123. package/src/cli/services/bench-stats.js +54 -0
  124. package/src/cli/services/benchmark.js +161 -0
  125. package/src/cli/services/feedback.js +155 -0
  126. package/src/cli/services/rag-service.js +322 -0
  127. package/src/cli/shared/cli-utils.js +24 -7
  128. package/src/cli/shared/config-context.js +21 -0
  129. package/src/cli/wizard/config-builder.js +81 -0
  130. package/src/cli/wizard/init-wizard.js +617 -0
  131. package/src/config/component-factory.js +125 -0
  132. package/src/config/load-config.js +29 -10
  133. package/src/config/load-plugin-config.js +46 -2
  134. package/src/connectors/anthropic-connector.js +93 -55
  135. package/src/connectors/base-connector.js +74 -19
  136. package/src/connectors/cohere-connector.js +88 -32
  137. package/src/connectors/connector-utils.js +302 -0
  138. package/src/connectors/local-embedder.js +43 -5
  139. package/src/connectors/memory-retriever.js +108 -15
  140. package/src/connectors/ollama-connector.js +83 -49
  141. package/src/connectors/openai-connector.js +108 -44
  142. package/src/connectors/rag-prompt.js +88 -0
  143. package/src/core/create-pipeline.js +209 -60
  144. package/src/core/plugin-registry.js +87 -11
  145. package/src/cost/cost-calculator.js +205 -32
  146. package/src/dev/dev-server.js +166 -11
  147. package/src/dev/hot-reload.js +40 -1
  148. package/src/ecosystem/plugin-checks.js +181 -0
  149. package/src/ecosystem/plugin-hub.js +50 -125
  150. package/src/ecosystem/plugin-installer.js +298 -0
  151. package/src/ecosystem/plugin-probe.js +127 -0
  152. package/src/ecosystem/plugin-scanner.js +185 -0
  153. package/src/ecosystem/tar-extract.js +114 -0
  154. package/src/enterprise/audit-logging.js +158 -29
  155. package/src/enterprise/sso-integration.js +715 -228
  156. package/src/evaluate/context-metrics.js +28 -16
  157. package/src/evaluate/evaluator.js +3 -3
  158. package/src/evaluate/faithfulness.js +18 -14
  159. package/src/evaluate/groundedness.js +43 -12
  160. package/src/evaluate/pipeline-evaluator.js +35 -8
  161. package/src/evaluate/scoring.js +251 -3
  162. package/src/experimental.js +71 -0
  163. package/src/guardrails/guardrails-pipeline.js +69 -7
  164. package/src/guardrails/injection-detector.js +283 -0
  165. package/src/guardrails/post-generation-guard.js +19 -0
  166. package/src/guardrails/pre-retrieval-guard.js +36 -36
  167. package/src/guardrails/retrieval-guard.js +58 -8
  168. package/src/index.js +36 -1
  169. package/src/loader/document-reader.js +91 -0
  170. package/src/reranker/cascade-reranker.js +3 -0
  171. package/src/reranker/embedding-reranker.js +136 -21
  172. package/src/reranker/llm-reranker.js +79 -12
  173. package/src/reranker/scoring-reranker.js +3 -0
  174. package/src/retrieval/bm25-search.js +12 -6
  175. package/src/retrieval/file-vector-store.js +212 -0
  176. package/src/retrieval/hybrid-retriever.js +22 -19
  177. package/src/security/jwt-config.js +13 -2
  178. package/src/security/jwt-validator.js +134 -30
  179. package/src/security/plugin-sandbox.js +18 -1
  180. package/src/security/plugin-signature-verifier.js +245 -70
  181. package/src/utils/deprecate.js +69 -0
  182. package/src/utils/embed-query.js +33 -0
  183. package/src/utils/input-sanitizer.js +19 -4
  184. package/src/utils/logger.js +34 -4
  185. package/src/utils/run-abort.js +102 -0
  186. package/src/ai/federated-learning.js +0 -211
  187. package/src/ai/federation.js +0 -71
  188. package/src/ai/index.js +0 -22
  189. package/src/ai/model-trainer.js +0 -217
  190. package/src/ai/model-training.js +0 -202
  191. package/src/ai/multimodal/multi-modal-processor.js +0 -345
  192. package/src/ai/orchestrator.js +0 -65
  193. package/src/ai/retrieval/adaptive-retrieval-engine.js +0 -398
  194. package/src/cli/commands/ai-ml/adaptive-commands.js +0 -178
  195. package/src/cli/commands/ai-ml/federated-commands.js +0 -207
  196. package/src/cli/commands/ai-ml/index.js +0 -17
  197. package/src/cli/commands/ai-ml/multimodal-commands.js +0 -187
  198. package/src/cli/commands/ai-ml/shared.js +0 -51
  199. package/src/cli/commands/ai-ml/training-commands.js +0 -228
  200. package/src/cli/commands/ai-ml.js +0 -386
  201. package/src/cli/commands/docs.js +0 -228
  202. package/src/cli/commands/dx.js +0 -538
  203. package/src/cli/commands/wizard.js +0 -627
  204. package/src/cli/input-sanitization-middleware.js +0 -356
  205. package/src/cli/interactive-wizard.js +0 -373
  206. package/src/cli/templates/development.template.json +0 -64
  207. package/src/cli/templates/minimal.template.json +0 -33
  208. package/src/cli/templates/production.template.json +0 -104
  209. package/src/cli/templates/testing.template.json +0 -45
  210. package/src/cli/wizard/configuration.js +0 -148
  211. package/src/cli/wizard/observability.js +0 -79
  212. package/src/cli/wizard/performance.js +0 -76
  213. package/src/cli/wizard/plugin-selection.js +0 -297
  214. package/src/cli/wizard/preview-save.js +0 -172
  215. package/src/cli/wizard/project-setup.js +0 -66
  216. package/src/core/pipeline-factory.js +0 -59
  217. package/src/dag/enhanced-dag-engine.js +0 -894
  218. package/src/dx/index.js +0 -40
  219. package/src/dx/integration-templates.js +0 -662
  220. package/src/dx/performance-profiler.js +0 -968
  221. package/src/dx/realtime-debugger.js +0 -755
  222. package/src/dx/visual-pipeline-builder.js +0 -578
  223. package/src/ingest.js +0 -59
  224. package/src/pipeline/pipeline.js +0 -18
  225. package/src/query.js +0 -117
@@ -1,386 +0,0 @@
1
- /**
2
- * Advanced AI/ML CLI Commands
3
- * Command-line interface for model training, adaptive retrieval, multi-modal processing, and federated learning
4
- *
5
- * This module is a thin aggregator that delegates to domain-specific modules
6
- * in the ai-ml/ directory.
7
- */
8
-
9
- const chalk = require("chalk");
10
- // eslint-disable-line global-require
11
- const ora = require("ora");
12
- // eslint-disable-line global-require
13
- const Table = require("cli-table3");
14
- // eslint-disable-line global-require
15
- const fs = require("fs").promises;
16
- // eslint-disable-line global-require
17
-
18
- const {
19
- ModelTrainingOrchestrator,
20
- AdaptiveRetrievalEngine,
21
- MultiModalProcessor,
22
- FederatedLearningCoordinator,
23
- } = require("../../ai");
24
- // eslint-disable-line global-require
25
-
26
- const {
27
- trainingCommands,
28
- adaptiveCommands,
29
- multimodalCommands,
30
- federatedCommands,
31
- } = require("./ai-ml/index");
32
-
33
- const { colorizeStatus, detectContentType } = require("./ai-ml/shared");
34
-
35
- class AIMLCommands {
36
- constructor() {
37
- this.modelTrainer = new ModelTrainingOrchestrator();
38
- this.adaptiveRetrieval = new AdaptiveRetrievalEngine();
39
- this.multiModalProcessor = new MultiModalProcessor();
40
- this.federatedLearning = new FederatedLearningCoordinator();
41
- }
42
-
43
- /**
44
- * Register all AI/ML commands
45
- */
46
- registerCommands(program) {
47
- const aiCommand = program
48
- .command("ai")
49
- .description("Advanced AI/ML capabilities");
50
-
51
- // Model Training Commands
52
- const trainCommand = aiCommand
53
- .command("train")
54
- .description("Model training and fine-tuning");
55
-
56
- trainCommand
57
- .command("embedding")
58
- .description("Train custom embedding model")
59
- .option("-t, --tenant <id>", "Tenant ID")
60
- .option("-d, --dataset <path>", "Dataset path")
61
- .option("-a, --architecture <arch>", "Model architecture", "transformer")
62
- .option("-e, --epochs <num>", "Number of epochs", "10")
63
- .option("-b, --batch-size <size>", "Batch size", "32")
64
- .option("-l, --learning-rate <rate>", "Learning rate", "0.001")
65
- .option("--optimize", "Enable hyperparameter optimization")
66
- .action(this.trainEmbeddingModel.bind(this));
67
-
68
- trainCommand
69
- .command("llm")
70
- .description("Fine-tune language model")
71
- .option("-t, --tenant <id>", "Tenant ID")
72
- .option("-d, --dataset <path>", "Dataset path")
73
- .option("-m, --base-model <model>", "Base model", "gpt-3.5-turbo")
74
- .option("-e, --epochs <num>", "Number of epochs", "5")
75
- .option("--lora", "Use LoRA fine-tuning")
76
- .action(this.fineTuneLLM.bind(this));
77
-
78
- trainCommand
79
- .command("status <jobId>")
80
- .description("Check training job status")
81
- .action(this.checkTrainingStatus.bind(this));
82
-
83
- trainCommand
84
- .command("deploy <jobId>")
85
- .description("Deploy trained model")
86
- .option("-e, --environment <env>", "Deployment environment", "staging")
87
- .option("--auto-scale", "Enable auto-scaling")
88
- .action(this.deployModel.bind(this));
89
-
90
- // Adaptive Retrieval Commands
91
- const adaptiveCommand = aiCommand
92
- .command("adaptive")
93
- .description("Adaptive retrieval system");
94
-
95
- adaptiveCommand
96
- .command("profile <userId>")
97
- .description("Initialize or view user profile")
98
- .option("-i, --interests <interests>", "User interests (comma-separated)")
99
- .option("-e, --expertise <level>", "Expertise level", "intermediate")
100
- .action(this.manageUserProfile.bind(this));
101
-
102
- adaptiveCommand
103
- .command("search <userId> <query>")
104
- .description("Perform adaptive search")
105
- .option("-n, --max-results <num>", "Maximum results", "10")
106
- .option("--explain", "Show adaptation explanation")
107
- .action(this.adaptiveSearch.bind(this));
108
-
109
- adaptiveCommand
110
- .command("feedback <userId>")
111
- .description("Provide feedback for learning")
112
- .option("-q, --query <query>", "Original query")
113
- .option("-r, --ratings <ratings>", "Result ratings (comma-separated)")
114
- .action(this.provideFeedback.bind(this));
115
-
116
- // Multi-modal Processing Commands
117
- const multimodalCommand = aiCommand
118
- .command("multimodal")
119
- .description("Multi-modal content processing");
120
-
121
- multimodalCommand
122
- .command("process <contentPath>")
123
- .description("Process multi-modal content")
124
- .option("-t, --tenant <id>", "Tenant ID")
125
- .option("-o, --output <path>", "Output path for results")
126
- .option("--extract-text", "Extract text from images/videos")
127
- .action(this.processMultiModalContent.bind(this));
128
-
129
- multimodalCommand
130
- .command("search <tenantId>")
131
- .description("Multi-modal search")
132
- .option("-q, --query <query>", "Text query")
133
- .option("-i, --image <path>", "Image query path")
134
- .option("-a, --audio <path>", "Audio query path")
135
- .option("-n, --max-results <num>", "Maximum results", "10")
136
- .action(this.multiModalSearch.bind(this));
137
-
138
- multimodalCommand
139
- .command("describe <contentId>")
140
- .description("Generate content description")
141
- .option("--detailed", "Generate detailed description")
142
- .action(this.describeContent.bind(this));
143
-
144
- // Federated Learning Commands
145
- const federatedCommand = aiCommand
146
- .command("federated")
147
- .description("Federated learning coordination");
148
-
149
- federatedCommand
150
- .command("create-federation")
151
- .description("Create federated learning session")
152
- .option("-t, --tenant <id>", "Tenant ID")
153
- .option("-m, --model-_type <_type>", "Model _type", "embedding")
154
- .option("-a, --architecture <arch>", "Model architecture", "transformer")
155
- .option("--min-participants <num>", "Minimum participants", "3")
156
- .option("--max-participants <num>", "Maximum participants", "10")
157
- .action(this.createFederation.bind(this));
158
-
159
- federatedCommand
160
- .command("join <federationId>")
161
- .description("Join federated learning session")
162
- .option("-t, --tenant <id>", "Tenant ID")
163
- .option("-d, --data-size <size>", "Data size")
164
- .option("-c, --compute-capacity <capacity>", "Compute capacity (0-1)")
165
- .option("-p, --privacy-level <level>", "Privacy level", "standard")
166
- .action(this.joinFederation.bind(this));
167
-
168
- federatedCommand
169
- .command("start-round <federationId>")
170
- .description("Start federated learning round")
171
- .action(this.startFederatedRound.bind(this));
172
-
173
- federatedCommand
174
- .command("stats <federationId>")
175
- .description("Show federation statistics")
176
- .option("--detailed", "Show detailed statistics")
177
- .action(this.showFederationStats.bind(this));
178
-
179
- // General AI Commands
180
- aiCommand
181
- .command("benchmark")
182
- .description("Run AI/ML benchmarks")
183
- .option("-t, --tenant <id>", "Tenant ID")
184
- .option("-m, --models <models>", "Models to benchmark (comma-separated)")
185
- .option("-o, --output <path>", "Output path for results")
186
- .action(this.runBenchmarks.bind(this));
187
-
188
- aiCommand
189
- .command("dashboard")
190
- .description("Launch AI/ML dashboard")
191
- .option("-p, --port <port>", "Dashboard port", "3001")
192
- .option("--open", "Open browser automatically")
193
- .action(this.launchDashboard.bind(this));
194
- }
195
-
196
- // --- Delegating methods ---
197
-
198
- // Model Training Commands
199
- async trainEmbeddingModel(_options) {
200
- return trainingCommands.trainEmbeddingModel(this.modelTrainer, _options);
201
- }
202
-
203
- async fineTuneLLM(_options) {
204
- return trainingCommands.fineTuneLLM(this.modelTrainer, _options);
205
- }
206
-
207
- async checkTrainingStatus(jobId) {
208
- return trainingCommands.checkTrainingStatus(this.modelTrainer, jobId);
209
- }
210
-
211
- async deployModel(jobId, _options) {
212
- return trainingCommands.deployModel(this.modelTrainer, jobId, _options);
213
- }
214
-
215
- // Adaptive Retrieval Commands
216
- async manageUserProfile(userId, _options) {
217
- return adaptiveCommands.manageUserProfile(
218
- this.adaptiveRetrieval,
219
- userId,
220
- _options,
221
- );
222
- }
223
-
224
- async adaptiveSearch(userId, query, _options) {
225
- return adaptiveCommands.adaptiveSearch(
226
- this.adaptiveRetrieval,
227
- userId,
228
- query,
229
- _options,
230
- );
231
- }
232
-
233
- async provideFeedback(userId, _options) {
234
- return adaptiveCommands.provideFeedback(
235
- this.adaptiveRetrieval,
236
- userId,
237
- _options,
238
- );
239
- }
240
-
241
- // Multi-modal Processing Commands
242
- async processMultiModalContent(contentPath, _options) {
243
- return multimodalCommands.processMultiModalContent(
244
- this.multiModalProcessor,
245
- contentPath,
246
- _options,
247
- );
248
- }
249
-
250
- async multiModalSearch(tenantId, _options) {
251
- return multimodalCommands.multiModalSearch(
252
- this.multiModalProcessor,
253
- tenantId,
254
- _options,
255
- );
256
- }
257
-
258
- async describeContent(contentId, _options) {
259
- return multimodalCommands.describeContent(
260
- this.multiModalProcessor,
261
- contentId,
262
- _options,
263
- );
264
- }
265
-
266
- // Federated Learning Commands
267
- async createFederation(_options) {
268
- return federatedCommands.createFederation(this.federatedLearning, _options);
269
- }
270
-
271
- async joinFederation(federationId, _options) {
272
- return federatedCommands.joinFederation(
273
- this.federatedLearning,
274
- federationId,
275
- _options,
276
- );
277
- }
278
-
279
- async startFederatedRound(federationId) {
280
- return federatedCommands.startFederatedRound(
281
- this.federatedLearning,
282
- federationId,
283
- );
284
- }
285
-
286
- async showFederationStats(federationId, _options) {
287
- return federatedCommands.showFederationStats(
288
- this.federatedLearning,
289
- federationId,
290
- _options,
291
- );
292
- }
293
-
294
- // Utility Commands (kept in aggregator as they don't belong to a specific domain)
295
- async runBenchmarks(_options) {
296
- const spinner = ora("Running AI/ML benchmarks...").start();
297
-
298
- try {
299
- // Mock benchmark implementation
300
- const benchmarks = {
301
- embedding: {
302
- latency: "45ms",
303
- throughput: "2000 docs/sec",
304
- accuracy: 0.89,
305
- },
306
- retrieval: {
307
- latency: "12ms",
308
- throughput: "5000 queries/sec",
309
- recall: 0.92,
310
- },
311
- generation: {
312
- latency: "150ms",
313
- throughput: "500 tokens/sec",
314
- quality: 0.85,
315
- },
316
- };
317
-
318
- spinner.succeed("Benchmarks completed");
319
-
320
- const table = new Table({
321
- head: ["Model", "Latency", "Throughput", "Quality Score"],
322
- colWidths: [15, 15, 20, 15],
323
- });
324
-
325
- Object.entries(benchmarks).forEach(([model, metrics]) => {
326
- table.push([
327
- model,
328
- metrics.latency,
329
- metrics.throughput,
330
- (metrics.accuracy || metrics.recall || metrics.quality)?.toFixed(3),
331
- ]);
332
- });
333
-
334
- console.log(table.toString());
335
- // eslint-disable-line no-console
336
-
337
- if (_options.output) {
338
- await fs.writeFile(
339
- _options.output,
340
- JSON.stringify(benchmarks, null, 2),
341
- );
342
- console.log(chalk.gray(`Results saved to: ${_options.output}`));
343
- // eslint-disable-line no-console
344
- }
345
- } catch (error) {
346
- spinner.fail(`Benchmark failed: ${error.message}`);
347
- }
348
- }
349
-
350
- async launchDashboard(_options) {
351
- console.log(chalk.blue("๐Ÿš€ Launching AI/ML Dashboard..."));
352
- // eslint-disable-line no-console
353
- console.log(chalk.gray(`Port: ${_options.port}`));
354
- // eslint-disable-line no-console
355
- console.log(chalk.gray(`URL: http://localhost:${_options.port}`)); // eslint-disable-line no-console
356
-
357
- if (_options.open) {
358
- console.log(chalk.green("Opening browser..."));
359
- // eslint-disable-line no-console
360
- }
361
-
362
- console.log(chalk.yellow("\nDashboard features:"));
363
- // eslint-disable-line no-console
364
- console.log("โ€ข Model training monitoring");
365
- // eslint-disable-line no-console
366
- console.log("โ€ข Adaptive retrieval analytics");
367
- // eslint-disable-line no-console
368
- console.log("โ€ข Multi-modal content explorer");
369
- // eslint-disable-line no-console
370
- console.log("โ€ข Federated learning coordinator");
371
- // eslint-disable-line no-console
372
- console.log("โ€ข Performance benchmarks");
373
- // eslint-disable-line no-console
374
- }
375
-
376
- // Helper methods (delegated to shared module, kept here for backward compatibility)
377
- _colorizeStatus(status) {
378
- return colorizeStatus(status);
379
- }
380
-
381
- _detectContentType(filePath) {
382
- return detectContentType(filePath);
383
- }
384
- }
385
-
386
- module.exports = AIMLCommands;
@@ -1,228 +0,0 @@
1
- /**
2
- * Documentation Automation CLI Commands
3
- * Comprehensive CLI interface for JSDoc automation, example synchronization, and interactive documentation
4
- */
5
-
6
- const { Command } = require('commander');
7
- // eslint-disable-line global-require
8
- const { JSDocAutomation } = require('../../docs/jsdoc-automation.js');
9
- // eslint-disable-line global-require
10
- const {
11
- ExampleSynchronization,
12
- } = require('../../docs/example-synchronization.js');
13
- // eslint-disable-line global-require
14
- const {
15
- InteractiveDocumentation,
16
- } = require('../../docs/interactive-documentation.js');
17
- // eslint-disable-line global-require
18
- const { logger } = require('../../utils/logger.js');
19
- // eslint-disable-line global-require
20
-
21
- /**
22
- * Create documentation automation commands
23
- */
24
- function createDocsCommands() {
25
- const docs = new Command('docs');
26
- docs.description('Documentation automation and generation commands');
27
-
28
- // Generate API documentation
29
- docs
30
- .command('generate')
31
- .description('Generate comprehensive API documentation')
32
- .option('-s, --source <dir>', 'Source directory to scan', 'src')
33
- .option(
34
- '-o, --output <dir>',
35
- 'Output directory for documentation',
36
- 'docs/api',
37
- )
38
- .option(
39
- '-c, --_config <file>',
40
- 'JSDoc configuration file',
41
- 'jsdoc._config.json',
42
- )
43
- .option('--no-interactive', 'Skip interactive documentation generation')
44
- .option('--no-examples', 'Skip example synchronization')
45
- .option('--include-private', 'Include private APIs in documentation')
46
- .action(async (_options) => {
47
- try {
48
- logger.info('Starting API documentation generation...');
49
-
50
- const automation = new JSDocAutomation({
51
- sourceDir: _options.source,
52
- outputDir: _options.output,
53
- configFile: _options._config,
54
- generateInteractive: _options.interactive,
55
- syncExamples: _options.examples,
56
- includePrivate: _options.includePrivate,
57
- });
58
-
59
- const result = await automation.generateAPIDocumentation();
60
-
61
- logger.info('API documentation generation completed successfully');
62
- // eslint-disable-next-line no-console
63
- console.log('\n๐Ÿ“š Documentation Generation Results:');
64
- // eslint-disable-line no-console
65
- // eslint-disable-next-line no-console
66
- console.log(`โœ… Output Directory: ${result.outputDir}`);
67
- // eslint-disable-line no-console
68
- // eslint-disable-next-line no-console
69
- console.log(`๐Ÿ“„ Generated Files: ${result.generatedFiles.length}`);
70
- // eslint-disable-line no-console
71
- // eslint-disable-next-line no-console
72
- console.log(`๐Ÿ—๏ธ API Structures: ${result.apiStructure.length}`);
73
- // eslint-disable-line no-console
74
- // eslint-disable-next-line no-console
75
- console.log(`๐Ÿ’ก Examples: ${result.examples.length}`);
76
- // eslint-disable-line no-console
77
-
78
- if (result.generatedFiles.length > 0) {
79
- // eslint-disable-next-line no-console
80
- console.log('\n๐Ÿ“ Generated Files:');
81
- // eslint-disable-line no-console
82
- result.generatedFiles.forEach((file) => {
83
- // eslint-disable-next-line no-console
84
- console.log(` ${file}`);
85
- // eslint-disable-line no-console
86
- });
87
- }
88
- } catch (error) {
89
- logger.error('API documentation generation failed:', error);
90
- process.exit(1);
91
- }
92
- });
93
-
94
- // Synchronize examples from tests
95
- docs
96
- .command('sync-examples')
97
- .description('Synchronize examples from passing tests')
98
- .option('-t, --test-dir <dir>', 'Test directory to scan', '__tests__')
99
- .option(
100
- '-o, --output <dir>',
101
- 'Output directory for examples',
102
- 'docs/examples',
103
- )
104
- .option('--no-passing-only', 'Include all tests, not just passing ones')
105
- .option('--no-runnable', 'Skip generating runnable example files')
106
- .option('--include-output', 'Include test output in examples')
107
- .action(async (_options) => {
108
- try {
109
- logger.info('Starting example synchronization...');
110
-
111
- const sync = new ExampleSynchronization({
112
- testDir: _options.testDir,
113
- outputDir: _options.output,
114
- syncOnlyPassing: _options.passingOnly,
115
- generateRunnable: _options.runnable,
116
- includeTestOutput: _options.includeOutput,
117
- });
118
-
119
- const result = await sync.synchronizeExamples();
120
-
121
- logger.info('Example synchronization completed successfully');
122
- // eslint-disable-next-line no-console
123
- console.log('\n๐Ÿ’ก Example Synchronization Results:');
124
- // eslint-disable-line no-console
125
- // eslint-disable-next-line no-console
126
- console.log(`โœ… Output Directory: ${result.outputDir}`);
127
- // eslint-disable-line no-console
128
- // eslint-disable-next-line no-console
129
- console.log(`๐Ÿ“ Synchronized Examples: ${result.syncedExamples}`);
130
- // eslint-disable-line no-console
131
- // eslint-disable-next-line no-console
132
- console.log(`๐Ÿงช Test Files Processed: ${result.processedTests}`);
133
- // eslint-disable-line no-console
134
-
135
- if (result.examples.length > 0) {
136
- // eslint-disable-next-line no-console
137
- console.log('\n๐Ÿ“Š Examples by Category:');
138
- // eslint-disable-line no-console
139
- result.examples.forEach(([category, examples]) => {
140
- // eslint-disable-next-line no-console
141
- console.log(` ${category}: ${examples.length} examples`);
142
- // eslint-disable-line no-console
143
- });
144
- }
145
- } catch (error) {
146
- logger.error('Example synchronization failed:', error);
147
- process.exit(1);
148
- }
149
- });
150
-
151
- // Start interactive documentation server
152
- docs
153
- .command('serve')
154
- .description('Start interactive documentation server')
155
- .option('-p, --port <number>', 'Server port', '3000')
156
- .option('-h, --host <host>', 'Server host', 'localhost')
157
- .option('-d, --docs-dir <dir>', 'Documentation directory', 'docs/api')
158
- .option('--no-live-reload', 'Disable live reload functionality')
159
- .option('--enable-code-execution', 'Enable code execution (security risk)')
160
- .action(async (_options) => {
161
- try {
162
- logger.info('Starting interactive documentation server...');
163
-
164
- const server = new InteractiveDocumentation({
165
- port: parseInt(_options.port),
166
- host: _options.host,
167
- docsDir: _options.docsDir,
168
- enableLiveReload: _options.liveReload,
169
- enableCodeExecution: _options.enableCodeExecution,
170
- });
171
-
172
- const result = await server.startServer();
173
-
174
- // eslint-disable-next-line no-console
175
- console.log('\n๐Ÿš€ Interactive Documentation Server Started!');
176
- // eslint-disable-line no-console
177
- // eslint-disable-next-line no-console
178
- console.log(`๐Ÿ“ URL: ${result.url}`);
179
- // eslint-disable-line no-console
180
- // eslint-disable-next-line no-console
181
- console.log(`๐Ÿ”ง Port: ${result.port}`);
182
- // eslint-disable-line no-console
183
- // eslint-disable-next-line no-console
184
- console.log(`๐Ÿ  Host: ${result.host}`);
185
- // eslint-disable-line no-console
186
- // eslint-disable-next-line no-console
187
- console.log(
188
- `๐Ÿ”„ Live Reload: ${_options.liveReload ? 'Enabled' : 'Disabled'}`,
189
- );
190
- // eslint-disable-line no-console
191
- // eslint-disable-next-line no-console
192
- console.log(
193
- `โšก Code Execution: ${_options.enableCodeExecution ? 'Enabled' : 'Disabled'}`,
194
- );
195
- // eslint-disable-line no-console
196
- // eslint-disable-next-line no-console
197
- console.log('\nPress Ctrl+C to stop the server');
198
- // eslint-disable-line no-console
199
-
200
- // Handle graceful shutdown
201
- process.on('SIGINT', async () => {
202
- // eslint-disable-next-line no-console
203
- console.log('\n๐Ÿ›‘ Shutting down server...');
204
- // eslint-disable-line no-console
205
- await server.stopServer();
206
- process.exit(0);
207
- });
208
-
209
- process.on('SIGTERM', async () => {
210
- // eslint-disable-next-line no-console
211
- console.log('\n๐Ÿ›‘ Shutting down server...');
212
- // eslint-disable-line no-console
213
- await server.stopServer();
214
- process.exit(0);
215
- });
216
- } catch (error) {
217
- logger.error(
218
- 'Failed to start interactive documentation server:',
219
- error,
220
- );
221
- process.exit(1);
222
- }
223
- });
224
-
225
- return docs;
226
- }
227
-
228
- module.exports = { createDocsCommands };