-
Notifications
You must be signed in to change notification settings - Fork 0
Development Workflow
EnerOS Bot edited this page Jul 5, 2026
·
1 revision
中文 | English
维护版本:v0.51.2 | 最后更新:2026-07-06
本页概述 EnerOS 的开发工作流:Workspace 组织 / 添加新 Agent / 添加新协议 / 添加新插件 / 调试技巧。完整开发者文档请参阅主仓库 docs/developer-guide.md 与 CONTRIBUTING.md。
EnerOS 使用 Cargo workspace 组织 79 个成员:56 库 + 23 二进制 + 3 SDK/宏。完整索引请参阅本 wiki Crate 索引 页。
依赖严格自上而下,禁止反向依赖与循环依赖(详见 分层依赖)。
| 项 | 要求 |
|---|---|
| Rust | 1.75+,edition 2021 |
| 平台 | Linux x86_64/aarch64(生产)/ Windows & macOS(核心库开发) |
| 推荐组件 | rustfmt / clippy / rust-src |
| IDE | VS Code + rust-analyzer |
rustup component add rustfmt clippy rust-srcWindows/macOS 编译核心库(排除 eneros-installer):
cargo build --workspace --exclude eneros-installer-
实现 Agent 逻辑:在
crates/eneros-agent/src/agents/下新建模块,实现决策循环与消息处理 -
创建二进制入口:在
crates/eneros-agent/bins/下新建目录,包含Cargo.toml和src/main.rs -
注册到 workspace:在根
Cargo.toml的members中添加路径 -
配置 init.toml:在
os/rootfs/files/etc/eneros/init.toml中添加启动配置(二进制路径 / 启动参数 / 资源配额) - 编译验证:
cargo build -p my-agent
cargo test -p eneros-agent详见主仓库 docs/developer-guide.md §4。
-
创建适配器模块:在
crates/eneros-device/src/adapters/下新建目录 -
实现 DeviceAdapter trait:参考
crates/eneros-device/src/adapter.rs中的 trait 定义 -
注册到 DeviceManager:在
crates/eneros-device/src/adapters/mod.rs中声明 -
协议一致性测试:在
tests/protocol_conformance/下添加测试用例 -
Fuzz 目标(可选):在
fuzz/下添加 fuzz target
详见主仓库 docs/developer-guide.md §5。
详见本 wiki 运维与插件 页与主仓库 docs/plugin-development.md。
简述:
- 创建
cdylibcrate - 实现
Plugintrait + 对应的ProtocolPlugin/AgentPlugin/AnalysisPlugintrait - 用
#[eneros_plugin]宏自动生成 C ABI 入口 - 编写
manifest.toml清单 - Ed25519 签名
- 部署到
~/.eneros/plugins/
{
"rust-analyzer.checkOnSave.command": "clippy",
"rust-analyzer.cargo.features": "all"
}{
"type": "lldb",
"request": "launch",
"name": "debug eneros-api",
"cargo": {
"args": ["build", "--package", "eneros-api"],
"filter": { "kind": "bin" }
},
"args": ["run", "--config", "eneros.toml"],
"cwd": "${workspaceFolder}"
}ENEROS_OBSERVABILITY__LOG_LEVEL=debug ./target/release/eneros-api run或运行时通过 API:
curl -X POST http://localhost:8080/api/config/reload# 生成火焰图
cargo flamegraph --bin eneros-api -- run --config eneros.toml
# 基准测试
cargo bench --workspace每次 PR 自动执行:
| 门禁 | 命令 | 失败处理 |
|---|---|---|
| 格式化 | cargo fmt --all -- --check |
阻塞合并 |
| Lint | cargo clippy --workspace --all-targets -- -D warnings |
阻塞合并 |
| 构建 | cargo build --workspace |
阻塞合并 |
| 测试 | cargo test --workspace |
阻塞合并 |
| 文档 | cargo doc --workspace --no-deps |
警告 |
| 依赖 | cargo deny check |
阻塞合并 |
| 覆盖率 | llvm-cov | 阈值检查 |
详见本 wiki 测试策略 页。
遵循 CONTRIBUTING.md:
- 提交信息使用 conventional commits(
feat:/fix:/docs:/refactor:/test:/chore:) - 每次 PR 必须更新
CHANGELOG.md对应版本节 - 新版本发布时将
ROADMAP.md完成项移到CHANGELOG.md - 重大架构决策必须新增 ADR
- 主仓库 docs/developer-guide.md — 完整开发者指南
- 主仓库 CONTRIBUTING.md — 贡献指南
- 本 wiki Crate 索引 — 79 个成员清单
- 本 wiki 分层依赖 — 依赖方向规则
- 本 wiki 测试策略 — 测试与质量门禁
- 本 wiki 运维与插件 — 插件开发详情
EnerOS Wiki | v0.51.2