feat(tui): introduce comprehensive state management for TUI interface

- Add AppStateRest as the central state struct for managing TUI state.
- Implement InputState for handling user input, autocomplete, and history.
- Create MiscState to manage overlays, notifications, and editor state.
- Introduce ScrollState for viewport scrolling functionality.
- Develop TranscriptCache for efficient message rendering in the chat pane.
- Implement SimpleAgent and SimpleWorkflowEngine for agent lifecycle management.
- Add helper functions for managing effort levels and token counting.
- Organize state-related modules for better maintainability and clarity.
This commit is contained in:
asepharyana
2026-07-21 06:42:53 +07:00
parent 802346f909
commit 8c58faf292
25 changed files with 2594 additions and 2158 deletions
+70
View File
@@ -0,0 +1,70 @@
//! Tool registry: the master list of all built-in tools, plus conversion
//! utilities for generating provider-facing tool definitions.
/// Construct one instance of every built-in tool.
pub fn all_tools() -> Vec<Box<dyn super::Tool>> {
vec![
Box::new(super::fs::read::Read),
Box::new(super::fs::write::Write),
Box::new(super::fs::edit::Edit),
Box::new(super::fs::delete::Delete),
Box::new(super::search::Grep),
Box::new(super::search::Glob),
Box::new(super::bash_tools::BashOutput),
Box::new(super::bash_tools::BashKill),
Box::new(super::shell::Bash),
Box::new(super::git::git_operator::GitOperator),
Box::new(super::git::git_worktree::GitWorktree),
Box::new(super::git::git_cred::GitCred),
Box::new(super::sequential_think::SeqThink),
Box::new(super::plan::PlanEnter),
Box::new(super::plan::PlanReady),
Box::new(super::workflow::WorkflowRun),
Box::new(super::workflow::NoteFinding),
Box::new(super::workflow::ReadFindings),
Box::new(super::workflow::HiveMind),
Box::new(super::spawn::SpawnAgents),
Box::new(super::spawn::SpawnPipeline),
Box::new(super::memory::remember::Remember),
Box::new(super::memory::forget::Forget),
Box::new(super::memory::recall::Recall),
Box::new(super::utility::cd::Cd),
Box::new(super::utility::dir_list::DirList),
Box::new(super::utility::dir_cache_update::DirCacheUpdate),
Box::new(super::utility::pong::Pong),
Box::new(super::utility::todowrite::Todowrite),
Box::new(super::utility::todofinish::Todofinish),
Box::new(super::lsp::LspConnect),
Box::new(super::lsp::LspDiagnostics),
Box::new(super::lsp::LspHover),
Box::new(super::lsp::LspCompletion),
Box::new(super::lsp::LspDefinition),
Box::new(super::lsp::LspReferences),
Box::new(super::lsp::LspDisconnect),
Box::new(super::web_search::WebSearch),
Box::new(super::semantic_search::SemanticSearch),
Box::new(super::semantic_search::RebuildIndex),
Box::new(super::parallel_delegate::ParallelDelegate),
]
}
/// Whether a tool by name can mutate the filesystem or run arbitrary shell
/// commands.
pub fn tool_is_risky(name: &str) -> bool {
matches!(name, "write" | "delete" | "edit" | "bash" | "git_operator")
}
/// Convert a list of tools into provider-facing `ToolDef` request schema.
pub fn tool_defs(tools: &[Box<dyn super::Tool>]) -> Vec<zesdex_domain::core::ToolDef> {
tools
.iter()
.map(|t| zesdex_domain::core::ToolDef {
type_: "function".to_string(),
function: zesdex_domain::core::ToolFunctionDef {
name: t.name().to_string(),
description: t.description().to_string(),
parameters: t.parameters(),
},
})
.collect()
}