kopipasta


Namekopipasta JSON
Version 0.16.0 PyPI version JSON
download
home_pagehttps://github.com/mkorpela/kopipasta
SummaryA CLI tool to generate prompts with project structure and file contents
upload_time2024-10-05 20:10:32
maintainerNone
docs_urlNone
authorMikko Korpela
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

<img src="kopipasta.jpg" alt="kopipasta" width="300">

- 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

```bash
❯ 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)

```python
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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mkorpela/kopipasta",
    "name": "kopipasta",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Mikko Korpela",
    "author_email": "mikko.korpela@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a2/22/2f151d9936d97319f5f94a2750b9c529022510a0b91ceceaab2be868a7b6/kopipasta-0.16.0.tar.gz",
    "platform": null,
    "description": "# kopipasta\n\nA 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.\n\n<img src=\"kopipasta.jpg\" alt=\"kopipasta\" width=\"300\">\n\n- An LLM told me that kopi means Coffee in some languages.. and a Diffusion model then made this delicious soup.\n\n## Installation\n\nYou can install kopipasta using pipx (or pip):\n\n```\npipx install kopipasta\n```\n\n## Usage\n\nTo use kopipasta, run the following command in your terminal:\n\n```\nkopipasta [files_or_directories_or_urls]\n```\n\nReplace `[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.\n\nExample:\n```\nkopipasta src/ config.json https://example.com/api-docs\n```\n\nThis will generate a prompt including:\n- The project structure\n- Contents of the specified files and directories (with snippet options for large files)\n- Content fetched from the provided URLs (with snippet options for large content)\n- Handling of environment variables found in a `.env` file (if present)\n\nFiles and directories typically excluded in version control (based on common .gitignore patterns) are ignored.\n\nThe generated prompt will be displayed in the console and automatically copied to your clipboard.\n\n## Features\n\n- Generates a structured prompt with project overview, file contents, web content, and task instructions\n- Offers snippet options for large files (>100 KB) and web content (>10,000 characters)\n- Fetches and includes content from web URLs\n- Detects and securely handles environment variables from a `.env` file\n- Ignores files and directories based on common .gitignore patterns\n- Allows interactive selection of files to include\n- Automatically copies the generated prompt to the clipboard\n\n## Environment Variable Handling\n\nIf a `.env` file is present in the current directory, kopipasta will:\n1. Read and store the environment variables\n2. Detect these variables in file contents and web content\n3. Prompt you to choose how to handle each detected variable:\n   - (m)ask: Replace the value with asterisks\n   - (s)kip: Replace the value with \"[REDACTED]\"\n   - (k)eep: Leave the value as-is\n\nThis ensures sensitive information is handled securely in the generated prompt.\n\n## Snippet Functionality\n\nFor large files (>100 KB) and web content (>10,000 characters), kopipasta offers a snippet option:\n\n- For files: The first 50 lines or 4 KB (4,096 bytes), whichever comes first\n- For web content: The first 1,000 characters\n\nThis helps manage the overall prompt size while still providing useful information about the content structure.\n\n## Example output\n\n```bash\n\u276f kopipasta . https://example.com/api-docs\n\nDirectory: .\nFiles:\n- __init__.py\n- main.py (120 KB, ~120000 chars, ~30000 tokens)\n- large_data.csv (5 MB, ~5000000 chars, ~1250000 tokens)\n- .env\n\n(y)es add all / (n)o ignore all / (s)elect individually / (q)uit? y\nmain.py is large. Use (f)ull content or (s)nippet? s\nlarge_data.csv is large. Use (f)ull content or (s)nippet? s\nAdded all files from .\nAdded web content from: https://example.com/api-docs\n\nFile and web content selection complete.\nCurrent prompt size: 10500 characters (~ 2625 tokens)\nSummary: Added 3 files from 1 directory and 1 web source.\n\nDetected environment variables:\n- API_KEY=12345abcde\n\nHow would you like to handle API_KEY? (m)ask / (k)eep: m\n\nEnter the task instructions: Implement new API endpoint\n\nGenerated prompt:\n# Project Overview\n\n## Project Structure\n\n```\n|-- ./\n    |-- __init__.py\n    |-- main.py\n    |-- large_data.csv\n    |-- .env\n```\n\n## File Contents\n\n### __init__.py\n\n```python\n# Initialize package\n```\n\n### main.py (snippet)\n\n```python\nimport os\nimport pandas as pd\n\nAPI_KEY = os.getenv('API_KEY')\n\ndef process_data(file_path):\n    df = pd.read_csv(file_path)\n    # Rest of the function...\n\n# More code...\n```\n\n### large_data.csv (snippet)\n\n```\nid,name,value\n1,John,100\n2,Jane,200\n3,Bob,150\n4,Alice,300\n# ... (first 50 lines or 4 KB)\n```\n\n## Web Content\n\n### https://example.com/api-docs (snippet)\n\n```\nAPI Documentation\nEndpoint: /api/v1/data\nMethod: GET\nAuthorization: Bearer **********\n...\n```\n\n## Task Instructions\n\nImplement new API endpoint\n\n## Task Analysis and Planning\n\nBefore starting, explain the task back to me in your own words. Ask for any clarifications if needed. Once you're clear, ask to proceed.\n\nThen, outline a plan for the task. Finally, use your plan to complete the task.\n\nPrompt has been copied to clipboard. Final size: 1500 characters (~ 375 tokens)\n```\n\n## License\n\nThis project is licensed under the MIT License.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A CLI tool to generate prompts with project structure and file contents",
    "version": "0.16.0",
    "project_urls": {
        "Homepage": "https://github.com/mkorpela/kopipasta"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "21bb5da04576fdceeb4d47c0510dc8400cf2b592e72344bfca1931ac83ef4e5d",
                "md5": "39fe89ec2d2d338a9971d31debabb137",
                "sha256": "a2772e554227a51e3dfdf0999afca78743a15e7d2a370a62254c0eb20b3b7f23"
            },
            "downloads": -1,
            "filename": "kopipasta-0.16.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "39fe89ec2d2d338a9971d31debabb137",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11873,
            "upload_time": "2024-10-05T20:10:31",
            "upload_time_iso_8601": "2024-10-05T20:10:31.274240Z",
            "url": "https://files.pythonhosted.org/packages/21/bb/5da04576fdceeb4d47c0510dc8400cf2b592e72344bfca1931ac83ef4e5d/kopipasta-0.16.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a2222f151d9936d97319f5f94a2750b9c529022510a0b91ceceaab2be868a7b6",
                "md5": "24eae368975adc4785a9886eb240e113",
                "sha256": "87e57eb231618b1a881b36a4ea19b90f3701a28e939b3698dd7f54de3e490db3"
            },
            "downloads": -1,
            "filename": "kopipasta-0.16.0.tar.gz",
            "has_sig": false,
            "md5_digest": "24eae368975adc4785a9886eb240e113",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 13487,
            "upload_time": "2024-10-05T20:10:32",
            "upload_time_iso_8601": "2024-10-05T20:10:32.768713Z",
            "url": "https://files.pythonhosted.org/packages/a2/22/2f151d9936d97319f5f94a2750b9c529022510a0b91ceceaab2be868a7b6/kopipasta-0.16.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-05 20:10:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mkorpela",
    "github_project": "kopipasta",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "kopipasta"
}
        
Elapsed time: 1.38956s