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,51 @@
1
+ /**
2
+ * Package and file-system utility helpers used by CLI command modules.
3
+ */
4
+ import type { PackageMetadata } from "./types.js";
5
+ /**
6
+ * Resolve the absolute path to the package root directory.
7
+ *
8
+ * Uses `import.meta.url` to locate the directory containing `package.json`
9
+ * relative to the compiled output.
10
+ *
11
+ * @returns Absolute path to the package root (e.g. `/path/to/opencode-rag`).
12
+ */
13
+ export declare function getPackageRoot(): string;
14
+ /**
15
+ * Read and parse `package.json` from the package root.
16
+ *
17
+ * @returns The parsed `PackageMetadata` containing name, version, and dependency maps.
18
+ * @throws {Error} If the package.json file cannot be read or parsed (e.g. merge conflicts).
19
+ */
20
+ export declare function getPackageMetadata(): PackageMetadata;
21
+ /**
22
+ * Filter an unknown value into a `Record<string, string>`.
23
+ *
24
+ * Returns an empty object if the value is not a plain object or contains
25
+ * non-string entries.
26
+ *
27
+ * @param value - The unknown value to normalize.
28
+ * @returns A record with only string-valued entries.
29
+ */
30
+ export declare function getStringRecord(value: unknown): Record<string, string>;
31
+ /**
32
+ * Read a JSON file from disk and return it as a generic record.
33
+ *
34
+ * @param filePath - Absolute path to the JSON file.
35
+ * @returns The parsed object, or `undefined` if the file does not exist.
36
+ */
37
+ export declare function readJsonObject(filePath: string): Record<string, unknown> | undefined;
38
+ /**
39
+ * Write a JavaScript object to disk as pretty-printed JSON.
40
+ *
41
+ * @param filePath - Absolute path to the target file.
42
+ * @param value - The object to serialize (2-space indentation, trailing newline).
43
+ */
44
+ export declare function writeJsonFile(filePath: string, value: Record<string, unknown>): void;
45
+ /**
46
+ * Convert a platform-specific path to POSIX (forward-slash) format.
47
+ *
48
+ * @param input - A file path using the platform separator.
49
+ * @returns The same path with all backslashes replaced by forward slashes.
50
+ */
51
+ export declare function toPosixPath(input: string): string;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Package and file-system utility helpers used by CLI command modules.
3
+ */
4
+ import path from "node:path";
5
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
6
+ import { fileURLToPath } from "node:url";
7
+ /**
8
+ * Resolve the absolute path to the package root directory.
9
+ *
10
+ * Uses `import.meta.url` to locate the directory containing `package.json`
11
+ * relative to the compiled output.
12
+ *
13
+ * @returns Absolute path to the package root (e.g. `/path/to/opencode-rag`).
14
+ */
15
+ export function getPackageRoot() {
16
+ return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
17
+ }
18
+ /**
19
+ * Read and parse `package.json` from the package root.
20
+ *
21
+ * @returns The parsed `PackageMetadata` containing name, version, and dependency maps.
22
+ * @throws {Error} If the package.json file cannot be read or parsed (e.g. merge conflicts).
23
+ */
24
+ export function getPackageMetadata() {
25
+ const packageJsonPath = path.join(getPackageRoot(), "package.json");
26
+ try {
27
+ return JSON.parse(readFileSync(packageJsonPath, "utf-8"));
28
+ }
29
+ catch (cause) {
30
+ throw new Error(`Failed to parse package.json at ${packageJsonPath}. ` +
31
+ "This usually means the file contains invalid JSON, such as unresolved git merge conflict markers " +
32
+ "(<<<<<<<, =======, >>>>>>>). Resolve the conflict manually.\n" +
33
+ `Inner error: ${cause.message}`);
34
+ }
35
+ }
36
+ /**
37
+ * Filter an unknown value into a `Record<string, string>`.
38
+ *
39
+ * Returns an empty object if the value is not a plain object or contains
40
+ * non-string entries.
41
+ *
42
+ * @param value - The unknown value to normalize.
43
+ * @returns A record with only string-valued entries.
44
+ */
45
+ export function getStringRecord(value) {
46
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
47
+ return {};
48
+ }
49
+ return Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string"));
50
+ }
51
+ /**
52
+ * Read a JSON file from disk and return it as a generic record.
53
+ *
54
+ * @param filePath - Absolute path to the JSON file.
55
+ * @returns The parsed object, or `undefined` if the file does not exist.
56
+ */
57
+ export function readJsonObject(filePath) {
58
+ if (!existsSync(filePath)) {
59
+ return undefined;
60
+ }
61
+ try {
62
+ return JSON.parse(readFileSync(filePath, "utf-8"));
63
+ }
64
+ catch (err) {
65
+ throw new Error(`Failed to parse JSON at ${filePath}: ${err.message}`);
66
+ }
67
+ }
68
+ /**
69
+ * Write a JavaScript object to disk as pretty-printed JSON.
70
+ *
71
+ * @param filePath - Absolute path to the target file.
72
+ * @param value - The object to serialize (2-space indentation, trailing newline).
73
+ */
74
+ export function writeJsonFile(filePath, value) {
75
+ writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`, "utf-8");
76
+ }
77
+ /**
78
+ * Convert a platform-specific path to POSIX (forward-slash) format.
79
+ *
80
+ * @param input - A file path using the platform separator.
81
+ * @returns The same path with all backslashes replaced by forward slashes.
82
+ */
83
+ export function toPosixPath(input) {
84
+ return input.split(path.sep).join("/");
85
+ }
86
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,cAAc,CAAC,CAAC;IACpE,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAoB,CAAC;IAC/E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,mCAAmC,eAAe,IAAI;YACpD,mGAAmG;YACnG,+DAA+D;YAC/D,gBAAiB,KAAe,CAAC,OAAO,EAAE,CAC7C,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAA6B,EAAE,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CACjG,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAA4B,CAAC;IAChF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,KAAM,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IACpF,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,KAA8B;IAC5E,aAAa,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * CLI entry point — creates the Commander program, wires all command modules,
3
+ * and handles auto-run detection for symlinked binaries.
4
+ *
5
+ * This file is compiled to `dist/cli/index.js`, the actual entry point
6
+ * referenced by the `bin` entry in `package.json`. The sibling file
7
+ * `dist/cli.js` is a backwards-compatibility re-export shim.
8
+ */
9
+ /**
10
+ * Determine whether the CLI should auto-run for the current module.
11
+ *
12
+ * Resolves the first argv entry so symlinked binaries compare against the
13
+ * real file path, and returns `false` if the path cannot be resolved.
14
+ *
15
+ * @param moduleUrl - The `import.meta.url` of the CLI entry module.
16
+ * @param argv1 - The first CLI argument (`process.argv[1]`), typically the script path.
17
+ * @returns `true` if the resolved argv path matches the module URL.
18
+ */
19
+ export declare function shouldAutoRunCli(moduleUrl: string, argv1?: string): boolean;
20
+ /**
21
+ * Programmatically invoke the CLI with custom arguments.
22
+ *
23
+ * This is the public API entry point for running the CLI from code
24
+ * (e.g. from tests or the library export).
25
+ *
26
+ * @param argv - The argument vector to parse (defaults to `process.argv`).
27
+ */
28
+ export declare function runCli(argv?: string[]): Promise<void>;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * CLI entry point — creates the Commander program, wires all command modules,
3
+ * and handles auto-run detection for symlinked binaries.
4
+ *
5
+ * This file is compiled to `dist/cli/index.js`, the actual entry point
6
+ * referenced by the `bin` entry in `package.json`. The sibling file
7
+ * `dist/cli.js` is a backwards-compatibility re-export shim.
8
+ */
9
+ import { Command } from "commander";
10
+ import { realpathSync } from "node:fs";
11
+ import { basename, dirname } from "node:path";
12
+ import { fileURLToPath } from "node:url";
13
+ import { registerIndexCommand, registerQueryCommand, registerClearCommand, registerStatusCommand, registerListCommand, registerShowCommand, registerDumpCommand, registerInitCommand, registerUiCommand, registerMcpCommand, registerUpdateCommand, registerEvalSessionsCommand, registerEvalAnalyzeCommand, registerEvalCompareCommand, registerDescribeImageCommand, } from "./commands/index.js";
14
+ /**
15
+ * The top-level Commander program instance that defines the `opencode-rag` CLI.
16
+ *
17
+ * All command modules register their sub-commands against this instance during
18
+ * module initialization. The program is parsed either on auto-run detection or
19
+ * when {@link runCli} is called programmatically.
20
+ */
21
+ const program = new Command();
22
+ program
23
+ .name("opencode-rag")
24
+ .description("Local-first RAG semantic code search");
25
+ registerIndexCommand(program);
26
+ registerQueryCommand(program);
27
+ registerClearCommand(program);
28
+ registerStatusCommand(program);
29
+ registerListCommand(program);
30
+ registerShowCommand(program);
31
+ registerDumpCommand(program);
32
+ registerDescribeImageCommand(program);
33
+ registerUiCommand(program);
34
+ registerMcpCommand(program);
35
+ registerUpdateCommand(program);
36
+ registerEvalSessionsCommand(program);
37
+ registerEvalAnalyzeCommand(program);
38
+ registerEvalCompareCommand(program);
39
+ registerInitCommand(program);
40
+ // ── Auto-run detection ──────────────────────────────────────────
41
+ /**
42
+ * Determine whether the CLI should auto-run for the current module.
43
+ *
44
+ * Resolves the first argv entry so symlinked binaries compare against the
45
+ * real file path, and returns `false` if the path cannot be resolved.
46
+ *
47
+ * @param moduleUrl - The `import.meta.url` of the CLI entry module.
48
+ * @param argv1 - The first CLI argument (`process.argv[1]`), typically the script path.
49
+ * @returns `true` if the resolved argv path matches the module URL.
50
+ */
51
+ export function shouldAutoRunCli(moduleUrl, argv1) {
52
+ if (!argv1) {
53
+ return false;
54
+ }
55
+ try {
56
+ const resolvedPath = realpathSync(argv1).replace(/\\/g, "/");
57
+ const normalizedUrl = moduleUrl.replace(/\\/g, "/");
58
+ return normalizedUrl === `file://${resolvedPath}` || normalizedUrl.endsWith(`/${resolvedPath}`) || normalizedUrl.includes(resolvedPath);
59
+ }
60
+ catch {
61
+ return false;
62
+ }
63
+ }
64
+ if (shouldAutoRunCli(import.meta.url, process.argv[1])) {
65
+ void program.parseAsync(process.argv);
66
+ }
67
+ else {
68
+ // Fallback: auto-run only when the script being executed IS the CLI entry
69
+ // (detected by basename match). Avoids triggering on test runner imports
70
+ // or other modules that import the CLI programmatically.
71
+ const modulePath = fileURLToPath(import.meta.url);
72
+ const argvRaw = process.argv[1] ?? "";
73
+ const cliScript = basename(modulePath);
74
+ const runningScript = basename(argvRaw);
75
+ if (cliScript === runningScript) {
76
+ void program.parseAsync(process.argv);
77
+ }
78
+ else {
79
+ // Backwards-compatibility: when a shim points to the sibling cli.js
80
+ // (e.g. node dist/cli.js) but the real entry is dist/cli/index.js,
81
+ // check whether the running script lives in the same parent directory.
82
+ try {
83
+ const resolvedArgv = realpathSync(argvRaw);
84
+ if (dirname(resolvedArgv) === dirname(dirname(modulePath))) {
85
+ void program.parseAsync(process.argv);
86
+ }
87
+ }
88
+ catch {
89
+ // If the path cannot be resolved, skip auto-run.
90
+ }
91
+ }
92
+ }
93
+ /**
94
+ * Programmatically invoke the CLI with custom arguments.
95
+ *
96
+ * This is the public API entry point for running the CLI from code
97
+ * (e.g. from tests or the library export).
98
+ *
99
+ * @param argv - The argument vector to parse (defaults to `process.argv`).
100
+ */
101
+ export async function runCli(argv = process.argv) {
102
+ await program.parseAsync(argv);
103
+ }
104
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAE7B;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,cAAc,CAAC;KACpB,WAAW,CAAC,sCAAsC,CAAC,CAAC;AAEvD,oBAAoB,CAAC,OA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AC,CAAC,EAAE,CAAC;IACvD,KAAK,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;KAAM,CAAC;IACN,0EAA0E;IAC1E,yEAAyE;IACzE,yDAAyD;IACzD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACtC,MAAM,SAAS,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACvC,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,SAAS,KAAK,aAAa,EAAE,CAAC;QAChC,KAAK,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;SAAM,CAAC;QACN,oEAAoE;QACpE,mEAAmE;QACnE,uEAAuE;QACvE,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;YAC3C,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;gBAC3D,KAAK,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,iDAAiD;QACnD,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAiB,OAAO,CAAC,IAAI;IACxD,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { IndexProgress } from "../core/interfaces.js";
2
+ /**
3
+ * Terminal-based progress reporter that renders a live-updating table of
4
+ * indexing progress for each file through the chunking → description → embedding pipeline.
5
+ *
6
+ * When output is a TTY, the table is re-rendered in-place on a 100 ms interval.
7
+ * For non-TTY streams (piped output), each finished or failed file is logged as a single line.
8
+ */
9
+ export declare class TerminalProgressTable implements IndexProgress {
10
+ private stream;
11
+ private entries;
12
+ private failed;
13
+ private fileLabels;
14
+ private fileCount;
15
+ private maxLabelLength;
16
+ private renderedLineCount;
17
+ private dirty;
18
+ private timer;
19
+ private done_;
20
+ private isTTY;
21
+ /**
22
+ * @param stream - The write stream used for rendering (typically `process.stdout` or `process.stderr`).
23
+ */
24
+ constructor(stream: NodeJS.WriteStream);
25
+ /** Set the total number of files to be processed (shown in the table header). */
26
+ setFileCount(n: number): void;
27
+ /** Register a new file with the given label and reset its stage to 0. */
28
+ startFile(label: string): void;
29
+ /** Advance the file to its next pipeline stage. */
30
+ finishStage(label: string): void;
31
+ /** Mark the file as fully processed through all stages. */
32
+ finishFile(label: string): void;
33
+ /** Mark the file as failed and log the failure. */
34
+ failFile(label: string): void;
35
+ /** Signal that indexing is complete — flush remaining output and clean up the interval timer. */
36
+ done(): void;
37
+ private flush;
38
+ private render;
39
+ }
@@ -0,0 +1,137 @@
1
+ const STAGE_LABELS = ["Chunking", "Description", "Embedding"];
2
+ /** Build a human-readable breadcrumb trail through the indexing pipeline stages. */
3
+ function formatBreadcrumb(stageIdx, failed) {
4
+ if (failed) {
5
+ return "Failed!";
6
+ }
7
+ const parts = [];
8
+ for (let i = 0; i < STAGE_LABELS.length; i++) {
9
+ if (i < stageIdx) {
10
+ parts.push(STAGE_LABELS[i]);
11
+ }
12
+ else if (i === stageIdx) {
13
+ parts.push(STAGE_LABELS[i] + "...");
14
+ break;
15
+ }
16
+ else {
17
+ break;
18
+ }
19
+ }
20
+ const breadcrumb = parts.join(" -> ");
21
+ if (stageIdx >= STAGE_LABELS.length) {
22
+ return breadcrumb + " -> Finished!";
23
+ }
24
+ return breadcrumb;
25
+ }
26
+ /** Format a single terminal progress line with padded label and breadcrumb. */
27
+ function logLine(label, maxLabelLength, breadcrumb) {
28
+ return ` ${label.padEnd(maxLabelLength + 2)}${breadcrumb}`;
29
+ }
30
+ /**
31
+ * Terminal-based progress reporter that renders a live-updating table of
32
+ * indexing progress for each file through the chunking → description → embedding pipeline.
33
+ *
34
+ * When output is a TTY, the table is re-rendered in-place on a 100 ms interval.
35
+ * For non-TTY streams (piped output), each finished or failed file is logged as a single line.
36
+ */
37
+ export class TerminalProgressTable {
38
+ stream;
39
+ entries = new Map();
40
+ failed = new Set();
41
+ fileLabels = [];
42
+ fileCount = 0;
43
+ maxLabelLength = 0;
44
+ renderedLineCount = 0;
45
+ dirty = false;
46
+ timer = null;
47
+ done_ = false;
48
+ isTTY;
49
+ /**
50
+ * @param stream - The write stream used for rendering (typically `process.stdout` or `process.stderr`).
51
+ */
52
+ constructor(stream) {
53
+ this.stream = stream;
54
+ this.isTTY = stream.isTTY;
55
+ if (this.isTTY) {
56
+ this.timer = setInterval(() => this.flush(), 100);
57
+ }
58
+ }
59
+ /** Set the total number of files to be processed (shown in the table header). */
60
+ setFileCount(n) {
61
+ this.fileCount = n;
62
+ this.dirty = true;
63
+ }
64
+ /** Register a new file with the given label and reset its stage to 0. */
65
+ startFile(label) {
66
+ if (!this.entries.has(label)) {
67
+ this.fileLabels.push(label);
68
+ this.maxLabelLength = Math.max(this.maxLabelLength, label.length);
69
+ }
70
+ this.entries.set(label, 0);
71
+ this.dirty = true;
72
+ }
73
+ /** Advance the file to its next pipeline stage. */
74
+ finishStage(label) {
75
+ const idx = this.entries.get(label);
76
+ if (idx !== undefined && idx < STAGE_LABELS.length) {
77
+ this.entries.set(label, idx + 1);
78
+ this.dirty = true;
79
+ }
80
+ }
81
+ /** Mark the file as fully processed through all stages. */
82
+ finishFile(label) {
83
+ const idx = this.entries.get(label);
84
+ if (idx !== undefined) {
85
+ this.entries.set(label, STAGE_LABELS.length);
86
+ this.dirty = true;
87
+ if (!this.isTTY) {
88
+ console.log(logLine(label, this.maxLabelLength, formatBreadcrumb(STAGE_LABELS.length)));
89
+ }
90
+ }
91
+ }
92
+ /** Mark the file as failed and log the failure. */
93
+ failFile(label) {
94
+ this.failed.add(label);
95
+ this.dirty = true;
96
+ if (!this.isTTY) {
97
+ console.log(logLine(label, this.maxLabelLength, formatBreadcrumb(0, true)));
98
+ }
99
+ }
100
+ /** Signal that indexing is complete — flush remaining output and clean up the interval timer. */
101
+ done() {
102
+ this.done_ = true;
103
+ if (this.timer) {
104
+ clearInterval(this.timer);
105
+ this.timer = null;
106
+ }
107
+ this.flush();
108
+ this.stream.write("\n");
109
+ }
110
+ flush() {
111
+ if (!this.dirty || this.done_)
112
+ return;
113
+ this.dirty = false;
114
+ this.render();
115
+ }
116
+ render() {
117
+ if (!this.isTTY)
118
+ return;
119
+ const lines = [];
120
+ if (this.fileCount > 0) {
121
+ lines.push(`Indexing ${this.fileCount} files:`);
122
+ }
123
+ for (const label of this.fileLabels) {
124
+ const stageIdx = this.entries.get(label);
125
+ if (stageIdx === undefined)
126
+ continue;
127
+ lines.push(logLine(label, this.maxLabelLength, formatBreadcrumb(stageIdx, this.failed.has(label))));
128
+ }
129
+ const clearCount = this.renderedLineCount;
130
+ if (clearCount > 0) {
131
+ this.stream.write(`\x1b[${clearCount}A\x1b[J`);
132
+ }
133
+ this.stream.write(lines.join("\n"));
134
+ this.renderedLineCount = lines.length;
135
+ }
136
+ }
137
+ //# sourceMappingURL=progress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/cli/progress.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,WAAW,CAAU,CAAC;AAEvE,oFAAoF;AACpF,SAAS,gBAAgB,CAAC,QAAgB,EAAE,MAAgB;IAC1D,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,C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AK,GAAa,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;YACvB,KAAK,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,SAAS,SAAS,CAAC,CAAC;QAClD,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACzC,IAAI,QAAQ,KAAK,SAAS;gBAAE,SAAS;YACrC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACtG,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAC1C,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;YACnB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,UAAU,SAAS,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1,40 @@
1
+ /** Shared CLI option interfaces used by all command modules. */
2
+ /** Standard CLI options shared by most commands (index, query, clear, etc.). */
3
+ export interface CliOptions {
4
+ /** Optional path to an `opencode-rag.json` config file. */
5
+ config?: string;
6
+ /** Force a full re-index when set. */
7
+ force?: boolean;
8
+ /** Watch workspace for changes and re-index automatically. */
9
+ watch?: boolean;
10
+ /** Maximum number of results to return (query command). */
11
+ topK?: string;
12
+ /** Chunk offset for paginated dump output. */
13
+ offset?: string;
14
+ /** Maximum number of chunks to dump. */
15
+ limit?: string;
16
+ /** Show hybrid score breakdown in query results. */
17
+ explain?: boolean;
18
+ /** Skip confirmation prompts for destructive operations. */
19
+ yes?: boolean;
20
+ }
21
+ /** Options for the `init` command. */
22
+ export interface InitOptions {
23
+ /** Overwrite existing files during initialization. */
24
+ force?: boolean;
25
+ /** Skip installing workspace-local plugin dependencies. */
26
+ skipInstall?: boolean;
27
+ /** Skip provider connectivity and model availability check. */
28
+ skipHealthCheck?: boolean;
29
+ }
30
+ /** Shape of the `package.json` metadata required by CLI helpers. */
31
+ export interface PackageMetadata {
32
+ /** The npm package name. */
33
+ name: string;
34
+ /** The semver version string. */
35
+ version: string;
36
+ /** Dev dependencies map, used to resolve plugin versions. */
37
+ devDependencies?: Record<string, string>;
38
+ /** Peer dependencies map, used to resolve plugin versions. */
39
+ peerDependencies?: Record<string, string>;
40
+ }
@@ -0,0 +1,3 @@
1
+ /** Shared CLI option interfaces used by all command modules. */
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/cli/types.ts"],"names":[],"mappings":"AAAA,gEAAgE"}
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,11 @@
1
- #!/usr/bin/env node
2
- export declare function removeStaleGlobalPluginRegistrations(homeDir: string, pluginName: string): string[];
3
- export declare function shouldAutoRunCli(moduleUrl: string, argv1?: string): boolean;
4
- export declare function runCli(argv?: string[]): Promise<void>;
1
+ /**
2
+ * Backwards-compatibility shim re-exports the public API from the new
3
+ * `cli/` module tree so existing tests and external consumers that import
4
+ * from `../cli.js` continue to work unchanged.
5
+ *
6
+ * The actual CLI entry point is now `cli/index.ts` (compiled to `dist/cli/index.js`).
7
+ */
8
+ /** Main CLI runner and auto-launch detection. */
9
+ export { runCli, shouldAutoRunCli } from "./cli/index.js";
10
+ /** Cleanup helper that removes stale global plugin registration symlinks. */
11
+ export { removeStaleGlobalPluginRegistrations } from "./cli/commands/init-helpers.js";