Introduction¶
The core of DeepSeek Harness (DSH) lies in its plugin-based extension capabilities. When an agent needs to access Zhihu data (such as hot lists, question-and-answer details, or user information), directly using browser automation or maintaining hard-coded crawler code is costly. The zhengjy01/dsh-zhihu plugin wraps the locally installed pyzhihu-cli, injects its capabilities into DSH’s tool set (Agent Tools), and provides a Web visualization panel for configuration and login.
Installation and Prerequisites¶
Before using this plugin, ensure that your system has pyzhihu-cli installed (Python 3.10+). The plugin itself depends on DeepSeek Harness >= 0.1.5-rc.1.
- Install pyzhihu-cli:
It is recommended to install it in isolation usinguvorpipx:
uv tool install pyzhihu-cli
# 或
pipx install pyzhihu-cli
After installation, you can verify the version in the terminal:
zhihu --version
- DSH Environment Requirements:
Ensure that your DSH version satisfies thepeerDependenciesrequirement (compatible with 0.2.0-rc.2 or later, with a minimum of 0.1.5-rc.1).
Core Features¶
The plugin primarily performs the following:
- Tool Wrapping: Wraps local
zhihuCLI commands intozhihu_*tools (such aszhihu_searchandzhihu_answer), returning structured JSON data. - Read-Only Mode by Default: For safety, write operations (publishing, voting, deleting) do not register tools by default. The model cannot see these tools, thereby avoiding accidental operations.
- Web Visualization Panel: Provides a sidebar floating bubble (“知” bubble) and a settings page card, supporting QR-code scan login and configuration viewing.
- Authentication Handling: Supports QR-code scan login or direct Cookie paste login; all credentials are processed locally only and are not exposed in process lists.
Typical Usage¶
1. Management and Authentication¶
The first use requires login. The plugin invokes the CLI’s login logic.
- Check Status:
View the plugin status, CLI version, and login state (whether the Cookie containsz_c0/_xsrf).
zhihu_status()
- Login (QR Code Recommended):
The CLI generates a QR code image path, which is displayed to the user by the Agent; after the user scans it, the plugin detects the authentication state.
// 返回二维码图片路径,可传入 read_image 查看或展示
zhihu_login()
- Login (Cookie):
If the environment is restricted and scanning is not possible, you can pass a Cookie string directly.
zhihu_login({ mode: "cookie", cookie: "z_c0=...; _xsrf=...; d_c0=..." })
2. Read Operations¶
All read tools are available by default, but every command requires login to be completed first.
- Search and Hot Lists:
zhihu_search({ query: "DeepSeek", type: "general" })
zhihu_hot()
- Question and Answer Details:
Get the question and its list of answers.
zhihu_question({ id: "123456", answers: true })
Get the answer body and comments:
zhihu_answer({ id: "789012", comments: true })
- Users and Feeds:
View user profile or feed.
zhihu_user({ id: "user123", include: "answers,articles" })
zhihu_feed({ withComments: true })
3. Write Operations (Manual Enablement)¶
By default, write tools do not exist. You need to disable read-only mode in the configuration.
- Enable Write Permissions:
SetreadOnly: falsevia a tool call or configuration file.
zhihu_config({ readOnly: false })
At this point, tools such as `zhihu_publish`, `zhihu_vote`, `zhihu_follow_question`, and `zhihu_delete` are registered.
- Publish Content:
zhihu_publish({ kind: "article", title: "标题", content: "正文" })
Web Visualization Panel¶
The plugin integrates two entry points in the DSH Web interface:
- Sidebar Floating Bubble: A blue “知” bubble in the bottom-right corner; clicking it expands a 380px operations panel.
- Settings Page Card: Adds a “Zhihu” configuration card in
settings.section.
The panel provides the following:
* Login Management: Displays the current login status and supports one-click QR code generation/refresh.
* Configuration Adjustment: Toggle read-only mode, set proxy, and adjust timeout.
* Quick Query: Directly invoke hot-list search and click links to navigate.
Security Restrictions: The panel API path is /api/dsh-zhihu/*; only localhost or 127.0.0.1 access is allowed to prevent cross-site request forgery.
Configuration Description¶
Configuration items are stored in ~/.dsh/dsh-zhihu.json (permissions 0600). The main parameters are as follows:
| Config Item | Default Value | Description |
|---|---|---|
readOnly |
true |
When true, only read tools are registered; when false, write tools are registered |
cliPath |
zhihu |
The local CLI command name or absolute path |
timeoutMs |
90000 |
Timeout for a single call (milliseconds) |
loginWaitMs |
15000 |
Timeout for waiting for QR code scan (milliseconds) |
proxy |
empty | Proxy setting; leave empty to inherit environment variables, or set none to force no proxy |
cliHome |
~/.zhihu-cli |
The CLI configuration directory; the plugin modifies the child process’s HOME to point here |
Notes and Limitations¶
- Authentication Requirement: Every
zhihu_*tool call requires an authenticated session; otherwise, the errorNot authenticatedis reported. - CLI Mode Differences:
- The CLI
--jsonmode does not support comments, feed+comments, or topic hot lists. These features fall back to text mode, and the results are included in thetextfield. zhihu_searchandzhihu_hotdo not support the-a/--answersparameter in JSON mode.
- The CLI
- Risk Control Risks: Zhihu has anti-crawler mechanisms, and the plugin is only a thin wrapper. Do not make high-frequency requests in a short period, as this may trigger risk controls and lead to account restrictions.
- Source Code Check: Before installation, verify the source code and license. The plugin runs with the permissions of the current DSH process, so ensure that you trust the plugin.
Summary¶
zhengjy01/dsh-zhihu is a bridge connecting local pyzhihu-cli to DeepSeek Harness. It provides structured Zhihu data access and defaults to read-only mode to protect account security. Through the Web panel and tool wrapping, developers can easily integrate Zhihu data queries and basic interaction features into their agents.