@aiusage/cli 1.6.4 → 1.7.1
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/dist/cli.js +693 -66
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require < "u" ? require : typeof
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
|
-
import { createInterface as
|
|
10
|
+
import { createInterface as createInterface4 } from "node:readline";
|
|
11
11
|
import { hostname as hostname3 } from "node:os";
|
|
12
12
|
|
|
13
13
|
// src/scanners/antigravity.ts
|
|
@@ -3119,11 +3119,588 @@ function fmtDateShort(dateStr) {
|
|
|
3119
3119
|
return (/* @__PURE__ */ new Date(dateStr + "T00:00:00")).toLocaleDateString("en-US", { month: "short", day: "numeric" });
|
|
3120
3120
|
}
|
|
3121
3121
|
|
|
3122
|
+
// src/activity.ts
|
|
3123
|
+
import { open as open3, readdir as readdir7 } from "node:fs/promises";
|
|
3124
|
+
import { createInterface as createInterface3 } from "node:readline";
|
|
3125
|
+
import { homedir as homedir15 } from "node:os";
|
|
3126
|
+
import { basename as basename9, join as join15 } from "node:path";
|
|
3127
|
+
var FILE_CONCURRENCY3 = 16, MAX_LINE_BYTES3 = 64 * 1024 * 1024;
|
|
3128
|
+
async function buildActivityReport(range, options = {}) {
|
|
3129
|
+
let targetDates = options.dates ? new Set(options.dates) : void 0, [codex, claude] = await Promise.all([
|
|
3130
|
+
scanCodexActivity(targetDates, options),
|
|
3131
|
+
scanClaudeActivity(targetDates, options)
|
|
3132
|
+
]), items = [...codex.items, ...claude.items].sort(sortActivityItems), requestedDates = options.dates?.slice().sort(), itemDates = [...new Set(items.map((item) => item.usageDate))].sort(), reportDates = requestedDates ?? itemDates, daily = reportDates.map((usageDate) => {
|
|
3133
|
+
let dayItems = items.filter((item) => item.usageDate === usageDate);
|
|
3134
|
+
return {
|
|
3135
|
+
usageDate,
|
|
3136
|
+
exactCount: sumByConfidence(dayItems, "exact"),
|
|
3137
|
+
proxyCount: sumByConfidence(dayItems, "proxy"),
|
|
3138
|
+
userMessageCount: sumUserMessages(dayItems)
|
|
3139
|
+
};
|
|
3140
|
+
}).filter((day) => requestedDates || day.exactCount > 0 || day.proxyCount > 0 || day.userMessageCount > 0);
|
|
3141
|
+
return {
|
|
3142
|
+
range,
|
|
3143
|
+
rangeLabel: getRangeLabel3(range),
|
|
3144
|
+
startDate: reportDates[0],
|
|
3145
|
+
endDate: reportDates[reportDates.length - 1],
|
|
3146
|
+
requestedDays: reportDates.length,
|
|
3147
|
+
daysWithData: daily.filter((day) => day.exactCount > 0 || day.proxyCount > 0).length,
|
|
3148
|
+
totals: {
|
|
3149
|
+
exactCount: sumByConfidence(items, "exact"),
|
|
3150
|
+
proxyCount: sumByConfidence(items, "proxy"),
|
|
3151
|
+
userMessageCount: codex.stats.userMessages.size + claude.stats.userMessages.size,
|
|
3152
|
+
filesScanned: codex.stats.filesScanned + claude.stats.filesScanned,
|
|
3153
|
+
sessionsScanned: (/* @__PURE__ */ new Set([...codex.stats.sessions, ...claude.stats.sessions])).size
|
|
3154
|
+
},
|
|
3155
|
+
daily,
|
|
3156
|
+
bySource: summarize(items, (item) => item.source, (item) => item.source),
|
|
3157
|
+
byKind: summarize(items, (item) => item.kind, (item) => labelKind(item.kind)),
|
|
3158
|
+
topTools: summarize(
|
|
3159
|
+
items.filter((item) => isToolLikeKind(item.kind)),
|
|
3160
|
+
(item) => `${item.source}|${item.name}`,
|
|
3161
|
+
(item) => `${item.name} (${item.source})`,
|
|
3162
|
+
12
|
|
3163
|
+
),
|
|
3164
|
+
topSkills: summarize(
|
|
3165
|
+
items.filter((item) => item.kind === "skill_call" || item.kind === "skill_proxy"),
|
|
3166
|
+
(item) => `${item.source}|${item.name}|${item.confidence}`,
|
|
3167
|
+
(item) => `${item.name} (${item.confidence === "proxy" ? "proxy" : item.source})`,
|
|
3168
|
+
12
|
|
3169
|
+
),
|
|
3170
|
+
topAgents: summarize(
|
|
3171
|
+
items.filter((item) => item.kind === "agent_call"),
|
|
3172
|
+
(item) => `${item.source}|${item.name}`,
|
|
3173
|
+
(item) => `${item.name} (${item.source})`,
|
|
3174
|
+
12
|
|
3175
|
+
),
|
|
3176
|
+
items,
|
|
3177
|
+
notes: [
|
|
3178
|
+
"Claude Code \u7684 Skill/Agent \u6765\u81EA\u7ED3\u6784\u5316 tool_use\uFF0C\u53E3\u5F84\u4E3A exact\u3002",
|
|
3179
|
+
"Codex \u7684 skill_proxy \u6765\u81EA\u547D\u4EE4\u4E2D\u8BFB\u53D6 SKILL.md \u7684\u75D5\u8FF9\uFF0C\u53EA\u80FD\u8868\u793A\u4EE3\u7406\u4FE1\u53F7\u3002",
|
|
3180
|
+
"sync \u4F1A\u4E0A\u4F20\u6309\u65E5\u805A\u5408\u540E\u7684 activity \u6307\u6807\uFF0C\u4E0D\u4E0A\u4F20\u539F\u59CB\u6D88\u606F\u5185\u5BB9\u3002"
|
|
3181
|
+
]
|
|
3182
|
+
};
|
|
3183
|
+
}
|
|
3184
|
+
function renderActivityReport(report, opts) {
|
|
3185
|
+
let lines = [], title = opts.emoji ? "\u{1F9ED} AIUsage Activity" : "AIUsage Activity";
|
|
3186
|
+
if (lines.push(title), lines.push("\u2500".repeat(stripAnsi(title).length)), lines.push(`\u5468\u671F ${report.rangeLabel} (${report.startDate ?? "-"} ~ ${report.endDate ?? "-"})`), lines.push(`\u786E\u5207\u4E8B\u4EF6 ${fmt(report.totals.exactCount)}`), lines.push(`\u4EE3\u7406\u4FE1\u53F7 ${fmt(report.totals.proxyCount)}`), lines.push(`\u7528\u6237\u6D88\u606F ${fmt(report.totals.userMessageCount)}`), lines.push(`Session ${fmt(report.totals.sessionsScanned)}`), lines.push(`\u6587\u4EF6 ${fmt(report.totals.filesScanned)}`), report.daysWithData === 0)
|
|
3187
|
+
return lines.push(""), lines.push("\u8BE5\u8303\u56F4\u65E0\u6D3B\u52A8\u6570\u636E\u3002"), lines.join(`
|
|
3188
|
+
`);
|
|
3189
|
+
lines.push(""), lines.push("\u6309\u6765\u6E90");
|
|
3190
|
+
for (let row of report.bySource)
|
|
3191
|
+
lines.push(` ${row.label}: ${formatSummaryCount(row)}`);
|
|
3192
|
+
lines.push(""), lines.push("\u6309\u7C7B\u578B");
|
|
3193
|
+
for (let row of report.byKind)
|
|
3194
|
+
lines.push(` ${row.label}: ${formatSummaryCount(row)}`);
|
|
3195
|
+
if (report.topTools.length > 0) {
|
|
3196
|
+
lines.push(""), lines.push("Top \u5DE5\u5177");
|
|
3197
|
+
for (let row of report.topTools)
|
|
3198
|
+
lines.push(` ${row.label}: ${fmt(row.count)}`);
|
|
3199
|
+
}
|
|
3200
|
+
if (report.topSkills.length > 0) {
|
|
3201
|
+
lines.push(""), lines.push("Top Skill");
|
|
3202
|
+
for (let row of report.topSkills)
|
|
3203
|
+
lines.push(` ${row.label}: ${formatSummaryCount(row)}`);
|
|
3204
|
+
}
|
|
3205
|
+
if (report.topAgents.length > 0) {
|
|
3206
|
+
lines.push(""), lines.push("Top Subagent");
|
|
3207
|
+
for (let row of report.topAgents)
|
|
3208
|
+
lines.push(` ${row.label}: ${fmt(row.count)}`);
|
|
3209
|
+
}
|
|
3210
|
+
if (opts.detail && report.daily.length > 0) {
|
|
3211
|
+
lines.push(""), lines.push("\u6BCF\u65E5");
|
|
3212
|
+
for (let day of report.daily)
|
|
3213
|
+
lines.push(` ${day.usageDate}: exact ${fmt(day.exactCount)} / proxy ${fmt(day.proxyCount)} / user ${fmt(day.userMessageCount)}`);
|
|
3214
|
+
}
|
|
3215
|
+
if (opts.detail) {
|
|
3216
|
+
lines.push(""), lines.push("\u53E3\u5F84");
|
|
3217
|
+
for (let note of report.notes) lines.push(` - ${note}`);
|
|
3218
|
+
}
|
|
3219
|
+
return lines.join(`
|
|
3220
|
+
`);
|
|
3221
|
+
}
|
|
3222
|
+
async function scanCodexActivity(targetDates, options) {
|
|
3223
|
+
let baseDir = options.codexDir ?? join15(homedir15(), ".codex"), acc = createAccumulator(targetDates, options.projectAliases), files = await collectCodexSessionFiles2(baseDir);
|
|
3224
|
+
return acc.stats.filesScanned = files.length, await runWithConcurrency(files, FILE_CONCURRENCY3, async (filePath) => {
|
|
3225
|
+
await processCodexFile2(filePath, acc);
|
|
3226
|
+
}), finalizeActivity(acc);
|
|
3227
|
+
}
|
|
3228
|
+
async function processCodexFile2(filePath, acc) {
|
|
3229
|
+
let fh;
|
|
3230
|
+
try {
|
|
3231
|
+
fh = await open3(filePath, "r");
|
|
3232
|
+
} catch {
|
|
3233
|
+
return;
|
|
3234
|
+
}
|
|
3235
|
+
let sessionId = basename9(filePath).replace(/\.jsonl$/, ""), projectFields = { project: "unknown", projectDisplay: "unknown" };
|
|
3236
|
+
try {
|
|
3237
|
+
let rl = createInterface3({
|
|
3238
|
+
input: fh.createReadStream({ encoding: "utf-8" }),
|
|
3239
|
+
crlfDelay: 1 / 0
|
|
3240
|
+
});
|
|
3241
|
+
for await (let line of rl) {
|
|
3242
|
+
if (!line || Buffer.byteLength(line) > MAX_LINE_BYTES3) continue;
|
|
3243
|
+
let record;
|
|
3244
|
+
try {
|
|
3245
|
+
record = JSON.parse(line);
|
|
3246
|
+
} catch {
|
|
3247
|
+
continue;
|
|
3248
|
+
}
|
|
3249
|
+
if (record.type === "session_meta") {
|
|
3250
|
+
let id = stringValue(record.payload?.id);
|
|
3251
|
+
id && (sessionId = id), acc.stats.sessions.add(`codex:${sessionId}`);
|
|
3252
|
+
continue;
|
|
3253
|
+
}
|
|
3254
|
+
if (record.type === "turn_context") {
|
|
3255
|
+
let cwd = stringValue(record.payload?.cwd);
|
|
3256
|
+
cwd && (projectFields = resolveProjectFields(cwd, acc.projectAliases));
|
|
3257
|
+
continue;
|
|
3258
|
+
}
|
|
3259
|
+
let ts = parseTs(record.timestamp);
|
|
3260
|
+
if (!ts) continue;
|
|
3261
|
+
let usageDate = dateKey(ts);
|
|
3262
|
+
if (acceptsDate(acc, usageDate)) {
|
|
3263
|
+
if (record.type === "response_item") {
|
|
3264
|
+
handleCodexResponseItem(record.payload?.item ?? record.payload, usageDate, projectFields, sessionId, filePath, record.timestamp ?? "", acc);
|
|
3265
|
+
continue;
|
|
3266
|
+
}
|
|
3267
|
+
record.type === "event_msg" && handleCodexEvent(record, usageDate, projectFields, sessionId, filePath, acc);
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
} finally {
|
|
3271
|
+
await fh.close();
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
function handleCodexResponseItem(item, usageDate, projectFields, sessionId, filePath, timestamp, acc) {
|
|
3275
|
+
if (!item?.type) return;
|
|
3276
|
+
let callId = item.call_id, baseKey = callId ? `codex:${item.type}:${callId}` : `codex:${filePath}:${usageDate}:${item.type}:${item.name ?? ""}:${item.arguments ?? ""}`;
|
|
3277
|
+
if (item.type === "message") {
|
|
3278
|
+
item.role === "user" && hasCodexUserMessageContent(item.content) && addUserMessage(acc, {
|
|
3279
|
+
provider: "openai",
|
|
3280
|
+
product: "codex",
|
|
3281
|
+
usageDate,
|
|
3282
|
+
projectFields,
|
|
3283
|
+
sessionId,
|
|
3284
|
+
timestamp,
|
|
3285
|
+
content: extractCodexMessageText(item.content),
|
|
3286
|
+
fallbackKey: `${filePath}:${usageDate}:${sessionId}:${JSON.stringify(item.content ?? "")}`
|
|
3287
|
+
});
|
|
3288
|
+
return;
|
|
3289
|
+
}
|
|
3290
|
+
if (item.type === "function_call") {
|
|
3291
|
+
let name = item.name ?? "unknown", args = parseJsonObject(item.arguments), kind = name === "spawn_agent" ? "agent_call" : "function_call";
|
|
3292
|
+
addActivity(acc, {
|
|
3293
|
+
usageDate,
|
|
3294
|
+
provider: "openai",
|
|
3295
|
+
product: "codex",
|
|
3296
|
+
projectFields,
|
|
3297
|
+
sessionId,
|
|
3298
|
+
kind,
|
|
3299
|
+
name: kind === "agent_call" ? stringValue(args.agent_type) ?? name : name,
|
|
3300
|
+
confidence: "exact",
|
|
3301
|
+
dedupeKey: baseKey
|
|
3302
|
+
});
|
|
3303
|
+
for (let skillName of extractSkillProxyNames(item.arguments))
|
|
3304
|
+
addActivity(acc, {
|
|
3305
|
+
usageDate,
|
|
3306
|
+
provider: "openai",
|
|
3307
|
+
product: "codex",
|
|
3308
|
+
projectFields,
|
|
3309
|
+
sessionId,
|
|
3310
|
+
kind: "skill_proxy",
|
|
3311
|
+
name: skillName,
|
|
3312
|
+
confidence: "proxy",
|
|
3313
|
+
dedupeKey: `${baseKey}:skill:${skillName}`
|
|
3314
|
+
});
|
|
3315
|
+
return;
|
|
3316
|
+
}
|
|
3317
|
+
if (item.type === "custom_tool_call") {
|
|
3318
|
+
addActivity(acc, {
|
|
3319
|
+
usageDate,
|
|
3320
|
+
provider: "openai",
|
|
3321
|
+
product: "codex",
|
|
3322
|
+
projectFields,
|
|
3323
|
+
sessionId,
|
|
3324
|
+
kind: "custom_tool_call",
|
|
3325
|
+
name: item.name ?? "unknown",
|
|
3326
|
+
confidence: "exact",
|
|
3327
|
+
dedupeKey: baseKey
|
|
3328
|
+
});
|
|
3329
|
+
return;
|
|
3330
|
+
}
|
|
3331
|
+
(item.type === "web_search_call" || item.type === "tool_search_call" || item.type === "image_generation_call") && addActivity(acc, {
|
|
3332
|
+
usageDate,
|
|
3333
|
+
provider: "openai",
|
|
3334
|
+
product: "codex",
|
|
3335
|
+
projectFields,
|
|
3336
|
+
sessionId,
|
|
3337
|
+
kind: item.type === "web_search_call" ? "web_search" : item.type === "tool_search_call" ? "tool_search" : "image_generation",
|
|
3338
|
+
name: item.name ?? item.type,
|
|
3339
|
+
confidence: "exact",
|
|
3340
|
+
dedupeKey: baseKey
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3343
|
+
function handleCodexEvent(record, usageDate, projectFields, sessionId, filePath, acc) {
|
|
3344
|
+
let payloadType = record.payload?.type;
|
|
3345
|
+
if (payloadType === "user_message") {
|
|
3346
|
+
addUserMessage(acc, {
|
|
3347
|
+
provider: "openai",
|
|
3348
|
+
product: "codex",
|
|
3349
|
+
usageDate,
|
|
3350
|
+
projectFields,
|
|
3351
|
+
sessionId,
|
|
3352
|
+
timestamp: record.timestamp ?? "",
|
|
3353
|
+
content: stringValue(record.payload?.message),
|
|
3354
|
+
fallbackKey: `${filePath}:${usageDate}:${sessionId}:event_user_message:${record.timestamp ?? ""}`
|
|
3355
|
+
});
|
|
3356
|
+
return;
|
|
3357
|
+
}
|
|
3358
|
+
let kind = payloadType === "task_started" || payloadType === "task_complete" ? "task" : payloadType === "context_compacted" ? "compaction" : payloadType === "thread_rolled_back" ? "rollback" : payloadType === "turn_aborted" ? "interruption" : payloadType === "mcp_tool_call_end" ? "mcp_tool_call" : void 0;
|
|
3359
|
+
if (!kind) return;
|
|
3360
|
+
let callId = stringValue(record.payload?.call_id);
|
|
3361
|
+
addActivity(acc, {
|
|
3362
|
+
usageDate,
|
|
3363
|
+
provider: "openai",
|
|
3364
|
+
product: "codex",
|
|
3365
|
+
projectFields,
|
|
3366
|
+
sessionId,
|
|
3367
|
+
kind,
|
|
3368
|
+
name: payloadType ?? kind,
|
|
3369
|
+
confidence: "exact",
|
|
3370
|
+
dedupeKey: callId ? `codex:event:${callId}:${payloadType}` : `codex:event:${filePath}:${usageDate}:${sessionId}:${payloadType}:${record.timestamp ?? ""}`
|
|
3371
|
+
});
|
|
3372
|
+
}
|
|
3373
|
+
async function scanClaudeActivity(targetDates, options) {
|
|
3374
|
+
let acc = createAccumulator(targetDates, options.projectAliases), fileJobs = [];
|
|
3375
|
+
for (let baseDir of getClaudeProjectDirs2(options.claudeProjectsDirs)) {
|
|
3376
|
+
let projectDirs;
|
|
3377
|
+
try {
|
|
3378
|
+
projectDirs = await readdir7(baseDir, { withFileTypes: !0 });
|
|
3379
|
+
} catch {
|
|
3380
|
+
continue;
|
|
3381
|
+
}
|
|
3382
|
+
for (let entry of projectDirs) {
|
|
3383
|
+
if (!entry.isDirectory()) continue;
|
|
3384
|
+
let projectPath = join15(baseDir, entry.name), jsonlFiles = [];
|
|
3385
|
+
await walkJsonl(projectPath, jsonlFiles);
|
|
3386
|
+
let fields = resolveClaudeProject(projectPath, acc.projectAliases);
|
|
3387
|
+
for (let filePath of jsonlFiles) fileJobs.push({ filePath, projectFields: fields });
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
return acc.stats.filesScanned = fileJobs.length, await runWithConcurrency(fileJobs, FILE_CONCURRENCY3, async (job) => {
|
|
3391
|
+
await processClaudeFile(job.filePath, job.projectFields, acc);
|
|
3392
|
+
}), finalizeActivity(acc);
|
|
3393
|
+
}
|
|
3394
|
+
async function processClaudeFile(filePath, fallbackFields, acc) {
|
|
3395
|
+
let fh;
|
|
3396
|
+
try {
|
|
3397
|
+
fh = await open3(filePath, "r");
|
|
3398
|
+
} catch {
|
|
3399
|
+
return;
|
|
3400
|
+
}
|
|
3401
|
+
let fallbackSessionId = basename9(filePath).replace(/\.jsonl$/, "");
|
|
3402
|
+
try {
|
|
3403
|
+
let rl = createInterface3({
|
|
3404
|
+
input: fh.createReadStream({ encoding: "utf-8" }),
|
|
3405
|
+
crlfDelay: 1 / 0
|
|
3406
|
+
});
|
|
3407
|
+
for await (let line of rl) {
|
|
3408
|
+
if (!line || Buffer.byteLength(line) > MAX_LINE_BYTES3) continue;
|
|
3409
|
+
let record;
|
|
3410
|
+
try {
|
|
3411
|
+
record = JSON.parse(line);
|
|
3412
|
+
} catch {
|
|
3413
|
+
continue;
|
|
3414
|
+
}
|
|
3415
|
+
let ts = parseTs(record.timestamp);
|
|
3416
|
+
if (!ts) continue;
|
|
3417
|
+
let usageDate = dateKey(ts);
|
|
3418
|
+
if (!acceptsDate(acc, usageDate)) continue;
|
|
3419
|
+
let sessionId = record.sessionId ?? fallbackSessionId;
|
|
3420
|
+
acc.stats.sessions.add(`claude:${sessionId}`);
|
|
3421
|
+
let projectFields = record.cwd ? resolveProjectFields(record.cwd, acc.projectAliases) : fallbackFields;
|
|
3422
|
+
isClaudeUserMessage(record) && addUserMessage(acc, {
|
|
3423
|
+
provider: "anthropic",
|
|
3424
|
+
product: "claude-code",
|
|
3425
|
+
usageDate,
|
|
3426
|
+
projectFields,
|
|
3427
|
+
sessionId,
|
|
3428
|
+
timestamp: record.timestamp ?? "",
|
|
3429
|
+
content: extractClaudeMessageText(record.message?.content),
|
|
3430
|
+
fallbackKey: `${filePath}:${usageDate}:${sessionId}:user:${record.timestamp ?? ""}`,
|
|
3431
|
+
id: record.uuid
|
|
3432
|
+
});
|
|
3433
|
+
let blocks = Array.isArray(record.message?.content) ? record.message.content : [];
|
|
3434
|
+
for (let block of blocks) {
|
|
3435
|
+
if (block?.type !== "tool_use") continue;
|
|
3436
|
+
let name = block.name ?? "unknown", kind = classifyClaudeTool(name), metricName = getClaudeMetricName(name, block.input), dedupeKey = block.id ? `claude:tool:${block.id}` : `claude:tool:${filePath}:${usageDate}:${sessionId}:${name}:${JSON.stringify(block.input ?? {})}`;
|
|
3437
|
+
addActivity(acc, {
|
|
3438
|
+
usageDate,
|
|
3439
|
+
provider: "anthropic",
|
|
3440
|
+
product: "claude-code",
|
|
3441
|
+
projectFields,
|
|
3442
|
+
sessionId,
|
|
3443
|
+
kind,
|
|
3444
|
+
name: metricName,
|
|
3445
|
+
confidence: "exact",
|
|
3446
|
+
dedupeKey
|
|
3447
|
+
});
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
} finally {
|
|
3451
|
+
await fh.close();
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
function createAccumulator(targetDates, projectAliases) {
|
|
3455
|
+
return {
|
|
3456
|
+
targetDates,
|
|
3457
|
+
projectAliases,
|
|
3458
|
+
items: /* @__PURE__ */ new Map(),
|
|
3459
|
+
seen: /* @__PURE__ */ new Set(),
|
|
3460
|
+
stats: {
|
|
3461
|
+
filesScanned: 0,
|
|
3462
|
+
sessions: /* @__PURE__ */ new Set(),
|
|
3463
|
+
userMessages: /* @__PURE__ */ new Set()
|
|
3464
|
+
}
|
|
3465
|
+
};
|
|
3466
|
+
}
|
|
3467
|
+
function finalizeActivity(acc) {
|
|
3468
|
+
return {
|
|
3469
|
+
items: [...acc.items.values()],
|
|
3470
|
+
stats: acc.stats
|
|
3471
|
+
};
|
|
3472
|
+
}
|
|
3473
|
+
function addActivity(acc, input) {
|
|
3474
|
+
if (acc.seen.has(input.dedupeKey)) return;
|
|
3475
|
+
acc.seen.add(input.dedupeKey);
|
|
3476
|
+
let source = `${input.provider}/${input.product}`, key = [
|
|
3477
|
+
input.usageDate,
|
|
3478
|
+
source,
|
|
3479
|
+
input.projectFields.project,
|
|
3480
|
+
input.kind,
|
|
3481
|
+
input.name,
|
|
3482
|
+
input.confidence
|
|
3483
|
+
].join("|"), existing = acc.items.get(key);
|
|
3484
|
+
if (existing) {
|
|
3485
|
+
existing.count += 1;
|
|
3486
|
+
return;
|
|
3487
|
+
}
|
|
3488
|
+
acc.items.set(key, {
|
|
3489
|
+
usageDate: input.usageDate,
|
|
3490
|
+
provider: input.provider,
|
|
3491
|
+
product: input.product,
|
|
3492
|
+
source,
|
|
3493
|
+
project: input.projectFields.project,
|
|
3494
|
+
projectDisplay: input.projectFields.projectDisplay,
|
|
3495
|
+
projectAlias: input.projectFields.projectAlias,
|
|
3496
|
+
kind: input.kind,
|
|
3497
|
+
name: input.name,
|
|
3498
|
+
count: 1,
|
|
3499
|
+
confidence: input.confidence
|
|
3500
|
+
});
|
|
3501
|
+
}
|
|
3502
|
+
function addUserMessage(acc, input) {
|
|
3503
|
+
let source = `${input.provider}/${input.product}`, normalized = normalizeMessageText(input.content), key = input.id ? `${source}:user_message:${input.id}` : normalized ? `${source}:user_message:${input.sessionId}:${input.timestamp}:${normalized}` : `${source}:user_message:${input.fallbackKey}`;
|
|
3504
|
+
acc.stats.userMessages.has(key) || (acc.stats.userMessages.add(key), addActivity(acc, {
|
|
3505
|
+
usageDate: input.usageDate,
|
|
3506
|
+
provider: input.provider,
|
|
3507
|
+
product: input.product,
|
|
3508
|
+
projectFields: input.projectFields,
|
|
3509
|
+
sessionId: input.sessionId,
|
|
3510
|
+
kind: "user_message",
|
|
3511
|
+
name: "user_message",
|
|
3512
|
+
confidence: "exact",
|
|
3513
|
+
dedupeKey: `activity:${key}`
|
|
3514
|
+
}));
|
|
3515
|
+
}
|
|
3516
|
+
function acceptsDate(acc, usageDate) {
|
|
3517
|
+
return !acc.targetDates || acc.targetDates.has(usageDate);
|
|
3518
|
+
}
|
|
3519
|
+
async function collectCodexSessionFiles2(baseDir) {
|
|
3520
|
+
let paths = [];
|
|
3521
|
+
try {
|
|
3522
|
+
let files = await readdir7(join15(baseDir, "archived_sessions"));
|
|
3523
|
+
for (let file of files)
|
|
3524
|
+
file.endsWith(".jsonl") && paths.push(join15(baseDir, "archived_sessions", file));
|
|
3525
|
+
} catch {
|
|
3526
|
+
}
|
|
3527
|
+
return await walkJsonl(join15(baseDir, "sessions"), paths), paths;
|
|
3528
|
+
}
|
|
3529
|
+
function getClaudeProjectDirs2(configured) {
|
|
3530
|
+
if (configured?.length) return configured;
|
|
3531
|
+
let envVar = process.env.CLAUDE_CONFIG_DIR?.trim();
|
|
3532
|
+
if (envVar)
|
|
3533
|
+
return envVar.split(",").map((p) => p.trim()).filter(Boolean).map((p) => join15(p, "projects"));
|
|
3534
|
+
let home = homedir15();
|
|
3535
|
+
return [
|
|
3536
|
+
join15(home, ".config", "claude", "projects"),
|
|
3537
|
+
join15(home, ".claude", "projects")
|
|
3538
|
+
];
|
|
3539
|
+
}
|
|
3540
|
+
async function walkJsonl(dir, result) {
|
|
3541
|
+
let entries;
|
|
3542
|
+
try {
|
|
3543
|
+
entries = await readdir7(dir, { withFileTypes: !0 });
|
|
3544
|
+
} catch {
|
|
3545
|
+
return;
|
|
3546
|
+
}
|
|
3547
|
+
for (let entry of entries) {
|
|
3548
|
+
let fullPath = join15(dir, entry.name);
|
|
3549
|
+
entry.isDirectory() ? await walkJsonl(fullPath, result) : entry.name.endsWith(".jsonl") && result.push(fullPath);
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
function resolveClaudeProject(projectPath, aliases2) {
|
|
3553
|
+
let rawName = basename9(projectPath), display = rawName.split("-").filter(Boolean).at(-1) || rawName || "unknown", alias = aliases2?.[projectPath] ?? aliases2?.[display];
|
|
3554
|
+
return {
|
|
3555
|
+
project: projectPath,
|
|
3556
|
+
projectDisplay: display,
|
|
3557
|
+
projectAlias: alias
|
|
3558
|
+
};
|
|
3559
|
+
}
|
|
3560
|
+
function classifyClaudeTool(name) {
|
|
3561
|
+
return name === "Skill" ? "skill_call" : name === "Agent" ? "agent_call" : name === "WebSearch" || name === "WebFetch" ? "web_search" : name === "ToolSearch" ? "tool_search" : name === "TaskCreate" || name === "TaskUpdate" || name === "TaskList" || name === "TaskStop" ? "task" : "tool_call";
|
|
3562
|
+
}
|
|
3563
|
+
function getClaudeMetricName(toolName, input) {
|
|
3564
|
+
return toolName === "Skill" ? stringValue(input?.skill) ?? "unknown" : toolName === "Agent" ? stringValue(input?.description) ?? stringValue(input?.subagent_type) ?? "unknown" : toolName;
|
|
3565
|
+
}
|
|
3566
|
+
function isClaudeUserMessage(record) {
|
|
3567
|
+
if (record.type !== "user" || record.message?.role !== "user" || record.isMeta || record.toolUseResult || record.sourceToolAssistantUUID || record.sourceToolUseID) return !1;
|
|
3568
|
+
let content = record.message.content;
|
|
3569
|
+
return typeof content == "string" ? content.trim().length > 0 : !Array.isArray(content) || content.length === 0 || content.some((block) => block?.type === "tool_result") ? !1 : content.some((block) => block?.type === "text" && stringValue(block.text));
|
|
3570
|
+
}
|
|
3571
|
+
function hasCodexUserMessageContent(content) {
|
|
3572
|
+
return typeof content == "string" ? content.trim().length > 0 : !Array.isArray(content) || content.length === 0 ? !1 : content.some((block) => block?.type === "input_text" || block?.type === "text");
|
|
3573
|
+
}
|
|
3574
|
+
function extractCodexMessageText(content) {
|
|
3575
|
+
return typeof content == "string" ? content : Array.isArray(content) && content.map((block) => stringValue(block.text)).filter(Boolean).join(`
|
|
3576
|
+
`) || void 0;
|
|
3577
|
+
}
|
|
3578
|
+
function extractClaudeMessageText(content) {
|
|
3579
|
+
return typeof content == "string" ? content : Array.isArray(content) && content.filter((block) => block?.type === "text").map((block) => stringValue(block.text)).filter(Boolean).join(`
|
|
3580
|
+
`) || void 0;
|
|
3581
|
+
}
|
|
3582
|
+
function normalizeMessageText(value) {
|
|
3583
|
+
return value?.replace(/\s+/g, " ").trim() || void 0;
|
|
3584
|
+
}
|
|
3585
|
+
function extractSkillProxyNames(rawArguments) {
|
|
3586
|
+
if (!rawArguments) return [];
|
|
3587
|
+
let args = parseJsonObject(rawArguments), command2 = stringValue(args.cmd) ?? stringValue(args.command) ?? "";
|
|
3588
|
+
if (!command2.includes("SKILL.md")) return [];
|
|
3589
|
+
let names = /* @__PURE__ */ new Set();
|
|
3590
|
+
for (let match of command2.matchAll(/([^\s'"]*SKILL\.md)/g))
|
|
3591
|
+
names.add(skillNameFromPath(match[1]));
|
|
3592
|
+
return [...names];
|
|
3593
|
+
}
|
|
3594
|
+
function parseJsonObject(raw) {
|
|
3595
|
+
if (!raw) return {};
|
|
3596
|
+
try {
|
|
3597
|
+
let parsed = JSON.parse(raw);
|
|
3598
|
+
return parsed && typeof parsed == "object" && !Array.isArray(parsed) ? parsed : {};
|
|
3599
|
+
} catch {
|
|
3600
|
+
return {};
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
function skillNameFromPath(rawPath) {
|
|
3604
|
+
let parts = rawPath.replace(/^[`'"]+|[`'"]+$/g, "").split("/").filter(Boolean), idx = parts.lastIndexOf("SKILL.md"), name = idx > 0 ? parts[idx - 1] : void 0;
|
|
3605
|
+
return !name || name === "$d" || name === "s#" ? "unknown-skill" : name;
|
|
3606
|
+
}
|
|
3607
|
+
function stringValue(value) {
|
|
3608
|
+
return typeof value == "string" && value.length > 0 ? value : void 0;
|
|
3609
|
+
}
|
|
3610
|
+
function summarize(items, keyFn, labelFn, limit) {
|
|
3611
|
+
let grouped = /* @__PURE__ */ new Map();
|
|
3612
|
+
for (let item of items) {
|
|
3613
|
+
let key = keyFn(item), existing = grouped.get(key);
|
|
3614
|
+
if (existing) {
|
|
3615
|
+
existing.count += item.count, item.confidence === "exact" ? existing.exactCount += item.count : existing.proxyCount += item.count;
|
|
3616
|
+
continue;
|
|
3617
|
+
}
|
|
3618
|
+
grouped.set(key, {
|
|
3619
|
+
key,
|
|
3620
|
+
label: labelFn(item),
|
|
3621
|
+
count: item.count,
|
|
3622
|
+
exactCount: item.confidence === "exact" ? item.count : 0,
|
|
3623
|
+
proxyCount: item.confidence === "proxy" ? item.count : 0
|
|
3624
|
+
});
|
|
3625
|
+
}
|
|
3626
|
+
let rows = [...grouped.values()].sort((a, b) => b.count - a.count || a.label.localeCompare(b.label));
|
|
3627
|
+
return limit ? rows.slice(0, limit) : rows;
|
|
3628
|
+
}
|
|
3629
|
+
function sumByConfidence(items, confidence) {
|
|
3630
|
+
return items.reduce((sum, item) => sum + (item.kind !== "user_message" && item.confidence === confidence ? item.count : 0), 0);
|
|
3631
|
+
}
|
|
3632
|
+
function sumUserMessages(items) {
|
|
3633
|
+
return items.reduce((sum, item) => sum + (item.kind === "user_message" ? item.count : 0), 0);
|
|
3634
|
+
}
|
|
3635
|
+
function isToolLikeKind(kind) {
|
|
3636
|
+
return kind === "function_call" || kind === "custom_tool_call" || kind === "tool_call" || kind === "web_search" || kind === "tool_search" || kind === "image_generation" || kind === "mcp_tool_call";
|
|
3637
|
+
}
|
|
3638
|
+
function labelKind(kind) {
|
|
3639
|
+
switch (kind) {
|
|
3640
|
+
case "user_message":
|
|
3641
|
+
return "User Message";
|
|
3642
|
+
case "function_call":
|
|
3643
|
+
return "Function Call";
|
|
3644
|
+
case "custom_tool_call":
|
|
3645
|
+
return "Custom Tool Call";
|
|
3646
|
+
case "tool_call":
|
|
3647
|
+
return "Tool Call";
|
|
3648
|
+
case "skill_call":
|
|
3649
|
+
return "Skill";
|
|
3650
|
+
case "skill_proxy":
|
|
3651
|
+
return "Skill Proxy";
|
|
3652
|
+
case "agent_call":
|
|
3653
|
+
return "Subagent";
|
|
3654
|
+
case "web_search":
|
|
3655
|
+
return "Web Search";
|
|
3656
|
+
case "tool_search":
|
|
3657
|
+
return "Tool Search";
|
|
3658
|
+
case "image_generation":
|
|
3659
|
+
return "Image Generation";
|
|
3660
|
+
case "task":
|
|
3661
|
+
return "Task";
|
|
3662
|
+
case "compaction":
|
|
3663
|
+
return "Context Compaction";
|
|
3664
|
+
case "rollback":
|
|
3665
|
+
return "Rollback";
|
|
3666
|
+
case "interruption":
|
|
3667
|
+
return "Interruption";
|
|
3668
|
+
case "mcp_tool_call":
|
|
3669
|
+
return "MCP Tool";
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
function getRangeLabel3(range) {
|
|
3673
|
+
switch (range) {
|
|
3674
|
+
case "7d":
|
|
3675
|
+
return "\u6700\u8FD1 7 \u5929";
|
|
3676
|
+
case "1m":
|
|
3677
|
+
return "\u6700\u8FD1 30 \u5929";
|
|
3678
|
+
case "3m":
|
|
3679
|
+
return "\u6700\u8FD1 90 \u5929";
|
|
3680
|
+
case "all":
|
|
3681
|
+
return "\u5168\u90E8\u5386\u53F2";
|
|
3682
|
+
case "today":
|
|
3683
|
+
return "\u4ECA\u5929";
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
function sortActivityItems(a, b) {
|
|
3687
|
+
return a.usageDate.localeCompare(b.usageDate) || a.source.localeCompare(b.source) || a.kind.localeCompare(b.kind) || a.name.localeCompare(b.name);
|
|
3688
|
+
}
|
|
3689
|
+
function formatSummaryCount(row) {
|
|
3690
|
+
return row.proxyCount === 0 ? fmt(row.exactCount) : row.exactCount === 0 ? `${fmt(row.proxyCount)} proxy` : `${fmt(row.exactCount)} exact / ${fmt(row.proxyCount)} proxy`;
|
|
3691
|
+
}
|
|
3692
|
+
function fmt(n) {
|
|
3693
|
+
return n.toLocaleString("en-US");
|
|
3694
|
+
}
|
|
3695
|
+
function stripAnsi(s) {
|
|
3696
|
+
return s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
3697
|
+
}
|
|
3698
|
+
|
|
3122
3699
|
// src/config.ts
|
|
3123
3700
|
import { mkdir, readFile as readFile15, writeFile } from "node:fs/promises";
|
|
3124
|
-
import { homedir as
|
|
3125
|
-
import { basename as
|
|
3126
|
-
var CONFIG_DIR =
|
|
3701
|
+
import { homedir as homedir16, hostname } from "node:os";
|
|
3702
|
+
import { basename as basename10, join as join16 } from "node:path";
|
|
3703
|
+
var CONFIG_DIR = join16(homedir16(), ".aiusage"), CONFIG_PATH = join16(CONFIG_DIR, "config.json");
|
|
3127
3704
|
function getConfigPath() {
|
|
3128
3705
|
return CONFIG_PATH;
|
|
3129
3706
|
}
|
|
@@ -3340,9 +3917,9 @@ async function requestJson(url, init) {
|
|
|
3340
3917
|
import { mkdir as mkdir2, readFile as readFile16, stat, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
3341
3918
|
import { execFile } from "node:child_process";
|
|
3342
3919
|
import { promisify } from "node:util";
|
|
3343
|
-
import { homedir as
|
|
3344
|
-
import { join as
|
|
3345
|
-
var execFileAsync = promisify(execFile), LABEL = "com.aiusage.sync", PLIST_PATH =
|
|
3920
|
+
import { homedir as homedir17, platform, tmpdir as tmpdir2 } from "node:os";
|
|
3921
|
+
import { join as join17, resolve as resolve3 } from "node:path";
|
|
3922
|
+
var execFileAsync = promisify(execFile), LABEL = "com.aiusage.sync", PLIST_PATH = join17(homedir17(), "Library", "LaunchAgents", `${LABEL}.plist`), LOG_PATH = join17(homedir17(), ".aiusage", "sync.log"), CRON_MARKER = "# aiusage-sync";
|
|
3346
3923
|
function parseInterval(value) {
|
|
3347
3924
|
let match = value.match(/^(\d+)(m|h|d)$/);
|
|
3348
3925
|
if (!match) throw new Error("--every \u683C\u5F0F\u9519\u8BEF\uFF0C\u793A\u4F8B: 30m, 1h, 2h, 1d");
|
|
@@ -3387,7 +3964,7 @@ function resolveCommandPaths() {
|
|
|
3387
3964
|
}
|
|
3388
3965
|
async function enableLaunchd(intervalSeconds) {
|
|
3389
3966
|
let { nodePath, scriptPath } = resolveCommandPaths();
|
|
3390
|
-
await mkdir2(
|
|
3967
|
+
await mkdir2(join17(homedir17(), ".aiusage"), { recursive: !0 });
|
|
3391
3968
|
let plist = [
|
|
3392
3969
|
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
3393
3970
|
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
|
|
@@ -3456,8 +4033,8 @@ async function getLaunchdStatus() {
|
|
|
3456
4033
|
}
|
|
3457
4034
|
}
|
|
3458
4035
|
async function enableCron(intervalSeconds) {
|
|
3459
|
-
let { nodePath, scriptPath } = resolveCommandPaths(), cronExpr = secondsToCron(intervalSeconds), logPath =
|
|
3460
|
-
await mkdir2(
|
|
4036
|
+
let { nodePath, scriptPath } = resolveCommandPaths(), cronExpr = secondsToCron(intervalSeconds), logPath = join17(homedir17(), ".aiusage", "sync.log"), cronLine = `${cronExpr} ${nodePath} ${scriptPath} sync --today >> ${logPath} 2>&1 ${CRON_MARKER}`;
|
|
4037
|
+
await mkdir2(join17(homedir17(), ".aiusage"), { recursive: !0 });
|
|
3461
4038
|
let existing = "";
|
|
3462
4039
|
try {
|
|
3463
4040
|
let { stdout } = await execFileAsync("crontab", ["-l"]);
|
|
@@ -3515,7 +4092,7 @@ async function getCronStatus() {
|
|
|
3515
4092
|
}
|
|
3516
4093
|
}
|
|
3517
4094
|
async function writeCrontab(content) {
|
|
3518
|
-
let tmpFile =
|
|
4095
|
+
let tmpFile = join17(tmpdir2(), `aiusage-cron-${Date.now()}`);
|
|
3519
4096
|
await writeFile2(tmpFile, content, "utf-8");
|
|
3520
4097
|
try {
|
|
3521
4098
|
await execFileAsync("crontab", [tmpFile]);
|
|
@@ -3546,9 +4123,9 @@ function escapeXml(value) {
|
|
|
3546
4123
|
}
|
|
3547
4124
|
|
|
3548
4125
|
// src/doctor.ts
|
|
3549
|
-
import { readdir as
|
|
3550
|
-
import { homedir as
|
|
3551
|
-
import { join as
|
|
4126
|
+
import { readdir as readdir8, stat as stat2 } from "node:fs/promises";
|
|
4127
|
+
import { homedir as homedir18 } from "node:os";
|
|
4128
|
+
import { join as join18 } from "node:path";
|
|
3552
4129
|
var msgs = {
|
|
3553
4130
|
en: {
|
|
3554
4131
|
groupConfig: "Configuration",
|
|
@@ -3604,13 +4181,13 @@ async function countFiles(dir, exts, cap = 1e3) {
|
|
|
3604
4181
|
for (; queue.length > 0 && count < cap; ) {
|
|
3605
4182
|
let current = queue.pop(), entries;
|
|
3606
4183
|
try {
|
|
3607
|
-
entries = await
|
|
4184
|
+
entries = await readdir8(current, { withFileTypes: !0 });
|
|
3608
4185
|
} catch {
|
|
3609
4186
|
continue;
|
|
3610
4187
|
}
|
|
3611
4188
|
for (let e of entries) {
|
|
3612
4189
|
if (count >= cap) break;
|
|
3613
|
-
let full =
|
|
4190
|
+
let full = join18(current, e.name);
|
|
3614
4191
|
e.isDirectory() ? queue.push(full) : exts.some((ext) => e.name.endsWith(ext)) && count++;
|
|
3615
4192
|
}
|
|
3616
4193
|
}
|
|
@@ -3639,20 +4216,20 @@ async function runDoctor(lang = "zh") {
|
|
|
3639
4216
|
}
|
|
3640
4217
|
target.lastSuccessfulUploadAt ? checks.push({ group: g2, name: `${prefix} ${s.lastSync}`, status: "ok", message: target.lastSuccessfulUploadAt }) : checks.push({ group: g2, name: `${prefix} ${s.lastSync}`, status: "warn", message: s.lastSyncNone });
|
|
3641
4218
|
}
|
|
3642
|
-
let g3 = s.groupTools, home =
|
|
3643
|
-
{ dir:
|
|
3644
|
-
{ dir:
|
|
3645
|
-
{ dir:
|
|
3646
|
-
{ dir:
|
|
3647
|
-
{ dir:
|
|
3648
|
-
{ dir:
|
|
3649
|
-
{ dir:
|
|
3650
|
-
{ dir:
|
|
3651
|
-
{ dir:
|
|
3652
|
-
{ dir:
|
|
3653
|
-
{ dir:
|
|
3654
|
-
{ dir:
|
|
3655
|
-
{ dir:
|
|
4219
|
+
let g3 = s.groupTools, home = homedir18(), tools = [
|
|
4220
|
+
{ dir: join18(home, ".claude", "projects"), label: "Claude Code", exts: [".jsonl"] },
|
|
4221
|
+
{ dir: join18(home, ".codex"), label: "Codex CLI", exts: [".jsonl"] },
|
|
4222
|
+
{ dir: join18(home, "Library", "Application Support", "Cursor", "User", "globalStorage"), label: "Cursor", exts: [".vscdb"] },
|
|
4223
|
+
{ dir: join18(home, ".copilot", "session-state"), label: "Copilot CLI", exts: [".jsonl"] },
|
|
4224
|
+
{ dir: join18(home, "Library", "Application Support", "Code", "logs"), label: "Copilot VS Code", exts: [".log"] },
|
|
4225
|
+
{ dir: join18(home, ".gemini", "tmp"), label: "Gemini CLI", exts: [".json"] },
|
|
4226
|
+
{ dir: join18(home, ".gemini", "antigravity"), label: "Antigravity", exts: [".json"] },
|
|
4227
|
+
{ dir: join18(home, ".qwen", "tmp"), label: "Qwen Code", exts: [".jsonl"] },
|
|
4228
|
+
{ dir: join18(home, ".kimi", "sessions"), label: "Kimi Code", exts: [".jsonl"] },
|
|
4229
|
+
{ dir: join18(home, ".local", "share", "amp", "threads"), label: "Amp", exts: [".json"] },
|
|
4230
|
+
{ dir: join18(home, ".factory", "sessions"), label: "Droid", exts: [".jsonl", ".json"] },
|
|
4231
|
+
{ dir: join18(home, ".local", "share", "opencode"), label: "OpenCode", exts: [".json"] },
|
|
4232
|
+
{ dir: join18(home, ".pi", "agent", "sessions"), label: "Pi", exts: [".jsonl"] }
|
|
3656
4233
|
];
|
|
3657
4234
|
for (let tool of tools) {
|
|
3658
4235
|
try {
|
|
@@ -3674,9 +4251,9 @@ async function runDoctor(lang = "zh") {
|
|
|
3674
4251
|
}
|
|
3675
4252
|
|
|
3676
4253
|
// src/project.ts
|
|
3677
|
-
import { open as
|
|
3678
|
-
import { basename as
|
|
3679
|
-
import { homedir as
|
|
4254
|
+
import { open as open4, readdir as readdir9, readFile as readFile17 } from "node:fs/promises";
|
|
4255
|
+
import { basename as basename11, join as join19 } from "node:path";
|
|
4256
|
+
import { homedir as homedir19 } from "node:os";
|
|
3680
4257
|
async function discoverProjects(projectAliases) {
|
|
3681
4258
|
let projectMap = /* @__PURE__ */ new Map();
|
|
3682
4259
|
function add(name, source) {
|
|
@@ -3720,20 +4297,20 @@ async function discoverClaudeProjects() {
|
|
|
3720
4297
|
for (let baseDir of getClaudeDirs()) {
|
|
3721
4298
|
let entries;
|
|
3722
4299
|
try {
|
|
3723
|
-
entries = await
|
|
4300
|
+
entries = await readdir9(baseDir, { withFileTypes: !0 });
|
|
3724
4301
|
} catch {
|
|
3725
4302
|
continue;
|
|
3726
4303
|
}
|
|
3727
4304
|
for (let entry of entries) {
|
|
3728
4305
|
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
3729
|
-
let projectDir =
|
|
4306
|
+
let projectDir = join19(baseDir, entry.name), name = await extractCwdFromFirstJsonl(projectDir);
|
|
3730
4307
|
name && name !== "unknown" && names.push(name);
|
|
3731
4308
|
}
|
|
3732
4309
|
}
|
|
3733
4310
|
return names;
|
|
3734
4311
|
}
|
|
3735
4312
|
async function discoverCodexProjects() {
|
|
3736
|
-
let sessionsDir =
|
|
4313
|
+
let sessionsDir = join19(homedir19(), ".codex", "sessions"), files = await walkJsonlFiles(sessionsDir), projects = /* @__PURE__ */ new Set();
|
|
3737
4314
|
for (let filePath of files) {
|
|
3738
4315
|
let name = await extractCwdFromSessionMeta(filePath);
|
|
3739
4316
|
name && name !== "unknown" && projects.add(name);
|
|
@@ -3743,7 +4320,7 @@ async function discoverCodexProjects() {
|
|
|
3743
4320
|
async function extractCwdFromSessionMeta(filePath) {
|
|
3744
4321
|
let fh;
|
|
3745
4322
|
try {
|
|
3746
|
-
fh = await
|
|
4323
|
+
fh = await open4(filePath, "r");
|
|
3747
4324
|
let buf = Buffer.alloc(4096), { bytesRead } = await fh.read(buf, 0, buf.length, 0);
|
|
3748
4325
|
if (bytesRead === 0) return;
|
|
3749
4326
|
let line = buf.subarray(0, bytesRead).toString("utf-8").split(`
|
|
@@ -3765,12 +4342,12 @@ async function walkFiles2(dir, ext) {
|
|
|
3765
4342
|
async function walk2(d) {
|
|
3766
4343
|
let entries;
|
|
3767
4344
|
try {
|
|
3768
|
-
entries = await
|
|
4345
|
+
entries = await readdir9(d, { withFileTypes: !0 });
|
|
3769
4346
|
} catch {
|
|
3770
4347
|
return;
|
|
3771
4348
|
}
|
|
3772
4349
|
for (let entry of entries) {
|
|
3773
|
-
let full =
|
|
4350
|
+
let full = join19(d, entry.name);
|
|
3774
4351
|
entry.isDirectory() ? await walk2(full) : entry.name.endsWith(ext) && result.push(full);
|
|
3775
4352
|
}
|
|
3776
4353
|
}
|
|
@@ -3781,7 +4358,7 @@ async function extractCwdFromFirstJsonl(dir) {
|
|
|
3781
4358
|
if (!jsonlPath) return;
|
|
3782
4359
|
let fh;
|
|
3783
4360
|
try {
|
|
3784
|
-
fh = await
|
|
4361
|
+
fh = await open4(jsonlPath, "r");
|
|
3785
4362
|
let buf = Buffer.alloc(32 * 1024), { bytesRead } = await fh.read(buf, 0, buf.length, 0);
|
|
3786
4363
|
if (bytesRead === 0) return;
|
|
3787
4364
|
let lines = buf.subarray(0, bytesRead).toString("utf-8").split(`
|
|
@@ -3807,27 +4384,27 @@ async function extractCwdFromFirstJsonl(dir) {
|
|
|
3807
4384
|
async function findFirstJsonl(dir) {
|
|
3808
4385
|
let entries;
|
|
3809
4386
|
try {
|
|
3810
|
-
entries = await
|
|
4387
|
+
entries = await readdir9(dir, { withFileTypes: !0 });
|
|
3811
4388
|
} catch {
|
|
3812
4389
|
return;
|
|
3813
4390
|
}
|
|
3814
4391
|
let topJsonl = entries.find((e) => e.isFile() && e.name.endsWith(".jsonl"));
|
|
3815
|
-
if (topJsonl) return
|
|
4392
|
+
if (topJsonl) return join19(dir, topJsonl.name);
|
|
3816
4393
|
for (let entry of entries)
|
|
3817
4394
|
if (!(!entry.isDirectory() || entry.name.startsWith(".")))
|
|
3818
4395
|
try {
|
|
3819
|
-
let sub = (await
|
|
3820
|
-
if (sub) return
|
|
4396
|
+
let sub = (await readdir9(join19(dir, entry.name))).find((f) => f.endsWith(".jsonl"));
|
|
4397
|
+
if (sub) return join19(dir, entry.name, sub);
|
|
3821
4398
|
} catch {
|
|
3822
4399
|
continue;
|
|
3823
4400
|
}
|
|
3824
4401
|
}
|
|
3825
4402
|
async function discoverCopilotProjects() {
|
|
3826
|
-
let dir =
|
|
4403
|
+
let dir = join19(homedir19(), ".copilot", "session-state"), files = await walkJsonlFiles(dir), projects = /* @__PURE__ */ new Set();
|
|
3827
4404
|
for (let filePath of files) {
|
|
3828
4405
|
let fh;
|
|
3829
4406
|
try {
|
|
3830
|
-
fh = await
|
|
4407
|
+
fh = await open4(filePath, "r");
|
|
3831
4408
|
let buf = Buffer.alloc(4096), { bytesRead } = await fh.read(buf, 0, buf.length, 0);
|
|
3832
4409
|
if (bytesRead === 0) continue;
|
|
3833
4410
|
let line = buf.subarray(0, bytesRead).toString("utf-8").split(`
|
|
@@ -3845,7 +4422,7 @@ async function discoverCopilotProjects() {
|
|
|
3845
4422
|
return [...projects];
|
|
3846
4423
|
}
|
|
3847
4424
|
async function discoverGeminiProjects() {
|
|
3848
|
-
let filePath =
|
|
4425
|
+
let filePath = join19(homedir19(), ".gemini", "projects.json");
|
|
3849
4426
|
try {
|
|
3850
4427
|
let raw = await readFile17(filePath, "utf-8"), projects = JSON.parse(raw)?.projects;
|
|
3851
4428
|
if (!projects || typeof projects != "object") return [];
|
|
@@ -3860,7 +4437,7 @@ async function discoverGeminiProjects() {
|
|
|
3860
4437
|
}
|
|
3861
4438
|
}
|
|
3862
4439
|
async function discoverCursorProjects() {
|
|
3863
|
-
let storagePath =
|
|
4440
|
+
let storagePath = join19(homedir19(), "Library", "Application Support", "Cursor", "User", "globalStorage", "storage.json");
|
|
3864
4441
|
try {
|
|
3865
4442
|
let raw = await readFile17(storagePath, "utf-8"), data = JSON.parse(raw), projects = /* @__PURE__ */ new Set(), workspaceUris = Object.keys(data.profileAssociations?.workspaces ?? {});
|
|
3866
4443
|
for (let uri of workspaceUris) {
|
|
@@ -3877,7 +4454,7 @@ async function discoverCursorProjects() {
|
|
|
3877
4454
|
}
|
|
3878
4455
|
}
|
|
3879
4456
|
async function discoverCopilotVscodeProjects() {
|
|
3880
|
-
let dir =
|
|
4457
|
+
let dir = join19(homedir19(), "Library", "Application Support", "Code", "logs"), files = (await walkFiles2(dir, ".log")).filter((filePath) => filePath.endsWith("GitHub Copilot Chat.log")), projects = /* @__PURE__ */ new Set();
|
|
3881
4458
|
for (let filePath of files) {
|
|
3882
4459
|
let content;
|
|
3883
4460
|
try {
|
|
@@ -3894,16 +4471,16 @@ async function discoverCopilotVscodeProjects() {
|
|
|
3894
4471
|
return [...projects];
|
|
3895
4472
|
}
|
|
3896
4473
|
async function discoverAntigravityProjects() {
|
|
3897
|
-
let dir =
|
|
4474
|
+
let dir = join19(homedir19(), ".gemini", "antigravity", "knowledge"), entries;
|
|
3898
4475
|
try {
|
|
3899
|
-
entries = await
|
|
4476
|
+
entries = await readdir9(dir, { withFileTypes: !0 });
|
|
3900
4477
|
} catch {
|
|
3901
4478
|
return [];
|
|
3902
4479
|
}
|
|
3903
4480
|
let projects = /* @__PURE__ */ new Set();
|
|
3904
4481
|
for (let entry of entries) {
|
|
3905
4482
|
if (!entry.isDirectory()) continue;
|
|
3906
|
-
let metadataPath =
|
|
4483
|
+
let metadataPath = join19(dir, entry.name, "metadata.json");
|
|
3907
4484
|
try {
|
|
3908
4485
|
let raw = await readFile17(metadataPath, "utf-8"), name = JSON.parse(raw).title?.trim() || entry.name.trim();
|
|
3909
4486
|
name && name !== "unknown" && projects.add(name);
|
|
@@ -3916,7 +4493,7 @@ async function discoverAntigravityProjects() {
|
|
|
3916
4493
|
function nameFromFileUri(raw) {
|
|
3917
4494
|
let path = pathFromFileUri(raw);
|
|
3918
4495
|
if (!path) return;
|
|
3919
|
-
let name =
|
|
4496
|
+
let name = basename11(path);
|
|
3920
4497
|
return name && name !== "unknown" ? name : void 0;
|
|
3921
4498
|
}
|
|
3922
4499
|
function pathFromFileUri(raw) {
|
|
@@ -3935,11 +4512,11 @@ function pathFromFileUri(raw) {
|
|
|
3935
4512
|
function getClaudeDirs() {
|
|
3936
4513
|
let envVar = process.env.CLAUDE_CONFIG_DIR?.trim();
|
|
3937
4514
|
if (envVar)
|
|
3938
|
-
return envVar.split(",").map((p) => p.trim()).filter(Boolean).map((p) =>
|
|
3939
|
-
let home =
|
|
4515
|
+
return envVar.split(",").map((p) => p.trim()).filter(Boolean).map((p) => join19(p, "projects"));
|
|
4516
|
+
let home = homedir19();
|
|
3940
4517
|
return [
|
|
3941
|
-
|
|
3942
|
-
|
|
4518
|
+
join19(home, ".config", "claude", "projects"),
|
|
4519
|
+
join19(home, ".claude", "projects")
|
|
3943
4520
|
];
|
|
3944
4521
|
}
|
|
3945
4522
|
|
|
@@ -3947,8 +4524,11 @@ function getClaudeDirs() {
|
|
|
3947
4524
|
import { createHash } from "node:crypto";
|
|
3948
4525
|
var DEFAULT_VISIBILITY = "masked";
|
|
3949
4526
|
function applyPrivacy(breakdowns, visibility) {
|
|
4527
|
+
return applyProjectPrivacy(breakdowns, visibility);
|
|
4528
|
+
}
|
|
4529
|
+
function applyProjectPrivacy(items, visibility) {
|
|
3950
4530
|
let mode = visibility ?? DEFAULT_VISIBILITY;
|
|
3951
|
-
return
|
|
4531
|
+
return items.map((item) => transformOne(item, mode));
|
|
3952
4532
|
}
|
|
3953
4533
|
function transformOne(b, mode) {
|
|
3954
4534
|
let original = b.project ?? "", display = b.projectDisplay ?? deriveBasename(original);
|
|
@@ -3982,9 +4562,9 @@ function shortHash(p) {
|
|
|
3982
4562
|
|
|
3983
4563
|
// src/pricing.ts
|
|
3984
4564
|
import { mkdir as mkdir3, readFile as readFile18, writeFile as writeFile3 } from "node:fs/promises";
|
|
3985
|
-
import { homedir as
|
|
3986
|
-
import { join as
|
|
3987
|
-
var CACHE_DIR =
|
|
4565
|
+
import { homedir as homedir20 } from "node:os";
|
|
4566
|
+
import { join as join20 } from "node:path";
|
|
4567
|
+
var CACHE_DIR = join20(homedir20(), ".aiusage"), CACHE_PATH = join20(CACHE_DIR, "pricing-cache.json"), DEFAULT_CACHE_TTL_HOURS = 24, FETCH_TIMEOUT_MS = 5e3, NPM_CDN_URLS = [
|
|
3988
4568
|
"https://cdn.jsdelivr.net/npm/@aiusage/cli@latest/pricing-catalog.json",
|
|
3989
4569
|
"https://unpkg.com/@aiusage/cli@latest/pricing-catalog.json",
|
|
3990
4570
|
"https://cdn.jsdelivr.net/npm/@aiusage/pricing@latest/catalog.json",
|
|
@@ -4094,6 +4674,10 @@ await (async () => {
|
|
|
4094
4674
|
let parsed = parseArgs(argv.slice(1));
|
|
4095
4675
|
if (parsed.flags.help) return helpForSubcommand("report");
|
|
4096
4676
|
await runReport(parsed.flags, parsed.positionals);
|
|
4677
|
+
} else if (command === "activity") {
|
|
4678
|
+
let parsed = parseArgs(argv.slice(1));
|
|
4679
|
+
if (parsed.flags.help) return helpForSubcommand("activity");
|
|
4680
|
+
await runActivity(parsed.flags, parsed.positionals);
|
|
4097
4681
|
} else if (command === "health") {
|
|
4098
4682
|
let parsed = parseArgs(argv.slice(1));
|
|
4099
4683
|
if (parsed.flags.help) return helpForSubcommand("health");
|
|
@@ -4212,10 +4796,10 @@ function printScanResult(result, zh2) {
|
|
|
4212
4796
|
for (let [provider, breakdowns] of byProvider) {
|
|
4213
4797
|
console.log(`\u2500\u2500 ${provider} \u2500\u2500`);
|
|
4214
4798
|
for (let b of breakdowns.sort((a, c) => c.inputTokens - a.inputTokens))
|
|
4215
|
-
console.log(` ${b.model} | ${b.projectAlias ?? b.projectDisplay ?? b.project}`), console.log(` \u4E8B\u4EF6: ${b.eventCount} \u8F93\u5165: ${
|
|
4799
|
+
console.log(` ${b.model} | ${b.projectAlias ?? b.projectDisplay ?? b.project}`), console.log(` \u4E8B\u4EF6: ${b.eventCount} \u8F93\u5165: ${fmt2(b.inputTokens)} \u7F13\u5B58\u8BFB: ${fmt2(b.cachedInputTokens)} \u7F13\u5B58\u5199: ${fmt2(b.cacheWriteTokens)} \u8F93\u51FA: ${fmt2(b.outputTokens)} \u63A8\u7406: ${fmt2(b.reasoningOutputTokens)}`);
|
|
4216
4800
|
console.log();
|
|
4217
4801
|
}
|
|
4218
|
-
console.log("\u2500\u2500 \u5408\u8BA1 \u2500\u2500"), console.log(` \u4E8B\u4EF6: ${result.totals.eventCount} \u8F93\u5165: ${
|
|
4802
|
+
console.log("\u2500\u2500 \u5408\u8BA1 \u2500\u2500"), console.log(` \u4E8B\u4EF6: ${result.totals.eventCount} \u8F93\u5165: ${fmt2(result.totals.inputTokens)} \u7F13\u5B58\u8BFB: ${fmt2(result.totals.cachedInputTokens)} \u7F13\u5B58\u5199: ${fmt2(result.totals.cacheWriteTokens)} \u8F93\u51FA: ${fmt2(result.totals.outputTokens)} \u63A8\u7406: ${fmt2(result.totals.reasoningOutputTokens)}`), console.log();
|
|
4219
4803
|
}
|
|
4220
4804
|
async function runReport(flags, positionals = []) {
|
|
4221
4805
|
let config = await readConfig();
|
|
@@ -4236,7 +4820,21 @@ async function runReport(flags, positionals = []) {
|
|
|
4236
4820
|
let lang = resolveGlobalLang(flags, config), emoji = flags["no-emoji"] === !0 ? !1 : config.emoji ?? !0, detail = flags.detail === !0;
|
|
4237
4821
|
console.log(renderReport(report, { lang, emoji, detail }));
|
|
4238
4822
|
}
|
|
4239
|
-
function
|
|
4823
|
+
async function runActivity(flags, positionals = []) {
|
|
4824
|
+
let config = await readConfig();
|
|
4825
|
+
assertNoPositionals("activity", positionals, config.lang === "zh");
|
|
4826
|
+
let { dates, range } = resolveDateParams(flags, config), report = await buildActivityReport(range, {
|
|
4827
|
+
projectAliases: config.projectAliases,
|
|
4828
|
+
dates
|
|
4829
|
+
});
|
|
4830
|
+
if (flags.json) {
|
|
4831
|
+
console.log(JSON.stringify(report, null, 2));
|
|
4832
|
+
return;
|
|
4833
|
+
}
|
|
4834
|
+
let emoji = flags["no-emoji"] === !0 ? !1 : config.emoji ?? !0, detail = flags.detail === !0;
|
|
4835
|
+
console.log(renderActivityReport(report, { emoji, detail }));
|
|
4836
|
+
}
|
|
4837
|
+
function fmt2(n) {
|
|
4240
4838
|
return n.toLocaleString("en-US");
|
|
4241
4839
|
}
|
|
4242
4840
|
async function runHealth(flags) {
|
|
@@ -4272,7 +4870,7 @@ async function runEnroll(flags) {
|
|
|
4272
4870
|
}, null, 2));
|
|
4273
4871
|
}
|
|
4274
4872
|
function prompt(question) {
|
|
4275
|
-
let rl =
|
|
4873
|
+
let rl = createInterface4({ input: process.stdin, output: process.stdout });
|
|
4276
4874
|
return new Promise((resolve4) => {
|
|
4277
4875
|
rl.question(question, (answer) => {
|
|
4278
4876
|
rl.close(), resolve4(answer.trim());
|
|
@@ -4289,7 +4887,13 @@ async function runSync(flags, positionals = []) {
|
|
|
4289
4887
|
if (!targetDates)
|
|
4290
4888
|
throw new Error("sync --range all \u9700\u8981\u660E\u786E\u65E5\u671F\u8303\u56F4\uFF0C\u8BF7\u6539\u7528 --from YYYY-MM-DD --to YYYY-MM-DD");
|
|
4291
4889
|
console.log(`\u626B\u63CF ${targetDates.length} \u5929 (${targetDates[0]} ~ ${targetDates[targetDates.length - 1]}) ...`);
|
|
4292
|
-
let results
|
|
4890
|
+
let [results, activityReport] = await Promise.all([
|
|
4891
|
+
scanDates(targetDates, { projectAliases: config.projectAliases }),
|
|
4892
|
+
buildActivityReport("all", { dates: targetDates, projectAliases: config.projectAliases })
|
|
4893
|
+
]), visibility = config.privacy?.projectVisibility, resultsByDate = new Map(results.map((result) => [result.usageDate, result])), activityByDate = buildActivityPayloadByDate(activityReport.items, visibility), allDays = targetDates.map((usageDate) => {
|
|
4894
|
+
let breakdowns = applyPrivacy(resultsByDate.get(usageDate)?.breakdowns ?? [], visibility), activity = activityByDate.get(usageDate);
|
|
4895
|
+
return { usageDate, breakdowns, activity };
|
|
4896
|
+
}).filter((day) => day.breakdowns.length > 0 || (day.activity?.items.length ?? 0) > 0);
|
|
4293
4897
|
if (allDays.length === 0) {
|
|
4294
4898
|
console.log("\u6CA1\u6709\u53EF\u4E0A\u4F20\u7684\u6570\u636E\u3002");
|
|
4295
4899
|
return;
|
|
@@ -4324,6 +4928,25 @@ async function runSync(flags, positionals = []) {
|
|
|
4324
4928
|
results: uploadResults
|
|
4325
4929
|
}, null, 2));
|
|
4326
4930
|
}
|
|
4931
|
+
function buildActivityPayloadByDate(items, visibility) {
|
|
4932
|
+
let map = /* @__PURE__ */ new Map(), sanitized = applyProjectPrivacy(items, visibility);
|
|
4933
|
+
for (let item of sanitized) {
|
|
4934
|
+
let day = map.get(item.usageDate) ?? { items: [] };
|
|
4935
|
+
day.items.push({
|
|
4936
|
+
provider: item.provider,
|
|
4937
|
+
product: item.product,
|
|
4938
|
+
source: item.source,
|
|
4939
|
+
project: item.project,
|
|
4940
|
+
projectDisplay: item.projectDisplay,
|
|
4941
|
+
projectAlias: item.projectAlias,
|
|
4942
|
+
kind: item.kind,
|
|
4943
|
+
name: item.name,
|
|
4944
|
+
count: item.count,
|
|
4945
|
+
confidence: item.confidence
|
|
4946
|
+
}), map.set(item.usageDate, day);
|
|
4947
|
+
}
|
|
4948
|
+
return map;
|
|
4949
|
+
}
|
|
4327
4950
|
async function runImport(flags, positionals = []) {
|
|
4328
4951
|
let config = await readConfig(), targetName = resolveOptionalString(flags.target, void 0), allTargets = config.targets ?? [];
|
|
4329
4952
|
if (allTargets.length === 0) throw new Error("\u672A\u914D\u7F6E\u4EFB\u4F55\u4E0A\u62A5\u76EE\u6807\uFF0C\u8BF7\u5148\u6267\u884C aiusage enroll");
|
|
@@ -4505,6 +5128,7 @@ function printHelp(zh2 = !1) {
|
|
|
4505
5128
|
let cmds = zh2 ? [
|
|
4506
5129
|
["scan [--date YYYY-MM-DD|--today|--range 7d|1m|3m] [--json]", "\u626B\u63CF\u7528\u91CF\u660E\u7EC6"],
|
|
4507
5130
|
["report [--today] [--range 7d|1m|3m|all] [--detail] [--json]", "\u672C\u5730\u7528\u91CF\u62A5\u544A"],
|
|
5131
|
+
["activity [--today] [--range 7d|1m|3m|all] [--detail] [--json]", "\u672C\u5730\u4EA4\u4E92\u6307\u6807"],
|
|
4508
5132
|
["sync [--today] [--range 7d|1m|3m]", "\u4E0A\u4F20\u7528\u91CF\u5230\u670D\u52A1\u7AEF"],
|
|
4509
5133
|
["scan/report/sync --from YYYY-MM-DD [--to YYYY-MM-DD]", "\u6307\u5B9A\u65E5\u671F\u8303\u56F4\uFF08--start/--end \u540C\u4E49\uFF09"],
|
|
4510
5134
|
["project [list|alias]", "\u9879\u76EE\u7BA1\u7406\u4E0E\u522B\u540D\u8BBE\u7F6E"],
|
|
@@ -4518,6 +5142,7 @@ function printHelp(zh2 = !1) {
|
|
|
4518
5142
|
] : [
|
|
4519
5143
|
["scan [--date YYYY-MM-DD|--today|--range 7d|1m|3m] [--json]", "Scan usage breakdown"],
|
|
4520
5144
|
["report [--today] [--range 7d|1m|3m|all] [--detail] [--json]", "Local usage report"],
|
|
5145
|
+
["activity [--today] [--range 7d|1m|3m|all] [--detail] [--json]", "Local interaction metrics"],
|
|
4521
5146
|
["sync [--today] [--range 7d|1m|3m]", "Upload usage to server"],
|
|
4522
5147
|
["scan/report/sync --from YYYY-MM-DD [--to YYYY-MM-DD]", "Date range (--start/--end aliases)"],
|
|
4523
5148
|
["project [list|alias]", "Project management & aliases"],
|
|
@@ -4540,6 +5165,7 @@ function printUsageHint(zh2 = !1) {
|
|
|
4540
5165
|
let cmds = zh2 ? [
|
|
4541
5166
|
["scan [--date YYYY-MM-DD|--range 1m]", "\u626B\u63CF\u7528\u91CF\u660E\u7EC6"],
|
|
4542
5167
|
["report [--today] [--range 7d|1m|3m|all]", "\u672C\u5730\u7528\u91CF\u62A5\u544A"],
|
|
5168
|
+
["activity [--range 7d|1m|3m|all]", "\u672C\u5730\u4EA4\u4E92\u6307\u6807"],
|
|
4543
5169
|
["sync [--today] [--range 7d|1m|3m]", "\u4E0A\u4F20\u7528\u91CF\u5230\u670D\u52A1\u7AEF"],
|
|
4544
5170
|
["project [list|alias]", "\u9879\u76EE\u7BA1\u7406\u4E0E\u522B\u540D\u8BBE\u7F6E"],
|
|
4545
5171
|
["pricing [status|update]", "\u67E5\u770B/\u66F4\u65B0\u5B9A\u4EF7\u76EE\u5F55"],
|
|
@@ -4549,6 +5175,7 @@ function printUsageHint(zh2 = !1) {
|
|
|
4549
5175
|
] : [
|
|
4550
5176
|
["scan [--date YYYY-MM-DD|--range 1m]", "Scan usage breakdown"],
|
|
4551
5177
|
["report [--today] [--range 7d|1m|3m|all]", "Local usage report"],
|
|
5178
|
+
["activity [--range 7d|1m|3m|all]", "Local interaction metrics"],
|
|
4552
5179
|
["sync [--today] [--range 7d|1m|3m]", "Upload usage to server"],
|
|
4553
5180
|
["project [list|alias]", "Project management & aliases"],
|
|
4554
5181
|
["pricing [status|update]", "Pricing catalog management"],
|