Mountain/Command/mod.rs
1//! # Command Module
2//!
3//! Defines and registers all native (Rust-implemented) commands for the
4//! Mountain application. Commands are organized by functionality and registered
5//! at startup via the `Bootstrap` module.
6//!
7//! ## RESPONSIBILITIES
8//!
9//! - **Command Registration**: Register all Tauri command handlers with the
10//! invoke_handler
11//! - **Module Organization**: Group commands by domain (LanguageFeature, SCM,
12//! etc.)
13//! - **Handler Coordination**: Delegate command execution to appropriate
14//! providers
15//! - **Error Propagation**: Convert provider errors to Tauri-compatible strings
16//!
17//! ## MODULE STRUCTURE
18//!
19//! - `Bootstrap`: Registers all native commands and providers at startup
20//! - `LanguageFeature`: Handles LSP-related commands (hover, completion, etc.)
21//! - `TreeView`: Manages tree view UI commands
22//! - `Keybinding`: Handles keybinding-related commands
23//! - `SourceControlManagement`: SCM (git) command implementations
24//!
25//! ## ARCHITECTURAL ROLE
26//!
27//! The Command module is the **UI-to-Backend bridge**:
28//! ```text
29//! Sky Frontend ──► Tauri invoke ──► Command Handler ──► Effect System ──► Providers
30//! ```
31//!
32//! ### Design Patterns:
33//! 1. **Command Pattern**: Each handler encapsulates a request
34//! 2. **Facade Pattern**: Simple interface to complex backend operations
35//! 3. **Error Translation**: Convert CommonError → String for Tauri
36//!
37//! ### VS Code Reference:
38//! - `vs/workbench/services/commands/common/commandService.ts` - Command
39//! registry
40//! - `vs/platform/commands/common/commands.ts` - Command definitions
41//! - `vs/base/parts/ipc/common/ipc.ts` - IPC-based command execution
42//!
43//! ## COMMAND FLOW
44//!
45//! 1. **Registration**: All command handlers registered in Binary::Main via
46//! `tauri::generate_handler![]`
47//! 2. **Invocation**: Frontend calls `app.invoke("command_name", args)`
48//! 3. **Dispatch**: `DispatchLogic::DispatchFrontendCommand` routes to effect
49//! 4. **Execution**: Effect runs via `ApplicationRunTime` with proper
50//! capabilities
51//! 5. **Response**: Result serialized and returned to frontend
52//!
53//! ## ERROR HANDLING
54//!
55//! - All errors returned as `Result<T, String>` for Tauri compatibility
56//! - Errors are logged with context before being returned
57//! - Frontend receives descriptive error messages for user display
58//!
59//! ## PERFORMANCE
60//!
61//! - Commands are async to avoid blocking the UI thread
62//! - Minimal serialization overhead (direct JSON)
63//! - Effect system provides async execution with scheduler
64//!
65//! ## TODO
66//!
67//! - [ ] Add command metrics (invocation count, duration)
68//! - [ ] Implement command throttling for high-frequency operations
69//! - [ ] Add command permission validation
70//! - [ ] Support command cancellation for long-running operations
71//!
72//! ## MODULE CONTENTS
73//!
74//! - [`Bootstrap`]: Command registration entry point
75//! - [`LanguageFeature`]: LSP hover/completion/definition commands
76//! - [`TreeView`]: Tree view manipulation commands
77//! - [`Keybinding`]: Keybinding resolution commands
78//! - [`SourceControlManagement`]: Git/SCM commands
79
80pub mod Bootstrap;
81pub mod Keybinding;
82pub mod LanguageFeature;
83pub mod SourceControlManagement;
84pub mod TreeView;