feat(usage): plan:kimi_coding 兼容 kimi-code 0.43.1 quota 用量模型

服务端 api.kimi.com/coding/v1/usages 已由绝对 used/limit 行切换为
quota 模型(usages.limit_5h/limit_7d/limit_month_total/limit_month_code,
条目为 used_ratio 0-1 比率 + reset_time),见上游 #3787。

- parse_kimi_coding 优先解析新结构,旧 limits/usage 结构保留为回退
- used_ratio >1 时按已是百分数处理(防御)
- 新 tier id month_code + 前端 planLabel/i18n 中英文案
- 新增 3 个测试:四窗口解析 / 比率防御 / 空窗口回退旧结构
This commit is contained in:
KimiSwitch Dev committed 2026-09-16 14:14:29 +08:00
1 parent 1b80d66239
commit 35581103ed
6 files changed
+428 -185

No files matched your search

+6 -3
View File
@@ -11,9 +11,10 @@ type TranslateFn = (
*
* Coverage note: ALL plan-type (套餐) queries flow through
* src-tauri/src/services/coding_plan.rs::percent_tier, whose names come only
* from TIER_FIVE_HOUR / TIER_WEEKLY_LIMIT / TIER_MONTHLY_LIMIT — so this
* mapping covers every current and future plan provider automatically. If a
* new tier id is ever added there, add a case here too.
* from TIER_FIVE_HOUR / TIER_WEEKLY_LIMIT / TIER_MONTHLY_LIMIT /
* TIER_MONTH_CODE — so this mapping covers every current and future plan
* provider automatically. If a new tier id is ever added there, add a case
* here too.
*/
export function planLabel(name: string, t: TranslateFn): string {
switch (name) {
@@ -25,6 +26,8 @@ export function planLabel(name: string, t: TranslateFn): string {
return t("usageTierWeekly");
case "monthly_limit":
return t("usageTierMonthly");
case "month_code":
return t("usageTierMonthCode");
default:
return name;
}