shenxiang-ai-cli 0.5.0 → 0.5.1
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 +30 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -740,7 +740,7 @@ function banner() {
|
|
|
740
740
|
const w = chalk.white.bold;
|
|
741
741
|
const lines = [
|
|
742
742
|
``,
|
|
743
|
-
` ${p("/\\_/\\")} ${b("\u6C88\u7FD4\u7684AI\u52A9\u624B")} ${m("v0.5.
|
|
743
|
+
` ${p("/\\_/\\")} ${b("\u6C88\u7FD4\u7684AI\u52A9\u624B")} ${m("v0.5.1")}`,
|
|
744
744
|
` ${p("(")} ${y("o")}${p(".")}${y("o")} ${p(")")} ${d("\u7EC8\u7AEF\u91CC\u7684AI\u5168\u6808\u5F00\u53D1\u642D\u6863")}`,
|
|
745
745
|
` ${p("> ")}${r("^")}${p(" <")}`,
|
|
746
746
|
` ${p("/|")}${p(" |")}${p("\\")} ${d("\u4F60\u7684\u7F16\u7A0B\u597D\u4F19\u4F34")} ${chalk.hex("#A78BFA")("\u{1F43E}")}`,
|
|
@@ -893,7 +893,8 @@ var writeFileTool = {
|
|
|
893
893
|
return { success: false, output: "", error: `Failed to write file: ${msg}` };
|
|
894
894
|
}
|
|
895
895
|
},
|
|
896
|
-
requiresConfirmation:
|
|
896
|
+
requiresConfirmation: false
|
|
897
|
+
// auto-approve for speed; use /auto off + delete_file for safety
|
|
897
898
|
};
|
|
898
899
|
var editFileTool = {
|
|
899
900
|
definition: {
|
|
@@ -956,7 +957,8 @@ var editFileTool = {
|
|
|
956
957
|
return { success: false, output: "", error: `Failed to edit file: ${msg}` };
|
|
957
958
|
}
|
|
958
959
|
},
|
|
959
|
-
requiresConfirmation:
|
|
960
|
+
requiresConfirmation: false
|
|
961
|
+
// auto-approve for speed
|
|
960
962
|
};
|
|
961
963
|
var deleteFileTool = {
|
|
962
964
|
definition: {
|
|
@@ -1676,7 +1678,8 @@ function generateSystemPrompt(ctx) {
|
|
|
1676
1678
|
[\u89D2\u8272] \u7528\u6237\u662F\u4EA7\u54C1\u8D1F\u8D23\u4EBA\uFF0C\u4F60\u6765\u5B9E\u73B0\u3002\u901A\u4FD7\u89E3\u91CA\uFF0C\u4E0D\u5806\u672F\u8BED\u3002\u65B9\u5411\u4E0D\u5BF9\u5C31\u63D0\u9192\u3002\u5BF9\u5C40\u9650\u6027\u8BDA\u5B9E\u3002`);
|
|
1677
1679
|
parts.push(`[\u534F\u4F5C] \u63A2\u7D22\u9700\u6C42\u2192\u89C4\u5212\u65B9\u6848\u2192\u5206\u9636\u6BB5\u6784\u5EFA\u2192\u6253\u78E8\u7EC6\u8282\u2192\u4EA4\u4ED8\u90E8\u7F72\u3002\u5173\u952E\u51B3\u7B56\u70B9\u505C\u4E0B\u786E\u8BA4\uFF0C\u9047\u95EE\u9898\u7ED9\u9009\u9879\u800C\u975E\u66FF\u7528\u6237\u51B3\u5B9A\u3002`);
|
|
1678
1680
|
parts.push(`
|
|
1679
|
-
[\u539F\u5219] \u5148\u8BFB\u518D\u6539\uFF1Bedit_file\u5C40\u90E8\u7F16\u8F91\uFF1B\u7834\u574F\u6027\u64CD\u4F5C\u8C28\u614E\uFF1B\u9075\u5FAA\u9879\u76EE\u98CE\u683C\uFF1B\u4E0D\u786E\u5B9A\u5C31\u5148\u641C\u7D22\uFF1B\u7528${ctx.packageManager}\u6267\u884C\u547D\u4EE4\
|
|
1681
|
+
[\u539F\u5219] \u5148\u8BFB\u518D\u6539\uFF1Bedit_file\u5C40\u90E8\u7F16\u8F91\uFF1B\u7834\u574F\u6027\u64CD\u4F5C\u8C28\u614E\uFF1B\u9075\u5FAA\u9879\u76EE\u98CE\u683C\uFF1B\u4E0D\u786E\u5B9A\u5C31\u5148\u641C\u7D22\uFF1B\u7528${ctx.packageManager}\u6267\u884C\u547D\u4EE4\u3002`);
|
|
1682
|
+
parts.push(`[\u6548\u7387] \u91CD\u8981\uFF1A\u5C3D\u91CF\u5728\u4E00\u6B21\u56DE\u590D\u4E2D\u8FD4\u56DE\u591A\u4E2A\u5DE5\u5177\u8C03\u7528\uFF08\u5E76\u884C\uFF09\uFF0C\u4E0D\u8981\u4E00\u4E2A\u4E00\u4E2A\u6765\u3002\u4F8B\u5982\u9700\u8981\u521B\u5EFA3\u4E2A\u6587\u4EF6\uFF0C\u4E00\u6B21\u6027\u8FD4\u56DE3\u4E2Awrite_file\u8C03\u7528\uFF0C\u800C\u4E0D\u662F\u5199\u5B8C\u4E00\u4E2A\u518D\u5199\u4E0B\u4E00\u4E2A\u3002\u8FD9\u6837\u5927\u5E45\u51CF\u5C11\u7B49\u5F85\u65F6\u95F4\u3002`);
|
|
1680
1683
|
if (ctx.projectType !== "unknown") {
|
|
1681
1684
|
const info = [`\u76EE\u5F55:${ctx.rootDir}`, `\u7C7B\u578B:${ctx.projectType}`];
|
|
1682
1685
|
if (ctx.projectName) info.push(`\u540D\u79F0:${ctx.projectName}`);
|
|
@@ -2017,7 +2020,8 @@ var Agent = class {
|
|
|
2017
2020
|
if (reasoningContent) assistantMsg.reasoning_content = reasoningContent;
|
|
2018
2021
|
this.messages.push(assistantMsg);
|
|
2019
2022
|
console.log();
|
|
2020
|
-
|
|
2023
|
+
if (toolCalls.length === 1) {
|
|
2024
|
+
const tc = toolCalls[0];
|
|
2021
2025
|
let args;
|
|
2022
2026
|
try {
|
|
2023
2027
|
args = JSON.parse(tc.function.arguments);
|
|
@@ -2031,6 +2035,26 @@ var Agent = class {
|
|
|
2031
2035
|
tool_call_id: tc.id,
|
|
2032
2036
|
name: tc.function.name
|
|
2033
2037
|
});
|
|
2038
|
+
} else {
|
|
2039
|
+
const tasks = toolCalls.map(async (tc) => {
|
|
2040
|
+
let args;
|
|
2041
|
+
try {
|
|
2042
|
+
args = JSON.parse(tc.function.arguments);
|
|
2043
|
+
} catch {
|
|
2044
|
+
args = {};
|
|
2045
|
+
}
|
|
2046
|
+
const result = await executeTool(tc.function.name, args);
|
|
2047
|
+
return { tc, result };
|
|
2048
|
+
});
|
|
2049
|
+
const results = await Promise.all(tasks);
|
|
2050
|
+
for (const { tc, result } of results) {
|
|
2051
|
+
this.messages.push({
|
|
2052
|
+
role: "tool",
|
|
2053
|
+
content: result.error || result.output,
|
|
2054
|
+
tool_call_id: tc.id,
|
|
2055
|
+
name: tc.function.name
|
|
2056
|
+
});
|
|
2057
|
+
}
|
|
2034
2058
|
}
|
|
2035
2059
|
}
|
|
2036
2060
|
if (iteration >= MAX_TOOL_ITERATIONS) {
|
|
@@ -3300,7 +3324,7 @@ function fmtTokens3(n) {
|
|
|
3300
3324
|
var program = new Command();
|
|
3301
3325
|
var config2 = getConfig();
|
|
3302
3326
|
setLocale(config2.locale);
|
|
3303
|
-
program.name("sxai").description(t("description")).version("0.5.
|
|
3327
|
+
program.name("sxai").description(t("description")).version("0.5.1");
|
|
3304
3328
|
program.command("chat", { isDefault: true }).description("\u542F\u52A8\u4EA4\u4E92\u5F0FAI\u5BF9\u8BDD\uFF08\u9ED8\u8BA4\u547D\u4EE4\uFF09").option("-m, --model <model>", "\u6307\u5B9AAI\u6A21\u578B", config2.model).option("-y, --yolo", "\u81EA\u52A8\u6A21\u5F0F\uFF1A\u8DF3\u8FC7\u6240\u6709\u786E\u8BA4\uFF0C\u8BA9AI\u81EA\u4E3B\u6267\u884C").action(async (options) => {
|
|
3305
3329
|
if (options.model && options.model !== config2.model) {
|
|
3306
3330
|
setConfig("model", options.model);
|