@ia-ccun/code-agent-cli 0.0.54-beta.5 → 0.0.54-beta.8
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 +10 -23
- package/config/agent/extensions/aicode-banner.ts +12 -14
- package/config/agent/extensions/custom-footer.ts +2 -22
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- 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 +19 -15
- package/scripts/regression/results/03-prompt-stream.log +19 -12
- package/scripts/regression/results/03-rpc-protocol.log +21 -16
- 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 +66 -23
- package/scripts/regression/results/08-cwd-resilience.log +1 -1
- package/dist/banner.d.ts +0 -15
- package/dist/banner.d.ts.map +0 -1
- package/dist/banner.js +0 -146
- package/dist/banner.js.map +0 -1
package/bin/cli.js
CHANGED
|
@@ -8,29 +8,19 @@
|
|
|
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 { homedir } from "node:os";
|
|
17
|
+
|
|
18
|
+
// 防御 cwd 被删: chdir 到 PWD env (用户启动目录) 或 home, 防 ENOENT
|
|
33
19
|
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
+
try {
|
|
21
|
+
process.chdir(process.env.PWD || homedir());
|
|
22
|
+
} catch {}
|
|
23
|
+
|
|
34
24
|
const __dirname = dirname(__filename);
|
|
35
25
|
|
|
36
26
|
// 获取本地版本号
|
|
@@ -71,8 +61,8 @@ function parseArgs() {
|
|
|
71
61
|
try {
|
|
72
62
|
const { version } = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
73
63
|
console.log(version);
|
|
74
|
-
} catch
|
|
75
|
-
//
|
|
64
|
+
} catch {
|
|
65
|
+
// package.json 不可读, 静默退出
|
|
76
66
|
}
|
|
77
67
|
}
|
|
78
68
|
process.exit(0);
|
|
@@ -167,9 +157,6 @@ replaceCLIVersionPlaceholder();
|
|
|
167
157
|
const localVersion = getLocalVersion();
|
|
168
158
|
process.env.AICODE_CLI_VERSION = localVersion || "";
|
|
169
159
|
|
|
170
|
-
// banner 启动后打印已移交给 config/agent/extensions/aicode-banner.ts
|
|
171
|
-
// 理由: 1) 避免 RPC 父进程的 stdout JSON-RPC 污染; 2) chdir 到 homedir 后再触发更稳
|
|
172
|
-
|
|
173
160
|
async function checkForUpdates() {
|
|
174
161
|
try {
|
|
175
162
|
const { execFileSync } = await import("child_process");
|
|
@@ -64,24 +64,21 @@ function buildBanner(themeColor: string, version: string): string {
|
|
|
64
64
|
`${color(bold("AICODE CLI"))} ${dim(`v${version}`)}`,
|
|
65
65
|
`${dim("Dir:")} ${dim(cwd)}`,
|
|
66
66
|
"",
|
|
67
|
-
dim(
|
|
68
|
-
"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -",
|
|
69
|
-
),
|
|
70
|
-
dim(
|
|
71
|
-
" 直接用自然语言描述需求即可 • 复杂任务先用 /plan 生成计划 • @文件路径 指定文件",
|
|
72
|
-
),
|
|
73
|
-
dim(
|
|
74
|
-
"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -",
|
|
75
|
-
),
|
|
76
|
-
"",
|
|
77
67
|
bold(" 常用命令"),
|
|
78
68
|
` ${color("/model")} 切换模型 ${color("/settings")} 设置 ${color("/compact")} 压缩上下文`,
|
|
79
69
|
` ${color("/new")} 新会话 ${color("/reload")} 重载配置 ${color("/resume")} 恢复会话`,
|
|
80
70
|
` ${color("/plan")} 计划模式(只读) ${color("/bugs")} 已知bug修复 ${color("/goal")} 目标导向`,
|
|
81
71
|
"",
|
|
82
|
-
bold("
|
|
83
|
-
` ${color("/workflow")} 六阶段工作流 ${color("/
|
|
84
|
-
` ${color("/
|
|
72
|
+
bold(" 常用提示词 (Prompts)"),
|
|
73
|
+
` ${color("/workflow")} 六阶段工作流 ${color("/feat")} 新功能开发 ${color("/git-commit")} Git提交`,
|
|
74
|
+
` ${color("/code-simplifier")} 代码简化 ${color("/init-project")} 项目初始化`,
|
|
75
|
+
"",
|
|
76
|
+
bold(" 常用技能 (Skills)"),
|
|
77
|
+
` ${color("/code-review")} 代码审查 ${color("/skill-creator")} 创建技能 ${color("/commit")} Git提交`,
|
|
78
|
+
` ${color("/frontend-design")} 前端设计 ${color("/brainstorming")} 头脑风暴`,
|
|
79
|
+
"",
|
|
80
|
+
dim(" 安装或更新 npm i -g @ia-ccun/code-agent-cli"),
|
|
81
|
+
"",
|
|
85
82
|
].join("\n");
|
|
86
83
|
}
|
|
87
84
|
|
|
@@ -96,6 +93,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
96
93
|
// 没有 TUI (纯 RPC/JSON 模式) 不打印 — 不污染 JSON 输出
|
|
97
94
|
if (!ctx.hasUI) return;
|
|
98
95
|
|
|
99
|
-
|
|
96
|
+
const ansi = /\x1b\[[\d;]*m/g;
|
|
97
|
+
ctx.ui.notify(buildBanner(themeColor, version).replace(ansi, ""), "info");
|
|
100
98
|
});
|
|
101
99
|
}
|
|
@@ -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/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* AI Coding Agent CLI
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
|
-
export * from
|
|
7
|
-
export { defaultConfig, type AppConfig } from
|
|
8
|
-
export { getConfig, getConfigDir, loadConfig } from
|
|
9
|
-
export { defaultBanner, generateBanner } from './banner.js';
|
|
6
|
+
export * from "@earendil-works/pi-coding-agent";
|
|
7
|
+
export { defaultConfig, type AppConfig } from "./config.js";
|
|
8
|
+
export { getConfig, getConfigDir, loadConfig } from "./config-loader.js";
|
|
10
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,iCAAiC,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,iCAAiC,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
* AI Coding Agent CLI
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
|
-
export * from
|
|
6
|
+
export * from "@earendil-works/pi-coding-agent";
|
|
7
7
|
// 导出配置相关
|
|
8
|
-
export { defaultConfig } from
|
|
9
|
-
export { getConfig, getConfigDir, loadConfig } from
|
|
10
|
-
// 导出 Banner
|
|
11
|
-
export { defaultBanner, generateBanner } from './banner.js';
|
|
8
|
+
export { defaultConfig } from "./config.js";
|
|
9
|
+
export { getConfig, getConfigDir, loadConfig } from "./config-loader.js";
|
|
12
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,iCAAiC,CAAC;AAEhD,SAAS;AACT,OAAO,EAAE,aAAa,EAAkB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,iCAAiC,CAAC;AAEhD,SAAS;AACT,OAAO,EAAE,aAAa,EAAkB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
22417
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/Users/jianjiang/.aicode-regression-
|
|
1
|
+
/Users/jianjiang/.aicode-regression-22195-3854000
|