@ia-ccun/code-agent-cli 0.0.54-beta.9 → 0.0.54

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/bin/cli.js CHANGED
@@ -8,19 +8,30 @@
8
8
  // 设置终端标题
9
9
  process.title = "aicode-cli";
10
10
 
11
+ // 防御 CWD 被删: 在所有 import 之前 chdir (node ESM 解析 import 时会读 cwd)
12
+ // 不 import os.homedir() 因为那需要模块解析, 此时 cwd 还没改
13
+ // 用 process.env.PWD 优先 (用户启动目录) → HOME fallback (防 PWD 缺失 ENOENT)
14
+ // 先 PWD 试 (用户启动目录), 失败 fallback HOME (cwd 被删时 PWD 也指向已删目录, chdir 会抛 ENOENT)
15
+ // catch 后再退一步: HOME 也失败则 chdir 到 / (绝对保证不会 ENOENT)
16
+ try {
17
+ process.chdir(process.env.PWD);
18
+ } catch {
19
+ try {
20
+ process.chdir(process.env.HOME || "/");
21
+ } catch {
22
+ try {
23
+ process.chdir("/");
24
+ } catch {}
25
+ }
26
+ }
27
+
11
28
  import { spawn } from "child_process";
12
29
  import { fileURLToPath } from "url";
13
30
  import { dirname, join } from "path";
14
31
  import { existsSync, readFileSync, writeFileSync } from "fs";
15
32
  import { getConfig, getConfigDir, loadConfig } from "../dist/config-loader.js";
16
- import { homedir } from "node:os";
17
33
 
18
- // 防御 cwd 被删: chdir 到 PWD env (用户启动目录) 或 home, 防 ENOENT
19
34
  const __filename = fileURLToPath(import.meta.url);
20
- try {
21
- process.chdir(process.env.PWD || homedir());
22
- } catch {}
23
-
24
35
  const __dirname = dirname(__filename);
25
36
 
26
37
  // 获取本地版本号
@@ -157,6 +168,7 @@ replaceCLIVersionPlaceholder();
157
168
  const localVersion = getLocalVersion();
158
169
  process.env.AICODE_CLI_VERSION = localVersion || "";
159
170
 
171
+
160
172
  async function checkForUpdates() {
161
173
  try {
162
174
  const { execFileSync } = await import("child_process");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ia-ccun/code-agent-cli",
3
- "version": "0.0.54-beta.9",
3
+ "version": "0.0.54",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1 +1 @@
1
- 37854
1
+ 72167
@@ -1 +1 @@
1
- /Users/jianjiang/.aicode-regression-37636-6046000
1
+ /Users/jianjiang/.aicode-regression-72044-1696000