docs(byte-codec): CommandResponse.output byte-faithful contract — (xxj.4)#65
Merged
Conversation
…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.
There was a problem hiding this comment.
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.outputexplaining the latin1-container (byte-preserving) behavior and showing an explicit decode pattern. - Exported
latin1ToBytesfrom 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.
…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.
… 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
…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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CommandResponse.outputdocumenting that each string is a latin1-container (one code unit per transport byte), not decoded Unicode — with an explicit decode example consumers can copylatin1ToBytesfrom the public package API so consumers have the primitive they need without reimplementing the conversionoutputfield description to matchWhy
The byte-faithful codec (xxj.1/xxj.2) made the transport layer correct, but left
CommandResponse.outputsilently 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— cleanpnpm run test:all— 573 tests passlatin1ToBytesappears indist/index.d.tsanddist/index.js