feat(observer): extend classifyPromptSignal vocabulary

Closes brain-retro 2026-05-20 #9 — добавлены маркеры:
- correction: 'не совсем', 'другое|другая', 'не сходится', 'wrong direction'
- approval: 'класс', 'хорошо', 'принято', 'well done', 'nice'
- new_task (prefix): 'теперь', 'далее', 'следующее', 'next', 'now'

NB на JS \b с Cyrillic: \b matches word↔non-word boundary, но Cyrillic
chars не word-chars в JS RegExp default → \b после русского слова
никогда не fires. Решение: substring-match для русских correction-маркеров;
lookahead с явными разделителями для start-of-prompt new_task маркеров.

11 new vitest tests, 301/301 GREEN.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Дмитрий
2026-05-20 13:17:11 +03:00
parent ffaeb8f37b
commit f8b32a7d3a
2 changed files with 39 additions and 2 deletions
+36
View File
@@ -1291,3 +1291,39 @@ describe('promptText strips <system-reminder> blocks (Task 8)', () => {
expect(ep.primary_rationale.task_classification).toBe('refactor');
});
});
describe('classifyPromptSignal — extended dictionary (Task 9)', () => {
it('detects "не совсем" as correction', () => {
expect(classifyPromptSignal('не совсем то')).toBe('correction');
});
it('detects "wrong direction" as correction', () => {
expect(classifyPromptSignal('wrong direction here')).toBe('correction');
});
it('detects "другое" as correction', () => {
expect(classifyPromptSignal('другое решение нужно')).toBe('correction');
});
it('detects "класс" as approval', () => {
expect(classifyPromptSignal('класс')).toBe('approval');
});
it('detects "well done" as approval', () => {
expect(classifyPromptSignal('well done')).toBe('approval');
});
it('detects "nice" as approval', () => {
expect(classifyPromptSignal('nice')).toBe('approval');
});
it('detects "теперь" prefix as new_task', () => {
expect(classifyPromptSignal('теперь сделай биллинг')).toBe('new_task');
});
it('detects "далее" prefix as new_task', () => {
expect(classifyPromptSignal('далее переходим к настройкам')).toBe('new_task');
});
it('detects "next" prefix as new_task', () => {
expect(classifyPromptSignal('next step please')).toBe('new_task');
});
it('preserves existing — neutral for nondescript text', () => {
expect(classifyPromptSignal('некий случайный текст')).toBe('neutral');
});
it('preserves existing — correction "переделай"', () => {
expect(classifyPromptSignal('переделай это')).toBe('correction');
});
});