vct-core 2.4.1

Vibe Coding Tracker core library - parse local AI coding assistant session data into CodeAnalysis results
Documentation
//! Library crate behind the `vibe_coding_tracker` / `vct` CLI.
//!
//! The crate scans on-disk session logs written by eight AI coding assistants:
//! JSONL logs from Claude Code, OpenAI Codex, GitHub Copilot CLI, and Gemini
//! CLI; `signals.json` plus sibling `updates.jsonl` from Grok CLI; SQLite data
//! from OpenCode and Cursor; and usage-only SQLite data from Hermes. It exposes
//! two views:
//!
//! - **usage** — per-model token counts and LiteLLM-priced cost
//! - **analysis** — complete per-session data plus compact per-model
//!   file-operation and tool-call metrics
//!
//! # Pipeline
//!
//! Raw bytes flow through a two-stage pipeline. [`session`] owns the
//! "local session data → typed [`CodeAnalysis`]" boundary (provider detection plus a
//! parser per provider); [`analysis`] and [`usage`] then aggregate those
//! typed records. The `vct-tui` crate renders the result as an interactive
//! TUI, a static table, plain text, or JSON, and the `vct-cli` binary wires
//! the clap surface to both. Both downstream views consume the same parsed
//! shape, so file parsing lives only in [`session`]. This crate holds no
//! terminal dependency, so a future GUI backend can reuse it directly.
//!
//! Supporting modules: [`pricing`] (LiteLLM price lookup with a daily
//! on-disk cache), [`cache`] (LRU file cache keyed by mtime), [`update`]
//! (self-replace from the matching GitHub release asset), [`utils`]
//! (path resolution and the glibc allocator tuning), and [`constants`]
//! (capacity and buffer sizing).

pub mod analysis;
pub mod cache;
pub mod config;
pub mod constants;
pub mod logging;
pub mod models;
pub mod pricing;
pub mod quota;
pub mod scan;
pub mod session;
pub mod summary_cache;
pub mod update;
pub mod usage;
pub mod utils;

pub use models::*;
pub use session::parser::{parse_session_file_to_value, parse_session_file_typed};
pub use usage::aggregator::{UsageData, aggregate_usage_from_home, aggregate_usage_from_paths};
// Curated surface for non-CLI consumers (e.g. a future GUI backend): the
// serializable priced-usage payload, the compact analysis summary, and the
// shared scan diagnostics.
pub use analysis::{AnalysisData, project_code_analysis};
pub use scan::{ScanDiagnostics, ScanFailure};
pub use usage::{PricedUsageRow, price_usage_data};

/// Full build version: latest git tag plus commits-since and short SHA
/// (with a `-dirty` suffix when the worktree is modified), generated by
/// `build.rs`. Falls back to the `Cargo.toml` version outside a git tree.
pub const VERSION: &str = env!("BUILD_VERSION");
/// Crate name from `Cargo.toml` (`vct-core`).
pub const PKG_NAME: &str = env!("CARGO_PKG_NAME");
/// Crate description from `Cargo.toml`.
pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION");
/// `rustc` version string captured at build time by `build.rs`.
pub const RUST_VERSION: &str = env!("BUILD_RUST_VERSION");
/// `cargo` version string captured at build time by `build.rs`.
pub const CARGO_VERSION: &str = env!("BUILD_CARGO_VERSION");

/// Snapshots the build version, Rust toolchain, and Cargo version into a
/// [`VersionInfo`].
///
/// Reads the compile-time [`VERSION`], [`RUST_VERSION`], and
/// [`CARGO_VERSION`] constants; this is what backs the `vct version`
/// subcommand.
///
/// # Examples
///
/// ```
/// let info = vct_core::get_version_info();
/// assert_eq!(info.version, vct_core::VERSION);
/// ```
pub fn get_version_info() -> VersionInfo {
    VersionInfo {
        version: VERSION.to_string(),
        rust_version: RUST_VERSION.to_string(),
        cargo_version: CARGO_VERSION.to_string(),
    }
}

/// Build metadata reported by the `vct version` subcommand.
///
/// Construct via [`get_version_info`]; the fields mirror the [`VERSION`],
/// [`RUST_VERSION`], and [`CARGO_VERSION`] constants. Serializes to JSON
/// for the `--json` output mode.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct VersionInfo {
    /// Full build version (see [`VERSION`]).
    pub version: String,
    /// `rustc` version the binary was built with.
    pub rust_version: String,
    /// `cargo` version the binary was built with.
    pub cargo_version: String,
}