@zvec/zvec-grep 0.1.5 → 0.1.7
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/README.md +154 -236
- package/README_CN.md +142 -233
- package/dist/authorization/index.d.ts +7 -0
- package/dist/authorization/index.js +7 -0
- package/dist/authorization/index.js.map +1 -0
- package/dist/authorization/manager.d.ts +8 -0
- package/dist/authorization/manager.js +19 -0
- package/dist/authorization/manager.js.map +1 -0
- package/dist/authorization/operation.d.ts +7 -0
- package/dist/authorization/operation.js +50 -0
- package/dist/authorization/operation.js.map +1 -0
- package/dist/authorization/planner.d.ts +21 -0
- package/dist/authorization/planner.js +97 -0
- package/dist/authorization/planner.js.map +1 -0
- package/dist/authorization/prompt.d.ts +11 -0
- package/dist/authorization/prompt.js +62 -0
- package/dist/authorization/prompt.js.map +1 -0
- package/dist/authorization/store.d.ts +20 -0
- package/dist/authorization/store.js +251 -0
- package/dist/authorization/store.js.map +1 -0
- package/dist/authorization/target.d.ts +15 -0
- package/dist/authorization/target.js +49 -0
- package/dist/authorization/target.js.map +1 -0
- package/dist/authorization/types.d.ts +61 -0
- package/dist/authorization/types.js +2 -0
- package/dist/authorization/types.js.map +1 -0
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.js +338 -55
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth.d.ts +21 -0
- package/dist/cli/auth.js +209 -0
- package/dist/cli/auth.js.map +1 -0
- package/dist/cli/commands.js +469 -625
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/errors.js +2 -2
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/format/context.d.ts +4 -0
- package/dist/cli/format/context.js +311 -44
- package/dist/cli/format/context.js.map +1 -1
- package/dist/cli/format/debug.js +12 -6
- package/dist/cli/format/debug.js.map +1 -1
- package/dist/cli/format/progress.d.ts +4 -0
- package/dist/cli/format/progress.js +219 -46
- package/dist/cli/format/progress.js.map +1 -1
- package/dist/cli/format/status.d.ts +79 -6
- package/dist/cli/format/status.js +341 -111
- package/dist/cli/format/status.js.map +1 -1
- package/dist/cli/help.js +395 -63
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/install.d.ts +4 -0
- package/dist/cli/install.js +963 -0
- package/dist/cli/install.js.map +1 -0
- package/dist/cli/managed-rg.d.ts +10 -0
- package/dist/cli/managed-rg.js +329 -0
- package/dist/cli/managed-rg.js.map +1 -0
- package/dist/cli/server-search.d.ts +3 -0
- package/dist/cli/server-search.js +12 -0
- package/dist/cli/server-search.js.map +1 -0
- package/dist/cli/types.d.ts +23 -6
- package/dist/cli/types.js.map +1 -1
- package/dist/client/daemon-client.d.ts +31 -0
- package/dist/client/daemon-client.js +203 -0
- package/dist/client/daemon-client.js.map +1 -0
- package/dist/client/mode-router.d.ts +9 -0
- package/dist/client/mode-router.js +28 -0
- package/dist/client/mode-router.js.map +1 -0
- package/dist/client/search-policy.d.ts +11 -0
- package/dist/client/search-policy.js +15 -0
- package/dist/client/search-policy.js.map +1 -0
- package/dist/daemon/backend.d.ts +77 -0
- package/dist/daemon/backend.js +1087 -0
- package/dist/daemon/backend.js.map +1 -0
- package/dist/daemon/change-set.d.ts +25 -0
- package/dist/daemon/change-set.js +101 -0
- package/dist/daemon/change-set.js.map +1 -0
- package/dist/daemon/config.d.ts +24 -0
- package/dist/daemon/config.js +88 -0
- package/dist/daemon/config.js.map +1 -0
- package/dist/daemon/errors.d.ts +5 -0
- package/dist/daemon/errors.js +11 -0
- package/dist/daemon/errors.js.map +1 -0
- package/dist/daemon/http-server.d.ts +30 -0
- package/dist/daemon/http-server.js +288 -0
- package/dist/daemon/http-server.js.map +1 -0
- package/dist/daemon/index-coordinator.d.ts +24 -0
- package/dist/daemon/index-coordinator.js +68 -0
- package/dist/daemon/index-coordinator.js.map +1 -0
- package/dist/daemon/job-scheduler.d.ts +70 -0
- package/dist/daemon/job-scheduler.js +366 -0
- package/dist/daemon/job-scheduler.js.map +1 -0
- package/dist/daemon/logger.d.ts +9 -0
- package/dist/daemon/logger.js +53 -0
- package/dist/daemon/logger.js.map +1 -0
- package/dist/daemon/model-pool.d.ts +45 -0
- package/dist/daemon/model-pool.js +187 -0
- package/dist/daemon/model-pool.js.map +1 -0
- package/dist/daemon/root-lease.d.ts +14 -0
- package/dist/daemon/root-lease.js +188 -0
- package/dist/daemon/root-lease.js.map +1 -0
- package/dist/daemon/root-runtime.d.ts +78 -0
- package/dist/daemon/root-runtime.js +333 -0
- package/dist/daemon/root-runtime.js.map +1 -0
- package/dist/daemon/runtime-manager.d.ts +46 -0
- package/dist/daemon/runtime-manager.js +246 -0
- package/dist/daemon/runtime-manager.js.map +1 -0
- package/dist/daemon/runtime.d.ts +12 -0
- package/dist/daemon/runtime.js +102 -0
- package/dist/daemon/runtime.js.map +1 -0
- package/dist/daemon/server-controller.d.ts +39 -0
- package/dist/daemon/server-controller.js +254 -0
- package/dist/daemon/server-controller.js.map +1 -0
- package/dist/daemon/watch-manager.d.ts +50 -0
- package/dist/daemon/watch-manager.js +293 -0
- package/dist/daemon/watch-manager.js.map +1 -0
- package/dist/daemon/workspace-read-session-cache.d.ts +31 -0
- package/dist/daemon/workspace-read-session-cache.js +115 -0
- package/dist/daemon/workspace-read-session-cache.js.map +1 -0
- package/dist/engine/code-formats.d.ts +3 -0
- package/dist/engine/code-formats.js +14 -0
- package/dist/engine/code-formats.js.map +1 -0
- package/dist/engine/config.d.ts +30 -8
- package/dist/engine/config.js +171 -45
- package/dist/engine/config.js.map +1 -1
- package/dist/engine/{errors/index.d.ts → errors.d.ts} +6 -1
- package/dist/engine/{errors/details.js → errors.js} +17 -4
- package/dist/engine/errors.js.map +1 -0
- package/dist/engine/extraction/code/adapter.d.ts +1 -1
- package/dist/engine/extraction/code/adapter.js +1 -1
- package/dist/engine/extraction/code/adapter.js.map +1 -1
- package/dist/engine/extraction/code/extractor.d.ts +5 -11
- package/dist/engine/extraction/code/extractor.js +116 -48
- package/dist/engine/extraction/code/extractor.js.map +1 -1
- package/dist/engine/extraction/code/families/c-family.js +1 -1
- package/dist/engine/extraction/code/families/c-family.js.map +1 -1
- package/dist/engine/extraction/code/families/js-ts.d.ts +1 -1
- package/dist/engine/extraction/code/families/metadata.d.ts +1 -1
- package/dist/engine/extraction/code/tree-sitter/grammar.js.map +1 -0
- package/dist/engine/extraction/code/tree-sitter/nodes.js.map +1 -0
- package/dist/engine/extraction/code/tree-sitter/parser.js.map +1 -0
- package/dist/engine/extraction/image/extractor.d.ts +5 -0
- package/dist/engine/extraction/image/extractor.js +35 -0
- package/dist/engine/extraction/image/extractor.js.map +1 -0
- package/dist/engine/extraction/index.d.ts +4 -44
- package/dist/engine/extraction/index.js +2 -280
- package/dist/engine/extraction/index.js.map +1 -1
- package/dist/engine/extraction/markdown/extractor.d.ts +5 -11
- package/dist/engine/extraction/markdown/extractor.js +38 -17
- package/dist/engine/extraction/markdown/extractor.js.map +1 -1
- package/dist/engine/extraction/runtime.d.ts +4 -0
- package/dist/engine/extraction/runtime.js +26 -0
- package/dist/engine/extraction/runtime.js.map +1 -0
- package/dist/engine/extraction/source.d.ts +18 -0
- package/dist/engine/extraction/source.js +22 -0
- package/dist/engine/extraction/source.js.map +1 -0
- package/dist/engine/extraction/text/extractor.d.ts +7 -0
- package/dist/engine/extraction/text/extractor.js +168 -0
- package/dist/engine/extraction/text/extractor.js.map +1 -0
- package/dist/engine/extraction/types.d.ts +4 -0
- package/dist/engine/{models → extraction}/types.js.map +1 -1
- package/dist/engine/extraction/vector-content.d.ts +5 -0
- package/dist/engine/extraction/vector-content.js +95 -0
- package/dist/engine/extraction/vector-content.js.map +1 -0
- package/dist/engine/file-size-policy.d.ts +6 -0
- package/dist/engine/file-size-policy.js +20 -0
- package/dist/engine/file-size-policy.js.map +1 -0
- package/dist/engine/file-type.d.ts +15 -0
- package/dist/engine/file-type.js +152 -0
- package/dist/engine/file-type.js.map +1 -0
- package/dist/engine/index-status.d.ts +9 -0
- package/dist/engine/index-status.js +38 -0
- package/dist/engine/index-status.js.map +1 -0
- package/dist/engine/manifest.d.ts +13 -0
- package/dist/engine/manifest.js +124 -0
- package/dist/engine/manifest.js.map +1 -0
- package/dist/engine/models/{providers/llama-cpp/embedding.d.ts → backends/llama-cpp.d.ts} +25 -20
- package/dist/engine/models/{providers/llama-cpp/embedding.js → backends/llama-cpp.js} +127 -106
- package/dist/engine/models/backends/llama-cpp.js.map +1 -0
- package/dist/engine/models/backends/model2vec-runtime.d.ts +63 -0
- package/dist/engine/models/backends/model2vec-runtime.js +112 -0
- package/dist/engine/models/backends/model2vec-runtime.js.map +1 -0
- package/dist/engine/models/backends/model2vec-tokenizer.d.ts +2 -0
- package/dist/engine/models/backends/model2vec-tokenizer.js +42 -0
- package/dist/engine/models/backends/model2vec-tokenizer.js.map +1 -0
- package/dist/engine/models/backends/model2vec-worker-pool.d.ts +25 -0
- package/dist/engine/models/backends/model2vec-worker-pool.js +264 -0
- package/dist/engine/models/backends/model2vec-worker-pool.js.map +1 -0
- package/dist/engine/models/backends/model2vec-worker.d.ts +1 -0
- package/dist/engine/models/backends/model2vec-worker.js +41 -0
- package/dist/engine/models/backends/model2vec-worker.js.map +1 -0
- package/dist/engine/models/backends/model2vec.d.ts +40 -0
- package/dist/engine/models/backends/model2vec.js +311 -0
- package/dist/engine/models/backends/model2vec.js.map +1 -0
- package/dist/engine/models/backends/qwen.d.ts +44 -0
- package/dist/engine/models/{providers/qwen/embedding.js → backends/qwen.js} +155 -94
- package/dist/engine/models/backends/qwen.js.map +1 -0
- package/dist/engine/models/backends/transformers-js.d.ts +87 -0
- package/dist/engine/models/backends/transformers-js.js +316 -0
- package/dist/engine/models/backends/transformers-js.js.map +1 -0
- package/dist/engine/models/catalog.d.ts +207 -23
- package/dist/engine/models/catalog.js +191 -25
- package/dist/engine/models/catalog.js.map +1 -1
- package/dist/engine/models/download-progress.d.ts +15 -0
- package/dist/engine/models/download-progress.js +48 -0
- package/dist/engine/models/download-progress.js.map +1 -0
- package/dist/engine/models/embeddings.d.ts +59 -18
- package/dist/engine/models/embeddings.js +52 -28
- package/dist/engine/models/embeddings.js.map +1 -1
- package/dist/engine/models/factory.d.ts +2 -5
- package/dist/engine/models/factory.js +41 -56
- package/dist/engine/models/factory.js.map +1 -1
- package/dist/engine/models/index.d.ts +4 -6
- package/dist/engine/models/index.js +4 -4
- package/dist/engine/models/index.js.map +1 -1
- package/dist/engine/models/ranking.d.ts +7 -3
- package/dist/engine/models/resolution.d.ts +8 -0
- package/dist/engine/models/resolution.js +22 -0
- package/dist/engine/models/resolution.js.map +1 -0
- package/dist/engine/pipeline/indexing/index.d.ts +9 -7
- package/dist/engine/pipeline/indexing/index.js +409 -165
- package/dist/engine/pipeline/indexing/index.js.map +1 -1
- package/dist/engine/pipeline/indexing/input-budget.d.ts +2 -0
- package/dist/engine/pipeline/indexing/input-budget.js +51 -0
- package/dist/engine/pipeline/indexing/input-budget.js.map +1 -0
- package/dist/engine/pipeline/indexing/root-paths.js +6 -6
- package/dist/engine/pipeline/indexing/root-paths.js.map +1 -1
- package/dist/engine/pipeline/indexing/scanner/index.d.ts +9 -2
- package/dist/engine/pipeline/indexing/scanner/index.js +291 -35
- package/dist/engine/pipeline/indexing/scanner/index.js.map +1 -1
- package/dist/engine/pipeline/search/index.d.ts +6 -6
- package/dist/engine/pipeline/search/index.js +8 -10
- package/dist/engine/pipeline/search/index.js.map +1 -1
- package/dist/engine/service/index.d.ts +3 -2
- package/dist/engine/service/index.js +1 -1
- package/dist/engine/service/index.js.map +1 -1
- package/dist/engine/service/root.d.ts +10 -12
- package/dist/engine/service/root.js +29 -25
- package/dist/engine/service/root.js.map +1 -1
- package/dist/engine/service/structure-enrichment.d.ts +1 -1
- package/dist/engine/service/structure-enrichment.js +20 -22
- package/dist/engine/service/structure-enrichment.js.map +1 -1
- package/dist/engine/service/types.d.ts +40 -38
- package/dist/engine/service/workspace-index.d.ts +26 -0
- package/dist/engine/service/workspace-index.js +157 -0
- package/dist/engine/service/workspace-index.js.map +1 -0
- package/dist/engine/service/zvec-grep.d.ts +12 -1
- package/dist/engine/service/zvec-grep.js +698 -489
- package/dist/engine/service/zvec-grep.js.map +1 -1
- package/dist/engine/storage/index.d.ts +30 -20
- package/dist/engine/storage/index.js +2 -1
- package/dist/engine/storage/index.js.map +1 -1
- package/dist/engine/storage/layout.d.ts +10 -0
- package/dist/engine/storage/layout.js +29 -0
- package/dist/engine/storage/layout.js.map +1 -0
- package/dist/engine/storage/zvec.d.ts +4 -67
- package/dist/engine/storage/zvec.js +115 -85
- package/dist/engine/storage/zvec.js.map +1 -1
- package/dist/engine/types.d.ts +29 -23
- package/dist/engine/types.js +1 -1
- package/dist/engine/types.js.map +1 -1
- package/dist/engine/utils/daemon-lease.d.ts +17 -0
- package/dist/engine/utils/daemon-lease.js +175 -0
- package/dist/engine/utils/daemon-lease.js.map +1 -0
- package/dist/engine/utils/file-selection.js +38 -1
- package/dist/engine/utils/file-selection.js.map +1 -1
- package/dist/engine/utils/lock.js +1 -1
- package/dist/engine/utils/lock.js.map +1 -1
- package/dist/index-progress.d.ts +10 -0
- package/dist/index-progress.js +159 -0
- package/dist/index-progress.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/http-transport.d.ts +27 -0
- package/dist/mcp/http-transport.js +182 -0
- package/dist/mcp/http-transport.js.map +1 -0
- package/dist/mcp/input-normalization.d.ts +38 -0
- package/dist/mcp/input-normalization.js +104 -0
- package/dist/mcp/input-normalization.js.map +1 -0
- package/dist/mcp/progress-heartbeat.d.ts +17 -0
- package/dist/mcp/progress-heartbeat.js +46 -0
- package/dist/mcp/progress-heartbeat.js.map +1 -0
- package/dist/mcp/request-metadata.d.ts +2 -0
- package/dist/mcp/request-metadata.js +11 -0
- package/dist/mcp/request-metadata.js.map +1 -0
- package/dist/mcp/request-state.d.ts +40 -0
- package/dist/mcp/request-state.js +210 -0
- package/dist/mcp/request-state.js.map +1 -0
- package/dist/mcp/result-format.d.ts +13 -0
- package/dist/mcp/result-format.js +75 -0
- package/dist/mcp/result-format.js.map +1 -0
- package/dist/mcp/schemas.d.ts +672 -0
- package/dist/mcp/schemas.js +506 -0
- package/dist/mcp/schemas.js.map +1 -0
- package/dist/mcp/stdio-bridge.d.ts +9 -0
- package/dist/mcp/stdio-bridge.js +131 -0
- package/dist/mcp/stdio-bridge.js.map +1 -0
- package/dist/mcp/tools.d.ts +153 -0
- package/dist/mcp/tools.js +482 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/toolset.d.ts +5 -0
- package/dist/mcp/toolset.js +12 -0
- package/dist/mcp/toolset.js.map +1 -0
- package/dist/observability/trace-context.d.ts +11 -0
- package/dist/observability/trace-context.js +138 -0
- package/dist/observability/trace-context.js.map +1 -0
- package/dist/prompts/zvec-grep-guidance.d.ts +2 -0
- package/dist/prompts/zvec-grep-guidance.js +9 -0
- package/dist/prompts/zvec-grep-guidance.js.map +1 -0
- package/docs/01-agents.md +132 -0
- package/docs/02-cli.md +239 -0
- package/docs/03-mcp.md +185 -0
- package/docs/04-pipeline.md +226 -0
- package/docs/05-architecture.md +86 -0
- package/docs/06-server.md +215 -0
- package/docs/07-embedding.md +182 -0
- package/docs/08-roadmap.md +85 -0
- package/docs/README.md +53 -0
- package/package.json +20 -11
- package/dist/cli/mcp.d.ts +0 -2
- package/dist/cli/mcp.js +0 -354
- package/dist/cli/mcp.js.map +0 -1
- package/dist/engine/collection/index.d.ts +0 -55
- package/dist/engine/collection/index.js +0 -710
- package/dist/engine/collection/index.js.map +0 -1
- package/dist/engine/errors/details.d.ts +0 -6
- package/dist/engine/errors/details.js.map +0 -1
- package/dist/engine/errors/index.js +0 -16
- package/dist/engine/errors/index.js.map +0 -1
- package/dist/engine/extraction/tree-sitter/grammar.js.map +0 -1
- package/dist/engine/extraction/tree-sitter/nodes.js.map +0 -1
- package/dist/engine/extraction/tree-sitter/parser.js.map +0 -1
- package/dist/engine/files/file-type.d.ts +0 -5
- package/dist/engine/files/file-type.js +0 -119
- package/dist/engine/files/file-type.js.map +0 -1
- package/dist/engine/models/providers/index.d.ts +0 -2
- package/dist/engine/models/providers/index.js +0 -3
- package/dist/engine/models/providers/index.js.map +0 -1
- package/dist/engine/models/providers/llama-cpp/embedding.js.map +0 -1
- package/dist/engine/models/providers/llama-cpp/index.d.ts +0 -1
- package/dist/engine/models/providers/llama-cpp/index.js +0 -2
- package/dist/engine/models/providers/llama-cpp/index.js.map +0 -1
- package/dist/engine/models/providers/qwen/embedding.d.ts +0 -42
- package/dist/engine/models/providers/qwen/embedding.js.map +0 -1
- package/dist/engine/models/providers/qwen/index.d.ts +0 -1
- package/dist/engine/models/providers/qwen/index.js +0 -2
- package/dist/engine/models/providers/qwen/index.js.map +0 -1
- package/dist/engine/models/types.d.ts +0 -30
- package/skills/zvec-grep/SKILL.md +0 -151
- package/skills/zvec-grep/agents/openai.yaml +0 -4
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/grammar.d.ts +0 -0
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/grammar.js +0 -0
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/nodes.d.ts +0 -0
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/nodes.js +0 -0
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/parser.d.ts +0 -0
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/parser.js +0 -0
- /package/dist/engine/{models → extraction}/types.js +0 -0
package/dist/cli/args.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VALID_SYMBOL_TYPES } from "./types.js";
|
|
2
|
+
import { parseMcpToolset } from "../mcp/toolset.js";
|
|
2
3
|
const RG_OPTIONS_WITH_VALUE = new Set([
|
|
3
4
|
"--dfa-size-limit",
|
|
4
5
|
"--encoding",
|
|
@@ -89,7 +90,32 @@ export function parseArgs(args) {
|
|
|
89
90
|
}
|
|
90
91
|
const options = {};
|
|
91
92
|
const positionals = [];
|
|
92
|
-
|
|
93
|
+
let startIndex = 1;
|
|
94
|
+
if (commandInput.command === "config") {
|
|
95
|
+
if (args[1] === "model" && args[2] === "set") {
|
|
96
|
+
options.configAction = "model-set";
|
|
97
|
+
startIndex = 3;
|
|
98
|
+
}
|
|
99
|
+
else if (args[1] === "provider" && args[2] === "set") {
|
|
100
|
+
options.configAction = "provider-set";
|
|
101
|
+
startIndex = 3;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else if (commandInput.command === "auth") {
|
|
105
|
+
if (args[1] === "grant" || args[1] === "status" || args[1] === "revoke") {
|
|
106
|
+
options.authAction = args[1];
|
|
107
|
+
startIndex = 2;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else if (commandInput.command === "server") {
|
|
111
|
+
if (args[1] === "on" ||
|
|
112
|
+
args[1] === "off" ||
|
|
113
|
+
args[1] === "status" ||
|
|
114
|
+
args[1] === "run") {
|
|
115
|
+
options.serverAction = args[1];
|
|
116
|
+
startIndex = 2;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
93
119
|
for (let index = startIndex; index < args.length; index++) {
|
|
94
120
|
const arg = args[index];
|
|
95
121
|
if (arg === "--") {
|
|
@@ -111,8 +137,35 @@ export function parseArgs(args) {
|
|
|
111
137
|
else if (arg === "--version") {
|
|
112
138
|
throw new Error(`${arg} must be used without a command`);
|
|
113
139
|
}
|
|
114
|
-
else if (arg
|
|
115
|
-
options.
|
|
140
|
+
else if (isLongOptionWithValue(arg, "--mode")) {
|
|
141
|
+
options.mode = parseClientMode(valueFromLongOption(arg));
|
|
142
|
+
}
|
|
143
|
+
else if (arg === "--mode") {
|
|
144
|
+
options.mode = parseClientMode(readOptionValue(args, ++index, arg));
|
|
145
|
+
}
|
|
146
|
+
else if (arg === "--force-direct") {
|
|
147
|
+
options.forceDirect = true;
|
|
148
|
+
}
|
|
149
|
+
else if (arg === "--stdio") {
|
|
150
|
+
options.serverStdio = true;
|
|
151
|
+
}
|
|
152
|
+
else if (isLongOptionWithValue(arg, "--mcp-toolset")) {
|
|
153
|
+
options.mcpToolset = parseMcpToolset(valueFromLongOption(arg));
|
|
154
|
+
}
|
|
155
|
+
else if (arg === "--mcp-toolset") {
|
|
156
|
+
options.mcpToolset = parseMcpToolset(readOptionValue(args, ++index, arg));
|
|
157
|
+
}
|
|
158
|
+
else if (isLongOptionWithValue(arg, "--listen")) {
|
|
159
|
+
options.listen = valueFromLongOption(arg);
|
|
160
|
+
}
|
|
161
|
+
else if (arg === "--listen") {
|
|
162
|
+
options.listen = readOptionValue(args, ++index, arg);
|
|
163
|
+
}
|
|
164
|
+
else if (isLongOptionWithValue(arg, "--token-file")) {
|
|
165
|
+
options.serverTokenFile = valueFromLongOption(arg);
|
|
166
|
+
}
|
|
167
|
+
else if (arg === "--token-file") {
|
|
168
|
+
options.serverTokenFile = readOptionValue(args, ++index, arg);
|
|
116
169
|
}
|
|
117
170
|
else if (isLongOptionWithValue(arg, "--target")) {
|
|
118
171
|
options.installTargets = appendInstallTargets(options.installTargets, valueFromLongOption(arg));
|
|
@@ -126,9 +179,43 @@ export function parseArgs(args) {
|
|
|
126
179
|
else if (arg === "--mcp-tool-timeout") {
|
|
127
180
|
options.installMcpToolTimeoutSeconds = parsePositiveInteger(readOptionValue(args, ++index, arg), arg);
|
|
128
181
|
}
|
|
182
|
+
else if (isLongOptionWithValue(arg, "--mcp-token-env")) {
|
|
183
|
+
options.installMcpTokenEnv = parseEnvironmentVariable(valueFromLongOption(arg), "--mcp-token-env");
|
|
184
|
+
}
|
|
185
|
+
else if (arg === "--mcp-token-env") {
|
|
186
|
+
options.installMcpTokenEnv = parseEnvironmentVariable(readOptionValue(args, ++index, arg), arg);
|
|
187
|
+
}
|
|
188
|
+
else if (isLongOptionWithValue(arg, "--mcp-transport")) {
|
|
189
|
+
options.installMcpTransport = parseMcpInstallTransport(valueFromLongOption(arg));
|
|
190
|
+
}
|
|
191
|
+
else if (arg === "--mcp-transport") {
|
|
192
|
+
options.installMcpTransport = parseMcpInstallTransport(readOptionValue(args, ++index, arg));
|
|
193
|
+
}
|
|
129
194
|
else if (arg === "--yes") {
|
|
130
195
|
options.yes = true;
|
|
131
196
|
}
|
|
197
|
+
else if (isLongOptionWithValue(arg, "--allow-remote")) {
|
|
198
|
+
throw allowRemoteValueError();
|
|
199
|
+
}
|
|
200
|
+
else if (arg === "--allow-remote") {
|
|
201
|
+
const legacyScope = args[index + 1];
|
|
202
|
+
if (legacyScope === "once" || legacyScope === "workspace") {
|
|
203
|
+
throw allowRemoteValueError();
|
|
204
|
+
}
|
|
205
|
+
options.allowRemote = true;
|
|
206
|
+
}
|
|
207
|
+
else if (isLongOptionWithValue(arg, "--capability")) {
|
|
208
|
+
options.authorizationCapability = parseAuthorizationCapability(valueFromLongOption(arg));
|
|
209
|
+
}
|
|
210
|
+
else if (arg === "--capability") {
|
|
211
|
+
options.authorizationCapability = parseAuthorizationCapability(readOptionValue(args, ++index, arg));
|
|
212
|
+
}
|
|
213
|
+
else if (isLongOptionWithValue(arg, "--scope")) {
|
|
214
|
+
options.authorizationScope = parseAuthorizationScope(valueFromLongOption(arg));
|
|
215
|
+
}
|
|
216
|
+
else if (arg === "--scope") {
|
|
217
|
+
options.authorizationScope = parseAuthorizationScope(readOptionValue(args, ++index, arg));
|
|
218
|
+
}
|
|
132
219
|
else if (arg === "--rg") {
|
|
133
220
|
options.rg = true;
|
|
134
221
|
}
|
|
@@ -141,6 +228,9 @@ export function parseArgs(args) {
|
|
|
141
228
|
else if (arg === "--human") {
|
|
142
229
|
options.human = true;
|
|
143
230
|
}
|
|
231
|
+
else if (arg === "--check-ready") {
|
|
232
|
+
options.checkReady = true;
|
|
233
|
+
}
|
|
144
234
|
else if (isLongOptionWithValue(arg, "--preview")) {
|
|
145
235
|
options.preview = parsePreviewMode(valueFromLongOption(arg));
|
|
146
236
|
}
|
|
@@ -165,15 +255,18 @@ export function parseArgs(args) {
|
|
|
165
255
|
else if (arg === "--reset-paths") {
|
|
166
256
|
options.resetPaths = true;
|
|
167
257
|
}
|
|
168
|
-
else if (arg === "--
|
|
169
|
-
options.
|
|
258
|
+
else if (arg === "--default") {
|
|
259
|
+
options.defaultModel = true;
|
|
260
|
+
}
|
|
261
|
+
else if (isLongOptionWithValue(arg, "--refresh")) {
|
|
262
|
+
options.refresh = parseQueryRefreshMode(valueFromLongOption(arg));
|
|
263
|
+
}
|
|
264
|
+
else if (arg === "--refresh") {
|
|
265
|
+
options.refresh = parseQueryRefreshMode(readOptionValue(args, ++index, arg));
|
|
170
266
|
}
|
|
171
267
|
else if (arg === "--prefer-symbol") {
|
|
172
268
|
options.preferSymbol = true;
|
|
173
269
|
}
|
|
174
|
-
else if (arg === "--collection") {
|
|
175
|
-
options.collection = readOptionValue(args, ++index, arg);
|
|
176
|
-
}
|
|
177
270
|
else if (arg === "--home") {
|
|
178
271
|
options.home = readOptionValue(args, ++index, arg);
|
|
179
272
|
}
|
|
@@ -183,17 +276,8 @@ export function parseArgs(args) {
|
|
|
183
276
|
else if (arg === "--model-cache") {
|
|
184
277
|
options.modelCacheDir = readOptionValue(args, ++index, arg);
|
|
185
278
|
}
|
|
186
|
-
else if (arg === "--
|
|
187
|
-
options.
|
|
188
|
-
}
|
|
189
|
-
else if (arg === "--no-gpu") {
|
|
190
|
-
options.llamaGpu = false;
|
|
191
|
-
}
|
|
192
|
-
else if (arg === "--llama-gpu") {
|
|
193
|
-
options.llamaGpu = parseLlamaGpu(readOptionValue(args, ++index, arg));
|
|
194
|
-
}
|
|
195
|
-
else if (arg === "--embedding-parallelism") {
|
|
196
|
-
options.embeddingParallelism = parsePositiveInteger(readOptionValue(args, ++index, arg), arg);
|
|
279
|
+
else if (arg === "--device") {
|
|
280
|
+
options.device = parseDevice(readOptionValue(args, ++index, arg));
|
|
197
281
|
}
|
|
198
282
|
else if (arg === "--api-key") {
|
|
199
283
|
options.apiKey = readOptionValue(args, ++index, arg);
|
|
@@ -393,7 +477,7 @@ function parseCommand(args) {
|
|
|
393
477
|
throw new Error(`${first} does not accept arguments`);
|
|
394
478
|
}
|
|
395
479
|
if (first === "help" && rest.length > 1) {
|
|
396
|
-
throw new Error("zg help accepts at most one command
|
|
480
|
+
throw new Error("zg help accepts at most one command or topic");
|
|
397
481
|
}
|
|
398
482
|
return {
|
|
399
483
|
command: "help",
|
|
@@ -412,46 +496,66 @@ function parseCommand(args) {
|
|
|
412
496
|
if (first === "query" ||
|
|
413
497
|
first === "index" ||
|
|
414
498
|
first === "status" ||
|
|
415
|
-
first === "collections" ||
|
|
416
499
|
first === "install" ||
|
|
417
500
|
first === "uninstall" ||
|
|
418
|
-
first === "
|
|
501
|
+
first === "config" ||
|
|
502
|
+
first === "auth" ||
|
|
503
|
+
first === "server") {
|
|
419
504
|
return { command: first };
|
|
420
505
|
}
|
|
506
|
+
if (first === "serve") {
|
|
507
|
+
throw new Error("zg serve has been removed; use zg server on and Streamable HTTP MCP");
|
|
508
|
+
}
|
|
421
509
|
throw new Error(`Unknown command: ${first}`);
|
|
422
510
|
}
|
|
423
511
|
function validateCliShape(command, options, positionals) {
|
|
512
|
+
if (command === "auth") {
|
|
513
|
+
if (!options.authAction) {
|
|
514
|
+
throw new Error("zg auth requires grant, status, or revoke");
|
|
515
|
+
}
|
|
516
|
+
if (positionals.length > 1) {
|
|
517
|
+
throw new Error(`zg auth ${options.authAction} accepts at most one root`);
|
|
518
|
+
}
|
|
519
|
+
if (options.authAction !== "grant" &&
|
|
520
|
+
(options.authorizationCapability || options.authorizationScope)) {
|
|
521
|
+
throw new Error(`--capability and --scope can only be used with zg auth grant`);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
else if (options.authorizationCapability || options.authorizationScope) {
|
|
525
|
+
throw new Error("--capability and --scope can only be used with zg auth");
|
|
526
|
+
}
|
|
527
|
+
if (options.allowRemote && command !== "query" && command !== "index") {
|
|
528
|
+
throw new Error("--allow-remote can only be used with query or index commands");
|
|
529
|
+
}
|
|
424
530
|
const queryOnly = firstEnabledOption([
|
|
425
531
|
[options.rg, "--rg"],
|
|
426
532
|
[options.hybridQueries?.length, "--hybrid"],
|
|
427
533
|
[options.routes?.length, "--fts/--vector"],
|
|
428
534
|
[options.fuse, "--fuse"],
|
|
429
|
-
[options.debug, "--debug"],
|
|
430
535
|
[options.trace, "--trace"],
|
|
431
536
|
[options.human, "--human"],
|
|
432
537
|
[options.preview, "--preview"],
|
|
433
538
|
[options.limit, "--limit"],
|
|
434
|
-
[options.
|
|
539
|
+
[options.refresh, "--refresh"],
|
|
435
540
|
[options.preferSymbol, "--prefer-symbol"],
|
|
436
541
|
[options.symbolTypes?.length, "--symbol-type"],
|
|
437
542
|
[options.modifiedAfter, "--modified-after"],
|
|
438
543
|
[options.modifiedBefore, "--modified-before"],
|
|
439
|
-
[options.collection, "--collection"],
|
|
440
544
|
[options.rgCompatibilityOptions?.length, "ripgrep options"],
|
|
441
545
|
]);
|
|
442
546
|
if (command !== "query" && queryOnly) {
|
|
443
547
|
throw new Error(`${queryOnly} can only be used with zg query`);
|
|
444
548
|
}
|
|
549
|
+
if (options.debug && command !== "query" && command !== "index") {
|
|
550
|
+
throw new Error("--debug can only be used with zg query or zg index");
|
|
551
|
+
}
|
|
445
552
|
const sharedSelection = firstEnabledOption([
|
|
446
553
|
[options.globs?.length, "--glob"],
|
|
447
554
|
[options.insensitiveGlobs?.length, "--iglob"],
|
|
448
555
|
[options.fileTypes?.length, "--type"],
|
|
449
556
|
[options.excludedFileTypes?.length, "--type-not"],
|
|
450
557
|
]);
|
|
451
|
-
if (sharedSelection &&
|
|
452
|
-
command !== "query" &&
|
|
453
|
-
command !== "index" &&
|
|
454
|
-
command !== "collections") {
|
|
558
|
+
if (sharedSelection && command !== "query" && command !== "index") {
|
|
455
559
|
throw new Error(`${sharedSelection} can only be used with query or index commands`);
|
|
456
560
|
}
|
|
457
561
|
const discoveryOption = firstEnabledOption([
|
|
@@ -464,10 +568,80 @@ function validateCliShape(command, options, positionals) {
|
|
|
464
568
|
]);
|
|
465
569
|
if (discoveryOption &&
|
|
466
570
|
command !== "index" &&
|
|
467
|
-
command !== "collections" &&
|
|
468
571
|
!(command === "query" && options.rg)) {
|
|
469
572
|
throw new Error(`${discoveryOption} can only be used with index commands or zg query --rg`);
|
|
470
573
|
}
|
|
574
|
+
if (command === "config") {
|
|
575
|
+
if (!options.configAction) {
|
|
576
|
+
throw new Error("zg config requires provider set or model set");
|
|
577
|
+
}
|
|
578
|
+
const unsupported = firstEnabledOption([
|
|
579
|
+
[options.installTargets?.length, "--target"],
|
|
580
|
+
[options.installMcpToolTimeoutSeconds, "--mcp-tool-timeout"],
|
|
581
|
+
[options.installMcpTokenEnv, "--mcp-token-env"],
|
|
582
|
+
[options.yes, "--yes"],
|
|
583
|
+
[options.rg, "--rg"],
|
|
584
|
+
[options.home, "--home"],
|
|
585
|
+
[options.embedding, "--embedding"],
|
|
586
|
+
[
|
|
587
|
+
options.configAction === "model-set" ? options.apiKey : undefined,
|
|
588
|
+
"--api-key",
|
|
589
|
+
],
|
|
590
|
+
[
|
|
591
|
+
options.configAction === "provider-set" ? options.endpoint : undefined,
|
|
592
|
+
"--endpoint",
|
|
593
|
+
],
|
|
594
|
+
[
|
|
595
|
+
options.configAction === "provider-set" ? options.device : undefined,
|
|
596
|
+
"--device",
|
|
597
|
+
],
|
|
598
|
+
[
|
|
599
|
+
options.configAction === "provider-set"
|
|
600
|
+
? options.defaultModel
|
|
601
|
+
: undefined,
|
|
602
|
+
"--default",
|
|
603
|
+
],
|
|
604
|
+
[options.mode, "--mode"],
|
|
605
|
+
[options.listen, "--listen"],
|
|
606
|
+
[options.serverTokenFile, "--token-file"],
|
|
607
|
+
]);
|
|
608
|
+
if (unsupported) {
|
|
609
|
+
throw new Error(`zg config ${options.configAction === "model-set" ? "model" : "provider"} set does not accept ${unsupported}`);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
else if (options.defaultModel) {
|
|
613
|
+
throw new Error("--default can only be used with zg config model set");
|
|
614
|
+
}
|
|
615
|
+
if (command === "server") {
|
|
616
|
+
if (!options.serverAction && !options.serverStdio) {
|
|
617
|
+
throw new Error("zg server requires on, off, status, run, or --stdio");
|
|
618
|
+
}
|
|
619
|
+
if (options.serverAction && options.serverStdio) {
|
|
620
|
+
throw new Error("--stdio cannot be combined with a server action");
|
|
621
|
+
}
|
|
622
|
+
if (options.listen !== undefined &&
|
|
623
|
+
options.serverAction !== "run" &&
|
|
624
|
+
options.serverAction !== "on" &&
|
|
625
|
+
!options.serverStdio) {
|
|
626
|
+
throw new Error("--listen can only be used with zg server on or run");
|
|
627
|
+
}
|
|
628
|
+
if (options.serverTokenFile !== undefined &&
|
|
629
|
+
options.serverAction === "status") {
|
|
630
|
+
throw new Error("--token-file cannot be used with zg server status");
|
|
631
|
+
}
|
|
632
|
+
if (options.mcpToolset !== undefined &&
|
|
633
|
+
options.serverAction !== "on" &&
|
|
634
|
+
options.serverAction !== "run" &&
|
|
635
|
+
!options.serverStdio) {
|
|
636
|
+
throw new Error("--mcp-toolset can only be used with zg server on or run");
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
else if (options.mcpToolset !== undefined && command !== "install") {
|
|
640
|
+
throw new Error("--mcp-toolset can only be used with zg server on, run, --stdio, or zg install");
|
|
641
|
+
}
|
|
642
|
+
else if (options.serverStdio !== undefined) {
|
|
643
|
+
throw new Error("--stdio can only be used with zg server");
|
|
644
|
+
}
|
|
471
645
|
if (options.rg &&
|
|
472
646
|
(hasExplicitRoutes(options) || options.hybridQueries?.length)) {
|
|
473
647
|
throw new Error("--rg cannot be combined with --hybrid, --fts, or --vector");
|
|
@@ -475,8 +649,8 @@ function validateCliShape(command, options, positionals) {
|
|
|
475
649
|
if (options.rg && options.fuse) {
|
|
476
650
|
throw new Error("--rg cannot be combined with --fuse");
|
|
477
651
|
}
|
|
478
|
-
if (options.
|
|
479
|
-
throw new Error("--
|
|
652
|
+
if (options.forceDirect && options.mode !== "direct") {
|
|
653
|
+
throw new Error("--force-direct requires --mode direct");
|
|
480
654
|
}
|
|
481
655
|
if (options.rg && options.preview) {
|
|
482
656
|
throw new Error("--preview is not supported with --rg; use -A/-B/-C for rg context");
|
|
@@ -488,18 +662,29 @@ function validateCliShape(command, options, positionals) {
|
|
|
488
662
|
throw new Error("--rg cannot be combined with indexed symbol options");
|
|
489
663
|
}
|
|
490
664
|
if (options.rg &&
|
|
491
|
-
(options.
|
|
665
|
+
(options.refresh || options.embeddingConcurrency !== undefined)) {
|
|
492
666
|
throw new Error("--rg cannot be combined with indexed refresh options");
|
|
493
667
|
}
|
|
494
668
|
if (!options.rg && (options.rgCompatibilityOptions?.length ?? 0) > 0) {
|
|
495
669
|
const [option] = options.rgCompatibilityOptions;
|
|
496
670
|
throw new Error(`${option} can only be used with --rg`);
|
|
497
671
|
}
|
|
498
|
-
if (options.
|
|
499
|
-
|
|
672
|
+
if (options.mode !== undefined &&
|
|
673
|
+
command !== "query" &&
|
|
674
|
+
command !== "index" &&
|
|
675
|
+
command !== "status") {
|
|
676
|
+
throw new Error("--mode can only be used with query, index, or status");
|
|
677
|
+
}
|
|
678
|
+
if (options.checkReady &&
|
|
679
|
+
command !== "status" &&
|
|
680
|
+
!(command === "server" && options.serverAction === "status")) {
|
|
681
|
+
throw new Error("--check-ready can only be used with zg status or zg server status");
|
|
500
682
|
}
|
|
501
|
-
if (command
|
|
502
|
-
throw new Error("zg
|
|
683
|
+
if (options.listen !== undefined && command !== "server") {
|
|
684
|
+
throw new Error("--listen can only be used with zg server on or run");
|
|
685
|
+
}
|
|
686
|
+
if (options.serverTokenFile !== undefined && command !== "server") {
|
|
687
|
+
throw new Error("--token-file can only be used with zg server");
|
|
503
688
|
}
|
|
504
689
|
if (options.installTargets?.length &&
|
|
505
690
|
command !== "install" &&
|
|
@@ -510,18 +695,27 @@ function validateCliShape(command, options, positionals) {
|
|
|
510
695
|
command !== "install") {
|
|
511
696
|
throw new Error("--mcp-tool-timeout can only be used with zg install");
|
|
512
697
|
}
|
|
698
|
+
if (options.installMcpTokenEnv !== undefined && command !== "install") {
|
|
699
|
+
throw new Error("--mcp-token-env can only be used with zg install");
|
|
700
|
+
}
|
|
701
|
+
if (options.installMcpTransport !== undefined && command !== "install") {
|
|
702
|
+
throw new Error("--mcp-transport can only be used with zg install");
|
|
703
|
+
}
|
|
704
|
+
if (command === "install" &&
|
|
705
|
+
options.installMcpTransport !== "http" &&
|
|
706
|
+
options.installMcpTokenEnv !== undefined) {
|
|
707
|
+
throw new Error("--mcp-token-env requires --mcp-transport http");
|
|
708
|
+
}
|
|
513
709
|
if (options.force && command !== "install") {
|
|
514
710
|
throw new Error("--force can only be used with zg install");
|
|
515
711
|
}
|
|
516
712
|
if (command === "install" || command === "uninstall") {
|
|
517
713
|
const unsupported = firstEnabledOption([
|
|
518
|
-
[options.mcp, "--mcp"],
|
|
519
714
|
[options.color, "--color"],
|
|
520
715
|
[options.home, "--home"],
|
|
521
716
|
[options.embedding, "--embedding"],
|
|
522
717
|
[options.modelCacheDir, "--model-cache"],
|
|
523
|
-
[options.
|
|
524
|
-
[options.embeddingParallelism, "--embedding-parallelism"],
|
|
718
|
+
[options.device, "--device"],
|
|
525
719
|
[options.apiKey, "--api-key"],
|
|
526
720
|
[options.endpoint, "--endpoint"],
|
|
527
721
|
[options.rebuild, "--rebuild"],
|
|
@@ -552,11 +746,11 @@ function validateCliShape(command, options, positionals) {
|
|
|
552
746
|
if (options.drop && command !== "index") {
|
|
553
747
|
throw new Error("--drop can only be used with zg index");
|
|
554
748
|
}
|
|
555
|
-
if (options.rebuild && command !== "index"
|
|
556
|
-
throw new Error("--rebuild can only be used with zg index
|
|
749
|
+
if (options.rebuild && command !== "index") {
|
|
750
|
+
throw new Error("--rebuild can only be used with zg index");
|
|
557
751
|
}
|
|
558
|
-
if (options.resetPaths && command !== "index"
|
|
559
|
-
throw new Error("--reset-paths can only be used with zg index
|
|
752
|
+
if (options.resetPaths && command !== "index") {
|
|
753
|
+
throw new Error("--reset-paths can only be used with zg index");
|
|
560
754
|
}
|
|
561
755
|
if (options.drop &&
|
|
562
756
|
(options.rebuild ||
|
|
@@ -564,8 +758,7 @@ function validateCliShape(command, options, positionals) {
|
|
|
564
758
|
options.home ||
|
|
565
759
|
options.embedding ||
|
|
566
760
|
options.modelCacheDir ||
|
|
567
|
-
options.
|
|
568
|
-
options.embeddingParallelism ||
|
|
761
|
+
options.device !== undefined ||
|
|
569
762
|
options.apiKey ||
|
|
570
763
|
options.endpoint ||
|
|
571
764
|
options.globs?.length ||
|
|
@@ -577,10 +770,21 @@ function validateCliShape(command, options, positionals) {
|
|
|
577
770
|
options.ignoreFiles?.length ||
|
|
578
771
|
options.maxDepth !== undefined ||
|
|
579
772
|
options.maxFileSizeBytes !== undefined ||
|
|
773
|
+
options.debug ||
|
|
580
774
|
options.follow ||
|
|
581
775
|
options.embeddingConcurrency)) {
|
|
582
776
|
throw new Error("zg index --drop cannot be combined with indexing options");
|
|
583
777
|
}
|
|
778
|
+
if (command === "query") {
|
|
779
|
+
const unsupported = firstEnabledOption([
|
|
780
|
+
[options.embedding, "--embedding"],
|
|
781
|
+
[options.endpoint, "--endpoint"],
|
|
782
|
+
[options.embeddingConcurrency, "--embedding-concurrency"],
|
|
783
|
+
]);
|
|
784
|
+
if (unsupported) {
|
|
785
|
+
throw new Error(`${unsupported} is not supported with zg query`);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
584
788
|
if (command === "query" && !options.rg) {
|
|
585
789
|
const queryCount = positionals.length +
|
|
586
790
|
(options.hybridQueries?.length ?? 0) +
|
|
@@ -593,6 +797,35 @@ function validateCliShape(command, options, positionals) {
|
|
|
593
797
|
function firstEnabledOption(candidates) {
|
|
594
798
|
return candidates.find(([value]) => Array.isArray(value) ? value.length > 0 : value !== undefined)?.[1];
|
|
595
799
|
}
|
|
800
|
+
function parseClientMode(value) {
|
|
801
|
+
if (value === "direct" || value === "server" || value === "auto")
|
|
802
|
+
return value;
|
|
803
|
+
throw new Error("--mode must be direct, server, or auto");
|
|
804
|
+
}
|
|
805
|
+
function parseQueryRefreshMode(value) {
|
|
806
|
+
if (value === "background" || value === "wait" || value === "off") {
|
|
807
|
+
return value;
|
|
808
|
+
}
|
|
809
|
+
throw new Error("--refresh must be background, wait, or off");
|
|
810
|
+
}
|
|
811
|
+
function allowRemoteValueError() {
|
|
812
|
+
return new Error([
|
|
813
|
+
"--allow-remote does not accept a value.",
|
|
814
|
+
"It authorizes Remote Embedding for the current command only.",
|
|
815
|
+
"For persistent authorization, use:",
|
|
816
|
+
" zg auth grant --capability embedding --scope workspace",
|
|
817
|
+
].join("\n"));
|
|
818
|
+
}
|
|
819
|
+
function parseAuthorizationCapability(value) {
|
|
820
|
+
if (value === "embedding")
|
|
821
|
+
return value;
|
|
822
|
+
throw new Error("--capability currently supports only embedding");
|
|
823
|
+
}
|
|
824
|
+
function parseAuthorizationScope(value) {
|
|
825
|
+
if (value === "workspace")
|
|
826
|
+
return value;
|
|
827
|
+
throw new Error("zg auth supports only workspace scope");
|
|
828
|
+
}
|
|
596
829
|
function readOptionValue(args, index, option) {
|
|
597
830
|
const value = args[index];
|
|
598
831
|
if (value === undefined || value.length === 0) {
|
|
@@ -803,6 +1036,17 @@ function parsePositiveInteger(value, option) {
|
|
|
803
1036
|
}
|
|
804
1037
|
return parsed;
|
|
805
1038
|
}
|
|
1039
|
+
function parseEnvironmentVariable(value, option) {
|
|
1040
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value)) {
|
|
1041
|
+
throw new Error(`${option} requires a valid environment variable name`);
|
|
1042
|
+
}
|
|
1043
|
+
return value;
|
|
1044
|
+
}
|
|
1045
|
+
function parseMcpInstallTransport(value) {
|
|
1046
|
+
if (value === "stdio" || value === "http")
|
|
1047
|
+
return value;
|
|
1048
|
+
throw new Error("--mcp-transport must be stdio or http");
|
|
1049
|
+
}
|
|
806
1050
|
function parseByteSize(value, option) {
|
|
807
1051
|
const match = value.trim().match(/^(\d+)([KMGT])?$/i);
|
|
808
1052
|
if (!match) {
|
|
@@ -847,18 +1091,16 @@ function parsePreviewMode(value) {
|
|
|
847
1091
|
}
|
|
848
1092
|
throw new Error(`Unsupported preview mode: ${value}`);
|
|
849
1093
|
}
|
|
850
|
-
export function
|
|
1094
|
+
export function parseDevice(value) {
|
|
851
1095
|
const normalized = value.trim().toLowerCase();
|
|
852
1096
|
if (normalized === "auto" ||
|
|
1097
|
+
normalized === "cpu" ||
|
|
853
1098
|
normalized === "metal" ||
|
|
854
1099
|
normalized === "vulkan" ||
|
|
855
1100
|
normalized === "cuda") {
|
|
856
1101
|
return normalized;
|
|
857
1102
|
}
|
|
858
|
-
|
|
859
|
-
return false;
|
|
860
|
-
}
|
|
861
|
-
throw new Error(`Unsupported llama GPU mode: ${value}`);
|
|
1103
|
+
throw new Error(`Unsupported device: ${value}`);
|
|
862
1104
|
}
|
|
863
1105
|
function hasExplicitRoutes(options) {
|
|
864
1106
|
return (options.routes?.length ?? 0) > 0;
|
|
@@ -884,10 +1126,51 @@ function parseSymbolType(value) {
|
|
|
884
1126
|
throw new Error(`Unsupported symbol type: ${value}`);
|
|
885
1127
|
}
|
|
886
1128
|
export function splitPathFilters(value) {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
1129
|
+
const filters = [];
|
|
1130
|
+
let start = 0;
|
|
1131
|
+
let braceDepth = 0;
|
|
1132
|
+
let bracketDepth = 0;
|
|
1133
|
+
let escaped = false;
|
|
1134
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
1135
|
+
const character = value[index];
|
|
1136
|
+
if (escaped) {
|
|
1137
|
+
escaped = false;
|
|
1138
|
+
continue;
|
|
1139
|
+
}
|
|
1140
|
+
if (character === "\\") {
|
|
1141
|
+
escaped = true;
|
|
1142
|
+
continue;
|
|
1143
|
+
}
|
|
1144
|
+
if (character === "[") {
|
|
1145
|
+
bracketDepth += 1;
|
|
1146
|
+
continue;
|
|
1147
|
+
}
|
|
1148
|
+
if (character === "]" && bracketDepth > 0) {
|
|
1149
|
+
bracketDepth -= 1;
|
|
1150
|
+
continue;
|
|
1151
|
+
}
|
|
1152
|
+
if (bracketDepth === 0 && character === "{") {
|
|
1153
|
+
braceDepth += 1;
|
|
1154
|
+
continue;
|
|
1155
|
+
}
|
|
1156
|
+
if (bracketDepth === 0 && character === "}" && braceDepth > 0) {
|
|
1157
|
+
braceDepth -= 1;
|
|
1158
|
+
continue;
|
|
1159
|
+
}
|
|
1160
|
+
if (character !== "," || braceDepth > 0 || bracketDepth > 0) {
|
|
1161
|
+
continue;
|
|
1162
|
+
}
|
|
1163
|
+
const filter = value.slice(start, index).trim();
|
|
1164
|
+
if (filter.length > 0) {
|
|
1165
|
+
filters.push(filter);
|
|
1166
|
+
}
|
|
1167
|
+
start = index + 1;
|
|
1168
|
+
}
|
|
1169
|
+
const finalFilter = value.slice(start).trim();
|
|
1170
|
+
if (finalFilter.length > 0) {
|
|
1171
|
+
filters.push(finalFilter);
|
|
1172
|
+
}
|
|
1173
|
+
return filters;
|
|
891
1174
|
}
|
|
892
1175
|
function appendValue(existing, value, option) {
|
|
893
1176
|
const normalized = value.trim();
|