opencode-search 1.0.0-next.3 → 1.0.0-next.7

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 (44) hide show
  1. package/README.md +7 -7
  2. package/REMOVED.md +3 -3
  3. package/dist/package.json +4 -2
  4. package/dist/src/providers/gnews-search.d.ts +1 -1
  5. package/dist/src/providers/gnews-search.d.ts.map +1 -1
  6. package/dist/src/providers/gnews-search.js +5 -3
  7. package/dist/src/providers/gnews-search.js.map +1 -1
  8. package/dist/src/search.d.ts.map +1 -1
  9. package/dist/src/search.js +35 -25
  10. package/dist/src/search.js.map +1 -1
  11. package/package.json +4 -2
  12. package/search.ts +22 -0
  13. package/src/cache.test.ts +14 -0
  14. package/src/cache.ts +61 -0
  15. package/src/format.test.ts +175 -0
  16. package/src/format.ts +72 -0
  17. package/src/html.ts +39 -0
  18. package/src/normalize-blurb.test.ts +67 -0
  19. package/src/normalize-blurb.ts +22 -0
  20. package/src/opencode/notify.ts +16 -0
  21. package/src/parse-results.test.ts +75 -0
  22. package/src/parse-results.ts +22 -0
  23. package/src/providers/brave-search.ts +39 -0
  24. package/src/providers/bsky-search.test.ts +16 -0
  25. package/src/providers/bsky-search.ts +88 -0
  26. package/src/providers/ddg-search.test.ts +15 -0
  27. package/src/providers/ddg-search.ts +117 -0
  28. package/src/providers/gnews-search.ts +72 -0
  29. package/src/providers/mdn-search.test.ts +17 -0
  30. package/src/providers/mdn-search.ts +83 -0
  31. package/src/providers/standard-search.test.ts +29 -0
  32. package/src/providers/standard-search.ts +94 -0
  33. package/src/providers/wiki-search.test.ts +16 -0
  34. package/src/providers/wiki-search.ts +72 -0
  35. package/src/renderers.test.ts +327 -0
  36. package/src/renderers.ts +51 -0
  37. package/src/safe.test.ts +87 -0
  38. package/src/safe.ts +27 -0
  39. package/src/search.ts +310 -0
  40. package/src/strategies.test.ts +92 -0
  41. package/src/strategies.ts +62 -0
  42. package/src/user-agent.ts +3 -0
  43. package/src/v1-message.test.ts +17 -0
  44. package/src/v1-message.ts +10 -0
package/README.md CHANGED
@@ -40,7 +40,7 @@ Restart OpenCode. The plugin will be installed automatically.
40
40
 
41
41
  ## Tools
42
42
 
43
- ### ddg-search
43
+ ### ddg_search
44
44
 
45
45
  Search the web using DuckDuckGo. Returns structured results with title, URL, and snippet.
46
46
 
@@ -51,7 +51,7 @@ Search the web using DuckDuckGo. Returns structured results with title, URL, and
51
51
  Uses DuckDuckGo's HTML endpoint with POST form parameters to avoid CAPTCHAs.
52
52
  Results are parsed from the HTML response into structured title/URL/abstract triples.
53
53
 
54
- ### brave-search
54
+ ### brave_search
55
55
 
56
56
  Search the web using Brave Search. Returns structured results with title, URL, and snippet.
57
57
 
@@ -61,7 +61,7 @@ Search the web using Brave Search. Returns structured results with title, URL, a
61
61
 
62
62
  Brave serves server-rendered HTML, so it is the most reliable general web provider here.
63
63
 
64
- ### gnews-search
64
+ ### gnews_search
65
65
 
66
66
  Search Google News for recent articles. Returns headline, publisher, and publication date.
67
67
 
@@ -71,7 +71,7 @@ Search Google News for recent articles. Returns headline, publisher, and publica
71
71
 
72
72
  **News and tech media only — not general web search, and not documentation.** It queries the Google News RSS feed, which is a different service from Google web search and still answers plain HTTP requests. Links are `news.google.com` redirect URLs rather than publisher URLs; they resolve only in a browser, so they are reported as-is.
73
73
 
74
- ### bsky-search
74
+ ### bsky_search
75
75
 
76
76
  Search Bluesky posts via the AT Protocol. Returns posts with author handle, text, and engagement counts (likes, reposts, replies).
77
77
 
@@ -81,7 +81,7 @@ Search Bluesky posts via the AT Protocol. Returns posts with author handle, text
81
81
  | `limit` | number | no | Number of results to return |
82
82
  | `sort` | string | no | Sort order: `top` or `latest` |
83
83
 
84
- ### standard-search
84
+ ### standard_search
85
85
 
86
86
  Search [standard.site](https://standard.site) document records on the AT Protocol. Returns blog posts and articles published to the ATmosphere with title, URL, date, and snippet.
87
87
 
@@ -95,7 +95,7 @@ standard.site is a publishing platform built on the AT Protocol where content is
95
95
 
96
96
  **Currently unavailable.** The appview this tool queries, `standard-search.octet-stream.net`, refuses connections, and no replacement endpoint is published on standard.site or in its docs. The provider is left in place unchanged; its live test soft-skips while the host is unreachable, so the suite stays green without masking parser regressions.
97
97
 
98
- ### wiki-search
98
+ ### wiki_search
99
99
 
100
100
  Search Wikipedia articles using the MediaWiki REST API. Returns structured results with title, description, excerpt, and a direct link to the article. No API key required.
101
101
 
@@ -104,7 +104,7 @@ Search Wikipedia articles using the MediaWiki REST API. Returns structured resul
104
104
  | `query` | string | yes | |
105
105
  | `limit` | number | no | Number of results (1-100) |
106
106
 
107
- ### mdn-search
107
+ ### mdn_search
108
108
 
109
109
  Search MDN Web Docs. Returns documentation pages for web technologies with title, URL, and summary. No API key required.
110
110
 
package/REMOVED.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Removed providers
2
2
 
3
- ## ggl-search — Google web search
3
+ ## ggl_search — Google web search
4
4
 
5
5
  Google returns no results to a non-browser client. Since 2025 it requires JavaScript for `/search`: a plain HTTP request gets a redirect stub pointing at `/httpservice/retry/enablejs`, with no results and no inline data in the body. A DOM parser or JS runtime does not help, because the results were never in the response. Legacy and text-browser user agents get a different wall, an "Update your browser" page.
6
6
 
@@ -16,9 +16,9 @@ The gate is applied before the page is built, so TLS fingerprinting is not the v
16
16
 
17
17
  [`googler`](https://github.com/jarun/googler) was archived in 2021, [`googlesearch-python`](https://github.com/Nv7-GitHub/googlesearch) has no commits since 2025-02 and an issue titled "google stop Lynx support" (2025-09), and `yagooglesearch` stopped in 2024.
18
18
 
19
- Use `brave-search` or `ddg-search` instead, or `gnews-search` for news — Google News RSS is a separate service and still answers plain HTTP.
19
+ Use `brave_search` or `ddg_search` instead, or `gnews_search` for news — Google News RSS is a separate service and still answers plain HTTP.
20
20
 
21
- ## mojeek-search — Mojeek
21
+ ## mojeek_search — Mojeek
22
22
 
23
23
  Mojeek's [robots.txt](https://www.mojeek.com/robots.txt) is `Disallow: /search` for all user agents, and their [terms](https://www.mojeek.com/about/terms.html) prohibit automated access except by "an authorised Mojeek API user", stating that "scraping the Services without Our prior consent is expressly prohibited".
24
24
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-search",
3
- "version": "1.0.0-next.3",
3
+ "version": "1.0.0-next.7",
4
4
  "description": "OpenCode plugin that provides web search tools using DuckDuckGo, Brave, Google News, Wikipedia, Bluesky, Standard.site, and MDN Web Docs.",
5
5
  "keywords": [
6
6
  "opencode",
@@ -38,6 +38,8 @@
38
38
  "types": "./dist/search.d.ts",
39
39
  "files": [
40
40
  "dist/",
41
+ "src/",
42
+ "search.ts",
41
43
  "README.md",
42
44
  "REMOVED.md",
43
45
  "LICENSE"
@@ -45,7 +47,7 @@
45
47
  "scripts": {
46
48
  "build": "npm run clean && tsc",
47
49
  "clean": "rm -rf dist",
48
- "prepublishOnly": "npm run build",
50
+ "prepare": "npm run build",
49
51
  "test": "bun test",
50
52
  "typecheck": "tsc --noEmit"
51
53
  },
@@ -5,5 +5,5 @@ export type GnewsResult = {
5
5
  source: string;
6
6
  date: string;
7
7
  };
8
- export declare const gnewsSearch: (query: string) => Promise<GnewsResult[]>;
8
+ export declare const gnewsSearch: (query: string, limit?: number) => Promise<GnewsResult[]>;
9
9
  //# sourceMappingURL=gnews-search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gnews-search.d.ts","sourceRoot":"","sources":["../../../src/providers/gnews-search.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAqBD,eAAO,MAAM,WAAW,GAAU,OAAO,MAAM,KAAG,OAAO,CAAC,WAAW,EAAE,CAmCtE,CAAA"}
1
+ {"version":3,"file":"gnews-search.d.ts","sourceRoot":"","sources":["../../../src/providers/gnews-search.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAwBD,eAAO,MAAM,WAAW,GAAU,OAAO,MAAM,EAAE,cAAqB,KAAG,OAAO,CAAC,WAAW,EAAE,CAmC7F,CAAA"}
@@ -16,11 +16,13 @@ const stripSource = (title, source) => {
16
16
  const suffix = ' - ' + source;
17
17
  return title.endsWith(suffix) ? title.slice(0, -suffix.length) : title;
18
18
  };
19
- export const gnewsSearch = async (query) => {
19
+ // The feed always returns about 100 items, which is ~10k tokens of context for one call.
20
+ const DEFAULT_LIMIT = 20;
21
+ export const gnewsSearch = async (query, limit = DEFAULT_LIMIT) => {
20
22
  const cacheKey = 'gnews:' + query;
21
23
  const cached = await cache.get(cacheKey);
22
24
  if (cached)
23
- return cached;
25
+ return cached.slice(0, limit);
24
26
  const params = new URLSearchParams({ q: query, hl: 'en-US', gl: 'US', ceid: 'US:en' });
25
27
  const res = await fetch(GNEWS_URL + '?' + params, { headers: baseHeaders('') });
26
28
  if (!res.ok)
@@ -43,6 +45,6 @@ export const gnewsSearch = async (query) => {
43
45
  results.push({ title, url, abstract: '', source, date: tag('pubDate') });
44
46
  }
45
47
  await cache.set(cacheKey, results);
46
- return results;
48
+ return results.slice(0, limit);
47
49
  };
48
50
  //# sourceMappingURL=gnews-search.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gnews-search.js","sourceRoot":"","sources":["../../../src/providers/gnews-search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,+FAA+F;AAC/F,MAAM,SAAS,GAAG,oCAAoC,CAAA;AAUtD,MAAM,QAAQ,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AAG,IAAI,CAAC,IAoCjE,CAAA;AAEF,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,CAAC,OAAO,KAAG,IAAI,CAAC,IAAI,EAQpE,CAAA"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,KAAK,IAAI,MAAM,+BAA+B,CAAA;AA0D1D,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,CAAC,OAAO,KAAG,IAAI,CAAC,IAqBjE,CAAA;AAEF,eAAO,MAAM,qBAAqB,GAAI,SAAS,MAAM,CAAC,OAAO,KAAG,IAAI,CAAC,IAqBnE,CAAA;AAEF,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,CAAC,OAAO,KAAG,IAAI,CAAC,IAwClE,CAAA;AAEF,eAAO,MAAM,wBAAwB,GAAI,SAAS,MAAM,CAAC,OAAO,KAAG,IAAI,CAAC,IAyCtE,CAAA;AAEF,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,CAAC,OAAO,KAAG,IAAI,CAAC,IAmClE,CAAA;AAEF,eAAO,MAAM,qBAAqB,GAAI,SAAS,MAAM,CAAC,OAAO,KAAG,IAAI,CAAC,IAkCnE,CAAA;AAEF,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,CAAC,OAAO,KAAG,IAAI,CAAC,IAoCjE,CAAA;AAEF,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,CAAC,OAAO,KAAG,IAAI,CAAC,IAAI,EAQpE,CAAA"}
@@ -12,8 +12,9 @@ import { safeAsync } from "./safe.js";
12
12
  const postResult = async (context, ctx, text) => {
13
13
  await safeAsync(() => sendResult({ context, sessionID: ctx.sessionID, text }));
14
14
  };
15
- const textOutput = (output, text) => ({
16
- output,
15
+ // No `output` field: declaring one without a matching output schema in the tool definition makes
16
+ // OpenCode reject the result.
17
+ const textOutput = (text) => ({
17
18
  content: [{ type: 'text', text }],
18
19
  });
19
20
  const isRecord = (value) => (typeof value === 'object' && value !== null && !Array.isArray(value));
@@ -38,14 +39,14 @@ const queryArg = {
38
39
  additionalProperties: false,
39
40
  };
40
41
  export const createDdgSearchTool = (context) => ({
41
- name: 'ddg-search',
42
+ name: 'ddg_search',
42
43
  description: 'Search DuckDuckGo and return results as extracted text content',
43
44
  input: queryArg,
44
45
  async execute(input, ctx) {
45
46
  const query = stringField(input, 'query');
46
47
  const { data, error } = await safeAsync(() => ddgSearch(query));
47
48
  if (error)
48
- return textOutput({ error: error.message }, 'DuckDuckGo search failed: ' + error.message);
49
+ return textOutput('DuckDuckGo search failed: ' + error.message);
49
50
  const formatted = formatResults({
50
51
  label: 'DuckDuckGo results',
51
52
  items: data,
@@ -53,18 +54,18 @@ export const createDdgSearchTool = (context) => ({
53
54
  renderItem: renderDdgResult,
54
55
  });
55
56
  await postResult(context, ctx, formatted);
56
- return textOutput({ results: data, total: data.length }, 'Search results displayed in chat.');
57
+ return textOutput(formatted);
57
58
  },
58
59
  });
59
60
  export const createBraveSearchTool = (context) => ({
60
- name: 'brave-search',
61
+ name: 'brave_search',
61
62
  description: 'Search the web via Brave Search, returning titles, URLs, and snippets.',
62
63
  input: queryArg,
63
64
  async execute(input, ctx) {
64
65
  const query = stringField(input, 'query');
65
66
  const { data, error } = await safeAsync(() => braveSearch(query));
66
67
  if (error)
67
- return textOutput({ error: error.message }, 'Brave search failed: ' + error.message);
68
+ return textOutput('Brave search failed: ' + error.message);
68
69
  const formatted = formatResults({
69
70
  label: 'Brave results',
70
71
  items: data,
@@ -72,11 +73,11 @@ export const createBraveSearchTool = (context) => ({
72
73
  renderItem: renderWebResult,
73
74
  });
74
75
  await postResult(context, ctx, formatted);
75
- return textOutput({ results: data, total: data.length }, 'Search results displayed in chat.');
76
+ return textOutput(formatted);
76
77
  },
77
78
  });
78
79
  export const createBskySearchTool = (context) => ({
79
- name: 'bsky-search',
80
+ name: 'bsky_search',
80
81
  description: [
81
82
  'Search Bluesky posts via the AT Protocol.',
82
83
  'Returns posts with author, text, and engagement counts.',
@@ -97,7 +98,7 @@ export const createBskySearchTool = (context) => ({
97
98
  const sort = stringField(input, 'sort') || undefined;
98
99
  const { data, error } = await safeAsync(() => (bskySearch({ query, limit, sort })));
99
100
  if (error)
100
- return textOutput({ error: error.message }, 'Bluesky search failed: ' + error.message);
101
+ return textOutput('Bluesky search failed: ' + error.message);
101
102
  const formatted = formatResults({
102
103
  label: 'Bluesky results',
103
104
  items: data.posts,
@@ -107,11 +108,11 @@ export const createBskySearchTool = (context) => ({
107
108
  renderItem: renderBskyPost,
108
109
  });
109
110
  await postResult(context, ctx, formatted);
110
- return textOutput({ results: data.posts, total: data.hitsTotal }, 'Search results displayed in chat.');
111
+ return textOutput(formatted);
111
112
  },
112
113
  });
113
114
  export const createStandardSearchTool = (context) => ({
114
- name: 'standard-search',
115
+ name: 'standard_search',
115
116
  description: [
116
117
  'Search site.standard.document records on the AT Protocol.',
117
118
  'Returns blog posts and articles from the ATmosphere.',
@@ -132,7 +133,7 @@ export const createStandardSearchTool = (context) => ({
132
133
  const offset = numberField(input, 'offset');
133
134
  const { data, error } = await safeAsync(() => (standardSearch({ query, limit, offset })));
134
135
  if (error)
135
- return textOutput({ error: error.message }, 'Standard.site search failed: ' + error.message);
136
+ return textOutput('Standard.site search failed: ' + error.message);
136
137
  const total = Number(data.totalResults) || data.documents.length;
137
138
  const formatted = formatResults({
138
139
  label: 'Standard.site results',
@@ -143,11 +144,11 @@ export const createStandardSearchTool = (context) => ({
143
144
  renderItem: renderStandardDoc,
144
145
  });
145
146
  await postResult(context, ctx, formatted);
146
- return textOutput({ results: data.documents, total }, 'Search results displayed in chat.');
147
+ return textOutput(formatted);
147
148
  },
148
149
  });
149
150
  export const createWikiSearchTool = (context) => ({
150
- name: 'wiki-search',
151
+ name: 'wiki_search',
151
152
  description: 'Search Wikipedia articles. Returns page titles, descriptions, and excerpts.',
152
153
  input: {
153
154
  type: 'object',
@@ -163,7 +164,7 @@ export const createWikiSearchTool = (context) => ({
163
164
  const limit = numberField(input, 'limit');
164
165
  const { data, error } = await safeAsync(() => (wikiSearch({ query, limit })));
165
166
  if (error)
166
- return textOutput({ error: error.message }, 'Wikipedia search failed: ' + error.message);
167
+ return textOutput('Wikipedia search failed: ' + error.message);
167
168
  const formatted = formatResults({
168
169
  label: 'Wikipedia results',
169
170
  items: data.pages,
@@ -173,22 +174,31 @@ export const createWikiSearchTool = (context) => ({
173
174
  renderItem: renderWikiPage,
174
175
  });
175
176
  await postResult(context, ctx, formatted);
176
- return textOutput({ results: data.pages, total: data.pages.length }, 'Search results displayed in chat.');
177
+ return textOutput(formatted);
177
178
  },
178
179
  });
179
180
  export const createGnewsSearchTool = (context) => ({
180
- name: 'gnews-search',
181
+ name: 'gnews_search',
181
182
  description: [
182
183
  'Search Google News for recent articles, returning headlines, publishers, and dates.',
183
184
  'News and tech media only — not general web search, and not documentation.',
184
185
  'Links are news.google.com redirect URLs, not publisher URLs.',
185
186
  ].join(' '),
186
- input: queryArg,
187
+ input: {
188
+ type: 'object',
189
+ properties: {
190
+ query: { type: 'string', description: 'The search query' },
191
+ limit: { type: 'number', description: 'Maximum number of results to return (default 20)' },
192
+ },
193
+ required: ['query'],
194
+ additionalProperties: false,
195
+ },
187
196
  async execute(input, ctx) {
188
197
  const query = stringField(input, 'query');
189
- const { data, error } = await safeAsync(() => gnewsSearch(query));
198
+ const limit = numberField(input, 'limit');
199
+ const { data, error } = await safeAsync(() => gnewsSearch(query, limit));
190
200
  if (error)
191
- return textOutput({ error: error.message }, 'Google News search failed: ' + error.message);
201
+ return textOutput('Google News search failed: ' + error.message);
192
202
  const formatted = formatResults({
193
203
  label: 'Google News results',
194
204
  items: data,
@@ -196,11 +206,11 @@ export const createGnewsSearchTool = (context) => ({
196
206
  renderItem: renderGnewsItem,
197
207
  });
198
208
  await postResult(context, ctx, formatted);
199
- return textOutput({ results: data, total: data.length }, 'Search results displayed in chat.');
209
+ return textOutput(formatted);
200
210
  },
201
211
  });
202
212
  export const createMdnSearchTool = (context) => ({
203
- name: 'mdn-search',
213
+ name: 'mdn_search',
204
214
  description: 'Search MDN Web Docs. Returns documentation pages for web technologies.',
205
215
  input: {
206
216
  type: 'object',
@@ -218,7 +228,7 @@ export const createMdnSearchTool = (context) => ({
218
228
  const page = numberField(input, 'page');
219
229
  const { data, error } = await safeAsync(() => (mdnSearch({ query, limit, page })));
220
230
  if (error)
221
- return textOutput({ error: error.message }, 'MDN search failed: ' + error.message);
231
+ return textOutput('MDN search failed: ' + error.message);
222
232
  const formatted = formatResults({
223
233
  label: 'MDN Web Docs results',
224
234
  items: data.documents,
@@ -227,7 +237,7 @@ export const createMdnSearchTool = (context) => ({
227
237
  renderItem: renderMdnDoc,
228
238
  });
229
239
  await postResult(context, ctx, formatted);
230
- return textOutput({ results: data.documents, total: data.total }, 'Search results displayed in chat.');
240
+ return textOutput(formatted);
231
241
  },
232
242
  });
233
243
  export const createSearchTools = (context) => [
@@ -1 +1 @@
1
- {"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/search.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EACL,cAAc,EACd,eAAe,EACf,eAAe,EACf,YAAY,EAC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C7B,mBAAmB,CAAC,OAAO,CAAC;IAC5B,qBAAqB,CAAC,OAAO,CAAC;IAC9B,mBAAmB,CAAC,OAAO,CAAC;IAC5B,wBAAwB,CAAC,OAAO,CAAC;IACjC,oBAAoB,CAAC,OAAO,CAAC;CAC9B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-search",
3
- "version": "1.0.0-next.3",
3
+ "version": "1.0.0-next.7",
4
4
  "description": "OpenCode plugin that provides web search tools using DuckDuckGo, Brave, Google News, Wikipedia, Bluesky, Standard.site, and MDN Web Docs.",
5
5
  "keywords": [
6
6
  "opencode",
@@ -38,6 +38,8 @@
38
38
  "types": "./dist/search.d.ts",
39
39
  "files": [
40
40
  "dist/",
41
+ "src/",
42
+ "search.ts",
41
43
  "README.md",
42
44
  "REMOVED.md",
43
45
  "LICENSE"
@@ -45,7 +47,7 @@
45
47
  "scripts": {
46
48
  "build": "npm run clean && tsc",
47
49
  "clean": "rm -rf dist",
48
- "prepublishOnly": "npm run build",
50
+ "prepare": "npm run build",
49
51
  "test": "bun test",
50
52
  "typecheck": "tsc --noEmit"
51
53
  },
package/search.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { createSearchTools } from './src/search.ts'
2
+ import { safeAsync } from './src/safe.ts'
3
+ import { V1_MESSAGE } from './src/v1-message.ts'
4
+
5
+ // Under OpenCode 1 this package is absent or exports no Plugin.define.
6
+ // A dynamic import makes that catchable, so the failure can be a message instead of a stack trace.
7
+ const { data: plugin, error } = await safeAsync(() => import('@opencode/plugin'))
8
+
9
+ if (error || typeof plugin.Plugin?.define !== 'function') {
10
+ throw new Error(V1_MESSAGE, { cause: error ?? new Error('Plugin.define is not exported') })
11
+ }
12
+
13
+ export default plugin.Plugin.define({
14
+ id: 'opencode-search',
15
+ setup: async (ctx) => {
16
+ await ctx.tool.transform((tools) => {
17
+ for (const definition of createSearchTools(ctx)) {
18
+ tools.add(definition)
19
+ }
20
+ })
21
+ },
22
+ })
@@ -0,0 +1,14 @@
1
+ import { describe, expect, it } from 'bun:test'
2
+ import { get, set } from './cache.ts'
3
+
4
+ describe('cache', () => {
5
+ it('stores and retrieves data', async () => {
6
+ const testKey = 'test:cache-key'
7
+ const testData = { foo: 'bar', nested: { value: 123 } }
8
+
9
+ await set(testKey, testData)
10
+ const result = await get(testKey)
11
+
12
+ expect(result).toEqual(testData)
13
+ })
14
+ })
package/src/cache.ts ADDED
@@ -0,0 +1,61 @@
1
+ import { readFile, writeFile } from 'node:fs/promises'
2
+ import { dirname, join } from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+ import { safe, safeAsync } from './safe.ts'
5
+
6
+ const CACHE_FILE = join(dirname(fileURLToPath(import.meta.url)), '..', '..', '.cache')
7
+ const CACHE_DURATION = 7 * 24 * 60 * 60 * 1000 // 7 days
8
+
9
+ type CacheEntry = {
10
+ data: unknown
11
+ timestamp: number
12
+ }
13
+
14
+ type CacheStore = Record<string, CacheEntry>
15
+
16
+ let store: CacheStore = {}
17
+ let loaded = false
18
+
19
+ const loadCache = async () => {
20
+ if (loaded) return
21
+
22
+ const { data } = await safeAsync(() => readFile(CACHE_FILE, 'utf-8'))
23
+
24
+ if (data) {
25
+ const { data: parsed } = safe(() => JSON.parse(data) as CacheStore)
26
+ store = parsed ?? {}
27
+ }
28
+
29
+ loaded = true
30
+ }
31
+
32
+ const saveCache = async () => {
33
+ await writeFile(CACHE_FILE, JSON.stringify(store, null, 2))
34
+ }
35
+
36
+ export const get = async <T = unknown>(key: string): Promise<T | null> => {
37
+ await loadCache()
38
+
39
+ const entry = store[key]
40
+ if (!entry) return null
41
+
42
+ const age = Date.now() - entry.timestamp
43
+ if (age > CACHE_DURATION) {
44
+ delete store[key]
45
+ await saveCache()
46
+ return null
47
+ }
48
+
49
+ return entry.data as T
50
+ }
51
+
52
+ export const set = async (key: string, data: unknown): Promise<void> => {
53
+ await loadCache()
54
+
55
+ store[key] = {
56
+ data,
57
+ timestamp: Date.now(),
58
+ }
59
+
60
+ await saveCache()
61
+ }