Skip to content

AI Response Weaver is a powerful Python-based application designed to streamline the process of converting AI-generated code blocks into actual files. It allows users to specify a file that contains AI responses, monitors that file for changes, and automatically creates or updates files based on the content.

Notifications You must be signed in to change notification settings

charlpcronje/AI-Response-Weaver

Repository files navigation

AI Response Weaver

Description

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.

Features

  • 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.

Installation

Using venv

  1. Clone the Repository:

    git clone https://github.com/yourusername/AI-Response-Weaver.git
    cd AI-Response-Weaver
  2. Set Up the Virtual Environment:

    python3 -m venv venv
    source venv/bin/activate
  3. Install the Package:

    pip install -e .

Using Conda

  1. Clone the Repository:

    git clone https://github.com/yourusername/AI-Response-Weaver.git
    cd AI-Response-Weaver
  2. Create and Activate Conda Environment:

    conda create -n ai-weaver python=3.8
    conda activate ai-weaver
  3. Install the Package:

    pip install -e .

Configuration

  1. Environment Variables: Create a .env file in the root directory with the following content:

    VSCODE_EXECUTABLE=code
    # OR
    VSCODE_EXECUTABLE=code-server
    
  2. 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.

Usage

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.

Lifecycle of the Application

  1. Initialization: Load config, set up file monitoring
  2. File Change Detection: Monitor specified file for changes
  3. Parsing: Extract and validate code blocks and instructions
  4. File Operations: Create new files, prepare updates for existing files
  5. Git Operations: Create branches, commit changes
  6. VS Code Integration: Trigger merge operations for conflict resolution
  7. Logging: Generate reports, create backups, save instruction blocks
  8. Continuous Monitoring: Return to step 2

Development

To set up the project for development:

  1. Make your changes to the code in the ai_response_weaver directory.
  2. Test your changes by reinstalling the package:
    pip install -e .

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

License

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.

Contact

For any questions or support, please open an issue in the GitHub repository.

About

AI Response Weaver is a powerful Python-based application designed to streamline the process of converting AI-generated code blocks into actual files. It allows users to specify a file that contains AI responses, monitors that file for changes, and automatically creates or updates files based on the content.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published