kopipasta 0.1.0__tar.gz → 0.3.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.

@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Mikko Korpela
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.1
2
+ Name: kopipasta
3
+ Version: 0.3.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
+ # kopipasta
25
+
26
+ 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.
27
+
28
+ <img src="kopipasta.jpg" alt="kopipasta" width="300">
29
+
30
+ ## Installation
31
+
32
+ You can install kopipasta using pipx (or pip):
33
+
34
+ ```
35
+ pipx install kopipasta
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ To use kopipasta, run the following command in your terminal:
41
+
42
+ ```
43
+ kopipasta [files_or_directories_or_urls]
44
+ ```
45
+
46
+ 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.
47
+
48
+ Example:
49
+ ```
50
+ kopipasta src/ config.json https://example.com/api-docs
51
+ ```
52
+
53
+ This will generate a prompt including:
54
+ - The project structure
55
+ - Contents of the specified files and directories (with snippet options for large files)
56
+ - Content fetched from the provided URLs (with snippet options for large content)
57
+ - Handling of environment variables found in a `.env` file (if present)
58
+
59
+ Files and directories typically excluded in version control (based on common .gitignore patterns) are ignored.
60
+
61
+ The generated prompt will be displayed in the console and automatically copied to your clipboard.
62
+
63
+ ## Features
64
+
65
+ - Generates a structured prompt with project overview, file contents, web content, and task instructions
66
+ - Offers snippet options for large files (>100 KB) and web content (>10,000 characters)
67
+ - Fetches and includes content from web URLs
68
+ - Detects and securely handles environment variables from a `.env` file
69
+ - Ignores files and directories based on common .gitignore patterns
70
+ - Allows interactive selection of files to include
71
+ - Automatically copies the generated prompt to the clipboard
72
+
73
+ ## Environment Variable Handling
74
+
75
+ If a `.env` file is present in the current directory, kopipasta will:
76
+ 1. Read and store the environment variables
77
+ 2. Detect these variables in file contents and web content
78
+ 3. Prompt you to choose how to handle each detected variable:
79
+ - (m)ask: Replace the value with asterisks
80
+ - (s)kip: Replace the value with "[REDACTED]"
81
+ - (k)eep: Leave the value as-is
82
+
83
+ This ensures sensitive information is handled securely in the generated prompt.
84
+
85
+ ## Snippet Functionality
86
+
87
+ For large files (>100 KB) and web content (>10,000 characters), kopipasta offers a snippet option:
88
+
89
+ - For files: The first 50 lines or 4 KB (4,096 bytes), whichever comes first
90
+ - For web content: The first 1,000 characters
91
+
92
+ This helps manage the overall prompt size while still providing useful information about the content structure.
93
+
94
+ ## Example output
95
+
96
+ ```bash
97
+ ❯ kopipasta . https://example.com/api-docs
98
+
99
+ Directory: .
100
+ Files:
101
+ - __init__.py
102
+ - main.py (120 KB, ~120000 chars, ~30000 tokens)
103
+ - large_data.csv (5 MB, ~5000000 chars, ~1250000 tokens)
104
+ - .env
105
+
106
+ (y)es add all / (n)o ignore all / (s)elect individually / (q)uit? y
107
+ main.py is large. Use (f)ull content or (s)nippet? s
108
+ large_data.csv is large. Use (f)ull content or (s)nippet? s
109
+ Added all files from .
110
+ Added web content from: https://example.com/api-docs
111
+
112
+ File and web content selection complete.
113
+ Current prompt size: 10500 characters (~ 2625 tokens)
114
+ Summary: Added 3 files from 1 directory and 1 web source.
115
+
116
+ Detected environment variables:
117
+ - API_KEY=12345abcde
118
+
119
+ How would you like to handle API_KEY? (m)ask / (k)eep: m
120
+
121
+ Enter the task instructions: Implement new API endpoint
122
+
123
+ Generated prompt:
124
+ # Project Overview
125
+
126
+ ## Project Structure
127
+
128
+ ```
129
+ |-- ./
130
+ |-- __init__.py
131
+ |-- main.py
132
+ |-- large_data.csv
133
+ |-- .env
134
+ ```
135
+
136
+ ## File Contents
137
+
138
+ ### __init__.py
139
+
140
+ ```python
141
+ # Initialize package
142
+ ```
143
+
144
+ ### main.py (snippet)
145
+
146
+ ```python
147
+ import os
148
+ import pandas as pd
149
+
150
+ API_KEY = os.getenv('API_KEY')
151
+
152
+ def process_data(file_path):
153
+ df = pd.read_csv(file_path)
154
+ # Rest of the function...
155
+
156
+ # More code...
157
+ ```
158
+
159
+ ### large_data.csv (snippet)
160
+
161
+ ```
162
+ id,name,value
163
+ 1,John,100
164
+ 2,Jane,200
165
+ 3,Bob,150
166
+ 4,Alice,300
167
+ # ... (first 50 lines or 4 KB)
168
+ ```
169
+
170
+ ## Web Content
171
+
172
+ ### https://example.com/api-docs (snippet)
173
+
174
+ ```
175
+ API Documentation
176
+ Endpoint: /api/v1/data
177
+ Method: GET
178
+ Authorization: Bearer **********
179
+ ...
180
+ ```
181
+
182
+ ## Task Instructions
183
+
184
+ Implement new API endpoint
185
+
186
+ ## Task Analysis and Planning
187
+
188
+ 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.
189
+
190
+ Then, outline a plan for the task. Finally, use your plan to complete the task.
191
+
192
+ Prompt has been copied to clipboard. Final size: 1500 characters (~ 375 tokens)
193
+ ```
194
+
195
+ ## License
196
+
197
+ This project is licensed under the MIT License.
@@ -0,0 +1,174 @@
1
+ # kopipasta
2
+
3
+ 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.
4
+
5
+ <img src="kopipasta.jpg" alt="kopipasta" width="300">
6
+
7
+ ## Installation
8
+
9
+ You can install kopipasta using pipx (or pip):
10
+
11
+ ```
12
+ pipx install kopipasta
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ To use kopipasta, run the following command in your terminal:
18
+
19
+ ```
20
+ kopipasta [files_or_directories_or_urls]
21
+ ```
22
+
23
+ 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.
24
+
25
+ Example:
26
+ ```
27
+ kopipasta src/ config.json https://example.com/api-docs
28
+ ```
29
+
30
+ This will generate a prompt including:
31
+ - The project structure
32
+ - Contents of the specified files and directories (with snippet options for large files)
33
+ - Content fetched from the provided URLs (with snippet options for large content)
34
+ - Handling of environment variables found in a `.env` file (if present)
35
+
36
+ Files and directories typically excluded in version control (based on common .gitignore patterns) are ignored.
37
+
38
+ The generated prompt will be displayed in the console and automatically copied to your clipboard.
39
+
40
+ ## Features
41
+
42
+ - Generates a structured prompt with project overview, file contents, web content, and task instructions
43
+ - Offers snippet options for large files (>100 KB) and web content (>10,000 characters)
44
+ - Fetches and includes content from web URLs
45
+ - Detects and securely handles environment variables from a `.env` file
46
+ - Ignores files and directories based on common .gitignore patterns
47
+ - Allows interactive selection of files to include
48
+ - Automatically copies the generated prompt to the clipboard
49
+
50
+ ## Environment Variable Handling
51
+
52
+ If a `.env` file is present in the current directory, kopipasta will:
53
+ 1. Read and store the environment variables
54
+ 2. Detect these variables in file contents and web content
55
+ 3. Prompt you to choose how to handle each detected variable:
56
+ - (m)ask: Replace the value with asterisks
57
+ - (s)kip: Replace the value with "[REDACTED]"
58
+ - (k)eep: Leave the value as-is
59
+
60
+ This ensures sensitive information is handled securely in the generated prompt.
61
+
62
+ ## Snippet Functionality
63
+
64
+ For large files (>100 KB) and web content (>10,000 characters), kopipasta offers a snippet option:
65
+
66
+ - For files: The first 50 lines or 4 KB (4,096 bytes), whichever comes first
67
+ - For web content: The first 1,000 characters
68
+
69
+ This helps manage the overall prompt size while still providing useful information about the content structure.
70
+
71
+ ## Example output
72
+
73
+ ```bash
74
+ ❯ kopipasta . https://example.com/api-docs
75
+
76
+ Directory: .
77
+ Files:
78
+ - __init__.py
79
+ - main.py (120 KB, ~120000 chars, ~30000 tokens)
80
+ - large_data.csv (5 MB, ~5000000 chars, ~1250000 tokens)
81
+ - .env
82
+
83
+ (y)es add all / (n)o ignore all / (s)elect individually / (q)uit? y
84
+ main.py is large. Use (f)ull content or (s)nippet? s
85
+ large_data.csv is large. Use (f)ull content or (s)nippet? s
86
+ Added all files from .
87
+ Added web content from: https://example.com/api-docs
88
+
89
+ File and web content selection complete.
90
+ Current prompt size: 10500 characters (~ 2625 tokens)
91
+ Summary: Added 3 files from 1 directory and 1 web source.
92
+
93
+ Detected environment variables:
94
+ - API_KEY=12345abcde
95
+
96
+ How would you like to handle API_KEY? (m)ask / (k)eep: m
97
+
98
+ Enter the task instructions: Implement new API endpoint
99
+
100
+ Generated prompt:
101
+ # Project Overview
102
+
103
+ ## Project Structure
104
+
105
+ ```
106
+ |-- ./
107
+ |-- __init__.py
108
+ |-- main.py
109
+ |-- large_data.csv
110
+ |-- .env
111
+ ```
112
+
113
+ ## File Contents
114
+
115
+ ### __init__.py
116
+
117
+ ```python
118
+ # Initialize package
119
+ ```
120
+
121
+ ### main.py (snippet)
122
+
123
+ ```python
124
+ import os
125
+ import pandas as pd
126
+
127
+ API_KEY = os.getenv('API_KEY')
128
+
129
+ def process_data(file_path):
130
+ df = pd.read_csv(file_path)
131
+ # Rest of the function...
132
+
133
+ # More code...
134
+ ```
135
+
136
+ ### large_data.csv (snippet)
137
+
138
+ ```
139
+ id,name,value
140
+ 1,John,100
141
+ 2,Jane,200
142
+ 3,Bob,150
143
+ 4,Alice,300
144
+ # ... (first 50 lines or 4 KB)
145
+ ```
146
+
147
+ ## Web Content
148
+
149
+ ### https://example.com/api-docs (snippet)
150
+
151
+ ```
152
+ API Documentation
153
+ Endpoint: /api/v1/data
154
+ Method: GET
155
+ Authorization: Bearer **********
156
+ ...
157
+ ```
158
+
159
+ ## Task Instructions
160
+
161
+ Implement new API endpoint
162
+
163
+ ## Task Analysis and Planning
164
+
165
+ 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.
166
+
167
+ Then, outline a plan for the task. Finally, use your plan to complete the task.
168
+
169
+ Prompt has been copied to clipboard. Final size: 1500 characters (~ 375 tokens)
170
+ ```
171
+
172
+ ## License
173
+
174
+ This project is licensed under the MIT License.