@ia-ccun/code-agent-cli 0.0.54-beta.4 → 0.0.54-beta.7
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 +21 -21
- package/config/agent/extensions/aicode-banner.ts +2 -1
- package/config/agent/extensions/custom-footer.ts +2 -22
- package/package.json +1 -1
- package/scripts/regression/results/.last_pid +1 -1
- package/scripts/regression/results/.last_workdir +1 -1
- package/scripts/regression/results/02-extension-loading.log +20 -15
- package/scripts/regression/results/03-prompt-stream.log +16 -12
- package/scripts/regression/results/03-rpc-protocol.log +20 -18
- package/scripts/regression/results/04-slash-commands-and-skills.log +11 -11
- package/scripts/regression/results/05-tool-execution.log +5 -5
- package/scripts/regression/results/06-pi-new-features.log +27 -17
- package/scripts/regression/results/08-cwd-resilience.log +1 -1
package/bin/cli.js
CHANGED
|
@@ -8,29 +8,20 @@
|
|
|
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
|
-
|
|
28
11
|
import { spawn } from "child_process";
|
|
29
12
|
import { fileURLToPath } from "url";
|
|
30
13
|
import { dirname, join } from "path";
|
|
31
14
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
32
|
-
import { getConfig, loadConfig } from "../dist/config-loader.js";
|
|
15
|
+
import { getConfig, getConfigDir, loadConfig } from "../dist/config-loader.js";
|
|
16
|
+
import { generateBanner } from "../dist/banner.js";
|
|
17
|
+
import { homedir } from "node:os";
|
|
18
|
+
|
|
19
|
+
// 防御 cwd 被删: chdir 到 PWD env (用户启动目录) 或 home, 防 ENOENT
|
|
33
20
|
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
try {
|
|
22
|
+
process.chdir(process.env.PWD || homedir());
|
|
23
|
+
} catch {}
|
|
24
|
+
|
|
34
25
|
const __dirname = dirname(__filename);
|
|
35
26
|
|
|
36
27
|
// 获取本地版本号
|
|
@@ -71,7 +62,10 @@ function parseArgs() {
|
|
|
71
62
|
try {
|
|
72
63
|
const { version } = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
73
64
|
console.log(version);
|
|
74
|
-
} catch
|
|
65
|
+
} catch {
|
|
66
|
+
// package.json 不可读, 静默退出
|
|
67
|
+
}
|
|
68
|
+
}
|
|
75
69
|
process.exit(0);
|
|
76
70
|
}
|
|
77
71
|
|
|
@@ -164,8 +158,14 @@ replaceCLIVersionPlaceholder();
|
|
|
164
158
|
const localVersion = getLocalVersion();
|
|
165
159
|
process.env.AICODE_CLI_VERSION = localVersion || "";
|
|
166
160
|
|
|
167
|
-
//
|
|
168
|
-
|
|
161
|
+
// ponytail: RPC 父进程把我们的 stdout 当 JSON-RPC 流读,banner 会污染输出
|
|
162
|
+
const isRpcMode = remainingArgs.some(
|
|
163
|
+
(a, i) =>
|
|
164
|
+
(a === "--mode" && remainingArgs[i + 1] === "rpc") || a === "--mode=rpc",
|
|
165
|
+
);
|
|
166
|
+
if ((config.banner === "__default__" || config.banner !== "") && !isRpcMode) {
|
|
167
|
+
console.log(generateBanner(config.themeColor));
|
|
168
|
+
}
|
|
169
169
|
|
|
170
170
|
async function checkForUpdates() {
|
|
171
171
|
try {
|
|
@@ -96,6 +96,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
96
96
|
// 没有 TUI (纯 RPC/JSON 模式) 不打印 — 不污染 JSON 输出
|
|
97
97
|
if (!ctx.hasUI) return;
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
const ansi = /\x1b\[[\d;]*m/g;
|
|
100
|
+
ctx.ui.notify(buildBanner(themeColor, version).replace(ansi, ""), "info");
|
|
100
101
|
});
|
|
101
102
|
}
|
|
@@ -6,30 +6,10 @@
|
|
|
6
6
|
* [gold] [dim] [dim] [color ctx] [accent]
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { basename } from "node:path";
|
|
10
9
|
import type { AssistantMessage } from "@earendil-works/pi-ai";
|
|
11
10
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
12
11
|
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
13
12
|
|
|
14
|
-
/**
|
|
15
|
-
* 解析 footer 显示用的项目名.
|
|
16
|
-
* 优先用 process.env.PWD (shell 启动时设进 env, cli.js 入口 chdir(homedir()) 也不改它),
|
|
17
|
-
* 退化到 process.cwd(). /user/xxx 启动显示 xxx, 跟 git 无关.
|
|
18
|
-
* cwd 被删时 fallback 到 'project'.
|
|
19
|
-
*/
|
|
20
|
-
function resolveProjectName(): string {
|
|
21
|
-
const pwd = process.env.PWD;
|
|
22
|
-
if (pwd) {
|
|
23
|
-
const name = basename(pwd);
|
|
24
|
-
if (name) return name;
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
return basename(process.cwd()) || "project";
|
|
28
|
-
} catch {
|
|
29
|
-
return "project";
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
13
|
function fmtTokens(n: number): string {
|
|
34
14
|
if (n < 1000) return n.toString();
|
|
35
15
|
if (n < 10000) return `${(n / 1000).toFixed(1)}k`;
|
|
@@ -88,8 +68,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
88
68
|
const sepWidth = 3; // " │ "
|
|
89
69
|
|
|
90
70
|
// ── Segment 1: project name (branch) ─────────────────────
|
|
91
|
-
|
|
92
|
-
const projectName =
|
|
71
|
+
const pwd = process.cwd();
|
|
72
|
+
const projectName = pwd.split("/").pop() || "project";
|
|
93
73
|
const branch = footerData.getGitBranch();
|
|
94
74
|
const pathRaw = projectName + (branch ? ` (${branch})` : "");
|
|
95
75
|
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
10335
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/Users/jianjiang/.aicode-regression-
|
|
1
|
+
/Users/jianjiang/.aicode-regression-10113-1681000
|