Skip to content

Commit 7fd99ec

Browse files
Merge pull request #234 from SpineEventEngine/migrate-to-compiler
Migrate to the Compiler API
2 parents 7ad0eeb + 750b564 commit 7fd99ec

File tree

194 files changed

+3378
-10119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+3378
-10119
lines changed

.agents/_TOC.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Table of Contents
2+
3+
1. [Quick Reference Card](quick-reference-card.md)
4+
2. [Project overview](project-overview.md)
5+
3. [Coding guidelines](coding-guidelines.md)
6+
4. [Documentation & comments](documentation-guidelines.md)
7+
5. [Documentation tasks](documentation-tasks.md)
8+
6. [Running builds](running-builds.md)
9+
7. [Version policy](version-policy.md)
10+
8. [Project structure expectations](project-structure-expectations.md)
11+
9. [Testing](testing.md)
12+
10. [Safety rules](safety-rules.md)
13+
11. [Advanced safety rules](advanced-safety-rules.md)
14+
12. [Refactoring guidelines](refactoring-guidelines.md)
15+
13. [Common tasks](common-tasks.md)
16+
14. [Java to Kotlin conversion](java-kotlin-conversion.md)

.agents/advanced-safety-rules.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 🚨 Advanced safety rules
2+
3+
- Do **not** auto-update external dependencies without explicit request.
4+
- Do **not** inject analytics or telemetry code.
5+
- Flag any usage of unsafe constructs (e.g., reflection, I/O on the main thread).
6+
- Avoid generating blocking calls inside coroutines.

.agents/coding-guidelines.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# 🧾 Coding guidelines
2+
3+
## Core principles
4+
5+
- Adhere to [Spine Event Engine Documentation][spine-docs] for coding style.
6+
- Generate code that compiles cleanly and passes static analysis.
7+
- Respect existing architecture, naming conventions, and project structure.
8+
- Write clear, incremental commits with descriptive messages.
9+
- Include automated tests for any code change that alters functionality.
10+
11+
## Kotlin best practices
12+
13+
### ✅ Prefer
14+
- **Kotlin idioms** over Java-style approaches:
15+
- Extension functions
16+
- `when` expressions
17+
- Smart casts
18+
- Data classes and sealed classes
19+
- Immutable data structures
20+
- **Simple nouns** over composite nouns (`user` > `userAccount`)
21+
- **Generic parameters** over explicit variable types (`val list = mutableList<Dependency>()`)
22+
- **Java interop annotations** only when needed (`@file:JvmName`, `@JvmStatic`)
23+
- **Kotlin DSL** for Gradle files
24+
25+
### ❌ Avoid
26+
- Mutable data structures
27+
- Java-style verbosity (builders with setters)
28+
- Redundant null checks (`?.let` misuse)
29+
- Using `!!` unless clearly justified
30+
- Type names in variable names (`userObject`, `itemList`)
31+
- String duplication (use constants in companion objects)
32+
- Mixing Groovy and Kotlin DSLs in build logic
33+
- Reflection unless specifically requested
34+
35+
## Text formatting
36+
- ✅ Remove double empty lines in the code.
37+
- ✅ Remove trailing space characters in the code.
38+
39+
[spine-docs]: https://github.com/SpineEventEngine/documentation/wiki

.agents/common-tasks.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 📋 Common tasks
2+
3+
- **Adding a new dependency**: Update relevant files in `buildSrc` directory.
4+
- **Creating a new module**: Follow existing module structure patterns.
5+
- **Documentation**: Use KDoc style for public and internal APIs.
6+
- **Testing**: Create comprehensive tests using Kotest assertions.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Documentation & comments
2+
3+
## Commenting guidelines
4+
- Avoid inline comments in production code unless necessary.
5+
- Inline comments are helpful in tests.
6+
- When using TODO comments, follow the format on the [dedicated page][todo-comments].
7+
- File and directory names should be formatted as code.
8+
9+
## Avoid widows, runts, orphans, or rivers
10+
11+
Agents should **AVOID** text flow patters illustrated
12+
on [this diagram](widow-runt-orphan-river.jpg).
13+
14+
[todo-comments]: https://github.com/SpineEventEngine/documentation/wiki/TODO-comments

.agents/documentation-tasks.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# 📄 Documentation tasks
2+
3+
1. Ensure all public and internal APIs have KDoc examples.
4+
2. Add in-line code blocks for clarity in tests.
5+
3. Convert inline API comments in Java to KDoc in Kotlin:
6+
```java
7+
// Literal string to be inlined whenever a placeholder references a non-existent argument.
8+
private final String missingArgumentMessage = "[MISSING ARGUMENT]";
9+
```
10+
transforms to:
11+
```kotlin
12+
/**
13+
* Literal string to be inlined whenever a placeholder references a non-existent argument.
14+
*/
15+
private val missingArgumentMessage = "[MISSING ARGUMENT]"
16+
```
17+
18+
4. Javadoc -> KDoc conversion tasks:
19+
- Remove `<p>` tags in the line with text: `"<p>This"` -> `"This"`.
20+
- Replace `<p>` with empty line if the tag is the only text in the line.

.agents/java-kotlin-conversion.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# 🪄 Converting Java code to Kotlin
2+
3+
* Java code API comments are Javadoc format.
4+
* Kotlin code API comments are in KDoc format.
5+
6+
## Javadoc to KDoc conversion
7+
8+
* The wording of original Javadoc comments must be preserved.
9+
10+
## Treating nullability
11+
12+
* Use nullable Kotlin type only if the type in Java is annotated as `@Nullable`.
13+
14+
## Efficient Conversion Workflow
15+
16+
* First, analyze the entire Java file structure before beginning conversion to understand dependencies and class relationships.
17+
* Convert Java code to Kotlin systematically: imports first, followed by class definitions, methods, and finally expressions.
18+
* Preserve all existing functionality and behavior during conversion.
19+
* Maintain original code structure and organization to ensure readability.
20+
21+
## Common Java to Kotlin Patterns
22+
23+
* Convert Java getters/setters to Kotlin properties with appropriate visibility modifiers.
24+
* Transform Java static methods to companion object functions or top-level functions as appropriate.
25+
* Replace Java anonymous classes with Kotlin lambda expressions when possible.
26+
* Convert Java interfaces with default methods to Kotlin interfaces with implementations.
27+
* Transform Java builders to Kotlin DSL patterns when appropriate.
28+
29+
## Error Prevention
30+
31+
* Pay special attention to Java's checked exceptions versus Kotlin's unchecked exceptions.
32+
* Be cautious with Java wildcards (`? extends`, `? super`) conversion to Kotlin's `out` and `in` type parameters.
33+
* Ensure proper handling of Java static initialization blocks in Kotlin companion objects.
34+
* Verify that Java overloaded methods convert correctly with appropriate default parameter values in Kotlin.
35+
* Remember that Kotlin has smart casts which can eliminate explicit type casting needed in Java.
36+
37+
## Documentation Conversion
38+
39+
* Convert `@param` to `@param` with the same description.
40+
* Convert `@return` to `@return` with the same description.
41+
* Convert `@throws` to `@throws` with the same description.
42+
* Convert `{@link}` to `[name][fully.qualified.Name]` format.
43+
* Convert `{@code}` to inline code with backticks (`).

.agents/project-overview.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 🛠️ Project overview
2+
3+
- **Languages**: Kotlin (primary), Java (secondary).
4+
- **Build tool**: Gradle with Kotlin DSL.
5+
- **Static analysis**: detekt, ErrorProne, Checkstyle, PMD.
6+
- **Testing**: JUnit 5, Kotest Assertions, Codecov.
7+
- **Tools used**: Gradle plugins, IntelliJ IDEA Platform, KSP, KotlinPoet, Dokka.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 📁 Project structure expectations
2+
3+
```yaml
4+
.github
5+
buildSrc/
6+
<module-1>
7+
src/
8+
├── main/
9+
│ ├── kotlin/ # Kotlin source files
10+
│ └── java/ # Legacy Java code
11+
├── test/
12+
│ └── kotlin/ # Unit and integration tests
13+
build.gradle.kts # Kotlin-based build configuration
14+
<module-2>
15+
<module-3>
16+
build.gradle.kts # Kotlin-based build configuration
17+
settings.gradle.kts # Project structure and settings
18+
README.md # Project overview
19+
AGENTS.md # Entry point for LLM agent instructions
20+
version.gradle.kts # Declares the project version.
21+
```

.agents/quick-reference-card.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# 📝 Quick Reference Card
2+
3+
```
4+
🔑 Key Information:
5+
- Kotlin/Java project with CQRS architecture
6+
- Use ChatGPT for documentation, Codex for code generation, GPT-4o for complex analysis
7+
- Follow coding guidelines in Spine Event Engine docs
8+
- Always include tests with code changes
9+
- Version bump required for all PRs
10+
```

0 commit comments

Comments
 (0)