Skip to main content

vtcode_commons/
lib.rs

1#![allow(
2    missing_docs,
3    clippy::expect_used,
4    dead_code,
5    unused_imports,
6    reason = "Intentional compatibility, platform, or test-only suppression."
7)]
8//! Shared primitives and helper types reused across VT Code crates.
9//!
10//! This crate provides the foundational building blocks that both the core
11//! agent library (`vtcode-core`) and the terminal UI (`vtcode-ui`) depend on.
12//! Modules include ANSI processing, diff rendering, file traversal, color
13//! policy, error classification, and shared protocol types.
14//!
15//! Items live here (rather than `vtcode-ui`) when they are consumed by
16//! `vtcode-core` or the main binary -- keeping the dependency direction clean.
17//!
18//! See `docs/modules/vtcode_commons_reference.md` for ready-to-use adapters.
19
20pub mod ansi;
21pub mod ansi_capabilities;
22pub mod ansi_codes;
23pub mod async_utils;
24pub mod at_pattern;
25pub mod cgp;
26pub mod color256_theme;
27pub mod color_policy;
28pub mod colors;
29pub mod diff;
30pub mod diff_paths;
31pub mod diff_preview;
32pub mod diff_theme;
33pub mod editor;
34pub mod env_lock;
35pub mod error_category;
36pub mod errors;
37pub mod exclusions;
38pub mod file_input;
39pub mod formatting;
40pub mod fs;
41pub mod http;
42pub mod image;
43pub mod interjection;
44pub mod interner;
45pub mod llm;
46pub mod lr_map;
47pub mod memory;
48pub mod message_metadata;
49pub mod misconfiguration;
50pub mod modal_hints;
51pub mod model_family;
52pub mod paths;
53pub mod preview;
54pub mod project;
55pub mod provider;
56pub mod reasoning;
57pub mod reference;
58pub mod retry;
59pub mod sanitizer;
60pub mod serde_helpers;
61pub mod slug;
62#[doc(hidden)]
63pub mod startup_trace;
64pub mod stop_hints;
65pub mod styling;
66pub mod task_guard;
67pub mod telemetry;
68pub mod terminal_detection;
69pub mod thread_safety;
70pub mod tokens;
71pub mod tool_types;
72pub mod trace_flush;
73pub mod ui_protocol;
74pub mod unicode;
75pub mod utils;
76pub mod validation;
77pub mod vtcode_paths;
78pub mod vtcodegitignore;
79pub mod walk;
80pub mod workspace_snapshot;
81pub use colors::{blend_colors, color_from_hex, contrasting_color, is_light_color, style};
82pub use editor::{
83    EditorPoint, EditorTarget, normalize_editor_hash_fragment, parse_editor_target, resolve_editor_path,
84    resolve_editor_target,
85};
86pub use error_category::{
87    BackoffStrategy, ErrorCategory, Retryability, classify_anyhow_error, classify_error_message,
88    is_context_capacity_error, is_context_capacity_message, is_retryable_llm_error_message,
89};
90pub use errors::{DisplayErrorFormatter, ErrorFormatter, ErrorReporter, MultiErrors, NoopErrorReporter};
91pub(crate) use interjection::{
92    EventQueue, FormattedInterjection, InterjectionBuffer, LARGE_PROMPT_THRESHOLD, PendingInterjection,
93    drain_formatted, format_interjection, user_query,
94};
95pub use interner::{StringId, StringInterner};
96pub use misconfiguration::{
97    ConfigGuidance, MisconfigurationKind, detect_misconfiguration, detect_misconfiguration_in_anyhow,
98    detect_misconfiguration_in_llm_error, is_misconfiguration,
99};
100pub use modal_hints::{
101    APPROVAL_NAVIGATE_CANCEL, APPROVAL_NAVIGATE_DENY, APPROVAL_NAVIGATE_STOP, choose_handling_line, truncate_modal_text,
102};
103pub use paths::{
104    PathExt, PathResolver, PathScope, StrPathExt, WorkspacePaths, canonicalize, canonicalize_async,
105    file_name_from_path, is_safe_relative_path, normalize_ascii_identifier, resolve_workspace_path,
106    workspace_relative_display,
107};
108pub use project::{ProjectOverview, build_project_overview};
109pub use reference::{MemoryErrorReporter, MemoryTelemetry, StaticWorkspacePaths};
110pub use stop_hints::{STOP_HINT_COMPACT, STOP_HINT_INLINE, with_stop_hint};
111pub use styling::{ColorPalette, DiffColorPalette, render_styled};
112pub use task_guard::TaskGuard;
113pub use telemetry::{NoopTelemetry, TelemetrySink};
114pub use tokens::{estimate_tokens, truncate_to_tokens};
115pub use unicode::{UNICODE_MONITOR, UnicodeMonitor, UnicodeValidationContext};
116pub use vtcode_paths::{
117    MigrationEntry, MigrationFailure, MigrationReport, MigrationSkip, MigrationSkipReason, VtCodePaths,
118};
119
120// Re-export key thread safety primitives.
121pub(crate) use thread_safety::RelaxedAtomic;