kiro-spec-engine 1.2.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/README.md +239 -213
  3. package/README.zh.md +0 -330
  4. package/bin/kiro-spec-engine.js +62 -0
  5. package/docs/README.md +223 -0
  6. package/docs/agent-hooks-analysis.md +815 -0
  7. package/docs/command-reference.md +252 -0
  8. package/docs/cross-tool-guide.md +554 -0
  9. package/docs/examples/add-export-command/design.md +194 -0
  10. package/docs/examples/add-export-command/requirements.md +110 -0
  11. package/docs/examples/add-export-command/tasks.md +88 -0
  12. package/docs/examples/add-rest-api/design.md +855 -0
  13. package/docs/examples/add-rest-api/requirements.md +323 -0
  14. package/docs/examples/add-rest-api/tasks.md +355 -0
  15. package/docs/examples/add-user-dashboard/design.md +192 -0
  16. package/docs/examples/add-user-dashboard/requirements.md +143 -0
  17. package/docs/examples/add-user-dashboard/tasks.md +91 -0
  18. package/docs/faq.md +696 -0
  19. package/docs/integration-modes.md +525 -0
  20. package/docs/integration-philosophy.md +313 -0
  21. package/docs/manual-workflows-guide.md +417 -0
  22. package/docs/quick-start-with-ai-tools.md +374 -0
  23. package/docs/quick-start.md +711 -0
  24. package/docs/spec-workflow.md +453 -0
  25. package/docs/steering-strategy-guide.md +196 -0
  26. package/docs/tools/claude-guide.md +653 -0
  27. package/docs/tools/cursor-guide.md +705 -0
  28. package/docs/tools/generic-guide.md +445 -0
  29. package/docs/tools/kiro-guide.md +308 -0
  30. package/docs/tools/vscode-guide.md +444 -0
  31. package/docs/tools/windsurf-guide.md +390 -0
  32. package/docs/troubleshooting.md +795 -0
  33. package/docs/zh/README.md +275 -0
  34. package/docs/zh/quick-start.md +711 -0
  35. package/docs/zh/tools/claude-guide.md +348 -0
  36. package/docs/zh/tools/cursor-guide.md +280 -0
  37. package/docs/zh/tools/generic-guide.md +498 -0
  38. package/docs/zh/tools/kiro-guide.md +342 -0
  39. package/docs/zh/tools/vscode-guide.md +448 -0
  40. package/docs/zh/tools/windsurf-guide.md +377 -0
  41. package/lib/adoption/detection-engine.js +14 -4
  42. package/lib/commands/adopt.js +117 -3
  43. package/lib/commands/context.js +99 -0
  44. package/lib/commands/prompt.js +105 -0
  45. package/lib/commands/status.js +225 -0
  46. package/lib/commands/task.js +199 -0
  47. package/lib/commands/watch.js +569 -0
  48. package/lib/commands/workflows.js +240 -0
  49. package/lib/commands/workspace.js +189 -0
  50. package/lib/context/context-exporter.js +378 -0
  51. package/lib/context/prompt-generator.js +482 -0
  52. package/lib/steering/adoption-config.js +164 -0
  53. package/lib/steering/steering-manager.js +289 -0
  54. package/lib/task/task-claimer.js +430 -0
  55. package/lib/utils/tool-detector.js +383 -0
  56. package/lib/watch/action-executor.js +458 -0
  57. package/lib/watch/event-debouncer.js +323 -0
  58. package/lib/watch/execution-logger.js +550 -0
  59. package/lib/watch/file-watcher.js +499 -0
  60. package/lib/watch/presets.js +266 -0
  61. package/lib/watch/watch-manager.js +533 -0
  62. package/lib/workspace/workspace-manager.js +370 -0
  63. package/lib/workspace/workspace-sync.js +356 -0
  64. package/package.json +3 -1
  65. package/template/.kiro/tools/backup_manager.py +295 -0
  66. package/template/.kiro/tools/configuration_manager.py +218 -0
  67. package/template/.kiro/tools/document_evaluator.py +550 -0
  68. package/template/.kiro/tools/enhancement_logger.py +168 -0
  69. package/template/.kiro/tools/error_handler.py +335 -0
  70. package/template/.kiro/tools/improvement_identifier.py +444 -0
  71. package/template/.kiro/tools/modification_applicator.py +737 -0
  72. package/template/.kiro/tools/quality_gate_enforcer.py +207 -0
  73. package/template/.kiro/tools/quality_scorer.py +305 -0
  74. package/template/.kiro/tools/report_generator.py +154 -0
  75. package/template/.kiro/tools/ultrawork_enhancer_refactored.py +0 -0
  76. package/template/.kiro/tools/ultrawork_enhancer_v2.py +463 -0
  77. package/template/.kiro/tools/ultrawork_enhancer_v3.py +606 -0
  78. package/template/.kiro/tools/workflow_quality_gate.py +100 -0
@@ -0,0 +1,444 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Improvement Identifier - 改进识别组件
4
+
5
+ 负责分析质量评估结果,识别具体的改进点
6
+ """
7
+
8
+ import re
9
+ from typing import List, Optional
10
+ from dataclasses import dataclass
11
+ from enum import Enum
12
+
13
+
14
+ class ImprovementType(Enum):
15
+ """改进类型"""
16
+ ADD_SECTION = "add_section"
17
+ ENHANCE_CRITERIA = "enhance_criteria"
18
+ ADD_NFR = "add_nfr"
19
+ ADD_ERROR_HANDLING = "add_error_handling"
20
+ ADD_EDGE_CASES = "add_edge_cases"
21
+ ADD_GLOSSARY_TERM = "add_glossary_term"
22
+ ADD_COMPONENT_DETAIL = "add_component_detail"
23
+ ADD_TRACEABILITY = "add_traceability"
24
+ ADD_PROPERTIES = "add_properties"
25
+ ADD_RATIONALE = "add_rationale"
26
+ ADD_DIAGRAM = "add_diagram"
27
+
28
+
29
+ class Priority(Enum):
30
+ """优先级"""
31
+ HIGH = "high"
32
+ MEDIUM = "medium"
33
+ LOW = "low"
34
+
35
+
36
+ @dataclass
37
+ class Improvement:
38
+ """改进项"""
39
+ type: ImprovementType
40
+ target_section: str
41
+ description: str
42
+ priority: Priority
43
+ template: Optional[str] = None
44
+ metadata: dict = None
45
+
46
+ def __post_init__(self):
47
+ if self.metadata is None:
48
+ self.metadata = {}
49
+
50
+
51
+ class ImprovementIdentifier:
52
+ """
53
+ 改进识别器 - 识别文档改进点
54
+
55
+ 支持中英文文档
56
+ """
57
+
58
+ def __init__(self):
59
+ self.language = 'en'
60
+
61
+ def identify_requirements_improvements(self, content: str, assessment) -> List[Improvement]:
62
+ """识别 Requirements 文档的改进点 - 支持中英文,增强改进识别"""
63
+ improvements = []
64
+ lang = assessment.language
65
+ self.language = lang
66
+
67
+ if lang == 'zh':
68
+ # 中文改进建议 - 增强版
69
+ # 检查基础结构
70
+ if "## 1. 概述" not in content and "## Introduction" not in content and "## 概述" not in content:
71
+ improvements.append(Improvement(
72
+ type=ImprovementType.ADD_SECTION,
73
+ target_section="概述",
74
+ description="添加项目概述章节,包括项目背景和目标",
75
+ priority=Priority.HIGH,
76
+ template="introduction_zh"
77
+ ))
78
+
79
+ if "## 2. 用户故事" not in content and "用户故事" not in content:
80
+ improvements.append(Improvement(
81
+ type=ImprovementType.ADD_SECTION,
82
+ target_section="用户故事",
83
+ description="添加用户故事章节,描述用户需求",
84
+ priority=Priority.HIGH,
85
+ template="user_stories_zh"
86
+ ))
87
+
88
+ if "## 3. 功能需求" not in content and "功能需求" not in content:
89
+ improvements.append(Improvement(
90
+ type=ImprovementType.ADD_SECTION,
91
+ target_section="功能需求",
92
+ description="添加功能需求章节",
93
+ priority=Priority.HIGH,
94
+ template="functional_requirements_zh"
95
+ ))
96
+
97
+ if "## 4. 非功能需求" not in content and "非功能需求" not in content:
98
+ improvements.append(Improvement(
99
+ type=ImprovementType.ADD_NFR,
100
+ target_section="非功能需求",
101
+ description="添加非功能需求章节,包括性能、安全等",
102
+ priority=Priority.MEDIUM,
103
+ template="nfr_section_zh"
104
+ ))
105
+
106
+ # 检查 EARS 格式
107
+ ears_count = len(re.findall(r'(?:WHEN|当|如果).*?(?:THEN|那么|则).*?(?:SHALL|应该|必须)', content, re.IGNORECASE | re.DOTALL))
108
+ if ears_count < 5:
109
+ improvements.append(Improvement(
110
+ type=ImprovementType.ENHANCE_CRITERIA,
111
+ target_section="验收标准",
112
+ description=f"增加更多 EARS 格式的验收标准 (当前 {ears_count},目标 5+)",
113
+ priority=Priority.HIGH,
114
+ template="ears_criteria_zh",
115
+ metadata={'current_count': ears_count, 'target_count': 5}
116
+ ))
117
+
118
+ # 检查用户故事格式
119
+ user_story_count = len(re.findall(r'(?:作为|As a).*?(?:我希望|I want).*?(?:以便|So that)', content, re.IGNORECASE | re.DOTALL))
120
+ if user_story_count < 3:
121
+ improvements.append(Improvement(
122
+ type=ImprovementType.ENHANCE_CRITERIA,
123
+ target_section="用户故事",
124
+ description=f"完善用户故事格式 (当前 {user_story_count},目标 3+)",
125
+ priority=Priority.HIGH,
126
+ template="user_story_format_zh",
127
+ metadata={'current_count': user_story_count, 'target_count': 3}
128
+ ))
129
+
130
+ # 检查验收标准完整性
131
+ acceptance_criteria = len(re.findall(r'(?:\*\*验收标准\*\*:|Acceptance Criteria)', content, re.IGNORECASE))
132
+ requirements_count = len(re.findall(r'### \d+\.\d+', content))
133
+ if requirements_count > 0 and acceptance_criteria < requirements_count:
134
+ improvements.append(Improvement(
135
+ type=ImprovementType.ENHANCE_CRITERIA,
136
+ target_section="验收标准",
137
+ description=f"为所有需求添加验收标准 ({acceptance_criteria}/{requirements_count})",
138
+ priority=Priority.HIGH,
139
+ metadata={'current': acceptance_criteria, 'total': requirements_count}
140
+ ))
141
+
142
+ # 检查非功能需求覆盖
143
+ nfr_keywords = ['性能', '安全', '可用性', '可维护性', '兼容性', '可扩展性']
144
+ missing_nfr = [kw for kw in nfr_keywords if kw not in content]
145
+
146
+ if missing_nfr and ("## 4. 非功能需求" in content or "非功能需求" in content):
147
+ improvements.append(Improvement(
148
+ type=ImprovementType.ADD_NFR,
149
+ target_section="非功能需求",
150
+ description=f"补充非功能需求: {', '.join(missing_nfr[:3])}",
151
+ priority=Priority.MEDIUM,
152
+ template="nfr_items_zh",
153
+ metadata={'missing_nfr': missing_nfr}
154
+ ))
155
+
156
+ # 检查错误处理需求
157
+ if "错误处理" not in content and "异常处理" not in content:
158
+ improvements.append(Improvement(
159
+ type=ImprovementType.ADD_ERROR_HANDLING,
160
+ target_section="功能需求",
161
+ description="添加错误处理和异常情况需求",
162
+ priority=Priority.MEDIUM,
163
+ template="error_handling_zh"
164
+ ))
165
+
166
+ # 检查边界条件
167
+ edge_case_keywords = ['边界', '极限', '最大', '最小', '空值', '异常']
168
+ edge_case_count = sum(1 for kw in edge_case_keywords if kw in content)
169
+ if edge_case_count < 2:
170
+ improvements.append(Improvement(
171
+ type=ImprovementType.ADD_EDGE_CASES,
172
+ target_section="验收标准",
173
+ description="添加边界条件和极限情况的验收标准",
174
+ priority=Priority.MEDIUM,
175
+ template="edge_cases_zh"
176
+ ))
177
+
178
+ # 检查约束条件
179
+ if "约束条件" not in content and "限制" not in content:
180
+ improvements.append(Improvement(
181
+ type=ImprovementType.ADD_SECTION,
182
+ target_section="约束条件",
183
+ description="添加约束条件和限制说明",
184
+ priority=Priority.LOW,
185
+ template="constraints_zh"
186
+ ))
187
+ else:
188
+ # 英文改进建议 - 增强版
189
+ # 检查基础结构
190
+ if "## Introduction" not in content and "## Overview" not in content:
191
+ improvements.append(Improvement(
192
+ type=ImprovementType.ADD_SECTION,
193
+ target_section="Introduction",
194
+ description="Add Introduction or Overview section with project background and goals",
195
+ priority=Priority.HIGH,
196
+ template="introduction_en"
197
+ ))
198
+
199
+ if "## Glossary" not in content and "## Terminology" not in content:
200
+ improvements.append(Improvement(
201
+ type=ImprovementType.ADD_GLOSSARY_TERM,
202
+ target_section="Glossary",
203
+ description="Add Glossary section to define key terms",
204
+ priority=Priority.MEDIUM,
205
+ template="glossary_en"
206
+ ))
207
+
208
+ if "User Story" not in content and "user story" not in content.lower():
209
+ improvements.append(Improvement(
210
+ type=ImprovementType.ADD_SECTION,
211
+ target_section="User Stories",
212
+ description="Add User Stories section",
213
+ priority=Priority.HIGH,
214
+ template="user_stories_en"
215
+ ))
216
+
217
+ if "## Requirements" not in content and "## Functional Requirements" not in content:
218
+ improvements.append(Improvement(
219
+ type=ImprovementType.ADD_SECTION,
220
+ target_section="Requirements",
221
+ description="Add Requirements or Functional Requirements section",
222
+ priority=Priority.HIGH,
223
+ template="functional_requirements_en"
224
+ ))
225
+
226
+ # 检查 EARS 格式
227
+ ears_count = len(re.findall(r'(?:WHEN|IF|WHILE|WHERE).*?(?:THEN|THE\s+system\s+SHALL)', content, re.IGNORECASE | re.DOTALL))
228
+ if ears_count < 5:
229
+ improvements.append(Improvement(
230
+ type=ImprovementType.ENHANCE_CRITERIA,
231
+ target_section="Acceptance Criteria",
232
+ description=f"Add more EARS-format acceptance criteria (currently {ears_count}, target 5+)",
233
+ priority=Priority.HIGH,
234
+ template="ears_criteria_en",
235
+ metadata={'current_count': ears_count, 'target_count': 5}
236
+ ))
237
+
238
+ # 检查用户故事格式
239
+ user_story_count = len(re.findall(r'(?:As a|As an).*?I want.*?(?:So that|so that)', content, re.IGNORECASE | re.DOTALL))
240
+ if user_story_count < 3:
241
+ improvements.append(Improvement(
242
+ type=ImprovementType.ENHANCE_CRITERIA,
243
+ target_section="User Stories",
244
+ description=f"Add more user stories in 'As a...I want...So that' format (currently {user_story_count}, target 3+)",
245
+ priority=Priority.HIGH,
246
+ template="user_story_format_en",
247
+ metadata={'current_count': user_story_count, 'target_count': 3}
248
+ ))
249
+
250
+ # 检查验收标准完整性
251
+ acceptance_criteria = len(re.findall(r'(?:Acceptance Criteria|#### Acceptance Criteria)', content, re.IGNORECASE))
252
+ requirements_count = len(re.findall(r'### Requirement \d+', content, re.IGNORECASE))
253
+ if requirements_count > 0 and acceptance_criteria < requirements_count:
254
+ improvements.append(Improvement(
255
+ type=ImprovementType.ENHANCE_CRITERIA,
256
+ target_section="Acceptance Criteria",
257
+ description=f"Add acceptance criteria for all requirements ({acceptance_criteria}/{requirements_count})",
258
+ priority=Priority.HIGH,
259
+ metadata={'current': acceptance_criteria, 'total': requirements_count}
260
+ ))
261
+
262
+ # 检查非功能需求
263
+ nfr_keywords = ['performance', 'security', 'usability', 'maintainability', 'scalability', 'reliability']
264
+ missing_nfr = [kw for kw in nfr_keywords if kw.lower() not in content.lower()]
265
+
266
+ if len(missing_nfr) > 2:
267
+ improvements.append(Improvement(
268
+ type=ImprovementType.ADD_NFR,
269
+ target_section="Non-functional Requirements",
270
+ description=f"Add non-functional requirements: {', '.join(missing_nfr[:3])}",
271
+ priority=Priority.MEDIUM,
272
+ template="nfr_section_en",
273
+ metadata={'missing_nfr': missing_nfr[:3]}
274
+ ))
275
+
276
+ # 检查错误处理需求
277
+ if "error handling" not in content.lower() and "exception" not in content.lower():
278
+ improvements.append(Improvement(
279
+ type=ImprovementType.ADD_ERROR_HANDLING,
280
+ target_section="Requirements",
281
+ description="Add error handling and exception requirements",
282
+ priority=Priority.MEDIUM,
283
+ template="error_handling_en"
284
+ ))
285
+
286
+ # 检查边界条件
287
+ edge_case_keywords = ['boundary', 'edge case', 'limit', 'maximum', 'minimum', 'empty', 'null']
288
+ edge_case_count = sum(1 for kw in edge_case_keywords if kw.lower() in content.lower())
289
+ if edge_case_count < 2:
290
+ improvements.append(Improvement(
291
+ type=ImprovementType.ADD_EDGE_CASES,
292
+ target_section="Acceptance Criteria",
293
+ description="Add boundary conditions and edge cases to acceptance criteria",
294
+ priority=Priority.MEDIUM,
295
+ template="edge_cases_en"
296
+ ))
297
+
298
+ # 检查约束条件
299
+ if "constraint" not in content.lower() and "limitation" not in content.lower():
300
+ improvements.append(Improvement(
301
+ type=ImprovementType.ADD_SECTION,
302
+ target_section="Constraints",
303
+ description="Add constraints and limitations section",
304
+ priority=Priority.LOW,
305
+ template="constraints_en"
306
+ ))
307
+
308
+ return improvements
309
+
310
+ def identify_design_improvements(self, design_content: str, requirements_content: str, assessment) -> List[Improvement]:
311
+ """识别 Design 文档的改进点 - 增强版"""
312
+ improvements = []
313
+ lang = assessment.language
314
+ self.language = lang
315
+
316
+ # 检查基础结构
317
+ if "## 1. 系统概述" not in design_content and "## 1. 概述" not in design_content and "## Overview" not in design_content:
318
+ improvements.append(Improvement(
319
+ type=ImprovementType.ADD_SECTION,
320
+ target_section="系统概述" if lang == 'zh' else "Overview",
321
+ description="添加系统概述章节,包括设计目标和方法" if lang == 'zh' else "Add system overview section with design goals and approach",
322
+ priority=Priority.HIGH,
323
+ template="overview_zh" if lang == 'zh' else "overview_en"
324
+ ))
325
+
326
+ if "## 2. 架构设计" not in design_content and "## Architecture" not in design_content:
327
+ improvements.append(Improvement(
328
+ type=ImprovementType.ADD_SECTION,
329
+ target_section="架构设计" if lang == 'zh' else "Architecture",
330
+ description="添加架构设计章节,包括系统架构图" if lang == 'zh' else "Add architecture design section with system architecture diagram",
331
+ priority=Priority.HIGH,
332
+ template="architecture_zh" if lang == 'zh' else "architecture_en"
333
+ ))
334
+
335
+ if "## 3. 组件设计" not in design_content and "## Components" not in design_content:
336
+ improvements.append(Improvement(
337
+ type=ImprovementType.ADD_COMPONENT_DETAIL,
338
+ target_section="组件设计" if lang == 'zh' else "Components",
339
+ description="添加组件设计章节,详细描述各组件" if lang == 'zh' else "Add components design section with detailed component descriptions",
340
+ priority=Priority.HIGH,
341
+ template="components_zh" if lang == 'zh' else "components_en"
342
+ ))
343
+
344
+ # 检查需求追溯
345
+ req_references = len(re.findall(r'(?:需求|Requirements?|Validates:)\s*\d+\.\d+', design_content, re.IGNORECASE))
346
+ bidirectional_refs = len(re.findall(r'Validates:\s*Requirements?\s+\d+\.\d+', design_content, re.IGNORECASE))
347
+
348
+ if req_references < 3:
349
+ improvements.append(Improvement(
350
+ type=ImprovementType.ADD_TRACEABILITY,
351
+ target_section="全文" if lang == 'zh' else "全文",
352
+ description=f"增加需求到设计的双向追溯 (当前 {req_references},目标 5+)" if lang == 'zh' else f"Add requirements traceability (current {req_references}, target 5+)",
353
+ priority=Priority.HIGH,
354
+ template="traceability_zh" if lang == 'zh' else "traceability_en",
355
+ metadata={'current_count': req_references, 'target_count': 5}
356
+ ))
357
+
358
+ if bidirectional_refs == 0:
359
+ improvements.append(Improvement(
360
+ type=ImprovementType.ADD_TRACEABILITY,
361
+ target_section="组件设计" if lang == 'zh' else "Components",
362
+ description="为设计元素添加 'Validates: Requirements X.Y' 注释" if lang == 'zh' else "Add 'Validates: Requirements X.Y' annotations to design elements",
363
+ priority=Priority.HIGH,
364
+ template="validates_annotation"
365
+ ))
366
+
367
+ # 检查架构图
368
+ mermaid_count = len(re.findall(r'```mermaid', design_content))
369
+ if mermaid_count == 0:
370
+ improvements.append(Improvement(
371
+ type=ImprovementType.ADD_DIAGRAM,
372
+ target_section="架构设计" if lang == 'zh' else "Architecture",
373
+ description="添加 Mermaid 架构图或设计图" if lang == 'zh' else "Add Mermaid architecture or design diagrams",
374
+ priority=Priority.MEDIUM,
375
+ template="mermaid_diagram_zh" if lang == 'zh' else "mermaid_diagram_en"
376
+ ))
377
+
378
+ # 检查组件详细度
379
+ component_sections = len(re.findall(r'### \d+\.\d+', design_content))
380
+ if component_sections < 3:
381
+ improvements.append(Improvement(
382
+ type=ImprovementType.ADD_COMPONENT_DETAIL,
383
+ target_section="组件设计" if lang == 'zh' else "Components",
384
+ description=f"增加更多组件描述 (当前 {component_sections},建议 3+)" if lang == 'zh' else f"Add more component descriptions (current {component_sections}, suggest 3+)",
385
+ priority=Priority.MEDIUM,
386
+ metadata={'current_count': component_sections}
387
+ ))
388
+
389
+ # 检查接口定义
390
+ interface_count = len(re.findall(r'(?:接口定义|Interface|API)', design_content, re.IGNORECASE))
391
+ if interface_count < 2:
392
+ improvements.append(Improvement(
393
+ type=ImprovementType.ADD_COMPONENT_DETAIL,
394
+ target_section="组件设计" if lang == 'zh' else "Components",
395
+ description="为组件添加接口定义和方法签名" if lang == 'zh' else "Add interface definitions and method signatures to components",
396
+ priority=Priority.MEDIUM,
397
+ template="interface_definition"
398
+ ))
399
+
400
+ # 检查技术选型
401
+ tech_keywords = ['技术选型', '技术栈', '框架选择'] if lang == 'zh' else ['technology', 'framework', 'stack']
402
+ if not any(keyword.lower() in design_content.lower() for keyword in tech_keywords):
403
+ improvements.append(Improvement(
404
+ type=ImprovementType.ADD_RATIONALE,
405
+ target_section="技术选型" if lang == 'zh' else "Technology Stack",
406
+ description="补充技术选型说明和选型理由" if lang == 'zh' else "Add technology stack explanation and rationale",
407
+ priority=Priority.MEDIUM,
408
+ template="technology_stack_zh" if lang == 'zh' else "technology_stack_en"
409
+ ))
410
+
411
+ # 检查错误处理策略
412
+ if "错误处理" not in design_content and "Error Handling" not in design_content:
413
+ improvements.append(Improvement(
414
+ type=ImprovementType.ADD_SECTION,
415
+ target_section="错误处理" if lang == 'zh' else "Error Handling",
416
+ description="添加错误处理策略章节" if lang == 'zh' else "Add error handling strategy section",
417
+ priority=Priority.MEDIUM,
418
+ template="error_handling_design_zh" if lang == 'zh' else "error_handling_design_en"
419
+ ))
420
+
421
+ # 检查非功能需求设计
422
+ nfr_design = ['性能设计', '安全设计', '可扩展性'] if lang == 'zh' else ['performance', 'security', 'scalability']
423
+ missing_nfr = [nfr for nfr in nfr_design if nfr.lower() not in design_content.lower()]
424
+ if len(missing_nfr) >= 2:
425
+ improvements.append(Improvement(
426
+ type=ImprovementType.ADD_COMPONENT_DETAIL,
427
+ target_section="非功能需求设计" if lang == 'zh' else "Non-functional Design",
428
+ description=f"补充非功能需求设计: {', '.join(missing_nfr)}" if lang == 'zh' else f"Add non-functional design: {', '.join(missing_nfr)}",
429
+ priority=Priority.MEDIUM,
430
+ template="nfr_design_zh" if lang == 'zh' else "nfr_design_en",
431
+ metadata={'missing_nfr': missing_nfr}
432
+ ))
433
+
434
+ # 检查正确性属性
435
+ if "Correctness Properties" not in design_content and "正确性属性" not in design_content:
436
+ improvements.append(Improvement(
437
+ type=ImprovementType.ADD_PROPERTIES,
438
+ target_section="正确性属性" if lang == 'zh' else "Correctness Properties",
439
+ description="添加正确性属性章节,用于属性测试" if lang == 'zh' else "Add correctness properties section for property-based testing",
440
+ priority=Priority.LOW,
441
+ template="correctness_properties_zh" if lang == 'zh' else "correctness_properties_en"
442
+ ))
443
+
444
+ return improvements