Adds @magpie-community/page-usage-board: a usage dashboard page with its own zero-dependency local service (quota cards with expiry tiers, TTFT, 7x24 heatmap, optional remote attribution). Reviewed at 8ca2562: the author's 80137b0 plus a maintainer merge of main (registry entry re-appended after upstream's newer packages). Since the 6b2625d review: [::1] in MAGPIE_ADDR stays IPv6 loopback (only 0.0.0.0/[::] map to 127.0.0.1), the config-dir test compares real paths so it passes on macOS, and the registry-block test tolerates CRLF. Run on mote at 8ca2562: packages/page-usage-board `bun test` 36 pass, `node --test test/*.test.mjs` 36 pass; `bun scripts/check.mjs` all ok. Not tried this round: the page in a live magpie window.
4.9 KiB
Community submission
The community publishes packages by merging a pull request into
magpie-community/plugins. Submitting is just
that PR — no dashboard form, and no manual npm publish: merging to the registry's main
branch bumps the version and trusted publishing puts the package on npm automatically,
so package.json's version must be release-ready when the PR lands. One PR adds three
things:
packages/page-usage-board/— this package (all files fromnpm pack, plusLICENSE,README.md,docs/and the development files — see the layout trap below).- One entry in
registry.json. - One row in the README's Pages table.
registry.json entry
{
"package": "@magpie-community/page-usage-board",
"name": "Usage Board",
"kind": "page",
"community": true,
"summary": {
"en": "A quota card wall with expiry tiers, daily/per-provider charts, 24h cache-hit and token curves, optional remote attribution and account detail. Runs its own zero-dependency local service reading this machine's Magpie usage data; optional remote attribution queries the configured remote magpie.",
"zh": "额度到期卡片墙 + 每日与 provider 用量图表 + 24 小时缓存命中与 token 曲线,可选远端归因与账号明细。自带零依赖本机服务,读本机 Magpie 用量数据;远端归因会查询所配置的远端 magpie。"
}
}
The summary above must stay verbatim-identical to magpie.summary in package.json —
copy it into the PR description together with the difference declaration (the registry
requires all three texts to match).
README Pages row
| [page-usage-board](packages/page-usage-board) | Full usage board: quota cards with expiry tiers, daily and per-provider charts, 24-hour cache-hit and token curves, optional remote attribution and account detail | none (the page reads nothing through the bridge; its local service reads your usage.jsonl, magpie's usage/quota API, and — for optional remote attribution — your magpie config's provider key to query the configured remote magpie) |
The packaging layout
npm pack ships what the files field in package.json lists — the runtime (index.mjs,
server.mjs, page/, static/), the vendored echarts bundle (build/echarts-entry.mjs +
static/echarts.min.js), docs/, scripts/ (prepack.mjs, build-echarts.mjs) and
NOTICE. The prepack hook asserts that the echarts entry and its build script exist and
are covered by files, and validates every relative link in README.md and docs/*.md.
Correct layout for packages/page-usage-board/: the npm pack output, plus LICENSE,
.env.example and test/ (development files the README references — they do not need to
be in files).
Check before opening the PR:
docs/and.env.exampleare in the staged tree.- Every relative link in README.md and
docs/*.mdresolves insidepackages/page-usage-board/— click through them in the GitHub PR preview.
Checks before opening the PR
npm testpasses (auth,Host, page gate, traversal, lead-page, package metadata).npm pack --dry-runcontains noremote.js, no page key, and includesLICENSE.- The host part guards every route with a token and checks
Host(community requirement for pages that navigate to a local service). The board page itself is served only on a loopback bind with a loopbackHostname — the token is injected into the served HTML rather than typed, and a non-loopback bind or a proxied publicHostnever receives the page. Deliberate anonymous routes, filed here for review:GET /api/ping(returns{service,ok,build,version}— an identity fingerprint + build id, used to recognise a live instance of the same build) andGET /api/health(returns{ok,jsonl}— liveness). Both carry no key and no usage data; every other/api/*route requires the token via thex-dash-keyheader (no?key=query auth, no cookie channel), and/static/*holds only the chart library and page assets (no data). - Remote attribution defaults to off (
magpie.options.attribution: "local"); the user must explicitly opt in (ATTRIBUTION=remoteoroptions.attribution: "remote"), which sends the configured provider key to the remote magpie and nowhere else. - The hosted page uses
window.magpie.servicewhen present, so a remotemagpie webdeployment keeps the frame under magpie's own origin and key. - The lead page has no inline scripts (its only sources are magpie's
_magpie/bridge.jsand the plugin'sboot.js) and fetches nothing; the board itself only calls its own service on127.0.0.1. Its Content-Security-Policy allows no third-party host, and brand logos come from magpie'splugin-providers.jsonas data URIs — the page never contacts a third-party CDN. magpie.permissionsis[]: the page reads nothing through the bridge.