CodeFusion
An app that merges your codebase into one text file so you can copy and paste it into another AI (e.g., one with a larger context window) for analysis.
Purpose:
Create a desktop app that lets you drag-and-drop a codebase folder onto a window. The app recursively traverses the folder, reads supported code files, and combines them into one annotated text file for AI analysis. Annotations include each file's folder and name. The app features:
-
Extensive File Support:
Supports a wide range of file types including:- JavaScript/TypeScript:
.js,.jsx,.ts,.tsx,.mjs,.cjs - Web Development:
.html,.htm,.css,.scss,.sass,.less,.vue,.svelte - Documentation/Config:
.md,.mdx,.txt,.yaml,.yml,.toml,.ini,.env.example,.json,.jsonc,.json5 - Python:
.py,.pyi,.pyw,.ipynb - Other Languages:
.java,.kt,.scala,.c,.cpp,.h,.hpp,.cs,.go,.rb,.php,.rs,.swift,.sh,.bash,.zsh,.fish,.pl,.pm - Config/Build:
.xml,.gradle,.properties,.dockerfile,.containerfile,.rules
- JavaScript/TypeScript:
-
Smart File Omission:
- Automatically excludes common non-essential directories (
.git,node_modules, etc.) - Respects
.gitignorepatterns if present - Excludes media files (images, audio, video)
- Provides checkboxes for common ignore patterns
- Supports custom regex patterns for fine-grained control
- Automatically excludes common non-essential directories (
-
Interactive File Preview:
- Tree view of all files with inclusion/exclusion status
- File size information
- Collapsible directory structure
- Search/filter functionality
- Individual file toggles
-
Results and Statistics:
- Character count
- Approximate token count
- Copy to clipboard functionality
- Save to file option
-
Modern UI/UX:
- Drag-and-drop interface
- Loading indicators
- Clear feedback on file processing
- Easy folder switching
- Responsive design
Note: Replace these placeholder images with your actual screenshots.
-
Clone the Repository
git clone https://github.com/YOUR_USERNAME/codefusion.git cd codefusion
-
Install Dependencies
npm install
-
Run in Development Mode
npm start
-
Build for Production (Optional)
npm run build
This will create an installer in the
distfolder.
- If you encounter any issues with native dependencies, make sure you have the following installed:
- Windows Build Tools: Run
npm install --global windows-build-toolsin an elevated (Administrator) PowerShell - Python 2.7 or 3.x (required for some node modules)
- Windows Build Tools: Run
- If you get permission errors, make sure you're running the commands with appropriate privileges
- Drag-and-drop folder selection ✅
- File system traversal ✅
- Smart file filtering ✅
- File content combination ✅
- Statistics calculation ✅
- Save functionality ✅
- Interactive file preview ✅
- Folder selection dialog ✅
- Loading overlay ✅
- File tree view ✅
- Omission controls ✅
- Results display ✅
-
.gitignoresupport ✅ - Custom regex filters ✅
- Individual file overrides ✅
- Directory collapsing ✅
- File search/filtering ✅
- Copy to clipboard ✅
- Entry Point:
main.js - Responsibilities:
- Create and manage the main application window.
- Handle file system operations (reading directories, files, applying omission patterns).
- Use Node.js APIs (
fs,path) to process files. - Expose IPC channels (using
ipcMain) to receive folder paths and omission settings from the renderer and to send back the combined text and statistics. - Handle file-save dialogs for exporting the combined file.
- Entry Point:
index.html - Responsibilities:
- Render the drag-and-drop interface and controls for omission settings.
- Allow the user to view an interactive preview of files that will be included or omitted (with the option to adjust filters or regular expressions).
- Display progress, statistics (character count and approximate token count), and final results.
- Trigger processing via IPC calls to the main process.
- Channel Examples:
process-folder: Renderer sends the dropped folder path along with omission settings (an array of regular expressions) to the main process.processing-complete: Main process returns the combined text and statistics (total characters, token approximation).save-file: Initiates a save dialog to write the output file.
-
Recursive Traversal:
Use a recursive function in the main process to traverse the dropped folder. For each file:- Check if it matches the supported file extensions (
js,json,md,ts,html,css,rules,py). - Apply default and user-specified omission rules.
- Defaults include:
- Patterns from a
.gitignorefile (if present in the root). - Folders named
.git,node_modules. - Any file/folder starting with a period (e.g.,
.next,.swc).
- Patterns from a
- Defaults include:
- If a file is not omitted, read its content and prepend an annotation header such as:
// ===== Folder: /path/to/folder | File: example.js =====
- Check if it matches the supported file extensions (
-
Interactive Preview:
Before final processing:- Build a list of all files encountered along with a flag indicating whether each file will be included or omitted.
- Send this list to the renderer so the user can review and adjust the omission patterns if needed.
- Allow the user to "toggle" or modify the omission rules via text input or checkboxes (for common patterns).
-
Combining Logic:
As files are read, append the annotated content to a single string (or stream it if needed for larger projects). -
Statistics Calculation:
- Character Count:
const totalCharacters = combinedText.length;
- Approximate Token Count:
const approxTokens = Math.ceil(totalCharacters / 4);
(This approximation assumes an average of 4 characters per token, which is acceptable for your needs.)
- Character Count:
-
Drag-and-Drop Area:
A prominent area where users can drop their folder. Visual cues (e.g., "Drop your code folder here") help indicate the action. -
Omission Controls:
- A text input area to enter additional regular expressions or file extensions to omit.
- Checkboxes for common omissions (e.g., "Ignore .git", "Ignore node_modules", "Ignore files/folders starting with a period").
- A preview pane listing files with an indicator for whether they will be processed or skipped.
-
Progress Indicator:
A progress bar or spinner during file processing. -
Results Panel:
After processing, display:- Total characters and approximate token count.
- A large text area containing the combined annotated code.
- A "Save File" button to export the results via a file dialog.
- Landing Screen:
The main window invites you to drag and drop your code folder. - Preview Screen:
Once the folder is dropped, the app shows a list of files marked as "included" or "omitted." You can adjust omission rules here. - Processing Screen:
Upon confirmation, the app processes the files while displaying progress. - Results Screen:
The app shows the combined text along with character and token counts, and provides an option to save the file.
- Tool:
Use a tool like electron-builder to package the app as a Windows installer. - Configuration:
Create a configuration file (electron-builder.jsonor package.json entries) specifying Windows targets, icon assets, and installation options.
/my-code-combiner-app
├── package.json // Dependencies (electron, electron-builder, etc.) and scripts
├── main.js // Main process: creates the window, handles IPC, and processes files
├── preload.js // (Optional) Securely expose required Node APIs to the renderer
├── renderer.js // Handles UI logic, drag-and-drop, preview, and interactions
├── index.html // Main HTML file for the UI
├── styles.css // Styling for the UI
└── ignoreDefaults.js // (Optional) Contains default ignore patterns and .gitignore processing logic
-
Performance:
Given a couple of megabytes of code (after omittingnode_modulesand similar folders), synchronous file reads should suffice, though you could refactor to asynchronous reads if needed. -
AI Analysis Metadata:
Currently, the app includes annotations (folder and file names) for context. If needed later, you could add timestamps or file sizes, but this should be sufficient for AI models to understand file context. -
Installer Packaging:
Use electron-builder with a configuration tailored to Windows, ensuring that the app can be installed easily on Windows systems.
Contributions are welcome! Here's how you can help:
-
Fork the Repository
- Fork the project to your GitHub account
- Clone your fork locally
-
Create a Branch
git checkout -b feature/your-feature-name
-
Make Your Changes
- Write your code
- Test your changes
- Commit with clear, descriptive messages
-
Push and Create a Pull Request
- Push to your fork
- Create a Pull Request from your branch to our main branch
- Describe your changes in detail
- Follow the existing code style
- Add comments for complex logic
- Update documentation as needed
- Test your changes thoroughly
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions or suggestions, please:
- Open an issue
- Submit a pull request
- Contact the maintainers through GitHub


