import type { Locale } from "./model"; export const stageLabels = { en: { plan: "Plan", review: "Review", freeze: "Freeze", execution: "Build", verification: "Verify", merge_pending: "Merge", merged: "Merged", }, "zh-CN": { plan: "计划", review: "评审", freeze: "冻结", execution: "构建", verification: "验证", merge_pending: "待合并", merged: "已合并", }, } as const; export const runModeLabels = { en: { exec: "New thread", resume: "Continue thread", }, "zh-CN": { exec: "新线程", resume: "继续线程", }, } as const; export const roleLabels = { en: { user: "User", leader: "Leader", worker: "Worker", }, "zh-CN": { user: "用户", leader: "Leader", worker: "Worker", }, } as const; export function humanize(value: string): string { return value .replace(/[_-]+/g, " ") .trim() .replace(/\b\w/g, (match) => match.toUpperCase()); } export function formatStageLabelValue(stage: string | undefined, locale: Locale, fallback: string): string { if (!stage) return fallback; return stageLabels[locale][stage as keyof (typeof stageLabels)[Locale]] ?? humanize(stage); } export function formatRunModeLabelValue(mode: string | undefined, locale: Locale, fallback: string): string { if (!mode) return fallback; return runModeLabels[locale][mode as keyof (typeof runModeLabels)[Locale]] ?? humanize(mode); } export function formatRoleLabelValue(role: string, locale: Locale): string { return roleLabels[locale][role as keyof (typeof roleLabels)[Locale]] ?? humanize(role); }