sdd-full 1.2.2 → 1.4.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/index.js +85 -49
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const path = require('path');
|
|
|
8
8
|
|
|
9
9
|
// 技能包的主入口
|
|
10
10
|
const SDD = {
|
|
11
|
-
version: '1.
|
|
11
|
+
version: '1.4.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,81 @@ const SDD = {
|
|
|
71
69
|
return null;
|
|
72
70
|
},
|
|
73
71
|
|
|
74
|
-
//
|
|
75
|
-
install: function(targetDir) {
|
|
76
|
-
const
|
|
77
|
-
const sourceDir = path.join(__dirname, 'skills');
|
|
72
|
+
// 安装技能到指定环境
|
|
73
|
+
install: function(targetDir, environment) {
|
|
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
|
-
|
|
87
|
-
|
|
81
|
+
const sourceDir = path.join(__dirname, 'skills');
|
|
82
|
+
|
|
83
|
+
// 根据环境选择安装目录
|
|
84
|
+
let dirsToInstall;
|
|
85
|
+
|
|
86
|
+
if (environment === 'cc') {
|
|
87
|
+
dirsToInstall = [
|
|
88
|
+
{ name: 'Claude Code', path: path.join(baseDir, '.claude', 'skills') }
|
|
89
|
+
];
|
|
90
|
+
} else if (environment === 'all') {
|
|
91
|
+
dirsToInstall = [
|
|
92
|
+
{ name: 'Trae-cn / Solo', path: path.join(baseDir, '.trae-cn', 'skills') },
|
|
93
|
+
{ name: 'Claude Code', path: path.join(baseDir, '.claude', 'skills') },
|
|
94
|
+
{ name: '通用 sdd-full', path: path.join(baseDir, '.sdd-full', 'skills') }
|
|
95
|
+
];
|
|
96
|
+
} else {
|
|
97
|
+
// 默认:Trae-cn / Solo
|
|
98
|
+
dirsToInstall = [
|
|
99
|
+
{ name: 'Trae-cn / Solo', path: path.join(baseDir, '.trae-cn', 'skills') }
|
|
100
|
+
];
|
|
88
101
|
}
|
|
89
102
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const
|
|
103
|
+
let totalCount = 0;
|
|
104
|
+
|
|
105
|
+
dirsToInstall.forEach(dirInfo => {
|
|
106
|
+
const destDir = dirInfo.path;
|
|
94
107
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
console.log(`\n正在安装到: ${dirInfo.name} (${destDir})`);
|
|
109
|
+
|
|
110
|
+
if (!fs.existsSync(destDir)) {
|
|
111
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let count = 0;
|
|
115
|
+
if (fs.existsSync(sourceDir)) {
|
|
116
|
+
const items = fs.readdirSync(sourceDir);
|
|
99
117
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
items.forEach(item => {
|
|
119
|
+
const srcItem = path.join(sourceDir, item);
|
|
120
|
+
const destItem = path.join(destDir, item);
|
|
121
|
+
const stat = fs.statSync(srcItem);
|
|
122
|
+
|
|
123
|
+
if (stat.isDirectory()) {
|
|
124
|
+
copyDirectory(srcItem, destItem);
|
|
125
|
+
count++;
|
|
126
|
+
} else if (stat.isFile() && item.endsWith('.md')) {
|
|
127
|
+
fs.copyFileSync(srcItem, destItem);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
totalCount += count;
|
|
133
|
+
console.log(` ✅ ${count} 个技能`);
|
|
134
|
+
});
|
|
110
135
|
|
|
111
|
-
console.log(
|
|
112
|
-
console.log(
|
|
113
|
-
console.log('
|
|
136
|
+
console.log('\n========================================');
|
|
137
|
+
console.log(`✅ 安装完成!共安装 ${totalCount} 个技能!`);
|
|
138
|
+
console.log('========================================');
|
|
139
|
+
console.log('\n现在您可以在以下环境中使用这些技能:');
|
|
140
|
+
dirsToInstall.forEach(dirInfo => {
|
|
141
|
+
console.log(` - ${dirInfo.name}`);
|
|
142
|
+
});
|
|
143
|
+
console.log('\n🎉 开始使用吧!\n');
|
|
114
144
|
}
|
|
115
145
|
};
|
|
116
146
|
|
|
117
|
-
// 复制目录的辅助函数
|
|
118
147
|
function copyDirectory(src, dest) {
|
|
119
148
|
if (!fs.existsSync(dest)) {
|
|
120
149
|
fs.mkdirSync(dest, { recursive: true });
|
|
@@ -134,32 +163,22 @@ function copyDirectory(src, dest) {
|
|
|
134
163
|
});
|
|
135
164
|
}
|
|
136
165
|
|
|
137
|
-
// 导出模块
|
|
138
166
|
module.exports = SDD;
|
|
139
167
|
|
|
140
|
-
// 如果直接运行,显示版本和技能列表或安装
|
|
141
168
|
if (require.main === module) {
|
|
142
169
|
const args = process.argv.slice(2);
|
|
143
170
|
|
|
144
|
-
if (args.includes('
|
|
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
|
-
// 默认显示模式
|
|
171
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
154
172
|
console.log('========================================');
|
|
155
173
|
console.log(` ${SDD.name} - ${SDD.description}`);
|
|
156
174
|
console.log(` 版本: ${SDD.version}`);
|
|
157
175
|
console.log('========================================');
|
|
158
176
|
console.log('\n用法:');
|
|
159
|
-
console.log(' npx sdd-full -
|
|
160
|
-
console.log(' npx sdd-full
|
|
161
|
-
console.log(' npx sdd-full
|
|
162
|
-
console.log(' npx sdd-full
|
|
177
|
+
console.log(' npx sdd-full - 安装到 Trae-cn / Solo(默认)');
|
|
178
|
+
console.log(' npx sdd-full cc - 安装到 Claude Code');
|
|
179
|
+
console.log(' npx sdd-full all - 安装到所有环境');
|
|
180
|
+
console.log(' npx sdd-full --help - 显示帮助');
|
|
181
|
+
console.log(' npx sdd-full --dir ./myproj - 安装到指定目录');
|
|
163
182
|
|
|
164
183
|
const skills = SDD.getSkills();
|
|
165
184
|
console.log('\n可用技能:');
|
|
@@ -168,5 +187,22 @@ if (require.main === module) {
|
|
|
168
187
|
});
|
|
169
188
|
|
|
170
189
|
console.log(`\n总计 ${skills.length} 个技能\n`);
|
|
190
|
+
} else {
|
|
191
|
+
let targetDir;
|
|
192
|
+
const targetIndex = args.indexOf('--dir') || args.indexOf('-d');
|
|
193
|
+
if (targetIndex !== -1 && args[targetIndex + 1]) {
|
|
194
|
+
targetDir = args[targetIndex + 1];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
let environment;
|
|
198
|
+
if (args.includes('cc')) {
|
|
199
|
+
environment = 'cc';
|
|
200
|
+
} else if (args.includes('all')) {
|
|
201
|
+
environment = 'all';
|
|
202
|
+
} else {
|
|
203
|
+
environment = 'trae'; // 默认
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
SDD.install(targetDir, environment);
|
|
171
207
|
}
|
|
172
208
|
}
|