fauxnix-cli 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/executor.js CHANGED
@@ -406,11 +406,18 @@ async function runPlans(plans, session, opts, afterSegment, ensureHost) {
406
406
  break;
407
407
  }
408
408
  const encoded = wrapScript(plan.body, { mode: 'host' });
409
+ // Response budgets cap what the CALLER receives — streams redirected to
410
+ // files must never be truncated by them (Codex-review P1: `printf … > f`
411
+ // with a small stdoutLimit was writing a clipped file). The final
412
+ // clipUtf8 below still enforces the returned-data budget.
413
+ const fileRedirected = !!(red.stdoutFile || red.stderrFile);
409
414
  const inv = await ensureHost().invoke(encoded, {
410
415
  FAUXNIX_CWD: currentDir,
411
416
  FAUXNIX_PREV_EXIT: session.prevExit === null ? '' : String(session.prevExit),
412
417
  FAUXNIX_STDIN_FILE: red.stdinFile || '',
413
- }, remainingMs, opts.signal, { stdoutLimit, stderrLimit });
418
+ }, remainingMs, opts.signal, fileRedirected
419
+ ? { stdoutLimit: 0, stderrLimit: 0 }
420
+ : { stdoutLimit, stderrLimit });
414
421
  if (inv.spawnError === 'ENOENT' || inv.spawnError === 'START') {
415
422
  stderr += inv.stderr.toString('utf8') || PS_MISSING_MESSAGE;
416
423
  exitCode = 127;
@@ -1221,7 +1221,22 @@ function fx-emit-chunks($type, $id, [byte[]]$bytes, $limit, [ref]$seq) {
1221
1221
  if ($null -ne $bytes) { $n = $bytes.Length }
1222
1222
  $use = $n
1223
1223
  $trunc = $false
1224
- if ($use -gt $limit) { $use = $limit; $trunc = $true }
1224
+ # limit 0 = uncapped (file-redirected streams must never be budget-clipped)
1225
+ if ($limit -gt 0 -and $use -gt $limit) {
1226
+ $use = $limit
1227
+ $trunc = $true
1228
+ # back the cut off to a valid UTF-8 boundary — a split codepoint makes
1229
+ # Node's decoder reject the whole buffer and fall back to GBK mojibake
1230
+ $i = $use - 1
1231
+ $back = 0
1232
+ while ($back -lt 3 -and $i -ge 0 -and (($bytes[$i] -band 0xC0) -eq 0x80)) { $i = $i - 1; $back = $back + 1 }
1233
+ if ($i -ge 0) {
1234
+ $lead = $bytes[$i]
1235
+ $seqlen = 1
1236
+ if (($lead -band 0xE0) -eq 0xC0) { $seqlen = 2 } elseif (($lead -band 0xF0) -eq 0xE0) { $seqlen = 3 } elseif (($lead -band 0xF8) -eq 0xF0) { $seqlen = 4 }
1237
+ if (($i + $seqlen) -gt $use) { $use = $i }
1238
+ }
1239
+ }
1225
1240
  $off = 0
1226
1241
  while ($off -lt $use) {
1227
1242
  $len = $use - $off
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fauxnix-cli",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Fauxnix — run Linux-style commands on Windows via deterministic PowerShell translation. No VM, no WSL. MCP server + CLI for AI agents.",
5
5
  "type": "module",
6
6
  "bin": {