bravecode-cli 0.1.2 → 0.1.4
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/bravecode +22 -0
- package/dist/cli.cjs +98 -40
- package/dist/cli.cjs.map +4 -4
- package/dist/cli.js +16 -7
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +40705 -537
- package/dist/cli.mjs.map +4 -4
- package/dist/core/tui/ChatTUI.d.ts +1 -2
- package/dist/core/tui/ChatTUI.d.ts.map +1 -1
- package/dist/core/tui/ChatTUI.js +5 -4
- package/dist/core/tui/ChatTUI.js.map +1 -1
- package/dist/core/tui/index.d.ts.map +1 -1
- package/dist/core/tui/index.js +10 -6
- package/dist/core/tui/index.js.map +1 -1
- package/dist/tui/ChatTUI.mjs +89 -0
- package/dist/tui-launcher.mjs +64 -0
- package/package.json +2 -2
package/dist/bravecode
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const BANNER = `
|
|
4
|
+
██████╗ ██████╗ ██████╗ ███████╗███████╗██╗ ██╗██████╗ █████╗ ██████╗ ██╗███████╗███████╗
|
|
5
|
+
██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔════╝██║ ██║██╔══██╗██╔══██╗██╔══██╗██║██╔════╝██╔════╝
|
|
6
|
+
██║ ██║ ██║██████╔╝█████╗ ███████╗██║ ██║██████╔╝███████║██████╔╝██║█████╗ ███████╗
|
|
7
|
+
██║ ██║ ██║██╔═══╝ ██╔══╝ ╚════██║██║ ██║██╔══██╗██╔══██║██╔══██╗██║██╔══╝ ╚════██║
|
|
8
|
+
╚██████╗╚██████╔╝██║ ███████╗███████║╚██████╔╝██║ ██║██║ ██║██║ ██║██║███████╗███████║
|
|
9
|
+
╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚══════╝╚══════╝
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
|
|
14
|
+
if (args.length === 0 || args[0] === "chat") {
|
|
15
|
+
console.log(BANNER);
|
|
16
|
+
import("./tui-launcher.mjs").then(m => m.main()).catch(err => {
|
|
17
|
+
console.error("Failed to launch TUI:", err.message);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
require("./cli.cjs");
|
|
22
|
+
}
|
package/dist/cli.cjs
CHANGED
|
@@ -40711,12 +40711,81 @@ IMPORTANT: Only test APIs you have authorization to test. Never attempt to acces
|
|
|
40711
40711
|
}
|
|
40712
40712
|
});
|
|
40713
40713
|
|
|
40714
|
+
// src/core/tui/simple-tui.ts
|
|
40715
|
+
var simple_tui_exports = {};
|
|
40716
|
+
__export(simple_tui_exports, {
|
|
40717
|
+
startSimpleTUI: () => startSimpleTUI
|
|
40718
|
+
});
|
|
40719
|
+
async function startSimpleTUI(model, agentId) {
|
|
40720
|
+
const provider = new LLMProviderManager();
|
|
40721
|
+
const tools = new ToolRegistry();
|
|
40722
|
+
const agentConfig = defaultAgents.find((a) => a.id === (agentId || "build")) || defaultAgents[0];
|
|
40723
|
+
const agentName = agentConfig.name;
|
|
40724
|
+
const modelName = model || agentConfig.model;
|
|
40725
|
+
const agent = new Agent(provider, tools, {
|
|
40726
|
+
...agentConfig,
|
|
40727
|
+
model: modelName
|
|
40728
|
+
});
|
|
40729
|
+
console.log(`Agent: ${agentName} | Model: ${modelName}`);
|
|
40730
|
+
console.log("Type your message and press Enter. Type 'exit' or press Ctrl+C to quit.\n");
|
|
40731
|
+
const rl = readline.createInterface({
|
|
40732
|
+
input: process.stdin,
|
|
40733
|
+
output: process.stdout
|
|
40734
|
+
});
|
|
40735
|
+
const prompt = () => {
|
|
40736
|
+
rl.question("\x1B[32m>\x1B[0m ", async (input) => {
|
|
40737
|
+
const trimmed = input.trim();
|
|
40738
|
+
if (trimmed === "exit" || trimmed === "quit") {
|
|
40739
|
+
console.log("\nGoodbye!");
|
|
40740
|
+
rl.close();
|
|
40741
|
+
process.exit(0);
|
|
40742
|
+
}
|
|
40743
|
+
if (!trimmed) {
|
|
40744
|
+
prompt();
|
|
40745
|
+
return;
|
|
40746
|
+
}
|
|
40747
|
+
try {
|
|
40748
|
+
let response = "";
|
|
40749
|
+
await agent.run(trimmed, (chunk) => {
|
|
40750
|
+
process.stdout.write(chunk);
|
|
40751
|
+
response += chunk;
|
|
40752
|
+
});
|
|
40753
|
+
console.log("\n");
|
|
40754
|
+
} catch (error40) {
|
|
40755
|
+
console.error(`
|
|
40756
|
+
Error: ${error40.message}
|
|
40757
|
+
`);
|
|
40758
|
+
}
|
|
40759
|
+
prompt();
|
|
40760
|
+
});
|
|
40761
|
+
};
|
|
40762
|
+
rl.on("SIGINT", () => {
|
|
40763
|
+
console.log("\nGoodbye!");
|
|
40764
|
+
rl.close();
|
|
40765
|
+
process.exit(0);
|
|
40766
|
+
});
|
|
40767
|
+
prompt();
|
|
40768
|
+
}
|
|
40769
|
+
var readline;
|
|
40770
|
+
var init_simple_tui = __esm({
|
|
40771
|
+
"src/core/tui/simple-tui.ts"() {
|
|
40772
|
+
"use strict";
|
|
40773
|
+
readline = __toESM(require("readline"), 1);
|
|
40774
|
+
init_provider();
|
|
40775
|
+
init_tool();
|
|
40776
|
+
init_agent();
|
|
40777
|
+
}
|
|
40778
|
+
});
|
|
40779
|
+
|
|
40714
40780
|
// src/core/tui/ChatTUI.tsx
|
|
40781
|
+
var ChatTUI_exports = {};
|
|
40782
|
+
__export(ChatTUI_exports, {
|
|
40783
|
+
ChatTUI: () => ChatTUI
|
|
40784
|
+
});
|
|
40715
40785
|
function ChatTUI({ agentName, modelName, onMessage, onExit }) {
|
|
40716
40786
|
const [messages, setMessages] = (0, import_react.useState)([]);
|
|
40717
40787
|
const [input, setInput] = (0, import_react.useState)("");
|
|
40718
40788
|
const [isLoading, setIsLoading] = (0, import_react.useState)(false);
|
|
40719
|
-
const [activeTab, setActiveTab] = (0, import_react.useState)("chat");
|
|
40720
40789
|
const { exit } = (0, import_ink.useApp)();
|
|
40721
40790
|
const handleSubmit = (0, import_react.useCallback)(async (value) => {
|
|
40722
40791
|
if (!value.trim()) return;
|
|
@@ -40756,13 +40825,6 @@ function ChatTUI({ agentName, modelName, onMessage, onExit }) {
|
|
|
40756
40825
|
onExit();
|
|
40757
40826
|
exit();
|
|
40758
40827
|
}
|
|
40759
|
-
if (key.tab) {
|
|
40760
|
-
setActiveTab((prev) => {
|
|
40761
|
-
if (prev === "chat") return "tools";
|
|
40762
|
-
if (prev === "tools") return "agents";
|
|
40763
|
-
return "chat";
|
|
40764
|
-
});
|
|
40765
|
-
}
|
|
40766
40828
|
});
|
|
40767
40829
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "column", height: "100%", children: [
|
|
40768
40830
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { borderStyle: "round", borderColor: "blue", padding: 1, flexDirection: "column", children: [
|
|
@@ -40777,9 +40839,6 @@ function ChatTUI({ agentName, modelName, onMessage, onExit }) {
|
|
|
40777
40839
|
messages.map((msg) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Box, { marginBottom: 1, children: msg.role === "user" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { children: [
|
|
40778
40840
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { bold: true, color: "green", children: "You: " }),
|
|
40779
40841
|
msg.content
|
|
40780
|
-
] }) : msg.role === "tool" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "yellow", children: [
|
|
40781
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { bold: true, children: "[Tool] " }),
|
|
40782
|
-
msg.content
|
|
40783
40842
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { children: [
|
|
40784
40843
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { bold: true, color: "blue", children: [
|
|
40785
40844
|
msg.agent || "AI",
|
|
@@ -40790,13 +40849,9 @@ function ChatTUI({ agentName, modelName, onMessage, onExit }) {
|
|
|
40790
40849
|
isLoading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "gray", italic: true, children: "Thinking..." })
|
|
40791
40850
|
] })
|
|
40792
40851
|
] }),
|
|
40793
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Box, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime.
|
|
40794
|
-
"[",
|
|
40795
|
-
activeTab.toUpperCase(),
|
|
40796
|
-
"] Tab: switch | Ctrl+C: exit"
|
|
40797
|
-
] }) }),
|
|
40852
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Box, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "gray", children: "Ctrl+C: exit" }) }),
|
|
40798
40853
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { marginTop: 1, children: [
|
|
40799
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "green", bold: true, children: "
|
|
40854
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "green", bold: true, children: "> " }),
|
|
40800
40855
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
40801
40856
|
import_ink_text_input.default,
|
|
40802
40857
|
{
|
|
@@ -40825,17 +40880,13 @@ var tui_exports = {};
|
|
|
40825
40880
|
__export(tui_exports, {
|
|
40826
40881
|
TUILauncher: () => TUILauncher
|
|
40827
40882
|
});
|
|
40828
|
-
var
|
|
40883
|
+
var TUILauncher;
|
|
40829
40884
|
var init_tui = __esm({
|
|
40830
40885
|
"src/core/tui/index.tsx"() {
|
|
40831
40886
|
"use strict";
|
|
40832
|
-
import_react2 = require("react");
|
|
40833
|
-
import_ink2 = require("ink");
|
|
40834
|
-
init_ChatTUI();
|
|
40835
40887
|
init_provider();
|
|
40836
40888
|
init_tool();
|
|
40837
40889
|
init_agent();
|
|
40838
|
-
import_jsx_runtime2 = require("react/jsx-runtime");
|
|
40839
40890
|
TUILauncher = class {
|
|
40840
40891
|
provider;
|
|
40841
40892
|
tools;
|
|
@@ -40854,6 +40905,9 @@ var init_tui = __esm({
|
|
|
40854
40905
|
});
|
|
40855
40906
|
}
|
|
40856
40907
|
async start() {
|
|
40908
|
+
const React2 = await import("react");
|
|
40909
|
+
const { render } = await import("ink");
|
|
40910
|
+
const { ChatTUI: ChatTUI2 } = await Promise.resolve().then(() => (init_ChatTUI(), ChatTUI_exports));
|
|
40857
40911
|
const onMessage = async (message) => {
|
|
40858
40912
|
let response = "";
|
|
40859
40913
|
await this.agent.run(message, (chunk) => {
|
|
@@ -40862,19 +40916,16 @@ var init_tui = __esm({
|
|
|
40862
40916
|
return response;
|
|
40863
40917
|
};
|
|
40864
40918
|
const onExit = () => {
|
|
40865
|
-
console.log("\nGoodbye!
|
|
40919
|
+
console.log("\nGoodbye!");
|
|
40866
40920
|
process.exit(0);
|
|
40867
40921
|
};
|
|
40868
|
-
const { waitUntilExit } =
|
|
40869
|
-
|
|
40870
|
-
|
|
40871
|
-
|
|
40872
|
-
|
|
40873
|
-
|
|
40874
|
-
|
|
40875
|
-
onExit
|
|
40876
|
-
}
|
|
40877
|
-
)
|
|
40922
|
+
const { waitUntilExit } = render(
|
|
40923
|
+
React2.createElement(ChatTUI2, {
|
|
40924
|
+
agentName: this.agentName,
|
|
40925
|
+
modelName: this.modelName,
|
|
40926
|
+
onMessage,
|
|
40927
|
+
onExit
|
|
40928
|
+
})
|
|
40878
40929
|
);
|
|
40879
40930
|
await waitUntilExit();
|
|
40880
40931
|
}
|
|
@@ -41347,9 +41398,21 @@ var UpdateChecker = class {
|
|
|
41347
41398
|
var import_fs9 = require("fs");
|
|
41348
41399
|
var import_path7 = require("path");
|
|
41349
41400
|
var program2 = new Command();
|
|
41350
|
-
|
|
41401
|
+
var BANNER = `
|
|
41402
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557
|
|
41403
|
+
\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551
|
|
41404
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551
|
|
41405
|
+
\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551
|
|
41406
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551
|
|
41407
|
+
\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D
|
|
41408
|
+
`;
|
|
41409
|
+
program2.name("bravecode").description("BraveCode AI - Agentic AI Vibe Coding CLI with free model support").version("0.1.2").action(async () => {
|
|
41410
|
+
console.log(BANNER);
|
|
41411
|
+
const { startSimpleTUI: startSimpleTUI2 } = await Promise.resolve().then(() => (init_simple_tui(), simple_tui_exports));
|
|
41412
|
+
await startSimpleTUI2();
|
|
41413
|
+
});
|
|
41351
41414
|
program2.command("chat").description("Start a chat session").option("-m, --model <model>", "Model to use (or 'auto' for auto-selection)").option("-t, --task <task>", "Task type hint (code, reasoning, vision, audio, general)").option("-a, --agent <agent>", "Agent to use", "build").option("--tui", "Launch interactive TUI mode").argument("[prompt]", "Initial prompt").action(async (prompt, options) => {
|
|
41352
|
-
if (options.tui) {
|
|
41415
|
+
if (!prompt || options.tui) {
|
|
41353
41416
|
const { TUILauncher: TUILauncher2 } = await Promise.resolve().then(() => (init_tui(), tui_exports));
|
|
41354
41417
|
const launcher = new TUILauncher2(options.model, options.agent);
|
|
41355
41418
|
await launcher.start();
|
|
@@ -41357,11 +41420,6 @@ program2.command("chat").description("Start a chat session").option("-m, --model
|
|
|
41357
41420
|
}
|
|
41358
41421
|
const provider = new LLMProviderManager();
|
|
41359
41422
|
const autoModel = new AutoModelSelector();
|
|
41360
|
-
if (!prompt) {
|
|
41361
|
-
console.log("Interactive mode coming soon. For now, provide a prompt:");
|
|
41362
|
-
console.log(' bravecode chat "Write a hello world program"');
|
|
41363
|
-
return;
|
|
41364
|
-
}
|
|
41365
41423
|
let modelId;
|
|
41366
41424
|
if (options.model === "auto" || !options.model) {
|
|
41367
41425
|
const taskType = options.task || autoModel.detectTaskType(prompt);
|