From 2f702ad446fcd6a261a3bea0ab2807d70eca43e2 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Tue, 21 Apr 2026 13:07:27 -0700 Subject: refactor: Replace ad-hoc dispatch with FSM + driver architecture (#3434) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the tangled dispatch handler system (`tui/dispatch.rs`, `tui/state.rs`) with a pure finite state machine + driver architecture. The FSM handles all state transitions as explicit `(State, Event) → (NewState, Effects)` mappings. The driver executes IO effects and bridges the TUI to the FSM. --- crates/atuin-ai/src/context.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'crates/atuin-ai/src/context.rs') diff --git a/crates/atuin-ai/src/context.rs b/crates/atuin-ai/src/context.rs index dabb5c5e..93fcf9b9 100644 --- a/crates/atuin-ai/src/context.rs +++ b/crates/atuin-ai/src/context.rs @@ -19,6 +19,32 @@ pub(crate) struct AppContext { pub capabilities: AiCapabilities, } +impl AppContext { + pub(crate) fn capabilities_as_strings(&self) -> Vec { + let mut caps = vec!["client_invocations".to_string()]; + if self.capabilities.enable_history_search.unwrap_or(true) { + caps.push("client_v1_atuin_history".to_string()); + } + if self.capabilities.enable_file_tools.unwrap_or(true) { + caps.push("client_v1_read_file".to_string()); + caps.push("client_v1_edit_file".to_string()); + caps.push("client_v1_write_file".to_string()); + } + if self.capabilities.enable_command_execution.unwrap_or(true) { + caps.push("client_v1_execute_shell_command".to_string()); + } + if let Ok(extra) = std::env::var("ATUIN_AI__ADDITIONAL_CAPS") { + caps.extend( + extra + .split(',') + .map(|s| s.trim().to_string()) + .filter(|s| !s.is_empty()), + ); + } + caps + } +} + /// Machine identity — computed once per session. #[derive(Clone, Debug)] pub(crate) struct ClientContext { -- cgit v1.3.1