From 2b53af06c5bcda05caa872f5ee2912a63dd5c942 Mon Sep 17 00:00:00 2001 From: chuan Date: Sun, 16 Aug 2026 23:53:41 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E6=B3=A8=E5=85=A5=20patched=20CPA=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 1 + patch/README.md | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 03706f7..92c4835 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,6 +35,7 @@ - 本地 CPA 在 WSL 中运行,项目运行目录统一使用 `cpa-plugin/.runtime`;Windows 客户端经 `127.0.0.1` 访问 WSL 时,localhost 转发层可能不会立即向 CPA 传递客户端断开,取消链路测试优先在 WSL 内直连执行。 - 从 PowerShell 跨 WSL 或 SSH 执行包含 Bash 变量、命令替换或多层引号的逻辑时,优先在 `.runtime/tmp/` 创建临时脚本后传入目标环境执行,不拼接复杂的单行 shell;临时脚本不提交。 - CLIProxyAPI `v7.2.133` 的宿主补丁保存在 `patch/`,必须按 `usage-context`、`usage-identity`、`request-lifecycle-cancel` 的顺序应用;升级 CPA 后先复测补丁是否仍有必要。 +- 构建本项目 patched CPA 时必须按上游 release workflow 使用 `-ldflags` 注入 `main.Version`、`main.Commit` 和 `main.BuildDate`。`Version` 固定使用“当前上游最新 tag + `-dev`”格式(例如 `v7.2.133-dev`),用于明确区分官方 Release 与本项目补丁构建;不得发布只显示 `dev`、`none` 或 `unknown` 的产物。上传前先在本地执行二进制并核对完整版本输出。 - CPA Linux 可执行文件解压后约 60 MiB,`gzip -9` 后约 20 MiB。上传远端时使用 gzip/tar.gz 或 `scp -C`,不要直接传输未压缩二进制;部署后的运行文件仍需解压为原始可执行文件。 - 实际服务器为 `root@akko.pchuan.top`,CPA 根目录为 `/root/cpa`。只维护本项目的 `billing` 和已要求启用的 `keeper`,不启用或部署其他参考插件。 - 远端替换 CPA 或 billing 前,先停止 `/root/cpa/cpa.sh` 管理的进程,并把旧二进制、插件和 `data/cpa-ext.db*` 备份到 `/root/cpa/backups//`;新版本启动失败时恢复旧二进制和插件。 diff --git a/patch/README.md b/patch/README.md index 26822fb..846abe7 100644 --- a/patch/README.md +++ b/patch/README.md @@ -84,7 +84,15 @@ git -C .externals/CLIProxyAPI apply ../../patch/cli-proxy-api-request-lifecycle- cd .externals/CLIProxyAPI gofmt -w internal/pluginhost sdk/api/handlers sdk/cliproxy/usage sdk/pluginabi sdk/pluginapi go test -race ./internal/pluginhost ./sdk/api/handlers ./sdk/cliproxy/usage -count=1 -CGO_ENABLED=1 go build -o test-output ./cmd/server +version=v7.2.133-dev +commit=7efe0a7c +build_date="$(date -u +%Y-%m-%dT%H:%M:%SZ)" +CGO_ENABLED=1 go build -buildvcs=false \ + -ldflags="-s -w -X main.Version=$version -X main.Commit=$commit -X main.BuildDate=$build_date" \ + -o test-output ./cmd/server +help_output="$(./test-output -h 2>&1)" +first_line="${help_output%%$'\n'*}" +test "$first_line" = "CLIProxyAPI Version: $version, Commit: $commit, BuiltAt: $build_date" rm test-output ```