@pikaa-ai/pikaa 0.1.7 → 0.1.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/bin/pikaa-linux-x64 +0 -0
- package/bin/pikaa.js +40 -51
- package/package.json +3 -1
- package/scripts/postinstall.js +89 -0
|
File without changes
|
package/bin/pikaa.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Universal Cross-Platform Dispatcher for Pikaa / Groupy Agent.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* 1. Runs precompiled native binary if present (downloaded by postinstall)
|
|
7
|
+
* 2. Falls back to Bun if installed (rare, for unsupported platforms)
|
|
8
|
+
* 3. Shows helpful install instructions if neither is available
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { spawnSync } from "node:child_process";
|
|
@@ -20,65 +20,54 @@ const rootDir = join(__dirname, "..");
|
|
|
20
20
|
const platform = process.platform;
|
|
21
21
|
const arch = process.arch;
|
|
22
22
|
|
|
23
|
-
// Map OS & Arch to precompiled binary filename
|
|
24
23
|
function getBinaryName() {
|
|
25
|
-
if (platform === "win32")
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (platform === "darwin") {
|
|
29
|
-
return arch === "arm64" ? "pikaa-darwin-arm64" : "pikaa-darwin-x64";
|
|
30
|
-
}
|
|
31
|
-
if (platform === "linux") {
|
|
32
|
-
return arch === "arm64" ? "pikaa-linux-arm64" : "pikaa-linux-x64";
|
|
33
|
-
}
|
|
24
|
+
if (platform === "win32") return arch === "arm64" ? "pikaa-windows-arm64.exe" : "pikaa-windows-x64.exe";
|
|
25
|
+
if (platform === "darwin") return arch === "arm64" ? "pikaa-darwin-arm64" : "pikaa-darwin-x64";
|
|
26
|
+
if (platform === "linux") return arch === "arm64" ? "pikaa-linux-arm64" : "pikaa-linux-x64";
|
|
34
27
|
return null;
|
|
35
28
|
}
|
|
36
29
|
|
|
30
|
+
// --- 1. Native binary (postinstall should have placed it here) ---
|
|
37
31
|
const binaryName = getBinaryName();
|
|
38
|
-
let nativeBinaryPath = null;
|
|
39
|
-
|
|
40
32
|
if (binaryName) {
|
|
41
|
-
const
|
|
42
|
-
join(rootDir, "dist", "bin", binaryName),
|
|
33
|
+
for (const p of [
|
|
43
34
|
join(rootDir, "bin", binaryName),
|
|
44
|
-
join(rootDir, binaryName),
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
for (const p of possiblePaths) {
|
|
35
|
+
join(rootDir, "dist", "bin", binaryName),
|
|
36
|
+
]) {
|
|
48
37
|
if (existsSync(p)) {
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
if (platform !== "win32") {
|
|
39
|
+
try { chmodSync(p, 0o755); } catch {}
|
|
40
|
+
}
|
|
41
|
+
const r = spawnSync(p, process.argv.slice(2), { stdio: "inherit", env: process.env });
|
|
42
|
+
process.exit(r.status ?? (r.error ? 1 : 0));
|
|
51
43
|
}
|
|
52
44
|
}
|
|
53
45
|
}
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
// --- 2. Fallback: run via Bun ---
|
|
48
|
+
const jsEntry = join(rootDir, "dist", "cli.js");
|
|
49
|
+
if (existsSync(jsEntry)) {
|
|
50
|
+
const probe = spawnSync("bun", ["--version"], { encoding: "utf8" });
|
|
51
|
+
if (!probe.error) {
|
|
52
|
+
const r = spawnSync("bun", ["run", jsEntry, ...process.argv.slice(2)], {
|
|
53
|
+
stdio: "inherit",
|
|
54
|
+
env: process.env,
|
|
55
|
+
});
|
|
56
|
+
process.exit(r.status ?? (r.error ? 1 : 0));
|
|
61
57
|
}
|
|
62
|
-
|
|
63
|
-
const result = spawnSync(nativeBinaryPath, process.argv.slice(2), {
|
|
64
|
-
stdio: "inherit",
|
|
65
|
-
env: process.env,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
if (result.error) {
|
|
69
|
-
console.error(`Failed to launch native binary: ${result.error.message}`);
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
process.exit(result.status ?? 0);
|
|
74
|
-
} else {
|
|
75
|
-
// Fallback to JS module execution
|
|
76
|
-
const jsEntry = existsSync(join(rootDir, "dist", "cli.js"))
|
|
77
|
-
? join(rootDir, "dist", "cli.js")
|
|
78
|
-
: join(rootDir, "src", "cli", "index.ts");
|
|
79
|
-
|
|
80
|
-
import(jsEntry).catch((err) => {
|
|
81
|
-
console.error("Failed to start CLI:", err);
|
|
82
|
-
process.exit(1);
|
|
83
|
-
});
|
|
84
58
|
}
|
|
59
|
+
|
|
60
|
+
// --- 3. Nothing worked ---
|
|
61
|
+
console.error([
|
|
62
|
+
"",
|
|
63
|
+
" pikaa could not start.",
|
|
64
|
+
" The precompiled binary may have failed to download during install.",
|
|
65
|
+
"",
|
|
66
|
+
" Try reinstalling:",
|
|
67
|
+
" npm install -g @pikaa-ai/pikaa",
|
|
68
|
+
"",
|
|
69
|
+
" Or install Bun as a fallback runtime:",
|
|
70
|
+
" curl -fsSL https://bun.sh/install | bash",
|
|
71
|
+
"",
|
|
72
|
+
].join("\n"));
|
|
73
|
+
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikaa-ai/pikaa",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "PIKAA CLI - AI coding agent that runs locally in your terminal.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
15
|
"bin",
|
|
16
|
+
"scripts/postinstall.js",
|
|
16
17
|
"README.md",
|
|
17
18
|
"LICENSE"
|
|
18
19
|
],
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
"build:exe": "bun build ./src/cli/index.ts --compile --outfile pikaa.exe",
|
|
25
26
|
"build:binaries": "bun run scripts/build-binaries.ts",
|
|
26
27
|
"build": "bun run build:js && bun run build:exe",
|
|
28
|
+
"postinstall": "node scripts/postinstall.js",
|
|
27
29
|
"prepublishOnly": "bun run build:js"
|
|
28
30
|
},
|
|
29
31
|
"keywords": [
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Postinstall: downloads the correct precompiled pikaa binary from GitHub Releases.
|
|
5
|
+
* Runs automatically after `npm install -g @pikaa-ai/pikaa`.
|
|
6
|
+
* Uses only Node.js built-ins — no Bun required.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { createWriteStream, chmodSync, existsSync, mkdirSync } from "node:fs";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { dirname, join } from "node:path";
|
|
12
|
+
import { pipeline } from "node:stream/promises";
|
|
13
|
+
import https from "node:https";
|
|
14
|
+
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = dirname(__filename);
|
|
17
|
+
const rootDir = join(__dirname, "..");
|
|
18
|
+
|
|
19
|
+
const pkg = JSON.parse(
|
|
20
|
+
await import("node:fs").then((fs) =>
|
|
21
|
+
fs.readFileSync(join(rootDir, "package.json"), "utf8")
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
const version = pkg.version;
|
|
25
|
+
const REPO = "Neural-Forge-AMD/agent-cli";
|
|
26
|
+
|
|
27
|
+
function getBinaryName() {
|
|
28
|
+
const platform = process.platform;
|
|
29
|
+
const arch = process.arch;
|
|
30
|
+
if (platform === "win32") return arch === "arm64" ? "pikaa-windows-arm64.exe" : "pikaa-windows-x64.exe";
|
|
31
|
+
if (platform === "darwin") return arch === "arm64" ? "pikaa-darwin-arm64" : "pikaa-darwin-x64";
|
|
32
|
+
if (platform === "linux") return arch === "arm64" ? "pikaa-linux-arm64" : "pikaa-linux-x64";
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const binaryName = getBinaryName();
|
|
37
|
+
|
|
38
|
+
if (!binaryName) {
|
|
39
|
+
console.warn(`[pikaa] Unsupported platform: ${process.platform}/${process.arch}. Fallback to bun required.`);
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const binDir = join(rootDir, "bin");
|
|
44
|
+
const destPath = join(binDir, binaryName);
|
|
45
|
+
|
|
46
|
+
if (existsSync(destPath)) {
|
|
47
|
+
// Already downloaded (e.g. cached by npm)
|
|
48
|
+
process.exit(0);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
mkdirSync(binDir, { recursive: true });
|
|
52
|
+
|
|
53
|
+
const url = `https://github.com/${REPO}/releases/download/v${version}/${binaryName}`;
|
|
54
|
+
|
|
55
|
+
console.log(`[pikaa] Downloading binary for ${process.platform}/${process.arch}...`);
|
|
56
|
+
console.log(`[pikaa] ${url}`);
|
|
57
|
+
|
|
58
|
+
async function download(downloadUrl, dest, redirects = 0) {
|
|
59
|
+
if (redirects > 5) throw new Error("Too many redirects");
|
|
60
|
+
|
|
61
|
+
await new Promise((resolve, reject) => {
|
|
62
|
+
const file = createWriteStream(dest);
|
|
63
|
+
https.get(downloadUrl, { headers: { "User-Agent": "pikaa-postinstall" } }, (res) => {
|
|
64
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
65
|
+
file.close();
|
|
66
|
+
resolve(download(res.headers.location, dest, redirects + 1));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (res.statusCode !== 200) {
|
|
70
|
+
file.close();
|
|
71
|
+
reject(new Error(`HTTP ${res.statusCode} from ${downloadUrl}`));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
pipeline(res, file).then(resolve).catch(reject);
|
|
75
|
+
}).on("error", reject);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
await download(url, destPath);
|
|
81
|
+
if (process.platform !== "win32") {
|
|
82
|
+
chmodSync(destPath, 0o755);
|
|
83
|
+
}
|
|
84
|
+
console.log(`[pikaa] ✓ Binary installed: ${destPath}`);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
// Non-fatal: user can still run via bun if installed
|
|
87
|
+
console.warn(`[pikaa] Warning: could not download binary (${err.message})`);
|
|
88
|
+
console.warn(`[pikaa] You can install Bun as a fallback: https://bun.sh/install`);
|
|
89
|
+
}
|