/** * sidebarProvider 가 chronicle 기록 / 세션 title / YAML frontmatter 등에서 공통으로 * 쓰는 작은 텍스트 변환 헬퍼. 모두 stateless. * * - slugify(value) — kebab-case slug (한/영/숫자 보존, 48자 cap) * - summarizeForTitle(value) — chat title 표시용 80자 trim * - escapeYamlString(value) — YAML double-quoted 문자열 안의 `\\` 와 `"` 이스케이프 */ export function slugify(value: string): string { const slug = value .toLowerCase() .replace(/[^a-z0-9가-힣]+/g, '-') .replace(/^-|-$/g, '') .slice(0, 48); return slug || 'conversation'; } export function summarizeForTitle(value: string): string { const normalized = value.replace(/\s+/g, ' ').trim(); if (!normalized) return 'Astra Conversation Raw Data'; return normalized.length > 80 ? `${normalized.slice(0, 80)}...` : normalized; } export function escapeYamlString(value: string): string { return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"'); } /** Wiki body snippet — 500자 trim. 비어 있으면 명시적 "Not captured." (chronicle 자동 채움 호환). */ export function summarizeTextForWiki(value: string): string { const normalized = value.replace(/\s+/g, ' ').trim(); if (!normalized) return 'Not captured.'; return normalized.length > 500 ? `${normalized.slice(0, 500)}...` : normalized; }