Skip to main content

A CLI tool to generate prompts with project structure and file contents

Project description

kopipasta

A CLI tool to generate prompts with project structure, file contents, and web content, while handling environment variables securely and offering snippets for large files also interactive patch selection, allowing you to include only the most relevant parts of your code.

kopipasta
  • An LLM told me that kopi means Coffee in some languages.. and a Diffusion model then made this delicious soup.

Installation

You can install kopipasta using pipx (or pip):

pipx install kopipasta

Usage

To use kopipasta, run the following command in your terminal:

kopipasta [files_or_directories_or_urls]

Replace [files_or_directories_or_urls] with the paths to the files or directories you want to include in the prompt, as well as any web URLs you want to fetch content from.

Example:

kopipasta src/ config.json https://example.com/api-docs

This will generate a prompt including:

  • The project structure
  • Contents of the specified files and directories (with snippet options for large files)
  • Content fetched from the provided URLs (with snippet options for large content)
  • Handling of environment variables found in a .env file (if present)

Files and directories typically excluded in version control (based on common .gitignore patterns) are ignored.

The generated prompt will be displayed in the console and automatically copied to your clipboard.

Features

  • Generates a structured prompt with project overview, file contents, web content, and task instructions
  • Offers snippet options for large files (>100 KB) and web content (>10,000 characters)
  • Fetches and includes content from web URLs
  • Detects and securely handles environment variables from a .env file
  • Ignores files and directories based on common .gitignore patterns
  • Allows interactive selection of files to include
  • Automatically copies the generated prompt to the clipboard

Environment Variable Handling

If a .env file is present in the current directory, kopipasta will:

  1. Read and store the environment variables
  2. Detect these variables in file contents and web content
  3. Prompt you to choose how to handle each detected variable:
    • (m)ask: Replace the value with asterisks
    • (s)kip: Replace the value with "[REDACTED]"
    • (k)eep: Leave the value as-is

This ensures sensitive information is handled securely in the generated prompt.

Snippet Functionality

For large files (>100 KB) and web content (>10,000 characters), kopipasta offers a snippet option:

  • For files: The first 50 lines or 4 KB (4,096 bytes), whichever comes first
  • For web content: The first 1,000 characters

This helps manage the overall prompt size while still providing useful information about the content structure.

Example output

 kopipasta . https://example.com/api-docs

Directory: .
Files:
- __init__.py
- main.py (120 KB, ~120000 chars, ~30000 tokens)
- large_data.csv (5 MB, ~5000000 chars, ~1250000 tokens)
- .env

(y)es add all / (n)o ignore all / (s)elect individually / (q)uit? y
main.py is large. Use (f)ull content or (s)nippet? s
large_data.csv is large. Use (f)ull content or (s)nippet? s
Added all files from .
Added web content from: https://example.com/api-docs

File and web content selection complete.
Current prompt size: 10500 characters (~ 2625 tokens)
Summary: Added 3 files from 1 directory and 1 web source.

Detected environment variables:
- API_KEY=12345abcde

How would you like to handle API_KEY? (m)ask / (k)eep: m

Enter the task instructions: Implement new API endpoint

Generated prompt:
# Project Overview

## Project Structure

|-- ./ |-- init.py |-- main.py |-- large_data.csv |-- .env


## File Contents

### __init__.py

```python
# Initialize package

main.py (snippet)

import os
import pandas as pd

API_KEY = os.getenv('API_KEY')

def process_data(file_path):
    df = pd.read_csv(file_path)
    # Rest of the function...

# More code...

large_data.csv (snippet)

id,name,value
1,John,100
2,Jane,200
3,Bob,150
4,Alice,300
# ... (first 50 lines or 4 KB)

Web Content

https://example.com/api-docs (snippet)

API Documentation
Endpoint: /api/v1/data
Method: GET
Authorization: Bearer **********
...

Task Instructions

Implement new API endpoint

Task Analysis and Planning

Before starting, explain the task back to me in your own words. Ask for any clarifications if needed. Once you're clear, ask to proceed.

Then, outline a plan for the task. Finally, use your plan to complete the task.

Prompt has been copied to clipboard. Final size: 1500 characters (~ 375 tokens)


## License

This project is licensed under the MIT License.

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

kopipasta-0.18.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

kopipasta-0.18.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file kopipasta-0.18.0.tar.gz.

File metadata

  • Download URL: kopipasta-0.18.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for kopipasta-0.18.0.tar.gz
Algorithm Hash digest
SHA256 737743ce3ce630e0e18e9afa7b0fa208beed6a6fb3c040799f9a7618b0b7452c
MD5 e46e993e605ab5393dcf8a198d080beb
BLAKE2b-256 a0058e8a84a0881da7bff5cb9fe5e06a2995f07a7983b85e583bb757bfb80e13

See more details on using hashes here.

File details

Details for the file kopipasta-0.18.0-py3-none-any.whl.

File metadata

  • Download URL: kopipasta-0.18.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for kopipasta-0.18.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3e69b7b13507b3f97fffb35ad8ae63ed9520a1dd3609d236c07a14b322e3419
MD5 69efdb98023c92def5a8f36a6243800c
BLAKE2b-256 d98a5f9a8c0460e16396962918e24ddea673d73f75890a243942431bf57d305c

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