@xagent/x-cli 1.1.99 → 1.1.100
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 +300 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
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.
|
|
18641
|
+
version: "1.1.100",
|
|
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,6 +20419,260 @@ Operations will now ${newLevel === "off" ? "show no explanations" : newLevel ===
|
|
|
20419
20419
|
clearInput();
|
|
20420
20420
|
return true;
|
|
20421
20421
|
}
|
|
20422
|
+
if (trimmedInput === "/safe-push") {
|
|
20423
|
+
const userEntry = {
|
|
20424
|
+
type: "user",
|
|
20425
|
+
content: trimmedInput,
|
|
20426
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
20427
|
+
};
|
|
20428
|
+
setChatHistory((prev) => [...prev, userEntry]);
|
|
20429
|
+
setIsProcessing(true);
|
|
20430
|
+
try {
|
|
20431
|
+
const startEntry = {
|
|
20432
|
+
type: "assistant",
|
|
20433
|
+
content: "\u{1F680} **Safe Push - Automated Workflow**\n\nRunning quality checks and git operations...",
|
|
20434
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
20435
|
+
};
|
|
20436
|
+
setChatHistory((prev) => [...prev, startEntry]);
|
|
20437
|
+
const tsCheckEntry = {
|
|
20438
|
+
type: "assistant",
|
|
20439
|
+
content: "\u{1F4DD} **Step 1/5**: Checking TypeScript...",
|
|
20440
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
20441
|
+
};
|
|
20442
|
+
setChatHistory((prev) => [...prev, tsCheckEntry]);
|
|
20443
|
+
const tsResult = await agent.executeBashCommand("npm run typecheck");
|
|
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 = {
|
|
20458
|
+
type: "assistant",
|
|
20459
|
+
content: `\u274C **Safe Push Failed: TypeScript Errors**
|
|
20460
|
+
|
|
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`,
|
|
20476
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
20477
|
+
};
|
|
20478
|
+
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20479
|
+
setIsProcessing(false);
|
|
20480
|
+
clearInput();
|
|
20481
|
+
return true;
|
|
20482
|
+
}
|
|
20483
|
+
const lintCheckEntry = {
|
|
20484
|
+
type: "assistant",
|
|
20485
|
+
content: "\u{1F9F9} **Step 2/5**: Running ESLint...",
|
|
20486
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
20487
|
+
};
|
|
20488
|
+
setChatHistory((prev) => [...prev, lintCheckEntry]);
|
|
20489
|
+
const lintResult = await agent.executeBashCommand("npm run lint");
|
|
20490
|
+
const lintResultEntry = {
|
|
20491
|
+
type: "tool_result",
|
|
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`,
|
|
20510
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
20511
|
+
toolCall: {
|
|
20512
|
+
id: `lint_check_${Date.now()}`,
|
|
20513
|
+
type: "function",
|
|
20514
|
+
function: { name: "bash", arguments: JSON.stringify({ command: "npm run lint" }) }
|
|
20515
|
+
},
|
|
20516
|
+
toolResult: lintResult
|
|
20517
|
+
};
|
|
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]);
|
|
20525
|
+
const statusResult = await agent.executeBashCommand("git status --porcelain");
|
|
20526
|
+
const hasChanges = statusResult.success && statusResult.output?.trim();
|
|
20527
|
+
if (!hasChanges) {
|
|
20528
|
+
const noChangesEntry = {
|
|
20529
|
+
type: "assistant",
|
|
20530
|
+
content: "\u2139\uFE0F **No Changes to Commit**: Working tree is clean. Nothing to push!",
|
|
20531
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
20532
|
+
};
|
|
20533
|
+
setChatHistory((prev) => [...prev, noChangesEntry]);
|
|
20534
|
+
setIsProcessing(false);
|
|
20535
|
+
clearInput();
|
|
20536
|
+
return true;
|
|
20537
|
+
}
|
|
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 = {
|
|
20559
|
+
type: "assistant",
|
|
20560
|
+
content: `\u274C **Safe Push Failed: Git Staging Error**
|
|
20561
|
+
|
|
20562
|
+
**Error Details:**
|
|
20563
|
+
\`\`\`
|
|
20564
|
+
${addResult.error || "Failed to stage changes"}
|
|
20565
|
+
\`\`\`
|
|
20566
|
+
|
|
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`,
|
|
20578
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
20579
|
+
};
|
|
20580
|
+
setChatHistory((prev) => [...prev, stagingErrorEntry]);
|
|
20581
|
+
setIsProcessing(false);
|
|
20582
|
+
clearInput();
|
|
20583
|
+
return true;
|
|
20584
|
+
}
|
|
20585
|
+
const commitEntry = {
|
|
20586
|
+
type: "assistant",
|
|
20587
|
+
content: "\u{1F4BE} **Step 5/5**: Creating commit...",
|
|
20588
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
20589
|
+
};
|
|
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**
|
|
20597
|
+
|
|
20598
|
+
**Error Details:**
|
|
20599
|
+
\`\`\`
|
|
20600
|
+
${commitResult.error || "Git commit failed"}
|
|
20601
|
+
\`\`\`
|
|
20602
|
+
|
|
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) {
|
|
20624
|
+
setIsProcessing(false);
|
|
20625
|
+
clearInput();
|
|
20626
|
+
return true;
|
|
20627
|
+
}
|
|
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
|
+
type: "tool_result",
|
|
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`,
|
|
20655
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
20656
|
+
toolCall: {
|
|
20657
|
+
id: `git_push_${Date.now()}`,
|
|
20658
|
+
type: "function",
|
|
20659
|
+
function: { name: "bash", arguments: JSON.stringify({ command: "git push" }) }
|
|
20660
|
+
},
|
|
20661
|
+
toolResult: pushResult
|
|
20662
|
+
};
|
|
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
|
+
}
|
|
20422
20676
|
if (trimmedInput === "/smart-push") {
|
|
20423
20677
|
const userEntry = {
|
|
20424
20678
|
type: "user",
|
|
@@ -21998,6 +22252,44 @@ var init_use_processing_timer = __esm({
|
|
|
21998
22252
|
});
|
|
21999
22253
|
|
|
22000
22254
|
// src/ui/colors.ts
|
|
22255
|
+
function detectTerminalTheme() {
|
|
22256
|
+
const colorFgBg = process.env.COLORFGBG;
|
|
22257
|
+
const termBackground = process.env.TERM_BACKGROUND;
|
|
22258
|
+
const grokTextColor = process.env.GROK_TEXT_COLOR;
|
|
22259
|
+
if (grokTextColor) {
|
|
22260
|
+
return grokTextColor.toLowerCase().includes("light") ? "light" : "dark";
|
|
22261
|
+
}
|
|
22262
|
+
if (colorFgBg) {
|
|
22263
|
+
const parts = colorFgBg.split(";");
|
|
22264
|
+
if (parts.length >= 2) {
|
|
22265
|
+
const bg = parseInt(parts[1]);
|
|
22266
|
+
return bg >= 8 ? "light" : "dark";
|
|
22267
|
+
}
|
|
22268
|
+
}
|
|
22269
|
+
if (termBackground) {
|
|
22270
|
+
return termBackground.toLowerCase() === "light" ? "light" : "dark";
|
|
22271
|
+
}
|
|
22272
|
+
const term = process.env.TERM || "";
|
|
22273
|
+
const termProgram = process.env.TERM_PROGRAM || "";
|
|
22274
|
+
if (termProgram.includes("Apple_Terminal") || termProgram.includes("Terminal.app") || term.includes("xterm-256color")) {
|
|
22275
|
+
return "dark";
|
|
22276
|
+
}
|
|
22277
|
+
return "dark";
|
|
22278
|
+
}
|
|
22279
|
+
function getAdaptiveTextColor() {
|
|
22280
|
+
const theme = detectTerminalTheme();
|
|
22281
|
+
if (process.env.GROK_DEBUG_COLORS) {
|
|
22282
|
+
console.error(`[Color Debug] Theme: ${theme}, COLORFGBG: ${process.env.COLORFGBG}, TERM_BACKGROUND: ${process.env.TERM_BACKGROUND}, TERM_PROGRAM: ${process.env.TERM_PROGRAM}`);
|
|
22283
|
+
}
|
|
22284
|
+
switch (theme) {
|
|
22285
|
+
case "light":
|
|
22286
|
+
return "black";
|
|
22287
|
+
case "dark":
|
|
22288
|
+
return "white";
|
|
22289
|
+
default:
|
|
22290
|
+
return "white";
|
|
22291
|
+
}
|
|
22292
|
+
}
|
|
22001
22293
|
function getSpinnerColor(operation) {
|
|
22002
22294
|
switch (operation.toLowerCase()) {
|
|
22003
22295
|
case "search":
|
|
@@ -22031,7 +22323,8 @@ var init_colors = __esm({
|
|
|
22031
22323
|
info: "blue",
|
|
22032
22324
|
muted: "gray",
|
|
22033
22325
|
accent: "magenta",
|
|
22034
|
-
text:
|
|
22326
|
+
text: process.env.FORCE_TEXT_COLOR || getAdaptiveTextColor(),
|
|
22327
|
+
// Adaptive text color
|
|
22035
22328
|
// Bright variants
|
|
22036
22329
|
primaryBright: "cyanBright",
|
|
22037
22330
|
successBright: "greenBright",
|
|
@@ -22395,14 +22688,14 @@ var init_user_message_entry = __esm({
|
|
|
22395
22688
|
function AssistantMessageEntry({ entry, verbosityLevel: _verbosityLevel }) {
|
|
22396
22689
|
const { content: processedContent, isTruncated } = handleLongContent(entry.content);
|
|
22397
22690
|
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginTop: 1, children: /* @__PURE__ */ jsxs(Box, { flexDirection: "row", alignItems: "flex-start", children: [
|
|
22398
|
-
/* @__PURE__ */ jsx(Text, { color:
|
|
22691
|
+
/* @__PURE__ */ jsx(Text, { color: inkColors.text, children: "\u23FA " }),
|
|
22399
22692
|
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", width: "100%", children: [
|
|
22400
22693
|
entry.toolCalls ? (
|
|
22401
22694
|
// If there are tool calls, just show plain text
|
|
22402
|
-
/* @__PURE__ */ jsx(Text, { color:
|
|
22695
|
+
/* @__PURE__ */ jsx(Text, { color: inkColors.text, wrap: "wrap", dimColor: false, children: processedContent.trim() })
|
|
22403
22696
|
) : (
|
|
22404
22697
|
// Use bright white text like Claude Code - explicit hex color to override any defaults
|
|
22405
|
-
/* @__PURE__ */ jsx(Text, { color:
|
|
22698
|
+
/* @__PURE__ */ jsx(Text, { color: inkColors.text, wrap: "wrap", dimColor: false, children: processedContent.trim() })
|
|
22406
22699
|
),
|
|
22407
22700
|
entry.isStreaming && /* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u2588" }),
|
|
22408
22701
|
isTruncated && /* @__PURE__ */ jsx(Text, { color: "yellow", italic: true, children: "[Response truncated for performance - full content in session log]" })
|
|
@@ -22412,6 +22705,7 @@ function AssistantMessageEntry({ entry, verbosityLevel: _verbosityLevel }) {
|
|
|
22412
22705
|
var handleLongContent;
|
|
22413
22706
|
var init_assistant_message_entry = __esm({
|
|
22414
22707
|
"src/ui/components/chat-entries/assistant-message-entry.tsx"() {
|
|
22708
|
+
init_colors();
|
|
22415
22709
|
handleLongContent = (content, maxLength = 5e3) => {
|
|
22416
22710
|
if (content.length <= maxLength) {
|
|
22417
22711
|
return { content, isTruncated: false };
|
|
@@ -24235,7 +24529,7 @@ var require_package = __commonJS({
|
|
|
24235
24529
|
module.exports = {
|
|
24236
24530
|
type: "module",
|
|
24237
24531
|
name: "@xagent/one-shot",
|
|
24238
|
-
version: "1.1.
|
|
24532
|
+
version: "1.1.100",
|
|
24239
24533
|
description: "An open-source AI agent that brings advanced AI capabilities directly into your terminal with automatic documentation updates.",
|
|
24240
24534
|
main: "dist/index.js",
|
|
24241
24535
|
module: "dist/index.js",
|