[PR #5814] [MERGED] fix(cli): preserve Unicode and text across token windows #7078

Closed
opened 2026-11-01 21:45:13 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5814
Author: @STDquantum
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @morluto

Base: main ← Head: fix-cli-token-window-unicode-20261021


📝 Commits (3)

  • beffd77 fix(cli): preserve Unicode and text across token windows
  • 172d523 fix(cli): avoid redundant token window formatting
  • 0e4cd5a Merge remote-tracking branch 'upstream/main' into fix-cli-token-window-unicode-20261021

📊 Changes

5 files changed (+569 additions, -16 deletions)

View changed files

📝 src/cli/cliResultOutput.ts (+75 -10)
➕ src/cli/tokenWindow.ts (+81 -0)
📝 src/cli/visitRegisteredCommands.ts (+18 -6)
➕ tests/acceptance/cliTokenWindowUnicode.test.ts (+107 -0)
➕ tests/boundary/cli/cliTokenWindowOutput.test.ts (+288 -0)

📄 Description

Summary

Fixes #5530. Preserve digest characters and valid Unicode when CLI text output is split into consecutive token windows.

Problem and expected behavior

Adjacent TOON pages can repeat a digest character because tokenx rounds the end and start differently; UTF-16 boundaries can also divide an emoji. After removing pagination markers, consecutive pages should reconstruct the original text without introducing replacement characters.

Change and scope

Use one disjoint, code-point-safe boundary mapping for text token windows, including full-output failures. Preserve trailing whitespace on the final page, full-output metadata, token counting, and command/group agent-only terminal presentation. Keep typed failures visible when an output filter would remove them.

This is an ordinary output-boundary fix; a separate maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: CLI result formatting and token-window slicing.

  • Contribution scope fit and linked maintainer decision: existing CLI behavior; not applicable.

  • CLI and MCP/tool-catalog contract: TOON/Markdown text windows preserve characters; no schema or MCP changes.

  • Provider, bridge, target-format, or platform compatibility: no provider changes; verified on Windows with Node 24.18.0.

  • Evidence, artifact, provenance, or reconstruction contract: preserve caller-visible digests and text; no stored evidence changes.

  • Target selection, authority, upstream behavior, and cleanup details: no new target interaction or authority.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

  • Launch or attach to a process.

  • Inject instrumentation or run scripts/code.

  • Change process memory, registers, files, or configuration.

  • Contact network services.

  • Recover protected code or work around protections.

  • Documentation or usability only; no target interaction.

  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Boundary coverage reconstructs digest/Unicode pages and trailing whitespace, checks full-output metadata, and exercises actual Incur terminal output policies, inherited group policies, explicit formats, token counts, and filtered typed failures.

  • Public CLI acceptance pages an artifact digest and a real Unicode filename, verifies nonempty pages, and reconstructs the complete selected output.

  • Example: a 64-character digest stays 64 characters after page reconstruction; valid emoji pages introduce no U+FFFD.

  • Remaining proof gaps: the original macOS inspect-plist reproduction was not rerun; acceptance uses cross-platform inspect-artifact.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • Current head, tests/boundary/cli/cliTokenWindowOutput.test.ts: 20/20 passed; tests/acceptance/cliTokenWindowUnicode.test.ts: 1/1 passed.
  • npm run check:fast: passed after conflict resolution and again in the pre-push check.
  • Formatting and git diff --check: passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; token positions remain approximate.
  • Real Hopper/Ghidra, browser, or OS coverage: Windows only; optional providers were not needed or tested. macOS/Linux were not tested.
  • Package or release metadata impact: none; tokenx remains pinned to 1.3.0.
  • Security, privacy, process, or containment review: output formatting only; no additional authority. Formatting still materializes text before slicing. Timing, CPU, and peak memory were not measured.

Author readiness

Human owner: @STDquantum

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5814 **Author:** [@STDquantum](https://github.com/STDquantum) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix-cli-token-window-unicode-20261021` --- ### 📝 Commits (3) - [`beffd77`](https://github.com/morluto/rea/commit/beffd77cd2559e6a48e0ca23a54c86ab39e55f14) fix(cli): preserve Unicode and text across token windows - [`172d523`](https://github.com/morluto/rea/commit/172d523b1985b1d7fd8547999a097cb48eb4fb7c) fix(cli): avoid redundant token window formatting - [`0e4cd5a`](https://github.com/morluto/rea/commit/0e4cd5a8772fb29efd8baff9c81637c49c7e0603) Merge remote-tracking branch 'upstream/main' into fix-cli-token-window-unicode-20261021 ### 📊 Changes **5 files changed** (+569 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `src/cli/cliResultOutput.ts` (+75 -10) ➕ `src/cli/tokenWindow.ts` (+81 -0) 📝 `src/cli/visitRegisteredCommands.ts` (+18 -6) ➕ `tests/acceptance/cliTokenWindowUnicode.test.ts` (+107 -0) ➕ `tests/boundary/cli/cliTokenWindowOutput.test.ts` (+288 -0) </details> ### 📄 Description ## Summary Fixes #5530. Preserve digest characters and valid Unicode when CLI text output is split into consecutive token windows. ## Problem and expected behavior Adjacent TOON pages can repeat a digest character because tokenx rounds the end and start differently; UTF-16 boundaries can also divide an emoji. After removing pagination markers, consecutive pages should reconstruct the original text without introducing replacement characters. ## Change and scope Use one disjoint, code-point-safe boundary mapping for text token windows, including full-output failures. Preserve trailing whitespace on the final page, full-output metadata, token counting, and command/group agent-only terminal presentation. Keep typed failures visible when an output filter would remove them. This is an ordinary output-boundary fix; a separate maintainer scope decision is not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: CLI result formatting and token-window slicing. - Contribution scope fit and linked maintainer decision: existing CLI behavior; not applicable. - CLI and MCP/tool-catalog contract: TOON/Markdown text windows preserve characters; no schema or MCP changes. - Provider, bridge, target-format, or platform compatibility: no provider changes; verified on Windows with Node 24.18.0. - Evidence, artifact, provenance, or reconstruction contract: preserve caller-visible digests and text; no stored evidence changes. - Target selection, authority, upstream behavior, and cleanup details: no new target interaction or authority. - Generated metadata, package, or installation impact: none. - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [x] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Boundary coverage reconstructs digest/Unicode pages and trailing whitespace, checks full-output metadata, and exercises actual Incur terminal output policies, inherited group policies, explicit formats, token counts, and filtered typed failures. - Public CLI acceptance pages an artifact digest and a real Unicode filename, verifies nonempty pages, and reconstructs the complete selected output. - Example: a 64-character digest stays 64 characters after page reconstruction; valid emoji pages introduce no U+FFFD. - Remaining proof gaps: the original macOS inspect-plist reproduction was not rerun; acceptance uses cross-platform inspect-artifact. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - Current head, `tests/boundary/cli/cliTokenWindowOutput.test.ts`: 20/20 passed; `tests/acceptance/cliTokenWindowUnicode.test.ts`: 1/1 passed. - `npm run check:fast`: passed after conflict resolution and again in the pre-push check. - Formatting and `git diff --check`: passed. ## Compatibility, safety, and release - Breaking changes or migration steps: none; token positions remain approximate. - Real Hopper/Ghidra, browser, or OS coverage: Windows only; optional providers were not needed or tested. macOS/Linux were not tested. - Package or release metadata impact: none; tokenx remains pinned to 1.3.0. - Security, privacy, process, or containment review: output formatting only; no additional authority. Formatting still materializes text before slicing. Timing, CPU, and peak memory were not measured. ## Author readiness Human owner: @STDquantum - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:45:13 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7078
No description provided.