Skip to content

docs(byte-codec): CommandResponse.output byte-faithful contract — (xxj.4)#65

Merged
brandon-fryslie merged 4 commits into
masterfrom
tmux-byte-codec-xxj.4
May 27, 2026
Merged

docs(byte-codec): CommandResponse.output byte-faithful contract — (xxj.4)#65
brandon-fryslie merged 4 commits into
masterfrom
tmux-byte-codec-xxj.4

Conversation

@brandon-fryslie

Copy link
Copy Markdown
Contributor

Summary

  • Adds JSDoc to CommandResponse.output documenting that each string is a latin1-container (one code unit per transport byte), not decoded Unicode — with an explicit decode example consumers can copy
  • Exports latin1ToBytes from the public package API so consumers have the primitive they need without reimplementing the conversion
  • Updates SPEC.md §26.3 output field description to match

Why

The byte-faithful codec (xxj.1/xxj.2) made the transport layer correct, but left CommandResponse.output silently carrying a non-obvious encoding contract. Non-ASCII command output (window names, session names) would silently produce garbled text without this documentation.

Test plan

  • pnpm run build — clean
  • pnpm run test:all — 573 tests pass
  • latin1ToBytes appears in dist/index.d.ts and dist/index.js

…ntract — (xxj.4)

CommandResponse.output strings are byte-faithful latin1 containers, not
decoded Unicode. Add JSDoc with an explicit decode example, export
latin1ToBytes from the public API so consumers have the primitive they
need, and update SPEC.md §26.3 to match.
Copilot AI review requested due to automatic review settings May 27, 2026 20:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR documents the byte-faithful encoding contract for CommandResponse.output (latin1-container strings carrying raw transport bytes), and makes the latin1ToBytes helper available from the package root so consumers can decode output correctly.

Changes:

  • Added JSDoc to CommandResponse.output explaining the latin1-container (byte-preserving) behavior and showing an explicit decode pattern.
  • Exported latin1ToBytes from the public package root entrypoint.
  • Updated SPEC.md (§26.3 CommandResponse.output) to match the documented encoding contract.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/protocol/types.ts Adds JSDoc describing CommandResponse.output as a latin1-container and provides a decode example.
src/index.ts Exposes latin1ToBytes from the package root public API.
SPEC.md Updates the spec’s CommandResponse.output field description to describe the byte-faithful contract and decoding.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/protocol/types.ts Outdated
Comment thread src/protocol/types.ts Outdated
…ec rather than restate bijection

Two suppressed Copilot findings:
- Wrong package name "tmux-control-mode" → "@promptctl/tmux-control-mode-js"
- JSDoc restated the byte↔code-unit mapping that byte-codec.ts owns under
  [LAW:one-source-of-truth]. Changed to reference bytesToLatin1 by name
  (a pointer, not a copy) so the contract has exactly one authoritative home.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/protocol/types.ts Outdated
Comment thread src/protocol/types.ts Outdated
… variable in snippet

- Removed reference to non-exported `bytesToLatin1` from the consumer-facing
  JSDoc description — internal symbols have no place in shipped .d.ts prose
- Changed `line` to `response.output[0]` so the decode snippet is self-contained
  and copy-pasteable without a NameError

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/protocol/types.ts
Comment thread SPEC.md Outdated
…iable

- [LAW:one-source-of-truth] comment in byte-codec.ts overstated its reach.
  Updated from "stated here and nowhere else" to "definition lives here;
  types may declare they use this encoding". Declaring usage ≠ duplicating
  the definition.
- SPEC.md §26.3 decode example: `line` → `response.output[0]` to match
  the JSDoc and be copy-pasteable.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@brandon-fryslie brandon-fryslie merged commit 1b21356 into master May 27, 2026
2 checks passed
@brandon-fryslie brandon-fryslie deleted the tmux-byte-codec-xxj.4 branch May 27, 2026 20:56
brandon-fryslie added a commit that referenced this pull request May 27, 2026
…j.4) (#65)

* docs(byte-codec): document CommandResponse.output latin1-container contract — (xxj.4)

CommandResponse.output strings are byte-faithful latin1 containers, not
decoded Unicode. Add JSDoc with an explicit decode example, export
latin1ToBytes from the public API so consumers have the primitive they
need, and update SPEC.md §26.3 to match.

* fix(byte-codec): correct package name in JSDoc example; reference codec rather than restate bijection

Two suppressed Copilot findings:
- Wrong package name "tmux-control-mode" → "@promptctl/tmux-control-mode-js"
- JSDoc restated the byte↔code-unit mapping that byte-codec.ts owns under
  [LAW:one-source-of-truth]. Changed to reference bytesToLatin1 by name
  (a pointer, not a copy) so the contract has exactly one authoritative home.

* fix(byte-codec): remove internal symbol ref from JSDoc; fix undefined variable in snippet

- Removed reference to non-exported `bytesToLatin1` from the consumer-facing
  JSDoc description — internal symbols have no place in shipped .d.ts prose
- Changed `line` to `response.output[0]` so the decode snippet is self-contained
  and copy-pasteable without a NameError

* fix(byte-codec): tighten LAW comment wording; fix SPEC.md snippet variable

- [LAW:one-source-of-truth] comment in byte-codec.ts overstated its reach.
  Updated from "stated here and nowhere else" to "definition lives here;
  types may declare they use this encoding". Declaring usage ≠ duplicating
  the definition.
- SPEC.md §26.3 decode example: `line` → `response.output[0]` to match
  the JSDoc and be copy-pasteable.
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.

2 participants