opencode-websearch-deepseek 0.1.0 → 0.1.2

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 (3) hide show
  1. package/README.md +10 -1
  2. package/dist/index.js +22 -1
  3. package/package.json +5 -2
package/README.md CHANGED
@@ -18,7 +18,7 @@ source URLs it was based on.
18
18
  - **OpenCode 2.x** with the V2 plugin API (the `plugins` config field). The
19
19
  OpenCode 1.x plugin loader expects the legacy `server()` export and will not
20
20
  load this plugin.
21
- - Node.js 20+ (for `fetch`; OpenCode's runtime already provides it).
21
+ - Node.js 22.14+ (for `fetch`; OpenCode's runtime already provides it).
22
22
  - A DeepSeek API key.
23
23
 
24
24
  ## Install
@@ -88,6 +88,15 @@ can use the normal `websearch` tool without any extra configuration.
88
88
  4. The plugin returns that answer plus the de-duplicated source URLs as
89
89
  `WebSearch.Result` entries.
90
90
 
91
+ ## Releases
92
+
93
+ Releases are automated with [`semantic-release`](https://semantic-release.gitbook.io/)
94
+ from [Conventional Commits](https://www.conventionalcommits.org/) merged to
95
+ `main`: `fix:` → patch, `feat:` → minor, and breaking changes → minor while
96
+ `< 1.0.0`. It publishes to npm via trusted publishing (OIDC) with provenance,
97
+ then tags the commit and creates a GitHub Release. See
98
+ [CONTRIBUTING.md](./CONTRIBUTING.md).
99
+
91
100
  ## Development
92
101
 
93
102
  ```sh
package/dist/index.js CHANGED
@@ -51,6 +51,23 @@ function readEnv(name, env = process.env) {
51
51
  const value = env[name];
52
52
  return value && value.trim() ? value.trim() : undefined;
53
53
  }
54
+ /**
55
+ * Rethrow the cancellation reason from `signal`. `Error` and `DOMException`
56
+ * (e.g. `AbortError`) are preserved as-is; other values (primitives) are
57
+ * normalised to an `Error` so callers always receive one.
58
+ */
59
+ function throwCancellation(signal, fallback) {
60
+ const reason = signal.reason;
61
+ if (reason instanceof Error)
62
+ throw reason;
63
+ if (typeof reason === "object" && reason !== null)
64
+ throw reason;
65
+ if (reason !== undefined && reason !== null)
66
+ throw new Error(String(reason));
67
+ if (fallback instanceof Error)
68
+ throw fallback;
69
+ throw new Error("The web search was aborted");
70
+ }
54
71
  /**
55
72
  * Resolve the `max_uses` value for the search tool declaration.
56
73
  * Falls back to {@link DEFAULT_MAX_USES} for missing or invalid input.
@@ -220,11 +237,15 @@ export const plugin = {
220
237
  const text = await response.text().catch((error) => {
221
238
  // Preserve cancellation: never turn an abort into an API error.
222
239
  if (signal?.aborted)
223
- throw signal.reason ?? error;
240
+ return throwCancellation(signal, error);
224
241
  if (error?.name === "AbortError")
225
242
  throw error;
226
243
  return "";
227
244
  });
245
+ // An abort can also arrive after the body resolves; re-check so it
246
+ // is not masked as an API error.
247
+ if (signal?.aborted)
248
+ throwCancellation(signal, undefined);
228
249
  throw new Error(`DeepSeek API error ${response.status}: ${text.slice(0, 300)}`);
229
250
  }
230
251
  const data = (await response.json());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "opencode-websearch-deepseek",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "description": "DeepSeek-powered web search provider for OpenCode's built-in websearch tool.",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "search"
26
26
  ],
27
27
  "engines": {
28
- "node": ">=20"
28
+ "node": ">=22.14.0"
29
29
  },
30
30
  "main": "./dist/index.js",
31
31
  "types": "./dist/index.d.ts",
@@ -49,7 +49,10 @@
49
49
  "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
50
50
  },
51
51
  "devDependencies": {
52
+ "@commitlint/cli": "^21.2.3",
53
+ "@commitlint/config-conventional": "^21.2.3",
52
54
  "@types/node": "^24.0.0",
55
+ "semantic-release": "^25.0.9",
53
56
  "typescript": "^5.8.2"
54
57
  }
55
58
  }