$ show tkellogg/dura
Dura is a background process (daemon) that automatically snapshots uncommitted changes in Git repositories. It runs as a CLI tool with subcommands: `serve` (daemon loop), `watch`/`unwatch` (manage watched repos), `capture` (one-shot snapshot), `status` (daemon state), `kill` (stop daemon), and `metrics` (post-process logs with git diff stats). The architecture is a single Rust binary. On every polling cycle (5 seconds), it iterates watched repos, uses an optimized file-timestamp check (`PollGuard`) to detect changes efficiently, then creates a commit on a separate `dura/<HEAD_hash>` branch without modifying the working tree or HEAD. Snapshots include all tracked and untracked files. Configuration is stored as TOML in the user's config directory; runtime state (PID) is stored as JSON. Logging is structured JSON via a custom tracing layer. The design emphasizes non-disruptive operation and data safety.
The LLM identified 2 files worth highlighting for reuse:
Implements `PollGuard`, a self-contained struct that detects file changes in a Git repository by comparing last-modified timestamps against the last commit time of the durable branch. It caches open `Repository` objects and uses `walkdir` to traverse files. This avoids expensive `git` operations on every poll. The component is fully independent (no internal crate imports) and can be extracted for any project needing efficient filesystem change detection.
Provides `NestedJsonLayer`, a custom `tracing` subscriber layer that serializes structured events into JSON with nested fields (e.g., target, file, level, fields, time). It handles arbitrary types by attempting JSON parsing or fallback to debug formatting. This layer is reusable in any Rust application using `tracing` for JSON logging and has no dependencies on other modules in the crate.