Skip to content

static-var/AgentPreview

Repository files navigation

AgentPreview

AgentPreview is a Gradle plugin that captures AndroidX Compose @Preview functions into files an AI agent can inspect:

<module>/build/agentPreviewSnapshots/<sanitized-preview-id>/<platform>-<viewport>/
  screenshot.png
  snapshot.json

Preview ids are sanitized for file paths: :app:main:LoginPreview becomes app-main-LoginPreview, and viewport folders include the platform, e.g. android-phone.

Use it when an agent is editing Compose UI and needs a quick screenshot plus structured preview data without driving the full app.

Local setup

The plugin is not published yet. Add this checkout as an included build in the target project's settings.gradle.kts:

pluginManagement {
    includeBuild("/path/to/AgentPreview")
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

Apply the plugin to the Android app/library or Compose Multiplatform module that owns the previews:

plugins {
    id("dev.staticvar.agentpreview")
}

Basic commands

List previews first:

./gradlew :app:listComposePreviews

Capture previews:

./gradlew :app:captureComposePreviews

For a focused capture while iterating:

./gradlew :app:captureComposePreviews \
  -PagentPreview.previewNameFilter=Login \
  -PagentPreview.viewportFilter=phone \
  -PagentPreview.maxCaptures=4

Outputs are written under:

  • snapshots: <module>/build/agentPreviewSnapshots/<sanitized-preview-id>/<platform>-<viewport>/
  • capture report: <module>/build/agentPreviewReports/capture-report.json

More docs

Current support and limitations

  • Supports Android app/library modules and Compose Multiplatform modules through an Android target.
  • Rendering is Android-backed; desktop and web Compose renderers are not separate targets yet.
  • @PreviewParameter is supported for one annotated user parameter.
  • Layout-tree source hints are experimental, best-effort, and sometimes missing.
  • Fake renderer mode (-PagentPreview.fakeRenderer=true) is for discovery/debug wiring only; do not judge UI from its placeholder outputs.

License

MIT. See LICENSE.

About

Gradle-first Compose preview snapshots for coding agents

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors