@lyra-ai/toolkit 0.2.5 → 0.2.6
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/bin/toolkit.mjs +4 -4
- package/package.json +1 -1
- package/src/flush.mjs +243 -221
- package/src/hook.mjs +35 -21
- package/src/install.mjs +69 -30
- package/src/shared/backlog.mjs +96 -0
- package/src/shared/config.mjs +17 -0
- package/src/shared/http.mjs +29 -0
- package/src/shared/lock.mjs +79 -0
- package/src/shared/settle.mjs +20 -0
- package/src/shared/zip.mjs +89 -0
- package/src/status.mjs +103 -36
- package/src/uninstall.mjs +26 -13
package/src/uninstall.mjs
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* uninstall.mjs — `toolkit uninstall`
|
|
4
|
-
*
|
|
3
|
+
* uninstall.mjs — `toolkit uninstall [--purge]`
|
|
4
|
+
*
|
|
5
|
+
* 删除 @skills-dir 插件目录(~/.claude/skills/toolkit)+ 旧版裸目录残留
|
|
6
|
+
* + settings.json 里失效的 toolkit@local 条目。可选 --purge 清除 ~/.toolkit/ 数据。
|
|
7
|
+
*
|
|
8
|
+
* 注:@skills-dir plugin 没有「卸载步骤」(按官方文档,删文件夹即停用)。
|
|
5
9
|
*/
|
|
6
10
|
import fs from 'node:fs';
|
|
7
11
|
import path from 'node:path';
|
|
8
12
|
import os from 'node:os';
|
|
9
13
|
|
|
10
14
|
const HOME = os.homedir();
|
|
11
|
-
const PLUGIN_DIR = path.join(HOME, '.claude', '
|
|
15
|
+
const PLUGIN_DIR = path.join(HOME, '.claude', 'skills', 'toolkit');
|
|
16
|
+
const OLD_PLUGIN_DIR = path.join(HOME, '.claude', 'plugins', 'toolkit');
|
|
12
17
|
const SETTINGS_PATH = path.join(HOME, '.claude', 'settings.json');
|
|
13
|
-
const
|
|
18
|
+
const OLD_PLUGIN_KEY = 'toolkit@local';
|
|
19
|
+
|
|
20
|
+
// 数据目录与 shared/config.mjs 的 TOOLKIT_DIR 同逻辑,但在调用时求值,
|
|
21
|
+
// 以便测试用 TOOLKIT_HOME / HOME 隔离(避免模块加载时绑定的陈旧值)。
|
|
22
|
+
function dataDir() {
|
|
23
|
+
return process.env.TOOLKIT_HOME || path.join(os.homedir(), '.toolkit');
|
|
24
|
+
}
|
|
14
25
|
|
|
15
26
|
function rmrf(dir) {
|
|
16
27
|
if (!fs.existsSync(dir)) return;
|
|
@@ -25,24 +36,26 @@ function rmrf(dir) {
|
|
|
25
36
|
}
|
|
26
37
|
|
|
27
38
|
export function uninstall(opts = {}) {
|
|
28
|
-
// 1.
|
|
39
|
+
// 1. 删 @skills-dir 插件目录 + 旧版裸目录残留
|
|
29
40
|
rmrf(PLUGIN_DIR);
|
|
30
|
-
|
|
41
|
+
rmrf(OLD_PLUGIN_DIR);
|
|
42
|
+
console.log(`✅ 插件目录已删除(${PLUGIN_DIR})`);
|
|
31
43
|
|
|
32
|
-
// 2. 移除 settings.json
|
|
44
|
+
// 2. 移除 settings.json 里失效的 toolkit@local(若有)
|
|
33
45
|
try {
|
|
34
46
|
const settings = JSON.parse(fs.readFileSync(SETTINGS_PATH, 'utf-8'));
|
|
35
|
-
if (settings.enabledPlugins?.[
|
|
36
|
-
delete settings.enabledPlugins[
|
|
47
|
+
if (settings.enabledPlugins?.[OLD_PLUGIN_KEY] !== undefined) {
|
|
48
|
+
delete settings.enabledPlugins[OLD_PLUGIN_KEY];
|
|
37
49
|
fs.writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2));
|
|
38
|
-
console.log('✅ settings.json
|
|
50
|
+
console.log('✅ settings.json 失效条目已移除');
|
|
39
51
|
}
|
|
40
52
|
} catch {}
|
|
41
53
|
|
|
42
|
-
// 3. 数据(~/.toolkit
|
|
54
|
+
// 3. 数据(~/.toolkit/,走 TOOLKIT_HOME 或 ~/.toolkit,与 install 一致)
|
|
43
55
|
if (opts.purge) {
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
const dir = dataDir();
|
|
57
|
+
rmrf(dir);
|
|
58
|
+
console.log(`✅ ${dir} 数据已清除`);
|
|
46
59
|
} else {
|
|
47
60
|
console.log('ℹ️ ~/.toolkit/ 数据保留(含 UID + 上传记录)。');
|
|
48
61
|
console.log(' 彻底清除: toolkit uninstall --purge');
|