@aiusage/cli 0.4.2 → 0.4.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/dist/cli.js +42 -17
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1826,7 +1826,7 @@ function escapeXml(value) {
|
|
|
1826
1826
|
}
|
|
1827
1827
|
|
|
1828
1828
|
// src/doctor.ts
|
|
1829
|
-
import { stat as stat2 } from "node:fs/promises";
|
|
1829
|
+
import { readdir as readdir6, stat as stat2 } from "node:fs/promises";
|
|
1830
1830
|
import { homedir as homedir14 } from "node:os";
|
|
1831
1831
|
import { join as join14 } from "node:path";
|
|
1832
1832
|
var msgs = {
|
|
@@ -1842,7 +1842,9 @@ var msgs = {
|
|
|
1842
1842
|
server: "Server",
|
|
1843
1843
|
lastSync: "Last sync",
|
|
1844
1844
|
lastSyncNone: "No record",
|
|
1845
|
-
|
|
1845
|
+
notInstalled: "Not installed",
|
|
1846
|
+
installedNoData: "Installed, no usage data yet",
|
|
1847
|
+
hasData: (n) => `${n} session${n > 1 ? "s" : ""} found`,
|
|
1846
1848
|
schedule: "Schedule",
|
|
1847
1849
|
scheduleEvery: "every",
|
|
1848
1850
|
scheduleEnabled: "Enabled",
|
|
@@ -1860,13 +1862,32 @@ var msgs = {
|
|
|
1860
1862
|
server: "\u670D\u52A1\u7AEF",
|
|
1861
1863
|
lastSync: "\u4E0A\u6B21\u540C\u6B65",
|
|
1862
1864
|
lastSyncNone: "\u6682\u65E0\u8BB0\u5F55",
|
|
1863
|
-
|
|
1865
|
+
notInstalled: "\u672A\u5B89\u88C5",
|
|
1866
|
+
installedNoData: "\u5DF2\u5B89\u88C5\uFF0C\u6682\u65E0\u4F7F\u7528\u6570\u636E",
|
|
1867
|
+
hasData: (n) => `\u53D1\u73B0 ${n} \u4E2A\u4F1A\u8BDD`,
|
|
1864
1868
|
schedule: "\u5B9A\u65F6\u540C\u6B65",
|
|
1865
1869
|
scheduleEvery: "\u6BCF",
|
|
1866
1870
|
scheduleEnabled: "\u5DF2\u542F\u7528",
|
|
1867
1871
|
scheduleOff: "\u672A\u542F\u7528\uFF0C\u53EF\u6267\u884C aiusage schedule on"
|
|
1868
1872
|
}
|
|
1869
1873
|
};
|
|
1874
|
+
async function countFiles(dir, exts, cap = 1e3) {
|
|
1875
|
+
let count = 0, queue = [dir];
|
|
1876
|
+
for (; queue.length > 0 && count < cap; ) {
|
|
1877
|
+
let current = queue.pop(), entries;
|
|
1878
|
+
try {
|
|
1879
|
+
entries = await readdir6(current, { withFileTypes: !0 });
|
|
1880
|
+
} catch {
|
|
1881
|
+
continue;
|
|
1882
|
+
}
|
|
1883
|
+
for (let e of entries) {
|
|
1884
|
+
if (count >= cap) break;
|
|
1885
|
+
let full = join14(current, e.name);
|
|
1886
|
+
e.isDirectory() ? queue.push(full) : exts.some((ext) => e.name.endsWith(ext)) && count++;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
return count;
|
|
1890
|
+
}
|
|
1870
1891
|
async function runDoctor(lang = "zh") {
|
|
1871
1892
|
let s = msgs[lang], checks = [], config = await readConfig(), configPath = getConfigPath();
|
|
1872
1893
|
try {
|
|
@@ -1890,24 +1911,28 @@ async function runDoctor(lang = "zh") {
|
|
|
1890
1911
|
}
|
|
1891
1912
|
target.lastSuccessfulUploadAt ? checks.push({ name: `${prefix} ${s.lastSync}`, status: "ok", message: target.lastSuccessfulUploadAt }) : checks.push({ name: `${prefix} ${s.lastSync}`, status: "warn", message: s.lastSyncNone });
|
|
1892
1913
|
}
|
|
1893
|
-
let home = homedir14(),
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1914
|
+
let home = homedir14(), tools = [
|
|
1915
|
+
{ dir: join14(home, ".claude", "projects"), label: "Claude Code", exts: [".jsonl"] },
|
|
1916
|
+
{ dir: join14(home, ".codex"), label: "Codex CLI", exts: [".jsonl"] },
|
|
1917
|
+
{ dir: join14(home, ".copilot", "session-state"), label: "Copilot CLI", exts: [".jsonl"] },
|
|
1918
|
+
{ dir: join14(home, ".gemini", "tmp"), label: "Gemini CLI", exts: [".json"] },
|
|
1919
|
+
{ dir: join14(home, ".qwen", "tmp"), label: "Qwen Code", exts: [".jsonl"] },
|
|
1920
|
+
{ dir: join14(home, ".kimi", "sessions"), label: "Kimi Code", exts: [".jsonl"] },
|
|
1921
|
+
{ dir: join14(home, ".local", "share", "amp", "threads"), label: "Amp", exts: [".json"] },
|
|
1922
|
+
{ dir: join14(home, ".factory", "sessions"), label: "Droid", exts: [".jsonl", ".json"] },
|
|
1923
|
+
{ dir: join14(home, ".local", "share", "opencode"), label: "OpenCode", exts: [".json"] },
|
|
1924
|
+
{ dir: join14(home, ".pi", "agent", "sessions"), label: "Pi", exts: [".jsonl"] }
|
|
1904
1925
|
];
|
|
1905
|
-
for (let
|
|
1926
|
+
for (let tool of tools) {
|
|
1906
1927
|
try {
|
|
1907
|
-
await stat2(
|
|
1928
|
+
await stat2(tool.dir);
|
|
1908
1929
|
} catch {
|
|
1909
|
-
checks.push({ name: label, status: "warn", message: s.
|
|
1930
|
+
checks.push({ name: tool.label, status: "warn", message: s.notInstalled });
|
|
1931
|
+
continue;
|
|
1910
1932
|
}
|
|
1933
|
+
let n = await countFiles(tool.dir, tool.exts);
|
|
1934
|
+
n > 0 ? checks.push({ name: tool.label, status: "ok", message: s.hasData(n) }) : checks.push({ name: tool.label, status: "warn", message: s.installedNoData });
|
|
1935
|
+
}
|
|
1911
1936
|
let schedule = await getScheduleStatus();
|
|
1912
1937
|
return schedule.enabled ? checks.push({
|
|
1913
1938
|
name: s.schedule,
|