moon-manifest

    Lossless MoonBit manifest queries and edits

    moonbit
    manifest
    moon-mod
    moon-pkg
    moon-work
    Download zip
    Author
    Version
    0.1.0
    License
    MIT
    Last updated
    3 hours ago
    Downloads
    59

    #unmbt/moon-manifest

    Lossless readers and editors for MoonBit moon.mod, moon.pkg, and moon.work files.

    The package is used by MoonBit release and dependency tools that need to inspect or update a manifest without reformatting it. Parsing is delegated to moonbitlang/moon_config, while edits replace only the selected string value and preserve comments, whitespace, line endings, and unrelated fields.

    #Install

    moon add unmbt/moon-manifest

    Then import the package from MoonBit:

    import "unmbt/moon-manifest"

    #Example

    let document = @manifest.parse(
    @manifest.Kind::Mod,
    "name = \"example/app\"\nversion = \"0.1.0\"\n",
    )
    let name = document.module_name()
    let updated = document.replace_string("version", "0.2.0")

    Document::dependency_version reads a dependency from a parsed manifest; Document::members reads workspace members; Document::find_string returns a byte span for a scalar string; and Document::replace_string performs a lossless replacement. Document::diagnostics exposes parser diagnostics with byte offsets into the original UTF-8 source.

    #Supported files and targets

    Kind::Mod, Kind::Pkg, and Kind::Work correspond to the three MoonBit manifest formats. The package targets native because it is intended for CLI, release, and workspace tooling.

    #License

    MIT

    Diagnostic

    pub struct Diagnostic {
    message : String
    start : Int
    end : Int
    } derive(Eq,
    Debug
    )

    A diagnostic reported by moon_config or by the lossless edit layer.

    Document

    pub struct Document {
    kind : Kind
    path : String
    source : Bytes
    ast :
    Ast

    diagnostics : Array[Diagnostic]
    } derive(
    Debug
    )

    A parsed manifest. source is retained byte-for-byte for stale-plan checks.

    Document::dependency_version

    fn Document::dependency_version(self : Document, module : String) -> String?

    Document::find_string

    fn Document::find_string(self : Document, key : String) -> Span?

    Find a scalar string assignment without changing comments or surrounding bytes.

    Document::members

    fn Document::members(self : Document) -> Array[String]

    Document::module_name

    fn Document::module_name(self : Document) -> String?

    Document::replace_string

    fn Document::replace_string(self : Document, key : String, value : String) -> String

    Replace the first key = "..." or "key": "..." value.

    Document::version

    fn Document::version(self : Document) -> String?

    Kind

    pub(all) enum Kind {
    Mod
    Pkg
    Work
    } derive(Eq,
    Debug
    )

    A supported MoonBit configuration file.

    Span

    pub struct Span {
    start : Int
    end : Int
    } derive(Eq,
    Debug
    )

    A byte range in the original UTF-8 source.

    parse

    fn parse(kind : Kind, source : String, path? : String) -> Document

    Source Files

    Powered by MoonBit

    Site sourceReport issueModulesSkillsBuild queueStatistics

    © 2026 mooncakes.io