yuangs 1.2.3 → 1.2.5
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/cli.js +26 -19
- package/package.json +2 -2
package/cli.js
CHANGED
|
@@ -82,7 +82,7 @@ async function handleAICommand() {
|
|
|
82
82
|
|
|
83
83
|
// 如果用户直接输入 `yuangs ai`,进入交互式模式
|
|
84
84
|
if (!question) {
|
|
85
|
-
console.log(chalk.bold.cyan('\n🤖 进入 AI 交互模式 (
|
|
85
|
+
console.log(chalk.bold.cyan('\n🤖 进入 AI 交互模式 (输入 exit 退出)\n'));
|
|
86
86
|
console.log(chalk.gray('直接输入你的问题,每回车一次提一个问题。\n'));
|
|
87
87
|
|
|
88
88
|
const readline = require('readline');
|
|
@@ -91,24 +91,31 @@ async function handleAICommand() {
|
|
|
91
91
|
output: process.stdout
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
+
// 定义递归询问函数
|
|
94
95
|
const askLoop = () => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
96
|
+
rl.question(chalk.green('你:'), async (q) => {
|
|
97
|
+
const trimmed = q.trim();
|
|
98
|
+
|
|
99
|
+
// ✨ 新增:优雅退出
|
|
100
|
+
if (['exit', 'quit', 'bye'].includes(trimmed.toLowerCase())) {
|
|
101
|
+
console.log(chalk.cyan('👋 再见!'));
|
|
102
|
+
rl.close();
|
|
103
|
+
process.exit(0);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!trimmed) {
|
|
107
|
+
return askLoop(); // 空输入则重新询问
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 等待回答完成后,再开启下一轮询问
|
|
111
|
+
await askOnce(trimmed, model);
|
|
112
|
+
askLoop();
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// 启动循环
|
|
117
|
+
askLoop();
|
|
118
|
+
return; // 结束函数,不再执行下面的单次请求
|
|
112
119
|
}
|
|
113
120
|
|
|
114
121
|
// 有问题时,直接请求一次
|
|
@@ -145,4 +152,4 @@ switch (command) {
|
|
|
145
152
|
default:
|
|
146
153
|
printHelp();
|
|
147
154
|
break;
|
|
148
|
-
}
|
|
155
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuangs",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "苑广山的个人应用集合 CLI(彩色版)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"yuangs": "
|
|
7
|
+
"yuangs": "cli.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|