@workskills/getskill 1.1.4 → 1.1.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/EXAMPLES.md +36 -37
- package/README.md +260 -282
- package/index.js +103 -123
- package/package.json +6 -6
package/EXAMPLES.md
CHANGED
|
@@ -24,14 +24,14 @@ Git 安装程序已下载到: C:\Users\...\AppData\Local\Temp\git-installer.exe
|
|
|
24
24
|
# Git 安装完成后,再次运行
|
|
25
25
|
$ getskill install commit-helper
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
克隆仓库: https://
|
|
29
|
-
仓库克隆成功: C:\Users\...\\.
|
|
27
|
+
下载技能: commit-helper...
|
|
28
|
+
克隆仓库: https://getskill.work/skills/commit-helper.git...
|
|
29
|
+
仓库克隆成功: C:\Users\...\\.openclaw\skills-cache\commit-helper
|
|
30
30
|
|
|
31
31
|
技能已安装到 skills 目录:
|
|
32
|
-
- C:\Users\...\.
|
|
32
|
+
- C:\Users\...\.openclaw\skills\commit-helper
|
|
33
33
|
|
|
34
|
-
Git 仓库缓存: C:\Users\...\.
|
|
34
|
+
Git 仓库缓存: C:\Users\...\.openclaw\skills-cache\commit-helper
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
### macOS 用户
|
|
@@ -89,55 +89,52 @@ $ getskill search commit
|
|
|
89
89
|
|
|
90
90
|
1. commit-helper
|
|
91
91
|
描述: 帮助生成规范的 git commit 信息
|
|
92
|
-
|
|
93
|
-
作者: workskills
|
|
92
|
+
Git: https://getskill.work/skills/commit-helper.git
|
|
94
93
|
|
|
95
94
|
2. commit-lint
|
|
96
95
|
描述: 检查 commit 信息是否符合规范
|
|
97
|
-
|
|
98
|
-
作者: workskills
|
|
96
|
+
Git: https://getskill.work/skills/commit-lint.git
|
|
99
97
|
|
|
100
98
|
# 安装技能
|
|
101
99
|
$ getskill install commit-helper
|
|
102
100
|
|
|
103
|
-
|
|
104
|
-
克隆仓库: https://
|
|
105
|
-
仓库克隆成功: ~/.
|
|
106
|
-
|
|
101
|
+
下载技能: commit-helper...
|
|
102
|
+
克隆仓库: https://getskill.work/skills/commit-helper.git...
|
|
103
|
+
仓库克隆成功: ~/.openclaw/skills-cache/commit-helper
|
|
104
|
+
已复制技能目录: ~/.openclaw/skills-cache/commit-helper -> ~/.openclaw/skills/commit-helper
|
|
107
105
|
|
|
108
106
|
技能已安装到 skills 目录:
|
|
109
|
-
- ~/.
|
|
107
|
+
- ~/.openclaw/skills/commit-helper
|
|
110
108
|
|
|
111
|
-
Git 仓库缓存: ~/.
|
|
109
|
+
Git 仓库缓存: ~/.openclaw/skills-cache/commit-helper
|
|
112
110
|
|
|
113
111
|
# 列出已安装的技能
|
|
114
112
|
$ getskill list
|
|
115
113
|
|
|
116
114
|
本地已安装的技能 (1):
|
|
117
|
-
1. commit-helper
|
|
115
|
+
1. commit-helper
|
|
118
116
|
|
|
119
117
|
# 更新技能
|
|
120
118
|
$ getskill update commit-helper
|
|
121
119
|
|
|
122
120
|
正在更新技能: commit-helper...
|
|
123
|
-
|
|
121
|
+
Git 仓库已更新
|
|
124
122
|
Already up to date.
|
|
125
|
-
|
|
126
|
-
已复制: commit-helper.md -> ~/.claude/skills/commit-helper.md
|
|
123
|
+
已复制技能目录: ~/.openclaw/skills-cache/commit-helper -> ~/.openclaw/skills/commit-helper
|
|
127
124
|
|
|
128
125
|
技能已更新到 skills 目录:
|
|
129
|
-
- ~/.
|
|
126
|
+
- ~/.openclaw/skills/commit-helper
|
|
130
127
|
|
|
131
128
|
# 查看目录路径
|
|
132
129
|
$ getskill path
|
|
133
130
|
|
|
134
|
-
技能目录: ~/.
|
|
135
|
-
缓存目录: ~/.
|
|
131
|
+
技能目录: ~/.openclaw/skills
|
|
132
|
+
缓存目录: ~/.openclaw/skills-cache
|
|
136
133
|
|
|
137
134
|
# 清理缓存
|
|
138
135
|
$ getskill clean
|
|
139
136
|
|
|
140
|
-
已清理缓存目录: ~/.
|
|
137
|
+
已清理缓存目录: ~/.openclaw/skills-cache
|
|
141
138
|
```
|
|
142
139
|
|
|
143
140
|
## 场景 3: 编程接口使用
|
|
@@ -213,21 +210,23 @@ $ ./install-skills.sh
|
|
|
213
210
|
```bash
|
|
214
211
|
# 技能不存在
|
|
215
212
|
$ getskill install non-existent-skill
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
执行命令时出错:
|
|
213
|
+
下载技能: non-existent-skill...
|
|
214
|
+
下载技能失败: 技能不存在: non-existent-skill
|
|
215
|
+
执行命令时出错: 技能不存在: non-existent-skill
|
|
219
216
|
|
|
220
217
|
# Git URL 无效
|
|
221
218
|
$ getskill install invalid-git-skill
|
|
222
|
-
|
|
223
|
-
克隆仓库: https://invalid-
|
|
224
|
-
克隆失败: fatal: repository 'https://invalid-
|
|
219
|
+
下载技能: invalid-git-skill...
|
|
220
|
+
克隆仓库: https://getskill.work/skills/invalid-git-skill.git...
|
|
221
|
+
克隆失败: fatal: repository 'https://getskill.work/skills/invalid-git-skill.git/' not found
|
|
222
|
+
下载技能失败: Command failed: git clone...
|
|
225
223
|
执行命令时出错: Command failed: git clone...
|
|
226
224
|
|
|
227
225
|
# 网络问题
|
|
228
226
|
$ getskill search commit
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
搜索失败: 请求超时,请稍后重试
|
|
228
|
+
未找到相关技能
|
|
229
|
+
提示: 尝试使用不同的关键词,或访问 https://getskill.work 查看所有可用技能
|
|
231
230
|
```
|
|
232
231
|
|
|
233
232
|
## 场景 6: 配置自定义 API 地址
|
|
@@ -255,13 +254,13 @@ $ getskill config get
|
|
|
255
254
|
|
|
256
255
|
```bash
|
|
257
256
|
# 安装几个技能后查看目录结构
|
|
258
|
-
$ tree ~/.
|
|
257
|
+
$ tree ~/.openclaw
|
|
259
258
|
|
|
260
|
-
~/.
|
|
259
|
+
~/.openclaw/
|
|
261
260
|
├── skills/
|
|
262
|
-
│ ├── commit-helper
|
|
263
|
-
│ ├── code-review
|
|
264
|
-
│ └── test-generator
|
|
261
|
+
│ ├── commit-helper/
|
|
262
|
+
│ ├── code-review/
|
|
263
|
+
│ └── test-generator/
|
|
265
264
|
└── skills-cache/
|
|
266
265
|
├── commit-helper/
|
|
267
266
|
│ ├── commit-helper.md
|
|
@@ -283,7 +282,7 @@ $ tree ~/.claude
|
|
|
283
282
|
A: Windows 用户需要重启终端或系统,以便环境变量生效。
|
|
284
283
|
|
|
285
284
|
### Q: 如何卸载技能?
|
|
286
|
-
A: 直接删除 `~/.
|
|
285
|
+
A: 直接删除 `~/.openclaw/skills/` 目录下的对应技能目录即可。
|
|
287
286
|
|
|
288
287
|
### Q: 缓存目录可以删除吗?
|
|
289
288
|
A: 可以使用 `getskill clean` 清理缓存,下次更新技能时会重新克隆。
|
package/README.md
CHANGED
|
@@ -1,282 +1,260 @@
|
|
|
1
|
-
# GetSkill
|
|
2
|
-
|
|
3
|
-
OpenClaw 技能管理工具 - 从 getskill.work 搜索、下载和更新技能文件
|
|
4
|
-
|
|
5
|
-
## 功能特性
|
|
6
|
-
|
|
7
|
-
- 🔍 从 getskill.work API 搜索技能
|
|
8
|
-
- 📥 通过 Git 克隆技能仓库
|
|
9
|
-
- 🔄 通过 Git pull 更新已安装的技能
|
|
10
|
-
- 🛠️ 自动检测并引导安装 Git(如未安装)
|
|
11
|
-
- 📂 跨平台支持(Windows/macOS/Linux)
|
|
12
|
-
- 💾 自动管理技能文件到 OpenClaw skills 目录
|
|
13
|
-
- ⚙️ 支持自定义 API 地址
|
|
14
|
-
|
|
15
|
-
## 工作原理
|
|
16
|
-
|
|
17
|
-
1. **搜索**: 从 `getskill.work` API 获取技能列表,包含 Git 仓库地址
|
|
18
|
-
2. **安装**: 使用 `git clone` 克隆技能仓库到缓存目录
|
|
19
|
-
3. **复制**:
|
|
20
|
-
4. **更新**: 使用 `git pull`
|
|
21
|
-
|
|
22
|
-
## 目录结构
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
~/.
|
|
26
|
-
├── skills/ # OpenClaw
|
|
27
|
-
│ ├── skill1
|
|
28
|
-
│ └── skill2
|
|
29
|
-
└── skills-cache/ # Git 仓库缓存
|
|
30
|
-
├── skill1/
|
|
31
|
-
└── skill2/
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### 平台路径
|
|
35
|
-
|
|
36
|
-
- **Windows**: `%USERPROFILE%\.
|
|
37
|
-
- **macOS**: `~/.
|
|
38
|
-
- **Linux**: `~/.
|
|
39
|
-
|
|
40
|
-
## 安装
|
|
41
|
-
|
|
42
|
-
### 全局安装(推荐)
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
npm install -g @workskills/getskill
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
安装后,可以在任何位置使用 `getskill` 命令。
|
|
49
|
-
|
|
50
|
-
### 本地安装
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
npm install @workskills/getskill
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
本地安装后,可以通过 npx 运行:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
npx getskill search <关键词>
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### 从源码安装
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
git clone https://github.com/
|
|
66
|
-
cd getskill
|
|
67
|
-
npm install
|
|
68
|
-
npm link
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## 使用方法
|
|
72
|
-
|
|
73
|
-
### 搜索技能
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
getskill search <关键词>
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
示例输出:
|
|
80
|
-
```
|
|
81
|
-
找到 3 个技能:
|
|
82
|
-
|
|
83
|
-
1. commit-helper
|
|
84
|
-
描述: 帮助生成规范的 git commit 信息
|
|
85
|
-
Git: https://
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
"
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
"
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
-
|
|
241
|
-
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
### Windows
|
|
262
|
-
- **自动下载**: 自动下载 Git 安装程序并启动安装向导
|
|
263
|
-
- **手动安装**: 如果自动下载失败,会提示访问 https://git-scm.com/download/win
|
|
264
|
-
|
|
265
|
-
### macOS
|
|
266
|
-
- 提示使用 Homebrew 安装:`brew install git`
|
|
267
|
-
- 如未安装 Homebrew,会提示访问 https://brew.sh/
|
|
268
|
-
|
|
269
|
-
### Linux
|
|
270
|
-
- 提示使用系统包管理器安装:
|
|
271
|
-
- Ubuntu/Debian: `sudo apt-get install git`
|
|
272
|
-
- CentOS/RHEL: `sudo yum install git`
|
|
273
|
-
- Fedora: `sudo dnf install git`
|
|
274
|
-
- Arch: `sudo pacman -S git`
|
|
275
|
-
|
|
276
|
-
## 许可证
|
|
277
|
-
|
|
278
|
-
MIT
|
|
279
|
-
|
|
280
|
-
## 作者
|
|
281
|
-
|
|
282
|
-
workskills.store
|
|
1
|
+
# GetSkill
|
|
2
|
+
|
|
3
|
+
OpenClaw 技能管理工具 - 从 getskill.work 搜索、下载和更新技能文件
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 🔍 从 getskill.work API 搜索技能
|
|
8
|
+
- 📥 通过 Git 克隆技能仓库
|
|
9
|
+
- 🔄 通过 Git pull 更新已安装的技能
|
|
10
|
+
- 🛠️ 自动检测并引导安装 Git(如未安装)
|
|
11
|
+
- 📂 跨平台支持(Windows/macOS/Linux)
|
|
12
|
+
- 💾 自动管理技能文件到 OpenClaw skills 目录
|
|
13
|
+
- ⚙️ 支持自定义 API 地址
|
|
14
|
+
|
|
15
|
+
## 工作原理
|
|
16
|
+
|
|
17
|
+
1. **搜索**: 从 `getskill.work` API 获取技能列表,包含 Git 仓库地址
|
|
18
|
+
2. **安装**: 使用 `git clone` 克隆技能仓库到缓存目录
|
|
19
|
+
3. **复制**: 将仓库目录(排除 `.git`)复制到 OpenClaw skills 目录
|
|
20
|
+
4. **更新**: 使用 `git pull` 更新仓库,并重新复制技能目录
|
|
21
|
+
|
|
22
|
+
## 目录结构
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
~/.openclaw/
|
|
26
|
+
├── skills/ # OpenClaw 技能目录
|
|
27
|
+
│ ├── skill1/
|
|
28
|
+
│ └── skill2/
|
|
29
|
+
└── skills-cache/ # Git 仓库缓存
|
|
30
|
+
├── skill1/
|
|
31
|
+
└── skill2/
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 平台路径
|
|
35
|
+
|
|
36
|
+
- **Windows**: `%USERPROFILE%\.openclaw\skills`
|
|
37
|
+
- **macOS**: `~/.openclaw/skills`
|
|
38
|
+
- **Linux**: `~/.openclaw/skills`
|
|
39
|
+
|
|
40
|
+
## 安装
|
|
41
|
+
|
|
42
|
+
### 全局安装(推荐)
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install -g @workskills/getskill
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
安装后,可以在任何位置使用 `getskill` 命令。
|
|
49
|
+
|
|
50
|
+
### 本地安装
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install @workskills/getskill
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
本地安装后,可以通过 npx 运行:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx getskill search <关键词>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 从源码安装
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/work-skills/getskill.git
|
|
66
|
+
cd getskill
|
|
67
|
+
npm install
|
|
68
|
+
npm link
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 使用方法
|
|
72
|
+
|
|
73
|
+
### 搜索技能
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
getskill search <关键词>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
示例输出:
|
|
80
|
+
```
|
|
81
|
+
找到 3 个技能:
|
|
82
|
+
|
|
83
|
+
1. commit-helper
|
|
84
|
+
描述: 帮助生成规范的 git commit 信息
|
|
85
|
+
Git: https://getskill.work/skills/commit-helper.git
|
|
86
|
+
|
|
87
|
+
2. code-review
|
|
88
|
+
描述: AI 代码审查助手
|
|
89
|
+
Git: https://getskill.work/skills/code-review.git
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 安装技能
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
getskill install <技能名称>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
示例:
|
|
99
|
+
```bash
|
|
100
|
+
getskill install commit-helper
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
操作流程:
|
|
104
|
+
1. 执行 `git clone` 到 `~/.openclaw/skills-cache/commit-helper`
|
|
105
|
+
2. 将整个技能目录复制到 `~/.openclaw/skills/commit-helper`
|
|
106
|
+
|
|
107
|
+
### 更新技能
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
getskill update <技能名称>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
示例:
|
|
114
|
+
```bash
|
|
115
|
+
getskill update commit-helper
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
操作流程:
|
|
119
|
+
1. 进入缓存目录 `~/.openclaw/skills-cache/commit-helper`
|
|
120
|
+
2. 执行 `git pull`
|
|
121
|
+
3. 重新复制最新的技能目录
|
|
122
|
+
|
|
123
|
+
### 列出本地技能
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
getskill list
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
返回 `~/.openclaw/skills` 下的技能目录名称列表。
|
|
130
|
+
|
|
131
|
+
### 查看目录路径
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
getskill path
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 清理缓存
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
getskill clean
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
清理所有 Git 仓库缓存(不影响 skills 目录中的文件)
|
|
144
|
+
|
|
145
|
+
### 配置 API 地址
|
|
146
|
+
|
|
147
|
+
查看当前 API 地址:
|
|
148
|
+
```bash
|
|
149
|
+
getskill config get
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
设置自定义 API 地址:
|
|
153
|
+
```bash
|
|
154
|
+
getskill config set https://your-custom-api.com
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
通过环境变量设置:
|
|
158
|
+
```bash
|
|
159
|
+
GETSKILL_BASE_URL=https://your-custom-api.com getskill search keyword
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## API 接口规范
|
|
163
|
+
|
|
164
|
+
### 搜索 API
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
GET https://getskill.work/api/v1/repos/search?sort=updated&order=desc&q=<关键词>&page=1&limit=20
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
响应格式:
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"ok": true,
|
|
174
|
+
"data": [
|
|
175
|
+
{
|
|
176
|
+
"id": 1,
|
|
177
|
+
"full_name": "skills/commit-helper",
|
|
178
|
+
"description": "帮助生成规范的 git commit 信息",
|
|
179
|
+
"html_url": "https://getskill.work/skills/commit-helper",
|
|
180
|
+
"clone_url": "https://getskill.work/skills/commit-helper.git"
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## 编程接口
|
|
187
|
+
|
|
188
|
+
```javascript
|
|
189
|
+
const getskill = require('@workskills/getskill');
|
|
190
|
+
|
|
191
|
+
// 设置自定义 API 地址(可选)
|
|
192
|
+
getskill.setBaseUrl('https://your-custom-api.com');
|
|
193
|
+
|
|
194
|
+
// 搜索技能
|
|
195
|
+
const results = await getskill.searchSkills('commit');
|
|
196
|
+
|
|
197
|
+
// 安装技能
|
|
198
|
+
const result = await getskill.downloadSkill('skills/commit-helper');
|
|
199
|
+
console.log(result.files); // 已复制的技能目录列表
|
|
200
|
+
|
|
201
|
+
// 更新技能
|
|
202
|
+
await getskill.updateSkill('commit-helper');
|
|
203
|
+
|
|
204
|
+
// 列出本地技能
|
|
205
|
+
const skills = getskill.listLocalSkills();
|
|
206
|
+
|
|
207
|
+
// 获取目录
|
|
208
|
+
const skillsDir = getskill.getSkillsDirectory();
|
|
209
|
+
const cacheDir = getskill.getSkillsCacheDirectory();
|
|
210
|
+
|
|
211
|
+
// 获取当前 API 地址
|
|
212
|
+
const baseUrl = getskill.getBaseUrl();
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## 技能仓库规范
|
|
216
|
+
|
|
217
|
+
技能 Git 仓库应包含:
|
|
218
|
+
- 一个或多个 `.md` 技能文件(非 README)
|
|
219
|
+
- 可选的 `README.md` 说明文档
|
|
220
|
+
- 可选的示例代码或配置文件
|
|
221
|
+
|
|
222
|
+
示例结构:
|
|
223
|
+
```
|
|
224
|
+
commit-helper/
|
|
225
|
+
├── commit-helper.md # 技能文件(仓库目录会被整体复制)
|
|
226
|
+
├── README.md # 说明文档(会随目录复制)
|
|
227
|
+
└── examples/ # 示例(会随目录复制)
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## 依赖
|
|
231
|
+
|
|
232
|
+
- Node.js >= 12
|
|
233
|
+
- Git 命令行工具(如未安装,程序会自动引导安装)
|
|
234
|
+
|
|
235
|
+
## Git 自动检测与安装
|
|
236
|
+
|
|
237
|
+
首次运行 `install` 或 `update` 命令时,程序会自动检测系统是否已安装 Git:
|
|
238
|
+
|
|
239
|
+
### Windows
|
|
240
|
+
- **自动下载**: 自动下载 Git 安装程序并启动安装向导
|
|
241
|
+
- **手动安装**: 如果自动下载失败,会提示访问 https://git-scm.com/download/win
|
|
242
|
+
|
|
243
|
+
### macOS
|
|
244
|
+
- 提示使用 Homebrew 安装:`brew install git`
|
|
245
|
+
- 如未安装 Homebrew,会提示访问 https://brew.sh/
|
|
246
|
+
|
|
247
|
+
### Linux
|
|
248
|
+
- 提示使用系统包管理器安装:
|
|
249
|
+
- Ubuntu/Debian: `sudo apt-get install git`
|
|
250
|
+
- CentOS/RHEL: `sudo yum install git`
|
|
251
|
+
- Fedora: `sudo dnf install git`
|
|
252
|
+
- Arch: `sudo pacman -S git`
|
|
253
|
+
|
|
254
|
+
## 许可证
|
|
255
|
+
|
|
256
|
+
MIT
|
|
257
|
+
|
|
258
|
+
## 作者
|
|
259
|
+
|
|
260
|
+
workskills.store
|
package/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const { exec } = require('child_process');
|
|
|
12
12
|
* 可以通过环境变量 GETSKILL_BASE_URL 自定义
|
|
13
13
|
*/
|
|
14
14
|
let BASE_URL = process.env.GETSKILL_BASE_URL || 'https://getskill.work';
|
|
15
|
+
const REQUEST_TIMEOUT_MS = 60000;
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* 设置自定义 BASE_URL
|
|
@@ -195,17 +196,17 @@ function getSkillsDirectory() {
|
|
|
195
196
|
|
|
196
197
|
switch (platform) {
|
|
197
198
|
case 'win32':
|
|
198
|
-
// Windows: %USERPROFILE%\.
|
|
199
|
-
return path.join(homeDir, '.
|
|
199
|
+
// Windows: %USERPROFILE%\.openclaw\skills
|
|
200
|
+
return path.join(homeDir, '.openclaw', 'skills');
|
|
200
201
|
case 'darwin':
|
|
201
|
-
// macOS: ~/.
|
|
202
|
-
return path.join(homeDir, '.
|
|
202
|
+
// macOS: ~/.openclaw/skills
|
|
203
|
+
return path.join(homeDir, '.openclaw', 'skills');
|
|
203
204
|
case 'linux':
|
|
204
|
-
// Linux: ~/.
|
|
205
|
-
return path.join(homeDir, '.
|
|
205
|
+
// Linux: ~/.openclaw/skills
|
|
206
|
+
return path.join(homeDir, '.openclaw', 'skills');
|
|
206
207
|
default:
|
|
207
|
-
// 默认使用 ~/.
|
|
208
|
-
return path.join(homeDir, '.
|
|
208
|
+
// 默认使用 ~/.openclaw/skills
|
|
209
|
+
return path.join(homeDir, '.openclaw', 'skills');
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
|
|
@@ -249,7 +250,7 @@ function request(url, options = {}, redirectCount = 0) {
|
|
|
249
250
|
path: urlObj.pathname + urlObj.search,
|
|
250
251
|
method: options.method || 'GET',
|
|
251
252
|
headers: options.headers || {},
|
|
252
|
-
timeout: options.timeout ||
|
|
253
|
+
timeout: options.timeout || REQUEST_TIMEOUT_MS // 默认 60 秒超时
|
|
253
254
|
};
|
|
254
255
|
|
|
255
256
|
const req = protocol.request(reqOptions, (res) => {
|
|
@@ -365,7 +366,7 @@ async function searchSkills(keyword, options = {}) {
|
|
|
365
366
|
const url = `${BASE_URL}/api/v1/repos/search?q=${encodeURIComponent(keyword)}&sort=${sort}&order=${order}&page=${page}&limit=${limit}`;
|
|
366
367
|
|
|
367
368
|
try {
|
|
368
|
-
const response = await request(url, { timeout:
|
|
369
|
+
const response = await request(url, { timeout: REQUEST_TIMEOUT_MS });
|
|
369
370
|
|
|
370
371
|
// 检查响应体是否为空
|
|
371
372
|
if (!response.body || response.body.trim() === '') {
|
|
@@ -440,96 +441,47 @@ async function searchSkills(keyword, options = {}) {
|
|
|
440
441
|
}
|
|
441
442
|
|
|
442
443
|
/**
|
|
443
|
-
*
|
|
444
|
-
* @param {string} skillId - 技能ID或名称
|
|
445
|
-
* @returns {Promise<Object>} 技能详情
|
|
444
|
+
* 获取技能仓库缓存目录
|
|
446
445
|
*/
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
const url = `${BASE_URL}/repo/${encodeURIComponent(skillId)}`;
|
|
454
|
-
|
|
455
|
-
try {
|
|
456
|
-
const response = await request(url, { timeout: 15000 });
|
|
457
|
-
|
|
458
|
-
// 检查响应体是否为空
|
|
459
|
-
if (!response.body || response.body.trim() === '') {
|
|
460
|
-
throw new Error('服务器返回空响应');
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// 尝试解析 JSON
|
|
464
|
-
let result;
|
|
465
|
-
try {
|
|
466
|
-
result = JSON.parse(response.body);
|
|
467
|
-
} catch (parseError) {
|
|
468
|
-
throw new Error(`JSON 解析错误: ${parseError.message}`);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
// 如果返回的数据格式类似搜索接口,需要解析 repository
|
|
472
|
-
if (result.repository) {
|
|
473
|
-
const repo = result.repository;
|
|
474
|
-
return {
|
|
475
|
-
name: repo.full_name || repo.name || skillId,
|
|
476
|
-
full_name: repo.full_name || '',
|
|
477
|
-
description: repo.description || '',
|
|
478
|
-
html_url: repo.html_url || '',
|
|
479
|
-
git_url: repo.html_url ? `${repo.html_url}.git` : '',
|
|
480
|
-
clone_url: repo.clone_url || ''
|
|
481
|
-
};
|
|
482
|
-
}
|
|
446
|
+
function getSkillsCacheDirectory() {
|
|
447
|
+
const homeDir = os.homedir();
|
|
448
|
+
return path.join(homeDir, '.openclaw', 'skills-cache');
|
|
449
|
+
}
|
|
483
450
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
clone_url: result.clone_url || ''
|
|
492
|
-
};
|
|
493
|
-
} catch (error) {
|
|
494
|
-
// 友好的错误提示
|
|
495
|
-
if (error.message.includes('Host not found')) {
|
|
496
|
-
throw new Error('无法连接到服务器,请检查网络或 API 地址配置');
|
|
497
|
-
} else if (error.message.includes('timeout')) {
|
|
498
|
-
throw new Error('请求超时,请稍后重试');
|
|
499
|
-
} else if (error.message.includes('Connection refused')) {
|
|
500
|
-
throw new Error('服务器拒绝连接,请检查 API 地址是否正确');
|
|
501
|
-
} else if (error.message.includes('status code 404')) {
|
|
502
|
-
throw new Error(`技能不存在: ${skillId}`);
|
|
503
|
-
} else if (error.message.includes('status code')) {
|
|
504
|
-
throw new Error(`服务器错误: ${error.message}`);
|
|
505
|
-
} else {
|
|
506
|
-
throw new Error(`获取技能详情失败: ${error.message}`);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
451
|
+
/**
|
|
452
|
+
* 规范化技能名称(用于本地目录)
|
|
453
|
+
* @param {string} skillName - 原始技能名称
|
|
454
|
+
* @returns {string} 本地目录名
|
|
455
|
+
*/
|
|
456
|
+
function normalizeSkillName(skillName) {
|
|
457
|
+
return skillName.replace(/^skills\//, '').replace(/[\\/]/g, '_');
|
|
509
458
|
}
|
|
510
459
|
|
|
511
460
|
/**
|
|
512
|
-
*
|
|
461
|
+
* 获取远程仓库路径(用于拼接 git URL)
|
|
462
|
+
* @param {string} skillName - 原始技能名称
|
|
463
|
+
* @returns {string} 远程仓库路径
|
|
513
464
|
*/
|
|
514
|
-
function
|
|
515
|
-
|
|
516
|
-
return path.join(homeDir, '.claude', 'skills-cache');
|
|
465
|
+
function getRemoteSkillPath(skillName) {
|
|
466
|
+
return skillName.includes('/') ? skillName : `skills/${skillName}`;
|
|
517
467
|
}
|
|
518
468
|
|
|
519
469
|
/**
|
|
520
470
|
* 克隆或更新 Git 仓库
|
|
521
|
-
* @param {string} gitUrl - Git 仓库地址
|
|
522
471
|
* @param {string} skillName - 技能名称
|
|
523
472
|
* @returns {Promise<string>} 本地仓库路径
|
|
524
473
|
*/
|
|
525
|
-
async function cloneOrUpdateRepo(
|
|
474
|
+
async function cloneOrUpdateRepo(skillName) {
|
|
526
475
|
// 首先检查并确保 Git 已安装
|
|
527
476
|
await ensureGitInstalled();
|
|
528
477
|
|
|
529
478
|
const cacheDir = getSkillsCacheDirectory();
|
|
530
479
|
ensureDirectoryExists(cacheDir);
|
|
531
480
|
|
|
532
|
-
const
|
|
481
|
+
const localSkillName = normalizeSkillName(skillName);
|
|
482
|
+
const remoteSkillPath = getRemoteSkillPath(skillName);
|
|
483
|
+
|
|
484
|
+
const repoPath = path.join(cacheDir, localSkillName);
|
|
533
485
|
|
|
534
486
|
if (fs.existsSync(repoPath)) {
|
|
535
487
|
// 仓库已存在,执行 git pull
|
|
@@ -543,9 +495,10 @@ async function cloneOrUpdateRepo(gitUrl, skillName) {
|
|
|
543
495
|
}
|
|
544
496
|
} else {
|
|
545
497
|
// 克隆新仓库
|
|
498
|
+
const gitUrl = `${BASE_URL}/${remoteSkillPath}.git`;
|
|
546
499
|
console.log(`克隆仓库: ${gitUrl}...`);
|
|
547
500
|
try {
|
|
548
|
-
await executeCommand(`git clone "${gitUrl}" "${
|
|
501
|
+
await executeCommand(`git clone "${gitUrl}" "${localSkillName}"`, cacheDir);
|
|
549
502
|
console.log(`仓库克隆成功: ${repoPath}`);
|
|
550
503
|
} catch (error) {
|
|
551
504
|
console.error(`克隆失败: ${error.message}`);
|
|
@@ -557,56 +510,83 @@ async function cloneOrUpdateRepo(gitUrl, skillName) {
|
|
|
557
510
|
}
|
|
558
511
|
|
|
559
512
|
/**
|
|
560
|
-
*
|
|
513
|
+
* 递归复制目录(排除 .git)
|
|
514
|
+
* @param {string} sourceDir - 源目录
|
|
515
|
+
* @param {string} targetDir - 目标目录
|
|
516
|
+
*/
|
|
517
|
+
function copyDirectoryRecursive(sourceDir, targetDir) {
|
|
518
|
+
ensureDirectoryExists(targetDir);
|
|
519
|
+
|
|
520
|
+
const entries = fs.readdirSync(sourceDir, { withFileTypes: true });
|
|
521
|
+
entries.forEach(entry => {
|
|
522
|
+
if (entry.name === '.git') {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const sourcePath = path.join(sourceDir, entry.name);
|
|
527
|
+
const targetPath = path.join(targetDir, entry.name);
|
|
528
|
+
|
|
529
|
+
if (entry.isDirectory()) {
|
|
530
|
+
copyDirectoryRecursive(sourcePath, targetPath);
|
|
531
|
+
} else if (entry.isFile()) {
|
|
532
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* 从仓库复制整个技能目录到 skills 目录
|
|
561
539
|
* @param {string} repoPath - 仓库路径
|
|
562
540
|
* @param {string} skillName - 技能名称
|
|
563
541
|
*/
|
|
564
|
-
function copySkillFiles(repoPath) {
|
|
542
|
+
function copySkillFiles(repoPath, skillName) {
|
|
565
543
|
const skillsDir = getSkillsDirectory();
|
|
566
544
|
ensureDirectoryExists(skillsDir);
|
|
545
|
+
const localSkillName = normalizeSkillName(skillName);
|
|
567
546
|
|
|
568
|
-
//
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
file.endsWith('.md') &&
|
|
572
|
-
!file.toLowerCase().startsWith('readme')
|
|
573
|
-
);
|
|
547
|
+
// 确保仓库目录中至少有一个技能 .md 文件
|
|
548
|
+
const hasSkillMd = fs.readdirSync(repoPath)
|
|
549
|
+
.some(file => file.endsWith('.md') && !file.toLowerCase().startsWith('readme'));
|
|
574
550
|
|
|
575
|
-
if (
|
|
576
|
-
throw new Error(
|
|
551
|
+
if (!hasSkillMd) {
|
|
552
|
+
throw new Error('在仓库中未找到技能 .md 文件');
|
|
577
553
|
}
|
|
578
554
|
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
555
|
+
const targetSkillDir = path.join(skillsDir, localSkillName);
|
|
556
|
+
fs.rmSync(targetSkillDir, { recursive: true, force: true });
|
|
557
|
+
copyDirectoryRecursive(repoPath, targetSkillDir);
|
|
558
|
+
console.log(`已复制技能目录: ${repoPath} -> ${targetSkillDir}`);
|
|
583
559
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
560
|
+
return [targetSkillDir];
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* 复制完成后尝试重启 OpenClaw Gateway,使新技能立即生效
|
|
565
|
+
*/
|
|
566
|
+
async function restartOpenClawGateway() {
|
|
567
|
+
const restartCommand = 'openclaw gateway restart';
|
|
568
|
+
console.log(`尝试执行: ${restartCommand}`);
|
|
588
569
|
|
|
589
|
-
|
|
570
|
+
try {
|
|
571
|
+
await executeCommand(restartCommand);
|
|
572
|
+
console.log('OpenClaw Gateway 重启成功,新技能应已生效。');
|
|
573
|
+
} catch (error) {
|
|
574
|
+
// 不阻断安装/更新主流程,给出手动操作提示
|
|
575
|
+
console.warn('自动重启 OpenClaw Gateway 失败,请手动执行: openclaw gateway restart');
|
|
576
|
+
console.warn(`失败原因: ${error.message}`);
|
|
577
|
+
}
|
|
590
578
|
}
|
|
591
579
|
|
|
592
580
|
/**
|
|
593
581
|
* 下载技能(通过 Git)
|
|
594
|
-
* @param {string}
|
|
582
|
+
* @param {string} skillName - 技能名称
|
|
595
583
|
*/
|
|
596
|
-
async function downloadSkill(
|
|
584
|
+
async function downloadSkill(skillName) {
|
|
597
585
|
try {
|
|
598
|
-
console.log(
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
const gitUrl = skillDetail.clone_url || skillDetail.git_url;
|
|
603
|
-
if (!gitUrl) {
|
|
604
|
-
throw new Error('技能信息中未包含 git_url 或 clone_url');
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
const skillName = skillDetail.name || skillIdOrName;
|
|
608
|
-
const repoPath = await cloneOrUpdateRepo(gitUrl, skillName);
|
|
609
|
-
const copiedFiles = copySkillFiles(repoPath);
|
|
586
|
+
console.log(`下载技能: ${skillName}...`);
|
|
587
|
+
const repoPath = await cloneOrUpdateRepo(skillName);
|
|
588
|
+
const copiedFiles = copySkillFiles(repoPath, skillName);
|
|
589
|
+
await restartOpenClawGateway();
|
|
610
590
|
|
|
611
591
|
return {
|
|
612
592
|
skillName,
|
|
@@ -628,7 +608,8 @@ async function updateSkill(skillName) {
|
|
|
628
608
|
console.log(`正在更新技能: ${skillName}...`);
|
|
629
609
|
|
|
630
610
|
const cacheDir = getSkillsCacheDirectory();
|
|
631
|
-
const
|
|
611
|
+
const localSkillName = normalizeSkillName(skillName);
|
|
612
|
+
const repoPath = path.join(cacheDir, localSkillName);
|
|
632
613
|
|
|
633
614
|
if (!fs.existsSync(repoPath)) {
|
|
634
615
|
console.log(`技能仓库不存在,将重新下载...`);
|
|
@@ -639,8 +620,9 @@ async function updateSkill(skillName) {
|
|
|
639
620
|
await executeCommand('git pull', repoPath);
|
|
640
621
|
console.log(`Git 仓库已更新`);
|
|
641
622
|
|
|
642
|
-
//
|
|
643
|
-
const copiedFiles = copySkillFiles(repoPath);
|
|
623
|
+
// 复制技能目录到 skills 目录
|
|
624
|
+
const copiedFiles = copySkillFiles(repoPath, skillName);
|
|
625
|
+
await restartOpenClawGateway();
|
|
644
626
|
|
|
645
627
|
console.log(`技能 ${skillName} 更新成功!`);
|
|
646
628
|
return {
|
|
@@ -665,10 +647,9 @@ function listLocalSkills() {
|
|
|
665
647
|
return [];
|
|
666
648
|
}
|
|
667
649
|
|
|
668
|
-
const
|
|
669
|
-
const
|
|
670
|
-
|
|
671
|
-
return skillFiles;
|
|
650
|
+
const entries = fs.readdirSync(skillsDir, { withFileTypes: true });
|
|
651
|
+
const skillDirs = entries.filter(entry => entry.isDirectory()).map(entry => entry.name);
|
|
652
|
+
return skillDirs;
|
|
672
653
|
}
|
|
673
654
|
|
|
674
655
|
/**
|
|
@@ -792,7 +773,6 @@ async function cli() {
|
|
|
792
773
|
// 导出模块函数
|
|
793
774
|
module.exports = {
|
|
794
775
|
searchSkills,
|
|
795
|
-
getSkillDetail,
|
|
796
776
|
downloadSkill,
|
|
797
777
|
updateSkill,
|
|
798
778
|
listLocalSkills,
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workskills/getskill",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.1.6",
|
|
4
|
+
"description": "A skill management tool for OpenClaw that enables searching, downloading, and updating skill files from the getskill.work repository",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"getskill": "
|
|
7
|
+
"getskill": "index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "node verify.js",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/
|
|
17
|
+
"url": "git+https://github.com/work-skills/getskill.git"
|
|
18
18
|
},
|
|
19
19
|
"bugs": {
|
|
20
|
-
"url": "https://github.com/
|
|
20
|
+
"url": "https://github.com/work-skills/getskill/issues"
|
|
21
21
|
},
|
|
22
|
-
"homepage": "https://github.com/
|
|
22
|
+
"homepage": "https://github.com/work-skills/getskill#readme",
|
|
23
23
|
"keywords": [
|
|
24
24
|
"openclaw",
|
|
25
25
|
"workskills",
|