@byteask/cli 0.1.3 → 0.1.5
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/byteask.js +39 -3
- package/package.json +7 -7
package/bin/byteask.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// package — it's a small dispatcher.
|
|
12
12
|
|
|
13
13
|
const { spawnSync } = require("child_process");
|
|
14
|
-
const { existsSync, mkdirSync, copyFileSync, writeFileSync, chmodSync } = require("fs");
|
|
14
|
+
const { existsSync, mkdirSync, copyFileSync, writeFileSync, chmodSync, renameSync } = require("fs");
|
|
15
15
|
const path = require("path");
|
|
16
16
|
const os = require("os");
|
|
17
17
|
|
|
@@ -34,6 +34,22 @@ function run(cmd, args) {
|
|
|
34
34
|
return spawnSync(cmd, args, { stdio: "inherit" });
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
function firstRunBanner() {
|
|
38
|
+
// Shown once, right after a fresh bundled unpack (the download path's install.sh
|
|
39
|
+
// prints its own). Keeps parity with curl so pip/npm users see how to sign in.
|
|
40
|
+
try {
|
|
41
|
+
if (process.env.CI || process.env.BYTEASK_NO_BANNER) return;
|
|
42
|
+
const g = "\x1b[1;38;2;134;174;165m";
|
|
43
|
+
const r = "\x1b[0m";
|
|
44
|
+
process.stderr.write(
|
|
45
|
+
"\n " + g + "✓" + r + " ByteAsk installed. New here? Sign in: " +
|
|
46
|
+
"byteask login --email you@company.com\n\n"
|
|
47
|
+
);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
/* a banner must never break the launch */
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
37
53
|
function writeInitialConfig() {
|
|
38
54
|
const cfg = path.join(HOME, "config.toml");
|
|
39
55
|
if (existsSync(cfg)) return;
|
|
@@ -64,21 +80,41 @@ function platformPackageDir() {
|
|
|
64
80
|
}
|
|
65
81
|
}
|
|
66
82
|
|
|
83
|
+
function brotliDecompressToFile(src, dst) {
|
|
84
|
+
// Stream-decompress in a child process: the engine is ~378 MB decompressed, so
|
|
85
|
+
// streaming keeps the parent light, and running it in a child lets us wait
|
|
86
|
+
// synchronously inside this sync flow. Uses node's built-in zlib brotli — no
|
|
87
|
+
// external tool needed on the user's machine.
|
|
88
|
+
const code =
|
|
89
|
+
"const z=require('zlib'),f=require('fs');" +
|
|
90
|
+
"f.createReadStream(process.argv[1]).pipe(z.createBrotliDecompress())" +
|
|
91
|
+
".pipe(f.createWriteStream(process.argv[2]))" +
|
|
92
|
+
".on('finish',()=>process.exit(0)).on('error',e=>{console.error(String(e));process.exit(1)});";
|
|
93
|
+
const r = spawnSync(process.execPath, ["-e", code, src, dst], { stdio: ["ignore", "ignore", "inherit"] });
|
|
94
|
+
return r && r.status === 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
67
97
|
function materialize() {
|
|
68
98
|
if (existsSync(engine) && existsSync(wrapper)) return;
|
|
69
99
|
const dir = platformPackageDir();
|
|
70
|
-
const bEngine = dir && path.join(dir, isWin ? "byteask-engine.exe" : "byteask-engine");
|
|
100
|
+
const bEngine = dir && path.join(dir, isWin ? "byteask-engine.exe.br" : "byteask-engine.br");
|
|
71
101
|
const bWrap = dir && path.join(dir, isWin ? "byteask.ps1" : "byteask");
|
|
72
102
|
if (bEngine && existsSync(bEngine) && existsSync(bWrap)) {
|
|
73
103
|
process.stderr.write("[byteask] first run: unpacking bundled engine...\n");
|
|
74
104
|
mkdirSync(VENDOR, { recursive: true });
|
|
75
|
-
|
|
105
|
+
const tmp = engine + ".tmp";
|
|
106
|
+
if (!brotliDecompressToFile(bEngine, tmp)) {
|
|
107
|
+
process.stderr.write("[byteask] failed to unpack bundled engine.\n");
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
renameSync(tmp, engine);
|
|
76
111
|
copyFileSync(bWrap, wrapper);
|
|
77
112
|
if (!isWin) {
|
|
78
113
|
chmodSync(engine, 0o755);
|
|
79
114
|
chmodSync(wrapper, 0o755);
|
|
80
115
|
}
|
|
81
116
|
writeInitialConfig();
|
|
117
|
+
firstRunBanner();
|
|
82
118
|
return;
|
|
83
119
|
}
|
|
84
120
|
// Fallback: no bundled platform package for this machine -> download via installer.
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byteask/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "ByteAsk - AI coding agent CLI for your terminal. Run `npx @byteask/cli` or `npm i -g @byteask/cli`.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"byteask": "bin/byteask.js"
|
|
7
7
|
},
|
|
8
|
+
"optionalDependencies": {
|
|
9
|
+
"@byteask/cli-linux-x64": "0.1.5",
|
|
10
|
+
"@byteask/cli-linux-arm64": "0.1.5",
|
|
11
|
+
"@byteask/cli-darwin-arm64": "0.1.5",
|
|
12
|
+
"@byteask/cli-win32-x64": "0.1.5"
|
|
13
|
+
},
|
|
8
14
|
"publishConfig": {
|
|
9
15
|
"access": "public"
|
|
10
16
|
},
|
|
@@ -15,12 +21,6 @@
|
|
|
15
21
|
"engines": {
|
|
16
22
|
"node": ">=16"
|
|
17
23
|
},
|
|
18
|
-
"optionalDependencies": {
|
|
19
|
-
"@byteask/cli-linux-x64": "0.1.3",
|
|
20
|
-
"@byteask/cli-linux-arm64": "0.1.3",
|
|
21
|
-
"@byteask/cli-darwin-arm64": "0.1.3",
|
|
22
|
-
"@byteask/cli-win32-x64": "0.1.3"
|
|
23
|
-
},
|
|
24
24
|
"keywords": [
|
|
25
25
|
"byteask",
|
|
26
26
|
"ai",
|