Giter Site home page Giter Site logo

prompit's Introduction

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.

prompit's People

Contributors

oliveirabruno01 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.