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,269 @@
1
+ # Backend System Design - {ModuleName}
2
+
3
+ > Feature Spec Reference: {FeatureSpecPath}
4
+ > API Contract Reference: {ApiContractPath}
5
+ > Platform: {PlatformId} | Framework: {Framework} | Language: {Language}
6
+
7
+ ## 1. Design Goal
8
+
9
+ {Brief description of what this module implements, referencing Feature Spec function}
10
+
11
+ ## 2. Module Structure
12
+
13
+ ### 2.1 File Layout
14
+
15
+ | File | Layer | Status | Description |
16
+ |------|-------|--------|-------------|
17
+ | {FilePath} | Controller/Service/Repository/Entity | [NEW]/[MODIFIED]/[EXISTING] | {Purpose} |
18
+
19
+ ### 2.2 Dependency Diagram
20
+
21
+ ```mermaid
22
+ graph TD
23
+ A[Controller] --> B[Service]
24
+ B --> C[Repository]
25
+ C --> D[Database]
26
+ B --> E[External Service]
27
+ ```
28
+
29
+ ## 3. Interface Detail Design
30
+
31
+ ### 3.N {API Name} - {HTTP Method} {Path}
32
+
33
+ **Contract Reference**: {link to API Contract section}
34
+
35
+ **Controller Layer**:
36
+
37
+ ```{framework-language}
38
+ // AI-NOTE: Use actual framework annotations/decorators from techs knowledge
39
+ // Spring Boot: @RestController, @PostMapping, @Valid, etc.
40
+ // NestJS: @Controller, @Post, @Body, etc.
41
+ // Go: gin.Context, echo.Context, etc.
42
+
43
+ {Controller pseudo-code with parameter validation}
44
+ ```
45
+
46
+ **Service Layer**:
47
+
48
+ ```{framework-language}
49
+ // AI-NOTE: Business logic implementation
50
+ // Include transaction annotation if needed
51
+
52
+ {Service pseudo-code with step-by-step logic}
53
+ ```
54
+
55
+ **Business Validation Pseudo-code**:
56
+
57
+ <!-- AI-NOTE: Detailed business rule validation patterns -->
58
+
59
+ ```java
60
+ // Business rule validation - detailed conditions
61
+ public void validateOrder(CreateOrderRequest request) {
62
+ // Null/empty checks
63
+ if (request.getItems() == null || request.getItems().isEmpty()) {
64
+ throw new BusinessException("ORDER_EMPTY", "Order must contain at least one item");
65
+ }
66
+ // Business rule: price validation
67
+ for (OrderItem item : request.getItems()) {
68
+ if (item.getQuantity() <= 0) {
69
+ throw new BusinessException("INVALID_QUANTITY", "Quantity must be positive");
70
+ }
71
+ if (item.getPrice().compareTo(BigDecimal.ZERO) < 0) {
72
+ throw new BusinessException("INVALID_PRICE", "Price must be non-negative");
73
+ }
74
+ }
75
+ // Business rule: total amount limit
76
+ BigDecimal total = calculateTotal(request.getItems());
77
+ if (total.compareTo(new BigDecimal("999999.99")) > 0) {
78
+ throw new BusinessException("AMOUNT_EXCEEDED", "Order total exceeds limit");
79
+ }
80
+ }
81
+ ```
82
+
83
+ **Business Flow**:
84
+
85
+ ```mermaid
86
+ flowchart TD
87
+ A[Receive Request] --> B[Validate Parameters]
88
+ B --> C{Business Rule Check}
89
+ C -->|Pass| D[Process Data]
90
+ C -->|Fail| E[Throw Business Exception]
91
+ D --> F[Persist to Database]
92
+ F --> G[Return Response]
93
+ ```
94
+
95
+ **Repository Layer**:
96
+
97
+ ```{framework-language}
98
+ // AI-NOTE: Use actual ORM/query patterns from conventions-data.md
99
+
100
+ {Repository method definitions}
101
+ ```
102
+
103
+ **Request/Response**:
104
+
105
+ | Field | Type | Required | Validation | Description |
106
+ |-------|------|----------|-----------|-------------|
107
+ | {field} | {type} | Yes/No | {rules} | {description} |
108
+
109
+ ## 4. Database Design
110
+
111
+ ### 4.1 Entity Definitions
112
+
113
+ ```{framework-language}
114
+ // AI-NOTE: Use actual ORM entity syntax from conventions-data.md
115
+ // Spring Boot: @Entity, @Table, @Column, etc.
116
+ // NestJS/TypeORM: @Entity, @Column, etc.
117
+
118
+ {Entity class definition with all fields, types, constraints}
119
+ ```
120
+
121
+ ### 4.2 Table Schema
122
+
123
+ | Column | Type | Nullable | Default | Index | Description |
124
+ |--------|------|----------|---------|-------|-------------|
125
+ | {column} | {db type} | Yes/No | {default} | {index type} | {description} |
126
+
127
+ ### 4.3 Index Strategy
128
+
129
+ | Index Name | Columns | Type | Purpose |
130
+ |-----------|---------|------|---------|
131
+ | {name} | {columns} | {UNIQUE/BTREE/...} | {query it optimizes} |
132
+
133
+ ### 4.4 Migration Requirements
134
+
135
+ | Migration | Type | Description |
136
+ |-----------|------|-------------|
137
+ | {migration-name} | CREATE TABLE/ALTER TABLE/ADD INDEX | {what changes} |
138
+
139
+ ## 5. Transaction Design
140
+
141
+ | Operation | Scope | Isolation Level | Rollback Trigger |
142
+ |-----------|-------|----------------|-----------------|
143
+ | {operation} | {which steps} | {level} | {error condition} |
144
+
145
+ ```{framework-language}
146
+ // AI-NOTE: Use actual transaction syntax from techs knowledge
147
+ {Transaction pseudo-code}
148
+ ```
149
+
150
+ ### 5.1 Concurrency Control Pseudo-code
151
+
152
+ <!-- AI-NOTE: Optimistic locking and batch processing patterns -->
153
+
154
+ ```java
155
+ // Optimistic locking with version check
156
+ @Transactional(isolation = Isolation.READ_COMMITTED)
157
+ public void updateStock(Long productId, int quantity, Long expectedVersion) {
158
+ Product product = productRepository.findById(productId)
159
+ .orElseThrow(() -> new NotFoundException("PRODUCT_NOT_FOUND", productId));
160
+
161
+ // Optimistic lock check
162
+ if (!product.getVersion().equals(expectedVersion)) {
163
+ throw new ConcurrentModificationException("Data has been modified by another user");
164
+ }
165
+
166
+ // Business rule: stock boundary check
167
+ int newStock = product.getStock() - quantity;
168
+ if (newStock < 0) {
169
+ throw new BusinessException("INSUFFICIENT_STOCK",
170
+ String.format("Available: %d, Requested: %d", product.getStock(), quantity));
171
+ }
172
+
173
+ product.setStock(newStock);
174
+ productRepository.save(product); // Version auto-incremented by @Version
175
+ }
176
+
177
+ // Batch operation with chunked processing
178
+ @Transactional
179
+ public BatchResult batchImport(List<ImportItem> items) {
180
+ int successCount = 0;
181
+ List<String> errors = new ArrayList<>();
182
+
183
+ // Process in chunks to avoid memory/timeout issues
184
+ List<List<ImportItem>> chunks = Lists.partition(items, 100);
185
+ for (List<ImportItem> chunk : chunks) {
186
+ try {
187
+ repository.saveAll(chunk.stream().map(this::toEntity).collect(toList()));
188
+ successCount += chunk.size();
189
+ } catch (DataIntegrityViolationException e) {
190
+ // Fallback: process one by one to identify problematic records
191
+ for (ImportItem item : chunk) {
192
+ try {
193
+ repository.save(toEntity(item));
194
+ successCount++;
195
+ } catch (Exception ex) {
196
+ errors.add(String.format("Row %d: %s", item.getRowNum(), ex.getMessage()));
197
+ }
198
+ }
199
+ }
200
+ }
201
+ return new BatchResult(successCount, errors);
202
+ }
203
+ ```
204
+
205
+ ## 6. Exception Handling
206
+
207
+ ### 6.1 Exception Types
208
+
209
+ | Exception Class | HTTP Status | Error Code | Trigger Scenario |
210
+ |----------------|-------------|-----------|-----------------|
211
+ | {exception} | {status} | {code from API Contract} | {when thrown} |
212
+
213
+ ### 6.2 Error Response Mapping
214
+
215
+ ```{framework-language}
216
+ // AI-NOTE: Use actual exception handler syntax
217
+ {Global/local exception handler pseudo-code}
218
+ ```
219
+
220
+ ### 6.3 Pagination & Boundary Handling
221
+
222
+ <!-- AI-NOTE: Pagination safety and null-safe data access patterns -->
223
+
224
+ ```java
225
+ // Pagination boundary handling
226
+ public Page<OrderDTO> listOrders(int page, int size, String sortBy) {
227
+ // Boundary normalization
228
+ page = Math.max(0, page);
229
+ size = Math.min(Math.max(1, size), 100); // Limit: 1-100 per page
230
+
231
+ // Validate sort field (prevent SQL injection via sort)
232
+ Set<String> allowedSorts = Set.of("createdAt", "updatedAt", "amount");
233
+ if (!allowedSorts.contains(sortBy)) {
234
+ sortBy = "createdAt"; // Default fallback
235
+ }
236
+
237
+ Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, sortBy));
238
+ Page<Order> orders = orderRepository.findAll(pageable);
239
+
240
+ return orders.map(this::toDTO);
241
+ }
242
+
243
+ // Null-safe data access patterns
244
+ private OrderDTO toDTO(Order order) {
245
+ return OrderDTO.builder()
246
+ .id(order.getId())
247
+ .customerName(Optional.ofNullable(order.getCustomer())
248
+ .map(Customer::getName)
249
+ .orElse("Unknown"))
250
+ .totalAmount(Optional.ofNullable(order.getItems())
251
+ .map(items -> items.stream()
252
+ .map(OrderItem::getSubtotal)
253
+ .reduce(BigDecimal.ZERO, BigDecimal::add))
254
+ .orElse(BigDecimal.ZERO))
255
+ .build();
256
+ }
257
+ ```
258
+
259
+ ## 7. Business Rules Implementation
260
+
261
+ | Rule | Description | Implementation Location | Validation Logic |
262
+ |------|-------------|----------------------|-----------------|
263
+ | {rule} | {description} | {Service/Validator/...} | {pseudo-code or description} |
264
+
265
+ ## 8. Unit Test Points
266
+
267
+ | Test Target | Test Scenario | Input | Expected Output |
268
+ |-------------|--------------|-------|----------------|
269
+ | {class.method} | {scenario} | {test data} | {expected result} |
@@ -0,0 +1,192 @@
1
+ ---
2
+ name: speccrew-sd-desktop
3
+ description: Desktop System Design SOP. Guide System Designer Agent to generate platform-specific desktop detailed design documents by filling technology implementation details into the Feature Spec skeleton. Reads techs knowledge to determine actual framework syntax (Electron/Tauri/Qt) and conventions.
4
+ tools: Read, Write, Glob, Grep
5
+ ---
6
+
7
+ # Trigger Scenarios
8
+
9
+ - System Designer Agent dispatches this skill with platform context (platform_id, techs paths, Feature Spec paths)
10
+ - Feature Spec has been confirmed, user requests desktop system design
11
+ - User asks "Create desktop design for this platform" or "Generate desktop module design"
12
+
13
+ # Workflow
14
+
15
+ ## Step 1: Read Inputs
16
+
17
+ Read in order:
18
+
19
+ 1. **Feature Spec document(s)**: `speccrew-workspace/iterations/{number}-{type}-{name}/02.feature-design/[feature-name]-feature-spec.md`
20
+ 2. **API Contract**: `speccrew-workspace/iterations/{number}-{type}-{name}/02.feature-design/[feature-name]-api-contract.md`
21
+ 3. **Desktop techs knowledge** (paths from agent context):
22
+ - `speccrew-workspace/knowledges/techs/{platform_id}/tech-stack.md`
23
+ - `speccrew-workspace/knowledges/techs/{platform_id}/architecture.md`
24
+ - `speccrew-workspace/knowledges/techs/{platform_id}/conventions-design.md`
25
+ - `speccrew-workspace/knowledges/techs/{platform_id}/conventions-dev.md`
26
+ 4. **Design template**: `speccrew-sd-desktop/templates/SD-DESKTOP-TEMPLATE.md`
27
+ 5. **Index template**: `speccrew-sd-desktop/templates/INDEX-TEMPLATE.md`
28
+
29
+ ## Step 2: Analyze Existing Code Structure
30
+
31
+ Use Glob/Grep to understand current codebase:
32
+
33
+ | Target | Glob Pattern | Purpose |
34
+ |--------|-------------|---------|
35
+ | Main process | `src/main/**/*.{ts,js}` or `src-tauri/src/**/*.rs` | Understand main process structure |
36
+ | Renderer process | `src/renderer/**/*.{tsx,vue,html}` or `src/**/*.{tsx,vue}` | Understand renderer structure |
37
+ | IPC definitions | `src/main/ipc/**/*` or `src-tauri/src/commands/**/*.rs` | Understand IPC channel patterns |
38
+ | Window management | `src/main/window/**/*` or patterns with `BrowserWindow` | Understand window patterns |
39
+ | Preload scripts | `src/preload/**/*` or `preload.{ts,js}` | Understand preload patterns |
40
+ | Native modules | `src/main/native/**/*` or binding files | Identify native dependencies |
41
+ | State management | `src/renderer/stores/**/*` or `src/stores/**/*` | Understand store pattern |
42
+ | API layer | `src/renderer/apis/**/*` or `src/apis/**/*` | Understand API encapsulation |
43
+
44
+ Document findings for reference in later steps.
45
+
46
+ ## Step 3: Extract Functions from Feature Spec
47
+
48
+ Parse Feature Spec to identify all functions (Section 2.N pattern).
49
+
50
+ For each function, extract:
51
+
52
+ | Aspect | Content to Extract |
53
+ |--------|-------------------|
54
+ | UI prototype | ASCII wireframe or description from Feature Spec |
55
+ | Interaction flow | User actions and system responses |
56
+ | Backend API calls | Required API endpoints from API Contract |
57
+ | Local operations | File system, native API, or local DB operations |
58
+ | Data requirements | Fields and structures needed |
59
+
60
+ Mark each function's components/modules as:
61
+
62
+ | Marker | Meaning | Example |
63
+ |--------|---------|---------|
64
+ | `[EXISTING]` | Reuse current component/module | `[EXISTING] UserSelect component` |
65
+ | `[MODIFIED]` | Enhance/change existing | `[MODIFIED] WindowManager - add new window type` |
66
+ | `[NEW]` | Create brand new | `[NEW] FileSyncWorker` |
67
+
68
+ **Checkpoint A: Present function extraction summary to user for confirmation.**
69
+
70
+ ## Step 4: Generate Module Design Documents
71
+
72
+ For each function (or logical group of closely related functions = one module):
73
+
74
+ ### 4.1 Read Template
75
+
76
+ Read `SD-DESKTOP-TEMPLATE.md` for document structure.
77
+
78
+ ### 4.2 Fill Technology-Specific Details
79
+
80
+ Fill each section with technology-specific implementation details:
81
+
82
+ | Section | Technology-Specific Content |
83
+ |---------|----------------------------|
84
+ | Process architecture | Main/Renderer split (Electron) or Rust Core/WebView (Tauri) |
85
+ | IPC channels | Actual channel names and payload types |
86
+ | Window design | Window types, sizes, frame options |
87
+ | Native integration | File system APIs, system tray, menus |
88
+ | Local storage | SQLite/LevelDB/electron-store patterns |
89
+ | Security | Context isolation, preload scripts, CSP |
90
+ | Auto-update | electron-updater or tauri-updater patterns |
91
+ | Pseudo-code | MUST use actual framework syntax from techs knowledge |
92
+
93
+ ### 4.3 Write Module Design
94
+
95
+ Write to: `speccrew-workspace/iterations/{number}-{type}-{name}/03.system-design/{platform_id}/{module}-design.md`
96
+
97
+ **Key Rules for Pseudo-code**:
98
+ - MUST use actual framework API syntax from techs knowledge
99
+ - NOT generic pseudo-code
100
+ - Include actual import statements
101
+ - Use actual IPC/store/API patterns from conventions
102
+ - For Electron: use `ipcMain.handle`, `ipcRenderer.invoke`, `BrowserWindow`
103
+ - For Tauri: use `#[tauri::command]`, `invoke()`, `Window`
104
+
105
+ ## Step 5: Generate Platform INDEX.md
106
+
107
+ After all module designs are complete:
108
+
109
+ ### 5.1 Read Template
110
+
111
+ Read `INDEX-TEMPLATE.md` for document structure.
112
+
113
+ ### 5.2 Fill Platform-Level Summary
114
+
115
+ | Section | Content Source |
116
+ |---------|---------------|
117
+ | Tech stack summary | tech-stack.md |
118
+ | Target operating systems | tech-stack.md OS support |
119
+ | Shared design decisions | architecture.md, conventions-design.md |
120
+ | Process architecture strategy | architecture.md process model |
121
+ | IPC patterns | conventions-design.md IPC section |
122
+ | Security model | architecture.md security section |
123
+ | Native dependencies | tech-stack.md dependencies |
124
+ | Packaging & distribution | architecture.md distribution section |
125
+
126
+ ### 5.3 Build Module List
127
+
128
+ Create table with links to each module design document.
129
+
130
+ ### 5.4 Write INDEX
131
+
132
+ Write to: `speccrew-workspace/iterations/{number}-{type}-{name}/03.system-design/{platform_id}/INDEX.md`
133
+
134
+ ## Step 6: Present Summary
135
+
136
+ Present to user:
137
+
138
+ ```
139
+ Desktop System Design Summary for: {feature-name}
140
+ Platform: {platform_id}
141
+ Framework: {Electron/Tauri/Qt}
142
+
143
+ Module Design Documents: {count}
144
+ ├── {module1}-design.md
145
+ ├── {module2}-design.md
146
+ └── ...
147
+
148
+ Key Design Decisions:
149
+ - Process Architecture: {approach}
150
+ - IPC Strategy: {approach}
151
+ - State Management: {approach}
152
+ - Security Model: {approach}
153
+ - Auto-Update: {approach}
154
+
155
+ Concerns/Trade-offs:
156
+ - {list any concerns}
157
+ ```
158
+
159
+ **Ask user to confirm:**
160
+ 1. Are the process architectures appropriate?
161
+ 2. Is the IPC communication design correct?
162
+ 3. Do the pseudo-code patterns match project conventions?
163
+ 4. Are all API calls from API Contract covered?
164
+ 5. Is the native integration approach suitable?
165
+
166
+ # Key Rules
167
+
168
+ | Rule | Description |
169
+ |------|-------------|
170
+ | **Actual Framework Syntax** | All pseudo-code MUST use actual framework/library syntax from techs knowledge, NOT generic code |
171
+ | **API Contract READ-ONLY** | API Contract is reference only - do not modify |
172
+ | **One Module Per Function Group** | Each module design document maps to one or more related Feature Spec functions |
173
+ | **Status Markers Required** | Use [EXISTING], [MODIFIED], [NEW] markers for all components, modules, and IPC handlers |
174
+ | **Follow Techs Conventions** | Naming, directory structure, patterns must follow techs knowledge |
175
+ | **Desktop-Specific Concerns** | Must address process architecture, IPC, native integration, local storage, auto-update |
176
+
177
+ # Checklist
178
+
179
+ - [ ] All techs knowledge documents loaded before design
180
+ - [ ] Existing code structure analyzed via Glob/Grep
181
+ - [ ] Every Feature Spec function covered in a module design
182
+ - [ ] All API calls from API Contract referenced correctly
183
+ - [ ] Pseudo-code uses actual framework syntax (not generic)
184
+ - [ ] Process architecture follows conventions-design.md
185
+ - [ ] IPC channels follow naming conventions from techs
186
+ - [ ] Window management follows existing patterns
187
+ - [ ] Native integration uses correct APIs
188
+ - [ ] Security design includes context isolation and CSP
189
+ - [ ] Auto-update mechanism specified
190
+ - [ ] INDEX.md generated with complete module list
191
+ - [ ] All files written to correct paths under 03.system-design/{platform_id}/
192
+ - [ ] Checkpoint A passed: function extraction confirmed with user