@bytevion/cli 0.1.0 → 0.3.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.
Files changed (41) hide show
  1. package/README.md +66 -0
  2. package/dist/base.js +8 -1
  3. package/dist/commands/compare.d.ts +12 -0
  4. package/dist/commands/compare.js +104 -0
  5. package/dist/commands/integrate.d.ts +1 -0
  6. package/dist/commands/integrate.js +76 -28
  7. package/dist/commands/login.js +40 -59
  8. package/dist/commands/opt/preset.js +8 -5
  9. package/dist/commands/opt/show.js +20 -6
  10. package/dist/commands/providers/add.d.ts +3 -1
  11. package/dist/commands/providers/add.js +102 -20
  12. package/dist/commands/providers/rotate.js +39 -4
  13. package/dist/commands/setup.d.ts +19 -0
  14. package/dist/commands/setup.js +277 -0
  15. package/dist/commands/usage.js +32 -8
  16. package/dist/hooks/init/home.d.ts +3 -0
  17. package/dist/hooks/init/home.js +107 -0
  18. package/dist/lib/api.d.ts +1 -0
  19. package/dist/lib/api.js +60 -0
  20. package/dist/lib/auth.d.ts +9 -0
  21. package/dist/lib/auth.js +100 -0
  22. package/dist/lib/friendly.d.ts +8 -0
  23. package/dist/lib/friendly.js +86 -0
  24. package/dist/lib/home.d.ts +16 -0
  25. package/dist/lib/home.js +97 -0
  26. package/dist/lib/integrations.d.ts +1 -0
  27. package/dist/lib/integrations.js +198 -61
  28. package/dist/lib/output.d.ts +3 -0
  29. package/dist/lib/output.js +43 -0
  30. package/dist/lib/presets.d.ts +9 -0
  31. package/dist/lib/presets.js +40 -0
  32. package/dist/lib/providers.d.ts +13 -0
  33. package/dist/lib/providers.js +39 -0
  34. package/dist/lib/tty.d.ts +1 -0
  35. package/dist/lib/tty.js +11 -0
  36. package/dist/lib/ui.d.ts +60 -0
  37. package/dist/lib/ui.js +122 -0
  38. package/dist/lib/util.d.ts +1 -2
  39. package/dist/lib/util.js +11 -79
  40. package/oclif.manifest.json +215 -16
  41. package/package.json +76 -59
package/dist/lib/ui.js ADDED
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.log = exports.theme = void 0;
7
+ exports.banner = banner;
8
+ exports.intro = intro;
9
+ exports.outro = outro;
10
+ exports.note = note;
11
+ exports.text = text;
12
+ exports.password = password;
13
+ exports.select = select;
14
+ exports.multiselect = multiselect;
15
+ exports.confirm = confirm;
16
+ exports.spinner = spinner;
17
+ exports.revealSecret = revealSecret;
18
+ exports.cancelAndExit = cancelAndExit;
19
+ const picocolors_1 = __importDefault(require("picocolors"));
20
+ let _clack;
21
+ const importESM = new Function('s', 'return import(s)');
22
+ function clack() {
23
+ if (!_clack)
24
+ _clack = importESM('@clack/prompts');
25
+ return _clack;
26
+ }
27
+ exports.theme = {
28
+ accent: (s) => picocolors_1.default.cyan(s),
29
+ ok: (s) => picocolors_1.default.green(s),
30
+ warn: (s) => picocolors_1.default.yellow(s),
31
+ bad: (s) => picocolors_1.default.red(s),
32
+ muted: (s) => picocolors_1.default.dim(s),
33
+ bold: (s) => picocolors_1.default.bold(s),
34
+ };
35
+ // The Byte signature: a `›b_` prompt glyph and a cyan→blue gradient wordmark. picocolors
36
+ // has no true gradient, so the letters step across a cyan→blue ramp; degrades to plain
37
+ // text under NO_COLOR/BYTE_PLAIN. Kept in sync with the home dashboard wordmark.
38
+ function banner() {
39
+ const plain = Boolean(process.env.NO_COLOR) || process.env.BYTE_PLAIN === '1';
40
+ const mark = `${picocolors_1.default.dim('›')}${picocolors_1.default.bold(picocolors_1.default.cyanBright('b'))}${picocolors_1.default.dim('_')}`;
41
+ if (plain)
42
+ return `${mark} BYTE`;
43
+ const ramp = [picocolors_1.default.cyanBright, picocolors_1.default.cyan, picocolors_1.default.blue, picocolors_1.default.blueBright];
44
+ const name = 'BYTE'
45
+ .split('')
46
+ .map((ch, i) => picocolors_1.default.bold(ramp[i % ramp.length](ch)))
47
+ .join('');
48
+ return `${mark} ${name}`;
49
+ }
50
+ function guard(value, c) {
51
+ if (c.isCancel(value)) {
52
+ c.cancel('Cancelled — no changes made.');
53
+ process.exit(130);
54
+ }
55
+ return value;
56
+ }
57
+ async function intro(message) {
58
+ ;
59
+ (await clack()).intro(message);
60
+ }
61
+ async function outro(message) {
62
+ ;
63
+ (await clack()).outro(message);
64
+ }
65
+ async function note(message, title) {
66
+ ;
67
+ (await clack()).note(message, title);
68
+ }
69
+ exports.log = {
70
+ async info(message) {
71
+ ;
72
+ (await clack()).log.info(message);
73
+ },
74
+ async success(message) {
75
+ ;
76
+ (await clack()).log.success(message);
77
+ },
78
+ async warn(message) {
79
+ ;
80
+ (await clack()).log.warn(message);
81
+ },
82
+ async error(message) {
83
+ ;
84
+ (await clack()).log.error(message);
85
+ },
86
+ async step(message) {
87
+ ;
88
+ (await clack()).log.step(message);
89
+ },
90
+ };
91
+ async function text(opts) {
92
+ const c = await clack();
93
+ return guard(await c.text(opts), c);
94
+ }
95
+ async function password(opts) {
96
+ const c = await clack();
97
+ return guard(await c.password(opts), c);
98
+ }
99
+ async function select(opts) {
100
+ const c = await clack();
101
+ return guard(await c.select(opts), c);
102
+ }
103
+ async function multiselect(opts) {
104
+ const c = await clack();
105
+ return guard(await c.multiselect(opts), c);
106
+ }
107
+ async function confirm(opts) {
108
+ const c = await clack();
109
+ return guard(await c.confirm(opts), c);
110
+ }
111
+ async function spinner() {
112
+ return (await clack()).spinner();
113
+ }
114
+ async function revealSecret(label, value) {
115
+ const c = await clack();
116
+ c.note(`${picocolors_1.default.cyan(value)}\n\n${picocolors_1.default.dim('Copy it now — this is shown only once.')}`, label);
117
+ }
118
+ async function cancelAndExit(message = 'Cancelled — no changes made.') {
119
+ const c = await clack();
120
+ c.cancel(message);
121
+ process.exit(130);
122
+ }
@@ -1,4 +1,3 @@
1
1
  export declare function sleep(ms: number): Promise<void>;
2
2
  export declare function openBrowser(url: string): Promise<void>;
3
- export declare function prompt(question: string): Promise<string>;
4
- export declare function promptHidden(question: string): Promise<string>;
3
+ export declare function withTimeout<T>(promise: Promise<T>, ms: number, fallback: T): Promise<T>;
package/dist/lib/util.js CHANGED
@@ -1,44 +1,9 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.sleep = sleep;
37
4
  exports.openBrowser = openBrowser;
38
- exports.prompt = prompt;
39
- exports.promptHidden = promptHidden;
5
+ exports.withTimeout = withTimeout;
40
6
  const node_child_process_1 = require("node:child_process");
41
- const readline = __importStar(require("node:readline/promises"));
42
7
  function sleep(ms) {
43
8
  return new Promise((resolve) => setTimeout(resolve, ms));
44
9
  }
@@ -51,51 +16,18 @@ async function openBrowser(url) {
51
16
  const cmd = platform === 'darwin' ? 'open' : 'xdg-open';
52
17
  (0, node_child_process_1.spawn)(cmd, [url], { stdio: 'ignore', detached: true }).unref();
53
18
  }
54
- async function prompt(question) {
55
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
19
+ // Resolve to `fallback` if the promise does not settle within `ms` — used so network
20
+ // probes (e.g. integrate --list) never hang the UI.
21
+ async function withTimeout(promise, ms, fallback) {
22
+ let timer;
23
+ const timeout = new Promise((resolve) => {
24
+ timer = setTimeout(() => resolve(fallback), ms);
25
+ });
56
26
  try {
57
- const answer = await rl.question(question);
58
- return answer.trim();
27
+ return await Promise.race([promise, timeout]);
59
28
  }
60
29
  finally {
61
- rl.close();
30
+ if (timer)
31
+ clearTimeout(timer);
62
32
  }
63
33
  }
64
- // Byte codes for control keys (avoids embedding raw control characters).
65
- const CR = 13;
66
- const LF = 10;
67
- const CTRL_C = 3;
68
- const BACKSPACE = 8;
69
- const DEL = 127;
70
- async function promptHidden(question) {
71
- const stdin = process.stdin;
72
- if (!stdin.isTTY)
73
- return prompt(question);
74
- process.stdout.write(question);
75
- return new Promise((resolve) => {
76
- let input = '';
77
- stdin.resume();
78
- stdin.setRawMode(true);
79
- const onData = (chunk) => {
80
- const code = chunk[0];
81
- if (code === CR || code === LF) {
82
- stdin.setRawMode(false);
83
- stdin.pause();
84
- stdin.removeListener('data', onData);
85
- process.stdout.write('\n');
86
- resolve(input.trim());
87
- }
88
- else if (code === CTRL_C) {
89
- process.stdout.write('\n');
90
- process.exit(130);
91
- }
92
- else if (code === BACKSPACE || code === DEL) {
93
- input = input.slice(0, -1);
94
- }
95
- else {
96
- input += chunk.toString('utf8');
97
- }
98
- };
99
- stdin.on('data', onData);
100
- });
101
- }
@@ -1,5 +1,67 @@
1
1
  {
2
2
  "commands": {
3
+ "compare": {
4
+ "aliases": [],
5
+ "args": {
6
+ "prompt": {
7
+ "description": "Prompt to run on both lanes",
8
+ "name": "prompt",
9
+ "required": true
10
+ }
11
+ },
12
+ "description": "Prove the win: run a prompt direct vs through Byte and compare cost, latency, and quality.",
13
+ "examples": [
14
+ "<%= config.bin %> compare \"Summarize the latest release notes\"",
15
+ "<%= config.bin %> compare \"Refactor this function\" --model byte-2-deepseek-chat"
16
+ ],
17
+ "flags": {
18
+ "json": {
19
+ "description": "Format output as json.",
20
+ "helpGroup": "GLOBAL",
21
+ "name": "json",
22
+ "allowNo": false,
23
+ "type": "boolean"
24
+ },
25
+ "profile": {
26
+ "description": "Configuration profile to use",
27
+ "env": "BYTE_PROFILE",
28
+ "name": "profile",
29
+ "hasDynamicHelp": false,
30
+ "multiple": false,
31
+ "type": "option"
32
+ },
33
+ "base-url": {
34
+ "description": "Override the API base URL",
35
+ "env": "BYTE_BASE_URL",
36
+ "name": "base-url",
37
+ "hasDynamicHelp": false,
38
+ "multiple": false,
39
+ "type": "option"
40
+ },
41
+ "model": {
42
+ "description": "Model id (byte alias) or \"auto\"",
43
+ "name": "model",
44
+ "default": "auto",
45
+ "hasDynamicHelp": false,
46
+ "multiple": false,
47
+ "type": "option"
48
+ }
49
+ },
50
+ "hasDynamicHelp": false,
51
+ "hiddenAliases": [],
52
+ "id": "compare",
53
+ "pluginAlias": "@bytevion/cli",
54
+ "pluginName": "@bytevion/cli",
55
+ "pluginType": "core",
56
+ "strict": true,
57
+ "enableJsonFlag": true,
58
+ "isESM": false,
59
+ "relativePath": [
60
+ "dist",
61
+ "commands",
62
+ "compare.js"
63
+ ]
64
+ },
3
65
  "doctor": {
4
66
  "aliases": [],
5
67
  "args": {},
@@ -209,11 +271,11 @@
209
271
  "required": false
210
272
  }
211
273
  },
212
- "description": "Wire a coding harness or SDK to Byte (Claude Code, Codex, Cursor, Cline, Aider, OpenAI/Anthropic SDK).",
274
+ "description": "Wire a coding harness or SDK to Byte (Claude Code, Codex, opencode, Cursor, Cline, Aider, ).",
213
275
  "examples": [
214
276
  "<%= config.bin %> integrate --list",
215
- "<%= config.bin %> integrate codex",
216
- "<%= config.bin %> integrate claude-code --write --preset lowest_latency"
277
+ "<%= config.bin %> integrate opencode --write",
278
+ "<%= config.bin %> integrate claude-code --write --model byte-2-deepseek-chat"
217
279
  ],
218
280
  "flags": {
219
281
  "json": {
@@ -279,6 +341,13 @@
279
341
  "multiple": false,
280
342
  "type": "option"
281
343
  },
344
+ "model": {
345
+ "description": "Model id (byte alias) to wire (default byte-default)",
346
+ "name": "model",
347
+ "hasDynamicHelp": false,
348
+ "multiple": false,
349
+ "type": "option"
350
+ },
282
351
  "preset": {
283
352
  "description": "Apply this optimization preset to the org before wiring",
284
353
  "name": "preset",
@@ -341,7 +410,7 @@
341
410
  "type": "option"
342
411
  },
343
412
  "no-browser": {
344
- "description": "Do not try to open the browser automatically",
413
+ "description": "Do not open the browser automatically",
345
414
  "name": "no-browser",
346
415
  "allowNo": false,
347
416
  "type": "boolean"
@@ -475,6 +544,122 @@
475
544
  "run.js"
476
545
  ]
477
546
  },
547
+ "setup": {
548
+ "aliases": [
549
+ "init",
550
+ "onboard"
551
+ ],
552
+ "args": {},
553
+ "description": "Guided setup: sign in, connect a provider, create a Byte key, and wire a tool.",
554
+ "examples": [
555
+ "<%= config.bin %> setup",
556
+ "<%= config.bin %> setup --provider deepseek --provider-key sk-... --connect opencode --json"
557
+ ],
558
+ "flags": {
559
+ "json": {
560
+ "description": "Format output as json.",
561
+ "helpGroup": "GLOBAL",
562
+ "name": "json",
563
+ "allowNo": false,
564
+ "type": "boolean"
565
+ },
566
+ "profile": {
567
+ "description": "Configuration profile to use",
568
+ "env": "BYTE_PROFILE",
569
+ "name": "profile",
570
+ "hasDynamicHelp": false,
571
+ "multiple": false,
572
+ "type": "option"
573
+ },
574
+ "base-url": {
575
+ "description": "Override the API base URL",
576
+ "env": "BYTE_BASE_URL",
577
+ "name": "base-url",
578
+ "hasDynamicHelp": false,
579
+ "multiple": false,
580
+ "type": "option"
581
+ },
582
+ "provider": {
583
+ "description": "Provider preset id (openai, deepseek, anthropic, …)",
584
+ "name": "provider",
585
+ "hasDynamicHelp": false,
586
+ "multiple": false,
587
+ "type": "option"
588
+ },
589
+ "provider-key": {
590
+ "description": "Upstream provider API key",
591
+ "env": "BYTE_PROVIDER_KEY",
592
+ "name": "provider-key",
593
+ "hasDynamicHelp": false,
594
+ "multiple": false,
595
+ "type": "option"
596
+ },
597
+ "provider-base-url": {
598
+ "description": "Custom provider base URL (for --provider custom)",
599
+ "name": "provider-base-url",
600
+ "hasDynamicHelp": false,
601
+ "multiple": false,
602
+ "type": "option"
603
+ },
604
+ "mode": {
605
+ "description": "Gateway mode override (byte_compatible/byte_messages/byte_generative)",
606
+ "name": "mode",
607
+ "hasDynamicHelp": false,
608
+ "multiple": false,
609
+ "type": "option"
610
+ },
611
+ "preset": {
612
+ "description": "Optimization mode",
613
+ "name": "preset",
614
+ "default": "maximum",
615
+ "hasDynamicHelp": false,
616
+ "multiple": false,
617
+ "options": [
618
+ "maximum",
619
+ "balanced",
620
+ "max_savings",
621
+ "lowest_latency",
622
+ "reliability_first"
623
+ ],
624
+ "type": "option"
625
+ },
626
+ "key-name": {
627
+ "description": "Name for the Byte key",
628
+ "name": "key-name",
629
+ "default": "cli",
630
+ "hasDynamicHelp": false,
631
+ "multiple": false,
632
+ "type": "option"
633
+ },
634
+ "skip-provider": {
635
+ "description": "Skip connecting a provider",
636
+ "name": "skip-provider",
637
+ "allowNo": false,
638
+ "type": "boolean"
639
+ },
640
+ "connect": {
641
+ "description": "Tool to wire after setup (e.g. opencode, codex)",
642
+ "name": "connect",
643
+ "hasDynamicHelp": false,
644
+ "multiple": false,
645
+ "type": "option"
646
+ }
647
+ },
648
+ "hasDynamicHelp": false,
649
+ "hiddenAliases": [],
650
+ "id": "setup",
651
+ "pluginAlias": "@bytevion/cli",
652
+ "pluginName": "@bytevion/cli",
653
+ "pluginType": "core",
654
+ "strict": true,
655
+ "enableJsonFlag": true,
656
+ "isESM": false,
657
+ "relativePath": [
658
+ "dist",
659
+ "commands",
660
+ "setup.js"
661
+ ]
662
+ },
478
663
  "stats": {
479
664
  "aliases": [],
480
665
  "args": {},
@@ -1018,18 +1203,19 @@
1018
1203
  "aliases": [],
1019
1204
  "args": {
1020
1205
  "preset": {
1021
- "description": "Preset to apply",
1206
+ "description": "Mode to apply",
1022
1207
  "name": "preset",
1023
1208
  "options": [
1024
- "balanced",
1209
+ "maximum",
1025
1210
  "max_savings",
1211
+ "balanced",
1026
1212
  "lowest_latency",
1027
1213
  "reliability_first"
1028
1214
  ],
1029
1215
  "required": true
1030
1216
  }
1031
1217
  },
1032
- "description": "Apply an optimization preset for the whole org.",
1218
+ "description": "Apply an optimization mode for the whole org (maximum, balanced, max_savings, lowest_latency, reliability_first).",
1033
1219
  "flags": {
1034
1220
  "json": {
1035
1221
  "description": "Format output as json.",
@@ -1140,7 +1326,7 @@
1140
1326
  "opt:show": {
1141
1327
  "aliases": [],
1142
1328
  "args": {},
1143
- "description": "Show the current optimization preset and layer states for the org.",
1329
+ "description": "Show the current optimization mode and every layer running on your requests.",
1144
1330
  "flags": {
1145
1331
  "json": {
1146
1332
  "description": "Format output as json.",
@@ -1185,10 +1371,10 @@
1185
1371
  "providers:add": {
1186
1372
  "aliases": [],
1187
1373
  "args": {},
1188
- "description": "Add an upstream provider key (BYOK). Byte stores it encrypted and can auto-import models.",
1374
+ "description": "Connect an upstream provider key (BYOK). Byte stores it encrypted and imports models.",
1189
1375
  "examples": [
1190
- "<%= config.bin %> providers add",
1191
- "<%= config.bin %> providers add --api-key sk-... --label \"OpenAI prod\""
1376
+ "<%= config.bin %> providers add --provider deepseek --api-key sk-...",
1377
+ "<%= config.bin %> providers add --provider custom --provider-base-url https://api.example.com/v1 --api-key ..."
1192
1378
  ],
1193
1379
  "flags": {
1194
1380
  "json": {
@@ -1214,6 +1400,13 @@
1214
1400
  "multiple": false,
1215
1401
  "type": "option"
1216
1402
  },
1403
+ "provider": {
1404
+ "description": "Provider preset id (openai, deepseek, anthropic, …)",
1405
+ "name": "provider",
1406
+ "hasDynamicHelp": false,
1407
+ "multiple": false,
1408
+ "type": "option"
1409
+ },
1217
1410
  "api-key": {
1218
1411
  "description": "Upstream provider API key",
1219
1412
  "env": "BYTE_PROVIDER_KEY",
@@ -1222,23 +1415,29 @@
1222
1415
  "multiple": false,
1223
1416
  "type": "option"
1224
1417
  },
1418
+ "provider-base-url": {
1419
+ "description": "Custom base URL (for --provider custom or to override)",
1420
+ "name": "provider-base-url",
1421
+ "hasDynamicHelp": false,
1422
+ "multiple": false,
1423
+ "type": "option"
1424
+ },
1225
1425
  "mode": {
1226
- "description": "Gateway mode for this provider",
1426
+ "description": "Gateway mode (byte_compatible/byte_messages/byte_generative)",
1227
1427
  "name": "mode",
1228
- "default": "byte_auto",
1229
1428
  "hasDynamicHelp": false,
1230
1429
  "multiple": false,
1231
1430
  "type": "option"
1232
1431
  },
1233
1432
  "label": {
1234
- "description": "A label for this connection",
1433
+ "description": "Label for this connection",
1235
1434
  "name": "label",
1236
1435
  "hasDynamicHelp": false,
1237
1436
  "multiple": false,
1238
1437
  "type": "option"
1239
1438
  },
1240
1439
  "no-fetch": {
1241
- "description": "Skip auto-importing the provider model list",
1440
+ "description": "Skip auto-importing the model list",
1242
1441
  "name": "no-fetch",
1243
1442
  "allowNo": false,
1244
1443
  "type": "boolean"
@@ -1512,5 +1711,5 @@
1512
1711
  ]
1513
1712
  }
1514
1713
  },
1515
- "version": "0.1.0"
1714
+ "version": "0.3.0"
1516
1715
  }