@xagent/x-cli 1.1.99 → 1.1.101

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
@@ -18638,7 +18638,7 @@ var init_package = __esm({
18638
18638
  package_default = {
18639
18639
  type: "module",
18640
18640
  name: "@xagent/one-shot",
18641
- version: "1.1.99",
18641
+ version: "1.1.101",
18642
18642
  description: "An open-source AI agent that brings advanced AI capabilities directly into your terminal with automatic documentation updates.",
18643
18643
  main: "dist/index.js",
18644
18644
  module: "dist/index.js",
@@ -20419,7 +20419,7 @@ Operations will now ${newLevel === "off" ? "show no explanations" : newLevel ===
20419
20419
  clearInput();
20420
20420
  return true;
20421
20421
  }
20422
- if (trimmedInput === "/smart-push") {
20422
+ if (trimmedInput === "/safe-push") {
20423
20423
  const userEntry = {
20424
20424
  type: "user",
20425
20425
  content: trimmedInput,
@@ -20428,88 +20428,106 @@ Operations will now ${newLevel === "off" ? "show no explanations" : newLevel ===
20428
20428
  setChatHistory((prev) => [...prev, userEntry]);
20429
20429
  setIsProcessing(true);
20430
20430
  try {
20431
- const branchResult = await agent.executeBashCommand("git branch --show-current");
20432
- const currentBranch = branchResult.output?.trim() || "unknown";
20433
- const qualityCheckEntry = {
20431
+ const startEntry = {
20434
20432
  type: "assistant",
20435
- content: "\u{1F50D} **Running pre-push quality checks...**",
20433
+ content: "\u{1F680} **Safe Push - Automated Workflow**\n\nRunning quality checks and git operations...",
20436
20434
  timestamp: /* @__PURE__ */ new Date()
20437
20435
  };
20438
- setChatHistory((prev) => [...prev, qualityCheckEntry]);
20436
+ setChatHistory((prev) => [...prev, startEntry]);
20439
20437
  const tsCheckEntry = {
20440
20438
  type: "assistant",
20441
- content: "\u{1F4DD} Checking TypeScript...",
20439
+ content: "\u{1F4DD} **Step 1/5**: Checking TypeScript...",
20442
20440
  timestamp: /* @__PURE__ */ new Date()
20443
20441
  };
20444
20442
  setChatHistory((prev) => [...prev, tsCheckEntry]);
20445
20443
  const tsResult = await agent.executeBashCommand("npm run typecheck");
20446
- if (tsResult.success) {
20447
- const tsSuccessEntry = {
20448
- type: "tool_result",
20449
- content: "\u2705 TypeScript check passed",
20450
- timestamp: /* @__PURE__ */ new Date(),
20451
- toolCall: {
20452
- id: `ts_check_${Date.now()}`,
20453
- type: "function",
20454
- function: {
20455
- name: "bash",
20456
- arguments: JSON.stringify({ command: "npm run typecheck" })
20457
- }
20458
- },
20459
- toolResult: tsResult
20460
- };
20461
- setChatHistory((prev) => [...prev, tsSuccessEntry]);
20462
- } else {
20463
- const tsFailEntry = {
20444
+ const tsResultEntry = {
20445
+ type: "tool_result",
20446
+ content: tsResult.success ? "\u2705 TypeScript check passed" : `\u274C TypeScript errors: ${tsResult.error}`,
20447
+ timestamp: /* @__PURE__ */ new Date(),
20448
+ toolCall: {
20449
+ id: `ts_check_${Date.now()}`,
20450
+ type: "function",
20451
+ function: { name: "bash", arguments: JSON.stringify({ command: "npm run typecheck" }) }
20452
+ },
20453
+ toolResult: tsResult
20454
+ };
20455
+ setChatHistory((prev) => [...prev, tsResultEntry]);
20456
+ if (!tsResult.success) {
20457
+ const errorEntry = {
20464
20458
  type: "assistant",
20465
- content: `\u274C **TypeScript check failed**
20459
+ content: `\u274C **Safe Push Failed: TypeScript Errors**
20466
20460
 
20467
- ${tsResult.error || tsResult.output}`,
20461
+ **Error Details:**
20462
+ \`\`\`
20463
+ ${tsResult.error || "TypeScript compilation failed"}
20464
+ \`\`\`
20465
+
20466
+ **Next Steps:**
20467
+ 1. **Fix the TypeScript errors** shown above
20468
+ 2. **Save your files** after making corrections
20469
+ 3. **Run \`/safe-push\` again** to retry the workflow
20470
+
20471
+ \u{1F4A1} **Common fixes:**
20472
+ \u2022 Add missing type annotations
20473
+ \u2022 Import missing types/modules
20474
+ \u2022 Fix property name typos
20475
+ \u2022 Check function signatures`,
20468
20476
  timestamp: /* @__PURE__ */ new Date()
20469
20477
  };
20470
- setChatHistory((prev) => [...prev, tsFailEntry]);
20478
+ setChatHistory((prev) => [...prev, errorEntry]);
20471
20479
  setIsProcessing(false);
20472
20480
  clearInput();
20473
20481
  return true;
20474
20482
  }
20475
20483
  const lintCheckEntry = {
20476
20484
  type: "assistant",
20477
- content: "\u{1F9F9} Running ESLint...",
20485
+ content: "\u{1F9F9} **Step 2/5**: Running ESLint...",
20478
20486
  timestamp: /* @__PURE__ */ new Date()
20479
20487
  };
20480
20488
  setChatHistory((prev) => [...prev, lintCheckEntry]);
20481
20489
  const lintResult = await agent.executeBashCommand("npm run lint");
20482
- const lintSuccessEntry = {
20490
+ const lintResultEntry = {
20483
20491
  type: "tool_result",
20484
- content: "\u2705 ESLint check completed (warnings allowed)",
20492
+ content: lintResult.success ? "\u2705 ESLint check completed" : `\u274C **Safe Push Failed: ESLint Critical Errors**
20493
+
20494
+ **Error Details:**
20495
+ \`\`\`
20496
+ ${lintResult.error || "ESLint found critical errors"}
20497
+ \`\`\`
20498
+
20499
+ **Next Steps:**
20500
+ 1. **Fix the ESLint errors** shown above
20501
+ 2. **Save your files** after making corrections
20502
+ 3. **Run \`/safe-push\` again** to retry the workflow
20503
+
20504
+ \u{1F4A1} **Common fixes:**
20505
+ \u2022 Remove unused variables/imports
20506
+ \u2022 Fix indentation and spacing
20507
+ \u2022 Add missing semicolons
20508
+ \u2022 Fix naming conventions
20509
+ \u2022 Use \`eslint --fix\` for auto-fixable issues`,
20485
20510
  timestamp: /* @__PURE__ */ new Date(),
20486
20511
  toolCall: {
20487
20512
  id: `lint_check_${Date.now()}`,
20488
20513
  type: "function",
20489
- function: {
20490
- name: "bash",
20491
- arguments: JSON.stringify({ command: "npm run lint" })
20492
- }
20514
+ function: { name: "bash", arguments: JSON.stringify({ command: "npm run lint" }) }
20493
20515
  },
20494
20516
  toolResult: lintResult
20495
20517
  };
20496
- setChatHistory((prev) => [...prev, lintSuccessEntry]);
20518
+ setChatHistory((prev) => [...prev, lintResultEntry]);
20519
+ const statusCheckEntry = {
20520
+ type: "assistant",
20521
+ content: "\u{1F4CB} **Step 3/5**: Checking git status...",
20522
+ timestamp: /* @__PURE__ */ new Date()
20523
+ };
20524
+ setChatHistory((prev) => [...prev, statusCheckEntry]);
20497
20525
  const statusResult = await agent.executeBashCommand("git status --porcelain");
20498
- if (!statusResult.success) {
20499
- const errorEntry = {
20500
- type: "assistant",
20501
- content: "\u274C **Git Error**\n\nUnable to check git status. Are you in a git repository?",
20502
- timestamp: /* @__PURE__ */ new Date()
20503
- };
20504
- setChatHistory((prev) => [...prev, errorEntry]);
20505
- setIsProcessing(false);
20506
- clearInput();
20507
- return true;
20508
- }
20509
- if (!statusResult.output || statusResult.output.trim() === "") {
20526
+ const hasChanges = statusResult.success && statusResult.output?.trim();
20527
+ if (!hasChanges) {
20510
20528
  const noChangesEntry = {
20511
20529
  type: "assistant",
20512
- content: "\u{1F4CB} **No Changes to Push**\n\nWorking directory is clean. No commits to push.",
20530
+ content: "\u2139\uFE0F **No Changes to Commit**: Working tree is clean. Nothing to push!",
20513
20531
  timestamp: /* @__PURE__ */ new Date()
20514
20532
  };
20515
20533
  setChatHistory((prev) => [...prev, noChangesEntry]);
@@ -20517,425 +20535,170 @@ ${tsResult.error || tsResult.output}`,
20517
20535
  clearInput();
20518
20536
  return true;
20519
20537
  }
20520
- const prePullAddResult = await agent.executeBashCommand("git add .");
20521
- if (!prePullAddResult.success) {
20522
- const errorEntry = {
20538
+ const stageEntry = {
20539
+ type: "assistant",
20540
+ content: "\u{1F4E6} **Step 4/5**: Staging changes...",
20541
+ timestamp: /* @__PURE__ */ new Date()
20542
+ };
20543
+ setChatHistory((prev) => [...prev, stageEntry]);
20544
+ const addResult = await agent.executeBashCommand("git add .");
20545
+ const addResultEntry = {
20546
+ type: "tool_result",
20547
+ content: addResult.success ? "\u2705 Changes staged successfully" : `\u274C Failed to stage: ${addResult.error}`,
20548
+ timestamp: /* @__PURE__ */ new Date(),
20549
+ toolCall: {
20550
+ id: `git_add_${Date.now()}`,
20551
+ type: "function",
20552
+ function: { name: "bash", arguments: JSON.stringify({ command: "git add ." }) }
20553
+ },
20554
+ toolResult: addResult
20555
+ };
20556
+ setChatHistory((prev) => [...prev, addResultEntry]);
20557
+ if (!addResult.success) {
20558
+ const stagingErrorEntry = {
20523
20559
  type: "assistant",
20524
- content: `\u274C **Failed to stage changes**
20560
+ content: `\u274C **Safe Push Failed: Git Staging Error**
20525
20561
 
20526
- ${prePullAddResult.error || "Unknown error"}`,
20527
- timestamp: /* @__PURE__ */ new Date()
20528
- };
20529
- setChatHistory((prev) => [...prev, errorEntry]);
20530
- setIsProcessing(false);
20531
- clearInput();
20532
- return true;
20533
- }
20534
- const stashResult = await agent.executeBashCommand("git stash push --include-untracked --message 'smart-push temporary stash'");
20535
- if (!stashResult.success) {
20536
- const errorEntry = {
20537
- type: "assistant",
20538
- content: `\u274C **Failed to stash changes**
20562
+ **Error Details:**
20563
+ \`\`\`
20564
+ ${addResult.error || "Failed to stage changes"}
20565
+ \`\`\`
20539
20566
 
20540
- ${stashResult.error || "Unknown error"}`,
20567
+ **Next Steps:**
20568
+ 1. **Check git status**: Run \`git status\` to see what's wrong
20569
+ 2. **Check file permissions**: Ensure files are writable
20570
+ 3. **Check .gitignore**: Make sure files aren't being ignored
20571
+ 4. **Manual staging**: Try \`git add <specific-file>\` for individual files
20572
+
20573
+ \u{1F4A1} **Common causes:**
20574
+ \u2022 File permission issues
20575
+ \u2022 Large files exceeding git limits
20576
+ \u2022 Corrupted git repository
20577
+ \u2022 Disk space issues`,
20541
20578
  timestamp: /* @__PURE__ */ new Date()
20542
20579
  };
20543
- setChatHistory((prev) => [...prev, errorEntry]);
20580
+ setChatHistory((prev) => [...prev, stagingErrorEntry]);
20544
20581
  setIsProcessing(false);
20545
20582
  clearInput();
20546
20583
  return true;
20547
20584
  }
20548
- const pullEntry = {
20585
+ const commitEntry = {
20549
20586
  type: "assistant",
20550
- content: "\u{1F504} Pulling latest changes...",
20587
+ content: "\u{1F4BE} **Step 5/5**: Creating commit...",
20551
20588
  timestamp: /* @__PURE__ */ new Date()
20552
20589
  };
20553
- setChatHistory((prev) => [...prev, pullEntry]);
20554
- const rebaseCheck = await agent.executeBashCommand("test -d .git/rebase-apply -o -d .git/rebase-merge -o -f .git/MERGE_HEAD && echo 'ongoing' || echo 'clean'");
20555
- if (rebaseCheck.output?.includes("ongoing")) {
20556
- const cleanupEntry = {
20557
- type: "assistant",
20558
- content: "\u26A0\uFE0F Git operation in progress - cleaning up...",
20559
- timestamp: /* @__PURE__ */ new Date()
20560
- };
20561
- setChatHistory((prev) => [...prev, cleanupEntry]);
20562
- await agent.executeBashCommand("git rebase --abort 2>/dev/null || git merge --abort 2>/dev/null || true");
20563
- }
20564
- let pullResult = await agent.executeBashCommand(`git pull --rebase origin ${currentBranch}`);
20565
- if (!pullResult.success) {
20566
- pullResult = await agent.executeBashCommand(`git pull origin ${currentBranch}`);
20567
- if (pullResult.success) {
20568
- const mergeFallbackEntry = {
20569
- type: "assistant",
20570
- content: "\u26A0\uFE0F Rebase failed, fell back to merge",
20571
- timestamp: /* @__PURE__ */ new Date()
20572
- };
20573
- setChatHistory((prev) => [...prev, mergeFallbackEntry]);
20574
- }
20575
- }
20576
- if (pullResult.success) {
20577
- const pullSuccessEntry = {
20578
- type: "tool_result",
20579
- content: pullResult.output?.includes("Successfully rebased") ? "\u2705 Successfully rebased local changes" : "\u2705 Successfully pulled latest changes",
20580
- timestamp: /* @__PURE__ */ new Date()
20581
- };
20582
- setChatHistory((prev) => [...prev, pullSuccessEntry]);
20583
- const popStashResult = await agent.executeBashCommand("git stash pop");
20584
- if (!popStashResult.success) {
20585
- const errorEntry = {
20586
- type: "assistant",
20587
- content: `\u26A0\uFE0F **Failed to restore stashed changes**
20588
-
20589
- ${popStashResult.error || "Unknown error"}
20590
-
20591
- \u{1F4A1} Your changes may be lost. Check git stash list.`,
20592
- timestamp: /* @__PURE__ */ new Date()
20593
- };
20594
- setChatHistory((prev) => [...prev, errorEntry]);
20595
- setIsProcessing(false);
20596
- clearInput();
20597
- return true;
20598
- } else {
20599
- const popSuccessEntry = {
20600
- type: "tool_result",
20601
- content: "\u2705 Changes restored from stash",
20602
- timestamp: /* @__PURE__ */ new Date()
20603
- };
20604
- setChatHistory((prev) => [...prev, popSuccessEntry]);
20605
- }
20606
- } else {
20607
- const pullFailEntry = {
20608
- type: "assistant",
20609
- content: `\u274C **Pull failed**
20610
-
20611
- ${pullResult.error || pullResult.output}
20590
+ setChatHistory((prev) => [...prev, commitEntry]);
20591
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 16).replace("T", " ");
20592
+ const commitMsg = `feat: update files - ${timestamp}`;
20593
+ const commitResult = await agent.executeBashCommand(`git commit -m "${commitMsg}"`);
20594
+ const commitResultEntry = {
20595
+ type: "tool_result",
20596
+ content: commitResult.success ? `\u2705 Commit created: "${commitMsg}"` : `\u274C **Safe Push Failed: Git Commit Error**
20612
20597
 
20613
- \u{1F4A1} Check git status and resolve any conflicts`,
20614
- timestamp: /* @__PURE__ */ new Date()
20615
- };
20616
- setChatHistory((prev) => [...prev, pullFailEntry]);
20617
- setIsProcessing(false);
20618
- clearInput();
20619
- return true;
20620
- }
20621
- const addResult = await agent.executeBashCommand("git add .");
20622
- if (!addResult.success) {
20623
- const errorEntry = {
20624
- type: "assistant",
20625
- content: `\u274C **Failed to stage changes**
20598
+ **Error Details:**
20599
+ \`\`\`
20600
+ ${commitResult.error || "Git commit failed"}
20601
+ \`\`\`
20626
20602
 
20627
- ${addResult.error || "Unknown error"}`,
20628
- timestamp: /* @__PURE__ */ new Date()
20629
- };
20630
- setChatHistory((prev) => [...prev, errorEntry]);
20603
+ **Next Steps:**
20604
+ 1. **Check git config**: Ensure user.name and user.email are set
20605
+ 2. **Check staged files**: Run \`git status\` to verify staged changes
20606
+ 3. **Manual commit**: Try \`git commit\` manually with your own message
20607
+ 4. **Reset staging**: Use \`git reset\` if needed to unstage problematic files
20608
+
20609
+ \u{1F4A1} **Common causes:**
20610
+ \u2022 Missing git configuration (name/email)
20611
+ \u2022 Empty commit (no staged changes)
20612
+ \u2022 Commit message formatting issues
20613
+ \u2022 Git hooks blocking the commit`,
20614
+ timestamp: /* @__PURE__ */ new Date(),
20615
+ toolCall: {
20616
+ id: `git_commit_${Date.now()}`,
20617
+ type: "function",
20618
+ function: { name: "bash", arguments: JSON.stringify({ command: `git commit -m "${commitMsg}"` }) }
20619
+ },
20620
+ toolResult: commitResult
20621
+ };
20622
+ setChatHistory((prev) => [...prev, commitResultEntry]);
20623
+ if (!commitResult.success) {
20631
20624
  setIsProcessing(false);
20632
20625
  clearInput();
20633
20626
  return true;
20634
20627
  }
20635
- const addEntry = {
20628
+ const pushEntry = {
20629
+ type: "assistant",
20630
+ content: "\u{1F680} **Pushing to remote...**",
20631
+ timestamp: /* @__PURE__ */ new Date()
20632
+ };
20633
+ setChatHistory((prev) => [...prev, pushEntry]);
20634
+ const pushResult = await agent.executeBashCommand("git push");
20635
+ const pushResultEntry = {
20636
20636
  type: "tool_result",
20637
- content: "\u2705 Changes staged successfully",
20637
+ content: pushResult.success ? "\u{1F389} **Safe Push Completed Successfully!**" : `\u274C **Safe Push Failed: Git Push Error**
20638
+
20639
+ **Error Details:**
20640
+ \`\`\`
20641
+ ${pushResult.error || "Git push failed"}
20642
+ \`\`\`
20643
+
20644
+ **Next Steps:**
20645
+ 1. **Pull latest changes**: Run \`git pull --rebase\` to get remote updates
20646
+ 2. **Resolve conflicts**: If there are merge conflicts, resolve them manually
20647
+ 3. **Try again**: Run \`/safe-push\` again after resolving issues
20648
+ 4. **Alternative**: Use \`npm run smart-push\` for complex scenarios
20649
+
20650
+ \u{1F4A1} **Common causes:**
20651
+ \u2022 Remote has new commits (fetch first)
20652
+ \u2022 Branch protection rules
20653
+ \u2022 Authentication issues
20654
+ \u2022 Network connectivity problems`,
20638
20655
  timestamp: /* @__PURE__ */ new Date(),
20639
20656
  toolCall: {
20640
- id: `git_add_${Date.now()}`,
20657
+ id: `git_push_${Date.now()}`,
20641
20658
  type: "function",
20642
- function: {
20643
- name: "bash",
20644
- arguments: JSON.stringify({ command: "git add ." })
20645
- }
20659
+ function: { name: "bash", arguments: JSON.stringify({ command: "git push" }) }
20646
20660
  },
20647
- toolResult: addResult
20661
+ toolResult: pushResult
20648
20662
  };
20649
- setChatHistory((prev) => [...prev, addEntry]);
20650
- const diffResult = await agent.executeBashCommand("git diff --cached");
20651
- const maxDiffLength = 5e4;
20652
- const truncatedDiff = diffResult.output ? diffResult.output.length > maxDiffLength ? diffResult.output.substring(0, maxDiffLength) + "\n... (truncated due to length)" : diffResult.output : "No staged changes shown";
20653
- const commitPrompt = `Generate a concise, professional git commit message for these changes:
20654
-
20655
- Git Status:
20656
- ${statusResult.output}
20657
-
20658
- Git Diff (staged changes):
20659
- ${truncatedDiff}
20660
-
20661
- Follow conventional commit format (feat:, fix:, docs:, etc.) and keep it under 72 characters.
20662
- Respond with ONLY the commit message, no additional text.`;
20663
- let commitMessage = "";
20664
- let streamingEntry = null;
20665
- let accumulatedCommitContent = "";
20666
- let lastCommitUpdateTime = Date.now();
20667
- try {
20668
- for await (const chunk of agent.processUserMessageStream(commitPrompt)) {
20669
- if (chunk.type === "content" && chunk.content) {
20670
- accumulatedCommitContent += chunk.content;
20671
- const now = Date.now();
20672
- if (now - lastCommitUpdateTime >= 150) {
20673
- commitMessage += accumulatedCommitContent;
20674
- if (!streamingEntry) {
20675
- const newEntry = {
20676
- type: "assistant",
20677
- content: `\u{1F916} Generating commit message...
20678
-
20679
- ${commitMessage}`,
20680
- timestamp: /* @__PURE__ */ new Date(),
20681
- isStreaming: true
20682
- };
20683
- setChatHistory((prev) => [...prev, newEntry]);
20684
- streamingEntry = newEntry;
20685
- } else {
20686
- setChatHistory(
20687
- (prev) => prev.map(
20688
- (entry, idx) => idx === prev.length - 1 && entry.isStreaming ? {
20689
- ...entry,
20690
- content: `\u{1F916} Generating commit message...
20691
-
20692
- ${commitMessage}`
20693
- } : entry
20694
- )
20695
- );
20696
- }
20697
- accumulatedCommitContent = "";
20698
- lastCommitUpdateTime = now;
20699
- }
20700
- } else if (chunk.type === "done") {
20701
- if (streamingEntry) {
20702
- setChatHistory(
20703
- (prev) => prev.map(
20704
- (entry) => entry.isStreaming ? {
20705
- ...entry,
20706
- content: `\u2705 Generated commit message: "${commitMessage.trim()}"`,
20707
- isStreaming: false
20708
- } : entry
20709
- )
20710
- );
20711
- }
20712
- break;
20713
- }
20714
- }
20715
- } catch (error) {
20716
- commitMessage = "feat: update files";
20717
- const errorEntry = {
20718
- type: "assistant",
20719
- content: `\u26A0\uFE0F **AI commit message generation failed**: ${error.message}
20720
-
20721
- Using fallback message: "${commitMessage}"`,
20722
- timestamp: /* @__PURE__ */ new Date()
20723
- };
20724
- setChatHistory((prev) => [...prev, errorEntry]);
20725
- if (streamingEntry) {
20726
- setChatHistory(
20727
- (prev) => prev.map(
20728
- (entry) => entry.isStreaming ? { ...entry, isStreaming: false } : entry
20729
- )
20730
- );
20731
- }
20732
- }
20733
- const cleanCommitMessage = commitMessage.trim().replace(/^["']|["']$/g, "");
20734
- const commitCommand = `git commit -m "${cleanCommitMessage}"`;
20735
- const commitResult = await agent.executeBashCommand(commitCommand);
20736
- const commitEntry = {
20663
+ setChatHistory((prev) => [...prev, pushResultEntry]);
20664
+ } catch (error) {
20665
+ const errorEntry = {
20666
+ type: "assistant",
20667
+ content: `\u274C **Safe Push Failed**: ${error instanceof Error ? error.message : String(error)}`,
20668
+ timestamp: /* @__PURE__ */ new Date()
20669
+ };
20670
+ setChatHistory((prev) => [...prev, errorEntry]);
20671
+ }
20672
+ setIsProcessing(false);
20673
+ clearInput();
20674
+ return true;
20675
+ }
20676
+ if (trimmedInput === "/smart-push") {
20677
+ const userEntry = {
20678
+ type: "user",
20679
+ content: trimmedInput,
20680
+ timestamp: /* @__PURE__ */ new Date()
20681
+ };
20682
+ setChatHistory((prev) => [...prev, userEntry]);
20683
+ setIsProcessing(true);
20684
+ try {
20685
+ const result = await agent.executeBashCommand("npm run smart-push");
20686
+ const resultEntry = {
20737
20687
  type: "tool_result",
20738
- content: commitResult.success ? `\u2705 **Commit Created**: ${commitResult.output?.split("\n")[0] || "Commit successful"}` : `\u274C **Commit Failed**: ${commitResult.error || "Unknown error"}`,
20688
+ content: result.success ? "\u{1F389} Smart Push Completed Successfully!" : `\u274C Smart Push Failed: ${result.error}`,
20739
20689
  timestamp: /* @__PURE__ */ new Date(),
20740
20690
  toolCall: {
20741
- id: `git_commit_${Date.now()}`,
20691
+ id: `smart_push_${Date.now()}`,
20742
20692
  type: "function",
20743
- function: {
20744
- name: "bash",
20745
- arguments: JSON.stringify({ command: commitCommand })
20746
- }
20693
+ function: { name: "bash", arguments: JSON.stringify({ command: "npm run smart-push" }) }
20747
20694
  },
20748
- toolResult: commitResult
20695
+ toolResult: result
20749
20696
  };
20750
- setChatHistory((prev) => [...prev, commitEntry]);
20751
- if (commitResult.success) {
20752
- const pushResult = await agent.executeBashCommand("git push");
20753
- if (pushResult.success) {
20754
- const pushEntry = {
20755
- type: "tool_result",
20756
- content: `\u{1F680} **Push Successful**: ${pushResult.output?.split("\n")[0] || "Changes pushed to remote"}`,
20757
- timestamp: /* @__PURE__ */ new Date(),
20758
- toolCall: {
20759
- id: `git_push_${Date.now()}`,
20760
- type: "function",
20761
- function: {
20762
- name: "bash",
20763
- arguments: JSON.stringify({ command: "git push" })
20764
- }
20765
- },
20766
- toolResult: pushResult
20767
- };
20768
- setChatHistory((prev) => [...prev, pushEntry]);
20769
- const verificationEntry = {
20770
- type: "assistant",
20771
- content: "\u{1F50D} **Running post-push verification...**",
20772
- timestamp: /* @__PURE__ */ new Date()
20773
- };
20774
- setChatHistory((prev) => [...prev, verificationEntry]);
20775
- const statusCheckResult = await agent.executeBashCommand("git status --porcelain");
20776
- if (statusCheckResult.success && statusCheckResult.output?.trim() === "") {
20777
- const statusOkEntry = {
20778
- type: "tool_result",
20779
- content: "\u2705 **Git Status**: Working directory clean",
20780
- timestamp: /* @__PURE__ */ new Date()
20781
- };
20782
- setChatHistory((prev) => [...prev, statusOkEntry]);
20783
- } else {
20784
- const statusIssueEntry = {
20785
- type: "assistant",
20786
- content: `\u26A0\uFE0F **Git Status Issues Detected**:
20787
-
20788
- ${statusCheckResult.output || "Unknown status"}`,
20789
- timestamp: /* @__PURE__ */ new Date()
20790
- };
20791
- setChatHistory((prev) => [...prev, statusIssueEntry]);
20792
- }
20793
- const waitEntry = {
20794
- type: "assistant",
20795
- content: "\u23F3 **Waiting for CI/NPM publishing...** (10 seconds)",
20796
- timestamp: /* @__PURE__ */ new Date()
20797
- };
20798
- setChatHistory((prev) => [...prev, waitEntry]);
20799
- await new Promise((resolve8) => setTimeout(resolve8, 1e4));
20800
- const localPackageResult = await agent.executeBashCommand(`node -p "require('./package.json').name" 2>/dev/null || echo 'no-package'`);
20801
- const localName = localPackageResult.success && localPackageResult.output?.trim() !== "no-package" ? localPackageResult.output?.trim() : null;
20802
- if (localName) {
20803
- const localVersionResult = await agent.executeBashCommand(`node -p "require('./package.json').version"`);
20804
- const localVersion = localVersionResult.success ? localVersionResult.output?.trim() : "unknown";
20805
- const npmCheckResult = await agent.executeBashCommand(`npm view ${localName} version 2>/dev/null || echo 'not-found'`);
20806
- if (npmCheckResult.success && npmCheckResult.output?.trim() && npmCheckResult.output?.trim() !== "not-found") {
20807
- const npmVersion = npmCheckResult.output.trim();
20808
- if (npmVersion === localVersion) {
20809
- const npmConfirmEntry = {
20810
- type: "tool_result",
20811
- content: `\u2705 **NPM Package Confirmed**: ${localName} v${npmVersion} published successfully`,
20812
- timestamp: /* @__PURE__ */ new Date()
20813
- };
20814
- setChatHistory((prev) => [...prev, npmConfirmEntry]);
20815
- } else {
20816
- const npmPendingEntry = {
20817
- type: "assistant",
20818
- content: `\u23F3 **NPM Status**: Local ${localName} v${localVersion}, NPM v${npmVersion}. Publishing may still be in progress.`,
20819
- timestamp: /* @__PURE__ */ new Date()
20820
- };
20821
- setChatHistory((prev) => [...prev, npmPendingEntry]);
20822
- }
20823
- } else {
20824
- const npmSkipEntry = {
20825
- type: "assistant",
20826
- content: `\u2139\uFE0F **NPM Check Skipped**: Package ${localName} not found on NPM (may not be published yet)`,
20827
- timestamp: /* @__PURE__ */ new Date()
20828
- };
20829
- setChatHistory((prev) => [...prev, npmSkipEntry]);
20830
- }
20831
- } else {
20832
- const npmSkipEntry = {
20833
- type: "assistant",
20834
- content: `\u2139\uFE0F **NPM Check Skipped**: No package.json found or not an NPM package`,
20835
- timestamp: /* @__PURE__ */ new Date()
20836
- };
20837
- setChatHistory((prev) => [...prev, npmSkipEntry]);
20838
- }
20839
- const finalSuccessEntry = {
20840
- type: "assistant",
20841
- content: "\u{1F389} **Smart Push Complete**: All verifications passed!",
20842
- timestamp: /* @__PURE__ */ new Date()
20843
- };
20844
- setChatHistory((prev) => [...prev, finalSuccessEntry]);
20845
- } else {
20846
- const pushError = pushResult.error || pushResult.output || "";
20847
- if (pushError.includes("protected branch") || pushError.includes("Changes must be made through a pull request") || pushError.includes("GH006")) {
20848
- const branchProtectionEntry = {
20849
- type: "assistant",
20850
- content: "\u{1F6E1}\uFE0F **Branch Protection Detected**: Direct pushes to this branch are blocked.\n\n\u{1F504} **Creating PR workflow...**",
20851
- timestamp: /* @__PURE__ */ new Date()
20852
- };
20853
- setChatHistory((prev) => [...prev, branchProtectionEntry]);
20854
- const featureBranch = `feature/${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/[:-]/g, "").replace("T", "-")}-smart-push`;
20855
- const createBranchResult = await agent.executeBashCommand(`git checkout -b ${featureBranch}`);
20856
- if (createBranchResult.success) {
20857
- const pushBranchResult = await agent.executeBashCommand(`git push -u origin ${featureBranch}`);
20858
- if (pushBranchResult.success) {
20859
- const branchSuccessEntry = {
20860
- type: "tool_result",
20861
- content: `\u2705 **Feature Branch Created**: \`${featureBranch}\`
20862
-
20863
- \u{1F4CB} **Attempting to create Pull Request...**`,
20864
- timestamp: /* @__PURE__ */ new Date()
20865
- };
20866
- setChatHistory((prev) => [...prev, branchSuccessEntry]);
20867
- const prResult = await agent.executeBashCommand(`gh pr create --title "${cleanCommitMessage}" --body "Auto-generated PR from smart-push" --head ${featureBranch} --base ${currentBranch}`);
20868
- if (prResult.success) {
20869
- const prUrl = prResult.output?.match(/https:\/\/github\.com\/[^\s]+/)?.[0];
20870
- const prSuccessEntry = {
20871
- type: "tool_result",
20872
- content: `\u2705 **Pull Request Created Successfully!**
20873
-
20874
- \u{1F517} **PR URL**: ${prUrl || "Check GitHub for the link"}
20875
-
20876
- \u{1F3AF} **Next Steps**:
20877
- \u2022 Review the PR on GitHub
20878
- \u2022 Wait for CI checks to pass
20879
- \u2022 Request approval and merge`,
20880
- timestamp: /* @__PURE__ */ new Date()
20881
- };
20882
- setChatHistory((prev) => [...prev, prSuccessEntry]);
20883
- } else {
20884
- const prManualEntry = {
20885
- type: "assistant",
20886
- content: `\u26A0\uFE0F **PR Creation Failed**: GitHub CLI may not be available.
20887
-
20888
- \u{1F4A1} **Create PR Manually**:
20889
- \u2022 Go to GitHub repository
20890
- \u2022 Create PR from \`${featureBranch}\` \u2192 \`${currentBranch}\`
20891
- \u2022 Title: \`${cleanCommitMessage}\``,
20892
- timestamp: /* @__PURE__ */ new Date()
20893
- };
20894
- setChatHistory((prev) => [...prev, prManualEntry]);
20895
- }
20896
- } else {
20897
- const pushFailEntry = {
20898
- type: "tool_result",
20899
- content: `\u274C **Failed to push feature branch**: ${pushBranchResult.error}`,
20900
- timestamp: /* @__PURE__ */ new Date()
20901
- };
20902
- setChatHistory((prev) => [...prev, pushFailEntry]);
20903
- }
20904
- } else {
20905
- const branchFailEntry = {
20906
- type: "tool_result",
20907
- content: `\u274C **Failed to create feature branch**: ${createBranchResult.error}`,
20908
- timestamp: /* @__PURE__ */ new Date()
20909
- };
20910
- setChatHistory((prev) => [...prev, branchFailEntry]);
20911
- }
20912
- } else {
20913
- const pushFailEntry = {
20914
- type: "tool_result",
20915
- content: `\u274C **Push Failed**: ${pushResult.error || "Unknown error"}
20916
-
20917
- Try running \`git push\` manually.`,
20918
- timestamp: /* @__PURE__ */ new Date(),
20919
- toolCall: {
20920
- id: `git_push_${Date.now()}`,
20921
- type: "function",
20922
- function: {
20923
- name: "bash",
20924
- arguments: JSON.stringify({ command: "git push" })
20925
- }
20926
- },
20927
- toolResult: pushResult
20928
- };
20929
- setChatHistory((prev) => [...prev, pushFailEntry]);
20930
- }
20931
- }
20932
- }
20697
+ setChatHistory((prev) => [...prev, resultEntry]);
20933
20698
  } catch (error) {
20934
20699
  const errorEntry = {
20935
20700
  type: "assistant",
20936
- content: `\u274C **Smart Push Failed**
20937
-
20938
- ${error instanceof Error ? error.message : String(error)}`,
20701
+ content: `\u274C Smart Push Failed: ${error instanceof Error ? error.message : String(error)}`,
20939
20702
  timestamp: /* @__PURE__ */ new Date()
20940
20703
  };
20941
20704
  setChatHistory((prev) => [...prev, errorEntry]);
@@ -21998,6 +21761,44 @@ var init_use_processing_timer = __esm({
21998
21761
  });
21999
21762
 
22000
21763
  // src/ui/colors.ts
21764
+ function detectTerminalTheme() {
21765
+ const colorFgBg = process.env.COLORFGBG;
21766
+ const termBackground = process.env.TERM_BACKGROUND;
21767
+ const grokTextColor = process.env.GROK_TEXT_COLOR;
21768
+ if (grokTextColor) {
21769
+ return grokTextColor.toLowerCase().includes("light") ? "light" : "dark";
21770
+ }
21771
+ if (colorFgBg) {
21772
+ const parts = colorFgBg.split(";");
21773
+ if (parts.length >= 2) {
21774
+ const bg = parseInt(parts[1]);
21775
+ return bg >= 8 ? "light" : "dark";
21776
+ }
21777
+ }
21778
+ if (termBackground) {
21779
+ return termBackground.toLowerCase() === "light" ? "light" : "dark";
21780
+ }
21781
+ const term = process.env.TERM || "";
21782
+ const termProgram = process.env.TERM_PROGRAM || "";
21783
+ if (termProgram.includes("Apple_Terminal") || termProgram.includes("Terminal.app") || term.includes("xterm-256color")) {
21784
+ return "dark";
21785
+ }
21786
+ return "dark";
21787
+ }
21788
+ function getAdaptiveTextColor() {
21789
+ const theme = detectTerminalTheme();
21790
+ if (process.env.GROK_DEBUG_COLORS) {
21791
+ console.error(`[Color Debug] Theme: ${theme}, COLORFGBG: ${process.env.COLORFGBG}, TERM_BACKGROUND: ${process.env.TERM_BACKGROUND}, TERM_PROGRAM: ${process.env.TERM_PROGRAM}`);
21792
+ }
21793
+ switch (theme) {
21794
+ case "light":
21795
+ return "black";
21796
+ case "dark":
21797
+ return "white";
21798
+ default:
21799
+ return "white";
21800
+ }
21801
+ }
22001
21802
  function getSpinnerColor(operation) {
22002
21803
  switch (operation.toLowerCase()) {
22003
21804
  case "search":
@@ -22031,7 +21832,8 @@ var init_colors = __esm({
22031
21832
  info: "blue",
22032
21833
  muted: "gray",
22033
21834
  accent: "magenta",
22034
- text: "black",
21835
+ text: process.env.FORCE_TEXT_COLOR || getAdaptiveTextColor(),
21836
+ // Adaptive text color
22035
21837
  // Bright variants
22036
21838
  primaryBright: "cyanBright",
22037
21839
  successBright: "greenBright",
@@ -22395,14 +22197,14 @@ var init_user_message_entry = __esm({
22395
22197
  function AssistantMessageEntry({ entry, verbosityLevel: _verbosityLevel }) {
22396
22198
  const { content: processedContent, isTruncated } = handleLongContent(entry.content);
22397
22199
  return /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginTop: 1, children: /* @__PURE__ */ jsxs(Box, { flexDirection: "row", alignItems: "flex-start", children: [
22398
- /* @__PURE__ */ jsx(Text, { color: "white", children: "\u23FA " }),
22200
+ /* @__PURE__ */ jsx(Text, { color: inkColors.text, children: "\u23FA " }),
22399
22201
  /* @__PURE__ */ jsxs(Box, { flexDirection: "column", width: "100%", children: [
22400
22202
  entry.toolCalls ? (
22401
22203
  // If there are tool calls, just show plain text
22402
- /* @__PURE__ */ jsx(Text, { color: "#FFFFFF", wrap: "wrap", dimColor: false, children: processedContent.trim() })
22204
+ /* @__PURE__ */ jsx(Text, { color: inkColors.text, wrap: "wrap", dimColor: false, children: processedContent.trim() })
22403
22205
  ) : (
22404
22206
  // Use bright white text like Claude Code - explicit hex color to override any defaults
22405
- /* @__PURE__ */ jsx(Text, { color: "#FFFFFF", wrap: "wrap", dimColor: false, children: processedContent.trim() })
22207
+ /* @__PURE__ */ jsx(Text, { color: inkColors.text, wrap: "wrap", dimColor: false, children: processedContent.trim() })
22406
22208
  ),
22407
22209
  entry.isStreaming && /* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u2588" }),
22408
22210
  isTruncated && /* @__PURE__ */ jsx(Text, { color: "yellow", italic: true, children: "[Response truncated for performance - full content in session log]" })
@@ -22412,6 +22214,7 @@ function AssistantMessageEntry({ entry, verbosityLevel: _verbosityLevel }) {
22412
22214
  var handleLongContent;
22413
22215
  var init_assistant_message_entry = __esm({
22414
22216
  "src/ui/components/chat-entries/assistant-message-entry.tsx"() {
22217
+ init_colors();
22415
22218
  handleLongContent = (content, maxLength = 5e3) => {
22416
22219
  if (content.length <= maxLength) {
22417
22220
  return { content, isTruncated: false };
@@ -24235,7 +24038,7 @@ var require_package = __commonJS({
24235
24038
  module.exports = {
24236
24039
  type: "module",
24237
24040
  name: "@xagent/one-shot",
24238
- version: "1.1.99",
24041
+ version: "1.1.101",
24239
24042
  description: "An open-source AI agent that brings advanced AI capabilities directly into your terminal with automatic documentation updates.",
24240
24043
  main: "dist/index.js",
24241
24044
  module: "dist/index.js",