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