super-dev 2.0.0__py3-none-any.whl
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.
- super_dev/__init__.py +11 -0
- super_dev/analyzer/__init__.py +34 -0
- super_dev/analyzer/analyzer.py +440 -0
- super_dev/analyzer/detectors.py +511 -0
- super_dev/analyzer/models.py +285 -0
- super_dev/cli.py +3257 -0
- super_dev/config/__init__.py +11 -0
- super_dev/config/frontend.py +557 -0
- super_dev/config/manager.py +281 -0
- super_dev/creators/__init__.py +26 -0
- super_dev/creators/creator.py +134 -0
- super_dev/creators/document_generator.py +2473 -0
- super_dev/creators/frontend_builder.py +371 -0
- super_dev/creators/implementation_builder.py +789 -0
- super_dev/creators/prompt_generator.py +289 -0
- super_dev/creators/requirement_parser.py +354 -0
- super_dev/creators/spec_builder.py +195 -0
- super_dev/deployers/__init__.py +20 -0
- super_dev/deployers/cicd.py +1269 -0
- super_dev/deployers/delivery.py +229 -0
- super_dev/deployers/migration.py +1032 -0
- super_dev/design/__init__.py +74 -0
- super_dev/design/aesthetics.py +530 -0
- super_dev/design/charts.py +396 -0
- super_dev/design/codegen.py +379 -0
- super_dev/design/engine.py +528 -0
- super_dev/design/generator.py +395 -0
- super_dev/design/landing.py +422 -0
- super_dev/design/tech_stack.py +524 -0
- super_dev/design/tokens.py +269 -0
- super_dev/design/ux_guide.py +391 -0
- super_dev/exceptions.py +119 -0
- super_dev/experts/__init__.py +19 -0
- super_dev/experts/service.py +161 -0
- super_dev/integrations/__init__.py +7 -0
- super_dev/integrations/manager.py +264 -0
- super_dev/orchestrator/__init__.py +12 -0
- super_dev/orchestrator/engine.py +958 -0
- super_dev/orchestrator/experts.py +423 -0
- super_dev/orchestrator/knowledge.py +352 -0
- super_dev/orchestrator/quality.py +356 -0
- super_dev/reviewers/__init__.py +17 -0
- super_dev/reviewers/code_review.py +471 -0
- super_dev/reviewers/quality_gate.py +964 -0
- super_dev/reviewers/redteam.py +881 -0
- super_dev/skills/__init__.py +7 -0
- super_dev/skills/manager.py +307 -0
- super_dev/specs/__init__.py +44 -0
- super_dev/specs/generator.py +264 -0
- super_dev/specs/manager.py +428 -0
- super_dev/specs/models.py +348 -0
- super_dev/specs/validator.py +415 -0
- super_dev/utils/__init__.py +11 -0
- super_dev/utils/logger.py +133 -0
- super_dev/web/api.py +1402 -0
- super_dev-2.0.0.dist-info/METADATA +252 -0
- super_dev-2.0.0.dist-info/RECORD +61 -0
- super_dev-2.0.0.dist-info/WHEEL +5 -0
- super_dev-2.0.0.dist-info/entry_points.txt +2 -0
- super_dev-2.0.0.dist-info/licenses/LICENSE +21 -0
- super_dev-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Spec-Driven Development 数据模型
|
|
3
|
+
|
|
4
|
+
开发:Excellent(11964948@qq.com)
|
|
5
|
+
功能:定义 SDD 的核心数据结构
|
|
6
|
+
作用:Spec、Change、Proposal、Task 等模型
|
|
7
|
+
创建时间:2025-12-30
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from dataclasses import dataclass, field
|
|
11
|
+
from datetime import datetime
|
|
12
|
+
from enum import Enum
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ChangeStatus(Enum):
|
|
16
|
+
"""变更状态"""
|
|
17
|
+
DRAFT = "draft" # 草稿
|
|
18
|
+
PROPOSED = "proposed" # 已提议
|
|
19
|
+
APPROVED = "approved" # 已批准
|
|
20
|
+
IN_PROGRESS = "in_progress" # 进行中
|
|
21
|
+
COMPLETED = "completed" # 已完成
|
|
22
|
+
ARCHIVED = "archived" # 已归档
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TaskStatus(Enum):
|
|
26
|
+
"""任务状态"""
|
|
27
|
+
PENDING = "pending" # 待处理
|
|
28
|
+
IN_PROGRESS = "in_progress" # 进行中
|
|
29
|
+
COMPLETED = "completed" # 已完成
|
|
30
|
+
SKIPPED = "skipped" # 已跳过
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class DeltaType(Enum):
|
|
34
|
+
"""增量类型"""
|
|
35
|
+
ADDED = "added" # 新增
|
|
36
|
+
MODIFIED = "modified" # 修改
|
|
37
|
+
REMOVED = "removed" # 删除
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass
|
|
41
|
+
class Scenario:
|
|
42
|
+
"""场景 - 需求的具体场景"""
|
|
43
|
+
given: str = "" # 前置条件
|
|
44
|
+
when: str = "" # 触发事件
|
|
45
|
+
then: str = "" # 预期结果
|
|
46
|
+
|
|
47
|
+
def to_markdown(self) -> str:
|
|
48
|
+
"""转换为 Markdown"""
|
|
49
|
+
lines = []
|
|
50
|
+
if self.given:
|
|
51
|
+
lines.append(f"- GIVEN {self.given}")
|
|
52
|
+
if self.when:
|
|
53
|
+
lines.append(f"- WHEN {self.when}")
|
|
54
|
+
if self.then:
|
|
55
|
+
lines.append(f"- THEN {self.then}")
|
|
56
|
+
return "\n".join(lines) if lines else "- (TBD)"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@dataclass
|
|
60
|
+
class Requirement:
|
|
61
|
+
"""需求 - 功能需求"""
|
|
62
|
+
name: str # 需求名称
|
|
63
|
+
description: str = "" # 需求描述
|
|
64
|
+
keyword: str = "SHALL" # 关键词 (SHALL/MUST/SHOULD/MAY)
|
|
65
|
+
scenarios: list[Scenario] = field(default_factory=list)
|
|
66
|
+
|
|
67
|
+
def to_markdown(self, level: int = 3) -> str:
|
|
68
|
+
"""转换为 Markdown"""
|
|
69
|
+
lines = [
|
|
70
|
+
f"{'#' * level} Requirement: {self.name}",
|
|
71
|
+
""
|
|
72
|
+
]
|
|
73
|
+
if self.description:
|
|
74
|
+
lines.append(f"{self.keyword} {self.description}")
|
|
75
|
+
lines.append("")
|
|
76
|
+
|
|
77
|
+
if self.scenarios:
|
|
78
|
+
for i, scenario in enumerate(self.scenarios, 1):
|
|
79
|
+
lines.append(f"#### Scenario {i}: {scenario.when or 'TBD'}")
|
|
80
|
+
lines.append(scenario.to_markdown())
|
|
81
|
+
lines.append("")
|
|
82
|
+
|
|
83
|
+
return "\n".join(lines)
|
|
84
|
+
|
|
85
|
+
def to_dict(self) -> dict:
|
|
86
|
+
"""转换为字典"""
|
|
87
|
+
return {
|
|
88
|
+
"name": self.name,
|
|
89
|
+
"description": self.description,
|
|
90
|
+
"keyword": self.keyword,
|
|
91
|
+
"scenarios": [
|
|
92
|
+
{"given": s.given, "when": s.when, "then": s.then}
|
|
93
|
+
for s in self.scenarios
|
|
94
|
+
],
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@dataclass
|
|
99
|
+
class Spec:
|
|
100
|
+
"""规范 - 功能规范文档"""
|
|
101
|
+
name: str # 规范名称 (如 "auth", "user-profile")
|
|
102
|
+
title: str = "" # 规范标题
|
|
103
|
+
purpose: str = "" # 规范目的
|
|
104
|
+
requirements: list[Requirement] = field(default_factory=list)
|
|
105
|
+
metadata: dict = field(default_factory=dict)
|
|
106
|
+
created_at: datetime = field(default_factory=datetime.now)
|
|
107
|
+
updated_at: datetime = field(default_factory=datetime.now)
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def slug(self) -> str:
|
|
111
|
+
"""获取 URL 友好的名称"""
|
|
112
|
+
return self.name.lower().replace("_", "-").replace(" ", "-")
|
|
113
|
+
|
|
114
|
+
def to_markdown(self) -> str:
|
|
115
|
+
"""转换为 Markdown"""
|
|
116
|
+
lines = [
|
|
117
|
+
f"# {self.title or self.name.title()}",
|
|
118
|
+
""
|
|
119
|
+
]
|
|
120
|
+
|
|
121
|
+
if self.purpose:
|
|
122
|
+
lines.extend([
|
|
123
|
+
"## Purpose",
|
|
124
|
+
self.purpose,
|
|
125
|
+
""
|
|
126
|
+
])
|
|
127
|
+
|
|
128
|
+
if self.requirements:
|
|
129
|
+
lines.append("## Requirements")
|
|
130
|
+
lines.append("")
|
|
131
|
+
for req in self.requirements:
|
|
132
|
+
lines.append(req.to_markdown())
|
|
133
|
+
|
|
134
|
+
return "\n".join(lines)
|
|
135
|
+
|
|
136
|
+
def to_dict(self) -> dict:
|
|
137
|
+
"""转换为字典"""
|
|
138
|
+
return {
|
|
139
|
+
"name": self.name,
|
|
140
|
+
"title": self.title,
|
|
141
|
+
"purpose": self.purpose,
|
|
142
|
+
"requirements": [
|
|
143
|
+
{
|
|
144
|
+
"name": r.name,
|
|
145
|
+
"description": r.description,
|
|
146
|
+
"keyword": r.keyword,
|
|
147
|
+
"scenarios": [
|
|
148
|
+
{
|
|
149
|
+
"given": s.given,
|
|
150
|
+
"when": s.when,
|
|
151
|
+
"then": s.then
|
|
152
|
+
}
|
|
153
|
+
for s in r.scenarios
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
for r in self.requirements
|
|
157
|
+
],
|
|
158
|
+
"metadata": self.metadata,
|
|
159
|
+
"created_at": self.created_at.isoformat(),
|
|
160
|
+
"updated_at": self.updated_at.isoformat()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@dataclass
|
|
165
|
+
class Task:
|
|
166
|
+
"""任务 - 实现任务"""
|
|
167
|
+
id: str # 任务 ID (如 "1.1", "2.3")
|
|
168
|
+
title: str # 任务标题
|
|
169
|
+
description: str = "" # 任务描述
|
|
170
|
+
status: TaskStatus = TaskStatus.PENDING
|
|
171
|
+
assigned_to: str = "" # 分配给谁
|
|
172
|
+
dependencies: list[str] = field(default_factory=list) # 依赖的任务 ID
|
|
173
|
+
spec_refs: list[str] = field(default_factory=list) # 引用的规范
|
|
174
|
+
|
|
175
|
+
def to_markdown(self) -> str:
|
|
176
|
+
"""转换为 Markdown"""
|
|
177
|
+
checkbox = {
|
|
178
|
+
TaskStatus.PENDING: "[ ]",
|
|
179
|
+
TaskStatus.IN_PROGRESS: "[~]",
|
|
180
|
+
TaskStatus.COMPLETED: "[x]",
|
|
181
|
+
TaskStatus.SKIPPED: "[_]"
|
|
182
|
+
}.get(self.status, "[ ]")
|
|
183
|
+
|
|
184
|
+
lines = [
|
|
185
|
+
f"- {checkbox} **{self.id}: {self.title}**"
|
|
186
|
+
]
|
|
187
|
+
|
|
188
|
+
if self.description:
|
|
189
|
+
lines.append(f" - {self.description}")
|
|
190
|
+
|
|
191
|
+
if self.spec_refs:
|
|
192
|
+
lines.append(f" - Refs: {', '.join(f'`{r}`' for r in self.spec_refs)}")
|
|
193
|
+
|
|
194
|
+
if self.dependencies:
|
|
195
|
+
lines.append(f" - Depends on: {', '.join(self.dependencies)}")
|
|
196
|
+
|
|
197
|
+
return "\n".join(lines)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
@dataclass
|
|
201
|
+
class SpecDelta:
|
|
202
|
+
"""规范增量 - 规范的变更"""
|
|
203
|
+
spec_name: str # 规范名称
|
|
204
|
+
delta_type: DeltaType # 增量类型
|
|
205
|
+
requirements: list[Requirement] = field(default_factory=list)
|
|
206
|
+
description: str = "" # 变更说明
|
|
207
|
+
|
|
208
|
+
def to_markdown(self) -> str:
|
|
209
|
+
"""转换为 Markdown"""
|
|
210
|
+
lines = [
|
|
211
|
+
f"## {self.delta_type.value.upper()} Requirements",
|
|
212
|
+
""
|
|
213
|
+
]
|
|
214
|
+
|
|
215
|
+
if self.description:
|
|
216
|
+
lines.extend([
|
|
217
|
+
f"> {self.description}",
|
|
218
|
+
""
|
|
219
|
+
])
|
|
220
|
+
|
|
221
|
+
for req in self.requirements:
|
|
222
|
+
lines.append(req.to_markdown())
|
|
223
|
+
|
|
224
|
+
return "\n".join(lines)
|
|
225
|
+
|
|
226
|
+
def to_dict(self) -> dict:
|
|
227
|
+
"""转换为字典"""
|
|
228
|
+
return {
|
|
229
|
+
"spec_name": self.spec_name,
|
|
230
|
+
"delta_type": self.delta_type.value,
|
|
231
|
+
"description": self.description,
|
|
232
|
+
"requirements": [r.to_dict() for r in self.requirements]
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
@dataclass
|
|
237
|
+
class Proposal:
|
|
238
|
+
"""提案 - 变更提案"""
|
|
239
|
+
title: str # 提案标题
|
|
240
|
+
description: str # 提案描述
|
|
241
|
+
motivation: str = "" # 动机/背景
|
|
242
|
+
impact: str = "" # 影响范围
|
|
243
|
+
|
|
244
|
+
def to_markdown(self) -> str:
|
|
245
|
+
"""转换为 Markdown"""
|
|
246
|
+
lines = [
|
|
247
|
+
"# Proposal",
|
|
248
|
+
""
|
|
249
|
+
]
|
|
250
|
+
|
|
251
|
+
if self.title:
|
|
252
|
+
lines.extend([
|
|
253
|
+
f"## {self.title}",
|
|
254
|
+
""
|
|
255
|
+
])
|
|
256
|
+
|
|
257
|
+
if self.description:
|
|
258
|
+
lines.extend([
|
|
259
|
+
"## Description",
|
|
260
|
+
self.description,
|
|
261
|
+
""
|
|
262
|
+
])
|
|
263
|
+
|
|
264
|
+
if self.motivation:
|
|
265
|
+
lines.extend([
|
|
266
|
+
"## Motivation",
|
|
267
|
+
self.motivation,
|
|
268
|
+
""
|
|
269
|
+
])
|
|
270
|
+
|
|
271
|
+
if self.impact:
|
|
272
|
+
lines.extend([
|
|
273
|
+
"## Impact",
|
|
274
|
+
self.impact,
|
|
275
|
+
""
|
|
276
|
+
])
|
|
277
|
+
|
|
278
|
+
return "\n".join(lines)
|
|
279
|
+
|
|
280
|
+
def to_dict(self) -> dict:
|
|
281
|
+
"""转换为字典"""
|
|
282
|
+
return {
|
|
283
|
+
"title": self.title,
|
|
284
|
+
"description": self.description,
|
|
285
|
+
"motivation": self.motivation,
|
|
286
|
+
"impact": self.impact
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
@dataclass
|
|
291
|
+
class Change:
|
|
292
|
+
"""变更 - 功能变更"""
|
|
293
|
+
id: str # 变更 ID (目录名,如 "add-user-auth")
|
|
294
|
+
title: str # 变更标题
|
|
295
|
+
status: ChangeStatus = ChangeStatus.DRAFT
|
|
296
|
+
proposal: Proposal | None = None
|
|
297
|
+
tasks: list[Task] = field(default_factory=list)
|
|
298
|
+
spec_deltas: list[SpecDelta] = field(default_factory=list)
|
|
299
|
+
design_notes: str = "" # 设计笔记 (可选)
|
|
300
|
+
created_at: datetime = field(default_factory=datetime.now)
|
|
301
|
+
updated_at: datetime = field(default_factory=datetime.now)
|
|
302
|
+
|
|
303
|
+
@property
|
|
304
|
+
def is_completed(self) -> bool:
|
|
305
|
+
"""是否所有任务都已完成"""
|
|
306
|
+
return all(t.status == TaskStatus.COMPLETED for t in self.tasks)
|
|
307
|
+
|
|
308
|
+
@property
|
|
309
|
+
def completion_rate(self) -> float:
|
|
310
|
+
"""完成率 (0-100)"""
|
|
311
|
+
if not self.tasks:
|
|
312
|
+
return 0.0
|
|
313
|
+
completed = sum(1 for t in self.tasks if t.status == TaskStatus.COMPLETED)
|
|
314
|
+
return (completed / len(self.tasks)) * 100
|
|
315
|
+
|
|
316
|
+
def to_dict(self) -> dict:
|
|
317
|
+
"""转换为字典"""
|
|
318
|
+
return {
|
|
319
|
+
"id": self.id,
|
|
320
|
+
"title": self.title,
|
|
321
|
+
"status": self.status.value,
|
|
322
|
+
"proposal": self.proposal.to_dict() if self.proposal else None,
|
|
323
|
+
"tasks": [
|
|
324
|
+
{
|
|
325
|
+
"id": t.id,
|
|
326
|
+
"title": t.title,
|
|
327
|
+
"description": t.description,
|
|
328
|
+
"status": t.status.value,
|
|
329
|
+
"assigned_to": t.assigned_to,
|
|
330
|
+
"dependencies": t.dependencies,
|
|
331
|
+
"spec_refs": t.spec_refs
|
|
332
|
+
}
|
|
333
|
+
for t in self.tasks
|
|
334
|
+
],
|
|
335
|
+
"spec_deltas": [d.to_dict() for d in self.spec_deltas],
|
|
336
|
+
"design_notes": self.design_notes,
|
|
337
|
+
"created_at": self.created_at.isoformat(),
|
|
338
|
+
"updated_at": self.updated_at.isoformat(),
|
|
339
|
+
"is_completed": self.is_completed,
|
|
340
|
+
"completion_rate": self.completion_rate
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
def get_task_by_id(self, task_id: str) -> Task | None:
|
|
344
|
+
"""根据 ID 获取任务"""
|
|
345
|
+
for task in self.tasks:
|
|
346
|
+
if task.id == task_id:
|
|
347
|
+
return task
|
|
348
|
+
return None
|