kopipasta 0.2.0__py3-none-any.whl → 0.4.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/main.py +144 -20
- kopipasta-0.4.0.dist-info/METADATA +198 -0
- kopipasta-0.4.0.dist-info/RECORD +8 -0
- {kopipasta-0.2.0.dist-info → kopipasta-0.4.0.dist-info}/WHEEL +1 -1
- kopipasta-0.2.0.dist-info/METADATA +0 -122
- kopipasta-0.2.0.dist-info/RECORD +0 -8
- {kopipasta-0.2.0.dist-info → kopipasta-0.4.0.dist-info}/LICENSE +0 -0
- {kopipasta-0.2.0.dist-info → kopipasta-0.4.0.dist-info}/entry_points.txt +0 -0
- {kopipasta-0.2.0.dist-info → kopipasta-0.4.0.dist-info}/top_level.txt +0 -0
kopipasta/main.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
import os
|
|
3
3
|
import argparse
|
|
4
|
+
import re
|
|
4
5
|
import pyperclip
|
|
5
6
|
import fnmatch
|
|
6
7
|
|
|
8
|
+
import requests
|
|
9
|
+
|
|
7
10
|
def read_gitignore():
|
|
8
11
|
default_ignore_patterns = [
|
|
9
12
|
'.git', 'node_modules', 'venv', '.venv', 'dist', '.idea', '__pycache__',
|
|
@@ -49,6 +52,9 @@ def get_human_readable_size(size):
|
|
|
49
52
|
return f"{size:.2f} {unit}"
|
|
50
53
|
size /= 1024.0
|
|
51
54
|
|
|
55
|
+
def is_large_file(file_path, threshold=102400): # 100 KB threshold
|
|
56
|
+
return os.path.getsize(file_path) > threshold
|
|
57
|
+
|
|
52
58
|
def get_project_structure(ignore_patterns):
|
|
53
59
|
tree = []
|
|
54
60
|
for root, dirs, files in os.walk('.'):
|
|
@@ -94,6 +100,17 @@ def get_language_for_file(file_path):
|
|
|
94
100
|
}
|
|
95
101
|
return language_map.get(extension, '')
|
|
96
102
|
|
|
103
|
+
def get_file_snippet(file_path, max_lines=50, max_bytes=4096):
|
|
104
|
+
snippet = ""
|
|
105
|
+
byte_count = 0
|
|
106
|
+
with open(file_path, 'r') as file:
|
|
107
|
+
for i, line in enumerate(file):
|
|
108
|
+
if i >= max_lines or byte_count >= max_bytes:
|
|
109
|
+
break
|
|
110
|
+
snippet += line
|
|
111
|
+
byte_count += len(line.encode('utf-8'))
|
|
112
|
+
return snippet
|
|
113
|
+
|
|
97
114
|
def select_files_in_directory(directory, ignore_patterns, current_char_count=0):
|
|
98
115
|
files = [f for f in os.listdir(directory)
|
|
99
116
|
if os.path.isfile(os.path.join(directory, f)) and not is_ignored(os.path.join(directory, f), ignore_patterns) and not is_binary(os.path.join(directory, f))]
|
|
@@ -115,10 +132,26 @@ def select_files_in_directory(directory, ignore_patterns, current_char_count=0):
|
|
|
115
132
|
print_char_count(current_char_count)
|
|
116
133
|
choice = input("(y)es add all / (n)o ignore all / (s)elect individually / (q)uit? ").lower()
|
|
117
134
|
if choice == 'y':
|
|
135
|
+
selected_files = []
|
|
118
136
|
for file in files:
|
|
119
|
-
|
|
137
|
+
file_path = os.path.join(directory, file)
|
|
138
|
+
if is_large_file(file_path):
|
|
139
|
+
while True:
|
|
140
|
+
snippet_choice = input(f"{file} is large. Use (f)ull content or (s)nippet? ").lower()
|
|
141
|
+
if snippet_choice in ['f', 's']:
|
|
142
|
+
break
|
|
143
|
+
print("Invalid choice. Please enter 'f' or 's'.")
|
|
144
|
+
if snippet_choice == 's':
|
|
145
|
+
selected_files.append((file, True))
|
|
146
|
+
current_char_count += len(get_file_snippet(file_path))
|
|
147
|
+
else:
|
|
148
|
+
selected_files.append((file, False))
|
|
149
|
+
current_char_count += os.path.getsize(file_path)
|
|
150
|
+
else:
|
|
151
|
+
selected_files.append((file, False))
|
|
152
|
+
current_char_count += os.path.getsize(file_path)
|
|
120
153
|
print(f"Added all files from {directory}")
|
|
121
|
-
return
|
|
154
|
+
return selected_files, current_char_count
|
|
122
155
|
elif choice == 'n':
|
|
123
156
|
print(f"Ignored all files from {directory}")
|
|
124
157
|
return [], current_char_count
|
|
@@ -135,8 +168,21 @@ def select_files_in_directory(directory, ignore_patterns, current_char_count=0):
|
|
|
135
168
|
print_char_count(current_char_count)
|
|
136
169
|
file_choice = input(f"{file} ({file_size_readable}, ~{file_char_estimate} chars, ~{file_token_estimate} tokens) (y/n/q)? ").lower()
|
|
137
170
|
if file_choice == 'y':
|
|
138
|
-
|
|
139
|
-
|
|
171
|
+
if is_large_file(file_path):
|
|
172
|
+
while True:
|
|
173
|
+
snippet_choice = input(f"{file} is large. Use (f)ull content or (s)nippet? ").lower()
|
|
174
|
+
if snippet_choice in ['f', 's']:
|
|
175
|
+
break
|
|
176
|
+
print("Invalid choice. Please enter 'f' or 's'.")
|
|
177
|
+
if snippet_choice == 's':
|
|
178
|
+
selected_files.append((file, True))
|
|
179
|
+
current_char_count += len(get_file_snippet(file_path))
|
|
180
|
+
else:
|
|
181
|
+
selected_files.append((file, False))
|
|
182
|
+
current_char_count += file_char_estimate
|
|
183
|
+
else:
|
|
184
|
+
selected_files.append((file, False))
|
|
185
|
+
current_char_count += file_char_estimate
|
|
140
186
|
break
|
|
141
187
|
elif file_choice == 'n':
|
|
142
188
|
break
|
|
@@ -165,24 +211,89 @@ def process_directory(directory, ignore_patterns, current_char_count=0):
|
|
|
165
211
|
continue
|
|
166
212
|
|
|
167
213
|
selected_files, current_char_count = select_files_in_directory(root, ignore_patterns, current_char_count)
|
|
168
|
-
full_paths = [os.path.join(root, f) for f in selected_files]
|
|
214
|
+
full_paths = [(os.path.join(root, f), use_snippet) for f, use_snippet in selected_files]
|
|
169
215
|
files_to_include.extend(full_paths)
|
|
170
216
|
processed_dirs.add(root)
|
|
171
217
|
|
|
172
218
|
return files_to_include, processed_dirs, current_char_count
|
|
173
219
|
|
|
174
|
-
def
|
|
220
|
+
def fetch_web_content(url):
|
|
221
|
+
try:
|
|
222
|
+
response = requests.get(url)
|
|
223
|
+
response.raise_for_status()
|
|
224
|
+
full_content = response.text
|
|
225
|
+
snippet = full_content[:1000] if len(full_content) > 10000 else full_content
|
|
226
|
+
return full_content, snippet
|
|
227
|
+
except requests.RequestException as e:
|
|
228
|
+
print(f"Error fetching content from {url}: {e}")
|
|
229
|
+
return None, None
|
|
230
|
+
|
|
231
|
+
def read_env_file():
|
|
232
|
+
env_vars = {}
|
|
233
|
+
if os.path.exists('.env'):
|
|
234
|
+
with open('.env', 'r') as env_file:
|
|
235
|
+
for line in env_file:
|
|
236
|
+
line = line.strip()
|
|
237
|
+
if line and not line.startswith('#'):
|
|
238
|
+
key, value = line.split('=', 1)
|
|
239
|
+
env_vars[key.strip()] = value.strip()
|
|
240
|
+
return env_vars
|
|
241
|
+
|
|
242
|
+
def detect_env_variables(content, env_vars):
|
|
243
|
+
detected_vars = []
|
|
244
|
+
for key, value in env_vars.items():
|
|
245
|
+
if value in content:
|
|
246
|
+
detected_vars.append((key, value))
|
|
247
|
+
return detected_vars
|
|
248
|
+
|
|
249
|
+
def handle_env_variables(content, env_vars):
|
|
250
|
+
detected_vars = detect_env_variables(content, env_vars)
|
|
251
|
+
if not detected_vars:
|
|
252
|
+
return content
|
|
253
|
+
|
|
254
|
+
print("Detected environment variables:")
|
|
255
|
+
for key, value in detected_vars:
|
|
256
|
+
print(f"- {key}={value}")
|
|
257
|
+
|
|
258
|
+
for key, value in detected_vars:
|
|
259
|
+
while True:
|
|
260
|
+
choice = input(f"How would you like to handle {key}? (m)ask / (s)kip / (k)eep: ").lower()
|
|
261
|
+
if choice in ['m', 's', 'k']:
|
|
262
|
+
break
|
|
263
|
+
print("Invalid choice. Please enter 'm', 's', or 'k'.")
|
|
264
|
+
|
|
265
|
+
if choice == 'm':
|
|
266
|
+
content = content.replace(value, '*' * len(value))
|
|
267
|
+
elif choice == 's':
|
|
268
|
+
content = content.replace(value, "[REDACTED]")
|
|
269
|
+
# If 'k', we don't modify the content
|
|
270
|
+
|
|
271
|
+
return content
|
|
272
|
+
|
|
273
|
+
def generate_prompt(files_to_include, ignore_patterns, web_contents, env_vars):
|
|
175
274
|
prompt = "# Project Overview\n\n"
|
|
176
275
|
prompt += "## Project Structure\n\n"
|
|
177
276
|
prompt += "```\n"
|
|
178
277
|
prompt += get_project_structure(ignore_patterns)
|
|
179
278
|
prompt += "\n```\n\n"
|
|
180
279
|
prompt += "## File Contents\n\n"
|
|
181
|
-
for file in files_to_include:
|
|
280
|
+
for file, use_snippet in files_to_include:
|
|
182
281
|
relative_path = get_relative_path(file)
|
|
183
282
|
language = get_language_for_file(file)
|
|
184
|
-
|
|
185
|
-
|
|
283
|
+
if use_snippet:
|
|
284
|
+
file_content = get_file_snippet(file)
|
|
285
|
+
prompt += f"### {relative_path} (snippet)\n\n```{language}\n{file_content}\n```\n\n"
|
|
286
|
+
else:
|
|
287
|
+
file_content = read_file_contents(file)
|
|
288
|
+
file_content = handle_env_variables(file_content, env_vars)
|
|
289
|
+
prompt += f"### {relative_path}\n\n```{language}\n{file_content}\n```\n\n"
|
|
290
|
+
|
|
291
|
+
if web_contents:
|
|
292
|
+
prompt += "## Web Content\n\n"
|
|
293
|
+
for url, (full_content, snippet) in web_contents.items():
|
|
294
|
+
content = handle_env_variables(snippet if len(full_content) > 10000 else full_content, env_vars)
|
|
295
|
+
prompt += f"### {url}{' (snippet)' if len(full_content) > 10000 else ''}\n\n```\n{content}\n```\n\n"
|
|
296
|
+
|
|
186
297
|
prompt += "## Task Instructions\n\n"
|
|
187
298
|
task_instructions = input("Enter the task instructions: ")
|
|
188
299
|
prompt += f"{task_instructions}\n\n"
|
|
@@ -200,21 +311,34 @@ def print_char_count(count):
|
|
|
200
311
|
print(f"\rCurrent prompt size: {count} characters (~ {token_estimate} tokens)", flush=True)
|
|
201
312
|
|
|
202
313
|
def main():
|
|
203
|
-
parser = argparse.ArgumentParser(description="Generate a prompt with project structure and
|
|
204
|
-
parser.add_argument('inputs', nargs='+', help='Files or
|
|
314
|
+
parser = argparse.ArgumentParser(description="Generate a prompt with project structure, file contents, and web content.")
|
|
315
|
+
parser.add_argument('inputs', nargs='+', help='Files, directories, or URLs to include in the prompt')
|
|
205
316
|
args = parser.parse_args()
|
|
206
317
|
|
|
207
318
|
ignore_patterns = read_gitignore()
|
|
319
|
+
env_vars = read_env_file()
|
|
208
320
|
|
|
209
321
|
files_to_include = []
|
|
210
322
|
processed_dirs = set()
|
|
323
|
+
web_contents = {}
|
|
211
324
|
current_char_count = 0
|
|
212
325
|
|
|
213
326
|
for input_path in args.inputs:
|
|
214
|
-
if
|
|
327
|
+
if input_path.startswith(('http://', 'https://')):
|
|
328
|
+
full_content, snippet = fetch_web_content(input_path)
|
|
329
|
+
if full_content:
|
|
330
|
+
web_contents[input_path] = (full_content, snippet)
|
|
331
|
+
current_char_count += len(snippet if len(full_content) > 10000 else full_content)
|
|
332
|
+
print(f"Added web content from: {input_path}")
|
|
333
|
+
elif os.path.isfile(input_path):
|
|
215
334
|
if not is_ignored(input_path, ignore_patterns) and not is_binary(input_path):
|
|
216
|
-
|
|
217
|
-
|
|
335
|
+
use_snippet = is_large_file(input_path)
|
|
336
|
+
files_to_include.append((input_path, use_snippet))
|
|
337
|
+
if use_snippet:
|
|
338
|
+
current_char_count += len(get_file_snippet(input_path))
|
|
339
|
+
else:
|
|
340
|
+
current_char_count += os.path.getsize(input_path)
|
|
341
|
+
print(f"Added file: {input_path}{' (snippet)' if use_snippet else ''}")
|
|
218
342
|
else:
|
|
219
343
|
print(f"Ignored file: {input_path}")
|
|
220
344
|
elif os.path.isdir(input_path):
|
|
@@ -222,17 +346,17 @@ def main():
|
|
|
222
346
|
files_to_include.extend(dir_files)
|
|
223
347
|
processed_dirs.update(dir_processed)
|
|
224
348
|
else:
|
|
225
|
-
print(f"Warning: {input_path} is not a valid file or
|
|
349
|
+
print(f"Warning: {input_path} is not a valid file, directory, or URL. Skipping.")
|
|
226
350
|
|
|
227
|
-
if not files_to_include:
|
|
228
|
-
print("No files were selected. Exiting.")
|
|
351
|
+
if not files_to_include and not web_contents:
|
|
352
|
+
print("No files or web content were selected. Exiting.")
|
|
229
353
|
return
|
|
230
354
|
|
|
231
|
-
print("\nFile selection complete.")
|
|
355
|
+
print("\nFile and web content selection complete.")
|
|
232
356
|
print_char_count(current_char_count)
|
|
233
|
-
print(f"Summary: Added {len(files_to_include)} files from {len(processed_dirs)} directories.")
|
|
357
|
+
print(f"Summary: Added {len(files_to_include)} files from {len(processed_dirs)} directories and {len(web_contents)} web sources.")
|
|
234
358
|
|
|
235
|
-
prompt = generate_prompt(files_to_include, ignore_patterns)
|
|
359
|
+
prompt = generate_prompt(files_to_include, ignore_patterns, web_contents, env_vars)
|
|
236
360
|
print("\n\nGenerated prompt:")
|
|
237
361
|
print(prompt)
|
|
238
362
|
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: kopipasta
|
|
3
|
+
Version: 0.4.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
|
+
|
|
25
|
+
# kopipasta
|
|
26
|
+
|
|
27
|
+
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.
|
|
28
|
+
|
|
29
|
+
<img src="kopipasta.jpg" alt="kopipasta" width="300">
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
You can install kopipasta using pipx (or pip):
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
pipx install kopipasta
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
To use kopipasta, run the following command in your terminal:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
kopipasta [files_or_directories_or_urls]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
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.
|
|
48
|
+
|
|
49
|
+
Example:
|
|
50
|
+
```
|
|
51
|
+
kopipasta src/ config.json https://example.com/api-docs
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This will generate a prompt including:
|
|
55
|
+
- The project structure
|
|
56
|
+
- Contents of the specified files and directories (with snippet options for large files)
|
|
57
|
+
- Content fetched from the provided URLs (with snippet options for large content)
|
|
58
|
+
- Handling of environment variables found in a `.env` file (if present)
|
|
59
|
+
|
|
60
|
+
Files and directories typically excluded in version control (based on common .gitignore patterns) are ignored.
|
|
61
|
+
|
|
62
|
+
The generated prompt will be displayed in the console and automatically copied to your clipboard.
|
|
63
|
+
|
|
64
|
+
## Features
|
|
65
|
+
|
|
66
|
+
- Generates a structured prompt with project overview, file contents, web content, and task instructions
|
|
67
|
+
- Offers snippet options for large files (>100 KB) and web content (>10,000 characters)
|
|
68
|
+
- Fetches and includes content from web URLs
|
|
69
|
+
- Detects and securely handles environment variables from a `.env` file
|
|
70
|
+
- Ignores files and directories based on common .gitignore patterns
|
|
71
|
+
- Allows interactive selection of files to include
|
|
72
|
+
- Automatically copies the generated prompt to the clipboard
|
|
73
|
+
|
|
74
|
+
## Environment Variable Handling
|
|
75
|
+
|
|
76
|
+
If a `.env` file is present in the current directory, kopipasta will:
|
|
77
|
+
1. Read and store the environment variables
|
|
78
|
+
2. Detect these variables in file contents and web content
|
|
79
|
+
3. Prompt you to choose how to handle each detected variable:
|
|
80
|
+
- (m)ask: Replace the value with asterisks
|
|
81
|
+
- (s)kip: Replace the value with "[REDACTED]"
|
|
82
|
+
- (k)eep: Leave the value as-is
|
|
83
|
+
|
|
84
|
+
This ensures sensitive information is handled securely in the generated prompt.
|
|
85
|
+
|
|
86
|
+
## Snippet Functionality
|
|
87
|
+
|
|
88
|
+
For large files (>100 KB) and web content (>10,000 characters), kopipasta offers a snippet option:
|
|
89
|
+
|
|
90
|
+
- For files: The first 50 lines or 4 KB (4,096 bytes), whichever comes first
|
|
91
|
+
- For web content: The first 1,000 characters
|
|
92
|
+
|
|
93
|
+
This helps manage the overall prompt size while still providing useful information about the content structure.
|
|
94
|
+
|
|
95
|
+
## Example output
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
❯ kopipasta . https://example.com/api-docs
|
|
99
|
+
|
|
100
|
+
Directory: .
|
|
101
|
+
Files:
|
|
102
|
+
- __init__.py
|
|
103
|
+
- main.py (120 KB, ~120000 chars, ~30000 tokens)
|
|
104
|
+
- large_data.csv (5 MB, ~5000000 chars, ~1250000 tokens)
|
|
105
|
+
- .env
|
|
106
|
+
|
|
107
|
+
(y)es add all / (n)o ignore all / (s)elect individually / (q)uit? y
|
|
108
|
+
main.py is large. Use (f)ull content or (s)nippet? s
|
|
109
|
+
large_data.csv is large. Use (f)ull content or (s)nippet? s
|
|
110
|
+
Added all files from .
|
|
111
|
+
Added web content from: https://example.com/api-docs
|
|
112
|
+
|
|
113
|
+
File and web content selection complete.
|
|
114
|
+
Current prompt size: 10500 characters (~ 2625 tokens)
|
|
115
|
+
Summary: Added 3 files from 1 directory and 1 web source.
|
|
116
|
+
|
|
117
|
+
Detected environment variables:
|
|
118
|
+
- API_KEY=12345abcde
|
|
119
|
+
|
|
120
|
+
How would you like to handle API_KEY? (m)ask / (k)eep: m
|
|
121
|
+
|
|
122
|
+
Enter the task instructions: Implement new API endpoint
|
|
123
|
+
|
|
124
|
+
Generated prompt:
|
|
125
|
+
# Project Overview
|
|
126
|
+
|
|
127
|
+
## Project Structure
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
|-- ./
|
|
131
|
+
|-- __init__.py
|
|
132
|
+
|-- main.py
|
|
133
|
+
|-- large_data.csv
|
|
134
|
+
|-- .env
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## File Contents
|
|
138
|
+
|
|
139
|
+
### __init__.py
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
# Initialize package
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### main.py (snippet)
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
import os
|
|
149
|
+
import pandas as pd
|
|
150
|
+
|
|
151
|
+
API_KEY = os.getenv('API_KEY')
|
|
152
|
+
|
|
153
|
+
def process_data(file_path):
|
|
154
|
+
df = pd.read_csv(file_path)
|
|
155
|
+
# Rest of the function...
|
|
156
|
+
|
|
157
|
+
# More code...
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### large_data.csv (snippet)
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
id,name,value
|
|
164
|
+
1,John,100
|
|
165
|
+
2,Jane,200
|
|
166
|
+
3,Bob,150
|
|
167
|
+
4,Alice,300
|
|
168
|
+
# ... (first 50 lines or 4 KB)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Web Content
|
|
172
|
+
|
|
173
|
+
### https://example.com/api-docs (snippet)
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
API Documentation
|
|
177
|
+
Endpoint: /api/v1/data
|
|
178
|
+
Method: GET
|
|
179
|
+
Authorization: Bearer **********
|
|
180
|
+
...
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Task Instructions
|
|
184
|
+
|
|
185
|
+
Implement new API endpoint
|
|
186
|
+
|
|
187
|
+
## Task Analysis and Planning
|
|
188
|
+
|
|
189
|
+
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.
|
|
190
|
+
|
|
191
|
+
Then, outline a plan for the task. Finally, use your plan to complete the task.
|
|
192
|
+
|
|
193
|
+
Prompt has been copied to clipboard. Final size: 1500 characters (~ 375 tokens)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
kopipasta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
kopipasta/main.py,sha256=5-zAPtdF4PU5xbMFJk5x5lmVAAXSIQ0FoKko4znch3k,15829
|
|
3
|
+
kopipasta-0.4.0.dist-info/LICENSE,sha256=xw4C9TAU7LFu4r_MwSbky90uzkzNtRwAo3c51IWR8lk,1091
|
|
4
|
+
kopipasta-0.4.0.dist-info/METADATA,sha256=8xv0cFWAnXYKS1_gUUCycrL_KGhWG1OUML0la5YAhiE,5431
|
|
5
|
+
kopipasta-0.4.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
6
|
+
kopipasta-0.4.0.dist-info/entry_points.txt,sha256=but54qDNz1-F8fVvGstq_QID5tHjczP7bO7rWLFkc6Y,50
|
|
7
|
+
kopipasta-0.4.0.dist-info/top_level.txt,sha256=iXohixMuCdw8UjGDUp0ouICLYBDrx207sgZIJ9lxn0o,10
|
|
8
|
+
kopipasta-0.4.0.dist-info/RECORD,,
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: kopipasta
|
|
3
|
-
Version: 0.2.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
|
-
|
|
24
|
-
|
|
25
|
-
# kopipasta
|
|
26
|
-
|
|
27
|
-
A CLI tool to generate prompts with project structure and file contents.
|
|
28
|
-
|
|
29
|
-
<img src="kopipasta.jpg" alt="kopipasta" width="300">
|
|
30
|
-
|
|
31
|
-
## Installation
|
|
32
|
-
|
|
33
|
-
You can install kopipasta using pipx (or pip):
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
pipx install kopipasta
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Usage
|
|
40
|
-
|
|
41
|
-
To use kopipasta, run the following command in your terminal:
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
kopipasta [files_or_directories]
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Replace `[files_or_directories]` with the paths to the files or directories you want to include in the prompt.
|
|
48
|
-
|
|
49
|
-
Example:
|
|
50
|
-
```
|
|
51
|
-
kopipasta src/ config.json
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
This will generate a prompt including the project structure and contents of the specified files and directories, ignoring files and directories typically excluded in version control (based on common .gitignore patterns).
|
|
55
|
-
|
|
56
|
-
The generated prompt will be displayed in the console and automatically copied to your clipboard.
|
|
57
|
-
|
|
58
|
-
## Features
|
|
59
|
-
|
|
60
|
-
- Generates a structured prompt with project overview, file contents, and task instructions
|
|
61
|
-
- Ignores files and directories based on common .gitignore patterns
|
|
62
|
-
- Allows interactive selection of files to include
|
|
63
|
-
- Automatically copies the generated prompt to the clipboard
|
|
64
|
-
|
|
65
|
-
## Example output
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
❯ kopipasta .
|
|
69
|
-
|
|
70
|
-
Directory: .
|
|
71
|
-
Files:
|
|
72
|
-
- __init__.py
|
|
73
|
-
- main.py
|
|
74
|
-
|
|
75
|
-
(y)es add all / (n)o ignore all / (s)elect individually / (q)uit? s
|
|
76
|
-
__init__.py (y/n/q)? y
|
|
77
|
-
main.py (y/n/q)? n
|
|
78
|
-
Added 1 files from .
|
|
79
|
-
|
|
80
|
-
File selection complete.
|
|
81
|
-
Summary: Added 1 files from 1 directories.
|
|
82
|
-
Enter the task instructions: Do my work
|
|
83
|
-
|
|
84
|
-
Generated prompt:
|
|
85
|
-
# Project Overview
|
|
86
|
-
|
|
87
|
-
## Summary of Included Files
|
|
88
|
-
|
|
89
|
-
- __init__.py
|
|
90
|
-
|
|
91
|
-
## Project Structure
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
|-- ./
|
|
95
|
-
|-- __init__.py
|
|
96
|
-
|-- main.py
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## File Contents
|
|
100
|
-
|
|
101
|
-
### __init__.py
|
|
102
|
-
|
|
103
|
-
```python
|
|
104
|
-
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## Task Instructions
|
|
108
|
-
|
|
109
|
-
Do my work
|
|
110
|
-
|
|
111
|
-
## Task Analysis and Planning
|
|
112
|
-
|
|
113
|
-
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.
|
|
114
|
-
|
|
115
|
-
Then, outline a plan for the task. Finally, use your plan to complete the task.
|
|
116
|
-
|
|
117
|
-
Prompt has been copied to clipboard.
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## License
|
|
121
|
-
|
|
122
|
-
This project is licensed under the MIT License.
|
kopipasta-0.2.0.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
kopipasta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
kopipasta/main.py,sha256=-3K3Pnv6auCjsQGwxTip8GlBZD2RiPAj9h7h_zeMbSc,10268
|
|
3
|
-
kopipasta-0.2.0.dist-info/LICENSE,sha256=xw4C9TAU7LFu4r_MwSbky90uzkzNtRwAo3c51IWR8lk,1091
|
|
4
|
-
kopipasta-0.2.0.dist-info/METADATA,sha256=hGK30wSKHEPuLh1DRibm6k1iq9Zsx-Dg7uGTO8bBBRo,3033
|
|
5
|
-
kopipasta-0.2.0.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
6
|
-
kopipasta-0.2.0.dist-info/entry_points.txt,sha256=but54qDNz1-F8fVvGstq_QID5tHjczP7bO7rWLFkc6Y,50
|
|
7
|
-
kopipasta-0.2.0.dist-info/top_level.txt,sha256=iXohixMuCdw8UjGDUp0ouICLYBDrx207sgZIJ9lxn0o,10
|
|
8
|
-
kopipasta-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|