@vylth/ragna 0.1.4

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.
Files changed (3) hide show
  1. package/bin/ragna +19 -0
  2. package/install.js +100 -0
  3. package/package.json +29 -0
package/bin/ragna ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { execFileSync } = require("child_process");
5
+ const path = require("path");
6
+
7
+ const ext = process.platform === "win32" ? ".exe" : "";
8
+ const bin = path.join(__dirname, `ragna${ext}`);
9
+
10
+ try {
11
+ execFileSync(bin, process.argv.slice(2), { stdio: "inherit" });
12
+ } catch (e) {
13
+ if (e.status !== undefined) {
14
+ process.exit(e.status);
15
+ }
16
+ console.error(`ragna: failed to execute binary at ${bin}`);
17
+ console.error("Run `npm install -g @vylth/ragna` to reinstall.");
18
+ process.exit(1);
19
+ }
package/install.js ADDED
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { execSync } = require("child_process");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const https = require("https");
8
+
9
+ const PLATFORMS = {
10
+ "linux-x64": "@vylth/ragna-linux-x64",
11
+ "darwin-x64": "@vylth/ragna-darwin-x64",
12
+ "darwin-arm64": "@vylth/ragna-darwin-arm64",
13
+ "win32-x64": "@vylth/ragna-win32-x64",
14
+ };
15
+
16
+ const GITHUB_RELEASE_URL =
17
+ "https://github.com/VYLTH/Ragna/releases/latest/download";
18
+
19
+ function getPlatformKey() {
20
+ return `${process.platform}-${process.arch}`;
21
+ }
22
+
23
+ function getBinaryName() {
24
+ return process.platform === "win32" ? "ragna.exe" : "ragna";
25
+ }
26
+
27
+ function tryPlatformPackage() {
28
+ const key = getPlatformKey();
29
+ const pkg = PLATFORMS[key];
30
+ if (!pkg) return false;
31
+
32
+ try {
33
+ const pkgPath = require.resolve(`${pkg}/bin/${getBinaryName()}`);
34
+ const dest = path.join(__dirname, "bin", getBinaryName());
35
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
36
+ fs.copyFileSync(pkgPath, dest);
37
+ fs.chmodSync(dest, 0o755);
38
+ console.log(`ragna: installed from ${pkg}`);
39
+ return true;
40
+ } catch {
41
+ return false;
42
+ }
43
+ }
44
+
45
+ function downloadFromGitHub() {
46
+ const key = getPlatformKey();
47
+ const binaryName = getBinaryName();
48
+ const assetName = `ragna-${key}${process.platform === "win32" ? ".exe" : ""}`;
49
+ const url = `${GITHUB_RELEASE_URL}/${assetName}`;
50
+ const dest = path.join(__dirname, "bin", binaryName);
51
+
52
+ console.log(`ragna: downloading from GitHub Releases...`);
53
+
54
+ return new Promise((resolve, reject) => {
55
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
56
+ const file = fs.createWriteStream(dest);
57
+
58
+ function follow(url) {
59
+ https
60
+ .get(url, (res) => {
61
+ if (res.statusCode === 302 || res.statusCode === 301) {
62
+ follow(res.headers.location);
63
+ return;
64
+ }
65
+ if (res.statusCode !== 200) {
66
+ reject(new Error(`HTTP ${res.statusCode}`));
67
+ return;
68
+ }
69
+ res.pipe(file);
70
+ file.on("finish", () => {
71
+ file.close();
72
+ fs.chmodSync(dest, 0o755);
73
+ console.log(`ragna: installed from GitHub Releases`);
74
+ resolve();
75
+ });
76
+ })
77
+ .on("error", reject);
78
+ }
79
+
80
+ follow(url);
81
+ });
82
+ }
83
+
84
+ async function main() {
85
+ if (tryPlatformPackage()) return;
86
+
87
+ try {
88
+ await downloadFromGitHub();
89
+ } catch (e) {
90
+ console.error(
91
+ `ragna: failed to install binary for ${getPlatformKey()}: ${e.message}`
92
+ );
93
+ console.error(
94
+ "ragna: you can install manually with `cargo install ragna-cli`"
95
+ );
96
+ process.exit(1);
97
+ }
98
+ }
99
+
100
+ main();
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@vylth/ragna",
3
+ "version": "0.1.4",
4
+ "description": "VYLTH Ragna Agent CLI — like Claude Code, but for VYLTH",
5
+ "bin": {
6
+ "ragna": "bin/ragna"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "optionalDependencies": {
12
+ "@vylth/ragna-linux-x64": "0.1.4",
13
+ "@vylth/ragna-darwin-x64": "0.1.4",
14
+ "@vylth/ragna-darwin-arm64": "0.1.4",
15
+ "@vylth/ragna-win32-x64": "0.1.4"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/VYLTH/Ragna"
20
+ },
21
+ "license": "MIT",
22
+ "keywords": [
23
+ "cli",
24
+ "ai",
25
+ "agent",
26
+ "vylth",
27
+ "ragna"
28
+ ]
29
+ }