mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-12 18:29:41 +02:00
fix(deepseek): reject the dsh footer's non-model words instead of requiring a digit
The digit rule from 21ae48a5 hid the official DeepSeek ids (`deepseek-chat`,
`deepseek-reasoner` carry no digit), so a session on the official route with
the model field on showed the logo alone (its bundle row pins a provider
alone, so the config had nothing either). It also still misread a folder name
with a digit when every field before it was off.
Now the captured field is rejected when it is what the field can be when it is
NOT the model, and read otherwise:
- capabilities.modelDetect.rejectWords (registry data, single tokens, compared
ignoring case; the schema bounds them and requires a screenLine). dsh lists
every effort id its adapters offer (pi-ai THINKING_LEVELS plus the DeepSeek
adapter's off/low/high/max) and the shipped mode ids, from dsh 0.1.1-rc.2 /
dsh-TUI 0.10.0-beta.1. A mode's drawn label (`plan mode`, `full access`,
CJK) can never be one captured field.
- In the shared screen reader, for every CLI: a field equal to the session's
own working-directory basename is the folder, never the model.
Fixtures: `deepseek-chat` and `deepseek-reasoner` with the model field on are
read; every effort id, `default`, `plan mode`, and the folder name first (with
and without a digit) are not; the live qwen footer still reads `qwen3.8-27b`.
Known gaps, all off by default, are named in stock.ts: a custom mode id drawn
raw, a git branch or a one-word session title first, and the non-compact
footer layout (nothing read there; the route config applies).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -66,6 +66,14 @@ export function sanitizeModelName(raw: unknown): string | undefined {
|
||||
return clean.slice(0, MAX_DISPLAY_MODEL_CHARS).trimEnd();
|
||||
}
|
||||
|
||||
/** What a footer field can show that is never the model. */
|
||||
export interface ScreenModelRejects {
|
||||
/** The CLI's declared non-model words (`capabilities.modelDetect.rejectWords`), lower-cased compare. */
|
||||
rejectWords?: readonly string[];
|
||||
/** The session's working-directory basename: a footer field equal to it is the folder, exact compare. */
|
||||
cwdBasename?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The model a pane's own chrome shows, read with the CLI's `modelDetect` pattern.
|
||||
*
|
||||
@@ -73,15 +81,23 @@ export function sanitizeModelName(raw: unknown): string | undefined {
|
||||
* can anchor on the row above), which keeps the search below the transcript: the
|
||||
* pattern itself must still anchor on chrome only that CLI draws.
|
||||
*
|
||||
* A footer whose model field is switched off shows its NEXT field where the model
|
||||
* was, so the captured field is not taken when it is one of the CLI's declared
|
||||
* non-model words (an effort level, a mode) or the session's own folder name, which a
|
||||
* footer field equal to is the folder, never the model, whatever the CLI. Anything
|
||||
* else the pattern captures is read as the model.
|
||||
*
|
||||
* @param paneText a plain `capture-pane -p` frame, or null when it could not be read
|
||||
* @param pattern compiled through `compileVersionRegex()`, capture group 1 = the model
|
||||
* @param tailRows how many non-blank rows from the bottom the pattern sees
|
||||
* @param rejects fields that are never the model (see {@link ScreenModelRejects})
|
||||
* @returns the model, or undefined when the frame shows none
|
||||
*/
|
||||
export function readScreenModel(
|
||||
paneText: string | null | undefined,
|
||||
pattern: RegExp,
|
||||
tailRows: number = 1
|
||||
tailRows: number = 1,
|
||||
rejects: ScreenModelRejects = {}
|
||||
): string | undefined {
|
||||
if (!paneText) return undefined;
|
||||
const rows = stripAnsi(paneText)
|
||||
@@ -93,7 +109,11 @@ export function readScreenModel(
|
||||
// stale lastIndex would make the same frame match every other call.
|
||||
pattern.lastIndex = 0;
|
||||
const match = pattern.exec(window);
|
||||
return match ? sanitizeModelName(match[1]) : undefined;
|
||||
if (!match) return undefined;
|
||||
const field = match[1] ?? '';
|
||||
if (rejects.cwdBasename && field === rejects.cwdBasename) return undefined;
|
||||
if (rejects.rejectWords?.some((word) => word.toLowerCase() === field.toLowerCase())) return undefined;
|
||||
return sanitizeModelName(field);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user