Skip to content

Use Claude Code with your ChatGPT, Kimi, Cursor or Grok subscription via a local Anthropic-compatible proxy

Rust

rename to claude-codex-proxy and add binary distribution

Raine Virtabebab52519d0
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..9fc7c95
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,141 @@
+name: Release
+
+on:
+ push:
+ tags: ['v*']
+
+permissions:
+ contents: write
+
+env:
+ BIN_NAME: claude-codex-proxy
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - target: bun-darwin-arm64
+ platform: darwin-arm64
+ - target: bun-darwin-x64
+ platform: darwin-amd64
+ - target: bun-linux-x64
+ platform: linux-amd64
+ - target: bun-linux-arm64
+ platform: linux-arm64
+ steps:
+ - uses: actions/checkout@v4
+ - uses: oven-sh/setup-bun@v2
+ with:
+ bun-version: latest
+ - name: Install dependencies
+ run: bun install --frozen-lockfile
+ - name: Build
+ env:
+ VERSION: ${{ github.ref_name }}
+ run: |
+ mkdir -p dist
+ bun build ./src/cli.ts \
+ --compile \
+ --target=${{ matrix.target }} \
+ --define BUILD_VERSION="\"${VERSION}\"" \
+ --outfile dist/${BIN_NAME}
+ - name: Package
+ run: |
+ archive="${BIN_NAME}-${{ matrix.platform }}.tar.gz"
+ tar -C dist -czf "$archive" ${BIN_NAME}
+ shasum -a 256 "$archive" > "${BIN_NAME}-${{ matrix.platform }}.sha256"
+ - uses: actions/upload-artifact@v4
+ with:
+ name: ${{ matrix.platform }}
+ path: |
+ ${{ env.BIN_NAME }}-${{ matrix.platform }}.tar.gz
+ ${{ env.BIN_NAME }}-${{ matrix.platform }}.sha256
+
+ release:
+ needs: build
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ steps:
+ - uses: actions/download-artifact@v4
+ with:
+ merge-multiple: true
+ - uses: softprops/action-gh-release@v2
+ with:
+ token: ${{ secrets.RELEASE_TOKEN }}
+ generate_release_notes: true
+ files: |
+ *.tar.gz
+ *.sha256
+
+ update-tap:
+ needs: release
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/download-artifact@v4
+ with:
+ merge-multiple: true
+ - uses: actions/checkout@v4
+ with:
+ repository: raine/homebrew-claude-codex-proxy
+ token: ${{ secrets.RELEASE_TOKEN }}
+ path: tap
+ - name: Generate formula and push to tap
+ env:
+ VERSION: ${{ github.ref_name }}
+ run: |
+ VERSION="${VERSION#v}"
+ SHA_ARM=$(awk '{print $1}' claude-codex-proxy-darwin-arm64.sha256)
+ SHA_INTEL=$(awk '{print $1}' claude-codex-proxy-darwin-amd64.sha256)
+ SHA_LINUX_AMD=$(awk '{print $1}' claude-codex-proxy-linux-amd64.sha256)
+ SHA_LINUX_ARM=$(awk '{print $1}' claude-codex-proxy-linux-arm64.sha256)
+
+ mkdir -p tap/Formula
+ cat > tap/Formula/claude-codex-proxy.rb << EOF
+ class ClaudeCodexProxy < Formula
+ desc "Local proxy: Claude Code to ChatGPT subscription via Codex Responses API"
+ homepage "https://github.com/raine/claude-codex-proxy"
+ version "${VERSION}"
+ license "MIT"
+
+ on_macos do
+ if Hardware::CPU.arm?
+ url "https://github.com/raine/claude-codex-proxy/releases/download/v${VERSION}/claude-codex-proxy-darwin-arm64.tar.gz"
+ sha256 "${SHA_ARM}"
+ else
+ url "https://github.com/raine/claude-codex-proxy/releases/download/v${VERSION}/claude-codex-proxy-darwin-amd64.tar.gz"
+ sha256 "${SHA_INTEL}"
+ end
+ end
+
+ on_linux do
+ if Hardware::CPU.arm?
+ url "https://github.com/raine/claude-codex-proxy/releases/download/v${VERSION}/claude-codex-proxy-linux-arm64.tar.gz"
+ sha256 "${SHA_LINUX_ARM}"
+ else
+ url "https://github.com/raine/claude-codex-proxy/releases/download/v${VERSION}/claude-codex-proxy-linux-amd64.tar.gz"
+ sha256 "${SHA_LINUX_AMD}"
+ end
+ end
+
+ def install
+ bin.install "claude-codex-proxy"
+ end
+
+ test do
+ assert_match version.to_s, shell_output("\#{bin}/claude-codex-proxy --version")
+ end
+ end
+ EOF
+ sed -i 's/^ //' tap/Formula/claude-codex-proxy.rb
+
+ cd tap
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+ git add Formula/claude-codex-proxy.rb
+ git commit -m "claude-codex-proxy ${VERSION}"
+ git pull --rebase
+ git push
diff --git a/.gitignore b/.gitignore
index c2658d7..b947077 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
node_modules/
+dist/
diff --git a/README.md b/README.md
index 571c232..c24d643 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-# claude-openai-proxy
+# claude-codex-proxy
-`claude-openai-proxy` is a local HTTP proxy that lets
+`claude-codex-proxy` is a local HTTP proxy that lets
[Claude Code](https://www.anthropic.com/claude-code) call OpenAI's Codex
Responses API using a **ChatGPT Pro/Plus subscription** — no Anthropic API key,
no OpenAI API key.
@@ -24,46 +24,62 @@ subscription.
### 1. Install
+**Homebrew** (macOS and Linux):
+
```sh
-git clone https://github.com/raine/claude-openai-proxy
-cd claude-openai-proxy
-bun install
+brew install raine/claude-codex-proxy/claude-codex-proxy
+```
+
+**Install script** (macOS and Linux):
+
+```sh
+curl -fsSL https://raw.githubusercontent.com/raine/claude-codex-proxy/main/scripts/install.sh | bash
```
-Requires [Bun](https://bun.sh) 1.3+.
+**Manual:** download a prebuilt binary for your platform from the
+[releases page](https://github.com/raine/claude-codex-proxy/releases).
+
+**From source** (requires [Bun](https://bun.sh) 1.3+):
+
+```sh
+git clone https://github.com/raine/claude-codex-proxy
+cd claude-codex-proxy
+bun install
+bun src/cli.ts --version
+```
### 2. Authenticate with ChatGPT
Open a browser (PKCE flow):
```sh
-bun src/cli.ts auth login
+claude-codex-proxy auth login
```
Or, on a headless machine (device code flow):
```sh
-bun src/cli.ts auth device
+claude-codex-proxy auth device
```
Either command prints a URL. Sign in with your **ChatGPT Plus/Pro account**. The
access and refresh tokens are stored at
-`~/.config/claude-openai-proxy/auth.json` with 0600 permissions.
+`~/.config/claude-codex-proxy/auth.json` with 0600 permissions.
Verify it stuck:
```sh
-bun src/cli.ts auth status
+claude-codex-proxy auth status
```
### 3. Start the proxy
```sh
-bun src/cli.ts serve
+claude-codex-proxy serve
```
Defaults to `http://127.0.0.1:11434` (loopback only). Override with
-`PORT=18765 bun src/cli.ts serve`.
+`PORT=18765 claude-codex-proxy serve`.
### 4. Point Claude Code at it
@@ -102,11 +118,11 @@ If you pass a model your account isn't entitled to, upstream returns a 400 like
sequenceDiagram
autonumber
participant CC as Claude Code
- participant P as claude-openai-proxy
+ participant P as claude-codex-proxy
participant AUTH as auth.openai.com
participant CGX as chatgpt.com/<br/>backend-api/codex
- Note over P,AUTH: One-time: PKCE or device OAuth<br/>tokens cached at<br/>~/.config/claude-openai-proxy/auth.json
+ Note over P,AUTH: One-time: PKCE or device OAuth<br/>tokens cached at<br/>~/.config/claude-codex-proxy/auth.json
CC->>P: POST /v1/messages (Anthropic shape, stream: true)
@@ -157,13 +173,13 @@ Key decisions:
### `serve`
Starts the HTTP proxy and blocks. Binds to `127.0.0.1` only. Logs to
-`$XDG_STATE_HOME/claude-openai-proxy/proxy.log` (rotated at 20 MiB). Set
-`CCXP_LOG_STDERR=1` to mirror log lines to stderr while running.
+`$XDG_STATE_HOME/claude-codex-proxy/proxy.log` (rotated at 20 MiB). Set
+`CCP_LOG_STDERR=1` to mirror log lines to stderr while running.
```sh
-claude-openai-proxy serve
-PORT=18765 claude-openai-proxy serve
-CCXP_LOG_STDERR=1 claude-openai-proxy serve
+claude-codex-proxy serve
+PORT=18765 claude-codex-proxy serve
+CCP_LOG_STDERR=1 claude-codex-proxy serve
```
Prints the exact `ANTHROPIC_BASE_URL` / `ANTHROPIC_MODEL` env vars to export on
@@ -177,11 +193,11 @@ stored a token.
Runs the PKCE browser flow against `auth.openai.com` using the Codex CLI's
client ID. Prints a URL, opens a local callback listener on port 1455, waits for
the browser to redirect back, and stores the resulting access / refresh tokens
-at `~/.config/claude-openai-proxy/auth.json` (mode 0600). The process exits
+at `~/.config/claude-codex-proxy/auth.json` (mode 0600). The process exits
automatically once the tokens are saved.
```sh
-claude-openai-proxy auth login
+claude-codex-proxy auth login
```
Sign in with your **ChatGPT Plus/Pro account** — not an OpenAI API account. The
@@ -197,7 +213,7 @@ you enter the code from any browser on any other device, and the CLI polls
`auth.openai.com` until you authorize, then stores the token.
```sh
-claude-openai-proxy auth device
+claude-codex-proxy auth device
```
Useful over SSH, inside a container, or on any host that can't open a browser.
@@ -210,7 +226,7 @@ Shows whether credentials are stored, the account ID, and how long until the
access token expires. Non-zero exit if no auth is present.
```sh
-claude-openai-proxy auth status
+claude-codex-proxy auth status
```
Example output:
@@ -218,7 +234,7 @@ Example output:
```
Account: 79342a5e-57b7-44ea-bfdc-a83ba070dad6
Expires: 2026-04-28T16:46:04.827Z (in 863946s)
-File: /Users/you/.config/claude-openai-proxy/auth.json
+File: /Users/you/.config/claude-codex-proxy/auth.json
```
The proxy refreshes the access token 5 minutes before expiry with a
@@ -229,11 +245,11 @@ calls.
### `auth logout`
-Removes `~/.config/claude-openai-proxy/auth.json`. No server call is needed; the
+Removes `~/.config/claude-codex-proxy/auth.json`. No server call is needed; the
refresh token just becomes dead.
```sh
-claude-openai-proxy auth logout
+claude-codex-proxy auth logout
```
Run `auth login` again to re-authenticate.
@@ -258,12 +274,12 @@ Settings are environment variables on the proxy process, not a config file.
| ----------------- | ---------------- | ------------------------------- |
| `PORT` | `11434` | Proxy listen port |
| `XDG_STATE_HOME` | `~/.local/state` | Base dir for `proxy.log` |
-| `CCXP_LOG_STDERR` | unset | Also mirror log lines to stderr |
+| `CCP_LOG_STDERR` | unset | Also mirror log lines to stderr |
### Files
-- `~/.config/claude-openai-proxy/auth.json` — OAuth tokens, 0600
-- `$XDG_STATE_HOME/claude-openai-proxy/proxy.log` — JSON-lines log, rotated at
+- `~/.config/claude-codex-proxy/auth.json` — OAuth tokens, 0600
+- `$XDG_STATE_HOME/claude-codex-proxy/proxy.log` — JSON-lines log, rotated at
20 MiB. Secrets (`authorization`, `access`, `refresh`, `id_token`,
`ChatGPT-Account-Id`, …) are redacted before write.
@@ -299,7 +315,7 @@ others.
```sh
bunx tsc --noEmit # typecheck
bun src/cli.ts serve # run locally
-tail -f ~/.local/state/claude-openai-proxy/proxy.log | jq .
+tail -f ~/.local/state/claude-codex-proxy/proxy.log | jq .
```
The core logic lives in:
diff --git a/package.json b/package.json
index a033c2d..7a329f9 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,10 @@
{
- "name": "claude-openai-proxy",
+ "name": "claude-codex-proxy",
"version": "0.0.1",
"private": true,
"type": "module",
"bin": {
- "claude-openai-proxy": "./src/cli.ts"
+ "claude-codex-proxy": "./src/cli.ts"
},
"scripts": {
"start": "bun run src/cli.ts serve",
diff --git a/scripts/install.sh b/scripts/install.sh
new file mode 100755
index 0000000..5004a44
--- /dev/null
+++ b/scripts/install.sh
@@ -0,0 +1,262 @@
+#!/usr/bin/env bash
+#
+# claude-codex-proxy installation script
+# Usage: curl -fsSL https://raw.githubusercontent.com/raine/claude-codex-proxy/main/scripts/install.sh | bash
+#
+# Environment variables:
+# CLAUDE_CODEX_PROXY_VERSION - Pin a specific version (e.g., v0.1.0)
+# CLAUDE_CODEX_PROXY_INSTALL_DIR - Override install directory (default: /usr/local/bin or ~/.local/bin)
+#
+# Examples:
+# CLAUDE_CODEX_PROXY_VERSION=v0.1.0 bash install.sh
+# CLAUDE_CODEX_PROXY_INSTALL_DIR=/opt/bin bash install.sh
+#
+
+set -e
+
+BIN_NAME="claude-codex-proxy"
+REPO="raine/claude-codex-proxy"
+
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+BLUE='\033[0;34m'
+NC='\033[0m'
+
+log_info() { echo -e "${BLUE}==>${NC} $1"; }
+log_success() { echo -e "${GREEN}==>${NC} $1"; }
+log_warning() { echo -e "${YELLOW}==>${NC} $1"; }
+log_error() { echo -e "${RED}Error:${NC} $1" >&2; }
+
+detect_platform() {
+ local os arch
+
+ case "$(uname -s)" in
+ Darwin) os="darwin" ;;
+ Linux) os="linux" ;;
+ *)
+ log_error "Unsupported operating system: $(uname -s)"
+ echo ""
+ echo "${BIN_NAME} supports macOS and Linux."
+ echo "For other platforms, build from source with Bun:"
+ echo " git clone https://github.com/${REPO}"
+ echo ""
+ exit 1
+ ;;
+ esac
+
+ case "$(uname -m)" in
+ x86_64 | amd64) arch="amd64" ;;
+ aarch64 | arm64) arch="arm64" ;;
+ *)
+ log_error "Unsupported architecture: $(uname -m)"
+ echo ""
+ echo "${BIN_NAME} prebuilt binaries are available for amd64 and arm64."
+ echo "For other architectures, build from source with Bun:"
+ echo " git clone https://github.com/${REPO}"
+ echo ""
+ exit 1
+ ;;
+ esac
+
+ echo "${os}-${arch}"
+}
+
+install_from_release() {
+ log_info "Installing ${BIN_NAME} from GitHub releases..."
+
+ local platform=$1
+ local tmp_dir
+ tmp_dir=$(mktemp -d)
+ trap 'rm -rf "$tmp_dir"' EXIT
+
+ local version="${CLAUDE_CODEX_PROXY_VERSION:-}"
+
+ if [ -z "$version" ]; then
+ log_info "Fetching latest release..."
+ local latest_url="https://api.github.com/repos/${REPO}/releases/latest"
+ local release_json
+
+ if command -v curl &>/dev/null; then
+ release_json=$(curl -fsSL --retry 3 --retry-connrefused --connect-timeout 10 --max-time 30 "$latest_url")
+ elif command -v wget &>/dev/null; then
+ release_json=$(wget --tries=3 --timeout=30 -qO- "$latest_url")
+ else
+ log_error "Neither curl nor wget found. Please install one of them."
+ exit 1
+ fi
+
+ version=$(echo "$release_json" | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
+
+ if [ -z "$version" ]; then
+ log_error "Failed to fetch latest version"
+ echo ""
+ echo "This might be due to network issues or GitHub API rate limits."
+ echo "You can specify a version manually:"
+ echo " CLAUDE_CODEX_PROXY_VERSION=v0.1.0 bash install.sh"
+ echo ""
+ exit 1
+ fi
+ fi
+
+ log_info "Installing version: $version"
+
+ local archive_name="${BIN_NAME}-${platform}.tar.gz"
+ local download_url="https://github.com/${REPO}/releases/download/${version}/${archive_name}"
+
+ log_info "Downloading $archive_name..."
+
+ cd "$tmp_dir"
+ if command -v curl &>/dev/null; then
+ if ! curl -fsSL --retry 3 --retry-connrefused --connect-timeout 10 --max-time 120 -o "$archive_name" "$download_url"; then
+ log_error "Download failed"
+ echo ""
+ echo "The release may not have a prebuilt binary for your platform."
+ echo ""
+ cd - >/dev/null || cd "$HOME"
+ exit 1
+ fi
+ elif command -v wget &>/dev/null; then
+ if ! wget --tries=3 --timeout=120 -q -O "$archive_name" "$download_url"; then
+ log_error "Download failed"
+ cd - >/dev/null || cd "$HOME"
+ exit 1
+ fi
+ fi
+
+ log_info "Verifying checksum..."
+ local checksum_file="${BIN_NAME}-${platform}.sha256"
+ local checksum_url="https://github.com/${REPO}/releases/download/${version}/${checksum_file}"
+
+ if command -v curl &>/dev/null; then
+ if ! curl -fsSL --retry 3 --retry-connrefused --connect-timeout 10 --max-time 30 -o "$checksum_file" "$checksum_url"; then
+ log_error "Failed to download checksum file"
+ cd - >/dev/null || cd "$HOME"
+ exit 1
+ fi
+ elif command -v wget &>/dev/null; then
+ if ! wget --tries=3 --timeout=30 -q -O "$checksum_file" "$checksum_url"; then
+ log_error "Failed to download checksum file"
+ cd - >/dev/null || cd "$HOME"
+ exit 1
+ fi
+ fi
+
+ if command -v sha256sum &>/dev/null; then
+ if ! sha256sum -c "$checksum_file" &>/dev/null; then
+ log_error "Checksum verification failed"
+ cd - >/dev/null || cd "$HOME"
+ exit 1
+ fi
+ elif command -v shasum &>/dev/null; then
+ if ! shasum -a 256 -c "$checksum_file" &>/dev/null; then
+ log_error "Checksum verification failed"
+ cd - >/dev/null || cd "$HOME"
+ exit 1
+ fi
+ else
+ log_warning "Neither sha256sum nor shasum found, skipping checksum verification"
+ fi
+
+ log_success "Checksum verified"
+
+ log_info "Extracting archive..."
+ if ! tar -xzf "$archive_name"; then
+ log_error "Failed to extract archive"
+ exit 1
+ fi
+
+ local install_dir="${CLAUDE_CODEX_PROXY_INSTALL_DIR:-}"
+ if [ -z "$install_dir" ]; then
+ if [[ -w /usr/local/bin ]]; then
+ install_dir="/usr/local/bin"
+ else
+ install_dir="$HOME/.local/bin"
+ mkdir -p "$install_dir"
+ fi
+ fi
+
+ if [ -f "$install_dir/${BIN_NAME}" ]; then
+ local existing_version
+ existing_version=$("$install_dir/${BIN_NAME}" --version 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' || echo "unknown")
+ log_info "Existing installation found: $existing_version"
+ log_info "Upgrading to: $version"
+ fi
+
+ log_info "Installing to $install_dir..."
+ local tmp_binary="$install_dir/${BIN_NAME}.tmp.$$"
+
+ if [[ -w "$install_dir" ]]; then
+ cp "${BIN_NAME}" "$tmp_binary"
+ chmod +x "$tmp_binary"
+ mv -f "$tmp_binary" "$install_dir/${BIN_NAME}"
+ else
+ if ! sudo cp "${BIN_NAME}" "$tmp_binary"; then
+ log_error "Failed to install to $install_dir (sudo required)"
+ exit 1
+ fi
+ sudo chmod +x "$tmp_binary"
+ sudo mv -f "$tmp_binary" "$install_dir/${BIN_NAME}"
+ fi
+
+ if [[ "$(uname -s)" == "Darwin" ]] && command -v xattr &>/dev/null; then
+ xattr -d com.apple.quarantine "$install_dir/${BIN_NAME}" 2>/dev/null || true
+ fi
+
+ log_success "${BIN_NAME} installed to $install_dir/${BIN_NAME}"
+
+ if [[ ":$PATH:" != *":$install_dir:"* ]]; then
+ log_warning "$install_dir is not in your PATH"
+ echo ""
+ echo "Add this to your shell profile (~/.bashrc, ~/.zshrc, etc.):"
+ echo " export PATH=\"\$PATH:$install_dir\""
+ echo ""
+ fi
+
+ cd - >/dev/null || cd "$HOME"
+
+ INSTALL_DIR="$install_dir"
+}
+
+verify_installation() {
+ local install_dir="$1"
+
+ if [ ! -x "$install_dir/${BIN_NAME}" ]; then
+ log_error "${BIN_NAME} binary not found or not executable at $install_dir/${BIN_NAME}"
+ exit 1
+ fi
+
+ if ! "$install_dir/${BIN_NAME}" --version &>/dev/null; then
+ log_error "${BIN_NAME} binary exists but failed to run"
+ exit 1
+ fi
+
+ log_success "${BIN_NAME} is installed and ready!"
+ echo ""
+ "$install_dir/${BIN_NAME}" --version
+ echo ""
+
+ echo "Get started:"
+ echo " ${BIN_NAME} auth login # authenticate with your ChatGPT account"
+ echo " ${BIN_NAME} serve # start the proxy"
+ echo ""
+ echo "Documentation: https://github.com/${REPO}"
+ echo ""
+}
+
+main() {
+ echo ""
+ echo "${BIN_NAME} installer"
+ echo ""
+
+ log_info "Detecting platform..."
+ local platform
+ platform=$(detect_platform)
+ log_info "Platform: $platform"
+
+ install_from_release "$platform"
+
+ verify_installation "$INSTALL_DIR"
+}
+
+main "$@"
diff --git a/scripts/publish b/scripts/publish
new file mode 100755
index 0000000..4a1d6f6
--- /dev/null
+++ b/scripts/publish
@@ -0,0 +1,152 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+SKIP_CHANGELOG=false
+bump=""
+
+for arg in "$@"; do
+ case "$arg" in
+ --skip-changelog) SKIP_CHANGELOG=true ;;
+ patch|minor|major|beta) bump="$arg" ;;
+ *)
+ echo "error: unknown argument: $arg" >&2
+ echo "usage: scripts/publish <patch|minor|major|beta> [--skip-changelog]" >&2
+ exit 1
+ ;;
+ esac
+done
+
+if [[ -z "$bump" ]]; then
+ echo "usage: scripts/publish <patch|minor|major|beta> [--skip-changelog]" >&2
+ exit 1
+fi
+
+BETA=false
+if [[ "$bump" == "beta" ]]; then
+ BETA=true
+fi
+
+if ! git diff --quiet || ! git diff --cached --quiet; then
+ echo "error: working tree has uncommitted changes" >&2
+ exit 1
+fi
+
+if [[ "$BETA" == false ]]; then
+ echo "Running checks..."
+ bun run typecheck
+fi
+
+cleanup() {
+ rc=$?
+ if [ $rc -ne 0 ]; then
+ echo "Failure detected, rolling back version changes..." >&2
+ git restore package.json CHANGELOG.md 2>/dev/null || true
+ fi
+ exit $rc
+}
+trap cleanup EXIT
+
+if [[ "$BETA" == true ]]; then
+ npm version prepatch --preid=beta --no-git-tag-version
+else
+ npm version "$bump" --no-git-tag-version
+fi
+VERSION=$(node -p "require('./package.json').version")
+
+if [[ "$SKIP_CHANGELOG" == false ]]; then
+ echo "Generating changelog entry for v${VERSION}..."
+
+ # shellcheck disable=SC2016
+ CHANGELOG_PROMPT=$(sed "s/__VERSION__/$VERSION/g" <<'PROMPT_EOF'
+# Changelog Updater (Pending Release)
+
+## Task
+
+Generate a user-focused changelog entry for the upcoming release `v__VERSION__` and insert it into CHANGELOG.md.
+
+## Steps
+
+1. **Find the previous tag**
+
+ ```bash
+ git describe --tags --abbrev=0
+ ```
+
+ If this fails (no previous tag exists), this is the first release—compare against the initial commit instead.
+
+2. **Get the commits since the last tag**
+
+ ```bash
+ git log --oneline PREVIOUS_TAG..HEAD
+ ```
+
+3. **Review the actual changes** to understand context
+
+ ```bash
+ git diff PREVIOUS_TAG..HEAD --stat
+ ```
+
+ Read relevant changed files as needed to understand what the changes do.
+
+4. **Update CHANGELOG.md**
+
+ - Insert the new entry at the top (after the `# Changelog` header), as the newest release
+ - Use heading level `##` for version entries
+ - Use today's date in YYYY-MM-DD format
+ - Create CHANGELOG.md if it does not exist, with `# Changelog` as the first line
+
+## Writing Guidelines
+
+- Write from the user's perspective: what can they now do, what's fixed, what's improved?
+- Use plain language, avoid implementation details like function names, file paths, or internal refactors
+- Focus on behavior changes, new capabilities, and bug fixes users would notice
+- Skip purely internal changes (refactoring, test improvements, CI changes) unless they affect users
+- Keep entries concise—one line per change is usually enough
+- If there are no user-facing changes, still create a minimal entry noting the release
+
+## Linking Issues and Pull Requests
+
+- Determine the GitHub repository URL from the git remote (e.g., `git remote get-url origin`)
+- When commits reference GitHub issues or pull requests (e.g., `#70`, `fixes #70`, `closes #65`), link them at the end of the relevant changelog entry
+- Even when commits don't explicitly reference issues or PRs, check recent closed issues and merged pull requests (`gh issue list --state closed --limit 20`, `gh pr list --state merged --limit 20`) to find ones related to the changes, and link them
+- Format: `([#70](https://github.com/OWNER/REPO/issues/70))` for issues, `([#68](https://github.com/OWNER/REPO/pull/68))` for pull requests
+- If multiple entries relate to the same issue/PR, link it on each relevant entry
+
+## Entry Format
+
+```markdown
+## v__VERSION__ (YYYY-MM-DD)
+
+- Change description ([#70](https://github.com/OWNER/REPO/issues/70))
+- Another change description
+```
+PROMPT_EOF
+)
+
+ claude --dangerously-skip-permissions --no-session-persistence -p "$CHANGELOG_PROMPT"
+ prettier --write CHANGELOG.md 2>/dev/null || true
+
+ ${EDITOR:-vim} CHANGELOG.md
+fi
+
+read -rp "Proceed with release v${VERSION}? [y/n] " response
+if [[ "$response" != "y" && "$response" != "yes" ]]; then
+ echo "Aborting release."
+ exit 1
+fi
+
+trap - EXIT
+
+CHANGELOG_FILE=""
+if [[ -f CHANGELOG.md ]]; then
+ CHANGELOG_FILE="CHANGELOG.md"
+fi
+
+git add package.json $CHANGELOG_FILE
+git commit -m "$VERSION"
+git tag "v$VERSION"
+git push
+git push --tags
+
+echo ""
+echo "Pushed v${VERSION} — CI will build and publish."
diff --git a/src/auth/manager.ts b/src/auth/manager.ts
index f5afdd3..2ed98df 100644
--- a/src/auth/manager.ts
+++ b/src/auth/manager.ts
@@ -8,7 +8,7 @@ let inflight: Promise<StoredAuth> | undefined
export async function getAuth(): Promise<StoredAuth> {
if (!cached) {
const stored = await loadAuth()
- if (!stored) throw new Error("Not authenticated. Run: claude-openai-proxy auth login")
+ if (!stored) throw new Error("Not authenticated. Run: claude-codex-proxy auth login")
cached = stored
}
if (cached.expires - REFRESH_MARGIN_MS > Date.now()) {
diff --git a/src/auth/token-store.ts b/src/auth/token-store.ts
index befbdd6..2246ce3 100644
--- a/src/auth/token-store.ts
+++ b/src/auth/token-store.ts
@@ -9,7 +9,7 @@ export interface StoredAuth {
accountId?: string
}
-const DIR = join(homedir(), ".config", "claude-openai-proxy")
+const DIR = join(homedir(), ".config", "claude-codex-proxy")
const FILE = join(DIR, "auth.json")
export async function loadAuth(): Promise<StoredAuth | undefined> {
diff --git a/src/cli.ts b/src/cli.ts
index 53510dd..d5fa2ac 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -6,10 +6,17 @@ import { loadAuth, authPath, clearAuth } from "./auth/token-store.ts"
import { startServer } from "./server.ts"
import { createLogger, logDir } from "./log.ts"
+declare const BUILD_VERSION: string | undefined
+const VERSION = typeof BUILD_VERSION === "string" ? BUILD_VERSION : "dev"
+
const log = createLogger("cli")
async function main() {
const [, , cmd, sub] = process.argv
+ if (cmd === "--version" || cmd === "-v" || cmd === "version") {
+ console.log(`claude-codex-proxy ${VERSION}`)
+ return
+ }
switch (cmd) {
case "serve":
case undefined: {
@@ -67,11 +74,12 @@ async function main() {
function usageAndExit(): never {
console.log(`Usage:
- claude-openai-proxy serve Run proxy (PORT env, default 11434)
- claude-openai-proxy auth login Browser OAuth (PKCE)
- claude-openai-proxy auth device Device-code OAuth
- claude-openai-proxy auth status Show current auth
- claude-openai-proxy auth logout Clear stored auth
+ claude-codex-proxy serve Run proxy (PORT env, default 11434)
+ claude-codex-proxy auth login Browser OAuth (PKCE)
+ claude-codex-proxy auth device Device-code OAuth
+ claude-codex-proxy auth status Show current auth
+ claude-codex-proxy auth logout Clear stored auth
+ claude-codex-proxy --version Show version
`)
process.exit(2)
}
diff --git a/src/log.ts b/src/log.ts
index 0aa7545..c6ef0fa 100644
--- a/src/log.ts
+++ b/src/log.ts
@@ -21,7 +21,7 @@ const REDACT_KEYS = new Set([
function stateDir(): string {
const base = process.env.XDG_STATE_HOME || join(homedir(), ".local", "state")
- return join(base, "claude-openai-proxy")
+ return join(base, "claude-codex-proxy")
}
export function logDir(): string {
@@ -100,7 +100,7 @@ async function write(level: Level, service: string, msg: string, fields?: Record
} catch {
// swallow; also print to stderr for visibility
}
- if (level === "error" || level === "warn" || process.env.CCXP_LOG_STDERR) {
+ if (level === "error" || level === "warn" || process.env.CCP_LOG_STDERR) {
process.stderr.write(line + "\n")
}
}