Skip to main content

Prompit

Project description

prompit Common Changelog GitHub release (latest by date)

prompit is a Python package and a Command Line Interface (CLI) tool designed to transform repositories, directories, and files into promptable texts for use with large language models. It's an invaluable tool for quickly understanding the structure of a new project and preparing it for interaction with AI models.

Features

  • List all files in your project, considering .gitignore files.
  • Print the directory structure of your project.
  • Transform your repository into a promptable text.

Installation

To install prompit from source, clone this repository and run the following command:

cd prompit
python -m pip install -e .

Alternatively you can install prompit with pip install prompit

Usage

As a CLI tool

You can use prompit to list all non-ignored files in your project:

prompit --list

To print the directory structure:

prompit --structure

To print the current directory or repo as a prompt:

prompit

This will promptfy your repo ignoring files under your .gitignore file. You can also append an instruction message on the prompt:

prompit --message "Your instruction here"

As a Python module

You can also use prompit as a Python module in your scripts. Here's an example:

from prompit import list_files, get_promptified_repo, get_repo_structure

# List all non-ignored files in the current directory
filepaths = list_files()

# Get the repository's structure, excluding all .svg files
structure = get_repo_structure(ignore_files="*.svg")

# Print the promptified repository
print(get_promptified_repo())

Examples

Here are some advanced examples of how you can use prompit:

  • To get a single file:
prompit -i * -a single_file.py

Note that the exact behavior may depend on your environment. * it will work on Windows but on unix-like systems it will probably fail. The exact reason can be explained by your favorite LLM.

In Unix-like systems, wildcard characters like * are expanded by the shell before being passed to commands, which can lead to unexpected behavior. However, in Windows Command Prompt or PowerShell, these characters are passed as-is to the command. To ensure consistent behavior across different systems, you can prevent the shell from expanding the wildcard by quoting it, like so: prompit -i '*'. This allows the command itself to handle the wildcard expansion.

  • To ignore a specific file and print the structure to the clipboard. This example uses Windows's clip.exe:
prompit -i src/languages.json -s | clip
  • For Node.js projects, you might want to ignore package-lock.json:
prompit -i package-lock.json

Note: .gitignore and .git specs are the only ones automatically ignored.

Contributing

We welcome contributions! Please see our CONTRIBUTING.md for details on how to contribute to this project.

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

prompit-0.3.3.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

prompit-0.3.3-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file prompit-0.3.3.tar.gz.

File metadata

  • Download URL: prompit-0.3.3.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for prompit-0.3.3.tar.gz
Algorithm Hash digest
SHA256 e539fe94a9a2b0b4f0d7b8e4dc253893b884b15eb2f34bd0d72ce4f32569d91d
MD5 9daccc7211af3a93a989974f6107f16f
BLAKE2b-256 7208db981a1d444f8f91aeb5b4c72e860eb509c9de5d36375eb2073b145d19b7

See more details on using hashes here.

File details

Details for the file prompit-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: prompit-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for prompit-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 45f01e3fd048f53c61f8d93d15d8777dd4dbf7d73df5bf5d0a763f5742bff7a5
MD5 8c85f2af4c1aa3a683b17e044f2f2bba
BLAKE2b-256 e3f6c752adf55099bff9e66e4b17828e8149915bbc4c17890b133c9d466c45de

See more details on using hashes here.

Supported by

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