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