The user asked the assistant to investigate a bug where oc-export produced a truncated JSONL file and then surfaced a misleading JSON parse error during HTML rendering. The assistant traced through the codebase, discovered the JSONL artifact was cut off at roughly 64 KB, identified that parseInputFile's JSONL fallback was producing the confusing "Expected property name or '}' in JSON at position 1 (line 1 column 2)" error, and ultimately pinpointed the truncation to spawnToFile piping the child's stdout through a Node Writable stream, which left buffered bytes unflushed when opencode export exited immediately. After the user provided a known-good manual export file for comparison, the assistant rewrote spawnToFile to write directly to an OS file descriptor and tightened parseInputFile to detect pretty-printed single JSON objects and surface the original parser error. The fix was verified locally: the full manual export renders successfully, a synthetic child that writes a large payload and exits immediately now captures the complete output, and the previously truncated file now produces a clear, accurate error pointing at the real problem.
- Confirmed the JSONL artifact was capped at 64 KB by Node's stdout pipe buffering on immediate child exit
- Rewrote
spawnToFile to stream stdout directly to a file descriptor, eliminating the truncation
- Improved
parseInputFile to detect pretty-printed single JSON documents and report the original parse error instead of the misleading JSONL fallback error
- Verified end-to-end with the manual export, a synthetic child process test, and the previously broken truncated file