mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 18:31:52 +00:00
2.2 KiB
2.2 KiB
Contributing to Core
For general environment setup, cloning, and build system, see the root CONTRIBUTING.md.
Prerequisites
- Rust (nightly for formatting)
- rust-analyzer recommended
- Docker (for cross-compilation via
rust-zig-buildercontainer)
Common Commands
cargo check -p start-os # Type check
cargo test --features=test # Run tests (or: make test-core)
make format # Format with nightly rustfmt
cd core && cargo test <test_name> --features=test # Run a specific test
Adding a New RPC Endpoint
- Define a params struct with
#[derive(Deserialize, Serialize)] - Choose a handler type (
from_fn_asyncfor most cases) - Write the handler function:
async fn my_handler(ctx: RpcContext, params: MyParams) -> Result<MyResponse, Error> - Register it in the appropriate
ParentHandlertree - If params/response should be available in TypeScript, add
#[derive(TS)]and#[ts(export)]
See rpc-toolkit.md for full handler patterns and all four handler types.
Adding TS-Exported Types
When a Rust type needs to be available in TypeScript (for the web frontend or SDK):
- Add
ts_rs::TSto the derive list and#[ts(export)]to the struct/enum - Use
#[serde(rename_all = "camelCase")]for JS-friendly field names - For types that don't implement TS (like
DateTime<Utc>,exver::Version), use#[ts(type = "string")]overrides - For
u64fields that should be JSnumber(notbigint), use#[ts(type = "number")] - Run
make ts-bindingsto regenerate — files appear incore/bindings/then sync tosdk/base/lib/osBindings/ - Rebuild the SDK:
cd sdk && make baseDist dist
Adding i18n Keys
- Add the key to
core/locales/i18n.yamlwith all 5 language translations - Use the
t!("your.key.name")macro in Rust code - Follow existing namespace conventions — match the module path where the key is used
- Use kebab-case for multi-word segments
- Translations are validated at compile time
See i18n-patterns.md for full conventions.