diff --git a/README.en.md b/README.en.md index ff5b57e..5b24585 100644 --- a/README.en.md +++ b/README.en.md @@ -6,7 +6,7 @@ *See local Codex usage by machine, model, project, and session—with API-equivalent cost estimates.* -[Live Demo](https://zjay26.github.io/codex-usage/?lang=en) · [Windows x64](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-windows-amd64.exe) · [Linux x64](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-linux-amd64) · English / [简体中文](README.md) +[Live Demo](https://zjay26.github.io/codex-usage/?lang=en) · [Windows x64](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-windows-amd64.exe) · [Linux x64](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-linux-amd64) · [macOS Apple Silicon](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-darwin-arm64) · [All downloads](#install-directly) · English / [简体中文](README.md) [![CI](https://github.com/zJay26/codex-usage/actions/workflows/ci.yml/badge.svg)](https://github.com/zJay26/codex-usage/actions/workflows/ci.yml) [![Release](https://img.shields.io/github/v/release/zJay26/codex-usage?display_name=tag)](https://github.com/zJay26/codex-usage/releases/latest) @@ -17,26 +17,38 @@ ![12-second Codex Usage demo: per-machine tokens, date drill-down, filters, and equivalent cost](docs/media/codex-usage-demo.gif) -> The animation and Live Demo use synthetic data only. They do not read your files, set cookies, run analytics, or make external requests. +> The animation shows the basic workflows; try the new task tree in the Live Demo's Details view. All demos use synthetic data, without reading your files, setting cookies, running analytics, or making external requests. ## Understand it in 30 seconds If you use Codex on more than one computer, an account total cannot tell you **which machine, project, model, or Session used the tokens**. codex-usage fills in that local detail. -Install it once on each computer, then open the Dashboard in your browser to see totals, daily trends, models, projects, and Sessions. Session details are searchable and include an API-equivalent cost estimate. New local usage appears automatically. +Install it once on each computer, then open the Dashboard in your browser to see totals, daily and hourly trends, models, and projects. Search Sessions or switch to a collapsible main-task/subtask tree to see each task's tokens and API-equivalent cost. New local usage appears automatically. All statistics stay on the current computer. codex-usage never stores prompts, replies, or tool output, and does not read `auth.json`. It extracts only usage and mode metadata, skipping conversation strings in diagnostic records. Cost is an estimate based on public API rates and Fast credit multipliers, not an OpenAI bill or account quota. ## Install directly -Windows amd64 / x64 (no administrator privileges required): +This README covers stable **[v2.6.1](https://github.com/zJay26/codex-usage/releases/tag/v2.6.1)**; see the [release notes](docs/releases/v2.6.1.md) for changes and upgrade boundaries. Download links below always resolve to the latest stable release. + +| System | amd64 / x64 | arm64 | +|---|---|---| +| Windows | [x64 binary](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-windows-amd64.exe) | [ARM64 binary](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-windows-arm64.exe) | +| Linux / WSL | [x64 binary](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-linux-amd64) | [ARM64 binary](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-linux-arm64) | +| macOS | [Intel binary](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-darwin-amd64) | [Apple Silicon binary](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-darwin-arm64) | + +### Windows + +amd64 / x64, without administrator privileges; replace `amd64` with `arm64` in the download URL for ARM64 devices: ```powershell Invoke-WebRequest https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-windows-amd64.exe -OutFile codex-usage.exe .\codex-usage.exe --lang en install ``` -Linux amd64 / x64: +### Linux / WSL + +amd64 / x64; replace `amd64` with `arm64` in the download URL for ARM64 devices: ```bash curl -fL https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-linux-amd64 -o codex-usage @@ -44,25 +56,41 @@ chmod +x codex-usage ./codex-usage --lang en install ``` -macOS (Apple Silicon; use `amd64` on Intel): +Login startup uses `systemd --user` by default. If the user bus is unavailable, the installer attempts a detached start and prints a warning; automatic startup then needs manual configuration. + +### macOS + +Apple Silicon; replace `arm64` with `amd64` in the download URL for Intel: ```bash curl -fL https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-darwin-arm64 -o codex-usage chmod +x codex-usage -./codex-usage install +./codex-usage --lang en install ``` -Installs a per-user login LaunchAgent without `sudo`. See [macOS installation](docs/macos.md) for checksums, locations and opening the unnotarized binary. +Install from a normal macOS graphical login session. A per-user LaunchAgent starts the service at login without `sudo`. Binaries are not Apple Developer-ID signed or notarized; see [macOS installation](docs/macos.md) for verification and opening instructions. In an SSH-only session, use `./codex-usage serve` to run in the foreground. + +### Verify and open the Dashboard + +Each Release includes [SHA256SUMS](https://github.com/zJay26/codex-usage/releases/latest/download/SHA256SUMS). Before executing the downloaded binary, you can calculate its hash with `Get-FileHash .\codex-usage.exe -Algorithm SHA256` on Windows, `sha256sum codex-usage` on Linux, or `shasum -a 256 codex-usage` on macOS. Compare it with the manifest entry for your system and architecture's full asset filename. + +The installer finds existing local usage and starts the background service. Open the Dashboard URL printed by installation, [http://127.0.0.1:43189](http://127.0.0.1:43189) by default. You can also run the installed binary to open the browser; commands for the default locations are: + +| System | Open the Dashboard | +|---|---| +| Windows PowerShell | `& "$env:LOCALAPPDATA\Programs\codex-usage\codex-usage.exe"` | +| Linux / WSL | `"$HOME/.local/bin/codex-usage"` | +| macOS | `"$HOME/Library/Application Support/codex-usage/bin/codex-usage"` | -Need arm64? Download `windows-arm64.exe` or `linux-arm64` from the [latest Release](https://github.com/zJay26/codex-usage/releases/latest). Verify the file against `SHA256SUMS` on the same page. +Installation does not modify `PATH`. If you set `CODEX_USAGE_HOME`, use the executable path printed by installation. On a headless Linux server, the program prints an SSH tunnel command; run it on your own computer before opening the Dashboard. -The installer finds existing Codex usage on this computer and keeps the Dashboard updated in the background. Run `codex-usage` to open it. +### Upgrade an existing installation Starting with **v2.5.0**, the application checks GitHub for the latest stable release every six hours by default. Updates are optional: open **Software updates** in the footer to review release notes, disable automatic checks, or check manually. Only **Download and update** downloads the release, verifies SHA256, backs up the program and local statistics, and replaces and restarts the application. A startup failure triggers an attempt to restore the previous program and data. Backups remain under `.codex-usage-updates/run-*` in the state directory. -**Older versions need one manual download and `install` before in-app updates become available.** Portable and preview copies only offer version checks and the release page. Checks fetch version information from GitHub, downloads come from this project's Release assets, and neither uploads usage, paths, or conversations. Turning off automatic checks stops background update requests. Re-running `install` remains available for manual upgrades. +**Installed v2.5.0 or later can update in the app; versions before v2.5.0 require a manual download and `install` first.** Portable and preview copies only offer version checks and the release page. Checks fetch version information from GitHub, downloads come from this project's Release assets, and neither uploads usage, paths, or conversations. Turning off automatic checks stops background update requests. Re-running `install` remains available for manual upgrades. -On a headless Linux server, Codex Usage prints an SSH tunnel command. Run it from your own computer, then open `http://127.0.0.1:43189`. +Upgrading to v2.6 preserves existing statistics and applies accounting fixes to newly read records. To correct earlier undercounts, back up the state and verify retained JSONL coverage before explicitly running `scan --rebuild`; rebuilding cannot recover history whose source files have been deleted. ## What you can see @@ -71,21 +99,23 @@ On a headless Linux server, Codex Usage prints an SSH tunnel command. Run it fro | Which machine used the tokens? | Separate statistics for each Windows, WSL, Linux, or macOS host, without mixing in other computers on the account | | Which models and token categories drove usage? | Model plus Input, Cached, Cache Write, Output, and Reasoning composition | | Which work drove it? | Project, Thread, Session, and main task, Subagent, Guardian, or Memory attribution | -| When did it happen? | Today, 7 days, 30 days, all time, and single-day details | +| When did it happen? | Today, 7 days, 30 days, all time, and daily/hourly details in one accounting time zone | | What did one Session use? | Session-level tokens and API-equivalent cost, with search and a one-click “Only this Session” filter | +| How much did a main task's subtasks use? | Switch Details to the task tree, collapse parent/child relationships, and compare own usage with totals including subtasks | | What would all of this roughly cost at API rates? | Overall and itemized API-equivalent cost, plus explicit pricing coverage | ## Highlights | Capability | What you get | |---|---| -| Per-machine attribution | Keep work, home, Windows, WSL, and Linux usage clearly separated | +| Per-machine attribution | Keep work, home, Windows, WSL, Linux, and macOS usage clearly separated | | History and incremental scans | Find existing records after installation and add new local usage automatically | | Optional software updates | Check and notify automatically; download and install only when chosen, with an opt-out for automatic checks | | Total and Fast | Keep total tokens prominent, show regular / Fast beneath the overview, and show total plus Fast in trends, models, and sessions | | Main tasks and subtasks | Collapse explicit parent/child links; compare own and subtree usage while costs remain own-only | | Session search and filters | Search by Thread, Session ID, project, model, or source; click an active quick filter again to clear it | -| Daily drill-down | Explore trends, calendar days, zero-usage days, and any day's model mix | +| Daily and hourly drill-down | Explore trends, calendar days, zero-usage days, and hourly distribution; remote browsers follow the footer's accounting zone, including repeated DST hours | +| Consistent usage and costs | Session search, tokens, and costs share a filter scope; caches refresh after other processes change statistics or pricing | | Multi-dimensional details | Understand usage by model, token category, source, project, Thread, Session, and Agent | | Equivalent cost | See API-equivalent cost overall and per Session; unpriced usage is clearly marked instead of looking free | | Local and private | Keep data on the current computer, with no conversation uploads or central server | @@ -103,7 +133,7 @@ On a headless Linux server, Codex Usage prints an SSH tunnel command. Run it fro > “Machine” means the host running Codex and codex-usage, not a remote target used by a shell or tool. Codex's official `/usage` shows account-level activity; codex-usage adds detailed attribution for the current computer. -
View static desktop and 390 × 844 mobile screenshots +
View basic interface screenshots (earlier release; use Live Demo for current interactions) ![Codex Usage Dashboard](docs/images/dashboard.png) @@ -133,32 +163,36 @@ flowchart LR The tool reads the current machine's `CODEX_HOME`. It first discovers canonical session metadata from the Codex state database, then streams JSONL files under `sessions/` and `archived_sessions/`. -Token records can be cumulative per session or per turn. Persisted scope and the last token turn distinguish them: total equal to last at a new turn establishes turn scope even when it equals or exceeds the preceding total. Legacy session counters retain their cross-turn baseline. At **each** `token_count` record, the scanner subtracts the previous cumulative vector and assigns that delta to the record timestamp's local calendar day. It never moves an entire multi-day session to the session's latest update date. Stable event IDs and cursors keep repeated scans idempotent. Large prompt, response, reasoning, and tool-output records are skipped without loading the entire line into memory or writing content to the database. +Token records can be cumulative per session or per turn. Persisted scope and the last token turn distinguish them: total equal to last at a new turn establishes turn scope whether it is smaller than, equal to, or larger than the preceding total. Legacy session counters retain their cross-turn baseline. At **each** `token_count` record, the scanner computes the delta against the corresponding session or turn baseline and assigns it to the record timestamp's accounting calendar day. It never moves an entire multi-day session to the session's latest update date. Stable event IDs and cursors keep repeated scans idempotent. Large prompt, response, reasoning, and tool-output records are skipped without loading the entire line into memory or writing content to the database. The Codex state database is used only to discover rollout paths and enrich titles, projects, and other metadata. Its `tokens_used` value never changes token totals. OpenAI's [`account/usage/read`](https://learn.chatgpt.com/docs/app-server#7-token-usage-chatgpt) is service-backed account activity; this tool counts only current-machine local JSONL, so the scopes differ. ### JSONL deduplication and fork ownership - The first `session_meta` fixes the owner session of a physical JSONL file; a copied parent `session_meta` cannot overwrite it. -- In a `forked_from_id` rollout, the “child metadata → copied parent snapshots → parent metadata” prefix establishes a cumulative baseline but is not counted as new child usage. -- Session counters use a high-water mark; turn counters deduplicate stable session/turn snapshot identities. A pre-upgrade session in a newly restored physical file requests a rebuild when old identities cannot safely prove the replay boundary. +- Copied parent history in a fork establishes a baseline without counting as new child usage. The scanner supports parent metadata before or after the copied history, and single-metadata formats, using the evidence available in each format to identify the child's start. +- Session counters retain a high-water mark; turn counters persist per-turn progress and deduplicate stable snapshot identities, counting only new usage after a restart or a copied file resumed mid-turn. A pre-upgrade session in a newly restored physical file requests a rebuild when old identities cannot safely prove the replay boundary. - If a same-total snapshot corrects Cached Input, Cache Write, Reasoning, or another category, the original event is corrected instead of treating the snapshot as a duplicate. ### File and calendar stability Every scan unions paths from the state database with `sessions/` and `archived_sessions/`, so a missing state row cannot hide a JSONL file. Ordinary Windows paths and `\\?\` extended paths normalize to one file. Truncation, a rewrite inside the scanned range, a newly completed fork-replay boundary, or a parser upgrade preserves the current statistics and requests a rebuild. Derived indexes are cleared only after confirmation in the Dashboard or an explicit `codex-usage scan --rebuild`, then rebuilt from the JSONL files that still exist. Data from deleted JSONL files may no longer be recoverable at that point. -An IANA accounting time zone is persisted in the database and shown in the footer. All processes and remote browsers use it. Events keep calendar dates and actual UTC hour identities, including repeated DST hours. Set `CODEX_USAGE_TIMEZONE` before creating a new database to choose its zone; subsequent environment changes do not change the saved zone. Newer Codex writers restart cumulative values at the beginning of a new turn; when that value exactly matches `last_token_usage`, the scanner treats it as an exact increment instead of a data-quality warning. Cumulative boundaries that cannot be fully verified, malformed records, invalid timestamps, and pending rebuilds remain visible. Stale file-rewrite or truncation warnings are removed after a later scan proves that the path has recovered. +An IANA accounting time zone is persisted in the database and shown in the footer. All processes and remote browsers use it. When v2.6 first opens a database without a saved zone, it uses `CODEX_USAGE_TIMEZONE` (for example, `Asia/Shanghai`) or detects the host zone if unset. Later system or process time-zone changes do not override the saved value. Upgrades preserve existing calendar labels; new events use the saved accounting zone. Hours use actual UTC start instants, keeping repeated DST hours distinct and allowing 23- or 25-hour days. Unverifiable cumulative boundaries, malformed records, invalid timestamps, and pending rebuilds remain visible. Stale file-rewrite or truncation warnings are removed after a later scan proves that the path has recovered. Events, modes, counter progress and file offsets commit atomically per file. Database failures roll back and retry; incomplete JSONL tails, including prefixes before the type field, remain unconsumed. -**v2.6.0 preserves pre-upgrade history and applies fixes to new records.** Recalculate earlier undercounts only after checking source coverage and backing up the state. See [the v2.6 accounting contract](docs/accounting-v2.6.md) for snapshots, search scope, task trees and measured query latency. +**Upgrades do not automatically recalculate old history.** See [the v2.6 accounting contract](docs/accounting-v2.6.md) for history preservation, accounting rules, and regression coverage. ### Local service The service scans once on startup, then checks only JSONL size and modification time every 30 seconds. It runs an incremental scan after a change and a fallback scan every 10 minutes. Dashboard reads use a separate read-only SQLite pool, so ingestion no longer queues every page query behind one connection. There is no central server or cross-machine sync. -The Dashboard has three first-level views: Overview, Daily, and Details. Overview defaults to the last seven local calendar days. Daily fills zero-usage dates and supports calendar drill-down. Details shows one attribution dimension—model, source, agent, project, or thread—at a time. +The Dashboard has three first-level views: Overview, Daily, and Details. Overview defaults to the last seven accounting calendar days. Daily fills zero-usage dates and supports calendar and hourly drill-down. Details includes model, source, agent, project, and thread dimensions, plus a Session list/task-tree switch. + +The task tree uses only explicit parent metadata from JSONL or the Codex state database; fork lineage is shown separately. Pagination selects roots with their descendants. Ancestors outside the filter provide structure without adding usage. Each row's tokens and cost belong to that task; the token subtotal includes its entire subtree under the current filter. Adding every row's subtree subtotal would double-count descendants. Missing parents and cycles appear as detached roots with diagnostic labels. + +Persistent data revisions and SQLite read snapshots keep Session rows and costs on the same data version; external pricing changes also invalidate caches. Search selects matching Sessions, then applies date, model, mode, and other filters consistently to tokens, costs, and exports. Session queries select a page and aggregate its events before joining metadata. See [query consistency and performance](docs/accounting-v2.6.md#query-consistency-and-performance) for measurement methods and local latency comparisons. Display settings in the header use a more comfortable type scale by default and let you adjust font size, display density, color theme, interface motion, and language with an immediate preview. These preferences stay in the current browser and never change usage data or exports. @@ -200,10 +234,12 @@ Internal models can be explicitly mapped to one built-in public model or assigne } ``` -The loopback API exposes `GET /api/v1/cost-estimate`, `GET /api/v1/pricing`, and `PUT /api/v1/pricing/overrides`. Pricing ships inside the binary; the running app never fetches price pages. +The loopback API exposes `GET /api/v1/sessions`, `GET /api/v1/session-tree`, `GET /api/v1/session-estimates`, `GET /api/v1/cost-estimate`, `GET /api/v1/pricing`, and `PUT /api/v1/pricing/overrides`. Pricing ships inside the binary; the running app never fetches price pages. ## Common commands +These examples use `codex-usage` as shorthand for a binary on `PATH`. Otherwise, use your system's full invocation shown above and append the arguments. Set CLI language with a global option, for example `codex-usage --lang en doctor`. + ```text codex-usage Open the Dashboard codex-usage summary --since 7d Show a 7-day summary @@ -211,24 +247,27 @@ codex-usage summary --since 30d --json codex-usage summary --since all --csv codex-usage scan Incremental historical scan codex-usage scan --rebuild Rebuild historical scan data +codex-usage serve Run the local service in the foreground codex-usage doctor Check paths, JSONL sources, and service codex-usage config add-home PATH Add another CODEX_HOME codex-usage uninstall Remove the app, keep the database codex-usage uninstall --purge Remove the app and local data ``` -The Dashboard supports `?lang=en|zh-CN` and its header language button. The URL wins over the saved locale, followed by the browser locale. The CLI supports global `--lang` and `CODEX_USAGE_LANG`, for example `CODEX_USAGE_LANG=en codex-usage doctor`. `--json` and `--csv` fields never change with language. +The Dashboard supports `?lang=en|zh-CN` and its header language button. The URL wins over the saved locale, followed by the browser locale. The CLI also supports the `CODEX_USAGE_LANG` environment variable. `--json` and `--csv` fields never change with language. ## Local data paths | Data | Windows | Linux | macOS | -|---|---|---| --- | +|---|---|---|---| | Codex Home | `%USERPROFILE%\.codex` | `~/.codex` | `~/.codex` | | codex-usage state | `%LOCALAPPDATA%\codex-usage` | `${XDG_DATA_HOME:-~/.local/share}/codex-usage` | `~/Library/Application Support/codex-usage` | -| Installed binary | `%LOCALAPPDATA%\Programs\codex-usage\codex-usage.exe` | `~/.local/bin/codex-usage` | `.../codex-usage/bin/codex-usage` | -| SQLite | `...\codex-usage\usage.sqlite` | `.../codex-usage/usage.sqlite` | `.../codex-usage/usage.sqlite` | +| Installed binary | `%LOCALAPPDATA%\Programs\codex-usage\codex-usage.exe` | `~/.local/bin/codex-usage` | `~/Library/Application Support/codex-usage/bin/codex-usage` | +| SQLite | `usage.sqlite` in the state directory | `usage.sqlite` in the state directory | `usage.sqlite` in the state directory | -`CODEX_USAGE_HOME` overrides the app state directory. Do not synchronize this directory between machines, or the per-machine boundary becomes unreliable. +`CODEX_HOME` selects the Codex source directory to read. `CODEX_USAGE_HOME` selects the tool's own dedicated state directory and installs its binary under that directory's `bin` folder. Windows and WSL should use separate statistics databases; sharing or synchronizing active state across systems or machines breaks per-machine attribution. + +The macOS login item is `~/Library/LaunchAgents/com.zjay.codex-usage.plist`. `uninstall` removes the service and program while retaining statistics; only `uninstall --purge` also deletes the tool's statistics data. `usage.sqlite` is created automatically when installation, service startup, scanning, or a query first opens the store, then persists in the state directory above. The embedded pure-Go SQLite driver requires no separately installed SQLite server, Python, Docker, or CGO. The current user only needs write access to the state directory and sufficient disk space. Prefer a local disk; do not place the active database on cloud-sync folders, network shares, or a directory written by multiple machines. @@ -246,16 +285,28 @@ Full local project paths and thread titles are retained for attribution, so JSON ## Build from source -Go 1.26.x is required: +Go 1.26.x is required; CI and official Releases use **Go 1.26.8**. Build for the current platform on Linux / macOS: ```bash go test ./... CGO_ENABLED=0 go build -trimpath -o codex-usage ./cmd/codex-usage ``` -Build all six targets with `scripts/build.ps1` on Windows or `scripts/build.sh` on Linux. +Build all six targets: + +```powershell +# Windows +.\scripts\build.ps1 +``` + +```bash +# Linux (the script uses sha256sum) +bash scripts/build.sh +``` + +Both scripts run Go tests and produce six binaries plus `dist/SHA256SUMS`. On macOS, use the single-platform build above, or cross-build with the Bash script in an environment providing GNU `sha256sum`. -Dashboard tests: +Dashboard tests (require Node.js / npm; CI uses Node.js 24): ```bash npm ci @@ -265,14 +316,16 @@ npm test By default, `npm test` builds and launches a real Go binary in a temporary directory. Set `CODEX_USAGE_BIN` to reuse an existing build. -See [ACCEPTANCE.md](ACCEPTANCE.md) for validation results, [CONTRIBUTING.md](CONTRIBUTING.md) before opening an issue, and [SECURITY.md](SECURITY.md) for private vulnerability reporting. +Current [CI](https://github.com/zJay26/codex-usage/actions/workflows/ci.yml) covers Go tests and vet on Windows, Linux, macOS Apple Silicon / Intel, Linux concurrency checks, six-target cross-builds, and Dashboard tests. Each macOS architecture also runs three install/uninstall/reinstall cycles. Release publication requires the native macOS checks to pass. + +See [the v2.6 technical and verification notes](docs/accounting-v2.6.md) for accounting regressions, task trees, remote time-zone charts, and performance evidence. [ACCEPTANCE.md](ACCEPTANCE.md) archives earlier releases. Read [CONTRIBUTING.md](CONTRIBUTING.md) before opening an issue and [SECURITY.md](SECURITY.md) for private vulnerability reporting. ## Known boundaries - This release does not aggregate multiple machines; open each machine's Dashboard separately - JSONL that is permanently deleted or damaged cannot be fabricated from state `tokens_used` or account usage - historical sessions cannot be reliably split after users synchronize one Codex Home across machines -- Codex `total` is displayed as reported; it is not an actual bill or account-quota measurement, and API-equivalent cost is only a current-price conversion of local tokens +- Codex `total` is displayed as reported; it is not an actual bill or account-quota measurement. API-equivalent cost converts local tokens using the installed catalog and local overrides; prices do not automatically sync online ## License diff --git a/README.md b/README.md index 1080e07..21bb843 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ *Which machine, model, project, or session used your Codex tokens?* -[在线体验](https://zjay26.github.io/codex-usage/?lang=zh-CN) · [Windows x64 下载](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-windows-amd64.exe) · [Linux x64 下载](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-linux-amd64) · [English](README.en.md) / 简体中文 +[在线体验](https://zjay26.github.io/codex-usage/?lang=zh-CN) · [Windows x64](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-windows-amd64.exe) · [Linux x64](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-linux-amd64) · [macOS Apple Silicon](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-darwin-arm64) · [全部下载](#直接安装) · [English](README.en.md) / 简体中文 [![CI](https://github.com/zJay26/codex-usage/actions/workflows/ci.yml/badge.svg)](https://github.com/zJay26/codex-usage/actions/workflows/ci.yml) [![Release](https://img.shields.io/github/v/release/zJay26/codex-usage?display_name=tag)](https://github.com/zJay26/codex-usage/releases/latest) @@ -17,26 +17,38 @@ ![Codex Usage 12 秒演示:逐电脑 Token、日期下钻、筛选与等价成本](docs/media/codex-usage-demo.gif) -> 演示与在线 Demo 全部使用合成数据;不读取你的文件、不设 Cookie、无埋点或外部请求。 +> 动图展示基础操作;新增任务树可在在线 Demo 的“明细”中体验。演示全部使用合成数据,不读取你的文件、不设 Cookie、无埋点或外部请求。 ## 30 秒理解 如果你在多台电脑上使用 Codex,账号总量并不能告诉你:**究竟是哪台电脑、哪个项目、哪个模型或哪段 Session 用掉了 Token**。codex-usage 就是补上这张本机明细表。 -每台电脑安装一次,之后打开浏览器就能查看总量、每日趋势、模型和项目分布;Session 明细可以直接搜索,并显示每段 Session 的 API 等价费用。页面会自动跟进本机后续产生的用量。 +每台电脑安装一次,之后打开浏览器就能查看总量、每日与小时趋势、模型和项目分布;Session 明细可以搜索,也可以切换为可折叠的主任务/子任务树,查看各任务的 Token 与 API 等价费用。页面会自动跟进本机后续产生的用量。 所有统计都留在当前电脑上;不保存 prompt、回复或工具输出,也不读取 `auth.json`。程序仅提取用量和模式元数据,跳过诊断记录中的对话字符串。费用按公开 API 单价及 Fast 额度倍率做等价估算,不是 OpenAI 账单或账号配额。 ## 直接安装 -Windows amd64 / x64(无需管理员权限): +本文对应稳定版 **[v2.6.1](https://github.com/zJay26/codex-usage/releases/tag/v2.6.1)**;变更和升级边界见 [发布说明](docs/releases/v2.6.1.md)。以下下载链接始终指向最新稳定版。 + +| 系统 | amd64 / x64 | arm64 | +|---|---|---| +| Windows | [x64 程序](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-windows-amd64.exe) | [ARM64 程序](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-windows-arm64.exe) | +| Linux / WSL | [x64 程序](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-linux-amd64) | [ARM64 程序](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-linux-arm64) | +| macOS | [Intel 程序](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-darwin-amd64) | [Apple Silicon 程序](https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-darwin-arm64) | + +### Windows + +amd64 / x64,无需管理员权限;ARM64 设备将下载地址中的 `amd64` 改为 `arm64`: ```powershell Invoke-WebRequest https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-windows-amd64.exe -OutFile codex-usage.exe .\codex-usage.exe install ``` -Linux amd64 / x64: +### Linux / WSL + +amd64 / x64;ARM64 设备将下载地址中的 `amd64` 改为 `arm64`: ```bash curl -fL https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-linux-amd64 -o codex-usage @@ -44,7 +56,11 @@ chmod +x codex-usage ./codex-usage install ``` -macOS(Apple Silicon;Intel 将 `arm64` 改为 `amd64`): +默认使用 `systemd --user` 登录自启;user bus 不可用时会尝试后台启动并给出提示,需要自行完成自启配置。 + +### macOS + +Apple Silicon;Intel 设备将下载地址中的 `arm64` 改为 `amd64`: ```bash curl -fL https://github.com/zJay26/codex-usage/releases/latest/download/codex-usage-darwin-arm64 -o codex-usage @@ -52,21 +68,29 @@ chmod +x codex-usage ./codex-usage install ``` -通过用户 LaunchAgent 登录自启,无需 `sudo`。校验、数据位置及未公证程序的打开方式见 [macOS 安装说明](docs/macos.md)。 +请在 macOS 图形登录会话中安装,通过用户 LaunchAgent 登录自启,无需 `sudo`。程序未经 Apple Developer ID 签名或公证;校验和打开方式见 [macOS 安装说明](docs/macos.md)。仅有 SSH 会话时可用 `./codex-usage serve` 前台运行。 -需要 arm64?从 [最新 Release](https://github.com/zJay26/codex-usage/releases/latest) 下载 `windows-arm64.exe` 或 `linux-arm64`。下载后可先用同页的 `SHA256SUMS` 校验。英文安装输出使用: +### 校验与打开 Dashboard -```text -codex-usage --lang en install -``` +每个 Release 附带 [SHA256SUMS](https://github.com/zJay26/codex-usage/releases/latest/download/SHA256SUMS)。可在执行下载的程序前,用 Windows 的 `Get-FileHash .\codex-usage.exe -Algorithm SHA256`、Linux 的 `sha256sum codex-usage` 或 macOS 的 `shasum -a 256 codex-usage` 计算哈希,与清单中对应系统和架构的完整文件名核对。 + +安装器会整理本机已有记录并启动后台服务。之后访问安装输出中的 Dashboard 地址,默认是 [http://127.0.0.1:43189](http://127.0.0.1:43189)。也可运行已安装的程序打开浏览器;默认路径下的命令如下: -安装器会自动整理这台电脑已有的 Codex 使用记录,并在后台持续更新。安装完成后运行 `codex-usage` 即可打开 Dashboard。 +| 系统 | 打开 Dashboard | +|---|---| +| Windows PowerShell | `& "$env:LOCALAPPDATA\Programs\codex-usage\codex-usage.exe"` | +| Linux / WSL | `"$HOME/.local/bin/codex-usage"` | +| macOS | `"$HOME/Library/Application Support/codex-usage/bin/codex-usage"` | + +安装器不会修改 `PATH`。设置过 `CODEX_USAGE_HOME` 时,以安装输出的程序路径为准。Linux 服务器没有桌面环境时,程序会打印 SSH 隧道命令;在自己的电脑执行后再打开 Dashboard。 + +### 升级现有安装 从 **v2.5.0** 起,程序默认每 6 小时检查一次 GitHub 最新稳定版,只提示、不强制更新。页面底部的“软件更新”可查看发布说明、关闭自动检查或手动检查;点击“下载并更新”后才下载并校验 SHA256、备份程序和本机统计、替换并重启。新版本启动失败会尝试恢复旧程序和数据,备份保留在状态目录的 `.codex-usage-updates/run-*` 中。 -**旧版本需要先手动下载并执行一次 `install`,之后即可在软件内选择更新。** 便携版和预览版只提供检查和发布页链接。更新检查只向 GitHub 请求版本信息,下载也来自本项目 Release,不上传用量、路径或对话;关闭自动检查后不会在后台请求更新信息。仍可随时通过重新执行 `install` 手动升级。 +**已安装 v2.5.0 或更高版本,可直接在软件内选择升级;早于 v2.5.0 的版本需先手动下载并执行 `install`。** 便携版和预览版只提供检查和发布页链接。更新检查只向 GitHub 请求版本信息,下载也来自本项目 Release,不上传用量、路径或对话;关闭自动检查后不会在后台请求更新信息。仍可随时通过重新执行 `install` 手动升级。 -Linux 服务器没有桌面环境时,程序会打印 SSH 隧道命令。在自己的电脑执行命令后访问 `http://127.0.0.1:43189`。 +v2.6 系列升级会保留现有统计,计量修复适用于新读入的记录。若要修正旧版本已经漏计的历史,需先备份并核对仍保留的 JSONL,再显式执行 `scan --rebuild`;源文件已删除的历史无法由重建恢复。 ## 你能看到什么 @@ -75,8 +99,9 @@ Linux 服务器没有桌面环境时,程序会打印 SSH 隧道命令。在自 | 哪台电脑用了 Token? | 每台 Windows、WSL、Linux 或 macOS 主机独立统计,不混入账号在其他电脑上的用量 | | 用在了什么模型和内容类型? | 模型及 Input、Cached、Cache Write、Output、Reasoning 构成 | | 哪项工作驱动了用量? | 项目、Thread、Session,以及主任务、Subagent、Guardian、Memory 归属 | -| 什么时候发生? | 今天、7 日、30 日、全部历史,以及按自然日查看详情 | +| 什么时候发生? | 今天、7 日、30 日、全部历史,以及统一计量时区下的自然日与小时详情 | | 某段 Session 花了多少? | Session 级 Token 与 API 等价费用;可搜索,也可一键只看当前 Session | +| 主任务带来了多少子任务用量? | 在“明细”切换任务树,折叠查看父子关系、本任务用量与包含子任务的合计 | | 如果全部按 API 价格折算呢? | 总体与分项的 API 等价费用,并明确显示有多少 Token 能够定价 | ## 功能亮点 @@ -89,7 +114,8 @@ Linux 服务器没有桌面环境时,程序会打印 SSH 隧道命令。在自 | 总量与 Fast | 以总 Token 为主,概览下方显示常规 / Fast 拆分;趋势、模型和任务同时显示总量与 Fast | | 主任务与子任务树 | 折叠查看明确父子关系,区分本任务与含子任务用量;费用列仅计本任务 | | Session 搜索与筛选 | 按 Thread、Session ID、项目、模型或来源搜索;快捷筛选再次点击即可取消 | -| 每日下钻 | 查看连续趋势、月历、零用量日和任意一天的模型构成 | +| 每日与小时下钻 | 查看连续趋势、月历、零用量日与小时分布;远程浏览器遵循页脚计量时区,正确区分夏令时重复小时 | +| 一致的统计与费用 | Session 搜索、Token、费用使用同一筛选范围;其他进程写入统计或修改定价后,缓存随数据版本刷新 | | 多维明细 | 按模型、Token 类型、来源、项目、Thread、Session 和 Agent 理解用量 | | 等价费用 | 总览和 Session 都显示 API 等价费用;无法定价的部分会明确标出,不会假装免费 | | 本地与隐私 | 数据只留在当前电脑,不上传对话,也不依赖中心服务器 | @@ -107,7 +133,7 @@ Linux 服务器没有桌面环境时,程序会打印 SSH 隧道命令。在自 > “电脑”指运行 Codex 客户端和 codex-usage 的主机,不是 shell 或 tool 实际执行的远程环境。Codex 官方 `/usage` 查看账号级活动;codex-usage 补充当前电脑上的详细归属。 -
查看静态桌面和 390 × 844 移动端截图 +
查看基础界面截图(早期版本;当前交互见在线 Demo) ![Codex Usage Dashboard](docs/images/dashboard.png) @@ -137,32 +163,36 @@ flowchart LR 程序只读当前电脑的 `CODEX_HOME`。它优先从 Codex 状态库取得 session 路径、项目和 Thread 信息,再流式读取 `sessions/` 与 `archived_sessions/` 中的 JSONL。 -Token 记录可能按 Session 累计,也可能按 Turn 累计。扫描器保存计量范围与上次 Token 所属 Turn;新 Turn 的 `total_token_usage` 与 `last_token_usage` 相等时建立 Turn 范围,数值小于、等于或大于上一 Turn 均重新起算。旧版 Session 累计仍保留跨 Turn 基线。程序在**每一条** `token_count` 记录处保存累计向量,用“本次累计值 - 上次累计值”得到这一次的增量,并把增量归到该条记录时间戳对应的本地自然日;不会按 session 的最后更新时间把整段历史塞到同一天。重复扫描仍由稳定事件 ID 与游标去重。超大的 prompt、回复和工具输出记录会被跳过,不会整行载入内存,也不会写进数据库。 +Token 记录可能按 Session 累计,也可能按 Turn 累计。扫描器保存计量范围与上次 Token 所属 Turn;新 Turn 的 `total_token_usage` 与 `last_token_usage` 相等时建立 Turn 范围,数值小于、等于或大于上一 Turn 均重新起算。旧版 Session 累计仍保留跨 Turn 基线。程序在**每一条** `token_count` 记录处按对应 Session 或 Turn 的累计基线计算增量,归到该条记录时间戳对应的计量自然日;不会按 session 的最后更新时间把整段历史塞到同一天。重复扫描仍由稳定事件 ID 与游标去重。超大的 prompt、回复和工具输出记录会被跳过,不会整行载入内存,也不会写进数据库。 Codex 状态库只用于发现 rollout 路径并补充标题、项目等 metadata;其中的 `tokens_used` 不参与 Token 总量。OpenAI 的 [`account/usage/read`](https://learn.chatgpt.com/docs/app-server#7-token-usage-chatgpt) 是服务端账号 Token 活动;本工具只统计当前电脑的本地 JSONL,两者范围不同。 ### 2. JSONL 防重与 fork 识别 - 一个物理 JSONL 的 owner session 由第一条 `session_meta` 固定,后续复制进来的父 `session_meta` 不会改写归属 -- `forked_from_id` 文件中“子线程 metadata → 父线程历史快照 → 父线程 metadata”这一前缀只建立累计基线,不计作子线程新消耗 -- Session 范围保留累计高水位;Turn 范围按任务与 Turn 的稳定快照标识排重。升级前 Session 出现在新的物理文件、旧标识无法安全核对时保留统计并提示重建 +- fork 文件中复制的父线程历史只建立累计基线,不计作子线程新消耗;兼容父 metadata 出现在历史之前或之后的格式,以及仅有一条 metadata 的格式,按对应证据识别子线程开始边界 +- Session 范围保留累计高水位;Turn 范围保存每个 Turn 的累计进度并按稳定快照标识排重,重启或从复制文件的 Turn 中途恢复时仅计新增部分。升级前 Session 出现在新的物理文件、旧标识无法安全核对时保留统计并提示重建 - `total_tokens` 不变但 Cached Input、Cache Write、Reasoning 等分类被修正时,会修正原事件,而不是当作重复忽略 ### 3. 文件与日期稳定性 扫描器每次都用状态库路径与 `sessions/`、`archived_sessions/` 目录取并集,避免状态库漏行。Windows 普通路径与 `\\?\` 扩展路径会归一为同一物理文件。检测到截断、原范围重写、后补出的 fork 重放边界或解析规则升级时,程序会保留现有统计并提示需要重建;只有用户在 Dashboard 明确确认,或显式运行 `codex-usage scan --rebuild` 后,才会清除派生索引并从当前仍存在的全部 JSONL 重建。已删除 JSONL 对应的数据届时可能无法恢复。 -计量时区以 IANA 名称保存在数据库,所有进程与远程浏览器使用同一时区;页脚显示当前时区。每个事件保留自然日标签,小时用真实 UTC 起点标识,夏令时重复小时不会合并。首次创建数据库前可设置 `CODEX_USAGE_TIMEZONE`,之后更改系统或进程时区不改变该库的计量时区。新版 Codex 在新 Turn 开始时重置累计值,但当该值与 `last_token_usage` 完全一致时,扫描器会把它作为精确增量处理,不再误报数据质量问题。真正无法完整核对的累计边界、坏记录、无效时间戳和待确认重建仍会明确提示;文件改写或截断问题经后续扫描确认恢复后,过时的红色提示会自动消除。 +计量时区以 IANA 名称保存在数据库,所有进程与远程浏览器使用同一时区;页脚显示当前时区。首次由 v2.6 系列打开尚未保存时区的库时,会采用 `CODEX_USAGE_TIMEZONE`(例如 `Asia/Shanghai`),未设置则检测主机时区;之后更改系统或进程时区不会覆盖已保存的值。升级保留原有自然日标签,新增事件使用保存的计量时区。小时用真实 UTC 起点标识,夏令时重复小时不会合并,一天可以有 23 或 25 小时。无法完整核对的累计边界、坏记录、无效时间戳和待确认重建会明确提示;文件改写或截断问题经后续扫描确认恢复后,过时的红色提示会自动消除。 事件、模式、累计进度与文件游标按文件原子提交;写入失败整笔回滚并保留重试位置。未完整写入的 JSONL 尾行不会提前消费,包括尚未写到 `type` 字段的前缀。 -**v2.6.0 升级保留旧账,修复适用于新增记录。** 旧版本已经漏计的历史需在核对源文件覆盖并备份后显式重算;不会因升级自动删除旧统计。查询快照、搜索范围、任务树和性能证据见 [v2.6 技术说明](docs/accounting-v2.6.md)。 +**升级不会自动重算旧账。** 历史保留、计量规则和回归验证见 [v2.6 技术说明](docs/accounting-v2.6.md)。 ### 4. 展示与服务 后台服务启动时先扫描一次,之后每 30 秒只检查 JSONL 的文件大小与修改时间;检测到变化才执行增量扫描,无变化时每 10 分钟兜底扫描。Dashboard 使用独立只读连接查询同一个本机 SQLite,扫描写入不会再把页面查询堵在单一连接后。没有任何中心服务器,也没有跨电脑同步;要看两台电脑,就分别打开两台电脑的 Dashboard。 -Dashboard 固定为“概览 / 每日 / 明细”三个一级视图。概览默认显示最近 7 个本地自然日;每日视图补齐零用量日期并支持月历下钻;明细视图一次只展开模型、来源、Agent、项目或 Thread 中的一个维度。 +Dashboard 固定为“概览 / 每日 / 明细”三个一级视图。概览默认显示最近 7 个计量自然日;每日视图补齐零用量日期并支持月历与小时下钻;明细视图提供模型、来源、Agent、项目、Thread 等维度,以及 Session 列表/任务树切换。 + +任务树只使用 JSONL 或 Codex 状态库中明确的父子元数据,fork 来源单独显示。分页按根任务进行,子任务跟随父任务;筛选范围外的祖先仅用于展示结构,不增加用量。每行 Token 与费用属于本任务,“含子任务”的 Token 合计覆盖当前筛选范围内的整个子树;不要把每一行子树合计再次相加。缺失父任务或循环关系会作为独立根节点显示并标注。 + +查询使用持久化的数据版本和 SQLite 读取快照,让 Session 行与费用来自同一版数据;外部定价配置变更也会使缓存失效。搜索先确定匹配的 Session,再统一应用日期、模型、模式等筛选到 Token、费用和导出。Session 查询先选页内任务并聚合其事件,再关联元数据;测量方法和本机延迟对比见 [查询一致性与性能](docs/accounting-v2.6.md#query-consistency-and-performance)。 页头“显示设置”默认采用更舒适的字号层级,并可即时调整字体大小、显示密度、颜色主题、界面动效和语言。所有显示偏好只保存在当前浏览器,不会影响统计数据或导出结果。 @@ -204,10 +234,12 @@ GPT-6 Astra 和 GPT-5.6 的 Cache Write 使用官方“普通 Input 的 1.25 倍 } ``` -本机 API 提供 `GET /api/v1/cost-estimate`、`GET /api/v1/pricing` 和 `PUT /api/v1/pricing/overrides`。价格随二进制嵌入,运行时不会抓取网页。 +本机 API 提供 `GET /api/v1/sessions`、`GET /api/v1/session-tree`、`GET /api/v1/session-estimates`、`GET /api/v1/cost-estimate`、`GET /api/v1/pricing` 和 `PUT /api/v1/pricing/overrides`。价格随二进制嵌入,运行时不会抓取网页。 ## 常用命令 +以下用 `codex-usage` 简写已加入 `PATH` 的程序;否则请使用上方对应系统的完整调用路径,再追加参数。CLI 输出可在命令前加全局参数切换语言,例如 `codex-usage --lang en doctor`。 + ```text codex-usage 打开 Dashboard codex-usage summary --since 7d 查看近 7 日摘要 @@ -215,24 +247,27 @@ codex-usage summary --since 30d --json codex-usage summary --since all --csv codex-usage scan 增量扫描 codex-usage scan --rebuild 重建历史扫描数据 +codex-usage serve 前台运行本机服务 codex-usage doctor 检查路径、JSONL 来源和服务 codex-usage config add-home PATH 添加额外 CODEX_HOME codex-usage uninstall 卸载程序,保留统计库 codex-usage uninstall --purge 卸载并删除统计数据 ``` -Dashboard 支持 `?lang=en|zh-CN` 和页头语言按钮;URL 参数优先于已保存语言,其次跟随浏览器。CLI 支持全局 `--lang` 和 `CODEX_USAGE_LANG`,例如 `CODEX_USAGE_LANG=en codex-usage doctor`。`--json` 与 `--csv` 字段不随语言改变。 +Dashboard 支持 `?lang=en|zh-CN` 和页头语言按钮;URL 参数优先于已保存语言,其次跟随浏览器。CLI 也支持 `CODEX_USAGE_LANG` 环境变量。`--json` 与 `--csv` 字段不随语言改变。 ## 数据存在哪里 | 内容 | Windows | Linux | macOS | -|---|---|---| --- | +|---|---|---|---| | Codex Home | `%USERPROFILE%\.codex` | `~/.codex` | `~/.codex` | | codex-usage 状态 | `%LOCALAPPDATA%\codex-usage` | `${XDG_DATA_HOME:-~/.local/share}/codex-usage` | `~/Library/Application Support/codex-usage` | -| 安装后的程序 | `%LOCALAPPDATA%\Programs\codex-usage\codex-usage.exe` | `~/.local/bin/codex-usage` | `.../codex-usage/bin/codex-usage` | -| SQLite | `...\codex-usage\usage.sqlite` | `.../codex-usage/usage.sqlite` | `.../codex-usage/usage.sqlite` | +| 安装后的程序 | `%LOCALAPPDATA%\Programs\codex-usage\codex-usage.exe` | `~/.local/bin/codex-usage` | `~/Library/Application Support/codex-usage/bin/codex-usage` | +| SQLite | 状态目录下的 `usage.sqlite` | 状态目录下的 `usage.sqlite` | 状态目录下的 `usage.sqlite` | + +`CODEX_HOME` 选择要读取的 Codex 源目录;`CODEX_USAGE_HOME` 选择工具自己的专用状态目录,并将程序安装到该目录的 `bin` 下。二者用途不同。Windows 和 WSL 应分别使用自己的统计库;不要跨系统或跨电脑共享、同步活动状态目录,否则逐电脑边界会失真。 -设置 `CODEX_USAGE_HOME` 可以覆盖工具自己的状态目录。不要在多台电脑之间同步这个目录,否则逐电脑边界会失真。 +macOS 登录项位于 `~/Library/LaunchAgents/com.zjay.codex-usage.plist`。`uninstall` 会卸载服务和程序、保留统计;只有 `uninstall --purge` 才会同时删除工具的统计数据。 `usage.sqlite` 会在首次安装、启动服务、扫描或查询需要打开状态库时自动创建,并持续保存在上述状态目录。程序使用内嵌的纯 Go SQLite 驱动,不要求预装 SQLite、数据库服务、Python、Docker 或 CGO;只需要当前用户对状态目录有读写权限,并有足够磁盘空间。应优先使用本机磁盘,不建议把活动数据库放在网盘、网络共享或多台电脑共同写入的同步目录。 @@ -252,7 +287,7 @@ Dashboard 支持 `?lang=en|zh-CN` 和页头语言按钮;URL 参数优先于已 ## 从源码构建 -需要 Go 1.26.x: +需要 Go 1.26.x;CI 和正式 Release 使用 **Go 1.26.8**。Linux / macOS 构建当前平台: ```bash go test ./... @@ -267,11 +302,13 @@ CGO_ENABLED=0 go build -trimpath -o codex-usage ./cmd/codex-usage ``` ```bash -# Linux -./scripts/build.sh +# Linux(脚本使用 sha256sum) +bash scripts/build.sh ``` -Dashboard 测试: +两个脚本都会运行 Go 测试,生成六个平台程序及 `dist/SHA256SUMS`。macOS 可按上方命令构建本机程序,或在提供 GNU `sha256sum` 的环境中使用 Bash 脚本交叉构建。 + +Dashboard 测试(需要 Node.js / npm;CI 使用 Node.js 24): ```bash npm ci @@ -281,14 +318,16 @@ npm test `npm test` 默认在临时目录构建并启动真实 Go 二进制;设置 `CODEX_USAGE_BIN` 可以复用已有构建产物。 -更多验收数据见 [ACCEPTANCE.md](ACCEPTANCE.md)。问题反馈前请阅读 [CONTRIBUTING.md](CONTRIBUTING.md);涉及本机数据或路径的安全问题请按 [SECURITY.md](SECURITY.md) 私密报告。 +当前 [CI](https://github.com/zJay26/codex-usage/actions/workflows/ci.yml) 覆盖 Windows、Linux、macOS Apple Silicon / Intel 的 Go 测试与 vet、Linux 并发检查、六目标交叉构建及 Dashboard 测试;两个 macOS 架构还各执行三轮安装、卸载和重装。Release 发布也要求原生 macOS 检查通过。 + +v2.6 的计量回归、任务树、远程时区图表与性能证据见 [技术与验证说明](docs/accounting-v2.6.md);旧版本验收记录归档于 [ACCEPTANCE.md](ACCEPTANCE.md)。问题反馈前请阅读 [CONTRIBUTING.md](CONTRIBUTING.md);涉及本机数据或路径的安全问题请按 [SECURITY.md](SECURITY.md) 私密报告。 ## 已知边界 - 当前版本不做跨电脑聚合;每台机器独立查看 - JSONL 若被外部工具永久删除或损坏,缺失部分无法由 state `tokens_used` 或账号用量伪造补回 - 主动同步同一个 Codex Home 后,安装前的历史无法可靠拆回原始电脑 -- `total` 按 Codex 原始值展示,不等于独立生成文字量、真实账单或账号配额;API 等价成本只是按当前价格对本机 Token 的重新折算 +- `total` 按 Codex 原始值展示,不等于独立生成文字量、真实账单或账号配额;API 等价成本按当前内置目录及本机定价设置对 Token 重新折算,价格不会在线自动同步 ## License