cc-viewer 1.4.21 → 1.4.23
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 +22 -7
- package/dist/assets/{index-DVJLme9U.js → index-Cy1FKik6.js} +54 -54
- package/dist/index.html +1 -1
- package/findcc.js +48 -0
- package/lib/plugin-loader.js +20 -1
- package/package.json +1 -1
- package/pty-manager.js +15 -5
- package/server.js +7 -1
package/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
6
6
|
import { homedir } from 'node:os';
|
|
7
7
|
import { spawn } from 'node:child_process';
|
|
8
8
|
import { t } from './i18n.js';
|
|
9
|
-
import { INJECT_IMPORT, resolveCliPath, resolveNativePath, buildShellCandidates } from './findcc.js';
|
|
9
|
+
import { INJECT_IMPORT, resolveCliPath, resolveNativePath, resolveNpmClaudePath, buildShellCandidates } from './findcc.js';
|
|
10
10
|
|
|
11
11
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
12
12
|
|
|
@@ -233,8 +233,15 @@ async function runProxyCommand(args) {
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
async function runCliMode(extraClaudeArgs = [], cwd) {
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
// 首先尝试 npm 版本(包括 nvm 安装),找不到再尝试 native 版本
|
|
237
|
+
let claudePath = resolveNpmClaudePath();
|
|
238
|
+
let isNpmVersion = !!claudePath;
|
|
239
|
+
|
|
240
|
+
if (!claudePath) {
|
|
241
|
+
claudePath = resolveNativePath();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (!claudePath) {
|
|
238
245
|
console.error(t('cli.cMode.notFound'));
|
|
239
246
|
process.exit(1);
|
|
240
247
|
}
|
|
@@ -276,7 +283,7 @@ async function runCliMode(extraClaudeArgs = [], cwd) {
|
|
|
276
283
|
// 3. 启动 PTY 中的 claude
|
|
277
284
|
const { spawnClaude, killPty } = await import('./pty-manager.js');
|
|
278
285
|
try {
|
|
279
|
-
await spawnClaude(proxyPort, workingDir, extraClaudeArgs);
|
|
286
|
+
await spawnClaude(proxyPort, workingDir, extraClaudeArgs, claudePath, isNpmVersion);
|
|
280
287
|
} catch (err) {
|
|
281
288
|
console.error('[CC Viewer] Failed to spawn Claude:', err.message);
|
|
282
289
|
serverMod.stopViewer();
|
|
@@ -304,8 +311,15 @@ async function runCliMode(extraClaudeArgs = [], cwd) {
|
|
|
304
311
|
}
|
|
305
312
|
|
|
306
313
|
async function runCliModeWorkspaceSelector(extraClaudeArgs = []) {
|
|
307
|
-
|
|
308
|
-
|
|
314
|
+
// 首先尝试 npm 版本(包括 nvm 安装),找不到再尝试 native 版本
|
|
315
|
+
let claudePath = resolveNpmClaudePath();
|
|
316
|
+
let isNpmVersion = !!claudePath;
|
|
317
|
+
|
|
318
|
+
if (!claudePath) {
|
|
319
|
+
claudePath = resolveNativePath();
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (!claudePath) {
|
|
309
323
|
console.error(t('cli.cMode.notFound'));
|
|
310
324
|
process.exit(1);
|
|
311
325
|
}
|
|
@@ -328,8 +342,9 @@ async function runCliModeWorkspaceSelector(extraClaudeArgs = []) {
|
|
|
328
342
|
|
|
329
343
|
const port = serverMod.getPort();
|
|
330
344
|
|
|
331
|
-
// 保存 extraClaudeArgs 供后续 launch 使用
|
|
345
|
+
// 保存 extraClaudeArgs 和 claudePath 供后续 launch 使用
|
|
332
346
|
serverMod.setWorkspaceClaudeArgs(extraClaudeArgs);
|
|
347
|
+
serverMod.setWorkspaceClaudePath(claudePath, isNpmVersion);
|
|
333
348
|
|
|
334
349
|
// 自动打开浏览器
|
|
335
350
|
const url = `http://127.0.0.1:${port}`;
|