@aiusage/cli 0.4.4 → 0.4.5

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.
Files changed (2) hide show
  1. package/dist/cli.js +27 -17
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1892,6 +1892,10 @@ import { homedir as homedir14 } from "node:os";
1892
1892
  import { join as join14 } from "node:path";
1893
1893
  var msgs = {
1894
1894
  en: {
1895
+ groupConfig: "Configuration",
1896
+ groupSync: "Sync Targets",
1897
+ groupTools: "Tools",
1898
+ groupSchedule: "Schedule",
1895
1899
  config: "Config",
1896
1900
  configMissing: "Not found, run aiusage init first",
1897
1901
  deviceId: "Device ID",
@@ -1912,6 +1916,10 @@ var msgs = {
1912
1916
  scheduleOff: "Not enabled, run aiusage schedule on"
1913
1917
  },
1914
1918
  zh: {
1919
+ groupConfig: "\u57FA\u672C\u914D\u7F6E",
1920
+ groupSync: "\u540C\u6B65\u76EE\u6807",
1921
+ groupTools: "\u5DE5\u5177\u68C0\u6D4B",
1922
+ groupSchedule: "\u5B9A\u65F6\u4EFB\u52A1",
1915
1923
  config: "\u914D\u7F6E\u6587\u4EF6",
1916
1924
  configMissing: "\u672A\u627E\u5230\uFF0C\u8BF7\u5148\u6267\u884C aiusage init",
1917
1925
  deviceId: "\u8BBE\u5907 ID",
@@ -1950,29 +1958,29 @@ async function countFiles(dir, exts, cap = 1e3) {
1950
1958
  return count;
1951
1959
  }
1952
1960
  async function runDoctor(lang = "zh") {
1953
- let s = msgs[lang], checks = [], config = await readConfig(), configPath = getConfigPath();
1961
+ let s = msgs[lang], checks = [], config = await readConfig(), g1 = s.groupConfig, configPath = getConfigPath();
1954
1962
  try {
1955
- await stat2(configPath), checks.push({ name: s.config, status: "ok", message: configPath });
1963
+ await stat2(configPath), checks.push({ group: g1, name: s.config, status: "ok", message: configPath });
1956
1964
  } catch {
1957
- checks.push({ name: s.config, status: "fail", message: s.configMissing });
1965
+ checks.push({ group: g1, name: s.config, status: "fail", message: s.configMissing });
1958
1966
  }
1959
- config.deviceId ? checks.push({ name: s.deviceId, status: "ok", message: config.deviceId }) : checks.push({ name: s.deviceId, status: "warn", message: s.deviceIdMissing });
1960
- let targets = config.targets ?? [];
1967
+ config.deviceId ? checks.push({ group: g1, name: s.deviceId, status: "ok", message: config.deviceId }) : checks.push({ group: g1, name: s.deviceId, status: "warn", message: s.deviceIdMissing });
1968
+ let g2 = s.groupSync, targets = config.targets ?? [];
1961
1969
  if (targets.length === 0)
1962
- checks.push({ name: s.targets, status: "warn", message: s.targetMissing });
1970
+ checks.push({ group: g2, name: s.targets, status: "warn", message: s.targetMissing });
1963
1971
  else
1964
1972
  for (let target of targets) {
1965
1973
  let prefix = `[${target.name}]`;
1966
- target.deviceToken ? checks.push({ name: `${prefix} ${s.deviceToken}`, status: "ok", message: `${target.deviceToken.slice(0, 12)}\u2026` }) : checks.push({ name: `${prefix} ${s.deviceToken}`, status: "fail", message: s.tokenMissing });
1974
+ target.deviceToken ? checks.push({ group: g2, name: `${prefix} ${s.deviceToken}`, status: "ok", message: `${target.deviceToken.slice(0, 12)}\u2026` }) : checks.push({ group: g2, name: `${prefix} ${s.deviceToken}`, status: "fail", message: s.tokenMissing });
1967
1975
  try {
1968
1976
  let health = await fetchHealth(target.apiBaseUrl);
1969
- checks.push({ name: `${prefix} ${s.server}`, status: "ok", message: health.siteId });
1977
+ checks.push({ group: g2, name: `${prefix} ${s.server}`, status: "ok", message: health.siteId });
1970
1978
  } catch (err) {
1971
- checks.push({ name: `${prefix} ${s.server}`, status: "fail", message: err instanceof Error ? err.message : String(err) });
1979
+ checks.push({ group: g2, name: `${prefix} ${s.server}`, status: "fail", message: err instanceof Error ? err.message : String(err) });
1972
1980
  }
1973
- target.lastSuccessfulUploadAt ? checks.push({ name: `${prefix} ${s.lastSync}`, status: "ok", message: target.lastSuccessfulUploadAt }) : checks.push({ name: `${prefix} ${s.lastSync}`, status: "warn", message: s.lastSyncNone });
1981
+ 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 });
1974
1982
  }
1975
- let home = homedir14(), tools = [
1983
+ let g3 = s.groupTools, home = homedir14(), tools = [
1976
1984
  { dir: join14(home, ".claude", "projects"), label: "Claude Code", exts: [".jsonl"] },
1977
1985
  { dir: join14(home, ".codex"), label: "Codex CLI", exts: [".jsonl"] },
1978
1986
  { dir: join14(home, ".copilot", "session-state"), label: "Copilot CLI", exts: [".jsonl"] },
@@ -1988,18 +1996,19 @@ async function runDoctor(lang = "zh") {
1988
1996
  try {
1989
1997
  await stat2(tool.dir);
1990
1998
  } catch {
1991
- checks.push({ name: tool.label, status: "warn", message: s.notInstalled });
1999
+ checks.push({ group: g3, name: tool.label, status: "warn", message: s.notInstalled });
1992
2000
  continue;
1993
2001
  }
1994
2002
  let n = await countFiles(tool.dir, tool.exts);
1995
- n > 0 ? checks.push({ name: tool.label, status: "ok", message: s.hasData(n) }) : checks.push({ name: tool.label, status: "warn", message: s.installedNoData });
2003
+ n > 0 ? checks.push({ group: g3, name: tool.label, status: "ok", message: s.hasData(n) }) : checks.push({ group: g3, name: tool.label, status: "warn", message: s.installedNoData });
1996
2004
  }
1997
- let schedule = await getScheduleStatus();
2005
+ let g4 = s.groupSchedule, schedule = await getScheduleStatus();
1998
2006
  return schedule.enabled ? checks.push({
2007
+ group: g4,
1999
2008
  name: s.schedule,
2000
2009
  status: "ok",
2001
2010
  message: schedule.intervalLabel ? `${s.scheduleEvery} ${schedule.intervalLabel}` : s.scheduleEnabled
2002
- }) : checks.push({ name: s.schedule, status: "warn", message: s.scheduleOff }), checks;
2011
+ }) : checks.push({ group: g4, name: s.schedule, status: "warn", message: s.scheduleOff }), checks;
2003
2012
  }
2004
2013
 
2005
2014
  // src/cli.ts
@@ -2183,10 +2192,11 @@ async function runSchedule(sub, flags) {
2183
2192
  }
2184
2193
  }
2185
2194
  async function runDoctorCommand(flags) {
2186
- let config = await readConfig(), lang = (typeof flags.lang == "string" ? flags.lang : config.lang) || "en", checks = await runDoctor(lang);
2195
+ let config = await readConfig(), lang = (typeof flags.lang == "string" ? flags.lang : config.lang) || "en", checks = await runDoctor(lang), lastGroup = "";
2187
2196
  for (let check of checks) {
2197
+ check.group !== lastGroup && (lastGroup && console.log(""), console.log(`\u2500\u2500 ${check.group} \u2500\u2500`), lastGroup = check.group);
2188
2198
  let icon = check.status === "ok" ? "\u2713" : check.status === "warn" ? "\u26A0" : "\u2717";
2189
- console.log(`${icon} ${check.name}: ${check.message}`);
2199
+ console.log(` ${icon} ${check.name}: ${check.message}`);
2190
2200
  }
2191
2201
  checks.filter((c) => c.status === "fail").length > 0 && (process.exitCode = 1);
2192
2202
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiusage/cli",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Track and sync AI tool token usage across devices.",
5
5
  "license": "MIT",
6
6
  "private": false,