lilyco 0.2.0

Lilyco facade — one dependency, auto backend selection (CLI / TUI / Web / MCP)
Documentation

Lilyco — 门面(facade)

一个依赖搞定四端:CLI / TUI / Web / MCP(AI)

借鉴 mininterface 的接口工厂设计:按运行环境自动选择后端, 显式参数 > 环境变量 > 自动探测,TUI 起不来时回退 CLI。

用法(零样板)

use lilyco::prelude::*;

#[derive(App)]
#[app(run = "run_hello")]
struct Hello {
    /// 问候对象
    name: String,
}

fn run_hello(app: &Hello, ctx: &Context) -> Result<serde_json::Value, AppError> {
    let r = serde_json::json!({ "msg": format!("hello {}", app.name) });
    ctx.done(r.clone(), 0);
    Ok(r)
}

fn main() {
    lilyco::run::<Hello>();
}

同一份二进制:

hello --name world        # CLI(非交互终端 / 管道)
hello                      # 交互终端 → TUI 表单
hello --gui                # Web GUI(SSE 进度)
hello --mcp                # MCP stdio 服务器(Agent 直接调用)
LILYCO_UI=web hello        # 环境变量强制后端