@byteask/cli 0.1.2 → 0.1.3

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/README.md CHANGED
@@ -27,6 +27,11 @@ runtime, so switching between them is free.
27
27
  pip install byteask
28
28
  ```
29
29
 
30
+ **uv**
31
+ ```bash
32
+ uv tool install byteask # or: uv pip install byteask / uvx byteask
33
+ ```
34
+
30
35
  **npm**
31
36
  ```bash
32
37
  npm install -g @byteask/cli
@@ -44,9 +49,10 @@ curl -fsSL https://code.byteask.ai/install.sh | sh
44
49
  irm https://code.byteask.ai/install.ps1 | iex
45
50
  ```
46
51
 
47
- The `pip` and `npm` packages are thin launchers: on first run they fetch the native
48
- engine into `~/.byteask/runtime` and hand off to it. Nothing else on your machine
49
- changes.
52
+ The `pip`, `uv`, and `npm` packages **bundle the native engine for your platform**
53
+ `pip install` / `npm i` gets you a working tool with no extra download. (On a platform
54
+ without a prebuilt binary they fall back to fetching it once.) The installed command is
55
+ `byteask` on every path.
50
56
 
51
57
  ---
52
58
 
package/bin/byteask.js CHANGED
@@ -1,60 +1,107 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- // ByteAsk npm launcher (thin bootstrapper).
3
+ // ByteAsk npm launcher (dispatcher).
4
4
  //
5
- // On first run it installs the native ByteAsk engine + wrapper into a shared
6
- // runtime dir (~/.byteask/runtime) via the same installer the curl|sh path uses,
7
- // then execs the wrapper. All the real logic (login, onboarding, update check,
8
- // /login|/logout loop) lives in that native wrapper this file only bootstraps.
9
- // The runtime dir is shared with the pip package, so the engine downloads once.
5
+ // The engine ships INSIDE per-platform optional-dependency packages
6
+ // (@byteask/cli-<os>-<arch>); npm installs only the one matching this machine.
7
+ // On first run we materialize that bundled engine + wrapper into the shared
8
+ // runtime dir (~/.byteask/runtime) and exec the wrapper (which holds all the auth
9
+ // / onboarding / loop logic). If no platform package is present (an unsupported
10
+ // platform), we fall back to the installer download. No engine is bundled in THIS
11
+ // package — it's a small dispatcher.
10
12
 
11
13
  const { spawnSync } = require("child_process");
12
- const { existsSync, mkdirSync } = require("fs");
14
+ const { existsSync, mkdirSync, copyFileSync, writeFileSync, chmodSync } = require("fs");
13
15
  const path = require("path");
14
16
  const os = require("os");
15
17
 
16
18
  const BUNDLE = (process.env.BYTEASK_BUNDLE_URL || "https://code.byteask.ai").replace(/\/+$/, "");
19
+ const GATEWAY = (process.env.BYTEASK_GATEWAY || BUNDLE).replace(/\/+$/, "");
17
20
  const HOME = process.env.BYTEASK_HOME || path.join(os.homedir(), ".byteask");
18
21
  const VENDOR = path.join(HOME, "runtime");
19
22
  const isWin = process.platform === "win32";
20
- const wrapper = path.join(VENDOR, isWin ? "byteask.ps1" : "byteask");
21
23
  const engine = path.join(VENDOR, isWin ? "byteask-engine.exe" : "byteask-engine");
24
+ const wrapper = path.join(VENDOR, isWin ? "byteask.ps1" : "byteask");
25
+
26
+ const PLATFORM_PKG = {
27
+ "linux-x64": "@byteask/cli-linux-x64",
28
+ "linux-arm64": "@byteask/cli-linux-arm64",
29
+ "darwin-arm64": "@byteask/cli-darwin-arm64",
30
+ "win32-x64": "@byteask/cli-win32-x64",
31
+ };
22
32
 
23
33
  function run(cmd, args) {
24
34
  return spawnSync(cmd, args, { stdio: "inherit" });
25
35
  }
26
36
 
27
- function ensureInstalled() {
37
+ function writeInitialConfig() {
38
+ const cfg = path.join(HOME, "config.toml");
39
+ if (existsSync(cfg)) return;
40
+ mkdirSync(HOME, { recursive: true });
41
+ writeFileSync(path.join(HOME, "gateway"), GATEWAY);
42
+ writeFileSync(
43
+ cfg,
44
+ 'model = "gpt-5.4"\n' +
45
+ 'model_provider = "byteask"\n' +
46
+ 'web_search = "live"\n\n' +
47
+ "[model_providers.byteask]\n" +
48
+ 'name = "ByteAsk"\n' +
49
+ 'base_url = "' + GATEWAY + '/byteask/v1"\n' +
50
+ 'wire_api = "responses"\n' +
51
+ "requires_openai_auth = false\n\n" +
52
+ "[model_providers.byteask.http_headers]\n" +
53
+ 'x-openai-actor-authorization = "byteask"\n'
54
+ );
55
+ }
56
+
57
+ function platformPackageDir() {
58
+ const pkgName = PLATFORM_PKG[process.platform + "-" + process.arch];
59
+ if (!pkgName) return null;
60
+ try {
61
+ return path.dirname(require.resolve(pkgName + "/package.json"));
62
+ } catch (e) {
63
+ return null;
64
+ }
65
+ }
66
+
67
+ function materialize() {
28
68
  if (existsSync(engine) && existsSync(wrapper)) return;
29
- mkdirSync(VENDOR, { recursive: true });
69
+ const dir = platformPackageDir();
70
+ const bEngine = dir && path.join(dir, isWin ? "byteask-engine.exe" : "byteask-engine");
71
+ const bWrap = dir && path.join(dir, isWin ? "byteask.ps1" : "byteask");
72
+ if (bEngine && existsSync(bEngine) && existsSync(bWrap)) {
73
+ process.stderr.write("[byteask] first run: unpacking bundled engine...\n");
74
+ mkdirSync(VENDOR, { recursive: true });
75
+ copyFileSync(bEngine, engine);
76
+ copyFileSync(bWrap, wrapper);
77
+ if (!isWin) {
78
+ chmodSync(engine, 0o755);
79
+ chmodSync(wrapper, 0o755);
80
+ }
81
+ writeInitialConfig();
82
+ return;
83
+ }
84
+ // Fallback: no bundled platform package for this machine -> download via installer.
30
85
  process.stderr.write("[byteask] first run: fetching the ByteAsk engine (one time)...\n");
86
+ mkdirSync(VENDOR, { recursive: true });
31
87
  let r;
32
88
  if (isWin) {
33
89
  const ps =
34
90
  "$ErrorActionPreference='Stop'; $env:PREFIX=" +
35
91
  JSON.stringify(VENDOR) +
36
- "; iex (irm " +
37
- JSON.stringify(BUNDLE + "/install.ps1") +
38
- ")";
92
+ "; iex (irm " + JSON.stringify(BUNDLE + "/install.ps1") + ")";
39
93
  r = run("powershell", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", ps]);
40
94
  } else {
41
- const sh =
42
- "curl -fsSL " +
43
- JSON.stringify(BUNDLE + "/install.sh") +
44
- " | PREFIX=" +
45
- JSON.stringify(VENDOR) +
46
- " sh";
95
+ const sh = "curl -fsSL " + JSON.stringify(BUNDLE + "/install.sh") + " | PREFIX=" + JSON.stringify(VENDOR) + " sh";
47
96
  r = run("sh", ["-c", sh]);
48
97
  }
49
98
  if (!r || r.status !== 0 || !existsSync(engine)) {
50
- process.stderr.write(
51
- "[byteask] install failed. Try the direct installer: curl -fsSL " + BUNDLE + "/install.sh | sh\n"
52
- );
99
+ process.stderr.write("[byteask] install failed. Try: curl -fsSL " + BUNDLE + "/install.sh | sh\n");
53
100
  process.exit(1);
54
101
  }
55
102
  }
56
103
 
57
- ensureInstalled();
104
+ materialize();
58
105
  const args = process.argv.slice(2);
59
106
  const r = isWin
60
107
  ? run("powershell", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", wrapper].concat(args))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byteask/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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"
@@ -15,6 +15,12 @@
15
15
  "engines": {
16
16
  "node": ">=16"
17
17
  },
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
+ },
18
24
  "keywords": [
19
25
  "byteask",
20
26
  "ai",