@holic512/slothtool 1.0.6 → 1.0.8
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/README.md +8 -0
- package/bin/slothtool.js +6 -2
- package/lib/commands/index.js +3 -1
- package/lib/commands/interactive.js +58 -8
- package/lib/commands/self-update.js +7 -0
- package/lib/i18n.js +26 -4
- package/lib/official-plugins.json +24 -0
- package/lib/plugin-manager.js +18 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,14 @@ their own dependencies.
|
|
|
26
26
|
npm install -g @holic512/slothtool
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
### Debian one-click install (Node.js 20 LTS + SlothTool)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
|
33
|
+
sudo apt-get install -y nodejs
|
|
34
|
+
npm install -g @holic512/slothtool
|
|
35
|
+
```
|
|
36
|
+
|
|
29
37
|
## Quick Start
|
|
30
38
|
|
|
31
39
|
```bash
|
package/bin/slothtool.js
CHANGED
|
@@ -19,7 +19,8 @@ if (!command) {
|
|
|
19
19
|
console.log(' slothtool <plugin> [args] ' + t('commands.runShorthand'));
|
|
20
20
|
console.log(' slothtool config language <lang> ' + t('commands.config'));
|
|
21
21
|
console.log(' slothtool -i, --interactive ' + t('commands.interactive'));
|
|
22
|
-
console.log(' slothtool --uninstall-all ' + t('commands.uninstallAll')
|
|
22
|
+
console.log(' slothtool --uninstall-all ' + t('commands.uninstallAll'));
|
|
23
|
+
console.log(' slothtool self-update ' + t('commands.selfUpdate') + '\n');
|
|
23
24
|
console.log(t('examples'));
|
|
24
25
|
console.log(' slothtool install @holic512/plugin-loc');
|
|
25
26
|
console.log(' slothtool loc ./src');
|
|
@@ -50,6 +51,8 @@ if (command === 'install') {
|
|
|
50
51
|
commands.interactive();
|
|
51
52
|
} else if (command === '--uninstall-all') {
|
|
52
53
|
commands.uninstallAll();
|
|
54
|
+
} else if (command === 'self-update') {
|
|
55
|
+
commands.selfUpdate();
|
|
53
56
|
} else if (command === '--help' || command === '-h') {
|
|
54
57
|
console.log(t('pluginManager') + '\n');
|
|
55
58
|
console.log(t('usage'));
|
|
@@ -62,7 +65,8 @@ if (command === 'install') {
|
|
|
62
65
|
console.log(' slothtool <plugin> [args] ' + t('commands.runShorthand'));
|
|
63
66
|
console.log(' slothtool config language <lang> ' + t('commands.config'));
|
|
64
67
|
console.log(' slothtool -i, --interactive ' + t('commands.interactive'));
|
|
65
|
-
console.log(' slothtool --uninstall-all ' + t('commands.uninstallAll')
|
|
68
|
+
console.log(' slothtool --uninstall-all ' + t('commands.uninstallAll'));
|
|
69
|
+
console.log(' slothtool self-update ' + t('commands.selfUpdate') + '\n');
|
|
66
70
|
console.log(t('examples'));
|
|
67
71
|
console.log(' slothtool install @holic512/plugin-loc');
|
|
68
72
|
console.log(' slothtool loc ./src');
|
package/lib/commands/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const interactive = require('./interactive');
|
|
|
7
7
|
const uninstallAll = require('./uninstall-all');
|
|
8
8
|
const update = require('./update');
|
|
9
9
|
const updateAll = require('./update-all');
|
|
10
|
+
const selfUpdate = require('./self-update');
|
|
10
11
|
|
|
11
12
|
module.exports = {
|
|
12
13
|
install,
|
|
@@ -17,5 +18,6 @@ module.exports = {
|
|
|
17
18
|
interactive,
|
|
18
19
|
uninstallAll,
|
|
19
20
|
update,
|
|
20
|
-
updateAll
|
|
21
|
+
updateAll,
|
|
22
|
+
selfUpdate
|
|
21
23
|
};
|
|
@@ -4,7 +4,7 @@ const path = require('path');
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const registry = require('../registry');
|
|
6
6
|
const settings = require('../settings');
|
|
7
|
-
const {installPlugin, uninstallPlugin, updatePlugin, updateAllPlugins} = require('../plugin-manager');
|
|
7
|
+
const {installPlugin, uninstallPlugin, updatePlugin, updateAllPlugins, updateSelf} = require('../plugin-manager');
|
|
8
8
|
const uninstallAll = require('./uninstall-all');
|
|
9
9
|
const {t} = require('../i18n');
|
|
10
10
|
|
|
@@ -25,8 +25,7 @@ async function interactive() {
|
|
|
25
25
|
choices: [
|
|
26
26
|
{title: t('interactive.installPlugin'), value: 'install'},
|
|
27
27
|
{title: t('interactive.uninstallPlugin'), value: 'uninstall'},
|
|
28
|
-
{title: t('interactive.
|
|
29
|
-
{title: t('interactive.updateAllPlugins'), value: 'updateAll'},
|
|
28
|
+
{title: t('interactive.updateMenu'), value: 'updateMenu'},
|
|
30
29
|
{title: t('interactive.listPlugins'), value: 'list'},
|
|
31
30
|
{title: t('interactive.runPlugin'), value: 'run'},
|
|
32
31
|
{title: t('interactive.configLanguage'), value: 'config'},
|
|
@@ -49,11 +48,8 @@ async function interactive() {
|
|
|
49
48
|
case 'uninstall':
|
|
50
49
|
await handleUninstall();
|
|
51
50
|
break;
|
|
52
|
-
case '
|
|
53
|
-
await
|
|
54
|
-
break;
|
|
55
|
-
case 'updateAll':
|
|
56
|
-
await handleUpdateAll();
|
|
51
|
+
case 'updateMenu':
|
|
52
|
+
await handleUpdateMenu();
|
|
57
53
|
break;
|
|
58
54
|
case 'list':
|
|
59
55
|
await handleList();
|
|
@@ -223,6 +219,40 @@ async function handleUninstall() {
|
|
|
223
219
|
uninstallPlugin(response.alias);
|
|
224
220
|
}
|
|
225
221
|
|
|
222
|
+
/**
|
|
223
|
+
* 处理更新菜单
|
|
224
|
+
*/
|
|
225
|
+
async function handleUpdateMenu() {
|
|
226
|
+
const response = await prompts({
|
|
227
|
+
type: 'select',
|
|
228
|
+
name: 'action',
|
|
229
|
+
message: t('interactive.updateMenu'),
|
|
230
|
+
choices: [
|
|
231
|
+
{title: t('interactive.updateSelf'), value: 'self'},
|
|
232
|
+
{title: t('interactive.updatePlugin'), value: 'single'},
|
|
233
|
+
{title: t('interactive.updateAllPlugins'), value: 'all'}
|
|
234
|
+
]
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
if (!response.action) {
|
|
238
|
+
throw new Error('cancelled');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
console.log('');
|
|
242
|
+
|
|
243
|
+
if (response.action === 'self') {
|
|
244
|
+
await handleUpdateSelf();
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (response.action === 'single') {
|
|
249
|
+
await handleUpdate();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
await handleUpdateAll();
|
|
254
|
+
}
|
|
255
|
+
|
|
226
256
|
/**
|
|
227
257
|
* 处理更新插件
|
|
228
258
|
*/
|
|
@@ -297,6 +327,26 @@ async function handleUpdateAll() {
|
|
|
297
327
|
updateAllPlugins();
|
|
298
328
|
}
|
|
299
329
|
|
|
330
|
+
/**
|
|
331
|
+
* 处理更新 SlothTool
|
|
332
|
+
*/
|
|
333
|
+
async function handleUpdateSelf() {
|
|
334
|
+
const confirm = await prompts({
|
|
335
|
+
type: 'confirm',
|
|
336
|
+
name: 'value',
|
|
337
|
+
message: t('interactive.confirmUpdateSelf'),
|
|
338
|
+
initial: true
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
if (!confirm.value) {
|
|
342
|
+
console.log(t('interactive.operationCancelled'));
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
console.log('');
|
|
347
|
+
updateSelf();
|
|
348
|
+
}
|
|
349
|
+
|
|
300
350
|
/**
|
|
301
351
|
* 处理列出插件
|
|
302
352
|
*/
|
package/lib/i18n.js
CHANGED
|
@@ -18,7 +18,8 @@ const messages = {
|
|
|
18
18
|
runShorthand: '运行插件(简写)',
|
|
19
19
|
config: '配置语言设置',
|
|
20
20
|
interactive: '交互式模式',
|
|
21
|
-
uninstallAll: '完全卸载 SlothTool(删除所有数据)'
|
|
21
|
+
uninstallAll: '完全卸载 SlothTool(删除所有数据)',
|
|
22
|
+
selfUpdate: '更新 SlothTool(本体)'
|
|
22
23
|
},
|
|
23
24
|
|
|
24
25
|
// 安装
|
|
@@ -51,6 +52,13 @@ const messages = {
|
|
|
51
52
|
specifyPluginToUpdate: '错误:请指定要更新的插件。',
|
|
52
53
|
updateUsage: '用法:slothtool update <插件别名>',
|
|
53
54
|
|
|
55
|
+
// 自更新
|
|
56
|
+
selfUpdate: {
|
|
57
|
+
starting: '正在更新 SlothTool...',
|
|
58
|
+
success: '✓ SlothTool 更新完成!',
|
|
59
|
+
failed: '✗ 更新 SlothTool 失败:'
|
|
60
|
+
},
|
|
61
|
+
|
|
54
62
|
// 更新所有插件
|
|
55
63
|
updateAll: {
|
|
56
64
|
title: '\n📦 更新所有插件',
|
|
@@ -109,7 +117,9 @@ const messages = {
|
|
|
109
117
|
installOfficial: '安装官方插件',
|
|
110
118
|
installCustom: '安装自定义插件',
|
|
111
119
|
uninstallPlugin: '卸载插件',
|
|
112
|
-
|
|
120
|
+
updateMenu: '更新',
|
|
121
|
+
updateSelf: '更新 SlothTool',
|
|
122
|
+
updatePlugin: '更新单个插件',
|
|
113
123
|
updateAllPlugins: '更新所有插件',
|
|
114
124
|
listPlugins: '查看已安装的插件',
|
|
115
125
|
runPlugin: '运行插件',
|
|
@@ -137,6 +147,7 @@ const messages = {
|
|
|
137
147
|
confirmUninstall: '确认卸载 {alias}?',
|
|
138
148
|
confirmUpdate: '确认更新 {alias}?',
|
|
139
149
|
confirmUpdateAll: '确认更新所有 {count} 个插件?',
|
|
150
|
+
confirmUpdateSelf: '确认更新 SlothTool?',
|
|
140
151
|
|
|
141
152
|
runWithArgs: '是否要运行此插件?',
|
|
142
153
|
enterArgs: '请输入运行参数(留空表示无参数):',
|
|
@@ -163,7 +174,8 @@ const messages = {
|
|
|
163
174
|
runShorthand: 'Run a plugin (shorthand)',
|
|
164
175
|
config: 'Configure language settings',
|
|
165
176
|
interactive: 'Interactive mode',
|
|
166
|
-
uninstallAll: 'Complete uninstall (remove all data)'
|
|
177
|
+
uninstallAll: 'Complete uninstall (remove all data)',
|
|
178
|
+
selfUpdate: 'Update SlothTool (self-update)'
|
|
167
179
|
},
|
|
168
180
|
|
|
169
181
|
// Install
|
|
@@ -196,6 +208,13 @@ const messages = {
|
|
|
196
208
|
specifyPluginToUpdate: 'Error: Please specify a plugin to update.',
|
|
197
209
|
updateUsage: 'Usage: slothtool update <plugin-alias>',
|
|
198
210
|
|
|
211
|
+
// Self update
|
|
212
|
+
selfUpdate: {
|
|
213
|
+
starting: 'Updating SlothTool...',
|
|
214
|
+
success: '✓ SlothTool updated successfully!',
|
|
215
|
+
failed: '✗ Failed to update SlothTool:'
|
|
216
|
+
},
|
|
217
|
+
|
|
199
218
|
// Update all plugins
|
|
200
219
|
updateAll: {
|
|
201
220
|
title: '\n📦 Update All Plugins',
|
|
@@ -254,7 +273,9 @@ const messages = {
|
|
|
254
273
|
installOfficial: 'Install official plugin',
|
|
255
274
|
installCustom: 'Install custom plugin',
|
|
256
275
|
uninstallPlugin: 'Uninstall plugin',
|
|
257
|
-
|
|
276
|
+
updateMenu: 'Update',
|
|
277
|
+
updateSelf: 'Update SlothTool',
|
|
278
|
+
updatePlugin: 'Update single plugin',
|
|
258
279
|
updateAllPlugins: 'Update all plugins',
|
|
259
280
|
listPlugins: 'List installed plugins',
|
|
260
281
|
runPlugin: 'Run plugin',
|
|
@@ -282,6 +303,7 @@ const messages = {
|
|
|
282
303
|
confirmUninstall: 'Confirm uninstall {alias}?',
|
|
283
304
|
confirmUpdate: 'Confirm update {alias}?',
|
|
284
305
|
confirmUpdateAll: 'Confirm update all {count} plugins?',
|
|
306
|
+
confirmUpdateSelf: 'Confirm update SlothTool?',
|
|
285
307
|
|
|
286
308
|
runWithArgs: 'Do you want to run this plugin?',
|
|
287
309
|
enterArgs: 'Enter arguments (leave empty for no arguments):',
|
|
@@ -65,6 +65,30 @@
|
|
|
65
65
|
"History cache",
|
|
66
66
|
"Bilingual support"
|
|
67
67
|
]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "@holic512/plugin-llm-base",
|
|
71
|
+
"alias": "llm-base",
|
|
72
|
+
"description": "LLM 基础能力层 - 配置管理、OpenAI 协议兼容调用与调用日志",
|
|
73
|
+
"descriptionEn": "LLM base layer for profile management, OpenAI-compatible calls, and call logs",
|
|
74
|
+
"version": "latest",
|
|
75
|
+
"author": "holic512",
|
|
76
|
+
"features": [
|
|
77
|
+
"多 profile 配置管理",
|
|
78
|
+
"low/high 双模型切换",
|
|
79
|
+
"OpenAI Chat Completions 兼容",
|
|
80
|
+
"统一返回结构与错误码",
|
|
81
|
+
"调用日志(最近 500 条)",
|
|
82
|
+
"默认安全脱敏"
|
|
83
|
+
],
|
|
84
|
+
"featuresEn": [
|
|
85
|
+
"Multi-profile configuration",
|
|
86
|
+
"Low/high model switching",
|
|
87
|
+
"OpenAI Chat Completions compatible",
|
|
88
|
+
"Unified response schema and error codes",
|
|
89
|
+
"Call logs (latest 500 entries)",
|
|
90
|
+
"Secure masking by default"
|
|
91
|
+
]
|
|
68
92
|
}
|
|
69
93
|
]
|
|
70
94
|
}
|
package/lib/plugin-manager.js
CHANGED
|
@@ -215,6 +215,22 @@ function updatePlugin(alias) {
|
|
|
215
215
|
/**
|
|
216
216
|
* 更新所有插件
|
|
217
217
|
*/
|
|
218
|
+
function updateSelf() {
|
|
219
|
+
console.log(t('selfUpdate.starting'));
|
|
220
|
+
|
|
221
|
+
try {
|
|
222
|
+
execSync('npm install -g @holic512/slothtool', {
|
|
223
|
+
stdio: 'inherit',
|
|
224
|
+
encoding: 'utf8'
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
console.log(t('selfUpdate.success'));
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error(t('selfUpdate.failed'), error.message);
|
|
230
|
+
process.exit(1);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
218
234
|
function updateAllPlugins() {
|
|
219
235
|
const plugins = registry.getAllPlugins();
|
|
220
236
|
const pluginList = Object.keys(plugins);
|
|
@@ -316,5 +332,6 @@ module.exports = {
|
|
|
316
332
|
installPlugin,
|
|
317
333
|
uninstallPlugin,
|
|
318
334
|
updatePlugin,
|
|
319
|
-
updateAllPlugins
|
|
335
|
+
updateAllPlugins,
|
|
336
|
+
updateSelf
|
|
320
337
|
};
|