2 Commits

Author SHA1 Message Date
teamchong 99bb931014 chore: rename all pixelpipe references to pxpipe
- code, tests, docs, README, wrangler.toml, help text
- data dir ~/.pixelpipe -> ~/.pxpipe (PXPIPE_LOG env var)
- rebuilt dist; 323/323 tests
2026-06-09 19:04:09 -04:00
teamchong 3109a3b5a4 cli: add 'pixelpipe stats' subcommand for offline log analysis
Reads ~/.pixelpipe/events.jsonl (or --file / PIXELPIPE_LOG) and prints
a one-screen summary of how the proxy is doing:

  - request counts by status bucket (2xx/4xx/5xx)
  - compression rate (compressed vs passthrough)
  - latency p50/p95/p99 (duration + first-byte separately)
  - aggregate Anthropic token usage (input/output/cache_create/cache_read)
  - cache hit rate computed two ways (by tokens, by events)
  - top skip reasons (so we see WHY a request wasn't compressed)
  - top cwds with per-project compression ratio
  - system_sha8 distribution → 'reuse rate' = how often the cached
    payload is being re-sent. High reuse + low cache_read means
    something is breaking cache_control.
  - unknown_static_tags warning section if Claude Code shipped a new
    dynamic tag that we're silently baking into the image.

--json mode dumps the raw Summary as JSON for downstream pipelines.

Streaming reader so a 100 MB log file doesn't OOM. Pure aggregator
(fold/newSummary/renderTextReport) is unit-tested; only the file IO
shell is untested.

Dispatched from src/node.ts BEFORE parseCli so its flags don't collide
with the proxy's flags. The CLI shim in bin/cli.js stays unchanged.

Tests: +6 (status bucketing, compressed/passthrough split, token agg,
cwd & sha histogram, unknown-tag collection, text report rendering).
2026-05-18 16:13:04 -04:00