speccrew 0.1.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 (153) hide show
  1. package/.speccrew/agents/speccrew-feature-designer.md +142 -0
  2. package/.speccrew/agents/speccrew-product-manager.md +61 -0
  3. package/.speccrew/agents/speccrew-system-designer.md +200 -0
  4. package/.speccrew/agents/speccrew-system-developer.md +238 -0
  5. package/.speccrew/agents/speccrew-task-worker.md +80 -0
  6. package/.speccrew/agents/speccrew-team-leader.md +92 -0
  7. package/.speccrew/agents/speccrew-test-manager.md +313 -0
  8. package/.speccrew/skills/speccrew-create-agents/SKILL.md +98 -0
  9. package/.speccrew/skills/speccrew-create-agents/templates/agents/designer-agent.md +54 -0
  10. package/.speccrew/skills/speccrew-create-agents/templates/agents/dev-agent.md +79 -0
  11. package/.speccrew/skills/speccrew-create-agents/templates/agents/test-agent.md +80 -0
  12. package/.speccrew/skills/speccrew-dev-backend/SKILL.md +205 -0
  13. package/.speccrew/skills/speccrew-dev-backend/templates/TASK-RECORD-TEMPLATE.md +118 -0
  14. package/.speccrew/skills/speccrew-dev-desktop/SKILL.md +258 -0
  15. package/.speccrew/skills/speccrew-dev-desktop/templates/TASK-RECORD-TEMPLATE.md +161 -0
  16. package/.speccrew/skills/speccrew-dev-frontend/SKILL.md +202 -0
  17. package/.speccrew/skills/speccrew-dev-frontend/templates/TASK-RECORD-TEMPLATE.md +115 -0
  18. package/.speccrew/skills/speccrew-dev-mobile/SKILL.md +200 -0
  19. package/.speccrew/skills/speccrew-dev-mobile/templates/TASK-RECORD-TEMPLATE.md +125 -0
  20. package/.speccrew/skills/speccrew-fd-api-contract/SKILL.md +73 -0
  21. package/.speccrew/skills/speccrew-fd-api-contract/templates/API-CONTRACT-TEMPLATE.md +96 -0
  22. package/.speccrew/skills/speccrew-fd-feature-design/SKILL.md +395 -0
  23. package/.speccrew/skills/speccrew-fd-feature-design/templates/FEATURE-SPEC-TEMPLATE.md +387 -0
  24. package/.speccrew/skills/speccrew-get-timestamp/SKILL.md +80 -0
  25. package/.speccrew/skills/speccrew-get-timestamp/scripts/get-timestamp.js +35 -0
  26. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/SKILL.md +1116 -0
  27. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-FASTAPI.md +462 -0
  28. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-JAVA.md +480 -0
  29. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-NET.md +464 -0
  30. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE.md +480 -0
  31. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/MODULE-OVERVIEW-TEMPLATE.md +367 -0
  32. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/SKILL.md +667 -0
  33. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/STATUS-FORMATS.md +74 -0
  34. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/batch-orchestrator.js +176 -0
  35. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-next-batch.js +150 -0
  36. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-pending-features.js +106 -0
  37. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/mark-stale.js +249 -0
  38. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/process-batch-results.js +848 -0
  39. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/update-feature-status.js +226 -0
  40. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/SKILL.md +264 -0
  41. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/examples/features.json +34 -0
  42. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/generate-inventory.js +867 -0
  43. package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/test-inventory.js +26 -0
  44. package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/SKILL.md +165 -0
  45. package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/apply-module-mapping.js +208 -0
  46. package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/extract-module-summary.js +180 -0
  47. package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/reindex-modules.js +358 -0
  48. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/SKILL.md +1055 -0
  49. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-DESKTOP.md +303 -0
  50. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-ELECTRON.md +327 -0
  51. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-MINIAPP.md +292 -0
  52. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-MOBILE.md +281 -0
  53. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI.md +324 -0
  54. package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/SKILL.md +270 -0
  55. package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/COMPONENT-PATTERN-TEMPLATE.md +33 -0
  56. package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/LAYOUT-PATTERN-TEMPLATE.md +33 -0
  57. package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/PAGE-TYPE-TEMPLATE.md +33 -0
  58. package/.speccrew/skills/speccrew-knowledge-graph-query/SKILL.md +229 -0
  59. package/.speccrew/skills/speccrew-knowledge-graph-query/scripts/graph-query.js +549 -0
  60. package/.speccrew/skills/speccrew-knowledge-graph-write/SKILL.md +181 -0
  61. package/.speccrew/skills/speccrew-knowledge-graph-write/scripts/graph-write.js +651 -0
  62. package/.speccrew/skills/speccrew-knowledge-module-summarize/SKILL.md +305 -0
  63. package/.speccrew/skills/speccrew-knowledge-module-summarize/templates/MODULE-OVERVIEW-TEMPLATE.md +400 -0
  64. package/.speccrew/skills/speccrew-knowledge-system-summarize/SKILL.md +351 -0
  65. package/.speccrew/skills/speccrew-knowledge-system-summarize/templates/SYSTEM-OVERVIEW-TEMPLATE.md +294 -0
  66. package/.speccrew/skills/speccrew-knowledge-techs-dispatch/SKILL.md +683 -0
  67. package/.speccrew/skills/speccrew-knowledge-techs-dispatch/STATUS-FORMATS.md +550 -0
  68. package/.speccrew/skills/speccrew-knowledge-techs-dispatch/templates/techs-manifest-EXAMPLE.json +35 -0
  69. package/.speccrew/skills/speccrew-knowledge-techs-generate/SKILL.md +1087 -0
  70. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/ARCHITECTURE-TEMPLATE.md +240 -0
  71. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/COLOR-SYSTEM-TEMPLATE.md +68 -0
  72. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/COMPONENT-LIBRARY-TEMPLATE.md +86 -0
  73. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-BUILD-TEMPLATE.md +466 -0
  74. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DATA-TEMPLATE.md +432 -0
  75. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DESIGN-TEMPLATE.md +1209 -0
  76. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DEV-TEMPLATE.md +1433 -0
  77. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-SYSTEM-TEST-TEMPLATE.md +1052 -0
  78. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-UNIT-TEST-TEMPLATE.md +946 -0
  79. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/INDEX-TEMPLATE.md +29 -0
  80. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/PAGE-LAYOUTS-TEMPLATE.md +69 -0
  81. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/PAGE-TYPE-SUMMARY-TEMPLATE.md +74 -0
  82. package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/TECH-STACK-TEMPLATE.md +232 -0
  83. package/.speccrew/skills/speccrew-knowledge-techs-generate-conventions/SKILL.md +628 -0
  84. package/.speccrew/skills/speccrew-knowledge-techs-generate-ui-style/SKILL.md +392 -0
  85. package/.speccrew/skills/speccrew-knowledge-techs-index/SKILL.md +489 -0
  86. package/.speccrew/skills/speccrew-knowledge-techs-index/templates/INDEX-TEMPLATE.md +243 -0
  87. package/.speccrew/skills/speccrew-knowledge-techs-init/SKILL.md +269 -0
  88. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/SKILL.md +562 -0
  89. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/BUSINESS-COMPONENTS-TEMPLATE.md +171 -0
  90. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMMON-COMPONENTS-TEMPLATE.md +177 -0
  91. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMPONENT-INDIVIDUAL-TEMPLATE.md +80 -0
  92. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMPONENT-LIBRARY-TEMPLATE.md +118 -0
  93. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/LAYOUT-INDIVIDUAL-TEMPLATE.md +97 -0
  94. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/LAYOUT-PATTERNS-TEMPLATE.md +208 -0
  95. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/NAVIGATION-PATTERNS-TEMPLATE.md +157 -0
  96. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/PAGE-TYPE-INDIVIDUAL-TEMPLATE.md +123 -0
  97. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/PAGE-TYPE-SUMMARY-TEMPLATE.md +58 -0
  98. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/SPACING-TEMPLATE.md +119 -0
  99. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/STYLE-SYSTEM-TEMPLATE.md +117 -0
  100. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/TYPOGRAPHY-TEMPLATE.md +107 -0
  101. package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/UI-STYLE-GUIDE-TEMPLATE.md +171 -0
  102. package/.speccrew/skills/speccrew-pm-requirement-analysis/SKILL.md +434 -0
  103. package/.speccrew/skills/speccrew-pm-requirement-analysis/templates/BIZS-MODELING-TEMPLATE.md +332 -0
  104. package/.speccrew/skills/speccrew-pm-requirement-analysis/templates/PRD-TEMPLATE.md +200 -0
  105. package/.speccrew/skills/speccrew-pm-requirement-assess/SKILL.md +195 -0
  106. package/.speccrew/skills/speccrew-project-diagnosis/SKILL.md +208 -0
  107. package/.speccrew/skills/speccrew-project-diagnosis/templates/DIAGNOSIS-REPORT-TEMPLATE.md +202 -0
  108. package/.speccrew/skills/speccrew-sd-backend/SKILL.md +188 -0
  109. package/.speccrew/skills/speccrew-sd-backend/templates/INDEX-TEMPLATE.md +85 -0
  110. package/.speccrew/skills/speccrew-sd-backend/templates/SD-BACKEND-TEMPLATE.md +269 -0
  111. package/.speccrew/skills/speccrew-sd-desktop/SKILL.md +192 -0
  112. package/.speccrew/skills/speccrew-sd-desktop/templates/INDEX-TEMPLATE.md +271 -0
  113. package/.speccrew/skills/speccrew-sd-desktop/templates/SD-DESKTOP-TEMPLATE.md +673 -0
  114. package/.speccrew/skills/speccrew-sd-frontend/SKILL.md +176 -0
  115. package/.speccrew/skills/speccrew-sd-frontend/templates/INDEX-TEMPLATE.md +184 -0
  116. package/.speccrew/skills/speccrew-sd-frontend/templates/SD-FRONTEND-TEMPLATE.md +382 -0
  117. package/.speccrew/skills/speccrew-sd-mobile/SKILL.md +189 -0
  118. package/.speccrew/skills/speccrew-sd-mobile/templates/INDEX-TEMPLATE.md +219 -0
  119. package/.speccrew/skills/speccrew-sd-mobile/templates/SD-MOBILE-TEMPLATE.md +534 -0
  120. package/.speccrew/skills/speccrew-test-case-design/SKILL.md +284 -0
  121. package/.speccrew/skills/speccrew-test-case-design/templates/TEST-CASE-DESIGN-TEMPLATE.md +263 -0
  122. package/.speccrew/skills/speccrew-test-code-gen/SKILL.md +313 -0
  123. package/.speccrew/skills/speccrew-test-code-gen/templates/TEST-CODE-PLAN-TEMPLATE.md +180 -0
  124. package/.speccrew/skills/speccrew-test-execute/SKILL.md +283 -0
  125. package/.speccrew/skills/speccrew-test-execute/templates/BUG-REPORT-TEMPLATE.md +50 -0
  126. package/.speccrew/skills/speccrew-test-execute/templates/TEST-REPORT-TEMPLATE.md +57 -0
  127. package/.speccrew/skills/speccrew-workflow-diagnose/SKILL.md +155 -0
  128. package/LICENSE +21 -0
  129. package/README.ar.md +318 -0
  130. package/README.en.md +318 -0
  131. package/README.es.md +318 -0
  132. package/README.md +340 -0
  133. package/bin/cli.js +62 -0
  134. package/lib/commands/doctor.js +138 -0
  135. package/lib/commands/init.js +231 -0
  136. package/lib/commands/list.js +114 -0
  137. package/lib/commands/uninstall.js +117 -0
  138. package/lib/commands/update.js +351 -0
  139. package/lib/ide-adapters.js +73 -0
  140. package/lib/utils.js +104 -0
  141. package/package.json +28 -0
  142. package/workspace-template/docs/configs/document-templates.json +667 -0
  143. package/workspace-template/docs/configs/platform-mapping.json +194 -0
  144. package/workspace-template/docs/configs/tech-stack-mappings.json +313 -0
  145. package/workspace-template/docs/configs/validation-rules.json +87 -0
  146. package/workspace-template/docs/rules/mermaid-rule.md +114 -0
  147. package/workspace-template/docs/solutions/Agent/346/212/200/350/203/275/345/256/232/344/271/211+/351/234/200/346/261/202/346/226/207/346/241/243+UML/344/275/277/347/224/250/346/250/241/346/235/277/357/274/210ISA-95/345/205/255/346/256/265/345/274/217/350/236/215/345/220/210/347/211/210/357/274/211.md +586 -0
  148. package/workspace-template/docs/solutions/agent-knowledge-map.md +238 -0
  149. package/workspace-template/docs/solutions/bizs-knowledge-pipeline.md +678 -0
  150. package/workspace-template/docs/solutions/harness.md +410 -0
  151. package/workspace-template/docs/solutions/knowledge-incremental-sync-spec.md +943 -0
  152. package/workspace-template/docs/solutions/techs-knowledge-pipeline.md +803 -0
  153. package/workspace-template/docs/solutions/workspace-structure.md +318 -0
@@ -0,0 +1,226 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Update the status of a feature in a features-*.json file.
5
+ *
6
+ * Updates the analyzed status, timestamps, and notes for a specific feature
7
+ * within a features-*.json file. Matches by fileName and sourcePath.
8
+ */
9
+
10
+ const fs = require('fs');
11
+ const path = require('path');
12
+
13
+ // Parse command line arguments
14
+ function parseArgs() {
15
+ const args = process.argv.slice(2);
16
+ const result = {
17
+ sourceFile: null,
18
+ fileName: null,
19
+ featureSourcePath: null,
20
+ analyzed: null,
21
+ setStarted: false,
22
+ setCompleted: false,
23
+ analysisNotes: null,
24
+ status: null
25
+ };
26
+
27
+ for (let i = 0; i < args.length; i++) {
28
+ const arg = args[i];
29
+ switch (arg) {
30
+ case '--sourceFile':
31
+ case '-SourceFile':
32
+ result.sourceFile = args[++i];
33
+ break;
34
+ case '--fileName':
35
+ case '-FileName':
36
+ result.fileName = args[++i];
37
+ break;
38
+ case '--featureSourcePath':
39
+ case '-FeatureSourcePath':
40
+ result.featureSourcePath = args[++i];
41
+ break;
42
+ case '--analyzed':
43
+ case '-Analyzed':
44
+ result.analyzed = args[++i];
45
+ break;
46
+ case '--setStarted':
47
+ case '-SetStarted':
48
+ result.setStarted = true;
49
+ break;
50
+ case '--setCompleted':
51
+ case '-SetCompleted':
52
+ result.setCompleted = true;
53
+ break;
54
+ case '--analysisNotes':
55
+ case '-AnalysisNotes':
56
+ result.analysisNotes = args[++i];
57
+ break;
58
+ case '--status':
59
+ case '-Status':
60
+ result.status = args[++i];
61
+ break;
62
+ }
63
+ }
64
+
65
+ return result;
66
+ }
67
+
68
+ // Helper function to safely set property on object
69
+ function setFeatureProperty(obj, propertyName, value) {
70
+ obj[propertyName] = value;
71
+ }
72
+
73
+ // Helper function to format timestamp
74
+ function getTimestamp() {
75
+ const now = new Date();
76
+ const year = now.getFullYear();
77
+ const month = String(now.getMonth() + 1).padStart(2, '0');
78
+ const day = String(now.getDate()).padStart(2, '0');
79
+ const hours = String(now.getHours()).padStart(2, '0');
80
+ const minutes = String(now.getMinutes()).padStart(2, '0');
81
+ const seconds = String(now.getSeconds()).padStart(2, '0');
82
+ return `${year}-${month}-${day}-${hours}${minutes}${seconds}`;
83
+ }
84
+
85
+ function main() {
86
+ try {
87
+ const args = parseArgs();
88
+
89
+ if (!args.sourceFile || !args.fileName || args.analyzed === null) {
90
+ console.error('Error: --sourceFile, --fileName, and --analyzed are required');
91
+ process.exit(1);
92
+ }
93
+
94
+ // Check if file exists
95
+ const sourceFilePath = path.resolve(args.sourceFile);
96
+ if (!fs.existsSync(sourceFilePath)) {
97
+ console.error(`Source file not found: ${args.sourceFile}`);
98
+ process.exit(1);
99
+ }
100
+
101
+ // Acquire file lock to prevent concurrent access
102
+ const lockPath = `${sourceFilePath}.lock`;
103
+ const maxRetries = 30;
104
+ let retryCount = 0;
105
+ let lockAcquired = false;
106
+
107
+ while (!lockAcquired && retryCount < maxRetries) {
108
+ try {
109
+ // Try to create lock file exclusively
110
+ const fd = fs.openSync(lockPath, 'wx');
111
+ fs.closeSync(fd);
112
+ lockAcquired = true;
113
+ } catch (error) {
114
+ retryCount++;
115
+ if (retryCount >= maxRetries) {
116
+ const errorMsg = `Failed to acquire file lock for '${sourceFilePath}' after ${maxRetries} attempts (waited ${maxRetries} seconds). The file may be locked by another process.`;
117
+ console.warn(errorMsg);
118
+ // Return error object instead of exiting
119
+ const errorResult = {
120
+ success: false,
121
+ error: errorMsg,
122
+ sourceFile: args.sourceFile,
123
+ fileName: args.fileName,
124
+ retryCount: retryCount
125
+ };
126
+ console.log(JSON.stringify(errorResult, null, 2));
127
+ process.exit(0);
128
+ }
129
+ if (retryCount % 5 === 0) {
130
+ console.warn(`Waiting for file lock on '${sourceFilePath}'... (attempt ${retryCount} of ${maxRetries})`);
131
+ }
132
+ // Wait 1 second before retry
133
+ const start = Date.now();
134
+ while (Date.now() - start < 1000) {
135
+ // Busy wait
136
+ }
137
+ }
138
+ }
139
+
140
+ try {
141
+ // Read the JSON file
142
+ const rawContent = fs.readFileSync(sourceFilePath, 'utf8');
143
+ const content = JSON.parse(rawContent);
144
+
145
+ // Convert Analyzed string to boolean
146
+ const analyzedBool = ['true', '1', '$true', 'True', 'TRUE'].includes(args.analyzed);
147
+
148
+ // Find and update the feature
149
+ let found = false;
150
+ if (content.features && Array.isArray(content.features)) {
151
+ for (let i = 0; i < content.features.length; i++) {
152
+ const feature = content.features[i];
153
+
154
+ // Match by fileName (and optionally sourcePath for disambiguation)
155
+ const nameMatch = feature.fileName === args.fileName;
156
+ const pathMatch = !args.featureSourcePath || feature.sourcePath === args.featureSourcePath;
157
+
158
+ if (nameMatch && pathMatch) {
159
+ setFeatureProperty(feature, 'analyzed', analyzedBool);
160
+
161
+ if (args.setStarted) {
162
+ setFeatureProperty(feature, 'startedAt', getTimestamp());
163
+ }
164
+ if (args.setCompleted) {
165
+ setFeatureProperty(feature, 'completedAt', getTimestamp());
166
+ }
167
+ if (args.analysisNotes !== null) {
168
+ setFeatureProperty(feature, 'analysisNotes', args.analysisNotes);
169
+ }
170
+
171
+ // Handle Status parameter with backward compatibility
172
+ if (args.status !== null) {
173
+ setFeatureProperty(feature, 'status', args.status);
174
+ // Backward compatibility: update analyzed based on status
175
+ if (args.status === 'completed') {
176
+ setFeatureProperty(feature, 'analyzed', true);
177
+ } else {
178
+ setFeatureProperty(feature, 'analyzed', false);
179
+ }
180
+ }
181
+
182
+ content.features[i] = feature;
183
+ found = true;
184
+ break;
185
+ }
186
+ }
187
+ }
188
+
189
+ if (!found) {
190
+ console.error(`Feature not found: FileName=${args.fileName}, SourcePath=${args.featureSourcePath}`);
191
+ // Clean up lock file before exit
192
+ try {
193
+ fs.unlinkSync(lockPath);
194
+ } catch (e) {
195
+ // Ignore
196
+ }
197
+ process.exit(1);
198
+ }
199
+
200
+ // Update counters
201
+ content.analyzedCount = content.features.filter(f => f.analyzed === true).length;
202
+ content.pendingCount = content.features.filter(f => f.analyzed === false).length;
203
+
204
+ // Write back to file using atomic write (temp file + rename)
205
+ const tempFile = `${sourceFilePath}.tmp`;
206
+ fs.writeFileSync(tempFile, JSON.stringify(content, null, 2), 'utf8');
207
+ fs.renameSync(tempFile, sourceFilePath);
208
+
209
+ console.warn(`Updated feature: ${args.fileName} (analyzed=${analyzedBool})`);
210
+ } finally {
211
+ // Release lock - remove lock file
212
+ try {
213
+ if (fs.existsSync(lockPath)) {
214
+ fs.unlinkSync(lockPath);
215
+ }
216
+ } catch (e) {
217
+ // Ignore cleanup errors
218
+ }
219
+ }
220
+ } catch (error) {
221
+ console.error(`Error: ${error.message}`);
222
+ process.exit(1);
223
+ }
224
+ }
225
+
226
+ main();
@@ -0,0 +1,264 @@
1
+ ---
2
+ name: speccrew-knowledge-bizs-init-features
3
+ description: Scan source code directories to identify all platforms and generate features.json inventory for knowledge base initialization. Use when initializing business knowledge base from source code.
4
+ tools: Read, Write, Glob, Grep, SearchCodebase, Skill, Bash
5
+ ---
6
+
7
+ ## Input
8
+
9
+ | Parameter | Type | Required | Description |
10
+ |-----------|------|----------|-------------|
11
+ | {source_path} | string | No | Source code directory path (default: project root) |
12
+ | {language} | string | Yes | Target language for generated content (e.g., "zh", "en") |
13
+
14
+ ## Output
15
+
16
+ - `speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/features-{platform}.json` - Platform-specific feature inventory files
17
+
18
+ ## Workflow
19
+
20
+ ```mermaid
21
+ flowchart TD
22
+ Start([Start]) --> Step1[Step 1: Identify Platforms]
23
+ Step1 --> Step2[Step 2: Configure Platform Parameters]
24
+ Step2 --> Step3[Step 3: Execute Inventory Scripts]
25
+ Step3 --> Step4[Step 4: Report Results]
26
+ Step4 --> End([End])
27
+ ```
28
+
29
+ ### Step 1: Identify Platforms
30
+
31
+ **Detection Process:**
32
+
33
+ 1. **Read Configuration:**
34
+ - `speccrew-workspace/docs/configs/platform-mapping.json` - Platform type and subtype mappings
35
+ - `speccrew-workspace/docs/configs/tech-stack-mappings.json` - Tech stack configurations and exclude directories
36
+
37
+ 2. Scan `{source_path}` for platform-specific configuration files (e.g., package.json, pubspec.yaml, pom.xml)
38
+
39
+ 3. Match detected files against `platform-mapping.json` → `platform_categories`
40
+
41
+ 4. For each matched platform, extract `platform_type` and `platform_subtype`
42
+
43
+ 5. Use `tech-stack-mappings.json` to determine:
44
+ - `FileExtensions`: Which file extensions to scan
45
+ - `ExcludeDirs`: Which directories to exclude
46
+ - `TechStack`: Technology stack array
47
+
48
+ 6. Each detected platform will generate one `features-{platform}.json` file
49
+
50
+ **Example Detection:**
51
+ - Found `frontend-web/package.json` with `"vue"` in dependencies
52
+ - Lookup `platform-mapping.json`: `web` + `vue` → `platform_type=web`, `platform_subtype=vue`
53
+ - Lookup `tech-stack-mappings.json`: vue → extensions=[".vue"], exclude_dirs=["components","utils"]
54
+
55
+ ### Step 2: Configure Platform Parameters
56
+
57
+ For each detected platform, configure the following parameters:
58
+
59
+ | Parameter | Description | Example |
60
+ |-----------|-------------|---------|
61
+ | `SourcePath` | Source directory relative to project root | `frontend-web/src/views` |
62
+ | `OutputFileName` | Output file name | `features-web.json` |
63
+ | `PlatformName` | Human-readable platform name | `Web Frontend` |
64
+ | `PlatformType` | Platform category | `web`, `mobile`, `backend`, `desktop` |
65
+ | `PlatformSubtype` | Technology/framework | `vue`, `react`, `flutter`, `spring` |
66
+ | `TechStack` | Technology stack array | `["vue", "typescript"]` |
67
+ | `FileExtensions` | File extensions to scan | `[".vue", ".ts"]` |
68
+ | `ExcludeDirs` | Directories to exclude | `["components", "utils"]` |
69
+
70
+ ### Step 3: Execute Inventory Scripts
71
+
72
+ > **MANDATORY**: You MUST execute the provided scripts via `run_in_terminal`. DO NOT use `read_file`, `search_codebase`, `Glob`, or any other tool to substitute script execution. DO NOT manually scan files and construct JSON output yourself.
73
+
74
+ Execute the inventory script for each platform:
75
+
76
+ **Prerequisites:**
77
+ - Node.js 14.0+
78
+
79
+ **Script Location (relative to this skill's directory):**
80
+ - All Platforms: `{skill_path}/scripts/generate-inventory.js`
81
+
82
+ **Example - Web Platform (Vue):**
83
+ ```bash
84
+ node "scripts/generate-inventory.js" \
85
+ --sourcePath "frontend-web/src/views" \
86
+ --outputFileName "features-web.json" \
87
+ --platformName "Web Frontend" \
88
+ --platformType "web" \
89
+ --platformSubtype "vue" \
90
+ --techStack "vue,typescript" \
91
+ --fileExtensions ".vue" \
92
+ --excludeDirs "components,composables,hooks,utils"
93
+ ```
94
+
95
+ **Example - Mobile Platform (UniApp):**
96
+ ```bash
97
+ node "scripts/generate-inventory.js" \
98
+ --sourcePath "frontend-mobile/pages" \
99
+ --outputFileName "features-mobile.json" \
100
+ --platformName "Mobile App" \
101
+ --platformType "mobile" \
102
+ --platformSubtype "uniapp" \
103
+ --techStack "uniapp,vue" \
104
+ --fileExtensions ".vue" \
105
+ --excludeDirs "components,utils"
106
+ ```
107
+
108
+ **Example - Backend Platform (Spring Single Module):**
109
+ ```bash
110
+ node "scripts/generate-inventory.js" \
111
+ --sourcePath "backend/src/main/java/com/example/controller" \
112
+ --outputFileName "features-backend.json" \
113
+ --platformName "Backend API" \
114
+ --platformType "backend" \
115
+ --platformSubtype "spring" \
116
+ --techStack "spring-boot,java" \
117
+ --fileExtensions ".java" \
118
+ --excludeDirs ""
119
+ ```
120
+
121
+ **Example - Backend Platform (Spring Multi-Module):**
122
+
123
+ > **IMPORTANT for Java/Kotlin backends**: Set `sourcePath` to the Java package root directory (e.g., `yudao-module-system/src/main/java/cn/iocoder/yudao/module/system`), NOT the module root. This ensures the `getModuleName` function extracts business module names (like `dept`, `auth`) instead of Java package segments (like `src`, `cn`).
124
+
125
+ For projects with multiple backend modules (e.g., ruoyi-vue-pro), execute the script once per module:
126
+
127
+ ```bash
128
+ # Module 1: AI
129
+ node "scripts/generate-inventory.js" \
130
+ --sourcePath "yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai" \
131
+ --outputFileName "features-backend-ai.json" \
132
+ --platformName "Backend API - AI Module" \
133
+ --platformType "backend" \
134
+ --platformSubtype "ai" \
135
+ --techIdentifier "spring" \
136
+ --techStack "spring-boot,java" \
137
+ --fileExtensions ".java" \
138
+ --excludeDirs ""
139
+
140
+ # Module 2: System
141
+ node "scripts/generate-inventory.js" \
142
+ --sourcePath "yudao-module-system/src/main/java/cn/iocoder/yudao/module/system" \
143
+ --outputFileName "features-backend-system.json" \
144
+ --platformName "Backend API - System Module" \
145
+ --platformType "backend" \
146
+ --platformSubtype "system" \
147
+ --techIdentifier "spring" \
148
+ --techStack "spring-boot,java" \
149
+ --fileExtensions ".java" \
150
+ --excludeDirs ""
151
+ ```
152
+
153
+ > **Note**: For multi-module backend projects, prefer per-module execution (above) over scan-all to get proper module-level directory isolation (e.g., `backend-ai/`, `backend-system/`).
154
+
155
+ **Alternative: Scan All Modules at Once**
156
+
157
+ If all modules share the same parent directory structure, you can scan from the project root:
158
+
159
+ ```bash
160
+ node "scripts/generate-inventory.js" \
161
+ --sourcePath "." \
162
+ --outputFileName "features-backend-all.json" \
163
+ --platformName "Backend API - All Modules" \
164
+ --platformType "backend" \
165
+ --platformSubtype "spring" \
166
+ --techStack "spring-boot,java" \
167
+ --fileExtensions ".java" \
168
+ --excludeDirs "test,target,.git"
169
+ ```
170
+
171
+ **Output: `features-{platform}.json` Structure:**
172
+ ```json
173
+ {
174
+ "platformName": "Web Frontend",
175
+ "platformType": "web",
176
+ "sourcePath": "frontend-web/src/views",
177
+ "techStack": ["vue", "typescript"],
178
+ "modules": ["system", "trade", "infra"],
179
+ "totalFiles": 25,
180
+ "analyzedCount": 0,
181
+ "pendingCount": 25,
182
+ "generatedAt": "2024-01-15-103000",
183
+ "features": [
184
+ {
185
+ "fileName": "index",
186
+ "sourcePath": "yudao-ui/yudao-ui-admin-uniapp/src/pages/bpm/index.vue",
187
+ "documentPath": "speccrew-workspace/knowledges/bizs/web-vue/src/views/system/user/index.md",
188
+ "module": "system",
189
+ "analyzed": false,
190
+ "startedAt": null,
191
+ "completedAt": null,
192
+ "analysisNotes": null
193
+ }
194
+ ]
195
+ }
196
+ ```
197
+
198
+ **Module Detection Rule:**
199
+ - The `module` field is automatically extracted from each file's relative directory path
200
+ - It uses the **first non-excluded directory level** as the module name
201
+ - Example: `system/user/index.vue` → module = `system`
202
+ - Example: `components/Table.vue` (excluded dir) → skipped by ExcludeDirs
203
+ - Files at root level (no subdirectory) → module = `_root`
204
+ - The top-level `modules` array lists all unique module names found
205
+
206
+ **sourcePath Format:**
207
+ - In both full-scan mode and entry-dirs mode, `sourcePath` is always a **project-root-relative path**
208
+ - Example: `yudao-ui/yudao-ui-admin-uniapp/src/pages/bpm/index.vue` (NOT `pages/bpm/index.vue`)
209
+ - Example: `yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java`
210
+
211
+ **Verification Checklist:**
212
+ - [ ] All `features-{platform}.json` files exist and are valid JSON
213
+ - [ ] Each file has correct platform metadata (platformName, platformType, techStack)
214
+ - [ ] All features have `analyzed: false` initially
215
+ - [ ] File paths are correct and accessible
216
+
217
+ ### Step 4: Report Results
218
+
219
+ ```
220
+ Feature Inventory Generated
221
+ - Platforms Found: [N]
222
+ - Platform 1: [platform_name] ([platform_type]) - [feature_count] features
223
+ - Platform 2: [platform_name] ([platform_type]) - [feature_count] features
224
+ - Total Features: [N]
225
+
226
+ Platform Inventory Files:
227
+ - Web Frontend:
228
+ - Inventory File: speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/features-web.json
229
+ - Total Features: [N]
230
+ - Status: Generated ✓
231
+ - Mobile App:
232
+ - Inventory File: speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/features-mobile.json
233
+ - Total Features: [N]
234
+ - Status: Generated ✓
235
+ - Backend API:
236
+ - Inventory File: speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/features-api.json
237
+ - Total Features: [N]
238
+ - Status: Generated ✓
239
+
240
+ Final Output:
241
+ - Platform Files:
242
+ - speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/features-web.json
243
+ - speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/features-mobile.json
244
+ - speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/features-api.json
245
+ ```
246
+
247
+ ## Checklist
248
+
249
+ ### Platform Detection
250
+ - [ ] Platforms identified (Web, Mobile, Desktop, or API)
251
+ - [ ] Each platform has correct `platformName`, `platformType`, `techStack` configuration
252
+ - [ ] Source directories located for all platforms
253
+
254
+ ### Inventory Generation
255
+ - [ ] **Inventory scripts executed**: Node.js script generated `features-{platform}.json` files
256
+ - [ ] **Inventory files valid**: JSON structure correct, all features listed
257
+ - [ ] **Total count verified**: `totalFiles` matches actual source file count per platform
258
+ - [ ] **File paths correct**: All `sourcePath` and `documentPath` values are accurate (sourcePath MUST be project-root-relative path)
259
+
260
+ ### Output Generation
261
+ - [ ] All platform inventory files generated in `sync-state` directory
262
+ - [ ] Output path verified
263
+ - [ ] Results reported
264
+
@@ -0,0 +1,34 @@
1
+ {
2
+ "platformName": "Web Frontend",
3
+ "platformType": "web",
4
+ "platformSubtype": "vue",
5
+ "sourcePath": "frontend-web/src/views",
6
+ "techStack": ["vue", "typescript"],
7
+ "modules": ["system"],
8
+ "totalFiles": 25,
9
+ "analyzedCount": 0,
10
+ "pendingCount": 25,
11
+ "generatedAt": "2024-01-15-103000",
12
+ "features": [
13
+ {
14
+ "fileName": "index",
15
+ "sourcePath": "frontend-web/src/views/system/user/index.vue",
16
+ "documentPath": "speccrew-workspace/knowledges/bizs/web-vue/src/views/system/user/index.md",
17
+ "module": "system",
18
+ "analyzed": false,
19
+ "startedAt": null,
20
+ "completedAt": null,
21
+ "analysisNotes": null
22
+ },
23
+ {
24
+ "fileName": "UserForm",
25
+ "sourcePath": "frontend-web/src/views/system/user/UserForm.vue",
26
+ "documentPath": "speccrew-workspace/knowledges/bizs/web-vue/src/views/system/user/UserForm.md",
27
+ "module": "system",
28
+ "analyzed": false,
29
+ "startedAt": null,
30
+ "completedAt": null,
31
+ "analysisNotes": null
32
+ }
33
+ ]
34
+ }