@catcuts-skills/commit 1.0.0
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 +193 -0
- package/SKILL.md +128 -0
- package/package.json +41 -0
- package/scripts/install-skill.js +102 -0
- package/scripts/uninstall-skill.js +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 <your-name>
|
|
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,193 @@
|
|
|
1
|
+
# Commit Skill
|
|
2
|
+
|
|
3
|
+
自动生成符合 Conventional Commits 规范的提交信息。
|
|
4
|
+
|
|
5
|
+
## 项目简介
|
|
6
|
+
|
|
7
|
+
这是一个实用的 Claude Code 技能,能够读取 Git 暂存区的代码差异,自动生成符合 [Conventional Commits](https://www.conventionalcommits.org/) 规范的提交信息。
|
|
8
|
+
|
|
9
|
+
## 功能特性
|
|
10
|
+
|
|
11
|
+
- **智能分析**: 分析 Git 暂存区的代码差异
|
|
12
|
+
- **规范生成**: 自动生成符合 Conventional Commits 规范的提交文本
|
|
13
|
+
- **类型识别**: 识别 feat、fix、docs、style、refactor、test、chore 等提交类型
|
|
14
|
+
- **格式化输出**: 提供清晰、规范的提交信息格式
|
|
15
|
+
|
|
16
|
+
## 安装方法
|
|
17
|
+
|
|
18
|
+
### 快速安装
|
|
19
|
+
|
|
20
|
+
从 npm 安装包时会自动将 skill 注册到 Claude Code:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# 全局安装(推荐)
|
|
24
|
+
npm install -g @<your-username>/commit
|
|
25
|
+
|
|
26
|
+
# 项目级安装
|
|
27
|
+
npm install @<your-username>/commit
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 本地开发安装
|
|
31
|
+
|
|
32
|
+
如果正在开发本 skill,可以使用 npm scripts 手动安装:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# 全局安装
|
|
36
|
+
npm run install:global
|
|
37
|
+
|
|
38
|
+
# 项目级安装
|
|
39
|
+
npm run install:local
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 手动安装
|
|
43
|
+
|
|
44
|
+
如果自动安装失败,可以手动运行:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# 全局安装
|
|
48
|
+
npx add-skill . -a claude-code -g -y
|
|
49
|
+
|
|
50
|
+
# 项目级安装
|
|
51
|
+
npx add-skill . -a claude-code -y
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**支持平台**: 基于 [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)。
|
|
55
|
+
|
|
56
|
+
### 测试安装
|
|
57
|
+
|
|
58
|
+
运行测试以验证安装配置(不会实际安装):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm test
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 卸载
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# 全局卸载
|
|
68
|
+
npm uninstall -g @<your-username>/commit
|
|
69
|
+
|
|
70
|
+
# 项目级卸载
|
|
71
|
+
npm uninstall @<your-username>/commit
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
卸载时会自动清理 skill 文件。
|
|
75
|
+
|
|
76
|
+
## 使用示例
|
|
77
|
+
|
|
78
|
+
安装完成后,在 Claude Code 中输入:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
commit
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
或者:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
生成 commit message
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
或者:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
创建提交
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**预期行为**:
|
|
97
|
+
|
|
98
|
+
1. 技能会执行 `git diff --staged` 获取暂存区差异
|
|
99
|
+
2. 分析代码变更的类型和范围
|
|
100
|
+
3. 生成符合 Conventional Commits 规范的提交信息
|
|
101
|
+
4. 提供格式化的输出供用户确认
|
|
102
|
+
|
|
103
|
+
**示例输出**:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
feat(skill): 添加提交信息生成功能
|
|
107
|
+
|
|
108
|
+
- 分析 Git 暂存区的代码差异
|
|
109
|
+
- 识别变更类型和影响范围
|
|
110
|
+
- 生成符合规范的提交信息
|
|
111
|
+
|
|
112
|
+
Closes #123
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Conventional Commits 规范
|
|
116
|
+
|
|
117
|
+
本技能遵循 Conventional Commits 规范,支持以下提交类型:
|
|
118
|
+
|
|
119
|
+
| 类型 | 说明 | 示例 |
|
|
120
|
+
|------|------|------|
|
|
121
|
+
| `feat` | 新功能 | feat: 添加用户登录功能 |
|
|
122
|
+
| `fix` | 修复 bug | fix: 修复登录页面错误 |
|
|
123
|
+
| `docs` | 文档更新 | docs: 更新 README.md |
|
|
124
|
+
| `style` | 代码格式调整 | style: 统一代码缩进 |
|
|
125
|
+
| `refactor` | 重构代码 | refactor: 优化数据处理逻辑 |
|
|
126
|
+
| `test` | 测试相关 | test: 添加单元测试 |
|
|
127
|
+
| `chore` | 构建/工具相关 | chore: 更新依赖版本 |
|
|
128
|
+
|
|
129
|
+
**提交信息格式**:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
<type>(<scope>): <subject>
|
|
133
|
+
|
|
134
|
+
<body>
|
|
135
|
+
|
|
136
|
+
<footer>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 技术细节
|
|
140
|
+
|
|
141
|
+
### 安装原理
|
|
142
|
+
|
|
143
|
+
本技能使用 [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)。
|
|
144
|
+
|
|
145
|
+
1. `package.json` 中的 `postinstall` 钩子自动运行安装脚本
|
|
146
|
+
2. 安装脚本调用 `add-skill` 将 `SKILL.md` 复制到目标目录
|
|
147
|
+
3. Claude Code 自动检测并加载技能
|
|
148
|
+
|
|
149
|
+
### 安装路径
|
|
150
|
+
|
|
151
|
+
**全局安装**:
|
|
152
|
+
- 实际存储: `~/.agents/skills/commit/`
|
|
153
|
+
- Claude Code 链接: `~/.claude/skills/commit/` (符号链接)
|
|
154
|
+
|
|
155
|
+
**项目级安装**:
|
|
156
|
+
- 实际存储: `.agents/skills/commit/`
|
|
157
|
+
- Claude Code 链接: `.claude/skills/commit/` (符号链接)
|
|
158
|
+
|
|
159
|
+
### 项目结构
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
skills/commit/
|
|
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
|
+
- Git
|
|
178
|
+
- Claude Code CLI
|
|
179
|
+
|
|
180
|
+
## 开发
|
|
181
|
+
|
|
182
|
+
本技能基于 [agent-skill-npm-boilerplate](https://github.com/<your-username>/agent-skill-npm-boilerplate) 开发。
|
|
183
|
+
|
|
184
|
+
## 相关资源
|
|
185
|
+
|
|
186
|
+
- [Conventional Commits 规范](https://www.conventionalcommits.org/)
|
|
187
|
+
- [Conventional Commits 中文版](https://conventionalcommits.cn/)
|
|
188
|
+
- [Commitlint](https://commitlint.js.org/)
|
|
189
|
+
- [Claude Code 技能开发规范](https://github.com/<your-username>/agent-skills/tree/main/docs/skill-development-standard)
|
|
190
|
+
|
|
191
|
+
## 许可证
|
|
192
|
+
|
|
193
|
+
MIT License - 详见 [LICENSE](LICENSE) 文件
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: commit
|
|
3
|
+
description: 读取 Git 暂存区代码差异,自动生成符合 Conventional Commits 规范的提交信息。使用时说"提交"、"生成 commit message"或"创建提交"。
|
|
4
|
+
allowed-tools: Bash, Read
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Commit Skill
|
|
9
|
+
|
|
10
|
+
自动生成符合 Conventional Commits 规范的 Git 提交信息。
|
|
11
|
+
|
|
12
|
+
## 任务指令
|
|
13
|
+
|
|
14
|
+
当用户要求生成 Git 提交信息时:
|
|
15
|
+
|
|
16
|
+
1. **获取暂存区差异**
|
|
17
|
+
- 使用 `Bash` 工具执行 `git diff --staged`
|
|
18
|
+
- 如果暂存区为空,提示用户先使用 `git add` 添加文件
|
|
19
|
+
|
|
20
|
+
2. **分析代码变更**
|
|
21
|
+
- 分析变更的类型:feat(新功能)、fix(修复)、docs(文档)、style(格式)、refactor(重构)、test(测试)、chore(构建/工具)
|
|
22
|
+
- 识别变更的范围和影响
|
|
23
|
+
- 提取关键变更内容
|
|
24
|
+
|
|
25
|
+
3. **生成提交信息**
|
|
26
|
+
- 按照以下格式生成提交信息:
|
|
27
|
+
```
|
|
28
|
+
<type>(<scope>): <subject>
|
|
29
|
+
|
|
30
|
+
<body>
|
|
31
|
+
|
|
32
|
+
<footer>
|
|
33
|
+
```
|
|
34
|
+
- type: 变更类型(feat/fix/docs/style/refactor/test/chore)
|
|
35
|
+
- scope: 影响范围(可选)
|
|
36
|
+
- subject: 简短描述(使用中文,不超过 50 字符)
|
|
37
|
+
- body: 详细描述(可选,列出主要变更)
|
|
38
|
+
- footer: 关联信息(如 Closes #123)
|
|
39
|
+
|
|
40
|
+
4. **输出结果**
|
|
41
|
+
- 显示完整的提交信息
|
|
42
|
+
- 提示用户可以使用生成的提交信息
|
|
43
|
+
- 如果需要,解释选择的提交类型和原因
|
|
44
|
+
|
|
45
|
+
## Conventional Commits 类型参考
|
|
46
|
+
|
|
47
|
+
| 类型 | 说明 | 使用场景 |
|
|
48
|
+
|------|------|---------|
|
|
49
|
+
| `feat` | 新功能 | 添加新的功能或特性 |
|
|
50
|
+
| `fix` | 修复 bug | 修复问题或错误 |
|
|
51
|
+
| `docs` | 文档更新 | 修改文档或注释 |
|
|
52
|
+
| `style` | 代码格式 | 代码格式调整(不影响功能) |
|
|
53
|
+
| `refactor` | 重构 | 代码重构(不是新功能也不是修复) |
|
|
54
|
+
| `test` | 测试相关 | 添加或修改测试 |
|
|
55
|
+
| `chore` | 构建/工具 | 构建过程、工具链、依赖更新 |
|
|
56
|
+
|
|
57
|
+
## 示例
|
|
58
|
+
|
|
59
|
+
### 示例 1:新功能
|
|
60
|
+
|
|
61
|
+
**代码变更**: 添加用户登录功能
|
|
62
|
+
|
|
63
|
+
**生成提交信息**:
|
|
64
|
+
```
|
|
65
|
+
feat(auth): 添加用户登录功能
|
|
66
|
+
|
|
67
|
+
- 实现用户名密码登录
|
|
68
|
+
- 添加 JWT token 认证
|
|
69
|
+
- 支持记住登录状态
|
|
70
|
+
|
|
71
|
+
Closes #123
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 示例 2:修复 bug
|
|
75
|
+
|
|
76
|
+
**代码变更**: 修复登录页面错误提示显示问题
|
|
77
|
+
|
|
78
|
+
**生成提交信息**:
|
|
79
|
+
```
|
|
80
|
+
fix(auth): 修复登录错误提示不显示的问题
|
|
81
|
+
|
|
82
|
+
- 调整错误处理逻辑
|
|
83
|
+
- 优化错误信息展示
|
|
84
|
+
|
|
85
|
+
Fixes #124
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 示例 3:文档更新
|
|
89
|
+
|
|
90
|
+
**代码变更**: 更新 README.md
|
|
91
|
+
|
|
92
|
+
**生成提交信息**:
|
|
93
|
+
```
|
|
94
|
+
docs: 更新项目安装说明
|
|
95
|
+
|
|
96
|
+
- 添加依赖安装步骤
|
|
97
|
+
- 补充常见问题解答
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 最佳实践
|
|
101
|
+
|
|
102
|
+
1. **提交类型选择**
|
|
103
|
+
- 优先选择明确的类型(feat/fix)
|
|
104
|
+
- 避免使用模糊的 chore
|
|
105
|
+
- 同一次变更只使用一个主要类型
|
|
106
|
+
|
|
107
|
+
2. **subject 编写**
|
|
108
|
+
- 使用中文,简洁明了
|
|
109
|
+
- 不要超过 50 个字符
|
|
110
|
+
- 使用动词开头(添加、修复、更新等)
|
|
111
|
+
- 不要以句号结尾
|
|
112
|
+
|
|
113
|
+
3. **body 编写**
|
|
114
|
+
- 列举主要变更点
|
|
115
|
+
- 说明变更的原因和目的
|
|
116
|
+
- 每行一个变更点
|
|
117
|
+
|
|
118
|
+
4. **footer 使用**
|
|
119
|
+
- 关联 issue: `Closes #123` 或 `Fixes #123`
|
|
120
|
+
- 标注破坏性变更: `BREAKING CHANGE:`
|
|
121
|
+
- 引用相关 commit
|
|
122
|
+
|
|
123
|
+
## 技术说明
|
|
124
|
+
|
|
125
|
+
- **支持的 Git 命令**: `git diff --staged`, `git status`
|
|
126
|
+
- **输出格式**: Markdown
|
|
127
|
+
- **语言**: 中文
|
|
128
|
+
- **编码**: UTF-8
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@catcuts-skills/commit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "读取 staged 代码差异,自动生成符合 Conventional Commits 规范的提交文本",
|
|
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
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"SKILL.md",
|
|
15
|
+
"scripts/"
|
|
16
|
+
],
|
|
17
|
+
"optionalDependencies": {
|
|
18
|
+
"add-skill": "^1.0.29"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"claude-code",
|
|
22
|
+
"skill",
|
|
23
|
+
"git",
|
|
24
|
+
"commit",
|
|
25
|
+
"conventional-commits"
|
|
26
|
+
],
|
|
27
|
+
"author": "catcuts",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/catcuts/agent-skills.git",
|
|
32
|
+
"directory": "skills/commit"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/catcuts/agent-skills/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/catcuts/agent-skills#readme",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18.0.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Commit Skill Installation Script
|
|
5
|
+
* Install skill to Claude Code using add-skill
|
|
6
|
+
*
|
|
7
|
+
* Command Line Arguments (Recommended):
|
|
8
|
+
* --dry-run: Test mode, show command without executing
|
|
9
|
+
* --global: Force global installation
|
|
10
|
+
* --local: Force project-level installation
|
|
11
|
+
*
|
|
12
|
+
* Environment Variables (Fallback):
|
|
13
|
+
* - SKILL_SCOPE: Installation scope, GLOBAL or LOCAL, default: GLOBAL
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const { execSync } = require('child_process');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
|
|
19
|
+
// Get package root directory
|
|
20
|
+
const packageRoot = path.resolve(__dirname, '..');
|
|
21
|
+
|
|
22
|
+
// Read package.json to get skill name
|
|
23
|
+
const packageJson = require(path.join(packageRoot, 'package.json'));
|
|
24
|
+
const skillName = packageJson.name.split('/')[1] || packageJson.name;
|
|
25
|
+
|
|
26
|
+
// Parse command line arguments
|
|
27
|
+
const args = process.argv.slice(2);
|
|
28
|
+
const dryRun = args.includes('--dry-run');
|
|
29
|
+
const forceGlobal = args.includes('--global');
|
|
30
|
+
const forceLocal = args.includes('--local');
|
|
31
|
+
|
|
32
|
+
// Determine installation scope
|
|
33
|
+
let scope;
|
|
34
|
+
if (forceGlobal) {
|
|
35
|
+
scope = 'GLOBAL';
|
|
36
|
+
} else if (forceLocal) {
|
|
37
|
+
scope = 'LOCAL';
|
|
38
|
+
} else {
|
|
39
|
+
scope = (process.env.SKILL_SCOPE || 'GLOBAL').toUpperCase();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const isGlobal = scope === 'GLOBAL';
|
|
43
|
+
|
|
44
|
+
// Logging function
|
|
45
|
+
function log(message, type = 'info') {
|
|
46
|
+
const prefix = {
|
|
47
|
+
info: '✓',
|
|
48
|
+
success: '✓',
|
|
49
|
+
warning: '⚠',
|
|
50
|
+
error: '✗'
|
|
51
|
+
}[type] || '✓';
|
|
52
|
+
|
|
53
|
+
console.log(`${prefix} ${message}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Error handler
|
|
57
|
+
function handleError(error) {
|
|
58
|
+
log(`Installation failed: ${error.message}`, 'error');
|
|
59
|
+
log('\nYou can try manual installation:', 'warning');
|
|
60
|
+
log(` npx add-skill "${packageRoot}" -a claude-code ${isGlobal ? '-g' : ''} -y`);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
log(`Starting installation of ${skillName}...`, 'info');
|
|
66
|
+
log(`Installation scope: ${isGlobal ? 'Global (GLOBAL)' : 'Project-level (LOCAL)'}`, 'info');
|
|
67
|
+
|
|
68
|
+
// Build add-skill command
|
|
69
|
+
const commandParts = [
|
|
70
|
+
'npx',
|
|
71
|
+
'add-skill',
|
|
72
|
+
`"${packageRoot}"`,
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
if (isGlobal) {
|
|
76
|
+
commandParts.push('-g');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
commandParts.push('-y'); // Non-interactive mode
|
|
80
|
+
|
|
81
|
+
const command = commandParts.join(' ');
|
|
82
|
+
|
|
83
|
+
if (dryRun) {
|
|
84
|
+
log('\n[DRY-RUN] Command to be executed:', 'warning');
|
|
85
|
+
console.log(` ${command}`);
|
|
86
|
+
log('\nTest passed - For actual installation run: npm run install:global or npm run install:local', 'success');
|
|
87
|
+
process.exit(0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Execute installation
|
|
91
|
+
log('\nExecuting add-skill...', 'info');
|
|
92
|
+
execSync(command, {
|
|
93
|
+
stdio: 'inherit',
|
|
94
|
+
cwd: packageRoot
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
log('\nInstallation successful!', 'success');
|
|
98
|
+
log(`Skill installed to: ${isGlobal ? `~/.claude/skills/${skillName}` : `.claude/skills/${skillName}`}`, 'info');
|
|
99
|
+
|
|
100
|
+
} catch (error) {
|
|
101
|
+
handleError(error);
|
|
102
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Commit Skill Uninstallation Script
|
|
5
|
+
* Remove installed skill files
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const os = require('os');
|
|
11
|
+
|
|
12
|
+
// Get package root directory
|
|
13
|
+
const packageRoot = path.resolve(__dirname, '..');
|
|
14
|
+
|
|
15
|
+
// Read package.json to get skill name
|
|
16
|
+
const packageName = require(path.join(packageRoot, 'package.json')).name;
|
|
17
|
+
const skillName = packageName.split('/')[1] || packageName;
|
|
18
|
+
|
|
19
|
+
// Logging function
|
|
20
|
+
function log(message, type = 'info') {
|
|
21
|
+
const prefix = {
|
|
22
|
+
info: '✓',
|
|
23
|
+
success: '✓',
|
|
24
|
+
warning: '⚠',
|
|
25
|
+
error: '✗'
|
|
26
|
+
}[type] || '✓';
|
|
27
|
+
|
|
28
|
+
console.log(`${prefix} ${message}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Remove function
|
|
32
|
+
function removeSkill(dir, description) {
|
|
33
|
+
try {
|
|
34
|
+
if (fs.existsSync(dir)) {
|
|
35
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
36
|
+
log(`Removed ${description}: ${dir}`, 'success');
|
|
37
|
+
} else {
|
|
38
|
+
log(`${description} does not exist: ${dir}`, 'info');
|
|
39
|
+
}
|
|
40
|
+
} catch (error) {
|
|
41
|
+
log(`Failed to remove ${description}: ${error.message}`, 'error');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
log(`Starting uninstallation of ${skillName}...`, 'info');
|
|
47
|
+
|
|
48
|
+
// Remove global installation
|
|
49
|
+
const globalDir = path.join(os.homedir(), '.claude', 'skills', skillName);
|
|
50
|
+
removeSkill(globalDir, 'global installation');
|
|
51
|
+
|
|
52
|
+
// Remove project-level installation
|
|
53
|
+
const localDir = path.join(process.cwd(), '.claude', 'skills', skillName);
|
|
54
|
+
removeSkill(localDir, 'project-level installation');
|
|
55
|
+
|
|
56
|
+
// Remove actual storage directories (.agents/)
|
|
57
|
+
const globalAgentsDir = path.join(os.homedir(), '.agents', 'skills', skillName);
|
|
58
|
+
removeSkill(globalAgentsDir, 'global storage directory');
|
|
59
|
+
|
|
60
|
+
const localAgentsDir = path.join(process.cwd(), '.agents', 'skills', skillName);
|
|
61
|
+
removeSkill(localAgentsDir, 'project-level storage directory');
|
|
62
|
+
|
|
63
|
+
log('\nUninstallation completed!', 'success');
|
|
64
|
+
|
|
65
|
+
} catch (error) {
|
|
66
|
+
log(`Uninstallation failed: ${error.message}`, 'error');
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|