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:
- When you accept or reject a fix, the feedback is recorded
- Features are extracted from each issue (type, severity, context, etc.)
- A RandomForest classifier learns your preferences
- Future suggestions are ranked by predicted acceptance probability
Force retrain the model:
weave model retrain
Reset to baseline:
weave model reset
Support
License
MIT License - see LICENSE file for details.
Metadata
Release files for weave-master 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| weave_master-1.0.1.tar.gz | 38.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| weave_master-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 79.4 kB
Release files / weave_master-1.0.1.tar.gz
| Download URL | weave_master-1.0.1.tar.gz |
|---|---|
| Size | 38.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b79859422163d7531cb8cf63a9c139d447e3488449721f97e031b9b02de9c78
|
|
BLAKE2b-256 checksum How to use checksums |
7bf12c1b10e88ece919eae1e87e4dd77242c7502b099877df380f544f6963c46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / weave_master-1.0.1-py3-none-any.whl
| Download URL | weave_master-1.0.1-py3-none-any.whl |
|---|---|
| Size | 41.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
efdce84a073f7d5cdfd890231114e8018322c47a26a88b46f8c0fcae8043bf00
|
|
BLAKE2b-256 checksum How to use checksums |
54c1016ca1e512c08b4b35cfec34aaad3d06fef5fb9247e85d0f05ac24a0648b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|