kopipasta 0.27.0__py3-none-any.whl → 0.29.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kopipasta might be problematic. Click here for more details.
- kopipasta/file.py +47 -0
- kopipasta/main.py +399 -640
- kopipasta/prompt.py +163 -0
- kopipasta/tree_selector.py +510 -0
- kopipasta-0.29.0.dist-info/METADATA +111 -0
- kopipasta-0.29.0.dist-info/RECORD +12 -0
- kopipasta-0.27.0.dist-info/METADATA +0 -171
- kopipasta-0.27.0.dist-info/RECORD +0 -9
- {kopipasta-0.27.0.dist-info → kopipasta-0.29.0.dist-info}/LICENSE +0 -0
- {kopipasta-0.27.0.dist-info → kopipasta-0.29.0.dist-info}/WHEEL +0 -0
- {kopipasta-0.27.0.dist-info → kopipasta-0.29.0.dist-info}/entry_points.txt +0 -0
- {kopipasta-0.27.0.dist-info → kopipasta-0.29.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: kopipasta
|
|
3
|
+
Version: 0.29.0
|
|
4
|
+
Summary: A CLI tool to generate prompts with project structure and file contents
|
|
5
|
+
Home-page: https://github.com/mkorpela/kopipasta
|
|
6
|
+
Author: Mikko Korpela
|
|
7
|
+
Author-email: mikko.korpela@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: pyperclip==1.9.0
|
|
23
|
+
Requires-Dist: requests==2.32.3
|
|
24
|
+
Requires-Dist: Pygments==2.18.0
|
|
25
|
+
Requires-Dist: rich==13.8.1
|
|
26
|
+
Requires-Dist: click==8.2.1
|
|
27
|
+
|
|
28
|
+
# kopipasta
|
|
29
|
+
|
|
30
|
+
[](https://pypi.python.org/pypi/kopipasta)
|
|
31
|
+
[](http://pepy.tech/project/kopipasta)
|
|
32
|
+
|
|
33
|
+
A CLI tool for taking **full, transparent control** of your LLM context. No black boxes.
|
|
34
|
+
|
|
35
|
+
<img src="kopipasta.jpg" alt="kopipasta" width="300">
|
|
36
|
+
|
|
37
|
+
- An LLM told me that "kopi" means Coffee in some languages... and a Diffusion model then made this delicious soup.
|
|
38
|
+
|
|
39
|
+
## The Philosophy: You Control the Context
|
|
40
|
+
|
|
41
|
+
Many AI coding assistants use Retrieval-Augmented Generation (RAG) to automatically find what *they think* is relevant context. This is a black box. When the LLM gives a bad answer, you can't debug it because you don't know what context it was actually given.
|
|
42
|
+
|
|
43
|
+
**`kopipasta` is the opposite.** I built it for myself on the principle of **explicit context control**. You are in the driver's seat. You decide *exactly* what files, functions, and snippets go into the prompt. This transparency is the key to getting reliable, debuggable results from an LLM.
|
|
44
|
+
|
|
45
|
+
It's a "smart copy" command for your project, not a magic wand.
|
|
46
|
+
|
|
47
|
+
## How It Works
|
|
48
|
+
|
|
49
|
+
The workflow is dead simple:
|
|
50
|
+
|
|
51
|
+
1. **Gather:** Run `kopipasta` and point it at the files, directories, and URLs that matter for your task.
|
|
52
|
+
2. **Select:** The tool interactively helps you choose what to include. For large files, you can send just a snippet or even hand-pick individual functions.
|
|
53
|
+
3. **Define:** Your default editor (`$EDITOR`) opens for you to write your instructions to the LLM.
|
|
54
|
+
4. **Paste:** The final, comprehensive prompt is now on your clipboard, ready to be pasted into ChatGPT, Gemini, Claude, or your LLM of choice.
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Using pipx (recommended for CLI tools)
|
|
60
|
+
pipx install kopipasta
|
|
61
|
+
|
|
62
|
+
# Or using standard pip
|
|
63
|
+
pip install kopipasta
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
kopipasta [options] [files_or_directories_or_urls...]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Arguments:**
|
|
73
|
+
|
|
74
|
+
* `[files_or_directories_or_urls...]`: One or more paths to files, directories, or web URLs to use as the starting point for your context.
|
|
75
|
+
|
|
76
|
+
**Options:**
|
|
77
|
+
|
|
78
|
+
* `-t TASK`, `--task TASK`: Provide the task description directly on the command line, skipping the editor.
|
|
79
|
+
|
|
80
|
+
## Key Features
|
|
81
|
+
|
|
82
|
+
* **Total Context Control:** Interactively select files, directories, snippets, or even individual functions. You see everything that goes into the prompt.
|
|
83
|
+
* **Transparent & Explicit:** No hidden RAG. You know exactly what's in the prompt because you built it. This makes debugging LLM failures possible.
|
|
84
|
+
* **Web-Aware:** Pulls in content directly from URLs—perfect for API documentation.
|
|
85
|
+
* **Safety First:**
|
|
86
|
+
* Automatically respects your `.gitignore` rules.
|
|
87
|
+
* Detects if you're about to include secrets from a `.env` file and asks what to do.
|
|
88
|
+
* **Context-Aware:** Keeps a running total of the prompt size (in characters and estimated tokens) so you don't overload the LLM's context window.
|
|
89
|
+
* **Developer-Friendly:**
|
|
90
|
+
* Uses your familiar `$EDITOR` for writing task descriptions.
|
|
91
|
+
* Copies the final prompt directly to your clipboard.
|
|
92
|
+
* Provides syntax highlighting during chunk selection.
|
|
93
|
+
|
|
94
|
+
## A Real-World Example
|
|
95
|
+
|
|
96
|
+
I had a bug where my `setup.py` didn't include all the dependencies from `requirements.txt`.
|
|
97
|
+
|
|
98
|
+
1. I ran `kopipasta -t "Update setup.py to read dependencies dynamically from requirements.txt" setup.py requirements.txt`.
|
|
99
|
+
2. The tool confirmed the inclusion of both files and copied the complete prompt to my clipboard.
|
|
100
|
+
3. I pasted the prompt into my LLM chat window.
|
|
101
|
+
4. I copied the LLM's suggested code back into my local `setup.py`.
|
|
102
|
+
5. I tested the changes and committed.
|
|
103
|
+
|
|
104
|
+
No manual file reading, no clumsy copy-pasting, just a clean, context-rich prompt that I had full control over.
|
|
105
|
+
|
|
106
|
+
## Configuration
|
|
107
|
+
|
|
108
|
+
Set your preferred command-line editor via the `EDITOR` environment variable.
|
|
109
|
+
```bash
|
|
110
|
+
export EDITOR=nvim # or vim, nano, code --wait, etc.
|
|
111
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
kopipasta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
kopipasta/file.py,sha256=2HEoNczbKH3TtLO0zYUcZfUoHqb0-o83xFUOgY9rG-Y,1244
|
|
3
|
+
kopipasta/import_parser.py,sha256=yLzkMlQm2avKjfqcpMY0PxbA_2ihV9gSYJplreWIPEQ,12424
|
|
4
|
+
kopipasta/main.py,sha256=MlfmP_eG0ZyvdhxdGyPsN2TxqnM4hq9pa2ToQEbbNP4,48894
|
|
5
|
+
kopipasta/prompt.py,sha256=fOCuJVTLUfR0fjKf5qIlnl_3pNsKNKsvt3C8f4tsmxk,6889
|
|
6
|
+
kopipasta/tree_selector.py,sha256=Dr7R4d19NzxWMwfQI3GioaD2i1ho84hMRxCzVp4sfCg,21342
|
|
7
|
+
kopipasta-0.29.0.dist-info/LICENSE,sha256=xw4C9TAU7LFu4r_MwSbky90uzkzNtRwAo3c51IWR8lk,1091
|
|
8
|
+
kopipasta-0.29.0.dist-info/METADATA,sha256=4vQpgi-XLKavkyQulJTbEscOUX5uAe1n6n-PJZwKTck,4894
|
|
9
|
+
kopipasta-0.29.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
10
|
+
kopipasta-0.29.0.dist-info/entry_points.txt,sha256=but54qDNz1-F8fVvGstq_QID5tHjczP7bO7rWLFkc6Y,50
|
|
11
|
+
kopipasta-0.29.0.dist-info/top_level.txt,sha256=iXohixMuCdw8UjGDUp0ouICLYBDrx207sgZIJ9lxn0o,10
|
|
12
|
+
kopipasta-0.29.0.dist-info/RECORD,,
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: kopipasta
|
|
3
|
-
Version: 0.27.0
|
|
4
|
-
Summary: A CLI tool to generate prompts with project structure and file contents
|
|
5
|
-
Home-page: https://github.com/mkorpela/kopipasta
|
|
6
|
-
Author: Mikko Korpela
|
|
7
|
-
Author-email: mikko.korpela@gmail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Classifier: Development Status :: 3 - Alpha
|
|
10
|
-
Classifier: Intended Audience :: Developers
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
Requires-Python: >=3.8
|
|
20
|
-
Description-Content-Type: text/markdown
|
|
21
|
-
License-File: LICENSE
|
|
22
|
-
Requires-Dist: pyperclip==1.9.0
|
|
23
|
-
Requires-Dist: requests==2.32.3
|
|
24
|
-
Requires-Dist: Pygments==2.18.0
|
|
25
|
-
Requires-Dist: google-genai==1.8.0
|
|
26
|
-
Requires-Dist: prompt-toolkit==3.0.50
|
|
27
|
-
|
|
28
|
-
# kopipasta
|
|
29
|
-
|
|
30
|
-
[](https://pypi.python.org/pypi/kopipasta)
|
|
31
|
-
[](http://pepy.tech/project/kopipasta)
|
|
32
|
-
|
|
33
|
-
Streamline your interaction with LLMs for coding tasks. `kopipasta` helps you provide comprehensive context (project structure, file contents, web content) and facilitates an interactive, patch-based workflow. Go beyond TAB TAB TAB and take control of your LLM context.
|
|
34
|
-
|
|
35
|
-
<img src="kopipasta.jpg" alt="kopipasta" width="300">
|
|
36
|
-
|
|
37
|
-
- An LLM told me that kopi means Coffee in some languages.. and a Diffusion model then made this delicious soup.
|
|
38
|
-
|
|
39
|
-
## Installation
|
|
40
|
-
|
|
41
|
-
You can install kopipasta using pipx (recommended) or pip:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
# Using pipx (recommended)
|
|
45
|
-
pipx install kopipasta
|
|
46
|
-
|
|
47
|
-
# Or using pip
|
|
48
|
-
pip install kopipasta
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Usage
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
kopipasta [options] [files_or_directories_or_urls...]
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
**Arguments:**
|
|
58
|
-
|
|
59
|
-
* `[files_or_directories_or_urls...]`: Paths to files, directories, or web URLs to include as context.
|
|
60
|
-
|
|
61
|
-
**Options:**
|
|
62
|
-
|
|
63
|
-
* `-t TASK`, `--task TASK`: Provide the task description directly via the command line. If omitted (and not using `-I`), an editor will open for you to write the task.
|
|
64
|
-
* `-I`, `--interactive`: Start an interactive chat session with Google's Gemini model after preparing the context. Requires `GOOGLE_API_KEY` environment variable.
|
|
65
|
-
|
|
66
|
-
**Examples:**
|
|
67
|
-
|
|
68
|
-
1. **Generate prompt and copy to clipboard (classic mode):**
|
|
69
|
-
```bash
|
|
70
|
-
# Interactively select files from src/, include config.json, fetch web content,
|
|
71
|
-
# then open editor for task input. Copy final prompt to clipboard.
|
|
72
|
-
kopipasta src/ config.json https://example.com/api-docs
|
|
73
|
-
|
|
74
|
-
# Provide task directly, include specific files, copy final prompt.
|
|
75
|
-
kopipasta -t "Refactor setup.py to read deps from requirements.txt" setup.py requirements.txt
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
2. **Start an interactive chat session:**
|
|
79
|
-
```bash
|
|
80
|
-
# Interactively select files, provide task directly, then start chat.
|
|
81
|
-
kopipasta -I -t "Implement the apply_simple_patch function" kopipasta/main.py
|
|
82
|
-
|
|
83
|
-
# Interactively select files, open editor for initial task, then start chat.
|
|
84
|
-
kopipasta -I kopipasta/ tests/
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Workflow
|
|
88
|
-
|
|
89
|
-
`kopipasta` is designed to support the following workflow when working with LLMs (like Gemini, ChatGPT, Claude, etc.) for coding tasks:
|
|
90
|
-
|
|
91
|
-
1. **Gather Context:** Run `kopipasta` with the relevant files, directories, and URLs. Interactively select exactly what content (full files, snippets, or specific code chunks/patches) should be included.
|
|
92
|
-
2. **Define Task:** Provide your coding task instructions, either via the `-t` flag or through your default editor.
|
|
93
|
-
3. **Interact (if using `-I`):**
|
|
94
|
-
* `kopipasta` prepares the context and your task as an initial prompt.
|
|
95
|
-
* An interactive chat session starts (currently using Google Gemini via `google-genai`).
|
|
96
|
-
* Discuss the task, clarify requirements, and ask the LLM to generate code.
|
|
97
|
-
* The initial prompt includes instructions guiding the LLM to provide incremental changes and clear explanations.
|
|
98
|
-
4. **Request Patches (`-I` mode):**
|
|
99
|
-
* During the chat, use the `/patch` command to ask the LLM to provide the proposed changes in a structured format.
|
|
100
|
-
* `kopipasta` will prompt you to review the proposed patches (file, reasoning, code change).
|
|
101
|
-
5. **Apply Patches (`-I` mode):**
|
|
102
|
-
* If you approve, `kopipasta` will attempt to automatically apply the patches to your local files. It validates that the original code exists and is unique before applying.
|
|
103
|
-
6. **Test & Iterate:** Test the changes locally. If further changes are needed, continue the chat, request new patches, or make manual edits.
|
|
104
|
-
7. **Commit:** Once satisfied, commit the changes.
|
|
105
|
-
|
|
106
|
-
For non-interactive mode, `kopipasta` generates the complete prompt (context + task) and copies it to your clipboard (Step 1 & 2). You can then paste this into your preferred LLM interface and proceed manually from Step 3 onwards.
|
|
107
|
-
|
|
108
|
-
## Features
|
|
109
|
-
|
|
110
|
-
* **Comprehensive Context Generation:** Creates structured prompts including:
|
|
111
|
-
* Project directory tree overview.
|
|
112
|
-
* Selected file contents.
|
|
113
|
-
* Content fetched from web URLs.
|
|
114
|
-
* Your specific task instructions.
|
|
115
|
-
* **Interactive File Selection:**
|
|
116
|
-
* Guides you through selecting files and directories.
|
|
117
|
-
* Option to include full file content, a snippet (first lines/bytes), or **select specific code chunks/patches** for large or complex files.
|
|
118
|
-
* Syntax highlighting during chunk selection for supported languages.
|
|
119
|
-
* Ignores files based on common `.gitignore` patterns and detects binary files.
|
|
120
|
-
* Displays estimated character/token counts during selection.
|
|
121
|
-
* **Web Content Fetching:** Includes content directly from URLs. Handles JSON/CSV content types.
|
|
122
|
-
* **Editor Integration:** Opens your preferred editor (`$EDITOR`) to input task instructions (if not using `-t`).
|
|
123
|
-
* **Environment Variable Handling:** Detects potential secrets from a `.env` file in included content and prompts you to mask, skip, or keep them.
|
|
124
|
-
* **Clipboard Integration:** Automatically copies the generated prompt to the clipboard (non-interactive mode).
|
|
125
|
-
* **Interactive Chat Mode (`-I`, `--interactive`):**
|
|
126
|
-
* Starts a chat session directly after context generation.
|
|
127
|
-
* Uses the `google-genai` library to interact with Google's Gemini models.
|
|
128
|
-
* Requires the `GOOGLE_API_KEY` environment variable to be set.
|
|
129
|
-
* Includes built-in instructions for the LLM to encourage clear, iterative responses.
|
|
130
|
-
* **Patch Management (`-I` mode):**
|
|
131
|
-
* `/patch` command to request structured code changes from the LLM.
|
|
132
|
-
* Prompts user to review proposed patches (reasoning, file, original/new code snippets).
|
|
133
|
-
* **Automatic patch application** to local files upon confirmation.
|
|
134
|
-
|
|
135
|
-
## Configuration
|
|
136
|
-
|
|
137
|
-
* **Editor:** Set the `EDITOR` environment variable to your preferred command-line editor (e.g., `vim`, `nvim`, `nano`, `emacs`, `code --wait`).
|
|
138
|
-
* **API Key (for `-I` mode):** Set the `GOOGLE_API_KEY` environment variable with your Google AI Studio API key to use the interactive chat feature.
|
|
139
|
-
|
|
140
|
-
## Real life example (Non-Interactive)
|
|
141
|
-
|
|
142
|
-
Context: I had a bug where `setup.py` didn't include all dependencies listed in `requirements.txt`.
|
|
143
|
-
|
|
144
|
-
1. `kopipasta -t "Update setup.py to read dependencies dynamically from requirements.txt" setup.py requirements.txt`
|
|
145
|
-
2. Paste the generated prompt (copied to clipboard) into my preferred LLM chat interface.
|
|
146
|
-
3. Review the LLM's proposed code.
|
|
147
|
-
4. Copy the code and update `setup.py` manually.
|
|
148
|
-
5. Test the changes.
|
|
149
|
-
|
|
150
|
-
## Real life example (Interactive)
|
|
151
|
-
|
|
152
|
-
Context: I want to refactor a function in `main.py`.
|
|
153
|
-
|
|
154
|
-
1. `export GOOGLE_API_KEY="YOUR_API_KEY_HERE"` (ensure key is set)
|
|
155
|
-
2. `kopipasta -I -t "Refactor the handle_content function in main.py to be more modular" module/main.py`
|
|
156
|
-
3. The tool gathers context, shows the file size, and confirms inclusion.
|
|
157
|
-
4. An interactive chat session starts with the context and task sent to Gemini.
|
|
158
|
-
5. Chat with the LLM:
|
|
159
|
-
* *User:* "Proceed"
|
|
160
|
-
* *LLM:* "Okay, I understand. My plan is to..."
|
|
161
|
-
* *User:* "Looks good."
|
|
162
|
-
* *LLM:* "Here's the first part of the refactoring..." (shows code)
|
|
163
|
-
6. Use the `/patch` command:
|
|
164
|
-
* *User:* `/patch`
|
|
165
|
-
* `kopipasta` asks the LLM for structured patches.
|
|
166
|
-
* `kopipasta` displays proposed patches: "Apply 1 patch to module/main.py? (y/N):"
|
|
167
|
-
7. Apply the patch:
|
|
168
|
-
* *User:* `y`
|
|
169
|
-
* `kopipasta` applies the change to `module/main.py`.
|
|
170
|
-
8. Test locally. If it works, commit. If not, continue chatting, request more patches, or debug.
|
|
171
|
-
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
kopipasta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
kopipasta/import_parser.py,sha256=yLzkMlQm2avKjfqcpMY0PxbA_2ihV9gSYJplreWIPEQ,12424
|
|
3
|
-
kopipasta/main.py,sha256=gTIPH5dScVKym_5QFrWE3gmChvrFaIgMJyvnTBxc_iI,62607
|
|
4
|
-
kopipasta-0.27.0.dist-info/LICENSE,sha256=xw4C9TAU7LFu4r_MwSbky90uzkzNtRwAo3c51IWR8lk,1091
|
|
5
|
-
kopipasta-0.27.0.dist-info/METADATA,sha256=ubZEEhK8410J4kZ5x1MTAWfm2EXPO4NtLqbpUB44rcM,8610
|
|
6
|
-
kopipasta-0.27.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
7
|
-
kopipasta-0.27.0.dist-info/entry_points.txt,sha256=but54qDNz1-F8fVvGstq_QID5tHjczP7bO7rWLFkc6Y,50
|
|
8
|
-
kopipasta-0.27.0.dist-info/top_level.txt,sha256=iXohixMuCdw8UjGDUp0ouICLYBDrx207sgZIJ9lxn0o,10
|
|
9
|
-
kopipasta-0.27.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|