# srcdmp
**srcdmp** (pronounced "source dump") is a source code snapshot tool. It packs an entire project directory into a single, compact `.srcdmp` binary file.
```sh
srcdmp wrap . # pack the current directory
srcdmp view snapshot.srcdmp # browse interactively
srcdmp unpack snapshot.srcdmp ./out # reconstruct the directory
```
Every snapshot filename carries its metadata:
```
2026-05-23-myproject-0.1.0.srcdmp
```
---
## Status
_srcdmp_ is under active development. The API and binary format are not yet stable.
```sh
cargo install srcdmp
```
---
## The codecs
`.srcdmp` files use the **SDMP** codec family, designed specifically for source code text.
| SDMP-C4 | `0x04` | Implemented | Huffman-tree compression using empirically-derived frequencies (default) |
| SDMP-7 | `0x07` | Implemented | Three-tier encoding with a 128-entry ASCII table + extended lookup |
| SDMP-8 | `0x08` | Implemented | Raw UTF-8 passthrough (no compression) |
| SDMP-C2 | `0x02` | Planned | Order-2 context model + arithmetic coding |
SDMP-C4 is the default, balancing compression ratio and throughput.
---
## CLI usage
### Wrap a directory
```sh
srcdmp wrap . output.srcdmp
srcdmp wrap . --codec 7 # use SDMP-7 instead
srcdmp wrap . --ignore "*.png" # skip files matching glob
srcdmp wrap . --gitignore # respect .gitignore rules
```
### Auto-named snapshot
```sh
srcdmp wrap . --from-cargo # produces 2026-05-23-<name>-<version>.srcdmp
```
### Unpack
```sh
srcdmp unpack snapshot.srcdmp # reconstruct into current directory
srcdmp unpack snapshot.srcdmp --output ./out
```
### Browse
```sh
srcdmp view snapshot.srcdmp # interactive TUI browser
srcdmp unwrap snapshot.srcdmp out.log # decode to a readable log file
```
### Inspect
```sh
srcdmp info snapshot.srcdmp # print header metadata (codec, file count, size)
srcdmp check snapshot.srcdmp # verify every file decodes successfully
```
---
## Library API
`srcdmp` is both a CLI tool and a Rust library (behind the `cli` and `fs` feature flags, both enabled by default).
```toml
[dependencies]
srcdmp = { git = "https://codeberg.org/razkar/srcdmp" }
```
```rust
use srcdmp::{Dump, Codec};
// Create a snapshot of the current directory.
let dump = Dump::from_dir(".")
.codec(Codec::Compact4)
.gitignore()
.ignore("target/**")
.build()?;
// Write to a date-stamped file using metadata from Cargo.toml.
dump.from_cargo().write_to("dump/")?;
// Open an existing snapshot and reconstruct the directory tree.
let dump = Dump::open("2026-05-23-myproject-0.1.0.srcdmp")?;
dump.unpack_to("output/")?;
```
The library also exposes the individual codecs and raw format primitives via the `raw` module:
```rust
use srcdmp::raw::codec::sdmpc4;
let compressed = sdmpc4::encode("fn main() { loop {} }");
let decompressed = sdmpc4::decode(&compressed)?;
```
---
## File annotations
Individual files can opt in or out using annotations in the first 512 bytes of content:
```
@srcdmp:ignore - exclude this file from the snapshot
@srcdmp:force - include even if the file appears binary
```
Binary detection checks for a null byte within the first 8000 bytes; files
appearing binary are skipped automatically.
---
## Self-hosting
Every release of srcdmp is archived as a `.srcdmp` snapshot in [`dump/`](dump/).
```sh
cargo install srcdmp
srcdmp view dump/2026-05-23-srcdmp-0.1.0-dev.1.srcdmp
```
---
## License
Licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))
- MIT license ([LICENSE-MIT](LICENSE-MIT))
at your option.
Cheers, RazkarStudio.
Copyright © 2026 RazkarStudio. All rights reserved.