@chenpu17/cc-gw 0.2.4 → 0.3.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/README.md CHANGED
@@ -53,6 +53,7 @@ pnpm --filter @cc-gw/cli exec tsx index.ts start --daemon --port 4100
53
53
  - **请求日志**:多条件筛选(时间、Provider、模型、状态),查看压缩日志详情,支持分页导出与清理。
54
54
  - **模型管理**:维护 Provider 列表、预置模型、路由策略;一键测试连通性(发送诊断 PROMPT)。
55
55
  - **系统设置**:端口、日志保留策略、是否存储请求 payload、日志级别与访问日志开关、日志清理工具。
56
+ - **使用指南**:提供图文步骤、常见问题与排查提示,帮助团队成员快速熟悉配置流程。
56
57
 
57
58
  UI 支持中英文、深色/浅色主题以及移动端响应式布局,提供键盘可达性(Skip Link、焦点管理)。
58
59
 
@@ -71,6 +72,13 @@ UI 支持中英文、深色/浅色主题以及移动端响应式布局,提供
71
72
  ```
72
73
  3. cc-gw 会根据 `modelRoutes`/默认策略将 Claude 请求路由到已配置的目标模型(如 Kimi、火山 DeepSeek、OpenAI 或自建模型)。
73
74
 
75
+ ### 使用场景 / Usage Scenarios
76
+
77
+ 1. **双端点适配 / Dual Endpoint Support**:通过 `/anthropic` 与 `/openai` 端点,分别兼容 Claude Code 与 Codex 客户端。无需重启 cc-gw,即可在 Web UI 中为两个端点配置独立的默认模型与路由策略。
78
+ 2. **日志追踪 / Request Auditing**:在“请求日志”页按端点、Provider、API Key 等维度筛选记录,可直接查看和复制完整的请求/响应 payload,辅助排查联调问题。
79
+ 3. **模型切换 / Cross-Provider Routing**:利用“模型管理”页的路由映射,将 Claude Code 请求透明地转发到 GLM、Kimi K2、DeepSeek 等任意 OpenAI 兼容模型,实现一套 IDE 客户端、多家大模型的快速切换。
80
+ 4. **操作指引 / Built-in Guidance**:左侧“Help”导航提供分步配置、日常运维建议及 FAQ,可作为新人上手或问题排查的快速参考。
81
+
74
82
  ## 配置说明
75
83
 
76
84
  大多数场景请通过 Web 管理台调整设置,以下仅作为 `~/.cc-gw/config.json` 结构参考,便于脚本化或排查:
@@ -108,13 +116,14 @@ UI 支持中英文、深色/浅色主题以及移动端响应式布局,提供
108
116
  "longContextThreshold": 60000
109
117
  },
110
118
  "modelRoutes": {
111
- "claude-sonnet-4-20250514": "kimi:kimi-k2-0905-preview",
119
+ "claude-sonnet-4-5-20250929": "kimi:kimi-k2-0905-preview",
112
120
  "claude-opus-4-1-20250805": "anthropic:claude-3-5-sonnet-latest"
113
121
  },
114
122
  "logRetentionDays": 30,
115
123
  "storePayloads": true,
116
124
  "logLevel": "info",
117
- "requestLogging": true
125
+ "requestLogging": true,
126
+ "responseLogging": true
118
127
  }
119
128
  ```
120
129
 
@@ -125,7 +134,8 @@ UI 支持中英文、深色/浅色主题以及移动端响应式布局,提供
125
134
  - `modelRoutes`:将 Claude 发起的模型名映射到上游模型;未命中时使用 `defaults`。
126
135
  - `storePayloads`:是否在 SQLite 中压缩保存原始请求/响应(Brotli),关闭后仅保留元信息。
127
136
  - `logLevel`:控制 Fastify/Pino 控制台日志级别(`fatal`/`error`/`warn`/`info`/`debug`/`trace`)。
128
- - `requestLogging`:是否输出每个 HTTP 请求的访问日志,关闭后终端更加安静。
137
+ - `requestLogging`:是否输出每个 HTTP 请求的进入日志。
138
+ - `responseLogging`:是否输出每个 HTTP 请求完成的日志,可独立于 `requestLogging` 控制。
129
139
  - 推荐通过 Web UI 的“模型管理 / 系统设置”在线编辑并热加载,无需手工修改文件。
130
140
 
131
141
  #### Anthropic Provider 额外说明
@@ -219,6 +229,7 @@ claude "help me review this file"
219
229
  - `storePayloads` toggles compressed body retention; disable to keep only metadata.
220
230
  - `logLevel` adjusts Fastify/Pino verbosity (`fatal` → `trace`).
221
231
  - `requestLogging` controls whether per-request access logs are emitted to the console.
232
+ - `responseLogging` toggles completion logs separately so you can keep the console quieter while preserving metrics.
222
233
  - Web UI allows editing without restarting; CLI restart will pick up bundle changes after rebuilds.
223
234
 
224
235
  ### Observability & Storage
@@ -249,6 +260,7 @@ claude "help me review this file"
249
260
  - Always rebuild `@cc-gw/server` and `@cc-gw/web` before restarts to ensure the daemon picks up new code.
250
261
  - If cache statistics remain zero, verify whether the upstream provider exposes `cached_tokens` or equivalent details.
251
262
  - Back up `~/.cc-gw/` (config, logs, SQLite DB) for migrations or disaster recovery.
263
+ - Use the **Help** page in the Web UI to review setup steps, troubleshooting tips, and FAQs whenever a teammate needs a refresher.
252
264
 
253
265
  ---
254
266
 
package/package.json CHANGED
@@ -1,8 +1,24 @@
1
1
  {
2
2
  "name": "@chenpu17/cc-gw",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "type": "module",
6
+ "scripts": {
7
+ "dev": "pnpm --filter server dev",
8
+ "build": "pnpm run build:server && pnpm run build:web",
9
+ "build:server": "pnpm --filter @cc-gw/server build",
10
+ "build:cli": "pnpm --filter @cc-gw/cli build",
11
+ "build:web": "pnpm --filter @cc-gw/web build",
12
+ "build:all": "pnpm run build:server && pnpm run build:cli && pnpm run build:web",
13
+ "release:bundle": "pnpm run build:all && node scripts/build-release.mjs",
14
+ "prepack": "pnpm run build:all",
15
+ "lint": "pnpm exec eslint .",
16
+ "format": "pnpm exec prettier --check .",
17
+ "format:write": "pnpm exec prettier --write .",
18
+ "typecheck": "pnpm -r exec tsc --noEmit",
19
+ "test": "pnpm exec vitest run",
20
+ "test:playwright": "playwright test"
21
+ },
6
22
  "bin": {
7
23
  "cc-gw": "src/cli/dist/index.js"
8
24
  },
@@ -13,6 +29,15 @@
13
29
  "README.md",
14
30
  "LICENSE"
15
31
  ],
32
+ "pnpm": {
33
+ "peerDependencyRules": {
34
+ "ignoreMissing": [
35
+ "react",
36
+ "react-dom"
37
+ ]
38
+ }
39
+ },
40
+ "packageManager": "pnpm@9.0.0",
16
41
  "engines": {
17
42
  "node": ">=18.18.0"
18
43
  },
@@ -31,37 +56,24 @@
31
56
  "dependencies": {
32
57
  "@fastify/cors": "^9.0.1",
33
58
  "@fastify/static": "^7.0.4",
34
- "sqlite3": "^5.1.7",
35
- "commander": "^12.0.0",
36
59
  "colorette": "^2.0.20",
60
+ "commander": "^12.0.0",
37
61
  "fastify": "^4.26.2",
38
62
  "open": "^10.1.0",
63
+ "sqlite3": "^5.1.7",
39
64
  "tiktoken": "^1.0.21",
40
65
  "undici": "^6.11.1"
41
66
  },
42
67
  "devDependencies": {
43
68
  "@eslint/js": "^9.5.0",
69
+ "@playwright/test": "^1.55.1",
44
70
  "@types/node": "^20.12.7",
71
+ "@types/sqlite3": "^3.1.11",
45
72
  "eslint": "^8.57.0",
46
73
  "globals": "^15.0.0",
47
74
  "prettier": "^3.2.5",
48
75
  "typescript": "^5.4.3",
49
76
  "typescript-eslint": "^7.5.0",
50
- "vitest": "^1.6.0",
51
- "@types/sqlite3": "^3.1.11"
52
- },
53
- "scripts": {
54
- "dev": "pnpm --filter server dev",
55
- "build": "pnpm run build:server && pnpm run build:web",
56
- "build:server": "pnpm --filter @cc-gw/server build",
57
- "build:cli": "pnpm --filter @cc-gw/cli build",
58
- "build:web": "pnpm --filter @cc-gw/web build",
59
- "build:all": "pnpm run build:server && pnpm run build:cli && pnpm run build:web",
60
- "release:bundle": "pnpm run build:all && node scripts/build-release.mjs",
61
- "lint": "pnpm exec eslint .",
62
- "format": "pnpm exec prettier --check .",
63
- "format:write": "pnpm exec prettier --write .",
64
- "typecheck": "pnpm -r exec tsc --noEmit",
65
- "test": "pnpm exec vitest run"
77
+ "vitest": "^1.6.0"
66
78
  }
67
- }
79
+ }
@@ -57,21 +57,33 @@ async function ensureConfigTemplate(port) {
57
57
  return false;
58
58
  } catch {
59
59
  const selectedPort = port ? Number.parseInt(port, 10) || DEFAULT_PORT : DEFAULT_PORT;
60
+ const baseDefaults = {
61
+ completion: null,
62
+ reasoning: null,
63
+ background: null,
64
+ longContextThreshold: 6e4
65
+ };
60
66
  const template = {
61
67
  host: "127.0.0.1",
62
68
  port: selectedPort,
63
69
  providers: [],
64
- defaults: {
65
- completion: null,
66
- reasoning: null,
67
- background: null,
68
- longContextThreshold: 6e4
70
+ defaults: { ...baseDefaults },
71
+ endpointRouting: {
72
+ anthropic: {
73
+ defaults: { ...baseDefaults },
74
+ modelRoutes: {}
75
+ },
76
+ openai: {
77
+ defaults: { ...baseDefaults },
78
+ modelRoutes: {}
79
+ }
69
80
  },
70
81
  logRetentionDays: 30,
71
82
  modelRoutes: {},
72
83
  storePayloads: true,
73
84
  logLevel: "info",
74
- requestLogging: true
85
+ requestLogging: true,
86
+ responseLogging: true
75
87
  };
76
88
  await fsp.mkdir(path.dirname(CONFIG_FILE), { recursive: true });
77
89
  await fsp.writeFile(CONFIG_FILE, JSON.stringify(template, null, 2), "utf-8");