@catcuts-skills/commit 1.0.1 → 1.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@catcuts-skills/commit",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "读取 staged 代码差异,自动生成符合 Conventional Commits 规范的提交文本",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -34,7 +34,7 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/catcuts/agent-skills/issues"
36
36
  },
37
- "homepage": "https://github.com/catcuts/agent-skills#readme",
37
+ "homepage": "https://github.com/catcuts/agent-skills/tree/main/skills/commit#readme",
38
38
  "engines": {
39
39
  "node": ">=18.0.0"
40
40
  }
@@ -15,6 +15,7 @@
15
15
 
16
16
  const { execSync } = require('child_process');
17
17
  const path = require('path');
18
+ const { printUsageGuide } = require('./usage-guide');
18
19
 
19
20
  // Get package root directory
20
21
  const packageRoot = path.resolve(__dirname, '..');
@@ -97,6 +98,9 @@ try {
97
98
  log('\nInstallation successful!', 'success');
98
99
  log(`Skill installed to: ${isGlobal ? `~/.claude/skills/${skillName}` : `.claude/skills/${skillName}`}`, 'info');
99
100
 
101
+ // 显示使用指南
102
+ printUsageGuide();
103
+
100
104
  } catch (error) {
101
105
  handleError(error);
102
106
  }
@@ -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 };