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