@catcuts-skills/hello-world 1.0.5 → 1.0.7
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 +30 -1
- package/package.json +4 -2
- package/scripts/install-skill.js +5 -5
- package/scripts/uninstall-skill.js +6 -6
package/README.md
CHANGED
|
@@ -70,15 +70,44 @@ npm test
|
|
|
70
70
|
|
|
71
71
|
### 卸载
|
|
72
72
|
|
|
73
|
+
**重要**:由于 npm 的限制,全局卸载时 preuninstall hook 可能不会执行。请按照以下步骤正确卸载:
|
|
74
|
+
|
|
75
|
+
#### 方式 1:使用 npm scripts(推荐)
|
|
76
|
+
|
|
73
77
|
```bash
|
|
74
78
|
# 全局卸载
|
|
79
|
+
npm run uninstall:global
|
|
75
80
|
npm uninstall -g @catcuts-skills/hello-world
|
|
76
81
|
|
|
77
82
|
# 项目级卸载
|
|
83
|
+
npm run uninstall:local
|
|
78
84
|
npm uninstall @catcuts-skills/hello-world
|
|
79
85
|
```
|
|
80
86
|
|
|
81
|
-
|
|
87
|
+
#### 方式 2:手动清理(如果方式 1 失败)
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# 1. 清理技能文件
|
|
91
|
+
rm -rf ~/.claude/skills/hello-world
|
|
92
|
+
rm -rf ~/.agents/skills/hello-world
|
|
93
|
+
|
|
94
|
+
# 2. 卸载 npm 包
|
|
95
|
+
npm uninstall -g @catcuts-skills/hello-world
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Windows PowerShell**:
|
|
99
|
+
```powershell
|
|
100
|
+
# 1. 清理技能文件
|
|
101
|
+
Remove-Item -Recurse -Force "$env:USERPROFILE\.claude\skills\hello-world"
|
|
102
|
+
Remove-Item -Recurse -Force "$env:USERPROFILE\.agents\skills\hello-world"
|
|
103
|
+
|
|
104
|
+
# 2. 卸载 npm 包
|
|
105
|
+
npm uninstall -g @catcuts-skills/hello-world
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### 为什么需要两步?
|
|
109
|
+
|
|
110
|
+
npm 的 `preuninstall` hook 在全局卸载时**不保证被执行**,这是 npm 的已知限制。因此需要先手动清理技能文件,再卸载 npm 包。
|
|
82
111
|
|
|
83
112
|
## 使用示例
|
|
84
113
|
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catcuts-skills/hello-world",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "简单的 Hello World 示例技能,用于验证技能安装是否成功。显示欢迎信息、环境信息和使用示例。",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "node scripts/install-skill.js",
|
|
8
|
-
"preuninstall": "node scripts/uninstall-skill.js",
|
|
8
|
+
"preuninstall": "node scripts/uninstall-skill.js || exit 0",
|
|
9
9
|
"test": "node scripts/install-skill.js --dry-run",
|
|
10
10
|
"install:global": "node scripts/install-skill.js --global",
|
|
11
11
|
"install:local": "node scripts/install-skill.js --local",
|
|
12
|
+
"uninstall:global": "node scripts/uninstall-skill.js --global",
|
|
13
|
+
"uninstall:local": "node scripts/uninstall-skill.js --local",
|
|
12
14
|
"lint": "echo 'Add your linting commands here'"
|
|
13
15
|
},
|
|
14
16
|
"files": [
|
package/scripts/install-skill.js
CHANGED
|
@@ -84,7 +84,7 @@ function isSymlink(filePath) {
|
|
|
84
84
|
function safeRemovePath(filePath, description) {
|
|
85
85
|
try {
|
|
86
86
|
if (!fs.existsSync(filePath)) {
|
|
87
|
-
return { success: true, removed: false, message:
|
|
87
|
+
return { success: true, removed: false, message: `不存在:${description}(${filePath})` };
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
const stats = fs.lstatSync(filePath);
|
|
@@ -96,28 +96,28 @@ function safeRemovePath(filePath, description) {
|
|
|
96
96
|
return {
|
|
97
97
|
success: true,
|
|
98
98
|
removed: true,
|
|
99
|
-
message: `已删除符号链接: ${description}`
|
|
99
|
+
message: `已删除符号链接: ${description}(${filePath})`
|
|
100
100
|
};
|
|
101
101
|
} else if (isDir) {
|
|
102
102
|
fs.rmSync(filePath, { recursive: true, force: true });
|
|
103
103
|
return {
|
|
104
104
|
success: true,
|
|
105
105
|
removed: true,
|
|
106
|
-
message: `已删除目录: ${description}`
|
|
106
|
+
message: `已删除目录: ${description}(${filePath})`
|
|
107
107
|
};
|
|
108
108
|
} else {
|
|
109
109
|
fs.unlinkSync(filePath);
|
|
110
110
|
return {
|
|
111
111
|
success: true,
|
|
112
112
|
removed: true,
|
|
113
|
-
message: `已删除文件: ${description}`
|
|
113
|
+
message: `已删除文件: ${description}(${filePath})`
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
} catch (error) {
|
|
117
117
|
return {
|
|
118
118
|
success: false,
|
|
119
119
|
removed: false,
|
|
120
|
-
message: `删除失败: ${error.message}`
|
|
120
|
+
message: `删除失败: ${description}(${filePath}) - ${error.message}`
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -53,7 +53,7 @@ function log(message, type = 'info') {
|
|
|
53
53
|
function safeRemovePath(filePath, description) {
|
|
54
54
|
try {
|
|
55
55
|
if (!fs.existsSync(filePath)) {
|
|
56
|
-
return { success: true, removed: false, message:
|
|
56
|
+
return { success: true, removed: false, message: `已不存在:${description}(${filePath})` };
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
const stats = fs.lstatSync(filePath);
|
|
@@ -65,32 +65,32 @@ function safeRemovePath(filePath, description) {
|
|
|
65
65
|
return {
|
|
66
66
|
success: true,
|
|
67
67
|
removed: true,
|
|
68
|
-
message: `已删除符号链接: ${description}`
|
|
68
|
+
message: `已删除符号链接: ${description}(${filePath})`
|
|
69
69
|
};
|
|
70
70
|
} else if (isDir) {
|
|
71
71
|
fs.rmSync(filePath, { recursive: true, force: true });
|
|
72
72
|
return {
|
|
73
73
|
success: true,
|
|
74
74
|
removed: true,
|
|
75
|
-
message: `已删除目录: ${description}`
|
|
75
|
+
message: `已删除目录: ${description}(${filePath})`
|
|
76
76
|
};
|
|
77
77
|
} else {
|
|
78
78
|
fs.unlinkSync(filePath);
|
|
79
79
|
return {
|
|
80
80
|
success: true,
|
|
81
81
|
removed: true,
|
|
82
|
-
message: `已删除文件: ${description}`
|
|
82
|
+
message: `已删除文件: ${description}(${filePath})`
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
} catch (error) {
|
|
86
86
|
// 忽略"文件不存在"错误,可能已被并发删除
|
|
87
87
|
if (error.code === 'ENOENT') {
|
|
88
|
-
return { success: true, removed: false, message:
|
|
88
|
+
return { success: true, removed: false, message: `已不存在:${description}(${filePath})` };
|
|
89
89
|
}
|
|
90
90
|
return {
|
|
91
91
|
success: false,
|
|
92
92
|
removed: false,
|
|
93
|
-
message: `删除失败: ${error.message}`
|
|
93
|
+
message: `删除失败: ${description}(${filePath}) - ${error.message}`
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
}
|