magic-agent 1.0.0 → 1.0.1

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.
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // magic-agent 的 npm bin 转发层:
5
+ // 按当前平台挑出预编译的 Go 二进制,原样转发 argv / stdio / 退出码。
6
+ //
7
+ // 之所以用 spawnSync + stdio:inherit 而不是直接 exec:
8
+ // - 保持真实 fd 0/1/2,Go 侧 process.stdin.isTTY 判定不受影响(管道读 prompt 依赖它)
9
+ // - 退出码、Ctrl-C 信号行为与直接运行二进制一致
10
+
11
+ const { spawnSync } = require("child_process");
12
+ const fs = require("fs");
13
+ const path = require("path");
14
+
15
+ const { binaryPath, distDir, currentTarget, exeName } = require("../lib/platform");
16
+
17
+ const target = currentTarget();
18
+ const bin = binaryPath(target);
19
+
20
+ if (!fs.existsSync(bin)) {
21
+ const found = fs.existsSync(distDir)
22
+ ? fs.readdirSync(distDir).filter((d) => fs.existsSync(path.join(distDir, d, exeName(d.startsWith("win32") ? "windows" : "linux"))))
23
+ : [];
24
+ process.stderr.write(
25
+ `magic-agent: 当前平台 ${target.dir} 没有可用二进制(期望 ${bin})\n` +
26
+ `已打包的平台:${found.length ? found.join(", ") : "(无)"}\n` +
27
+ `解决办法:在有 Go 的环境执行 \`npm run build\`,或用 \`go build -o bin/magic-agent ./cmd/magic-agent\` 自行编译后直接调用。\n`
28
+ );
29
+ process.exit(1);
30
+ }
31
+
32
+ const res = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
33
+
34
+ if (res.error) {
35
+ process.stderr.write(`magic-agent: 启动失败: ${res.error.message}\n`);
36
+ process.exit(1);
37
+ }
38
+ if (res.signal) {
39
+ // 让父进程以相同信号退出,保持 shell 语义(如超时/中断)
40
+ process.kill(process.pid, res.signal);
41
+ process.exit(1);
42
+ }
43
+ process.exit(res.status === null ? 1 : res.status);
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-agent",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "专业的 agent CLI 代理工具 - 统一 claude / codebuddy / trae / llm / codex / openclaw 引擎",
5
5
  "license": "MIT",
6
6
  "bin": {