Read-only development environment diagnostics with composable MoonBit rules
| 能力 | 实现范围 |
|---|---|
| 核心模型 | Passed / Warning / Failed / Skipped / Unsupported / Error,严重程度、证据、建议、耗时 |
| 规则与调度 | 注册/注销/启停、优先级、DAG 验证、依赖阻塞、单项错误隔离、异步超时、取消令牌、总预算 |
| 条件 | 有界 AND / OR / NOT、变量存在性与相等判断 |
| 环境与工具链 | OS/架构、环境变量、PATH 完整条目检查,包括 moon/moonc/git/cc/clang/gcc 的版本命令 |
| 依赖 | 显式版本清单或 moon tree --json 快照、SemVer 约束和来源检查 |
| 文件与配置 | 根目录边界、文件类型和权限、有界 UTF-8 读取、JSON 类型、数值范围与字段依赖 |
| 网络与资源 | 显式授权的 DNS/TCP、CPU 数、内存总量和可用量、目录所在磁盘空间、当前进程 ID |
| 报告与 CLI | Text/JSON/Markdown、敏感证据脱敏、profile/category/config、稳定退出码 |
git clone https://github.com/mik1e80/moonsystermdoctor.git
cd moonsystermdoctor
moon update
moon check --target native --deny-warn
moon run cmd/doctor -- check
moon run cmd/doctor -- rules list
moon run cmd/doctor -- versionmoon run cmd/doctor -- check --config examples/doctor.json --profile development
moon run cmd/doctor -- check --category toolchain --jobs 4 --format json
moon run cmd/doctor -- check --config examples/moon-dependency.json --format json
moon run cmd/doctor -- check --config examples/doctor.json --profile network --allow-network
moon run cmd/doctor -- check --config examples/doctor.json --profile development --format markdown
moon run cmd/doctor -- check --config examples/failure.jsonmoon build --target native --release cmd/doctor| 退出码 | 含义 |
|---|---|
| 0 | 无失败或执行异常;默认允许警告/跳过/不支持 |
| 1 | 存在 Failed;--strict 下也包括 Warning/Skipped/Unsupported |
| 2 | 参数/配置错误或规则执行 Error;高于诊断失败优先级 |
moon add mik1e80/moonsystemdoctor@0.1.0moon run examples/basic
moon run examples/custom_rulepub struct Cancellation {
// private fields
}fn Condition::evaluate(self : Condition, facts : Map[String, String], max_depth? : Int, max_nodes? : Int) -> Bool raise DoctorErrorfn Configuration::context(self : Configuration, platform : &Platform, allow_network? : Bool) -> Contextfn Configuration::selection(self : Configuration, profile? : String, category? : String) -> Array[String] raise DoctorErrorimpl Platform for MockPlatformfn MockPlatform::new(facts? : Map[String, String], observations? : Map[String, Finding], files? : Map[String, String]) -> MockPlatformasync fn Registry::run(self : Registry, ctx : Context, selected? : Array[String], cancellation? : Cancellation, budget_ms? : Int, jobs? : Int) -> Array[DiagnosticResult]pub(all) struct ReportMetadata {
started_at_unix_ms : UInt64
tool_version : String
os : String
backend : String
}pub(all) enum Severity {
Info
Low
Medium
High
Critical
}pub(all) struct Summary {
passed : Int
warning : Int
failed : Int
skipped : Int
unsupported : Int
errors : Int
}fn configuration_rule(id : String, platform : &Platform, path : String, fields : Array[Field]) -> Rule raise DoctorErrorfn display_text(text : String, limit? : Int) -> Stringfn remediation_for(code : String) -> Stringfn render_report(results : Array[DiagnosticResult], format : String, secrets? : Array[String], max_bytes? : Int, metadata? : ReportMetadata) -> String raise DoctorErrorfn safe_relative(path : String) -> Bool