Allow /debug ask and /why to call the LLM for a short explanation.

Client dump stays the source of truth; the model only narrates Exact vs session vs live without applying a patch.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-21 23:36:29 +03:00
co-authored by Cursor
parent 6d487726ef
commit 25c98b2d1d
3 changed files with 37 additions and 9 deletions
+32 -6
View File
@@ -66,7 +66,9 @@
let HELP_TEXT = `Slash-команды (без LLM):
/help — этот список
/debug — сводка: промпт, params, Exact/session, почему так
/debug — сводка UI/Exact (без LLM)
/debug ask — то же + короткий ответ модели
/why — сразу /debug ask
/gen — Generate сейчас
/look generate|refN — прикрепить окно к vision
/init /mask /clear — Init / Mask / Clear Init
@@ -82,7 +84,8 @@
let SLASH_COMMANDS = [
{ cmd: '/help', hint: 'список команд' },
{ cmd: '/debug', hint: 'сводка настроек' },
{ cmd: '/debug', hint: 'сводка · ask = с LLM' },
{ cmd: '/why', hint: 'debug + пояснение LLM' },
{ cmd: '/gen', hint: 'Generate сейчас' },
{ cmd: '/look ', hint: 'generate|refN' },
{ cmd: '/init', hint: 'как Init' },
@@ -4234,7 +4237,7 @@
}
async function handleReplySideEffects(reply, civitaiResults, opts = {}) {
const { fromAutoCritique, fromVisionHop, fromCards } = opts;
const { fromAutoCritique, fromVisionHop, fromCards, fromDebug } = opts;
if (fromCards) {
const card = extractCardJson(reply);
if (card) {
@@ -4286,6 +4289,11 @@
return;
}
}
if (fromDebug) {
// Q&A only — never apply patches / generate from a debug explanation turn.
state.pendingSilentGen = false;
return;
}
const wantsGen = !!(opts.userWantsGenerate || state.pendingSilentGen
|| (Array.isArray(patch?.actions) && patch.actions.map(String).includes('generate')));
const doApply = !!(patch && (wantsGen || $('sa_auto_apply')?.checked));
@@ -4456,8 +4464,26 @@
return true;
}
if (cmd === 'debug' || cmd === 'dbg' || cmd === 'why') {
appendSystemNote(buildDebugSummary());
setStatus('/debug');
const dump = buildDebugSummary();
appendSystemNote(dump);
const argL = String(arg || '').toLowerCase().trim();
const wantLlm = cmd === 'why'
|| /^(ask|llm|explain|поясни|почему|модель)(\s|$)/i.test(argL);
if (wantLlm) {
setStatus('/debug ask…');
await sendChat({
forcedUserText:
'Отладка Assistent. Ниже факты UI (уже собраны клиентом). ' +
'Кратко своими словами (5–10 строк, язык пользователя): какие промпт/params сейчас, ' +
'что из Exact vs session_exact vs live, что сделал последний патч и почему так логично. ' +
'Без JSON patch, без generate, без look_at.\n\n' + dump,
skipSlash: true,
skipAutoPack: true,
fromDebug: true,
});
} else {
setStatus('/debug');
}
return true;
}
if (cmd === 'gen' || cmd === 'generate') {
@@ -4660,7 +4686,7 @@
if (!text) {
return;
}
if (!opts.fromAutoCritique && !opts.fromDownload && !opts.fromVisionHop) {
if (!opts.fromAutoCritique && !opts.fromDownload && !opts.fromVisionHop && !opts.fromDebug) {
state.lastUserParamIntent = userTextMentionsParams(text);
state.pendingSilentGen = userAsksGenerate(text);
}