2025-10-20 13:14:37 -04:00
2025-10-20 13:14:37 -04:00
2025-10-20 13:14:37 -04:00
2025-10-20 13:14:37 -04:00
2025-10-20 13:14:37 -04:00
2025-10-20 13:14:37 -04:00
2025-10-20 13:14:37 -04:00
2025-10-20 13:14:37 -04:00
2025-10-20 13:14:37 -04:00
2025-10-20 13:14:37 -04:00

CodeCraft - Intelligent Python Editor

An intelligent coding assistant built in Rust that analyzes Python code in real-time using tree-sitter and provides instant code quality improvements.

Features

Real-Time Code Analysis

  • Tree-sitter powered parsing: Uses the official Python tree-sitter grammar for accurate syntax analysis
  • Live diagnostics: Instant feedback as you type
  • Smart pattern detection: Identifies anti-patterns and security issues

Intelligent Suggestions

CodeCraft detects and helps fix:

  1. Bare except clauses - Catches dangerous except: that can hide critical errors

    • Auto-fix: Converts to except Exception:
  2. Mutable default arguments - Warns about lists/dicts as default parameters

  3. Old string formatting - Suggests using f-strings over .format()

  4. List comprehension opportunities - Identifies loops that append to lists

  5. Deprecated imports - Flags old modules (imp, optparse)

  6. Inefficient loops - Suggests enumerate() over range(len())

  7. Security issues - Detects dangerous functions (eval, exec, compile)

One-Click Code Actions

When CodeCraft identifies an issue with an available fix, click the "🔧 Apply Fix" button to automatically refactor your code!

Python Code Execution

  • Run code directly from the editor (Ctrl+R)
  • Automatic dependency detection - Extracts imports and installs missing packages
  • Real-time output - See stdout and stderr as your code runs
  • Smart dependency management - Skips standard library modules

Requirements

  • Rust 1.70+ (for building)
  • Python 3.x (for running code)
  • pip (for installing dependencies)

Installation

git clone <your-repo>
cd text_edit
cargo build --release

Usage

Run the application:

cargo run --release

Keyboard Shortcuts

  • Ctrl+N: New file
  • Ctrl+O: Open file
  • Ctrl+S: Save file
  • Ctrl+R: Run Python code

UI Components

  1. Editor Panel (center): Write your Python code with line numbers and issue indicators
  2. Diagnostics Panel (left): View all detected issues with descriptions and quick fixes
  3. Output Panel (bottom): See execution results and dependency installation logs

Example

When you write code like this:

def example_function():
    try:
        result = []
        for i in range(len([1, 2, 3])):
            result.append(i * 2)
        return result
    except:
        pass

CodeCraft will detect:

  • Bare except: clause (with one-click fix)
  • Inefficient range(len()) pattern
  • List comprehension opportunity

Architecture

  • analyzer.rs: Tree-sitter integration and Python code analysis
  • runner.rs: Python code execution with dependency management
  • main.rs: egui-based UI and application logic

Dependencies

  • eframe/egui: Modern immediate-mode GUI framework
  • tree-sitter: Incremental parsing system
  • tree-sitter-python: Python grammar for tree-sitter
  • regex: Pattern matching for import detection
  • rfd: Native file dialogs

Future Enhancements

  • More code actions (convert to f-string, refactor to comprehension)
  • Custom rule configuration
  • Support for other languages
  • LSP integration
  • Inline code suggestions with ghost text

License

MIT

Description
No description provided
Readme 44 KiB
Latest
2025-10-20 17:14:37 +00:00
Languages
Rust 94.3%
Python 5.7%