Something went wrong. Try again.
A monorepo for writing specs and other serious text on the AT Protocol.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829// Small text helpers shared by the schema, the ops and the assistant.
/** A stable, URL-safe slug; `fallback` when nothing survives. */export function slugify(text: string, fallback = 'empty'): string { const s = text .normalize('NFKD') .replace(/[̀-ͯ]/g, '') .toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/^-+|-+$/g, ''); return s || fallback;}
/** Split prose into sentences (good enough for suggestions, not for linguistics). */export function sentences(text: string): string[] { const out: string[] = []; const re = /[^.!?]+(?:[.!?]+["')\]]*|$)/g; let m: RegExpExecArray | null; while ((m = re.exec(text))) { const s = m[0]; if (s.trim()) out.push(s); } return out;}
export function words(text: string): string[] { return text.split(/\s+/).filter(Boolean);}