day-card 0.1.0: a day of your usage drawn as a card, copied or saved as a PNG

A new page plugin, @magpie-community/page-day-card, for JungleyYeh on X,
who asked for a "daily AI statement".

- It shows a chosen day (today by default, others from a date menu): its
  tokens, cost, calls and errors, then each agent with its models and
  icons. Below them come the streak, the average active day and the last
  two weeks.
- Copy puts the card on the clipboard as an image; Save writes it as a
  PNG.
- The design is quiet, with no gradients and no coloured accents, in
  light and dark. It speaks en, zh, zh-TW, ja and de.
- It asks for one read, usage:day, and needs magpie 0.1.3427 (623e797fd)
  for that read and for magpie.image.copy/save.

What was run (mote):
- bun test packages/day-card: 11 pass, 0 fail. Before engines.magpie
  was set, the guard test was red on the placeholder.
- bun scripts/check.mjs: exit 0.
- Real use: the page in magpie's real GUI server with a sandbox HOME
  holding a copy of real usage, in Chromium and WebKit, light and dark,
  en/zh/zh-TW/ja/de, at 420 and 1100 px, with an earlier day picked and
  Copy pressed. No page errors (magpie 623e797fd's body has the rest).
This commit is contained in:
yetone
2026-11-09 23:23:24 +08:00
parent 573f26760d
commit cbb58f654a
10 changed files with 909 additions and 0 deletions
+1
View File
@@ -177,6 +177,7 @@ These add a page to magpie's window, in the app and in `magpie web`, under Plugi
| Package | Page | Reads |
|---|---|---|
| [usage](packages/usage) | Usage glance: calls, errors, tokens and cost for today, 7 or 30 days, and the models behind them | `usage:summary` |
| [day-card](packages/day-card) | Day card: a day of your usage drawn as a card (tokens, cost, each agent and its models, streak, average day), copied as a picture or saved as a PNG | `usage:day` |
| [powercontext](packages/powercontext) | Connection settings for an independently deployed PowerContext service | None |
| [nowledge-mem](packages/nowledge-mem) | Connection settings, recall and capture switches, a real connection test, and the scope of what is sent | None |
| [agent-office](packages/agent-office) | What are my agents doing: a real WebGL 3D office with six scenes, an isometric/2D office, grouped workbench, Today usage and recent conversations | no `magpie.read`; its host part reads local session files of Claude Code, Codex, Copilot CLI, Kimi Code, dsh, Gemini CLI, Qwen Code, Pi, omp, Qoder, WorkBuddy, CodeBuddy and Grok Build, including prompts, replies and tool commands (`text:false` keeps statuses and tool names only) |
+27
View File
@@ -0,0 +1,27 @@
# @magpie-community/page-day-card
A page in [magpie](https://usemagpie.ai)'s window that draws a day of your AI usage as a card. It shows the day's tokens, cost and calls, input, output, cache reads and the cache hit rate, then each agent with its models and logos, your streak and your average active day, and the last two weeks as small bars. **Copy image** puts the card on the clipboard; **Save PNG** saves it in Downloads.
Install it from magpie's **Plugins › Discover**, or with `magpie plugin add @magpie-community/page-day-card`. It then has a tab, **Day card** (titled in the window's language: 每日用量卡, 1日の使用量カード, Tageskarte), under Plugins in the sidebar, in the app and in `magpie web`. Pick an earlier day with the arrows or the date's menu.
It needs a magpie with the `usage:day` read and `magpie.image` (see `engines.magpie`). An older magpie refuses the read, and the page says to update.
## What it reads
Only `usage:day`, the one permission its `package.json` declares (`magpie.permissions`): a day's totals, each agent's and model's, the days before it that had calls, and the agents' and providers' logos. Nothing in it is a key, an account, a session or a prompt.
Like every plugin page, it runs in a sandboxed frame with no network (`connect-src 'none'`) and no inline scripts. The card is drawn on a canvas in magpie's theme, light or dark, and its PNG goes to magpie through `_magpie/bridge.js`. In `magpie web` the browser copies or downloads it itself.
## Files
- `page/index.html`, `page/style.css`: the page.
- `page/view.js`: what the card says, in English, 简体中文, 繁體中文, 日本語 and Deutsch, with no DOM. The test loads it.
- `page/app.js`: reads through the bridge, draws the card, copies and saves it, and refreshes today's every minute.
## Test
```sh
bun test packages/day-card
```
中文:在 magpie 窗口里加一个「每日用量卡」页面,把某一天的用量画成一张卡片:token、费用、调用次数、缓存命中率,每个 Agent 及其模型(带图标)、连续使用天数、活跃日均和最近两周的小柱状图。可以「复制图片」到剪贴板,或「保存 PNG」到下载文件夹。只读取声明过的 `usage:day`,运行在无网络的沙盒 frame 里。
+179
View File
@@ -0,0 +1,179 @@
import { expect, test } from "bun:test"
import { readFileSync, readdirSync } from "node:fs"
import { join } from "node:path"
const dir = import.meta.dir
const page = join(dir, "page")
const read = (f) => readFileSync(join(page, f), "utf8")
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"))
// view.js is a classic script, as the page loads it
const scope = {}
new Function("globalThis", read("view.js"))(scope)
const V = scope.DayView
// usage:day as magpie answers it (internal/gui/pageday.go, usageapi.DayOf)
const day = {
date: "2026-11-09", today: "2026-11-09",
calls: 412, errors: 3, input: 1_200_000, output: 300_000, cacheRead: 8_000_000, cacheWrite: 500_000, reasoning: 0,
cost: 12.345, unpriced: 2, cacheUnknown: 0,
agents: [
{ id: "claude", name: "Claude Code", icon: "claude-color", calls: 300, input: 1_000_000, output: 200_000, cacheRead: 7_000_000, cacheWrite: 400_000, cost: 10,
models: [
{ model: "claude-opus-4-1", provider: "anthropic", providerName: "Anthropic", icon: "claude-color", input: 800_000, output: 150_000, cacheRead: 6_000_000, cacheWrite: 300_000 },
{ model: "claude-haiku-4-5", provider: "anthropic", providerName: "Anthropic", icon: "claude-color", input: 200_000, output: 50_000, cacheRead: 1_000_000, cacheWrite: 100_000 },
] },
{ id: "codex", name: "Codex", icon: "openai", calls: 100, input: 150_000, output: 90_000, cacheRead: 900_000, cacheWrite: 0, cost: 2.3,
models: [{ model: "gpt-5-codex", provider: "openai", icon: "openai", input: 150_000, output: 90_000, cacheRead: 900_000 }], moreModels: 3 },
{ id: "", name: "", icon: "generic", calls: 12, input: 50_000, output: 10_000, cacheRead: 100_000, cacheWrite: 100_000, cost: 0.04, models: [] },
],
days: [
{ date: "2026-11-01", calls: 10, tokens: 1000, cost: 1 },
{ date: "2026-11-06", calls: 10, tokens: 2000, cost: 2 },
{ date: "2026-11-07", calls: 10, tokens: 3000, cost: 3 },
{ date: "2026-11-08", calls: 10, tokens: 4000, cost: 4 },
{ date: "2026-11-09", calls: 412, tokens: 10_000_000, cost: 12.345 },
],
icons: {}, currency: "usd", rate: 7.1,
}
test("asks for one read, usage:day, and nothing else", () => {
expect(pkg.magpie.permissions).toEqual(["usage:day"])
const reads = new Set()
for (const f of readdirSync(page).filter((f) => f.endsWith(".js"))) {
for (const m of read(f).matchAll(/magpie\.read\(\s*"([^"]+)"/g)) reads.add(m[1])
// no way out of the frame: magpie's policy refuses these anyway
expect(read(f)).not.toMatch(/\bfetch\(|XMLHttpRequest|WebSocket|sendBeacon|EventSource|importScripts/)
}
expect([...reads]).toEqual(["usage:day"])
})
test("is a page magpie serves: its files in page/, scripts as files", () => {
expect(pkg.main).toBeUndefined()
expect(pkg.exports).toBeUndefined()
expect(pkg.engines.magpie).toMatch(/^>=0\.1\.\d+$/)
expect(Object.keys(pkg.magpie.page.titles).sort()).toEqual(["de", "ja", "zh", "zh-TW"])
const html = read("index.html")
expect(html).toContain('<script src="_magpie/bridge.js"></script>')
// the policy runs no inline script
for (const m of html.matchAll(/<script([^>]*)>([\s\S]*?)<\/script>/g)) {
expect(m[1]).toMatch(/\ssrc="/)
expect(m[2].trim()).toBe("")
}
for (const m of html.matchAll(/(?:src|href)="([^"]+)"/g)) {
if (m[1].startsWith("_magpie/")) continue
expect(m[1]).not.toMatch(/^(?:[a-z]+:|\/|\.\.)/i)
expect(readdirSync(page)).toContain(m[1])
}
// magpie's GUI picks from its own menus, never a native select
expect(html).not.toContain("<select")
})
test("every language has every word the page and the card use", () => {
const keys = Object.keys(V.TEXT.en).sort()
for (const [lang, t] of Object.entries(V.TEXT)) {
expect([lang, Object.keys(t).sort()]).toEqual([lang, keys])
for (const [k, v] of Object.entries(t)) {
if (typeof v === "function") expect(v(2)).toContain("2")
else expect([lang, k, v.trim() !== ""]).toEqual([lang, k, true])
}
}
for (const m of read("index.html").matchAll(/data-t(?:-label)?="([^"]+)"/g)) expect(keys).toContain(m[1])
expect([V.langOf("zh-CN"), V.langOf("zh-TW"), V.langOf("zh-Hant-HK"), V.langOf("ja-JP"), V.langOf("de-DE"), V.langOf("fr"), V.langOf("")]).toEqual(["zh", "zh-TW", "zh-TW", "ja", "de", "en", "en"])
})
test("the card: the day's tokens, cost, calls and errors, then its parts", () => {
const c = V.card(day, "en")
expect(c.headline).toBe("10.0M")
expect(c.unit).toBe("tokens")
expect(c.sub).toBe("$12.35 · 412 calls · 3 errors")
expect(c.stats).toEqual([
{ label: "Input", value: "1.20M" },
{ label: "Output", value: "300K" },
{ label: "Cache read", value: "8.00M" },
// 8M of the 9.7M prompt came from the cache
{ label: "Cache hits", value: "82%" },
])
expect(c.date).toBe("Mon, Nov 9, 2026")
expect(c.note).toBe("2 calls without a price")
expect(c.empty).toBe("")
})
test("agents by their tokens, each with its models and what was left out", () => {
const c = V.card(day, "en")
expect(c.agents.map((a) => [a.name, a.icon, a.value])).toEqual([
["Claude Code", "claude-color", "8.60M · $10.00"],
["Codex", "openai", "1.14M · $2.30"],
["No agent named", "generic", "260K · $0.04"],
])
expect(c.agents[0].share).toBe(1)
expect(c.agents[1].share).toBeCloseTo(1.14 / 8.6)
expect(c.agents[0].models.map((m) => [m.name, m.value])).toEqual([["claude-opus-4-1", "7.25M"], ["claude-haiku-4-5", "1.35M"]])
expect(c.agents[0].models[0].share).toBe(1)
expect(c.agents[0].models[1].share).toBeCloseTo(1.35 / 7.25)
expect(c.agents[0].more).toBe("")
expect(c.agents[1].more).toBe("+3 more")
// the card's limits, and what magpie itself left out
const small = V.card({ ...day, moreAgents: 2 }, "en", { agents: 1, models: 1 })
expect(small.agents).toHaveLength(1)
expect(small.agents[0].more).toBe("+1 more")
expect(small.moreAgents).toBe("+4 more")
})
test("streak, average active day and the last two weeks", () => {
expect(V.streak(day.days, "2026-11-09", "2026-11-09")).toBe(4)
// today with no calls yet keeps yesterday's streak
expect(V.streak(day.days.slice(0, 4), "2026-11-09", "2026-11-09")).toBe(3)
// a past day with none has none
expect(V.streak(day.days, "2026-11-05", "2026-11-09")).toBe(0)
expect(V.streak([], "2026-11-09", "2026-11-09")).toBe(0)
// across a month and a year
expect(V.streak([{ date: "2025-12-31", calls: 1 }, { date: "2026-01-01", calls: 1 }], "2026-01-01", "2026-01-02")).toBe(2)
expect(V.average(day.days, "2026-11-08")).toEqual({ days: 4, tokens: 2500, cost: 2.5 })
expect(V.average([], "2026-11-08")).toBeNull()
const c = V.card(day, "en")
expect(c.streak).toEqual({ label: "Streak", value: "4 days" })
expect(c.average.value).toBe("2.00M · $4.47")
expect(c.bars).toHaveLength(14)
expect(c.bars[0]).toEqual({ date: "2026-10-27", tokens: 0 })
expect(c.bars.at(-1)).toEqual({ date: "2026-11-09", tokens: 10_000_000 })
expect(c.bars.filter((b) => b.tokens).length).toBe(5)
})
test("an empty day has nothing to divide by", () => {
const c = V.card({ date: "2026-11-09", today: "2026-11-09", calls: 0, agents: [], days: [], currency: "usd" }, "zh")
expect(c.empty).toBe("这一天没有调用。")
expect(c.headline).toBe("0")
expect(c.stats.at(-1).value).toBe("–")
expect(c.streak.value).toBe("0 天")
expect(c.average.value).toBe("–")
expect(c.sub).toBe("$0 · 0 次调用")
})
test("cost in the currency magpie's Settings picked", () => {
expect(V.money(12.345, "usd", 7.1)).toBe("$12.35")
expect(V.money(12.345, "cny", 7.1)).toBe("¥87.65")
// no rate known: dollars still
expect(V.money(12.345, "cny", 0)).toBe("$12.35")
expect([V.money(0), V.money(0.004), V.money(0.0001, "cny", 7)]).toEqual(["$0", "<$0.01", "<¥0.01"])
expect(V.card({ ...day, currency: "cny" }, "zh").sub).toBe("¥87.65 · 412 次调用 · 3 次错误")
})
test("hit rate leaves out what a vendor counts no cache for", () => {
expect(V.hitRate({ input: 100, cacheRead: 300 })).toBe(0.75)
expect(V.hitRate({ input: 100, cacheRead: 300, cacheUnknown: 100 })).toBe(1)
expect(V.hitRate({})).toBeNull()
expect(V.percent(0.004)).toBe("0.4%")
})
test("dates in the reader's language, by the calendar", () => {
expect(V.shift("2026-03-01", -1)).toBe("2026-02-28")
expect(V.shift("2026-12-31", 1)).toBe("2027-01-01")
expect(V.dateLabel("2026-11-09", "zh")).toContain("2026")
expect(V.dateLabel("2026-11-09", "de")).toContain("2026")
expect(V.fileName("2026-11-09")).toBe("magpie 2026-11-09")
})
test("numbers read short", () => {
expect([V.count(999), V.count(12345), V.count(123456), V.count(1234567), V.count(12345678), V.count(2.5e9)]).toEqual(["999", "12,345", "123K", "1.23M", "12.3M", "2.50B"])
})
+19
View File
@@ -0,0 +1,19 @@
{
"name": "@magpie-community/page-day-card",
"version": "0.1.0",
"description": "A page in magpie's window that draws a day of your AI usage as a card: tokens, cost, each agent and its models, your streak and your average day. Copy it as a picture or save it as a PNG",
"files": ["page", "README.md"],
"keywords": ["magpie", "magpie-page", "usage", "tokens", "cost", "card"],
"license": "MIT",
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/day-card" },
"engines": { "magpie": ">=0.1.3427" },
"magpie": {
"page": {
"title": "Day card",
"titles": { "zh": "每日用量卡", "zh-TW": "每日用量卡", "ja": "1日の使用量カード", "de": "Tageskarte" },
"file": "page/index.html",
"icon": "page/icon.svg"
},
"permissions": ["usage:day"]
}
}
+393
View File
@@ -0,0 +1,393 @@
// The page: reads usage:day (the only read package.json declares) for the
// day picked, draws it on a canvas in magpie's colours, and hands that
// canvas's PNG to magpie.image to copy or save.
(async () => {
const V = globalThis.DayView;
const $ = (id) => document.getElementById(id);
const theme = await magpie.ready;
let lang = theme.lang;
const zone = (() => { try { return Intl.DateTimeFormat().resolvedOptions().timeZone || ""; } catch { return ""; } })();
const state = { date: "", day: null, icons: new Map(), loading: 0 };
// ---- words ----
function words() {
const t = V.text(lang);
document.querySelectorAll("[data-t]").forEach((e) => { e.textContent = t[e.dataset.t]; });
document.querySelectorAll("[data-t-label]").forEach((e) => { e.setAttribute("aria-label", t[e.dataset.tLabel]); e.title = t[e.dataset.tLabel]; });
}
let statusTimer = 0;
function status(msg, bad, keep) {
clearTimeout(statusTimer);
$("status").textContent = msg || "";
$("status").classList.toggle("bad", !!bad);
if (msg && !keep) statusTimer = setTimeout(() => status(""), 6000);
}
// ---- colours and fonts, from magpie's theme ----
function look() {
const css = getComputedStyle(document.documentElement);
const v = (k, f) => css.getPropertyValue("--magpie-" + k).trim() || f;
const dark = document.documentElement.dataset.theme === "dark";
return {
bg: v("card", dark ? "#1c1c1e" : "#f6f6f7"),
fg: v("fg", dark ? "#f5f5f7" : "#1d1d1f"),
fg2: v("fg-2", v("fg", dark ? "#d1d1d6" : "#3a3a3c")),
muted: v("muted", dark ? "#98989d" : "#6e6e73"),
line: v("line", dark ? "#38383a" : "#e5e5ea"),
font: v("font", '-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif'),
code: v("code", "ui-monospace, SFMono-Regular, Menlo, monospace"),
};
}
// ---- logos: data: pictures from the read, a mono one in the text's colour ----
function picture(name) {
const ic = state.day?.icons?.[name];
if (!ic?.src) return Promise.resolve(null);
if (!state.icons.has(ic.src)) {
state.icons.set(ic.src, new Promise((ok) => {
const img = new Image();
img.onload = () => ok({ img, mono: !!ic.mono });
img.onerror = () => ok(null);
img.src = ic.src;
}));
}
return state.icons.get(ic.src);
}
function drawIcon(ctx, ic, x, y, size, colour, scale) {
if (!ic) {
// no logo: a quiet dot where it would be
ctx.fillStyle = colour;
ctx.globalAlpha = 0.3;
ctx.beginPath();
ctx.arc(x + size / 2, y + size / 2, size * 0.28, 0, Math.PI * 2);
ctx.fill();
ctx.globalAlpha = 1;
return;
}
if (!ic.mono) {
ctx.drawImage(ic.img, x, y, size, size);
return;
}
const px = Math.ceil(size * scale);
const off = document.createElement("canvas");
off.width = off.height = px;
const o = off.getContext("2d");
o.drawImage(ic.img, 0, 0, px, px);
o.globalCompositeOperation = "source-in";
o.fillStyle = colour;
o.fillRect(0, 0, px, px);
ctx.drawImage(off, x, y, size, size);
}
// ---- the card ----
const W = 600;
const PAD = 28;
function fit(ctx, s, width) {
if (ctx.measureText(s).width <= width) return s;
let lo = 0, hi = s.length;
while (lo < hi) {
const mid = (lo + hi + 1) >> 1;
if (ctx.measureText(s.slice(0, mid) + "…").width <= width) lo = mid; else hi = mid - 1;
}
return s.slice(0, lo) + "…";
}
// the card's height for model c: the drawing's own walk, measured
function heightOf(c) {
let h = PAD + 22 + 58 + 22 + 22 + 50 + 24;
if (c.empty) h += 40;
else {
h += 24;
for (const a of c.agents) h += 30 + a.models.length * 22 + (a.more ? 20 : 0) + 8;
if (c.moreAgents) h += 20;
}
h += 16 + 60 + (c.note ? 18 : 0) + 18 + PAD;
return Math.ceil(h);
}
async function draw() {
const day = state.day;
if (!day) return;
const c = V.card(day, lang);
const icons = new Map();
await Promise.all([...new Set(c.agents.flatMap((a) => [a.icon, ...a.models.map((m) => m.icon)]))].map(async (n) => icons.set(n, await picture(n))));
if (state.day !== day) return;
const L = look();
const H = heightOf(c);
const scale = Math.max(2, Math.min(3, Math.ceil(window.devicePixelRatio || 1)));
const cv = $("card");
cv.width = W * scale;
cv.height = H * scale;
cv.style.aspectRatio = `${W} / ${H}`;
const ctx = cv.getContext("2d");
ctx.setTransform(scale, 0, 0, scale, 0, 0);
ctx.clearRect(0, 0, W, H);
ctx.fillStyle = L.bg;
ctx.beginPath();
ctx.roundRect ? ctx.roundRect(0, 0, W, H, 18) : ctx.rect(0, 0, W, H);
ctx.fill();
ctx.textBaseline = "alphabetic";
const f = (w, px, fam = L.font) => `${w} ${px}px ${fam}`;
const right = W - PAD;
const rule = (y) => {
ctx.fillStyle = L.line;
ctx.fillRect(PAD, y, W - PAD * 2, 1);
};
let y = PAD;
// magpie, and the day
y += 14;
ctx.font = f(600, 13);
ctx.fillStyle = L.fg;
ctx.textAlign = "left";
ctx.fillText("magpie", PAD, y);
ctx.font = f(400, 13);
ctx.fillStyle = L.muted;
ctx.textAlign = "right";
ctx.fillText(c.date, right, y);
y += 8;
// the day's tokens
y += 52;
ctx.textAlign = "left";
ctx.fillStyle = L.fg;
ctx.font = f(600, 46);
ctx.fillText(c.headline, PAD - 2, y);
const hw = ctx.measureText(c.headline).width;
ctx.font = f(400, 16);
ctx.fillStyle = L.muted;
ctx.fillText(c.unit, PAD + hw + 8, y);
y += 6;
y += 22;
ctx.font = f(400, 14);
ctx.fillStyle = L.fg2;
ctx.fillText(c.sub, PAD, y);
y += 22;
// input, output, cache, hits
const col = (W - PAD * 2) / c.stats.length;
c.stats.forEach((s, i) => {
const x = PAD + i * col;
ctx.font = f(400, 12);
ctx.fillStyle = L.muted;
ctx.fillText(fit(ctx, s.label, col - 10), x, y + 14);
ctx.font = f(600, 17);
ctx.fillStyle = L.fg;
ctx.fillText(s.value, x, y + 38);
});
y += 50;
y += 12;
rule(y);
y += 12;
if (c.empty) {
ctx.font = f(400, 14);
ctx.fillStyle = L.muted;
ctx.fillText(c.empty, PAD, y + 26);
y += 40;
} else {
ctx.font = f(400, 12);
ctx.fillStyle = L.muted;
ctx.fillText(c.agentsLabel, PAD, y + 16);
y += 24;
for (const a of c.agents) {
drawIcon(ctx, icons.get(a.icon), PAD, y + 4, 18, L.fg, scale);
ctx.font = f(400, 13);
ctx.textAlign = "right";
ctx.fillStyle = L.fg2;
ctx.fillText(a.value, right, y + 18);
const vw = ctx.measureText(a.value).width;
ctx.textAlign = "left";
ctx.font = f(600, 14);
ctx.fillStyle = L.fg;
ctx.fillText(fit(ctx, a.name, W - PAD * 2 - 28 - vw - 16), PAD + 28, y + 18);
// its share of the day's busiest agent
ctx.fillStyle = L.line;
ctx.fillRect(PAD + 28, y + 25, W - PAD * 2 - 28, 2);
ctx.fillStyle = L.muted;
ctx.fillRect(PAD + 28, y + 25, Math.max(2, (W - PAD * 2 - 28) * a.share), 2);
y += 30;
for (const m of a.models) {
drawIcon(ctx, icons.get(m.icon), PAD + 28, y + 5, 13, L.fg2, scale);
ctx.font = f(400, 12);
ctx.textAlign = "right";
ctx.fillStyle = L.muted;
ctx.fillText(m.value, right, y + 16);
const mw = ctx.measureText(m.value).width;
ctx.textAlign = "left";
ctx.font = f(400, 12.5, L.code);
ctx.fillStyle = L.fg2;
ctx.fillText(fit(ctx, m.name, W - PAD * 2 - 48 - mw - 16), PAD + 48, y + 16);
y += 22;
}
if (a.more) {
ctx.font = f(400, 12);
ctx.fillStyle = L.muted;
ctx.fillText(a.more, PAD + 48, y + 14);
y += 20;
}
y += 8;
}
if (c.moreAgents) {
ctx.font = f(400, 12);
ctx.fillStyle = L.muted;
ctx.fillText(c.moreAgents, PAD + 28, y + 12);
y += 20;
}
}
// streak, average day, the last two weeks
y += 4;
rule(y);
y += 12;
const third = (W - PAD * 2) / 3;
for (const [i, s] of [c.streak, c.average].entries()) {
const x = PAD + i * third;
ctx.textAlign = "left";
ctx.font = f(400, 12);
ctx.fillStyle = L.muted;
ctx.fillText(fit(ctx, s.label, third - 12), x, y + 16);
ctx.font = f(600, 15);
ctx.fillStyle = L.fg;
ctx.fillText(fit(ctx, s.value, third - 12), x, y + 40);
}
const bars = c.bars;
const most = bars.reduce((m, b) => Math.max(m, b.tokens), 0);
const bw = 7, gap = 4;
const bx = right - bars.length * (bw + gap) + gap;
const base = y + 44;
bars.forEach((b, i) => {
const h = b.tokens > 0 && most > 0 ? Math.max(3, (b.tokens / most) * 34) : 1.5;
ctx.fillStyle = i === bars.length - 1 ? L.fg : L.muted;
ctx.globalAlpha = i === bars.length - 1 ? 1 : b.tokens > 0 ? 0.45 : 0.3;
ctx.beginPath();
ctx.roundRect ? ctx.roundRect(bx + i * (bw + gap), base - h, bw, h, Math.min(2, h / 2)) : ctx.rect(bx + i * (bw + gap), base - h, bw, h);
ctx.fill();
});
ctx.globalAlpha = 1;
y += 60;
if (c.note) {
ctx.font = f(400, 11);
ctx.fillStyle = L.muted;
ctx.fillText(c.note, PAD, y + 8);
y += 18;
}
ctx.font = f(400, 11);
ctx.fillStyle = L.muted;
ctx.textAlign = "right";
ctx.fillText("usemagpie.ai", right, y + 10);
ctx.textAlign = "left";
$("copy").disabled = $("save").disabled = !magpie.image;
}
// ---- reading a day ----
async function load(date) {
const n = ++state.loading;
try {
const day = await magpie.read("usage:day", { date: date || "", tz: zone });
if (n !== state.loading) return;
state.day = day;
state.date = day.date;
status("");
} catch (e) {
if (n !== state.loading) return;
const m = String(e?.message || e);
// a magpie from before usage:day refuses it as a read it doesn't have
status(/usage:day/.test(m) ? V.text(lang).update : `${V.text(lang).failed}: ${m}`, true, true);
}
paintBar();
await draw();
}
function paintBar() {
const d = state.day;
$("date-text").textContent = d ? V.dateLabel(d.date, lang) : "…";
$("next").disabled = !d || d.date >= d.today;
$("today").disabled = !d || d.date === d.today;
$("prev").disabled = !d;
}
// ---- the day menu: the days that had calls, newest first ----
const menu = $("menu");
function openMenu() {
const d = state.day;
if (!d) return;
const days = (d.days || []).slice().reverse().slice(0, 120);
if (!days.some((x) => x.date === d.today)) days.unshift({ date: d.today, tokens: 0 });
menu.replaceChildren(...days.map((x) => {
const li = document.createElement("li");
li.setAttribute("role", "option");
li.dataset.date = x.date;
li.setAttribute("aria-selected", String(x.date === d.date));
const a = document.createElement("span");
a.textContent = V.dateLabel(x.date, lang);
const b = document.createElement("span");
b.textContent = x.tokens ? V.count(x.tokens) : "";
li.append(a, b);
return li;
}));
menu.hidden = false;
menu.classList.remove("closing");
menu.classList.add("opening");
$("date").setAttribute("aria-expanded", "true");
requestAnimationFrame(() => menu.classList.remove("opening"));
menu.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
}
function closeMenu() {
if (menu.hidden) return;
$("date").setAttribute("aria-expanded", "false");
menu.classList.add("closing");
setTimeout(() => { if (menu.classList.contains("closing")) { menu.hidden = true; menu.classList.remove("closing"); } }, 110);
}
$("date").addEventListener("click", (e) => {
e.stopPropagation();
if (menu.hidden || menu.classList.contains("closing")) openMenu(); else closeMenu();
});
menu.addEventListener("click", (e) => {
const li = e.target.closest("li");
if (!li) return;
closeMenu();
if (li.dataset.date !== state.date) load(li.dataset.date);
});
document.addEventListener("click", (e) => { if (!e.target.closest(".pick")) closeMenu(); });
document.addEventListener("keydown", (e) => { if (e.key === "Escape") closeMenu(); });
$("prev").addEventListener("click", () => state.date && load(V.shift(state.date, -1)));
$("next").addEventListener("click", () => state.date && state.day && state.date < state.day.today && load(V.shift(state.date, 1)));
$("today").addEventListener("click", () => load(""));
// ---- sharing ----
const png = () => new Promise((ok, no) => $("card").toBlob((b) => (b ? ok(b) : no(new Error("no picture"))), "image/png"));
$("copy").addEventListener("click", async () => {
const b = $("copy");
b.disabled = true;
try {
await magpie.image.copy(await png());
b.textContent = V.text(lang).copied;
setTimeout(() => { b.textContent = V.text(lang).copy; }, 1500);
} catch (e) {
status(`${V.text(lang).shareFailed}: ${e?.message || e}`, true);
} finally {
b.disabled = false;
}
});
$("save").addEventListener("click", async () => {
const b = $("save");
b.disabled = true;
try {
const r = await magpie.image.save(await png(), V.fileName(state.date));
if (r?.path) status(`${V.text(lang).saved} ${r.path}`);
} catch (e) {
status(`${V.text(lang).shareFailed}: ${e?.message || e}`, true);
} finally {
b.disabled = false;
}
});
magpie.onTheme((t) => { lang = t.lang; words(); paintBar(); draw(); });
// today's numbers keep coming while the page is open
setInterval(() => { if (state.day && state.date === state.day.today && document.visibilityState !== "hidden") load(state.date); }, 60_000);
words();
paintBar();
await load("");
})();
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 1.8h9v12.4l-1.5-1-1.5 1-1.5-1-1.5 1-1.5-1-1.5 1z"/><path d="M5.8 5h4.4M5.8 7.6h4.4M5.8 10.2h2.4"/></g></svg>

After

Width:  |  Height:  |  Size: 286 B

+31
View File
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Day card</title>
<link rel="stylesheet" href="style.css">
<script src="_magpie/bridge.js"></script>
<script src="view.js"></script>
<script src="app.js" defer></script>
</head>
<body>
<header>
<div class="days">
<button type="button" class="step" id="prev" aria-label="Previous day" data-t-label="prev"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10 3.5 5.5 8l4.5 4.5"/></svg></button>
<div class="pick">
<button type="button" id="date" aria-haspopup="listbox" aria-expanded="false"><span id="date-text"></span><svg viewBox="0 0 16 16" aria-hidden="true"><path d="m4.5 6.5 3.5 3.5 3.5-3.5"/></svg></button>
<ul id="menu" role="listbox" hidden></ul>
</div>
<button type="button" class="step" id="next" aria-label="Next day" data-t-label="next"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 3.5 10.5 8 6 12.5"/></svg></button>
<button type="button" id="today" data-t="today">Today</button>
</div>
<div class="share">
<button type="button" id="copy" data-t="copy" disabled>Copy image</button>
<button type="button" id="save" data-t="save" disabled>Save PNG</button>
</div>
</header>
<p class="status" id="status" role="status"></p>
<main><canvas id="card"></canvas></main>
</body>
</html>
+33
View File
@@ -0,0 +1,33 @@
:root {
--bg: var(--magpie-bg, #fff);
--card: var(--magpie-card, #f6f6f7);
--fg: var(--magpie-fg, #1d1d1f);
--muted: var(--magpie-muted, #6e6e73);
--line: var(--magpie-line, #e5e5ea);
--red: var(--magpie-red, #d70015);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { padding: 16px 20px 32px; font: 13px/1.45 var(--magpie-font, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif); }
header { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; max-width: 640px; margin: 0 auto; }
.days, .share { display: flex; align-items: center; gap: 6px; }
button { font: inherit; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 7px; padding: 4px 10px; cursor: default; transition: border-color .15s ease, transform .12s cubic-bezier(.23, 1, .32, 1); }
button:disabled { color: var(--muted); opacity: .6; }
button:active:not(:disabled) { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { button:hover:not(:disabled) { border-color: var(--muted); } }
svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; display: block; }
.step { padding: 4px 6px; }
.pick { position: relative; }
#date { display: inline-flex; align-items: center; gap: 6px; min-width: 9em; justify-content: space-between; font-variant-numeric: tabular-nums; }
#menu { position: absolute; z-index: 2; top: calc(100% + 4px); left: 0; min-width: 100%; max-height: 300px; overflow: auto; margin: 0; padding: 4px; list-style: none; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14); transform-origin: top left; transition: opacity .15s cubic-bezier(.23, 1, .32, 1), transform .15s cubic-bezier(.23, 1, .32, 1); }
#menu.closing, #menu.opening { opacity: 0; transform: scale(.96); }
#menu.closing { transition-duration: .1s; }
#menu li { display: flex; justify-content: space-between; gap: 16px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#menu li span:last-child { color: var(--muted); }
#menu li[aria-selected="true"], #menu li.on { background: var(--card); }
@media (hover: hover) and (pointer: fine) { #menu li:hover { background: var(--card); } }
.status { max-width: 640px; margin: 8px auto; min-height: 1.45em; color: var(--muted); overflow-wrap: anywhere; }
.status.bad { color: var(--red); }
main { max-width: 640px; margin: 0 auto; }
canvas { display: block; width: 100%; height: auto; }
@media (prefers-reduced-motion: reduce) { #menu.closing, #menu.opening { transform: none; } button:active:not(:disabled) { transform: none; } }
+223
View File
@@ -0,0 +1,223 @@
// What the card says, worked out from usage:day without the DOM, so a test
// can check it. A classic script: it sets globalThis.DayView.
(() => {
const TEXT = {
en: {
tokens: "tokens", calls: (n) => (n === 1 ? "1 call" : `${n} calls`), errors: (n) => (n === 1 ? "1 error" : `${n} errors`),
input: "Input", output: "Output", cacheRead: "Cache read", hit: "Cache hits", agents: "Agents",
streak: "Streak", days: (n) => (n === 1 ? "1 day" : `${n} days`), average: "Average active day",
noCalls: "No calls on this day.", more: (n) => `+${n} more`, unpriced: (n) => (n === 1 ? "1 call without a price" : `${n} calls without a price`),
today: "Today", prev: "Previous day", next: "Next day", copy: "Copy image", copied: "Copied", save: "Save PNG", saved: "Saved to",
failed: "Couldn't read usage", shareFailed: "Couldn't share the picture", update: "This card needs a newer magpie. Update magpie, then open it again.",
noAgent: "No agent named",
},
zh: {
tokens: "token", calls: (n) => `${n} 次调用`, errors: (n) => `${n} 次错误`,
input: "输入", output: "输出", cacheRead: "缓存读取", hit: "缓存命中", agents: "Agent",
streak: "连续使用", days: (n) => `${n} 天`, average: "活跃日均",
noCalls: "这一天没有调用。", more: (n) => `还有 ${n} 个`, unpriced: (n) => `${n} 次调用没有价格`,
today: "今天", prev: "前一天", next: "后一天", copy: "复制图片", copied: "已复制", save: "保存 PNG", saved: "已保存到",
failed: "读取用量失败", shareFailed: "分享图片失败", update: "这个卡片需要更新版本的 magpie。请更新 magpie 后再打开。",
noAgent: "未标明 Agent",
},
"zh-TW": {
tokens: "token", calls: (n) => `${n} 次呼叫`, errors: (n) => `${n} 次錯誤`,
input: "輸入", output: "輸出", cacheRead: "快取讀取", hit: "快取命中", agents: "Agent",
streak: "連續使用", days: (n) => `${n} 天`, average: "活躍日均",
noCalls: "這一天沒有呼叫。", more: (n) => `還有 ${n} 個`, unpriced: (n) => `${n} 次呼叫沒有價格`,
today: "今天", prev: "前一天", next: "後一天", copy: "複製圖片", copied: "已複製", save: "儲存 PNG", saved: "已儲存到",
failed: "讀取用量失敗", shareFailed: "分享圖片失敗", update: "這張卡片需要更新版本的 magpie。請更新 magpie 後再開啟。",
noAgent: "未標明 Agent",
},
ja: {
tokens: "トークン", calls: (n) => `${n} 回の呼び出し`, errors: (n) => `${n} 件のエラー`,
input: "入力", output: "出力", cacheRead: "キャッシュ読み取り", hit: "キャッシュヒット", agents: "エージェント",
streak: "連続日数", days: (n) => `${n} 日`, average: "稼働日の平均",
noCalls: "この日の呼び出しはありません。", more: (n) => `ほか ${n} 件`, unpriced: (n) => `価格のない呼び出し ${n} 回`,
today: "今日", prev: "前の日", next: "次の日", copy: "画像をコピー", copied: "コピーしました", save: "PNG を保存", saved: "保存先",
failed: "使用量を読み込めませんでした", shareFailed: "画像を共有できませんでした", update: "このカードには新しい magpie が必要です。magpie を更新してから開き直してください。",
noAgent: "エージェント名なし",
},
de: {
tokens: "Tokens", calls: (n) => (n === 1 ? "1 Aufruf" : `${n} Aufrufe`), errors: (n) => (n === 1 ? "1 Fehler" : `${n} Fehler`),
input: "Eingabe", output: "Ausgabe", cacheRead: "Cache gelesen", hit: "Cache-Treffer", agents: "Agents",
streak: "Serie", days: (n) => (n === 1 ? "1 Tag" : `${n} Tage`), average: "Durchschnitt aktiver Tage",
noCalls: "An diesem Tag keine Aufrufe.", more: (n) => `+${n} weitere`, unpriced: (n) => (n === 1 ? "1 Aufruf ohne Preis" : `${n} Aufrufe ohne Preis`),
today: "Heute", prev: "Vorheriger Tag", next: "Nächster Tag", copy: "Bild kopieren", copied: "Kopiert", save: "PNG sichern", saved: "Gesichert in",
failed: "Nutzung nicht lesbar", shareFailed: "Bild nicht teilbar", update: "Diese Karte braucht ein neueres magpie. Aktualisiere magpie und öffne sie dann erneut.",
noAgent: "Ohne Agent",
},
};
// magpie's languages; anything else reads English
function langOf(lang) {
const l = String(lang || "").toLowerCase();
if (l.startsWith("zh")) return /^zh[-_](tw|hk|mo|hant)/.test(l) ? "zh-TW" : "zh";
if (l.startsWith("ja")) return "ja";
if (l.startsWith("de")) return "de";
return "en";
}
const text = (lang) => TEXT[langOf(lang)];
// 1234 → "1,234"; 1234567 → "1.23M"
function count(n) {
n = Number(n) || 0;
const a = Math.abs(n);
if (a >= 1e9) return (n / 1e9).toFixed(a >= 1e10 ? 1 : 2) + "B";
if (a >= 1e6) return (n / 1e6).toFixed(a >= 1e7 ? 1 : 2) + "M";
if (a >= 1e5) return (n / 1e3).toFixed(0) + "K";
return Math.round(n).toLocaleString("en-US");
}
// a cost in USD, shown as magpie's Settings has it: in CNY at its rate
function money(usd, currency, rate) {
let n = Number(usd) || 0;
let sign = "$";
if (currency === "cny" && Number(rate) > 0) {
n *= Number(rate);
sign = "¥";
}
if (n === 0) return sign + "0";
if (n < 0.01) return "<" + sign + "0.01";
return sign + n.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
}
// every token the day moved: in, out, and through the cache (as
// usage:day's days count them)
const tokensOf = (t) => (Number(t?.input) || 0) + (Number(t?.output) || 0) + (Number(t?.cacheRead) || 0) + (Number(t?.cacheWrite) || 0);
// the share of the prompt read from the cache, of the calls whose vendor
// counts a cache; null when none did
function hitRate(t) {
const read = Number(t?.cacheRead) || 0;
const prompt = (Number(t?.input) || 0) + read + (Number(t?.cacheWrite) || 0) - (Number(t?.cacheUnknown) || 0);
if (prompt <= 0) return null;
return Math.min(1, read / prompt);
}
function percent(r) {
if (r == null) return "–";
const p = r * 100;
return (p > 0 && p < 1 ? p.toFixed(1) : Math.round(p)) + "%";
}
// YYYY-MM-DD arithmetic, by the calendar alone
function shift(date, n) {
const [y, m, d] = String(date).split("-").map(Number);
return new Date(Date.UTC(y, m - 1, d + n)).toISOString().slice(0, 10);
}
// "Sun, Nov 9, 2026" in the reader's language
function dateLabel(date, lang, short) {
const [y, m, d] = String(date).split("-").map(Number);
if (!y || !m || !d) return String(date || "");
const at = new Date(Date.UTC(y, m - 1, d, 12));
const o = short ? { month: "short", day: "numeric", timeZone: "UTC" } : { weekday: "short", year: "numeric", month: "short", day: "numeric", timeZone: "UTC" };
try {
return at.toLocaleDateString(langOf(lang), o);
} catch {
return date;
}
}
// the days in a row with calls that end on date; a today with none yet
// keeps yesterday's streak going
function streak(days, date, today) {
const had = new Set((days || []).filter((d) => Number(d.calls) > 0).map((d) => d.date));
let at = date;
if (!had.has(at) && at === today) at = shift(at, -1);
let n = 0;
while (had.has(at)) {
n++;
at = shift(at, -1);
}
return n;
}
// the average of the days with calls up to date: tokens and cost
function average(days, date) {
const list = (days || []).filter((d) => d.date <= date && Number(d.calls) > 0);
if (!list.length) return null;
const sum = list.reduce((s, d) => ({ tokens: s.tokens + (Number(d.tokens) || 0), cost: s.cost + (Number(d.cost) || 0) }), { tokens: 0, cost: 0 });
return { days: list.length, tokens: sum.tokens / list.length, cost: sum.cost / list.length };
}
// the n days ending on date, each with its tokens (0 for none): the card's
// small bars
function recent(days, date, n = 14) {
const by = new Map((days || []).map((d) => [d.date, Number(d.tokens) || 0]));
const out = [];
for (let i = n - 1; i >= 0; i--) {
const d = shift(date, -i);
out.push({ date: d, tokens: by.get(d) || 0 });
}
return out;
}
// The card, as words and shares the drawing lays out:
// { date, headline, sub, stats[], agents[{name, icon, value, share,
// models[{name, icon, value, share}], more}], moreAgents, streak,
// average, bars[], note, empty }
// An agent shows its first `models` models, and the card its first
// `agents` agents.
function card(day, lang, limits = {}) {
const t = text(lang);
const maxAgents = limits.agents ?? 6;
const maxModels = limits.models ?? 4;
const cur = day.currency;
const rate = day.rate;
const total = tokensOf(day);
const calls = Number(day.calls) || 0;
const errors = Number(day.errors) || 0;
const agents = (Array.isArray(day.agents) ? day.agents : []).slice();
const top = agents.reduce((m, a) => Math.max(m, tokensOf(a)), 0);
const shown = agents.slice(0, maxAgents).map((a) => {
const models = Array.isArray(a.models) ? a.models : [];
const mtop = models.reduce((m, x) => Math.max(m, tokensOf(x)), 0);
const hidden = Math.max(0, models.length - maxModels) + (Number(a.moreModels) || 0);
return {
name: a.id ? String(a.name || a.id) : t.noAgent,
icon: a.icon || "",
value: `${count(tokensOf(a))} · ${money(a.cost, cur, rate)}`,
share: top > 0 ? tokensOf(a) / top : 0,
models: models.slice(0, maxModels).map((m) => ({
name: String(m.model || "?"),
icon: m.icon || "",
value: count(tokensOf(m)),
share: mtop > 0 ? tokensOf(m) / mtop : 0,
})),
more: hidden ? t.more(hidden) : "",
};
});
const hiddenAgents = Math.max(0, agents.length - maxAgents) + (Number(day.moreAgents) || 0);
const avg = average(day.days, day.date);
const s = streak(day.days, day.date, day.today);
const subs = [money(day.cost, cur, rate), t.calls(calls)];
if (errors) subs.push(t.errors(errors));
return {
date: dateLabel(day.date, lang),
headline: count(total),
unit: t.tokens,
sub: subs.join(" · "),
stats: [
{ label: t.input, value: count(day.input) },
{ label: t.output, value: count(day.output) },
{ label: t.cacheRead, value: count(day.cacheRead) },
{ label: t.hit, value: percent(hitRate(day)) },
],
agentsLabel: t.agents,
agents: shown,
moreAgents: hiddenAgents ? t.more(hiddenAgents) : "",
streak: { label: t.streak, value: t.days(s) },
average: { label: t.average, value: avg ? `${count(avg.tokens)} · ${money(avg.cost, cur, rate)}` : "–" },
bars: recent(day.days, day.date),
note: Number(day.unpriced) > 0 ? t.unpriced(Number(day.unpriced)) : "",
empty: calls === 0 ? t.noCalls : "",
};
}
// the file a saved card is named
const fileName = (date) => `magpie ${date}`;
globalThis.DayView = { TEXT, langOf, text, count, money, tokensOf, hitRate, percent, shift, dateLabel, streak, average, recent, card, fileName };
})();
+2
View File
@@ -137,6 +137,8 @@
{"package": "@magpie-community/tools-layerfs", "name": "LayerFS", "kind": "tools", "community": true, "summary": {"en": "LayerFS workspaces for every agent: deduplicated checkpoints and branches behind stable filesystem paths, instead of a fresh copy of the tree for every agent.", "zh": "给每个 agent 的 LayerFS 工作区:稳定的文件系统路径背后是可去重的检查点与分支,而不是每个 agent 各复制一棵项目树。"}},
{ "package": "@magpie-community/page-usage", "name": "Usage Glance", "kind": "page", "community": true,
"summary": { "en": "A page in magpie's window with calls, errors, tokens and cost for today, 7 or 30 days, and the models behind them. Reads only your usage summary.", "zh": "在 magpie 窗口里一眼看到今天、7 天或 30 天的调用、错误、token、费用和对应模型。只读取用量汇总。" } },
{ "package": "@magpie-community/page-day-card", "name": "Day Card", "kind": "page", "community": true,
"summary": { "en": "A day of your AI usage drawn as a card: tokens, cost, each agent and its models, your streak and your average day. Copy it as a picture or save it as a PNG. Reads only your usage by day.", "zh": "把一天的 AI 用量画成一张卡片:token、费用、每个 Agent 和它用的模型、连续使用天数和日均用量。可复制为图片或保存为 PNG。只读取按天的用量。" } },
{ "package": "@magpie-community/page-fingerprint", "name": "Fingerprint", "kind": "page", "community": true,
"summary": { "en": "Check for suspected model substitution by comparing response fingerprints across Magpie providers. Uses lm-detector with shared challenges, local evidence history and JSON export; sampling uses provider quota. Reference data is downloaded on demand from lm.ikale.io, falling back to cdn.jsdmirror.com.", "zh": "在 Magpie 内检测响应指纹,为疑似模型替换提供核查线索。基于 lm-detector,支持跨渠道共享挑战、保留本地证据与 JSON 导出;采样会消耗模型额度。参考库按需从 lm.ikale.io 下载,备用源为 cdn.jsdmirror.com。" } },
{ "package": "@magpie-community/page-chat", "name": "Chat", "kind": "page", "community": true,