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.
Files changed (61) hide show
  1. super_dev/__init__.py +11 -0
  2. super_dev/analyzer/__init__.py +34 -0
  3. super_dev/analyzer/analyzer.py +440 -0
  4. super_dev/analyzer/detectors.py +511 -0
  5. super_dev/analyzer/models.py +285 -0
  6. super_dev/cli.py +3257 -0
  7. super_dev/config/__init__.py +11 -0
  8. super_dev/config/frontend.py +557 -0
  9. super_dev/config/manager.py +281 -0
  10. super_dev/creators/__init__.py +26 -0
  11. super_dev/creators/creator.py +134 -0
  12. super_dev/creators/document_generator.py +2473 -0
  13. super_dev/creators/frontend_builder.py +371 -0
  14. super_dev/creators/implementation_builder.py +789 -0
  15. super_dev/creators/prompt_generator.py +289 -0
  16. super_dev/creators/requirement_parser.py +354 -0
  17. super_dev/creators/spec_builder.py +195 -0
  18. super_dev/deployers/__init__.py +20 -0
  19. super_dev/deployers/cicd.py +1269 -0
  20. super_dev/deployers/delivery.py +229 -0
  21. super_dev/deployers/migration.py +1032 -0
  22. super_dev/design/__init__.py +74 -0
  23. super_dev/design/aesthetics.py +530 -0
  24. super_dev/design/charts.py +396 -0
  25. super_dev/design/codegen.py +379 -0
  26. super_dev/design/engine.py +528 -0
  27. super_dev/design/generator.py +395 -0
  28. super_dev/design/landing.py +422 -0
  29. super_dev/design/tech_stack.py +524 -0
  30. super_dev/design/tokens.py +269 -0
  31. super_dev/design/ux_guide.py +391 -0
  32. super_dev/exceptions.py +119 -0
  33. super_dev/experts/__init__.py +19 -0
  34. super_dev/experts/service.py +161 -0
  35. super_dev/integrations/__init__.py +7 -0
  36. super_dev/integrations/manager.py +264 -0
  37. super_dev/orchestrator/__init__.py +12 -0
  38. super_dev/orchestrator/engine.py +958 -0
  39. super_dev/orchestrator/experts.py +423 -0
  40. super_dev/orchestrator/knowledge.py +352 -0
  41. super_dev/orchestrator/quality.py +356 -0
  42. super_dev/reviewers/__init__.py +17 -0
  43. super_dev/reviewers/code_review.py +471 -0
  44. super_dev/reviewers/quality_gate.py +964 -0
  45. super_dev/reviewers/redteam.py +881 -0
  46. super_dev/skills/__init__.py +7 -0
  47. super_dev/skills/manager.py +307 -0
  48. super_dev/specs/__init__.py +44 -0
  49. super_dev/specs/generator.py +264 -0
  50. super_dev/specs/manager.py +428 -0
  51. super_dev/specs/models.py +348 -0
  52. super_dev/specs/validator.py +415 -0
  53. super_dev/utils/__init__.py +11 -0
  54. super_dev/utils/logger.py +133 -0
  55. super_dev/web/api.py +1402 -0
  56. super_dev-2.0.0.dist-info/METADATA +252 -0
  57. super_dev-2.0.0.dist-info/RECORD +61 -0
  58. super_dev-2.0.0.dist-info/WHEEL +5 -0
  59. super_dev-2.0.0.dist-info/entry_points.txt +2 -0
  60. super_dev-2.0.0.dist-info/licenses/LICENSE +21 -0
  61. super_dev-2.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,281 @@
1
+ """
2
+ 开发:Excellent(11964948@qq.com)
3
+ 功能:配置管理器 - 管理项目配置
4
+ 作用:读取、验证、持久化 super-dev.yaml 配置
5
+ 创建时间:2025-12-30
6
+ 最后修改:2025-12-30
7
+ """
8
+
9
+ from dataclasses import dataclass, field
10
+ from pathlib import Path
11
+ from typing import Any, cast
12
+
13
+ import yaml # type: ignore[import-untyped]
14
+
15
+
16
+ @dataclass
17
+ class ProjectConfig:
18
+ """项目配置"""
19
+
20
+ name: str
21
+ description: str = ""
22
+ version: str = "2.0.0"
23
+ author: str = ""
24
+ license: str = "MIT"
25
+
26
+ # 技术栈
27
+ platform: str = "web" # web, mobile, wechat, desktop
28
+ frontend: str = "next" # 扩展支持:next, remix, react-vite, gatsby, nuxt, vue-vite, angular, sveltekit, astro, solid, qwik
29
+ backend: str = "node" # node, python, go, java
30
+ database: str = "postgresql" # postgresql, mysql, mongodb, redis
31
+
32
+ # 前端配置 (扩展)
33
+ ui_library: str | None = None # UI 组件库
34
+ style_solution: str | None = None # 样式方案
35
+ state_management: list[str] = field(default_factory=list) # 状态管理
36
+ testing_frameworks: list[str] = field(default_factory=list) # 测试框架
37
+
38
+ # 领域知识
39
+ domain: str = "" # fintech, ecommerce, medical, social, iot, education
40
+
41
+ # 工作流配置
42
+ phases: list[str] = field(default_factory=lambda: [
43
+ "discovery", "intelligence", "drafting",
44
+ "redteam", "qa", "delivery", "deployment"
45
+ ])
46
+
47
+ # 专家配置
48
+ experts: list[str] = field(default_factory=lambda: [
49
+ "PM", "ARCHITECT", "UI", "UX", "SECURITY", "CODE"
50
+ ])
51
+
52
+ # 质量门禁
53
+ quality_gate: int = 80
54
+
55
+ # 输出目录
56
+ output_dir: str = "output"
57
+
58
+ # CLI 设置
59
+ cli: dict[str, Any] = field(default_factory=dict)
60
+
61
+
62
+ class ConfigManager:
63
+ """配置管理器"""
64
+
65
+ CONFIG_FILENAME = "super-dev.yaml"
66
+ DEFAULT_CONFIG: dict[str, Any] = {
67
+ "name": "my-project",
68
+ "description": "A Super Dev project",
69
+ "version": "2.0.0",
70
+ "platform": "web",
71
+ "frontend": "next", # 默认使用 Next.js
72
+ "backend": "node",
73
+ "database": "postgresql",
74
+ "domain": "",
75
+ "quality_gate": 80,
76
+ "output_dir": "output",
77
+ # 前端配置
78
+ "ui_library": None,
79
+ "style_solution": None,
80
+ "state_management": [],
81
+ "testing_frameworks": [],
82
+ }
83
+
84
+ def __init__(self, project_dir: Path | None = None):
85
+ """
86
+ 初始化配置管理器
87
+
88
+ Args:
89
+ project_dir: 项目目录,默认为当前目录
90
+ """
91
+ self.project_dir = Path.cwd() if project_dir is None else project_dir
92
+ self.config_path = self.project_dir / self.CONFIG_FILENAME
93
+ self._config: ProjectConfig | None = None
94
+
95
+ @property
96
+ def config(self) -> ProjectConfig:
97
+ """获取配置(延迟加载)"""
98
+ if self._config is None:
99
+ self._config = self.load()
100
+ return self._config
101
+
102
+ def exists(self) -> bool:
103
+ """检查配置文件是否存在"""
104
+ return self.config_path.exists()
105
+
106
+ def load(self) -> ProjectConfig:
107
+ """
108
+ 加载配置文件
109
+
110
+ Returns:
111
+ ProjectConfig: 项目配置对象
112
+ """
113
+ if not self.exists():
114
+ # 返回默认配置
115
+ return ProjectConfig(**cast(dict[str, Any], self.DEFAULT_CONFIG.copy()))
116
+
117
+ with open(self.config_path, encoding="utf-8") as f:
118
+ loaded = yaml.safe_load(f)
119
+ data = loaded if isinstance(loaded, dict) else {}
120
+
121
+ # 合并默认配置
122
+ config_data: dict[str, Any] = {**self.DEFAULT_CONFIG, **data}
123
+
124
+ return ProjectConfig(**cast(dict[str, Any], config_data))
125
+
126
+ def save(self, config: ProjectConfig | None = None) -> None:
127
+ """
128
+ 保存配置文件
129
+
130
+ Args:
131
+ config: 要保存的配置,默认使用当前配置
132
+ """
133
+ config_to_save = config or self._config
134
+ if config_to_save is None:
135
+ raise ValueError("No config to save")
136
+
137
+ # 转换为字典(排除 None 值)
138
+ data = {
139
+ k: v for k, v in config_to_save.__dict__.items()
140
+ if v is not None and not k.startswith("_")
141
+ }
142
+
143
+ with open(self.config_path, "w", encoding="utf-8") as f:
144
+ yaml.dump(data, f, allow_unicode=True, default_flow_style=False)
145
+
146
+ self._config = config_to_save
147
+
148
+ def create(self, **kwargs: Any) -> ProjectConfig:
149
+ """
150
+ 创建新配置
151
+
152
+ Args:
153
+ **kwargs: 配置参数
154
+
155
+ Returns:
156
+ ProjectConfig: 新创建的配置对象
157
+ """
158
+ config_data: dict[str, Any] = {**self.DEFAULT_CONFIG, **kwargs}
159
+ self._config = ProjectConfig(**cast(dict[str, Any], config_data))
160
+ self.save()
161
+ return self._config
162
+
163
+ def update(self, **kwargs: Any) -> ProjectConfig:
164
+ """
165
+ 更新配置
166
+
167
+ Args:
168
+ **kwargs: 要更新的配置参数
169
+
170
+ Returns:
171
+ ProjectConfig: 更新后的配置对象
172
+ """
173
+ if not self.exists():
174
+ return self.create(**kwargs)
175
+
176
+ # 类型转换映射
177
+ type_converters: dict[str, type[int]] = {
178
+ "quality_gate": int, # 质量门禁必须是整数
179
+ }
180
+
181
+ # 转换类型
182
+ converted_kwargs: dict[str, Any] = {}
183
+ for key, value in kwargs.items():
184
+ if key in type_converters and isinstance(value, str):
185
+ try:
186
+ converted_kwargs[key] = type_converters[key](value)
187
+ except (ValueError, TypeError):
188
+ converted_kwargs[key] = value
189
+ else:
190
+ converted_kwargs[key] = value
191
+
192
+ # 合并现有配置
193
+ current_data: dict[str, Any] = dict(self.config.__dict__)
194
+ updated_data: dict[str, Any] = {**current_data, **converted_kwargs}
195
+
196
+ self._config = ProjectConfig(**cast(dict[str, Any], updated_data))
197
+ self.save()
198
+ return self._config
199
+
200
+ def get(self, key: str, default: Any = None) -> Any:
201
+ """
202
+ 获取配置值
203
+
204
+ Args:
205
+ key: 配置键(支持点号分隔的嵌套键)
206
+ default: 默认值
207
+
208
+ Returns:
209
+ 配置值
210
+ """
211
+ value = self.config
212
+ for part in key.split("."):
213
+ if hasattr(value, part):
214
+ value = getattr(value, part)
215
+ else:
216
+ return default
217
+ return value
218
+
219
+ def validate(self) -> tuple[bool, list[str]]:
220
+ """
221
+ 验证配置
222
+
223
+ Returns:
224
+ (是否有效, 错误列表)
225
+ """
226
+ errors: list[str] = []
227
+
228
+ # 验证必需字段
229
+ if not self.config.name:
230
+ errors.append("项目名称不能为空")
231
+
232
+ # 验证平台
233
+ valid_platforms = ["web", "mobile", "wechat", "desktop"]
234
+ if self.config.platform not in valid_platforms:
235
+ errors.append(f"平台必须是: {', '.join(valid_platforms)}")
236
+
237
+ # 验证前端框架
238
+ valid_frontends = [
239
+ "next", "remix", "react-vite", "gatsby",
240
+ "nuxt", "vue-vite",
241
+ "angular",
242
+ "sveltekit",
243
+ "astro", "solid", "qwik",
244
+ "react", "vue", "svelte",
245
+ "none",
246
+ ]
247
+ if self.config.frontend not in valid_frontends:
248
+ errors.append(f"前端框架必须是: {', '.join(valid_frontends)}")
249
+
250
+ # 验证后端框架
251
+ valid_backends = ["node", "python", "go", "java", "none"]
252
+ if self.config.backend not in valid_backends:
253
+ errors.append(f"后端框架必须是: {', '.join(valid_backends)}")
254
+
255
+ # 验证质量门禁
256
+ if not 0 <= self.config.quality_gate <= 100:
257
+ errors.append("质量门禁必须在 0-100 之间")
258
+
259
+ return len(errors) == 0, errors
260
+
261
+
262
+ # 全局配置管理器缓存(按项目目录隔离)
263
+ _global_config_managers: dict[Path, ConfigManager] = {}
264
+
265
+
266
+ def get_config_manager(project_dir: Path | None = None) -> ConfigManager:
267
+ """
268
+ 获取全局配置管理器实例
269
+
270
+ Args:
271
+ project_dir: 项目目录
272
+
273
+ Returns:
274
+ ConfigManager: 配置管理器实例
275
+ """
276
+ project_root = (Path.cwd() if project_dir is None else Path(project_dir)).resolve()
277
+ manager = _global_config_managers.get(project_root)
278
+ if manager is None:
279
+ manager = ConfigManager(project_root)
280
+ _global_config_managers[project_root] = manager
281
+ return manager
@@ -0,0 +1,26 @@
1
+ """
2
+ Super Dev 项目创建器
3
+
4
+ 开发:Excellent(11964948@qq.com)
5
+ 功能:从一句话描述自动生成完整的项目文档和 Spec
6
+ 作用:一键启动项目,从想法到可执行的规范
7
+ 创建时间:2025-12-30
8
+ """
9
+
10
+ from .creator import ProjectCreator
11
+ from .document_generator import DocumentGenerator
12
+ from .frontend_builder import FrontendScaffoldBuilder
13
+ from .implementation_builder import ImplementationScaffoldBuilder
14
+ from .prompt_generator import AIPromptGenerator
15
+ from .requirement_parser import RequirementParser
16
+ from .spec_builder import SpecBuilder
17
+
18
+ __all__ = [
19
+ "ProjectCreator",
20
+ "DocumentGenerator",
21
+ "FrontendScaffoldBuilder",
22
+ "ImplementationScaffoldBuilder",
23
+ "SpecBuilder",
24
+ "AIPromptGenerator",
25
+ "RequirementParser",
26
+ ]
@@ -0,0 +1,134 @@
1
+ """
2
+ 项目创建器 - 核心协调器
3
+
4
+ 开发:Excellent(11964948@qq.com)
5
+ 功能:从一句话描述到完整项目规范
6
+ 作用:协调文档生成、Spec 创建和 AI 提示词生成
7
+ 创建时间:2025-12-30
8
+ """
9
+
10
+ from pathlib import Path
11
+
12
+ from .document_generator import DocumentGenerator
13
+ from .prompt_generator import AIPromptGenerator
14
+ from .spec_builder import SpecBuilder
15
+
16
+
17
+ class ProjectCreator:
18
+ """项目创建器 - 一键从想法到规范"""
19
+
20
+ def __init__(
21
+ self,
22
+ project_dir: Path,
23
+ name: str,
24
+ description: str,
25
+ platform: str = "web",
26
+ frontend: str = "next",
27
+ backend: str = "node",
28
+ domain: str = "",
29
+ ui_library: str | None = None,
30
+ style_solution: str | None = None,
31
+ state_management: list[str] | None = None,
32
+ testing_frameworks: list[str] | None = None,
33
+ ):
34
+ """初始化项目创建器"""
35
+ self.project_dir = Path(project_dir).resolve()
36
+ self.name = name
37
+ self.description = description
38
+ self.platform = platform
39
+ self.frontend = frontend
40
+ self.backend = backend
41
+ self.domain = domain
42
+ self.ui_library = ui_library
43
+ self.style_solution = style_solution
44
+ self.state_management = state_management or []
45
+ self.testing_frameworks = testing_frameworks or []
46
+
47
+ # 确保输出目录存在
48
+ self.output_dir = self.project_dir / "output"
49
+ self.output_dir.mkdir(exist_ok=True)
50
+
51
+ # 初始化子模块
52
+ self.doc_generator = DocumentGenerator(
53
+ name=name,
54
+ description=description,
55
+ platform=platform,
56
+ frontend=frontend,
57
+ backend=backend,
58
+ domain=domain,
59
+ ui_library=ui_library,
60
+ style_solution=style_solution,
61
+ state_management=state_management,
62
+ testing_frameworks=testing_frameworks,
63
+ )
64
+ self.spec_builder = SpecBuilder(
65
+ project_dir=self.project_dir,
66
+ name=name,
67
+ description=description
68
+ )
69
+ self.prompt_generator = AIPromptGenerator(
70
+ project_dir=self.project_dir,
71
+ name=name
72
+ )
73
+
74
+ def generate_documents(self) -> dict:
75
+ """生成所有文档 (PRD, 架构, UI/UX)"""
76
+ docs = {}
77
+
78
+ # 1. PRD
79
+ prd_path = self.output_dir / f"{self.name}-prd.md"
80
+ prd_content = self.doc_generator.generate_prd()
81
+ prd_path.write_text(prd_content, encoding="utf-8")
82
+ docs['prd'] = str(prd_path)
83
+
84
+ # 2. 架构文档
85
+ arch_path = self.output_dir / f"{self.name}-architecture.md"
86
+ arch_content = self.doc_generator.generate_architecture()
87
+ arch_path.write_text(arch_content, encoding="utf-8")
88
+ docs['architecture'] = str(arch_path)
89
+
90
+ # 3. UI/UX 文档
91
+ uiux_path = self.output_dir / f"{self.name}-uiux.md"
92
+ uiux_content = self.doc_generator.generate_uiux()
93
+ uiux_path.write_text(uiux_content, encoding="utf-8")
94
+ docs['uiux'] = str(uiux_path)
95
+
96
+ # 4. 执行路线图
97
+ scenario = self.doc_generator.requirement_parser.detect_scenario(self.project_dir)
98
+ plan_path = self.output_dir / f"{self.name}-execution-plan.md"
99
+ plan_content = self.doc_generator.generate_execution_plan(scenario=scenario)
100
+ plan_path.write_text(plan_content, encoding="utf-8")
101
+ docs['plan'] = str(plan_path)
102
+
103
+ # 5. 前端蓝图
104
+ frontend_blueprint_path = self.output_dir / f"{self.name}-frontend-blueprint.md"
105
+ frontend_blueprint_content = self.doc_generator.generate_frontend_blueprint()
106
+ frontend_blueprint_path.write_text(frontend_blueprint_content, encoding="utf-8")
107
+ docs['frontend_blueprint'] = str(frontend_blueprint_path)
108
+
109
+ return docs
110
+
111
+ def create_spec(self) -> str:
112
+ """创建 Spec 规范"""
113
+ # 生成需求列表
114
+ requirements = self.doc_generator.extract_requirements()
115
+
116
+ # 创建 Spec 变更提案
117
+ change_id = self.spec_builder.create_change(
118
+ requirements=requirements,
119
+ tech_stack={
120
+ 'platform': self.platform,
121
+ 'frontend': self.frontend,
122
+ 'backend': self.backend,
123
+ 'domain': self.domain
124
+ }
125
+ )
126
+
127
+ return change_id
128
+
129
+ def generate_ai_prompt(self) -> str:
130
+ """生成 AI 提示词"""
131
+ prompt_file = self.output_dir / f"{self.name}-ai-prompt.md"
132
+ prompt_content = self.prompt_generator.generate()
133
+ prompt_file.write_text(prompt_content, encoding="utf-8")
134
+ return str(prompt_file)