@xagent/x-cli 1.1.43 → 1.1.44

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## 1.1.43 – Logo Assets & NPM Publication Complete
1
+ ## 1.1.44 – Logo Assets & NPM Publication Complete
2
2
 
3
3
  ✅ **Live on NPM**: [@xagent/x-cli](https://www.npmjs.com/package/@xagent/x-cli) - Fully published and ready for global installation
4
4
 
package/dist/index.js CHANGED
@@ -7033,10 +7033,10 @@ var DependencyAnalyzerTool = class {
7033
7033
  const circularDeps = [];
7034
7034
  const visited = /* @__PURE__ */ new Set();
7035
7035
  const visiting = /* @__PURE__ */ new Set();
7036
- const dfs = (filePath, path28) => {
7036
+ const dfs = (filePath, path29) => {
7037
7037
  if (visiting.has(filePath)) {
7038
- const cycleStart = path28.indexOf(filePath);
7039
- const cycle = path28.slice(cycleStart).concat([filePath]);
7038
+ const cycleStart = path29.indexOf(filePath);
7039
+ const cycle = path29.slice(cycleStart).concat([filePath]);
7040
7040
  circularDeps.push({
7041
7041
  cycle: cycle.map((fp) => graph.nodes.get(fp)?.filePath || fp),
7042
7042
  severity: cycle.length <= 2 ? "error" : "warning",
@@ -7052,7 +7052,7 @@ var DependencyAnalyzerTool = class {
7052
7052
  if (node) {
7053
7053
  for (const dependency of node.dependencies) {
7054
7054
  if (graph.nodes.has(dependency)) {
7055
- dfs(dependency, [...path28, filePath]);
7055
+ dfs(dependency, [...path29, filePath]);
7056
7056
  }
7057
7057
  }
7058
7058
  }
@@ -9024,10 +9024,10 @@ Current working directory: ${process.cwd()}`
9024
9024
  return await this.textEditor.view(args.path, range);
9025
9025
  } catch (error) {
9026
9026
  console.warn(`view_file tool failed, falling back to bash: ${error.message}`);
9027
- const path28 = args.path;
9028
- let command = `cat "${path28}"`;
9027
+ const path29 = args.path;
9028
+ let command = `cat "${path29}"`;
9029
9029
  if (args.start_line && args.end_line) {
9030
- command = `sed -n '${args.start_line},${args.end_line}p' "${path28}"`;
9030
+ command = `sed -n '${args.start_line},${args.end_line}p' "${path29}"`;
9031
9031
  }
9032
9032
  return await this.bash.execute(command);
9033
9033
  }
@@ -9287,7 +9287,7 @@ EOF`;
9287
9287
  var package_default = {
9288
9288
  type: "module",
9289
9289
  name: "@xagent/x-cli",
9290
- version: "1.1.43",
9290
+ version: "1.1.44",
9291
9291
  description: "An open-source AI agent that brings the power of Grok directly into your terminal.",
9292
9292
  main: "dist/index.js",
9293
9293
  module: "dist/index.js",
@@ -14853,6 +14853,7 @@ async function getCachedVersionInfo() {
14853
14853
  }
14854
14854
 
14855
14855
  // src/hooks/use-input-handler.ts
14856
+ init_settings_manager();
14856
14857
  function useInputHandler({
14857
14858
  agent,
14858
14859
  chatHistory,
@@ -16090,6 +16091,140 @@ ${incidents.slice(0, 3).map((i) => `- ${i.title} (${i.impact} impact)`).join("\n
16090
16091
  clearInput();
16091
16092
  return true;
16092
16093
  }
16094
+ if (trimmedInput === "/switch" || trimmedInput.startsWith("/switch ")) {
16095
+ const userEntry = {
16096
+ type: "user",
16097
+ content: trimmedInput,
16098
+ timestamp: /* @__PURE__ */ new Date()
16099
+ };
16100
+ setChatHistory((prev) => [...prev, userEntry]);
16101
+ setIsProcessing(true);
16102
+ try {
16103
+ const args = trimmedInput.split(" ").slice(1);
16104
+ const settingsManager = getSettingsManager();
16105
+ if (args.length === 0) {
16106
+ const settings = settingsManager.loadUserSettings();
16107
+ const autoCompact = settings.autoCompact ?? false;
16108
+ const thresholds = settings.compactThreshold || { lines: 800, bytes: 2e5 };
16109
+ const statusEntry = {
16110
+ type: "assistant",
16111
+ content: `\u{1F504} **Auto-Compact Status**
16112
+
16113
+ **Current Settings:**
16114
+ - Auto-compact: ${autoCompact ? "\u2705 ENABLED" : "\u274C DISABLED"}
16115
+ - Line threshold: ${thresholds.lines || 800} lines
16116
+ - Size threshold: ${Math.round((thresholds.bytes || 2e5) / 1024)}KB
16117
+
16118
+ **Commands:**
16119
+ - \`/switch compact on\` - Enable auto-compact
16120
+ - \`/switch compact off\` - Disable auto-compact
16121
+ - \`/switch compact lines 500\` - Set line threshold
16122
+ - \`/switch compact bytes 100000\` - Set size threshold (in bytes)
16123
+
16124
+ **How it works:**
16125
+ Auto-compact automatically enables compact mode when conversations exceed thresholds, similar to Claude Code's context management.`,
16126
+ timestamp: /* @__PURE__ */ new Date()
16127
+ };
16128
+ setChatHistory((prev) => [...prev, statusEntry]);
16129
+ } else if (args[0] === "compact") {
16130
+ if (args[1] === "on") {
16131
+ settingsManager.updateUserSetting("autoCompact", true);
16132
+ const successEntry = {
16133
+ type: "assistant",
16134
+ content: "\u2705 **Auto-compact enabled!**\n\nCompact mode will automatically activate for long conversations to maintain performance.",
16135
+ timestamp: /* @__PURE__ */ new Date()
16136
+ };
16137
+ setChatHistory((prev) => [...prev, successEntry]);
16138
+ } else if (args[1] === "off") {
16139
+ settingsManager.updateUserSetting("autoCompact", false);
16140
+ const successEntry = {
16141
+ type: "assistant",
16142
+ content: "\u274C **Auto-compact disabled**\n\nNormal conversation mode will be used.",
16143
+ timestamp: /* @__PURE__ */ new Date()
16144
+ };
16145
+ setChatHistory((prev) => [...prev, successEntry]);
16146
+ } else if (args[1] === "lines" && args[2]) {
16147
+ const lines = parseInt(args[2]);
16148
+ if (isNaN(lines) || lines < 100) {
16149
+ const errorEntry = {
16150
+ type: "assistant",
16151
+ content: "\u274C Invalid line threshold. Must be a number >= 100.",
16152
+ timestamp: /* @__PURE__ */ new Date()
16153
+ };
16154
+ setChatHistory((prev) => [...prev, errorEntry]);
16155
+ } else {
16156
+ const currentThresholds = settingsManager.getUserSetting("compactThreshold") || {};
16157
+ settingsManager.updateUserSetting("compactThreshold", {
16158
+ ...currentThresholds,
16159
+ lines
16160
+ });
16161
+ const successEntry = {
16162
+ type: "assistant",
16163
+ content: `\u2705 **Line threshold updated to ${lines} lines**`,
16164
+ timestamp: /* @__PURE__ */ new Date()
16165
+ };
16166
+ setChatHistory((prev) => [...prev, successEntry]);
16167
+ }
16168
+ } else if (args[1] === "bytes" && args[2]) {
16169
+ const bytes = parseInt(args[2]);
16170
+ if (isNaN(bytes) || bytes < 1e4) {
16171
+ const errorEntry = {
16172
+ type: "assistant",
16173
+ content: "\u274C Invalid size threshold. Must be a number >= 10000 bytes.",
16174
+ timestamp: /* @__PURE__ */ new Date()
16175
+ };
16176
+ setChatHistory((prev) => [...prev, errorEntry]);
16177
+ } else {
16178
+ const currentThresholds = settingsManager.getUserSetting("compactThreshold") || {};
16179
+ settingsManager.updateUserSetting("compactThreshold", {
16180
+ ...currentThresholds,
16181
+ bytes
16182
+ });
16183
+ const successEntry = {
16184
+ type: "assistant",
16185
+ content: `\u2705 **Size threshold updated to ${Math.round(bytes / 1024)}KB**`,
16186
+ timestamp: /* @__PURE__ */ new Date()
16187
+ };
16188
+ setChatHistory((prev) => [...prev, successEntry]);
16189
+ }
16190
+ } else {
16191
+ const helpEntry = {
16192
+ type: "assistant",
16193
+ content: `\u2753 **Invalid compact command**
16194
+
16195
+ **Usage:**
16196
+ - \`/switch compact on\` - Enable auto-compact
16197
+ - \`/switch compact off\` - Disable auto-compact
16198
+ - \`/switch compact lines <number>\` - Set line threshold
16199
+ - \`/switch compact bytes <number>\` - Set size threshold`,
16200
+ timestamp: /* @__PURE__ */ new Date()
16201
+ };
16202
+ setChatHistory((prev) => [...prev, helpEntry]);
16203
+ }
16204
+ } else {
16205
+ const helpEntry = {
16206
+ type: "assistant",
16207
+ content: `\u2753 **Unknown switch command**
16208
+
16209
+ **Available switches:**
16210
+ - \`/switch compact\` - Manage auto-compact settings
16211
+ - \`/switch\` - Show current status`,
16212
+ timestamp: /* @__PURE__ */ new Date()
16213
+ };
16214
+ setChatHistory((prev) => [...prev, helpEntry]);
16215
+ }
16216
+ } catch (error) {
16217
+ const errorEntry = {
16218
+ type: "assistant",
16219
+ content: `Failed to manage switches: ${error.message}`,
16220
+ timestamp: /* @__PURE__ */ new Date()
16221
+ };
16222
+ setChatHistory((prev) => [...prev, errorEntry]);
16223
+ }
16224
+ setIsProcessing(false);
16225
+ clearInput();
16226
+ return true;
16227
+ }
16093
16228
  const directBashCommands = [
16094
16229
  "ls",
16095
16230
  "pwd",
@@ -17997,7 +18132,7 @@ function ChatInterfaceWithAgent({
17997
18132
  }
17998
18133
  console.log(" ");
17999
18134
  console.log(" ");
18000
- const logoOutput = "GROK CLI - HURRY MODE\n" + package_default.version;
18135
+ const logoOutput = "X-CLI\n" + package_default.version;
18001
18136
  const logoLines = logoOutput.split("\n");
18002
18137
  logoLines.forEach((line) => {
18003
18138
  if (line.trim()) {
@@ -18631,6 +18766,26 @@ function ensureUserSettingsDirectory() {
18631
18766
  } catch {
18632
18767
  }
18633
18768
  }
18769
+ function checkAutoCompact() {
18770
+ try {
18771
+ const manager = getSettingsManager();
18772
+ const settings = manager.loadUserSettings();
18773
+ if (!settings.autoCompact) {
18774
+ return;
18775
+ }
18776
+ const sessionLogPath = path7__default.join(__require("os").homedir(), ".grok", "session.log");
18777
+ const thresholds = settings.compactThreshold || { lines: 800, bytes: 2e5 };
18778
+ if (__require("fs").existsSync(sessionLogPath)) {
18779
+ const stats = __require("fs").statSync(sessionLogPath);
18780
+ const lines = parseInt(__require("child_process").execSync(`wc -l < "${sessionLogPath}"`, { encoding: "utf8" }).trim()) || 0;
18781
+ if (lines >= (thresholds.lines || 800) || stats.size >= (thresholds.bytes || 2e5)) {
18782
+ process.env.COMPACT = "1";
18783
+ console.log(`\u{1F504} Auto-compact enabled (${lines} lines, ${Math.round(stats.size / 1024)}KB)`);
18784
+ }
18785
+ }
18786
+ } catch {
18787
+ }
18788
+ }
18634
18789
  async function checkStartupUpdates() {
18635
18790
  try {
18636
18791
  const versionInfo = await checkForUpdates();
@@ -18871,6 +19026,7 @@ program.name("grok").description(
18871
19026
  const agent = new GrokAgent(apiKey, baseURL, model, maxToolRounds);
18872
19027
  console.log("\u{1F916} Starting X CLI Conversational Assistant...\n");
18873
19028
  ensureUserSettingsDirectory();
19029
+ checkAutoCompact();
18874
19030
  checkStartupUpdates();
18875
19031
  const initialMessage = Array.isArray(message) ? message.join(" ") : message;
18876
19032
  const app = render(React3.createElement(ChatInterface, { agent, initialMessage }));