SuperAPI AI 工具集

diagnosing-compose-stability

通用与其它

查看项目

更新于 10-16 01:24

技能介绍

用途:该技能指导 Claude 通过 Compose Compiler Reports 定位哪些参数不稳定、为什么不稳定,并输出按优先级排列的不稳定类型与不可跳过的可组合函数清单;具体修复由 ../stabilizing-compose-types/SKILL.md 负责。

适用场景:开发者问“为什么会重组”、报告卡顿/掉帧/滚动抖动;@TraceRecomposition 日志显示重组次数超过有意义的状态变更次数;提到 Compose Compiler Reports、classes.txt、composables.txt、composables.csv、module.json 或 non-skippable;询问 List<Foo>、LocalDateTime 或某领域类型是否稳定;评审者需要可组合函数可跳过的证据。不适用场景:不稳定类型已知(直接跳到修复技能);症状是错误阶段状态读取(Modifier.alpha(state.value))或 derivedStateOf 误用;需要 CI 门禁而非一次性诊断。

前置条件:Kotlin 2.0.0+ 并应用 Compose Compiler Gradle 插件 id("org.jetbrains.kotlin.plugin.compose");需要可构建的 release 变体,报告必须在 release 下生成,debug 会引入 Live Literals 使常量显示为动态并扭曲所有报告。

用法:在模块 build.gradle.kts 的 composeCompiler { } 中设置 reportsDestination 与 metricsDestination 指向 build/compose_compiler,可仅 release 启用或始终启用,也可通过 stabilityConfigurationFiles 加入 stability_config.conf;然后运行 release 构建,例如 ./gradlew :app:assembleRelease -PcomposeCompilerReports=true,库模块为 ./gradlew :feature-feed:assembleRelease;产物含 <module>_release-classes.txt、composables.txt、composables.csv、module.json。优先读 composables.txt:查找 restartable 但未标 skippable 的行,并读取每个参数前缀 stable/unstable/@static/@dynamic,unstable 会阻断跳过;再到 classes.txt 查根因(var 字段、泛型参数或不稳定的嵌套类型);module.json 用于分诊与前后对比,但不应把计数当目标。最后按热路径优先级排序,并用 @TraceRecomposition 或 Macrobenchmark FrameTimingMetric 交叉验证,再交给修复技能。

限制:不要追求 100% 可跳过(可跳过性是诊断而非 KPI);不要仅依据报告将类标注 @Stable;不要只数 composables.csv 行数就结束;runtime stable class 属编译器正确的惰性稳定发射,应说明其不是问题。