@uselegion/cli 0.0.1-rc.1 → 0.0.1-rc.3
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/package.json +6 -6
- package/run.js +30 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uselegion/cli",
|
|
3
|
-
"version": "0.0.1-rc.
|
|
3
|
+
"version": "0.0.1-rc.3",
|
|
4
4
|
"description": "Self-hosted, multi-channel AI agent gateway and CLI \u2014 installer wrapper that resolves the prebuilt `legion` binary for your platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"run.js"
|
|
16
16
|
],
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@uselegion/cli-darwin-arm64": "0.0.
|
|
19
|
-
"@uselegion/cli-darwin-x64": "0.0.
|
|
20
|
-
"@uselegion/cli-linux-arm64-musl": "0.0.
|
|
21
|
-
"@uselegion/cli-linux-x64-musl": "0.0.
|
|
22
|
-
"@uselegion/cli-win32-x64-msvc": "0.0.
|
|
18
|
+
"@uselegion/cli-darwin-arm64": "0.0.1-rc.3",
|
|
19
|
+
"@uselegion/cli-darwin-x64": "0.0.1-rc.3",
|
|
20
|
+
"@uselegion/cli-linux-arm64-musl": "0.0.1-rc.3",
|
|
21
|
+
"@uselegion/cli-linux-x64-musl": "0.0.1-rc.3",
|
|
22
|
+
"@uselegion/cli-win32-x64-msvc": "0.0.1-rc.3"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=18"
|
package/run.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
// optional dep was pruned).
|
|
9
9
|
|
|
10
10
|
const { spawn } = require("node:child_process");
|
|
11
|
-
const { existsSync } = require("node:fs");
|
|
12
|
-
const { join } = require("node:path");
|
|
11
|
+
const { existsSync, realpathSync } = require("node:fs");
|
|
12
|
+
const { join, delimiter } = require("node:path");
|
|
13
13
|
|
|
14
14
|
// Map the current process to a platform package suffix.
|
|
15
15
|
const PLATFORMS = {
|
|
@@ -44,25 +44,38 @@ function resolveBinary() {
|
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
// Find a `legion` binary on PATH that is NOT this wrapper. A global npm
|
|
48
|
+
// install puts a `legion` shim on PATH that symlinks right back to run.js;
|
|
49
|
+
// spawning it would recurse until the kernel refuses with EAGAIN.
|
|
50
|
+
function findOnPath() {
|
|
51
|
+
const self = realpathSync(__filename);
|
|
52
|
+
const exe = process.platform === "win32" ? "legion.exe" : "legion";
|
|
53
|
+
for (const dir of (process.env.PATH || "").split(delimiter)) {
|
|
54
|
+
if (!dir) continue;
|
|
55
|
+
const candidate = join(dir, exe);
|
|
56
|
+
if (!existsSync(candidate)) continue;
|
|
57
|
+
let real;
|
|
58
|
+
try {
|
|
59
|
+
real = realpathSync(candidate);
|
|
60
|
+
} catch {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (real === self) continue; // the npm shim pointing back at us
|
|
64
|
+
return candidate;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
47
69
|
function main() {
|
|
48
|
-
let bin = resolveBinary();
|
|
49
70
|
const args = process.argv.slice(2);
|
|
71
|
+
const bin = resolveBinary() ?? findOnPath();
|
|
50
72
|
|
|
51
73
|
if (!bin) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"legion: no platform binary installed and `legion` not found on PATH.\n" +
|
|
58
|
-
"Install via Homebrew (`brew install dawnswwwww/tap/legion`) or Cargo (`cargo install legion-cli`).",
|
|
59
|
-
);
|
|
60
|
-
process.exit(127);
|
|
61
|
-
}
|
|
62
|
-
throw err;
|
|
63
|
-
});
|
|
64
|
-
child.on("exit", (code) => process.exit(code ?? 1));
|
|
65
|
-
return;
|
|
74
|
+
console.error(
|
|
75
|
+
"legion: no platform binary installed and `legion` not found on PATH.\n" +
|
|
76
|
+
"Reinstall (`npm i -g @uselegion/cli`) or use Homebrew (`brew install dawnswwwww/tap/legion`) or Cargo (`cargo install uselegion-cli`).",
|
|
77
|
+
);
|
|
78
|
+
process.exit(127);
|
|
66
79
|
}
|
|
67
80
|
|
|
68
81
|
const child = spawn(bin, args, { stdio: "inherit" });
|