kopipasta 0.11.0__tar.gz → 0.12.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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kopipasta
3
- Version: 0.11.0
3
+ Version: 0.12.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
@@ -713,7 +713,53 @@ def main():
713
713
 
714
714
  files_to_include = []
715
715
  web_contents = {}
716
- current_char_count = 0
716
+
717
+ def process_directory(directory):
718
+ files = [f for f in os.listdir(directory)
719
+ 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))]
720
+
721
+ if not files:
722
+ return []
723
+
724
+ print(f"\nDirectory: {directory}")
725
+ print("Files:")
726
+ for file in files:
727
+ file_path = os.path.join(directory, file)
728
+ file_size = os.path.getsize(file_path)
729
+ file_size_readable = get_human_readable_size(file_size)
730
+ print(f"- {file} ({file_size_readable})")
731
+
732
+ while True:
733
+ choice = input("(y)es add all / (n)o ignore all / (s)elect individually / (q)uit? ").lower()
734
+ if choice == 'y':
735
+ return [(os.path.join(directory, f), False) for f in files]
736
+ elif choice == 'n':
737
+ return []
738
+ elif choice == 's':
739
+ selected_files = []
740
+ for file in files:
741
+ file_path = os.path.join(directory, file)
742
+ while True:
743
+ file_choice = input(f"{file} (y/n/p/q)? ").lower()
744
+ if file_choice == 'y':
745
+ selected_files.append((file_path, False))
746
+ break
747
+ elif file_choice == 'n':
748
+ break
749
+ elif file_choice == 'p':
750
+ chunks, _ = select_file_patches(file_path)
751
+ if chunks:
752
+ selected_files.append((file_path, True, chunks))
753
+ break
754
+ elif file_choice == 'q':
755
+ return selected_files
756
+ else:
757
+ print("Invalid choice. Please enter 'y', 'n', 'p', or 'q'.")
758
+ return selected_files
759
+ elif choice == 'q':
760
+ return []
761
+ else:
762
+ print("Invalid choice. Please try again.")
717
763
 
718
764
  for input_path in args.inputs:
719
765
  if input_path.startswith(('http://', 'https://')):
@@ -721,7 +767,6 @@ def main():
721
767
  if content:
722
768
  content, is_snippet = handle_content(content, content_type, input_path)
723
769
  web_contents[input_path] = (content, is_snippet, content_type)
724
- current_char_count += len(json.dumps(content)) if content_type == 'json' else len(content)
725
770
  print(f"Added web content from: {input_path}")
726
771
  elif os.path.isfile(input_path):
727
772
  if not is_ignored(input_path, ignore_patterns) and not is_binary(input_path):
@@ -731,16 +776,14 @@ def main():
731
776
  content, content_type = read_file_content(input_path)
732
777
  content, is_snippet = handle_content(content, content_type, input_path)
733
778
  files_to_include.append((input_path, content, is_snippet, content_type))
734
- current_char_count += len(json.dumps(content)) if content_type == 'json' else len(content)
735
779
  print(f"Added file: {input_path}{' (snippet)' if is_snippet else ''}")
736
780
  break
737
781
  elif file_choice == 'n':
738
782
  break
739
783
  elif file_choice == 'p':
740
- chunks, char_count = select_file_patches(input_path)
784
+ chunks, _ = select_file_patches(input_path)
741
785
  if chunks:
742
786
  files_to_include.append((input_path, None, False, 'text', chunks))
743
- current_char_count += char_count
744
787
  break
745
788
  elif file_choice == 'q':
746
789
  print("Quitting.")
@@ -750,36 +793,16 @@ def main():
750
793
  else:
751
794
  print(f"Ignored file: {input_path}")
752
795
  elif os.path.isdir(input_path):
753
- for root, _, files in os.walk(input_path):
754
- for file in files:
755
- file_path = os.path.join(root, file)
756
- if not is_ignored(file_path, ignore_patterns) and not is_binary(file_path):
757
- while True:
758
- file_choice = input(f"{file_path} (y)es include / (n)o skip / (p)atches / (q)uit? ").lower()
759
- if file_choice == 'y':
760
- content, content_type = read_file_content(file_path)
761
- content, is_snippet = handle_content(content, content_type, file_path)
762
- files_to_include.append((file_path, content, is_snippet, content_type))
763
- current_char_count += len(json.dumps(content)) if content_type == 'json' else len(content)
764
- print(f"Added file: {file_path}{' (snippet)' if is_snippet else ''}")
765
- break
766
- elif file_choice == 'n':
767
- break
768
- elif file_choice == 'p':
769
- chunks, char_count = select_file_patches(file_path)
770
- if chunks:
771
- files_to_include.append((file_path, None, False, 'text', chunks))
772
- current_char_count += char_count
773
- break
774
- elif file_choice == 'q':
775
- print("Quitting directory processing.")
776
- break
777
- else:
778
- print("Invalid choice. Please enter 'y', 'n', 'p', or 'q'.")
779
- if file_choice == 'q':
780
- break
781
- if file_choice == 'q':
782
- break
796
+ selected_files = process_directory(input_path)
797
+ for file_info in selected_files:
798
+ if len(file_info) == 2:
799
+ file_path, use_snippet = file_info
800
+ content, content_type = read_file_content(file_path)
801
+ content, is_snippet = handle_content(content, content_type, file_path)
802
+ files_to_include.append((file_path, content, is_snippet, content_type))
803
+ else:
804
+ file_path, _, chunks = file_info
805
+ files_to_include.append((file_path, None, False, 'text', chunks))
783
806
  else:
784
807
  print(f"Warning: {input_path} is not a valid file, directory, or URL. Skipping.")
785
808
 
@@ -788,7 +811,6 @@ def main():
788
811
  return
789
812
 
790
813
  print("\nFile and web content selection complete.")
791
- print_char_count(current_char_count)
792
814
  print(f"Summary: Added {len(files_to_include)} files and {len(web_contents)} web sources.")
793
815
 
794
816
  prompt = generate_prompt(files_to_include, ignore_patterns, web_contents, env_vars)
@@ -800,7 +822,6 @@ def main():
800
822
  pyperclip.copy(prompt)
801
823
  separator = "\n" + "=" * 40 + "\n☕🍝 Kopipasta Complete! 🍝☕\n" + "=" * 40 + "\n"
802
824
  print(separator)
803
- final_char_count = len(prompt)
804
825
  final_token_estimate = final_char_count // 4
805
826
  print(f"Prompt has been copied to clipboard. Final size: {final_char_count} characters (~ {final_token_estimate} tokens)")
806
827
  except pyperclip.PyperclipException as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kopipasta
3
- Version: 0.11.0
3
+ Version: 0.12.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
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="kopipasta",
8
- version="0.11.0",
8
+ version="0.12.0",
9
9
  author="Mikko Korpela",
10
10
  author_email="mikko.korpela@gmail.com",
11
11
  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