@xagent/one-shot 1.1.100 → 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/README.md +1 -1
- package/dist/index.js +10 -501
- 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.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",
|
|
@@ -20682,514 +20682,23 @@ ${pushResult.error || "Git push failed"}
|
|
|
20682
20682
|
setChatHistory((prev) => [...prev, userEntry]);
|
|
20683
20683
|
setIsProcessing(true);
|
|
20684
20684
|
try {
|
|
20685
|
-
const
|
|
20686
|
-
const
|
|
20687
|
-
const qualityCheckEntry = {
|
|
20688
|
-
type: "assistant",
|
|
20689
|
-
content: "\u{1F50D} **Running pre-push quality checks...**",
|
|
20690
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20691
|
-
};
|
|
20692
|
-
setChatHistory((prev) => [...prev, qualityCheckEntry]);
|
|
20693
|
-
const tsCheckEntry = {
|
|
20694
|
-
type: "assistant",
|
|
20695
|
-
content: "\u{1F4DD} Checking TypeScript...",
|
|
20696
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20697
|
-
};
|
|
20698
|
-
setChatHistory((prev) => [...prev, tsCheckEntry]);
|
|
20699
|
-
const tsResult = await agent.executeBashCommand("npm run typecheck");
|
|
20700
|
-
if (tsResult.success) {
|
|
20701
|
-
const tsSuccessEntry = {
|
|
20702
|
-
type: "tool_result",
|
|
20703
|
-
content: "\u2705 TypeScript check passed",
|
|
20704
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
20705
|
-
toolCall: {
|
|
20706
|
-
id: `ts_check_${Date.now()}`,
|
|
20707
|
-
type: "function",
|
|
20708
|
-
function: {
|
|
20709
|
-
name: "bash",
|
|
20710
|
-
arguments: JSON.stringify({ command: "npm run typecheck" })
|
|
20711
|
-
}
|
|
20712
|
-
},
|
|
20713
|
-
toolResult: tsResult
|
|
20714
|
-
};
|
|
20715
|
-
setChatHistory((prev) => [...prev, tsSuccessEntry]);
|
|
20716
|
-
} else {
|
|
20717
|
-
const tsFailEntry = {
|
|
20718
|
-
type: "assistant",
|
|
20719
|
-
content: `\u274C **TypeScript check failed**
|
|
20720
|
-
|
|
20721
|
-
${tsResult.error || tsResult.output}`,
|
|
20722
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20723
|
-
};
|
|
20724
|
-
setChatHistory((prev) => [...prev, tsFailEntry]);
|
|
20725
|
-
setIsProcessing(false);
|
|
20726
|
-
clearInput();
|
|
20727
|
-
return true;
|
|
20728
|
-
}
|
|
20729
|
-
const lintCheckEntry = {
|
|
20730
|
-
type: "assistant",
|
|
20731
|
-
content: "\u{1F9F9} Running ESLint...",
|
|
20732
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20733
|
-
};
|
|
20734
|
-
setChatHistory((prev) => [...prev, lintCheckEntry]);
|
|
20735
|
-
const lintResult = await agent.executeBashCommand("npm run lint");
|
|
20736
|
-
const lintSuccessEntry = {
|
|
20737
|
-
type: "tool_result",
|
|
20738
|
-
content: "\u2705 ESLint check completed (warnings allowed)",
|
|
20739
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
20740
|
-
toolCall: {
|
|
20741
|
-
id: `lint_check_${Date.now()}`,
|
|
20742
|
-
type: "function",
|
|
20743
|
-
function: {
|
|
20744
|
-
name: "bash",
|
|
20745
|
-
arguments: JSON.stringify({ command: "npm run lint" })
|
|
20746
|
-
}
|
|
20747
|
-
},
|
|
20748
|
-
toolResult: lintResult
|
|
20749
|
-
};
|
|
20750
|
-
setChatHistory((prev) => [...prev, lintSuccessEntry]);
|
|
20751
|
-
const statusResult = await agent.executeBashCommand("git status --porcelain");
|
|
20752
|
-
if (!statusResult.success) {
|
|
20753
|
-
const errorEntry = {
|
|
20754
|
-
type: "assistant",
|
|
20755
|
-
content: "\u274C **Git Error**\n\nUnable to check git status. Are you in a git repository?",
|
|
20756
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20757
|
-
};
|
|
20758
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20759
|
-
setIsProcessing(false);
|
|
20760
|
-
clearInput();
|
|
20761
|
-
return true;
|
|
20762
|
-
}
|
|
20763
|
-
if (!statusResult.output || statusResult.output.trim() === "") {
|
|
20764
|
-
const noChangesEntry = {
|
|
20765
|
-
type: "assistant",
|
|
20766
|
-
content: "\u{1F4CB} **No Changes to Push**\n\nWorking directory is clean. No commits to push.",
|
|
20767
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20768
|
-
};
|
|
20769
|
-
setChatHistory((prev) => [...prev, noChangesEntry]);
|
|
20770
|
-
setIsProcessing(false);
|
|
20771
|
-
clearInput();
|
|
20772
|
-
return true;
|
|
20773
|
-
}
|
|
20774
|
-
const prePullAddResult = await agent.executeBashCommand("git add .");
|
|
20775
|
-
if (!prePullAddResult.success) {
|
|
20776
|
-
const errorEntry = {
|
|
20777
|
-
type: "assistant",
|
|
20778
|
-
content: `\u274C **Failed to stage changes**
|
|
20779
|
-
|
|
20780
|
-
${prePullAddResult.error || "Unknown error"}`,
|
|
20781
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20782
|
-
};
|
|
20783
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20784
|
-
setIsProcessing(false);
|
|
20785
|
-
clearInput();
|
|
20786
|
-
return true;
|
|
20787
|
-
}
|
|
20788
|
-
const stashResult = await agent.executeBashCommand("git stash push --include-untracked --message 'smart-push temporary stash'");
|
|
20789
|
-
if (!stashResult.success) {
|
|
20790
|
-
const errorEntry = {
|
|
20791
|
-
type: "assistant",
|
|
20792
|
-
content: `\u274C **Failed to stash changes**
|
|
20793
|
-
|
|
20794
|
-
${stashResult.error || "Unknown error"}`,
|
|
20795
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20796
|
-
};
|
|
20797
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20798
|
-
setIsProcessing(false);
|
|
20799
|
-
clearInput();
|
|
20800
|
-
return true;
|
|
20801
|
-
}
|
|
20802
|
-
const pullEntry = {
|
|
20803
|
-
type: "assistant",
|
|
20804
|
-
content: "\u{1F504} Pulling latest changes...",
|
|
20805
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20806
|
-
};
|
|
20807
|
-
setChatHistory((prev) => [...prev, pullEntry]);
|
|
20808
|
-
const rebaseCheck = await agent.executeBashCommand("test -d .git/rebase-apply -o -d .git/rebase-merge -o -f .git/MERGE_HEAD && echo 'ongoing' || echo 'clean'");
|
|
20809
|
-
if (rebaseCheck.output?.includes("ongoing")) {
|
|
20810
|
-
const cleanupEntry = {
|
|
20811
|
-
type: "assistant",
|
|
20812
|
-
content: "\u26A0\uFE0F Git operation in progress - cleaning up...",
|
|
20813
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20814
|
-
};
|
|
20815
|
-
setChatHistory((prev) => [...prev, cleanupEntry]);
|
|
20816
|
-
await agent.executeBashCommand("git rebase --abort 2>/dev/null || git merge --abort 2>/dev/null || true");
|
|
20817
|
-
}
|
|
20818
|
-
let pullResult = await agent.executeBashCommand(`git pull --rebase origin ${currentBranch}`);
|
|
20819
|
-
if (!pullResult.success) {
|
|
20820
|
-
pullResult = await agent.executeBashCommand(`git pull origin ${currentBranch}`);
|
|
20821
|
-
if (pullResult.success) {
|
|
20822
|
-
const mergeFallbackEntry = {
|
|
20823
|
-
type: "assistant",
|
|
20824
|
-
content: "\u26A0\uFE0F Rebase failed, fell back to merge",
|
|
20825
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20826
|
-
};
|
|
20827
|
-
setChatHistory((prev) => [...prev, mergeFallbackEntry]);
|
|
20828
|
-
}
|
|
20829
|
-
}
|
|
20830
|
-
if (pullResult.success) {
|
|
20831
|
-
const pullSuccessEntry = {
|
|
20832
|
-
type: "tool_result",
|
|
20833
|
-
content: pullResult.output?.includes("Successfully rebased") ? "\u2705 Successfully rebased local changes" : "\u2705 Successfully pulled latest changes",
|
|
20834
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20835
|
-
};
|
|
20836
|
-
setChatHistory((prev) => [...prev, pullSuccessEntry]);
|
|
20837
|
-
const popStashResult = await agent.executeBashCommand("git stash pop");
|
|
20838
|
-
if (!popStashResult.success) {
|
|
20839
|
-
const errorEntry = {
|
|
20840
|
-
type: "assistant",
|
|
20841
|
-
content: `\u26A0\uFE0F **Failed to restore stashed changes**
|
|
20842
|
-
|
|
20843
|
-
${popStashResult.error || "Unknown error"}
|
|
20844
|
-
|
|
20845
|
-
\u{1F4A1} Your changes may be lost. Check git stash list.`,
|
|
20846
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20847
|
-
};
|
|
20848
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20849
|
-
setIsProcessing(false);
|
|
20850
|
-
clearInput();
|
|
20851
|
-
return true;
|
|
20852
|
-
} else {
|
|
20853
|
-
const popSuccessEntry = {
|
|
20854
|
-
type: "tool_result",
|
|
20855
|
-
content: "\u2705 Changes restored from stash",
|
|
20856
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20857
|
-
};
|
|
20858
|
-
setChatHistory((prev) => [...prev, popSuccessEntry]);
|
|
20859
|
-
}
|
|
20860
|
-
} else {
|
|
20861
|
-
const pullFailEntry = {
|
|
20862
|
-
type: "assistant",
|
|
20863
|
-
content: `\u274C **Pull failed**
|
|
20864
|
-
|
|
20865
|
-
${pullResult.error || pullResult.output}
|
|
20866
|
-
|
|
20867
|
-
\u{1F4A1} Check git status and resolve any conflicts`,
|
|
20868
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20869
|
-
};
|
|
20870
|
-
setChatHistory((prev) => [...prev, pullFailEntry]);
|
|
20871
|
-
setIsProcessing(false);
|
|
20872
|
-
clearInput();
|
|
20873
|
-
return true;
|
|
20874
|
-
}
|
|
20875
|
-
const addResult = await agent.executeBashCommand("git add .");
|
|
20876
|
-
if (!addResult.success) {
|
|
20877
|
-
const errorEntry = {
|
|
20878
|
-
type: "assistant",
|
|
20879
|
-
content: `\u274C **Failed to stage changes**
|
|
20880
|
-
|
|
20881
|
-
${addResult.error || "Unknown error"}`,
|
|
20882
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20883
|
-
};
|
|
20884
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20885
|
-
setIsProcessing(false);
|
|
20886
|
-
clearInput();
|
|
20887
|
-
return true;
|
|
20888
|
-
}
|
|
20889
|
-
const addEntry = {
|
|
20890
|
-
type: "tool_result",
|
|
20891
|
-
content: "\u2705 Changes staged successfully",
|
|
20892
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
20893
|
-
toolCall: {
|
|
20894
|
-
id: `git_add_${Date.now()}`,
|
|
20895
|
-
type: "function",
|
|
20896
|
-
function: {
|
|
20897
|
-
name: "bash",
|
|
20898
|
-
arguments: JSON.stringify({ command: "git add ." })
|
|
20899
|
-
}
|
|
20900
|
-
},
|
|
20901
|
-
toolResult: addResult
|
|
20902
|
-
};
|
|
20903
|
-
setChatHistory((prev) => [...prev, addEntry]);
|
|
20904
|
-
const diffResult = await agent.executeBashCommand("git diff --cached");
|
|
20905
|
-
const maxDiffLength = 5e4;
|
|
20906
|
-
const truncatedDiff = diffResult.output ? diffResult.output.length > maxDiffLength ? diffResult.output.substring(0, maxDiffLength) + "\n... (truncated due to length)" : diffResult.output : "No staged changes shown";
|
|
20907
|
-
const commitPrompt = `Generate a concise, professional git commit message for these changes:
|
|
20908
|
-
|
|
20909
|
-
Git Status:
|
|
20910
|
-
${statusResult.output}
|
|
20911
|
-
|
|
20912
|
-
Git Diff (staged changes):
|
|
20913
|
-
${truncatedDiff}
|
|
20914
|
-
|
|
20915
|
-
Follow conventional commit format (feat:, fix:, docs:, etc.) and keep it under 72 characters.
|
|
20916
|
-
Respond with ONLY the commit message, no additional text.`;
|
|
20917
|
-
let commitMessage = "";
|
|
20918
|
-
let streamingEntry = null;
|
|
20919
|
-
let accumulatedCommitContent = "";
|
|
20920
|
-
let lastCommitUpdateTime = Date.now();
|
|
20921
|
-
try {
|
|
20922
|
-
for await (const chunk of agent.processUserMessageStream(commitPrompt)) {
|
|
20923
|
-
if (chunk.type === "content" && chunk.content) {
|
|
20924
|
-
accumulatedCommitContent += chunk.content;
|
|
20925
|
-
const now = Date.now();
|
|
20926
|
-
if (now - lastCommitUpdateTime >= 150) {
|
|
20927
|
-
commitMessage += accumulatedCommitContent;
|
|
20928
|
-
if (!streamingEntry) {
|
|
20929
|
-
const newEntry = {
|
|
20930
|
-
type: "assistant",
|
|
20931
|
-
content: `\u{1F916} Generating commit message...
|
|
20932
|
-
|
|
20933
|
-
${commitMessage}`,
|
|
20934
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
20935
|
-
isStreaming: true
|
|
20936
|
-
};
|
|
20937
|
-
setChatHistory((prev) => [...prev, newEntry]);
|
|
20938
|
-
streamingEntry = newEntry;
|
|
20939
|
-
} else {
|
|
20940
|
-
setChatHistory(
|
|
20941
|
-
(prev) => prev.map(
|
|
20942
|
-
(entry, idx) => idx === prev.length - 1 && entry.isStreaming ? {
|
|
20943
|
-
...entry,
|
|
20944
|
-
content: `\u{1F916} Generating commit message...
|
|
20945
|
-
|
|
20946
|
-
${commitMessage}`
|
|
20947
|
-
} : entry
|
|
20948
|
-
)
|
|
20949
|
-
);
|
|
20950
|
-
}
|
|
20951
|
-
accumulatedCommitContent = "";
|
|
20952
|
-
lastCommitUpdateTime = now;
|
|
20953
|
-
}
|
|
20954
|
-
} else if (chunk.type === "done") {
|
|
20955
|
-
if (streamingEntry) {
|
|
20956
|
-
setChatHistory(
|
|
20957
|
-
(prev) => prev.map(
|
|
20958
|
-
(entry) => entry.isStreaming ? {
|
|
20959
|
-
...entry,
|
|
20960
|
-
content: `\u2705 Generated commit message: "${commitMessage.trim()}"`,
|
|
20961
|
-
isStreaming: false
|
|
20962
|
-
} : entry
|
|
20963
|
-
)
|
|
20964
|
-
);
|
|
20965
|
-
}
|
|
20966
|
-
break;
|
|
20967
|
-
}
|
|
20968
|
-
}
|
|
20969
|
-
} catch (error) {
|
|
20970
|
-
commitMessage = "feat: update files";
|
|
20971
|
-
const errorEntry = {
|
|
20972
|
-
type: "assistant",
|
|
20973
|
-
content: `\u26A0\uFE0F **AI commit message generation failed**: ${error.message}
|
|
20974
|
-
|
|
20975
|
-
Using fallback message: "${commitMessage}"`,
|
|
20976
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20977
|
-
};
|
|
20978
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20979
|
-
if (streamingEntry) {
|
|
20980
|
-
setChatHistory(
|
|
20981
|
-
(prev) => prev.map(
|
|
20982
|
-
(entry) => entry.isStreaming ? { ...entry, isStreaming: false } : entry
|
|
20983
|
-
)
|
|
20984
|
-
);
|
|
20985
|
-
}
|
|
20986
|
-
}
|
|
20987
|
-
const cleanCommitMessage = commitMessage.trim().replace(/^["']|["']$/g, "");
|
|
20988
|
-
const commitCommand = `git commit -m "${cleanCommitMessage}"`;
|
|
20989
|
-
const commitResult = await agent.executeBashCommand(commitCommand);
|
|
20990
|
-
const commitEntry = {
|
|
20685
|
+
const result = await agent.executeBashCommand("npm run smart-push");
|
|
20686
|
+
const resultEntry = {
|
|
20991
20687
|
type: "tool_result",
|
|
20992
|
-
content:
|
|
20688
|
+
content: result.success ? "\u{1F389} Smart Push Completed Successfully!" : `\u274C Smart Push Failed: ${result.error}`,
|
|
20993
20689
|
timestamp: /* @__PURE__ */ new Date(),
|
|
20994
20690
|
toolCall: {
|
|
20995
|
-
id: `
|
|
20691
|
+
id: `smart_push_${Date.now()}`,
|
|
20996
20692
|
type: "function",
|
|
20997
|
-
function: {
|
|
20998
|
-
name: "bash",
|
|
20999
|
-
arguments: JSON.stringify({ command: commitCommand })
|
|
21000
|
-
}
|
|
20693
|
+
function: { name: "bash", arguments: JSON.stringify({ command: "npm run smart-push" }) }
|
|
21001
20694
|
},
|
|
21002
|
-
toolResult:
|
|
20695
|
+
toolResult: result
|
|
21003
20696
|
};
|
|
21004
|
-
setChatHistory((prev) => [...prev,
|
|
21005
|
-
if (commitResult.success) {
|
|
21006
|
-
const pushResult = await agent.executeBashCommand("git push");
|
|
21007
|
-
if (pushResult.success) {
|
|
21008
|
-
const pushEntry = {
|
|
21009
|
-
type: "tool_result",
|
|
21010
|
-
content: `\u{1F680} **Push Successful**: ${pushResult.output?.split("\n")[0] || "Changes pushed to remote"}`,
|
|
21011
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
21012
|
-
toolCall: {
|
|
21013
|
-
id: `git_push_${Date.now()}`,
|
|
21014
|
-
type: "function",
|
|
21015
|
-
function: {
|
|
21016
|
-
name: "bash",
|
|
21017
|
-
arguments: JSON.stringify({ command: "git push" })
|
|
21018
|
-
}
|
|
21019
|
-
},
|
|
21020
|
-
toolResult: pushResult
|
|
21021
|
-
};
|
|
21022
|
-
setChatHistory((prev) => [...prev, pushEntry]);
|
|
21023
|
-
const verificationEntry = {
|
|
21024
|
-
type: "assistant",
|
|
21025
|
-
content: "\u{1F50D} **Running post-push verification...**",
|
|
21026
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21027
|
-
};
|
|
21028
|
-
setChatHistory((prev) => [...prev, verificationEntry]);
|
|
21029
|
-
const statusCheckResult = await agent.executeBashCommand("git status --porcelain");
|
|
21030
|
-
if (statusCheckResult.success && statusCheckResult.output?.trim() === "") {
|
|
21031
|
-
const statusOkEntry = {
|
|
21032
|
-
type: "tool_result",
|
|
21033
|
-
content: "\u2705 **Git Status**: Working directory clean",
|
|
21034
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21035
|
-
};
|
|
21036
|
-
setChatHistory((prev) => [...prev, statusOkEntry]);
|
|
21037
|
-
} else {
|
|
21038
|
-
const statusIssueEntry = {
|
|
21039
|
-
type: "assistant",
|
|
21040
|
-
content: `\u26A0\uFE0F **Git Status Issues Detected**:
|
|
21041
|
-
|
|
21042
|
-
${statusCheckResult.output || "Unknown status"}`,
|
|
21043
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21044
|
-
};
|
|
21045
|
-
setChatHistory((prev) => [...prev, statusIssueEntry]);
|
|
21046
|
-
}
|
|
21047
|
-
const waitEntry = {
|
|
21048
|
-
type: "assistant",
|
|
21049
|
-
content: "\u23F3 **Waiting for CI/NPM publishing...** (10 seconds)",
|
|
21050
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21051
|
-
};
|
|
21052
|
-
setChatHistory((prev) => [...prev, waitEntry]);
|
|
21053
|
-
await new Promise((resolve8) => setTimeout(resolve8, 1e4));
|
|
21054
|
-
const localPackageResult = await agent.executeBashCommand(`node -p "require('./package.json').name" 2>/dev/null || echo 'no-package'`);
|
|
21055
|
-
const localName = localPackageResult.success && localPackageResult.output?.trim() !== "no-package" ? localPackageResult.output?.trim() : null;
|
|
21056
|
-
if (localName) {
|
|
21057
|
-
const localVersionResult = await agent.executeBashCommand(`node -p "require('./package.json').version"`);
|
|
21058
|
-
const localVersion = localVersionResult.success ? localVersionResult.output?.trim() : "unknown";
|
|
21059
|
-
const npmCheckResult = await agent.executeBashCommand(`npm view ${localName} version 2>/dev/null || echo 'not-found'`);
|
|
21060
|
-
if (npmCheckResult.success && npmCheckResult.output?.trim() && npmCheckResult.output?.trim() !== "not-found") {
|
|
21061
|
-
const npmVersion = npmCheckResult.output.trim();
|
|
21062
|
-
if (npmVersion === localVersion) {
|
|
21063
|
-
const npmConfirmEntry = {
|
|
21064
|
-
type: "tool_result",
|
|
21065
|
-
content: `\u2705 **NPM Package Confirmed**: ${localName} v${npmVersion} published successfully`,
|
|
21066
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21067
|
-
};
|
|
21068
|
-
setChatHistory((prev) => [...prev, npmConfirmEntry]);
|
|
21069
|
-
} else {
|
|
21070
|
-
const npmPendingEntry = {
|
|
21071
|
-
type: "assistant",
|
|
21072
|
-
content: `\u23F3 **NPM Status**: Local ${localName} v${localVersion}, NPM v${npmVersion}. Publishing may still be in progress.`,
|
|
21073
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21074
|
-
};
|
|
21075
|
-
setChatHistory((prev) => [...prev, npmPendingEntry]);
|
|
21076
|
-
}
|
|
21077
|
-
} else {
|
|
21078
|
-
const npmSkipEntry = {
|
|
21079
|
-
type: "assistant",
|
|
21080
|
-
content: `\u2139\uFE0F **NPM Check Skipped**: Package ${localName} not found on NPM (may not be published yet)`,
|
|
21081
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21082
|
-
};
|
|
21083
|
-
setChatHistory((prev) => [...prev, npmSkipEntry]);
|
|
21084
|
-
}
|
|
21085
|
-
} else {
|
|
21086
|
-
const npmSkipEntry = {
|
|
21087
|
-
type: "assistant",
|
|
21088
|
-
content: `\u2139\uFE0F **NPM Check Skipped**: No package.json found or not an NPM package`,
|
|
21089
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21090
|
-
};
|
|
21091
|
-
setChatHistory((prev) => [...prev, npmSkipEntry]);
|
|
21092
|
-
}
|
|
21093
|
-
const finalSuccessEntry = {
|
|
21094
|
-
type: "assistant",
|
|
21095
|
-
content: "\u{1F389} **Smart Push Complete**: All verifications passed!",
|
|
21096
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21097
|
-
};
|
|
21098
|
-
setChatHistory((prev) => [...prev, finalSuccessEntry]);
|
|
21099
|
-
} else {
|
|
21100
|
-
const pushError = pushResult.error || pushResult.output || "";
|
|
21101
|
-
if (pushError.includes("protected branch") || pushError.includes("Changes must be made through a pull request") || pushError.includes("GH006")) {
|
|
21102
|
-
const branchProtectionEntry = {
|
|
21103
|
-
type: "assistant",
|
|
21104
|
-
content: "\u{1F6E1}\uFE0F **Branch Protection Detected**: Direct pushes to this branch are blocked.\n\n\u{1F504} **Creating PR workflow...**",
|
|
21105
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21106
|
-
};
|
|
21107
|
-
setChatHistory((prev) => [...prev, branchProtectionEntry]);
|
|
21108
|
-
const featureBranch = `feature/${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/[:-]/g, "").replace("T", "-")}-smart-push`;
|
|
21109
|
-
const createBranchResult = await agent.executeBashCommand(`git checkout -b ${featureBranch}`);
|
|
21110
|
-
if (createBranchResult.success) {
|
|
21111
|
-
const pushBranchResult = await agent.executeBashCommand(`git push -u origin ${featureBranch}`);
|
|
21112
|
-
if (pushBranchResult.success) {
|
|
21113
|
-
const branchSuccessEntry = {
|
|
21114
|
-
type: "tool_result",
|
|
21115
|
-
content: `\u2705 **Feature Branch Created**: \`${featureBranch}\`
|
|
21116
|
-
|
|
21117
|
-
\u{1F4CB} **Attempting to create Pull Request...**`,
|
|
21118
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21119
|
-
};
|
|
21120
|
-
setChatHistory((prev) => [...prev, branchSuccessEntry]);
|
|
21121
|
-
const prResult = await agent.executeBashCommand(`gh pr create --title "${cleanCommitMessage}" --body "Auto-generated PR from smart-push" --head ${featureBranch} --base ${currentBranch}`);
|
|
21122
|
-
if (prResult.success) {
|
|
21123
|
-
const prUrl = prResult.output?.match(/https:\/\/github\.com\/[^\s]+/)?.[0];
|
|
21124
|
-
const prSuccessEntry = {
|
|
21125
|
-
type: "tool_result",
|
|
21126
|
-
content: `\u2705 **Pull Request Created Successfully!**
|
|
21127
|
-
|
|
21128
|
-
\u{1F517} **PR URL**: ${prUrl || "Check GitHub for the link"}
|
|
21129
|
-
|
|
21130
|
-
\u{1F3AF} **Next Steps**:
|
|
21131
|
-
\u2022 Review the PR on GitHub
|
|
21132
|
-
\u2022 Wait for CI checks to pass
|
|
21133
|
-
\u2022 Request approval and merge`,
|
|
21134
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21135
|
-
};
|
|
21136
|
-
setChatHistory((prev) => [...prev, prSuccessEntry]);
|
|
21137
|
-
} else {
|
|
21138
|
-
const prManualEntry = {
|
|
21139
|
-
type: "assistant",
|
|
21140
|
-
content: `\u26A0\uFE0F **PR Creation Failed**: GitHub CLI may not be available.
|
|
21141
|
-
|
|
21142
|
-
\u{1F4A1} **Create PR Manually**:
|
|
21143
|
-
\u2022 Go to GitHub repository
|
|
21144
|
-
\u2022 Create PR from \`${featureBranch}\` \u2192 \`${currentBranch}\`
|
|
21145
|
-
\u2022 Title: \`${cleanCommitMessage}\``,
|
|
21146
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21147
|
-
};
|
|
21148
|
-
setChatHistory((prev) => [...prev, prManualEntry]);
|
|
21149
|
-
}
|
|
21150
|
-
} else {
|
|
21151
|
-
const pushFailEntry = {
|
|
21152
|
-
type: "tool_result",
|
|
21153
|
-
content: `\u274C **Failed to push feature branch**: ${pushBranchResult.error}`,
|
|
21154
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21155
|
-
};
|
|
21156
|
-
setChatHistory((prev) => [...prev, pushFailEntry]);
|
|
21157
|
-
}
|
|
21158
|
-
} else {
|
|
21159
|
-
const branchFailEntry = {
|
|
21160
|
-
type: "tool_result",
|
|
21161
|
-
content: `\u274C **Failed to create feature branch**: ${createBranchResult.error}`,
|
|
21162
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21163
|
-
};
|
|
21164
|
-
setChatHistory((prev) => [...prev, branchFailEntry]);
|
|
21165
|
-
}
|
|
21166
|
-
} else {
|
|
21167
|
-
const pushFailEntry = {
|
|
21168
|
-
type: "tool_result",
|
|
21169
|
-
content: `\u274C **Push Failed**: ${pushResult.error || "Unknown error"}
|
|
21170
|
-
|
|
21171
|
-
Try running \`git push\` manually.`,
|
|
21172
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
21173
|
-
toolCall: {
|
|
21174
|
-
id: `git_push_${Date.now()}`,
|
|
21175
|
-
type: "function",
|
|
21176
|
-
function: {
|
|
21177
|
-
name: "bash",
|
|
21178
|
-
arguments: JSON.stringify({ command: "git push" })
|
|
21179
|
-
}
|
|
21180
|
-
},
|
|
21181
|
-
toolResult: pushResult
|
|
21182
|
-
};
|
|
21183
|
-
setChatHistory((prev) => [...prev, pushFailEntry]);
|
|
21184
|
-
}
|
|
21185
|
-
}
|
|
21186
|
-
}
|
|
20697
|
+
setChatHistory((prev) => [...prev, resultEntry]);
|
|
21187
20698
|
} catch (error) {
|
|
21188
20699
|
const errorEntry = {
|
|
21189
20700
|
type: "assistant",
|
|
21190
|
-
content: `\u274C
|
|
21191
|
-
|
|
21192
|
-
${error instanceof Error ? error.message : String(error)}`,
|
|
20701
|
+
content: `\u274C Smart Push Failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
21193
20702
|
timestamp: /* @__PURE__ */ new Date()
|
|
21194
20703
|
};
|
|
21195
20704
|
setChatHistory((prev) => [...prev, errorEntry]);
|
|
@@ -24529,7 +24038,7 @@ var require_package = __commonJS({
|
|
|
24529
24038
|
module.exports = {
|
|
24530
24039
|
type: "module",
|
|
24531
24040
|
name: "@xagent/one-shot",
|
|
24532
|
-
version: "1.1.
|
|
24041
|
+
version: "1.1.101",
|
|
24533
24042
|
description: "An open-source AI agent that brings advanced AI capabilities directly into your terminal with automatic documentation updates.",
|
|
24534
24043
|
main: "dist/index.js",
|
|
24535
24044
|
module: "dist/index.js",
|