Skip to content

Margaret

Margaret measures the byte size and physical-line count of Rust source files. It can write a Markdown report from the command line or expose the same measurements through a local MCP server.

Build and run

Build Margaret:

cargo build --release

From the root of the Rust project to measure, run the executable with no arguments:

/path/to/marg/target/release/marg

This prints totals and writes a dated report to docs/reports/report-marge-YYYY-MM-DD.md (UTC). Files in .git and target directories are excluded. Symlinks are not followed. Each file’s byte count uses its raw contents; physical lines count each LF-terminated line once and a nonempty final line without LF once.

MCP

Launch Margaret as a local MCP server over stdio:

/path/to/marg/target/release/marg mcp

Configure it in OpenCode with the project workspace as cwd. See docs/opencode-mcp.md for a configuration example. The audit_project tool returns each Rust file’s path, byte size, and physical-line count, along with totals and the generated Markdown report.

If a discovered file cannot be read, Margaret reports a scan warning and marks verification incomplete. Invalid UTF-8 files can still be measured because file sizes are read as raw bytes.