Pewarta Proxy

πŸ“‹ Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

βš™οΈ Pengaturan Proxy Target

Skip to content

Latest commit

Β 

History

History
209 lines (172 loc) Β· 13.3 KB

AGENTS.md

File metadata and controls

209 lines (172 loc) Β· 13.3 KB

Custom Rules

  • Never write any comments in code
  • Exception: tests must use // given, // when, // then, // expect, and // and structural comments to separate test phases (does NOT apply to recipe tests using before/beforeAndAfter/after RewriteTest patterns)
  • Update AGENTS.md every time project structure is changed
  • ktlint must pass (./gradlew ktlintCheck); run the full ./gradlew check before pushing anything

Project Overview

allwrite is a CLI tool and collection of OpenRewrite recipes for automated code transformations across YAML, Gradle, Java/Kotlin, and Spring projects. It wraps OpenRewrite's runtime into a CLI that can run recipes by name, integrate with GitHub Actions, and work with Dependabot PRs.

Tech Stack

Category Technology
Primary language Kotlin
Secondary language Java (minimal, in allwrite-recipes)
Core framework OpenRewrite
Dependency injection Koin (with KSP annotation processing)
CLI framework Clikt
Logging SLF4J + Logback + kotlin-logging
Serialization kotlinx-serialization
HTTP client Ktor
Markdown rendering Markout, clikt-markdown, Mordant
Build system Gradle (Kotlin DSL) with composite build
Release management JReleaser + Axion Release Plugin
Testing Kotest (FunSpec), JUnit 5, MockK, OpenRewrite RewriteTest

Documentation

The documentation site is built with MkDocs from mkdocs.yml, docs/requirements.txt, and the docs/ directory.

  • docs/index.md β€” project overview
  • docs/cli.md β€” CLI reference
  • docs/contributing.md β€” recipe authoring guide
  • docs/recipes/index.md β€” built-in recipes overview and authoring helpers
  • docs/recipes/{yaml,gradle,java,spring}/ β€” individual built-in recipe pages grouped by category
  • Every new recipe gets a dedicated page under docs/recipes/ and a matching entry in mkdocs.yml navigation.
  • docs/extra.css β€” documentation layout overrides

Architecture

Multi-module Gradle project using Hexagonal Architecture (Ports & Adapters).

Module Dependency Graph

allwrite-cli  -->  allwrite-runtime  -->  allwrite-api
      |                  |                     ^
      |                  v                     |
      |            allwrite-recipes -----------+
      |                  |
      |                  v
      |            allwrite-spi
      |                  ^
      +-----> allwrite-completions
                    (annotation processor)
      |
      +-----> allwrite-recipes (direct, for recipe classpath)

Module Responsibilities

Module Role
allwrite-api Public API layer. Incoming port interfaces (RecipeExecutor, RecipeSource, RecipeCoordinates). Published as a Maven artifact.
allwrite-spi Published SPI for recipe authors. Base classes (AllwriteRecipe, CliAllwriteRecipe, AllwriteScanningRecipe, CliAllwriteScanningRecipe), RecipeMetadata, tag generation (including dependabot-artifact).
allwrite-recipes Pure OpenRewrite recipe implementations. Published as a Maven artifact. Depends on allwrite-api and allwrite-spi.
allwrite-runtime Domain layer. Outgoing port interfaces and OpenRewrite-backed implementations. Depends on allwrite-api.
allwrite-cli Application + Infrastructure layer. CLI commands, OS/GitHub integration, DI wiring.
allwrite-completions Build-time annotation processor for shell completion generation.
build-logic Gradle composite build with convention plugins and custom tasks.

Directory Structure

allwrite/
β”œβ”€β”€ allwrite-api/
β”‚   └── src/main/kotlin/              Incoming port interfaces (RecipeExecutor, RecipeSource, RecipeCoordinates)
β”‚
β”œβ”€β”€ allwrite-cli/
β”‚   β”œβ”€β”€ src/main/kotlin/              CLI application (commands, infrastructure adapters)
β”‚   β”‚   β”œβ”€β”€ runner/Main.kt            Entry point
β”‚   β”‚   β”œβ”€β”€ runner/RunnerModule.kt
β”‚   β”‚   β”œβ”€β”€ runner/application/       CLI commands (run, ls, external add/update/rm/ls), application logic
β”‚   β”‚   β”œβ”€β”€ runner/infrastructure/    OS, GitHub, PR manager adapters (incl. external recipe store)
β”‚   β”‚   └── runner/util/              Utility classes
β”‚   β”œβ”€β”€ src/main/resources/           logback.xml
β”‚   β”œβ”€β”€ src/test/kotlin/              Unit tests (Kotest FunSpec)
β”‚   └── src/e2e/kotlin/              End-to-end tests
β”‚
β”œβ”€β”€ allwrite-runtime/
β”‚   β”œβ”€β”€ src/main/kotlin/              Outgoing ports, recipe executor, source file parser
β”‚   β”œβ”€β”€ src/test/kotlin/              Unit tests (Kotest FunSpec)
β”‚   └── src/testFixtures/kotlin/      Shared test fakes/fixtures
β”‚
β”œβ”€β”€ allwrite-recipes/
β”‚   β”œβ”€β”€ src/main/kotlin/
β”‚   β”‚   β”œβ”€β”€ recipes/yaml/            YAML transformation recipes
β”‚   β”‚   β”œβ”€β”€ recipes/spring/          Spring property/annotation and migration recipes, including conditional dependency and custom Spring Boot 4 migration helpers
β”‚   β”‚   β”œβ”€β”€ recipes/java/            Java refactoring recipes
β”‚   β”‚   β”œβ”€β”€ recipes/gradle/          Gradle dependency recipes
β”‚   β”‚   β”‚   β”œβ”€β”€ *DependencyRewriter.kt  Dedicated helpers for Gradle dependency transforms
β”‚   β”‚   β”‚   β”œβ”€β”€ AddTomlVersionCatalogPlugin.kt  Add and apply version catalog plugins
β”‚   β”‚   β”‚   β”œβ”€β”€ AddSettingsPluginRepository.kt  Add gated repositories to Gradle settings files
β”‚   β”‚   β”‚   β”œβ”€β”€ AppliedPluginDetector.kt  Detect applied Gradle plugins
β”‚   β”‚   β”‚   β”œβ”€β”€ RemoveLibraryVersionRefs.kt  Remove version references from matching libraries
β”‚   β”‚   β”‚   └── RemoveTomlVersionCatalogLibrary.kt  Remove a library from a TOML version catalog
β”‚   β”‚   β”œβ”€β”€ recipes/properties/      Properties file recipes
β”‚   β”‚   β”œβ”€β”€ recipes/toml/            TOML utilities
β”‚   β”‚   └── recipes/util/            Shared recipe utilities
β”‚   β”œβ”€β”€ src/main/resources/META-INF/rewrite/   Declarative YAML recipes
β”‚   β”œβ”€β”€ src/test/kotlin/              Unit tests (JUnit 5 + RewriteTest)
β”‚   └── src/testFixtures/kotlin/      Test fixture classes
β”‚
β”œβ”€β”€ allwrite-spi/
β”‚   └── src/main/kotlin/              Recipe base classes (AllwriteRecipe, CliAllwriteRecipe, AllwriteScanningRecipe, CliAllwriteScanningRecipe, RecipeMetadata)
β”‚
β”œβ”€β”€ allwrite-completions/
β”‚   └── src/main/kotlin/              kapt processors + generators
β”‚
β”œβ”€β”€ build-logic/
β”‚   └── src/main/kotlin/
β”‚       β”œβ”€β”€ conventions/              Convention plugins (kotlin, koin, openrewrite-recipe-library, jreleaser, etc.)
β”‚       └── *.kt                      Custom Gradle tasks (FetchJdkTask, etc.)
β”‚
β”œβ”€β”€ gradle/
β”‚   β”œβ”€β”€ libs.versions.toml            Central dependency version catalog
β”‚   └── wrapper/
β”‚
β”œβ”€β”€ .github/workflows/               CI, documentation build/publish, and releases
β”œβ”€β”€ docs/                            MkDocs documentation source, recipe catalog, and dependencies
└── mkdocs.yml                       MkDocs site configuration

Entry Point

allwrite-cli/src/main/kotlin/pl/allegro/tech/allwrite/runner/Main.kt

The main() function bootstraps Koin DI, conditionally loads GithubModule when running in GitHub Actions, then delegates to AppEntrypoint.execute(args). AppEntrypoint is implemented by MainCommand (a Clikt command) dispatching to sub-commands.

Coding Conventions

Style

  • Kotlin explicit API mode is enabled β€” all public declarations require explicit visibility modifiers
  • .editorconfig enforces: 4-space indentation, 160 char line length, LF line endings, UTF-8
  • Kotlin style: ktlint_code_style = intellij_idea, trailing commas required, no star imports
  • YAML files: 2-space indentation
  • Shell scripts: 2-space indentation

Naming

  • Kotlin files: PascalCase class names matching file names
  • Test files: *Spec.kt (Kotest) or *Test.kt (JUnit)
  • Packages: pl.allegro.tech.allwrite.*
  • Koin modules: *Module.kt
  • Incoming port interfaces: in pl.allegro.tech.allwrite.api package (allwrite-api module)
  • Outgoing port interfaces: under port/outgoing/ in allwrite-runtime
  • Fake test implementations: Fake* prefix

Patterns

  • Hexagonal Architecture: Incoming ports (RecipeExecutor, RecipeSource, AppEntrypoint) and outgoing ports (UserProblemReporter, InputFilesProvider, GitMetadata, PullRequestContext, TelemetryPublisher, SystemInfo, ExternalRecipeJarsProvider)
  • Koin + KSP DI: Modules annotated with @Module and @ComponentScan, services with @Single
  • Convention Plugins: Shared build logic in build-logic/ (conventions.kotlin, conventions.koin, conventions.recipe-classpaths, etc.)
  • Template Method: SubCommand abstract class defines run() lifecycle; subclasses implement runSubCommand(). ExternalSubCommand extends SubCommand as a marker for commands nested under the external group. ExternalCommand is a Clikt group command that collects ExternalSubCommand instances as subcommands.
  • Observer/Listener: CommandListener instances notified after each command execution (telemetry)
  • Recipe Strategy: Recipes can implement ParsingAwareRecipe or PostprocessingRecipe. Base classes: AllwriteRecipe, CliAllwriteRecipe, AllwriteScanningRecipe, CliAllwriteScanningRecipe
  • Test Fakes over Mocks: Heavy use of Fake* implementations for test isolation
  • Tag-based Recipe Metadata: Custom tag system (group:*, action:*, from:*, to:*, dependabot-artifact:*) for CLI recipe discovery, version matching, and Dependabot integration
  • Declarative Recipes: Recipes defined programmatically (Kotlin) or declaratively (YAML under META-INF/rewrite/)

Testing

Module Location Framework Naming
allwrite-cli src/test/kotlin/ Kotest FunSpec *Spec.kt
allwrite-cli src/e2e/kotlin/ Kotest FunSpec *IntegrationSpec.kt
allwrite-runtime src/test/kotlin/ Kotest FunSpec *Spec.kt
allwrite-recipes src/test/kotlin/ JUnit 5 + RewriteTest *Test.kt
  • BaseRunnerSpec β€” abstract base for runner tests, sets up Koin DI with faked modules
  • BaseRuntimeSpec β€” abstract base for runtime tests
  • Test fixtures shared via testFixtures source set
  • Recipe tests use OpenRewrite's RewriteTest interface for before/after source assertions

Commands

Command Description
./gradlew test Run unit tests across all modules
./gradlew build Full build including JReleaser assembly
./gradlew :allwrite-cli:run --args "<args>" Run the CLI locally
./gradlew :allwrite-cli:e2e Run end-to-end tests
./gradlew check Run tests + e2e

Key Dependencies

Core: openrewrite (rewrite-core, rewrite-java, rewrite-java-11, rewrite-java-17, rewrite-java-21, rewrite-kotlin, rewrite-yaml, rewrite-toml, rewrite-properties, rewrite-gradle, rewrite-groovy), openrewrite-recipe (rewrite-spring, rewrite-static-analysis), koin-core, koin-annotations, koin-ksp-compiler, clikt, clikt-markdown, markout, markout-markdown, kotlin-reflect, kotlinx-serialization-json, kotlinx-datetime

Infrastructure: ktor-client-core, ktor-client-cio, ktor-client-content-negotiation, ktor-serialization-kotlinx-json, github-client (Spotify), java-semver, snakeyaml, logback-classic, kotlin-logging, slf4j-api

Build-only: kotlinpoet-jvm, mustache-java, auto-service, commons-compress, pgpainless-core, jackson-module-kotlin

Testing: kotest-runner-junit5-jvm, kotest-assertions-core-jvm, kotest-framework-datatest, kotest-extensions-koin, mockk, rewrite-test, junit-jupiter, assertj-core