opencode-dux 1.0.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 (302) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +452 -0
  3. package/dist/agents/descriptions.d.ts +6 -0
  4. package/dist/agents/designer.d.ts +2 -0
  5. package/dist/agents/explorer.d.ts +2 -0
  6. package/dist/agents/fixer.d.ts +2 -0
  7. package/dist/agents/index.d.ts +22 -0
  8. package/dist/agents/interpreter.d.ts +2 -0
  9. package/dist/agents/librarian.d.ts +2 -0
  10. package/dist/agents/oracle.d.ts +2 -0
  11. package/dist/agents/orchestrator.d.ts +27 -0
  12. package/dist/agents/overrides.d.ts +18 -0
  13. package/dist/agents/prompt-blocks.d.ts +97 -0
  14. package/dist/agents/steward.d.ts +3 -0
  15. package/dist/cli/config-io.d.ts +24 -0
  16. package/dist/cli/config-manager.d.ts +4 -0
  17. package/dist/cli/index.d.ts +2 -0
  18. package/dist/cli/index.js +1006 -0
  19. package/dist/cli/install.d.ts +2 -0
  20. package/dist/cli/mcps.d.ts +13 -0
  21. package/dist/cli/model-key-normalization.d.ts +1 -0
  22. package/dist/cli/paths.d.ts +35 -0
  23. package/dist/cli/providers.d.ts +137 -0
  24. package/dist/cli/skills.d.ts +22 -0
  25. package/dist/cli/system.d.ts +5 -0
  26. package/dist/cli/types.d.ts +38 -0
  27. package/dist/config/constants.d.ts +12 -0
  28. package/dist/config/index.d.ts +4 -0
  29. package/dist/config/loader.d.ts +40 -0
  30. package/dist/config/runtime-preset.d.ts +12 -0
  31. package/dist/config/schema.d.ts +281 -0
  32. package/dist/config/utils.d.ts +10 -0
  33. package/dist/discovery/local/types.d.ts +79 -0
  34. package/dist/discovery/local.d.ts +73 -0
  35. package/dist/discovery/mcp-servers.d.ts +88 -0
  36. package/dist/discovery/skills.d.ts +94 -0
  37. package/dist/hooks/apply-patch/codec.d.ts +7 -0
  38. package/dist/hooks/apply-patch/errors.d.ts +25 -0
  39. package/dist/hooks/apply-patch/execution-context.d.ts +27 -0
  40. package/dist/hooks/apply-patch/index.d.ts +15 -0
  41. package/dist/hooks/apply-patch/matching.d.ts +26 -0
  42. package/dist/hooks/apply-patch/operations.d.ts +3 -0
  43. package/dist/hooks/apply-patch/patch.d.ts +2 -0
  44. package/dist/hooks/apply-patch/prepared-changes.d.ts +17 -0
  45. package/dist/hooks/apply-patch/resolution.d.ts +19 -0
  46. package/dist/hooks/apply-patch/rewrite.d.ts +7 -0
  47. package/dist/hooks/apply-patch/test-helpers.d.ts +6 -0
  48. package/dist/hooks/apply-patch/types.d.ts +80 -0
  49. package/dist/hooks/auto-update-checker/cache.d.ts +11 -0
  50. package/dist/hooks/auto-update-checker/checker.d.ts +32 -0
  51. package/dist/hooks/auto-update-checker/constants.d.ts +11 -0
  52. package/dist/hooks/auto-update-checker/index.d.ts +18 -0
  53. package/dist/hooks/auto-update-checker/types.d.ts +22 -0
  54. package/dist/hooks/chat-headers.d.ts +16 -0
  55. package/dist/hooks/context-pressure-reminder/index.d.ts +33 -0
  56. package/dist/hooks/delegate-task-retry/guidance.d.ts +2 -0
  57. package/dist/hooks/delegate-task-retry/hook.d.ts +8 -0
  58. package/dist/hooks/delegate-task-retry/index.d.ts +4 -0
  59. package/dist/hooks/delegate-task-retry/patterns.d.ts +11 -0
  60. package/dist/hooks/filter-available-skills/index.d.ts +32 -0
  61. package/dist/hooks/foreground-fallback/index.d.ts +72 -0
  62. package/dist/hooks/image-hook.d.ts +5 -0
  63. package/dist/hooks/index.d.ts +14 -0
  64. package/dist/hooks/json-error-recovery/hook.d.ts +18 -0
  65. package/dist/hooks/json-error-recovery/index.d.ts +1 -0
  66. package/dist/hooks/phase-reminder/index.d.ts +26 -0
  67. package/dist/hooks/post-file-tool-nudge/index.d.ts +19 -0
  68. package/dist/hooks/task-session-manager/index.d.ts +52 -0
  69. package/dist/hooks/todo-continuation/index.d.ts +53 -0
  70. package/dist/hooks/todo-continuation/todo-hygiene.d.ts +35 -0
  71. package/dist/index.d.ts +5 -0
  72. package/dist/index.js +31782 -0
  73. package/dist/mcp/context7.d.ts +6 -0
  74. package/dist/mcp/grep-app.d.ts +6 -0
  75. package/dist/mcp/index.d.ts +13 -0
  76. package/dist/mcp/types.d.ts +12 -0
  77. package/dist/mcp/websearch.d.ts +9 -0
  78. package/dist/skills/registry.d.ts +29 -0
  79. package/dist/subscriptions/accounts-store.d.ts +57 -0
  80. package/dist/subscriptions/index.d.ts +13 -0
  81. package/dist/subscriptions/neuralwatt-scraper.d.ts +14 -0
  82. package/dist/subscriptions/opencode-go-scraper.d.ts +27 -0
  83. package/dist/subscriptions/types.d.ts +115 -0
  84. package/dist/subscriptions/usage-service.d.ts +74 -0
  85. package/dist/tools/ast-grep/cli.d.ts +15 -0
  86. package/dist/tools/ast-grep/constants.d.ts +25 -0
  87. package/dist/tools/ast-grep/downloader.d.ts +5 -0
  88. package/dist/tools/ast-grep/index.d.ts +10 -0
  89. package/dist/tools/ast-grep/tools.d.ts +3 -0
  90. package/dist/tools/ast-grep/types.d.ts +30 -0
  91. package/dist/tools/ast-grep/utils.d.ts +4 -0
  92. package/dist/tools/delegate.d.ts +14 -0
  93. package/dist/tools/index.d.ts +5 -0
  94. package/dist/tools/preset-manager.d.ts +27 -0
  95. package/dist/tools/smartfetch/binary.d.ts +3 -0
  96. package/dist/tools/smartfetch/cache.d.ts +6 -0
  97. package/dist/tools/smartfetch/constants.d.ts +12 -0
  98. package/dist/tools/smartfetch/index.d.ts +3 -0
  99. package/dist/tools/smartfetch/network.d.ts +38 -0
  100. package/dist/tools/smartfetch/secondary-model.d.ts +28 -0
  101. package/dist/tools/smartfetch/tool.d.ts +3 -0
  102. package/dist/tools/smartfetch/types.d.ts +122 -0
  103. package/dist/tools/smartfetch/utils.d.ts +18 -0
  104. package/dist/tui-state.d.ts +168 -0
  105. package/dist/tui.d.ts +37 -0
  106. package/dist/tui.js +1896 -0
  107. package/dist/utils/agent-variant.d.ts +63 -0
  108. package/dist/utils/compat.d.ts +30 -0
  109. package/dist/utils/env.d.ts +1 -0
  110. package/dist/utils/index.d.ts +9 -0
  111. package/dist/utils/internal-initiator.d.ts +6 -0
  112. package/dist/utils/logger.d.ts +8 -0
  113. package/dist/utils/polling.d.ts +21 -0
  114. package/dist/utils/session-manager.d.ts +55 -0
  115. package/dist/utils/session.d.ts +90 -0
  116. package/dist/utils/subagent-depth.d.ts +35 -0
  117. package/dist/utils/system-collapse.d.ts +6 -0
  118. package/dist/utils/task.d.ts +4 -0
  119. package/dist/utils/zip-extractor.d.ts +1 -0
  120. package/index.ts +1 -0
  121. package/opencode-dux.schema.json +634 -0
  122. package/package.json +103 -0
  123. package/src/agents/descriptions.ts +55 -0
  124. package/src/agents/designer.test.ts +86 -0
  125. package/src/agents/designer.ts +154 -0
  126. package/src/agents/display-name.test.ts +186 -0
  127. package/src/agents/explorer.test.ts +79 -0
  128. package/src/agents/explorer.ts +144 -0
  129. package/src/agents/fixer.test.ts +79 -0
  130. package/src/agents/fixer.ts +145 -0
  131. package/src/agents/index.test.ts +472 -0
  132. package/src/agents/index.ts +248 -0
  133. package/src/agents/interpreter.ts +136 -0
  134. package/src/agents/librarian.test.ts +80 -0
  135. package/src/agents/librarian.ts +145 -0
  136. package/src/agents/oracle.test.ts +89 -0
  137. package/src/agents/oracle.ts +184 -0
  138. package/src/agents/orchestrator.test.ts +116 -0
  139. package/src/agents/orchestrator.ts +574 -0
  140. package/src/agents/overrides.ts +95 -0
  141. package/src/agents/prompt-blocks.test.ts +114 -0
  142. package/src/agents/prompt-blocks.ts +640 -0
  143. package/src/agents/steward.ts +146 -0
  144. package/src/cli/config-io.test.ts +536 -0
  145. package/src/cli/config-io.ts +473 -0
  146. package/src/cli/config-manager.test.ts +141 -0
  147. package/src/cli/config-manager.ts +4 -0
  148. package/src/cli/index.ts +88 -0
  149. package/src/cli/install.ts +282 -0
  150. package/src/cli/mcps.test.ts +62 -0
  151. package/src/cli/mcps.ts +39 -0
  152. package/src/cli/model-key-normalization.test.ts +21 -0
  153. package/src/cli/model-key-normalization.ts +60 -0
  154. package/src/cli/paths.test.ts +167 -0
  155. package/src/cli/paths.ts +144 -0
  156. package/src/cli/providers.test.ts +118 -0
  157. package/src/cli/providers.ts +141 -0
  158. package/src/cli/skills.test.ts +111 -0
  159. package/src/cli/skills.ts +103 -0
  160. package/src/cli/system.test.ts +91 -0
  161. package/src/cli/system.ts +180 -0
  162. package/src/cli/types.ts +43 -0
  163. package/src/config/constants.ts +58 -0
  164. package/src/config/index.ts +4 -0
  165. package/src/config/loader.test.ts +1194 -0
  166. package/src/config/loader.ts +269 -0
  167. package/src/config/model-resolution.test.ts +176 -0
  168. package/src/config/runtime-preset.test.ts +61 -0
  169. package/src/config/runtime-preset.ts +37 -0
  170. package/src/config/schema.ts +248 -0
  171. package/src/config/utils.test.ts +41 -0
  172. package/src/config/utils.ts +23 -0
  173. package/src/discovery/local/types.ts +85 -0
  174. package/src/discovery/local.ts +322 -0
  175. package/src/discovery/mcp-servers.ts +804 -0
  176. package/src/discovery/skills.ts +959 -0
  177. package/src/hooks/apply-patch/codec.test.ts +184 -0
  178. package/src/hooks/apply-patch/codec.ts +352 -0
  179. package/src/hooks/apply-patch/errors.ts +117 -0
  180. package/src/hooks/apply-patch/execution-context.ts +432 -0
  181. package/src/hooks/apply-patch/hook.test.ts +768 -0
  182. package/src/hooks/apply-patch/index.ts +126 -0
  183. package/src/hooks/apply-patch/matching.test.ts +215 -0
  184. package/src/hooks/apply-patch/matching.ts +586 -0
  185. package/src/hooks/apply-patch/operations.test.ts +1535 -0
  186. package/src/hooks/apply-patch/operations.ts +3 -0
  187. package/src/hooks/apply-patch/patch.ts +9 -0
  188. package/src/hooks/apply-patch/prepared-changes.ts +400 -0
  189. package/src/hooks/apply-patch/resolution.test.ts +420 -0
  190. package/src/hooks/apply-patch/resolution.ts +437 -0
  191. package/src/hooks/apply-patch/rewrite.ts +496 -0
  192. package/src/hooks/apply-patch/test-helpers.ts +52 -0
  193. package/src/hooks/apply-patch/types.ts +111 -0
  194. package/src/hooks/auto-update-checker/cache.test.ts +179 -0
  195. package/src/hooks/auto-update-checker/cache.ts +188 -0
  196. package/src/hooks/auto-update-checker/checker.test.ts +159 -0
  197. package/src/hooks/auto-update-checker/checker.ts +308 -0
  198. package/src/hooks/auto-update-checker/constants.ts +33 -0
  199. package/src/hooks/auto-update-checker/index.test.ts +282 -0
  200. package/src/hooks/auto-update-checker/index.ts +225 -0
  201. package/src/hooks/auto-update-checker/types.ts +26 -0
  202. package/src/hooks/chat-headers.test.ts +236 -0
  203. package/src/hooks/chat-headers.ts +97 -0
  204. package/src/hooks/context-pressure-reminder/index.test.ts +179 -0
  205. package/src/hooks/context-pressure-reminder/index.ts +137 -0
  206. package/src/hooks/delegate-task-retry/guidance.ts +41 -0
  207. package/src/hooks/delegate-task-retry/hook.ts +23 -0
  208. package/src/hooks/delegate-task-retry/index.test.ts +38 -0
  209. package/src/hooks/delegate-task-retry/index.ts +7 -0
  210. package/src/hooks/delegate-task-retry/patterns.ts +79 -0
  211. package/src/hooks/filter-available-skills/index.test.ts +297 -0
  212. package/src/hooks/filter-available-skills/index.ts +160 -0
  213. package/src/hooks/foreground-fallback/index.test.ts +624 -0
  214. package/src/hooks/foreground-fallback/index.ts +374 -0
  215. package/src/hooks/image-hook.ts +6 -0
  216. package/src/hooks/index.ts +17 -0
  217. package/src/hooks/json-error-recovery/hook.ts +73 -0
  218. package/src/hooks/json-error-recovery/index.test.ts +111 -0
  219. package/src/hooks/json-error-recovery/index.ts +6 -0
  220. package/src/hooks/phase-reminder/index.test.ts +74 -0
  221. package/src/hooks/phase-reminder/index.ts +85 -0
  222. package/src/hooks/post-file-tool-nudge/index.test.ts +94 -0
  223. package/src/hooks/post-file-tool-nudge/index.ts +63 -0
  224. package/src/hooks/task-session-manager/index.test.ts +833 -0
  225. package/src/hooks/task-session-manager/index.ts +434 -0
  226. package/src/hooks/todo-continuation/index.test.ts +3026 -0
  227. package/src/hooks/todo-continuation/index.ts +878 -0
  228. package/src/hooks/todo-continuation/todo-hygiene.test.ts +204 -0
  229. package/src/hooks/todo-continuation/todo-hygiene.ts +207 -0
  230. package/src/index.ts +1672 -0
  231. package/src/mcp/context7.ts +14 -0
  232. package/src/mcp/grep-app.ts +11 -0
  233. package/src/mcp/index.test.ts +96 -0
  234. package/src/mcp/index.ts +66 -0
  235. package/src/mcp/types.ts +16 -0
  236. package/src/mcp/websearch.ts +47 -0
  237. package/src/skills/codemap/README.md +60 -0
  238. package/src/skills/codemap/SKILL.md +174 -0
  239. package/src/skills/codemap/scripts/codemap.mjs +483 -0
  240. package/src/skills/codemap/scripts/codemap.test.ts +129 -0
  241. package/src/skills/registry.ts +218 -0
  242. package/src/skills/simplify/README.md +19 -0
  243. package/src/skills/simplify/SKILL.md +138 -0
  244. package/src/subscriptions/accounts-store.test.ts +236 -0
  245. package/src/subscriptions/accounts-store.ts +184 -0
  246. package/src/subscriptions/index.ts +30 -0
  247. package/src/subscriptions/neuralwatt-scraper.ts +108 -0
  248. package/src/subscriptions/opencode-go-scraper.ts +301 -0
  249. package/src/subscriptions/types.ts +145 -0
  250. package/src/subscriptions/usage-service.test.ts +202 -0
  251. package/src/subscriptions/usage-service.ts +651 -0
  252. package/src/tools/ast-grep/cli.ts +257 -0
  253. package/src/tools/ast-grep/constants.ts +214 -0
  254. package/src/tools/ast-grep/downloader.ts +131 -0
  255. package/src/tools/ast-grep/index.ts +24 -0
  256. package/src/tools/ast-grep/tools.ts +117 -0
  257. package/src/tools/ast-grep/types.ts +51 -0
  258. package/src/tools/ast-grep/utils.ts +126 -0
  259. package/src/tools/delegate-handoff.test.ts +18 -0
  260. package/src/tools/delegate.ts +508 -0
  261. package/src/tools/index.ts +8 -0
  262. package/src/tools/preset-manager.test.ts +795 -0
  263. package/src/tools/preset-manager.ts +332 -0
  264. package/src/tools/smartfetch/binary.ts +58 -0
  265. package/src/tools/smartfetch/cache.test.ts +34 -0
  266. package/src/tools/smartfetch/cache.ts +112 -0
  267. package/src/tools/smartfetch/constants.ts +29 -0
  268. package/src/tools/smartfetch/index.ts +8 -0
  269. package/src/tools/smartfetch/network.test.ts +178 -0
  270. package/src/tools/smartfetch/network.ts +614 -0
  271. package/src/tools/smartfetch/secondary-model.test.ts +85 -0
  272. package/src/tools/smartfetch/secondary-model.ts +276 -0
  273. package/src/tools/smartfetch/tool.test.ts +60 -0
  274. package/src/tools/smartfetch/tool.ts +832 -0
  275. package/src/tools/smartfetch/types.ts +135 -0
  276. package/src/tools/smartfetch/utils.test.ts +24 -0
  277. package/src/tools/smartfetch/utils.ts +456 -0
  278. package/src/tui-state.test.ts +867 -0
  279. package/src/tui-state.ts +1255 -0
  280. package/src/tui.test.ts +336 -0
  281. package/src/tui.ts +1539 -0
  282. package/src/utils/agent-variant.test.ts +244 -0
  283. package/src/utils/agent-variant.ts +187 -0
  284. package/src/utils/compat.ts +91 -0
  285. package/src/utils/env.ts +12 -0
  286. package/src/utils/index.ts +9 -0
  287. package/src/utils/internal-initiator.ts +28 -0
  288. package/src/utils/logger.test.ts +220 -0
  289. package/src/utils/logger.ts +136 -0
  290. package/src/utils/polling.test.ts +191 -0
  291. package/src/utils/polling.ts +67 -0
  292. package/src/utils/session-manager.test.ts +173 -0
  293. package/src/utils/session-manager.ts +356 -0
  294. package/src/utils/session.test.ts +110 -0
  295. package/src/utils/session.ts +389 -0
  296. package/src/utils/subagent-depth.test.ts +170 -0
  297. package/src/utils/subagent-depth.ts +75 -0
  298. package/src/utils/system-collapse.test.ts +86 -0
  299. package/src/utils/system-collapse.ts +24 -0
  300. package/src/utils/task.test.ts +24 -0
  301. package/src/utils/task.ts +20 -0
  302. package/src/utils/zip-extractor.ts +102 -0
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Type definitions for the discovery module.
3
+ *
4
+ * These types describe MCP servers and skills discovered from local
5
+ * filesystem sources (node_modules, skill directories, etc.).
6
+ *
7
+ * @module
8
+ */
9
+ /**
10
+ * An MCP server discovered from a local source (e.g., node_modules).
11
+ */
12
+ export interface DiscoveredMcp {
13
+ /** Unique name used as the config key (e.g., 'server-github'). */
14
+ name: string;
15
+ /** Command to launch the MCP server (e.g., `['npx', '@org/mcp-server']`). */
16
+ command: string[];
17
+ /** Human-readable description of what this MCP provides. */
18
+ description?: string;
19
+ /** Categorization tags (e.g., 'browser', 'github', 'filesystem'). */
20
+ tags: string[];
21
+ /** Source identifier indicating where this was found (e.g., 'node_modules'). */
22
+ source: string;
23
+ /** Absolute path to the package.json that defined this MCP. */
24
+ packageJsonPath: string;
25
+ /** Version from the package.json, if available. */
26
+ version?: string;
27
+ }
28
+ /**
29
+ * A skill discovered from a local source (skill directory, plugin root, etc.).
30
+ */
31
+ export interface DiscoveredSkill {
32
+ /** Unique skill name (derived from folder name). */
33
+ name: string;
34
+ /** Human-readable description. */
35
+ description: string;
36
+ /** Absolute path to the SKILL.md file. */
37
+ path: string;
38
+ /** Tags for categorisation and matching. */
39
+ tags: string[];
40
+ /** Agents that are recommended to use this skill. */
41
+ recommendedAgents: string[];
42
+ /** Source identifier (e.g., 'plugin', 'user-skills-dir'). */
43
+ source: string;
44
+ /** Version of the skill, if available. */
45
+ version?: string;
46
+ }
47
+ /**
48
+ * Complete result of a local discovery scan.
49
+ */
50
+ export interface LocalDiscoveryResult {
51
+ /** Discovered MCP servers. */
52
+ mcps: DiscoveredMcp[];
53
+ /** Discovered skills. */
54
+ skills: DiscoveredSkill[];
55
+ /** ISO timestamp when the scan was performed. */
56
+ scannedAt: string;
57
+ /** How long the scan took in milliseconds. */
58
+ scanDurationMs: number;
59
+ }
60
+ /**
61
+ * Options to control the behaviour of a local discovery scan.
62
+ */
63
+ export interface ScanOptions {
64
+ /**
65
+ * Additional directories to scan for skills (absolute paths).
66
+ * Skills are discovered from each directory using the same SKILL.md
67
+ * convention as the plugin's built-in skills.
68
+ */
69
+ userSkillsDirs?: string[];
70
+ /**
71
+ * If true, skip scanning node_modules for MCP servers.
72
+ * Useful when the caller only needs skill discovery.
73
+ */
74
+ skipNodeModules?: boolean;
75
+ /**
76
+ * If true, bypass the module-level cache and force a fresh scan.
77
+ */
78
+ forceRefresh?: boolean;
79
+ }
@@ -0,0 +1,73 @@
1
+ import type { PluginInput } from '@opencode-ai/plugin';
2
+ /**
3
+ * A single MCP server discovered via the OpenCode SDK.
4
+ */
5
+ export interface DiscoveredMcp {
6
+ /** Unique name used as the config key (e.g., 'playwright', 'github'). */
7
+ name: string;
8
+ /** Current connection status reported by OpenCode. */
9
+ status: 'connected' | 'disabled' | 'failed' | 'needs_auth' | 'needs_client_registration';
10
+ /** Human-readable description, may include error details when status is 'failed'. */
11
+ description?: string;
12
+ /** Categorization tags derived from the MCP name. */
13
+ tags: string[];
14
+ /** Agents that benefit most from this MCP based on defaults. */
15
+ recommendedAgents: string[];
16
+ }
17
+ /**
18
+ * A single skill discovered via the OpenCode SDK.
19
+ */
20
+ export interface DiscoveredSkill {
21
+ /** Unique skill name. */
22
+ name: string;
23
+ /** Human-readable description. */
24
+ description?: string;
25
+ /** Filesystem location of the skill (SKILL.md path). */
26
+ location: string;
27
+ /** Categorization tags derived from the skill name. */
28
+ tags: string[];
29
+ /** Agents that benefit most from this skill based on defaults. */
30
+ recommendedAgents: string[];
31
+ /** Whether the skill ships with the plugin or was added by the user. */
32
+ source: 'bundled' | 'user';
33
+ }
34
+ /**
35
+ * Complete result of an SDK-based local discovery scan.
36
+ */
37
+ export interface LocalDiscoveryResult {
38
+ /** Discovered skills. */
39
+ skills: DiscoveredSkill[];
40
+ /** Discovered MCP servers. */
41
+ mcps: DiscoveredMcp[];
42
+ /** Unix timestamp (ms) when the scan was performed. */
43
+ scannedAt: number;
44
+ /** How long the scan took in milliseconds. */
45
+ scanDurationMs: number;
46
+ }
47
+ /**
48
+ * Scan locally configured MCP servers and skills using the OpenCode SDK.
49
+ *
50
+ * Calls `ctx.client.mcp.status()` and `ctx.client.instance.skill()` for fast,
51
+ * authoritative local discovery. Each SDK call is independently wrapped in a
52
+ * try/catch so that a failure in one does not prevent the other from
53
+ * succeeding. Empty arrays are returned for any failing SDK call.
54
+ *
55
+ * Results are **not** cached by this function – use
56
+ * {@link getLocalDiscovery} for caching support.
57
+ *
58
+ * @param ctx - The OpenCode plugin input context
59
+ * @returns A {@link LocalDiscoveryResult} with discovered MCPs and skills
60
+ */
61
+ export declare function scanLocal(ctx: PluginInput): Promise<LocalDiscoveryResult>;
62
+ /**
63
+ * Get locally discovered resources, using a cached result when available.
64
+ *
65
+ * Results are cached for 5 minutes. Call with `forceRefresh = true` to
66
+ * bypass the cache and perform a fresh scan. The cache lives at module
67
+ * scope and is shared across all callers within the same plugin instance.
68
+ *
69
+ * @param ctx - The OpenCode plugin input context
70
+ * @param forceRefresh - If `true`, bypass the cache and force a fresh scan
71
+ * @returns A {@link LocalDiscoveryResult}
72
+ */
73
+ export declare function getLocalDiscovery(ctx: PluginInput, forceRefresh?: boolean): Promise<LocalDiscoveryResult>;
@@ -0,0 +1,88 @@
1
+ import type { PluginInput, ToolDefinition } from '@opencode-ai/plugin';
2
+ /**
3
+ * Input parameters for discovering MCP servers online.
4
+ */
5
+ export interface McpDiscoveryInput {
6
+ /** Natural-language description of the task at hand. */
7
+ task_description: string;
8
+ /** Keywords that characterise the task (used for search queries). */
9
+ task_keywords: string[];
10
+ /** The subagent that initiated the discovery request. */
11
+ agent_name: string;
12
+ /**
13
+ * MCP servers already known to be installed.
14
+ * Recommendations that match by name will be filtered out.
15
+ */
16
+ existing_mcp_names?: string[];
17
+ /** Maximum number of recommendations to return (default: 5). */
18
+ max_results?: number;
19
+ }
20
+ /**
21
+ * A single recommendation for an installable MCP server.
22
+ */
23
+ export interface McpRecommendation {
24
+ type: 'mcp';
25
+ /** Canonical name (e.g. 'playwright', 'github'). */
26
+ name: string;
27
+ /** Human-readable summary of what the MCP server provides. */
28
+ description: string;
29
+ /**
30
+ * A ready-to-use JSON config block for the user's opencode config,
31
+ * e.g. `{"mcpServers": {"playwright": {"command": ["npx", "@modelcontextprotocol/server-playwright"]}}}`.
32
+ */
33
+ install_command: string;
34
+ /** Why this recommendation is relevant to the task. */
35
+ relevance_reason: string;
36
+ /** Relevance score from 0 (irrelevant) to 1 (perfect match). */
37
+ relevance_score: number;
38
+ /** URL to the project's homepage, repository, or package page. */
39
+ source_url?: string;
40
+ /** Agent names that are most likely to benefit from this MCP server. */
41
+ recommended_agents: string[];
42
+ /** Categorisation tags (e.g. 'browser', 'github', 'filesystem'). */
43
+ tags: string[];
44
+ /** Whether the user already has this MCP server installed. */
45
+ already_installed?: boolean;
46
+ }
47
+ /**
48
+ * The complete output of an MCP discovery request.
49
+ */
50
+ export interface McpDiscoveryOutput {
51
+ /** Ordered list of recommendations, highest relevance first. */
52
+ recommendations: McpRecommendation[];
53
+ /** Whether the result was served from cache. */
54
+ from_cache: boolean;
55
+ /** The search queries that were executed. */
56
+ queries_used: string[];
57
+ }
58
+ /**
59
+ * Run the full MCP discovery flow for a given set of inputs.
60
+ *
61
+ * 1. Builds search queries from keywords and agent name
62
+ * 2. Searches the npm registry for matching MCP packages
63
+ * 3. Maps results to recommendations with relevance scores
64
+ * 4. Marks already-installed items with `already_installed: true` and
65
+ * only includes them when relevance_score > 0.8
66
+ * 5. Returns the top N results
67
+ *
68
+ * Results are cached on disk for 24 hours.
69
+ */
70
+ export declare function discoverMcpServers(input: McpDiscoveryInput, ctx: PluginInput): Promise<McpDiscoveryOutput>;
71
+ /**
72
+ * Create the `discover_mcp_servers` tool that subagents can call to find
73
+ * installable MCP servers for a given task.
74
+ *
75
+ * The tool:
76
+ * 1. Builds search queries from task keywords and agent name
77
+ * 2. Searches the npm registry for verified MCP packages
78
+ * 3. Scores each result by relevance (0-1)
79
+ * 4. Filters out MCP servers the user already has installed
80
+ * 5. Returns the top N recommendations with ready-to-use mcpServers JSON config
81
+ *
82
+ * Results are cached on disk at `~/.config/opencode/discovery-cache.json`
83
+ * with a 24-hour TTL and LRU eviction (max 100 entries).
84
+ *
85
+ * @param ctx - The OpenCode plugin input (provides client for SDK access)
86
+ * @returns A `ToolDefinition` ready for registration in the plugin's tool hook
87
+ */
88
+ export declare function createDiscoverMcpServersTool(ctx: PluginInput): ToolDefinition;
@@ -0,0 +1,94 @@
1
+ import type { PluginInput, ToolDefinition } from '@opencode-ai/plugin';
2
+ /**
3
+ * Input parameters for discovering OpenCode skills online.
4
+ */
5
+ export interface DiscoverSkillsInput {
6
+ /** Natural-language description of the task at hand. */
7
+ task_description: string;
8
+ /** Keywords that characterise the task (used for search queries). */
9
+ task_keywords: string[];
10
+ /** The subagent that initiated the discovery request. */
11
+ agent_name: string;
12
+ /**
13
+ * Skills already known to be installed.
14
+ * Recommendations that match by name will be filtered out or marked.
15
+ */
16
+ existing_skill_names?: string[];
17
+ /** Maximum number of recommendations to return (default: 5). */
18
+ max_results?: number;
19
+ }
20
+ /**
21
+ * A single recommendation for an installable OpenCode skill.
22
+ */
23
+ export interface SkillRecommendation {
24
+ type: 'skill';
25
+ /** Canonical name (e.g. 'ast-grep', 'codemap'). */
26
+ name: string;
27
+ /** Human-readable summary of what the skill provides. */
28
+ description: string;
29
+ /**
30
+ * A ready-to-use install command, e.g.
31
+ * `npx skills add https://github.com/vercel-labs/skills --skill ast-grep`.
32
+ */
33
+ install_command: string;
34
+ /** Why this recommendation is relevant to the task. */
35
+ relevance_reason: string;
36
+ /** Relevance score from 0 (irrelevant) to 1 (perfect match). */
37
+ relevance_score: number;
38
+ /** GitHub repository URL for the skill. */
39
+ source_url: string;
40
+ /** Agent names that are most likely to benefit from this skill. */
41
+ recommended_agents: string[];
42
+ /** Categorisation tags (e.g. 'search', 'code', 'ast'). */
43
+ tags: string[];
44
+ /** Whether the user already has this skill installed. */
45
+ already_installed?: boolean;
46
+ }
47
+ /**
48
+ * The complete output of a skill discovery request.
49
+ */
50
+ export interface DiscoverSkillsOutput {
51
+ /** Ordered list of recommendations, highest relevance first. */
52
+ recommendations: SkillRecommendation[];
53
+ /** Whether the result was served from cache. */
54
+ from_cache: boolean;
55
+ /** The search queries that were executed. */
56
+ queries_used: string[];
57
+ }
58
+ /**
59
+ * Run the full skill discovery flow for a given set of inputs.
60
+ *
61
+ * 1. Builds search queries from keywords and agent name
62
+ * 2. Searches the vercel-labs/skills repository for skill definitions
63
+ * 3. Searches GitHub broadly for opencode skill-related repositories
64
+ * 4. Tries the OpenCode SDK's skill endpoint (if available)
65
+ * 5. Merges, deduplicates, and scores results
66
+ * 6. Returns the top N results
67
+ *
68
+ * Does NOT search npm.
69
+ * Results are cached on disk for 7 days (skills change less often).
70
+ */
71
+ export declare function discoverSkills(input: DiscoverSkillsInput, ctx: PluginInput): Promise<DiscoverSkillsOutput>;
72
+ /**
73
+ * Create the `discover_skills_online` tool that subagents can call to find
74
+ * installable OpenCode skills for a given task.
75
+ *
76
+ * The tool:
77
+ * 1. Builds search queries from task keywords and agent name
78
+ * 2. Searches the vercel-labs/skills repository and general GitHub for skills
79
+ * 3. Tries the OpenCode SDK's skill endpoint if available
80
+ * 4. Scores each result by relevance (0-1)
81
+ * 5. Marks already-installed skills with `already_installed: true` and
82
+ * only includes them when relevance_score > 0.8
83
+ * 6. Returns the top N recommendations with install commands
84
+ *
85
+ * Does NOT search npm. Skills are knowledge/prompt resources separate from
86
+ * MCP servers (which are tool/capability resources).
87
+ *
88
+ * Results are cached on disk at `~/.config/opencode/discovery-cache.json`
89
+ * with a 7-day TTL and LRU eviction (max 100 entries).
90
+ *
91
+ * @param ctx - The OpenCode plugin input (provides client for SDK access)
92
+ * @returns A `ToolDefinition` ready for registration in the plugin's tool hook
93
+ */
94
+ export declare function createDiscoverSkillsTool(ctx: PluginInput): ToolDefinition;
@@ -0,0 +1,7 @@
1
+ import type { ParsedPatch } from './types';
2
+ export declare function normalizeUnicode(text: string): string;
3
+ export declare function stripHeredoc(input: string): string;
4
+ export declare function normalizePatchText(patchText: string): string;
5
+ export declare function parsePatch(patchText: string): ParsedPatch;
6
+ export declare function parsePatchStrict(patchText: string): ParsedPatch;
7
+ export declare function formatPatch(patch: ParsedPatch): string;
@@ -0,0 +1,25 @@
1
+ import type { ApplyPatchErrorCode, ApplyPatchErrorKind } from './types';
2
+ export declare class ApplyPatchError extends Error {
3
+ readonly kind: ApplyPatchErrorKind;
4
+ readonly code: ApplyPatchErrorCode;
5
+ readonly cause?: unknown;
6
+ constructor(kind: ApplyPatchErrorKind, code: ApplyPatchErrorCode, message: string, options?: {
7
+ cause?: unknown;
8
+ });
9
+ }
10
+ export declare function getErrorMessage(error: unknown): string;
11
+ export declare function createApplyPatchBlockedError(message: string, cause?: unknown): ApplyPatchError;
12
+ export declare function createApplyPatchValidationError(message: string, cause?: unknown): ApplyPatchError;
13
+ export declare function createApplyPatchVerificationError(message: string, cause?: unknown): ApplyPatchError;
14
+ export declare function createApplyPatchInternalError(message: string, cause?: unknown): ApplyPatchError;
15
+ export declare function isApplyPatchError(error: unknown): error is ApplyPatchError;
16
+ export declare function isApplyPatchBlockedError(error: unknown): boolean;
17
+ export declare function isApplyPatchValidationError(error: unknown): boolean;
18
+ export declare function isApplyPatchVerificationError(error: unknown): boolean;
19
+ export declare function isApplyPatchInternalError(error: unknown): boolean;
20
+ export declare function getApplyPatchErrorDetails(error: unknown): {
21
+ kind: ApplyPatchErrorKind;
22
+ code: ApplyPatchErrorCode;
23
+ message: string;
24
+ } | undefined;
25
+ export declare function ensureApplyPatchError(error: unknown, context: string): ApplyPatchError;
@@ -0,0 +1,27 @@
1
+ import { resolveUpdateChunksFromText } from './resolution';
2
+ import type { ApplyPatchRuntimeOptions, PatchHunk, UpdatePatchHunk } from './types';
3
+ export type PreparedFileState = {
4
+ exists: false;
5
+ derived: boolean;
6
+ } | {
7
+ exists: true;
8
+ text: string;
9
+ mode?: number;
10
+ derived: boolean;
11
+ };
12
+ export type PatchExecutionContext = {
13
+ hunks: PatchHunk[];
14
+ pathsNormalized: boolean;
15
+ staged: Map<string, PreparedFileState>;
16
+ getPreparedFileState: (filePath: string, verb: 'update' | 'delete') => Promise<PreparedFileState>;
17
+ assertPreparedPathMissing: (filePath: string, verb: 'add' | 'move') => Promise<void>;
18
+ };
19
+ export type ResolvedPreparedUpdate = {
20
+ resolved: Awaited<ReturnType<typeof resolveUpdateChunksFromText>>['resolved'];
21
+ nextText: string;
22
+ };
23
+ export declare function isMissingPathError(error: unknown): boolean;
24
+ export declare function parseValidatedPatch(patchText: string): PatchHunk[];
25
+ export declare function createPatchExecutionContext(root: string, patchText: string, worktree?: string): Promise<PatchExecutionContext>;
26
+ export declare function resolvePreparedUpdate(filePath: string, currentText: string, hunk: UpdatePatchHunk, cfg: ApplyPatchRuntimeOptions): ResolvedPreparedUpdate;
27
+ export declare function stageAddedText(contents: string): string;
@@ -0,0 +1,15 @@
1
+ import type { PluginInput } from '@opencode-ai/plugin';
2
+ interface ToolExecuteBeforeInput {
3
+ tool: string;
4
+ directory?: string;
5
+ }
6
+ interface ToolExecuteBeforeOutput {
7
+ args?: {
8
+ patchText?: unknown;
9
+ [key: string]: unknown;
10
+ };
11
+ }
12
+ export declare function createApplyPatchHook(ctx: PluginInput): {
13
+ 'tool.execute.before': (input: ToolExecuteBeforeInput, output: ToolExecuteBeforeOutput) => Promise<void>;
14
+ };
15
+ export {};
@@ -0,0 +1,26 @@
1
+ import type { LineComparator, MatchComparatorName, RescueResult, SeekHit } from './types';
2
+ export type PreparedAutoRescueTarget = {
3
+ exact: string;
4
+ unicode: string;
5
+ trimEnd: string;
6
+ unicodeTrimEnd: string;
7
+ };
8
+ export declare function equalExact(a: string, b: string): boolean;
9
+ export declare function equalUnicodeExact(a: string, b: string): boolean;
10
+ export declare function equalTrimEnd(a: string, b: string): boolean;
11
+ export declare function equalUnicodeTrimEnd(a: string, b: string): boolean;
12
+ export declare function equalTrim(a: string, b: string): boolean;
13
+ export declare function equalUnicodeTrim(a: string, b: string): boolean;
14
+ export declare const autoRescueComparators: LineComparator[];
15
+ export declare function prepareAutoRescueTarget(target: string): PreparedAutoRescueTarget;
16
+ export declare function matchPreparedAutoRescueComparator(candidate: string, target: PreparedAutoRescueTarget): MatchComparatorName | undefined;
17
+ export declare const permissiveComparators: LineComparator[];
18
+ export declare function seekMatch(lines: string[], pattern: string[], start: number, eof?: boolean): SeekHit | undefined;
19
+ export declare function seek(lines: string[], pattern: string[], start: number, eof?: boolean): number;
20
+ export declare function list(lines: string[], pattern: string[], start: number, same: LineComparator): number[];
21
+ export declare function sameRescueLine(a: string, b: string): boolean;
22
+ export declare function prefix(old_lines: string[], new_lines: string[]): number;
23
+ export declare function suffix(old_lines: string[], new_lines: string[], prefixLength: number): number;
24
+ export declare function rescueByPrefixSuffix(lines: string[], old_lines: string[], new_lines: string[], start: number): RescueResult;
25
+ export declare function score(a: string[], b: string[]): number;
26
+ export declare function rescueByLcs(lines: string[], old_lines: string[], new_lines: string[], start: number): RescueResult;
@@ -0,0 +1,3 @@
1
+ export { parseValidatedPatch } from './execution-context';
2
+ export { applyPreparedChanges, preparePatchChanges } from './prepared-changes';
3
+ export { rewritePatch, rewritePatchText } from './rewrite';
@@ -0,0 +1,2 @@
1
+ export { parsePatch } from './codec';
2
+ export { preparePatchChanges, rewritePatch, rewritePatchText, } from './operations';
@@ -0,0 +1,17 @@
1
+ import type { ApplyPatchRuntimeOptions, PreparedChange } from './types';
2
+ export declare function preparePatchChanges(root: string, patchText: string, cfg: ApplyPatchRuntimeOptions, worktree?: string): Promise<PreparedChange[]>;
3
+ /**
4
+ * Internal best-effort helper that applies the output of
5
+ * `preparePatchChanges()`: it snapshots all touched paths first and uses
6
+ * temp + rename for writes to regular files. It is not a universal multi-file
7
+ * transaction and is not perfect against concurrent external interference,
8
+ * but it avoids leaving silent partial states on normal apply failures.
9
+ *
10
+ * Contract: although it is exported for local tests/helpers, its expected
11
+ * input is the already prepared output of `preparePatchChanges()`. If it
12
+ * receives manual arrays, it revalidates the basic shape
13
+ * (types/text/normalized absolute paths) and filesystem invariants: it
14
+ * rejects updates/deletes/moves whose source does not exist, and add/move
15
+ * operations whose destination is already occupied.
16
+ */
17
+ export declare function applyPreparedChanges(changes: PreparedChange[]): Promise<void>;
@@ -0,0 +1,19 @@
1
+ import type { ApplyPatchRuntimeOptions, MatchHit, PatchChunk, ResolvedChunk } from './types';
2
+ export declare function readFileLines(file: string): Promise<string[]>;
3
+ export declare function resolveChunkStart(lines: string[], chunk: PatchChunk, start: number): number;
4
+ export declare function locateChunk(lines: string[], file: string, chunk: PatchChunk, start: number, cfg: ApplyPatchRuntimeOptions): ResolvedChunk;
5
+ export declare function applyHits(lines: string[], hits: MatchHit[], eol?: '\n' | '\r\n', hasFinalNewline?: boolean): string;
6
+ export declare function resolveUpdateChunks(file: string, chunks: PatchChunk[], cfg: ApplyPatchRuntimeOptions): Promise<{
7
+ lines: string[];
8
+ resolved: ResolvedChunk[];
9
+ eol: '\n' | '\r\n';
10
+ hasFinalNewline: boolean;
11
+ }>;
12
+ export declare function deriveNewContentFromText(file: string, text: string, chunks: PatchChunk[], cfg: ApplyPatchRuntimeOptions): string;
13
+ export declare function resolveUpdateChunksFromText(file: string, text: string, chunks: PatchChunk[], cfg: ApplyPatchRuntimeOptions): {
14
+ lines: string[];
15
+ resolved: ResolvedChunk[];
16
+ eol: '\n' | '\r\n';
17
+ hasFinalNewline: boolean;
18
+ };
19
+ export declare function deriveNewContent(file: string, chunks: PatchChunk[], cfg: ApplyPatchRuntimeOptions): Promise<string>;
@@ -0,0 +1,7 @@
1
+ import type { ApplyPatchRuntimeOptions } from './types';
2
+ export type RewritePatchResult = {
3
+ patchText: string;
4
+ changed: boolean;
5
+ };
6
+ export declare function rewritePatch(root: string, patchText: string, cfg: ApplyPatchRuntimeOptions, worktree?: string): Promise<RewritePatchResult>;
7
+ export declare function rewritePatchText(root: string, patchText: string, cfg: ApplyPatchRuntimeOptions, worktree?: string): Promise<string>;
@@ -0,0 +1,6 @@
1
+ import type { ApplyPatchRuntimeOptions } from './types';
2
+ export declare const DEFAULT_OPTIONS: ApplyPatchRuntimeOptions;
3
+ export declare function createTempDir(prefix?: string): Promise<string>;
4
+ export declare function writeFixture(root: string, relativePath: string, contents: string): Promise<void>;
5
+ export declare function readText(root: string, relativePath: string): Promise<string>;
6
+ export declare function applyPatch(root: string, patchText: string, cfg?: ApplyPatchRuntimeOptions): Promise<void>;
@@ -0,0 +1,80 @@
1
+ export type ApplyPatchRuntimeOptions = {
2
+ prefixSuffix: boolean;
3
+ lcsRescue: boolean;
4
+ };
5
+ export type ApplyPatchErrorKind = 'blocked' | 'validation' | 'verification' | 'internal';
6
+ export type ApplyPatchErrorCode = 'malformed_patch' | 'outside_workspace' | 'verification_failed' | 'internal_unexpected';
7
+ export type ApplyPatchRescueStrategy = 'prefix/suffix' | 'lcs' | 'anchor';
8
+ export type MatchComparatorName = 'exact' | 'unicode' | 'trim-end' | 'unicode-trim-end' | 'trim' | 'unicode-trim';
9
+ export type PatchChunk = {
10
+ old_lines: string[];
11
+ new_lines: string[];
12
+ change_context?: string;
13
+ is_end_of_file?: boolean;
14
+ };
15
+ export type AddPatchHunk = {
16
+ type: 'add';
17
+ path: string;
18
+ contents: string;
19
+ };
20
+ export type DeletePatchHunk = {
21
+ type: 'delete';
22
+ path: string;
23
+ };
24
+ export type UpdatePatchHunk = {
25
+ type: 'update';
26
+ path: string;
27
+ move_path?: string;
28
+ chunks: PatchChunk[];
29
+ };
30
+ export type PatchHunk = AddPatchHunk | DeletePatchHunk | UpdatePatchHunk;
31
+ export type ParsedPatch = {
32
+ hunks: PatchHunk[];
33
+ };
34
+ export type AddPreparedChange = {
35
+ type: 'add';
36
+ file: string;
37
+ text: string;
38
+ };
39
+ export type DeletePreparedChange = {
40
+ type: 'delete';
41
+ file: string;
42
+ };
43
+ export type UpdatePreparedChange = {
44
+ type: 'update';
45
+ file: string;
46
+ move?: string;
47
+ text: string;
48
+ };
49
+ export type PreparedChange = AddPreparedChange | DeletePreparedChange | UpdatePreparedChange;
50
+ export type MatchHit = {
51
+ start: number;
52
+ del: number;
53
+ add: string[];
54
+ };
55
+ export type SeekHit = {
56
+ index: number;
57
+ comparator: MatchComparatorName;
58
+ exact: boolean;
59
+ };
60
+ export type ResolvedChunk = {
61
+ hit: MatchHit;
62
+ old_lines: string[];
63
+ canonical_old_lines: string[];
64
+ canonical_new_lines: string[];
65
+ canonical_change_context?: string;
66
+ resolved_is_end_of_file: boolean;
67
+ rewritten: boolean;
68
+ strategy?: ApplyPatchRescueStrategy;
69
+ matchComparator?: MatchComparatorName;
70
+ };
71
+ export type RescueResult = {
72
+ kind: 'miss';
73
+ } | {
74
+ kind: 'ambiguous';
75
+ phase: 'prefix_suffix' | 'lcs';
76
+ } | {
77
+ kind: 'match';
78
+ hit: MatchHit;
79
+ };
80
+ export type LineComparator = (a: string, b: string) => boolean;
@@ -0,0 +1,11 @@
1
+ interface AutoUpdateInstallContext {
2
+ installDir: string;
3
+ packageJsonPath: string;
4
+ }
5
+ export declare function resolveInstallContext(runtimePackageJsonPath?: string | null): AutoUpdateInstallContext | null;
6
+ /**
7
+ * Prepares the current install root for a clean re-install of the target version.
8
+ * Returns the install directory to run `bun install` in.
9
+ */
10
+ export declare function preparePackageUpdate(version: string, packageName?: string, runtimePackageJsonPath?: string | null): string | null;
11
+ export {};
@@ -0,0 +1,32 @@
1
+ import type { PluginEntryInfo } from './types';
2
+ /**
3
+ * Extracts the update channel (latest, alpha, beta, etc.) from a version string.
4
+ * @param version The version or tag to analyze.
5
+ * @returns The channel name.
6
+ */
7
+ export declare function extractChannel(version: string | null): string;
8
+ /**
9
+ * Resolves the version of the plugin when running in local development mode.
10
+ */
11
+ export declare function getLocalDevVersion(directory: string): string | null;
12
+ /**
13
+ * Resolves the package.json for the currently running plugin bundle.
14
+ */
15
+ export declare function getCurrentRuntimePackageJsonPath(currentModuleUrl?: string): string | null;
16
+ /**
17
+ * Searches across all config locations to find the current installation entry for this plugin.
18
+ */
19
+ export declare function findPluginEntry(directory: string): PluginEntryInfo | null;
20
+ /**
21
+ * Resolves the installed version from node_modules, with memoization.
22
+ */
23
+ export declare function getCachedVersion(): string | null;
24
+ /**
25
+ * Safely updates a pinned version in the configuration file.
26
+ * It attempts to replace the exact plugin string to preserve comments and formatting.
27
+ */
28
+ export declare function updatePinnedVersion(configPath: string, oldEntry: string, newVersion: string): boolean;
29
+ /**
30
+ * Fetches the latest version for a specific channel from the NPM registry.
31
+ */
32
+ export declare function getLatestVersion(channel?: string): Promise<string | null>;
@@ -0,0 +1,11 @@
1
+ export declare const PACKAGE_NAME = "opencode-dux";
2
+ export declare const NPM_REGISTRY_URL = "https://registry.npmjs.org/-/package/opencode-dux/dist-tags";
3
+ export declare const NPM_FETCH_TIMEOUT = 5000;
4
+ /** The directory used by OpenCode to cache node_modules for plugins. */
5
+ export declare const CACHE_DIR: string;
6
+ /** Path to this plugin's package.json within the OpenCode cache. */
7
+ export declare const INSTALLED_PACKAGE_JSON: string;
8
+ /** Primary OpenCode configuration file path (standard JSON). */
9
+ export declare const USER_OPENCODE_CONFIG: string;
10
+ /** Alternative OpenCode configuration file path (JSON with Comments). */
11
+ export declare const USER_OPENCODE_CONFIG_JSONC: string;
@@ -0,0 +1,18 @@
1
+ import type { PluginInput } from '@opencode-ai/plugin';
2
+ import type { AutoUpdateCheckerOptions } from './types';
3
+ /**
4
+ * Creates an OpenCode hook that checks for plugin updates when a new session is created.
5
+ * @param ctx The plugin input context.
6
+ * @param options Configuration options for the update checker.
7
+ * @returns A hook object for the session.created event.
8
+ */
9
+ export declare function createAutoUpdateCheckerHook(ctx: PluginInput, options?: AutoUpdateCheckerOptions): {
10
+ event: ({ event }: {
11
+ event: {
12
+ type: string;
13
+ properties?: unknown;
14
+ };
15
+ }) => void;
16
+ };
17
+ export declare function getAutoUpdateInstallDir(): string;
18
+ export type { AutoUpdateCheckerOptions } from './types';