molddir simplifies merging directory files into a single file. It's especially useful for sending entire codebases to Large Language Models (LLMs) by encoding the codebase into one string
Project description
molddir: Encoder-Decoder Module
molddir is a Python package that provides a simple way to encode and decode files and directories into a custom format. This module is particularly useful in the era of Large Language Models (LLMs), where sending a complete codebase to an LLM can be a tedious task. molddir helps by encoding the entire codebase into a single string, which can then be easily decoded back into the original files and directories.
Features
- Encoder Class: Encodes files and directories into a custom format.
- Decoder Class: Decodes the encoded data back into files and directories.
- CLI Tool: Provides a command-line interface for easy usage.
- Supports ignoring files from repository
.gitignorefiles. - Allows you to customize the encoding pattern using keys.py module.
Installation
You can install molddir using Poetry:
poetry add molddir
Or using pip:
pip install molddir
Modules
decoder: Contains theDecoderclass for decoding the codebase.encoder: Contains theEncoderclass for encoding the codebase.keys: Contains theKeyBuilderclass for building keys.walker: Contains theFolderWalkerclass for walking through folders.
Using the Module
Encoder Class
The Encoder class is responsible for encoding files and directories into a custom format. It takes in a codebase path as an argument, which can be a file or a directory.
from molddir import Encoder
encoder = Encoder("path/to/codebase")
encoded_data = encoder()
print(encoded_data)
Decoder Class
The Decoder class is responsible for decoding the encoded data back into files and directories.
from molddir import Decoder
decoder = Decoder("output_dir")
decoder(encoded_str="@@@@@@@file1@@@@@@@\nprint('Hello, World!')\n=======\n")
Using the CLI Tool
This script main.py provides a command-line interface (CLI) for encoding and decoding a codebase. It supports the following functionalities:
- Encoding a codebase using the
Encoderclass. - Decoding an encoded file using the
Decoderclass. - Displaying the version of the tool.
Usage
python main.py --encode --codebase_path <path_to_codebase>
python main.py --decode --encoded_file <path_to_encoded_file> --output_dir <output_directory>
python main.py -v | --version
Arguments
- --encode: Encode the codebase.
- --decode: Decode the codebase.
- --codebase_path: Path to the codebase to encode.
- --encoded_file: Path to the encoded file to decode.
- --output_dir: Directory to save the decoded codebase.
- -v, --version: Display the version of the tool.
Examples
Encode a Codebase
python main.py --encode --codebase_path /path/to/codebase
Decode an encoded file
python main.py --decode --encoded_file /path/to/encoded/file --output_dir /path/to/output/dir
Display the version
python main.py -v
Why Use molddir?
In the era of Large Language Models (LLMs), sending a complete codebase to an LLM can be a tedious task. molddir simplifies this process by encoding the entire codebase into a single string. This encoded string can then be easily sent to an LLM, and decoded back into the original files and directories when needed.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file molddir-0.1.3.tar.gz.
File metadata
- Download URL: molddir-0.1.3.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.9.19 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56835c01cf9bef159136662c847e96a5b63fd1f796b8dc8e6166a61a372d4eed
|
|
| MD5 |
168e60fe192f728d23be0996eea29c35
|
|
| BLAKE2b-256 |
e645c319b95d62aaf0197ea61fbd4a1e375125536c98152885785f1ea73dc6a8
|
File details
Details for the file molddir-0.1.3-py3-none-any.whl.
File metadata
- Download URL: molddir-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.9.19 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72ba0b8193e56c8637253c6735e9c35b07d9cd94c317b8b75b94be307c65d9a3
|
|
| MD5 |
7ef29b18c12a8c10e6058e284bc01a8d
|
|
| BLAKE2b-256 |
1d4c5c6b95b41cd4f3ef8ab5a726e89e3bf7ff75d07ae5361b80c22602aca809
|