@cc-go-proxy/ccgp 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +22 -0
- package/NOTICE +19 -0
- package/README.md +265 -2
- package/THIRD_PARTY_LICENSES.md +1794 -0
- package/bin/ccgp.js +62 -0
- package/bin/ccgpy.js +62 -0
- package/package.json +48 -4
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Claude Code Proxy Contributors
|
|
4
|
+
Copyright (c) 2026 PHPCraftdream and ccgp contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
ccgp (cc-go-proxy)
|
|
2
|
+
Copyright (c) 2026 PHPCraftdream and ccgp contributors
|
|
3
|
+
|
|
4
|
+
ccgp is licensed under either of
|
|
5
|
+
|
|
6
|
+
* the Apache License, Version 2.0 (LICENSE-APACHE), or
|
|
7
|
+
* the MIT license (LICENSE-MIT),
|
|
8
|
+
|
|
9
|
+
at your option.
|
|
10
|
+
|
|
11
|
+
This work is derived from claude-code-proxy by nielspeter
|
|
12
|
+
(https://github.com/nielspeter/claude-code-proxy),
|
|
13
|
+
Copyright (c) 2025 Claude Code Proxy Contributors, which is licensed under the
|
|
14
|
+
MIT license. The portions that originate there remain available under the MIT
|
|
15
|
+
license (LICENSE-MIT) with the original copyright notice preserved.
|
|
16
|
+
|
|
17
|
+
Third-party libraries linked into the ccgp binary are listed, with their
|
|
18
|
+
licenses, in THIRD_PARTY_LICENSES.md, which is shipped inside every release
|
|
19
|
+
archive and npm package.
|
package/README.md
CHANGED
|
@@ -1,3 +1,266 @@
|
|
|
1
|
-
|
|
1
|
+
> **ccgp is a fork of [nielspeter/claude-code-proxy](https://github.com/nielspeter/claude-code-proxy)** (MIT). Upstream is a general proxy that puts OpenAI-compatible APIs behind Claude Code; ccgp keeps that translation core and turns it into a headless launcher + proxy for daily use: `ccgp <profile>` runs Claude Code on your ChatGPT Codex subscription, an OpenAI-compatible API or z.ai GLM, with token-protected URLs, per-profile model mapping and context windows, and Claude credentials kept out of the session. [How it differs](#how-ccgp-differs-from-upstream)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# ccgp
|
|
4
|
+
|
|
5
|
+
[](https://github.com/PHPCraftdream/cc-go-proxy/actions/workflows/ci.yml)
|
|
6
|
+
[](https://github.com/PHPCraftdream/cc-go-proxy/actions/workflows/licenses.yml)
|
|
7
|
+
[](https://github.com/PHPCraftdream/cc-go-proxy/releases)
|
|
8
|
+
[](https://www.npmjs.com/package/@cc-go-proxy/ccgp)
|
|
9
|
+
[](go.mod)
|
|
10
|
+
[](#license)
|
|
11
|
+
[](#install)
|
|
12
|
+
[](https://goreportcard.com/report/github.com/PHPCraftdream/cc-go-proxy)
|
|
13
|
+
|
|
14
|
+
Run [Claude Code](https://claude.com/claude-code) on other models. ccgp is one small Go binary: a local proxy that speaks
|
|
15
|
+
Claude's API to Claude Code and the backend's API to the other side, and a launcher that wires the two together.
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
ccgp codex # Claude Code on your ChatGPT subscription (Codex)
|
|
19
|
+
ccgp zai # Claude Code on z.ai GLM
|
|
20
|
+
ccgp codex -p "explain this" # headless: everything after the profile goes to claude
|
|
21
|
+
ccgpy codex # same, with every permission prompt off (--dangerously-skip-permissions)
|
|
22
|
+
ccgpy # choose the profile from a list (ccgpy . -c: the same, with claude's arguments)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- **Launcher and proxy in one.** `ccgp <profile>` starts the background server if needed, makes sure you are signed in,
|
|
28
|
+
then runs `claude` through it. No service to install, no env files to juggle.
|
|
29
|
+
- **Backends.** ChatGPT Codex with a subscription (OAuth, refresh-token rotation, browser or device-code sign-in),
|
|
30
|
+
OpenAI-compatible APIs with a key (OpenAI, OpenRouter, Ollama, …), and Anthropic-compatible endpoints such as z.ai.
|
|
31
|
+
- **Named profiles.** Each profile has its own URL token and its own provider; Claude's `fable` / `opus` / `sonnet` /
|
|
32
|
+
`haiku` map to the models you choose, with the real context window of each, so compaction fires at the right time.
|
|
33
|
+
Several logins are supported: `ccgp --profile add` clones a profile with its own login (a second ChatGPT account),
|
|
34
|
+
adds a profile to an existing login, or wires up a new backend. `--type claude` makes a profile of the real Claude
|
|
35
|
+
Code (no proxy): a clean config directory of its own and its own sign-in, so you can keep several Claude accounts
|
|
36
|
+
([details](docs/configuration.md#profiles-of-the-real-claude-code---type-claude)). `--type claude_api` is the same with
|
|
37
|
+
an API key of the Claude Platform of its own and a server you can set, the official one by default
|
|
38
|
+
([details](docs/configuration.md#profiles-with-an-api-key---type-claude_api)).
|
|
39
|
+
- **Locked down.** Every request needs `/call/<token>/…`; the server listens on loopback; secrets are owner-only on disk.
|
|
40
|
+
- **Your Claude credentials stay out.** Each profile runs Claude Code in its own config directory with your agents,
|
|
41
|
+
skills, commands and plugins copied in, but never an official login or API key.
|
|
42
|
+
- **Sessions travel.** `ccgp --send` (aliases `ccgp --import` / `ccgp --export`) copy the latest sessions of the
|
|
43
|
+
current directory between Claude Code and a profile, or between two profiles; a session continued on both sides is
|
|
44
|
+
kept as a second one (`--fork`), replaced with the old file kept (`--force`), or written afresh as the second one
|
|
45
|
+
(`--fork --force`).
|
|
46
|
+
- **Separate setups.** `ccgp --local` / `ccgp --home <dir>` (or a `.ccgp` directory in the project) keep the config,
|
|
47
|
+
logins, tokens, Claude dirs and the log in one directory that shares nothing with the default setup
|
|
48
|
+
([details](docs/cli.md#own-home-a-setup-that-shares-nothing)).
|
|
49
|
+
- **Through a proxy.** SOCKS5, HTTP `CONNECT` and HTTPS proxies for every outbound connection (models, sign-in, token
|
|
50
|
+
refresh, update), global, per provider or per profile (the nearest level replaces the ones above it), with `none`
|
|
51
|
+
for a direct connection; without a setting the `HTTPS_PROXY` / `HTTP_PROXY` / `NO_PROXY` environment applies
|
|
52
|
+
([details](docs/configuration.md#layout)).
|
|
53
|
+
- **Peak hours.** Give a provider its peak hours (`ccgp --peak zai set mon-fri 14:00-18:00`, in the provider's zone)
|
|
54
|
+
and ccgp refuses its requests then, with a notice in the chat that says when work can go on; `pause` lets you
|
|
55
|
+
through for a while. The provider never sees the refused request ([details](docs/peak-hours.md)).
|
|
56
|
+
- **Interactive setup.** `ccgp --interactive` (or `-i`) is a full-screen interface ([Bubble Tea](https://github.com/charmbracelet/bubbletea))
|
|
57
|
+
to do everything the commands do without remembering them: profiles and providers (settings, proxy, sign-in), peak
|
|
58
|
+
hours, connections, models, sessions, the server. The commands and the interface cover each other both ways, and a
|
|
59
|
+
test keeps it so ([details](docs/cli.md#interactive-mode)).
|
|
60
|
+
- **Plain Ktav config**, created on first run, hot-reloaded. ccgp changes it only on your command (`--profile`,
|
|
61
|
+
`--connections`, `--peak`, `--models apply`, the interactive interface), and every change is validated with the
|
|
62
|
+
real loader and keeps a backup first ([details](docs/configuration.md)).
|
|
63
|
+
- **Windows first**, also Linux and macOS; Windows is tested in CI.
|
|
64
|
+
|
|
65
|
+
## Install
|
|
66
|
+
|
|
67
|
+
Linux and macOS:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
curl -fsSL https://raw.githubusercontent.com/PHPCraftdream/cc-go-proxy/main/install.sh | sh
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Windows (PowerShell):
|
|
74
|
+
|
|
75
|
+
```powershell
|
|
76
|
+
irm https://raw.githubusercontent.com/PHPCraftdream/cc-go-proxy/main/install.ps1 | iex
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The scripts download the archive of the latest [release](https://github.com/PHPCraftdream/cc-go-proxy/releases) for your
|
|
80
|
+
OS and CPU, check it against `SHA256SUMS` and install `ccgp` and `ccgpy` (Linux and macOS: `~/.local/bin`; Windows:
|
|
81
|
+
`%LOCALAPPDATA%\Programs\ccgp`, added to your user `PATH`). Set `CCGP_VERSION` to pick a version and
|
|
82
|
+
`CCGP_INSTALL_DIR` to pick the directory (Windows: `CCGP_NO_PATH=1` leaves `PATH` alone); the scripts are short, read
|
|
83
|
+
them first if you like:
|
|
84
|
+
[install.sh](install.sh), [install.ps1](install.ps1).
|
|
85
|
+
|
|
86
|
+
Platforms of the release archives: Linux (x86-64, arm64, 32-bit ARM from the Raspberry Pi 1 on, riscv64), macOS
|
|
87
|
+
(Intel, Apple silicon), Windows (x86-64, arm64) and FreeBSD (x86-64, arm64). The binaries are static and need no
|
|
88
|
+
libc, so the same Linux build runs on glibc and on musl systems (Alpine); CI runs it on Alpine, Debian 11 and
|
|
89
|
+
Ubuntu 20.04 and on arm64 and ARM. It carries a fallback set of root certificates, used only when the system has none
|
|
90
|
+
(minimal containers), so HTTPS works there too. The npm package covers the six most common platforms (Linux,
|
|
91
|
+
macOS and Windows on x86-64 and arm64); on the others use the archive or `install.sh`.
|
|
92
|
+
|
|
93
|
+
With npm (any platform, Node.js 18 or newer):
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
npm install -g @cc-go-proxy/ccgp
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The package [`@cc-go-proxy/ccgp`](https://www.npmjs.com/package/@cc-go-proxy/ccgp) (in the npm organization
|
|
100
|
+
[`cc-go-proxy`](https://www.npmjs.com/org/cc-go-proxy)) installs the same two commands, `ccgp` and `ccgpy`, from a prebuilt binary for your
|
|
101
|
+
platform (no install scripts run). Update it with npm, not with `ccgp --update`.
|
|
102
|
+
|
|
103
|
+
You also need Claude Code (`claude` on `PATH`). ccgp is one self-contained binary: the
|
|
104
|
+
[Ktav](https://github.com/ktav-lang/golang) config parser is pure Go, nothing is downloaded on first use.
|
|
105
|
+
|
|
106
|
+
## Quick start
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
ccgp codex
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
On the first run ccgp:
|
|
113
|
+
|
|
114
|
+
1. creates a default [`config.ktav`](internal/config/config.example.ktav) with `codex`, `codex_api` and `zai` profiles
|
|
115
|
+
(`%APPDATA%\cc-go-proxy\` on Windows, `~/Library/Application Support/cc-go-proxy/` on macOS,
|
|
116
|
+
`~/.config/cc-go-proxy/` elsewhere);
|
|
117
|
+
2. starts the proxy in the background (`127.0.0.1:60093`);
|
|
118
|
+
3. prints a sign-in link for Codex (the browser is never opened for you) or asks for an API key;
|
|
119
|
+
4. generates the profile's URL token;
|
|
120
|
+
5. runs `claude` with `ANTHROPIC_BASE_URL=http://127.0.0.1:60093/call/<token>`.
|
|
121
|
+
|
|
122
|
+
For z.ai: `ccgp --login zai` once (asks for your API key), then `ccgp zai`.
|
|
123
|
+
|
|
124
|
+
A second ChatGPT account: `ccgp --profile add codex2 --like codex`, then `ccgp codex2` (signs in on first start).
|
|
125
|
+
Details: [profiles](docs/configuration.md#creating-and-removing-profiles).
|
|
126
|
+
|
|
127
|
+
Several Claude accounts, each clean and separate (no proxy, nothing of your own login, ids or sessions copied):
|
|
128
|
+
`ccgp --profile add work --type claude`, then `ccgp work` and `/login` inside. Details:
|
|
129
|
+
[profiles of the real Claude Code](docs/configuration.md#profiles-of-the-real-claude-code---type-claude).
|
|
130
|
+
|
|
131
|
+
A Claude profile on the Claude Platform with an API key of its own, next to the others: `ccgp --profile add api --type
|
|
132
|
+
claude_api`, `ccgp --login api` (the key), then `ccgp api`. The server is the official one; another:
|
|
133
|
+
`--base-url https://…` or `ccgp --provider set api base_url https://…`. Details:
|
|
134
|
+
[profiles with an API key](docs/configuration.md#profiles-with-an-api-key---type-claude_api).
|
|
135
|
+
|
|
136
|
+
Bring a conversation along: `cd` into the project and `ccgp --import codex` (your Claude Code's latest sessions of this
|
|
137
|
+
directory into profile `codex`), then `ccgp codex -c`. A proxy profile that has none of this directory's sessions gets
|
|
138
|
+
the latest one by itself on its first start. Details: [sessions](docs/sessions.md).
|
|
139
|
+
|
|
140
|
+
A setup of its own that shares nothing with the default one: `ccgp --local --login codex` (everything in `./.ccgp`),
|
|
141
|
+
`ccgp --home ~/work/ccgp work`. Details: [own home](docs/cli.md#own-home-a-setup-that-shares-nothing).
|
|
142
|
+
|
|
143
|
+
Prefer menus to commands? `ccgp -i` opens a full-screen interface that lists, edits and adds profiles and providers
|
|
144
|
+
and edits their peak hours ([interactive mode](docs/cli.md#interactive-mode)).
|
|
145
|
+
|
|
146
|
+
Keep a provider's expensive hours free of work: `ccgp --peak zai set mon-fri 14:00-18:00` and
|
|
147
|
+
`ccgp --peak zai tz Asia/Shanghai`; in those hours its profiles answer with a notice instead of working, and
|
|
148
|
+
`ccgp --peak zai pause 2h` is the way past it. Details: [peak hours](docs/peak-hours.md).
|
|
149
|
+
|
|
150
|
+
Check everything: `ccgp --doctor`; look at the server: `ccgp --status`, `ccgp --logs -f`; where a model goes:
|
|
151
|
+
`ccgp --which codex claude-opus-4-1`.
|
|
152
|
+
|
|
153
|
+
Behind a proxy: `ccgp --connections proxy socks5://127.0.0.1:1080` (or `http://user:pass@host:3128`) for everything,
|
|
154
|
+
`ccgp --connections proxy http://corp:3128 provider codex` for all profiles of one provider (it replaces the global
|
|
155
|
+
one), `... profile work` for one profile (it replaces both), `proxy none profile home` to bypass them,
|
|
156
|
+
`ccgp --connections proxy off` to remove the global one. A change applies on the next request.
|
|
157
|
+
|
|
158
|
+
## Commands
|
|
159
|
+
|
|
160
|
+
Commands start with `--`; a word without dashes is always a profile (`ccgp status` would run a profile called
|
|
161
|
+
`status`). Per command: `ccgp --<command> --help`. Details: [CLI reference](docs/cli.md).
|
|
162
|
+
|
|
163
|
+
| Command | Purpose |
|
|
164
|
+
| --- | --- |
|
|
165
|
+
| `ccgp <profile> [claude args…]` | Ensure server and credentials, run `claude` through the profile |
|
|
166
|
+
| `ccgp --local` / `--home <dir>` `…` | First flags of any command or profile run: keep config, logins, tokens and log in `./.ccgp` or in `<dir>` instead of the default places; a `.ccgp` directory in the current directory is picked up by itself ([own home](docs/cli.md#own-home-a-setup-that-shares-nothing)) |
|
|
167
|
+
| `ccgp . [claude args…]` | Choose the profile from a list, then run it with the arguments; the last entry, `claude`, is your own Claude Code run as plain `claude` |
|
|
168
|
+
| `ccgpy <profile> [claude args…]` | Same as `ccgp <profile> --dangerously-skip-permissions …`: Claude Code without permission prompts, so use it only where that is acceptable. `ccgpy` alone is `ccgpy .` |
|
|
169
|
+
| `ccgp --login <provider> [--device]` | (Re)authenticate. Codex: browser OAuth, or `--device` for a device code. Others: API key |
|
|
170
|
+
| `ccgp --logout <provider> [--yes]` | Remove the stored login (OAuth tokens or API key) of a provider; the config is not touched |
|
|
171
|
+
| `ccgp --models [apply] [-v] [--json] [profile]` | Show, or write into the config, the newest models per Claude tier |
|
|
172
|
+
| `ccgp --which <profile> <model> [--json]` | Show where a Claude model name is routed in a profile, offline |
|
|
173
|
+
| `ccgp --send <from> <to> [count] [--fork] [--force]` | Copy the latest sessions (default 10) of the current directory between two profiles or `claude` (your own Claude Code). A session continued on both sides is skipped; `--fork` keeps both versions, `--force` replaces the destination (the old file is kept); together they write it afresh as a fork, replacing an earlier fork that went its own way |
|
|
174
|
+
| `ccgp --import <profile> [count] [--fork] [--force]` | Alias of `ccgp --send claude <profile>` |
|
|
175
|
+
| `ccgp --export <profile> [count] [--fork] [--force]` | Alias of `ccgp --send <profile> claude` |
|
|
176
|
+
| `ccgp --profile add\|list\|rm\|set\|unset` | Manage profiles (and their providers) in the config: new logins (`--like`), profiles on an existing login (`--provider`), new backends (`--type codex\|codex_api\|anthropic_compat`), profiles of the real Claude Code with their own account (`--type claude`) or API key (`--type claude_api`); `set` / `unset` change one setting of a profile (`default_model`, `context_window`, `compact_percent`, `provider`) |
|
|
177
|
+
| `ccgp --provider [NAME] [--json]` / `set\|unset NAME KEY [VALUE]` | Show the providers, or one in detail (base URL, key variable, login, proxy, peak hours, profiles); set or remove its `base_url` or `api_key_env` |
|
|
178
|
+
| `ccgp --start` / `--stop` / `--restart` | Manage the background server |
|
|
179
|
+
| `ccgp --status [--json]` | Show the server, paths and login state |
|
|
180
|
+
| `ccgp --logs [-f] [-n N]` | Show the tail of the background server log, `-f` follows it |
|
|
181
|
+
| `ccgp --doctor [--offline] [--json]` | Check `claude`, config, server, logins, backend reachability and permissions |
|
|
182
|
+
| `ccgp --serve [-d] [-s]` | Run the server in the foreground (`-d` dumps bodies, `-s` logs requests) |
|
|
183
|
+
| `ccgp --config reset` | Back up the config and write the default one |
|
|
184
|
+
| `ccgp --connections [active N] [total N] [proxy URL\|off [provider NAME \| profile NAME]] [--json]` | Show or set the connections kept to each backend (default 7 active, 10 total) and the SOCKS5 / HTTP proxy: global, with a different one or none per provider or per profile (the nearest level wins) |
|
|
185
|
+
| `ccgp --interactive` / `-i` | Full-screen interface that does everything the commands do: profiles, providers (settings, proxy, sign-in), peak hours, connections, models, sessions, the server; needs a terminal, only the flag starts it. The commands and the interface cover each other, and a test keeps it so ([interactive mode](docs/cli.md#interactive-mode)) |
|
|
186
|
+
| `ccgp --peak [provider [set\|add WINDOW...\|rm N...\|tz ZONE\|clear\|pause [LEN]\|resume]] [--json]` | Show or set the peak hours of a provider: in them its profiles' requests are refused with a notice in the chat (`mon-fri 14:00-18:00`, in the provider's zone); `pause` works anyway for a while ([peak hours](docs/peak-hours.md)) |
|
|
187
|
+
| `ccgp --update [--check]` | Update ccgp and ccgpy from the latest GitHub release (checksum verified) |
|
|
188
|
+
| `ccgp --completion bash\|zsh\|powershell` | Print a shell completion script |
|
|
189
|
+
| `ccgp --version` | Print the version |
|
|
190
|
+
|
|
191
|
+
## Model label metadata
|
|
192
|
+
|
|
193
|
+
`GET /call/<token>/model?requested=<model-id>` resolves a request alias with the same `MapModel` used for inference. The normal profile-token authentication and hot-reloaded profile configuration apply; no upstream inference or login request is made by this handler.
|
|
194
|
+
|
|
195
|
+
The response contains only `kind: "ccgp:model-route:v1"`, `requestedModel`, and `backendModel`, with `Cache-Control: no-store`. It reports the configured route, not the model ultimately selected behind an upstream alias. Clients must fall back to their original labels when the endpoint is unavailable. This also supports `ccgpy`, which uses the same launcher and proxy.
|
|
196
|
+
|
|
197
|
+
[cah (cc-arch-hands)](https://github.com/PHPCraftdream/cc-arch-hands) supports ccgp's model mappings: its status line,
|
|
198
|
+
chat stamp and context gauge show the model a request is really routed to (`gpt-6.1-sol`, `gpt-6.1-terra`,
|
|
199
|
+
`gpt-6.1-luna`, `gpt-6.1-astra`, `glm-5.3`, …) by ccgp's own mapping rules, not the Claude alias Claude Code sent.
|
|
200
|
+
|
|
201
|
+
## How ccgp differs from upstream
|
|
202
|
+
|
|
203
|
+
| | [claude-code-proxy](https://github.com/nielspeter/claude-code-proxy) (upstream) | ccgp |
|
|
204
|
+
| --- | --- | --- |
|
|
205
|
+
| Shape | A proxy you configure with env vars and point Claude Code at | A launcher + proxy: `ccgp <profile>` does the whole run |
|
|
206
|
+
| Backends | OpenAI-compatible Chat Completions (OpenRouter, OpenAI, Ollama) | Those, plus ChatGPT Codex via subscription OAuth (Responses API) and Anthropic-compatible endpoints (z.ai) |
|
|
207
|
+
| Routing and access | One backend (`OPENAI_BASE_URL`) per proxy | Several providers; named profiles, each with its own URL token and its own provider |
|
|
208
|
+
| Config | `.env` and environment | Ktav `providers[]` / `profiles[]`, per-rule model mapping, generated mappings (`ccgp --models`), hot reload |
|
|
209
|
+
| Context | — | Per-model context windows; compaction window set for the session's main model |
|
|
210
|
+
| Claude credentials | Not addressed | Never reach a ccgp session: isolated config directory per profile |
|
|
211
|
+
| Sessions | — | `ccgp --send` copies the current directory's latest sessions between profiles (and your own Claude Code via `--import` / `--export`) |
|
|
212
|
+
| Secrets | `.env` | Separate owner-only credentials directory; OAuth refresh tokens rotate safely |
|
|
213
|
+
| Platforms | Builds for macOS, Linux and Windows | Windows first (owner-only ACLs, detached background process, tested in CI), also Linux and macOS |
|
|
214
|
+
| Distribution | Source builds and release binaries | Binaries for 10 platforms with provenance attestations, install scripts, npm package |
|
|
215
|
+
|
|
216
|
+
The Anthropic ↔ OpenAI Chat Completions translation, streaming and adaptive per-model capability detection are
|
|
217
|
+
upstream's work, kept here for `codex_api`. Thank you, Niels Peter Strandberg and contributors.
|
|
218
|
+
|
|
219
|
+
## Documentation
|
|
220
|
+
|
|
221
|
+
| | |
|
|
222
|
+
| --- | --- |
|
|
223
|
+
| [CLI reference](docs/cli.md) | Every command with examples: running a profile, own home, server and log, `--json`, `--doctor`, `--update`, completion, environment variables, exit codes |
|
|
224
|
+
| [HTTP API](docs/api.md) | `/health` and `/call/<token>/…`: the endpoints, tokens, errors, `curl` examples |
|
|
225
|
+
| [Configuration](docs/configuration.md) | Config file, providers, profiles (`--profile add` / `rm`), model rules, context windows |
|
|
226
|
+
| [Providers](docs/providers.md) | Codex, API keys, z.ai, the real Claude Code: sign-in, model mapping, effort levels |
|
|
227
|
+
| [Peak hours](docs/peak-hours.md) | Refuse a provider's requests at set hours: windows, zones, what Claude Code shows, `ccgp --peak`, pause |
|
|
228
|
+
| [Sessions](docs/sessions.md) | `ccgp --send`, `--import` / `--export`, thinking blocks |
|
|
229
|
+
| [Security](docs/security.md) | Token URLs, secrets at rest, why official credentials never reach a session |
|
|
230
|
+
| [Architecture](docs/architecture.md) | Layout, request flow, invariants |
|
|
231
|
+
| [Releasing](docs/releasing.md) | How releases, npm (token and Trusted Publishing) and license checks work |
|
|
232
|
+
| [Changelog](CHANGELOG.md) | What changed |
|
|
233
|
+
|
|
234
|
+
## Terms and disclaimer
|
|
235
|
+
|
|
236
|
+
ccgp is an independent project, not affiliated with or endorsed by Anthropic, OpenAI or z.ai; product names belong to
|
|
237
|
+
their owners. The Codex sign-in uses the private backend of OpenAI's own clients, and using a ChatGPT subscription
|
|
238
|
+
through a third-party client is subject to OpenAI's terms and may stop working at any time. ccgp never reads, forwards
|
|
239
|
+
or stores a Claude subscription's credentials. You are responsible for complying with the terms of every service you
|
|
240
|
+
connect. The software is provided as is, without warranty (see the licenses).
|
|
241
|
+
|
|
242
|
+
## Development
|
|
243
|
+
|
|
244
|
+
```sh
|
|
245
|
+
make build # ./ccgp
|
|
246
|
+
go vet ./...
|
|
247
|
+
go test ./...
|
|
248
|
+
node --test "scripts/npm/*.test.mjs" # npm packaging
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
CI runs tests on Linux and Windows, golangci-lint, a license allowlist, a type-check of every release target, and the
|
|
252
|
+
static Linux binary on several distributions and CPUs.
|
|
253
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md).
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
Licensed under either of
|
|
258
|
+
|
|
259
|
+
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))
|
|
260
|
+
- MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
261
|
+
|
|
262
|
+
at your option. Parts derived from [nielspeter/claude-code-proxy](https://github.com/nielspeter/claude-code-proxy)
|
|
263
|
+
remain available under the MIT license with their copyright notice ([NOTICE](NOTICE)).
|
|
264
|
+
|
|
265
|
+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in ccgp by you, as defined
|
|
266
|
+
in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
|