6aspec 2.0.0-dev.10

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 (110) hide show
  1. package/.6aspec/rules/biz/api_rule.md +578 -0
  2. package/.6aspec/rules/biz/background_job_rule.md +719 -0
  3. package/.6aspec/rules/biz/c_user_system_rule.md +240 -0
  4. package/.6aspec/rules/biz/code.md +39 -0
  5. package/.6aspec/rules/biz/event_subscriber_rule.md +529 -0
  6. package/.6aspec/rules/biz/project-structure.md +90 -0
  7. package/.6aspec/rules/biz/scheduled_job_rule.md +850 -0
  8. package/.6aspec/rules/brown/brown_archive_sop.md +132 -0
  9. package/.6aspec/rules/brown/brown_constitution.md +20 -0
  10. package/.6aspec/rules/brown/brown_continue_sop.md +97 -0
  11. package/.6aspec/rules/brown/brown_design_sop.md +155 -0
  12. package/.6aspec/rules/brown/brown_ff_sop.md +194 -0
  13. package/.6aspec/rules/brown/brown_impact_sop.md +293 -0
  14. package/.6aspec/rules/brown/brown_implement_sop.md +133 -0
  15. package/.6aspec/rules/brown/brown_list_sop.md +69 -0
  16. package/.6aspec/rules/brown/brown_new_sop.md +257 -0
  17. package/.6aspec/rules/brown/brown_proposal_sop.md +160 -0
  18. package/.6aspec/rules/brown/brown_quick_sop.md +134 -0
  19. package/.6aspec/rules/brown/brown_review_sop.md +270 -0
  20. package/.6aspec/rules/brown/brown_rollback_sop.md +188 -0
  21. package/.6aspec/rules/brown/brown_specs_sop.md +228 -0
  22. package/.6aspec/rules/brown/brown_status_sop.md +135 -0
  23. package/.6aspec/rules/brown/brown_tasks_sop.md +202 -0
  24. package/.6aspec/rules/brown/brown_understand_sop.md +208 -0
  25. package/.6aspec/rules/brown/brown_verify_sop.md +360 -0
  26. package/.6aspec/rules/green/6A_archive_sop.md +301 -0
  27. package/.6aspec/rules/green/6A_clarify_sop.md +238 -0
  28. package/.6aspec/rules/green/6A_code_implementation_sop.md +110 -0
  29. package/.6aspec/rules/green/6A_constitution.md +52 -0
  30. package/.6aspec/rules/green/6A_continue_sop.md +186 -0
  31. package/.6aspec/rules/green/6A_design_sop.md +228 -0
  32. package/.6aspec/rules/green/6A_import_model_table_sop.md +120 -0
  33. package/.6aspec/rules/green/6A_init_event_list_sop.md +62 -0
  34. package/.6aspec/rules/green/6A_init_map_sop.md +79 -0
  35. package/.6aspec/rules/green/6A_model_sop.md +210 -0
  36. package/.6aspec/rules/green/6A_new_sop.md +319 -0
  37. package/.6aspec/rules/green/6A_rollback_sop.md +198 -0
  38. package/.6aspec/rules/green/6A_status_sop.md +275 -0
  39. package/.6aspec/rules/green/6A_tasks_sop.md +181 -0
  40. package/.6aspec/rules/green/6A_visual_logic_sop.md +121 -0
  41. package/.6aspec/rules/green/green_status_schema.md +293 -0
  42. package/.6aspec/script/create_entities_from_markdown.py +688 -0
  43. package/.claude/commands/6aspec/brown/archive.md +11 -0
  44. package/.claude/commands/6aspec/brown/continue.md +11 -0
  45. package/.claude/commands/6aspec/brown/design.md +11 -0
  46. package/.claude/commands/6aspec/brown/ff.md +11 -0
  47. package/.claude/commands/6aspec/brown/impact.md +11 -0
  48. package/.claude/commands/6aspec/brown/implement.md +11 -0
  49. package/.claude/commands/6aspec/brown/list.md +11 -0
  50. package/.claude/commands/6aspec/brown/new.md +11 -0
  51. package/.claude/commands/6aspec/brown/proposal.md +11 -0
  52. package/.claude/commands/6aspec/brown/quick.md +11 -0
  53. package/.claude/commands/6aspec/brown/review.md +11 -0
  54. package/.claude/commands/6aspec/brown/rollback.md +11 -0
  55. package/.claude/commands/6aspec/brown/specs.md +11 -0
  56. package/.claude/commands/6aspec/brown/status.md +11 -0
  57. package/.claude/commands/6aspec/brown/tasks.md +11 -0
  58. package/.claude/commands/6aspec/brown/understand.md +11 -0
  59. package/.claude/commands/6aspec/brown/verify.md +11 -0
  60. package/.claude/commands/6aspec/green/archive.md +8 -0
  61. package/.claude/commands/6aspec/green/clarify.md +13 -0
  62. package/.claude/commands/6aspec/green/continue.md +8 -0
  63. package/.claude/commands/6aspec/green/design.md +8 -0
  64. package/.claude/commands/6aspec/green/execute-task.md +20 -0
  65. package/.claude/commands/6aspec/green/import-model-table.md +8 -0
  66. package/.claude/commands/6aspec/green/init.md +14 -0
  67. package/.claude/commands/6aspec/green/model.md +12 -0
  68. package/.claude/commands/6aspec/green/new.md +13 -0
  69. package/.claude/commands/6aspec/green/rollback.md +8 -0
  70. package/.claude/commands/6aspec/green/status.md +8 -0
  71. package/.claude/commands/6aspec/green/tasks.md +8 -0
  72. package/.claude/commands/6aspec/green/visual-logic.md +9 -0
  73. package/.claude/settings.local.json +8 -0
  74. package/.cursor/commands/6aspec/brown/archive.md +9 -0
  75. package/.cursor/commands/6aspec/brown/continue.md +9 -0
  76. package/.cursor/commands/6aspec/brown/design.md +9 -0
  77. package/.cursor/commands/6aspec/brown/ff.md +9 -0
  78. package/.cursor/commands/6aspec/brown/impact.md +9 -0
  79. package/.cursor/commands/6aspec/brown/implement.md +9 -0
  80. package/.cursor/commands/6aspec/brown/list.md +9 -0
  81. package/.cursor/commands/6aspec/brown/new.md +9 -0
  82. package/.cursor/commands/6aspec/brown/proposal.md +9 -0
  83. package/.cursor/commands/6aspec/brown/quick.md +9 -0
  84. package/.cursor/commands/6aspec/brown/review.md +9 -0
  85. package/.cursor/commands/6aspec/brown/rollback.md +9 -0
  86. package/.cursor/commands/6aspec/brown/specs.md +9 -0
  87. package/.cursor/commands/6aspec/brown/status.md +9 -0
  88. package/.cursor/commands/6aspec/brown/tasks.md +9 -0
  89. package/.cursor/commands/6aspec/brown/understand.md +9 -0
  90. package/.cursor/commands/6aspec/brown/verify.md +9 -0
  91. package/.cursor/commands/6aspec/green/archive.md +9 -0
  92. package/.cursor/commands/6aspec/green/clarify.md +14 -0
  93. package/.cursor/commands/6aspec/green/continue.md +9 -0
  94. package/.cursor/commands/6aspec/green/design.md +9 -0
  95. package/.cursor/commands/6aspec/green/execute-task.md +21 -0
  96. package/.cursor/commands/6aspec/green/import-model-table.md +9 -0
  97. package/.cursor/commands/6aspec/green/init.md +15 -0
  98. package/.cursor/commands/6aspec/green/model.md +13 -0
  99. package/.cursor/commands/6aspec/green/new.md +14 -0
  100. package/.cursor/commands/6aspec/green/rollback.md +9 -0
  101. package/.cursor/commands/6aspec/green/status.md +9 -0
  102. package/.cursor/commands/6aspec/green/tasks.md +9 -0
  103. package/.cursor/commands/6aspec/green/visual-logic.md +10 -0
  104. package/README.en.md +36 -0
  105. package/README.md +146 -0
  106. package/bin/6a-spec-install +54 -0
  107. package/bin/6aspec +64 -0
  108. package/lib/cli.js +451 -0
  109. package/lib/installer.js +333 -0
  110. package/package.json +62 -0
@@ -0,0 +1,333 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ class Installer {
5
+ constructor() {
6
+ // 获取包目录(安装后)
7
+ this.packageDir = this.findPackageDir();
8
+ this.targetDir = process.cwd();
9
+ this.mergeMode = false; // 合并模式标志
10
+ }
11
+
12
+ // 查找包目录(支持本地开发和 npm 安装)
13
+ findPackageDir() {
14
+ // 如果是本地开发,直接使用当前目录
15
+ if (fs.existsSync(path.join(__dirname, '../.6aspec')) ||
16
+ fs.existsSync(path.join(__dirname, '../.cursor'))) {
17
+ return path.join(__dirname, '..');
18
+ }
19
+
20
+ // 如果是 npm 安装,查找 node_modules
21
+ let current = __dirname;
22
+ while (current !== path.dirname(current)) {
23
+ const sixaspecPath = path.join(current, '.6aspec');
24
+ const cursorPath = path.join(current, '.cursor');
25
+ if (fs.existsSync(sixaspecPath) || fs.existsSync(cursorPath)) {
26
+ return current;
27
+ }
28
+ current = path.dirname(current);
29
+ }
30
+
31
+ throw new Error('未找到 .6aspec 或 .cursor 目录,请确保包已正确安装');
32
+ }
33
+
34
+ // 颜色输出
35
+ log(message, type = 'info') {
36
+ const colors = {
37
+ info: '\x1b[32m[INFO]\x1b[0m',
38
+ warn: '\x1b[33m[WARN]\x1b[0m',
39
+ error: '\x1b[31m[ERROR]\x1b[0m',
40
+ success: '\x1b[32m[SUCCESS]\x1b[0m'
41
+ };
42
+ console.log(`${colors[type]} ${message}`);
43
+ }
44
+
45
+ // 备份目录
46
+ backupDir(targetPath) {
47
+ if (fs.existsSync(targetPath)) {
48
+ const backupPath = `${targetPath}.backup.${Date.now()}`;
49
+ this.log(`备份现有配置到: ${backupPath}`, 'warn');
50
+ this.copyDir(targetPath, backupPath);
51
+ return backupPath;
52
+ }
53
+ return null;
54
+ }
55
+
56
+ // 递归删除目录
57
+ removeDir(dirPath) {
58
+ if (fs.existsSync(dirPath)) {
59
+ const entries = fs.readdirSync(dirPath, { withFileTypes: true });
60
+ for (const entry of entries) {
61
+ const fullPath = path.join(dirPath, entry.name);
62
+ if (entry.isDirectory()) {
63
+ this.removeDir(fullPath);
64
+ } else {
65
+ fs.unlinkSync(fullPath);
66
+ }
67
+ }
68
+ fs.rmdirSync(dirPath);
69
+ }
70
+ }
71
+
72
+ // 递归复制目录(完全覆盖模式)
73
+ copyDir(src, dest) {
74
+ // 如果目标目录存在,先完全删除(确保完全覆盖)
75
+ if (fs.existsSync(dest)) {
76
+ this.removeDir(dest);
77
+ }
78
+
79
+ // 重新创建目录并复制
80
+ fs.mkdirSync(dest, { recursive: true });
81
+
82
+ const entries = fs.readdirSync(src, { withFileTypes: true });
83
+
84
+ for (const entry of entries) {
85
+ const srcPath = path.join(src, entry.name);
86
+ const destPath = path.join(dest, entry.name);
87
+
88
+ if (entry.isDirectory()) {
89
+ this.copyDir(srcPath, destPath);
90
+ } else {
91
+ fs.copyFileSync(srcPath, destPath);
92
+ }
93
+ }
94
+ }
95
+
96
+ // 智能合并目录(只更新包中存在的文件,保留用户自定义文件)
97
+ mergeDir(src, dest) {
98
+ if (!fs.existsSync(dest)) {
99
+ fs.mkdirSync(dest, { recursive: true });
100
+ }
101
+
102
+ const entries = fs.readdirSync(src, { withFileTypes: true });
103
+ let updatedCount = 0;
104
+ let addedCount = 0;
105
+
106
+ for (const entry of entries) {
107
+ const srcPath = path.join(src, entry.name);
108
+ const destPath = path.join(dest, entry.name);
109
+
110
+ if (entry.isDirectory()) {
111
+ const result = this.mergeDir(srcPath, destPath);
112
+ updatedCount += result.updated;
113
+ addedCount += result.added;
114
+ } else {
115
+ const exists = fs.existsSync(destPath);
116
+ fs.copyFileSync(srcPath, destPath);
117
+ if (exists) {
118
+ updatedCount++;
119
+ } else {
120
+ addedCount++;
121
+ }
122
+ }
123
+ }
124
+
125
+ return { updated: updatedCount, added: addedCount };
126
+ }
127
+
128
+ // 获取目录中所有文件的相对路径列表
129
+ getAllFiles(dir, baseDir = dir) {
130
+ const files = [];
131
+ if (!fs.existsSync(dir)) {
132
+ return files;
133
+ }
134
+
135
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
136
+ for (const entry of entries) {
137
+ const fullPath = path.join(dir, entry.name);
138
+ const relativePath = path.relative(baseDir, fullPath);
139
+
140
+ if (entry.isDirectory()) {
141
+ files.push(...this.getAllFiles(fullPath, baseDir));
142
+ } else {
143
+ files.push(relativePath);
144
+ }
145
+ }
146
+
147
+ return files;
148
+ }
149
+
150
+ // 安装公共配置 (.6aspec)
151
+ install6aspec() {
152
+ this.log('开始安装公共配置 (.6aspec)...');
153
+
154
+ const sourceDir = path.join(this.packageDir, '.6aspec');
155
+ const targetDir = path.join(this.targetDir, '.6aspec');
156
+
157
+ if (!fs.existsSync(sourceDir)) {
158
+ this.log('未找到 .6aspec 源目录,跳过', 'warn');
159
+ return;
160
+ }
161
+
162
+ const targetExists = fs.existsSync(targetDir);
163
+
164
+ if (this.mergeMode && targetExists) {
165
+ // 智能合并模式
166
+ this.log('使用智能合并模式(保留用户自定义文件)...');
167
+
168
+ // 统计用户自定义文件
169
+ const sourceFiles = new Set(this.getAllFiles(sourceDir, sourceDir));
170
+ const targetFiles = this.getAllFiles(targetDir, targetDir);
171
+ const customFiles = targetFiles.filter(f => !sourceFiles.has(f));
172
+
173
+ if (customFiles.length > 0) {
174
+ this.log(`检测到 ${customFiles.length} 个用户自定义文件,将保留`, 'info');
175
+ }
176
+
177
+ const result = this.mergeDir(sourceDir, targetDir);
178
+ this.log(`更新了 ${result.updated} 个文件,新增了 ${result.added} 个文件`, 'info');
179
+
180
+ if (customFiles.length > 0) {
181
+ this.log(`保留了 ${customFiles.length} 个用户自定义文件`, 'info');
182
+ }
183
+ } else {
184
+ // 完全覆盖模式
185
+ if (targetExists) {
186
+ this.backupDir(targetDir);
187
+ }
188
+ this.log('复制公共配置文件...');
189
+ this.copyDir(sourceDir, targetDir);
190
+ }
191
+
192
+ this.log('✓ 公共配置安装完成!', 'success');
193
+ }
194
+
195
+ // 安装 Cursor 配置
196
+ installCursor() {
197
+ this.log('开始安装 Cursor 配置...');
198
+
199
+ const sourceDir = path.join(this.packageDir, '.cursor');
200
+ const targetDir = path.join(this.targetDir, '.cursor');
201
+
202
+ if (!fs.existsSync(sourceDir)) {
203
+ throw new Error('未找到 .cursor 源目录');
204
+ }
205
+
206
+ const targetExists = fs.existsSync(targetDir);
207
+
208
+ if (this.mergeMode && targetExists) {
209
+ // 智能合并模式
210
+ this.log('使用智能合并模式(保留用户自定义文件)...');
211
+
212
+ // 只复制 commands 目录
213
+ const commandsSourceDir = path.join(sourceDir, 'commands');
214
+ if (fs.existsSync(commandsSourceDir)) {
215
+ const commandsTargetDir = path.join(targetDir, 'commands');
216
+ const result = this.mergeDir(commandsSourceDir, commandsTargetDir);
217
+ this.log(`commands: 更新了 ${result.updated} 个文件,新增了 ${result.added} 个文件`, 'info');
218
+ }
219
+ } else {
220
+ // 完全覆盖模式
221
+ if (targetExists) {
222
+ this.backupDir(targetDir);
223
+ }
224
+ this.log('复制 Cursor 配置文件...');
225
+
226
+ // 创建目标目录
227
+ if (!fs.existsSync(targetDir)) {
228
+ fs.mkdirSync(targetDir, { recursive: true });
229
+ }
230
+
231
+ // 只复制 commands 目录
232
+ const commandsSourceDir = path.join(sourceDir, 'commands');
233
+ if (fs.existsSync(commandsSourceDir)) {
234
+ const commandsTargetDir = path.join(targetDir, 'commands');
235
+ this.copyDir(commandsSourceDir, commandsTargetDir);
236
+ }
237
+ }
238
+
239
+ this.log('✓ Cursor 配置安装完成!', 'success');
240
+ }
241
+
242
+ // 安装 Claude 配置
243
+ installClaude() {
244
+ this.log('开始安装 Claude 配置...');
245
+
246
+ const sourceDir = path.join(this.packageDir, '.claude');
247
+ const targetDir = path.join(this.targetDir, '.claude');
248
+
249
+ if (!fs.existsSync(sourceDir)) {
250
+ this.log('未找到 .claude 源目录,跳过', 'warn');
251
+ return;
252
+ }
253
+
254
+ const targetExists = fs.existsSync(targetDir);
255
+
256
+ // 创建目标目录结构
257
+ if (!fs.existsSync(targetDir)) {
258
+ fs.mkdirSync(targetDir, { recursive: true });
259
+ }
260
+
261
+ if (this.mergeMode && targetExists) {
262
+ // 智能合并模式
263
+ this.log('使用智能合并模式(保留用户自定义文件)...');
264
+
265
+ // 复制 commands
266
+ const commandsDir = path.join(sourceDir, 'commands');
267
+ if (fs.existsSync(commandsDir)) {
268
+ const targetCommandsDir = path.join(targetDir, 'commands');
269
+ const result = this.mergeDir(commandsDir, targetCommandsDir);
270
+ if (result.updated > 0 || result.added > 0) {
271
+ this.log(`commands: 更新了 ${result.updated} 个文件,新增了 ${result.added} 个文件`, 'info');
272
+ }
273
+ }
274
+ } else {
275
+ // 完全覆盖模式
276
+ if (targetExists) {
277
+ this.backupDir(targetDir);
278
+ }
279
+ this.log('复制 Claude 配置文件...');
280
+
281
+ // 复制 commands
282
+ const commandsDir = path.join(sourceDir, 'commands');
283
+ if (fs.existsSync(commandsDir)) {
284
+ const targetCommandsDir = path.join(targetDir, 'commands');
285
+ this.copyDir(commandsDir, targetCommandsDir);
286
+ }
287
+ }
288
+
289
+ this.log('✓ Claude 配置安装完成!', 'success');
290
+ }
291
+
292
+ // 主安装方法
293
+ async install(tool = 'cursor', mergeMode = false) {
294
+ this.mergeMode = mergeMode;
295
+
296
+ this.log(`6A-spec 安装工具`);
297
+ this.log(`目标目录: ${this.targetDir}`);
298
+ this.log(`工具: ${tool}`);
299
+ if (mergeMode) {
300
+ this.log(`模式: 智能合并(保留用户自定义文件)`, 'info');
301
+ } else {
302
+ this.log(`模式: 完全覆盖(会先备份现有配置)`, 'info');
303
+ }
304
+
305
+ try {
306
+ // 无论安装哪个工具,都要先安装公共配置
307
+ this.install6aspec();
308
+
309
+ switch (tool.toLowerCase()) {
310
+ case 'cursor':
311
+ this.installCursor();
312
+ break;
313
+ case 'claude':
314
+ this.installClaude();
315
+ break;
316
+ case 'all':
317
+ this.installCursor();
318
+ this.installClaude();
319
+ break;
320
+ default:
321
+ throw new Error(`未知工具: ${tool}\n支持的工具: cursor, claude, all`);
322
+ }
323
+
324
+ this.log('安装完成!', 'success');
325
+ } catch (error) {
326
+ this.log(error.message, 'error');
327
+ throw error;
328
+ }
329
+ }
330
+ }
331
+
332
+ module.exports = new Installer();
333
+
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "6aspec",
3
+ "version": "2.0.0-dev.10",
4
+ "description": "6Aspec - 轻量级 spec 驱动开发框架,支持 Cursor 和 Claude Code",
5
+ "main": "lib/installer.js",
6
+ "bin": {
7
+ "6aspec": "./bin/6aspec"
8
+ },
9
+ "scripts": {
10
+ "test": "node bin/6aspec --help",
11
+ "version:dev": "npm version prerelease --preid=dev --no-git-tag-version",
12
+ "version:beta": "npm version prerelease --preid=beta --no-git-tag-version",
13
+ "version:rc": "npm version prerelease --preid=rc --no-git-tag-version",
14
+ "version:patch": "npm version patch --no-git-tag-version",
15
+ "version:minor": "npm version minor --no-git-tag-version",
16
+ "version:major": "npm version major --no-git-tag-version",
17
+ "version:dev:git": "npm version prerelease --preid=dev",
18
+ "version:beta:git": "npm version prerelease --preid=beta",
19
+ "version:rc:git": "npm version prerelease --preid=rc",
20
+ "version:patch:git": "npm version patch",
21
+ "version:minor:git": "npm version minor",
22
+ "version:major:git": "npm version major",
23
+ "publish:dev": "npm run version:dev && npm publish --tag dev",
24
+ "publish:beta": "npm run version:beta && npm publish --tag beta",
25
+ "publish:rc": "npm run version:rc && npm publish --tag rc",
26
+ "publish:latest": "npm run version:patch && npm publish",
27
+ "publish:dev:otp": "npm run version:dev && npm publish --tag dev --otp",
28
+ "publish:beta:otp": "npm run version:beta && npm publish --tag beta --otp",
29
+ "publish:rc:otp": "npm run version:rc && npm publish --tag rc --otp",
30
+ "publish:latest:otp": "npm run version:patch && npm publish --otp",
31
+ "publish:dev:git": "npm run version:dev:git && npm publish --tag dev",
32
+ "publish:beta:git": "npm run version:beta:git && npm publish --tag beta",
33
+ "publish:rc:git": "npm run version:rc:git && npm publish --tag rc",
34
+ "publish:latest:git": "npm run version:patch:git && npm publish"
35
+ },
36
+ "keywords": [
37
+ "cursor",
38
+ "claude",
39
+ "ai",
40
+ "prompts",
41
+ "spec-driven",
42
+ "development",
43
+ "6aspec"
44
+ ],
45
+ "author": "yanghuijava@gmail.com",
46
+ "license": "MIT",
47
+ "files": [
48
+ "bin/",
49
+ "lib/",
50
+ ".cursor/",
51
+ ".claude/",
52
+ ".6aspec/",
53
+ "README.md"
54
+ ],
55
+ "engines": {
56
+ "node": ">=14.0.0"
57
+ },
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "https://gitee.com/yanghuijava/6-a-spec.git"
61
+ }
62
+ }