397777089e
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
44 lines
2.3 KiB
JavaScript
44 lines
2.3 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { classify } from './router-classifier.mjs';
|
|
import { recommendedChainOf } from './on-plan-write.mjs';
|
|
|
|
// Цель плана, которую prefilter ложно относит к micro (подстрока 'format' в detectMicro).
|
|
const MICRO_GOAL = 'Сделай модуль format-bytes для форматирования размера';
|
|
|
|
describe('A — classify({skipPrefilter}) обходит prefilter для сверки наставника', () => {
|
|
it('skipPrefilter:true → prefilter пропущен, llmCall вызван, рекомендация из LLM', async () => {
|
|
let called = false;
|
|
const mockLlm = async () => { called = true; return { task_type: 'feature', recommended_chain: ['#19'] }; };
|
|
const r = await classify(MICRO_GOAL, null, { skipPrefilter: true, llmCall: mockLlm });
|
|
expect(called).toBe(true);
|
|
expect(r.recommended_chain).toEqual(['#19']);
|
|
});
|
|
|
|
it('умолчание (без skipPrefilter) → prefilter короткозамыкает на micro, llmCall НЕ вызван', async () => {
|
|
let called = false;
|
|
const mockLlm = async () => { called = true; return { task_type: 'feature', recommended_chain: ['#19'] }; };
|
|
const r = await classify(MICRO_GOAL, null, { llmCall: mockLlm });
|
|
expect(called).toBe(false);
|
|
expect(r.task_type).toBe('micro');
|
|
});
|
|
});
|
|
|
|
describe('B — recommendedChainOf: устойчивый маппинг рекомендации', () => {
|
|
it('recommended_chain используется как есть', () => {
|
|
expect(recommendedChainOf({ recommended_chain: ['#18', '#19'] })).toEqual(['#18', '#19']);
|
|
});
|
|
it('recommended_node → одноэлементный список', () => {
|
|
expect(recommendedChainOf({ recommended_node: '#18' })).toEqual(['#18']);
|
|
});
|
|
it('node (prefilter/regex-выход) → одноэлементный список', () => {
|
|
expect(recommendedChainOf({ node: '#18' })).toEqual(['#18']);
|
|
});
|
|
it("node:'direct' → пустой список (скил не нужен)", () => {
|
|
expect(recommendedChainOf({ node: 'direct' })).toEqual([]);
|
|
});
|
|
it('пустой/битый вход → пустой список', () => {
|
|
expect(recommendedChainOf({})).toEqual([]);
|
|
expect(recommendedChainOf(null)).toEqual([]);
|
|
});
|
|
});
|