-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate_quick.py
More file actions
63 lines (48 loc) · 2.24 KB
/
Copy pathgenerate_quick.py
File metadata and controls
63 lines (48 loc) · 2.24 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
#!/usr/bin/env python3
"""Generate chunked analysis for nlp2cmd project - QUICK 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.streaming_analyzer import StreamingAnalyzer, STRATEGY_QUICK
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")
for sp in plan:
print(f" - {sp.name}: {sp.file_count} files (~{sp.estimated_size_kb}KB)")
# Analyze each subproject with quick strategy
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, # Skip for speed
detect_recursion=False, # Skip for speed
output_dir=str(sp_output_dir),
verbose=False
)
try:
# Use streaming analyzer with quick strategy
analyzer = StreamingAnalyzer(config, STRATEGY_QUICK)
# Run analysis
for update in analyzer.analyze_streaming(str(subproject.path)):
if update['type'] == 'complete':
break
# Get results from streaming analyzer
result = analyzer.results
# 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")
except Exception as e:
print(f" ✗ Error: {e}")
print(f"\n✓ Analysis complete. Output: {output_dir}")