opencode-rag-plugin 2.11.2 → 2.12.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 (36) hide show
  1. package/ReadMe.md +305 -207
  2. package/dist/cli/commands/backend-detect.d.ts +1 -1
  3. package/dist/cli/commands/backend-detect.js +1 -1
  4. package/dist/cli/commands/index.d.ts +0 -1
  5. package/dist/cli/commands/index.js +0 -1
  6. package/dist/cli/commands/setup.js +271 -85
  7. package/dist/cli/commands/{init-helpers.d.ts → workspace-helpers.d.ts} +10 -7
  8. package/dist/cli/commands/{init-helpers.js → workspace-helpers.js} +12 -62
  9. package/dist/cli/index.js +1 -2
  10. package/dist/cli/prompt.d.ts +84 -0
  11. package/dist/cli/prompt.js +247 -0
  12. package/dist/cli/types.d.ts +16 -17
  13. package/dist/cli/wizard/apply.d.ts +58 -0
  14. package/dist/cli/wizard/apply.js +234 -0
  15. package/dist/cli/wizard/flow.d.ts +83 -0
  16. package/dist/cli/wizard/flow.js +759 -0
  17. package/dist/cli/wizard/model-catalog.d.ts +80 -0
  18. package/dist/cli/wizard/model-catalog.js +414 -0
  19. package/dist/cli/wizard/types.d.ts +94 -0
  20. package/dist/cli/wizard/types.js +5 -0
  21. package/dist/cli/workspace.d.ts +40 -0
  22. package/dist/cli/workspace.js +322 -0
  23. package/dist/cli.d.ts +1 -1
  24. package/dist/cli.js +1 -1
  25. package/dist/core/config.d.ts +2 -2
  26. package/dist/core/config.js +2 -2
  27. package/dist/core/provider-defaults.d.ts +2 -0
  28. package/dist/core/provider-defaults.js +4 -0
  29. package/dist/eval/fast-index.js +1 -1
  30. package/dist/opencode/system-guidance.d.ts +1 -1
  31. package/dist/opencode/system-guidance.js +1 -1
  32. package/dist/tui.d.ts +11 -0
  33. package/dist/tui.js +12 -1
  34. package/package.json +1 -1
  35. package/dist/cli/commands/init.d.ts +0 -51
  36. package/dist/cli/commands/init.js +0 -508
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @fileoverview Model discovery for the `setup` wizard.
3
+ *
4
+ * The wizard offers model pickers instead of asking the user to type names
5
+ * from memory. Discovery is provider-specific:
6
+ *
7
+ * - Ollama: `GET /api/tags` for the list, `POST /api/show` for per-model
8
+ * capabilities (`embedding`, `vision`, `completion`).
9
+ * - OpenAI-compatible providers: `GET /v1/models` (ids only, so capability is
10
+ * inferred from the model name).
11
+ * - Cohere: `GET /v1/models` (endpoints include `embed` / `chat`).
12
+ * - Anthropic / Google: `GET /v1/models`, chat/vision only (no embedding API).
13
+ *
14
+ * Everything is best-effort: an unreachable host returns `reachable: false`
15
+ * and the wizard falls back to manual model entry. No call throws.
16
+ */
17
+ import type { ProxyConfig } from "../../core/config.js";
18
+ /** Capability buckets the wizard asks for. */
19
+ export type ModelCapability = "embedding" | "chat" | "vision";
20
+ /** A model discovered on the configured host. */
21
+ export interface ModelInfo {
22
+ /** Model identifier as the provider expects it (e.g. `qwen3-embedding:0.6b`). */
23
+ id: string;
24
+ /** Capabilities the provider reported, or inferred from the name when unknown. */
25
+ capabilities: ModelCapability[];
26
+ /** Optional provider detail such as parameter size or family. */
27
+ detail?: string;
28
+ }
29
+ /** Result of probing a model host. */
30
+ export interface ModelCatalog {
31
+ /** Provider id (`ollama`, `openai`, `cohere`, …). */
32
+ provider: string;
33
+ /** Base URL as it should be written into the config (Ollama keeps `/api`). */
34
+ baseUrl: string;
35
+ /** Whether the host answered the list request. */
36
+ reachable: boolean;
37
+ /** Human-readable failure reason when `reachable` is false. */
38
+ error?: string;
39
+ /** Discovered models (possibly empty). */
40
+ models: ModelInfo[];
41
+ }
42
+ /**
43
+ * Normalize an Ollama base URL to the API root (`http://host:port`).
44
+ *
45
+ * The config convention is `…/api` because the health checks append `/embed`
46
+ * and `/chat`; the discovery endpoints live at the root (`/api/tags`).
47
+ */
48
+ export declare function ollamaRoot(baseUrl: string): string;
49
+ /** Normalize an OpenAI-compatible base URL (`…/v1`). */
50
+ export declare function openAiBase(baseUrl: string): string;
51
+ /** Infer capabilities from a model id when the provider reports none. */
52
+ export declare function inferCapabilities(id: string): ModelCapability[];
53
+ /**
54
+ * Discover the models available on a host.
55
+ *
56
+ * Never throws: a failed probe returns `reachable: false` plus an error that
57
+ * the wizard prints before falling back to manual entry.
58
+ */
59
+ export declare function fetchModelCatalog(options: {
60
+ provider: string;
61
+ baseUrl: string;
62
+ apiKey?: string;
63
+ proxy?: ProxyConfig;
64
+ }): Promise<ModelCatalog>;
65
+ /**
66
+ * Probe an embedding model and return its vector dimension.
67
+ *
68
+ * This is what keeps `vectorDimension` honest: writing the wrong dimension
69
+ * makes LanceDB silently pad/truncate embeddings and the store unreachable.
70
+ * Returns `undefined` when the probe fails (the wizard then omits the value
71
+ * and the runtime probe decides).
72
+ */
73
+ export declare function probeEmbeddingDimension(options: {
74
+ provider: string;
75
+ baseUrl: string;
76
+ model: string;
77
+ apiKey?: string;
78
+ proxy?: ProxyConfig;
79
+ timeoutMs?: number;
80
+ }): Promise<number | undefined>;
@@ -0,0 +1,414 @@
1
+ /**
2
+ * @fileoverview Model discovery for the `setup` wizard.
3
+ *
4
+ * The wizard offers model pickers instead of asking the user to type names
5
+ * from memory. Discovery is provider-specific:
6
+ *
7
+ * - Ollama: `GET /api/tags` for the list, `POST /api/show` for per-model
8
+ * capabilities (`embedding`, `vision`, `completion`).
9
+ * - OpenAI-compatible providers: `GET /v1/models` (ids only, so capability is
10
+ * inferred from the model name).
11
+ * - Cohere: `GET /v1/models` (endpoints include `embed` / `chat`).
12
+ * - Anthropic / Google: `GET /v1/models`, chat/vision only (no embedding API).
13
+ *
14
+ * Everything is best-effort: an unreachable host returns `reachable: false`
15
+ * and the wizard falls back to manual model entry. No call throws.
16
+ */
17
+ import { fetchWithProxy, postJson } from "../../embedder/http.js";
18
+ /** Request timeout for discovery calls. Kept short so setup stays snappy. */
19
+ const LIST_TIMEOUT_MS = 6_000;
20
+ /** Total budget for the per-model Ollama capability probes. */
21
+ const CAPABILITY_BUDGET_MS = 5_000;
22
+ /** Parallel `/api/show` requests. */
23
+ const CAPABILITY_CONCURRENCY = 8;
24
+ /**
25
+ * Normalize an Ollama base URL to the API root (`http://host:port`).
26
+ *
27
+ * The config convention is `…/api` because the health checks append `/embed`
28
+ * and `/chat`; the discovery endpoints live at the root (`/api/tags`).
29
+ */
30
+ export function ollamaRoot(baseUrl) {
31
+ return baseUrl.replace(/\/+$/, "").replace(/\/(api|v1)$/i, "");
32
+ }
33
+ /** Normalize an OpenAI-compatible base URL (`…/v1`). */
34
+ export function openAiBase(baseUrl) {
35
+ return baseUrl.replace(/\/+$/, "");
36
+ }
37
+ /** Build the auth header for a provider, when it needs one. */
38
+ function authHeaders(provider, apiKey) {
39
+ if (!apiKey)
40
+ return {};
41
+ if (provider === "anthropic") {
42
+ return { "x-api-key": apiKey, "anthropic-version": "2023-06-01" };
43
+ }
44
+ return { Authorization: `Bearer ${apiKey}` };
45
+ }
46
+ /** Name heuristics used when the provider does not report capabilities. */
47
+ const EMBEDDING_NAME = /(embed|bge[-_]|e5[-_]|gte[-_]|jina|nomic|mxbai|text-embedding|voyage)/i;
48
+ const VISION_NAME = /(vision|llava|vl[-_]|minicpm[-_]v|pixtral|molmo|idefics|internvl|gpt-4o|gpt-4\.1|claude|gemini|gemma3)/i;
49
+ const NON_CHAT_NAME = /(whisper|tts|rerank|moderation|dall-e|stable-diffusion|flux|clip)/i;
50
+ /** Infer capabilities from a model id when the provider reports none. */
51
+ export function inferCapabilities(id) {
52
+ const capabilities = [];
53
+ if (EMBEDDING_NAME.test(id)) {
54
+ capabilities.push("embedding");
55
+ }
56
+ if (!EMBEDDING_NAME.test(id) && !NON_CHAT_NAME.test(id)) {
57
+ capabilities.push("chat");
58
+ }
59
+ if (VISION_NAME.test(id) && !EMBEDDING_NAME.test(id)) {
60
+ capabilities.push("vision");
61
+ }
62
+ return capabilities;
63
+ }
64
+ /** GET JSON with a bounded timeout and proxy support. Returns `undefined` on failure. */
65
+ async function getJson(url, headers, proxy) {
66
+ try {
67
+ const response = await fetchWithProxy(url, { method: "GET", headers, signal: AbortSignal.timeout(LIST_TIMEOUT_MS) }, proxy);
68
+ if (!response.ok)
69
+ return undefined;
70
+ return await response.json();
71
+ }
72
+ catch {
73
+ return undefined;
74
+ }
75
+ }
76
+ /** Extract a human-readable error from a failed list call (best-effort). */
77
+ async function describeListFailure(url, headers, proxy) {
78
+ try {
79
+ const response = await fetchWithProxy(url, { method: "GET", headers, signal: AbortSignal.timeout(LIST_TIMEOUT_MS) }, proxy);
80
+ if (response.ok)
81
+ return "The model list endpoint returned an unexpected response.";
82
+ if (response.status === 401 || response.status === 403) {
83
+ return `HTTP ${response.status}: authentication failed — check the API key.`;
84
+ }
85
+ return `HTTP ${response.status} from ${url}`;
86
+ }
87
+ catch (err) {
88
+ const message = err.message || String(err);
89
+ if (/ECONNREFUSED|fetch failed|connect/i.test(message)) {
90
+ return `Cannot reach ${url} — is the server running?`;
91
+ }
92
+ return message.slice(0, 200);
93
+ }
94
+ }
95
+ /** Read an array-valued property from an unknown JSON object. */
96
+ function asArray(value) {
97
+ return Array.isArray(value) ? value : [];
98
+ }
99
+ /** Read a string property from an unknown record. */
100
+ function asString(value) {
101
+ return typeof value === "string" && value.length > 0 ? value : undefined;
102
+ }
103
+ /** Read a record property from an unknown value. */
104
+ function asRecord(value) {
105
+ return value && typeof value === "object" && !Array.isArray(value)
106
+ ? value
107
+ : undefined;
108
+ }
109
+ /**
110
+ * Probe Ollama model capabilities with `POST /api/show`.
111
+ *
112
+ * Runs with bounded concurrency and a hard total budget so a slow remote host
113
+ * cannot stall setup. Models whose probe did not finish keep name-inferred
114
+ * capabilities.
115
+ */
116
+ async function probeOllamaCapabilities(root, models, apiKey, proxy) {
117
+ const deadline = Date.now() + CAPABILITY_BUDGET_MS;
118
+ const headers = authHeaders("ollama", apiKey);
119
+ let cursor = 0;
120
+ const worker = async () => {
121
+ for (;;) {
122
+ if (Date.now() > deadline)
123
+ return;
124
+ const index = cursor;
125
+ cursor += 1;
126
+ const model = models[index];
127
+ if (!model)
128
+ return;
129
+ try {
130
+ const response = await postJson(`${root}/api/show`, { model: model.id }, headers, Math.min(LIST_TIMEOUT_MS, Math.max(1_000, deadline - Date.now())), proxy);
131
+ if (!response.ok)
132
+ continue;
133
+ const body = asRecord(await response.json());
134
+ const reported = asArray(body?.capabilities).filter((value) => typeof value === "string");
135
+ if (reported.length > 0) {
136
+ const capabilities = [];
137
+ if (reported.includes("embedding"))
138
+ capabilities.push("embedding");
139
+ if (reported.includes("completion") || reported.includes("tools"))
140
+ capabilities.push("chat");
141
+ if (reported.includes("vision")) {
142
+ capabilities.push("vision");
143
+ if (!capabilities.includes("chat"))
144
+ capabilities.push("chat");
145
+ }
146
+ if (capabilities.length > 0)
147
+ model.capabilities = capabilities;
148
+ }
149
+ const details = asRecord(body?.details);
150
+ const family = asString(details?.family);
151
+ const parameterSize = asString(details?.parameter_size);
152
+ if (family && parameterSize)
153
+ model.detail = `${family} · ${parameterSize}`;
154
+ else if (family)
155
+ model.detail = family;
156
+ }
157
+ catch {
158
+ // Probe is optional — keep inferred capabilities.
159
+ }
160
+ }
161
+ };
162
+ await Promise.all(Array.from({ length: Math.min(CAPABILITY_CONCURRENCY, models.length) }, () => worker()));
163
+ }
164
+ /** Discover Ollama models. */
165
+ async function fetchOllamaCatalog(baseUrl, apiKey, proxy) {
166
+ const root = ollamaRoot(baseUrl);
167
+ const configBaseUrl = /\/api$/i.test(baseUrl.replace(/\/+$/, ""))
168
+ ? baseUrl.replace(/\/+$/, "")
169
+ : /\/v1$/i.test(baseUrl.replace(/\/+$/, ""))
170
+ ? `${root}/api`
171
+ : `${root}/api`;
172
+ const headers = authHeaders("ollama", apiKey);
173
+ const body = asRecord(await getJson(`${root}/api/tags`, headers, proxy));
174
+ if (!body) {
175
+ return {
176
+ provider: "ollama",
177
+ baseUrl: configBaseUrl,
178
+ reachable: false,
179
+ error: await describeListFailure(`${root}/api/tags`, headers, proxy),
180
+ models: [],
181
+ };
182
+ }
183
+ const models = [];
184
+ for (const entry of asArray(body.models)) {
185
+ const record = asRecord(entry);
186
+ const id = asString(record?.name) ?? asString(record?.model);
187
+ if (!id)
188
+ continue;
189
+ if (models.some((model) => model.id === id))
190
+ continue;
191
+ const details = asRecord(record?.details);
192
+ const family = asString(details?.family);
193
+ const parameterSize = asString(details?.parameter_size);
194
+ models.push({
195
+ id,
196
+ capabilities: inferCapabilities(id),
197
+ ...(family || parameterSize
198
+ ? { detail: [family, parameterSize].filter(Boolean).join(" · ") }
199
+ : {}),
200
+ });
201
+ }
202
+ await probeOllamaCapabilities(root, models, apiKey, proxy);
203
+ return { provider: "ollama", baseUrl: configBaseUrl, reachable: true, models };
204
+ }
205
+ /** Discover OpenAI-compatible models (`GET {baseUrl}/models`). */
206
+ async function fetchOpenAiCatalog(baseUrl, provider, apiKey, proxy) {
207
+ const base = openAiBase(baseUrl);
208
+ const url = `${base}/models`;
209
+ const headers = authHeaders(provider, apiKey);
210
+ const body = asRecord(await getJson(url, headers, proxy));
211
+ if (!body) {
212
+ return {
213
+ provider,
214
+ baseUrl: base,
215
+ reachable: false,
216
+ error: await describeListFailure(url, headers, proxy),
217
+ models: [],
218
+ };
219
+ }
220
+ const models = [];
221
+ for (const entry of asArray(body.data)) {
222
+ const record = asRecord(entry);
223
+ const id = asString(record?.id);
224
+ if (!id || models.some((model) => model.id === id))
225
+ continue;
226
+ models.push({ id, capabilities: inferCapabilities(id) });
227
+ }
228
+ models.sort((a, b) => a.id.localeCompare(b.id));
229
+ return { provider, baseUrl: base, reachable: true, models };
230
+ }
231
+ /** Discover Cohere models (`GET {baseUrl}/models`, endpoints carry capabilities). */
232
+ async function fetchCohereCatalog(baseUrl, apiKey, proxy) {
233
+ const base = openAiBase(baseUrl);
234
+ const url = `${base}/models`;
235
+ const headers = authHeaders("cohere", apiKey);
236
+ const body = asRecord(await getJson(url, headers, proxy));
237
+ if (!body) {
238
+ return {
239
+ provider: "cohere",
240
+ baseUrl: base,
241
+ reachable: false,
242
+ error: await describeListFailure(url, headers, proxy),
243
+ models: [],
244
+ };
245
+ }
246
+ const models = [];
247
+ for (const entry of asArray(body.models)) {
248
+ const record = asRecord(entry);
249
+ const id = asString(record?.name);
250
+ if (!id || models.some((model) => model.id === id))
251
+ continue;
252
+ const endpoints = asArray(record?.endpoints)
253
+ .filter((value) => typeof value === "string")
254
+ .map((value) => value.toLowerCase());
255
+ const capabilities = [];
256
+ if (endpoints.includes("embed") || inferCapabilities(id).includes("embedding")) {
257
+ capabilities.push("embedding");
258
+ }
259
+ if (endpoints.includes("chat") || endpoints.includes("generate")) {
260
+ capabilities.push("chat");
261
+ }
262
+ if (capabilities.length === 0)
263
+ capabilities.push(...inferCapabilities(id));
264
+ models.push({ id, capabilities });
265
+ }
266
+ models.sort((a, b) => a.id.localeCompare(b.id));
267
+ return { provider: "cohere", baseUrl: base, reachable: true, models };
268
+ }
269
+ /** Discover Anthropic models (`GET {baseUrl}/models`, chat + vision). */
270
+ async function fetchAnthropicCatalog(baseUrl, apiKey, proxy) {
271
+ const base = openAiBase(baseUrl);
272
+ const url = `${base}/models`;
273
+ const headers = authHeaders("anthropic", apiKey);
274
+ const body = asRecord(await getJson(url, headers, proxy));
275
+ if (!body) {
276
+ return {
277
+ provider: "anthropic",
278
+ baseUrl: base,
279
+ reachable: false,
280
+ error: await describeListFailure(url, headers, proxy),
281
+ models: [],
282
+ };
283
+ }
284
+ const models = [];
285
+ for (const entry of asArray(body.data)) {
286
+ const record = asRecord(entry);
287
+ const id = asString(record?.id);
288
+ if (!id || models.some((model) => model.id === id))
289
+ continue;
290
+ models.push({ id, capabilities: ["chat", "vision"] });
291
+ }
292
+ return { provider: "anthropic", baseUrl: base, reachable: true, models };
293
+ }
294
+ /** Discover Google models (`GET {baseUrl}/models?key=...`). */
295
+ async function fetchGoogleCatalog(baseUrl, apiKey, proxy) {
296
+ const base = openAiBase(baseUrl);
297
+ const url = apiKey ? `${base}/models?key=${encodeURIComponent(apiKey)}` : `${base}/models`;
298
+ const body = asRecord(await getJson(url, {}, proxy));
299
+ if (!body) {
300
+ return {
301
+ provider: "google",
302
+ baseUrl: base,
303
+ reachable: false,
304
+ error: await describeListFailure(url, {}, proxy),
305
+ models: [],
306
+ };
307
+ }
308
+ const models = [];
309
+ for (const entry of asArray(body.models)) {
310
+ const record = asRecord(entry);
311
+ const rawName = asString(record?.name);
312
+ if (!rawName)
313
+ continue;
314
+ const id = rawName.replace(/^models\//, "");
315
+ if (models.some((model) => model.id === id))
316
+ continue;
317
+ const methods = asArray(record?.supportedGenerationMethods)
318
+ .filter((value) => typeof value === "string")
319
+ .map((value) => value.toLowerCase());
320
+ const capabilities = [];
321
+ if (methods.includes("embedcontent"))
322
+ capabilities.push("embedding");
323
+ if (methods.includes("generatecontent")) {
324
+ capabilities.push("chat");
325
+ if (VISION_NAME.test(id))
326
+ capabilities.push("vision");
327
+ }
328
+ if (capabilities.length === 0)
329
+ capabilities.push(...inferCapabilities(id));
330
+ models.push({ id, capabilities });
331
+ }
332
+ return { provider: "google", baseUrl: base, reachable: true, models };
333
+ }
334
+ /**
335
+ * Discover the models available on a host.
336
+ *
337
+ * Never throws: a failed probe returns `reachable: false` plus an error that
338
+ * the wizard prints before falling back to manual entry.
339
+ */
340
+ export async function fetchModelCatalog(options) {
341
+ const { provider, baseUrl, apiKey, proxy } = options;
342
+ if (!baseUrl.trim()) {
343
+ return {
344
+ provider,
345
+ baseUrl,
346
+ reachable: false,
347
+ error: "No base URL configured.",
348
+ models: [],
349
+ };
350
+ }
351
+ if (provider === "ollama")
352
+ return fetchOllamaCatalog(baseUrl, apiKey, proxy);
353
+ if (provider === "cohere")
354
+ return fetchCohereCatalog(baseUrl, apiKey, proxy);
355
+ if (provider === "anthropic")
356
+ return fetchAnthropicCatalog(baseUrl, apiKey, proxy);
357
+ if (provider === "google")
358
+ return fetchGoogleCatalog(baseUrl, apiKey, proxy);
359
+ return fetchOpenAiCatalog(baseUrl, provider, apiKey, proxy);
360
+ }
361
+ /**
362
+ * Probe an embedding model and return its vector dimension.
363
+ *
364
+ * This is what keeps `vectorDimension` honest: writing the wrong dimension
365
+ * makes LanceDB silently pad/truncate embeddings and the store unreachable.
366
+ * Returns `undefined` when the probe fails (the wizard then omits the value
367
+ * and the runtime probe decides).
368
+ */
369
+ export async function probeEmbeddingDimension(options) {
370
+ const { provider, baseUrl, model, apiKey, proxy, timeoutMs = 15_000 } = options;
371
+ const headers = authHeaders(provider, apiKey);
372
+ const text = "dimension probe";
373
+ const readLength = (value) => {
374
+ const arrays = asArray(value);
375
+ const first = asArray(arrays[0]);
376
+ return first.length > 0 ? first.length : undefined;
377
+ };
378
+ try {
379
+ if (provider === "cohere") {
380
+ const response = await postJson(`${openAiBase(baseUrl)}/embed`, { model, texts: [text], input_type: "search_document" }, headers, timeoutMs, proxy);
381
+ if (!response.ok)
382
+ return undefined;
383
+ return readLength(asRecord(await response.json())?.embeddings);
384
+ }
385
+ if (provider === "ollama") {
386
+ const root = ollamaRoot(baseUrl);
387
+ const response = await postJson(`${root}/api/embed`, { model, input: [text] }, headers, timeoutMs, proxy);
388
+ if (response.ok) {
389
+ return readLength(asRecord(await response.json())?.embeddings);
390
+ }
391
+ // Some Ollama builds only expose the OpenAI-compatible endpoint.
392
+ const fallback = await postJson(`${root}/v1/embeddings`, { model, input: [text] }, headers, timeoutMs, proxy);
393
+ if (!fallback.ok)
394
+ return undefined;
395
+ const body = asRecord(await fallback.json());
396
+ const data = asRecord(asArray(body?.data)[0]);
397
+ const embedding = asArray(data?.embedding);
398
+ return embedding.length > 0 ? embedding.length : undefined;
399
+ }
400
+ if (provider === "anthropic" || provider === "google")
401
+ return undefined;
402
+ const response = await postJson(`${openAiBase(baseUrl)}/embeddings`, { model, input: [text] }, headers, timeoutMs, proxy);
403
+ if (!response.ok)
404
+ return undefined;
405
+ const body = asRecord(await response.json());
406
+ const data = asRecord(asArray(body?.data)[0]);
407
+ const embedding = asArray(data?.embedding);
408
+ return embedding.length > 0 ? embedding.length : undefined;
409
+ }
410
+ catch {
411
+ return undefined;
412
+ }
413
+ }
414
+ //# sourceMappingURL=model-catalog.js.map
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @fileoverview Answer and config-patch types shared by the `setup` wizard.
3
+ */
4
+ /** A provider endpoint selected for one capability group. */
5
+ export interface HostChoice {
6
+ /** Provider id: `ollama`, `openai`, `cohere`, `anthropic`, `google`. */
7
+ provider: string;
8
+ /** Base URL written into the config (Ollama keeps the `/api` suffix). */
9
+ baseUrl: string;
10
+ /** API key typed by the user. Omitted when it is resolved from the environment. */
11
+ apiKey?: string;
12
+ }
13
+ /** Embedding host plus the selected model. */
14
+ export interface EmbeddingChoice extends HostChoice {
15
+ /** Embedding model id. */
16
+ model: string;
17
+ /** Probed vector dimension, so the store schema stays stable. */
18
+ vectorDimension?: number;
19
+ }
20
+ /** Chat/vision host plus the selected model. */
21
+ export interface ChatChoice extends HostChoice {
22
+ /** Chat or vision model id. */
23
+ model: string;
24
+ }
25
+ /** Decision-model settings (Ollama only). */
26
+ export interface DecisionChoice {
27
+ /** Whether `make_decision` / shell guard are available. */
28
+ enabled: boolean;
29
+ /** Ollama root or `/api` URL. */
30
+ baseUrl?: string;
31
+ /** Decision model id (`tev1:0.8b`, `tev1:4b`). */
32
+ model?: string;
33
+ /** Route choices through `make_decision` before asking the user. */
34
+ routeBeforeAsking?: boolean;
35
+ }
36
+ /** Optional reranker settings. */
37
+ export interface RerankChoice {
38
+ /** Whether reranking is enabled. */
39
+ enabled: boolean;
40
+ /** Rerank endpoint base URL (llama-server `/v1`). */
41
+ baseUrl?: string;
42
+ /** Rerank model id. */
43
+ model?: string;
44
+ }
45
+ /** Central vector-store backend selected in the wizard. */
46
+ export interface VectorStoreChoice {
47
+ /** Backend id. */
48
+ provider: "lancedb" | "clickhouse";
49
+ /** ClickHouse connection settings (only when `provider` is `clickhouse`). */
50
+ clickhouse?: {
51
+ url?: string;
52
+ database?: string;
53
+ username?: string;
54
+ passwordEnv?: string;
55
+ namespace?: string;
56
+ };
57
+ }
58
+ /** Everything the wizard collected. */
59
+ export interface WizardAnswers {
60
+ /** Required: where embeddings come from. */
61
+ embedding: EmbeddingChoice;
62
+ /** Optional: LLM chunk descriptions. */
63
+ description?: ChatChoice;
64
+ /** Explicit on/off for chunk descriptions (the wizard always answers this). */
65
+ descriptionEnabled?: boolean;
66
+ /** Optional: vision-based image descriptions. */
67
+ imageDescription?: ChatChoice;
68
+ /** Explicit on/off for image descriptions. */
69
+ imageDescriptionEnabled?: boolean;
70
+ /** Optional: decision model (Ollama `/v1/systemone`). */
71
+ decision?: DecisionChoice;
72
+ /** Optional: reranker. */
73
+ reranking?: RerankChoice;
74
+ /** Optional: shell-command guard toggle. */
75
+ shellGuard?: {
76
+ enabled: boolean;
77
+ };
78
+ /** Optional: automatic quirk capture (memory) toggles. */
79
+ memory?: {
80
+ passiveCapture?: boolean;
81
+ promptEnforcement?: boolean;
82
+ sessionEndExtraction?: boolean;
83
+ };
84
+ /** Optional: vector-store backend. */
85
+ vectorStore?: VectorStoreChoice;
86
+ /** Optional: indexing tweaks. */
87
+ indexing?: {
88
+ embedDescriptions?: boolean;
89
+ };
90
+ /** Optional: background indexing. */
91
+ openCode?: {
92
+ autoIndex?: boolean;
93
+ };
94
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @fileoverview Answer and config-patch types shared by the `setup` wizard.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @fileoverview Workspace scaffolding shared by `opencode-rag setup`.
3
+ *
4
+ * Creates/updates the `.opencode/` tree, plugin entrypoints, skills,
5
+ * `AGENTS.md` guidance and the workspace `package.json`. Configuration is
6
+ * written separately (see `src/cli/wizard/apply.ts`) so the wizard can decide
7
+ * what goes into the workspace file before `AGENTS.md` is rendered from the
8
+ * effective `decision`/`memory` flags.
9
+ */
10
+ import type { Prompter } from "./prompt.js";
11
+ /** Options for {@link scaffoldWorkspace}. */
12
+ export interface WorkspaceScaffoldOptions {
13
+ /** Rewrite generated files even when their content already matches. */
14
+ force?: boolean;
15
+ /** Skip linking the plugin from the global runtime cache. */
16
+ skipInstall?: boolean;
17
+ /** Config path used to render the AGENTS.md guidance. */
18
+ configPath?: string;
19
+ }
20
+ /**
21
+ * Best-effort check whether `cwd` looks like a project root (git repo or
22
+ * common project manifest files). `setup` uses this to warn before creating
23
+ * `.opencode/` in an unrelated directory.
24
+ */
25
+ export declare function isLikelyProjectRoot(cwd: string): boolean;
26
+ /**
27
+ * Create or refresh the workspace files.
28
+ *
29
+ * Idempotent: unchanged generated files are reported as existing and not
30
+ * rewritten. The workspace config is never modified here.
31
+ */
32
+ export declare function scaffoldWorkspace(options?: WorkspaceScaffoldOptions): Promise<void>;
33
+ /**
34
+ * Check provider connectivity and offer to pull missing Ollama models.
35
+ *
36
+ * Uses the effective config (global < workspace) so models chosen in the
37
+ * wizard are probed even though most provider settings live in the global
38
+ * file.
39
+ */
40
+ export declare function runWorkspaceHealthCheck(cwd: string, prompter: Prompter): Promise<void>;