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

pi-zcode-headers

v0.1.0

Published

让 pi 伪装成官方 ZCode 客户端 | Make pi pretend to be the official ZCode client — injects ZCode identity headers so the Zhipu backend treats pi traffic as ZCode traffic.

Readme

pi-zcode-headers

🎭 让 pi 伪装成官方 ZCode 客户端,让智谱后端把 pi 流量当作 ZCode 流量。 Make pi pretend to be the official ZCode client — the Zhipu backend treats pi traffic as ZCode traffic.

当 pi 使用智谱 / Z.AI provider(zai-coding、zai-coding-cn、api.z.ai、open.bigmodel.cn 等)时,自动注入与官方 ZCode 客户端完全一致的身份 headers,让智谱后端将 pi 的流量识别为 ZCode 流量。

When pi uses a Zhipu / Z.AI provider, this extension injects the exact identity headers the official ZCode client sends, so Zhipu's backend treats pi traffic as ZCode traffic.

安装 / Install

pi install npm:pi-zcode-headers

工作原理 / How It Works

每次 pi 发出 LLM 请求前,扩展检查当前 provider:

  • 智谱官方端点(provider 名 zai / zai-coding / zai-coding-cn / zhipu / bigmodel,或 baseUrl 为 api.z.ai / open.bigmodel.cn)→ 注入完整 ZCode 身份 headers
  • 其他 provider (DeepSeek, OpenAI, etc.) → 不注入,零影响

注入的 headers 与官方 ZCode(桌面版 3.10.2 内置 agent runtime)实测抓包逐字节一致,覆盖 Anthropic 风格(/api/anthropic)与 OpenAI 风格(/api/coding/paas/v4)两类 coding-plan 端点:

| Header | 值 / Value | |---|---| | User-Agent | ZCode/<版本> ai-sdk/provider-utils/<4.0.x> runtime/node.js/<主版本> | | HTTP-Referer | https://zcode.z.ai | | X-Title | Z Code@electron(桌面身份)或 Z Code@cli(runtime 身份) | | X-ZCode-App-Version | 与 User-Agent 一致的版本号 | | X-ZCode-Agent | glm | | X-ZCode-Session-Type | main | | X-Platform | darwin-arm64(platform-arch) | | X-Os-Category | macos / windows / linux | | X-Os-Version | 系统内核版本(os.release()) | | X-Client-Language | 系统 locale(如 zh-CN) | | X-Client-Timezone | 系统时区(如 Asia/Shanghai) | | X-Release-Channel | production | | X-Session-Id | 每个 pi 会话一个持久 UUID | | X-Query-Id / X-Request-Id / X-ZCode-Trace-Id | 每次请求新 UUID |

同时清除 openai SDK 的 x-stainless-* 指纹头(官方客户端不发这些头),确保 header 层面完全一致。

版本号解析顺序(优先级从高到低):

  1. 环境变量 ZCODE_APP_VERSION(官方 runtime 同名变量)
  2. 本机安装的官方桌面版 ZCode(读取 Info.plist,此时伪装为桌面身份 Z Code@electron)
  3. 本机安装的 zcode CLI(官方 runtime,此时为 Z Code@cli 身份)
  4. 内置 fallback(随官方发版更新)

环境变量 / Environment Variables

| 变量 | 作用 | |---|---| | ZCODE_APP_VERSION | 覆盖上报的客户端版本 | | ZCODE_SOURCE_TITLE | electron 或 cli,覆盖身份表面 | | ZCODE_AI_SDK_VERSION | 覆盖 User-Agent 中 ai-sdk 版本后缀 | | ZCODE_ENV | test 时上报 X-Release-Channel: test |

License

MIT