// Project page tabs «Код», «Спеки», «PR» and the epics block of «⋯ Настройки проекта» (PEP-66). import type { Words } from "@peppa/shared/wording"; import { Archive, ExternalLink, GitBranch, GitPullRequest, Pencil } from "lucide-react"; import type { Epic, SpecSummary } from "@peppa/core"; import { Markdown } from "@/components/Markdown"; import type { AgentsMd, OpenPull, RepoOverview } from "@peppa/runner"; import { addEpic, editEpic, saveAgentsMdAction } from "../../actions"; import { Hidden } from "@/components/cards"; import { Disclosure, Empty, Key, Notice, Section, StatusBadge } from "@/components/common"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Input, Textarea } from "@/components/ui/input"; import { getT } from "@/lib/i18n"; import { intlLocale, type Translator } from "@peppa/shared/i18n"; const when = (iso: string | null, t: Translator) => (iso ? new Date(iso).toLocaleString(intlLocale(t.locale), { dateStyle: "short", timeStyle: "short" }) : "—"); export async function CodeTab({ code }: { code: RepoOverview }) { const t = await getT(); const gitea = ( ); if (code.error) { return (
{t.text(code.error)}. {t("Репозиторий:")} {code.url}
); } return (
README {code.readme && {code.readme.path}}} actions={gitea}> {code.readme ? (
{code.readme.text}
) : ( {code.defaultBranch ? t("В ветке {branch} нет README.", { branch: code.defaultBranch }) : t("Репозиторий пуст.")} )}
{code.branches.length === 0 ? ( {t("Веток нет.")} ) : (
    {code.branches.map((b) => (
  • {b.name} {b.name === code.defaultBranch && {t("по умолчанию")}} {b.sha.slice(0, 7)}
  • ))}
)}
{code.commits.length === 0 ? ( {t("Коммитов нет.")} ) : (
    {code.commits.map((c) => (
  • {c.message} {c.sha.slice(0, 7)} {c.author} · {when(c.date, t)}
  • ))}
)}
); } /** PEP-30: the project memory (.peppa/memory.md of the working copy), written by agents. */ export async function MemorySection({ text, chars, max, nearLimit }: { text: string; chars: number; max: number; nearLimit: boolean }) { const t = await getT(); return (
{t("{chars} из {max} символов", { chars, max })}} className="mb-8">

{t("Что агенты запомнили для следующих стори: команды, соглашения, грабли, решения")} (.peppa/memory.md, MCP remember). {t("Раннер подкладывает её агенту при каждом запуске.")}

{text.trim() ? ( {nearLimit ? t("Показать память — почти предел, агент ужмёт её") : t("Показать память")}}> ) : ( {t("Память пуста — агенты пополнят её в конце стори.")} )}
); } export async function SpecsTab({ specs }: { specs: SpecSummary[] }) { const t = await getT(); return (

{t("Что система умеет сейчас: требования OpenSpec из рабочей копии (openspec/specs). Обновляются, когда стори архивирует свой change.")}

{specs.length === 0 ? ( {t("Спек ещё нет — они появляются после archive первого change.")} ) : ( specs.map((s) => ( {s.name} {t.n(s.requirements, "{n} требование", "{n} требования", "{n} требований")} {s.purpose && {s.purpose.split("\n")[0]}} } >
{s.text}
)) )}
); } const CI_TONE = { success: "ok", failure: "danger", pending: "info", none: "muted", not_configured: "muted" } as const; export async function PullsTab({ pulls, error, repoUrl }: { pulls: OpenPull[]; error: string | null; repoUrl: string }) { const t = await getT(); return (
{t("Все PR в Gitea")} } > {error ? ( {t.text(error)}. ) : pulls.length === 0 ? ( {t("Открытых PR нет.")} ) : ( pulls.map((p) => (
#{p.number} {p.title}
{p.branch} {p.task ? ( <> · {p.task.key} {t.text(p.task.ci.label)} ) : ( · {t("не стори FORGE")} )}
)) )}
); } /** «⋯ Настройки проекта» → Эпики: labels that group stories (stored as goals). */ /** PEP-34: done/total of an epic as a thin bar. */ export async function ProgressBar({ done, total, className }: { done: number; total: number; className?: string }) { const t = await getT(); const pct = total ? Math.round((done / total) * 100) : 0; return ( ); } export async function EpicsPanel({ projectId, projectKey, epics, progress, back, w }: { w: Words; projectId: number; projectKey: string; epics: Epic[]; progress: Map; back: string }) { const t = await getT(); return (
{epics.length === 0 &&

{t("Эпиков нет. Эпик — большая цель, которая объединяет {tasks}; его описание агент получает вместе с {task}.", { tasks: w.task("accPl"), task: w.task("ins") })}

} {epics.map((e) => (
› {e.title} {progress.get(e.id)?.done ?? 0}/{progress.get(e.id)?.total ?? 0} {w.engineer && #{e.id}}