quick-sh 1.0.0 → 1.0.4

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/CHANGELOG.md ADDED
@@ -0,0 +1,50 @@
1
+ # Changelog
2
+
3
+ 所有重要的更改都会记录在此文件中。
4
+
5
+ ## [1.0.4] - 2025-06-18
6
+
7
+ ### 更新内容
8
+
9
+ - 版本发布
10
+
11
+ ### 详细信息
12
+ - **更新人**: Young6118
13
+ - **更新时间**: 2025-06-18
14
+ - **提交数量**: 0
15
+
16
+ ---
17
+
18
+
19
+ ## [1.0.3] - 2025-06-18
20
+
21
+ ### 更新内容
22
+
23
+ - fix: executor spawn set cwd (9e745e3)
24
+ - feat: locales path fix (48586fb)
25
+
26
+ ### 详细信息
27
+ - **更新人**: Young6118
28
+ - **更新时间**: 2025-06-18
29
+ - **提交数量**: 2
30
+ - **提交范围**: 48586fb..9e745e3
31
+
32
+ ---
33
+
34
+
35
+ ## [1.0.2] - 2025-06-18
36
+
37
+ ### 更新内容
38
+
39
+ - feat: 添加npm-version工具测试输入文件 (a849dc5)
40
+ - feat: 修复npm-version工具目录切换问题 (56fdf17)
41
+ - feat(examples): add npm version tool (4941a89)
42
+
43
+ ### 详细信息
44
+ - **更新人**: Young6118
45
+ - **更新时间**: 2025-06-18
46
+ - **提交数量**: 3
47
+
48
+ ---
49
+
50
+
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 YoungChou
3
+ Copyright (c) 2025 Young6118
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # Quick Shell
1
+ # Quick Sh
2
2
 
3
- [![npm version](https://badge.fury.io/js/@youngchou%2Fquick-sh.svg)](https://badge.fury.io/js/@youngchou%2Fquick-sh)
3
+ [![npm version](https://badge.fury.io/js/quick-sh.svg)](https://badge.fury.io/js/quick-sh)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
6
  A local script management tool for quick execution of JavaScript and Shell scripts with advanced alias support.
7
7
 
8
- [中文文档](./README-zh.md) | English
8
+ [中文文档](https://github.com/Young6118/quick-sh/blob/main/README-zh.md) | English
9
9
 
10
10
  ## Features
11
11
 
@@ -20,7 +20,7 @@ A local script management tool for quick execution of JavaScript and Shell scrip
20
20
  ## Installation
21
21
 
22
22
  ```bash
23
- npm install -g @youngchou/quick-sh
23
+ npm install -g quick-sh
24
24
  ```
25
25
 
26
26
  After installation, you can use the `q` command globally.
@@ -219,8 +219,8 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
219
219
 
220
220
  ## Author
221
221
 
222
- - **YoungChou** - *Initial work*
222
+ - **Young6118** - *Initial work*
223
223
 
224
224
  ## Support
225
225
 
226
- If you encounter any issues or have questions, please [open an issue](https://github.com/YoungChou/quick-sh/issues) on GitHub.
226
+ If you encounter any issues or have questions, please [open an issue](https://github.com/Young6118/quick-sh/issues) on GitHub.
package/bin/cli.js CHANGED
@@ -1,12 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { program } = require('commander');
4
- const { setPath } = require('../lib/config');
5
- const { executeScript, showStatus } = require('../lib/script-manager');
4
+ const { setPath, setLanguage, showLanguage } = require('../lib/config');
5
+ const { configureAI, selectModel, showAIConfig } = require('../lib/ai');
6
+ const { executeScript, showStatus, showBrief } = require('../lib/script-manager');
6
7
  const { showHelp } = require('../lib/help');
8
+ const {
9
+ addSource,
10
+ removeSource,
11
+ listSources,
12
+ downloadScript,
13
+ listRemoteScripts,
14
+ removeRemoteScript,
15
+ SOURCE_TYPES
16
+ } = require('../lib/remote-manager');
17
+ const { initI18n } = require('../lib/i18n');
7
18
 
8
- // 自定义命令处理 - 在 commander.js 解析之前拦截
9
- const args = process.argv.slice(2);
19
+ // 初始化国际化系统
20
+ (async () => {
21
+ await initI18n();
22
+
23
+ // 自定义命令处理 - 在 commander.js 解析之前拦截
24
+ const args = process.argv.slice(2);
10
25
 
11
26
  if (args.length > 0) {
12
27
  const firstArg = args[0];
@@ -17,21 +32,149 @@ if (args.length > 0) {
17
32
  return;
18
33
  }
19
34
 
35
+ // 处理语言设置命令
36
+ if (firstArg === '-lang' || firstArg === '--lang') {
37
+ if (args.length >= 2) {
38
+ setLanguage(args[1]).catch(error => {
39
+ console.error(`❌ ${error.message}`);
40
+ process.exit(1);
41
+ });
42
+ } else {
43
+ showLanguage().catch(error => {
44
+ console.error(`❌ ${error.message}`);
45
+ process.exit(1);
46
+ });
47
+ }
48
+ return;
49
+ }
50
+
51
+ // 处理AI聊天命令
52
+ if (firstArg === '-ai' || firstArg === '--ai') {
53
+ if (args.length >= 2) {
54
+ const subCommand = args[1];
55
+
56
+ if (subCommand === '-config' || subCommand === '--config') {
57
+ configureAI().catch(error => {
58
+ console.error(`❌ ${error.message}`);
59
+ process.exit(1);
60
+ });
61
+ return;
62
+ }
63
+
64
+ if (subCommand === '-use' || subCommand === '--use') {
65
+ if (args.length >= 3) {
66
+ // 直接使用指定模型
67
+ selectModel(args[2]).catch(error => {
68
+ console.error(`❌ ${error.message}`);
69
+ process.exit(1);
70
+ });
71
+ } else {
72
+ // 显示模型选择菜单
73
+ selectModel().catch(error => {
74
+ console.error(`❌ ${error.message}`);
75
+ process.exit(1);
76
+ });
77
+ }
78
+ return;
79
+ }
80
+
81
+ if (subCommand === '-show' || subCommand === '--show') {
82
+ showAIConfig().catch(error => {
83
+ console.error(`❌ ${error.message}`);
84
+ process.exit(1);
85
+ });
86
+ return;
87
+ }
88
+ } else {
89
+ // 没有子命令,尝试启动AI聊天
90
+ selectModel().catch(error => {
91
+ console.error(`❌ ${error.message}`);
92
+ process.exit(1);
93
+ });
94
+ }
95
+ return;
96
+ }
97
+
20
98
  if (firstArg === '-list' || firstArg === '-l') {
21
99
  showStatus();
22
100
  return;
23
101
  }
24
102
 
25
- if (firstArg === '-help' || firstArg === '-h') {
103
+ if (firstArg === '-help' || firstArg === '-h' || firstArg === '--help') {
26
104
  showHelp();
27
105
  return;
28
106
  }
107
+
108
+ // 处理远程脚本管理命令
109
+ if (firstArg === '--sources' || firstArg === '-s') {
110
+ listSources();
111
+ return;
112
+ }
113
+
114
+ if (firstArg === '--add-source' && args.length >= 4) {
115
+ const [, name, type, url, ...options] = args;
116
+ const sourceOptions = {};
117
+
118
+ // 解析选项参数
119
+ for (let i = 0; i < options.length; i += 2) {
120
+ if (options[i] && options[i + 1]) {
121
+ const key = options[i].replace(/^--/, '');
122
+ sourceOptions[key] = options[i + 1];
123
+ }
124
+ }
125
+
126
+ addSource(name, type, url, sourceOptions).catch(error => {
127
+ console.error(`❌ ${error.message}`);
128
+ process.exit(1);
129
+ });
130
+ return;
131
+ }
132
+
133
+ if (firstArg === '--remove-source' && args.length >= 2) {
134
+ removeSource(args[1]).catch(error => {
135
+ console.error(`❌ ${error.message}`);
136
+ process.exit(1);
137
+ });
138
+ return;
139
+ }
140
+
141
+ if (firstArg === '--download' && args.length >= 3) {
142
+ const [, sourceName, scriptPath, localName] = args;
143
+ downloadScript(sourceName, scriptPath, localName).catch(error => {
144
+ console.error(`❌ ${error.message}`);
145
+ process.exit(1);
146
+ });
147
+ return;
148
+ }
149
+
150
+ if (firstArg === '--remote-list' || firstArg === '-rl') {
151
+ listRemoteScripts().catch(error => {
152
+ console.error(`❌ ${error.message}`);
153
+ process.exit(1);
154
+ });
155
+ return;
156
+ }
157
+
158
+ if (firstArg === '--remove-remote' && args.length >= 3) {
159
+ const [, sourceName, scriptName] = args;
160
+ removeRemoteScript(sourceName, scriptName).catch(error => {
161
+ console.error(`❌ ${error.message}`);
162
+ process.exit(1);
163
+ });
164
+ return;
165
+ }
166
+
167
+ // 对于其他命令,直接执行脚本,避免 commander.js 解析参数
168
+ if (firstArg && !firstArg.startsWith('-')) {
169
+ executeScript(firstArg, args.slice(1));
170
+ return;
171
+ }
29
172
  }
30
173
 
31
174
  // 设置命令行程序
32
175
  program
33
176
  .name('q')
34
- .description('Quick Shell - Local script management tool')
177
+ .description('quick sh - Local script management tool')
35
178
  .version('1.0.0');
36
179
 
37
180
  // 默认命令:执行脚本
@@ -40,10 +183,11 @@ program
40
183
  .argument('[args...]', 'Arguments to pass to the script')
41
184
  .action(async (script, args) => {
42
185
  if (!script) {
43
- await showStatus();
186
+ await showBrief();
44
187
  return;
45
188
  }
46
189
  await executeScript(script, args || []);
47
190
  });
48
191
 
49
- program.parse();
192
+ program.parse();
193
+ })();