promptprep
- promptprep package
BaseFormatterCodeAggregatorCodeAggregator.DEFAULT_EXCLUDE_DIRSCodeAggregator.DEFAULT_EXCLUDE_FILESCodeAggregator.DEFAULT_MAX_FILE_SIZE_MBCodeAggregator.DEFAULT_PROGRAMMING_EXTENSIONSCodeAggregator.DEFAULT_TOKEN_MODELCodeAggregator.aggregate()CodeAggregator.aggregate_code()CodeAggregator.collect_metadata()CodeAggregator.compare_files()CodeAggregator.compare_runs()CodeAggregator.copy_to_clipboard()CodeAggregator.count_text_tokens()CodeAggregator.is_file_size_within_limit()CodeAggregator.is_programming_file()CodeAggregator.should_exclude()CodeAggregator.should_include()CodeAggregator.write_to_file()
ConfigManagerDirectoryTreeGeneratorFileSelectorHighlightedFormatterHighlightedFormatter.__init__()HighlightedFormatter.format_code_content()HighlightedFormatter.format_directory_tree()HighlightedFormatter.format_error()HighlightedFormatter.format_file_header()HighlightedFormatter.format_metadata()HighlightedFormatter.format_skipped_files()HighlightedFormatter.get_full_html()
HtmlFormatterMarkdownFormatterPlainTextFormatterget_formatter()select_files_interactive()- Submodules
Modules Overview
promptprep is organized into several modules, each with a specific responsibility. This page provides an overview of these modules and how they interact.
Module Structure
Module |
Description |
|---|---|
Core functionality for scanning, processing, and aggregating code files |
|
Output formatting in various formats (plain, markdown, HTML, etc.) |
|
Command-line interface and argument parsing |
|
Configuration management and persistence |
|
Terminal user interface for interactive file selection |
Module Interactions
The modules interact in the following way:
The CLI module parses command-line arguments and coordinates the overall process.
The Config module loads and saves configuration settings.
The TUI module (if interactive mode is enabled) allows the user to select files.
The Aggregator module scans directories, processes files, and aggregates code.
The Formatters module formats the aggregated code in the desired output format.
Here’s a simplified flow diagram:
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
│ CLI │────▶│ Config │ │ TUI │ │Aggregator│────▶│Formatters│
└─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘
│ │ ▲ ▲
│ │ │ │
└────────────────┼───────────────┘ │
│ │
└───────────────────────────────┘
Module Details
Aggregator Module
The Aggregator Module module is the core of promptprep. It handles:
Scanning directories for code files
Filtering files based on various criteria
Processing file content (with or without comments, summary mode, etc.)
Generating directory trees
Incremental processing
Generating diffs between versions
Formatters Module
The Formatters Module module handles the output formatting. It supports:
Plain text format
Markdown format with code blocks
HTML format
Syntax-highlighted HTML (with Pygments)
Custom templates
CLI Module
The CLI Module module provides the command-line interface. It handles:
Parsing command-line arguments
Coordinating the overall process
Handling clipboard operations
Error handling and reporting
Config Module
The Config Module module manages configuration settings. It handles:
Loading configuration from files
Saving configuration to files
Managing default settings
Converting between configuration formats
TUI Module
The TUI Module module provides the interactive file selection interface. It handles:
Displaying a terminal-based file browser
Allowing navigation through directories
Selecting and deselecting files
Handling keyboard input
Extending promptprep
If you want to extend promptprep with new features, here are some guidelines:
New Output Format: Add a new formatter class in the formatters module that inherits from BaseFormatter.
New File Processing Method: Extend the FileProcessor class in the aggregator module.
New Command-Line Option: Add the option to the argument parser in the cli module and handle it appropriately.
New Configuration Setting: Add the setting to the default configuration in the config module.
New TUI Feature: Extend the FileSelector class in the tui module.
For more detailed information about each module, refer to their respective documentation pages.