Ordered Valve KeyValues tooling, source editing, streaming and Steam metadata in MoonBit
git clone https://github.com/Charles67676767/MoonValve.git
cd MoonValve
moon version --all
moon update
moon check
moon test
moon run examples/demo
moon run examples/advancedimport {
"Charles67676767/moonvalve" @valve,
}let doc = @valve.parse("root { tag one tag two name \"Moon Harbor\" }")
let name = doc.lookup(["root", "name"])
let normalized = @valve.stringify(doc)
let same = @valve.parse(normalized) == docmoon run cmd/main --target js -- help
moon run cmd/main --target js -- parse fixtures/duplicates.vdf
moon run cmd/main --target js -- from-json data.json
moon run cmd/main --target js -- format fixtures/duplicates.vdf
moon run cmd/main --target js -- query fixtures/appmanifest_480.acf AppState name
moon run cmd/main --target js -- app fixtures/appmanifest_480.acf
moon run cmd/main --target js -- libraries fixtures/libraryfolders.vdf{"app_id":"480","name":"Moon Harbor","install_dir":"Moon Harbor","size_on_disk":"1048576","build_id":"20261023"}moon run cmd/main --target js -- inventory "/path/to/Steam/steamapps/libraryfolders.vdf"
moon run cmd/main --target js -- inventory "/path/to/libraryfolders.vdf" --filter portal --sort size --csvmoon build --target js --release
node _build/js/release/build/cmd/main/main.js helpmoon build --target native --release
moon run cmd/main --target native --release -- helpmoon fmt --check
moon check --target js
moon test --target all --deny-warn
moon build --target js --release
node scripts/test-cli.cjs
moon build --target native --release
node scripts/test-cli.cjs --native
python -m pip install vdf==3.4
python scripts/check-reference.py
node scripts/benchmark.cjs --native
moon infomodel.mbt 有序数据模型与查询
parser.mbt KV1 文本解析及诊断
writer.mbt 规范化文本写出
steam.mbt Steam 清单模型
inventory.mbt 筛选、排序、统计、检查与 CSV
edit.mbt 重复键感知的文档编辑
source_edit.mbt 保留原文的局部编辑
json_codec.mbt 有序 JSON 导入
conditions.mbt 平台条件表达式
resolve.mbt 文件引用解析
project.mbt 引用关系与原文来源
stream_writer.mbt 有界事件写出
binary.mbt 标准二进制 KV1
cmd/main/ JS/C 宿主适配与 MoonBit CLI
examples/demo/ 跨后端最小使用示例
examples/advanced/ 编辑、条件、引用与二进制示例
fixtures/ 合成示例与注明来源许可的实际配置
scripts/test-cli.cjs CLI 端到端测试
docs/ 兼容性、设计与路线图moon run cmd/main --target native -- workspace-export fixtures/workspace-fields.json new-project
moon run cmd/main --target native -- workspace-zip fixtures/workspace-fields.json project.zip
moon run cmd/main --target native -- kv3-select fixtures/sample.kv3 '/**?type=integer&>9007199254740993'pub(all) enum BinaryValue {
ObjectValue(Array[BinaryEntry])
StringValue(String)
Int32Value(Int)
Float32Bits(UInt)
Pointer32(UInt)
WideString(String)
Color32(UInt)
UInt64Value(UInt64)
Int64Value(Int64)
} derive(Eq, Debug)pub(all) struct DMXDocument {
format_name : String
format_version : Int
root : String
elements : Array[DMXElement]
} derive(Eq, Debug)fn DMXDocument::with_attribute(self : DMXDocument, id : String, name : String, value : DMXValue) -> DMXDocument raisepub(all) struct DMXElement {
id : String
name : String
kind : String
attributes : Array[DMXAttribute]
} derive(Eq, Debug)type DependencyGraphfn DependencyGraph::dependents(self : DependencyGraph, target : String, transitive? : Bool) -> Array[String]fn DependencyGraph::export_files(self : DependencyGraph, include_base? : Bool, strict? : Bool) -> Map[String, Bytes] raisefn DependencyGraph::export_vpk(self : DependencyGraph, include_base? : Bool, strict? : Bool, options? : BinaryOptions) -> Bytes raisefn DependencyGraph::export_zip(self : DependencyGraph, include_base? : Bool, strict? : Bool) -> Bytes raisetype GameFileSystempub(all) enum GameMount {
LooseMount(String, Bool, (String) -> Bool raise, (String) -> Bytes raise)
VPKMount(String, Bool, VPKArchive, (Int, Int, Int) -> Bytes raise)
}pub(all) struct KV3BinaryDocument {
version : Int
compression : Int
format_id : String
root : KV3BinaryValue
} derive(Eq, Debug)fn KV3BinaryDocument::edit_query(self : KV3BinaryDocument, expression : String, operation : KV3QueryEdit) -> KV3BinaryDocument raisefn KV3BinaryDocument::select(self : KV3BinaryDocument, expression : String) -> Array[KV3BinaryLocatedValue] raisepub(all) struct KV3BinaryLocatedValue {
path : Array[String]
value : KV3BinaryValue
} derive(Eq, Debug)pub(all) enum KV3BinaryValue {
BNull
BBool(Bool)
BNumber(Int, UInt64)
BString(String)
BBlob(Bytes)
BArray(Array[KV3BinaryValue])
BObject(Array[(String, KV3BinaryValue)])
BFlag(String, KV3BinaryValue)
} derive(Eq, Debug)type KV3Querytype KV3SourceDocumentfn KV3SourceDocument::edit(self : KV3SourceDocument, path : Array[String], operation : KV3Edit) -> KV3SourceDocument raisefn KV3SourceDocument::edit_query(self : KV3SourceDocument, expression : String, operation : KV3QueryEdit) -> KV3SourceDocument raisefn KV3SourceDocument::resources(self : KV3SourceDocument, roots? : Array[ResourceRoot]) -> Array[ResourceReference] raisefn KV3SourceDocument::rewrite_resources(self : KV3SourceDocument, roots : Array[ResourceRoot], moves : Map[String, String]) -> KV3SourceDocument raisepub(all) struct Localization {
language : String
tokens : Array[LocalizationToken]
encoding : String
} derive(Eq, Debug)fn Localization::import_po(self : Localization, catalog : POCatalog, language : String, syntax? : String, allow_fuzzy? : Bool) -> LocalizationImport raisefn Localization::validate_translation(self : Localization, translated : Localization, syntax? : String) -> Array[LocalizationIssue] raisepub(all) struct LocalizationImport {
document : Localization
issues : Array[LocalizationIssue]
} derive(Eq, Debug)type LspFramertype LspServertype Querypub(all) enum QueryEdit {
SetText(String)
ReplacePrefix(String, String)
RenameKey(String)
RemoveMatches
} derive(Debug)pub(all) struct ReferenceEdge {
source : String
target : String
kind : String
location : SourceLocation
} derive(Eq, Debug)pub(all) struct ResolvedOrigin {
path : Array[Selector]
location : SourceLocation
} derive(Eq, Debug)pub(all) struct ResolvedProject {
document : Document
origins : Array[ResolvedOrigin]
references : Array[ReferenceEdge]
} derive(Eq, Debug)pub(all) struct ResourceContainer {
version : Int
declared_size : Int
blocks : Array[ResourceBlock]
trailing : Bytes
} derive(Eq, Debug)fn ResourceContainer::data(self : ResourceContainer, options? : BinaryOptions) -> KV3BinaryDocument raisefn ResourceContainer::external_references(self : ResourceContainer, options? : BinaryOptions) -> Array[ResourceExternalReference] raisefn ResourceExternalReference::not_equal(x : ResourceExternalReference, y : ResourceExternalReference) -> Booltype ShortcutFilefn ShortcutFile::add(self : ShortcutFile, name : String, exe : String, start_dir? : String, launch_options? : String, tags? : Array[String]) -> ShortcutFile raise SteamErrorfn ShortcutFile::set(self : ShortcutFile, shortcut : SteamShortcut) -> ShortcutFile raise SteamErrortype SourceDocumentfn SourceDocument::apply_snapshot(self : SourceDocument, changes : Array[Change]) -> SourceDocument raisefn SourceDocument::edit(self : SourceDocument, path : Array[Selector], operation : Edit) -> SourceDocument raisefn SourceDocument::edit_query(self : SourceDocument, expression : String, operation : QueryEdit) -> SourceDocument raisefn SourceDocument::evaluate(self : SourceDocument, symbols : Array[String]) -> Document raise ParseErrorfn SourceDocument::transfer(self : SourceDocument, from : Array[Selector], to : Array[Selector], index : Int, copy? : Bool) -> SourceDocument raisetype SteamCachefn SteamCache::page(self : SteamCache, query? : String, offset? : Int, limit? : Int) -> CachePage raise BinaryErrortype StreamParsertype StreamWriterfn VMTMaterial::textures(self : VMTMaterial, extra_parameters? : Array[String]) -> Array[VMTTexture] raisefn VMTMaterial::with_parameter(self : VMTMaterial, key : String, value : String) -> VMTMaterial raisetype VPKArchivefn VPKArchive::read(self : VPKArchive, path : String, loader : (Int, Int, Int) -> Bytes raise, verify_crc? : Bool) -> Bytes raisetype Workspacefn Workspace::edit_query_kv3(self : Workspace, expression : String, operation : KV3QueryEdit, files? : Array[String]) -> Workspace raisefn build_dependency_graph(roots : Array[String], filesystem : GameFileSystem, max_files? : Int, max_bytes? : Int) -> DependencyGraph raisefn check_inventory(libraries : Array[SteamLibrary], records : Array[InventoryRecord]) -> Array[InventoryIssue]fn create_vpk(files : Map[String, Bytes], preload_bytes? : Int, options? : BinaryOptions) -> Bytes raisefn decode_binary(bytes : Bytes, options? : BinaryOptions, string_table? : Array[String]?) -> Array[BinaryEntry] raise BinaryErrorfn encode_binary(entries : Array[BinaryEntry], options? : BinaryOptions, string_table? : Array[String]?) -> Bytes raise BinaryErrorfn encode_dmx_binary(document : DMXDocument, version? : Int, options? : BinaryOptions) -> Bytes raisefn encode_kv3_binary(document : KV3BinaryDocument, version? : Int, compression? : Int, options? : BinaryOptions) -> Bytes raisefn encode_kv3_resource(document : KV3BinaryDocument, resource_version? : Int, version? : Int, compression? : Int, options? : BinaryOptions) -> Bytes raisefn gameinfo_search_paths(document : Document, gameinfo_directory : String, engine_directory : String, language? : String) -> Array[GameSearchPath] raisefn load_project(source : String, loader : (String) -> String raise, options? : ParseOptions, max_files? : Int) -> ResolvedProject raisefn load_resolved(source : String, loader : (String) -> String raise, options? : ParseOptions, max_files? : Int) -> Document raisefn load_vmt(source : String, loader : (String) -> String raise, options? : ParseOptions, max_files? : Int) -> VMTMaterial raisefn new_stream_parser(visitor : (StreamEvent) -> Bool raise, options? : ParseOptions) -> StreamParser raise ParseErrorfn open_steam_cache(input : Bytes, max_bytes? : Int, max_records? : Int) -> SteamCache raise BinaryErrorfn parse_kv3(input : String, options? : ParseOptions, allow_headerless? : Bool) -> KV3Document raisefn parse_kv3_preserving(input : String, options? : ParseOptions, allow_headerless? : Bool) -> KV3SourceDocument raisefn query_workspace_kv3_snapshot(snapshot : Json, expression : String, files? : Array[String], options? : ParseOptions) -> Json raisefn query_workspace_snapshot(snapshot : Json, expression : String, files? : Array[String], options? : ParseOptions) -> Json raisefn select_inventory(records : Array[InventoryRecord], filter? : String, sort? : String) -> Array[InventoryRecord] raise SteamErrorfn shortcut_app_id(name : String, exe : String) -> UIntfn version() -> StringInstall
Download zipOrdered Valve KeyValues tooling, source editing, streaming and Steam metadata in MoonBit