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