sdd-full 1.4.1 → 1.5.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/bin.js +180 -0
- package/index.js +12 -5
- package/package.json +4 -5
package/bin.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// sdd-full npm 包 CLI 入口
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const SDD = {
|
|
9
|
+
version: '1.5.0',
|
|
10
|
+
name: 'sdd-full',
|
|
11
|
+
description: '完整的软件设计开发技能包'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function copyDirectory(src, dest) {
|
|
15
|
+
if (!fs.existsSync(dest)) {
|
|
16
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const items = fs.readdirSync(src);
|
|
20
|
+
items.forEach(item => {
|
|
21
|
+
const srcPath = path.join(src, item);
|
|
22
|
+
const destPath = path.join(dest, item);
|
|
23
|
+
const stat = fs.statSync(srcPath);
|
|
24
|
+
|
|
25
|
+
if (stat.isDirectory()) {
|
|
26
|
+
copyDirectory(srcPath, destPath);
|
|
27
|
+
} else {
|
|
28
|
+
fs.copyFileSync(srcPath, destPath);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getSkills() {
|
|
34
|
+
const skillsDir = path.join(__dirname, 'skills');
|
|
35
|
+
const skills = [];
|
|
36
|
+
|
|
37
|
+
if (fs.existsSync(skillsDir)) {
|
|
38
|
+
const items = fs.readdirSync(skillsDir);
|
|
39
|
+
|
|
40
|
+
items.forEach(item => {
|
|
41
|
+
const itemPath = path.join(skillsDir, item);
|
|
42
|
+
const stat = fs.statSync(itemPath);
|
|
43
|
+
|
|
44
|
+
if (stat.isDirectory() && !item.endsWith('.md')) {
|
|
45
|
+
const skillPath = path.join(itemPath, 'SKILL.md');
|
|
46
|
+
if (fs.existsSync(skillPath)) {
|
|
47
|
+
skills.push(item);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return skills;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function install(targetDir, environment) {
|
|
57
|
+
const baseDir = targetDir || process.cwd();
|
|
58
|
+
|
|
59
|
+
console.log('========================================');
|
|
60
|
+
console.log(` ${SDD.name} - ${SDD.description}`);
|
|
61
|
+
console.log(` 版本: ${SDD.version}`);
|
|
62
|
+
console.log('========================================');
|
|
63
|
+
|
|
64
|
+
const sourceDir = path.join(__dirname, 'skills');
|
|
65
|
+
|
|
66
|
+
// 根据环境选择安装目录
|
|
67
|
+
let dirsToInstall;
|
|
68
|
+
|
|
69
|
+
if (environment === 'cc') {
|
|
70
|
+
dirsToInstall = [
|
|
71
|
+
{ name: 'Claude Code', path: path.join(baseDir, '.claude', 'skills') }
|
|
72
|
+
];
|
|
73
|
+
} else if (environment === 'all') {
|
|
74
|
+
dirsToInstall = [
|
|
75
|
+
{ name: 'Trae / Solo', path: path.join(baseDir, '.trae', 'skills') },
|
|
76
|
+
{ name: 'Claude Code', path: path.join(baseDir, '.claude', 'skills') },
|
|
77
|
+
{ name: '通用 sdd-full', path: path.join(baseDir, '.sdd-full', 'skills') }
|
|
78
|
+
];
|
|
79
|
+
} else {
|
|
80
|
+
// 默认:Trae / Solo
|
|
81
|
+
dirsToInstall = [
|
|
82
|
+
{ name: 'Trae / Solo', path: path.join(baseDir, '.trae', 'skills') }
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let totalCount = 0;
|
|
87
|
+
|
|
88
|
+
dirsToInstall.forEach(dirInfo => {
|
|
89
|
+
const destDir = dirInfo.path;
|
|
90
|
+
|
|
91
|
+
console.log(`\n正在安装到: ${dirInfo.name} (${destDir})`);
|
|
92
|
+
|
|
93
|
+
if (!fs.existsSync(destDir)) {
|
|
94
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let count = 0;
|
|
98
|
+
if (fs.existsSync(sourceDir)) {
|
|
99
|
+
const items = fs.readdirSync(sourceDir);
|
|
100
|
+
|
|
101
|
+
items.forEach(item => {
|
|
102
|
+
const srcItem = path.join(sourceDir, item);
|
|
103
|
+
const destItem = path.join(destDir, item);
|
|
104
|
+
const stat = fs.statSync(srcItem);
|
|
105
|
+
|
|
106
|
+
if (stat.isDirectory()) {
|
|
107
|
+
copyDirectory(srcItem, destItem);
|
|
108
|
+
count++;
|
|
109
|
+
} else if (stat.isFile() && item.endsWith('.md')) {
|
|
110
|
+
fs.copyFileSync(srcItem, destItem);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
totalCount += count;
|
|
116
|
+
console.log(` ✅ ${count} 个技能`);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
console.log('\n========================================');
|
|
120
|
+
console.log(`✅ 安装完成!共安装 ${totalCount} 个技能!`);
|
|
121
|
+
console.log('========================================');
|
|
122
|
+
console.log('\n现在您可以在以下环境中使用这些技能:');
|
|
123
|
+
dirsToInstall.forEach(dirInfo => {
|
|
124
|
+
console.log(` - ${dirInfo.name}`);
|
|
125
|
+
});
|
|
126
|
+
console.log('\n🎉 开始使用吧!\n');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// 主入口
|
|
130
|
+
function main() {
|
|
131
|
+
const args = process.argv.slice(2);
|
|
132
|
+
|
|
133
|
+
// 检查是否需要显示帮助
|
|
134
|
+
const showHelp = args.some(arg => arg === '--help' || arg === '-h');
|
|
135
|
+
|
|
136
|
+
if (showHelp) {
|
|
137
|
+
console.log('========================================');
|
|
138
|
+
console.log(` ${SDD.name} - ${SDD.description}`);
|
|
139
|
+
console.log(` 版本: ${SDD.version}`);
|
|
140
|
+
console.log('========================================');
|
|
141
|
+
console.log('\n用法:');
|
|
142
|
+
console.log(' npx sdd-full - 安装到 Trae / Solo(默认)');
|
|
143
|
+
console.log(' npx sdd-full cc - 安装到 Claude Code');
|
|
144
|
+
console.log(' npx sdd-full all - 安装到所有环境');
|
|
145
|
+
console.log(' npx sdd-full --help - 显示帮助');
|
|
146
|
+
console.log(' npx sdd-full --dir ./myproj - 安装到指定目录');
|
|
147
|
+
|
|
148
|
+
const skills = getSkills();
|
|
149
|
+
console.log('\n可用技能:');
|
|
150
|
+
skills.forEach(skill => {
|
|
151
|
+
console.log(` - ${skill}`);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
console.log(`\n总计 ${skills.length} 个技能\n`);
|
|
155
|
+
} else {
|
|
156
|
+
// 否则,直接安装
|
|
157
|
+
let targetDir;
|
|
158
|
+
const targetIndex = args.indexOf('--dir');
|
|
159
|
+
const targetIndexShort = args.indexOf('-d');
|
|
160
|
+
if (targetIndex !== -1 && args[targetIndex + 1]) {
|
|
161
|
+
targetDir = args[targetIndex + 1];
|
|
162
|
+
} else if (targetIndexShort !== -1 && args[targetIndexShort + 1]) {
|
|
163
|
+
targetDir = args[targetIndexShort + 1];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
let environment;
|
|
167
|
+
if (args.indexOf('cc') !== -1) {
|
|
168
|
+
environment = 'cc';
|
|
169
|
+
} else if (args.indexOf('all') !== -1) {
|
|
170
|
+
environment = 'all';
|
|
171
|
+
} else {
|
|
172
|
+
environment = 'trae'; // 默认
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
install(targetDir, environment);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// 运行主函数
|
|
180
|
+
main();
|
package/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const path = require('path');
|
|
|
8
8
|
|
|
9
9
|
// 技能包的主入口
|
|
10
10
|
const SDD = {
|
|
11
|
-
version: '1.4.
|
|
11
|
+
version: '1.4.3',
|
|
12
12
|
name: 'sdd-full',
|
|
13
13
|
description: '完整的软件设计开发技能包',
|
|
14
14
|
|
|
@@ -168,7 +168,10 @@ module.exports = SDD;
|
|
|
168
168
|
if (require.main === module) {
|
|
169
169
|
const args = process.argv.slice(2);
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
// 检查是否需要显示帮助
|
|
172
|
+
const showHelp = args.some(arg => arg === '--help' || arg === '-h');
|
|
173
|
+
|
|
174
|
+
if (showHelp) {
|
|
172
175
|
console.log('========================================');
|
|
173
176
|
console.log(` ${SDD.name} - ${SDD.description}`);
|
|
174
177
|
console.log(` 版本: ${SDD.version}`);
|
|
@@ -188,16 +191,20 @@ if (require.main === module) {
|
|
|
188
191
|
|
|
189
192
|
console.log(`\n总计 ${skills.length} 个技能\n`);
|
|
190
193
|
} else {
|
|
194
|
+
// 否则,直接安装
|
|
191
195
|
let targetDir;
|
|
192
|
-
const targetIndex = args.indexOf('--dir')
|
|
196
|
+
const targetIndex = args.indexOf('--dir');
|
|
197
|
+
const targetIndexShort = args.indexOf('-d');
|
|
193
198
|
if (targetIndex !== -1 && args[targetIndex + 1]) {
|
|
194
199
|
targetDir = args[targetIndex + 1];
|
|
200
|
+
} else if (targetIndexShort !== -1 && args[targetIndexShort + 1]) {
|
|
201
|
+
targetDir = args[targetIndexShort + 1];
|
|
195
202
|
}
|
|
196
203
|
|
|
197
204
|
let environment;
|
|
198
|
-
if (args.
|
|
205
|
+
if (args.indexOf('cc') !== -1) {
|
|
199
206
|
environment = 'cc';
|
|
200
|
-
} else if (args.
|
|
207
|
+
} else if (args.indexOf('all') !== -1) {
|
|
201
208
|
environment = 'all';
|
|
202
209
|
} else {
|
|
203
210
|
environment = 'trae'; // 默认
|
package/package.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdd-full",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "SDD Full - 完整的软件设计开发技能包",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"bin":
|
|
7
|
-
"sdd-full": "./index.js"
|
|
8
|
-
},
|
|
6
|
+
"bin": "./bin.js",
|
|
9
7
|
"keywords": [
|
|
10
8
|
"sdd",
|
|
11
9
|
"software design",
|
|
@@ -17,9 +15,10 @@
|
|
|
17
15
|
"license": "MIT",
|
|
18
16
|
"scripts": {
|
|
19
17
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
20
|
-
"start": "node
|
|
18
|
+
"start": "node bin.js"
|
|
21
19
|
},
|
|
22
20
|
"files": [
|
|
21
|
+
"bin.js",
|
|
23
22
|
"index.js",
|
|
24
23
|
"package.json",
|
|
25
24
|
"README.md",
|