Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Features

* **mvn:** add Maven (Java) filter module — test, compile, checkstyle:check, dependency:tree ([#1089](https://github.com/rtk-ai/rtk/pull/1089))
* **mvn:** enrich `mvn test` / `verify` / `integration-test` output with structured failure details read from `target/surefire-reports/TEST-*.xml` and `target/failsafe-reports/*.xml`. Stack traces are segmented on `Caused by:` with framework frames collapsed; the root-cause segment is always preserved.
* **mvn:** autodetect application package from `pom.xml` `<groupId>` (with `<parent>/<groupId>` fallback) for framework-frame classification. Override via `RTK_MVN_APP_PACKAGE`.
* **mvn:** red-flag heuristic — `no tests run` with no fresh XML reports emits a diagnostic pointing at surefire misconfiguration.

### Bug Fixes

* **git:** remove `-u` short alias from `--ultra-compact` to fix `git push -u` upstream tracking ([#1086](https://github.com/rtk-ai/rtk/issues/1086))
Expand Down
68 changes: 67 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ libc = "0.2"
toml = "0.8"

[dev-dependencies]
filetime = "0.2"
insta = "1"

[profile.release]
opt-level = 3
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ rtk filters and compresses command outputs before they reach your LLM context. S
| `git log` | 5x | 2,500 | 500 | -80% |
| `git add/commit/push` | 8x | 1,600 | 120 | -92% |
| `cargo test` / `npm test` | 5x | 25,000 | 2,500 | -90% |
| `mvn test` | 3x | 30,000 | 300 | -99% |
| `ruff check` | 3x | 3,000 | 600 | -80% |
| `pytest` | 4x | 8,000 | 800 | -90% |
| `go test` | 3x | 6,000 | 600 | -90% |
Expand Down Expand Up @@ -179,6 +180,7 @@ rtk go test # Go tests (NDJSON, -90%)
rtk cargo test # Cargo tests (-90%)
rtk rake test # Ruby minitest (-90%)
rtk rspec # RSpec tests (JSON, -60%+)
rtk mvn test # Maven tests (-99%)
rtk err <cmd> # Filter errors only from any command
rtk test <cmd> # Generic test wrapper - failures only (-90%)
```
Expand All @@ -195,6 +197,8 @@ rtk cargo clippy # Cargo clippy (-80%)
rtk ruff check # Python linting (JSON, -80%)
rtk golangci-lint run # Go linting (JSON, -85%)
rtk rubocop # Ruby linting (JSON, -60%+)
rtk mvn build # Maven build (-90%)
rtk mvn dependency:tree # Maven dependency tree (-60%+)
```

### Package Managers
Expand Down
59 changes: 59 additions & 0 deletions src/cmds/java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Java Ecosystem

> Part of [`src/cmds/`](../README.md) — see also [docs/contributing/TECHNICAL.md](../../../docs/contributing/TECHNICAL.md)

## Specifics

- **mvn_cmd.rs** handles Maven (`mvn`) and Maven Wrapper (`mvnw`) commands
- Auto-detects `mvnw` wrapper in project root; falls back to system `mvn`
- `mvn test` uses a state-machine parser (Preamble → Testing → Summary → Done) for 97-99%+ savings on real-world output
- `mvn compile` uses line filtering to strip `[INFO]` noise, download progress, JVM/native-access warnings, and plugin chatter (jOOQ codegen, Liquibase, npm/React builds, typescript-generator). Also routes `process-classes` and `test-compile` through the same filter (same noise profile)
- `mvn checkstyle:check` (aliased as `checkstyle`) compacts violation lines to `path:line:col [Rule] message`, strips mvn startup noise and Help-link boilerplate, keeps `N Checkstyle violations` summary and BUILD SUCCESS/FAILURE
- `mvn dependency:tree` strips "omitted for duplicate" lines, "version managed from" annotations, and collapses deep transitive branches
- Unknown goals stream via `cmd.status()` passthrough (safe for long-running goals like `spring-boot:run`); rare lifecycle phases (`package`, `install`, `verify`, `clean`, `deploy`) also passthrough — filtered only when the output shape matches compile
- Routing via Clap sub-enum with `#[command(external_subcommand)] Other` for unknown goals; compile-like and checkstyle goals received as `Other` are auto-re-dispatched by `route_goal` to the right filter

## Output enrichment from Surefire/Failsafe XML reports

When `mvn test` (or verify/integration-test) reports failures, rtk reads
`target/surefire-reports/TEST-*.xml` and `target/failsafe-reports/*.xml`
**after** the build finishes and appends a structured Failures section
with:

- Full stack trace per failure, with framework frames collapsed and the
root-cause segment preserved (up to 50 lines per trace).
- Captured stdout + stderr from failing tests only, capped at 2000 chars
per test and 10000 chars total.
- File counters in the footer: `(reports: N surefire, M failsafe, K stale files skipped)`.

### Application-package detection

rtk classifies stack frames as *application* vs *framework* by comparing
frame class names against the Java `groupId` from `pom.xml`:

1. `RTK_MVN_APP_PACKAGE` env var (if set, overrides everything).
2. `<project>/<groupId>` from the pom.xml in the current working directory.
3. Fallback: `<project>/<parent>/<groupId>`.
4. Otherwise: no filtering — full stack traces are preserved.

### Time-gated report reads

Stale XML reports from previous runs are skipped: only files with
`mtime >= started_at` (captured just before `mvn` executes) are parsed.

### Red-flag heuristic for "0 tests"

If the summary says `no tests run` but surefire reports are empty or
absent, rtk emits a diagnostic instead of the silent summary:

```
mvn test: 0 tests executed — surefire detected no tests. Check pom.xml (surefire plugin configuration) or run: rtk proxy mvn test
```

### Bypass

For the rare cases where you need the full raw Maven output:

```bash
rtk proxy mvn test
```
1 change: 1 addition & 0 deletions src/cmds/java/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
automod::dir!(pub "src/cmds/java");
Loading