9ac6d96dee
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
29 lines
1.4 KiB
JavaScript
29 lines
1.4 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* enforce-verdict-surface — UserPromptSubmit-хук (Фикс 1): показывает контроллеру непоказанные
|
|
* строки исхода судьи/наставника через additionalContext (проверенный канал, как ruflo-recall).
|
|
* fail-open: любая ошибка → пустой вывод, exit 0. Регистрация в settings.json — шаг владельца.
|
|
*/
|
|
import { readStdin, parseEventJson } from './enforce-hook-helpers.mjs';
|
|
import { readUnsurfaced, markAllSurfaced } from './verdict-surface-store.mjs';
|
|
|
|
export function buildVerdictSurfaceOutput(lines) {
|
|
if (!Array.isArray(lines) || lines.length === 0) return null;
|
|
const additionalContext = ['Вердикты наставника/судьи (с прошлых записей):', ...lines].join('\n');
|
|
return { hookSpecificOutput: { hookEventName: 'UserPromptSubmit', additionalContext } };
|
|
}
|
|
|
|
async function main() {
|
|
try {
|
|
const event = parseEventJson(await readStdin());
|
|
const sessionId = (event && event.session_id) || 'unknown';
|
|
const out = buildVerdictSurfaceOutput(readUnsurfaced({ sessionId }));
|
|
if (out) { process.stdout.write(JSON.stringify(out)); markAllSurfaced({ sessionId }); }
|
|
} catch { /* fail-open */ }
|
|
process.exit(0);
|
|
}
|
|
|
|
import { fileURLToPath } from 'node:url';
|
|
const isCli = process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1];
|
|
if (isCli) main();
|