peppa/apps/web/lib/chat-text.ts
peppa-bot e8247924c6 PEP-207: чаты — понятно, что от меня нужно, и это можно сделать на месте
Агент не меняет статус принятой задачи (причина противоречия в PEP-204);
«Посмотреть результат» / «Принять» / «Поправить» в сообщении «готово»;
переписка сверху вниз с полем ввода внизу; строка состояния вместо служебных
сообщений; компактные события; очистка «Всех событий»; выбор проекта списком;
«Задача описана. Начать работу?».

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 00:30:02 +05:00

15 lines
840 B
TypeScript

import { userText } from "@peppa/core";
/** PEP-207: what a person reads of the factory's text — no terminal output, paths or service blocks. */
export function cleanText(text: string, superadmin: boolean, gitea = ""): string {
if (superadmin) return text;
// The agent CLI's screen («⏺ Calling…», «⎿ …», rules) starts where the person's text ends.
const lines = text.split("\n");
const cut = lines.findIndex((l) => TERMINAL_LINE.test(l));
let out = userText(cut >= 0 ? lines.slice(0, cut).join("\n") : text) || lines[0]!;
if (gitea) out = out.split(gitea).length > 1 ? out.replace(new RegExp(`${gitea.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\S*`, "g"), "").replace(/[ \t]+\n/g, "\n").trim() : out;
return out;
}
const TERMINAL_LINE = /^\s*(?:[⏺⎿●│└├╭╰─━]|\$ |> |✻|Calling\b|Running\b)/;