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

aicodewith

v1.0.1

Published

Aicodewith Activator for Claude Code & Codex

Readme

aicodewith

一个命令行激活器(bin:aicodewith):验证 API Key 后,根据接口返回的 service_type 自动为 Claude CodeCodex CLI 写入本地配置。

本版本的特点:验证请求地址(verify URL)可配置

激活器逻辑(做了什么)

整体流程:

  1. 交互式输入 API Key(密码输入,不回显)。
  2. 验证 API Key:向 verifyUrl 发起 GET 请求,带 Authorization: Bearer <API Key>,要求返回 JSON。
  3. 解析返回的 service_type
    • claude:激活 Claude Code
    • codex:激活 Codex CLI
  4. 展示 Key 状态/配额/有效期等信息后二次确认。
  5. 写入本地配置并提示重启工具生效。

Claude Code(service_type = "claude"

通过定位 Claude Code 的 @anthropic-ai/claude-code/cli.js,在文件开头(跳过 shebang/注释/空行后)注入一段环境变量设置:

// AICODEWITH_INJECTED_START
process.env.ANTHROPIC_BASE_URL="<baseUrl>/claude";
process.env.ANTHROPIC_AUTH_TOKEN="<API Key>";
// AICODEWITH_INJECTED_END

如果之前已经注入过,会先移除旧的 AICODEWITH_INJECTED_START ~ AICODEWITH_INJECTED_END(以及历史的 APIGATHER_INJECTED_*)区块再写入,避免重复。 写入前会在 ~/.codex/.aicodewith_backup/ 生成 cli.js__<原目录>.bak.<时间戳> 备份(如 20201212101010),不会覆盖历史备份;恢复时选最新时间戳即可。

Codex CLI(service_type = "codex"

写入/更新 Codex 配置目录 ~/.codex/

  • ~/.codex/config.toml:设置 model_provider = "aicodewith" 并写入 [model_providers.aicodewith]name="aicodewith"base_url="<baseUrl>/codex"wire_api="responses"temp_env_key="AICODEWITH_API_KEY"requires_openai_auth=truemodel="gpt-5-codex" 等)。
  • ~/.codex/auth.json:写入 OPENAI_API_KEYAICODEWITH_API_KEY(值均为该 API Key,会覆盖原文件内容)。

同样会清理旧的同名段落/标题与旧 model_provider 行,避免重复配置。 写入前会在 ~/.codex/.aicodewith_backup/ 生成 config.toml__<原目录>.bak.<时间戳>auth.json__<原目录>.bak.<时间戳> 备份(如 20201212101010),不会覆盖历史备份;恢复时选最新时间戳即可。

安装/运行

在本目录执行:

npm install
npm run build
node dist/index.js --help

或安装为全局命令(示例):

npm install -g .
aicodewith --help

构建期配置:aicodewith.config.json

验证地址用于校验 API Key,会发起:

  • GET <verify-url>
  • Header:Authorization: Bearer <API Key>

请在仓库根目录的 aicodewith.config.json 中配置,构建时会将配置打包进 dist/index.js。 若没有该文件,构建会失败。可参考 aicodewith.config.example.json

示例:

{
  "verifyUrl": "https://example.com/user/api/v1/me",
  "baseUrl": "https://example.com",
  "templates": {
    "claude": {
      "env": [
        "process.env.ANTHROPIC_BASE_URL=\"{CLAUDE_BASE_URL}\";",
        "process.env.ANTHROPIC_AUTH_TOKEN=\"{API_KEY}\";"
      ]
    },
    "codex": {
      "provider": "aicodewith",
      "header": "# Aicodewith API 中转配置",
      "configLines": [
        "name = \"{PROVIDER}\"",
        "base_url = \"{CODEX_BASE_URL}\"",
        "wire_api = \"responses\"",
        "temp_env_key = \"AICODEWITH_API_KEY\"",
        "requires_openai_auth = true",
        "model = \"gpt-5-codex\""
      ],
      "auth": {
        "OPENAI_API_KEY": "{API_KEY}",
        "AICODEWITH_API_KEY": "{API_KEY}"
      }
    }
  }
}

可用占位符:

  • {API_KEY}{VERIFY_URL}{BASE_URL}
  • {CLAUDE_BASE_URL}<baseUrl>/claude
  • {CODEX_BASE_URL}<baseUrl>/codex
  • {PROVIDER}templates.codex.provider

中转 base URL(可选)

默认会从 verify-urlorigin 推导中转地址:

  • Claude:<origin>/claude
  • Codex:<origin>/codex

如需覆盖,在 aicodewith.config.json 中设置 baseUrl 后重新构建。

打包说明

package.json的bin定义了安装后可以执行的命令 "aicodewith": "dist/index.js"

其他参数

  • --help / -h:显示帮助
  • --version / -v:输出版本号

发布到 npm(维护者)

  • 已配置 prepublishOnly:执行 npm publish 前会自动 npm run build,确保 dist/ 为编译产物。
  • repository/homepage/bugs 等字段需要你在仓库设置好远程地址后补齐(当前本仓库未配置 git remote origin)。