mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-03 07:54:40 +08:00
Node's console writes each formatted line with stream.write(line, errorHandler), so a replaced process.stdout.write sees a string and a function; a Buffer write arrives as a Buffer. The stdio write hook carried only a `wide` bit, so every intercepted chunk became a JavaScript string and console lines carried a single argument. Replace that bit with a `flags` int (SCR_STDIO_HOOK_WIDE, _CONSOLE, _BYTES) and keep the hook signature at four parameters, so the console write path and the byte paths differ only in what they pass. scr_stdio_intercept now builds a chunk instead of a string, boxes SCR_STDIO_HOOK_BYTES as a Buffer, and appends a console error handler for SCR_STDIO_HOOK_CONSOLE. Text callers of the old string entry point move to a new scr_stdio_write_text. Corpus: stdout-patch-console-arguments.js. Co-Authored-By: Claude Code <noreply@anthropic.com> Co-Authored-By: Claude 5.5 <noreply@anthropic.com>