@pikaa-ai/pikaa 0.1.5 → 0.1.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/pikaa.js +49 -26
- package/package.json +1 -1
package/bin/pikaa.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Universal Cross-Platform Dispatcher for Pikaa / Groupy Agent.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Priority order:
|
|
7
|
+
* 1. Precompiled native binary (zero-dependency, instant start)
|
|
8
|
+
* 2. Bun runtime running the bundled JS (requires Bun installed)
|
|
9
|
+
* 3. Clear error message pointing user to install Bun
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
import { spawnSync } from "node:child_process";
|
|
@@ -34,17 +35,16 @@ function getBinaryName() {
|
|
|
34
35
|
return null;
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
// --- 1. Try native binary ---
|
|
37
39
|
const binaryName = getBinaryName();
|
|
38
40
|
let nativeBinaryPath = null;
|
|
39
41
|
|
|
40
42
|
if (binaryName) {
|
|
41
|
-
const
|
|
43
|
+
for (const p of [
|
|
42
44
|
join(rootDir, "dist", "bin", binaryName),
|
|
43
45
|
join(rootDir, "bin", binaryName),
|
|
44
46
|
join(rootDir, binaryName),
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
for (const p of possiblePaths) {
|
|
47
|
+
]) {
|
|
48
48
|
if (existsSync(p)) {
|
|
49
49
|
nativeBinaryPath = p;
|
|
50
50
|
break;
|
|
@@ -53,32 +53,55 @@ if (binaryName) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
if (nativeBinaryPath) {
|
|
56
|
-
// Ensure execute permissions on Unix
|
|
57
56
|
if (platform !== "win32") {
|
|
58
|
-
try {
|
|
59
|
-
chmodSync(nativeBinaryPath, 0o755);
|
|
60
|
-
} catch {}
|
|
57
|
+
try { chmodSync(nativeBinaryPath, 0o755); } catch {}
|
|
61
58
|
}
|
|
62
|
-
|
|
63
59
|
const result = spawnSync(nativeBinaryPath, process.argv.slice(2), {
|
|
64
60
|
stdio: "inherit",
|
|
65
61
|
env: process.env,
|
|
66
62
|
});
|
|
63
|
+
process.exit(result.status ?? (result.error ? 1 : 0));
|
|
64
|
+
}
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
66
|
+
// --- 2. Fallback: run via Bun (dist/cli.js is a Bun bundle) ---
|
|
67
|
+
const jsEntry = join(rootDir, "dist", "cli.js");
|
|
72
68
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
? join(rootDir, "dist", "cli.js")
|
|
78
|
-
: join(rootDir, "src", "cli", "index.ts");
|
|
69
|
+
if (!existsSync(jsEntry)) {
|
|
70
|
+
console.error("pikaa: dist/cli.js not found. Please reinstall the package.");
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
79
73
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
// Find Bun executable
|
|
75
|
+
const bunCandidates = platform === "win32"
|
|
76
|
+
? ["bun.exe"]
|
|
77
|
+
: ["bun"];
|
|
78
|
+
|
|
79
|
+
let bunBin = null;
|
|
80
|
+
for (const candidate of bunCandidates) {
|
|
81
|
+
const probe = spawnSync(candidate, ["--version"], { encoding: "utf8" });
|
|
82
|
+
if (!probe.error) {
|
|
83
|
+
bunBin = candidate;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
84
86
|
}
|
|
87
|
+
|
|
88
|
+
if (!bunBin) {
|
|
89
|
+
console.error([
|
|
90
|
+
"",
|
|
91
|
+
" pikaa requires Bun to run.",
|
|
92
|
+
" Install Bun with:",
|
|
93
|
+
"",
|
|
94
|
+
" curl -fsSL https://bun.sh/install | bash # macOS / Linux",
|
|
95
|
+
" powershell -c \"irm bun.sh/install.ps1 | iex\" # Windows",
|
|
96
|
+
"",
|
|
97
|
+
" Then re-run: pikaa",
|
|
98
|
+
"",
|
|
99
|
+
].join("\n"));
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const result = spawnSync(bunBin, ["run", jsEntry, ...process.argv.slice(2)], {
|
|
104
|
+
stdio: "inherit",
|
|
105
|
+
env: process.env,
|
|
106
|
+
});
|
|
107
|
+
process.exit(result.status ?? (result.error ? 1 : 0));
|