Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

147 changes: 0 additions & 147 deletions .github/workflows/docker-image.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/release.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ COPY --from=builder ./app/CLIProxyAPI /CLIProxyAPI/CLIProxyAPI

COPY config.example.yaml /CLIProxyAPI/config.example.yaml

# Bake the management UI bundle so a freshly-pulled image serves the right
# UI on first request, before the auto-updater's first 3-hour tick. The build
# context is expected to carry a fresh static/management.html (see the
# README's release flow).
COPY static/management.html /CLIProxyAPI/static/management.html

ENV MANAGEMENT_STATIC_PATH=/CLIProxyAPI/static

WORKDIR /CLIProxyAPI

EXPOSE 8317
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

English | [中文](README_CN.md) | [日本語](README_JA.md)

> **Fork notice.** This is [Z-M-Huang's](https://github.com/Z-M-Huang) fork of [router-for-me/CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI). It carries extra features (currently: **Prompt Rules** — content-level inject/strip on outgoing requests; revived logging support is planned for v0.2.0) and republishes the docker image at `zhironghuang/cli-proxy-api`. Upstream improvements are merged in periodically. For the original project, follow the upstream link.

A proxy server that provides OpenAI/Gemini/Claude/Codex compatible API interfaces for CLI.

It now also supports OpenAI Codex (GPT models) and Claude Code via OAuth.
Expand Down
2 changes: 2 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[English](README.md) | 中文 | [日本語](README_JA.md)

> **分叉说明。** 本仓库是 [Z-M-Huang](https://github.com/Z-M-Huang) 维护的 [router-for-me/CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) 分叉,附带额外功能(当前:**提示规则** — 出站请求的内容级注入/剥离;恢复版日志支持计划在 v0.2.0 上线),并以 `zhironghuang/cli-proxy-api` 重新发布 Docker 镜像。会定期合并上游改进。原始项目请访问上方链接。

一个为 CLI 提供 OpenAI/Gemini/Claude/Codex 兼容 API 接口的代理服务器。

现已支持通过 OAuth 登录接入 OpenAI Codex(GPT 系列)和 Claude Code。
Expand Down
2 changes: 2 additions & 0 deletions README_JA.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[English](README.md) | [中文](README_CN.md) | 日本語

> **フォークについて。** 本リポジトリは [Z-M-Huang](https://github.com/Z-M-Huang) による [router-for-me/CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) のフォークで、追加機能(現在は **Prompt Rules** — 送信リクエストへのコンテンツレベルの注入/除去。再構築されたロギングサポートは v0.2.0 で予定)を含み、Docker イメージは `zhironghuang/cli-proxy-api` で再公開しています。上流の改善は定期的にマージしています。元のプロジェクトは上記リンクをご参照ください。

CLI向けのOpenAI/Gemini/Claude/Codex互換APIインターフェースを提供するプロキシサーバーです。

OAuth経由でOpenAI Codex(GPTモデル)およびClaude Codeもサポートしています。
Expand Down
2 changes: 1 addition & 1 deletion config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ remote-management:
# disable-auto-update-panel: false

# GitHub repository for the management control panel. Accepts a repository URL or releases API URL.
panel-github-repository: "https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
panel-github-repository: "https://github.com/Z-M-Huang/Cli-Proxy-API-Management-Center"

# Authentication directory (supports ~ for home directory)
auth-dir: "~/.cli-proxy-api"
Expand Down
2 changes: 1 addition & 1 deletion docker-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ switch ($choice) {
Write-Host "----------------------------------------"

# Build and start the services with a local-only image tag
$env:CLI_PROXY_IMAGE = "cli-proxy-api:local"
$env:CLI_PROXY_IMAGE = "zhironghuang/cli-proxy-api:local"

Write-Host "Building the Docker image..."
docker compose build --build-arg VERSION=$VERSION --build-arg COMMIT=$COMMIT --build-arg BUILD_DATE=$BUILD_DATE
Expand Down
2 changes: 1 addition & 1 deletion docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ case "$choice" in
echo "----------------------------------------"

# Build and start the services with a local-only image tag
export CLI_PROXY_IMAGE="cli-proxy-api:local"
export CLI_PROXY_IMAGE="zhironghuang/cli-proxy-api:local"

echo "Building the Docker image..."
docker compose build \
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
cli-proxy-api:
image: ${CLI_PROXY_IMAGE:-eceasy/cli-proxy-api:latest}
image: ${CLI_PROXY_IMAGE:-zhironghuang/cli-proxy-api:latest}
pull_policy: always
build:
context: .
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

const (
DefaultPanelGitHubRepository = "https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
DefaultPanelGitHubRepository = "https://github.com/Z-M-Huang/Cli-Proxy-API-Management-Center"
DefaultPprofAddr = "127.0.0.1:8316"
)

Expand Down
55 changes: 18 additions & 37 deletions internal/managementasset/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@ import (
)

const (
defaultManagementReleaseURL = "https://api.github.com/repos/router-for-me/Cli-Proxy-API-Management-Center/releases/latest"
defaultManagementFallbackURL = "https://cpamc.router-for.me/"
managementAssetName = "management.html"
httpUserAgent = "CLIProxyAPI-management-updater"
managementSyncMinInterval = 30 * time.Second
updateCheckInterval = 3 * time.Hour
maxAssetDownloadSize = 50 << 20 // 10 MB safety limit for management asset downloads
// defaultManagementReleaseURL points at the fork's frontend release feed.
// The auto-updater pulls management.html from "latest" here every
// updateCheckInterval. The fork-controlled fallback URL upstream used
// (https://cpamc.router-for.me/) is intentionally absent — if the GitHub
// release fetch fails the updater leaves whatever local asset already
// exists in place; if no local asset exists, /management.html returns 404
// until the next successful fetch. The Dockerfile bakes the bundle so
// fresh containers always have a usable local asset.
defaultManagementReleaseURL = "https://api.github.com/repos/Z-M-Huang/Cli-Proxy-API-Management-Center/releases/latest"
managementAssetName = "management.html"
httpUserAgent = "CLIProxyAPI-management-updater"
managementSyncMinInterval = 30 * time.Second
updateCheckInterval = 3 * time.Hour
maxAssetDownloadSize = 50 << 20 // 10 MB safety limit for management asset downloads
)

// ManagementFileName exposes the control panel asset filename.
Expand Down Expand Up @@ -234,11 +241,11 @@ func EnsureLatestManagementHTML(ctx context.Context, staticDir string, proxyURL

asset, remoteHash, err := fetchLatestAsset(ctx, client, releaseURL)
if err != nil {
// No fork-operated fallback URL — if the GitHub fetch fails we
// leave any existing local asset in place. localFileMissing here
// means /management.html will 404 until the next tick succeeds.
if localFileMissing {
log.WithError(err).Warn("failed to fetch latest management release information, trying fallback page")
if ensureFallbackManagementHTML(ctx, client, localPath) {
return nil, nil
}
log.WithError(err).Warn("failed to fetch latest management release information; no local asset to serve")
return nil, nil
}
log.WithError(err).Warn("failed to fetch latest management release information")
Expand All @@ -252,13 +259,6 @@ func EnsureLatestManagementHTML(ctx context.Context, staticDir string, proxyURL

data, downloadedHash, err := downloadAsset(ctx, client, asset.BrowserDownloadURL)
if err != nil {
if localFileMissing {
log.WithError(err).Warn("failed to download management asset, trying fallback page")
if ensureFallbackManagementHTML(ctx, client, localPath) {
return nil, nil
}
return nil, nil
}
log.WithError(err).Warn("failed to download management asset")
return nil, nil
}
Expand All @@ -281,25 +281,6 @@ func EnsureLatestManagementHTML(ctx context.Context, staticDir string, proxyURL
return err == nil
}

func ensureFallbackManagementHTML(ctx context.Context, client *http.Client, localPath string) bool {
data, downloadedHash, err := downloadAsset(ctx, client, defaultManagementFallbackURL)
if err != nil {
log.WithError(err).Warn("failed to download fallback management control panel page")
return false
}

log.Warnf("management asset downloaded from fallback URL without digest verification (hash=%s) — "+
"enable verified GitHub updates by keeping disable-auto-update-panel set to false", downloadedHash)

if err = atomicWriteFile(localPath, data); err != nil {
log.WithError(err).Warn("failed to persist fallback management control panel page")
return false
}

log.Infof("management asset updated from fallback page successfully (hash=%s)", downloadedHash)
return true
}

func resolveReleaseURL(repo string) string {
repo = strings.TrimSpace(repo)
if repo == "" {
Expand Down
Loading