Skip to content

feat: add Kotlin/Android error and stacktrace compression#8

Open
Cyvid7-Darus10 wants to merge 1 commit intojee599:mainfrom
Cyvid7-Darus10:feat/kotlin-android-filter
Open

feat: add Kotlin/Android error and stacktrace compression#8
Cyvid7-Darus10 wants to merge 1 commit intojee599:mainfrom
Cyvid7-Darus10:feat/kotlin-android-filter

Conversation

@Cyvid7-Darus10
Copy link
Copy Markdown

@Cyvid7-Darus10 Cyvid7-Darus10 commented Apr 5, 2026

This addresses #2 by adding a Kotlin/Android filter to contextzip. I took a look at how the existing filters work (cargo_cmd, go_cmd, error_cmd) and followed the same pattern for Gradle/Kotlin.

The new contextzip gradle command handles three kinds of noise that Android developers deal with constantly. First, Kotlin compiler errors — those e: and w: lines get collected and presented as a numbered summary instead of being buried in build output. Second, Android/JVM stack traces — framework frames from android.*, androidx.*, java.*, kotlin.*, kotlinx.*, dalvik.*, and friends get collapsed into a "(+ N framework frames hidden)" line while your app code stays visible. Third, Gradle task spam — those 30+ "> Task :app:compileSomething" lines that nobody reads get collapsed into a single "(N Gradle tasks executed)" summary. The BUILD SUCCESSFUL/FAILED line is always preserved.

Here is what the before/after looks like for a typical Android build failure:

Before (raw Gradle output):

> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
... 28 more task lines ...
> Task :app:compileDebugKotlin
e: file:///src/App.kt:15:42 Unresolved reference: foo
e: file:///src/Bar.kt:30:10 Type mismatch
> Task :app:compileDebugKotlin FAILED
BUILD FAILED in 12s

After (contextzip gradle build):

Kotlin: 2 errors
1. e: file:///src/App.kt:15:42 Unresolved reference: foo
2. e: file:///src/Bar.kt:30:10 Type mismatch

(31 Gradle tasks executed)
BUILD FAILED in 12s

And for stack traces, a typical Android crash that spits out 15+ framework frames gets compressed to just your app frames plus a hidden count.

The implementation registers contextzip gradle {build,test,lint} as subcommands with passthrough for any other Gradle tasks. I also added .kt/.kts extension mapping to the Java language in filter.rs for code filtering, and added the gradle/gradlew/./gradlew pattern to discover/rules.rs so the hook can automatically rewrite gradle commands. All 1056 existing tests still pass along with the 7 new ones I added.

Closes #2

Adds a new `contextzip gradle` command that compresses Kotlin compiler
errors, Android/JVM stack traces, and Gradle build noise.

- Kotlin compiler errors (e:/w: lines) are collected and summarized
- Android/JVM stack frames from framework packages (android.*, kotlin.*,
  java.*, androidx.*, dalvik.*, etc.) are collapsed with a count
- Gradle task lines are collapsed into a single count summary
- Gradle download and configuration noise is stripped
- BUILD SUCCESSFUL/FAILED result lines are always preserved
- Caused-by exception chains are preserved

Registered as `contextzip gradle {build,test,lint}` with passthrough
for other Gradle subcommands. Added .kt/.kts extension mapping to the
Java language for code filtering. Includes 7 unit tests covering
compiler errors, stacktrace compression, task collapse, and mixed
output scenarios.

Closes jee599#2
@Cyvid7-Darus10 Cyvid7-Darus10 force-pushed the feat/kotlin-android-filter branch from 91347e6 to 7378864 Compare April 5, 2026 08:00
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.

Add Kotlin/Android stacktrace compression

1 participant