mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-15 03:08:56 +02:00
Trois défauts sans rapport entre eux, tous visibles à l'écran. Jauge de contexte bloquée à « 0 / N (0 %) » : le comptage exact vient de usage.prompt_tokens (include_usage), qu'un llama-server récent a cessé de renvoyer. On note désormais si l'usage est arrivé ; sinon la fin de tour publie l'estimation qui pilote déjà la compaction — approximative, mais jamais absente. Et la souscription envoie la valeur courante juste après le rattrapage : une page rechargée affichait zéro sur une discussion pourtant pleine, faute d'événement ctx_used dans la fenêtre rejouée. Espace disque : « il ne reste que 11,9 Go » sur un partage Unraid qui en a des centaines. /mnt/user est servi par shfs, un FUSE qui agrège plusieurs disques — statfs y renvoie l'espace d'un seul, et ce chiffre REFUSAIT l'installation du modèle. Les systèmes de fichiers qui approximent (FUSE, overlay, NFS, CIFS, Ceph, Gluster) sont reconnus par leur magie : leur chiffre reste affiché, précédé d'un « ~ », mais ne bloque plus rien. Panneau Fichiers : le panneau entier défilait, emportant vers le haut l'en-tête, le fil d'Ariane et le pied (occupation disque, bouton .zip) dès qu'il y avait quelques fichiers. Seule la liste défile maintenant ; le pied reste en bas et l'état vide se centre. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
233 lines
4.7 KiB
JavaScript
233 lines
4.7 KiB
JavaScript
/**
|
|
* @import {
|
|
* Construct,
|
|
* State,
|
|
* TokenizeContext,
|
|
* Tokenizer
|
|
* } from 'micromark-util-types'
|
|
*/
|
|
|
|
import { asciiAlphanumeric, asciiAlpha, asciiAtext, asciiControl } from 'micromark-util-character';
|
|
/** @type {Construct} */
|
|
export const autolink = {
|
|
name: 'autolink',
|
|
tokenize: tokenizeAutolink
|
|
};
|
|
|
|
/**
|
|
* @this {TokenizeContext}
|
|
* Context.
|
|
* @type {Tokenizer}
|
|
*/
|
|
function tokenizeAutolink(effects, ok, nok) {
|
|
let size = 0;
|
|
return start;
|
|
|
|
/**
|
|
* Start of an autolink.
|
|
*
|
|
* ```markdown
|
|
* > | a<https://example.com>b
|
|
* ^
|
|
* > | a<user@example.com>b
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function start(code) {
|
|
effects.enter("autolink");
|
|
effects.enter("autolinkMarker");
|
|
effects.consume(code);
|
|
effects.exit("autolinkMarker");
|
|
effects.enter("autolinkProtocol");
|
|
return open;
|
|
}
|
|
|
|
/**
|
|
* After `<`, at protocol or atext.
|
|
*
|
|
* ```markdown
|
|
* > | a<https://example.com>b
|
|
* ^
|
|
* > | a<user@example.com>b
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function open(code) {
|
|
if (asciiAlpha(code)) {
|
|
effects.consume(code);
|
|
return schemeOrEmailAtext;
|
|
}
|
|
if (code === 64) {
|
|
return nok(code);
|
|
}
|
|
return emailAtext(code);
|
|
}
|
|
|
|
/**
|
|
* At second byte of protocol or atext.
|
|
*
|
|
* ```markdown
|
|
* > | a<https://example.com>b
|
|
* ^
|
|
* > | a<user@example.com>b
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function schemeOrEmailAtext(code) {
|
|
// ASCII alphanumeric and `+`, `-`, and `.`.
|
|
if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) {
|
|
// Count the previous alphabetical from `open` too.
|
|
size = 1;
|
|
return schemeInsideOrEmailAtext(code);
|
|
}
|
|
return emailAtext(code);
|
|
}
|
|
|
|
/**
|
|
* In ambiguous protocol or atext.
|
|
*
|
|
* ```markdown
|
|
* > | a<https://example.com>b
|
|
* ^
|
|
* > | a<user@example.com>b
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function schemeInsideOrEmailAtext(code) {
|
|
if (code === 58) {
|
|
effects.consume(code);
|
|
size = 0;
|
|
return urlInside;
|
|
}
|
|
|
|
// ASCII alphanumeric and `+`, `-`, and `.`.
|
|
if ((code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32) {
|
|
effects.consume(code);
|
|
return schemeInsideOrEmailAtext;
|
|
}
|
|
size = 0;
|
|
return emailAtext(code);
|
|
}
|
|
|
|
/**
|
|
* After protocol, in URL.
|
|
*
|
|
* ```markdown
|
|
* > | a<https://example.com>b
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function urlInside(code) {
|
|
if (code === 62) {
|
|
effects.exit("autolinkProtocol");
|
|
effects.enter("autolinkMarker");
|
|
effects.consume(code);
|
|
effects.exit("autolinkMarker");
|
|
effects.exit("autolink");
|
|
return ok;
|
|
}
|
|
|
|
// ASCII control, space, or `<`.
|
|
if (code === null || code === 32 || code === 60 || asciiControl(code)) {
|
|
return nok(code);
|
|
}
|
|
effects.consume(code);
|
|
return urlInside;
|
|
}
|
|
|
|
/**
|
|
* In email atext.
|
|
*
|
|
* ```markdown
|
|
* > | a<user.name@example.com>b
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function emailAtext(code) {
|
|
if (code === 64) {
|
|
effects.consume(code);
|
|
return emailAtSignOrDot;
|
|
}
|
|
if (asciiAtext(code)) {
|
|
effects.consume(code);
|
|
return emailAtext;
|
|
}
|
|
return nok(code);
|
|
}
|
|
|
|
/**
|
|
* In label, after at-sign or dot.
|
|
*
|
|
* ```markdown
|
|
* > | a<user.name@example.com>b
|
|
* ^ ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function emailAtSignOrDot(code) {
|
|
return asciiAlphanumeric(code) ? emailLabel(code) : nok(code);
|
|
}
|
|
|
|
/**
|
|
* In label, where `.` and `>` are allowed.
|
|
*
|
|
* ```markdown
|
|
* > | a<user.name@example.com>b
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function emailLabel(code) {
|
|
if (code === 46) {
|
|
effects.consume(code);
|
|
size = 0;
|
|
return emailAtSignOrDot;
|
|
}
|
|
if (code === 62) {
|
|
// Exit, then change the token type.
|
|
effects.exit("autolinkProtocol").type = "autolinkEmail";
|
|
effects.enter("autolinkMarker");
|
|
effects.consume(code);
|
|
effects.exit("autolinkMarker");
|
|
effects.exit("autolink");
|
|
return ok;
|
|
}
|
|
return emailValue(code);
|
|
}
|
|
|
|
/**
|
|
* In label, where `.` and `>` are *not* allowed.
|
|
*
|
|
* Though, this is also used in `emailLabel` to parse other values.
|
|
*
|
|
* ```markdown
|
|
* > | a<user.name@ex-ample.com>b
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function emailValue(code) {
|
|
// ASCII alphanumeric or `-`.
|
|
if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {
|
|
const next = code === 45 ? emailValue : emailLabel;
|
|
effects.consume(code);
|
|
return next;
|
|
}
|
|
return nok(code);
|
|
}
|
|
} |