Skip to main content

CLI tool to analyze and create text dumps of codebases for LLMs

Project description

Gitingest

Image

License PyPI version GitHub stars Downloads

Discord

Turn any Git repository into a prompt-friendly text ingest for LLMs.

You can also replace hub with ingest in any GitHub URL to access the corresponding digest.

gitingest.com · Chrome Extension · Firefox Add-on

🚀 Features

  • Easy code context: Get a text digest from a Git repository URL or a directory
  • Smart Formatting: Optimized output format for LLM prompts
  • Statistics about:
    • File and directory structure
    • Size of the extract
    • Token count
  • CLI tool: Run it as a shell command
  • Python package: Import it in your code

📚 Requirements

  • Python 3.7+

📦 Installation

Purgo Ingest is available on PyPI. You can install it using pip:

pip install purgo_ingest

However, it might be a good idea to use pipx to install it. You can install pipx using your preferred package manager.

brew install pipx
apt install pipx
scoop install pipx
...

If you are using pipx for the first time, run:

pipx ensurepath
# install purgo_ingest
pipx install purgo_ingest

🧩 Browser Extension Usage

Available in the Chrome Web Store Get The Add-on for Firefox Get from the Edge Add-ons

The extension is open source at lcandy2/gitingest-extension.

Issues and feature requests are welcome to the repo.

💡 Command line usage

The purgo_ingest command line tool allows you to analyze codebases and create a text dump of their contents.

# Basic usage
purgo_ingest /path/to/directory

# From URL
purgo_ingest https://github.com/cyclotruc/gitingest

# See more options
purgo_ingest --help

This will write the digest in a text file (default digest.txt) in your current working directory.

🐍 Python package usage

# Synchronous usage
from purgo_ingest import ingest

summary, tree, content = ingest("path/to/directory")

# or from URL
summary, tree, content = ingest("https://github.com/cyclotruc/gitingest")

By default, this won't write a file but can be enabled with the output argument.

# Asynchronous usage
from purgo_ingest import ingest_async
import asyncio

result = asyncio.run(ingest_async("path/to/directory"))

Structured Output

If you need to ingest a repository and want to access each file separately rather than combined in a single prompt, use the structured output entry points:

# Synchronous structured usage
from purgo_ingest import ingest_structured

# Returns a dictionary with metadata and individual file contents
result = ingest_structured("path/to/directory")

# Access metadata
repo_name = result["metadata"]["repository"]

# Access individual files
for file in result["files"]:
    file_path = file["path"]
    file_content = file["content"]
    file_size = file["size"]
    # Process each file separately
# Asynchronous structured usage
from purgo_ingest import ingest_structured_async
import asyncio

# Returns a dictionary with metadata and individual file contents
result = asyncio.run(ingest_structured_async("path/to/directory"))

The structured output is also available in the CLI:

# Generate structured JSON output
purgo_ingest /path/to/directory --structured

# Output to a specific file
purgo_ingest /path/to/directory --structured -o output.json

Jupyter notebook usage

from purgo_ingest import ingest_async

# Use await directly in Jupyter
summary, tree, content = await ingest_async("path/to/directory")

This is because Jupyter notebooks are asynchronous by default.

🐳 Self-host

  1. Build the image:

    docker build -t gitingest .
    
  2. Run the container:

    docker run -d --name gitingest -p 8000:8000 gitingest
    

The application will be available at http://localhost:8000.

If you are hosting it on a domain, you can specify the allowed hostnames via env variable ALLOWED_HOSTS.

# Default: "gitingest.com, *.gitingest.com, localhost, 127.0.0.1".
ALLOWED_HOSTS="example.com, localhost, 127.0.0.1"

🤝 Contributing

Non-technical ways to contribute

  • Create an Issue: If you find a bug or have an idea for a new feature, please create an issue on GitHub. This will help us track and prioritize your request.
  • Spread the Word: If you like Gitingest, please share it with your friends, colleagues, and on social media. This will help us grow the community and make Gitingest even better.
  • Use Gitingest: The best feedback comes from real-world usage! If you encounter any issues or have ideas for improvement, please let us know by creating an issue on GitHub or by reaching out to us on Discord.

Technical ways to contribute

Gitingest aims to be friendly for first time contributors, with a simple Python and HTML codebase. If you need any help while working with the code, reach out to us on Discord. For detailed instructions on how to make a pull request, see CONTRIBUTING.md.

🛠️ Stack

Looking for a JavaScript/FileSystemNode package?

Check out the NPM alternative 📦 Repomix: https://github.com/yamadashy/repomix

🚀 Project Growth

Star History Chart

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

purgo_ingest-0.1.4.tar.gz (44.0 kB view details)

Uploaded Source

Built Distribution

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

purgo_ingest-0.1.4-py3-none-any.whl (45.6 kB view details)

Uploaded Python 3

File details

Details for the file purgo_ingest-0.1.4.tar.gz.

File metadata

  • Download URL: purgo_ingest-0.1.4.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for purgo_ingest-0.1.4.tar.gz
Algorithm Hash digest
SHA256 710187ec12077d4020259b447648fb57bc408ddca8bdb963d1269354f94e97a9
MD5 ad1d75f77a0ddd1e53dd5e0f9dfb0515
BLAKE2b-256 210db028bd37a3ee4916c1420452ece9c833dea9f84725f46208f595671ba15b

See more details on using hashes here.

File details

Details for the file purgo_ingest-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: purgo_ingest-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 45.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for purgo_ingest-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 652e867913255dbfe293db70c08072b8a7083c99ad1a099caa9b90d36216a949
MD5 9ad8cc119c4563ea202b799d0c6623d1
BLAKE2b-256 1cb5d493a429184a9a54b8b4c43e56fe2edc2fb2804a7fc41ad58f4c488c37b4

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