peppa/packages/shared/src/wording.ts
peppa-bot f3d10a4c25 PEP-243: платформа называется FORGE — название во всех текстах для людей и подсказках агентам, адрес forge.telecom.quest
«Peppa FACTORY» → «FORGE» в экранах, сообщениях, словарях en/kk, шаблоне и тестах; «Пеппа» → «FORGE» в подсказках
агентам и правилах; логотип, значок, версия кэша service worker; в словаре старые названия — в «Нельзя».
Внутренние имена (CLI peppa, PEPPA_*, MCP-сервер peppa, ключи PEP-N) не меняются. Второй адрес — в mac-route.sh.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 11:18:49 +05:00

113 lines
4.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// PEP-123: the words a person reads depend on the view (PEP-119). «Продакт» reads «задача» and
// «агент» (docs/glossary.md); «Инженер» keeps «стори» (one OpenSpec change; «задачи» there are
// the items of tasks.md) and «раннер» (the process, as opposed to the agent's persona).
// Pure module: used by the browser too.
export type WordMode = "product" | "engineer";
/** Case forms: singular nom/gen/dat/acc/ins/pre and the same in plural. */
export type WordForm = "nom" | "gen" | "dat" | "acc" | "ins" | "pre" | "pl" | "genPl" | "datPl" | "accPl" | "insPl" | "prePl";
export const BRAND = "FORGE";
const TASK: Record<WordForm, string> = {
nom: "задача",
gen: "задачи",
dat: "задаче",
acc: "задачу",
ins: "задачей",
pre: "задаче",
pl: "задачи",
genPl: "задач",
datPl: "задачам",
accPl: "задачи",
insPl: "задачами",
prePl: "задачах",
};
// «агент» and «раннер» decline alike; both are animate, so the accusative follows the genitive.
const ENDING: Record<WordForm, string> = { nom: "", gen: "а", dat: "у", acc: "а", ins: "ом", pre: "е", pl: "ы", genPl: "ов", datPl: "ам", accPl: "ов", insPl: "ами", prePl: "ах" };
const cap = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
/** «1 задача», «2 задачи», «5 задач» — the form of a counted noun. */
export function plural(n: number, one: string, few: string, many: string): string {
const d = Math.abs(n) % 100;
const u = d % 10;
if (d > 10 && d < 20) return many;
if (u === 1) return one;
return u >= 2 && u <= 4 ? few : many;
}
export interface Words {
mode: WordMode;
/** True in «Продакт»: hide what only an engineer reads. */
product: boolean;
engineer: boolean;
/** «задача» / «стори» in the given form. */
task(form?: WordForm): string;
/** The same, capitalized. */
Task(form?: WordForm): string;
/** «5 задач» / «5 стори». */
tasks(n: number): string;
/** «агент» / «раннер» in the given form. */
runner(form?: WordForm): string;
Runner(form?: WordForm): string;
}
// PEP-98: English words of the two views. Russian templates stay keys of the dictionary; the word is
// a {placeholder} filled from here, so «Создать {task}» reads «Create task» / «Create story».
const EN_PLURAL = new Set<WordForm>(["pl", "genPl", "datPl", "accPl", "insPl", "prePl"]);
export function wording(mode: WordMode | null | undefined, locale?: string | null): Words {
const product = mode !== "engineer";
if (locale === "en") {
const task = (form: WordForm = "nom") => (product ? "task" : "story") + (EN_PLURAL.has(form) ? (product ? "s" : "") : "");
const enTask = (form: WordForm = "nom") => (!product && EN_PLURAL.has(form) ? "stories" : task(form));
const runner = (form: WordForm = "nom") => (product ? "agent" : "runner") + (EN_PLURAL.has(form) ? "s" : "");
return {
mode: product ? "product" : "engineer",
product,
engineer: !product,
task: enTask,
Task: (form) => cap(enTask(form)),
tasks: (n) => `${n} ${enTask(n === 1 ? "nom" : "pl")}`,
runner,
Runner: (form) => cap(runner(form)),
};
}
if (locale === "kk") {
// PEP-99: a Kazakh case ending cannot be glued to a {placeholder}, so the Kazakh templates are
// written around the nominative and every form gives it (plural forms — the plural nominative).
const many = (form: WordForm) => EN_PLURAL.has(form);
const task = (form: WordForm = "nom") => (product ? "тапсырма" : "стори") + (many(form) ? (product ? "лар" : "лер") : "");
const runner = (form: WordForm = "nom") => (product ? "агент" : "раннер") + (many(form) ? (product ? "тер" : "лер") : "");
return {
mode: product ? "product" : "engineer",
product,
engineer: !product,
task,
Task: (form) => cap(task(form)),
// Kazakh does not change a noun after a number: «5 тапсырма».
tasks: (n) => `${n} ${task()}`,
runner,
Runner: (form) => cap(runner(form)),
};
}
const task = (form: WordForm = "nom") => (product ? TASK[form] : "стори");
const runner = (form: WordForm = "nom") => (product ? "агент" : "раннер") + ENDING[form];
return {
mode: product ? "product" : "engineer",
product,
engineer: !product,
task,
Task: (form) => cap(task(form)),
tasks: (n) => `${n} ${product ? plural(n, TASK.nom, TASK.gen, TASK.genPl) : "стори"}`,
runner,
Runner: (form) => cap(runner(form)),
};
}
/** Texts stored or sent without knowing the reader's view (chat events, Telegram, push). */
export const PRODUCT_WORDS = wording("product");