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

@2api-store/activate

v0.8.0

Published

TokenShop CLI 一键激活:配置本地 codex/claude/gemini/grok/opencode 指向 2api.store 中转(彩色输出 + 自动安装 CLI)

Readme

@2api-store/activate

TokenShop CLI 一键激活脚本:在任意有 node 环境的终端,一行命令把本地 codex / claude / gemini / grok / opencode 等 CLI 配置为指向 2api.store 中转。

快速开始

npx @2api-store/activate

按提示输入 API Key兑换码,脚本会自动:

  1. 检测你的操作系统与已安装的 CLI
  2. 拉取适配当前系统的配置模板(运行时从服务端获取,脚本不硬编码)
  3. 备份原配置到 <path>.bak.<时间戳>
  4. 渲染占位符(apiKey / baseUrl / defaultModel)后写入
  5. 验证 API Key 可访问 /v1/models

两种模式

| 模式 | 输入 | 说明 | |------|------|------| | API Key 模式 | sk-... | 已有 2api.store 的 API Key,直接配置本地 CLI | | 兑换码模式 | 32 字符兑换码 + 邮箱 | 邮箱已有用户则绑定,无对应用户则自动创建账号 + 发激活邮件(含初始密码)→ 消费兑换码 → 创建 API Key 绑定到兑换码指定的分组 |

凭据格式自动识别:sk- 前缀走 Key 模式;否则按兑换码处理。

子命令

除了默认激活流程,还提供 5 个子命令用于后续维护:

npx @2api-store/activate <subcommand> [options]

| 子命令 | 作用 | |--------|------| | restore | 从备份恢复:扫描 ~/.codex/~/.claude/~/.gemini/ 下的 .bak.* 文件,选择一个恢复(覆盖当前) | | reset | 恢复官方默认:删除 2api.store 写入的配置文件(~/.codex/config.toml~/.codex/auth.json~/.claude/settings.json~/.gemini/settings.json),并尝试从最新备份恢复。破坏性操作,需确认 | | refresh-groups | 查看可用分组:GET /cli/groups → 彩色表格展示。只读,不改 key/配置 | | diagnose | 一键诊断连接并生成日志压缩包:环境收集 + 渠道 HTTP 实测(真实小请求)+ 已装 CLI 实测,zip 已脱敏,发给客服排障 |

restore — 从备份恢复

npx @2api-store/activate restore
npx @2api-store/activate restore --dry-run      # 预演
  • 扫描三个 CLI 目录下的 .bak.<时间戳> 文件,按修改时间倒序列出
  • 选择要恢复的备份,复制回原文件(覆盖当前)
  • 恢复前会自动再产生一份安全备份(防止恢复后想撤销)
  • .bak.* 文件保留,可多次恢复

reset — 恢复官方默认

npx @2api-store/activate reset
  • 列出 2api.store 写入的配置文件(仅现存的)
  • 删除前再备份一次.bak.reset.<时间戳>,方便撤销)
  • 删除后尝试从最新常规备份恢复(回到激活前的官方状态)
  • 需要显式确认(默认 N,输入 y 才执行)
  • 输入现有 sk- API Key(不接受兑换码)
  • POST /cli/activate(key 模式,不创建账号)→ 重拉最新模板/模型
  • 多选 CLI(默认选主 CLI)→ 选默认模型 → 备份并写入
  • 适合:换了机器、配置丢失、想刷新到最新模板

refresh-groups — 查看可用分组

npx @2api-store/activate refresh-groups
  • 彩色表格列出所有可用分组(ID + 名称)
  • 只读,不改 key/配置
  • 如需切组:已有 API Key 走管理后台,或重新激活(兑换码可重选分组)

diagnose — 连接诊断与日志收集

npx @2api-store/activate diagnose            # 一键诊断(执行前有确认)
npx @2api-store/activate diagnose --yes      # 免确认(客服远程指导可直接贴这条命令)

连接不通 / 时快时慢 / 想让客服排查时使用。自动完成:凭据发现(按序扫 ~/.codex/auth.json~/.claude/settings.json~/.gemini/settings.json,找不到会提示输入)→ 环境快照(OS / Node / 已装 CLI / 配置文件元信息 / 代理环境变量)→ 拉后端诊断矩阵(不可用时走内置兜底)→ 对每个测试模型发真实小请求实测 → 已装 CLI 非交互实测(各 30s 超时)→ 脱敏打包 zip + 打印摘要表。

| 参数 | 说明 | |------|------| | --yes, -y | 免确认直接执行(真实小请求,正常计费) | | --model <m1,m2> | 覆盖测试模型(逗号分隔;默认用后端下发矩阵 / 内置兜底) | | --skip-cli-tests | 只测 HTTP,不运行本地 CLI | | --out <dir> | 诊断包输出目录(默认当前目录) | | --api-base <url> | 覆盖 API 端点(同其他子命令) |

zip 包内文件(顶层目录 tokenshop-diagnose-<时间戳>/):

| 文件 | 内容 | |------|------| | summary.json | 环境 + 测试结果汇总(客服先看这个) | | env.json | OS / Node 版本 / 已装 CLI / 配置文件元信息 / 代理环境变量 | | http-tests.jsonl | 每个模型一行:request_id / 状态码 / ttfb / 总延迟 / 错误 / 响应片段 | | cli-tests.jsonl | 每个已装 CLI 一行:命令 / 退出码 / 耗时 / 是否超时 / stdout+stderr(截断 10KB) | | configs/ | 本地配置文件的脱敏副本(不存在的文件跳过) | | README.txt | 给客服的说明(含 request_id 对账用法) |

隐私说明:包内所有密钥全程掩码(sk-…尾6 形态,绝不落明文);Bearer 凭证、邮箱、代理 URL 内嵌的账号密码均自动脱敏;configs/ 是脱敏副本,本地原始配置文件不会被修改。

计费提示:HTTP 实测会对每个测试模型发送真实计费的小请求(max_tokens=1,每模型约几分钱)。每条 HTTP 记录的 request_id 取自响应头 X-Request-Id,客服凭它可在生产后台 usage_logs / 网关日志中精确对账该次请求。

命令行选项

npx @2api-store/activate [options]                默认激活流程
npx @2api-store/activate <subcommand> [options]   运行子命令

选项(默认激活流程 + 所有子命令通用):
  --dry-run, -n          不真写配置,只展示将写入什么(不适用 refresh-groups)
  --platform <name>      只激活指定平台(openai/anthropic/gemini/grok/antigravity)
  --api-base <url>       覆盖 API 端点
  -h, --help             显示帮助
  -v, --version          显示版本

环境变量

  • ACTIVATE_API_BASE:覆盖 API 端点(同 --api-base)。本地开发指向 http://127.0.0.1:5566

--dry-run

只展示将写入哪些文件、内容预览,不真实写入、不创建备份。适合先看一下会发生什么再决定是否正式激活。

npx @2api-store/activate --dry-run

权限提示

CLI 配置文件位于用户家目录(如 ~/.codex/config.toml~/.claude/)。脚本先用普通用户权限尝试写入:

  • 写入成功:直接完成。
  • 权限不足EACCES / EPERM / EROFS):脚本不会自动 sudo,而是明确报出目标路径与错误类型,并提示重跑方式:

| 系统 | 重跑命令 | |------|----------| | macOS / Linux | sudo npx -y @2api-store/activate | | Windows | 用「管理员 PowerShell」运行 Start-Process powershell -Verb RunAs -ArgumentList "npx,-y,@2api-store/activate" |

备份策略

  • 写入前自动备份原文件到同目录 <path>.bak.<ISO时间戳>(非覆盖,保留多次备份)。
  • 目标文件不存在则跳过备份。
  • 备份失败但文件存在 → 跳过该文件写入,避免无备份覆盖。

安全

  • 凭据输入掩码(***)显示。
  • 写入的配置文件权限 0o600(仅属主可读写,因含 API Key)。
  • 兑换码模式创建的新账号会发送高熵随机初始密码到邮箱,请登录后尽快修改。
  • 全程不落库明文密码,不自动 sudo。

跨平台

  • macOS / Linux:使用 ~ 展开($HOME),选 os_type=unix 的配置。
  • Windows:使用 %userprofile% 展开,选 os_type=windows 的配置。
  • os_type=all 的配置(如环境变量导出)在两端都可选。
  • 部分"环境变量类"配置(路径为 Terminal / PowerShell)只打印 shell 命令,让用户手动执行,不写文件。

本地开发与测试

cd cli-activate
node --check activate.mjs && for f in lib/*.mjs; do node --check "$f" || exit 1; done
node test/smoke.mjs    # 起本地 mock server 跑全流程(用临时 HOME + --dry-run,不碰真实配置)

退出码

| 码 | 含义 | |----|------| | 0 | 成功 | | 1 | 输入错误 / 网络失败 / 致命错误 | | 2 | 部分文件权限不足(请按提示用 sudo / 管理员 PowerShell 重跑) | | 3 | 其他写入失败 |

License

MIT © TokenShop