Imported from virtualritz/monster-step-viewer (
AGENTS.md). Install upstream withnpx skills add virtualritz/monster-step-viewer. Copyright stays with the author.
Repository Guidelines
Project Structure & Module Organization
src/main.rsboots the Bevy app, passing optional STEP paths from CLI.src/lib.rsre-exports the public API fromstep_loader.src/step_loader.rsowns STEP parsing, tessellation, transforms, colors, and streaming loader.assets/contains icons, manifest, andsw.jsfor the web build; keep cache names in sync when renaming the crate.index.htmlandTrunk.tomlconfigure the WASM build;examples/parse_test.rsis a CLI parser smoke test.check.shruns the full CI-like suite locally. Avoid editingtarget/or other generated outputs.
Build, Test, and Development Commands
cargo run --release [<path/to/file.step>]— launch the native viewer (you can pass a STEP path).cargo run --example parse_test— parse the sample STEP file without the GUI../check.sh— fmt, clippy (warnings-as-errors), tests, wasm check, and a Trunk build; fastest way to match CI.- Web:
rustup target add wasm32-unknown-unknown && cargo install --locked trunkonce, thentrunk servefor live reload athttp://127.0.0.1:8080/index.html#dev;trunk build --releasefor deployabledist/.
Coding Style & Naming Conventions
- Rust 2024 edition; prefer idiomatic snake_case for files/modules and UpperCamelCase for types (e.g.,
StepViewerApp,StepRenderer). - Run
cargo fmtbefore committing;cargo clippy --all-targets --all-features -- -D warningsshould stay clean. - RFC 430 casing. Use
as_/to_/into_conversion conventions. - No
get_prefix on getters: usewidth()notget_width().
Functional Style
- Prefer
collect()/iterator pipelines overVec::new()+ for + push. - Use
map,filter,for_each. - Direct init with
vec![],BTreeMap::from([..])where possible.
Import Rules
- Always import types at file top with
use. Never usestd::path::PathBufor other qualified paths inline in function bodies.
Expression Style
- Avoid explicit
returnstatements. Structure with if/else expression blocks instead.
Comment Rules
- All
//and///comments must end with a period. - Comments go on their own line. Never put comments at end of a line of code.
Testing
- Add unit tests near the code they cover or in
tests/for integration; include doc tests for examples. - Run
cargo test --all-targets --all-featuresandcargo test --doc(already incheck.sh). - For parser changes, update or extend
examples/parse_test.rs; keep sample STEP fixtures small and committed. - No
test_prefix on test functions.
Performance
- Use rayon for parallel processing of larger data.
- Use SmallVec for small fixed-size collections in hot paths.
- Avoid unnecessary allocations and clones.
Type Design
- C-COMMON-TRAITS: Derive
Debug,Clone,Hash,PartialEq,Eq,Copywhere possible on public types. - C-STRUCT-PRIVATE: Prefer private fields with accessors.
- No unsafe unless absolutely necessary.
Documentation
- Comments end with a period.
- First reference to external types linked with backtick brackets.
Module Size
- Target ~300-500 lines per file. Split larger files into submodules.
Commit & Pull Request Guidelines
- Prefer concise, imperative commits (
Add STEP entity legend,Fix trunk build warnings); keep scope tight. - In PRs, describe the user-visible change, how it was tested (commands), and attach screenshots/GIFs for UI updates.
- Link related issues when available; note any platform-specific considerations (native vs. wasm) and asset changes that affect caching.