Skip to main content

vtcode_bash_runner/
lib.rs

1#![allow(
2    missing_docs,
3    dead_code,
4    unused_imports,
5    reason = "Intentional compatibility, platform, or test-only suppression."
6)]
7#![expect(
8    unused_results,
9    clippy::let_underscore_must_use,
10    clippy::indexing_slicing,
11    reason = "Process wrappers intentionally detach best-effort tasks, use OS process IDs, and configure commands through bounded builder APIs."
12)]
13#![cfg_attr(
14    unix,
15    expect(
16        clippy::cast_possible_wrap,
17        reason = "Process wrappers intentionally detach best-effort tasks, use OS process IDs, and configure commands through bounded builder APIs."
18    )
19)]
20//! Cross-platform command runner modeled after VT Code's original bash
21//! wrapper. The crate exposes a trait-based executor so downstream
22//! applications can swap the underlying process strategy (system shell,
23//! pure-Rust emulation, or dry-run logging) while reusing the higher-level
24//! helpers for workspace-safe filesystem manipulation.
25//!
26//! ## Modules
27//!
28//! - [`executor`] - Command execution strategies (process, dry-run, pure-rust)
29//! - [`runner`] - High-level `BashRunner` for workspace-safe operations
30//! - [`background`] - Background task management
31//! - [`pipe`] - Async pipe-based process spawning with unified handles
32//! - [`process`] - Process handle types for PTY and pipe backends
33//! - [`process_group`] - Process group management for reliable cleanup
34//! - [`stream`] - Stream utilities for reading output
35
36pub mod background;
37pub mod executor;
38pub mod pipe;
39pub mod policy;
40pub mod process;
41pub mod process_group;
42pub mod runner;
43pub mod stream;
44
45// Background task management
46pub use background::{BackgroundCommandManager, BackgroundTaskHandle, BackgroundTaskStatus};
47
48// Executor variants
49#[cfg(feature = "dry-run")]
50pub use executor::DryRunCommandExecutor;
51#[cfg(feature = "exec-events")]
52pub use executor::EventfulExecutor;
53#[cfg(feature = "std-process")]
54pub use executor::ProcessCommandExecutor;
55#[cfg(feature = "pure-rust")]
56pub use executor::PureRustCommandExecutor;
57pub use executor::{CommandCategory, CommandExecutor, CommandInvocation, CommandOutput, CommandStatus, ShellKind};
58
59// Policy types
60pub use policy::{AllowAllPolicy, CommandPolicy, WorkspaceGuardPolicy};
61
62// Runner
63pub use runner::BashRunner;
64
65// Stream utilities
66pub(crate) use stream::{ReadLineResult, read_line_with_limit};
67
68// Pipe-based process spawning (codex-rs compatible)
69pub use pipe::{
70    PipeSpawnOptions, PipeStdinMode, spawn_process as spawn_pipe_process,
71    spawn_process_no_stdin as spawn_pipe_process_no_stdin,
72    spawn_process_with_options as spawn_pipe_process_with_options,
73};
74
75// Process handle types (unified interface for PTY and pipe)
76pub use process::{
77    ChildTerminator, ExecCommandSession, ProcessHandle, PtyHandle, PtyHandles, SpawnedProcess, SpawnedPty,
78    collect_output_until_exit,
79};
80
81// Process group utilities
82pub use process_group::{
83    DEFAULT_GRACEFUL_TIMEOUT_MS, GracefulTerminationResult, KillSignal, detach_from_tty, graceful_kill_process_group,
84    graceful_kill_process_group_default, graceful_kill_process_group_default_async, kill_child_process_group,
85    kill_child_process_group_with_signal, kill_process_group, kill_process_group_by_pid,
86    kill_process_group_by_pid_with_signal, kill_process_group_with_signal, set_parent_death_signal, set_process_group,
87};
88
89#[cfg(windows)]
90pub use process_group::kill_process;