From 6dbca4347b485e8d1200980f1726fb0cfeb3e9c9 Mon Sep 17 00:00:00 2001 From: Ranjan Mohanty Date: Sun, 15 Nov 2026 00:28:57 +0100 Subject: [PATCH] Basic Java/Kotlin support: detection, tests, linters, build commands Detect Java and Kotlin from a root Maven/Gradle build (or a significant share of JVM code) and score them in the existing checks: test command and test files, JVM linters (checkstyle/spotless/PMD/SpotBugs/Error Prone/ktlint/detekt), compile as typecheck, compiler-checked types. --fix generates Maven/Gradle commands; ./mvnw commands in docs are recognized; an untracked, unignored target/ is flagged. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 21 ++++++++ README.md | 18 +++---- src/checks/context-docs.ts | 4 +- src/checks/feedback.ts | 82 +++++++++++++++++++++++++++++- src/checks/navigability.ts | 2 + src/checks/type-safety.ts | 11 ++-- src/context.ts | 19 +++++-- src/fix/agents-md.ts | 21 ++++++++ test/jvm.test.ts | 101 +++++++++++++++++++++++++++++++++++++ 9 files changed, 259 insertions(+), 20 deletions(-) create mode 100644 test/jvm.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index dff367e..d73d7fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,27 @@ All notable changes to this project are documented here. The format is based on [Semantic Versioning](https://semver.org/). Until 1.0, scoring weights may still be tuned in minor releases; any change that moves scores is called out here. +## [Unreleased] + +### Added + +- Basic Java/Kotlin support: + - Detection: a root `pom.xml`/`build.gradle(.kts)`/`settings.gradle(.kts)` with `.java`/`.kt` + files, or a significant share of JVM code. An `android/` folder in a JS app does not count. + - The existing checks now score the JVM side: + - `feedback.test`: tests under `src/test/` or `*Test`/`*IT`/`*Spec`, run via + `./mvnw test`/`mvn test`/`./gradlew test`. + - `feedback.lint`: checkstyle, spotless, PMD, SpotBugs, Error Prone, ktlint or detekt in the + build or config files (1.0), otherwise compiler warnings only (0.6). + - `feedback.typecheck`: compile. + - `types.static`: Java/Kotlin count as compiler-checked. + - `--fix` generates Maven/Gradle build and test commands, and docs that list `./mvnw` commands + are recognized. + - `target/` (Maven, Cargo) is suggested for `.gitignore` when it is present, untracked and + not ignored. + - Score effect: Java repos used to be scored on CI alone, with type safety n/a. Now, for + example: gson 61 → 67, spring-petclinic 63 → 69, timber 58 → 64. No non-JVM repo moved. + ## [0.1.1] - 2026-11-14 ### Changed diff --git a/README.md b/README.md index 2f33494..a08fcc7 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ npx @mintwork/agent-ready # no install npm i -D @mintwork/agent-ready # or pin it in your project ``` -Node 22+. Zero runtime dependencies. Works on JS/TS and Python repos, with basic Go and Rust support. Read-only unless you pass `--fix`. +Node 22+. Zero runtime dependencies. Works on JS/TS and Python repos, with basic Go, Rust and Java/Kotlin support. Read-only unless you pass `--fix`. ## Usage @@ -123,13 +123,13 @@ missing sections in your context doc). It never rewrites content you wrote unles ## What it checks -| Category | Weight | Checks | -| ------------------ | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **Context docs** | 30% | `AGENTS.md` / `CLAUDE.md` / `.cursor/rules` / Copilot / Gemini instructions exist · they list exact build, test and lint commands · they describe architecture and key directories · **not stale**: every referenced path and `npm run` script actually exists · not too long (or too thin) · both `AGENTS.md` and `CLAUDE.md` so every agent is covered | -| **Feedback loops** | 25% | A discoverable test command (package.json `test`, pytest config, `make test`, `cargo test`, `go test`) · linter configured (eslint, biome, oxlint, ruff, flake8, clippy, golangci-lint) · typecheck command (`tsc`, mypy, pyright) · CI config · `--run`: test suite passes and is fast | -| **Navigability** | 20% | `node_modules`, `.venv`, `dist`, caches ignored (and not committed) · no source files over 1000 lines · no minified/vendored/generated blobs in agent view · shallow directory tree · README | -| **Type safety** | 15% | TypeScript `strict` across root and package tsconfigs (follows `extends`, incl. workspace packages), `any` / `@ts-ignore` / `@ts-nocheck` density · plain JS penalized · Python type-hint coverage of product code + mypy/pyright config · Go/Rust count as compiler-checked | -| **Safety** | 10% | Committed `.env` / keys / credentials files · AWS, GitHub, Slack, Stripe, OpenAI, Anthropic, Google, npm token patterns · dangerous scripts: `rm -rf ~`, `curl \| sh`, force-push, `npm publish` hidden in `build`/`test`, network calls in install hooks | +| Category | Weight | Checks | +| ------------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **Context docs** | 30% | `AGENTS.md` / `CLAUDE.md` / `.cursor/rules` / Copilot / Gemini instructions exist · they list exact build, test and lint commands · they describe architecture and key directories · **not stale**: every referenced path and `npm run` script actually exists · not too long (or too thin) · both `AGENTS.md` and `CLAUDE.md` so every agent is covered | +| **Feedback loops** | 25% | A discoverable test command (package.json `test`, pytest config, `make test`, `cargo test`, `go test`, `mvn test` / `./gradlew test`) · linter configured (eslint, biome, oxlint, ruff, flake8, clippy, golangci-lint, checkstyle/spotless/PMD/SpotBugs/Error Prone/ktlint/detekt) · typecheck command (`tsc`, mypy, pyright) · CI config · `--run`: test suite passes and is fast | +| **Navigability** | 20% | `node_modules`, `.venv`, `dist`, caches ignored (and not committed) · no source files over 1000 lines · no minified/vendored/generated blobs in agent view · shallow directory tree · README | +| **Type safety** | 15% | TypeScript `strict` across root and package tsconfigs (follows `extends`, incl. workspace packages), `any` / `@ts-ignore` / `@ts-nocheck` density · plain JS penalized · Python type-hint coverage of product code + mypy/pyright config · Go/Rust count as compiler-checked | +| **Safety** | 10% | Committed `.env` / keys / credentials files · AWS, GitHub, Slack, Stripe, OpenAI, Anthropic, Google, npm token patterns · dangerous scripts: `rm -rf ~`, `curl \| sh`, force-push, `npm publish` hidden in `build`/`test`, network calls in install hooks | Checks that don't apply (e.g. Python checks in a TS repo) are marked n/a and excluded from the score. In polyglot repos, per-language parts are weighted by each language's share of the code, so a tooling @@ -220,7 +220,7 @@ whatever `npm run build` does. ## Roadmap -- [ ] Deeper Go and Rust checks (unsafe/`interface{}` density, nested `Cargo.toml` workspaces) and Java/Kotlin support +- [ ] Deeper Go and Rust checks (unsafe/`interface{}` density, nested `Cargo.toml` workspaces) and Java/Kotlin support (Java/Kotlin basics done) - [ ] `--run` for lint/typecheck too, and flaky-test detection (run twice, compare) - [ ] Monorepo awareness: score each workspace package, check nested `AGENTS.md` - [ ] Doc staleness via git history (doc untouched while referenced code churned) diff --git a/src/checks/context-docs.ts b/src/checks/context-docs.ts index 8321c25..a6ea5da 100644 --- a/src/checks/context-docs.ts +++ b/src/checks/context-docs.ts @@ -27,7 +27,7 @@ export function codeText(md: string): string { } const RUNNERS = - '(?:npm|pnpm|yarn|bun|npx|bunx|nub|vp|make|just|task|mise|moon|uv|uvx|poetry|pdm|hatch|tox|nox|python3?|pip|cargo|go|deno|turbo|nx|bazel|bazelisk|gradlew|gradle|mvn|dotnet|rake|bundle|mix)'; + '(?:npm|pnpm|yarn|bun|npx|bunx|nub|vp|make|just|task|mise|moon|uv|uvx|poetry|pdm|hatch|tox|nox|python3?|pip|cargo|go|deno|turbo|nx|bazel|bazelisk|gradlew|gradle|mvnw|mvn|dotnet|rake|bundle|mix)'; /** Any tool invoked as ` run|exec ` (e.g. `mise run test`, `nub exec vitest`). */ const GENERIC_RUN = '(?:\\b[\\w.-]+\\s+(?:run|exec)\\b)'; @@ -41,7 +41,7 @@ const COMMAND_KINDS: Record = { 'im', ), build: new RegExp( - `(?:(?:\\b${RUNNERS}\\b|${GENERIC_RUN})[^\\n]*\\b(?:build|compile|bundle|install|sync|dev|start)\\b)|^\\s*(?:tsc|vite|webpack|esbuild)\\b|^\\s*(?:make|just)\\s*$`, + `(?:(?:\\b${RUNNERS}\\b|${GENERIC_RUN})[^\\n]*\\b(?:build|compile|bundle|install|sync|dev|start|package|assemble)\\b)|^\\s*(?:tsc|vite|webpack|esbuild)\\b|^\\s*(?:make|just)\\s*$`, 'im', ), }; diff --git a/src/checks/feedback.ts b/src/checks/feedback.ts index 80cae02..8fa4b52 100644 --- a/src/checks/feedback.ts +++ b/src/checks/feedback.ts @@ -1,6 +1,7 @@ import { spawnSync } from 'node:child_process'; -import { type Language, type RepoContext, runScriptCmd } from '../context.js'; +import { JVM_BUILD, type Language, type RepoContext, runScriptCmd } from '../context.js'; import type { Check, CheckResult } from '../types.js'; +import { isFixturePath } from '../util/paths.js'; import { projectTsconfigs } from './type-safety.js'; const JS_TEST_DEPS = [ @@ -66,9 +67,49 @@ export function testCommand(ctx: RepoContext): string | null { } if (hasRust(ctx) && ctx.has('Cargo.toml')) return 'cargo test'; if (hasGo(ctx) && ctx.has('go.mod')) return 'go test ./...'; + const jvm = jvmBuildTool(ctx); + if (hasJvm(ctx) && jvm) return `${jvm.run} test`; return null; } +function hasJvm(ctx: RepoContext): boolean { + return ctx.languages.includes('java') || ctx.languages.includes('kotlin'); +} + +/** The root Maven/Gradle build, with the wrapper when one is committed. */ +export function jvmBuildTool(ctx: RepoContext): { tool: 'maven' | 'gradle'; run: string } | null { + if ( + ['build.gradle', 'build.gradle.kts', 'settings.gradle', 'settings.gradle.kts'].some((f) => + ctx.has(f), + ) + ) { + return { tool: 'gradle', run: ctx.has('gradlew') ? './gradlew' : 'gradle' }; + } + if (ctx.has('pom.xml')) return { tool: 'maven', run: ctx.has('mvnw') ? './mvnw' : 'mvn' }; + return null; +} + +/** All Maven/Gradle build files, for plugins that are configured by being applied (checkstyle, spotless). */ +function jvmBuildText(ctx: RepoContext): string { + return ctx.files + .filter((f) => JVM_BUILD.test(f) && !isFixturePath(f)) + .slice(0, 200) + .map((f) => ctx.read(f) ?? '') + .join('\n'); +} + +const JVM_LINTERS = + /\b(checkstyle|spotless|pmd|spotbugs|errorprone|error_prone|error-prone|ktlint|detekt|ktfmt|google-java-format|palantir-java-format|diktat)\b/i; + +function jvmTestFiles(ctx: RepoContext): number { + return ctx.files.filter( + (f) => + /\.(?:java|kt|groovy|scala)$/.test(f) && + (/(^|\/)src\/(?:test|androidTest|integrationTest|[\w]*[Tt]est)\/|(^|\/)test\//.test(f) || + /(?:Tests?|IT|Spec)\.(?:java|kt|groovy)$/.test(f)), + ).length; +} + /** Per-language part of a check: its score and how much of the codebase it covers. */ type Part = [score: number, weight: number]; @@ -169,6 +210,19 @@ export const feedbackChecks: Check[] = [ parts.push(part(ctx, tests ? 1 : 0, 'go')); notes.push(tests ? '`go test ./...`' : 'no Go tests'); } + if (hasJvm(ctx)) { + const build = jvmBuildTool(ctx); + const tests = jvmTestFiles(ctx); + const score = tests && build ? 1 : tests ? 0.5 : 0; + parts.push(part(ctx, score, 'java', 'kotlin')); + notes.push( + tests && build + ? `\`${build.run} test\` (${tests} test files)` + : tests + ? `${tests} JVM test files but no root Maven/Gradle build` + : 'no Java/Kotlin tests', + ); + } const score = avg(parts); if (score === null) return { score: null, summary: 'No supported language detected' }; return { @@ -256,6 +310,21 @@ export const feedbackChecks: Check[] = [ ); } } + if (hasJvm(ctx)) { + const configured = + JVM_LINTERS.test(jvmBuildText(ctx)) || + ctx.files.some((f) => + /(^|\/)(?:checkstyle[\w-]*\.xml|detekt[\w-]*\.ya?ml|pmd[\w-]*\.xml|\.?ktlint[\w-]*)$/.test( + f, + ), + ); + parts.push(part(ctx, configured ? 1 : 0.6, 'java', 'kotlin')); + notes.push( + configured + ? 'JVM linter (checkstyle/spotless/detekt/...)' + : 'only compiler warnings (no checkstyle/spotless/ktlint/detekt)', + ); + } const score = avg(parts); if (score === null) return { score: null, summary: 'No supported language detected' }; return { @@ -263,7 +332,7 @@ export const feedbackChecks: Check[] = [ summary: `Lint: ${notes.join('; ')}`, suggestion: score < 1 - ? 'Configure a fast linter (eslint/biome for JS, ruff for Python, clippy for Rust, golangci-lint for Go) and run it in CI.' + ? 'Configure a fast linter (eslint/biome for JS, ruff for Python, clippy for Rust, golangci-lint for Go, checkstyle/spotless/detekt for the JVM) and run it in CI.' : undefined, }; }, @@ -323,6 +392,15 @@ export const feedbackChecks: Check[] = [ parts.push(part(ctx, 1, 'go')); notes.push('`go build ./...`'); } + if (hasJvm(ctx)) { + const build = jvmBuildTool(ctx); + parts.push(part(ctx, build ? 1 : 0.5, 'java', 'kotlin')); + notes.push( + build + ? `\`${build.run} ${build.tool === 'maven' ? 'compile' : 'classes'}\`` + : 'no root Maven/Gradle build to compile with', + ); + } const score = avg(parts); if (score === null) return { score: null, summary: 'No typed language detected' }; return { diff --git a/src/checks/navigability.ts b/src/checks/navigability.ts index 64e9323..1d85b9a 100644 --- a/src/checks/navigability.ts +++ b/src/checks/navigability.ts @@ -61,6 +61,8 @@ const CANDIDATES: IgnoreCandidate[] = [ { entry: 'dist/', dir: 'dist', onlyIfUntracked: true }, { entry: 'build/', dir: 'build', onlyIfUntracked: true }, { entry: 'out/', dir: 'out', onlyIfUntracked: true }, + // Maven and Cargo build output. + { entry: 'target/', dir: 'target', onlyIfUntracked: true }, { entry: 'coverage/', dir: 'coverage', onlyIfUntracked: true }, { entry: '.cache/', dir: '.cache', onlyIfUntracked: true }, { entry: '*.egg-info/', file: /(^|\/)[^/]+\.egg-info\// }, diff --git a/src/checks/type-safety.ts b/src/checks/type-safety.ts index 567e2e6..9daa26f 100644 --- a/src/checks/type-safety.ts +++ b/src/checks/type-safety.ts @@ -388,15 +388,18 @@ export const typeSafetyChecks: Check[] = [ { id: 'types.static', category: 'types', - title: 'Compiler-checked types (Go/Rust)', + title: 'Compiler-checked types (Go/Rust/Java/Kotlin)', weight: 1, run(ctx): CheckResult { - const langs = (['rust', 'go'] as const).filter((l) => ctx.languages.includes(l)); - if (langs.length === 0) return { score: null, summary: 'No Go/Rust' }; + const names = { rust: 'Rust', go: 'Go', java: 'Java', kotlin: 'Kotlin' } as const; + const langs = (['rust', 'go', 'java', 'kotlin'] as const).filter((l) => + ctx.languages.includes(l), + ); + if (langs.length === 0) return { score: null, summary: 'No Go/Rust/Java/Kotlin' }; return { score: 1, weightScale: ctx.share(...langs), - summary: `${langs.map((l) => (l === 'rust' ? 'Rust' : 'Go')).join(' + ')}: statically typed, checked by the compiler`, + summary: `${langs.map((l) => names[l]).join(' + ')}: statically typed, checked by the compiler`, }; }, }, diff --git a/src/context.ts b/src/context.ts index 11aef18..7567b01 100644 --- a/src/context.ts +++ b/src/context.ts @@ -28,7 +28,10 @@ export const HEAVY_DIRS = [ const MAX_FILES = 200_000; -export type Language = 'typescript' | 'javascript' | 'python' | 'go' | 'rust'; +/** Maven / Gradle build files (any module). */ +export const JVM_BUILD = /(^|\/)(?:pom\.xml|build\.gradle(?:\.kts)?|settings\.gradle(?:\.kts)?)$/; + +export type Language = 'typescript' | 'javascript' | 'python' | 'go' | 'rust' | 'java' | 'kotlin'; export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun'; @@ -330,8 +333,11 @@ export function createContext(rootInput: string): RepoContext { const pyCount = countExt(/\.py$/); const goCount = countExt(/\.go$/); const rsCount = countExt(/\.rs$/); - const otherCount = countExt(/\.(?:java|kt|scala|c|cc|cpp|h|hpp|cs|rb|php|swift|m|zig|ex|exs)$/); - const codeTotal = tsCount + jsCount + pyCount + goCount + rsCount + otherCount; + const javaCount = countExt(/\.java$/); + const ktCount = countExt(/\.kt$/); + const otherCount = countExt(/\.(?:scala|c|cc|cpp|h|hpp|cs|rb|php|swift|m|zig|ex|exs)$/); + const codeTotal = + tsCount + jsCount + pyCount + goCount + rsCount + javaCount + ktCount + otherCount; const significant = (n: number) => n > 0 && (n >= Math.max(3, codeTotal * 0.1) || n === codeTotal); const hasTsconfig = files.some( @@ -350,6 +356,11 @@ export function createContext(rootInput: string): RepoContext { if (pyManifest || significant(pyCount)) languages.push('python'); if (fileSet.has('go.mod') || significant(goCount)) languages.push('go'); if (fileSet.has('Cargo.toml') || significant(rsCount)) languages.push('rust'); + // A root Maven/Gradle build decides it; otherwise (e.g. an `android/` folder in a React Native + // app) Java/Kotlin must be a real share of the code. + const jvmBuild = files.some((f) => !f.includes('/') && JVM_BUILD.test(f)); + if ((jvmBuild && javaCount > 0) || significant(javaCount)) languages.push('java'); + if ((jvmBuild && ktCount > 0) || significant(ktCount)) languages.push('kotlin'); const codeFiles: Partial> = {}; const counts: Record = { typescript: tsCount, @@ -357,6 +368,8 @@ export function createContext(rootInput: string): RepoContext { python: pyCount, go: goCount, rust: rsCount, + java: javaCount, + kotlin: ktCount, }; for (const l of languages) codeFiles[l] = counts[l]; const detectedTotal = languages.reduce((n, l) => n + counts[l], 0); diff --git a/src/fix/agents-md.ts b/src/fix/agents-md.ts index 1ee4a4e..be11907 100644 --- a/src/fix/agents-md.ts +++ b/src/fix/agents-md.ts @@ -1,4 +1,5 @@ import { basename } from 'node:path'; +import { jvmBuildTool } from '../checks/feedback.js'; import { isDangerousScript } from '../checks/safety.js'; import { type RepoContext, runScriptCmd } from '../context.js'; @@ -143,6 +144,24 @@ export function detectCommands(ctx: RepoContext): Cmd[] { : { label: 'Vet (Go)', cmd: 'go vet ./...' }, ); } + const jvm = jvmBuildTool(ctx); + if ((ctx.languages.includes('java') || ctx.languages.includes('kotlin')) && jvm) { + const maven = jvm.tool === 'maven'; + cmds.push({ + label: 'Build (JVM)', + cmd: `${jvm.run} ${maven ? 'package -DskipTests' : 'build -x test'}`, + }); + cmds.push({ label: 'Run tests (JVM)', cmd: `${jvm.run} test` }); + const buildText = ['pom.xml', 'build.gradle', 'build.gradle.kts'] + .map((f) => ctx.read(f) ?? '') + .join('\n'); + if (/\bspotless\b/.test(buildText)) { + cmds.push({ + label: 'Format check (JVM)', + cmd: maven ? `${jvm.run} spotless:check` : `${jvm.run} spotlessCheck`, + }); + } + } if (makefile && cmds.length <= 1) { for (const target of ['build', 'test', 'lint', 'check']) { if (new RegExp(`^${target}:`, 'm').test(makefile)) @@ -252,6 +271,8 @@ export function generateAgentsMd(ctx: RepoContext): string { python: 'Python', go: 'Go', rust: 'Rust', + java: 'Java', + kotlin: 'Kotlin', }; const langs = ctx.languages.map((l) => LABELS[l] ?? l); const lines: string[] = []; diff --git a/test/jvm.test.ts b/test/jvm.test.ts new file mode 100644 index 0000000..1ad752d --- /dev/null +++ b/test/jvm.test.ts @@ -0,0 +1,101 @@ +import { mkdirSync, writeFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { describe, expect, it } from 'vitest'; +import { detectCommands } from '../src/checks/context-docs.js'; +import { testCommand } from '../src/checks/feedback.js'; +import { createContext } from '../src/context.js'; +import { generateAgentsMd } from '../src/fix/agents-md.js'; +import { scan } from '../src/scan.js'; +import type { Report } from '../src/types.js'; +import { fixture } from './helpers.js'; + +function check(report: Report, id: string) { + const c = report.checks.find((x) => x.id === id); + if (!c) throw new Error(`no check ${id}`); + return c; +} + +const javaClass = (name: string) => `package app;\n\npublic class ${name} {}\n`; + +function maven(extra: Record = {}): string { + return fixture(null, { + git: true, + files: { + 'pom.xml': + 'maven-checkstyle-plugin\n', + mvnw: '#!/bin/sh\n', + 'src/main/java/app/App.java': javaClass('App'), + 'src/main/java/app/Util.java': javaClass('Util'), + 'src/test/java/app/AppTest.java': javaClass('AppTest'), + ...extra, + }, + }); +} + +describe('Java/Kotlin detection', () => { + it('detects Java from a root Maven build and scores its feedback loops', async () => { + const dir = maven(); + expect(testCommand(createContext(dir))).toBe('./mvnw test'); + const r = await scan(dir); + expect(r.languages).toEqual(['java']); + expect(check(r, 'feedback.test')).toMatchObject({ + score: 1, + summary: 'Tests: `./mvnw test` (1 test files)', + }); + expect(check(r, 'feedback.lint').score).toBe(1); + expect(check(r, 'feedback.typecheck').summary).toBe('Typecheck: `./mvnw compile`'); + expect(check(r, 'types.static').summary).toBe( + 'Java: statically typed, checked by the compiler', + ); + }); + + it('detects Kotlin with Gradle and asks for a linter and tests', async () => { + const r = await scan( + fixture(null, { + git: true, + files: { + 'settings.gradle.kts': 'rootProject.name = "k"\n', + 'build.gradle.kts': 'plugins { kotlin("jvm") }\n', + 'src/main/kotlin/App.kt': 'fun main() {}\n', + }, + }), + ); + expect(r.languages).toEqual(['kotlin']); + expect(check(r, 'feedback.test')).toMatchObject({ score: 0 }); + expect(check(r, 'feedback.lint').score).toBe(0.6); + expect(check(r, 'feedback.typecheck').summary).toBe('Typecheck: `gradle classes`'); + }); + + it('does not make a JS app with a small android/ folder a Java project', async () => { + const r = await scan( + fixture('good-ts', { + git: true, + files: { + 'android/build.gradle': 'apply plugin: "com.android.application"\n', + 'android/app/src/main/java/com/app/MainActivity.java': javaClass('MainActivity'), + }, + }), + ); + expect(r.languages).not.toContain('java'); + }); + + it('generates and recognizes JVM commands in context docs', () => { + const md = generateAgentsMd(createContext(maven())); + expect(md).toContain('./mvnw package -DskipTests'); + expect(md).toContain('./mvnw test'); + expect([...detectCommands('```\n./mvnw test\n./mvnw package\n```')].sort()).toEqual([ + 'build', + 'test', + ]); + }); + + it('flags an unignored Maven target/ directory', async () => { + const dir = maven({ '.gitignore': '.idea/\n' }); + // build output appears after `git add`, so it is untracked (and not ignored) + mkdirSync(join(dir, 'target/classes'), { recursive: true }); + writeFileSync(join(dir, 'target/classes/App.class'), 'x'); + const r = await scan(dir); + const nav = check(r, 'nav.gitignore'); + expect(nav.findings?.some((f) => f.message.includes('add `target/`'))).toBe(true); + }); +});