cc-viewer 1.5.18 → 1.5.19

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.
Files changed (5) hide show
  1. package/README.md +79 -60
  2. package/cli.js +22 -25
  3. package/i18n.js +3 -3
  4. package/package.json +1 -1
  5. package/proxy.js +3 -21
package/README.md CHANGED
@@ -3,6 +3,12 @@
3
3
  A Claude Code request monitoring system that captures and visualizes all API requests and responses from Claude Code in real time (raw text, unredacted). Helps developers monitor their context for review and troubleshooting during Vibe Coding sessions.
4
4
  The latest version of CC-Viewer also provides a server-deployed web programming solution and mobile programming tools. Feel free to use them in your own projects — more plugin features and cloud deployment support are coming in the future.
5
5
 
6
+ Check out the fun part — here's what you can see on mobile:
7
+
8
+ <img width="1700" height="790" alt="image" src="https://github.com/user-attachments/assets/da3e519f-ff66-4cd2-81d1-f4e131215f6c" />
9
+
10
+ <font color="#999">(Current version has limited iOS compatibility — iOS optimization is planned for 2026.04.01)</font>
11
+
6
12
  English | [简体中文](./docs/README.zh.md) | [繁體中文](./docs/README.zh-TW.md) | [한국어](./docs/README.ko.md) | [日本語](./docs/README.ja.md) | [Deutsch](./docs/README.de.md) | [Español](./docs/README.es.md) | [Français](./docs/README.fr.md) | [Italiano](./docs/README.it.md) | [Dansk](./docs/README.da.md) | [Polski](./docs/README.pl.md) | [Русский](./docs/README.ru.md) | [العربية](./docs/README.ar.md) | [Norsk](./docs/README.no.md) | [Português (Brasil)](./docs/README.pt-BR.md) | [ไทย](./docs/README.th.md) | [Türkçe](./docs/README.tr.md) | [Українська](./docs/README.uk.md)
7
13
 
8
14
  ## Usage
@@ -13,47 +19,49 @@ English | [简体中文](./docs/README.zh.md) | [繁體中文](./docs/README.zh-
13
19
  npm install -g cc-viewer --registry=https://registry.npmjs.org
14
20
  ```
15
21
 
16
- ### Monitor Mode (launching claude or claude --dangerously-skip-permissions in this mode automatically starts a logging process to record request payloads)
17
-
18
- ```bash
19
- ccv
20
- ```
21
-
22
22
  ### Programming Mode
23
23
 
24
- == claude
24
+ ccv is a drop-in replacement for claude — all arguments are passed through to claude while launching the Web Viewer.
25
25
 
26
26
  ```bash
27
- ccv -c
27
+ ccv # == claude (interactive mode)
28
+ ccv -c # == claude --continue (continue last conversation)
29
+ ccv -r # == claude --resume (resume a conversation)
30
+ ccv -p "hello" # == claude --print "hello" (print mode)
31
+ ccv --d # == claude --dangerously-skip-permissions (shortcut)
32
+ ccv --model opus # == claude --model opus
28
33
  ```
29
34
 
30
- == claude --dangerously-skip-permissions
31
-
32
- ```bash
33
- ccv -d
34
- ```
35
-
36
- After launching programming mode, a web page will open automatically.
35
+ After launching, a web page will open automatically.
37
36
 
38
37
  You can use Claude directly from the web page while viewing the full request payloads and code changes.
39
38
 
40
39
  Even better — you can even code from your mobile device!
41
40
 
42
- This command automatically detects how Claude Code is installed locally (NPM or Native Install) and adapts accordingly.
43
41
 
44
- - **NPM Install**: Automatically injects an interceptor script into Claude Code's `cli.js`.
45
- - **Native Install**: Automatically detects the `claude` binary, configures a local transparent proxy, and sets up a Zsh Shell Hook to forward traffic automatically.
46
- - NPM-installed Claude Code is the recommended approach for this project.
42
+ ### Logger Mode
47
43
 
48
- ### Configuration Override
44
+ ⚠️ If you still prefer using the native claude tool or VS Code extension, use this mode.
49
45
 
50
- If you need to use a custom API endpoint (e.g., a corporate proxy), simply configure it in `~/.claude/settings.json` or set the `ANTHROPIC_BASE_URL` environment variable. `ccv` will automatically detect and correctly forward requests.
46
+ In this mode, launching `claude` or `claude --dangerously-skip-permissions` will automatically start a logging process that records request logs to ~/.claude/cc-viewer/*yourproject*/date.jsonl
51
47
 
52
- ### Silent Mode
48
+ Enable logger mode:
49
+ ```bash
50
+ ccv -logger
51
+ ```
53
52
 
54
- By default, `ccv` runs in silent mode when wrapping `claude`, keeping your terminal output clean and consistent with the native experience. All logs are captured in the background and can be viewed at `http://localhost:7008`.
53
+ When the console cannot print the specific port, the default first port is 127.0.0.1:7008. Multiple instances use sequential ports like 7009, 7010.
55
54
 
56
- Once configured, use the `claude` command as normal. Visit `http://localhost:7008` to access the monitoring interface.
55
+ This command automatically detects how Claude Code is installed locally (NPM or Native Install) and adapts accordingly.
56
+
57
+ - **NPM version Claude Code**: Automatically injects an interceptor script into Claude Code's `cli.js`.
58
+ - **Native version Claude Code**: Automatically detects the `claude` binary, configures a local transparent proxy, and sets up a Zsh Shell Hook to forward traffic automatically.
59
+ - NPM-installed Claude Code is the recommended approach for this project.
60
+
61
+ Uninstall logger mode:
62
+ ```bash
63
+ ccv --uninstall
64
+ ```
57
65
 
58
66
  ### Troubleshooting
59
67
 
@@ -69,65 +77,75 @@ Letting Claude Code diagnose the issue itself is more effective than asking anyo
69
77
 
70
78
  After the above instruction is completed, `findcc.js` will be updated. If your project frequently requires local deployment, or if forked code often needs to resolve installation issues, keeping this file lets you simply copy it next time. At this stage, many projects and companies using Claude Code are not deploying on Mac but rather on server-side hosted environments, so the author has separated `findcc.js` to make it easier to track cc-viewer source code updates going forward.
71
79
 
72
- ### Uninstall
80
+ ### Other Commands
73
81
 
82
+ See:
74
83
  ```bash
75
- ccv --uninstall
84
+ ccv -h
76
85
  ```
77
86
 
78
- ### Check Version
87
+ ### Configuration Override
79
88
 
80
- ```bash
81
- ccv -v
82
- ```
89
+ If you need to use a custom API endpoint (e.g., a corporate proxy), simply configure it in `~/.claude/settings.json` or set the `ANTHROPIC_BASE_URL` environment variable. `ccv` will automatically detect and correctly forward requests.
83
90
 
84
- ## Features
91
+ ### Silent Mode
85
92
 
86
- ### Request Monitoring (Raw Mode)
87
- <img width="1500" height="720" alt="image" src="https://github.com/user-attachments/assets/519dd496-68bd-4e76-84d7-2a3d14ae3f61" />
93
+ By default, `ccv` runs in silent mode when wrapping `claude`, keeping your terminal output clean and consistent with the native experience. All logs are captured in the background and can be viewed at `http://localhost:7008`.
88
94
 
89
- - Captures all API requests made by Claude Code in real time, ensuring raw content rather than truncated logs (this is important!!!)
90
- - Automatically identifies and labels Main Agent and Sub Agent requests (subtypes: Plan, Search, Bash)
91
- - MainAgent requests support Body Diff JSON, showing a collapsed diff of changes from the previous MainAgent request (only changed/added fields)
92
- - Inline token usage stats per request (input/output tokens, cache creation/read, hit rate)
93
- - Compatible with Claude Code Router (CCR) and other proxy scenarios — falls back to API path pattern matching
95
+ Once configured, use the `claude` command as normal. Visit `http://localhost:7008` to access the monitoring interface.
94
96
 
95
- ### Conversation Mode
96
97
 
97
- Click the "Conversation Mode" button in the top-right corner to parse the Main Agent's full conversation history into a chat interface:
98
- <img width="1500" height="730" alt="image" src="https://github.com/user-attachments/assets/c973f142-748b-403f-b2b7-31a5d81e33e6" />
98
+ ## Features
99
99
 
100
- - Agent Team display is not yet supported
101
- - User messages are right-aligned (blue bubbles), Main Agent replies are left-aligned (dark bubbles)
102
- - `thinking` blocks are collapsed by default, rendered in Markdown, and can be expanded to view the reasoning process; one-click translation is supported (feature is still unstable)
103
- - User selection messages (AskUserQuestion) are displayed in a Q&A format
104
- - Bidirectional mode sync: switching to Conversation Mode automatically scrolls to the conversation corresponding to the selected request; switching back to Raw Mode automatically scrolls to the selected request
105
- - Settings panel: toggle the default collapsed state for tool results and thinking blocks
106
- - Mobile conversation browsing: in mobile CLI mode, tap the "Conversation Browse" button in the top bar to slide out a read-only conversation view for browsing the full conversation history on your phone
107
100
 
108
101
  ### Programming Mode
109
102
 
110
- After launching with ccv -c or ccv -d, you will see:
103
+ After launching with ccv, you can see:
104
+
111
105
  <img width="1500" height="725" alt="image" src="https://github.com/user-attachments/assets/a64a381e-5a68-430c-b594-6d57dc01f4d3" />
112
106
 
113
107
  You can view code diffs directly after editing:
108
+
114
109
  <img width="1500" height="728" alt="image" src="https://github.com/user-attachments/assets/2a4acdaa-fc5f-4dc0-9e5f-f3273f0849b2" />
115
110
 
116
- While you can open files and edit code manually, manual coding is not recommended — that's old-school coding!
111
+ While you can open files and code manually, manual coding is not recommended — that's old-school coding!
117
112
 
118
113
  ### Mobile Programming
119
114
 
120
- You can even scan a QR code to code on your mobile device:
115
+ You can even scan a QR code to code from your mobile device:
116
+
121
117
  <img width="3018" height="1460" alt="image" src="https://github.com/user-attachments/assets/8debf48e-daec-420c-b37a-609f8b81cd20" />
122
118
 
123
- On mobile you can see:
124
- <img width="1700" height="790" alt="image" src="https://github.com/user-attachments/assets/da3e519f-ff66-4cd2-81d1-f4e131215f6c" />
119
+ Fulfill your imagination of mobile programming. There's also a plugin mechanism — if you need to customize for your coding habits, stay tuned for plugin hooks updates.
120
+
121
+ ### Logger Mode (View Complete Claude Code Sessions)
122
+
123
+ <img width="1500" height="720" alt="image" src="https://github.com/user-attachments/assets/519dd496-68bd-4e76-84d7-2a3d14ae3f61" />
124
+
125
+ - Captures all API requests from Claude Code in real time, ensuring raw text — not redacted logs (this is important!!!)
126
+ - Automatically identifies and labels Main Agent and Sub Agent requests (subtypes: Plan, Search, Bash)
127
+ - MainAgent requests support Body Diff JSON, showing collapsed differences from the previous MainAgent request (only changed/new fields)
128
+ - Each request displays inline Token usage statistics (input/output tokens, cache creation/read, hit rate)
129
+ - Compatible with Claude Code Router (CCR) and other proxy scenarios — falls back to API path pattern matching
130
+
131
+ ### Conversation Mode
125
132
 
126
- Fulfills everything you can imagine about mobile programming.
133
+ Click the "Conversation Mode" button in the top-right corner to parse the Main Agent's complete conversation history into a chat interface:
134
+
135
+ <img width="1500" height="730" alt="image" src="https://github.com/user-attachments/assets/c973f142-748b-403f-b2b7-31a5d81e33e6" />
136
+
137
+ - Agent Team display is not yet supported
138
+ - User messages are right-aligned (blue bubbles), Main Agent replies are left-aligned (dark bubbles)
139
+ - `thinking` blocks are collapsed by default, rendered as Markdown — click to expand and view the thinking process; one-click translation is supported (feature is still unstable)
140
+ - User selection messages (AskUserQuestion) are displayed in Q&A format
141
+ - Bidirectional mode sync: switching to conversation mode auto-scrolls to the conversation corresponding to the selected request; switching back to raw mode auto-scrolls to the selected request
142
+ - Settings panel: toggle default collapse state for tool results and thinking blocks
143
+ - Mobile conversation browsing: in mobile CLI mode, tap the "Conversation Browse" button in the top bar to slide out a read-only conversation view for browsing the complete conversation history on mobile
127
144
 
128
145
  ### Statistics Tool
129
146
 
130
147
  The "Data Statistics" floating panel in the header area:
148
+
131
149
  <img width="1500" height="729" alt="image" src="https://github.com/user-attachments/assets/b23f9a81-fc3d-4937-9700-e70d84e4e5ce" />
132
150
 
133
151
  - Displays cache creation/read counts and cache hit rate
@@ -139,6 +157,7 @@ The "Data Statistics" floating panel in the header area:
139
157
  ### Log Management
140
158
 
141
159
  Via the CC-Viewer dropdown menu in the top-left corner:
160
+
142
161
  <img width="1200" height="672" alt="image" src="https://github.com/user-attachments/assets/8cf24f5b-9450-4790-b781-0cd074cd3b39" />
143
162
 
144
163
  - Import local logs: browse historical log files grouped by project, open in a new window
@@ -148,18 +167,18 @@ Via the CC-Viewer dropdown menu in the top-left corner:
148
167
  - View user Prompts: extract and display all user inputs, supporting three view modes — Raw mode (original content), Context mode (system tags collapsible), Text mode (plain text); slash commands (`/model`, `/context`, etc.) shown as standalone entries; command-related tags are auto-hidden from Prompt content
149
168
  - Export Prompts to TXT: export user Prompts (plain text, excluding system tags) to a local `.txt` file
150
169
 
151
- ### Multi-language Support
152
-
153
- CC-Viewer supports 18 languages, automatically switching based on system locale:
154
-
155
- 简体中文 | English | 繁體中文 | 한국어 | Deutsch | Español | Français | Italiano | Dansk | 日本語 | Polski | Русский | العربية | Norsk | Português (Brasil) | ไทย | Türkçe | Українська
156
-
157
170
  ### Auto-Update
158
171
 
159
172
  CC-Viewer automatically checks for updates on startup (at most once every 4 hours). Within the same major version (e.g., 1.x.x → 1.y.z), updates are applied automatically and take effect on the next restart. Cross-major-version updates only show a notification.
160
173
 
161
174
  Auto-update follows Claude Code's global configuration in `~/.claude/settings.json`. If Claude Code has auto-updates disabled (`autoUpdates: false`), CC-Viewer will also skip auto-updates.
162
175
 
176
+ ### Multi-language Support
177
+
178
+ CC-Viewer supports 18 languages, automatically switching based on system locale:
179
+
180
+ 简体中文 | English | 繁體中文 | 한국어 | Deutsch | Español | Français | Italiano | Dansk | 日本語 | Polski | Русский | العربية | Norsk | Português (Brasil) | ไทย | Türkçe | Українська
181
+
163
182
  ## License
164
183
 
165
184
  MIT
package/cli.js CHANGED
@@ -383,11 +383,12 @@ async function runCliModeWorkspaceSelector(extraClaudeArgs = []) {
383
383
  // === 主逻辑 ===
384
384
 
385
385
  const args = process.argv.slice(2);
386
+
387
+ // ccv 自有命令判断
388
+ const isLogger = args.includes('-logger');
386
389
  const isUninstall = args.includes('--uninstall');
387
390
  const isHelp = args.includes('--help') || args.includes('-h') || args[0] === 'help';
388
391
  const isVersion = args.includes('--v') || args.includes('--version') || args.includes('-v');
389
- const isCliMode = args.includes('--c') || args.includes('-c');
390
- const isDangerousMode = args.includes('-d') || args.includes('--d');
391
392
 
392
393
  if (isHelp) {
393
394
  console.log(t('cli.help'));
@@ -404,31 +405,13 @@ if (isVersion) {
404
405
  process.exit(0);
405
406
  }
406
407
 
407
- if (isCliMode || isDangerousMode) {
408
- const extraArgs = isDangerousMode ? ['--dangerously-skip-permissions'] : [];
409
-
410
- // 解析 -d/-c 后的可选路径参数
411
- const flagIndex = args.findIndex(a => a === '-d' || a === '--d' || a === '-c' || a === '--c');
412
- let workspacePath = null;
413
- if (flagIndex >= 0 && flagIndex + 1 < args.length && !args[flagIndex + 1].startsWith('-')) {
414
- workspacePath = resolve(args[flagIndex + 1]);
415
- }
416
-
417
- // 默认用 cwd 启动,支持可选路径参数
418
- runCliMode(extraArgs, workspacePath || process.cwd()).catch(err => {
419
- console.error('CLI mode error:', err);
420
- process.exit(1);
421
- });
422
- } else if (args[0] === 'run') {
423
- runProxyCommand(args);
424
- } else if (isUninstall) {
408
+ if (isUninstall) {
425
409
  const cliResult = removeCliJsInjection();
426
410
  const shellResult = removeShellHook();
427
411
 
428
412
  if (cliResult === 'removed' || cliResult === 'clean') {
429
413
  console.log(t('cli.uninstall.cliCleaned'));
430
414
  } else if (cliResult === 'not_found') {
431
- // console.log(t('cli.uninstall.cliNotFound'));
432
415
  // Silent is better for mixed mode uninstall
433
416
  } else {
434
417
  console.log(t('cli.uninstall.cliFail'));
@@ -444,12 +427,13 @@ if (isCliMode || isDangerousMode) {
444
427
  console.log(t('cli.uninstall.reloadShell'));
445
428
  console.log(t('cli.uninstall.done'));
446
429
  process.exit(0);
447
- } else {
448
- // Installation Logic
430
+ }
431
+
432
+ if (isLogger) {
433
+ // 安装/修复 hook 逻辑(原来无参数 ccv 的行为)
449
434
  let mode = 'unknown';
450
435
 
451
- // Check PATH to determine priority
452
- let prefersNative = true; // default to native if not found in PATH
436
+ let prefersNative = true;
453
437
  const paths = (process.env.PATH || '').split(':');
454
438
  for (const dir of paths) {
455
439
  if (!dir) continue;
@@ -542,4 +526,17 @@ if (isCliMode || isDangerousMode) {
542
526
  process.exit(1);
543
527
  }
544
528
  }
529
+ process.exit(0);
530
+ }
531
+
532
+ if (args[0] === 'run') {
533
+ runProxyCommand(args);
534
+ } else {
535
+ // 默认行为:所有参数透传给 claude(通过 PTY + Web Viewer)
536
+ // 展开 --d 快捷方式为 --dangerously-skip-permissions
537
+ const claudeArgs = args.map(a => a === '--d' ? '--dangerously-skip-permissions' : a);
538
+ runCliMode(claudeArgs, process.cwd()).catch(err => {
539
+ console.error('CLI mode error:', err);
540
+ process.exit(1);
541
+ });
545
542
  }
package/i18n.js CHANGED
@@ -162,9 +162,9 @@ const i18nData = {
162
162
  "uk": "\nДля видалення виконайте: ccv --uninstall"
163
163
  },
164
164
  "cli.help": {
165
- "zh": "CC Viewer CLI\n\n用法:\n ccv [options]\n ccv run -- <command> [args...]\n ccv -d [path] 启动交互模式 + 危险权限\n ccv -c [path] 启动交互模式\n\n选项:\n -h, --help 显示帮助\n -v, --version 显示版本\n -d [path] 启动交互式 Web Viewer(跳过权限确认)\n 不指定 path 时使用当前目录\n -c [path] 启动交互式 Web Viewer\n 不指定 path 时使用当前目录\n --uninstall 移除 CC Viewer 集成\n\n说明:\n 直接运行 ccv 将安装/修复 Claude Code 的集成 Hook。\n 使用 -d/-c 启动后,可在 Web 界面中切换工作区。",
166
- "en": "CC Viewer CLI\n\nUsage:\n ccv [options]\n ccv run -- <command> [args...]\n ccv -d [path] Start interactive mode + dangerous permissions\n ccv -c [path] Start interactive mode\n\nOptions:\n -h, --help Show help\n -v, --version Show version\n -d [path] Start interactive Web Viewer (skip permission prompts)\n Uses current directory if path is not specified\n -c [path] Start interactive Web Viewer\n Uses current directory if path is not specified\n --uninstall Remove CC Viewer integration\n\nNotes:\n Running ccv without arguments installs/repairs the Claude Code hook.\n After starting with -d/-c, you can switch workspaces from the Web UI.",
167
- "zh-TW": "CC Viewer CLI\n\n用法:\n ccv [options]\n ccv run -- <command> [args...]\n ccv -d [path] 啟動互動模式 + 危險權限\n ccv -c [path] 啟動互動模式\n\n選項:\n -h, --help 顯示說明\n -v, --version 顯示版本\n -d [path] 啟動互動式 Web Viewer(跳過權限確認)\n 不指定 path 時使用當前目錄\n -c [path] 啟動互動式 Web Viewer\n 不指定 path 時使用當前目錄\n --uninstall 移除 CC Viewer 整合\n\n說明:\n 直接執行 ccv 會安裝/修復 Claude Code 的整合 Hook。\n 使用 -d/-c 啟動後,可在 Web 介面中切換工作區。"
165
+ "zh": "CC Viewer CLI — Claude Code 的 Web Viewer 前端\n\n用法: ccv [选项] [命令] [提示词]\n\n默认启动交互式会话 + Web Viewer,所有参数透传给 claude。\n\n参数:\n prompt 你的提示词\n\nCCV 专属选项:\n -logger 安装/修复 Claude Code Hook\n --uninstall 移除 CC Viewer 集成\n --d --dangerously-skip-permissions 的快捷方式\n\nClaude 选项(透传):\n -c, --continue 继续当前目录最近的对话\n -r, --resume [value] 通过会话 ID 恢复对话,或打开交互式选择器\n -p, --print 打印响应后退出(适用于管道)\n -d, --debug [filter] 启用调试模式\n -w, --worktree [name] 为此会话创建新的 git worktree\n --model <model> 当前会话使用的模型\n --effort <level> 努力级别 (low, medium, high, max)\n --dangerously-skip-permissions 跳过所有权限检查\n --allowedTools <tools...> 允许的工具列表\n --disallowedTools <tools...> 禁止的工具列表\n --system-prompt <prompt> 会话系统提示词\n --append-system-prompt <prompt> 追加系统提示词\n --mcp-config <configs...> 加载 MCP 服务器配置\n --permission-mode <mode> 权限模式\n --add-dir <directories...> 额外允许访问的目录\n --max-budget-usd <amount> API 调用最大预算(仅 --print)\n --output-format <format> 输出格式(仅 --print): text, json, stream-json\n --json-schema <schema> 结构化输出的 JSON Schema\n --verbose 详细模式\n -h, --help 显示帮助\n -v, --version 显示版本\n\n 更多选项请参考: claude --help\n\n示例:\n ccv 启动交互模式\n ccv -c 继续上次对话\n ccv -r 恢复对话\n ccv -p \"hello\" 打印模式\n ccv --model opus 指定模型\n ccv --d 跳过权限确认(快捷方式)\n ccv -c --model sonnet --effort max 组合使用\n ccv -logger 安装/修复 Hook",
166
+ "en": "CC Viewer CLI — Web Viewer frontend for Claude Code\n\nUsage: ccv [options] [command] [prompt]\n\nStarts an interactive session with Web Viewer by default. All args are passed\nthrough to claude.\n\nArguments:\n prompt Your prompt\n\nCCV Options:\n -logger Install/repair Claude Code hook\n --uninstall Remove CC Viewer integration\n --d Shortcut for --dangerously-skip-permissions\n\nClaude Options (passed through):\n -c, --continue Continue the most recent conversation\n -r, --resume [value] Resume a conversation by session ID, or open picker\n -p, --print Print response and exit (useful for pipes)\n -d, --debug [filter] Enable debug mode\n -w, --worktree [name] Create a new git worktree for this session\n --model <model> Model for the current session\n --effort <level> Effort level (low, medium, high, max)\n --dangerously-skip-permissions Bypass all permission checks\n --allowedTools <tools...> Allowed tool names\n --disallowedTools <tools...> Disallowed tool names\n --system-prompt <prompt> System prompt for the session\n --append-system-prompt <prompt> Append to default system prompt\n --mcp-config <configs...> Load MCP servers from JSON files or strings\n --permission-mode <mode> Permission mode for the session\n --add-dir <directories...> Additional directories to allow access to\n --max-budget-usd <amount> Max dollar amount for API calls (--print only)\n --output-format <format> Output format (--print only): text, json, stream-json\n --json-schema <schema> JSON Schema for structured output\n --verbose Enable verbose mode\n -h, --help Show help\n -v, --version Show version\n\n For all options, see: claude --help\n\nExamples:\n ccv Start interactive mode\n ccv -c Continue last conversation\n ccv -r Resume a conversation\n ccv -p \"hello\" Print mode\n ccv --model opus Specify model\n ccv --d Skip permission prompts (shortcut)\n ccv -c --model sonnet --effort max Combine options\n ccv -logger Install/repair hook",
167
+ "zh-TW": "CC Viewer CLI — Claude Code 的 Web Viewer 前端\n\n用法: ccv [選項] [命令] [提示詞]\n\n預設啟動互動式會話 + Web Viewer,所有參數透傳給 claude。\n\n參數:\n prompt 你的提示詞\n\nCCV 專屬選項:\n -logger 安裝/修復 Claude Code Hook\n --uninstall 移除 CC Viewer 整合\n --d --dangerously-skip-permissions 的快捷方式\n\nClaude 選項(透傳):\n -c, --continue 繼續當前目錄最近的對話\n -r, --resume [value] 透過會話 ID 恢復對話,或開啟互動式選擇器\n -p, --print 列印回應後退出(適用於管道)\n -d, --debug [filter] 啟用除錯模式\n -w, --worktree [name] 為此會話建立新的 git worktree\n --model <model> 當前會話使用的模型\n --effort <level> 努力級別 (low, medium, high, max)\n --dangerously-skip-permissions 跳過所有權限檢查\n --allowedTools <tools...> 允許的工具列表\n --disallowedTools <tools...> 禁止的工具列表\n --system-prompt <prompt> 會話系統提示詞\n --append-system-prompt <prompt> 追加系統提示詞\n --mcp-config <configs...> 載入 MCP 伺服器設定\n --permission-mode <mode> 權限模式\n --add-dir <directories...> 額外允許存取的目錄\n --max-budget-usd <amount> API 呼叫最大預算(僅 --print)\n --output-format <format> 輸出格式(僅 --print): text, json, stream-json\n --json-schema <schema> 結構化輸出的 JSON Schema\n --verbose 詳細模式\n -h, --help 顯示說明\n -v, --version 顯示版本\n\n 更多選項請參考: claude --help\n\n範例:\n ccv 啟動互動模式\n ccv -c 繼續上次對話\n ccv -r 恢復對話\n ccv -p \"hello\" 列印模式\n ccv --model opus 指定模型\n ccv --d 跳過權限確認(快捷方式)\n ccv -c --model sonnet --effort max 組合使用\n ccv -logger 安裝/修復 Hook"
168
168
  },
169
169
  "cli.cMode.notFound": {
170
170
  "zh": "错误: 未找到 claude 命令,请确认已安装 Claude Code",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-viewer",
3
- "version": "1.5.18",
3
+ "version": "1.5.19",
4
4
  "description": "Claude Code Logger visualization management tool",
5
5
  "license": "MIT",
6
6
  "main": "server.js",
package/proxy.js CHANGED
@@ -4,6 +4,7 @@ import { readFileSync, existsSync } from 'node:fs';
4
4
  import { join } from 'node:path';
5
5
  import { homedir } from 'node:os';
6
6
  import { setupInterceptor } from './interceptor.js';
7
+ import { extractApiErrorMessage, formatProxyRequestError } from './proxy-errors.js';
7
8
 
8
9
  // Setup interceptor to patch fetch
9
10
  setupInterceptor();
@@ -98,19 +99,7 @@ export function startProxy() {
98
99
  if (!response.ok) {
99
100
  try {
100
101
  const errorText = await response.text();
101
- try {
102
- const errorJson = JSON.parse(errorText);
103
- // 提取 Anthropic 格式的错误信息
104
- if (errorJson.error && errorJson.error.message) {
105
- console.error(`[CC-Viewer Proxy] API Error: ${errorJson.error.message}`);
106
- } else if (errorJson.message) {
107
- console.error(`[CC-Viewer Proxy] API Error: ${errorJson.message}`);
108
- } else {
109
- console.error(`[CC-Viewer Proxy] API Error (${response.status}): ${errorText.slice(0, 200)}`);
110
- }
111
- } catch {
112
- console.error(`[CC-Viewer Proxy] API Error (${response.status}): ${errorText.slice(0, 200)}`);
113
- }
102
+ console.error(`[CC-Viewer Proxy] ${extractApiErrorMessage(response.status, errorText)}`);
114
103
 
115
104
  res.writeHead(response.status, responseHeaders);
116
105
  res.end(errorText);
@@ -143,14 +132,7 @@ export function startProxy() {
143
132
  if (process.env.CCV_DEBUG) {
144
133
  console.error('[CC-Viewer Proxy] Error:', err);
145
134
  } else {
146
- // Format concise error message
147
- let msg = err.message;
148
- if (err.cause) msg += ` (${err.cause.message || err.cause.code || err.cause})`;
149
- // Shorten common timeout errors
150
- if (msg.includes('HEADERS_TIMEOUT')) msg = 'Upstream headers timeout';
151
- if (msg.includes('BODY_TIMEOUT')) msg = 'Upstream body timeout';
152
-
153
- console.error(`[CC-Viewer Proxy] Request failed: ${msg}`);
135
+ console.error(formatProxyRequestError(err));
154
136
  }
155
137
 
156
138
  res.statusCode = 502;