Skip to main content

Mountain/
Library.rs

1#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
2#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
3
4//! # Mountain: Native Backend for Code Editor Land
5//!
6//! Mountain replaces Electron with Rust and Tauri. It manages windows, file
7//! systems, processes, and extensions at native speed. Where Electron takes
8//! milliseconds, Mountain responds in microseconds.
9//!
10//! ## What Mountain Does
11//!
12//! - **Hosts the editor UI** via Tauri webview (no Chromium process overhead)
13//! - **Runs VS Code extensions** by managing the Cocoon sidecar over gRPC
14//! - **Handles file I/O** through native async Rust (tokio), not Node.js `fs`
15//! - **Manages terminals** via native PTY (`portable-pty`), not shell wrappers
16//! - **Stores secrets** in the OS keychain (`keyring` crate), not plaintext
17//!
18//! ## Architecture
19//!
20//! Mountain uses a declarative effect system defined in `Common`. Business
21//! logic is expressed as `ActionEffect`s executed by the `ApplicationRunTime`.
22//! All state lives in a single thread-safe `ApplicationState` managed by Tauri.
23//!
24//! ```text
25//! Wind/Sky (UI) ──Tauri commands──> Mountain ──gRPC──> Cocoon (extensions)
26//!                                      │
27//!                                      ├── Environment providers (file, process, terminal)
28//!                                      ├── ApplicationRunTime (effect executor)
29//!                                      └── ApplicationState (shared state)
30//! ```
31//!
32//! ## Module Layout
33//!
34//! ### Core Infrastructure
35//! - [`ApplicationState`]: Centralized, thread-safe state for the entire app
36//! - [`Environment`]: Capability providers (file system, processes, extensions)
37//! - [`RunTime`]: Effect execution engine that runs `ActionEffect` pipelines
38//!
39//! ### Communication
40//! - [`IPC`]: Inter-process communication primitives
41//! - [`Air`]: Client for the background daemon (updates, crypto signing)
42//! - [`Vine`]: gRPC server/client for Cocoon extension host communication
43//! - [`RPC`]: Remote procedure call service implementations
44//!
45//! ### Services
46//! - [`ProcessManagement`]: Sidecar process lifecycle (launch, monitor,
47//!   restart)
48//! - [`FileSystem`]: Native TreeView provider for the File Explorer
49//! - [`ExtensionManagement`]: Extension discovery, scanning, and activation
50//!
51//! ### Commands
52//! - [`Command`]: Native command handlers (file, edit, view, terminal)
53//! - [`Track`]: Central command dispatcher routing UI requests to providers
54//! - [`Workspace`]: `.code-workspace` file parsing and multi-root support
55//!
56//! ## Related Crates
57//!
58//! | Crate | Role |
59//! |---|---|
60//! | `Common` | Abstract traits and DTOs that Mountain implements |
61//! | `Echo` | Work-stealing task scheduler used by Mountain's runtime |
62//! | `Air` | Background daemon that Mountain communicates with |
63//!
64//! ## Getting Started
65//!
66//! Mountain builds as part of the Land monorepo:
67//! ```bash
68//! cargo build -p Mountain
69//! ```
70//!
71//! Full setup: <https://github.com/CodeEditorLand/Land>
72
73// Core Infrastructure
74/// Centralized error handling system
75pub mod Error;
76
77pub mod ApplicationState;
78
79pub mod Environment;
80
81pub mod RunTime;
82
83// Communication
84pub mod IPC;
85
86pub mod Air;
87
88pub mod Vine;
89
90pub mod RPC;
91
92// Services
93pub mod ProcessManagement;
94
95pub mod FileSystem;
96
97pub mod ExtensionManagement;
98
99// Commands
100pub mod Command;
101
102pub mod Track;
103
104pub mod Workspace;
105
106// Entry Point
107pub mod Binary;
108
109/// Main entry point for both mobile and desktop builds.
110#[cfg_attr(mobile, tauri::mobile_entry_point)]
111pub fn main() { Binary::Main::Main(); }