@aiusage/cli 1.8.0 → 1.8.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 +23 -11
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4792,7 +4792,7 @@ function fmtDateShort(dateStr) {
|
|
|
4792
4792
|
}
|
|
4793
4793
|
|
|
4794
4794
|
// src/activity.ts
|
|
4795
|
-
import { open, readdir as readdir7 } from "node:fs/promises";
|
|
4795
|
+
import { open, readdir as readdir7, stat as stat4 } from "node:fs/promises";
|
|
4796
4796
|
import { createInterface as createInterface3 } from "node:readline";
|
|
4797
4797
|
import { homedir as homedir16 } from "node:os";
|
|
4798
4798
|
import { basename as basename12, join as join17 } from "node:path";
|
|
@@ -4896,7 +4896,7 @@ function renderActivityReport(report, opts) {
|
|
|
4896
4896
|
`);
|
|
4897
4897
|
}
|
|
4898
4898
|
async function scanCodexActivity(targetDates, options) {
|
|
4899
|
-
let baseDir = options.codexDir ?? join17(homedir16(), ".codex"), acc = createAccumulator(targetDates, options.projectAliases), files = await collectCodexSessionFiles2(baseDir);
|
|
4899
|
+
let baseDir = options.codexDir ?? join17(homedir16(), ".codex"), acc = createAccumulator(targetDates, options.projectAliases), files = await keepRecentFiles(await collectCodexSessionFiles2(baseDir), targetDates, (path) => path);
|
|
4900
4900
|
return acc.stats.filesScanned = files.length, await runWithConcurrency(files, FILE_CONCURRENCY3, async (filePath) => {
|
|
4901
4901
|
await processCodexFile2(filePath, acc);
|
|
4902
4902
|
}), finalizeActivity(acc);
|
|
@@ -5086,7 +5086,8 @@ async function scanClaudeActivity(targetDates, options) {
|
|
|
5086
5086
|
for (let filePath of jsonlFiles) fileJobs.push({ filePath, projectFields: fields });
|
|
5087
5087
|
}
|
|
5088
5088
|
}
|
|
5089
|
-
|
|
5089
|
+
let recentJobs = await keepRecentFiles(fileJobs, targetDates, (job) => job.filePath);
|
|
5090
|
+
return acc.stats.filesScanned = recentJobs.length, await runWithConcurrency(recentJobs, FILE_CONCURRENCY3, async (job) => {
|
|
5090
5091
|
await processClaudeFile(job.filePath, job.projectFields, acc);
|
|
5091
5092
|
}), finalizeActivity(acc);
|
|
5092
5093
|
}
|
|
@@ -5228,6 +5229,17 @@ function addUserMessage(acc, input) {
|
|
|
5228
5229
|
amount: input.chars
|
|
5229
5230
|
}));
|
|
5230
5231
|
}
|
|
5232
|
+
async function keepRecentFiles(items, targetDates, pathOf) {
|
|
5233
|
+
if (!targetDates?.size) return items;
|
|
5234
|
+
let earliest = [...targetDates].sort()[0], cutoff = Date.parse(`${earliest}T00:00:00Z`) - 1440 * 60 * 1e3, keep = await Promise.all(items.map(async (item) => {
|
|
5235
|
+
try {
|
|
5236
|
+
return (await stat4(pathOf(item))).mtimeMs >= cutoff;
|
|
5237
|
+
} catch {
|
|
5238
|
+
return !1;
|
|
5239
|
+
}
|
|
5240
|
+
}));
|
|
5241
|
+
return items.filter((_, i) => keep[i]);
|
|
5242
|
+
}
|
|
5231
5243
|
function acceptsDate(acc, usageDate) {
|
|
5232
5244
|
return !acc.targetDates || acc.targetDates.has(usageDate);
|
|
5233
5245
|
}
|
|
@@ -5663,7 +5675,7 @@ async function requestJson(url, init) {
|
|
|
5663
5675
|
|
|
5664
5676
|
// src/schedule.ts
|
|
5665
5677
|
import { realpathSync } from "node:fs";
|
|
5666
|
-
import { mkdir as mkdir2, readFile as readFile16, stat as
|
|
5678
|
+
import { mkdir as mkdir2, readFile as readFile16, stat as stat5, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
5667
5679
|
import { execFile as execFile2 } from "node:child_process";
|
|
5668
5680
|
import { promisify } from "node:util";
|
|
5669
5681
|
import { homedir as homedir18, platform, tmpdir as tmpdir2 } from "node:os";
|
|
@@ -5764,7 +5776,7 @@ async function disableLaunchd() {
|
|
|
5764
5776
|
}
|
|
5765
5777
|
async function getLaunchdStatus() {
|
|
5766
5778
|
try {
|
|
5767
|
-
await
|
|
5779
|
+
await stat5(PLIST_PATH);
|
|
5768
5780
|
} catch {
|
|
5769
5781
|
return { enabled: !1 };
|
|
5770
5782
|
}
|
|
@@ -5874,7 +5886,7 @@ function escapeXml(value) {
|
|
|
5874
5886
|
}
|
|
5875
5887
|
|
|
5876
5888
|
// src/doctor.ts
|
|
5877
|
-
import { readdir as readdir8, stat as
|
|
5889
|
+
import { readdir as readdir8, stat as stat6 } from "node:fs/promises";
|
|
5878
5890
|
import { homedir as homedir19 } from "node:os";
|
|
5879
5891
|
import { join as join20 } from "node:path";
|
|
5880
5892
|
var msgs = {
|
|
@@ -5953,7 +5965,7 @@ async function countFiles(dir, exts, cap = 1e3) {
|
|
|
5953
5965
|
async function runDoctor(lang = "zh") {
|
|
5954
5966
|
let s = msgs[lang], checks = [], config = await readConfig(), g1 = s.groupConfig, configPath = getConfigPath();
|
|
5955
5967
|
try {
|
|
5956
|
-
await
|
|
5968
|
+
await stat6(configPath), checks.push({ group: g1, name: s.config, status: "ok", message: configPath });
|
|
5957
5969
|
} catch {
|
|
5958
5970
|
checks.push({ group: g1, name: s.config, status: "fail", message: s.configMissing });
|
|
5959
5971
|
}
|
|
@@ -6000,7 +6012,7 @@ async function runDoctor(lang = "zh") {
|
|
|
6000
6012
|
let installed = !1, installedDirs = 0, n = 0;
|
|
6001
6013
|
for (let dir of tool.dirs)
|
|
6002
6014
|
try {
|
|
6003
|
-
await
|
|
6015
|
+
await stat6(dir), installed = !0, installedDirs++, n += await countFiles(dir, tool.exts);
|
|
6004
6016
|
} catch {
|
|
6005
6017
|
}
|
|
6006
6018
|
if (!installed) {
|
|
@@ -6019,7 +6031,7 @@ async function runDoctor(lang = "zh") {
|
|
|
6019
6031
|
}), openCodeLegacyCount = await countFiles(openCodeSources.legacyDir, [".json"]), openCodeInstalled = openCodeSources.dbPaths.length > 0 || openCodeLegacyCount > 0;
|
|
6020
6032
|
if (!openCodeInstalled)
|
|
6021
6033
|
try {
|
|
6022
|
-
await
|
|
6034
|
+
await stat6(openCodeSources.dataDir), openCodeInstalled = !0;
|
|
6023
6035
|
} catch {
|
|
6024
6036
|
}
|
|
6025
6037
|
openCodeInstalled ? openCodeSources.dbPaths.length === 0 && openCodeLegacyCount === 0 ? checks.push({ group: g3, name: "OpenCode", status: "warn", message: s.installedNoData }) : openCodeSources.dbPaths.length > 0 && await detectOpenCodeSqliteRuntime() === "unavailable" ? checks.push({
|
|
@@ -6508,7 +6520,7 @@ function assertPricingCatalog(value) {
|
|
|
6508
6520
|
import { execFile as execFile3 } from "node:child_process";
|
|
6509
6521
|
import { createHash as createHash2 } from "node:crypto";
|
|
6510
6522
|
import { existsSync as existsSync2 } from "node:fs";
|
|
6511
|
-
import { mkdir as mkdir4, open as open3, readdir as readdir10, rename, stat as
|
|
6523
|
+
import { mkdir as mkdir4, open as open3, readdir as readdir10, rename, stat as stat7, writeFile as writeFile4 } from "node:fs/promises";
|
|
6512
6524
|
import { createServer } from "node:net";
|
|
6513
6525
|
import { homedir as homedir22 } from "node:os";
|
|
6514
6526
|
import { join as join23 } from "node:path";
|
|
@@ -6829,7 +6841,7 @@ async function findCompletionLogs(dir) {
|
|
|
6829
6841
|
if (entry.isDirectory()) files.push(...await findCompletionLogs(path));
|
|
6830
6842
|
else if (entry.name === "completion.log" && path.includes("trae.ai-code-completion"))
|
|
6831
6843
|
try {
|
|
6832
|
-
files.push({ path, mtimeMs: (await
|
|
6844
|
+
files.push({ path, mtimeMs: (await stat7(path)).mtimeMs });
|
|
6833
6845
|
} catch {
|
|
6834
6846
|
}
|
|
6835
6847
|
}
|