desktop/src-tauri/crates/core/src/copilot_quota.rs
第 1 条注释,第 1 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:1
//! GitHub Copilot 本机额度记录提取(`copilot-user-cache.json`)。第 2 条注释,第 2 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:2
//!(空行)第 3 条注释,第 3 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:3
//! 文件识别依据:2026-10-01 本机核验与官方 cli-config-dir-reference 的 cache 目录说明。第 4 条注释,第 4 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:4
//! VS Code Copilot Chat 与 Copilot CLI 共享的账户额度缓存文件第 5 条注释,第 5 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:5
//! `copilot-user-cache.json`,Windows 位于 `%LOCALAPPDATA%/copilot/`,第 6 条注释,第 6 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:6
//! macOS `~/Library/Caches/copilot/`,Linux `$XDG_CACHE_HOME/copilot` 或第 7 条注释,第 7 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:7
//! `~/.cache/copilot/`。文件以 `//` 注释行开头,随后为 JSON:第 8 条注释,第 8 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:8
//! 额度字段位于 copilotUserCache.<hash>.response.quota_snapshots.<quota_id>。第 9 条注释,第 9 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:9
//!(空行)第 10 条注释,第 10 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:10
//! 账号 premium 请求额度跨设备和入口共享;已观察样本的配额为第 11 条注释,第 11 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:11
//! 1500,并非所有账号统一上限。原生请求额度独立展示,不折算为 token。第 12 条注释,第 12 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:12
//! timestamp_utc 是服务端快照时间;2026-10-01 的逐次 token 缺失结论第 13 条注释,第 13 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:13
//! 仅适用于当时检查的 chronicle session-store.db。VS Code 原生第 14 条注释,第 14 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:14
//! chatSessions/*.jsonl 用量和轮次记录由 copilot_chat 读取,额度继续独立保留。第 15 条注释,第 19 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:19
/// 单条额度快照(账户级;请求计数,非 token)。第 16 条注释,第 22 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:22
/// 额度标识:premium_interactions / chat / completions。第 17 条注释,第 24 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:24
/// 本计费周期配额上限(0 表示无上限占位)。第 18 条注释,第 26 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:26
/// 剩余额度,千分之一请求;缺失/不可精确映射为未知。第 19 条注释,第 28 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:28
/// 已用额度 = entitlement − remaining(有上限且非 unlimited 时才有意义)。第 20 条注释,第 30 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:30
/// 剩余百分比(服务端原值)。第 21 条注释,第 32 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:32
/// 是否无上限(chat/completions 通常 true:不计入已用)。第 22 条注释,第 34 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:34
/// 快照观测时刻(来自 timestamp_utc,毫秒)。第 23 条注释,第 38 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:38
/// 解析结果:账户计划标识 + 各额度快照。第 24 条注释,第 45 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:45
/// 解析 `copilot-user-cache.json` 文本(先剥离 `//` 注释行再按 JSON 解析)。第 25 条注释,第 47 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:47
// 删除去除前导空白后以 // 开头的注释行,保留 JSON 正文。第 26 条注释,第 56 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:56
// 选择 retrievedAt 最大的条目;缺失时间戳排在已知时间戳之前。第 27 条注释,第 75 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:75
// 按 quota_id 字典序稳定输出。第 28 条注释,第 81 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:81
// has_quota=false 表示该额度对本账户不适用:跳过。第 29 条注释,第 89 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:89
// premium 额度可为小数;用千分之一请求的整数存储,禁止取整。第 30 条注释,第 110 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:110
// 已用仅在有正上限且非 unlimited 时可派生(配额语义);否则未知不补零。第 31 条注释,第 146 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:146
/// 解析缓存文件默认路径(平台 cache 目录;COPILOT_CACHE_HOME 覆盖)。第 32 条注释,第 147 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:147
/// 传入显式 env map 便于测试,不直接读进程环境。第 33 条注释,第 174 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:174
// Linux / 其他:XDG_CACHE_HOME 优先,否则 ~/.cache。第 34 条注释,第 184 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:184
/// 读取并解析本机 Copilot 额度缓存(文件缺失/不可解析返回 None)。第 35 条注释,第 204 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:204
// ---- 归一到通用额度时序(agent 无关 quota_history)----第 36 条注释,第 210 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:210
/// 统计 Agent 名。第 37 条注释,第 213 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:213
/// 把解析出的额度快照映射为通用 [`QuotaObservation`]。第 38 条注释,第 214 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:214
/// 仅纳入有真实上限且非 unlimited 的额度(premium_interactions):第 39 条注释,第 215 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:215
/// 账户级请求配额(所有设备共享 ⇒ locality_verified=false),按请求计数、非 token。第 40 条注释,第 238 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:238
// 账户级配额跨设备共享,不可证明属于本机:locality_verified=false。第 41 条注释,第 248 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:248
/// 便捷:从本机缓存读取并记录到通用 quota_history;返回记录的额度条数。第 42 条注释,第 301 行
desktop/src-tauri/crates/core/src/copilot_quota.rs:301
// timestamp_utc -07:00 → UTC 毫秒。