sdd-full 1.2.1 → 1.3.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.
Files changed (2) hide show
  1. package/index.js +61 -48
  2. package/package.json +4 -2
package/index.js CHANGED
@@ -8,7 +8,7 @@ const path = require('path');
8
8
 
9
9
  // 技能包的主入口
10
10
  const SDD = {
11
- version: '1.2.1',
11
+ version: '1.3.0',
12
12
  name: 'sdd-full',
13
13
  description: '完整的软件设计开发技能包',
14
14
 
@@ -17,7 +17,6 @@ const SDD = {
17
17
  const skillsDir = path.join(__dirname, 'skills');
18
18
  const skills = [];
19
19
 
20
- // 检查目录是否存在
21
20
  if (fs.existsSync(skillsDir)) {
22
21
  const items = fs.readdirSync(skillsDir);
23
22
 
@@ -25,7 +24,6 @@ const SDD = {
25
24
  const itemPath = path.join(skillsDir, item);
26
25
  const stat = fs.statSync(itemPath);
27
26
 
28
- // 只处理目录(技能),排除 .md 文件
29
27
  if (stat.isDirectory() && !item.endsWith('.md')) {
30
28
  const skillPath = path.join(itemPath, 'SKILL.md');
31
29
  if (fs.existsSync(skillPath)) {
@@ -71,50 +69,68 @@ const SDD = {
71
69
  return null;
72
70
  },
73
71
 
74
- // 安装技能到当前目录
72
+ // 安装技能到当前目录(适配 trae-cn 和 claude code)
75
73
  install: function(targetDir) {
76
- const destDir = path.join(targetDir || process.cwd(), '.sdd-full', 'skills');
77
- const sourceDir = path.join(__dirname, 'skills');
74
+ const baseDir = targetDir || process.cwd();
78
75
 
79
76
  console.log('========================================');
80
77
  console.log(` ${SDD.name} - ${SDD.description}`);
81
78
  console.log(` 版本: ${SDD.version}`);
82
79
  console.log('========================================');
83
- console.log(`\n正在安装技能到: ${destDir}`);
84
80
 
85
- // 确保目标目录存在
86
- if (!fs.existsSync(destDir)) {
87
- fs.mkdirSync(destDir, { recursive: true });
88
- }
81
+ const sourceDir = path.join(__dirname, 'skills');
82
+
83
+ // 定义要安装的目录位置(支持多种环境)
84
+ const dirsToInstall = [
85
+ { name: 'Trae-cn / Solo', path: path.join(baseDir, '.trae-cn', 'skills') },
86
+ { name: 'Claude Code', path: path.join(baseDir, '.claude', 'skills') },
87
+ { name: '通用 sdd-full', path: path.join(baseDir, '.sdd-full', 'skills') }
88
+ ];
89
89
 
90
- // 复制所有技能文件
91
- let count = 0;
92
- if (fs.existsSync(sourceDir)) {
93
- const items = fs.readdirSync(sourceDir);
90
+ let totalCount = 0;
91
+
92
+ dirsToInstall.forEach(dirInfo => {
93
+ const destDir = dirInfo.path;
94
94
 
95
- items.forEach(item => {
96
- const srcItem = path.join(sourceDir, item);
97
- const destItem = path.join(destDir, item);
98
- const stat = fs.statSync(srcItem);
95
+ console.log(`\n正在安装到: ${dirInfo.name} (${destDir})`);
96
+
97
+ if (!fs.existsSync(destDir)) {
98
+ fs.mkdirSync(destDir, { recursive: true });
99
+ }
100
+
101
+ let count = 0;
102
+ if (fs.existsSync(sourceDir)) {
103
+ const items = fs.readdirSync(sourceDir);
99
104
 
100
- if (stat.isDirectory()) {
101
- // 复制目录(技能)
102
- copyDirectory(srcItem, destItem);
103
- count++;
104
- } else if (stat.isFile() && item.endsWith('.md')) {
105
- // 复制文档文件
106
- fs.copyFileSync(srcItem, destItem);
107
- }
108
- });
109
- }
105
+ items.forEach(item => {
106
+ const srcItem = path.join(sourceDir, item);
107
+ const destItem = path.join(destDir, item);
108
+ const stat = fs.statSync(srcItem);
109
+
110
+ if (stat.isDirectory()) {
111
+ copyDirectory(srcItem, destItem);
112
+ count++;
113
+ } else if (stat.isFile() && item.endsWith('.md')) {
114
+ fs.copyFileSync(srcItem, destItem);
115
+ }
116
+ });
117
+ }
118
+
119
+ totalCount += count;
120
+ console.log(` ✅ ${count} 个技能`);
121
+ });
110
122
 
111
- console.log(`\n✅ 成功安装 ${count} 个技能!`);
112
- console.log(`\n技能目录: ${destDir}`);
113
- console.log('\n您现在可以在支持技能的环境中使用这些技能了!\n');
123
+ console.log('\n========================================');
124
+ console.log(`✅ 安装完成!共安装 ${totalCount} 个技能!`);
125
+ console.log('========================================');
126
+ console.log('\n现在您可以在以下环境中使用这些技能:');
127
+ dirsToInstall.forEach(dirInfo => {
128
+ console.log(` - ${dirInfo.name}`);
129
+ });
130
+ console.log('\n🎉 开始使用吧!\n');
114
131
  }
115
132
  };
116
133
 
117
- // 复制目录的辅助函数
118
134
  function copyDirectory(src, dest) {
119
135
  if (!fs.existsSync(dest)) {
120
136
  fs.mkdirSync(dest, { recursive: true });
@@ -134,32 +150,22 @@ function copyDirectory(src, dest) {
134
150
  });
135
151
  }
136
152
 
137
- // 导出模块
138
153
  module.exports = SDD;
139
154
 
140
- // 如果直接运行,显示版本和技能列表或安装
141
155
  if (require.main === module) {
142
156
  const args = process.argv.slice(2);
143
157
 
144
- if (args.includes('install') || args.includes('i')) {
145
- // 安装模式
146
- const targetIndex = args.indexOf('--dir') || args.indexOf('-d');
147
- let targetDir;
148
- if (targetIndex !== -1 && args[targetIndex + 1]) {
149
- targetDir = args[targetIndex + 1];
150
- }
151
- SDD.install(targetDir);
152
- } else {
153
- // 默认显示模式
158
+ if (args.includes('--help') || args.includes('-h')) {
154
159
  console.log('========================================');
155
160
  console.log(` ${SDD.name} - ${SDD.description}`);
156
161
  console.log(` 版本: ${SDD.version}`);
157
162
  console.log('========================================');
158
163
  console.log('\n用法:');
159
- console.log(' npx sdd-full - 显示帮助和技能列表');
160
- console.log(' npx sdd-full install - 安装技能到当前目录');
164
+ console.log(' npx sdd-full - 安装技能(默认)');
165
+ console.log(' npx sdd-full install - 安装技能');
161
166
  console.log(' npx sdd-full i - 安装技能(简写)');
162
- console.log(' npx sdd-full install --dir ./my-project - 安装到指定目录');
167
+ console.log(' npx sdd-full --help - 显示帮助');
168
+ console.log(' npx sdd-full --dir ./myproj - 安装到指定目录');
163
169
 
164
170
  const skills = SDD.getSkills();
165
171
  console.log('\n可用技能:');
@@ -168,5 +174,12 @@ if (require.main === module) {
168
174
  });
169
175
 
170
176
  console.log(`\n总计 ${skills.length} 个技能\n`);
177
+ } else {
178
+ let targetDir;
179
+ const targetIndex = args.indexOf('--dir') || args.indexOf('-d');
180
+ if (targetIndex !== -1 && args[targetIndex + 1]) {
181
+ targetDir = args[targetIndex + 1];
182
+ }
183
+ SDD.install(targetDir);
171
184
  }
172
185
  }
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "sdd-full",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "SDD Full - 完整的软件设计开发技能包",
5
5
  "main": "index.js",
6
- "bin": "index.js",
6
+ "bin": {
7
+ "sdd-full": "./index.js"
8
+ },
7
9
  "keywords": [
8
10
  "sdd",
9
11
  "software design",