Skip to content
Merged
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
22 changes: 15 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ Multi-module Gradle project using **Hexagonal Architecture (Ports & Adapters)**.
## Module Dependency Graph

```
allwrite-cli --> allwrite-runtime --> allwrite-recipes
| ^
+-----> allwrite-completions ----------------+
allwrite-cli --> allwrite-runtime --> allwrite-api
| | ^
| v |
| allwrite-recipes -----------+
| ^
+-----> allwrite-completions
(annotation processor)
|
+-----> allwrite-recipes (direct, for recipe classpath)
Expand All @@ -49,8 +52,9 @@ allwrite-cli --> allwrite-runtime --> allwrite-recipes

| Module | Role |
|---|---|
| `allwrite-recipes` | Pure OpenRewrite recipe implementations. Published as a Maven artifact. |
| `allwrite-runtime` | Domain layer. Port interfaces and OpenRewrite-backed implementations. |
| `allwrite-api` | Public API layer. Incoming port interfaces (`RecipeExecutor`, `RecipeSource`, `RecipeCoordinates`). Published as a Maven artifact. |
| `allwrite-recipes` | Pure OpenRewrite recipe implementations. Published as a Maven artifact. Depends on `allwrite-api`. |
| `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. |
Expand All @@ -59,6 +63,9 @@ allwrite-cli --> allwrite-runtime --> allwrite-recipes

```
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
Expand All @@ -71,7 +78,7 @@ allwrite/
│ └── src/e2e/kotlin/ End-to-end tests
├── allwrite-runtime/
│ ├── src/main/kotlin/ Ports, recipe executor, source file parser
│ ├── src/main/kotlin/ Outgoing ports, recipe executor, source file parser
│ ├── src/test/kotlin/ Unit tests (Kotest FunSpec)
│ └── src/testFixtures/kotlin/ Shared test fakes/fixtures
Expand Down Expand Up @@ -126,7 +133,8 @@ The `main()` function bootstraps Koin DI, conditionally loads `GithubModule` whe
- Test files: `*Spec.kt` (Kotest) or `*Test.kt` (JUnit)
- Packages: `pl.allegro.tech.allwrite.*`
- Koin modules: `*Module.kt`
- Port interfaces: under `port/incoming/` and `port/outgoing/`
- 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
Expand Down
16 changes: 16 additions & 0 deletions allwrite-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id("conventions.kotlin")
id("conventions.publishable-library")
}

publishableLibrary {
name = "allwrite-api"
description = "Public API for allwrite runtime - incoming port interfaces"
}

dependencies {
api(platform(libs.rewrite.bom))
api(libs.rewrite.core)

api(libs.semver)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.allegro.tech.allwrite.runtime.port.incoming
package pl.allegro.tech.allwrite.api

import com.github.zafarkhaja.semver.Version
import org.openrewrite.config.RecipeDescriptor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.allegro.tech.allwrite.runtime.port.incoming
package pl.allegro.tech.allwrite.api

import org.openrewrite.Recipe
import java.nio.file.Path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.allegro.tech.allwrite.runtime.port.incoming
package pl.allegro.tech.allwrite.api

import org.openrewrite.Recipe
import org.openrewrite.config.RecipeDescriptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import com.github.ajalt.clikt.parameters.options.option
import io.koalaql.markout.md.markdown
import org.koin.core.annotation.Single
import org.openrewrite.config.RecipeDescriptor
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeSource
import pl.allegro.tech.allwrite.runtime.port.incoming.tagPropertyOrNull
import pl.allegro.tech.allwrite.runtime.port.incoming.toCompactString
import pl.allegro.tech.allwrite.runtime.port.incoming.toRecipeCoordinatesOrNull
import pl.allegro.tech.allwrite.api.RecipeSource
import pl.allegro.tech.allwrite.api.tagPropertyOrNull
import pl.allegro.tech.allwrite.api.toCompactString
import pl.allegro.tech.allwrite.api.toRecipeCoordinatesOrNull
import pl.allegro.tech.allwrite.RecipeVisibility.PUBLIC
import pl.allegro.tech.allwrite.cli.application.CommandExecutionResult.ExecutionResult
import com.github.ajalt.mordant.markdown.Markdown as MdWidget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import kotlinx.serialization.Serializable
import org.koin.core.annotation.Single
import org.openrewrite.Recipe
import org.openrewrite.RecipeException
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeSource
import pl.allegro.tech.allwrite.api.RecipeSource
import pl.allegro.tech.allwrite.cli.util.JSON
import java.io.File
import java.io.FileNotFoundException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package pl.allegro.tech.allwrite.cli.application
import com.github.zafarkhaja.semver.Version
import org.koin.core.annotation.Single
import org.openrewrite.config.RecipeDescriptor
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeCoordinates
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeSource
import pl.allegro.tech.allwrite.runtime.port.incoming.getFromVersion
import pl.allegro.tech.allwrite.runtime.port.incoming.getToVersion
import pl.allegro.tech.allwrite.runtime.port.incoming.tagPropertyOrNull
import pl.allegro.tech.allwrite.api.RecipeCoordinates
import pl.allegro.tech.allwrite.api.RecipeSource
import pl.allegro.tech.allwrite.api.getFromVersion
import pl.allegro.tech.allwrite.api.getToVersion
import pl.allegro.tech.allwrite.api.tagPropertyOrNull

@Single
internal class RecipeMatcher(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import com.github.ajalt.clikt.parameters.options.option
import com.github.zafarkhaja.semver.Version
import org.koin.core.annotation.Single
import org.openrewrite.Recipe
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeCoordinates
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeExecutor
import pl.allegro.tech.allwrite.api.RecipeCoordinates
import pl.allegro.tech.allwrite.api.RecipeExecutor
import pl.allegro.tech.allwrite.cli.application.CommandExecutionResult.ExecutionResult
import pl.allegro.tech.allwrite.cli.application.Messages.LIST_RECIPES_HINT
import pl.allegro.tech.allwrite.cli.application.port.outgoing.InputFilesProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.github.ajalt.clikt.parameters.options.required
import kotlinx.serialization.Serializable
import org.koin.core.annotation.Single
import org.openrewrite.Recipe
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeExecutor
import pl.allegro.tech.allwrite.api.RecipeExecutor
import pl.allegro.tech.allwrite.cli.application.CommandExecutionResult.ExecutionResult
import pl.allegro.tech.allwrite.cli.application.port.outgoing.InputFilesProvider
import pl.allegro.tech.allwrite.cli.util.JSON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package pl.allegro.tech.allwrite.cli.application

import com.github.zafarkhaja.semver.Version as DomainVersion
import kotlinx.serialization.Serializable
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeCoordinates
import pl.allegro.tech.allwrite.api.RecipeCoordinates

private val GROUPS_BY_ARTIFACT = mapOf<String, String>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import pl.allegro.tech.allwrite.cli.base.BaseCliSpec
import pl.allegro.tech.allwrite.runtime.fake.FakeRecipe
import pl.allegro.tech.allwrite.runtime.fake.FakeRecipeSource
import pl.allegro.tech.allwrite.runtime.fake.FakeRuntimeModule
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeCoordinates
import pl.allegro.tech.allwrite.api.RecipeCoordinates
import pl.allegro.tech.allwrite.runtime.util.injectEagerly

class RecipeMatcherSpec : BaseCliSpec() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import org.koin.core.context.startKoin
import org.koin.ksp.generated.module
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeSource
import pl.allegro.tech.allwrite.api.RecipeSource
import pl.allegro.tech.allwrite.kapt.generators.CompletionGenerator
import pl.allegro.tech.allwrite.kapt.util.injectAll
import java.io.File
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import com.squareup.kotlinpoet.SET
import com.squareup.kotlinpoet.STRING
import org.koin.core.annotation.Single
import org.openrewrite.config.RecipeDescriptor
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeCoordinates
import pl.allegro.tech.allwrite.runtime.port.incoming.toRecipeCoordinatesOrNull
import pl.allegro.tech.allwrite.api.RecipeCoordinates
import pl.allegro.tech.allwrite.api.toRecipeCoordinatesOrNull

@Single
internal class RecipeCanonicalNameCompletionGenerator : CompletionGenerator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.github.mustachejava.Mustache
import com.squareup.kotlinpoet.PropertySpec
import org.koin.core.annotation.Single
import org.openrewrite.config.RecipeDescriptor
import pl.allegro.tech.allwrite.runtime.port.incoming.toRecipeCoordinatesOrNull
import pl.allegro.tech.allwrite.api.toRecipeCoordinatesOrNull
import pl.allegro.tech.allwrite.kapt.util.MustacheUtils.executeToString
import pl.allegro.tech.allwrite.kapt.util.MustacheUtils.resourceTemplate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.github.mustachejava.Mustache
import com.squareup.kotlinpoet.PropertySpec
import org.koin.core.annotation.Single
import org.openrewrite.config.RecipeDescriptor
import pl.allegro.tech.allwrite.runtime.port.incoming.toRecipeCoordinatesOrNull
import pl.allegro.tech.allwrite.api.toRecipeCoordinatesOrNull
import pl.allegro.tech.allwrite.kapt.util.MustacheUtils.executeToString
import pl.allegro.tech.allwrite.kapt.util.MustacheUtils.resourceTemplate

Expand Down
2 changes: 1 addition & 1 deletion allwrite-recipes/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ recipeDependencies {

dependencies {
api(projects.allwriteSpi)
implementation(projects.allwriteRuntime)
implementation(projects.allwriteApi)

implementation(platform(libs.rewrite.bom))
implementation(libs.rewrite.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package pl.allegro.tech.allwrite.recipes

import org.koin.core.annotation.ComponentScan
import org.koin.core.annotation.Module
import pl.allegro.tech.allwrite.runtime.RuntimeModule

@Module(includes = [RuntimeModule::class])
@Module
@ComponentScan
public class RecipesModule
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.koin.core.component.inject
import org.openrewrite.Recipe
import pl.allegro.tech.allwrite.AllwriteRecipe
import pl.allegro.tech.allwrite.RecipeVisibility.PUBLIC
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeSource
import pl.allegro.tech.allwrite.api.RecipeSource
import kotlin.getValue

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.koin.core.component.inject
import org.openrewrite.Recipe
import pl.allegro.tech.allwrite.AllwriteRecipe
import pl.allegro.tech.allwrite.RecipeVisibility.PUBLIC
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeSource
import pl.allegro.tech.allwrite.api.RecipeSource
import kotlin.getValue

/**
Expand Down
1 change: 1 addition & 0 deletions allwrite-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
}

dependencies {
api(projects.allwriteApi)
api(projects.allwriteSpi)

// OpenRewrite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.openrewrite.Recipe
import org.openrewrite.RecipeRun
import org.openrewrite.SourceFile
import org.openrewrite.internal.InMemoryLargeSourceSet
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeExecutor
import pl.allegro.tech.allwrite.api.RecipeExecutor
import pl.allegro.tech.allwrite.runtime.port.outgoing.Problem
import pl.allegro.tech.allwrite.runtime.port.outgoing.UserProblemReporter
import pl.allegro.tech.allwrite.runtime.util.WORKDIR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import org.openrewrite.Recipe
import org.openrewrite.config.Environment
import org.openrewrite.config.RecipeDescriptor
import pl.allegro.tech.allwrite.RecipeVisibility.PUBLIC
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeSource
import pl.allegro.tech.allwrite.runtime.port.incoming.tagPropertyOrNull
import pl.allegro.tech.allwrite.api.RecipeSource
import pl.allegro.tech.allwrite.api.tagPropertyOrNull
import pl.allegro.tech.allwrite.runtime.port.outgoing.ExternalRecipeProvider
import java.net.URLClassLoader

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.equals.shouldBeEqual
import io.kotest.matchers.shouldBe
import org.openrewrite.config.RecipeDescriptor
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeCoordinates
import pl.allegro.tech.allwrite.runtime.port.incoming.getFromVersion
import pl.allegro.tech.allwrite.runtime.port.incoming.getToVersion
import pl.allegro.tech.allwrite.runtime.port.incoming.toRecipeCoordinatesOrNull
import pl.allegro.tech.allwrite.api.RecipeCoordinates
import pl.allegro.tech.allwrite.api.getFromVersion
import pl.allegro.tech.allwrite.api.getToVersion
import pl.allegro.tech.allwrite.api.toRecipeCoordinatesOrNull
import java.net.URI

class RecipeCoordinatesSpec : FunSpec() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import pl.allegro.tech.allwrite.runtime.fake.FakePostProcessingRecipe
import pl.allegro.tech.allwrite.runtime.fake.FakeRecipe
import pl.allegro.tech.allwrite.runtime.fake.FakeThrowingRecipe
import pl.allegro.tech.allwrite.runtime.fake.FakeUserProblemReporter
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeExecutor
import pl.allegro.tech.allwrite.api.RecipeExecutor
import pl.allegro.tech.allwrite.runtime.port.outgoing.Problem
import pl.allegro.tech.allwrite.runtime.util.injectEagerly
import java.nio.file.Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import io.kotest.matchers.collections.shouldContainAll
import io.kotest.matchers.collections.shouldNotContainAnyOf
import org.koin.test.inject
import pl.allegro.tech.allwrite.runtime.base.BaseRuntimeSpec
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeSource
import pl.allegro.tech.allwrite.api.RecipeSource

class RecipeSourceSpec : BaseRuntimeSpec() {
init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package pl.allegro.tech.allwrite.runtime.fake

import org.koin.core.annotation.Single
import org.openrewrite.Recipe
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeExecutor
import pl.allegro.tech.allwrite.api.RecipeExecutor
import java.nio.file.Path

@Single
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import org.koin.core.annotation.Single
import org.openrewrite.Recipe
import org.openrewrite.RecipeException
import org.openrewrite.config.RecipeDescriptor
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeSource
import pl.allegro.tech.allwrite.runtime.port.incoming.tagPropertyOrNull
import pl.allegro.tech.allwrite.api.RecipeSource
import pl.allegro.tech.allwrite.api.tagPropertyOrNull
import pl.allegro.tech.allwrite.RecipeVisibility.PUBLIC

@Single
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.koin.core.module.Module
import org.koin.core.parameter.ParametersDefinition
import org.koin.core.qualifier.Qualifier
import org.koin.test.KoinTest
import pl.allegro.tech.allwrite.runtime.port.incoming.RecipeSource
import pl.allegro.tech.allwrite.api.RecipeSource
import pl.allegro.tech.allwrite.runtime.fake.FakeRecipeSource
import kotlin.reflect.KClass
import kotlin.reflect.KProperty
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencyResolutionManagement {

rootProject.name = "allwrite"

include("allwrite-api")
include("allwrite-completions")
include("allwrite-runtime")
include("allwrite-recipes")
Expand Down
Loading