ai-otel-setup 1.0.7 → 1.0.9
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/cli.js +29 -6
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -28,15 +28,38 @@ const { execFileSync } = require("child_process");
|
|
|
28
28
|
|
|
29
29
|
const PKG_VERSION = require("./package.json").version;
|
|
30
30
|
|
|
31
|
-
// 安装时这台机器的 node
|
|
31
|
+
// 安装时这台机器的 node 绝对路径,POSIX 上拿来构造 hook command 用。
|
|
32
|
+
// Windows 上不再写 node 绝对路径(见 buildHookCommand 注释)。
|
|
32
33
|
const NODE_BIN = process.execPath;
|
|
33
34
|
|
|
34
|
-
// 跨平台 hook
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
35
|
+
// 跨平台 hook 命令构造。
|
|
36
|
+
//
|
|
37
|
+
// **Windows 上的关键决策(v1.0.9 重构)**:不再写 node 绝对路径,也不再加引号,
|
|
38
|
+
// 让 shell 自己按空白 split + 用 PATH lookup node。原因:
|
|
39
|
+
// - 写绝对路径如 "C:\Program Files\nodejs\node.exe",PowerShell 5.1(cc/gemini
|
|
40
|
+
// 在 Windows 默认 shell)解析时会把外层引号脱掉,按空白把 "C:\Program" 切成
|
|
41
|
+
// 一个 token,"Files\nodejs\..." 切成另一个,hook 进程起不来,exit code 1。
|
|
42
|
+
// - 用 8.3 短路径 (C:\Progra~1\...) 在 NTFS 8dot3name 禁用的卷上失效,
|
|
43
|
+
// 更糟的是 cmd /c for 在某些 locale 下输出会带额外引号,被 installer
|
|
44
|
+
// 二次拼装成 ""\"C:\\\"C:\\Program Files\\nodejs\\node.exe\\\"\"" 这种
|
|
45
|
+
// 非法嵌套,比原 bug 更难修。
|
|
46
|
+
// - 改写 wrapper .cmd / .sh 让用户用别的 shell 接管 → 整体复杂度+30 行,
|
|
47
|
+
// 而且 wrapper 路径本身仍可能带空格,治标不治本。
|
|
48
|
+
//
|
|
49
|
+
// 务实最稳的解:让 shell 自己 PATH 找 node,命令字符串本身不含空格路径段。
|
|
50
|
+
// 假设 ~/.codex/ai-otel/ 这条路径不含空格(取决于用户名):
|
|
51
|
+
// - 99% 用户名是 ASCII 无空格 → 完美工作
|
|
52
|
+
// - 用户名带空格的极少数(如 "John Smith")→ 文档化处理(见
|
|
53
|
+
// docs/codex-windows-troubleshooting.md "用户名含空格" 一节)
|
|
54
|
+
//
|
|
55
|
+
// launch-hook.js 内部还会再做一次 PATH 上探 node、失败时 fallback baked
|
|
56
|
+
// execPath 的兜底,所以 PATH 上 node 临时失踪也能起来。
|
|
57
|
+
//
|
|
58
|
+
// POSIX:保持 quoted 三段格式,shell 行为统一,路径有空格也安全。
|
|
39
59
|
function buildHookCommand(launcherPath, scriptPath) {
|
|
60
|
+
if (process.platform === "win32") {
|
|
61
|
+
return `node ${launcherPath} ${scriptPath}`;
|
|
62
|
+
}
|
|
40
63
|
return `"${NODE_BIN}" "${launcherPath}" "${scriptPath}"`;
|
|
41
64
|
}
|
|
42
65
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-otel-setup",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "One-shot installer for AI CLI OpenTelemetry forwarding. Writes Claude Code, Codex CLI, and Gemini CLI telemetry config in a single npx command.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ai-otel-setup": "cli.js",
|