CodeUnify: Combine Multiple Code Files into One
Introduction
CodeUnify is a Python library that helps developers combine multiple source code files from a directory into a single output file. It supports various programming languages and preserves the structure by marking the start and end of each file with appropriate comment styles.
This tool is particularly useful for AI-assisted development tools, enabling better context-aware debugging, analysis, and assistance by providing a unified file containing all necessary code components with clear section markers.
Features
- Combines files from multiple languages: Supports
.py,.js,.cpp,.c,.java,.ts,.go,.cs,.html,.xml,.txt, and more. - Per-file comment styles: Each file retains its own comment style (
#,//,<!-- -->, etc.), ensuring readability. - Indentation for clarity: The contents of each file are indented under its respective section headers for easy visual distinction.
- Command-line integration: Run directly from the terminal with flexible options.
- Excludes metadata and binary files: Ignores
.git,__pycache__,.idea,.vscode, and skips non-text files.
Installation
-
Clone the repository:
git clone https://github.com/takuphilchan/codeunify.git cd codeunify
-
Install dependencies:
pip install -r requirements.txt
-
Ensure Python 3.x is installed:
python --version
Usage
1. Combine Files with Default Settings
To combine all code files from a directory into a single output file, run:
codeunify /path/to/code/files output_combined.txt
2. Combine Specific File Types
To only include certain file extensions (e.g., .py and .js):
codeunify /path/to/code/files output_combined.txt --file_types .py .js
3. Customize Indentation
The --block_indent flag allows adjusting how much each file's content is indented:
codeunify /path/to/code/files output_combined.txt --block_indent " "
(Default indentation is a tab \t.)
Example
Given Input Files:
app.py:
def main():
print("Hello, World!")
utils.js:
function greet() {
console.log("Hello from JS!");
}
index.html:
<html>
<body>
<h1>Welcome to my website</h1>
</body>
</html>
Running:
codeunify /projects/code/ combined_output.txt
Correct Output:
# >>>>> START: app.py <<<<<
def main():
print("Hello, World!")
# <<<<< END: app.py >>>>>
// >>>>> START: utils.js <<<<<
function greet() {
console.log("Hello from JS!");
}
// <<<<< END: utils.js >>>>>
<!-- >>>>> START: index.html <<<<< -->
<html>
<body>
<h1>Welcome to my website</h1>
</body>
</html>
<!-- <<<<< END: index.html >>>>> -->
How It Helps AI-Assisted Development
- Improved Code Context: AI tools can analyze code with clear section markers instead of handling separate files.
- Enhanced Debugging: AI-powered debugging can trace issues across multiple files more effectively.
- Better Code Completions: By knowing the entire project's structure, AI can provide better auto-suggestions.
Contributing
We welcome contributions! Feel free to fork the repository, make changes, and submit a pull request.
License
This library is licensed under the MIT License.
Metadata
Release files for codeunify 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| codeunify-0.2.6.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codeunify-0.2.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.3 kB
Release files / codeunify-0.2.6.tar.gz
| Download URL | codeunify-0.2.6.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
802e09fefacd468ba9e1ec5ceb0d958696b75d4ee5b42a27c0138cab649b36ee
|
|
BLAKE2b-256 checksum How to use checksums |
4ff45fe50a415ab39771949c4e623862fba6bad47d7122dda5e610c21e42d46c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
|
Release files / codeunify-0.2.6-py3-none-any.whl
| Download URL | codeunify-0.2.6-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd9fa9398863a3b10bb3099e9c1a43e3e636ddf57e8c65704859bb8b1072a0e8
|
|
BLAKE2b-256 checksum How to use checksums |
901b5f577d7af05b1b54eede3de94d138a353cc32f531d4b7507235fd52b3087
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
|