Skip to content

Commit 4bb353c

Browse files
committed
docs: update README and DEVELOPMENT for auth CLI and model cleanup
1 parent 6e77505 commit 4bb353c

2 files changed

Lines changed: 70 additions & 43 deletions

File tree

DEVELOPMENT.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,33 @@ pnpm install
1616
## Commands
1717

1818
```bash
19-
make install # Install dependencies
20-
make dev # Dev mode with hot reload
21-
make build # Build to dist/
22-
make test # Run tests
23-
make test-watch # Run tests in watch mode
24-
make test-coverage # Run tests with coverage
25-
make lint # Lint with oxlint
26-
make fmt # Format with oxfmt
27-
make typecheck # Type-check with tsc
28-
make check # Format + lint + typecheck + test + build
29-
make docker-build # Build Docker image
19+
pnpm install # Install dependencies
20+
pnpm dev # Dev mode with hot reload (tsx)
21+
pnpm build # Build to dist/
22+
pnpm test # Run tests
23+
pnpm test:watch # Run tests in watch mode
24+
pnpm test:coverage # Run tests with coverage
25+
26+
# Auth management
27+
pnpm auth login # Save API key
28+
pnpm auth logout # Remove saved API key
29+
30+
# OpenCode setup
31+
pnpm build && node dist/proxy.js --setup-opencode
3032
```
3133

34+
Scripts are defined in `package.json`. The `make` shortcuts are also available if you have `make` installed.
35+
3236
## Project structure
3337

3438
```
3539
src/
36-
├── proxy.ts # Entry point
40+
├── proxy.ts # Entry point (server, auth CLI, setup)
41+
├── auth.ts # Auth helpers: read/save/delete key, masked prompt
3742
├── config.ts # Config loader (env, CLI, auth.json)
3843
├── logger.ts # Structured logger
3944
├── server.ts # HTTP server & routes
40-
├── models.json # Model list & aliases
45+
├── models.json # Model list, aliases, context windows
4146
├── stream.ts # NDJSON parser & SSE formatter
4247
├── upstream.ts # CC API client
4348
├── setup/
@@ -49,6 +54,7 @@ src/
4954
├── validation.ts # Request validation
5055
└── openai.ts # OpenAI ↔ CC translation
5156
tests/
57+
├── auth.test.ts # Auth module tests
5258
├── config.test.ts # Config loader tests
5359
├── server.test.ts # HTTP server tests
5460
├── stream.test.ts # NDJSON parser & SSE tests
@@ -64,14 +70,14 @@ tests/
6470
# Build
6571
docker build -t commandcode-api-proxy .
6672

67-
# Run
73+
# Run with env var
6874
docker run --rm -p 8787:8787 \
6975
-e CC_API_KEY=user_xxx \
7076
commandcode-api-proxy
7177

7278
# Or mount auth.json
7379
docker run --rm -p 8787:8787 \
74-
-v ~/.commandcode:/home/node/.commandcode:ro \
80+
-v ~/.config/commandcode-api-proxy:/home/node/.config/commandcode-api-proxy:ro \
7581
commandcode-api-proxy
7682

7783
# Using docker compose

README.md

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,24 @@ The proxy loads your API key from (in order of priority):
3535

3636
1. `--api-key` CLI flag: `npx commandcode-api-proxy --api-key user_xxx`
3737
2. `CC_API_KEY` environment variable
38-
3. `~/.commandcode/auth.json` (auto-generated by `npx command-code`)
38+
3. `~/.config/commandcode-api-proxy/auth.json` (saved via `auth login`)
3939

40-
If you've already run `npx command-code` to log in, no extra setup is needed.
40+
On first run without a key, the proxy prompts you to enter one and persists it.
41+
42+
#### CLI auth commands
43+
44+
```bash
45+
# Save a new API key
46+
commandcode-api-proxy auth login
47+
48+
# Overwrite existing key
49+
commandcode-api-proxy auth login --force
50+
51+
# Remove saved key
52+
commandcode-api-proxy auth logout
53+
```
54+
55+
Get your API key from https://commandcode.ai/settings.
4156

4257
### CLI options
4358

@@ -46,14 +61,15 @@ If you've already run `npx command-code` to log in, no extra setup is needed.
4661
| `--host` | Bind address | `127.0.0.1` |
4762
| `--port` | Port | `8787` |
4863
| `--api-key` | Command Code API key ||
64+
| `--setup-opencode` | Generate OpenCode provider config ||
4965

5066
## Endpoints
5167

5268
### `POST /v1/chat/completions` (OpenAI)
5369

5470
```bash
5571
curl http://127.0.0.1:8787/v1/chat/completions \
56-
-H "Authorization: Bearer user_xxx" \
72+
-H "Authorization: Bearer proxy-managed" \
5773
-H "Content-Type: application/json" \
5874
-d '{
5975
"model": "deepseek/deepseek-v4-pro",
@@ -66,7 +82,13 @@ curl http://127.0.0.1:8787/v1/chat/completions \
6682

6783
### OpenCode
6884

69-
Add to your `opencode.json` (project root or `~/.config/opencode/opencode.json`):
85+
Run setup (writes to `~/.config/opencode/opencode.json`):
86+
87+
```bash
88+
npx commandcode-api-proxy --setup-opencode
89+
```
90+
91+
Or add manually:
7092

7193
```json
7294
{
@@ -76,28 +98,24 @@ Add to your `opencode.json` (project root or `~/.config/opencode/opencode.json`)
7698
"npm": "@ai-sdk/openai-compatible",
7799
"name": "Command Code",
78100
"options": {
79-
"baseURL": "http://127.0.0.1:8787/v1"
101+
"baseURL": "http://127.0.0.1:8787/v1",
102+
"apiKey": "proxy-managed"
80103
},
81104
"models": {
82-
"deepseek/deepseek-v4-pro": { "name": "DeepSeek V4 Pro" },
83-
"deepseek/deepseek-v4-flash": { "name": "DeepSeek V4 Flash" },
84-
"MiniMaxAI/MiniMax-M2.7": { "name": "MiniMax M2.7" },
85-
"MiniMaxAI/MiniMax-M2.5": { "name": "MiniMax M2.5" },
86-
"zai-org/GLM-5.1": { "name": "GLM 5.1" },
87-
"zai-org/GLM-5": { "name": "GLM 5" },
88-
"moonshotai/Kimi-K2.6": { "name": "Kimi K2.6" },
89-
"moonshotai/Kimi-K2.5": { "name": "Kimi K2.5" },
90-
"Qwen/Qwen3.6-Max-Preview": { "name": "Qwen 3.6 Max" },
91-
"Qwen/Qwen3.6-Plus": { "name": "Qwen 3.6 Plus" },
92-
"Qwen/Qwen3.7-Max": { "name": "Qwen 3.7 Max" },
93-
"Qwen/Qwen3.7-Plus": { "name": "Qwen 3.7 Plus" },
94-
"stepfun/Step-3.5-Flash": { "name": "Step 3.5 Flash" },
95-
"google/gemini-3.1-flash-lite": { "name": "Gemini 3.1 Flash Lite" },
96-
"google/gemini-3.5-flash": { "name": "Gemini 3.5 Flash" },
97-
"xiaomi/mimo-v2.5": { "name": "MiMo v2.5" },
98-
"claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" },
99-
"claude-opus-4-7": { "name": "Claude Opus 4.7" },
100-
"openai/gpt-5.5": { "name": "GPT 5.5" }
105+
"deepseek-v4-pro": { "name": "DeepSeek V4 Pro", "limit": { "context": 1048576, "output": 393216 } },
106+
"deepseek-v4-flash": { "name": "DeepSeek V4 Flash", "limit": { "context": 1048576, "output": 393216 } },
107+
"MiniMax-M2.7": { "name": "MiniMax M2.7", "limit": { "context": 204800, "output": 32768 } },
108+
"MiniMax-M2.5": { "name": "MiniMax M2.5", "limit": { "context": 204800, "output": 32768 } },
109+
"GLM-5.1": { "name": "GLM-5.1", "limit": { "context": 200000, "output": 131072 } },
110+
"GLM-5": { "name": "GLM-5", "limit": { "context": 200000, "output": 131072 } },
111+
"Kimi-K2.6": { "name": "Kimi K2.6", "limit": { "context": 262144, "output": 98304 } },
112+
"Kimi-K2.5": { "name": "Kimi K2.5", "limit": { "context": 262144, "output": 98304 } },
113+
"Qwen3.6-Max-Preview": { "name": "Qwen 3.6 Max Preview", "limit": { "context": 262144, "output": 65536 } },
114+
"Qwen3.6-Plus": { "name": "Qwen 3.6 Plus", "limit": { "context": 1048576, "output": 65536 } },
115+
"Qwen3.7-Max": { "name": "Qwen 3.7 Max", "limit": { "context": 1048576, "output": 65536 } },
116+
"Qwen3.7-Plus": { "name": "Qwen 3.7 Plus", "limit": { "context": 1048576, "output": 65536 } },
117+
"Step-3.5-Flash": { "name": "Step 3.5 Flash", "limit": { "context": 262144, "output": 65536 } },
118+
"mimo-v2.5": { "name": "MiMo V2.5", "limit": { "context": 1048576, "output": 131072 } }
101119
}
102120
}
103121
}
@@ -144,11 +162,14 @@ Short names work in addition to full model IDs:
144162
| -------------------------------------- | ---------------------------- |
145163
| `deepseek-v4-pro`, `deepseek-v4` | `deepseek/deepseek-v4-pro` |
146164
| `deepseek-v4-flash`, `deepseek-flash` | `deepseek/deepseek-v4-flash` |
147-
| `claude-sonnet-4-6`, `claude-opus-4-7` | `deepseek/deepseek-v4-pro` |
148-
| `gpt-4`, `gpt-4o`, `gpt-5`, `gpt-5.5` | `deepseek/deepseek-v4-pro` |
149-
| `kimi-k2.6`, `kimi-k2.5` | `moonshotai/Kimi-*` |
150-
| `qwen-3.6-max`, `qwen-3.6-plus` | `Qwen/Qwen3.6-*` |
165+
| `minimax-m2.7`, `minimax-m2.5` | `MiniMaxAI/MiniMax-*` |
151166
| `glm-5.1`, `glm-5` | `zai-org/GLM-*` |
167+
| `kimi-k2.6`, `kimi-k2.5` | `moonshotai/Kimi-*` |
168+
| `qwen3.6-max`, `qwen3.6-plus` | `Qwen/Qwen3.6-*` |
169+
| `step3.5` | `stepfun/Step-3.5-Flash` |
170+
| `mimo-v2.5` | `xiaomi/mimo-v2.5` |
171+
172+
Any model ID is passed through as-is — the proxy does not validate against a fixed list.
152173

153174
## License
154175

0 commit comments

Comments
 (0)