Metadata-Version: 2.1
Name: pipe2prompt
Version: 0.1.0
Summary: Prompt to pipe
Author-email: Ahn Keeho <digsy89@gmail.com>
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/x-rst
License-File: LICENSE.txt
Requires-Dist: click==8.1.7
Requires-Dist: openai==1.59.3

pipe2prompt (p2p)
=================

A command-line tool that lets you pipe input into customizable AI prompts.

**Example Usage**

.. code-block:: bash

    # Generate a commit message from staged changes
    git diff --staged | p2p create-commit-message

**Example Output**

.. code-block:: text

    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
------------

Install from source:

.. code-block:: bash

    git clone https://github.com/digsy89/pipe2prompt
    cd pipe2prompt
    pip install --user .

This will:

1. Install the package locally with pip
2. Set up shell completion
3. 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:

.. code-block:: bash

    export OPENAI_API_KEY=your-api-key-here


Shell Completion
----------------

To manually set up completion:

.. code-block:: bash

    p2p init

This will:

1. Create completion scripts in your shell's completion directory
2. Add source commands to your shell config file
3. 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:

.. code-block:: bash

    # For bash
    source ~/.bashrc
    
    # For zsh
    source ~/.zshrc
    
    # For fish
    source ~/.config/fish/config.fish


Usage
-----

Basic usage:

.. code-block:: bash

    # 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:

.. code-block:: toml

    [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
