How cod-e-codes/astvcs works
1. System shape
astvcs is a local-first Rust CLI for versioning a working tree of source files. The repository model lives under .astvcs/ and is built around content-addressed state, a commit timeline, branches, tags, and remotes. It is not Git-compatible; Git import is one-way only.
2. Entry points
src/main.rs is the CLI binary, while src/lib.rs exposes the reusable core. The command surface is organized around familiar VCS actions such as init, status, add, commit, diff, merge, branch, fetch, clone, reset, revert, rebase, cherry-pick, stash, blame, and bisect.
3. Command interpretation layer
The src/intent/ module is the top-level orchestration boundary between CLI commands and repository operations. It likely turns parsed command-line input into higher-level actions against the store, diff, merge, and network subsystems.
4. Repository/store subsystem
src/store/ is the main persistence and repository-state layer. It covers repository initialization, history, manifest, blobs, staging, working-tree interaction, locks, hooks, identity, tags, stash, shallow history, reachability, integrity checks, garbage collection/repacking, and Git import. This is where on-disk state under .astvcs/ is managed.
5. Content model and persistence
Inside the store, blobs and manifests are the basic storage units. Supporting modules such as format, pack, atomic, lock, scan_cache, and working indicate a content-addressed storage format with atomic updates, advisory locking, and cached filesystem scans to keep repository operations safe and efficient.
6. Graph and history model
src/graph/ models the commit DAG and its edges/nodes/mutations. This is the layer that history-oriented features such as log, blame, reachability, bisect, rebase, and cherry-pick build on. It is the structural representation of repository history separate from file content.
7. Frontend/file classification
src/frontend/ decides how a path is represented before diffing or storage. Tree-sitter support is central: if a file type is parseable, astvcs treats it as an AST-backed structural blob; otherwise it falls back to UTF-8 text (textblob.rs) or raw bytes (binaryblob.rs). Symlinks are handled separately, and language detection lives here too.
8. Structural diff pipeline
src/diff/ implements the comparison engine. It includes AST diffing, text diffing, LCS/alignment, path rename detection, and a viewer export path. The diff system is not only for user-facing diff; it also feeds merge and conflict detection by determining how nodes and lines correspond across versions.
9. Merge subsystem
src/merge/ and store-side merge helpers handle three-way merging of structural edits. The key architectural boundary is that non-overlapping AST edits can be auto-applied, while overlapping edits become structural conflicts that are resolved per path rather than by writing conflict markers into files.
10. Network and remote sync
src/network/ provides remote interaction over local paths, HTTP/HTTPS, and SSH. The presence of serve, remote_serve, transport, api, sync, and ssh suggests a split between transport abstraction, server-side serving, and client-side fetch/clone/push-like synchronization, with optional bearer auth and TLS support in the serving path.
11. Working tree, staging, and user-visible workflow
The workflow is local and stateful: working-tree changes are scanned, staged via add, committed into the store, and compared via diff --staged or normal diff. The staging/index layer sits between filesystem state and repository history, so operations like reset, status, and commit are mediated through it.
12. Operational safety
The store includes explicit integrity, reachability, and locking modules, indicating that concurrent access and repository health are first-class concerns. This supports safe reads during serving while writes serialize, and enables maintenance commands such as fsck, gc, and repack.
13. Developer-facing artifacts
examples/ contains runnable fixture repositories that demonstrate identity, import-git, lifecycle, merge, network, shallow history, same-file handling, serving, and workflow scenarios. The .cursor/skills/ content and tests/ folder show that the repo is organized for both automated validation and guided contributor workflows.
14. Architecture boundary summary
The key diagram boundary is: CLI/intent at the top, repository/store and graph in the middle, frontend and diff/merge as content-processing engines, and network as an outer synchronization layer. Everything ultimately converges on the local .astvcs/ repository state rather than an external service or Git-compatible backend.
Main entry points: store/mod.rs store · intent/mod.rs intent · frontend/mod.rs frontend · network/mod.rs network
Components 21
CLI surface
Command entrypoints and command-to-action orchestration
Repository core
Persistence, history, and working-tree state under .astvcs
- lib · Reusable crate entrypoint for the repository engine
src/lib.rs - store · Main persistence layer for .astvcs state
src/store/mod.rs - repo · Repository initialization and top-level operations
src/store/repo.rs - history · Commit history and revision-oriented operations
src/store/history.rs - staging · Tracks staged changes between working tree and history
src/store/staging.rs - working tree · Working-tree scanning and file state tracking
src/store/working.rs - blobs · Blob storage and content-addressed file data
src/store/blobs.rs - manifest · Manifest and tracked path snapshots
src/store/manifest.rs - graph · Repository graph of nodes, edges, and mutations
src/graph/mod.rs
Content processing
File classification, structural diffing, and merge resolution
- frontend · Chooses structural, text, binary, or symlink representation
src/frontend/mod.rs - tree-sitter · Structural parsing support for parseable file types
src/frontend/treesitter.rs - text blob · Fallback representation for text files
src/frontend/textblob.rs - binary blob · Fallback representation for non-text files
src/frontend/binaryblob.rs - diff · Structural and text comparison pipeline
src/diff/mod.rs - merge · Resolves non-overlapping structural edits and conflicts
src/merge/mod.rs
Sync layer
Remote transport, serving, and synchronization
- network · Remote transport, serving, and synchronization
src/network/mod.rs - sync · Client-side repository synchronization flows
src/network/sync.rs - serve · Server-side repository serving entrypoint
src/network/serve.rs - transport · Abstraction over local, HTTP, HTTPS, and SSH transport
src/network/transport.rs
Connections 27
- main → intent: dispatches · CLI hands parsed commands to orchestration
- intent → store: operates on · High-level commands act on repository state
- intent → diff: requests · User-facing diff and compare commands
- intent → merge: requests · Merge and conflict-oriented commands
- intent → network: requests · Fetch/clone/serve synchronization commands
- lib → store: exports · Library exposes the repository core
- lib → graph: exports · Library exposes history graph structures
- store → repo: includes · Repository lifecycle and top-level state
- store → history: includes · Commit timeline and revision queries
- store → staging: includes · Staging and index state
- store → working tree: includes · Working-tree interaction and scans
- store → blobs: includes · Content-addressed blob storage
- store → manifest: includes · Tracked tree and snapshot state
- store → graph: uses · History-backed operations depend on the DAG model
- working tree → frontend: classifies via · Files are classified before storage or diffing
- frontend → tree-sitter: uses · Parseable files become structural blobs
- frontend → text blob: falls back to · UTF-8 files use text representation
- frontend → binary blob: falls back to · Unparseable non-text files use raw bytes
- diff → graph: compares history · Structural history and rename logic rely on commit graph context
- diff → frontend: compares content · Diff operates on file representations from the frontend
- merge → diff: aligns with · Merge uses diff correspondence for three-way resolution
- merge → store: writes to · Resolved results are persisted back into repository state
- network → transport: abstracts through · Network operations route through transport implementations
- network → sync: includes · Client-side sync flows
- network → serve: includes · Server-side serving flows
- sync → store: syncs · Remote sync reads and updates repository state
- serve → store: serves · Repository data is exposed from local store state