mdpack
Pack codebases into code2prompt-style Markdown bundles and expand them back into files. Inspired by code2prompt. Ships as both a CLI and a reusable Rust library.
Features
- Bundle a directory into a single Markdown file.
- Restore a bundle back into a directory.
- Safe path handling (no absolute paths or parent traversal).
- Works as a CLI and as a library API.
Install (CLI)
From this repository:
CLI usage
Pack a directory:
If -o is omitted, the bundle is written to bundle.md in the current directory.
Unpack a bundle:
If -o is omitted, files are written to the current directory.
Options:
--include-hiddento include dotfiles during packing.--forceto overwrite existing files during unpacking.
Library usage
Add as a dependency:
[]
= { = "https://github.com/AlextheYounga/mdpack.git" }
Pack to a string or file:
use ;
use Path;
let options = PackOptions ;
let bundle = pack_to_string?;
pack_to_path?;
Unpack from a string or file:
use ;
use Path;
let options = UnpackOptions ;
let output = unpack_from_str?;
unpack_from_path?;
Format
Bundles follow the code2prompt layout, minus the Project Path: line:
Source Tree:section with an ASCII tree- Per-file blocks in the form:
`path/to/file`:
```lang
<file contents>
```
Tests