From 67c1189bd81107f2275ea2074a3d14d1dcbada64 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 21:53:50 -0700 Subject: [PATCH] build(config): add the komorebi-config crate skeleton Add crates/komorebi-config (edition 2024, root workspace member) with the feature-gated schema module that prints a schema the way komorebic does (pretty JSON plus a newline). No type has moved yet: the crate depends on komorebi-layouts, komorebi-themes and komorebi-protocol, which every type that follows needs. Verified: native cargo test -p komorebi-config compiles (tier 1). Cargo.lock gains only the new package. Windows, KDE and macOS trees do not depend on the crate yet. --- Cargo.lock | 13 +++++++++++++ Cargo.toml | 1 + crates/komorebi-config/Cargo.toml | 29 ++++++++++++++++++++++++++++ crates/komorebi-config/src/lib.rs | 11 +++++++++++ crates/komorebi-config/src/schema.rs | 13 +++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 crates/komorebi-config/Cargo.toml create mode 100644 crates/komorebi-config/src/lib.rs create mode 100644 crates/komorebi-config/src/schema.rs diff --git a/Cargo.lock b/Cargo.lock index e11eae46..9b69ce31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3439,6 +3439,19 @@ dependencies = [ "serde_json_lenient", ] +[[package]] +name = "komorebi-config" +version = "0.1.42" +dependencies = [ + "komorebi-layouts", + "komorebi-protocol", + "komorebi-themes", + "schemars 1.2.3", + "serde", + "serde_json_lenient", + "strum", +] + [[package]] name = "komorebi-e2e-agent" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 744d315b..ac915c2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ members = [ "komorebi-client", "komorebi-gui", "crates/komorebi-collections", + "crates/komorebi-config", "komorebi-layouts", "komorebi-scrolling", "komorebic", diff --git a/crates/komorebi-config/Cargo.toml b/crates/komorebi-config/Cargo.toml new file mode 100644 index 00000000..56d6295e --- /dev/null +++ b/crates/komorebi-config/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "komorebi-config" +version = "0.1.42" +edition = "2024" +description = "The komorebi.json data types (StaticConfig and the types it is made of) and the generation of its JSON Schema" + +[dependencies] +komorebi-layouts = { path = "../../komorebi-layouts" } +komorebi-protocol = { path = "../komorebi-protocol", default-features = false } +komorebi-themes = { path = "../../komorebi-themes" } + +serde = { workspace = true } +serde_json = { workspace = true, features = ["preserve_order"] } +strum = { workspace = true } + +# Optional dependencies +schemars = { workspace = true, optional = true } + +[dev-dependencies] +schemars = { workspace = true } + +[features] +default = ["schemars"] +schemars = [ + "dep:schemars", + "komorebi-layouts/schemars", + "komorebi-protocol/schemars", + "komorebi-themes/schemars", +] diff --git a/crates/komorebi-config/src/lib.rs b/crates/komorebi-config/src/lib.rs new file mode 100644 index 00000000..9d41cbcb --- /dev/null +++ b/crates/komorebi-config/src/lib.rs @@ -0,0 +1,11 @@ +//! The `komorebi.json` data types and the generation of their JSON Schema. +//! +//! The crate holds no window manager code: it knows what a configuration file may say, not +//! how a daemon applies it. The types are moved here from the three daemons one family at a +//! time; the schema of each tree is checked in (`schema.json`, `schema.asc.json`) and +//! `tests/schemas.rs` compares what this crate generates with those files. +#![warn(clippy::all)] +#![allow(clippy::missing_errors_doc, clippy::use_self, clippy::doc_markdown)] + +#[cfg(feature = "schemars")] +pub mod schema; diff --git a/crates/komorebi-config/src/schema.rs b/crates/komorebi-config/src/schema.rs new file mode 100644 index 00000000..553e4c49 --- /dev/null +++ b/crates/komorebi-config/src/schema.rs @@ -0,0 +1,13 @@ +//! Generation of the JSON Schema files that are checked in next to the sources. + +use schemars::JsonSchema; + +/// The text `komorebic` prints for the schema of `T` (and that is checked in): pretty +/// JSON followed by a newline. +#[must_use] +pub fn pretty() -> String { + let schema = schemars::schema_for!(T); + let mut text = serde_json::to_string_pretty(&schema).expect("a schema is JSON"); + text.push('\n'); + text +}