快速开始与总览

从安装 wings-compile / wings-vm / wings-lsp 到编译运行单模块与多 Actor HTTP/TCP 服务。

早期阶段声明(0.0.x):项目处于快速演进阶段,不承诺语法、受管 C ABI、产物清单( manifest.json / bundle.json)或 Rust 接口的向后兼容;升级版本后请直接重新编译源码。

1. 安装工具链

环境要求:Rust 1.85+,以及系统 C 链接器(cc,可通过环境变量 CC 指定)。首要支持 macOS AArch64(Apple Silicon) 与 Linux x86-64:

cargo install wings-compile wings-vm wings-lsp --version 0.0.3 --locked

也可以在克隆源码仓库后直接通过 Cargo 构建并运行全量工作区测试:

git clone https://github.com/wsafight/wings.git
cd wings
cargo test --workspace --locked

2. 单 Actor 编译与运行

使用 wings-compile check 进行静态类型与消息协议校验,build 生成原生 AOT 共享库与清单(输出目录须不存在),再由 wings-vm run --trusted 执行消息流:

# 静态语法、类型与协议检查
wings-compile check examples/counter.wings

# 编译单 Actor 原生 AOT 产物(输出目录须不存在)
wings-compile build examples/counter.wings -o target/counter-aot

# 通过标准输入 JSON Lines 执行消息流
wings-vm run --trusted target/counter-aot < examples/counter.messages.jsonl

3. 多 Actor 打包与服务化

针对包含多个 Actor、共享不可变 struct、异步 .ask、send_after 定时与 monitor 监控重启的应用,使用 build-app 打包并通过 serve 启动服务:

# 编译多 Actor 应用包(含监督重启与 send_after 定时心跳)
wings-compile build-app examples/session-service.wings -o target/session-bundle

# 启动多 worker HTTP JSON-RPC 服务(含 GET /healthz)
wings-vm serve --trusted target/session-bundle --workers 2 --http 127.0.0.1:8080

# 或启动 TCP JSON Lines 服务
wings-vm serve --trusted target/session-bundle --workers 2 --tcp 127.0.0.1:9000

核心文档导览

以下 7 篇章节直接同源构建自仓库 docs/zh/ 目录: