Skip to main content

lds_pack/
lib.rs

1//! Pack a whole project into one portable archive, and put it back.
2//!
3//! An `lds` pack is not a source tarball and not a `git bundle`. It carries the
4//! project as it actually exists on the machine:
5//!
6//! - the **`.git` directory itself**, copied wholesale — so stashes, the
7//!   reflog, local-only branches, and objects no ref points at all come along.
8//!   A bundle is assembled from an enumerated set of refs, and everything
9//!   outside that set is quietly left behind; copying the directory means there
10//!   is no set to enumerate and nothing to forget.
11//! - the **untracked local state** that ordinarily never leaves the machine:
12//!   a `workspace/` tree, journal databases, sandbox snapshots, `.mcp.json`,
13//!   `.claude/`.
14//!
15//! Three things are treated specially:
16//!
17//! | | treatment |
18//! |---|---|
19//! | secrets (`.env`, `*.pem`, …) | **not packed**, reported instead — moving credentials is the operator's own business |
20//! | caches (`target/`, `node_modules/`, …) | **not packed**, recorded — regenerable by definition |
21//! | symlinks | packed as links, never followed; reported so a restore elsewhere can name what dangles |
22//!
23//! `.claude/` is its own layer: packed verbatim, with its links counted and
24//! their shared roots summarized rather than enumerated one by one.
25//!
26//! # Example
27//!
28//! ```no_run
29//! use lds_pack::{CreateOptions, RestoreOptions, create, restore};
30//!
31//! let report = create(&CreateOptions::new("/path/to/proj", "proj.pack", "0.13.3"))?;
32//! println!("packed {} files", report.manifest.stats.file_count);
33//!
34//! let restored = restore(&RestoreOptions::new("proj.pack", "/tmp/proj"))?;
35//! if restored.needs_attention() {
36//!     println!("{} symlinks dangle here", restored.dangling_symlinks.len());
37//! }
38//! # Ok::<(), lds_pack::PackError>(())
39//! ```
40
41pub mod create;
42pub mod error;
43pub mod inspect;
44pub mod manifest;
45pub mod restore;
46pub mod rules;
47pub mod scan;
48
49pub use create::{CreateOptions, CreateReport, DEFAULT_COMPRESSION_LEVEL, create};
50pub use error::PackError;
51pub use inspect::{inspect, list_payload_paths, verify};
52pub use manifest::{
53    ClaudeInfo, MANIFEST_NAME, Manifest, PACK_FORMAT_VERSION, SkipRecord, Stats, SymlinkRecord,
54    WorktreeRecord,
55};
56pub use restore::{RestoreOptions, RestoreReport, restore};
57pub use rules::{DEFAULT_CACHE_DIRS, DEFAULT_KEEP, DEFAULT_SECRET_GLOBS, PackRules, RuleOverrides};
58pub use scan::{Scan, scan, scan_with};