kopipasta 0.21.0__tar.gz → 0.23.0__tar.gz
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-0.23.0/PKG-INFO +171 -0
- kopipasta-0.23.0/README.md +144 -0
- {kopipasta-0.21.0 → kopipasta-0.23.0}/kopipasta/main.py +346 -99
- kopipasta-0.23.0/kopipasta.egg-info/PKG-INFO +171 -0
- kopipasta-0.23.0/kopipasta.egg-info/requires.txt +5 -0
- kopipasta-0.21.0/kopipasta.egg-info/requires.txt → kopipasta-0.23.0/requirements.txt +2 -0
- {kopipasta-0.21.0 → kopipasta-0.23.0}/setup.py +1 -1
- kopipasta-0.21.0/PKG-INFO +0 -91
- kopipasta-0.21.0/README.md +0 -69
- kopipasta-0.21.0/kopipasta.egg-info/PKG-INFO +0 -91
- kopipasta-0.21.0/requirements.txt +0 -3
- {kopipasta-0.21.0 → kopipasta-0.23.0}/LICENSE +0 -0
- {kopipasta-0.21.0 → kopipasta-0.23.0}/MANIFEST.in +0 -0
- {kopipasta-0.21.0 → kopipasta-0.23.0}/kopipasta/__init__.py +0 -0
- {kopipasta-0.21.0 → kopipasta-0.23.0}/kopipasta.egg-info/SOURCES.txt +0 -0
- {kopipasta-0.21.0 → kopipasta-0.23.0}/kopipasta.egg-info/dependency_links.txt +0 -0
- {kopipasta-0.21.0 → kopipasta-0.23.0}/kopipasta.egg-info/entry_points.txt +0 -0
- {kopipasta-0.21.0 → kopipasta-0.23.0}/kopipasta.egg-info/top_level.txt +0 -0
- {kopipasta-0.21.0 → kopipasta-0.23.0}/setup.cfg +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: kopipasta
|
|
3
|
+
Version: 0.23.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
|
+
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# kopipasta
|
|
2
|
+
|
|
3
|
+
[](https://pypi.python.org/pypi/kopipasta)
|
|
4
|
+
[](http://pepy.tech/project/kopipasta)
|
|
5
|
+
|
|
6
|
+
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.
|
|
7
|
+
|
|
8
|
+
<img src="kopipasta.jpg" alt="kopipasta" width="300">
|
|
9
|
+
|
|
10
|
+
- An LLM told me that kopi means Coffee in some languages.. and a Diffusion model then made this delicious soup.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
You can install kopipasta using pipx (recommended) or pip:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Using pipx (recommended)
|
|
18
|
+
pipx install kopipasta
|
|
19
|
+
|
|
20
|
+
# Or using pip
|
|
21
|
+
pip install kopipasta
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
kopipasta [options] [files_or_directories_or_urls...]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Arguments:**
|
|
31
|
+
|
|
32
|
+
* `[files_or_directories_or_urls...]`: Paths to files, directories, or web URLs to include as context.
|
|
33
|
+
|
|
34
|
+
**Options:**
|
|
35
|
+
|
|
36
|
+
* `-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.
|
|
37
|
+
* `-I`, `--interactive`: Start an interactive chat session with Google's Gemini model after preparing the context. Requires `GOOGLE_API_KEY` environment variable.
|
|
38
|
+
|
|
39
|
+
**Examples:**
|
|
40
|
+
|
|
41
|
+
1. **Generate prompt and copy to clipboard (classic mode):**
|
|
42
|
+
```bash
|
|
43
|
+
# Interactively select files from src/, include config.json, fetch web content,
|
|
44
|
+
# then open editor for task input. Copy final prompt to clipboard.
|
|
45
|
+
kopipasta src/ config.json https://example.com/api-docs
|
|
46
|
+
|
|
47
|
+
# Provide task directly, include specific files, copy final prompt.
|
|
48
|
+
kopipasta -t "Refactor setup.py to read deps from requirements.txt" setup.py requirements.txt
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
2. **Start an interactive chat session:**
|
|
52
|
+
```bash
|
|
53
|
+
# Interactively select files, provide task directly, then start chat.
|
|
54
|
+
kopipasta -I -t "Implement the apply_simple_patch function" kopipasta/main.py
|
|
55
|
+
|
|
56
|
+
# Interactively select files, open editor for initial task, then start chat.
|
|
57
|
+
kopipasta -I kopipasta/ tests/
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Workflow
|
|
61
|
+
|
|
62
|
+
`kopipasta` is designed to support the following workflow when working with LLMs (like Gemini, ChatGPT, Claude, etc.) for coding tasks:
|
|
63
|
+
|
|
64
|
+
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.
|
|
65
|
+
2. **Define Task:** Provide your coding task instructions, either via the `-t` flag or through your default editor.
|
|
66
|
+
3. **Interact (if using `-I`):**
|
|
67
|
+
* `kopipasta` prepares the context and your task as an initial prompt.
|
|
68
|
+
* An interactive chat session starts (currently using Google Gemini via `google-genai`).
|
|
69
|
+
* Discuss the task, clarify requirements, and ask the LLM to generate code.
|
|
70
|
+
* The initial prompt includes instructions guiding the LLM to provide incremental changes and clear explanations.
|
|
71
|
+
4. **Request Patches (`-I` mode):**
|
|
72
|
+
* During the chat, use the `/patch` command to ask the LLM to provide the proposed changes in a structured format.
|
|
73
|
+
* `kopipasta` will prompt you to review the proposed patches (file, reasoning, code change).
|
|
74
|
+
5. **Apply Patches (`-I` mode):**
|
|
75
|
+
* 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.
|
|
76
|
+
6. **Test & Iterate:** Test the changes locally. If further changes are needed, continue the chat, request new patches, or make manual edits.
|
|
77
|
+
7. **Commit:** Once satisfied, commit the changes.
|
|
78
|
+
|
|
79
|
+
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.
|
|
80
|
+
|
|
81
|
+
## Features
|
|
82
|
+
|
|
83
|
+
* **Comprehensive Context Generation:** Creates structured prompts including:
|
|
84
|
+
* Project directory tree overview.
|
|
85
|
+
* Selected file contents.
|
|
86
|
+
* Content fetched from web URLs.
|
|
87
|
+
* Your specific task instructions.
|
|
88
|
+
* **Interactive File Selection:**
|
|
89
|
+
* Guides you through selecting files and directories.
|
|
90
|
+
* Option to include full file content, a snippet (first lines/bytes), or **select specific code chunks/patches** for large or complex files.
|
|
91
|
+
* Syntax highlighting during chunk selection for supported languages.
|
|
92
|
+
* Ignores files based on common `.gitignore` patterns and detects binary files.
|
|
93
|
+
* Displays estimated character/token counts during selection.
|
|
94
|
+
* **Web Content Fetching:** Includes content directly from URLs. Handles JSON/CSV content types.
|
|
95
|
+
* **Editor Integration:** Opens your preferred editor (`$EDITOR`) to input task instructions (if not using `-t`).
|
|
96
|
+
* **Environment Variable Handling:** Detects potential secrets from a `.env` file in included content and prompts you to mask, skip, or keep them.
|
|
97
|
+
* **Clipboard Integration:** Automatically copies the generated prompt to the clipboard (non-interactive mode).
|
|
98
|
+
* **Interactive Chat Mode (`-I`, `--interactive`):**
|
|
99
|
+
* Starts a chat session directly after context generation.
|
|
100
|
+
* Uses the `google-genai` library to interact with Google's Gemini models.
|
|
101
|
+
* Requires the `GOOGLE_API_KEY` environment variable to be set.
|
|
102
|
+
* Includes built-in instructions for the LLM to encourage clear, iterative responses.
|
|
103
|
+
* **Patch Management (`-I` mode):**
|
|
104
|
+
* `/patch` command to request structured code changes from the LLM.
|
|
105
|
+
* Prompts user to review proposed patches (reasoning, file, original/new code snippets).
|
|
106
|
+
* **Automatic patch application** to local files upon confirmation.
|
|
107
|
+
|
|
108
|
+
## Configuration
|
|
109
|
+
|
|
110
|
+
* **Editor:** Set the `EDITOR` environment variable to your preferred command-line editor (e.g., `vim`, `nvim`, `nano`, `emacs`, `code --wait`).
|
|
111
|
+
* **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.
|
|
112
|
+
|
|
113
|
+
## Real life example (Non-Interactive)
|
|
114
|
+
|
|
115
|
+
Context: I had a bug where `setup.py` didn't include all dependencies listed in `requirements.txt`.
|
|
116
|
+
|
|
117
|
+
1. `kopipasta -t "Update setup.py to read dependencies dynamically from requirements.txt" setup.py requirements.txt`
|
|
118
|
+
2. Paste the generated prompt (copied to clipboard) into my preferred LLM chat interface.
|
|
119
|
+
3. Review the LLM's proposed code.
|
|
120
|
+
4. Copy the code and update `setup.py` manually.
|
|
121
|
+
5. Test the changes.
|
|
122
|
+
|
|
123
|
+
## Real life example (Interactive)
|
|
124
|
+
|
|
125
|
+
Context: I want to refactor a function in `main.py`.
|
|
126
|
+
|
|
127
|
+
1. `export GOOGLE_API_KEY="YOUR_API_KEY_HERE"` (ensure key is set)
|
|
128
|
+
2. `kopipasta -I -t "Refactor the handle_content function in main.py to be more modular" module/main.py`
|
|
129
|
+
3. The tool gathers context, shows the file size, and confirms inclusion.
|
|
130
|
+
4. An interactive chat session starts with the context and task sent to Gemini.
|
|
131
|
+
5. Chat with the LLM:
|
|
132
|
+
* *User:* "Proceed"
|
|
133
|
+
* *LLM:* "Okay, I understand. My plan is to..."
|
|
134
|
+
* *User:* "Looks good."
|
|
135
|
+
* *LLM:* "Here's the first part of the refactoring..." (shows code)
|
|
136
|
+
6. Use the `/patch` command:
|
|
137
|
+
* *User:* `/patch`
|
|
138
|
+
* `kopipasta` asks the LLM for structured patches.
|
|
139
|
+
* `kopipasta` displays proposed patches: "Apply 1 patch to module/main.py? (y/N):"
|
|
140
|
+
7. Apply the patch:
|
|
141
|
+
* *User:* `y`
|
|
142
|
+
* `kopipasta` applies the change to `module/main.py`.
|
|
143
|
+
8. Test locally. If it works, commit. If not, continue chatting, request more patches, or debug.
|
|
144
|
+
|