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
75/// Local error taxonomy (superseded; zero callers - see
76/// `CommonLibrary::Error::CommonError`).
77pub mod Error;
78
79/// Centralized, thread-safe application state managed by Tauri.
80pub mod ApplicationState;
81
82/// Capability providers: file system, process, terminal, and extension host.
83pub mod Environment;
84
85/// Effect execution engine that drives `ActionEffect` pipelines.
86pub mod RunTime;
87
88// Communication
89
90/// Inter-process communication primitives.
91pub mod IPC;
92
93/// Client for the Air background daemon (updates and crypto signing).
94pub mod Air;
95
96/// gRPC server and client for Cocoon extension host communication.
97pub mod Vine;
98
99/// Remote procedure call service implementations.
100pub mod RPC;
101
102/// MemoryMap asset cache, path-canonicalisation cache, and future entries.
103/// See `Cache` module index for the full entry list.
104pub mod Cache;
105
106// Services
107
108/// Sidecar process lifecycle: launch, monitor, and restart.
109pub mod ProcessManagement;
110
111/// Native TreeView provider for the File Explorer.
112pub mod FileSystem;
113
114/// Extension discovery, scanning, and activation.
115pub mod ExtensionManagement;
116
117// Commands
118
119/// Native command handlers for file, edit, view, and terminal operations.
120pub mod Command;
121
122/// Central command dispatcher routing UI requests to the correct provider.
123pub mod Track;
124
125/// `.code-workspace` file parsing and multi-root workspace support.
126pub mod Workspace;
127
128/// Emits a single ISO-timestamped boot banner listing all compiled-in tier
129/// values.
130pub mod LandFixTier;
131
132/// Binary entry points for desktop and mobile builds.
133pub mod Binary;
134
135/// Main entry point for both mobile and desktop builds.
136#[cfg_attr(mobile, tauri::mobile_entry_point)]
137pub fn main() { Binary::Main::Entry::Fn(); }