modwright 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +35 -0
- package/README.md +212 -0
- package/assets/claude/agents/mw-explore.md +46 -0
- package/assets/claude/agents/mw-fixture.md +33 -0
- package/assets/claude/agents/mw-rule-author.md +51 -0
- package/assets/claude/agents/mw-scaffold-author.md +48 -0
- package/assets/claude/skills/mw-author.md +59 -0
- package/assets/claude/skills/mw-new-item.md +51 -0
- package/assets/claude/skills/mw-new-spell.md +50 -0
- package/assets/claude/skills/mw-scaffold.md +59 -0
- package/assets/claude/skills/mw-ship.md +57 -0
- package/assets/claude/skills/mw-validate.md +51 -0
- package/assets/claude/skills/mw-verify.md +59 -0
- package/assets/nivalisnights/extract_resources.py +177 -0
- package/bridges/bg3-se/Mods/ModWrightBridge/ScriptExtender/Config.json +5 -0
- package/bridges/bg3-se/Mods/ModWrightBridge/ScriptExtender/Lua/BootstrapClient.lua +55 -0
- package/bridges/bg3-se/Mods/ModWrightBridge/ScriptExtender/Lua/BootstrapServer.lua +81 -0
- package/bridges/bg3-se/Mods/ModWrightBridge/ScriptExtender/Lua/ModWrightBridge/Log.lua +96 -0
- package/bridges/bg3-se/Mods/ModWrightBridge/ScriptExtender/Lua/ModWrightBridge/Probes.lua +1038 -0
- package/bridges/bg3-se/Mods/ModWrightBridge/ScriptExtender/Lua/ModWrightBridge/ProbesClient.lua +74 -0
- package/bridges/bg3-se/Mods/ModWrightBridge/ScriptExtender/Lua/ModWrightBridge/Protocol.lua +985 -0
- package/bridges/bg3-se/Mods/ModWrightBridge/ScriptExtender/Lua/ModWrightBridge/Watch.lua +175 -0
- package/bridges/bg3-se/Mods/ModWrightBridge/meta.lsx +45 -0
- package/bridges/bg3-se/README.md +99 -0
- package/bridges/bg3-se/bridge.json +68 -0
- package/bridges/cp2077-cet/ModWrightBridge/init.lua +375 -0
- package/bridges/cp2077-cet/ModWrightBridge/probes.lua +1104 -0
- package/bridges/cp2077-cet/ModWrightBridge/protocol.lua +1306 -0
- package/bridges/cp2077-cet/README.md +165 -0
- package/bridges/cp2077-cet/bridge.json +53 -0
- package/dist/core/bridge/arm.js +175 -0
- package/dist/core/bridge/cet-console.js +26 -0
- package/dist/core/bridge/cet-log.js +362 -0
- package/dist/core/bridge/index.js +11 -0
- package/dist/core/bridge/locate.js +35 -0
- package/dist/core/bridge/paths.js +34 -0
- package/dist/core/bridge/pending.js +89 -0
- package/dist/core/bridge/poll.js +155 -0
- package/dist/core/bridge/stage.js +100 -0
- package/dist/core/bridge/status.js +97 -0
- package/dist/core/bridge/types.js +145 -0
- package/dist/core/bridge/validate.js +107 -0
- package/dist/core/build/index.js +6 -0
- package/dist/core/build/manifest.js +47 -0
- package/dist/core/build/paths.js +32 -0
- package/dist/core/build/run.js +342 -0
- package/dist/core/build/stage.js +265 -0
- package/dist/core/build/steps/bg3.js +129 -0
- package/dist/core/build/steps/core.js +195 -0
- package/dist/core/build/steps/cyberpunk.js +95 -0
- package/dist/core/build/steps/listing.js +35 -0
- package/dist/core/build/types.js +13 -0
- package/dist/core/build/zip.js +148 -0
- package/dist/core/compat/check.js +113 -0
- package/dist/core/compat/pe.js +220 -0
- package/dist/core/compat/types.js +1 -0
- package/dist/core/compat/version.js +70 -0
- package/dist/core/deploy/guards.js +292 -0
- package/dist/core/deploy/index.js +5 -0
- package/dist/core/deploy/plan.js +696 -0
- package/dist/core/deploy/reload-apply.js +361 -0
- package/dist/core/deploy/reload.js +358 -0
- package/dist/core/deploy/sources.js +169 -0
- package/dist/core/deploy/types.js +1 -0
- package/dist/core/epic.js +54 -0
- package/dist/core/fsutil.js +191 -0
- package/dist/core/home.js +70 -0
- package/dist/core/knowledge/facts.js +229 -0
- package/dist/core/knowledge/index.js +4 -0
- package/dist/core/knowledge/search.js +112 -0
- package/dist/core/knowledge/store.js +123 -0
- package/dist/core/knowledge/types.js +1 -0
- package/dist/core/ledger/check.js +42 -0
- package/dist/core/ledger/hooks.js +80 -0
- package/dist/core/ledger/index.js +7 -0
- package/dist/core/ledger/query.js +17 -0
- package/dist/core/ledger/record.js +84 -0
- package/dist/core/ledger/status.js +53 -0
- package/dist/core/ledger/store.js +98 -0
- package/dist/core/ledger/types.js +108 -0
- package/dist/core/logs/index.js +4 -0
- package/dist/core/logs/registry.js +50 -0
- package/dist/core/logs/scan.js +195 -0
- package/dist/core/logs/triage.js +160 -0
- package/dist/core/logs/types.js +1 -0
- package/dist/core/lsx.js +10 -0
- package/dist/core/lz4.js +66 -0
- package/dist/core/mods.js +229 -0
- package/dist/core/process.js +49 -0
- package/dist/core/project/build-steps.js +83 -0
- package/dist/core/project/describe.js +74 -0
- package/dist/core/project/index.js +5 -0
- package/dist/core/project/load.js +146 -0
- package/dist/core/project/schema.js +264 -0
- package/dist/core/project/types.js +3 -0
- package/dist/core/prompts.js +72 -0
- package/dist/core/registry.js +35 -0
- package/dist/core/safety/backup.js +206 -0
- package/dist/core/safety/execute.js +188 -0
- package/dist/core/safety/index.js +5 -0
- package/dist/core/safety/plan.js +122 -0
- package/dist/core/safety/restore.js +172 -0
- package/dist/core/safety/types.js +1 -0
- package/dist/core/scaffold/bootstrap.js +7 -0
- package/dist/core/scaffold/catalog.js +28 -0
- package/dist/core/scaffold/claude-assets.js +271 -0
- package/dist/core/scaffold/collisions.js +64 -0
- package/dist/core/scaffold/emit.js +356 -0
- package/dist/core/scaffold/engine.js +680 -0
- package/dist/core/scaffold/ids.js +78 -0
- package/dist/core/scaffold/index.js +10 -0
- package/dist/core/scaffold/jsonpath.js +121 -0
- package/dist/core/scaffold/load.js +81 -0
- package/dist/core/scaffold/render.js +85 -0
- package/dist/core/scaffold/sequence.js +396 -0
- package/dist/core/scaffold/types.js +309 -0
- package/dist/core/steam.js +63 -0
- package/dist/core/surfaceutil.js +36 -0
- package/dist/core/testplan/check.js +67 -0
- package/dist/core/testplan/index.js +5 -0
- package/dist/core/testplan/load.js +100 -0
- package/dist/core/testplan/registry.js +317 -0
- package/dist/core/testplan/run.js +389 -0
- package/dist/core/testplan/types.js +82 -0
- package/dist/core/text/converters/bg3.js +50 -0
- package/dist/core/text/converters/cyberpunk.js +36 -0
- package/dist/core/text/converters/index.js +261 -0
- package/dist/core/text/diff/cr2w.js +180 -0
- package/dist/core/text/diff/index.js +16 -0
- package/dist/core/text/diff/loca.js +43 -0
- package/dist/core/text/diff/lsx.js +126 -0
- package/dist/core/text/handles.js +86 -0
- package/dist/core/text/index.js +6 -0
- package/dist/core/text/json.js +46 -0
- package/dist/core/text/templates/cache.js +71 -0
- package/dist/core/text/templates/index.js +3 -0
- package/dist/core/text/templates/library.js +245 -0
- package/dist/core/text/templates/types.js +51 -0
- package/dist/core/text/toolchain.js +16 -0
- package/dist/core/text/types.js +1 -0
- package/dist/core/text/validate.js +149 -0
- package/dist/core/text/xml.js +58 -0
- package/dist/core/toolchain/datafetch.js +151 -0
- package/dist/core/toolchain/env.js +63 -0
- package/dist/core/toolchain/features.js +170 -0
- package/dist/core/toolchain/index.js +8 -0
- package/dist/core/toolchain/install.js +191 -0
- package/dist/core/toolchain/locate.js +275 -0
- package/dist/core/toolchain/remember.js +84 -0
- package/dist/core/toolchain/run.js +318 -0
- package/dist/core/toolchain/specs.js +351 -0
- package/dist/core/toolchain/types.js +1 -0
- package/dist/core/types.js +1 -0
- package/dist/core/userconfig.js +66 -0
- package/dist/core/validate/context.js +139 -0
- package/dist/core/validate/index.js +5 -0
- package/dist/core/validate/registry.js +58 -0
- package/dist/core/validate/run.js +131 -0
- package/dist/core/validate/suppressions.js +91 -0
- package/dist/core/validate/types.js +2 -0
- package/dist/core/yamledit.js +51 -0
- package/dist/index.js +389 -0
- package/dist/server.js +1914 -0
- package/dist/surfaces/baldursgate3/compat.js +164 -0
- package/dist/surfaces/baldursgate3/identity.js +110 -0
- package/dist/surfaces/baldursgate3/index/build.js +331 -0
- package/dist/surfaces/baldursgate3/index/index.js +17 -0
- package/dist/surfaces/baldursgate3/index/info.js +40 -0
- package/dist/surfaces/baldursgate3/index/parsers/loca.js +41 -0
- package/dist/surfaces/baldursgate3/index/parsers/lsx.js +137 -0
- package/dist/surfaces/baldursgate3/index/parsers/stats.js +45 -0
- package/dist/surfaces/baldursgate3/index/parsers/treasuretable.js +57 -0
- package/dist/surfaces/baldursgate3/index/parsers/xmlutil.js +142 -0
- package/dist/surfaces/baldursgate3/index/queries.js +327 -0
- package/dist/surfaces/baldursgate3/index/schema.js +62 -0
- package/dist/surfaces/baldursgate3/index.js +3 -0
- package/dist/surfaces/baldursgate3/logs.js +278 -0
- package/dist/surfaces/baldursgate3/modsettings.js +115 -0
- package/dist/surfaces/baldursgate3/pak.js +153 -0
- package/dist/surfaces/baldursgate3/settings.js +49 -0
- package/dist/surfaces/baldursgate3/surface.js +232 -0
- package/dist/surfaces/baldursgate3/validators/bridge.js +7 -0
- package/dist/surfaces/baldursgate3/validators/files.js +476 -0
- package/dist/surfaces/baldursgate3/validators/items.js +1001 -0
- package/dist/surfaces/baldursgate3/validators/progression.js +734 -0
- package/dist/surfaces/baldursgate3/validators/stats.js +1076 -0
- package/dist/surfaces/baldursgate3/validators/story.js +790 -0
- package/dist/surfaces/baldursgate3/validators/templates.js +7 -0
- package/dist/surfaces/cyberpunk2077/compat.js +223 -0
- package/dist/surfaces/cyberpunk2077/index/build.js +231 -0
- package/dist/surfaces/cyberpunk2077/index/index.js +17 -0
- package/dist/surfaces/cyberpunk2077/index/info.js +51 -0
- package/dist/surfaces/cyberpunk2077/index/model.js +52 -0
- package/dist/surfaces/cyberpunk2077/index/parsers/tweak.js +483 -0
- package/dist/surfaces/cyberpunk2077/index/parsers/tweakxl-yaml.js +183 -0
- package/dist/surfaces/cyberpunk2077/index/queries.js +504 -0
- package/dist/surfaces/cyberpunk2077/index/resource.js +135 -0
- package/dist/surfaces/cyberpunk2077/index/schema.js +90 -0
- package/dist/surfaces/cyberpunk2077/index.js +3 -0
- package/dist/surfaces/cyberpunk2077/logs.js +742 -0
- package/dist/surfaces/cyberpunk2077/paths.js +12 -0
- package/dist/surfaces/cyberpunk2077/surface.js +218 -0
- package/dist/surfaces/cyberpunk2077/validators/bridge.js +7 -0
- package/dist/surfaces/cyberpunk2077/validators/cr2w.js +349 -0
- package/dist/surfaces/cyberpunk2077/validators/garments.js +1181 -0
- package/dist/surfaces/cyberpunk2077/validators/mesh.js +338 -0
- package/dist/surfaces/cyberpunk2077/validators/modsettings.js +120 -0
- package/dist/surfaces/cyberpunk2077/validators/packaging.js +463 -0
- package/dist/surfaces/cyberpunk2077/validators/red4ext.js +318 -0
- package/dist/surfaces/cyberpunk2077/validators/redscript.js +193 -0
- package/dist/surfaces/cyberpunk2077/validators/templates.js +7 -0
- package/dist/surfaces/cyberpunk2077/validators/tweaks.js +768 -0
- package/dist/surfaces/cyberpunk2077/validators/vehicles.js +531 -0
- package/dist/surfaces/cyberpunk2077/validators/xl.js +308 -0
- package/dist/surfaces/eldenring/binders.js +111 -0
- package/dist/surfaces/eldenring/compat.js +166 -0
- package/dist/surfaces/eldenring/dcx.js +49 -0
- package/dist/surfaces/eldenring/index.js +13 -0
- package/dist/surfaces/eldenring/loaders.js +132 -0
- package/dist/surfaces/eldenring/logs.js +67 -0
- package/dist/surfaces/eldenring/paramdef.js +256 -0
- package/dist/surfaces/eldenring/params.js +129 -0
- package/dist/surfaces/eldenring/surface.js +121 -0
- package/dist/surfaces/eldenring/tools.js +52 -0
- package/dist/surfaces/eldenring/validators/binders.js +193 -0
- package/dist/surfaces/eldenring/validators/packages.js +159 -0
- package/dist/surfaces/eldenring/validators/params.js +334 -0
- package/dist/surfaces/eldenring/validators/profiles.js +287 -0
- package/dist/surfaces/index.js +34 -0
- package/dist/surfaces/nivalisnights/compat.js +229 -0
- package/dist/surfaces/nivalisnights/index/build.js +310 -0
- package/dist/surfaces/nivalisnights/index/index.js +5 -0
- package/dist/surfaces/nivalisnights/index/queries.js +231 -0
- package/dist/surfaces/nivalisnights/index.js +4 -0
- package/dist/surfaces/nivalisnights/logs.js +473 -0
- package/dist/surfaces/nivalisnights/surface.js +195 -0
- package/dist/surfaces/skyrimse/archives.js +229 -0
- package/dist/surfaces/skyrimse/compat.js +163 -0
- package/dist/surfaces/skyrimse/index.js +12 -0
- package/dist/surfaces/skyrimse/loadorder.js +174 -0
- package/dist/surfaces/skyrimse/logs.js +241 -0
- package/dist/surfaces/skyrimse/plugins.js +149 -0
- package/dist/surfaces/skyrimse/records.js +94 -0
- package/dist/surfaces/skyrimse/surface.js +240 -0
- package/dist/surfaces/skyrimse/validators/archive-records.js +165 -0
- package/dist/surfaces/skyrimse/validators/archives.js +110 -0
- package/dist/surfaces/skyrimse/validators/plugins.js +374 -0
- package/dist/surfaces/skyrimse/validators/records.js +117 -0
- package/dist/surfaces/stardewvalley/compat.js +190 -0
- package/dist/surfaces/stardewvalley/config.js +42 -0
- package/dist/surfaces/stardewvalley/contentpatcher.js +203 -0
- package/dist/surfaces/stardewvalley/index/index.js +229 -0
- package/dist/surfaces/stardewvalley/index/wiki.js +190 -0
- package/dist/surfaces/stardewvalley/index.js +12 -0
- package/dist/surfaces/stardewvalley/logs.js +307 -0
- package/dist/surfaces/stardewvalley/mods.js +182 -0
- package/dist/surfaces/stardewvalley/surface.js +244 -0
- package/dist/surfaces/stardewvalley/validators/content.js +321 -0
- package/dist/surfaces/stardewvalley/validators/fields.js +147 -0
- package/dist/surfaces/stardewvalley/validators/loadorder.js +69 -0
- package/dist/surfaces/stardewvalley/validators/manifest.js +221 -0
- package/dist/surfaces/subnautica2/compat.js +138 -0
- package/dist/surfaces/subnautica2/index.js +5 -0
- package/dist/surfaces/subnautica2/logs.js +129 -0
- package/dist/surfaces/subnautica2/paks.js +173 -0
- package/dist/surfaces/subnautica2/surface.js +151 -0
- package/dist/surfaces/subnautica2/validators/packaging.js +298 -0
- package/dist/surfaces/valheim/compat.js +171 -0
- package/dist/surfaces/valheim/index/index.js +301 -0
- package/dist/surfaces/valheim/index/tables.js +103 -0
- package/dist/surfaces/valheim/index.js +11 -0
- package/dist/surfaces/valheim/logs.js +197 -0
- package/dist/surfaces/valheim/packaging.js +131 -0
- package/dist/surfaces/valheim/plugins.js +270 -0
- package/dist/surfaces/valheim/references.js +121 -0
- package/dist/surfaces/valheim/surface.js +223 -0
- package/dist/surfaces/valheim/validators/packaging.js +218 -0
- package/dist/surfaces/valheim/validators/plugins.js +287 -0
- package/dist/surfaces/valheim/validators/references.js +169 -0
- package/knowledge/baldursgate3/animations.gr2.yaml +166 -0
- package/knowledge/baldursgate3/audio.voice.yaml +182 -0
- package/knowledge/baldursgate3/audio.wwise.yaml +104 -0
- package/knowledge/baldursgate3/charactercreation.heads-hair.yaml +193 -0
- package/knowledge/baldursgate3/communitylibrary.shared-content.yaml +129 -0
- package/knowledge/baldursgate3/compatibilityframework.api.yaml +176 -0
- package/knowledge/baldursgate3/crash.causes.yaml +90 -0
- package/knowledge/baldursgate3/dialogue.dialogbank.yaml +120 -0
- package/knowledge/baldursgate3/dialogue.files.yaml +236 -0
- package/knowledge/baldursgate3/dialogue.osiris-goals.yaml +386 -0
- package/knowledge/baldursgate3/dialogue.yaml +122 -0
- package/knowledge/baldursgate3/feats.classes.yaml +164 -0
- package/knowledge/baldursgate3/items.cloth-physics.yaml +167 -0
- package/knowledge/baldursgate3/items.roottemplates.yaml +320 -0
- package/knowledge/baldursgate3/items.visualbank.yaml +628 -0
- package/knowledge/baldursgate3/journal.quests.yaml +214 -0
- package/knowledge/baldursgate3/loadorder.modsettings.yaml +128 -0
- package/knowledge/baldursgate3/localization.handles.yaml +92 -0
- package/knowledge/baldursgate3/misc.encoding-and-practice.yaml +111 -0
- package/knowledge/baldursgate3/origins.companions.yaml +144 -0
- package/knowledge/baldursgate3/osiris.signatures.yaml +211 -0
- package/knowledge/baldursgate3/packaging.meta.yaml +155 -0
- package/knowledge/baldursgate3/packaging.paks.yaml +79 -0
- package/knowledge/baldursgate3/process.launch.yaml +34 -0
- package/knowledge/baldursgate3/progressions.yaml +92 -0
- package/knowledge/baldursgate3/publishing.modio-nexus.yaml +170 -0
- package/knowledge/baldursgate3/publishing.toolkit-modio.yaml +135 -0
- package/knowledge/baldursgate3/races.progression.yaml +228 -0
- package/knowledge/baldursgate3/scriptextender.console.yaml +257 -0
- package/knowledge/baldursgate3/scriptextender.yaml +252 -0
- package/knowledge/baldursgate3/stats.boosts.yaml +293 -0
- package/knowledge/baldursgate3/stats.equipment-kits.yaml +69 -0
- package/knowledge/baldursgate3/stats.interrupts.yaml +45 -0
- package/knowledge/baldursgate3/stats.itemcombos.yaml +65 -0
- package/knowledge/baldursgate3/stats.spells.yaml +293 -0
- package/knowledge/baldursgate3/stats.weapons.yaml +210 -0
- package/knowledge/baldursgate3/toolchain.divine.yaml +179 -0
- package/knowledge/baldursgate3/toolchain.lslib-formats.yaml +242 -0
- package/knowledge/baldursgate3/toolkit.levels.yaml +177 -0
- package/knowledge/baldursgate3/ui.icons-atlas.yaml +78 -0
- package/knowledge/baldursgate3/ui.icons.yaml +412 -0
- package/knowledge/baldursgate3/ui.mcm.yaml +161 -0
- package/knowledge/baldursgate3/vfx.materials.yaml +174 -0
- package/knowledge/baldursgate3/visuals.characterfix.yaml +73 -0
- package/knowledge/cyberpunk2077/animations.anims.yaml +118 -0
- package/knowledge/cyberpunk2077/anims.archivexl.yaml +163 -0
- package/knowledge/cyberpunk2077/anims.authoring.yaml +579 -0
- package/knowledge/cyberpunk2077/anims.encoder.yaml +156 -0
- package/knowledge/cyberpunk2077/anims.graph.yaml +629 -0
- package/knowledge/cyberpunk2077/anims.method.yaml +360 -0
- package/knowledge/cyberpunk2077/anims.pipeline.yaml +352 -0
- package/knowledge/cyberpunk2077/anims.roundtrip.yaml +222 -0
- package/knowledge/cyberpunk2077/anims.sets.yaml +176 -0
- package/knowledge/cyberpunk2077/archivexl.bodytypes.yaml +149 -0
- package/knowledge/cyberpunk2077/archivexl.dynamic-appearances.yaml +218 -0
- package/knowledge/cyberpunk2077/archivexl.manifest.yaml +214 -0
- package/knowledge/cyberpunk2077/audio.events.yaml +168 -0
- package/knowledge/cyberpunk2077/audio.sounds.yaml +164 -0
- package/knowledge/cyberpunk2077/audio.voicesets.yaml +146 -0
- package/knowledge/cyberpunk2077/cet.sandbox.yaml +219 -0
- package/knowledge/cyberpunk2077/clothing.garments.yaml +283 -0
- package/knowledge/cyberpunk2077/clothing.refits.yaml +215 -0
- package/knowledge/cyberpunk2077/codeware.overview.yaml +111 -0
- package/knowledge/cyberpunk2077/codeware.systems.yaml +192 -0
- package/knowledge/cyberpunk2077/drones.combat.yaml +416 -0
- package/knowledge/cyberpunk2077/drones.control.yaml +552 -0
- package/knowledge/cyberpunk2077/entities.appearance.yaml +166 -0
- package/knowledge/cyberpunk2077/equipmentex.slots.yaml +151 -0
- package/knowledge/cyberpunk2077/fx.effects.yaml +246 -0
- package/knowledge/cyberpunk2077/fx.lights.yaml +171 -0
- package/knowledge/cyberpunk2077/hair.modding.yaml +145 -0
- package/knowledge/cyberpunk2077/items.wiring.yaml +246 -0
- package/knowledge/cyberpunk2077/loadorder.archives.yaml +71 -0
- package/knowledge/cyberpunk2077/mesh.blender.yaml +209 -0
- package/knowledge/cyberpunk2077/nativedb.dump.yaml +98 -0
- package/knowledge/cyberpunk2077/npc.appearance.yaml +275 -0
- package/knowledge/cyberpunk2077/npc.behaviour.yaml +128 -0
- package/knowledge/cyberpunk2077/npc.locomotion.yaml +490 -0
- package/knowledge/cyberpunk2077/packaging.deploy.yaml +175 -0
- package/knowledge/cyberpunk2077/packaging.variants.yaml +176 -0
- package/knowledge/cyberpunk2077/player.control.yaml +918 -0
- package/knowledge/cyberpunk2077/process.assetbuild.yaml +154 -0
- package/knowledge/cyberpunk2077/process.lessons.yaml +276 -0
- package/knowledge/cyberpunk2077/quests.minor.yaml +46 -0
- package/knowledge/cyberpunk2077/quests.scenes.yaml +282 -0
- package/knowledge/cyberpunk2077/quickhacks.tiers.yaml +41 -0
- package/knowledge/cyberpunk2077/red4ext.api.yaml +645 -0
- package/knowledge/cyberpunk2077/red4ext.plugins.yaml +124 -0
- package/knowledge/cyberpunk2077/redhottools.hotreload.yaml +245 -0
- package/knowledge/cyberpunk2077/redscript.compile-log.yaml +76 -0
- package/knowledge/cyberpunk2077/redscript.modules.yaml +118 -0
- package/knowledge/cyberpunk2077/toolchain.wolvenkit.yaml +163 -0
- package/knowledge/cyberpunk2077/tweakdb.loot-recipes.yaml +184 -0
- package/knowledge/cyberpunk2077/tweakdb.melee.yaml +352 -0
- package/knowledge/cyberpunk2077/tweakdb.weapons.yaml +325 -0
- package/knowledge/cyberpunk2077/tweakxl.hotreload.yaml +151 -0
- package/knowledge/cyberpunk2077/tweakxl.yaml-syntax.yaml +208 -0
- package/knowledge/cyberpunk2077/ui.icons.yaml +259 -0
- package/knowledge/cyberpunk2077/ui.inkatlas.yaml +81 -0
- package/knowledge/cyberpunk2077/ui.modsettings.yaml +204 -0
- package/knowledge/cyberpunk2077/vehicles.control.yaml +475 -0
- package/knowledge/cyberpunk2077/vehicles.dashboard-ui.yaml +203 -0
- package/knowledge/cyberpunk2077/vehicles.entities.yaml +195 -0
- package/knowledge/cyberpunk2077/vehicles.wiring.yaml +137 -0
- package/knowledge/cyberpunk2077/wolvenkit.cli.yaml +167 -0
- package/knowledge/cyberpunk2077/workspot.system.yaml +55 -0
- package/knowledge/cyberpunk2077/world.interactions.yaml +41 -0
- package/knowledge/cyberpunk2077/world.loot-container.yaml +167 -0
- package/knowledge/cyberpunk2077/world.sectors.yaml +233 -0
- package/knowledge/eldenring/formats.binders.yaml +237 -0
- package/knowledge/eldenring/launcher.me3.yaml +230 -0
- package/knowledge/eldenring/launcher.modengine2.yaml +119 -0
- package/knowledge/eldenring/params.paramdef.yaml +149 -0
- package/knowledge/eldenring/params.regulation.yaml +142 -0
- package/knowledge/eldenring/saves.online.yaml +118 -0
- package/knowledge/eldenring/toolchain.cli.yaml +256 -0
- package/knowledge/nivalisnights/modding.runtime.yaml +157 -0
- package/knowledge/skyrimse/archives.bsa.yaml +212 -0
- package/knowledge/skyrimse/install.detection.yaml +41 -0
- package/knowledge/skyrimse/loadorder.files.yaml +242 -0
- package/knowledge/skyrimse/plugins.esl.yaml +189 -0
- package/knowledge/skyrimse/plugins.format.yaml +224 -0
- package/knowledge/skyrimse/skse.runtime.yaml +283 -0
- package/knowledge/skyrimse/toolchain.xedit-spriggit.yaml +336 -0
- package/knowledge/stardewvalley/contentpatcher.format.yaml +338 -0
- package/knowledge/stardewvalley/distribution.channels.yaml +236 -0
- package/knowledge/stardewvalley/game.versions.yaml +202 -0
- package/knowledge/stardewvalley/install.layout.yaml +277 -0
- package/knowledge/stardewvalley/smapi.loader.yaml +284 -0
- package/knowledge/stardewvalley/smapi.logs.yaml +329 -0
- package/knowledge/stardewvalley/smapi.manifest.yaml +293 -0
- package/knowledge/stardewvalley/toolchain.build.yaml +261 -0
- package/knowledge/stardewvalley/wiki.dataformat.yaml +130 -0
- package/knowledge/subnautica2/game.build.yaml +331 -0
- package/knowledge/subnautica2/modding.state.yaml +210 -0
- package/knowledge/subnautica2/ue5.containers.yaml +72 -0
- package/knowledge/subnautica2/ue5.paks.yaml +203 -0
- package/knowledge/subnautica2/ue5.tooling.yaml +175 -0
- package/knowledge/subnautica2/ue5.ue4ss.yaml +203 -0
- package/knowledge/valheim/bepinex.loader.yaml +247 -0
- package/knowledge/valheim/bepinex.plugins.yaml +251 -0
- package/knowledge/valheim/game.versions.yaml +321 -0
- package/knowledge/valheim/install.layout.yaml +216 -0
- package/knowledge/valheim/jotunn.library.yaml +334 -0
- package/knowledge/valheim/thunderstore.packaging.yaml +217 -0
- package/knowledge/valheim/toolchain.build.yaml +111 -0
- package/package.json +29 -0
- package/scaffolds/baldursgate3/new-class-injection.yaml +148 -0
- package/scaffolds/baldursgate3/new-item.yaml +264 -0
- package/scaffolds/baldursgate3/new-mod.yaml +174 -0
- package/scaffolds/baldursgate3/new-passive.yaml +100 -0
- package/scaffolds/baldursgate3/new-project.yaml +118 -0
- package/scaffolds/baldursgate3/new-quest-stub.yaml +159 -0
- package/scaffolds/baldursgate3/new-spell.yaml +102 -0
- package/scaffolds/baldursgate3/new-status.yaml +119 -0
- package/scaffolds/baldursgate3/sequences/subclass-kit.yaml +50 -0
- package/scaffolds/cyberpunk2077/edit-tweak.yaml +70 -0
- package/scaffolds/cyberpunk2077/mesh-export-preset.yaml +170 -0
- package/scaffolds/cyberpunk2077/new-entity-patch.yaml +255 -0
- package/scaffolds/cyberpunk2077/new-garment-refit.yaml +279 -0
- package/scaffolds/cyberpunk2077/new-item-chain.yaml +548 -0
- package/scaffolds/cyberpunk2077/new-localization.yaml +130 -0
- package/scaffolds/cyberpunk2077/new-mod-settings.yaml +133 -0
- package/scaffolds/cyberpunk2077/new-player-replacer.yaml +1003 -0
- package/scaffolds/cyberpunk2077/new-project.yaml +157 -0
- package/scaffolds/cyberpunk2077/new-sector-node.yaml +156 -0
- package/scaffolds/cyberpunk2077/new-tweak.yaml +121 -0
- package/scaffolds/cyberpunk2077/new-vehicle-livery.yaml +148 -0
- package/scaffolds/cyberpunk2077/new-workspot-entity.yaml +177 -0
- package/scaffolds/cyberpunk2077/sequences/iconic-weapon.yaml +72 -0
- package/scaffolds/cyberpunk2077/sequences/quickhack-takeover.yaml +213 -0
- package/scaffolds/stardewvalley/new-cp-patch.yaml +106 -0
- package/scaffolds/stardewvalley/new-csharp-mod.yaml +195 -0
- package/scaffolds/stardewvalley/new-project.yaml +184 -0
- package/scaffolds/stardewvalley/sequences/content-pack.yaml +31 -0
- package/scripts/mw-tool.mjs +184 -0
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
import { TweakParseError } from "../model.js";
|
|
2
|
+
const TYPE_KEYWORDS = new Set([
|
|
3
|
+
"int",
|
|
4
|
+
"float",
|
|
5
|
+
"bool",
|
|
6
|
+
"string",
|
|
7
|
+
"CName",
|
|
8
|
+
"LocKey",
|
|
9
|
+
"ResRef",
|
|
10
|
+
"TweakDBID",
|
|
11
|
+
"Quaternion",
|
|
12
|
+
"EulerAngles",
|
|
13
|
+
"Vector2",
|
|
14
|
+
"Vector3",
|
|
15
|
+
]);
|
|
16
|
+
const TUPLE_TYPES = new Set(["Quaternion", "EulerAngles", "Vector2", "Vector3"]);
|
|
17
|
+
function isIdentStart(ch) {
|
|
18
|
+
return /[A-Za-z_]/.test(ch);
|
|
19
|
+
}
|
|
20
|
+
function isIdentPart(ch) {
|
|
21
|
+
return /[A-Za-z0-9_]/.test(ch);
|
|
22
|
+
}
|
|
23
|
+
function isDigit(ch) {
|
|
24
|
+
return /[0-9]/.test(ch);
|
|
25
|
+
}
|
|
26
|
+
function tokenize(text, file) {
|
|
27
|
+
const tokens = [];
|
|
28
|
+
let i = 0;
|
|
29
|
+
let line = 1;
|
|
30
|
+
const n = text.length;
|
|
31
|
+
function advance(count = 1) {
|
|
32
|
+
for (let k = 0; k < count; k++) {
|
|
33
|
+
if (text[i] === "\n")
|
|
34
|
+
line++;
|
|
35
|
+
i++;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
while (i < n) {
|
|
39
|
+
const ch = text[i];
|
|
40
|
+
if (ch === "\n" || ch === "\r" || ch === " " || ch === "\t") {
|
|
41
|
+
advance();
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (ch === "/" && text[i + 1] === "/") {
|
|
45
|
+
while (i < n && text[i] !== "\n")
|
|
46
|
+
i++;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (ch === "/" && text[i + 1] === "*") {
|
|
50
|
+
const startLine = line;
|
|
51
|
+
advance(2);
|
|
52
|
+
let closed = false;
|
|
53
|
+
while (i < n) {
|
|
54
|
+
if (text[i] === "*" && text[i + 1] === "/") {
|
|
55
|
+
advance(2);
|
|
56
|
+
closed = true;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
advance();
|
|
60
|
+
}
|
|
61
|
+
if (!closed)
|
|
62
|
+
throw new TweakParseError("unterminated block comment", file, startLine);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const startLine = line;
|
|
66
|
+
if (ch === '"') {
|
|
67
|
+
advance();
|
|
68
|
+
let value = "";
|
|
69
|
+
let closed = false;
|
|
70
|
+
while (i < n) {
|
|
71
|
+
const c = text[i];
|
|
72
|
+
if (c === "\\" && (text[i + 1] === '"' || text[i + 1] === "\\")) {
|
|
73
|
+
value += text[i + 1];
|
|
74
|
+
advance(2);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (c === '"') {
|
|
78
|
+
advance();
|
|
79
|
+
closed = true;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
if (c === "\n")
|
|
83
|
+
break;
|
|
84
|
+
value += c;
|
|
85
|
+
advance();
|
|
86
|
+
}
|
|
87
|
+
if (!closed)
|
|
88
|
+
throw new TweakParseError("unterminated string literal", file, startLine);
|
|
89
|
+
tokens.push({ type: "string", text: value, line: startLine });
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (isDigit(ch) ||
|
|
93
|
+
(ch === "." && isDigit(text[i + 1] ?? "")) ||
|
|
94
|
+
(ch === "-" && (isDigit(text[i + 1] ?? "") || (text[i + 1] === "." && isDigit(text[i + 2] ?? ""))))) {
|
|
95
|
+
let raw = "";
|
|
96
|
+
if (ch === "-") {
|
|
97
|
+
raw += "-";
|
|
98
|
+
advance();
|
|
99
|
+
}
|
|
100
|
+
while (i < n && isDigit(text[i])) {
|
|
101
|
+
raw += text[i];
|
|
102
|
+
advance();
|
|
103
|
+
}
|
|
104
|
+
if (text[i] === "." && (isDigit(text[i + 1] ?? "") || text[i + 1] === "f" || text[i + 1] === "F" || text[i + 1] === ";" || text[i + 1] === "," || text[i + 1] === ")" || text[i + 1] === "]" || text[i + 1] === " ")) {
|
|
105
|
+
raw += ".";
|
|
106
|
+
advance();
|
|
107
|
+
while (i < n && isDigit(text[i])) {
|
|
108
|
+
raw += text[i];
|
|
109
|
+
advance();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (text[i] === "f" || text[i] === "F") {
|
|
113
|
+
raw += text[i];
|
|
114
|
+
advance();
|
|
115
|
+
}
|
|
116
|
+
tokens.push({ type: "number", text: raw, line: startLine });
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (isIdentStart(ch)) {
|
|
120
|
+
let raw = "";
|
|
121
|
+
while (i < n && isIdentPart(text[i])) {
|
|
122
|
+
raw += text[i];
|
|
123
|
+
advance();
|
|
124
|
+
}
|
|
125
|
+
while (text[i] === "." && isIdentStart(text[i + 1] ?? "")) {
|
|
126
|
+
raw += ".";
|
|
127
|
+
advance();
|
|
128
|
+
while (i < n && isIdentPart(text[i])) {
|
|
129
|
+
raw += text[i];
|
|
130
|
+
advance();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
tokens.push({ type: "ident", text: raw, line: startLine });
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
switch (ch) {
|
|
137
|
+
case "{":
|
|
138
|
+
tokens.push({ type: "lbrace", text: ch, line: startLine });
|
|
139
|
+
advance();
|
|
140
|
+
continue;
|
|
141
|
+
case "}":
|
|
142
|
+
tokens.push({ type: "rbrace", text: ch, line: startLine });
|
|
143
|
+
advance();
|
|
144
|
+
continue;
|
|
145
|
+
case "[":
|
|
146
|
+
tokens.push({ type: "lbracket", text: ch, line: startLine });
|
|
147
|
+
advance();
|
|
148
|
+
continue;
|
|
149
|
+
case "]":
|
|
150
|
+
tokens.push({ type: "rbracket", text: ch, line: startLine });
|
|
151
|
+
advance();
|
|
152
|
+
continue;
|
|
153
|
+
case "(":
|
|
154
|
+
tokens.push({ type: "lparen", text: ch, line: startLine });
|
|
155
|
+
advance();
|
|
156
|
+
continue;
|
|
157
|
+
case ")":
|
|
158
|
+
tokens.push({ type: "rparen", text: ch, line: startLine });
|
|
159
|
+
advance();
|
|
160
|
+
continue;
|
|
161
|
+
case ":":
|
|
162
|
+
tokens.push({ type: "colon", text: ch, line: startLine });
|
|
163
|
+
advance();
|
|
164
|
+
continue;
|
|
165
|
+
case ";":
|
|
166
|
+
tokens.push({ type: "semi", text: ch, line: startLine });
|
|
167
|
+
advance();
|
|
168
|
+
continue;
|
|
169
|
+
case ",":
|
|
170
|
+
tokens.push({ type: "comma", text: ch, line: startLine });
|
|
171
|
+
advance();
|
|
172
|
+
continue;
|
|
173
|
+
case "<":
|
|
174
|
+
tokens.push({ type: "lt", text: ch, line: startLine });
|
|
175
|
+
advance();
|
|
176
|
+
continue;
|
|
177
|
+
case ">":
|
|
178
|
+
tokens.push({ type: "gt", text: ch, line: startLine });
|
|
179
|
+
advance();
|
|
180
|
+
continue;
|
|
181
|
+
case "=":
|
|
182
|
+
advance();
|
|
183
|
+
tokens.push({ type: "eq", text: "=", line: startLine });
|
|
184
|
+
continue;
|
|
185
|
+
case "+":
|
|
186
|
+
if (text[i + 1] === "=") {
|
|
187
|
+
advance(2);
|
|
188
|
+
tokens.push({ type: "pluseq", text: "+=", line: startLine });
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
throw new TweakParseError(`unexpected character '${ch}'`, file, startLine);
|
|
192
|
+
case "-":
|
|
193
|
+
if (text[i + 1] === "=") {
|
|
194
|
+
advance(2);
|
|
195
|
+
tokens.push({ type: "minuseq", text: "-=", line: startLine });
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
throw new TweakParseError(`unexpected character '${ch}'`, file, startLine);
|
|
199
|
+
default:
|
|
200
|
+
throw new TweakParseError(`unexpected character '${ch}'`, file, startLine);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
tokens.push({ type: "eof", text: "", line: line });
|
|
204
|
+
return tokens;
|
|
205
|
+
}
|
|
206
|
+
class Parser {
|
|
207
|
+
tokens;
|
|
208
|
+
file;
|
|
209
|
+
pos = 0;
|
|
210
|
+
pkg = "";
|
|
211
|
+
inlineCounters = new Map();
|
|
212
|
+
inlineRoot;
|
|
213
|
+
declaredNames = new Set();
|
|
214
|
+
records = [];
|
|
215
|
+
constructor(tokens, file) {
|
|
216
|
+
this.tokens = tokens;
|
|
217
|
+
this.file = file;
|
|
218
|
+
}
|
|
219
|
+
peek(offset = 0) {
|
|
220
|
+
return this.tokens[Math.min(this.pos + offset, this.tokens.length - 1)];
|
|
221
|
+
}
|
|
222
|
+
next() {
|
|
223
|
+
const t = this.tokens[this.pos];
|
|
224
|
+
if (this.pos < this.tokens.length - 1)
|
|
225
|
+
this.pos++;
|
|
226
|
+
return t;
|
|
227
|
+
}
|
|
228
|
+
expect(type, what) {
|
|
229
|
+
const t = this.peek();
|
|
230
|
+
if (t.type !== type) {
|
|
231
|
+
throw new TweakParseError(`expected ${what}, found '${t.text || t.type}'`, this.file, t.line);
|
|
232
|
+
}
|
|
233
|
+
return this.next();
|
|
234
|
+
}
|
|
235
|
+
qualify(name) {
|
|
236
|
+
if (name.includes(".") || !this.pkg)
|
|
237
|
+
return name;
|
|
238
|
+
return `${this.pkg}.${name}`;
|
|
239
|
+
}
|
|
240
|
+
parse() {
|
|
241
|
+
if (this.peek().type === "ident" && this.peek().text === "package") {
|
|
242
|
+
this.next();
|
|
243
|
+
const name = this.expect("ident", "package name");
|
|
244
|
+
this.pkg = name.text;
|
|
245
|
+
}
|
|
246
|
+
while (this.peek().type === "ident" && this.peek().text === "using") {
|
|
247
|
+
this.next();
|
|
248
|
+
this.expect("ident", "using target");
|
|
249
|
+
while (this.peek().type === "comma") {
|
|
250
|
+
this.next();
|
|
251
|
+
this.expect("ident", "using target");
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
while (this.peek().type !== "eof") {
|
|
255
|
+
if (this.skipTagGroup())
|
|
256
|
+
continue;
|
|
257
|
+
const t = this.peek();
|
|
258
|
+
if (t.type === "ident" && (TYPE_KEYWORDS.has(t.text) || (t.text === "fk" && this.peek(1).type === "lt"))) {
|
|
259
|
+
const owner = this.pkg || "Global";
|
|
260
|
+
this.packageFlats.push(this.parseMember(owner));
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
this.parseBlock();
|
|
264
|
+
}
|
|
265
|
+
if (this.packageFlats.length > 0) {
|
|
266
|
+
const owner = this.pkg || "Global";
|
|
267
|
+
this.records.push({ name: owner, flats: this.packageFlats, file: this.file, line: 1 });
|
|
268
|
+
this.declaredNames.add(owner);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
skipTagGroup() {
|
|
272
|
+
if (this.peek().type === "lbracket" && this.peek(1).type === "ident" && this.peek(2).type === "rbracket") {
|
|
273
|
+
this.next();
|
|
274
|
+
this.next();
|
|
275
|
+
this.next();
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
packageFlats = [];
|
|
281
|
+
parseBlock() {
|
|
282
|
+
const nameTok = this.expect("ident", "record or group name");
|
|
283
|
+
const line = nameTok.line;
|
|
284
|
+
let base;
|
|
285
|
+
let type;
|
|
286
|
+
if (this.peek().type === "colon") {
|
|
287
|
+
this.next();
|
|
288
|
+
const targetTok = this.expect("ident", "base record or type name");
|
|
289
|
+
if (targetTok.text.includes(".")) {
|
|
290
|
+
base = targetTok.text;
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
const qualified = this.qualify(targetTok.text);
|
|
294
|
+
if (this.declaredNames.has(qualified))
|
|
295
|
+
base = qualified;
|
|
296
|
+
else
|
|
297
|
+
type = targetTok.text;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
this.expect("lbrace", "'{'");
|
|
301
|
+
const owner = this.qualify(nameTok.text);
|
|
302
|
+
const flats = this.parseMembers(owner);
|
|
303
|
+
this.expect("rbrace", "'}'");
|
|
304
|
+
this.records.push({ name: owner, base, type, flats, file: this.file, line });
|
|
305
|
+
this.declaredNames.add(owner);
|
|
306
|
+
}
|
|
307
|
+
nextInlineName(owner) {
|
|
308
|
+
const count = this.inlineCounters.get(owner) ?? 0;
|
|
309
|
+
this.inlineCounters.set(owner, count + 1);
|
|
310
|
+
return `${owner}_inline${count}`;
|
|
311
|
+
}
|
|
312
|
+
parseMembers(owner) {
|
|
313
|
+
const flats = [];
|
|
314
|
+
while (this.peek().type !== "rbrace") {
|
|
315
|
+
if (this.skipTagGroup())
|
|
316
|
+
continue;
|
|
317
|
+
flats.push(this.parseMember(owner));
|
|
318
|
+
}
|
|
319
|
+
return flats;
|
|
320
|
+
}
|
|
321
|
+
parseMember(owner) {
|
|
322
|
+
{
|
|
323
|
+
const first = this.peek();
|
|
324
|
+
if (first.type !== "ident") {
|
|
325
|
+
throw new TweakParseError(`expected a flat name or type, found '${first.text || first.type}'`, this.file, first.line);
|
|
326
|
+
}
|
|
327
|
+
let typeToken;
|
|
328
|
+
if (TYPE_KEYWORDS.has(first.text)) {
|
|
329
|
+
typeToken = this.next().text;
|
|
330
|
+
}
|
|
331
|
+
else if (first.text === "fk" && this.peek(1).type === "lt") {
|
|
332
|
+
this.next();
|
|
333
|
+
this.next();
|
|
334
|
+
const inner = this.expect("ident", "fk<Type> target");
|
|
335
|
+
this.expect("gt", "'>'");
|
|
336
|
+
typeToken = `fk<${inner.text}>`;
|
|
337
|
+
}
|
|
338
|
+
if (typeToken && this.peek().type === "lbracket" && this.peek(1).type === "rbracket") {
|
|
339
|
+
this.next();
|
|
340
|
+
this.next();
|
|
341
|
+
typeToken = `${typeToken}[]`;
|
|
342
|
+
}
|
|
343
|
+
const nameTok = this.expect("ident", "flat name");
|
|
344
|
+
const opTok = this.peek();
|
|
345
|
+
let op;
|
|
346
|
+
if (opTok.type === "eq") {
|
|
347
|
+
op = "set";
|
|
348
|
+
this.next();
|
|
349
|
+
}
|
|
350
|
+
else if (opTok.type === "pluseq") {
|
|
351
|
+
op = "append";
|
|
352
|
+
this.next();
|
|
353
|
+
}
|
|
354
|
+
else if (opTok.type === "minuseq") {
|
|
355
|
+
op = "remove";
|
|
356
|
+
this.next();
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
throw new TweakParseError(`expected '=', '+=' or '-=', found '${opTok.text || opTok.type}'`, this.file, opTok.line);
|
|
360
|
+
}
|
|
361
|
+
const { value, kind } = typeToken
|
|
362
|
+
? this.parseTypedValue(typeToken, owner)
|
|
363
|
+
: this.parseUntypedValue(owner);
|
|
364
|
+
this.expect("semi", "';'");
|
|
365
|
+
return { name: nameTok.text, value, kind: typeToken ?? kind, op };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
parseTypedValue(typeToken, owner) {
|
|
369
|
+
const base = typeToken.replace(/\[\]$/, "");
|
|
370
|
+
const isArray = typeToken.endsWith("[]");
|
|
371
|
+
if (isArray) {
|
|
372
|
+
this.expect("lbracket", "'['");
|
|
373
|
+
const items = [];
|
|
374
|
+
while (this.peek().type !== "rbracket") {
|
|
375
|
+
items.push(this.parseTypedScalar(base, owner));
|
|
376
|
+
if (this.peek().type === "comma")
|
|
377
|
+
this.next();
|
|
378
|
+
else
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
this.expect("rbracket", "']'");
|
|
382
|
+
return { value: items, kind: typeToken };
|
|
383
|
+
}
|
|
384
|
+
return { value: this.parseTypedScalar(base, owner), kind: typeToken };
|
|
385
|
+
}
|
|
386
|
+
parseTypedScalar(base, owner) {
|
|
387
|
+
if (TUPLE_TYPES.has(base))
|
|
388
|
+
return this.parseTuple();
|
|
389
|
+
if (base === "int")
|
|
390
|
+
return parseInt(this.expect("number", "integer literal").text, 10);
|
|
391
|
+
if (base === "float")
|
|
392
|
+
return parseFloat(this.expect("number", "float literal").text);
|
|
393
|
+
if (base === "bool")
|
|
394
|
+
return this.parseBool();
|
|
395
|
+
if (this.peek().type === "lbrace")
|
|
396
|
+
return this.parseInlineRecord(owner);
|
|
397
|
+
return this.expect("string", `${base} string literal`).text;
|
|
398
|
+
}
|
|
399
|
+
parseBool() {
|
|
400
|
+
const t = this.peek();
|
|
401
|
+
if (t.type === "ident" && (t.text === "true" || t.text === "false")) {
|
|
402
|
+
this.next();
|
|
403
|
+
return t.text === "true";
|
|
404
|
+
}
|
|
405
|
+
throw new TweakParseError(`expected 'true' or 'false', found '${t.text || t.type}'`, this.file, t.line);
|
|
406
|
+
}
|
|
407
|
+
parseTuple() {
|
|
408
|
+
this.expect("lparen", "'('");
|
|
409
|
+
const nums = [];
|
|
410
|
+
while (this.peek().type !== "rparen") {
|
|
411
|
+
const numTok = this.expect("number", "number in tuple");
|
|
412
|
+
nums.push(parseFloat(numTok.text));
|
|
413
|
+
if (this.peek().type === "comma")
|
|
414
|
+
this.next();
|
|
415
|
+
else
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
this.expect("rparen", "')'");
|
|
419
|
+
return nums;
|
|
420
|
+
}
|
|
421
|
+
parseUntypedValue(owner) {
|
|
422
|
+
const t = this.peek();
|
|
423
|
+
switch (t.type) {
|
|
424
|
+
case "number": {
|
|
425
|
+
this.next();
|
|
426
|
+
const isFloat = t.text.includes(".") || /[fF]$/.test(t.text);
|
|
427
|
+
return { value: isFloat ? parseFloat(t.text) : parseInt(t.text, 10), kind: isFloat ? "number" : "number" };
|
|
428
|
+
}
|
|
429
|
+
case "string":
|
|
430
|
+
this.next();
|
|
431
|
+
return { value: t.text, kind: "string" };
|
|
432
|
+
case "ident":
|
|
433
|
+
if (t.text === "true" || t.text === "false") {
|
|
434
|
+
this.next();
|
|
435
|
+
return { value: t.text === "true", kind: "bool" };
|
|
436
|
+
}
|
|
437
|
+
throw new TweakParseError(`unexpected identifier '${t.text}' as a value`, this.file, t.line);
|
|
438
|
+
case "lparen":
|
|
439
|
+
return { value: this.parseTuple(), kind: "tuple" };
|
|
440
|
+
case "lbracket": {
|
|
441
|
+
this.next();
|
|
442
|
+
const items = [];
|
|
443
|
+
while (this.peek().type !== "rbracket") {
|
|
444
|
+
items.push(this.parseUntypedValue(owner).value);
|
|
445
|
+
if (this.peek().type === "comma")
|
|
446
|
+
this.next();
|
|
447
|
+
else
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
this.expect("rbracket", "']'");
|
|
451
|
+
return { value: items, kind: "array" };
|
|
452
|
+
}
|
|
453
|
+
case "lbrace":
|
|
454
|
+
return { value: this.parseInlineRecord(owner), kind: "record" };
|
|
455
|
+
default:
|
|
456
|
+
throw new TweakParseError(`unexpected token '${t.text || t.type}' where a value was expected`, this.file, t.line);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
parseInlineRecord(owner) {
|
|
460
|
+
const openTok = this.expect("lbrace", "'{'");
|
|
461
|
+
const outerRoot = this.inlineRoot;
|
|
462
|
+
const root = outerRoot ?? owner;
|
|
463
|
+
const name = this.nextInlineName(root);
|
|
464
|
+
this.inlineRoot = root;
|
|
465
|
+
const flats = this.parseMembers(name);
|
|
466
|
+
this.inlineRoot = outerRoot;
|
|
467
|
+
this.expect("rbrace", "'}'");
|
|
468
|
+
let type;
|
|
469
|
+
if (this.peek().type === "colon") {
|
|
470
|
+
this.next();
|
|
471
|
+
type = this.expect("ident", "inline record type").text;
|
|
472
|
+
}
|
|
473
|
+
this.records.push({ name, type, flats, file: this.file, line: openTok.line });
|
|
474
|
+
this.declaredNames.add(name);
|
|
475
|
+
return name;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
export function parseTweakFile(text, file) {
|
|
479
|
+
const tokens = tokenize(text, file);
|
|
480
|
+
const parser = new Parser(tokens, file);
|
|
481
|
+
parser.parse();
|
|
482
|
+
return parser.records;
|
|
483
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as YAML from "yaml";
|
|
2
|
+
import { TweakParseError } from "../model.js";
|
|
3
|
+
function toIR(node) {
|
|
4
|
+
if (node === null || node === undefined)
|
|
5
|
+
return { kind: "scalar", value: null };
|
|
6
|
+
if (YAML.isScalar(node))
|
|
7
|
+
return { kind: "scalar", value: node.value ?? null, tag: node.tag };
|
|
8
|
+
if (YAML.isSeq(node))
|
|
9
|
+
return { kind: "seq", tag: node.tag, items: node.items.map(toIR) };
|
|
10
|
+
if (YAML.isMap(node)) {
|
|
11
|
+
return {
|
|
12
|
+
kind: "map",
|
|
13
|
+
tag: node.tag,
|
|
14
|
+
entries: node.items.map((pair) => ({
|
|
15
|
+
key: String(YAML.isScalar(pair.key) ? pair.key.value : pair.key),
|
|
16
|
+
value: toIR(pair.value),
|
|
17
|
+
})),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return { kind: "scalar", value: node };
|
|
21
|
+
}
|
|
22
|
+
const OP_TAGS = {
|
|
23
|
+
"!append": "append",
|
|
24
|
+
"!append-once": "append",
|
|
25
|
+
"!append-from": "append",
|
|
26
|
+
"!prepend": "append",
|
|
27
|
+
"!prepend-once": "append",
|
|
28
|
+
"!prepend-from": "append",
|
|
29
|
+
"!remove": "remove",
|
|
30
|
+
};
|
|
31
|
+
function tagToOp(tag) {
|
|
32
|
+
return tag ? OP_TAGS[tag] : undefined;
|
|
33
|
+
}
|
|
34
|
+
function hasBaseOrType(node) {
|
|
35
|
+
return node.kind === "map" && node.entries.some((e) => e.key === "$base" || e.key === "$type");
|
|
36
|
+
}
|
|
37
|
+
const VAR_RE = /\$\(([^)]+)\)/g;
|
|
38
|
+
function substituteText(text, bindings) {
|
|
39
|
+
return text.replace(VAR_RE, (whole, name) => (name in bindings ? bindings[name] : whole));
|
|
40
|
+
}
|
|
41
|
+
function substituteIR(node, bindings) {
|
|
42
|
+
if (node.kind === "scalar") {
|
|
43
|
+
return typeof node.value === "string" ? { ...node, value: substituteText(node.value, bindings) } : node;
|
|
44
|
+
}
|
|
45
|
+
if (node.kind === "seq")
|
|
46
|
+
return { ...node, items: node.items.map((i) => substituteIR(i, bindings)) };
|
|
47
|
+
return { ...node, entries: node.entries.map((e) => ({ key: e.key, value: substituteIR(e.value, bindings) })) };
|
|
48
|
+
}
|
|
49
|
+
function inferScalarKind(value) {
|
|
50
|
+
if (typeof value === "number")
|
|
51
|
+
return "number";
|
|
52
|
+
if (typeof value === "boolean")
|
|
53
|
+
return "bool";
|
|
54
|
+
if (value === null)
|
|
55
|
+
return "null";
|
|
56
|
+
return "string";
|
|
57
|
+
}
|
|
58
|
+
function nextInlineName(ctx, owner) {
|
|
59
|
+
const n = ctx.inlineCounters.get(owner) ?? 0;
|
|
60
|
+
ctx.inlineCounters.set(owner, n + 1);
|
|
61
|
+
return `${owner}_inline${n}`;
|
|
62
|
+
}
|
|
63
|
+
function resolveValue(node, owner, line, ctx) {
|
|
64
|
+
if (node.kind === "scalar")
|
|
65
|
+
return node.value;
|
|
66
|
+
if (node.kind === "seq")
|
|
67
|
+
return node.items.map((item) => resolveValue(item, owner, line, ctx));
|
|
68
|
+
if (hasBaseOrType(node)) {
|
|
69
|
+
const name = nextInlineName(ctx, owner);
|
|
70
|
+
buildRecord(name, node, line, ctx);
|
|
71
|
+
return name;
|
|
72
|
+
}
|
|
73
|
+
const obj = {};
|
|
74
|
+
for (const entry of node.entries)
|
|
75
|
+
obj[entry.key] = resolveValue(entry.value, owner, line, ctx);
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
function buildFlatsForEntry(key, value, owner, line, ctx) {
|
|
79
|
+
if (value.kind === "seq") {
|
|
80
|
+
const wholeOp = tagToOp(value.tag);
|
|
81
|
+
if (wholeOp) {
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
name: key,
|
|
85
|
+
value: value.items.map((item) => resolveValue(item, owner, line, ctx)),
|
|
86
|
+
kind: "array",
|
|
87
|
+
op: wholeOp,
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
const order = [];
|
|
92
|
+
const groups = new Map();
|
|
93
|
+
for (const item of value.items) {
|
|
94
|
+
const op = tagToOp(item.tag) ?? "set";
|
|
95
|
+
if (!groups.has(op)) {
|
|
96
|
+
groups.set(op, []);
|
|
97
|
+
order.push(op);
|
|
98
|
+
}
|
|
99
|
+
groups.get(op).push(resolveValue(item, owner, line, ctx));
|
|
100
|
+
}
|
|
101
|
+
return order.map((op) => ({ name: key, value: groups.get(op), kind: "array", op }));
|
|
102
|
+
}
|
|
103
|
+
if (value.kind === "map") {
|
|
104
|
+
const isRecord = hasBaseOrType(value);
|
|
105
|
+
const resolved = resolveValue(value, owner, line, ctx);
|
|
106
|
+
return [{ name: key, value: resolved, kind: isRecord ? "record" : "struct", op: tagToOp(value.tag) ?? "set" }];
|
|
107
|
+
}
|
|
108
|
+
return [{ name: key, value: value.value, kind: inferScalarKind(value.value), op: tagToOp(value.tag) ?? "set" }];
|
|
109
|
+
}
|
|
110
|
+
function buildRecord(name, ir, line, ctx) {
|
|
111
|
+
if (ir.kind !== "map") {
|
|
112
|
+
ctx.records.push({ name, flats: [], file: ctx.file, line });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
let base;
|
|
116
|
+
let type;
|
|
117
|
+
const flats = [];
|
|
118
|
+
for (const { key, value } of ir.entries) {
|
|
119
|
+
if (key === "$base") {
|
|
120
|
+
base = String(resolveValue(value, name, line, ctx));
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (key === "$type") {
|
|
124
|
+
type = String(resolveValue(value, name, line, ctx));
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (key === "$instances")
|
|
128
|
+
continue;
|
|
129
|
+
flats.push(...buildFlatsForEntry(key, value, name, line, ctx));
|
|
130
|
+
}
|
|
131
|
+
ctx.records.push({ name, base, type, flats, file: ctx.file, line });
|
|
132
|
+
}
|
|
133
|
+
function extractBindings(node, file, line) {
|
|
134
|
+
if (node.kind !== "map") {
|
|
135
|
+
throw new TweakParseError("each $instances entry must be a mapping of variable names to values", file, line);
|
|
136
|
+
}
|
|
137
|
+
const bindings = {};
|
|
138
|
+
for (const { key, value } of node.entries) {
|
|
139
|
+
bindings[key] = value.kind === "scalar" && value.value !== null ? String(value.value) : "";
|
|
140
|
+
}
|
|
141
|
+
return bindings;
|
|
142
|
+
}
|
|
143
|
+
export function parseTweakXLYaml(text, file) {
|
|
144
|
+
const lineCounter = new YAML.LineCounter();
|
|
145
|
+
const doc = YAML.parseDocument(text, { lineCounter });
|
|
146
|
+
if (doc.errors.length > 0) {
|
|
147
|
+
const first = doc.errors[0];
|
|
148
|
+
const line = first.pos ? lineCounter.linePos(first.pos[0]).line : 1;
|
|
149
|
+
throw new TweakParseError(first.message, file, line);
|
|
150
|
+
}
|
|
151
|
+
const root = doc.contents;
|
|
152
|
+
if (!root || !YAML.isMap(root))
|
|
153
|
+
return [];
|
|
154
|
+
const ctx = { file, records: [], inlineCounters: new Map() };
|
|
155
|
+
for (const pair of root.items) {
|
|
156
|
+
if (!YAML.isScalar(pair.key))
|
|
157
|
+
continue;
|
|
158
|
+
const rawName = String(pair.key.value);
|
|
159
|
+
const line = pair.key.range ? lineCounter.linePos(pair.key.range[0]).line : 1;
|
|
160
|
+
const bodyIR = toIR(pair.value);
|
|
161
|
+
if (bodyIR.kind !== "map") {
|
|
162
|
+
const dot = rawName.lastIndexOf(".");
|
|
163
|
+
const owner = dot === -1 ? rawName : rawName.slice(0, dot);
|
|
164
|
+
const flatName = dot === -1 ? rawName : rawName.slice(dot + 1);
|
|
165
|
+
const flats = buildFlatsForEntry(flatName, bodyIR, owner, line, ctx);
|
|
166
|
+
ctx.records.push({ name: owner, flats, file, line });
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const instancesEntry = bodyIR.entries.find((e) => e.key === "$instances");
|
|
170
|
+
if (instancesEntry && instancesEntry.value.kind === "seq" && bodyIR.kind === "map") {
|
|
171
|
+
const withoutInstances = { ...bodyIR, entries: bodyIR.entries.filter((e) => e.key !== "$instances") };
|
|
172
|
+
for (const instanceNode of instancesEntry.value.items) {
|
|
173
|
+
const bindings = extractBindings(instanceNode, file, line);
|
|
174
|
+
const expandedName = substituteText(rawName, bindings);
|
|
175
|
+
const substituted = substituteIR(withoutInstances, bindings);
|
|
176
|
+
buildRecord(expandedName, substituted, line, ctx);
|
|
177
|
+
}
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
buildRecord(rawName, bodyIR, line, ctx);
|
|
181
|
+
}
|
|
182
|
+
return ctx.records;
|
|
183
|
+
}
|