Skip to content

[Feature Request] /stats Local Usage Statistics Command #947

Description

@myk1yt

Summary

Add a /stats slash command that displays local token usage statistics for LLM API calls, similar to Claude Code's /stats feature.

Demo Video

Demo Video

▶️ YouTube에서 보기

Problem

Users have no way to track their actual token consumption across different models, providers, and sessions. Current UI shows per-task token counts but doesn't provide aggregate statistics over time.

Proposed Solution

A /stats command that opens a dedicated statistics panel showing:

Core Features

  • Time ranges: Today, 7 days, 30 days, All time
  • Token breakdown: Input, Output, Cache Read, Cache Write, Reasoning tokens
  • Grouping: By model, provider, Zoo Code mode, status (completed/failed/cancelled)
  • Time-axis aggregation: Daily, weekly, monthly views
  • Daily heatmap: Visual representation of usage over time
  • Export: JSON and CSV formats
  • Reset: With confirmation dialog

Technical Design

  • Append-only event log: Each API call records a UsageEvent as NDJSON
  • Local storage only: Data stored in globalStorage/usage-stats/
  • No sensitive data: API keys, prompts, and responses are never stored
  • Single instrumentation point: Task.ts terminal finalize (not per-chunk)
  • Idempotent recording: Prevents duplicate events from retries

Safety

  • Data is local-only (VS Code globalStorage)
  • API keys, prompts, responses are never stored
  • Storage failures don't affect LLM task execution
  • Corrupt data is quarantined, not deleted
  • Clear requires nonce-based confirmation

Alternatives Considered

  1. Mutable cumulative summary — Simpler but no audit trail, can't reaggregate
  2. Scan existing task history on demand — Slow, incomplete data, privacy concerns

Additional Context

  • Implementation follows the existing Zoo Code architecture patterns
  • No new runtime dependencies (uses existing Zod, proper-lockfile, safeWriteJson)
  • Compatible with all 30+ providers through the common ApiStreamUsageChunk type

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions