Skip to content

feat: Add Java source code search and decompilation tools.#1344

Merged
esengine merged 1 commit into
esengine:mainfrom
ezdemo:main-add-java-tool-fix
May 20, 2026
Merged

feat: Add Java source code search and decompilation tools.#1344
esengine merged 1 commit into
esengine:mainfrom
ezdemo:main-add-java-tool-fix

Conversation

@ezdemo

@ezdemo ezdemo commented May 19, 2026

Copy link
Copy Markdown

What

Add a java_source tool that lets the agent find and decompile Java source code by fully-qualified class name. Default off — enabled via config "javaSource": true or env REASONIX_JAVA_SOURCE=1.

New modules:

  • src/java/zip-reader.ts — zero-dependency pure-Node ZIP/JAR entry reader (STORED + DEFLATED). No JDK jar command required.
  • src/java/class-source-finder.ts — three-phase search engine: (1) BFS walk of the project tree for .java files, (2) recursive scan of Maven .m2 and Gradle caches for matching jars, (3) javap -c -p decompilation. Supports keyword filtering, maxJarScan guard, AbortSignal cancellation, and direct jarPath mode.
  • src/java/index.ts — barrel export.

New tool (parallelSafe, readOnly):

  • java_source(className, projectRoot?, jarPath?, jarKeyword?) — registered in buildCodeToolset() via registerJavaSourceTool(), gated by loadJavaSourceEnabled().

Wiring:

  • src/config.ts: javaSource config field + loadJavaSourceEnabled() (env REASONIX_JAVA_SOURCE takes precedence).
  • src/code/setup.ts: conditional registration in buildCodeToolset().

Why

Java developers working on Maven/Gradle projects need to inspect library source without leaving the agent session. The tool is default-off because javap decompilation is I/O-heavy and not relevant to non-Java projects.

How to verify

  1. npm run verify passes (lint + typecheck + tests).
  2. 41 unit tests in tests/java-source.test.ts cover zip reading, project search, repo scan, keyword filtering, maxJarScan truncation, corrupt jar resilience, AbortSignal, decompilation, javap failure, and tool registration + dispatch.
  3. The tool does not appear in the registry unless javaSource: true is set.

Checklist

  • [√] npm run verify passes locally (lint + typecheck + tests + comment-policy gate)
  • [√] No Co-Authored-By: Claude trailer in commits
  • [√] Comments follow CONTRIBUTING.md (no module-essay headers, no incident history)
  • [√] No edits to CHANGELOG.md — release notes are maintainer-written at release time

@J3y0r

J3y0r commented May 19, 2026

Copy link
Copy Markdown

omg i like it!

@J3y0r

J3y0r commented May 19, 2026

Copy link
Copy Markdown

I can finally get rid of that awful recaf-mcp

@esengine esengine merged commit b0d8fea into esengine:main May 20, 2026
4 checks passed
@esengine

Copy link
Copy Markdown
Owner

Thanks @limerence-zou — a genuinely well-shaped first PR. A few things I want to call out for future contributors reading this:

  • Default-off via javaSource config + REASONIX_JAVA_SOURCE env is exactly right. Non-Java users pay nothing — no JDK requirement, no tool slot in the registry, no extra cache-prefix bytes.
  • Hand-rolling the pure-Node ZIP reader instead of pulling in an npm dep matches how we like to keep the dep tree narrow. Nicely scoped to STORED + DEFLATED, with EOCD comment-search done right.
  • readOnly: true + parallelSafe: true are the right markers, and the className regex guard + AbortSignal + 30s/10 MiB caps on javap are the kind of defensive boundary handling we want at tool edges.
  • 41 tests including DEFLATED entries, corrupt-jar resilience, maxJarScan truncation, and abort behavior — solid.

I'll do a small follow-up to bring the comment style in line with CLAUDE.md (section-banner separators like // ── types ── and the 2–3-line module-header essays should go — code is self-explanatory). Nothing for you to fix; just keeping the file headers consistent across the codebase.

Looking forward to more like this.

esengine added a commit that referenced this pull request May 20, 2026
)

* chore(java): strip section-banner comments and module-header essays

#1344 followed conventions from a different codebase — `// ── types ──`
banner separators, multi-line module-header essays, and JSDoc-style
`@param`/`@returns` text restating type signatures. CLAUDE.md bans all
three. Trim to plain code with comments only on hidden constraints or
non-obvious invariants.

No behavior change; all 41 java-source tests still pass.

* test(java-source): isolate project-search tests from real ~/.m2 cache

Three searchProject tests ("returns not-found", "skips common non-source
directories", "handles empty project root gracefully") were walking the
real ~/.m2 / ~/.gradle defaults — fine on a fresh CI runner, flaky on a
dev machine with a populated cache under full-suite I/O contention.

- Pass repoPaths: [] so the not-found path skips the jar scan entirely.
- Bump per-test timeout to 30s as a defensive cap; the searches now run
  in ms, but Windows AV scanning of fresh tmp dirs can still spike.

---------

Co-authored-by: reasonix <reasonix@deepseek.com>
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
…engine#1363)

* chore(java): strip section-banner comments and module-header essays

esengine#1344 followed conventions from a different codebase — `// ── types ──`
banner separators, multi-line module-header essays, and JSDoc-style
`@param`/`@returns` text restating type signatures. CLAUDE.md bans all
three. Trim to plain code with comments only on hidden constraints or
non-obvious invariants.

No behavior change; all 41 java-source tests still pass.

* test(java-source): isolate project-search tests from real ~/.m2 cache

Three searchProject tests ("returns not-found", "skips common non-source
directories", "handles empty project root gracefully") were walking the
real ~/.m2 / ~/.gradle defaults — fine on a fresh CI runner, flaky on a
dev machine with a populated cache under full-suite I/O contention.

- Pass repoPaths: [] so the not-found path skips the jar scan entirely.
- Bump per-test timeout to 30s as a defensive cap; the searches now run
  in ms, but Windows AV scanning of fresh tmp dirs can still spike.

---------

Co-authored-by: reasonix <reasonix@deepseek.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants