aico-cli 0.4.9 → 0.5.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.
@@ -13,7 +13,7 @@ import { join as join$1 } from 'node:path';
13
13
  import { join, dirname, basename } from 'pathe';
14
14
  import { fileURLToPath } from 'node:url';
15
15
 
16
- const version = "0.4.9";
16
+ const version = "0.5.0";
17
17
 
18
18
  function displayBanner(subtitle) {
19
19
  const defaultSubtitle = "\u4E00\u952E\u914D\u7F6E\u4F60\u7684\u5F00\u53D1\u73AF\u5883";
package/dist/cli.mjs CHANGED
@@ -329,6 +329,22 @@ class ProcessManager extends EventEmitter {
329
329
  }
330
330
  return report;
331
331
  }
332
+ /**
333
+ * 获取适用于当前平台的命令路径
334
+ */
335
+ getPlatformCommand(command) {
336
+ const isWindows = process.platform === "win32";
337
+ if (isWindows) {
338
+ const commandMappings = {
339
+ "npm": "npm.cmd",
340
+ "npx": "npx.cmd",
341
+ "node": "node.exe",
342
+ "claude": "claude.cmd"
343
+ };
344
+ return commandMappings[command] || command;
345
+ }
346
+ return command;
347
+ }
332
348
  /**
333
349
  * 强制清理僵尸进程(状态为运行中但实际已退出的进程)
334
350
  */
@@ -362,18 +378,32 @@ class ProcessManager extends EventEmitter {
362
378
  async replaceProcess(command, args = [], options = {}) {
363
379
  const processName = options.name || command;
364
380
  try {
365
- this.log(`\u6E05\u7406 ${this.processes.size} \u4E2A\u7BA1\u7406\u8FDB\u7A0B...`, "info");
366
381
  this.cleanup();
367
382
  const { spawn: spawn2 } = await import('node:child_process');
368
- const child = spawn2(command, args, {
383
+ const isWindows = process.platform === "win32";
384
+ let finalCommand = this.getPlatformCommand(command);
385
+ let finalArgs = args;
386
+ const spawnOptions = {
369
387
  stdio: "inherit",
370
388
  // 继承所有 stdio
371
389
  cwd: options.cwd || process.cwd(),
372
390
  env: { ...process.env, ...options.env },
373
- shell: options.shell || process.platform === "win32"
374
- // 移除 detached: true,避免子进程脱离管理
375
- // detached: false 是默认值,子进程会随着父进程退出而退出
376
- });
391
+ windowsHide: isWindows
392
+ // Windows上隐藏子进程窗口
393
+ };
394
+ if (isWindows) {
395
+ if (finalCommand.endsWith(".cmd")) {
396
+ spawnOptions.shell = true;
397
+ const fullCommand = `${finalCommand} ${finalArgs.join(" ")}`;
398
+ finalCommand = fullCommand;
399
+ finalArgs = [];
400
+ } else {
401
+ spawnOptions.shell = false;
402
+ }
403
+ } else {
404
+ spawnOptions.shell = false;
405
+ }
406
+ const child = spawn2(finalCommand, finalArgs, spawnOptions);
377
407
  child.on("error", (error) => {
378
408
  this.log(`\u8FDB\u7A0B\u66FF\u6362\u5931\u8D25: ${error}`, "error");
379
409
  process.exit(1);
@@ -502,15 +532,15 @@ promisify$1(exec$1);
502
532
  promisify$1(exec$1);
503
533
 
504
534
  async function tryStartClaude(command, args, options) {
505
- const isWindows = process.platform === "win32";
506
- await processManager.replaceProcess(command, args, {
535
+ process.platform === "win32";
536
+ const spawnOptions = {
507
537
  name: "Claude Code",
508
- cwd: options.cwd,
509
- stdio: "inherit",
538
+ cwd: options.cwd || process.cwd(),
539
+ stdio: "inherit"
510
540
  // 必须继承 stdio 才能正确交互
511
- shell: isWindows ? false : options.shell
512
- // Windows上禁用shell避免进程泄漏
513
- });
541
+ // shell选项由processManager内部处理
542
+ };
543
+ await processManager.replaceProcess(command, args, spawnOptions);
514
544
  }
515
545
  async function startClaudeCodeEditor(_lang) {
516
546
  try {
@@ -526,7 +556,7 @@ async function startClaudeCodeEditor(_lang) {
526
556
  };
527
557
  try {
528
558
  const command = isWindows ? "claude.cmd" : "claude";
529
- const args = ["--dangerously-skip-permissions"];
559
+ const args = [];
530
560
  if (isWindows) {
531
561
  await tryStartClaude(command, args, spawnOptions);
532
562
  } else {
@@ -537,7 +567,7 @@ async function startClaudeCodeEditor(_lang) {
537
567
  if (firstError.code === "ENOENT") {
538
568
  console.log(ansis.yellow("\u26A0\uFE0F \u76F4\u63A5\u8C03\u7528 claude \u5931\u8D25\uFF0C\u5C1D\u8BD5\u4F7F\u7528 npx..."));
539
569
  try {
540
- const npxArgs = ["@anthropic-ai/claude-code", "--dangerously-skip-permissions"];
570
+ const npxArgs = ["@anthropic-ai/claude-code"];
541
571
  if (isWindows) {
542
572
  await tryStartClaude("npx.cmd", npxArgs, spawnOptions);
543
573
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aico-cli",
3
- "version": "0.4.9",
3
+ "version": "0.5.0",
4
4
  "packageManager": "pnpm@9.15.9",
5
5
  "description": "AI CLI",
6
6
  "repository": {