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 modal_hints;
50pub mod model_family;
51pub mod paths;
52pub mod preview;
53pub mod project;
54pub mod provider;
55pub mod reasoning;
56pub mod reference;
57pub mod retry;
58pub mod sanitizer;
59pub mod serde_helpers;
60pub mod slug;
61#[doc(hidden)]
62pub mod startup_trace;
63pub mod stop_hints;
64pub mod styling;
65pub mod task_guard;
66pub mod telemetry;
67pub mod terminal_detection;
68pub mod thread_safety;
69pub mod tokens;
70pub mod tool_types;
71pub mod trace_flush;
72pub mod ui_protocol;
73pub mod unicode;
74pub mod utils;
75pub mod validation;
76pub mod vtcode_paths;
77pub mod vtcodegitignore;
78pub mod walk;
79pub mod workspace_snapshot;
80pub use colors::{blend_colors, color_from_hex, contrasting_color, is_light_color, style};
81pub use editor::{
82    EditorPoint, EditorTarget, normalize_editor_hash_fragment, parse_editor_target, resolve_editor_path,
83    resolve_editor_target,
84};
85pub use error_category::{
86    BackoffStrategy, ErrorCategory, Retryability, classify_anyhow_error, classify_error_message,
87    is_context_capacity_error, is_context_capacity_message, is_retryable_llm_error_message,
88};
89pub use errors::{DisplayErrorFormatter, ErrorFormatter, ErrorReporter, MultiErrors, NoopErrorReporter};
90pub(crate) use interjection::{
91    EventQueue, FormattedInterjection, InterjectionBuffer, LARGE_PROMPT_THRESHOLD, PendingInterjection,
92    drain_formatted, format_interjection, user_query,
93};
94pub use interner::{StringId, StringInterner};
95pub use modal_hints::{
96    APPROVAL_NAVIGATE_CANCEL, APPROVAL_NAVIGATE_DENY, APPROVAL_NAVIGATE_STOP, choose_handling_line, truncate_modal_text,
97};
98pub use paths::{
99    PathExt, PathResolver, PathScope, StrPathExt, WorkspacePaths, canonicalize, canonicalize_async,
100    file_name_from_path, is_safe_relative_path, normalize_ascii_identifier, resolve_workspace_path,
101    workspace_relative_display,
102};
103pub use project::{ProjectOverview, build_project_overview};
104pub use reference::{MemoryErrorReporter, MemoryTelemetry, StaticWorkspacePaths};
105pub use stop_hints::{STOP_HINT_COMPACT, STOP_HINT_INLINE, with_stop_hint};
106pub use styling::{ColorPalette, DiffColorPalette, render_styled};
107pub use task_guard::TaskGuard;
108pub use telemetry::{NoopTelemetry, TelemetrySink};
109pub use tokens::{estimate_tokens, truncate_to_tokens};
110pub use unicode::{UNICODE_MONITOR, UnicodeMonitor, UnicodeValidationContext};
111pub use vtcode_paths::{
112    MigrationEntry, MigrationFailure, MigrationReport, MigrationSkip, MigrationSkipReason, VtCodePaths,
113};
114
115// Re-export key thread safety primitives.
116pub(crate) use thread_safety::RelaxedAtomic;