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