diff --git a/openspec/changes/pep-303-screen-watchers-own-lines/tasks.md b/openspec/changes/pep-303-screen-watchers-own-lines/tasks.md index 4e1f4b4e..2fc526c1 100644 --- a/openspec/changes/pep-303-screen-watchers-own-lines/tasks.md +++ b/openspec/changes/pep-303-screen-watchers-own-lines/tasks.md @@ -1,16 +1,16 @@ ## 1. Распознавание экрана -- [ ] 1.1 `screen-lines.ts`: `isQuotedLine`, `ownLines`, `unbox` -- [ ] 1.2 Плашка лимита: `LIMIT_LINE_RE`/`isLimitLine`, `limitLines` через неё; мёртвое окно в вачдоге — через `limitLines` -- [ ] 1.3 Диалог кредитов: структура «вопрос → варианты внизу» -- [ ] 1.4 Меню модели и доверие папке Codex, `startQuestion`, `usageWarning` — только «свои» строки -- [ ] 1.5 Вачдог: нажатия и сообщение о кредитах — только на неизменившемся экране +- [x] 1.1 `screen-lines.ts`: `isQuotedLine`, `ownLines`, `unbox` +- [x] 1.2 Плашка лимита: `LIMIT_LINE_RE`/`isLimitLine`, `limitLines` через неё; мёртвое окно в вачдоге — через `limitLines` +- [x] 1.3 Диалог кредитов: структура «вопрос → варианты внизу» +- [x] 1.4 Меню модели и доверие папке Codex, `startQuestion`, `usageWarning` — только «свои» строки +- [x] 1.5 Вачдог: нажатия и сообщение о кредитах — только на неизменившемся экране ## 2. Тесты -- [ ] 2.1 Мок `credits`; тесты диалога в `lost-conversation.test.ts` — на нём -- [ ] 2.2 `screen-watchers.test.ts`: diff/grep с фразой и «1. Switch to Opus» — нет тревоги и нажатия; строка лимита в diff — нет `usage_limit`, подписка не помечена, агент не остановлен; настоящие плашки Claude/Codex на живом и мёртвом окне узнаются -- [ ] 2.3 Проверить, что новые тесты падают на старом коде; прогнать связанные тесты (limits, codex-recovery, start-hang, lost-conversation, subscription-*) +- [x] 2.1 Мок `credits`; тесты диалога в `lost-conversation.test.ts` — на нём +- [x] 2.2 `screen-watchers.test.ts`: diff/grep с фразой и «1. Switch to Opus» — нет тревоги и нажатия; строка лимита в diff — нет `usage_limit`, подписка не помечена, агент не остановлен; настоящие плашки Claude/Codex на живом и мёртвом окне узнаются +- [x] 2.3 Проверить, что новые тесты падают на старом коде; прогнать связанные тесты (limits, codex-recovery, start-hang, lost-conversation, subscription-*) ## 3. Завершение diff --git a/packages/runner/src/limits.ts b/packages/runner/src/limits.ts index c9b03f85..a7357057 100644 --- a/packages/runner/src/limits.ts +++ b/packages/runner/src/limits.ts @@ -17,13 +17,13 @@ const REPEAT_WINDOW_MS = 5 * 60_000; // PEP-205: Codex prints a typographic apostrophe — «You’ve hit your usage limit … try again at 8:47 PM». export const LIMIT_SCREEN_RE = /(usage limit reached|limit reached.{0,40}reset|you[’'`]ve hit your (usage )?limit|out of extra usage)/i; -// PEP-303: a banner is a line the CLI printed, so it *begins* with the limit phrase — after at most one -// glyph of the CLI («■ ⎿ ⏺ ● ✗ ⚠ ·»; not «+ - < > | : # * /» nor a frame) and the words it puts in front +// PEP-303: a banner is a line the CLI printed, so it *begins* with the limit phrase — after at most two +// glyphs of the CLI («■ ⎿ ⏺ ● ✗ ⚠ ·»; not «+ - < > | : # * /» nor a frame) and the words it puts in front // («API Error:», «Claude (AI)», «5-hour», «weekly»). A diff line («447 + out(`■ You’ve hit…`)»), grep // output, code or a comment that quotes the phrase is not a banner. Without a glyph the line may be // indented by two spaces at most: the continuation lines of a tool's output are indented by five. const LIMIT_LINE_RE = - /^(?:\s*[^\w\s"'`(\[{<>|:+\-#*\/─-╿]️?\s*|\s{0,2})(?:API Error:\s*)?(?:Claude(?: AI)?\s+|(?:\d+-hour|(?:opus\s+)?weekly)\s+)?(?:you[’'`]re\s+)?(?:usage limit reached|limit reached.{0,40}reset|you[’'`]ve hit your (?:usage )?limit|out of extra usage)/iu; + /^(?:(?:\s*[^\w\s"'`(\[{<>|:+\-#*\/─-╿]️?){1,2}\s*|\s{0,2})(?:API Error:\s*)?(?:Claude(?: AI)?\s+|(?:\d+-hour|(?:opus\s+)?weekly)\s+)?(?:you[’'`]re\s+)?(?:usage limit reached|limit reached.{0,40}reset|you[’'`]ve hit your (?:usage )?limit|out of extra usage)/iu; /** One screen line is the CLI's limit banner (see LIMIT_LINE_RE), not a quote of it. */ export const isLimitLine = (line: string): boolean => LIMIT_LINE_RE.test(line) && !isQuotedLine(line);