char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
92d1bb0c9
char/aliceai-t5-moe
1/** 2* Slash-command token detection for the chat form. Valid only at offset 0. 3*/ 4export function findCommandToken ( 5value :string 6) :{ name :string ; args :string ; end :number } | null { 7if ( ! value . startsWith ( '/' )) return null ; 8 9const rest = value . slice ( 1 ); 10const spaceIdx = rest . search ( / \s / ); 11const name = spaceIdx === - 1 ?rest :rest . slice ( 0 , spaceIdx ); 12const args = spaceIdx === - 1 ?'' :rest . slice ( spaceIdx + 1 ); 13 14return { args, end :value . length , name}; 15} 16 17/** 18* Stable signature of a slash-command token for use as a "dismissed" 19* marker: while the picker is closed and this exact token is still intact, 20* the picker does not re-open on in-token edits. 21*/ 22export interface CommandDismissSnapshot { 23name :string ; 24args :string ; 25} 26 27export function takeCommandDismissSnapshot ( value :string ) :CommandDismissSnapshot | null { 28const token = findCommandToken ( value ); 29 30if ( ! token ) return null ; 31 32return { args :token . args , name :token . name }; 33}