From 3b1d2a4389cc8a77c4753b1d775ce899d5490142 Mon Sep 17 00:00:00 2001 From: ocd Date: Thu, 30 Jul 2026 01:07:30 +0300 Subject: [PATCH] Scaffold ocd: config, HTTP fetch, cache, paced pipeline, render Rust CLI with clap subcommands (pretty/raw json/raw plain/fetch/cache/config). Per-workspace dual HTTP (Zen balance + Go limits) run with tokio::join, 500 ms workspace pacing, TTL-180s file cache, retry/backoff for transient failures. scrape.rs holds the only OpenCode-coupled HTML selectors (placeholders until the real Zen/Go pages are captured). Unicode blitter-block bars in pretty mode; stable JSON/plain raw output for widgets and agent plugins. --- .gitignore | 3 + Cargo.lock | 2598 ++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 32 + README.md | 56 + examples/ocd.toml | 15 + src/cache.rs | 118 ++ src/cli.rs | 122 ++ src/client.rs | 119 ++ src/config.rs | 149 +++ src/error.rs | 63 + src/fetch.rs | 185 +++ src/main.rs | 195 ++++ src/model.rs | 86 ++ src/render/mod.rs | 6 + src/render/pretty.rs | 169 +++ src/render/raw.rs | 64 ++ src/scrape.rs | 60 + src/timefmt.rs | 52 + 18 files changed, 4092 insertions(+) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 examples/ocd.toml create mode 100644 src/cache.rs create mode 100644 src/cli.rs create mode 100644 src/client.rs create mode 100644 src/config.rs create mode 100644 src/error.rs create mode 100644 src/fetch.rs create mode 100644 src/main.rs create mode 100644 src/model.rs create mode 100644 src/render/mod.rs create mode 100644 src/render/pretty.rs create mode 100644 src/render/raw.rs create mode 100644 src/scrape.rs create mode 100644 src/timefmt.rs diff --git a/.gitignore b/.gitignore index 4c49bd7..8b6eeaf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .env +/target +/tmp/ +*.toml.bak \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..191abba --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2598 @@ +# This file is automatically @generated by Cargo. +# 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 = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "async-compression" +version = "0.4.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3976abdc8fe7d1133d43d304afd42abdf5bc3e1319d263d223bde07b5efc4be8" +dependencies = [ + "compression-codecs", + "compression-core", + "pin-project-lite", + "tokio", +] + +[[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 = "aws-lc-rs" +version = "1.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00bdb5da18dac48ca2cc7cd4a98e533e8635a58e2361d13a1a4ee3888e0d72f1" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43103168cc76fe62678a375e722fc9cb3a0146159ac5828bc4f0dfd755c2224c" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", + "pkg-config", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cc" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5add81bb678e6cb321aff7fa0dc7689ad82b112dbc032cea19f91d6b8e3582b9" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "chacha20" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core", +] + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91e0c145792ef73a6ad36d27c75ac09f1832222a3c209689d90f534685ee5b7" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f09628afdcc538b57f3c6341e9c8e9970f18e4a481690a64974d7023bd33548b" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d012d2b9d65aca7f18f4d9878a045bc17899bba951561ba5ec3c2ba1eed9a061" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "compression-codecs" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce2548391e9c1929c21bf6aa2680af86fe4c1b33e6cea9ac1cfeec0bd11218cf" +dependencies = [ + "compression-core", + "flate2", + "memchr", +] + +[[package]] +name = "compression-core" +version = "0.4.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc14f565cf027a105f7a44ccf9e5b424348421a1d8952a8fc9d499d313107789" + +[[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 = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "cssparser" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9cdaae01d5ed7882b04d795e7f752f46ff52d2fa3b50a20d28c464510bba98" +dependencies = [ + "cssparser-macros", + "dtoa-short", + "itoa", + "phf", + "smallvec", +] + +[[package]] +name = "cssparser-macros" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a2a99df6e410a8ff4245aa2006499ea662245f967cc7c0a38c83ef8eb44dbf" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "derive_more" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.119", +] + +[[package]] +name = "directories" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.61.2", +] + +[[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.3", +] + +[[package]] +name = "dtoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c3cf4824e2d5f025c7b531afcb2325364084a16806f6d47fbc1f5fbd9960590" + +[[package]] +name = "dtoa-short" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd1511a7b6a56299bd043a9c167a6d2bfb37bf84a6dfceaba651168adfb43c87" +dependencies = [ + "dtoa", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "ego-tree" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b04dc5a38e4f151a79d9f2451ae6037fb6eaf5cba34771f44781f80e508498e3" + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "flate2" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[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 = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "futures-channel" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "262590f4fe6afeb0bc83be1daa64e52657fe185690a958af7f3ad0e92085c5ae" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cd50c473c80f6d7c3670a752354b8e569b1a7cbfdc0419ec88e5edad85e0dc7" + +[[package]] +name = "futures-sink" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e34418ac499d6305c2fb5ad0ed2f6ac998c5f8ca209b4510f7f94242c647e307" + +[[package]] +name = "futures-task" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b231ed28831efb4a61a08580c4bc233ec56bc009f4cd8f52da2c3cb97df0c109" + +[[package]] +name = "futures-util" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a77a90a256fce34da66415271e30f94ee91c57b04b8a2c042d9cf3220179deaa" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getopts" +version = "0.2.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe4fbac503b8d1f88e6676011885f34b7174f46e59956bba534ba83abded4df" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "rand_core", + "wasm-bindgen", +] + +[[package]] +name = "h2" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cb093c84e8bd9b188d4c4a8cb6579fc016968d14c99882163cd3ff402a4f155" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "html5ever" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a1761807faccc9a19e86944bbf40610014066306f96edcdedc2fb714bcb7b8" +dependencies = [ + "log", + "markup5ever", +] + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f41fd6a08e4d4ec69df65976da761afd5ad5e58a9d4acb46bd1c953a9e3ff2" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d22053281f852e11534f5198498373cbb59295120a20771d90f7ed1897490a72" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" + +[[package]] +name = "icu_properties" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" + +[[package]] +name = "icu_provider" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ipnet" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys 0.3.1", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.189" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" + +[[package]] +name = "libredox" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c943259e342f1e06ff2da7a83eabdfe7f92ce10262688dbf1895ff0b3e6e4652" +dependencies = [ + "libc", +] + +[[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" + +[[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.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" + +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + +[[package]] +name = "markup5ever" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7122d987ec5f704ee56f6e5b41a7d93722e9aae27ae07cafa4036c4d3f9757de" +dependencies = [ + "log", + "tendril", + "web_atoms", +] + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d65c71f1ce40ab09135ce117d742b9f8a19ff91a41a8b57ed50bc2de59c427" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "ocd" +version = "0.1.0" +dependencies = [ + "anstyle", + "anyhow", + "chrono", + "clap", + "directories", + "reqwest", + "scraper", + "serde", + "serde_json", + "terminal_size", + "thiserror 2.0.19", + "tokio", + "toml", + "tracing", + "tracing-subscriber", +] + +[[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 = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[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 = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "phf" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" +dependencies = [ + "phf_macros", + "phf_shared", + "serde", +] + +[[package]] +name = "phf_codegen" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737" +dependencies = [ + "fastrand", + "phf_shared", +] + +[[package]] +name = "phf_macros" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "phf_shared" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" + +[[package]] +name = "potential_utf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +dependencies = [ + "zerovec", +] + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quinn" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c1a41e437b6bbd489372cd4971de128e85c855f56c57f283d20ff016cf7c0a8" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.19", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4bfc015262b9df63c8845072ce59068853ff5872180c2ce2f13038b970e560" +dependencies = [ + "aws-lc-rs", + "bytes", + "getrandom 0.4.3", + "lru-slab", + "rand", + "rand_pcg", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.19", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35a133f956daabe89a61a685c2649f13d82d5aa4bd5d12d1277e1072a21c0694" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.61.2", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +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.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rand_pcg" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a" +dependencies = [ + "rand_core", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" +dependencies = [ + "getrandom 0.2.17", + "libredox", + "thiserror 2.0.19", +] + +[[package]] +name = "regex-automata" +version = "0.4.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad" +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 = "reqwest" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04e9018c9d814e5f30cc16a0f03271aeab3571e609612d9fe78c1aa8d11c2f62" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "mime", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", + "serde", + "serde_json", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", +] + +[[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 = "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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0283386ce02abc0151e1761d08802dfe86c173b0b494af5cbc086574e453da06" +dependencies = [ + "aws-lc-rs", + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dab5152771c58876a2146916e53e35057e1a4dfa2b9df0f0305b07f611fdea4d" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-platform-verifier" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d99feebc72bae7ab76ba994bb5e121b8d83d910ca40b36e0921f53becc41784" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + +[[package]] +name = "rustls-webpki" +version = "0.103.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +dependencies = [ + "aws-lc-rs", + "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 = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "scraper" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdd0be4d296f048bfb06dd01bbc80ef789ddd2e55583e8d2e6b804942abfabc2" +dependencies = [ + "cssparser", + "ego-tree", + "getopts", + "html5ever", + "precomputed-hash", + "selectors", + "tendril", +] + +[[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 = "selectors" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8adfa1c298912827b8a28b223b3b874357397ae706e6190acd9bf28cee99114d" +dependencies = [ + "bitflags", + "cssparser", + "derive_more", + "log", + "new_debug_unreachable", + "phf", + "phf_codegen", + "precomputed-hash", + "rustc-hash", + "servo_arc", + "smallvec", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "serde_json" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_spanned" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" +dependencies = [ + "serde_core", +] + +[[package]] +name = "servo_arc" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "170fb83ab34de17dc69aa7c67482b22218ddb85da56546f9bd6b929e32a05930" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "siphasher" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" + +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "string_cache" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18596f8c785a729f2819c0f6a7eae6ebeebdfffbfe4214ae6b087f690e31901" +dependencies = [ + "new_debug_unreachable", + "parking_lot", + "phf_shared", + "precomputed-hash", +] + +[[package]] +name = "string_cache_codegen" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "585635e46db231059f76c5849798146164652513eb9e8ab2685939dd90f29b69" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", +] + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tendril" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fed54709c5b3a53d09bb1c113ea4f5ceafd1e772ddcb0030a82e1d56c087b08" +dependencies = [ + "new_debug_unreachable", +] + +[[package]] +name = "terminal_size" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" +dependencies = [ + "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.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9" +dependencies = [ + "thiserror-impl 2.0.19", +] + +[[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.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "thread_local" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "tinystr" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb4ebadaa0af04fab11ae01eb5f9fdb5f9c5b875506e210e71c07873528baa7f" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "libc", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "1.1.4+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3aace63f4bbcdfc2c965b059de67119c89c4017a70d633be6c104910f67056f5" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.1+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" +dependencies = [ + "async-compression", + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "pin-project-lite", + "tokio", + "tokio-util", + "tower", + "tower-layer", + "tower-service", + "url", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[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", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[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_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 = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +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.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62df1340f32221cb9c54d6a27b030e3dba64361d4a95bed55f9aacb44da291d" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 2.0.119", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8622dcb61c0bcc9fffa6938bed81210af2da9a7e4a1a834b2e37a59b6dfb6141" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web_atoms" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "075474b12bcb3d2e3d4546580e9de478eeeead668a1761e2a8860c836b7ef297" +dependencies = [ + "phf", + "phf_codegen", + "string_cache", + "string_cache_codegen", +] + +[[package]] +name = "webpki-root-certs" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "webpki-roots" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a" +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 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[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.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[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.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[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.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[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.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[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.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[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.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" + +[[package]] +name = "writeable" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" + +[[package]] +name = "yoke" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "synstructure", +] + +[[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.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" + +[[package]] +name = "zerotrie" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..8edd3be --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "ocd" +version = "0.1.0" +edition = "2024" +description = "OpenCode limits and balance dashboard" +license = "MIT" +repository = "https://example.invalid/ocd" + +[[bin]] +name = "ocd" +path = "src/main.rs" + +[dependencies] +anstyle = "1.0" +anyhow = "1.0" +chrono = { version = "0.4", features = ["serde"] } +clap = { version = "4.6", features = ["derive", "env", "cargo"] } +directories = "6.0" +reqwest = { version = "0.13", default-features = false, features = ["rustls", "webpki-roots", "gzip", "json", "charset", "http2"] } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +scraper = "0.27" +terminal_size = "0.4" +thiserror = "2" +tokio = { version = "1", features = ["rt-multi-thread", "macros", "time", "sync"] } +toml = "1" +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } + +[profile.release] +lto = "thin" +codegen-units = 1 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b191bbc --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# ocd + +Console dashboard for opencode account limits and balance. + +`ocd` reads a config of opencode accounts and auth cookies. It scrapes the +opencode Zen page for balance and the Go page for limits. It prints usage for +the 5-hour, week, and month time frames, each reset time, the next update time, +and remaining balance. + +## Install + +``` +cargo install --path . +``` + +## Configure + +``` +ocd config init +$EDITOR ocd.toml +ocd config check # lists accounts and workspaces, no network +``` + +Each account section carries `default_workspace` and optional `extra_workspaces`. + +```toml +[[account]] +name = "work" +cookie = "${OCD_COOKIE_WORK}" +default_workspace = "ws_123" +extra_workspaces = ["ws_456"] +``` + +`${VAR}` expands from the environment so cookies stay out of the file. + +## Run + +``` +ocd pretty # default terminal output +ocd raw json # one JSON object for widgets and agent plugins +ocd raw plain # TSV-ish lines for shell and awk +ocd fetch # update cache, print nothing; for cron +ocd cache ls | clear +ocd -a work -w ws_456 pretty # one account, one workspace +``` + +## Politeness + +Per workspace two requests run at once (Zen, Go). The walk paces 500 ms between +workspaces. Cache TTL defaults to 180 s. Use `--force-refresh` to bypass. + +## Status + +This is a scaffold. The HTTP, cache, pacing, and render pipeline work. The +opencode HTML selectors in `src/scrape.rs` are placeholders until the real Zen +and Go pages are captured. See `DESIGN.md`. \ No newline at end of file diff --git a/examples/ocd.toml b/examples/ocd.toml new file mode 100644 index 0000000..efabaa5 --- /dev/null +++ b/examples/ocd.toml @@ -0,0 +1,15 @@ +# Example ocd config. Copy to ~/.config/ocd/config.toml and edit. +# Cookies are the full Cookie header value. ${VAR} expands from the environment. +default_concurrency = 1 +default_ttl_secs = 180 + +[[account]] +name = "work" +cookie = "${OCD_COOKIE_WORK}" +default_workspace = "ws_REPLACE_ME" +extra_workspaces = [] + +[[account]] +name = "personal" +cookie = "ocd_session=...." +default_workspace = "ws_REPLACE_ME" \ No newline at end of file diff --git a/src/cache.rs b/src/cache.rs new file mode 100644 index 0000000..a23e769 --- /dev/null +++ b/src/cache.rs @@ -0,0 +1,118 @@ +//! File-backed cache, keyed by (account, workspace). +//! +//! Stores the parsed report as JSON under the XDG cache dir. Honors a TTL. +//! Carries optional `etag` and `last_modified` so the HTTP layer can do +//! conditional GET. The path is stable, so widgets can read it directly. + +use std::path::PathBuf; + +use serde::{Deserialize, Serialize}; + +use crate::model::AccountReport; + +/// One cached entry: the report plus conditional-GET headers from both pages. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CachedRecord { + pub report: AccountReport, + pub go_etag: Option, + pub go_last_modified: Option, + pub zen_etag: Option, + pub zen_last_modified: Option, +} + +/// Opens the cache root. The root is `$XDG_CACHE_HOME/ocd/` or +/// `~/.cache/ocd/`. +pub fn cache_dir() -> PathBuf { + directories::ProjectDirs::from("", "", "ocd") + .map(|p| p.cache_dir().to_path_buf()) + .unwrap_or_else(|| PathBuf::from(".cache/ocd")) +} + +/// File path for one (account, workspace) target. +pub fn entry_path(account: &str, workspace: &str) -> PathBuf { + cache_dir().join(format!("{}.{}.json", slug(account), slug(workspace))) +} + +/// Read a cache entry if it is fresh. Fresh means file mtime is within `ttl` +/// seconds of now. Missing or expired entries return None. +pub fn read(account: &str, workspace: &str, ttl_secs: u32) -> Option { + let path = entry_path(account, workspace); + let meta = std::fs::metadata(&path).ok()?; + let age = age_secs(&meta).ok()?; + if age > ttl_secs as u64 { + return None; + } + let body = std::fs::read_to_string(&path).ok()?; + serde_json::from_str(&body).ok() +} + +/// Write a cache entry. Creates the cache dir on demand. +pub fn write(account: &str, workspace: &str, record: &CachedRecord) -> std::io::Result<()> { + let path = entry_path(account, workspace); + if let Some(parent) = path.parent() { + std::fs::create_dir_all(parent)?; + } + let body = serde_json::to_vec_pretty(record)?; + std::fs::write(&path, body) +} + +/// Remove a cache entry. Returns true if a file was removed. +#[allow(dead_code)] +pub fn clear(account: &str, workspace: &str) -> std::io::Result { + let path = entry_path(account, workspace); + match std::fs::remove_file(&path) { + Ok(_) => Ok(true), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(false), + Err(e) => Err(e), + } +} + +/// List cache entries with account and workspace labels. +pub fn list() -> Vec<(String, String)> { + let dir = cache_dir(); + let mut out = Vec::new(); + let Ok(rd) = std::fs::read_dir(&dir) else { + return out; + }; + for entry in rd.flatten() { + let p = entry.path(); + if p.extension().and_then(|e| e.to_str()) != Some("json") { + continue; + } + let stem = p.file_stem().and_then(|s| s.to_str()).unwrap_or(""); + if let Some((a, w)) = stem.rsplit_once('.') { + out.push((a.to_string(), w.to_string())); + } + } + out.sort(); + out +} + +/// Remove every cache entry. Returns the count removed. +pub fn clear_all() -> std::io::Result { + let dir = cache_dir(); + let mut n = 0; + for entry in std::fs::read_dir(&dir)?.flatten() { + let p = entry.path(); + if p.extension().and_then(|e| e.to_str()) == Some("json") { + if std::fs::remove_file(&p).is_ok() { + n += 1; + } + } + } + Ok(n) +} + +fn slug(s: &str) -> String { + s.chars() + .map(|c| if c.is_ascii_alphanumeric() || c == '-' || c == '_' { c } else { '_' }) + .collect() +} + +fn age_secs(meta: &std::fs::Metadata) -> std::io::Result { + let mt = meta.modified()?; + let dur = std::time::SystemTime::now().duration_since(mt).map_err(|e| { + std::io::Error::new(std::io::ErrorKind::InvalidData, e.to_string()) + })?; + Ok(dur.as_secs()) +} \ No newline at end of file diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..db3cd66 --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,122 @@ +//! clap definitions. A bare `ocd` maps to `ocd pretty`. + +use std::path::PathBuf; + +use clap::{ArgAction, Parser, Subcommand}; + +#[derive(Parser, Debug)] +#[command(name = "ocd", version, about = "OpenCode limits and balance dashboard")] +pub struct Cli { + #[command(subcommand)] + pub command: Option, + + /// Path to the config file. Env: OCD_CONFIG. + #[arg(long, short = 'c', global = true, env = "OCD_CONFIG", value_name = "PATH")] + pub config: Option, + + /// Ignore the cache for this run. Always fetch. + #[arg(long, global = true)] + pub no_cache: bool, + + /// Force a refresh even when cache is fresh. Implies a network fetch. + #[arg(long, global = true)] + pub force_refresh: bool, + + /// Cache TTL in seconds. Default 180. + #[arg(long, global = true, value_name = "SECS")] + pub ttl: Option, + + /// Per request timeout in seconds. Default 15. + #[arg(long, global = true, value_name = "SECS", default_value_t = 15)] + pub timeout_secs: u64, + + /// Max retries for transient failures. Default 3. + #[arg(long, global = true, value_name = "N", default_value_t = 3)] + pub retries: u8, + + /// Max parallel workspaces. Default 1, because the walk stays sequential. + #[arg(long, short = 'j', global = true, value_name = "N")] + pub concurrency: Option, + + /// Pace between workspaces in ms. Default 500. + #[arg(long, global = true, value_name = "MS", default_value_t = 500)] + pub pace_ms: u64, + + /// Restrict to these account names. + #[arg(long, short = 'a', global = true, value_name = "NAME", num_args = 1)] + pub account: Option>, + + /// Restrict to these workspace ids. + #[arg(long, short = 'w', global = true, value_name = "ID", num_args = 1)] + pub workspace: Option>, + + /// Override the User-Agent. + #[arg(long, global = true, value_name = "UA")] + pub user_agent: Option, + + /// Turn color off. + #[arg(long, global = true)] + pub no_color: bool, + + /// Force ASCII bars instead of Unicode blocks. + #[arg(long, global = true)] + pub ascii: bool, + + /// Quiet output. Still sets exit codes. + #[arg(long, short = 'q', global = true)] + pub quiet: bool, + + /// Verbosity: -v info, -vv debug, -vvv trace. + #[arg(long, short = 'v', global = true, action = ArgAction::Count)] + pub verbose: u8, +} + +#[derive(Subcommand, Clone, Debug)] +pub enum Command { + /// Pretty terminal output. The default. + Pretty, + + /// Machine-readable output for widgets and agent plugins. + Raw { + /// Output format: json or plain. + #[arg(default_value = "json")] + format: RawFormat, + }, + + /// Run the network fetch and update the cache. Print nothing. For cron. + Fetch, + + /// Cache management. + Cache { + #[command(subcommand)] + action: CacheAction, + }, + + /// Config management. + Config { + #[command(subcommand)] + action: ConfigAction, + }, +} + +#[derive(clap::ValueEnum, Clone, Debug)] +pub enum RawFormat { + Json, + Plain, +} + +#[derive(Subcommand, Clone, Debug)] +pub enum CacheAction { + /// List cached (account, workspace) entries. + Ls, + /// Clear the whole cache. + Clear, +} + +#[derive(Subcommand, Clone, Debug)] +pub enum ConfigAction { + /// Write a template config to the given path, default `ocd.toml`. + Init { path: Option }, + /// Parse and validate the config file. List accounts. No network. + Check, +} \ No newline at end of file diff --git a/src/client.rs b/src/client.rs new file mode 100644 index 0000000..95f843a --- /dev/null +++ b/src/client.rs @@ -0,0 +1,119 @@ +//! Thin HTTP client. One `reqwest::Client` instance serves all workspaces so +//! connections pool across the host (one TLS handshake for the run). +//! +//! The `get_text` method does retry and backoff for transient failures. The +//! caller fires `get_text` twice per workspace (Zen and Go) with `tokio::join`. + +use std::time::Duration; + +use crate::error::FetchError; + +/// Balance comes from the Zen page. Limits come from the Go page. +/// +/// TODO: Confirm the real base URLs and the `{workspace}` path. Replace these +/// constants once the pages are captured. +pub const ZEN_BASE_URL: &str = "https://opencode.ai/zen/{workspace}"; +pub const GO_BASE_URL: &str = "https://opencode.ai/go/{workspace}"; + +pub fn zen_url(workspace: &str) -> String { + ZEN_BASE_URL.replace("{workspace}", workspace) +} + +pub fn go_url(workspace: &str) -> String { + GO_BASE_URL.replace("{workspace}", workspace) +} + +pub struct HttpClient { + client: reqwest::Client, + retries: u8, +} + +impl HttpClient { + pub fn new(user_agent: String, timeout_secs: u64, retries: u8) -> anyhow::Result { + let client = reqwest::Client::builder() + .timeout(Duration::from_secs(timeout_secs)) + .user_agent(user_agent) + .build()?; + Ok(Self { client, retries }) + } + + /// GET a page as text with the account cookie. Retries transient errors + /// with exponential backoff and jitter. Returns the response body. + pub async fn get_text(&self, url: &str, cookie: &str) -> Result { + let mut attempt: u8 = 0; + loop { + match self.get_once(url, cookie).await { + Ok(body) => return Ok(body), + Err(e) if e.is_transient() && attempt < self.retries => { + let backoff = backoff_for(attempt); + tracing::warn!(attempt, backoff_ms = backoff.as_millis(), error = %e, "retry"); + tokio::time::sleep(backoff).await; + attempt += 1; + continue; + } + Err(e) => return Err(e), + } + } + } + + async fn get_once(&self, url: &str, cookie: &str) -> Result { + let resp = self + .client + .get(url) + .header("cookie", cookie) + .header("accept", "text/html,application/xhtml+xml,*/*;q=0.8") + .send() + .await + .map_err(|e| { + if e.is_timeout() { + FetchError::Timeout + } else { + FetchError::Send(e.to_string()) + } + })?; + + let status = resp.status().as_u16(); + if status == 429 { + return Err(FetchError::RateLimited); + } + if status == 304 { + return Err(FetchError::Send("unexpected 304".to_string())); + } + if !(200..300).contains(&status) { + return Err(FetchError::Status { + status, + url: url.to_string(), + }); + } + + resp.text() + .await + .map_err(|e| FetchError::Body(e.to_string())) + } +} + +/// Backoff for `attempt` (0-based): 500 ms, 1 s, 2 s, capped at 8 s, plus +/// jitter up to 25 per cent of each step. +fn backoff_for(attempt: u8) -> Duration { + let step = 500u64 << attempt.min(4); + let cap = 8_000u64; + let ms = step.min(cap); + let jitter = (ms / 4).max(1); + let extra = (prng() % jitter) as u64; + Duration::from_millis(ms + extra) +} + +/// A cheap, allocation-free PRNG seeded from thread time. Only feeds jitter, so +/// quality does not matter. We avoid pulling in `rand` for this. +fn prng() -> u64 { + use std::time::SystemTime; + let since_epoch = SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .map(|d| d.as_nanos()) + .unwrap_or(0) as u64; + let mut x = since_epoch.wrapping_mul(0x9E37_79B9_7F4A_7C15).max(1); + x ^= x << 13; + x ^= x >> 7; + x ^= x << 17; + x +} \ No newline at end of file diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..8fe21c0 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,149 @@ +//! Config load, `${VAR}` expansion, path discovery. + +use std::path::{Path, PathBuf}; + +use serde::Deserialize; + +use crate::error::LoadError; + +/// Top-level TOML config. Maps directly to the file in DESIGN.md. +#[derive(Debug, Clone, Deserialize, Default)] +pub struct Config { + #[serde(default)] + #[allow(dead_code)] + pub default_concurrency: Option, + #[serde(default)] + pub default_ttl_secs: Option, + #[serde(default)] + #[allow(dead_code)] + pub user_agent: Option, + #[serde(default)] + pub account: Vec, +} + +/// One opencode account. Owns its auth cookie and workspace ids. +#[derive(Debug, Clone, Deserialize)] +pub struct Account { + /// Human label shown in output. + pub name: String, + /// Value of the Cookie header. `${VAR}` expands on load. + pub cookie: String, + /// Workspace id fetched by default. + pub default_workspace: String, + /// Extra workspace ids to also fetch. + #[serde(default)] + pub extra_workspaces: Vec, +} + +impl Account { + /// All workspace ids for this account: default first, then extras, deduped + /// in order. + pub fn workspace_ids(&self) -> Vec { + let mut out: Vec = Vec::with_capacity(1 + self.extra_workspaces.len()); + out.push(self.default_workspace.clone()); + for ws in &self.extra_workspaces { + if !out.contains(ws) { + out.push(ws.clone()); + } + } + out + } +} + +/// Find a config file. Precedence: explicit path, `$OCD_CONFIG`, `./ocd.toml`, +/// then `$XDG_CONFIG_HOME/ocd/config.toml`. +pub fn discover(explicit: Option<&Path>) -> Result { + if let Some(p) = explicit { + if p.exists() { + return Ok(p.to_path_buf()); + } + return Err(LoadError::NotFound(p.to_path_buf())); + } + if let Ok(env) = std::env::var("OCD_CONFIG") { + let p = PathBuf::from(env); + if p.exists() { + return Ok(p); + } + } + let local = PathBuf::from("ocd.toml"); + if local.exists() { + return Ok(local); + } + if let Some(proj) = directories::ProjectDirs::from("", "", "ocd") { + let p = proj.config_dir().join("config.toml"); + if p.exists() { + return Ok(p); + } + } + Err(LoadError::NotFound(PathBuf::from( + "$OCD_CONFIG | ./ocd.toml | $XDG_CONFIG_HOME/ocd/config.toml", + ))) +} + +/// Load and parse a config file from `path`. Expands `${VAR}` in string +/// values. +pub fn load(path: &Path) -> Result { + let raw = std::fs::read_to_string(path).map_err(|source| LoadError::Io { + path: path.to_path_buf(), + source, + })?; + let expanded = expand_vars(&raw); + let cfg: Config = + toml::from_str(&expanded).map_err(|e| LoadError::Parse(e.to_string()))?; + Ok(cfg) +} + +/// Replace `${VAR}` (or `${VAR:-default}`) with environment values. Used on the +/// raw text before TOML parse, so values land intact and quoted. +fn expand_vars(raw: &str) -> String { + let mut out = String::with_capacity(raw.len()); + let bytes = raw.as_bytes(); + let mut i = 0; + while i < bytes.len() { + // Look for "${". + if bytes[i] == b'$' && i + 1 < bytes.len() && bytes[i + 1] == b'{' { + if let Some(end) = find_close(&bytes[i + 2..]) { + let token = &raw[i + 2..i + 2 + end]; + out.push_str(&resolve_token(token)); + i = i + 2 + end + 1; // skip "${", token, "}" + continue; + } + } + out.push(bytes[i] as char); + i += 1; + } + out +} + +/// Find the index of the closing "}". +fn find_close(rest: &[u8]) -> Option { + rest.iter().position(|&b| b == b'}') +} + +/// Resolve a `${VAR}` or `${VAR:-fallback}` token. +fn resolve_token(token: &str) -> String { + if let Some((name, default)) = token.split_once(":-") { + std::env::var(name).unwrap_or_else(|_| default.to_string()) + } else { + std::env::var(token).unwrap_or_default() + } +} + +/// The template written by `ocd config init`. +pub const TEMPLATE: &str = r#"# ocd config. See DESIGN.md. +default_concurrency = 1 +default_ttl_secs = 180 + +# One block per account. Cookie is the full Cookie header value. +# ${VAR} expands from the environment. Keep secrets out of this file. +[[account]] +name = "work" +cookie = "${OCD_COOKIE_WORK}" +default_workspace = "ws_REPLACE_ME" +extra_workspaces = [] + +[[account]] +name = "personal" +cookie = "ocd_session=...." +default_workspace = "ws_REPLACE_ME" +"#; \ No newline at end of file diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..e856754 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,63 @@ +//! Typed errors for config load, HTTP fetch, and HTML scrape. +//! +//! anyhow carries these at boundaries. thiserror keeps the variants typed so +//! the fetch loop can branch on transient versus hard failures. + +use thiserror::Error; + +/// Failures while reading or parsing the config file. +#[derive(Debug, Error)] +pub enum LoadError { + #[error("config file not found at {0}")] + NotFound(std::path::PathBuf), + + #[error("could not read config file {path}: {source}")] + Io { + path: std::path::PathBuf, + source: std::io::Error, + }, + + #[error("could not parse config as TOML: {0}")] + Parse(String), +} + +/// Failures while fetching a page over HTTP. +#[derive(Debug, Error)] +pub enum FetchError { + #[error("request timed out")] + Timeout, + + #[error("rate limited (HTTP 429)")] + RateLimited, + + #[error("HTTP {status} from {url}")] + Status { status: u16, url: String }, + + #[error("request failed: {0}")] + Send(String), + + #[error("could not read body: {0}")] + Body(String), +} + +impl FetchError { + /// True when the error is worth a retry. 5xx, timeouts, and network errors + /// qualify. 4xx (except 429, handled above) does not. + pub fn is_transient(&self) -> bool { + match self { + FetchError::Timeout | FetchError::Send(_) | FetchError::Body(_) => true, + FetchError::Status { status, .. } if *status >= 500 => true, + _ => false, + } + } +} + +/// Failures while turning a fetched HTML page into the data model. +#[derive(Debug, Error)] +pub enum ScrapeError { + #[error("opencode HTML selectors are not configured yet; see scrape.rs: {hint}")] + NotConfigured { hint: String }, + + #[error("could not parse page: {0}")] + Parse(String), +} \ No newline at end of file diff --git a/src/fetch.rs b/src/fetch.rs new file mode 100644 index 0000000..0f498df --- /dev/null +++ b/src/fetch.rs @@ -0,0 +1,185 @@ +//! The paced workspace walk. +//! +//! Targets are flattened into one ordered list of (account, workspace). The +//! walk is sequential with 500 ms pacing. Per workspace two requests run at +//! once: Zen for balance and Go for limits. Fresh cache skips the network. + +use std::time::Duration; + +use chrono::Utc; + +use crate::cache::{self, CachedRecord}; +use crate::client::{self, HttpClient}; +use crate::model::{AccountReport, Balance, Limits, ReportStatus}; +use crate::scrape; + +/// One fetch target: an account and one workspace of it, with the cookie. +#[derive(Clone)] +pub struct Target { + pub account: String, + pub workspace: String, + pub cookie: String, +} + +/// Resolved pipeline options from the CLI. +#[derive(Clone)] +pub struct FetchOptions { + pub ttl_secs: u32, + pub timeout_secs: u64, + pub retries: u8, + pub force_refresh: bool, + pub no_cache: bool, + pub workspace_pace_ms: u64, + pub account_filter: Vec, + pub workspace_filter: Vec, + pub user_agent: String, +} + +/// Build the target list from the config, applying CLI filters. +pub fn targets(cfg: &crate::config::Config, opts: &FetchOptions) -> Vec { + let mut out = Vec::new(); + for acct in &cfg.account { + if !opts.account_filter.is_empty() && !opts.account_filter.contains(&acct.name) { + continue; + } + for ws in acct.workspace_ids() { + if !opts.workspace_filter.is_empty() && !opts.workspace_filter.contains(&ws) { + continue; + } + out.push(Target { + account: acct.name.clone(), + workspace: ws, + cookie: acct.cookie.clone(), + }); + } + } + out +} + +/// Walk all targets. Returns one report per target, in config order. +pub async fn run(cfg: &crate::config::Config, opts: &FetchOptions) -> anyhow::Result> { + let http = HttpClient::new(opts.user_agent.clone(), opts.timeout_secs, opts.retries)?; + let targets = targets(cfg, opts); + + let mut reports = Vec::with_capacity(targets.len()); + for (i, tgt) in targets.iter().enumerate() { + let report = fetch_target(tgt, opts, &http).await; + reports.push(report); + + // Pace before the next workspace. Do not pace after the last. + if i + 1 < targets.len() && opts.workspace_pace_ms > 0 { + tokio::time::sleep(Duration::from_millis(opts.workspace_pace_ms)).await; + } + } + Ok(reports) +} + +/// Fetch one target. Cache short-circuits the network. +async fn fetch_target(tgt: &Target, opts: &FetchOptions, http: &HttpClient) -> AccountReport { + // Cache hit path. + if !opts.force_refresh && !opts.no_cache { + if let Some(rec) = cache::read(&tgt.account, &tgt.workspace, opts.ttl_secs) { + let mut r = rec.report; + r.status = ReportStatus::Cached; + return r; + } + } + + // Network path. Fire Zen and Go at once. + let zen_url = client::zen_url(&tgt.workspace); + let go_url = client::go_url(&tgt.workspace); + let (zen_res, go_res) = tokio::join!( + http.get_text(&zen_url, &tgt.cookie), + http.get_text(&go_url, &tgt.cookie), + ); + + let fetched_at = Some(Utc::now().to_rfc3339()); + let balance = match &zen_res { + Ok(html) => match scrape::parse_zen_balance(html) { + Ok(b) => Some(b), + Err(e) => { + tracing::warn!(account = %tgt.account, workspace = %tgt.workspace, error = %e, "zen parse failed"); + None + } + }, + Err(e) => { + tracing::warn!(account = %tgt.account, workspace = %tgt.workspace, error = %e, "zen fetch failed"); + None + } + }; + let limits = match &go_res { + Ok(html) => match scrape::parse_go_limits(html) { + Ok(l) => Some(l), + Err(e) => { + tracing::warn!(account = %tgt.account, workspace = %tgt.workspace, error = %e, "go parse failed"); + None + } + }, + Err(e) => { + tracing::warn!(account = %tgt.account, workspace = %tgt.workspace, error = %e, "go fetch failed"); + None + } + }; + + // Decide the status. RateLimited and Timeout take priority over generic + // Error so callers can react. + let status = report_status(&zen_res, &go_res, limits.as_ref(), balance.as_ref()); + + let report = AccountReport { + account: tgt.account.clone(), + workspace: tgt.workspace.clone(), + fetched_at, + status: status.clone(), + limits: limits.clone(), + balance: balance.clone(), + }; + + // Write cache only on a clean Ok, so errors never poison the cache. + if status == ReportStatus::Ok { + let record = CachedRecord { + report: report.clone(), + go_etag: None, + go_last_modified: None, + zen_etag: None, + zen_last_modified: None, + }; + if let Err(e) = cache::write(&tgt.account, &tgt.workspace, &record) { + tracing::warn!(error = %e, "cache write failed"); + } + } + + report +} + +/// Fold the two fetch results into one status. +fn report_status( + zen: &Result, + go: &Result, + limits: Option<&Limits>, + balance: Option<&Balance>, +) -> ReportStatus { + use crate::error::FetchError; + for r in [zen, go] { + match r { + Err(FetchError::RateLimited) => return ReportStatus::RateLimited, + Err(FetchError::Timeout) => return ReportStatus::Timeout, + Err(FetchError::Status { status, .. }) if *status == 429 => { + return ReportStatus::RateLimited; + } + _ => {} + } + } + for r in [zen, go] { + if let Err(e) = r { + if limits.is_none() && balance.is_none() { + return ReportStatus::Error(e.to_string()); + } + return ReportStatus::Error(e.to_string()); + } + } + if limits.is_some() || balance.is_some() { + ReportStatus::Ok + } else { + ReportStatus::Error("no limits or balance parsed".to_string()) + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..c6f58dc --- /dev/null +++ b/src/main.rs @@ -0,0 +1,195 @@ +//! ocd entry point. + +mod cache; +mod cli; +mod client; +mod config; +mod error; +mod fetch; +mod model; +mod render; +mod scrape; +mod timefmt; + +use std::process::ExitCode; + +use clap::Parser; + +use cli::{CacheAction, Cli, Command, ConfigAction, RawFormat}; +use model::{AccountReport, ReportStatus}; + +fn main() -> ExitCode { + let cli = Cli::parse(); + let rt = match tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + { + Ok(rt) => rt, + Err(e) => { + eprintln!("ocd: could not start runtime: {e}"); + return ExitCode::from(2); + } + }; + + init_tracing(cli.verbose); + + let result: anyhow::Result = + rt.block_on(async { run(cli).await }); + match result { + Ok(code) => code, + Err(e) => { + eprintln!("ocd: {e:#}"); + ExitCode::from(2) + } + } +} + +async fn run(cli: Cli) -> anyhow::Result { + let command = cli.command.clone().unwrap_or(Command::Pretty); + match command { + Command::Pretty => { + let (cfg, opts) = load_and_options(&cli)?; + let reports = fetch::run(&cfg, &opts).await?; + print_summary(&reports, !cli.quiet, || { + render::render_pretty(&reports, cli.ascii, cli.no_color || !stdout_is_tty()) + })?; + Ok(exit_code(&reports)) + } + Command::Raw { format } => { + let (cfg, opts) = load_and_options(&cli)?; + let reports = fetch::run(&cfg, &opts).await?; + print_summary(&reports, !cli.quiet, || match format { + RawFormat::Json => render::raw::render_json(&reports, true), + RawFormat::Plain => render::raw::render_plain(&reports), + })?; + Ok(exit_code(&reports)) + } + Command::Fetch => { + let (cfg, opts) = load_and_options(&cli)?; + let reports = fetch::run(&cfg, &opts).await?; + let ok = reports + .iter() + .filter(|r| matches!(r.status, ReportStatus::Ok | ReportStatus::Cached)) + .count(); + tracing::info!(ok, total = reports.len(), "fetch done"); + Ok(exit_code(&reports)) + } + Command::Cache { action } => match action { + CacheAction::Ls => { + let entries = cache::list(); + if entries.is_empty() { + println!("cache is empty"); + } else { + println!("account\tworkspace"); + for (a, w) in entries { + println!("{a}\t{w}"); + } + } + Ok(ExitCode::SUCCESS) + } + CacheAction::Clear => { + let n = cache::clear_all()?; + println!("cleared {n} entries"); + Ok(ExitCode::SUCCESS) + } + }, + Command::Config { action } => match action { + ConfigAction::Init { path } => { + let path = path.unwrap_or_else(|| std::path::PathBuf::from("ocd.toml")); + if path.exists() { + anyhow::bail!("refusing to overwrite existing {}", path.display()); + } + if let Some(p) = path.parent() { + std::fs::create_dir_all(p)?; + } + std::fs::write(&path, config::TEMPLATE)?; + println!("wrote {}", path.display()); + Ok(ExitCode::SUCCESS) + } + ConfigAction::Check => { + let path = config::discover(cli.config.as_deref())?; + let cfg = config::load(&path)?; + println!("config ok: {}", path.display()); + for a in &cfg.account { + let workspaces = a.workspace_ids(); + println!( + " account \"{}\": {} workspace(s): {}", + a.name, workspaces.len(), workspaces.join(", ") + ); + } + Ok(ExitCode::SUCCESS) + } + }, + } +} + +/// Load the config and resolve the fetch options from CLI flags plus config +/// defaults. +fn load_and_options(cli: &Cli) -> anyhow::Result<(config::Config, fetch::FetchOptions)> { + let path = config::discover(cli.config.as_deref())?; + let cfg = config::load(&path)?; + let user_agent = cli + .user_agent + .clone() + .unwrap_or_else(|| format!("ocd/{}", env!("CARGO_PKG_VERSION"))); + let ttl = cli.ttl.or(cfg.default_ttl_secs).unwrap_or(180); + let opts = fetch::FetchOptions { + ttl_secs: ttl, + timeout_secs: cli.timeout_secs, + retries: cli.retries, + force_refresh: cli.force_refresh, + no_cache: cli.no_cache, + workspace_pace_ms: cli.pace_ms, + account_filter: cli.account.clone().unwrap_or_default(), + workspace_filter: cli.workspace.clone().unwrap_or_default(), + user_agent, + }; + Ok((cfg, opts)) +} + +/// Print the rendered output unless quiet. The renderer runs lazily so quiet +/// mode does not pay for it. +fn print_summary( + _reports: &[AccountReport], + emit: bool, + render: impl FnOnce() -> String, +) -> anyhow::Result<()> { + if emit { + print!("{}", render()); + } + Ok(()) +} + +/// Exit 0 if at least one account is Ok or Cached. Exit 1 if all failed. +fn exit_code(reports: &[AccountReport]) -> ExitCode { + let any_ok = reports + .iter() + .any(|r| matches!(r.status, ReportStatus::Ok | ReportStatus::Cached)); + if any_ok { + ExitCode::SUCCESS + } else { + ExitCode::from(1) + } +} + +fn stdout_is_tty() -> bool { + use std::io::IsTerminal; + std::io::stdout().is_terminal() +} + +fn init_tracing(verbose: u8) { + use tracing_subscriber::EnvFilter; + let level = match verbose { + 0 => "warn", + 1 => "info", + 2 => "debug", + _ => "trace", + }; + let filter = + EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(level)); + tracing_subscriber::fmt() + .with_env_filter(filter) + .with_target(false) + .with_writer(std::io::stderr) + .init(); +} \ No newline at end of file diff --git a/src/model.rs b/src/model.rs new file mode 100644 index 0000000..8450036 --- /dev/null +++ b/src/model.rs @@ -0,0 +1,86 @@ +//! The normalized data model that flows from scrape to render. +//! +//! All datetimes are ISO 8601 UTC strings, for example "2025-08-31T17:00:00Z". +//! Keeping times as strings avoids serde feature churn. `timefmt` parses them +//! for human strings. + +use serde::{Deserialize, Serialize}; + +/// Bumped when the JSON shape changes. Widgets pin to this value. +pub const SCHEMA_VERSION: u32 = 1; + +/// The full machine-readable output for `ocd raw json`. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Envelope { + pub schema_version: u32, + pub generated_at: String, + pub accounts: Vec, +} + +/// One report per (account, workspace) pair. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct AccountReport { + /// Config name of the account. + pub account: String, + /// Workspace id. + pub workspace: String, + /// When the live fetch happened. None for a cache hit with no stored time. + pub fetched_at: Option, + pub status: ReportStatus, + pub limits: Option, + pub balance: Option, +} + +/// Per-workspace outcome. +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "snake_case")] +pub enum ReportStatus { + /// Fetched from the network this run. + Ok, + /// Served from local cache. + Cached, + /// HTTP 429 from the server. + RateLimited, + /// A request exceeded the timeout after retries. + Timeout, + /// Any other failure. The string explains it. + Error(String), +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Limits { + /// 5-hour window. Activity based. + pub usage_5h: UsageFrame, + /// Weekly. Resets every Monday. + pub usage_week: UsageFrame, + /// Monthly. Resets 31 days from subscription date. + pub usage_month: UsageFrame, + /// Next time the server updates these frames, if the page reports it. + pub next_update: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct UsageFrame { + pub used: f64, + pub total: f64, + /// "credits", "requests", "$", and so on. + pub unit: String, + pub resets_at: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Balance { + pub remaining: f64, + pub unit: String, +} + +impl UsageFrame { + /// Used divided by total, as a percentage 0 to 100. Zero when total is zero. + pub fn pct(&self) -> f64 { + if self.total <= 0.0 { + 0.0 + } else { + (self.used / self.total * 100.0).clamp(0.0, 100.0) + } + } +} \ No newline at end of file diff --git a/src/render/mod.rs b/src/render/mod.rs new file mode 100644 index 0000000..58adcd1 --- /dev/null +++ b/src/render/mod.rs @@ -0,0 +1,6 @@ +//! Output renderers. + +pub mod pretty; +pub mod raw; + +pub use pretty::render_pretty; \ No newline at end of file diff --git a/src/render/pretty.rs b/src/render/pretty.rs new file mode 100644 index 0000000..4c275b8 --- /dev/null +++ b/src/render/pretty.rs @@ -0,0 +1,169 @@ +//! Pretty terminal renderer. Unicode blitter-block bars, colored by usage. +//! Degrades to ASCII with `--ascii`, and to no color with `--no-color` or when +//! stdout is not a terminal. + +use anstyle::{AnsiColor, Style}; + +use crate::model::{AccountReport, ReportStatus, UsageFrame}; +use crate::timefmt; + +const EIGHTHS: [&str; 7] = ["▏", "▎", "▍", "▌", "▋", "▊", "▉"]; + +/// One report block, then the next. Reports are separated by a blank line. +pub fn render_pretty(reports: &[AccountReport], ascii: bool, no_color: bool) -> String { + let width = bar_width(); + let mut out = String::new(); + for (i, r) in reports.iter().enumerate() { + if i > 0 { + out.push('\n'); + } + out.push_str(&render_one(r, width, ascii, no_color)); + } + out +} + +fn render_one(r: &AccountReport, width: usize, ascii: bool, no_color: bool) -> String { + let mut out = String::new(); + + // Header line. + let status = paint(&status_text(&r.status), status_style(&r.status), no_color); + let fetched = r + .fetched_at + .as_deref() + .map(timefmt::relative) + .unwrap_or_else(|| "unknown".to_string()); + out.push_str(&format!("{} / {} {} fetched {}\n", r.account, r.workspace, status, fetched)); + + + if let Some(l) = &r.limits { + out.push_str(&frame_row("5h", &l.usage_5h, width, ascii, no_color, "resets")); + out.push_str(&frame_row("week", &l.usage_week, width, ascii, no_color, "resets")); + out.push_str(&frame_row("month", &l.usage_month, width, ascii, no_color, "resets")); + if let Some(nu) = &l.next_update { + out.push_str(&format!( + " next {}\n", + timefmt::absolute(nu), + )); + out.push_str(&format!( + " ({})\n", + timefmt::relative(nu), + )); + } + } else { + out.push_str(" limits unavailable\n"); + } + + if let Some(b) = &r.balance { + out.push_str(&format!( + " balance {} {} remaining\n", + fmt_num(b.remaining), + b.unit, + )); + } else { + out.push_str(" balance unavailable\n"); + } + + // Print the failure detail on an error status. + if let ReportStatus::Error(msg) = &r.status { + out.push_str(&format!(" error {msg}\n")); + } + + out +} + +fn frame_row(label: &str, frame: &UsageFrame, width: usize, ascii: bool, no_color: bool, _reset_tag: &str) -> String { + let pct = frame.pct(); + let bar = colored_bar(pct, width, ascii, no_color); + let usage = if frame.total > 0.0 { + format!("{} / {} {}", fmt_num(frame.used), fmt_num(frame.total), frame.unit) + } else { + format!("{} {}", fmt_num(frame.used), frame.unit) + }; + let resets = frame + .resets_at + .as_deref() + .map(|t| format!("resets in {}", timefmt::relative(t))) + .unwrap_or_default(); + format!( + " {:<7} {} {:<22} {:>5.1}% {}\n", + label, bar, usage, pct, resets + ) +} + +fn colored_bar(pct: f64, width: usize, ascii: bool, no_color: bool) -> String { + let total_eighths = ((pct / 100.0) * (width as f64 * 8.0)).round() as i64; + let total_eighths = total_eighths.clamp(0, (width as i64) * 8); + let whole = (total_eighths / 8) as usize; + let rem = (total_eighths % 8) as usize; + let mid = if rem > 0 { 1 } else { 0 }; + let total_filled = whole + mid; + let empty = width.saturating_sub(total_filled); + + let filled_str = if ascii { + "#".repeat(whole) + if rem > 0 { "#" } else { "" } + } else { + "█".repeat(whole) + if rem > 0 { EIGHTHS[rem - 1] } else { "" } + }; + let empty_str = if ascii { "-".repeat(empty) } else { "░".repeat(empty) }; + + let style = zone_style(pct); + format!("{}{}{}", paint(&filled_str, style, no_color), empty_str, "" ) +} + +fn zone_style(pct: f64) -> Style { + if pct >= 90.0 { + Style::new().fg_color(Some(AnsiColor::BrightRed.into())) + } else if pct >= 70.0 { + Style::new().fg_color(Some(AnsiColor::Yellow.into())) + } else { + Style::new().fg_color(Some(AnsiColor::Green.into())) + } +} + +fn status_text(s: &ReportStatus) -> String { + match s { + ReportStatus::Ok => "[ok]".to_string(), + ReportStatus::Cached => "[cached]".to_string(), + ReportStatus::RateLimited => "[rate limited]".to_string(), + ReportStatus::Timeout => "[timeout]".to_string(), + ReportStatus::Error(_) => "[error]".to_string(), + } +} + +fn status_style(s: &ReportStatus) -> Style { + match s { + ReportStatus::Ok => Style::new().fg_color(Some(AnsiColor::Green.into())), + ReportStatus::Cached => Style::new().fg_color(Some(AnsiColor::Cyan.into())), + ReportStatus::RateLimited => Style::new().fg_color(Some(AnsiColor::Yellow.into())), + ReportStatus::Timeout => Style::new().fg_color(Some(AnsiColor::Magenta.into())), + ReportStatus::Error(_) => Style::new().fg_color(Some(AnsiColor::Red.into())), + } +} + +fn paint(text: &str, style: Style, no_color: bool) -> String { + if no_color { + text.to_string() + } else { + format!("{}{}{}", style.render(), text, style.render_reset()) + } +} + +fn bar_width() -> usize { + let fallback = 20usize; + if let Some(terminal_size::Width(w)) = terminal_size::terminal_size().map(|(w, _)| w) { + (w as usize / 3).clamp(10, 44) + } else { + fallback + } +} + +fn fmt_num(n: f64) -> String { + let n = n.abs(); + if n >= 1000.0 { + format!("{:.1}k", n / 1000.0) + } else if n.fract() == 0.0 { + format!("{}", n as i64) + } else { + format!("{:.2}", n) + } +} \ No newline at end of file diff --git a/src/render/raw.rs b/src/render/raw.rs new file mode 100644 index 0000000..c20804b --- /dev/null +++ b/src/render/raw.rs @@ -0,0 +1,64 @@ +//! Machine-readable output for `ocd raw`. + +use crate::model::{AccountReport, ReportStatus, SCHEMA_VERSION, UsageFrame, Envelope}; + +/// Serialize the envelope as JSON. `pretty` switches between an indented and a +/// compact form. +pub fn render_json(reports: &[AccountReport], pretty: bool) -> String { + let env = Envelope { + schema_version: SCHEMA_VERSION, + generated_at: chrono::Utc::now().to_rfc3339(), + accounts: reports.to_vec(), + }; + if pretty { + serde_json::to_string_pretty(&env).unwrap_or_else(|e| e.to_string()) + } else { + serde_json::to_string(&env).unwrap_or_else(|e| e.to_string()) + } +} + +/// TSV-ish lines. One line per (account, workspace). Stable column order. +pub fn render_plain(reports: &[AccountReport]) -> String { + let blank = UsageFrame { + used: 0.0, + total: 0.0, + unit: String::new(), + resets_at: None, + }; + let mut out = String::new(); + out.push_str( + "account\tworkspace\tstatus\tused_5h\ttotal_5h\tunit_5h\tused_week\ttotal_week\tunit_week\tused_month\ttotal_month\tunit_month\tbalance_remaining\tbalance_unit\n", + ); + for r in reports { + let (l5, lw, lm) = r.limits.as_ref().map_or_else( + || (&blank, &blank, &blank), + |l| (&l.usage_5h, &l.usage_week, &l.usage_month), + ); + let bal = r + .balance + .as_ref() + .map(|b| (b.remaining, b.unit.as_str())) + .unwrap_or((0.0, "")); + out.push_str(&format!( + "{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\n", + r.account, + r.workspace, + status_word(&r.status), + l5.used, l5.total, l5.unit, + lw.used, lw.total, lw.unit, + lm.used, lm.total, lm.unit, + bal.0, bal.1, + )); + } + out +} + +fn status_word(s: &ReportStatus) -> &'static str { + match s { + ReportStatus::Ok => "ok", + ReportStatus::Cached => "cached", + ReportStatus::RateLimited => "rate_limited", + ReportStatus::Timeout => "timeout", + ReportStatus::Error(_) => "error", + } +} \ No newline at end of file diff --git a/src/scrape.rs b/src/scrape.rs new file mode 100644 index 0000000..51815e5 --- /dev/null +++ b/src/scrape.rs @@ -0,0 +1,60 @@ +//! HTML to model. The ONLY module coupled to the opencode page shape. +//! +//! When the page changes, edit selectors here. Transport, cache, and render do +//! not change. Each function returns the data for one page: +//! +//! - `parse_go_limits` reads the Go page. It returns `Limits`. +//! - `parse_zen_balance` reads the Zen page. It returns `Balance`. +//! +//! Both live in `scraper`. CSS selectors target small subtrees. The code below +//! is wired but the selectors are placeholders. Fill them from a captured page. +//! Until then the functions return `ScrapeError::NotConfigured`. + +use scraper::{Html, Selector}; + +use crate::error::ScrapeError; +use crate::model::{Balance, Limits, UsageFrame}; + +/// Parse the Go page HTML into limits for the three frames plus next-update. +/// +/// Plan once selectors are known: +/// 1. Selector the headline count for the 5h, week, and month frames. +/// 2. Read `used`, `total`, and `unit` from each frame block. +/// 3. Read `resets_at` per frame. The 5h frame is activity based, so the time +/// must come from the page. The week and month frames may be computed from +/// "every Monday" and "31 days from subscription" when absent. +/// 4. Read the "next update" banner into `next_update`. +pub fn parse_go_limits(html: &str) -> Result { + // `Html::parse_document` validates the HTML pipeline. Replace the rest. + let _document = Html::parse_document(html); + let _ = Selector::parse(":root").map_err(|e| ScrapeError::Parse(e.to_string()))?; + + Err(ScrapeError::NotConfigured { + hint: "fill selectors for the 5h, week, and month frames in parse_go_limits" + .to_string(), + }) +} + +/// Parse the Zen page HTML into remaining balance. +/// +/// Plan once selectors are known: selector the balance figure, the currency +/// unit, and optional time-of-fetch stamp. +pub fn parse_zen_balance(html: &str) -> Result { + let _document = Html::parse_document(html); + let _ = Selector::parse(":root").map_err(|e| ScrapeError::Parse(e.to_string()))?; + + Err(ScrapeError::NotConfigured { + hint: "fill selectors for the balance figure and unit in parse_zen_balance".to_string(), + }) +} + +/// Helper for future use: parse a frame block once the DOM is known. +#[allow(dead_code)] +fn frame(used: f64, total: f64, unit: &str, resets_at: Option) -> UsageFrame { + UsageFrame { + used, + total, + unit: unit.to_string(), + resets_at, + } +} \ No newline at end of file diff --git a/src/timefmt.rs b/src/timefmt.rs new file mode 100644 index 0000000..2f7223a --- /dev/null +++ b/src/timefmt.rs @@ -0,0 +1,52 @@ +//! Human time strings from ISO 8601 UTC timestamps. +//! +//! Used by the pretty renderer for "resets in 3h12m" and "in 47m". Parses are +//! lenient. A parse failure returns the raw string unchanged. + +use chrono::{DateTime, Utc}; + +/// Relative phrasing of a future or past timestamp. Example: "in 3h12m" or +/// "47m ago". Falls back to the input on parse failure. +pub fn relative(iso: &str) -> String { + let Some(t) = parse(iso) else { + return iso.to_string(); + }; + let now = Utc::now(); + let d = t.signed_duration_since(now); + let secs = d.num_seconds(); + + if secs.abs() < 60 { + if secs >= 0 { + "in <1m".to_string() + } else { + "<1m ago".to_string() + } + } else { + let h = secs / 3600; + let m = (secs % 3600) / 60; + let core = match (h.abs() > 0, m != 0) { + (true, true) => format!("{}h{}m", h.abs(), m.abs()), + (true, false) => format!("{}h", h.abs()), + (false, _) => format!("{}m", m.abs()), + }; + if secs >= 0 { + format!("in {core}") + } else { + format!("{core} ago") + } + } +} + +/// Absolute UTC string like "2025-08-31 17:00 UTC". +pub fn absolute(iso: &str) -> String { + let Some(t) = parse(iso) else { + return iso.to_string(); + }; + t.format("%Y-%m-%d %H:%M UTC").to_string() +} + +fn parse(iso: &str) -> Option> { + DateTime::parse_from_rfc3339(iso) + .ok() + .map(|dt| dt.with_timezone(&Utc)) +} \ No newline at end of file