pipe2prompt (p2p)
A command-line tool that lets you pipe input into customizable AI prompts.
Example Usage
# Generate a commit message from staged changes
git diff --staged | p2p create-commit-message
# Example explanation of the above command
# This command takes the output of `git diff --staged` and pipes it into the `p2p` tool
# to generate a commit message based on the changes.
Example Output
refactor: reorder imports in cli.py and update flake8 select list
- Reorganize the import order in `pipe2prompt/cli.py` for better readability.
- Remove the `isort` ("I") code from the flake8 select list in `pyproject.toml`.
Installation
To install the package, you can use pip:
pip install pipe2prompt
To install from source:
git clone https://github.com/digsy89/pipe2prompt
cd pipe2prompt
pip install --user .
This will:
Install the package locally with pip
Set up shell completion
Create initial config file at ~/.p2p/config.toml
OpenAI API Key
This tool requires an OpenAI API key to function. You can set it up in two ways:
export OPENAI_API_KEY=your-api-key-here
Shell Completion
To manually set up completion:
p2p init
This will:
Create completion scripts in your shell’s completion directory
Add source commands to your shell config file
Enable tab completion for p2p commands and prompts
Supported shells:
Bash (~/.bash_completion.d/_p2p)
Zsh (~/.zsh/completions/_p2p)
Fish (~/.config/fish/completions/_p2p)
After installation, you may need to restart your shell or source your config file:
# For bash
source ~/.bashrc
# For zsh
source ~/.zshrc
# For fish
source ~/.config/fish/config.fish
Usage
Basic usage:
# Run a prompt directly
p2p <prompt-name> "your input"
# Pipe input into a prompt
echo "your input" | p2p <prompt-name>
# List available prompts
p2p prompt list
p2p prompt list --long
Prompt Configuration
Prompts are configured in ~/.p2p/config.toml. Example configuration:
[explain]
content = "Explain this code: {pipe}"
base_model = "gpt-3.5-turbo"
description = "Explain code"
[fix]
content = "Fix this code and explain the issues: {pipe}"
base_model = "gpt-3.5-turbo"
description = "Fix code issues"
Each prompt requires:
content: The prompt template. Use {pipe} to reference piped input
base_model: The OpenAI model to use
description: Description shown in help text
enabled: Optional boolean to enable/disable the prompt
You can find example configurations in the project’s [pipe2prompt/config.toml](pipe2prompt/config.toml) file for reference.
License
MIT
Metadata
Release files for pipe2prompt 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pipe2prompt-0.1.1.tar.gz | 7.6 kB | Without provenance | Details for pipe2prompt-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pipe2prompt-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pipe2prompt-0.1.1-py3-none-any.whl |
Total release size: 15.8 kB
Release files / pipe2prompt-0.1.1.tar.gz
| Download URL | pipe2prompt-0.1.1.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cff2a0b6f3128359361a258732da390b5ca967ba1f9e207174c8fdb0c763c841
|
|
BLAKE2b-256 checksum How to use checksums |
040c5b6edb861ac71d35395683d1d891784776d6ef9401b78ddec381bc061591
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.11
|
Release files / pipe2prompt-0.1.1-py3-none-any.whl
| Download URL | pipe2prompt-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd6e1cbf38ec9c03811cc7bc490461038be88940fa57955f9bff4c4539825f59
|
|
BLAKE2b-256 checksum How to use checksums |
f7ba2486b92a7b132e08cb038b9e4276718a30cb67fbc98afb92ca3e1d46b24e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.11
|
Security for pipe2prompt 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.