feat(commands): multi-select ordered command pipeline with step reordering and single-pass composition (AI-05, AI-07)
This commit is contained in:
parent
f49acf0105
commit
10af20a0ad
157 changed files with 29455 additions and 913 deletions
|
|
@ -1,11 +1,16 @@
|
|||
import { describe, it, expect } from 'vitest'
|
||||
import {
|
||||
DEFAULT_INSTRUCTION_TARGET_LANGUAGE,
|
||||
composeInstructionPipelinePrompt,
|
||||
detectUserSlot,
|
||||
fillInstructionPlaceholders,
|
||||
findUnresolvedPlaceholders,
|
||||
moveInstructionInPipeline,
|
||||
parseActiveInstructionIds,
|
||||
renderInstruction,
|
||||
renderInstructionAsSingleMessage,
|
||||
serializeActiveInstructionIds,
|
||||
toggleInstructionInPipeline,
|
||||
} from '../src/instruction-template'
|
||||
|
||||
describe('fillInstructionPlaceholders — 치환값은 문자 그대로 들어간다', () => {
|
||||
|
|
@ -112,3 +117,36 @@ describe('renderInstructionAsSingleMessage', () => {
|
|||
expect(renderInstructionAsSingleMessage('요약: {{text}}', { text: "a $' b" })).toBe("요약: a $' b")
|
||||
})
|
||||
})
|
||||
|
||||
describe('다단계 명령 파이프라인 (parseActiveInstructionIds / toggle / move / compose)', () => {
|
||||
it('콤마 구분 문자열에서 선택 순서를 유지하고 공백·중복을 제거한다', () => {
|
||||
expect(parseActiveInstructionIds(' builtin-clean-speech , builtin-formal , builtin-clean-speech ')).toEqual([
|
||||
'builtin-clean-speech',
|
||||
'builtin-formal',
|
||||
])
|
||||
expect(serializeActiveInstructionIds(['builtin-clean-speech', 'builtin-formal'])).toBe(
|
||||
'builtin-clean-speech,builtin-formal',
|
||||
)
|
||||
})
|
||||
|
||||
it('토글 및 위·아래 순서 이동이 정확히 동작한다', () => {
|
||||
const step1 = toggleInstructionInPipeline([], 'builtin-clean-speech')
|
||||
expect(step1).toEqual(['builtin-clean-speech'])
|
||||
const step2 = toggleInstructionInPipeline(step1, 'builtin-formal')
|
||||
expect(step2).toEqual(['builtin-clean-speech', 'builtin-formal'])
|
||||
const swapped = moveInstructionInPipeline(step2, 'builtin-formal', 'up')
|
||||
expect(swapped).toEqual(['builtin-formal', 'builtin-clean-speech'])
|
||||
const removed = toggleInstructionInPipeline(swapped, 'builtin-formal')
|
||||
expect(removed).toEqual(['builtin-clean-speech'])
|
||||
})
|
||||
|
||||
it('2개 이상 명령은 단계 번호와 후행 단계 우선 규칙이 포함된 단일 파이프라인 프롬프트로 합성한다', () => {
|
||||
const composed = composeInstructionPipelinePrompt([
|
||||
{ name: '구어·추임새·중복 정리', prompt: '추임새와 중복을 제거하세요.' },
|
||||
{ name: '격식체 변환', prompt: '정중한 비즈니스 존댓말(-습니다/-합니다)로 변환하세요.' },
|
||||
])
|
||||
expect(composed).toContain('[1단계: 구어·추임새·중복 정리]')
|
||||
expect(composed).toContain('[2단계: 격식체 변환]')
|
||||
expect(composed).toContain('뒤쪽(마지막) 단계')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -398,6 +398,16 @@ describe('낱자 잡음 (2026-10-17 실측 입력)', () => {
|
|||
}
|
||||
})
|
||||
|
||||
it('커서 끝에서 다음 한글 음절을 조합하기 시작한 초성(안ㄴ·안녕ㅎ·한ㄱ·글ㅈ)은 잡음이나 오타로 보지 않는다', () => {
|
||||
for (const composing of ['안ㄴ', '안녕ㅎ', '한ㄱ', '글ㅈ', '오늘 회의 자ㄹ']) {
|
||||
expect(detectJamoNoise(composing)).toEqual([])
|
||||
expect(hasSuspiciousTypo(composing)).toBe(false)
|
||||
}
|
||||
// 반면 공백이나 문장부호로 어절이 끝났는데도 자음이 홀로 남았으면 잡음으로 지운다
|
||||
expect(fixed('안ㄴ ')).toBe('안 ')
|
||||
expect(fixed('한ㄱ ')).toBe('한 ')
|
||||
})
|
||||
|
||||
it('모델 교정이 같은 단어의 낱자 지우기보다 앞선다', () => {
|
||||
const text = '안ㄴ뇽하세여.?'
|
||||
const model = validateModelCorrections(text, [{ from: '안ㄴ뇽하세여', to: '안녕하세요' }])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue