import {
BarChart,
Button,
Callout,
Card,
CardBody,
CardHeader,
CollapsibleSection,
Divider,
Grid,
H1,
H2,
H3,
Pill,
Row,
Stack,
Stat,
Swatch,
Table,
Text,
UsageBar,
usageColorSequence,
useCanvasAction,
useHostTheme,
} from "cursor/canvas";
const report = /*__BETTER_HARNESS_REPORT__*/ null as any;
function list(value: any): any[] {
return Array.isArray(value) ? value.filter(Boolean) : [];
}
function copy(english: string, chinese: string): string {
return report?.summary?.locale === "zh-CN" ? chinese : english;
}
function number(value: any): number {
const parsed = Number(value);
return Number.isFinite(parsed) ? parsed : 0;
}
function formatNumber(value: any): string {
return new Intl.NumberFormat(report?.summary?.locale === "zh-CN" ? "zh-CN" : "en-US", {
maximumFractionDigits: 1,
}).format(number(value));
}
function formatTokens(value: any): string {
const tokens = number(value);
if (tokens >= 1_000_000) return `${(tokens / 1_000_000).toFixed(1)}M`;
if (tokens >= 1_000) return `${(tokens / 1_000).toFixed(1)}K`;
return formatNumber(tokens);
}
function findingFilePath(finding: any): string | null {
const target = finding?.target;
for (const candidate of [target?.path, target?.file, target?.workspaceRelativePath]) {
if (typeof candidate === "string" && candidate.trim()) return candidate.trim();
}
return null;
}
function OpenFileButton({ path, label }: { path?: string | null; label?: string }) {
const dispatch = useCanvasAction();
if (!path) return null;
return (
dispatch({ type: "openFile", path })}>
{label ?? copy("Open file", "打开文件")}
);
}
function NewChatButton({ prompt, label, primary = false }: { prompt?: string | null; label: string; primary?: boolean }) {
const dispatch = useCanvasAction();
return (
prompt && dispatch({ type: "newComposerChat", userPrompt: prompt })}
>
{label}
);
}
function OpenAgentButton({ agentId }: { agentId?: string | null }) {
const dispatch = useCanvasAction();
if (!agentId) return null;
return (
dispatch({ type: "openAgent", agentId })}>
{copy("Open source conversation", "打开来源会话")}
);
}
function ReportHeader() {
const contextUsage = report?.summary?.contextUsage;
return (
BETTER HARNESS · AGENT WORK LOOP
{report?.summary?.projectName ?? copy("Better Harness report", "Better Harness 报告")}
{report?.summary?.overview ?? copy("Evidence-bounded engineering readiness report.", "基于证据边界的工程就绪度报告。")}
{report?.summary?.evidenceMode ?? "unobserved"}
{copy("No aggregate score", "不计算总分")}
);
}
function Strengths() {
const strengths = list(report?.summary?.strengths);
if (strengths.length === 0) return null;
return (
{copy("What is already working", "已有的有效基础")}
{strengths.slice(0, 4).map((strength: string, index: number) => (
{strength}
))}
);
}
function FluencyDimensions() {
const dimensions = list(report?.summary?.dimensions);
return (
{copy("Fluency", "Fluency")}
{copy(
"Five evidence-bounded dimensions. Scores stay separate so one strong area cannot hide another area's gap.",
"五个有证据边界的维度分别呈现,避免某个强项掩盖其他环节的缺口。",
)}
dimension.label ?? dimension.id)}
series={[{ name: copy("Score", "分数"), data: dimensions.map((dimension: any) => number(dimension.score)) }]}
horizontal
height={Math.max(240, dimensions.length * 54)}
yMin={0}
yMax={100}
valueSuffix=" / 100"
showValues
/>
{dimensions.map((dimension: any) => (
= 70}>{formatNumber(dimension.score)}}>
{dimension.label ?? dimension.id}
{dimension.summary ?? dimension.scoreReason ?? "—"}
))}
);
}
function ProjectUsage() {
const activity = report?.summary?.usageActivity;
const efficiency = report?.summary?.usageEfficiency;
if (!activity && !efficiency) {
return (
{copy("Project usage", "项目使用情况")}
{copy("Session usage was not observed for this report window.", "本次报告窗口没有观察到会话使用数据。")}
);
}
const dates = list(activity?.dates).slice(-30);
const activeMinutes = list(activity?.sessions?.activeMinutes).slice(-dates.length).map(number);
const selection = efficiency?.selection ?? {};
return (
{copy("Project usage", "项目使用情况")}
sum + value, 0))} label={copy("Active minutes · 30d", "活跃分钟 · 30 天")} />
0 ? "warning" : undefined} />
{dates.length > 0 ? (
) : null}
);
}
function AgentPractice() {
const practice = report?.summary?.aiAgentPractice ?? {};
const rows = list(practice.coverageRows);
return (
{copy("AI Agent Practice", "AI Agent Practice")}
{copy("Configured assets and representative safe sources observed by this scan.", "本次扫描观察到的 Agent 配置资产及代表性安全来源。")}
{
const paths = list(entry.paths).filter((value: any) => typeof value === "string");
return [
entry.surface ?? "—",
`${formatNumber(entry.count)} · ${list(entry.scopes).join(", ") || "—"}`,
paths[0] ? : "—",
];
})}
emptyMessage={copy("No configured asset inventory was retained.", "未保留配置资产清单。")}
striped
/>
);
}
function ContextWindow() {
const usage = report?.summary?.contextUsage;
if (!usage || usage.status !== "observed") {
return (
{copy("Context Window", "Context Window")}
{copy(
"Cursor did not expose a workspace Context Usage canvas for this report window. No token total or category share is inferred.",
"Cursor 在本次报告窗口中没有提供工作区 Context Usage Canvas,因此不会推断 token 总量或分类占比。",
)}
);
}
const categories = list(usage.categories);
const items = list(usage.items);
return (
{copy("Context Window", "Context Window")}
{copy("Latest workspace-scoped native Cursor snapshot; raw item text is omitted.", "最新的工作区级 Cursor 原生快照;原始条目文本已省略。")}
({
id: category.id,
value: number(category.estimatedTokens),
color: usageColorSequence[index % usageColorSequence.length],
}))}
/>
{categories.map((category: any, index: number) => {
const categoryItems = items
.filter((item: any) => item.categoryId === category.id)
.sort((left: any, right: any) => number(right.estimatedTokens) - number(left.estimatedTokens));
return (
}
trailing={{formatTokens(category.estimatedTokens)} tokens }
>
{categoryItems.slice(0, 20).map((item: any) => (
{item.label}
{formatTokens(item.estimatedTokens)} tokens · {formatNumber(item.characterCount)} chars
))}
{categoryItems.length > 20 ? (
{copy("Additional bounded items omitted from the default view.", "其余有界条目已从默认视图中省略。")}
) : null}
);
})}
);
}
function Findings() {
const findings = list(report?.findings);
return (
{copy("Prioritized improvements", "优先改进项")}
{copy(`${findings.length} evidence-backed findings`, `${findings.length} 项有证据支持的发现`)}
{findings.map((finding: any) => {
const outputs = list(finding.expectedOutput);
const filePath = findingFilePath(finding);
return (
{finding.severity ?? "—"}}>
{finding.title ?? finding.id}
{finding.reason ?? "—"}
{outputs.length > 0 ? (
{outputs.map((output: string, index: number) => (
{index + 1}. {output}
))}
) : null}
);
})}
);
}
function Suggestions() {
const suggestions = list(report?.summary?.suggestions);
if (suggestions.length === 0) return null;
return (
{copy("Next opportunities", "后续机会")}
{suggestions.map((suggestion: any) => (
{suggestion.confidence ?? "—"}}
>
{suggestion.reason ?? "—"}
{copy("Next step: ", "下一步:")} {suggestion.nextStep ?? "—"}
))}
);
}
function EvidenceAndMethodology() {
const boundary = report?.summary?.evidenceBoundary ?? {};
const manifest = boundary.manifest ?? {};
const selection = manifest.selection ?? {};
const facets = list(report?.summary?.semanticFacets?.entries);
const sourceGaps = list(boundary.sourceGaps);
return (
{copy("Evidence and methodology", "证据与方法")}
0 ? "warning" : "info"} title={copy("Decision boundary", "决策边界")}>
{copy(
`Analyzed ${formatNumber(selection.analyzedCount)} of ${formatNumber(selection.eligibleCount)} eligible sessions with ${selection.confidence ?? "unknown"} sampling confidence.`,
`共分析 ${formatNumber(selection.analyzedCount)} / ${formatNumber(selection.eligibleCount)} 个符合条件的会话,抽样可信度为 ${selection.confidence ?? "未知"}。`,
)}
0 ? "warning" : "success"} />
{facets.length > 0 ? (
{copy("Session observations", "会话观察")}
{facets.slice(0, 6).map((facet: any, index: number) => (
{facet.title ?? facet.label ?? copy("Observation", "观察")}
{facet.summary ?? facet.body ?? "—"}
))}
) : null}
{sourceGaps.length > 0
? sourceGaps.map((gap: string) => {gap} )
: {copy("No declared source gaps.", "没有声明的来源缺口。")} }
);
}
export default function BetterHarnessCursorReport() {
const theme = useHostTheme();
return (
);
}