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
super_dev/__init__.py ADDED
@@ -0,0 +1,11 @@
1
+ """
2
+ 开发:Excellent(11964948@qq.com)
3
+ 功能:Super Dev - 顶级 AI 开发战队
4
+ 作用:通过 5 位精英专家 (产品/架构/UI/UX/安全) 交付商业级研发资产
5
+ 创建时间:2025-12-30
6
+ 最后修改:2025-12-30
7
+ """
8
+
9
+ __version__ = "2.0.0"
10
+ __author__ = "Excellent"
11
+ __description__ = "顶级 AI 开发战队 - God-Tier Development Team"
@@ -0,0 +1,34 @@
1
+ """
2
+ Super Dev 项目分析器
3
+ 用于自动检测和分析项目结构
4
+ """
5
+
6
+ from .analyzer import ArchitectureReport, ProjectAnalyzer
7
+ from .detectors import detect_project_type, detect_tech_stack
8
+ from .models import (
9
+ ArchitecturePattern,
10
+ Dependency,
11
+ DesignPattern,
12
+ FrameworkType,
13
+ PatternType,
14
+ ProjectCategory,
15
+ ProjectType,
16
+ TechStack,
17
+ )
18
+
19
+ __all__ = [
20
+ "ProjectAnalyzer",
21
+ "ProjectCategory",
22
+ "ProjectType",
23
+ "ArchitectureReport",
24
+ "Dependency",
25
+ "DesignPattern",
26
+ "PatternType",
27
+ "TechStack",
28
+ "FrameworkType",
29
+ "ArchitecturePattern",
30
+ "detect_project_type",
31
+ "detect_tech_stack",
32
+ ]
33
+
34
+
@@ -0,0 +1,440 @@
1
+ """
2
+ Super Dev 项目分析器核心模块
3
+ """
4
+
5
+ import ast
6
+ import os
7
+ from pathlib import Path
8
+
9
+ from .detectors import (
10
+ detect_architecture_pattern,
11
+ detect_project_type,
12
+ detect_tech_stack,
13
+ )
14
+ from .models import (
15
+ ArchitectureReport,
16
+ Dependency,
17
+ DesignPattern,
18
+ PatternType,
19
+ ProjectCategory,
20
+ )
21
+
22
+ # 类型别名,向后兼容
23
+ ProjectType = ProjectCategory
24
+
25
+
26
+ class ProjectAnalyzer:
27
+ """
28
+ 项目分析器
29
+
30
+ 用于分析现有项目的结构、技术栈、架构模式和设计模式
31
+ """
32
+
33
+ def __init__(self, project_path: str | Path):
34
+ """
35
+ 初始化分析器
36
+
37
+ Args:
38
+ project_path: 项目根目录路径
39
+ """
40
+ self.project_path = Path(project_path).resolve()
41
+ if not self.project_path.exists():
42
+ raise FileNotFoundError(f"项目不存在: {self.project_path}")
43
+
44
+ self._report: ArchitectureReport | None = None
45
+
46
+ def analyze(self) -> ArchitectureReport:
47
+ """
48
+ 执行完整分析
49
+
50
+ Returns:
51
+ ArchitectureReport: 架构分析报告
52
+ """
53
+ # 检测项目类型
54
+ category = detect_project_type(self.project_path)
55
+
56
+ # 检测技术栈
57
+ tech_stack = detect_tech_stack(self.project_path)
58
+
59
+ # 检测架构模式
60
+ architecture_pattern = detect_architecture_pattern(self.project_path)
61
+
62
+ # 分析目录结构
63
+ directory_structure = self._analyze_directory_structure()
64
+
65
+ # 统计文件和代码行数
66
+ file_count, total_lines, languages_used = self._count_files_and_lines()
67
+
68
+ # 检测设计模式
69
+ design_patterns = self._detect_design_patterns()
70
+
71
+ self._report = ArchitectureReport(
72
+ project_path=self.project_path,
73
+ category=category,
74
+ tech_stack=tech_stack,
75
+ architecture_pattern=architecture_pattern,
76
+ design_patterns=design_patterns,
77
+ directory_structure=directory_structure,
78
+ file_count=file_count,
79
+ total_lines=total_lines,
80
+ languages_used=languages_used,
81
+ )
82
+
83
+ return self._report
84
+
85
+ def _analyze_directory_structure(self, max_depth: int = 3) -> dict:
86
+ """
87
+ 分析目录结构
88
+
89
+ Args:
90
+ max_depth: 最大递归深度
91
+
92
+ Returns:
93
+ dict: 目录结构树
94
+ """
95
+ result = {}
96
+
97
+ def _build_tree(path: Path, depth: int) -> dict | None:
98
+ if depth > max_depth:
99
+ return None
100
+
101
+ tree: dict[str, dict | None] = {}
102
+ try:
103
+ for item in sorted(path.iterdir(), key=lambda x: (not x.is_dir(), x.name)):
104
+ # 跳过隐藏文件和目录
105
+ if item.name.startswith("."):
106
+ continue
107
+
108
+ # 跳过常见忽略目录
109
+ if item.name in ["node_modules", "__pycache__", ".git", "venv", "dist", "build"]:
110
+ continue
111
+
112
+ if item.is_dir():
113
+ subtree = _build_tree(item, depth + 1)
114
+ if subtree:
115
+ tree[item.name] = subtree
116
+ else:
117
+ # 只包含代码文件
118
+ if item.suffix in [".py", ".js", ".ts", ".tsx", ".jsx", ".go", ".java"]:
119
+ tree[item.name] = None
120
+ except PermissionError:
121
+ pass
122
+
123
+ return tree if tree else None
124
+
125
+ top_tree = _build_tree(self.project_path, 0)
126
+ if top_tree:
127
+ result = top_tree
128
+
129
+ return result
130
+
131
+ def _count_files_and_lines(
132
+ self,
133
+ ) -> tuple[int, int, dict[str, int]]:
134
+ """
135
+ 统计文件数量和代码行数
136
+
137
+ Returns:
138
+ tuple: (文件数量, 总行数, 各语言行数)
139
+ """
140
+ file_count = 0
141
+ total_lines = 0
142
+ languages_used: dict[str, int] = {}
143
+
144
+ # 语言扩展名映射
145
+ lang_map = {
146
+ ".py": "Python",
147
+ ".js": "JavaScript",
148
+ ".ts": "TypeScript",
149
+ ".tsx": "TypeScript",
150
+ ".jsx": "JavaScript",
151
+ ".go": "Go",
152
+ ".java": "Java",
153
+ ".kt": "Kotlin",
154
+ ".swift": "Swift",
155
+ ".rb": "Ruby",
156
+ ".php": "PHP",
157
+ ".rs": "Rust",
158
+ ".cpp": "C++",
159
+ ".c": "C",
160
+ ".cs": "C#",
161
+ ".vue": "Vue",
162
+ ".svelte": "Svelte",
163
+ }
164
+
165
+ # 忽略的目录
166
+ ignore_dirs = {
167
+ "node_modules", "__pycache__", ".git", "venv", "env",
168
+ ".venv", "dist", "build", "target", "bin", "obj",
169
+ ".next", ".nuxt", "coverage", ".pytest_cache",
170
+ }
171
+
172
+ for root, dirs, files in os.walk(self.project_path):
173
+ # 过滤忽略的目录
174
+ dirs[:] = [d for d in dirs if d not in ignore_dirs]
175
+
176
+ for file in files:
177
+ suffix = Path(file).suffix
178
+
179
+ if suffix not in lang_map:
180
+ continue
181
+
182
+ file_path = Path(root) / file
183
+ try:
184
+ with open(file_path, encoding="utf-8", errors="ignore") as f:
185
+ lines = len(f.readlines())
186
+ total_lines += lines
187
+ file_count += 1
188
+
189
+ lang = lang_map[suffix]
190
+ languages_used[lang] = languages_used.get(lang, 0) + lines
191
+ except (OSError, UnicodeDecodeError):
192
+ pass
193
+
194
+ return file_count, total_lines, languages_used
195
+
196
+ def _detect_design_patterns(self) -> list[DesignPattern]:
197
+ """
198
+ 检测设计模式
199
+
200
+ Returns:
201
+ list[DesignPattern]: 检测到的设计模式列表
202
+ """
203
+ patterns: list[DesignPattern] = []
204
+
205
+ # 根据语言选择检测策略
206
+ if self.project_path.joinpath("package.json").exists():
207
+ patterns.extend(self._detect_js_patterns())
208
+ elif (
209
+ self.project_path.joinpath("requirements.txt").exists()
210
+ or self.project_path.joinpath("pyproject.toml").exists()
211
+ ):
212
+ patterns.extend(self._detect_python_patterns())
213
+
214
+ return patterns
215
+
216
+ def _detect_js_patterns(self) -> list[DesignPattern]:
217
+ """检测 JavaScript/TypeScript 设计模式"""
218
+ patterns: list[DesignPattern] = []
219
+
220
+ src_dir = self.project_path / "src"
221
+ if not src_dir.exists():
222
+ src_dir = self.project_path
223
+
224
+ # 遍历源文件
225
+ for js_file in src_dir.rglob("*.js"):
226
+ self._check_file_for_patterns(js_file, patterns, "javascript")
227
+
228
+ for ts_file in src_dir.rglob("*.ts"):
229
+ self._check_file_for_patterns(ts_file, patterns, "typescript")
230
+
231
+ for tsx_file in src_dir.rglob("*.tsx"):
232
+ self._check_file_for_patterns(tsx_file, patterns, "typescript")
233
+
234
+ return patterns
235
+
236
+ def _detect_python_patterns(self) -> list[DesignPattern]:
237
+ """检测 Python 设计模式"""
238
+ patterns: list[DesignPattern] = []
239
+
240
+ for py_file in self.project_path.rglob("*.py"):
241
+ self._check_file_for_patterns(py_file, patterns, "python")
242
+
243
+ return patterns
244
+
245
+ def _check_file_for_patterns(
246
+ self, file_path: Path, patterns: list[DesignPattern], language: str
247
+ ) -> None:
248
+ """
249
+ 检查文件中的设计模式
250
+
251
+ Args:
252
+ file_path: 文件路径
253
+ patterns: 模式列表(输出参数)
254
+ language: 编程语言
255
+ """
256
+ try:
257
+ content = file_path.read_text(encoding="utf-8")
258
+
259
+ if language == "python":
260
+ self._detect_python_ast_patterns(file_path, patterns)
261
+ else:
262
+ self._detect_text_based_patterns(file_path, content, patterns)
263
+
264
+ except (OSError, UnicodeDecodeError):
265
+ pass
266
+
267
+ def _detect_python_ast_patterns(
268
+ self, file_path: Path, patterns: list[DesignPattern]
269
+ ) -> None:
270
+ """使用 AST 检测 Python 设计模式"""
271
+ try:
272
+ content = file_path.read_text(encoding="utf-8")
273
+ tree = ast.parse(content, filename=str(file_path))
274
+
275
+ for node in ast.walk(tree):
276
+ # 检测 Singleton 模式
277
+ if isinstance(node, ast.ClassDef):
278
+ self._check_singleton_class(node, file_path, patterns)
279
+
280
+ # 检测 Observer 模式
281
+ if isinstance(node, ast.FunctionDef):
282
+ self._check_observer_methods(node, file_path, patterns)
283
+
284
+ except (OSError, SyntaxError):
285
+ pass
286
+
287
+ def _check_singleton_class(
288
+ self, class_node: ast.ClassDef, file_path: Path, patterns: list[DesignPattern]
289
+ ) -> None:
290
+ """检查 Singleton 模式"""
291
+ # 查找 _instance 属性
292
+ has_instance = False
293
+ has_get_instance = False
294
+
295
+ for item in class_node.body:
296
+ if isinstance(item, ast.AnnAssign):
297
+ if isinstance(item.target, ast.Name):
298
+ if item.target.id == "_instance":
299
+ has_instance = True
300
+
301
+ if isinstance(item, ast.FunctionDef):
302
+ if item.name in ["__new__", "get_instance", "instance"]:
303
+ has_get_instance = True
304
+
305
+ if has_instance or has_get_instance:
306
+ patterns.append(
307
+ DesignPattern(
308
+ name=PatternType.SINGLETON,
309
+ location=file_path,
310
+ description=f"类 {class_node.name} 实现了单例模式",
311
+ )
312
+ )
313
+
314
+ def _check_observer_methods(
315
+ self, func_node: ast.FunctionDef, file_path: Path, patterns: list[DesignPattern]
316
+ ) -> None:
317
+ """检查 Observer 模式相关方法"""
318
+ observer_methods = ["attach", "detach", "notify", "subscribe", "unsubscribe"]
319
+
320
+ if func_node.name in observer_methods:
321
+ patterns.append(
322
+ DesignPattern(
323
+ name=PatternType.OBSERVER,
324
+ location=file_path,
325
+ description=f"方法 {func_node.name} 可能是观察者模式的一部分",
326
+ confidence=0.7,
327
+ )
328
+ )
329
+
330
+ def _detect_text_based_patterns(
331
+ self, file_path: Path, content: str, patterns: list[DesignPattern]
332
+ ) -> None:
333
+ """基于文本检测设计模式(适用于 JS/TS 等)"""
334
+
335
+ # Singleton 检测
336
+ if "getInstance" in content or ("instance" in content and "private" in content):
337
+ patterns.append(
338
+ DesignPattern(
339
+ name=PatternType.SINGLETON,
340
+ location=file_path,
341
+ description="检测到单例模式相关代码",
342
+ confidence=0.6,
343
+ )
344
+ )
345
+
346
+ # Factory 检测
347
+ if "create" in content and ("Factory" in content or "factory" in content):
348
+ patterns.append(
349
+ DesignPattern(
350
+ name=PatternType.FACTORY,
351
+ location=file_path,
352
+ description="检测到工厂模式相关代码",
353
+ confidence=0.7,
354
+ )
355
+ )
356
+
357
+ # Observer 检测
358
+ observer_keywords = ["subscribe", "unsubscribe", "notify", "emit", "addEventListener"]
359
+ if any(keyword in content for keyword in observer_keywords):
360
+ patterns.append(
361
+ DesignPattern(
362
+ name=PatternType.OBSERVER,
363
+ location=file_path,
364
+ description="检测到观察者模式相关代码",
365
+ confidence=0.6,
366
+ )
367
+ )
368
+
369
+ # Strategy 检测
370
+ if "Strategy" in content or ("execute" in content and "context" in content):
371
+ patterns.append(
372
+ DesignPattern(
373
+ name=PatternType.STRATEGY,
374
+ location=file_path,
375
+ description="检测到策略模式相关代码",
376
+ confidence=0.6,
377
+ )
378
+ )
379
+
380
+ def get_summary(self) -> str:
381
+ """
382
+ 获取项目摘要
383
+
384
+ Returns:
385
+ str: 项目摘要文本
386
+ """
387
+ if self._report is None:
388
+ self.analyze()
389
+
390
+ if self._report is None:
391
+ raise RuntimeError("analyze() did not produce a report")
392
+
393
+ lines = [
394
+ f"项目类型: {self._report.category.value}",
395
+ f"编程语言: {self._report.tech_stack.language}",
396
+ f"框架: {self._report.tech_stack.framework.value if hasattr(self._report.tech_stack.framework, 'value') else self._report.tech_stack.framework}",
397
+ f"文件数量: {self._report.file_count}",
398
+ f"代码行数: {self._report.total_lines:,}",
399
+ ]
400
+
401
+ if self._report.architecture_pattern:
402
+ lines.append(f"架构模式: {self._report.architecture_pattern.value}")
403
+
404
+ return "\n".join(lines)
405
+
406
+ def get_dependencies(self) -> list[Dependency]:
407
+ """
408
+ 获取项目依赖列表
409
+
410
+ Returns:
411
+ list[Dependency]: 依赖列表
412
+ """
413
+ if self._report is None:
414
+ self.analyze()
415
+
416
+ if self._report is None:
417
+ raise RuntimeError("analyze() did not produce a report")
418
+ return self._report.tech_stack.dependencies
419
+
420
+ def get_language_distribution(self) -> dict[str, float]:
421
+ """
422
+ 获取语言分布百分比
423
+
424
+ Returns:
425
+ dict[str, float]: 语言 -> 百分比
426
+ """
427
+ if self._report is None:
428
+ self.analyze()
429
+
430
+ if self._report is None:
431
+ raise RuntimeError("analyze() did not produce a report")
432
+
433
+ total = self._report.total_lines
434
+ if total == 0:
435
+ return {}
436
+
437
+ return {
438
+ lang: (count / total) * 100
439
+ for lang, count in self._report.languages_used.items()
440
+ }