opencode-search 1.0.0-next.7 → 1.0.0-next.8
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.
- package/README.md +4 -18
- package/REMOVED.md +10 -0
- package/dist/package.json +3 -4
- package/dist/src/renderers.d.ts +0 -2
- package/dist/src/renderers.d.ts.map +1 -1
- package/dist/src/renderers.js +0 -8
- package/dist/src/renderers.js.map +1 -1
- package/dist/src/search.d.ts +0 -1
- package/dist/src/search.d.ts.map +1 -1
- package/dist/src/search.js +1 -39
- package/dist/src/search.js.map +1 -1
- package/package.json +3 -4
- package/src/renderers.test.ts +0 -64
- package/src/renderers.ts +0 -9
- package/src/search.ts +0 -46
- package/dist/src/providers/standard-search.d.ts +0 -18
- package/dist/src/providers/standard-search.d.ts.map +0 -1
- package/dist/src/providers/standard-search.js +0 -61
- package/dist/src/providers/standard-search.js.map +0 -1
- package/src/providers/standard-search.test.ts +0 -29
- package/src/providers/standard-search.ts +0 -94
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# opencode-search
|
|
2
2
|
|
|
3
|
-
An [OpenCode](https://opencode.ai) plugin that gives your agent access to DuckDuckGo, Brave, Google News, Wikipedia, Bluesky,
|
|
3
|
+
An [OpenCode](https://opencode.ai) plugin that gives your agent access to DuckDuckGo, Brave, Google News, Wikipedia, Bluesky, and MDN Web Docs.
|
|
4
4
|
|
|
5
5
|
<img width="786" height="377" alt="image" src="https://github.com/user-attachments/assets/9ad19ade-402a-4cc1-9882-a33d2a8e4d42" />
|
|
6
6
|
|
|
7
7
|
## What this adds over OpenCode's built-in tools
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Six search tools that work without an API key. OpenCode 1 has no web search at all unless you use its own provider, and OpenCode 2's requires a key for Exa, Firecrawl, Parallel or Tavily.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Four of the tools search sources a general web search does not reach: Bluesky posts through the AT Protocol, Wikipedia and MDN through their own APIs, and Google News for what is being published now.
|
|
12
12
|
|
|
13
13
|
**Use at your own risk:** the DuckDuckGo and Brave providers scrape HTML nobody promised would stay parseable, so they can break without warning and may run against a service's terms. Results are unverified input.
|
|
14
14
|
|
|
15
|
-
Google web search and
|
|
15
|
+
Google web search, Mojeek and standard.site were removed — see [REMOVED.md](REMOVED.md) for what was tested and why.
|
|
16
16
|
|
|
17
17
|
## Quick Start
|
|
18
18
|
|
|
@@ -81,20 +81,6 @@ 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
|
|
85
|
-
|
|
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
|
-
|
|
88
|
-
| Parameter | Type | Required | Description |
|
|
89
|
-
| --------- | ------ | -------- | ---------------------------------- |
|
|
90
|
-
| `query` | string | yes | |
|
|
91
|
-
| `limit` | number | no | Number of results to return |
|
|
92
|
-
| `offset` | number | no | Number of results to skip |
|
|
93
|
-
|
|
94
|
-
standard.site is a publishing platform built on the AT Protocol where content is stored in a user's personal data repository. Unlike traditional websites that require crawlers and indexing pipelines to be discoverable, content published on standard.site is structured, portable, and directly queryable through the AT Protocol.
|
|
95
|
-
|
|
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
|
-
|
|
98
84
|
### wiki_search
|
|
99
85
|
|
|
100
86
|
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.
|
package/REMOVED.md
CHANGED
|
@@ -18,6 +18,16 @@ The gate is applied before the page is built, so TLS fingerprinting is not the v
|
|
|
18
18
|
|
|
19
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
|
+
## standard_search — standard.site
|
|
22
|
+
|
|
23
|
+
The appview this tool queried, `standard-search.octet-stream.net`, no longer resolves. Checked 2026-09-19: no DNS record at all, so the host is gone rather than temporarily down.
|
|
24
|
+
|
|
25
|
+
standard.site itself is alive and answers on `/`, but publishes no replacement search endpoint. `/docs` returns 200 and mentions none; `/api`, `/about` and `/developers` are 404.
|
|
26
|
+
|
|
27
|
+
The provider had been kept in place with its live test soft-skipping while the host was unreachable. With the DNS record gone and nothing documented to point at, there is no endpoint to restore it to.
|
|
28
|
+
|
|
29
|
+
Worth revisiting if standard.site publishes an appview again — the AT Protocol records it searched are structured and directly queryable, which no general web search substitutes for.
|
|
30
|
+
|
|
21
31
|
## mojeek_search — Mojeek
|
|
22
32
|
|
|
23
33
|
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".
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-search",
|
|
3
|
-
"version": "1.0.0-next.
|
|
4
|
-
"description": "OpenCode plugin that provides web search tools using DuckDuckGo, Brave, Google News, Wikipedia, Bluesky,
|
|
3
|
+
"version": "1.0.0-next.8",
|
|
4
|
+
"description": "OpenCode plugin that provides web search tools using DuckDuckGo, Brave, Google News, Wikipedia, Bluesky, and MDN Web Docs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
7
7
|
"opencode-plugin",
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
"wikipedia",
|
|
15
15
|
"mdn",
|
|
16
16
|
"bluesky",
|
|
17
|
-
"atproto"
|
|
18
|
-
"standard-site"
|
|
17
|
+
"atproto"
|
|
19
18
|
],
|
|
20
19
|
"homepage": "https://github.com/whaaaley/opencode-search#readme",
|
|
21
20
|
"bugs": {
|
package/dist/src/renderers.d.ts
CHANGED
|
@@ -2,13 +2,11 @@ import type { BskyPost } from './providers/bsky-search.ts';
|
|
|
2
2
|
import type { DdgResult } from './providers/ddg-search.ts';
|
|
3
3
|
import type { GnewsResult } from './providers/gnews-search.ts';
|
|
4
4
|
import type { MdnDocument } from './providers/mdn-search.ts';
|
|
5
|
-
import type { StandardDocument } from './providers/standard-search.ts';
|
|
6
5
|
import type { WikiPage } from './providers/wiki-search.ts';
|
|
7
6
|
export declare const renderDdgResult: (result: DdgResult, index: number) => string;
|
|
8
7
|
export declare const renderWebResult: (result: DdgResult, index: number) => string;
|
|
9
8
|
export declare const renderGnewsItem: (result: GnewsResult, index: number) => string;
|
|
10
9
|
export declare const renderBskyPost: (post: BskyPost, index: number) => string;
|
|
11
|
-
export declare const renderStandardDoc: (doc: StandardDocument, index: number) => string;
|
|
12
10
|
export declare const renderWikiPage: (page: WikiPage, index: number) => string;
|
|
13
11
|
export declare const renderMdnDoc: (doc: MdnDocument, index: number) => string;
|
|
14
12
|
//# sourceMappingURL=renderers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderers.d.ts","sourceRoot":"","sources":["../../src/renderers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"renderers.d.ts","sourceRoot":"","sources":["../../src/renderers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAE1D,eAAO,MAAM,eAAe,GAAI,QAAQ,SAAS,EAAE,OAAO,MAAM,KAAG,MAIlE,CAAA;AAGD,eAAO,MAAM,eAAe,WAPY,SAAS,SAAS,MAAM,KAAG,MAOrB,CAAA;AAE9C,eAAO,MAAM,eAAe,GAAI,QAAQ,WAAW,EAAE,OAAO,MAAM,KAAG,MAIpE,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,KAAG,MAI9D,CAAA;AAGD,eAAO,MAAM,cAAc,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,KAAG,MAK9D,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,KAAK,WAAW,EAAE,OAAO,MAAM,KAAG,MAI9D,CAAA"}
|
package/dist/src/renderers.js
CHANGED
|
@@ -15,14 +15,6 @@ export const renderGnewsItem = (result, index) => {
|
|
|
15
15
|
export const renderBskyPost = (post, index) => (`${index + 1}. @${post.author.handle} (${formatDateTime(post.record.createdAt)})
|
|
16
16
|
${normalizeBlurb(post.record.text)}
|
|
17
17
|
Likes: ${post.likeCount} Reposts: ${post.repostCount} Replies: ${post.replyCount}`);
|
|
18
|
-
export const renderStandardDoc = (doc, index) => {
|
|
19
|
-
const title = doc.date
|
|
20
|
-
? `${index + 1}. ${doc.title} (${formatDate(doc.date)})`
|
|
21
|
-
: `${index + 1}. ${doc.title}`;
|
|
22
|
-
return `${title}
|
|
23
|
-
${doc.url}
|
|
24
|
-
${normalizeBlurb(doc.snippet)}`;
|
|
25
|
-
};
|
|
26
18
|
export const renderWikiPage = (page, index) => {
|
|
27
19
|
const desc = page.description ? `\n ${normalizeBlurb(page.description)}` : '';
|
|
28
20
|
return `${index + 1}. ${page.title}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderers.js","sourceRoot":"","sources":["../../src/renderers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"renderers.js","sourceRoot":"","sources":["../../src/renderers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAOrD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAiB,EAAE,KAAa,EAAU,EAAE;IAC1E,OAAO,GAAG,KAAK,GAAG,CAAC,KAAK,MAAM,CAAC,KAAK;KACjC,MAAM,CAAC,GAAG;KACV,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;AACtC,CAAC,CAAA;AAED,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAA;AAE9C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAmB,EAAE,KAAa,EAAU,EAAE;IAC5E,OAAO,GAAG,KAAK,GAAG,CAAC,KAAK,MAAM,CAAC,KAAK;KACjC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;KAClE,MAAM,CAAC,GAAG,EAAE,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAc,EAAE,KAAa,EAAU,EAAE,CAAC,CACvE,GAAG,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;KAC3E,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACzB,IAAI,CAAC,SAAS,cAAc,IAAI,CAAC,WAAW,cAAc,IAAI,CAAC,UAAU,EAAE,CACtF,CAAA;AAGD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAc,EAAE,KAAa,EAAU,EAAE;IACtE,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/E,OAAO,GAAG,KAAK,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK;mCACD,IAAI,CAAC,GAAG,GAAG,IAAI;KAC7C,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAA;AACnC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAgB,EAAE,KAAa,EAAU,EAAE;IACtE,OAAO,GAAG,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK;kCACD,GAAG,CAAC,OAAO;KACxC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAA;AAClC,CAAC,CAAA"}
|
package/dist/src/search.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type * as Tool from '@opencode/plugin/promise/tool';
|
|
|
3
3
|
export declare const createDdgSearchTool: (context: Plugin.Context) => Tool.Info;
|
|
4
4
|
export declare const createBraveSearchTool: (context: Plugin.Context) => Tool.Info;
|
|
5
5
|
export declare const createBskySearchTool: (context: Plugin.Context) => Tool.Info;
|
|
6
|
-
export declare const createStandardSearchTool: (context: Plugin.Context) => Tool.Info;
|
|
7
6
|
export declare const createWikiSearchTool: (context: Plugin.Context) => Tool.Info;
|
|
8
7
|
export declare const createGnewsSearchTool: (context: Plugin.Context) => Tool.Info;
|
|
9
8
|
export declare const createMdnSearchTool: (context: Plugin.Context) => Tool.Info;
|
package/dist/src/search.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAwD1D,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,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,EAOpE,CAAA"}
|
package/dist/src/search.js
CHANGED
|
@@ -5,9 +5,8 @@ import { bskySearch } from "./providers/bsky-search.js";
|
|
|
5
5
|
import { ddgSearch } from "./providers/ddg-search.js";
|
|
6
6
|
import { gnewsSearch } from "./providers/gnews-search.js";
|
|
7
7
|
import { mdnSearch } from "./providers/mdn-search.js";
|
|
8
|
-
import { standardSearch } from "./providers/standard-search.js";
|
|
9
8
|
import { wikiSearch } from "./providers/wiki-search.js";
|
|
10
|
-
import { renderBskyPost, renderDdgResult, renderGnewsItem, renderMdnDoc,
|
|
9
|
+
import { renderBskyPost, renderDdgResult, renderGnewsItem, renderMdnDoc, renderWebResult, renderWikiPage, } from "./renderers.js";
|
|
11
10
|
import { safeAsync } from "./safe.js";
|
|
12
11
|
const postResult = async (context, ctx, text) => {
|
|
13
12
|
await safeAsync(() => sendResult({ context, sessionID: ctx.sessionID, text }));
|
|
@@ -111,42 +110,6 @@ export const createBskySearchTool = (context) => ({
|
|
|
111
110
|
return textOutput(formatted);
|
|
112
111
|
},
|
|
113
112
|
});
|
|
114
|
-
export const createStandardSearchTool = (context) => ({
|
|
115
|
-
name: 'standard_search',
|
|
116
|
-
description: [
|
|
117
|
-
'Search site.standard.document records on the AT Protocol.',
|
|
118
|
-
'Returns blog posts and articles from the ATmosphere.',
|
|
119
|
-
].join(' '),
|
|
120
|
-
input: {
|
|
121
|
-
type: 'object',
|
|
122
|
-
properties: {
|
|
123
|
-
query: { type: 'string', description: 'The search query' },
|
|
124
|
-
limit: { type: 'number', description: 'Maximum number of results to return' },
|
|
125
|
-
offset: { type: 'number', description: 'Number of results to skip' },
|
|
126
|
-
},
|
|
127
|
-
required: ['query'],
|
|
128
|
-
additionalProperties: false,
|
|
129
|
-
},
|
|
130
|
-
async execute(input, ctx) {
|
|
131
|
-
const query = stringField(input, 'query');
|
|
132
|
-
const limit = numberField(input, 'limit');
|
|
133
|
-
const offset = numberField(input, 'offset');
|
|
134
|
-
const { data, error } = await safeAsync(() => (standardSearch({ query, limit, offset })));
|
|
135
|
-
if (error)
|
|
136
|
-
return textOutput('Standard.site search failed: ' + error.message);
|
|
137
|
-
const total = Number(data.totalResults) || data.documents.length;
|
|
138
|
-
const formatted = formatResults({
|
|
139
|
-
label: 'Standard.site results',
|
|
140
|
-
items: data.documents,
|
|
141
|
-
total,
|
|
142
|
-
limit,
|
|
143
|
-
offset,
|
|
144
|
-
renderItem: renderStandardDoc,
|
|
145
|
-
});
|
|
146
|
-
await postResult(context, ctx, formatted);
|
|
147
|
-
return textOutput(formatted);
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
113
|
export const createWikiSearchTool = (context) => ({
|
|
151
114
|
name: 'wiki_search',
|
|
152
115
|
description: 'Search Wikipedia articles. Returns page titles, descriptions, and excerpts.',
|
|
@@ -246,7 +209,6 @@ export const createSearchTools = (context) => [
|
|
|
246
209
|
createDdgSearchTool(context),
|
|
247
210
|
createGnewsSearchTool(context),
|
|
248
211
|
createMdnSearchTool(context),
|
|
249
|
-
createStandardSearchTool(context),
|
|
250
212
|
createWikiSearchTool(context),
|
|
251
213
|
];
|
|
252
214
|
//# sourceMappingURL=search.js.map
|
package/dist/src/search.js.map
CHANGED
|
@@ -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,
|
|
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,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AC;IAC7B,mBAAmB,CAAC,OAAO,CAAC;IAC5B,qBAAqB,CAAC,OAAO,CAAC;IAC9B,mBAAmB,CAAC,OAAO,CAAC;IAC5B,oBAAoB,CAAC,OAAO,CAAC;CAC9B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-search",
|
|
3
|
-
"version": "1.0.0-next.
|
|
4
|
-
"description": "OpenCode plugin that provides web search tools using DuckDuckGo, Brave, Google News, Wikipedia, Bluesky,
|
|
3
|
+
"version": "1.0.0-next.8",
|
|
4
|
+
"description": "OpenCode plugin that provides web search tools using DuckDuckGo, Brave, Google News, Wikipedia, Bluesky, and MDN Web Docs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
7
7
|
"opencode-plugin",
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
"wikipedia",
|
|
15
15
|
"mdn",
|
|
16
16
|
"bluesky",
|
|
17
|
-
"atproto"
|
|
18
|
-
"standard-site"
|
|
17
|
+
"atproto"
|
|
19
18
|
],
|
|
20
19
|
"homepage": "https://github.com/whaaaley/opencode-search#readme",
|
|
21
20
|
"bugs": {
|
package/src/renderers.test.ts
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
renderDdgResult,
|
|
5
5
|
renderGnewsItem,
|
|
6
6
|
renderMdnDoc,
|
|
7
|
-
renderStandardDoc,
|
|
8
7
|
renderWebResult,
|
|
9
8
|
renderWikiPage,
|
|
10
9
|
} from './renderers.ts'
|
|
@@ -134,69 +133,6 @@ describe('renderBskyPost', () => {
|
|
|
134
133
|
})
|
|
135
134
|
})
|
|
136
135
|
|
|
137
|
-
describe('renderStandardDoc', () => {
|
|
138
|
-
it('includes date in title line when date is present', () => {
|
|
139
|
-
const doc = {
|
|
140
|
-
title: 'My Article',
|
|
141
|
-
url: 'https://example.com/article',
|
|
142
|
-
date: '2025-03-10',
|
|
143
|
-
snippet: 'Article snippet text',
|
|
144
|
-
}
|
|
145
|
-
const lines = renderStandardDoc(doc, 0).split('\n')
|
|
146
|
-
expect(lines[0]).toContain('1. My Article')
|
|
147
|
-
expect(lines[0]).toContain('Mar')
|
|
148
|
-
expect(lines[0]).toContain('2025')
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
it('omits date from title line when date is empty', () => {
|
|
152
|
-
const doc = {
|
|
153
|
-
title: 'No Date Article',
|
|
154
|
-
url: 'https://example.com/nodate',
|
|
155
|
-
date: '',
|
|
156
|
-
snippet: 'Snippet',
|
|
157
|
-
}
|
|
158
|
-
const lines = renderStandardDoc(doc, 0).split('\n')
|
|
159
|
-
expect(lines[0]).toBe('1. No Date Article')
|
|
160
|
-
expect(lines[0]).not.toContain('(')
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
it('returns three lines: title, url, snippet', () => {
|
|
164
|
-
const doc = {
|
|
165
|
-
title: 'Title',
|
|
166
|
-
url: 'https://example.com',
|
|
167
|
-
date: '',
|
|
168
|
-
snippet: 'Snippet text',
|
|
169
|
-
}
|
|
170
|
-
const lines = renderStandardDoc(doc, 0).split('\n')
|
|
171
|
-
expect(lines).toHaveLength(3)
|
|
172
|
-
expect(lines[1]).toContain('https://example.com')
|
|
173
|
-
expect(lines[2]).toContain('Snippet text')
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
it('uses 1-based index', () => {
|
|
177
|
-
const doc = {
|
|
178
|
-
title: 'Title',
|
|
179
|
-
url: 'https://example.com',
|
|
180
|
-
date: '',
|
|
181
|
-
snippet: 'Snippet',
|
|
182
|
-
}
|
|
183
|
-
const lines = renderStandardDoc(doc, 9).split('\n')
|
|
184
|
-
expect(lines[0]).toStartWith('10. ')
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
it('indents url and snippet lines', () => {
|
|
188
|
-
const doc = {
|
|
189
|
-
title: 'Title',
|
|
190
|
-
url: 'https://example.com',
|
|
191
|
-
date: '',
|
|
192
|
-
snippet: 'Snippet',
|
|
193
|
-
}
|
|
194
|
-
const lines = renderStandardDoc(doc, 0).split('\n')
|
|
195
|
-
expect(lines[1]).toStartWith(' ')
|
|
196
|
-
expect(lines[2]).toStartWith(' ')
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
|
|
200
136
|
describe('renderWikiPage', () => {
|
|
201
137
|
it('includes title and wikipedia url', () => {
|
|
202
138
|
const result = renderWikiPage({
|
package/src/renderers.ts
CHANGED
|
@@ -4,7 +4,6 @@ import type { BskyPost } from './providers/bsky-search.ts'
|
|
|
4
4
|
import type { DdgResult } from './providers/ddg-search.ts'
|
|
5
5
|
import type { GnewsResult } from './providers/gnews-search.ts'
|
|
6
6
|
import type { MdnDocument } from './providers/mdn-search.ts'
|
|
7
|
-
import type { StandardDocument } from './providers/standard-search.ts'
|
|
8
7
|
import type { WikiPage } from './providers/wiki-search.ts'
|
|
9
8
|
|
|
10
9
|
export const renderDdgResult = (result: DdgResult, index: number): string => {
|
|
@@ -28,14 +27,6 @@ export const renderBskyPost = (post: BskyPost, index: number): string => (
|
|
|
28
27
|
Likes: ${post.likeCount} Reposts: ${post.repostCount} Replies: ${post.replyCount}`
|
|
29
28
|
)
|
|
30
29
|
|
|
31
|
-
export const renderStandardDoc = (doc: StandardDocument, index: number): string => {
|
|
32
|
-
const title = doc.date
|
|
33
|
-
? `${index + 1}. ${doc.title} (${formatDate(doc.date)})`
|
|
34
|
-
: `${index + 1}. ${doc.title}`
|
|
35
|
-
return `${title}
|
|
36
|
-
${doc.url}
|
|
37
|
-
${normalizeBlurb(doc.snippet)}`
|
|
38
|
-
}
|
|
39
30
|
|
|
40
31
|
export const renderWikiPage = (page: WikiPage, index: number): string => {
|
|
41
32
|
const desc = page.description ? `\n ${normalizeBlurb(page.description)}` : ''
|
package/src/search.ts
CHANGED
|
@@ -7,14 +7,12 @@ import { bskySearch } from './providers/bsky-search.ts'
|
|
|
7
7
|
import { ddgSearch } from './providers/ddg-search.ts'
|
|
8
8
|
import { gnewsSearch } from './providers/gnews-search.ts'
|
|
9
9
|
import { mdnSearch } from './providers/mdn-search.ts'
|
|
10
|
-
import { standardSearch } from './providers/standard-search.ts'
|
|
11
10
|
import { wikiSearch } from './providers/wiki-search.ts'
|
|
12
11
|
import {
|
|
13
12
|
renderBskyPost,
|
|
14
13
|
renderDdgResult,
|
|
15
14
|
renderGnewsItem,
|
|
16
15
|
renderMdnDoc,
|
|
17
|
-
renderStandardDoc,
|
|
18
16
|
renderWebResult,
|
|
19
17
|
renderWikiPage,
|
|
20
18
|
} from './renderers.ts'
|
|
@@ -145,49 +143,6 @@ export const createBskySearchTool = (context: Plugin.Context): Tool.Info => ({
|
|
|
145
143
|
},
|
|
146
144
|
})
|
|
147
145
|
|
|
148
|
-
export const createStandardSearchTool = (context: Plugin.Context): Tool.Info => ({
|
|
149
|
-
name: 'standard_search',
|
|
150
|
-
description: [
|
|
151
|
-
'Search site.standard.document records on the AT Protocol.',
|
|
152
|
-
'Returns blog posts and articles from the ATmosphere.',
|
|
153
|
-
].join(' '),
|
|
154
|
-
input: {
|
|
155
|
-
type: 'object',
|
|
156
|
-
properties: {
|
|
157
|
-
query: { type: 'string', description: 'The search query' },
|
|
158
|
-
limit: { type: 'number', description: 'Maximum number of results to return' },
|
|
159
|
-
offset: { type: 'number', description: 'Number of results to skip' },
|
|
160
|
-
},
|
|
161
|
-
required: ['query'],
|
|
162
|
-
additionalProperties: false,
|
|
163
|
-
},
|
|
164
|
-
async execute(input, ctx) {
|
|
165
|
-
const query = stringField(input, 'query')
|
|
166
|
-
const limit = numberField(input, 'limit')
|
|
167
|
-
const offset = numberField(input, 'offset')
|
|
168
|
-
|
|
169
|
-
const { data, error } = await safeAsync(() => (
|
|
170
|
-
standardSearch({ query, limit, offset })
|
|
171
|
-
))
|
|
172
|
-
|
|
173
|
-
if (error) return textOutput('Standard.site search failed: ' + error.message)
|
|
174
|
-
|
|
175
|
-
const total = Number(data.totalResults) || data.documents.length
|
|
176
|
-
const formatted = formatResults({
|
|
177
|
-
label: 'Standard.site results',
|
|
178
|
-
items: data.documents,
|
|
179
|
-
total,
|
|
180
|
-
limit,
|
|
181
|
-
offset,
|
|
182
|
-
renderItem: renderStandardDoc,
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
await postResult(context, ctx, formatted)
|
|
186
|
-
|
|
187
|
-
return textOutput(formatted)
|
|
188
|
-
},
|
|
189
|
-
})
|
|
190
|
-
|
|
191
146
|
export const createWikiSearchTool = (context: Plugin.Context): Tool.Info => ({
|
|
192
147
|
name: 'wiki_search',
|
|
193
148
|
description: 'Search Wikipedia articles. Returns page titles, descriptions, and excerpts.',
|
|
@@ -305,6 +260,5 @@ export const createSearchTools = (context: Plugin.Context): Tool.Info[] => [
|
|
|
305
260
|
createDdgSearchTool(context),
|
|
306
261
|
createGnewsSearchTool(context),
|
|
307
262
|
createMdnSearchTool(context),
|
|
308
|
-
createStandardSearchTool(context),
|
|
309
263
|
createWikiSearchTool(context),
|
|
310
264
|
]
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type StandardDocument = {
|
|
2
|
-
title: string;
|
|
3
|
-
url: string;
|
|
4
|
-
date: string;
|
|
5
|
-
snippet: string;
|
|
6
|
-
};
|
|
7
|
-
export type StandardSearchResult = {
|
|
8
|
-
documents: Array<StandardDocument>;
|
|
9
|
-
totalResults: string;
|
|
10
|
-
};
|
|
11
|
-
type StandardSearchOptions = {
|
|
12
|
-
query: string;
|
|
13
|
-
limit?: number;
|
|
14
|
-
offset?: number;
|
|
15
|
-
};
|
|
16
|
-
export declare const standardSearch: (options: StandardSearchOptions) => Promise<StandardSearchResult>;
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=standard-search.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard-search.d.ts","sourceRoot":"","sources":["../../../src/providers/standard-search.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAClC,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AA0BD,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,SAAS,qBAAqB,KAAG,OAAO,CAAC,oBAAoB,CA8CjG,CAAA"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { JSDOM, VirtualConsole } from 'jsdom';
|
|
2
|
-
import * as cache from "../cache.js";
|
|
3
|
-
const SEARCH_URL = 'https://standard-search.octet-stream.net/search';
|
|
4
|
-
const parseDocument = (el) => {
|
|
5
|
-
const titleEl = el.querySelector('.result-title a');
|
|
6
|
-
if (!titleEl || !titleEl.textContent)
|
|
7
|
-
return null;
|
|
8
|
-
const title = titleEl.textContent.trim();
|
|
9
|
-
const href = titleEl.getAttribute('href');
|
|
10
|
-
const urlEl = el.querySelector('.result-url');
|
|
11
|
-
const urlText = urlEl && urlEl.textContent ? urlEl.textContent : '';
|
|
12
|
-
const snippetEl = el.querySelector('.result-snippet');
|
|
13
|
-
const snippet = snippetEl && snippetEl.textContent ? snippetEl.textContent : '';
|
|
14
|
-
const parts = urlText.split(' \u00B7 ');
|
|
15
|
-
const datePart = parts.length > 1 ? parts[1] : '';
|
|
16
|
-
return {
|
|
17
|
-
title,
|
|
18
|
-
url: href ? href.trim() : '',
|
|
19
|
-
date: datePart ? datePart.trim() : '',
|
|
20
|
-
snippet: snippet.trim(),
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
export const standardSearch = async (options) => {
|
|
24
|
-
const cacheKey = ['standard', options.query, options.limit ?? 0, options.offset ?? 0].join(':');
|
|
25
|
-
const cached = await cache.get(cacheKey);
|
|
26
|
-
if (cached && cached.documents && cached.documents.length > 0)
|
|
27
|
-
return cached;
|
|
28
|
-
const url = SEARCH_URL + '?q=' + encodeURIComponent(options.query);
|
|
29
|
-
const res = await fetch(url);
|
|
30
|
-
if (!res.ok)
|
|
31
|
-
throw new Error('Standard Search error (' + res.status + '): ' + res.statusText);
|
|
32
|
-
const html = await res.text();
|
|
33
|
-
const virtualConsole = new VirtualConsole();
|
|
34
|
-
virtualConsole.on('jsdomError', () => { });
|
|
35
|
-
const dom = new JSDOM(html, { url, virtualConsole });
|
|
36
|
-
const doc = dom.window.document;
|
|
37
|
-
const countEl = doc.querySelector('.result-count');
|
|
38
|
-
const countText = countEl ? countEl.textContent : '';
|
|
39
|
-
const totalResults = countText ? countText.trim() : '0';
|
|
40
|
-
const elements = doc.querySelectorAll('.result');
|
|
41
|
-
const documents = [];
|
|
42
|
-
for (let i = 0; i < elements.length; i++) {
|
|
43
|
-
const el = elements[i];
|
|
44
|
-
if (!el)
|
|
45
|
-
continue;
|
|
46
|
-
const parsed = parseDocument(el);
|
|
47
|
-
if (parsed)
|
|
48
|
-
documents.push(parsed);
|
|
49
|
-
}
|
|
50
|
-
const start = options.offset ?? 0;
|
|
51
|
-
const end = options.limit ? start + options.limit : documents.length;
|
|
52
|
-
const sliced = documents.slice(start, end);
|
|
53
|
-
const result = {
|
|
54
|
-
documents: sliced,
|
|
55
|
-
totalResults,
|
|
56
|
-
};
|
|
57
|
-
if (sliced.length > 0)
|
|
58
|
-
await cache.set(cacheKey, result);
|
|
59
|
-
return result;
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=standard-search.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard-search.js","sourceRoot":"","sources":["../../../src/providers/standard-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM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|
|
4
|
-
|
|
5
|
-
const isServiceDown = (error: Error): boolean => (
|
|
6
|
-
error.message.includes('Unable to connect') || error.message.includes('ConnectionRefused')
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
describe('standardSearch', () => {
|
|
10
|
-
it('returns document results', async () => {
|
|
11
|
-
const { data: results, error } = await safeAsync(() => standardSearch({ query: 'atproto' }))
|
|
12
|
-
if (error) {
|
|
13
|
-
// An unreachable appview host is a service outage, not a plugin bug
|
|
14
|
-
if (isServiceDown(error)) {
|
|
15
|
-
console.warn('standard-search appview unreachable, skipping live assertion')
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
throw error
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
expect(results.documents.length > 0).toEqual(true)
|
|
23
|
-
|
|
24
|
-
const first = results.documents[0]
|
|
25
|
-
if (!first) throw new Error('expected at least one document')
|
|
26
|
-
expect(first.title).toBeDefined()
|
|
27
|
-
expect(first.url).toBeDefined()
|
|
28
|
-
})
|
|
29
|
-
})
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { JSDOM, VirtualConsole } from 'jsdom'
|
|
2
|
-
import * as cache from '../cache.ts'
|
|
3
|
-
|
|
4
|
-
const SEARCH_URL = 'https://standard-search.octet-stream.net/search'
|
|
5
|
-
|
|
6
|
-
export type StandardDocument = {
|
|
7
|
-
title: string
|
|
8
|
-
url: string
|
|
9
|
-
date: string
|
|
10
|
-
snippet: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type StandardSearchResult = {
|
|
14
|
-
documents: Array<StandardDocument>
|
|
15
|
-
totalResults: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const parseDocument = (el: Element): StandardDocument | null => {
|
|
19
|
-
const titleEl = el.querySelector('.result-title a')
|
|
20
|
-
if (!titleEl || !titleEl.textContent) return null
|
|
21
|
-
|
|
22
|
-
const title = titleEl.textContent.trim()
|
|
23
|
-
const href = titleEl.getAttribute('href')
|
|
24
|
-
|
|
25
|
-
const urlEl = el.querySelector('.result-url')
|
|
26
|
-
const urlText = urlEl && urlEl.textContent ? urlEl.textContent : ''
|
|
27
|
-
|
|
28
|
-
const snippetEl = el.querySelector('.result-snippet')
|
|
29
|
-
const snippet = snippetEl && snippetEl.textContent ? snippetEl.textContent : ''
|
|
30
|
-
|
|
31
|
-
const parts = urlText.split(' \u00B7 ')
|
|
32
|
-
const datePart = parts.length > 1 ? parts[1] : ''
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
title,
|
|
36
|
-
url: href ? href.trim() : '',
|
|
37
|
-
date: datePart ? datePart.trim() : '',
|
|
38
|
-
snippet: snippet.trim(),
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
type StandardSearchOptions = {
|
|
43
|
-
query: string
|
|
44
|
-
limit?: number
|
|
45
|
-
offset?: number
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const standardSearch = async (options: StandardSearchOptions): Promise<StandardSearchResult> => {
|
|
49
|
-
const cacheKey = ['standard', options.query, options.limit ?? 0, options.offset ?? 0].join(':')
|
|
50
|
-
|
|
51
|
-
const cached = await cache.get<StandardSearchResult>(cacheKey)
|
|
52
|
-
if (cached && cached.documents && cached.documents.length > 0) return cached
|
|
53
|
-
|
|
54
|
-
const url = SEARCH_URL + '?q=' + encodeURIComponent(options.query)
|
|
55
|
-
const res = await fetch(url)
|
|
56
|
-
|
|
57
|
-
if (!res.ok) throw new Error('Standard Search error (' + res.status + '): ' + res.statusText)
|
|
58
|
-
|
|
59
|
-
const html = await res.text()
|
|
60
|
-
|
|
61
|
-
const virtualConsole = new VirtualConsole()
|
|
62
|
-
virtualConsole.on('jsdomError', () => {})
|
|
63
|
-
|
|
64
|
-
const dom = new JSDOM(html, { url, virtualConsole })
|
|
65
|
-
const doc = dom.window.document
|
|
66
|
-
|
|
67
|
-
const countEl = doc.querySelector('.result-count')
|
|
68
|
-
const countText = countEl ? countEl.textContent : ''
|
|
69
|
-
const totalResults = countText ? countText.trim() : '0'
|
|
70
|
-
|
|
71
|
-
const elements = doc.querySelectorAll('.result')
|
|
72
|
-
const documents: Array<StandardDocument> = []
|
|
73
|
-
|
|
74
|
-
for (let i = 0; i < elements.length; i++) {
|
|
75
|
-
const el = elements[i]
|
|
76
|
-
if (!el) continue
|
|
77
|
-
|
|
78
|
-
const parsed = parseDocument(el)
|
|
79
|
-
if (parsed) documents.push(parsed)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const start = options.offset ?? 0
|
|
83
|
-
const end = options.limit ? start + options.limit : documents.length
|
|
84
|
-
const sliced = documents.slice(start, end)
|
|
85
|
-
|
|
86
|
-
const result: StandardSearchResult = {
|
|
87
|
-
documents: sliced,
|
|
88
|
-
totalResults,
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (sliced.length > 0) await cache.set(cacheKey, result)
|
|
92
|
-
|
|
93
|
-
return result
|
|
94
|
-
}
|