ai-cli-switch 1.0.0 → 1.0.1
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/README.en.md +260 -0
- package/README.hi.md +143 -0
- package/README.ko.md +143 -0
- package/README.md +170 -157
- package/README.zh.md +208 -0
- package/package.json +19 -2
package/README.en.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="assets/demo.png" alt="ai-cli-switch demo" width="720" />
|
|
4
|
+
|
|
5
|
+
<h1>⚡ ai-cli-switch</h1>
|
|
6
|
+
|
|
7
|
+
<p><strong>Configure all your AI CLI tools in one command</strong></p>
|
|
8
|
+
<p>Claude Code · Codex · Gemini CLI · OpenCode · OpenClaw — done in 30 seconds</p>
|
|
9
|
+
<p>Works with any Base URL: official APIs, relay services, or self-hosted proxies</p>
|
|
10
|
+
|
|
11
|
+
<br/>
|
|
12
|
+
|
|
13
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
14
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
15
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
16
|
+
[](https://nodejs.org)
|
|
17
|
+
[](LICENSE)
|
|
18
|
+
[](https://github.com/zxyyang/ai-cli-switch)
|
|
19
|
+
|
|
20
|
+
<br/>
|
|
21
|
+
|
|
22
|
+
**🌐 Language / 语言 / 언어 / भाषा**
|
|
23
|
+
|
|
24
|
+
[🇨🇳 中文](README.md) · [🇺🇸 English](README.en.md) · [🇰🇷 한국어](README.ko.md) · [🇮🇳 हिन्दी](README.hi.md)
|
|
25
|
+
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## ✨ Why ai-cli-switch?
|
|
31
|
+
|
|
32
|
+
Stop manually hunting for config file locations and formats. Stop re-configuring every tool when you switch API providers. Just run one command.
|
|
33
|
+
|
|
34
|
+
| Without ai-cli-switch | With ai-cli-switch |
|
|
35
|
+
|----------------------|-------------------|
|
|
36
|
+
| Google "where is Claude Code config file" | `npx ai-cli-switch` |
|
|
37
|
+
| Manually edit JSON / TOML / .env files | Interactive guided setup |
|
|
38
|
+
| Risk breaking existing config | Auto-backup before every write |
|
|
39
|
+
| Do it again for each tool | Configure all tools in one session |
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 🚀 Quick Start
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx ai-cli-switch
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> Zero install required. Requires Node.js >= 18.
|
|
50
|
+
|
|
51
|
+
Or install globally:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install -g ai-cli-switch
|
|
55
|
+
ai-cli-switch
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 🛠️ Supported Tools
|
|
61
|
+
|
|
62
|
+
<table>
|
|
63
|
+
<thead>
|
|
64
|
+
<tr>
|
|
65
|
+
<th>Tool</th>
|
|
66
|
+
<th>Description</th>
|
|
67
|
+
<th>Default Base URL</th>
|
|
68
|
+
<th>Config File</th>
|
|
69
|
+
</tr>
|
|
70
|
+
</thead>
|
|
71
|
+
<tbody>
|
|
72
|
+
<tr>
|
|
73
|
+
<td><b>Claude Code</b></td>
|
|
74
|
+
<td>Anthropic's official AI coding CLI</td>
|
|
75
|
+
<td><code>https://api.anthropic.com</code></td>
|
|
76
|
+
<td><code>~/.claude/settings.json</code></td>
|
|
77
|
+
</tr>
|
|
78
|
+
<tr>
|
|
79
|
+
<td><b>Codex</b></td>
|
|
80
|
+
<td>OpenAI's official CLI tool</td>
|
|
81
|
+
<td><code>https://api.openai.com/v1</code></td>
|
|
82
|
+
<td><code>~/.codex/auth.json</code></td>
|
|
83
|
+
</tr>
|
|
84
|
+
<tr>
|
|
85
|
+
<td><b>Gemini CLI</b></td>
|
|
86
|
+
<td>Google Gemini command-line tool</td>
|
|
87
|
+
<td><code>https://generativelanguage.googleapis.com</code></td>
|
|
88
|
+
<td><code>~/.gemini/.env</code></td>
|
|
89
|
+
</tr>
|
|
90
|
+
<tr>
|
|
91
|
+
<td><b>OpenCode</b></td>
|
|
92
|
+
<td>Open-source AI coding assistant (multi-model)</td>
|
|
93
|
+
<td>depends on model</td>
|
|
94
|
+
<td><code>~/.config/opencode/opencode.json</code></td>
|
|
95
|
+
</tr>
|
|
96
|
+
<tr>
|
|
97
|
+
<td><b>OpenClaw</b></td>
|
|
98
|
+
<td>Open-source AI coding assistant (multi-model)</td>
|
|
99
|
+
<td>depends on model</td>
|
|
100
|
+
<td><code>~/.openclaw/openclaw.json</code></td>
|
|
101
|
+
</tr>
|
|
102
|
+
</tbody>
|
|
103
|
+
</table>
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 🌐 Base URL Support
|
|
108
|
+
|
|
109
|
+
Works with any OpenAI-compatible or Anthropic-compatible endpoint:
|
|
110
|
+
|
|
111
|
+
| Scenario | Example Base URL |
|
|
112
|
+
|----------|-----------------|
|
|
113
|
+
| Anthropic official | `https://api.anthropic.com` |
|
|
114
|
+
| OpenAI official | `https://api.openai.com/v1` |
|
|
115
|
+
| Google Gemini official | `https://generativelanguage.googleapis.com` |
|
|
116
|
+
| 78code relay (Claude) | `https://www.78code.cc` |
|
|
117
|
+
| 78code relay (OpenAI) | `https://www.78code.cc/v1` |
|
|
118
|
+
| Local proxy | `http://127.0.0.1:8080` |
|
|
119
|
+
| Any OpenAI-compatible API | `https://your-api.example.com/v1` |
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 📋 How It Works
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
$ npx ai-cli-switch
|
|
127
|
+
|
|
128
|
+
1. [Optional] Configure network proxy
|
|
129
|
+
2. Auto-detect installed AI CLI tools
|
|
130
|
+
3. Select the tool to configure
|
|
131
|
+
4. Choose model provider (for OpenCode / OpenClaw)
|
|
132
|
+
5. Enter Base URL (edit the pre-filled default)
|
|
133
|
+
6. Enter API Key (masked input)
|
|
134
|
+
7. Test API connectivity
|
|
135
|
+
8. Write config file (auto-backup existing)
|
|
136
|
+
9. Self-check verification ✅
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 🔒 Security
|
|
142
|
+
|
|
143
|
+
- **API Key never logged** — masked during input, never written to logs
|
|
144
|
+
- **Atomic writes** — config failures can't corrupt existing files
|
|
145
|
+
- **Auto-backup** — original config backed up as `*.bak.{timestamp}` before every change
|
|
146
|
+
- **Deep merge** — only updates key-related fields, preserves all your existing settings
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## 📦 Config File Formats
|
|
151
|
+
|
|
152
|
+
<details>
|
|
153
|
+
<summary><b>Claude Code</b> — <code>~/.claude/settings.json</code></summary>
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"env": {
|
|
158
|
+
"ANTHROPIC_API_KEY": "sk-ant-...",
|
|
159
|
+
"ANTHROPIC_BASE_URL": "https://api.anthropic.com"
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
</details>
|
|
164
|
+
|
|
165
|
+
<details>
|
|
166
|
+
<summary><b>Codex</b> — <code>~/.codex/auth.json</code> + <code>config.toml</code></summary>
|
|
167
|
+
|
|
168
|
+
```json
|
|
169
|
+
{ "OPENAI_API_KEY": "sk-..." }
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
```toml
|
|
173
|
+
model_provider = "api-openai-com"
|
|
174
|
+
disable_response_storage = true
|
|
175
|
+
|
|
176
|
+
[model_providers.api-openai-com]
|
|
177
|
+
name = "api-openai-com"
|
|
178
|
+
base_url = "https://api.openai.com/v1"
|
|
179
|
+
wire_api = "responses"
|
|
180
|
+
requires_openai_auth = true
|
|
181
|
+
```
|
|
182
|
+
</details>
|
|
183
|
+
|
|
184
|
+
<details>
|
|
185
|
+
<summary><b>Gemini CLI</b> — <code>~/.gemini/.env</code></summary>
|
|
186
|
+
|
|
187
|
+
```env
|
|
188
|
+
GEMINI_API_KEY=AIza...
|
|
189
|
+
GOOGLE_GEMINI_BASE_URL=https://generativelanguage.googleapis.com
|
|
190
|
+
```
|
|
191
|
+
</details>
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 🧩 Fork for Your Own Service
|
|
196
|
+
|
|
197
|
+
Running an API relay or proxy service? Build your own branded version:
|
|
198
|
+
|
|
199
|
+
1. Fork this repo
|
|
200
|
+
2. Set your URL as default in `src/index.js` → `DEFAULT_BASE_URLS`
|
|
201
|
+
3. Update `name` and `bin` in `package.json`
|
|
202
|
+
4. Update the banner and completion screen branding
|
|
203
|
+
5. `npm publish`
|
|
204
|
+
|
|
205
|
+
Your users run `npx your-package` and get configured instantly. 🎉
|
|
206
|
+
|
|
207
|
+
**Example:** [78code-ai](https://github.com/zxyyang/78code) — a branded edition built for 78code.cc users
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## ❓ FAQ
|
|
212
|
+
|
|
213
|
+
<details>
|
|
214
|
+
<summary>No AI CLI tools detected?</summary>
|
|
215
|
+
|
|
216
|
+
Install at least one tool first:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npm install -g @anthropic-ai/claude-code # Claude Code
|
|
220
|
+
npm install -g @openai/codex # Codex
|
|
221
|
+
npm install -g @google/gemini-cli # Gemini CLI
|
|
222
|
+
```
|
|
223
|
+
</details>
|
|
224
|
+
|
|
225
|
+
<details>
|
|
226
|
+
<summary>API connection test failed?</summary>
|
|
227
|
+
|
|
228
|
+
- Ensure no trailing `/` in Base URL
|
|
229
|
+
- Verify API Key is correct and has credits
|
|
230
|
+
- Try setting a proxy at startup if you're behind a firewall
|
|
231
|
+
- You can still choose "write config anyway" after a failed test
|
|
232
|
+
</details>
|
|
233
|
+
|
|
234
|
+
<details>
|
|
235
|
+
<summary>How to verify the config was written?</summary>
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
cat ~/.claude/settings.json # Claude Code
|
|
239
|
+
cat ~/.gemini/.env # Gemini CLI
|
|
240
|
+
cat ~/.codex/auth.json # Codex
|
|
241
|
+
```
|
|
242
|
+
</details>
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 🤝 Contributing
|
|
247
|
+
|
|
248
|
+
PRs and issues are welcome! If this tool saves you time, please give it a ⭐ — it helps others find it.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
<div align="center">
|
|
253
|
+
|
|
254
|
+
**If this tool helped you, a ⭐ Star means the world!**
|
|
255
|
+
|
|
256
|
+
[](https://star-history.com/#zxyyang/ai-cli-switch&Date)
|
|
257
|
+
|
|
258
|
+
Made with ❤️ · [npm](https://www.npmjs.com/package/ai-cli-switch) · [Issues](https://github.com/zxyyang/ai-cli-switch/issues)
|
|
259
|
+
|
|
260
|
+
</div>
|
package/README.hi.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="assets/demo.png" alt="ai-cli-switch डेमो" width="720" />
|
|
4
|
+
|
|
5
|
+
<h1>⚡ ai-cli-switch</h1>
|
|
6
|
+
|
|
7
|
+
<p><strong>एक कमांड से सभी AI CLI टूल्स को कॉन्फ़िगर करें</strong></p>
|
|
8
|
+
<p>Claude Code · Codex · Gemini CLI · OpenCode · OpenClaw — 30 सेकंड में</p>
|
|
9
|
+
<p>किसी भी Base URL के साथ काम करता है — ऑफिशियल API, प्रॉक्सी, या सेल्फ-होस्टेड</p>
|
|
10
|
+
|
|
11
|
+
<br/>
|
|
12
|
+
|
|
13
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
14
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
15
|
+
[](https://nodejs.org)
|
|
16
|
+
[](LICENSE)
|
|
17
|
+
|
|
18
|
+
<br/>
|
|
19
|
+
|
|
20
|
+
**🌐 Language / 语言 / 언어 / भाषा**
|
|
21
|
+
|
|
22
|
+
[🇨🇳 中文](README.md) · [🇺🇸 English](README.en.md) · [🇰🇷 한국어](README.ko.md) · [🇮🇳 हिन्दी](README.hi.md)
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## ✨ ai-cli-switch क्यों?
|
|
29
|
+
|
|
30
|
+
- 😩 Claude Code, Codex, Gemini की config फाइल कहाँ है? हर बार Google करना पड़ता है?
|
|
31
|
+
- 🔑 API Key का format गलत होने से टूल काम नहीं करता?
|
|
32
|
+
- 🌏 API access के लिए proxy की जरूरत है लेकिन कॉन्फ़िगर कैसे करें?
|
|
33
|
+
|
|
34
|
+
**ai-cli-switch इन सभी समस्याओं को हल करता है।** Interactive guidance के साथ 30 सेकंड में setup।
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🚀 Quick Start
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx ai-cli-switch
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
> Install की जरूरत नहीं। बस Node.js >= 18 चाहिए।
|
|
45
|
+
|
|
46
|
+
Global install के लिए:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install -g ai-cli-switch
|
|
50
|
+
ai-cli-switch
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 🛠️ Supported Tools
|
|
56
|
+
|
|
57
|
+
| Tool | विवरण | Default Base URL | Config File |
|
|
58
|
+
|------|-------|-----------------|-------------|
|
|
59
|
+
| **Claude Code** | Anthropic का ऑफिशियल AI coding CLI | `https://api.anthropic.com` | `~/.claude/settings.json` |
|
|
60
|
+
| **Codex** | OpenAI का ऑफिशियल CLI | `https://api.openai.com/v1` | `~/.codex/auth.json` |
|
|
61
|
+
| **Gemini CLI** | Google Gemini terminal tool | `https://generativelanguage.googleapis.com` | `~/.gemini/.env` |
|
|
62
|
+
| **OpenCode** | Open-source AI coding assistant | model के अनुसार | `~/.config/opencode/opencode.json` |
|
|
63
|
+
| **OpenClaw** | Open-source AI coding assistant | model के अनुसार | `~/.openclaw/openclaw.json` |
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 🌐 Base URL Examples
|
|
68
|
+
|
|
69
|
+
| Scenario | Base URL |
|
|
70
|
+
|----------|----------|
|
|
71
|
+
| Anthropic Official | `https://api.anthropic.com` |
|
|
72
|
+
| OpenAI Official | `https://api.openai.com/v1` |
|
|
73
|
+
| Google Gemini Official | `https://generativelanguage.googleapis.com` |
|
|
74
|
+
| Local Proxy | `http://127.0.0.1:8080` |
|
|
75
|
+
| Custom API Server | `https://your-api.example.com/v1` |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 📋 Usage Flow
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
$ npx ai-cli-switch
|
|
83
|
+
|
|
84
|
+
1. [Optional] Network proxy सेट करें
|
|
85
|
+
2. Installed AI CLI tools auto-detect
|
|
86
|
+
3. Configure करने का tool चुनें
|
|
87
|
+
4. Model provider चुनें (OpenCode/OpenClaw के लिए)
|
|
88
|
+
5. Base URL दर्ज करें (default बदल सकते हैं)
|
|
89
|
+
6. API Key दर्ज करें (masked input)
|
|
90
|
+
7. API connection test
|
|
91
|
+
8. Config file लिखें (existing का auto-backup)
|
|
92
|
+
9. Self-check verification ✅
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 🔒 Security
|
|
98
|
+
|
|
99
|
+
- **API Key कभी log नहीं होता** — input masked, कोई log नहीं
|
|
100
|
+
- **Atomic writes** — failure पर existing config सुरक्षित रहती है
|
|
101
|
+
- **Auto-backup** — हर save से पहले `*.bak.{timestamp}` backup
|
|
102
|
+
- **Deep merge** — सिर्फ key fields update होते हैं, बाकी settings safe
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## ❓ FAQ
|
|
107
|
+
|
|
108
|
+
<details>
|
|
109
|
+
<summary>"कोई AI CLI tool नहीं मिला" error?</summary>
|
|
110
|
+
|
|
111
|
+
पहले tool install करें:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm install -g @anthropic-ai/claude-code
|
|
115
|
+
npm install -g @openai/codex
|
|
116
|
+
npm install -g @google/gemini-cli
|
|
117
|
+
```
|
|
118
|
+
</details>
|
|
119
|
+
|
|
120
|
+
<details>
|
|
121
|
+
<summary>API connection test fail हो रहा है?</summary>
|
|
122
|
+
|
|
123
|
+
- Base URL के अंत में `/` न हो
|
|
124
|
+
- API Key सही और valid हो
|
|
125
|
+
- Firewall के पीछे हैं तो proxy set करें
|
|
126
|
+
- Test fail के बाद भी "config save करें" option मिलेगा
|
|
127
|
+
</details>
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 🤝 Contributing
|
|
132
|
+
|
|
133
|
+
PRs और Issues का स्वागत है! अगर helpful लगा तो ⭐ Star जरूर दें।
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
<div align="center">
|
|
138
|
+
|
|
139
|
+
**अगर यह tool काम आया तो ⭐ Star से support करें!**
|
|
140
|
+
|
|
141
|
+
Made with ❤️ · [npm](https://www.npmjs.com/package/ai-cli-switch) · [Issues](https://github.com/zxyyang/ai-cli-switch/issues)
|
|
142
|
+
|
|
143
|
+
</div>
|
package/README.ko.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="assets/demo.png" alt="ai-cli-switch 데모" width="720" />
|
|
4
|
+
|
|
5
|
+
<h1>⚡ ai-cli-switch</h1>
|
|
6
|
+
|
|
7
|
+
<p><strong>모든 AI CLI 도구를 한 번에 설정하세요</strong></p>
|
|
8
|
+
<p>Claude Code · Codex · Gemini CLI · OpenCode · OpenClaw — 30초면 완료</p>
|
|
9
|
+
<p>공식 API, 릴레이 서비스, 자체 프록시 — 모든 Base URL 지원</p>
|
|
10
|
+
|
|
11
|
+
<br/>
|
|
12
|
+
|
|
13
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
14
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
15
|
+
[](https://nodejs.org)
|
|
16
|
+
[](LICENSE)
|
|
17
|
+
|
|
18
|
+
<br/>
|
|
19
|
+
|
|
20
|
+
**🌐 Language / 语言 / 언어 / भाषा**
|
|
21
|
+
|
|
22
|
+
[🇨🇳 中文](README.md) · [🇺🇸 English](README.en.md) · [🇰🇷 한국어](README.ko.md) · [🇮🇳 हिन्दी](README.hi.md)
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## ✨ 왜 ai-cli-switch인가?
|
|
29
|
+
|
|
30
|
+
- 😩 Claude Code, Codex, Gemini 설정 파일 위치를 매번 검색하시나요?
|
|
31
|
+
- 🔑 API 키를 입력했는데 형식이 틀려서 동작이 안 되나요?
|
|
32
|
+
- 🌏 해외 API에 접근하기 위해 프록시를 사용해야 하나요?
|
|
33
|
+
|
|
34
|
+
**ai-cli-switch로 이 모든 문제를 해결하세요.** 대화형 안내로 30초 만에 설정 완료.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🚀 빠른 시작
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx ai-cli-switch
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
> 설치 불필요. Node.js >= 18만 있으면 됩니다.
|
|
45
|
+
|
|
46
|
+
전역 설치:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install -g ai-cli-switch
|
|
50
|
+
ai-cli-switch
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 🛠️ 지원 도구
|
|
56
|
+
|
|
57
|
+
| 도구 | 설명 | 기본 Base URL | 설정 파일 |
|
|
58
|
+
|------|------|---------------|-----------|
|
|
59
|
+
| **Claude Code** | Anthropic 공식 AI 코딩 CLI | `https://api.anthropic.com` | `~/.claude/settings.json` |
|
|
60
|
+
| **Codex** | OpenAI 공식 CLI | `https://api.openai.com/v1` | `~/.codex/auth.json` |
|
|
61
|
+
| **Gemini CLI** | Google Gemini 터미널 도구 | `https://generativelanguage.googleapis.com` | `~/.gemini/.env` |
|
|
62
|
+
| **OpenCode** | 오픈소스 AI 코딩 어시스턴트 | 모델에 따라 다름 | `~/.config/opencode/opencode.json` |
|
|
63
|
+
| **OpenClaw** | 오픈소스 AI 코딩 어시스턴트 | 모델에 따라 다름 | `~/.openclaw/openclaw.json` |
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 🌐 Base URL 예시
|
|
68
|
+
|
|
69
|
+
| 시나리오 | Base URL 예시 |
|
|
70
|
+
|----------|---------------|
|
|
71
|
+
| Anthropic 공식 | `https://api.anthropic.com` |
|
|
72
|
+
| OpenAI 공식 | `https://api.openai.com/v1` |
|
|
73
|
+
| Google Gemini 공식 | `https://generativelanguage.googleapis.com` |
|
|
74
|
+
| 로컬 프록시 | `http://127.0.0.1:8080` |
|
|
75
|
+
| 커스텀 API 서버 | `https://your-api.example.com/v1` |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 📋 사용 흐름
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
$ npx ai-cli-switch
|
|
83
|
+
|
|
84
|
+
1. [선택] 네트워크 프록시 설정
|
|
85
|
+
2. 설치된 AI CLI 도구 자동 감지
|
|
86
|
+
3. 설정할 도구 선택
|
|
87
|
+
4. 모델 제공자 선택 (OpenCode/OpenClaw용)
|
|
88
|
+
5. Base URL 입력 (기본값 수정 가능)
|
|
89
|
+
6. API Key 입력 (마스킹 처리)
|
|
90
|
+
7. API 연결 테스트 자동 실행
|
|
91
|
+
8. 설정 파일 저장 (기존 파일 자동 백업)
|
|
92
|
+
9. 자체 검증 ✅
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 🔒 보안
|
|
98
|
+
|
|
99
|
+
- **API Key 비노출** — 입력 시 완전히 마스킹, 로그 기록 없음
|
|
100
|
+
- **원자 쓰기** — 실패 시 기존 설정 파일 손상 없음
|
|
101
|
+
- **자동 백업** — 매 저장 전 `*.bak.{timestamp}` 형식으로 백업
|
|
102
|
+
- **딥 머지** — 기존 설정을 유지하고 키 관련 필드만 업데이트
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## ❓ 자주 묻는 질문
|
|
107
|
+
|
|
108
|
+
<details>
|
|
109
|
+
<summary>"설치된 AI CLI 도구가 없습니다" 오류</summary>
|
|
110
|
+
|
|
111
|
+
도구를 먼저 설치하세요:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm install -g @anthropic-ai/claude-code
|
|
115
|
+
npm install -g @openai/codex
|
|
116
|
+
npm install -g @google/gemini-cli
|
|
117
|
+
```
|
|
118
|
+
</details>
|
|
119
|
+
|
|
120
|
+
<details>
|
|
121
|
+
<summary>API 연결 테스트 실패 시</summary>
|
|
122
|
+
|
|
123
|
+
- Base URL 끝에 `/` 없는지 확인
|
|
124
|
+
- API Key 유효성 및 잔액 확인
|
|
125
|
+
- 방화벽 환경이라면 프록시 설정 필요
|
|
126
|
+
- 테스트 실패 후에도 "설정 저장" 선택 가능
|
|
127
|
+
</details>
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 🤝 기여하기
|
|
132
|
+
|
|
133
|
+
PR과 Issue 환영합니다! 유용하셨다면 ⭐ Star를 눌러주세요.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
<div align="center">
|
|
138
|
+
|
|
139
|
+
**유용하게 사용하셨다면 ⭐ Star로 응원해주세요!**
|
|
140
|
+
|
|
141
|
+
Made with ❤️ · [npm](https://www.npmjs.com/package/ai-cli-switch) · [Issues](https://github.com/zxyyang/ai-cli-switch/issues)
|
|
142
|
+
|
|
143
|
+
</div>
|
package/README.md
CHANGED
|
@@ -1,194 +1,215 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
> Supports any Base URL: official APIs, self-hosted proxies, or third-party relay services.
|
|
3
|
+
<img src="assets/demo.png" alt="ai-cli-switch demo" width="720" />
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
8
|
-
[](https://nodejs.org)
|
|
9
|
-
[](LICENSE)
|
|
5
|
+
<h1>⚡ ai-cli-switch</h1>
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
<p><strong>一条命令,完成所有 AI CLI 工具的 API 配置</strong></p>
|
|
8
|
+
<p>Configure Claude Code · Codex · Gemini CLI · OpenCode · OpenClaw in seconds</p>
|
|
9
|
+
<p>支持任意 Base URL — 官方 API / 中转服务 / 自建代理</p>
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
$ npx ai-cli-switch
|
|
11
|
+
<br/>
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/
|
|
23
|
-
/
|
|
24
|
-
/____/
|
|
13
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
14
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
15
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
16
|
+
[](https://nodejs.org)
|
|
17
|
+
[](LICENSE)
|
|
18
|
+
[](https://github.com/zxyyang/ai-cli-switch)
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
快速配置 Claude Code / Codex / Gemini / OpenCode / OpenClaw
|
|
28
|
-
支持自定义 Base URL,兼容任意 API 中转服务
|
|
29
|
-
─────────────────────────────────────────
|
|
20
|
+
<br/>
|
|
30
21
|
|
|
31
|
-
|
|
32
|
-
⠋ 正在检测环境...
|
|
33
|
-
✔ 环境检测完成
|
|
22
|
+
**🌐 语言 / Language / 언어 / भाषा**
|
|
34
23
|
|
|
35
|
-
|
|
36
|
-
Node.js v22.0.0
|
|
37
|
-
Shell /bin/zsh
|
|
38
|
-
用户目录 /Users/yourname
|
|
24
|
+
[🇨🇳 中文](README.md) · [🇺🇸 English](README.en.md) · [🇰🇷 한국어](README.ko.md) · [🇮🇳 हिन्दी](README.hi.md)
|
|
39
25
|
|
|
40
|
-
|
|
26
|
+
</div>
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
● Gemini CLI
|
|
44
|
-
|
|
45
|
-
? 选择要配置的工具 Claude Code
|
|
46
|
-
? Base URL(留空使用官方地址,或填入你的中转地址)
|
|
47
|
-
https://api.anthropic.com ← 默认官方,直接改成中转地址即可
|
|
28
|
+
---
|
|
48
29
|
|
|
49
|
-
|
|
30
|
+
## ✨ 为什么选择 ai-cli-switch?
|
|
50
31
|
|
|
51
|
-
|
|
52
|
-
✔ API 连接测试通过
|
|
53
|
-
✔ 配置写入成功
|
|
54
|
-
配置文件: /Users/yourname/.claude/settings.json
|
|
55
|
-
备份文件: /Users/yourname/.claude/settings.json.bak.1709123456789
|
|
56
|
-
✔ 自检通过,一切正常
|
|
57
|
-
└ 完成
|
|
32
|
+
你是否遇到过这些问题?
|
|
58
33
|
|
|
59
|
-
|
|
34
|
+
- 🤔 Claude Code / Codex / Gemini 配置文件在哪?格式是什么?
|
|
35
|
+
- 😩 每次换 API 中转都要手动改多个配置文件
|
|
36
|
+
- 🔑 API Key 配置错了格式导致工具无法使用
|
|
37
|
+
- 🌏 国内访问需要中转,不知道怎么配置 Base URL
|
|
60
38
|
|
|
61
|
-
|
|
39
|
+
**ai-cli-switch 解决这一切。** 交互式引导,30 秒完成配置,支持所有主流 AI CLI 工具。
|
|
62
40
|
|
|
63
|
-
|
|
41
|
+
---
|
|
64
42
|
|
|
65
|
-
|
|
43
|
+
## 🚀 快速开始
|
|
66
44
|
|
|
67
|
-
|
|
45
|
+
```bash
|
|
46
|
+
npx ai-cli-switch
|
|
68
47
|
```
|
|
69
48
|
|
|
70
|
-
|
|
49
|
+
> 无需安装,一行命令即可运行。Node.js >= 18 即可。
|
|
71
50
|
|
|
72
|
-
|
|
51
|
+
或全局安装后使用:
|
|
73
52
|
|
|
74
|
-
|
|
53
|
+
```bash
|
|
54
|
+
npm install -g ai-cli-switch
|
|
55
|
+
ai-cli-switch
|
|
56
|
+
```
|
|
75
57
|
|
|
76
|
-
|
|
77
|
-
- **第三方中转服务** — 如 78code.cc、openrouter 等
|
|
78
|
-
- **自建 API 代理** — 本地或云端任意地址
|
|
58
|
+
---
|
|
79
59
|
|
|
80
|
-
|
|
60
|
+
## 🛠️ 支持的工具
|
|
61
|
+
|
|
62
|
+
<table>
|
|
63
|
+
<thead>
|
|
64
|
+
<tr>
|
|
65
|
+
<th>工具</th>
|
|
66
|
+
<th>说明</th>
|
|
67
|
+
<th>默认 Base URL</th>
|
|
68
|
+
<th>配置文件</th>
|
|
69
|
+
</tr>
|
|
70
|
+
</thead>
|
|
71
|
+
<tbody>
|
|
72
|
+
<tr>
|
|
73
|
+
<td><b>Claude Code</b></td>
|
|
74
|
+
<td>Anthropic 官方 AI 编程助手</td>
|
|
75
|
+
<td><code>https://api.anthropic.com</code></td>
|
|
76
|
+
<td><code>~/.claude/settings.json</code></td>
|
|
77
|
+
</tr>
|
|
78
|
+
<tr>
|
|
79
|
+
<td><b>Codex</b></td>
|
|
80
|
+
<td>OpenAI 官方 CLI 工具</td>
|
|
81
|
+
<td><code>https://api.openai.com/v1</code></td>
|
|
82
|
+
<td><code>~/.codex/auth.json</code></td>
|
|
83
|
+
</tr>
|
|
84
|
+
<tr>
|
|
85
|
+
<td><b>Gemini CLI</b></td>
|
|
86
|
+
<td>Google Gemini 命令行工具</td>
|
|
87
|
+
<td><code>https://generativelanguage.googleapis.com</code></td>
|
|
88
|
+
<td><code>~/.gemini/.env</code></td>
|
|
89
|
+
</tr>
|
|
90
|
+
<tr>
|
|
91
|
+
<td><b>OpenCode</b></td>
|
|
92
|
+
<td>开源 AI 编程助手(多模型)</td>
|
|
93
|
+
<td>视模型而定</td>
|
|
94
|
+
<td><code>~/.config/opencode/opencode.json</code></td>
|
|
95
|
+
</tr>
|
|
96
|
+
<tr>
|
|
97
|
+
<td><b>OpenClaw</b></td>
|
|
98
|
+
<td>开源 AI 编程助手(多模型)</td>
|
|
99
|
+
<td>视模型而定</td>
|
|
100
|
+
<td><code>~/.openclaw/openclaw.json</code></td>
|
|
101
|
+
</tr>
|
|
102
|
+
</tbody>
|
|
103
|
+
</table>
|
|
81
104
|
|
|
82
105
|
---
|
|
83
106
|
|
|
84
|
-
##
|
|
107
|
+
## 🌐 支持的 Base URL 类型
|
|
85
108
|
|
|
86
|
-
|
|
|
87
|
-
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
| **
|
|
92
|
-
| **
|
|
109
|
+
| 场景 | Base URL 示例 |
|
|
110
|
+
|------|---------------|
|
|
111
|
+
| Anthropic 官方 API | `https://api.anthropic.com` |
|
|
112
|
+
| OpenAI 官方 API | `https://api.openai.com/v1` |
|
|
113
|
+
| Google Gemini 官方 | `https://generativelanguage.googleapis.com` |
|
|
114
|
+
| **78code 中转(Claude)** | `https://www.78code.cc` |
|
|
115
|
+
| **78code 中转(OpenAI)** | `https://www.78code.cc/v1` |
|
|
116
|
+
| 自建本地代理 | `http://127.0.0.1:8080` |
|
|
117
|
+
| 任意 OpenAI 兼容接口 | `https://your-api.example.com/v1` |
|
|
93
118
|
|
|
94
119
|
---
|
|
95
120
|
|
|
96
|
-
##
|
|
97
|
-
|
|
98
|
-
### 无需安装,直接运行
|
|
121
|
+
## 📋 使用流程
|
|
99
122
|
|
|
100
|
-
```bash
|
|
101
|
-
npx ai-cli-switch
|
|
102
123
|
```
|
|
124
|
+
$ npx ai-cli-switch
|
|
103
125
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
126
|
+
1. [可选] 设置网络代理(支持 HTTP/HTTPS 代理)
|
|
127
|
+
2. 自动检测已安装的 AI CLI 工具
|
|
128
|
+
3. 选择要配置的工具
|
|
129
|
+
4. 选择模型类型(OpenCode/OpenClaw 需要)
|
|
130
|
+
5. 输入 Base URL(可修改默认值)
|
|
131
|
+
6. 输入 API Key(密码模式,字符不显示)
|
|
132
|
+
7. 自动测试 API 连通性
|
|
133
|
+
8. 写入配置文件(自动备份原文件)
|
|
134
|
+
9. 自检验证 ✅
|
|
109
135
|
```
|
|
110
136
|
|
|
111
137
|
---
|
|
112
138
|
|
|
113
|
-
##
|
|
139
|
+
## 🔒 安全设计
|
|
114
140
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
| Gemini 官方 | `https://generativelanguage.googleapis.com` |
|
|
120
|
-
| 78code 中转(Claude) | `https://www.78code.cc` |
|
|
121
|
-
| 78code 中转(OpenAI) | `https://www.78code.cc/v1` |
|
|
122
|
-
| 自建代理(本地) | `http://127.0.0.1:8080` |
|
|
123
|
-
| 云端代理 | `https://your-proxy.example.com` |
|
|
141
|
+
- **API Key 不落盘**:输入时完全遮蔽,不写入日志
|
|
142
|
+
- **原子写入**:配置写入失败不会破坏原有配置
|
|
143
|
+
- **自动备份**:每次写入前备份原文件,格式 `*.bak.{timestamp}`
|
|
144
|
+
- **只改密钥字段**:深度合并配置,不会删除你其他的自定义配置
|
|
124
145
|
|
|
125
146
|
---
|
|
126
147
|
|
|
127
|
-
##
|
|
148
|
+
## 📦 配置文件格式
|
|
128
149
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
写入 `~/.claude/settings.json`:
|
|
150
|
+
<details>
|
|
151
|
+
<summary><b>Claude Code</b> — <code>~/.claude/settings.json</code></summary>
|
|
132
152
|
|
|
133
153
|
```json
|
|
134
154
|
{
|
|
135
155
|
"env": {
|
|
136
|
-
"ANTHROPIC_API_KEY": "
|
|
137
|
-
"ANTHROPIC_BASE_URL": "
|
|
156
|
+
"ANTHROPIC_API_KEY": "sk-ant-...",
|
|
157
|
+
"ANTHROPIC_BASE_URL": "https://api.anthropic.com"
|
|
138
158
|
}
|
|
139
159
|
}
|
|
140
160
|
```
|
|
161
|
+
</details>
|
|
141
162
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
- `~/.codex/auth.json` → `{ "OPENAI_API_KEY": "..." }`
|
|
145
|
-
- `~/.codex/config.toml` → 添加自定义 provider 段落(provider ID 根据 Base URL hostname 自动生成)
|
|
163
|
+
<details>
|
|
164
|
+
<summary><b>Codex</b> — <code>~/.codex/auth.json</code> + <code>config.toml</code></summary>
|
|
146
165
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
写入 `~/.gemini/.env`:
|
|
150
|
-
|
|
151
|
-
```
|
|
152
|
-
GEMINI_API_KEY=<your-api-key>
|
|
153
|
-
GOOGLE_GEMINI_BASE_URL=<your-base-url>
|
|
166
|
+
```json
|
|
167
|
+
{ "OPENAI_API_KEY": "sk-..." }
|
|
154
168
|
```
|
|
155
169
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
### OpenClaw
|
|
161
|
-
|
|
162
|
-
写入 `~/.openclaw/openclaw.json`,格式同 OpenCode。
|
|
163
|
-
|
|
164
|
-
---
|
|
170
|
+
```toml
|
|
171
|
+
model_provider = "api-openai-com"
|
|
172
|
+
disable_response_storage = true
|
|
165
173
|
|
|
166
|
-
|
|
174
|
+
[model_providers.api-openai-com]
|
|
175
|
+
name = "api-openai-com"
|
|
176
|
+
base_url = "https://api.openai.com/v1"
|
|
177
|
+
wire_api = "responses"
|
|
178
|
+
requires_openai_auth = true
|
|
179
|
+
```
|
|
180
|
+
</details>
|
|
167
181
|
|
|
168
|
-
|
|
182
|
+
<details>
|
|
183
|
+
<summary><b>Gemini CLI</b> — <code>~/.gemini/.env</code></summary>
|
|
169
184
|
|
|
185
|
+
```env
|
|
186
|
+
GEMINI_API_KEY=AIza...
|
|
187
|
+
GOOGLE_GEMINI_BASE_URL=https://generativelanguage.googleapis.com
|
|
170
188
|
```
|
|
171
|
-
|
|
172
|
-
```
|
|
189
|
+
</details>
|
|
173
190
|
|
|
174
191
|
---
|
|
175
192
|
|
|
176
|
-
##
|
|
193
|
+
## 🧩 Fork 为你自己的专属版
|
|
177
194
|
|
|
178
|
-
|
|
179
|
-
- 至少安装了一个上述 AI CLI 工具
|
|
195
|
+
运营 API 中转服务?可以基于本工具快速定制:
|
|
180
196
|
|
|
181
|
-
|
|
197
|
+
1. Fork 本仓库
|
|
198
|
+
2. 修改 `src/index.js` 中的 `DEFAULT_BASE_URLS` 为你的服务地址
|
|
199
|
+
3. 修改 `package.json` 的 `name` 和 `bin`
|
|
200
|
+
4. 更新 Banner 和完成页面的品牌信息
|
|
201
|
+
5. `npm publish` 发布
|
|
182
202
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
203
|
+
用户只需 `npx 你的包名` 即可一键配置你的服务 🎉
|
|
204
|
+
|
|
205
|
+
**示例:** [78code-ai](https://github.com/zxyyang/78code) — 基于本工具为 78code.cc 定制的专属版本
|
|
186
206
|
|
|
187
207
|
---
|
|
188
208
|
|
|
189
|
-
## 常见问题
|
|
209
|
+
## ❓ 常见问题
|
|
190
210
|
|
|
191
|
-
|
|
211
|
+
<details>
|
|
212
|
+
<summary>提示"未检测到任何已安装的 AI CLI 工具"</summary>
|
|
192
213
|
|
|
193
214
|
请先安装对应工具:
|
|
194
215
|
|
|
@@ -197,54 +218,46 @@ npm install -g @anthropic-ai/claude-code # Claude Code
|
|
|
197
218
|
npm install -g @openai/codex # Codex
|
|
198
219
|
npm install -g @google/gemini-cli # Gemini CLI
|
|
199
220
|
```
|
|
221
|
+
</details>
|
|
200
222
|
|
|
201
|
-
|
|
223
|
+
<details>
|
|
224
|
+
<summary>API 连接测试失败怎么办?</summary>
|
|
202
225
|
|
|
203
|
-
- 检查 Base URL
|
|
204
|
-
-
|
|
205
|
-
-
|
|
226
|
+
- 检查 Base URL 末尾不要有 `/`
|
|
227
|
+
- 确认 API Key 正确且有余额
|
|
228
|
+
- 国内网络请在启动时配置代理(工具会提示)
|
|
229
|
+
- 测试失败后仍可选择"继续写入配置"
|
|
230
|
+
</details>
|
|
206
231
|
|
|
207
|
-
|
|
232
|
+
<details>
|
|
233
|
+
<summary>如何验证配置是否生效?</summary>
|
|
208
234
|
|
|
209
235
|
```bash
|
|
236
|
+
# Claude Code
|
|
210
237
|
cat ~/.claude/settings.json
|
|
211
|
-
```
|
|
212
238
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
## 项目结构
|
|
239
|
+
# Gemini CLI
|
|
240
|
+
cat ~/.gemini/.env
|
|
216
241
|
|
|
242
|
+
# Codex
|
|
243
|
+
cat ~/.codex/auth.json
|
|
217
244
|
```
|
|
218
|
-
|
|
219
|
-
├── bin/
|
|
220
|
-
│ └── index.js # CLI 入口
|
|
221
|
-
├── src/
|
|
222
|
-
│ ├── index.js # 主流程(交互逻辑)
|
|
223
|
-
│ ├── utils.js # 工具函数
|
|
224
|
-
│ └── config/
|
|
225
|
-
│ ├── claude.js # Claude Code 配置模块
|
|
226
|
-
│ ├── codex.js # Codex 配置模块
|
|
227
|
-
│ ├── gemini.js # Gemini CLI 配置模块
|
|
228
|
-
│ ├── opencode.js # OpenCode 配置模块
|
|
229
|
-
│ └── openclaw.js # OpenClaw 配置模块
|
|
230
|
-
└── package.json
|
|
231
|
-
```
|
|
245
|
+
</details>
|
|
232
246
|
|
|
233
247
|
---
|
|
234
248
|
|
|
235
|
-
##
|
|
249
|
+
## 🤝 贡献
|
|
236
250
|
|
|
237
|
-
|
|
251
|
+
欢迎提交 PR 和 Issue!如果这个工具对你有帮助,请点个 ⭐ Star,让更多人发现它。
|
|
238
252
|
|
|
239
|
-
|
|
240
|
-
2. 修改 `package.json` 中的 `name` 和 `bin` 字段
|
|
241
|
-
3. 更新 banner 和完成页面中的品牌信息
|
|
242
|
-
4. 发布到 npm,用户即可一键使用你的专属配置工具
|
|
253
|
+
---
|
|
243
254
|
|
|
244
|
-
|
|
255
|
+
<div align="center">
|
|
245
256
|
|
|
246
|
-
|
|
257
|
+
**如果觉得有用,请给个 ⭐ Star 支持一下!**
|
|
258
|
+
|
|
259
|
+
[](https://star-history.com/#zxyyang/ai-cli-switch&Date)
|
|
247
260
|
|
|
248
|
-
|
|
261
|
+
Made with ❤️ · [npm](https://www.npmjs.com/package/ai-cli-switch) · [Issues](https://github.com/zxyyang/ai-cli-switch/issues)
|
|
249
262
|
|
|
250
|
-
|
|
263
|
+
</div>
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# ai-cli-switch
|
|
2
|
+
|
|
3
|
+
> 一条命令配置所有 AI CLI 工具
|
|
4
|
+
> 支持任意 Base URL — 官方 API、第三方中转服务或自建代理均可
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
7
|
+
[](https://www.npmjs.com/package/ai-cli-switch)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
|
|
11
|
+
[English](README.md)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 演示
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 简介
|
|
22
|
+
|
|
23
|
+
`ai-cli-switch` 是一个通用的 AI CLI 配置助手,支持:
|
|
24
|
+
|
|
25
|
+
- **官方 API** — `api.anthropic.com` / `api.openai.com` / `generativelanguage.googleapis.com`
|
|
26
|
+
- **第三方中转服务** — 如 78code.cc、OpenRouter 等
|
|
27
|
+
- **自建 API 代理** — 本地或云端任意地址
|
|
28
|
+
|
|
29
|
+
无需手动编辑配置文件,交互式填写 Base URL 和 API Key 即可完成配置。
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 支持的工具
|
|
34
|
+
|
|
35
|
+
| 工具 | 说明 | 默认 Base URL |
|
|
36
|
+
|------|------|---------------|
|
|
37
|
+
| **Claude Code** | Anthropic 官方 CLI | `https://api.anthropic.com` |
|
|
38
|
+
| **Codex** | OpenAI Codex CLI | `https://api.openai.com/v1` |
|
|
39
|
+
| **Gemini CLI** | Google Gemini 命令行 | `https://generativelanguage.googleapis.com` |
|
|
40
|
+
| **OpenCode** | 开源 AI 编程助手(Claude/OpenAI/Gemini) | 视模型而定 |
|
|
41
|
+
| **OpenClaw** | 开源 AI 编程助手(Claude/OpenAI/Gemini) | 视模型而定 |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 快速开始
|
|
46
|
+
|
|
47
|
+
### 无需安装,直接运行
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx ai-cli-switch
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 全局安装
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install -g ai-cli-switch
|
|
57
|
+
ai-cli-switch
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 使用流程
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
ai-cli-switch
|
|
66
|
+
│
|
|
67
|
+
├─ [可选] 设置网络代理
|
|
68
|
+
│
|
|
69
|
+
├─ 自动检测已安装的 AI CLI 工具
|
|
70
|
+
│
|
|
71
|
+
├─ 选择要配置的工具
|
|
72
|
+
│ Claude Code / Codex / Gemini CLI / OpenCode / OpenClaw
|
|
73
|
+
│
|
|
74
|
+
├─ [OpenCode/OpenClaw] 选择模型类型
|
|
75
|
+
│ Claude (Anthropic) / OpenAI (GPT) / Gemini (Google)
|
|
76
|
+
│
|
|
77
|
+
├─ 输入 Base URL
|
|
78
|
+
│ 默认为官方地址,直接修改为中转/代理地址即可
|
|
79
|
+
│
|
|
80
|
+
├─ 输入 API Key(密码模式,不显示明文)
|
|
81
|
+
│
|
|
82
|
+
├─ 自动测试 API 连接
|
|
83
|
+
│
|
|
84
|
+
├─ 写入配置文件(自动备份原配置)
|
|
85
|
+
│
|
|
86
|
+
└─ 自检确认配置生效 ✅
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Base URL 填写示例
|
|
92
|
+
|
|
93
|
+
| 场景 | Base URL 示例 |
|
|
94
|
+
|------|---------------|
|
|
95
|
+
| Anthropic 官方 | `https://api.anthropic.com` |
|
|
96
|
+
| OpenAI 官方 | `https://api.openai.com/v1` |
|
|
97
|
+
| Gemini 官方 | `https://generativelanguage.googleapis.com` |
|
|
98
|
+
| 78code 中转(Claude) | `https://www.78code.cc` |
|
|
99
|
+
| 78code 中转(OpenAI) | `https://www.78code.cc/v1` |
|
|
100
|
+
| 自建代理(本地) | `http://127.0.0.1:8080` |
|
|
101
|
+
| 云端代理 | `https://your-proxy.example.com` |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 各工具配置详情
|
|
106
|
+
|
|
107
|
+
### Claude Code
|
|
108
|
+
|
|
109
|
+
写入 `~/.claude/settings.json`:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"env": {
|
|
114
|
+
"ANTHROPIC_API_KEY": "<your-api-key>",
|
|
115
|
+
"ANTHROPIC_BASE_URL": "<your-base-url>"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Codex (OpenAI)
|
|
121
|
+
|
|
122
|
+
- `~/.codex/auth.json` → `{ "OPENAI_API_KEY": "..." }`
|
|
123
|
+
- `~/.codex/config.toml` → 添加自定义 provider 段落(ID 根据 Base URL hostname 自动生成)
|
|
124
|
+
|
|
125
|
+
### Gemini CLI
|
|
126
|
+
|
|
127
|
+
写入 `~/.gemini/.env`:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
GEMINI_API_KEY=<your-api-key>
|
|
131
|
+
GOOGLE_GEMINI_BASE_URL=<your-base-url>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### OpenCode
|
|
135
|
+
|
|
136
|
+
写入 `~/.config/opencode/opencode.json`,provider ID 格式:`{hostname}-{model-type}`
|
|
137
|
+
|
|
138
|
+
### OpenClaw
|
|
139
|
+
|
|
140
|
+
写入 `~/.openclaw/openclaw.json`,格式同 OpenCode
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 配置备份
|
|
145
|
+
|
|
146
|
+
每次写入前自动备份原配置文件:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
~/.claude/settings.json.bak.1709123456789
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 前置要求
|
|
155
|
+
|
|
156
|
+
- **Node.js** >= 18.0.0([下载](https://nodejs.org))
|
|
157
|
+
- 至少安装了一个上述 AI CLI 工具
|
|
158
|
+
|
|
159
|
+
### 安装 Claude Code(示例)
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
npm install -g @anthropic-ai/claude-code
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 常见问题
|
|
168
|
+
|
|
169
|
+
**Q: 提示"未检测到任何已安装的 AI CLI 工具"?**
|
|
170
|
+
|
|
171
|
+
请先安装对应工具:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
npm install -g @anthropic-ai/claude-code # Claude Code
|
|
175
|
+
npm install -g @openai/codex # Codex
|
|
176
|
+
npm install -g @google/gemini-cli # Gemini CLI
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Q: API 连接测试失败?**
|
|
180
|
+
|
|
181
|
+
- 检查 Base URL 是否正确(末尾不要加 `/`)
|
|
182
|
+
- 检查 API Key 是否有效
|
|
183
|
+
- 国内网络可在启动时选择设置代理
|
|
184
|
+
|
|
185
|
+
**Q: 如何手动验证 Claude Code 配置?**
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
cat ~/.claude/settings.json
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Fork 为自己的专属版
|
|
194
|
+
|
|
195
|
+
如果你运营自己的 API 中转服务,可以 fork 本仓库:
|
|
196
|
+
|
|
197
|
+
1. 修改 `src/index.js` 中 `DEFAULT_BASE_URLS` 为你的服务地址
|
|
198
|
+
2. 修改 `package.json` 中的 `name` 和 `bin` 字段
|
|
199
|
+
3. 更新 banner 和完成页面中的品牌信息
|
|
200
|
+
4. 发布到 npm,用户 `npx 你的包名` 即可一键配置
|
|
201
|
+
|
|
202
|
+
示例:[78code-ai](https://github.com/zxyyang/78code) — 基于本工具定制的 78code.cc 专属版
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-cli-switch",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "One-command configuration tool for AI CLI tools — Claude Code, Codex, Gemini CLI, OpenCode & OpenClaw. Bring your own Base URL.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,14 +14,31 @@
|
|
|
14
14
|
"ai",
|
|
15
15
|
"cli",
|
|
16
16
|
"claude-code",
|
|
17
|
+
"claude",
|
|
17
18
|
"codex",
|
|
18
19
|
"gemini",
|
|
20
|
+
"gemini-cli",
|
|
19
21
|
"opencode",
|
|
20
22
|
"openclaw",
|
|
21
23
|
"api-key",
|
|
22
24
|
"configuration",
|
|
23
25
|
"base-url",
|
|
24
|
-
"proxy"
|
|
26
|
+
"proxy",
|
|
27
|
+
"anthropic",
|
|
28
|
+
"openai",
|
|
29
|
+
"google",
|
|
30
|
+
"ai-tools",
|
|
31
|
+
"developer-tools",
|
|
32
|
+
"cli-tool",
|
|
33
|
+
"api-config",
|
|
34
|
+
"setup",
|
|
35
|
+
"interactive",
|
|
36
|
+
"ai-cli",
|
|
37
|
+
"llm",
|
|
38
|
+
"ai-setup",
|
|
39
|
+
"claude-code-config",
|
|
40
|
+
"openai-proxy",
|
|
41
|
+
"api-proxy"
|
|
25
42
|
],
|
|
26
43
|
"author": "",
|
|
27
44
|
"license": "MIT",
|