code2llm 0.3.10__tar.gz → 0.5.2__tar.gz
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.
- {code2llm-0.3.10/code2llm.egg-info → code2llm-0.5.2}/PKG-INFO +44 -44
- {code2llm-0.3.10 → code2llm-0.5.2}/README.md +43 -43
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/__init__.py +2 -2
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/__main__.py +1 -1
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/analysis/__init__.py +1 -1
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/analysis/data_analysis.py +1 -1
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/analysis/pipeline_detector.py +10 -5
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/analysis/side_effects.py +12 -1
- code2llm-0.5.2/code2llm/cli.py +495 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/core/__init__.py +1 -1
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/core/analyzer.py +1 -1
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/core/config.py +2 -2
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/core/streaming_analyzer.py +2 -2
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/exporters/__init__.py +4 -1
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/exporters/base.py +1 -1
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/exporters/context_exporter.py +1 -1
- code2llm-0.5.2/code2llm/exporters/evolution_exporter.py +317 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/exporters/json_exporter.py +1 -1
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/exporters/map_exporter.py +69 -62
- code2llm-0.5.2/code2llm/exporters/mermaid_exporter.py +243 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/exporters/toon.py +197 -146
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/exporters/yaml_exporter.py +1 -1
- code2llm-0.5.2/code2llm/generators/__init__.py +12 -0
- code2llm-0.3.10/code2flow/llm_flow_generator.py → code2llm-0.5.2/code2llm/generators/llm_flow.py +1 -1
- code2llm-0.5.2/code2llm/generators/mermaid.py +477 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/nlp/__init__.py +1 -1
- {code2llm-0.3.10 → code2llm-0.5.2/code2llm.egg-info}/PKG-INFO +44 -44
- code2llm-0.5.2/code2llm.egg-info/SOURCES.txt +64 -0
- code2llm-0.5.2/code2llm.egg-info/entry_points.txt +2 -0
- code2llm-0.5.2/code2llm.egg-info/top_level.txt +1 -0
- {code2llm-0.3.10 → code2llm-0.5.2}/pyproject.toml +3 -3
- {code2llm-0.3.10 → code2llm-0.5.2}/setup.py +1 -1
- {code2llm-0.3.10 → code2llm-0.5.2}/tests/test_advanced_analysis.py +6 -6
- {code2llm-0.3.10 → code2llm-0.5.2}/tests/test_analyzer.py +6 -6
- code2llm-0.3.10/tests/test_sprint4.py → code2llm-0.5.2/tests/test_deep_analysis.py +3 -3
- {code2llm-0.3.10 → code2llm-0.5.2}/tests/test_edge_cases.py +5 -5
- code2llm-0.3.10/tests/test_sprint2_flow.py → code2llm-0.5.2/tests/test_flow_exporter.py +4 -4
- {code2llm-0.3.10 → code2llm-0.5.2}/tests/test_format_quality.py +11 -11
- {code2llm-0.3.10 → code2llm-0.5.2}/tests/test_nlp_pipeline.py +10 -10
- code2llm-0.3.10/tests/test_sprint3_pipelines.py → code2llm-0.5.2/tests/test_pipeline_detector.py +8 -8
- code2llm-0.3.10/tests/test_sprint5.py → code2llm-0.5.2/tests/test_prompt_engine.py +2 -2
- {code2llm-0.3.10 → code2llm-0.5.2}/tests/test_refactoring_engine.py +7 -7
- {code2llm-0.3.10 → code2llm-0.5.2}/tests/test_toon_v2.py +6 -6
- code2llm-0.3.10/code2flow/cli.py +0 -493
- code2llm-0.3.10/code2flow/exporters/mermaid_exporter.py +0 -67
- code2llm-0.3.10/code2flow/mermaid_generator.py +0 -481
- code2llm-0.3.10/code2flow/visualizers/__init__.py +0 -0
- code2llm-0.3.10/code2flow/visualizers/graph.py +0 -196
- code2llm-0.3.10/code2llm.egg-info/SOURCES.txt +0 -64
- code2llm-0.3.10/code2llm.egg-info/entry_points.txt +0 -2
- code2llm-0.3.10/code2llm.egg-info/top_level.txt +0 -1
- {code2llm-0.3.10 → code2llm-0.5.2}/LICENSE +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/analysis/call_graph.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/analysis/cfg.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/analysis/coupling.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/analysis/dfg.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/analysis/smells.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/analysis/type_inference.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/core/models.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/exporters/flow_exporter.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/exporters/llm_exporter.py +0 -0
- /code2llm-0.3.10/code2flow/llm_task_generator.py → /code2llm-0.5.2/code2llm/generators/llm_task.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/nlp/config.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/nlp/entity_resolution.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/nlp/intent_matching.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/nlp/normalization.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/nlp/pipeline.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/patterns/__init__.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/patterns/detector.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/refactor/__init__.py +0 -0
- {code2llm-0.3.10/code2flow → code2llm-0.5.2/code2llm}/refactor/prompt_engine.py +0 -0
- {code2llm-0.3.10 → code2llm-0.5.2}/code2llm.egg-info/dependency_links.txt +0 -0
- {code2llm-0.3.10 → code2llm-0.5.2}/code2llm.egg-info/requires.txt +0 -0
- {code2llm-0.3.10 → code2llm-0.5.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: code2llm
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: High-performance Python code flow analysis with optimized TOON format - CFG, DFG, call graphs, and intelligent code queries
|
|
5
5
|
Home-page: https://github.com/wronai/stts
|
|
6
6
|
Author: STTS Project
|
|
@@ -135,17 +135,17 @@ pip install -e ".[dev]"
|
|
|
135
135
|
|
|
136
136
|
```bash
|
|
137
137
|
# Analyze a Python project (default: TOON format)
|
|
138
|
-
|
|
138
|
+
code2llm /path/to/project
|
|
139
139
|
|
|
140
140
|
# With verbose output
|
|
141
|
-
|
|
141
|
+
code2llm /path/to/project -v
|
|
142
142
|
|
|
143
143
|
# Generate all formats
|
|
144
|
-
|
|
144
|
+
code2llm /path/to/project -f all
|
|
145
145
|
|
|
146
146
|
# Use different analysis modes
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
code2llm /path/to/project -m static # Fast static analysis only
|
|
148
|
+
code2llm /path/to/project -m hybrid # Combined analysis (default)
|
|
149
149
|
```
|
|
150
150
|
|
|
151
151
|
## Usage
|
|
@@ -154,40 +154,40 @@ code2flow /path/to/project -m hybrid # Combined analysis (default)
|
|
|
154
154
|
|
|
155
155
|
```bash
|
|
156
156
|
# Default: TOON format only
|
|
157
|
-
|
|
157
|
+
code2llm /path/to/project
|
|
158
158
|
|
|
159
159
|
# All formats (toon,yaml,json,mermaid,png)
|
|
160
|
-
|
|
160
|
+
code2llm /path/to/project -f all
|
|
161
161
|
|
|
162
162
|
# Custom combinations
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
code2llm /path/to/project -f toon,yaml
|
|
164
|
+
code2llm /path/to/project -f json,png
|
|
165
|
+
code2llm /path/to/project -f mermaid,png
|
|
166
166
|
```
|
|
167
167
|
|
|
168
168
|
### Analysis Modes
|
|
169
169
|
|
|
170
170
|
```bash
|
|
171
171
|
# Static analysis only (fastest)
|
|
172
|
-
|
|
172
|
+
code2llm /path/to/project -m static
|
|
173
173
|
|
|
174
174
|
# Dynamic analysis with tracing
|
|
175
|
-
|
|
175
|
+
code2llm /path/to/project -m dynamic
|
|
176
176
|
|
|
177
177
|
# Hybrid analysis (recommended)
|
|
178
|
-
|
|
178
|
+
code2llm /path/to/project -m hybrid
|
|
179
179
|
|
|
180
180
|
# Behavioral pattern focus
|
|
181
|
-
|
|
181
|
+
code2llm /path/to/project -m behavioral
|
|
182
182
|
|
|
183
183
|
# Reverse engineering ready
|
|
184
|
-
|
|
184
|
+
code2llm /path/to/project -m reverse
|
|
185
185
|
```
|
|
186
186
|
|
|
187
187
|
### Custom Output
|
|
188
188
|
|
|
189
189
|
```bash
|
|
190
|
-
|
|
190
|
+
code2llm /path/to/project -o my_analysis
|
|
191
191
|
```
|
|
192
192
|
|
|
193
193
|
## Output Files
|
|
@@ -213,11 +213,11 @@ The TOON v2 format is designed for rapid scanning and actionable insights:
|
|
|
213
213
|
# CC̄=4.6 | critical:39/406 | dups:0 | cycles:0
|
|
214
214
|
|
|
215
215
|
HEALTH[20]:
|
|
216
|
-
🔴 GOD
|
|
216
|
+
🔴 GOD code2llm/core/analyzer.py = 765L, 4 classes, 30m, max CC=20
|
|
217
217
|
🟡 CC validate_mermaid_file CC=42 (limit:15)
|
|
218
218
|
|
|
219
219
|
REFACTOR[4]:
|
|
220
|
-
1. split
|
|
220
|
+
1. split code2llm/core/analyzer.py (god module)
|
|
221
221
|
2. split 17 high-CC methods (CC>15)
|
|
222
222
|
|
|
223
223
|
COUPLING:
|
|
@@ -229,7 +229,7 @@ COUPLING:
|
|
|
229
229
|
└─────────────┴──────────────────────────────────────┘
|
|
230
230
|
|
|
231
231
|
LAYERS:
|
|
232
|
-
|
|
232
|
+
code2llm/ CC̄=5.0 ←in:0 →out:0
|
|
233
233
|
│ !! toon 982L 1C 29m CC=31
|
|
234
234
|
│ !! analyzer 765L 4C 30m CC=20
|
|
235
235
|
|
|
@@ -372,10 +372,10 @@ The analyzer is designed to be extensible. Key areas for enhancement:
|
|
|
372
372
|
|
|
373
373
|
| Command | Output | Use Case |
|
|
374
374
|
|---------|--------|----------|
|
|
375
|
-
| `
|
|
376
|
-
| `
|
|
377
|
-
| `
|
|
378
|
-
| `
|
|
375
|
+
| `code2llm ./project` | `analysis.toon` | Quick analysis (default) |
|
|
376
|
+
| `code2llm ./project -f all` | All formats | Complete analysis |
|
|
377
|
+
| `code2llm ./project -f toon,yaml` | TOON + YAML | Comparison |
|
|
378
|
+
| `code2llm ./project -m hybrid -v` | TOON + verbose | Detailed analysis |
|
|
379
379
|
| `python validate_toon.py analysis.toon` | Validation | Quality check |
|
|
380
380
|
|
|
381
381
|
## 🔧 Advanced Usage
|
|
@@ -384,7 +384,7 @@ The analyzer is designed to be extensible. Key areas for enhancement:
|
|
|
384
384
|
|
|
385
385
|
```bash
|
|
386
386
|
# Deep analysis with all insights
|
|
387
|
-
|
|
387
|
+
code2llm ./project \
|
|
388
388
|
-m hybrid \
|
|
389
389
|
-f toon \
|
|
390
390
|
--max-depth 15 \
|
|
@@ -392,14 +392,14 @@ code2flow ./project \
|
|
|
392
392
|
-v
|
|
393
393
|
|
|
394
394
|
# Performance-optimized for large projects
|
|
395
|
-
|
|
395
|
+
code2llm ./project \
|
|
396
396
|
-m static \
|
|
397
397
|
-f toon \
|
|
398
398
|
--strategy quick \
|
|
399
399
|
--max-memory 500
|
|
400
400
|
|
|
401
401
|
# Refactoring-focused analysis
|
|
402
|
-
|
|
402
|
+
code2llm ./project \
|
|
403
403
|
-m behavioral \
|
|
404
404
|
-f toon \
|
|
405
405
|
--refactor \
|
|
@@ -412,7 +412,7 @@ code2flow ./project \
|
|
|
412
412
|
```bash
|
|
413
413
|
#!/bin/bash
|
|
414
414
|
# Analyze code quality in CI
|
|
415
|
-
|
|
415
|
+
code2llm ./src -f toon -o ./analysis
|
|
416
416
|
python validate_toon.py ./analysis/analysis.toon
|
|
417
417
|
if [ $? -eq 0 ]; then
|
|
418
418
|
echo "✅ Code analysis passed"
|
|
@@ -426,7 +426,7 @@ fi
|
|
|
426
426
|
```bash
|
|
427
427
|
#!/bin/sh
|
|
428
428
|
# .git/hooks/pre-commit
|
|
429
|
-
|
|
429
|
+
code2llm ./ -f toon -o ./temp_analysis
|
|
430
430
|
python validate_toon.py ./temp_analysis/analysis.toon
|
|
431
431
|
rm -rf ./temp_analysis
|
|
432
432
|
```
|
|
@@ -436,21 +436,21 @@ rm -rf ./temp_analysis
|
|
|
436
436
|
### Microservice Analysis
|
|
437
437
|
```bash
|
|
438
438
|
# Analyze microservice complexity
|
|
439
|
-
|
|
439
|
+
code2llm ./microservice -f toon -o ./service_analysis
|
|
440
440
|
# Results: 15 critical functions, 3 modules need refactoring
|
|
441
441
|
```
|
|
442
442
|
|
|
443
443
|
### Legacy Code Migration
|
|
444
444
|
```bash
|
|
445
445
|
# Prepare for legacy system migration
|
|
446
|
-
|
|
446
|
+
code2llm ./legacy -f toon,yaml -o ./migration_analysis
|
|
447
447
|
# Use TOON for quick overview, YAML for detailed migration planning
|
|
448
448
|
```
|
|
449
449
|
|
|
450
450
|
### Code Review Enhancement
|
|
451
451
|
```bash
|
|
452
452
|
# Generate insights for code review
|
|
453
|
-
|
|
453
|
+
code2llm ./feature-branch -f toon --refactor -o ./review
|
|
454
454
|
# Focus on critical functions and code smells
|
|
455
455
|
```
|
|
456
456
|
|
|
@@ -460,13 +460,13 @@ code2flow ./feature-branch -f toon --refactor -o ./review
|
|
|
460
460
|
|
|
461
461
|
**Before:**
|
|
462
462
|
```bash
|
|
463
|
-
|
|
463
|
+
code2llm ./project -f yaml -o ./analysis
|
|
464
464
|
# Output: analysis.yaml (2.5MB)
|
|
465
465
|
```
|
|
466
466
|
|
|
467
467
|
**After:**
|
|
468
468
|
```bash
|
|
469
|
-
|
|
469
|
+
code2llm ./project -f toon -o ./analysis
|
|
470
470
|
# Output: analysis.toon (204KB)
|
|
471
471
|
```
|
|
472
472
|
|
|
@@ -480,7 +480,7 @@ code2flow ./project -f toon -o ./analysis
|
|
|
480
480
|
|
|
481
481
|
```bash
|
|
482
482
|
# Still generate YAML if needed
|
|
483
|
-
|
|
483
|
+
code2llm ./project -f toon,yaml
|
|
484
484
|
# Both formats available for comparison
|
|
485
485
|
```
|
|
486
486
|
|
|
@@ -531,14 +531,14 @@ ls -la ./output/
|
|
|
531
531
|
**Issue:** Validation fails
|
|
532
532
|
```bash
|
|
533
533
|
# Solution: Run with verbose output
|
|
534
|
-
|
|
534
|
+
code2llm ./project -f toon -v
|
|
535
535
|
# Check for any errors during analysis
|
|
536
536
|
```
|
|
537
537
|
|
|
538
538
|
**Issue:** Large file sizes
|
|
539
539
|
```bash
|
|
540
540
|
# Solution: Use TOON format instead of YAML
|
|
541
|
-
|
|
541
|
+
code2llm ./project -f toon # 200KB vs 2.5MB
|
|
542
542
|
```
|
|
543
543
|
|
|
544
544
|
### Performance Issues
|
|
@@ -546,13 +546,13 @@ code2flow ./project -f toon # 200KB vs 2.5MB
|
|
|
546
546
|
**Memory Usage:**
|
|
547
547
|
```bash
|
|
548
548
|
# Limit memory for large projects
|
|
549
|
-
|
|
549
|
+
code2llm ./large-project --max-memory 500 -f toon
|
|
550
550
|
```
|
|
551
551
|
|
|
552
552
|
**Slow Analysis:**
|
|
553
553
|
```bash
|
|
554
554
|
# Use fast mode for initial exploration
|
|
555
|
-
|
|
555
|
+
code2llm ./project -m static -f toon --strategy quick
|
|
556
556
|
```
|
|
557
557
|
|
|
558
558
|
## 🤝 Contributing to TOON Format
|
|
@@ -569,8 +569,8 @@ The TOON format is designed to be extensible. Areas for contribution:
|
|
|
569
569
|
|
|
570
570
|
```bash
|
|
571
571
|
# Clone and setup development environment
|
|
572
|
-
git clone https://github.com/tom-sapletta/
|
|
573
|
-
cd
|
|
572
|
+
git clone https://github.com/tom-sapletta/code2llm.git
|
|
573
|
+
cd code2llm
|
|
574
574
|
pip install -e ".[dev]"
|
|
575
575
|
|
|
576
576
|
# Run tests
|
|
@@ -584,15 +584,15 @@ python validate_toon.py output/analysis.toon
|
|
|
584
584
|
|
|
585
585
|
- [TOON Format Validation](validate_toon.py) - Built-in validation tool
|
|
586
586
|
- [Project Testing Script](project.sh) - Comprehensive test suite
|
|
587
|
-
- [CLI Reference](
|
|
588
|
-
- [Exporter Implementation](
|
|
587
|
+
- [CLI Reference](code2llm/cli.py) - Complete command-line interface
|
|
588
|
+
- [Exporter Implementation](code2llm/exporters/base.py) - TOON format implementation
|
|
589
589
|
|
|
590
590
|
---
|
|
591
591
|
|
|
592
592
|
**Ready to analyze your code?** Start with the optimized TOON format:
|
|
593
593
|
|
|
594
594
|
```bash
|
|
595
|
-
|
|
595
|
+
code2llm ./your-project -f toon
|
|
596
596
|
```
|
|
597
597
|
|
|
598
598
|
## License
|
|
@@ -86,17 +86,17 @@ pip install -e ".[dev]"
|
|
|
86
86
|
|
|
87
87
|
```bash
|
|
88
88
|
# Analyze a Python project (default: TOON format)
|
|
89
|
-
|
|
89
|
+
code2llm /path/to/project
|
|
90
90
|
|
|
91
91
|
# With verbose output
|
|
92
|
-
|
|
92
|
+
code2llm /path/to/project -v
|
|
93
93
|
|
|
94
94
|
# Generate all formats
|
|
95
|
-
|
|
95
|
+
code2llm /path/to/project -f all
|
|
96
96
|
|
|
97
97
|
# Use different analysis modes
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
code2llm /path/to/project -m static # Fast static analysis only
|
|
99
|
+
code2llm /path/to/project -m hybrid # Combined analysis (default)
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
## Usage
|
|
@@ -105,40 +105,40 @@ code2flow /path/to/project -m hybrid # Combined analysis (default)
|
|
|
105
105
|
|
|
106
106
|
```bash
|
|
107
107
|
# Default: TOON format only
|
|
108
|
-
|
|
108
|
+
code2llm /path/to/project
|
|
109
109
|
|
|
110
110
|
# All formats (toon,yaml,json,mermaid,png)
|
|
111
|
-
|
|
111
|
+
code2llm /path/to/project -f all
|
|
112
112
|
|
|
113
113
|
# Custom combinations
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
code2llm /path/to/project -f toon,yaml
|
|
115
|
+
code2llm /path/to/project -f json,png
|
|
116
|
+
code2llm /path/to/project -f mermaid,png
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
### Analysis Modes
|
|
120
120
|
|
|
121
121
|
```bash
|
|
122
122
|
# Static analysis only (fastest)
|
|
123
|
-
|
|
123
|
+
code2llm /path/to/project -m static
|
|
124
124
|
|
|
125
125
|
# Dynamic analysis with tracing
|
|
126
|
-
|
|
126
|
+
code2llm /path/to/project -m dynamic
|
|
127
127
|
|
|
128
128
|
# Hybrid analysis (recommended)
|
|
129
|
-
|
|
129
|
+
code2llm /path/to/project -m hybrid
|
|
130
130
|
|
|
131
131
|
# Behavioral pattern focus
|
|
132
|
-
|
|
132
|
+
code2llm /path/to/project -m behavioral
|
|
133
133
|
|
|
134
134
|
# Reverse engineering ready
|
|
135
|
-
|
|
135
|
+
code2llm /path/to/project -m reverse
|
|
136
136
|
```
|
|
137
137
|
|
|
138
138
|
### Custom Output
|
|
139
139
|
|
|
140
140
|
```bash
|
|
141
|
-
|
|
141
|
+
code2llm /path/to/project -o my_analysis
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
## Output Files
|
|
@@ -164,11 +164,11 @@ The TOON v2 format is designed for rapid scanning and actionable insights:
|
|
|
164
164
|
# CC̄=4.6 | critical:39/406 | dups:0 | cycles:0
|
|
165
165
|
|
|
166
166
|
HEALTH[20]:
|
|
167
|
-
🔴 GOD
|
|
167
|
+
🔴 GOD code2llm/core/analyzer.py = 765L, 4 classes, 30m, max CC=20
|
|
168
168
|
🟡 CC validate_mermaid_file CC=42 (limit:15)
|
|
169
169
|
|
|
170
170
|
REFACTOR[4]:
|
|
171
|
-
1. split
|
|
171
|
+
1. split code2llm/core/analyzer.py (god module)
|
|
172
172
|
2. split 17 high-CC methods (CC>15)
|
|
173
173
|
|
|
174
174
|
COUPLING:
|
|
@@ -180,7 +180,7 @@ COUPLING:
|
|
|
180
180
|
└─────────────┴──────────────────────────────────────┘
|
|
181
181
|
|
|
182
182
|
LAYERS:
|
|
183
|
-
|
|
183
|
+
code2llm/ CC̄=5.0 ←in:0 →out:0
|
|
184
184
|
│ !! toon 982L 1C 29m CC=31
|
|
185
185
|
│ !! analyzer 765L 4C 30m CC=20
|
|
186
186
|
|
|
@@ -323,10 +323,10 @@ The analyzer is designed to be extensible. Key areas for enhancement:
|
|
|
323
323
|
|
|
324
324
|
| Command | Output | Use Case |
|
|
325
325
|
|---------|--------|----------|
|
|
326
|
-
| `
|
|
327
|
-
| `
|
|
328
|
-
| `
|
|
329
|
-
| `
|
|
326
|
+
| `code2llm ./project` | `analysis.toon` | Quick analysis (default) |
|
|
327
|
+
| `code2llm ./project -f all` | All formats | Complete analysis |
|
|
328
|
+
| `code2llm ./project -f toon,yaml` | TOON + YAML | Comparison |
|
|
329
|
+
| `code2llm ./project -m hybrid -v` | TOON + verbose | Detailed analysis |
|
|
330
330
|
| `python validate_toon.py analysis.toon` | Validation | Quality check |
|
|
331
331
|
|
|
332
332
|
## 🔧 Advanced Usage
|
|
@@ -335,7 +335,7 @@ The analyzer is designed to be extensible. Key areas for enhancement:
|
|
|
335
335
|
|
|
336
336
|
```bash
|
|
337
337
|
# Deep analysis with all insights
|
|
338
|
-
|
|
338
|
+
code2llm ./project \
|
|
339
339
|
-m hybrid \
|
|
340
340
|
-f toon \
|
|
341
341
|
--max-depth 15 \
|
|
@@ -343,14 +343,14 @@ code2flow ./project \
|
|
|
343
343
|
-v
|
|
344
344
|
|
|
345
345
|
# Performance-optimized for large projects
|
|
346
|
-
|
|
346
|
+
code2llm ./project \
|
|
347
347
|
-m static \
|
|
348
348
|
-f toon \
|
|
349
349
|
--strategy quick \
|
|
350
350
|
--max-memory 500
|
|
351
351
|
|
|
352
352
|
# Refactoring-focused analysis
|
|
353
|
-
|
|
353
|
+
code2llm ./project \
|
|
354
354
|
-m behavioral \
|
|
355
355
|
-f toon \
|
|
356
356
|
--refactor \
|
|
@@ -363,7 +363,7 @@ code2flow ./project \
|
|
|
363
363
|
```bash
|
|
364
364
|
#!/bin/bash
|
|
365
365
|
# Analyze code quality in CI
|
|
366
|
-
|
|
366
|
+
code2llm ./src -f toon -o ./analysis
|
|
367
367
|
python validate_toon.py ./analysis/analysis.toon
|
|
368
368
|
if [ $? -eq 0 ]; then
|
|
369
369
|
echo "✅ Code analysis passed"
|
|
@@ -377,7 +377,7 @@ fi
|
|
|
377
377
|
```bash
|
|
378
378
|
#!/bin/sh
|
|
379
379
|
# .git/hooks/pre-commit
|
|
380
|
-
|
|
380
|
+
code2llm ./ -f toon -o ./temp_analysis
|
|
381
381
|
python validate_toon.py ./temp_analysis/analysis.toon
|
|
382
382
|
rm -rf ./temp_analysis
|
|
383
383
|
```
|
|
@@ -387,21 +387,21 @@ rm -rf ./temp_analysis
|
|
|
387
387
|
### Microservice Analysis
|
|
388
388
|
```bash
|
|
389
389
|
# Analyze microservice complexity
|
|
390
|
-
|
|
390
|
+
code2llm ./microservice -f toon -o ./service_analysis
|
|
391
391
|
# Results: 15 critical functions, 3 modules need refactoring
|
|
392
392
|
```
|
|
393
393
|
|
|
394
394
|
### Legacy Code Migration
|
|
395
395
|
```bash
|
|
396
396
|
# Prepare for legacy system migration
|
|
397
|
-
|
|
397
|
+
code2llm ./legacy -f toon,yaml -o ./migration_analysis
|
|
398
398
|
# Use TOON for quick overview, YAML for detailed migration planning
|
|
399
399
|
```
|
|
400
400
|
|
|
401
401
|
### Code Review Enhancement
|
|
402
402
|
```bash
|
|
403
403
|
# Generate insights for code review
|
|
404
|
-
|
|
404
|
+
code2llm ./feature-branch -f toon --refactor -o ./review
|
|
405
405
|
# Focus on critical functions and code smells
|
|
406
406
|
```
|
|
407
407
|
|
|
@@ -411,13 +411,13 @@ code2flow ./feature-branch -f toon --refactor -o ./review
|
|
|
411
411
|
|
|
412
412
|
**Before:**
|
|
413
413
|
```bash
|
|
414
|
-
|
|
414
|
+
code2llm ./project -f yaml -o ./analysis
|
|
415
415
|
# Output: analysis.yaml (2.5MB)
|
|
416
416
|
```
|
|
417
417
|
|
|
418
418
|
**After:**
|
|
419
419
|
```bash
|
|
420
|
-
|
|
420
|
+
code2llm ./project -f toon -o ./analysis
|
|
421
421
|
# Output: analysis.toon (204KB)
|
|
422
422
|
```
|
|
423
423
|
|
|
@@ -431,7 +431,7 @@ code2flow ./project -f toon -o ./analysis
|
|
|
431
431
|
|
|
432
432
|
```bash
|
|
433
433
|
# Still generate YAML if needed
|
|
434
|
-
|
|
434
|
+
code2llm ./project -f toon,yaml
|
|
435
435
|
# Both formats available for comparison
|
|
436
436
|
```
|
|
437
437
|
|
|
@@ -482,14 +482,14 @@ ls -la ./output/
|
|
|
482
482
|
**Issue:** Validation fails
|
|
483
483
|
```bash
|
|
484
484
|
# Solution: Run with verbose output
|
|
485
|
-
|
|
485
|
+
code2llm ./project -f toon -v
|
|
486
486
|
# Check for any errors during analysis
|
|
487
487
|
```
|
|
488
488
|
|
|
489
489
|
**Issue:** Large file sizes
|
|
490
490
|
```bash
|
|
491
491
|
# Solution: Use TOON format instead of YAML
|
|
492
|
-
|
|
492
|
+
code2llm ./project -f toon # 200KB vs 2.5MB
|
|
493
493
|
```
|
|
494
494
|
|
|
495
495
|
### Performance Issues
|
|
@@ -497,13 +497,13 @@ code2flow ./project -f toon # 200KB vs 2.5MB
|
|
|
497
497
|
**Memory Usage:**
|
|
498
498
|
```bash
|
|
499
499
|
# Limit memory for large projects
|
|
500
|
-
|
|
500
|
+
code2llm ./large-project --max-memory 500 -f toon
|
|
501
501
|
```
|
|
502
502
|
|
|
503
503
|
**Slow Analysis:**
|
|
504
504
|
```bash
|
|
505
505
|
# Use fast mode for initial exploration
|
|
506
|
-
|
|
506
|
+
code2llm ./project -m static -f toon --strategy quick
|
|
507
507
|
```
|
|
508
508
|
|
|
509
509
|
## 🤝 Contributing to TOON Format
|
|
@@ -520,8 +520,8 @@ The TOON format is designed to be extensible. Areas for contribution:
|
|
|
520
520
|
|
|
521
521
|
```bash
|
|
522
522
|
# Clone and setup development environment
|
|
523
|
-
git clone https://github.com/tom-sapletta/
|
|
524
|
-
cd
|
|
523
|
+
git clone https://github.com/tom-sapletta/code2llm.git
|
|
524
|
+
cd code2llm
|
|
525
525
|
pip install -e ".[dev]"
|
|
526
526
|
|
|
527
527
|
# Run tests
|
|
@@ -535,15 +535,15 @@ python validate_toon.py output/analysis.toon
|
|
|
535
535
|
|
|
536
536
|
- [TOON Format Validation](validate_toon.py) - Built-in validation tool
|
|
537
537
|
- [Project Testing Script](project.sh) - Comprehensive test suite
|
|
538
|
-
- [CLI Reference](
|
|
539
|
-
- [Exporter Implementation](
|
|
538
|
+
- [CLI Reference](code2llm/cli.py) - Complete command-line interface
|
|
539
|
+
- [Exporter Implementation](code2llm/exporters/base.py) - TOON format implementation
|
|
540
540
|
|
|
541
541
|
---
|
|
542
542
|
|
|
543
543
|
**Ready to analyze your code?** Start with the optimized TOON format:
|
|
544
544
|
|
|
545
545
|
```bash
|
|
546
|
-
|
|
546
|
+
code2llm ./your-project -f toon
|
|
547
547
|
```
|
|
548
548
|
|
|
549
549
|
## License
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
code2llm - Optimized Python Code Flow Analysis Tool
|
|
3
3
|
|
|
4
4
|
A high-performance tool for analyzing Python code control flow, data flow,
|
|
5
5
|
and call graphs with caching and parallel processing.
|
|
@@ -8,7 +8,7 @@ Includes NLP Processing Pipeline for query normalization, intent matching,
|
|
|
8
8
|
and entity resolution with multilingual support.
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
__version__ = "0.
|
|
11
|
+
__version__ = "0.4.0"
|
|
12
12
|
__author__ = "STTS Project"
|
|
13
13
|
|
|
14
14
|
# Core analysis components
|
|
@@ -395,7 +395,7 @@ class PipelineDetector:
|
|
|
395
395
|
parts = fi.module.split(".")
|
|
396
396
|
# Use most specific module component
|
|
397
397
|
for part in parts:
|
|
398
|
-
if part and part not in ("
|
|
398
|
+
if part and part not in ("code2llm", "__init__"):
|
|
399
399
|
module_counts[part] += 1
|
|
400
400
|
|
|
401
401
|
if module_counts:
|
|
@@ -436,10 +436,15 @@ class PipelineDetector:
|
|
|
436
436
|
def _resolve_callee(
|
|
437
437
|
self, callee: str, funcs: Dict[str, FunctionInfo]
|
|
438
438
|
) -> Optional[str]:
|
|
439
|
-
"""Resolve callee name to qualified name.
|
|
439
|
+
"""Resolve callee name to qualified name.
|
|
440
|
+
|
|
441
|
+
Returns None for ambiguous matches (multiple candidates)
|
|
442
|
+
to avoid creating phantom pipeline edges.
|
|
443
|
+
"""
|
|
440
444
|
if callee in funcs:
|
|
441
445
|
return callee
|
|
442
|
-
for
|
|
443
|
-
|
|
444
|
-
|
|
446
|
+
candidates = [qn for qn in funcs if qn.endswith(f".{callee}")]
|
|
447
|
+
if len(candidates) == 1:
|
|
448
|
+
return candidates[0]
|
|
449
|
+
# Ambiguous or not found — skip to avoid wrong edges
|
|
445
450
|
return None
|
|
@@ -26,10 +26,16 @@ IO_CALLS = frozenset({
|
|
|
26
26
|
"dump", "dumps", "load", "loads",
|
|
27
27
|
"save", "savefig",
|
|
28
28
|
"send", "recv", "connect", "listen", "accept",
|
|
29
|
-
"get", "post", "put", "delete", "patch", # HTTP
|
|
30
29
|
"execute", "commit", "rollback", # DB
|
|
31
30
|
})
|
|
32
31
|
|
|
32
|
+
# HTTP verbs — only IO when called on known HTTP objects (requests.get, session.post)
|
|
33
|
+
HTTP_METHODS = frozenset({"get", "post", "put", "delete", "patch"})
|
|
34
|
+
HTTP_CALLERS = frozenset({
|
|
35
|
+
"requests", "session", "client", "http", "aiohttp",
|
|
36
|
+
"httpx", "urllib", "conn", "api", "resp", "response",
|
|
37
|
+
})
|
|
38
|
+
|
|
33
39
|
IO_ATTRIBUTES = frozenset({
|
|
34
40
|
"write", "read", "readline", "readlines", "writelines",
|
|
35
41
|
"flush", "close", "seek", "tell",
|
|
@@ -174,6 +180,11 @@ class SideEffectDetector:
|
|
|
174
180
|
# IO detection
|
|
175
181
|
if base_name in IO_CALLS:
|
|
176
182
|
info.io_operations.append(base_name)
|
|
183
|
+
elif base_name in HTTP_METHODS and len(parts) >= 2:
|
|
184
|
+
# Only classify as IO if caller looks like HTTP client
|
|
185
|
+
caller = parts[-2].lower()
|
|
186
|
+
if caller in HTTP_CALLERS:
|
|
187
|
+
info.io_operations.append(call_name)
|
|
177
188
|
elif base_name in IO_ATTRIBUTES:
|
|
178
189
|
info.io_operations.append(call_name)
|
|
179
190
|
|