Write your tests, and let AI generate the code.
If changes are needed, simply update the tests, and AI will regenerate the code to meet the new requirements.
- Create a
local.properties
file and add the following:
API_KEY="sk-proj-mSwcp..."
- Kotlin (KTS)
plugins {
id("com.google.devtools.ksp") version "1.9.24-1.0.20"
}
- Add dependencies
dependencies {
ksp("io.github.antonbutov:code-factory-processor:$last_version")
}
- Create an interface without an implementation
interface ForGenerate {
fun plus(first: Int, second: Int): Int
}
- Write a test with not implemented implementation
class GeneratedTest {
@Test
fun generatedFileGets() {
val forGenerate: ForGenerate = GeneratedCode()
val expected = forGenerate.plus(2, 2)
assertEquals(4, expected)
}
}
- Build the module 🚀. The plugin has to generate
class GeneratedCode(): ForGenerate {
override fun plus(first: Int, second: Int): Int {
return first + second
}
}
w: [ksp] Request: ---->
You had to implement interface: ForGenerate Return only code implementation please.
interface ForGenerate {
fun plus(
first: Int,
second: Int,
): Int
}
import kotlin.test.Test
import kotlin.test.assertEquals
class GeneratedTest {
@Test
fun generatedFileGets() {
val forGenerate: ForGenerate = GeneratedCode()
val expected = forGenerate.plus(2, 2)
assertEquals(4, expected)
}
}
Response: <----
Sure, the implementation of the interface `ForGenerate` can be done as follows:
```kotlin
class GeneratedCode(): ForGenerate {
override fun plus(first: Int, second: Int): Int {
return first + second
}
}
Code Factory is built with the following technologies:
- Test-Driven Development (TDD) using Kotest –
io.kotest:kotest
- AI Integration with OpenAI API –
com.aallam.openai:openai
- Code Quality enforced with ktlint
- Code Generation using KSP (Kotlin Symbol Processing)
We follow best practices to ensure a robust and maintainable codebase. Contributions are welcome! 🚀 We're looking for skilled contributors, especially those with expertise in AI and Kotlin. Join us in enhancing Code Factory's capabilities!
If you need OpenAI API key, write to me at [email protected]. I can give it to you within 24 hours.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.