@catcuts-skills/hello-world 1.0.3
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/LICENSE +21 -0
- package/README.md +201 -0
- package/SKILL.md +64 -0
- package/package.json +42 -0
- package/scripts/install-skill.js +110 -0
- package/scripts/uninstall-skill.js +108 -0
- package/scripts/usage-guide.js +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agent Skill NPM Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# Hello World Skill
|
|
2
|
+
|
|
3
|
+
简单的 Hello World 示例技能,用于验证 Claude Code 技能安装是否成功。
|
|
4
|
+
|
|
5
|
+
## 项目简介
|
|
6
|
+
|
|
7
|
+
这是一个入门级的 Claude Code 技能示例,旨在帮助新用户:
|
|
8
|
+
|
|
9
|
+
- 验证技能系统是否正常工作
|
|
10
|
+
- 了解技能的基本结构和安装流程
|
|
11
|
+
- 检查开发环境配置(Node.js、npm)
|
|
12
|
+
|
|
13
|
+
## 功能特性
|
|
14
|
+
|
|
15
|
+
- **欢迎信息**:显示友好的欢迎消息
|
|
16
|
+
- **环境检查**:自动检测并显示 Node.js 和 npm 版本
|
|
17
|
+
- **路径验证**:确认技能文件已正确安装
|
|
18
|
+
- **使用示例**:提供下一步学习建议
|
|
19
|
+
|
|
20
|
+
## 安装方法
|
|
21
|
+
|
|
22
|
+
### 快速安装
|
|
23
|
+
|
|
24
|
+
从 npm 安装包时会自动注册 skill 到 Opencode、Claude Code、Codex、Cursor 及其他 [19 个工具](https://github.com/vercel-labs/add-skill?tab=readme-ov-file#available-agents)。感谢 [Vercel 开源的 add-skill](https://github.com/vercel-labs/add-skill) 🌹
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# 全局安装(推荐)
|
|
28
|
+
npm install -g @catcuts-skills/hello-world
|
|
29
|
+
|
|
30
|
+
# 项目级安装
|
|
31
|
+
npm install @catcuts-skills/hello-world
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 本地开发安装
|
|
35
|
+
|
|
36
|
+
如果正在开发本 skill,可以使用 npm scripts 手动安装:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# 全局安装
|
|
40
|
+
npm run install:global
|
|
41
|
+
|
|
42
|
+
# 项目级安装
|
|
43
|
+
npm run install:local
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 手动安装
|
|
47
|
+
|
|
48
|
+
如果自动安装失败,可以手动运行:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# 全局安装
|
|
52
|
+
npx add-skill . -a claude-code -g -y
|
|
53
|
+
|
|
54
|
+
# 项目级安装
|
|
55
|
+
npx add-skill . -a claude-code -y
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**安装范围说明**:
|
|
59
|
+
|
|
60
|
+
- **全局**: 安装到用户目录 `~/.claude/skills/hello-world`,所有项目可用
|
|
61
|
+
- **项目级**: 安装到项目目录 `.claude/skills/hello-world`,仅当前项目可用
|
|
62
|
+
|
|
63
|
+
### 测试安装
|
|
64
|
+
|
|
65
|
+
运行测试以验证安装配置(不会实际安装):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm test
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 卸载
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# 全局卸载
|
|
75
|
+
npm uninstall -g @catcuts-skills/hello-world
|
|
76
|
+
|
|
77
|
+
# 项目级卸载
|
|
78
|
+
npm uninstall @catcuts-skills/hello-world
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
卸载时会自动清理 skill 文件。
|
|
82
|
+
|
|
83
|
+
## 使用示例
|
|
84
|
+
|
|
85
|
+
安装完成后,在 Claude Code 中输入:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
hello-world
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**预期输出**:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
✨ Hello World Skill 已成功安装!
|
|
95
|
+
|
|
96
|
+
这是你的第一个 Claude Code 技能。让我们验证一下环境配置是否正确。
|
|
97
|
+
|
|
98
|
+
环境信息:
|
|
99
|
+
Node.js 版本: v20.x.x
|
|
100
|
+
npm 版本: 10.x.x
|
|
101
|
+
当前工作目录: /your/current/path
|
|
102
|
+
当前日期时间: 2026-01-26 10:30:00
|
|
103
|
+
|
|
104
|
+
✓ 技能文件已正确安装
|
|
105
|
+
|
|
106
|
+
🎉 恭喜!你的技能系统运行正常。
|
|
107
|
+
|
|
108
|
+
下一步建议:
|
|
109
|
+
1. 探索更多技能:访问 https://github.com/catcuts/agent-skills
|
|
110
|
+
2. 创建自定义技能:参考本技能的结构创建你自己的技能
|
|
111
|
+
3. 了解更多 Claude Code 功能:查看官方文档
|
|
112
|
+
|
|
113
|
+
技术信息:
|
|
114
|
+
- 技能名称:hello-world
|
|
115
|
+
- 版本:1.0.0
|
|
116
|
+
- 作者:catcuts
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## 验证安装成功
|
|
120
|
+
|
|
121
|
+
安装成功的标志:
|
|
122
|
+
|
|
123
|
+
1. **文件存在**:检查技能文件是否已安装
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# 全局安装
|
|
127
|
+
ls ~/.claude/skills/hello-world/SKILL.md
|
|
128
|
+
|
|
129
|
+
# 项目级安装
|
|
130
|
+
ls .claude/skills/hello-world/SKILL.md
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
2. **Claude Code 识别**:在 Claude Code 中输入 `/skills` 应该能看到 `hello-world` 技能
|
|
134
|
+
|
|
135
|
+
3. **功能正常**:输入 `hello-world` 能正确显示欢迎信息和环境信息
|
|
136
|
+
|
|
137
|
+
## 技术细节
|
|
138
|
+
|
|
139
|
+
### 安装原理
|
|
140
|
+
|
|
141
|
+
本技能使用 [Vercel 开源的 add-skill](https://github.com/vercel-labs/add-skill) 工具进行安装管理,支持 Opencode、Claude Code、Codex、Cursor 及其他 [19 个工具](https://github.com/vercel-labs/add-skill?tab=readme-ov-file#available-agents)。
|
|
142
|
+
|
|
143
|
+
1. `package.json` 中的 `postinstall` 钩子自动运行安装脚本
|
|
144
|
+
2. 安装脚本调用 `add-skill` 将 `SKILL.md` 复制到目标目录
|
|
145
|
+
3. Claude Code 自动检测并加载技能
|
|
146
|
+
|
|
147
|
+
### 安装路径
|
|
148
|
+
|
|
149
|
+
**全局安装**:
|
|
150
|
+
|
|
151
|
+
- 实际存储: `~/.agents/skills/hello-world/`
|
|
152
|
+
- Claude Code 链接: `~/.claude/skills/hello-world/` (符号链接)
|
|
153
|
+
|
|
154
|
+
**项目级安装**:
|
|
155
|
+
|
|
156
|
+
- 实际存储: `.agents/skills/hello-world/`
|
|
157
|
+
- Claude Code 链接: `.claude/skills/hello-world/` (符号链接)
|
|
158
|
+
|
|
159
|
+
### 项目结构
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
skills/hello-world/
|
|
163
|
+
├── package.json # NPM 包配置
|
|
164
|
+
├── SKILL.md # 技能定义文件
|
|
165
|
+
├── README.md # 使用文档
|
|
166
|
+
├── LICENSE # MIT 许可证
|
|
167
|
+
├── .gitignore # Git 忽略规则
|
|
168
|
+
└── scripts/
|
|
169
|
+
├── install-skill.js # 安装脚本
|
|
170
|
+
└── uninstall-skill.js # 卸载脚本
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## 系统要求
|
|
174
|
+
|
|
175
|
+
- Node.js >= 18.0.0
|
|
176
|
+
- npm >= 9.0.0
|
|
177
|
+
- Claude Code CLI
|
|
178
|
+
|
|
179
|
+
## 下一步学习建议
|
|
180
|
+
|
|
181
|
+
1. **探索更多技能**
|
|
182
|
+
- 访问 [agent-skills 仓库](https://github.com/catcuts/agent-skills) 查看更多技能示例
|
|
183
|
+
- 尝试 `handover` 技能学习跨会话工作交接
|
|
184
|
+
|
|
185
|
+
2. **创建自定义技能**
|
|
186
|
+
- 参考 `SKILL.md` 的 YAML frontmatter 格式
|
|
187
|
+
- 学习如何使用 `allowed-tools` 声明需要的工具
|
|
188
|
+
- 编写清晰的技能指令
|
|
189
|
+
|
|
190
|
+
3. **深入学习 Claude Code**
|
|
191
|
+
- 阅读 [Claude Code 官方文档](https://claude.com/claude-code)
|
|
192
|
+
- 了解技能开发最佳实践
|
|
193
|
+
- 参与社区讨论
|
|
194
|
+
|
|
195
|
+
## 开发
|
|
196
|
+
|
|
197
|
+
本技能基于 [agent-skill-npm-boilerplate](https://github.com/catcuts/agent-skill-npm-boilerplate) 开发。
|
|
198
|
+
|
|
199
|
+
## 许可证
|
|
200
|
+
|
|
201
|
+
MIT License - 详见 [LICENSE](LICENSE) 文件
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hello-world
|
|
3
|
+
description: 简单的 Hello World 示例技能,用于验证技能安装是否成功。显示欢迎信息、环境信息和使用示例。
|
|
4
|
+
allowed-tools: Bash
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Hello World Skill
|
|
9
|
+
|
|
10
|
+
欢迎使用 Hello World Skill!这是一个简单的示例技能,用于验证 Claude Code 技能系统是否正常工作。
|
|
11
|
+
|
|
12
|
+
## 任务指令
|
|
13
|
+
|
|
14
|
+
当被调用时,执行以下步骤:
|
|
15
|
+
|
|
16
|
+
1. **显示欢迎信息**
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
✨ Hello World Skill 已成功安装!
|
|
20
|
+
|
|
21
|
+
这是你的第一个 Claude Code 技能。让我们验证一下环境配置是否正确。
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
2. **收集环境信息**
|
|
25
|
+
|
|
26
|
+
使用 `Bash` 工具执行以下命令:
|
|
27
|
+
- `node --version` - 显示 Node.js 版本
|
|
28
|
+
- `npm --version` - 显示 npm 版本
|
|
29
|
+
- `pwd` - 显示当前工作目录
|
|
30
|
+
- `date` - 显示当前日期时间
|
|
31
|
+
|
|
32
|
+
3. **验证安装路径**
|
|
33
|
+
|
|
34
|
+
检查 skill 文件是否已正确安装:
|
|
35
|
+
- 全局安装:`~/.claude/skills/hello-world/SKILL.md`
|
|
36
|
+
- 项目级安装:`.claude/skills/hello-world/SKILL.md`
|
|
37
|
+
|
|
38
|
+
使用 Bash 执行:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
ls -la ~/.claude/skills/hello-world/SKILL.md 2>/dev/null || ls -la .claude/skills/hello-world/SKILL.md 2>/dev/null
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
如果文件存在,显示:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
✓ 技能文件已正确安装
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
4. **显示下一步建议**
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
🎉 恭喜!你的技能系统运行正常。
|
|
54
|
+
|
|
55
|
+
下一步建议:
|
|
56
|
+
1. 探索更多技能:访问 https://github.com/catcuts/agent-skills
|
|
57
|
+
2. 创建自定义技能:参考本技能的结构创建你自己的技能
|
|
58
|
+
3. 了解更多 Claude Code 功能:查看官方文档
|
|
59
|
+
|
|
60
|
+
技术信息:
|
|
61
|
+
- 技能名称:hello-world
|
|
62
|
+
- 版本:1.0.0
|
|
63
|
+
- 作者:catcuts
|
|
64
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@catcuts-skills/hello-world",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "简单的 Hello World 示例技能,用于验证技能安装是否成功。显示欢迎信息、环境信息和使用示例。",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node scripts/install-skill.js",
|
|
8
|
+
"preuninstall": "node scripts/uninstall-skill.js",
|
|
9
|
+
"test": "node scripts/install-skill.js --dry-run",
|
|
10
|
+
"install:global": "node scripts/install-skill.js --global",
|
|
11
|
+
"install:local": "node scripts/install-skill.js --local",
|
|
12
|
+
"lint": "echo 'Add your linting commands here'"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"SKILL.md",
|
|
16
|
+
"scripts/"
|
|
17
|
+
],
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"skills": "^1.1.2"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"claude-code",
|
|
23
|
+
"skill",
|
|
24
|
+
"hello-world",
|
|
25
|
+
"getting-started",
|
|
26
|
+
"environment-check"
|
|
27
|
+
],
|
|
28
|
+
"author": "catcuts",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/catcuts/agent-skills.git",
|
|
33
|
+
"directory": "skills/hello-world"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/catcuts/agent-skills/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/catcuts/agent-skills/tree/main/skills/hello-world#readme",
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18.0.0"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hello World Skill 安装脚本
|
|
5
|
+
* 使用 skills 将 skill 安装到 Claude Code
|
|
6
|
+
*
|
|
7
|
+
* 命令行参数 (推荐):
|
|
8
|
+
* --dry-run: 测试模式,只显示将要执行的命令,不实际安装
|
|
9
|
+
* --global: 强制全局安装
|
|
10
|
+
* --local: 强制项目级安装
|
|
11
|
+
*
|
|
12
|
+
* 环境变量 (备用):
|
|
13
|
+
* - SKILL_SCOPE: 安装范围,可选值: GLOBAL(全局) 或 LOCAL(项目级),默认: GLOBAL
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const { execSync } = require('child_process');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const { printUsageGuide } = require('./usage-guide');
|
|
20
|
+
|
|
21
|
+
// 获取包根目录
|
|
22
|
+
const packageRoot = path.resolve(__dirname, '..');
|
|
23
|
+
|
|
24
|
+
// 解析命令行参数
|
|
25
|
+
const args = process.argv.slice(2);
|
|
26
|
+
const dryRun = args.includes('--dry-run');
|
|
27
|
+
const forceGlobal = args.includes('--global');
|
|
28
|
+
const forceLocal = args.includes('--local');
|
|
29
|
+
|
|
30
|
+
// 确定安装范围
|
|
31
|
+
let scope;
|
|
32
|
+
if (forceGlobal) {
|
|
33
|
+
scope = 'GLOBAL';
|
|
34
|
+
} else if (forceLocal) {
|
|
35
|
+
scope = 'LOCAL';
|
|
36
|
+
} else {
|
|
37
|
+
scope = (process.env.SKILL_SCOPE || 'GLOBAL').toUpperCase();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const isGlobal = scope === 'GLOBAL';
|
|
41
|
+
|
|
42
|
+
// 日志函数
|
|
43
|
+
function log(message, type = 'info') {
|
|
44
|
+
const prefix =
|
|
45
|
+
{
|
|
46
|
+
info: '✓',
|
|
47
|
+
success: '✓',
|
|
48
|
+
warning: '⚠',
|
|
49
|
+
error: '✗',
|
|
50
|
+
}[type] || '✓';
|
|
51
|
+
|
|
52
|
+
console.log(`${prefix} ${message}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 错误处理
|
|
56
|
+
function handleError(error) {
|
|
57
|
+
log(`安装失败: ${error.message}`, 'error');
|
|
58
|
+
log('\n您可以尝试手动安装:', 'warning');
|
|
59
|
+
log(` npx skills add "${packageRoot}" ${isGlobal ? '-g' : ''} -y`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
log(`开始安装 Hello World Skill...`, 'info');
|
|
65
|
+
log(`安装范围: ${isGlobal ? '全局(GLOBAL)' : '项目级(LOCAL)'}`, 'info');
|
|
66
|
+
|
|
67
|
+
// 构建 skills 命令
|
|
68
|
+
const commandParts = [
|
|
69
|
+
'npx',
|
|
70
|
+
'skills',
|
|
71
|
+
'add',
|
|
72
|
+
`"${packageRoot}"`,
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
if (isGlobal) {
|
|
76
|
+
commandParts.push('-g');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
commandParts.push('-y'); // 非交互模式
|
|
80
|
+
|
|
81
|
+
const command = commandParts.join(' ');
|
|
82
|
+
|
|
83
|
+
if (dryRun) {
|
|
84
|
+
log('\n[DRY-RUN] 将要执行的命令:', 'warning');
|
|
85
|
+
console.log(` ${command}`);
|
|
86
|
+
log(
|
|
87
|
+
'\n测试通过 - 实际安装请运行: npm run install:global 或 npm run install:local',
|
|
88
|
+
'success'
|
|
89
|
+
);
|
|
90
|
+
process.exit(0);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 执行安装
|
|
94
|
+
log('\n正在执行 skills add...', 'info');
|
|
95
|
+
execSync(command, {
|
|
96
|
+
stdio: 'inherit',
|
|
97
|
+
cwd: packageRoot,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
log('\n安装成功!', 'success');
|
|
101
|
+
log(
|
|
102
|
+
`Skill 已安装到: ${isGlobal ? '~/.claude/skills/hello-world' : '.claude/skills/hello-world'}`,
|
|
103
|
+
'info'
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// 显示使用指南
|
|
107
|
+
printUsageGuide();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
handleError(error);
|
|
110
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hello World Skill 卸载脚本
|
|
5
|
+
* 从 Claude Code 中移除 skill
|
|
6
|
+
*
|
|
7
|
+
* 命令行参数 (推荐):
|
|
8
|
+
* --global: 强制全局卸载
|
|
9
|
+
* --local: 强制项目级卸载
|
|
10
|
+
*
|
|
11
|
+
* 环境变量 (备用):
|
|
12
|
+
* - SKILL_SCOPE: 安装范围,可选值: GLOBAL(全局) 或 LOCAL(项目级),默认: GLOBAL
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const os = require('os');
|
|
18
|
+
|
|
19
|
+
// 解析命令行参数
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
const forceGlobal = args.includes('--global');
|
|
22
|
+
const forceLocal = args.includes('--local');
|
|
23
|
+
|
|
24
|
+
// 确定安装范围
|
|
25
|
+
let scope;
|
|
26
|
+
if (forceGlobal) {
|
|
27
|
+
scope = 'GLOBAL';
|
|
28
|
+
} else if (forceLocal) {
|
|
29
|
+
scope = 'LOCAL';
|
|
30
|
+
} else {
|
|
31
|
+
scope = (process.env.SKILL_SCOPE || 'GLOBAL').toUpperCase();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isGlobal = scope === 'GLOBAL';
|
|
35
|
+
|
|
36
|
+
// 日志函数
|
|
37
|
+
function log(message, type = 'info') {
|
|
38
|
+
const prefix =
|
|
39
|
+
{
|
|
40
|
+
info: '✓',
|
|
41
|
+
success: '✓',
|
|
42
|
+
warning: '⚠',
|
|
43
|
+
error: '✗',
|
|
44
|
+
}[type] || '✓';
|
|
45
|
+
|
|
46
|
+
console.log(`${prefix} ${message}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 递归删除目录
|
|
50
|
+
function removeDirectory(dirPath) {
|
|
51
|
+
if (!fs.existsSync(dirPath)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
fs.rmSync(dirPath, { recursive: true, force: true });
|
|
57
|
+
return true;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
log(`删除 ${dirPath} 失败: ${error.message}`, 'error');
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
log(`开始卸载 Hello World Skill...`, 'info');
|
|
66
|
+
log(`卸载范围: ${isGlobal ? '全局(GLOBAL)' : '项目级(LOCAL)'}`, 'info');
|
|
67
|
+
|
|
68
|
+
let removedCount = 0;
|
|
69
|
+
|
|
70
|
+
if (isGlobal) {
|
|
71
|
+
// 全局卸载
|
|
72
|
+
const homeDir = os.homedir();
|
|
73
|
+
const paths = [
|
|
74
|
+
path.join(homeDir, '.claude', 'skills', 'hello-world'),
|
|
75
|
+
path.join(homeDir, '.agents', 'skills', 'hello-world'),
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
paths.forEach((dirPath) => {
|
|
79
|
+
if (removeDirectory(dirPath)) {
|
|
80
|
+
log(`已删除: ${dirPath}`, 'success');
|
|
81
|
+
removedCount++;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
// 项目级卸载
|
|
86
|
+
const cwd = process.cwd();
|
|
87
|
+
const paths = [
|
|
88
|
+
path.join(cwd, '.claude', 'skills', 'hello-world'),
|
|
89
|
+
path.join(cwd, '.agents', 'skills', 'hello-world'),
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
paths.forEach((dirPath) => {
|
|
93
|
+
if (removeDirectory(dirPath)) {
|
|
94
|
+
log(`已删除: ${dirPath}`, 'success');
|
|
95
|
+
removedCount++;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (removedCount > 0) {
|
|
101
|
+
log(`\n卸载成功! 已删除 ${removedCount} 个目录`, 'success');
|
|
102
|
+
} else {
|
|
103
|
+
log('\n未找到已安装的 skill 文件', 'warning');
|
|
104
|
+
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
log(`卸载失败: ${error.message}`, 'error');
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 技能使用指南生成器
|
|
5
|
+
* 在安装成功后显示友好的使用指南
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 读取 package.json 中的信息
|
|
13
|
+
*/
|
|
14
|
+
function getPackageInfo() {
|
|
15
|
+
const packageRoot = path.resolve(__dirname, '..');
|
|
16
|
+
const packageJsonPath = path.join(packageRoot, 'package.json');
|
|
17
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
name: packageJson.name.split('/')[1] || packageJson.name,
|
|
21
|
+
description: packageJson.description,
|
|
22
|
+
homepage: packageJson.homepage || '',
|
|
23
|
+
repository: packageJson.repository?.url || '',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 读取 SKILL.md 中的触发指令
|
|
29
|
+
*/
|
|
30
|
+
function getSkillInstructions() {
|
|
31
|
+
const packageRoot = path.resolve(__dirname, '..');
|
|
32
|
+
const skillMdPath = path.join(packageRoot, 'SKILL.md');
|
|
33
|
+
|
|
34
|
+
if (!fs.existsSync(skillMdPath)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const content = fs.readFileSync(skillMdPath, 'utf-8');
|
|
39
|
+
// 匹配 description 行中的指令说明
|
|
40
|
+
const match = content.match(/^description:\s*(.+)$/m);
|
|
41
|
+
return match ? match[1].trim() : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 打印使用指南
|
|
46
|
+
*/
|
|
47
|
+
function printUsageGuide() {
|
|
48
|
+
const pkg = getPackageInfo();
|
|
49
|
+
const instructions = getSkillInstructions();
|
|
50
|
+
|
|
51
|
+
// 如果 SKILL.md 中有指令说明,使用它;否则使用 package.json 的 description
|
|
52
|
+
const usageInfo = instructions || pkg.description;
|
|
53
|
+
|
|
54
|
+
const guide = `
|
|
55
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
56
|
+
🎉 技能安装成功!
|
|
57
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
58
|
+
|
|
59
|
+
📦 技能名称: ${pkg.name}
|
|
60
|
+
📝 功能描述: ${pkg.description}
|
|
61
|
+
|
|
62
|
+
🚀 如何使用:
|
|
63
|
+
${usageInfo}
|
|
64
|
+
|
|
65
|
+
📖 更多信息:
|
|
66
|
+
${pkg.homepage ? ` 文档: ${pkg.homepage}` : ''}
|
|
67
|
+
${pkg.repository ? ` 仓库: ${pkg.repository}` : ''}
|
|
68
|
+
|
|
69
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
console.log(guide);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = { printUsageGuide };
|