diff --git a/packages/kilo-jetbrains/backend/build.gradle.kts b/packages/kilo-jetbrains/backend/build.gradle.kts index 1ff4b5d30b..b82a96e709 100644 --- a/packages/kilo-jetbrains/backend/build.gradle.kts +++ b/packages/kilo-jetbrains/backend/build.gradle.kts @@ -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) diff --git a/packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/KiloBackendAppService.kt b/packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/KiloBackendAppService.kt index 302584500d..270e02c9e5 100644 --- a/packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/KiloBackendAppService.kt +++ b/packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/KiloBackendAppService.kt @@ -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.Disconnected) val appState: StateFlow = _appState.asStateFlow() - // ── Delegated from connection (internal use) ──────────────────── - val events: SharedFlow 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 = 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 fetchWithRetry( name: String, block: suspend () -> FetchResult, @@ -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() diff --git a/packages/kilo-jetbrains/build-tasks/build.gradle.kts b/packages/kilo-jetbrains/build-tasks/build.gradle.kts index 184ed01dc4..3f8c8caf00 100644 --- a/packages/kilo-jetbrains/build-tasks/build.gradle.kts +++ b/packages/kilo-jetbrains/build-tasks/build.gradle.kts @@ -9,7 +9,7 @@ repositories { gradlePlugin { plugins { create("build-tasks") { - id = "ai.kilocode.jetbrains.build-tasks" + id = "build-tasks" implementationClass = "BuildTasksPlugin" } } diff --git a/packages/kilo-jetbrains/build-tasks/src/main/kotlin/BuildTasksPlugin.kt b/packages/kilo-jetbrains/build-tasks/src/main/kotlin/BuildTasksPlugin.kt index dc7f640c13..cb38c58841 100644 --- a/packages/kilo-jetbrains/build-tasks/src/main/kotlin/BuildTasksPlugin.kt +++ b/packages/kilo-jetbrains/build-tasks/src/main/kotlin/BuildTasksPlugin.kt @@ -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 { - override fun apply(target: Project) { - // Task classes are available on the classpath once this plugin is applied. - } + override fun apply(target: Project) {} } diff --git a/packages/kilo-jetbrains/build-tasks/src/main/kotlin/FixGeneratedApiTask.kt b/packages/kilo-jetbrains/build-tasks/src/main/kotlin/FixGeneratedApiTask.kt index 41d593440c..4e291139a2 100644 --- a/packages/kilo-jetbrains/build-tasks/src/main/kotlin/FixGeneratedApiTask.kt +++ b/packages/kilo-jetbrains/build-tasks/src/main/kotlin/FixGeneratedApiTask.kt @@ -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",