mdpack 0.1.0

Pack codebases into Markdown bundles and expand them back into files.
Documentation
  • Coverage
  • 0%
    0 out of 10 items documented0 out of 0 items with examples
  • Size
  • Source code size: 25 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.82 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 24s Average build duration of successful builds.
  • all releases: 28s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • AlextheYounga

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:

cargo install --git https://github.com/AlextheYounga/mdpack.git

CLI usage

Pack a directory:

mdpack pack ./my-project -o bundle.md

If -o is omitted, the bundle is written to bundle.md in the current directory.

Unpack a bundle:

mdpack unpack bundle.md -o ./my-project

If -o is omitted, files are written to the current directory.

Options:

  • --include-hidden to include dotfiles during packing.
  • --force to overwrite existing files during unpacking.

Library usage

Add as a dependency:

[dependencies]
mdpack = { git = "https://github.com/AlextheYounga/mdpack.git" }

Pack to a string or file:

use mdpack::{pack_to_path, pack_to_string, PackOptions};
use std::path::Path;

let options = PackOptions { include_hidden: false };
let bundle = pack_to_string(Path::new("./my-project"), options)?;
pack_to_path(Path::new("./my-project"), Path::new("bundle.md"), options)?;

Unpack from a string or file:

use mdpack::{unpack_from_path, unpack_from_str, UnpackOptions};
use std::path::Path;

let options = UnpackOptions { force: false };
let output = unpack_from_str("`foo.txt`:\n\n```\ncontent\n```\n", None, options)?;
unpack_from_path(Path::new("bundle.md"), Some(Path::new("./out")), options)?;

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

cargo test