104 lines
4.1 KiB
Markdown
104 lines
4.1 KiB
Markdown
# LLM Dumper for PrestaShop (or any) Modules
|
|
|
|
A simple, zero-dependency PHP script to aggregate all meaningful source code from a PrestaShop module into a single text file. This tool is designed to make it easy to copy-paste an entire module's codebase into the context window of a Large Language Model (LLM) like GPT-4, Claude, or Llama.
|
|
|
|
## The Problem It Solves
|
|
|
|
When working with LLMs for code analysis, debugging, or documentation, you often need to provide the full source code of a project as context. For a typical PrestaShop module, this involves opening dozens of files (`.php`, `.tpl`, `.js`, `.css`, etc.) and pasting them one by one. This is tedious, error-prone, and inefficient.
|
|
|
|
This script automates that process, creating a single, well-structured text file containing all relevant code, ready to be fed to an LLM.
|
|
|
|
## Features
|
|
|
|
- **Recursive Scanning**: Scans the entire module directory, including all subdirectories.
|
|
- **Intelligent Exclusions**: Automatically ignores:
|
|
- The `vendor` directory (Composer dependencies).
|
|
- Common image file types (`.png`, `.jpg`, `.svg`, etc.).
|
|
- The script itself (`llmdumper.php`).
|
|
- The generated output file (`.llmdump`).
|
|
- **Clear Context**: Prepends each file's content with a header containing its relative path (e.g., `myawesomemodule/controllers/front/main.php`).
|
|
- **Single File Output**: Creates one easy-to-manage `.llmdump` file.
|
|
- **Command-Line Friendly**: Provides progress feedback as it runs.
|
|
|
|
## How to Use
|
|
|
|
1. **Download**: Place the `llmdumper.php` script into the root directory of the PrestaShop module you want to dump.
|
|
```
|
|
/prestashop
|
|
└── /modules
|
|
└── /myawesomemodule <-- Place the script here
|
|
├── llmdumper.php
|
|
├── myawesomemodule.php
|
|
├── config.xml
|
|
└── /views
|
|
└── ...
|
|
```
|
|
|
|
2. **Navigate**: Open your terminal or command prompt and navigate to the module's directory.
|
|
```bash
|
|
cd /path/to/prestashop/modules/myawesomemodule
|
|
```
|
|
|
|
3. **Execute**: Run the script using PHP.
|
|
```bash
|
|
php llmdumper.php
|
|
```
|
|
You will see a list of files being appended to the dump.
|
|
|
|
4. **Find the Output**: A hidden file named `.llmdump` will be created in the module's root directory.
|
|
|
|
5. **Use the Content**: Open `.llmdump` in a text editor, select all (Ctrl+A / Cmd+A), copy the contents, and paste it into your LLM prompt.
|
|
|
|
6. **CLEAN UP**: **This is the most important step.** After you are done, delete both files from your server.
|
|
```bash
|
|
rm llmdumper.php .llmdump
|
|
```
|
|
|
|
---
|
|
|
|
## ⚠️ Security Warning ⚠️
|
|
|
|
- This script is intended for use in a **local development environment only**.
|
|
- The generated `.llmdump` file contains your module's **entire source code**.
|
|
- If you run this script on a live, public-facing web server, the `.llmdump` file could potentially be downloaded by anyone if your server is not configured to block access to dotfiles.
|
|
- **Always delete `llmdumper.php` and `.llmdump` immediately after use.**
|
|
|
|
---
|
|
|
|
## Example Output
|
|
|
|
The generated `.llmdump` file will look like this:
|
|
|
|
```text
|
|
//- - - - - - - - - - START: myawesomemodule/myawesomemodule.php - - - - - - - - - -//
|
|
<?php
|
|
if (!defined('_PS_VERSION_')) {
|
|
exit;
|
|
}
|
|
|
|
class MyAwesomeModule extends Module
|
|
{
|
|
// ... module class content ...
|
|
}
|
|
|
|
//- - - - - - - - - - END: myawesomemodule/myawesomemodule.php - - - - - - - - - -//
|
|
|
|
|
|
//- - - - - - - - - - START: myawesomemodule/views/templates/hook/displayHome.tpl - - - - - - - - - -//
|
|
<div class="awesome-block">
|
|
<p>{l s='This is an awesome module!' mod='myawesomemodule'}</p>
|
|
</div>
|
|
//- - - - - - - - - - END: myawesomemodule/views/templates/hook/displayHome.tpl - - - - - - - - - -//
|
|
```
|
|
|
|
## Configuration
|
|
|
|
The script has a few constants at the top that you can modify if needed:
|
|
|
|
- `OUTPUT_FILE`: Change the name of the output file (default: `.llmdump`).
|
|
- `VENDOR_DIR`: Change the name of the vendor directory to exclude (default: `vendor`).
|
|
- `IMAGE_EXTENSIONS`: Add or remove file extensions to be treated as non-text/image files.
|
|
|
|
## License
|
|
|
|
This project is licensed under the MIT License. |