@involvex/super-agent-cli 0.0.39 → 0.0.45
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 +1185 -308
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
3
20
|
var __export = (target, all) => {
|
|
4
21
|
for (var name in all)
|
|
5
22
|
__defProp(target, name, {
|
|
@@ -12,6 +29,11 @@ var __export = (target, all) => {
|
|
|
12
29
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
13
30
|
|
|
14
31
|
// src/utils/settings-manager.ts
|
|
32
|
+
var exports_settings_manager = {};
|
|
33
|
+
__export(exports_settings_manager, {
|
|
34
|
+
getSettingsManager: () => getSettingsManager,
|
|
35
|
+
SettingsManager: () => SettingsManager
|
|
36
|
+
});
|
|
15
37
|
import * as path from "path";
|
|
16
38
|
import * as os from "os";
|
|
17
39
|
import * as fs from "fs";
|
|
@@ -349,6 +371,70 @@ class ConfirmationService extends EventEmitter {
|
|
|
349
371
|
// src/index.ts
|
|
350
372
|
init_settings_manager();
|
|
351
373
|
|
|
374
|
+
// src/utils/file-utils.ts
|
|
375
|
+
import * as fs2 from "fs-extra";
|
|
376
|
+
import * as path2 from "path";
|
|
377
|
+
async function listFilesRecursive(dir, baseDir = dir, maxDepth = 3) {
|
|
378
|
+
const result = [];
|
|
379
|
+
try {
|
|
380
|
+
const entries = await fs2.readdir(dir, { withFileTypes: true });
|
|
381
|
+
for (const entry of entries) {
|
|
382
|
+
const fullPath = path2.join(dir, entry.name);
|
|
383
|
+
const relativePath = path2.relative(baseDir, fullPath);
|
|
384
|
+
const isIgnored = [
|
|
385
|
+
"node_modules",
|
|
386
|
+
".git",
|
|
387
|
+
"dist",
|
|
388
|
+
"build",
|
|
389
|
+
".next",
|
|
390
|
+
"target",
|
|
391
|
+
"vendor"
|
|
392
|
+
].includes(entry.name);
|
|
393
|
+
if (isIgnored) {
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
if (entry.name.startsWith(".") && entry.name !== ".env") {
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
result.push({
|
|
400
|
+
name: entry.name,
|
|
401
|
+
path: relativePath,
|
|
402
|
+
isDirectory: entry.isDirectory()
|
|
403
|
+
});
|
|
404
|
+
if (entry.isDirectory() && maxDepth > 0) {
|
|
405
|
+
const subFiles = await listFilesRecursive(fullPath, baseDir, maxDepth - 1);
|
|
406
|
+
result.push(...subFiles);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
} catch (error) {}
|
|
410
|
+
return result;
|
|
411
|
+
}
|
|
412
|
+
function filterFileEntries(entries, query) {
|
|
413
|
+
if (!query) {
|
|
414
|
+
return entries.slice(0, 20);
|
|
415
|
+
}
|
|
416
|
+
const lowerQuery = query.toLowerCase();
|
|
417
|
+
return entries.filter((e) => e.path.toLowerCase().includes(lowerQuery)).sort((a, b) => {
|
|
418
|
+
const aLower = a.name.toLowerCase();
|
|
419
|
+
const bLower = b.name.toLowerCase();
|
|
420
|
+
if (aLower === lowerQuery && bLower !== lowerQuery) {
|
|
421
|
+
return -1;
|
|
422
|
+
}
|
|
423
|
+
if (bLower === lowerQuery && aLower !== lowerQuery) {
|
|
424
|
+
return 1;
|
|
425
|
+
}
|
|
426
|
+
const aPathLower = a.path.toLowerCase();
|
|
427
|
+
const bPathLower = b.path.toLowerCase();
|
|
428
|
+
if (aPathLower.startsWith(lowerQuery) && !bPathLower.startsWith(lowerQuery)) {
|
|
429
|
+
return -1;
|
|
430
|
+
}
|
|
431
|
+
if (bPathLower.startsWith(lowerQuery) && !aPathLower.startsWith(lowerQuery)) {
|
|
432
|
+
return 1;
|
|
433
|
+
}
|
|
434
|
+
return a.path.length - b.path.length;
|
|
435
|
+
}).slice(0, 20);
|
|
436
|
+
}
|
|
437
|
+
|
|
352
438
|
// src/utils/text-utils.ts
|
|
353
439
|
function isWordBoundary(char) {
|
|
354
440
|
if (!char) {
|
|
@@ -514,7 +600,7 @@ function useInputHistory() {
|
|
|
514
600
|
}
|
|
515
601
|
|
|
516
602
|
// src/hooks/use-enhanced-input.ts
|
|
517
|
-
import {
|
|
603
|
+
import { useCallback as useCallback2, useRef, useState as useState2 } from "react";
|
|
518
604
|
function useEnhancedInput({
|
|
519
605
|
onSubmit,
|
|
520
606
|
onEscape,
|
|
@@ -570,7 +656,7 @@ function useEnhancedInput({
|
|
|
570
656
|
setOriginalInput("");
|
|
571
657
|
return;
|
|
572
658
|
}
|
|
573
|
-
if (onSpecialKey?.(key)) {
|
|
659
|
+
if (onSpecialKey?.(inputChar, key)) {
|
|
574
660
|
return;
|
|
575
661
|
}
|
|
576
662
|
if (key.escape) {
|
|
@@ -745,7 +831,18 @@ function CommandSuggestions({
|
|
|
745
831
|
return /* @__PURE__ */ jsxDEV(Box, {
|
|
746
832
|
marginTop: 1,
|
|
747
833
|
flexDirection: "column",
|
|
834
|
+
borderStyle: "round",
|
|
835
|
+
borderColor: "magenta",
|
|
836
|
+
paddingX: 1,
|
|
748
837
|
children: [
|
|
838
|
+
/* @__PURE__ */ jsxDEV(Box, {
|
|
839
|
+
marginBottom: 1,
|
|
840
|
+
children: /* @__PURE__ */ jsxDEV(Text, {
|
|
841
|
+
color: "magenta",
|
|
842
|
+
bold: true,
|
|
843
|
+
children: "Commands (/):"
|
|
844
|
+
}, undefined, false, undefined, this)
|
|
845
|
+
}, undefined, false, undefined, this),
|
|
749
846
|
filteredSuggestions.map((suggestion, index) => /* @__PURE__ */ jsxDEV(Box, {
|
|
750
847
|
paddingLeft: 1,
|
|
751
848
|
children: [
|
|
@@ -791,6 +888,7 @@ function updateCurrentModel(modelName) {
|
|
|
791
888
|
|
|
792
889
|
// src/hooks/use-input-handler.ts
|
|
793
890
|
init_settings_manager();
|
|
891
|
+
import * as fs3 from "fs-extra";
|
|
794
892
|
function useInputHandler({
|
|
795
893
|
agent,
|
|
796
894
|
chatHistory,
|
|
@@ -813,11 +911,41 @@ function useInputHandler({
|
|
|
813
911
|
const sessionFlags = confirmationService.getSessionFlags();
|
|
814
912
|
return sessionFlags.allOperations;
|
|
815
913
|
});
|
|
816
|
-
const
|
|
914
|
+
const [agentMode, setAgentMode] = useState3("code");
|
|
915
|
+
const [showMentionSuggestions, setShowMentionSuggestions] = useState3(false);
|
|
916
|
+
const [mentionSuggestions, setMentionSuggestions] = useState3([]);
|
|
917
|
+
const [mentionQuery, setMentionQuery] = useState3("");
|
|
918
|
+
const [selectedMentionIndex, setSelectedMentionIndex] = useState3(0);
|
|
919
|
+
const [showCommandPalette, setShowCommandPalette] = useState3(false);
|
|
920
|
+
const [commandPaletteQuery, setCommandPaletteQuery] = useState3("");
|
|
921
|
+
const [selectedPaletteIndex, setSelectedPaletteIndex] = useState3(0);
|
|
922
|
+
const [showProviderSelection, setShowProviderSelection] = useState3(false);
|
|
923
|
+
const [selectedProviderIndex, setSelectedProviderIndex] = useState3(0);
|
|
924
|
+
const [showConfigViewer, setShowConfigViewer] = useState3(false);
|
|
925
|
+
useEffect(() => {
|
|
926
|
+
listFilesRecursive(process.cwd()).then(setMentionSuggestions);
|
|
927
|
+
}, []);
|
|
928
|
+
const handleSpecialKey = (char, key) => {
|
|
817
929
|
if (isConfirmationActive) {
|
|
818
930
|
return true;
|
|
819
931
|
}
|
|
820
932
|
if (key.shift && key.tab) {
|
|
933
|
+
const modeCycle = ["plan", "code", "debug"];
|
|
934
|
+
const currentIndex = modeCycle.indexOf(agentMode);
|
|
935
|
+
const nextMode = modeCycle[(currentIndex + 1) % modeCycle.length];
|
|
936
|
+
setAgentMode(nextMode);
|
|
937
|
+
setChatHistory((prev) => [
|
|
938
|
+
...prev,
|
|
939
|
+
{
|
|
940
|
+
type: "assistant",
|
|
941
|
+
content: `⏺ Switched mode to: ${nextMode.toUpperCase()}`,
|
|
942
|
+
timestamp: new Date
|
|
943
|
+
}
|
|
944
|
+
]);
|
|
945
|
+
return true;
|
|
946
|
+
}
|
|
947
|
+
const isCtrlY = char === "\x19" || key.ctrl && (char === "y" || char === "Y");
|
|
948
|
+
if (isCtrlY) {
|
|
821
949
|
const newAutoEditState = !autoEditEnabled;
|
|
822
950
|
setAutoEditEnabled(newAutoEditState);
|
|
823
951
|
const confirmationService = ConfirmationService.getInstance();
|
|
@@ -826,6 +954,105 @@ function useInputHandler({
|
|
|
826
954
|
} else {
|
|
827
955
|
confirmationService.resetSession();
|
|
828
956
|
}
|
|
957
|
+
setChatHistory((prev) => [
|
|
958
|
+
...prev,
|
|
959
|
+
{
|
|
960
|
+
type: "assistant",
|
|
961
|
+
content: `\uD83D\uDE80 YOLO Mode: ${newAutoEditState ? "ENABLED" : "DISABLED"}`,
|
|
962
|
+
timestamp: new Date
|
|
963
|
+
}
|
|
964
|
+
]);
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
967
|
+
const isShellTrigger = char === "!" && input === "";
|
|
968
|
+
if (isShellTrigger) {
|
|
969
|
+
const newInput = "!";
|
|
970
|
+
setInput(newInput);
|
|
971
|
+
setCursorPosition(newInput.length);
|
|
972
|
+
return true;
|
|
973
|
+
}
|
|
974
|
+
const isCtrlP = char === "\x10" || key.ctrl && (char === "p" || char === "P");
|
|
975
|
+
if (isCtrlP) {
|
|
976
|
+
setShowCommandPalette(true);
|
|
977
|
+
setCommandPaletteQuery("");
|
|
978
|
+
setSelectedPaletteIndex(0);
|
|
979
|
+
return true;
|
|
980
|
+
}
|
|
981
|
+
if (showCommandPalette) {
|
|
982
|
+
const filtered = filterFileEntries(mentionSuggestions, commandPaletteQuery);
|
|
983
|
+
if (key.upArrow) {
|
|
984
|
+
setSelectedPaletteIndex((prev) => prev === 0 ? Math.max(0, filtered.length - 1) : prev - 1);
|
|
985
|
+
return true;
|
|
986
|
+
}
|
|
987
|
+
if (key.downArrow) {
|
|
988
|
+
setSelectedPaletteIndex((prev) => (prev + 1) % Math.max(1, filtered.length));
|
|
989
|
+
return true;
|
|
990
|
+
}
|
|
991
|
+
if (key.return) {
|
|
992
|
+
if (filtered.length > 0) {
|
|
993
|
+
const selected = filtered[selectedPaletteIndex];
|
|
994
|
+
const newInput = input + " @" + selected.path + " ";
|
|
995
|
+
setInput(newInput);
|
|
996
|
+
setCursorPosition(newInput.length);
|
|
997
|
+
}
|
|
998
|
+
setShowCommandPalette(false);
|
|
999
|
+
return true;
|
|
1000
|
+
}
|
|
1001
|
+
if (key.escape) {
|
|
1002
|
+
setShowCommandPalette(false);
|
|
1003
|
+
return true;
|
|
1004
|
+
}
|
|
1005
|
+
if (char && char.length === 1 && !key.ctrl && !key.meta && !key.escape && !key.return && !key.tab && !key.upArrow && !key.downArrow) {
|
|
1006
|
+
setCommandPaletteQuery((prev) => prev + char);
|
|
1007
|
+
setSelectedPaletteIndex(0);
|
|
1008
|
+
return true;
|
|
1009
|
+
}
|
|
1010
|
+
if (key.backspace) {
|
|
1011
|
+
setCommandPaletteQuery((prev) => prev.slice(0, -1));
|
|
1012
|
+
setSelectedPaletteIndex(0);
|
|
1013
|
+
return true;
|
|
1014
|
+
}
|
|
1015
|
+
return true;
|
|
1016
|
+
}
|
|
1017
|
+
if (showProviderSelection) {
|
|
1018
|
+
const manager = getSettingsManager();
|
|
1019
|
+
const settings = manager.loadUserSettings();
|
|
1020
|
+
const providers = Object.keys(settings.providers || {});
|
|
1021
|
+
if (key.upArrow) {
|
|
1022
|
+
setSelectedProviderIndex((prev) => prev === 0 ? Math.max(0, providers.length - 1) : prev - 1);
|
|
1023
|
+
return true;
|
|
1024
|
+
}
|
|
1025
|
+
if (key.downArrow) {
|
|
1026
|
+
setSelectedProviderIndex((prev) => (prev + 1) % Math.max(1, providers.length));
|
|
1027
|
+
return true;
|
|
1028
|
+
}
|
|
1029
|
+
if (key.return || key.tab) {
|
|
1030
|
+
if (providers.length > 0) {
|
|
1031
|
+
const selectedProviderId = providers[selectedProviderIndex];
|
|
1032
|
+
manager.updateUserSetting("active_provider", selectedProviderId);
|
|
1033
|
+
setChatHistory((prev) => [
|
|
1034
|
+
...prev,
|
|
1035
|
+
{
|
|
1036
|
+
type: "assistant",
|
|
1037
|
+
content: `✓ Switched active provider to: ${selectedProviderId}`,
|
|
1038
|
+
timestamp: new Date
|
|
1039
|
+
}
|
|
1040
|
+
]);
|
|
1041
|
+
}
|
|
1042
|
+
setShowProviderSelection(false);
|
|
1043
|
+
return true;
|
|
1044
|
+
}
|
|
1045
|
+
if (key.escape) {
|
|
1046
|
+
setShowProviderSelection(false);
|
|
1047
|
+
return true;
|
|
1048
|
+
}
|
|
1049
|
+
return true;
|
|
1050
|
+
}
|
|
1051
|
+
if (showConfigViewer) {
|
|
1052
|
+
if (key.escape) {
|
|
1053
|
+
setShowConfigViewer(false);
|
|
1054
|
+
return true;
|
|
1055
|
+
}
|
|
829
1056
|
return true;
|
|
830
1057
|
}
|
|
831
1058
|
if (key.escape) {
|
|
@@ -901,6 +1128,31 @@ function useInputHandler({
|
|
|
901
1128
|
return true;
|
|
902
1129
|
}
|
|
903
1130
|
}
|
|
1131
|
+
if (showMentionSuggestions) {
|
|
1132
|
+
const filtered = filterFileEntries(mentionSuggestions, mentionQuery);
|
|
1133
|
+
if (filtered.length === 0) {
|
|
1134
|
+
setShowMentionSuggestions(false);
|
|
1135
|
+
return false;
|
|
1136
|
+
}
|
|
1137
|
+
if (key.upArrow) {
|
|
1138
|
+
setSelectedMentionIndex((prev) => prev === 0 ? filtered.length - 1 : prev - 1);
|
|
1139
|
+
return true;
|
|
1140
|
+
}
|
|
1141
|
+
if (key.downArrow) {
|
|
1142
|
+
setSelectedMentionIndex((prev) => (prev + 1) % filtered.length);
|
|
1143
|
+
return true;
|
|
1144
|
+
}
|
|
1145
|
+
if (key.tab || key.return) {
|
|
1146
|
+
const selected = filtered[selectedMentionIndex];
|
|
1147
|
+
const lastAtIndex = input.lastIndexOf("@");
|
|
1148
|
+
const newInput = input.slice(0, lastAtIndex) + "@" + selected.path + " ";
|
|
1149
|
+
setInput(newInput);
|
|
1150
|
+
setCursorPosition(newInput.length);
|
|
1151
|
+
setShowMentionSuggestions(false);
|
|
1152
|
+
setSelectedMentionIndex(0);
|
|
1153
|
+
return true;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
904
1156
|
return false;
|
|
905
1157
|
};
|
|
906
1158
|
const handleInputSubmit = async (userInput) => {
|
|
@@ -920,7 +1172,14 @@ function useInputHandler({
|
|
|
920
1172
|
setSelectedCommandIndex(0);
|
|
921
1173
|
} else {
|
|
922
1174
|
setShowCommandSuggestions(false);
|
|
923
|
-
|
|
1175
|
+
}
|
|
1176
|
+
const mentionMatch = newInput.match(/@([\w\-\./]*)$/);
|
|
1177
|
+
if (mentionMatch) {
|
|
1178
|
+
setShowMentionSuggestions(true);
|
|
1179
|
+
setMentionQuery(mentionMatch[1]);
|
|
1180
|
+
setSelectedMentionIndex(0);
|
|
1181
|
+
} else {
|
|
1182
|
+
setShowMentionSuggestions(false);
|
|
924
1183
|
}
|
|
925
1184
|
};
|
|
926
1185
|
const {
|
|
@@ -933,10 +1192,32 @@ function useInputHandler({
|
|
|
933
1192
|
handleInput
|
|
934
1193
|
} = useEnhancedInput({
|
|
935
1194
|
onSubmit: handleInputSubmit,
|
|
936
|
-
|
|
1195
|
+
onEscape: () => {
|
|
1196
|
+
if (showCommandSuggestions) {
|
|
1197
|
+
setShowCommandSuggestions(false);
|
|
1198
|
+
setSelectedCommandIndex(0);
|
|
1199
|
+
} else if (showModelSelection) {
|
|
1200
|
+
setShowModelSelection(false);
|
|
1201
|
+
setSelectedModelIndex(0);
|
|
1202
|
+
} else if (showMentionSuggestions) {
|
|
1203
|
+
setShowMentionSuggestions(false);
|
|
1204
|
+
} else if (showCommandPalette) {
|
|
1205
|
+
setShowCommandPalette(false);
|
|
1206
|
+
} else if (isProcessing || isStreaming) {
|
|
1207
|
+
agent.abortCurrentOperation();
|
|
1208
|
+
setIsProcessing(false);
|
|
1209
|
+
setIsStreaming(false);
|
|
1210
|
+
setTokenCount(0);
|
|
1211
|
+
setProcessingTime(0);
|
|
1212
|
+
processingStartTime.current = 0;
|
|
1213
|
+
}
|
|
1214
|
+
},
|
|
937
1215
|
disabled: isConfirmationActive
|
|
938
1216
|
});
|
|
939
1217
|
useInput((inputChar, key) => {
|
|
1218
|
+
if (handleSpecialKey(inputChar, key)) {
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
940
1221
|
handleInput(inputChar, key);
|
|
941
1222
|
});
|
|
942
1223
|
useEffect(() => {
|
|
@@ -1008,41 +1289,13 @@ Config Commands:
|
|
|
1008
1289
|
process.exit(0);
|
|
1009
1290
|
}
|
|
1010
1291
|
if (trimmedInput === "/config") {
|
|
1011
|
-
|
|
1012
|
-
const settings = manager.loadUserSettings();
|
|
1013
|
-
const activeProvider = settings.active_provider;
|
|
1014
|
-
const activeConfig = settings.providers[activeProvider];
|
|
1015
|
-
const content = `Current Configuration:
|
|
1016
|
-
- Active Provider: ${activeProvider}
|
|
1017
|
-
- API Key: ${activeConfig?.api_key ? "********" : "(not set)"}
|
|
1018
|
-
- Base URL: ${activeConfig?.base_url || "(default)"}
|
|
1019
|
-
- Model: ${activeConfig?.model || "(default)"}
|
|
1020
|
-
- Theme: ${settings.ui.theme}
|
|
1021
|
-
|
|
1022
|
-
Use '/provider' to see all providers.
|
|
1023
|
-
Use '/provider use <id>' to switch.
|
|
1024
|
-
`;
|
|
1025
|
-
setChatHistory((prev) => [
|
|
1026
|
-
...prev,
|
|
1027
|
-
{ type: "assistant", content, timestamp: new Date }
|
|
1028
|
-
]);
|
|
1292
|
+
setShowConfigViewer(true);
|
|
1029
1293
|
clearInput();
|
|
1030
1294
|
return true;
|
|
1031
1295
|
}
|
|
1032
1296
|
if (trimmedInput === "/provider") {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
const providers = Object.keys(settings.providers || {});
|
|
1036
|
-
const active = settings.active_provider;
|
|
1037
|
-
const content = `Configured Providers:
|
|
1038
|
-
${providers.map((p) => `- ${p} ${p === active ? "(active)" : ""}`).join(`
|
|
1039
|
-
`)}
|
|
1040
|
-
|
|
1041
|
-
Use '/provider use <id>' to switch provider.`;
|
|
1042
|
-
setChatHistory((prev) => [
|
|
1043
|
-
...prev,
|
|
1044
|
-
{ type: "assistant", content, timestamp: new Date }
|
|
1045
|
-
]);
|
|
1297
|
+
setShowProviderSelection(true);
|
|
1298
|
+
setSelectedProviderIndex(0);
|
|
1046
1299
|
clearInput();
|
|
1047
1300
|
return true;
|
|
1048
1301
|
}
|
|
@@ -1274,6 +1527,46 @@ ${commitMessage}`
|
|
|
1274
1527
|
clearInput();
|
|
1275
1528
|
return true;
|
|
1276
1529
|
}
|
|
1530
|
+
if (trimmedInput.startsWith("!")) {
|
|
1531
|
+
const command = trimmedInput.slice(1).trim();
|
|
1532
|
+
if (!command) {
|
|
1533
|
+
clearInput();
|
|
1534
|
+
return true;
|
|
1535
|
+
}
|
|
1536
|
+
const userEntry = {
|
|
1537
|
+
type: "user",
|
|
1538
|
+
content: trimmedInput,
|
|
1539
|
+
timestamp: new Date
|
|
1540
|
+
};
|
|
1541
|
+
setChatHistory((prev) => [...prev, userEntry]);
|
|
1542
|
+
try {
|
|
1543
|
+
const result = await agent.executeBashCommand(command);
|
|
1544
|
+
const commandEntry = {
|
|
1545
|
+
type: "tool_result",
|
|
1546
|
+
content: result.success ? result.output || "Command completed" : result.error || "Command failed",
|
|
1547
|
+
timestamp: new Date,
|
|
1548
|
+
toolCall: {
|
|
1549
|
+
id: `bash_${Date.now()}`,
|
|
1550
|
+
type: "function",
|
|
1551
|
+
function: {
|
|
1552
|
+
name: "bash",
|
|
1553
|
+
arguments: JSON.stringify({ command })
|
|
1554
|
+
}
|
|
1555
|
+
},
|
|
1556
|
+
toolResult: result
|
|
1557
|
+
};
|
|
1558
|
+
setChatHistory((prev) => [...prev, commandEntry]);
|
|
1559
|
+
} catch (error) {
|
|
1560
|
+
const errorEntry = {
|
|
1561
|
+
type: "assistant",
|
|
1562
|
+
content: `Error executing command: ${error.message}`,
|
|
1563
|
+
timestamp: new Date
|
|
1564
|
+
};
|
|
1565
|
+
setChatHistory((prev) => [...prev, errorEntry]);
|
|
1566
|
+
}
|
|
1567
|
+
clearInput();
|
|
1568
|
+
return true;
|
|
1569
|
+
}
|
|
1277
1570
|
const directBashCommands = [
|
|
1278
1571
|
"ls",
|
|
1279
1572
|
"pwd",
|
|
@@ -1327,6 +1620,42 @@ ${commitMessage}`
|
|
|
1327
1620
|
return false;
|
|
1328
1621
|
};
|
|
1329
1622
|
const processUserMessage = async (userInput) => {
|
|
1623
|
+
let resolvedInput = userInput;
|
|
1624
|
+
const mentionMatches = userInput.match(/@([\w\-\./]+)/g);
|
|
1625
|
+
if (mentionMatches) {
|
|
1626
|
+
for (const mention of mentionMatches) {
|
|
1627
|
+
const filePath = mention.slice(1);
|
|
1628
|
+
try {
|
|
1629
|
+
const stats = await fs3.stat(filePath);
|
|
1630
|
+
if (stats.isFile()) {
|
|
1631
|
+
const content = await fs3.readFile(filePath, "utf-8");
|
|
1632
|
+
resolvedInput = resolvedInput.replace(mention, `
|
|
1633
|
+
|
|
1634
|
+
--- FILE: ${filePath} ---
|
|
1635
|
+
${content}
|
|
1636
|
+
--- END FILE ---
|
|
1637
|
+
|
|
1638
|
+
`);
|
|
1639
|
+
} else if (stats.isDirectory()) {
|
|
1640
|
+
const tree = await listFilesRecursive(filePath, process.cwd(), 1);
|
|
1641
|
+
const structure = tree.map((t) => `${t.isDirectory ? "\uD83D\uDCC1" : "\uD83D\uDCC4"} ${t.path}`).join(`
|
|
1642
|
+
`);
|
|
1643
|
+
resolvedInput = resolvedInput.replace(mention, `
|
|
1644
|
+
|
|
1645
|
+
--- DIRECTORY: ${filePath} ---
|
|
1646
|
+
${structure}
|
|
1647
|
+
--- END DIRECTORY ---
|
|
1648
|
+
|
|
1649
|
+
`);
|
|
1650
|
+
}
|
|
1651
|
+
} catch (e) {}
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
if (agentMode === "plan") {
|
|
1655
|
+
resolvedInput = `[MODE: PLAN] ${resolvedInput}`;
|
|
1656
|
+
} else if (agentMode === "debug") {
|
|
1657
|
+
resolvedInput = `[MODE: DEBUG] ${resolvedInput}`;
|
|
1658
|
+
}
|
|
1330
1659
|
const userEntry = {
|
|
1331
1660
|
type: "user",
|
|
1332
1661
|
content: userInput,
|
|
@@ -1338,7 +1667,7 @@ ${commitMessage}`
|
|
|
1338
1667
|
try {
|
|
1339
1668
|
setIsStreaming(true);
|
|
1340
1669
|
let streamingEntry = null;
|
|
1341
|
-
for await (const chunk of agent.processUserMessageStream(
|
|
1670
|
+
for await (const chunk of agent.processUserMessageStream(resolvedInput)) {
|
|
1342
1671
|
switch (chunk.type) {
|
|
1343
1672
|
case "content":
|
|
1344
1673
|
if (chunk.content) {
|
|
@@ -1429,21 +1758,194 @@ ${commitMessage}`
|
|
|
1429
1758
|
selectedModelIndex,
|
|
1430
1759
|
commandSuggestions,
|
|
1431
1760
|
availableModels,
|
|
1432
|
-
|
|
1433
|
-
|
|
1761
|
+
autoEditEnabled,
|
|
1762
|
+
setInput,
|
|
1763
|
+
setCursorPosition,
|
|
1764
|
+
clearInput,
|
|
1765
|
+
resetHistory,
|
|
1766
|
+
handleInput,
|
|
1767
|
+
agentMode,
|
|
1768
|
+
showMentionSuggestions,
|
|
1769
|
+
selectedMentionIndex,
|
|
1770
|
+
mentionSuggestions,
|
|
1771
|
+
mentionQuery,
|
|
1772
|
+
showCommandPalette,
|
|
1773
|
+
commandPaletteQuery,
|
|
1774
|
+
selectedPaletteIndex,
|
|
1775
|
+
showProviderSelection,
|
|
1776
|
+
selectedProviderIndex,
|
|
1777
|
+
showConfigViewer
|
|
1434
1778
|
};
|
|
1435
1779
|
}
|
|
1436
1780
|
|
|
1781
|
+
// src/ui/components/mention-suggestions.tsx
|
|
1782
|
+
import { useMemo as useMemo3 } from "react";
|
|
1783
|
+
import { Box as Box2, Text as Text2 } from "ink";
|
|
1784
|
+
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
1785
|
+
function MentionSuggestions({
|
|
1786
|
+
suggestions,
|
|
1787
|
+
query,
|
|
1788
|
+
selectedIndex,
|
|
1789
|
+
isVisible
|
|
1790
|
+
}) {
|
|
1791
|
+
if (!isVisible) {
|
|
1792
|
+
return null;
|
|
1793
|
+
}
|
|
1794
|
+
const filteredSuggestions = useMemo3(() => filterFileEntries(suggestions, query), [suggestions, query]);
|
|
1795
|
+
const displayedSuggestions = filteredSuggestions.slice(0, 8);
|
|
1796
|
+
return /* @__PURE__ */ jsxDEV2(Box2, {
|
|
1797
|
+
flexDirection: "column",
|
|
1798
|
+
borderStyle: "round",
|
|
1799
|
+
borderColor: "cyan",
|
|
1800
|
+
paddingX: 1,
|
|
1801
|
+
width: process.stdout.columns ? Math.min(100, process.stdout.columns - 4) : 100,
|
|
1802
|
+
children: [
|
|
1803
|
+
/* @__PURE__ */ jsxDEV2(Box2, {
|
|
1804
|
+
marginBottom: 1,
|
|
1805
|
+
children: /* @__PURE__ */ jsxDEV2(Text2, {
|
|
1806
|
+
color: "cyan",
|
|
1807
|
+
bold: true,
|
|
1808
|
+
children: "Mention file or folder (@):"
|
|
1809
|
+
}, undefined, false, undefined, this)
|
|
1810
|
+
}, undefined, false, undefined, this),
|
|
1811
|
+
displayedSuggestions.map((suggestion, index) => /* @__PURE__ */ jsxDEV2(Box2, {
|
|
1812
|
+
paddingLeft: 1,
|
|
1813
|
+
children: [
|
|
1814
|
+
/* @__PURE__ */ jsxDEV2(Box2, {
|
|
1815
|
+
width: 3,
|
|
1816
|
+
children: /* @__PURE__ */ jsxDEV2(Text2, {
|
|
1817
|
+
children: index === selectedIndex ? "❯" : " "
|
|
1818
|
+
}, undefined, false, undefined, this)
|
|
1819
|
+
}, undefined, false, undefined, this),
|
|
1820
|
+
/* @__PURE__ */ jsxDEV2(Text2, {
|
|
1821
|
+
color: index === selectedIndex ? "black" : suggestion.isDirectory ? "blue" : "white",
|
|
1822
|
+
backgroundColor: index === selectedIndex ? "cyan" : undefined,
|
|
1823
|
+
children: [
|
|
1824
|
+
suggestion.isDirectory ? "\uD83D\uDCC1" : "\uD83D\uDCC4",
|
|
1825
|
+
" ",
|
|
1826
|
+
suggestion.path
|
|
1827
|
+
]
|
|
1828
|
+
}, undefined, true, undefined, this)
|
|
1829
|
+
]
|
|
1830
|
+
}, index, true, undefined, this)),
|
|
1831
|
+
filteredSuggestions.length > 8 && /* @__PURE__ */ jsxDEV2(Box2, {
|
|
1832
|
+
paddingLeft: 1,
|
|
1833
|
+
children: /* @__PURE__ */ jsxDEV2(Text2, {
|
|
1834
|
+
color: "gray",
|
|
1835
|
+
children: [
|
|
1836
|
+
"... and ",
|
|
1837
|
+
filteredSuggestions.length - 8,
|
|
1838
|
+
" more"
|
|
1839
|
+
]
|
|
1840
|
+
}, undefined, true, undefined, this)
|
|
1841
|
+
}, undefined, false, undefined, this),
|
|
1842
|
+
/* @__PURE__ */ jsxDEV2(Box2, {
|
|
1843
|
+
marginTop: 1,
|
|
1844
|
+
children: /* @__PURE__ */ jsxDEV2(Text2, {
|
|
1845
|
+
color: "gray",
|
|
1846
|
+
dimColor: true,
|
|
1847
|
+
children: "↑↓ navigate • Enter/Tab select • Esc cancel"
|
|
1848
|
+
}, undefined, false, undefined, this)
|
|
1849
|
+
}, undefined, false, undefined, this)
|
|
1850
|
+
]
|
|
1851
|
+
}, undefined, true, undefined, this);
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
// src/ui/components/provider-selection.tsx
|
|
1855
|
+
import { Box as Box3, Text as Text3 } from "ink";
|
|
1856
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
1857
|
+
function ProviderSelection({
|
|
1858
|
+
providers,
|
|
1859
|
+
selectedIndex,
|
|
1860
|
+
isVisible
|
|
1861
|
+
}) {
|
|
1862
|
+
if (!isVisible) {
|
|
1863
|
+
return null;
|
|
1864
|
+
}
|
|
1865
|
+
return /* @__PURE__ */ jsxDEV3(Box3, {
|
|
1866
|
+
flexDirection: "column",
|
|
1867
|
+
borderStyle: "round",
|
|
1868
|
+
borderColor: "cyan",
|
|
1869
|
+
paddingX: 1,
|
|
1870
|
+
width: process.stdout.columns ? Math.min(80, process.stdout.columns - 4) : 80,
|
|
1871
|
+
children: [
|
|
1872
|
+
/* @__PURE__ */ jsxDEV3(Box3, {
|
|
1873
|
+
marginBottom: 1,
|
|
1874
|
+
children: /* @__PURE__ */ jsxDEV3(Text3, {
|
|
1875
|
+
color: "cyan",
|
|
1876
|
+
bold: true,
|
|
1877
|
+
children: "\uD83D\uDD0C Select AI Provider"
|
|
1878
|
+
}, undefined, false, undefined, this)
|
|
1879
|
+
}, undefined, false, undefined, this),
|
|
1880
|
+
/* @__PURE__ */ jsxDEV3(Box3, {
|
|
1881
|
+
flexDirection: "column",
|
|
1882
|
+
children: providers.map((provider, index) => /* @__PURE__ */ jsxDEV3(Box3, {
|
|
1883
|
+
paddingLeft: 1,
|
|
1884
|
+
children: [
|
|
1885
|
+
/* @__PURE__ */ jsxDEV3(Box3, {
|
|
1886
|
+
width: 3,
|
|
1887
|
+
children: /* @__PURE__ */ jsxDEV3(Text3, {
|
|
1888
|
+
children: index === selectedIndex ? "❯" : " "
|
|
1889
|
+
}, undefined, false, undefined, this)
|
|
1890
|
+
}, undefined, false, undefined, this),
|
|
1891
|
+
/* @__PURE__ */ jsxDEV3(Text3, {
|
|
1892
|
+
color: index === selectedIndex ? "white" : "white",
|
|
1893
|
+
backgroundColor: index === selectedIndex ? "cyan" : undefined,
|
|
1894
|
+
bold: index === selectedIndex,
|
|
1895
|
+
children: [
|
|
1896
|
+
provider.id,
|
|
1897
|
+
provider.isActive && " ★"
|
|
1898
|
+
]
|
|
1899
|
+
}, undefined, true, undefined, this),
|
|
1900
|
+
/* @__PURE__ */ jsxDEV3(Box3, {
|
|
1901
|
+
marginLeft: 2,
|
|
1902
|
+
children: /* @__PURE__ */ jsxDEV3(Text3, {
|
|
1903
|
+
color: "gray",
|
|
1904
|
+
children: [
|
|
1905
|
+
provider.hasApiKey ? "✓" : "✗",
|
|
1906
|
+
" API Key",
|
|
1907
|
+
provider.model ? ` | ${provider.model}` : ""
|
|
1908
|
+
]
|
|
1909
|
+
}, undefined, true, undefined, this)
|
|
1910
|
+
}, undefined, false, undefined, this)
|
|
1911
|
+
]
|
|
1912
|
+
}, provider.id, true, undefined, this))
|
|
1913
|
+
}, undefined, false, undefined, this),
|
|
1914
|
+
providers.length === 0 && /* @__PURE__ */ jsxDEV3(Box3, {
|
|
1915
|
+
padding: 1,
|
|
1916
|
+
children: /* @__PURE__ */ jsxDEV3(Text3, {
|
|
1917
|
+
color: "gray",
|
|
1918
|
+
italic: true,
|
|
1919
|
+
children: "No providers configured. Check ~/.super-agent/settings.json"
|
|
1920
|
+
}, undefined, false, undefined, this)
|
|
1921
|
+
}, undefined, false, undefined, this),
|
|
1922
|
+
/* @__PURE__ */ jsxDEV3(Box3, {
|
|
1923
|
+
marginTop: 1,
|
|
1924
|
+
borderStyle: "single",
|
|
1925
|
+
borderTop: true,
|
|
1926
|
+
borderBottom: false,
|
|
1927
|
+
borderLeft: false,
|
|
1928
|
+
borderRight: false,
|
|
1929
|
+
children: /* @__PURE__ */ jsxDEV3(Text3, {
|
|
1930
|
+
color: "gray",
|
|
1931
|
+
dimColor: true,
|
|
1932
|
+
children: "↑↓ navigate • Enter select • Esc cancel"
|
|
1933
|
+
}, undefined, false, undefined, this)
|
|
1934
|
+
}, undefined, false, undefined, this)
|
|
1935
|
+
]
|
|
1936
|
+
}, undefined, true, undefined, this);
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1437
1939
|
// src/ui/shared/max-sized-box.tsx
|
|
1438
|
-
import { Box as
|
|
1439
|
-
import { jsxDEV as
|
|
1940
|
+
import { Box as Box4 } from "ink";
|
|
1941
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
1440
1942
|
var MaxSizedBox = ({
|
|
1441
1943
|
maxHeight,
|
|
1442
1944
|
maxWidth,
|
|
1443
1945
|
children,
|
|
1444
1946
|
...props
|
|
1445
1947
|
}) => {
|
|
1446
|
-
return /* @__PURE__ */
|
|
1948
|
+
return /* @__PURE__ */ jsxDEV4(Box4, {
|
|
1447
1949
|
flexDirection: "column",
|
|
1448
1950
|
...props,
|
|
1449
1951
|
children
|
|
@@ -1464,9 +1966,9 @@ var Colors = {
|
|
|
1464
1966
|
};
|
|
1465
1967
|
|
|
1466
1968
|
// src/ui/components/diff-renderer.tsx
|
|
1467
|
-
import { Box as
|
|
1969
|
+
import { Box as Box5, Text as Text4 } from "ink";
|
|
1468
1970
|
import crypto from "crypto";
|
|
1469
|
-
import { jsxDEV as
|
|
1971
|
+
import { jsxDEV as jsxDEV5, Fragment } from "react/jsx-dev-runtime";
|
|
1470
1972
|
function parseDiffWithLineNumbers(diffContent) {
|
|
1471
1973
|
const lines = diffContent.split(`
|
|
1472
1974
|
`);
|
|
@@ -1530,7 +2032,7 @@ var DiffRenderer = ({
|
|
|
1530
2032
|
terminalWidth = 80
|
|
1531
2033
|
}) => {
|
|
1532
2034
|
if (!diffContent || typeof diffContent !== "string") {
|
|
1533
|
-
return /* @__PURE__ */
|
|
2035
|
+
return /* @__PURE__ */ jsxDEV5(Text4, {
|
|
1534
2036
|
color: Colors.AccentYellow,
|
|
1535
2037
|
children: "No diff content."
|
|
1536
2038
|
}, undefined, false, undefined, this);
|
|
@@ -1545,13 +2047,13 @@ var DiffRenderer = ({
|
|
|
1545
2047
|
}
|
|
1546
2048
|
const parsedLines = parseDiffWithLineNumbers(actualDiffContent);
|
|
1547
2049
|
if (parsedLines.length === 0) {
|
|
1548
|
-
return /* @__PURE__ */
|
|
2050
|
+
return /* @__PURE__ */ jsxDEV5(Text4, {
|
|
1549
2051
|
dimColor: true,
|
|
1550
2052
|
children: "No changes detected."
|
|
1551
2053
|
}, undefined, false, undefined, this);
|
|
1552
2054
|
}
|
|
1553
2055
|
const renderedOutput = renderDiffContent(parsedLines, filename, tabWidth, availableTerminalHeight, terminalWidth);
|
|
1554
|
-
return /* @__PURE__ */
|
|
2056
|
+
return /* @__PURE__ */ jsxDEV5(Fragment, {
|
|
1555
2057
|
children: renderedOutput
|
|
1556
2058
|
}, undefined, false, undefined, this);
|
|
1557
2059
|
};
|
|
@@ -1562,7 +2064,7 @@ var renderDiffContent = (parsedLines, filename, tabWidth = DEFAULT_TAB_WIDTH, av
|
|
|
1562
2064
|
}));
|
|
1563
2065
|
const displayableLines = normalizedLines.filter((l) => l.type !== "hunk" && l.type !== "other");
|
|
1564
2066
|
if (displayableLines.length === 0) {
|
|
1565
|
-
return /* @__PURE__ */
|
|
2067
|
+
return /* @__PURE__ */ jsxDEV5(Text4, {
|
|
1566
2068
|
dimColor: true,
|
|
1567
2069
|
children: "No changes detected."
|
|
1568
2070
|
}, undefined, false, undefined, this);
|
|
@@ -1582,7 +2084,7 @@ var renderDiffContent = (parsedLines, filename, tabWidth = DEFAULT_TAB_WIDTH, av
|
|
|
1582
2084
|
const key = filename ? `diff-box-${filename}` : `diff-box-${crypto.createHash("sha1").update(JSON.stringify(parsedLines)).digest("hex")}`;
|
|
1583
2085
|
let lastLineNumber = null;
|
|
1584
2086
|
const MAX_CONTEXT_LINES_WITHOUT_GAP = 5;
|
|
1585
|
-
return /* @__PURE__ */
|
|
2087
|
+
return /* @__PURE__ */ jsxDEV5(MaxSizedBox, {
|
|
1586
2088
|
maxHeight: availableTerminalHeight,
|
|
1587
2089
|
maxWidth: terminalWidth,
|
|
1588
2090
|
children: displayableLines.reduce((acc, line, index) => {
|
|
@@ -1593,8 +2095,8 @@ var renderDiffContent = (parsedLines, filename, tabWidth = DEFAULT_TAB_WIDTH, av
|
|
|
1593
2095
|
relevantLineNumberForGapCalc = line.oldLine ?? null;
|
|
1594
2096
|
}
|
|
1595
2097
|
if (lastLineNumber !== null && relevantLineNumberForGapCalc !== null && relevantLineNumberForGapCalc > lastLineNumber + MAX_CONTEXT_LINES_WITHOUT_GAP + 1) {
|
|
1596
|
-
acc.push(/* @__PURE__ */
|
|
1597
|
-
children: /* @__PURE__ */
|
|
2098
|
+
acc.push(/* @__PURE__ */ jsxDEV5(Box5, {
|
|
2099
|
+
children: /* @__PURE__ */ jsxDEV5(Text4, {
|
|
1598
2100
|
wrap: "truncate",
|
|
1599
2101
|
children: "═".repeat(terminalWidth)
|
|
1600
2102
|
}, undefined, false, undefined, this)
|
|
@@ -1630,15 +2132,15 @@ var renderDiffContent = (parsedLines, filename, tabWidth = DEFAULT_TAB_WIDTH, av
|
|
|
1630
2132
|
return acc;
|
|
1631
2133
|
}
|
|
1632
2134
|
const displayContent = line.content.substring(baseIndentation);
|
|
1633
|
-
acc.push(/* @__PURE__ */
|
|
2135
|
+
acc.push(/* @__PURE__ */ jsxDEV5(Box5, {
|
|
1634
2136
|
flexDirection: "row",
|
|
1635
2137
|
children: [
|
|
1636
|
-
/* @__PURE__ */
|
|
2138
|
+
/* @__PURE__ */ jsxDEV5(Text4, {
|
|
1637
2139
|
color: Colors.Gray,
|
|
1638
2140
|
dimColor: dim,
|
|
1639
2141
|
children: gutterNumStr.padEnd(4)
|
|
1640
2142
|
}, undefined, false, undefined, this),
|
|
1641
|
-
/* @__PURE__ */
|
|
2143
|
+
/* @__PURE__ */ jsxDEV5(Text4, {
|
|
1642
2144
|
color: backgroundColor ? "#000000" : undefined,
|
|
1643
2145
|
backgroundColor,
|
|
1644
2146
|
dimColor: !backgroundColor && dim,
|
|
@@ -1647,7 +2149,7 @@ var renderDiffContent = (parsedLines, filename, tabWidth = DEFAULT_TAB_WIDTH, av
|
|
|
1647
2149
|
" "
|
|
1648
2150
|
]
|
|
1649
2151
|
}, undefined, true, undefined, this),
|
|
1650
|
-
/* @__PURE__ */
|
|
2152
|
+
/* @__PURE__ */ jsxDEV5(Text4, {
|
|
1651
2153
|
color: backgroundColor ? "#000000" : undefined,
|
|
1652
2154
|
backgroundColor,
|
|
1653
2155
|
dimColor: !backgroundColor && dim,
|
|
@@ -1662,9 +2164,9 @@ var renderDiffContent = (parsedLines, filename, tabWidth = DEFAULT_TAB_WIDTH, av
|
|
|
1662
2164
|
};
|
|
1663
2165
|
|
|
1664
2166
|
// src/ui/components/confirmation-dialog.tsx
|
|
1665
|
-
import { Box as
|
|
2167
|
+
import { Box as Box6, Text as Text5, useInput as useInput2 } from "ink";
|
|
1666
2168
|
import { useState as useState4 } from "react";
|
|
1667
|
-
import { jsxDEV as
|
|
2169
|
+
import { jsxDEV as jsxDEV6, Fragment as Fragment2 } from "react/jsx-dev-runtime";
|
|
1668
2170
|
function ConfirmationDialog({
|
|
1669
2171
|
operation,
|
|
1670
2172
|
filename,
|
|
@@ -1728,32 +2230,32 @@ function ConfirmationDialog({
|
|
|
1728
2230
|
}
|
|
1729
2231
|
});
|
|
1730
2232
|
if (feedbackMode) {
|
|
1731
|
-
return /* @__PURE__ */
|
|
2233
|
+
return /* @__PURE__ */ jsxDEV6(Box6, {
|
|
1732
2234
|
flexDirection: "column",
|
|
1733
2235
|
padding: 1,
|
|
1734
2236
|
children: [
|
|
1735
|
-
/* @__PURE__ */
|
|
2237
|
+
/* @__PURE__ */ jsxDEV6(Box6, {
|
|
1736
2238
|
flexDirection: "column",
|
|
1737
2239
|
marginBottom: 1,
|
|
1738
|
-
children: /* @__PURE__ */
|
|
2240
|
+
children: /* @__PURE__ */ jsxDEV6(Text5, {
|
|
1739
2241
|
color: "gray",
|
|
1740
2242
|
children: "Type your feedback and press Enter, or press Escape to go back."
|
|
1741
2243
|
}, undefined, false, undefined, this)
|
|
1742
2244
|
}, undefined, false, undefined, this),
|
|
1743
|
-
/* @__PURE__ */
|
|
2245
|
+
/* @__PURE__ */ jsxDEV6(Box6, {
|
|
1744
2246
|
borderStyle: "round",
|
|
1745
2247
|
borderColor: "yellow",
|
|
1746
2248
|
paddingX: 1,
|
|
1747
2249
|
marginTop: 1,
|
|
1748
2250
|
children: [
|
|
1749
|
-
/* @__PURE__ */
|
|
2251
|
+
/* @__PURE__ */ jsxDEV6(Text5, {
|
|
1750
2252
|
color: "gray",
|
|
1751
2253
|
children: "❯ "
|
|
1752
2254
|
}, undefined, false, undefined, this),
|
|
1753
|
-
/* @__PURE__ */
|
|
2255
|
+
/* @__PURE__ */ jsxDEV6(Text5, {
|
|
1754
2256
|
children: [
|
|
1755
2257
|
feedback,
|
|
1756
|
-
/* @__PURE__ */
|
|
2258
|
+
/* @__PURE__ */ jsxDEV6(Text5, {
|
|
1757
2259
|
color: "white",
|
|
1758
2260
|
children: "█"
|
|
1759
2261
|
}, undefined, false, undefined, this)
|
|
@@ -1764,18 +2266,18 @@ function ConfirmationDialog({
|
|
|
1764
2266
|
]
|
|
1765
2267
|
}, undefined, true, undefined, this);
|
|
1766
2268
|
}
|
|
1767
|
-
return /* @__PURE__ */
|
|
2269
|
+
return /* @__PURE__ */ jsxDEV6(Box6, {
|
|
1768
2270
|
flexDirection: "column",
|
|
1769
2271
|
children: [
|
|
1770
|
-
/* @__PURE__ */
|
|
2272
|
+
/* @__PURE__ */ jsxDEV6(Box6, {
|
|
1771
2273
|
marginTop: 1,
|
|
1772
|
-
children: /* @__PURE__ */
|
|
2274
|
+
children: /* @__PURE__ */ jsxDEV6(Box6, {
|
|
1773
2275
|
children: [
|
|
1774
|
-
/* @__PURE__ */
|
|
2276
|
+
/* @__PURE__ */ jsxDEV6(Text5, {
|
|
1775
2277
|
color: "magenta",
|
|
1776
2278
|
children: "⏺"
|
|
1777
2279
|
}, undefined, false, undefined, this),
|
|
1778
|
-
/* @__PURE__ */
|
|
2280
|
+
/* @__PURE__ */ jsxDEV6(Text5, {
|
|
1779
2281
|
color: "white",
|
|
1780
2282
|
children: [
|
|
1781
2283
|
" ",
|
|
@@ -1788,24 +2290,24 @@ function ConfirmationDialog({
|
|
|
1788
2290
|
]
|
|
1789
2291
|
}, undefined, true, undefined, this)
|
|
1790
2292
|
}, undefined, false, undefined, this),
|
|
1791
|
-
/* @__PURE__ */
|
|
2293
|
+
/* @__PURE__ */ jsxDEV6(Box6, {
|
|
1792
2294
|
marginLeft: 2,
|
|
1793
2295
|
flexDirection: "column",
|
|
1794
2296
|
children: [
|
|
1795
|
-
/* @__PURE__ */
|
|
2297
|
+
/* @__PURE__ */ jsxDEV6(Text5, {
|
|
1796
2298
|
color: "gray",
|
|
1797
2299
|
children: "⎿ Requesting user confirmation"
|
|
1798
2300
|
}, undefined, false, undefined, this),
|
|
1799
|
-
showVSCodeOpen && /* @__PURE__ */
|
|
2301
|
+
showVSCodeOpen && /* @__PURE__ */ jsxDEV6(Box6, {
|
|
1800
2302
|
marginTop: 1,
|
|
1801
|
-
children: /* @__PURE__ */
|
|
2303
|
+
children: /* @__PURE__ */ jsxDEV6(Text5, {
|
|
1802
2304
|
color: "gray",
|
|
1803
2305
|
children: "⎿ Opened changes in Visual Studio Code ⧉"
|
|
1804
2306
|
}, undefined, false, undefined, this)
|
|
1805
2307
|
}, undefined, false, undefined, this),
|
|
1806
|
-
content && /* @__PURE__ */
|
|
2308
|
+
content && /* @__PURE__ */ jsxDEV6(Fragment2, {
|
|
1807
2309
|
children: [
|
|
1808
|
-
/* @__PURE__ */
|
|
2310
|
+
/* @__PURE__ */ jsxDEV6(Text5, {
|
|
1809
2311
|
color: "gray",
|
|
1810
2312
|
children: [
|
|
1811
2313
|
"⎿ ",
|
|
@@ -1813,10 +2315,10 @@ function ConfirmationDialog({
|
|
|
1813
2315
|
`)[0]
|
|
1814
2316
|
]
|
|
1815
2317
|
}, undefined, true, undefined, this),
|
|
1816
|
-
/* @__PURE__ */
|
|
2318
|
+
/* @__PURE__ */ jsxDEV6(Box6, {
|
|
1817
2319
|
marginLeft: 4,
|
|
1818
2320
|
flexDirection: "column",
|
|
1819
|
-
children: /* @__PURE__ */
|
|
2321
|
+
children: /* @__PURE__ */ jsxDEV6(DiffRenderer, {
|
|
1820
2322
|
diffContent: content,
|
|
1821
2323
|
filename,
|
|
1822
2324
|
terminalWidth: 80
|
|
@@ -1826,21 +2328,21 @@ function ConfirmationDialog({
|
|
|
1826
2328
|
}, undefined, true, undefined, this)
|
|
1827
2329
|
]
|
|
1828
2330
|
}, undefined, true, undefined, this),
|
|
1829
|
-
/* @__PURE__ */
|
|
2331
|
+
/* @__PURE__ */ jsxDEV6(Box6, {
|
|
1830
2332
|
flexDirection: "column",
|
|
1831
2333
|
marginTop: 1,
|
|
1832
2334
|
children: [
|
|
1833
|
-
/* @__PURE__ */
|
|
2335
|
+
/* @__PURE__ */ jsxDEV6(Box6, {
|
|
1834
2336
|
marginBottom: 1,
|
|
1835
|
-
children: /* @__PURE__ */
|
|
2337
|
+
children: /* @__PURE__ */ jsxDEV6(Text5, {
|
|
1836
2338
|
children: "Do you want to proceed with this operation?"
|
|
1837
2339
|
}, undefined, false, undefined, this)
|
|
1838
2340
|
}, undefined, false, undefined, this),
|
|
1839
|
-
/* @__PURE__ */
|
|
2341
|
+
/* @__PURE__ */ jsxDEV6(Box6, {
|
|
1840
2342
|
flexDirection: "column",
|
|
1841
|
-
children: options.map((option, index) => /* @__PURE__ */
|
|
2343
|
+
children: options.map((option, index) => /* @__PURE__ */ jsxDEV6(Box6, {
|
|
1842
2344
|
paddingLeft: 1,
|
|
1843
|
-
children: /* @__PURE__ */
|
|
2345
|
+
children: /* @__PURE__ */ jsxDEV6(Text5, {
|
|
1844
2346
|
color: selectedOption === index ? "black" : "white",
|
|
1845
2347
|
backgroundColor: selectedOption === index ? "cyan" : undefined,
|
|
1846
2348
|
children: [
|
|
@@ -1851,9 +2353,9 @@ function ConfirmationDialog({
|
|
|
1851
2353
|
}, undefined, true, undefined, this)
|
|
1852
2354
|
}, index, false, undefined, this))
|
|
1853
2355
|
}, undefined, false, undefined, this),
|
|
1854
|
-
/* @__PURE__ */
|
|
2356
|
+
/* @__PURE__ */ jsxDEV6(Box6, {
|
|
1855
2357
|
marginTop: 1,
|
|
1856
|
-
children: /* @__PURE__ */
|
|
2358
|
+
children: /* @__PURE__ */ jsxDEV6(Text5, {
|
|
1857
2359
|
color: "gray",
|
|
1858
2360
|
dimColor: true,
|
|
1859
2361
|
children: "↑↓ navigate • Enter select • Esc cancel"
|
|
@@ -1869,8 +2371,8 @@ function ConfirmationDialog({
|
|
|
1869
2371
|
import { useEffect as useEffect4, useRef as useRef2, useState as useState8 } from "react";
|
|
1870
2372
|
|
|
1871
2373
|
// src/ui/components/model-selection.tsx
|
|
1872
|
-
import { Box as
|
|
1873
|
-
import { jsxDEV as
|
|
2374
|
+
import { Box as Box7, Text as Text6 } from "ink";
|
|
2375
|
+
import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
|
|
1874
2376
|
function ModelSelection({
|
|
1875
2377
|
models,
|
|
1876
2378
|
selectedIndex,
|
|
@@ -1880,14 +2382,18 @@ function ModelSelection({
|
|
|
1880
2382
|
if (!isVisible) {
|
|
1881
2383
|
return null;
|
|
1882
2384
|
}
|
|
1883
|
-
return /* @__PURE__ */
|
|
2385
|
+
return /* @__PURE__ */ jsxDEV7(Box7, {
|
|
1884
2386
|
marginTop: 1,
|
|
1885
2387
|
flexDirection: "column",
|
|
2388
|
+
borderStyle: "round",
|
|
2389
|
+
borderColor: "cyan",
|
|
2390
|
+
paddingX: 1,
|
|
1886
2391
|
children: [
|
|
1887
|
-
/* @__PURE__ */
|
|
2392
|
+
/* @__PURE__ */ jsxDEV7(Box7, {
|
|
1888
2393
|
marginBottom: 1,
|
|
1889
|
-
children: /* @__PURE__ */
|
|
2394
|
+
children: /* @__PURE__ */ jsxDEV7(Text6, {
|
|
1890
2395
|
color: "cyan",
|
|
2396
|
+
bold: true,
|
|
1891
2397
|
children: [
|
|
1892
2398
|
"Select Super Agent Model (current: ",
|
|
1893
2399
|
currentModel,
|
|
@@ -1895,17 +2401,17 @@ function ModelSelection({
|
|
|
1895
2401
|
]
|
|
1896
2402
|
}, undefined, true, undefined, this)
|
|
1897
2403
|
}, undefined, false, undefined, this),
|
|
1898
|
-
models.map((modelOption, index) => /* @__PURE__ */
|
|
2404
|
+
models.map((modelOption, index) => /* @__PURE__ */ jsxDEV7(Box7, {
|
|
1899
2405
|
paddingLeft: 1,
|
|
1900
|
-
children: /* @__PURE__ */
|
|
2406
|
+
children: /* @__PURE__ */ jsxDEV7(Text6, {
|
|
1901
2407
|
color: index === selectedIndex ? "black" : "white",
|
|
1902
2408
|
backgroundColor: index === selectedIndex ? "cyan" : undefined,
|
|
1903
2409
|
children: modelOption.model
|
|
1904
2410
|
}, undefined, false, undefined, this)
|
|
1905
2411
|
}, index, false, undefined, this)),
|
|
1906
|
-
/* @__PURE__ */
|
|
2412
|
+
/* @__PURE__ */ jsxDEV7(Box7, {
|
|
1907
2413
|
marginTop: 1,
|
|
1908
|
-
children: /* @__PURE__ */
|
|
2414
|
+
children: /* @__PURE__ */ jsxDEV7(Text6, {
|
|
1909
2415
|
color: "gray",
|
|
1910
2416
|
dimColor: true,
|
|
1911
2417
|
children: "↑↓ navigate • Enter/Tab select • Esc cancel"
|
|
@@ -1974,8 +2480,8 @@ function createTokenCounter(model) {
|
|
|
1974
2480
|
|
|
1975
2481
|
// src/ui/components/loading-spinner.tsx
|
|
1976
2482
|
import { useState as useState5, useEffect as useEffect2 } from "react";
|
|
1977
|
-
import { Box as
|
|
1978
|
-
import { jsxDEV as
|
|
2483
|
+
import { Box as Box8, Text as Text7 } from "ink";
|
|
2484
|
+
import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
|
|
1979
2485
|
var loadingTexts = [
|
|
1980
2486
|
"Thinking...",
|
|
1981
2487
|
"Computing...",
|
|
@@ -2023,10 +2529,10 @@ function LoadingSpinner({
|
|
|
2023
2529
|
return null;
|
|
2024
2530
|
}
|
|
2025
2531
|
const spinnerFrames = ["/", "-", "\\", "|"];
|
|
2026
|
-
return /* @__PURE__ */
|
|
2532
|
+
return /* @__PURE__ */ jsxDEV8(Box8, {
|
|
2027
2533
|
marginTop: 1,
|
|
2028
2534
|
children: [
|
|
2029
|
-
/* @__PURE__ */
|
|
2535
|
+
/* @__PURE__ */ jsxDEV8(Text7, {
|
|
2030
2536
|
color: "cyan",
|
|
2031
2537
|
children: [
|
|
2032
2538
|
spinnerFrames[spinnerFrame],
|
|
@@ -2035,7 +2541,7 @@ function LoadingSpinner({
|
|
|
2035
2541
|
" "
|
|
2036
2542
|
]
|
|
2037
2543
|
}, undefined, true, undefined, this),
|
|
2038
|
-
/* @__PURE__ */
|
|
2544
|
+
/* @__PURE__ */ jsxDEV8(Text7, {
|
|
2039
2545
|
color: "gray",
|
|
2040
2546
|
children: [
|
|
2041
2547
|
"(",
|
|
@@ -2049,11 +2555,259 @@ function LoadingSpinner({
|
|
|
2049
2555
|
}, undefined, true, undefined, this);
|
|
2050
2556
|
}
|
|
2051
2557
|
|
|
2558
|
+
// src/ui/components/command-palette.tsx
|
|
2559
|
+
import { useMemo as useMemo4 } from "react";
|
|
2560
|
+
import { Box as Box9, Text as Text8 } from "ink";
|
|
2561
|
+
import { jsxDEV as jsxDEV9 } from "react/jsx-dev-runtime";
|
|
2562
|
+
function CommandPalette({
|
|
2563
|
+
files,
|
|
2564
|
+
query,
|
|
2565
|
+
selectedIndex,
|
|
2566
|
+
isVisible
|
|
2567
|
+
}) {
|
|
2568
|
+
if (!isVisible) {
|
|
2569
|
+
return null;
|
|
2570
|
+
}
|
|
2571
|
+
const filteredFiles = useMemo4(() => filterFileEntries(files, query), [files, query]);
|
|
2572
|
+
const displayedFiles = filteredFiles.slice(0, 10);
|
|
2573
|
+
return /* @__PURE__ */ jsxDEV9(Box9, {
|
|
2574
|
+
flexDirection: "column",
|
|
2575
|
+
borderStyle: "round",
|
|
2576
|
+
borderColor: "magenta",
|
|
2577
|
+
paddingX: 1,
|
|
2578
|
+
width: process.stdout.columns ? Math.min(80, process.stdout.columns - 4) : 80,
|
|
2579
|
+
children: [
|
|
2580
|
+
/* @__PURE__ */ jsxDEV9(Box9, {
|
|
2581
|
+
marginBottom: 1,
|
|
2582
|
+
justifyContent: "space-between",
|
|
2583
|
+
children: [
|
|
2584
|
+
/* @__PURE__ */ jsxDEV9(Text8, {
|
|
2585
|
+
color: "cyan",
|
|
2586
|
+
bold: true,
|
|
2587
|
+
children: "\uD83D\uDD0D Command Palette / File Search"
|
|
2588
|
+
}, undefined, false, undefined, this),
|
|
2589
|
+
/* @__PURE__ */ jsxDEV9(Text8, {
|
|
2590
|
+
color: "gray",
|
|
2591
|
+
children: [
|
|
2592
|
+
filteredFiles.length,
|
|
2593
|
+
" files found"
|
|
2594
|
+
]
|
|
2595
|
+
}, undefined, true, undefined, this)
|
|
2596
|
+
]
|
|
2597
|
+
}, undefined, true, undefined, this),
|
|
2598
|
+
/* @__PURE__ */ jsxDEV9(Box9, {
|
|
2599
|
+
marginBottom: 1,
|
|
2600
|
+
borderStyle: "single",
|
|
2601
|
+
borderColor: "gray",
|
|
2602
|
+
paddingX: 1,
|
|
2603
|
+
children: [
|
|
2604
|
+
/* @__PURE__ */ jsxDEV9(Text8, {
|
|
2605
|
+
color: "gray",
|
|
2606
|
+
children: "Query: "
|
|
2607
|
+
}, undefined, false, undefined, this),
|
|
2608
|
+
/* @__PURE__ */ jsxDEV9(Text8, {
|
|
2609
|
+
color: "white",
|
|
2610
|
+
bold: true,
|
|
2611
|
+
children: query || "Search files..."
|
|
2612
|
+
}, undefined, false, undefined, this)
|
|
2613
|
+
]
|
|
2614
|
+
}, undefined, true, undefined, this),
|
|
2615
|
+
/* @__PURE__ */ jsxDEV9(Box9, {
|
|
2616
|
+
flexDirection: "column",
|
|
2617
|
+
children: displayedFiles.map((file, index) => /* @__PURE__ */ jsxDEV9(Box9, {
|
|
2618
|
+
paddingLeft: 1,
|
|
2619
|
+
children: [
|
|
2620
|
+
/* @__PURE__ */ jsxDEV9(Box9, {
|
|
2621
|
+
width: 3,
|
|
2622
|
+
children: /* @__PURE__ */ jsxDEV9(Text8, {
|
|
2623
|
+
children: index === selectedIndex ? "❯" : " "
|
|
2624
|
+
}, undefined, false, undefined, this)
|
|
2625
|
+
}, undefined, false, undefined, this),
|
|
2626
|
+
/* @__PURE__ */ jsxDEV9(Text8, {
|
|
2627
|
+
color: index === selectedIndex ? "white" : file.isDirectory ? "blue" : "white",
|
|
2628
|
+
backgroundColor: index === selectedIndex ? "magenta" : undefined,
|
|
2629
|
+
bold: index === selectedIndex,
|
|
2630
|
+
children: [
|
|
2631
|
+
file.isDirectory ? "\uD83D\uDCC1" : "\uD83D\uDCC4",
|
|
2632
|
+
" ",
|
|
2633
|
+
file.path
|
|
2634
|
+
]
|
|
2635
|
+
}, undefined, true, undefined, this)
|
|
2636
|
+
]
|
|
2637
|
+
}, index, true, undefined, this))
|
|
2638
|
+
}, undefined, false, undefined, this),
|
|
2639
|
+
filteredFiles.length === 0 && /* @__PURE__ */ jsxDEV9(Box9, {
|
|
2640
|
+
padding: 1,
|
|
2641
|
+
children: /* @__PURE__ */ jsxDEV9(Text8, {
|
|
2642
|
+
color: "gray",
|
|
2643
|
+
italic: true,
|
|
2644
|
+
children: [
|
|
2645
|
+
'No files found matching "',
|
|
2646
|
+
query,
|
|
2647
|
+
'"'
|
|
2648
|
+
]
|
|
2649
|
+
}, undefined, true, undefined, this)
|
|
2650
|
+
}, undefined, false, undefined, this),
|
|
2651
|
+
/* @__PURE__ */ jsxDEV9(Box9, {
|
|
2652
|
+
marginTop: 1,
|
|
2653
|
+
borderStyle: "single",
|
|
2654
|
+
borderTop: true,
|
|
2655
|
+
borderBottom: false,
|
|
2656
|
+
borderLeft: false,
|
|
2657
|
+
borderRight: false,
|
|
2658
|
+
children: /* @__PURE__ */ jsxDEV9(Text8, {
|
|
2659
|
+
color: "gray",
|
|
2660
|
+
dimColor: true,
|
|
2661
|
+
children: "↑↓ navigate • Enter select • Esc cancel"
|
|
2662
|
+
}, undefined, false, undefined, this)
|
|
2663
|
+
}, undefined, false, undefined, this)
|
|
2664
|
+
]
|
|
2665
|
+
}, undefined, true, undefined, this);
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
// src/ui/components/config-viewer.tsx
|
|
2669
|
+
import { Box as Box10, Text as Text9 } from "ink";
|
|
2670
|
+
import { jsxDEV as jsxDEV10 } from "react/jsx-dev-runtime";
|
|
2671
|
+
function ConfigViewer({ config, isVisible }) {
|
|
2672
|
+
if (!isVisible) {
|
|
2673
|
+
return null;
|
|
2674
|
+
}
|
|
2675
|
+
return /* @__PURE__ */ jsxDEV10(Box10, {
|
|
2676
|
+
flexDirection: "column",
|
|
2677
|
+
borderStyle: "round",
|
|
2678
|
+
borderColor: "magenta",
|
|
2679
|
+
paddingX: 1,
|
|
2680
|
+
width: process.stdout.columns ? Math.min(80, process.stdout.columns - 4) : 80,
|
|
2681
|
+
children: [
|
|
2682
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2683
|
+
marginBottom: 1,
|
|
2684
|
+
children: /* @__PURE__ */ jsxDEV10(Text9, {
|
|
2685
|
+
color: "magenta",
|
|
2686
|
+
bold: true,
|
|
2687
|
+
children: "⚙️ Current Configuration"
|
|
2688
|
+
}, undefined, false, undefined, this)
|
|
2689
|
+
}, undefined, false, undefined, this),
|
|
2690
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2691
|
+
flexDirection: "column",
|
|
2692
|
+
paddingX: 1,
|
|
2693
|
+
children: [
|
|
2694
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2695
|
+
marginBottom: 1,
|
|
2696
|
+
children: [
|
|
2697
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2698
|
+
width: 20,
|
|
2699
|
+
children: /* @__PURE__ */ jsxDEV10(Text9, {
|
|
2700
|
+
color: "cyan",
|
|
2701
|
+
bold: true,
|
|
2702
|
+
children: "Active Provider:"
|
|
2703
|
+
}, undefined, false, undefined, this)
|
|
2704
|
+
}, undefined, false, undefined, this),
|
|
2705
|
+
/* @__PURE__ */ jsxDEV10(Text9, {
|
|
2706
|
+
color: "white",
|
|
2707
|
+
children: config.activeProvider
|
|
2708
|
+
}, undefined, false, undefined, this)
|
|
2709
|
+
]
|
|
2710
|
+
}, undefined, true, undefined, this),
|
|
2711
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2712
|
+
marginBottom: 1,
|
|
2713
|
+
children: [
|
|
2714
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2715
|
+
width: 20,
|
|
2716
|
+
children: /* @__PURE__ */ jsxDEV10(Text9, {
|
|
2717
|
+
color: "cyan",
|
|
2718
|
+
bold: true,
|
|
2719
|
+
children: "API Key:"
|
|
2720
|
+
}, undefined, false, undefined, this)
|
|
2721
|
+
}, undefined, false, undefined, this),
|
|
2722
|
+
/* @__PURE__ */ jsxDEV10(Text9, {
|
|
2723
|
+
color: config.apiKeySet ? "green" : "red",
|
|
2724
|
+
children: config.apiKeySet ? "✓ Set (hidden)" : "✗ Not set"
|
|
2725
|
+
}, undefined, false, undefined, this)
|
|
2726
|
+
]
|
|
2727
|
+
}, undefined, true, undefined, this),
|
|
2728
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2729
|
+
marginBottom: 1,
|
|
2730
|
+
children: [
|
|
2731
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2732
|
+
width: 20,
|
|
2733
|
+
children: /* @__PURE__ */ jsxDEV10(Text9, {
|
|
2734
|
+
color: "cyan",
|
|
2735
|
+
bold: true,
|
|
2736
|
+
children: "Base URL:"
|
|
2737
|
+
}, undefined, false, undefined, this)
|
|
2738
|
+
}, undefined, false, undefined, this),
|
|
2739
|
+
/* @__PURE__ */ jsxDEV10(Text9, {
|
|
2740
|
+
color: "white",
|
|
2741
|
+
children: config.baseUrl || "(default)"
|
|
2742
|
+
}, undefined, false, undefined, this)
|
|
2743
|
+
]
|
|
2744
|
+
}, undefined, true, undefined, this),
|
|
2745
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2746
|
+
marginBottom: 1,
|
|
2747
|
+
children: [
|
|
2748
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2749
|
+
width: 20,
|
|
2750
|
+
children: /* @__PURE__ */ jsxDEV10(Text9, {
|
|
2751
|
+
color: "cyan",
|
|
2752
|
+
bold: true,
|
|
2753
|
+
children: "Model:"
|
|
2754
|
+
}, undefined, false, undefined, this)
|
|
2755
|
+
}, undefined, false, undefined, this),
|
|
2756
|
+
/* @__PURE__ */ jsxDEV10(Text9, {
|
|
2757
|
+
color: "white",
|
|
2758
|
+
children: config.model || "(default)"
|
|
2759
|
+
}, undefined, false, undefined, this)
|
|
2760
|
+
]
|
|
2761
|
+
}, undefined, true, undefined, this),
|
|
2762
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2763
|
+
children: [
|
|
2764
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2765
|
+
width: 20,
|
|
2766
|
+
children: /* @__PURE__ */ jsxDEV10(Text9, {
|
|
2767
|
+
color: "cyan",
|
|
2768
|
+
bold: true,
|
|
2769
|
+
children: "Theme:"
|
|
2770
|
+
}, undefined, false, undefined, this)
|
|
2771
|
+
}, undefined, false, undefined, this),
|
|
2772
|
+
/* @__PURE__ */ jsxDEV10(Text9, {
|
|
2773
|
+
color: "white",
|
|
2774
|
+
children: config.theme
|
|
2775
|
+
}, undefined, false, undefined, this)
|
|
2776
|
+
]
|
|
2777
|
+
}, undefined, true, undefined, this)
|
|
2778
|
+
]
|
|
2779
|
+
}, undefined, true, undefined, this),
|
|
2780
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2781
|
+
marginTop: 1,
|
|
2782
|
+
paddingX: 1,
|
|
2783
|
+
children: /* @__PURE__ */ jsxDEV10(Text9, {
|
|
2784
|
+
color: "gray",
|
|
2785
|
+
italic: true,
|
|
2786
|
+
children: "Use /provider to switch providers • /models to change model"
|
|
2787
|
+
}, undefined, false, undefined, this)
|
|
2788
|
+
}, undefined, false, undefined, this),
|
|
2789
|
+
/* @__PURE__ */ jsxDEV10(Box10, {
|
|
2790
|
+
marginTop: 1,
|
|
2791
|
+
borderStyle: "single",
|
|
2792
|
+
borderTop: true,
|
|
2793
|
+
borderBottom: false,
|
|
2794
|
+
borderLeft: false,
|
|
2795
|
+
borderRight: false,
|
|
2796
|
+
children: /* @__PURE__ */ jsxDEV10(Text9, {
|
|
2797
|
+
color: "gray",
|
|
2798
|
+
dimColor: true,
|
|
2799
|
+
children: "Esc to close"
|
|
2800
|
+
}, undefined, false, undefined, this)
|
|
2801
|
+
}, undefined, false, undefined, this)
|
|
2802
|
+
]
|
|
2803
|
+
}, undefined, true, undefined, this);
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2052
2806
|
// src/ui/utils/markdown-renderer.tsx
|
|
2053
2807
|
import TerminalRenderer from "marked-terminal";
|
|
2054
2808
|
import { marked } from "marked";
|
|
2055
|
-
import { Text as
|
|
2056
|
-
import { jsxDEV as
|
|
2809
|
+
import { Text as Text10 } from "ink";
|
|
2810
|
+
import { jsxDEV as jsxDEV11 } from "react/jsx-dev-runtime";
|
|
2057
2811
|
marked.setOptions({
|
|
2058
2812
|
renderer: new TerminalRenderer
|
|
2059
2813
|
});
|
|
@@ -2061,24 +2815,24 @@ function MarkdownRenderer({ content }) {
|
|
|
2061
2815
|
try {
|
|
2062
2816
|
const result = marked.parse(content);
|
|
2063
2817
|
const rendered = typeof result === "string" ? result : content;
|
|
2064
|
-
return /* @__PURE__ */
|
|
2818
|
+
return /* @__PURE__ */ jsxDEV11(Text10, {
|
|
2065
2819
|
children: rendered
|
|
2066
2820
|
}, undefined, false, undefined, this);
|
|
2067
2821
|
} catch (error) {
|
|
2068
2822
|
console.error("Markdown rendering error:", error);
|
|
2069
|
-
return /* @__PURE__ */
|
|
2823
|
+
return /* @__PURE__ */ jsxDEV11(Text10, {
|
|
2070
2824
|
children: content
|
|
2071
2825
|
}, undefined, false, undefined, this);
|
|
2072
2826
|
}
|
|
2073
2827
|
}
|
|
2074
2828
|
|
|
2075
2829
|
// src/ui/components/chat-history.tsx
|
|
2076
|
-
import { Box as
|
|
2077
|
-
import
|
|
2078
|
-
import { jsxDEV as
|
|
2079
|
-
var MemoizedChatEntry =
|
|
2830
|
+
import { Box as Box11, Text as Text11 } from "ink";
|
|
2831
|
+
import React3 from "react";
|
|
2832
|
+
import { jsxDEV as jsxDEV12 } from "react/jsx-dev-runtime";
|
|
2833
|
+
var MemoizedChatEntry = React3.memo(({ entry, index }) => {
|
|
2080
2834
|
const renderDiff = (diffContent, filename) => {
|
|
2081
|
-
return /* @__PURE__ */
|
|
2835
|
+
return /* @__PURE__ */ jsxDEV12(DiffRenderer, {
|
|
2082
2836
|
diffContent,
|
|
2083
2837
|
filename,
|
|
2084
2838
|
terminalWidth: 80
|
|
@@ -2101,7 +2855,7 @@ var MemoizedChatEntry = React4.memo(({ entry, index }) => {
|
|
|
2101
2855
|
}
|
|
2102
2856
|
return lines.map((line, index2) => {
|
|
2103
2857
|
const displayContent = line.substring(baseIndentation);
|
|
2104
|
-
return /* @__PURE__ */
|
|
2858
|
+
return /* @__PURE__ */ jsxDEV12(Text11, {
|
|
2105
2859
|
color: "gray",
|
|
2106
2860
|
children: displayContent
|
|
2107
2861
|
}, index2, false, undefined, this);
|
|
@@ -2109,11 +2863,11 @@ var MemoizedChatEntry = React4.memo(({ entry, index }) => {
|
|
|
2109
2863
|
};
|
|
2110
2864
|
switch (entry.type) {
|
|
2111
2865
|
case "user":
|
|
2112
|
-
return /* @__PURE__ */
|
|
2866
|
+
return /* @__PURE__ */ jsxDEV12(Box11, {
|
|
2113
2867
|
flexDirection: "column",
|
|
2114
2868
|
marginTop: 1,
|
|
2115
|
-
children: /* @__PURE__ */
|
|
2116
|
-
children: /* @__PURE__ */
|
|
2869
|
+
children: /* @__PURE__ */ jsxDEV12(Box11, {
|
|
2870
|
+
children: /* @__PURE__ */ jsxDEV12(Text11, {
|
|
2117
2871
|
color: "gray",
|
|
2118
2872
|
children: [
|
|
2119
2873
|
">",
|
|
@@ -2124,28 +2878,28 @@ var MemoizedChatEntry = React4.memo(({ entry, index }) => {
|
|
|
2124
2878
|
}, undefined, false, undefined, this)
|
|
2125
2879
|
}, index, false, undefined, this);
|
|
2126
2880
|
case "assistant":
|
|
2127
|
-
return /* @__PURE__ */
|
|
2881
|
+
return /* @__PURE__ */ jsxDEV12(Box11, {
|
|
2128
2882
|
flexDirection: "column",
|
|
2129
2883
|
marginTop: 1,
|
|
2130
|
-
children: /* @__PURE__ */
|
|
2884
|
+
children: /* @__PURE__ */ jsxDEV12(Box11, {
|
|
2131
2885
|
flexDirection: "row",
|
|
2132
2886
|
alignItems: "flex-start",
|
|
2133
2887
|
children: [
|
|
2134
|
-
/* @__PURE__ */
|
|
2888
|
+
/* @__PURE__ */ jsxDEV12(Text11, {
|
|
2135
2889
|
color: "white",
|
|
2136
2890
|
children: "⏺ "
|
|
2137
2891
|
}, undefined, false, undefined, this),
|
|
2138
|
-
/* @__PURE__ */
|
|
2892
|
+
/* @__PURE__ */ jsxDEV12(Box11, {
|
|
2139
2893
|
flexDirection: "column",
|
|
2140
2894
|
flexGrow: 1,
|
|
2141
2895
|
children: [
|
|
2142
|
-
entry.toolCalls ? /* @__PURE__ */
|
|
2896
|
+
entry.toolCalls ? /* @__PURE__ */ jsxDEV12(Text11, {
|
|
2143
2897
|
color: "white",
|
|
2144
2898
|
children: entry.content.trim()
|
|
2145
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */
|
|
2899
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV12(MarkdownRenderer, {
|
|
2146
2900
|
content: entry.content.trim()
|
|
2147
2901
|
}, undefined, false, undefined, this),
|
|
2148
|
-
entry.isStreaming && /* @__PURE__ */
|
|
2902
|
+
entry.isStreaming && /* @__PURE__ */ jsxDEV12(Text11, {
|
|
2149
2903
|
color: "cyan",
|
|
2150
2904
|
children: "█"
|
|
2151
2905
|
}, undefined, false, undefined, this)
|
|
@@ -2219,17 +2973,17 @@ var MemoizedChatEntry = React4.memo(({ entry, index }) => {
|
|
|
2219
2973
|
};
|
|
2220
2974
|
const shouldShowDiff = entry.toolCall?.function?.name === "str_replace_editor" && entry.toolResult?.success && entry.content.includes("Updated") && entry.content.includes("---") && entry.content.includes("+++");
|
|
2221
2975
|
const shouldShowFileContent = (entry.toolCall?.function?.name === "view_file" || entry.toolCall?.function?.name === "create_file") && entry.toolResult?.success && !shouldShowDiff;
|
|
2222
|
-
return /* @__PURE__ */
|
|
2976
|
+
return /* @__PURE__ */ jsxDEV12(Box11, {
|
|
2223
2977
|
flexDirection: "column",
|
|
2224
2978
|
marginTop: 1,
|
|
2225
2979
|
children: [
|
|
2226
|
-
/* @__PURE__ */
|
|
2980
|
+
/* @__PURE__ */ jsxDEV12(Box11, {
|
|
2227
2981
|
children: [
|
|
2228
|
-
/* @__PURE__ */
|
|
2982
|
+
/* @__PURE__ */ jsxDEV12(Text11, {
|
|
2229
2983
|
color: "magenta",
|
|
2230
2984
|
children: "⏺"
|
|
2231
2985
|
}, undefined, false, undefined, this),
|
|
2232
|
-
/* @__PURE__ */
|
|
2986
|
+
/* @__PURE__ */ jsxDEV12(Text11, {
|
|
2233
2987
|
color: "white",
|
|
2234
2988
|
children: [
|
|
2235
2989
|
" ",
|
|
@@ -2238,33 +2992,33 @@ var MemoizedChatEntry = React4.memo(({ entry, index }) => {
|
|
|
2238
2992
|
}, undefined, true, undefined, this)
|
|
2239
2993
|
]
|
|
2240
2994
|
}, undefined, true, undefined, this),
|
|
2241
|
-
/* @__PURE__ */
|
|
2995
|
+
/* @__PURE__ */ jsxDEV12(Box11, {
|
|
2242
2996
|
marginLeft: 2,
|
|
2243
2997
|
flexDirection: "column",
|
|
2244
|
-
children: isExecuting ? /* @__PURE__ */
|
|
2998
|
+
children: isExecuting ? /* @__PURE__ */ jsxDEV12(Text11, {
|
|
2245
2999
|
color: "cyan",
|
|
2246
3000
|
children: "⎿ Executing..."
|
|
2247
|
-
}, undefined, false, undefined, this) : shouldShowFileContent ? /* @__PURE__ */
|
|
3001
|
+
}, undefined, false, undefined, this) : shouldShowFileContent ? /* @__PURE__ */ jsxDEV12(Box11, {
|
|
2248
3002
|
flexDirection: "column",
|
|
2249
3003
|
children: [
|
|
2250
|
-
/* @__PURE__ */
|
|
3004
|
+
/* @__PURE__ */ jsxDEV12(Text11, {
|
|
2251
3005
|
color: "gray",
|
|
2252
3006
|
children: "⎿ File contents:"
|
|
2253
3007
|
}, undefined, false, undefined, this),
|
|
2254
|
-
/* @__PURE__ */
|
|
3008
|
+
/* @__PURE__ */ jsxDEV12(Box11, {
|
|
2255
3009
|
marginLeft: 2,
|
|
2256
3010
|
flexDirection: "column",
|
|
2257
3011
|
children: renderFileContent(entry.content)
|
|
2258
3012
|
}, undefined, false, undefined, this)
|
|
2259
3013
|
]
|
|
2260
|
-
}, undefined, true, undefined, this) : shouldShowDiff ? /* @__PURE__ */
|
|
3014
|
+
}, undefined, true, undefined, this) : shouldShowDiff ? /* @__PURE__ */ jsxDEV12(Text11, {
|
|
2261
3015
|
color: "gray",
|
|
2262
3016
|
children: [
|
|
2263
3017
|
"⎿ ",
|
|
2264
3018
|
entry.content.split(`
|
|
2265
3019
|
`)[0]
|
|
2266
3020
|
]
|
|
2267
|
-
}, undefined, true, undefined, this) : /* @__PURE__ */
|
|
3021
|
+
}, undefined, true, undefined, this) : /* @__PURE__ */ jsxDEV12(Text11, {
|
|
2268
3022
|
color: "gray",
|
|
2269
3023
|
children: [
|
|
2270
3024
|
"⎿ ",
|
|
@@ -2272,7 +3026,7 @@ var MemoizedChatEntry = React4.memo(({ entry, index }) => {
|
|
|
2272
3026
|
]
|
|
2273
3027
|
}, undefined, true, undefined, this)
|
|
2274
3028
|
}, undefined, false, undefined, this),
|
|
2275
|
-
shouldShowDiff && !isExecuting && /* @__PURE__ */
|
|
3029
|
+
shouldShowDiff && !isExecuting && /* @__PURE__ */ jsxDEV12(Box11, {
|
|
2276
3030
|
marginLeft: 4,
|
|
2277
3031
|
flexDirection: "column",
|
|
2278
3032
|
children: renderDiff(entry.content, filePath)
|
|
@@ -2289,9 +3043,9 @@ function ChatHistory({
|
|
|
2289
3043
|
isConfirmationActive = false
|
|
2290
3044
|
}) {
|
|
2291
3045
|
const filteredEntries = isConfirmationActive ? entries.filter((entry) => !(entry.type === "tool_call" && entry.content === "Executing...")) : entries;
|
|
2292
|
-
return /* @__PURE__ */
|
|
3046
|
+
return /* @__PURE__ */ jsxDEV12(Box11, {
|
|
2293
3047
|
flexDirection: "column",
|
|
2294
|
-
children: filteredEntries.slice(-20).map((entry, index) => /* @__PURE__ */
|
|
3048
|
+
children: filteredEntries.slice(-20).map((entry, index) => /* @__PURE__ */ jsxDEV12(MemoizedChatEntry, {
|
|
2295
3049
|
entry,
|
|
2296
3050
|
index
|
|
2297
3051
|
}, `${entry.timestamp.getTime()}-${index}`, false, undefined, this))
|
|
@@ -2440,8 +3194,8 @@ class ConfirmationTool {
|
|
|
2440
3194
|
}
|
|
2441
3195
|
}
|
|
2442
3196
|
// src/tools/morph-editor.ts
|
|
2443
|
-
import * as
|
|
2444
|
-
import
|
|
3197
|
+
import * as path3 from "path";
|
|
3198
|
+
import fs4 from "fs-extra";
|
|
2445
3199
|
import axios from "axios";
|
|
2446
3200
|
|
|
2447
3201
|
class MorphEditorTool {
|
|
@@ -2456,8 +3210,8 @@ class MorphEditorTool {
|
|
|
2456
3210
|
}
|
|
2457
3211
|
async editFile(targetFile, instructions, codeEdit) {
|
|
2458
3212
|
try {
|
|
2459
|
-
const resolvedPath =
|
|
2460
|
-
if (!await
|
|
3213
|
+
const resolvedPath = path3.resolve(targetFile);
|
|
3214
|
+
if (!await fs4.pathExists(resolvedPath)) {
|
|
2461
3215
|
return {
|
|
2462
3216
|
success: false,
|
|
2463
3217
|
error: `File not found: ${targetFile}`
|
|
@@ -2469,7 +3223,7 @@ class MorphEditorTool {
|
|
|
2469
3223
|
error: "MORPH_API_KEY not configured. Please set your Morph API key."
|
|
2470
3224
|
};
|
|
2471
3225
|
}
|
|
2472
|
-
const initialCode = await
|
|
3226
|
+
const initialCode = await fs4.readFile(resolvedPath, "utf-8");
|
|
2473
3227
|
const sessionFlags = this.confirmationService.getSessionFlags();
|
|
2474
3228
|
if (!sessionFlags.fileOperations && !sessionFlags.allOperations) {
|
|
2475
3229
|
const confirmationResult = await this.confirmationService.requestConfirmation({
|
|
@@ -2489,7 +3243,7 @@ ${codeEdit}`
|
|
|
2489
3243
|
}
|
|
2490
3244
|
}
|
|
2491
3245
|
const mergedCode = await this.callMorphApply(instructions, initialCode, codeEdit);
|
|
2492
|
-
await
|
|
3246
|
+
await fs4.writeFile(resolvedPath, mergedCode, "utf-8");
|
|
2493
3247
|
const oldLines = initialCode.split(`
|
|
2494
3248
|
`);
|
|
2495
3249
|
const newLines = mergedCode.split(`
|
|
@@ -2672,11 +3426,11 @@ ${codeEdit}`
|
|
|
2672
3426
|
}
|
|
2673
3427
|
async view(filePath, viewRange) {
|
|
2674
3428
|
try {
|
|
2675
|
-
const resolvedPath =
|
|
2676
|
-
if (await
|
|
2677
|
-
const stats = await
|
|
3429
|
+
const resolvedPath = path3.resolve(filePath);
|
|
3430
|
+
if (await fs4.pathExists(resolvedPath)) {
|
|
3431
|
+
const stats = await fs4.stat(resolvedPath);
|
|
2678
3432
|
if (stats.isDirectory()) {
|
|
2679
|
-
const files = await
|
|
3433
|
+
const files = await fs4.readdir(resolvedPath);
|
|
2680
3434
|
return {
|
|
2681
3435
|
success: true,
|
|
2682
3436
|
output: `Directory contents of ${filePath}:
|
|
@@ -2684,7 +3438,7 @@ ${files.join(`
|
|
|
2684
3438
|
`)}`
|
|
2685
3439
|
};
|
|
2686
3440
|
}
|
|
2687
|
-
const content = await
|
|
3441
|
+
const content = await fs4.readFile(resolvedPath, "utf-8");
|
|
2688
3442
|
const lines = content.split(`
|
|
2689
3443
|
`);
|
|
2690
3444
|
if (viewRange) {
|
|
@@ -2730,8 +3484,8 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
2730
3484
|
}
|
|
2731
3485
|
}
|
|
2732
3486
|
// src/tools/project-map.ts
|
|
2733
|
-
import * as
|
|
2734
|
-
import
|
|
3487
|
+
import * as path4 from "path";
|
|
3488
|
+
import fs5 from "fs-extra";
|
|
2735
3489
|
|
|
2736
3490
|
class ProjectMapTool {
|
|
2737
3491
|
currentDirectory = process.cwd();
|
|
@@ -2765,7 +3519,7 @@ Important Files:
|
|
|
2765
3519
|
}
|
|
2766
3520
|
let result = "";
|
|
2767
3521
|
try {
|
|
2768
|
-
const entries = await
|
|
3522
|
+
const entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
2769
3523
|
const sortedEntries = entries.sort((a, b) => {
|
|
2770
3524
|
if (a.isDirectory() && !b.isDirectory()) {
|
|
2771
3525
|
return -1;
|
|
@@ -2793,7 +3547,7 @@ Important Files:
|
|
|
2793
3547
|
if (entry.isDirectory()) {
|
|
2794
3548
|
result += `${indent}\uD83D\uDCC1 ${entry.name}/
|
|
2795
3549
|
`;
|
|
2796
|
-
result += await this.generateTree(
|
|
3550
|
+
result += await this.generateTree(path4.join(dir, entry.name), maxDepth, currentDepth + 1);
|
|
2797
3551
|
} else {
|
|
2798
3552
|
result += `${indent}\uD83D\uDCC4 ${entry.name}
|
|
2799
3553
|
`;
|
|
@@ -2815,8 +3569,8 @@ Important Files:
|
|
|
2815
3569
|
];
|
|
2816
3570
|
const found = [];
|
|
2817
3571
|
for (const pattern of importantPatterns) {
|
|
2818
|
-
const fullPath =
|
|
2819
|
-
if (await
|
|
3572
|
+
const fullPath = path4.join(this.currentDirectory, pattern);
|
|
3573
|
+
if (await fs5.pathExists(fullPath)) {
|
|
2820
3574
|
found.push(pattern);
|
|
2821
3575
|
}
|
|
2822
3576
|
}
|
|
@@ -2828,8 +3582,8 @@ Important Files:
|
|
|
2828
3582
|
}
|
|
2829
3583
|
// src/tools/search.ts
|
|
2830
3584
|
import { spawn } from "child_process";
|
|
2831
|
-
import * as
|
|
2832
|
-
import
|
|
3585
|
+
import * as path5 from "path";
|
|
3586
|
+
import fs6 from "fs-extra";
|
|
2833
3587
|
|
|
2834
3588
|
class SearchTool {
|
|
2835
3589
|
confirmationService = ConfirmationService.getInstance();
|
|
@@ -2969,13 +3723,13 @@ class SearchTool {
|
|
|
2969
3723
|
return;
|
|
2970
3724
|
}
|
|
2971
3725
|
try {
|
|
2972
|
-
const entries = await
|
|
3726
|
+
const entries = await fs6.readdir(dir, { withFileTypes: true });
|
|
2973
3727
|
for (const entry of entries) {
|
|
2974
3728
|
if (files.length >= maxResults) {
|
|
2975
3729
|
break;
|
|
2976
3730
|
}
|
|
2977
|
-
const fullPath =
|
|
2978
|
-
const relativePath =
|
|
3731
|
+
const fullPath = path5.join(dir, entry.name);
|
|
3732
|
+
const relativePath = path5.relative(this.currentDirectory, fullPath);
|
|
2979
3733
|
if (!options.includeHidden && entry.name.startsWith(".")) {
|
|
2980
3734
|
continue;
|
|
2981
3735
|
}
|
|
@@ -3074,19 +3828,19 @@ class SearchTool {
|
|
|
3074
3828
|
}
|
|
3075
3829
|
// src/tools/text-editor.ts
|
|
3076
3830
|
import { writeFile as writeFilePromise } from "fs/promises";
|
|
3077
|
-
import * as
|
|
3078
|
-
import
|
|
3831
|
+
import * as path6 from "path";
|
|
3832
|
+
import fs7 from "fs-extra";
|
|
3079
3833
|
|
|
3080
3834
|
class TextEditorTool {
|
|
3081
3835
|
editHistory = [];
|
|
3082
3836
|
confirmationService = ConfirmationService.getInstance();
|
|
3083
3837
|
async view(filePath, viewRange) {
|
|
3084
3838
|
try {
|
|
3085
|
-
const resolvedPath =
|
|
3086
|
-
if (await
|
|
3087
|
-
const stats = await
|
|
3839
|
+
const resolvedPath = path6.resolve(filePath);
|
|
3840
|
+
if (await fs7.pathExists(resolvedPath)) {
|
|
3841
|
+
const stats = await fs7.stat(resolvedPath);
|
|
3088
3842
|
if (stats.isDirectory()) {
|
|
3089
|
-
const files = await
|
|
3843
|
+
const files = await fs7.readdir(resolvedPath);
|
|
3090
3844
|
return {
|
|
3091
3845
|
success: true,
|
|
3092
3846
|
output: `Directory contents of ${filePath}:
|
|
@@ -3094,7 +3848,7 @@ ${files.join(`
|
|
|
3094
3848
|
`)}`
|
|
3095
3849
|
};
|
|
3096
3850
|
}
|
|
3097
|
-
const content = await
|
|
3851
|
+
const content = await fs7.readFile(resolvedPath, "utf-8");
|
|
3098
3852
|
const lines = content.split(`
|
|
3099
3853
|
`);
|
|
3100
3854
|
if (viewRange) {
|
|
@@ -3134,14 +3888,14 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
3134
3888
|
}
|
|
3135
3889
|
async strReplace(filePath, oldStr, newStr, replaceAll = false) {
|
|
3136
3890
|
try {
|
|
3137
|
-
const resolvedPath =
|
|
3138
|
-
if (!await
|
|
3891
|
+
const resolvedPath = path6.resolve(filePath);
|
|
3892
|
+
if (!await fs7.pathExists(resolvedPath)) {
|
|
3139
3893
|
return {
|
|
3140
3894
|
success: false,
|
|
3141
3895
|
error: `File not found: ${filePath}`
|
|
3142
3896
|
};
|
|
3143
3897
|
}
|
|
3144
|
-
const content = await
|
|
3898
|
+
const content = await fs7.readFile(resolvedPath, "utf-8");
|
|
3145
3899
|
if (!content.includes(oldStr)) {
|
|
3146
3900
|
if (oldStr.includes(`
|
|
3147
3901
|
`)) {
|
|
@@ -3209,7 +3963,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
3209
3963
|
}
|
|
3210
3964
|
async create(filePath, content) {
|
|
3211
3965
|
try {
|
|
3212
|
-
const resolvedPath =
|
|
3966
|
+
const resolvedPath = path6.resolve(filePath);
|
|
3213
3967
|
const sessionFlags = this.confirmationService.getSessionFlags();
|
|
3214
3968
|
if (!sessionFlags.fileOperations && !sessionFlags.allOperations) {
|
|
3215
3969
|
const contentLines = content.split(`
|
|
@@ -3235,8 +3989,8 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
3235
3989
|
};
|
|
3236
3990
|
}
|
|
3237
3991
|
}
|
|
3238
|
-
const dir =
|
|
3239
|
-
await
|
|
3992
|
+
const dir = path6.dirname(resolvedPath);
|
|
3993
|
+
await fs7.ensureDir(dir);
|
|
3240
3994
|
await writeFilePromise(resolvedPath, content, "utf-8");
|
|
3241
3995
|
this.editHistory.push({
|
|
3242
3996
|
command: "create",
|
|
@@ -3260,14 +4014,14 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
3260
4014
|
}
|
|
3261
4015
|
async replaceLines(filePath, startLine, endLine, newContent) {
|
|
3262
4016
|
try {
|
|
3263
|
-
const resolvedPath =
|
|
3264
|
-
if (!await
|
|
4017
|
+
const resolvedPath = path6.resolve(filePath);
|
|
4018
|
+
if (!await fs7.pathExists(resolvedPath)) {
|
|
3265
4019
|
return {
|
|
3266
4020
|
success: false,
|
|
3267
4021
|
error: `File not found: ${filePath}`
|
|
3268
4022
|
};
|
|
3269
4023
|
}
|
|
3270
|
-
const fileContent = await
|
|
4024
|
+
const fileContent = await fs7.readFile(resolvedPath, "utf-8");
|
|
3271
4025
|
const lines = fileContent.split(`
|
|
3272
4026
|
`);
|
|
3273
4027
|
if (startLine < 1 || startLine > lines.length) {
|
|
@@ -3330,14 +4084,14 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
3330
4084
|
}
|
|
3331
4085
|
async insert(filePath, insertLine, content) {
|
|
3332
4086
|
try {
|
|
3333
|
-
const resolvedPath =
|
|
3334
|
-
if (!await
|
|
4087
|
+
const resolvedPath = path6.resolve(filePath);
|
|
4088
|
+
if (!await fs7.pathExists(resolvedPath)) {
|
|
3335
4089
|
return {
|
|
3336
4090
|
success: false,
|
|
3337
4091
|
error: `File not found: ${filePath}`
|
|
3338
4092
|
};
|
|
3339
4093
|
}
|
|
3340
|
-
const fileContent = await
|
|
4094
|
+
const fileContent = await fs7.readFile(resolvedPath, "utf-8");
|
|
3341
4095
|
const lines = fileContent.split(`
|
|
3342
4096
|
`);
|
|
3343
4097
|
lines.splice(insertLine - 1, 0, content);
|
|
@@ -3373,19 +4127,19 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
3373
4127
|
switch (lastEdit.command) {
|
|
3374
4128
|
case "str_replace":
|
|
3375
4129
|
if (lastEdit.path && lastEdit.old_str && lastEdit.new_str) {
|
|
3376
|
-
const content = await
|
|
4130
|
+
const content = await fs7.readFile(lastEdit.path, "utf-8");
|
|
3377
4131
|
const revertedContent = content.replace(lastEdit.new_str, lastEdit.old_str);
|
|
3378
4132
|
await writeFilePromise(lastEdit.path, revertedContent, "utf-8");
|
|
3379
4133
|
}
|
|
3380
4134
|
break;
|
|
3381
4135
|
case "create":
|
|
3382
4136
|
if (lastEdit.path) {
|
|
3383
|
-
await
|
|
4137
|
+
await fs7.remove(lastEdit.path);
|
|
3384
4138
|
}
|
|
3385
4139
|
break;
|
|
3386
4140
|
case "insert":
|
|
3387
4141
|
if (lastEdit.path && lastEdit.insert_line) {
|
|
3388
|
-
const content = await
|
|
4142
|
+
const content = await fs7.readFile(lastEdit.path, "utf-8");
|
|
3389
4143
|
const lines = content.split(`
|
|
3390
4144
|
`);
|
|
3391
4145
|
lines.splice(lastEdit.insert_line - 1, 1);
|
|
@@ -4444,19 +5198,19 @@ async function getAllSuperAgentTools() {
|
|
|
4444
5198
|
}
|
|
4445
5199
|
|
|
4446
5200
|
// src/utils/custom-instructions.ts
|
|
4447
|
-
import * as
|
|
5201
|
+
import * as path7 from "path";
|
|
4448
5202
|
import * as os2 from "os";
|
|
4449
|
-
import * as
|
|
5203
|
+
import * as fs8 from "fs";
|
|
4450
5204
|
function loadCustomInstructions(workingDirectory = process.cwd()) {
|
|
4451
5205
|
try {
|
|
4452
|
-
let instructionsPath =
|
|
4453
|
-
if (
|
|
4454
|
-
const customInstructions =
|
|
5206
|
+
let instructionsPath = path7.join(workingDirectory, ".super-agent", "SUPER_AGENT.md");
|
|
5207
|
+
if (fs8.existsSync(instructionsPath)) {
|
|
5208
|
+
const customInstructions = fs8.readFileSync(instructionsPath, "utf-8");
|
|
4455
5209
|
return customInstructions.trim();
|
|
4456
5210
|
}
|
|
4457
|
-
instructionsPath =
|
|
4458
|
-
if (
|
|
4459
|
-
const customInstructions =
|
|
5211
|
+
instructionsPath = path7.join(os2.homedir(), ".super-agent", "SUPER_AGENT.md");
|
|
5212
|
+
if (fs8.existsSync(instructionsPath)) {
|
|
5213
|
+
const customInstructions = fs8.readFileSync(instructionsPath, "utf-8");
|
|
4460
5214
|
return customInstructions.trim();
|
|
4461
5215
|
}
|
|
4462
5216
|
return null;
|
|
@@ -5371,9 +6125,9 @@ Maximum tool execution rounds reached. Stopping to prevent infinite loops.`
|
|
|
5371
6125
|
}
|
|
5372
6126
|
|
|
5373
6127
|
// src/ui/components/api-key-input.tsx
|
|
5374
|
-
import { Box as
|
|
6128
|
+
import { Box as Box12, Text as Text12, useApp, useInput as useInput3 } from "ink";
|
|
5375
6129
|
import { useState as useState6 } from "react";
|
|
5376
|
-
import { jsxDEV as
|
|
6130
|
+
import { jsxDEV as jsxDEV13 } from "react/jsx-dev-runtime";
|
|
5377
6131
|
function ApiKeyInput({ onApiKeySet }) {
|
|
5378
6132
|
const [input, setInput] = useState6("");
|
|
5379
6133
|
const [error, setError] = useState6("");
|
|
@@ -5436,40 +6190,40 @@ function ApiKeyInput({ onApiKeySet }) {
|
|
|
5436
6190
|
}
|
|
5437
6191
|
};
|
|
5438
6192
|
const displayText = input.length > 0 ? isSubmitting ? "*".repeat(input.length) : "*".repeat(input.length) + "█" : isSubmitting ? " " : "█";
|
|
5439
|
-
return /* @__PURE__ */
|
|
6193
|
+
return /* @__PURE__ */ jsxDEV13(Box12, {
|
|
5440
6194
|
flexDirection: "column",
|
|
5441
6195
|
paddingX: 2,
|
|
5442
6196
|
paddingY: 1,
|
|
5443
6197
|
children: [
|
|
5444
|
-
/* @__PURE__ */
|
|
6198
|
+
/* @__PURE__ */ jsxDEV13(Text12, {
|
|
5445
6199
|
color: "yellow",
|
|
5446
6200
|
children: "\uD83D\uDD11 Super Agent API Key Required"
|
|
5447
6201
|
}, undefined, false, undefined, this),
|
|
5448
|
-
/* @__PURE__ */
|
|
6202
|
+
/* @__PURE__ */ jsxDEV13(Box12, {
|
|
5449
6203
|
marginBottom: 1,
|
|
5450
|
-
children: /* @__PURE__ */
|
|
6204
|
+
children: /* @__PURE__ */ jsxDEV13(Text12, {
|
|
5451
6205
|
color: "gray",
|
|
5452
6206
|
children: "Please enter your Super Agent API key to continue:"
|
|
5453
6207
|
}, undefined, false, undefined, this)
|
|
5454
6208
|
}, undefined, false, undefined, this),
|
|
5455
|
-
/* @__PURE__ */
|
|
6209
|
+
/* @__PURE__ */ jsxDEV13(Box12, {
|
|
5456
6210
|
borderStyle: "round",
|
|
5457
6211
|
borderColor: "blue",
|
|
5458
6212
|
paddingX: 1,
|
|
5459
6213
|
marginBottom: 1,
|
|
5460
6214
|
children: [
|
|
5461
|
-
/* @__PURE__ */
|
|
6215
|
+
/* @__PURE__ */ jsxDEV13(Text12, {
|
|
5462
6216
|
color: "gray",
|
|
5463
6217
|
children: "❯ "
|
|
5464
6218
|
}, undefined, false, undefined, this),
|
|
5465
|
-
/* @__PURE__ */
|
|
6219
|
+
/* @__PURE__ */ jsxDEV13(Text12, {
|
|
5466
6220
|
children: displayText
|
|
5467
6221
|
}, undefined, false, undefined, this)
|
|
5468
6222
|
]
|
|
5469
6223
|
}, undefined, true, undefined, this),
|
|
5470
|
-
error ? /* @__PURE__ */
|
|
6224
|
+
error ? /* @__PURE__ */ jsxDEV13(Box12, {
|
|
5471
6225
|
marginBottom: 1,
|
|
5472
|
-
children: /* @__PURE__ */
|
|
6226
|
+
children: /* @__PURE__ */ jsxDEV13(Text12, {
|
|
5473
6227
|
color: "red",
|
|
5474
6228
|
children: [
|
|
5475
6229
|
"❌ ",
|
|
@@ -5477,30 +6231,30 @@ function ApiKeyInput({ onApiKeySet }) {
|
|
|
5477
6231
|
]
|
|
5478
6232
|
}, undefined, true, undefined, this)
|
|
5479
6233
|
}, undefined, false, undefined, this) : null,
|
|
5480
|
-
/* @__PURE__ */
|
|
6234
|
+
/* @__PURE__ */ jsxDEV13(Box12, {
|
|
5481
6235
|
flexDirection: "column",
|
|
5482
6236
|
marginTop: 1,
|
|
5483
6237
|
children: [
|
|
5484
|
-
/* @__PURE__ */
|
|
6238
|
+
/* @__PURE__ */ jsxDEV13(Text12, {
|
|
5485
6239
|
color: "gray",
|
|
5486
6240
|
dimColor: true,
|
|
5487
6241
|
children: "• Press Enter to submit"
|
|
5488
6242
|
}, undefined, false, undefined, this),
|
|
5489
|
-
/* @__PURE__ */
|
|
6243
|
+
/* @__PURE__ */ jsxDEV13(Text12, {
|
|
5490
6244
|
color: "gray",
|
|
5491
6245
|
dimColor: true,
|
|
5492
6246
|
children: "• Press Ctrl+C to exit"
|
|
5493
6247
|
}, undefined, false, undefined, this),
|
|
5494
|
-
/* @__PURE__ */
|
|
6248
|
+
/* @__PURE__ */ jsxDEV13(Text12, {
|
|
5495
6249
|
color: "gray",
|
|
5496
6250
|
dimColor: true,
|
|
5497
6251
|
children: "Note: API key will be saved to ~/.super-agent/settings.json"
|
|
5498
6252
|
}, undefined, false, undefined, this)
|
|
5499
6253
|
]
|
|
5500
6254
|
}, undefined, true, undefined, this),
|
|
5501
|
-
isSubmitting ? /* @__PURE__ */
|
|
6255
|
+
isSubmitting ? /* @__PURE__ */ jsxDEV13(Box12, {
|
|
5502
6256
|
marginTop: 1,
|
|
5503
|
-
children: /* @__PURE__ */
|
|
6257
|
+
children: /* @__PURE__ */ jsxDEV13(Text12, {
|
|
5504
6258
|
color: "yellow",
|
|
5505
6259
|
children: "\uD83D\uDD04 Validating API key..."
|
|
5506
6260
|
}, undefined, false, undefined, this)
|
|
@@ -5511,8 +6265,8 @@ function ApiKeyInput({ onApiKeySet }) {
|
|
|
5511
6265
|
|
|
5512
6266
|
// src/ui/components/mcp-status.tsx
|
|
5513
6267
|
import { useEffect as useEffect3, useState as useState7 } from "react";
|
|
5514
|
-
import { Box as
|
|
5515
|
-
import { jsxDEV as
|
|
6268
|
+
import { Box as Box13, Text as Text13 } from "ink";
|
|
6269
|
+
import { jsxDEV as jsxDEV14 } from "react/jsx-dev-runtime";
|
|
5516
6270
|
function MCPStatus({}) {
|
|
5517
6271
|
const [connectedServers, setConnectedServers] = useState7([]);
|
|
5518
6272
|
const [availableTools, setAvailableTools] = useState7([]);
|
|
@@ -5539,9 +6293,9 @@ function MCPStatus({}) {
|
|
|
5539
6293
|
if (connectedServers.length === 0) {
|
|
5540
6294
|
return null;
|
|
5541
6295
|
}
|
|
5542
|
-
return /* @__PURE__ */
|
|
6296
|
+
return /* @__PURE__ */ jsxDEV14(Box13, {
|
|
5543
6297
|
marginLeft: 1,
|
|
5544
|
-
children: /* @__PURE__ */
|
|
6298
|
+
children: /* @__PURE__ */ jsxDEV14(Text13, {
|
|
5545
6299
|
color: "green",
|
|
5546
6300
|
children: [
|
|
5547
6301
|
"⚒ mcps: ",
|
|
@@ -5553,8 +6307,8 @@ function MCPStatus({}) {
|
|
|
5553
6307
|
}
|
|
5554
6308
|
|
|
5555
6309
|
// src/ui/components/chat-input.tsx
|
|
5556
|
-
import { Box as
|
|
5557
|
-
import { jsxDEV as
|
|
6310
|
+
import { Box as Box14, Text as Text14 } from "ink";
|
|
6311
|
+
import { jsxDEV as jsxDEV15, Fragment as Fragment3 } from "react/jsx-dev-runtime";
|
|
5558
6312
|
function ChatInput({
|
|
5559
6313
|
input,
|
|
5560
6314
|
cursorPosition,
|
|
@@ -5583,7 +6337,7 @@ function ChatInput({
|
|
|
5583
6337
|
const placeholderText = "Ask me anything...";
|
|
5584
6338
|
const isPlaceholder = !input;
|
|
5585
6339
|
if (isMultiline) {
|
|
5586
|
-
return /* @__PURE__ */
|
|
6340
|
+
return /* @__PURE__ */ jsxDEV15(Box14, {
|
|
5587
6341
|
borderStyle: "round",
|
|
5588
6342
|
borderColor,
|
|
5589
6343
|
paddingY: 0,
|
|
@@ -5595,19 +6349,19 @@ function ChatInput({
|
|
|
5595
6349
|
const beforeCursorInLine = line.slice(0, currentCharIndex);
|
|
5596
6350
|
const cursorChar2 = line.slice(currentCharIndex, currentCharIndex + 1) || " ";
|
|
5597
6351
|
const afterCursorInLine = line.slice(currentCharIndex + 1);
|
|
5598
|
-
return /* @__PURE__ */
|
|
6352
|
+
return /* @__PURE__ */ jsxDEV15(Box14, {
|
|
5599
6353
|
children: [
|
|
5600
|
-
/* @__PURE__ */
|
|
6354
|
+
/* @__PURE__ */ jsxDEV15(Text14, {
|
|
5601
6355
|
color: promptColor,
|
|
5602
6356
|
children: [
|
|
5603
6357
|
promptChar,
|
|
5604
6358
|
" "
|
|
5605
6359
|
]
|
|
5606
6360
|
}, undefined, true, undefined, this),
|
|
5607
|
-
/* @__PURE__ */
|
|
6361
|
+
/* @__PURE__ */ jsxDEV15(Text14, {
|
|
5608
6362
|
children: [
|
|
5609
6363
|
beforeCursorInLine,
|
|
5610
|
-
showCursor && /* @__PURE__ */
|
|
6364
|
+
showCursor && /* @__PURE__ */ jsxDEV15(Text14, {
|
|
5611
6365
|
backgroundColor: "white",
|
|
5612
6366
|
color: "black",
|
|
5613
6367
|
children: cursorChar2
|
|
@@ -5619,16 +6373,16 @@ function ChatInput({
|
|
|
5619
6373
|
]
|
|
5620
6374
|
}, index, true, undefined, this);
|
|
5621
6375
|
} else {
|
|
5622
|
-
return /* @__PURE__ */
|
|
6376
|
+
return /* @__PURE__ */ jsxDEV15(Box14, {
|
|
5623
6377
|
children: [
|
|
5624
|
-
/* @__PURE__ */
|
|
6378
|
+
/* @__PURE__ */ jsxDEV15(Text14, {
|
|
5625
6379
|
color: promptColor,
|
|
5626
6380
|
children: [
|
|
5627
6381
|
promptChar,
|
|
5628
6382
|
" "
|
|
5629
6383
|
]
|
|
5630
6384
|
}, undefined, true, undefined, this),
|
|
5631
|
-
/* @__PURE__ */
|
|
6385
|
+
/* @__PURE__ */ jsxDEV15(Text14, {
|
|
5632
6386
|
children: line
|
|
5633
6387
|
}, undefined, false, undefined, this)
|
|
5634
6388
|
]
|
|
@@ -5639,35 +6393,35 @@ function ChatInput({
|
|
|
5639
6393
|
}
|
|
5640
6394
|
const cursorChar = input.slice(cursorPosition, cursorPosition + 1) || " ";
|
|
5641
6395
|
const afterCursorText = input.slice(cursorPosition + 1);
|
|
5642
|
-
return /* @__PURE__ */
|
|
6396
|
+
return /* @__PURE__ */ jsxDEV15(Box14, {
|
|
5643
6397
|
borderStyle: "round",
|
|
5644
6398
|
borderColor,
|
|
5645
6399
|
paddingX: 1,
|
|
5646
6400
|
paddingY: 0,
|
|
5647
6401
|
marginTop: 1,
|
|
5648
|
-
children: /* @__PURE__ */
|
|
6402
|
+
children: /* @__PURE__ */ jsxDEV15(Box14, {
|
|
5649
6403
|
children: [
|
|
5650
|
-
/* @__PURE__ */
|
|
6404
|
+
/* @__PURE__ */ jsxDEV15(Text14, {
|
|
5651
6405
|
color: promptColor,
|
|
5652
6406
|
children: "❯ "
|
|
5653
6407
|
}, undefined, false, undefined, this),
|
|
5654
|
-
isPlaceholder ? /* @__PURE__ */
|
|
6408
|
+
isPlaceholder ? /* @__PURE__ */ jsxDEV15(Fragment3, {
|
|
5655
6409
|
children: [
|
|
5656
|
-
/* @__PURE__ */
|
|
6410
|
+
/* @__PURE__ */ jsxDEV15(Text14, {
|
|
5657
6411
|
color: "gray",
|
|
5658
6412
|
dimColor: true,
|
|
5659
6413
|
children: placeholderText
|
|
5660
6414
|
}, undefined, false, undefined, this),
|
|
5661
|
-
showCursor && /* @__PURE__ */
|
|
6415
|
+
showCursor && /* @__PURE__ */ jsxDEV15(Text14, {
|
|
5662
6416
|
backgroundColor: "white",
|
|
5663
6417
|
color: "black",
|
|
5664
6418
|
children: " "
|
|
5665
6419
|
}, undefined, false, undefined, this)
|
|
5666
6420
|
]
|
|
5667
|
-
}, undefined, true, undefined, this) : /* @__PURE__ */
|
|
6421
|
+
}, undefined, true, undefined, this) : /* @__PURE__ */ jsxDEV15(Text14, {
|
|
5668
6422
|
children: [
|
|
5669
6423
|
beforeCursor,
|
|
5670
|
-
showCursor && /* @__PURE__ */
|
|
6424
|
+
showCursor && /* @__PURE__ */ jsxDEV15(Text14, {
|
|
5671
6425
|
backgroundColor: "white",
|
|
5672
6426
|
color: "black",
|
|
5673
6427
|
children: cursorChar
|
|
@@ -5682,9 +6436,9 @@ function ChatInput({
|
|
|
5682
6436
|
}
|
|
5683
6437
|
|
|
5684
6438
|
// src/ui/components/chat-interface.tsx
|
|
5685
|
-
import { Box as
|
|
6439
|
+
import { Box as Box15, Text as Text15 } from "ink";
|
|
5686
6440
|
import cfonts from "cfonts";
|
|
5687
|
-
import { jsxDEV as
|
|
6441
|
+
import { jsxDEV as jsxDEV16, Fragment as Fragment4 } from "react/jsx-dev-runtime";
|
|
5688
6442
|
function ChatInterfaceWithAgent({
|
|
5689
6443
|
agent,
|
|
5690
6444
|
initialMessage
|
|
@@ -5705,9 +6459,20 @@ function ChatInterfaceWithAgent({
|
|
|
5705
6459
|
selectedCommandIndex,
|
|
5706
6460
|
showModelSelection,
|
|
5707
6461
|
selectedModelIndex,
|
|
5708
|
-
commandSuggestions,
|
|
5709
6462
|
availableModels,
|
|
5710
|
-
autoEditEnabled
|
|
6463
|
+
autoEditEnabled,
|
|
6464
|
+
agentMode,
|
|
6465
|
+
showMentionSuggestions,
|
|
6466
|
+
commandSuggestions,
|
|
6467
|
+
showCommandPalette,
|
|
6468
|
+
commandPaletteQuery,
|
|
6469
|
+
selectedPaletteIndex,
|
|
6470
|
+
mentionSuggestions,
|
|
6471
|
+
mentionQuery,
|
|
6472
|
+
selectedMentionIndex,
|
|
6473
|
+
showProviderSelection,
|
|
6474
|
+
selectedProviderIndex,
|
|
6475
|
+
showConfigViewer
|
|
5711
6476
|
} = useInputHandler({
|
|
5712
6477
|
agent,
|
|
5713
6478
|
chatHistory,
|
|
@@ -5864,40 +6629,40 @@ function ChatInterfaceWithAgent({
|
|
|
5864
6629
|
setProcessingTime(0);
|
|
5865
6630
|
processingStartTime.current = 0;
|
|
5866
6631
|
};
|
|
5867
|
-
return /* @__PURE__ */
|
|
6632
|
+
return /* @__PURE__ */ jsxDEV16(Box15, {
|
|
5868
6633
|
flexDirection: "column",
|
|
5869
6634
|
paddingX: 2,
|
|
5870
6635
|
children: [
|
|
5871
|
-
chatHistory.length === 0 && !confirmationOptions && /* @__PURE__ */
|
|
6636
|
+
chatHistory.length === 0 && !confirmationOptions && /* @__PURE__ */ jsxDEV16(Box15, {
|
|
5872
6637
|
flexDirection: "column",
|
|
5873
6638
|
marginBottom: 2,
|
|
5874
6639
|
children: [
|
|
5875
|
-
/* @__PURE__ */
|
|
6640
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
5876
6641
|
color: "cyan",
|
|
5877
6642
|
bold: true,
|
|
5878
6643
|
children: "Tips for getting started:"
|
|
5879
6644
|
}, undefined, false, undefined, this),
|
|
5880
|
-
/* @__PURE__ */
|
|
6645
|
+
/* @__PURE__ */ jsxDEV16(Box15, {
|
|
5881
6646
|
marginTop: 1,
|
|
5882
6647
|
flexDirection: "column",
|
|
5883
6648
|
children: [
|
|
5884
|
-
/* @__PURE__ */
|
|
6649
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
5885
6650
|
color: "gray",
|
|
5886
6651
|
children: "1. Ask questions, edit files, or run commands."
|
|
5887
6652
|
}, undefined, false, undefined, this),
|
|
5888
|
-
/* @__PURE__ */
|
|
6653
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
5889
6654
|
color: "gray",
|
|
5890
6655
|
children: "2. Be specific for the best results."
|
|
5891
6656
|
}, undefined, false, undefined, this),
|
|
5892
|
-
/* @__PURE__ */
|
|
6657
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
5893
6658
|
color: "gray",
|
|
5894
6659
|
children: "3. Create SUPER_AGENT.md files to customize your interactions."
|
|
5895
6660
|
}, undefined, false, undefined, this),
|
|
5896
|
-
/* @__PURE__ */
|
|
6661
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
5897
6662
|
color: "gray",
|
|
5898
6663
|
children: "4. Press Shift+Tab to toggle auto-edit mode."
|
|
5899
6664
|
}, undefined, false, undefined, this),
|
|
5900
|
-
/* @__PURE__ */
|
|
6665
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
5901
6666
|
color: "gray",
|
|
5902
6667
|
children: "5. /help for more information."
|
|
5903
6668
|
}, undefined, false, undefined, this)
|
|
@@ -5905,23 +6670,23 @@ function ChatInterfaceWithAgent({
|
|
|
5905
6670
|
}, undefined, true, undefined, this)
|
|
5906
6671
|
]
|
|
5907
6672
|
}, undefined, true, undefined, this),
|
|
5908
|
-
/* @__PURE__ */
|
|
6673
|
+
/* @__PURE__ */ jsxDEV16(Box15, {
|
|
5909
6674
|
flexDirection: "column",
|
|
5910
6675
|
marginBottom: 1,
|
|
5911
|
-
children: /* @__PURE__ */
|
|
6676
|
+
children: /* @__PURE__ */ jsxDEV16(Text15, {
|
|
5912
6677
|
color: "gray",
|
|
5913
6678
|
children: "Type your request in natural language. Ctrl+C to clear, 'exit' to quit."
|
|
5914
6679
|
}, undefined, false, undefined, this)
|
|
5915
6680
|
}, undefined, false, undefined, this),
|
|
5916
|
-
/* @__PURE__ */
|
|
6681
|
+
/* @__PURE__ */ jsxDEV16(Box15, {
|
|
5917
6682
|
flexDirection: "column",
|
|
5918
6683
|
ref: scrollRef,
|
|
5919
|
-
children: /* @__PURE__ */
|
|
6684
|
+
children: /* @__PURE__ */ jsxDEV16(ChatHistory, {
|
|
5920
6685
|
entries: chatHistory,
|
|
5921
6686
|
isConfirmationActive: !!confirmationOptions
|
|
5922
6687
|
}, undefined, false, undefined, this)
|
|
5923
6688
|
}, undefined, false, undefined, this),
|
|
5924
|
-
confirmationOptions && /* @__PURE__ */
|
|
6689
|
+
confirmationOptions && /* @__PURE__ */ jsxDEV16(ConfirmationDialog, {
|
|
5925
6690
|
operation: confirmationOptions.operation,
|
|
5926
6691
|
filename: confirmationOptions.filename,
|
|
5927
6692
|
showVSCodeOpen: confirmationOptions.showVSCodeOpen,
|
|
@@ -5929,72 +6694,184 @@ function ChatInterfaceWithAgent({
|
|
|
5929
6694
|
onConfirm: handleConfirmation,
|
|
5930
6695
|
onReject: handleRejection
|
|
5931
6696
|
}, undefined, false, undefined, this),
|
|
5932
|
-
!confirmationOptions && /* @__PURE__ */
|
|
5933
|
-
children:
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
/* @__PURE__ */
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
/* @__PURE__ */ jsxDEV12(ModelSelection, {
|
|
6697
|
+
!confirmationOptions && /* @__PURE__ */ jsxDEV16(Fragment4, {
|
|
6698
|
+
children: showCommandPalette ? /* @__PURE__ */ jsxDEV16(Box15, {
|
|
6699
|
+
flexDirection: "column",
|
|
6700
|
+
marginTop: 1,
|
|
6701
|
+
children: /* @__PURE__ */ jsxDEV16(CommandPalette, {
|
|
6702
|
+
files: mentionSuggestions,
|
|
6703
|
+
query: commandPaletteQuery,
|
|
6704
|
+
selectedIndex: selectedPaletteIndex,
|
|
6705
|
+
isVisible: showCommandPalette
|
|
6706
|
+
}, undefined, false, undefined, this)
|
|
6707
|
+
}, undefined, false, undefined, this) : showProviderSelection ? /* @__PURE__ */ jsxDEV16(Box15, {
|
|
6708
|
+
flexDirection: "column",
|
|
6709
|
+
marginTop: 1,
|
|
6710
|
+
children: /* @__PURE__ */ jsxDEV16(ProviderSelection, {
|
|
6711
|
+
providers: (() => {
|
|
6712
|
+
const {
|
|
6713
|
+
getSettingsManager: getSettingsManager2
|
|
6714
|
+
} = (init_settings_manager(), __toCommonJS(exports_settings_manager));
|
|
6715
|
+
const manager = getSettingsManager2();
|
|
6716
|
+
const settings = manager.loadUserSettings();
|
|
6717
|
+
const active = settings.active_provider;
|
|
6718
|
+
return Object.keys(settings.providers || {}).map((id) => ({
|
|
6719
|
+
id,
|
|
6720
|
+
name: id,
|
|
6721
|
+
isActive: id === active,
|
|
6722
|
+
hasApiKey: !!settings.providers[id]?.api_key,
|
|
6723
|
+
model: settings.providers[id]?.model
|
|
6724
|
+
}));
|
|
6725
|
+
})(),
|
|
6726
|
+
selectedIndex: selectedProviderIndex,
|
|
6727
|
+
isVisible: showProviderSelection
|
|
6728
|
+
}, undefined, false, undefined, this)
|
|
6729
|
+
}, undefined, false, undefined, this) : showConfigViewer ? /* @__PURE__ */ jsxDEV16(Box15, {
|
|
6730
|
+
flexDirection: "column",
|
|
6731
|
+
marginTop: 1,
|
|
6732
|
+
children: /* @__PURE__ */ jsxDEV16(ConfigViewer, {
|
|
6733
|
+
config: (() => {
|
|
6734
|
+
const {
|
|
6735
|
+
getSettingsManager: getSettingsManager2
|
|
6736
|
+
} = (init_settings_manager(), __toCommonJS(exports_settings_manager));
|
|
6737
|
+
const manager = getSettingsManager2();
|
|
6738
|
+
const settings = manager.loadUserSettings();
|
|
6739
|
+
const activeProvider = settings.active_provider;
|
|
6740
|
+
const activeConfig = settings.providers[activeProvider];
|
|
6741
|
+
return {
|
|
6742
|
+
activeProvider,
|
|
6743
|
+
apiKeySet: !!activeConfig?.api_key,
|
|
6744
|
+
baseUrl: activeConfig?.base_url,
|
|
6745
|
+
model: activeConfig?.model,
|
|
6746
|
+
theme: settings.ui.theme
|
|
6747
|
+
};
|
|
6748
|
+
})(),
|
|
6749
|
+
isVisible: showConfigViewer
|
|
6750
|
+
}, undefined, false, undefined, this)
|
|
6751
|
+
}, undefined, false, undefined, this) : showModelSelection ? /* @__PURE__ */ jsxDEV16(Box15, {
|
|
6752
|
+
flexDirection: "column",
|
|
6753
|
+
marginTop: 1,
|
|
6754
|
+
children: /* @__PURE__ */ jsxDEV16(ModelSelection, {
|
|
5991
6755
|
models: availableModels,
|
|
5992
6756
|
selectedIndex: selectedModelIndex,
|
|
5993
6757
|
isVisible: showModelSelection,
|
|
5994
6758
|
currentModel: agent.getCurrentModel()
|
|
5995
6759
|
}, undefined, false, undefined, this)
|
|
5996
|
-
|
|
5997
|
-
|
|
6760
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV16(Fragment4, {
|
|
6761
|
+
children: [
|
|
6762
|
+
/* @__PURE__ */ jsxDEV16(LoadingSpinner, {
|
|
6763
|
+
isActive: isProcessing || isStreaming,
|
|
6764
|
+
processingTime,
|
|
6765
|
+
tokenCount
|
|
6766
|
+
}, undefined, false, undefined, this),
|
|
6767
|
+
/* @__PURE__ */ jsxDEV16(ChatInput, {
|
|
6768
|
+
input,
|
|
6769
|
+
cursorPosition,
|
|
6770
|
+
isProcessing,
|
|
6771
|
+
isStreaming
|
|
6772
|
+
}, undefined, false, undefined, this),
|
|
6773
|
+
/* @__PURE__ */ jsxDEV16(Box15, {
|
|
6774
|
+
flexDirection: "row",
|
|
6775
|
+
marginTop: 1,
|
|
6776
|
+
flexWrap: "wrap",
|
|
6777
|
+
children: [
|
|
6778
|
+
/* @__PURE__ */ jsxDEV16(Box15, {
|
|
6779
|
+
marginRight: 2,
|
|
6780
|
+
children: [
|
|
6781
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
6782
|
+
color: "cyan",
|
|
6783
|
+
children: [
|
|
6784
|
+
autoEditEnabled ? "\uD83D\uDE80" : "⏸",
|
|
6785
|
+
" yolo:",
|
|
6786
|
+
" ",
|
|
6787
|
+
autoEditEnabled ? "on" : "off",
|
|
6788
|
+
" "
|
|
6789
|
+
]
|
|
6790
|
+
}, undefined, true, undefined, this),
|
|
6791
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
6792
|
+
color: "gray",
|
|
6793
|
+
dimColor: true,
|
|
6794
|
+
children: "(ctrl+y)"
|
|
6795
|
+
}, undefined, false, undefined, this)
|
|
6796
|
+
]
|
|
6797
|
+
}, undefined, true, undefined, this),
|
|
6798
|
+
/* @__PURE__ */ jsxDEV16(Box15, {
|
|
6799
|
+
marginRight: 2,
|
|
6800
|
+
children: [
|
|
6801
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
6802
|
+
color: agentMode === "plan" ? "cyan" : agentMode === "debug" ? "magenta" : "green",
|
|
6803
|
+
bold: true,
|
|
6804
|
+
children: [
|
|
6805
|
+
"◈ ",
|
|
6806
|
+
agentMode.toUpperCase()
|
|
6807
|
+
]
|
|
6808
|
+
}, undefined, true, undefined, this),
|
|
6809
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
6810
|
+
color: "gray",
|
|
6811
|
+
dimColor: true,
|
|
6812
|
+
children: [
|
|
6813
|
+
" ",
|
|
6814
|
+
"(shift+tab)"
|
|
6815
|
+
]
|
|
6816
|
+
}, undefined, true, undefined, this)
|
|
6817
|
+
]
|
|
6818
|
+
}, undefined, true, undefined, this),
|
|
6819
|
+
/* @__PURE__ */ jsxDEV16(Box15, {
|
|
6820
|
+
marginRight: 2,
|
|
6821
|
+
children: [
|
|
6822
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
6823
|
+
color: "magenta",
|
|
6824
|
+
children: "\uD83D\uDD0D palette "
|
|
6825
|
+
}, undefined, false, undefined, this),
|
|
6826
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
6827
|
+
color: "gray",
|
|
6828
|
+
dimColor: true,
|
|
6829
|
+
children: "(ctrl+p)"
|
|
6830
|
+
}, undefined, false, undefined, this)
|
|
6831
|
+
]
|
|
6832
|
+
}, undefined, true, undefined, this),
|
|
6833
|
+
/* @__PURE__ */ jsxDEV16(Box15, {
|
|
6834
|
+
marginRight: 2,
|
|
6835
|
+
children: [
|
|
6836
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
6837
|
+
color: "cyan",
|
|
6838
|
+
children: "\uD83D\uDC1A shell "
|
|
6839
|
+
}, undefined, false, undefined, this),
|
|
6840
|
+
/* @__PURE__ */ jsxDEV16(Text15, {
|
|
6841
|
+
color: "gray",
|
|
6842
|
+
dimColor: true,
|
|
6843
|
+
children: "(!)"
|
|
6844
|
+
}, undefined, false, undefined, this)
|
|
6845
|
+
]
|
|
6846
|
+
}, undefined, true, undefined, this),
|
|
6847
|
+
/* @__PURE__ */ jsxDEV16(Box15, {
|
|
6848
|
+
marginRight: 2,
|
|
6849
|
+
children: /* @__PURE__ */ jsxDEV16(Text15, {
|
|
6850
|
+
color: "yellow",
|
|
6851
|
+
children: [
|
|
6852
|
+
"≋ ",
|
|
6853
|
+
agent.getCurrentModel()
|
|
6854
|
+
]
|
|
6855
|
+
}, undefined, true, undefined, this)
|
|
6856
|
+
}, undefined, false, undefined, this),
|
|
6857
|
+
/* @__PURE__ */ jsxDEV16(MCPStatus, {}, undefined, false, undefined, this)
|
|
6858
|
+
]
|
|
6859
|
+
}, undefined, true, undefined, this),
|
|
6860
|
+
/* @__PURE__ */ jsxDEV16(MentionSuggestions, {
|
|
6861
|
+
suggestions: mentionSuggestions,
|
|
6862
|
+
query: mentionQuery,
|
|
6863
|
+
selectedIndex: selectedMentionIndex,
|
|
6864
|
+
isVisible: showMentionSuggestions
|
|
6865
|
+
}, undefined, false, undefined, this),
|
|
6866
|
+
/* @__PURE__ */ jsxDEV16(CommandSuggestions, {
|
|
6867
|
+
suggestions: commandSuggestions,
|
|
6868
|
+
input,
|
|
6869
|
+
selectedIndex: selectedCommandIndex,
|
|
6870
|
+
isVisible: showCommandSuggestions
|
|
6871
|
+
}, undefined, false, undefined, this)
|
|
6872
|
+
]
|
|
6873
|
+
}, undefined, true, undefined, this)
|
|
6874
|
+
}, undefined, false, undefined, this)
|
|
5998
6875
|
]
|
|
5999
6876
|
}, undefined, true, undefined, this);
|
|
6000
6877
|
}
|
|
@@ -6007,11 +6884,11 @@ function ChatInterface({
|
|
|
6007
6884
|
setCurrentAgent(newAgent);
|
|
6008
6885
|
};
|
|
6009
6886
|
if (!currentAgent) {
|
|
6010
|
-
return /* @__PURE__ */
|
|
6887
|
+
return /* @__PURE__ */ jsxDEV16(ApiKeyInput, {
|
|
6011
6888
|
onApiKeySet: handleApiKeySet
|
|
6012
6889
|
}, undefined, false, undefined, this);
|
|
6013
6890
|
}
|
|
6014
|
-
return /* @__PURE__ */
|
|
6891
|
+
return /* @__PURE__ */ jsxDEV16(ChatInterfaceWithAgent, {
|
|
6015
6892
|
agent: currentAgent,
|
|
6016
6893
|
initialMessage
|
|
6017
6894
|
}, undefined, false, undefined, this);
|
|
@@ -6216,7 +7093,7 @@ import { program } from "commander";
|
|
|
6216
7093
|
// package.json
|
|
6217
7094
|
var package_default = {
|
|
6218
7095
|
name: "@involvex/super-agent-cli",
|
|
6219
|
-
version: "0.0.
|
|
7096
|
+
version: "0.0.45",
|
|
6220
7097
|
description: "An open-source AI agent that brings the power of Super Agent directly into your terminal.",
|
|
6221
7098
|
keywords: [
|
|
6222
7099
|
"cli",
|
|
@@ -6305,7 +7182,7 @@ var package_default = {
|
|
|
6305
7182
|
// src/index.ts
|
|
6306
7183
|
import * as dotenv from "dotenv";
|
|
6307
7184
|
import { render } from "ink";
|
|
6308
|
-
import
|
|
7185
|
+
import React4 from "react";
|
|
6309
7186
|
dotenv.config();
|
|
6310
7187
|
process.on("SIGTERM", () => {
|
|
6311
7188
|
if (process.stdin.isTTY && process.stdin.setRawMode) {
|
|
@@ -6529,7 +7406,7 @@ program.name("super-agent").description("A conversational AI CLI tool powered by
|
|
|
6529
7406
|
`);
|
|
6530
7407
|
ensureUserSettingsDirectory();
|
|
6531
7408
|
const initialMessage = Array.isArray(message) ? message.join(" ") : message;
|
|
6532
|
-
render(
|
|
7409
|
+
render(React4.createElement(ChatInterface, { agent, initialMessage }));
|
|
6533
7410
|
} catch (error) {
|
|
6534
7411
|
console.error("❌ Error initializing Super Agent CLI:", error.message);
|
|
6535
7412
|
process.exit(1);
|