Skip to main content

vtcode_commons/
lib.rs

1//! Shared primitives and helper types reused across VT Code crates.
2//!
3//! This crate provides the foundational building blocks that both the core
4//! agent library (`vtcode-core`) and the terminal UI (`vtcode-ui`) depend on.
5//! Modules include ANSI processing, diff rendering, file traversal, color
6//! policy, error classification, and shared protocol types.
7//!
8//! Items live here (rather than `vtcode-ui`) when they are consumed by
9//! `vtcode-core` or the main binary -- keeping the dependency direction clean.
10//!
11//! See `docs/modules/vtcode_commons_reference.md` for ready-to-use adapters.
12
13pub mod ansi;
14pub mod ansi_capabilities;
15pub mod ansi_codes;
16pub mod async_utils;
17pub mod at_pattern;
18pub mod cgp;
19pub mod color256_theme;
20pub mod color_policy;
21pub mod colors;
22pub mod diff;
23pub mod diff_paths;
24pub mod diff_preview;
25pub mod diff_theme;
26pub mod editor;
27pub mod env_lock;
28pub mod error_category;
29pub mod errors;
30pub mod exclusions;
31pub mod file_input;
32pub mod formatting;
33pub mod fs;
34pub mod http;
35pub mod image;
36pub mod llm;
37pub mod lr_map;
38pub mod model_family;
39pub mod paths;
40pub mod preview;
41pub mod project;
42pub mod provider;
43pub mod reasoning;
44pub mod reference;
45pub mod retry;
46pub mod sanitizer;
47pub mod serde_helpers;
48pub mod slug;
49pub mod stop_hints;
50pub mod styling;
51pub mod telemetry;
52pub mod terminal_detection;
53pub mod thread_safety;
54pub mod tokens;
55pub mod tool_types;
56pub mod trace_flush;
57pub mod ui_protocol;
58pub mod unicode;
59pub mod utils;
60pub mod validation;
61pub mod vtcodegitignore;
62pub mod walk;
63pub use colors::{blend_colors, color_from_hex, contrasting_color, is_light_color, style};
64pub use editor::{
65    EditorPoint, EditorTarget, normalize_editor_hash_fragment, parse_editor_target,
66    resolve_editor_path, resolve_editor_target,
67};
68pub use error_category::{
69    BackoffStrategy, ErrorCategory, Retryability, classify_anyhow_error, classify_error_message,
70    is_retryable_llm_error_message,
71};
72pub use errors::{DisplayErrorFormatter, ErrorFormatter, ErrorReporter, NoopErrorReporter};
73pub use paths::{
74    PathExt, PathResolver, PathScope, StrPathExt, WorkspacePaths, file_name_from_path,
75    is_safe_relative_path, normalize_ascii_identifier, resolve_workspace_path,
76};
77pub use project::{ProjectOverview, build_project_overview};
78pub use reference::{MemoryErrorReporter, MemoryTelemetry, StaticWorkspacePaths};
79pub use stop_hints::{STOP_HINT_COMPACT, STOP_HINT_INLINE, with_stop_hint};
80pub use styling::{ColorPalette, DiffColorPalette, render_styled};
81pub use telemetry::{NoopTelemetry, TelemetrySink};
82pub use tokens::{estimate_tokens, truncate_to_tokens};
83pub use unicode::{UNICODE_MONITOR, UnicodeMonitor, UnicodeValidationContext};
84
85// Re-export key thread safety primitives.
86pub use thread_safety::RelaxedAtomic;