feat(cli): sync pi-agent usage via ccusage#26
Open
JaceThings wants to merge 2 commits into
Open
Conversation
serviceScheduledSyncSince bucketed lastSuccessAt/now via localDateKey, which reads machine-local date parts — so a test feeding UTC instants (2026-06-16T23:30Z) asserted a local-date string that only held in UTC or US (UTC-) zones, failing on UTC+ hosts. Make the bucket key injectable (default localDateKey, so runtime is unchanged) and rewrite the test to pass a UTC key. Replace previousLocalDateKey with previousDateKey, which derives yesterday from the key string via UTC normalization (timezone- independent, handles month/year rollover).
Register the `pi` ccusage subcommand as a sync source so Pi coding agent usage rolls up under the `pi` source tag. The aggregator and schema already handle ccusage's per-source dialects, and `source` is a free-form string server-side, so sources.ts is the single registration point. Add a sources test guarding the registration and subcommand name, and document Pi in the READMEs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Register the
piccusage subcommand as a sync source so Pi (https://pi.dev) usage rolls up under apisource tag.ccusage already ships
ccusage pi daily; the CLI shells out to oneccusage <subcommand> dailyrun per source and tags rows withsource. The aggregator/schema already handle ccusage's per-source dialects, andsourceis a free-form string server-side — sosources.tsis the single registration point:The
--sourceshelp text and unknown-source error auto-includepiviaDEFAULT_SOURCE_NAMES.Changes
apps/cli/src/ccusage/sources.ts— register thepisourceapps/cli/src/ccusage/sources.test.ts— guard the registration + subcommand mapping + unknown-source rejectionREADME.md,apps/cli/README.md— document PiPrerequisite: timezone-stable test fix
A pre-existing test (
serviceScheduledSyncSince) asserted a machine-local date string against UTC instants, so it only passed in UTC/US zones and blocked CI. Fixed as a separate commit: the bucket key is now injectable (default unchanged) and the test uses a UTC key. Happy to split into its own PR if you'd prefer this one stay focused on the source addition.