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

new-api-ccstatusline

v0.3.3

Published

Claude Code status line for New API compatible gateways

Readme

new-api-ccstatusline

Claude Code 的 New API 通用状态栏工具。

安装方式

方式一:直接运行 npx

npx -y new-api-ccstatusline@latest

运行后会进入两项 TUI 菜单:

  • 配置 Claude
  • 配置 statusLine

菜单按键:

  • ↑/↓ 选择
  • Enter 确认
  • L 切换中英文
  • Esc 返回 / 取消

方式二:下载单文件 JS

如果你不想每次走 npx,也可以先下载再运行:

curl -fsSL https://cdn.jsdelivr.net/npm/new-api-ccstatusline@latest/dist/new-api-ccstatusline.js -o new-api-ccstatusline.js
node ./new-api-ccstatusline.js

第一步:配置 Claude

先运行:

npx -y new-api-ccstatusline@latest

然后在菜单里选:

  • 配置 Claude

这一项会要求你输入:

  • New API 地址
  • API key

第二步:配置 statusLine

再运行一次:

npx -y new-api-ccstatusline@latest

然后在菜单里选:

  • 配置 statusLine

这一项会要求你输入:

  • userId
  • accessToken

获取方式:

  • 打开你的 New API / One API / 兼容面板后台
  • 进入“用户”“个人中心”“令牌”或同类页面
  • 找到当前账号的 userId
  • 创建或查看该用户的 accessToken

刷新与缓存

  • 状态栏默认每 5 分钟刷新一次
  • 两次刷新之间会直接读取本地缓存
  • 缓存文件默认在 ~/.claude/new-api-ccstatusline/cache.json
  • 配置文件默认在 ~/.claude/new-api-ccstatusline/config.json

如果你想改刷新间隔,可以直接改 config.json 里的 cacheSeconds

例如改成 60 秒:

{
  "cacheSeconds": 60
}

请求失败时的退避策略

当请求 New API 失败时(网络断开、地址写错、服务挂了等),状态栏不会每次刷新都重发请求,而是按以下规则处理:

  • 指数退避:第 1 次失败后等待 cacheSeconds,之后每次失败等待时间翻倍,最长封顶到 30 分钟(含 ±10% 抖动),期间状态栏显示陈旧数据并加 缓存: 前缀和简短错误信息
  • 冻结上限:连续失败 10 次后进入冻结状态,状态栏显示 冻结: 前缀(红色),完全停止重试

冻结状态会在以下情况自动解除:

  • Claude Code session 重启:状态栏检测到 session_id 变化时自动重置失败计数
  • 配置变更:修改 baseUrl / userId / accessToken / apiKey 任一项,缓存自动失效

也可以手动清掉缓存立即重试:

rm ~/.claude/new-api-ccstatusline/cache.json

可以直接改的 JSON 配置

常用的是 ~/.claude/new-api-ccstatusline/config.json

示例:

{
  "baseUrl": "https://your-new-api.example",
  "cacheSeconds": 300,
  "usageDays": 1,
  "auth": {
    "userId": "123",
    "accessToken": "your_token"
  },
  "ui": {
    "language": "zh",
    "showAccount": true,
    "showKey": true,
    "showContext": true,
    "showRecentUsage": true,
    "showGit": true,
    "showWorkspace": true
  }
}

常用字段:

  • baseUrl:New API 地址
  • cacheSeconds:刷新间隔,单位秒,默认 300
  • usageDays:最近使用统计天数
  • auth.userId:状态栏用的用户 ID
  • auth.accessToken:状态栏用的访问令牌
  • ui.languagezhen
  • ui.showAccount:显示余额
  • ui.showKey:显示 key 信息
  • ui.showContext:显示 context
  • ui.showRecentUsage:显示最近使用
  • ui.showGit:显示 Git 分支
  • ui.showWorkspace:显示当前目录

状态栏会显示什么

  • 当前 key 额度
  • 当前会话 context 使用率
  • 账户余额
  • 最近使用
  • Git 分支
  • 当前工作目录

具体会改哪些配置

配置 Claude 会改什么

  • 修改 ~/.claude/settings.json
  • 写入 Claude 所需的 New API 配置
  • 写入 hasCompletedOnboarding: true

配置 statusLine 会改什么

  • 写入工具自己的配置文件
  • 写入 userId
  • 写入 accessToken
  • 确保 Claude 能调用状态栏脚本

命令行方式

如果你不想进入 TUI,也可以直接用命令行参数。

配置 Claude

npx -y new-api-ccstatusline@latest --install \
  --yes \
  --base-url https://your-new-api.example \
  --api-key sk-xxx

配置 statusLine

npx -y new-api-ccstatusline@latest --setup \
  --user-id 123 \
  --access-token your_usertoken

本地开发

构建:

bun run build

本地测试菜单:

node dist/new-api-ccstatusline.js

本地测试状态栏:

echo '{}' | node dist/new-api-ccstatusline.js