feat(driver): add getBuildCode() to extract current build as shareable code#150
Open
SFerenczy wants to merge 1 commit intoatty303:mainfrom
Open
feat(driver): add getBuildCode() to extract current build as shareable code#150SFerenczy wants to merge 1 commit intoatty303:mainfrom
SFerenczy wants to merge 1 commit intoatty303:mainfrom
Conversation
…e code Symmetric counterpart to loadBuildFromCode. Serializes the current build to XML via PoB's SaveDB, then deflates and base64-encodes it into the standard URL-safe build code format. Added across all layers: - boot.lua: getBuildCode() Lua function - driver.c: get_build_code() exported C function with safe string handling - worker.ts: getBuildCode() on DriverWorker with cwrap binding - driver.ts: getBuildCode(): Promise<string> public API on Driver Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Adds
getBuildCode()as the symmetric counterpart to the existingloadBuildFromCode(). Serializes the current build back to the standard PoB share-code format —base64url(zlib(xml))— so embedders can round-trip: load a code → user/agent edits → read the code back out.The shape mirrors
loadBuildFromCodeexactly; changes are threaded through all four layers:packages/driver/boot.luagetBuildCode()Lua function — callsbuild:SaveDB("code"), deflates, URL-safe base64packages/driver/src/c/driver.cget_build_code()exported C function with static buffer lifecycle matching the existings_*patternpackages/driver/src/js/worker.tsgetBuildCode()onDriverWorker+cwrapbindingpackages/driver/src/js/driver.tsgetBuildCode(): Promise<string>public API onDriverMotivation
I'm embedding pob-web in a build-analysis app where an AI agent mutates the build XML. After mutation, I need to serialize the current in-memory build back to a code to persist/share it. Today
loadBuildFromCodegets you in to pob-web; there's no symmetric way to get out. This closes that gap with a minimally-invasive addition.Design notes
common.base64andDeflatealready in PoB, same asloadBuildFromCode.error()on missingmainObject.main/ wrong mode, C-side prints tostderrand returnsNULLon pcall failure, matches the style ofload_build_from_codein the same file.s_build_codefollows the existing pattern indriver.c; freed on next call.+→-,/→_) matches whatloadBuildFromCodeaccepts, so the output is a drop-in input for the inverse call.Test plan
await driver.loadBuildFromCode(code); const out = await driver.getBuildCode();and confirm the resulting XML (after base64/inflate) equals the input XML for at least one non-trivial buildgetBuildCode()before a build is loaded — expect a rejected promise with a clear errordist/driver.wasmsize doesn't meaningfully regressHappy to adjust naming, error handling, or scope if you'd prefer a different shape.