diff --git a/.env.example b/.env.example index f9ec6f8..cb606ef 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,5 @@ -# No environment variables are read yet. Add names only (never values) as they appear. +# grove reads no .env file. Provider tokens normally live in the system keyring (`grove login`). +# Headless override (CI, servers without a Secret Service): GROVE_TOKEN_, where is the provider +# id upper-cased with non-alphanumerics replaced by `_`. Example for a provider called "home": +# GROVE_TOKEN_HOME= +# GROVE_BIN= # GUI shell only: path of the grove CLI (default: `grove` from PATH) diff --git a/CLAUDE.md b/CLAUDE.md index 284ca5c..f2545f0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -3,23 +3,27 @@ ## Overview Linux tool that keeps chosen git repos continuously in sync across machines, including uncommitted work, via snapshot refs (`refs/sync//`) on a primary remote. -Planned as a Rust workspace (core, providers, daemon, CLI, Tauri GUI). Currently in -**Phase 0 done, Phase 1 implemented and validated against the real Gitea with two simulated machines (real two-PC run still pending)**: `grove-core` + `grove` CLI (`status`, `snapshot`, `add`, `sync`, `doctor`); daemon (`groved`, Phase 2) implemented (not yet run on the real two PCs); GUI and providers do not exist yet. Do not start a -new phase before its predecessor's results are written to `docs/`. +Rust workspace: `grove-core`, `grove` (CLI), `grove-daemon` (`groved`), `grove-providers` (Gitea/Forgejo/GitHub), +`grove-bridge` (localhost HTTP bridge for the GUI), plus `gui/ui` (plain HTML/JS) and `gui/src-tauri` (Tauri shell, +outside the workspace, never compiled yet). Phases 0-5 are implemented; the real two-PC run is still pending. +Do not start new work before the previous results are written to `docs/`. ## Commands - Check shell scripts: `for f in spikes/*.sh; do bash -n "$f"; done` - Throwaway Forgejo (dev only, Podman): `spikes/forgejo-up.sh`, then `spikes/phase0.sh` - Rust: `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, `cargo test` - Daemon: `cargo run -p grove-daemon --bin groved -- --config PATH`; client `grove daemon status` +- GUI in a browser: `cargo run -p grove-bridge -- --ui gui/ui`; Tauri shell: see `docs/phase3.md` +- Package: `cargo build --release --workspace && cargo deb -p grove --no-build` +- Throwaway e2e on a local Forgejo: `spikes/phase4-e2e.sh` ## Architecture -See `docs/` (`phase0-spike.md`, `phase1.md`, `phase2.md`, `DECISIONS.md`). Git is the storage layer; shell out to +See `docs/` (`phase0-spike.md` ... `phase5.md`, `DECISIONS.md`). Git is the storage layer; shell out to system `git`; snapshots use a temp `GIT_INDEX_FILE` + `commit-tree`, never touching the user's branch or index. ## Conventions -- Dependencies: serde+toml (config), clap+anyhow (CLI), notify+serde_json (daemon), approved. Ask before adding more. +- Dependencies: serde+toml, clap+anyhow, notify+serde_json, ureq, keyring, age, tauri v2 (GUI shell), approved. Ask before adding more. - Everything in the repo is English. Open questions go to `docs/DECISIONS.md`. - Never destroy local work; divergence is surfaced, never auto-merged. diff --git a/Cargo.lock b/Cargo.lock index d1374b7..fcf4733 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,118 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common 0.1.7", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures 0.2.17", +] + +[[package]] +name = "aes" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fc36d7440d015b45468ba08a21e80e056ebbd014c611c6298bb7503e04bd1" +dependencies = [ + "cipher 0.5.2", + "cpubits", + "cpufeatures 0.3.1", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead", + "aes 0.8.4", + "cipher 0.4.4", + "ctr", + "ghash", + "subtle", +] + +[[package]] +name = "age" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd290633c2482479f70f6d1d96ae0e9f52c6a26cd5859edd47ee1fe33fc89f26" +dependencies = [ + "age-core", + "base64 0.22.1", + "bech32", + "chacha20poly1305", + "cipher 0.4.4", + "cookie-factory", + "hkdf 0.12.4", + "hmac 0.12.1", + "hpke", + "i18n-embed", + "i18n-embed-fl", + "lazy_static", + "ml-kem", + "nom", + "p256", + "pin-project", + "rand", + "rust-embed", + "scrypt", + "sha2 0.10.9", + "sha3", + "subtle", + "x25519-dalek", + "zeroize", +] + +[[package]] +name = "age-core" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d4375964d1501e5f1b32aef2ead573913893ff238448d4e9fdf1522d828656" +dependencies = [ + "base64 0.22.1", + "bech32", + "chacha20poly1305", + "cookie-factory", + "hkdf 0.12.4", + "hpke", + "io_tee", + "nom", + "rand", + "secrecy", + "sha2 0.10.9", +] + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + [[package]] name = "anstream" version = "1.0.0" @@ -38,7 +150,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -49,7 +161,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -58,12 +170,336 @@ version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" +[[package]] +name = "apple-native-keyring-store" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b350bfd03649e07aa05c0a81b3e15934374e585c98204a57e20b9d49f49bb9a" +dependencies = [ + "keyring-core", + "log", + "security-framework", +] + +[[package]] +name = "arc-swap" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b5d51209f6de83d37a0b33d320acb8da88823e42a94c075140708f032a5" +dependencies = [ + "rustversion", +] + +[[package]] +name = "async-broadcast" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-channel" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f426a31126c735126297bc5ea7a521263c9faff4f63ca415267ee625651c4f37" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" +dependencies = [ + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-lock" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0876700b0d007ad25d5508865a4259c3af9af6d296bf663a0d586d0bc3369f6f" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75" +dependencies = [ + "async-channel", + "async-io", + "async-lock", + "async-signal", + "async-task", + "blocking", + "cfg-if", + "event-listener", + "futures-lite", + "rustix", +] + +[[package]] +name = "async-recursion" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "async-signal" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix", + "signal-hook-registry", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + +[[package]] +name = "async-trait" +version = "0.1.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "basic-toml" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a" +dependencies = [ + "serde", +] + +[[package]] +name = "bech32" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" + [[package]] name = "bitflags" version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" +dependencies = [ + "hybrid-array 0.4.15", +] + +[[package]] +name = "block-padding" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "710f1dd022ef4e93f8a438b4ba958de7f64308434fa6a87104481645cc30068b" +dependencies = [ + "hybrid-array 0.4.15", +] + +[[package]] +name = "blocking" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + +[[package]] +name = "bumpalo" +version = "3.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cbc" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce2dc9ee5f88d11e0beb842c88b33c8a5cf0d1329c4b19494af42b07dbfe8896" +dependencies = [ + "cipher 0.5.2", +] + +[[package]] +name = "cc" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures 0.2.17", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20", + "cipher 0.4.4", + "poly1305", + "zeroize", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common 0.1.7", + "inout 0.1.4", + "zeroize", +] + +[[package]] +name = "cipher" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" +dependencies = [ + "crypto-common 0.2.2", + "inout 0.2.6", +] + [[package]] name = "clap" version = "4.6.7" @@ -95,7 +531,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 3.0.10", ] [[package]] @@ -104,27 +540,628 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486" +[[package]] +name = "cmov" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" + [[package]] name = "colorchoice" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "const-oid" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" + +[[package]] +name = "cookie" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "cookie-factory" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9885fa71e26b8ab7855e2ec7cae6e9b380edff76cd052e07c683a0319d51b3a2" +dependencies = [ + "futures", +] + +[[package]] +name = "cookie_store" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b2c103cf610ec6cae3da84a766285b42fd16aad564758459e6ecf128c75206" +dependencies = [ + "cookie", + "document-features", + "idna", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "time", + "url", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpubits" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "rand_core", + "typenum", +] + +[[package]] +name = "crypto-common" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" +dependencies = [ + "hybrid-array 0.4.15", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher 0.4.4", +] + +[[package]] +name = "ctutils" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261af4dc7a06ea8a527a8717d8cbba3417530d6ea14e1edb3de6b67806be474f" +dependencies = [ + "cmov", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "curve25519-dalek-derive", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid 0.9.6", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common 0.1.7", + "subtle", +] + +[[package]] +name = "digest" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" +dependencies = [ + "block-buffer 0.12.1", + "const-oid 0.10.3", + "crypto-common 0.2.2", + "ctutils", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array", + "group", + "hkdf 0.12.4", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "endi" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" + +[[package]] +name = "enumflags2" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "equivalent" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" +[[package]] +name = "errno" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "ff" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "find-crate" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a98bbaacea1c0eb6a0876280051b892eb73594fd90cf3b20e9c817029c57d2" +dependencies = [ + "toml 0.5.11", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "flate2" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" +dependencies = [ + "crc32fast", + "miniz_oxide", + "zlib-rs", +] + +[[package]] +name = "fluent" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8137a6d5a2c50d6b0ebfcb9aaa91a28154e0a70605f112d30cb0cd4a78670477" +dependencies = [ + "fluent-bundle", + "unic-langid", +] + +[[package]] +name = "fluent-bundle" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01203cb8918f5711e73891b347816d932046f95f54207710bda99beaeb423bf4" +dependencies = [ + "fluent-langneg", + "fluent-syntax", + "intl-memoizer", + "intl_pluralrules", + "rustc-hash", + "self_cell", + "smallvec", + "unic-langid", +] + +[[package]] +name = "fluent-langneg" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eebbe59450baee8282d71676f3bfed5689aeab00b27545e83e5f14b1195e8b0" +dependencies = [ + "unic-langid", +] + +[[package]] +name = "fluent-syntax" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54f0d287c53ffd184d04d8677f590f4ac5379785529e5e08b1c8083acdd5c198" +dependencies = [ + "memchr", + "thiserror 2.0.21", +] + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-lite" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", +] + +[[package]] +name = "ghash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +dependencies = [ + "opaque-debug", + "polyval", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + [[package]] name = "grove" version = "0.1.0" dependencies = [ + "age", "anyhow", "clap", "grove-core", "grove-daemon", + "grove-providers", "serde_json", + "toml 1.2.1+spec-1.1.0", +] + +[[package]] +name = "grove-bridge" +version = "0.1.0" +dependencies = [ + "anyhow", + "grove-daemon", + "serde_json", + "toml 1.2.1+spec-1.1.0", ] [[package]] @@ -132,7 +1169,7 @@ name = "grove-core" version = "0.1.0" dependencies = [ "serde", - "toml", + "toml 1.2.1+spec-1.1.0", ] [[package]] @@ -146,6 +1183,17 @@ dependencies = [ "serde_json", ] +[[package]] +name = "grove-providers" +version = "0.1.0" +dependencies = [ + "grove-core", + "keyring", + "serde", + "serde_json", + "ureq", +] + [[package]] name = "hashbrown" version = "0.17.1" @@ -158,6 +1206,278 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac 0.12.1", +] + +[[package]] +name = "hkdf" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018" +dependencies = [ + "hmac 0.13.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "hmac" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" +dependencies = [ + "digest 0.11.3", +] + +[[package]] +name = "hpke" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4917627a14198c3603282c5158b815ad5534795451d3c074b53cf3cee0960b11" +dependencies = [ + "aead", + "aes-gcm", + "chacha20poly1305", + "digest 0.10.7", + "generic-array", + "hkdf 0.12.4", + "hmac 0.12.1", + "p256", + "rand_core", + "sha2 0.10.9", + "subtle", + "zeroize", +] + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hybrid-array" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2d35805454dc9f8662a98d6d61886ffe26bd465f5960e0e55345c70d5c0d2a9" +dependencies = [ + "typenum", +] + +[[package]] +name = "hybrid-array" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" +dependencies = [ + "typenum", +] + +[[package]] +name = "i18n-config" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e06b90c8a0d252e203c94344b21e35a30f3a3a85dc7db5af8f8df9f3e0c63ef" +dependencies = [ + "basic-toml", + "log", + "serde", + "serde_derive", + "thiserror 1.0.69", + "unic-langid", +] + +[[package]] +name = "i18n-embed" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a217bbb075dcaefb292efa78897fc0678245ca67f265d12c351e42268fcb0305" +dependencies = [ + "arc-swap", + "fluent", + "fluent-langneg", + "fluent-syntax", + "i18n-embed-impl", + "intl-memoizer", + "log", + "parking_lot", + "rust-embed", + "thiserror 1.0.69", + "unic-langid", + "walkdir", +] + +[[package]] +name = "i18n-embed-fl" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "602e6bd30c3db2749e13e38b363a3d98d9d41de1d8de7a79c31bb69e45b47cda" +dependencies = [ + "find-crate", + "fluent", + "fluent-syntax", + "i18n-config", + "i18n-embed", + "proc-macro-error3", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.119", + "unic-langid", +] + +[[package]] +name = "i18n-embed-impl" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2cc0e0523d1fe6fc2c6f66e5038624ea8091b3e7748b5e8e0c84b1698db6c2" +dependencies = [ + "find-crate", + "i18n-config", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "indexmap" version = "2.14.2" @@ -188,6 +1508,50 @@ dependencies = [ "libc", ] +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + +[[package]] +name = "inout" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a580c13f0ffc335ef42dd3f6b1a41b726051c5e1656d9a3aa6fddb3c5dfbbf9" +dependencies = [ + "block-padding", + "hybrid-array 0.4.15", +] + +[[package]] +name = "intl-memoizer" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "310da2e345f5eb861e7a07ee182262e94975051db9e4223e909ba90f392f163f" +dependencies = [ + "type-map", + "unic-langid", +] + +[[package]] +name = "intl_pluralrules" +version = "7.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078ea7b7c29a2b4df841a7f6ac8775ff6074020c6776d48491ce2268e068f972" +dependencies = [ + "unic-langid", +] + +[[package]] +name = "io_tee" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b3f7cef34251886990511df1c61443aa928499d598a9473929ab5a90a527304" + [[package]] name = "is_terminal_polyfill" version = "1.70.2" @@ -200,6 +1564,57 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "keccak" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb26cec98cce3a3d96cbb7bced3c4b16e3d13f27ec56dbd62cbc8f39cfb9d653" +dependencies = [ + "cpufeatures 0.2.17", +] + +[[package]] +name = "kem" +version = "0.3.0-pre.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b8645470337db67b01a7f966decf7d0bafedbae74147d33e641c67a91df239f" +dependencies = [ + "rand_core", + "zeroize", +] + +[[package]] +name = "keyring" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2270074a3d26bcac93c1dc5d2845eb4c089e8d761ccf6e0ea266a16004640627" +dependencies = [ + "apple-native-keyring-store", + "keyring-core", + "windows-native-keyring-store", + "zbus-secret-service-keyring-store", +] + +[[package]] +name = "keyring-core" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29fbf4b551298c67925f38cf341a1ada797a75f1837bdf8ae1fc8e2ebc6efb59" +dependencies = [ + "log", +] + [[package]] name = "kqueue" version = "1.2.1" @@ -220,12 +1635,45 @@ dependencies = [ "libc", ] +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + [[package]] name = "libc" version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "litrs" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + [[package]] name = "log" version = "0.4.35" @@ -238,6 +1686,41 @@ version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5848f5a9e8117cf94f2f90faac24a87ff81600ff8628c1e3deaab572e76bfa1" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + [[package]] name = "mio" version = "1.2.5" @@ -247,7 +1730,28 @@ dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "ml-kem" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de49b3df74c35498c0232031bb7e85f9389f913e2796169c8ab47a53993a18f" +dependencies = [ + "hybrid-array 0.2.3", + "kem", + "rand_core", + "sha3", +] + +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", ] [[package]] @@ -266,7 +1770,7 @@ dependencies = [ "objc2-core-foundation", "objc2-core-services", "walkdir", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -278,6 +1782,84 @@ dependencies = [ "bitflags", ] +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "objc2-core-foundation" version = "0.3.2" @@ -297,12 +1879,227 @@ dependencies = [ "objc2-core-foundation", ] +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + [[package]] name = "once_cell_polyfill" version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "elliptic-curve", + "primeorder", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest 0.10.7", + "hmac 0.12.1", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "piper" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "polyval" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro-error-attr3" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e564d14133360e1ae169ffde5da25881b5fa47261665b8e5713c212c27799da" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error3" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f0d4471b3436c22106b21913b1dda531558918ae9b7ec55d58aa84b43552233" +dependencies = [ + "proc-macro-error-attr3", + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "proc-macro2" version = "1.0.107" @@ -321,6 +2118,207 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rust-embed" +version = "8.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e98f580cf7a2863aeb6827800283f52cbe6fb3f3bb7c1843783f903c16dcb8ad" +dependencies = [ + "rust-embed-impl", + "rust-embed-utils", + "walkdir", +] + +[[package]] +name = "rust-embed-impl" +version = "8.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a93e2f69cf224a6c7df7509aa5ba4a23f56828ee41b040e92ac8762371eb9ba7" +dependencies = [ + "mime_guess", + "proc-macro2", + "quote", + "rust-embed-utils", + "syn 2.0.119", + "walkdir", +] + +[[package]] +name = "rust-embed-utils" +version = "8.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915e33dccbe7deb2b8a342dc4c517503fe85e0230ddbae40a4fb0220493dad9b" +dependencies = [ + "sha2 0.11.1", + "walkdir", +] + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher 0.4.4", +] + [[package]] name = "same-file" version = "1.0.6" @@ -330,6 +2328,99 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "scrypt" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f" +dependencies = [ + "pbkdf2", + "salsa20", + "sha2 0.10.9", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "subtle", + "zeroize", +] + +[[package]] +name = "secrecy" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e891af845473308773346dc847b2c23ee78fe442e0472ac50e22a18a93d3ae5a" +dependencies = [ + "zeroize", +] + +[[package]] +name = "secret-service" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5107b24b91445dd2aa449a258a1807b63240942157292354dc5bfdbeb8bc6db8" +dependencies = [ + "aes 0.9.4", + "cbc", + "futures-util", + "getrandom 0.4.3", + "hkdf 0.13.0", + "hybrid-array 0.4.15", + "num", + "once_cell", + "serde", + "sha2 0.11.1", + "zbus", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "self_cell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + [[package]] name = "serde" version = "1.0.229" @@ -357,7 +2448,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.10", ] [[package]] @@ -373,6 +2464,17 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_repr" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "serde_spanned" version = "1.1.3" @@ -382,12 +2484,101 @@ dependencies = [ "serde_core", ] +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "digest 0.11.3", +] + +[[package]] +name = "sha3" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77fd7028345d415a4034cf8777cd4f8ab1851274233b45f84e3d955502d93874" +dependencies = [ + "digest 0.10.7", + "keccak", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "3.0.10" @@ -399,6 +2590,120 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "time" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "serde_core", + "zerovec", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "toml" version = "1.2.1+spec-1.1.0" @@ -423,6 +2728,18 @@ dependencies = [ "serde_core", ] +[[package]] +name = "toml_edit" +version = "0.25.19+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + [[package]] name = "toml_parser" version = "1.1.5+spec-1.1.0" @@ -438,18 +2755,189 @@ version = "1.2.0+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a" +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "type-map" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb30dbbd9036155e74adad6812e9898d03ec374946234fbcebd5dfc7b9187b90" +dependencies = [ + "rustc-hash", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "uds_windows" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" +dependencies = [ + "memoffset", + "tempfile", + "windows-sys 0.61.2", +] + +[[package]] +name = "unic-langid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28ba52c9b05311f4f6e62d5d9d46f094bd6e84cb8df7b3ef952748d752a7d05" +dependencies = [ + "unic-langid-impl", +] + +[[package]] +name = "unic-langid-impl" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce1bf08044d4b7a94028c93786f8566047edc11110595914de93362559bc658" +dependencies = [ + "serde", + "tinystr", +] + +[[package]] +name = "unicase" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357cc3acc6a036009fd6c973ed009037c732d60d0b4f6c673e9041497482a28f" + [[package]] name = "unicode-ident" version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common 0.1.7", + "subtle", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "3.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ac5cecf619ca81f66a96482db09687c9f7465af65f4300a8c30cca05bd5a59d" +dependencies = [ + "base64 0.23.1", + "cookie_store", + "flate2", + "log", + "percent-encoding", + "rustls", + "rustls-pki-types", + "serde", + "serde_json", + "ureq-proto", + "utf8-zero", + "webpki-roots", +] + +[[package]] +name = "ureq-proto" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622dce33c252115466d83f63e9744a18f12b4406aae51a01c15ad8fcf1185eb3" +dependencies = [ + "base64 0.23.1", + "http", + "httparse", + "log", +] + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8-zero" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c0a043c9540bae7c578c88f91dda8bd82e59ae27c21baca69c8b191aaf5a6e" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "uuid" +version = "1.29.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bed99139f7dac9b5cfe5f17be4d66dc7079a34dee1d74bcc77217119240e267c" +dependencies = [ + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + [[package]] name = "walkdir" version = "2.5.0" @@ -466,13 +2954,66 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +[[package]] +name = "wasm-bindgen" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.10", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "webpki-roots" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7265c9301c16a8711c992c2d8da90ee77ef54b1ed51482d6dfeb00dc756b1297" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "winapi-util" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -481,6 +3022,28 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-native-keyring-store" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063426e76fdec7438d56bb777f67e318a84a25c707b07e575cb8b78e10c028f8" +dependencies = [ + "byteorder", + "keyring-core", + "regex", + "windows-sys 0.61.2", + "zeroize", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.61.2" @@ -490,14 +3053,345 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winnow" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +dependencies = [ + "memchr", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "x25519-dalek" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" +dependencies = [ + "curve25519-dalek", + "rand_core", + "serde", + "zeroize", +] + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zbus" +version = "5.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5db4be7c075cb421e4b7ee645541604239bd243ba7c357511f4ff3a74b555907" +dependencies = [ + "async-broadcast", + "async-executor", + "async-io", + "async-lock", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "enumflags2", + "event-listener", + "futures-core", + "futures-lite", + "hex", + "libc", + "ordered-stream", + "rustix", + "serde", + "serde_repr", + "tracing", + "uds_windows", + "uuid", + "windows-sys 0.61.2", + "winnow", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus-secret-service-keyring-store" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74801d001b9e7729adb4f1825b67b398185fed424749aa3d8bacf70417137d9a" +dependencies = [ + "keyring-core", + "secret-service", + "zbus", +] + +[[package]] +name = "zbus_macros" +version = "5.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 3.0.10", + "zbus_names", + "zvariant", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "4.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd" +dependencies = [ + "serde", + "winnow", + "zvariant", +] + +[[package]] +name = "zcheapstr" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939f186d9ecebe044315a5cb6d6f78568bbc21152adc954d5a0c2f58bdbc9920" +dependencies = [ + "serde", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "serde", + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" [[package]] name = "zmij" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zvariant" +version = "5.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7" +dependencies = [ + "endi", + "enumflags2", + "serde", + "winnow", + "zcheapstr", + "zvariant_derive", + "zvariant_utils", +] + +[[package]] +name = "zvariant_derive" +version = "5.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 3.0.10", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 3.0.10", + "winnow", +] diff --git a/Cargo.toml b/Cargo.toml index b764f5d..a315bd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "3" -members = ["crates/grove-core", "crates/grove", "crates/grove-daemon"] +members = ["crates/grove-core", "crates/grove", "crates/grove-daemon", "crates/grove-providers", "crates/grove-bridge"] [workspace.package] edition = "2024" diff --git a/LESSONS.md b/LESSONS.md index 3975ffd..dadba6a 100644 --- a/LESSONS.md +++ b/LESSONS.md @@ -5,3 +5,6 @@ - `Git::run` trims stdout, which also eats the leading space of the first `status --porcelain` line (` M x` becomes `M x`). Don't assert on that format via `run`. - Fetch other machines' snapshots into `refs/sync-remote/*`, never into `refs/sync/*`, or a fetch can clobber this machine's own refs. - Run tests that create many temp repos with unique dir names (pid + nanos); the shared `tests/common` helper does this. +- Bare-layout clones must set upstream tracking per branch, or `status` silently reports Synced for Behind/Diverged. Assert tracking in tests of any clone path. +- Unix socket paths are limited to ~100 bytes: use a short `XDG_RUNTIME_DIR` (e.g. `/tmp/gd`) when running a daemon from deep scratch dirs. +- Mock-server tests must parse the JSON request body; pretty-printed JSON breaks string asserts. diff --git a/contrib/groved.deb.service b/contrib/groved.deb.service new file mode 100644 index 0000000..bc1da9f --- /dev/null +++ b/contrib/groved.deb.service @@ -0,0 +1,13 @@ +[Unit] +Description=grove daemon (keeps git repos in sync across machines) +Documentation=https://git.zenvairo.es/dasemu/Grove + +[Service] +Type=simple +ExecStart=/usr/bin/groved +Restart=on-failure +RestartSec=5 +# Nothing to flush on stop: all durable state lives in git, so a plain SIGTERM is safe. + +[Install] +WantedBy=default.target diff --git a/crates/grove-bridge/Cargo.toml b/crates/grove-bridge/Cargo.toml new file mode 100644 index 0000000..508e322 --- /dev/null +++ b/crates/grove-bridge/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "grove-bridge" +description = "Backend of the grove GUI: daemon IPC + allow-listed CLI calls, and a localhost dev server" +edition.workspace = true +version.workspace = true +license.workspace = true + +[dependencies] +anyhow = "1.0.104" +grove-daemon = { version = "0.1.0", path = "../grove-daemon" } +serde_json = "1.0.154" +toml = "1.2.1" diff --git a/crates/grove-bridge/src/lib.rs b/crates/grove-bridge/src/lib.rs new file mode 100644 index 0000000..997974f --- /dev/null +++ b/crates/grove-bridge/src/lib.rs @@ -0,0 +1,175 @@ +//! Everything the GUI needs from the machine, behind three calls. The Tauri shell and the +//! localhost dev server both expose exactly these. + +use serde_json::{Value, json}; +use std::io::Write; +use std::path::PathBuf; +use std::process::{Command, Stdio}; + +/// `grove` subcommands the GUI may run. Everything else is refused. +const ALLOWED: &[&str] = &[ + "init", + "login", + "new", + "import", + "config-repo-init", + "bootstrap", + "resolve", + "secrets", + "sync", + "status", +]; + +pub struct Bridge { + pub grove_bin: PathBuf, + pub config: Option, + pub socket: PathBuf, +} + +impl Bridge { + /// Forwards one IPC request to the daemon. An unreachable daemon is a normal answer. + pub fn ipc(&self, req: &Value) -> Value { + grove_daemon::ipc::request(&self.socket, req).unwrap_or_else( + |e| json!({"v": 1, "ok": false, "offline": true, "error": format!("daemon not reachable: {e}")}), + ) + } + + /// Runs an allow-listed `grove` subcommand. `stdin` is passed through (used by `login`). + pub fn cli(&self, args: &[String], stdin: &str) -> Value { + let Some(sub) = args.first() else { + return json!({"ok": false, "output": "no command"}); + }; + if !ALLOWED.contains(&sub.as_str()) { + return json!({"ok": false, "output": format!("command {sub:?} is not allowed from the GUI")}); + } + if let Err(e) = validate(args) { + return json!({"ok": false, "output": format!("rejected: {e}")}); + } + let mut cmd = Command::new(&self.grove_bin); + if let Some(c) = &self.config { + cmd.arg("--config").arg(c); + } + cmd.args(args) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()); + let mut run = || -> std::io::Result { + let mut child = cmd.spawn()?; + // Feed stdin from a thread so a chatty child cannot deadlock against a full pipe. + let writer = child.stdin.take().map(|mut si| { + let data = stdin.to_owned(); + std::thread::spawn(move || { + let _ = si.write_all(data.as_bytes()); + }) + }); + let out = child.wait_with_output(); + if let Some(w) = writer { + let _ = w.join(); + } + out + }; + match run() { + Ok(o) => { + let mut text = String::from_utf8_lossy(&o.stdout).into_owned(); + text.push_str(&String::from_utf8_lossy(&o.stderr)); + json!({"ok": o.status.success(), "output": text.trim()}) + } + Err(e) => { + json!({"ok": false, "output": format!("cannot run {}: {e}", self.grove_bin.display())}) + } + } + } + + /// `config.toml` as JSON (it holds no secrets), or `None` before onboarding. + pub fn config_json(&self) -> Option { + let p = self.config.clone().or_else(grove_core_default_config)?; + let t: toml::Value = toml::from_str(&std::fs::read_to_string(p).ok()?).ok()?; + serde_json::to_value(t).ok() + } +} + +/// Per-command flag table: (flags without value, flags taking one value). +fn flag_spec(sub: &str) -> (&'static [&'static str], &'static [&'static str]) { + match sub { + "init" => (&[], &["--machine", "--root", "--provider", "--kind", "--group", "--config-repo", "--url"]), + "new" => (&["--public"], &[]), + "resolve" => (&["--take-remote", "--keep-local"], &["--save-as"]), + _ => (&[], &[]), + } +} + +/// Strict argument shape: only known flags, no option-like positionals or values (so nothing can +/// smuggle in `--config`, `--force`, `--compare`, ...), and `secrets` limited to init/pull/rekey. +pub fn validate(args: &[String]) -> Result<(), String> { + let sub = args.first().map(String::as_str).unwrap_or(""); + let (bools, valued) = flag_spec(sub); + let mut it = args[1..].iter().enumerate(); + while let Some((i, a)) = it.next() { + if a.starts_with('-') { + if valued.contains(&a.as_str()) { + match it.next() { + Some((_, v)) if !v.starts_with('-') => {} + _ => return Err(format!("{a} needs a value")), + } + } else if !bools.contains(&a.as_str()) { + return Err(format!("flag {a:?} is not allowed from the GUI")); + } + } else if sub == "secrets" && i == 0 && !["init", "pull", "rekey"].contains(&a.as_str()) { + return Err(format!("secrets {a:?} is not allowed from the GUI")); + } + } + if sub == "secrets" && args.len() != 2 { + return Err("secrets takes exactly one action".into()); + } + Ok(()) +} + +fn grove_core_default_config() -> Option { + let base = std::env::var_os("XDG_CONFIG_HOME") + .map(PathBuf::from) + .or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".config")))?; + Some(base.join("grove/config.toml")) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn validate_blocks_smuggled_flags() { + let v = |a: &[&str]| validate(&a.iter().map(|s| s.to_string()).collect::>()); + assert!(v(&["sync", "--config", "/x"]).is_err()); + assert!(v(&["init", "--force"]).is_err()); + assert!(v(&["resolve", "/p", "--compare"]).is_err()); + assert!(v(&["resolve", "/p", "--save-as", "--take-remote"]).is_err()); + assert!(v(&["secrets", "push", "f"]).is_err()); + assert!(v(&["new", "g", "-x"]).is_err()); + assert!(v(&["resolve", "/p", "--save-as", "b", "--take-remote"]).is_ok()); + assert!(v(&["new", "g", "n", "--public"]).is_ok()); + assert!(v(&["secrets", "pull"]).is_ok()); + } + + fn bridge() -> Bridge { + Bridge { + grove_bin: "/nonexistent/grove".into(), + config: None, + socket: "/nonexistent/sock".into(), + } + } + + #[test] + fn only_allow_listed_subcommands_run() { + let r = bridge().cli(&["daemon".into(), "pause".into()], ""); + assert_eq!(r["ok"], false); + assert!(r["output"].as_str().unwrap().contains("not allowed")); + let r = bridge().cli(&["sync".into()], ""); + assert!(r["output"].as_str().unwrap().contains("cannot run")); + } + + #[test] + fn offline_daemon_is_a_regular_answer() { + let r = bridge().ipc(&json!({"v": 1, "cmd": "status"})); + assert_eq!(r["ok"], false); + assert_eq!(r["offline"], true); + } +} diff --git a/crates/grove-bridge/src/main.rs b/crates/grove-bridge/src/main.rs new file mode 100644 index 0000000..5c7c126 --- /dev/null +++ b/crates/grove-bridge/src/main.rs @@ -0,0 +1,155 @@ +//! Localhost dev server for the GUI frontend: static files plus the `Bridge` calls over HTTP. +//! Binds to 127.0.0.1 only. POSTs need the `X-Grove: 1` header (not sendable cross-origin +//! without a preflight, which is never answered); the Host must be exactly 127.0.0.1: or +//! localhost: and any Origin must match too (DNS rebinding). + +use anyhow::{Context, Result}; +use grove_bridge::Bridge; +use serde_json::{Value, json}; +use std::io::{BufRead, BufReader, Read, Write}; +use std::net::{TcpListener, TcpStream}; +use std::path::PathBuf; +use std::sync::Arc; + +fn arg(name: &str) -> Option { + let a: Vec = std::env::args().collect(); + a.iter() + .position(|x| x == name) + .and_then(|i| a.get(i + 1)) + .cloned() +} + +fn main() -> Result<()> { + let ui = PathBuf::from(arg("--ui").unwrap_or_else(|| "gui/ui".into())); + let port: u16 = arg("--port") + .map_or(Ok(4780), |p| p.parse()) + .context("bad --port")?; + let bridge = Arc::new(Bridge { + grove_bin: arg("--grove-bin").map_or_else(|| "grove".into(), PathBuf::from), + config: arg("--config").map(PathBuf::from), + socket: arg("--socket") + .map(PathBuf::from) + .unwrap_or_else(grove_daemon::ipc::default_socket_path), + }); + let l = TcpListener::bind(("127.0.0.1", port)).with_context(|| format!("port {port}"))?; + eprintln!( + "grove GUI dev server on http://127.0.0.1:{port}/ (ui: {})", + ui.display() + ); + for s in l.incoming().filter_map(Result::ok) { + let (b, ui) = (bridge.clone(), ui.clone()); + let _ = s.set_read_timeout(Some(std::time::Duration::from_secs(10))); + std::thread::spawn(move || { + let _ = handle(s, &b, &ui, port); + }); + } + Ok(()) +} + +fn respond(s: &mut TcpStream, status: &str, ctype: &str, body: &[u8]) -> std::io::Result<()> { + write!( + s, + "HTTP/1.1 {status}\r\nContent-Type: {ctype}\r\nContent-Length: {}\r\nCache-Control: no-store\r\nConnection: close\r\n\r\n", + body.len() + )?; + s.write_all(body) +} + +fn handle(mut s: TcpStream, b: &Bridge, ui: &std::path::Path, port: u16) -> std::io::Result<()> { + // Cap what a client can make us buffer while reading the request head. + let mut r = BufReader::new(s.try_clone()?.take(64 * 1024)); + let mut line = String::new(); + r.read_line(&mut line)?; + let mut it = line.split_whitespace(); + let (method, path) = ( + it.next().unwrap_or("").to_string(), + it.next().unwrap_or("/").to_string(), + ); + let (mut len, mut host, mut marker, mut origin) = (0usize, String::new(), false, None); + loop { + let mut h = String::new(); + if r.read_line(&mut h)? == 0 || h.trim().is_empty() { + break; + } + let lower = h.to_ascii_lowercase(); + if let Some(v) = lower.strip_prefix("content-length:") { + len = v.trim().parse().unwrap_or(0); + } else if let Some(v) = lower.strip_prefix("host:") { + host = v.trim().to_string(); + } else if let Some(v) = lower.strip_prefix("origin:") { + origin = Some(v.trim().to_string()); + } else if lower.starts_with("x-grove:") { + marker = true; + } + } + // Exact match: a prefix check would accept `localhost.evil.com` (DNS rebinding). + let local = [format!("127.0.0.1:{port}"), format!("localhost:{port}")]; + if !local.contains(&host) { + return respond(&mut s, "403 Forbidden", "text/plain", b"bad host"); + } + if let Some(o) = &origin + && !local.iter().any(|h| *o == format!("http://{h}")) + { + return respond(&mut s, "403 Forbidden", "text/plain", b"bad origin"); + } + if method == "POST" { + if !marker || len > 1 << 20 { + return respond(&mut s, "403 Forbidden", "text/plain", b"forbidden"); + } + r.get_mut().set_limit(1 << 20); // head parsed; allow the (capped) body + let mut body = vec![0u8; len]; + r.read_exact(&mut body)?; + let req: Value = serde_json::from_slice(&body).unwrap_or(Value::Null); + let out = match path.as_str() { + "/api/ipc" => b.ipc(&req), + "/api/cli" => { + let args: Vec = req["args"] + .as_array() + .map(|a| { + a.iter() + .filter_map(|x| x.as_str().map(String::from)) + .collect() + }) + .unwrap_or_default(); + b.cli(&args, req["stdin"].as_str().unwrap_or("")) + } + _ => return respond(&mut s, "404 Not Found", "text/plain", b"not found"), + }; + return respond( + &mut s, + "200 OK", + "application/json", + out.to_string().as_bytes(), + ); + } + if path == "/api/config" { + let body = match b.config_json() { + Some(c) => json!({"exists": true, "config": c}), + None => json!({"exists": false}), + }; + return respond( + &mut s, + "200 OK", + "application/json", + body.to_string().as_bytes(), + ); + } + let name = match path.split('?').next().unwrap_or("/") { + "/" => "index.html", + p => p.trim_start_matches('/'), + }; + if name.contains("..") { + return respond(&mut s, "403 Forbidden", "text/plain", b"forbidden"); + } + let ctype = match name.rsplit('.').next() { + Some("html") => "text/html; charset=utf-8", + Some("js") => "text/javascript; charset=utf-8", + Some("css") => "text/css; charset=utf-8", + Some("svg") => "image/svg+xml", + _ => "application/octet-stream", + }; + match std::fs::read(ui.join(name)) { + Ok(data) => respond(&mut s, "200 OK", ctype, &data), + Err(_) => respond(&mut s, "404 Not Found", "text/plain", b"not found"), + } +} diff --git a/crates/grove-core/src/config.rs b/crates/grove-core/src/config.rs index f0ee5c6..7e1c9e7 100644 --- a/crates/grove-core/src/config.rs +++ b/crates/grove-core/src/config.rs @@ -1,11 +1,11 @@ //! `config.toml` model, loading and validation (section 6 of the plan). -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::fmt; use std::path::{Path, PathBuf}; -#[derive(Debug, Clone, PartialEq, Deserialize)] +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct Config { pub machine: Machine, pub root: Root, @@ -15,20 +15,21 @@ pub struct Config { pub groups: Vec, #[serde(default)] pub sync: Sync, + #[serde(skip_serializing_if = "Option::is_none")] pub config_repo: Option, } -#[derive(Debug, Clone, PartialEq, Deserialize)] +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct Machine { pub name: String, } -#[derive(Debug, Clone, PartialEq, Deserialize)] +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct Root { pub path: String, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] pub enum ProviderKind { Gitea, @@ -36,13 +37,14 @@ pub enum ProviderKind { Github, } -#[derive(Debug, Clone, PartialEq, Deserialize)] +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct Provider { pub kind: ProviderKind, + #[serde(skip_serializing_if = "Option::is_none")] pub url: Option, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub enum Layout { #[default] @@ -50,7 +52,7 @@ pub enum Layout { Plain, } -#[derive(Debug, Clone, PartialEq, Deserialize)] +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct Group { pub name: String, pub primary: String, @@ -62,7 +64,7 @@ pub struct Group { pub auto_materialize: bool, } -#[derive(Debug, Clone, PartialEq, Deserialize)] +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct Sync { #[serde(default = "default_debounce")] pub snapshot_debounce_ms: u64, @@ -70,6 +72,9 @@ pub struct Sync { pub fetch_interval_s: u64, #[serde(default)] pub ignore_extra: Vec, + /// Changed files larger than this many MiB are not snapshotted (0 = no limit). + #[serde(default = "default_max_file_mb")] + pub max_file_mb: u64, } impl Default for Sync { @@ -78,11 +83,12 @@ impl Default for Sync { snapshot_debounce_ms: default_debounce(), fetch_interval_s: default_fetch(), ignore_extra: Vec::new(), + max_file_mb: default_max_file_mb(), } } } -#[derive(Debug, Clone, PartialEq, Deserialize)] +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct ConfigRepo { pub provider: String, pub name: String, @@ -94,6 +100,9 @@ fn yes() -> bool { fn default_debounce() -> u64 { 2000 } +fn default_max_file_mb() -> u64 { + 50 +} fn default_fetch() -> u64 { 60 } @@ -124,6 +133,18 @@ impl Config { Ok(cfg) } + /// Writes the config atomically (temp file + rename). + pub fn save(&self, path: &Path) -> Result<(), ConfigError> { + let text = toml::to_string_pretty(self).map_err(|e| ConfigError::Parse(e.to_string()))?; + let io = |e| ConfigError::Io(path.to_path_buf(), e); + if let Some(dir) = path.parent() { + std::fs::create_dir_all(dir).map_err(io)?; + } + let tmp = path.with_extension("toml.tmp"); + std::fs::write(&tmp, text).map_err(io)?; + std::fs::rename(&tmp, path).map_err(io) + } + pub fn load(path: &Path) -> Result { let text = std::fs::read_to_string(path).map_err(|e| ConfigError::Io(path.to_path_buf(), e))?; diff --git a/crates/grove-core/src/lib.rs b/crates/grove-core/src/lib.rs index d0bfa32..8f68d35 100644 --- a/crates/grove-core/src/lib.rs +++ b/crates/grove-core/src/lib.rs @@ -6,6 +6,8 @@ pub mod inspect; pub mod layout; pub mod migrate; pub mod receive; +pub mod registry; +pub mod resolve; pub mod snapshot; pub mod state; pub mod sync; diff --git a/crates/grove-core/src/receive.rs b/crates/grove-core/src/receive.rs index 8c2bf4c..1182f46 100644 --- a/crates/grove-core/src/receive.rs +++ b/crates/grove-core/src/receive.rs @@ -15,13 +15,13 @@ pub const REMOTE_SYNC: &str = "refs/sync-remote"; /// Backup refs live in `refs/sync-backup///`; each kind has its own /// sub-namespace so refs of different operations in one pass can never collide (D/F conflict). -fn backup_ref(machine: &str, stamp: &str, kind: &str) -> String { +pub(crate) fn backup_ref(machine: &str, stamp: &str, kind: &str) -> String { format!("refs/sync-backup/{machine}/{stamp}/{kind}") } /// Paths the incoming change would add that already exist locally as *ignored* files. /// `git status` does not report those, but a merge/read-tree would silently overwrite them. -fn ignored_conflicts(g: &Git, target: &str) -> Result, GitError> { +pub(crate) fn ignored_conflicts(g: &Git, target: &str) -> Result, GitError> { let added = g.run(&[ "diff", "--no-renames", diff --git a/crates/grove-core/src/registry.rs b/crates/grove-core/src/registry.rs new file mode 100644 index 0000000..d6fd454 --- /dev/null +++ b/crates/grove-core/src/registry.rs @@ -0,0 +1,126 @@ +//! The config repo: a private git repo holding `repos.toml` (what to materialize) and one +//! heartbeat file per machine. A fresh machine needs nothing else to rebuild its workspace. + +use crate::git::{Git, GitError}; +use crate::layout::dir_name; +use crate::receive::{ensure_fetch_refspec, materialize}; +use serde::{Deserialize, Serialize}; +use std::fs; +use std::path::{Path, PathBuf}; + +#[derive(Debug, Clone, PartialEq, Eq, Default, Deserialize, Serialize)] +pub struct Registry { + #[serde(default)] + pub repos: Vec, +} + +#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] +pub struct Entry { + pub group: String, + pub name: String, + /// Clone URL on the group's primary remote. + pub url: String, +} + +impl Registry { + pub fn parse(text: &str) -> Result { + toml::from_str(text).map_err(|e| e.to_string()) + } + + pub fn to_text(&self) -> String { + toml::to_string_pretty(self).unwrap_or_default() + } + + /// Adds or updates an entry (same group + name). + pub fn upsert(&mut self, e: Entry) { + match self + .repos + .iter_mut() + .find(|x| x.group == e.group && x.name == e.name) + { + Some(x) => *x = e, + None => self.repos.push(e), + } + self.repos + .sort_by(|a, b| (&a.group, &a.name).cmp(&(&b.group, &b.name))); + } +} + +/// Creates `/.bare` as a clone of `url` and a worktree per remote branch. +/// `envs` are extra git environment variables (credentials). +pub fn clone_bare_layout( + url: &str, + dir: &Path, + envs: &[(String, String)], +) -> Result, GitError> { + fs::create_dir_all(dir)?; + let bare = dir.join(".bare"); + let mut g = Git::new(dir); + for (k, v) in envs { + g = g.with_env(k, v); + } + g.run(&["clone", "-q", "--bare", url, &bare.to_string_lossy()])?; + Git::new(&bare).run(&["config", "core.bare", "true"])?; + ensure_fetch_refspec(&bare, "origin")?; + let mut f = Git::new(&bare); + for (k, v) in envs { + f = f.with_env(k, v); + } + f.run(&["fetch", "-q", "--prune", "origin"])?; + // `clone --bare` creates local branches without upstream config; worktrees made from them + // would then never be classified as ahead/behind. + let b = Git::new(&bare); + let heads = b.run(&["for-each-ref", "--format=%(refname:short)", "refs/heads"])?; + for br in heads.lines() { + let up = format!("origin/{br}"); + if b.probe(&["rev-parse", "-q", "--verify", &format!("refs/remotes/{up}")])? + .is_some() + { + b.run(&["branch", "-q", &format!("--set-upstream-to={up}"), br])?; + } + } + materialize(dir, "origin") +} + +/// Creates a brand new local repo in the bare layout with an initial empty commit on `main`, +/// pointing at `url`. Nothing is pushed here. +pub fn init_bare_layout(dir: &Path, url: &str) -> Result { + fs::create_dir_all(dir)?; + let bare = dir.join(".bare"); + let g = Git::new(dir); + g.run(&[ + "init", + "-q", + "--bare", + "-b", + "main", + &bare.to_string_lossy(), + ])?; + let b = Git::new(&bare); + b.run(&["remote", "add", "origin", url])?; + ensure_fetch_refspec(&bare, "origin")?; + // `hash-object -t tree` on an empty file writes the empty tree object. + let tree = b.run(&["hash-object", "-t", "tree", "-w", "/dev/null"])?; + let commit = b + .with_env("GIT_AUTHOR_NAME", "grove") + .with_env("GIT_AUTHOR_EMAIL", "grove@localhost") + .with_env("GIT_COMMITTER_NAME", "grove") + .with_env("GIT_COMMITTER_EMAIL", "grove@localhost") + .run(&["commit-tree", &tree, "-m", "chore: initial commit"])?; + let b = Git::new(&bare); + b.run(&["update-ref", "refs/heads/main", &commit])?; + let name = dir_name("main", &[]); + let wt = dir.join(&name); + b.run(&["worktree", "add", "-q", &wt.to_string_lossy(), "main"])?; + Ok(wt) +} + +/// Pushes `main` of a freshly initialised layout and sets the upstream. +pub fn push_initial(dir: &Path, envs: &[(String, String)]) -> Result<(), GitError> { + let mut g = Git::new(dir.join(".bare")); + for (k, v) in envs { + g = g.with_env(k, v); + } + g.run(&["push", "-q", "-u", "origin", "main"])?; + Ok(()) +} diff --git a/crates/grove-core/src/resolve.rs b/crates/grove-core/src/resolve.rs new file mode 100644 index 0000000..2d39ee3 --- /dev/null +++ b/crates/grove-core/src/resolve.rs @@ -0,0 +1,107 @@ +//! Resolution of a `Diverged` worktree. Always an explicit choice by the user; every action +//! writes a backup ref first so nothing is ever lost. + +use crate::git::{Git, GitError}; +use crate::inspect::facts; +use crate::layout::dir_name; +use crate::receive::{backup_ref, ignored_conflicts}; +use std::path::Path; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Choice { + /// Discard the local commits and move to the remote tip. + TakeRemote, + /// Overwrite the remote branch with the local one (force-with-lease on the observed tip). + KeepLocal, + /// Keep the local commits on a new branch (own worktree), then move this one to the remote tip. + SaveAsBranch(String), +} + +fn fail(msg: impl Into) -> Result { + Err(GitError::Other(msg.into())) +} + +/// Applies `choice` to the diverged worktree. Returns a one-line description of what happened. +pub fn resolve( + worktree: &Path, + machine: &str, + stamp: &str, + choice: &Choice, +) -> Result { + let g = Git::new(worktree); + let f = facts(worktree)?; + if !(f.ahead && f.behind) { + return fail("worktree is not diverged: nothing to resolve"); + } + let branch = g + .probe(&["symbolic-ref", "--short", "-q", "HEAD"])? + .ok_or_else(|| GitError::Other("detached HEAD".into()))?; + let upstream = g.run(&["rev-parse", "@{upstream}"])?; + let head = g.run(&["rev-parse", "HEAD"])?; + match choice { + Choice::KeepLocal => { + g.run(&[ + "update-ref", + &backup_ref(machine, stamp, &format!("resolve-remote/{branch}")), + &upstream, + ])?; + let remote = g.run(&["config", "--get", &format!("branch.{branch}.remote")])?; + g.run(&[ + "push", + "-q", + &format!("--force-with-lease={branch}:{upstream}"), + &remote, + &format!("HEAD:refs/heads/{branch}"), + ])?; + Ok(format!( + "remote {branch} overwritten with local (old tip kept at backup ref)" + )) + } + Choice::TakeRemote | Choice::SaveAsBranch(_) => { + if f.dirty { + return fail("worktree has uncommitted changes: commit or stash them first"); + } + let clash = ignored_conflicts(&g, &upstream)?; + if !clash.is_empty() { + return fail(format!( + "would overwrite ignored local files: {}", + clash.join(", ") + )); + } + g.run(&[ + "update-ref", + &backup_ref(machine, stamp, &format!("resolve-local/{branch}")), + &head, + ])?; + let mut msg = + format!("{branch} moved to the remote tip (local tip kept at backup ref)"); + if let Choice::SaveAsBranch(name) = choice { + if g.probe(&["rev-parse", "-q", "--verify", &format!("refs/heads/{name}")])? + .is_some() + { + return fail(format!("branch {name:?} already exists")); + } + let root = worktree + .parent() + .ok_or_else(|| GitError::Other("worktree has no parent dir".into()))?; + if !root.join(".bare").is_dir() { + return fail("saving as a branch needs the bare + worktrees layout"); + } + let taken: Vec = std::fs::read_dir(root)? + .filter_map(Result::ok) + .map(|e| e.file_name().to_string_lossy().into_owned()) + .collect(); + let refs: Vec<&str> = taken.iter().map(String::as_str).collect(); + let dest = root.join(dir_name(name, &refs)); + g.run(&["branch", name, &head])?; + g.run(&["worktree", "add", "-q", &dest.to_string_lossy(), name])?; + msg = format!( + "local commits saved on branch {name} ({}); {msg}", + dest.display() + ); + } + g.run(&["reset", "-q", "--hard", &upstream])?; + Ok(msg) + } + } +} diff --git a/crates/grove-core/src/snapshot.rs b/crates/grove-core/src/snapshot.rs index ff592bb..fe2106e 100644 --- a/crates/grove-core/src/snapshot.rs +++ b/crates/grove-core/src/snapshot.rs @@ -3,6 +3,7 @@ use crate::git::{Git, GitError}; use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicU64, Ordering}; use std::time::{SystemTime, UNIX_EPOCH}; #[derive(Debug, Clone, PartialEq, Eq)] @@ -10,6 +11,16 @@ pub struct Snapshot { pub commit: String, pub tree: String, pub refname: String, + /// Changed files left out because they exceed the size limit. + pub skipped: Vec, +} + +static MAX_FILE_BYTES: AtomicU64 = AtomicU64::new(0); + +/// Process-wide limit: changed files larger than this are left out of snapshots (0 = no limit). +/// Set once at startup from `sync.max_file_mb`. +pub fn set_max_file_bytes(n: u64) { + MAX_FILE_BYTES.store(n, Ordering::Relaxed); } #[derive(Debug, Clone, PartialEq, Eq)] @@ -43,7 +54,7 @@ fn temp_index_path() -> PathBuf { /// built in a temporary copy of the index so the real index is never modified. The returned /// guard keeps the temporary index alive; `Git` has it set as `GIT_INDEX_FILE` and the author /// identity forced. -fn stage(git: &Git) -> Result<(TempIndex, Git, String), GitError> { +fn stage(git: &Git) -> Result<(TempIndex, Git, String, Vec), GitError> { let gitdir = PathBuf::from(git.run(&["rev-parse", "--absolute-git-dir"])?); let tmp = TempIndex(temp_index_path()); let real_index = gitdir.join("index"); @@ -58,8 +69,49 @@ fn stage(git: &Git) -> Result<(TempIndex, Git, String), GitError> { .with_env("GIT_COMMITTER_NAME", "grove") .with_env("GIT_COMMITTER_EMAIL", "grove@localhost"); snap.run(&["add", "-A"])?; + let skipped = drop_oversized(&snap, git.dir())?; let tree = snap.run(&["write-tree"])?; - Ok((tmp, snap, tree)) + Ok((tmp, snap, tree, skipped)) +} + +/// Reverts oversized changed files in the temporary index to their HEAD version (or removes them +/// when HEAD has none). Returns their paths. +fn drop_oversized(snap: &Git, worktree: &Path) -> Result, GitError> { + let limit = MAX_FILE_BYTES.load(Ordering::Relaxed); + if limit == 0 { + return Ok(Vec::new()); + } + let has_head = snap + .probe(&["rev-parse", "-q", "--verify", "HEAD"])? + .is_some(); + let changed = if has_head { + snap.run(&[ + "diff", + "--cached", + "--name-only", + "-z", + "--no-renames", + "HEAD", + ])? + } else { + snap.run(&["ls-files", "-z"])? + }; + let mut skipped = Vec::new(); + for rel in changed.split('\0').filter(|p| !p.is_empty()) { + let big = std::fs::symlink_metadata(worktree.join(rel)) + .map(|m| m.is_file() && m.len() > limit) + .unwrap_or(false); + if !big { + continue; + } + if has_head { + snap.run(&["reset", "-q", "HEAD", "--", rel])?; + } else { + snap.run(&["rm", "--cached", "-q", "--ignore-unmatch", "--", rel])?; + } + skipped.push(rel.to_string()); + } + Ok(skipped) } /// The tree a snapshot of `worktree` would have, without creating any object besides the tree. @@ -75,7 +127,7 @@ pub fn take(worktree: &Path, machine: &str, message_stamp: &str) -> Result Result, pub state: State, pub errors: Vec, + /// Large files left out of the snapshot (see `sync.max_file_mb`). + pub skipped: Vec, } #[derive(Debug, Clone, Default, PartialEq)] @@ -81,6 +83,7 @@ pub fn sync_repo(path: &Path, o: &Options) -> Result { applied: None, state: State::Synced, errors: Vec::new(), + skipped: Vec::new(), }; if let Some(branch) = &wt.branch { sync_worktree(&mut r, branch, o, rep.fetch_error.is_none()); @@ -109,7 +112,10 @@ fn sync_worktree(r: &mut WorktreeReport, branch: &str, o: &Options, fetched: boo // A clean worktree still refreshes an existing snapshot so a stale WIP never lingers. if dirty || has_ref { match take(&path, &o.machine, &o.stamp) { - Ok(Outcome::Created(_)) => r.snapshot = Some("created"), + Ok(Outcome::Created(s)) => { + r.snapshot = Some("created"); + r.skipped = s.skipped; + } Ok(Outcome::Unchanged(_)) => r.snapshot = Some("unchanged"), Err(e) => { r.errors.push(format!("snapshot: {e}")); diff --git a/crates/grove-core/tests/registry.rs b/crates/grove-core/tests/registry.rs new file mode 100644 index 0000000..0bf2d3c --- /dev/null +++ b/crates/grove-core/tests/registry.rs @@ -0,0 +1,76 @@ +mod common; +use common::*; +use grove_core::git::Git; +use grove_core::registry::*; +use std::fs; + +#[test] +fn new_repo_pushes_and_a_fresh_machine_clones_it_into_the_bare_layout() { + let base = tmpdir("reg"); + let remote = base.join("r.git"); + Git::new(&base) + .run(&[ + "init", + "-q", + "--bare", + "-b", + "main", + remote.to_str().unwrap(), + ]) + .unwrap(); + let url = remote.to_str().unwrap(); + + let a = base.join("A/g/proj"); + let wt = init_bare_layout(&a, url).unwrap(); + assert!(wt.ends_with("main") && wt.join(".git").exists()); + push_initial(&a, &[]).unwrap(); + let g = Git::new(&wt); + assert_eq!(g.run(&["status", "--porcelain"]).unwrap(), ""); + assert_eq!( + g.run(&["rev-parse", "--abbrev-ref", "@{upstream}"]) + .unwrap(), + "origin/main" + ); + + let b = base.join("B/g/proj"); + let made = clone_bare_layout(url, &b, &[]).unwrap(); + assert_eq!(made.len(), 1); + assert_eq!( + Git::new(b.join("main")) + .run(&["rev-parse", "--abbrev-ref", "@{upstream}"]) + .unwrap(), + "origin/main", + "cloned worktrees must track their remote branch" + ); + assert!(b.join("main/.git").exists() && b.join(".bare").is_dir()); + assert_eq!( + Git::new(b.join("main")) + .run(&["rev-parse", "HEAD"]) + .unwrap(), + g.run(&["rev-parse", "HEAD"]).unwrap() + ); + fs::remove_dir_all(&base).unwrap(); +} + +#[test] +fn registry_roundtrip_and_upsert() { + let mut r = Registry::default(); + r.upsert(Entry { + group: "z".into(), + name: "b".into(), + url: "u1".into(), + }); + r.upsert(Entry { + group: "a".into(), + name: "x".into(), + url: "u2".into(), + }); + r.upsert(Entry { + group: "z".into(), + name: "b".into(), + url: "u3".into(), + }); + assert_eq!(r.repos.len(), 2); + assert_eq!(r.repos[0].group, "a"); + assert_eq!(Registry::parse(&r.to_text()).unwrap(), r); +} diff --git a/crates/grove-core/tests/resolve.rs b/crates/grove-core/tests/resolve.rs new file mode 100644 index 0000000..6d6e32e --- /dev/null +++ b/crates/grove-core/tests/resolve.rs @@ -0,0 +1,107 @@ +mod common; +use common::*; +use grove_core::git::Git; +use grove_core::inspect::state; +use grove_core::registry::{clone_bare_layout, init_bare_layout, push_initial}; +use grove_core::resolve::{Choice, resolve}; +use grove_core::state::State; +use std::fs; +use std::path::PathBuf; + +/// Two machines on the bare layout, both committed on main: diverged on B. +fn diverged() -> (PathBuf, PathBuf, PathBuf) { + let base = tmpdir("resolve"); + let remote = base.join("r.git"); + Git::new(&base) + .run(&[ + "init", + "-q", + "--bare", + "-b", + "main", + remote.to_str().unwrap(), + ]) + .unwrap(); + let url = remote.to_str().unwrap().to_string(); + let a = base.join("A"); + init_bare_layout(&a, &url).unwrap(); + push_initial(&a, &[]).unwrap(); + let b = base.join("B"); + clone_bare_layout(&url, &b, &[]).unwrap(); + for (root, who) in [(&a, "a"), (&b, "b")] { + let g = Git::new(root.join("main")); + g.run(&["config", "user.email", "t@t"]).unwrap(); + g.run(&["config", "user.name", "t"]).unwrap(); + let _ = who; + } + // A commits and pushes; B commits locally and fetches. + let ga = Git::new(a.join("main")); + fs::write(a.join("main/f.txt"), "from A\n").unwrap(); + ga.run(&["add", "-A"]).unwrap(); + ga.run(&["commit", "-qm", "a"]).unwrap(); + ga.run(&["push", "-q"]).unwrap(); + let gb = Git::new(b.join("main")); + fs::write(b.join("main/g.txt"), "from B\n").unwrap(); + gb.run(&["add", "-A"]).unwrap(); + gb.run(&["commit", "-qm", "b"]).unwrap(); + gb.run(&["fetch", "-q"]).unwrap(); + assert_eq!(state(&b.join("main")), State::Diverged); + (base, a, b) +} + +#[test] +fn take_remote_discards_local_commits_but_keeps_a_backup_ref() { + let (_base, _a, b) = diverged(); + let wt = b.join("main"); + let msg = resolve(&wt, "B", "s1", &Choice::TakeRemote).unwrap(); + assert!(msg.contains("backup")); + let g = Git::new(&wt); + assert_eq!(state(&wt), State::Synced); + assert!(wt.join("f.txt").exists() && !wt.join("g.txt").exists()); + let backup = g + .run(&["rev-parse", "refs/sync-backup/B/s1/resolve-local/main"]) + .unwrap(); + assert!(g.run(&["show", &format!("{backup}:g.txt")]).is_ok()); +} + +#[test] +fn save_as_branch_keeps_the_local_work_in_its_own_worktree() { + let (_base, _a, b) = diverged(); + let wt = b.join("main"); + resolve(&wt, "B", "s1", &Choice::SaveAsBranch("b-work".into())).unwrap(); + assert_eq!(state(&wt), State::Synced); + assert!(!wt.join("g.txt").exists()); + assert_eq!( + fs::read_to_string(b.join("b-work/g.txt")).unwrap(), + "from B\n" + ); +} + +#[test] +fn keep_local_force_pushes_with_lease_and_backs_up_the_remote_tip() { + let (_base, a, b) = diverged(); + let wt = b.join("main"); + resolve(&wt, "B", "s1", &Choice::KeepLocal).unwrap(); + assert_eq!(state(&wt), State::Synced); + let ga = Git::new(a.join("main")); + ga.run(&["fetch", "-q"]).unwrap(); + let remote_tree = ga.run(&["ls-tree", "--name-only", "origin/main"]).unwrap(); + assert!(remote_tree.contains("g.txt") && !remote_tree.contains("f.txt")); + let g = Git::new(&wt); + assert!( + g.run(&["rev-parse", "refs/sync-backup/B/s1/resolve-remote/main"]) + .is_ok() + ); +} + +#[test] +fn refuses_when_not_diverged_or_when_the_worktree_is_dirty() { + let (_base, _a, b) = diverged(); + let wt = b.join("main"); + fs::write(wt.join("wip.txt"), "x\n").unwrap(); + let e = resolve(&wt, "B", "s", &Choice::TakeRemote) + .unwrap_err() + .to_string(); + assert!(e.contains("uncommitted"), "{e}"); + assert!(wt.join("wip.txt").exists() && wt.join("g.txt").exists()); +} diff --git a/crates/grove-core/tests/size_limit.rs b/crates/grove-core/tests/size_limit.rs new file mode 100644 index 0000000..d640ce3 --- /dev/null +++ b/crates/grove-core/tests/size_limit.rs @@ -0,0 +1,43 @@ +//! Own test binary: the limit is process-wide. +mod common; +use common::*; +use grove_core::git::Git; +use grove_core::snapshot::{Outcome, set_max_file_bytes, take}; +use std::fs; + +#[test] +fn oversized_changes_are_left_out_but_small_ones_and_head_content_stay() { + let base = tmpdir("size"); + let g = init(&base.join("p")); + commit(&g, "tracked.bin", "old\n"); + set_max_file_bytes(1000); + let p = base.join("p"); + fs::write(p.join("small.txt"), "ok\n").unwrap(); + fs::write(p.join("big.bin"), vec![b'x'; 5000]).unwrap(); // untracked, too big + fs::write(p.join("tracked.bin"), vec![b'y'; 5000]).unwrap(); // tracked, modified, too big + let Outcome::Created(s) = take(&p, "A", "t").unwrap() else { + panic!("expected a snapshot") + }; + let mut skipped = s.skipped.clone(); + skipped.sort(); + assert_eq!(skipped, ["big.bin", "tracked.bin"]); + let show = |f: &str| Git::new(&p).run(&["show", &format!("{}:{f}", s.commit)]); + assert_eq!(show("small.txt").unwrap(), "ok"); + assert!( + show("big.bin").is_err(), + "big untracked file must not be in the snapshot" + ); + assert_eq!( + show("tracked.bin").unwrap(), + "old", + "tracked file keeps its HEAD content" + ); + // The user's real index and files are untouched. + assert_eq!(fs::read(p.join("big.bin")).unwrap().len(), 5000); + assert!( + Git::new(&p) + .run(&["status", "--porcelain"]) + .unwrap() + .contains("big.bin") + ); +} diff --git a/crates/grove-daemon/src/daemon.rs b/crates/grove-daemon/src/daemon.rs index c80bdb7..8bc2023 100644 --- a/crates/grove-daemon/src/daemon.rs +++ b/crates/grove-daemon/src/daemon.rs @@ -42,6 +42,7 @@ impl Settings { pub struct WtStatus { pub branch: Option, pub state: String, + pub path: String, } #[derive(Debug, Clone)] @@ -379,8 +380,14 @@ fn pass( let branch = w.branch.clone().unwrap_or_else(|| "(detached)".into()); let state = format!("{:?}", w.state).to_lowercase(); if let Some(kind) = w.snapshot { - ctx.activity - .log("snapshot", Some(&name), format!("{branch}: {kind}")); + let mut msg = format!("{branch}: {kind}"); + if !w.skipped.is_empty() { + msg.push_str(&format!( + " (left out, over the size limit: {})", + w.skipped.join(", ") + )); + } + ctx.activity.log("snapshot", Some(&name), msg); } match &w.received { Some(Received::FastForwarded { .. }) => { @@ -411,6 +418,7 @@ fn pass( now_wts.push(WtStatus { branch: w.branch.clone(), state, + path: w.path.display().to_string(), }); } status.worktrees = now_wts; diff --git a/crates/grove-daemon/src/ipc.rs b/crates/grove-daemon/src/ipc.rs index c5350d3..6b0eac2 100644 --- a/crates/grove-daemon/src/ipc.rs +++ b/crates/grove-daemon/src/ipc.rs @@ -161,7 +161,7 @@ fn handle(req: &Request, ctx: &Ctx) -> Value { "last_error": r.last_error, "failures": r.failures, "worktrees": r.worktrees.iter() - .map(|w| json!({"branch": w.branch, "state": w.state})) + .map(|w| json!({"branch": w.branch, "state": w.state, "path": w.path})) .collect::>(), }) }) diff --git a/crates/grove-daemon/src/main.rs b/crates/grove-daemon/src/main.rs index 6b6ea72..ec08e23 100644 --- a/crates/grove-daemon/src/main.rs +++ b/crates/grove-daemon/src/main.rs @@ -22,6 +22,7 @@ fn main() -> Result<()> { .or_else(Config::default_path) .context("cannot determine config path")?; let cfg = Config::load(&path)?; + grove_core::snapshot::set_max_file_bytes(cfg.sync.max_file_mb * 1024 * 1024); let st = Settings::standard(); eprintln!( "groved: machine {:?}, root {}, socket {}", diff --git a/crates/grove-providers/Cargo.toml b/crates/grove-providers/Cargo.toml new file mode 100644 index 0000000..9a7fb13 --- /dev/null +++ b/crates/grove-providers/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "grove-providers" +description = "Forge providers (Gitea/Forgejo, GitHub) and token storage for grove" +edition.workspace = true +version.workspace = true +license.workspace = true + +[dependencies] +grove-core = { version = "0.1.0", path = "../grove-core" } +keyring = "4.2.0" +serde = { version = "1.0.229", features = ["derive"] } +serde_json = "1.0.154" +ureq = { version = "3", features = ["json"] } diff --git a/crates/grove-providers/src/gitea.rs b/crates/grove-providers/src/gitea.rs new file mode 100644 index 0000000..cf21c82 --- /dev/null +++ b/crates/grove-providers/src/gitea.rs @@ -0,0 +1,97 @@ +use crate::http::Http; +use crate::{Capabilities, Error, MirrorSpec, NewRepo, Provider, RemoteRepo, Result}; +use grove_core::config::ProviderKind; +use serde_json::{Value, json}; + +/// Gitea and Forgejo share the same `/api/v1`. +pub struct Gitea { + kind: ProviderKind, + http: Http, +} + +impl Gitea { + pub fn new(kind: ProviderKind, url: &str, token: String) -> Self { + Gitea { + kind, + http: Http::new( + &format!("{}/api/v1", url.trim_end_matches('/')), + format!("token {token}"), + ), + } + } +} + +fn repo(v: &Value) -> RemoteRepo { + let s = |k: &str| v[k].as_str().unwrap_or_default().to_string(); + RemoteRepo { + owner: v["owner"]["login"].as_str().unwrap_or_default().to_string(), + name: s("name"), + private: v["private"].as_bool().unwrap_or(false), + clone_url: s("clone_url"), + default_branch: v["default_branch"].as_str().unwrap_or("main").to_string(), + } +} + +impl Provider for Gitea { + fn kind(&self) -> ProviderKind { + self.kind + } + + fn capabilities(&self) -> Capabilities { + Capabilities { + push_mirror: true, + orgs: true, + } + } + + fn test_connection(&self) -> Result { + let u = self.http.ok("GET", "/user", None)?; + u["login"] + .as_str() + .map(str::to_string) + .ok_or_else(|| Error::Other("response has no login".into())) + } + + fn list_repos(&self) -> Result> { + let mut out = Vec::new(); + for page in 1..=200 { + let v = self + .http + .ok("GET", &format!("/user/repos?limit=50&page={page}"), None)?; + let items = v.as_array().cloned().unwrap_or_default(); + let n = items.len(); + out.extend(items.iter().map(repo)); + if n < 50 { + break; + } + } + Ok(out) + } + + fn create_repo(&self, new: &NewRepo) -> Result { + let path = match &new.owner { + Some(o) => format!("/orgs/{o}/repos"), + None => "/user/repos".to_string(), + }; + let body = json!({"name": new.name, "private": new.private, + "description": new.description, "default_branch": "main"}); + Ok(repo(&self.http.ok("POST", &path, Some(&body))?)) + } + + fn configure_mirror(&self, owner: &str, name: &str, spec: &MirrorSpec) -> Result<()> { + let body = json!({ + "remote_address": spec.remote_url, + "remote_username": spec.remote_username, + "remote_password": spec.remote_token, + "interval": spec.interval, + "sync_on_commit": spec.sync_on_commit, + }); + self.http + .ok( + "POST", + &format!("/repos/{owner}/{name}/push_mirrors"), + Some(&body), + ) + .map(|_| ()) + } +} diff --git a/crates/grove-providers/src/github.rs b/crates/grove-providers/src/github.rs new file mode 100644 index 0000000..1077b11 --- /dev/null +++ b/crates/grove-providers/src/github.rs @@ -0,0 +1,87 @@ +use crate::http::Http; +use crate::{Capabilities, Error, MirrorSpec, NewRepo, Provider, RemoteRepo, Result}; +use grove_core::config::ProviderKind; +use serde_json::{Value, json}; + +pub struct GitHub { + http: Http, +} + +impl GitHub { + /// `url` empty means github.com; set it for GitHub Enterprise (`https://host/api/v3`) or tests. + pub fn new(url: &str, token: String) -> Self { + let base = if url.is_empty() || url == "https://github.com" { + "https://api.github.com" + } else { + url + }; + GitHub { + http: Http::new(base, format!("Bearer {token}")), + } + } +} + +fn repo(v: &Value) -> RemoteRepo { + RemoteRepo { + owner: v["owner"]["login"].as_str().unwrap_or_default().to_string(), + name: v["name"].as_str().unwrap_or_default().to_string(), + private: v["private"].as_bool().unwrap_or(false), + clone_url: v["clone_url"].as_str().unwrap_or_default().to_string(), + default_branch: v["default_branch"].as_str().unwrap_or("main").to_string(), + } +} + +impl Provider for GitHub { + fn kind(&self) -> ProviderKind { + ProviderKind::Github + } + + fn capabilities(&self) -> Capabilities { + Capabilities { + push_mirror: false, + orgs: true, + } + } + + fn test_connection(&self) -> Result { + let u = self.http.ok("GET", "/user", None)?; + u["login"] + .as_str() + .map(str::to_string) + .ok_or_else(|| Error::Other("response has no login".into())) + } + + fn list_repos(&self) -> Result> { + let mut out = Vec::new(); + for page in 1..=200 { + let v = self.http.ok( + "GET", + &format!("/user/repos?per_page=100&page={page}"), + None, + )?; + let items = v.as_array().cloned().unwrap_or_default(); + let n = items.len(); + out.extend(items.iter().map(repo)); + if n < 100 { + break; + } + } + Ok(out) + } + + fn create_repo(&self, new: &NewRepo) -> Result { + let path = match &new.owner { + Some(o) => format!("/orgs/{o}/repos"), + None => "/user/repos".to_string(), + }; + let body = + json!({"name": new.name, "private": new.private, "description": new.description}); + Ok(repo(&self.http.ok("POST", &path, Some(&body))?)) + } + + fn configure_mirror(&self, _: &str, _: &str, _: &MirrorSpec) -> Result<()> { + Err(Error::Unsupported( + "GitHub has no push mirrors; use a Gitea pull mirror or the daemon's branch push", + )) + } +} diff --git a/crates/grove-providers/src/http.rs b/crates/grove-providers/src/http.rs new file mode 100644 index 0000000..050f63d --- /dev/null +++ b/crates/grove-providers/src/http.rs @@ -0,0 +1,63 @@ +use crate::{Error, Result}; +use serde_json::Value; +use std::time::Duration; + +pub struct Http { + base: String, + auth: String, + agent: ureq::Agent, +} + +impl Http { + pub fn new(base: &str, auth: String) -> Self { + let agent: ureq::Agent = ureq::Agent::config_builder() + .http_status_as_error(false) + .timeout_global(Some(Duration::from_secs(30))) + .build() + .into(); + Http { + base: base.trim_end_matches('/').to_string(), + auth, + agent, + } + } + + /// Returns the status and the parsed JSON body (`Null` when empty or not JSON). + pub fn send(&self, method: &str, path: &str, body: Option<&Value>) -> Result<(u16, Value)> { + let url = format!("{}{}", self.base, path); + let net = |e: ureq::Error| Error::Network(e.to_string()); + let mut resp = match (method, body) { + ("GET", _) => self + .agent + .get(&url) + .header("Authorization", &self.auth) + .header("Accept", "application/json") + .call(), + ("POST", Some(b)) => self + .agent + .post(&url) + .header("Authorization", &self.auth) + .header("Accept", "application/json") + .send_json(b), + _ => return Err(Error::Other(format!("unsupported request {method}"))), + } + .map_err(net)?; + let status = resp.status().as_u16(); + let text = resp.body_mut().read_to_string().map_err(net)?; + let json = serde_json::from_str(&text).unwrap_or(Value::Null); + Ok((status, json)) + } + + /// Like [`send`], but maps non-2xx statuses to [`Error::Api`]. + pub fn ok(&self, method: &str, path: &str, body: Option<&Value>) -> Result { + let (status, json) = self.send(method, path, body)?; + if (200..300).contains(&status) { + return Ok(json); + } + let message = json["message"] + .as_str() + .unwrap_or("(no message)") + .to_string(); + Err(Error::Api { status, message }) + } +} diff --git a/crates/grove-providers/src/lib.rs b/crates/grove-providers/src/lib.rs new file mode 100644 index 0000000..0536e89 --- /dev/null +++ b/crates/grove-providers/src/lib.rs @@ -0,0 +1,108 @@ +//! Forge providers (Gitea/Forgejo, GitHub) and token storage. +//! +//! Providers only talk to the forge's REST API. Nothing here ever deletes a remote repository. + +mod gitea; +mod github; +mod http; +pub mod token; + +pub use gitea::Gitea; +pub use github::GitHub; + +use grove_core::config::{Provider as ProviderCfg, ProviderKind}; +use std::fmt; + +#[derive(Debug)] +pub enum Error { + /// Transport problem (DNS, TLS, timeout...). + Network(String), + /// The forge answered with an error status. + Api { + status: u16, + message: String, + }, + /// The forge cannot do what was asked (see [`Capabilities`]). + Unsupported(&'static str), + /// No token stored for the provider. + NoToken(String), + Other(String), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Error::Network(m) => write!(f, "network error: {m}"), + Error::Api { status, message } => write!(f, "forge returned {status}: {message}"), + Error::Unsupported(m) => write!(f, "not supported by this forge: {m}"), + Error::NoToken(id) => write!( + f, + "no token for provider {id:?} (run `grove login {id}` or set GROVE_TOKEN_*)" + ), + Error::Other(m) => f.write_str(m), + } + } +} + +impl std::error::Error for Error {} +pub type Result = std::result::Result; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RemoteRepo { + pub owner: String, + pub name: String, + pub private: bool, + pub clone_url: String, + pub default_branch: String, +} + +#[derive(Debug, Clone)] +pub struct NewRepo { + pub name: String, + /// Create under this organisation instead of the authenticated user. + pub owner: Option, + pub private: bool, + pub description: String, +} + +/// Push mirror from the primary forge to a secondary one. +#[derive(Debug, Clone)] +pub struct MirrorSpec { + pub remote_url: String, + pub remote_username: String, + pub remote_token: String, + /// Go-style duration (`8h0m0s`); `0` disables the periodic sync. + pub interval: String, + pub sync_on_commit: bool, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Capabilities { + /// The forge can push-mirror a repo to another forge by itself. + pub push_mirror: bool, + pub orgs: bool, +} + +pub trait Provider { + fn kind(&self) -> ProviderKind; + fn capabilities(&self) -> Capabilities; + /// Verifies the token and returns the authenticated login. + fn test_connection(&self) -> Result; + fn list_repos(&self) -> Result>; + fn create_repo(&self, new: &NewRepo) -> Result; + fn configure_mirror(&self, owner: &str, repo: &str, spec: &MirrorSpec) -> Result<()>; +} + +/// Builds the provider described by `cfg`, using `token`. +pub fn build(cfg: &ProviderCfg, token: String) -> Box { + match cfg.kind { + ProviderKind::Gitea | ProviderKind::Forgejo => Box::new(Gitea::new( + cfg.kind, + cfg.url.as_deref().unwrap_or_default(), + token, + )), + ProviderKind::Github => { + Box::new(GitHub::new(cfg.url.as_deref().unwrap_or_default(), token)) + } + } +} diff --git a/crates/grove-providers/src/token.rs b/crates/grove-providers/src/token.rs new file mode 100644 index 0000000..d60e04a --- /dev/null +++ b/crates/grove-providers/src/token.rs @@ -0,0 +1,47 @@ +//! Token storage: `GROVE_TOKEN_` env var first (headless machines, tests), then the +//! desktop Secret Service. Tokens are never written to the config file. + +use crate::{Error, Result}; + +const SERVICE: &str = "grove"; + +pub fn env_name(provider_id: &str) -> String { + let id: String = provider_id + .chars() + .map(|c| { + if c.is_ascii_alphanumeric() { + c.to_ascii_uppercase() + } else { + '_' + } + }) + .collect(); + format!("GROVE_TOKEN_{id}") +} + +pub fn get(provider_id: &str) -> Result { + if let Ok(t) = std::env::var(env_name(provider_id)) + && !t.trim().is_empty() + { + return Ok(t.trim().to_string()); + } + let e = keyring::Entry::new(SERVICE, provider_id).map_err(|e| Error::Other(e.to_string()))?; + match e.get_password() { + Ok(t) => Ok(t), + Err(keyring::Error::NoEntry) => Err(Error::NoToken(provider_id.into())), + Err(e) => Err(Error::Other(format!("secret service: {e}"))), + } +} + +pub fn set(provider_id: &str, token: &str) -> Result<()> { + keyring::Entry::new(SERVICE, provider_id) + .and_then(|e| e.set_password(token)) + .map_err(|e| Error::Other(format!("secret service: {e}"))) +} + +pub fn delete(provider_id: &str) -> Result<()> { + match keyring::Entry::new(SERVICE, provider_id).and_then(|e| e.delete_credential()) { + Ok(()) | Err(keyring::Error::NoEntry) => Ok(()), + Err(e) => Err(Error::Other(format!("secret service: {e}"))), + } +} diff --git a/crates/grove-providers/tests/api.rs b/crates/grove-providers/tests/api.rs new file mode 100644 index 0000000..675eaf6 --- /dev/null +++ b/crates/grove-providers/tests/api.rs @@ -0,0 +1,185 @@ +use grove_core::config::ProviderKind; +use grove_providers::{Error, GitHub, Gitea, MirrorSpec, NewRepo, Provider, token}; +use std::io::{Read, Write}; +use std::net::TcpListener; +use std::sync::mpsc; +use std::thread; + +/// Serves the scripted `(status, body)` replies in order, one connection each, and reports +/// every raw request it received. +fn mock(replies: Vec<(u16, &'static str)>) -> (String, mpsc::Receiver) { + let l = TcpListener::bind("127.0.0.1:0").unwrap(); + let url = format!("http://{}", l.local_addr().unwrap()); + let (tx, rx) = mpsc::channel(); + thread::spawn(move || { + for (status, body) in replies { + let (mut s, _) = l.accept().unwrap(); + let mut buf = Vec::new(); + let mut chunk = [0u8; 4096]; + loop { + let n = s.read(&mut chunk).unwrap(); + buf.extend_from_slice(&chunk[..n]); + let text = String::from_utf8_lossy(&buf).to_string(); + if let Some(h) = text.find("\r\n\r\n") { + let len = text[..h] + .lines() + .find_map(|l| { + l.to_ascii_lowercase() + .strip_prefix("content-length:") + .map(|v| v.trim().parse::().unwrap()) + }) + .unwrap_or(0); + if buf.len() >= h + 4 + len { + break; + } + } + if n == 0 { + break; + } + } + tx.send(String::from_utf8_lossy(&buf).to_string()).unwrap(); + let resp = format!( + "HTTP/1.1 {status} X\r\nContent-Type: application/json\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}", + body.len() + ); + s.write_all(resp.as_bytes()).unwrap(); + } + }); + (url, rx) +} + +fn body(req: &str) -> serde_json::Value { + serde_json::from_str(req.split("\r\n\r\n").nth(1).unwrap()).unwrap() +} + +#[test] +fn gitea_connection_list_create_and_mirror() { + let (url, rx) = mock(vec![ + (200, r#"{"login":"dasemu"}"#), + ( + 200, + r#"[{"name":"a","private":true,"clone_url":"u/a.git","default_branch":"main","owner":{"login":"dasemu"}}]"#, + ), + ( + 201, + r#"{"name":"n","private":true,"clone_url":"u/n.git","default_branch":"main","owner":{"login":"dasemu"}}"#, + ), + (200, "{}"), + ]); + let g = Gitea::new(ProviderKind::Gitea, &url, "secret".into()); + assert_eq!(g.test_connection().unwrap(), "dasemu"); + let first = rx.recv().unwrap(); + assert!(first.starts_with("GET /api/v1/user "), "{first}"); + assert!(first.to_lowercase().contains("authorization: token secret")); + + let repos = g.list_repos().unwrap(); + assert_eq!( + (repos.len(), repos[0].name.as_str(), repos[0].private), + (1, "a", true) + ); + + let r = g + .create_repo(&NewRepo { + name: "n".into(), + owner: None, + private: true, + description: "d".into(), + }) + .unwrap(); + assert_eq!(r.clone_url, "u/n.git"); + rx.recv().unwrap(); + let create = rx.recv().unwrap(); + assert!(create.starts_with("POST /api/v1/user/repos "), "{create}"); + assert_eq!(body(&create)["private"], true); + + g.configure_mirror( + "dasemu", + "n", + &MirrorSpec { + remote_url: "https://github.com/x/n.git".into(), + remote_username: "x".into(), + remote_token: "t".into(), + interval: "8h0m0s".into(), + sync_on_commit: true, + }, + ) + .unwrap(); + let m = rx.recv().unwrap(); + assert!( + m.starts_with("POST /api/v1/repos/dasemu/n/push_mirrors "), + "{m}" + ); + assert_eq!(body(&m)["sync_on_commit"], true); +} + +#[test] +fn gitea_org_create_uses_org_endpoint_and_api_errors_carry_status() { + let (url, rx) = mock(vec![ + (409, r#"{"message":"repository already exists"}"#), + (401, r#"{"message":"bad token"}"#), + ]); + let g = Gitea::new(ProviderKind::Forgejo, &url, "t".into()); + let e = g + .create_repo(&NewRepo { + name: "n".into(), + owner: Some("org".into()), + private: false, + description: String::new(), + }) + .unwrap_err(); + assert!(matches!(e, Error::Api { status: 409, .. }), "{e}"); + assert!( + rx.recv() + .unwrap() + .starts_with("POST /api/v1/orgs/org/repos ") + ); + assert!(matches!( + g.test_connection().unwrap_err(), + Error::Api { status: 401, .. } + )); +} + +#[test] +fn github_uses_bearer_and_has_no_push_mirror() { + let (url, rx) = mock(vec![(200, r#"{"login":"me"}"#)]); + let g = GitHub::new(&url, "tok".into()); + assert_eq!(g.test_connection().unwrap(), "me"); + assert!( + rx.recv() + .unwrap() + .to_lowercase() + .contains("authorization: bearer tok") + ); + assert!(!g.capabilities().push_mirror); + let e = g + .configure_mirror( + "o", + "r", + &MirrorSpec { + remote_url: String::new(), + remote_username: String::new(), + remote_token: String::new(), + interval: String::new(), + sync_on_commit: false, + }, + ) + .unwrap_err(); + assert!(matches!(e, Error::Unsupported(_))); +} + +#[test] +fn unreachable_forge_is_a_network_error() { + let g = Gitea::new(ProviderKind::Gitea, "http://127.0.0.1:1", "t".into()); + assert!(matches!( + g.test_connection().unwrap_err(), + Error::Network(_) + )); +} + +#[test] +fn env_var_overrides_the_keyring() { + assert_eq!(token::env_name("gitea-main"), "GROVE_TOKEN_GITEA_MAIN"); + // SAFETY: tests in this binary that touch this variable run in this single test. + unsafe { std::env::set_var("GROVE_TOKEN_ENV_TEST", " abc ") }; + assert_eq!(token::get("env-test").unwrap(), "abc"); +} diff --git a/crates/grove/Cargo.toml b/crates/grove/Cargo.toml index aa043ce..3307b78 100644 --- a/crates/grove/Cargo.toml +++ b/crates/grove/Cargo.toml @@ -5,8 +5,23 @@ edition.workspace = true version.workspace = true [dependencies] +age = "0.12.1" anyhow = "1.0.104" clap = { version = "4.6.7", features = ["derive"] } grove-core = { version = "0.1.0", path = "../grove-core" } grove-daemon = { version = "0.1.0", path = "../grove-daemon" } +grove-providers = { version = "0.1.0", path = "../grove-providers" } serde_json = "1.0.154" +toml = "1.2.1" + +# `cargo build --release --workspace && cargo deb -p grove --no-build` packages CLI + daemon + user unit. +[package.metadata.deb] +name = "grove" +section = "devel" +depends = "$auto, git" +extended-description = "Keeps chosen git repos continuously in sync across machines, including uncommitted work." +assets = [ + ["../../target/release/grove", "usr/bin/", "755"], + ["../../target/release/groved", "usr/bin/", "755"], + ["../../contrib/groved.deb.service", "usr/lib/systemd/user/groved.service", "644"], +] diff --git a/crates/grove/src/main.rs b/crates/grove/src/main.rs index ca5e2f8..8e38405 100644 --- a/crates/grove/src/main.rs +++ b/crates/grove/src/main.rs @@ -1,15 +1,20 @@ use anyhow::{Context, Result, bail}; use clap::{Parser, Subcommand}; -use grove_core::config::Config; +use grove_core::config::{Config, ProviderKind}; use grove_core::git::Git; use grove_core::inspect::{state, worktrees}; use grove_core::migrate::migrate; use grove_core::receive::{Applied, Archived, Received}; +use grove_core::resolve::{Choice, resolve}; use grove_core::snapshot::{Outcome, take}; +use grove_core::state::State; use grove_core::sync::{Options, SyncReport, git_dir_for, sync_repo}; use std::path::{Path, PathBuf}; use std::time::{SystemTime, UNIX_EPOCH}; +mod secrets; +mod workflow; + #[derive(Parser)] #[command(name = "grove", about = "Keep git workspaces in sync across machines")] struct Cli { @@ -26,6 +31,26 @@ enum Cmd { Status { #[arg(default_value = ".")] path: PathBuf, + /// Also say what the next sync pass would do (no network, nothing changed) + #[arg(long)] + plan: bool, + }, + /// Resolve a diverged worktree (an explicit choice; backups are always written) + Resolve { + /// The worktree directory + path: PathBuf, + /// Discard local commits, move to the remote tip + #[arg(long, group = "how")] + take_remote: bool, + /// Overwrite the remote branch with the local one + #[arg(long, group = "how")] + keep_local: bool, + /// Keep local commits on a new branch (own worktree), then take the remote tip + #[arg(long, value_name = "BRANCH", group = "how")] + save_as: Option, + /// Open both sides in your difftool and change nothing + #[arg(long, group = "how")] + compare: bool, }, /// Take a snapshot of the worktree at PATH into refs/sync// Snapshot { @@ -49,6 +74,47 @@ enum Cmd { }, /// Check the local setup Doctor, + /// Write a first config file for this machine + Init { + #[arg(long)] + machine: Option, + #[arg(long, default_value = "~/Workspace")] + root: String, + /// Provider id (name used in the config and for the token) + #[arg(long, default_value = "main")] + provider: String, + #[arg(long, default_value = "gitea")] + kind: String, + #[arg(long)] + url: Option, + #[arg(long, default_value = "default")] + group: String, + /// Name of the private config repo to keep the repo registry in + #[arg(long)] + config_repo: Option, + #[arg(long)] + force: bool, + }, + /// Store the API token for a provider (read from stdin, never from argv) + Login { provider: String }, + /// Create a repo on the group's primary forge and set it up locally + New { + group: String, + name: String, + #[arg(long)] + public: bool, + }, + /// List (or, with names, clone) remote repos that are not on this machine + Import { group: String, names: Vec }, + /// Create the config repo and register every repo already on disk + ConfigRepoInit, + /// Fresh machine: clone every repo listed in the config repo + Bootstrap, + /// Encrypted sync of files git must not hold (.env, ...), via the config repo + Secrets { + #[command(subcommand)] + action: SecretsCmd, + }, /// Talk to the running daemon (`groved`) Daemon { #[command(subcommand)] @@ -56,6 +122,18 @@ enum Cmd { }, } +#[derive(Subcommand)] +enum SecretsCmd { + /// Create this machine's age key and publish the public half + Init, + /// Encrypt FILE (inside a workspace worktree) to every machine key and store it + Push { file: PathBuf }, + /// Decrypt stored files into the worktrees that lack them (never overwrites) + Pull, + /// Re-encrypt everything to the current set of machine keys + Rekey, +} + #[derive(Subcommand)] enum DaemonCmd { /// Show every managed repo and its state @@ -169,11 +247,47 @@ fn main() -> Result<()> { let cli = Cli::parse(); match &cli.cmd { Cmd::Daemon { action } => daemon(action), - Cmd::Status { path } => status(path), + Cmd::Status { path, plan } => status(path, *plan), + Cmd::Resolve { + path, + take_remote, + keep_local, + save_as, + compare, + } => { + let cfg = load_config(&cli.config)?; + let choice = match (take_remote, keep_local, save_as, compare) { + (true, ..) => Choice::TakeRemote, + (_, true, ..) => Choice::KeepLocal, + (_, _, Some(b), _) => Choice::SaveAsBranch(b.clone()), + (.., true) => { + let ok = std::process::Command::new("git") + .current_dir(path) + .args(["difftool", "-d", "HEAD", "@{upstream}"]) + .status()? + .success(); + if !ok { + bail!("git difftool failed (is a difftool configured?)"); + } + return Ok(()); + } + _ => bail!( + "choose one of --take-remote, --keep-local, --save-as , --compare" + ), + }; + println!("{}", resolve(path, &cfg.machine.name, &stamp(), &choice)?); + Ok(()) + } Cmd::Snapshot { path } => { let cfg = load_config(&cli.config)?; + grove_core::snapshot::set_max_file_bytes(cfg.sync.max_file_mb * 1024 * 1024); match take(path, &cfg.machine.name, &stamp())? { - Outcome::Created(s) => println!("created {} {}", s.refname, s.commit), + Outcome::Created(s) => { + println!("created {} {}", s.refname, s.commit); + for f in &s.skipped { + println!("left out (over the size limit): {f}"); + } + } Outcome::Unchanged(c) => println!("unchanged {c}"), } Ok(()) @@ -196,6 +310,7 @@ fn main() -> Result<()> { } Cmd::Sync { path, offline } => { let cfg = load_config(&cli.config)?; + grove_core::snapshot::set_max_file_bytes(cfg.sync.max_file_mb * 1024 * 1024); let rep = sync_repo( path, &Options { @@ -209,18 +324,115 @@ fn main() -> Result<()> { print_report(&rep) } Cmd::Doctor => doctor(&cli.config), + Cmd::Init { + machine, + root, + provider, + kind, + url, + group, + config_repo, + force, + } => { + let path = cli + .config + .clone() + .or_else(Config::default_path) + .context("cannot determine config path (set --config)")?; + let kind = match kind.as_str() { + "gitea" => ProviderKind::Gitea, + "forgejo" => ProviderKind::Forgejo, + "github" => ProviderKind::Github, + k => bail!("unknown provider kind {k:?} (gitea, forgejo, github)"), + }; + let machine = machine + .clone() + .or_else(|| { + std::fs::read_to_string("/etc/hostname") + .ok() + .map(|h| h.trim().to_string()) + }) + .context("cannot determine the machine name (set --machine)")?; + workflow::init( + &path, + workflow::InitArgs { + machine, + root: root.clone(), + provider: provider.clone(), + kind, + url: url.clone(), + group: group.clone(), + config_repo: config_repo.clone(), + }, + *force, + )?; + println!("wrote {}", path.display()); + println!("next: `grove login {provider}` to store the API token"); + Ok(()) + } + Cmd::Login { provider } => { + let cfg = load_config(&cli.config)?; + let mut tok = String::new(); + std::io::stdin().read_line(&mut tok)?; + let who = workflow::login(&cfg, provider, tok.trim())?; + println!("logged in to {provider} as {who}; token stored in the Secret Service"); + Ok(()) + } + Cmd::New { + group, + name, + public, + } => { + let wt = workflow::new_repo(&load_config(&cli.config)?, group, name, !public)?; + println!("ready: {}", wt.display()); + Ok(()) + } + Cmd::Import { group, names } => workflow::import(&load_config(&cli.config)?, group, names), + Cmd::ConfigRepoInit => { + let n = workflow::config_repo_init(&load_config(&cli.config)?)?; + println!("config repo up to date ({n} repos registered)"); + Ok(()) + } + Cmd::Secrets { action } => { + let cfg = load_config(&cli.config)?; + match action { + SecretsCmd::Init => secrets::init(&cfg), + SecretsCmd::Push { file } => secrets::push(&cfg, file), + SecretsCmd::Pull => secrets::pull(&cfg), + SecretsCmd::Rekey => secrets::rekey(&cfg), + } + } + Cmd::Bootstrap => { + let (done, skipped) = workflow::bootstrap(&load_config(&cli.config)?)?; + println!("bootstrap finished: {done} cloned, {skipped} already present"); + Ok(()) + } } } -fn status(path: &Path) -> Result<()> { +fn plan_for(s: &State) -> &'static str { + match s { + State::Synced => "nothing to do", + State::Dirty => "snapshot the working changes and push the snapshot ref", + State::Ahead => "nothing automatic: push your commits yourself", + State::Behind => "fast-forward to the remote tip", + State::BehindDirty => { + "keep your edits; adopt the remote tip only if the content is identical" + } + State::Diverged => "nothing automatic: run `grove resolve` to choose", + State::Error(_) => "retry; see the error", + } +} + +fn status(path: &Path, plan: bool) -> Result<()> { for wt in worktrees(&git_dir_for(path))? { let branch = wt.branch.as_deref().unwrap_or("(detached)"); - println!( - "{:<24} {:?} {}", - branch, - state(&wt.path), - wt.path.display() - ); + let st = state(&wt.path); + print!("{:<24} {:?} {}", branch, st, wt.path.display()); + if plan { + print!("\n next: {}", plan_for(&st)); + } + println!(); } Ok(()) } @@ -250,6 +462,9 @@ fn print_report(rep: &SyncReport) -> Result<()> { if let Some(s) = w.snapshot { notes.push(format!("snapshot {s}")); } + if !w.skipped.is_empty() { + notes.push(format!("left out (too large): {}", w.skipped.join(", "))); + } match &w.received { Some(Received::FastForwarded { .. }) => notes.push("fast-forwarded".into()), Some(Received::Declined(why)) => notes.push(format!("not fast-forwarded: {why}")), diff --git a/crates/grove/src/secrets.rs b/crates/grove/src/secrets.rs new file mode 100644 index 0000000..4bb1633 --- /dev/null +++ b/crates/grove/src/secrets.rs @@ -0,0 +1,239 @@ +//! Encrypted channel for files git must never hold in clear (`.env` and similar). +//! +//! Each machine has an age identity in its state dir; the public keys live in the config repo +//! (`machines/.age.pub`). A pushed file is encrypted to every machine's key and stored as +//! `secrets///.age` in the config repo. Decrypted copies are only ever written +//! to worktrees, mode 0600, and never overwrite a file whose content differs. + +use crate::workflow::{commit_and_push, config_repo_open}; +use age::secrecy::ExposeSecret; +use age::x25519::{Identity, Recipient}; +use anyhow::{Context, Result, bail}; +use grove_core::config::Config; +use std::fs; +use std::io::Write; +use std::os::unix::fs::PermissionsExt; +use std::path::{Path, PathBuf}; + +fn identity_path() -> Result { + Ok(Config::state_dir() + .context("cannot determine state dir")? + .join("age-identity.txt")) +} + +fn load_identity() -> Result { + let p = identity_path()?; + let text = fs::read_to_string(&p) + .with_context(|| format!("no identity at {} (run `grove secrets init`)", p.display()))?; + text.trim() + .parse::() + .map_err(|e| anyhow::anyhow!("bad identity file: {e}")) +} + +pub fn encrypt(recipients: &[Recipient], data: &[u8]) -> Result> { + if recipients.is_empty() { + bail!("no recipients: run `grove secrets init` on each machine first"); + } + let enc = age::Encryptor::with_recipients(recipients.iter().map(|r| r as &dyn age::Recipient)) + .map_err(|e| anyhow::anyhow!("{e}"))?; + let mut out = Vec::new(); + let mut w = enc.wrap_output(&mut out)?; + w.write_all(data)?; + w.finish()?; + Ok(out) +} + +pub fn decrypt(id: &Identity, blob: &[u8]) -> Result> { + age::decrypt(id, blob) + .map_err(|e| anyhow::anyhow!("cannot decrypt (not encrypted to this machine?): {e}")) +} + +fn recipients(dir: &Path) -> Result> { + let mut out = Vec::new(); + let Ok(rd) = fs::read_dir(dir.join("machines")) else { + return Ok(out); + }; + for e in rd.filter_map(Result::ok) { + if e.file_name().to_string_lossy().ends_with(".age.pub") { + let t = fs::read_to_string(e.path())?; + out.push( + t.trim() + .parse::() + .map_err(|e| anyhow::anyhow!("bad key: {e}"))?, + ); + } + } + Ok(out) +} + +pub fn init(cfg: &Config) -> Result<()> { + let p = identity_path()?; + if !p.exists() { + fs::create_dir_all(p.parent().unwrap())?; + let id = Identity::generate(); + fs::write(&p, format!("{}\n", id.to_string().expose_secret()))?; + fs::set_permissions(&p, fs::Permissions::from_mode(0o600))?; + println!("generated identity {}", p.display()); + } + let id = load_identity()?; + let (dir, forge) = config_repo_open(cfg, true)?; + fs::create_dir_all(dir.join("machines"))?; + fs::write( + dir.join("machines") + .join(format!("{}.age.pub", cfg.machine.name)), + format!("{}\n", id.to_public()), + )?; + commit_and_push(cfg, &dir, &forge, "publish age key")?; + println!("public key published for machine {}", cfg.machine.name); + println!( + "note: files pushed earlier are not readable here until another machine runs `grove secrets rekey`" + ); + Ok(()) +} + +/// `////` -> (group, repo, worktree dir name, rel path). +fn locate(cfg: &Config, file: &Path) -> Result<(String, String, PathBuf, String)> { + let file = fs::canonicalize(file).with_context(|| format!("{} not found", file.display()))?; + let root = fs::canonicalize(cfg.root_path())?; + let rel = file + .strip_prefix(&root) + .context("file is not under the workspace root")?; + let parts: Vec<_> = rel + .components() + .map(|c| c.as_os_str().to_string_lossy().into_owned()) + .collect(); + if parts.len() < 4 { + bail!("expected ////"); + } + Ok(( + parts[0].clone(), + parts[1].clone(), + root.join(&parts[0]).join(&parts[1]), + parts[3..].join("/"), + )) +} + +fn blob_path(dir: &Path, group: &str, repo: &str, rel: &str) -> PathBuf { + dir.join("secrets") + .join(group) + .join(repo) + .join(format!("{}.age", rel.replace('/', "%2F"))) +} + +pub fn push(cfg: &Config, file: &Path) -> Result<()> { + let (group, repo, _, rel) = locate(cfg, file)?; + let (dir, forge) = config_repo_open(cfg, false)?; + let blob = encrypt(&recipients(&dir)?, &fs::read(file)?)?; + let dest = blob_path(&dir, &group, &repo, &rel); + fs::create_dir_all(dest.parent().unwrap())?; + fs::write(&dest, blob)?; + commit_and_push(cfg, &dir, &forge, &format!("secret {group}/{repo}/{rel}"))?; + println!("encrypted and stored {group}/{repo}/{rel}"); + Ok(()) +} + +pub fn pull(cfg: &Config) -> Result<()> { + let id = load_identity()?; + let (dir, _) = config_repo_open(cfg, false)?; + let sroot = dir.join("secrets"); + let (mut wrote, mut same, mut conflict) = (0, 0, 0); + for g in fs::read_dir(&sroot) + .into_iter() + .flatten() + .filter_map(Result::ok) + { + for r in fs::read_dir(g.path())?.filter_map(Result::ok) { + let repo_dir = cfg.root_path().join(g.file_name()).join(r.file_name()); + for b in fs::read_dir(r.path())?.filter_map(Result::ok) { + let name = b.file_name().to_string_lossy().into_owned(); + let Some(rel) = name.strip_suffix(".age").map(|n| n.replace("%2F", "/")) else { + continue; + }; + let plain = match decrypt(&id, &fs::read(b.path())?) { + Ok(p) => p, + Err(e) => { + println!("skip {}/{}: {e}", g.file_name().to_string_lossy(), rel); + continue; + } + }; + for wt in fs::read_dir(&repo_dir) + .into_iter() + .flatten() + .filter_map(Result::ok) + { + if !wt.path().join(".git").exists() { + continue; + } + let target = wt.path().join(&rel); + match fs::read(&target) { + Ok(cur) if cur == plain => same += 1, + Ok(_) => { + conflict += 1; + println!( + "kept local {} (differs from the stored copy)", + target.display() + ); + } + Err(_) => { + fs::create_dir_all(target.parent().unwrap())?; + fs::write(&target, &plain)?; + fs::set_permissions(&target, fs::Permissions::from_mode(0o600))?; + wrote += 1; + println!("wrote {}", target.display()); + } + } + } + } + } + } + println!("{wrote} written, {same} already identical, {conflict} kept (differ)"); + Ok(()) +} + +/// Re-encrypts every stored secret to the current set of machine keys. +pub fn rekey(cfg: &Config) -> Result<()> { + let id = load_identity()?; + let (dir, forge) = config_repo_open(cfg, false)?; + let rec = recipients(&dir)?; + let mut n = 0; + let mut stack = vec![dir.join("secrets")]; + while let Some(d) = stack.pop() { + for e in fs::read_dir(&d) + .into_iter() + .flatten() + .filter_map(Result::ok) + { + let p = e.path(); + if p.is_dir() { + stack.push(p); + } else if p.extension().is_some_and(|x| x == "age") { + let plain = decrypt(&id, &fs::read(&p)?)?; + fs::write(&p, encrypt(&rec, &plain)?)?; + n += 1; + } + } + } + commit_and_push(cfg, &dir, &forge, "rekey secrets")?; + println!("re-encrypted {n} file(s) to {} machine key(s)", rec.len()); + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn every_recipient_can_decrypt_and_strangers_cannot() { + let (a, b, c) = ( + Identity::generate(), + Identity::generate(), + Identity::generate(), + ); + let blob = encrypt(&[a.to_public(), b.to_public()], b"TOKEN=1\n").unwrap(); + assert!(!String::from_utf8_lossy(&blob).contains("TOKEN")); + assert_eq!(decrypt(&a, &blob).unwrap(), b"TOKEN=1\n"); + assert_eq!(decrypt(&b, &blob).unwrap(), b"TOKEN=1\n"); + assert!(decrypt(&c, &blob).is_err()); + assert!(encrypt(&[], b"x").is_err()); + } +} diff --git a/crates/grove/src/workflow.rs b/crates/grove/src/workflow.rs new file mode 100644 index 0000000..9497dc0 --- /dev/null +++ b/crates/grove/src/workflow.rs @@ -0,0 +1,389 @@ +//! Onboarding, new-repo, import and bootstrap flows (Phase 4). + +use anyhow::{Context, Result, bail}; +use grove_core::config::{ + Config, Group, Layout, Machine, Provider as ProviderCfg, ProviderKind, Root, +}; +use grove_core::git::Git; +use grove_core::registry::{Entry, Registry, clone_bare_layout, init_bare_layout, push_initial}; +use grove_providers::{MirrorSpec, NewRepo, Provider, build, token}; +use std::fs; +use std::path::{Path, PathBuf}; + +pub struct Forge { + pub api: Box, + pub login: String, + /// Git environment that authenticates HTTPS operations with the stored token. + pub git_env: Vec<(String, String)>, +} + +pub fn connect(cfg: &Config, id: &str) -> Result { + let pc = cfg + .providers + .get(id) + .with_context(|| format!("provider {id:?} is not in the config"))?; + let tok = token::get(id)?; + let api = build(pc, tok.clone()); + let login = api.test_connection()?; + let git_env = match pc.kind { + ProviderKind::Gitea | ProviderKind::Forgejo => vec![ + ("GIT_CONFIG_COUNT".into(), "1".into()), + ("GIT_CONFIG_KEY_0".into(), "http.extraHeader".into()), + ( + "GIT_CONFIG_VALUE_0".into(), + format!("Authorization: token {tok}"), + ), + ("GIT_TERMINAL_PROMPT".into(), "0".into()), + ], + // GitHub git-over-HTTPS needs Basic auth; leave it to the user's credential helper. + ProviderKind::Github => vec![("GIT_TERMINAL_PROMPT".into(), "0".into())], + }; + Ok(Forge { + api, + login, + git_env, + }) +} + +fn group<'a>(cfg: &'a Config, name: &str) -> Result<&'a Group> { + cfg.groups + .iter() + .find(|g| g.name == name) + .with_context(|| format!("group {name:?} is not in the config")) +} + +fn with_env(g: Git, envs: &[(String, String)]) -> Git { + envs.iter().fold(g, |g, (k, v)| g.with_env(k, v)) +} + +pub struct InitArgs { + pub machine: String, + pub root: String, + pub provider: String, + pub kind: ProviderKind, + pub url: Option, + pub group: String, + pub config_repo: Option, +} + +pub fn init(path: &Path, a: InitArgs, force: bool) -> Result { + if path.exists() && !force { + bail!( + "{} already exists (use --force to overwrite)", + path.display() + ); + } + let mut providers = std::collections::BTreeMap::new(); + providers.insert( + a.provider.clone(), + ProviderCfg { + kind: a.kind, + url: a.url, + }, + ); + let cfg = Config { + machine: Machine { name: a.machine }, + root: Root { path: a.root }, + providers, + groups: vec![Group { + name: a.group, + primary: a.provider.clone(), + mirror_to: vec![], + layout: Layout::BareWorktrees, + auto_materialize: true, + }], + sync: Default::default(), + config_repo: a.config_repo.map(|name| grove_core::config::ConfigRepo { + provider: a.provider, + name, + }), + }; + // Validate by round-tripping through the parser before writing anything. + let text = toml::to_string_pretty(&cfg)?; + Config::parse(&text)?; + cfg.save(path)?; + Ok(cfg) +} + +pub fn login(cfg: &Config, id: &str, tok: &str) -> Result { + let pc = cfg + .providers + .get(id) + .with_context(|| format!("provider {id:?} is not in the config"))?; + let who = build(pc, tok.to_string()).test_connection()?; + // Keep the secret out of the store when the env override is in use. + token::set(id, tok)?; + Ok(who) +} + +/// Creates the remote repo, the local bare layout, the mirrors and the registry entry. +pub fn new_repo(cfg: &Config, group_name: &str, name: &str, private: bool) -> Result { + let grp = group(cfg, group_name)?; + let dir = cfg.root_path().join(&grp.name).join(name); + if dir.exists() { + bail!("{} already exists", dir.display()); + } + let primary = connect(cfg, &grp.primary)?; + let remote = primary.api.create_repo(&NewRepo { + name: name.into(), + owner: None, + private, + description: String::new(), + })?; + println!( + "created {}/{} on {}", + remote.owner, remote.name, grp.primary + ); + let wt = init_bare_layout(&dir, &remote.clone_url)?; + push_initial(&dir, &primary.git_env)?; + println!("pushed initial commit; worktree {}", wt.display()); + + for mid in &grp.mirror_to { + match configure_mirror(cfg, &primary, mid, &remote.owner, name, private) { + Ok(()) => println!("push mirror to {mid} configured"), + Err(e) => println!("warning: mirror to {mid} not configured: {e}"), + } + } + register( + cfg, + &Entry { + group: grp.name.clone(), + name: name.into(), + url: remote.clone_url, + }, + )?; + Ok(wt) +} + +fn configure_mirror( + cfg: &Config, + primary: &Forge, + mirror_id: &str, + owner: &str, + name: &str, + private: bool, +) -> Result<()> { + let m = connect(cfg, mirror_id)?; + let target = m.api.create_repo(&NewRepo { + name: name.into(), + owner: None, + private, + description: "Mirror managed by grove".into(), + })?; + primary.api.configure_mirror( + owner, + name, + &MirrorSpec { + remote_url: target.clone_url, + remote_username: m.login, + remote_token: token::get(mirror_id)?, + interval: "8h0m0s".into(), + sync_on_commit: true, + }, + )?; + Ok(()) +} + +/// Lists remote repos of the group's primary that are not on disk; clones the named ones. +pub fn import(cfg: &Config, group_name: &str, wanted: &[String]) -> Result<()> { + let grp = group(cfg, group_name)?; + let primary = connect(cfg, &grp.primary)?; + let gdir = cfg.root_path().join(&grp.name); + let missing: Vec<_> = primary + .api + .list_repos()? + .into_iter() + .filter(|r| !gdir.join(&r.name).join(".bare").exists()) + .collect(); + if wanted.is_empty() { + println!("repos on {} not yet in {}:", grp.primary, gdir.display()); + for r in &missing { + println!( + " {}/{}{}", + r.owner, + r.name, + if r.private { " (private)" } else { "" } + ); + } + println!("run `grove import {group_name} ...` to clone them"); + return Ok(()); + } + for w in wanted { + let r = missing + .iter() + .find(|r| &r.name == w) + .with_context(|| format!("{w:?} is not a remote repo missing locally"))?; + let dir = gdir.join(&r.name); + clone_bare_layout(&r.clone_url, &dir, &primary.git_env)?; + println!("imported {} -> {}", r.name, dir.display()); + register( + cfg, + &Entry { + group: grp.name.clone(), + name: r.name.clone(), + url: r.clone_url.clone(), + }, + )?; + } + Ok(()) +} + +// ---- config repo ------------------------------------------------------------------------- + +fn config_repo_dir() -> Result { + Ok(Config::state_dir() + .context("cannot determine state dir")? + .join("config-repo")) +} + +/// Makes sure the local clone of the config repo exists and is current. Returns its path. +pub(crate) fn config_repo_open(cfg: &Config, create: bool) -> Result<(PathBuf, Forge)> { + let cr = cfg + .config_repo + .as_ref() + .context("no [config_repo] in the config")?; + let forge = connect(cfg, &cr.provider)?; + let dir = config_repo_dir()?; + if !dir.join(".git").exists() { + let exists = forge + .api + .list_repos()? + .into_iter() + .find(|r| r.name == cr.name); + let url = match exists { + Some(r) => r.clone_url, + None if create => { + let r = forge.api.create_repo(&NewRepo { + name: cr.name.clone(), + owner: None, + private: true, + description: "grove configuration (managed repos, machines)".into(), + })?; + r.clone_url + } + None => bail!( + "config repo {:?} does not exist on {}", + cr.name, + cr.provider + ), + }; + fs::create_dir_all(dir.parent().unwrap())?; + let g = with_env(Git::new(dir.parent().unwrap()), &forge.git_env); + g.run(&["clone", "-q", &url, &dir.to_string_lossy()])?; + } else { + // An empty remote has nothing to pull yet. + let _ = with_env(Git::new(&dir), &forge.git_env).run(&["pull", "-q", "--ff-only"]); + } + Ok((dir, forge)) +} + +fn read_registry(dir: &Path) -> Result { + match fs::read_to_string(dir.join("repos.toml")) { + Ok(t) => Registry::parse(&t).map_err(anyhow::Error::msg), + Err(_) => Ok(Registry::default()), + } +} + +pub(crate) fn commit_and_push(cfg: &Config, dir: &Path, forge: &Forge, msg: &str) -> Result<()> { + let g = Git::new(dir) + .with_env("GIT_AUTHOR_NAME", "grove") + .with_env("GIT_AUTHOR_EMAIL", "grove@localhost") + .with_env("GIT_COMMITTER_NAME", "grove") + .with_env("GIT_COMMITTER_EMAIL", "grove@localhost"); + g.run(&["add", "-A"])?; + if g.run(&["status", "--porcelain"])?.is_empty() { + return Ok(()); + } + let machine = &cfg.machine.name; + g.run(&["commit", "-q", "-m", &format!("{msg} (from {machine})")])?; + let branch = g.run(&["rev-parse", "--abbrev-ref", "HEAD"])?; + with_env(g, &forge.git_env).run(&["push", "-q", "-u", "origin", &branch])?; + Ok(()) +} + +fn write_heartbeat(cfg: &Config, dir: &Path) -> Result<()> { + let m = dir.join("machines"); + fs::create_dir_all(&m)?; + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map_or(0, |d| d.as_secs()); + let body = serde_json::json!({"machine": cfg.machine.name, "last_registered": now}); + fs::write( + m.join(format!("{}.json", cfg.machine.name)), + serde_json::to_string_pretty(&body)?, + )?; + Ok(()) +} + +/// Adds a repo to the config repo, if one is configured (silently skipped otherwise). +pub fn register(cfg: &Config, e: &Entry) -> Result<()> { + if cfg.config_repo.is_none() { + return Ok(()); + } + let (dir, forge) = config_repo_open(cfg, true)?; + let mut reg = read_registry(&dir)?; + reg.upsert(e.clone()); + fs::write(dir.join("repos.toml"), reg.to_text())?; + write_heartbeat(cfg, &dir)?; + commit_and_push( + cfg, + &dir, + &forge, + &format!("register {}/{}", e.group, e.name), + ) +} + +/// First machine: creates the config repo (if needed) and registers every repo already on disk. +pub fn config_repo_init(cfg: &Config) -> Result { + let (dir, forge) = config_repo_open(cfg, true)?; + let mut reg = read_registry(&dir)?; + for grp in &cfg.groups { + let gdir = cfg.root_path().join(&grp.name); + let Ok(rd) = fs::read_dir(&gdir) else { + continue; + }; + for e in rd.filter_map(Result::ok) { + let bare = e.path().join(".bare"); + if !bare.is_dir() { + continue; + } + let Some(url) = Git::new(&bare).probe(&["config", "--get", "remote.origin.url"])? + else { + continue; + }; + reg.upsert(Entry { + group: grp.name.clone(), + name: e.file_name().to_string_lossy().into_owned(), + url, + }); + } + } + fs::write(dir.join("repos.toml"), reg.to_text())?; + write_heartbeat(cfg, &dir)?; + commit_and_push(cfg, &dir, &forge, "update registry")?; + Ok(reg.repos.len()) +} + +/// Fresh machine: materializes every repo of the config repo under the root. +pub fn bootstrap(cfg: &Config) -> Result<(usize, usize)> { + let (dir, forge) = config_repo_open(cfg, false)?; + let reg = read_registry(&dir)?; + let (mut done, mut skipped) = (0, 0); + for e in ®.repos { + let target = cfg.root_path().join(&e.group).join(&e.name); + if target.join(".bare").exists() { + skipped += 1; + continue; + } + match clone_bare_layout(&e.url, &target, &forge.git_env) { + Ok(_) => { + println!("cloned {}/{}", e.group, e.name); + done += 1; + } + Err(err) => println!("FAILED {}/{}: {err}", e.group, e.name), + } + } + write_heartbeat(cfg, &dir)?; + commit_and_push(cfg, &dir, &forge, "machine heartbeat")?; + Ok((done, skipped)) +} diff --git a/docs/phase1.md b/docs/phase1.md index 2f7865e..38d3a7a 100644 --- a/docs/phase1.md +++ b/docs/phase1.md @@ -82,3 +82,9 @@ exclusion of `refs/sync/*` on this Gitea (needs a mirror target and credentials) Observed UX noise: a stale snapshot from another machine is reported as "not applied" on every pass until that machine syncs again. + +## Bug found later (Phase 5 tests) + +`clone_bare_layout` created worktrees without upstream tracking, so `Diverged` and `Behind` were +reported as `Synced` on repos cloned by grove itself. Fixed: every local branch with an `origin/
` +counterpart gets `--set-upstream-to` before worktrees are materialized (asserted in `tests/registry.rs`). diff --git a/docs/phase3.md b/docs/phase3.md new file mode 100644 index 0000000..6f66e75 --- /dev/null +++ b/docs/phase3.md @@ -0,0 +1,55 @@ +# Phase 3: GUI + +## Layout + +| Part | Where | Status | +|---|---|---| +| Frontend (plain HTML/CSS/JS, no build step) | `gui/ui/` | Implemented, exercised in a browser against a live daemon | +| Dev bridge (`grove-bridge`, std-only HTTP server on 127.0.0.1) | `crates/grove-bridge/` | Implemented, unit-tested, exercised end to end | +| Tauri v2 shell with tray | `gui/src-tauri/` | **Written but never compiled** (see below) | + +The frontend talks to a backend through one adapter in `gui/ui/app.js`: `window.__TAURI__` commands +(`ipc`, `cli`, `config`) when running inside Tauri, otherwise `fetch('/api/...')` against the bridge. +The GUI contains no sync logic: state comes from the daemon over its Unix socket, and every action +(new, import, resolve, login, secrets, bootstrap) shells out to the allow-listed `grove` subcommands. + +## Screens + +Repositories (aggregate pill: all synced / syncing / paused / needs attention / daemon offline), +repository detail (per-worktree state and what the next pass will do, resolve panel for `Diverged`), +Activity (live log, filter), New repository, Import, Settings (config, token login, config repo, +secrets), and onboarding when no config exists. Toasts (and browser notifications when permitted) +fire on a transition into `Diverged` or `Error`. + +Resolve actions (save as branch / take remote / keep mine) always ask for confirmation and write a +backup ref first. Comparing both sides stays in the CLI (`grove resolve --compare`). + +## Dev bridge safety + +Binds 127.0.0.1 only, rejects non-local `Host` headers (DNS rebinding) and POSTs without +`X-Grove: 1` (cross-site forms cannot set it). Only these subcommands are forwarded: `init login new +import config-repo-init bootstrap resolve secrets sync status`. Verified: a POST without the header gets 403. + +```bash +cargo run -p grove-bridge -- --ui gui/ui # then open http://127.0.0.1:4780 +``` + +## Tauri shell: not verified + +Needs system packages that were missing on the dev machine and no root was available: + +```bash +sudo dnf install webkit2gtk4.1-devel libsoup3-devel librsvg2-devel # Fedora +cd gui/src-tauri && cargo install tauri-cli --locked && cargo tauri dev +``` + +The shell is ~80 lines: three commands reusing `grove-bridge`, a tray (open / pause-resume / quit), +and close-to-tray. The CSP allows only `self`; the capability file grants `core:default` only. +Expect small compile fixes on the first build. It is intentionally outside the workspace so that +`cargo test` works without webkit installed. + +## Not done + +- Screenshots/visual QA inside the real Tauri window. +- Side-by-side compare view for `Diverged` (CLI only). +- Native notifications from the Tauri side (the web Notification API is used). diff --git a/docs/phase4.md b/docs/phase4.md new file mode 100644 index 0000000..114c123 --- /dev/null +++ b/docs/phase4.md @@ -0,0 +1,52 @@ +# Phase 4: providers and wizards + +Crate `grove-providers`: `Provider` trait with Gitea/Forgejo (`/api/v1`) and GitHub clients over +`ureq`, plus token storage. The CLI (`crates/grove/src/workflow.rs`) composes them. + +## Tokens + +`GROVE_TOKEN_` (id upper-cased, non-alphanumerics to `_`) wins; otherwise the desktop Secret +Service via `keyring` (service `grove`, user = provider id). Tokens are never written to the config +file. `grove login ` reads the token from stdin (never argv), checks it against the forge and +stores it. HTTPS git operations of the wizards authenticate through `http.extraHeader` set in the +process environment only (Gitea/Forgejo); for GitHub they use the user's credential helper. + +## Commands + +| Command | What it does | +|---|---| +| `grove init` | Writes a first `config.toml` (machine, root, one provider, one group, optional config repo) | +| `grove login ` | Stores the API token after verifying it | +| `grove new [--public]` | Creates the repo on the group's primary forge, the local bare+worktree layout, an initial commit, pushes, configures push mirrors, registers it in the config repo | +| `grove import [names...]` | Lists remote repos not on this machine; with names, clones them into the layout | +| `grove config-repo-init` | Creates the private config repo and registers every repo already on disk | +| `grove bootstrap` | Fresh machine: clones every repo in the config repo under the root | + +## Config repo + +A private repo (name from `[config_repo]`) holding `repos.toml` (`group`, `name`, `url` per repo) and +`machines/.json` (written only when the registry changes, so no commit noise). The local +clone lives in `/config-repo`. It is created on the first registration if missing. + +## Mirrors + +Gitea/Forgejo: the primary creates a push mirror via `POST /repos/{o}/{r}/push_mirrors` +(`sync_on_commit`, 8 h interval) to a repo created on the mirror provider. GitHub has no push +mirrors: `configure_mirror` reports `Unsupported` and `new` warns. The daemon-side fallback (push +branches and tags only, never `refs/sync/*`) is **not implemented**. + +## Validation + +- Unit/mock tests: `crates/grove-providers/tests/api.rs` (requests, auth headers, error mapping, + org endpoint, no-push-mirror on GitHub, env token override), `grove-core/tests/registry.rs` + (bare layout creation, push, clone into layout, registry round trip). +- End to end against a local Forgejo 11: `spikes/phase4-e2e.sh` (new x2, config repo, a second + machine rebuilds the workspace with `login` env token + `bootstrap`). Passed; repos cleaned up. +- Also exercised there: `import` (list, clone, unknown name rejected), invalid token rejected (401). + +## Not done / not verified + +- Mirror creation against a real forge pair (only the API call shape is mock-tested). +- Secret Service storage on a real desktop session (the sandbox has none; env override used). +- GitHub provider against github.com (mock only). GitHub git auth relies on the credential helper. +- Deleting remote repos is deliberately not implemented. diff --git a/docs/phase5.md b/docs/phase5.md new file mode 100644 index 0000000..2b5f89d --- /dev/null +++ b/docs/phase5.md @@ -0,0 +1,26 @@ +# Phase 5: resolve, safety, packaging + +## Done + +- **Resolve** (`grove resolve --take-remote | --keep-local | --save-as BRANCH | --compare`, + also in the GUI). Every choice writes a backup ref first (`refs/sync-backup///resolve-local/` + or `resolve-remote/`). `--keep-local` uses force-with-lease on the observed upstream tip. + `--take-remote` and `--save-as` refuse on a dirty worktree or when ignored files would be overwritten. + `--save-as` needs the bare + worktrees layout. `status --plan` explains what the next pass will do. + Covered by `crates/grove-core/tests/resolve.rs` (4 tests). +- **Size limit**: `sync.max_file_mb` (default 50, 0 = unlimited). Oversized changed files are left out of + the snapshot (reset to their HEAD version, or absent), reported in the pass result and the daemon log. + Covered by `tests/size_limit.rs`. +- **Encrypted files** (`grove secrets init|push|pull|rekey`, age x25519): see `phase4.md`. +- **Packaging**: `cargo build --release --workspace && cargo deb -p grove --no-build` produces + `target/debian/grove_*.deb` (CLI, daemon, systemd *user* unit `/usr/lib/systemd/user/groved.service`). + The package was built; it was **not installed or run**. `dpkg-shlibdeps` is unavailable here, so `$auto` + dependencies were not computed. + +## Not done + +- AppImage (no `appimagetool`) and Flatpak: not attempted. The Tauri bundle config requests `deb` and + `appimage`, untested. +- Daemon-side mirroring fallback for GitHub (GitHub has no push mirrors; `configure_mirror` returns `Unsupported`). +- Syncing agent sessions (optional item in the plan): not implemented. +- A real two-PC run, a real cross-forge mirror, Secret Service on a desktop, github.com: unverified. diff --git a/gui/src-tauri/.gitignore b/gui/src-tauri/.gitignore new file mode 100644 index 0000000..4cacddf --- /dev/null +++ b/gui/src-tauri/.gitignore @@ -0,0 +1,2 @@ +/target +/gen diff --git a/gui/src-tauri/Cargo.toml b/gui/src-tauri/Cargo.toml new file mode 100644 index 0000000..66ee7d6 --- /dev/null +++ b/gui/src-tauri/Cargo.toml @@ -0,0 +1,19 @@ +# Tauri shell for the grove GUI. Deliberately NOT a member of the root workspace: it needs the +# webkit2gtk/libsoup system packages (see docs/phase3.md) and must not break `cargo test` without them. +[package] +name = "grove-gui" +version = "0.1.0" +edition = "2024" +license = "MIT" +description = "grove desktop GUI (Tauri shell around gui/ui)" + +[workspace] + +[dependencies] +grove-bridge = { path = "../../crates/grove-bridge" } +grove-daemon = { path = "../../crates/grove-daemon" } +serde_json = "1" +tauri = { version = "2", features = ["tray-icon"] } + +[build-dependencies] +tauri-build = "2" diff --git a/gui/src-tauri/build.rs b/gui/src-tauri/build.rs new file mode 100644 index 0000000..d860e1e --- /dev/null +++ b/gui/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/gui/src-tauri/capabilities/default.json b/gui/src-tauri/capabilities/default.json new file mode 100644 index 0000000..e9b9f39 --- /dev/null +++ b/gui/src-tauri/capabilities/default.json @@ -0,0 +1,7 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Main window: only the app's own commands, no filesystem or shell access.", + "windows": ["main"], + "permissions": ["core:default"] +} diff --git a/gui/src-tauri/icons/icon.png b/gui/src-tauri/icons/icon.png new file mode 100644 index 0000000..76c0e69 Binary files /dev/null and b/gui/src-tauri/icons/icon.png differ diff --git a/gui/src-tauri/src/main.rs b/gui/src-tauri/src/main.rs new file mode 100644 index 0000000..2af493c --- /dev/null +++ b/gui/src-tauri/src/main.rs @@ -0,0 +1,79 @@ +//! Tauri shell: serves `gui/ui` and exposes the same three calls the dev bridge offers +//! (`ipc`, `cli`, `config`) as Tauri commands, backed by the shared `grove-bridge` library. +//! Also a tray icon with open / pause-resume / quit so the window can be closed. + +use grove_bridge::Bridge; +use serde_json::{Value, json}; +use tauri::menu::{Menu, MenuItem}; +use tauri::tray::TrayIconBuilder; +use tauri::{Manager, WindowEvent}; + +fn bridge() -> Bridge { + Bridge { + grove_bin: std::env::var_os("GROVE_BIN") + .map(Into::into) + .unwrap_or_else(|| "grove".into()), + config: None, + socket: grove_daemon::ipc::default_socket_path(), + } +} + +#[tauri::command] +fn ipc(req: Value) -> Value { + bridge().ipc(&req) +} + +#[tauri::command] +fn cli(args: Vec, stdin: Option) -> Value { + bridge().cli(&args, &stdin.unwrap_or_default()) +} + +#[tauri::command] +fn config() -> Value { + match bridge().config_json() { + Some(c) => json!({"exists": true, "config": c}), + None => json!({"exists": false}), + } +} + +fn main() { + tauri::Builder::default() + .invoke_handler(tauri::generate_handler![ipc, cli, config]) + .setup(|app| { + let open = MenuItem::with_id(app, "open", "Open Grove", true, None::<&str>)?; + let pause = MenuItem::with_id(app, "pause", "Pause / resume sync", true, None::<&str>)?; + let quit = MenuItem::with_id(app, "quit", "Quit GUI (daemon keeps running)", true, None::<&str>)?; + let menu = Menu::with_items(app, &[&open, &pause, &quit])?; + TrayIconBuilder::new() + .icon(app.default_window_icon().cloned().expect("window icon")) + .menu(&menu) + .on_menu_event(|app, ev| match ev.id.as_ref() { + "open" => { + if let Some(w) = app.get_webview_window("main") { + let _ = w.show(); + let _ = w.set_focus(); + } + } + "pause" => { + let b = bridge(); + let paused = b.ipc(&json!({"v":1,"cmd":"status"}))["data"]["paused"] + .as_bool() + .unwrap_or(false); + b.ipc(&json!({"v":1,"cmd": if paused {"resume"} else {"pause"}})); + } + "quit" => app.exit(0), + _ => {} + }) + .build(app)?; + Ok(()) + }) + // Closing the window hides it; the tray keeps the app (and its notifications) alive. + .on_window_event(|w, ev| { + if let WindowEvent::CloseRequested { api, .. } = ev { + api.prevent_close(); + let _ = w.hide(); + } + }) + .run(tauri::generate_context!()) + .expect("error while running grove-gui"); +} diff --git a/gui/src-tauri/tauri.conf.json b/gui/src-tauri/tauri.conf.json new file mode 100644 index 0000000..d52dad4 --- /dev/null +++ b/gui/src-tauri/tauri.conf.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "Grove", + "version": "0.1.0", + "identifier": "es.zenvairo.grove", + "build": { "frontendDist": "../ui" }, + "app": { + "withGlobalTauri": true, + "windows": [{ "title": "Grove", "width": 1100, "height": 720, "minWidth": 720, "minHeight": 480 }], + "security": { + "csp": "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:" + } + }, + "bundle": { + "active": true, + "targets": ["deb", "appimage"], + "icon": ["icons/icon.png"], + "category": "DeveloperTool" + } +} diff --git a/gui/ui/app.js b/gui/ui/app.js new file mode 100644 index 0000000..3a71a4f --- /dev/null +++ b/gui/ui/app.js @@ -0,0 +1,367 @@ +'use strict'; +// ---- backend adapter: Tauri shell (invoke) or the localhost dev bridge (fetch) ---------------- +const tauri = window.__TAURI__ && window.__TAURI__.core; +async function post(path, body) { + const r = await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Grove': '1' }, body: JSON.stringify(body) }); + if (!r.ok) throw new Error(r.status + ' ' + (await r.text())); + return r.json(); +} +// Backend failures never throw into the UI: they come back as {ok:false, ...}. +const safe = (p, fail) => p.catch((e) => fail(String((e && e.message) || e))); +const ipc = (req) => safe(tauri ? tauri.invoke('ipc', { req }) : post('/api/ipc', req), (m) => ({ ok: false, offline: true, error: m })); +const cli = (args, stdin = '') => safe(tauri ? tauri.invoke('cli', { args, stdin }) : post('/api/cli', { args, stdin }), (m) => ({ ok: false, output: m })); +async function getConfig() { + if (tauri) return tauri.invoke('config'); + return (await fetch('/api/config')).json(); +} + +// ---- tiny DOM helper (text is always set via textContent, never innerHTML) -------------------- +function h(tag, attrs, ...kids) { + const e = document.createElement(tag); + for (const [k, v] of Object.entries(attrs || {})) { + if (k === 'class') e.className = v; + else if (k.startsWith('on')) e.addEventListener(k.slice(2), v); + else if (v === true) e.setAttribute(k, ''); + else if (v !== false && v != null) e.setAttribute(k, v); + } + for (const c of kids.flat()) if (c != null && c !== false) e.append(c.nodeType ? c : document.createTextNode(c)); + return e; +} +const $ = (s) => document.querySelector(s); + +// ---- state --------------------------------------------------------------------------------- +const S = { out: {}, branchName: {}, busy: false, status: null, offline: false, config: undefined, log: [], logFilter: '', lastStates: new Map() }; +const stateName = (s) => (s.startsWith('error') ? 'error' : s); +const STATE_LABEL = { synced: 'Synced', dirty: 'Editing', ahead: 'Ahead', behind: 'Behind', behinddirty: 'Behind + editing', diverged: 'Diverged', error: 'Error' }; +const PLAN = { + synced: 'Nothing to do.', + dirty: 'Snapshot the working changes and push the snapshot ref.', + ahead: 'Nothing automatic: push your commits yourself.', + behind: 'Fast-forward to the remote tip.', + behinddirty: 'Keep your edits; adopt the remote tip only if the content is identical.', + diverged: 'Nothing automatic: choose how to resolve it.', + error: 'Retry with backoff; see the error.', +}; +const short = (p) => p.split('/').slice(-2).join('/'); +function ago(ts, now) { + if (!ts) return 'never'; + const d = Math.max(0, (now || Date.now() / 1000) - ts); + if (d < 5) return 'just now'; + if (d < 60) return Math.round(d) + 's ago'; + if (d < 3600) return Math.round(d / 60) + ' min ago'; + if (d < 86400) return Math.round(d / 3600) + ' h ago'; + return Math.round(d / 86400) + ' d ago'; +} +function toast(msg, bad) { + const t = h('div', { class: 'toast' + (bad ? ' bad' : ''), role: 'status' }, msg); + $('#toasts').append(t); + setTimeout(() => t.remove(), 5000); +} +function notify(title, body) { + toast(title + ': ' + body, true); + try { + if ('Notification' in window && Notification.permission === 'granted') new Notification(title, { body }); + } catch (_) { /* notifications are optional */ } +} +const badge = (st) => h('span', { class: 'badge b-' + stateName(st) }, STATE_LABEL[stateName(st)] || st); + +// ---- aggregate ------------------------------------------------------------------------------- +function aggregate() { + const s = S.status; + if (S.offline || !s) return { cls: 'pill-muted', text: S.offline ? 'Daemon offline' : 'Connecting…', bad: 0 }; + let attention = 0, dirty = 0, total = 0; + for (const r of s.repos) { + if (r.last_error && !r.worktrees.some((w) => stateName(w.state) === 'error')) attention++; + for (const w of r.worktrees) { + total++; + const n = stateName(w.state); + if (n === 'diverged' || n === 'error') attention++; + else if (n !== 'synced') dirty++; + } + } + if (s.paused) return { cls: 'pill-muted', text: 'Paused', total, attention }; + if (attention) return { cls: 'pill-bad', text: attention + ' need' + (attention === 1 ? 's' : '') + ' attention', total, attention }; + if (dirty) return { cls: 'pill-warn', text: dirty + ' syncing', total, attention }; + return { cls: 'pill-ok', text: 'All synced', total, attention }; +} +function renderTop() { + const a = aggregate(); + $('#pill').className = 'pill ' + a.cls; + $('#pill-text').textContent = a.text; + const paused = S.status && S.status.paused; + $('#btn-pause').textContent = paused ? 'Resume sync' : 'Pause sync'; + $('#btn-pause').disabled = S.offline; + $('#btn-sync').disabled = S.offline || paused; + const m = $('#machine'); + m.textContent = ''; + if (S.status) m.append('Machine ', h('b', {}, S.status.machine)); + document.title = (a.attention ? '(' + a.attention + ') ' : '') + 'Grove'; +} + +// ---- views --------------------------------------------------------------------------------- +const views = {}; +views.repos = () => { + const s = S.status; + if (S.offline) return offline(); + if (!s) return h('p', { class: 'muted' }, 'Loading…'); + const a = aggregate(); + const stats = h('div', { class: 'grid2' }, + stat(s.repos.length, 'Repositories'), + stat(a.total || 0, 'Worktrees'), + stat(a.attention || 0, 'Need attention')); + if (!s.repos.length) return h('div', {}, head('Repositories', 'Everything grove keeps in sync on this machine.'), h('div', { class: 'card empty' }, 'No repositories yet. Create one under “New repository” or clone existing ones with “Import”.')); + const rows = s.repos.map((r) => h('tr', { class: 'row', tabindex: 0, onclick: () => (location.hash = '#/repo/' + encodeURIComponent(r.path)), onkeydown: (e) => { if (e.key === 'Enter') location.hash = '#/repo/' + encodeURIComponent(r.path); } }, + h('td', {}, h('div', { class: 'repo-name' }, short(r.path)), h('div', { class: 'path' }, r.path)), + h('td', {}, r.worktrees.map((w) => h('span', { title: w.branch || '' }, badge(w.state), h('span', { class: 'muted' }, (w.branch || '(detached)') + ' ')))), + h('td', {}, h('span', { class: 'muted' }, r.phase)), + h('td', {}, h('span', { class: 'muted' }, ago(r.last_sync, s.now)), r.last_error && h('div', { class: 'err' }, r.last_error)))); + return h('div', {}, head('Repositories', 'Everything grove keeps in sync on this machine.'), stats, + h('div', { class: 'card' }, h('table', { class: 'table' }, + h('thead', {}, h('tr', {}, h('th', {}, 'Repository'), h('th', {}, 'Worktrees'), h('th', {}, 'Phase'), h('th', {}, 'Last sync'))), + h('tbody', {}, rows)))); +}; +const stat = (n, label) => h('div', { class: 'card stat' }, h('b', {}, String(n)), h('span', {}, label)); +const head = (t, sub) => h('div', {}, h('h1', {}, t), h('p', { class: 'sub' }, sub)); +const offline = () => h('div', { class: 'card empty' }, h('b', {}, 'The grove daemon is not running.'), h('p', {}, 'Start it with ', h('code', {}, 'systemctl --user start groved'), ' (or run ', h('code', {}, 'groved'), ' in a terminal).')); + +views.repo = (path) => { + const r = S.status && S.status.repos.find((x) => x.path === path); + if (S.offline) return offline(); + if (!r) return h('div', {}, h('a', { class: 'back', href: '#/repos' }, '← Repositories'), h('p', { class: 'muted' }, 'Repository not found.')); + const rows = r.worktrees.map((w) => { + const n = stateName(w.state); + return h('tr', {}, + h('td', {}, h('div', { class: 'repo-name' }, w.branch || '(detached)'), h('div', { class: 'path' }, w.path || '')), + h('td', {}, badge(w.state)), + h('td', { class: 'muted' }, PLAN[n] || '')); + }); + const diverged = r.worktrees.filter((w) => stateName(w.state) === 'diverged'); + return h('div', {}, + h('a', { class: 'back', href: '#/repos' }, '← Repositories'), + h('h1', {}, short(r.path)), + h('p', { class: 'sub path' }, r.path), + h('div', { class: 'actions' }, h('button', { class: 'btn', onclick: () => syncRepo(r.path) }, 'Sync this repository')), + r.last_error && h('div', { class: 'err' }, r.last_error), + h('h2', {}, 'Worktrees'), + h('div', { class: 'card' }, h('table', { class: 'table' }, + h('thead', {}, h('tr', {}, h('th', {}, 'Branch'), h('th', {}, 'State'), h('th', {}, 'Next sync pass'))), h('tbody', {}, rows))), + diverged.map((w) => resolvePanel(w)), + r.worktrees.filter((w) => stateName(w.state) !== 'diverged' && S.out[w.path]).map((w) => h('div', { class: 'term' + (S.out[w.path].ok ? '' : ' fail') }, S.out[w.path].text))); +}; +function resolvePanel(w) { + const out = h('div'); + const run = async (flag, label) => { + if (!confirm(label + '\n\nA backup ref is written first, so nothing is lost. Continue?')) return; + const r = await cli(['resolve', w.path, ...flag]); + S.out[w.path] = { ok: r.ok, text: r.output }; + render(true); + refresh(); + }; + if (!w.path) return h('div', { class: 'callout' }, 'Diverged, but this daemon does not report the worktree path. Update groved.'); + const prev = S.out[w.path]; + if (prev) out.append(h('div', { class: 'term' + (prev.ok ? '' : ' fail') }, prev.text)); + const branchName = h('input', { type: 'text', id: 'brname', placeholder: 'branch name', 'aria-label': 'New branch name', value: S.branchName[w.path] ?? (w.branch || 'work') + '-local', oninput: (e) => { S.branchName[w.path] = e.target.value; } }); + return h('div', { class: 'callout' }, + h('h3', {}, 'Diverged: ' + (w.branch || '') + ' has commits here and on the remote'), + h('p', {}, 'Grove never merges for you. Pick what should win:'), + h('div', { class: 'actions' }, + h('button', { class: 'btn', onclick: () => run(['--save-as', branchName.value], 'Keep your commits on branch “' + branchName.value + '” and move this branch to the remote tip') }, 'Save mine as a branch'), branchName, + h('button', { class: 'btn', onclick: () => run(['--take-remote'], 'Discard your local commits and take the remote tip') }, 'Take remote'), + h('button', { class: 'btn btn-danger', onclick: () => run(['--keep-local'], 'Overwrite the remote branch with your local commits') }, 'Keep mine (overwrite remote)')), + h('p', { class: 'muted' }, 'To inspect both sides first, run ', h('code', {}, 'grove resolve ' + w.path + ' --compare'), ' in a terminal.'), + out); +} + +views.activity = () => { + if (S.offline) return offline(); + const f = S.logFilter.toLowerCase(); + const items = S.log.slice().reverse().filter((e) => !f || (e.kind + ' ' + (e.repo || '') + ' ' + e.msg).toLowerCase().includes(f)); + const filter = h('input', { type: 'text', id: 'flt', placeholder: 'Filter…', 'aria-label': 'Filter activity', value: S.logFilter, oninput: (e) => { S.logFilter = e.target.value; render(true); } }); + const body = items.length + ? h('table', { class: 'table' }, h('thead', {}, h('tr', {}, h('th', {}, 'Time'), h('th', {}, 'Event'), h('th', {}, 'Repository'), h('th', {}, 'Details'))), + h('tbody', {}, items.map((e) => h('tr', {}, + h('td', { class: 'muted' }, new Date(e.ts * 1000).toLocaleTimeString('en-GB')), + h('td', {}, h('span', { class: 'kind k-' + e.kind }, e.kind)), + h('td', { class: 'muted' }, e.repo || '–'), + h('td', {}, e.msg))))) + : h('div', { class: 'empty' }, 'No activity yet.'); + return h('div', {}, head('Activity', 'What the daemon did, newest first.'), h('div', { class: 'actions' }, filter), h('div', { class: 'card', style: 'margin-top:12px' }, body)); +}; + +function groupSelect() { + const groups = (S.config && S.config.groups) || []; + return h('select', { id: 'group', 'aria-label': 'Group' }, groups.map((g) => h('option', { value: g.name }, g.name + ' → ' + g.primary))); +} +function needConfig() { + return S.config && S.config.exists ? null : h('div', { class: 'card empty' }, 'Finish onboarding first (Settings).'); +} +views.new = () => { + if (needConfig()) return needConfig(); + const out = h('div'); + const name = h('input', { type: 'text', id: 'name', placeholder: 'my-project', pattern: '[A-Za-z0-9._-]+' }); + const pub = h('input', { type: 'checkbox', id: 'public' }); + const btn = h('button', { class: 'btn btn-primary', type: 'submit' }, 'Create repository'); + const form = h('form', { class: 'card form', onsubmit: async (e) => { + e.preventDefault(); + if (!name.value.trim()) return; + btn.disabled = true; btn.textContent = 'Creating…'; + const args = ['new', $('#group').value, name.value.trim()].concat(pub.checked ? ['--public'] : []); + const r = await cli(args); + out.replaceChildren(h('div', { class: 'term' + (r.ok ? '' : ' fail') }, r.output)); + btn.disabled = false; btn.textContent = 'Create repository'; + if (r.ok) { toast('Repository created'); name.value = ''; refresh(); } + } }, + h('label', {}, 'Group', groupSelect()), + h('label', {}, 'Name', name, h('span', { class: 'hint' }, 'Created on the group’s primary forge, with an initial commit and the bare + worktrees layout.')), + h('label', { class: 'check' }, pub, 'Public repository'), btn); + return h('div', {}, head('New repository', 'Creates the remote, the local checkout, the mirrors and registers it for your other machines.'), form, out); +}; + +views.import = () => { + if (needConfig()) return needConfig(); + const out = h('div'), list = h('div'); + const sel = groupSelect(); + const scan = async () => { + list.replaceChildren(h('p', { class: 'muted' }, 'Scanning…')); + out.replaceChildren(); + const r = await cli(['import', sel.value]); + const names = (r.output.match(/^\s+\S+\/(\S+?)(?: \(private\))?$/gm) || []).map((l) => l.trim().split(/\s+/)[0].split('/')[1]); + if (!r.ok) return list.replaceChildren(h('div', { class: 'term fail' }, r.output)); + if (!names.length) return list.replaceChildren(h('p', { class: 'muted' }, 'Nothing to import: every remote repository is already on this machine.')); + const boxes = names.map((n) => h('label', { class: 'check' }, h('input', { type: 'checkbox', value: n }), n)); + const go = h('button', { class: 'btn btn-primary', onclick: async () => { + const picked = [...list.querySelectorAll('input:checked')].map((i) => i.value); + if (!picked.length) return; + go.disabled = true; + const res = await cli(['import', sel.value, ...picked]); + out.replaceChildren(h('div', { class: 'term' + (res.ok ? '' : ' fail') }, res.output)); + go.disabled = false; refresh(); + if (res.ok) scan(); + } }, 'Import selected'); + list.replaceChildren(h('div', { class: 'card form' }, boxes, go)); + }; + return h('div', {}, head('Import', 'Clone repositories that exist on your forge but not on this machine.'), + h('div', { class: 'actions' }, sel, h('button', { class: 'btn', onclick: scan }, 'Scan remote')), list, out); +}; + +views.settings = () => { + const c = S.config; + if (!c || !c.exists) return onboarding(); + const cfg = c.config; + const kv = (rows) => h('dl', { class: 'kv card' }, rows.flatMap(([k, v]) => [h('dt', {}, k), h('dd', {}, v)])); + const provs = Object.entries(cfg.providers || {}); + const out = h('div'); + const prov = h('select', { id: 'tokprov', 'aria-label': 'Provider' }, provs.map(([id]) => h('option', { value: id }, id))); + const tok = h('input', { type: 'password', id: 'tok', autocomplete: 'off', placeholder: 'API token' }); + const act = async (args, stdin) => { const r = await cli(args, stdin); out.replaceChildren(h('div', { class: 'term' + (r.ok ? '' : ' fail') }, r.output)); refresh(); }; + return h('div', {}, head('Settings', 'Read from config.toml. Tokens live in the system keyring, never in the file.'), + h('h2', {}, 'This machine'), + kv([['Name', cfg.machine.name], ['Workspace root', cfg.root.path], ['Fetch interval', ((cfg.sync && cfg.sync.fetch_interval_s) || 60) + ' s'], ['Largest synced file', ((cfg.sync && cfg.sync.max_file_mb) ?? 50) + ' MiB']]), + h('h2', {}, 'Providers'), + kv(provs.map(([id, p]) => [id, p.kind + (p.url ? ' · ' + p.url : '')])), + h('h2', {}, 'Groups'), + kv((cfg.groups || []).map((g) => [g.name, 'primary ' + g.primary + (g.mirror_to && g.mirror_to.length ? ' · mirrors: ' + g.mirror_to.join(', ') : '') + ' · ' + (g.layout || 'bare-worktrees')])), + h('h2', {}, 'Config repository'), + kv([['Repository', cfg.config_repo ? cfg.config_repo.name + ' on ' + cfg.config_repo.provider : 'not configured']]), + h('div', { class: 'actions' }, + h('button', { class: 'btn', onclick: () => act(['config-repo-init']) }, 'Register repos on disk'), + h('button', { class: 'btn', onclick: () => act(['bootstrap']) }, 'Bootstrap from config repo')), + h('h2', {}, 'Sign in to a provider'), + h('form', { class: 'card form', onsubmit: (e) => { e.preventDefault(); if (tok.value) { act(['login', prov.value], tok.value + '\n'); tok.value = ''; } } }, + h('label', {}, 'Provider', prov), h('label', {}, 'Token', tok, h('span', { class: 'hint' }, 'Needs repository read/write scope. Sent to the forge only.')), + h('button', { class: 'btn btn-primary', type: 'submit' }, 'Verify and store')), + h('h2', {}, 'Encrypted files (.env)'), + h('div', { class: 'actions' }, + h('button', { class: 'btn', onclick: () => act(['secrets', 'init']) }, 'Create this machine’s key'), + h('button', { class: 'btn', onclick: () => act(['secrets', 'pull']) }, 'Pull secrets'), + h('button', { class: 'btn', onclick: () => act(['secrets', 'rekey']) }, 'Re-encrypt for all machines')), + out); +}; +function onboarding() { + const f = {}; + const field = (id, label, value, hint) => { f[id] = h('input', { type: 'text', id, value }); return h('label', {}, label, f[id], hint && h('span', { class: 'hint' }, hint)); }; + f.kind = h('select', { id: 'kind' }, ['gitea', 'forgejo', 'github'].map((k) => h('option', { value: k }, k))); + f.token = h('input', { type: 'password', id: 'token', autocomplete: 'off' }); + const out = h('div'); + const btn = h('button', { class: 'btn btn-primary', type: 'submit' }, 'Set up grove'); + const form = h('form', { class: 'card form', onsubmit: async (e) => { + e.preventDefault(); btn.disabled = true; + const lines = []; + const step = async (args, stdin) => { const r = await cli(args, stdin); lines.push('$ grove ' + args[0] + '\n' + r.output); out.replaceChildren(h('div', { class: 'term' + (r.ok ? '' : ' fail') }, lines.join('\n\n'))); return r.ok; }; + const a = ['init', '--machine', f.machine.value, '--root', f.root.value, '--provider', f.provider.value, '--kind', f.kind.value, '--group', f.group.value, '--config-repo', f.crepo.value]; + if (f.url.value) a.push('--url', f.url.value); + const existing = await getConfig(); // a previous attempt may already have written the config + if ((existing.exists || await step(a)) && await step(['login', f.provider.value], f.token.value + '\n') && await step(['bootstrap'])) { toast('All set'); S.config = undefined; await refresh(); location.hash = '#/repos'; } + btn.disabled = false; + } }, + field('machine', 'Machine name', 'my-laptop', 'Letters, digits, - and _. Unique per computer.'), + field('root', 'Workspace folder', '~/Workspace'), + h('label', {}, 'Forge type', f.kind), + field('provider', 'Provider id', 'main'), + field('url', 'Forge URL', 'https://git.example.com', 'Empty for github.com.'), + field('group', 'First group', 'work'), + field('crepo', 'Config repository', 'grove-config', 'Private repo holding the list of your repos, so a new machine only needs to sign in.'), + h('label', {}, 'API token', f.token), btn); + return h('div', {}, head('Welcome to Grove', 'Set up this machine. On a second computer this is all you do: sign in and your workspace appears.'), form, out); +} + +// ---- router / render ------------------------------------------------------------------------- +function route() { + const hash = location.hash.replace(/^#\/?/, '') || 'repos'; + const [name, ...rest] = hash.split('/'); + return { name, arg: rest.length ? decodeURIComponent(rest.join('/')) : null }; +} +let lastKey = ''; +function render(force) { + const { name, arg } = route(); + document.querySelectorAll('#nav a').forEach((a) => a.classList.toggle('active', a.dataset.route === (name === 'repo' ? 'repos' : name))); + renderTop(); + // Avoid clobbering forms while the user types: re-render form views only on navigation. + const formView = ['new', 'import', 'settings'].includes(name); + const key = name + '|' + arg; + if (!force && formView && key === lastKey) return; + lastKey = key; + // Never rebuild under the user's cursor on a background poll. + const ae = document.activeElement; + const typing = ae && $('#view').contains(ae) && /^(INPUT|SELECT|TEXTAREA)$/.test(ae.tagName); + if (!force && typing) return; + const keep = typing && ae.id ? { id: ae.id, pos: ae.selectionStart } : null; + const v = name === 'repo' ? views.repo(arg) : (views[name] || views.repos)(); + $('#view').replaceChildren(v); + if (keep) { const e = document.getElementById(keep.id); if (e) { e.focus(); try { e.setSelectionRange(keep.pos, keep.pos); } catch (_) { /* not a text input */ } } } +} + +// ---- actions & polling ----------------------------------------------------------------------- +async function syncRepo(path) { + const r = await ipc({ v: 1, cmd: 'sync', repo: path }); + toast(r.ok ? 'Sync queued' : r.error, !r.ok); +} +$('#btn-sync').addEventListener('click', async () => { const r = await ipc({ v: 1, cmd: 'sync' }); toast(r.ok ? 'Sync queued for all repositories' : r.error, !r.ok); }); +$('#btn-pause').addEventListener('click', async () => { + const paused = S.status && S.status.paused; + await ipc({ v: 1, cmd: paused ? 'resume' : 'pause' }); + refresh(); +}); +function watchTransitions() { + if (!S.status) return; + for (const r of S.status.repos) for (const w of r.worktrees) { + const key = w.path || r.path + w.branch, n = stateName(w.state), prev = S.lastStates.get(key); + if (prev && prev !== n && (n === 'diverged' || n === 'error')) notify(n === 'diverged' ? 'Diverged' : 'Sync error', short(r.path) + ' · ' + (w.branch || '')); + S.lastStates.set(key, n); + } +} +async function refresh() { + if (S.busy) return; + S.busy = true; + try { + const st = await ipc({ v: 1, cmd: 'status' }); + S.offline = !st.ok; S.status = st.ok ? st.data : null; + if (st.ok) { const lg = await ipc({ v: 1, cmd: 'log', limit: 200 }); if (lg.ok) S.log = lg.data; } + } catch (_) { S.offline = true; S.status = null; } + if (S.config === undefined) { try { S.config = await getConfig(); } catch (_) { S.config = { exists: false }; } } + try { watchTransitions(); } finally { S.busy = false; } + render(false); +} +window.addEventListener('hashchange', () => render(true)); +refresh().then(() => { if (!(S.config && S.config.exists) && !location.hash) location.hash = '#/settings'; }); +setInterval(refresh, 2000); // refresh() skips while a previous one is still in flight diff --git a/gui/ui/index.html b/gui/ui/index.html new file mode 100644 index 0000000..fb31684 --- /dev/null +++ b/gui/ui/index.html @@ -0,0 +1,36 @@ + + + + + +Grove + + + + +
+ +
+
+
Connecting…
+
+ + +
+
+
+
+
+ + + diff --git a/gui/ui/logo.svg b/gui/ui/logo.svg new file mode 100644 index 0000000..0708609 --- /dev/null +++ b/gui/ui/logo.svg @@ -0,0 +1 @@ + diff --git a/gui/ui/style.css b/gui/ui/style.css new file mode 100644 index 0000000..4679a3f --- /dev/null +++ b/gui/ui/style.css @@ -0,0 +1,98 @@ +:root { + --bg: #f5f6f4; --panel: #ffffff; --text: #1b2420; --muted: #66726b; --line: #e1e5e1; + --accent: #1f7a4d; --accent-ink: #ffffff; --accent-soft: #e3f2ea; + --ok: #1f7a4d; --ok-bg: #e3f2ea; + --warn: #9a6200; --warn-bg: #fdf0d5; + --info: #1d5fa8; --info-bg: #e3eefa; + --bad: #b3261e; --bad-bg: #fbe4e1; + --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace; + --radius: 10px; +} +@media (prefers-color-scheme: dark) { + :root { + --bg: #121714; --panel: #1a211d; --text: #e6ede8; --muted: #93a39a; --line: #2a342e; + --accent: #3fb27a; --accent-ink: #08140d; --accent-soft: #1d3a2b; + --ok: #5bd197; --ok-bg: #1d3a2b; --warn: #f0b64a; --warn-bg: #3a2e12; + --info: #7ab4f0; --info-bg: #17304d; --bad: #ff8a80; --bad-bg: #4a1f1b; + } +} +* { box-sizing: border-box; } +html, body { height: 100%; } +body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; } +.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100%; } +.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; } +.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; letter-spacing: .2px; padding: 0 6px; } +nav { display: flex; flex-direction: column; gap: 2px; } +nav a { padding: 8px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; } +nav a:hover { background: var(--bg); color: var(--text); } +nav a.active { background: var(--accent-soft); color: var(--accent); } +.machine { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 6px; word-break: break-all; } +.machine b { color: var(--text); font-weight: 600; } +.main { display: flex; flex-direction: column; min-width: 0; } +.top { display: flex; align-items: center; gap: 10px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 2; } +.spacer { flex: 1; } +.view { padding: 24px; max-width: 1100px; width: 100%; } +h1 { font-size: 20px; margin: 0 0 4px; } +h2 { font-size: 15px; margin: 22px 0 8px; } +.sub { color: var(--muted); margin: 0 0 18px; } +.btn { font: inherit; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; font-weight: 500; } +.btn:hover { border-color: var(--muted); } +.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, .row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } +.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); } +.btn-danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; } +.btn:disabled { opacity: .5; cursor: default; } +.pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; } +.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; } +.pill-ok { background: var(--ok-bg); color: var(--ok); } +.pill-warn { background: var(--warn-bg); color: var(--warn); } +.pill-bad { background: var(--bad-bg); color: var(--bad); } +.pill-muted { background: var(--bg); color: var(--muted); } +.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); } +.table { width: 100%; border-collapse: collapse; } +.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; padding: 10px 16px; border-bottom: 1px solid var(--line); } +.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; } +.table tr:last-child td { border-bottom: 0; } +.row { cursor: pointer; } +.row:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); } +.repo-name { font-weight: 600; } +.path { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-all; } +.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; margin: 1px 4px 1px 0; } +.b-synced { background: var(--ok-bg); color: var(--ok); } +.b-dirty, .b-behinddirty { background: var(--warn-bg); color: var(--warn); } +.b-ahead, .b-behind { background: var(--info-bg); color: var(--info); } +.b-diverged, .b-error { background: var(--bad-bg); color: var(--bad); } +.muted { color: var(--muted); } +.err { color: var(--bad); font-size: 13px; margin-top: 4px; } +.empty { padding: 40px 20px; text-align: center; color: var(--muted); } +.form { display: grid; gap: 14px; max-width: 520px; padding: 20px; } +label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; } +label .hint { font-weight: 400; color: var(--muted); } +input[type=text], input[type=password], select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); } +.check { display: flex; align-items: center; gap: 8px; font-weight: 500; } +.term { font-family: var(--mono); font-size: 12.5px; background: #0f1512; color: #cfe8d9; border-radius: var(--radius); padding: 14px 16px; white-space: pre-wrap; word-break: break-word; margin-top: 14px; max-height: 320px; overflow: auto; } +.term.fail { color: #ffb4ab; } +.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; padding: 16px 20px; } +.kv dt { color: var(--muted); } +.kv dd { margin: 0; word-break: break-all; } +.kind { font-family: var(--mono); font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); } +.k-error, .k-watch_error { color: var(--bad); border-color: var(--bad); } +.k-snapshot, .k-applied, .k-fast_forward, .k-materialized { color: var(--ok); } +.k-declined, .k-pause { color: var(--warn); } +.back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; } +.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; } +.callout { border: 1px solid var(--bad); background: var(--bad-bg); border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; } +.callout h3 { margin: 0 0 4px; font-size: 14px; color: var(--bad); } +.callout p { margin: 4px 0 10px; } +.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 10; } +.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; max-width: 360px; box-shadow: 0 6px 24px rgba(0,0,0,.25); } +.toast.bad { background: var(--bad); color: #fff; } +.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 18px; } +.stat { padding: 14px 16px; } +.stat b { display: block; font-size: 24px; line-height: 1.1; } +.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; } +@media (max-width: 760px) { + .app { grid-template-columns: 1fr; } + .side { flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; } + nav { flex-direction: row; } .machine { display: none; } + .view { padding: 16px; } .table th:nth-child(n+4), .table td:nth-child(n+4) { display: none; } +} diff --git a/spikes/phase4-e2e.sh b/spikes/phase4-e2e.sh new file mode 100755 index 0000000..9da2595 --- /dev/null +++ b/spikes/phase4-e2e.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# Phase 4 end-to-end check against a throwaway Forgejo on localhost:3300 (spikes/forgejo-up.sh): +# new repo -> config repo -> a fresh machine rebuilds the workspace with `grove bootstrap`. +set -euo pipefail +G=${GROVE_BIN:-target/debug/grove} +G=$(realpath "$G") +W=$(mktemp -d) +api() { curl -fs -u spike:spike-pass-123 "$@"; } +cleanup() { + for r in alpha beta gamma grove-config; do api -X DELETE "localhost:3300/api/v1/repos/spike/$r" >/dev/null || true; done + rm -rf "$W" +} +trap cleanup EXIT +TOK=$(api -H 'Content-Type: application/json' -X POST localhost:3300/api/v1/users/spike/tokens \ + -d "{\"name\":\"e2e$RANDOM\",\"scopes\":[\"all\"]}" | sed -E 's/.*"sha1":"([^"]+)".*/\1/') +export GROVE_TOKEN_MAIN=$TOK +machine() { # name + export XDG_CONFIG_HOME=$W/$1/cfg XDG_STATE_HOME=$W/$1/state + "$G" init --machine "$1" --root "$W/$1/ws" --provider main --kind gitea \ + --url http://localhost:3300 --group work --config-repo grove-config --force >/dev/null +} +machine pca +"$G" new work alpha +"$G" new work beta --public +"$G" config-repo-init +machine pcb +"$G" bootstrap +test -d "$W/pcb/ws/work/alpha/main" && test -d "$W/pcb/ws/work/beta/main" +echo "OK: fresh machine pcb has both repos" + +# Encrypted .env channel: pca pushes, pcb (own key, after rekey on pca) pulls. +machine pca +"$G" new work gamma >/dev/null +"$G" secrets init +echo "API_KEY=s3cr3t" > "$W/pca/ws/work/gamma/main/.env" +machine pcb +"$G" bootstrap >/dev/null +"$G" secrets init +machine pca +"$G" secrets push "$W/pca/ws/work/gamma/main/.env" +"$G" secrets rekey +machine pcb +"$G" secrets pull +test "$(cat "$W/pcb/ws/work/gamma/main/.env")" = "API_KEY=s3cr3t" +test "$(stat -c %a "$W/pcb/ws/work/gamma/main/.env")" = "600" +echo "OK: .env travelled encrypted and landed with mode 600"