Skip to main content

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 : Ignores the files/directory from repository .gitignore .
  • Supports Incremental Encoding: Encode only the incremental changes since the last commit.
  • 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 the Decoder class for decoding the codebase.
  • encoder: Contains the Encoder class for encoding the codebase.
  • keys: Contains the KeyBuilder class for building keys.
  • walker: Contains the FolderWalker class 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(codebase_path = "path/to/codebase" )
encoder()

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 = "path/of/a/directory")
decoder(encoded_file = "path/to/encoded/file")

Using the CLI Tool

<<<<<<< HEAD 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 Encoder class.
  • Decoding an encoded file using the Decoder class.
  • 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
=======
molddir provides a command-line interface for easy usage. Below are the available commands and their usage:

### Encoding
To encode a codebase, run:

molddir --encode --codebase_path <path_to_codebase> [--incremental] [--log-level <log_level>]

main

* --encode: Encode the codebase.
* --codebase_path: Path to the codebase (file or directory) to be encoded.
* --incremental: (Optional) Enable incremental encoding.
* --log-level: (Optional) Set the logging level. Choices are DEBUG, INFO, WARNING, ERROR, CRITICAL. Default is INFO.

<<<<<<< HEAD
### Arguments
* --encode: Encode the codebase.
* --decode: Decode the codebase.
* --codebase_path: Path to the codebase to encode.
* --incremental: Enable incremental encoding (default: False)
* --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

Decoding

To decode the encoded data back into files and directories, run:

molddir --decode --encoded_file <path_to_encoded_file> --output_dir <output_directory> [--incremental] [--log-level <log_level>]
>>>>>>> main
  • --decode: Decode the codebase.
  • --encoded_file: Path to the encoded file to decode.
  • --output_dir: Directory where the decoded files and directories will be saved.
  • --incremental: (Optional) Enable incremental decoding.
  • --log-level: (Optional) Set the logging level. Choices are DEBUG, INFO, WARNING, ERROR, CRITICAL. Default is INFO.

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.

Metadata

Release files for molddir 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for molddir 0.1.5
File Size Uploaded
molddir-0.1.5.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for molddir 0.1.5
File Interpreter ABI Platform
molddir-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 22.7 kB

Release files / molddir-0.1.5.tar.gz

Download URL molddir-0.1.5.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fd4d8fdf9356bce48acd60655a8966f662ca96565fd9ddb529e4f35d36549409
BLAKE2b-256 checksum
How to use checksums
95464b0da6e3031144d9d498068a1e225983319497f8d35b6319010f2f6c03f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.9.19 Linux/6.5.0-1025-azure

Release files / molddir-0.1.5-py3-none-any.whl

Download URL molddir-0.1.5-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97a8bb5638c0874b6c88debb00cfccaa14e460b0d75441d0367798aa51d89228
BLAKE2b-256 checksum
How to use checksums
3d17ddc602f455f601c89e629d0e67fe8c79f807827ab0b924a57699cadb401e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.9.19 Linux/6.5.0-1025-azure

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page