mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-31 04:07:52 +00:00
fix(cli): keep the R4-pinned stdin branch shape in applyStdinParam (#3513)
Shard 10's R4 regression pin (test/cycle/regression-pr-wave-r1-r2-r4.test.ts, protecting PR #1325's Windows /dev/stdin → fd 0 fix) asserts three source literals in src/cli.ts: `readFileSync(0, ...)`, the `op.cliHints?.stdin` + `MAX_STDIN = 5_000_000` branch, and the `!process.stdin.isTTY` gate. The bounded-read refactor kept the first two but inverted the TTY gate into a positive early-return, dropping the pinned `!process.stdin.isTTY` spelling. Restore the original branch shape inside applyStdinParam (guard + read + cap + assign), unchanged semantics. The #1325 protection itself was never at risk: no '/dev/stdin' anywhere, readFileSync(0) remains the read for non-pipe stdin, and pipes drain through process.stdin (fd 0, cross-platform). The pin now passes unmodified. A comment marks the shape as R4-pinned so the next refactor doesn't trip it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
8621f50ba9
commit
18f6c50eb9
+12
-8
@@ -837,15 +837,19 @@ export async function applyStdinParam(
|
||||
op: Operation,
|
||||
params: Record<string, unknown>,
|
||||
): Promise<void> {
|
||||
if (!op.cliHints?.stdin || params[op.cliHints.stdin] || process.stdin.isTTY) return;
|
||||
const content = await readStdinBounded();
|
||||
if (content === null) return; // no input arrived — let the required-param check fail fast
|
||||
const MAX_STDIN = 5_000_000; // 5MB
|
||||
if (Buffer.byteLength(content, 'utf-8') > MAX_STDIN) {
|
||||
console.error(`Error: stdin content exceeds ${MAX_STDIN} bytes. Split into smaller inputs.`);
|
||||
process.exit(1);
|
||||
// Branch shape (stdin hint + missing param + `!process.stdin.isTTY` gate +
|
||||
// 5MB cap) is pinned by the R4 regression test for PR #1325's Windows fix
|
||||
// (test/cycle/regression-pr-wave-r1-r2-r4.test.ts) — keep the spelling.
|
||||
if (op.cliHints?.stdin && !params[op.cliHints.stdin] && !process.stdin.isTTY) {
|
||||
const content = await readStdinBounded();
|
||||
if (content === null) return; // no input arrived — let the required-param check fail fast
|
||||
const MAX_STDIN = 5_000_000; // 5MB
|
||||
if (Buffer.byteLength(content, 'utf-8') > MAX_STDIN) {
|
||||
console.error(`Error: stdin content exceeds ${MAX_STDIN} bytes. Split into smaller inputs.`);
|
||||
process.exit(1);
|
||||
}
|
||||
params[op.cliHints.stdin] = content;
|
||||
}
|
||||
params[op.cliHints.stdin] = content;
|
||||
}
|
||||
|
||||
/** First-byte deadline for pipe/socket stdin (#3513). Env-overridable escape hatch. */
|
||||
|
||||
Reference in New Issue
Block a user