Skip to content

perf(kaos): stream UTF-8 readLines - #966

Closed
7Sageer wants to merge 1 commit into
MoonshotAI:mainfrom
7Sageer:perf/kaos-readlines-streaming
Closed

perf(kaos): stream UTF-8 readLines#966
7Sageer wants to merge 1 commit into
MoonshotAI:mainfrom
7Sageer:perf/kaos-readlines-streaming

Conversation

@7Sageer

@7Sageer 7Sageer commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No related issue. This continues the review discussion from PR #962 and fixes the encoding regression found there.

Problem

Reading a large text file through LocalKaos.readLines loads the whole file into memory before splitting lines. PR #962 tried to stream UTF-8 reads, but it applied byte-level LF splitting to every BufferEncoding, which broke utf16le and changed behavior for lossless encodings such as hex.

What changed

LocalKaos.readLines now streams UTF-8 files in 64 KiB chunks and keeps only the current unfinished line across chunk boundaries. Non-UTF-8 encodings stay on the previous decode-then-split path so their existing behavior is preserved. Added tests for line-ending fidelity, multi-chunk files, multibyte UTF-8 across the chunk boundary, UTF-8 decode error modes, UTF-16LE splitting, and hex decoding.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c82700a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 22, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@c82700a
npx https://pkg.pr.new/@moonshot-ai/kimi-code@c82700a

commit: c82700a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant