npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wangshaodan/web-search-zhihu

v0.1.1

Published

Zhihu global-search provider for the DeepSeek Harness web capability seam (ctx.web)

Readme

@wangshaodan/web-search-zhihu

知乎全网搜索(global_search)的 DeepSeek Harness WebSearchProvider 插件。安装后向 ctx.web 注册 provider zhihu-global-search,由 @deepseek-ai/dsh-tool-webweb_search 工具消费。本包注册面向模型的 tool,也占用 ctx.web 服务键。

这是全网搜索,不是知乎站内搜索。若只要 zhihu.com 站内内容,请使用知乎 OpenAPI 的 zhihu_search 接口,而不是给本 provider 加 host=="zhihu.com" 过滤(官方 API 明确不支持该写法)。

安装

dsh plugin 会把命令转发给 profile 目录里的 pnpm,因此本机 PATH 上需要有 pnpm

发布到 npm 后:

dsh plugin --profile web add @wangshaodan/web-search-zhihu

从 GitHub 安装依赖(不经过 npm registry):

npm install -g github:momowsd/web-search-zhihu
# 或
npm install -g https://github.com/momowsd/web-search-zhihu.git

clone 后在本地安装依赖:

git clone https://github.com/momowsd/web-search-zhihu.git
cd web-search-zhihu
npm install
npm run build

本地开发 / 未发布时,也可把仓库目录或 tarball 交给 dsh plugin

dsh plugin --profile web add /path/to/web-search-zhihu
# 或
pnpm pack
dsh plugin --profile web add ./wangshaodan-web-search-zhihu-0.1.1.tgz

安装成功后,profile 会把本包加入 dsh.profile.bundles,并应用 cordis.patch.yml

  • 插入插件行 web-search-zhihu
  • web.config.searchProvider 覆盖为 zhihu-global-search

用下面命令确认层已生效(输出中应出现 # == @wangshaodan/web-search-zhihu,且 searchProviderzhihu-global-search):

dsh --profile web --dump-config

用户仍可通过 profile / home 的 cordis.patch.yml,或环境变量 $DSH_WEB_SEARCH_PROVIDER 覆盖所选 provider。

凭据配置

ZHIHU_ACCESS_SECRET 有两种配置方式,任选其一即可。进程环境优先于 $DSH_HOME/.credentials.yaml(与 DSH 其它凭据相同)。

方式一:export 环境变量

export ZHIHU_ACCESS_SECRET=你的密钥
dsh --profile web

方式二:写入 $DSH_HOME/.credentials.yaml

默认路径是 ~/.dsh/.credentials.yaml(若设置了 $DSH_HOME 则用那个目录)。文件权限建议 600

ZHIHU_ACCESS_SECRET: 你的密钥
# 若文件尚不存在
install -m 600 /dev/null "${DSH_HOME:-$HOME/.dsh}/.credentials.yaml"
# 然后编辑上述文件,加入 ZHIHU_ACCESS_SECRET 一行
chmod 600 "${DSH_HOME:-$HOME/.dsh}/.credentials.yaml"

两种方式都不要把密钥写进 cordis.patch.yml 或 git 仓库。可选的 ZHIHU_OPENAPI_BASE_URL / ZHIHU_GLOBAL_SEARCH_URL 仍只走环境变量。

| 变量 | 必填 | 默认 | 含义 | |---|---|---|---| | ZHIHU_ACCESS_SECRET | 是 | — | Bearer Token。环境变量或 .credentials.yaml 都未设置时,搜索会以 WEB_PROVIDER_CREDENTIAL_MISSING 失败 | | ZHIHU_OPENAPI_BASE_URL | 否 | https://developer.zhihu.com | OpenAPI 源站,拼接 /api/v1/content/global_search | | ZHIHU_GLOBAL_SEARCH_URL | 否 | — | 完整 endpoint,优先级最高 |

Config

| 键 | 默认 | 含义 | |---|---|---| | apiKey | (不设) | 字面量密钥。一般不用,优先用下面两种凭据方式 | | apiKeyEnv | ZHIHU_ACCESS_SECRET | 凭据引用名:每次搜索经 ctx.credentials(含 $DSH_HOME/.credentials.yaml)解析,没有凭据平面时再读环境变量 | | baseURL | $ZHIHU_OPENAPI_BASE_URL → 公开源站 | OpenAPI origin | | endpoint | $ZHIHU_GLOBAL_SEARCH_URL | 完整搜索 URL,覆盖 baseURL | | filter | (不传) | 知乎 Filter 表达式,例如 host=="example.com" | | searchDB | (不传,API 默认 all) | all / realtime / static | | numResults | 10 | 请求未带 maxResults 时的 Count,钳制到 1–20 | | timeoutMs | 30000 | HTTP 超时(毫秒) |

- id: web-search-zhihu
  name: '@wangshaodan/web-search-zhihu'
  config:
    apiKeyEnv: ZHIHU_ACCESS_SECRET
    searchDB: all
    numResults: 10

映射与错误

请求:GET {endpoint}?Query=&Count=,可选 FilterSearchDB。Header 含 Authorization: Bearer …X-Request-Timestamp(秒级 Unix 时间戳)。HTTP 重定向会被拒绝。

每条结果映射为 WebSearchSource

  • urlUrl(无 URL 的条目丢弃)
  • titleTitle
  • snippetContentText(去掉 <em> 高亮标签)
  • publishedAtEditTime(秒级时间戳 → ISO-8601)

知乎不返回生成式答案,因此省略 contentCount 上限 20;seam 仍会按 maxResults 截断。

失败约定:

  • HTTP / 网络 / 非 JSON / Code != 0 / 超时 → WebError WEB_PROVIDER_ERROR
  • 未配置 ZHIHU_ACCESS_SECRETWEB_PROVIDER_CREDENTIAL_MISSING
  • 调用方 AbortSignal 取消 → WEB_ABORTED

开发

pnpm install
pnpm test
pnpm typecheck
pnpm build
pnpm pack --dry-run

真实 API 冒烟测试仅在设置了 ZHIHU_ACCESS_SECRET 时运行:

ZHIHU_ACCESS_SECRET=... pnpm test

发布前先 pnpm buildprepack 会自动执行)。npm 安装使用预构建的 lib/,不需要用户本机编译。从 git 源安装时,请改用 pnpm pack 后的 tarball,或自行允许 prepare 构建脚本。

安全注意

  • ZHIHU_ACCESS_SECRET 放在进程环境或 $DSH_HOME/.credentials.yaml,不要提交到仓库或 patch 文件。.credentials.yaml 权限保持 600
  • Filter 会进入 GET URL,可能被代理 / access log 记录。
  • $ZHIHU_GLOBAL_SEARCH_URL 被篡改时,Bearer token 可能发往非预期主机。