mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-30 17:14:40 +08:00
refactor(jetbrains): clean up section divider comments and simplify build-tasks plugin
Remove box-drawing section comments from build scripts, task classes, and KiloBackendAppService. Simplify build-tasks plugin ID and fix circular property evaluation in CheckCliTask configuration.
This commit is contained in:
@@ -3,7 +3,7 @@ plugins {
|
||||
alias(libs.plugins.kotlin)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
alias(libs.plugins.openapi.generator)
|
||||
id("ai.kilocode.jetbrains.build-tasks")
|
||||
id("build-tasks")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -19,8 +19,6 @@ sourceSets {
|
||||
}
|
||||
}
|
||||
|
||||
// ── OpenAPI client generation ───────────────────────────────────────
|
||||
|
||||
openApiGenerate {
|
||||
generatorName.set("kotlin")
|
||||
library.set("jvm-okhttp4")
|
||||
@@ -65,8 +63,6 @@ tasks.named("compileKotlin") {
|
||||
dependsOn(fixGeneratedApi)
|
||||
}
|
||||
|
||||
// ── CLI binary packaging ────────────────────────────────────────────
|
||||
|
||||
val cliDir = layout.buildDirectory.dir("generated/cli/cli")
|
||||
val production = providers.gradleProperty("production").map { it.toBoolean() }.orElse(false)
|
||||
|
||||
@@ -116,8 +112,6 @@ tasks.processResources {
|
||||
dependsOn(checkCli)
|
||||
}
|
||||
|
||||
// ── Dependencies ────────────────────────────────────────────────────
|
||||
|
||||
dependencies {
|
||||
intellijPlatform {
|
||||
intellijIdea(libs.versions.intellij.platform)
|
||||
|
||||
-18
@@ -58,18 +58,12 @@ class KiloBackendAppService(private val cs: CoroutineScope) : Disposable {
|
||||
private var router: Job? = null
|
||||
private var loader: Job? = null
|
||||
|
||||
// ── App state ───────────────────────────────────────────────────
|
||||
|
||||
private val _appState = MutableStateFlow<KiloAppState>(KiloAppState.Disconnected)
|
||||
val appState: StateFlow<KiloAppState> = _appState.asStateFlow()
|
||||
|
||||
// ── Delegated from connection (internal use) ────────────────────
|
||||
|
||||
val events: SharedFlow<SseEvent> get() = connection.events
|
||||
val api: DefaultApi? get() = connection.api
|
||||
|
||||
// ── Cached data (also held inside KiloAppState.Ready) ───────────
|
||||
|
||||
@Volatile var profile: KiloProfile200Response? = null
|
||||
private set
|
||||
|
||||
@@ -79,8 +73,6 @@ class KiloBackendAppService(private val cs: CoroutineScope) : Disposable {
|
||||
@Volatile var notifications: List<KiloNotifications200ResponseInner> = emptyList()
|
||||
private set
|
||||
|
||||
// ── Lifecycle ────────────────────────────────────────────────────
|
||||
|
||||
suspend fun connect() {
|
||||
mutex.withLock {
|
||||
val current = _appState.value
|
||||
@@ -110,8 +102,6 @@ class KiloBackendAppService(private val cs: CoroutineScope) : Disposable {
|
||||
return HealthDto(healthy = true, version = response.version)
|
||||
}
|
||||
|
||||
// ── Internals ───────────────────────────────────────────────────
|
||||
|
||||
private suspend fun reconnect() {
|
||||
mutex.withLock {
|
||||
val current = _appState.value
|
||||
@@ -210,8 +200,6 @@ class KiloBackendAppService(private val cs: CoroutineScope) : Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Individual fetch functions ──────────────────────────────────
|
||||
|
||||
private suspend fun fetchProfile(): ProfileResult {
|
||||
val client = connection.api ?: return ProfileResult.NOT_LOGGED_IN
|
||||
return try {
|
||||
@@ -266,8 +254,6 @@ class KiloBackendAppService(private val cs: CoroutineScope) : Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Retry helper ────────────────────────────────────────────────
|
||||
|
||||
private suspend fun <T> fetchWithRetry(
|
||||
name: String,
|
||||
block: suspend () -> FetchResult<T>,
|
||||
@@ -285,8 +271,6 @@ class KiloBackendAppService(private val cs: CoroutineScope) : Disposable {
|
||||
return last
|
||||
}
|
||||
|
||||
// ── SSE event routing ───────────────────────────────────────────
|
||||
|
||||
private fun ensureRouter() {
|
||||
if (router?.isActive == true) return
|
||||
router = cs.launch {
|
||||
@@ -309,8 +293,6 @@ class KiloBackendAppService(private val cs: CoroutineScope) : Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Cleanup ─────────────────────────────────────────────────────
|
||||
|
||||
private fun clear() {
|
||||
loader?.cancel()
|
||||
router?.cancel()
|
||||
|
||||
@@ -9,7 +9,7 @@ repositories {
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("build-tasks") {
|
||||
id = "ai.kilocode.jetbrains.build-tasks"
|
||||
id = "build-tasks"
|
||||
implementationClass = "BuildTasksPlugin"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
/**
|
||||
* Empty marker plugin that exposes task classes from this build-logic
|
||||
* module to the main build. Apply it in any subproject that needs
|
||||
* [FixGeneratedApiTask], [PrepareLocalCliTask], or [CheckCliTask].
|
||||
*/
|
||||
class BuildTasksPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) {
|
||||
// Task classes are available on the classpath once this plugin is applied.
|
||||
}
|
||||
override fun apply(target: Project) {}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ abstract class FixGeneratedApiTask : DefaultTask() {
|
||||
root.walkTopDown().filter { it.extension == "kt" }.forEach { fix(it) }
|
||||
}
|
||||
|
||||
// ── Fix 7: empty anyOf wrapper classes → JsonElement ─────────────
|
||||
private fun fixEmptyWrappers(root: File) {
|
||||
val models = File(root, "ai/kilocode/jetbrains/api/model")
|
||||
if (!models.isDirectory) return
|
||||
@@ -63,7 +62,7 @@ abstract class FixGeneratedApiTask : DefaultTask() {
|
||||
var text = file.readText()
|
||||
var changed = false
|
||||
|
||||
// ── Fix 1: boolean const enums ──────────────────────────────
|
||||
// Fix 1: boolean const enums
|
||||
val decl = Regex("""enum class (\w+)\(val value: kotlin\.Boolean\)""")
|
||||
for (name in decl.findAll(text).map { it.groupValues[1] }.toList()) {
|
||||
text = text.replace(Regex("""(val \w+:\s*)\w+\.$name""")) { m ->
|
||||
@@ -78,13 +77,13 @@ abstract class FixGeneratedApiTask : DefaultTask() {
|
||||
changed = true
|
||||
}
|
||||
|
||||
// ── Fix 2: double parentheses `HashMap<…>()()` ─────────────
|
||||
// Fix 2: double parentheses `HashMap<…>()()`
|
||||
if (text.contains("()()")) {
|
||||
text = text.replace("()()", "()")
|
||||
changed = true
|
||||
}
|
||||
|
||||
// ── Fix 3: `kotlin.Double("…")` → double literal ───────────
|
||||
// Fix 3: `kotlin.Double("…")` → double literal
|
||||
val ctor = Regex("""kotlin\.Double\("(\d+(?:\.\d+)?)"\)""")
|
||||
if (ctor.containsMatchIn(text)) {
|
||||
text = ctor.replace(text) { m ->
|
||||
@@ -94,7 +93,7 @@ abstract class FixGeneratedApiTask : DefaultTask() {
|
||||
changed = true
|
||||
}
|
||||
|
||||
// ── Fix 4: @Contextual on bare kotlin.Any ───────────────────
|
||||
// Fix 4: @Contextual on bare kotlin.Any
|
||||
if (text.contains("kotlin.Any") &&
|
||||
text.contains("import kotlinx.serialization.Contextual") &&
|
||||
text.contains("@Serializable") &&
|
||||
@@ -107,7 +106,7 @@ abstract class FixGeneratedApiTask : DefaultTask() {
|
||||
changed = true
|
||||
}
|
||||
|
||||
// ── Fix 5: nullable body in ApiClient ───────────────────────
|
||||
// Fix 5: nullable body in ApiClient
|
||||
if (file.name == "ApiClient.kt") {
|
||||
val guard = "val body = response.body"
|
||||
if (text.contains(guard) && !text.contains("if (body == null) return null")) {
|
||||
@@ -121,7 +120,7 @@ abstract class FixGeneratedApiTask : DefaultTask() {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Fix 6: AnySerializer in Serializer.kt ───────────────────
|
||||
// Fix 6: AnySerializer in Serializer.kt
|
||||
if (file.name == "Serializer.kt" && !text.contains("AnySerializer")) {
|
||||
text = text.replace(
|
||||
"import kotlinx.serialization.modules.SerializersModuleBuilder",
|
||||
|
||||
Reference in New Issue
Block a user