-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate_working.py
More file actions
60 lines (47 loc) · 2.14 KB
/
Copy pathgenerate_working.py
File metadata and controls
60 lines (47 loc) · 2.14 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
#!/usr/bin/env python3
"""Generate chunked analysis for nlp2cmd project - WORKING version."""
import sys
sys.path.insert(0, '/home/tom/github/wronai/code2llm')
from pathlib import Path
from code2llm.core.large_repo import HierarchicalRepoSplitter
from code2llm.core.analyzer import ProjectAnalyzer
from code2llm.core.config import Config
from code2llm.exporters import ToonExporter, ContextExporter, EvolutionExporter
project_path = Path('/home/tom/github/wronai/nlp2cmd')
output_dir = Path('/home/tom/github/wronai/nlp2cmd/project')
output_dir.mkdir(parents=True, exist_ok=True)
# Get analysis plan
splitter = HierarchicalRepoSplitter(size_limit_kb=256)
plan = splitter.get_analysis_plan(project_path)
print(f"Analysis plan: {len(plan)} chunks")
print("Chunks (max ~384KB each with margin):")
for sp in plan:
size_info = f"~{sp.estimated_size_kb}KB"
print(f" - {sp.name}: {sp.file_count} files ({size_info})")
# Analyze each subproject
for i, subproject in enumerate(plan, 1):
sp_output_dir = output_dir / subproject.name.replace('.', '_')
sp_output_dir.mkdir(parents=True, exist_ok=True)
print(f"\n[{i}/{len(plan)}] Analyzing: {subproject.name}")
config = Config(
mode='static',
max_depth_enumeration=2, # Lower depth for speed
detect_state_machines=False,
detect_recursion=False,
output_dir=str(sp_output_dir),
verbose=False
)
try:
# Analyze only subproject's specific files (not entire directory)
analyzer = ProjectAnalyzer(config)
result = analyzer.analyze_files(subproject.files, str(project_path))
# Export
ToonExporter().export(result, str(sp_output_dir / 'analysis.toon'))
ContextExporter().export(result, str(sp_output_dir / 'context.md'))
EvolutionExporter().export(result, str(sp_output_dir / 'evolution.toon'))
print(f" ✓ {subproject.name}: {len(result.functions)} functions, {len(result.classes)} classes")
except Exception as e:
print(f" ✗ Error: {e}")
import traceback
traceback.print_exc()
print(f"\n✓ Analysis complete. Output: {output_dir}")