Olegcat File Merger
Olegcat File Merger is a Visual Studio Code extension designed to concatenate multiple files from your workspace into a single, structured output file. This is particularly useful for preparing large code contexts for Large Language Models (LLMs), creating comprehensive project snapshots, or any scenario where you need a combined view of various project files.
The extension uses a simple configuration file named .olegcat
(by default) in your project root to determine which files to include or exclude, based on glob-like patterns.
License
All the code is licensed under the Universal Permissive License. See LICENSE.md for more details.
Features
- Pattern-Based File Selection: Define precisely which files to include or exclude using an
.olegcat
configuration file.
- Glob-like Patterns: Supports common wildcards (
*
, ?
) and recursive directory matching (**
) for flexible file matching.
- Project Structure Overview: The merged output automatically includes a text-based representation of your project's directory structure (for the included files).
- Metadata Header: The output file begins with a header containing:
- Project Name
- Creation Timestamp
- Project Root Path
- Include Patterns Used
- Exclude Patterns Used
- Context Menu Integration:
- Right-click on files/folders in the Explorer to merge them directly.
- Right-click on an
.olegcat
file to merge based on its configuration.
- Command Palette Access: All functionalities are available through the VS Code Command Palette.
- Default Configuration Generation: Easily generate a starter
.olegcat
file with common defaults.
- Syntax Highlighting Hints: The merged file uses Markdown code blocks with language identifiers for better readability.
How it Works
Create or Generate .olegcat
:
- Manually create a file named
.olegcat
in the root of your workspace.
- Or, use the command
Olegcat: Generate Default .olegcat Config File
to create one with pre-filled common patterns.
Define Patterns:
- Edit the
.olegcat
file to specify your include and exclude patterns.
- See the
.olegcat
File Format section below for details.
Merge Files:
- Use one of the available Commands to initiate the merge process.
- The merged content will be opened in a new editor tab. You'll be prompted if you want to save it.
The .olegcat
file is a plain text file where each line defines a pattern or is a comment.
- Comments: Lines starting with
#
are ignored.
- Include Patterns: Any line that is not a comment and does not start with
!
is an include pattern.
- Examples:
*.ts
, src/**/*.py
, docs/README.md
- Exclude Patterns: Lines starting with
!
are exclusion patterns. These take precedence over include patterns.
- Examples:
!node_modules/
, !dist/
, !*.log
, !**/*.test.ts
- Wildcards:
*
: Matches any sequence of characters except path separators (/
).
?
: Matches any single character except path separators.
**
: Matches any sequence of characters including path separators (for recursive directory matching). Usually used like src/**/*.js
.
- Directory Matching: Patterns ending with a
/
(e.g., dist/
) are typically used to match directories.
Example .olegcat
file:
# This is a comment
# Include all TypeScript files
*.ts
# Include all Python files within the 'src' directory and its subdirectories
src/**/*.py
# Include HTML files from the 'public' directory
public/*.html
# Exclude the node_modules directory
!node_modules/
# Exclude all .map files
!*.map
# Exclude temporary files
!temp/
!*.tmp
Commands
Access these commands via the Command Palette (Ctrl+Shift+P
or Cmd+Shift+P
):
Olegcat: Merge Selected Files/Folders
- Merges the files and/or folders currently selected in the VS Code Explorer.
- If an
.olegcat
file exists in the workspace root, its exclusion patterns will be respected. Selected files will be included if they match include patterns or if no include patterns are defined in the config.
Olegcat: Merge Files from Config
- Merges files based on the patterns defined in the
.olegcat
file.
- If invoked via the context menu on an
.olegcat
file, that specific file is used.
- If invoked from the command palette, it looks for
.olegcat
in the workspace root.
Olegcat: Generate Default .olegcat Config File
- Creates a new
.olegcat
file in the workspace root with a set of common default include and exclude patterns.
- If the file already exists, it will ask for confirmation before overwriting.
Development
Building from Source
- Clone the repository
- Run
npm install
to install dependencies
- Run
npm run compile
to build the extension
- Press
F5
to open a new Extension Development Host window
npm run install:publishers
2. Set Up Publishing Credentials
For VS Code Marketplace:
- Create a Personal Access Token at Azure DevOps
- Login with vsce:
vsce login your-publisher-name
For OpenVSX:
- Get an access token from Open VSX Registry
- Login with ovsx:
ovsx create-namespace your-publisher-name
(if needed)
Before publishing, update these fields in package.json
:
publisher
: Your publisher name/ID
repository.url
: Your GitHub repository URL
version
: Increment version number for each release
4. Publishing Commands
# Package extension into .vsix file
npm run package
# Publish to VS Code Marketplace only
npm run publish:vscode
# Publish to OpenVSX only
npm run publish:openvsx
# Publish to both marketplaces
npm run publish:all
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request