dsh-zhihu-search 1.2.3 → 1.2.5
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 +35 -12
- package/README_en.md +35 -12
- package/lib/present/search.js +4 -1
- package/lib/tools/global-search.js +7 -4
- package/lib/tools/search.js +4 -2
- package/lib/types.d.ts +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">dsh-zhihu-search</h1>
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[](.node-version)
|
|
7
|
-
[](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
|
-
|
|
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
|
-
|
|
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
|
-
!
|
|
29
|
+
> [!NOTE]
|
|
30
|
+
> **基于知乎开放平台官方 API 构建**,非爬虫抓取。所有检索结果均附带可引用的原始链接,知乎站内结果另附点赞数,让模型的每一次回答都有据可查。
|
|
31
|
+
|
|
32
|
+
给 DSH 装上知乎:站内检索、全网检索与直答三个工具,返回可引用的来源列表,而不是一段无法核对的摘要。
|
|
14
33
|
|
|
15
|
-
|
|
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
|
|
|
@@ -21,7 +44,7 @@
|
|
|
21
44
|
| 工具 | 一句话说明 | 适用场景 |
|
|
22
45
|
|---|---|---|
|
|
23
46
|
| `zhihu_search` | 知乎站内问答与文章搜索,支持按点赞/评论/时间排序 | 中文经验、产品评测、行业讨论、技术实践 |
|
|
24
|
-
| `zhihu_global_search` |
|
|
47
|
+
| `zhihu_global_search` | 知乎全网索引搜索,可按域名和时间过滤;结果会混入知乎站内内容 | 查找特定网站上的公开资料 |
|
|
25
48
|
| `zhihu_zhida` | 知乎直答,成体系的综合性回答 | 需要「先检索再总结」的复杂中文问题 |
|
|
26
49
|
|
|
27
50
|
下面三个小节是每个工具的完整参数与能力边界。模型只看到下表中的语义化参数——知乎原生的字符串查询语法由插件内部编译,模型接触不到,也就不可能写错。
|
|
@@ -51,7 +74,7 @@
|
|
|
51
74
|
| `publishedBefore` | string | — | 只要该日期之前发布的内容,格式 `YYYY-MM-DD`。 |
|
|
52
75
|
| `searchDb` | enum | `all` | `all` 全部 · `realtime` 偏最新 · `static` 偏长期收录。 |
|
|
53
76
|
|
|
54
|
-
|
|
77
|
+
**边界**:**没有排序参数**——该端点会忽略排序字段,与其给模型一个转不动的旋钮,不如不给。**也没有翻页参数**:单次最多 20 条,超出由服务端截断。`site` 不接受 `zhihu.com` 及其子域,知乎会直接拒绝该请求。结果里**会混入知乎站内内容**;要专搜知乎的问答和文章,用 `zhihu_search`。
|
|
55
78
|
|
|
56
79
|
### `zhihu_zhida` —— 直答
|
|
57
80
|
|
package/README_en.md
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">dsh-zhihu-search</h1>
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[](.node-version)
|
|
7
|
-
[](package.json)
|
|
5
|
+
<div align="center">
|
|
6
|
+
<p><strong>Empowering DeepSeek Harness with Zhihu Insights</strong></p>
|
|
7
|
+
<p><em>赋予 DeepSeek Harness 检索知乎社区的能力</em></p>
|
|
8
8
|
|
|
9
|
-
|
|
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>
|
|
10
14
|
|
|
11
|
-
|
|
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>
|
|
12
21
|
|
|
13
|
-
|
|
22
|
+
<p>
|
|
23
|
+
<a href="README.md">简体中文</a> · <strong><a href="README_en.md">English</a></strong>
|
|
24
|
+
</p>
|
|
25
|
+
</div>
|
|
14
26
|
|
|
15
|
-
|
|
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
|
|
|
@@ -21,7 +44,7 @@ Installing adds three tools to the model:
|
|
|
21
44
|
| Tool | One line | Use it for |
|
|
22
45
|
|---|---|---|
|
|
23
46
|
| `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;
|
|
47
|
+
| `zhihu_global_search` | Searches Zhihu's global web index; the results mix in some Zhihu content | Finding material on a specific site |
|
|
25
48
|
| `zhihu_zhida` | Zhihu Zhida: a synthesized answer that pulls a topic together | Complex Chinese questions that need "retrieve, then summarize" |
|
|
26
49
|
|
|
27
50
|
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 +74,7 @@ The three sections below are each tool's full parameter set and limits. The mode
|
|
|
51
74
|
| `publishedBefore` | string | — | Only content published before this date, `YYYY-MM-DD`. |
|
|
52
75
|
| `searchDb` | enum | `all` | `all` · `realtime` newest · `static` long-term index. |
|
|
53
76
|
|
|
54
|
-
**Limits**: **there is no sorting parameter
|
|
77
|
+
**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
78
|
|
|
56
79
|
### `zhihu_zhida` — Zhida
|
|
57
80
|
|
package/lib/present/search.js
CHANGED
|
@@ -41,7 +41,10 @@ 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 || '匿名'}
|
|
44
|
+
const meta = [`**作者**: ${item.author || '匿名'}`];
|
|
45
|
+
// 点赞数缺失时整段省略:写 `**点赞**: 0` 会把「不知道」说成「没人赞」。
|
|
46
|
+
if (item.voteUpCount !== undefined)
|
|
47
|
+
meta.push(`**点赞**: ${String(item.voteUpCount)}`);
|
|
45
48
|
// 类型缺失时整段省略,而不是渲染成空的「类型: 」。
|
|
46
49
|
if (item.contentType !== '')
|
|
47
50
|
meta.push(`**类型**: ${item.contentType}`);
|
|
@@ -39,7 +39,9 @@ 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
|
-
|
|
42
|
+
// 上游没报点赞数时整个键省略,不兜底成 0:全网的第三方网页没有这个字段,
|
|
43
|
+
// 写 0 等于告诉模型「这个页面没人赞」,而事实是「不知道」。
|
|
44
|
+
...(typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? { voteUpCount: item.VoteUpCount } : {}),
|
|
43
45
|
// ContentType 缺失时留空,不编造标签:实测第三方网页(如接单平台)就没有这个字段,
|
|
44
46
|
// 兜底成 'Article' 会让模型把广告页当成知乎文章。
|
|
45
47
|
contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
|
|
@@ -54,8 +56,9 @@ function projectItem(item) {
|
|
|
54
56
|
export function createZhihuGlobalSearchTool(deps) {
|
|
55
57
|
return defineTool({
|
|
56
58
|
name: ZHIHU_GLOBAL_SEARCH_TOOL,
|
|
57
|
-
description: '
|
|
58
|
-
'
|
|
59
|
+
description: '知乎全网索引搜索:检索知乎索引收录的公开网页,结果里会混入部分知乎站内内容。' +
|
|
60
|
+
'适合按站点域名或发布时间找资料;要专搜知乎的问答和文章、且要更贴题的排序,用 zhihu_search。' +
|
|
61
|
+
`单次最多 ${String(MAX_COUNT)} 条且没有翻页参数;域名过滤不接受知乎域名。`,
|
|
59
62
|
parameters: {
|
|
60
63
|
query: { type: 'string', required: true, description: '搜索关键词。' },
|
|
61
64
|
count: { type: 'integer', description: `返回条数,1–${String(MAX_COUNT)},默认 ${String(DEFAULT_COUNT)}。`, default: DEFAULT_COUNT },
|
|
@@ -82,7 +85,7 @@ export function createZhihuGlobalSearchTool(deps) {
|
|
|
82
85
|
url: { type: 'string', required: true },
|
|
83
86
|
snippet: { type: 'string', required: true },
|
|
84
87
|
author: { type: 'string', required: true },
|
|
85
|
-
voteUpCount: { type: 'number'
|
|
88
|
+
voteUpCount: { type: 'number' },
|
|
86
89
|
contentType: { type: 'string', required: true },
|
|
87
90
|
},
|
|
88
91
|
},
|
package/lib/tools/search.js
CHANGED
|
@@ -41,7 +41,9 @@ 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
|
-
|
|
44
|
+
// 上游没报点赞数时整个键省略,不兜底成 0:全网的第三方网页没有这个字段,
|
|
45
|
+
// 写 0 等于告诉模型「这个页面没人赞」,而事实是「不知道」。
|
|
46
|
+
...(typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? { voteUpCount: item.VoteUpCount } : {}),
|
|
45
47
|
// ContentType 缺失时留空,不编造标签:实测外部网页根本没有这个字段,
|
|
46
48
|
// 兜底成 'Answer' 会让模型把一个陌生网页当成知乎回答。
|
|
47
49
|
contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
|
|
@@ -100,7 +102,7 @@ export function createZhihuSearchTool(deps) {
|
|
|
100
102
|
url: { type: 'string', required: true },
|
|
101
103
|
snippet: { type: 'string', required: true },
|
|
102
104
|
author: { type: 'string', required: true },
|
|
103
|
-
voteUpCount: { type: 'number'
|
|
105
|
+
voteUpCount: { type: 'number' },
|
|
104
106
|
contentType: { type: 'string', required: true },
|
|
105
107
|
},
|
|
106
108
|
},
|
package/lib/types.d.ts
CHANGED
|
@@ -114,7 +114,11 @@ export interface SearchOutput {
|
|
|
114
114
|
/** 已清洗 <em> 标签的纯文本摘要。 */
|
|
115
115
|
snippet: string;
|
|
116
116
|
author: string;
|
|
117
|
-
|
|
117
|
+
/**
|
|
118
|
+
* 点赞数。上游没报该字段时**整个键省略**,不兜底成 0 ——
|
|
119
|
+
* 全网的第三方网页就不带这个字段,「0 赞」与「不知道」是两回事。
|
|
120
|
+
*/
|
|
121
|
+
voteUpCount?: number;
|
|
118
122
|
contentType: string;
|
|
119
123
|
}>;
|
|
120
124
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-zhihu-search",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
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",
|