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-fetch-header-rewrite

v0.1.2

Published

Rewrite outbound HTTP request headers (User-Agent, custom) for any dsh provider/gateway request, with optional prefix/regex rules.

Readme

dsh-fetch-header-rewrite

一个用于 DeepSeek Harness(dsh)的 cordis 插件:改写对外 HTTP 请求头(如 User-Agent)。它通过 patch globalThis.fetch 生效,因此一份配置作用于运行中 dsh 的所有 provider 路由,与具体适配器无关。

零默认值:未配置前不修改任何请求;包内不内置任何 URL 或请求头值。

安装

dsh plugin --profile web add dsh-fetch-header-rewrite

然后在 profile 的 cordis.patch.yml 挂载:

- insert:
    - id: dsh-fetch-header-rewrite
      name: dsh-fetch-header-rewrite

配置

所有请求——最常见场景

- insert:
    - id: dsh-fetch-header-rewrite
      name: dsh-fetch-header-rewrite
      config:
        headers:                 # 作用于所有请求
          user-agent: opencode/0.2.1

全局默认 + 按规则精确控制

      config:
        headers:                 # 全局默认:所有请求
          user-agent: opencode/0.2.1
        rules:                   # 可选;首个命中即停
          - match: https://api.example.com
            headers:
              x-tenant: acme
          - match: /^https://corp\.example/i
            headers:
              x-region: cn
        verbose: false           # 可选;true 时打印每个被改写的请求(凭据头会被脱敏)

只用规则

      config:
        rules:
          - match: /api\/v1\/chat\/completions$/
            headers:
              x-trace: "1"

语义

| 配置 | 行为 | |---|---| | headers(顶层) | 作用于所有请求。 | | rules | 按顺序检查,首个命中的规则生效并停止,后续规则不再检查。 | | 命中规则与全局 | 命中规则的 headers 与全局合并;同名 header 由规则覆盖。 | | 无规则命中 | 仅应用全局 headers。 | | match 普通字符串 | URL 前缀匹配(URL.startsWith(match))。 | | match 用 /…/ 包裹 | 对完整 URL 做正则 test。第一个 / 与最后一个 / 之间为 pattern,最后一个 / 之后为 flags(如 /…/i)。pattern 内的字面 / 无需转义;pattern 以 / 结尾时写双斜杠(/foo//)。 | | 无效规则 | 启动时警告并跳过(缺 match、缺/空 headers、非法正则、非法 flags);其余有效规则照常生效。 | | 空配置 | no-op:不 patch fetch,不修改任何请求。 | | verbose: true | 打印每个被改写请求的 URL 与生效头部;authorization、cookie 等携带凭据的头部会被脱敏。 |

本地开发与调试

运行测试套件:

node --test

不发布即可把本地 checkout 挂进 profile:

  1. 在 profile 的 package.json 添加:
    "dependencies": { "dsh-fetch-header-rewrite": "file:/绝对路径/to/dsh-fetch-header-rewrite" }
  2. 在 profile 目录运行 pnpm install。
  3. 添加 cordis.patch.yml 条目(见安装),调试时把 verbose 设为 true。

插件没有构建步骤:file: 依赖直接指向源码,改代码后重启 dsh 即生效。cordis.patch.yml 的配置改动在长生命周期界面(web)上热重载;代码改动需要重启。

调试输出:verbose: true 时,每个被改写的请求会打印一行 [dsh-fetch-header-rewrite]——URL 与生效头部,携带凭据的头部(authorization、cookie 等)会被脱敏。用一次性任务观察:

dsh --profile headless "reply with exactly: OK"

说明与局限

  • 匹配目标是完整请求 URL。
  • 插件 patch 全局 fetch;dsh 的适配器通过全局 fetch 发请求时生效(当前 DeepSeek 适配器与 pi-ai 都是如此)。未来若某适配器绕过全局 fetch(例如自定义 undici dispatcher),则不在覆盖范围内。
  • 首个命中即停意味着列表中靠前的宽泛规则会遮蔽后续规则;请按从窄到宽的顺序排列规则。

License

MIT