.kilo/plans/1779987162764-misty-rocket.md
The JetBrains plugin currently imports com.intellij.util.SVGLoader in packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/SvgIconColorizer.kt and calls SVGLoader.load(ByteArrayInputStream(patch()), scale.toFloat()) from SvgIcon.image(Graphics).
Inspection reports this as an internal API usage because SVGLoader and its load(InputStream, float) method are marked @ApiStatus.Internal.
I checked the local IntelliJ source reference via $INTELLIJ_REPO=/Users/kirillk/products/intellij-community:
platform/util/ui/src/com/intellij/util/SVGLoader.ktplatform/util/ui/src/com/intellij/ui/svg/svg.ktplatform/util/ui/src/com/intellij/ui/svg/jsvg.ktlibraries/jsvg/intellij.libraries.jsvg.imlImportant findings:
SVGLoader.load(stream, scale) delegates to internal loadSvg(...) in com.intellij.ui.svg.com.github.weisj:jsvg:2.1.0 and renders into a BufferedImage with antialiasing, bicubic interpolation, and pure stroke control.SVGLoader.kt directly would keep references to other internal IntelliJ APIs (IconLoader, ScaleContext, ImageUtil, SvgAttributePatcher, createJSvgDocument, renderSvgWithSize, cache classes, etc.) and would be broader than needed.Add Kilo-owned SVG rendering code under the frontend UI package, for example:
packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/SvgLoader.ktai.kilocode.client.uiSvgLoaderKeep the copied implementation minimal and purpose-specific:
InputStream and scale: Float.com.github.weisj.jsvg.parser.SVGLoader().load(stream) or the equivalent public jsvg API available in version 2.1.0.width and height already parsed by existing SvgIconColorizer.size(...), or by passing dimensions into the loader if the public jsvg API does not expose reliable intrinsic size.BufferedImage(width * scale, height * scale, BufferedImage.TYPE_INT_ARGB) using Graphics2D rendering hints matching IntelliJ’s jsvg.kt:
KEY_ANTIALIASING = VALUE_ANTIALIAS_ONKEY_INTERPOLATION = VALUE_INTERPOLATION_BICUBICKEY_STROKE_CONTROL = VALUE_STROKE_PUREImage/BufferedImage.If jsvg does not expose intrinsic size cleanly from public API, adjust the API to avoid duplicating SVG parsing:
width and height parameters to the Kilo loader.SvgIcon.image(Graphics), call the loader with the already-computed size.first and size.second.width and height for SvgIconColorizer.size(...).Add the jsvg dependency explicitly to the plugin frontend module instead of relying on the IntelliJ-bundled library:
packages/kilo-jetbrains/gradle/libs.versions.toml, add jsvg = "2.1.0" and jsvg = { module = "com.github.weisj:jsvg", version.ref = "jsvg" }.packages/kilo-jetbrains/frontend/build.gradle.kts, add implementation(libs.jsvg).Update SvgIconColorizer.kt:
import com.intellij.util.SVGLoader.SVGLoader.load(ByteArrayInputStream(patch()), scale.toFloat()) with the Kilo-owned loader call.Add a focused frontend unit test:
frontend/src/test/kotlin/ai/kilocode/client/ui/SvgIconColorizerTest.kt or SvgLoaderTest.kt.1f and 2f, and that scaled dimensions are correct.BufferedImage and verify at least one expected patched pixel color appears.Run verification from packages/kilo-jetbrains/:
./gradlew typecheck./gradlew test.com.intellij.util.SVGLoader, and typecheck/tests were run.SVGLoader”. The implementation should copy the relevant rendering behavior, not IntelliJ’s full internal SVGLoader object, because the full source depends on multiple other internal APIs and cache infrastructure.packages/kilo-jetbrains/, a Kilo-owned package, so kilocode_change markers are not needed.