@involvex/super-agent-cli 0.0.48 → 0.0.50

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 CHANGED
@@ -46,6 +46,9 @@ class SettingsManager {
46
46
  this.userSettingsPath = path.join(os.homedir(), ".super-agent", "settings.json");
47
47
  this.projectSettingsPath = path.join(process.cwd(), ".super-agent", "settings.json");
48
48
  }
49
+ getStorageDirectory() {
50
+ return path.join(os.homedir(), ".super-agent");
51
+ }
49
52
  static getInstance() {
50
53
  if (!SettingsManager.instance) {
51
54
  SettingsManager.instance = new SettingsManager;
@@ -146,21 +149,24 @@ class SettingsManager {
146
149
  this.saveUserSettings(settings);
147
150
  }
148
151
  }
149
- getAvailableModels() {
152
+ getAvailableModels(providerId) {
153
+ const activeProvider = providerId || this.getActiveProviderConfig()?.id || "grok";
154
+ let models = PROVIDER_MODELS[activeProvider];
155
+ if (!models) {
156
+ const config = this.getEffectiveSettings().providers[activeProvider];
157
+ if (config && PROVIDER_MODELS[config.provider]) {
158
+ models = PROVIDER_MODELS[config.provider];
159
+ }
160
+ }
161
+ if (models) {
162
+ return models;
163
+ }
150
164
  return [
151
165
  "grok-beta",
152
166
  "grok-vision-beta",
153
167
  "grok-2-vision-1212",
154
168
  "grok-2-1212",
155
- "grok-code-fast-1",
156
- "gpt-4o",
157
- "gpt-4o-mini",
158
- "o1-preview",
159
- "o1-mini",
160
- "gemini-3-pro-preview",
161
- "gemini-2.5-pro",
162
- "gemini-2.5-flash",
163
- "GLM-4.7"
169
+ "grok-code-fast-1"
164
170
  ];
165
171
  }
166
172
  getApiKey() {
@@ -181,8 +187,48 @@ class SettingsManager {
181
187
  function getSettingsManager() {
182
188
  return SettingsManager.getInstance();
183
189
  }
184
- var SETTINGS_VERSION = 2, DEFAULT_USER_SETTINGS, DEFAULT_PROJECT_SETTINGS;
190
+ var SETTINGS_VERSION = 2, PROVIDER_MODELS, DEFAULT_USER_SETTINGS, DEFAULT_PROJECT_SETTINGS;
185
191
  var init_settings_manager = __esm(() => {
192
+ PROVIDER_MODELS = {
193
+ grok: [
194
+ "grok-beta",
195
+ "grok-vision-beta",
196
+ "grok-2-vision-1212",
197
+ "grok-2-1212",
198
+ "grok-code-fast-1"
199
+ ],
200
+ openai: [
201
+ "gpt-4o",
202
+ "gpt-4o-mini",
203
+ "o1-preview",
204
+ "o1-mini",
205
+ "gpt-4-turbo",
206
+ "gpt-3.5-turbo"
207
+ ],
208
+ gemini: [
209
+ "gemini-2.0-flash",
210
+ "gemini-2.0-pro-exp-02-05",
211
+ "gemini-1.5-pro",
212
+ "gemini-1.5-flash"
213
+ ],
214
+ mistral: ["mistral-large-latest", "mistral-small-latest", "codestral-latest"],
215
+ openrouter: [
216
+ "anthropic/claude-3.5-sonnet",
217
+ "anthropic/claude-3-opus",
218
+ "meta-llama/llama-3.1-70b-instruct",
219
+ "mistralai/mistral-large",
220
+ "google/gemini-flash-1.5"
221
+ ],
222
+ minimax: ["abab6.5s-chat"],
223
+ groq: [
224
+ "llama-3.3-70b-versatile",
225
+ "llama-3.1-8b-instant",
226
+ "mixtral-8x7b-32768"
227
+ ],
228
+ deepseek: ["deepseek-chat", "deepseek-coder"],
229
+ ollama: ["llama3", "mistral", "codellama"],
230
+ "workers-ai": ["@cf/meta/llama-3.1-70b-instruct"]
231
+ };
186
232
  DEFAULT_USER_SETTINGS = {
187
233
  active_provider: "grok",
188
234
  providers: {
@@ -944,7 +990,75 @@ function updateCurrentModel(modelName) {
944
990
 
945
991
  // src/hooks/use-input-handler.ts
946
992
  init_settings_manager();
993
+
994
+ // src/utils/chat-manager.ts
995
+ init_settings_manager();
947
996
  import * as fs3 from "fs-extra";
997
+ import * as path3 from "path";
998
+
999
+ class ChatManager {
1000
+ static instance;
1001
+ chatDirectory;
1002
+ constructor() {
1003
+ const settingsManager = getSettingsManager();
1004
+ this.chatDirectory = path3.join(settingsManager.getStorageDirectory(), "chats");
1005
+ this.ensureDirectoryExists();
1006
+ }
1007
+ static getInstance() {
1008
+ if (!ChatManager.instance) {
1009
+ ChatManager.instance = new ChatManager;
1010
+ }
1011
+ return ChatManager.instance;
1012
+ }
1013
+ ensureDirectoryExists() {
1014
+ if (!fs3.existsSync(this.chatDirectory)) {
1015
+ fs3.mkdirSync(this.chatDirectory, { recursive: true, mode: 448 });
1016
+ }
1017
+ }
1018
+ getChatPath(name) {
1019
+ return path3.join(this.chatDirectory, `${name}.json`);
1020
+ }
1021
+ async saveChat(name, history) {
1022
+ const filePath = this.getChatPath(name);
1023
+ await fs3.writeJson(filePath, {
1024
+ name,
1025
+ updatedAt: new Date().toISOString(),
1026
+ history
1027
+ }, { spaces: 2, mode: 384 });
1028
+ }
1029
+ async loadChat(name) {
1030
+ const filePath = this.getChatPath(name);
1031
+ if (!fs3.existsSync(filePath)) {
1032
+ throw new Error(`Chat session '${name}' not found.`);
1033
+ }
1034
+ const data = await fs3.readJson(filePath);
1035
+ return data.history.map((entry) => ({
1036
+ ...entry,
1037
+ timestamp: new Date(entry.timestamp)
1038
+ }));
1039
+ }
1040
+ async listChats() {
1041
+ if (!fs3.existsSync(this.chatDirectory)) {
1042
+ return [];
1043
+ }
1044
+ const files = await fs3.readdir(this.chatDirectory);
1045
+ return files.filter((file) => file.endsWith(".json")).map((file) => file.replace(".json", ""));
1046
+ }
1047
+ async deleteChat(name) {
1048
+ const filePath = this.getChatPath(name);
1049
+ if (fs3.existsSync(filePath)) {
1050
+ await fs3.unlink(filePath);
1051
+ } else {
1052
+ throw new Error(`Chat session '${name}' not found.`);
1053
+ }
1054
+ }
1055
+ }
1056
+ function getChatManager() {
1057
+ return ChatManager.getInstance();
1058
+ }
1059
+
1060
+ // src/hooks/use-input-handler.ts
1061
+ import * as fs4 from "fs-extra";
948
1062
  function useInputHandler({
949
1063
  agent,
950
1064
  chatHistory,
@@ -1285,12 +1399,19 @@ function useInputHandler({
1285
1399
  { command: "/models", description: "Switch Super Agent Model" },
1286
1400
  { command: "/config", description: "View or edit configuration" },
1287
1401
  { command: "/provider", description: "Manage AI providers" },
1402
+ { command: "/chat save <name>", description: "Save current chat" },
1403
+ { command: "/chat load <name>", description: "Load a saved chat" },
1404
+ { command: "/chat list", description: "List saved chats" },
1405
+ { command: "/chat delete <name>", description: "Delete a saved chat" },
1288
1406
  { command: "/commit-and-push", description: "AI commit & push to remote" },
1289
1407
  { command: "/exit", description: "Exit the application" }
1290
1408
  ];
1409
+ const [activeProvider, setActiveProvider] = useState3(() => {
1410
+ return getSettingsManager().loadUserSettings().active_provider;
1411
+ });
1291
1412
  const availableModels = useMemo2(() => {
1292
1413
  return loadModelConfig();
1293
- }, []);
1414
+ }, [activeProvider]);
1294
1415
  const handleDirectCommand = async (input2) => {
1295
1416
  const trimmedInput = input2.trim();
1296
1417
  if (trimmedInput === "/clear") {
@@ -1361,15 +1482,27 @@ Config Commands:
1361
1482
  const settings = manager.loadUserSettings();
1362
1483
  if (settings.providers && settings.providers[providerId]) {
1363
1484
  manager.updateUserSetting("active_provider", providerId);
1364
- setChatHistory((prev) => [
1365
- ...prev,
1366
- {
1367
- type: "assistant",
1368
- content: `✓ Switched active provider to: ${providerId}`,
1369
- timestamp: new Date
1370
- }
1371
- ]);
1372
- const newConfig = settings.providers[providerId];
1485
+ try {
1486
+ agent.setProvider(providerId);
1487
+ setActiveProvider(providerId);
1488
+ setChatHistory((prev) => [
1489
+ ...prev,
1490
+ {
1491
+ type: "assistant",
1492
+ content: `✓ Switched active provider to: ${providerId}`,
1493
+ timestamp: new Date
1494
+ }
1495
+ ]);
1496
+ } catch (error) {
1497
+ setChatHistory((prev) => [
1498
+ ...prev,
1499
+ {
1500
+ type: "assistant",
1501
+ content: `❌ Failed to switch provider: ${error.message}`,
1502
+ timestamp: new Date
1503
+ }
1504
+ ]);
1505
+ }
1373
1506
  } else {
1374
1507
  setChatHistory((prev) => [
1375
1508
  ...prev,
@@ -1431,6 +1564,91 @@ Available models: ${modelNames.join(", ")}`,
1431
1564
  clearInput();
1432
1565
  return true;
1433
1566
  }
1567
+ if (trimmedInput.startsWith("/chat ")) {
1568
+ const args = trimmedInput.replace("/chat ", "").split(" ");
1569
+ const action = args[0];
1570
+ const name = args.slice(1).join(" ");
1571
+ const chatManager = getChatManager();
1572
+ try {
1573
+ if (action === "save") {
1574
+ if (!name) {
1575
+ throw new Error("Chat name is required.");
1576
+ }
1577
+ await chatManager.saveChat(name, chatHistory);
1578
+ setChatHistory((prev) => [
1579
+ ...prev,
1580
+ {
1581
+ type: "assistant",
1582
+ content: `✓ Chat saved as '${name}'.`,
1583
+ timestamp: new Date
1584
+ }
1585
+ ]);
1586
+ } else if (action === "load") {
1587
+ if (!name) {
1588
+ throw new Error("Chat name is required.");
1589
+ }
1590
+ const history = await chatManager.loadChat(name);
1591
+ setChatHistory(history);
1592
+ setChatHistory((prev) => [
1593
+ ...prev,
1594
+ {
1595
+ type: "assistant",
1596
+ content: `✓ Chat '${name}' loaded.`,
1597
+ timestamp: new Date
1598
+ }
1599
+ ]);
1600
+ } else if (action === "list") {
1601
+ const chats = await chatManager.listChats();
1602
+ setChatHistory((prev) => [
1603
+ ...prev,
1604
+ {
1605
+ type: "assistant",
1606
+ content: `Saved Chats:
1607
+ ${chats.length ? chats.map((c) => `- ${c}`).join(`
1608
+ `) : "No saved chats."}`,
1609
+ timestamp: new Date
1610
+ }
1611
+ ]);
1612
+ } else if (action === "delete") {
1613
+ if (!name) {
1614
+ throw new Error("Chat name is required.");
1615
+ }
1616
+ await chatManager.deleteChat(name);
1617
+ setChatHistory((prev) => [
1618
+ ...prev,
1619
+ {
1620
+ type: "assistant",
1621
+ content: `✓ Chat '${name}' deleted.`,
1622
+ timestamp: new Date
1623
+ }
1624
+ ]);
1625
+ } else if (action === "clear") {
1626
+ setChatHistory([]);
1627
+ setIsProcessing(false);
1628
+ setIsStreaming(false);
1629
+ setTokenCount(0);
1630
+ setProcessingTime(0);
1631
+ processingStartTime.current = 0;
1632
+ ConfirmationService.getInstance().resetSession();
1633
+ clearInput();
1634
+ resetHistory();
1635
+ return true;
1636
+ } else {
1637
+ throw new Error(`Unknown chat action: ${action}`);
1638
+ }
1639
+ } catch (error) {
1640
+ setChatHistory((prev) => [
1641
+ ...prev,
1642
+ {
1643
+ type: "assistant",
1644
+ content: `❌ Error: ${error.message}`,
1645
+ timestamp: new Date
1646
+ }
1647
+ ]);
1648
+ }
1649
+ clearInput();
1650
+ return true;
1651
+ }
1434
1652
  if (trimmedInput === "/commit-and-push") {
1435
1653
  const userEntry = {
1436
1654
  type: "user",
@@ -1682,9 +1900,9 @@ ${commitMessage}`
1682
1900
  for (const mention of mentionMatches) {
1683
1901
  const filePath = mention.slice(1);
1684
1902
  try {
1685
- const stats = await fs3.stat(filePath);
1903
+ const stats = await fs4.stat(filePath);
1686
1904
  if (stats.isFile()) {
1687
- const content = await fs3.readFile(filePath, "utf-8");
1905
+ const content = await fs4.readFile(filePath, "utf-8");
1688
1906
  resolvedInput = resolvedInput.replace(mention, `
1689
1907
 
1690
1908
  --- FILE: ${filePath} ---
@@ -3250,8 +3468,8 @@ class ConfirmationTool {
3250
3468
  }
3251
3469
  }
3252
3470
  // src/tools/morph-editor.ts
3253
- import * as path3 from "path";
3254
- import fs4 from "fs-extra";
3471
+ import * as path4 from "path";
3472
+ import fs5 from "fs-extra";
3255
3473
  import axios from "axios";
3256
3474
 
3257
3475
  class MorphEditorTool {
@@ -3266,8 +3484,8 @@ class MorphEditorTool {
3266
3484
  }
3267
3485
  async editFile(targetFile, instructions, codeEdit) {
3268
3486
  try {
3269
- const resolvedPath = path3.resolve(targetFile);
3270
- if (!await fs4.pathExists(resolvedPath)) {
3487
+ const resolvedPath = path4.resolve(targetFile);
3488
+ if (!await fs5.pathExists(resolvedPath)) {
3271
3489
  return {
3272
3490
  success: false,
3273
3491
  error: `File not found: ${targetFile}`
@@ -3279,7 +3497,7 @@ class MorphEditorTool {
3279
3497
  error: "MORPH_API_KEY not configured. Please set your Morph API key."
3280
3498
  };
3281
3499
  }
3282
- const initialCode = await fs4.readFile(resolvedPath, "utf-8");
3500
+ const initialCode = await fs5.readFile(resolvedPath, "utf-8");
3283
3501
  const sessionFlags = this.confirmationService.getSessionFlags();
3284
3502
  if (!sessionFlags.fileOperations && !sessionFlags.allOperations) {
3285
3503
  const confirmationResult = await this.confirmationService.requestConfirmation({
@@ -3299,7 +3517,7 @@ ${codeEdit}`
3299
3517
  }
3300
3518
  }
3301
3519
  const mergedCode = await this.callMorphApply(instructions, initialCode, codeEdit);
3302
- await fs4.writeFile(resolvedPath, mergedCode, "utf-8");
3520
+ await fs5.writeFile(resolvedPath, mergedCode, "utf-8");
3303
3521
  const oldLines = initialCode.split(`
3304
3522
  `);
3305
3523
  const newLines = mergedCode.split(`
@@ -3482,11 +3700,11 @@ ${codeEdit}`
3482
3700
  }
3483
3701
  async view(filePath, viewRange) {
3484
3702
  try {
3485
- const resolvedPath = path3.resolve(filePath);
3486
- if (await fs4.pathExists(resolvedPath)) {
3487
- const stats = await fs4.stat(resolvedPath);
3703
+ const resolvedPath = path4.resolve(filePath);
3704
+ if (await fs5.pathExists(resolvedPath)) {
3705
+ const stats = await fs5.stat(resolvedPath);
3488
3706
  if (stats.isDirectory()) {
3489
- const files = await fs4.readdir(resolvedPath);
3707
+ const files = await fs5.readdir(resolvedPath);
3490
3708
  return {
3491
3709
  success: true,
3492
3710
  output: `Directory contents of ${filePath}:
@@ -3494,7 +3712,7 @@ ${files.join(`
3494
3712
  `)}`
3495
3713
  };
3496
3714
  }
3497
- const content = await fs4.readFile(resolvedPath, "utf-8");
3715
+ const content = await fs5.readFile(resolvedPath, "utf-8");
3498
3716
  const lines = content.split(`
3499
3717
  `);
3500
3718
  if (viewRange) {
@@ -3540,8 +3758,8 @@ ${numberedLines}${additionalLinesMessage}`
3540
3758
  }
3541
3759
  }
3542
3760
  // src/tools/project-map.ts
3543
- import * as path4 from "path";
3544
- import fs5 from "fs-extra";
3761
+ import * as path5 from "path";
3762
+ import fs6 from "fs-extra";
3545
3763
 
3546
3764
  class ProjectMapTool {
3547
3765
  currentDirectory = process.cwd();
@@ -3575,7 +3793,7 @@ Important Files:
3575
3793
  }
3576
3794
  let result = "";
3577
3795
  try {
3578
- const entries = await fs5.readdir(dir, { withFileTypes: true });
3796
+ const entries = await fs6.readdir(dir, { withFileTypes: true });
3579
3797
  const sortedEntries = entries.sort((a, b) => {
3580
3798
  if (a.isDirectory() && !b.isDirectory()) {
3581
3799
  return -1;
@@ -3603,7 +3821,7 @@ Important Files:
3603
3821
  if (entry.isDirectory()) {
3604
3822
  result += `${indent}\uD83D\uDCC1 ${entry.name}/
3605
3823
  `;
3606
- result += await this.generateTree(path4.join(dir, entry.name), maxDepth, currentDepth + 1);
3824
+ result += await this.generateTree(path5.join(dir, entry.name), maxDepth, currentDepth + 1);
3607
3825
  } else {
3608
3826
  result += `${indent}\uD83D\uDCC4 ${entry.name}
3609
3827
  `;
@@ -3625,8 +3843,8 @@ Important Files:
3625
3843
  ];
3626
3844
  const found = [];
3627
3845
  for (const pattern of importantPatterns) {
3628
- const fullPath = path4.join(this.currentDirectory, pattern);
3629
- if (await fs5.pathExists(fullPath)) {
3846
+ const fullPath = path5.join(this.currentDirectory, pattern);
3847
+ if (await fs6.pathExists(fullPath)) {
3630
3848
  found.push(pattern);
3631
3849
  }
3632
3850
  }
@@ -3638,8 +3856,8 @@ Important Files:
3638
3856
  }
3639
3857
  // src/tools/search.ts
3640
3858
  import { spawn } from "child_process";
3641
- import * as path5 from "path";
3642
- import fs6 from "fs-extra";
3859
+ import * as path6 from "path";
3860
+ import fs7 from "fs-extra";
3643
3861
 
3644
3862
  class SearchTool {
3645
3863
  confirmationService = ConfirmationService.getInstance();
@@ -3779,13 +3997,13 @@ class SearchTool {
3779
3997
  return;
3780
3998
  }
3781
3999
  try {
3782
- const entries = await fs6.readdir(dir, { withFileTypes: true });
4000
+ const entries = await fs7.readdir(dir, { withFileTypes: true });
3783
4001
  for (const entry of entries) {
3784
4002
  if (files.length >= maxResults) {
3785
4003
  break;
3786
4004
  }
3787
- const fullPath = path5.join(dir, entry.name);
3788
- const relativePath = path5.relative(this.currentDirectory, fullPath);
4005
+ const fullPath = path6.join(dir, entry.name);
4006
+ const relativePath = path6.relative(this.currentDirectory, fullPath);
3789
4007
  if (!options.includeHidden && entry.name.startsWith(".")) {
3790
4008
  continue;
3791
4009
  }
@@ -3884,19 +4102,19 @@ class SearchTool {
3884
4102
  }
3885
4103
  // src/tools/text-editor.ts
3886
4104
  import { writeFile as writeFilePromise } from "fs/promises";
3887
- import * as path6 from "path";
3888
- import fs7 from "fs-extra";
4105
+ import * as path7 from "path";
4106
+ import fs8 from "fs-extra";
3889
4107
 
3890
4108
  class TextEditorTool {
3891
4109
  editHistory = [];
3892
4110
  confirmationService = ConfirmationService.getInstance();
3893
4111
  async view(filePath, viewRange) {
3894
4112
  try {
3895
- const resolvedPath = path6.resolve(filePath);
3896
- if (await fs7.pathExists(resolvedPath)) {
3897
- const stats = await fs7.stat(resolvedPath);
4113
+ const resolvedPath = path7.resolve(filePath);
4114
+ if (await fs8.pathExists(resolvedPath)) {
4115
+ const stats = await fs8.stat(resolvedPath);
3898
4116
  if (stats.isDirectory()) {
3899
- const files = await fs7.readdir(resolvedPath);
4117
+ const files = await fs8.readdir(resolvedPath);
3900
4118
  return {
3901
4119
  success: true,
3902
4120
  output: `Directory contents of ${filePath}:
@@ -3904,7 +4122,7 @@ ${files.join(`
3904
4122
  `)}`
3905
4123
  };
3906
4124
  }
3907
- const content = await fs7.readFile(resolvedPath, "utf-8");
4125
+ const content = await fs8.readFile(resolvedPath, "utf-8");
3908
4126
  const lines = content.split(`
3909
4127
  `);
3910
4128
  if (viewRange) {
@@ -3944,14 +4162,14 @@ ${numberedLines}${additionalLinesMessage}`
3944
4162
  }
3945
4163
  async strReplace(filePath, oldStr, newStr, replaceAll = false) {
3946
4164
  try {
3947
- const resolvedPath = path6.resolve(filePath);
3948
- if (!await fs7.pathExists(resolvedPath)) {
4165
+ const resolvedPath = path7.resolve(filePath);
4166
+ if (!await fs8.pathExists(resolvedPath)) {
3949
4167
  return {
3950
4168
  success: false,
3951
4169
  error: `File not found: ${filePath}`
3952
4170
  };
3953
4171
  }
3954
- const content = await fs7.readFile(resolvedPath, "utf-8");
4172
+ const content = await fs8.readFile(resolvedPath, "utf-8");
3955
4173
  if (!content.includes(oldStr)) {
3956
4174
  if (oldStr.includes(`
3957
4175
  `)) {
@@ -4019,7 +4237,7 @@ ${numberedLines}${additionalLinesMessage}`
4019
4237
  }
4020
4238
  async create(filePath, content) {
4021
4239
  try {
4022
- const resolvedPath = path6.resolve(filePath);
4240
+ const resolvedPath = path7.resolve(filePath);
4023
4241
  const sessionFlags = this.confirmationService.getSessionFlags();
4024
4242
  if (!sessionFlags.fileOperations && !sessionFlags.allOperations) {
4025
4243
  const contentLines = content.split(`
@@ -4045,8 +4263,8 @@ ${numberedLines}${additionalLinesMessage}`
4045
4263
  };
4046
4264
  }
4047
4265
  }
4048
- const dir = path6.dirname(resolvedPath);
4049
- await fs7.ensureDir(dir);
4266
+ const dir = path7.dirname(resolvedPath);
4267
+ await fs8.ensureDir(dir);
4050
4268
  await writeFilePromise(resolvedPath, content, "utf-8");
4051
4269
  this.editHistory.push({
4052
4270
  command: "create",
@@ -4070,14 +4288,14 @@ ${numberedLines}${additionalLinesMessage}`
4070
4288
  }
4071
4289
  async replaceLines(filePath, startLine, endLine, newContent) {
4072
4290
  try {
4073
- const resolvedPath = path6.resolve(filePath);
4074
- if (!await fs7.pathExists(resolvedPath)) {
4291
+ const resolvedPath = path7.resolve(filePath);
4292
+ if (!await fs8.pathExists(resolvedPath)) {
4075
4293
  return {
4076
4294
  success: false,
4077
4295
  error: `File not found: ${filePath}`
4078
4296
  };
4079
4297
  }
4080
- const fileContent = await fs7.readFile(resolvedPath, "utf-8");
4298
+ const fileContent = await fs8.readFile(resolvedPath, "utf-8");
4081
4299
  const lines = fileContent.split(`
4082
4300
  `);
4083
4301
  if (startLine < 1 || startLine > lines.length) {
@@ -4140,14 +4358,14 @@ ${numberedLines}${additionalLinesMessage}`
4140
4358
  }
4141
4359
  async insert(filePath, insertLine, content) {
4142
4360
  try {
4143
- const resolvedPath = path6.resolve(filePath);
4144
- if (!await fs7.pathExists(resolvedPath)) {
4361
+ const resolvedPath = path7.resolve(filePath);
4362
+ if (!await fs8.pathExists(resolvedPath)) {
4145
4363
  return {
4146
4364
  success: false,
4147
4365
  error: `File not found: ${filePath}`
4148
4366
  };
4149
4367
  }
4150
- const fileContent = await fs7.readFile(resolvedPath, "utf-8");
4368
+ const fileContent = await fs8.readFile(resolvedPath, "utf-8");
4151
4369
  const lines = fileContent.split(`
4152
4370
  `);
4153
4371
  lines.splice(insertLine - 1, 0, content);
@@ -4183,19 +4401,19 @@ ${numberedLines}${additionalLinesMessage}`
4183
4401
  switch (lastEdit.command) {
4184
4402
  case "str_replace":
4185
4403
  if (lastEdit.path && lastEdit.old_str && lastEdit.new_str) {
4186
- const content = await fs7.readFile(lastEdit.path, "utf-8");
4404
+ const content = await fs8.readFile(lastEdit.path, "utf-8");
4187
4405
  const revertedContent = content.replace(lastEdit.new_str, lastEdit.old_str);
4188
4406
  await writeFilePromise(lastEdit.path, revertedContent, "utf-8");
4189
4407
  }
4190
4408
  break;
4191
4409
  case "create":
4192
4410
  if (lastEdit.path) {
4193
- await fs7.remove(lastEdit.path);
4411
+ await fs8.remove(lastEdit.path);
4194
4412
  }
4195
4413
  break;
4196
4414
  case "insert":
4197
4415
  if (lastEdit.path && lastEdit.insert_line) {
4198
- const content = await fs7.readFile(lastEdit.path, "utf-8");
4416
+ const content = await fs8.readFile(lastEdit.path, "utf-8");
4199
4417
  const lines = content.split(`
4200
4418
  `);
4201
4419
  lines.splice(lastEdit.insert_line - 1, 1);
@@ -5326,19 +5544,19 @@ class OpenAICompatibleProvider {
5326
5544
  }
5327
5545
 
5328
5546
  // src/utils/custom-instructions.ts
5329
- import * as path7 from "path";
5547
+ import * as path8 from "path";
5330
5548
  import * as os2 from "os";
5331
- import * as fs8 from "fs";
5549
+ import * as fs9 from "fs";
5332
5550
  function loadCustomInstructions(workingDirectory = process.cwd()) {
5333
5551
  try {
5334
- let instructionsPath = path7.join(workingDirectory, ".super-agent", "SUPER_AGENT.md");
5335
- if (fs8.existsSync(instructionsPath)) {
5336
- const customInstructions = fs8.readFileSync(instructionsPath, "utf-8");
5552
+ let instructionsPath = path8.join(workingDirectory, ".super-agent", "SUPER_AGENT.md");
5553
+ if (fs9.existsSync(instructionsPath)) {
5554
+ const customInstructions = fs9.readFileSync(instructionsPath, "utf-8");
5337
5555
  return customInstructions.trim();
5338
5556
  }
5339
- instructionsPath = path7.join(os2.homedir(), ".super-agent", "SUPER_AGENT.md");
5340
- if (fs8.existsSync(instructionsPath)) {
5341
- const customInstructions = fs8.readFileSync(instructionsPath, "utf-8");
5557
+ instructionsPath = path8.join(os2.homedir(), ".super-agent", "SUPER_AGENT.md");
5558
+ if (fs9.existsSync(instructionsPath)) {
5559
+ const customInstructions = fs9.readFileSync(instructionsPath, "utf-8");
5342
5560
  return customInstructions.trim();
5343
5561
  }
5344
5562
  return null;
@@ -5770,6 +5988,30 @@ IMPORTANT RESPONSE GUIDELINES:
5770
5988
  Current working directory: ${process.cwd()}`
5771
5989
  });
5772
5990
  }
5991
+ setProvider(providerId) {
5992
+ const manager = getSettingsManager();
5993
+ const settings = manager.loadUserSettings();
5994
+ const activeProviderId = (providerId || "grok").toLowerCase();
5995
+ if (activeProviderId === "zai") {}
5996
+ const providerConfig = settings.providers[activeProviderId];
5997
+ if (!providerConfig) {
5998
+ throw new Error(`Provider '${activeProviderId}' not configured.`);
5999
+ }
6000
+ const providerType = providerConfig.provider || activeProviderId;
6001
+ const effectiveApiKey = providerConfig.api_key || "";
6002
+ const effectiveBaseURL = providerConfig.base_url || undefined;
6003
+ const effectiveModel = providerConfig.model || providerConfig.default_model || "grok-code-fast-1";
6004
+ if (providerType === "openai") {
6005
+ this.superAgentClient = new OpenAIProvider(effectiveApiKey, effectiveBaseURL, effectiveModel);
6006
+ } else if (providerType === "gemini" || providerType === "google") {
6007
+ this.superAgentClient = new GeminiProvider(effectiveApiKey, effectiveBaseURL, effectiveModel);
6008
+ } else if (providerType === "grok") {
6009
+ this.superAgentClient = new GrokProvider(effectiveApiKey, effectiveBaseURL, effectiveModel);
6010
+ } else {
6011
+ this.superAgentClient = new OpenAICompatibleProvider(effectiveApiKey, effectiveBaseURL || "", effectiveModel, activeProviderId);
6012
+ }
6013
+ this.tokenCounter = createTokenCounter(effectiveModel);
6014
+ }
5773
6015
  async initializeMCP() {
5774
6016
  Promise.resolve().then(async () => {
5775
6017
  try {
@@ -7211,7 +7453,7 @@ import { program } from "commander";
7211
7453
  // package.json
7212
7454
  var package_default = {
7213
7455
  name: "@involvex/super-agent-cli",
7214
- version: "0.0.48",
7456
+ version: "0.0.50",
7215
7457
  description: "An open-source AI agent that brings the power of Super Agent directly into your terminal.",
7216
7458
  keywords: [
7217
7459
  "cli",
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@involvex/super-agent-cli",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "description": "An open-source AI agent that brings the power of Super Agent directly into your terminal.",
5
5
  "keywords": [
6
6
  "cli",