@aiusage/cli 1.7.2 → 1.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,12 +3,19 @@
3
3
  `@aiusage/cli` is the AIUsage command-line tool for:
4
4
 
5
5
  - discovering and managing projects across AI tools
6
- - scanning local Claude Code, Codex, Cursor, Copilot CLI, Copilot for VS Code, Gemini CLI, and Antigravity usage
6
+ - scanning local Claude Code, Codex, Cursor, Copilot CLI, Copilot for VS Code, Gemini CLI, Antigravity, Amp, Kimi Code, Qwen Code, Droid, OpenCode, and Pi usage
7
7
  - importing historical usage from Anthropic Admin API
8
8
  - printing local usage summaries for the last 7 days, 30 days, 90 days, or all history
9
9
  - scheduling automatic sync to an AIUsage Worker
10
10
  - diagnosing configuration and connectivity issues
11
11
 
12
+ Kimi scanning supports both legacy Kimi CLI data in `~/.kimi/sessions/` and
13
+ new Kimi Code data in `$KIMI_CODE_HOME/sessions/` (default:
14
+ `~/.kimi-code/sessions/`). It reads only token counters and session metadata
15
+ from `wire.jsonl`; conversation content is not uploaded. The new wire-format
16
+ parser references the MIT-licensed [tokscale](https://github.com/junhoyeo/tokscale)
17
+ implementation.
18
+
12
19
  ## Install
13
20
 
14
21
  ```bash
@@ -41,7 +48,7 @@ aiusage project alias # list all configured aliases
41
48
  aiusage project alias --remove myapp # remove alias
42
49
  ```
43
50
 
44
- Scans data directories for Claude Code, Codex, Cursor, Copilot CLI, Copilot for VS Code, Gemini CLI, and Antigravity, listing discovered projects with their aliases and sources.
51
+ Scans data directories for all supported tools, including Kimi Code session metadata, listing discovered projects with their aliases and sources.
45
52
 
46
53
  Project aliases are applied locally before upload. If two devices set the same alias for their respective project directories, the server merges them into one project.
47
54
 
package/README.zh-CN.md CHANGED
@@ -9,6 +9,11 @@
9
9
  - 定时自动同步数据到 AIUsage Worker
10
10
  - 诊断配置与连接问题
11
11
 
12
+ Kimi 同时支持旧版 Kimi CLI 的 `~/.kimi/sessions/` 与新版 Kimi Code 的
13
+ `$KIMI_CODE_HOME/sessions/`(默认 `~/.kimi-code/sessions/`)。扫描器仅读取
14
+ `wire.jsonl` 中的 Token 计数与会话元数据,不上传对话正文;新版格式参考了
15
+ [tokscale](https://github.com/junhoyeo/tokscale) 的 MIT 开源实现。
16
+
12
17
  ## 安装
13
18
 
14
19
  ```bash
package/dist/cli.js CHANGED
@@ -964,16 +964,40 @@ var google = {
964
964
  var moonshot = {
965
965
  "kimi-code": {
966
966
  models: {
967
+ "kimi-k3": {
968
+ currency: "CNY",
969
+ effective_from: "2026-07-17",
970
+ input_per_million: 20,
971
+ cached_input_per_million: 2,
972
+ cache_write_per_million: 20,
973
+ output_per_million: 100
974
+ },
975
+ "kimi-k2.7-code": {
976
+ currency: "CNY",
977
+ input_per_million: 6.5,
978
+ cached_input_per_million: 1.3,
979
+ cache_write_per_million: 6.5,
980
+ output_per_million: 27
981
+ },
982
+ "kimi-k2.7-code-highspeed": {
983
+ currency: "CNY",
984
+ input_per_million: 13,
985
+ cached_input_per_million: 2.6,
986
+ cache_write_per_million: 13,
987
+ output_per_million: 54
988
+ },
967
989
  "kimi-k2.6": {
968
990
  currency: "CNY",
969
991
  input_per_million: 6.5,
970
992
  cached_input_per_million: 1.1,
993
+ cache_write_per_million: 6.5,
971
994
  output_per_million: 27
972
995
  },
973
996
  "kimi-k2.5": {
974
997
  currency: "CNY",
975
998
  input_per_million: 4,
976
999
  cached_input_per_million: 0.7,
1000
+ cache_write_per_million: 4,
977
1001
  output_per_million: 21
978
1002
  },
979
1003
  "kimi-k2-0905-preview": {
@@ -981,6 +1005,7 @@ var moonshot = {
981
1005
  notes: "will be retired 2026-05-25",
982
1006
  input_per_million: 4,
983
1007
  cached_input_per_million: 1,
1008
+ cache_write_per_million: 4,
984
1009
  output_per_million: 16
985
1010
  },
986
1011
  "kimi-k2-0711-preview": {
@@ -988,6 +1013,7 @@ var moonshot = {
988
1013
  notes: "will be retired 2026-05-25",
989
1014
  input_per_million: 4,
990
1015
  cached_input_per_million: 1,
1016
+ cache_write_per_million: 4,
991
1017
  output_per_million: 16
992
1018
  },
993
1019
  "kimi-k2-turbo-preview": {
@@ -995,48 +1021,57 @@ var moonshot = {
995
1021
  notes: "will be retired 2026-05-25",
996
1022
  input_per_million: 8,
997
1023
  cached_input_per_million: 1,
1024
+ cache_write_per_million: 8,
998
1025
  output_per_million: 58
999
1026
  },
1000
1027
  "kimi-k2-thinking": {
1001
1028
  currency: "CNY",
1002
1029
  input_per_million: 4,
1003
1030
  cached_input_per_million: 1,
1031
+ cache_write_per_million: 4,
1004
1032
  output_per_million: 16
1005
1033
  },
1006
1034
  "kimi-k2-thinking-turbo": {
1007
1035
  currency: "CNY",
1008
1036
  input_per_million: 8,
1009
1037
  cached_input_per_million: 1,
1038
+ cache_write_per_million: 8,
1010
1039
  output_per_million: 58
1011
1040
  },
1012
1041
  "moonshot-v1-8k": {
1013
1042
  currency: "CNY",
1014
1043
  input_per_million: 2,
1044
+ cache_write_per_million: 2,
1015
1045
  output_per_million: 10
1016
1046
  },
1017
1047
  "moonshot-v1-32k": {
1018
1048
  currency: "CNY",
1019
1049
  input_per_million: 5,
1050
+ cache_write_per_million: 5,
1020
1051
  output_per_million: 20
1021
1052
  },
1022
1053
  "moonshot-v1-128k": {
1023
1054
  currency: "CNY",
1024
1055
  input_per_million: 10,
1056
+ cache_write_per_million: 10,
1025
1057
  output_per_million: 30
1026
1058
  },
1027
1059
  "moonshot-v1-8k-vision-preview": {
1028
1060
  currency: "CNY",
1029
1061
  input_per_million: 2,
1062
+ cache_write_per_million: 2,
1030
1063
  output_per_million: 10
1031
1064
  },
1032
1065
  "moonshot-v1-32k-vision-preview": {
1033
1066
  currency: "CNY",
1034
1067
  input_per_million: 5,
1068
+ cache_write_per_million: 5,
1035
1069
  output_per_million: 20
1036
1070
  },
1037
1071
  "moonshot-v1-128k-vision-preview": {
1038
1072
  currency: "CNY",
1039
1073
  input_per_million: 10,
1074
+ cache_write_per_million: 10,
1040
1075
  output_per_million: 30
1041
1076
  }
1042
1077
  }
@@ -1287,14 +1322,16 @@ var inflection = {
1287
1322
  };
1288
1323
 
1289
1324
  // ../shared/src/pricing/catalog.ts
1290
- var PRICING_VERSION = "2026-07-10-gpt-5.6-v1", aliases = {
1325
+ var PRICING_VERSION = "2026-07-18-kimi-k3-v1", aliases = {
1291
1326
  "claude-opus-4-7-20260201": "claude-opus-4-7",
1292
1327
  "claude-sonnet-4-6-20250301": "claude-sonnet-4-6",
1293
1328
  "claude-opus-4-6-20250301": "claude-opus-4-6",
1294
1329
  "claude-haiku-4-5-20251001": "claude-haiku-4-5",
1295
1330
  "claude-sonnet-4.6": "claude-sonnet-4-6",
1296
1331
  "gpt-5.6": "gpt-5.6-sol",
1297
- "codex-auto-review": "gpt-5.4"
1332
+ "codex-auto-review": "gpt-5.4",
1333
+ k3: "kimi-k3",
1334
+ "kimi-code/k3": "kimi-k3"
1298
1335
  }, catalog = {
1299
1336
  version: PRICING_VERSION,
1300
1337
  // 汇率(1 USD ≈ N CNY)。Worker 启动时可被 env 覆盖。
@@ -2067,81 +2104,242 @@ async function scanQwenDates(targetDates, baseDir, projectAliases) {
2067
2104
  }
2068
2105
 
2069
2106
  // src/scanners/kimi.ts
2070
- import { readFile as readFile8 } from "node:fs/promises";
2107
+ import { readFile as readFile8, stat } from "node:fs/promises";
2071
2108
  import { join as join10, basename as basename5, dirname as dirname3 } from "node:path";
2072
2109
  import { homedir as homedir9 } from "node:os";
2073
- async function scanKimiDates(targetDates, baseDir, projectAliases) {
2074
- let dates = new Set(targetDates), kimiHome = baseDir ?? join10(homedir9(), ".kimi"), sessionsDir = join10(kimiHome, "sessions"), files = await walkFiles(sessionsDir, ".jsonl");
2075
- if (files.length === 0) return emptyResult(dates);
2076
- let workspaceMap = await loadWorkspaceMap(kimiHome), grouped = initDateMap(dates), seen = /* @__PURE__ */ new Set();
2077
- for (let filePath of files) {
2078
- let sessionDir = dirname3(filePath), hashDir = dirname3(sessionDir), workDirHash = basename5(hashDir), projectFields = resolveKimiProject(workDirHash, workspaceMap, projectAliases), content;
2110
+ var DEFAULT_MODEL = "kimi-for-coding";
2111
+ function resolveKimiCodeHome(home = homedir9()) {
2112
+ return process.env.KIMI_CODE_HOME?.trim() || join10(home, ".kimi-code");
2113
+ }
2114
+ async function scanKimiDates(targetDates, legacyBaseDir, projectAliases, kimiCodeBaseDir) {
2115
+ let dates = new Set(targetDates), legacyHome = legacyBaseDir ?? join10(homedir9(), ".kimi"), codeHome = kimiCodeBaseDir ?? (legacyBaseDir ? void 0 : resolveKimiCodeHome()), [legacyFiles, codeFiles] = await Promise.all([
2116
+ findWireFiles(join10(legacyHome, "sessions")),
2117
+ codeHome ? findWireFiles(join10(codeHome, "sessions")) : Promise.resolve([])
2118
+ ]);
2119
+ if (legacyFiles.length === 0 && codeFiles.length === 0) return emptyResult(dates);
2120
+ let [legacyWorkspaceMap, legacyModel, codeSessionIndex] = await Promise.all([
2121
+ loadLegacyWorkspaceMap(legacyHome),
2122
+ loadLegacyModel(legacyHome),
2123
+ codeHome ? loadKimiCodeSessionIndex(codeHome) : Promise.resolve(/* @__PURE__ */ new Map())
2124
+ ]), grouped = initDateMap(dates), sessionSets = /* @__PURE__ */ new Map(), codeProjectCache = /* @__PURE__ */ new Map();
2125
+ for (let filePath of legacyFiles) {
2126
+ let sessionDir = dirname3(filePath), workspaceHash = basename5(dirname3(sessionDir)), sessionId = basename5(sessionDir), rawProject = legacyWorkspaceMap.get(workspaceHash) ?? workspaceHash, projectFields = resolveProjectFields(rawProject, projectAliases), usages = await parseLegacyFile(filePath, legacyModel);
2127
+ for (let usage of usages)
2128
+ addUsage(grouped, sessionSets, dates, usage, projectFields, sessionId);
2129
+ }
2130
+ for (let filePath of codeFiles) {
2131
+ let pathInfo = getKimiCodePathInfo(filePath);
2132
+ if (!pathInfo) continue;
2133
+ let projectFields = codeProjectCache.get(pathInfo.sessionDir);
2134
+ if (!projectFields) {
2135
+ let rawProject = await resolveKimiCodeProjectPath(pathInfo, codeSessionIndex);
2136
+ projectFields = resolveProjectFields(rawProject, projectAliases), codeProjectCache.set(pathInfo.sessionDir, projectFields);
2137
+ }
2138
+ let usages = await parseKimiCodeFile(filePath);
2139
+ for (let usage of usages)
2140
+ addUsage(grouped, sessionSets, dates, usage, projectFields, pathInfo.sessionId);
2141
+ }
2142
+ let result = finalize(grouped);
2143
+ for (let [usageDate, breakdowns] of result)
2144
+ for (let breakdown of breakdowns) {
2145
+ let key = `${usageDate}|${breakdown.model}|${breakdown.project}`;
2146
+ breakdown.sessionCount = sessionSets.get(key)?.size ?? 0;
2147
+ }
2148
+ return result;
2149
+ }
2150
+ async function findWireFiles(sessionsDir) {
2151
+ return (await walkFiles(sessionsDir, ".jsonl")).filter((filePath) => basename5(filePath) === "wire.jsonl");
2152
+ }
2153
+ async function parseLegacyFile(filePath, fallbackModel) {
2154
+ let content = await safeRead(filePath);
2155
+ if (content == null) return [];
2156
+ let fallbackTimestamp = await fileModifiedDate(filePath), usages = [], keyedIndices = /* @__PURE__ */ new Map(), currentModel = fallbackModel;
2157
+ for (let line of content.split(`
2158
+ `)) {
2159
+ if (!line.trim()) continue;
2160
+ let record;
2079
2161
  try {
2080
- content = await readFile8(filePath, "utf-8");
2162
+ record = JSON.parse(line);
2081
2163
  } catch {
2082
2164
  continue;
2083
2165
  }
2084
- let currentModel = "unknown";
2085
- for (let line of content.split(`
2166
+ let payload = record.message?.payload ?? record.payload;
2167
+ if (payload?.model && (currentModel = normalizeModel2(payload.model)), (record.message?.type ?? record.type) !== "StatusUpdate" || !payload?.token_usage) continue;
2168
+ let tokens = normalizeUsage(payload.token_usage);
2169
+ if (tokens.input + tokens.cached + tokens.cacheWrite + tokens.output === 0) continue;
2170
+ let timestamp = parseTs(record.timestamp) ?? fallbackTimestamp;
2171
+ if (!timestamp) continue;
2172
+ let usage = {
2173
+ timestamp,
2174
+ model: currentModel,
2175
+ ...tokens,
2176
+ messageId: payload.message_id
2177
+ };
2178
+ pushOrReplaceProgressiveUsage(usages, keyedIndices, usage);
2179
+ }
2180
+ return usages;
2181
+ }
2182
+ async function parseKimiCodeFile(filePath) {
2183
+ let content = await safeRead(filePath);
2184
+ if (content == null) return [];
2185
+ let fallbackTimestamp = await fileModifiedDate(filePath), usages = [];
2186
+ for (let line of content.split(`
2086
2187
  `)) {
2087
- if (!line.trim()) continue;
2088
- let obj;
2188
+ if (!line.trim()) continue;
2189
+ let record;
2190
+ try {
2191
+ record = JSON.parse(line);
2192
+ } catch {
2193
+ continue;
2194
+ }
2195
+ if (record.type !== "usage.record" || record.usageScope !== "turn" || !record.usage) continue;
2196
+ let tokens = normalizeUsage(record.usage);
2197
+ if (tokens.input + tokens.cached + tokens.cacheWrite + tokens.output === 0) continue;
2198
+ let timestamp = parseTs(record.time ?? record.created_at) ?? fallbackTimestamp;
2199
+ timestamp && usages.push({
2200
+ timestamp,
2201
+ model: normalizeModel2(record.model ?? DEFAULT_MODEL),
2202
+ ...tokens
2203
+ });
2204
+ }
2205
+ return usages;
2206
+ }
2207
+ function addUsage(grouped, sessionSets, dates, usage, projectFields, sessionId) {
2208
+ let usageDate = dateKey(usage.timestamp);
2209
+ if (!dates.has(usageDate)) return;
2210
+ let dayMap = grouped.get(usageDate);
2211
+ if (!dayMap) return;
2212
+ let breakdownKey = `${usage.model}|${projectFields.project}`;
2213
+ accumulate(
2214
+ dayMap,
2215
+ breakdownKey,
2216
+ {
2217
+ provider: "moonshot",
2218
+ product: "kimi-code",
2219
+ channel: "cli",
2220
+ model: usage.model,
2221
+ project: projectFields.project,
2222
+ projectDisplay: projectFields.projectDisplay,
2223
+ projectAlias: projectFields.projectAlias,
2224
+ sessionCount: 0,
2225
+ inputTokens: 0,
2226
+ cachedInputTokens: 0,
2227
+ cacheWriteTokens: 0,
2228
+ outputTokens: 0,
2229
+ reasoningOutputTokens: 0
2230
+ },
2231
+ {
2232
+ input: usage.input,
2233
+ cached: usage.cached,
2234
+ cacheWrite: usage.cacheWrite,
2235
+ output: usage.output,
2236
+ reasoning: 0
2237
+ }
2238
+ );
2239
+ let sessionKey = `${usageDate}|${breakdownKey}`, sessions = sessionSets.get(sessionKey);
2240
+ sessions || (sessions = /* @__PURE__ */ new Set(), sessionSets.set(sessionKey, sessions)), sessions.add(sessionId);
2241
+ }
2242
+ function normalizeUsage(usage) {
2243
+ return {
2244
+ input: normalizeTokenCount(usage.inputOther ?? usage.input_other),
2245
+ cached: normalizeTokenCount(usage.inputCacheRead ?? usage.input_cache_read),
2246
+ cacheWrite: normalizeTokenCount(usage.inputCacheCreation ?? usage.input_cache_creation),
2247
+ output: normalizeTokenCount(usage.output)
2248
+ };
2249
+ }
2250
+ function normalizeTokenCount(value) {
2251
+ return typeof value == "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : 0;
2252
+ }
2253
+ function normalizeModel2(model) {
2254
+ return model.trim().replace(/^kimi-code\//, "") || DEFAULT_MODEL;
2255
+ }
2256
+ function pushOrReplaceProgressiveUsage(usages, keyedIndices, candidate) {
2257
+ let messageId = candidate.messageId?.trim();
2258
+ if (!messageId) {
2259
+ usages.push(candidate);
2260
+ return;
2261
+ }
2262
+ let existingIndex = keyedIndices.get(messageId);
2263
+ if (existingIndex == null) {
2264
+ keyedIndices.set(messageId, usages.length), usages.push(candidate);
2265
+ return;
2266
+ }
2267
+ let existing = usages[existingIndex], existingTotal = totalUsage(existing), candidateTotal = totalUsage(candidate);
2268
+ (candidateTotal > existingTotal || candidateTotal === existingTotal && candidate.timestamp >= existing.timestamp) && (usages[existingIndex] = candidate);
2269
+ }
2270
+ function totalUsage(usage) {
2271
+ return usage.input + usage.cached + usage.cacheWrite + usage.output;
2272
+ }
2273
+ function getKimiCodePathInfo(filePath) {
2274
+ let agentDir = dirname3(filePath), agentsDir = dirname3(agentDir);
2275
+ if (basename5(agentsDir) !== "agents") return null;
2276
+ let sessionDir = dirname3(agentsDir);
2277
+ return {
2278
+ sessionDir,
2279
+ sessionId: basename5(sessionDir),
2280
+ workspaceKey: basename5(dirname3(sessionDir))
2281
+ };
2282
+ }
2283
+ async function resolveKimiCodeProjectPath(pathInfo, sessionIndex) {
2284
+ try {
2285
+ let raw = await readFile8(join10(pathInfo.sessionDir, "state.json"), "utf-8"), state = JSON.parse(raw);
2286
+ if (state.workDir?.trim()) return state.workDir;
2287
+ } catch {
2288
+ }
2289
+ let indexed = sessionIndex.get(pathInfo.sessionId);
2290
+ return indexed || workspaceLabel(pathInfo.workspaceKey);
2291
+ }
2292
+ function workspaceLabel(workspaceKey) {
2293
+ return workspaceKey.match(/^wd_(.+)_[0-9a-f]{12}$/i)?.[1] || workspaceKey;
2294
+ }
2295
+ async function loadKimiCodeSessionIndex(kimiCodeHome) {
2296
+ let map = /* @__PURE__ */ new Map(), content = await safeRead(join10(kimiCodeHome, "session_index.jsonl"));
2297
+ if (content == null) return map;
2298
+ for (let line of content.split(`
2299
+ `))
2300
+ if (line.trim())
2089
2301
  try {
2090
- obj = JSON.parse(line);
2302
+ let record = JSON.parse(line);
2303
+ record.sessionId?.trim() && record.workDir?.trim() && map.set(record.sessionId, record.workDir);
2091
2304
  } catch {
2092
2305
  continue;
2093
2306
  }
2094
- if (obj.payload?.model && (currentModel = obj.payload.model), obj.type !== "StatusUpdate") continue;
2095
- let usage = obj.payload?.token_usage;
2096
- if (!usage) continue;
2097
- let ts = parseTs(obj.timestamp);
2098
- if (!ts) continue;
2099
- let dk = dateKey(ts), dayMap = grouped.get(dk);
2100
- if (!dayMap) continue;
2101
- let msgId = obj.payload?.message_id;
2102
- if (msgId) {
2103
- if (seen.has(msgId)) continue;
2104
- seen.add(msgId);
2105
- }
2106
- let input = usage.input_other ?? 0, cached2 = usage.input_cache_read ?? 0, output = usage.output ?? 0;
2107
- accumulate(
2108
- dayMap,
2109
- `${currentModel}|${projectFields.project}`,
2110
- {
2111
- provider: "moonshot",
2112
- product: "kimi-code",
2113
- channel: "cli",
2114
- model: currentModel,
2115
- project: projectFields.project,
2116
- projectDisplay: projectFields.projectDisplay,
2117
- projectAlias: projectFields.projectAlias,
2118
- inputTokens: 0,
2119
- cachedInputTokens: 0,
2120
- cacheWriteTokens: 0,
2121
- outputTokens: 0,
2122
- reasoningOutputTokens: 0
2123
- },
2124
- { input, cached: cached2, cacheWrite: 0, output, reasoning: 0 }
2125
- );
2126
- }
2127
- }
2128
- return finalize(grouped);
2129
- }
2130
- function resolveKimiProject(hash, workspaceMap, aliases2) {
2131
- let wsPath = workspaceMap.get(hash);
2132
- return wsPath ? resolveProjectFields(wsPath, aliases2) : resolveProjectFields(hash, aliases2);
2307
+ return map;
2133
2308
  }
2134
- async function loadWorkspaceMap(kimiHome) {
2309
+ async function loadLegacyWorkspaceMap(kimiHome) {
2135
2310
  let map = /* @__PURE__ */ new Map();
2136
2311
  try {
2137
2312
  let raw = await readFile8(join10(kimiHome, "kimi.json"), "utf-8"), config = JSON.parse(raw);
2138
- if (config.workspaces)
2139
- for (let [hash, info] of Object.entries(config.workspaces))
2140
- info.path && map.set(hash, info.path);
2313
+ for (let [hash, info] of Object.entries(config.workspaces ?? {}))
2314
+ info.path?.trim() && map.set(hash, info.path);
2141
2315
  } catch {
2142
2316
  }
2143
2317
  return map;
2144
2318
  }
2319
+ async function loadLegacyModel(kimiHome) {
2320
+ for (let name of ["config.json", "kimi.json"])
2321
+ try {
2322
+ let raw = await readFile8(join10(kimiHome, name), "utf-8"), config = JSON.parse(raw);
2323
+ if (config.model?.trim()) return normalizeModel2(config.model);
2324
+ } catch {
2325
+ continue;
2326
+ }
2327
+ return DEFAULT_MODEL;
2328
+ }
2329
+ async function safeRead(filePath) {
2330
+ try {
2331
+ return await readFile8(filePath, "utf-8");
2332
+ } catch {
2333
+ return null;
2334
+ }
2335
+ }
2336
+ async function fileModifiedDate(filePath) {
2337
+ try {
2338
+ return (await stat(filePath)).mtime;
2339
+ } catch {
2340
+ return null;
2341
+ }
2342
+ }
2145
2343
 
2146
2344
  // src/scanners/amp.ts
2147
2345
  import { readFile as readFile9 } from "node:fs/promises";
@@ -2726,6 +2924,7 @@ async function discoverAllDates() {
2726
2924
  discoverGenericJsonlDates(join14(home, ".copilot", "session-state"), dates),
2727
2925
  discoverGenericJsonlDates(join14(home, ".qwen", "tmp"), dates),
2728
2926
  discoverGenericJsonlDates(join14(home, ".kimi", "sessions"), dates),
2927
+ discoverGenericJsonlDates(join14(resolveKimiCodeHome(home), "sessions"), dates),
2729
2928
  discoverGenericJsonDates(join14(home, ".local", "share", "amp", "threads"), dates),
2730
2929
  discoverGenericJsonlDates(join14(home, ".factory", "sessions"), dates),
2731
2930
  discoverGenericJsonDates(join14(home, ".local", "share", "opencode"), dates),
@@ -2747,7 +2946,7 @@ async function discoverGenericJsonlDates(baseDir, dates) {
2747
2946
  } catch {
2748
2947
  continue;
2749
2948
  }
2750
- let ts = parseTs(record.timestamp);
2949
+ let ts = parseTs(record.timestamp ?? record.time ?? record.created_at);
2751
2950
  ts && dates.add(dateKey(ts));
2752
2951
  }
2753
2952
  }
@@ -4061,7 +4260,7 @@ async function requestJson(url, init) {
4061
4260
  }
4062
4261
 
4063
4262
  // src/schedule.ts
4064
- import { mkdir as mkdir2, readFile as readFile16, stat, unlink, writeFile as writeFile2 } from "node:fs/promises";
4263
+ import { mkdir as mkdir2, readFile as readFile16, stat as stat2, unlink, writeFile as writeFile2 } from "node:fs/promises";
4065
4264
  import { execFile } from "node:child_process";
4066
4265
  import { promisify } from "node:util";
4067
4266
  import { homedir as homedir17, platform, tmpdir as tmpdir2 } from "node:os";
@@ -4160,7 +4359,7 @@ async function disableLaunchd() {
4160
4359
  }
4161
4360
  async function getLaunchdStatus() {
4162
4361
  try {
4163
- await stat(PLIST_PATH);
4362
+ await stat2(PLIST_PATH);
4164
4363
  } catch {
4165
4364
  return { enabled: !1 };
4166
4365
  }
@@ -4270,7 +4469,7 @@ function escapeXml(value) {
4270
4469
  }
4271
4470
 
4272
4471
  // src/doctor.ts
4273
- import { readdir as readdir8, stat as stat2 } from "node:fs/promises";
4472
+ import { readdir as readdir8, stat as stat3 } from "node:fs/promises";
4274
4473
  import { homedir as homedir18 } from "node:os";
4275
4474
  import { join as join18 } from "node:path";
4276
4475
  var msgs = {
@@ -4343,7 +4542,7 @@ async function countFiles(dir, exts, cap = 1e3) {
4343
4542
  async function runDoctor(lang = "zh") {
4344
4543
  let s = msgs[lang], checks = [], config = await readConfig(), g1 = s.groupConfig, configPath = getConfigPath();
4345
4544
  try {
4346
- await stat2(configPath), checks.push({ group: g1, name: s.config, status: "ok", message: configPath });
4545
+ await stat3(configPath), checks.push({ group: g1, name: s.config, status: "ok", message: configPath });
4347
4546
  } catch {
4348
4547
  checks.push({ group: g1, name: s.config, status: "fail", message: s.configMissing });
4349
4548
  }
@@ -4372,7 +4571,8 @@ async function runDoctor(lang = "zh") {
4372
4571
  { dir: join18(home, ".gemini", "tmp"), label: "Gemini CLI", exts: [".json"] },
4373
4572
  { dir: join18(home, ".gemini", "antigravity"), label: "Antigravity", exts: [".json"] },
4374
4573
  { dir: join18(home, ".qwen", "tmp"), label: "Qwen Code", exts: [".jsonl"] },
4375
- { dir: join18(home, ".kimi", "sessions"), label: "Kimi Code", exts: [".jsonl"] },
4574
+ { dir: join18(resolveKimiCodeHome(home), "sessions"), label: "Kimi Code", exts: [".jsonl"] },
4575
+ { dir: join18(home, ".kimi", "sessions"), label: "Kimi CLI (legacy)", exts: [".jsonl"] },
4376
4576
  { dir: join18(home, ".local", "share", "amp", "threads"), label: "Amp", exts: [".json"] },
4377
4577
  { dir: join18(home, ".factory", "sessions"), label: "Droid", exts: [".jsonl", ".json"] },
4378
4578
  { dir: join18(home, ".local", "share", "opencode"), label: "OpenCode", exts: [".json"] },
@@ -4380,7 +4580,7 @@ async function runDoctor(lang = "zh") {
4380
4580
  ];
4381
4581
  for (let tool of tools) {
4382
4582
  try {
4383
- await stat2(tool.dir);
4583
+ await stat3(tool.dir);
4384
4584
  } catch {
4385
4585
  checks.push({ group: g3, name: tool.label, status: "warn", message: s.notInstalled });
4386
4586
  continue;
@@ -4426,7 +4626,9 @@ async function discoverProjects(projectAliases) {
4426
4626
  discoverGeminiProjects().then((names) => names.forEach((n) => add(n, "gemini"))),
4427
4627
  // Antigravity: ~/.gemini/antigravity/knowledge/*/metadata.json
4428
4628
  // 仅读取知识项元数据标题,不读取对话内容
4429
- discoverAntigravityProjects().then((names) => names.forEach((n) => add(n, "antigravity")))
4629
+ discoverAntigravityProjects().then((names) => names.forEach((n) => add(n, "antigravity"))),
4630
+ // Kimi CLI / Kimi Code: legacy workspace map + new session metadata.
4631
+ discoverKimiProjects().then((names) => names.forEach((n) => add(n, "kimi")))
4430
4632
  ]);
4431
4633
  let results = [];
4432
4634
  for (let [name, sources] of projectMap) {
@@ -4637,6 +4839,40 @@ async function discoverAntigravityProjects() {
4637
4839
  }
4638
4840
  return [...projects];
4639
4841
  }
4842
+ async function discoverKimiProjects() {
4843
+ let projects = /* @__PURE__ */ new Set(), home = homedir19();
4844
+ try {
4845
+ let raw = await readFile17(join19(home, ".kimi", "kimi.json"), "utf-8"), data = JSON.parse(raw);
4846
+ for (let workspace of Object.values(data.workspaces ?? {})) {
4847
+ let name = basename11(workspace.path?.trim() ?? "");
4848
+ name && name !== "unknown" && projects.add(name);
4849
+ }
4850
+ } catch {
4851
+ }
4852
+ let codeHome = resolveKimiCodeHome(home);
4853
+ try {
4854
+ let raw = await readFile17(join19(codeHome, "session_index.jsonl"), "utf-8");
4855
+ for (let line of raw.split(`
4856
+ `))
4857
+ if (line.trim())
4858
+ try {
4859
+ let record = JSON.parse(line), name = basename11(record.workDir?.trim() ?? "");
4860
+ name && name !== "unknown" && projects.add(name);
4861
+ } catch {
4862
+ continue;
4863
+ }
4864
+ } catch {
4865
+ }
4866
+ let stateFiles = (await walkFiles2(join19(codeHome, "sessions"), ".json")).filter((filePath) => basename11(filePath) === "state.json");
4867
+ for (let filePath of stateFiles)
4868
+ try {
4869
+ let raw = await readFile17(filePath, "utf-8"), state = JSON.parse(raw), name = basename11(state.workDir?.trim() ?? "");
4870
+ name && name !== "unknown" && projects.add(name);
4871
+ } catch {
4872
+ continue;
4873
+ }
4874
+ return [...projects];
4875
+ }
4640
4876
  function nameFromFileUri(raw) {
4641
4877
  let path = pathFromFileUri(raw);
4642
4878
  if (!path) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiusage/cli",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "Track and sync AI tool token usage across devices.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2026-07-10-gpt-5.6-v1",
2
+ "version": "2026-07-18-kimi-k3-v1",
3
3
  "fx": {
4
4
  "CNY": 7.2
5
5
  },
@@ -10,7 +10,9 @@
10
10
  "claude-haiku-4-5-20251001": "claude-haiku-4-5",
11
11
  "claude-sonnet-4.6": "claude-sonnet-4-6",
12
12
  "gpt-5.6": "gpt-5.6-sol",
13
- "codex-auto-review": "gpt-5.4"
13
+ "codex-auto-review": "gpt-5.4",
14
+ "k3": "kimi-k3",
15
+ "kimi-code/k3": "kimi-k3"
14
16
  },
15
17
  "providers": {
16
18
  "anthropic": {
@@ -773,16 +775,40 @@
773
775
  "moonshot": {
774
776
  "kimi-code": {
775
777
  "models": {
778
+ "kimi-k3": {
779
+ "currency": "CNY",
780
+ "effective_from": "2026-07-17",
781
+ "input_per_million": 20,
782
+ "cached_input_per_million": 2,
783
+ "cache_write_per_million": 20,
784
+ "output_per_million": 100
785
+ },
786
+ "kimi-k2.7-code": {
787
+ "currency": "CNY",
788
+ "input_per_million": 6.5,
789
+ "cached_input_per_million": 1.3,
790
+ "cache_write_per_million": 6.5,
791
+ "output_per_million": 27
792
+ },
793
+ "kimi-k2.7-code-highspeed": {
794
+ "currency": "CNY",
795
+ "input_per_million": 13,
796
+ "cached_input_per_million": 2.6,
797
+ "cache_write_per_million": 13,
798
+ "output_per_million": 54
799
+ },
776
800
  "kimi-k2.6": {
777
801
  "currency": "CNY",
778
802
  "input_per_million": 6.5,
779
803
  "cached_input_per_million": 1.1,
804
+ "cache_write_per_million": 6.5,
780
805
  "output_per_million": 27
781
806
  },
782
807
  "kimi-k2.5": {
783
808
  "currency": "CNY",
784
809
  "input_per_million": 4,
785
810
  "cached_input_per_million": 0.7,
811
+ "cache_write_per_million": 4,
786
812
  "output_per_million": 21
787
813
  },
788
814
  "kimi-k2-0905-preview": {
@@ -790,6 +816,7 @@
790
816
  "notes": "will be retired 2026-05-25",
791
817
  "input_per_million": 4,
792
818
  "cached_input_per_million": 1,
819
+ "cache_write_per_million": 4,
793
820
  "output_per_million": 16
794
821
  },
795
822
  "kimi-k2-0711-preview": {
@@ -797,6 +824,7 @@
797
824
  "notes": "will be retired 2026-05-25",
798
825
  "input_per_million": 4,
799
826
  "cached_input_per_million": 1,
827
+ "cache_write_per_million": 4,
800
828
  "output_per_million": 16
801
829
  },
802
830
  "kimi-k2-turbo-preview": {
@@ -804,48 +832,57 @@
804
832
  "notes": "will be retired 2026-05-25",
805
833
  "input_per_million": 8,
806
834
  "cached_input_per_million": 1,
835
+ "cache_write_per_million": 8,
807
836
  "output_per_million": 58
808
837
  },
809
838
  "kimi-k2-thinking": {
810
839
  "currency": "CNY",
811
840
  "input_per_million": 4,
812
841
  "cached_input_per_million": 1,
842
+ "cache_write_per_million": 4,
813
843
  "output_per_million": 16
814
844
  },
815
845
  "kimi-k2-thinking-turbo": {
816
846
  "currency": "CNY",
817
847
  "input_per_million": 8,
818
848
  "cached_input_per_million": 1,
849
+ "cache_write_per_million": 8,
819
850
  "output_per_million": 58
820
851
  },
821
852
  "moonshot-v1-8k": {
822
853
  "currency": "CNY",
823
854
  "input_per_million": 2,
855
+ "cache_write_per_million": 2,
824
856
  "output_per_million": 10
825
857
  },
826
858
  "moonshot-v1-32k": {
827
859
  "currency": "CNY",
828
860
  "input_per_million": 5,
861
+ "cache_write_per_million": 5,
829
862
  "output_per_million": 20
830
863
  },
831
864
  "moonshot-v1-128k": {
832
865
  "currency": "CNY",
833
866
  "input_per_million": 10,
867
+ "cache_write_per_million": 10,
834
868
  "output_per_million": 30
835
869
  },
836
870
  "moonshot-v1-8k-vision-preview": {
837
871
  "currency": "CNY",
838
872
  "input_per_million": 2,
873
+ "cache_write_per_million": 2,
839
874
  "output_per_million": 10
840
875
  },
841
876
  "moonshot-v1-32k-vision-preview": {
842
877
  "currency": "CNY",
843
878
  "input_per_million": 5,
879
+ "cache_write_per_million": 5,
844
880
  "output_per_million": 20
845
881
  },
846
882
  "moonshot-v1-128k-vision-preview": {
847
883
  "currency": "CNY",
848
884
  "input_per_million": 10,
885
+ "cache_write_per_million": 10,
849
886
  "output_per_million": 30
850
887
  }
851
888
  }