lystn-cli 0.3.6 → 0.4.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/lystn.js
CHANGED
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
/*
|
|
3
3
|
* `lystn` launcher for the npm package.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* The prebuilt Rust binaries for every supported platform are BUNDLED inside
|
|
6
|
+
* this package (the `binary/` dir, populated at publish time by CI). We just
|
|
7
|
+
* pick the one matching this machine and exec it.
|
|
8
|
+
*
|
|
9
|
+
* No postinstall script, no install-time download — so npm raises no
|
|
10
|
+
* `allow-scripts` warning and there's nothing to fail on a restricted network.
|
|
7
11
|
*/
|
|
8
12
|
"use strict";
|
|
9
13
|
|
|
@@ -11,27 +15,49 @@ const { spawnSync } = require("child_process");
|
|
|
11
15
|
const fs = require("fs");
|
|
12
16
|
const path = require("path");
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
18
|
+
// Map Node's platform/arch to the bundled binary filename (Rust target triple).
|
|
19
|
+
function binName() {
|
|
20
|
+
const p = process.platform;
|
|
21
|
+
const a = process.arch;
|
|
22
|
+
if (p === "win32" && a === "x64") return "lystn-x86_64-pc-windows-msvc.exe";
|
|
23
|
+
// macOS: Apple Silicon binary. An x64 Node under Rosetta on an M-series Mac
|
|
24
|
+
// still runs the arm64 binary natively.
|
|
25
|
+
if (p === "darwin") return "lystn-aarch64-apple-darwin";
|
|
26
|
+
if (p === "linux" && a === "x64") return "lystn-x86_64-unknown-linux-gnu";
|
|
27
|
+
if (p === "linux" && a === "arm64") return "lystn-aarch64-unknown-linux-gnu";
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const name = binName();
|
|
32
|
+
if (!name) {
|
|
33
|
+
console.error(
|
|
34
|
+
"[lystn] Unsupported platform: " + process.platform + "/" + process.arch
|
|
35
|
+
);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const exe = path.join(__dirname, "..", "binary", name);
|
|
40
|
+
if (!fs.existsSync(exe)) {
|
|
41
|
+
console.error(
|
|
42
|
+
"[lystn] The bundled binary for this platform (" + name + ") is missing.\n" +
|
|
43
|
+
"[lystn] Please reinstall: npm install -g lystn-cli"
|
|
44
|
+
);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
20
47
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
48
|
+
// Belt-and-suspenders: npm preserves the executable bit from the tarball, but
|
|
49
|
+
// ensure it on first run too (ignored if we can't write to a global install).
|
|
50
|
+
if (process.platform !== "win32") {
|
|
51
|
+
try {
|
|
52
|
+
fs.accessSync(exe, fs.constants.X_OK);
|
|
53
|
+
} catch (_) {
|
|
54
|
+
try {
|
|
55
|
+
fs.chmodSync(exe, 0o755);
|
|
56
|
+
} catch (_) {
|
|
57
|
+
/* not writable (root-owned global) — rely on the tarball's mode */
|
|
31
58
|
}
|
|
32
59
|
}
|
|
33
|
-
const res = spawnSync(exe, process.argv.slice(2), { stdio: "inherit" });
|
|
34
|
-
process.exit(res.status === null ? 1 : res.status);
|
|
35
60
|
}
|
|
36
61
|
|
|
37
|
-
|
|
62
|
+
const res = spawnSync(exe, process.argv.slice(2), { stdio: "inherit" });
|
|
63
|
+
process.exit(res.status === null ? 1 : res.status);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lystn-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Listen to your AI coding assistant — speaks Claude Code & Codex replies aloud.",
|
|
5
5
|
"homepage": "https://lystn.space",
|
|
6
6
|
"repository": { "type": "git", "url": "git+https://github.com/burakayener/lystn-cli.git" },
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"bin": { "lystn": "bin/lystn.js" },
|
|
9
|
-
"scripts": {
|
|
10
|
-
"postinstall": "node scripts/postinstall.js || exit 0"
|
|
11
|
-
},
|
|
12
9
|
"files": [
|
|
13
10
|
"bin/",
|
|
14
|
-
"
|
|
11
|
+
"binary/",
|
|
15
12
|
"README.md"
|
|
16
13
|
],
|
|
17
14
|
"engines": { "node": ">=18" },
|
package/scripts/postinstall.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/*
|
|
3
|
-
* Download the prebuilt Lystn (Rust) binary for this OS/arch.
|
|
4
|
-
*
|
|
5
|
-
* Runs at `npm install -g lystn-cli` (postinstall) AND lazily from bin/lystn.js
|
|
6
|
-
* if the binary is missing (pnpm v10+ skips postinstall by default, so the
|
|
7
|
-
* launcher must be able to self-fetch on first run).
|
|
8
|
-
*
|
|
9
|
-
* No Python, no compiler — just downloads the matching binary from the
|
|
10
|
-
* lystn-cli GitHub Release that matches this package version.
|
|
11
|
-
*/
|
|
12
|
-
"use strict";
|
|
13
|
-
|
|
14
|
-
const fs = require("fs");
|
|
15
|
-
const path = require("path");
|
|
16
|
-
const https = require("https");
|
|
17
|
-
|
|
18
|
-
const PKG_ROOT = path.join(__dirname, "..");
|
|
19
|
-
const VERSION = require(path.join(PKG_ROOT, "package.json")).version;
|
|
20
|
-
const REPO = "burakayener/lystn-cli";
|
|
21
|
-
const BIN_DIR = path.join(PKG_ROOT, "binary");
|
|
22
|
-
|
|
23
|
-
// Map Node's platform/arch to the Rust target triple used in the release asset
|
|
24
|
-
// names (see .github/workflows/release.yml). `lystn-<triple>` (+ .exe on Windows).
|
|
25
|
-
function target() {
|
|
26
|
-
const p = process.platform;
|
|
27
|
-
const a = process.arch;
|
|
28
|
-
if (p === "win32" && a === "x64") return { asset: "lystn-x86_64-pc-windows-msvc.exe", ext: ".exe" };
|
|
29
|
-
// macOS: Apple Silicon only. Serve the arm64 binary for any darwin — an
|
|
30
|
-
// M-series Mac running an x64 Node under Rosetta still runs arm64 natively.
|
|
31
|
-
if (p === "darwin") return { asset: "lystn-aarch64-apple-darwin", ext: "" };
|
|
32
|
-
if (p === "linux" && a === "x64") return { asset: "lystn-x86_64-unknown-linux-gnu", ext: "" };
|
|
33
|
-
if (p === "linux" && a === "arm64") return { asset: "lystn-aarch64-unknown-linux-gnu", ext: "" };
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function binaryPath() {
|
|
38
|
-
const ext = process.platform === "win32" ? ".exe" : "";
|
|
39
|
-
return path.join(BIN_DIR, "lystn" + ext);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// GET with redirect following (GitHub release assets 302 to a CDN host).
|
|
43
|
-
function get(url, cb, redirects) {
|
|
44
|
-
redirects = redirects || 0;
|
|
45
|
-
if (redirects > 10) return cb(new Error("too many redirects"));
|
|
46
|
-
https
|
|
47
|
-
.get(url, { headers: { "User-Agent": "lystn-cli-installer" } }, (res) => {
|
|
48
|
-
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
|
|
49
|
-
res.resume();
|
|
50
|
-
return get(res.headers.location, cb, redirects + 1);
|
|
51
|
-
}
|
|
52
|
-
if (res.statusCode !== 200) {
|
|
53
|
-
res.resume();
|
|
54
|
-
return cb(new Error("HTTP " + res.statusCode + " for " + url));
|
|
55
|
-
}
|
|
56
|
-
cb(null, res);
|
|
57
|
-
})
|
|
58
|
-
.on("error", cb);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function download() {
|
|
62
|
-
return new Promise((resolve) => {
|
|
63
|
-
const t = target();
|
|
64
|
-
if (!t) {
|
|
65
|
-
console.error("[lystn] Unsupported platform: " + process.platform + "/" + process.arch);
|
|
66
|
-
return resolve(false);
|
|
67
|
-
}
|
|
68
|
-
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${t.asset}`;
|
|
69
|
-
const dest = binaryPath();
|
|
70
|
-
const tmp = dest + ".download";
|
|
71
|
-
try {
|
|
72
|
-
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
73
|
-
} catch (_) {}
|
|
74
|
-
console.error("[lystn] Downloading the speech engine for your system ...");
|
|
75
|
-
get(url, (err, res) => {
|
|
76
|
-
if (err) {
|
|
77
|
-
console.error("[lystn] Could not download the binary: " + err.message);
|
|
78
|
-
return resolve(false);
|
|
79
|
-
}
|
|
80
|
-
const file = fs.createWriteStream(tmp);
|
|
81
|
-
res.pipe(file);
|
|
82
|
-
file.on("finish", () =>
|
|
83
|
-
file.close(() => {
|
|
84
|
-
try {
|
|
85
|
-
fs.renameSync(tmp, dest);
|
|
86
|
-
if (process.platform !== "win32") fs.chmodSync(dest, 0o755);
|
|
87
|
-
resolve(true);
|
|
88
|
-
} catch (e) {
|
|
89
|
-
console.error("[lystn] Could not install the binary: " + e.message);
|
|
90
|
-
resolve(false);
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
);
|
|
94
|
-
file.on("error", (e) => {
|
|
95
|
-
console.error("[lystn] Download failed: " + e.message);
|
|
96
|
-
try {
|
|
97
|
-
fs.unlinkSync(tmp);
|
|
98
|
-
} catch (_) {}
|
|
99
|
-
resolve(false);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
module.exports = { download, binaryPath };
|
|
106
|
-
|
|
107
|
-
if (require.main === module) {
|
|
108
|
-
// Postinstall: NEVER fail the npm install — the launcher self-fetches later.
|
|
109
|
-
download().then((ok) => {
|
|
110
|
-
if (ok) console.error("[lystn] Ready. Run: lystn install && lystn login");
|
|
111
|
-
process.exit(0);
|
|
112
|
-
});
|
|
113
|
-
}
|