deepseek-web-retrieval 0.6.0 → 0.7.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/README.md +79 -10
  3. package/dist/cli.js +2203 -1826
  4. package/docs/adr/0002-shared-config-base-layer.md +43 -0
  5. package/docs/agents/codex.md +48 -27
  6. package/docs/agents/opencode-v2.md +57 -33
  7. package/docs/agents/pi.md +48 -27
  8. package/docs/design/config-layering-design.md +180 -0
  9. package/docs/design/installer-design.md +8 -0
  10. package/docs/integration.md +6 -3
  11. package/docs/research/control-matrix.md +15 -2
  12. package/docs/research/mcp-compatibility.md +4 -1
  13. package/docs/research/ori-question-sourcing.md +336 -0
  14. package/docs/research/result-quality-passthrough.md +159 -0
  15. package/docs/research/search-api-defaults.md +18 -2
  16. package/docs/research/search-inline-content.md +244 -0
  17. package/examples/opencode.global.jsonc +3 -2
  18. package/package.json +2 -1
  19. package/src/core/auth.ts +3 -0
  20. package/src/core/client.ts +26 -4
  21. package/src/core/config-file.ts +168 -0
  22. package/src/core/config-summary.ts +82 -0
  23. package/src/core/constants.ts +15 -1
  24. package/src/core/descriptions.ts +6 -2
  25. package/src/core/env.ts +99 -32
  26. package/src/core/format.ts +19 -1
  27. package/src/core/options.ts +22 -2
  28. package/src/core/search.ts +6 -0
  29. package/src/core/types.ts +11 -0
  30. package/src/installer/cli.ts +50 -16
  31. package/src/installer/config-command.ts +116 -0
  32. package/src/installer/hosts/codex.ts +5 -3
  33. package/src/installer/hosts/opencode.ts +9 -5
  34. package/src/installer/hosts/pi.ts +10 -6
  35. package/src/installer/ownership.ts +54 -1
  36. package/src/installer/paths.ts +7 -1
  37. package/src/installer/state.ts +72 -19
  38. package/src/installer/types.ts +10 -0
  39. package/src/mcp/auth.ts +2 -3
  40. package/src/mcp/cli.ts +4 -3
  41. package/src/mcp/serve.ts +10 -1
  42. package/src/mcp/server.ts +7 -2
  43. package/src/opencode/plugin.ts +22 -2
  44. package/src/pi/extension.ts +78 -9
package/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project are documented here, with one sentence per item.
3
+ All notable changes to this project are documented here, one sentence per item.
4
+
5
+ ## 0.7.0
6
+
7
+ - Layer a shared config file (`$XDG_CONFIG_HOME/deepseek-web-retrieval/config.json`, camelCase keys) under the environment on every host, with the precedence `built-in defaults < shared file < DEEPSEEK_* environment < host-native config`; unknown and host-integration keys are warned about and ignored, and the API key stays out of the file.
8
+ - Add a `config` command that prints every knob with its effective value and source (default, file, or environment — a count-derived `maxResults` is labeled `count`), replays shared-file problems, and verifies the key, config, and network end to end with `config --search "<query>"`.
9
+ - Forward every `DEEPSEEK_*` option variable — not just the API key — in the Codex installer's `env_vars` entry, so shell-set knobs reach the stdio server without hand-editing `config.toml`.
10
+ - Surface DeepSeek's `rerank_score`, `authority`, and `site_name` on search results in both text and structured output, accept an optional `original_question` on the MCP and Pi search tools (sent as `ori_question`), and add the `searchLocalization` deployment knob.
11
+ - Couple `maxResults` to `count` when left unset — configuring only `count` was a silent no-op — and retry transient failures (408/425/429/5xx) twice by default instead of failing the billed call on the first attempt.
12
+ - Resolve the shared config directory the Windows way on win32 (`%APPDATA%`, with an explicitly set `XDG_CONFIG_HOME` still winning), for the shared config file and the installer's global records alike.
13
+ - Add `init --pin` to register the exact running CLI version (`deepseek-web-retrieval@<version>`) instead of the unpinned name, with package-identity comparisons that still match a pinned ref to its lineage.
14
+ - `config` now warns and exits 1 when a `DEEPSEEK_*` variable is set but unusable (unknown name, non-numeric value, no-op switch value) instead of silently showing the default.
4
15
 
5
16
  ## 0.6.0
6
17
 
package/README.md CHANGED
@@ -75,12 +75,12 @@ Tiers: search=preferred, fetch=preferred
75
75
 
76
76
  Files:
77
77
  ~/.codex/config.toml
78
- set mcp_servers.deepseek = {"command":"npx","args":["-y","deepseek-web-retrieval"],"env_vars":["DEEPSEEK_API_KEY"]} (was (absent))
78
+ set mcp_servers.deepseek = {"command":"npx","args":["-y","deepseek-web-retrieval"],"env_vars":["DEEPSEEK_API_KEY","DEEPSEEK_... (was (absent))
79
79
  ~/.codex/AGENTS.md
80
80
  upsert marked rules block
81
81
 
82
82
  Notes:
83
- - Codex stdio children do not inherit the parent environment, so the entry forwards DEEPSEEK_API_KEY explicitly via env_vars; the key must be set in the shell that launches Codex.
83
+ - Codex stdio children do not inherit the parent environment, so the entry forwards DEEPSEEK_API_KEY and every DEEPSEEK_* option variable explicitly via env_vars; shell-set knobs reach the server without hand-editing config.toml (the shared config file works without any forwarding).
84
84
  - Rules block upserted in ~/.codex/AGENTS.md; Codex reads ~/.codex/AGENTS.md plus every AGENTS.md from the project root to the cwd.
85
85
  - Shared config ownership is recorded in ~/.codex/.config.toml.deepseek-web-retrieval.codex.owner.json; uninstall releases it. Keep this local metadata with the config.
86
86
 
@@ -89,7 +89,10 @@ Plan only — re-run with --apply to write these changes.
89
89
 
90
90
  Repeat your chosen command with `--apply` to write the plan. The host guides explain
91
91
  activation steps and per-host tier limits. Pi defaults to the extension path; add
92
- `--path mcp` to use its MCP fallback.
92
+ `--path mcp` to use its MCP fallback. Add `--pin` to register the exact version of the
93
+ CLI you are running (`deepseek-web-retrieval@<version>`) instead of the unpinned name,
94
+ so hosts keep resolving that release rather than every latest publish — reproducible
95
+ setups trade away auto-updates; re-run `init --pin` from a newer CLI to move the pin.
93
96
 
94
97
  Other stdio MCP hosts may use the server, but the supported setup guides and installer
95
98
  currently cover the three hosts above. See the [integration model](docs/integration.md)
@@ -113,11 +116,17 @@ binary files, per-request billing) are documented there.
113
116
  - Returns at most ten results by default (matching the API's `count` default and the
114
117
  industry norm for AI-native search APIs), deduplicating URLs.
115
118
  - Optional `rerank_score` and `authority` thresholds are off by default — the default
116
- returns exactly what DeepSeek ranked, including results without a score;
117
- when a positive threshold is set, results below it (or without a score to
118
- compare) are dropped.
119
+ returns exactly what DeepSeek ranked, including results without a score. A positive
120
+ `rerank_score` threshold drops results below it and results without a score; a positive
121
+ `authority` threshold drops known authorities below it, while results with an unknown
122
+ authority stay unless `allowUnknownAuthority` is set to false.
119
123
  - Builds `blockedDomains`, `includeDomains`, and `language` into query operators and
120
124
  rejects the final query locally when it exceeds the API's 128-character limit.
125
+ - On the paths where this package defines the search tool's inputs (the MCP server and
126
+ the Pi extension), the tool accepts an optional `original_question` — the user's
127
+ question in their own words — forwarded as DeepSeek's `ori_question`, trimmed and
128
+ truncated to the API's 128 characters; a blank input on the Pi extension falls back
129
+ to the most recent user message in the session.
121
130
  - An empty result set is normal and is not an error.
122
131
 
123
132
  ### Fetch
@@ -134,10 +143,10 @@ binary files, per-request billing) are documented there.
134
143
 
135
144
  ### Timeouts and retries
136
145
 
137
- Request timeouts include reading the response body. Retries are disabled by default;
138
- when enabled, retryable responses are 408, 425, 429, and 5xx, and `Retry-After` is honored
139
- up to 10 seconds. Other failures, including 401, timeouts, and network errors, fail
140
- without retrying.
146
+ Request timeouts include reading the response body. Transient failures are retried twice
147
+ by default (0–5, `maxRetries`); retryable responses are 408, 425, 429, and 5xx, and
148
+ `Retry-After` is honored up to 10 seconds. Other failures, including 401, timeouts, and
149
+ network errors, fail without retrying.
141
150
 
142
151
  ### No automatic fallback
143
152
 
@@ -151,6 +160,66 @@ Queries and URLs are sent to `https://api.deepseek.com`; the API key is sent onl
151
160
  Bearer token to DeepSeek and to nothing else. Retrieval is billed per successful request —
152
161
  see the official docs for pricing and rate limits before enabling a team deployment.
153
162
 
163
+ ## Configuration
164
+
165
+ Every knob resolves through one chain, low → high, identically on every host:
166
+ `built-in defaults < shared config file < DEEPSEEK_* environment < host-native config`
167
+ — a higher layer always wins, so nothing already configured loses effect.
168
+
169
+ The shared file — `$XDG_CONFIG_HOME/deepseek-web-retrieval/config.json`, default
170
+ `~/.config/deepseek-web-retrieval/config.json` on Linux and macOS and
171
+ `%APPDATA%\deepseek-web-retrieval\config.json` on Windows (an explicitly set
172
+ `XDG_CONFIG_HOME` still wins there) — works on every host and uses the
173
+ camelCase option keys:
174
+
175
+ ```json
176
+ {
177
+ "count": 20,
178
+ "blockedDomains": ["pinterest.com"],
179
+ "language": "zh",
180
+ "searchLocalization": "203.0.113.7"
181
+ }
182
+ ```
183
+
184
+ Unknown keys and host-integration keys are warned about on stderr and ignored. The
185
+ API key does not go in the file — it keeps its existing channels (`DEEPSEEK_API_KEY`
186
+ in the environment, or OpenCode's stored credential).
187
+
188
+ Knobs fall into three classes; the shared file carries the first two:
189
+
190
+ | Knob class | Shared file | Examples |
191
+ | --- | --- | --- |
192
+ | API behavior — the user↔DeepSeek relationship | yes — that is the point of the file | `count`, `blockedDomains`, `language`, `maxRetries` |
193
+ | Host-sensitive — interacts with host output caps and deadlines | carries the safe defaults; a host layer is the recommended override point | `searchTimeoutMs`, `fetchTimeoutMs`, `fetchMaxChars`, `maxSummaryChars` |
194
+ | Host integration — the host's tool landscape | rejected — warned about and ignored | `searchEnabled`, `setDefaultWebsearch`, `apiKeySource` |
195
+
196
+ The same knob has two names — the camelCase key for the shared file and OpenCode's
197
+ options, the `DEEPSEEK_*` variable for the environment:
198
+
199
+ | Shared file / OpenCode options | Environment |
200
+ | --- | --- |
201
+ | `count` | `DEEPSEEK_SEARCH_COUNT` |
202
+ | `blockedDomains` | `DEEPSEEK_SEARCH_BLOCKED_DOMAINS` |
203
+ | `language` | `DEEPSEEK_SEARCH_LANGUAGE` |
204
+ | `searchLocalization` | `DEEPSEEK_SEARCH_LOCALIZATION` |
205
+ | `fetchMaxChars` | `DEEPSEEK_FETCH_MAX_CHARS` |
206
+ | `maxRetries` | `DEEPSEEK_MAX_RETRIES` |
207
+
208
+ The full per-knob mapping is documented side by side in each guide's option table;
209
+ per-host mechanics — how the environment reaches a stdio server, each host's output
210
+ caps and deadlines — live there too: [Codex](docs/agents/codex.md),
211
+ [Pi](docs/agents/pi.md), [OpenCode](docs/agents/opencode-v2.md). Keep
212
+ host-independent intent in the shared file; prefer a host layer when a
213
+ host-sensitive knob would cross its host's cap or deadline.
214
+
215
+ To see what actually resolves, run `npx deepseek-web-retrieval config`: every knob
216
+ printed with its value and its source (`default`, `file`, or `env`), plus any problems
217
+ in the file or in `DEEPSEEK_*` variables (unknown names, unusable values) replayed as
218
+ visible warnings — it exits 1 when there are problems, so it doubles as a dotfile CI
219
+ check. `npx deepseek-web-retrieval config --search "<query>"`
220
+ runs one billed search through the effective configuration to verify the key, config,
221
+ and network end to end.
222
+
154
223
  ## Development
155
224
 
156
225
  ```bash