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,322 @@
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 path from "node:path";
11
+ import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
12
+ import { loadConfig, loadWorkspaceConfig, configuredSections, findConfigFile, projectConfigPath } from "../core/config.js";
13
+ import { checkProviderHealth, pullOllamaModels } from "../embedder/health.js";
14
+ import { c } from "./format.js";
15
+ import { getPackageMetadata, readJsonObject, writeJsonFile } from "./helpers.js";
16
+ import { buildLegacyTuiConfig, buildOpencodeConfig, buildWorkspacePackageJson, generateDecisionSkillFile, generateLegacyWorkspacePluginFile, generateLegacyWorkspaceTuiPluginFile, generateSkillFile, generateWorkspacePluginFile, generateWorkspaceTuiPluginFile, installPluginFromGlobal, mergeAgentsMdContent, mergeGitignoreContent, LEGACY_PLUGIN_ENTRY, LEGACY_TUI_CONFIG, LEGACY_TUI_ENTRY, WORKSPACE_PLUGIN_DIR, WORKSPACE_PLUGIN_ENTRY, WORKSPACE_TUI_ENTRY, } from "./commands/workspace-helpers.js";
17
+ /**
18
+ * Best-effort check whether `cwd` looks like a project root (git repo or
19
+ * common project manifest files). `setup` uses this to warn before creating
20
+ * `.opencode/` in an unrelated directory.
21
+ */
22
+ export function isLikelyProjectRoot(cwd) {
23
+ if (existsSync(path.join(cwd, ".git"))) {
24
+ return true;
25
+ }
26
+ const markers = [
27
+ "package.json",
28
+ "AGENTS.md",
29
+ "README.md",
30
+ "pyproject.toml",
31
+ "Cargo.toml",
32
+ "go.mod",
33
+ "opencode-rag.json",
34
+ ".opencode/opencode-rag.json",
35
+ ];
36
+ return markers.some((marker) => existsSync(path.join(cwd, marker)));
37
+ }
38
+ /**
39
+ * Create or refresh the workspace files.
40
+ *
41
+ * Idempotent: unchanged generated files are reported as existing and not
42
+ * rewritten. The workspace config is never modified here.
43
+ */
44
+ export async function scaffoldWorkspace(options = {}) {
45
+ const cwd = process.cwd();
46
+ const packageMetadata = getPackageMetadata();
47
+ const configPath = options.configPath ?? findConfigFile(cwd) ?? projectConfigPath(cwd);
48
+ const opencodeDir = path.join(cwd, ".opencode");
49
+ const gitignorePath = path.join(opencodeDir, ".gitignore");
50
+ const opencodeConfigPath = path.join(opencodeDir, "opencode.json");
51
+ const pluginsDir = path.join(opencodeDir, "plugins");
52
+ const workspacePluginDir = path.join(pluginsDir, WORKSPACE_PLUGIN_DIR);
53
+ const pluginEntryPath = path.join(workspacePluginDir, "index.js");
54
+ const tuiPluginEntryPath = path.join(workspacePluginDir, "tui.js");
55
+ const legacyPluginEntryPath = path.join(pluginsDir, "rag-plugin.js");
56
+ const legacyTuiPluginEntryPath = path.join(pluginsDir, "rag-tui.js");
57
+ const legacyTuiConfigPath = path.join(opencodeDir, "tui.json");
58
+ const opencodePackagePath = path.join(opencodeDir, "package.json");
59
+ console.log(`\n${c.heading("Workspace files")}\n`);
60
+ if (!existsSync(opencodeDir)) {
61
+ mkdirSync(opencodeDir, { recursive: true });
62
+ console.log(` ${c.created("Created:")} .opencode/`);
63
+ }
64
+ else {
65
+ console.log(` ${c.exists("Exists:")} .opencode/`);
66
+ }
67
+ // The wiki is user-authored; setup never touches it.
68
+ const wikiDir = path.join(opencodeDir, "wiki");
69
+ if (existsSync(wikiDir)) {
70
+ console.log(` ${c.exists("Preserved:")} .opencode/wiki/ (never modified by setup)`);
71
+ }
72
+ if (!existsSync(pluginsDir)) {
73
+ mkdirSync(pluginsDir, { recursive: true });
74
+ console.log(` ${c.created("Created:")} .opencode/plugins/`);
75
+ }
76
+ else {
77
+ console.log(` ${c.exists("Exists:")} .opencode/plugins/`);
78
+ }
79
+ const gitignoreExists = existsSync(gitignorePath);
80
+ const nextGitignoreContent = mergeGitignoreContent(gitignoreExists ? readFileSync(gitignorePath, "utf-8") : undefined);
81
+ if (!gitignoreExists || options.force || readFileSync(gitignorePath, "utf-8") !== nextGitignoreContent) {
82
+ writeFileSync(gitignorePath, nextGitignoreContent, "utf-8");
83
+ console.log(` ${gitignoreExists ? c.updated("Updated:") : c.created("Created:")} .opencode/.gitignore`);
84
+ }
85
+ else {
86
+ console.log(` ${c.exists("Exists:")} .opencode/.gitignore`);
87
+ }
88
+ const opencodeConfigExists = existsSync(opencodeConfigPath);
89
+ const nextOpencodeConfig = buildOpencodeConfig(readJsonObject(opencodeConfigPath));
90
+ if (!opencodeConfigExists || options.force) {
91
+ writeJsonFile(opencodeConfigPath, nextOpencodeConfig);
92
+ console.log(` ${opencodeConfigExists ? c.updated("Updated:") : c.created("Created:")} .opencode/opencode.json`);
93
+ }
94
+ else if (JSON.stringify(readJsonObject(opencodeConfigPath)) !== JSON.stringify(nextOpencodeConfig)) {
95
+ writeJsonFile(opencodeConfigPath, nextOpencodeConfig);
96
+ console.log(` ${c.updated("Updated:")} .opencode/opencode.json`);
97
+ }
98
+ else {
99
+ console.log(` ${c.exists("Exists:")} .opencode/opencode.json`);
100
+ }
101
+ // OpenCode 2 discovers plugin *directories* under `.opencode/plugins/`:
102
+ // `index.js` is the server entrypoint and `tui.js` beside it is the CLI
103
+ // entrypoint. Flat `.js` files only reach the server role.
104
+ if (!existsSync(workspacePluginDir)) {
105
+ mkdirSync(workspacePluginDir, { recursive: true });
106
+ console.log(` ${c.created("Created:")} .opencode/plugins/${WORKSPACE_PLUGIN_DIR}/`);
107
+ }
108
+ const pluginEntryExists = existsSync(pluginEntryPath);
109
+ const pluginEntryContent = generateWorkspacePluginFile(packageMetadata.name);
110
+ if (!pluginEntryExists || options.force) {
111
+ writeFileSync(pluginEntryPath, pluginEntryContent, "utf-8");
112
+ console.log(` ${pluginEntryExists ? c.updated("Updated:") : c.created("Created:")} ${WORKSPACE_PLUGIN_ENTRY}`);
113
+ }
114
+ else if (readFileSync(pluginEntryPath, "utf-8") !== pluginEntryContent) {
115
+ writeFileSync(pluginEntryPath, pluginEntryContent, "utf-8");
116
+ console.log(` ${c.updated("Updated:")} ${WORKSPACE_PLUGIN_ENTRY}`);
117
+ }
118
+ else {
119
+ console.log(` ${c.exists("Exists:")} ${WORKSPACE_PLUGIN_ENTRY}`);
120
+ }
121
+ const tuiPluginEntryExists = existsSync(tuiPluginEntryPath);
122
+ const tuiPluginEntryContent = generateWorkspaceTuiPluginFile(packageMetadata.name);
123
+ if (!tuiPluginEntryExists || options.force) {
124
+ writeFileSync(tuiPluginEntryPath, tuiPluginEntryContent, "utf-8");
125
+ console.log(` ${tuiPluginEntryExists ? c.updated("Updated:") : c.created("Created:")} ${WORKSPACE_TUI_ENTRY}`);
126
+ }
127
+ else if (readFileSync(tuiPluginEntryPath, "utf-8") !== tuiPluginEntryContent) {
128
+ writeFileSync(tuiPluginEntryPath, tuiPluginEntryContent, "utf-8");
129
+ console.log(` ${c.updated("Updated:")} ${WORKSPACE_TUI_ENTRY}`);
130
+ }
131
+ else {
132
+ console.log(` ${c.exists("Exists:")} ${WORKSPACE_TUI_ENTRY}`);
133
+ }
134
+ // Remove only the V1-era flat entries that an older `init` wrote verbatim;
135
+ // modified files are kept (they are no longer loaded by OpenCode 2).
136
+ const legacyEntries = [
137
+ [legacyPluginEntryPath, generateLegacyWorkspacePluginFile(packageMetadata.name), LEGACY_PLUGIN_ENTRY],
138
+ [legacyTuiPluginEntryPath, generateLegacyWorkspaceTuiPluginFile(packageMetadata.name), LEGACY_TUI_ENTRY],
139
+ ];
140
+ for (const [legacyPath, legacyContent, legacyRel] of legacyEntries) {
141
+ if (!existsSync(legacyPath))
142
+ continue;
143
+ if (readFileSync(legacyPath, "utf-8") === legacyContent) {
144
+ unlinkSync(legacyPath);
145
+ console.log(` ${c.updated("Removed:")} ${legacyRel} (superseded by ${WORKSPACE_PLUGIN_DIR}/)`);
146
+ }
147
+ else {
148
+ console.log(` ${c.warn("Kept:")} ${legacyRel} (modified locally — no longer loaded by OpenCode 2)`);
149
+ }
150
+ }
151
+ if (existsSync(legacyTuiConfigPath)) {
152
+ const sameLegacyConfig = JSON.stringify(readJsonObject(legacyTuiConfigPath)) === JSON.stringify(buildLegacyTuiConfig());
153
+ if (sameLegacyConfig) {
154
+ unlinkSync(legacyTuiConfigPath);
155
+ console.log(` ${c.updated("Removed:")} ${LEGACY_TUI_CONFIG} (V1 config — OpenCode 2 discovers CLI plugins)`);
156
+ }
157
+ else {
158
+ console.log(` ${c.warn("Kept:")} ${LEGACY_TUI_CONFIG} (V1 config — ignored by OpenCode 2)`);
159
+ }
160
+ }
161
+ const skillsDir = path.join(opencodeDir, "skills");
162
+ const skillDir = path.join(skillsDir, "opencode-rag");
163
+ const skillPath = path.join(skillDir, "SKILL.md");
164
+ if (!existsSync(skillDir)) {
165
+ mkdirSync(skillDir, { recursive: true });
166
+ console.log(` ${c.created("Created:")} .opencode/skills/opencode-rag/`);
167
+ }
168
+ const skillContent = generateSkillFile();
169
+ const skillExists = existsSync(skillPath);
170
+ if (!skillExists || options.force) {
171
+ writeFileSync(skillPath, skillContent, "utf-8");
172
+ console.log(` ${skillExists ? c.updated("Updated:") : c.created("Created:")} .opencode/skills/opencode-rag/SKILL.md`);
173
+ }
174
+ else if (readFileSync(skillPath, "utf-8") !== skillContent) {
175
+ writeFileSync(skillPath, skillContent, "utf-8");
176
+ console.log(` ${c.updated("Updated:")} .opencode/skills/opencode-rag/SKILL.md`);
177
+ }
178
+ else {
179
+ console.log(` ${c.exists("Exists:")} .opencode/skills/opencode-rag/SKILL.md`);
180
+ }
181
+ const decisionSkillDir = path.join(skillsDir, "make-decision");
182
+ const decisionSkillPath = path.join(decisionSkillDir, "SKILL.md");
183
+ if (!existsSync(decisionSkillDir)) {
184
+ mkdirSync(decisionSkillDir, { recursive: true });
185
+ console.log(` ${c.created("Created:")} .opencode/skills/make-decision/`);
186
+ }
187
+ const decisionSkillContent = generateDecisionSkillFile();
188
+ const decisionSkillExists = existsSync(decisionSkillPath);
189
+ if (!decisionSkillExists || options.force) {
190
+ writeFileSync(decisionSkillPath, decisionSkillContent, "utf-8");
191
+ console.log(` ${decisionSkillExists ? c.updated("Updated:") : c.created("Created:")} .opencode/skills/make-decision/SKILL.md`);
192
+ }
193
+ else if (readFileSync(decisionSkillPath, "utf-8") !== decisionSkillContent) {
194
+ writeFileSync(decisionSkillPath, decisionSkillContent, "utf-8");
195
+ console.log(` ${c.updated("Updated:")} .opencode/skills/make-decision/SKILL.md`);
196
+ }
197
+ else {
198
+ console.log(` ${c.exists("Exists:")} .opencode/skills/make-decision/SKILL.md`);
199
+ }
200
+ const agentsMdPath = path.join(cwd, "AGENTS.md");
201
+ const agentsMdExists = existsSync(agentsMdPath);
202
+ let promptEnforcement = true;
203
+ let decisionEnabled = false;
204
+ let routeBeforeAsking = false;
205
+ try {
206
+ if (existsSync(configPath)) {
207
+ const existingCfg = loadConfig(configPath, false);
208
+ promptEnforcement = existingCfg.memory?.promptEnforcement ?? true;
209
+ decisionEnabled = existingCfg.decision?.enabled ?? false;
210
+ routeBeforeAsking = existingCfg.decision?.routeBeforeAsking ?? false;
211
+ }
212
+ }
213
+ catch {
214
+ // Malformed or missing config — use defaults.
215
+ }
216
+ const nextAgentsMd = mergeAgentsMdContent(agentsMdExists ? readFileSync(agentsMdPath, "utf-8") : undefined, { promptEnforcement, decisionEnabled, routeBeforeAsking });
217
+ if (!agentsMdExists || options.force) {
218
+ writeFileSync(agentsMdPath, nextAgentsMd, "utf-8");
219
+ console.log(` ${agentsMdExists ? c.updated("Updated:") : c.created("Created:")} AGENTS.md`);
220
+ }
221
+ else if (readFileSync(agentsMdPath, "utf-8") !== nextAgentsMd) {
222
+ writeFileSync(agentsMdPath, nextAgentsMd, "utf-8");
223
+ console.log(` ${c.updated("Updated:")} AGENTS.md`);
224
+ }
225
+ else {
226
+ console.log(` ${c.exists("Exists:")} AGENTS.md`);
227
+ }
228
+ const workspacePackageExists = existsSync(opencodePackagePath);
229
+ const nextWorkspacePackage = buildWorkspacePackageJson(readJsonObject(opencodePackagePath), packageMetadata);
230
+ if (!workspacePackageExists || options.force) {
231
+ writeJsonFile(opencodePackagePath, nextWorkspacePackage);
232
+ console.log(` ${workspacePackageExists ? c.updated("Updated:") : c.created("Created:")} .opencode/package.json`);
233
+ }
234
+ else if (JSON.stringify(readJsonObject(opencodePackagePath)) !== JSON.stringify(nextWorkspacePackage)) {
235
+ writeJsonFile(opencodePackagePath, nextWorkspacePackage);
236
+ console.log(` ${c.updated("Updated:")} .opencode/package.json`);
237
+ }
238
+ else {
239
+ console.log(` ${c.exists("Exists:")} .opencode/package.json`);
240
+ }
241
+ if (options.skipInstall) {
242
+ console.log(`\n ${c.exists("Skipped:")} plugin installation (--skip-install)`);
243
+ return;
244
+ }
245
+ console.log(`\n${c.heading("Installing workspace-local plugin...")}\n`);
246
+ await installPluginFromGlobal(opencodeDir, packageMetadata.name, false);
247
+ console.log(`\n ${c.success("Installed:")} .opencode/node_modules/`);
248
+ console.log(` ${c.dim("Plugin is linked to the global runtime cache; no npm install was required.")}`);
249
+ }
250
+ /**
251
+ * Check provider connectivity and offer to pull missing Ollama models.
252
+ *
253
+ * Uses the effective config (global < workspace) so models chosen in the
254
+ * wizard are probed even though most provider settings live in the global
255
+ * file.
256
+ */
257
+ export async function runWorkspaceHealthCheck(cwd, prompter) {
258
+ console.log(`\n${c.heading("Checking provider connectivity...")}\n`);
259
+ const ragConfig = loadWorkspaceConfig(cwd);
260
+ const results = await checkProviderHealth(ragConfig, configuredSections(cwd));
261
+ for (const result of results) {
262
+ const icon = result.status === "ok" ? c.success("✓") : result.status === "missing" ? c.warn("○") : c.error("✗");
263
+ const typeLabel = result.type === "image_description"
264
+ ? "image description"
265
+ : result.type === "image_description_on_demand"
266
+ ? "image description (on-demand)"
267
+ : result.type;
268
+ console.log(` ${icon} ${c.value(result.model)} (${result.provider}) — ${typeLabel} model: ${result.status}`);
269
+ if (result.error)
270
+ console.log(` ${c.dim(result.error)}`);
271
+ }
272
+ const missingOllama = results.filter((result) => result.status === "missing" && result.provider === "ollama");
273
+ if (missingOllama.length > 0) {
274
+ const pullEntries = missingOllama.map((result) => {
275
+ if (result.type === "embedding") {
276
+ return { model: result.model, baseUrl: ragConfig.embedding.baseUrl, proxy: ragConfig.embedding.proxy };
277
+ }
278
+ if (result.type === "description" && ragConfig.description) {
279
+ return { model: result.model, baseUrl: ragConfig.description.baseUrl, proxy: ragConfig.description.proxy };
280
+ }
281
+ if (result.type === "image_description" && ragConfig.imageDescription) {
282
+ return { model: result.model, baseUrl: ragConfig.imageDescription.baseUrl, proxy: ragConfig.imageDescription.proxy };
283
+ }
284
+ if (result.type === "image_description_on_demand" && ragConfig.imageDescription) {
285
+ const onDemand = ragConfig.imageDescription.onDemand;
286
+ return {
287
+ model: result.model,
288
+ baseUrl: onDemand?.baseUrl ?? ragConfig.imageDescription.baseUrl,
289
+ proxy: onDemand?.proxy ?? ragConfig.imageDescription.proxy,
290
+ };
291
+ }
292
+ return { model: result.model, baseUrl: ragConfig.embedding.baseUrl, proxy: ragConfig.embedding.proxy };
293
+ });
294
+ console.log(`\n ${c.warn("Models not found:")} ${pullEntries.map((entry) => entry.model).join(", ")}`);
295
+ const pull = prompter.interactive
296
+ ? await prompter.confirm({
297
+ message: `Pull ${pullEntries.length === 1 ? "this model" : "these models"} now?`,
298
+ defaultValue: false,
299
+ })
300
+ : false;
301
+ if (pull) {
302
+ console.log();
303
+ try {
304
+ await pullOllamaModels(pullEntries, (model, line) => {
305
+ console.log(` ${c.value(model)}: ${line}`);
306
+ });
307
+ console.log(`\n ${c.success("Models pulled successfully.")}`);
308
+ }
309
+ catch (err) {
310
+ console.error(`\n ${c.error("Pull failed:")} ${err.message}`);
311
+ console.log(` ${c.dim("Pull manually with: ollama pull <model>")}`);
312
+ }
313
+ }
314
+ else {
315
+ console.log(` ${c.dim("Skipped. Pull manually with: ollama pull <model>")}`);
316
+ }
317
+ }
318
+ if (results.some((result) => result.status === "error")) {
319
+ console.log(`\n ${c.warn("Some providers are not reachable.")} Check configuration and network, then run ${c.file("'opencode-rag index'")}.`);
320
+ }
321
+ }
322
+ //# sourceMappingURL=workspace.js.map
package/dist/cli.d.ts CHANGED
@@ -5,4 +5,4 @@
5
5
  /** Main CLI runner and auto-launch detection. */
6
6
  export { runCli, shouldAutoRunCli } from "./cli/index.js";
7
7
  /** Cleanup helper that removes stale global plugin registration symlinks. */
8
- export { removeStaleGlobalPluginRegistrations } from "./cli/commands/init-helpers.js";
8
+ export { removeStaleGlobalPluginRegistrations } from "./cli/commands/workspace-helpers.js";
package/dist/cli.js CHANGED
@@ -5,5 +5,5 @@
5
5
  /** Main CLI runner and auto-launch detection. */
6
6
  export { runCli, shouldAutoRunCli } from "./cli/index.js";
7
7
  /** Cleanup helper that removes stale global plugin registration symlinks. */
8
- export { removeStaleGlobalPluginRegistrations } from "./cli/commands/init-helpers.js";
8
+ export { removeStaleGlobalPluginRegistrations } from "./cli/commands/workspace-helpers.js";
9
9
  //# sourceMappingURL=cli.js.map
@@ -825,9 +825,9 @@ export declare function validateConfig(config: RagConfig): ConfigValidationResul
825
825
  * Config file locations to search, in order of precedence.
826
826
  *
827
827
  * `.opencode/opencode-rag.json` is the canonical workspace location — every
828
- * writer (TUI, `init`, `clickhouse setup`, the Web UI) creates and updates it
828
+ * writer (TUI, `setup`, `clickhouse setup`, the Web UI) creates and updates it
829
829
  * there. The root-level `opencode-rag.json` is the legacy location, still read
830
- * for compatibility (and migrated into `.opencode/` by `opencode-rag init`);
830
+ * for compatibility (and migrated into `.opencode/` by `opencode-rag setup`);
831
831
  * `.opencode/rag.json` is a legacy alias inside `.opencode/`.
832
832
  */
833
833
  export declare const CONFIG_FILE_CANDIDATES: string[];
@@ -707,9 +707,9 @@ export function validateConfig(config) {
707
707
  * Config file locations to search, in order of precedence.
708
708
  *
709
709
  * `.opencode/opencode-rag.json` is the canonical workspace location — every
710
- * writer (TUI, `init`, `clickhouse setup`, the Web UI) creates and updates it
710
+ * writer (TUI, `setup`, `clickhouse setup`, the Web UI) creates and updates it
711
711
  * there. The root-level `opencode-rag.json` is the legacy location, still read
712
- * for compatibility (and migrated into `.opencode/` by `opencode-rag init`);
712
+ * for compatibility (and migrated into `.opencode/` by `opencode-rag setup`);
713
713
  * `.opencode/rag.json` is a legacy alias inside `.opencode/`.
714
714
  */
715
715
  export const CONFIG_FILE_CANDIDATES = [
@@ -21,3 +21,5 @@ export declare function getProviderDefault(provider: string): ProviderDefaults |
21
21
  export declare function isOpenAiCompatible(provider: string): boolean;
22
22
  /** Whether the given provider can produce embeddings. */
23
23
  export declare function supportsEmbedding(provider: string): boolean;
24
+ /** Whether the given provider can serve chat/completion requests. */
25
+ export declare function supportsChat(provider: string): boolean;
@@ -103,4 +103,8 @@ export function isOpenAiCompatible(provider) {
103
103
  export function supportsEmbedding(provider) {
104
104
  return PROVIDER_DEFAULTS[provider]?.supportsEmbedding ?? false;
105
105
  }
106
+ /** Whether the given provider can serve chat/completion requests. */
107
+ export function supportsChat(provider) {
108
+ return PROVIDER_DEFAULTS[provider]?.supportsChat ?? false;
109
+ }
106
110
  //# sourceMappingURL=provider-defaults.js.map
@@ -43,7 +43,7 @@ const INCLUDE_EXTS = new Set([".ts", ".tsx"]);
43
43
  const CHANGED_FILES = new Set([
44
44
  "src/api.ts",
45
45
  "src/chunker/pdf.ts",
46
- "src/cli/commands/init-helpers.ts",
46
+ "src/cli/commands/workspace-helpers.ts",
47
47
  "src/core/config.ts",
48
48
  "src/core/interfaces.ts",
49
49
  "src/core/manifest.ts",
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Single source of truth for the mandatory OpenCodeRAG tool-usage guidance
3
3
  * that is injected into both the runtime system prompt (via plugin.ts) and the AGENTS.md
4
- * directive (via init-helpers.ts).
4
+ * directive (via workspace-helpers.ts).
5
5
  */
6
6
  import type { OpenCodeShellConfig } from "../core/config.js";
7
7
  /** Sentinel marker that opens the managed section. */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Single source of truth for the mandatory OpenCodeRAG tool-usage guidance
3
3
  * that is injected into both the runtime system prompt (via plugin.ts) and the AGENTS.md
4
- * directive (via init-helpers.ts).
4
+ * directive (via workspace-helpers.ts).
5
5
  */
6
6
  /** Sentinel marker that opens the managed section. */
7
7
  export const BEGIN_MARKER = "<!-- BEGIN opencode-rag -->";
package/dist/tui.d.ts CHANGED
@@ -82,6 +82,17 @@ type V2TuiContext = {
82
82
  id: string;
83
83
  title?: string;
84
84
  bind?: string;
85
+ /**
86
+ * Adds the command to prompt slash completion (`KeymapCommand.slash`
87
+ * in `@opencode/plugin/tui`). The name has no leading slash; a command
88
+ * needs a stable `id` to be slash-addressable.
89
+ */
90
+ slash?: {
91
+ name: string;
92
+ aliases?: string[];
93
+ /** Keeps the slash command in the prompt and passes its raw input to run. */
94
+ arguments?: true;
95
+ };
85
96
  run: (input?: string) => void;
86
97
  }[];
87
98
  bindings: readonly string[];
package/dist/tui.js CHANGED
@@ -162,6 +162,15 @@ function formatKeybinding(key) {
162
162
  * Kitty keyboard protocol is negotiated. Exactly one chord is bound.
163
163
  */
164
164
  const DEFAULT_SETTINGS_KEYBINDING = "alt+s";
165
+ /**
166
+ * Prompt slash name for the settings dialog (no leading slash — the host adds
167
+ * it). A slash path matters because key delivery is terminal-dependent: VTE
168
+ * collapses `ctrl+shift+<letter>` to the plain control byte and VS Code's
169
+ * xterm sends nothing until the Kitty keyboard protocol is negotiated, while
170
+ * text input works everywhere. `tui.settingsKeybinding` stays the shortcut;
171
+ * this is the fallback that is also discoverable from `/` completion.
172
+ */
173
+ const SETTINGS_SLASH_NAME = "rag-settings";
165
174
  const PLUGIN_NAME = "opencode-rag-plugin";
166
175
  /**
167
176
  * Create a TUI element node with the given tag, props, and children.
@@ -243,7 +252,7 @@ function renderSidebar(theme, version, status, tuiConfig, tokenStats) {
243
252
  text({ fg: theme.textMuted }, [timeLine]),
244
253
  text({ fg: watcher.running ? theme.accent : watcherStale ? theme.text : theme.textMuted }, [watcherLine]),
245
254
  ...(watcherDetail ? [text({ fg: theme.textMuted }, [watcherDetail])] : []),
246
- text({ fg: theme.textMuted }, [`${formatKeybinding(settingsKey)} → Settings`]),
255
+ text({ fg: theme.textMuted }, [`${formatKeybinding(settingsKey)} / /${SETTINGS_SLASH_NAME} → Settings`]),
247
256
  text({ fg: theme.textMuted }, [`${formatKeybinding(fileListKey)} → Add File List`]),
248
257
  text({ fg: theme.textMuted }, [`${formatKeybinding(chunksKey)} → Add Chunks`]),
249
258
  ...(tokenStats && tokenStats.queries > 0 ? [
@@ -1000,6 +1009,8 @@ async function setup(context) {
1000
1009
  id: "opencode-rag:settings",
1001
1010
  title: "OpenCodeRAG Settings",
1002
1011
  bind: v2Bind(settingsKey),
1012
+ // Also in prompt slash completion: `/rag-settings` (alias `/rag`).
1013
+ slash: { name: SETTINGS_SLASH_NAME, aliases: ["rag"] },
1003
1014
  run: () => {
1004
1015
  if (worktree) {
1005
1016
  void openSettingsDialogV2(context, worktree, v2LegacyProviders(context), () => refreshStatus());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-rag-plugin",
3
- "version": "2.11.2",
3
+ "version": "2.12.0",
4
4
  "description": "OpenCode plugin for local-first RAG-based semantic code search",
5
5
  "type": "module",
6
6
  "main": "./dist/plugin-entry.js",
@@ -1,51 +0,0 @@
1
- /**
2
- * @fileoverview Init command for configuring a workspace with OpenCodeRAG (directory structure, plugin files, config, health checks).
3
- */
4
- /**
5
- * `init` command — configures a workspace for OpenCodeRAG.
6
- *
7
- * Creates the `.opencode/` directory structure, plugin entry files,
8
- * workspace package.json, opencode config, skill file, and runtime
9
- * configuration. Also handles provider health checks and dependency
10
- * installation.
11
- */
12
- import type { Command } from "commander";
13
- import type { InitOptions } from "../types.js";
14
- /**
15
- * Register the `init` command on the given Commander program.
16
- *
17
- * Creates the full `.opencode/` workspace structure, plugin entries,
18
- * skill file, and `opencode-rag.json` config. Optionally runs provider
19
- * health checks and installs workspace-local npm dependencies.
20
- *
21
- * @param program - The Commander `Command` instance to register on.
22
- */
23
- export declare function registerInitCommand(program: Command): void;
24
- /**
25
- * Run the full workspace initialization: `.opencode/` directory structure,
26
- * plugin entry files, `opencode-rag.json`, skill file, AGENTS.md guidance,
27
- * provider health checks, and plugin linking from the global runtime cache.
28
- *
29
- * Shared between the `init` command and the automatic workspace step of
30
- * `opencode-rag setup`.
31
- *
32
- * @param options - init options (force, skipInstall, skipHealthCheck).
33
- */
34
- export declare function runWorkspaceInit(options?: InitOptions): Promise<void>;
35
- /**
36
- * Best-effort check whether `cwd` looks like a project root (git repo or
37
- * common project manifest files). `opencode-rag setup` uses this to decide
38
- * whether to automatically initialize the current workspace.
39
- *
40
- * @param cwd - Directory to inspect.
41
- * @returns Whether the directory looks like a project root.
42
- */
43
- export declare function isLikelyProjectRoot(cwd: string): boolean;
44
- /**
45
- * Check whether the workspace at `cwd` has already been initialized with
46
- * OpenCodeRAG (plugin entry files and the TUI plugin config are present).
47
- *
48
- * @param cwd - Directory to inspect.
49
- * @returns Whether the workspace looks initialized.
50
- */
51
- export declare function isWorkspaceInitialized(cwd: string): boolean;