{
    "sourceFile": "Project Notes/FEAT-rar-7z-support-plan.md",
    "activeCommit": 0,
    "commits": [
        {
            "activePatchIndex": 0,
            "patches": [
                {
                    "date": 1745506880027,
                    "content": "Index: \n===================================================================\n--- \n+++ \n"
                }
            ],
            "date": 1745506880027,
            "name": "Commit-0",
            "content": "# Plan for Adding .rar and .7z Support\r\n\r\n**Goal:** Extend the Asset Processor Tool to accept `.rar` and `.7z` files as input sources, in addition to the currently supported `.zip` files and folders.\r\n\r\n**Plan:**\r\n\r\n1.  **Add Required Libraries:**\r\n    *   Update the `requirements.txt` file to include `py7zr` and `rarfile` as dependencies. This will ensure these libraries are installed when setting up the project.\r\n\r\n2.  **Modify Input Extraction Logic:**\r\n    *   Locate the `_extract_input` method within the `AssetProcessor` class in `asset_processor.py`.\r\n    *   Modify this method to check the file extension of the input source.\r\n    *   If the extension is `.zip`, retain the existing extraction logic using Python's built-in `zipfile` module.\r\n    *   If the extension is `.rar`, implement extraction using the `rarfile` library.\r\n    *   If the extension is `.7z`, implement extraction using the `py7zr` library.\r\n    *   Include error handling for cases where the archive might be corrupted, encrypted (since we are not implementing password support at this stage, these should likely be skipped or logged as errors), or uses an unsupported compression method. Log appropriate warnings or errors in such cases.\r\n    *   If the input is a directory, retain the existing logic to copy its contents to the temporary workspace.\r\n\r\n3.  **Update CLI and Monitor Input Handling:**\r\n    *   Review `main.py` (CLI entry point) and `monitor.py` (Directory Monitor).\r\n    *   Ensure that the argument parsing in `main.py` can accept `.rar` and `.7z` file paths as valid inputs.\r\n    *   In `monitor.py`, modify the `ZipHandler` (or create a new handler) to watch for `.rar` and `.7z` file creation events in the watched directory, in addition to `.zip` files. The logic for triggering processing via `main.run_processing` should then be extended to handle these new file types.\r\n\r\n4.  **Update Documentation:**\r\n    *   Edit `Documentation/00_Overview.md` to explicitly mention `.rar` and `.7z` as supported input formats in the overview section.\r\n    *   Update `Documentation/01_User_Guide/02_Features.md` to list `.rar` and `.7z` alongside `.zip` and folders in the features list.\r\n    *   Modify `Documentation/01_User_Guide/03_Installation.md` to include instructions for installing the new `py7zr` and `rarfile` dependencies (likely via `pip install -r requirements.txt`).\r\n    *   Revise `Documentation/02_Developer_Guide/05_Processing_Pipeline.md` to accurately describe the updated `_extract_input` method, detailing how `.zip`, `.rar`, `.7z`, and directories are handled.\r\n\r\n5.  **Testing:**\r\n    *   Prepare sample `.rar` and `.7z` files (including nested directories and various file types) to test the extraction logic thoroughly.\r\n    *   Test processing of these new archive types via both the CLI and the Directory Monitor.\r\n    *   Verify that the subsequent processing steps (classification, map processing, metadata generation, etc.) work correctly with files extracted from `.rar` and `.7z` archives.\r\n\r\nHere is a simplified flow diagram illustrating the updated input handling:\r\n\r\n```mermaid\r\ngraph TD\r\n    A[Input Source] --> B{Is it a file or directory?};\r\n    B -- Directory --> C[Copy Contents to Workspace];\r\n    B -- File --> D{What is the file extension?};\r\n    D -- .zip --> E[Extract using zipfile];\r\n    D -- .rar --> F[Extract using rarfile];\r\n    D -- .7z --> G[Extract using py7zr];\r\n    E --> H[Temporary Workspace];\r\n    F --> H;\r\n    G --> H;\r\n    C --> H;\r\n    H --> I[Processing Pipeline Starts];"
        }
    ]
}