Skip to main content

Generate a formatted LLM prompt from a repository directory.

Project description

RepoForge

RepoForge is a Python tool that scans a repository directory, summarizes its contents, and generates a formatted prompt with XML tags. This prompt includes a visual directory tree and summaries of text files, making it ideal for integrations with other tools or for creating structured inputs for language models.

Features

  • Recursive Directory Scanning: Walks through the directory tree while ignoring specified directories (e.g., .git, __pycache__, .idea, .vscode).
  • File Summarization: Reads text files and includes a truncated summary (up to a configurable number of lines) unless the file exceeds a set size limit.
  • Ignored File Types: Skips files with certain extensions (e.g., .pyc, images, PDFs, ZIPs) to focus on relevant content.
  • XML-Formatted Output: Combines the directory tree and file summaries into a structured XML-like prompt.
  • Command-Line Interface (CLI): Includes an optional CLI entrypoint for manual testing and quick usage.

Installation

Repo Prompt Generator can be installed via PyPI once published:

pip install repoforge

Alternatively, clone the repository from GitHub and install it locally:

git clone https://github.com/ahearn15/repoforge.git
cd repoforge
pip install .

Usage

As a Command-Line Tool

The package provides a CLI that allows you to generate a prompt directly from the terminal.

python -m repoforge <repo_directory> [<system_message>] [<user_instructions>]

For example:

python -m repoforge /path/to/your/repo "System message goes here" "User instructions go here"

As a Python Module

You can also import and use the functionality directly in your Python code:

from repoforge import generate_prompt

# Define the repository directory and optional messages
repo_dir = "/path/to/your/repo"
system_message = "System message goes here"
user_instructions = "User instructions go here"

# Generate the formatted prompt
prompt = generate_prompt(repo_dir, system_message, user_instructions)
print(prompt)

Configuration

The behavior of Repo Prompt Generator can be modified by adjusting the following configuration constants in the code:

  • IGNORED_DIRS: Set of directory names to skip (default: {'.git', '__pycache__', '.idea', '.vscode'}).
  • IGNORED_EXTENSIONS: Set of file extensions to ignore (default: {'.pyc', '.png', '.jpg', '.jpeg', '.gif', '.pdf', '.zip'}).
  • MAX_FILE_SIZE_BYTES: Maximum file size in bytes to summarize (default: 100000 bytes).
  • MAX_SUMMARY_LINES: Maximum number of lines to include from a file’s content (default: 500).

Feel free to modify these constants to fit the needs of your project.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contributing

Contributions, bug reports, and feature requests are welcome! Please open an issue or submit a pull request on GitHub.

Acknowledgements

repo-forge leverages Python's standard libraries, such as os and textwrap, to provide a simple yet powerful solution for summarizing repository contents.

Happy coding!

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

repoforge-0.1.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

repoforge-0.1.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file repoforge-0.1.3.tar.gz.

File metadata

  • Download URL: repoforge-0.1.3.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for repoforge-0.1.3.tar.gz
Algorithm Hash digest
SHA256 df81f2d120d86e55b3dc4745eaa1479fc140edee8f7f79808f9f40e9a61b5b85
MD5 a12bc6d6ab6fbf81c65f1be6521db8d3
BLAKE2b-256 751c52c3bcc0f475278da9b46ddd2281bbe7b408b3e6e47bfee344fb9778d092

See more details on using hashes here.

File details

Details for the file repoforge-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: repoforge-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for repoforge-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8a5d7d2aeac11feb13c0c943936801b2f830e646ca3063917d382085a81d727b
MD5 2b1f5ec4fe0cfbcbf857b936383ada7b
BLAKE2b-256 27149cfd04deeaba8e49cd22f26987769d8ccd3291e584c84676858ef8f26d41

See more details on using hashes here.

Supported by

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