Skip to main content

Crate fude

Crate fude 

Source
Expand description

§fude (筆)

A minimal wry + tao shell for AI-assisted document editors. The brush: the tool you reach for to write with an AI as co-author. A lightweight alternative to Tauri for this narrow use case.

  • Boots a single-window webview loading asset://localhost/ from a local dist/ directory
  • Exposes window.__shell_ipc(cmd, args) => Promise to the frontend with JSON request/reply semantics, plus window.__shell_listen(name, fn) for server-push events
  • Ships opt-in building blocks for allow-list file I/O and native dialogs
  • Leaves app-specific commands (PTY for AI CLI panes, ACP clients, custom business logic) to the consumer via App::command

§Example

use fude::App;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    App::new("com.example.my-editor")
        .title("My Editor")
        .assets("./dist")
        .with_fs_sandbox()
        .with_dialogs()
        .command("ping", |_ctx, _args| Ok(serde_json::json!("pong")))
        .run()
}

Re-exports§

pub use acp::AcpAdapterConfig;
pub use events::EventEmitter;
pub use fs::FsState;
pub use sandbox::app_config_dir;
pub use sandbox::app_data_dir;
pub use sandbox::atomic_write;
pub use sandbox::ensure_scratch;
pub use sandbox::is_dir_allowed;
pub use sandbox::is_path_allowed;
pub use sandbox::new_list;
pub use sandbox::safe_lock;
pub use sandbox::validate_path;
pub use sandbox::SharedList;

Modules§

acp
ACP (Agent Client Protocol) client.
acp_commands
Synchronous dispatch wrappers for ACP IPC commands. Runs the underlying async ops on a dedicated current-thread tokio runtime.
dialogs
Native dialogs backed by rfd. Registered by crate::App::with_dialogs.
events
Event emitter: background threads push named events to the webview via the tao event loop proxy.
fs
Sandbox-backed file I/O commands. Registered by crate::App::with_fs_sandbox.
pty
PTY sessions for spawning CLI tools from inside a fude window.
sandbox
Path sandbox primitives: an allow-list model where the user grants access to files/directories via native dialogs, and read/write ops refuse to touch anything outside that list. Also blocks well-known credential locations (~/.ssh, ~/.aws, etc.) regardless of allow-list.
settings
JSON settings persistence. Registered by crate::App::with_settings.
shell
Opens URLs or allow-listed files in the OS default application. Registered by crate::App::with_shell_open.

Structs§

App
Builder for a fude application.
Ctx
Runtime context passed to every command. Provides the app identifier, the shared EventEmitter for server-push events, and the allow-list state if with_fs_sandbox was called.
MainDispatcher
Dispatches a closure to run on the main (UI) thread and blocks the caller until it completes. Required on macOS for native dialogs — AppKit NSOpenPanel / NSSavePanel / NSAlert refuse to run from background threads.

Functions§

asset_url_from_file
Returns an asset:// URL that streams an allow-listed local file to the webview. Equivalent to window.__shell_asset_url(path) on the frontend: path is percent-encoded and suffixed onto asset://localhost/__file/. The file is served only when its canonical path is in the FsState allow-list at request time; calling this function does not grant access on its own.
ensure_scratch_dir
Create and allow-list <app_data_dir>/<name>. Convenience wrapper around ensure_scratch for app-owned scratch directories (e.g. "temp-images", "cache").

Type Aliases§

CommandHandler
Handler signature for commands registered via App::command.