@xagent/x-cli 1.1.65 → 1.1.67

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.65 – Logo Assets & NPM Publication Complete
1
+ ## 1.1.67 – 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
@@ -14655,7 +14655,7 @@ ${guardrail.createdFrom ? `- Created from incident: ${guardrail.createdFrom}` :
14655
14655
  var package_default = {
14656
14656
  type: "module",
14657
14657
  name: "@xagent/x-cli",
14658
- version: "1.1.65",
14658
+ version: "1.1.67",
14659
14659
  description: "An open-source AI agent that brings the power of Grok directly into your terminal.",
14660
14660
  main: "dist/index.js",
14661
14661
  module: "dist/index.js",
@@ -15183,6 +15183,7 @@ Self-Healing & Optimization:
15183
15183
 
15184
15184
  Git Commands:
15185
15185
  /commit-and-push - AI-generated commit + push to remote
15186
+ /smart-push - Intelligent staging, commit message generation, and push
15186
15187
 
15187
15188
  Enhanced Input Features:
15188
15189
  \u2191/\u2193 Arrow - Navigate command history
@@ -16357,6 +16358,181 @@ Operations will now ${newLevel === "off" ? "show no explanations" : newLevel ===
16357
16358
  clearInput();
16358
16359
  return true;
16359
16360
  }
16361
+ if (trimmedInput === "/smart-push") {
16362
+ const userEntry = {
16363
+ type: "user",
16364
+ content: trimmedInput,
16365
+ timestamp: /* @__PURE__ */ new Date()
16366
+ };
16367
+ setChatHistory((prev) => [...prev, userEntry]);
16368
+ setIsProcessing(true);
16369
+ try {
16370
+ const statusResult = await agent.executeBashCommand("git status --porcelain");
16371
+ if (!statusResult.success) {
16372
+ const errorEntry = {
16373
+ type: "assistant",
16374
+ content: "\u274C **Git Error**\n\nUnable to check git status. Are you in a git repository?",
16375
+ timestamp: /* @__PURE__ */ new Date()
16376
+ };
16377
+ setChatHistory((prev) => [...prev, errorEntry]);
16378
+ setIsProcessing(false);
16379
+ clearInput();
16380
+ return true;
16381
+ }
16382
+ if (!statusResult.output || statusResult.output.trim() === "") {
16383
+ const noChangesEntry = {
16384
+ type: "assistant",
16385
+ content: "\u{1F4CB} **No Changes to Push**\n\nWorking directory is clean. No commits to push.",
16386
+ timestamp: /* @__PURE__ */ new Date()
16387
+ };
16388
+ setChatHistory((prev) => [...prev, noChangesEntry]);
16389
+ setIsProcessing(false);
16390
+ clearInput();
16391
+ return true;
16392
+ }
16393
+ const addResult = await agent.executeBashCommand("git add .");
16394
+ if (!addResult.success) {
16395
+ const errorEntry = {
16396
+ type: "assistant",
16397
+ content: `\u274C **Failed to stage changes**
16398
+
16399
+ ${addResult.error || "Unknown error"}`,
16400
+ timestamp: /* @__PURE__ */ new Date()
16401
+ };
16402
+ setChatHistory((prev) => [...prev, errorEntry]);
16403
+ setIsProcessing(false);
16404
+ clearInput();
16405
+ return true;
16406
+ }
16407
+ const addEntry = {
16408
+ type: "tool_result",
16409
+ content: "\u2705 Changes staged successfully",
16410
+ timestamp: /* @__PURE__ */ new Date(),
16411
+ toolCall: {
16412
+ id: `git_add_${Date.now()}`,
16413
+ type: "function",
16414
+ function: {
16415
+ name: "bash",
16416
+ arguments: JSON.stringify({ command: "git add ." })
16417
+ }
16418
+ },
16419
+ toolResult: addResult
16420
+ };
16421
+ setChatHistory((prev) => [...prev, addEntry]);
16422
+ const diffResult = await agent.executeBashCommand("git diff --cached");
16423
+ const commitPrompt = `Generate a concise, professional git commit message for these changes:
16424
+
16425
+ Git Status:
16426
+ ${statusResult.output}
16427
+
16428
+ Git Diff (staged changes):
16429
+ ${diffResult.output || "No staged changes shown"}
16430
+
16431
+ Follow conventional commit format (feat:, fix:, docs:, etc.) and keep it under 72 characters.
16432
+ Respond with ONLY the commit message, no additional text.`;
16433
+ let commitMessage = "";
16434
+ let streamingEntry = null;
16435
+ let accumulatedCommitContent = "";
16436
+ let lastCommitUpdateTime = Date.now();
16437
+ for await (const chunk of agent.processUserMessageStream(commitPrompt)) {
16438
+ if (chunk.type === "content" && chunk.content) {
16439
+ accumulatedCommitContent += chunk.content;
16440
+ const now = Date.now();
16441
+ if (now - lastCommitUpdateTime >= 150) {
16442
+ commitMessage += accumulatedCommitContent;
16443
+ if (!streamingEntry) {
16444
+ const newEntry = {
16445
+ type: "assistant",
16446
+ content: `\u{1F916} Generating commit message...
16447
+
16448
+ ${commitMessage}`,
16449
+ timestamp: /* @__PURE__ */ new Date(),
16450
+ isStreaming: true
16451
+ };
16452
+ setChatHistory((prev) => [...prev, newEntry]);
16453
+ streamingEntry = newEntry;
16454
+ } else {
16455
+ setChatHistory(
16456
+ (prev) => prev.map(
16457
+ (entry, idx) => idx === prev.length - 1 && entry.isStreaming ? {
16458
+ ...entry,
16459
+ content: `\u{1F916} Generating commit message...
16460
+
16461
+ ${commitMessage}`
16462
+ } : entry
16463
+ )
16464
+ );
16465
+ }
16466
+ accumulatedCommitContent = "";
16467
+ lastCommitUpdateTime = now;
16468
+ }
16469
+ } else if (chunk.type === "done") {
16470
+ if (streamingEntry) {
16471
+ setChatHistory(
16472
+ (prev) => prev.map(
16473
+ (entry) => entry.isStreaming ? {
16474
+ ...entry,
16475
+ content: `\u2705 Generated commit message: "${commitMessage.trim()}"`,
16476
+ isStreaming: false
16477
+ } : entry
16478
+ )
16479
+ );
16480
+ }
16481
+ break;
16482
+ }
16483
+ }
16484
+ const cleanCommitMessage = commitMessage.trim().replace(/^["']|["']$/g, "");
16485
+ const commitCommand = `git commit -m "${cleanCommitMessage}"`;
16486
+ const commitResult = await agent.executeBashCommand(commitCommand);
16487
+ const commitEntry = {
16488
+ type: "tool_result",
16489
+ content: commitResult.success ? `\u2705 **Commit Created**: ${commitResult.output?.split("\n")[0] || "Commit successful"}` : `\u274C **Commit Failed**: ${commitResult.error || "Unknown error"}`,
16490
+ timestamp: /* @__PURE__ */ new Date(),
16491
+ toolCall: {
16492
+ id: `git_commit_${Date.now()}`,
16493
+ type: "function",
16494
+ function: {
16495
+ name: "bash",
16496
+ arguments: JSON.stringify({ command: commitCommand })
16497
+ }
16498
+ },
16499
+ toolResult: commitResult
16500
+ };
16501
+ setChatHistory((prev) => [...prev, commitEntry]);
16502
+ if (commitResult.success) {
16503
+ const pushResult = await agent.executeBashCommand("git push");
16504
+ const pushEntry = {
16505
+ type: "tool_result",
16506
+ content: pushResult.success ? `\u{1F680} **Push Successful**: ${pushResult.output?.split("\n")[0] || "Changes pushed to remote"}` : `\u274C **Push Failed**: ${pushResult.error || "Unknown error"}
16507
+
16508
+ Try running \`git push\` manually.`,
16509
+ timestamp: /* @__PURE__ */ new Date(),
16510
+ toolCall: {
16511
+ id: `git_push_${Date.now()}`,
16512
+ type: "function",
16513
+ function: {
16514
+ name: "bash",
16515
+ arguments: JSON.stringify({ command: "git push" })
16516
+ }
16517
+ },
16518
+ toolResult: pushResult
16519
+ };
16520
+ setChatHistory((prev) => [...prev, pushEntry]);
16521
+ }
16522
+ } catch (error) {
16523
+ const errorEntry = {
16524
+ type: "assistant",
16525
+ content: `\u274C **Smart Push Failed**
16526
+
16527
+ ${error instanceof Error ? error.message : String(error)}`,
16528
+ timestamp: /* @__PURE__ */ new Date()
16529
+ };
16530
+ setChatHistory((prev) => [...prev, errorEntry]);
16531
+ }
16532
+ setIsProcessing(false);
16533
+ clearInput();
16534
+ return true;
16535
+ }
16360
16536
  const directBashCommands = [
16361
16537
  "ls",
16362
16538
  "pwd",
@@ -17097,26 +17273,15 @@ function useConfirmations(confirmationService, state) {
17097
17273
  handleRejection
17098
17274
  };
17099
17275
  }
17100
- function useConsoleSetup() {
17276
+ function useConsoleSetup(quiet = false) {
17101
17277
  useEffect(() => {
17278
+ if (quiet) return;
17102
17279
  const isWindows = process.platform === "win32";
17103
17280
  const isPowerShell = process.env.ComSpec?.toLowerCase().includes("powershell") || process.env.PSModulePath !== void 0;
17104
17281
  if (!isWindows || !isPowerShell) {
17105
17282
  console.clear();
17106
17283
  }
17107
- console.log(" ");
17108
- console.log(" ");
17109
- const logoOutput = "X-CLI\n" + package_default.version;
17110
- const logoLines = logoOutput.split("\n");
17111
- logoLines.forEach((line) => {
17112
- if (line.trim()) {
17113
- console.log(" " + line);
17114
- } else {
17115
- console.log(line);
17116
- }
17117
- });
17118
- console.log(" ");
17119
- }, []);
17284
+ }, [quiet]);
17120
17285
  }
17121
17286
  function useSessionLogging(chatHistory) {
17122
17287
  const lastChatHistoryLength = useRef(0);
@@ -18828,7 +18993,8 @@ function ChatInterfaceRenderer({
18828
18993
  }
18829
18994
  function ChatInterfaceWithAgent({
18830
18995
  agent,
18831
- initialMessage
18996
+ initialMessage,
18997
+ quiet = false
18832
18998
  }) {
18833
18999
  const [chatHistory, setChatHistory] = useState([]);
18834
19000
  const [isProcessing, setIsProcessing] = useState(false);
@@ -18838,7 +19004,7 @@ function ChatInterfaceWithAgent({
18838
19004
  const [confirmationOptions, setConfirmationOptions] = useState(null);
18839
19005
  const [showContextTooltip, setShowContextTooltip] = useState(false);
18840
19006
  const processingStartTime = useRef(0);
18841
- useConsoleSetup();
19007
+ useConsoleSetup(quiet);
18842
19008
  useAutoRead(setChatHistory);
18843
19009
  useEffect(() => {
18844
19010
  setChatHistory([]);
@@ -18931,7 +19097,8 @@ function ChatInterfaceWithAgent({
18931
19097
  }
18932
19098
  function ChatInterface({
18933
19099
  agent,
18934
- initialMessage
19100
+ initialMessage,
19101
+ quiet = false
18935
19102
  }) {
18936
19103
  const [currentAgent, setCurrentAgent] = useState(
18937
19104
  agent || null
@@ -18946,7 +19113,8 @@ function ChatInterface({
18946
19113
  ChatInterfaceWithAgent,
18947
19114
  {
18948
19115
  agent: currentAgent,
18949
- initialMessage
19116
+ initialMessage,
19117
+ quiet
18950
19118
  }
18951
19119
  );
18952
19120
  }
@@ -19313,7 +19481,7 @@ Respond with ONLY the commit message, no additional text.`;
19313
19481
  process.exit(1);
19314
19482
  }
19315
19483
  } catch (error) {
19316
- console.error("\u274C Error during commit and push:", error.message);
19484
+ console.error("\u274C Error during commit and push:", error instanceof Error ? error.message : String(error));
19317
19485
  process.exit(1);
19318
19486
  }
19319
19487
  }
@@ -19367,7 +19535,7 @@ async function processPromptHeadless(prompt, apiKey, baseURL, model, maxToolRoun
19367
19535
  console.log(
19368
19536
  JSON.stringify({
19369
19537
  role: "assistant",
19370
- content: `Error: ${error.message}`
19538
+ content: `Error: ${error instanceof Error ? error.message : String(error)}`
19371
19539
  })
19372
19540
  );
19373
19541
  process.exit(1);
@@ -19388,6 +19556,9 @@ program.name("grok").description(
19388
19556
  "--max-tool-rounds <rounds>",
19389
19557
  "maximum number of tool execution rounds (default: 400)",
19390
19558
  "400"
19559
+ ).option(
19560
+ "-q, --quiet",
19561
+ "suppress startup banner and messages"
19391
19562
  ).action(async (message, options) => {
19392
19563
  if (options.directory) {
19393
19564
  try {
@@ -19429,12 +19600,14 @@ program.name("grok").description(
19429
19600
  process.exit(1);
19430
19601
  }
19431
19602
  const agent = new GrokAgent(apiKey, baseURL, model, maxToolRounds);
19432
- console.log("\u{1F916} Starting X CLI Conversational Assistant...\n");
19603
+ if (!options.quiet) {
19604
+ console.log("\u{1F916} Starting X CLI Conversational Assistant...\n");
19605
+ }
19433
19606
  ensureUserSettingsDirectory();
19434
19607
  checkAutoCompact();
19435
19608
  checkStartupUpdates();
19436
19609
  const initialMessage = Array.isArray(message) ? message.join(" ") : message;
19437
- const app = render(React4.createElement(ChatInterface, { agent, initialMessage }));
19610
+ const app = render(React4.createElement(ChatInterface, { agent, initialMessage, quiet: options.quiet }));
19438
19611
  const cleanup = () => {
19439
19612
  app.unmount();
19440
19613
  agent.abortCurrentOperation();