@crowandraven/evalkeeper 0.15.0 → 0.17.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/dist/glossary.d.ts +1 -0
- package/dist/glossary.js +1 -0
- package/dist/glossary.js.map +1 -1
- package/dist/health.d.ts +24 -0
- package/dist/health.js +61 -7
- package/dist/health.js.map +1 -1
- package/dist/react/AnswerKey.js +46 -15
- package/dist/react/AnswerKey.js.map +1 -1
- package/dist/react/ConfirmAnswer.d.ts +25 -4
- package/dist/react/ConfirmAnswer.js +66 -13
- package/dist/react/ConfirmAnswer.js.map +1 -1
- package/dist/react/Fields.d.ts +8 -2
- package/dist/react/Fields.js +22 -6
- package/dist/react/Fields.js.map +1 -1
- package/dist/react/Folded.d.ts +13 -0
- package/dist/react/Folded.js +15 -0
- package/dist/react/Folded.js.map +1 -0
- package/dist/react/HubSections.d.ts +4 -1
- package/dist/react/HubSections.js +30 -12
- package/dist/react/HubSections.js.map +1 -1
- package/dist/react/Readable.d.ts +39 -0
- package/dist/react/Readable.js +136 -0
- package/dist/react/Readable.js.map +1 -0
- package/dist/react/app.d.ts +3 -1
- package/dist/react/app.js.map +1 -1
- package/dist/react/pieces.d.ts +28 -1
- package/dist/react/pieces.js +43 -1
- package/dist/react/pieces.js.map +1 -1
- package/dist/types.d.ts +22 -0
- package/dist/types.js.map +1 -1
- package/package.json +4 -4
- package/src/glossary.ts +2 -0
- package/src/health.ts +81 -9
- package/src/react/AnswerKey.tsx +237 -93
- package/src/react/ConfirmAnswer.tsx +120 -30
- package/src/react/Fields.tsx +28 -20
- package/src/react/Folded.tsx +38 -0
- package/src/react/HubSections.tsx +124 -40
- package/src/react/Readable.tsx +266 -0
- package/src/react/app.ts +3 -2
- package/src/react/pieces.tsx +78 -2
- package/src/types.ts +23 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, type ReactNode } from "react";
|
|
4
|
+
import { Button } from "./pieces.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Long content, folded: `short` shows until the person opens the rest.
|
|
8
|
+
* For a posting's text or a long list, so a case reads at a glance.
|
|
9
|
+
*/
|
|
10
|
+
export function Folded({
|
|
11
|
+
short,
|
|
12
|
+
children,
|
|
13
|
+
more,
|
|
14
|
+
}: {
|
|
15
|
+
/** What shows while folded. */
|
|
16
|
+
short: ReactNode;
|
|
17
|
+
/** The whole of it. */
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
/** The button's label: "Show all 24" or "Show the whole text". */
|
|
20
|
+
more: string;
|
|
21
|
+
}) {
|
|
22
|
+
const [open, setOpen] = useState(false);
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
{open ? children : short}
|
|
26
|
+
<Button
|
|
27
|
+
type="button"
|
|
28
|
+
aria-expanded={open}
|
|
29
|
+
onClick={() => {
|
|
30
|
+
setOpen(!open);
|
|
31
|
+
}}
|
|
32
|
+
className="mt-1 text-xs text-accent hover:underline"
|
|
33
|
+
>
|
|
34
|
+
{open ? "Show less" : more}
|
|
35
|
+
</Button>
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
perAnswer,
|
|
6
6
|
priorityOf,
|
|
7
7
|
seconds,
|
|
8
|
+
STANDING_LABEL,
|
|
9
|
+
STANDING_ORDER,
|
|
8
10
|
suiteHealth,
|
|
9
11
|
thumbsSummary,
|
|
10
12
|
type GlossaryTerm,
|
|
@@ -12,7 +14,14 @@ import {
|
|
|
12
14
|
type Settings,
|
|
13
15
|
type SettingsVersion,
|
|
14
16
|
} from "../index.js";
|
|
15
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
Link,
|
|
19
|
+
Card,
|
|
20
|
+
InfoTip,
|
|
21
|
+
LocalDate,
|
|
22
|
+
StandingBadge,
|
|
23
|
+
HealthReasons,
|
|
24
|
+
} from "./pieces.js";
|
|
16
25
|
import { pct } from "./format.js";
|
|
17
26
|
import { HistoryEntries } from "./SettingsHistory.js";
|
|
18
27
|
import {
|
|
@@ -152,45 +161,66 @@ export function HubStats({ data }: { data: HubData }) {
|
|
|
152
161
|
);
|
|
153
162
|
}
|
|
154
163
|
|
|
155
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* One card per feature, grouped by standing with what needs you first: at
|
|
166
|
+
* risk, can improve, healthy, and can't tell yet. An injection suite's results show on its base feature's card.
|
|
167
|
+
*/
|
|
156
168
|
export function SuiteList({ data }: { data: HubData }) {
|
|
157
169
|
const { app, histories, attacksOn, cards } = data;
|
|
170
|
+
const all = cards.map(({ b, i }) => {
|
|
171
|
+
const attacked = attacksOn(b.suite.key);
|
|
172
|
+
const [history, current] = histories[i] ?? [[], null];
|
|
173
|
+
const health = suiteHealth(
|
|
174
|
+
b.rows,
|
|
175
|
+
b.suite.checks,
|
|
176
|
+
priorityOf(b.suite, current?.settings),
|
|
177
|
+
b.cases,
|
|
178
|
+
b.provisional,
|
|
179
|
+
app.models,
|
|
180
|
+
{ attacks: attacksFrom(attacked) },
|
|
181
|
+
);
|
|
182
|
+
return { b, attacked, history, current, health };
|
|
183
|
+
});
|
|
184
|
+
const card = (c: (typeof all)[number]) => (
|
|
185
|
+
<SuiteCard
|
|
186
|
+
app={app}
|
|
187
|
+
key={c.b.suite.key}
|
|
188
|
+
board={c.b}
|
|
189
|
+
attacked={c.attacked}
|
|
190
|
+
health={c.health}
|
|
191
|
+
history={c.history}
|
|
192
|
+
current={c.current}
|
|
193
|
+
/>
|
|
194
|
+
);
|
|
158
195
|
return (
|
|
159
|
-
|
|
160
|
-
<
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
current={current}
|
|
188
|
-
/>
|
|
189
|
-
);
|
|
190
|
-
})}
|
|
191
|
-
</div>
|
|
192
|
-
</section>
|
|
193
|
-
</>
|
|
196
|
+
<section aria-labelledby="suites" className="space-y-3">
|
|
197
|
+
<h2 id="suites" className="text-lg font-semibold">
|
|
198
|
+
Suites
|
|
199
|
+
<InfoTip term="suites" />
|
|
200
|
+
</h2>
|
|
201
|
+
{cards.length === 0 && <NoSuites />}
|
|
202
|
+
{STANDING_ORDER.map((standing) => {
|
|
203
|
+
const group = all.filter((c) => c.health.standing === standing);
|
|
204
|
+
if (!group.length) return null;
|
|
205
|
+
const heading = (
|
|
206
|
+
<span className="flex items-center gap-2 text-sm text-muted">
|
|
207
|
+
<StandingBadge standing={standing} />
|
|
208
|
+
{group.length} {group.length === 1 ? "suite" : "suites"}
|
|
209
|
+
</span>
|
|
210
|
+
);
|
|
211
|
+
return (
|
|
212
|
+
<div
|
|
213
|
+
key={standing}
|
|
214
|
+
role="group"
|
|
215
|
+
aria-label={STANDING_LABEL[standing]}
|
|
216
|
+
className="space-y-3 pt-2"
|
|
217
|
+
>
|
|
218
|
+
{heading}
|
|
219
|
+
<div className="space-y-4">{group.map(card)}</div>
|
|
220
|
+
</div>
|
|
221
|
+
);
|
|
222
|
+
})}
|
|
223
|
+
</section>
|
|
194
224
|
);
|
|
195
225
|
}
|
|
196
226
|
|
|
@@ -259,6 +289,44 @@ function Stat({
|
|
|
259
289
|
|
|
260
290
|
type Board = Awaited<ReturnType<Runner["board"]>>;
|
|
261
291
|
|
|
292
|
+
/**
|
|
293
|
+
* The live model's check furthest under its bar, as a bar with a tick at
|
|
294
|
+
* the bar, so a card shows how far off it is, not only that it is.
|
|
295
|
+
*/
|
|
296
|
+
function WorstCheck({
|
|
297
|
+
worst: w,
|
|
298
|
+
}: {
|
|
299
|
+
worst: NonNullable<ReturnType<typeof suiteHealth>["worst"]>;
|
|
300
|
+
}) {
|
|
301
|
+
return (
|
|
302
|
+
<div className="flex flex-wrap items-center gap-3 text-sm text-muted">
|
|
303
|
+
<span>
|
|
304
|
+
{w.label}
|
|
305
|
+
{w.serious ? " (serious)" : ""}{" "}
|
|
306
|
+
<span
|
|
307
|
+
className={`font-semibold ${w.serious ? "text-bad" : "text-warn"}`}
|
|
308
|
+
>
|
|
309
|
+
{pct(w.rate)}
|
|
310
|
+
</span>
|
|
311
|
+
</span>
|
|
312
|
+
<span aria-hidden className="relative h-1.5 w-40 rounded-full bg-tint">
|
|
313
|
+
<span
|
|
314
|
+
className={`absolute inset-y-0 left-0 rounded-full ${w.serious ? "bg-bad" : "bg-warn"}`}
|
|
315
|
+
style={{ width: `${Math.round(w.rate * 100)}%` }}
|
|
316
|
+
/>
|
|
317
|
+
<span
|
|
318
|
+
className="absolute -inset-y-1 w-px bg-ink"
|
|
319
|
+
style={{ left: `${Math.round(w.bar * 100)}%` }}
|
|
320
|
+
/>
|
|
321
|
+
</span>
|
|
322
|
+
<span>
|
|
323
|
+
bar {pct(w.bar)}
|
|
324
|
+
<InfoTip term="bar" />
|
|
325
|
+
</span>
|
|
326
|
+
</div>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
262
330
|
/** Green at 95% and up, amber from 80%, red below. */
|
|
263
331
|
const scoreTone = (rate: number) =>
|
|
264
332
|
rate >= 0.95 ? "text-good" : rate >= 0.8 ? "text-warn" : "text-bad";
|
|
@@ -309,8 +377,10 @@ function SuiteCard({
|
|
|
309
377
|
{b.suite.label}
|
|
310
378
|
</Link>
|
|
311
379
|
</h2>
|
|
312
|
-
<
|
|
380
|
+
<StandingBadge standing={h.standing} />
|
|
381
|
+
<InfoTip term="standing" />
|
|
313
382
|
</div>
|
|
383
|
+
<HealthReasons flags={h.flags} />
|
|
314
384
|
<p className="readable text-sm text-muted">{b.suite.description}</p>
|
|
315
385
|
</div>
|
|
316
386
|
{t && (
|
|
@@ -362,6 +432,7 @@ function SuiteCard({
|
|
|
362
432
|
)}{" "}
|
|
363
433
|
· {b.cases} cases · {h.testedModels} models tested
|
|
364
434
|
</p>
|
|
435
|
+
{h.worst && <WorstCheck worst={h.worst} />}
|
|
365
436
|
</div>
|
|
366
437
|
|
|
367
438
|
{h.details.length > 0 && (
|
|
@@ -450,9 +521,22 @@ export function NoEvalYet({ data }: { data: HubData }) {
|
|
|
450
521
|
No eval yet
|
|
451
522
|
</h2>
|
|
452
523
|
<p className="readable text-sm text-muted">
|
|
453
|
-
{
|
|
454
|
-
|
|
524
|
+
Nothing tells you yet whether{" "}
|
|
525
|
+
{gaps.length === 1 ? "this feature" : "these features"} got worse.
|
|
455
526
|
</p>
|
|
527
|
+
{/* One slim card per feature, like the suites above. */}
|
|
528
|
+
<ul className="space-y-3">
|
|
529
|
+
{gaps.map((f) => (
|
|
530
|
+
<li key={f.operation}>
|
|
531
|
+
<Card className="space-y-1 py-3">
|
|
532
|
+
<p className="font-semibold">{f.label}</p>
|
|
533
|
+
{f.description && (
|
|
534
|
+
<p className="readable text-sm text-muted">{f.description}</p>
|
|
535
|
+
)}
|
|
536
|
+
</Card>
|
|
537
|
+
</li>
|
|
538
|
+
))}
|
|
539
|
+
</ul>
|
|
456
540
|
</section>
|
|
457
541
|
);
|
|
458
542
|
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { asText } from "../index.js";
|
|
3
|
+
import { Folded } from "./Folded.js";
|
|
4
|
+
|
|
5
|
+
/** Longer than this, text is folded to its start. */
|
|
6
|
+
const LONG_TEXT = 320;
|
|
7
|
+
/** More items than this, a list is folded to its first ones. */
|
|
8
|
+
const LONG_LIST = 6;
|
|
9
|
+
/** Deeper than this, a value shows as data. */
|
|
10
|
+
const MAX_DEPTH = 3;
|
|
11
|
+
|
|
12
|
+
/** "linkStatus" or "link_status" → "Link status". */
|
|
13
|
+
export function humanize(key: string): string {
|
|
14
|
+
const words = key
|
|
15
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
16
|
+
.replace(/[_-]+/g, " ")
|
|
17
|
+
.trim()
|
|
18
|
+
.toLowerCase();
|
|
19
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** `text` with each of `marks` highlighted, ignoring case. */
|
|
23
|
+
export function Marked({
|
|
24
|
+
text,
|
|
25
|
+
marks = [],
|
|
26
|
+
}: {
|
|
27
|
+
text: string;
|
|
28
|
+
marks?: string[] | undefined;
|
|
29
|
+
}): ReactNode {
|
|
30
|
+
const terms = marks.map((m) => m.trim()).filter(Boolean);
|
|
31
|
+
if (!terms.length) return text;
|
|
32
|
+
const escaped = terms
|
|
33
|
+
.sort((a, b) => b.length - a.length)
|
|
34
|
+
.map((m) => m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
35
|
+
const parts = text.split(new RegExp(`(${escaped.join("|")})`, "gi"));
|
|
36
|
+
if (parts.length === 1) return text;
|
|
37
|
+
const lower = new Set(terms.map((t) => t.toLowerCase()));
|
|
38
|
+
return parts.map((p, i) =>
|
|
39
|
+
lower.has(p.toLowerCase()) ? (
|
|
40
|
+
<mark key={i} className="rounded-sm bg-warn/20 px-0.5 text-ink">
|
|
41
|
+
{p}
|
|
42
|
+
</mark>
|
|
43
|
+
) : (
|
|
44
|
+
p
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** "VERIFIED" → "Verified", "NOT_SURE" → "Not sure"; other text as is. */
|
|
50
|
+
export function enumText(text: string): string {
|
|
51
|
+
if (!/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/.test(text)) return text;
|
|
52
|
+
const words = text.replace(/_/g, " ").toLowerCase();
|
|
53
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Whether `value` contains any of `marks` anywhere, ignoring case. */
|
|
57
|
+
export function hasMark(value: unknown, marks: string[] = []): boolean {
|
|
58
|
+
if (!marks.length) return false;
|
|
59
|
+
const text = (typeof value === "string" ? value : asText(value))
|
|
60
|
+
.toLowerCase()
|
|
61
|
+
.replace(/\\n/g, "\n");
|
|
62
|
+
return marks.some((m) => m.trim() && text.includes(m.trim().toLowerCase()));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type Block =
|
|
66
|
+
| { kind: "heading"; text: string }
|
|
67
|
+
| { kind: "list"; items: string[] }
|
|
68
|
+
| { kind: "text"; text: string };
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Text as blocks a person reads: Markdown-style headings ("### Wants")
|
|
72
|
+
* and lists ("- item") as such, paragraphs at blank lines, other line
|
|
73
|
+
* breaks kept.
|
|
74
|
+
*/
|
|
75
|
+
export function blocksOf(text: string): Block[] {
|
|
76
|
+
const out: Block[] = [];
|
|
77
|
+
let para: string[] = [];
|
|
78
|
+
const endPara = () => {
|
|
79
|
+
const t = para.join("\n").trim();
|
|
80
|
+
if (t) out.push({ kind: "text", text: t });
|
|
81
|
+
para = [];
|
|
82
|
+
};
|
|
83
|
+
for (const raw of text.split("\n")) {
|
|
84
|
+
const line = raw.trimEnd();
|
|
85
|
+
const heading = /^#{1,6}\s+(.+)$/.exec(line);
|
|
86
|
+
const item = /^\s*[-*•]\s+(.+)$/.exec(line);
|
|
87
|
+
if (heading?.[1]) {
|
|
88
|
+
endPara();
|
|
89
|
+
out.push({ kind: "heading", text: heading[1] });
|
|
90
|
+
} else if (item?.[1]) {
|
|
91
|
+
endPara();
|
|
92
|
+
const last = out.at(-1);
|
|
93
|
+
if (last?.kind === "list") last.items.push(item[1]);
|
|
94
|
+
else out.push({ kind: "list", items: [item[1]] });
|
|
95
|
+
} else if (!line.trim()) endPara();
|
|
96
|
+
else para.push(line);
|
|
97
|
+
}
|
|
98
|
+
endPara();
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Text in blocks: headings, lists, and paragraphs, with marks. */
|
|
103
|
+
function Paragraphs({
|
|
104
|
+
text,
|
|
105
|
+
marks,
|
|
106
|
+
}: {
|
|
107
|
+
text: string;
|
|
108
|
+
marks?: string[] | undefined;
|
|
109
|
+
}) {
|
|
110
|
+
return (
|
|
111
|
+
<div className="readable space-y-2">
|
|
112
|
+
{blocksOf(text).map((b, i) =>
|
|
113
|
+
b.kind === "heading" ? (
|
|
114
|
+
<p key={i} className="text-xs font-semibold text-muted">
|
|
115
|
+
<Marked text={b.text} marks={marks} />
|
|
116
|
+
</p>
|
|
117
|
+
) : b.kind === "list" ? (
|
|
118
|
+
<ul key={i} className="list-disc space-y-1 pl-5">
|
|
119
|
+
{b.items.map((t, j) => (
|
|
120
|
+
<li key={j}>
|
|
121
|
+
<Marked text={t} marks={marks} />
|
|
122
|
+
</li>
|
|
123
|
+
))}
|
|
124
|
+
</ul>
|
|
125
|
+
) : (
|
|
126
|
+
<p key={i} className="whitespace-pre-wrap">
|
|
127
|
+
<Marked text={b.text} marks={marks} />
|
|
128
|
+
</p>
|
|
129
|
+
),
|
|
130
|
+
)}
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Text as a person reads it: short text inline, long text as paragraphs
|
|
137
|
+
* folded to its start, unless a highlight sits in the rest.
|
|
138
|
+
*/
|
|
139
|
+
function ReadableText({
|
|
140
|
+
text,
|
|
141
|
+
marks,
|
|
142
|
+
}: {
|
|
143
|
+
text: string;
|
|
144
|
+
marks?: string[] | undefined;
|
|
145
|
+
}) {
|
|
146
|
+
if (/^https?:\/\/\S+$/.test(text))
|
|
147
|
+
return (
|
|
148
|
+
<a
|
|
149
|
+
href={text}
|
|
150
|
+
target="_blank"
|
|
151
|
+
rel="noreferrer"
|
|
152
|
+
className="break-all text-accent hover:underline"
|
|
153
|
+
>
|
|
154
|
+
<Marked text={text} marks={marks} />
|
|
155
|
+
</a>
|
|
156
|
+
);
|
|
157
|
+
if (text.length <= LONG_TEXT && !text.includes("\n"))
|
|
158
|
+
return <Marked text={enumText(text)} marks={marks} />;
|
|
159
|
+
const whole = (
|
|
160
|
+
<div className="rounded-md bg-tint px-3 py-2">
|
|
161
|
+
<Paragraphs text={text} marks={marks} />
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
if (text.length <= LONG_TEXT) return whole;
|
|
165
|
+
const cut = text.slice(0, LONG_TEXT).replace(/\s+\S*$/, "");
|
|
166
|
+
const markedLater = hasMark(text, marks) && !hasMark(cut, marks);
|
|
167
|
+
return (
|
|
168
|
+
<div>
|
|
169
|
+
<Folded
|
|
170
|
+
more="Show the whole text"
|
|
171
|
+
short={
|
|
172
|
+
<div className="rounded-md bg-tint px-3 py-2">
|
|
173
|
+
<Paragraphs text={`${cut}…`} marks={marks} />
|
|
174
|
+
{markedLater && (
|
|
175
|
+
<p className="mt-1 text-xs text-muted">
|
|
176
|
+
More highlighted further on.
|
|
177
|
+
</p>
|
|
178
|
+
)}
|
|
179
|
+
</div>
|
|
180
|
+
}
|
|
181
|
+
>
|
|
182
|
+
{whole}
|
|
183
|
+
</Folded>
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* A stored value, read like a page rather than data: an object as
|
|
190
|
+
* labeled rows, a list as a list (folded when long), text as text, with
|
|
191
|
+
* `marks` highlighted.
|
|
192
|
+
*/
|
|
193
|
+
export function ReadableValue({
|
|
194
|
+
value,
|
|
195
|
+
marks,
|
|
196
|
+
depth = 0,
|
|
197
|
+
}: {
|
|
198
|
+
value: unknown;
|
|
199
|
+
marks?: string[] | undefined;
|
|
200
|
+
depth?: number;
|
|
201
|
+
}): ReactNode {
|
|
202
|
+
if (value === undefined || value === null || value === "")
|
|
203
|
+
return <span className="text-muted">—</span>;
|
|
204
|
+
if (typeof value === "string")
|
|
205
|
+
return <ReadableText text={value} marks={marks} />;
|
|
206
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
207
|
+
return String(value);
|
|
208
|
+
if (depth >= MAX_DEPTH)
|
|
209
|
+
return (
|
|
210
|
+
<pre className="whitespace-pre-wrap text-xs">
|
|
211
|
+
{JSON.stringify(value, null, 2)}
|
|
212
|
+
</pre>
|
|
213
|
+
);
|
|
214
|
+
if (Array.isArray(value)) {
|
|
215
|
+
if (!value.length) return <span className="text-muted">None</span>;
|
|
216
|
+
// Records (résumés, facts with fields): each its own tinted block.
|
|
217
|
+
const records = value.every(
|
|
218
|
+
(x) => x !== null && typeof x === "object" && !Array.isArray(x),
|
|
219
|
+
);
|
|
220
|
+
const items = (xs: unknown[]) =>
|
|
221
|
+
records ? (
|
|
222
|
+
<ul className="space-y-2">
|
|
223
|
+
{xs.map((x, i) => (
|
|
224
|
+
<li key={i} className="rounded-md bg-tint px-3 py-2">
|
|
225
|
+
<ReadableValue value={x} marks={marks} depth={depth + 1} />
|
|
226
|
+
</li>
|
|
227
|
+
))}
|
|
228
|
+
</ul>
|
|
229
|
+
) : (
|
|
230
|
+
<ul className="list-disc space-y-1 pl-5">
|
|
231
|
+
{xs.map((x, i) => (
|
|
232
|
+
<li key={i}>
|
|
233
|
+
<ReadableValue value={x} marks={marks} depth={depth + 1} />
|
|
234
|
+
</li>
|
|
235
|
+
))}
|
|
236
|
+
</ul>
|
|
237
|
+
);
|
|
238
|
+
if (value.length <= LONG_LIST) return items(value);
|
|
239
|
+
return (
|
|
240
|
+
<div>
|
|
241
|
+
<Folded
|
|
242
|
+
more={`Show all ${value.length}`}
|
|
243
|
+
short={items(value.slice(0, LONG_LIST - 1))}
|
|
244
|
+
>
|
|
245
|
+
{items(value)}
|
|
246
|
+
</Folded>
|
|
247
|
+
</div>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
const entries = Object.entries(value as Record<string, unknown>).filter(
|
|
251
|
+
([, v]) => v !== undefined,
|
|
252
|
+
);
|
|
253
|
+
if (!entries.length) return <span className="text-muted">—</span>;
|
|
254
|
+
return (
|
|
255
|
+
<dl className="grid grid-cols-[minmax(6rem,auto)_minmax(0,1fr)] gap-x-3 gap-y-1.5">
|
|
256
|
+
{entries.map(([k, v]) => (
|
|
257
|
+
<div key={k} className="contents">
|
|
258
|
+
<dt className="text-xs text-muted">{humanize(k)}</dt>
|
|
259
|
+
<dd className="min-w-0 break-words">
|
|
260
|
+
<ReadableValue value={v} marks={marks} depth={depth + 1} />
|
|
261
|
+
</dd>
|
|
262
|
+
</div>
|
|
263
|
+
))}
|
|
264
|
+
</dl>
|
|
265
|
+
);
|
|
266
|
+
}
|
package/src/react/app.ts
CHANGED
|
@@ -80,9 +80,10 @@ export type EvalApp = {
|
|
|
80
80
|
basePath: string;
|
|
81
81
|
/**
|
|
82
82
|
* Every AI feature your app has, by the operation its suites name. The
|
|
83
|
-
* hub lists the ones no suite tests yet
|
|
83
|
+
* hub lists the ones no suite tests yet, one card each, with the
|
|
84
|
+
* description when there is one. Leave it out to skip that list.
|
|
84
85
|
*/
|
|
85
|
-
features?: { operation: string; label: string }[];
|
|
86
|
+
features?: { operation: string; label: string; description?: string }[];
|
|
86
87
|
};
|
|
87
88
|
|
|
88
89
|
/** An `EvalApp` with its suites by key, as the screens read it. */
|
package/src/react/pieces.tsx
CHANGED
|
@@ -9,9 +9,14 @@ import {
|
|
|
9
9
|
type ReactNode,
|
|
10
10
|
} from "react";
|
|
11
11
|
import { useFormStatus } from "react-dom";
|
|
12
|
-
import { ArrowLeft, Info, LoaderCircle } from "lucide-react";
|
|
12
|
+
import { ArrowLeft, CircleAlert, Info, LoaderCircle } from "lucide-react";
|
|
13
13
|
import { GLOSSARY, type GlossaryTerm } from "../glossary.js";
|
|
14
|
-
import
|
|
14
|
+
import {
|
|
15
|
+
STANDING_LABEL,
|
|
16
|
+
type HealthFlag,
|
|
17
|
+
type HealthStanding,
|
|
18
|
+
type HealthStatus,
|
|
19
|
+
} from "../health.js";
|
|
15
20
|
import { dayOf, momentOf, pct, QUIET_BUTTON } from "./format.js";
|
|
16
21
|
|
|
17
22
|
/**
|
|
@@ -115,8 +120,22 @@ export type EvalComponents = {
|
|
|
115
120
|
TextArea: ComponentType<TextAreaProps>;
|
|
116
121
|
Select: ComponentType<SelectProps>;
|
|
117
122
|
RefreshWhile: ComponentType<RefreshWhileProps>;
|
|
123
|
+
/**
|
|
124
|
+
* Your app's toast, for what happened after a quick action (an answer
|
|
125
|
+
* confirmed, or a save that failed). Without it, the screens say so in
|
|
126
|
+
* place, and say nothing on success.
|
|
127
|
+
*/
|
|
128
|
+
notify: Notify;
|
|
118
129
|
};
|
|
119
130
|
|
|
131
|
+
/** Shows a short message as your app does (`EvalComponents.notify`). */
|
|
132
|
+
export type Notify = (type: "success" | "error", message: string) => void;
|
|
133
|
+
|
|
134
|
+
/** Your app's toast, if it gave one (`EvalComponents.notify`). */
|
|
135
|
+
export function useNotify(): Notify | undefined {
|
|
136
|
+
return useContext(Swapped).notify;
|
|
137
|
+
}
|
|
138
|
+
|
|
120
139
|
const Swapped = createContext<Partial<EvalComponents>>({});
|
|
121
140
|
|
|
122
141
|
/**
|
|
@@ -243,6 +262,63 @@ function flagChips(f: HealthFlag): { text: string; tone: ChipTone }[] {
|
|
|
243
262
|
}
|
|
244
263
|
}
|
|
245
264
|
|
|
265
|
+
const STANDING_TONE: Record<HealthStanding, ChipTone> = {
|
|
266
|
+
risk: "serious",
|
|
267
|
+
improve: "warn",
|
|
268
|
+
healthy: "live",
|
|
269
|
+
unknown: "neutral",
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* A suite's one status, colored by what it asks of you: red at risk, amber
|
|
274
|
+
* can improve, green healthy, gray can't tell yet. Each color means only
|
|
275
|
+
* that, so a glance down the hub finds what needs you.
|
|
276
|
+
*/
|
|
277
|
+
export function StandingBadge({ standing }: { standing: HealthStanding }) {
|
|
278
|
+
return <Chip tone={STANDING_TONE[standing]}>{STANDING_LABEL[standing]}</Chip>;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* The reasons behind a suite's standing as one plain line ("1 serious
|
|
283
|
+
* under bar · New fallback suggested"), for under its name. Provisional
|
|
284
|
+
* answers are left out: a choice, not a problem, so the card says it in a
|
|
285
|
+
* footnote instead.
|
|
286
|
+
*/
|
|
287
|
+
export function HealthReasons({ flags }: { flags: readonly HealthFlag[] }) {
|
|
288
|
+
const reasons = flags
|
|
289
|
+
.filter((f) => f.kind !== "provisional" && f.kind !== "good")
|
|
290
|
+
.flatMap(flagChips);
|
|
291
|
+
if (!reasons.length) return null;
|
|
292
|
+
// Each in its standing's color with an icon, so it reads at a glance
|
|
293
|
+
// without another row of chips.
|
|
294
|
+
return (
|
|
295
|
+
<ul className="flex flex-wrap gap-x-4 gap-y-1 text-sm font-medium">
|
|
296
|
+
{reasons.map((r) => {
|
|
297
|
+
const urgent = r.tone === "serious" || r.tone === "warn";
|
|
298
|
+
return (
|
|
299
|
+
<li
|
|
300
|
+
key={r.text}
|
|
301
|
+
className={`inline-flex items-center gap-1.5 ${
|
|
302
|
+
r.tone === "serious"
|
|
303
|
+
? "text-bad"
|
|
304
|
+
: r.tone === "warn"
|
|
305
|
+
? "text-warn"
|
|
306
|
+
: "text-ink"
|
|
307
|
+
}`}
|
|
308
|
+
>
|
|
309
|
+
{urgent ? (
|
|
310
|
+
<CircleAlert aria-hidden className="h-4 w-4 shrink-0" />
|
|
311
|
+
) : (
|
|
312
|
+
<Info aria-hidden className="h-4 w-4 shrink-0 text-muted" />
|
|
313
|
+
)}
|
|
314
|
+
{r.text}
|
|
315
|
+
</li>
|
|
316
|
+
);
|
|
317
|
+
})}
|
|
318
|
+
</ul>
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
246
322
|
/**
|
|
247
323
|
* A suite's health as chips naming each reason ("2 serious under bar",
|
|
248
324
|
* "New fallback suggested", "Add cases (33 of 50)"), so a card says why at
|
package/src/types.ts
CHANGED
|
@@ -286,6 +286,27 @@ export type Suite<Input, Output, Label> = {
|
|
|
286
286
|
* the model, so it doesn't change the instructions hash.
|
|
287
287
|
*/
|
|
288
288
|
answerGuide?: AnswerGuide;
|
|
289
|
+
/**
|
|
290
|
+
* What a person should look at to check this case's answer: shown with
|
|
291
|
+
* the answer to confirm ("Look at: pay is below their floor"), each
|
|
292
|
+
* note's `marks` highlighted wherever they appear in the input. Pick
|
|
293
|
+
* them by rule from the case (a dealbreaker beside what it rules on),
|
|
294
|
+
* never from the draft answer's own reasoning: that steers a person to
|
|
295
|
+
* agree with it. When models' tests disagree, the answer key says so on
|
|
296
|
+
* its own. For people only: it never reaches the model.
|
|
297
|
+
*
|
|
298
|
+
* @param input - The case's input, already checked against `input`.
|
|
299
|
+
* @param answer - The answer being checked, or null without one.
|
|
300
|
+
*/
|
|
301
|
+
lookAt?(input: Input, answer: Label | null): LookAt[];
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/** One thing to look at when checking an answer (`Suite.lookAt`). */
|
|
305
|
+
export type LookAt = {
|
|
306
|
+
/** A short note: "pay is below their $70K floor". */
|
|
307
|
+
note: string;
|
|
308
|
+
/** Text to highlight in the case's input: "$55,000–$61,000". */
|
|
309
|
+
marks?: string[];
|
|
289
310
|
};
|
|
290
311
|
|
|
291
312
|
/** How to judge a suite's answers: a lead-in, the points, and a note. */
|
|
@@ -333,6 +354,8 @@ export type FormField = {
|
|
|
333
354
|
kind: "text" | "textarea" | "select" | "lines" | "json";
|
|
334
355
|
/** For "select". */
|
|
335
356
|
options?: readonly string[];
|
|
357
|
+
/** For "select": how each option reads to a person ("YES" → "Would apply"). */
|
|
358
|
+
optionLabels?: Readonly<Record<string, string>>;
|
|
336
359
|
required?: boolean;
|
|
337
360
|
};
|
|
338
361
|
|