Skip to main content

A proactive code healer that predicts and fixes Python issues before they cause problems

Project description

Code Weaver

A proactive code healer that predicts and fixes Python issues before they cause problems, with ML-based learning from user feedback.

Features

  • AST-based Analysis: Deep code analysis using Python's Abstract Syntax Tree
  • Issue Detection: Finds undefined variables, unused imports, type errors, and syntax issues
  • Auto-fix Suggestions: Intelligent fix suggestions with confidence scores
  • ML Learning: Learns from your feedback to improve fix suggestions over time
  • File Watching: Continuous monitoring with automatic issue detection
  • Safe Healing: Rollback support and atomic file operations

Installation

pip install code-weaver

Quick Start

Command Line

# Analyze a file or directory
weave check src/
weave check myfile.py

# Watch mode (continuous monitoring)
weave watch src/

# Interactive fix mode
weave heal src/myfile.py

# Rollback last fix
weave rollback src/myfile.py

# View/manage ML model
weave model status        # Show model stats
weave model retrain       # Force retrain
weave model reset         # Reset to baseline

# Configure
weave config set auto_heal true
weave config set confidence_threshold 0.85

Python API

from code_weaver import Weaver, analyze_file, analyze_code

# Quick analysis
issues = analyze_file("mycode.py")
issues = analyze_code("x = undefined_var")

# Full control
weaver = Weaver(
    auto_heal=False,
    confidence_threshold=0.8,
    learn=True,  # Enable ML feedback
)

# Analyze
issues = weaver.analyze("src/")

# Apply fixes interactively
for issue in issues:
    if issue.suggested_fix:
        weaver.apply_fix(issue)  # Prompts for confirmation

# Watch mode
weaver.watch("src/", callback=my_handler)

Issue Types Detected

Undefined Variables

  • Detects use before assignment
  • Suggests imports, typo fixes, or initialization

Unused Imports

  • Tracks all imports and their usage
  • Safe removal suggestions

Type Errors

  • Detects obvious type mismatches (str + int, etc.)
  • Uses type hints when available

Syntax Issues

  • Missing colons, unmatched brackets
  • f-string errors
  • Indentation problems

Configuration

Code Weaver stores its configuration in ~/.config/code_weaver/config.json:

{
    "auto_heal": false,
    "confidence_threshold": 0.8,
    "watch_debounce_ms": 300,
    "max_history_per_file": 50,
    "ignore_patterns": [".git", "__pycache__", "venv", ".venv", "node_modules"]
}

ML Feedback System

Code Weaver learns from your decisions:

  1. When you accept or reject a fix, the feedback is recorded
  2. Features are extracted from each issue (type, severity, context, etc.)
  3. A RandomForest classifier learns your preferences
  4. Future suggestions are ranked by predicted acceptance probability

Force retrain the model:

weave model retrain

Reset to baseline:

weave model reset

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weave_master-1.0.0.tar.gz (38.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

weave_master-1.0.0-py3-none-any.whl (40.8 kB view details)

Uploaded Python 3

File details

Details for the file weave_master-1.0.0.tar.gz.

File metadata

  • Download URL: weave_master-1.0.0.tar.gz
  • Upload date:
  • Size: 38.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for weave_master-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1fc2ba84ae95febd0f46fda7c24e951c15132a603f153977390dca4e935d4cc1
MD5 038f8d5c0b7e302f9dc27055987e9a3e
BLAKE2b-256 303d047a980537224679c803bfd389f27a1799409892f5aec580f91d406c795f

See more details on using hashes here.

File details

Details for the file weave_master-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: weave_master-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 40.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for weave_master-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ca56f4b6296bb92f2ab74a82d581036f792ecc90d65e2bcc10de1a3dd73ea87
MD5 53629c55dc5463773b2ee7ffb27f6101
BLAKE2b-256 6bf93047d38645bf50b3c217a55d79ede823b143085213b6ca8154db7ab83d10

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page