Skip to main content

vtcode_commons/
lib.rs

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