bravecode-cli 0.1.30 → 0.1.32
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-main.mjs +169 -48
- package/dist/cli-main.mjs.map +3 -3
- package/package.json +1 -1
package/dist/cli-main.mjs
CHANGED
|
@@ -38185,7 +38185,7 @@ var APP_VERSION, APP_NAME;
|
|
|
38185
38185
|
var init_version = __esm({
|
|
38186
38186
|
"src/version.ts"() {
|
|
38187
38187
|
"use strict";
|
|
38188
|
-
APP_VERSION = "0.1.
|
|
38188
|
+
APP_VERSION = "0.1.32";
|
|
38189
38189
|
APP_NAME = "BraveCode";
|
|
38190
38190
|
}
|
|
38191
38191
|
});
|
|
@@ -42129,28 +42129,91 @@ function MessageContainer() {
|
|
|
42129
42129
|
const { colors: colors2 } = useTheme();
|
|
42130
42130
|
return /* @__PURE__ */ jsx("scrollbox", { style: { flexGrow: 1, backgroundColor: colors2.bg, paddingLeft: 1, paddingRight: 1 }, children: /* @__PURE__ */ jsx("box", { style: { flexDirection: "column", gap: 1, paddingTop: 1 }, children: messages.map((msg) => /* @__PURE__ */ jsx(MessageBubble, { msg }, s(msg.id))) }) });
|
|
42131
42131
|
}
|
|
42132
|
+
function CommandPalette({
|
|
42133
|
+
filter: filter3,
|
|
42134
|
+
selectedIndex
|
|
42135
|
+
}) {
|
|
42136
|
+
const { colors: colors2 } = useTheme();
|
|
42137
|
+
const filtered = React4.useMemo(() => {
|
|
42138
|
+
if (!filter3) return COMMANDS;
|
|
42139
|
+
const lower = filter3.toLowerCase();
|
|
42140
|
+
return COMMANDS.filter((c) => c.name.toLowerCase().includes(lower));
|
|
42141
|
+
}, [filter3]);
|
|
42142
|
+
if (filtered.length === 0) return null;
|
|
42143
|
+
return /* @__PURE__ */ jsxs(
|
|
42144
|
+
"box",
|
|
42145
|
+
{
|
|
42146
|
+
style: {
|
|
42147
|
+
position: "absolute",
|
|
42148
|
+
bottom: 6,
|
|
42149
|
+
width: 50,
|
|
42150
|
+
maxHeight: 12,
|
|
42151
|
+
border: true,
|
|
42152
|
+
borderStyle: "rounded",
|
|
42153
|
+
borderColor: colors2.primary,
|
|
42154
|
+
backgroundColor: colors2.surface2,
|
|
42155
|
+
padding: 1,
|
|
42156
|
+
flexDirection: "column",
|
|
42157
|
+
zIndex: 10,
|
|
42158
|
+
marginLeft: 1
|
|
42159
|
+
},
|
|
42160
|
+
children: [
|
|
42161
|
+
/* @__PURE__ */ jsx("text", { fg: colors2.textMuted, children: /* @__PURE__ */ jsx("b", { children: "Commands" }) }),
|
|
42162
|
+
filtered.map((cmd, i) => /* @__PURE__ */ jsxs(
|
|
42163
|
+
"box",
|
|
42164
|
+
{
|
|
42165
|
+
style: {
|
|
42166
|
+
paddingLeft: 1,
|
|
42167
|
+
paddingRight: 1,
|
|
42168
|
+
paddingTop: 0,
|
|
42169
|
+
paddingBottom: 0,
|
|
42170
|
+
backgroundColor: i === selectedIndex ? colors2.primaryDim : "transparent",
|
|
42171
|
+
flexDirection: "row",
|
|
42172
|
+
justifyContent: "space-between",
|
|
42173
|
+
width: "100%"
|
|
42174
|
+
},
|
|
42175
|
+
children: [
|
|
42176
|
+
/* @__PURE__ */ jsx("text", { fg: i === selectedIndex ? colors2.primary : colors2.text, children: /* @__PURE__ */ jsx("b", { children: cmd.name }) }),
|
|
42177
|
+
/* @__PURE__ */ jsxs("text", { fg: colors2.textMuted, children: [
|
|
42178
|
+
" ",
|
|
42179
|
+
cmd.description
|
|
42180
|
+
] })
|
|
42181
|
+
]
|
|
42182
|
+
},
|
|
42183
|
+
cmd.name
|
|
42184
|
+
)),
|
|
42185
|
+
/* @__PURE__ */ jsx("text", { fg: colors2.textMuted, children: "\u2191\u2193 navigate \xB7 Enter select \xB7 Esc close" })
|
|
42186
|
+
]
|
|
42187
|
+
}
|
|
42188
|
+
);
|
|
42189
|
+
}
|
|
42132
42190
|
function InputEditor({
|
|
42133
42191
|
onSubmit,
|
|
42134
42192
|
placeholder,
|
|
42135
|
-
showAbove
|
|
42193
|
+
showAbove,
|
|
42194
|
+
inputValue,
|
|
42195
|
+
onInputChange,
|
|
42196
|
+
paletteOpen,
|
|
42197
|
+
paletteFilter,
|
|
42198
|
+
paletteSelectedIndex
|
|
42136
42199
|
}) {
|
|
42137
42200
|
const { colors: colors2 } = useTheme();
|
|
42138
42201
|
const { isRunning } = useAgent();
|
|
42139
|
-
const [value, setValue] = React4.useState("");
|
|
42140
42202
|
const inputRef = React4.useRef(null);
|
|
42141
42203
|
const doSubmit = () => {
|
|
42142
|
-
if (!
|
|
42204
|
+
if (!inputValue.trim()) return;
|
|
42143
42205
|
if (isRunning) return;
|
|
42144
|
-
const v =
|
|
42145
|
-
|
|
42206
|
+
const v = inputValue;
|
|
42207
|
+
onInputChange("");
|
|
42146
42208
|
onSubmit(v);
|
|
42147
42209
|
};
|
|
42148
42210
|
if (showAbove) {
|
|
42149
42211
|
return /* @__PURE__ */ jsxs("box", { style: { flexDirection: "column" }, children: [
|
|
42212
|
+
paletteOpen ? /* @__PURE__ */ jsx(CommandPalette, { filter: paletteFilter, selectedIndex: paletteSelectedIndex }) : null,
|
|
42150
42213
|
/* @__PURE__ */ jsx("box", { style: {
|
|
42151
42214
|
border: true,
|
|
42152
42215
|
borderStyle: "single",
|
|
42153
|
-
borderColor: isRunning ? colors2.warning : colors2.border,
|
|
42216
|
+
borderColor: isRunning ? colors2.warning : paletteOpen ? colors2.primary : colors2.border,
|
|
42154
42217
|
paddingLeft: 2,
|
|
42155
42218
|
paddingRight: 2,
|
|
42156
42219
|
paddingTop: 1,
|
|
@@ -42163,8 +42226,8 @@ function InputEditor({
|
|
|
42163
42226
|
"input",
|
|
42164
42227
|
{
|
|
42165
42228
|
ref: inputRef,
|
|
42166
|
-
value:
|
|
42167
|
-
onChange: (val) =>
|
|
42229
|
+
value: inputValue,
|
|
42230
|
+
onChange: (val) => onInputChange(s(val)),
|
|
42168
42231
|
onSubmit: () => doSubmit(),
|
|
42169
42232
|
placeholder: s(placeholder),
|
|
42170
42233
|
placeholderColor: colors2.textMuted,
|
|
@@ -42176,11 +42239,12 @@ function InputEditor({
|
|
|
42176
42239
|
] });
|
|
42177
42240
|
}
|
|
42178
42241
|
return /* @__PURE__ */ jsxs("box", { style: { flexDirection: "column" }, children: [
|
|
42242
|
+
paletteOpen ? /* @__PURE__ */ jsx(CommandPalette, { filter: paletteFilter, selectedIndex: paletteSelectedIndex }) : null,
|
|
42179
42243
|
/* @__PURE__ */ jsx(AgentModelLine, { inline: false }),
|
|
42180
42244
|
/* @__PURE__ */ jsx("box", { style: {
|
|
42181
42245
|
border: true,
|
|
42182
42246
|
borderStyle: "single",
|
|
42183
|
-
borderColor: isRunning ? colors2.warning : colors2.border,
|
|
42247
|
+
borderColor: isRunning ? colors2.warning : paletteOpen ? colors2.primary : colors2.border,
|
|
42184
42248
|
paddingLeft: 2,
|
|
42185
42249
|
paddingRight: 2,
|
|
42186
42250
|
paddingTop: 1,
|
|
@@ -42192,8 +42256,8 @@ function InputEditor({
|
|
|
42192
42256
|
"input",
|
|
42193
42257
|
{
|
|
42194
42258
|
ref: inputRef,
|
|
42195
|
-
value:
|
|
42196
|
-
onChange: (val) =>
|
|
42259
|
+
value: inputValue,
|
|
42260
|
+
onChange: (val) => onInputChange(s(val)),
|
|
42197
42261
|
onSubmit: () => doSubmit(),
|
|
42198
42262
|
placeholder: s(placeholder),
|
|
42199
42263
|
placeholderColor: colors2.textMuted,
|
|
@@ -42393,7 +42457,79 @@ function App() {
|
|
|
42393
42457
|
const [sidebarForced, setSidebarForced] = React4.useState(false);
|
|
42394
42458
|
const sidebarVisible = sidebarForced || width >= SIDEBAR_BREAKPOINT;
|
|
42395
42459
|
const [infoCompact, setInfoCompact] = React4.useState(false);
|
|
42460
|
+
const [inputValue, setInputValue] = React4.useState("");
|
|
42461
|
+
const paletteOpen = inputValue.startsWith("/");
|
|
42462
|
+
const paletteFilter = inputValue.slice(1);
|
|
42463
|
+
const [paletteSelectedIndex, setPaletteSelectedIndex] = React4.useState(0);
|
|
42464
|
+
const filteredCommands = React4.useMemo(() => {
|
|
42465
|
+
if (!paletteOpen) return [];
|
|
42466
|
+
const lower = paletteFilter.toLowerCase();
|
|
42467
|
+
if (!lower) return COMMANDS;
|
|
42468
|
+
return COMMANDS.filter((c) => c.name.toLowerCase().includes(lower));
|
|
42469
|
+
}, [paletteOpen, paletteFilter]);
|
|
42470
|
+
React4.useEffect(() => {
|
|
42471
|
+
setPaletteSelectedIndex(0);
|
|
42472
|
+
}, [paletteFilter]);
|
|
42473
|
+
const handleSubmit = (value) => {
|
|
42474
|
+
if (value.startsWith("/")) {
|
|
42475
|
+
const [command, ...args] = value.slice(1).split(" ");
|
|
42476
|
+
void args;
|
|
42477
|
+
switch (command) {
|
|
42478
|
+
case "help":
|
|
42479
|
+
openDialog("help");
|
|
42480
|
+
return;
|
|
42481
|
+
case "models":
|
|
42482
|
+
case "model":
|
|
42483
|
+
openDialog("model");
|
|
42484
|
+
return;
|
|
42485
|
+
case "agents":
|
|
42486
|
+
case "agent":
|
|
42487
|
+
openDialog("model");
|
|
42488
|
+
return;
|
|
42489
|
+
case "clear":
|
|
42490
|
+
process.stdout.write("\x1B[2J\x1B[H");
|
|
42491
|
+
return;
|
|
42492
|
+
case "status":
|
|
42493
|
+
openDialog("help");
|
|
42494
|
+
return;
|
|
42495
|
+
case "exit":
|
|
42496
|
+
case "quit":
|
|
42497
|
+
try {
|
|
42498
|
+
renderer.destroy();
|
|
42499
|
+
} catch {
|
|
42500
|
+
process.exit(0);
|
|
42501
|
+
}
|
|
42502
|
+
return;
|
|
42503
|
+
default:
|
|
42504
|
+
break;
|
|
42505
|
+
}
|
|
42506
|
+
}
|
|
42507
|
+
setInputValue("");
|
|
42508
|
+
void sendMessage(value);
|
|
42509
|
+
};
|
|
42396
42510
|
useKeyboard((key) => {
|
|
42511
|
+
if (paletteOpen && filteredCommands.length > 0) {
|
|
42512
|
+
if (key.name === "arrowDown") {
|
|
42513
|
+
setPaletteSelectedIndex((i) => Math.min(i + 1, filteredCommands.length - 1));
|
|
42514
|
+
return true;
|
|
42515
|
+
}
|
|
42516
|
+
if (key.name === "arrowUp") {
|
|
42517
|
+
setPaletteSelectedIndex((i) => Math.max(0, i - 1));
|
|
42518
|
+
return true;
|
|
42519
|
+
}
|
|
42520
|
+
if (key.name === "return" || key.name === "enter") {
|
|
42521
|
+
const cmd = filteredCommands[paletteSelectedIndex];
|
|
42522
|
+
if (cmd) {
|
|
42523
|
+
setInputValue("");
|
|
42524
|
+
handleSubmit(cmd.name);
|
|
42525
|
+
}
|
|
42526
|
+
return true;
|
|
42527
|
+
}
|
|
42528
|
+
if (key.name === "escape") {
|
|
42529
|
+
setInputValue("");
|
|
42530
|
+
return true;
|
|
42531
|
+
}
|
|
42532
|
+
}
|
|
42397
42533
|
if (key.ctrl && key.name === "p") {
|
|
42398
42534
|
openDialog("model");
|
|
42399
42535
|
return true;
|
|
@@ -42435,39 +42571,6 @@ function App() {
|
|
|
42435
42571
|
}
|
|
42436
42572
|
return false;
|
|
42437
42573
|
});
|
|
42438
|
-
const handleSubmit = (value) => {
|
|
42439
|
-
if (value.startsWith("/")) {
|
|
42440
|
-
const [command, ...args] = value.slice(1).split(" ");
|
|
42441
|
-
void args;
|
|
42442
|
-
switch (command) {
|
|
42443
|
-
case "help":
|
|
42444
|
-
openDialog("help");
|
|
42445
|
-
return;
|
|
42446
|
-
case "models":
|
|
42447
|
-
case "model":
|
|
42448
|
-
openDialog("model");
|
|
42449
|
-
return;
|
|
42450
|
-
case "agents":
|
|
42451
|
-
case "agent":
|
|
42452
|
-
openDialog("model");
|
|
42453
|
-
return;
|
|
42454
|
-
case "clear":
|
|
42455
|
-
process.stdout.write("\x1B[2J\x1B[H");
|
|
42456
|
-
return;
|
|
42457
|
-
case "exit":
|
|
42458
|
-
case "quit":
|
|
42459
|
-
try {
|
|
42460
|
-
renderer.destroy();
|
|
42461
|
-
} catch {
|
|
42462
|
-
process.exit(0);
|
|
42463
|
-
}
|
|
42464
|
-
return;
|
|
42465
|
-
default:
|
|
42466
|
-
break;
|
|
42467
|
-
}
|
|
42468
|
-
}
|
|
42469
|
-
void sendMessage(value);
|
|
42470
|
-
};
|
|
42471
42574
|
const hasMessages = messages.length > 0;
|
|
42472
42575
|
React4.useEffect(() => {
|
|
42473
42576
|
if (width < SIDEBAR_BREAKPOINT && !sidebarForced) setInfoCompact(true);
|
|
@@ -42498,7 +42601,12 @@ function App() {
|
|
|
42498
42601
|
{
|
|
42499
42602
|
onSubmit: handleSubmit,
|
|
42500
42603
|
placeholder: isRunning ? "Generating\u2026 press esc to interrupt" : 'Ask anything... "What is the tech stack of this project?"',
|
|
42501
|
-
showAbove: false
|
|
42604
|
+
showAbove: false,
|
|
42605
|
+
inputValue,
|
|
42606
|
+
onInputChange: setInputValue,
|
|
42607
|
+
paletteOpen,
|
|
42608
|
+
paletteFilter,
|
|
42609
|
+
paletteSelectedIndex
|
|
42502
42610
|
}
|
|
42503
42611
|
),
|
|
42504
42612
|
/* @__PURE__ */ jsx(ShortcutHints, { interrupted: isRunning })
|
|
@@ -42508,7 +42616,12 @@ function App() {
|
|
|
42508
42616
|
{
|
|
42509
42617
|
onSubmit: handleSubmit,
|
|
42510
42618
|
placeholder: 'Ask anything... "What is the tech stack of this project?"',
|
|
42511
|
-
showAbove: true
|
|
42619
|
+
showAbove: true,
|
|
42620
|
+
inputValue,
|
|
42621
|
+
onInputChange: setInputValue,
|
|
42622
|
+
paletteOpen,
|
|
42623
|
+
paletteFilter,
|
|
42624
|
+
paletteSelectedIndex
|
|
42512
42625
|
}
|
|
42513
42626
|
) }),
|
|
42514
42627
|
/* @__PURE__ */ jsx(ShortcutHints, { interrupted: isRunning })
|
|
@@ -42522,7 +42635,7 @@ function App() {
|
|
|
42522
42635
|
/* @__PURE__ */ jsx(ToastContainer, {})
|
|
42523
42636
|
] });
|
|
42524
42637
|
}
|
|
42525
|
-
var SIDEBAR_BREAKPOINT;
|
|
42638
|
+
var SIDEBAR_BREAKPOINT, COMMANDS;
|
|
42526
42639
|
var init_app = __esm({
|
|
42527
42640
|
"src/core/tui/app.tsx"() {
|
|
42528
42641
|
"use strict";
|
|
@@ -42532,6 +42645,14 @@ var init_app = __esm({
|
|
|
42532
42645
|
init_version();
|
|
42533
42646
|
init_autoModel();
|
|
42534
42647
|
SIDEBAR_BREAKPOINT = 90;
|
|
42648
|
+
COMMANDS = [
|
|
42649
|
+
{ name: "/help", description: "Show help and shortcuts" },
|
|
42650
|
+
{ name: "/models", description: "Switch model" },
|
|
42651
|
+
{ name: "/agents", description: "Switch agent" },
|
|
42652
|
+
{ name: "/clear", description: "Clear screen" },
|
|
42653
|
+
{ name: "/status", description: "Show session status" },
|
|
42654
|
+
{ name: "/exit", description: "Exit application" }
|
|
42655
|
+
];
|
|
42535
42656
|
}
|
|
42536
42657
|
});
|
|
42537
42658
|
|