|
| 1 | +# AGENT HANDBOOK – Minecraft Dev MCP |
| 2 | + |
| 3 | +Reference for AI/agent operators working in this repo. Grounded in `CLAUDE.md` and current project state. |
| 4 | + |
| 5 | +## Project Snapshot |
| 6 | +- MCP server that lets agents decompile, remap, search, and analyze Minecraft (1.14+; obfuscated through 1.21.11). |
| 7 | +- Phase 1 & 2 complete (core + advanced tools); 29 integration tests green as of 2025-12-06. |
| 8 | +- Phase 3 focus: third-party mod analysis; missing piece is decompiling remapped mod JARs (see TODO). |
| 9 | +- Stack: Node 18+/ESM-only (`"type": "module"`), TS 5.7, Java 17+ (21+ for newest MC), better-sqlite3, VineFlower decompiler, tiny-remapper. |
| 10 | + |
| 11 | +## What Agents Should Prioritize |
| 12 | +- Keep ESM intact: no CommonJS, ensure `.js` extensions on local imports after build. |
| 13 | +- Registry extraction must use the obfuscated **server JAR** with version-aware bundler flag; never the client JAR. |
| 14 | +- Yarn remapping is two-step: official → intermediary → yarn; do not collapse into one pass. |
| 15 | +- Respect cache layout in platform app data (`jars/`, `mappings/`, `remapped/`, `decompiled/{version}/{mapping}/`, `registry/{version}/`, `resources/`, `search-index/`, `cache.db`). |
| 16 | +- VineFlower drops `libraries/`, `versions/`, `logs/` in CWD during runs; temporary and gitignored. |
| 17 | + |
| 18 | +## Architecture Wayfinder (src/) |
| 19 | +- `services/`: `version-manager` (JARs), `mapping-service` (Yarn/Mojmap/Intermediary), `remap-service` (two-step Yarn), `decompile-service` (VineFlower), `registry-service` (data generator on server JAR), `source-service` (pipeline orchestrator). |
| 20 | +- `java/`: `tiny-remapper`, `vineflower`, `mc-data-gen` (bundler vs legacy invocation), `java-process` (exec wrapper). |
| 21 | +- `downloaders/`: Mojang assets/mappings, Yarn mappings, Java tool JARs. |
| 22 | +- `cache/`: cache manager + SQLite metadata DB. |
| 23 | +- `utils/paths.ts`: resolves OS-specific cache roots. |
| 24 | + |
| 25 | +## Available MCP Tools (for LLM surfaces) |
| 26 | +- Phase 1 core: `get_minecraft_source`, `decompile_minecraft_version`, `list_minecraft_versions`, `get_registry_data`. |
| 27 | +- Phase 2 analysis: `remap_mod_jar`, `find_mapping`, `search_minecraft_code`, `compare_versions`, `analyze_mixin`, `validate_access_widener`, `compare_versions_detailed`, `index_minecraft_version`, `search_indexed`, `get_documentation`, `search_documentation`. |
| 28 | +- Phase 3: `analyze_mod_jar` (metadata/mixins/bytecode scan). Missing: decompile remapped mod JARs. |
| 29 | + |
| 30 | +## Critical Behaviors & Pitfalls |
| 31 | +- **Registry paths**: MC ≥1.21 writes `reports/registries.json`; <1.21 uses `generated/reports/registries.json`. Names are singular (`block`, `item`, `entity`), auto-prefixed with `minecraft:` if absent. |
| 32 | +- **Java invocation**: MC 1.18+ bundler needs `-DbundlerMainClass=net.minecraft.data.Main`; pre-1.18 uses `-cp` mode. |
| 33 | +- **Performance**: first decompile downloads/remaps (~400–500 MB/version). Caching makes subsequent requests near-instant. |
| 34 | +- **Integrity**: downloads are SHA-verified; cache rebuilds on corruption; Java processes run with timeouts and memory caps. |
| 35 | + |
| 36 | +## Testing & Commands |
| 37 | +- Fast suite: `npm test` (vitest, targets 1.21.10 pipeline end-to-end). |
| 38 | +- Manual/versioned suites: `npm run test:manual` (Yarn 1.21.10/1.20.1/1.19.4), `npm run test:manual:mojmap` (+ version-specific overrides). |
| 39 | +- Dev/build: `npm run dev` (tsx watch), `npm run build`, `npm run typecheck`, `npm run lint[:fix]`. |
| 40 | +- Full sweep: `npm run test:all` (CI + manual). |
| 41 | + |
| 42 | +## Active TODO / Gaps |
| 43 | +- Add **mod JAR decompilation** after remapping (reuse VineFlower); target output under `decompiled-mods/{mod-id}/{version}/{mapping}/`. New tool name suggestion: `decompile_mod_jar` or `remap_mod_jar` with `decompile` flag. |
| 44 | + |
| 45 | +## Quick Playbooks |
| 46 | +- Retrieve class source: ensure version cached → `get_minecraft_source(version, className, mapping)`; triggers download/remap/decompile if missing. |
| 47 | +- Extract registries: use `registry-service` with server JAR and version-aware path detection; fail fast on wrong registry names. |
| 48 | +- Add new mapping type: extend `MappingType`, add downloader, wire into `mapping-service`, add tests. |
| 49 | +- Add manual test for version: copy template under `__tests__/manual/vX.Y.Z`, add script `test:manual:X.Y.Z`. |
| 50 | + |
| 51 | +## Support Files & References |
| 52 | +- Primary context: `CLAUDE.md` (architecture, constraints, known issues). |
| 53 | +- Manual test guide: `__tests__/manual/README.md`. |
0 commit comments