cc2go 0.7.3__tar.gz
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.
- cc2go-0.7.3/LICENSE +21 -0
- cc2go-0.7.3/PKG-INFO +194 -0
- cc2go-0.7.3/README.md +162 -0
- cc2go-0.7.3/pyproject.toml +52 -0
- cc2go-0.7.3/setup.cfg +4 -0
- cc2go-0.7.3/src/cc2go.egg-info/PKG-INFO +194 -0
- cc2go-0.7.3/src/cc2go.egg-info/SOURCES.txt +14 -0
- cc2go-0.7.3/src/cc2go.egg-info/dependency_links.txt +1 -0
- cc2go-0.7.3/src/cc2go.egg-info/entry_points.txt +2 -0
- cc2go-0.7.3/src/cc2go.egg-info/requires.txt +6 -0
- cc2go-0.7.3/src/cc2go.egg-info/top_level.txt +5 -0
- cc2go-0.7.3/src/error_handler.py +150 -0
- cc2go-0.7.3/src/mcp_bypass.py +176 -0
- cc2go-0.7.3/src/router.py +1349 -0
- cc2go-0.7.3/src/streaming.py +184 -0
- cc2go-0.7.3/src/tray.py +209 -0
cc2go-0.7.3/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
cc2go-0.7.3/PKG-INFO
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cc2go
|
|
3
|
+
Version: 0.7.3
|
|
4
|
+
Summary: Claude Code to OpenCode Go adapter β route Anthropic format to OpenAI models
|
|
5
|
+
Author: lzg14
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/lzg14/cc2go
|
|
8
|
+
Project-URL: Source, https://github.com/lzg14/cc2go
|
|
9
|
+
Project-URL: BugTracker, https://github.com/lzg14/cc2go/issues
|
|
10
|
+
Keywords: claude-code,opencode,llm-proxy,ai-adapter,anthropic,openai
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Web Environment
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Internet :: Proxy Servers
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: fastapi
|
|
26
|
+
Requires-Dist: uvicorn
|
|
27
|
+
Requires-Dist: httpx
|
|
28
|
+
Requires-Dist: python-dotenv
|
|
29
|
+
Requires-Dist: pystray>=0.19.0
|
|
30
|
+
Requires-Dist: Pillow>=10.0.0
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# cc2go <small>v0.7.3</small>
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<b>Claude Code β OpenCode Go Adapter</b>
|
|
37
|
+
<br>
|
|
38
|
+
A lightweight proxy that lets Claude Code use any OpenAI-compatible model
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<img src="https://img.shields.io/badge/python-3.9%2B-blue" alt="Python">
|
|
43
|
+
<img src="https://img.shields.io/github/license/lzg14/cc2go" alt="License">
|
|
44
|
+
<img src="https://img.shields.io/github/v/release/lzg14/cc2go" alt="Release">
|
|
45
|
+
<img src="https://img.shields.io/github/stars/lzg14/cc2go" alt="Stars">
|
|
46
|
+
<img src="https://img.shields.io/github/actions/workflow/status/lzg14/cc2go/ci.yml?branch=master" alt="CI">
|
|
47
|
+
<img src="https://img.shields.io/pypi/v/cc2go" alt="PyPI">
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
<p align="center">
|
|
51
|
+
<img src="static/screenshot.png" alt="cc2go Web UI" width="800">
|
|
52
|
+
<br>
|
|
53
|
+
<em>Web admin page β switch models, add endpoints, view logs</em>
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- π **Protocol translation** β Converts Anthropic Messages API β OpenAI Chat Completions
|
|
59
|
+
- π **Web UI** β Built-in admin page at `http://localhost:4001`, click to switch models
|
|
60
|
+
- π― **Model switching** β Click to switch models, auto-syncs to Claude Code settings
|
|
61
|
+
- β **Custom models** β Add your own endpoints with independent API keys and URLs
|
|
62
|
+
- πΌοΈ **Image support** β Converts Anthropic image blocks to OpenAI image_url format
|
|
63
|
+
- β‘ **Streaming** β Real-time SSE streaming conversion (OpenAI β Anthropic format)
|
|
64
|
+
- π **Adaptive retry** β Error classification with exponential backoff, max 3 retries
|
|
65
|
+
- π **Log management** β Built-in log viewer with rotation (5MB per file, 3 backups)
|
|
66
|
+
- π₯οΈ **System tray** β Tray icon for opening admin page and quitting; auto-opens admin on start
|
|
67
|
+
- π° **Token saving** β Strips `<system-reminder>`, `[ζθθΏη¨]` reasoning, and `thinking` blocks before forwarding upstream
|
|
68
|
+
- πΎ **Config backup** β Auto-backup original Claude Code config on first model switch; one-click restore from admin UI
|
|
69
|
+
- π **Security** β Defaults to 127.0.0.1 (local-only), Bearer Token authentication on proxy endpoints
|
|
70
|
+
- π§ **Tool name sanitization** β Replaces special characters in tool names to prevent 400 errors
|
|
71
|
+
- π§Ή **Schema cleaning** β Recursively removes incompatible JSON Schema fields for broader model compatibility
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Getting Started (For Non-Technical Users)
|
|
76
|
+
|
|
77
|
+
### Step 1: Download
|
|
78
|
+
|
|
79
|
+
Download the latest release from [GitHub Releases](https://github.com/lzg14/cc2go/releases).
|
|
80
|
+
Extract the ZIP file to any folder (not Program Files).
|
|
81
|
+
|
|
82
|
+
### Step 2: Configure API Key
|
|
83
|
+
|
|
84
|
+
1. Open the extracted folder
|
|
85
|
+
2. Copy `.env.example` to `.env` (or create a new file named `.env`)
|
|
86
|
+
3. Open `.env` with a text editor (like Notepad) and add your OpenCode Go API key:
|
|
87
|
+
```
|
|
88
|
+
OPENCODE_API_KEY=your_api_key_here
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Step 3: Run
|
|
92
|
+
|
|
93
|
+
Double-click `start_bg.bat` in the folder.
|
|
94
|
+
|
|
95
|
+
A system tray icon will appear. The admin page will open automatically in your browser.
|
|
96
|
+
|
|
97
|
+
### Step 4: Open in Claude Code
|
|
98
|
+
|
|
99
|
+
In Claude Code's settings, configure:
|
|
100
|
+
|
|
101
|
+
| Setting | Value |
|
|
102
|
+
|---------|-------|
|
|
103
|
+
| Base URL | `http://localhost:4001` |
|
|
104
|
+
| API Key | `sk-cc2go-local` |
|
|
105
|
+
|
|
106
|
+
That's it! Use Claude Code as normal β select models from the web admin page at `http://localhost:4001`.
|
|
107
|
+
|
|
108
|
+
### How to Quit
|
|
109
|
+
|
|
110
|
+
Right-click the system tray icon β click "Exit".
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## For Developers
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pip install -r requirements.txt
|
|
118
|
+
cp .env.example .env # Edit .env with your API key
|
|
119
|
+
python src/router.py
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Scripts (Windows)
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
scripts\start_bg.bat # Background mode (system tray, no terminal)
|
|
126
|
+
scripts\stop.bat # Stop background process
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Docker
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
docker build -t cc2go .
|
|
135
|
+
docker run -d -p 4001:4001 --env-file .env cc2go
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Access at `http://localhost:4001`.
|
|
139
|
+
|
|
140
|
+
## Linux Service (systemd)
|
|
141
|
+
|
|
142
|
+
For permanent deployment on Linux:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Copy service file
|
|
146
|
+
sudo cp cc2go.service /etc/systemd/system/
|
|
147
|
+
sudo systemctl daemon-reload
|
|
148
|
+
sudo systemctl enable cc2go
|
|
149
|
+
sudo systemctl start cc2go
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Requires a `cc2go` user and `/opt/cc2go` installation directory.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## API Endpoints
|
|
157
|
+
|
|
158
|
+
| Endpoint | Method | Description |
|
|
159
|
+
|----------|--------|-------------|
|
|
160
|
+
| `/` | GET | Web admin UI |
|
|
161
|
+
| `/v1/messages` | POST | Claude format entry (Anthropic β OpenAI) |
|
|
162
|
+
| `/v1/chat/completions` | POST | OpenAI format passthrough |
|
|
163
|
+
| `/v1/models` | GET | List available models |
|
|
164
|
+
| `/health` | GET | Health check |
|
|
165
|
+
| `/api/config` | GET/PUT | Configuration management |
|
|
166
|
+
| `/api/custom-models` | GET/PUT | Custom model management |
|
|
167
|
+
| `/api/logs` | GET | Recent log entries |
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Custom Model Routing
|
|
172
|
+
|
|
173
|
+
| Endpoint | Behavior |
|
|
174
|
+
|----------|----------|
|
|
175
|
+
| `/v1/messages` | Anthropic format passthrough (no conversion, thinking blocks preserved) |
|
|
176
|
+
| `/v1/chat/completions` | OpenAI format conversion (tool_calls gets reasoning_content="" if missing) |
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Configuration
|
|
181
|
+
|
|
182
|
+
All configuration via Web UI (`http://localhost:4001`):
|
|
183
|
+
- **Connection** β OpenCode Go base URL and API key
|
|
184
|
+
- **Service** β Host, port, master key (auto-syncs to Claude Code)
|
|
185
|
+
- **Custom Models** β Add/edit/remove custom model endpoints
|
|
186
|
+
- **Logs** β View logs, set log level, toggle detailed logging
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT
|
|
193
|
+
|
|
194
|
+
> Technical details in [ARCHITECTURE.md](ARCHITECTURE.md)
|
cc2go-0.7.3/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# cc2go <small>v0.7.3</small>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<b>Claude Code β OpenCode Go Adapter</b>
|
|
5
|
+
<br>
|
|
6
|
+
A lightweight proxy that lets Claude Code use any OpenAI-compatible model
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="https://img.shields.io/badge/python-3.9%2B-blue" alt="Python">
|
|
11
|
+
<img src="https://img.shields.io/github/license/lzg14/cc2go" alt="License">
|
|
12
|
+
<img src="https://img.shields.io/github/v/release/lzg14/cc2go" alt="Release">
|
|
13
|
+
<img src="https://img.shields.io/github/stars/lzg14/cc2go" alt="Stars">
|
|
14
|
+
<img src="https://img.shields.io/github/actions/workflow/status/lzg14/cc2go/ci.yml?branch=master" alt="CI">
|
|
15
|
+
<img src="https://img.shields.io/pypi/v/cc2go" alt="PyPI">
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
<img src="static/screenshot.png" alt="cc2go Web UI" width="800">
|
|
20
|
+
<br>
|
|
21
|
+
<em>Web admin page β switch models, add endpoints, view logs</em>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- π **Protocol translation** β Converts Anthropic Messages API β OpenAI Chat Completions
|
|
27
|
+
- π **Web UI** β Built-in admin page at `http://localhost:4001`, click to switch models
|
|
28
|
+
- π― **Model switching** β Click to switch models, auto-syncs to Claude Code settings
|
|
29
|
+
- β **Custom models** β Add your own endpoints with independent API keys and URLs
|
|
30
|
+
- πΌοΈ **Image support** β Converts Anthropic image blocks to OpenAI image_url format
|
|
31
|
+
- β‘ **Streaming** β Real-time SSE streaming conversion (OpenAI β Anthropic format)
|
|
32
|
+
- π **Adaptive retry** β Error classification with exponential backoff, max 3 retries
|
|
33
|
+
- π **Log management** β Built-in log viewer with rotation (5MB per file, 3 backups)
|
|
34
|
+
- π₯οΈ **System tray** β Tray icon for opening admin page and quitting; auto-opens admin on start
|
|
35
|
+
- π° **Token saving** β Strips `<system-reminder>`, `[ζθθΏη¨]` reasoning, and `thinking` blocks before forwarding upstream
|
|
36
|
+
- πΎ **Config backup** β Auto-backup original Claude Code config on first model switch; one-click restore from admin UI
|
|
37
|
+
- π **Security** β Defaults to 127.0.0.1 (local-only), Bearer Token authentication on proxy endpoints
|
|
38
|
+
- π§ **Tool name sanitization** β Replaces special characters in tool names to prevent 400 errors
|
|
39
|
+
- π§Ή **Schema cleaning** β Recursively removes incompatible JSON Schema fields for broader model compatibility
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Getting Started (For Non-Technical Users)
|
|
44
|
+
|
|
45
|
+
### Step 1: Download
|
|
46
|
+
|
|
47
|
+
Download the latest release from [GitHub Releases](https://github.com/lzg14/cc2go/releases).
|
|
48
|
+
Extract the ZIP file to any folder (not Program Files).
|
|
49
|
+
|
|
50
|
+
### Step 2: Configure API Key
|
|
51
|
+
|
|
52
|
+
1. Open the extracted folder
|
|
53
|
+
2. Copy `.env.example` to `.env` (or create a new file named `.env`)
|
|
54
|
+
3. Open `.env` with a text editor (like Notepad) and add your OpenCode Go API key:
|
|
55
|
+
```
|
|
56
|
+
OPENCODE_API_KEY=your_api_key_here
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Step 3: Run
|
|
60
|
+
|
|
61
|
+
Double-click `start_bg.bat` in the folder.
|
|
62
|
+
|
|
63
|
+
A system tray icon will appear. The admin page will open automatically in your browser.
|
|
64
|
+
|
|
65
|
+
### Step 4: Open in Claude Code
|
|
66
|
+
|
|
67
|
+
In Claude Code's settings, configure:
|
|
68
|
+
|
|
69
|
+
| Setting | Value |
|
|
70
|
+
|---------|-------|
|
|
71
|
+
| Base URL | `http://localhost:4001` |
|
|
72
|
+
| API Key | `sk-cc2go-local` |
|
|
73
|
+
|
|
74
|
+
That's it! Use Claude Code as normal β select models from the web admin page at `http://localhost:4001`.
|
|
75
|
+
|
|
76
|
+
### How to Quit
|
|
77
|
+
|
|
78
|
+
Right-click the system tray icon β click "Exit".
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## For Developers
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install -r requirements.txt
|
|
86
|
+
cp .env.example .env # Edit .env with your API key
|
|
87
|
+
python src/router.py
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Scripts (Windows)
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
scripts\start_bg.bat # Background mode (system tray, no terminal)
|
|
94
|
+
scripts\stop.bat # Stop background process
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Docker
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
docker build -t cc2go .
|
|
103
|
+
docker run -d -p 4001:4001 --env-file .env cc2go
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Access at `http://localhost:4001`.
|
|
107
|
+
|
|
108
|
+
## Linux Service (systemd)
|
|
109
|
+
|
|
110
|
+
For permanent deployment on Linux:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Copy service file
|
|
114
|
+
sudo cp cc2go.service /etc/systemd/system/
|
|
115
|
+
sudo systemctl daemon-reload
|
|
116
|
+
sudo systemctl enable cc2go
|
|
117
|
+
sudo systemctl start cc2go
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Requires a `cc2go` user and `/opt/cc2go` installation directory.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## API Endpoints
|
|
125
|
+
|
|
126
|
+
| Endpoint | Method | Description |
|
|
127
|
+
|----------|--------|-------------|
|
|
128
|
+
| `/` | GET | Web admin UI |
|
|
129
|
+
| `/v1/messages` | POST | Claude format entry (Anthropic β OpenAI) |
|
|
130
|
+
| `/v1/chat/completions` | POST | OpenAI format passthrough |
|
|
131
|
+
| `/v1/models` | GET | List available models |
|
|
132
|
+
| `/health` | GET | Health check |
|
|
133
|
+
| `/api/config` | GET/PUT | Configuration management |
|
|
134
|
+
| `/api/custom-models` | GET/PUT | Custom model management |
|
|
135
|
+
| `/api/logs` | GET | Recent log entries |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Custom Model Routing
|
|
140
|
+
|
|
141
|
+
| Endpoint | Behavior |
|
|
142
|
+
|----------|----------|
|
|
143
|
+
| `/v1/messages` | Anthropic format passthrough (no conversion, thinking blocks preserved) |
|
|
144
|
+
| `/v1/chat/completions` | OpenAI format conversion (tool_calls gets reasoning_content="" if missing) |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Configuration
|
|
149
|
+
|
|
150
|
+
All configuration via Web UI (`http://localhost:4001`):
|
|
151
|
+
- **Connection** β OpenCode Go base URL and API key
|
|
152
|
+
- **Service** β Host, port, master key (auto-syncs to Claude Code)
|
|
153
|
+
- **Custom Models** β Add/edit/remove custom model endpoints
|
|
154
|
+
- **Logs** β View logs, set log level, toggle detailed logging
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT
|
|
161
|
+
|
|
162
|
+
> Technical details in [ARCHITECTURE.md](ARCHITECTURE.md)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cc2go"
|
|
7
|
+
version = "0.7.3"
|
|
8
|
+
description = "Claude Code to OpenCode Go adapter β route Anthropic format to OpenAI models"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
keywords = ["claude-code", "opencode", "llm-proxy", "ai-adapter", "anthropic", "openai"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "lzg14"},
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Environment :: Web Environment",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Topic :: Internet :: Proxy Servers",
|
|
27
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
28
|
+
]
|
|
29
|
+
dependencies = [
|
|
30
|
+
"fastapi",
|
|
31
|
+
"uvicorn",
|
|
32
|
+
"httpx",
|
|
33
|
+
"python-dotenv",
|
|
34
|
+
"pystray>=0.19.0",
|
|
35
|
+
"Pillow>=10.0.0",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/lzg14/cc2go"
|
|
40
|
+
Source = "https://github.com/lzg14/cc2go"
|
|
41
|
+
BugTracker = "https://github.com/lzg14/cc2go/issues"
|
|
42
|
+
|
|
43
|
+
[tool.setuptools]
|
|
44
|
+
package-dir = {"" = "src"}
|
|
45
|
+
py-modules = ["router", "tray", "streaming", "mcp_bypass", "error_handler"]
|
|
46
|
+
|
|
47
|
+
[project.scripts]
|
|
48
|
+
cc2go = "router:main"
|
|
49
|
+
|
|
50
|
+
[tool.ruff]
|
|
51
|
+
line-length = 120
|
|
52
|
+
target-version = "py39"
|
cc2go-0.7.3/setup.cfg
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cc2go
|
|
3
|
+
Version: 0.7.3
|
|
4
|
+
Summary: Claude Code to OpenCode Go adapter β route Anthropic format to OpenAI models
|
|
5
|
+
Author: lzg14
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/lzg14/cc2go
|
|
8
|
+
Project-URL: Source, https://github.com/lzg14/cc2go
|
|
9
|
+
Project-URL: BugTracker, https://github.com/lzg14/cc2go/issues
|
|
10
|
+
Keywords: claude-code,opencode,llm-proxy,ai-adapter,anthropic,openai
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Web Environment
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Internet :: Proxy Servers
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: fastapi
|
|
26
|
+
Requires-Dist: uvicorn
|
|
27
|
+
Requires-Dist: httpx
|
|
28
|
+
Requires-Dist: python-dotenv
|
|
29
|
+
Requires-Dist: pystray>=0.19.0
|
|
30
|
+
Requires-Dist: Pillow>=10.0.0
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# cc2go <small>v0.7.3</small>
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<b>Claude Code β OpenCode Go Adapter</b>
|
|
37
|
+
<br>
|
|
38
|
+
A lightweight proxy that lets Claude Code use any OpenAI-compatible model
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<img src="https://img.shields.io/badge/python-3.9%2B-blue" alt="Python">
|
|
43
|
+
<img src="https://img.shields.io/github/license/lzg14/cc2go" alt="License">
|
|
44
|
+
<img src="https://img.shields.io/github/v/release/lzg14/cc2go" alt="Release">
|
|
45
|
+
<img src="https://img.shields.io/github/stars/lzg14/cc2go" alt="Stars">
|
|
46
|
+
<img src="https://img.shields.io/github/actions/workflow/status/lzg14/cc2go/ci.yml?branch=master" alt="CI">
|
|
47
|
+
<img src="https://img.shields.io/pypi/v/cc2go" alt="PyPI">
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
<p align="center">
|
|
51
|
+
<img src="static/screenshot.png" alt="cc2go Web UI" width="800">
|
|
52
|
+
<br>
|
|
53
|
+
<em>Web admin page β switch models, add endpoints, view logs</em>
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- π **Protocol translation** β Converts Anthropic Messages API β OpenAI Chat Completions
|
|
59
|
+
- π **Web UI** β Built-in admin page at `http://localhost:4001`, click to switch models
|
|
60
|
+
- π― **Model switching** β Click to switch models, auto-syncs to Claude Code settings
|
|
61
|
+
- β **Custom models** β Add your own endpoints with independent API keys and URLs
|
|
62
|
+
- πΌοΈ **Image support** β Converts Anthropic image blocks to OpenAI image_url format
|
|
63
|
+
- β‘ **Streaming** β Real-time SSE streaming conversion (OpenAI β Anthropic format)
|
|
64
|
+
- π **Adaptive retry** β Error classification with exponential backoff, max 3 retries
|
|
65
|
+
- π **Log management** β Built-in log viewer with rotation (5MB per file, 3 backups)
|
|
66
|
+
- π₯οΈ **System tray** β Tray icon for opening admin page and quitting; auto-opens admin on start
|
|
67
|
+
- π° **Token saving** β Strips `<system-reminder>`, `[ζθθΏη¨]` reasoning, and `thinking` blocks before forwarding upstream
|
|
68
|
+
- πΎ **Config backup** β Auto-backup original Claude Code config on first model switch; one-click restore from admin UI
|
|
69
|
+
- π **Security** β Defaults to 127.0.0.1 (local-only), Bearer Token authentication on proxy endpoints
|
|
70
|
+
- π§ **Tool name sanitization** β Replaces special characters in tool names to prevent 400 errors
|
|
71
|
+
- π§Ή **Schema cleaning** β Recursively removes incompatible JSON Schema fields for broader model compatibility
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Getting Started (For Non-Technical Users)
|
|
76
|
+
|
|
77
|
+
### Step 1: Download
|
|
78
|
+
|
|
79
|
+
Download the latest release from [GitHub Releases](https://github.com/lzg14/cc2go/releases).
|
|
80
|
+
Extract the ZIP file to any folder (not Program Files).
|
|
81
|
+
|
|
82
|
+
### Step 2: Configure API Key
|
|
83
|
+
|
|
84
|
+
1. Open the extracted folder
|
|
85
|
+
2. Copy `.env.example` to `.env` (or create a new file named `.env`)
|
|
86
|
+
3. Open `.env` with a text editor (like Notepad) and add your OpenCode Go API key:
|
|
87
|
+
```
|
|
88
|
+
OPENCODE_API_KEY=your_api_key_here
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Step 3: Run
|
|
92
|
+
|
|
93
|
+
Double-click `start_bg.bat` in the folder.
|
|
94
|
+
|
|
95
|
+
A system tray icon will appear. The admin page will open automatically in your browser.
|
|
96
|
+
|
|
97
|
+
### Step 4: Open in Claude Code
|
|
98
|
+
|
|
99
|
+
In Claude Code's settings, configure:
|
|
100
|
+
|
|
101
|
+
| Setting | Value |
|
|
102
|
+
|---------|-------|
|
|
103
|
+
| Base URL | `http://localhost:4001` |
|
|
104
|
+
| API Key | `sk-cc2go-local` |
|
|
105
|
+
|
|
106
|
+
That's it! Use Claude Code as normal β select models from the web admin page at `http://localhost:4001`.
|
|
107
|
+
|
|
108
|
+
### How to Quit
|
|
109
|
+
|
|
110
|
+
Right-click the system tray icon β click "Exit".
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## For Developers
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pip install -r requirements.txt
|
|
118
|
+
cp .env.example .env # Edit .env with your API key
|
|
119
|
+
python src/router.py
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Scripts (Windows)
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
scripts\start_bg.bat # Background mode (system tray, no terminal)
|
|
126
|
+
scripts\stop.bat # Stop background process
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Docker
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
docker build -t cc2go .
|
|
135
|
+
docker run -d -p 4001:4001 --env-file .env cc2go
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Access at `http://localhost:4001`.
|
|
139
|
+
|
|
140
|
+
## Linux Service (systemd)
|
|
141
|
+
|
|
142
|
+
For permanent deployment on Linux:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Copy service file
|
|
146
|
+
sudo cp cc2go.service /etc/systemd/system/
|
|
147
|
+
sudo systemctl daemon-reload
|
|
148
|
+
sudo systemctl enable cc2go
|
|
149
|
+
sudo systemctl start cc2go
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Requires a `cc2go` user and `/opt/cc2go` installation directory.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## API Endpoints
|
|
157
|
+
|
|
158
|
+
| Endpoint | Method | Description |
|
|
159
|
+
|----------|--------|-------------|
|
|
160
|
+
| `/` | GET | Web admin UI |
|
|
161
|
+
| `/v1/messages` | POST | Claude format entry (Anthropic β OpenAI) |
|
|
162
|
+
| `/v1/chat/completions` | POST | OpenAI format passthrough |
|
|
163
|
+
| `/v1/models` | GET | List available models |
|
|
164
|
+
| `/health` | GET | Health check |
|
|
165
|
+
| `/api/config` | GET/PUT | Configuration management |
|
|
166
|
+
| `/api/custom-models` | GET/PUT | Custom model management |
|
|
167
|
+
| `/api/logs` | GET | Recent log entries |
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Custom Model Routing
|
|
172
|
+
|
|
173
|
+
| Endpoint | Behavior |
|
|
174
|
+
|----------|----------|
|
|
175
|
+
| `/v1/messages` | Anthropic format passthrough (no conversion, thinking blocks preserved) |
|
|
176
|
+
| `/v1/chat/completions` | OpenAI format conversion (tool_calls gets reasoning_content="" if missing) |
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Configuration
|
|
181
|
+
|
|
182
|
+
All configuration via Web UI (`http://localhost:4001`):
|
|
183
|
+
- **Connection** β OpenCode Go base URL and API key
|
|
184
|
+
- **Service** β Host, port, master key (auto-syncs to Claude Code)
|
|
185
|
+
- **Custom Models** β Add/edit/remove custom model endpoints
|
|
186
|
+
- **Logs** β View logs, set log level, toggle detailed logging
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT
|
|
193
|
+
|
|
194
|
+
> Technical details in [ARCHITECTURE.md](ARCHITECTURE.md)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/error_handler.py
|
|
5
|
+
src/mcp_bypass.py
|
|
6
|
+
src/router.py
|
|
7
|
+
src/streaming.py
|
|
8
|
+
src/tray.py
|
|
9
|
+
src/cc2go.egg-info/PKG-INFO
|
|
10
|
+
src/cc2go.egg-info/SOURCES.txt
|
|
11
|
+
src/cc2go.egg-info/dependency_links.txt
|
|
12
|
+
src/cc2go.egg-info/entry_points.txt
|
|
13
|
+
src/cc2go.egg-info/requires.txt
|
|
14
|
+
src/cc2go.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|