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