opencode-rag-plugin 2.12.3 → 2.13.1

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.
@@ -0,0 +1,821 @@
1
+ /**
2
+ * @fileoverview Declarative schema for the Web UI Configuration page.
3
+ *
4
+ * The browser never derives setting names or types on its own: this module is
5
+ * the single server-owned description of what is editable, where it may be
6
+ * written (project vs. machine-global provider options), how it is validated,
7
+ * and what a change implies (live, reindex, restart).
8
+ *
9
+ * Keeping the schema on the server also lets the redaction layer work from
10
+ * known secret paths instead of guessing from key names — the old regex
11
+ * redacted numeric settings such as `memory.autoInjectMinTokenOverlap`.
12
+ */
13
+ import { isProviderScopedPath } from "../core/config.js";
14
+ /** Secret leaf names, used for fields the schema has not enumerated yet. */
15
+ const SECRET_LEAVES = new Set(["apiKey", "password", "passwd", "secret", "token", "authorization"]);
16
+ /** Provider sections whose proxy/onDemand blocks are machine-global too. */
17
+ const PROVIDER_SECTIONS = new Set(["embedding", "description", "imageDescription", "decision", "reranking"]);
18
+ /** Resolve the writer scope for a path (explicit override wins). */
19
+ function scopeFor(path, explicit) {
20
+ if (explicit)
21
+ return explicit;
22
+ if (isProviderScopedPath(path))
23
+ return "global";
24
+ const section = path[0];
25
+ if (section && PROVIDER_SECTIONS.has(section) && (path.includes("proxy") || path.includes("onDemand"))) {
26
+ return "global";
27
+ }
28
+ return "project";
29
+ }
30
+ /** True when a path's leaf is a credential name. */
31
+ function isSecretPath(path) {
32
+ const leaf = path[path.length - 1];
33
+ return leaf !== undefined && SECRET_LEAVES.has(leaf);
34
+ }
35
+ /** Build a field, deriving scope and secret-ness from its path. */
36
+ function field(path, label, type, options = {}) {
37
+ const { scope, secret, impact, ...rest } = options;
38
+ return {
39
+ path,
40
+ label,
41
+ type,
42
+ ...rest,
43
+ scope: scopeFor(path, scope),
44
+ secret: secret ?? isSecretPath(path),
45
+ impact: impact ?? "live",
46
+ };
47
+ }
48
+ const boolean = (path, label, options) => field(path, label, "boolean", options);
49
+ const number = (path, label, options) => field(path, label, "number", options);
50
+ const string = (path, label, options) => field(path, label, "string", options);
51
+ const enumField = (path, label, values, options) => field(path, label, "enum", { enumValues: values, ...options });
52
+ const strings = (path, label, options) => field(path, label, "string[]", options);
53
+ const stringMap = (path, label, options) => field(path, label, "stringMap", options);
54
+ const stringArrayMap = (path, label, options) => field(path, label, "stringArrayMap", options);
55
+ const json = (path, label, options) => field(path, label, "json", options);
56
+ /** Proxy helper: one global block per provider section. */
57
+ function proxyFields(section) {
58
+ return [
59
+ string([section, "proxy", "url"], "Proxy URL", {
60
+ advanced: true,
61
+ placeholder: "http://proxy:8080",
62
+ }),
63
+ string([section, "proxy", "username"], "Proxy username", { advanced: true }),
64
+ string([section, "proxy", "password"], "Proxy password", { advanced: true }),
65
+ string([section, "proxy", "noProxy"], "Proxy bypass list", {
66
+ advanced: true,
67
+ description: "Comma-separated hosts that skip the proxy.",
68
+ }),
69
+ ];
70
+ }
71
+ /** The complete settings schema, in page order. */
72
+ export const SETTINGS_SECTIONS = [
73
+ {
74
+ id: "embedding",
75
+ label: "Embedding",
76
+ description: "Model used to vectorise code and queries.",
77
+ fields: [
78
+ enumField(["embedding", "provider"], "Provider", [
79
+ "ollama",
80
+ "openai",
81
+ "cohere",
82
+ "nvidia",
83
+ "azure",
84
+ "mistral",
85
+ "together",
86
+ "fireworks",
87
+ ], { impact: "reindex" }),
88
+ string(["embedding", "model"], "Model", { impact: "reindex" }),
89
+ string(["embedding", "baseUrl"], "Base URL", { impact: "reindex" }),
90
+ string(["embedding", "apiKey"], "API key", { impact: "reindex" }),
91
+ number(["embedding", "vectorDimension"], "Vector dimension", {
92
+ advanced: true,
93
+ minimum: 1,
94
+ impact: "reindex",
95
+ description: "Probed automatically; set only when the probe cannot reach the provider.",
96
+ }),
97
+ number(["embedding", "timeoutMs"], "Request timeout (ms)", { minimum: 1 }),
98
+ string(["embedding", "documentPrefix"], "Document prefix", {
99
+ advanced: true,
100
+ impact: "reindex",
101
+ }),
102
+ string(["embedding", "queryPrefix"], "Query prefix", { advanced: true }),
103
+ string(["embedding", "keepAlive"], "Ollama keep-alive", {
104
+ advanced: true,
105
+ placeholder: "30m",
106
+ }),
107
+ ...proxyFields("embedding"),
108
+ ],
109
+ },
110
+ {
111
+ id: "description",
112
+ label: "Descriptions",
113
+ description: "LLM-generated summaries embedded alongside code chunks.",
114
+ fields: [
115
+ boolean(["description", "enabled"], "Generate descriptions", { impact: "reindex" }),
116
+ enumField(["description", "provider"], "Provider", ["ollama", "openai", "anthropic", "google"], {
117
+ impact: "reindex",
118
+ }),
119
+ string(["description", "model"], "Model", { impact: "reindex" }),
120
+ string(["description", "baseUrl"], "Base URL", { impact: "reindex" }),
121
+ string(["description", "apiKey"], "API key", { impact: "reindex" }),
122
+ number(["description", "timeoutMs"], "Request timeout (ms)", { minimum: 1 }),
123
+ string(["description", "keepAlive"], "Ollama keep-alive", { advanced: true }),
124
+ string(["description", "systemPrompt"], "System prompt", {
125
+ advanced: true,
126
+ multiline: true,
127
+ impact: "reindex",
128
+ }),
129
+ boolean(["description", "think"], "Allow reasoning tokens", { advanced: true }),
130
+ number(["description", "numCtx"], "Context window", { advanced: true, minimum: 1 }),
131
+ number(["description", "maxContentChars"], "Max content chars", {
132
+ advanced: true,
133
+ minimum: 1,
134
+ }),
135
+ boolean(["description", "batchEnabled"], "Batch requests", { advanced: true, impact: "reindex" }),
136
+ number(["description", "batchMaxChunks"], "Batch size", { advanced: true, minimum: 1 }),
137
+ number(["description", "batchTimeoutMs"], "Batch timeout (ms)", { advanced: true, minimum: 1 }),
138
+ number(["description", "batchConcurrency"], "Batch concurrency", { advanced: true, minimum: 1 }),
139
+ number(["description", "retryMax"], "Max retries", { advanced: true, minimum: 0 }),
140
+ number(["description", "retryBaseDelayMs"], "Retry base delay (ms)", {
141
+ advanced: true,
142
+ minimum: 0,
143
+ }),
144
+ ...proxyFields("description"),
145
+ ],
146
+ },
147
+ {
148
+ id: "imageDescription",
149
+ label: "Image Descriptions",
150
+ description: "Vision model used to describe images during indexing.",
151
+ fields: [
152
+ boolean(["imageDescription", "enabled"], "Describe images", { impact: "reindex" }),
153
+ enumField(["imageDescription", "provider"], "Provider", [
154
+ "ollama",
155
+ "openai",
156
+ "anthropic",
157
+ "google",
158
+ "opencode",
159
+ "opencode-go",
160
+ ], { impact: "reindex" }),
161
+ string(["imageDescription", "model"], "Model", { impact: "reindex" }),
162
+ string(["imageDescription", "baseUrl"], "Base URL", { impact: "reindex" }),
163
+ string(["imageDescription", "apiKey"], "API key", { impact: "reindex" }),
164
+ number(["imageDescription", "timeoutMs"], "Request timeout (ms)", { minimum: 1 }),
165
+ string(["imageDescription", "prompt"], "Prompt", { multiline: true, impact: "reindex" }),
166
+ boolean(["imageDescription", "think"], "Allow reasoning tokens", { advanced: true }),
167
+ number(["imageDescription", "numCtx"], "Context window", { advanced: true, minimum: 1 }),
168
+ string(["imageDescription", "keepAlive"], "Ollama keep-alive", { advanced: true }),
169
+ number(["imageDescription", "resizeMaxDimension"], "Max image dimension", {
170
+ advanced: true,
171
+ minimum: 1,
172
+ }),
173
+ ...proxyFields("imageDescription"),
174
+ enumField(["imageDescription", "onDemand", "provider"], "On-demand provider", [
175
+ "ollama",
176
+ "openai",
177
+ "anthropic",
178
+ "google",
179
+ "opencode",
180
+ "opencode-go",
181
+ ], { advanced: true }),
182
+ string(["imageDescription", "onDemand", "model"], "On-demand model", { advanced: true }),
183
+ string(["imageDescription", "onDemand", "baseUrl"], "On-demand base URL", { advanced: true }),
184
+ string(["imageDescription", "onDemand", "apiKey"], "On-demand API key", { advanced: true }),
185
+ number(["imageDescription", "onDemand", "timeoutMs"], "On-demand timeout (ms)", {
186
+ advanced: true,
187
+ minimum: 1,
188
+ }),
189
+ string(["imageDescription", "onDemand", "prompt"], "On-demand prompt", { advanced: true }),
190
+ boolean(["imageDescription", "onDemand", "think"], "On-demand reasoning tokens", {
191
+ advanced: true,
192
+ }),
193
+ number(["imageDescription", "onDemand", "numCtx"], "On-demand context window", {
194
+ advanced: true,
195
+ minimum: 1,
196
+ }),
197
+ string(["imageDescription", "onDemand", "keepAlive"], "On-demand keep-alive", {
198
+ advanced: true,
199
+ }),
200
+ number(["imageDescription", "onDemand", "resizeMaxDimension"], "On-demand max dimension", {
201
+ advanced: true,
202
+ minimum: 1,
203
+ }),
204
+ ],
205
+ },
206
+ {
207
+ id: "decision",
208
+ label: "Decision Model",
209
+ description: "Local tev1 model behind the make_decision tool.",
210
+ fields: [
211
+ boolean(["decision", "enabled"], "Enable make_decision"),
212
+ enumField(["decision", "provider"], "Provider", ["ollama"]),
213
+ string(["decision", "model"], "Model"),
214
+ string(["decision", "baseUrl"], "Base URL"),
215
+ number(["decision", "timeoutMs"], "Request timeout (ms)", { minimum: 1 }),
216
+ string(["decision", "keepAlive"], "Ollama keep-alive", { advanced: true }),
217
+ boolean(["decision", "routeBeforeAsking"], "Route choices before asking"),
218
+ number(["decision", "maxStateChars"], "Max state chars", { advanced: true, minimum: 1 }),
219
+ number(["decision", "retryMax"], "Max retries", { advanced: true, minimum: 0 }),
220
+ number(["decision", "retryBaseDelayMs"], "Retry base delay (ms)", {
221
+ advanced: true,
222
+ minimum: 0,
223
+ }),
224
+ ...proxyFields("decision"),
225
+ ],
226
+ },
227
+ {
228
+ id: "reranking",
229
+ label: "Reranking",
230
+ description: "Optional cross-encoder rerank stage after hybrid fusion.",
231
+ fields: [
232
+ boolean(["reranking", "enabled"], "Enable reranking"),
233
+ enumField(["reranking", "provider"], "Provider", ["llama-server"]),
234
+ string(["reranking", "model"], "Model"),
235
+ string(["reranking", "baseUrl"], "Base URL"),
236
+ string(["reranking", "apiKey"], "API key"),
237
+ number(["reranking", "candidates"], "Candidates", { minimum: 1 }),
238
+ number(["reranking", "maxDocChars"], "Max document chars", { advanced: true, minimum: 1 }),
239
+ number(["reranking", "minScore"], "Rerank min score", {
240
+ advanced: true,
241
+ minimum: 0,
242
+ maximum: 1,
243
+ step: 0.01,
244
+ }),
245
+ number(["reranking", "timeoutMs"], "Timeout (ms)", { minimum: 1 }),
246
+ string(["reranking", "queryTemplate"], "Query template", { advanced: true }),
247
+ enumField(["reranking", "docField"], "Document field", ["content", "content+description"], {
248
+ advanced: true,
249
+ }),
250
+ ...proxyFields("reranking"),
251
+ ],
252
+ },
253
+ {
254
+ id: "shellGuard",
255
+ label: "Shell Guard",
256
+ description: "Decision-model vetting of shell commands before they run.",
257
+ fields: [
258
+ boolean(["shellGuard", "enabled"], "Enable Shell Guard"),
259
+ number(["shellGuard", "threshold"], "Flag threshold", {
260
+ minimum: 0,
261
+ maximum: 1,
262
+ step: 0.01,
263
+ }),
264
+ enumField(["shellGuard", "onError"], "On classifier error", ["allow", "ask"]),
265
+ number(["shellGuard", "timeoutMs"], "Classification timeout (ms)", { minimum: 1 }),
266
+ string(["shellGuard", "provider"], "Provider override", { advanced: true }),
267
+ string(["shellGuard", "baseUrl"], "Base URL override", { advanced: true }),
268
+ string(["shellGuard", "model"], "Model override", { advanced: true }),
269
+ number(["shellGuard", "cacheTtlMs"], "Verdict cache TTL (ms)", {
270
+ advanced: true,
271
+ minimum: 0,
272
+ }),
273
+ number(["shellGuard", "maxCacheEntries"], "Max cached verdicts", {
274
+ advanced: true,
275
+ minimum: 1,
276
+ }),
277
+ ],
278
+ },
279
+ {
280
+ id: "indexing",
281
+ label: "Indexing",
282
+ description: "What gets scanned and how indexing is tuned.",
283
+ fields: [
284
+ strings(["indexing", "includeExtensions"], "Included extensions", { impact: "reindex" }),
285
+ strings(["indexing", "includeDirs"], "Included folders", {
286
+ impact: "reindex",
287
+ description: "Empty = whole workspace. Paths are anchored to the workspace root.",
288
+ }),
289
+ strings(["indexing", "excludeDirs"], "Excluded folders", { impact: "reindex" }),
290
+ strings(["indexing", "excludeFiles"], "Excluded files", { impact: "reindex" }),
291
+ number(["indexing", "chunkOverlap"], "Chunk overlap (lines)", {
292
+ minimum: 0,
293
+ impact: "reindex",
294
+ }),
295
+ number(["indexing", "maxChunkSize"], "Max chunk size (lines)", {
296
+ minimum: 0,
297
+ impact: "reindex",
298
+ description: "0 = no limit (whole AST node).",
299
+ }),
300
+ number(["indexing", "minFileSizeBytes"], "Minimum file size (bytes)", {
301
+ minimum: 0,
302
+ impact: "reindex",
303
+ }),
304
+ number(["indexing", "concurrency"], "File concurrency", { minimum: 1 }),
305
+ number(["indexing", "embedBatchSize"], "Embedding batch size", { minimum: 1 }),
306
+ number(["indexing", "embedConcurrency"], "Embedding concurrency", { minimum: 1 }),
307
+ number(["indexing", "ollamaMaxBatchSize"], "Ollama max batch size", {
308
+ advanced: true,
309
+ minimum: 1,
310
+ }),
311
+ number(["indexing", "descriptionConcurrency"], "Description concurrency", {
312
+ advanced: true,
313
+ minimum: 1,
314
+ }),
315
+ boolean(["indexing", "embedDescriptions"], "Embed descriptions", { impact: "reindex" }),
316
+ number(["indexing", "maxSvgSizeBytes"], "Max SVG size (bytes)", {
317
+ advanced: true,
318
+ minimum: 0,
319
+ impact: "reindex",
320
+ }),
321
+ number(["indexing", "optimizeIntervalWindows"], "Optimize every N windows", {
322
+ advanced: true,
323
+ minimum: 0,
324
+ }),
325
+ ],
326
+ },
327
+ {
328
+ id: "chunking",
329
+ label: "Chunking",
330
+ description: "Per-language parser overrides.",
331
+ fields: [
332
+ stringMap(["chunking", "parsers"], "Extension → parser", {
333
+ advanced: true,
334
+ impact: "reindex",
335
+ }),
336
+ stringArrayMap(["chunking", "nodeTypes"], "Language → node types", {
337
+ advanced: true,
338
+ impact: "reindex",
339
+ }),
340
+ json(["chunkers"], "Custom chunker modules", { advanced: true, impact: "restart" }),
341
+ ],
342
+ },
343
+ {
344
+ id: "retrieval",
345
+ label: "Retrieval",
346
+ description: "Query-time ranking and context shaping.",
347
+ fields: [
348
+ number(["retrieval", "topK"], "Top K", { minimum: 1, maximum: 1000 }),
349
+ number(["retrieval", "minScore"], "Minimum score", {
350
+ minimum: 0,
351
+ maximum: 1,
352
+ step: 0.01,
353
+ }),
354
+ enumField(["retrieval", "minScoreMode"], "Min-score mode", ["fused", "normalized"]),
355
+ boolean(["retrieval", "hybridSearch", "enabled"], "Hybrid search"),
356
+ number(["retrieval", "hybridSearch", "keywordWeight"], "Keyword weight", {
357
+ minimum: 0,
358
+ maximum: 1,
359
+ step: 0.01,
360
+ }),
361
+ number(["retrieval", "hybridSearch", "symbolKeywordWeight"], "Symbol keyword weight", {
362
+ minimum: 0,
363
+ maximum: 1,
364
+ step: 0.01,
365
+ }),
366
+ number(["retrieval", "hybridSearch", "docKeywordDemotion"], "Document demotion", {
367
+ advanced: true,
368
+ minimum: 0,
369
+ maximum: 1,
370
+ step: 0.01,
371
+ }),
372
+ number(["retrieval", "hybridSearch", "testKeywordDemotion"], "Test demotion", {
373
+ advanced: true,
374
+ minimum: 0,
375
+ maximum: 1,
376
+ step: 0.01,
377
+ }),
378
+ boolean(["retrieval", "contextOptimization", "enabled"], "Context optimization"),
379
+ number(["retrieval", "contextOptimization", "maxPerFile"], "Max chunks per file", {
380
+ advanced: true,
381
+ minimum: 0,
382
+ }),
383
+ boolean(["retrieval", "contextOptimization", "mergeAdjacent"], "Merge adjacent chunks", {
384
+ advanced: true,
385
+ }),
386
+ number(["retrieval", "contextOptimization", "adjacentGapThreshold"], "Adjacent gap", {
387
+ advanced: true,
388
+ minimum: 0,
389
+ }),
390
+ number(["retrieval", "contextOptimization", "similarityThreshold"], "Similarity threshold", {
391
+ advanced: true,
392
+ minimum: 0,
393
+ maximum: 1,
394
+ step: 0.01,
395
+ }),
396
+ ],
397
+ },
398
+ {
399
+ id: "vectorStore",
400
+ label: "Vector Store",
401
+ description: "Where the index lives. Most changes need a restart.",
402
+ fields: [
403
+ string(["vectorStore", "path"], "Store path", { impact: "restart" }),
404
+ enumField(["vectorStore", "provider"], "Backend", ["lancedb", "memory", "clickhouse"], {
405
+ impact: "restart",
406
+ }),
407
+ string(["vectorStore", "clickhouse", "url"], "ClickHouse URL", {
408
+ advanced: true,
409
+ impact: "restart",
410
+ }),
411
+ string(["vectorStore", "clickhouse", "database"], "ClickHouse database", {
412
+ advanced: true,
413
+ impact: "restart",
414
+ }),
415
+ string(["vectorStore", "clickhouse", "username"], "ClickHouse user", {
416
+ advanced: true,
417
+ impact: "restart",
418
+ }),
419
+ string(["vectorStore", "clickhouse", "password"], "ClickHouse password", {
420
+ advanced: true,
421
+ impact: "restart",
422
+ }),
423
+ string(["vectorStore", "clickhouse", "passwordEnv"], "Password env var", {
424
+ advanced: true,
425
+ impact: "restart",
426
+ description: "Preferred over a password in a committed file.",
427
+ }),
428
+ string(["vectorStore", "clickhouse", "namespace"], "Namespace", {
429
+ advanced: true,
430
+ impact: "restart",
431
+ }),
432
+ number(["vectorStore", "clickhouse", "requestTimeoutMs"], "Request timeout (ms)", {
433
+ advanced: true,
434
+ minimum: 1,
435
+ impact: "restart",
436
+ }),
437
+ number(["vectorStore", "clickhouse", "maxOpenConnections"], "Max connections", {
438
+ advanced: true,
439
+ minimum: 1,
440
+ impact: "restart",
441
+ }),
442
+ boolean(["vectorStore", "clickhouse", "compression"], "Compression", {
443
+ advanced: true,
444
+ impact: "restart",
445
+ }),
446
+ boolean(["vectorStore", "clickhouse", "state", "syncDescCache"], "Sync description cache", {
447
+ advanced: true,
448
+ impact: "restart",
449
+ }),
450
+ boolean(["vectorStore", "clickhouse", "lease", "enabled"], "Single-writer lease", {
451
+ advanced: true,
452
+ impact: "restart",
453
+ }),
454
+ number(["vectorStore", "clickhouse", "lease", "ttlSeconds"], "Lease TTL (s)", {
455
+ advanced: true,
456
+ minimum: 10,
457
+ impact: "restart",
458
+ }),
459
+ number(["vectorStore", "clickhouse", "diskFreeFloorBytes"], "Disk free floor (bytes)", {
460
+ advanced: true,
461
+ minimum: 0,
462
+ impact: "restart",
463
+ }),
464
+ enumField(["vectorStore", "clickhouse", "ann"], "ANN index", ["off", "hnsw"], {
465
+ advanced: true,
466
+ impact: "restart",
467
+ }),
468
+ number(["vectorStore", "clickhouse", "annFetchMultiplier"], "ANN fetch multiplier", {
469
+ advanced: true,
470
+ minimum: 1,
471
+ impact: "restart",
472
+ }),
473
+ boolean(["vectorStore", "clickhouse", "annWithRescoring"], "ANN rescoring", {
474
+ advanced: true,
475
+ impact: "restart",
476
+ }),
477
+ ],
478
+ },
479
+ {
480
+ id: "openCode",
481
+ label: "OpenCode Integration",
482
+ description: "Tools, prompt injection, and background indexing.",
483
+ fields: [
484
+ boolean(["openCode", "enabled"], "Plugin enabled"),
485
+ number(["openCode", "maxContextChunks"], "Max context chunks", { minimum: 1 }),
486
+ boolean(["openCode", "readOverride"], "Override read tool"),
487
+ number(["openCode", "maxReadOutputChars"], "Max read output chars", {
488
+ advanced: true,
489
+ minimum: 1,
490
+ }),
491
+ enumField(["openCode", "readNoResultsBehavior"], "Read with no results", [
492
+ "hint",
493
+ "empty",
494
+ "error",
495
+ ], { advanced: true }),
496
+ number(["openCode", "readRelatedFilesMax"], "Related files shown", {
497
+ advanced: true,
498
+ minimum: 0,
499
+ }),
500
+ boolean(["openCode", "injectSystemPrompt"], "Inject RAG guidance"),
501
+ boolean(["openCode", "exploreAgentTools"], "Give explore agent RAG tools"),
502
+ boolean(["openCode", "autoIndex", "enabled"], "Auto-index file changes"),
503
+ number(["openCode", "autoIndex", "debounceMs"], "Auto-index debounce (ms)", {
504
+ minimum: 0,
505
+ }),
506
+ number(["openCode", "autoIndex", "intervalMs"], "Git poll interval (ms)", {
507
+ advanced: true,
508
+ minimum: 0,
509
+ }),
510
+ enumField(["openCode", "autoIndex", "watcher"], "Watcher backend", ["chokidar", "git"], {
511
+ advanced: true,
512
+ }),
513
+ boolean(["openCode", "shell", "backgroundGuidance"], "Background guidance", {
514
+ advanced: true,
515
+ }),
516
+ number(["openCode", "shell", "longRunningThresholdMs"], "Long command threshold (ms)", {
517
+ advanced: true,
518
+ minimum: 0,
519
+ }),
520
+ number(["openCode", "shell", "foregroundTimeoutMs"], "Foreground timeout (ms)", {
521
+ advanced: true,
522
+ minimum: 1,
523
+ }),
524
+ boolean(["openCode", "shell", "captureLongRunningQuirk"], "Capture long-command quirks", {
525
+ advanced: true,
526
+ }),
527
+ ],
528
+ },
529
+ {
530
+ id: "memory",
531
+ label: "Quirk Memory",
532
+ description: "Experiential memory captured across sessions.",
533
+ fields: [
534
+ boolean(["memory", "enabled"], "Memory enabled"),
535
+ boolean(["memory", "autoInject"], "Auto-inject quirks"),
536
+ number(["memory", "minConfidence"], "Min confidence", {
537
+ minimum: 0,
538
+ maximum: 1,
539
+ step: 0.01,
540
+ }),
541
+ number(["memory", "recallMinScore"], "Manual recall min score", {
542
+ minimum: 0,
543
+ maximum: 1,
544
+ step: 0.01,
545
+ }),
546
+ number(["memory", "autoInjectMinScore"], "Auto-inject min score", {
547
+ minimum: 0,
548
+ maximum: 1,
549
+ step: 0.01,
550
+ }),
551
+ number(["memory", "autoInjectTopK"], "Auto-inject top K", { minimum: 0 }),
552
+ number(["memory", "autoInjectMinTokenOverlap"], "Auto-inject token overlap", {
553
+ advanced: true,
554
+ minimum: 0,
555
+ }),
556
+ number(["memory", "autoInjectLatencyBudgetMs"], "Auto-inject latency budget (ms)", {
557
+ advanced: true,
558
+ minimum: 0,
559
+ }),
560
+ boolean(["memory", "passiveCapture"], "Passive capture", { advanced: true }),
561
+ boolean(["memory", "promptEnforcement"], "Mandatory capture prompt", { advanced: true }),
562
+ boolean(["memory", "sessionEndExtraction"], "Session-end extraction", { advanced: true }),
563
+ number(["memory", "autoCaptureMaxPerTurn"], "Max captures per turn", {
564
+ advanced: true,
565
+ minimum: 0,
566
+ }),
567
+ number(["memory", "autoCaptureDedupThreshold"], "Capture dedup threshold", {
568
+ advanced: true,
569
+ minimum: 0,
570
+ maximum: 1,
571
+ step: 0.01,
572
+ }),
573
+ boolean(["memory", "injectOnToolError"], "Inject after tool errors", { advanced: true }),
574
+ number(["memory", "toolErrorMinScore"], "Tool-error min score", {
575
+ advanced: true,
576
+ minimum: 0,
577
+ maximum: 1,
578
+ step: 0.01,
579
+ }),
580
+ number(["memory", "toolErrorTopK"], "Tool-error top K", { advanced: true, minimum: 0 }),
581
+ number(["memory", "toolErrorMinTokenOverlap"], "Tool-error token overlap", {
582
+ advanced: true,
583
+ minimum: 0,
584
+ }),
585
+ number(["memory", "toolErrorCooldownMs"], "Tool-error cooldown (ms)", {
586
+ advanced: true,
587
+ minimum: 0,
588
+ }),
589
+ number(["memory", "toolErrorMaxPerSession"], "Tool-error injections / session", {
590
+ advanced: true,
591
+ minimum: 0,
592
+ }),
593
+ number(["memory", "toolErrorLatencyBudgetMs"], "Tool-error latency budget (ms)", {
594
+ advanced: true,
595
+ minimum: 0,
596
+ }),
597
+ boolean(["memory", "autoCreateOnToolError"], "Create quirks from tool errors", {
598
+ advanced: true,
599
+ }),
600
+ number(["memory", "toolErrorCreateMaxPerSession"], "Creations / session", {
601
+ advanced: true,
602
+ minimum: 0,
603
+ }),
604
+ number(["memory", "toolErrorCreateCooldownMs"], "Creation cooldown (ms)", {
605
+ advanced: true,
606
+ minimum: 0,
607
+ }),
608
+ number(["memory", "toolErrorCreateMinScore"], "Creation min score", {
609
+ advanced: true,
610
+ minimum: 0,
611
+ maximum: 1,
612
+ step: 0.01,
613
+ }),
614
+ number(["memory", "toolErrorCreateLatencyBudgetMs"], "Creation latency budget (ms)", {
615
+ advanced: true,
616
+ minimum: 0,
617
+ }),
618
+ boolean(["memory", "toolErrorInjectCreated"], "Inject created quirk", { advanced: true }),
619
+ boolean(["memory", "toolErrorProactiveInject"], "Proactive tool gotchas", { advanced: true }),
620
+ number(["memory", "toolErrorProactiveMaxItems"], "Max proactive gotchas", {
621
+ advanced: true,
622
+ minimum: 0,
623
+ }),
624
+ boolean(["memory", "interceptAllErrors"], "Intercept all failures", { advanced: true }),
625
+ boolean(["memory", "autoCreateOnInterceptedError"], "Create from intercepted failures", {
626
+ advanced: true,
627
+ }),
628
+ boolean(["memory", "decay", "enabled"], "Confidence decay", { advanced: true }),
629
+ number(["memory", "decay", "halfLifeDays"], "Decay half-life (days)", {
630
+ advanced: true,
631
+ minimum: 1,
632
+ }),
633
+ ],
634
+ },
635
+ {
636
+ id: "documentationMode",
637
+ label: "Documentation Mode",
638
+ description: "Agent mode that adds doc comments to undocumented code.",
639
+ fields: [
640
+ boolean(["documentationMode", "enabled"], "Documentation mode enabled"),
641
+ boolean(["documentationMode", "autoStart"], "Start automatically"),
642
+ number(["documentationMode", "batchSize"], "Files per batch", { minimum: 1 }),
643
+ string(["documentationMode", "systemPrompt"], "System prompt", {
644
+ advanced: true,
645
+ multiline: true,
646
+ }),
647
+ ],
648
+ },
649
+ {
650
+ id: "wikiMode",
651
+ label: "Wiki Mode",
652
+ description: "Agent instruction that maintains a knowledge wiki.",
653
+ fields: [
654
+ boolean(["wikiMode", "enabled"], "Wiki mode enabled"),
655
+ string(["wikiMode", "systemPrompt"], "System prompt", {
656
+ advanced: true,
657
+ multiline: true,
658
+ }),
659
+ ],
660
+ },
661
+ {
662
+ id: "mcp",
663
+ label: "MCP Server",
664
+ description: "Standalone Model Context Protocol server.",
665
+ fields: [boolean(["mcp", "enabled"], "Auto-start MCP server", { impact: "restart" })],
666
+ },
667
+ {
668
+ id: "setup",
669
+ label: "Workspace Setup",
670
+ description: "Scaffolding behaviour for repositories without a config.",
671
+ fields: [boolean(["setup", "autoScaffold"], "Auto-scaffold new workspaces", { advanced: true })],
672
+ },
673
+ {
674
+ id: "autoUpdate",
675
+ label: "Auto Update",
676
+ description: "Update checks and optional automatic installs.",
677
+ fields: [
678
+ boolean(["autoUpdate", "enabled"], "Check for updates"),
679
+ boolean(["autoUpdate", "autoInstall"], "Install updates automatically", { advanced: true }),
680
+ number(["autoUpdate", "cooldownMs"], "Retry cooldown (ms)", {
681
+ advanced: true,
682
+ minimum: 0,
683
+ }),
684
+ number(["autoUpdate", "maxConsecutiveFailures"], "Max consecutive failures", {
685
+ advanced: true,
686
+ minimum: 1,
687
+ }),
688
+ ],
689
+ },
690
+ {
691
+ id: "ui",
692
+ label: "Web UI",
693
+ description: "This dashboard's own server settings.",
694
+ fields: [
695
+ number(["ui", "port"], "Port", { minimum: 1, maximum: 65535, impact: "restart" }),
696
+ boolean(["ui", "openBrowser"], "Open browser on start", { impact: "restart" }),
697
+ enumField(["ui", "theme"], "Theme", ["dark", "light", "plasma", "drama"], {
698
+ scope: "global",
699
+ description: "Dashboard color theme. A machine-wide preference, saved to the global config.",
700
+ }),
701
+ ],
702
+ },
703
+ {
704
+ id: "tui",
705
+ label: "Terminal UI",
706
+ description: "Keybindings for the OpenCode terminal plugin.",
707
+ fields: [
708
+ string(["tui", "settingsKeybinding"], "Open settings", { impact: "restart" }),
709
+ string(["tui", "fileListKeybinding"], "Add file list", { impact: "restart" }),
710
+ string(["tui", "chunksKeybinding"], "Add chunks", { impact: "restart" }),
711
+ ],
712
+ },
713
+ {
714
+ id: "logging",
715
+ label: "Logging",
716
+ description: "Plugin log verbosity and destination.",
717
+ fields: [
718
+ enumField(["logging", "level"], "Level", ["debug", "info", "error", "none"]),
719
+ string(["logging", "logFilePath"], "Log file path", { advanced: true }),
720
+ ],
721
+ },
722
+ ];
723
+ /** Flattened path→field index. */
724
+ const FIELD_BY_PATH = new Map();
725
+ for (const section of SETTINGS_SECTIONS) {
726
+ for (const entry of section.fields) {
727
+ FIELD_BY_PATH.set(entry.path.join("."), entry);
728
+ }
729
+ }
730
+ /** Dotted form of a config path. */
731
+ export function dottedPath(path) {
732
+ return path.join(".");
733
+ }
734
+ /** Look up a schema field by path. */
735
+ export function findSettingField(path) {
736
+ return FIELD_BY_PATH.get(dottedPath(path));
737
+ }
738
+ /** True when every segment is a safe object key (no prototype pollution). */
739
+ export function isSafeConfigPath(path) {
740
+ if (path.length === 0 || path.length > 12)
741
+ return false;
742
+ return path.every((segment) => typeof segment === "string" &&
743
+ segment.length > 0 &&
744
+ segment.length <= 120 &&
745
+ segment !== "__proto__" &&
746
+ segment !== "prototype" &&
747
+ segment !== "constructor");
748
+ }
749
+ /**
750
+ * Secret-ness of a path for redaction purposes.
751
+ *
752
+ * Schema fields win. For paths the schema does not know (custom or future
753
+ * keys) only an EXACT credential leaf name counts — never a substring match,
754
+ * which is what wrongly redacted `autoInjectMinTokenOverlap`.
755
+ */
756
+ export function isSecretConfigPath(path) {
757
+ const declared = findSettingField(path);
758
+ if (declared)
759
+ return declared.secret === true;
760
+ const leaf = path[path.length - 1];
761
+ return leaf !== undefined && SECRET_LEAVES.has(leaf);
762
+ }
763
+ /** True when a value is a plain JSON object. */
764
+ export function isPlainConfigObject(value) {
765
+ return typeof value === "object" && value !== null && !Array.isArray(value);
766
+ }
767
+ /** Deep-clone a JSON-ish value. */
768
+ export function cloneConfigValue(value) {
769
+ return value === undefined ? value : JSON.parse(JSON.stringify(value));
770
+ }
771
+ /**
772
+ * Strip secret values from a config object, in place.
773
+ *
774
+ * Known secret fields become the `***` sentinel (so the UI can show that a
775
+ * value exists without receiving it); unknown credential-named leaves are
776
+ * removed entirely.
777
+ */
778
+ export function redactConfigSecrets(value, path = []) {
779
+ if (!isPlainConfigObject(value))
780
+ return;
781
+ for (const [key, child] of Object.entries(value)) {
782
+ const childPath = [...path, key];
783
+ if (isPlainConfigObject(child)) {
784
+ redactConfigSecrets(child, childPath);
785
+ continue;
786
+ }
787
+ if (!isSecretConfigPath(childPath))
788
+ continue;
789
+ const declared = findSettingField(childPath);
790
+ if (declared?.secret) {
791
+ value[key] = "***";
792
+ }
793
+ else {
794
+ delete value[key];
795
+ }
796
+ }
797
+ }
798
+ /** Explicitly ignored leaves that are not user-editable settings. */
799
+ export const IGNORED_CONFIG_PATHS = new Set([
800
+ // `vectorStore.path` is editable, but the probe-derived dimension cache is
801
+ // intentionally schema-managed only when the provider cannot be reached.
802
+ ]);
803
+ /** Collect the dotted leaf paths of a config object (arrays are leaves). */
804
+ export function collectConfigLeafPaths(value, path = [], out = []) {
805
+ if (isPlainConfigObject(value)) {
806
+ const keys = Object.keys(value);
807
+ if (keys.length === 0) {
808
+ if (path.length > 0)
809
+ out.push(dottedPath(path));
810
+ return out;
811
+ }
812
+ for (const [key, child] of Object.entries(value)) {
813
+ collectConfigLeafPaths(child, [...path, key], out);
814
+ }
815
+ return out;
816
+ }
817
+ if (path.length > 0)
818
+ out.push(dottedPath(path));
819
+ return out;
820
+ }
821
+ //# sourceMappingURL=config-schema.js.map