@mustafagoksever/java-inspector 2.4.0 → 3.1.1

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.
Files changed (69) hide show
  1. package/README.md +147 -261
  2. package/dist/analyzer/ApiDiff.d.ts +35 -0
  3. package/dist/analyzer/ApiDiff.d.ts.map +1 -0
  4. package/dist/analyzer/ApiDiff.js +199 -0
  5. package/dist/analyzer/ApiDiff.js.map +1 -0
  6. package/dist/analyzer/JavaClassAnalyzer.d.ts +16 -0
  7. package/dist/analyzer/JavaClassAnalyzer.d.ts.map +1 -1
  8. package/dist/analyzer/JavaClassAnalyzer.js +64 -10
  9. package/dist/analyzer/JavaClassAnalyzer.js.map +1 -1
  10. package/dist/analyzer/JdkSourceService.d.ts +17 -0
  11. package/dist/analyzer/JdkSourceService.d.ts.map +1 -0
  12. package/dist/analyzer/JdkSourceService.js +138 -0
  13. package/dist/analyzer/JdkSourceService.js.map +1 -0
  14. package/dist/cache/ProjectCache.d.ts +14 -1
  15. package/dist/cache/ProjectCache.d.ts.map +1 -1
  16. package/dist/cache/ProjectCache.js +122 -12
  17. package/dist/cache/ProjectCache.js.map +1 -1
  18. package/dist/decompiler/DecompilerService.d.ts +9 -2
  19. package/dist/decompiler/DecompilerService.d.ts.map +1 -1
  20. package/dist/decompiler/DecompilerService.js +114 -17
  21. package/dist/decompiler/DecompilerService.js.map +1 -1
  22. package/dist/index.d.ts +96 -18
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1146 -606
  25. package/dist/index.js.map +1 -1
  26. package/dist/scanner/ArtifactService.d.ts +168 -0
  27. package/dist/scanner/ArtifactService.d.ts.map +1 -0
  28. package/dist/scanner/ArtifactService.js +828 -0
  29. package/dist/scanner/ArtifactService.js.map +1 -0
  30. package/dist/scanner/BackgroundScanner.d.ts.map +1 -1
  31. package/dist/scanner/BackgroundScanner.js +38 -26
  32. package/dist/scanner/BackgroundScanner.js.map +1 -1
  33. package/dist/scanner/ClassFileMetadataReader.d.ts +31 -0
  34. package/dist/scanner/ClassFileMetadataReader.d.ts.map +1 -0
  35. package/dist/scanner/ClassFileMetadataReader.js +215 -0
  36. package/dist/scanner/ClassFileMetadataReader.js.map +1 -0
  37. package/dist/scanner/DependencyScanner.d.ts +80 -0
  38. package/dist/scanner/DependencyScanner.d.ts.map +1 -1
  39. package/dist/scanner/DependencyScanner.js +401 -41
  40. package/dist/scanner/DependencyScanner.js.map +1 -1
  41. package/dist/scanner/JarIndexer.d.ts +73 -0
  42. package/dist/scanner/JarIndexer.d.ts.map +1 -0
  43. package/dist/scanner/JarIndexer.js +445 -0
  44. package/dist/scanner/JarIndexer.js.map +1 -0
  45. package/dist/scanner/JarScanCoordinator.d.ts +32 -0
  46. package/dist/scanner/JarScanCoordinator.d.ts.map +1 -0
  47. package/dist/scanner/JarScanCoordinator.js +124 -0
  48. package/dist/scanner/JarScanCoordinator.js.map +1 -0
  49. package/dist/scanner/LazyResolver.js +1 -1
  50. package/dist/scanner/LazyResolver.js.map +1 -1
  51. package/dist/scanner/ProjectDiscovery.d.ts +13 -0
  52. package/dist/scanner/ProjectDiscovery.d.ts.map +1 -0
  53. package/dist/scanner/ProjectDiscovery.js +84 -0
  54. package/dist/scanner/ProjectDiscovery.js.map +1 -0
  55. package/dist/utils/cachePaths.d.ts +3 -0
  56. package/dist/utils/cachePaths.d.ts.map +1 -1
  57. package/dist/utils/cachePaths.js +9 -0
  58. package/dist/utils/cachePaths.js.map +1 -1
  59. package/dist/utils/javaOutline.d.ts +70 -0
  60. package/dist/utils/javaOutline.d.ts.map +1 -0
  61. package/dist/utils/javaOutline.js +444 -0
  62. package/dist/utils/javaOutline.js.map +1 -0
  63. package/dist/utils/methodExtractor.d.ts +7 -0
  64. package/dist/utils/methodExtractor.d.ts.map +1 -1
  65. package/dist/utils/methodExtractor.js +50 -0
  66. package/dist/utils/methodExtractor.js.map +1 -1
  67. package/lib/vineflower-1.12.0.jar +0 -0
  68. package/package.json +8 -5
  69. package/lib/vineflower-1.11.2.jar +0 -0
package/README.md CHANGED
@@ -1,340 +1,226 @@
1
1
  # Java Inspector
2
2
 
3
- > **Decompile Maven dependencies into readable Java source — directly inside your AI agent.**
3
+ Java Inspector is an MCP server that gives AI agents fast, read-only access to code and metadata inside Maven and Gradle dependencies, local JARs, executable JARs, WARs, and the JDK.
4
4
 
5
- [![npm](https://img.shields.io/npm/v/@mustafagoksever/java-inspector)](https://www.npmjs.com/package/@mustafagoksever/java-inspector)
6
- [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
5
+ The server starts accepting MCP calls immediately. Dependency scanning continues in the background, while an interactive query can promote the JAR it needs to a foreground queue and return without waiting for the complete project index.
7
6
 
8
- ---
7
+ ## Requirements
9
8
 
10
- ## What is this?
9
+ - Node.js 20 or newer
10
+ - Java 17 or newer (`java` and `javap`); required by bundled Vineflower 1.12.0
11
+ - Maven for Maven projects; Gradle (or the project's `gradlew`) for Gradle projects
11
12
 
12
- AI editors can't read compiled `.class` files. Ask *"How does `JpaRepository` work?"* and the agent hallucinates.
13
+ Vineflower 1.12.0 is bundled in `lib/`.
13
14
 
14
- **Java Inspector** is an MCP server that exposes the internals of your project's Maven dependencies (Spring, Hibernate, Jackson, Micrometer, etc.) as decompiled Java source code. Zero configuration — just point your agent at it.
15
+ ## Install and configure
15
16
 
16
- ### Supported operations
17
+ ```bash
18
+ npm install -g @mustafagoksever/java-inspector
19
+ ```
17
20
 
18
- | Tool | What it does |
19
- |------|--------------|
20
- | `scan_dependencies` | Kicks off a background scan of every JAR on the Maven classpath. Call again to poll progress. |
21
- | `decompile_class` | Returns the **full Java source** (method bodies and all) via Vineflower. Optionally extract a single method by `methodName`, or paginate with `offset`/`limit`. |
22
- | `analyze_class` | Returns the **structural signature** — fields, methods, constructors, inheritance — via `javap`. No method bodies. |
23
- | `search_class` | Fuzzy-find classes by partial name (e.g. `"ObservationRegistry"`). |
24
- | `get_inheritance_tree` | Walks the superclass chain up to `java.lang.Object`. |
21
+ ```json
22
+ {
23
+ "mcpServers": {
24
+ "java-inspector": {
25
+ "command": "java-inspector",
26
+ "args": ["start"]
27
+ }
28
+ }
29
+ }
30
+ ```
25
31
 
26
- ### Response formats
32
+ For local development:
27
33
 
28
- Every tool accepts a `format` parameter (`text` | `json` | `toon`). Default is `text`.
34
+ ```bash
35
+ npm ci
36
+ npm run build
37
+ node dist/cli.js start
38
+ ```
29
39
 
30
- | Format | What you get | Best for |
31
- |--------|-------------|----------|
32
- | `text` | Human-readable markdown, tables, code blocks | Reading by LLMs and humans |
33
- | `json` | Pure `structuredContent` — no text wrapper | Programmatic consumption, piping to other tools |
34
- | `toon` | [Token-Oriented Object Notation](https://github.com/toon-format/toon) — compact, schema-aware text | LLM prompts where token count matters (~40% fewer tokens than JSON) |
40
+ ## Startup discovery
35
41
 
36
- **`json`** strips the text wrapper and returns only the structured payload.
37
- **`toon`** encodes the same payload via `@toon-format/toon`, giving you YAML-like readability with CSV-like compactness for uniform arrays.
42
+ After the MCP transport connects, Java Inspector performs non-blocking discovery:
38
43
 
39
- ---
44
+ 1. If `cwd` has a `pom.xml` (or a Gradle `settings.gradle[.kts]` / `build.gradle[.kts]`), that build is used. Maven wins when both exist.
45
+ 2. Otherwise directories are searched breadth-first.
46
+ 3. Every build root at the first matching depth is selected.
47
+ 4. Deeper builds are not independently scanned.
48
+ 5. Classpaths are resolved (`mvn dependency:build-classpath`, or a Gradle init script that prints the compile/runtime/test classpath of every project) and their JARs enter the background light-scan queue.
40
49
 
41
- ## Architecture
50
+ In a multi-module Maven checkout whose modules depend on each other but were never installed, Maven 3 fails `dependency:build-classpath`. Java Inspector then retries with `--fail-at-end` and adds the external dependencies of `dependency:tree` that are in the local repository.
42
51
 
43
- ```mermaid
44
- graph LR
45
- A[AI Agent<br/>Claude / Cursor / Codex / Opencode] -->|MCP| B[java-inspector<br/>TypeScript Server]
46
- B -->|auto-detect| C{Maven Resolver}
47
- C -->|priority 1| D[MAVEN_CMD env]
48
- C -->|priority 2| E[mvnd daemon<br/>~2x faster]
49
- C -->|priority 3| F[MAVEN_HOME/bin/mvn]
50
- C -->|priority 4| G[mvn from PATH]
51
- B -->|dependency:build-classpath| H[~/.m2/repository]
52
- H -->|JAR streams| I[yauzl extractor]
53
- I -->|class names| J[JSON Lines Cache]
54
- B -->|cache hit| J
55
- B -->|cache miss| I
56
- B -->|java -jar vineflower.jar| K[Vineflower 1.11.2<br/>Decompiler]
57
- K -->|*.java source| A
58
- ```
52
+ Directories such as `.git`, `node_modules`, `.gradle`, `target`, `build`, and `out` are excluded from POM discovery.
59
53
 
60
- ### Why JSON Lines?
54
+ Local, non-Maven JARs are not scanned at startup. They are found and indexed only when a tool call supplies a path, directory, or filename prefix.
61
55
 
62
- Traditional JSON caches rewrite the entire file on every batch — O(n²) overhead for large projects. We use **append-only JSON Lines**:
56
+ ## Tools
63
57
 
64
- - **Crash-safe**: each line is independent; a truncated final line is skipped on reload.
65
- - **Fast startup**: the server replays the JSONL into an in-memory `Map<string, ClassIndexEntry>` on launch.
66
- - **Low memory**: ~35 MB RAM for 100,000 classes.
58
+ | Tool | Purpose |
59
+ |---|---|
60
+ | `scan_project` | Start, refresh, or poll the non-blocking dependency scan. |
61
+ | `find_jar` | Find an artifact by path, filename, prefix, substring, or Maven coordinates without opening it. |
62
+ | `inspect_jar` | Inspect manifest, Maven metadata, packages, classes, resources, and nested artifacts. |
63
+ | `search_class` | Search the live partial index and foreground-scan relevant JARs on a miss. |
64
+ | `search_code` | Search methods, fields, annotations, references, or string constants without mass decompilation. |
65
+ | `find_implementations` | Find direct or transitive implementations/subtypes from lazy deep indexes. |
66
+ | `find_duplicates` | List classes present in more than one classpath JAR (two versions of one artifact, split packages, shaded copies). |
67
+ | `inspect_class` | Return source, outline, API, hierarchy, bytecode, or all views for a class. One method with `methodName`, or the method at a stack-trace `line`. Nested classes: `Outer$Inner`. |
68
+ | `explain_dependency` | Run a filtered Maven dependency tree for a selected artifact. |
69
+ | `compare_versions` | Public/protected API diff between two versions of an artifact (or two JARs) with breaking changes flagged. |
70
+ | `list_dependencies` | Resolved dependencies per Maven module: GAV, scope, direct or transitive (with the path). |
71
+ | `search_resources` | Search resource paths or bounded text content. |
72
+ | `read_resource` | Read an exact text resource with line pagination. |
67
73
 
68
- ### Cache layout
74
+ Every tool supports `text`, `json`, and `toon` output where applicable.
69
75
 
70
- ```
71
- ~/.cache/java-inspector/<project>_<hash>/
72
- ├── classpath.json # pomHash + jarPaths[] + classpathHash + timestamp
73
- ├── class-index.jsonl # Append-only ClassIndexEntry batches
74
- ├── scan-state.json # jarCount, processedJars[], isComplete
75
- ├── server-<pid>.log # Per-process append-only logs (multi-process safe)
76
- ├── write.lock # Cross-process lock for JSONL / state writes
77
- ├── scan.lock # Cross-process lock for scan lifecycle
78
- └── decompile-cache-vineflower/ # Cached .java sources
79
- ```
76
+ ## Artifact selectors
80
77
 
81
- ---
78
+ Class, JAR, and resource tools share the same selection model:
82
79
 
83
- ## Quick Start
80
+ - `jarPath`: exact absolute JAR path; fastest and unambiguous.
81
+ - `jarDirectory` + `jarNamePrefix`: useful for Maven-free projects with `lib/` directories.
82
+ - `workspacePath` + `jarNamePrefix`: search the Maven classpath and workspace.
83
+ - `workspacePath`: use the live partial index and bounded lazy fallback.
84
+ - `coordinates`: `groupId:artifactId[:version[:classifier]]`.
84
85
 
85
- Add to your MCP client config:
86
+ When no selector is supplied, tools use the server's current working directory. If Maven classpath resolution is still running, searches return `complete: false` instead of reporting a definitive miss. Per-JAR scan failures are returned in `errors`; an unreadable exact `jarPath` fails the tool call.
86
87
 
87
- ### Claude Desktop
88
+ If multiple JARs or classes match, the server returns candidates instead of silently choosing one.
88
89
 
89
- Edit `%APPDATA%\Claude\claude_desktop_config.json`:
90
+ ### Inspect a class from a local JAR
90
91
 
91
92
  ```json
92
93
  {
93
- "mcpServers": {
94
- "java-inspector": {
95
- "command": "npx",
96
- "args": ["-y", "@mustafagoksever/java-inspector"]
97
- }
98
- }
94
+ "className": "com.vendor.Client",
95
+ "jarPath": "C:\\project\\lib\\vendor-client-2.1.jar",
96
+ "view": "source"
99
97
  }
100
98
  ```
101
99
 
102
- ### Cursor
103
-
104
- `Settings` → `MCP Servers` → Add:
100
+ ### Find an exception message
105
101
 
106
102
  ```json
107
103
  {
108
- "mcpServers": {
109
- "java-inspector": {
110
- "command": "npx",
111
- "args": ["-y", "@mustafagoksever/java-inspector"]
112
- }
113
- }
104
+ "query": "Connection refused",
105
+ "kind": "string",
106
+ "workspacePath": "C:\\project",
107
+ "mode": "balanced"
114
108
  }
115
109
  ```
116
110
 
117
- ### Codex
118
-
119
- Edit `~/.codex/config.toml`:
111
+ ### Find implementations
120
112
 
121
- ```toml
122
- [mcp_servers.java-inspector]
123
- command = "npx"
124
- args = ["-y", "@mustafagoksever/java-inspector"]
113
+ ```json
114
+ {
115
+ "className": "com.vendor.Transport",
116
+ "workspacePath": "C:\\project",
117
+ "transitive": true
118
+ }
125
119
  ```
126
120
 
127
- ### Opencode
128
-
129
- Edit `%APPDATA%\opencode\config.json`:
121
+ ### Inspect a JDK class
130
122
 
131
123
  ```json
132
124
  {
133
- "mcp": {
134
- "java-inspector": {
135
- "type": "local",
136
- "command": [
137
- "npx",
138
- "-y",
139
- "@mustafagoksever/java-inspector"
140
- ]
141
- }
142
- }
125
+ "className": "java.util.ArrayList",
126
+ "view": "all"
143
127
  }
144
128
  ```
145
129
 
146
- Restart your editor and ask: *"Show me the source of `ObservationRegistry`"*
147
-
148
- That's it. No `JAVA_HOME` tweaks. No manual decompiler download. The server ships the ~1.8 MB Vineflower JAR inside the package.
149
-
150
- ---
151
-
152
- ## Workflow
153
-
154
- ```mermaid
155
- sequenceDiagram
156
- participant U as User
157
- participant A as AI Agent
158
- participant S as java-inspector
159
- participant M as Maven / mvnd
160
- participant C as Cache
161
-
162
- U->>A: "Show me JpaRepository source"
163
- A->>S: decompile_class("org.springframework.data.jpa.repository.JpaRepository")
164
- alt Index not built yet
165
- S->>M: dependency:build-classpath
166
- M-->>S: JAR list
167
- S->>S: Background scan (20 JARs in parallel)
168
- S-->>A: Class found via lazy JAR search
169
- else Cache hit
170
- S->>C: Map.get(className) — O(1)
171
- C-->>S: ClassIndexEntry
172
- end
173
- S->>S: Extract .class from JAR (yauzl)
174
- S->>S: java -jar vineflower.jar ...
175
- S-->>A: Decompiled .java source
176
- A-->>U: Formatted response
177
- ```
130
+ JDK source is read from `src.zip` when available. API and bytecode views use `javap`.
178
131
 
132
+ ## Foreground and background scheduling
179
133
 
134
+ All JAR reads pass through a shared coordinator:
180
135
 
181
- ## Cache invalidation
136
+ - Up to eight JAR reads run concurrently.
137
+ - Background scanning may occupy at most six slots.
138
+ - Two slots remain available for interactive foreground work.
139
+ - A foreground request promotes a queued background JAR.
140
+ - Concurrent requests for the same JAR share one Promise and one cache write.
141
+ - Light scans time out after 30 seconds; deep scans time out after 60 seconds.
182
142
 
183
- ```mermaid
184
- flowchart TD
185
- A[scan_dependencies called] --> B{isIndexComplete?}
186
- B -->|pomHash mismatch| C[Invalidate disk + memory]
187
- B -->|classpathHash mismatch| C
188
- B -->|both match| D[Return existing index]
189
- C --> E[Delete ~/.cache/java-inspector/<hash>/*]
190
- E --> F[Re-run Maven dependency:build-classpath]
191
- F --> G[Start background scan]
192
- D --> H[Return Map of classes]
193
- ```
143
+ The background scan builds a light index from ZIP entries. More expensive class-file metadata is generated only when `search_code` or `find_implementations` needs it.
194
144
 
195
- Invalidation triggers:
145
+ Context-wide deep searches are intentionally bounded. A partial response includes `complete`, `scannedJarCount`, and `remainingJarCount`. Calling the tool again continues using the already cached deep indexes.
196
146
 
197
- 1. **Module `pom.xml` changes** — `pomHash` mismatch.
198
- 2. **Parent POM / dependency-management changes** — `classpathHash` mismatch.
199
- 3. **Manual** — call `scan_dependencies` with `forceRefresh: true`. This force-releases cross-process locks and wipes the cache directory before restarting.
147
+ ## Class inspection
200
148
 
201
- ---
149
+ `inspect_class` supports:
202
150
 
203
- ## Platform Support
151
+ - `source`: local `*-sources.jar`, embedded `.java`, or Vineflower decompilation. With `downloadSources: true` (Maven), a missing `-sources.jar` is fetched with `mvn dependency:get` first.
152
+ - `outline`: every member with its line range; the cheapest view of a large class.
153
+ - `api`: `javap -p` signatures.
154
+ - `hierarchy`: resolved superclass chain with interfaces.
155
+ - `bytecode`: `javap -c -l -p -s` output; with `methodName` or `line` only that member.
156
+ - `all`: all available views.
204
157
 
205
- | OS | Command |
206
- |----|---------|
207
- | Windows | `npx -y @mustafagoksever/java-inspector` |
208
- | Linux | `npx -y @mustafagoksever/java-inspector` |
209
- | macOS | `npx -y @mustafagoksever/java-inspector` |
158
+ Source responses support `methodName` (searched in superclasses and interfaces when the class does not declare it), `paramTypes`, `line` (stack-trace line number: returns the containing method, also for decompiled code via the line table), `offset`, and `limit`.
210
159
 
211
- **Requirements:** Node.js ≥ 16, Java runtime, Maven (or `mvnd` for faster resolves).
160
+ Responses are kept small for agent contexts: sources over 400 lines return the first 120 lines plus an outline, bytecode over 400 lines returns member signatures, and every response is capped at 40,000 characters with a note saying how to narrow the request. Methods that Vineflower cannot decompile keep its bytecode listing without the decompiler's stack trace, and the response names them.
212
161
 
213
- ---
162
+ The decompiler executable cannot be overridden by a tool argument. Java Inspector uses the bundled Vineflower JAR or the operator-controlled `DECOMPILER_PATH` environment variable.
214
163
 
215
- ## Environment variables
164
+ ## JAR layouts
216
165
 
217
- | Variable | Effect |
218
- |----------|--------|
219
- | `JAVA_HOME` | Locates `java` and `javap`. |
220
- | `MAVEN_HOME` | Locates `mvn` / `mvn.cmd`. |
221
- | `MAVEN_CMD` | Override executable entirely — e.g. `mvnd`, `mvnw`, or a full path. |
222
- | `MAVEN_REPO` | Overrides `~/.m2/repository`. |
223
- | `DECOMPILER_PATH` | Use a custom Vineflower JAR instead of the bundled one. |
224
- | `NODE_ENV=development` | Enables verbose `server.log` output. |
166
+ Light indexing understands:
225
167
 
226
- ---
168
+ - Ordinary and shaded JARs
169
+ - Multi-release entries under `META-INF/versions/`
170
+ - Spring Boot classes under `BOOT-INF/classes`
171
+ - WAR classes under `WEB-INF/classes`
172
+ - JMOD class paths under `classes/`
173
+ - Nested artifact metadata under `BOOT-INF/lib`, `WEB-INF/lib`, and `lib`
174
+ - Maven `pom.properties`, manifests, source JARs, and text resources
227
175
 
228
- ## Installation alternatives
176
+ Nested JAR contents are extracted and scanned only when explicitly needed.
229
177
 
230
- **Zero-setup (recommended)**
231
- ```bash
232
- npx @mustafagoksever/java-inspector
233
- ```
178
+ ## Cache
234
179
 
235
- **Global install**
236
- ```bash
237
- npm install -g @mustafagoksever/java-inspector
238
- java-inspector start
239
- ```
180
+ Cache data is stored under:
240
181
 
241
- **Build from source**
242
- ```bash
243
- git clone https://github.com/mustafagoksever/java-inspector.git
244
- cd java-inspector
245
- npm install
246
- npm run build
182
+ ```text
183
+ ~/.cache/java-inspector/<context>_<hash>/
247
184
  ```
248
185
 
249
- ---
186
+ Important entries include:
250
187
 
251
- ## Troubleshooting
188
+ ```text
189
+ classpath.json
190
+ class-index.jsonl
191
+ scan-state.json
192
+ jar-indexes-v3/
193
+ results-v3/
194
+ server-<pid>.log
195
+ ```
252
196
 
253
- ### Log Files
197
+ Per-JAR caches use resolved path, size, and modification time as their fingerprint. Nested artifacts additionally use their parent fingerprint and ZIP entry identity. JSONL project indexes remain append-only and crash-safe, with cross-process locks protecting writes.
254
198
 
255
- All logs are stored in the cache directory under your user home:
199
+ ## Environment variables
256
200
 
257
- ```
258
- ~/.cache/java-inspector/<project>_<hash>/server-<pid>.log
259
- ```
201
+ | Variable | Purpose |
202
+ |---|---|
203
+ | `NODE_ENV` | Enables additional development logging. |
204
+ | `JAVA_HOME` | Locates `java`, `javap`, and JDK `src.zip`. |
205
+ | `MAVEN_HOME` | Locates Maven. |
206
+ | `MAVEN_CMD` | Overrides the Maven executable. |
207
+ | `MAVEN_REPO` | Overrides the local Maven repository path. |
208
+ | `GRADLE_CMD` | Overrides the Gradle executable (default: the project's `gradlew`, then `GRADLE_HOME/bin/gradle`, then `gradle`). |
209
+ | `GRADLE_HOME` | Locates Gradle. |
210
+ | `JAVA_INSPECTOR_DOWNLOAD_SOURCES` | `true` makes `inspect_class` download missing `-sources.jar` files by default. |
211
+ | `DECOMPILER_PATH` | Overrides the bundled Vineflower JAR. |
260
212
 
261
- **Viewing logs while connected:**
213
+ Maven command resolution order is `MAVEN_CMD`, `mvnd`, `MAVEN_HOME/bin/mvn`, then `mvn` from `PATH`.
262
214
 
263
- ```powershell
264
- # PowerShell
265
- Get-Content ~/.cache/java-inspector/<project>_<hash>/server-<pid>.log -Wait -Tail 20
215
+ ## Development
266
216
 
267
- # Unix/macOS
268
- tail -f ~/.cache/java-inspector/<project>_<hash>/server-<pid>.log
217
+ ```bash
218
+ npm run build
219
+ npm test
220
+ npm run dev
269
221
  ```
270
222
 
271
- Log files are **cleared when cache is invalidated** (`forceRefresh: true` or hash mismatch).
272
-
273
- | Tag | Description |
274
- |-----|-------------|
275
- | `[SERVER]` | Server startup/shutdown |
276
- | `[AUTO-SCAN]` | Automatic scan on startup |
277
- | `[MAVEN]` | Maven command resolution & classpath building |
278
- | `[SCAN]` | Background JAR scanning |
279
- | `[JAVAP]` | `javap` class analysis |
280
- | `[DECOMPILE]` | Vineflower decompilation |
281
- | `[TOOL:<name>]` | Tool call entry/exit with duration |
282
- | `[CACHE]` | Cache invalidation & state |
283
- | `[LOCK]` | Cross-process lock acquire/release/compromise |
284
-
285
- ### Common Issues
286
-
287
- **"command not found" error**
288
- - Ensure Node.js and npm are in your PATH.
289
-
290
- **Maven not found**
291
- - Set `MAVEN_HOME` environment variable or ensure Maven is in your PATH.
292
- - Try using `mvnd` (Maven Daemon) for ~2x faster resolves.
293
-
294
- **Lock timeout errors**
295
- - If a process was killed with SIGKILL while scanning, locks become stale after 60 seconds.
296
- - Another process can then acquire the lock. No action needed unless the problem persists.
297
-
298
- **Cache problems**
299
- - Call `scan_dependencies` with `forceRefresh: true` to clear cache and restart.
300
-
301
- ---
302
-
303
- ## Technical stack
304
-
305
- | Layer | Technology |
306
- |-------|------------|
307
- | Language | TypeScript 5.7 |
308
- | Runtime | Node.js 16+ |
309
- | Protocol | Model Context Protocol (MCP) |
310
- | Decompiler | Vineflower 1.11.2 (bundled) |
311
- | JAR reader | yauzl (streaming, lazy entries) |
312
- | Build tool | tsc |
313
- | Package manager | npm |
314
- | License | Apache-2.0 |
315
-
316
- ---
317
-
318
- ## Performance Test Results
319
-
320
- ### Spring AI Project Test (April 2026)
321
-
322
- **Test Environment:** Windows, Maven Daemon (`mvnd`)
323
- **Project:** Spring AI (multi-module project)
324
-
325
- | Operation | Time |
326
- |-----------|------|
327
- | Maven classpath resolution (185 JARs) | 44.87s |
328
- | Background scan (185 JARs, 30,612 classes) | 12.38s |
329
- | Total initial scan | ~57s |
330
- | analyze_class (UserMessage) | <1s |
331
- | decompile_class (UserMessage) | <1s |
332
- | search_class (query: "UserMessage") | <1s |
333
-
334
- **Notes:**
335
- - First call triggers classpath resolution + background scan (non-blocking)
336
- - Subsequent calls use cached index (in-memory Map)
337
- - Cross-process locking prevents duplicate scans
223
+ The project is ES modules and emits JavaScript, declarations, and source maps to `dist/`.
338
224
 
339
225
  ## License
340
226
 
@@ -0,0 +1,35 @@
1
+ import { ClassFileMetadata, ClassMemberMetadata } from '../scanner/ClassFileMetadataReader.js';
2
+ export interface MemberChange {
3
+ member: string;
4
+ change: string;
5
+ breaking: boolean;
6
+ }
7
+ export interface ClassApiDiff {
8
+ className: string;
9
+ status: 'added' | 'removed' | 'changed';
10
+ /** Breaking for callers or subclasses compiled against the old version. */
11
+ breaking: boolean;
12
+ classChanges: string[];
13
+ added: string[];
14
+ removed: string[];
15
+ changed: MemberChange[];
16
+ }
17
+ export interface ApiDiffResult {
18
+ addedClasses: string[];
19
+ removedClasses: string[];
20
+ changedClasses: ClassApiDiff[];
21
+ unchangedClassCount: number;
22
+ breakingChangeCount: number;
23
+ }
24
+ /** Decode a field/method descriptor into Java type names (java.lang. prefix dropped). */
25
+ export declare function decodeDescriptor(descriptor: string): {
26
+ params: string[];
27
+ returnType?: string;
28
+ };
29
+ export declare function memberSignature(owner: string, member: ClassMemberMetadata, isMethod: boolean): string;
30
+ /**
31
+ * Compare the public/protected API of two sets of class files (binary compatibility view:
32
+ * removed or narrowed members, changed static/final/abstract, changed supertypes).
33
+ */
34
+ export declare function diffApi(fromClasses: ClassFileMetadata[], toClasses: ClassFileMetadata[]): ApiDiffResult;
35
+ //# sourceMappingURL=ApiDiff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiDiff.d.ts","sourceRoot":"","sources":["../../src/analyzer/ApiDiff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAc/F,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IACxC,2EAA2E;IAC3E,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,YAAY,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC1B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,YAAY,EAAE,CAAC;IAC/B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;CAC/B;AAID,yFAAyF;AACzF,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAsB9F;AAmBD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAUrG;AAuBD;;;GAGG;AACH,wBAAgB,OAAO,CAAC,WAAW,EAAE,iBAAiB,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,aAAa,CA2EvG"}