opencode-rag-plugin 1.12.17 → 1.14.6

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 (335) hide show
  1. package/ReadMe.md +15 -13
  2. package/dist/api.d.ts +54 -2
  3. package/dist/api.js +41 -1
  4. package/dist/api.js.map +1 -1
  5. package/dist/chunker/base.js +2 -0
  6. package/dist/chunker/base.js.map +1 -1
  7. package/dist/chunker/bash.d.ts +5 -0
  8. package/dist/chunker/bash.js +5 -0
  9. package/dist/chunker/bash.js.map +1 -1
  10. package/dist/chunker/c.d.ts +6 -0
  11. package/dist/chunker/c.js +6 -0
  12. package/dist/chunker/c.js.map +1 -1
  13. package/dist/chunker/cpp.d.ts +6 -0
  14. package/dist/chunker/cpp.js +6 -0
  15. package/dist/chunker/cpp.js.map +1 -1
  16. package/dist/chunker/csharp.d.ts +6 -0
  17. package/dist/chunker/csharp.js +6 -0
  18. package/dist/chunker/csharp.js.map +1 -1
  19. package/dist/chunker/css.d.ts +6 -0
  20. package/dist/chunker/css.js +6 -0
  21. package/dist/chunker/css.js.map +1 -1
  22. package/dist/chunker/doc.d.ts +18 -0
  23. package/dist/chunker/doc.js +18 -0
  24. package/dist/chunker/doc.js.map +1 -1
  25. package/dist/chunker/dockerfile.d.ts +6 -0
  26. package/dist/chunker/dockerfile.js +6 -0
  27. package/dist/chunker/dockerfile.js.map +1 -1
  28. package/dist/chunker/docx.d.ts +18 -0
  29. package/dist/chunker/docx.js +18 -0
  30. package/dist/chunker/docx.js.map +1 -1
  31. package/dist/chunker/excel.d.ts +19 -0
  32. package/dist/chunker/excel.js +19 -0
  33. package/dist/chunker/excel.js.map +1 -1
  34. package/dist/chunker/go.d.ts +5 -0
  35. package/dist/chunker/go.js +5 -0
  36. package/dist/chunker/go.js.map +1 -1
  37. package/dist/chunker/grammar.d.ts +62 -0
  38. package/dist/chunker/grammar.js +133 -0
  39. package/dist/chunker/grammar.js.map +1 -1
  40. package/dist/chunker/html.d.ts +5 -0
  41. package/dist/chunker/html.js +5 -0
  42. package/dist/chunker/html.js.map +1 -1
  43. package/dist/chunker/image.d.ts +31 -0
  44. package/dist/chunker/image.js +50 -4
  45. package/dist/chunker/image.js.map +1 -1
  46. package/dist/chunker/ini.d.ts +5 -0
  47. package/dist/chunker/ini.js +5 -0
  48. package/dist/chunker/ini.js.map +1 -1
  49. package/dist/chunker/java.d.ts +5 -0
  50. package/dist/chunker/java.js +5 -0
  51. package/dist/chunker/java.js.map +1 -1
  52. package/dist/chunker/javascript.d.ts +6 -0
  53. package/dist/chunker/javascript.js +6 -0
  54. package/dist/chunker/javascript.js.map +1 -1
  55. package/dist/chunker/json.d.ts +5 -0
  56. package/dist/chunker/json.js +5 -0
  57. package/dist/chunker/json.js.map +1 -1
  58. package/dist/chunker/kotlin.d.ts +6 -0
  59. package/dist/chunker/kotlin.js +6 -0
  60. package/dist/chunker/kotlin.js.map +1 -1
  61. package/dist/chunker/loader.d.ts +11 -0
  62. package/dist/chunker/loader.js +20 -0
  63. package/dist/chunker/loader.js.map +1 -1
  64. package/dist/chunker/markdown.d.ts +5 -0
  65. package/dist/chunker/markdown.js +5 -0
  66. package/dist/chunker/markdown.js.map +1 -1
  67. package/dist/chunker/pdf.d.ts +19 -0
  68. package/dist/chunker/pdf.js +30 -0
  69. package/dist/chunker/pdf.js.map +1 -1
  70. package/dist/chunker/php.d.ts +5 -0
  71. package/dist/chunker/php.js +5 -0
  72. package/dist/chunker/php.js.map +1 -1
  73. package/dist/chunker/powershell.d.ts +5 -0
  74. package/dist/chunker/powershell.js +5 -0
  75. package/dist/chunker/powershell.js.map +1 -1
  76. package/dist/chunker/python.d.ts +5 -0
  77. package/dist/chunker/python.js +5 -0
  78. package/dist/chunker/python.js.map +1 -1
  79. package/dist/chunker/razor.d.ts +12 -0
  80. package/dist/chunker/razor.js +25 -0
  81. package/dist/chunker/razor.js.map +1 -1
  82. package/dist/chunker/ruby.d.ts +5 -0
  83. package/dist/chunker/ruby.js +5 -0
  84. package/dist/chunker/ruby.js.map +1 -1
  85. package/dist/chunker/rust.d.ts +6 -0
  86. package/dist/chunker/rust.js +6 -0
  87. package/dist/chunker/rust.js.map +1 -1
  88. package/dist/chunker/sln.d.ts +11 -0
  89. package/dist/chunker/sln.js +11 -0
  90. package/dist/chunker/sln.js.map +1 -1
  91. package/dist/chunker/sql.d.ts +5 -0
  92. package/dist/chunker/sql.js +5 -0
  93. package/dist/chunker/sql.js.map +1 -1
  94. package/dist/chunker/ssl.d.ts +12 -0
  95. package/dist/chunker/ssl.js +21 -2
  96. package/dist/chunker/ssl.js.map +1 -1
  97. package/dist/chunker/swift.d.ts +5 -0
  98. package/dist/chunker/swift.js +5 -0
  99. package/dist/chunker/swift.js.map +1 -1
  100. package/dist/chunker/tex.d.ts +12 -0
  101. package/dist/chunker/tex.js +12 -0
  102. package/dist/chunker/tex.js.map +1 -1
  103. package/dist/chunker/toml.d.ts +5 -0
  104. package/dist/chunker/toml.js +5 -0
  105. package/dist/chunker/toml.js.map +1 -1
  106. package/dist/chunker/typescript.d.ts +6 -0
  107. package/dist/chunker/typescript.js +6 -0
  108. package/dist/chunker/typescript.js.map +1 -1
  109. package/dist/chunker/xml.d.ts +5 -0
  110. package/dist/chunker/xml.js +5 -0
  111. package/dist/chunker/xml.js.map +1 -1
  112. package/dist/chunker/yaml.d.ts +5 -0
  113. package/dist/chunker/yaml.js +5 -0
  114. package/dist/chunker/yaml.js.map +1 -1
  115. package/dist/cli/commands/clear.d.ts +12 -0
  116. package/dist/cli/commands/clear.js +81 -0
  117. package/dist/cli/commands/clear.js.map +1 -0
  118. package/dist/cli/commands/describe-image.d.ts +14 -0
  119. package/dist/cli/commands/describe-image.js +68 -0
  120. package/dist/cli/commands/describe-image.js.map +1 -0
  121. package/dist/cli/commands/dump.d.ts +13 -0
  122. package/dist/cli/commands/dump.js +55 -0
  123. package/dist/cli/commands/dump.js.map +1 -0
  124. package/dist/cli/commands/eval.d.ts +32 -0
  125. package/dist/cli/commands/eval.js +158 -0
  126. package/dist/cli/commands/eval.js.map +1 -0
  127. package/dist/cli/commands/index-command.d.ts +17 -0
  128. package/dist/cli/commands/index-command.js +167 -0
  129. package/dist/cli/commands/index-command.js.map +1 -0
  130. package/dist/cli/commands/index.d.ts +16 -0
  131. package/dist/cli/commands/index.js +17 -0
  132. package/dist/cli/commands/index.js.map +1 -0
  133. package/dist/cli/commands/init-helpers.d.ts +101 -0
  134. package/dist/cli/commands/init-helpers.js +397 -0
  135. package/dist/cli/commands/init-helpers.js.map +1 -0
  136. package/dist/cli/commands/init.d.ts +19 -0
  137. package/dist/cli/commands/init.js +251 -0
  138. package/dist/cli/commands/init.js.map +1 -0
  139. package/dist/cli/commands/list.d.ts +13 -0
  140. package/dist/cli/commands/list.js +46 -0
  141. package/dist/cli/commands/list.js.map +1 -0
  142. package/dist/cli/commands/mcp.d.ts +14 -0
  143. package/dist/cli/commands/mcp.js +35 -0
  144. package/dist/cli/commands/mcp.js.map +1 -0
  145. package/dist/cli/commands/query.d.ts +14 -0
  146. package/dist/cli/commands/query.js +86 -0
  147. package/dist/cli/commands/query.js.map +1 -0
  148. package/dist/cli/commands/show.d.ts +13 -0
  149. package/dist/cli/commands/show.js +51 -0
  150. package/dist/cli/commands/show.js.map +1 -0
  151. package/dist/cli/commands/status.d.ts +14 -0
  152. package/dist/cli/commands/status.js +104 -0
  153. package/dist/cli/commands/status.js.map +1 -0
  154. package/dist/cli/commands/ui.d.ts +14 -0
  155. package/dist/cli/commands/ui.js +69 -0
  156. package/dist/cli/commands/ui.js.map +1 -0
  157. package/dist/cli/commands/update.d.ts +14 -0
  158. package/dist/cli/commands/update.js +76 -0
  159. package/dist/cli/commands/update.js.map +1 -0
  160. package/dist/cli/format.d.ts +112 -0
  161. package/dist/cli/format.js +184 -0
  162. package/dist/cli/format.js.map +1 -0
  163. package/dist/cli/helpers.d.ts +51 -0
  164. package/dist/cli/helpers.js +86 -0
  165. package/dist/cli/helpers.js.map +1 -0
  166. package/dist/cli/index.d.ts +28 -0
  167. package/dist/cli/index.js +104 -0
  168. package/dist/cli/index.js.map +1 -0
  169. package/dist/cli/progress.d.ts +39 -0
  170. package/dist/cli/progress.js +137 -0
  171. package/dist/cli/progress.js.map +1 -0
  172. package/dist/cli/types.d.ts +40 -0
  173. package/dist/cli/types.js +3 -0
  174. package/dist/cli/types.js.map +1 -0
  175. package/dist/cli.d.ts +11 -4
  176. package/dist/cli.js +9 -1253
  177. package/dist/cli.js.map +1 -1
  178. package/dist/content/doc.d.ts +1 -1
  179. package/dist/content/doc.js +1 -1
  180. package/dist/content/doc.js.map +1 -1
  181. package/dist/content/docx.d.ts +1 -1
  182. package/dist/content/docx.js +1 -1
  183. package/dist/content/docx.js.map +1 -1
  184. package/dist/content/excel.d.ts +1 -1
  185. package/dist/content/excel.js +1 -1
  186. package/dist/content/excel.js.map +1 -1
  187. package/dist/content/pdf.d.ts +1 -1
  188. package/dist/content/pdf.js +1 -1
  189. package/dist/content/pdf.js.map +1 -1
  190. package/dist/content/reader.d.ts +3 -1
  191. package/dist/content/reader.js +42 -10
  192. package/dist/content/reader.js.map +1 -1
  193. package/dist/core/bootstrap.d.ts +18 -0
  194. package/dist/core/bootstrap.js +9 -15
  195. package/dist/core/bootstrap.js.map +1 -1
  196. package/dist/core/config.d.ts +144 -0
  197. package/dist/core/config.js +65 -14
  198. package/dist/core/config.js.map +1 -1
  199. package/dist/core/doc-progress.d.ts +15 -0
  200. package/dist/core/doc-progress.js +61 -0
  201. package/dist/core/doc-progress.js.map +1 -0
  202. package/dist/core/fileLogger.d.ts +7 -0
  203. package/dist/core/fileLogger.js +2 -0
  204. package/dist/core/fileLogger.js.map +1 -1
  205. package/dist/core/interfaces.d.ts +52 -1
  206. package/dist/core/manifest.d.ts +25 -0
  207. package/dist/core/manifest.js +15 -1
  208. package/dist/core/manifest.js.map +1 -1
  209. package/dist/core/provider-defaults.d.ts +8 -0
  210. package/dist/core/provider-defaults.js +3 -0
  211. package/dist/core/provider-defaults.js.map +1 -1
  212. package/dist/core/rag-injection-flag.d.ts +3 -0
  213. package/dist/core/rag-injection-flag.js +2 -0
  214. package/dist/core/rag-injection-flag.js.map +1 -1
  215. package/dist/core/resolve-api-key.d.ts +1 -0
  216. package/dist/core/resolve-api-key.js +1 -0
  217. package/dist/core/resolve-api-key.js.map +1 -1
  218. package/dist/core/runtime-overrides.d.ts +4 -0
  219. package/dist/core/runtime-overrides.js +4 -1
  220. package/dist/core/runtime-overrides.js.map +1 -1
  221. package/dist/describer/anthropic.d.ts +22 -2
  222. package/dist/describer/anthropic.js +42 -110
  223. package/dist/describer/anthropic.js.map +1 -1
  224. package/dist/describer/describer.d.ts +21 -4
  225. package/dist/describer/describer.js +52 -111
  226. package/dist/describer/describer.js.map +1 -1
  227. package/dist/describer/gemini.d.ts +1 -2
  228. package/dist/describer/gemini.js +20 -113
  229. package/dist/describer/gemini.js.map +1 -1
  230. package/dist/describer/shared.d.ts +3 -0
  231. package/dist/describer/shared.js +19 -0
  232. package/dist/describer/shared.js.map +1 -0
  233. package/dist/embedder/factory.d.ts +25 -0
  234. package/dist/embedder/factory.js +25 -0
  235. package/dist/embedder/factory.js.map +1 -1
  236. package/dist/embedder/health.d.ts +10 -0
  237. package/dist/embedder/health.js +26 -14
  238. package/dist/embedder/health.js.map +1 -1
  239. package/dist/embedder/http.d.ts +47 -0
  240. package/dist/embedder/http.js +61 -3
  241. package/dist/embedder/http.js.map +1 -1
  242. package/dist/eval/index.d.ts +6 -0
  243. package/dist/eval/index.js.map +1 -1
  244. package/dist/eval/run-token-test.js +1 -5
  245. package/dist/eval/run-token-test.js.map +1 -1
  246. package/dist/eval/session-logger.d.ts +5 -0
  247. package/dist/eval/session-logger.js +4 -0
  248. package/dist/eval/session-logger.js.map +1 -1
  249. package/dist/eval/storage.d.ts +9 -0
  250. package/dist/eval/storage.js +9 -5
  251. package/dist/eval/storage.js.map +1 -1
  252. package/dist/eval/token-analysis.d.ts +8 -0
  253. package/dist/eval/token-analysis.js +6 -2
  254. package/dist/eval/token-analysis.js.map +1 -1
  255. package/dist/eval/token-counter.d.ts +1 -3
  256. package/dist/eval/token-counter.js +4 -5
  257. package/dist/eval/token-counter.js.map +1 -1
  258. package/dist/eval/types.d.ts +6 -0
  259. package/dist/eval/types.js +2 -0
  260. package/dist/eval/types.js.map +1 -1
  261. package/dist/index.d.ts +11 -0
  262. package/dist/index.js +12 -3
  263. package/dist/index.js.map +1 -1
  264. package/dist/indexer/description-stage.js +11 -2
  265. package/dist/indexer/description-stage.js.map +1 -1
  266. package/dist/indexer/embed-stage.js +0 -8
  267. package/dist/indexer/embed-stage.js.map +1 -1
  268. package/dist/indexer/pipeline.d.ts +27 -3
  269. package/dist/indexer/pipeline.js +314 -143
  270. package/dist/indexer/pipeline.js.map +1 -1
  271. package/dist/indexer/stats.d.ts +35 -0
  272. package/dist/indexer/stats.js +9 -0
  273. package/dist/indexer/stats.js.map +1 -1
  274. package/dist/indexer/watch.d.ts +25 -0
  275. package/dist/indexer/watch.js +21 -0
  276. package/dist/indexer/watch.js.map +1 -1
  277. package/dist/indexer/worker.d.ts +90 -2
  278. package/dist/indexer/worker.js +109 -24
  279. package/dist/indexer/worker.js.map +1 -1
  280. package/dist/indexer.d.ts +11 -1
  281. package/dist/indexer.js +9 -0
  282. package/dist/indexer.js.map +1 -1
  283. package/dist/mcp/cli.d.ts +3 -0
  284. package/dist/mcp/cli.js +1 -0
  285. package/dist/mcp/cli.js.map +1 -1
  286. package/dist/mcp/handlers.d.ts +41 -0
  287. package/dist/mcp/handlers.js +40 -1
  288. package/dist/mcp/handlers.js.map +1 -1
  289. package/dist/mcp/server.d.ts +8 -0
  290. package/dist/mcp/server.js +18 -1
  291. package/dist/mcp/server.js.map +1 -1
  292. package/dist/opencode/create-read-tool.js +1 -0
  293. package/dist/opencode/create-read-tool.js.map +1 -1
  294. package/dist/opencode/tools.d.ts +8 -17
  295. package/dist/opencode/tools.js +74 -109
  296. package/dist/opencode/tools.js.map +1 -1
  297. package/dist/plugin-entry.d.ts +6 -0
  298. package/dist/plugin-entry.js +6 -0
  299. package/dist/plugin-entry.js.map +1 -1
  300. package/dist/plugin.d.ts +37 -0
  301. package/dist/plugin.js +265 -40
  302. package/dist/plugin.js.map +1 -1
  303. package/dist/retriever/keyword-index.js +9 -9
  304. package/dist/retriever/keyword-index.js.map +1 -1
  305. package/dist/retriever/retriever.js +14 -4
  306. package/dist/retriever/retriever.js.map +1 -1
  307. package/dist/tui.d.ts +5 -0
  308. package/dist/tui.js +100 -12
  309. package/dist/tui.js.map +1 -1
  310. package/dist/types/opencode-plugin.d.ts +4 -1
  311. package/dist/updater.d.ts +23 -1
  312. package/dist/updater.js +55 -16
  313. package/dist/updater.js.map +1 -1
  314. package/dist/vectorstore/factory.d.ts +13 -0
  315. package/dist/vectorstore/factory.js +13 -0
  316. package/dist/vectorstore/factory.js.map +1 -1
  317. package/dist/vectorstore/lancedb.d.ts +78 -1
  318. package/dist/vectorstore/lancedb.js +195 -21
  319. package/dist/vectorstore/lancedb.js.map +1 -1
  320. package/dist/vectorstore/memory.d.ts +5 -0
  321. package/dist/vectorstore/memory.js +11 -0
  322. package/dist/vectorstore/memory.js.map +1 -1
  323. package/dist/watcher.d.ts +24 -0
  324. package/dist/watcher.js +17 -35
  325. package/dist/watcher.js.map +1 -1
  326. package/dist/web/api.d.ts +37 -0
  327. package/dist/web/api.js +54 -0
  328. package/dist/web/api.js.map +1 -1
  329. package/dist/web/server.d.ts +15 -0
  330. package/dist/web/server.js +14 -0
  331. package/dist/web/server.js.map +1 -1
  332. package/dist/web/static.d.ts +8 -0
  333. package/dist/web/static.js +8 -0
  334. package/dist/web/static.js.map +1 -1
  335. package/package.json +11 -15
@@ -0,0 +1,397 @@
1
+ /**
2
+ * Helper functions for the `init` command — file generation, config building,
3
+ * dependency installation, and gitignore merging.
4
+ */
5
+ import path from "node:path";
6
+ import os from "node:os";
7
+ import { existsSync, mkdirSync, rmSync, symlinkSync, } from "node:fs";
8
+ import { DEFAULT_CONFIG } from "../../core/config.js";
9
+ import { c } from "../format.js";
10
+ import { getStringRecord, readJsonObject, writeJsonFile, } from "../helpers.js";
11
+ /**
12
+ * Build the workspace-local `.opencode/package.json` content.
13
+ *
14
+ * Only declares `@opencode-ai/plugin` as a dependency — the RAG plugin
15
+ * itself is extracted directly into `node_modules/` by `installPluginFromGlobal`.
16
+ *
17
+ * @param existing - The existing package.json content (if any).
18
+ * @param packageMetadata - The CLI package's metadata for version resolution.
19
+ * @returns The merged package.json object.
20
+ */
21
+ export function buildWorkspacePackageJson(existing, packageMetadata) {
22
+ const existingDependencies = getStringRecord(existing?.dependencies);
23
+ const pluginVersion = existingDependencies["@opencode-ai/plugin"] ??
24
+ packageMetadata.devDependencies?.["@opencode-ai/plugin"] ??
25
+ packageMetadata.peerDependencies?.["@opencode-ai/plugin"] ??
26
+ ">=1.0.0";
27
+ const deps = {};
28
+ // Preserve any existing deps that are NOT the RAG plugin (it's extracted directly)
29
+ for (const [name, version] of Object.entries(existingDependencies)) {
30
+ if (name !== packageMetadata.name) {
31
+ deps[name] = version;
32
+ }
33
+ }
34
+ // Ensure @opencode-ai/plugin is always present
35
+ deps["@opencode-ai/plugin"] = pluginVersion;
36
+ return {
37
+ ...existing,
38
+ name: typeof existing?.name === "string" ? existing.name : ".opencode",
39
+ private: true,
40
+ type: "module",
41
+ dependencies: deps,
42
+ };
43
+ }
44
+ /**
45
+ * Build the `.opencode/opencode.json` config object.
46
+ *
47
+ * Ensures the `$schema` key is present and removes any stale `plugin`
48
+ * entries that would trigger erroneous npm installs.
49
+ *
50
+ * @param existing - The existing opencode.json content (if any).
51
+ * @returns The normalized config object.
52
+ */
53
+ export function buildOpencodeConfig(existing) {
54
+ const next = { ...(existing ?? {}) };
55
+ if (typeof next.$schema !== "string") {
56
+ next.$schema = "https://opencode.ai/config.json";
57
+ }
58
+ // Plugin is loaded via .opencode/plugins/rag-plugin.js auto-discovery,
59
+ // not via npm package resolution. Stale "plugin" entries from older
60
+ // init versions would trigger npm install (which fails due to native
61
+ // dependencies like canvas) and produce "Plugin export is not a function".
62
+ delete next.plugin;
63
+ return next;
64
+ }
65
+ /**
66
+ * Remove stale global OpenCode plugin registrations from config files.
67
+ *
68
+ * Scans `~/.config/opencode/opencode.jsonc` and `opencode.json` for
69
+ * plugin entries matching `pluginName` and removes them.
70
+ *
71
+ * @param homeDir - The user's home directory (typically `os.homedir()`).
72
+ * @param pluginName - The plugin package name to remove.
73
+ * @returns Array of config file paths that were modified.
74
+ */
75
+ export function removeStaleGlobalPluginRegistrations(homeDir, pluginName) {
76
+ const globalConfigDir = path.join(homeDir, ".config", "opencode");
77
+ const updatedPaths = [];
78
+ for (const cfgFile of ["opencode.jsonc", "opencode.json"]) {
79
+ const configPath = path.join(globalConfigDir, cfgFile);
80
+ if (!existsSync(configPath)) {
81
+ continue;
82
+ }
83
+ try {
84
+ const cfg = readJsonObject(configPath);
85
+ if (!cfg || !Array.isArray(cfg.plugin)) {
86
+ continue;
87
+ }
88
+ const nextPlugins = cfg.plugin.filter((entry) => typeof entry === "string" && entry !== pluginName);
89
+ if (nextPlugins.length === cfg.plugin.length) {
90
+ continue;
91
+ }
92
+ if (nextPlugins.length > 0) {
93
+ cfg.plugin = nextPlugins;
94
+ }
95
+ else {
96
+ delete cfg.plugin;
97
+ }
98
+ writeJsonFile(configPath, cfg);
99
+ updatedPaths.push(configPath);
100
+ }
101
+ catch {
102
+ // Ignore malformed OpenCode config files and leave them unchanged.
103
+ }
104
+ }
105
+ return updatedPaths;
106
+ }
107
+ /**
108
+ * Generate the content for `.opencode/plugins/rag-plugin.js`.
109
+ *
110
+ * This file re-exports the plugin from the workspace-local node_modules.
111
+ *
112
+ * @param packageName - The npm package name of the RAG plugin.
113
+ * @returns The JavaScript source code for the plugin entry file.
114
+ */
115
+ export function generateWorkspacePluginFile(packageName) {
116
+ return [
117
+ `import plugin from "../node_modules/${packageName}/dist/plugin-entry.js";`,
118
+ `export const id = plugin.id;`,
119
+ `export const server = plugin.server;`,
120
+ `export default plugin;`,
121
+ "",
122
+ ].join("\n");
123
+ }
124
+ /**
125
+ * Generate the content for `.opencode/plugins/rag-tui.js`.
126
+ *
127
+ * This file re-exports the TUI plugin from the workspace-local node_modules.
128
+ *
129
+ * @param packageName - The npm package name of the RAG plugin.
130
+ * @returns The JavaScript source code for the TUI plugin entry file.
131
+ */
132
+ export function generateWorkspaceTuiPluginFile(packageName) {
133
+ return [
134
+ `import plugin from "../node_modules/${packageName}/dist/tui.js";`,
135
+ `export default plugin;`,
136
+ "",
137
+ ].join("\n");
138
+ }
139
+ /**
140
+ * Generate the content for `.opencode/skills/opencode-rag/SKILL.md`.
141
+ *
142
+ * This file provides tool usage guidance for AI assistants working in the workspace.
143
+ *
144
+ * @returns The full Markdown content of the skill file.
145
+ */
146
+ export function generateSkillFile() {
147
+ return [
148
+ "---",
149
+ "name: opencode-rag",
150
+ "description: Semantic code & image retrieval via OpenCodeRAG — vector search, file skeletons, symbol usage lookup, and image description lookup for this workspace",
151
+ "---",
152
+ "",
153
+ "## OpenCodeRAG Tools",
154
+ "",
155
+ "This workspace has OpenCodeRAG indexed for semantic code and image search. Use these tools BEFORE planning, editing, or answering code questions.",
156
+ "",
157
+ "### Decision tree — ALWAYS follow this order",
158
+ "",
159
+ "1. User mentions code behavior/architecture → `search_semantic(query)`",
160
+ "2. User mentions a file path → `get_file_skeleton(filePath)` THEN `read` on specific lines",
161
+ "3. User mentions a function/class/variable to edit → `find_usages(symbolName)` THEN `search_semantic` THEN `edit`",
162
+ "4. User asks a code question → `search_semantic` to gather context before answering",
163
+ "5. User asks about an image or visual asset → `describe_image(filePath)` to retrieve its generated description, then optionally `search_semantic` for related code",
164
+ "",
165
+ "### When to use each tool",
166
+ "",
167
+ "| Tool | Use when | Example |",
168
+ "|------|----------|---------|",
169
+ "| `search_semantic` | Any code search — find relevant code by meaning or keyword | `\"authentication middleware\"` |",
170
+ "| `get_file_skeleton` | You have a file path but need to orient before reading | `\"src/plugin.ts\"` |",
171
+ "| `find_usages` | Before editing any function, class, or variable — check all call sites | `\"createRagHooks\"` |",
172
+ "| `describe_image` | When the user refers to an image or asks \"what's in this screenshot/diagram?\" | `\"assets/login-screen.png\"` |",
173
+ "",
174
+ "### Workflow",
175
+ "",
176
+ "1. **Skeleton first** — call `get_file_skeleton(filePath)` to see structure",
177
+ "2. **Find usages** — call `find_usages(symbolName)` before modifying any symbol",
178
+ "3. **Search** — call `search_semantic(query)` to find relevant code",
179
+ "4. **Describe images** — call `describe_image(filePath)` when context involves an image file",
180
+ "5. **Read** — use the `read` tool on specific line ranges identified above",
181
+ "6. **Edit** — now you have full context to make safe changes",
182
+ "",
183
+ "### Anti-patterns — NEVER do these",
184
+ "",
185
+ "- Reading full files without calling `get_file_skeleton` first (wastes tokens)",
186
+ "- Editing a function without calling `find_usages` first (breaks call sites)",
187
+ "- Answering code questions without calling `search_semantic` first (you guess at behavior)",
188
+ "- Using `grep`/`glob` when `search_semantic` would find the answer faster",
189
+ "- Treating image files as text — use `describe_image` instead of reading raw bytes",
190
+ "",
191
+ "### Parameters",
192
+ "",
193
+ "- `search_semantic`: `query` (req), `pathHints?`, `languageHints?`, `topK?`",
194
+ "- `get_file_skeleton`: `filePath` (req)",
195
+ "- `find_usages`: `symbolName` (req), `pathHint?`, `topK?`",
196
+ "- `describe_image`: `filePath` (req)",
197
+ "",
198
+ "### Tips",
199
+ "",
200
+ "- Use `pathHints` to narrow searches to specific directories",
201
+ "- Use `languageHints` to filter by file type",
202
+ "- `find_usages` is essential before refactoring — it shows every reference",
203
+ "- If no results appear, the workspace may not be indexed yet — run `opencode-rag index`",
204
+ "- Image descriptions are generated at index time using the configured vision provider; ensure `imageDescription` is configured in `opencode-rag.json` if your project includes images",
205
+ "",
206
+ ].join("\n");
207
+ }
208
+ /**
209
+ * Merge required entries into an existing `.gitignore` content string.
210
+ *
211
+ * Ensures `node_modules/`, `package-lock.json`, `rag_db/`, and `opencode-rag.log`
212
+ * are present. If no existing content is provided, generates a complete file.
213
+ *
214
+ * @param existingContent - The current `.gitignore` content, or `undefined` if absent.
215
+ * @returns The merged `.gitignore` content with a trailing newline.
216
+ */
217
+ export function mergeGitignoreContent(existingContent) {
218
+ const lines = existingContent ? existingContent.split(/\r?\n/) : [];
219
+ const trimmed = new Set(lines.map((line) => line.trim()));
220
+ const requiredEntries = ["node_modules/", "package-lock.json", "rag_db/", "opencode-rag.log"];
221
+ const missing = requiredEntries.filter((entry) => !trimmed.has(entry));
222
+ if (!existingContent) {
223
+ return [
224
+ "# Ignore workspace-local plugin dependencies",
225
+ "node_modules/",
226
+ "package-lock.json",
227
+ "",
228
+ "# Ignore the LanceDB vector store (binary data)",
229
+ "rag_db/",
230
+ "",
231
+ "# Ignore logs",
232
+ "opencode-rag.log",
233
+ "",
234
+ ].join("\n");
235
+ }
236
+ if (missing.length === 0) {
237
+ return existingContent.endsWith("\n") ? existingContent : `${existingContent}\n`;
238
+ }
239
+ const merged = [...lines];
240
+ const lastLine = merged.length > 0 ? (merged[merged.length - 1] ?? "") : "";
241
+ if (lastLine.trim().length > 0) {
242
+ merged.push("");
243
+ }
244
+ merged.push("# OpenCodeRAG workspace state", ...missing, "");
245
+ return merged.join("\n");
246
+ }
247
+ /**
248
+ * Get the runtime directory path (`~/.opencode`).
249
+ *
250
+ * @returns The absolute path to the user's OpenCode runtime directory.
251
+ */
252
+ export function getRuntimeDir() {
253
+ return path.join(os.homedir(), ".opencode");
254
+ }
255
+ /**
256
+ * Create a directory junction (Windows) or symlink (Linux/macOS) from
257
+ * `linkPath` pointing to `targetPath`.
258
+ *
259
+ * @param targetPath - The existing directory to link to.
260
+ * @param linkPath - The junction/symlink to create (must not exist).
261
+ */
262
+ function createJunction(targetPath, linkPath) {
263
+ const type = process.platform === "win32" ? "junction" : "dir";
264
+ symlinkSync(targetPath, linkPath, type);
265
+ }
266
+ /**
267
+ * Link the precompiled plugin from the global runtime directory
268
+ * (`~/.opencode/node_modules/...`) into the workspace via a junction/symlink,
269
+ * then verify that both the plugin entry and `@opencode-ai/plugin` are
270
+ * resolvable through the junction.
271
+ *
272
+ * No npm install is required — the global runtime (created by the `compile`
273
+ * step) has all dependencies pre-installed, and Node.js resolves module
274
+ * imports through the junction's real path.
275
+ *
276
+ * @param opencodeDir - Absolute path to the workspace `.opencode/` directory.
277
+ * @param packageName - The npm package name of the RAG plugin.
278
+ * @param skipInstall - If true, skip the junction creation.
279
+ * @throws If the global runtime is missing or the junction cannot be created.
280
+ */
281
+ export async function installPluginFromGlobal(opencodeDir, packageName, skipInstall) {
282
+ if (skipInstall) {
283
+ console.log(`\n ${c.exists("Skipped:")} plugin installation (--skip-install)`);
284
+ return;
285
+ }
286
+ const runtimeDir = getRuntimeDir();
287
+ const globalPluginDir = path.join(runtimeDir, "node_modules", packageName);
288
+ const workspaceTarget = path.join(opencodeDir, "node_modules", packageName);
289
+ if (!existsSync(globalPluginDir)) {
290
+ throw new Error(`Global plugin cache not found at ${globalPluginDir}. ` +
291
+ "Run 'install.sh compile' / 'install.ps1 compile' first.");
292
+ }
293
+ // Remove any stale copy (e.g. from a previous 'npm install' run)
294
+ if (existsSync(workspaceTarget)) {
295
+ rmSync(workspaceTarget, { recursive: true, force: true });
296
+ }
297
+ // Create directory junction from workspace → global runtime
298
+ console.log(` ${c.created("Linking:")} ${packageName} from global cache...`);
299
+ mkdirSync(path.dirname(workspaceTarget), { recursive: true });
300
+ createJunction(globalPluginDir, workspaceTarget);
301
+ // Verify the plugin entry resolves through the junction
302
+ const cliEntry = path.join(workspaceTarget, "dist", "cli.js");
303
+ if (!existsSync(cliEntry)) {
304
+ // Junction may not work (e.g. cross-drive on Windows) — fall back to copy
305
+ console.log(` ${c.warn("Junction not supported, falling back to copy...")}`);
306
+ rmSync(workspaceTarget, { recursive: true, force: true });
307
+ const { cpSync } = await import("node:fs");
308
+ mkdirSync(path.dirname(workspaceTarget), { recursive: true });
309
+ cpSync(globalPluginDir, workspaceTarget, { recursive: true });
310
+ }
311
+ // Verify @opencode-ai/plugin is resolvable from the global runtime
312
+ const pluginSdkPkg = path.join(runtimeDir, "node_modules", "@opencode-ai", "plugin", "package.json");
313
+ if (!existsSync(pluginSdkPkg)) {
314
+ throw new Error("@opencode-ai/plugin not found in global runtime. " +
315
+ "Run 'install.sh compile' / 'install.ps1 compile' to install it.");
316
+ }
317
+ }
318
+ /**
319
+ * Generate the default `opencode-rag.json` configuration content.
320
+ *
321
+ * @returns A pretty-printed JSON string with all default configuration values.
322
+ */
323
+ export function generateDefaultConfigJson() {
324
+ return JSON.stringify({
325
+ embedding: {
326
+ provider: DEFAULT_CONFIG.embedding.provider,
327
+ baseUrl: DEFAULT_CONFIG.embedding.baseUrl,
328
+ model: DEFAULT_CONFIG.embedding.model,
329
+ timeoutMs: DEFAULT_CONFIG.embedding.timeoutMs,
330
+ },
331
+ indexing: {
332
+ includeExtensions: DEFAULT_CONFIG.indexing.includeExtensions,
333
+ excludeDirs: DEFAULT_CONFIG.indexing.excludeDirs,
334
+ chunkOverlap: DEFAULT_CONFIG.indexing.chunkOverlap,
335
+ minFileSizeBytes: DEFAULT_CONFIG.indexing.minFileSizeBytes,
336
+ concurrency: DEFAULT_CONFIG.indexing.concurrency,
337
+ embedBatchSize: DEFAULT_CONFIG.indexing.embedBatchSize,
338
+ },
339
+ vectorStore: {
340
+ path: DEFAULT_CONFIG.vectorStore.path,
341
+ },
342
+ retrieval: {
343
+ topK: DEFAULT_CONFIG.retrieval.topK,
344
+ minScore: DEFAULT_CONFIG.retrieval.minScore,
345
+ hybridSearch: {
346
+ enabled: DEFAULT_CONFIG.retrieval.hybridSearch.enabled,
347
+ keywordWeight: DEFAULT_CONFIG.retrieval.hybridSearch.keywordWeight,
348
+ },
349
+ },
350
+ openCode: {
351
+ enabled: DEFAULT_CONFIG.openCode.enabled,
352
+ maxContextChunks: DEFAULT_CONFIG.openCode.maxContextChunks,
353
+ readOverride: DEFAULT_CONFIG.openCode.readOverride,
354
+ autoIndex: {
355
+ enabled: DEFAULT_CONFIG.openCode.autoIndex.enabled,
356
+ debounceMs: DEFAULT_CONFIG.openCode.autoIndex.debounceMs,
357
+ intervalMs: DEFAULT_CONFIG.openCode.autoIndex.intervalMs,
358
+ },
359
+ autoInject: {
360
+ enabled: DEFAULT_CONFIG.openCode.autoInject.enabled,
361
+ minScore: DEFAULT_CONFIG.openCode.autoInject.minScore,
362
+ maxChunks: DEFAULT_CONFIG.openCode.autoInject.maxChunks,
363
+ maxTokens: DEFAULT_CONFIG.openCode.autoInject.maxTokens,
364
+ contentType: DEFAULT_CONFIG.openCode.autoInject.contentType,
365
+ },
366
+ },
367
+ imageDescription: {
368
+ enabled: DEFAULT_CONFIG.imageDescription.enabled,
369
+ provider: DEFAULT_CONFIG.imageDescription.provider,
370
+ model: DEFAULT_CONFIG.imageDescription.model,
371
+ baseUrl: DEFAULT_CONFIG.imageDescription.baseUrl,
372
+ timeoutMs: DEFAULT_CONFIG.imageDescription.timeoutMs,
373
+ think: DEFAULT_CONFIG.imageDescription.think,
374
+ numCtx: DEFAULT_CONFIG.imageDescription.numCtx,
375
+ },
376
+ description: {
377
+ enabled: DEFAULT_CONFIG.description.enabled,
378
+ provider: DEFAULT_CONFIG.description.provider,
379
+ baseUrl: DEFAULT_CONFIG.description.baseUrl,
380
+ model: DEFAULT_CONFIG.description.model,
381
+ think: DEFAULT_CONFIG.description.think,
382
+ numCtx: DEFAULT_CONFIG.description.numCtx,
383
+ timeoutMs: DEFAULT_CONFIG.description.timeoutMs,
384
+ },
385
+ mcp: {
386
+ enabled: DEFAULT_CONFIG.mcp.enabled,
387
+ },
388
+ logging: {
389
+ level: DEFAULT_CONFIG.logging.level,
390
+ logFilePath: DEFAULT_CONFIG.logging.logFilePath,
391
+ },
392
+ chunking: {
393
+ nodeTypes: {},
394
+ },
395
+ }, null, 2) + "\n";
396
+ }
397
+ //# sourceMappingURL=init-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-helpers.js","sourceRoot":"","sources":["../../../src/cli/commands/init-helpers.ts"],"names":[],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,cAAc,CAAC,gBAAiB,CAAC,OAAO;YACjD,SAAS,EAAE,cAAc,CAAC,gBAAiB,CAAC,SAAS;YACrD,KAAK,EAAE,cAAc,CAAC,gBAAiB,CAAC,KAAK;YAC7C,MAAM,EAAE,cAAc,CAAC,gBAAiB,CAAC,MAAM;SAChD;QACD,WAAW,EAAE;YACX,OAAO,EAAE,cAAc,CAAC,WAAY,CAAC,OAAO;YAC5C,QAAQ,EAAE,cAAc,CAAC,WAAY,CAAC,QAAQ;YAC9C,OAAO,EAAE,cAAc,CAAC,WAAY,CAAC,OAAO;YAC5C,KAAK,EAAE,cAAc,CAAC,WAAY,CAAC,KAAK;YACxC,KAAK,EAAE,cAAc,CAAC,WAAY,CAAC,KAAK;YACxC,MAAM,EAAE,cAAc,CAAC,WAAY,CAAC,MAAM;YAC1C,SAAS,EAAE,cAAc,CAAC,WAAY,CAAC,SAAS;SACjD;QACD,GAAG,EAAE;YACH,OAAO,EAAE,cAAc,CAAC,GAAI,CAAC,OAAO;SACrC;QACD,OAAO,EAAE;YACP,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,KAAK;YACnC,WAAW,EAAE,cAAc,CAAC,OAAO,CAAC,WAAW;SAChD;QACD,QAAQ,EAAE;YACR,SAAS,EAAE,EAAE;SACd;KACF,EACD,IAAI,EACJ,CAAC,CACF,GAAG,IAAI,CAAC;AACX,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `init` command — configures a workspace for OpenCodeRAG.
3
+ *
4
+ * Creates the `.opencode/` directory structure, plugin entry files,
5
+ * workspace package.json, opencode config, skill file, and runtime
6
+ * configuration. Also handles provider health checks and dependency
7
+ * installation.
8
+ */
9
+ import type { Command } from "commander";
10
+ /**
11
+ * Register the `init` command on the given Commander program.
12
+ *
13
+ * Creates the full `.opencode/` workspace structure, plugin entries,
14
+ * skill file, and `opencode-rag.json` config. Optionally runs provider
15
+ * health checks and installs workspace-local npm dependencies.
16
+ *
17
+ * @param program - The Commander `Command` instance to register on.
18
+ */
19
+ export declare function registerInitCommand(program: Command): void;