Skip to main content

Crate vtcode_commons

Crate vtcode_commons 

Source
Expand description

Shared primitives and helper types reused across VT Code crates.

This crate provides the foundational building blocks that both the core agent library (vtcode-core) and the terminal UI (vtcode-ui) depend on. Modules include ANSI processing, diff rendering, file traversal, color policy, error classification, and shared protocol types.

Items live here (rather than vtcode-ui) when they are consumed by vtcode-core or the main binary – keeping the dependency direction clean.

See docs/modules/vtcode_commons_reference.md for ready-to-use adapters.

Re-exports§

pub use colors::blend_colors;
pub use colors::color_from_hex;
pub use colors::contrasting_color;
pub use colors::is_light_color;
pub use colors::style;
pub use editor::EditorPoint;
pub use editor::EditorTarget;
pub use editor::normalize_editor_hash_fragment;
pub use editor::parse_editor_target;
pub use editor::resolve_editor_path;
pub use editor::resolve_editor_target;
pub use error_category::BackoffStrategy;
pub use error_category::ErrorCategory;
pub use error_category::Retryability;
pub use error_category::classify_anyhow_error;
pub use error_category::classify_error_message;
pub use error_category::is_retryable_llm_error_message;
pub use errors::DisplayErrorFormatter;
pub use errors::ErrorFormatter;
pub use errors::ErrorReporter;
pub use errors::NoopErrorReporter;
pub use paths::PathExt;
pub use paths::PathResolver;
pub use paths::PathScope;
pub use paths::StrPathExt;
pub use paths::WorkspacePaths;
pub use paths::file_name_from_path;
pub use paths::is_safe_relative_path;
pub use paths::normalize_ascii_identifier;
pub use paths::resolve_workspace_path;
pub use project::ProjectOverview;
pub use project::build_project_overview;
pub use reference::MemoryErrorReporter;
pub use reference::MemoryTelemetry;
pub use reference::StaticWorkspacePaths;
pub use stop_hints::STOP_HINT_COMPACT;
pub use stop_hints::STOP_HINT_INLINE;
pub use stop_hints::with_stop_hint;
pub use styling::ColorPalette;
pub use styling::DiffColorPalette;
pub use styling::render_styled;
pub use telemetry::NoopTelemetry;
pub use telemetry::TelemetrySink;
pub use tokens::estimate_tokens;
pub use tokens::truncate_to_tokens;
pub use unicode::UNICODE_MONITOR;
pub use unicode::UnicodeMonitor;
pub use unicode::UnicodeValidationContext;
pub use thread_safety::RelaxedAtomic;

Modules§

ansi
Shared ANSI escape parser and stripping utilities for VT Code.
ansi_capabilities
ANSI terminal capabilities detection and feature support
ansi_codes
Shared ANSI escape sequence constants and small builders for VT Code.
async_utils
Async utility functions
at_pattern
Utilities for parsing @ symbol patterns in user input
cgp
Context-Generic Programming (CGP) core wiring trait.
color256_theme
Theme-aware 256-color helpers.
color_policy
Runtime color output policy helpers.
colors
Color utilities for VT Code
diff
Diff utilities for generating structured diffs.
diff_paths
diff_preview
Shared helpers for rendering diff previews.
diff_theme
Diff theme configuration and color palettes
editor
env_lock
Process-environment mutation lock.
error_category
Unified error categorization system for consistent error classification across VT Code.
errors
exclusions
Centralized exclusion constants and helpers for file traversal.
file_input
File input helpers for provider-specific inline file attachments.
formatting
Unified formatting utilities for UI and logging
fs
File utility functions for common operations
http
HTTP client utilities
image
Image processing utilities
llm
Core LLM types shared across the project
lr_map
Lock-free concurrent map built on left_right.
model_family
Model family definitions and capability groupings.
paths
preview
Shared preview formatting helpers.
project
Project-related utilities and structures
provider
Provider enum and core definitions shared across VT Code crates.
reasoning
Reasoning effort level definitions shared across VT Code crates.
reference
retry
Minimal shared retry policy for wire-level HTTP clients.
sanitizer
Secret sanitization utilities for redacting sensitive information.
serde_helpers
Serde helper utilities
slug
Human-readable slug generator for plan file names
stop_hints
styling
Unified message styles and their logical mappings
telemetry
terminal_detection
Terminal detection primitives shared across VT Code crates.
thread_safety
Thread Safety Primitives
tokens
Token estimation utilities
tool_types
Shared runtime types for the VT Code tool system.
trace_flush
Global trace log flush hook.
ui_protocol
Shared UI protocol types used across VT Code crates.
unicode
Unicode monitoring and validation utilities
utils
Generic utility functions
validation
Validation utilities for common operations
vtcodegitignore
.vtcodegitignore file pattern matching utilities
walk
Shared directory walker helpers built on the ignore crate.

Macros§

ctx_err
Helper macro for context errors Usage: ctx_err!(operation, context) -> “operation context”
delegate_components
Wire multiple component names to provider types for a context.
file_err
Helper macro for file operation errors with context Usage: file_err!(“path”, “read”) -> “failed to read path”
model_family
Macro to simplify model family definitions