@xagent/x-cli 1.1.66 → 1.1.68
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 +6 -2
- package/dist/index.js +263 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- Test comment for PR creation -->
|
|
2
|
+
|
|
3
|
+
## 1.1.68 – Logo Assets & NPM Publication Complete
|
|
2
4
|
|
|
3
5
|
✅ **Live on NPM**: [@xagent/x-cli](https://www.npmjs.com/package/@xagent/x-cli) - Fully published and ready for global installation
|
|
4
6
|
|
|
@@ -1078,7 +1080,7 @@ To add yourself as a contributor:
|
|
|
1078
1080
|
|
|
1079
1081
|
- **[@unblock-everything](https://github.com/unblock-everything)** — [x.ai](https://x.ai) — Cold-ass honkey 😎
|
|
1080
1082
|
- **[@Bucko89](https://github.com/Bucko89)** — [GMA](https://getmyagencies.com) — Grinding daily
|
|
1081
|
-
- **[@base-buzz](https://github.com/base-buzz)** — [
|
|
1083
|
+
- **[@base-buzz](https://github.com/base-buzz)** — [BaseBUzz](team.basebuzz.com)
|
|
1082
1084
|
|
|
1083
1085
|
_Want to see your name here? Check out our [Contributing Guide](CONTRIBUTING.md) and submit a pull request!_
|
|
1084
1086
|
|
|
@@ -1102,3 +1104,5 @@ _Want to see your name here? Check out our [Contributing Guide](CONTRIBUTING.md)
|
|
|
1102
1104
|
- 💡 **Feature requests** - Suggest new functionality
|
|
1103
1105
|
|
|
1104
1106
|
Join our growing community of AI-powered terminal enthusiasts!
|
|
1107
|
+
|
|
1108
|
+
# Test: Branch Protection Rules Test
|
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.
|
|
14658
|
+
version: "1.1.68",
|
|
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,267 @@ 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
|
+
if (pushResult.success) {
|
|
16505
|
+
const pushEntry = {
|
|
16506
|
+
type: "tool_result",
|
|
16507
|
+
content: `\u{1F680} **Push Successful**: ${pushResult.output?.split("\n")[0] || "Changes pushed to remote"}`,
|
|
16508
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
16509
|
+
toolCall: {
|
|
16510
|
+
id: `git_push_${Date.now()}`,
|
|
16511
|
+
type: "function",
|
|
16512
|
+
function: {
|
|
16513
|
+
name: "bash",
|
|
16514
|
+
arguments: JSON.stringify({ command: "git push" })
|
|
16515
|
+
}
|
|
16516
|
+
},
|
|
16517
|
+
toolResult: pushResult
|
|
16518
|
+
};
|
|
16519
|
+
setChatHistory((prev) => [...prev, pushEntry]);
|
|
16520
|
+
} else {
|
|
16521
|
+
const pushError = pushResult.error || pushResult.output || "";
|
|
16522
|
+
if (pushError.includes("protected branch") || pushError.includes("Changes must be made through a pull request") || pushError.includes("GH006")) {
|
|
16523
|
+
const branchProtectionEntry = {
|
|
16524
|
+
type: "assistant",
|
|
16525
|
+
content: "\u{1F6E1}\uFE0F **Branch Protection Detected**: Direct pushes to this branch are blocked.\n\n\u{1F504} **Creating PR workflow...**",
|
|
16526
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
16527
|
+
};
|
|
16528
|
+
setChatHistory((prev) => [...prev, branchProtectionEntry]);
|
|
16529
|
+
const featureBranch = `feature/${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/[:-]/g, "").replace("T", "-")}-smart-push`;
|
|
16530
|
+
const createBranchResult = await agent.executeBashCommand(`git checkout -b ${featureBranch}`);
|
|
16531
|
+
if (createBranchResult.success) {
|
|
16532
|
+
const pushBranchResult = await agent.executeBashCommand(`git push -u origin ${featureBranch}`);
|
|
16533
|
+
if (pushBranchResult.success) {
|
|
16534
|
+
const branchSuccessEntry = {
|
|
16535
|
+
type: "tool_result",
|
|
16536
|
+
content: `\u2705 **Feature Branch Created**: \`${featureBranch}\`
|
|
16537
|
+
|
|
16538
|
+
\u{1F4CB} **Attempting to create Pull Request...**`,
|
|
16539
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
16540
|
+
};
|
|
16541
|
+
setChatHistory((prev) => [...prev, branchSuccessEntry]);
|
|
16542
|
+
const prResult = await agent.executeBashCommand(`gh pr create --title "${cleanCommitMessage}" --body "Auto-generated PR from smart-push" --head ${featureBranch} --base main`);
|
|
16543
|
+
if (prResult.success) {
|
|
16544
|
+
const prUrl = prResult.output?.match(/https:\/\/github\.com\/[^\s]+/)?.[0];
|
|
16545
|
+
const prSuccessEntry = {
|
|
16546
|
+
type: "tool_result",
|
|
16547
|
+
content: `\u2705 **Pull Request Created Successfully!**
|
|
16548
|
+
|
|
16549
|
+
\u{1F517} **PR URL**: ${prUrl || "Check GitHub for the link"}
|
|
16550
|
+
|
|
16551
|
+
\u{1F3AF} **Next Steps**:
|
|
16552
|
+
\u2022 Review the PR on GitHub
|
|
16553
|
+
\u2022 Wait for CI checks to pass
|
|
16554
|
+
\u2022 Request approval and merge`,
|
|
16555
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
16556
|
+
};
|
|
16557
|
+
setChatHistory((prev) => [...prev, prSuccessEntry]);
|
|
16558
|
+
} else {
|
|
16559
|
+
const prManualEntry = {
|
|
16560
|
+
type: "assistant",
|
|
16561
|
+
content: `\u26A0\uFE0F **PR Creation Failed**: GitHub CLI may not be available.
|
|
16562
|
+
|
|
16563
|
+
\u{1F4A1} **Create PR Manually**:
|
|
16564
|
+
\u2022 Go to GitHub repository
|
|
16565
|
+
\u2022 Create PR from \`${featureBranch}\` \u2192 \`main\`
|
|
16566
|
+
\u2022 Title: \`${cleanCommitMessage}\``,
|
|
16567
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
16568
|
+
};
|
|
16569
|
+
setChatHistory((prev) => [...prev, prManualEntry]);
|
|
16570
|
+
}
|
|
16571
|
+
} else {
|
|
16572
|
+
const pushFailEntry = {
|
|
16573
|
+
type: "tool_result",
|
|
16574
|
+
content: `\u274C **Failed to push feature branch**: ${pushBranchResult.error}`,
|
|
16575
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
16576
|
+
};
|
|
16577
|
+
setChatHistory((prev) => [...prev, pushFailEntry]);
|
|
16578
|
+
}
|
|
16579
|
+
} else {
|
|
16580
|
+
const branchFailEntry = {
|
|
16581
|
+
type: "tool_result",
|
|
16582
|
+
content: `\u274C **Failed to create feature branch**: ${createBranchResult.error}`,
|
|
16583
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
16584
|
+
};
|
|
16585
|
+
setChatHistory((prev) => [...prev, branchFailEntry]);
|
|
16586
|
+
}
|
|
16587
|
+
} else {
|
|
16588
|
+
const pushFailEntry = {
|
|
16589
|
+
type: "tool_result",
|
|
16590
|
+
content: `\u274C **Push Failed**: ${pushResult.error || "Unknown error"}
|
|
16591
|
+
|
|
16592
|
+
Try running \`git push\` manually.`,
|
|
16593
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
16594
|
+
toolCall: {
|
|
16595
|
+
id: `git_push_${Date.now()}`,
|
|
16596
|
+
type: "function",
|
|
16597
|
+
function: {
|
|
16598
|
+
name: "bash",
|
|
16599
|
+
arguments: JSON.stringify({ command: "git push" })
|
|
16600
|
+
}
|
|
16601
|
+
},
|
|
16602
|
+
toolResult: pushResult
|
|
16603
|
+
};
|
|
16604
|
+
setChatHistory((prev) => [...prev, pushFailEntry]);
|
|
16605
|
+
}
|
|
16606
|
+
}
|
|
16607
|
+
}
|
|
16608
|
+
} catch (error) {
|
|
16609
|
+
const errorEntry = {
|
|
16610
|
+
type: "assistant",
|
|
16611
|
+
content: `\u274C **Smart Push Failed**
|
|
16612
|
+
|
|
16613
|
+
${error instanceof Error ? error.message : String(error)}`,
|
|
16614
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
16615
|
+
};
|
|
16616
|
+
setChatHistory((prev) => [...prev, errorEntry]);
|
|
16617
|
+
}
|
|
16618
|
+
setIsProcessing(false);
|
|
16619
|
+
clearInput();
|
|
16620
|
+
return true;
|
|
16621
|
+
}
|
|
16360
16622
|
const directBashCommands = [
|
|
16361
16623
|
"ls",
|
|
16362
16624
|
"pwd",
|