Skip to content

Add pi coding-agent local session usage/cost analytics provider - #10

Merged
bernardopg merged 4 commits into
bernardopg:mainfrom
gtheys:feature/pi-provider-analytics
Aug 6, 2026
Merged

Add pi coding-agent local session usage/cost analytics provider#10
bernardopg merged 4 commits into
bernardopg:mainfrom
gtheys:feature/pi-provider-analytics

Conversation

@gtheys

@gtheys gtheys commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

createdAt: 2026-08-05T16:55:00Z
ticket: FEATURE-81e2e9ff
branch: feature/pi-provider-analytics
base: main

Description

Loved the claude code local statistics. As I use Pi agent I build one for that tool too. Tried to follow all standards + translations and documentation.

Summary

  • Adds pi (the pi coding-agent CLI) as a new Analytics-coverage provider, reading local session telemetry from ~/.pi/agent/sessions/**/*.jsonl — cost/tokens, no quota API (pi has no rate limits).
  • Mirrors the existing 9Router local-telemetry pattern: a cheap cached envelope for the collapsed card (fetch_pi_native in get-provider-usage) plus a standalone providers/get-pi-analytics script for the expanded "pi telemetry" card (today/week/month, 7-day chart, top models, top projects). TTL-cached (120s) so the session scan runs at most once per refresh window regardless of poll frequency.
  • Registered pi everywhere provider ids are keyed: widget's availableProviderOptions/name/accent/dashboard maps, Settings' separate allProviders catalog, ProviderLogo fallback icon, and get-provider-health.

Dependencies

  • None. Purely additive; opt-in via Settings' provider list, same as any other provider.

Type of change

  • New feature

Screenshots (if any)

Collapsed and expanded pi card, verified against real session data:

  • Collapsed: pi · pi-local · Today · $6.38 · 20.3M tok
  • Expanded "pi telemetry": Today/Week metric tiles, 7-day cost chart, top models, top projects tables

Note on tests: no JS/unit test harness exists for provider scripts in this repo (bash -n + shellcheck + qmllint are the established automated bar, all run clean). shellcheck was unavailable in the dev environment this was built in — CI runs it.

gtheys added 4 commits August 5, 2026 16:44
Adds `pi` as an Analytics-coverage provider (no quota API — mirrors the
claude/9router local-telemetry tier):

- providers/get-pi-analytics: scans ~/.pi/agent/sessions/**/*.jsonl,
  aggregates today/week/month cost+tokens, 7-day trailing chart, top
  models, top projects. TTL-cached (120s) to avoid rescanning on every
  poll.
- providers/get-provider-usage: fetch_pi_native() envelope, reads only
  the cached snapshot (never triggers a full scan itself, keeping the
  shared 45s dispatcher timeout safe).
- providers/get-provider-health: readiness check (pi CLI or
  ~/.pi/agent/sessions present).

Ref: FEATURE-81e2e9ff (local feature ticket, no Jira)
Wires `pi` into every place the widget/settings key off provider id
strings, so it's a real, selectable provider card (not just a working
backend script):

- AiOverviewControlWidget.qml: availableProviderOptions, providerName,
  providerAccent, dashboard URL map, piAnalyticsScript property
  (mirrors nineRouterAnalyticsScript for Phase 3).
- AiOverviewControlSettings.qml: added to the separate `allProviders`
  catalog that drives the provider manager UI (discovered this is a
  second, independent list from the widget's) + diagnostic quick-actions.
- ProviderLogo.qml: fallback Material icon (smart_toy) since there's no
  provider-logos/pi.svg asset yet.

Ref: FEATURE-81e2e9ff
Clones the 9Router extension-point pattern (Process + buffer property +
conditional card block keyed by provider id) for pi's expanded view:

- piStatsProcess runs providers/get-pi-analytics on the normal refresh
  cycle, alongside the 9router one.
- Card block: metric tiles (today/week/month cost+tokens), 7-day
  trailing cost bar chart with hover detail, top-models table
  (UsageBar, cost share of week), and a top-projects table styled after
  Claude's existing project rows (path + token bar) — new since 9Router
  has no cwd/project dimension.

Ref: FEATURE-81e2e9ff
- architecture.md: components list, "pi protocol" section (mirrors
  the Antigravity/Codex protocol write-ups), pi in the validation
  command example.
- providers.md: pi row in the coverage matrix (Analytics, local JSONL
  session logs, no quota API) and in the coverage-levels legend.
- README.md: provider count badge/highlight (34 → 35), pi row in
  "Notable integrations", pi in the CI validation snippet, architecture
  component list.
- CHANGELOG.md: Unreleased entry.
- i18n: added card.pi_details/pi_models_week/pi_month_total/pi_today
  to all 5 locales (parity verified: 0 drift).

Ref: FEATURE-81e2e9ff
bernardopg added a commit that referenced this pull request Aug 6, 2026
Finalize the 1.9.0 changelog (pi provider + Codex reliability), credit
contributors, and bump the version in plugin.json and the settings hero
pill. get-codex-usage reads plugin.json dynamically.

Contributions in this release:
- pi coding-agent local analytics provider — Geert Theys (#10)
- Codex app-server handshake stabilization — Xianggang Wang (#12, fixes #11)
@bernardopg
bernardopg merged commit 2072ffd into bernardopg:main Aug 6, 2026
5 of 6 checks passed
@bernardopg

Copy link
Copy Markdown
Owner

Thank you, @gtheys! 🎉

Your pi provider has been merged and shipped in v1.9.0. It's a clean, well-scoped addition — the local-JSONL analytics approach mirrors the existing 9Router telemetry pattern nicely, and the TTL-cached envelope keeps the collapsed card cheap while the expanded "pi telemetry" card gives the full today/week/month cost + token breakdown, 7-day chart, top models, and top projects.

Follow-ups I added on top of your commits while landing the release:

  • A shellcheck pass on get-pi-analytics / get-provider-usage (dropped an unused week-start var, annotated the intentional ~/.pi/agent/sessions label tildes).
  • The official pi.dev mark now ships as assets/provider-logos/pi.svg, so the card, DankBar pill, and settings chip use the real logo instead of the Material fallback.

Your original commits are preserved with full authorship. Really appreciate the contribution — thanks for making the plugin better! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants