@lark-codem/codem-cli 0.1.180-lark-cli-scope-upgrade.202608240736.0.g21ff8f7 → 0.1.180
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/codem.js +73 -3
- package/package.json +8 -7
package/bin/codem.js
CHANGED
|
@@ -52,6 +52,31 @@ function resolvePlatformBinary() {
|
|
|
52
52
|
// 会被 Node 降级成异步 `error` 事件,其余 errno(ENOEXEC / ENOTDIR / EPERM,以及
|
|
53
53
|
// Windows 上杀软 / EDR 拦截 CreateProcessW 时 libuv 报的 UNKNOWN=-4094)在
|
|
54
54
|
// `child_process.spawn()` 里直接 `throw new ErrnoException(err, 'spawn')`。
|
|
55
|
+
// stderr 同步写。本文件里每一条诊断后面都紧跟 process.exit,而 process.exit()
|
|
56
|
+
// 按 Node 官方契约会**放弃尚未完成的 stdout/stderr I/O**("a note on process I/O")。
|
|
57
|
+
// stderr 是否同步取决于它接的是什么:
|
|
58
|
+
// Files —— Windows / POSIX 均同步
|
|
59
|
+
// Pipes —— Windows / POSIX 均同步
|
|
60
|
+
// TTY —— POSIX 同步,**Windows 异步**
|
|
61
|
+
// 最需要这些诊断的现场恰恰落在唯一异步的那格:用户在 PowerShell 里交互式敲
|
|
62
|
+
// codem,stderr 就是 Windows TTY。走 console.error 时诊断可能被截断甚至整条丢失,
|
|
63
|
+
// 用户继续看到「零输出」——正是本次修复要消灭的现象,等于修了个寂寞。
|
|
64
|
+
// fs.writeSync 绕过流缓冲直接写 fd,返回即已落地,不受 process.exit 影响。
|
|
65
|
+
function writeStderrSync(message) {
|
|
66
|
+
const line = `${message}\n`;
|
|
67
|
+
try {
|
|
68
|
+
fs.writeSync(process.stderr.fd, line);
|
|
69
|
+
} catch {
|
|
70
|
+
// fd 已关闭 / EPIPE 等场景下不能再抛:诊断本身不该变成新的失败源。
|
|
71
|
+
// 退回流式写尽力而为——此时能不能送达已不由本进程决定。
|
|
72
|
+
try {
|
|
73
|
+
process.stderr.write(line);
|
|
74
|
+
} catch {
|
|
75
|
+
// 到这里已无可用错误通道,只能放弃。
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
55
80
|
// 两条出口必须汇到同一个 reporter:只挂 child.on("error") 的话,后一类失败会以
|
|
56
81
|
// 一段指向 node:internal/child_process 的裸栈抛给用户——codem-cli 的平台二进制是
|
|
57
82
|
// bun --compile 出来的未签名可执行文件,Windows 上被拦截是真实可达路径。
|
|
@@ -70,10 +95,51 @@ function reportSpawnFailure(targetPath, error) {
|
|
|
70
95
|
"codem: 操作系统给出的错误会比这里的 spawn 报错具体得多。"
|
|
71
96
|
);
|
|
72
97
|
}
|
|
73
|
-
|
|
98
|
+
writeStderrSync(lines.join("\n"));
|
|
74
99
|
process.exit(1);
|
|
75
100
|
}
|
|
76
101
|
|
|
102
|
+
// Windows NTSTATUS 翻译。0xC0000000 以上是内核致命错误码:进程在 main 之前就被
|
|
103
|
+
// 杀掉,stdio 里不会有任何字节。不翻译的话用户侧现象是「敲 codem 完全没反应」,
|
|
104
|
+
// 连一条能拿去搜的错误串都没有——实测一例 AVX2 缺失,PATH / launcher / 指针 /
|
|
105
|
+
// 运行时四层全部正常,三层把同一个退出码原样透传上来,用户完全无从判断断在哪。
|
|
106
|
+
// 这里只往 stderr 补一条说明,退出码仍原样透传,不改变对上游的语义。
|
|
107
|
+
//
|
|
108
|
+
// code 的符号表示两可:libuv 从 GetExitCodeProcess 拿到的是 DWORD,Node 侧多为
|
|
109
|
+
// 正数(0xC000001D → 3221225501),而 shell 常按 int32 显示(-1073741795)。
|
|
110
|
+
// `>>> 0` 把两种表示归一到同一个无符号值,避免只判其中一种而漏掉。
|
|
111
|
+
function explainWindowsFatalStatus(code) {
|
|
112
|
+
if (process.platform !== "win32" || typeof code !== "number") {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const status = code >>> 0;
|
|
116
|
+
if (status < 0xc0000000) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const detail = {
|
|
120
|
+
0xc000001d: [
|
|
121
|
+
"STATUS_ILLEGAL_INSTRUCTION:CPU 不支持二进制中用到的指令集,最常见是缺少 AVX2。",
|
|
122
|
+
"注意「年份新」不代表有 AVX2:Intel 在 Pentium Gold / Celeron 整条产品线上熔断了",
|
|
123
|
+
"AVX/AVX2(如 2020 年的 Pentium Gold G6400);Atom / Gemini Lake、Sandy/Ivy Bridge",
|
|
124
|
+
"以及屏蔽 AVX2 的虚拟化环境同理。请升级到使用 baseline 产线的 CodeM 版本。",
|
|
125
|
+
"自查(PowerShell,返回 False 即无 AVX2):",
|
|
126
|
+
" Add-Type -Namespace W -Name K -MemberDefinition '[DllImport(\"kernel32.dll\")] public static extern bool IsProcessorFeaturePresent(uint f);'",
|
|
127
|
+
" [W.K]::IsProcessorFeaturePresent(40)"
|
|
128
|
+
],
|
|
129
|
+
0xc0000005: ["STATUS_ACCESS_VIOLATION:二进制崩溃(段错误)。请重装 CodeM CLI,仍复现请反馈。"],
|
|
130
|
+
0xc0000022: ["STATUS_ACCESS_DENIED:进程被拒绝执行,通常是杀毒软件 / EDR 拦截。请把 CodeM 安装目录加入白名单。"],
|
|
131
|
+
0xc000007b: ["STATUS_INVALID_IMAGE_FORMAT:可执行文件架构与系统不匹配(x64 / ARM64 错配)。请重装 CodeM CLI。"],
|
|
132
|
+
0xc0000135: ["STATUS_DLL_NOT_FOUND:缺少运行时 DLL,通常需要安装 Microsoft Visual C++ 运行库。"],
|
|
133
|
+
0xc0000142: ["STATUS_DLL_INIT_FAILED:运行时 DLL 初始化失败,常见于被安全软件注入的进程。"],
|
|
134
|
+
0xc0000409: ["STATUS_STACK_BUFFER_OVERRUN:进程被安全检查主动终止。请重装 CodeM CLI,仍复现请反馈。"]
|
|
135
|
+
}[status];
|
|
136
|
+
const hex = `0x${status.toString(16).toUpperCase().padStart(8, "0")}`;
|
|
137
|
+
return [
|
|
138
|
+
`codem: CLI 二进制被系统终止,NTSTATUS=${hex}(进程在启动阶段被杀,因此没有任何输出)。`,
|
|
139
|
+
...(detail ?? ["未知的 Windows 致命错误码,请带上该 NTSTATUS 反馈。"]).map((line) => `codem: ${line}`)
|
|
140
|
+
].join("\n");
|
|
141
|
+
}
|
|
142
|
+
|
|
77
143
|
const binaryPath = resolvePlatformBinary();
|
|
78
144
|
|
|
79
145
|
if (binaryPath) {
|
|
@@ -117,6 +183,10 @@ if (binaryPath) {
|
|
|
117
183
|
process.kill(process.pid, signal);
|
|
118
184
|
return;
|
|
119
185
|
}
|
|
186
|
+
const fatal = explainWindowsFatalStatus(code);
|
|
187
|
+
if (fatal) {
|
|
188
|
+
writeStderrSync(fatal);
|
|
189
|
+
}
|
|
120
190
|
process.exit(code ?? 0);
|
|
121
191
|
});
|
|
122
192
|
} else {
|
|
@@ -128,11 +198,11 @@ if (binaryPath) {
|
|
|
128
198
|
if (devEntry) {
|
|
129
199
|
const { main } = await import(pathToFileURL(devEntry));
|
|
130
200
|
main().catch((error) => {
|
|
131
|
-
|
|
201
|
+
writeStderrSync(error.message);
|
|
132
202
|
process.exit(1);
|
|
133
203
|
});
|
|
134
204
|
} else {
|
|
135
|
-
|
|
205
|
+
writeStderrSync(
|
|
136
206
|
`codem: 未找到平台 CLI 包 ${PLATFORM_PACKAGE_NAME}。` +
|
|
137
207
|
"通常是安装时 optional 依赖被跳过(npm install --no-optional)或当前平台暂不支持;" +
|
|
138
208
|
"请重新安装 CodeM CLI。"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-codem/codem-cli",
|
|
3
|
-
"version": "0.1.180
|
|
3
|
+
"version": "0.1.180",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CodeM local CLI for Feishu-driven coding sessions",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -26,14 +26,15 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@lark-codem/codem-core": "0.8.8
|
|
29
|
+
"@lark-codem/codem-core": "0.8.8"
|
|
30
30
|
},
|
|
31
31
|
"optionalDependencies": {
|
|
32
|
-
"@lark-codem/codem-cli-darwin-arm64": "0.1.180
|
|
33
|
-
"@lark-codem/codem-cli-
|
|
34
|
-
"@lark-codem/codem-cli-linux-x64": "0.1.180
|
|
35
|
-
"@lark-codem/codem-cli-
|
|
36
|
-
"@lark-codem/codem-cli-win32-
|
|
32
|
+
"@lark-codem/codem-cli-darwin-arm64": "0.1.180",
|
|
33
|
+
"@lark-codem/codem-cli-darwin-x64": "0.1.180",
|
|
34
|
+
"@lark-codem/codem-cli-linux-x64": "0.1.180",
|
|
35
|
+
"@lark-codem/codem-cli-linux-arm64": "0.1.180",
|
|
36
|
+
"@lark-codem/codem-cli-win32-arm64": "0.1.180",
|
|
37
|
+
"@lark-codem/codem-cli-win32-x64": "0.1.180"
|
|
37
38
|
},
|
|
38
39
|
"engines": {
|
|
39
40
|
"node": ">=18"
|