npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pati-cli

v0.3.0

Published

Command-line interface for the PATI master app — disputes, sync, CS metrics.

Readme

pati-cli

Command-line interface cho PATI master app — xem số liệu business (revenue, PnL, disputes, CS metrics, sync health) từ terminal. Đọc data trực tiếp từ pnl.patigroup.com qua REST API.

Install

bun install -g pati-cli
# hoặc dùng bunx một lần:
bunx pati-cli dispute list

Sau khi publish lên npm. Trong lúc dev local:

cd cli
bun run dev dispute list

Auth

pati auth login

CLI mở browser, anh login Lark như bình thường trên pnl.patigroup.com. Sau khi login xong, browser tự bounce token về CLI qua localhost:<random-port> và CLI lưu vào ~/.pati/config.json.

Nếu browser không mở tự động, copy URL CLI in ra và paste vào browser thủ công.

pati auth status     # show config hiện tại
pati auth logout     # xoá token

Env override khi cần (CI, debug):

export PATI_TOKEN=<jwt>
pati dispute list

Commands

# Auth
pati auth login                          # browser Lark OAuth
pati auth status
pati auth logout

# Active store (multi-store)
pati shop list                           # ● = đang chọn
pati shop switch wellness-nest
pati shop active
pati shop clear

# Analytics (xem số doanh thu / PnL / ROAS)
pati analytics summary                   # 7 ngày: sales, orders, AOV, profit, ROAS, MER…
pati analytics summary --days 30
pati analytics summary --from 2026-05-01 --to 2026-05-28
pati analytics pnl                       # PnL line items + summary
pati analytics pnl --days 1              # hôm nay
pati analytics summary --json | jq

# Disputes (PayPal + Shopify Payments + Stripe)
pati dispute stats                       # tổng + per-gateway + win rate + dispute rate
pati dispute stats --days 30
pati dispute list                        # 15 mới nhất gộp 3 cổng
pati dispute list --status needs_response
pati dispute list --gateway paypal
pati dispute list --days 90 --limit 50
pati dispute list --json | jq
pati dispute show <id>

# CS metrics
pati cs metrics                          # 6 North-Star metrics
pati cs overdue                          # email backlog + overdue counts

# Cron / sync health
pati cron status                         # per-shop per-provider snapshot
pati cron status --shop wellness
pati sync-logs --limit 50
pati sync-logs --status error
pati sync-logs --type shopify --status error

pati --help                              # full reference
pati dispute --help                      # subcommand help

Config

  • File: ~/.pati/config.json (mode 0600)
  • Env override: PATI_TOKEN, PATI_BASE_URL, PATI_SHOP_ID
  • Env wins over file. File wins over defaults.

Debug

PATI_DEBUG=1 pati dispute list   # in stack trace khi error

Build & ship

bun run build           # node bundle dist/index.mjs
bun run build:binary    # standalone executable dist/pati (~50MB)
bun run typecheck

Roadmap

  • [x] Phase 1: dispute list/show, auth scaffolding
  • [x] Phase 2: OAuth login flow (pati auth login mở browser, Lark OAuth, localhost callback)
  • [x] Phase 3: shop · cs metrics/overdue · cron status · sync-logs
  • [x] Phase 3.5: analytics summary/pnl · dispute stats · window flags (--from/--to/--days)
  • [ ] Phase 4: pati dispute upload-evidence, pati cron run <pipeline>, pati order get
  • [ ] Phase 5: single-binary GitHub Releases, Authorization Bearer native

Auth architecture

CLI                                       Backend
───                                       ───────
pati auth login
  ├─ start HTTP server on random :PORT
  ├─ generate state token (16 bytes hex)
  └─ open browser →  /cli/auth?port=PORT&state=STATE
                          │
                          ├─ has pati_session cookie?
                          │     ├─ yes → emit HTML redirecting to
                          │     │        http://localhost:PORT/callback?token=JWT&state=STATE
                          │     └─ no  → 302 /api/auth/lark/start?next=/cli/auth?...
                          │              (after Lark login, callback restores `next` cookie
                          │               and redirects back to /cli/auth)
                          │
  ├─ receive callback ←─────────┘
  ├─ verify state matches
  ├─ save token to ~/.pati/config.json
  └─ HTTP 200 "✓ Logged in, close this tab"

Token forwarded only to localhost (browser controls destination). Random port

  • state token + localhost binding prevent LAN snoop / CSRF / open redirect.