🚀 A straightforward tool to combine multiple code files into a single output.
In a development environment, managing multiple code files can be a cumbersome task. The "Simple Code Combiner" app streamlines your workflow by allowing you to effortlessly combine various code files into a single output while labeling each file with its extension, all with just one click. Whether you're preparing scripts for deployment, consolidating code for testing, Feeding your code to LLMs for retrieval-augmented generation (RAG)., or simply organizing your projects, this free and open-source GUI tool enhances efficiency and reduces the risk of errors associated with manual copying and pasting. With support for a wide range of programming languages, customizable file types, and now, AI-powered summarization with local LLM support, it adapts to your specific needs, making it an essential addition to any developer's toolkit.
Code Combiner has been tested and produced in a Windows environment. If you are using a different platform (Linux or Mac), you can technically build the application in the respective environment using the provided source code.
- ✅ Streamlined for AI: With a single click, all your code is gathered in one location, simplifying the process of feeding it to AI / LLM.
- ✅ AI-Powered Summarization (API Key Req): Quickly summarize combined code using popular AI providers like OpenAI, Google Gemini, Mistral AI, Anthropic, and now with support for local LLMs (e.g., LM Studio, Ollama).
- ✅ Simple GUI: Intuitive drag-and-drop interface for easy file selection.
- ✅ Automatic Labeling: Automatically labels each file with its extension for clarity and organization, making it easier for AI to identify each file.
- ✅ Flexible File Support: Accepts a wide range of programming languages and code-related file extensions.
- ✅ Customizable File Types: Allows users to add or remove supported file extensions, saving preferences to a configuration file.
- ✅ Copy to Clipboard: Copies the combined content to the clipboard with one click.
- ✅ Save Combined Output: Saves the combined text to a single .txt file.
- ✅ Always on Top: Keeps the application window in front of all other windows for easy access to all your code files.
- ✅ Configuration: Added a dedicated configuration dialog for AI providers, allowing users to easily set API keys, API bases, organization IDs, and choose the preferred model.
To run the program:
- Python 3.8+ installed (if running from source).
- TkinterDnD2, ttkbootstrap and
requestsinstalled as dependencies
- Download the latest release from the Releases Page.
- Run the
CodeCombiner.exefile.
Note Regarding Antivirus: Some antivirus programs might flag the executable as a potential threat. This is a common occurrence for applications created with tools like PyInstaller. If this happens, you can usually choose to "allow" or "whitelist" the application in your antivirus settings. The source code is available for review in this repository.
- Clone this repository:
git clone https://github.com/chandrath/Simple-Code-Combiner.git cd Simple-Code-Combiner - Install dependencies:
pip install -r requirements.txt
- Run the application:
python CodeCombiner.py
- Drag and drop code files directly into the text area of the application.
- Use the
Preferences -> Manage Extensionsto view the current list of supported file types. - Add a new file extension (e.g.,
.myext) into the text entry and clickAdd - Select an extension in the list and click
Removeto remove it from the list.
- Click the 'Combine Files' button to merge the content of all listed files into a single output in the text area.
- Click the 'Copy to Clipboard' button to copy the combined content to the clipboard.
- Use the 'File -> Save Combined File' option to save the combined content to a file.
- Click the 'AI Summarize' button to generate a summary of the combined text using a configured AI provider. The progress bar will show the summarization process.
- Configure your AI provider via
Preferences -> AI Configuration - Important: Your text will be processed by the selected AI provider and will be subject to their respective privacy policies.
We believe strongly in protecting your privacy. Code Combiner does not collect or store any of your input data. It doesn't even collect general logs. If you choose to use a local LLM, your text processing is entirely on-device and there's no risk of your data being sent to a server. Note: If you choose to use a cloud-based LLM, refer to the AI provider's privacy policy and terms of service.
- Download and install Ollama: (https://ollama.com/download)
- Choose an LLM from here. Recommended: Llama 3.1 8B (~8GB RAM or VRAM required).
- Run ollama run llama3.1:8b in your terminal to download and launch Llama 3.1.
- In Code Combiner, set the Local LLM provider with:
- API Key: ollama
- API Base URL: http://localhost:11434/v1
- API Model: llama3.1:8b That's it! Enjoy Code Combiner 's ai summerzie fearutre with absolute privacy and no internet connection! 🎉
To create a standalone executable for the CodeCombiner application (which uses tkinterdnd2 for drag-and-drop functionality), follow these instructions. It is crucial to complete each step carefully for a successful build.
Prerequisites:
-
Python and Pip: Ensure you have Python (version 3.8 or higher) and
pipinstalled on your system. -
PyInstaller: If you don't have it installed, install it using pip:
pip install pyinstaller
-
tkinterdnd2: Ensure you havetkinterdnd2installed:pip install tkinterdnd2
Steps:
-
Prepare Project Files: Ensure your main project file (
main.py) and the hook file (hook-tkinterdnd2.py) are in the same directory. -
Obtain
hook-tkinterdnd2.py: Downloadhook-tkinterdnd2.pyand save it in the same directory as yourmain.pyfile. The original file (under MIT License) can be obtained from:
https://github.com/pmgagne/tkinterdnd2/blob/master/hook-tkinterdnd2.py
*Note: If you are working with an updated version or fork, make sure to use the corresponding hook file (if needed).*
A modified version of the hook file that resolves certain issues can be used from the project folder
-
Build with PyInstaller: Open a terminal or command prompt in the same directory where your project files are located. Then, execute the following PyInstaller command:
pyinstaller -F --additional-hooks-dir=. --onefile --windowed --icon=app.ico --add-data "models.json:." main.py-For--onefile: Creates a single, self-contained executable file.--additional-hooks-dir=.: Tells PyInstaller to use thehook-tkinterdnd2.pyfile in the current directory to correctly includetkinterdnd2files.--windowed: Creates an executable without a console window, suitable for GUI applications.--icon=app.ico: For the exe icon.CodeCombiner.py: Specifies your main Python script file.
-
Locate the Executable: After a successful build, the executable file will be located in the
distsubdirectory within your project directory.
Explanation of the Process
tkinterdnd2Dependency: Thetkinterdnd2library is a wrapper for thetkdndextension and requires special handling during PyInstaller builds. Thehook-tkinterdnd2.pyfile provides PyInstaller with the necessary information to correctly bundletkdnd.- Custom Hook File: The custom hook file ensures that all platform specific binaries of
tkdndlibrary are included in your build. Theadditional-hooks-dir=.tells PyInstaller where to find the custom hook script. - One-File Distribution: Using
-For--onefileprovides a single executable, which simplifies distribution as it does not require additional files or setup on the user's machine. - No Console Window: By using the
--windowedthe end user won't see a console window when launching the executable.
Important Notes:
- License: The provided
hook-tkinterdnd2.pyfile is under the MIT License. Make sure you retain the license notices where appropriate. - Error Troubleshooting: If you encounter errors during the build, carefully check the terminal output and verify that you have followed all the steps.
- Testing: Thoroughly test your built executable after building it to make sure all functions work as expected.
- Alternative Hook File: If the hook file from the repository does not work properly, use the modified one from project directory.
Attribution:
These instructions are partially based on the information available in the tkinterdnd2 project's page on PyPI (https://pypi.org/project/tkinterdnd2/) and with thanks to the advice and tips of @Matthias W (https://stackoverflow.com/a/78833056).
- Support for CLI interface
- "Simple Code Combiner" uses the GPLv3 license
