pi-evals 0.1.0 → 0.2.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 +7 -0
- package/README.md +13 -3
- package/dist/index.js +8 -3
- package/dist/render.js +30 -171
- package/dist/report/concepts.js +37 -0
- package/dist/report/findings.js +73 -0
- package/dist/report/format.js +16 -0
- package/dist/report/sections.js +61 -0
- package/dist/report/style.js +77 -0
- package/dist/report/timeline.js +91 -0
- package/dist/report/week.js +36 -0
- package/docs/design.md +11 -0
- package/docs/learn.zh-TW.md +33 -0
- package/package.json +2 -2
- package/src/index.ts +8 -3
- package/src/render.ts +62 -188
- package/src/report/concepts.ts +94 -0
- package/src/report/findings.ts +84 -0
- package/src/report/format.ts +24 -0
- package/src/report/sections.ts +188 -0
- package/src/report/style.ts +77 -0
- package/src/report/timeline.ts +143 -0
- package/src/report/week.ts +55 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { concepts, lesson } from "./concepts.js";
|
|
2
|
+
import { finding, readings, select, value, verdict } from "./findings.js";
|
|
3
|
+
import { esc, num, stamp, title, words } from "./format.js";
|
|
4
|
+
function card(c, id, rs, L) {
|
|
5
|
+
const i = c.impact;
|
|
6
|
+
return `<article class="card"><p class="eyebrow"><time datetime="${esc(c.at)}">${esc(stamp(c.at))} UTC</time></p><h3>${esc(title(c))}</h3>${rs.map((r) => `<div class="reading"><b>${esc(r.label)} ${value(r, "before")} → ${value(r, "after")}</b><small>${num(r.before?.n ?? 0)} → ${num(r.after?.n ?? 0)} ${r.unit}</small></div>`).join("")}<p class="muted">${rs[0].direction === rs[1].direction
|
|
7
|
+
? L(`Both: ${rs[0].direction}.`, `兩項都${rs[0].direction}。`)
|
|
8
|
+
: rs.map((r) => `${r.label}:${r.direction}`).join(" · ")}${i ? ` ${num(i.before.sessions)} → ${num(i.after.sessions)} ${L("sessions.", "段工作。")}` : ""}<br><span class="verdict">${esc(verdict(c, rs, L))}</span></p><a class="button" href="#${id}">${L("Change details", "看調整明細")} →</a></article>`;
|
|
9
|
+
}
|
|
10
|
+
function ruler(c, last, L) {
|
|
11
|
+
const i = c.impact;
|
|
12
|
+
const cutoff = last && last > c.at && last < i.window.after.until ? last : null;
|
|
13
|
+
const points = [
|
|
14
|
+
[i.window.before.since, L("Before starts", "開始算調整前")],
|
|
15
|
+
[c.at, L("Change", "做了調整")],
|
|
16
|
+
...(cutoff ? [[cutoff, L("Last extract", "資料截至這裡")]] : []),
|
|
17
|
+
[i.window.after.until, L("After window ends", "調整後期間結束")],
|
|
18
|
+
];
|
|
19
|
+
return `<div class="ruler-head"><h2>${L(`Compare ${i.window.days} days on each side`, `同一條規則,前後各看 ${i.window.days} 天`)}</h2><small>${L("Grouped by start time · not to scale", "依工作開始時間分組 / 時間線不按比例繪製")}</small></div><ol class="ruler${cutoff ? " partial" : ""}">${points.map(([at, text]) => `<li><time>${esc(stamp(at))}</time><i></i><span>${text}</span></li>`).join("")}</ol>`;
|
|
20
|
+
}
|
|
21
|
+
function panel(c, side, rs, period, L) {
|
|
22
|
+
const i = c.impact;
|
|
23
|
+
return `<article class="panel compare ${side}"><p class="eyebrow">${side === "before" ? L("Before", "調整前") : L("After", "調整後")} / ${esc(period)}</p><h3>${num(i[side].sessions)} ${L("sessions", "段工作")}</h3>${rs.map((r) => {
|
|
24
|
+
const x = r[side];
|
|
25
|
+
const sample = x?.value != null
|
|
26
|
+
? (r.key === "cost_per_session" ? `${num(x.n)} ${r.unit}` : `${num(Math.round(x.value * x.n))} / ${num(x.n)} ${r.unit}`)
|
|
27
|
+
: L("no eligible records", "沒有適用紀錄");
|
|
28
|
+
return `<div class="reading"><span>${esc(r.label)}</span><b>${value(r, side)} <small>(${sample})</small></b></div>`;
|
|
29
|
+
}).join("")}</article>`;
|
|
30
|
+
}
|
|
31
|
+
function detail(c, id, rs, m, w, lang, siblings) {
|
|
32
|
+
const L = words(lang), i = c.impact, lessons = concepts(m, w, c, L);
|
|
33
|
+
const peers = siblings.filter((s) => s !== c);
|
|
34
|
+
const together = peers.length
|
|
35
|
+
? L(`Same commit: ${peers.map((s) => s.package ?? m.meta.changeKinds[s.kind][lang]).join(", ")}.`, `同一次提交也調整了 ${peers.map((s) => s.package ?? m.meta.changeKinds[s.kind][lang]).join("、")}。`)
|
|
36
|
+
: "";
|
|
37
|
+
const primary = rs[0];
|
|
38
|
+
const age = (Date.parse(m.freshness.lastExtract ?? "") - Date.parse(c.at)) / 3600000;
|
|
39
|
+
const partial = i?.incomplete && age >= 0 && age < i.window.days * 24;
|
|
40
|
+
const ageText = age < 1 ? L("less than an hour", "不到一小時") : L(`about ${Math.floor(age)} hours`, `約 ${Math.floor(age)} 小時`);
|
|
41
|
+
const heading = partial ? L(`Only ${ageText} since the change: too early to tell`, `調整後${ageText},還看不出效果`) : verdict(c, rs, L);
|
|
42
|
+
const fullPeriod = L(`${i?.window.days} days`, `${i?.window.days} 天`);
|
|
43
|
+
const beforePeriod = i?.incomplete ? L(`Planned: ${fullPeriod}`, `原定 ${fullPeriod}`) : fullPeriod;
|
|
44
|
+
return `<section class="detail" id="${id}" tabindex="-1"><div class="hero"><a class="back" href="#timeline">← ${L("Timeline", "回時間軸")}</a><p class="eyebrow">${L("Architecture change", "架構調整明細")} / ${esc(stamp(c.at))} UTC</p><h2 class="hero-title">${esc(heading)}</h2><p class="deck">${esc(title(c))} ${esc(together)}</p>${i
|
|
45
|
+
? `<p class="deck">${esc(primary.label)}:${value(primary, "before")} → ${value(primary, "after")}。 ${esc(verdict(c, rs, L))}</p>`
|
|
46
|
+
: ""}</div>
|
|
47
|
+
${i
|
|
48
|
+
? `${ruler(c, m.freshness.lastExtract, L)}<p class="eyebrow">${L("Records side by side", "紀錄對照")}</p><h2>${L("Compare the two groups", "比較兩個時段的工作")}</h2><div class="pair">${panel(c, "before", rs, beforePeriod, L)}${panel(c, "after", rs, partial ? ageText : fullPeriod, L)}</div><p>${rs.map((r) => `${esc(r.label)}:${r.direction}`).join(" / ")}</p>`
|
|
49
|
+
: ""}
|
|
50
|
+
<div class="notes-grid">${lesson(lessons.sample, L)}${lesson(lessons.confounding, L)}${c.package === "pi-anchorloop" ? lesson(lessons.check, L) : ""}</div><p class="muted">${esc(c.repo)} ${esc(c.sha)} ${esc(c.subject)}</p><a href="#timeline">← ${L("Timeline", "回時間軸")}</a></section>`;
|
|
51
|
+
}
|
|
52
|
+
export function timeline(m, w, lang) {
|
|
53
|
+
const L = words(lang), { all, lead, highlighted, folded } = select(m);
|
|
54
|
+
const ids = new Map(all.map((c, i) => [c, `change-${i + 1}`]));
|
|
55
|
+
const metrics = new Map(all.map((c) => [c, readings(c, m, lang)]));
|
|
56
|
+
const byDay = new Map(), byCommit = new Map();
|
|
57
|
+
for (const c of folded) {
|
|
58
|
+
const d = c.at.slice(0, 10);
|
|
59
|
+
if (!byDay.has(d))
|
|
60
|
+
byDay.set(d, []);
|
|
61
|
+
byDay.get(d).push(c);
|
|
62
|
+
}
|
|
63
|
+
for (const c of all) {
|
|
64
|
+
if (c.sha) {
|
|
65
|
+
const key = `${c.repo}/${c.sha}`;
|
|
66
|
+
if (!byCommit.has(key))
|
|
67
|
+
byCommit.set(key, []);
|
|
68
|
+
byCommit.get(key).push(c);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const headline = lead
|
|
72
|
+
? finding(lead, metrics.get(lead), L)
|
|
73
|
+
: all.length
|
|
74
|
+
? L("Not enough sessions to compare changes yet", "這批調整的工作段數還不夠比較")
|
|
75
|
+
: L("No changes recorded in this period", "這段期間沒有調整紀錄");
|
|
76
|
+
const reason = lead?.impact;
|
|
77
|
+
const trust = lead && reason?.incomplete && reason.confounded && !reason.smallSample
|
|
78
|
+
? L(`There were ${num(reason.confounded)} other changes, and one side has less than ${reason.window.days} days of data. We cannot credit this change alone.`, `同期還有 ${num(reason.confounded)} 筆別的調整,一側的資料也未滿 ${reason.window.days} 天;目前不能把差異歸給這次調整。`)
|
|
79
|
+
: lead
|
|
80
|
+
? verdict(lead, metrics.get(lead), L)
|
|
81
|
+
: L(`There are ${num(m.totals.sessions)} sessions in this report, but no eligible comparison.`, `報表收錄 ${num(m.totals.sessions)} 段工作,目前沒有適合放在首頁的比較。`);
|
|
82
|
+
return {
|
|
83
|
+
lead,
|
|
84
|
+
headline,
|
|
85
|
+
trust,
|
|
86
|
+
count: highlighted.length,
|
|
87
|
+
cards: highlighted.map((c) => card(c, ids.get(c), metrics.get(c), L)).join(""),
|
|
88
|
+
archive: [...byDay].map(([day, list]) => `<details class="day"><summary>${esc(day)} / ${num(list.length)} ${L("changes", "筆調整")}</summary><ul>${list.map((c) => `<li><time>${esc(c.at.slice(11, 16))}</time> <a href="#${ids.get(c)}">${esc(title(c))}</a></li>`).join("")}</ul></details>`).join(""),
|
|
89
|
+
details: all.map((c) => detail(c, ids.get(c), metrics.get(c), m, w, lang, byCommit.get(`${c.repo}/${c.sha}`) ?? [])).join(""),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { esc, num } from "./format.js";
|
|
2
|
+
/** Last seven calendar days ending on the last complete UTC day in the selected period. */
|
|
3
|
+
export function week(m) {
|
|
4
|
+
const last = m.freshness.lastExtract?.slice(0, 10);
|
|
5
|
+
if (!last || !m.window.until || !m.window.since)
|
|
6
|
+
return [];
|
|
7
|
+
const end = Math.min(Date.parse(last) - 86400000, Date.parse(m.window.until));
|
|
8
|
+
const rows = [];
|
|
9
|
+
for (let t = Math.max(end - 6 * 86400000, Date.parse(m.window.since)); t <= end; t += 86400000) {
|
|
10
|
+
const day = new Date(t).toISOString().slice(0, 10), i = m.series.days.indexOf(day);
|
|
11
|
+
rows.push({
|
|
12
|
+
day,
|
|
13
|
+
sessions: m.series.sessions[i] ?? 0,
|
|
14
|
+
calls: m.series.toolCalls[i] ?? 0,
|
|
15
|
+
loads: m.series.skillLoads[i] ?? 0,
|
|
16
|
+
changes: m.changes.filter((c) => c.at.startsWith(day)).length,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return rows;
|
|
20
|
+
}
|
|
21
|
+
export function workload(rows, L) {
|
|
22
|
+
const heading = `<h2>${L("This week’s workload", "這週的工作量")}</h2>`;
|
|
23
|
+
if (!rows.length)
|
|
24
|
+
return `<div class="panel">${heading}<p>${L("No complete recorded day yet.", "尚無完整一天的紀錄。")}</p></div>`;
|
|
25
|
+
const total = (key) => num(rows.reduce((n, r) => n + r[key], 0));
|
|
26
|
+
const max = Math.max(1, ...rows.map((r) => r.sessions));
|
|
27
|
+
const points = rows.map((r, i) => [5 + i * 348 / Math.max(1, rows.length - 1), 89 - 64 * r.sessions / max]);
|
|
28
|
+
const line = points.map((p) => p.join(",")).join(" ");
|
|
29
|
+
const md = (d) => d.slice(5).replace("-", ".");
|
|
30
|
+
const desc = rows.map((r) => `${r.day}: ${num(r.sessions)} ${L("sessions", "段工作")} · ${r.changes} ${L("changes", "筆調整")}`).join("; ");
|
|
31
|
+
return `<div class="panel workload">${heading}<p class="muted">${md(rows[0].day)}–${md(rows.at(-1).day)} / ${L("Volume is not quality", "多寡不代表好壞")}</p><h3>${total("sessions")} ${L("sessions", "段工作")}</h3><p class="muted">${L("Sessions per day · dashes mark changes", "每日工作段數 · 虛線表示當天有調整")}</p>
|
|
32
|
+
<svg role="img" aria-label="${esc(desc)}" viewBox="0 0 358 96"><polygon points="5,89 ${line} ${points.at(-1)[0]},89" class="area"/><polyline points="${line}" class="trend"/>${points.map(([x, y], i) => rows[i].changes
|
|
33
|
+
? `<path d="M${x} 12V89" class="marker"/><circle cx="${x}" cy="${y}" r="3.5" class="dot"><title>${esc(rows[i].day)}: ${rows[i].changes} ${L("changes", "筆調整")}</title></circle>`
|
|
34
|
+
: "").join("")}</svg>
|
|
35
|
+
<div class="ends"><span>${md(rows[0].day)} ${num(rows[0].sessions)}</span><span>${md(rows.at(-1).day)} ${num(rows.at(-1).sessions)}</span></div><p class="footline">${L("Tool calls", "工具呼叫")} ${total("calls")} / ${L("Skill loads", "讀取技能")} ${total("loads")}</p></div>`;
|
|
36
|
+
}
|
package/docs/design.md
CHANGED
|
@@ -82,6 +82,17 @@ The ReportModel holds every number with its n and window, and the plain-language
|
|
|
82
82
|
The HTML has no scripts, no network and no external assets, uses inline SVG, and follows the system's light or dark setting.
|
|
83
83
|
It renders in Traditional Chinese by default (`--lang en` for English).
|
|
84
84
|
|
|
85
|
+
Version 0.2.0 uses the timeline and comparison layouts selected on 2026-11-26.
|
|
86
|
+
The renderer makes the following editorial choices from the model, without consulting transcripts or fetching data:
|
|
87
|
+
|
|
88
|
+
- A pin or routing change qualifies for the front page even without a comparison; another change qualifies only if both windows have at least 20 sessions.
|
|
89
|
+
- The headline gives priority to a change to the process rules themselves: an anchorloop pin within seven days of the latest change with at least 20 applicable sessions on both sides of the anchor check. Otherwise take the newest qualifying comparison with enough sessions, then the newest qualifying change. With no candidate, report why there is nothing to compare.
|
|
90
|
+
- Show the lead and at most one earlier change from a different commit. Prefer a small sample with records on both sides (to show why the numbers might mislead), then a pin or routing change with a complete window, then the next eligible change. Order the cards by time. Keep every other entry in its UTC day’s disclosure, with a direct link to its detail; no truncation.
|
|
91
|
+
- For an anchorloop pin with two comparable readings of the anchor check, compare the two process rates. Otherwise use the package error rate when available on both sides, or the overall tool error rate, alongside cost per session. Rates use their own denominators, not the total session count. A missing value is a dash, not zero.
|
|
92
|
+
- The headline names the first comparable reading and whether it rose, fell or held steady at the displayed precision. A short window, small sample or overlapping change qualifies that observation. The verdict lists every applicable caveat, including a displayed reading based on fewer than 20 applicable observations on either side. Only a complete, unconfounded comparison with enough observations and a visible difference says there was an observable change. Even that is not a causal claim.
|
|
93
|
+
- The workload chart covers the last seven complete UTC dates in the report period (or fewer if the filter starts later), not seven nonempty days. Each marker means at least one change that day. Session and tool totals in the other sections still cover the selected report period.
|
|
94
|
+
- Each detail uses the model’s actual window and session counts. Dates with records may exceed seven in a seven-day window that starts mid-day. The ruler shows the last extract only when it falls inside the after window, and its segments are not to scale.
|
|
95
|
+
|
|
85
96
|
### Storage choices
|
|
86
97
|
|
|
87
98
|
JSON lines and JSON files, no database: the index is rebuilt from per-session summaries in about a second, and the reader needs no service (research §4: everything reduces to files plus one static page).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# 怎麼讀一次調整的結果
|
|
2
|
+
|
|
3
|
+
2026 年 11 月 25 日更新 pi-anchorloop 後,動手前先說好驗證方法的比例從 20.3% 降到 12.5%。
|
|
4
|
+
但報表產生時,新版才用了八個多小時。
|
|
5
|
+
以下數字取自當時的報表;下次抽取後,調整後的那一組還會變。
|
|
6
|
+
|
|
7
|
+
## 紀錄:當時做了什麼
|
|
8
|
+
|
|
9
|
+
代理人讀了一份技能說明,就留下一筆載入紀錄。
|
|
10
|
+
11 月 19 日至 25 日共計有 2,619 次技能載入;知道載入了幾次,不必知道對話裡說了什麼。
|
|
11
|
+
|
|
12
|
+
## 指標:用同一個算法數紀錄
|
|
13
|
+
|
|
14
|
+
同一週,按開始時間計算,共有 5,246 段工作。
|
|
15
|
+
工作段數是工作量的指標:一段工作載入三次技能,仍只有一段工作。
|
|
16
|
+
工作段數變多,不等於工作品質更好。
|
|
17
|
+
|
|
18
|
+
## 程式檢查:查得到先後,查不到方法好壞
|
|
19
|
+
|
|
20
|
+
調整後,有 6 段工作在改檔前就說好怎麼驗證,通過了這條檢查。
|
|
21
|
+
程式查的是「先說方法,再改檔」的順序;就算順序正確,那個方法也可能驗不到要修的問題。
|
|
22
|
+
|
|
23
|
+
## 前後比較與樣本數:哪幾段工作算進去了
|
|
24
|
+
|
|
25
|
+
以更新時間 16:46 UTC 為界,前面有 5,171 段工作,後面有 164 段。
|
|
26
|
+
後面這組只有 48 段適用「動手前先說好怎麼驗證」,所以 6 段通過是 6 / 48,也就是 12.5%,不是 6 / 164。
|
|
27
|
+
看另一條規則時,適用的工作不同,樣本數也會不同。
|
|
28
|
+
|
|
29
|
+
## 同期多個調整:原因還不能指給某個版本
|
|
30
|
+
|
|
31
|
+
同一段比較期間還有 76 筆別的調整。
|
|
32
|
+
如果規則和模型分派都改過,前後即使有差異,也不能只歸給套件更新。
|
|
33
|
+
等七天的資料收齊,可以重看比例;資料收齊本身不會排除其他調整的影響。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-evals",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Usage and process records for pi: how skills, packages, ask-user, monitors and subagents are used, back-filled from past sessions, with a static report and an evals_query tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"opentelemetry"
|
|
22
22
|
],
|
|
23
23
|
"bin": {
|
|
24
|
-
"pi-evals": "
|
|
24
|
+
"pi-evals": "dist/cli.js"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"src",
|
package/src/index.ts
CHANGED
|
@@ -50,14 +50,14 @@ export function createEvals(options: { env?: Env; spawnExtract?: typeof spawn; n
|
|
|
50
50
|
});
|
|
51
51
|
let running: Promise<void> | undefined;
|
|
52
52
|
|
|
53
|
-
const extractInChild = (ctx: ExtensionCommandContext): Promise<void> => {
|
|
53
|
+
const extractInChild = (ctx: ExtensionCommandContext, workers: number): Promise<void> => {
|
|
54
54
|
const cli = cliPath();
|
|
55
55
|
if (!cli) {
|
|
56
56
|
ctx.ui.notify("pi-evals: cannot find its CLI (dist/cli.js); run npm run build in the package.", "error");
|
|
57
57
|
return Promise.resolve();
|
|
58
58
|
}
|
|
59
59
|
return new Promise<void>((resolve) => {
|
|
60
|
-
const child = spawnFn(cli.cmd, [...cli.args, "extract", "--json"], { env: { ...process.env, ...env }, stdio: ["ignore", "pipe", "pipe"] });
|
|
60
|
+
const child = spawnFn(cli.cmd, [...cli.args, "extract", "--json", "--workers", String(workers)], { env: { ...process.env, ...env }, stdio: ["ignore", "pipe", "pipe"] });
|
|
61
61
|
let buffer = "";
|
|
62
62
|
let last = "";
|
|
63
63
|
let errText = "";
|
|
@@ -109,8 +109,13 @@ export function createEvals(options: { env?: Env; spawnExtract?: typeof spawn; n
|
|
|
109
109
|
ctx.ui.notify("pi-evals: an extract is already running.", "warning");
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
|
+
const workers = words.length === 1 ? 2 : words.length === 3 && words[1] === "--workers" && /^\d+$/.test(words[2]) ? Number(words[2]) : NaN;
|
|
113
|
+
if (!Number.isSafeInteger(workers)) {
|
|
114
|
+
ctx.ui.notify("Usage: /evals extract [--workers <non-negative integer>]", "warning");
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
112
117
|
ctx.ui.notify("pi-evals: extract started in the background; progress shows in the footer.", "info");
|
|
113
|
-
running = extractInChild(ctx).finally(() => {
|
|
118
|
+
running = extractInChild(ctx, workers).finally(() => {
|
|
114
119
|
running = undefined;
|
|
115
120
|
});
|
|
116
121
|
} else if (sub === "report") {
|
package/src/render.ts
CHANGED
|
@@ -1,189 +1,63 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const meta = m[id];
|
|
64
|
-
if (!meta) return "";
|
|
65
|
-
const dir = meta.goodDirection === "higher" ? (lang === "zh" ? "越高越好" : "higher is better") : meta.goodDirection === "lower" ? (lang === "zh" ? "越低越好" : "lower is better") : "";
|
|
66
|
-
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>`;
|
|
67
|
-
};
|
|
68
|
-
const L = (en: string, zh: string) => (lang === "zh" ? zh : en);
|
|
69
|
-
const sections: string[] = [];
|
|
70
|
-
|
|
71
|
-
const fresh = model.freshness;
|
|
72
|
-
sections.push(`<section><h2>${L("Overview", "總覽")}</h2>
|
|
73
|
-
<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>
|
|
74
|
-
<p class="${fresh.stale ? "warn" : ""}">${L("Last extract", "上次抽取")}: ${esc(fresh.lastExtract ?? "—")}${fresh.stale ? ` — ${L("data is stale; run /evals extract", "資料過時,請執行 /evals extract")}` : ""}</p>
|
|
75
|
-
${table([L("Number", "數字"), L("Value", "數值")], [
|
|
76
|
-
[tx(m.sessions.label), model.totals.sessions],
|
|
77
|
-
[tx(m.subagent_sessions.label), model.totals.subagentSessions],
|
|
78
|
-
[tx(m.prompts.label), model.totals.prompts],
|
|
79
|
-
[tx(m.tool_calls.label), model.totals.toolCalls],
|
|
80
|
-
[tx(m.tool_error_rate.label), `${pct(model.totals.toolErrorRate)} (n=${num(nOf(model.totals.toolErrorRate))})`],
|
|
81
|
-
[tx(m.cost.label), usd(model.totals.cost)],
|
|
82
|
-
])}
|
|
83
|
-
${explain("sessions")}
|
|
84
|
-
<h3>${L("Sessions per day", "每日工作階段")}</h3>${columns(model.series.days, model.series.sessions)}
|
|
85
|
-
<h3>${L("Cost per day (USD)", "每日費用(美元)")}</h3>${columns(model.series.days, model.series.cost)}</section>`);
|
|
86
|
-
|
|
87
|
-
const sk = model.skills;
|
|
88
|
-
sections.push(`<section><h2>${L("Skills", "技能")}</h2>${explain("skill_loads")}
|
|
89
|
-
<h3>${L("Loads per day", "每日載入")}</h3>${columns(model.series.days, model.series.skillLoads)}
|
|
90
|
-
<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", "階段")}` })))}
|
|
91
|
-
${explain("skill_sessions")}
|
|
92
|
-
<h3>${L("How skills were loaded", "載入方式")}</h3>${table([L("Way", "方式"), L("Loads", "次數")], Object.entries(sk.triggers).map(([k, v]) => [esc(k), v]))}
|
|
93
|
-
<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]))}
|
|
94
|
-
<h3>${tx(m.never_loaded.label)} (${sk.neverLoaded.length} / ${sk.offered})</h3>${explain("never_loaded")}<p>${sk.neverLoaded.map(esc).join(", ") || "—"}</p></section>`);
|
|
95
|
-
|
|
96
|
-
sections.push(`<section><h2>${L("Packages", "套件")}</h2>${explain("package_calls")}${explain("tool_error_rate")}${explain("avg_duration_ms")}
|
|
97
|
-
${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)]))}
|
|
98
|
-
<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>`);
|
|
99
|
-
|
|
100
|
-
const ask = model.askUser;
|
|
101
|
-
const bucketLabel = (up: number | null, i: number, all: { upToMs: number | null }[]) => (up === null ? `≥ ${ms(all[i - 1]?.upToMs ?? 0)}` : `< ${ms(up)}`);
|
|
102
|
-
sections.push(`<section><h2>${L("Questions to you", "問你的問題")}</h2>${explain("ask_calls")}${explain("ask_wait_ms")}${explain("ask_cancel_rate")}
|
|
103
|
-
${table([L("Number", "數字"), L("Value", "數值")], [
|
|
104
|
-
[tx(m.ask_calls.label), ask.calls],
|
|
105
|
-
[tx(m.ask_wait_ms.label), `${ms(ask.avgWaitMs)} (n=${num(ask.waitN)})`],
|
|
106
|
-
[tx(m.ask_cancel_rate.label), `${pct(ask.cancelRate)} (n=${num(nOf(ask.cancelRate))})`],
|
|
107
|
-
])}
|
|
108
|
-
<h3>${L("How long you took", "你花多久回答")}</h3>${bars(ask.buckets.map((b, i) => ({ label: bucketLabel(b.upToMs, i, ask.buckets), value: b.n })))}
|
|
109
|
-
<h3>${L("Where the answer came from", "回答來源")}</h3>${table([L("Source", "來源"), L("Questions", "題數")], Object.entries(ask.sources).map(([k, v]) => [esc(k), v]))}</section>`);
|
|
110
|
-
|
|
111
|
-
const mon = model.monitors;
|
|
112
|
-
sections.push(`<section><h2>${L("Background jobs", "背景工作")}</h2>${explain("monitor_outcomes")}${explain("monitor_duration_ms")}
|
|
113
|
-
<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>
|
|
114
|
-
${bars(Object.entries(mon.statuses).map(([k, v]) => ({ label: k, value: v })))}</section>`);
|
|
115
|
-
|
|
116
|
-
const sub = model.subagents;
|
|
117
|
-
sections.push(`<section><h2>${L("Subagents", "子代理")}</h2>${explain("subagent_launches")}
|
|
118
|
-
${table([L("Role", "角色"), L("Model", "模型"), L("Launches", "次數")], sub.launches.slice(0, 40).map((r) => [esc(r.role), esc(r.model), r.n]))}
|
|
119
|
-
${explain("subagent_cost")}${bars(sub.costByRole.slice(0, 20).map((r) => ({ label: r.role, value: r.cost, note: usd(r.cost) })))}
|
|
120
|
-
<p>${L("Subagent sessions linked to a parent", "能對回母工作階段的子代理")}: ${num(sub.linked)} / ${num(sub.subagentTotal)}</p></section>`);
|
|
121
|
-
|
|
122
|
-
const proc = model.process;
|
|
123
|
-
const dm = model.meta.detectors;
|
|
124
|
-
sections.push(`<section><h2>${L("Process: does the work follow the anchorloop rules?", "流程:工作有沒有照 anchorloop 規則走?")}</h2>
|
|
125
|
-
<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")}
|
|
126
|
-
${proc.detectors
|
|
127
|
-
.map((d) => {
|
|
128
|
-
const meta = dm[d.name];
|
|
129
|
-
const daily = d.perDay.map((x) => (x.pass + x.fail ? Math.round((100 * x.pass) / (x.pass + x.fail)) : 0));
|
|
130
|
-
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>
|
|
131
|
-
<p>${tx(meta?.meaning)}<br><span class="how">${tx(meta?.howComputed)}</span></p>
|
|
132
|
-
<p class="ex">✔ ${tx(meta?.example.pass)}<br>✘ ${tx(meta?.example.fail)}</p>
|
|
133
|
-
<h4>${L("Share followed per day (%)", "每日遵守比例(%)")}</h4>${columns(model.series.days, daily, 720, 80)}
|
|
134
|
-
${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>`;
|
|
135
|
-
})
|
|
136
|
-
.join("")}
|
|
137
|
-
<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>`);
|
|
138
|
-
|
|
139
|
-
sections.push(`<section><h2>${L("Cost", "費用")}</h2>${explain("cost")}${explain("cost_per_session")}${explain("skill_cost")}
|
|
140
|
-
<p>${tx(m.cost_per_session.label)}: ${model.cost.perSession.value === null ? "—" : usd(model.cost.perSession.value)} (n=${num(model.cost.perSession.n)})</p>
|
|
141
|
-
<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)}` })))}
|
|
142
|
-
<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>`);
|
|
143
|
-
|
|
144
|
-
const changes = model.changes.slice(-40).reverse();
|
|
145
|
-
const imp = (c: (typeof model.changes)[number]) => {
|
|
146
|
-
if (!c.impact) return L("no data before this change", "變更前沒有資料");
|
|
147
|
-
const i = c.impact;
|
|
148
|
-
const row = (key: keyof typeof i.before, label: string) => {
|
|
149
|
-
const b = i.before[key] as Rate | number | undefined;
|
|
150
|
-
const a = i.after[key] as Rate | number | undefined;
|
|
151
|
-
if (b === undefined || a === undefined) return "";
|
|
152
|
-
const show = (x: Rate | number) => (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));
|
|
153
|
-
return `<tr><td>${esc(label)}</td><td>${show(b)}</td><td>${show(a)}</td></tr>`;
|
|
154
|
-
};
|
|
155
|
-
const kinds = Object.entries(i.confounders)
|
|
156
|
-
.map(([k, v]) => `${tx(model.meta.changeKinds[k])} ${v}`)
|
|
157
|
-
.join(", ");
|
|
158
|
-
const flags = [
|
|
159
|
-
i.smallSample ? `<span class="warn">${tx(m.small_sample.label)}</span>` : "",
|
|
160
|
-
i.incomplete ? `<span class="warn">${tx(m.incomplete_window.label)} (${L("days with data", "有資料的天數")}: ${i.daysWithData.before} / ${i.daysWithData.after})</span>` : "",
|
|
161
|
-
i.confounded ? `<span class="warn">${tx(m.confounded.label)}: ${i.confounded} (${esc(kinds)})</span>` : "",
|
|
162
|
-
]
|
|
163
|
-
.filter(Boolean)
|
|
164
|
-
.join(" · ");
|
|
165
|
-
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}`;
|
|
166
|
-
};
|
|
167
|
-
sections.push(`<section><h2>${L("Your changes and what followed", "你的變更與之後的變化")}</h2>${explain("impact")}${explain("small_sample")}${explain("incomplete_window")}${explain("confounded")}
|
|
168
|
-
${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>`);
|
|
169
|
-
|
|
170
|
-
const lab = model.labels;
|
|
171
|
-
sections.push(`<section><h2>${L("Your labels", "你的標記")}</h2>${explain("agreement")}
|
|
172
|
-
${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>`);
|
|
173
|
-
|
|
174
|
-
const cov = model.coverage;
|
|
175
|
-
if (cov)
|
|
176
|
-
sections.push(`<section><h2>${tx(m.coverage.label)}</h2>${explain("coverage")}
|
|
177
|
-
<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>`);
|
|
178
|
-
|
|
179
|
-
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>
|
|
180
|
-
<style>
|
|
181
|
-
:root{color-scheme:light dark;--fg:#1d1d1f;--bg:#fff;--muted:#666;--bar:#4a7bd0;--line:#ddd;--warn:#b35c00}
|
|
182
|
-
@media (prefers-color-scheme:dark){:root{--fg:#e6e6e6;--bg:#151515;--muted:#9a9a9a;--bar:#7aa2f7;--line:#333;--warn:#f0a050}}
|
|
183
|
-
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}
|
|
184
|
-
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}
|
|
185
|
-
table{border-collapse:collapse;margin:.5rem 0}td,th{border-bottom:1px solid var(--line);padding:.25rem .6rem;text-align:left;vertical-align:top}
|
|
186
|
-
.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)}
|
|
187
|
-
.ex{color:var(--muted);font-size:.92em}details{margin:.3rem 0}summary{cursor:pointer}
|
|
188
|
-
</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>`;
|
|
1
|
+
/** Offline, script-free views of one ReportModel. A fragment selects a detail page without loading another file. */
|
|
2
|
+
import type { ReportModel } from "./model.ts";
|
|
3
|
+
import { concepts, lesson } from "./report/concepts.ts";
|
|
4
|
+
import { esc, type Lang, num, words } from "./report/format.ts";
|
|
5
|
+
import { sections } from "./report/sections.ts";
|
|
6
|
+
import { css } from "./report/style.ts";
|
|
7
|
+
import { timeline } from "./report/timeline.ts";
|
|
8
|
+
import { week, workload } from "./report/week.ts";
|
|
9
|
+
export type { Lang } from "./report/format.ts";
|
|
10
|
+
|
|
11
|
+
export function renderHtml(m: ReportModel, lang: Lang = "zh"): string {
|
|
12
|
+
const L = words(lang), w = week(m), t = timeline(m, w, lang), c = concepts(m, w, t.lead, L);
|
|
13
|
+
const nav = [
|
|
14
|
+
["archive", L("All changes", "所有調整")],
|
|
15
|
+
["skills", L("Skills", "技能")],
|
|
16
|
+
["packages", L("Tools", "套件與工具")],
|
|
17
|
+
["ask", L("Questions", "提問")],
|
|
18
|
+
["monitors", L("Jobs", "背景工作")],
|
|
19
|
+
["subagents", L("Subagents", "子代理")],
|
|
20
|
+
["process", L("Process checks", "流程檢查")],
|
|
21
|
+
["cost", L("Cost", "費用")],
|
|
22
|
+
["coverage", L("Cleanup", "清理門檻")],
|
|
23
|
+
["labels", L("Labels", "你的標記")],
|
|
24
|
+
["concepts", L("Concepts", "概念")],
|
|
25
|
+
];
|
|
26
|
+
const date = m.generated.slice(0, 10);
|
|
27
|
+
return `<!doctype html><html lang="${
|
|
28
|
+
lang === "zh" ? "zh-Hant-TW" : "en"
|
|
29
|
+
}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>pi-evals · ${
|
|
30
|
+
L("Change timeline", "調整時間軸")
|
|
31
|
+
}</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>${
|
|
32
|
+
L("Agent work, observed", "代理工作觀察")
|
|
33
|
+
}</span></a><small>${esc(date)} ${L("report", "更新")} / ${L("All times UTC", "時間皆為 UTC")}</small></header>
|
|
34
|
+
<main id="timeline"><div class="hero"><p class="eyebrow">${L("Change journal / Newest first", "調整紀事 / 依更新時間排列")}</p><h1>${
|
|
35
|
+
esc(t.headline)
|
|
36
|
+
}</h1><p class="deck">${esc(t.trust)}</p>${
|
|
37
|
+
m.freshness.stale
|
|
38
|
+
? `<p class="stale">${L("Last extract", "上次抽取")}:${esc(m.freshness.lastExtract ?? "—")} · ${
|
|
39
|
+
L("Refresh with /evals extract.", "資料過時,請執行 /evals extract。")
|
|
40
|
+
}</p>`
|
|
41
|
+
: ""
|
|
42
|
+
}</div>
|
|
43
|
+
<div class="spine"><h2>${
|
|
44
|
+
L(`${t.count} changes worth a closer look`, `${t.count === 2 ? "兩" : t.count === 1 ? "一" : "零"}筆值得回看的調整`)
|
|
45
|
+
}</h2><div class="layout"><div class="rail">${
|
|
46
|
+
t.cards || `<p>${L("Nothing to highlight yet.", "還沒有適合比較的調整。")}</p>`
|
|
47
|
+
}</div><aside class="side">${workload(w, L)}${lesson(c.record, L)}${lesson(c.metric, L)}</aside></div><details><summary>${
|
|
48
|
+
L("How to read the comparisons", "怎麼讀時間軸上的比較?")
|
|
49
|
+
}</summary><div class="notes-grid">${lesson(c.sample, L)}${lesson(c.confounding, L)}${lesson(c.check, L)}</div></details></div>
|
|
50
|
+
<nav class="jump" aria-label="${L("Report sections", "報表章節")}">${
|
|
51
|
+
nav.map(([id, text]) => `<a href="#${id}">${text}</a>`).join("")
|
|
52
|
+
}</nav><section class="topic" id="archive"><h2>${L("Other changes by day", "按日期查其餘調整")}</h2><p>${
|
|
53
|
+
L("Open a day for its changes. Each link opens the before-and-after comparison.", "展開一天,點選調整名稱,就能看到它的前後比較。")
|
|
54
|
+
}</p>${t.archive || "—"}</section>
|
|
55
|
+
<p class="muted">${esc(m.window.project ?? L("All projects", "全部專案"))} · ${esc(m.window.since ?? "—")} → ${
|
|
56
|
+
esc(m.window.until ?? "—")
|
|
57
|
+
} · ${num(m.totals.sessions)} ${L("sessions", "段工作")} · ${num(m.totals.prompts)} ${L("prompts", "次提示")}</p>${
|
|
58
|
+
sections(m, lang, c)
|
|
59
|
+
}</main>
|
|
60
|
+
${t.details}<footer><b>PI-EVALS / ${L("Change timeline", "調整時間軸")}</b><span>${
|
|
61
|
+
esc(m.window.project ?? L("All projects", "全部專案"))
|
|
62
|
+
} · ${L("Transcript text not included", "統計不含對話原文")}</span></footer></body></html>`;
|
|
189
63
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { ReportModel } from "../model.ts";
|
|
2
|
+
import { type Change, esc, num, type Words } from "./format.ts";
|
|
3
|
+
import type { Week } from "./week.ts";
|
|
4
|
+
|
|
5
|
+
export function concepts(m: ReportModel, week: Week, c: Change | undefined, L: Words) {
|
|
6
|
+
const i = c?.impact,
|
|
7
|
+
n = num(week.reduce((s, r) => s + r.sessions, 0)),
|
|
8
|
+
d = m.process.detectors.find((r) => r.name === "anchor_before_first_edit");
|
|
9
|
+
return {
|
|
10
|
+
record: [
|
|
11
|
+
L("Record", "紀錄"),
|
|
12
|
+
L(
|
|
13
|
+
`A tool call leaves a record: ${
|
|
14
|
+
num(week.reduce((s, r) => s + r.calls, 0))
|
|
15
|
+
} calls in this chart’s period. The words exchanged are not kept.`,
|
|
16
|
+
`一次工具呼叫留下一筆紀錄。圖中這幾天共 ${num(week.reduce((s, r) => s + r.calls, 0))} 次,不保留對話原文。`,
|
|
17
|
+
),
|
|
18
|
+
],
|
|
19
|
+
metric: [
|
|
20
|
+
L("Metric", "指標"),
|
|
21
|
+
L(
|
|
22
|
+
`Count sessions by their start date: ${n} in the chart. This measures workload, not whether the work was good.`,
|
|
23
|
+
`把工作按開始日期計數,圖中共有 ${n} 段。這個指標量的是工作量,不是工作品質。`,
|
|
24
|
+
),
|
|
25
|
+
],
|
|
26
|
+
sample: [
|
|
27
|
+
L("Before, after and sample size", "前後比較與樣本數"),
|
|
28
|
+
i
|
|
29
|
+
? L(
|
|
30
|
+
`Split sessions at the change time: ${num(i.before.sessions)} before and ${
|
|
31
|
+
num(i.after.sessions)
|
|
32
|
+
} after. Only sessions to which a rule applies count in its percentage.`,
|
|
33
|
+
`依開始時間分組:調整前 ${num(i.before.sessions)} 段、調整後 ${
|
|
34
|
+
num(i.after.sessions)
|
|
35
|
+
} 段。算一條規則的通過比例時,只數適用的工作段。`,
|
|
36
|
+
)
|
|
37
|
+
: L(
|
|
38
|
+
`There are ${num(m.totals.sessions)} sessions in the report. Without records on both sides, we cannot compare a change.`,
|
|
39
|
+
`報表裡有 ${num(m.totals.sessions)} 段工作。調整前後都要有紀錄,才有兩組數字能比。`,
|
|
40
|
+
),
|
|
41
|
+
],
|
|
42
|
+
confounding: [
|
|
43
|
+
L("Other changes at the same time", "同期多個調整"),
|
|
44
|
+
i
|
|
45
|
+
? L(
|
|
46
|
+
`There were ${
|
|
47
|
+
num(i.confounded)
|
|
48
|
+
} other changes in these windows. If a rule and a package changed together, their effects cannot be separated here.`,
|
|
49
|
+
`這段期間另有 ${num(i.confounded)} 筆調整。規則和套件若一起改,只比前後分不出哪一項影響了結果。`,
|
|
50
|
+
)
|
|
51
|
+
: L(
|
|
52
|
+
`There are ${num(m.changes.length)} changes on this timeline. Check what else changed before crediting a new version.`,
|
|
53
|
+
`時間軸有 ${num(m.changes.length)} 筆調整。要把差異歸給某個版本,得先查同一期間還改了什麼。`,
|
|
54
|
+
),
|
|
55
|
+
],
|
|
56
|
+
check: [
|
|
57
|
+
L("Code check", "程式檢查"),
|
|
58
|
+
L(
|
|
59
|
+
`In ${
|
|
60
|
+
num(d?.passRate.n ?? 0)
|
|
61
|
+
} eligible sessions, code checked whether the agent named a check before editing. It cannot judge whether that check tested the right thing.`,
|
|
62
|
+
`程式在 ${num(d?.passRate.n ?? 0)} 段適用的工作裡查「改檔前有沒有先說怎麼驗證」。它看得出先後順序,判斷不了方法好不好。`,
|
|
63
|
+
),
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function lesson(entry: string[], L: Words) {
|
|
68
|
+
return `<aside class="lesson"><strong class="eyebrow">${L("Reading the numbers", "讀數字")} / ${esc(entry[0])}</strong><p>${
|
|
69
|
+
esc(entry[1])
|
|
70
|
+
}</p></aside>`;
|
|
71
|
+
}
|
|
72
|
+
export function selfCheck(L: Words) {
|
|
73
|
+
const item = (q: string, a: string) => `<p>${q}</p><details><summary>${L("Answer", "看答案")}</summary><p>${a}</p></details>`;
|
|
74
|
+
return `<h3>${L("Check your reading", "試著判讀")}</h3>${
|
|
75
|
+
item(
|
|
76
|
+
L("1. Tool errors fell after a pin. Did the new version fix them?", "1. 更新後工具出錯比例下降,就能說是新版本修好了嗎?"),
|
|
77
|
+
L(
|
|
78
|
+
"Not from this alone. Check the window, the sample and what else changed.",
|
|
79
|
+
"還不能。先看前後各有幾段工作、資料收齊了沒,以及同期還改了什麼。",
|
|
80
|
+
),
|
|
81
|
+
)
|
|
82
|
+
}${
|
|
83
|
+
item(
|
|
84
|
+
L(
|
|
85
|
+
"2. A session passed the check for naming a test before editing. Did the test cover the bug?",
|
|
86
|
+
"2. 一段工作通過「動手前先說好怎麼驗證」,表示測試驗到了那個錯誤嗎?",
|
|
87
|
+
),
|
|
88
|
+
L(
|
|
89
|
+
"The order was right. Whether the test could catch the bug is a different question.",
|
|
90
|
+
"只知道順序對。那個測試抓不抓得到錯誤,要另外看測試內容。",
|
|
91
|
+
),
|
|
92
|
+
)
|
|
93
|
+
}`;
|
|
94
|
+
}
|