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 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;
54pub mod stop_hints;
55pub mod styling;
56pub mod telemetry;
57pub mod terminal_detection;
58pub mod thread_safety;
59pub mod tokens;
60pub mod tool_types;
61pub mod trace_flush;
62pub mod ui_protocol;
63pub mod unicode;
64pub mod utils;
65pub mod validation;
66pub mod vtcodegitignore;
67pub mod walk;
68pub mod workspace_snapshot;
69pub use colors::{blend_colors, color_from_hex, contrasting_color, is_light_color, style};
70pub use editor::{
71    EditorPoint, EditorTarget, normalize_editor_hash_fragment, parse_editor_target, resolve_editor_path,
72    resolve_editor_target,
73};
74pub use error_category::{
75    BackoffStrategy, ErrorCategory, Retryability, classify_anyhow_error, classify_error_message,
76    is_retryable_llm_error_message,
77};
78pub use errors::{DisplayErrorFormatter, ErrorFormatter, ErrorReporter, MultiErrors, NoopErrorReporter};
79pub use interjection::{
80    EventQueue, FormattedInterjection, InterjectionBuffer, LARGE_PROMPT_THRESHOLD, PendingInterjection,
81    drain_formatted, format_interjection, user_query,
82};
83pub use interner::{StringId, StringInterner};
84pub use paths::{
85    PathExt, PathResolver, PathScope, StrPathExt, WorkspacePaths, canonicalize, canonicalize_async,
86    file_name_from_path, is_safe_relative_path, normalize_ascii_identifier, resolve_workspace_path,
87};
88pub use project::{ProjectOverview, build_project_overview};
89pub use reference::{MemoryErrorReporter, MemoryTelemetry, StaticWorkspacePaths};
90pub use stop_hints::{STOP_HINT_COMPACT, STOP_HINT_INLINE, with_stop_hint};
91pub use styling::{ColorPalette, DiffColorPalette, render_styled};
92pub use telemetry::{NoopTelemetry, TelemetrySink};
93pub use tokens::{estimate_tokens, truncate_to_tokens};
94pub use unicode::{UNICODE_MONITOR, UnicodeMonitor, UnicodeValidationContext};
95
96// Re-export key thread safety primitives.
97pub use thread_safety::RelaxedAtomic;