brito-cli 0.7.4 → 0.8.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/dist/setup.js DELETED
@@ -1,110 +0,0 @@
1
- import readline from "node:readline";
2
- import { hasClaudeCli } from "./agent/claude-cli.js";
3
- import { DEFAULT_MODEL, MODEL_ALIASES, saveEffort, saveModel, saveReasoningDisplay } from "./model.js";
4
- import { c } from "./ui/theme.js";
5
- const out = (s = "") => process.stdout.write(s + "\n");
6
- /** Menu de setas (↑/↓, j/k, número, Enter). Ctrl+C cancela o assistente. */
7
- async function select(title, options, current = 0) {
8
- const stdin = process.stdin;
9
- readline.emitKeypressEvents(stdin);
10
- stdin.setRawMode(true);
11
- stdin.resume();
12
- let idx = current;
13
- let drawn = 0;
14
- const render = () => {
15
- if (drawn)
16
- process.stdout.write(`\x1b[${drawn}A\x1b[J`);
17
- const lines = [c.bold(title)];
18
- options.forEach((o, i) => {
19
- const on = i === idx;
20
- lines.push(` ${on ? c.accent("❯") : " "} ${on ? c.light(o.label) : o.label}${o.hint ? c.muted(" " + o.hint) : ""}`);
21
- });
22
- lines.push(c.muted(" ↑/↓ navegar · Enter confirmar"));
23
- process.stdout.write(lines.join("\n") + "\n");
24
- drawn = lines.length;
25
- };
26
- render();
27
- return new Promise((resolve) => {
28
- const onKey = (_, key) => {
29
- if (key.ctrl && key.name === "c") {
30
- stdin.setRawMode(false);
31
- out();
32
- process.exit(130);
33
- }
34
- if (key.name === "up" || key.name === "k")
35
- idx = (idx + options.length - 1) % options.length;
36
- else if (key.name === "down" || key.name === "j")
37
- idx = (idx + 1) % options.length;
38
- else if (key.sequence && /^[1-9]$/.test(key.sequence) && Number(key.sequence) <= options.length)
39
- idx = Number(key.sequence) - 1;
40
- else if (key.name === "return") {
41
- stdin.off("keypress", onKey);
42
- stdin.setRawMode(false);
43
- stdin.pause();
44
- process.stdout.write(`\x1b[${drawn}A\x1b[J`);
45
- out(`${c.bold(title)} ${c.ok("✓")} ${c.light(options[idx].label)}`);
46
- return resolve(options[idx].value);
47
- }
48
- render();
49
- };
50
- stdin.on("keypress", onKey);
51
- });
52
- }
53
- const step = (n, total, name) => out(`\n${c.accent(`◆ Passo ${n}/${total}`)} ${c.muted("·")} ${c.bold(name)}`);
54
- export async function runSetup(opts = {}) {
55
- const interactive = !!process.stdin.isTTY && !!process.stdout.isTTY && !opts.yes;
56
- const total = 4;
57
- const hasKey = !!process.env.ANTHROPIC_API_KEY;
58
- const hasCli = hasClaudeCli();
59
- out();
60
- out(c.accent(" ╭─────────────────────────────────────╮"));
61
- out(c.accent(" │") + c.bold(" Brito · assistente de configuração".padEnd(37)) + c.accent("│"));
62
- out(c.accent(" ╰─────────────────────────────────────╯"));
63
- out(c.muted(" Escolhas ficam em ~/.brito/config.json; rode `brito setup` de novo quando quiser mudar."));
64
- // 1 · autenticação
65
- step(1, total, "Autenticação");
66
- out(` ${hasKey ? c.ok("✓") : c.muted("·")} ANTHROPIC_API_KEY ${hasKey ? "definida" : "não definida"}`);
67
- out(` ${hasCli ? c.ok("✓") : c.muted("·")} Claude Code (claude CLI) ${hasCli ? "encontrado" : "não encontrado"}`);
68
- if (!hasKey && !hasCli) {
69
- out(c.warn(" Nenhum acesso detectado. Escolha um e depois rode `brito`:"));
70
- out(c.muted(" • export ANTHROPIC_API_KEY=sk-ant-… (chave da API)"));
71
- out(c.muted(" • npm i -g @anthropic-ai/claude-code && claude → /login (assinatura)"));
72
- }
73
- let model = DEFAULT_MODEL;
74
- let effort;
75
- let showReasoning = true;
76
- if (interactive) {
77
- // 2 · modelo
78
- step(2, total, "Modelo padrão");
79
- const names = Object.keys(MODEL_ALIASES);
80
- const hints = { fable: "mais capaz", opus: "raciocínio profundo", sonnet: "equilíbrio (recomendado)", haiku: "rápido e barato" };
81
- model = await select("Qual modelo usar por padrão?", names.map((n) => ({ label: n, hint: hints[n], value: MODEL_ALIASES[n] })), names.indexOf("sonnet"));
82
- // 3 · esforço
83
- step(3, total, "Esforço de raciocínio");
84
- effort = await select("Quanto o modelo deve pensar?", [
85
- { label: "padrão", hint: "deixa o claude decidir", value: undefined },
86
- { label: "low", hint: "respostas rápidas", value: "low" },
87
- { label: "medium", value: "medium" },
88
- { label: "high", hint: "tarefas difíceis", value: "high" },
89
- { label: "max", hint: "mais lento e caro", value: "max" },
90
- ]);
91
- // 4 · exibição
92
- step(4, total, "Exibição");
93
- showReasoning = await select("Mostrar o raciocínio do modelo?", [
94
- { label: "sim", hint: "recortado, como no Hermes", value: true },
95
- { label: "não", value: false },
96
- ]);
97
- }
98
- else {
99
- out(c.muted(`\n Modo não interativo: usando padrões (${DEFAULT_MODEL}).`));
100
- }
101
- saveModel(model);
102
- saveEffort(effort);
103
- saveReasoningDisplay({ show: showReasoning });
104
- const row = (k, v) => out(` ${c.muted(k.padEnd(12))} ${v}`);
105
- out(`\n${c.ok("✓")} ${c.bold("Tudo pronto")}`);
106
- row("modelo", model);
107
- row("esforço", effort ?? "padrão");
108
- row("raciocínio", showReasoning ? "visível" : "oculto");
109
- out(`\n Próximo passo: ${c.light("cd seu-projeto && brito")}\n`);
110
- }