Skip to content

LoganSeven/promptcraft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

# PromptCraft

<div align="center">

![Python](https://img.shields.io/badge/python-3.8+-blue.svg)
![PySide6](https://img.shields.io/badge/PySide6-6.5+-green.svg)
![License](https://img.shields.io/badge/license-MIT-lightgrey.svg)
![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-lightgrey.svg)

**A powerful GUI tool for crafting structured prompts with file integration**

*Built for efficient communication with AI assistants*

</div>

## ✨ Features

### πŸ“ **Structured Prompt Sections**
- **Pre-prompt**: Set the initial context and tone
- **Role**: Define the AI's persona and expertise
- **Context**: Provide background information and constraints
- **Mission**: Specify the primary objective and goals
- **Rules**: Establish guidelines and constraints
- **Post-prompt**: Add final instructions and formatting

### πŸ“ **File System Integration**
- Interactive file tree with checkboxes for selection
- Language filtering (Python, C/C++, or all files)
- Intelligent ignore patterns via `.excludes` file
- Preserve selections across directory changes

### πŸ”§ **Other Features**
- **One-click crafting**: Combine sections and files into formatted prompts
- **Auto-copy to clipboard**: Results are automatically copied for immediate use
- **File syntax highlighting**: Code blocks with appropriate language tags
- **Configurable defaults**: Load and save section templates
- **Dark theme**: Modern, eye-friendly interface

## πŸš€ Quick Start

### Prerequisites
- Python 3.8 or higher
- pip (Python package manager)

### Installation Options

#### Option 1: Automatic Setup (Linux/macOS)
If you're on Linux or macOS, use the provided setup script:

```bash
# Make the setup script executable
chmod +x setup_venv.sh

# Run the setup script
./setup_venv.sh

The setup_venv.sh script will:

  1. Check if Python 3.8+ is installed
  2. Create a virtual environment in venv/
  3. Upgrade pip to the latest version
  4. Install all required dependencies from requirements.txt
  5. Provide instructions for activating the virtual environment

Option 2: Manual Setup (All Platforms)

For Windows users or if you prefer manual setup:

  1. Clone the repository

    git clone https://github.com/LoganSeven/promptcraft.git
    cd promptcraft
  2. Create and activate virtual environment

    # Windows
    python -m venv venv
    venv\Scripts\activate
    
    # Linux/macOS
    python3 -m venv venv
    source venv/bin/activate
  3. Install dependencies

    pip install -r requirements.txt

Running the Application

After setup, run the application:

# Ensure virtual environment is activated
# On Linux/macOS:
source venv/bin/activate

# On Windows:
venv\Scripts\activate

# Run the application
python main.py

Quick Commands Reference

Platform Activation Command Run Command
Linux/macOS source venv/bin/activate python main.py
Windows venv\Scripts\activate python main.py

πŸ“– Usage Guide

Basic Workflow

  1. Load a Project Directory

    • Click the folder icon in the file tree panel
    • Select your project directory
  2. Configure Prompt Sections

    • Edit each section with your specific requirements
    • Use the Load/Save/Clear buttons for template management
    • Default templates load automatically from default_*.txt files
  3. Select Files to Include

    • Browse the file tree on the right panel
    • Check files you want to include in the prompt
    • Use "Select All"/"Deselect All" for bulk operations
    • Filter by language using the dropdown (Python, C/C++, or all files)
  4. Craft Your Prompt

    • Click the Craft button in the Result section
    • The formatted prompt appears in the Result area
    • The prompt is automatically copied to your clipboard
    • A status message shows file count and character count

File Selection Tips

  • Files are filtered based on the language setting in the dropdown
  • Hidden files and directories are automatically excluded using patterns in .excludes
  • You can customize ignore patterns by editing the .excludes file
  • Selections are preserved when refreshing or changing directories
  • The tree automatically expands to show all directories

Keyboard Shortcuts

Action Shortcut
Switch between sections Tab / Shift+Tab
Select all files Ctrl+A (in file tree)
Craft prompt Ctrl+Enter (when in Result section)
Clear current section Ctrl+Delete

βš™οΈ Configuration

Default Configuration Files

Place these files in your project root to pre-load section content on startup:

File Purpose Example Content
default_pre_prompt.txt Initial context and tone Hello comrade, happy to work with you
default_role.txt AI persona definition You are an experienced Python developer...
default_context.txt Background information You are working on a GUI application...
default_mission.txt Primary objectives You need to implement a feature that...
default_rules.txt Guidelines and constraints 1. Write clean, commented code...
default_post_prompt.txt Final instructions Please provide the complete solution...

Customizing Ignore Patterns

The application uses a .excludes file to determine which files/directories to hide. You can edit this file directly in the application or manually:

# Example .excludes file content
__pycache__/
*.pyc
.venv/
venv/
env/
build/
dist/
*.log
.git/
.vscode/
.idea/

The application automatically generates a default .excludes file based on your selected language filter.

Display Script Integration

The application can also parse exclude patterns from a display_folder_tree.sh script if present:

EXCLUDE_PATTERNS=(
    "*.pyc"
    "__pycache__"
    ".git"
    "venv/"
)

πŸ—οΈ Project Structure

promptcraft/
β”œβ”€β”€ main.py                 # Application entry point
β”œβ”€β”€ requirements.txt        # Python dependencies (PySide6)
β”œβ”€β”€ setup_venv.sh          # Automatic setup script (Linux/macOS)
β”œβ”€β”€ .gitignore             # Git ignore rules
β”œβ”€β”€ README.md              # This documentation
β”‚
β”œβ”€β”€ config/                # Configuration modules
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ constants.py       # Constants, defaults, and language mappings
β”‚   └── language_config.py # Language-specific patterns and configurations
β”‚
β”œβ”€β”€ core/                  # Core business logic
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ file_operations.py # File I/O with encoding fallbacks
β”‚   β”œβ”€β”€ ignore_patterns.py # Pattern matching and ignore logic
β”‚   └── tree_model.py      # File tree model and builder classes
β”‚
β”œβ”€β”€ ui/                    # User interface components
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ main_window.py     # Main application window and layout
β”‚   β”œβ”€β”€ style.qss          # Qt Style Sheet for dark theme
β”‚   β”œβ”€β”€ utils.py           # UI utility functions
β”‚   └── components/        # Reusable UI widgets
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ file_tree_widget.py  # Interactive file tree with controls
β”‚       └── text_section.py      # Text section with buttons
β”‚
└── assets/                # Optional asset files (icons)
    β”œβ”€β”€ folder.png         # Folder icon for directory button
    └── refresh.png        # Refresh icon for refresh button

🎨 Customization

Styling with QSS

The application uses Qt Style Sheets (QSS) for theming. You can customize the appearance:

  1. Edit the main stylesheet: Modify ui/style.qss to change colors, borders, and spacing
  2. Inline styles: Some components have inline styles that can be modified in the code
  3. Fallback styles: If style.qss is not found, embedded fallback styles are used

Example style modification in ui/style.qss:

QPushButton {
    background-color: #2d2d30;
    color: #ffffff;
    border: 1px solid #3a3a3a;
    border-radius: 3px;
    padding: 2px 8px;
    min-height: 22px;
    max-height: 22px;
}

QPushButton:hover {
    background-color: #3e3e42;
    border: 1px solid #2196F3;
}

Adding Language Support

To add support for a new programming language:

  1. Update config/constants.py:

    LANGUAGE_EXTENSIONS: Dict[str, Set[str]] = {
        "python": {".py", ".pyw", ".pyx"},
        "c/cpp": {".c", ".cpp", ".h", ".hpp"},
        "javascript": {".js", ".jsx", ".ts", ".tsx"},  # Add new language
        # Add more languages as needed
    }
    
    LANGUAGE_DISPLAY_NAMES = {
        "python": "Python files only",
        "c/cpp": "C/C++ files only",
        "javascript": "JavaScript/TypeScript files",  # Add display name
    }
  2. Add language-specific patterns in config/language_config.py:

    def get_language_specific_patterns(language_filter: str) -> List[str]:
        if language_filter == "javascript":
            return [
                "",
                "# JavaScript/TypeScript",
                "node_modules/",
                "dist/",
                "build/",
                "*.js.map",
                "*.ts.buildinfo",
                "package-lock.json",
                "yarn.lock",
            ]
  3. Add to SECTION_ORDER in config/constants.py if needed.

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Report Issues: Open a GitHub issue for bugs or problems
  2. Request Features: Suggest new features through the issue tracker
  3. Submit Pull Requests: Implement improvements or fixes

Development Setup

# Activate virtual environment
source venv/bin/activate  # or venv\Scripts\activate on Windows

# Install development tools
pip install black flake8 mypy

# Format code (follows PEP 8)
black .

# Check code quality and style
flake8 .

# Run type checking
mypy .

# Test the application
python main.py

Code Style Guidelines

  • Follow PEP 8 conventions
  • Use type hints for function signatures
  • Add docstrings for public functions and classes
  • Keep functions focused and modular
  • Use descriptive variable and function names

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with PySide6 - The official Qt for Python binding
  • Inspired by the growing need for structured AI prompt engineering
  • Color scheme inspired by VsCodium's dark theme

πŸ› Troubleshooting

Common Issues

  1. "ModuleNotFoundError: No module named 'PySide6'"

    • Ensure virtual environment is activated: source venv/bin/activate
    • Reinstall requirements: pip install -r requirements.txt
  2. Application crashes on startup

    • Check Python version: python --version (needs 3.8+)
    • Try running with python3 main.py if python points to Python 2
  3. File tree not showing files

    • Check that you've selected a directory with the folder button
    • Verify language filter setting
    • Check .excludes file for overly restrictive patterns
  4. Buttons or text cut off

    • This is usually a DPI scaling issue on high-resolution displays
    • Try adjusting your system's display scaling settings
    • Or modify button heights in ui/components/text_section.py

Getting Help

  • GitHub Issues: Report bugs or request features
  • Pull Requests: Submit fixes or improvements
  • Documentation: Check this README first for common solutions

πŸ“ž Support


Made with ❀️ for developers and AI enthusiasts

Craft better prompts, write better code πŸš€

About

A GUI tool for crafting structured prompts with file integration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors