@bike4mind/cli 0.2.8-cli-bash-tools.17146 → 0.2.8-cli-bash-tools.17156
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/index.js +214 -119
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -79,13 +79,13 @@ import {
|
|
|
79
79
|
} from "./chunk-PDX44BCA.js";
|
|
80
80
|
|
|
81
81
|
// src/index.tsx
|
|
82
|
-
import
|
|
83
|
-
import { render, Box as Box14, Text as
|
|
82
|
+
import React15, { useState as useState6, useEffect as useEffect3, useCallback, useRef } from "react";
|
|
83
|
+
import { render, Box as Box14, Text as Text14, useApp, useInput as useInput5 } from "ink";
|
|
84
84
|
import { v4 as uuidv49 } from "uuid";
|
|
85
85
|
|
|
86
86
|
// src/components/App.tsx
|
|
87
|
-
import
|
|
88
|
-
import { Box as Box9, Text as
|
|
87
|
+
import React10 from "react";
|
|
88
|
+
import { Box as Box9, Text as Text9 } from "ink";
|
|
89
89
|
|
|
90
90
|
// src/components/StatusBar.tsx
|
|
91
91
|
import React from "react";
|
|
@@ -95,27 +95,127 @@ var StatusBar = React.memo(function StatusBar2({ sessionName, model, tokenUsage
|
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
// src/components/InputPrompt.tsx
|
|
98
|
-
import
|
|
99
|
-
import { Box as Box4, Text as
|
|
100
|
-
|
|
98
|
+
import React5, { useState as useState2, useMemo, useEffect } from "react";
|
|
99
|
+
import { Box as Box4, Text as Text5, useInput as useInput2 } from "ink";
|
|
100
|
+
|
|
101
|
+
// src/components/CustomTextInput.tsx
|
|
102
|
+
import React2, { useState } from "react";
|
|
103
|
+
import { Text as Text2, useInput } from "ink";
|
|
104
|
+
function CustomTextInput({
|
|
105
|
+
value,
|
|
106
|
+
onChange,
|
|
107
|
+
onSubmit,
|
|
108
|
+
placeholder = "",
|
|
109
|
+
showCursor = true
|
|
110
|
+
}) {
|
|
111
|
+
const [cursorOffset, setCursorOffset] = useState(value.length);
|
|
112
|
+
useInput(
|
|
113
|
+
(input, key) => {
|
|
114
|
+
if (key.return && !key.meta && !key.shift) {
|
|
115
|
+
onSubmit(value);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (key.ctrl) {
|
|
119
|
+
switch (input) {
|
|
120
|
+
case "u":
|
|
121
|
+
{
|
|
122
|
+
const lines = value.split("\n");
|
|
123
|
+
let currentLineStart = 0;
|
|
124
|
+
let currentLineIndex = 0;
|
|
125
|
+
let charCount = 0;
|
|
126
|
+
for (let i = 0; i < lines.length; i++) {
|
|
127
|
+
const lineLength = lines[i].length;
|
|
128
|
+
if (charCount + lineLength >= cursorOffset) {
|
|
129
|
+
currentLineIndex = i;
|
|
130
|
+
currentLineStart = charCount;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
charCount += lineLength + 1;
|
|
134
|
+
}
|
|
135
|
+
lines.splice(currentLineIndex, 1);
|
|
136
|
+
const newValue = lines.join("\n");
|
|
137
|
+
onChange(newValue);
|
|
138
|
+
setCursorOffset(Math.min(currentLineStart, newValue.length));
|
|
139
|
+
}
|
|
140
|
+
return;
|
|
141
|
+
case "k":
|
|
142
|
+
onChange(value.slice(0, cursorOffset));
|
|
143
|
+
return;
|
|
144
|
+
case "w":
|
|
145
|
+
{
|
|
146
|
+
const beforeCursor2 = value.slice(0, cursorOffset);
|
|
147
|
+
const afterCursor2 = value.slice(cursorOffset);
|
|
148
|
+
const trimmed = beforeCursor2.trimEnd();
|
|
149
|
+
const lastSpace = trimmed.lastIndexOf(" ");
|
|
150
|
+
const newBefore = lastSpace === -1 ? "" : trimmed.slice(0, lastSpace + 1);
|
|
151
|
+
const newValue = newBefore + afterCursor2;
|
|
152
|
+
onChange(newValue);
|
|
153
|
+
setCursorOffset(newBefore.length);
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
case "a":
|
|
157
|
+
setCursorOffset(0);
|
|
158
|
+
return;
|
|
159
|
+
case "e":
|
|
160
|
+
setCursorOffset(value.length);
|
|
161
|
+
return;
|
|
162
|
+
case "l":
|
|
163
|
+
onChange("");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (key.backspace || key.delete) {
|
|
168
|
+
if (cursorOffset > 0) {
|
|
169
|
+
const newValue = value.slice(0, cursorOffset - 1) + value.slice(cursorOffset);
|
|
170
|
+
onChange(newValue);
|
|
171
|
+
setCursorOffset(cursorOffset - 1);
|
|
172
|
+
}
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (key.leftArrow) {
|
|
176
|
+
setCursorOffset(Math.max(0, cursorOffset - 1));
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (key.rightArrow) {
|
|
180
|
+
setCursorOffset(Math.min(value.length, cursorOffset + 1));
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (!key.ctrl && !key.meta && input.length === 1) {
|
|
184
|
+
const sanitizedInput = input === "\r" ? "\n" : input;
|
|
185
|
+
const newValue = value.slice(0, cursorOffset) + sanitizedInput + value.slice(cursorOffset);
|
|
186
|
+
onChange(newValue);
|
|
187
|
+
setCursorOffset(cursorOffset + 1);
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{ isActive: true }
|
|
191
|
+
);
|
|
192
|
+
const hasValue = value.length > 0;
|
|
193
|
+
if (!hasValue) {
|
|
194
|
+
return /* @__PURE__ */ React2.createElement(Text2, null, showCursor ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Text2, { inverse: true }, " "), /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, placeholder)) : /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, placeholder));
|
|
195
|
+
}
|
|
196
|
+
const beforeCursor = value.slice(0, cursorOffset);
|
|
197
|
+
const cursorChar = value[cursorOffset] || " ";
|
|
198
|
+
const afterCursor = value.slice(cursorOffset + 1);
|
|
199
|
+
return /* @__PURE__ */ React2.createElement(Text2, null, beforeCursor, showCursor && /* @__PURE__ */ React2.createElement(Text2, { inverse: true }, cursorChar), !showCursor && cursorChar, afterCursor);
|
|
200
|
+
}
|
|
101
201
|
|
|
102
202
|
// src/components/CommandAutocomplete.tsx
|
|
103
|
-
import
|
|
104
|
-
import { Box as Box2, Text as
|
|
203
|
+
import React3 from "react";
|
|
204
|
+
import { Box as Box2, Text as Text3 } from "ink";
|
|
105
205
|
function CommandAutocomplete({ commands, selectedIndex }) {
|
|
106
206
|
if (commands.length === 0) {
|
|
107
|
-
return /* @__PURE__ */
|
|
207
|
+
return /* @__PURE__ */ React3.createElement(Box2, { marginLeft: 2, marginTop: 1 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, "No matching commands"));
|
|
108
208
|
}
|
|
109
|
-
return /* @__PURE__ */
|
|
209
|
+
return /* @__PURE__ */ React3.createElement(Box2, { flexDirection: "column", marginLeft: 2, marginTop: 1 }, /* @__PURE__ */ React3.createElement(Box2, { marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, commands.length === 1 ? "1 command" : `${commands.length} commands`, " \u2022 Use \u2191\u2193 to navigate, Enter to select")), commands.map((cmd, index) => {
|
|
110
210
|
const args = cmd.args ? ` ${cmd.args}` : "";
|
|
111
211
|
const isSelected = index === selectedIndex;
|
|
112
|
-
return /* @__PURE__ */
|
|
212
|
+
return /* @__PURE__ */ React3.createElement(Box2, { key: cmd.name, marginLeft: 1 }, /* @__PURE__ */ React3.createElement(Text3, { color: isSelected ? "cyan" : void 0, bold: isSelected }, isSelected ? "\u25B8 " : " ", "/", cmd.name, args, " - ", cmd.description));
|
|
113
213
|
}));
|
|
114
214
|
}
|
|
115
215
|
|
|
116
216
|
// src/components/FileAutocomplete.tsx
|
|
117
|
-
import
|
|
118
|
-
import { Box as Box3, Text as
|
|
217
|
+
import React4 from "react";
|
|
218
|
+
import { Box as Box3, Text as Text4 } from "ink";
|
|
119
219
|
|
|
120
220
|
// src/utils/fileSearch.ts
|
|
121
221
|
import * as fs from "fs";
|
|
@@ -304,14 +404,14 @@ var MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
|
304
404
|
// src/components/FileAutocomplete.tsx
|
|
305
405
|
function FileAutocomplete({ files, selectedIndex, query }) {
|
|
306
406
|
if (files.length === 0) {
|
|
307
|
-
return /* @__PURE__ */
|
|
407
|
+
return /* @__PURE__ */ React4.createElement(Box3, { marginLeft: 2, marginTop: 1 }, /* @__PURE__ */ React4.createElement(Text4, { dimColor: true }, "No matching files", query ? ` for "${query}"` : ""));
|
|
308
408
|
}
|
|
309
|
-
return /* @__PURE__ */
|
|
409
|
+
return /* @__PURE__ */ React4.createElement(Box3, { flexDirection: "column", marginLeft: 2, marginTop: 1 }, /* @__PURE__ */ React4.createElement(Box3, { marginBottom: 1 }, /* @__PURE__ */ React4.createElement(Text4, { dimColor: true }, files.length === 1 ? "1 match" : `${files.length} matches`, " - Use up/down to navigate, Tab to select")), files.map((file, index) => {
|
|
310
410
|
const isSelected = index === selectedIndex;
|
|
311
411
|
const icon = file.isDirectory ? "[folder]" : "[file] ";
|
|
312
412
|
const sizeDisplay = file.isDirectory ? "" : file.size !== void 0 ? ` (${formatFileSize(file.size)})` : "";
|
|
313
413
|
const pathDisplay = file.isDirectory ? `${file.path}/` : file.path;
|
|
314
|
-
return /* @__PURE__ */
|
|
414
|
+
return /* @__PURE__ */ React4.createElement(Box3, { key: file.path, marginLeft: 1 }, /* @__PURE__ */ React4.createElement(Text4, { color: isSelected ? "cyan" : void 0, bold: isSelected }, isSelected ? "> " : " "), /* @__PURE__ */ React4.createElement(Text4, { color: file.isDirectory ? "yellow" : isSelected ? "cyan" : void 0, bold: isSelected }, icon), /* @__PURE__ */ React4.createElement(Text4, { color: isSelected ? "cyan" : void 0, bold: isSelected }, " ", pathDisplay), /* @__PURE__ */ React4.createElement(Text4, { dimColor: true }, sizeDisplay));
|
|
315
415
|
}));
|
|
316
416
|
}
|
|
317
417
|
|
|
@@ -638,20 +738,18 @@ function InputPrompt({
|
|
|
638
738
|
prefillInput,
|
|
639
739
|
onPrefillConsumed
|
|
640
740
|
}) {
|
|
641
|
-
const [value, setValue] =
|
|
642
|
-
const [selectedIndex, setSelectedIndex] =
|
|
643
|
-
const [historyIndex, setHistoryIndex] =
|
|
644
|
-
const [tempInput, setTempInput] =
|
|
645
|
-
const [inputKey, setInputKey] = useState(0);
|
|
741
|
+
const [value, setValue] = useState2("");
|
|
742
|
+
const [selectedIndex, setSelectedIndex] = useState2(0);
|
|
743
|
+
const [historyIndex, setHistoryIndex] = useState2(-1);
|
|
744
|
+
const [tempInput, setTempInput] = useState2("");
|
|
646
745
|
useEffect(() => {
|
|
647
746
|
if (prefillInput) {
|
|
648
747
|
setValue(prefillInput);
|
|
649
|
-
setInputKey((prev) => prev + 1);
|
|
650
748
|
onPrefillConsumed?.();
|
|
651
749
|
}
|
|
652
750
|
}, [prefillInput, onPrefillConsumed]);
|
|
653
|
-
const [fileAutocomplete, setFileAutocomplete] =
|
|
654
|
-
const [fileSelectedIndex, setFileSelectedIndex] =
|
|
751
|
+
const [fileAutocomplete, setFileAutocomplete] = useState2(null);
|
|
752
|
+
const [fileSelectedIndex, setFileSelectedIndex] = useState2(0);
|
|
655
753
|
const shouldShowCommandAutocomplete = value.startsWith("/") && !disabled && !fileAutocomplete?.active;
|
|
656
754
|
const commandQuery = shouldShowCommandAutocomplete ? value.slice(1) : "";
|
|
657
755
|
const filteredCommands = useMemo(() => {
|
|
@@ -668,7 +766,7 @@ function InputPrompt({
|
|
|
668
766
|
useEffect(() => {
|
|
669
767
|
setFileSelectedIndex(0);
|
|
670
768
|
}, [filteredFiles]);
|
|
671
|
-
|
|
769
|
+
useInput2((_input, key) => {
|
|
672
770
|
if (fileAutocomplete?.active && filteredFiles.length > 0) {
|
|
673
771
|
if (key.upArrow) {
|
|
674
772
|
setFileSelectedIndex((prev) => prev > 0 ? prev - 1 : filteredFiles.length - 1);
|
|
@@ -725,7 +823,6 @@ function InputPrompt({
|
|
|
725
823
|
const pathToInsert = file.isDirectory ? `@${file.path}/` : `@${file.path}`;
|
|
726
824
|
const newValue = beforeAt + pathToInsert + afterQuery;
|
|
727
825
|
setValue(newValue);
|
|
728
|
-
setInputKey((prev) => prev + 1);
|
|
729
826
|
if (file.isDirectory) {
|
|
730
827
|
setFileAutocomplete({
|
|
731
828
|
active: true,
|
|
@@ -752,7 +849,6 @@ function InputPrompt({
|
|
|
752
849
|
if (selectedCommand.args) {
|
|
753
850
|
setValue(commandText + " ");
|
|
754
851
|
setHistoryIndex(-1);
|
|
755
|
-
setInputKey((prev) => prev + 1);
|
|
756
852
|
return;
|
|
757
853
|
}
|
|
758
854
|
setValue("");
|
|
@@ -771,7 +867,6 @@ function InputPrompt({
|
|
|
771
867
|
if (imageEvent && onImageDetected) {
|
|
772
868
|
const placeholder = await onImageDetected(imageEvent.data);
|
|
773
869
|
setValue(`${placeholder} `);
|
|
774
|
-
setInputKey((prev) => prev + 1);
|
|
775
870
|
return;
|
|
776
871
|
}
|
|
777
872
|
}
|
|
@@ -791,29 +886,28 @@ function InputPrompt({
|
|
|
791
886
|
setFileAutocomplete(null);
|
|
792
887
|
}
|
|
793
888
|
};
|
|
794
|
-
return /* @__PURE__ */
|
|
795
|
-
|
|
889
|
+
return /* @__PURE__ */ React5.createElement(Box4, { flexDirection: "column" }, /* @__PURE__ */ React5.createElement(Box4, null, /* @__PURE__ */ React5.createElement(Text5, { bold: true, color: "cyan" }, "> "), /* @__PURE__ */ React5.createElement(
|
|
890
|
+
CustomTextInput,
|
|
796
891
|
{
|
|
797
|
-
key: inputKey,
|
|
798
892
|
value,
|
|
799
893
|
onChange: handleChange,
|
|
800
894
|
onSubmit: handleSubmit,
|
|
801
895
|
placeholder: disabled ? "" : "Type your message, /help for commands, or @file to reference",
|
|
802
896
|
showCursor: !disabled
|
|
803
897
|
}
|
|
804
|
-
)), shouldShowCommandAutocomplete && /* @__PURE__ */
|
|
898
|
+
)), shouldShowCommandAutocomplete && /* @__PURE__ */ React5.createElement(CommandAutocomplete, { commands: filteredCommands, selectedIndex }), fileAutocomplete?.active && /* @__PURE__ */ React5.createElement(FileAutocomplete, { files: filteredFiles, selectedIndex: fileSelectedIndex, query: fileAutocomplete.query }));
|
|
805
899
|
}
|
|
806
900
|
|
|
807
901
|
// src/components/AgentThinking.tsx
|
|
808
|
-
import
|
|
902
|
+
import React7 from "react";
|
|
809
903
|
import { Box as Box6 } from "ink";
|
|
810
904
|
|
|
811
905
|
// src/components/ThoughtStream.tsx
|
|
812
|
-
import
|
|
813
|
-
import { Box as Box5, Text as
|
|
906
|
+
import React6 from "react";
|
|
907
|
+
import { Box as Box5, Text as Text6 } from "ink";
|
|
814
908
|
import Spinner from "ink-spinner";
|
|
815
|
-
var ThoughtStream =
|
|
816
|
-
return /* @__PURE__ */
|
|
909
|
+
var ThoughtStream = React6.memo(function ThoughtStream2({ steps }) {
|
|
910
|
+
return /* @__PURE__ */ React6.createElement(Box5, { flexDirection: "column", gap: 1 }, steps.map((step, index) => /* @__PURE__ */ React6.createElement(Box5, { key: index, flexDirection: "column" }, step.type === "thought" && /* @__PURE__ */ React6.createElement(Box5, null, /* @__PURE__ */ React6.createElement(Text6, { color: "magenta" }, "\u{1F914} Thought: "), /* @__PURE__ */ React6.createElement(Text6, null, step.content)), step.type === "action" && /* @__PURE__ */ React6.createElement(Box5, { flexDirection: "column" }, /* @__PURE__ */ React6.createElement(Box5, null, /* @__PURE__ */ React6.createElement(Text6, { color: "yellow" }, "\u26A1 Action: "), /* @__PURE__ */ React6.createElement(Text6, { bold: true }, step.metadata?.toolName || "unknown")), step.metadata?.toolInput && /* @__PURE__ */ React6.createElement(Box5, { paddingLeft: 2 }, /* @__PURE__ */ React6.createElement(Text6, { dimColor: true }, JSON.stringify(step.metadata.toolInput, null, 2)))), step.type === "observation" && /* @__PURE__ */ React6.createElement(Box5, { flexDirection: "column" }, /* @__PURE__ */ React6.createElement(Box5, null, /* @__PURE__ */ React6.createElement(Text6, { color: "blue" }, "\u{1F4CA} Observation: ")), /* @__PURE__ */ React6.createElement(Box5, { paddingLeft: 2 }, /* @__PURE__ */ React6.createElement(Text6, null, step.content))), step.type === "final_answer" && /* @__PURE__ */ React6.createElement(Box5, { flexDirection: "column" }, /* @__PURE__ */ React6.createElement(Box5, null, /* @__PURE__ */ React6.createElement(Text6, { color: "green", bold: true }, "\u2705 Final Answer:", " ")), /* @__PURE__ */ React6.createElement(Box5, { paddingLeft: 2 }, /* @__PURE__ */ React6.createElement(Text6, null, step.content)), step.metadata?.tokenUsage && /* @__PURE__ */ React6.createElement(Box5, { paddingLeft: 2 }, /* @__PURE__ */ React6.createElement(Text6, { dimColor: true }, "(", step.metadata.tokenUsage.total, " tokens)"))))), !steps.some((s) => s.type === "final_answer") && /* @__PURE__ */ React6.createElement(Box5, null, /* @__PURE__ */ React6.createElement(Text6, { color: "yellow" }, /* @__PURE__ */ React6.createElement(Spinner, { type: "dots" })), /* @__PURE__ */ React6.createElement(Text6, null, " ", steps.length === 0 ? "Thinking..." : "Processing...")));
|
|
817
911
|
});
|
|
818
912
|
|
|
819
913
|
// src/store/index.ts
|
|
@@ -843,32 +937,32 @@ var useCliStore = create((set) => ({
|
|
|
843
937
|
}));
|
|
844
938
|
|
|
845
939
|
// src/components/AgentThinking.tsx
|
|
846
|
-
var AgentThinking =
|
|
940
|
+
var AgentThinking = React7.memo(function AgentThinking2() {
|
|
847
941
|
const isThinking = useCliStore((state) => state.isThinking);
|
|
848
942
|
const agentSteps = useCliStore((state) => state.agentSteps);
|
|
849
943
|
if (!isThinking) {
|
|
850
944
|
return null;
|
|
851
945
|
}
|
|
852
|
-
return /* @__PURE__ */
|
|
946
|
+
return /* @__PURE__ */ React7.createElement(Box6, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React7.createElement(ThoughtStream, { steps: agentSteps }));
|
|
853
947
|
});
|
|
854
948
|
|
|
855
949
|
// src/components/PermissionPrompt.tsx
|
|
856
|
-
import
|
|
857
|
-
import { Box as Box7, Text as
|
|
950
|
+
import React8 from "react";
|
|
951
|
+
import { Box as Box7, Text as Text7 } from "ink";
|
|
858
952
|
import SelectInput from "ink-select-input";
|
|
859
953
|
function renderDiffPreview(preview) {
|
|
860
954
|
const lines = preview.split("\n");
|
|
861
955
|
return lines.map((line, index) => {
|
|
862
956
|
if (line.startsWith("+")) {
|
|
863
|
-
return /* @__PURE__ */
|
|
957
|
+
return /* @__PURE__ */ React8.createElement(Text7, { key: index, color: "green" }, line);
|
|
864
958
|
}
|
|
865
959
|
if (line.startsWith("-")) {
|
|
866
|
-
return /* @__PURE__ */
|
|
960
|
+
return /* @__PURE__ */ React8.createElement(Text7, { key: index, color: "red" }, line);
|
|
867
961
|
}
|
|
868
962
|
if (line.startsWith("@@")) {
|
|
869
|
-
return /* @__PURE__ */
|
|
963
|
+
return /* @__PURE__ */ React8.createElement(Text7, { key: index, color: "cyan" }, line);
|
|
870
964
|
}
|
|
871
|
-
return /* @__PURE__ */
|
|
965
|
+
return /* @__PURE__ */ React8.createElement(Text7, { key: index, dimColor: true }, line);
|
|
872
966
|
});
|
|
873
967
|
}
|
|
874
968
|
function PermissionPrompt({
|
|
@@ -888,12 +982,12 @@ function PermissionPrompt({
|
|
|
888
982
|
{ label: "\u2717 Deny", value: "deny" }
|
|
889
983
|
];
|
|
890
984
|
const argsString = typeof args === "string" ? args : JSON.stringify(args, null, 2);
|
|
891
|
-
return /* @__PURE__ */
|
|
985
|
+
return /* @__PURE__ */ React8.createElement(Box7, { flexDirection: "column", borderStyle: "bold", borderColor: "yellow", padding: 1, marginY: 1 }, /* @__PURE__ */ React8.createElement(Box7, null, /* @__PURE__ */ React8.createElement(Text7, { bold: true, color: "yellow" }, "\u26A0\uFE0F Permission Required")), /* @__PURE__ */ React8.createElement(Box7, { marginTop: 1 }, /* @__PURE__ */ React8.createElement(Text7, { dimColor: true }, "Tool: "), /* @__PURE__ */ React8.createElement(Text7, { bold: true, color: "cyan" }, toolName)), toolDescription && /* @__PURE__ */ React8.createElement(Box7, null, /* @__PURE__ */ React8.createElement(Text7, { dimColor: true }, "Action: "), /* @__PURE__ */ React8.createElement(Text7, null, toolDescription)), /* @__PURE__ */ React8.createElement(Box7, { marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React8.createElement(Text7, { bold: true }, "Arguments:"), /* @__PURE__ */ React8.createElement(Box7, { paddingLeft: 2, flexDirection: "column" }, /* @__PURE__ */ React8.createElement(Text7, { dimColor: true }, argsString))), preview && /* @__PURE__ */ React8.createElement(Box7, { marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React8.createElement(Text7, { bold: true }, "Preview:"), /* @__PURE__ */ React8.createElement(Box7, { borderStyle: "single", borderColor: "gray", paddingX: 1, flexDirection: "column" }, renderDiffPreview(preview))), !canBeTrusted && /* @__PURE__ */ React8.createElement(Box7, { marginTop: 1 }, /* @__PURE__ */ React8.createElement(Text7, { color: "red", dimColor: true }, "Note: This tool cannot be trusted due to its dangerous nature.")), /* @__PURE__ */ React8.createElement(Box7, { marginTop: 1 }, /* @__PURE__ */ React8.createElement(SelectInput, { items, onSelect: (item) => onResponse(item.value) })));
|
|
892
986
|
}
|
|
893
987
|
|
|
894
988
|
// src/components/ConfigEditor.tsx
|
|
895
|
-
import
|
|
896
|
-
import { Box as Box8, Text as
|
|
989
|
+
import React9, { useState as useState3, useMemo as useMemo2 } from "react";
|
|
990
|
+
import { Box as Box8, Text as Text8, useInput as useInput3 } from "ink";
|
|
897
991
|
var MAX_ITERATIONS_OPTIONS = [
|
|
898
992
|
{ label: "10", value: 10 },
|
|
899
993
|
{ label: "20", value: 20 },
|
|
@@ -1024,10 +1118,10 @@ function buildConfigItems(availableModels) {
|
|
|
1024
1118
|
return items;
|
|
1025
1119
|
}
|
|
1026
1120
|
function ConfigEditor({ config, availableModels, onSave, onClose }) {
|
|
1027
|
-
const [selectedIndex, setSelectedIndex] =
|
|
1028
|
-
const [editedConfig, setEditedConfig] =
|
|
1029
|
-
const [saveError, setSaveError] =
|
|
1030
|
-
const [isSaving, setIsSaving] =
|
|
1121
|
+
const [selectedIndex, setSelectedIndex] = useState3(0);
|
|
1122
|
+
const [editedConfig, setEditedConfig] = useState3(config);
|
|
1123
|
+
const [saveError, setSaveError] = useState3(null);
|
|
1124
|
+
const [isSaving, setIsSaving] = useState3(false);
|
|
1031
1125
|
const configItems = useMemo2(() => buildConfigItems(availableModels), [availableModels]);
|
|
1032
1126
|
const hasChanges = useMemo2(() => {
|
|
1033
1127
|
return JSON.stringify(config.preferences) !== JSON.stringify(editedConfig.preferences) || config.defaultModel !== editedConfig.defaultModel;
|
|
@@ -1047,7 +1141,7 @@ function ConfigEditor({ config, availableModels, onSave, onClose }) {
|
|
|
1047
1141
|
}
|
|
1048
1142
|
onClose();
|
|
1049
1143
|
};
|
|
1050
|
-
|
|
1144
|
+
useInput3((input, key) => {
|
|
1051
1145
|
const currentItem = configItems[selectedIndex];
|
|
1052
1146
|
if (key.upArrow) {
|
|
1053
1147
|
setSelectedIndex((prev) => prev > 0 ? prev - 1 : configItems.length - 1);
|
|
@@ -1112,13 +1206,13 @@ function ConfigEditor({ config, availableModels, onSave, onClose }) {
|
|
|
1112
1206
|
}
|
|
1113
1207
|
return String(value);
|
|
1114
1208
|
};
|
|
1115
|
-
return /* @__PURE__ */
|
|
1209
|
+
return /* @__PURE__ */ React9.createElement(Box8, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 2, paddingY: 1, marginY: 1 }, /* @__PURE__ */ React9.createElement(Box8, { justifyContent: "space-between", marginBottom: 1 }, /* @__PURE__ */ React9.createElement(Text8, { bold: true, color: "cyan" }, "Settings"), isSaving ? /* @__PURE__ */ React9.createElement(Text8, { color: "yellow" }, "Saving...") : hasChanges ? /* @__PURE__ */ React9.createElement(Text8, { dimColor: true, color: "yellow" }, "(unsaved changes)") : null), saveError && /* @__PURE__ */ React9.createElement(Box8, { marginBottom: 1 }, /* @__PURE__ */ React9.createElement(Text8, { color: "red" }, "Error: ", saveError)), /* @__PURE__ */ React9.createElement(Box8, { flexDirection: "column", marginBottom: 1 }, configItems.map((item, index) => {
|
|
1116
1210
|
const isSelected = index === selectedIndex;
|
|
1117
1211
|
const value = item.getValue(editedConfig);
|
|
1118
1212
|
const displayValue = formatValue(item, value);
|
|
1119
1213
|
const hasOptions = item.type === "select" || item.type === "boolean" || item.type === "number";
|
|
1120
|
-
return /* @__PURE__ */
|
|
1121
|
-
})), /* @__PURE__ */
|
|
1214
|
+
return /* @__PURE__ */ React9.createElement(Box8, { key: item.key }, /* @__PURE__ */ React9.createElement(Text8, { color: isSelected ? "cyan" : void 0 }, isSelected ? "> " : " "), /* @__PURE__ */ React9.createElement(Box8, { width: 18 }, /* @__PURE__ */ React9.createElement(Text8, { bold: isSelected, color: isSelected ? "white" : "gray" }, item.label, ":")), /* @__PURE__ */ React9.createElement(Box8, null, hasOptions && isSelected && /* @__PURE__ */ React9.createElement(Text8, { dimColor: true }, "< "), /* @__PURE__ */ React9.createElement(Text8, { bold: isSelected, color: isSelected ? "green" : void 0 }, displayValue), hasOptions && isSelected && /* @__PURE__ */ React9.createElement(Text8, { dimColor: true }, " >")));
|
|
1215
|
+
})), /* @__PURE__ */ React9.createElement(Box8, { borderStyle: "single", borderColor: "gray", paddingX: 1 }, /* @__PURE__ */ React9.createElement(Text8, { dimColor: true }, "\u2191/\u2193: Navigate | Space/\u2190/\u2192: Change | q/Esc: Save & Exit")));
|
|
1122
1216
|
}
|
|
1123
1217
|
|
|
1124
1218
|
// src/utils/processFileReferences.ts
|
|
@@ -1258,7 +1352,7 @@ function App({
|
|
|
1258
1352
|
const setShowConfigEditor = useCliStore((state) => state.setShowConfigEditor);
|
|
1259
1353
|
const exitRequested = useCliStore((state) => state.exitRequested);
|
|
1260
1354
|
const setIsThinking = useCliStore((state) => state.setIsThinking);
|
|
1261
|
-
const handleSubmit =
|
|
1355
|
+
const handleSubmit = React10.useCallback(
|
|
1262
1356
|
async (input) => {
|
|
1263
1357
|
const trimmed = input.trim();
|
|
1264
1358
|
if (!trimmed) return;
|
|
@@ -1287,7 +1381,7 @@ ${errorBlock}`;
|
|
|
1287
1381
|
},
|
|
1288
1382
|
[onMessage, onCommand, setIsThinking]
|
|
1289
1383
|
);
|
|
1290
|
-
return /* @__PURE__ */
|
|
1384
|
+
return /* @__PURE__ */ React10.createElement(Box9, { flexDirection: "column" }, /* @__PURE__ */ React10.createElement(StatusBar, { sessionName, model: currentModel, tokenUsage: totalTokens }), showConfigEditor && config && onSaveConfig ? /* @__PURE__ */ React10.createElement(Box9, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React10.createElement(
|
|
1291
1385
|
ConfigEditor,
|
|
1292
1386
|
{
|
|
1293
1387
|
config,
|
|
@@ -1295,7 +1389,7 @@ ${errorBlock}`;
|
|
|
1295
1389
|
onSave: onSaveConfig,
|
|
1296
1390
|
onClose: () => setShowConfigEditor(false)
|
|
1297
1391
|
}
|
|
1298
|
-
)) : permissionPrompt ? /* @__PURE__ */
|
|
1392
|
+
)) : permissionPrompt ? /* @__PURE__ */ React10.createElement(Box9, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React10.createElement(
|
|
1299
1393
|
PermissionPrompt,
|
|
1300
1394
|
{
|
|
1301
1395
|
toolName: permissionPrompt.toolName,
|
|
@@ -1304,7 +1398,7 @@ ${errorBlock}`;
|
|
|
1304
1398
|
canBeTrusted: permissionPrompt.canBeTrusted,
|
|
1305
1399
|
onResponse: onPermissionResponse
|
|
1306
1400
|
}
|
|
1307
|
-
)) : /* @__PURE__ */
|
|
1401
|
+
)) : /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(Box9, { flexDirection: "column" }, messages.map((message, index) => /* @__PURE__ */ React10.createElement(Box9, { key: `${message.timestamp}-${message.role}-${index}`, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React10.createElement(MessageItem, { message })))), /* @__PURE__ */ React10.createElement(AgentThinking, null), exitRequested && /* @__PURE__ */ React10.createElement(Box9, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React10.createElement(Text9, { color: "yellow", bold: true }, "Press Ctrl+C again to exit")), /* @__PURE__ */ React10.createElement(Box9, { borderStyle: "single", borderColor: "cyan", paddingX: 1 }, /* @__PURE__ */ React10.createElement(
|
|
1308
1402
|
InputPrompt,
|
|
1309
1403
|
{
|
|
1310
1404
|
onSubmit: handleSubmit,
|
|
@@ -1318,36 +1412,36 @@ ${errorBlock}`;
|
|
|
1318
1412
|
}
|
|
1319
1413
|
function MessageItem({ message }) {
|
|
1320
1414
|
const isUser = message.role === "user";
|
|
1321
|
-
return /* @__PURE__ */
|
|
1415
|
+
return /* @__PURE__ */ React10.createElement(Box9, { flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ React10.createElement(Box9, null, /* @__PURE__ */ React10.createElement(Text9, { bold: true, color: isUser ? "cyan" : "green" }, isUser ? "\u{1F464} You" : "\u{1F916} Assistant"), /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, " \u2022 ", new Date(message.timestamp).toLocaleTimeString())), isUser && message.content && /* @__PURE__ */ React10.createElement(Box9, { paddingLeft: 2 }, /* @__PURE__ */ React10.createElement(Text9, { backgroundColor: "whiteBright", color: "black" }, " ", message.content, " ")), !isUser && message.metadata?.steps && message.metadata.steps.length > 0 && /* @__PURE__ */ React10.createElement(Box9, { paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React10.createElement(Text9, { dimColor: true, bold: true }, "\u{1F527} Agent Reasoning Trace (", message.metadata.steps.filter((s) => s.type === "action").length, " ", "tools used, ", message.metadata.steps.length, " total steps)", message.metadata.tokenUsage && ` \u2022 ${message.metadata.tokenUsage.total} tokens`), /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, "Step types: ", message.metadata.steps.map((s) => s.type).join(", ")), message.metadata.steps.map((step, idx) => {
|
|
1322
1416
|
if (step.type === "thought") {
|
|
1323
|
-
return /* @__PURE__ */
|
|
1417
|
+
return /* @__PURE__ */ React10.createElement(Box9, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React10.createElement(Text9, { color: "blue" }, "\u{1F4AD} Thought:"), /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, ` ${step.content.slice(0, 200)}${step.content.length > 200 ? "..." : ""}`));
|
|
1324
1418
|
}
|
|
1325
1419
|
if (step.type === "action") {
|
|
1326
1420
|
const toolName = step.metadata?.toolName || "unknown";
|
|
1327
1421
|
const toolInput = step.metadata?.toolInput;
|
|
1328
1422
|
const observationStep = message.metadata.steps[idx + 1];
|
|
1329
1423
|
const result = observationStep?.type === "observation" ? observationStep.content : null;
|
|
1330
|
-
return /* @__PURE__ */
|
|
1424
|
+
return /* @__PURE__ */ React10.createElement(Box9, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React10.createElement(Text9, { color: "yellow" }, "\u{1F527} Action: ", toolName), toolInput && /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, ` Input: ${typeof toolInput === "string" ? toolInput : JSON.stringify(toolInput).slice(0, 100)}`), result && /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, ` Result: ${typeof result === "string" ? result.slice(0, 200) : JSON.stringify(result).slice(0, 200)}${(typeof result === "string" ? result.length : JSON.stringify(result).length) > 200 ? "..." : ""}`));
|
|
1331
1425
|
}
|
|
1332
1426
|
return null;
|
|
1333
|
-
}).filter(Boolean)), !isUser && message.content !== "..." && /* @__PURE__ */
|
|
1427
|
+
}).filter(Boolean)), !isUser && message.content !== "..." && /* @__PURE__ */ React10.createElement(Box9, { paddingLeft: 2, marginTop: message.metadata?.steps?.length ? 1 : 0 }, message.metadata?.permissionDenied ? /* @__PURE__ */ React10.createElement(Text9, { color: "yellow" }, "\u26A0\uFE0F ", message.content) : /* @__PURE__ */ React10.createElement(Text9, null, message.content)), message.metadata?.tokenUsage && (!message.metadata.steps || message.metadata.steps.length === 0) && /* @__PURE__ */ React10.createElement(Box9, { paddingLeft: 2 }, /* @__PURE__ */ React10.createElement(Text9, { dimColor: true }, `${message.metadata.tokenUsage.total} tokens`)));
|
|
1334
1428
|
}
|
|
1335
1429
|
|
|
1336
1430
|
// src/components/MessageList.tsx
|
|
1337
|
-
import
|
|
1338
|
-
import { Box as Box10, Text as
|
|
1431
|
+
import React11 from "react";
|
|
1432
|
+
import { Box as Box10, Text as Text10 } from "ink";
|
|
1339
1433
|
function stripThinkingTags(content) {
|
|
1340
1434
|
return content.replace(/<think>[\s\S]*?<\/think>/g, "").trim();
|
|
1341
1435
|
}
|
|
1342
|
-
var MessageList =
|
|
1436
|
+
var MessageList = React11.memo(
|
|
1343
1437
|
function MessageList2({ messages }) {
|
|
1344
1438
|
if (messages.length === 0) {
|
|
1345
|
-
return /* @__PURE__ */
|
|
1439
|
+
return /* @__PURE__ */ React11.createElement(Box10, { paddingY: 1 }, /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, "No messages yet. Type a message to start!"));
|
|
1346
1440
|
}
|
|
1347
|
-
return /* @__PURE__ */
|
|
1441
|
+
return /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column", gap: 1, paddingY: 1 }, messages.map((message, index) => /* @__PURE__ */ React11.createElement(Box10, { key: index, flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ React11.createElement(Box10, null, /* @__PURE__ */ React11.createElement(Text10, { bold: true, color: message.role === "user" ? "cyan" : "green" }, message.role === "user" ? "\u{1F464} You" : "\u{1F916} Assistant"), /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, " \u2022 ", new Date(message.timestamp).toLocaleTimeString())), /* @__PURE__ */ React11.createElement(Box10, { paddingLeft: 2 }, message.metadata?.permissionDenied ? /* @__PURE__ */ React11.createElement(Text10, { color: "yellow" }, "\u26A0\uFE0F ", stripThinkingTags(message.content)) : /* @__PURE__ */ React11.createElement(Text10, null, stripThinkingTags(message.content))), message.metadata?.steps && message.metadata.steps.length > 0 && /* @__PURE__ */ React11.createElement(Box10, { paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React11.createElement(Text10, { dimColor: true, bold: true }, "\u{1F527} Agent Reasoning Trace (", message.metadata.steps.filter((s) => s.type === "action").length, " tools used,", " ", message.metadata.steps.length, " total steps)", message.metadata.tokenUsage && ` \u2022 ${message.metadata.tokenUsage.total} tokens`), /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, "Step types: ", message.metadata.steps.map((s) => s.type).join(", ")), message.metadata.steps.map((step, idx) => {
|
|
1348
1442
|
if (step.type === "thought") {
|
|
1349
|
-
return /* @__PURE__ */
|
|
1350
|
-
|
|
1443
|
+
return /* @__PURE__ */ React11.createElement(Box10, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React11.createElement(Text10, { color: "blue" }, "\u{1F4AD} Thought:"), /* @__PURE__ */ React11.createElement(
|
|
1444
|
+
Text10,
|
|
1351
1445
|
{
|
|
1352
1446
|
dimColor: true
|
|
1353
1447
|
},
|
|
@@ -1359,10 +1453,10 @@ var MessageList = React10.memo(
|
|
|
1359
1453
|
const toolInput = step.metadata?.toolInput;
|
|
1360
1454
|
const observationStep = message.metadata.steps[idx + 1];
|
|
1361
1455
|
const result = observationStep?.type === "observation" ? observationStep.content : null;
|
|
1362
|
-
return /* @__PURE__ */
|
|
1456
|
+
return /* @__PURE__ */ React11.createElement(Box10, { key: idx, paddingLeft: 2, marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React11.createElement(Text10, { color: "yellow" }, "\u{1F527} Action: ", toolName), toolInput && /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, ` Input: ${typeof toolInput === "string" ? toolInput : JSON.stringify(toolInput).slice(0, 100)}`), result && /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, ` Result: ${typeof result === "string" ? result.slice(0, 200) : JSON.stringify(result).slice(0, 200)}${(typeof result === "string" ? result.length : JSON.stringify(result).length) > 200 ? "..." : ""}`));
|
|
1363
1457
|
}
|
|
1364
1458
|
return null;
|
|
1365
|
-
}).filter(Boolean)), message.metadata?.tokenUsage && (!message.metadata.steps || message.metadata.steps.length === 0) && /* @__PURE__ */
|
|
1459
|
+
}).filter(Boolean)), message.metadata?.tokenUsage && (!message.metadata.steps || message.metadata.steps.length === 0) && /* @__PURE__ */ React11.createElement(Box10, { paddingLeft: 2 }, /* @__PURE__ */ React11.createElement(Text10, { dimColor: true }, `${message.metadata.tokenUsage.total} tokens`)))));
|
|
1366
1460
|
},
|
|
1367
1461
|
(prevProps, nextProps) => {
|
|
1368
1462
|
if (prevProps.messages.length !== nextProps.messages.length) {
|
|
@@ -1373,8 +1467,8 @@ var MessageList = React10.memo(
|
|
|
1373
1467
|
);
|
|
1374
1468
|
|
|
1375
1469
|
// src/components/TrustLocationSelector.tsx
|
|
1376
|
-
import
|
|
1377
|
-
import { Box as Box11, Text as
|
|
1470
|
+
import React12 from "react";
|
|
1471
|
+
import { Box as Box11, Text as Text11 } from "ink";
|
|
1378
1472
|
import SelectInput2 from "ink-select-input";
|
|
1379
1473
|
function TrustLocationSelector({ inProject, onSelect, onCancel }) {
|
|
1380
1474
|
const items = [];
|
|
@@ -1395,24 +1489,24 @@ function TrustLocationSelector({ inProject, onSelect, onCancel }) {
|
|
|
1395
1489
|
const handleSelect = (item) => {
|
|
1396
1490
|
onSelect(item.value);
|
|
1397
1491
|
};
|
|
1398
|
-
return /* @__PURE__ */
|
|
1492
|
+
return /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React12.createElement(Box11, { marginBottom: 1 }, /* @__PURE__ */ React12.createElement(Text11, { bold: true }, "Where should this rule be saved?")), /* @__PURE__ */ React12.createElement(
|
|
1399
1493
|
SelectInput2,
|
|
1400
1494
|
{
|
|
1401
1495
|
items,
|
|
1402
1496
|
onSelect: handleSelect,
|
|
1403
|
-
itemComponent: ({ isSelected, label }) => /* @__PURE__ */
|
|
1497
|
+
itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React12.createElement(Box11, null, /* @__PURE__ */ React12.createElement(Text11, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
|
|
1404
1498
|
}
|
|
1405
|
-
), /* @__PURE__ */
|
|
1499
|
+
), /* @__PURE__ */ React12.createElement(Box11, { marginTop: 1 }, /* @__PURE__ */ React12.createElement(Text11, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Ctrl+C to cancel")));
|
|
1406
1500
|
}
|
|
1407
1501
|
|
|
1408
1502
|
// src/components/RewindSelector.tsx
|
|
1409
|
-
import
|
|
1410
|
-
import { Box as Box12, Text as
|
|
1503
|
+
import React13, { useState as useState4 } from "react";
|
|
1504
|
+
import { Box as Box12, Text as Text12, useInput as useInput4 } from "ink";
|
|
1411
1505
|
import SelectInput3 from "ink-select-input";
|
|
1412
1506
|
function RewindSelector({ messages, onSelect, onCancel }) {
|
|
1413
|
-
const [step, setStep] =
|
|
1414
|
-
const [selectedMessageIndex, setSelectedMessageIndex] =
|
|
1415
|
-
|
|
1507
|
+
const [step, setStep] = useState4("selection");
|
|
1508
|
+
const [selectedMessageIndex, setSelectedMessageIndex] = useState4(null);
|
|
1509
|
+
useInput4((input, key) => {
|
|
1416
1510
|
if (key.escape) {
|
|
1417
1511
|
if (step === "confirmation") {
|
|
1418
1512
|
setStep("selection");
|
|
@@ -1449,14 +1543,14 @@ function RewindSelector({ messages, onSelect, onCancel }) {
|
|
|
1449
1543
|
return sum2 + (msg.metadata?.tokenUsage?.total || 0);
|
|
1450
1544
|
}, 0);
|
|
1451
1545
|
if (step === "selection") {
|
|
1452
|
-
return /* @__PURE__ */
|
|
1546
|
+
return /* @__PURE__ */ React13.createElement(Box12, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React13.createElement(Box12, { marginBottom: 1 }, /* @__PURE__ */ React13.createElement(Text12, { bold: true }, "Select a point to rewind to:")), /* @__PURE__ */ React13.createElement(
|
|
1453
1547
|
SelectInput3,
|
|
1454
1548
|
{
|
|
1455
1549
|
items,
|
|
1456
1550
|
onSelect: handleSelectionSelect,
|
|
1457
|
-
itemComponent: ({ isSelected, label }) => /* @__PURE__ */
|
|
1551
|
+
itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React13.createElement(Box12, null, /* @__PURE__ */ React13.createElement(Text12, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
|
|
1458
1552
|
}
|
|
1459
|
-
), /* @__PURE__ */
|
|
1553
|
+
), /* @__PURE__ */ React13.createElement(Box12, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(Text12, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Esc to cancel")));
|
|
1460
1554
|
}
|
|
1461
1555
|
const confirmationItems = [
|
|
1462
1556
|
{ label: "Yes, rewind to this point", value: "confirm" },
|
|
@@ -1464,19 +1558,19 @@ function RewindSelector({ messages, onSelect, onCancel }) {
|
|
|
1464
1558
|
];
|
|
1465
1559
|
const selectedMessage = selectedMessageIndex !== null && selectedMessageIndex >= 0 && selectedMessageIndex < messages.length ? messages[selectedMessageIndex] : null;
|
|
1466
1560
|
const selectedPreview = selectedMessage ? selectedMessage.content.length > 50 ? selectedMessage.content.substring(0, 50) + "..." : selectedMessage.content : "";
|
|
1467
|
-
return /* @__PURE__ */
|
|
1561
|
+
return /* @__PURE__ */ React13.createElement(Box12, { flexDirection: "column", marginY: 1 }, /* @__PURE__ */ React13.createElement(Box12, { marginBottom: 1, flexDirection: "column" }, /* @__PURE__ */ React13.createElement(Text12, { bold: true }, "Confirm rewind operation:"), /* @__PURE__ */ React13.createElement(Text12, { dimColor: true }, "Message: ", selectedPreview), /* @__PURE__ */ React13.createElement(Text12, { color: "yellow" }, "This will remove ", messagesToRemove.length, " message(s) (", tokensToRemove.toLocaleString(), " tokens)"), /* @__PURE__ */ React13.createElement(Text12, { color: "cyan" }, "The selected message will be placed in your input for editing.")), /* @__PURE__ */ React13.createElement(
|
|
1468
1562
|
SelectInput3,
|
|
1469
1563
|
{
|
|
1470
1564
|
items: confirmationItems,
|
|
1471
1565
|
onSelect: handleConfirmationSelect,
|
|
1472
|
-
itemComponent: ({ isSelected, label }) => /* @__PURE__ */
|
|
1566
|
+
itemComponent: ({ isSelected, label }) => /* @__PURE__ */ React13.createElement(Box12, null, /* @__PURE__ */ React13.createElement(Text12, { color: isSelected ? "cyan" : void 0 }, isSelected ? "\u276F " : " ", label))
|
|
1473
1567
|
}
|
|
1474
|
-
), /* @__PURE__ */
|
|
1568
|
+
), /* @__PURE__ */ React13.createElement(Box12, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(Text12, { dimColor: true }, "Use \u2191\u2193 arrows to navigate, Enter to select, Esc to go back")));
|
|
1475
1569
|
}
|
|
1476
1570
|
|
|
1477
1571
|
// src/components/LoginFlow.tsx
|
|
1478
|
-
import
|
|
1479
|
-
import { Box as Box13, Text as
|
|
1572
|
+
import React14, { useState as useState5, useEffect as useEffect2 } from "react";
|
|
1573
|
+
import { Box as Box13, Text as Text13 } from "ink";
|
|
1480
1574
|
import Spinner2 from "ink-spinner";
|
|
1481
1575
|
import jwt from "jsonwebtoken";
|
|
1482
1576
|
import open from "open";
|
|
@@ -1592,10 +1686,10 @@ var OAuthClient = class {
|
|
|
1592
1686
|
|
|
1593
1687
|
// src/components/LoginFlow.tsx
|
|
1594
1688
|
function LoginFlow({ apiUrl = "http://localhost:3000", configStore, onSuccess, onError }) {
|
|
1595
|
-
const [status, setStatus] =
|
|
1596
|
-
const [deviceFlow, setDeviceFlow] =
|
|
1597
|
-
const [statusMessage, setStatusMessage] =
|
|
1598
|
-
const [error, setError] =
|
|
1689
|
+
const [status, setStatus] = useState5("initiating");
|
|
1690
|
+
const [deviceFlow, setDeviceFlow] = useState5(null);
|
|
1691
|
+
const [statusMessage, setStatusMessage] = useState5("Initiating device authorization...");
|
|
1692
|
+
const [error, setError] = useState5(null);
|
|
1599
1693
|
useEffect2(() => {
|
|
1600
1694
|
const runLoginFlow = async () => {
|
|
1601
1695
|
const oauth = new OAuthClient(apiUrl);
|
|
@@ -1639,15 +1733,15 @@ function LoginFlow({ apiUrl = "http://localhost:3000", configStore, onSuccess, o
|
|
|
1639
1733
|
}
|
|
1640
1734
|
}, [deviceFlow, status]);
|
|
1641
1735
|
if (status === "initiating") {
|
|
1642
|
-
return /* @__PURE__ */
|
|
1736
|
+
return /* @__PURE__ */ React14.createElement(Box13, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React14.createElement(Box13, null, /* @__PURE__ */ React14.createElement(Text13, { color: "cyan" }, /* @__PURE__ */ React14.createElement(Spinner2, { type: "dots" }), " Initiating device authorization...")));
|
|
1643
1737
|
}
|
|
1644
1738
|
if (status === "error") {
|
|
1645
|
-
return /* @__PURE__ */
|
|
1739
|
+
return /* @__PURE__ */ React14.createElement(Box13, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React14.createElement(Box13, { marginBottom: 1 }, /* @__PURE__ */ React14.createElement(Text13, { color: "red", bold: true }, "\u2716 Authentication Failed")), /* @__PURE__ */ React14.createElement(Box13, null, /* @__PURE__ */ React14.createElement(Text13, { color: "red" }, error)));
|
|
1646
1740
|
}
|
|
1647
1741
|
if (status === "success") {
|
|
1648
|
-
return /* @__PURE__ */
|
|
1742
|
+
return /* @__PURE__ */ React14.createElement(Box13, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React14.createElement(Box13, { marginBottom: 1 }, /* @__PURE__ */ React14.createElement(Text13, { color: "green", bold: true }, "\u2714 Successfully authenticated!")), /* @__PURE__ */ React14.createElement(Box13, null, /* @__PURE__ */ React14.createElement(Text13, { dimColor: true }, "You can now use B4M CLI with your account.")));
|
|
1649
1743
|
}
|
|
1650
|
-
return /* @__PURE__ */
|
|
1744
|
+
return /* @__PURE__ */ React14.createElement(Box13, { flexDirection: "column", padding: 1, borderStyle: "round", borderColor: "cyan" }, /* @__PURE__ */ React14.createElement(Box13, { marginBottom: 1 }, /* @__PURE__ */ React14.createElement(Text13, { color: "cyan", bold: true }, "\u{1F510} Device Authorization")), /* @__PURE__ */ React14.createElement(Box13, { marginBottom: 1 }, /* @__PURE__ */ React14.createElement(Text13, null, "Opening browser automatically... If it doesn't open, please visit:")), /* @__PURE__ */ React14.createElement(Box13, { marginBottom: 1, paddingLeft: 2 }, /* @__PURE__ */ React14.createElement(Text13, { color: "blue", bold: true }, deviceFlow?.verification_uri)), /* @__PURE__ */ React14.createElement(Box13, { marginBottom: 1 }, /* @__PURE__ */ React14.createElement(Text13, null, "And enter this code when prompted:")), /* @__PURE__ */ React14.createElement(Box13, { marginBottom: 1, paddingLeft: 2 }, /* @__PURE__ */ React14.createElement(Text13, { color: "yellow", bold: true }, deviceFlow?.user_code)), /* @__PURE__ */ React14.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React14.createElement(Text13, { color: "cyan" }, /* @__PURE__ */ React14.createElement(Spinner2, { type: "dots" }), " ", statusMessage)), /* @__PURE__ */ React14.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React14.createElement(Text13, { dimColor: true }, "Expires in ", deviceFlow ? Math.floor(deviceFlow.expires_in / 60) : 0, " minutes")));
|
|
1651
1745
|
}
|
|
1652
1746
|
|
|
1653
1747
|
// src/storage/SessionStore.ts
|
|
@@ -9551,7 +9645,8 @@ var LOCAL_TOOLS = [
|
|
|
9551
9645
|
"edit_file",
|
|
9552
9646
|
"dice_roll",
|
|
9553
9647
|
"math_evaluate",
|
|
9554
|
-
"current_datetime"
|
|
9648
|
+
"current_datetime",
|
|
9649
|
+
"bash_execute"
|
|
9555
9650
|
];
|
|
9556
9651
|
function isServerTool(toolName) {
|
|
9557
9652
|
return SERVER_TOOLS.includes(toolName);
|
|
@@ -10813,7 +10908,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
|
|
|
10813
10908
|
// package.json
|
|
10814
10909
|
var package_default = {
|
|
10815
10910
|
name: "@bike4mind/cli",
|
|
10816
|
-
version: "0.2.8-cli-bash-tools.
|
|
10911
|
+
version: "0.2.8-cli-bash-tools.17156+ced3f15ab",
|
|
10817
10912
|
type: "module",
|
|
10818
10913
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
10819
10914
|
license: "UNLICENSED",
|
|
@@ -10916,10 +11011,10 @@ var package_default = {
|
|
|
10916
11011
|
},
|
|
10917
11012
|
devDependencies: {
|
|
10918
11013
|
"@bike4mind/agents": "0.1.0",
|
|
10919
|
-
"@bike4mind/common": "2.38.2-cli-bash-tools.
|
|
10920
|
-
"@bike4mind/mcp": "1.20.2-cli-bash-tools.
|
|
10921
|
-
"@bike4mind/services": "2.33.2-cli-bash-tools.
|
|
10922
|
-
"@bike4mind/utils": "2.1.3-cli-bash-tools.
|
|
11014
|
+
"@bike4mind/common": "2.38.2-cli-bash-tools.17156+ced3f15ab",
|
|
11015
|
+
"@bike4mind/mcp": "1.20.2-cli-bash-tools.17156+ced3f15ab",
|
|
11016
|
+
"@bike4mind/services": "2.33.2-cli-bash-tools.17156+ced3f15ab",
|
|
11017
|
+
"@bike4mind/utils": "2.1.3-cli-bash-tools.17156+ced3f15ab",
|
|
10923
11018
|
"@types/better-sqlite3": "^7.6.12",
|
|
10924
11019
|
"@types/diff": "^5.0.9",
|
|
10925
11020
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -10932,7 +11027,7 @@ var package_default = {
|
|
|
10932
11027
|
typescript: "^5.9.3",
|
|
10933
11028
|
vitest: "^3.2.4"
|
|
10934
11029
|
},
|
|
10935
|
-
gitHead: "
|
|
11030
|
+
gitHead: "ced3f15ab25eb7967bc31832769ab00be9965ff3"
|
|
10936
11031
|
};
|
|
10937
11032
|
|
|
10938
11033
|
// src/config/constants.ts
|
|
@@ -10954,7 +11049,7 @@ var usageCache = null;
|
|
|
10954
11049
|
function CliApp() {
|
|
10955
11050
|
const { exit } = useApp();
|
|
10956
11051
|
const imageRenderer = new ImageRenderer();
|
|
10957
|
-
const [state, setState] =
|
|
11052
|
+
const [state, setState] = useState6({
|
|
10958
11053
|
session: null,
|
|
10959
11054
|
sessionStore: new SessionStore(),
|
|
10960
11055
|
configStore: new ConfigStore(),
|
|
@@ -10970,9 +11065,9 @@ function CliApp() {
|
|
|
10970
11065
|
trustLocationSelector: null,
|
|
10971
11066
|
rewindSelector: null
|
|
10972
11067
|
});
|
|
10973
|
-
const [isInitialized, setIsInitialized] =
|
|
10974
|
-
const [initError, setInitError] =
|
|
10975
|
-
const [commandHistory, setCommandHistory] =
|
|
11068
|
+
const [isInitialized, setIsInitialized] = useState6(false);
|
|
11069
|
+
const [initError, setInitError] = useState6(null);
|
|
11070
|
+
const [commandHistory, setCommandHistory] = useState6([]);
|
|
10976
11071
|
const imageStoreInitPromise = useRef(null);
|
|
10977
11072
|
const setStoreSession = useCliStore((state2) => state2.setSession);
|
|
10978
11073
|
const setPermissionPrompt = useCliStore((state2) => state2.setPermissionPrompt);
|
|
@@ -11013,7 +11108,7 @@ function CliApp() {
|
|
|
11013
11108
|
process.exit(0);
|
|
11014
11109
|
}, 100);
|
|
11015
11110
|
}, [state.session, state.sessionStore, state.mcpManager, state.agent, state.imageStore]);
|
|
11016
|
-
|
|
11111
|
+
useInput5((input, key) => {
|
|
11017
11112
|
if (key.ctrl && input === "c") {
|
|
11018
11113
|
const now = Date.now();
|
|
11019
11114
|
if (exitTimestamp && now - exitTimestamp < EXIT_TIMEOUT_MS) {
|
|
@@ -11925,12 +12020,12 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
11925
12020
|
setState((prev) => ({ ...prev, config: updatedConfig }));
|
|
11926
12021
|
};
|
|
11927
12022
|
if (initError) {
|
|
11928
|
-
return /* @__PURE__ */
|
|
12023
|
+
return /* @__PURE__ */ React15.createElement(Box14, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React15.createElement(Text14, { color: "red", bold: true }, "\u274C Initialization Error"), /* @__PURE__ */ React15.createElement(Text14, null, initError), /* @__PURE__ */ React15.createElement(Text14, { dimColor: true }, "\n", "Tip: Run /config to set up your API keys"));
|
|
11929
12024
|
}
|
|
11930
12025
|
if (state.trustLocationSelector) {
|
|
11931
12026
|
const projectDir = state.configStore.getProjectConfigDir();
|
|
11932
12027
|
const inProject = projectDir !== null;
|
|
11933
|
-
return /* @__PURE__ */
|
|
12028
|
+
return /* @__PURE__ */ React15.createElement(
|
|
11934
12029
|
TrustLocationSelector,
|
|
11935
12030
|
{
|
|
11936
12031
|
inProject,
|
|
@@ -11948,7 +12043,7 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
11948
12043
|
);
|
|
11949
12044
|
}
|
|
11950
12045
|
if (state.rewindSelector && state.session) {
|
|
11951
|
-
return /* @__PURE__ */
|
|
12046
|
+
return /* @__PURE__ */ React15.createElement(
|
|
11952
12047
|
RewindSelector,
|
|
11953
12048
|
{
|
|
11954
12049
|
messages: state.session.messages,
|
|
@@ -11967,7 +12062,7 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
11967
12062
|
}
|
|
11968
12063
|
if (state.showLoginFlow) {
|
|
11969
12064
|
const loginApiUrl = getApiUrl(state.config?.apiConfig);
|
|
11970
|
-
return /* @__PURE__ */
|
|
12065
|
+
return /* @__PURE__ */ React15.createElement(
|
|
11971
12066
|
LoginFlow,
|
|
11972
12067
|
{
|
|
11973
12068
|
apiUrl: loginApiUrl,
|
|
@@ -11990,9 +12085,9 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
11990
12085
|
);
|
|
11991
12086
|
}
|
|
11992
12087
|
if (!isInitialized) {
|
|
11993
|
-
return /* @__PURE__ */
|
|
12088
|
+
return /* @__PURE__ */ React15.createElement(Box14, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React15.createElement(Text14, null, "\u{1F680} Initializing..."));
|
|
11994
12089
|
}
|
|
11995
|
-
return /* @__PURE__ */
|
|
12090
|
+
return /* @__PURE__ */ React15.createElement(
|
|
11996
12091
|
App,
|
|
11997
12092
|
{
|
|
11998
12093
|
onMessage: handleMessage,
|
|
@@ -12031,6 +12126,6 @@ var isDevMode = import.meta.url.includes("/src/") || process.env.NODE_ENV === "d
|
|
|
12031
12126
|
if (isDevMode) {
|
|
12032
12127
|
console.log("\u{1F527} Running in development mode (using TypeScript source)\n");
|
|
12033
12128
|
}
|
|
12034
|
-
render(/* @__PURE__ */
|
|
12129
|
+
render(/* @__PURE__ */ React15.createElement(CliApp, null), {
|
|
12035
12130
|
exitOnCtrlC: false
|
|
12036
12131
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bike4mind/cli",
|
|
3
|
-
"version": "0.2.8-cli-bash-tools.
|
|
3
|
+
"version": "0.2.8-cli-bash-tools.17156+ced3f15ab",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -103,10 +103,10 @@
|
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@bike4mind/agents": "0.1.0",
|
|
106
|
-
"@bike4mind/common": "2.38.2-cli-bash-tools.
|
|
107
|
-
"@bike4mind/mcp": "1.20.2-cli-bash-tools.
|
|
108
|
-
"@bike4mind/services": "2.33.2-cli-bash-tools.
|
|
109
|
-
"@bike4mind/utils": "2.1.3-cli-bash-tools.
|
|
106
|
+
"@bike4mind/common": "2.38.2-cli-bash-tools.17156+ced3f15ab",
|
|
107
|
+
"@bike4mind/mcp": "1.20.2-cli-bash-tools.17156+ced3f15ab",
|
|
108
|
+
"@bike4mind/services": "2.33.2-cli-bash-tools.17156+ced3f15ab",
|
|
109
|
+
"@bike4mind/utils": "2.1.3-cli-bash-tools.17156+ced3f15ab",
|
|
110
110
|
"@types/better-sqlite3": "^7.6.12",
|
|
111
111
|
"@types/diff": "^5.0.9",
|
|
112
112
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"typescript": "^5.9.3",
|
|
120
120
|
"vitest": "^3.2.4"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "ced3f15ab25eb7967bc31832769ab00be9965ff3"
|
|
123
123
|
}
|