shenxiang-ai-cli 0.5.1 → 0.5.3
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 +70 -22
- package/package.json +64 -54
package/dist/index.js
CHANGED
|
@@ -730,24 +730,6 @@ var theme = {
|
|
|
730
730
|
tokenLabel: chalk.hex("#6B7280"),
|
|
731
731
|
tokenValue: chalk.hex("#A78BFA")
|
|
732
732
|
};
|
|
733
|
-
function banner() {
|
|
734
|
-
const p = theme.brand;
|
|
735
|
-
const b = theme.brandBold;
|
|
736
|
-
const d = theme.dim;
|
|
737
|
-
const m = theme.muted;
|
|
738
|
-
const y = chalk.hex("#FBBF24");
|
|
739
|
-
const r = chalk.hex("#F87171");
|
|
740
|
-
const w = chalk.white.bold;
|
|
741
|
-
const lines = [
|
|
742
|
-
``,
|
|
743
|
-
` ${p("/\\_/\\")} ${b("\u6C88\u7FD4\u7684AI\u52A9\u624B")} ${m("v0.5.1")}`,
|
|
744
|
-
` ${p("(")} ${y("o")}${p(".")}${y("o")} ${p(")")} ${d("\u7EC8\u7AEF\u91CC\u7684AI\u5168\u6808\u5F00\u53D1\u642D\u6863")}`,
|
|
745
|
-
` ${p("> ")}${r("^")}${p(" <")}`,
|
|
746
|
-
` ${p("/|")}${p(" |")}${p("\\")} ${d("\u4F60\u7684\u7F16\u7A0B\u597D\u4F19\u4F34")} ${chalk.hex("#A78BFA")("\u{1F43E}")}`,
|
|
747
|
-
` ${p("(_| |_)")}`
|
|
748
|
-
];
|
|
749
|
-
return lines.join("\n");
|
|
750
|
-
}
|
|
751
733
|
function separator() {
|
|
752
734
|
return theme.dim("\u2500".repeat(40));
|
|
753
735
|
}
|
|
@@ -1882,8 +1864,12 @@ var Agent = class {
|
|
|
1882
1864
|
const resetIdleTimer = () => {
|
|
1883
1865
|
if (idleTimer) clearTimeout(idleTimer);
|
|
1884
1866
|
idleTimer = setTimeout(() => {
|
|
1885
|
-
if (
|
|
1886
|
-
|
|
1867
|
+
if (isStreamingThinking && hasThinkingOutput) {
|
|
1868
|
+
isStreamingThinking = false;
|
|
1869
|
+
process.stdout.write("\n" + theme.dim(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500") + "\n");
|
|
1870
|
+
}
|
|
1871
|
+
if (!spinner.isSpinning && spinnerStopped) {
|
|
1872
|
+
spinner.text = "AI \u6B63\u5728\u751F\u6210\u4EE3\u7801...";
|
|
1887
1873
|
spinner.start();
|
|
1888
1874
|
}
|
|
1889
1875
|
}, 1500);
|
|
@@ -2232,6 +2218,68 @@ ${truncated}
|
|
|
2232
2218
|
}
|
|
2233
2219
|
};
|
|
2234
2220
|
|
|
2221
|
+
// src/ui/banner.ts
|
|
2222
|
+
import boxen from "boxen";
|
|
2223
|
+
import chalk3 from "chalk";
|
|
2224
|
+
function showBanner() {
|
|
2225
|
+
console.clear();
|
|
2226
|
+
const p = chalk3.hex("#A78BFA");
|
|
2227
|
+
const w = chalk3.white;
|
|
2228
|
+
const version = "v0.5.3";
|
|
2229
|
+
const avatarLines = [
|
|
2230
|
+
` ${p("\u2584\u2580\u2580\u2580\u2584")}`,
|
|
2231
|
+
` ${p("\u2588")} ${w("\u2580")} ${w("\u2580")} ${p("\u2588")}`,
|
|
2232
|
+
` ${p("\u2588")} ${w("\u2580")} ${p("\u2588")}`,
|
|
2233
|
+
` ${p("\u2580\u2584\u2584\u2584\u2584\u2584\u2580")}`,
|
|
2234
|
+
` ${p("\u2580")} ${p("\u2580")}`
|
|
2235
|
+
];
|
|
2236
|
+
const terminalWidth = process.stdout.columns || 80;
|
|
2237
|
+
const boxWidth = Math.max(60, Math.min(terminalWidth - 4, 120));
|
|
2238
|
+
const leftColWidth = Math.floor(boxWidth * 0.45);
|
|
2239
|
+
const rightColWidth = boxWidth - leftColWidth - 4;
|
|
2240
|
+
const leftContent = [
|
|
2241
|
+
"",
|
|
2242
|
+
" Welcome back!",
|
|
2243
|
+
"",
|
|
2244
|
+
...avatarLines,
|
|
2245
|
+
"",
|
|
2246
|
+
` ${theme.brandBold("DevPilot")} ${theme.dim(version)}`,
|
|
2247
|
+
` ${chalk3.dim(process.cwd().length > leftColWidth - 2 ? "..." + process.cwd().slice(-(leftColWidth - 5)) : process.cwd())}`,
|
|
2248
|
+
""
|
|
2249
|
+
];
|
|
2250
|
+
const rightContent = [
|
|
2251
|
+
theme.brand("Tips for getting started"),
|
|
2252
|
+
`Run ${theme.code("/help")} for a list of commands`,
|
|
2253
|
+
"",
|
|
2254
|
+
// Removed /init
|
|
2255
|
+
theme.brand("Recent activity"),
|
|
2256
|
+
"No recent activity",
|
|
2257
|
+
"",
|
|
2258
|
+
"",
|
|
2259
|
+
""
|
|
2260
|
+
];
|
|
2261
|
+
const maxLines = Math.max(leftContent.length, rightContent.length);
|
|
2262
|
+
const lines = [];
|
|
2263
|
+
for (let i = 0; i < maxLines; i++) {
|
|
2264
|
+
const left = leftContent[i] || "";
|
|
2265
|
+
const leftVisible = left.replace(/\u001b\[\d+m/g, "").length;
|
|
2266
|
+
const leftPadding = " ".repeat(Math.max(0, leftColWidth - leftVisible));
|
|
2267
|
+
const right = rightContent[i] || "";
|
|
2268
|
+
lines.push(`${left}${leftPadding} ${theme.dim("\u2502")} ${right}`);
|
|
2269
|
+
}
|
|
2270
|
+
const content = lines.join("\n");
|
|
2271
|
+
console.log(boxen(content, {
|
|
2272
|
+
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
|
2273
|
+
margin: 0,
|
|
2274
|
+
// No margin since we clear screen and want full width likely
|
|
2275
|
+
borderStyle: "round",
|
|
2276
|
+
borderColor: "#A78BFA",
|
|
2277
|
+
title: chalk3.hex("#A78BFA")(" \u6C88\u7FD4\u7684AI\u7F16\u7A0B\u52A9\u7406 "),
|
|
2278
|
+
titleAlignment: "left",
|
|
2279
|
+
width: boxWidth
|
|
2280
|
+
}));
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2235
2283
|
// src/commands/chat.ts
|
|
2236
2284
|
async function chatCommand(options = {}) {
|
|
2237
2285
|
const config3 = getConfig();
|
|
@@ -2249,7 +2297,7 @@ async function chatCommand(options = {}) {
|
|
|
2249
2297
|
console.error(theme.error(`
|
|
2250
2298
|
\u26A0 \u672A\u6355\u83B7\u9519\u8BEF: ${err.message}`));
|
|
2251
2299
|
});
|
|
2252
|
-
|
|
2300
|
+
showBanner();
|
|
2253
2301
|
if (isYoloMode()) {
|
|
2254
2302
|
console.log(theme.warning(" \u26A1 \u81EA\u52A8\u6A21\u5F0F (YOLO) \u2014 \u6240\u6709\u64CD\u4F5C\u81EA\u52A8\u6267\u884C\uFF0C\u65E0\u9700\u786E\u8BA4"));
|
|
2255
2303
|
}
|
|
@@ -3324,7 +3372,7 @@ function fmtTokens3(n) {
|
|
|
3324
3372
|
var program = new Command();
|
|
3325
3373
|
var config2 = getConfig();
|
|
3326
3374
|
setLocale(config2.locale);
|
|
3327
|
-
program.name("sxai").description(t("description")).version("0.5.
|
|
3375
|
+
program.name("sxai").description(t("description")).version("0.5.3");
|
|
3328
3376
|
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) => {
|
|
3329
3377
|
if (options.model && options.model !== config2.model) {
|
|
3330
3378
|
setConfig("model", options.model);
|
package/package.json
CHANGED
|
@@ -1,54 +1,64 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "shenxiang-ai-cli",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "沈翔的AI助手 - 终端里的AI全栈开发搭档",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"sxai": "./dist/index.js"
|
|
8
|
-
},
|
|
9
|
-
"main": "./dist/index.js",
|
|
10
|
-
"files": [
|
|
11
|
-
"dist",
|
|
12
|
-
"README.md"
|
|
13
|
-
],
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": ""
|
|
17
|
-
},
|
|
18
|
-
"engines": {
|
|
19
|
-
"node": ">=18.0.0"
|
|
20
|
-
},
|
|
21
|
-
"scripts": {
|
|
22
|
-
"dev": "tsx watch src/index.ts",
|
|
23
|
-
"build": "tsup src/index.ts --format esm --clean",
|
|
24
|
-
"start": "node dist/index.js",
|
|
25
|
-
"clean": "rimraf dist",
|
|
26
|
-
"prepublishOnly": "npm run build"
|
|
27
|
-
},
|
|
28
|
-
"keywords": [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"cli-highlight": "^2.1.11",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "shenxiang-ai-cli",
|
|
3
|
+
"version": "0.5.3",
|
|
4
|
+
"description": "沈翔的AI助手 - 终端里的AI全栈开发搭档",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"sxai": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": ""
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18.0.0"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"dev": "tsx watch src/index.ts",
|
|
23
|
+
"build": "tsup src/index.ts --format esm --clean",
|
|
24
|
+
"start": "node dist/index.js",
|
|
25
|
+
"clean": "rimraf dist",
|
|
26
|
+
"prepublishOnly": "npm run build"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"ai",
|
|
30
|
+
"cli",
|
|
31
|
+
"coding",
|
|
32
|
+
"assistant",
|
|
33
|
+
"devpilot",
|
|
34
|
+
"fullstack",
|
|
35
|
+
"chinese",
|
|
36
|
+
"developer-tools"
|
|
37
|
+
],
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"boxen": "^8.0.1",
|
|
41
|
+
"chalk": "^5.3.0",
|
|
42
|
+
"cli-highlight": "^2.1.11",
|
|
43
|
+
"commander": "^12.1.0",
|
|
44
|
+
"conf": "^13.0.1",
|
|
45
|
+
"diff": "^7.0.0",
|
|
46
|
+
"glob": "^11.0.0",
|
|
47
|
+
"inquirer": "^9.3.0",
|
|
48
|
+
"marked": "^14.0.0",
|
|
49
|
+
"marked-terminal": "^7.2.0",
|
|
50
|
+
"openai": "^4.70.0",
|
|
51
|
+
"ora": "^8.1.0",
|
|
52
|
+
"simple-git": "^3.27.0",
|
|
53
|
+
"strip-ansi": "^7.1.0",
|
|
54
|
+
"undici": "^6.21.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/diff": "^6.0.0",
|
|
58
|
+
"@types/node": "^22.0.0",
|
|
59
|
+
"rimraf": "^6.0.0",
|
|
60
|
+
"tsup": "^8.3.0",
|
|
61
|
+
"tsx": "^4.19.0",
|
|
62
|
+
"typescript": "^5.6.0"
|
|
63
|
+
}
|
|
64
|
+
}
|