ccusage/ccusage
GitHub: ccusage/ccusage
一款跨多种 AI 编码助手的命令行使用量与成本报告工具,将本地 token 消耗数据汇总为多维度报表。
Stars: 17371 | Forks: 747
ccusage
贡献者设置
贡献者设置使用带有 [nix-direnv](https://github.com/nix-community/nix-direnv) 的 Nix flake 开发环境来锁定工具版本,并使用 `just` 执行日常开发任务。安装 [Nix](https://nixos.org/) 并启用 `nix-command` 和 `flakes` 实验性功能,然后让 nix-direnv 在你进入目录时自动加载开发 shell: ``` # Clone repository git clone https://github.com/ccusage/ccusage.git cd ccusage # 允许 direnv 加载 Nix dev shell direnv allow ``` 开发 shell 提供了来自 `flake.nix` 的锁定版 `pnpm`、Rust 工具链、GitHub CLI、git 钩子、生成的本地 agent 技能、打包工具和项目实用程序。仅当任务需要工作区的 `node_modules` 时,才运行 `pnpm install --frozen-lockfile`。 在 Nix 环境中使用 `just` 运行项目任务(`just --list` 会显示所有配方): ``` just fmt just test just check ``` ### Nix 包 该 flake 将 `ccusage` 作为默认包和应用公开: ``` nix run github:ccusage/ccusage nix run github:ccusage/ccusage -- codex daily --offline nix build github:ccusage/ccusage ``` Nix 构建会从锁定的 `litellm` flake 输入中嵌入 LiteLLM 定价文件,因此沙盒构建不会在构建时获取定价。要更新锁定的定价快照: 非 Nix 的 Cargo 构建会从 `flake.lock` 读取相同的锁定 LiteLLM 版本,并在构建时从该版本获取定价文件。 ``` just update-litellm-pricing ``` 计划的 `update pricing` 工作流会运行相同的更新和验证,然后在定价快照发生更改时提交 PR。标签:Claude Code, GNU通用公共许可证, MITM代理, Node.js, 使用量统计, 可视化界面, 开发辅助, 暗色界面, 通知系统