pi-evals 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +29 -9
- package/dist/build.js +4 -3
- package/dist/cli.js +2 -2
- package/dist/coverage.js +8 -1
- package/dist/findings.js +50 -0
- package/dist/index.js +22 -10
- package/dist/model.js +21 -10
- package/dist/ops.js +52 -22
- package/dist/query.js +32 -13
- package/dist/ranges.js +14 -0
- package/dist/render.js +38 -170
- package/dist/report/concepts.js +37 -0
- package/dist/report/findings.js +84 -0
- package/dist/report/format.js +16 -0
- package/dist/report/sections.js +61 -0
- package/dist/report/strip.js +42 -0
- package/dist/report/style.js +85 -0
- package/dist/report/timeline.js +82 -0
- package/dist/report/week.js +44 -0
- package/dist/trends.js +58 -0
- package/docs/design.md +26 -0
- package/docs/learn.zh-TW.md +33 -0
- package/package.json +6 -3
- package/scripts/change-impact.mjs +18 -0
- package/scripts/package-errors.mjs +10 -0
- package/scripts/query-lib.mjs +36 -0
- package/scripts/skill-days.mjs +9 -0
- package/skills/analyzing-evals/SKILL.md +21 -0
- package/src/aggregate.ts +3 -0
- package/src/build.ts +4 -3
- package/src/cli.ts +2 -2
- package/src/coverage.ts +8 -1
- package/src/findings.ts +49 -0
- package/src/index.ts +22 -12
- package/src/model.ts +22 -10
- package/src/ops.ts +49 -22
- package/src/query.ts +29 -13
- package/src/ranges.ts +15 -0
- package/src/render.ts +70 -187
- package/src/report/concepts.ts +94 -0
- package/src/report/findings.ts +102 -0
- package/src/report/format.ts +24 -0
- package/src/report/sections.ts +186 -0
- package/src/report/strip.ts +40 -0
- package/src/report/style.ts +85 -0
- package/src/report/timeline.ts +127 -0
- package/src/report/week.ts +59 -0
- package/src/trends.ts +61 -0
package/dist/render.js
CHANGED
|
@@ -1,172 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
const usd = (v) => (v === null || v === undefined ? "—" : `$${v.toFixed(2)}`);
|
|
16
|
-
const num = (v) => v.toLocaleString("en-US");
|
|
17
|
-
function bars(rows, width = 560) {
|
|
18
|
-
if (!rows.length)
|
|
19
|
-
return `<p class="empty">—</p>`;
|
|
20
|
-
const max = Math.max(...rows.map((r) => r.value), 1);
|
|
21
|
-
const h = 18;
|
|
22
|
-
const labelW = 220;
|
|
23
|
-
const body = rows
|
|
24
|
-
.map((r, i) => {
|
|
25
|
-
const w = Math.max(1, Math.round(((width - labelW - 90) * r.value) / max));
|
|
26
|
-
const y = i * (h + 4);
|
|
27
|
-
return `<text x="0" y="${y + 13}" class="lbl">${esc(r.label.length > 34 ? `${r.label.slice(0, 33)}…` : r.label)}</text><rect x="${labelW}" y="${y}" width="${w}" height="${h}" class="bar"/><text x="${labelW + w + 6}" y="${y + 13}" class="val">${esc(r.note ?? num(r.value))}</text>`;
|
|
28
|
-
})
|
|
29
|
-
.join("");
|
|
30
|
-
return `<svg role="img" width="${width}" height="${rows.length * (h + 4)}" viewBox="0 0 ${width} ${rows.length * (h + 4)}">${body}</svg>`;
|
|
1
|
+
import { concepts, lesson } from "./report/concepts.js";
|
|
2
|
+
import { esc, num, words } from "./report/format.js";
|
|
3
|
+
import { sections } from "./report/sections.js";
|
|
4
|
+
import { css } from "./report/style.js";
|
|
5
|
+
import { timeline } from "./report/timeline.js";
|
|
6
|
+
import { PRESETS, suffix } from "./ranges.js";
|
|
7
|
+
import { trendPair } from "./trends.js";
|
|
8
|
+
import { periodRows, workload } from "./report/week.js";
|
|
9
|
+
function weeklyPanel(m, L) {
|
|
10
|
+
const w = m.weekly, p = w?.packages[0];
|
|
11
|
+
if (!w || (!p && !w.monitors))
|
|
12
|
+
return "";
|
|
13
|
+
const rows = [p && `${p.name === "unknown" ? L("Tools with no known package", "套件不明的工具") : p.name} ${L("errors/calls", "錯誤數/呼叫數")} ${trendPair(p)}`, w.monitors && `${L("Failed/finished jobs", "失敗數/已結束工作數")} ${trendPair(w.monitors)}`];
|
|
14
|
+
return `<section class="panel"><h2>${L("Weekly error increases", "每週錯誤比例上升")}</h2><p>${esc(w.start)}–${esc(w.end)} UTC · ${L("Earlier week → later week", "前一週 → 後一週")}</p>${rows.filter(Boolean).map(s => `<p>${esc(s)}</p>`).join("")}</section>`;
|
|
31
15
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (!meta)
|
|
57
|
-
return "";
|
|
58
|
-
const dir = meta.goodDirection === "higher" ? (lang === "zh" ? "越高越好" : "higher is better") : meta.goodDirection === "lower" ? (lang === "zh" ? "越低越好" : "lower is better") : "";
|
|
59
|
-
return `<p class="meaning"><b>${tx(meta.label)}</b>: ${tx(meta.meaning)}${dir ? ` <span class="dir">(${dir})</span>` : ""}<br><span class="how">${tx(meta.howComputed)}</span></p>`;
|
|
60
|
-
};
|
|
61
|
-
const L = (en, zh) => (lang === "zh" ? zh : en);
|
|
62
|
-
const sections = [];
|
|
63
|
-
const fresh = model.freshness;
|
|
64
|
-
sections.push(`<section><h2>${L("Overview", "總覽")}</h2>
|
|
65
|
-
<p>${L("Window", "期間")}: ${esc(model.window.since ?? "—")} → ${esc(model.window.until ?? "—")} (${model.window.days} ${L("days", "天")})${model.window.project ? ` · ${L("project", "專案")} ${esc(model.window.project)}` : ""}</p>
|
|
66
|
-
<p class="${fresh.stale ? "warn" : ""}">${L("Last extract", "上次抽取")}: ${esc(fresh.lastExtract ?? "—")}${fresh.stale ? ` — ${L("data is stale; run /evals extract", "資料過時,請執行 /evals extract")}` : ""}</p>
|
|
67
|
-
${table([L("Number", "數字"), L("Value", "數值")], [
|
|
68
|
-
[tx(m.sessions.label), model.totals.sessions],
|
|
69
|
-
[tx(m.subagent_sessions.label), model.totals.subagentSessions],
|
|
70
|
-
[tx(m.prompts.label), model.totals.prompts],
|
|
71
|
-
[tx(m.tool_calls.label), model.totals.toolCalls],
|
|
72
|
-
[tx(m.tool_error_rate.label), `${pct(model.totals.toolErrorRate)} (n=${num(nOf(model.totals.toolErrorRate))})`],
|
|
73
|
-
[tx(m.cost.label), usd(model.totals.cost)],
|
|
74
|
-
])}
|
|
75
|
-
${explain("sessions")}
|
|
76
|
-
<h3>${L("Sessions per day", "每日工作階段")}</h3>${columns(model.series.days, model.series.sessions)}
|
|
77
|
-
<h3>${L("Cost per day (USD)", "每日費用(美元)")}</h3>${columns(model.series.days, model.series.cost)}</section>`);
|
|
78
|
-
const sk = model.skills;
|
|
79
|
-
sections.push(`<section><h2>${L("Skills", "技能")}</h2>${explain("skill_loads")}
|
|
80
|
-
<h3>${L("Loads per day", "每日載入")}</h3>${columns(model.series.days, model.series.skillLoads)}
|
|
81
|
-
<h3>${L("Most loaded", "最常載入")}</h3>${bars(sk.top.slice(0, 25).map((s) => ({ label: s.name, value: s.loads, note: `${num(s.loads)} · ${num(s.sessions)} ${L("sessions", "階段")}` })))}
|
|
82
|
-
${explain("skill_sessions")}
|
|
83
|
-
<h3>${L("How skills were loaded", "載入方式")}</h3>${table([L("Way", "方式"), L("Loads", "次數")], Object.entries(sk.triggers).map(([k, v]) => [esc(k), v]))}
|
|
84
|
-
<h3>${L("By project (top 30)", "各專案(前 30)")}</h3>${table([L("Project", "專案"), L("Skill", "技能"), L("Loads", "次數")], sk.byProject.slice(0, 30).map((r) => [esc(r.project), esc(r.skill), r.loads]))}
|
|
85
|
-
<h3>${tx(m.never_loaded.label)} (${sk.neverLoaded.length} / ${sk.offered})</h3>${explain("never_loaded")}<p>${sk.neverLoaded.map(esc).join(", ") || "—"}</p></section>`);
|
|
86
|
-
sections.push(`<section><h2>${L("Packages", "套件")}</h2>${explain("package_calls")}${explain("tool_error_rate")}${explain("avg_duration_ms")}
|
|
87
|
-
${table([L("Package", "套件"), L("Version", "版本"), L("Calls", "呼叫"), L("Errors", "錯誤"), tx(m.tool_error_rate.label), tx(m.avg_duration_ms.label)], model.packages.map((p) => [esc(p.owner), esc(p.version ?? "—"), p.calls, p.errors, pct(p.errorRate), ms(p.avgMs)]))}
|
|
88
|
-
<h3>${L("Tools (top 40)", "工具(前 40)")}</h3>${table([L("Tool", "工具"), L("Package", "套件"), L("Calls", "呼叫"), tx(m.tool_error_rate.label), tx(m.avg_duration_ms.label)], model.tools.slice(0, 40).map((t) => [esc(t.name), esc(t.owner), t.calls, pct(t.errorRate), ms(t.avgMs)]))}</section>`);
|
|
89
|
-
const ask = model.askUser;
|
|
90
|
-
const bucketLabel = (up, i, all) => (up === null ? `≥ ${ms(all[i - 1]?.upToMs ?? 0)}` : `< ${ms(up)}`);
|
|
91
|
-
sections.push(`<section><h2>${L("Questions to you", "問你的問題")}</h2>${explain("ask_calls")}${explain("ask_wait_ms")}${explain("ask_cancel_rate")}
|
|
92
|
-
${table([L("Number", "數字"), L("Value", "數值")], [
|
|
93
|
-
[tx(m.ask_calls.label), ask.calls],
|
|
94
|
-
[tx(m.ask_wait_ms.label), `${ms(ask.avgWaitMs)} (n=${num(ask.waitN)})`],
|
|
95
|
-
[tx(m.ask_cancel_rate.label), `${pct(ask.cancelRate)} (n=${num(nOf(ask.cancelRate))})`],
|
|
96
|
-
])}
|
|
97
|
-
<h3>${L("How long you took", "你花多久回答")}</h3>${bars(ask.buckets.map((b, i) => ({ label: bucketLabel(b.upToMs, i, ask.buckets), value: b.n })))}
|
|
98
|
-
<h3>${L("Where the answer came from", "回答來源")}</h3>${table([L("Source", "來源"), L("Questions", "題數")], Object.entries(ask.sources).map(([k, v]) => [esc(k), v]))}</section>`);
|
|
99
|
-
const mon = model.monitors;
|
|
100
|
-
sections.push(`<section><h2>${L("Background jobs", "背景工作")}</h2>${explain("monitor_outcomes")}${explain("monitor_duration_ms")}
|
|
101
|
-
<p>${L("Started", "啟動")}: ${num(mon.started)} · ${L("Ending recorded", "有結束紀錄")}: ${num(mon.finished)} · ${tx(m.monitor_duration_ms.label)}: ${ms(mon.avgMs)} (n=${num(mon.durationN)})</p>
|
|
102
|
-
${bars(Object.entries(mon.statuses).map(([k, v]) => ({ label: k, value: v })))}</section>`);
|
|
103
|
-
const sub = model.subagents;
|
|
104
|
-
sections.push(`<section><h2>${L("Subagents", "子代理")}</h2>${explain("subagent_launches")}
|
|
105
|
-
${table([L("Role", "角色"), L("Model", "模型"), L("Launches", "次數")], sub.launches.slice(0, 40).map((r) => [esc(r.role), esc(r.model), r.n]))}
|
|
106
|
-
${explain("subagent_cost")}${bars(sub.costByRole.slice(0, 20).map((r) => ({ label: r.role, value: r.cost, note: usd(r.cost) })))}
|
|
107
|
-
<p>${L("Subagent sessions linked to a parent", "能對回母工作階段的子代理")}: ${num(sub.linked)} / ${num(sub.subagentTotal)}</p></section>`);
|
|
108
|
-
const proc = model.process;
|
|
109
|
-
const dm = model.meta.detectors;
|
|
110
|
-
sections.push(`<section><h2>${L("Process: does the work follow the anchorloop rules?", "流程:工作有沒有照 anchorloop 規則走?")}</h2>
|
|
111
|
-
<p>${L(`Only sessions from ${proc.eraStart} (anchorloop 3.0.0) on are judged; older ones are out of scope, not failures.`, `只評 ${proc.eraStart}(anchorloop 3.0.0)之後的工作階段;更早的不在範圍內,不算失敗。`)}</p>${explain("pass_rate")}
|
|
112
|
-
${proc.detectors
|
|
113
|
-
.map((d) => {
|
|
114
|
-
const meta = dm[d.name];
|
|
115
|
-
const daily = d.perDay.map((x) => (x.pass + x.fail ? Math.round((100 * x.pass) / (x.pass + x.fail)) : 0));
|
|
116
|
-
return `<div class="detector"><h3>${tx(meta?.label)}: ${pct(d.passRate)} <small>(n=${num(nOf(d.passRate))}, ${L("not applicable", "不適用")} ${num(d.na)})</small></h3>
|
|
117
|
-
<p>${tx(meta?.meaning)}<br><span class="how">${tx(meta?.howComputed)}</span></p>
|
|
118
|
-
<p class="ex">✔ ${tx(meta?.example.pass)}<br>✘ ${tx(meta?.example.fail)}</p>
|
|
119
|
-
<h4>${L("Share followed per day (%)", "每日遵守比例(%)")}</h4>${columns(model.series.days, daily, 720, 80)}
|
|
120
|
-
${table([L("anchorloop version", "anchorloop 版本"), L("Followed", "遵守"), L("Not followed", "未遵守"), tx(m.pass_rate.label)], d.byVersion.map((v) => [esc(v.version), v.pass, v.fail, pct(v.passRate)]))}</div>`;
|
|
121
|
-
})
|
|
122
|
-
.join("")}
|
|
123
|
-
<h3>${L("Close-guard reminders", "收尾提醒")}</h3>${table([L("Kind", "種類"), L("Count", "次數")], Object.entries(proc.notices).map(([k, v]) => [tx(model.meta.notices[k]) || esc(k), v]))}</section>`);
|
|
124
|
-
sections.push(`<section><h2>${L("Cost", "費用")}</h2>${explain("cost")}${explain("cost_per_session")}${explain("skill_cost")}
|
|
125
|
-
<p>${tx(m.cost_per_session.label)}: ${model.cost.perSession.value === null ? "—" : usd(model.cost.perSession.value)} (n=${num(model.cost.perSession.n)})</p>
|
|
126
|
-
<h3>${L("By skill loaded (top 25)", "依載入技能(前 25)")}</h3>${bars(model.cost.bySkill.map((r) => ({ label: r.skill, value: r.cost, note: `${usd(r.cost)} · ${num(r.sessions)}` })))}
|
|
127
|
-
<h3>${L("Model replies by model", "各模型回覆數")}</h3>${table([L("Model", "模型"), L("Replies", "回覆")], model.cost.byModel.slice(0, 20).map((r) => [esc(r.model), r.replies]))}</section>`);
|
|
128
|
-
const changes = model.changes.slice(-40).reverse();
|
|
129
|
-
const imp = (c) => {
|
|
130
|
-
if (!c.impact)
|
|
131
|
-
return L("no data before this change", "變更前沒有資料");
|
|
132
|
-
const i = c.impact;
|
|
133
|
-
const row = (key, label) => {
|
|
134
|
-
const b = i.before[key];
|
|
135
|
-
const a = i.after[key];
|
|
136
|
-
if (b === undefined || a === undefined)
|
|
137
|
-
return "";
|
|
138
|
-
const show = (x) => (typeof x === "number" ? num(x) : key === "cost_per_session" ? (x.value === null ? "—" : usd(x.value)) : key.endsWith("per_session") ? (x.value === null ? "—" : x.value.toFixed(2)) : pct(x));
|
|
139
|
-
return `<tr><td>${esc(label)}</td><td>${show(b)}</td><td>${show(a)}</td></tr>`;
|
|
140
|
-
};
|
|
141
|
-
const kinds = Object.entries(i.confounders)
|
|
142
|
-
.map(([k, v]) => `${tx(model.meta.changeKinds[k])} ${v}`)
|
|
143
|
-
.join(", ");
|
|
144
|
-
const flags = [
|
|
145
|
-
i.smallSample ? `<span class="warn">${tx(m.small_sample.label)}</span>` : "",
|
|
146
|
-
i.incomplete ? `<span class="warn">${tx(m.incomplete_window.label)} (${L("days with data", "有資料的天數")}: ${i.daysWithData.before} / ${i.daysWithData.after})</span>` : "",
|
|
147
|
-
i.confounded ? `<span class="warn">${tx(m.confounded.label)}: ${i.confounded} (${esc(kinds)})</span>` : "",
|
|
148
|
-
]
|
|
149
|
-
.filter(Boolean)
|
|
150
|
-
.join(" · ");
|
|
151
|
-
return `<table><thead><tr><th></th><th>${L("before", "之前")}</th><th>${L("after", "之後")}</th></tr></thead><tbody>${row("sessions", tx(m.sessions.label))}${row("tool_error_rate", tx(m.tool_error_rate.label))}${row("package_error_rate", L("This package's error rate", "此套件出錯比例"))}${row("ask_cancel_rate", tx(m.ask_cancel_rate.label))}${row("cost_per_session", tx(m.cost_per_session.label))}${row("skill_loads_per_session", tx(m.skill_loads_per_session.label))}${row("notices_per_session", tx(m.notices_per_session.label))}${row("anchor_before_first_edit", tx(dm.anchor_before_first_edit.label))}${row("check_after_last_edit", tx(dm.check_after_last_edit.label))}</tbody></table>${flags}`;
|
|
152
|
-
};
|
|
153
|
-
sections.push(`<section><h2>${L("Your changes and what followed", "你的變更與之後的變化")}</h2>${explain("impact")}${explain("small_sample")}${explain("incomplete_window")}${explain("confounded")}
|
|
154
|
-
${changes.map((c) => `<details><summary>${esc(c.at.slice(0, 10))} · ${tx(model.meta.changeKinds[c.kind])} · ${esc(c.package ? `${c.package} ${c.from ?? "∅"} → ${c.to ?? "∅"}` : c.subject)}${c.repo ? ` <small>${esc(c.repo)} ${esc(c.sha ?? "")}</small>` : ""}</summary><p>${esc(c.subject)}</p>${imp(c)}</details>`).join("") || `<p class="empty">—</p>`}</section>`);
|
|
155
|
-
const lab = model.labels;
|
|
156
|
-
sections.push(`<section><h2>${L("Your labels", "你的標記")}</h2>${explain("agreement")}
|
|
157
|
-
${lab.present ? table([L("Check", "檢查"), L("Labelled", "已標記"), L("Agree", "一致"), tx(m.agreement.label)], lab.agreement.map((a) => [tx(dm[a.detector]?.label) || esc(a.detector), a.n, a.agree, pct(a.rate)])) : `<p class="empty">${L("No labels yet. Labelling sessions comes in a later phase.", "還沒有標記。標記工作階段會在之後的階段加入。")}</p>`}</section>`);
|
|
158
|
-
const cov = model.coverage;
|
|
159
|
-
if (cov)
|
|
160
|
-
sections.push(`<section><h2>${tx(m.coverage.label)}</h2>${explain("coverage")}
|
|
161
|
-
<p>${L(`Inactive more than ${cov.cutDays} days`, `閒置超過 ${cov.cutDays} 天`)}: ${num(cov.old.files)} ${L("files", "個檔案")} (${(cov.old.bytes / 1e9).toFixed(2)} GB) · ${L("indexed", "已建索引")} ${num(cov.indexed.files)} · ${L("not indexed", "未建索引")} ${num(cov.notIndexed.files)} (${(cov.notIndexed.bytes / 1e9).toFixed(2)} GB)</p></section>`);
|
|
162
|
-
return `<!doctype html><html lang="${lang === "zh" ? "zh-Hant-TW" : "en"}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>pi-evals report</title>
|
|
163
|
-
<style>
|
|
164
|
-
:root{color-scheme:light dark;--fg:#1d1d1f;--bg:#fff;--muted:#666;--bar:#4a7bd0;--line:#ddd;--warn:#b35c00}
|
|
165
|
-
@media (prefers-color-scheme:dark){:root{--fg:#e6e6e6;--bg:#151515;--muted:#9a9a9a;--bar:#7aa2f7;--line:#333;--warn:#f0a050}}
|
|
166
|
-
body{font:15px/1.55 system-ui,-apple-system,"PingFang TC","Noto Sans TC",sans-serif;color:var(--fg);background:var(--bg);max-width:980px;margin:2rem auto;padding:0 1rem}
|
|
167
|
-
section{border-top:1px solid var(--line);padding:1rem 0}h1{font-size:1.6rem}h2{font-size:1.3rem}h3{font-size:1.05rem;margin-top:1.2rem}
|
|
168
|
-
table{border-collapse:collapse;margin:.5rem 0}td,th{border-bottom:1px solid var(--line);padding:.25rem .6rem;text-align:left;vertical-align:top}
|
|
169
|
-
.bar{fill:var(--bar)}.lbl,.val{fill:var(--fg);font-size:12px}.meaning{color:var(--fg)}.how,.dir,small{color:var(--muted)}.warn{color:var(--warn)}.empty{color:var(--muted)}
|
|
170
|
-
.ex{color:var(--muted);font-size:.92em}details{margin:.3rem 0}summary{cursor:pointer}
|
|
171
|
-
</style></head><body><h1>pi-evals</h1><p class="how">${L("Generated", "產生時間")} ${esc(model.generated)} · ${L("numbers only: no transcript text is stored or shown", "只有數字:不儲存也不顯示對話內容")}</p>${sections.join("\n")}</body></html>`;
|
|
16
|
+
export function renderHtml(m, lang = "zh", range = "custom") {
|
|
17
|
+
const L = words(lang), w = periodRows(m), t = timeline(m, w, lang, range), c = concepts(m, w, t.lead, L);
|
|
18
|
+
const nav = [
|
|
19
|
+
["archive", L("All changes", "所有調整")],
|
|
20
|
+
["skills", L("Skills", "技能")],
|
|
21
|
+
["packages", L("Tools", "套件與工具")],
|
|
22
|
+
["ask", L("Questions", "提問")],
|
|
23
|
+
["monitors", L("Jobs", "背景工作")],
|
|
24
|
+
["subagents", L("Subagents", "子代理")],
|
|
25
|
+
["process", L("Process checks", "流程檢查")],
|
|
26
|
+
["cost", L("Cost", "費用")],
|
|
27
|
+
["coverage", L("Cleanup", "清理門檻")],
|
|
28
|
+
["labels", L("Labels", "你的標記")],
|
|
29
|
+
["concepts", L("Concepts", "概念")],
|
|
30
|
+
];
|
|
31
|
+
const date = m.generated.slice(0, 10);
|
|
32
|
+
return `<!doctype html><html lang="${lang === "zh" ? "zh-Hant-TW" : "en"}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>pi-evals · ${L("Change timeline", "調整時間軸")}</title><style>${css}</style></head><body><header><a href="#timeline" class="brand"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><rect width="30" height="30" rx="8" fill="#174e47"/><path d="M7 22V15M15 22V8M23 22V12" fill="none" stroke="white" stroke-width="3"/></svg>pi-evals<span>${L("Agent work, observed", "代理工作觀察")}</span></a><small>${esc(date)} ${L("report", "更新")} / ${L("All times UTC", "時間皆為 UTC")}</small></header>
|
|
33
|
+
<main id="timeline"><div class="ranges">${range === "custom" ? "" : `<nav aria-label="${L("Time range", "時間範圍")}">${PRESETS.map(p => `<a href="report${suffix(p)}.html"${p === range ? ' aria-current="page"' : ""}>${p === "all" ? L("All time", "全部") : L(`Last ${p} days`, `近 ${p} 天`)}</a>`).join("")}</nav>`}<small>${esc(m.window.since ?? "—")} – ${esc(m.window.until ?? "—")} UTC</small></div>${t.strip}<div class="hero"><p class="eyebrow">${L("Change journal / Newest first", "調整紀事 / 依更新時間排列")}</p><h1>${esc(t.headline)}</h1><p class="deck">${esc(t.trust)}</p>${m.freshness.stale
|
|
34
|
+
? `<p class="stale">${L("Last extract", "上次抽取")}:${esc(m.freshness.lastExtract ?? "—")} · ${L("Refresh with /evals extract.", "資料過時,請執行 /evals extract。")}</p>`
|
|
35
|
+
: ""}</div>
|
|
36
|
+
<div class="spine"><h2>${L(`${t.count} changes worth a closer look`, `${t.count === 2 ? "兩" : t.count === 1 ? "一" : "零"}筆值得回看的調整`)}</h2><div class="layout"><div class="rail">${t.cards || `<p>${L("Nothing to highlight yet.", "還沒有適合比較的調整。")}</p>`}</div><aside class="side">${workload(w, L)}${weeklyPanel(m, L)}${lesson(c.record, L)}${lesson(c.metric, L)}</aside></div><details><summary>${L("How to read the comparisons", "怎麼讀時間軸上的比較?")}</summary><div class="notes-grid">${lesson(c.sample, L)}${lesson(c.confounding, L)}${lesson(c.check, L)}</div></details></div>
|
|
37
|
+
<nav class="jump" aria-label="${L("Report sections", "報表章節")}">${nav.map(([id, text]) => `<a href="#${id}">${text}</a>`).join("")}</nav><section class="topic" id="archive"><h2>${L("Other changes by day", "按日期查其餘調整")}</h2><p>${L("Open a day for its changes. Each link opens the before-and-after comparison.", "展開一天,點選調整名稱,就能看到它的前後比較。")}</p>${t.archive || "—"}</section>
|
|
38
|
+
<p class="muted">${esc(m.window.project ?? L("All projects", "全部專案"))} · ${esc(m.window.since ?? "—")} → ${esc(m.window.until ?? "—")} · ${num(m.totals.sessions)} ${L("sessions", "段工作")} · ${num(m.totals.prompts)} ${L("prompts", "次提示")}</p>${sections(m, lang, c)}</main>
|
|
39
|
+
${t.details}<footer><b>PI-EVALS / ${L("Change timeline", "調整時間軸")}</b><span>${esc(m.window.project ?? L("All projects", "全部專案"))} · ${L("Transcript text not included", "統計不含對話原文")}</span></footer></body></html>`;
|
|
172
40
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { esc, num } from "./format.js";
|
|
2
|
+
export function concepts(m, week, c, L) {
|
|
3
|
+
const i = c?.impact, n = num(week.reduce((s, r) => s + r.sessions, 0)), d = m.process.detectors.find((r) => r.name === "anchor_before_first_edit");
|
|
4
|
+
return {
|
|
5
|
+
record: [
|
|
6
|
+
L("Record", "紀錄"),
|
|
7
|
+
L(`A tool call leaves a record: ${num(week.reduce((s, r) => s + r.calls, 0))} calls in this chart’s period. The words exchanged are not kept.`, `一次工具呼叫留下一筆紀錄。圖中這幾天共 ${num(week.reduce((s, r) => s + r.calls, 0))} 次,不保留對話原文。`),
|
|
8
|
+
],
|
|
9
|
+
metric: [
|
|
10
|
+
L("Metric", "指標"),
|
|
11
|
+
L(`Count sessions by their start date: ${n} in the chart. This measures workload, not whether the work was good.`, `把工作按開始日期計數,圖中共有 ${n} 段。這個指標量的是工作量,不是工作品質。`),
|
|
12
|
+
],
|
|
13
|
+
sample: [
|
|
14
|
+
L("Before, after and sample size", "前後比較與樣本數"),
|
|
15
|
+
i
|
|
16
|
+
? L(`Split sessions at the change time: ${num(i.before.sessions)} before and ${num(i.after.sessions)} after. Only sessions to which a rule applies count in its percentage.`, `依開始時間分組:調整前 ${num(i.before.sessions)} 段、調整後 ${num(i.after.sessions)} 段。算一條規則的通過比例時,只數適用的工作段。`)
|
|
17
|
+
: L(`There are ${num(m.totals.sessions)} sessions in the report. Without records on both sides, we cannot compare a change.`, `報表裡有 ${num(m.totals.sessions)} 段工作。調整前後都要有紀錄,才有兩組數字能比。`),
|
|
18
|
+
],
|
|
19
|
+
confounding: [
|
|
20
|
+
L("Other changes at the same time", "同期多個調整"),
|
|
21
|
+
i
|
|
22
|
+
? L(`There were ${num(i.confounded)} other changes in these windows. If a rule and a package changed together, their effects cannot be separated here.`, `這段期間另有 ${num(i.confounded)} 筆調整。規則和套件若一起改,只比前後分不出哪一項影響了結果。`)
|
|
23
|
+
: L(`There are ${num(m.changes.length)} changes on this timeline. Check what else changed before crediting a new version.`, `時間軸有 ${num(m.changes.length)} 筆調整。要把差異歸給某個版本,得先查同一期間還改了什麼。`),
|
|
24
|
+
],
|
|
25
|
+
check: [
|
|
26
|
+
L("Code check", "程式檢查"),
|
|
27
|
+
L(`In ${num(d?.passRate.n ?? 0)} eligible sessions, code checked whether the agent named a check before editing. It cannot judge whether that check tested the right thing.`, `程式在 ${num(d?.passRate.n ?? 0)} 段適用的工作裡查「改檔前有沒有先說怎麼驗證」。它看得出先後順序,判斷不了方法好不好。`),
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function lesson(entry, L) {
|
|
32
|
+
return `<aside class="lesson"><strong class="eyebrow">${L("Reading the numbers", "讀數字")} / ${esc(entry[0])}</strong><p>${esc(entry[1])}</p></aside>`;
|
|
33
|
+
}
|
|
34
|
+
export function selfCheck(L) {
|
|
35
|
+
const item = (q, a) => `<p>${q}</p><details><summary>${L("Answer", "看答案")}</summary><p>${a}</p></details>`;
|
|
36
|
+
return `<h3>${L("Check your reading", "試著判讀")}</h3>${item(L("1. Tool errors fell after a pin. Did the new version fix them?", "1. 更新後工具出錯比例下降,就能說是新版本修好了嗎?"), L("Not from this alone. Check the window, the sample and what else changed.", "還不能。先看前後各有幾段工作、資料收齊了沒,以及同期還改了什麼。"))}${item(L("2. A session passed the check for naming a test before editing. Did the test cover the bug?", "2. 一段工作通過「動手前先說好怎麼驗證」,表示測試驗到了那個錯誤嗎?"), L("The order was right. Whether the test could catch the bug is a different question.", "只知道順序對。那個測試抓不抓得到錯誤,要另外看測試內容。"))}`;
|
|
37
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { num, pct, usd, words } from "./format.js";
|
|
2
|
+
export function readings(c, m, lang) {
|
|
3
|
+
const L = words(lang), i = c.impact;
|
|
4
|
+
const has = (k) => i?.before[k]?.value != null && i.after[k]?.value != null;
|
|
5
|
+
const process = c.package === "pi-anchorloop" && has("anchor_before_first_edit");
|
|
6
|
+
const keys = process
|
|
7
|
+
? ["anchor_before_first_edit", "check_after_last_edit"]
|
|
8
|
+
: [has("package_error_rate") ? "package_error_rate" : "tool_error_rate", "cost_per_session"];
|
|
9
|
+
return keys.map((key) => {
|
|
10
|
+
const meta = m.meta.detectors[key] ?? m.meta.metrics[key === "package_error_rate" ? "tool_error_rate" : key];
|
|
11
|
+
return {
|
|
12
|
+
key,
|
|
13
|
+
label: key === "package_error_rate" ? L("Package tool error rate", "套件工具出錯比例") : meta.label[lang],
|
|
14
|
+
direction: meta.goodDirection === "higher" ? L("higher is better", "越高越好") : L("lower is better", "越低越好"),
|
|
15
|
+
unit: key.endsWith("error_rate") ? L("calls", "次呼叫") : L("sessions", "段"),
|
|
16
|
+
before: i?.before[key],
|
|
17
|
+
after: i?.after[key],
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export const value = (r, side) => r.key === "cost_per_session" ? usd(r[side]?.value ?? null) : pct(r[side]);
|
|
22
|
+
const comparable = (r) => r.before?.value != null && r.after?.value != null;
|
|
23
|
+
export function verdict(c, rs, L) {
|
|
24
|
+
const i = c.impact;
|
|
25
|
+
if (!i)
|
|
26
|
+
return L("Too early to tell: no earlier records.", "還看不出來:調整前沒有紀錄。");
|
|
27
|
+
const notes = [];
|
|
28
|
+
if (i.smallSample)
|
|
29
|
+
notes.push(L("too few sessions", "樣本太少"));
|
|
30
|
+
else if (rs.some((r) => comparable(r) && Math.min(r.before.n, r.after.n) < 20)) {
|
|
31
|
+
notes.push(L("a reading is based on fewer than 20 observations", "有指標的樣本不到 20"));
|
|
32
|
+
}
|
|
33
|
+
if (i.incomplete)
|
|
34
|
+
notes.push(L(`less than ${i.window.days} days on one side`, `一側未滿 ${i.window.days} 天`));
|
|
35
|
+
if (!rs.some(comparable))
|
|
36
|
+
notes.push(L("no comparable readings", "沒有可比較的數字"));
|
|
37
|
+
const other = i.confounded ? L(`${num(i.confounded)} other changes in the same period`, `同期還有 ${num(i.confounded)} 筆別的調整`) + L("; we cannot tell which change mattered", ",無法分辨是哪一筆造成的") : "";
|
|
38
|
+
if (notes.length || other) {
|
|
39
|
+
return [notes.length ? L(`Too early to tell: ${notes.join("; ")}`, `還看不出來(${notes.join("、")})`) : "", other].filter(Boolean)
|
|
40
|
+
.join(" · ");
|
|
41
|
+
}
|
|
42
|
+
return rs.some((r) => comparable(r) && value(r, "before") !== value(r, "after"))
|
|
43
|
+
? L("An observable difference, not proof of cause.", "看得出變化,但不能證明原因。")
|
|
44
|
+
: L("No visible difference at this precision.", "依顯示精度,前後數字持平。");
|
|
45
|
+
}
|
|
46
|
+
export const eligible = (c) => c.kind === "pin" || c.kind === "model-routing" || (!!c.impact && !c.impact.smallSample);
|
|
47
|
+
export function select(m) {
|
|
48
|
+
const all = [...m.changes].sort((a, b) => b.at.localeCompare(a.at));
|
|
49
|
+
const candidates = all.filter(eligible);
|
|
50
|
+
const recent = candidates.filter((c) => Date.parse(c.at) >= Date.parse(all[0]?.at ?? "") - 7 * 86400000);
|
|
51
|
+
const lead = recent.find((c) => c.package === "pi-anchorloop" && (c.impact?.before.anchor_before_first_edit.n ?? 0) >= 20 &&
|
|
52
|
+
(c.impact?.after.anchor_before_first_edit.n ?? 0) >= 20) ??
|
|
53
|
+
candidates.find((c) => c.impact && !c.impact.smallSample) ?? candidates[0];
|
|
54
|
+
const rest = candidates.filter((c) => c !== lead && c.at <= lead.at && (!lead.sha || c.sha !== lead.sha));
|
|
55
|
+
const second = rest.find((c) => c.impact?.smallSample && c.impact.before.sessions && c.impact.after.sessions) ??
|
|
56
|
+
rest.find((c) => (c.kind === "pin" || c.kind === "model-routing") && c.impact && !c.impact.incomplete) ?? rest[0];
|
|
57
|
+
const highlighted = all.filter((c) => c === lead || c === second);
|
|
58
|
+
return { all, lead, highlighted, folded: all.filter((c) => !highlighted.includes(c)) };
|
|
59
|
+
}
|
|
60
|
+
/** Editorial choices shared by the HTML timeline and the compact query. */
|
|
61
|
+
export function overview(m, lang) {
|
|
62
|
+
const selected = select(m), { lead, all } = selected, L = words(lang);
|
|
63
|
+
const rs = lead ? readings(lead, m, lang) : [];
|
|
64
|
+
const headline = lead ? finding(lead, rs, L) : all.length
|
|
65
|
+
? L("Not enough sessions to compare changes yet", "這批調整的工作段數還不夠比較")
|
|
66
|
+
: L("No changes recorded in this period", "這段期間沒有調整紀錄");
|
|
67
|
+
const i = lead?.impact;
|
|
68
|
+
const trust = i?.incomplete && i.confounded && !i.smallSample ? L(`There were ${num(i.confounded)} other changes, and one side has less than ${i.window.days} days of data. We cannot credit this change alone.`, `同期還有 ${num(i.confounded)} 筆別的調整,一側的資料也未滿 ${i.window.days} 天;目前不能把差異歸給這次調整。`) : lead ? verdict(lead, rs, L) : L(`There are ${num(m.totals.sessions)} sessions in this report, but no eligible comparison.`, `報表收錄 ${num(m.totals.sessions)} 段工作,目前沒有適合放在首頁的比較。`);
|
|
69
|
+
return { ...selected, headline, trust };
|
|
70
|
+
}
|
|
71
|
+
export function finding(c, rs, L) {
|
|
72
|
+
const r = rs.find(comparable);
|
|
73
|
+
if (!r)
|
|
74
|
+
return L("There are not enough records to compare this change", "這次調整還沒有足夠紀錄可比較");
|
|
75
|
+
const dir = value(r, "before") === value(r, "after")
|
|
76
|
+
? L(" held steady", "持平")
|
|
77
|
+
: r.after.value > r.before.value
|
|
78
|
+
? L(" rose", "上升")
|
|
79
|
+
: L(" fell", "下降");
|
|
80
|
+
const label = r.key === "anchor_before_first_edit" ? L("The share naming a check before editing", "先說驗證方法的比例") : r.label;
|
|
81
|
+
return `${label}${dir}${c.impact?.confounded || c.impact?.smallSample || c.impact?.incomplete || Math.min(r.before.n, r.after.n) < 20
|
|
82
|
+
? L("; the reason is unclear", ",原因還不明")
|
|
83
|
+
: ""}`;
|
|
84
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const words = (lang) => (en, zh) => lang === "zh" ? zh : en;
|
|
2
|
+
export const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
3
|
+
const formatter = new Intl.NumberFormat("en-US");
|
|
4
|
+
export const num = (n) => formatter.format(n);
|
|
5
|
+
export const pct = (r) => r?.value != null ? `${(100 * r.value).toFixed(1)}%` : "—";
|
|
6
|
+
export const usd = (v) => v == null ? "—" : `$${v.toFixed(2)}`;
|
|
7
|
+
export const duration = (v) => v == null ? "—" : v < 1000 ? `${v} ms` : v < 60_000 ? `${(v / 1000).toFixed(1)} s` : `${(v / 60_000).toFixed(1)} min`;
|
|
8
|
+
export const stamp = (at) => `${at.slice(5, 10).replace("-", ".")} ${at.slice(11, 16)}`;
|
|
9
|
+
export const title = (c) => c.package ? `${c.package} ${c.from ?? "∅"} → ${c.to ?? "∅"}` : c.subject;
|
|
10
|
+
/** Cells are text, never markup. */
|
|
11
|
+
export function table(headers, rows, L) {
|
|
12
|
+
if (!rows.length)
|
|
13
|
+
return `<p class="muted">${L("No records in this period.", "這段期間沒有紀錄。")}</p>`;
|
|
14
|
+
const cell = (x) => esc(typeof x === "number" ? num(x) : x);
|
|
15
|
+
return `<div class="scroll"><table><thead><tr>${headers.map((h) => `<th scope="col">${esc(h)}</th>`).join("")}</tr></thead><tbody>${rows.map((r) => `<tr>${r.map((c) => `<td>${cell(c)}</td>`).join("")}</tr>`).join("")}</tbody></table></div>`;
|
|
16
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { lesson, selfCheck } from "./concepts.js";
|
|
2
|
+
import { duration, esc, num, pct, table, usd, words } from "./format.js";
|
|
3
|
+
export function sections(m, lang, cards) {
|
|
4
|
+
const L = words(lang), meta = m.meta.metrics;
|
|
5
|
+
const label = (id) => meta[id].label[lang];
|
|
6
|
+
const T = (head, rows) => table(head, rows, L);
|
|
7
|
+
const section = (id, title, intro, body) => `<section id="${id}" class="topic"><p class="eyebrow">PI-EVALS / ${L("Field notes", "工作紀錄")}</p><h2>${title}</h2><p class="intro">${esc(intro)}</p>${body}</section>`;
|
|
8
|
+
const more = (title, html) => `<details><summary>${esc(title)}</summary>${html}</details>`;
|
|
9
|
+
const daily = (values) => T([L("Date (UTC)", "日期(UTC)"), L("Value", "數值")], m.series.days.map((d, i) => [d, values[i]]));
|
|
10
|
+
const entries = (map) => Object.entries(map);
|
|
11
|
+
const sk = m.skills, a = m.askUser, mon = m.monitors, s = m.subagents;
|
|
12
|
+
const skills = section("skills", L("Which skills got opened?", "哪些技能真的有人打開?"), meta.skill_loads.meaning[lang], `<div class="pair"><article class="panel"><h3>${L("Most used", "最常載入")}</h3>${T([L("Skill", "技能"), L("Loads", "次數"), L("Sessions", "工作段數")], sk.top.slice(0, 8).map((r) => [r.name, r.loads, r.sessions]))}</article><article class="panel tint"><h3>${L("Offered but never opened", "有提供,但沒人載入")}</h3><p class="big">${num(sk.neverLoaded.length)} / ${num(sk.offered)}</p><p>${esc(meta.never_loaded.howComputed[lang])}</p>${more(L("Skill names", "看技能名稱"), `<p>${sk.neverLoaded.map(esc).join("、") || "—"}</p>`)}</article></div>` +
|
|
13
|
+
more(L("Loads by day, project and trigger", "查看每日載入、各專案與載入方式"), daily(m.series.skillLoads) +
|
|
14
|
+
T([L("Project", "專案"), L("Skill", "技能"), L("Loads", "次數")], sk.byProject.map((r) => [r.project, r.skill, r.loads])) +
|
|
15
|
+
T([L("Trigger", "方式"), L("Loads", "次數")], entries(sk.triggers))));
|
|
16
|
+
const packages = section("packages", L("Packages and tools", "套件與工具"), meta.package_calls.meaning[lang], T([L("Package", "套件"), L("Version", "版本"), L("Calls", "呼叫次數"), label("tool_error_rate"), label("avg_duration_ms")], m.packages.map((r) => [r.owner, r.version ?? "—", r.calls, pct(r.errorRate), duration(r.avgMs)])) +
|
|
17
|
+
more(L("Tools by calls", "依呼叫次數查看工具"), T([L("Tool", "工具"), L("Package", "套件"), L("Calls", "次數"), label("tool_error_rate")], m.tools.map((r) => [r.name, r.owner, r.calls, pct(r.errorRate)]))));
|
|
18
|
+
const ask = section("ask", L("When the agent stopped to ask", "代理人何時停下來問你"), L("See how often you were asked, how long an answer took and how often you dismissed the question.", "這裡可以看到代理人問了幾次、答一題平均要等多久,以及你取消了多少提問。"), T([L("Measure", "指標"), L("Reading", "數值"), L("Counted", "計算次數")], [[label("ask_calls"), a.calls, a.calls], [
|
|
19
|
+
label("ask_wait_ms"),
|
|
20
|
+
duration(a.avgWaitMs),
|
|
21
|
+
a.waitN,
|
|
22
|
+
], [label("ask_cancel_rate"), pct(a.cancelRate), a.cancelRate.n]]) +
|
|
23
|
+
more(L("Wait times and answer sources", "查看等待時間分布與回答來源"), T([L("Wait", "等待時間"), L("Count", "次數")], a.buckets.map((b, i) => [
|
|
24
|
+
b.upToMs == null
|
|
25
|
+
? `≥ ${duration(a.buckets[i - 1]?.upToMs ?? 0)}`
|
|
26
|
+
: `${duration(i ? a.buckets[i - 1].upToMs : 0)} – < ${duration(b.upToMs)}`,
|
|
27
|
+
b.n,
|
|
28
|
+
])) + T([L("Source", "來源"), L("Count", "次數")], entries(a.sources))));
|
|
29
|
+
const monitors = section("monitors", L("Background jobs", "背景工作"), meta.monitor_outcomes.meaning[lang], `<p>${L("Started", "啟動")} ${num(mon.started)} / ${L("Ending recorded", "有結束紀錄")} ${num(mon.finished)} / ${label("monitor_duration_ms")} ${duration(mon.avgMs)}(${num(mon.durationN)})</p>${T([L("Outcome", "結果"), L("Count", "次數")], entries(mon.statuses))}<p class="muted">${esc(meta.monitor_outcomes.howComputed[lang])}</p>`);
|
|
30
|
+
const sub = section("subagents", L("Work handed to other agents", "交給子代理的工作"), meta.subagent_launches.meaning[lang], T([L("Role", "角色"), L("Model", "模型"), L("Launches", "啟動次數")], s.launches.slice(0, 40).map((r) => [r.role, r.model, r.n])) +
|
|
31
|
+
more(label("subagent_cost"), T([L("Role", "角色"), L("USD", "美元")], s.costByRole.map((r) => [r.role, usd(r.cost)]))) +
|
|
32
|
+
`<p>${L("Linked to a parent in this period", "這段期間能對回母工作階段的子代理")}:${s.linked === null ? L("Run /evals extract for this breakdown.", "請執行 /evals extract 更新分期統計。") : `${num(s.linked)} / ${num(s.subagentTotal)}`} </p>`);
|
|
33
|
+
const process = section("process", L("Did the agent follow the steps?", "工作有沒有照說好的步驟走?"), L(`Only sessions starting from ${m.process.eraStart} are judged. Earlier work is not a failure.`, `只檢查 ${m.process.eraStart} 起的工作;更早的工作不算失敗。`), lesson(cards.check, L) + `<div class="pair checks">${m.process.detectors.map((d) => {
|
|
34
|
+
const md = m.meta.detectors[d.name];
|
|
35
|
+
return `<article class="panel"><p class="eyebrow">${L("Code check", "程式檢查")} / ${L("higher is better", "越高越好")}</p><h3>${esc(md.label[lang])}</h3><p class="big">${pct(d.passRate)} <small>${num(d.pass)} / ${num(d.passRate.n)} ${L("sessions", "段")}</small></p><p>${esc(md.howComputed[lang])}</p><p><b>${L("Pass", "通過")}</b> ${esc(md.example.pass[lang])}<br><b>${L("Fail", "未通過")}</b> ${esc(md.example.fail[lang])}</p>${more(L("By day and version", "查看每日與各版本的通過數"), T([L("Day", "日期"), L("Pass", "通過"), L("Fail", "未通過")], d.perDay.map((r) => [r.day, r.pass, r.fail])) +
|
|
36
|
+
T([L("Version", "版本"), L("Pass", "通過"), L("Fail", "未通過")], d.byVersion.map((r) => [r.version, r.pass, r.fail])))}</article>`;
|
|
37
|
+
}).join("")}</div>` +
|
|
38
|
+
more(L("Close-guard reminders", "收尾提醒"), T([L("Kind", "種類"), L("Count", "次數")], entries(m.process.notices).map(([k, n]) => [m.meta.notices[k]?.[lang] ?? k, n]))));
|
|
39
|
+
const cost = section("cost", L("What the work cost", "工作花了多少錢"), meta.cost.meaning[lang], `<p class="big">${usd(m.cost.total)} <small>USD</small></p><p>${label("cost_per_session")} ${usd(m.cost.perSession.value)}(${num(m.cost.perSession.n)} ${L("sessions", "段")})</p><p>${esc(meta.skill_cost.meaning[lang])}</p>` +
|
|
40
|
+
T([L("Skill", "技能"), L("USD", "美元"), L("Sessions", "工作段數")], m.cost.bySkill.map((r) => [r.skill, usd(r.cost), r.sessions])) +
|
|
41
|
+
more(L("Daily spend and model replies", "查看每日費用與各模型回覆數"), daily(m.series.cost) + T([L("Model", "模型"), L("Replies", "回覆數")], m.cost.byModel.map((r) => [r.model, r.replies]))));
|
|
42
|
+
const cov = m.coverage;
|
|
43
|
+
const coverage = section("coverage", L("When is cleanup safe?", "何時可以開啟清理?"), L("Only consider cleanup when all old files match the index, by both file count and bytes. This report never deletes a file.", "所有舊檔的大小和修改時間都要和索引相符,未建索引的檔案數和位元組數都歸零,才考慮開啟清理。報表不會刪檔。"), cov
|
|
44
|
+
? `<p>${L("Files modified in the selected dates, indexed (all projects)", "選定日期內有修改的檔案,已建索引(全部專案)")}:${num(cov.inRange?.indexed ?? 0)} / ${num(cov.inRange?.files ?? 0)}</p><p>${L("Cleanup gate across all dates", "清理門檻不分日期")} · ${L("Inactive days", "閒置天數")} > ${cov.cutDays} / ${L("Files indexed", "已建索引")} ${num(cov.indexed.files)} / ${num(cov.old.files)}</p><p>${L("Not indexed", "未建索引")}:${num(cov.notIndexed.files)} ${L("files", "個檔案")} · ${num(cov.notIndexed.bytes)} bytes</p>`
|
|
45
|
+
: `<p>${L("Coverage not measured; keep cleanup off.", "沒有索引覆蓋資料,請勿開啟清理。")}</p>`);
|
|
46
|
+
const labels = section("labels", L("Your labels", "你的標記"), meta.agreement.meaning[lang], m.labels.needsIndex ? `<p>${L("Run /evals extract to count labels in this period.", "請執行 /evals extract 以計算這段期間的標記。")}</p>` : m.labels.present && m.labels.n
|
|
47
|
+
? T([L("Check", "檢查"), L("Labelled", "已標記"), L("Agreement", "一致比例")], m.labels.agreement.map((r) => [m.meta.detectors[r.detector]?.label[lang] ?? r.detector, r.n, pct(r.rate)]))
|
|
48
|
+
: `<p>${L("No labels yet. In phase 2 you will judge sessions yourself and compare your answers with the code checks.", "還沒有標記。第二階段會讓你親自判讀工作紀錄,再對照程式與你的判斷是否一致。")}</p>`);
|
|
49
|
+
return [
|
|
50
|
+
skills,
|
|
51
|
+
packages,
|
|
52
|
+
ask,
|
|
53
|
+
monitors,
|
|
54
|
+
sub,
|
|
55
|
+
process,
|
|
56
|
+
cost,
|
|
57
|
+
coverage,
|
|
58
|
+
labels,
|
|
59
|
+
section("concepts", L("Concepts", "概念"), L("Use these five ideas when you read the next report.", "下次讀報表時,可以用這五個概念判讀數字。"), `<div class="notes-grid">${Object.values(cards).map((c) => lesson(c, L)).join("")}</div>${selfCheck(L)}`),
|
|
60
|
+
].join("");
|
|
61
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { esc, num, words } from "./format.js";
|
|
2
|
+
const KINDS = ["pin", "model-routing", "rule", "agent-role", "skill", "manual"];
|
|
3
|
+
/** Dense time slots get a count; every change still has its own mark and title. */
|
|
4
|
+
export function changeStrip(m, all, picks, ids, lang, range) {
|
|
5
|
+
const L = words(lang), label = (k) => m.meta.changeKinds[k][lang];
|
|
6
|
+
const period = typeof range === "number" ? L(`Last ${range} days`, `近 ${range} 天`) : range === "all" ? L("All time", "全部期間") : L("Selected dates", "選定期間");
|
|
7
|
+
const since = m.window.since ?? "", until = m.window.until ?? "", start = Date.parse(since), span = Date.parse(until) + 86400000 - start;
|
|
8
|
+
const x = (c) => 16 + Math.min(1, Math.max(0, (Date.parse(c.at) - start) / span)) * 968;
|
|
9
|
+
const bins = new Map(), counts = new Map();
|
|
10
|
+
for (const c of all) {
|
|
11
|
+
const slot = Math.floor((x(c) - 16) / 30), cells = bins.get(slot) ?? [];
|
|
12
|
+
cells.push(c);
|
|
13
|
+
bins.set(slot, cells);
|
|
14
|
+
counts.set(c.kind, (counts.get(c.kind) ?? 0) + 1);
|
|
15
|
+
}
|
|
16
|
+
const short = { pin: "版本", "model-routing": "模型路由", rule: "規則", "agent-role": "角色", skill: "skill", manual: "手動" };
|
|
17
|
+
const breakdown = KINDS.map(k => `${L(label(k), short[k])} ${num(counts.get(k) ?? 0)}`).join(L(", ", "、"));
|
|
18
|
+
const total = L(`${period}: ${num(all.length)} changes: ${breakdown}; ${picks.length} worth a closer look.`, `${period}共 ${num(all.length)} 筆調整:${breakdown};其中 ${picks.length} 筆值得回看。`);
|
|
19
|
+
const legend = KINDS.map(k => `<span><i class="key kind-${k}"></i>${esc(label(k))}: ${num(counts.get(k) ?? 0)}</span>`).join("");
|
|
20
|
+
const base = 64, marks = [], labeled = new Map();
|
|
21
|
+
for (const [slot, cells] of bins) {
|
|
22
|
+
cells.reverse(); // Earliest mark at the left of a dense slot.
|
|
23
|
+
const left = 16 + slot * 30, columns = Math.ceil(cells.length / 5);
|
|
24
|
+
cells.forEach((c, i) => {
|
|
25
|
+
const px = cells.length <= 5 ? x(c) : left + (Math.floor(i / 5) + .5) * 28 / columns;
|
|
26
|
+
const py = base - 6 - i % 5 * 5;
|
|
27
|
+
const dot = `<circle class="change-mark kind-${c.kind}" cx="${px.toFixed(1)}" cy="${py}" r="${Math.min(2.4, 13 / columns)}"><title>${esc(c.at)} · ${esc(label(c.kind))}</title></circle>`;
|
|
28
|
+
if (picks.includes(c))
|
|
29
|
+
labeled.set(c, { px, py, dot });
|
|
30
|
+
else
|
|
31
|
+
marks.push(dot);
|
|
32
|
+
});
|
|
33
|
+
if (cells.length > 5)
|
|
34
|
+
marks.push(`<text class="slot-count" x="${left + 14}" y="28" text-anchor="middle">×${cells.length}</text>`);
|
|
35
|
+
}
|
|
36
|
+
const links = picks.map((c, i) => {
|
|
37
|
+
const { px, py, dot } = labeled.get(c), end = px > 700, caption = c.package ? `${c.package} ${c.to ?? ""}` : `${label(c.kind)} · ${c.at.slice(5, 16).replace("T", " ")}`;
|
|
38
|
+
const y = 87 + i * 23;
|
|
39
|
+
return `<a href="#${ids.get(c)}"><title>${esc(caption)}</title><path class="guide" d="M${px} ${py}V${y - 6}h${end ? -7 : 7}"/>${dot}<text x="${px + (end ? -10 : 10)}" y="${y}" text-anchor="${end ? "end" : "start"}">${esc(Array.from(caption).length > 48 ? Array.from(caption).slice(0, 47).join("") + "…" : caption)}</text></a>`;
|
|
40
|
+
}).join("");
|
|
41
|
+
return `<section class="change-strip"><h2>${total}</h2><div class="kind-key">${legend}</div><svg viewBox="0 0 1000 ${base + 14 + picks.length * 23}" aria-label="${esc(total)}"><path class="axis" d="M16 ${base}H984"/>${marks.join("")}${links}</svg><div class="ends"><span>${esc(since)}</span><span>${esc(until)} UTC</span></div></section>`;
|
|
42
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** Embedded in report.html so the page also works when copied or opened offline. */
|
|
2
|
+
export const css = `
|
|
3
|
+
:root {
|
|
4
|
+
color-scheme:light dark; --bg:#f9faf6; --paper:#fff; --ink:#172e36; --sub:#4f6366;
|
|
5
|
+
--green:#16665c; --line:#cdd8d3; --tint:#e4f1eb; --area:#dceae3; --warm:#855126; --accent:#16665c;
|
|
6
|
+
}
|
|
7
|
+
@media(prefers-color-scheme:dark) { :root {
|
|
8
|
+
--bg:#152320; --paper:#1e302d; --ink:#ebf5ef; --sub:#bdcfc8; --green:#98dcca;
|
|
9
|
+
--line:#465d56; --tint:#243e36; --area:#355348; --warm:#eabc90;
|
|
10
|
+
} }
|
|
11
|
+
* {box-sizing:border-box}
|
|
12
|
+
body {margin:0 auto;max-width:1280px;padding:0 clamp(18px,4.375vw,56px);background:var(--bg);color:var(--ink);
|
|
13
|
+
font:17px/1.58 -apple-system,BlinkMacSystemFont,"PingFang TC","Noto Sans TC","Segoe UI",sans-serif;
|
|
14
|
+
font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
|
|
15
|
+
a,summary {color:var(--green)}
|
|
16
|
+
a:focus-visible,summary:focus-visible {outline:3px solid var(--warm);outline-offset:3px}
|
|
17
|
+
header,.hero,.topic {border-bottom:1px solid var(--line)}
|
|
18
|
+
header,footer,.ends,.ruler-head,.reading {display:flex;align-items:center;justify-content:space-between;gap:12px}
|
|
19
|
+
header {min-height:75px;flex-wrap:wrap}
|
|
20
|
+
.brand {display:flex;align-items:center;gap:12px;text-decoration:none;color:var(--ink);font-size:21px;font-weight:700}
|
|
21
|
+
.brand span {font-size:17px;font-weight:400;padding-left:20px;margin-left:16px;border-left:1px solid var(--line);color:var(--sub)}
|
|
22
|
+
small,.muted,.intro,.deck,.ends {color:var(--sub)}
|
|
23
|
+
small,.muted,.ends,summary,.footline,.button {font-size:15px}
|
|
24
|
+
.ranges,.ranges nav {display:flex;align-items:center;gap:6px;flex-wrap:wrap}.ranges {justify-content:space-between;margin-top:18px}
|
|
25
|
+
.ranges a {padding:5px 12px;text-decoration:none;border-radius:6px}.ranges a[aria-current] {background:var(--tint);font-weight:700}
|
|
26
|
+
.hero {padding:36px 0 20px}
|
|
27
|
+
.hero h1,.hero-title {font-size:clamp(29px,3.125vw,40px);line-height:1.25;margin:18px 0}
|
|
28
|
+
.deck,.intro {font-size:19px;margin:0}.hero .deck+.deck {margin-top:24px}
|
|
29
|
+
.eyebrow {font-size:14px;font-weight:650;letter-spacing:1px;color:var(--green);margin:0}
|
|
30
|
+
.stale,.verdict {color:var(--warm)}
|
|
31
|
+
h2 {font-size:25px;line-height:1.35;margin:0 0 14px}
|
|
32
|
+
h3,.big {font-size:29px;line-height:1.35;margin:14px 0 18px}
|
|
33
|
+
.spine {padding-top:25px}
|
|
34
|
+
.layout {display:grid;grid-template-columns:minmax(0,709fr) minmax(0,419fr);gap:40px;align-items:start}
|
|
35
|
+
.rail {position:relative;padding-left:54px}
|
|
36
|
+
.rail:before {content:"";position:absolute;left:22px;top:20px;bottom:20px;border-left:2px solid var(--line)}
|
|
37
|
+
.card,.panel,.lesson {background:var(--paper);border:1px solid var(--line);border-radius:12px;padding:22px 25px}
|
|
38
|
+
.card {position:relative;padding-block:19px 17px}.card+.card {margin-top:30px}
|
|
39
|
+
.card:before,.ruler i {width:10px;height:10px;background:var(--green);border:3px solid var(--bg);outline:2px solid var(--green);border-radius:50%}
|
|
40
|
+
.card:before {content:"";position:absolute;left:-37px;top:31px}
|
|
41
|
+
.card h3 {margin:9px 0 14px}.reading {line-height:1.45;margin:12px 0}.card .reading {margin:9px 0}
|
|
42
|
+
.reading b {font-size:18px}.reading small {flex-shrink:0}.card .muted {margin:9px 0}
|
|
43
|
+
.button {display:inline-block;padding:9px 22px;border-radius:8px;background:var(--accent);color:white;text-decoration:none;margin-top:3px;min-width:156px;text-align:center}
|
|
44
|
+
.workload h2 {margin-bottom:0}.workload h3 {margin:25px 0 12px}.workload .muted {margin:5px 0}
|
|
45
|
+
.workload svg {width:100%;height:auto;display:block;margin-top:8px}
|
|
46
|
+
.area {fill:var(--area)}.trend {stroke:var(--green);stroke-width:2.5;stroke-linejoin:round;fill:none}
|
|
47
|
+
.ends {margin:4px 0}
|
|
48
|
+
.change-strip {margin:18px 0 0;padding:12px 0;border-block:1px solid var(--line)}.change-strip h2 {font-size:19px;margin:0 0 6px}
|
|
49
|
+
.kind-key {display:flex;flex-wrap:wrap;gap:4px 16px;font-size:14px;color:var(--sub)}.key {display:inline-block;width:.7em;height:.7em;border-radius:100%;background:var(--kind);margin-right:5px}
|
|
50
|
+
.kind-pin {--kind:#3b9090}.kind-model-routing {--kind:#736cc9}.kind-rule {--kind:#c78231}.kind-agent-role {--kind:#c16c89}.kind-skill {--kind:#718c40}.kind-manual {--kind:#477dac}
|
|
51
|
+
.change-mark,.work-mark {fill:var(--kind)}.change-strip svg {width:100%;display:block}.change-strip .axis,.change-strip .guide {stroke:var(--line);fill:none}
|
|
52
|
+
.change-strip .slot-count {fill:var(--sub);font:12px sans-serif}.change-strip a text {fill:var(--green);font-size:14px;text-decoration:underline}
|
|
53
|
+
@media(max-width:640px){.change-strip {overflow-x:auto}.change-strip svg {min-width:600px}}
|
|
54
|
+
.footline {border-top:1px solid var(--line);padding-top:13px;margin:12px 0 0}
|
|
55
|
+
.lesson,.tint,.after {background:var(--tint)}.lesson {padding:16px 19px}.lesson p {margin:5px 0 0}.side>.lesson {margin-top:16px}
|
|
56
|
+
.topic {padding:38px 0}.topic h2 {margin:9px 0}.intro {margin:0 0 18px}
|
|
57
|
+
.jump {display:flex;flex-wrap:wrap;gap:8px 18px;padding:20px 0;border-block:1px solid var(--line);margin:32px 0 0}
|
|
58
|
+
.day li {margin:.45rem 0}.day time {color:var(--sub)}details {margin:12px 0}summary {cursor:pointer;font-weight:600}
|
|
59
|
+
.scroll {overflow-x:auto}table {width:100%;border-collapse:collapse;margin:.4rem 0;background:var(--paper)}
|
|
60
|
+
th,td {text-align:start;padding:7px 12px;border-bottom:1px solid var(--line)}th {font-size:15px;color:var(--green)}
|
|
61
|
+
.pair,.notes-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}
|
|
62
|
+
.checks {margin-top:18px}.checks h3,.topic .panel h3 {font-size:22px}
|
|
63
|
+
.detail {display:none;padding-bottom:24px;scroll-margin-top:75px}.detail:target {display:block;outline:none}
|
|
64
|
+
body:has(.detail:target) main {display:none}.back {float:right;font-size:15px}
|
|
65
|
+
.ruler-head {margin:30px 0 24px}.ruler-head h2 {margin:0}
|
|
66
|
+
.ruler {position:relative;list-style:none;margin:0 0 30px;padding:0;height:86px}
|
|
67
|
+
.ruler:before,.ruler.partial:after {content:"";position:absolute;top:39px;left:6%;right:6%;height:2px;background:var(--green)}
|
|
68
|
+
.ruler.partial:after {left:65.5%;right:6.5%;background:var(--bg);border-top:2px dashed var(--line)}
|
|
69
|
+
.ruler li {position:absolute;width:118px;transform:translateX(-50%);text-align:center;font-size:15px;color:var(--sub)}
|
|
70
|
+
.ruler li:first-child {left:6%}.ruler li:nth-child(2) {left:50%}.ruler li:nth-child(3) {left:65%}.ruler li:last-child {left:94%}
|
|
71
|
+
.ruler time {color:var(--green);white-space:nowrap}.ruler i {display:block;position:relative;margin:11px auto}
|
|
72
|
+
.compare h3 {border-bottom:1px solid var(--line);padding-bottom:12px}.compare .reading {min-height:32px}.detail>.eyebrow {margin-bottom:8px}
|
|
73
|
+
.notes-grid {margin:16px 0}.notes-grid .lesson {font-size:16px}
|
|
74
|
+
footer {font-size:14px;margin-top:24px;padding:18px 0 25px;color:var(--sub);border-top:1px solid var(--line)}
|
|
75
|
+
@media(max-width:850px) {
|
|
76
|
+
.layout,.pair,.notes-grid {grid-template-columns:1fr}.layout {gap:22px}.rail {padding-left:27px}.rail:before {left:7px}.card:before {left:-26px}
|
|
77
|
+
.reading {flex-wrap:wrap}.ruler-head,footer {align-items:flex-start;flex-direction:column}
|
|
78
|
+
}
|
|
79
|
+
@media(max-width:640px) {
|
|
80
|
+
header {padding:12px 0;gap:5px}.hero {padding:24px 0}.brand span {margin-left:4px;padding-left:10px}
|
|
81
|
+
.card,.panel {padding:16px}.ruler {height:auto}.ruler:before,.ruler:after,.ruler li i {display:none}
|
|
82
|
+
.ruler li {position:static;width:auto;transform:none;display:flex;align-items:center;gap:8px;text-align:left}
|
|
83
|
+
.card h3 {font-size:23px}.back {float:none;display:block;margin-bottom:8px}
|
|
84
|
+
}
|
|
85
|
+
`;
|