# OpenVCS Core (`openvcs-core`)
[](https://github.com/Open-VCS/OpenVCS-Core/actions/workflows/ci.yml)
Shared Rust crate for:
- OpenVCS plugins (JSON-RPC over stdio)
- The OpenVCS client/host (shared models + backend trait surface)
## Cargo features
- `plugin-protocol` (default): JSON-RPC wire types + plugin helper modules:
- `openvcs_core::plugin_protocol` (`PluginMessage`, `RpcRequest`, `RpcResponse`)
- `openvcs_core::plugin_stdio` (read/write helpers, `respond_shared`, host calls)
- `openvcs_core::plugin_runtime` (simple request dispatch loop + handler registry)
- `openvcs_core::events` (host event subscribe/emit helpers)
- `openvcs_core::host` (bridge for calling the host over stdio)
- `vcs`: the backend trait surface:
- `openvcs_core::Vcs`, `openvcs_core::VcsError`, `openvcs_core::Result`
- `openvcs_core::models` (shared request/response/event types)
- enables `backend-registry`
- `backend-registry`: link-time backend discovery via `openvcs_core::backend_descriptor::BACKENDS`
- intended to be enabled together with `vcs`
- on `wasm32`, the registry is always empty (no `linkme` support)
## Plugin quickstart (stdio JSON-RPC)
Register one or more RPC handlers and run the dispatch loop:
```rust
use openvcs_core::plugin_runtime::{register_delegate, run_registered};
use openvcs_core::plugin_stdio::ok;
fn main() -> std::io::Result<()> {
register_delegate("ping", |_ctx, _req| ok(serde_json::json!({ "pong": true })));
run_registered()
}
```
Notes:
- `openvcs_core::{trace, debug, info, warn, error}` forward logs to the OpenVCS host when available (and also emit normal `log` records).
- Host calls from plugins go through `openvcs_core::host::call(...)` (the runtime initializes the host bridge for stdio).
- `OPENVCS_PLUGIN_HOST_TIMEOUT_MS` controls host call timeouts (default: 60000ms).
## Development
Common checks (matches CI):
- `just fix` (runs rustfmt + clippy)
- `cargo fmt --all -- --check`
- `cargo clippy --all-targets --all-features -- -D warnings`
- `cargo check --all-targets --all-features`
- `cargo test`
- `cargo test --no-default-features --features plugin-protocol,vcs,backend-registry`
- `cargo package`
## License
GPL-3.0-or-later (see `LICENSE`).