GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - semcod/code2logic: High-performance Python code flow analysis with NLP query processing - CFG, DFG, call graphs, and intelligent code queries

BranchesTags
Open more actions menu

Latest commit

 

History

179 Commits
179 Commits

Folders and files

NameName
Last commit message
Last commit date
.cursor/rules
.cursor/rules
 
 
.githooks
.githooks
 
 
.github
.github
 
 
.governance
.governance
 
 
.pyqual
.pyqual
 
 
.subactor
.subactor
 
 
.taskill
.taskill
 
 
benchmark_output
benchmark_output
 
 
benchmarks
benchmarks
 
 
code2flow
code2flow
 
 
code2logic
code2logic
 
 
docs
docs
 
 
errors
errors
 
 
examples
examples
 
 
generated_code
generated_code
 
 
logic2code
logic2code
 
 
logic2test
logic2test
 
 
lolm
lolm
 
 
project
project
 
 
raport
raport
 
 
scripts
scripts
 
 
tests
tests
 
 
.aider.conf.yml
.aider.conf.yml
 
 
.env.example
.env.example
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.nojekyll
.nojekyll
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
AGENTS.md
AGENTS.md
 
 
API_REFERENCE.md
API_REFERENCE.md
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CHANGELOG_v2.md
CHANGELOG_v2.md
 
 
CLAUDE.md
CLAUDE.md
 
 
DOCUMENTATION.md
DOCUMENTATION.md
 
 
Dockerfile
Dockerfile
 
 
Dockerfile.dev
Dockerfile.dev
 
 
GEMINI.md
GEMINI.md
 
 
LICENSE
LICENSE
 
 
MANIFEST.in
MANIFEST.in
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
REFACTORING_PLAN.md
REFACTORING_PLAN.md
 
 
ROADMAP.md
ROADMAP.md
 
 
TICKET
TICKET
 
 
TODO.md
TODO.md
 
 
Taskfile.yml
Taskfile.yml
 
 
VERSION
VERSION
 
 
advanced_data_analyzer.py
advanced_data_analyzer.py
 
 
advanced_yaml_optimizer.py
advanced_yaml_optimizer.py
 
 
app.doql.css
app.doql.css
 
 
app.doql.less
app.doql.less
 
 
complexity_reduction_examples.py
complexity_reduction_examples.py
 
 
context.md
context.md
 
 
context_final.md
context_final.md
 
 
context_fixed.md
context_fixed.md
 
 
context_improved.md
context_improved.md
 
 
docker-compose.yml
docker-compose.yml
 
 
fast_analysis.py
fast_analysis.py
 
 
fast_analysis.sh
fast_analysis.sh
 
 
final_advanced_data_analyzer.py
final_advanced_data_analyzer.py
 
 
fixed_advanced_data_analyzer.py
fixed_advanced_data_analyzer.py
 
 
fixed_refactoring_implementation_executor.py
fixed_refactoring_implementation_executor.py
 
 
flow.py
flow.py
 
 
function-schema.json
function-schema.json
 
 
function.toon
function.toon
 
 
general_refactoring_template.py
general_refactoring_template.py
 
 
generate_graph_viewer.py
generate_graph_viewer.py
 
 
generate_index_html.py
generate_index_html.py
 
 
goal.yaml
goal.yaml
 
 
hybrid_export.py
hybrid_export.py
 
 
image-1.png
image-1.png
 
 
image.png
image.png
 
 
index.html
index.html
 
 
litellm_config.yaml
litellm_config.yaml
 
 
llm_refactoring_executor.py
llm_refactoring_executor.py
 
 
local.dev.txt
local.dev.txt
 
 
mermaid_to_png.py
mermaid_to_png.py
 
 
ollama_benchmark_results.csv
ollama_benchmark_results.csv
 
 
optimization_test_results.yaml
optimization_test_results.yaml
 
 
optimize_llm_prompt.py
optimize_llm_prompt.py
 
 
optimize_llm_prompt_fixed.py
optimize_llm_prompt_fixed.py
 
 
performance_optimizations.py
performance_optimizations.py
 
 
pipeline_runner_utils_improved.py
pipeline_runner_utils_improved.py
 
 
planfile.yaml
planfile.yaml
 
 
prefact.yaml
prefact.yaml
 
 
project.bat
project.bat
 
 
project.sh
project.sh
 
 
project.toon
project.toon
 
 
project.toon-schema.json
project.toon-schema.json
 
 
project_summary.yaml
project_summary.yaml
 
 
project_summary_generator.py
project_summary_generator.py
 
 
pyproject.toml
pyproject.toml
 
 
pyqual.yaml
pyqual.yaml
 
 
refactoring_implementation_executor.py
refactoring_implementation_executor.py
 
 
refactoring_implementation_report.yaml
refactoring_implementation_report.yaml
 
 
refactoring_validation_report.yaml
refactoring_validation_report.yaml
 
 
refactoring_validator.py
refactoring_validator.py
 
 
requirements.txt
requirements.txt
 
 
setup.py
setup.py
 
 
split_yaml.py
split_yaml.py
 
 

Repository files navigation

code2flow

AI Cost Tracking

PyPI Version Python License AI Cost Human Time Model

  • 🤖 LLM usage: $13.0434 (125 commits)
  • 👤 Human dev: ~$6497 (65.0h @ $100/h, 30min dedup)

Generated on 2026-07-29 using openrouter/qwen/qwen3-coder-next


Python Code Flow Analysis Tool - Static analysis for control flow graphs (CFG), data flow graphs (DFG), and call graph extraction.

Performance Optimization

For large projects (>1000 functions), use Fast Mode:

# Ultra-fast analysis (5-10x faster)
code2flow /path/to/project --fast

# Custom performance settings
code2flow /path/to/project \
    --parallel-workers 8 \
    --max-depth 3 \
    --skip-data-flow \
    --cache-dir ./.cache

Performance Tips

Technique Speedup Use Case
--fast mode 5-10x Initial exploration
Parallel workers 2-4x Multi-core machines
Caching 3-5x Repeated analysis
Depth limiting 2-3x Large codebases
Skip private methods 1.5-2x Public API analysis

Benchmarks

Project Size Functions Time (fast) Time (full)
Small (<100) ~50 0.5s 2s
Medium (1K) ~500 3s 15s
Large (10K) ~2000 15s 120s

Features

  • Control Flow Graph (CFG): Extract execution paths from Python AST
  • Data Flow Graph (DFG): Track variable definitions and dependencies
  • Call Graph Analysis: Map function calls and dependencies
  • Pattern Detection: Identify design patterns (state machines, factories, recursion)
  • Compact Output: Deduplicated flow diagrams with pattern recognition
  • Multiple Output Formats: YAML, JSON, Mermaid diagrams, PNG visualizations
  • LLM-Ready Output: Generate prompts for reverse engineering

Installation

# Install from source
pip install -e .

# Or with development dependencies
pip install -e ".[dev]"

Quick Start

# Analyze a Python project
code2flow /path/to/project

# With verbose output
code2flow /path/to/project -v

# Specify output directory and formats
code2flow /path/to/project -o ./analysis --format yaml,json,mermaid,png

# Use different analysis modes
code2flow /path/to/project -m static    # Fast static analysis only
code2flow /path/to/project -m hybrid     # Combined analysis (default)

Usage

Basic Analysis

code2flow /path/to/project

Analysis Modes

# Static analysis only (fastest)
code2flow /path/to/project -m static

# Dynamic analysis with tracing
code2flow /path/to/project -m dynamic

# Hybrid analysis (recommended)
code2flow /path/to/project -m hybrid

# Behavioral pattern focus
code2flow /path/to/project -m behavioral

# Reverse engineering ready
code2flow /path/to/project -m reverse

Custom Output

code2flow /path/to/project -o my_analysis

Output Files

File Description
analysis.yaml Complete structured analysis data
analysis.json JSON format for programmatic use
flow.mmd Full Mermaid flowchart (all nodes)
compact_flow.mmd Compact flowchart - deduplicated nodes, grouped by function
calls.mmd Function call graph
cfg.png Control flow visualization
call_graph.png Call graph visualization
llm_prompt.md LLM-ready analysis summary

Compact Flow Format

The compact_flow.mmd file provides optimized output:

  • Deduplication: Identical node patterns are merged (e.g., x = 1, x = 2 → x = N)
  • Function Subgraphs: Nodes grouped by function in subgraphs
  • Pattern Preservation: Control flow structure maintained while reducing file size
  • Import Reuse: Common patterns linked rather than duplicated

Example compact output:

flowchart TD
    %% Function subgraphs
    subgraph F12345["process_data"]
        N1["x = N"]  
        N2{"if x > 0"}
        N3[/"return x"/]
    end
    
    %% Edges reference deduplicated nodes
    N1 --> N2
    N2 -->|"true"| N3
Loading

Understanding the Output

LLM Prompt Structure

The generated prompt includes:

  • System overview with metrics
  • Call graph structure
  • Behavioral patterns with confidence scores
  • Data flow insights
  • State machine definitions
  • Reverse engineering guidelines

Behavioral Patterns

Each pattern includes:

  • Name: Descriptive identifier
  • Type: sequential, conditional, iterative, recursive, state_machine
  • Entry/Exit points: Key functions
  • Decision points: Conditional logic locations
  • Data transformations: Variable dependencies
  • Confidence: Pattern detection certainty

Reverse Engineering Guidelines

The analysis provides specific guidance for:

  1. Preserving call graph structure
  2. Implementing identified patterns
  3. Maintaining data dependencies
  4. Recreating state machines
  5. Preserving decision logic

Advanced Features

State Machine Detection

Automatically identifies:

  • State variables
  • Transition methods
  • Source and destination states
  • State machine hierarchy

Data Flow Tracking

Maps:

  • Variable dependencies
  • Data transformations
  • Information flow paths
  • Side effects

Dynamic Tracing

When using dynamic mode:

  • Function entry/exit timing
  • Call stack reconstruction
  • Exception tracking
  • Performance profiling

Integration with LLMs

The generated system_analysis_prompt.md is designed to be:

  • Comprehensive: Contains all necessary system information
  • Structured: Organized for easy parsing
  • Actionable: Includes specific implementation guidance
  • Language-agnostic: Describes behavior, not implementation

Example usage with an LLM:

"Based on the system analysis provided, implement this system in Go,
preserving all behavioral patterns and data flow characteristics."

Limitations

  • Dynamic analysis requires test files
  • Complex inheritance hierarchies may need manual review
  • External library calls are treated as black boxes
  • Runtime reflection and metaprogramming not fully captured

Contributing

The analyzer is designed to be extensible. Key areas for enhancement:

  • Additional pattern types
  • Language-specific optimizations
  • Improved visualization
  • Real-time analysis mode

License

Licensed under Apache-2.0.

Author

Tom Sapletta

Status

Last updated by taskill at 2026-04-25 13:36 UTC

Metric Value
HEAD bdf9336
Coverage —
Failing tests —
Commits in last cycle 50

Large refactor and feature sweep: added a deep code analysis engine and supporting modules, improved configuration management and CLI, integrated AppDefaults for auto-loading a default LLM profile, and delegated env file I/O to getv.EnvStore. Docs, examples, and tests were updated alongside several chore/quality improvements and a release commit.

About

High-performance Python code flow analysis with NLP query processing - CFG, DFG, call graphs, and intelligent code queries

semcod.github.io/code2logic/

Topics

astcall-graphcode-analysiscode-understandingcontrol-flowdata-flowllmnlppythonreverse-engineeringsemcodstatic-analysis

Resources

Readme
Apache-2.0 license

Contributing

Contributing
Activity
Custom properties

Stars

7 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.