Skip to main content

vtcode_commons/
lib.rs

1#![allow(missing_docs, clippy::expect_used)]
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 memory;
40pub mod message_metadata;
41pub mod model_family;
42pub mod paths;
43pub mod preview;
44pub mod project;
45pub mod provider;
46pub mod reasoning;
47pub mod reference;
48pub mod retry;
49pub mod sanitizer;
50pub mod serde_helpers;
51pub mod slug;
52pub mod stop_hints;
53pub mod styling;
54pub mod telemetry;
55pub mod terminal_detection;
56pub mod thread_safety;
57pub mod tokens;
58pub mod tool_types;
59pub mod trace_flush;
60pub mod ui_protocol;
61pub mod unicode;
62pub mod utils;
63pub mod validation;
64pub mod vtcodegitignore;
65pub mod walk;
66pub use colors::{blend_colors, color_from_hex, contrasting_color, is_light_color, style};
67pub use editor::{
68    EditorPoint, EditorTarget, normalize_editor_hash_fragment, parse_editor_target,
69    resolve_editor_path, resolve_editor_target,
70};
71pub use error_category::{
72    BackoffStrategy, ErrorCategory, Retryability, classify_anyhow_error, classify_error_message,
73    is_retryable_llm_error_message,
74};
75pub use errors::{
76    DisplayErrorFormatter, ErrorFormatter, ErrorReporter, MultiErrors, NoopErrorReporter,
77};
78pub use paths::{
79    PathExt, PathResolver, PathScope, StrPathExt, WorkspacePaths, file_name_from_path,
80    is_safe_relative_path, normalize_ascii_identifier, resolve_workspace_path,
81};
82pub use project::{ProjectOverview, build_project_overview};
83pub use reference::{MemoryErrorReporter, MemoryTelemetry, StaticWorkspacePaths};
84pub use stop_hints::{STOP_HINT_COMPACT, STOP_HINT_INLINE, with_stop_hint};
85pub use styling::{ColorPalette, DiffColorPalette, render_styled};
86pub use telemetry::{NoopTelemetry, TelemetrySink};
87pub use tokens::{estimate_tokens, truncate_to_tokens};
88pub use unicode::{UNICODE_MONITOR, UnicodeMonitor, UnicodeValidationContext};
89
90// Re-export key thread safety primitives.
91pub use thread_safety::RelaxedAtomic;