dsh-zhihu-search 1.2.4 → 1.2.6

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
@@ -1,18 +1,41 @@
1
- # dsh-zhihu-search
1
+ <p align="center">
2
+ <h1 align="center">dsh-zhihu-search</h1>
3
+ </p>
2
4
 
3
- [![CI](https://github.com/zlZayn/dsh-zhihu-search/actions/workflows/ci.yml/badge.svg)](https://github.com/zlZayn/dsh-zhihu-search/actions/workflows/ci.yml)
4
- [![npm](https://img.shields.io/npm/v/dsh-zhihu-search.svg)](https://www.npmjs.com/package/dsh-zhihu-search)
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
- [![Node](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](.node-version)
7
- [![DSH](https://img.shields.io/badge/DSH-0.1.5--rc.2-blue.svg)](package.json)
5
+ <div align="center">
6
+ <p><strong>赋予 DeepSeek Harness 检索知乎社区的能力</strong></p>
7
+ <p><em>Empowering DeepSeek Harness with Zhihu Insights</em></p>
8
8
 
9
- [简体中文](README.md) | [English](README_en.md)
9
+ <p>
10
+ <a href="https://developer.zhihu.com/"><img src="https://img.shields.io/badge/Zhihu%20Open%20Platform-Official%20API-0084FF?style=flat&logo=zhihu&logoColor=white" alt="知乎开放平台官方 API"></a>
11
+ <a href="https://github.com/deepseek-ai/deepseek-harness"><img src="https://img.shields.io/badge/DeepSeek%20Harness-Plugin-4176E6?style=flat" alt="DeepSeek Harness Plugin"></a>
12
+ <a href="https://github.com/topics/dsh-plugin"><img src="https://img.shields.io/badge/dsh--plugin-Auto%20Discovered-orange?style=flat" alt="dsh-plugin"></a>
13
+ </p>
10
14
 
11
- 给 DSH 装上知乎:站内检索、全网检索与直答三个工具,返回可引用的来源列表,而不是一段无法核对的摘要。
15
+ <p>
16
+ <a href="https://github.com/zlZayn/dsh-zhihu-search/actions/workflows/ci.yml"><img src="https://github.com/zlZayn/dsh-zhihu-search/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
17
+ <a href="https://www.npmjs.com/package/dsh-zhihu-search"><img src="https://img.shields.io/npm/v/dsh-zhihu-search.svg" alt="npm"></a>
18
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="MIT 许可证"></a>
19
+ <a href="https://slsa.dev/"><img src="https://img.shields.io/badge/SLSA-Provenance-green?logo=slsa" alt="SLSA Provenance"></a>
20
+ </p>
21
+
22
+ <p>
23
+ <strong><a href="README.md">简体中文</a></strong> · <a href="README_en.md">English</a>
24
+ </p>
25
+ </div>
26
+
27
+ ---
12
28
 
13
- ![插件配置页中的「知乎搜索」卡片](https://raw.githubusercontent.com/zlZayn/dsh-zhihu-search/main/assets/settings-card.png)
29
+ > [!NOTE]
30
+ > **基于知乎开放平台官方 API 构建**,非爬虫抓取。所有检索结果均附带可引用的原始链接,知乎站内结果另附点赞数,让模型的每一次回答都有据可查。
31
+
32
+ 给 DSH 装上知乎:站内检索、全网检索与直答三个工具,返回可引用的来源列表,而不是一段无法核对的摘要。
14
33
 
15
- *在 **设置 → 插件 → 插件配置** 中与其他插件并排,Access Secret 就地填写、立即生效。*
34
+ <p align="center">
35
+ <img src="assets/settings-card.png" alt="插件配置页中的「知乎搜索」卡片" width="600">
36
+ <br>
37
+ <em>在 <strong>设置 → 插件 → 插件配置</strong> 中与其他插件并排,Access Secret 就地填写、立即生效。</em>
38
+ </p>
16
39
 
17
40
  ## 工具一览
18
41
 
package/README_en.md CHANGED
@@ -1,18 +1,41 @@
1
- # dsh-zhihu-search
2
-
3
- [![CI](https://github.com/zlZayn/dsh-zhihu-search/actions/workflows/ci.yml/badge.svg)](https://github.com/zlZayn/dsh-zhihu-search/actions/workflows/ci.yml)
4
- [![npm](https://img.shields.io/npm/v/dsh-zhihu-search.svg)](https://www.npmjs.com/package/dsh-zhihu-search)
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
- [![Node](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](.node-version)
7
- [![DSH](https://img.shields.io/badge/DSH-0.1.5--rc.2-blue.svg)](package.json)
8
-
9
- [简体中文](README.md) | [English](README_en.md)
10
-
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
-
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
-
15
- *Sits alongside your other plugins in **Settings → Plugins → Plugin configuration**; the Access Secret is entered right there and takes effect immediately.*
1
+ <p align="center">
2
+ <h1 align="center">dsh-zhihu-search</h1>
3
+ </p>
4
+
5
+ <div align="center">
6
+ <p><strong>Empowering DeepSeek Harness with Zhihu Insights</strong></p>
7
+ <p><em>赋予 DeepSeek Harness 检索知乎社区的能力</em></p>
8
+
9
+ <p>
10
+ <a href="https://developer.zhihu.com/"><img src="https://img.shields.io/badge/Zhihu%20Open%20Platform-Official%20API-0084FF?style=flat&logo=zhihu&logoColor=white" alt="Zhihu Open Platform Official API"></a>
11
+ <a href="https://github.com/deepseek-ai/deepseek-harness"><img src="https://img.shields.io/badge/DeepSeek%20Harness-Plugin-4176E6?style=flat" alt="DeepSeek Harness Plugin"></a>
12
+ <a href="https://github.com/topics/dsh-plugin"><img src="https://img.shields.io/badge/dsh--plugin-Auto%20Discovered-orange?style=flat" alt="dsh-plugin"></a>
13
+ </p>
14
+
15
+ <p>
16
+ <a href="https://github.com/zlZayn/dsh-zhihu-search/actions/workflows/ci.yml"><img src="https://github.com/zlZayn/dsh-zhihu-search/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
17
+ <a href="https://www.npmjs.com/package/dsh-zhihu-search"><img src="https://img.shields.io/npm/v/dsh-zhihu-search.svg" alt="npm"></a>
18
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="MIT License"></a>
19
+ <a href="https://slsa.dev/"><img src="https://img.shields.io/badge/SLSA-Provenance-green?logo=slsa" alt="SLSA Provenance"></a>
20
+ </p>
21
+
22
+ <p>
23
+ <a href="README.md">简体中文</a> · <strong><a href="README_en.md">English</a></strong>
24
+ </p>
25
+ </div>
26
+
27
+ ---
28
+
29
+ > [!NOTE]
30
+ > **Built on the official Zhihu Open Platform API**, not web scraping. All search results include citable original links, and Zhihu's own results also carry their upvote counts, ensuring every model response is verifiable.
31
+
32
+ Equips DSH with three Zhihu tools: in-site search, global web search, and Zhida direct answers — returning a list of citable sources instead of an unverifiable summary.
33
+
34
+ <p align="center">
35
+ <img src="assets/settings-card_en.png" alt="Zhihu Search card in the plugin settings" width="600">
36
+ <br>
37
+ <em>Sits alongside other plugins in <strong>Settings → Plugins → Plugin configuration</strong>. Enter your Access Secret and it takes effect immediately.</em>
38
+ </p>
16
39
 
17
40
  ## Tools
18
41
 
@@ -41,7 +41,12 @@ 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
- const meta = [`**作者**: ${item.author || '匿名'}`, `**点赞**: ${String(item.voteUpCount)}`];
44
+ const meta = [`**作者**: ${item.author || '匿名'}`];
45
+ // 点赞段只对知乎内容渲染。
46
+ // 全网搜索会混进第三方网页:外站没有「知乎点赞」这回事,上游对它恒报 0,
47
+ // 渲染出来就是把「不适用」说成「没人赞」——所以连同缺失一起整段省略。
48
+ if (item.contentType !== '' && item.voteUpCount !== undefined)
49
+ meta.push(`**点赞**: ${String(item.voteUpCount)}`);
45
50
  // 类型缺失时整段省略,而不是渲染成空的「类型: 」。
46
51
  if (item.contentType !== '')
47
52
  meta.push(`**类型**: ${item.contentType}`);
@@ -39,9 +39,12 @@ function projectItem(item) {
39
39
  url,
40
40
  snippet: sanitizeSnippet(typeof item.ContentText === 'string' ? item.ContentText : ''),
41
41
  author: sanitizeSnippet(typeof item.AuthorName === 'string' ? item.AuthorName : '', 60),
42
- voteUpCount: typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? item.VoteUpCount : 0,
43
- // ContentType 缺失时留空,不编造标签:实测第三方网页(如接单平台)就没有这个字段,
44
- // 兜底成 'Article' 会让模型把广告页当成知乎文章。
42
+ // 上游没报点赞数时整个键省略,不兜底成 0 —— 写 0 等于告诉模型「没人赞」。
43
+ // 注意实测结论:上游**从未省略**该字段,外站网页也有这个键、值是占位的 0。
44
+ // 省略分支是防伪造的兜底;外站那个 0 由渲染层决定不展示(present/search.ts)。
45
+ ...(typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? { voteUpCount: item.VoteUpCount } : {}),
46
+ // ContentType 缺失时留空,不编造标签:实测第三方网页(如接单平台)的类型是**空串**
47
+ // (字段在、值为空),兜底成 'Article' 会让模型把广告页当成知乎文章。
45
48
  contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
46
49
  };
47
50
  }
@@ -83,7 +86,7 @@ export function createZhihuGlobalSearchTool(deps) {
83
86
  url: { type: 'string', required: true },
84
87
  snippet: { type: 'string', required: true },
85
88
  author: { type: 'string', required: true },
86
- voteUpCount: { type: 'number', required: true },
89
+ voteUpCount: { type: 'number' },
87
90
  contentType: { type: 'string', required: true },
88
91
  },
89
92
  },
@@ -41,8 +41,11 @@ function projectItem(item) {
41
41
  url,
42
42
  snippet: sanitizeSnippet(typeof item.ContentText === 'string' ? item.ContentText : ''),
43
43
  author: sanitizeSnippet(typeof item.AuthorName === 'string' ? item.AuthorName : '', 60),
44
- voteUpCount: typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? item.VoteUpCount : 0,
45
- // ContentType 缺失时留空,不编造标签:实测外部网页根本没有这个字段,
44
+ // 上游没报点赞数时整个键省略,不兜底成 0 —— 写 0 等于告诉模型「没人赞」。
45
+ // 注意实测结论:上游**从未省略**该字段,外站网页也有这个键、值是占位的 0。
46
+ // 省略分支是防伪造的兜底;外站那个 0 由渲染层决定不展示(present/search.ts)。
47
+ ...(typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? { voteUpCount: item.VoteUpCount } : {}),
48
+ // ContentType 缺失时留空,不编造标签:实测外站网页的类型是**空串**(字段在、值为空),
46
49
  // 兜底成 'Answer' 会让模型把一个陌生网页当成知乎回答。
47
50
  contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
48
51
  };
@@ -100,7 +103,7 @@ export function createZhihuSearchTool(deps) {
100
103
  url: { type: 'string', required: true },
101
104
  snippet: { type: 'string', required: true },
102
105
  author: { type: 'string', required: true },
103
- voteUpCount: { type: 'number', required: true },
106
+ voteUpCount: { type: 'number' },
104
107
  contentType: { type: 'string', required: true },
105
108
  },
106
109
  },
package/lib/types.d.ts CHANGED
@@ -114,7 +114,13 @@ export interface SearchOutput {
114
114
  /** 已清洗 <em> 标签的纯文本摘要。 */
115
115
  snippet: string;
116
116
  author: string;
117
- voteUpCount: number;
117
+ /**
118
+ * 点赞数。上游没报该字段时**整个键省略**,不兜底成 0。
119
+ *
120
+ * 实测(30 条样本)上游**从未省略**该字段:外站网页也有这个键,值是占位的 `0`,
121
+ * 它不代表「没人赞」。省略分支是防伪造的兜底,外站那个 0 不在渲染层展示。
122
+ */
123
+ voteUpCount?: number;
118
124
  contentType: string;
119
125
  }>;
120
126
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-zhihu-search",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
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",