Skip to content

Commit 270d60c

Browse files
committed
feat: Complete Phase 3 mod analysis with decompilation and search
Implements comprehensive third-party mod analysis capabilities including decompilation, search, and indexing. Completes Phase 3 milestone. New Features: - mod-decompile-service: Decompiles mod JARs to readable Java source - Auto-detection: remap_mod_jar now auto-detects MC version from mod metadata - Mod search: Full regex and FTS5 search across decompiled mod source - Database: Added mod_decompile_jobs table with progress tracking - Test suite: 12 tests validating all mod tools end-to-end Technical Changes: - Fixed database initialization to always create tables (handles schema updates) - Added Yarn mapping validation in tests (verifies class names remapped) - Extended cache manager with mod-specific operations - Added WSL/Windows path support throughout mod tools - Updated documentation to reflect Phase 3 completion Tools Added: - decompile_mod_jar: Decompile mod JARs with auto-detected metadata - search_mod_code: Regex search in decompiled mod source - index_mod: Create FTS5 index for fast searching - search_mod_indexed: Fast full-text search on indexed mods - remap_mod_jar: Enhanced with optional auto-detected MC version All 12 integration tests pass including validation that remapping correctly converts Minecraft class references from intermediary to Yarn.
1 parent 18f9567 commit 270d60c

10 files changed

Lines changed: 1592 additions & 38 deletions

File tree

.claude/settings.local.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@
3333
"Bash(git remote get-url:*)",
3434
"Skill(readme-generator)",
3535
"Skill(repo-sweep)",
36-
"Bash(git check-ignore:*)"
36+
"Bash(git check-ignore:*)",
37+
"Bash(del REMAINING_WORK.md)"
3738
]
3839
},
3940
"enableAllProjectMcpServers": true,
40-
"enabledMcpjsonServers": ["minecraft-dev"]
41+
"enabledMcpjsonServers": [
42+
"minecraft-dev"
43+
]
4144
}

CLAUDE.md

Lines changed: 102 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ This is a **Model Context Protocol (MCP) server** that provides AI assistants wi
88

99
## Release Status
1010

11-
- Phase 1 & 2 complete (core services, remap/decompile/search/compare) as of 2025-12-06; 29 integration tests pass end-to-end.
12-
- Phase 3 focus: third-party mod analysis; missing piece is decompiling remapped mod JARs (see TODO below).
11+
- **Phase 1 & 2 complete** (core services, remap/decompile/search/compare) as of 2025-12-06; 29 integration tests pass end-to-end.
12+
- **Phase 3 complete** (third-party mod analysis) as of 2025-12-15; includes full mod decompilation, search, and indexing capabilities with WSL support.
1313

1414
## Architecture
1515

@@ -309,6 +309,10 @@ The code should work automatically, but be aware:
309309

310310
### Phase 3 Tools (Mod Analysis)
311311
16. **`analyze_mod_jar`** - Analyze third-party mod JAR files
312+
17. **`decompile_mod_jar`** - Decompile mod JARs to readable Java source
313+
18. **`search_mod_code`** - Search decompiled mod source code
314+
19. **`index_mod`** - Create full-text search index for mod source
315+
20. **`search_mod_indexed`** - Fast FTS5 search on indexed mod source
312316

313317
#### `analyze_mod_jar` Tool
314318

@@ -357,32 +361,106 @@ Analyzes third-party mod JARs without requiring Java. Performs:
357361
- `ModClass`: Class metadata including mixin detection
358362
- `ModMixinConfig`: Parsed mixin configuration
359363

360-
## Missing Functionality / Future Enhancements
364+
### `mod-decompile-service.ts`
361365

362-
### Mod JAR Decompilation (TODO)
366+
Decompiles mod JARs to readable Java source code. Supports both original (intermediary) and remapped JARs.
363367

364-
**Current State**: The `remap_mod_jar` tool successfully remaps Fabric mod JARs from intermediary to human-readable mappings (yarn/mojmap), converting all Minecraft class references inside the JAR to use named mappings.
368+
**Key features**:
369+
1. **Auto-detection**: Automatically detects mod ID and version from JAR metadata
370+
2. **Caching**: Decompiled sources cached in `AppData/decompiled-mods/{modId}/{modVersion}/{mapping}/`
371+
3. **Progress tracking**: Database-backed job tracking with progress updates
372+
4. **VineFlower integration**: Reuses same decompiler as Minecraft decompilation
373+
5. **WSL compatibility**: Full support for WSL and Windows path formats
365374

366-
**Missing**: There is no tool to **decompile the remapped JAR** to readable source code.
375+
**Workflow**:
376+
1. `remap_mod_jar` - Remap mod JAR from intermediary → yarn/mojmap (optional, can skip if JAR already remapped)
377+
2. `decompile_mod_jar` - Decompile JAR to readable Java source
378+
3. `search_mod_code` OR `index_mod` + `search_mod_indexed` - Search through decompiled source
367379

368-
**Current Workflow**:
369-
1.`remap_mod_jar` - Remap intermediary → yarn/mojmap (Minecraft class references)
370-
2.**Missing** - Decompile remapped JAR to readable Java source
371-
3.`analyze_mod_jar` - Extract metadata from JAR (works on original or remapped)
380+
#### `decompile_mod_jar` Tool
372381

373-
**Desired Workflow**:
374-
1. `remap_mod_jar` - Remap the mod JAR
375-
2. `decompile_mod_jar` - Decompile remapped JAR using VineFlower (same as Minecraft decompilation)
376-
3. Browse/search decompiled mod source with human-readable Minecraft class names
382+
Decompiles a mod JAR file to readable Java source code.
377383

378-
**Implementation Notes**:
379-
- Can reuse existing VineFlower integration from `decompile-service.ts`
380-
- Output structure: `AppData/minecraft-dev-mcp/decompiled-mods/{mod-id}/{version}/{mapping}/`
381-
- Tool name: `decompile_mod_jar` or add `decompile?: boolean` parameter to `remap_mod_jar`
382-
- Would enable full mod source code analysis for educational/compatibility purposes
384+
**Input**:
385+
```typescript
386+
{
387+
jarPath: string; // Path to mod JAR (WSL or Windows path)
388+
mapping: 'yarn' | 'mojmap'; // Mapping type JAR uses
389+
modId?: string; // Optional, auto-detected if not provided
390+
modVersion?: string; // Optional, auto-detected if not provided
391+
}
392+
```
393+
394+
**Output**: Decompiled source directory path, mod ID, and version
395+
396+
**Example**:
397+
```
398+
decompile_mod_jar({ jarPath: "C:/mods/meteor-remapped-yarn.jar", mapping: "yarn" })
399+
```
400+
401+
#### `search_mod_code` Tool
402+
403+
Search for classes, methods, fields, or content in decompiled mod source code using regex patterns.
404+
405+
**Input**:
406+
```typescript
407+
{
408+
modId: string;
409+
modVersion: string;
410+
query: string; // Regex pattern or literal string
411+
searchType: 'class' | 'method' | 'field' | 'content' | 'all';
412+
mapping: 'yarn' | 'mojmap';
413+
limit?: number; // Default: 50
414+
}
415+
```
416+
417+
**Example**:
418+
```
419+
search_mod_code({ modId: "meteor-client", modVersion: "0.5.8", query: "onTick", searchType: "method", mapping: "yarn" })
420+
```
421+
422+
#### `index_mod` Tool
423+
424+
Creates a full-text search index for decompiled mod source code using SQLite FTS5.
425+
426+
**Input**:
427+
```typescript
428+
{
429+
modId: string;
430+
modVersion: string;
431+
mapping: 'yarn' | 'mojmap';
432+
force?: boolean; // Force re-indexing, default: false
433+
}
434+
```
435+
436+
**Benefits**: Enables much faster searching via `search_mod_indexed` tool
437+
438+
#### `search_mod_indexed` Tool
439+
440+
Fast full-text search using pre-built mod index. Supports FTS5 syntax.
441+
442+
**Input**:
443+
```typescript
444+
{
445+
query: string; // FTS5 syntax: AND, OR, NOT, "phrase", prefix*
446+
modId: string;
447+
modVersion: string;
448+
mapping: 'yarn' | 'mojmap';
449+
types?: Array<'class' | 'method' | 'field'>; // Optional filter
450+
limit?: number; // Default: 100
451+
}
452+
```
453+
454+
**Example**:
455+
```
456+
search_mod_indexed({ query: "packet AND send", modId: "meteor-client", modVersion: "0.5.8", mapping: "yarn" })
457+
```
458+
459+
## Mod Analysis Use Cases
383460

384-
**Use Cases**:
385-
- Understanding how other mods work for compatibility
386-
- Learning mod development techniques
387-
- Debugging mod interactions
388-
- Educational reference for Minecraft modding patterns
461+
The Phase 3 mod tools enable:
462+
- **Compatibility analysis**: Understanding how other mods work for interop
463+
- **Learning**: Studying mod development techniques from popular mods
464+
- **Debugging**: Investigating mod interactions and conflicts
465+
- **Educational reference**: Exploring Minecraft modding patterns
466+
- **Code search**: Finding specific implementations across mod codebases

__tests__/test-constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ const __dirname = dirname(__filename);
1010

1111
export const TEST_VERSION = '1.21.11';
1212
export const TEST_MAPPING = 'yarn' as const;
13-
export const METEOR_JAR_PATH = join(__dirname, 'fixtures', 'meteor-client-1.21.10-32.jar');
13+
14+
// Updated to use the meteor JAR in ai_reference
15+
export const METEOR_JAR_PATH = join(__dirname, '..', 'ai_reference', 'meteor-client-1.21.11-4.jar');

0 commit comments

Comments
 (0)