cc-viewer 1.6.299 → 1.6.300

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/cli.js CHANGED
@@ -593,79 +593,6 @@ const url = `${protocol}://127.0.0.1:${port}${basePath}`;
593
593
  process.on('SIGTERM', cleanup);
594
594
  }
595
595
 
596
- async function runCliModeWorkspaceSelector(extraClaudeArgs = [], noOpen = false) {
597
- // 首先尝试 npm 版本(包括 nvm 安装),找不到再尝试 native 版本
598
- let claudePath = resolveNpmClaudePath();
599
- let isNpmVersion = !!claudePath;
600
-
601
- if (!claudePath) {
602
- claudePath = resolveNativePath();
603
- }
604
-
605
- if (!claudePath) {
606
- reportClaudeNotFound(cliPath);
607
- process.exit(1);
608
- }
609
-
610
- console.log(t('cli.cMode.starting'));
611
-
612
- process.env.CCV_CLI_MODE = '1';
613
- process.env.CCV_WORKSPACE_MODE = '1';
614
-
615
- // 启动代理
616
- const { startProxy } = await import('./server/proxy.js');
617
- const proxyPort = await startProxy();
618
- process.env.CCV_PROXY_PORT = String(proxyPort);
619
-
620
- // 启动 HTTP 服务器(工作区模式,不初始化 interceptor 日志)
621
- const serverMod = await import('./server/server.js');
622
-
623
- // 工作区模式下 server.js 跳过了自动启动,需要手动调用
624
- await serverMod.startViewer();
625
-
626
- const port = serverMod.getPort();
627
-
628
- // 保存 extraClaudeArgs 和 claudePath 供后续 launch 使用
629
- serverMod.setWorkspaceClaudeArgs(extraClaudeArgs);
630
- serverMod.setWorkspaceClaudePath(claudePath, isNpmVersion);
631
-
632
- // 自动打开浏览器
633
- const basePath = process.env.CCV_BASE_PATH || '';
634
- const wsProtocol = serverMod.getProtocol();
635
- const url = `${wsProtocol}://127.0.0.1:${port}${basePath}`;
636
- if (!noOpen) {
637
- try {
638
- // URL 含 & 在 cmd.exe 下会被当命令分隔符切断 query;用 spawn 数组传参避免 shell interpolation。
639
- // Win 上 `start` 是 cmd.exe 内置不是 .exe,必须 shell:true;用 spawn + 数组让 Node 自己 escape。
640
- // 第二个 arg '""' 是 `start` 的 window-title 占位(否则 start 会把 URL 当 title)。
641
- const { spawn } = await import('node:child_process');
642
- if (process.platform === 'win32') {
643
- spawn('cmd.exe', ['/c', 'start', '""', url], { stdio: 'ignore', detached: true, windowsHide: true }).unref();
644
- } else {
645
- const cmd = process.platform === 'darwin' ? 'open' : 'xdg-open';
646
- spawn(cmd, [url], { stdio: 'ignore', detached: true }).unref();
647
- }
648
- } catch {}
649
- }
650
-
651
- console.log(`CC Viewer (Workspace):`);
652
- console.log(` ➜ Local: ${url}`);
653
- const _lanIps = serverMod.getAllLocalIps();
654
- const _token = serverMod.getAccessToken();
655
- for (const _ip of _lanIps) {
656
- console.log(` ➜ Network: ${wsProtocol}://${_ip}:${port}${basePath}?token=${_token}`);
657
- }
658
-
659
- // 注册退出处理
660
- const { killPty } = await import('./server/pty-manager.js');
661
- const cleanup = () => {
662
- killPty();
663
- serverMod.stopViewer().finally(() => process.exit());
664
- };
665
- process.on('SIGINT', cleanup);
666
- process.on('SIGTERM', cleanup);
667
- }
668
-
669
596
  // === 主逻辑 ===
670
597
 
671
598
  const args = process.argv.slice(2);