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

dsh-pi-ai-header-patch

v0.2.0

Published

Thin patch that lets dsh-llm-pi-ai profile headers (e.g. user-agent) override the mandatory app-attribution headers

Readme

dsh-pi-ai-header-patch

一个只做一件事的补丁工具:把 @deepseek-ai/dsh-llm-pi-ai 里请求头合并的优先级翻过来, 让 provider profile 配置的 headers(典型如 user-agent覆盖强制的应用归因头。

用法就是一句话:

npx dsh-pi-ai-header-patch

它会自动找到你机器上安装的 @deepseek-ai/dsh-llm-pi-ai——本地工程、全局安装(npm/pnpm/yarn)、 以及 npx dsh 的缓存目录——逐个打上补丁。幂等:已经打过补丁的副本会被跳过。

它改了什么

只改 lib/index.js 里一个私有函数 requestHeaders(),其它一律不动:

  • 打补丁前(上游语义)attributionHeaders()user-agent 是“保留名”,配置里同名的头会被过滤掉,归因头获胜。
  • 打补丁后:从归因头起步,逐条把配置头按大小写不敏感的方式删除冲突键后写入,配置头获胜

于是 headers.user-agent 就能把 User-Agent 伪装成 claude-cli/2.1.110codex_cli_rs/0.1.0 等。

为什么是源码补丁而不是运行时插件:requestHeaders 是打包产物里的私有、未导出函数,且 LLM 层的 GenerateOptions 没有 headers 字段,运行时插件没有可挂的 seam,只能在源码层改这一个函数。

命令

# 修补所有发现的副本(默认)
npx dsh-pi-ai-header-patch

# 只看状态、不写入
npx dsh-pi-ai-header-patch --check

# 只修补指定目录或文件(dsh 装在非标准位置时用它兜底)
npx dsh-pi-ai-header-patch --path /path/to/node_modules/@deepseek-ai/dsh-llm-pi-ai

退出码:0 成功,1 有副本打不上(版本不符等),2 用法错误或没找到目标。

它能找到哪些安装

| 安装方式 | 探测方式 | |---|---| | 本地工程 | 从当前目录解析 + node_modules/... | | 全局 npm | npm root -g | | 全局 pnpm | pnpm root -g + 同级 .pnpm 内容寻址存储(<root>/../.pnpm/<@scope+name@version>/…) | | 全局 yarn | yarn global dir | | 全局 Volta / nvm / fnm | 枚举每个 Node 版本下的 lib/node_modules;Volta 2.x 另扫 image/packages/<scope>/<name>/lib/node_modules | | 系统级 | /usr/local/lib/node_modules/usr/lib/node_modules | | npx dsh 缓存 | 枚举 ~/.npm/_npx/*/node_modules/... |

全局安装的依赖可能扁平化到全局 node_modules,也可能嵌套在 @deepseek-ai/dsh(或 dsh-base/dsh-web-app/dsh-headless)的 node_modules 里——工具先按常见位置快速解析, 再对 @deepseek-ai 作用域做一次有界的递归扫描兜底,因此嵌套多深都能命中。若你的 dsh 装在探测不到的地方,用 --path 兜底(失败时它会打印所有已探测的根目录,方便定位)。

验证

grep -n "letting configured headers override" \
  node_modules/@deepseek-ai/dsh-llm-pi-ai/lib/index.js

命中即已生效。然后在 settings 里配一个路由验证真实请求的 User-Agent

llm-pi-ai:
  providers:
    tal-anthropic:
      api: anthropic-messages
      baseURL: http://ai-service.tal.com/coding
      headers:
        user-agent: claude-cli/*
      models:
        - id: <model-id>
          name: <model-name>

本地使用 / 发布

发布前本地测试:

npx ./dsh-pi-ai-header-patch --check      # 从父目录直接跑本地目录
# 或临时挂到 PATH:
npm link                                    # 之后可直接 dsh-pi-ai-header-patch

发布后即可 npx dsh-pi-ai-header-patch(或改 package.jsonname 后再发布,比如作用域名 @your-scope/dsh-pi-ai-header-patch,则命令为 npx @your-scope/dsh-pi-ai-header-patch)。

注意

  • 目标版本是 @deepseek-ai/[email protected];其它版本若改过该函数,工具会报 [fail] 而不是硬改。
  • 打补丁后配置头可以覆盖强制的归因 User-Agent。这是刻意的白标/伪装选择,上游 README / .d.ts 仍写着 “Harness attribution wins”,属于已覆盖的文档差异。

变更记录

0.2.0

  • 修补所有发现的副本(本地 + 全局 + npx 缓存),不再“命中第一个就停”;逐份 [ok]/[skip]/[fail] 汇报并汇总。
  • 支持 Volta 2.x 的全局布局(~/.volta/tools/image/packages/<scope>/<name>/lib/node_modules)。
  • 支持 pnpm 全局安装(pnpm root -g 同级的 .pnpm 内容寻址存储)。

0.1.0

  • 首个版本:单目标精确字符串替换,翻转 requestHeaders 的合并优先级。