-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_blueprint.py
More file actions
90 lines (76 loc) · 2.65 KB
/
Copy pathrun_blueprint.py
File metadata and controls
90 lines (76 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"""
Project Blueprint - 简单测试脚本
"""
import sys
from pathlib import Path
project_dir = Path(__file__).parent
sys.path.insert(0, str(project_dir))
from project_blueprint.scanner import DirectoryScanner
from project_blueprint.analyzer import ProjectAnalyzer
from project_blueprint.generator import DescriptionGenerator
from project_blueprint.documenter import DocumentGenerator
def main():
"""主函数"""
import sys
if hasattr(sys.stdout, 'reconfigure'):
try:
sys.stdout.reconfigure(encoding='utf-8')
except Exception:
pass
if hasattr(sys.stderr, 'reconfigure'):
try:
sys.stderr.reconfigure(encoding='utf-8')
except Exception:
pass
print("\n🔍 Project Blueprint - 智能项目结构分析工具")
print("=" * 60)
current_path = Path.cwd()
print(f"\n正在分析目录:{current_path}")
print(f"这可能需要几秒钟时间...\n")
print("📂 步骤 1/4:扫描目录结构...")
scanner = DirectoryScanner()
try:
root_node = scanner.scan(str(current_path))
file_count = root_node.get_file_count()
print(f" ✅ 扫描完成!发现 {file_count} 个文件")
except Exception as e:
print(f"❌ 错误:{e}")
return
print("\n📊 步骤 2/4:分析项目信息...")
analyzer = ProjectAnalyzer()
try:
project_info = analyzer.analyze(root_node, current_path)
print(f" ✅ 项目类型:{project_info.project_type}")
if project_info.tech_stack:
print(f" ✅ 技术栈:{', '.join(project_info.tech_stack[:5])}")
except Exception as e:
print(f"❌ 错误:{e}")
return
print("\n✍️ 步骤 3/4:生成文件夹说明...")
generator = DescriptionGenerator()
try:
folder_descriptions = generator.generate(root_node, project_info)
print(f" ✅ 生成 {len(folder_descriptions)} 个文件夹的说明")
except Exception as e:
print(f"❌ 错误:{e}")
return
print("\n📝 步骤 4/4:生成文档...")
documenter = DocumentGenerator()
try:
doc = documenter.generate(
root_node,
project_info,
folder_descriptions,
current_path
)
output_file = current_path / 'PROJECT_BLUEPRINT.md'
print(f" ✅ 文档已保存到:{output_file}")
except Exception as e:
print(f"❌ 错误:{e}")
return
print("\n" + "=" * 60)
print("✅ 分析完成!")
print(f"📄 打开 PROJECT_BLUEPRINT.md 查看完整分析结果")
print("=" * 60)
if __name__ == '__main__':
main()