reyes-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.js +45 -0
- package/install.js +166 -0
- package/package.json +40 -0
package/bin.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const { install } = require("./install");
|
|
7
|
+
|
|
8
|
+
const binaryName = process.platform === "win32" ? "reyes.exe" : "reyes";
|
|
9
|
+
const binaryPath = path.join(__dirname, "bin", binaryName);
|
|
10
|
+
|
|
11
|
+
async function ensureBinary() {
|
|
12
|
+
if (fs.existsSync(binaryPath)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
console.error("reyes binary not found. Attempting download...");
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
await install();
|
|
20
|
+
} catch (error) {
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!fs.existsSync(binaryPath)) {
|
|
25
|
+
console.error("❌ reyes binary still missing after download.");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function run() {
|
|
31
|
+
await ensureBinary();
|
|
32
|
+
|
|
33
|
+
const child = spawn(binaryPath, process.argv.slice(2), { stdio: "inherit" });
|
|
34
|
+
|
|
35
|
+
child.on("error", (err) => {
|
|
36
|
+
console.error("❌ Failed to start reyes:", err.message);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
child.on("exit", (code, signal) => {
|
|
41
|
+
process.exit(signal ? 1 : code || 0);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
run();
|
package/install.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require("child_process");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const https = require("https");
|
|
7
|
+
|
|
8
|
+
// Version should match your Rust crate version
|
|
9
|
+
const VERSION = require("./package.json").version;
|
|
10
|
+
const BINARY_NAME = "reyes";
|
|
11
|
+
|
|
12
|
+
function getPlatformInfo() {
|
|
13
|
+
const platform = process.platform;
|
|
14
|
+
const arch = process.arch;
|
|
15
|
+
|
|
16
|
+
// Map Node.js platform/arch to Rust target triples
|
|
17
|
+
const platformMap = {
|
|
18
|
+
darwin: {
|
|
19
|
+
x64: "x86_64-apple-darwin",
|
|
20
|
+
arm64: "aarch64-apple-darwin",
|
|
21
|
+
},
|
|
22
|
+
linux: {
|
|
23
|
+
x64: "x86_64-unknown-linux-gnu",
|
|
24
|
+
arm64: "aarch64-unknown-linux-gnu",
|
|
25
|
+
},
|
|
26
|
+
win32: {
|
|
27
|
+
x64: "x86_64-pc-windows-msvc",
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (!platformMap[platform]) {
|
|
32
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!platformMap[platform][arch]) {
|
|
36
|
+
throw new Error(`Unsupported architecture: ${arch} on ${platform}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const target = platformMap[platform][arch];
|
|
40
|
+
const extension = platform === "win32" ? ".zip" : ".tar.xz";
|
|
41
|
+
const binaryName = platform === "win32" ? `${BINARY_NAME}.exe` : BINARY_NAME;
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
target,
|
|
45
|
+
extension,
|
|
46
|
+
binaryName,
|
|
47
|
+
filename: `${BINARY_NAME}-${target}${extension}`,
|
|
48
|
+
url: `https://github.com/Blankeos/reyes/releases/download/v${VERSION}/${BINARY_NAME}-${target}${extension}`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function downloadFile(url, dest) {
|
|
53
|
+
console.log(`Downloading ${url}...`);
|
|
54
|
+
|
|
55
|
+
const file = fs.createWriteStream(dest);
|
|
56
|
+
const response = await new Promise((resolve, reject) => {
|
|
57
|
+
https
|
|
58
|
+
.get(url, (res) => {
|
|
59
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
60
|
+
https.get(res.headers.location, resolve).on("error", reject);
|
|
61
|
+
} else if (res.statusCode === 200) {
|
|
62
|
+
resolve(res);
|
|
63
|
+
} else {
|
|
64
|
+
reject(
|
|
65
|
+
new Error(
|
|
66
|
+
`Failed to download: ${res.statusCode} ${res.statusMessage}`,
|
|
67
|
+
),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
.on("error", reject);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
response.pipe(file);
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
file.on("finish", () => {
|
|
77
|
+
file.close();
|
|
78
|
+
resolve();
|
|
79
|
+
});
|
|
80
|
+
file.on("error", (err) => {
|
|
81
|
+
fs.unlink(dest, () => {});
|
|
82
|
+
reject(err);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function extractArchive(archivePath, extractDir, platformInfo) {
|
|
88
|
+
console.log("Extracting binary...");
|
|
89
|
+
|
|
90
|
+
const cmd =
|
|
91
|
+
platformInfo.extension === ".zip"
|
|
92
|
+
? `unzip -o "${archivePath}" -d "${extractDir}" 2>/dev/null || powershell -command "Expand-Archive -Path '${archivePath}' -DestinationPath '${extractDir}' -Force"`
|
|
93
|
+
: `tar -xf "${archivePath}" -C "${extractDir}"`;
|
|
94
|
+
|
|
95
|
+
execSync(cmd, { stdio: "inherit" });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function logInstallFailure(error) {
|
|
99
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
100
|
+
console.error("❌ Installation failed:", message);
|
|
101
|
+
console.error("\nYou can install reyes directly using:");
|
|
102
|
+
console.error(
|
|
103
|
+
'curl --proto "=https" --tlsv1.2 -LsSf https://github.com/Blankeos/reyes/releases/latest/download/reyes-installer.sh | sh',
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function install({ exitOnComplete = false } = {}) {
|
|
108
|
+
try {
|
|
109
|
+
const platformInfo = getPlatformInfo();
|
|
110
|
+
const binDir = path.join(__dirname, "bin");
|
|
111
|
+
const archivePath = path.join(__dirname, platformInfo.filename);
|
|
112
|
+
const binaryPath = path.join(binDir, platformInfo.binaryName);
|
|
113
|
+
|
|
114
|
+
if (!fs.existsSync(binDir)) fs.mkdirSync(binDir, { recursive: true });
|
|
115
|
+
|
|
116
|
+
await downloadFile(platformInfo.url, archivePath);
|
|
117
|
+
extractArchive(archivePath, __dirname, platformInfo);
|
|
118
|
+
|
|
119
|
+
const extractedBinaryPath = path.join(__dirname, platformInfo.binaryName);
|
|
120
|
+
if (fs.existsSync(extractedBinaryPath)) {
|
|
121
|
+
fs.renameSync(extractedBinaryPath, binaryPath);
|
|
122
|
+
} else {
|
|
123
|
+
const subdirPath = path.join(
|
|
124
|
+
__dirname,
|
|
125
|
+
`${BINARY_NAME}-${platformInfo.target}`,
|
|
126
|
+
platformInfo.binaryName,
|
|
127
|
+
);
|
|
128
|
+
if (fs.existsSync(subdirPath)) {
|
|
129
|
+
fs.renameSync(subdirPath, binaryPath);
|
|
130
|
+
fs.rmSync(path.dirname(subdirPath), { recursive: true, force: true });
|
|
131
|
+
} else {
|
|
132
|
+
throw new Error("Binary not found after extraction");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (process.platform !== "win32") {
|
|
137
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
fs.unlinkSync(archivePath);
|
|
141
|
+
console.log(`✅ reyes v${VERSION} installed successfully!`);
|
|
142
|
+
|
|
143
|
+
if (exitOnComplete) {
|
|
144
|
+
process.exit(0);
|
|
145
|
+
return binaryPath;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return binaryPath;
|
|
149
|
+
} catch (error) {
|
|
150
|
+
logInstallFailure(error);
|
|
151
|
+
|
|
152
|
+
if (exitOnComplete) {
|
|
153
|
+
process.exit(1);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Only run install if this script is executed directly
|
|
162
|
+
if (require.main === module) {
|
|
163
|
+
install({ exitOnComplete: true });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
module.exports = { getPlatformInfo, install };
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "reyes-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A comprehensive computer-use CLI built on rustautogui - giving AI vision and control over your computer",
|
|
5
|
+
"main": "bin.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"reyes": "./bin.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node install.js"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/Blankeos/reyes.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"cli",
|
|
18
|
+
"automation",
|
|
19
|
+
"gui",
|
|
20
|
+
"autogui",
|
|
21
|
+
"computer-use",
|
|
22
|
+
"vision",
|
|
23
|
+
"control"
|
|
24
|
+
],
|
|
25
|
+
"author": "Blankeos",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"files": [
|
|
28
|
+
"install.js",
|
|
29
|
+
"bin.js",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=12"
|
|
34
|
+
},
|
|
35
|
+
"os": [
|
|
36
|
+
"darwin",
|
|
37
|
+
"linux",
|
|
38
|
+
"win32"
|
|
39
|
+
]
|
|
40
|
+
}
|