char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Linting & Formatting scripts (#26819)92d1bb0c9

char/aliceai-t5-moe
961 B33 linesraw
1/**
2 * Slash-command token detection for the chat form. Valid only at offset 0.
3 */
4export function findCommandToken(
5	value: string
6): { name: string; args: string; end: number } | null {
7	if (!value.startsWith('/')) return null;
8
9	const rest = value.slice(1);
10	const spaceIdx = rest.search(/\s/);
11	const name = spaceIdx === -1 ? rest : rest.slice(0, spaceIdx);
12	const args = spaceIdx === -1 ? '' : rest.slice(spaceIdx + 1);
13
14	return { 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 {
23	name: string;
24	args: string;
25}
26
27export function takeCommandDismissSnapshot(value: string): CommandDismissSnapshot | null {
28	const token = findCommandToken(value);
29
30	if (!token) return null;
31
32	return { args: token.args, name: token.name };
33}