dsh-all-search 0.1.1 → 0.2.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.
package/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  Adds an **AnySearch** web-search provider to DeepSeek Harness, registered into `ctx.web`. AnySearch is a single MCP gateway that aggregates exa / tavily / firecrawl / context7 behind **one API key**.
8
8
 
9
+ With an optional `firecrawl_api_key`, developer-intent queries (repo / issue / PR / commit / skill) are answered by the **Firecrawl Developer Index** first — a semantic artifact index over READMEs, issues, PRs, OpenAPI specs and skills — falling back to AnySearch when it fails or returns nothing.
10
+
9
11
  > Port of [pi-all-search](https://github.com/RealAlexandreAI/pi-all-search).
10
12
 
11
13
  [English](README.md) · [中文](README.zh.md)
@@ -33,6 +35,7 @@ The provider registers as `anysearch` on `ctx.web` — the built-in `web_search`
33
35
  |---|---|---|
34
36
  | `api_key` | ✅ | your AnySearch key |
35
37
  | `base_url` | – | MCP endpoint override |
38
+ | `firecrawl_api_key` | – | enables the Firecrawl Developer Index branch for repo/issue/PR/skill queries |
36
39
 
37
40
  Without a key the provider reports `available() = false` and the seam skips it.
38
41
 
package/dist/index.d.ts CHANGED
@@ -8,8 +8,11 @@ export interface Config {
8
8
  api_key: string;
9
9
  /** AnySearch MCP endpoint override. */
10
10
  base_url?: string;
11
+ /** Firecrawl API key — enables the Developer Index branch for developer-intent queries. */
12
+ firecrawl_api_key?: string;
11
13
  }
12
14
  export declare const Config: z<Config>;
15
+ export declare function isDeveloperQuery(query: string): boolean;
13
16
  export declare class AnysearchProvider implements WebSearchProvider {
14
17
  private readonly apiKey;
15
18
  private readonly baseUrl;
@@ -20,4 +23,11 @@ export declare class AnysearchProvider implements WebSearchProvider {
20
23
  search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
21
24
  private parseResults;
22
25
  }
26
+ export declare class FirecrawlDevProvider implements WebSearchProvider {
27
+ private readonly apiKey;
28
+ readonly id = "firecrawl-dev";
29
+ constructor(apiKey: string);
30
+ available(): boolean;
31
+ search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
32
+ }
23
33
  export declare function apply(ctx: Context, config: Config): void;
package/dist/index.js CHANGED
@@ -7,15 +7,27 @@
7
7
  // Ported from pi-all-search (providers/anysearch.ts) with the pi UI/typebox
8
8
  // surface replaced by the dsh WebSearchProvider seam.
9
9
  //
10
- // Privacy: the API key lives in the plugin config only; it is never logged.
10
+ // Optionally, with `firecrawl_api_key` set, developer-intent queries
11
+ // (repo / issue / PR / github / commit / skill) are answered by the
12
+ // Firecrawl Developer Index first (semantic artifact index: READMEs, issues,
13
+ // PRs, OpenAPI specs, skills), falling back to AnySearch when it fails or
14
+ // returns nothing. Kept inside one provider because the dsh-web seam errors
15
+ // on multiple usable providers unless one is configured explicitly.
16
+ //
17
+ // Privacy: API keys live in the plugin config only; they are never logged.
11
18
  import z from '@deepseek-ai/schemastery';
12
19
  export const name = 'all-search';
13
20
  export const inject = ['web'];
14
21
  export const Config = z.object({
15
22
  api_key: z.string().required().description('AnySearch API key'),
16
23
  base_url: z.string().description('AnySearch MCP endpoint override (default https://api.anysearch.com/mcp)'),
24
+ firecrawl_api_key: z.string().description('Firecrawl API key (optional) — enables Developer Index for repo/issue/PR/skill queries'),
17
25
  });
18
26
  const DEFAULT_BASE_URL = 'https://api.anysearch.com/mcp';
27
+ const DEVELOPER_QUERY_RE = /\b(repo|repos|repository|repositories|github|issue|issues|pull request|pull requests|commit|commits|branch|merge|openapi|readme|skill|skills|library|framework)\b/i;
28
+ export function isDeveloperQuery(query) {
29
+ return DEVELOPER_QUERY_RE.test(query);
30
+ }
19
31
  export class AnysearchProvider {
20
32
  apiKey;
21
33
  baseUrl;
@@ -72,15 +84,64 @@ export class AnysearchProvider {
72
84
  return results;
73
85
  }
74
86
  }
87
+ export class FirecrawlDevProvider {
88
+ apiKey;
89
+ id = 'firecrawl-dev';
90
+ constructor(apiKey) {
91
+ this.apiKey = apiKey;
92
+ }
93
+ available() {
94
+ return Boolean(this.apiKey);
95
+ }
96
+ async search(request, signal) {
97
+ const resp = await fetch('https://api.firecrawl.dev/v2/search/developer', {
98
+ method: 'POST',
99
+ headers: {
100
+ 'Content-Type': 'application/json',
101
+ Authorization: `Bearer ${this.apiKey}`,
102
+ },
103
+ signal,
104
+ body: JSON.stringify({ query: request.query, limit: request.maxResults ?? 5 }),
105
+ });
106
+ if (!resp.ok)
107
+ throw new Error(`Firecrawl Developer Index HTTP ${resp.status}`);
108
+ const data = (await resp.json());
109
+ const sources = (data.data ?? []).map((r) => ({
110
+ title: r.title ?? r.id ?? '',
111
+ url: r.url ?? '',
112
+ snippet: r.description ??
113
+ (Array.isArray(r.passages) ? r.passages.slice(0, 3).join(' ') : '') ??
114
+ '',
115
+ }));
116
+ const truncated = request.maxResults !== undefined && sources.length > request.maxResults;
117
+ return {
118
+ sources: truncated ? sources.slice(0, request.maxResults) : sources,
119
+ truncated,
120
+ };
121
+ }
122
+ }
75
123
  export function apply(ctx, config) {
76
- // `available()` is a cheap local check — no network.
124
+ const anysearch = new AnysearchProvider(config.api_key, config.base_url ?? DEFAULT_BASE_URL);
125
+ const devIndex = config.firecrawl_api_key ? new FirecrawlDevProvider(config.firecrawl_api_key) : null;
126
+ // Single provider to avoid dsh-web's WEB_PROVIDER_AMBIGUOUS on multiple
127
+ // usable providers. Developer-intent queries try the Developer Index first.
77
128
  const wrapper = {
78
129
  id: 'anysearch',
79
130
  available: () => Boolean(config.api_key),
80
131
  async search(request, signal) {
81
132
  if (!config.api_key)
82
133
  throw new Error('AnySearch API key not configured (set api_key in the plugin config)');
83
- return new AnysearchProvider(config.api_key, config.base_url ?? DEFAULT_BASE_URL).search(request, signal);
134
+ if (devIndex && isDeveloperQuery(request.query)) {
135
+ try {
136
+ const dev = await devIndex.search(request, signal);
137
+ if (dev.sources.length > 0)
138
+ return dev;
139
+ }
140
+ catch {
141
+ // fall through to AnySearch
142
+ }
143
+ }
144
+ return anysearch.search(request, signal);
84
145
  },
85
146
  };
86
147
  ctx.web.registerSearchProvider(wrapper);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-all-search",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "DeepSeek Harness plugin: AnySearch-backed web search provider (aggregates exa/tavily/firecrawl via one MCP gateway) registered into ctx.web.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
31
  "@deepseek-ai/cordis": "^4.0.1",
32
- "@deepseek-ai/dsh-web": "^0.0.1-rc.1",
32
+ "@deepseek-ai/dsh-web": "^0.1.0-rc.7",
33
33
  "@deepseek-ai/schemastery": "^3.18.0"
34
34
  },
35
35
  "devDependencies": {