A tool to convert project files into structured markdown for LLM prompts
Project description
โจ project-prompt-generator (ppg) ๐
A command-line tool to convert your project's files into structured markdown documents, ideal for generating prompts for large language models (LLMs) ๐ค.
Features ๐
- Flexible Output Options: ๐ Generate individual markdown files, a single consolidated file, or JSON output.
- Automatic Markdown Conversion: ๐ Converts all project files (excluding those in
.gitignore
) into individual markdown files. - Structured Output: ๐ Option to create an all-in-one file that includes an outline and the content of all converted files for easy use with LLMs.
- Code Highlighting: ๐ Automatically detects file extensions and applies proper markdown code highlighting.
- Customizable Ignored Files: ๐ก๏ธ Respects
.gitignore
and supports additional custom ignore patterns. - Organized Output: ๐ Generates an outline file that clearly lists all converted files.
- Sensitive Data Masking: ๐ Automatically detects and masks API keys, passwords, and other sensitive information (enabled by default).
- Event-Based Architecture: ๐ก Uses an event system to process files and handle output generation.
- JSON Output Formats: ๐ Supports both compact and line-split JSON formats for different use cases.
- Clipboard Integration: ๐ Option to automatically copy output file paths to clipboard (macOS).
- last-run Tool: ๐ Quickly run recently modified scripts in your Downloads directory.
Installation ๐ ๏ธ
# Install via pipx
pipx install project-prompt-generator
# Install from source
pip install .
# Or install in development mode
pip install -e ".[dev]"
Usage ๐
โ ๏ธ Important Notes
- Markdown Output Deprecation: The
--markdown
output format is deprecated and will be removed in a future version. Please use JSON output format instead. - Sensitive Data Masking: While the tool attempts to mask sensitive information, it may not catch all instances. Always review generated files before sharing or uploading them to ensure no sensitive data is exposed.
Navigate to your project's root directory and use the following command:
# Generate JSON output with content split into lines (default)
ppg
# Generate markdown output (compact format) [DEPRECATED]
ppg --markdown
# Force execution outside of a git repository
ppg --force
# Update .envrc with output paths and exit
ppg --update-env
This creates either:
- A JSON file
project_data.json
in the current directory containing:- An outline of all processed files.
- The content of all files converted to markdown format.
Or, when using --markdown
:
- A single file
project_docs.md
in the current directory containing:- An outline listing all processed files.
- The content of all files converted to markdown format.
Or, when using --json
or --json-lines
:
- A JSON file (default:
project_data.json
) containing:- An outline of all processed files
- File contents in either:
- Compact format (with
--json
): Content as single strings - Line-split format (with
--json-lines
): Content split into arrays of lines
- Compact format (with
Security Options
The tool automatically masks sensitive data by default. You can control this behavior with:
# Disable sensitive data masking
ppg --no-mask
Default patterns detect common sensitive information like:
- API keys and tokens
- Passwords
- Database connection strings
- AWS access keys
- Generic secrets
- PowerShell secure strings
Environment Variable Configuration ๐ง
You can customize the output locations using the --update-env
option, which will automatically update your .envrc
file with the appropriate environment variables:
# Update .envrc with default output paths
ppg --update-env
This will add the following environment variables to your .envrc
file:
PPG_OUTPUT_FILE
: File for consolidated markdown outputPPG_JSON_OUTPUT_FILE
: File for JSON outputPPG_ENABLE_CLIPBOARD
: Enable/disable clipboard functionality (default: "false")
The paths will be automatically configured to use your Downloads directory with the current project name. You can then modify these paths in the .envrc
file if needed.
Note: Make sure you have direnv
installed and configured to use the .envrc
file.
Project Structure ๐
project-prompt-generator/
โโโ cli/
โ โโโ __init__.py # Package exports
โ โโโ last_run.py # Last-run tool implementation
โ โโโ ppg.py # Command-line interface
โโโ outputs/
โ โโโ __init__.py # Package exports
โ โโโ events.py # Event classes for file processing
โ โโโ json_handler.py # JSON output handler
โ โโโ osx_clipboard.py # macOS clipboard functionality
โ โโโ output_handler.py # Base output handler class
โ โโโ single_file_handler.py # Consolidated file output handler
โโโ prompts/
โ โโโ __init__.py # Package exports
โ โโโ file_processor.py # File processing utilities
โ โโโ generator.py # Core generation functionality
โ โโโ options.py # Configuration options
โ โโโ sensitive_masker.py # Sensitive data masking
โโโ utils/
โ โโโ __init__.py # Package exports
โ โโโ envrc.py # .envrc configuration
โ โโโ file_walker.py # Directory traversal and file filtering
โ โโโ ignore_handler.py # Handles .gitignore and custom ignores
โ โโโ language_mapping.py # Maps file extensions to language hints
โโโ tests/
โ โโโ test_sensitive_masker.py # Tests for sensitive data masking
โโโ setup.py # Package configuration
โโโ README.md # Documentation
How it Works โ๏ธ
- The tool scans your project directory, respecting
.gitignore
and any custom ignore patterns. ๐ - Each file is converted into a markdown format with a header showing the filename and path, followed by its content enclosed in a code block with appropriate language highlighting. ๐
- An event-based system handles file processing and output generation, making the code extensible. ๐
- Sensitive data is automatically detected and masked with asterisks (*) to protect your credentials. ๐
- Depending on the command used, the tool generates either individual markdown files, a single consolidated file, or JSON output. ๐งฉ
last-run Tool
The last-run
tool helps you quickly find and run recently modified scripts in your Downloads directory:
- Lists the 3 most recent
.sh
and.py
scripts - Shows how long ago each script was modified
- Lets you execute scripts with a simple keypress
- On macOS, allows creating and running scripts directly from clipboard content
Just run last-run
from your terminal to use this feature.
License ๐
This project is licensed under the MIT License. ๐
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file project_prompt_generator-0.1.7.tar.gz
.
File metadata
- Download URL: project_prompt_generator-0.1.7.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
211751223beb6f082c3c8067c952c31815d1812b9f54c16ec974c04081f97a02
|
|
MD5 |
233c341988e55e8772084551052471a4
|
|
BLAKE2b-256 |
30a76783160d7abf4dfeae25d6c22361e1341ce7f0f2b10601431ad268792d36
|
File details
Details for the file project_prompt_generator-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: project_prompt_generator-0.1.7-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
01773a316497ce3ee7251b5250792dde6b17641f8b4fb5d498cb8b1ab2c06525
|
|
MD5 |
78316ef72dd16a5516fa63a674c8fc83
|
|
BLAKE2b-256 |
9539bdb7a4cadcd65d60f9a3ce52680e45e4ea75d391ff90f969578879911e93
|