Repository navigation
fix(cli,core): npm --scene/--view parity, GLB sRGB->linear, clamp warnings, and strict exit code 3 (Fixes #58, #82, #83, #84) - #101
Merged
wrong-nebula merged 2 commits intoDec 4, 2026
Conversation
…nings, and strict exit code 3
# Conflicts: # crates/forma-cli/src/main.rs # crates/forma-core/src/scene.rs # crates/forma-core/tests/kernel_tests.rs # crates/forma-lang/tests/audit_regressions.rs # lib/index.d.ts # tests/npm_smoke.mjs
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
Resolves four focused CLI, export, and diagnostic issues with regression tests, zero external dependencies, and 0 extra
forma-mcpschema tokens:1. npm/WASM CLI
--scenerendering &--viewparity (Fixes #58)bin/forma.mjsso--sceneroutes--renderthroughsession.exportScenePngBytes(renderSize, renderView)and--drawthroughsession.exportSceneSvg(), bringing the npm CLI in line with the native Rust CLI (crates/forma-cli/src/main.rs).--view <quad|front|back|right|left|top|iso>support toforma-wasm(forma_session_export_png_view,forma_session_export_scene_png_view),lib/edge.mjs,lib/index.d.ts,bin/forma.mjs, anddocs/reference/cli.md(plusScene::render_preview_scene_view_bytes).2. Consistent sRGB color space between PNG preview and glTF 2.0
baseColorFactor(Fixes #82)srgb_to_linear/linear_to_srgbhelpers incrates/forma-core/src/export.rs.Material::colorRGB channels from sRGB to linear when writingbaseColorFactorin both single-part (write_glb_bytes_with_unit) and multi-part scene (write_scene_glb_bytes_with_unit) GLB exporters (alpha stays linear per glTF 2.0 spec).baseColorFactorRGB channels from linear back to sRGB incrates/forma-core/src/import.rsso GLB export → import round-trips losslessly and imported models preview accurately.3. Emit clamp warnings for out-of-range
subsurf(levels)andbevel(w, segs)(Fixes #83)subsurf(levels > 4)now emitssubsurf: levels=<N> clamped to 4 (supported range 0..=4)in bothForma-Pipe(pipeline.rs) and Compact DSL (Scene::subsurf).bevel_edges_with_warning(crates/forma-core/src/ops.rs) now reports warnings whensegsis clamped outside1..=8or whenwidthis clamped to fit edge geometry across all three bevel paths (try_bevel_vertical_prism,try_bevel_z_rims,bevel_general_polyhedron), andScene::bevelpropagates them toeval_warnings.4. Return documented exit code
3on--strictinvariant failures (Fixes #84)forma_lang::is_invariant_violation_errand updated both nativecrates/forma-cli/src/main.rsand WASMbin/forma.mjsso strict invariant rollbacks (SceneError::InvariantViolation) exit with code3while script/syntax/I/O errors keep exiting with code1and invalid CLI usage exits2.docs/reference/cli.mdexit code table for consistency.(Note:
wasm/forma.wasmis intentionally left unmodified in git so CI rebuilds andwasm-opt -Ozoptimizes it cleanly, matching recent PRs; also made theSKILL.mdfence regex intests/npm_smoke.mjshandle CRLF checkouts on Windows.)Verification
test_issue_82_glb_base_color_srgb_to_linear_roundtripincrates/forma-core/tests/kernel_tests.rs.issue_83_subsurf_levels_and_bevel_width_emit_clamp_warningsincrates/forma-lang/tests/audit_regressions.rs.crates/forma-cli/tests/cli_exit_codes.rscovering exit codes0,1,2, and3(text and--json).tests/npm_smoke.mjsto test--scenemulti-part PNG/SVG,--view, and exit codes1/2/3onbin/forma.mjs.cargo test --locked --release -p forma-core -p forma-lang -p forma-cli -p forma-mcp -p forma-server -- --skip test_10000_fuzzed_modeling_operations_zero_crashes_zero_nansforma-wasm(--profile wasm-release --target wasm32-unknown-unknown) and rannode tests/npm_smoke.mjs:→
5/5passed (then revertedwasm/forma.wasmbefore committing).