kopipasta 0.22.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.22.0/kopipasta.egg-info → kopipasta-0.23.0}/PKG-INFO +6 -1
- {kopipasta-0.22.0 → kopipasta-0.23.0}/kopipasta/main.py +5 -61
- {kopipasta-0.22.0 → kopipasta-0.23.0/kopipasta.egg-info}/PKG-INFO +6 -1
- kopipasta-0.22.0/requirements.txt → kopipasta-0.23.0/kopipasta.egg-info/requires.txt +2 -1
- kopipasta-0.22.0/kopipasta.egg-info/requires.txt → kopipasta-0.23.0/requirements.txt +1 -0
- {kopipasta-0.22.0 → kopipasta-0.23.0}/setup.py +1 -1
- {kopipasta-0.22.0 → kopipasta-0.23.0}/LICENSE +0 -0
- {kopipasta-0.22.0 → kopipasta-0.23.0}/MANIFEST.in +0 -0
- {kopipasta-0.22.0 → kopipasta-0.23.0}/README.md +0 -0
- {kopipasta-0.22.0 → kopipasta-0.23.0}/kopipasta/__init__.py +0 -0
- {kopipasta-0.22.0 → kopipasta-0.23.0}/kopipasta.egg-info/SOURCES.txt +0 -0
- {kopipasta-0.22.0 → kopipasta-0.23.0}/kopipasta.egg-info/dependency_links.txt +0 -0
- {kopipasta-0.22.0 → kopipasta-0.23.0}/kopipasta.egg-info/entry_points.txt +0 -0
- {kopipasta-0.22.0 → kopipasta-0.23.0}/kopipasta.egg-info/top_level.txt +0 -0
- {kopipasta-0.22.0 → kopipasta-0.23.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: kopipasta
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.23.0
|
|
4
4
|
Summary: A CLI tool to generate prompts with project structure and file contents
|
|
5
5
|
Home-page: https://github.com/mkorpela/kopipasta
|
|
6
6
|
Author: Mikko Korpela
|
|
@@ -19,6 +19,11 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
19
19
|
Requires-Python: >=3.8
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
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
|
|
22
27
|
|
|
23
28
|
# kopipasta
|
|
24
29
|
|
|
@@ -22,6 +22,7 @@ from pydantic import BaseModel, Field
|
|
|
22
22
|
import traceback
|
|
23
23
|
from google import genai
|
|
24
24
|
from google.genai.types import GenerateContentConfig
|
|
25
|
+
from prompt_toolkit import prompt # Added for multiline input
|
|
25
26
|
|
|
26
27
|
FileTuple = Tuple[str, bool, Optional[List[str]], str]
|
|
27
28
|
|
|
@@ -682,65 +683,6 @@ def fetch_web_content(url: str) -> Tuple[Optional[FileTuple], Optional[str], Opt
|
|
|
682
683
|
print(f"Error fetching content from {url}: {e}")
|
|
683
684
|
return None, None, None
|
|
684
685
|
|
|
685
|
-
def read_file_content(file_path):
|
|
686
|
-
_, ext = os.path.splitext(file_path)
|
|
687
|
-
if ext.lower() == '.json':
|
|
688
|
-
with open(file_path, 'r') as f:
|
|
689
|
-
return json.load(f), 'json'
|
|
690
|
-
elif ext.lower() == '.csv':
|
|
691
|
-
with open(file_path, 'r') as f:
|
|
692
|
-
return f.read(), 'csv'
|
|
693
|
-
else:
|
|
694
|
-
with open(file_path, 'r') as f:
|
|
695
|
-
return f.read(), 'text'
|
|
696
|
-
|
|
697
|
-
def get_content_snippet(content, content_type, max_lines=50, max_chars=4096):
|
|
698
|
-
if content_type == 'json':
|
|
699
|
-
return json.dumps(content, indent=2)[:max_chars]
|
|
700
|
-
elif content_type == 'csv':
|
|
701
|
-
csv_content = content if isinstance(content, str) else content.getvalue()
|
|
702
|
-
csv_reader = csv.reader(io.StringIO(csv_content))
|
|
703
|
-
rows = list(csv_reader)[:max_lines]
|
|
704
|
-
output = io.StringIO()
|
|
705
|
-
csv.writer(output).writerows(rows)
|
|
706
|
-
return output.getvalue()[:max_chars]
|
|
707
|
-
else:
|
|
708
|
-
return '\n'.join(content.split('\n')[:max_lines])[:max_chars]
|
|
709
|
-
|
|
710
|
-
def handle_content(content, content_type, file_or_url):
|
|
711
|
-
is_large = len(json.dumps(content)) > 102400 if content_type == 'json' else len(content) > 102400
|
|
712
|
-
|
|
713
|
-
if is_large:
|
|
714
|
-
while True:
|
|
715
|
-
choice = input(f"{file_or_url} is large. View (f)ull content, (s)nippet, or (p)review? ").lower()
|
|
716
|
-
if choice in ['f', 's', 'p']:
|
|
717
|
-
break
|
|
718
|
-
print("Invalid choice. Please enter 'f', 's', or 'p'.")
|
|
719
|
-
|
|
720
|
-
if choice == 'f':
|
|
721
|
-
return content, False
|
|
722
|
-
elif choice == 's':
|
|
723
|
-
return get_content_snippet(content, content_type), True
|
|
724
|
-
else: # preview
|
|
725
|
-
preview = get_content_preview(content, content_type)
|
|
726
|
-
print(f"\nPreview of {file_or_url}:\n{preview}\n")
|
|
727
|
-
return handle_content(content, content_type, file_or_url)
|
|
728
|
-
else:
|
|
729
|
-
return content, False
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
def get_content_preview(content, content_type):
|
|
733
|
-
if content_type == 'json':
|
|
734
|
-
return json.dumps(content, indent=2)[:1000] + "\n..."
|
|
735
|
-
elif content_type == 'csv':
|
|
736
|
-
csv_content = content if isinstance(content, str) else content.getvalue()
|
|
737
|
-
csv_reader = csv.reader(io.StringIO(csv_content))
|
|
738
|
-
rows = list(csv_reader)[:10]
|
|
739
|
-
output = io.StringIO()
|
|
740
|
-
csv.writer(output).writerows(rows)
|
|
741
|
-
return output.getvalue() + "\n..."
|
|
742
|
-
else:
|
|
743
|
-
return '\n'.join(content.split('\n')[:20]) + "\n..."
|
|
744
686
|
|
|
745
687
|
def read_env_file():
|
|
746
688
|
env_vars = {}
|
|
@@ -921,8 +863,10 @@ def start_chat_session(initial_prompt: str):
|
|
|
921
863
|
|
|
922
864
|
while True:
|
|
923
865
|
try:
|
|
924
|
-
|
|
925
|
-
|
|
866
|
+
# Replace standard input with prompt_toolkit for multiline support
|
|
867
|
+
user_input = prompt("👤 You (Submit with Esc+Enter or Alt+Enter): ", multiline=True)
|
|
868
|
+
# prompt_toolkit raises EOFError on Ctrl+D, so this handler remains correct.
|
|
869
|
+
except EOFError:
|
|
926
870
|
print("\nExiting...")
|
|
927
871
|
break
|
|
928
872
|
except KeyboardInterrupt: # Handle Ctrl+C
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: kopipasta
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.23.0
|
|
4
4
|
Summary: A CLI tool to generate prompts with project structure and file contents
|
|
5
5
|
Home-page: https://github.com/mkorpela/kopipasta
|
|
6
6
|
Author: Mikko Korpela
|
|
@@ -19,6 +19,11 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
19
19
|
Requires-Python: >=3.8
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
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
|
|
22
27
|
|
|
23
28
|
# kopipasta
|
|
24
29
|
|
|
@@ -10,7 +10,7 @@ with open("requirements.txt", "r", encoding="utf-8") as f:
|
|
|
10
10
|
|
|
11
11
|
setup(
|
|
12
12
|
name="kopipasta",
|
|
13
|
-
version="0.
|
|
13
|
+
version="0.23.0",
|
|
14
14
|
author="Mikko Korpela",
|
|
15
15
|
author_email="mikko.korpela@gmail.com",
|
|
16
16
|
description="A CLI tool to generate prompts with project structure and file contents",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|