yuangs 1.3.38 → 1.3.41

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.
Files changed (57) hide show
  1. package/README.md +44 -0
  2. package/dist/ai/client.d.ts +9 -0
  3. package/dist/ai/client.js +118 -0
  4. package/dist/ai/client.js.map +1 -0
  5. package/dist/ai/prompt.d.ts +3 -0
  6. package/dist/ai/prompt.js +56 -0
  7. package/dist/ai/prompt.js.map +1 -0
  8. package/dist/ai/types.d.ts +5 -0
  9. package/dist/ai/types.js +3 -0
  10. package/dist/ai/types.js.map +1 -0
  11. package/dist/cli.d.ts +2 -0
  12. package/dist/cli.js +125 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/commands/handleAIChat.d.ts +1 -0
  15. package/dist/commands/handleAIChat.js +92 -0
  16. package/dist/commands/handleAIChat.js.map +1 -0
  17. package/dist/commands/handleAICommand.d.ts +4 -0
  18. package/dist/commands/handleAICommand.js +97 -0
  19. package/dist/commands/handleAICommand.js.map +1 -0
  20. package/dist/commands/handleConfig.d.ts +1 -0
  21. package/dist/commands/handleConfig.js +73 -0
  22. package/dist/commands/handleConfig.js.map +1 -0
  23. package/dist/core/apps.d.ts +7 -0
  24. package/dist/core/apps.js +64 -0
  25. package/dist/core/apps.js.map +1 -0
  26. package/dist/core/autofix.d.ts +3 -0
  27. package/dist/core/autofix.js +24 -0
  28. package/dist/core/autofix.js.map +1 -0
  29. package/dist/core/executor.d.ts +6 -0
  30. package/dist/core/executor.js +28 -0
  31. package/dist/core/executor.js.map +1 -0
  32. package/dist/core/macros.d.ts +9 -0
  33. package/dist/core/macros.js +51 -0
  34. package/dist/core/macros.js.map +1 -0
  35. package/dist/core/os.d.ts +7 -0
  36. package/dist/core/os.js +36 -0
  37. package/dist/core/os.js.map +1 -0
  38. package/dist/core/risk.d.ts +1 -0
  39. package/dist/core/risk.js +11 -0
  40. package/dist/core/risk.js.map +1 -0
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.js +3 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/utils/confirm.d.ts +1 -0
  45. package/dist/utils/confirm.js +21 -0
  46. package/dist/utils/confirm.js.map +1 -0
  47. package/dist/utils/history.d.ts +10 -0
  48. package/dist/utils/history.js +31 -0
  49. package/dist/utils/history.js.map +1 -0
  50. package/package.json +25 -9
  51. package/cli.js +0 -560
  52. package/index.js +0 -361
  53. package/test/index.test.js +0 -78
  54. package/test/macros.test.js +0 -91
  55. package/yuangs.config.example.json +0 -11
  56. package/yuangs.config.example.yaml +0 -23
  57. package/yuangs.config.json +0 -9
package/cli.js DELETED
@@ -1,560 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const yuangs = require('./index.js');
4
- const chalk = require('chalk');
5
- const { version } = require('./package.json');
6
- const fs = require('fs');
7
- const path = require('path');
8
- const ora = require('ora').default;
9
- const { marked } = require('marked');
10
- const TerminalRenderer = require('marked-terminal').default;
11
- const { exec } = require('child_process');
12
-
13
- marked.setOptions({
14
- renderer: new TerminalRenderer({
15
- code: chalk.yellow,
16
- heading: chalk.magenta.bold,
17
- firstHeading: chalk.magenta.underline.bold,
18
- listitem: chalk.cyan,
19
- table: chalk.white,
20
- strong: chalk.bold.red,
21
- em: chalk.italic
22
- })
23
- });
24
-
25
- const args = process.argv.slice(2);
26
- const command = args[0];
27
-
28
- async function readStdin() {
29
- if (process.stdin.isTTY) return '';
30
- return new Promise((resolve) => {
31
- let data = '';
32
- process.stdin.setEncoding('utf8');
33
- process.stdin.on('data', (chunk) => {
34
- data += chunk;
35
- });
36
- process.stdin.on('end', () => {
37
- resolve(data);
38
- });
39
- });
40
- }
41
-
42
- function printHelp() {
43
- console.log(chalk.bold.cyan('\n🎨 苑广山的个人应用启动器\n'));
44
- console.log(chalk.yellow(`当前版本: ${version}`)); // 显示版本号
45
- console.log(chalk.gray('仓库地址: https://www.npmjs.com/package/yuangs?activeTab=readme\n'));
46
- console.log(chalk.white('使用方法:') + chalk.gray(' yuangs <命令> [参数]\n'));
47
- console.log(chalk.bold('命令列表:'));
48
-
49
- // Show default commands
50
- console.log(` ${chalk.green('shici')} 打开古诗词 PWA`);
51
- console.log(` ${chalk.green('dict')} 打开英语词典`);
52
- console.log(` ${chalk.green('pong')} 打开 Pong 游戏`);
53
- console.log(` ${chalk.green('list')} 列出所有应用链接`);
54
-
55
- // Show dynamically configured apps
56
- const dynamicApps = Object.keys(yuangs.urls).filter(key =>
57
- !['shici', 'dict', 'pong'].includes(key)
58
- );
59
- if (dynamicApps.length > 0) {
60
- console.log(chalk.bold('\n自定义应用:'));
61
- dynamicApps.forEach(app => {
62
- console.log(` ${chalk.green(app)} 打开 ${app} 应用`);
63
- });
64
- }
65
-
66
- console.log(` ${chalk.green('ai')} "<问题>" 向 AI 提问(不写问题进入交互模式)`);
67
- console.log(` ${chalk.gray('--model, -m <模型名称>')} 指定 AI 模型 (可选)`);
68
- console.log(` ${chalk.gray('-p -f -l')} 指定 pro,flash,lite 模型 (可选)`);
69
- console.log(` ${chalk.gray('-e <描述>')} 生成 Linux 命令`);
70
- console.log(` ${chalk.green('config')} <key> <value> 设置配置项`);
71
- console.log(` ${chalk.green('history')} 查看命令历史`);
72
- console.log(` ${chalk.green('save')} <名称> 创建快捷指令`);
73
- console.log(` ${chalk.green('run')} <名称> 执行快捷指令`);
74
- console.log(` ${chalk.green('macros')} 查看所有快捷指令`);
75
- console.log(` ${chalk.green('help')} 显示帮助信息\n`);
76
- console.log(chalk.bold('AI 交互模式命令:'));
77
- console.log(` ${chalk.gray('/clear')} 清空对话历史`);
78
- console.log(` ${chalk.gray('/history')} 查看对话历史\n`);
79
- console.log(chalk.gray('AI 示例: yuangs ai "你好" --model gemini-pro-latest'));
80
- console.log(chalk.gray('AI 生成命令: yuangs ai -e "查看当前目录"'));
81
- console.log(chalk.gray('普通示例: yuangs shici\n'));
82
- console.log(chalk.gray('配置文件: 您可以通过创建 yuangs.config.json 或 ~/.yuangs.json 来自定义应用列表\n'));
83
- }
84
-
85
- function printSuccess(app, url) {
86
- console.log(chalk.green(`✓ 正在打开 ${app}...`));
87
- console.log(chalk.gray(` ${url}`));
88
- }
89
-
90
- async function askOnce(question, model) {
91
- const startTime = Date.now();
92
- let i = 0;
93
- const spinner = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
94
- const interval = setInterval(() => {
95
- const elapsedTime = Math.floor((Date.now() - startTime) / 1000);
96
- process.stdout.write(chalk.cyan(`\r${spinner[i++ % spinner.length]} 正在请求 AI,请稍候... (${elapsedTime}s}`));
97
- }, 100);
98
-
99
- try {
100
- const answer = await yuangs.getAIAnswer(question, model, true);
101
- clearInterval(interval);
102
-
103
- if (process.stdout.clearLine) {
104
- process.stdout.clearLine(0);
105
- process.stdout.cursorTo(0);
106
- } else {
107
- process.stdout.write('\r');
108
- }
109
-
110
- const totalElapsedTime = (Date.now() - startTime) / 1000;
111
- if (answer && answer.explanation) {
112
- console.log(marked(answer.explanation));
113
- } else {
114
- console.log(chalk.yellow('AI 未返回有效内容。'));
115
- }
116
- console.log(chalk.gray(`\n请求耗时: ${totalElapsedTime.toFixed(2)}s\n`));
117
- } catch (error) {
118
- clearInterval(interval);
119
-
120
- if (process.stdout.clearLine) {
121
- process.stdout.clearLine(0);
122
- process.stdout.cursorTo(0);
123
- } else {
124
- process.stdout.write('\r');
125
- }
126
-
127
- const totalElapsedTime = (Date.now() - startTime) / 1000;
128
- console.error(chalk.red('处理 AI 请求时出错:'), error.message || error);
129
- console.log(chalk.gray(`\n请求耗时: ${totalElapsedTime.toFixed(2)}s\n`));
130
- }
131
- }
132
-
133
- async function askOnceStream(question, model) {
134
- const startTime = Date.now();
135
- let messages = [...yuangs.getConversationHistory()];
136
- messages.push({ role: 'user', content: question });
137
-
138
- const spinner = ora(chalk.cyan('AI 正在思考...')).start();
139
- let fullResponse = '';
140
- let firstChunk = true;
141
-
142
- const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
143
-
144
- try {
145
- await yuangs.callAI_Stream(messages, model, (chunk) => {
146
- if (spinner.isSpinning) {
147
- spinner.stop();
148
- }
149
- fullResponse += chunk;
150
- process.stdout.write(chunk);
151
- });
152
-
153
- yuangs.addToConversationHistory('user', question);
154
- yuangs.addToConversationHistory('assistant', fullResponse);
155
-
156
- // 打印优美的分割线和 Markdown 渲染结果
157
- console.log('');
158
- console.log(chalk.gray('─'.repeat(Math.min(80, process.stdout.columns || 80))));
159
- console.log(marked(fullResponse));
160
-
161
- const totalElapsedTime = (Date.now() - startTime) / 1000;
162
- console.log(chalk.gray(`\n\n请求耗时: ${totalElapsedTime.toFixed(2)}s\n`));
163
- } catch (error) {
164
- if (spinner.isSpinning) {
165
- spinner.fail(chalk.red('AI 响应出错'));
166
- }
167
- console.error(error.message);
168
- }
169
- }
170
-
171
- async function handleAICommand() {
172
- const commandArgs = args.slice(1);
173
-
174
- let model = null;
175
- let questionParts = commandArgs;
176
- let isExecMode = false;
177
-
178
- const stdinContent = await readStdin();
179
-
180
- if (stdinContent) {
181
- questionParts.unshift(stdinContent);
182
- }
183
-
184
- // Check for -e flag
185
- const execIndex = commandArgs.indexOf('-e');
186
- if (execIndex !== -1) {
187
- isExecMode = true;
188
- // removing -e from args
189
- const before = commandArgs.slice(0, execIndex);
190
- const after = commandArgs.slice(execIndex + 1);
191
- questionParts = [...before, ...after];
192
- }
193
-
194
- // Check for shorthand model flags first
195
- const proIndex = questionParts.indexOf('-p');
196
- const flashIndex = questionParts.indexOf('-f');
197
- const liteIndex = questionParts.indexOf('-l');
198
-
199
- if (proIndex !== -1) {
200
- model = 'gemini-pro-latest';
201
- questionParts = questionParts.filter((_, index) => index !== proIndex);
202
- } else if (flashIndex !== -1) {
203
- model = 'gemini-flash-latest';
204
- questionParts = questionParts.filter((_, index) => index !== flashIndex);
205
- } else if (liteIndex !== -1) {
206
- model = 'gemini-flash-lite-latest';
207
- questionParts = questionParts.filter((_, index) => index !== liteIndex);
208
- }
209
-
210
- // If shorthand flags are not used, check for --model or -m
211
- if (!model) {
212
- const longIndex = questionParts.indexOf('--model');
213
- const shortIndex = questionParts.indexOf('-m');
214
- const modelIndex = longIndex !== -1 ? longIndex : shortIndex;
215
-
216
- if (modelIndex !== -1 && questionParts.length > modelIndex + 1) {
217
- model = questionParts[modelIndex + 1];
218
- // Filter out --model/-m and its value
219
- questionParts = questionParts.filter((_, index) => index !== modelIndex && index !== modelIndex + 1);
220
- }
221
- }
222
-
223
- const question = questionParts.join(' ').trim();
224
-
225
- // Special handling for execution mode
226
- if (isExecMode) {
227
- if (!question) {
228
- console.log(chalk.red('错误: 使用 -e 参数时必需提供描述。'));
229
- return;
230
- }
231
-
232
- const startTime = Date.now();
233
- let i = 0;
234
- const spinner = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
235
- const interval = setInterval(() => {
236
- process.stdout.write(chalk.cyan(`\r${spinner[i++ % spinner.length]} 正在生成命令...`));
237
- }, 100);
238
-
239
- const command = await yuangs.generateCommand(question, model);
240
- clearInterval(interval);
241
-
242
- if (process.stdout.clearLine) {
243
- process.stdout.clearLine(0);
244
- process.stdout.cursorTo(0);
245
- } else {
246
- process.stdout.write('\r');
247
- }
248
-
249
- if (command) {
250
- console.log(chalk.gray('生成命令:'));
251
- console.log(chalk.bold.green(`> ${command}`));
252
-
253
- // 1. Try to copy to clipboard
254
- let copied = false;
255
- try {
256
- const { spawn } = require('child_process');
257
- let copyCmd, copyArgs = [];
258
- if (process.platform === 'darwin') {
259
- copyCmd = 'pbcopy';
260
- } else if (process.platform === 'win32') {
261
- copyCmd = 'clip';
262
- }
263
-
264
- if (copyCmd) {
265
- const proc = spawn(copyCmd, copyArgs);
266
- proc.stdin.write(command);
267
- proc.stdin.end();
268
- copied = true;
269
- console.log(chalk.gray('(已复制到剪贴板)'));
270
- }
271
- } catch (e) {
272
- // Ignore copy errors
273
- }
274
-
275
- // 2. Pre-fill and ask to execute
276
- const readline = require('readline');
277
- const rl = readline.createInterface({
278
- input: process.stdin,
279
- output: process.stdout
280
- });
281
-
282
- console.log(chalk.gray('👇 您可以直接回车执行,或修改后回车:'));
283
-
284
- // This puts the command into the input line, effectively "pre-filling" it
285
- rl.write(command);
286
-
287
- rl.on('line', (input) => {
288
- rl.close();
289
- const finalCommand = input.trim();
290
-
291
- if (!finalCommand) {
292
- process.exit(0);
293
- }
294
-
295
- const { spawn } = require('child_process');
296
- console.log(chalk.gray('正在执行...'));
297
- const child = spawn(finalCommand, [], { shell: true, stdio: 'inherit' });
298
-
299
- child.on('close', (code) => {
300
- if (code === 0) {
301
- yuangs.saveSuccessfulCommand(question, finalCommand);
302
- console.log(chalk.green('\n✓ 执行成功并已存入历史库'));
303
- } else {
304
- console.log(chalk.red(`\n命令执行失败 (退出码: ${code})`));
305
- }
306
- process.exit(code);
307
- });
308
- });
309
-
310
- // Return to avoid continuing to other logic, let callback handle exit
311
- return;
312
-
313
- } else {
314
- console.log(chalk.yellow('未能生成有效的命令。'));
315
- process.exit(1);
316
- }
317
- return;
318
- }
319
-
320
- // 如果用户直接输入 `yuangs ai`,进入交互式模式
321
- if (!question) {
322
- console.log(chalk.bold.cyan('\n🤖 进入 AI 交互模式 (输入 exit 退出)\n'));
323
- console.log(chalk.gray('直接输入你的问题,每回车一次提一个问题。\n'));
324
- console.log(chalk.gray('支持的命令:'));
325
- console.log(chalk.gray(' /clear - 清空对话历史'));
326
- console.log(chalk.gray(' /history - 查看对话历史\n'));
327
-
328
- const readline = require('readline');
329
- const rl = readline.createInterface({
330
- input: process.stdin,
331
- output: process.stdout
332
- });
333
-
334
- // 定义递归询问函数
335
- const askLoop = () => {
336
- rl.question(chalk.green('你:'), async (q) => {
337
- const trimmed = q.trim();
338
-
339
- // ✨ 新增:优雅退出
340
- if (['exit', 'quit', 'bye'].includes(trimmed.toLowerCase())) {
341
- console.log(chalk.cyan('👋 再见!'));
342
- rl.close();
343
- process.exit(0);
344
- }
345
-
346
- // Handle special commands
347
- if (trimmed === '/clear') {
348
- yuangs.clearConversationHistory();
349
- console.log(chalk.yellow('✓ 对话历史已清空\n'));
350
- return askLoop();
351
- }
352
-
353
- if (trimmed === '/history') {
354
- const history = yuangs.getConversationHistory();
355
- if (history.length === 0) {
356
- console.log(chalk.gray('暂无对话历史\n'));
357
- } else {
358
- console.log(chalk.bold('📋 对话历史:\n'));
359
- history.forEach((msg, index) => {
360
- const prefix = msg.role === 'user' ? chalk.green('你: ') : chalk.blue('AI: ');
361
- console.log(prefix + msg.content);
362
- });
363
- console.log('');
364
- }
365
- return askLoop();
366
- }
367
-
368
- if (!trimmed) {
369
- return askLoop();
370
- }
371
-
372
- await askOnceStream(trimmed, model);
373
- askLoop();
374
- });
375
- };
376
-
377
- // 启动循环
378
- askLoop();
379
- return; // 结束函数,不再执行下面的单次请求
380
- }
381
-
382
- // 有问题时,直接请求一次
383
- await askOnceStream(question, model);
384
- }
385
-
386
- // Check if the command matches one of the configured apps
387
- const isAppCommand = Object.keys(yuangs.urls).includes(command);
388
-
389
- switch (command) {
390
- case 'shici':
391
- printSuccess('古诗词应用', yuangs.urls.shici || 'N/A');
392
- yuangs.openShici();
393
- break;
394
- case 'dict':
395
- printSuccess('英语词典', yuangs.urls.dict || 'N/A');
396
- yuangs.openDict();
397
- break;
398
- case 'pong':
399
- printSuccess('Pong 游戏', yuangs.urls.pong || 'N/A');
400
- yuangs.openPong();
401
- break;
402
- case 'list':
403
- console.log(chalk.bold.cyan('\n📱 苑广山的应用列表\n'));
404
- console.log(chalk.gray('─────────────────────────────────────────────────'));
405
- Object.entries(yuangs.urls).forEach(([key, url]) => {
406
- console.log(` ${chalk.green('●')} ${chalk.bold(key.padEnd(8))} ${chalk.blue(url)}`);
407
- });
408
- console.log(chalk.gray('─────────────────────────────────────────────────\n'));
409
- break;
410
- case 'ai':
411
- handleAICommand();
412
- break;
413
- case 'config':
414
- const key = args[1];
415
- const value = args[2];
416
- if (!key || !value) {
417
- console.log(chalk.cyan('\n⚙️ 配置帮助: yuangs config <key> <value>'));
418
- console.log(chalk.gray('当前配置:'), yuangs.getUserConfig());
419
- console.log(chalk.gray('\n可用配置:'));
420
- console.log(chalk.gray(' defaultModel 默认AI模型 (如: Assistant, gemini-pro-latest)'));
421
- console.log(chalk.gray(' aiProxyUrl AI代理地址'));
422
- console.log(chalk.gray(' accountType 账户类型 (如: free, pro)\n'));
423
- break;
424
- }
425
- const config = yuangs.getUserConfig();
426
- config[key] = value;
427
- fs.writeFileSync(path.join(require('os').homedir(), '.yuangs.json'), JSON.stringify(config, null, 2));
428
- console.log(chalk.green(`✓ 已更新 ${key}`));
429
- break;
430
- case 'history':
431
- const history = yuangs.getCommandHistory();
432
- if (history.length === 0) {
433
- console.log(chalk.gray('暂无命令历史\n'));
434
- } else {
435
- console.log(chalk.bold.cyan('\n📋 命令历史\n'));
436
- console.log(chalk.gray('─────────────────────────────────────────────────'));
437
- history.forEach((item, index) => {
438
- console.log(chalk.white(`${index + 1}. ${item.command}`));
439
- console.log(chalk.gray(` 问题: ${item.question}`));
440
- console.log(chalk.gray(` 时间: ${item.time}\n`));
441
- });
442
- console.log(chalk.gray('─────────────────────────────────────────────────\n'));
443
- }
444
- break;
445
- case 'save':
446
- const macroName = args[1];
447
- if (!macroName) {
448
- console.log(chalk.red('\n错误: 请指定快捷指令名称'));
449
- console.log(chalk.gray('用法: yuangs save <名称>\n'));
450
- break;
451
- }
452
-
453
- const readline = require('readline');
454
- const saveRl = readline.createInterface({
455
- input: process.stdin,
456
- output: process.stdout
457
- });
458
-
459
- console.log(chalk.cyan(`\n正在创建快捷指令 "${macroName}"...`));
460
- console.log(chalk.gray('请输入要保存的命令(多行命令用 && 或 ; 分隔,输入空行结束):\n'));
461
-
462
- let commandLines = [];
463
- const askCommand = () => {
464
- saveRl.question(chalk.green('> '), (line) => {
465
- if (line.trim() === '') {
466
- if (commandLines.length === 0) {
467
- console.log(chalk.yellow('\n未输入命令,已取消'));
468
- saveRl.close();
469
- return;
470
- }
471
-
472
- saveRl.question(chalk.cyan('请输入描述(可选): '), (desc) => {
473
- const commands = commandLines.map(cmd => cmd.trim()).join(' && ');
474
- yuangs.saveMacro(macroName, commands, desc.trim());
475
- console.log(chalk.green(`\n✓ 快捷指令 "${macroName}" 已保存\n`));
476
- saveRl.close();
477
- });
478
- return;
479
- }
480
- commandLines.push(line);
481
- askCommand();
482
- });
483
- };
484
- askCommand();
485
- break;
486
- case 'run':
487
- const runMacroName = args[1];
488
- if (!runMacroName) {
489
- console.log(chalk.red('\n错误: 请指定快捷指令名称'));
490
- console.log(chalk.gray('用法: yuangs run <名称>\n'));
491
- break;
492
- }
493
-
494
- const macros = yuangs.getMacros();
495
- if (!macros[runMacroName]) {
496
- console.log(chalk.red(`\n错误: 快捷指令 "${runMacroName}" 不存在`));
497
- console.log(chalk.gray('使用 "yuangs macros" 查看所有快捷指令\n'));
498
- break;
499
- }
500
-
501
- const macro = macros[runMacroName];
502
- console.log(chalk.cyan(`\n执行快捷指令: ${runMacroName}`));
503
- if (macro.description) {
504
- console.log(chalk.gray(`描述: ${macro.description}`));
505
- }
506
- console.log(chalk.gray(`命令: ${macro.commands}\n`));
507
-
508
- const { spawn } = require('child_process');
509
- const child = spawn(macro.commands, [], { shell: true, stdio: 'inherit' });
510
-
511
- child.on('close', (code) => {
512
- if (code !== 0) {
513
- console.error(chalk.red(`\n快捷指令执行失败 (退出码: ${code})`));
514
- process.exit(code);
515
- }
516
- });
517
- break;
518
- case 'macros':
519
- const allMacros = yuangs.getMacros();
520
- const macroNames = Object.keys(allMacros);
521
-
522
- if (macroNames.length === 0) {
523
- console.log(chalk.gray('暂无快捷指令\n'));
524
- console.log(chalk.gray('使用 "yuangs save <名称>" 创建快捷指令\n'));
525
- break;
526
- }
527
-
528
- console.log(chalk.bold.cyan('\n🚀 快捷指令列表\n'));
529
- console.log(chalk.gray('─────────────────────────────────────────────────'));
530
- macroNames.forEach(name => {
531
- const m = allMacros[name];
532
- console.log(chalk.white(` ${name}`));
533
- if (m.description) {
534
- console.log(chalk.gray(` 描述: ${m.description}`));
535
- }
536
- console.log(chalk.gray(` 命令: ${m.commands}`));
537
- console.log('');
538
- });
539
- console.log(chalk.gray('─────────────────────────────────────────────────\n'));
540
- console.log(chalk.gray('使用:'));
541
- console.log(chalk.gray(' yuangs run <名称> 执行快捷指令'));
542
- console.log(chalk.gray(' yuangs save <名称> 创建新快捷指令\n'));
543
- break;
544
- case 'help':
545
- case '--help':
546
- case '-h':
547
- printHelp();
548
- break;
549
- default:
550
- if (isAppCommand) {
551
- printSuccess(command, yuangs.urls[command]);
552
- yuangs.openApp(command);
553
- } else if (command) {
554
- console.log(chalk.red(`\n错误: 未知命令 '${command}'\n`));
555
- printHelp();
556
- } else {
557
- printHelp();
558
- }
559
- break;
560
- }