@wenaixi/searchfuse 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 (38) hide show
  1. package/CHANGELOG.md +157 -1
  2. package/README.md +2 -10
  3. package/README.zh-CN.md +2 -10
  4. package/SECURITY.md +36 -2
  5. package/claude/.claude-plugin/plugin.json +1 -1
  6. package/claude/hooks/register.ts +90 -18
  7. package/dist/kernel.js +17 -6
  8. package/dist/main.js +64 -21
  9. package/dist/{search-BIW13Csk.js → search-DeT416xs.js} +123 -11
  10. package/dist/serve-ensure.js +1 -140
  11. package/dist/serveEnsure-BTj9IifL.js +632 -0
  12. package/dsh/index.js +137 -3
  13. package/omp/extension.ts +263 -29
  14. package/omp/host-types.d.ts +47 -0
  15. package/omp/tsconfig.json +13 -0
  16. package/package.json +3 -7
  17. package/skills/searchfuse/SKILL.md +4 -4
  18. package/skills/searchfuse/references/configure.md +4 -2
  19. package/skills/searchfuse/references/runtime.md +1 -1
  20. package/skills/searchfuse/scripts/run.ps1 +1 -1
  21. package/skills/searchfuse/scripts/run.sh +1 -1
  22. package/dist/serve-Bfqz-nCB.js +0 -279
  23. package/docs/commit.md +0 -77
  24. package/docs/dsh.md +0 -205
  25. package/docs/harness-setup.md +0 -78
  26. package/docs/parity-matrix.md +0 -61
  27. package/docs/searxng-setup.md +0 -117
  28. package/docs/security.md +0 -59
  29. package/docs/settings-redesign-decisions.md +0 -407
  30. package/docs/superpowers/plans/2026-11-24-serve-lifecycle.md +0 -880
  31. package/docs/superpowers/reports/2026-11-24-serve-lifecycle-ledger.md +0 -211
  32. package/docs/superpowers/specs/2026-11-20-searchfuse-dual-host-design.md +0 -172
  33. package/docs/superpowers/specs/2026-11-21-searchfuse-tri-host-design.md +0 -659
  34. package/docs/superpowers/specs/2026-11-21-tri-host-takeover-design.md +0 -363
  35. package/docs/superpowers/specs/2026-11-22-settings-card-refactor-design.md +0 -117
  36. package/docs/superpowers/specs/2026-11-24-serve-lifecycle-design.md +0 -155
  37. package/docs/testing.md +0 -92
  38. package/docs/troubleshooting.md +0 -258
@@ -39,11 +39,11 @@ Nothing else needs setting up first: searchfuse works with no config file. Web s
39
39
 
40
40
  ### If you cannot run the launcher script
41
41
 
42
- Some harnesses forbid running scripts. Reason through the same order by hand and run the first line that works (the pinned version is 0.1.0):
42
+ Some harnesses forbid running scripts. Reason through the same order by hand and run the first line that works (the pinned version is 0.1.2):
43
43
 
44
- 1. A `searchfuse` on `PATH` whose major version is 0 and is at least 0.1.0: `searchfuse <args>`.
45
- 2. Otherwise, if `npx` exists: `npx --yes --package @wenaixi/searchfuse@0.1.0 searchfuse <args>`.
46
- 3. Otherwise, if `bunx` exists: `bunx --bun @wenaixi/searchfuse@0.1.0 <args>`.
44
+ 1. A `searchfuse` on `PATH` whose major version is 0 and is at least 0.1.2: `searchfuse <args>`.
45
+ 2. Otherwise, if `npx` exists: `npx --yes --package @wenaixi/searchfuse@0.1.2 searchfuse <args>`.
46
+ 3. Otherwise, if `bunx` exists: `bunx --bun @wenaixi/searchfuse@0.1.2 <args>`.
47
47
  4. Otherwise none of these runtimes is here. Tell the user no JavaScript runtime was found and that installing Node 22.19+ (https://nodejs.org) or Bun (https://bun.sh) is the next step. Do not claim searchfuse itself failed.
48
48
 
49
49
  `references/runtime.md` documents the version pin, the compatibility rule, and the diagnostic fields.
@@ -228,7 +228,9 @@ searchfuse config set searxng.baseURL http://127.0.0.1:8888 # 用自己的实
228
228
 
229
229
  填了 `baseURL` 就用用户的实例,`embedded` 不再起作用;留空则用随包实例。公共实例几乎总返回 403,因为它的 `settings.yml` 里 `format: json` 是关的,所以要么指向自己实例、要么用随包实例,不要随便填一个公共地址。
230
230
 
231
- 它只搜索,`-u` 配 `-e searxng` 会报错。`searxng.outgoing` 控制的是随包实例自己去抓网页时走哪个代理,与 `engines.searxng.proxy`(管 searchfuse 直连那一跳)互不覆盖。自建细节见 [docs/searxng-setup.md](../../../docs/searxng-setup.md)。
231
+ 它只搜索,`-u` 配 `-e searxng` 会报错。`searxng.outgoing` 控制的是随包实例自己去抓网页时走哪个代理,与 `engines.searxng.proxy`(管 searchfuse 直连那一跳)互不覆盖。
232
+
233
+ 自建实例要满足两条:`settings.yml` 里开 `json` 格式(否则 adapter 拿不到结构化结果),以及允许 searchfuse 的来源地址。`searxng.baseURL` 填你自己的实例后 `embedded` 就不再起作用;留空则一直用随包实例。
232
234
 
233
235
 
234
236
 
@@ -274,7 +276,7 @@ searchfuse config set allowPrivateNetwork true # 永久生效(顶层,全
274
276
  某个 API key 因额度类错误失败时,searchfuse 把这个 key 记在 `~/.searchfuse/state.json`(与 `config.json` 分开)。下一次运行会先试同一引擎里的健康 key。只有所有已配置 key 都在冷却时,整个引擎才会移到后备链末尾。没有 API key 的引擎仍按引擎粒度冷却。这是软化的熔断器,不是负载均衡:健康 key 和健康引擎拿全部工作,冷却项仍保留为最后尝试。
275
277
 
276
278
  - 冷却中的 key 不会被移除。某个 key 成功后只清除它自己的冷却。旧格式的引擎级状态仍可读取,并在任一 key 成功前作用于该引擎的所有 key。
277
- - 引擎报错里的精确重置时间(agy 的 `Resets in 94h19m9s`)会被采用。没写时间的额度错误冷却 45 分钟。按秒的速率限制是瞬时的,从不记录。
279
+ - 恢复时间按精度从高到低取:服务器给的 `retry_after_seconds`(firecrawl 的免注册额度墙回 429 时带的 JSON 字段)→ 报错正文里的 `Resets in 94h19m9s` → 兜底。没写时间的额度错误冷却 45 分钟,月度额度(Tavily 的 432/433)冷却 24 小时。按秒的速率限制是瞬时的,从不记录——但**429 不等于瞬时限流**:正文写着 `"reason":"credits"` 的是花光的预算,会记。
278
280
  - 显式 `-e`/`--engine` 仍是硬指定,不会跨引擎后备。同一引擎有多个 key 时,健康 key 仍排在冷却 key 前面。
279
281
  - 结果的 `warnings` 会指出哪个 key 进入冷却。只有所有已配置 key 都在冷却并导致引擎后移时,路由 warning 才按引擎报告。
280
282
 
@@ -4,7 +4,7 @@ skill 如何启动 `searchfuse` CLI、钉在哪个版本、在什么都跑不了
4
4
 
5
5
  ## 钉住的版本
6
6
 
7
- - Pinned CLI version: 0.1.0
7
+ - Pinned CLI version: 0.1.2
8
8
  - npm 包:`@wenaixi/searchfuse`
9
9
  - CLI 命令名:`searchfuse`
10
10
 
@@ -24,7 +24,7 @@ $ErrorActionPreference = 'Stop'
24
24
  # package.json version, and the release script rewrites it on every bump.
25
25
  $Package = '@wenaixi/searchfuse'
26
26
  $Bin = 'searchfuse'
27
- $Pinned = '0.1.0'
27
+ $Pinned = '0.1.2'
28
28
  # -------------------------------------------------------------------------------
29
29
 
30
30
  $NativeNote = 'no native artifact is published for this tool yet; phase A ships npm launch paths only'
@@ -22,7 +22,7 @@ set -eu
22
22
  # package.json version, and the release script rewrites it on every bump.
23
23
  PKG="@wenaixi/searchfuse"
24
24
  BIN="searchfuse"
25
- PINNED="0.1.0"
25
+ PINNED="0.1.2"
26
26
  # -------------------------------------------------------------------------------
27
27
 
28
28
  NATIVE_NOTE="no native artifact is published for this tool yet; phase A ships npm launch paths only"
@@ -1,279 +0,0 @@
1
- import { C as loadConfigFile, _ as currentConfigPath, m as allowsPrivateNetwork, t as runSearch } from "./search-BIW13Csk.js";
2
- import * as os from "node:os";
3
- import * as path from "node:path";
4
- import * as fs from "node:fs";
5
- import * as http from "node:http";
6
- // src/serve.ts
7
- /** token 文件位置。与配置分离:配置会被复制备份,秘密不该跟着走。 */
8
- function serveTokenPath() {
9
- return path.join(os.homedir(), ".searchfuse", "serve-token");
10
- }
11
- /** 运行时文件:谁在跑、什么时候起的。不含端口(固定端口)。 */
12
- function runtimePath() {
13
- return path.join(os.homedir(), ".searchfuse", "runtime.json");
14
- }
15
- /** 读 token;没有就生成一个并写盘(POSIX 上用 0600)。 */
16
- function ensureServeToken() {
17
- const file = serveTokenPath();
18
- try {
19
- const existing = fs.readFileSync(file, "utf-8").trim();
20
- if (existing !== "") return existing;
21
- } catch {}
22
- const token = randomToken();
23
- fs.mkdirSync(path.dirname(file), {
24
- recursive: true,
25
- mode: 448
26
- });
27
- fs.writeFileSync(file, `${token}\n`, { mode: 384 });
28
- try {
29
- fs.chmodSync(file, 384);
30
- } catch {}
31
- return token;
32
- }
33
- /** 32 字节随机 token 的十六进制形式。 */
34
- function randomToken() {
35
- const bytes = /* @__PURE__ */ new Uint8Array(32);
36
- crypto.getRandomValues(bytes);
37
- return [...bytes].map((b) => b.toString(16).padStart(2, "0")).join("");
38
- }
39
- /**
40
- * 把一次聚合结果翻译成 SearXNG 的形状。
41
- *
42
- * 三条规则:
43
- * - `title` / `url` / `content` 直对,缺 `url` 的条目丢弃(omp 需要它)
44
- * - `engine` 填作答的引擎名,不是 `searxng`——它本来就是别的东西
45
- * - **`unresponsive_engines` 必须带上**:omp 靠它在结果为空时保真上游原因,
46
- * 缺了它只会退化成一句泛化错误
47
- */
48
- function toSearxngShape(raw, query) {
49
- const root = typeof raw === "object" && raw !== null ? raw : {};
50
- const results = Array.isArray(root.results) ? root.results : [];
51
- const entry = typeof results[0] === "object" && results[0] !== null ? results[0] : {};
52
- const items = Array.isArray(entry.items) ? entry.items : [];
53
- const mapped = [];
54
- for (const item of items) {
55
- if (typeof item !== "object" || item === null) continue;
56
- const record = item;
57
- const url = typeof record.url === "string" ? record.url : void 0;
58
- if (!url) continue;
59
- const title = typeof record.title === "string" ? record.title : url;
60
- const content = typeof record.snippet === "string" ? record.snippet : typeof record.summary === "string" ? record.summary : "";
61
- mapped.push({
62
- title,
63
- url,
64
- content,
65
- engine: typeof entry.engine === "string" ? entry.engine : "searchfuse"
66
- });
67
- }
68
- const failures = [];
69
- const attempts = Array.isArray(entry.attempts) ? entry.attempts : [];
70
- for (const attempt of attempts) {
71
- if (typeof attempt !== "object" || attempt === null) continue;
72
- const record = attempt;
73
- if (typeof record.error !== "string") continue;
74
- failures.push([typeof record.engine === "string" ? record.engine : "unknown", record.error]);
75
- }
76
- if (failures.length === 0) {
77
- const uncertainty = Array.isArray(entry.uncertainty) ? entry.uncertainty : [];
78
- for (const line of uncertainty) {
79
- if (typeof line !== "string" || line === "") continue;
80
- const colon = line.indexOf(":");
81
- if (colon > 0 && colon < 40) failures.push([line.slice(0, colon).trim(), line.slice(colon + 1).trim()]);
82
- else failures.push(["searchfuse", line]);
83
- }
84
- }
85
- const answer = typeof entry.summary === "string" && entry.summary !== "" ? [entry.summary] : [];
86
- return {
87
- query,
88
- number_of_results: mapped.length,
89
- results: mapped,
90
- answers: answer,
91
- unresponsive_engines: failures
92
- };
93
- }
94
- /** `config.engines` 里启用中的引擎名,供 `/config` 的壳使用。 */
95
- function enabledEngines() {
96
- const engines = loadConfigFile(currentConfigPath()).engines ?? {};
97
- return Object.entries(engines).filter(([, settings]) => settings.enabled !== false).map(([name]) => ({ name }));
98
- }
99
- /** 常量的响应头。`no-store`:这是搜索,不该被任何中间层缓存。 */
100
- var JSON_HEADERS = {
101
- "content-type": "application/json; charset=utf-8",
102
- "cache-control": "no-store"
103
- };
104
- /** 从请求里取 bearer token,大小写不敏感。 */
105
- function bearerOf(header) {
106
- if (header === void 0) return void 0;
107
- return /^Bearer\s+(.+)$/i.exec(header.trim())?.[1];
108
- }
109
- /**
110
- * 起服务。固定端口——被占用就报错,不漂移。
111
- *
112
- * 为什么不漂移:omp 的 `searxng.endpoint` 是配置文件里的静态字符串,
113
- * 端口变了它不会跟着变,于是每次重启都要用户手动跑一次 `hosts sync`。
114
- * 固定端口把这条高频故障变成一次性配置。
115
- */
116
- function startServe(options) {
117
- const search = options.search ?? runSearch;
118
- let hits = 0;
119
- let inFlight = 0;
120
- let idleTimer;
121
- const server = http.createServer((req, res) => {
122
- const url = new URL(req.url ?? "/", `http://127.0.0.1:${options.port}`);
123
- if (url.pathname === "/healthz") {
124
- res.writeHead(200, {
125
- "content-type": "text/plain; charset=utf-8",
126
- "cache-control": "no-store"
127
- });
128
- res.end("OK");
129
- return;
130
- }
131
- if (bearerOf(req.headers.authorization) !== options.token) {
132
- res.writeHead(401, JSON_HEADERS);
133
- res.end(JSON.stringify({ error: "unauthorized" }));
134
- return;
135
- }
136
- if (url.pathname === "/__stats") {
137
- res.writeHead(200, JSON_HEADERS);
138
- res.end(JSON.stringify({ localHits: hits }));
139
- return;
140
- }
141
- if (url.pathname === "/config") {
142
- res.writeHead(200, JSON_HEADERS);
143
- res.end(JSON.stringify({ engines: enabledEngines() }));
144
- return;
145
- }
146
- if (url.pathname === "/v1/search" || url.pathname === "/v1/read-page") {
147
- inFlight += 1;
148
- scheduleIdleExit();
149
- const config = loadConfigFile(currentConfigPath());
150
- const isReadPage = url.pathname === "/v1/read-page";
151
- const query = url.searchParams.get("q") ?? "";
152
- const targetUrl = url.searchParams.get("url") ?? "";
153
- if (isReadPage && targetUrl === "") {
154
- inFlight -= 1;
155
- res.writeHead(400, JSON_HEADERS);
156
- res.end(JSON.stringify({ error: "missing url" }));
157
- return;
158
- }
159
- if (!isReadPage && query === "") {
160
- inFlight -= 1;
161
- res.writeHead(400, JSON_HEADERS);
162
- res.end(JSON.stringify({ error: "missing q" }));
163
- return;
164
- }
165
- const options = isReadPage ? {
166
- url: targetUrl,
167
- allowPrivateNetwork: allowsPrivateNetwork(config),
168
- config
169
- } : {
170
- query,
171
- sources: url.searchParams.get("source") ?? "web",
172
- maxResults: Number(url.searchParams.get("max") ?? "") || void 0,
173
- timeoutMs: Number(url.searchParams.get("timeout") ?? "") || void 0,
174
- deadlineMs: Number(url.searchParams.get("deadline") ?? "") || void 0,
175
- allowPrivateNetwork: allowsPrivateNetwork(config),
176
- config
177
- };
178
- search(options).then((result) => {
179
- if (result.results.some((entry) => entry.status !== "unavailable")) hits += 1;
180
- res.writeHead(200, JSON_HEADERS);
181
- res.end(JSON.stringify(result));
182
- }).catch((error) => {
183
- const message = error instanceof Error ? error.message : String(error);
184
- res.writeHead(500, JSON_HEADERS);
185
- res.end(JSON.stringify({ error: message }));
186
- }).finally(() => {
187
- inFlight -= 1;
188
- scheduleIdleExit();
189
- });
190
- return;
191
- }
192
- if (url.pathname === "/search") {
193
- const query = url.searchParams.get("q") ?? "";
194
- inFlight += 1;
195
- scheduleIdleExit();
196
- const config = loadConfigFile(currentConfigPath());
197
- search({
198
- query,
199
- sources: "web",
200
- allowPrivateNetwork: allowsPrivateNetwork(config),
201
- config
202
- }).then((result) => {
203
- const payload = toSearxngShape(result, query);
204
- if (payload.results.length > 0) hits += 1;
205
- res.writeHead(200, JSON_HEADERS);
206
- res.end(JSON.stringify(payload));
207
- }).catch((error) => {
208
- const message = error instanceof Error ? error.message : String(error);
209
- res.writeHead(500, JSON_HEADERS);
210
- res.end(JSON.stringify({
211
- error: message,
212
- results: [],
213
- answers: [],
214
- unresponsive_engines: []
215
- }));
216
- }).finally(() => {
217
- inFlight -= 1;
218
- scheduleIdleExit();
219
- });
220
- return;
221
- }
222
- res.writeHead(404, JSON_HEADERS);
223
- res.end(JSON.stringify({ error: "not found" }));
224
- });
225
- /** 空闲退出:**只统计空闲**,在途请求期间绝不退出。 */
226
- function scheduleIdleExit() {
227
- if (options.idleExitSeconds <= 0) return;
228
- clearTimeout(idleTimer);
229
- if (inFlight > 0) return;
230
- idleTimer = setTimeout(() => {
231
- if (inFlight > 0) return;
232
- close();
233
- }, options.idleExitSeconds * 1e3 + 2e3);
234
- idleTimer.unref();
235
- }
236
- async function close() {
237
- clearTimeout(idleTimer);
238
- try {
239
- fs.rmSync(runtimePath(), { force: true });
240
- } catch {}
241
- const closed = Promise.withResolvers();
242
- server.close(() => closed.resolve());
243
- await closed.promise;
244
- }
245
- const ready = Promise.withResolvers();
246
- server.once("error", (error) => {
247
- if (error.code === "EADDRINUSE") {
248
- ready.reject(/* @__PURE__ */ new Error(`Port ${options.port} is already in use. Set serve.port to 0 (or omit it) to let the system pick a free port, or choose a different number. Hosts read the actual port from runtime.json, so a picked port needs no host reconfiguration.`));
249
- return;
250
- }
251
- ready.reject(error);
252
- });
253
- server.listen(options.port, "127.0.0.1", () => {
254
- const address = server.address();
255
- const boundPort = typeof address === "object" && address !== null ? address.port : options.port;
256
- try {
257
- fs.mkdirSync(path.dirname(runtimePath()), {
258
- recursive: true,
259
- mode: 448
260
- });
261
- fs.writeFileSync(runtimePath(), `${JSON.stringify({
262
- port: boundPort,
263
- pid: process.pid,
264
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
265
- version: "0.1.0",
266
- token: options.token
267
- }, null, 2)}\n`);
268
- } catch {}
269
- scheduleIdleExit();
270
- ready.resolve({
271
- server,
272
- port: boundPort,
273
- localHits: () => hits,
274
- close
275
- });
276
- });
277
- return ready.promise;
278
- }
279
- export { runtimePath as n, startServe as r, ensureServeToken as t };
package/docs/commit.md DELETED
@@ -1,77 +0,0 @@
1
- ---
2
- summary: 'Git 提交规范:Conventional Commits 格式、原子提交、HEREDOC 用法'
3
- read_when:
4
- - 准备提交代码
5
- - 写提交信息
6
- - 需要了解提交规范
7
- ---
8
-
9
- # Git 提交规范
10
-
11
- ## 提交信息格式
12
-
13
- ```
14
- <类型>[可选范围]: <祈使句摘要>
15
-
16
- [可选正文]
17
-
18
- [可选脚注]
19
- ```
20
-
21
- - 摘要用祈使句,不超过 72 个字符
22
- - 结尾不加句号
23
- - 只在能增加清晰度时使用范围(例如 `auth`、`api`、`ui`)
24
- - 破坏性变更用 `!` 标记(例如 `feat!:`),或写一行 `BREAKING CHANGE:` 脚注
25
-
26
- ## 可用类型
27
-
28
- | 类型 | 说明 |
29
- |------|------|
30
- | `feat` | 新功能 |
31
- | `fix` | 缺陷修复 |
32
- | `docs` | 文档更新 |
33
- | `style` | 格式调整(不改逻辑) |
34
- | `refactor` | 代码重构(不改行为) |
35
- | `perf` | 性能优化 |
36
- | `test` | 测试相关 |
37
- | `build` | 构建系统或依赖变更 |
38
- | `ci` | CI/CD 变更 |
39
- | `chore` | 杂务 |
40
- | `revert` | 回退一次提交 |
41
-
42
- ## 原子提交原则
43
-
44
- 1. 一次提交只做一件事
45
- 2. 每次提交之后仓库都应当仍可构建、仍可运行
46
- 3. 每次提交都应当能被独立回退,只影响它对应的那一处改动
47
- 4. 行为有变化时,把相关测试放在同一次提交里
48
- 5. 不要把重构、格式化与行为变更混在一次提交里
49
-
50
- ## 提交流程
51
-
52
- ```bash
53
- # 1. 查看改动
54
- git status --short
55
- git diff --staged --stat
56
-
57
- # 2. 选择性暂存(避免 git add -A)
58
- git add <具体文件>
59
-
60
- # 3. 复核将要提交的内容
61
- git diff --staged
62
-
63
- # 4. 提交(HEREDOC 格式,正文里说清「为什么」而不是「改了什么」)
64
- git commit -F- <<'EOF'
65
- <类型>[范围]: <摘要>
66
-
67
- <正文:问题是什么、为什么这样改、验证过什么>
68
- EOF
69
- ```
70
-
71
- 不要加 `Co-Authored-By` 之类的署名尾巴:这个仓库的提交历史里没有,作者的署名由 git 配置决定。
72
-
73
- ## 注意事项
74
-
75
- - 不要提交 `.env`、凭据之类敏感文件
76
- - 提交钩子失败后,修好问题再建一次**新提交**(不要用 `--amend`)
77
- - 不要自动推送;等用户的指示
package/docs/dsh.md DELETED
@@ -1,205 +0,0 @@
1
- ---
2
- summary: 'DeepSeek Harness 插件:安装、配置、验证、更新与故障定位'
3
- read_when:
4
- - 在 dsh profile 中安装或更新 searchfuse
5
- - 配置 dsh 插件开关或 searchfuse 引擎
6
- - 验证 dsh 中的 web_search、x_search 或 read_page
7
- - dsh 发布新版本后检查兼容性
8
- ---
9
-
10
- # DeepSeek Harness 插件
11
-
12
- SearchFuse 是原生 dsh bundle。它保留 dsh 内置的 `web_search` 工具与引用卡片,只替换背后的搜索 provider,同时补上 dsh web 接缝没有的 `x_search` 和 `read_page`。
13
-
14
- ## 兼容性
15
-
16
- 当前 bundle 已对照 `@deepseek-ai/dsh 0.2.3-alpha.2` 实测:`--dump-config` 输出里 `searchProvider: modsearch` 与 `@wenaixi/searchfuse` 插件行都正常出现,bundle patch 生效。更早的版本线(0.2.2-rc.3 到 rc.5、0.1.7-alpha.1、设置卡片对照过的 0.1.5-rc.2)也验证过,下面这几条接口在各版之间没有变化:
17
-
18
- - npm bundle 仍通过 `dsh.bundle.patch` 声明配置层。
19
- - web 接缝仍通过 `ctx.web.registerSearchProvider(...)` 接收 provider。
20
- - 工具仍通过 `ctx.tools.register(...)` 注册。
21
- - bundle 可以显示自己的设置卡片。从 0.1.6-alpha.2 起,它通过 `plugins.bundle.config` 插槽出现在「插件」面板里该 bundle 的页面上。更早的版本通过 `settings.plugin.item` 把它放在设置页里。
22
-
23
- dsh 仍是预览版本,每次升级后都应重新检查。下面的组合检查不调用模型,不需要 API key,也不消耗额度:
24
-
25
- ```sh
26
- npx -y @deepseek-ai/dsh --version
27
- npx -y @deepseek-ai/dsh --profile web --dump-config
28
- ```
29
-
30
- 输出中应同时出现 `searchProvider: modsearch` 和名为 `@wenaixi/searchfuse` 的插件行。
31
-
32
- ## 安装
33
-
34
- 把插件装进实际启动的 profile。浏览器界面通常使用 `web`:
35
-
36
- ```sh
37
- npx -y @deepseek-ai/dsh plugin --profile web add @wenaixi/searchfuse@0.1.0
38
- ```
39
-
40
- 安装后重启 dsh,再确认真正解析到的包:
41
-
42
- ```sh
43
- npx -y @deepseek-ai/dsh plugin --profile web list --depth 0
44
- ```
45
-
46
- 这里故意写精确版本。pnpm 11 可能通过 `minimumReleaseAge` 扣住刚发布的版本,让 `@latest` 解析成旧包。发布流程会让本命令中的版本与 `package.json` 保持同步。
47
-
48
- 桌面版的 `desktop` profile 只能在桌面版窗口里装,dsh CLI 会以 `profile "desktop" is managed exclusively by the Electron application` 拒绝它。在「添加插件」对话框里,填包名 `@wenaixi/searchfuse`,不要填 GitHub 仓库地址。只有 npm 包带构建好的 CLI。从 GitHub 安装只拿到源码,而 pnpm 会拦下补构建的那一步。
49
-
50
- ## bundle 改了什么
51
-
52
- bundle 贡献两条 patch:
53
-
54
- 1. 把 dsh web 接缝的 `searchProvider` 设为 `searchfuse`,并保留自带的 `fetchProvider: http`(这一行会整体替换宿主的 web 配置)。
55
- 2. 把包根入口挂载为 `searchfuse` 插件。
56
-
57
- 插件随后提供:
58
-
59
- | 能力 | dsh 接口 | 行为 |
60
- | :-- | :-- | :-- |
61
- | 网页搜索 | 内置 `web_search` | 运行 SearchFuse 网页引擎链,保留原生引用卡片。 |
62
- | X 搜索 | 新增 `x_search` 工具 | 有 Grok Build 时直接使用。网页替代结果会明确标成降级。 |
63
- | 带焦点读单页 | 新增 `read_page` 工具 | 读取一个 URL,可附问题聚焦。私网目标仍会拦截。dsh 自带的 `web_fetch` 照常保留,用于取原始正文和状态码。 |
64
-
65
- ## 配置搜索引擎
66
-
67
- dsh 插件不维护第二份引擎配置。它继承同一组环境变量,并读取 CLI 与 skill 共用的 `~/.searchfuse/config.json`。
68
-
69
- 先跑离线体检:
70
-
71
- ```sh
72
- npx -y @wenaixi/searchfuse@0.1.0 doctor
73
- ```
74
-
75
- 常用配置:
76
-
77
- ```sh
78
- searchfuse config set engine antigravity-cli
79
- searchfuse config set tavily.apiKey <key>
80
- searchfuse config set exa.apiKey <key>
81
- searchfuse config set firecrawl.apiKey <key>
82
- searchfuse config set keenable.apiKey <key>
83
- searchfuse config set anysearch.apiKey <key>
84
- searchfuse config set firecrawl.keylessFetch false
85
- searchfuse config set cooldown off
86
- ```
87
-
88
- 不做任何设置就能开跑:搜索和单页抓取默认运行在 Firecrawl 的免注册免费额度上(每月 1,000 免费 credits,无需注册),搜索还能依次退到 Keenable 的免注册额度(每个 IP 每小时 1,000 次)、AnySearch 的匿名档(按 IP 限流,配 key 可解开)、You.com 的免注册搜索(每个 IP 每天 100 次),以及随包的 SearXNG 实例(不需要 key)。免注册公网抓取默认开启,它会把请求的 URL 交给 Firecrawl 的云端爬虫,结果中的 warning 会标明这条路径。`firecrawl.keylessFetch false` 可让自动抓取只走本地。私有或保留地址不会发给 Firecrawl,而会落到本地抓取器。
89
-
90
- 完整说明见[引擎配置手册](../skills/searchfuse/references/configure.md)和[安全说明](security.md)。
91
-
92
- ## 在网页端配置
93
-
94
- dsh 网页端没有终端,所以插件自带一张设置卡片。dsh 0.1.6-alpha.2 及之后的版本里,它在插件自己的页面上:在侧栏点开「插件」,进入 `@wenaixi/searchfuse`。更早的 dsh 版本把它显示为「设置 → 插件 → 插件配置」里的**搜索引擎(SearchFuse)**卡片(dsh 自带的「网页搜索」卡片是 DeepSeek 自己的搜索提供方,两者不是一回事)。无论在哪,它改的都是 CLI 改的那份 `~/.searchfuse/config.json`,走插件注册的路由 `/searchfuse/config`。这份文件属于当前系统用户,不属于某个 dsh profile,所以本机所有 dsh profile 和 CLI 共用同一套引擎设置。
95
-
96
- 卡片管四件事:
97
-
98
- - 首选引擎:自动,或 `antigravity-cli`、`tavily`、`exa`、`firecrawl`、`keenable`、`anysearch`、`youcom`、`searxng`、`grok-cli` 之一。`firecrawl`、`keenable`、`anysearch`、`youcom` 和 `searxng` 五项标注「免注册免费」。`local` 只抓单页不搜索,所以不在这个列表里,除非配置文件当前就把它设成了 `engine`,那时它照常显示,免得界面与文件不一致。
99
- - 当前所选引擎自己的设置:HTTP 引擎(`tavily`、`exa`、`firecrawl`、`keenable`、`anysearch`,以及 `searxng`——它的接口地址就是实例地址)显示 API 密钥与接口地址,`antigravity-cli` 显示模型,每个引擎都可以单独配一个代理。走自家命令行工具登录的引擎和内置抓取器只显示一行说明,因为它们两样都不需要。选中未配置密钥的 `firecrawl`、`keenable` 或 `anysearch` 时会多一行说明,讲清它默认跑在免注册的免费额度上。选中 `youcom` 时不显示密钥框,改显示一行说明,因为它只有免注册这一种用法。
100
- - 自动引擎链:只列出 `searchfuse doctor` 判定本机已就绪的搜索引擎,每个一个复选框,勾选表示允许自动路由使用它。本机跑不了的引擎不出现在这里,它们不是需要用户做的决定。`local` 是单页抓取,不参与搜索,所以也不在这排里。`grok-cli` 只服务 X 搜索,旁边标注「仅 X 搜索」。读不到 doctor 结果时会列出全部搜索引擎并说明状态未知。保存成功后卡片会重新问一次 doctor,刚配好密钥的引擎马上就能长出复选框。
101
- - 曝光矩阵:每个引擎一个四选一——融入 `web_search`、作为独立工具、两者兼得、或关闭,外加独立形态下用的工具名。默认是只融入,但 `antigravity-cli` 默认关闭。卡片显示的是**生效状态**,所以一个因为从未被启用而关着的引擎,看起来不会和一个被手动关掉的引擎一样。
102
-
103
- 每个引擎默认都勾选,但插件主动留着不启用的一个除外:`antigravity-cli`。卡片把它们的关闭状态连同理由一起显示出来,而不是假装它们是开着的。取消勾选只写入 `enabled: false`,重新勾选会删除这项覆盖,不保存多余的 `true`。取消当前首选引擎时,首选项会回到自动。卡片只改自己列出来的引擎:没有复选框的引擎(本机跑不了的,以及 `local`)的 `enabled` 一律原样带过,改它们只能用 `searchfuse config set <engine>.enabled`。本机一个就绪引擎都没有时,这排复选框换成一行提示,说明本机暂无就绪的引擎。
104
-
105
- Tavily、Exa、Firecrawl、Keenable、AnySearch 的官方接口地址内置在 provider 代码里,SearXNG 没有官方主机(它连你填的实例,或随包实例)。界面的接口地址只表示覆盖值。留空或清空都会使用内置官方地址,不会把默认 URL 写进配置文件。
106
-
107
- 其余设置仍然只走 CLI,包括 `bin`、`allowPrivateNetwork`、`cooldown` 和 `keylessFetch`。卡片保存时会原样带过这些字段,也无法新建它们。
108
-
109
- 密钥的处理:
110
-
111
- - 浏览器拿不到已保存的密钥,只知道有没有。密钥框留空保存,原密钥保持不变。
112
- - 多个密钥写在同一个输入框中,用英文逗号分隔。SearchFuse 会按顺序尝试,鉴权、限流或配额失败时自动轮换。其他失败不会逐个尝试所有密钥,而是继续走引擎后备链。
113
- - 环境变量里的密钥在运行时仍然优先于配置文件,卡片会直说这一点,而不是让人以为保存改变了结果。
114
- - 插件不限制 Host、Origin 或 Fetch Metadata 请求头,域名反代和局域网部署都可以读取、保存设置。部署时,认证必须同时覆盖 `/searchfuse/config` 和 dsh 本身。这个直接注册的插件路由不会自动继承 dsh Connection 的登录认证。
115
- - 写盘方式与 CLI 一致:先写一个新的 0600 临时文件,再重命名覆盖。
116
- - 这个路由只在插件开启时存在。在「插件」页关掉 bundle 会把它一起撤下,重新打开后不用重启就会恢复。
117
-
118
- ## 配置 dsh 插件
119
-
120
- 插件开关写在 profile patch 中,通常是 `~/.dsh/profiles/<name>/cordis.patch.yml`。后应用的 profile patch 会覆盖 bundle 行:
121
-
122
- ```yaml
123
- - id: modsearch
124
- config:
125
- searchProvider: true
126
- xSearch: true
127
- readPage: true
128
- settingsCard: true
129
- providerTimeoutMs: 40000
130
- providerDeadlineMs: 55000
131
- ```
132
-
133
- 所有字段都可省略:
134
-
135
- | 字段 | 默认值 | 作用 |
136
- | :-- | :-- | :-- |
137
- | `searchProvider` | `true` | 向 dsh web 接缝注册 SearchFuse。 |
138
- | `xSearch` | `true` | 注册 `x_search`。 |
139
- | `readPage` | `true` | 注册 `read_page`。 |
140
- | `settingsCard` | `true` | 提供设置卡片与 `/searchfuse/config` 路由。关掉后两者都不注册,浏览器那半边也随之停手。 |
141
- | `providerTimeoutMs` | `40000` | `web_search` provider 路径上单个引擎最多用多久(即 CLI 的 `--timeout`)。要明显小于 `providerDeadlineMs`,备用引擎才轮得到。 |
142
- | `providerDeadlineMs` | `55000` | `web_search` 整次运行最多用多久,所有引擎合计(即 CLI 的 `--deadline`)。应小于 dsh 的工具预算,自带搜索路由是 60 秒。 |
143
-
144
- 只关闭 `x_search` 或 `read_page` 不会影响别的能力。关闭 `searchProvider` 时还要把 web 接缝指向另一个已注册 provider。否则 dsh 仍被配置成选择 `searchfuse`,但对应 provider 已不存在:
145
-
146
- ```yaml
147
- - id: web
148
- config:
149
- searchProvider: deepseek-official
150
- fetchProvider: http
151
-
152
- - id: modsearch
153
- config:
154
- searchProvider: false
155
- ```
156
-
157
- 修改 patch 后运行 `--dump-config`。dsh patch 行会整体替换目标行的 `config`,所以同一行需要保留的值必须全部重写。
158
-
159
- **注意 `- id: modsearch` 不是笔误。** 那是 bundle 在 `cordis.patch.yml` 里注册的插件 id,也是 web 接缝 `searchProvider` 指向的名字。包名改过(`@liustack/modsearch` → `@wenaixi/searchfuse`),但这个 id 一直保留,改它会让接缝找不到 provider。
160
-
161
- ## 运行时验证
162
-
163
- 按 dsh 的标准入口启动 profile:
164
-
165
- ```sh
166
- npx -y @deepseek-ai/dsh --profile web
167
- ```
168
-
169
- 依次使用三个小问题:
170
-
171
- 1. `搜索当前 Node.js LTS 版本并引用来源。`
172
- 2. `搜索 X 上 @deepseek_ai 最近的帖子。`
173
- 3. `读取 https://example.com 并总结页面。`
174
-
175
- 第一个调用应使用 dsh 原生 `web_search` 卡片。后两个应分别显示为 `x_search` 和 `read_page`。工具存在但引擎失败时,运行 `searchfuse doctor`。
176
-
177
- ## 更新与卸载
178
-
179
- 用当前精确版本刷新 profile 中记录的请求:
180
-
181
- ```sh
182
- npx -y @deepseek-ai/dsh plugin --profile <name> add @wenaixi/searchfuse@0.1.0
183
- ```
184
-
185
- 卸载命令:
186
-
187
- ```sh
188
- npx -y @deepseek-ai/dsh plugin --profile <name> remove @wenaixi/searchfuse
189
- ```
190
-
191
- 如果用户 patch 仍写着 `searchProvider: modsearch`,卸载后要修改或删除该覆盖。
192
-
193
- ## 故障定位
194
-
195
- - `declares no dsh.bundle`:装到了不带 dsh 插件的旧版本。按上方精确版本重新安装。
196
- - `searchfuse's CLI build is missing`,或报 `Cannot find module .../dist/main.js`:插件是从 GitHub 仓库装的,而仓库只有源码、没有构建产物。卸载后按包名 `@wenaixi/searchfuse` 重新添加。
197
- - `web seam has no registerSearchProvider`:dsh 移动了开发预览接口。`x_search` 与 `read_page` 仍会注册,网页搜索则跳过并打印明确日志。修改插件前先检查最新 dsh release。
198
- - `searchfuse failed (exit ...)`:运行 `searchfuse doctor`。错误会保留 CLI 尝试过的引擎。
199
- - `plugin list` 有包但 `--dump-config` 没有:检查 `~/.dsh/profiles/<name>/package.json` 的 `dsh.profile.bundles` 中是否存在该包。
200
- - Electron 又打开一个应用进程,没有运行 CLI:插件会给子进程设置 `ELECTRON_RUN_AS_NODE=1`。
201
- - `settings namespace skipped: TypeError: scope.settings.register is not a function`:dsh 0.1.7 起改用按已服务命名空间分发插件卡片,而旧版 SearchFuse 只注册了空 schema。搜索和两个工具照常可用,只是设置卡片缺失。装当前版本即可。
202
- - 插件页上看不到 SearchFuse 的设置:dsh 0.1.6-alpha.2 把插件设置搬到了插件页,而更早的 SearchFuse 只把卡片交给旧的设置页插槽。装当前版本即可。如果配置了 `settingsCard: false`,卡片是被有意关掉的。
203
- - `settings card route skipped: Error: webserver: duplicate exact route "/searchfuse/config"`:旧版在「插件」页关掉插件时没有撤下路由。重启 dsh,或装当前版本。
204
-
205
- CLI 自身的错误见[故障排查](troubleshooting.md)。