@xagent/x-cli 1.1.66 → 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.66 – 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.66",
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",