7d6b8b509f
v2.2.311 — 응답 지연 (실측: 출력 22토큰에 94.7초, 원인은 매 턴 13k+ 토큰 전체 재프리필) - KV 캐시 친화 프롬프트 분리(kvCachePromptSplit, 기본 ON): message[0]을 불변 정적 본문으로 고정, 날짜/RAG/[CONTEXT]/동적 블록을 마지막 user 메시지 직전의 internal system 메시지로 이동 — llama.cpp prompt cache 프리픽스 재사용으로 턴당 재프리필을 "직전 교환 + 동적 컨텍스트"로 축소. truncation 도 tail 적용. - 검색 토큰 예산 현실화(retrievalTokenBudget, 0=자동): 창의 25%(8k~80k) → 12%(2.5k~6k 클램프). - continuation 은 depth-0 memoryCtx 재사용: 라운드당 재검색 3~8초 제거 + 빈 쿼리 재검색으로 청크가 갈리던 문제 제거 + 턴 내 프롬프트 안정화. - 제2뇌 상주 캐시(신규 brainWatch.ts): 재귀 fs.watch 세대 카운터로 변경 없으면 디렉터리 워크·파일별 statSync 전면 생략. 수정 직후 3초 창은 신뢰 제외(이벤트 지연 레이스 가드), 워처 불가 시 종전 폴백, 활성화 시 백그라운드 워밍, 유휴 해제 30분→2시간. v2.2.312 — 보고 품질 (실사례: "## 4."부터 시작하는 7줄 일반론 보고서) - 중간 라운드 본문 표시 버그 수정: 액션과 함께 작성된 섹션(1~3)이 화면에 한 번도 안 나가고 최종 라운드만 표시되던 근본 원인 제거 — stripForDisplay.ts 로 액션 태그만 걷어내고 라운드 순서대로 버블에 표시. - '분석 보고' 업무 유형 신설(requirementGraph): 보고 개요(첫 줄 자기선언)·파일 근거(주장마다 실제 읽은 파일 인용, 일반론 금지)·구조·발견·다음 단계 강제, 유형 감지 시 "최대 3섹션" 규칙보다 필수 요소 커버 우선. - 근거 없는 분석 감지: 파일을 읽고도 인용 2개 미만인 장문 분석에 "근거 인용 없음" footer 경고 (헛조사 감지의 반대 방향). 검증: 전체 테스트 954건 통과(신규 28), tsc 무오류, vsix 패키징·설치 확인. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
147 lines
6.7 KiB
TypeScript
147 lines
6.7 KiB
TypeScript
/**
|
|
* Requirement Graph (Self-Evolving OS Phase 1 / Track 2-1) 단위 테스트.
|
|
* 순수 함수만 검증 — vscode 의존 없음.
|
|
*/
|
|
import {
|
|
DEFAULT_TASK_REQUIREMENTS,
|
|
detectTaskType,
|
|
buildRequirementGraphBlock,
|
|
checkRequirementCoverage,
|
|
formatRequirementCoverageFooter,
|
|
} from '../src/intelligence/requirementGraph';
|
|
|
|
describe('detectTaskType', () => {
|
|
it('회의록 요청을 감지한다', () => {
|
|
expect(detectTaskType('오늘 주간회의 내용 회의록으로 정리해줘')?.id).toBe('meeting-minutes');
|
|
expect(detectTaskType('어제 미팅 노트 만들어줘')?.id).toBe('meeting-minutes');
|
|
});
|
|
|
|
it('시장조사 요청을 감지한다', () => {
|
|
expect(detectTaskType('전기차 충전 인프라 시장조사 해줘')?.id).toBe('market-research');
|
|
expect(detectTaskType('국내 로봇청소기 시장 규모 분석 부탁해')?.id).toBe('market-research');
|
|
});
|
|
|
|
it('일정 관리 요청을 감지한다', () => {
|
|
expect(detectTaskType('내일 3시에 미팅 잡아줘')?.id).toBe('schedule');
|
|
expect(detectTaskType('이번 주 일정 확인해줘')?.id).toBe('schedule');
|
|
});
|
|
|
|
it('범용 조사 요청은 업무조사로 감지한다 (시장조사보다 후순위)', () => {
|
|
expect(detectTaskType('MCP 프로토콜에 대해 조사해줘')?.id).toBe('work-research');
|
|
});
|
|
|
|
it('일반 잡담·빈 입력은 null', () => {
|
|
expect(detectTaskType('안녕! 오늘 기분 어때?')).toBeNull();
|
|
expect(detectTaskType('')).toBeNull();
|
|
expect(detectTaskType(' ')).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('buildRequirementGraphBlock', () => {
|
|
it('회의록 블록에 필수 요소 5종이 모두 포함된다', () => {
|
|
const block = buildRequirementGraphBlock('회의록 정리해줘');
|
|
expect(block).toContain('[TASK REQUIREMENTS — 회의록]');
|
|
for (const label of ['참석자', '결정사항', '액션 아이템', '담당자', '기한']) {
|
|
expect(block).toContain(label);
|
|
}
|
|
expect(block).toContain('(확인 필요)'); // 조용한 생략 금지 지시
|
|
expect(block).toContain('[/TASK REQUIREMENTS]');
|
|
});
|
|
|
|
it('업무 유형 미감지 시 빈 문자열 (dynamicBlocks join 에서 자동 제외)', () => {
|
|
expect(buildRequirementGraphBlock('고마워!')).toBe('');
|
|
});
|
|
});
|
|
|
|
describe('checkRequirementCoverage', () => {
|
|
const fullMinutes = [
|
|
'# 주간회의 회의록',
|
|
'## 참석자: 김OO, 이OO',
|
|
'## 결정사항: A안 채택',
|
|
'## 액션 아이템',
|
|
'- 견적서 발송 (담당자: 김OO, 기한: 6월 20일까지)',
|
|
].join('\n');
|
|
|
|
it('모든 요소가 있으면 missing 이 빈 배열', () => {
|
|
const r = checkRequirementCoverage('회의록 정리해줘', fullMinutes);
|
|
expect(r.ran).toBe(true);
|
|
expect(r.taskId).toBe('meeting-minutes');
|
|
expect(r.missing).toEqual([]);
|
|
});
|
|
|
|
it('담당자·기한 누락을 검출한다', () => {
|
|
const partial = '# 회의록\n참석자: 김OO\n결정사항: A안 채택\n액션 아이템: 견적서 발송';
|
|
const r = checkRequirementCoverage('회의록 정리해줘', partial);
|
|
expect(r.ran).toBe(true);
|
|
expect(r.missing).toContain('담당자');
|
|
expect(r.missing).toContain('기한');
|
|
expect(r.covered).toContain('참석자');
|
|
});
|
|
|
|
it('coverageCheck=false 업무(일정)는 검사하지 않는다', () => {
|
|
const r = checkRequirementCoverage('내일 3시 미팅 잡아줘', '등록했습니다.');
|
|
expect(r.ran).toBe(false);
|
|
});
|
|
|
|
it('업무 유형 미감지·빈 답변이면 ran=false', () => {
|
|
expect(checkRequirementCoverage('안녕', '반가워요').ran).toBe(false);
|
|
expect(checkRequirementCoverage('회의록 정리해줘', ' ').ran).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('formatRequirementCoverageFooter', () => {
|
|
it('누락이 있으면 footer 에 업무명과 누락 요소를 표시', () => {
|
|
const footer = formatRequirementCoverageFooter({
|
|
ran: true, taskId: 'meeting-minutes', taskLabel: '회의록',
|
|
covered: ['참석자'], missing: ['담당자', '기한'],
|
|
});
|
|
expect(footer).toContain('회의록');
|
|
expect(footer).toContain('담당자, 기한');
|
|
});
|
|
|
|
it('전부 충족 또는 미실행이면 빈 문자열 (노이즈 방지)', () => {
|
|
expect(formatRequirementCoverageFooter({ ran: true, covered: ['참석자'], missing: [] })).toBe('');
|
|
expect(formatRequirementCoverageFooter({ ran: false, covered: [], missing: [] })).toBe('');
|
|
});
|
|
});
|
|
|
|
describe('DEFAULT_TASK_REQUIREMENTS 무결성', () => {
|
|
it('모든 detectKeywords / detectPatterns 가 유효한 정규식이다', () => {
|
|
for (const req of DEFAULT_TASK_REQUIREMENTS) {
|
|
expect(() => new RegExp(req.detectKeywords.join('|'), 'iu')).not.toThrow();
|
|
for (const el of req.elements) {
|
|
expect(() => new RegExp(el.detectPatterns.join('|'), 'iu')).not.toThrow();
|
|
}
|
|
}
|
|
});
|
|
|
|
it('업무 ID 와 요소 ID 가 중복되지 않는다', () => {
|
|
const taskIds = DEFAULT_TASK_REQUIREMENTS.map((r) => r.id);
|
|
expect(new Set(taskIds).size).toBe(taskIds.length);
|
|
for (const req of DEFAULT_TASK_REQUIREMENTS) {
|
|
const ids = req.elements.map((e) => e.id);
|
|
expect(new Set(ids).size).toBe(ids.length);
|
|
}
|
|
});
|
|
});
|
|
|
|
// [v2.2.312] 분석 보고 유형 — "프로젝트 분석하고 보고해줘" 실사례가 유형 미감지로
|
|
// 일반론 총평이 되던 갭을 막는다.
|
|
describe('detectTaskType — analysis-report (v2.2.312)', () => {
|
|
test('실사례 문장을 정확히 감지한다', () => {
|
|
expect(detectTaskType('E:\Wiki\connectai 프로젝트를 분석하고 어떻게 되어 있는지 보고해줘')?.id).toBe('analysis-report');
|
|
expect(detectTaskType('진행 현황 보고 부탁해')?.id).toBe('analysis-report');
|
|
expect(detectTaskType('이 코드 검토해서 보고해줘')?.id).toBe('analysis-report');
|
|
});
|
|
test('더 구체적인 유형이 우선한다 (회의록·시장조사)', () => {
|
|
expect(detectTaskType('회의록으로 정리해서 보고해줘')?.id).toBe('meeting-minutes');
|
|
expect(detectTaskType('시장조사 결과 보고해줘')?.id).toBe('market-research');
|
|
});
|
|
test('블록에 파일 근거 요소와 섹션 규칙 오버라이드가 포함된다', () => {
|
|
const block = buildRequirementGraphBlock('프로젝트 분석하고 보고해줘');
|
|
expect(block).toContain('파일 근거');
|
|
expect(block).toContain('보고 개요');
|
|
expect(block).toContain('최대 3섹션');
|
|
});
|
|
});
|