feat(desktop): built-in Han/Eng layout auto-switching, terminal/Vim support, and Unicode input

This commit is contained in:
Yun Chan 2026-10-27 10:48:07 +09:00
parent 1da04b9e46
commit a3ac44da2b
109 changed files with 8234 additions and 242 deletions

View file

@ -68,8 +68,9 @@ export function normalizeSessionPrefix(prefix: string): string {
*/
const LIST_MARKER_PATTERN = /^(?:[-*•]+[.)\]]?|\d{1,3}[.)\]])\s+/u
const WRAPPING_QUOTES_PATTERN = /^["'“”‘’`]+|["'“”‘’`]+$/gu
/** 모델이 지시문을 되풀이한 경우 (llm-prompts 회귀와 같은 부류) */
const INSTRUCTION_ECHO_PATTERN = /^(suggestion|completion|candidate|output|answer|다음 문장)\s*[::]/iu
/** 모델이 지시문·섹션 헤더를 되풀이한 경우 (llm-prompts 지시문 누출 차단) */
const INSTRUCTION_ECHO_PATTERN =
/^(?:(?:suggestion|completion|candidate|output|answer|다음 문장|입력)\s*[::]|\[(?:이어 쓰기 지시|지금 쓰는 문장|직전 문장|앞 문맥|현재 앱|글의 첫머리|글에 나온 사실)\])|(?:검색어입니다\.?|검색어 키워드 몇 개로만|짧게 이어 쓰세요|나머지 부분만 쓰세요|새 문장 하나를 쓰세요|바로 뒤부터 이어 쓰세요|겹치지 않는 다른 문장을 쓰세요)/iu
const TEMPLATE_ECHO_PATTERN = /^\{\{.*\}\}$/u
/**
@ -326,6 +327,17 @@ function firstCodePoint(text: string): string {
* - 앞 글자가 여는 괄호/따옴표·경로 기호가 아니고, 후보가 닫는 구두점으로 시작하지 않는다.
* - 이음새 양쪽 어느 쪽도 띄어 쓰지 않는 문자 체계(중·일·태 등, CJK 구두점)가 아니다.
*/
/**
* 후보를 첫 어절과 나머지로 나눈다 (단어 단위 수락). 어절 뒤 문장부호는 그 어절에 붙인다.
* 나머지가 없으면 rest 는 빈 문자열 — 호출자는 통째로 수락한다.
*/
export function splitFirstWord(candidate: string): { word: string; rest: string } {
const text = candidate.replace(/^\s+/u, '')
const match = /^\S+/u.exec(text)
if (!match) return { word: text, rest: '' }
return { word: match[0], rest: text.slice(match[0].length).replace(/^\s+/u, '') }
}
export function joinSuggestion(rawPrefix: string, candidate: string, joint: SuggestionJoint = 'separate'): string {
if (!candidate) return candidate
// 단어 중간 이어 쓰기는 공백 없이 붙인다. 원문이 이미 공백으로 끝났으면 이어 붙일 단어가 없다