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 weave-master

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

Support

Ko-fi

Buy Me A Coffee

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.1.tar.gz (38.4 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.1-py3-none-any.whl (41.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: weave_master-1.0.1.tar.gz
  • Upload date:
  • Size: 38.4 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.1.tar.gz
Algorithm Hash digest
SHA256 1b79859422163d7531cb8cf63a9c139d447e3488449721f97e031b9b02de9c78
MD5 8fe07bf7a2c1ecf9c07684fefc468eec
BLAKE2b-256 7bf12c1b10e88ece919eae1e87e4dd77242c7502b099877df380f544f6963c46

See more details on using hashes here.

File details

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

File metadata

  • Download URL: weave_master-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 41.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 efdce84a073f7d5cdfd890231114e8018322c47a26a88b46f8c0fcae8043bf00
MD5 ea8a951b1a2e547807e6b5975d7d1a4d
BLAKE2b-256 54c1016ca1e512c08b4b35cfec34aaad3d06fef5fb9247e85d0f05ac24a0648b

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