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 clipboard_5522;
27pub mod color256_theme;
28pub mod color_policy;
29pub mod colors;
30pub mod content_search;
31pub mod diff;
32pub mod diff_paths;
33pub mod diff_preview;
34pub mod diff_theme;
35pub mod editor;
36pub mod env_lock;
37pub mod error_category;
38pub mod errors;
39pub mod exclusions;
40pub mod file_input;
41pub mod formatting;
42pub mod fs;
43pub mod history_scope;
44pub mod http;
45pub mod image;
46pub mod interjection;
47pub mod interner;
48pub mod json_extract;
49pub mod lexical;
50pub mod line_framing;
51pub mod llm;
52pub mod lr_map;
53pub mod mcp_tool_names;
54pub mod memory;
55pub mod message_metadata;
56pub mod message_timestamp;
57pub mod misconfiguration;
58pub mod modal_hints;
59pub mod model_family;
60pub mod paths;
61pub mod preview;
62pub mod program_status;
63pub mod project;
64pub mod prompt_history;
65pub mod provider;
66pub mod reasoning;
67pub mod reference;
68pub mod retry;
69pub mod runtime_diagnostics;
70pub mod sanitizer;
71pub mod search;
72pub mod serde_helpers;
73pub mod slug;
74#[doc(hidden)]
75pub mod startup_trace;
76pub mod stop_hints;
77pub mod styling;
78pub mod task_guard;
79pub mod telemetry;
80pub mod terminal_capabilities;
81pub mod terminal_detection;
82pub mod text_fence;
83pub mod thread_safety;
84pub mod tokens;
85pub mod tool_headlines;
86pub mod tool_intent;
87pub mod tool_types;
88pub mod trace_flush;
89pub mod tracker_title;
90pub mod tty;
91pub mod ui_protocol;
92pub mod unicode;
93pub mod utf8_stream;
94pub mod utils;
95pub mod validation;
96pub mod vtcode_paths;
97pub mod vtcodegitignore;
98pub mod walk;
99pub mod workspace_snapshot;
100pub use colors::{blend_colors, color_from_hex, contrasting_color, is_light_color, style};
101pub use editor::{
102    EditorPoint, EditorTarget, normalize_editor_hash_fragment, parse_editor_target, resolve_editor_path,
103    resolve_editor_target,
104};
105pub use error_category::{
106    BackoffStrategy, ErrorCategory, Retryability, classify_anyhow_error, classify_error_message,
107    is_context_capacity_error, is_context_capacity_message, is_retryable_llm_error_message,
108};
109pub use errors::{DisplayErrorFormatter, ErrorFormatter, ErrorReporter, MultiErrors, NoopErrorReporter};
110pub(crate) use interjection::{
111    EventQueue, FormattedInterjection, InterjectionBuffer, LARGE_PROMPT_THRESHOLD, PendingInterjection,
112    drain_formatted, format_interjection, user_query,
113};
114pub use interner::{StringId, StringInterner};
115pub use misconfiguration::{
116    ConfigGuidance, MisconfigurationKind, detect_misconfiguration, detect_misconfiguration_in_anyhow,
117    detect_misconfiguration_in_llm_error, is_misconfiguration,
118};
119pub use modal_hints::{
120    APPROVAL_NAVIGATE_CANCEL, APPROVAL_NAVIGATE_DENY, APPROVAL_NAVIGATE_STOP, choose_handling_line, truncate_modal_text,
121};
122pub use paths::{
123    PathExt, PathResolver, PathScope, StrPathExt, WorkspacePathDisplay, WorkspacePaths, canonicalize,
124    canonicalize_async, file_name_from_path, is_safe_relative_path, normalize_ascii_identifier, resolve_workspace_path,
125    safe_archive_relative_path, validate_no_escaping_symlink_ancestors, workspace_relative_display,
126    workspace_relative_slash,
127};
128pub use project::{ProjectOverview, build_project_overview};
129pub use reference::{MemoryErrorReporter, MemoryTelemetry, StaticWorkspacePaths};
130pub use stop_hints::{STOP_HINT_COMPACT, STOP_HINT_INLINE, with_stop_hint};
131pub use styling::{ColorPalette, DiffColorPalette, render_styled};
132pub use task_guard::TaskGuard;
133pub use telemetry::{NoopTelemetry, TelemetrySink};
134pub use tokens::{
135    CHARS_PER_TOKEN, estimate_tokens, format_token_count, heuristic_tokens_from_byte_len,
136    heuristic_tokens_from_byte_len_u64, truncate_to_tokens,
137};
138pub use unicode::{UNICODE_MONITOR, UnicodeMonitor, UnicodeValidationContext};
139pub use utf8_stream::Utf8StreamDecoder;
140pub use validation::{EmptyCollectionError, NonEmptySlice, NonEmptyString, NonEmptyVec};
141pub use vtcode_paths::{
142    MigrationEntry, MigrationFailure, MigrationReport, MigrationSkip, MigrationSkipReason, VtCodePaths,
143};
144
145// Re-export key thread safety primitives.
146pub(crate) use thread_safety::RelaxedAtomic;
147
148/// Canonical runtime diagnostic sanitization.
149pub mod diagnostics;