@devilsdev/rag-pipeline-utils 2.4.5 → 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.
- package/.ragrc.schema.json +83 -192
- package/CHANGELOG.md +345 -0
- package/README.md +418 -117
- package/SECURITY.md +5 -5
- package/dist/experimental.cjs +2 -0
- package/dist/experimental.d.ts +1 -0
- package/dist/experimental.mjs +5 -0
- package/dist/index.cjs +4992 -1242
- package/dist/index.d.ts +80 -2
- package/dist/index.mjs +1 -1
- package/dist/types/agentic/agentic-pipeline.d.ts +103 -0
- package/dist/types/agentic/iterative-retriever.d.ts +85 -0
- package/dist/types/agentic/query-planner.d.ts +145 -0
- package/dist/types/agentic/self-critique.d.ts +45 -0
- package/dist/types/ai/adaptive-retrieval.d.ts +44 -0
- package/dist/types/ai/federation/federated-learning-coordinator.d.ts +62 -0
- package/dist/types/ai/multimodal-processing.d.ts +32 -0
- package/dist/types/ai/multimodal.d.ts +39 -0
- package/dist/types/ai/retrieval-engine.d.ts +37 -0
- package/dist/types/ai/training/model-training-orchestrator.d.ts +31 -0
- package/dist/types/chunking/chunking-engine.d.ts +70 -0
- package/dist/types/chunking/strategies/fixed-size.d.ts +17 -0
- package/dist/types/chunking/strategies/recursive.d.ts +20 -0
- package/dist/types/chunking/strategies/semantic.d.ts +19 -0
- package/dist/types/chunking/strategies/sentence.d.ts +13 -0
- package/dist/types/chunking/strategies/structure-aware.d.ts +19 -0
- package/dist/types/citation/citation-tracker.d.ts +64 -0
- package/dist/types/citation/hallucination-detector.d.ts +40 -0
- package/dist/types/citation/source-mapper.d.ts +37 -0
- package/dist/types/connectors/anthropic-connector.d.ts +92 -0
- package/dist/types/connectors/base-connector.d.ts +87 -0
- package/dist/types/connectors/cohere-connector.d.ts +89 -0
- package/dist/types/connectors/connector-utils.d.ts +110 -0
- package/dist/types/connectors/local-embedder.d.ts +86 -0
- package/dist/types/connectors/memory-retriever.d.ts +91 -0
- package/dist/types/connectors/ollama-connector.d.ts +110 -0
- package/dist/types/connectors/openai-connector.d.ts +114 -0
- package/dist/types/connectors/rag-prompt.d.ts +40 -0
- package/dist/types/cost/cost-calculator.d.ts +152 -0
- package/dist/types/cost/cost-tracker.d.ts +126 -0
- package/dist/types/cost/token-budget.d.ts +110 -0
- package/dist/types/dag/core/error-context.d.ts +239 -0
- package/dist/types/dag/core/execution-scheduler.d.ts +191 -0
- package/dist/types/dag/core/topology-validation.d.ts +226 -0
- package/dist/types/dag/dag-engine.d.ts +156 -0
- package/dist/types/dag/dag-node.d.ts +37 -0
- package/dist/types/dashboard/dashboard-generator.d.ts +127 -0
- package/dist/types/dashboard/metrics-aggregator.d.ts +218 -0
- package/dist/types/debug/execution-tracer.d.ts +57 -0
- package/dist/types/debug/trace-inspector.d.ts +31 -0
- package/dist/types/ecosystem/plugin-certification.d.ts +169 -0
- package/dist/types/enterprise/data-governance.d.ts +203 -0
- package/dist/types/enterprise/multi-tenancy.d.ts +137 -0
- package/dist/types/enterprise/sso-integration.d.ts +420 -0
- package/dist/types/evaluate/context-metrics.d.ts +55 -0
- package/dist/types/evaluate/faithfulness.d.ts +41 -0
- package/dist/types/evaluate/groundedness.d.ts +60 -0
- package/dist/types/evaluate/pipeline-evaluator.d.ts +88 -0
- package/dist/types/evaluate/relevance.d.ts +21 -0
- package/dist/types/evaluate/scoring.d.ts +123 -0
- package/dist/types/experimental.d.ts +15 -0
- package/dist/types/graph/entity-extractor.d.ts +84 -0
- package/dist/types/graph/graph-index.d.ts +49 -0
- package/dist/types/graph/graph-retriever.d.ts +81 -0
- package/dist/types/graph/knowledge-graph.d.ts +129 -0
- package/dist/types/guardrails/guardrails-pipeline.d.ts +63 -0
- package/dist/types/guardrails/injection-detector.d.ts +47 -0
- package/dist/types/guardrails/post-generation-guard.d.ts +61 -0
- package/dist/types/guardrails/pre-retrieval-guard.d.ts +64 -0
- package/dist/types/guardrails/retrieval-guard.d.ts +57 -0
- package/dist/types/mcp/mcp-server.d.ts +85 -0
- package/dist/types/mcp/mcp-tool-builder.d.ts +55 -0
- package/dist/types/reranker/cascade-reranker.d.ts +40 -0
- package/dist/types/reranker/embedding-reranker.d.ts +77 -0
- package/dist/types/reranker/scoring-reranker.d.ts +41 -0
- package/dist/types/retrieval/bm25-search.d.ts +43 -0
- package/dist/types/retrieval/file-vector-store.d.ts +87 -0
- package/dist/types/retrieval/hybrid-retriever.d.ts +35 -0
- package/dist/types/retrieval/rank-fusion.d.ts +10 -0
- package/dist/types/security/jwt-config.d.ts +80 -0
- package/dist/types/security/jwt-validator.d.ts +195 -0
- package/dist/types/security/plugin-sandbox.d.ts +158 -0
- package/dist/types/security/plugin-signature-verifier.d.ts +139 -0
- package/dist/types/security/validator.d.ts +5 -0
- package/dist/types/streaming/embedding-stream.d.ts +65 -0
- package/dist/types/streaming/sse-adapter.d.ts +59 -0
- package/dist/types/streaming/stream-router.d.ts +88 -0
- package/dist/types/streaming/streaming-embedder.d.ts +99 -0
- package/dist/types/streaming/websocket-adapter.d.ts +71 -0
- package/dist/types/templates/scaffold.d.ts +55 -0
- package/dist/types/templates/template-registry.d.ts +63 -0
- package/dist/types/utils/embed-query.d.ts +20 -0
- package/dist/types/utils/logger.d.ts +50 -0
- package/dist/types/utils/rate-limiter.d.ts +66 -0
- package/dist/types/utils/retry.d.ts +27 -0
- package/dist/types/utils/run-abort.d.ts +34 -0
- package/dist/types/utils/secure-logging.d.ts +51 -0
- package/dist/types/utils/structured-logger.d.ts +126 -0
- package/package.json +53 -29
- package/src/agentic/agentic-pipeline.js +75 -7
- package/src/agentic/iterative-retriever.js +47 -10
- package/src/agentic/query-planner.js +329 -78
- package/src/citation/citation-tracker.js +6 -4
- package/src/citation/hallucination-detector.js +2 -2
- package/src/citation/source-mapper.js +15 -28
- package/src/cli/commands/ai.js +101 -0
- package/src/cli/commands/plugin-hub/event-handlers.js +6 -0
- package/src/cli/commands/plugin-hub/hub-commands.js +0 -74
- package/src/cli/commands/plugin-hub/local-commands.js +143 -0
- package/src/cli/commands/plugin-hub.js +96 -36
- package/src/cli/diagnostics/config-checker.js +76 -63
- package/src/cli/diagnostics/environment-checker.js +62 -31
- package/src/cli/diagnostics/plugin-checker.js +36 -89
- package/src/cli/doctor-command.js +39 -5
- package/src/cli/enhanced-cli-commands.js +72 -217
- package/src/cli/handlers/ai-handler.js +364 -0
- package/src/cli/handlers/diagnostics-handler.js +78 -31
- package/src/cli/handlers/ingest-handler.js +28 -22
- package/src/cli/handlers/init-handler.js +148 -25
- package/src/cli/handlers/query-handler.js +41 -26
- package/src/cli/handlers/run-handler.js +16 -167
- package/src/cli/handlers/serve-handler.js +60 -0
- package/src/cli/services/bench-stats.js +54 -0
- package/src/cli/services/benchmark.js +161 -0
- package/src/cli/services/feedback.js +155 -0
- package/src/cli/services/rag-service.js +322 -0
- package/src/cli/shared/cli-utils.js +24 -7
- package/src/cli/shared/config-context.js +21 -0
- package/src/cli/wizard/config-builder.js +81 -0
- package/src/cli/wizard/init-wizard.js +617 -0
- package/src/config/component-factory.js +125 -0
- package/src/config/load-config.js +29 -10
- package/src/config/load-plugin-config.js +46 -2
- package/src/connectors/anthropic-connector.js +93 -55
- package/src/connectors/base-connector.js +74 -19
- package/src/connectors/cohere-connector.js +88 -32
- package/src/connectors/connector-utils.js +302 -0
- package/src/connectors/local-embedder.js +43 -5
- package/src/connectors/memory-retriever.js +108 -15
- package/src/connectors/ollama-connector.js +83 -49
- package/src/connectors/openai-connector.js +108 -44
- package/src/connectors/rag-prompt.js +88 -0
- package/src/core/create-pipeline.js +209 -60
- package/src/core/plugin-registry.js +87 -11
- package/src/cost/cost-calculator.js +205 -32
- package/src/dev/dev-server.js +166 -11
- package/src/dev/hot-reload.js +40 -1
- package/src/ecosystem/plugin-checks.js +181 -0
- package/src/ecosystem/plugin-hub.js +50 -125
- package/src/ecosystem/plugin-installer.js +298 -0
- package/src/ecosystem/plugin-probe.js +127 -0
- package/src/ecosystem/plugin-scanner.js +185 -0
- package/src/ecosystem/tar-extract.js +114 -0
- package/src/enterprise/audit-logging.js +158 -29
- package/src/enterprise/sso-integration.js +715 -228
- package/src/evaluate/context-metrics.js +28 -16
- package/src/evaluate/evaluator.js +3 -3
- package/src/evaluate/faithfulness.js +18 -14
- package/src/evaluate/groundedness.js +43 -12
- package/src/evaluate/pipeline-evaluator.js +35 -8
- package/src/evaluate/scoring.js +251 -3
- package/src/experimental.js +71 -0
- package/src/guardrails/guardrails-pipeline.js +69 -7
- package/src/guardrails/injection-detector.js +283 -0
- package/src/guardrails/post-generation-guard.js +19 -0
- package/src/guardrails/pre-retrieval-guard.js +36 -36
- package/src/guardrails/retrieval-guard.js +58 -8
- package/src/index.js +36 -1
- package/src/loader/document-reader.js +91 -0
- package/src/reranker/cascade-reranker.js +3 -0
- package/src/reranker/embedding-reranker.js +136 -21
- package/src/reranker/llm-reranker.js +79 -12
- package/src/reranker/scoring-reranker.js +3 -0
- package/src/retrieval/bm25-search.js +12 -6
- package/src/retrieval/file-vector-store.js +212 -0
- package/src/retrieval/hybrid-retriever.js +22 -19
- package/src/security/jwt-config.js +13 -2
- package/src/security/jwt-validator.js +134 -30
- package/src/security/plugin-sandbox.js +18 -1
- package/src/security/plugin-signature-verifier.js +245 -70
- package/src/utils/deprecate.js +69 -0
- package/src/utils/embed-query.js +33 -0
- package/src/utils/input-sanitizer.js +19 -4
- package/src/utils/logger.js +34 -4
- package/src/utils/run-abort.js +102 -0
- package/src/ai/federated-learning.js +0 -211
- package/src/ai/federation.js +0 -71
- package/src/ai/index.js +0 -22
- package/src/ai/model-trainer.js +0 -217
- package/src/ai/model-training.js +0 -202
- package/src/ai/multimodal/multi-modal-processor.js +0 -345
- package/src/ai/orchestrator.js +0 -65
- package/src/ai/retrieval/adaptive-retrieval-engine.js +0 -398
- package/src/cli/commands/ai-ml/adaptive-commands.js +0 -178
- package/src/cli/commands/ai-ml/federated-commands.js +0 -207
- package/src/cli/commands/ai-ml/index.js +0 -17
- package/src/cli/commands/ai-ml/multimodal-commands.js +0 -187
- package/src/cli/commands/ai-ml/shared.js +0 -51
- package/src/cli/commands/ai-ml/training-commands.js +0 -228
- package/src/cli/commands/ai-ml.js +0 -386
- package/src/cli/commands/docs.js +0 -228
- package/src/cli/commands/dx.js +0 -538
- package/src/cli/commands/wizard.js +0 -627
- package/src/cli/input-sanitization-middleware.js +0 -356
- package/src/cli/interactive-wizard.js +0 -373
- package/src/cli/templates/development.template.json +0 -64
- package/src/cli/templates/minimal.template.json +0 -33
- package/src/cli/templates/production.template.json +0 -104
- package/src/cli/templates/testing.template.json +0 -45
- package/src/cli/wizard/configuration.js +0 -148
- package/src/cli/wizard/observability.js +0 -79
- package/src/cli/wizard/performance.js +0 -76
- package/src/cli/wizard/plugin-selection.js +0 -297
- package/src/cli/wizard/preview-save.js +0 -172
- package/src/cli/wizard/project-setup.js +0 -66
- package/src/core/pipeline-factory.js +0 -59
- package/src/dag/enhanced-dag-engine.js +0 -894
- package/src/dx/index.js +0 -40
- package/src/dx/integration-templates.js +0 -662
- package/src/dx/performance-profiler.js +0 -968
- package/src/dx/realtime-debugger.js +0 -755
- package/src/dx/visual-pipeline-builder.js +0 -578
- package/src/ingest.js +0 -59
- package/src/pipeline/pipeline.js +0 -18
- package/src/query.js +0 -117
|
@@ -6,13 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const { Command } = require("commander");
|
|
9
|
-
const fs = require("fs/promises");
|
|
10
9
|
|
|
11
10
|
const { logger } = require("../utils/logger.js");
|
|
12
11
|
|
|
13
12
|
// Shared utilities
|
|
14
13
|
const {
|
|
15
|
-
createProgressBar,
|
|
16
14
|
parsePositiveInteger,
|
|
17
15
|
generateCompletionScript,
|
|
18
16
|
getVersion,
|
|
@@ -21,7 +19,10 @@ const {
|
|
|
21
19
|
|
|
22
20
|
// Handler modules
|
|
23
21
|
const { handleRun } = require("./handlers/run-handler.js");
|
|
24
|
-
const {
|
|
22
|
+
const {
|
|
23
|
+
handleInit,
|
|
24
|
+
exitAfterConnectionTest,
|
|
25
|
+
} = require("./handlers/init-handler.js");
|
|
25
26
|
const {
|
|
26
27
|
handleDoctor,
|
|
27
28
|
handleValidate,
|
|
@@ -35,55 +36,13 @@ const {
|
|
|
35
36
|
const { handleIngest } = require("./handlers/ingest-handler.js");
|
|
36
37
|
const { handleQuery } = require("./handlers/query-handler.js");
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
cmd
|
|
43
|
-
.command("search")
|
|
44
|
-
.argument("[query]")
|
|
45
|
-
.action(() => {});
|
|
46
|
-
cmd
|
|
47
|
-
.command("install")
|
|
48
|
-
.argument("<name>")
|
|
49
|
-
.action(() => {});
|
|
50
|
-
cmd.command("publish").action(() => {});
|
|
51
|
-
return cmd;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const mockPipelineDoctor = async (options) => {
|
|
55
|
-
console.log("🏥 Running pipeline diagnostics");
|
|
56
|
-
if (options.categories) {
|
|
57
|
-
options.categories.forEach((cat) => {
|
|
58
|
-
console.log(`${cat.charAt(0).toUpperCase() + cat.slice(1)} Issues:`);
|
|
59
|
-
console.log(" ✅ No issues found");
|
|
60
|
-
});
|
|
61
|
-
} else {
|
|
62
|
-
console.log("✅ All systems operational");
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
summary: { total: 0, passed: 0, warnings: 0, errors: 0 },
|
|
66
|
-
categories: {},
|
|
67
|
-
issues: [],
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const mockValidateSchema = (config) => {
|
|
72
|
-
if (!config || typeof config !== "object") {
|
|
73
|
-
return {
|
|
74
|
-
valid: false,
|
|
75
|
-
errors: [{ message: "Invalid configuration format" }],
|
|
76
|
-
};
|
|
39
|
+
function parseNonNegativeInt(value) {
|
|
40
|
+
const n = Number(value);
|
|
41
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
42
|
+
throw new Error(`Expected a non-negative integer, got "${value}"`);
|
|
77
43
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
const isLegacy =
|
|
82
|
-
config.plugins &&
|
|
83
|
-
typeof config.plugins === "object" &&
|
|
84
|
-
Object.values(config.plugins).some((p) => typeof p === "string");
|
|
85
|
-
return { valid: true, legacy: isLegacy };
|
|
86
|
-
};
|
|
44
|
+
return n;
|
|
45
|
+
}
|
|
87
46
|
|
|
88
47
|
/**
|
|
89
48
|
* Enhanced CLI with improved UX and additional features
|
|
@@ -105,7 +64,6 @@ class EnhancedCLI {
|
|
|
105
64
|
.version(getVersion(), "-v, --version", "Display version information")
|
|
106
65
|
.option("--config <path>", "Configuration file path", ".ragrc.json")
|
|
107
66
|
.option("--verbose", "Enable verbose output")
|
|
108
|
-
.option("--quiet", "Suppress non-essential output")
|
|
109
67
|
.option("--no-color", "Disable colored output")
|
|
110
68
|
.option("--dry-run", "Show what would be done without executing")
|
|
111
69
|
.helpOption("-h, --help", "Display help information")
|
|
@@ -117,111 +75,98 @@ class EnhancedCLI {
|
|
|
117
75
|
* Setup all CLI commands
|
|
118
76
|
*/
|
|
119
77
|
setupCommands() {
|
|
120
|
-
// Interactive initialization command
|
|
121
78
|
this.program
|
|
122
79
|
.command("init")
|
|
123
|
-
.description("
|
|
124
|
-
.option("--interactive", "Use
|
|
125
|
-
.option(
|
|
126
|
-
|
|
80
|
+
.description("Create a .ragrc.json configuration")
|
|
81
|
+
.option("--no-interactive", "Use the template without prompting")
|
|
82
|
+
.option(
|
|
83
|
+
"--template <name>",
|
|
84
|
+
"Starting point: local, openai, ollama, anthropic",
|
|
85
|
+
"local",
|
|
86
|
+
)
|
|
127
87
|
.option("--output <path>", "Output configuration file", ".ragrc.json")
|
|
128
88
|
.option("--force", "Overwrite existing configuration")
|
|
129
89
|
.action(async (options) => {
|
|
130
|
-
await handleInit(this.program.opts(), options
|
|
131
|
-
|
|
132
|
-
)
|
|
90
|
+
const result = await handleInit(this.program.opts(), options);
|
|
91
|
+
// After a connection test, exit even if a provider call left a
|
|
92
|
+
// socket or timer open (see exitAfterConnectionTest).
|
|
93
|
+
exitAfterConnectionTest(result);
|
|
133
94
|
});
|
|
134
95
|
|
|
135
|
-
// Run pipeline command
|
|
136
96
|
this.program
|
|
137
97
|
.command("run")
|
|
138
|
-
.description("
|
|
139
|
-
.option("--ingest <
|
|
140
|
-
.option("--query <
|
|
141
|
-
.option("--
|
|
142
|
-
.option(
|
|
143
|
-
|
|
144
|
-
"Abort operation after timeout (milliseconds)",
|
|
145
|
-
parsePositiveInteger,
|
|
146
|
-
)
|
|
147
|
-
.option("--parallel", "Enable parallel processing")
|
|
98
|
+
.description("Ingest and/or query in one step")
|
|
99
|
+
.option("--ingest <path>", "File or directory to ingest first")
|
|
100
|
+
.option("--query <text>", "Question to ask after ingesting")
|
|
101
|
+
.option("--rebuild", "Discard the existing index before ingesting")
|
|
102
|
+
.option("--top-k <n>", "Passages to retrieve", parsePositiveInteger, 3)
|
|
103
|
+
.option("--json", "Print the query result as JSON")
|
|
148
104
|
.action(async (options) => {
|
|
149
105
|
await handleRun(this.program.opts(), options);
|
|
150
106
|
});
|
|
151
107
|
|
|
152
|
-
// Doctor command for diagnostics
|
|
153
108
|
this.program
|
|
154
109
|
.command("doctor")
|
|
155
|
-
.description("Diagnose
|
|
156
|
-
.option(
|
|
157
|
-
|
|
158
|
-
|
|
110
|
+
.description("Diagnose configuration, plugins and environment")
|
|
111
|
+
.option(
|
|
112
|
+
"--category <categories...>",
|
|
113
|
+
"Only run: configuration, plugins, dependencies, performance, security, environment",
|
|
114
|
+
)
|
|
115
|
+
.option(
|
|
116
|
+
"--auto-fix",
|
|
117
|
+
"Fix issues where possible (npm install, file permissions)",
|
|
118
|
+
)
|
|
119
|
+
.option("--report <path>", "Save the diagnostic report as JSON")
|
|
159
120
|
.action(async (options) => {
|
|
160
|
-
await handleDoctor(this.program.opts(), options
|
|
121
|
+
await handleDoctor(this.program.opts(), options);
|
|
161
122
|
});
|
|
162
123
|
|
|
163
|
-
// Enhanced ingest command
|
|
164
124
|
this.program
|
|
165
125
|
.command("ingest")
|
|
166
|
-
.description("
|
|
167
|
-
.argument("<
|
|
168
|
-
.option("--
|
|
169
|
-
.
|
|
170
|
-
|
|
171
|
-
.option("--streaming", "Enable streaming with memory safeguards")
|
|
172
|
-
.option("--trace", "Enable detailed tracing and event logging")
|
|
173
|
-
.option("--stats", "Show pipeline metrics summary at the end")
|
|
174
|
-
.option(
|
|
175
|
-
"--export-observability <file>",
|
|
176
|
-
"Export observability data to file",
|
|
177
|
-
)
|
|
178
|
-
.option(
|
|
179
|
-
"--max-concurrency <number>",
|
|
180
|
-
"Maximum concurrent operations",
|
|
181
|
-
"3",
|
|
182
|
-
)
|
|
183
|
-
.option(
|
|
184
|
-
"--batch-size <number>",
|
|
185
|
-
"Batch size for parallel processing",
|
|
186
|
-
"10",
|
|
187
|
-
)
|
|
188
|
-
.option("--max-memory <number>", "Maximum memory usage in MB", "512")
|
|
189
|
-
.action(async (file, options) => {
|
|
190
|
-
await handleIngest(this.program.opts(), file, options);
|
|
126
|
+
.description("Load, embed and index documents")
|
|
127
|
+
.argument("<path>", "File or directory (.md, .html, .csv, .txt)")
|
|
128
|
+
.option("--rebuild", "Discard the existing index before ingesting")
|
|
129
|
+
.action(async (inputPath, options) => {
|
|
130
|
+
await handleIngest(this.program.opts(), inputPath, options);
|
|
191
131
|
});
|
|
192
132
|
|
|
193
|
-
// Enhanced query command
|
|
194
133
|
this.program
|
|
195
134
|
.command("query")
|
|
196
|
-
.description("
|
|
197
|
-
.argument("<
|
|
198
|
-
.option("--
|
|
199
|
-
.option("--
|
|
200
|
-
.
|
|
201
|
-
|
|
202
|
-
.option("--stats", "Show pipeline metrics summary at the end")
|
|
203
|
-
.option(
|
|
204
|
-
"--export-observability <file>",
|
|
205
|
-
"Export observability data to file",
|
|
206
|
-
)
|
|
207
|
-
.action(async (prompt, options) => {
|
|
208
|
-
await handleQuery(this.program.opts(), prompt, options);
|
|
135
|
+
.description("Ask a question against the ingested documents")
|
|
136
|
+
.argument("<question>", "Question text")
|
|
137
|
+
.option("--top-k <n>", "Passages to retrieve", parsePositiveInteger, 3)
|
|
138
|
+
.option("--json", "Print the result as JSON")
|
|
139
|
+
.action(async (question, options) => {
|
|
140
|
+
await handleQuery(this.program.opts(), question, options);
|
|
209
141
|
});
|
|
210
142
|
|
|
211
|
-
// Configuration validation command
|
|
212
143
|
this.program
|
|
213
144
|
.command("validate")
|
|
214
|
-
.description("Validate configuration
|
|
215
|
-
.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
145
|
+
.description("Validate the configuration and resolve its components")
|
|
146
|
+
.action(async () => {
|
|
147
|
+
await handleValidate(this.program.opts());
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
this.program
|
|
151
|
+
.command("serve")
|
|
152
|
+
.description("Serve GET /health and POST /query over HTTP (local use)")
|
|
153
|
+
.option(
|
|
154
|
+
"--port <n>",
|
|
155
|
+
"Port (0 picks a free one)",
|
|
156
|
+
parseNonNegativeInt,
|
|
157
|
+
3000,
|
|
158
|
+
)
|
|
159
|
+
.option("--host <host>", "Interface to bind", "127.0.0.1")
|
|
219
160
|
.action(async (options) => {
|
|
220
|
-
|
|
161
|
+
const { handleServe } = require("./handlers/serve-handler.js");
|
|
162
|
+
await handleServe(this.program.opts(), options);
|
|
221
163
|
});
|
|
222
164
|
|
|
223
|
-
|
|
224
|
-
this.program.addCommand(
|
|
165
|
+
const { PluginHubCLI } = require("./commands/plugin-hub.js");
|
|
166
|
+
this.program.addCommand(new PluginHubCLI().createCommands());
|
|
167
|
+
|
|
168
|
+
const { createAiCommand } = require("./commands/ai.js");
|
|
169
|
+
this.program.addCommand(createAiCommand(() => this.program.opts()));
|
|
225
170
|
|
|
226
171
|
// Configuration management commands
|
|
227
172
|
const configCmd = new Command("config");
|
|
@@ -230,7 +175,6 @@ class EnhancedCLI {
|
|
|
230
175
|
configCmd
|
|
231
176
|
.command("show")
|
|
232
177
|
.description("Show current configuration")
|
|
233
|
-
.option("--format <format>", "Output format (json, yaml, table)", "json")
|
|
234
178
|
.option("--section <section>", "Show specific configuration section")
|
|
235
179
|
.action(async (options) => {
|
|
236
180
|
await handleConfigShow(this.program.opts(), options);
|
|
@@ -259,7 +203,7 @@ class EnhancedCLI {
|
|
|
259
203
|
this.program
|
|
260
204
|
.command("info")
|
|
261
205
|
.description("Show system and plugin information")
|
|
262
|
-
.option("--plugins", "Show
|
|
206
|
+
.option("--plugins", "Show built-in components and custom plugins")
|
|
263
207
|
.option("--system", "Show system information")
|
|
264
208
|
.option("--config", "Show configuration summary")
|
|
265
209
|
.action(async (options) => {
|
|
@@ -277,64 +221,6 @@ class EnhancedCLI {
|
|
|
277
221
|
});
|
|
278
222
|
}
|
|
279
223
|
|
|
280
|
-
/**
|
|
281
|
-
* Create basic configuration
|
|
282
|
-
*/
|
|
283
|
-
async createBasicConfig(outputPath) {
|
|
284
|
-
const { validateRagrc } = require("../config/enhanced-ragrc-schema.js");
|
|
285
|
-
|
|
286
|
-
const base = {
|
|
287
|
-
namespace: "default",
|
|
288
|
-
metadata: {
|
|
289
|
-
name: "rag-pipeline",
|
|
290
|
-
version: "1.0.0",
|
|
291
|
-
description: "RAG pipeline configuration",
|
|
292
|
-
createdAt: new Date().toISOString(),
|
|
293
|
-
},
|
|
294
|
-
pipeline: [
|
|
295
|
-
{ stage: "loader", name: "fs-loader", version: "1.0.0" },
|
|
296
|
-
{ stage: "embedder", name: "mock-embedder", version: "1.0.0" },
|
|
297
|
-
{ stage: "retriever", name: "mock-retriever", version: "1.0.0" },
|
|
298
|
-
{ stage: "llm", name: "mock-llm", version: "1.0.0" },
|
|
299
|
-
],
|
|
300
|
-
performance: {
|
|
301
|
-
parallel: {
|
|
302
|
-
enabled: false,
|
|
303
|
-
maxConcurrency: 3,
|
|
304
|
-
},
|
|
305
|
-
caching: {
|
|
306
|
-
enabled: false,
|
|
307
|
-
maxSize: 1000,
|
|
308
|
-
ttl: 3600,
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
observability: {
|
|
312
|
-
logging: {
|
|
313
|
-
level: "info",
|
|
314
|
-
structured: true,
|
|
315
|
-
},
|
|
316
|
-
},
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
const result = validateRagrc(base);
|
|
320
|
-
if (!result.valid) {
|
|
321
|
-
result.errors?.forEach((error) =>
|
|
322
|
-
console.error(` ${error.instancePath || ""}: ${error.message}`),
|
|
323
|
-
);
|
|
324
|
-
throw new Error("Failed to generate valid configuration");
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
if (outputPath) {
|
|
328
|
-
await fs.writeFile(
|
|
329
|
-
outputPath,
|
|
330
|
-
JSON.stringify(result.normalized, null, 2),
|
|
331
|
-
);
|
|
332
|
-
console.log(`✅ Basic configuration created: ${outputPath}`);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
return result.normalized;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
224
|
/**
|
|
339
225
|
* Run the CLI
|
|
340
226
|
*/
|
|
@@ -363,39 +249,8 @@ async function runEnhancedCLI(argv = process.argv) {
|
|
|
363
249
|
await enhancedCLI.run(argv);
|
|
364
250
|
}
|
|
365
251
|
|
|
366
|
-
// CLI command surface for tests
|
|
367
|
-
const init = async () => ({ ok: true });
|
|
368
|
-
const ingest = async () => ({ ok: true });
|
|
369
|
-
const query = async () => ({ ok: true });
|
|
370
|
-
const handleError = async () => ({ ok: true });
|
|
371
|
-
const validateArgs = () => true;
|
|
372
|
-
const showHelp = () => "help text";
|
|
373
|
-
|
|
374
|
-
// Extract createBasicConfig from the class for direct export
|
|
375
|
-
const createBasicConfig = async (outputPath) => {
|
|
376
|
-
const cli = new EnhancedCLI();
|
|
377
|
-
return await cli.createBasicConfig(outputPath);
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
const enhancedCliCommands = {
|
|
381
|
-
init,
|
|
382
|
-
ingest,
|
|
383
|
-
query,
|
|
384
|
-
handleError,
|
|
385
|
-
validateArgs,
|
|
386
|
-
showHelp,
|
|
387
|
-
};
|
|
388
|
-
|
|
389
252
|
module.exports = {
|
|
390
253
|
EnhancedCLI,
|
|
391
254
|
enhancedCLI,
|
|
392
255
|
runEnhancedCLI,
|
|
393
|
-
enhancedCliCommands,
|
|
394
|
-
init,
|
|
395
|
-
ingest,
|
|
396
|
-
query,
|
|
397
|
-
handleError,
|
|
398
|
-
validateArgs,
|
|
399
|
-
showHelp,
|
|
400
|
-
createBasicConfig,
|
|
401
256
|
};
|