Conservative, compile-tested compatibility shims for evolving MoonBit public APIs.
moon add 2227057182/moonshim@0.1.1git clone https://github.com/2227057182/moonshim.git
cd moonshim
moon update
moon check --deny-warn
moon test --deny-warngit checkout <old-version>
moon info
cp pkg.generated.mbti ../old.mbti
git checkout <new-version>
moon info
cp pkg.generated.mbti ../new.mbti{
"version": 1,
"renames": [
{ "kind": "function", "from": "parse_amount", "to": "parse_money" },
{ "kind": "type", "from": "Money", "to": "Cash" }
]
}moon run cmd/main -- diff old.mbti new.mbti \
--rules renames.json \
--markdown migration-report.md \
--json migration-report.json \
--shim compat_generated.mbt \
--fail-on-breakingMoonShim: 0 added, 5 shimmable, 0 blocked, 5 shim declaration(s)pub fn parse_amount(
input : StringView,
currency~ : String = "CNY",
) -> Int32 raise {
parse_money(input, currency~)
}
pub type Money = Cashparser.mbt .mbti parser and interface model
diff.mbt conservative compatibility classification
rules.mbt JSON migration rules
render.mbt Markdown and JSON reports
cmd/main/ CLI
compat_fixture/ compile-time proof that generated shims work
fixtures/ old/new interfaces and reviewed rename rules
docs/ architecture, rules, and submission material
scripts/ local end-to-end verificationmoon fmt --check
moon check --deny-warn
moon test --deny-warn
./scripts/e2e.sh./scripts/e2e.ps1pub(all) suberror RuleError {
RuleError(String)
}pub(all) struct ApiChange {
change_kind : ChangeKind
symbol_kind : SymbolKind
old_name : String?
new_name : String?
old_signature : String?
new_signature : String?
safely_shimmable : Bool
reason : String
}pub(all) struct ApiSymbol {
kind : SymbolKind
name : String
signature : String
parameters : Array[Parameter]
result_text : String
}pub(all) enum ChangeKind {
Added
Removed
Renamed
SignatureChanged
BodyChanged
}pub(all) struct Parameter {
name : String
type_text : String
mode : ParameterMode
default_value : String?
}pub(all) enum ParameterMode {
Positional
Optional
Labelled
Receiver
}pub(all) enum SymbolKind {
Function
TypeAlias
Struct
Enum
Trait
Value
}fn plan_migration(old : ApiSnapshot, new : ApiSnapshot, rules : Array[MigrationRule]) -> MigrationPlan{
"version": 1,
"renames": [
{ "kind": "function", "from": "parse_amount", "to": "parse_money" }
]
}Install
Download zipConservative, compile-tested compatibility shims for evolving MoonBit public APIs.