AI Response Weaver is a Python-based application designed to streamline the process of converting AI-generated code blocks into actual files. It monitors a specified file for changes, parses AI-generated code blocks within that file, and creates or updates corresponding files based on the content. The app intelligently handles various programming languages using a configurable JSON file to parse file names and relative paths, ensuring that the correct files are created or merged seamlessly.
- Automated File Creation and Update: Converts code blocks in a specified file into actual files, creating new files or updating existing ones.
- Intelligent File Monitoring: Continuously monitors a specified file for changes and processes new content automatically, skipping already processed content.
- Git Integration: Automatically creates new branches for file updates, facilitating version control and conflict resolution.
- Backup System: Creates backups of existing files before overwriting them, storing backups in a designated history folder.
- Configurable File Type Parsing: Uses a JSON configuration file to handle various file types and comment styles for parsing file names and paths.
- Detailed Logging: Generates comprehensive reports of processing activities and saves instruction blocks for reference.
- VS Code Integration: Triggers merge operations in VS Code or code-server for manual resolution of conflicts.
-
Clone the Repository:
git clone https://github.com/yourusername/AI-Response-Weaver.git cd AI-Response-Weaver
-
Set Up the Virtual Environment:
python3 -m venv venv source venv/bin/activate
-
Install the Package:
pip install -e .
-
Clone the Repository:
git clone https://github.com/yourusername/AI-Response-Weaver.git cd AI-Response-Weaver
-
Create and Activate Conda Environment:
conda create -n ai-weaver python=3.8 conda activate ai-weaver
-
Install the Package:
pip install -e .
-
Environment Variables: Create a
.env
file in the root directory with the following content:VSCODE_EXECUTABLE=code # OR VSCODE_EXECUTABLE=code-server
-
Config File: The
config/config.json
file contains settings for various file types and comment styles. Example structure:{ "file_types": { "dart": { "comment_styles": ["slash"] }, "py": { "comment_styles": ["hash"] }, "html": { "comment_styles": ["xml"] } }, "comment_styles": { "slash": ["//", "/*"], "hash": ["#"], "xml": ["<!--"] } }
To add support for additional file types, update this file accordingly.
Run AI Response Weaver using the following command:
weaver [file_to_monitor] [log_folder]
- If run without arguments, it will check for a
.weaver
file in the current directory. - If no
.weaver
file is found, it will prompt for the file to monitor (default:weaver.md
) and the log folder (default:weaver_logs
). - The
.weaver
file will be created/updated with the current settings for future runs.
- Initialization: Load config, set up file monitoring
- File Change Detection: Monitor specified file for changes
- Parsing: Extract and validate code blocks and instructions
- File Operations: Create new files, prepare updates for existing files
- Git Operations: Create branches, commit changes
- VS Code Integration: Trigger merge operations for conflict resolution
- Logging: Generate reports, create backups, save instruction blocks
- Continuous Monitoring: Return to step 2
To set up the project for development:
- Make your changes to the code in the
ai_response_weaver
directory. - Test your changes by reinstalling the package:
pip install -e .
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
No license, but it will be cool if you let me know if you used it and what you did with it and if it worked for you.
For any questions or support, please open an issue in the GitHub repository.