Skip to main content

vtcode_commons/
lib.rs

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