mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
pnpm eval drives the production workbench in Chromium against a release openidea-server and real jdtls, judging each scenario (navigation, usages, implementations, gutter markers, lenses, diagnostics, completion, docs, rename) on time to feedback, first and complete result, and checking results against evals/java/golden/. Supporting changes: data-* hooks in the usages popup, hints and rows; a shared in-page Tauri shim for smoke tests and evals; a shared perf bundle builder; language-server versions in .github/tool-versions.env shared with Language smoke; the eval agent skill.
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
/**
|
|
* Golden results: what a scenario found when a person last confirmed it, keyed to the
|
|
* language server and JDK that found it. Compared as sets (recall / precision), not by order.
|
|
*/
|
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
import { dirname } from "node:path";
|
|
|
|
/** Result group → items (e.g. `src/…/OrderBook.java:14`); repeated items count once. */
|
|
export type ResultSet = Record<string, string[]>;
|
|
|
|
export interface Golden {
|
|
/** Tool versions the results were recorded with (`jdtls`, `java`). */
|
|
tools: Record<string, string>;
|
|
groups: ResultSet;
|
|
}
|
|
|
|
export interface Comparison {
|
|
recall: number;
|
|
precision: number;
|
|
/** In the golden, not found (`group: item`). */
|
|
missing: string[];
|
|
/** Found, not in the golden. */
|
|
extra: string[];
|
|
}
|
|
|
|
const keys = (set: ResultSet) => new Set(Object.entries(set).flatMap(([g, items]) => items.map((i) => `${g}: ${i}`)));
|
|
|
|
export function compare(found: ResultSet, golden: ResultSet): Comparison {
|
|
const got = keys(found);
|
|
const want = keys(golden);
|
|
const missing = [...want].filter((k) => !got.has(k));
|
|
const extra = [...got].filter((k) => !want.has(k));
|
|
const hit = want.size - missing.length;
|
|
return {
|
|
// Nothing expected and nothing found is a perfect answer.
|
|
recall: want.size ? hit / want.size : 1,
|
|
precision: got.size ? hit / got.size : want.size ? 0 : 1,
|
|
missing: missing.sort(),
|
|
extra: extra.sort(),
|
|
};
|
|
}
|
|
|
|
export function readGolden(file: string): Golden | null {
|
|
return existsSync(file) ? (JSON.parse(readFileSync(file, "utf8")) as Golden) : null;
|
|
}
|
|
|
|
export function writeGolden(file: string, golden: Golden) {
|
|
mkdirSync(dirname(file), { recursive: true });
|
|
const sorted = Object.fromEntries(
|
|
Object.entries(golden.groups)
|
|
.sort(([a], [b]) => a.localeCompare(b))
|
|
.map(([g, items]) => [g, [...new Set(items)].sort()]),
|
|
);
|
|
writeFileSync(file, JSON.stringify({ tools: golden.tools, groups: sorted }, null, 2) + "\n");
|
|
}
|
|
|
|
/** Tools that differ between the golden's recording and this run (`name: was → now`). */
|
|
export function toolDrift(golden: Golden, tools: Record<string, string>): string[] {
|
|
return Object.entries(golden.tools)
|
|
.filter(([k, v]) => tools[k] !== undefined && tools[k] !== v)
|
|
.map(([k, v]) => `${k}: ${v} → ${tools[k]}`);
|
|
}
|