gearbox-code 0.1.8 → 0.1.9
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/dist/cli.mjs +101 -32
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -136281,8 +136281,48 @@ function App2({ selector: initialSelector, runner, fullscreen = false, resumeId
|
|
|
136281
136281
|
var jsx_dev_runtime13 = __toESM(require_jsx_dev_runtime(), 1);
|
|
136282
136282
|
process.env.LANG = process.env.LANG || "en_US.UTF-8";
|
|
136283
136283
|
process.env.LC_ALL = process.env.LC_ALL || "en_US.UTF-8";
|
|
136284
|
-
var VERSION16 = "0.1.
|
|
136284
|
+
var VERSION16 = "0.1.9";
|
|
136285
136285
|
var args = process.argv.slice(2);
|
|
136286
|
+
var supportsAnsi = process.env.NO_COLOR !== "1" && process.env.TERM !== "dumb" && (process.stdout.isTTY || process.env.FORCE_COLOR === "1");
|
|
136287
|
+
var ansi = (code) => supportsAnsi ? `\x1B[${code}m` : "";
|
|
136288
|
+
var paint = (code, text2) => `${ansi(code)}${text2}${ansi("0")}`;
|
|
136289
|
+
var bold = (text2) => paint("1", text2);
|
|
136290
|
+
var accent = (text2) => paint("36", text2);
|
|
136291
|
+
var dim = (text2) => paint("2", text2);
|
|
136292
|
+
var ok = (text2) => paint("32", text2);
|
|
136293
|
+
var warn = (text2) => paint("33", text2);
|
|
136294
|
+
var errColor = (text2) => paint("31", text2);
|
|
136295
|
+
var stripAnsi2 = (text2) => text2.replace(/\x1b\[[0-9;]*m/g, "");
|
|
136296
|
+
var visibleLength = (text2) => stripAnsi2(text2).length;
|
|
136297
|
+
var padVisible = (text2, width) => text2 + " ".repeat(Math.max(width - visibleLength(text2), 0));
|
|
136298
|
+
function onboardingBoo() {
|
|
136299
|
+
return [
|
|
136300
|
+
" .-''''-.",
|
|
136301
|
+
" .' .--. '.",
|
|
136302
|
+
" / ( ) \\",
|
|
136303
|
+
" | .-. .-. |",
|
|
136304
|
+
" | |_| |_| |",
|
|
136305
|
+
" | __ |",
|
|
136306
|
+
" \\ .' '. /",
|
|
136307
|
+
" '._\\____/_.'",
|
|
136308
|
+
" /| |\\"
|
|
136309
|
+
].join(`
|
|
136310
|
+
`);
|
|
136311
|
+
}
|
|
136312
|
+
function box(title, lines) {
|
|
136313
|
+
const width = Math.min(78, Math.max(title.length + 4, ...lines.map((l) => visibleLength(l) + 4)));
|
|
136314
|
+
const rule = "─".repeat(width - 2);
|
|
136315
|
+
console.log(accent(`╭${rule}╮`));
|
|
136316
|
+
console.log(accent("│ ") + padVisible(bold(title), width - 3) + accent("│"));
|
|
136317
|
+
console.log(accent(`├${rule}┤`));
|
|
136318
|
+
for (const line of lines) {
|
|
136319
|
+
console.log(accent("│ ") + padVisible(line, width - 3) + accent("│"));
|
|
136320
|
+
}
|
|
136321
|
+
console.log(accent(`╰${rule}╯`));
|
|
136322
|
+
}
|
|
136323
|
+
function optionLine(key, label, detail) {
|
|
136324
|
+
return `${accent(key.padStart(2))} ${bold(label)} ${dim(detail)}`;
|
|
136325
|
+
}
|
|
136286
136326
|
async function runCliOnboarding() {
|
|
136287
136327
|
const { listAccounts: listAccounts2 } = await Promise.resolve().then(() => (init_store(), exports_store));
|
|
136288
136328
|
const { importableEnvCreds: importableEnvCreds2, importEnvCred: importEnvCred2, importableCloudCreds: importableCloudCreds2, importCloudCred: importCloudCred2 } = await Promise.resolve().then(() => (init_detect(), exports_detect));
|
|
@@ -136290,41 +136330,55 @@ async function runCliOnboarding() {
|
|
|
136290
136330
|
const { subscriptionEnv: subscriptionEnv2 } = await Promise.resolve().then(() => (init_cli_backend(), exports_cli_backend));
|
|
136291
136331
|
const { detectProviderByKey: detectProviderByKey2 } = await Promise.resolve().then(() => (init_catalog(), exports_catalog));
|
|
136292
136332
|
const { which: which2 } = await Promise.resolve().then(() => (init_proc(), exports_proc));
|
|
136293
|
-
const
|
|
136294
|
-
const
|
|
136295
|
-
const
|
|
136333
|
+
const pipedAnswers = process.stdin.isTTY ? null : (await readStdin()).split(/\r?\n/);
|
|
136334
|
+
const rl = pipedAnswers ? null : createInterface({ input: process.stdin, output: process.stdout });
|
|
136335
|
+
const ask = async (q) => {
|
|
136336
|
+
if (pipedAnswers) {
|
|
136337
|
+
const answer = (pipedAnswers.shift() ?? "").trim();
|
|
136338
|
+
console.log(accent(q) + answer);
|
|
136339
|
+
return answer;
|
|
136340
|
+
}
|
|
136341
|
+
return (await rl.question(accent(q))).trim();
|
|
136342
|
+
};
|
|
136343
|
+
const providerRows = () => addableProviders2().map((p) => ` ${accent(p.id.padEnd(16))} ${p.label}`).join(`
|
|
136296
136344
|
`);
|
|
136297
136345
|
const testAndReport = async (account) => {
|
|
136298
|
-
console.log("Testing credential...");
|
|
136346
|
+
console.log(dim("Testing credential with the provider..."));
|
|
136299
136347
|
const t2 = await testAccount2(account);
|
|
136300
|
-
console.log(t2.ok ? `
|
|
136348
|
+
console.log(t2.ok ? ok(`Credential works: ${t2.message}`) : warn(`Stored, but the live test failed: ${t2.message}`));
|
|
136301
136349
|
};
|
|
136302
136350
|
const addSubscription = async (provider) => {
|
|
136303
136351
|
const res = addCliAccount2(provider);
|
|
136304
|
-
console.log(res.message);
|
|
136352
|
+
console.log(res.ok ? ok(res.message) : errColor(res.message));
|
|
136305
136353
|
if (!res.ok || !res.account || res.account.auth.kind !== "cli")
|
|
136306
136354
|
return false;
|
|
136307
136355
|
const bin = res.account.auth.binary;
|
|
136308
136356
|
const profile = res.account.auth.loginProfile;
|
|
136309
136357
|
let status = await cliAuthStatus2(bin, profile);
|
|
136310
136358
|
if (!status.loggedIn) {
|
|
136311
|
-
console.log(`Starting ${bin} sign-in...`);
|
|
136359
|
+
console.log(dim(`Starting ${bin} sign-in in this terminal...`));
|
|
136312
136360
|
const r2 = spawnSync(bin, cliLoginArgs2(bin), { stdio: "inherit", env: subscriptionEnv2(bin, profile) });
|
|
136313
136361
|
if ((r2.status ?? 1) !== 0)
|
|
136314
136362
|
return false;
|
|
136315
136363
|
status = await cliAuthStatus2(bin, profile);
|
|
136316
136364
|
}
|
|
136317
136365
|
if (!status.loggedIn) {
|
|
136318
|
-
console.log(`${bin} did not report a completed sign-in.`);
|
|
136366
|
+
console.log(warn(`${bin} did not report a completed sign-in.`));
|
|
136319
136367
|
return false;
|
|
136320
136368
|
}
|
|
136321
|
-
console.log(
|
|
136369
|
+
console.log(ok(`${bin} subscription ready${status.detail ? ` (${status.detail})` : ""}`));
|
|
136322
136370
|
return true;
|
|
136323
136371
|
};
|
|
136324
136372
|
try {
|
|
136325
136373
|
console.log("");
|
|
136326
|
-
|
|
136327
|
-
|
|
136374
|
+
if (supportsAnsi)
|
|
136375
|
+
console.log(paint("38;5;117", onboardingBoo()));
|
|
136376
|
+
else
|
|
136377
|
+
console.log(onboardingBoo());
|
|
136378
|
+
console.log("");
|
|
136379
|
+
console.log(bold("Gearbox setup"));
|
|
136380
|
+
console.log("Boo needs one model account before the coding app opens.");
|
|
136381
|
+
console.log(dim("Your credentials stay local. API keys are stored in Gearbox's credential store; subscription sign-ins stay inside the vendor CLI."));
|
|
136328
136382
|
console.log("");
|
|
136329
136383
|
while (!anyProviderAvailable()) {
|
|
136330
136384
|
const env3 = importableEnvCreds2();
|
|
@@ -136332,27 +136386,32 @@ async function runCliOnboarding() {
|
|
|
136332
136386
|
const existing = listAccounts2();
|
|
136333
136387
|
if (existing.length)
|
|
136334
136388
|
break;
|
|
136335
|
-
|
|
136336
|
-
if (env3.length || cloud.length)
|
|
136337
|
-
|
|
136338
|
-
|
|
136339
|
-
|
|
136340
|
-
|
|
136389
|
+
const options2 = [];
|
|
136390
|
+
if (env3.length || cloud.length) {
|
|
136391
|
+
const names = [...env3.map((c) => c.envVar), ...cloud.map((c) => `${c.label} (${c.source})`)];
|
|
136392
|
+
options2.push(optionLine("1", "Import detected credentials", names.join(", ")));
|
|
136393
|
+
}
|
|
136394
|
+
options2.push(optionLine("2", "Paste API key", "auto-detects common key prefixes"));
|
|
136395
|
+
options2.push(optionLine("3", "Choose provider + key", "Anthropic, OpenAI, Gemini, OpenRouter, Groq, ..."));
|
|
136396
|
+
options2.push(optionLine("4", "Azure endpoint + key", "Azure OpenAI or Azure AI Foundry"));
|
|
136341
136397
|
if (which2("claude"))
|
|
136342
|
-
|
|
136398
|
+
options2.push(optionLine("5", "Claude subscription", "uses the official claude CLI; no token extraction"));
|
|
136343
136399
|
if (which2("codex"))
|
|
136344
|
-
|
|
136345
|
-
|
|
136346
|
-
|
|
136400
|
+
options2.push(optionLine("6", "ChatGPT subscription", "uses the official codex CLI; no token extraction"));
|
|
136401
|
+
options2.push(optionLine("p", "Show provider catalog", "all API-key providers Gearbox knows how to add"));
|
|
136402
|
+
options2.push(optionLine("q", "Quit setup", "Gearbox will not open the coding app yet"));
|
|
136403
|
+
box("Choose how Gearbox should connect", options2);
|
|
136347
136404
|
console.log("");
|
|
136348
136405
|
const choice = (await ask("Selection: ")).toLowerCase();
|
|
136349
136406
|
if (choice === "q" || choice === "quit" || choice === "skip") {
|
|
136350
136407
|
console.log("");
|
|
136351
|
-
console.log("Setup skipped. Run `gearbox onboard` when you are ready.");
|
|
136408
|
+
console.log(warn("Setup skipped. Run `gearbox onboard` when you are ready."));
|
|
136352
136409
|
return false;
|
|
136353
136410
|
}
|
|
136354
136411
|
if (choice === "p" || choice === "providers") {
|
|
136355
136412
|
console.log("");
|
|
136413
|
+
console.log(bold("Provider catalog"));
|
|
136414
|
+
console.log(dim("Use these ids with: gearbox auth add <provider> <api-key>"));
|
|
136356
136415
|
console.log(providerRows());
|
|
136357
136416
|
console.log("");
|
|
136358
136417
|
continue;
|
|
@@ -136362,20 +136421,21 @@ async function runCliOnboarding() {
|
|
|
136362
136421
|
await importEnvCred2(c);
|
|
136363
136422
|
for (const c of cloud)
|
|
136364
136423
|
await importCloudCred2(c);
|
|
136365
|
-
console.log(`Imported ${env3.length + cloud.length} credential${env3.length + cloud.length === 1 ? "" : "s"}.`);
|
|
136424
|
+
console.log(ok(`Imported ${env3.length + cloud.length} credential${env3.length + cloud.length === 1 ? "" : "s"}.`));
|
|
136366
136425
|
break;
|
|
136367
136426
|
}
|
|
136368
136427
|
if (choice === "2") {
|
|
136428
|
+
console.log(dim("Paste is visible in most terminals. Use option 3 if you want to be explicit about the provider."));
|
|
136369
136429
|
const key = await ask("Paste API key: ");
|
|
136370
136430
|
if (!key)
|
|
136371
136431
|
continue;
|
|
136372
136432
|
const detected = detectProviderByKey2(key);
|
|
136373
136433
|
if (!detected) {
|
|
136374
|
-
console.log("Could not detect the provider from that key. Use option 3.");
|
|
136434
|
+
console.log(warn("Could not detect the provider from that key. Use option 3."));
|
|
136375
136435
|
continue;
|
|
136376
136436
|
}
|
|
136377
136437
|
const res = await addByPastedKey2(key);
|
|
136378
|
-
console.log(res.message);
|
|
136438
|
+
console.log(res.ok ? ok(res.message) : errColor(res.message));
|
|
136379
136439
|
if (res.ok && res.account) {
|
|
136380
136440
|
await testAndReport(res.account);
|
|
136381
136441
|
break;
|
|
@@ -136384,12 +136444,14 @@ async function runCliOnboarding() {
|
|
|
136384
136444
|
}
|
|
136385
136445
|
if (choice === "3") {
|
|
136386
136446
|
console.log("");
|
|
136447
|
+
console.log(bold("Provider catalog"));
|
|
136387
136448
|
console.log(providerRows());
|
|
136388
136449
|
console.log("");
|
|
136389
136450
|
const provider = await ask("Provider id: ");
|
|
136451
|
+
console.log(dim("The key is stored locally and tested before setup finishes."));
|
|
136390
136452
|
const key = await ask("API key: ");
|
|
136391
136453
|
const res = await addApiKeyAccount2(provider, key);
|
|
136392
|
-
console.log(res.message);
|
|
136454
|
+
console.log(res.ok ? ok(res.message) : errColor(res.message));
|
|
136393
136455
|
if (res.ok && res.account) {
|
|
136394
136456
|
await testAndReport(res.account);
|
|
136395
136457
|
break;
|
|
@@ -136397,11 +136459,12 @@ async function runCliOnboarding() {
|
|
|
136397
136459
|
continue;
|
|
136398
136460
|
}
|
|
136399
136461
|
if (choice === "4") {
|
|
136462
|
+
console.log(dim("Use a resource name like my-openai-resource, or a full Foundry endpoint URL."));
|
|
136400
136463
|
const endpoint = await ask("Azure resource name or endpoint: ");
|
|
136401
136464
|
const key = await ask("API key: ");
|
|
136402
136465
|
const apiVersion = await ask("API version (optional): ");
|
|
136403
136466
|
const res = /^https?:\/\//i.test(endpoint) ? await addAzureFoundryAccount2(endpoint, key) : await addAzureAccount2(endpoint, key, { apiVersion: apiVersion || undefined });
|
|
136404
|
-
console.log(res.message);
|
|
136467
|
+
console.log(res.ok ? ok(res.message) : errColor(res.message));
|
|
136405
136468
|
if (res.ok && res.account) {
|
|
136406
136469
|
await testAndReport(res.account);
|
|
136407
136470
|
break;
|
|
@@ -136418,16 +136481,22 @@ async function runCliOnboarding() {
|
|
|
136418
136481
|
break;
|
|
136419
136482
|
continue;
|
|
136420
136483
|
}
|
|
136421
|
-
console.log("Choose one of the listed options.");
|
|
136484
|
+
console.log(warn("Choose one of the listed options."));
|
|
136422
136485
|
}
|
|
136423
136486
|
console.log("");
|
|
136424
|
-
console.log("Gearbox is ready.");
|
|
136425
|
-
console.log("
|
|
136487
|
+
console.log(ok("Gearbox is ready."));
|
|
136488
|
+
console.log(`Next: ${accent("cd ~/your-project")} and run ${accent("gearbox")}.`);
|
|
136426
136489
|
return true;
|
|
136427
136490
|
} finally {
|
|
136428
|
-
rl
|
|
136491
|
+
rl?.close();
|
|
136429
136492
|
}
|
|
136430
136493
|
}
|
|
136494
|
+
async function readStdin() {
|
|
136495
|
+
let input = "";
|
|
136496
|
+
for await (const chunk2 of process.stdin)
|
|
136497
|
+
input += chunk2;
|
|
136498
|
+
return input;
|
|
136499
|
+
}
|
|
136431
136500
|
if (args[0] === "upgrade" || args[0] === "update") {
|
|
136432
136501
|
const root2 = resolve11(import.meta.dir, "..");
|
|
136433
136502
|
if (!existsSync8(resolve11(root2, ".git"))) {
|
package/package.json
CHANGED