@xagent/x-cli 1.1.42 → 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 +1 -1
- package/dist/index.js +192 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
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,
|
|
7036
|
+
const dfs = (filePath, path29) => {
|
|
7037
7037
|
if (visiting.has(filePath)) {
|
|
7038
|
-
const cycleStart =
|
|
7039
|
-
const cycle =
|
|
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, [...
|
|
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
|
|
9028
|
-
let command = `cat "${
|
|
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' "${
|
|
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.
|
|
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",
|
|
@@ -11882,7 +11882,7 @@ Documentation for documentation system commands:
|
|
|
11882
11882
|
async generateSystemDocs(agentPath) {
|
|
11883
11883
|
const systemPath = path7__default.join(agentPath, "system");
|
|
11884
11884
|
const files = [];
|
|
11885
|
-
const archContent = this.config.projectType === "
|
|
11885
|
+
const archContent = this.config.projectType === "x-cli" ? this.generateGrokArchitecture() : this.generateExternalArchitecture();
|
|
11886
11886
|
await ops6.promises.writeFile(path7__default.join(systemPath, "architecture.md"), archContent);
|
|
11887
11887
|
files.push(".agent/system/architecture.md");
|
|
11888
11888
|
const criticalStateContent = this.generateCriticalState();
|
|
@@ -11997,7 +11997,7 @@ External project documented using Grok CLI's .agent system.
|
|
|
11997
11997
|
}
|
|
11998
11998
|
generateCriticalState() {
|
|
11999
11999
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
12000
|
-
if (this.config.projectType === "
|
|
12000
|
+
if (this.config.projectType === "x-cli") {
|
|
12001
12001
|
return `# \u{1F527} Current System State
|
|
12002
12002
|
|
|
12003
12003
|
## Architecture Overview
|
|
@@ -12083,7 +12083,7 @@ Updated By: Agent System Generator during /init-agent
|
|
|
12083
12083
|
}
|
|
12084
12084
|
}
|
|
12085
12085
|
generateApiSchema() {
|
|
12086
|
-
if (this.config.projectType === "
|
|
12086
|
+
if (this.config.projectType === "x-cli") {
|
|
12087
12087
|
return `# \u{1F50C} API Schema
|
|
12088
12088
|
|
|
12089
12089
|
## Grok API Integration
|
|
@@ -12248,7 +12248,7 @@ interface Tool {
|
|
|
12248
12248
|
`;
|
|
12249
12249
|
await ops6.promises.writeFile(path7__default.join(sopPath, "documentation-workflow.md"), docWorkflowContent);
|
|
12250
12250
|
files.push(".agent/sop/documentation-workflow.md");
|
|
12251
|
-
if (this.config.projectType === "
|
|
12251
|
+
if (this.config.projectType === "x-cli") {
|
|
12252
12252
|
const newCommandContent = `# \u2699\uFE0F Adding New Commands SOP
|
|
12253
12253
|
|
|
12254
12254
|
## Command System Architecture
|
|
@@ -12329,7 +12329,7 @@ Create tool in \`src/tools/\`, then reference in command handler.
|
|
|
12329
12329
|
async generateExampleTask(agentPath) {
|
|
12330
12330
|
const tasksPath = path7__default.join(agentPath, "tasks");
|
|
12331
12331
|
const files = [];
|
|
12332
|
-
const exampleContent = this.config.projectType === "
|
|
12332
|
+
const exampleContent = this.config.projectType === "x-cli" ? this.generateGrokExampleTask() : this.generateExternalExampleTask();
|
|
12333
12333
|
await ops6.promises.writeFile(path7__default.join(tasksPath, "example-prd.md"), exampleContent);
|
|
12334
12334
|
files.push(".agent/tasks/example-prd.md");
|
|
12335
12335
|
return files;
|
|
@@ -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,
|
|
@@ -15229,7 +15230,7 @@ Use \`/upgrade\` to update automatically or run:
|
|
|
15229
15230
|
\`${versionInfo.updateCommand}\`` : "\u2705 **You are up to date!**"}
|
|
15230
15231
|
|
|
15231
15232
|
Package: ${package_default.name}
|
|
15232
|
-
GitHub: https://github.com/
|
|
15233
|
+
GitHub: https://github.com/x-cli-team/x-cli
|
|
15233
15234
|
NPM: https://www.npmjs.com/package/${package_default.name}`,
|
|
15234
15235
|
timestamp: /* @__PURE__ */ new Date()
|
|
15235
15236
|
};
|
|
@@ -15542,9 +15543,9 @@ ${commitMessage}`
|
|
|
15542
15543
|
setChatHistory((prev) => [...prev, userEntry]);
|
|
15543
15544
|
setIsProcessing(true);
|
|
15544
15545
|
try {
|
|
15545
|
-
const
|
|
15546
|
-
const projectType =
|
|
15547
|
-
const projectName =
|
|
15546
|
+
const isXCli = process.cwd().includes("x-cli") || trimmedInput.includes("--xcli");
|
|
15547
|
+
const projectType = isXCli ? "x-cli" : "external";
|
|
15548
|
+
const projectName = isXCli ? "X CLI" : "Current Project";
|
|
15548
15549
|
const generator = new AgentSystemGenerator({
|
|
15549
15550
|
projectName,
|
|
15550
15551
|
projectType,
|
|
@@ -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",
|
|
@@ -16665,6 +16800,19 @@ var truncateContent = (content, maxLength = 100) => {
|
|
|
16665
16800
|
if (process.env.COMPACT !== "1") return content;
|
|
16666
16801
|
return content.length > maxLength ? content.substring(0, maxLength) + "..." : content;
|
|
16667
16802
|
};
|
|
16803
|
+
var handleLongContent = (content, maxLength = 5e3) => {
|
|
16804
|
+
if (content.length <= maxLength) {
|
|
16805
|
+
return { content, isTruncated: false };
|
|
16806
|
+
}
|
|
16807
|
+
const truncated = content.substring(0, maxLength);
|
|
16808
|
+
const summary = `
|
|
16809
|
+
|
|
16810
|
+
[Content truncated - ${content.length - maxLength} characters remaining. Full content available in chat history.]`;
|
|
16811
|
+
return {
|
|
16812
|
+
content: truncated + summary,
|
|
16813
|
+
isTruncated: true
|
|
16814
|
+
};
|
|
16815
|
+
};
|
|
16668
16816
|
var MemoizedChatEntry = React3.memo(
|
|
16669
16817
|
({ entry, index }) => {
|
|
16670
16818
|
const renderDiff = (diffContent, filename) => {
|
|
@@ -16704,17 +16852,19 @@ var MemoizedChatEntry = React3.memo(
|
|
|
16704
16852
|
truncateContent(displayText)
|
|
16705
16853
|
] }) }) }, index);
|
|
16706
16854
|
case "assistant":
|
|
16855
|
+
const { content: processedContent, isTruncated } = handleLongContent(entry.content);
|
|
16707
16856
|
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginTop: 1, children: /* @__PURE__ */ jsxs(Box, { flexDirection: "row", alignItems: "flex-start", children: [
|
|
16708
16857
|
/* @__PURE__ */ jsx(Text, { color: "white", children: "\u23FA " }),
|
|
16709
16858
|
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", flexGrow: 1, children: [
|
|
16710
16859
|
entry.toolCalls ? (
|
|
16711
16860
|
// If there are tool calls, just show plain text
|
|
16712
|
-
/* @__PURE__ */ jsx(Text, { color: "white", children:
|
|
16861
|
+
/* @__PURE__ */ jsx(Text, { color: "white", children: processedContent.trim() })
|
|
16713
16862
|
) : (
|
|
16714
16863
|
// If no tool calls, render as markdown
|
|
16715
|
-
/* @__PURE__ */ jsx(MarkdownRenderer, { content:
|
|
16864
|
+
/* @__PURE__ */ jsx(MarkdownRenderer, { content: processedContent.trim() })
|
|
16716
16865
|
),
|
|
16717
|
-
entry.isStreaming && /* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u2588" })
|
|
16866
|
+
entry.isStreaming && /* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u2588" }),
|
|
16867
|
+
isTruncated && /* @__PURE__ */ jsx(Text, { color: "yellow", italic: true, children: "[Response truncated for performance - full content in session log]" })
|
|
16718
16868
|
] })
|
|
16719
16869
|
] }) }, index);
|
|
16720
16870
|
case "tool_call":
|
|
@@ -17982,7 +18132,7 @@ function ChatInterfaceWithAgent({
|
|
|
17982
18132
|
}
|
|
17983
18133
|
console.log(" ");
|
|
17984
18134
|
console.log(" ");
|
|
17985
|
-
const logoOutput = "
|
|
18135
|
+
const logoOutput = "X-CLI\n" + package_default.version;
|
|
17986
18136
|
const logoLines = logoOutput.split("\n");
|
|
17987
18137
|
logoLines.forEach((line) => {
|
|
17988
18138
|
if (line.trim()) {
|
|
@@ -18616,6 +18766,26 @@ function ensureUserSettingsDirectory() {
|
|
|
18616
18766
|
} catch {
|
|
18617
18767
|
}
|
|
18618
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
|
+
}
|
|
18619
18789
|
async function checkStartupUpdates() {
|
|
18620
18790
|
try {
|
|
18621
18791
|
const versionInfo = await checkForUpdates();
|
|
@@ -18856,6 +19026,7 @@ program.name("grok").description(
|
|
|
18856
19026
|
const agent = new GrokAgent(apiKey, baseURL, model, maxToolRounds);
|
|
18857
19027
|
console.log("\u{1F916} Starting X CLI Conversational Assistant...\n");
|
|
18858
19028
|
ensureUserSettingsDirectory();
|
|
19029
|
+
checkAutoCompact();
|
|
18859
19030
|
checkStartupUpdates();
|
|
18860
19031
|
const initialMessage = Array.isArray(message) ? message.join(" ") : message;
|
|
18861
19032
|
const app = render(React3.createElement(ChatInterface, { agent, initialMessage }));
|