dsh-zhihu-search 1.2.2 → 1.2.4

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
@@ -10,7 +10,7 @@
10
10
 
11
11
  给 DSH 装上知乎:站内检索、全网检索与直答三个工具,返回可引用的来源列表,而不是一段无法核对的摘要。
12
12
 
13
- ![插件配置页中的「知乎搜索」卡片](https://raw.githubusercontent.com/zlZayn/dsh-zhihu-search/main/docs/images/settings-card.png)
13
+ ![插件配置页中的「知乎搜索」卡片](https://raw.githubusercontent.com/zlZayn/dsh-zhihu-search/main/assets/settings-card.png)
14
14
 
15
15
  *在 **设置 → 插件 → 插件配置** 中与其他插件并排,Access Secret 就地填写、立即生效。*
16
16
 
@@ -21,7 +21,7 @@
21
21
  | 工具 | 一句话说明 | 适用场景 |
22
22
  |---|---|---|
23
23
  | `zhihu_search` | 知乎站内问答与文章搜索,支持按点赞/评论/时间排序 | 中文经验、产品评测、行业讨论、技术实践 |
24
- | `zhihu_global_search` | 知乎全网索引搜索,可按域名和时间过滤 | 查找特定网站上的公开资料 |
24
+ | `zhihu_global_search` | 知乎全网索引搜索,可按域名和时间过滤;结果会混入知乎站内内容 | 查找特定网站上的公开资料 |
25
25
  | `zhihu_zhida` | 知乎直答,成体系的综合性回答 | 需要「先检索再总结」的复杂中文问题 |
26
26
 
27
27
  下面三个小节是每个工具的完整参数与能力边界。模型只看到下表中的语义化参数——知乎原生的字符串查询语法由插件内部编译,模型接触不到,也就不可能写错。
@@ -51,7 +51,7 @@
51
51
  | `publishedBefore` | string | — | 只要该日期之前发布的内容,格式 `YYYY-MM-DD`。 |
52
52
  | `searchDb` | enum | `all` | `all` 全部 · `realtime` 偏最新 · `static` 偏长期收录。 |
53
53
 
54
- **边界**:**没有排序参数**。该端点会忽略排序字段,与其给模型一个转不动的旋钮,不如不给。**也没有翻页参数**:`hasMore` 为 `true` 时结果里会写明未全部返回,提示模型收窄关键词或补过滤条件后重搜。`site` 不接受 `zhihu.com` 及其子域——知乎会直接拒绝该请求,要搜知乎站内内容请用 `zhihu_search`。
54
+ **边界**:**没有排序参数**——该端点会忽略排序字段,与其给模型一个转不动的旋钮,不如不给。**也没有翻页参数**:单次最多 20 条,超出由服务端截断。`site` 不接受 `zhihu.com` 及其子域,知乎会直接拒绝该请求。结果里**会混入知乎站内内容**;要专搜知乎的问答和文章,用 `zhihu_search`。
55
55
 
56
56
  ### `zhihu_zhida` —— 直答
57
57
 
package/README_en.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  Zhihu for DSH: in-site search, global-index search and Zhida — three tools that return a citable list of sources instead of a summary you cannot check.
12
12
 
13
- ![The "Zhihu Search" card in the plugin configuration page](https://raw.githubusercontent.com/zlZayn/dsh-zhihu-search/main/docs/images/settings-card_en.png)
13
+ ![The "Zhihu Search" card in the plugin configuration page](https://raw.githubusercontent.com/zlZayn/dsh-zhihu-search/main/assets/settings-card_en.png)
14
14
 
15
15
  *Sits alongside your other plugins in **Settings → Plugins → Plugin configuration**; the Access Secret is entered right there and takes effect immediately.*
16
16
 
@@ -21,7 +21,7 @@ Installing adds three tools to the model:
21
21
  | Tool | One line | Use it for |
22
22
  |---|---|---|
23
23
  | `zhihu_search` | Searches Zhihu's own questions and articles; sortable by votes / comments / time | Chinese experience, product reviews, industry discussion, engineering practice |
24
- | `zhihu_global_search` | Searches Zhihu's global web index; filterable by domain and time | Finding material on a specific site |
24
+ | `zhihu_global_search` | Searches Zhihu's global web index; the results mix in some Zhihu content | Finding material on a specific site |
25
25
  | `zhihu_zhida` | Zhihu Zhida: a synthesized answer that pulls a topic together | Complex Chinese questions that need "retrieve, then summarize" |
26
26
 
27
27
  The three sections below are each tool's full parameter set and limits. The model only ever sees the semantic parameters in these tables — Zhihu's native string query syntax is compiled inside the plugin, so the model cannot get it wrong.
@@ -51,7 +51,7 @@ The three sections below are each tool's full parameter set and limits. The mode
51
51
  | `publishedBefore` | string | — | Only content published before this date, `YYYY-MM-DD`. |
52
52
  | `searchDb` | enum | `all` | `all` · `realtime` newest · `static` long-term index. |
53
53
 
54
- **Limits**: **there is no sorting parameter.** This endpoint ignores the sort field, so the plugin does not offer a knob that does nothing. **There is no pagination parameter either**: when `hasMore` is `true` the result says it is incomplete, telling the model to narrow the keywords or add filters and search again. `site` rejects `zhihu.com` and its subdomains — Zhihu refuses that request outright; use `zhihu_search` for Zhihu content.
54
+ **Limits**: **there is no sorting parameter** — the endpoint ignores the sort field, so the plugin does not offer a knob that does nothing. **There is no pagination parameter either**: at most 20 results per call, and the server truncates anything larger. `site` rejects `zhihu.com` and its subdomains; Zhihu refuses that request outright. The results **mix in some Zhihu content**; to search Zhihu's own questions and articles specifically, use `zhihu_search`.
55
55
 
56
56
  ### `zhihu_zhida` — Zhida
57
57
 
@@ -41,7 +41,11 @@ export function renderSearch(value) {
41
41
  const lines = [`找到 ${String(value.items.length)} 条关于 "${value.query}" 的知乎结果:`, ''];
42
42
  for (const item of value.items) {
43
43
  lines.push(`### [${escapeLinkText(item.title)}](${item.url})`);
44
- lines.push(`**作者**: ${item.author || '匿名'} | **点赞**: ${String(item.voteUpCount)} | **类型**: ${item.contentType}`);
44
+ const meta = [`**作者**: ${item.author || '匿名'}`, `**点赞**: ${String(item.voteUpCount)}`];
45
+ // 类型缺失时整段省略,而不是渲染成空的「类型: 」。
46
+ if (item.contentType !== '')
47
+ meta.push(`**类型**: ${item.contentType}`);
48
+ lines.push(meta.join(' | '));
45
49
  lines.push(`> ${item.snippet}`);
46
50
  lines.push('');
47
51
  }
@@ -40,7 +40,9 @@ function projectItem(item) {
40
40
  snippet: sanitizeSnippet(typeof item.ContentText === 'string' ? item.ContentText : ''),
41
41
  author: sanitizeSnippet(typeof item.AuthorName === 'string' ? item.AuthorName : '', 60),
42
42
  voteUpCount: typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? item.VoteUpCount : 0,
43
- contentType: typeof item.ContentType === 'string' && item.ContentType !== '' ? item.ContentType : 'Article',
43
+ // ContentType 缺失时留空,不编造标签:实测第三方网页(如接单平台)就没有这个字段,
44
+ // 兜底成 'Article' 会让模型把广告页当成知乎文章。
45
+ contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
44
46
  };
45
47
  }
46
48
  /**
@@ -52,8 +54,9 @@ function projectItem(item) {
52
54
  export function createZhihuGlobalSearchTool(deps) {
53
55
  return defineTool({
54
56
  name: ZHIHU_GLOBAL_SEARCH_TOOL,
55
- description: '知乎全网索引搜索:检索知乎索引收录的公开网页,可限定域名与发布时间,适合查找特定网站上的资料。' +
56
- '要搜知乎站内的问答和文章改用 zhihu_search;域名过滤不接受知乎域名。',
57
+ description: '知乎全网索引搜索:检索知乎索引收录的公开网页,结果里会混入部分知乎站内内容。' +
58
+ '适合按站点域名或发布时间找资料;要专搜知乎的问答和文章、且要更贴题的排序,用 zhihu_search。' +
59
+ `单次最多 ${String(MAX_COUNT)} 条且没有翻页参数;域名过滤不接受知乎域名。`,
57
60
  parameters: {
58
61
  query: { type: 'string', required: true, description: '搜索关键词。' },
59
62
  count: { type: 'integer', description: `返回条数,1–${String(MAX_COUNT)},默认 ${String(DEFAULT_COUNT)}。`, default: DEFAULT_COUNT },
@@ -42,7 +42,9 @@ function projectItem(item) {
42
42
  snippet: sanitizeSnippet(typeof item.ContentText === 'string' ? item.ContentText : ''),
43
43
  author: sanitizeSnippet(typeof item.AuthorName === 'string' ? item.AuthorName : '', 60),
44
44
  voteUpCount: typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? item.VoteUpCount : 0,
45
- contentType: typeof item.ContentType === 'string' && item.ContentType !== '' ? item.ContentType : 'Answer',
45
+ // ContentType 缺失时留空,不编造标签:实测外部网页根本没有这个字段,
46
+ // 兜底成 'Answer' 会让模型把一个陌生网页当成知乎回答。
47
+ contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
46
48
  };
47
49
  }
48
50
  /**
package/lib/types.d.ts CHANGED
@@ -34,12 +34,14 @@ export interface ZhihuApiResponse<T> {
34
34
  */
35
35
  export interface ZhihuSearchData {
36
36
  /**
37
- * ⚠ 站内搜索当前**固定返回 false**(官方文档原文)。
38
- * 因此它不能当作「还有下一页」使用,也不能据此提示模型翻页;
39
- * 只有全网搜索的 HasMore 才是真实分页标识。
37
+ * ⚠ 站内搜索按官方文档**固定返回 false**;全网搜索在 12 个宽泛查询的实测里**也全部为 false**。
38
+ * 因此两个端点都不能据此翻页——全网搜索根本没有翻页参数(见 ARCHITECTURE 的防错清单)。
40
39
  */
41
40
  HasMore: boolean;
42
- /** 搜索请求标识,排障用,不面向模型。 */
41
+ /**
42
+ * 搜索请求标识,排障用,不面向模型。
43
+ * ⚠ 实测**不是游标**:原样传回不改变结果(试过 SearchHashId / HashId / Cursor / Offset / Page / Start)。
44
+ */
43
45
  SearchHashId?: string;
44
46
  /** 无结果原因;有结果时为空串。 */
45
47
  EmptyReason?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-zhihu-search",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "DSH plugin: Zhihu in-site search, global web search, and Zhida over the official Zhihu Open Platform API — with a native settings card and source-cited results.",
5
5
  "keywords": [
6
6
  "dsh",