Skip to main content

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

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 output
  • PPG_JSON_OUTPUT_FILE: File for JSON output
  • PPG_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 โš™๏ธ

  1. The tool scans your project directory, respecting .gitignore and any custom ignore patterns. ๐Ÿ”
  2. 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. ๐Ÿ“
  3. An event-based system handles file processing and output generation, making the code extensible. ๐Ÿ”„
  4. Sensitive data is automatically detected and masked with asterisks (*) to protect your credentials. ๐Ÿ”’
  5. 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

project_prompt_generator-0.1.7.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

project_prompt_generator-0.1.7-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

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

Hashes for project_prompt_generator-0.1.7.tar.gz
Algorithm Hash digest
SHA256 211751223beb6f082c3c8067c952c31815d1812b9f54c16ec974c04081f97a02
MD5 233c341988e55e8772084551052471a4
BLAKE2b-256 30a76783160d7abf4dfeae25d6c22361e1341ce7f0f2b10601431ad268792d36

See more details on using hashes here.

File details

Details for the file project_prompt_generator-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for project_prompt_generator-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 01773a316497ce3ee7251b5250792dde6b17641f8b4fb5d498cb8b1ab2c06525
MD5 78316ef72dd16a5516fa63a674c8fc83
BLAKE2b-256 9539bdb7a4cadcd65d60f9a3ce52680e45e4ea75d391ff90f969578879911e93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page