feat(bgcode): MeatPack G-code decoder (DD-011 phase 2) (#188) - #234
Merged
Conversation
Adds the MeatPack encoding (both variants) to the .bgcode decoder: a GCode block encoded with
MeatPack now decodes end-to-end (optionally after DEFLATE) to plain G-code.
The decoder is a faithful TS port of the MIT jamesgopsill/meatpack unpacker (© 2025 James Gopsill;
derived from the published Prusa spec), attribution preserved — NO AGPL libbgcode/OctoPrint-MeatPack
code (RR-003 §8). MeatPack packs the 15 most common g-code chars into 4-bit nibbles (first char =
low nibble); nibble 0xF escapes a full literal byte; FF FF <cmd> toggles packing/no-spaces; the
stream starts disabled (FF FF FB enables it).
Validated by HAND-COMPUTED vectors (the nibble table applied by hand as an oracle independent of the
decoder's own table): packable line, left/right/double full-width escapes, the (\n,\n)→single-newline
special case, no-spaces + disable-packing commands, invalid-command rejection — plus block-level
integration through openBgcode (None + DEFLATE × MeatPack/MeatPack-comments). Output is bounded
(bomb defense). Real PrusaSlicer meatpack files = phase-4 golden-equivalence.
Also fixes a docs-build regression: bgcode.ts's `{@link ContainerError}` (an unresolvable
cross-package typedoc link that landed in dev via #233's squash) → a code span, restoring the
API-docs warning budget to 3/3.
heatshrink compression remains phase 3.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sobechestnut-dev
enabled auto-merge (squash)
July 27, 2026 20:12
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.
Phase 2 of the #188 bgcode epic (DD-011 §14). Does not close #188 — heatshrink (phase 3), container-adapter integration + golden-equivalence (phase 4), and the §7.3 review (phase 5) remain.
What
The MeatPack G-code encoding (both variants —
MeatPackandMeatPack (comments preserved)). A.bgcodeGCode block encoded with MeatPack now decodes end-to-end (optionally after DEFLATE) to plain G-code.Licensing — clean, and attributed
The decoder is a faithful TypeScript port of the MIT
jamesgopsill/meatpackunpacker (© 2025 James Gopsill), which is itself derived from the published Prusa spec — attribution preserved in the source header. No AGPLlibbgcode/OctoPrint-MeatPack code (RR-003 §8: port only from MIT/BSD/ISC with attribution).Validation — independent oracle, not just round-trip
RR-003 flagged that the MeatPack table "must be reconstructed and validated, not lifted." Rather than a self-consistent round-trip (which shares the table's blind spot), the tests use hand-computed vectors — each expected byte stream is assembled by applying the published nibble table by hand, so a wrong table/order/escape is caught:
G1 X2.5\n, left/right/double full-width escapes, the(\n,\n)→single-newline special case, the no-spaces and disable-packing commands, and invalid-command rejection;openBgcode(None + DEFLATE × MeatPack/MeatPack-comments).Output is bounded (decompression-bomb defense). Real PrusaSlicer meatpack files land in phase 4 for golden-equivalence.
Also: fixes a docs-build regression
bgcode.ts's{@link ContainerError}— an unresolvable cross-package typedoc link — landed indevwhen #233's phase-1 fix was dropped in the squash-merge, pushing the API-docs warning budget to 4 > 3. This PR downgrades it to a code span, restoring 3/3.Verification
typeCheck✓,lint✓ (0 errors),docs:build✓ (3/3), CI-liketest:packages✓ (22 bgcode tests),pack:check✓ (additivemeatpack.*snapshot).🤖 Generated with Claude Code