feat(text): refactored text processing with UTF-16 optimization and ANSI state bitflags

- Added `visibleWidth()` function to measure visible text width while excluding ANSI codes.
- Optimized text processing from UTF-8 to UTF-16 implementation with direct JsString handling for improved performance.
- Refactored ANSI state tracking to use bitflags-based SgrState struct instead of individual boolean fields for more efficient storage.
- Introduced ColorCode enum to represent color codes (Basic, Indexed, Rgb) for better type safety.
- Added comprehensive test coverage for UTF-16 text processing, ANSI detection, and width calculations.
- Updated napi feature from 'napi8' to 'napi10' and added unicode-segmentation dependency.
This commit is contained in:
can1357
2026-02-01 09:34:54 +01:00
parent b91ab4bad0
commit c8f106c58c
11 changed files with 982 additions and 453 deletions
+1 -1
View File
@@ -135,7 +135,7 @@ function resolveModelOverride(
): { model?: Model<Api>; thinkingLevel?: ThinkingLevel } {
if (modelPatterns.length === 0) return {};
const matchPreferences = { usageOrder: settings?.getStorage()?.getModelUsageOrder() };
const roles = settings?.serialize().modelRoles as Record<string, string> | undefined;
const roles = settings?.getGroup("modelRoles");
for (const pattern of modelPatterns) {
const normalized = pattern.trim().toLowerCase();
if (!normalized || DEFAULT_MODEL_ALIASES.has(normalized)) {