@chro-ai/cli 0.1.0
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/cli.js +26 -0
- package/bin/platform.js +62 -0
- package/bin/postinstall.js +5 -0
- package/package.json +29 -0
package/bin/cli.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawn } = require("child_process");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const { getBinaryName } = require("./platform");
|
|
8
|
+
|
|
9
|
+
const binName = getBinaryName("chro");
|
|
10
|
+
const localBinary = path.resolve(__dirname, "..", "..", "target", "release", binName);
|
|
11
|
+
|
|
12
|
+
if (!fs.existsSync(localBinary)) {
|
|
13
|
+
console.error("chro binary not found.");
|
|
14
|
+
console.error("Build it first with: cd apps/cli && cargo build --release");
|
|
15
|
+
console.error("This wrapper is scaffold-only; remote download is not wired yet.");
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const args = process.argv.slice(2);
|
|
20
|
+
const proc = spawn(localBinary, args, { stdio: "inherit" });
|
|
21
|
+
|
|
22
|
+
proc.on("exit", (code) => process.exit(code || 0));
|
|
23
|
+
proc.on("error", (error) => {
|
|
24
|
+
console.error("failed to launch chro:", error.message);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
package/bin/platform.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { execSync } = require("child_process");
|
|
5
|
+
|
|
6
|
+
// Public binary host URL placeholder for future releases.
|
|
7
|
+
const R2_PUBLIC_URL = "https://example.com/chro";
|
|
8
|
+
|
|
9
|
+
function getEffectiveArch() {
|
|
10
|
+
const platform = process.platform;
|
|
11
|
+
const nodeArch = process.arch;
|
|
12
|
+
|
|
13
|
+
if (platform === "darwin") {
|
|
14
|
+
if (nodeArch === "arm64") return "arm64";
|
|
15
|
+
try {
|
|
16
|
+
const translated = execSync("sysctl -in sysctl.proc_translated", {
|
|
17
|
+
encoding: "utf8",
|
|
18
|
+
}).trim();
|
|
19
|
+
if (translated === "1") return "arm64";
|
|
20
|
+
} catch {
|
|
21
|
+
// Ignore and assume Intel.
|
|
22
|
+
}
|
|
23
|
+
return "x64";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (/arm/i.test(nodeArch)) return "arm64";
|
|
27
|
+
|
|
28
|
+
if (platform === "win32") {
|
|
29
|
+
const pa = process.env.PROCESSOR_ARCHITECTURE || "";
|
|
30
|
+
const paw = process.env.PROCESSOR_ARCHITEW6432 || "";
|
|
31
|
+
if (/arm/i.test(pa) || /arm/i.test(paw)) return "arm64";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return "x64";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const PLATFORM_MAP = {
|
|
38
|
+
"linux-x64": "linux-x64",
|
|
39
|
+
"linux-arm64": "linux-arm64",
|
|
40
|
+
"win32-x64": "windows-x64",
|
|
41
|
+
"win32-arm64": "windows-arm64",
|
|
42
|
+
"darwin-x64": "macos-x64",
|
|
43
|
+
"darwin-arm64": "macos-arm64",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function getPlatformDir() {
|
|
47
|
+
const key = `${process.platform}-${getEffectiveArch()}`;
|
|
48
|
+
const dir = PLATFORM_MAP[key];
|
|
49
|
+
|
|
50
|
+
if (!dir) {
|
|
51
|
+
console.error(`Unsupported platform: ${key}`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return dir;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getBinaryName(base) {
|
|
59
|
+
return process.platform === "win32" ? `${base}.exe` : base;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = { getEffectiveArch, getPlatformDir, getBinaryName, R2_PUBLIC_URL };
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chro-ai/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Chro CLI",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/n-asuy/chro"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://chro-ai.com",
|
|
11
|
+
"bin": {
|
|
12
|
+
"chro": "bin/cli.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "node bin/postinstall.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"cli",
|
|
25
|
+
"skills",
|
|
26
|
+
"productivity",
|
|
27
|
+
"ai"
|
|
28
|
+
]
|
|
29
|
+
}
|