diff options
| author | Christopher Warner <cwarner@kernelcode.com> | 2026-10-10 18:47:24 -0400 |
|---|---|---|
| committer | Christopher Warner <cwarner@kernelcode.com> | 2026-10-10 18:47:24 -0400 |
| commit | 5c61196f27b9342e5f25414c11df5710f956f406 (patch) | |
| tree | c81f15f54c9baa35f61ce3c71b81f1c1e7b5f590 | |
| parent | 78862ba855c6e66cac64a86c25dca6149d8fb2fd (diff) | |
| download | iphone-notes-5c61196f27b9342e5f25414c11df5710f956f406.tar.gz iphone-notes-5c61196f27b9342e5f25414c11df5710f956f406.tar.bz2 iphone-notes-5c61196f27b9342e5f25414c11df5710f956f406.tar.xz iphone-notes-5c61196f27b9342e5f25414c11df5710f956f406.zip | |
feat!: rewrite icloud-note CLI in Rust with chromiumoxide
Replace the Node/Playwright driver with a single Rust binary so create/status
stay headless without a visible browser. Move the previous implementation to
legacy/nodejs for reference.
BREAKING CHANGE: the supported CLI is the Rust `icloud-note` binary; the
Node entrypoint is no longer installed by setup.sh.
Co-authored-by: Cursor <cursoragent@cursor.com>
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | Cargo.lock | 1662 | ||||
| -rw-r--r-- | Cargo.toml | 36 | ||||
| -rw-r--r-- | README.md | 50 | ||||
| -rw-r--r-- | SKILL.md | 59 | ||||
| -rw-r--r-- | legacy/nodejs/README.md | 4 | ||||
| -rw-r--r-- | legacy/nodejs/package.json (renamed from package.json) | 0 | ||||
| -rwxr-xr-x | legacy/nodejs/scripts/icloud-note.mjs (renamed from scripts/icloud-note.mjs) | 0 | ||||
| -rw-r--r-- | legacy/nodejs/scripts/lib/note-helpers.mjs (renamed from scripts/lib/note-helpers.mjs) | 0 | ||||
| -rw-r--r-- | legacy/nodejs/tests/helpers.test.mjs (renamed from tests/helpers.test.mjs) | 0 | ||||
| -rwxr-xr-x | scripts/setup.sh | 43 | ||||
| -rw-r--r-- | src/browser.rs | 302 | ||||
| -rw-r--r-- | src/config.rs | 51 | ||||
| -rw-r--r-- | src/helpers.rs | 142 | ||||
| -rw-r--r-- | src/lib.rs | 3 | ||||
| -rw-r--r-- | src/main.rs | 176 | ||||
| -rwxr-xr-x | tests/cli.test.sh | 37 | ||||
| -rwxr-xr-x | tests/conventional-commits.test.sh | 18 | ||||
| -rwxr-xr-x | tests/run.sh | 5 |
19 files changed, 2476 insertions, 116 deletions
@@ -1,6 +1,10 @@ +# Rust +/target/ + # Local runtime (lives under ~/.config/icloud-notes — never commit) browser-profile/ storage-state.json +session.ok node_modules/ package-lock.json .env diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..9f78152 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1662 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "1.0.0" +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", +] + +[[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", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "async-tungstenite" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc405d38be14342132609f06f02acaf825ddccfe76c4824a69281e0458ebd4" +dependencies = [ + "atomic-waker", + "futures-core", + "futures-io", + "futures-task", + "futures-util", + "log", + "pin-project-lite", + "tokio", + "tungstenite", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "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" +dependencies = [ + "serde", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "chromiumoxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26ed067eb6c1f660bdb87c05efb964421d2ca262bae0296cdfe38cf0cd949a3e" +dependencies = [ + "async-tungstenite", + "base64 0.22.1", + "bytes", + "chromiumoxide_cdp", + "chromiumoxide_types", + "dunce", + "fnv", + "futures", + "futures-timer", + "pin-project-lite", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "url", + "which", + "windows-registry", +] + +[[package]] +name = "chromiumoxide_cdp" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68a6a03a7ebac4ea85308f285d6959a3e6b2ce32a0c9465dc7a7b1db0144eec7" +dependencies = [ + "chromiumoxide_pdl", + "chromiumoxide_types", + "serde", + "serde_json", +] + +[[package]] +name = "chromiumoxide_pdl" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c602dea92337bc4d824668d78c5b79c3b4ddb29b40dd7218282bbe8fd3fc2091" +dependencies = [ + "chromiumoxide_types", + "either", + "heck", + "once_cell", + "proc-macro2", + "quote", + "regex", + "serde_json", +] + +[[package]] +name = "chromiumoxide_types" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678d5146e74f16fc4a41978b275af572cd913de1f10270d2b93b6c276bc57d80" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "clap" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 3.0.7", +] + +[[package]] +name = "clap_lex" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486" + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +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", +] + +[[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.7", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[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 = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.7", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-timer" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af43fadb8a98512d547e37b4e92e0ced13e205c061b87b4623eff01d918d6968" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" +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.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c" +dependencies = [ + "atomic-waker", + "bytes", + "futures-core", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-util" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" +dependencies = [ + "base64 0.23.1", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "icloud-note" +version = "0.2.0" +dependencies = [ + "anyhow", + "chromiumoxide", + "clap", + "dirs", + "futures", + "serde", + "serde_json", + "tempfile", + "tokio", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "icu_collections" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" + +[[package]] +name = "icu_properties" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" + +[[package]] +name = "icu_provider" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73" +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 = "ipnet" +version = "2.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" + +[[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 = "js-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + +[[package]] +name = "libc" +version = "0.2.190" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78" + +[[package]] +name = "libredox" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[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 = "mio" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee" +dependencies = [ + "libc", + "wasi", + "windows-sys", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys", +] + +[[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 = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[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 = "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 = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[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.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "redox_users" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0" +dependencies = [ + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "reqwest" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16a1cfa75cc186dd73d5818e510e042e40927bccc9c236b061cea97e1eb08029" +dependencies = [ + "base64 0.23.1", + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "rustix" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[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.7", +] + +[[package]] +name = "serde_json" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1741ab7a6cc54a03a89b5d563ed60075c277d9e3cfa73ad0c1f23f23974703c6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "sha1" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[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 = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b" + +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "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.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d62a2e0561533f2ca2561d0cf27fd9fedb640a1bf2616ff5d5c80d99017faadc" +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.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.7", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.7", +] + +[[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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.53.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e95f91fcc7a621e8b030f6aa23c71fe9838ae2fb4d8118b75602a328f5144044" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys", +] + +[[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.7", +] + +[[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 = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", + "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 = "tungstenite" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8628dcc84e5a09eb3d8423d6cb682965dea9133204e8fb3efee74c2a0c259442" +dependencies = [ + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicode-ident" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" + +[[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 = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[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 = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b" +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 = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cbab34de2d982e9b48e18d216d04c4a6f641066ff19ffb699980f591ee3610e" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.7", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "which" +version = "8.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae2f2b2b816647a1cab1acc91f5bd20812d53cb344382635ec2181940c8034f" +dependencies = [ + "libc", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + +[[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.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.7", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86502bf56ac7c77571a32e2647bb2a15894565e981fb2a48d7bde2d91c965a9d" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5457206954b06561e2608c7e19cf58b1926586d999c246eebe4502f7e2039d1a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.7", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.7", +] + +[[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..902d691 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "icloud-note" +version = "0.2.0" +edition = "2021" +rust-version = "1.85" +description = "Create Apple Notes from Linux via icloud.com/notes (headless Chromium)" +license = "MIT" +publish = false + +[lib] +name = "icloud_note" +path = "src/lib.rs" + +[[bin]] +name = "icloud-note" +path = "src/main.rs" + +[dependencies] +clap = { version = "4", features = ["derive", "env"] } +tokio = { version = "1", features = ["rt-multi-thread", "macros", "time", "fs", "io-util"] } +futures = "0.3" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +anyhow = "1" +dirs = "6" +chromiumoxide = "0.9" +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } + +[dev-dependencies] +tempfile = "3" + +[profile.release] +lto = true +codegen-units = 1 +strip = true @@ -1,17 +1,16 @@ # iphone-notes Create real **Apple Notes** on an iPhone from Linux by driving -[icloud.com/notes](https://www.icloud.com/notes/) with Playwright and a saved -Apple ID browser session. +[icloud.com/notes](https://www.icloud.com/notes/) with a **Rust** CLI +(`chromiumoxide` + headless Chromium) and a saved browser profile. -Also packaged as a Cursor/Goose agent skill (`SKILL.md`) so agents can forward -prompt results to your phone as Notes. +Also packaged as a Cursor/Goose agent skill (`SKILL.md`). ## Quick start ```bash -./scripts/setup.sh -icloud-note login # Apple ID + 2FA once (graphical session) +./scripts/setup.sh # cargo build --release + Chromium + ~/.local/bin +icloud-note login # Apple ID + 2FA once (visible window) icloud-note create --title "Hello" --body "From Linux" ``` @@ -19,44 +18,45 @@ icloud-note create --title "Hello" --body "From Linux" | Command | Purpose | |---|---| -| `icloud-note setup` | Install Playwright Chromium + `~/.local/bin` wrapper | -| `icloud-note login` | **Only** command that opens a visible browser (one-time Apple ID) | -| `icloud-note status` | Headless check that the saved session can open Notes | -| `icloud-note create` | Headless create (`--title`, `--body` / `--body-file`) — no window | +| `icloud-note setup` | Build/install binary + ensure Chromium | +| `icloud-note login` | **Only** command that opens a visible browser | +| `icloud-note status` | Headless session check | +| `icloud-note create` | Headless create (`--title`, `--body` / `--body-file`) | ## Layout ```text -SKILL.md Agent instructions -scripts/icloud-note.mjs CLI -scripts/setup.sh One-time install + skill symlinks -tests/cli.test.sh Smoke tests (no Apple network required) +src/ Rust library + CLI (chromiumoxide) +scripts/setup.sh Build, install, skill symlinks +SKILL.md Agent instructions +tests/ cargo test + CLI dry-run + Conventional Commits +legacy/nodejs/ Previous Playwright implementation (reference only) ``` Runtime config (not in git): ```text ~/.config/icloud-notes/ - storage-state.json Cookies/session for headless create (private) - browser-profile/ Used only during `login` (private) - node_modules/ Playwright install + browser-profile/ Chromium user-data (private) + session.ok Marker after successful login ``` +Optional: `ICLOUD_NOTES_CHROME=/path/to/chrome` +Tests: `ICLOUD_NOTES_DRY_RUN=1` + ## Tests ```bash -npm test -# or ./tests/run.sh +# or +cargo test && ./tests/cli.test.sh && ./tests/conventional-commits.test.sh ``` -Covers: - -- Pure helpers (`tests/helpers.test.mjs`) — note formatting, auth heuristics, argv, Conventional Commits subjects -- CLI dry-run (`tests/cli.test.sh`) — help, create/status/login without a browser (`ICLOUD_NOTES_DRY_RUN=1`) -- Git history (`tests/conventional-commits.test.sh`) — every commit subject matches Conventional Commits 1.0.0 +## Why Rust -Live Apple create/status (real headless Chromium) is manual after `icloud-note login`. +Single binary, `cargo test` for helpers, and headless Chromium via CDP without a +Node/Playwright process flashing a window on Linux. The Notes web app is still +driven through JavaScript evaluation — that part is inherent to iCloud. ## License @@ -2,23 +2,24 @@ name: iphone-icloud-notes description: >- Create real Apple Notes on the user's iPhone by driving icloud.com/notes from - Linux (Playwright + saved Apple ID session). Use when the user asks to create - a note, send/forward results to their iPhone, push text to Apple Notes, or - mentions icloud.com/notes / iCloud Notes from Linux. + Linux with the Rust icloud-note CLI (headless Chromium). Use when the user asks + to create a note, send/forward results to their iPhone, push text to Apple + Notes, or mentions icloud.com/notes / iCloud Notes from Linux. --- -# iPhone notes via icloud.com/notes +# iPhone notes via icloud.com/notes (Rust) ## Goal When asked to create a note or forward prompt results to the iPhone, **create a -real Apple Note** through the iCloud Notes web app. Do not use LocalSend for this -unless the user explicitly wants file transfer instead of Notes. +real Apple Note** through the iCloud Notes web app using the **Rust** +`icloud-note` binary. Do not use LocalSend unless the user wants file transfer. ## Source of truth Repo: `~/Code/iphone-notes` -Linked as: `~/.agents/skills/iphone-icloud-notes` → that repo +Binary: `~/.local/bin/icloud-note` (from `cargo build --release`) +Skill link: `~/.agents/skills/iphone-icloud-notes` → that repo ## Helper @@ -30,42 +31,24 @@ icloud-note create --title "Title" --body-file /path/to.txt icloud-note create --title "Title" --body-file - # stdin ``` -`create` / `status` are **always headless** (no visible browser). Never pass flags -to force a window. Never run `login` unless the user must re-authenticate. - -Do **not** set `ICLOUD_NOTES_DRY_RUN=1` for real sends (tests only). - -If `icloud-note` is missing from PATH: +If missing from PATH: ```bash -node "$HOME/Code/iphone-notes/scripts/icloud-note.mjs" … +"$HOME/Code/iphone-notes/target/release/icloud-note" … +# or: cargo run --manifest-path "$HOME/Code/iphone-notes/Cargo.toml" -- … ``` -Config / session (XDG): `~/.config/icloud-notes/` -Browser profile: `~/.config/icloud-notes/browser-profile/` -(Do not commit the browser profile or Apple credentials.) - -## Agent workflow +`create` / `status` are **always headless**. Never run `login` unless the user +must re-authenticate. Do **not** set `ICLOUD_NOTES_DRY_RUN=1` for real sends. -1. **Prepare content** — title (short) + body (full text to send). -2. **`icloud-note status`** — if not logged in, tell the user to run - `icloud-note login` once (Apple ID + 2FA in a browser window), then retry. - Do not invent note creation; do not claim success without a successful create. -3. **Create** — write body to a temp file if long, then: +Config: `~/.config/icloud-notes/` (browser profile; private) - ```bash - icloud-note create --title "$TITLE" --body-file "$TMPFILE" - ``` - -4. **Report** — quote the script’s success line (title). Note syncs to iPhone - Notes when iCloud Notes is enabled on the device. - -## Rules +## Agent workflow -- Prefer this skill over LocalSend / email for “send a note to my iPhone.” -- Never store Apple ID passwords in the skill, repo, or chat logs. -- Session cookies live only under `~/.config/icloud-notes/browser-profile/` (mode keep private). -- First-line-as-title matches Apple Notes; the helper already formats title + body. +1. Prepare title + body. +2. `icloud-note status` — if not logged in, ask the user to run `icloud-note login`. +3. `icloud-note create --title "$TITLE" --body-file "$TMPFILE"` +4. Report the `created:` line. Syncs to iPhone when iCloud Notes is enabled. ## Setup (human / once) @@ -74,5 +57,5 @@ Browser profile: `~/.config/icloud-notes/browser-profile/` icloud-note login ``` -Requires a graphical session for `login` only. After that, `create` / `status` -use `~/.config/icloud-notes/storage-state.json` headlessly — no window. +Requires Rust (`cargo`) and a Chromium binary (setup can install Playwright’s +Chromium under `~/.cache/ms-playwright`). diff --git a/legacy/nodejs/README.md b/legacy/nodejs/README.md new file mode 100644 index 0000000..59be97c --- /dev/null +++ b/legacy/nodejs/README.md @@ -0,0 +1,4 @@ +# Legacy Node/Playwright implementation + +Superseded by the Rust `icloud-note` binary (`chromiumoxide`) at the repo root. +Kept for reference only; not installed by `scripts/setup.sh`. diff --git a/package.json b/legacy/nodejs/package.json index 0b3f513..0b3f513 100644 --- a/package.json +++ b/legacy/nodejs/package.json diff --git a/scripts/icloud-note.mjs b/legacy/nodejs/scripts/icloud-note.mjs index aa42e95..aa42e95 100755 --- a/scripts/icloud-note.mjs +++ b/legacy/nodejs/scripts/icloud-note.mjs diff --git a/scripts/lib/note-helpers.mjs b/legacy/nodejs/scripts/lib/note-helpers.mjs index 5dd43a0..5dd43a0 100644 --- a/scripts/lib/note-helpers.mjs +++ b/legacy/nodejs/scripts/lib/note-helpers.mjs diff --git a/tests/helpers.test.mjs b/legacy/nodejs/tests/helpers.test.mjs index 38742d8..38742d8 100644 --- a/tests/helpers.test.mjs +++ b/legacy/nodejs/tests/helpers.test.mjs diff --git a/scripts/setup.sh b/scripts/setup.sh index a4a03fa..9c64c4c 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1,36 +1,43 @@ #!/usr/bin/env bash -# Install Playwright + Chromium for icloud-note under ~/.config/icloud-notes +# Build Rust icloud-note, ensure Chromium, install to ~/.local/bin, link agent skill. set -euo pipefail REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" CONFIG_DIR="${ICLOUD_NOTES_CONFIG:-$HOME/.config/icloud-notes}" -SKILL_SCRIPT="$REPO_ROOT/scripts/icloud-note.mjs" -BIN="$HOME/.local/bin/icloud-note" +BIN_DIR="$HOME/.local/bin" +BIN="$BIN_DIR/icloud-note" AGENTS_SKILL="$HOME/.agents/skills/iphone-icloud-notes" CURSOR_SKILL="$HOME/.cursor/skills/iphone-icloud-notes" -mkdir -p "$CONFIG_DIR" "$HOME/.local/bin" "$HOME/.agents/skills" "$HOME/.cursor/skills" +mkdir -p "$CONFIG_DIR" "$BIN_DIR" "$HOME/.agents/skills" "$HOME/.cursor/skills" chmod 700 "$CONFIG_DIR" -cd "$CONFIG_DIR" -if [[ ! -f package.json ]]; then - npm init -y >/dev/null +# Prefer existing Playwright Chromium; otherwise install via npx playwright +if [[ -z "${ICLOUD_NOTES_CHROME:-}" ]]; then + if compgen -G "$HOME/.cache/ms-playwright/chromium-*/chrome-linux64/chrome" > /dev/null; then + CHROME="$(ls -1 "$HOME/.cache/ms-playwright"/chromium-*/chrome-linux64/chrome | head -1)" + echo "ok: using Playwright Chromium at $CHROME" + elif command -v npm >/dev/null 2>&1; then + echo "Installing Playwright Chromium for automation…" + mkdir -p "$CONFIG_DIR" + cd "$CONFIG_DIR" + if [[ ! -f package.json ]]; then + npm init -y >/dev/null + fi + npm install playwright@latest + npx playwright install chromium + else + echo "warn: no Chromium found and npm unavailable; install Chromium or set ICLOUD_NOTES_CHROME" >&2 + fi fi -npm install playwright@latest -npx playwright install chromium +cd "$REPO_ROOT" +cargo build --release +install -m 755 "$REPO_ROOT/target/release/icloud-note" "$BIN" -cat > "$BIN" <<EOF -#!/usr/bin/env bash -exec node "$SKILL_SCRIPT" "\$@" -EOF -chmod 755 "$BIN" "$SKILL_SCRIPT" "$REPO_ROOT/scripts/setup.sh" - -# Point agent skill dirs at this repo (source of truth) ln -sfn "$REPO_ROOT" "$AGENTS_SKILL" ln -sfn "$REPO_ROOT" "$CURSOR_SKILL" -echo "ok: playwright installed in $CONFIG_DIR" -echo "ok: wrapper $BIN" +echo "ok: installed $BIN" echo "ok: skill linked -> $REPO_ROOT" echo "Next: icloud-note login" diff --git a/src/browser.rs b/src/browser.rs new file mode 100644 index 0000000..187b535 --- /dev/null +++ b/src/browser.rs @@ -0,0 +1,302 @@ +use std::path::PathBuf; +use std::time::{Duration, Instant}; + +use anyhow::{anyhow, bail, Context, Result}; +use chromiumoxide::browser::{Browser, BrowserConfig}; +use chromiumoxide::page::Page; +use futures::StreamExt; +use serde::Deserialize; +use tokio::time::sleep; + +use crate::config::{notes_url, Paths}; +use crate::helpers::{format_note_text, looks_logged_out, LoggedOutSignals}; + +#[derive(Debug, Deserialize)] +struct ReadyFlag { + ready: bool, +} + +#[derive(Debug, Deserialize)] +struct SignalsJson { + body_text: String, + has_password_field: bool, + has_sign_in_control: bool, + has_notes_app: bool, +} + +#[derive(Debug, Deserialize)] +struct CreatedNote { + title: String, + #[serde(default)] + record_name: String, +} + +fn find_chrome() -> Result<PathBuf> { + if let Ok(p) = std::env::var("ICLOUD_NOTES_CHROME") { + let pb = PathBuf::from(&p); + if pb.is_file() { + return Ok(pb); + } + bail!("ICLOUD_NOTES_CHROME not a file: {p}"); + } + let home = dirs::home_dir().unwrap_or_else(|| PathBuf::from("/tmp")); + let candidates = [ + home.join(".cache/ms-playwright/chromium-1248/chrome-linux64/chrome"), + PathBuf::from("/usr/bin/chromium"), + PathBuf::from("/usr/bin/chromium-browser"), + PathBuf::from("/usr/bin/google-chrome"), + PathBuf::from("/usr/bin/google-chrome-stable"), + ]; + for c in candidates { + if c.is_file() { + return Ok(c); + } + } + // glob playwright chromium + let pw = home.join(".cache/ms-playwright"); + if pw.is_dir() { + if let Ok(entries) = std::fs::read_dir(&pw) { + for ent in entries.flatten() { + let name = ent.file_name().to_string_lossy().to_string(); + if name.starts_with("chromium-") { + let chrome = ent.path().join("chrome-linux64/chrome"); + if chrome.is_file() { + return Ok(chrome); + } + } + } + } + } + bail!( + "No Chrome/Chromium found. Set ICLOUD_NOTES_CHROME or install Chromium. \ + Tip: run scripts/setup.sh (uses Playwright Chromium under ~/.cache/ms-playwright)." + ) +} + +async fn launch(paths: &Paths, headed: bool) -> Result<(Browser, tokio::task::JoinHandle<()>)> { + paths.ensure()?; + let chrome = find_chrome()?; + let mut builder = BrowserConfig::builder() + .chrome_executable(chrome) + .user_data_dir(&paths.profile_dir) + .arg("--disable-blink-features=AutomationControlled") + .arg("--no-first-run") + .arg("--no-default-browser-check"); + builder = if headed { + builder.with_head() + } else { + builder + .new_headless_mode() + .arg("--ozone-platform=headless") + }; + let cfg = builder.build().map_err(|e| anyhow!(e))?; + let (browser, mut handler) = Browser::launch(cfg).await.context("launch Chrome")?; + let handle = tokio::spawn(async move { + while let Some(h) = handler.next().await { + if h.is_err() { + break; + } + } + }); + Ok((browser, handle)) +} + +async fn page_looks_logged_out(page: &Page) -> Result<bool> { + let url = page.url().await?.unwrap_or_default(); + let signals: SignalsJson = page + .evaluate( + r#"() => { + const t = (document.body?.innerText || "").slice(0, 4000); + const hasPasswordField = Boolean( + document.querySelector( + 'input[type="password"], #password_text_field, #account_name_text_field' + ) + ); + const hasSignInControl = [...document.querySelectorAll("a,button,div[role='button']")] + .some((el) => /^sign in$/i.test((el.textContent || "").trim())); + const hasNotesApp = Boolean( + document.querySelector("iframe")?.contentWindow?.NotesApp?.dataManager + ); + return { + body_text: t, + has_password_field: hasPasswordField, + has_sign_in_control: hasSignInControl, + has_notes_app: hasNotesApp + }; + }"#, + ) + .await? + .into_value() + .unwrap_or(SignalsJson { + body_text: String::new(), + has_password_field: false, + has_sign_in_control: false, + has_notes_app: false, + }); + Ok(looks_logged_out(&LoggedOutSignals { + url, + body_text: signals.body_text, + has_password_field: signals.has_password_field, + has_sign_in_control: signals.has_sign_in_control, + has_notes_app: signals.has_notes_app, + })) +} + +async fn notes_ready(page: &Page) -> Result<bool> { + let flag: ReadyFlag = page + .evaluate( + r#"() => { + const iframe = document.querySelector("iframe"); + const w = iframe?.contentWindow; + const dm = w?.NotesApp?.dataManager; + if (!dm) return { ready: false }; + const notes = dm.allNotes || dm.__CW__allNotes; + const folders = dm.allFolders || dm.__CW__allFolders || dm.folders; + const n = notes?.length || 0; + const f = folders?.length || 0; + return { ready: n > 0 || f > 0 }; + }"#, + ) + .await? + .into_value() + .unwrap_or(ReadyFlag { ready: false }); + Ok(flag.ready) +} + +async fn wait_for_notes_app(page: &Page, timeout: Duration, allow_login_wait: bool) -> Result<()> { + page.goto(notes_url()).await.context("goto Notes")?; + let deadline = Instant::now() + timeout; + let mut saw_login = false; + while Instant::now() < deadline { + if notes_ready(page).await? { + return Ok(()); + } + if page_looks_logged_out(page).await? { + saw_login = true; + if !allow_login_wait { + bail!("Not signed in. Run: icloud-note login"); + } + } + sleep(Duration::from_secs(1)).await; + } + if saw_login { + bail!("Login did not finish. Complete Apple ID sign-in in the browser window."); + } + bail!("NotesApp did not become ready. Run: icloud-note login"); +} + +async fn create_via_notes_app(page: &Page, title: &str, body: &str) -> Result<CreatedNote> { + let full = format_note_text(title, body); + // Pass text via JSON.stringify embedded in JS to avoid injection issues + let text_js = serde_json::to_string(&full)?; + let expr = format!( + r#"async () => {{ + const text = {text_js}; + const iframe = document.querySelector("iframe"); + const w = iframe?.contentWindow; + const app = w?.NotesApp; + if (!app?.dataManager) throw new Error("NotesApp unavailable"); + const dataManager = app.dataManager; + const mv = app.mainViewModel; + const noteList = dataManager.allNotes || dataManager.__CW__allNotes; + const sample = + mv?.selectedNote || + (noteList?.objectAt ? noteList.objectAt(0) : noteList?.[0]) || + null; + const Note = sample?.constructor; + if (!Note?.createNoteWithTitleText && !Note?.createEmptyNote) {{ + throw new Error("Could not find Note.createNoteWithTitleText — UI may have changed"); + }} + const folderList = + dataManager.allFolders || dataManager.__CW__allFolders || dataManager.folders; + const folder = + mv?.selectedFolder || + dataManager.defaultFolder || + dataManager.inboxFolder || + (folderList?.objectAt ? folderList.objectAt(0) : folderList?.[0]) || + null; + if (!folder) throw new Error("Could not resolve a Notes folder"); + let note; + if (typeof Note.createNoteWithTitleText === "function") {{ + note = Note.createNoteWithTitleText(text, folder); + }} else {{ + note = Note.createEmptyNote(folder); + note.userDidChangeTopoText?.(text); + if (note.Title !== undefined) note.Title = text.split("\n")[0] || "Note"; + }} + if (typeof dataManager.userDidCreateNote === "function") {{ + dataManager.userDidCreateNote(note); + }} + await note.save(true); + return {{ + title: String(note.Title || text.split("\n")[0] || "(untitled)"), + record_name: String(note.recordName || note.id || "") + }}; + }}"# + ); + let note: CreatedNote = page.evaluate(expr).await?.into_value()?; + Ok(note) +} + +fn mark_session(paths: &Paths) -> Result<()> { + std::fs::write(&paths.marker_path, b"ok\n")?; + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + let _ = std::fs::set_permissions(&paths.marker_path, std::fs::Permissions::from_mode(0o600)); + } + Ok(()) +} + +pub async fn cmd_login(paths: &Paths) -> Result<()> { + if std::env::var_os("DISPLAY").is_none() && std::env::var_os("WAYLAND_DISPLAY").is_none() { + bail!("login needs a graphical session (DISPLAY or WAYLAND_DISPLAY)."); + } + eprintln!("Opening Chromium for Apple ID sign-in (one-time)…"); + eprintln!("Sign in, complete 2FA, wait until Notes loads."); + let (mut browser, handle) = launch(paths, true).await?; + let page = browser.new_page(notes_url()).await?; + wait_for_notes_app(&page, Duration::from_secs(600), true).await?; + mark_session(paths)?; + println!("ok: session saved under {}", paths.profile_dir.display()); + println!("ok: create/status will run headless (no window)"); + browser.close().await?; + let _ = handle.await; + Ok(()) +} + +pub async fn cmd_status(paths: &Paths) -> Result<()> { + if !paths.has_session() { + bail!("No saved session. Run: icloud-note login"); + } + let (mut browser, handle) = launch(paths, false).await?; + let page = browser.new_page("about:blank").await?; + wait_for_notes_app(&page, Duration::from_secs(20), false).await?; + println!("ok: logged in to icloud.com/notes (headless)"); + browser.close().await?; + let _ = handle.await; + Ok(()) +} + +pub async fn cmd_create(paths: &Paths, title: &str, body: &str) -> Result<()> { + if !paths.has_session() { + bail!("No saved session. Run: icloud-note login"); + } + let (mut browser, handle) = launch(paths, false).await?; + let page = browser.new_page("about:blank").await?; + wait_for_notes_app(&page, Duration::from_secs(90), false).await?; + let note = create_via_notes_app(&page, title, body) + .await + .context("create note via NotesApp")?; + sleep(Duration::from_secs(2)).await; + mark_session(paths)?; + if note.record_name.is_empty() { + println!("created: {}", note.title); + } else { + println!("created: {} ({})", note.title, note.record_name); + } + browser.close().await?; + let _ = handle.await; + Ok(()) +} + diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..dbd2136 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,51 @@ +use std::path::PathBuf; + +#[derive(Debug, Clone)] +pub struct Paths { + pub config_dir: PathBuf, + pub profile_dir: PathBuf, + pub marker_path: PathBuf, +} + +impl Paths { + pub fn resolve() -> Self { + let config_dir = std::env::var_os("ICLOUD_NOTES_CONFIG") + .map(PathBuf::from) + .unwrap_or_else(|| { + dirs::config_dir() + .unwrap_or_else(|| PathBuf::from(".").join(".config")) + .join("icloud-notes") + }); + Self { + profile_dir: config_dir.join("browser-profile"), + marker_path: config_dir.join("session.ok"), + config_dir, + } + } + + pub fn ensure(&self) -> std::io::Result<()> { + std::fs::create_dir_all(&self.config_dir)?; + std::fs::create_dir_all(&self.profile_dir)?; + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + let _ = std::fs::set_permissions(&self.config_dir, std::fs::Permissions::from_mode(0o700)); + let _ = std::fs::set_permissions(&self.profile_dir, std::fs::Permissions::from_mode(0o700)); + } + Ok(()) + } + + pub fn has_session(&self) -> bool { + self.marker_path.is_file() + || self.profile_dir.join("Default").is_dir() + || self.profile_dir.join("Cookies").is_file() + } +} + +pub fn dry_run() -> bool { + matches!(std::env::var("ICLOUD_NOTES_DRY_RUN").as_deref(), Ok("1")) +} + +pub fn notes_url() -> &'static str { + "https://www.icloud.com/notes/" +} diff --git a/src/helpers.rs b/src/helpers.rs new file mode 100644 index 0000000..c6a8163 --- /dev/null +++ b/src/helpers.rs @@ -0,0 +1,142 @@ +//! Pure helpers (no Chromium). + +/// Join title + body the way Apple Notes expects (first line = title). +pub fn format_note_text(title: &str, body: &str) -> String { + match (title.is_empty(), body.is_empty()) { + (true, true) => String::new(), + (false, true) => title.to_string(), + (true, false) => body.to_string(), + (false, false) => format!("{title}\n\n{body}"), + } +} + +pub fn is_apple_auth_url(url: &str) -> bool { + url.contains("idmsa.apple.com") || url.contains("appleid.apple.com") +} + +#[derive(Debug, Default, Clone)] +pub struct LoggedOutSignals { + pub url: String, + pub body_text: String, + pub has_password_field: bool, + pub has_sign_in_control: bool, + pub has_notes_app: bool, +} + +pub fn looks_logged_out(s: &LoggedOutSignals) -> bool { + if is_apple_auth_url(&s.url) { + return true; + } + let t = s.body_text.chars().take(4000).collect::<String>(); + if t.to_ascii_lowercase().contains("sign in to icloud") { + return true; + } + if s.has_password_field { + return true; + } + if s.has_sign_in_control && !s.has_notes_app { + return true; + } + false +} + +pub fn require_create_content(title: &str, body: &str) -> Result<(String, String), String> { + let title = title.to_string(); + let body = body.trim_end().to_string(); + if title.is_empty() && body.is_empty() { + return Err( + "Provide --title and/or --body / --body-file / stdin".to_string(), + ); + } + Ok((title, body)) +} + +/// Conventional Commits 1.0.0 subject line (no regex crate). +pub fn is_conventional_commit_subject(subject: &str) -> bool { + let line = subject.trim(); + let types = [ + "feat", "fix", "docs", "style", "refactor", "perf", "test", "build", "ci", "chore", + "revert", + ]; + let Some((ty, rest)) = line.split_once(':') else { + return false; + }; + if !rest.starts_with(' ') || rest.len() < 2 { + return false; + } + let ty = ty.trim_end_matches('!'); + if let Some((base, scope)) = ty.split_once('(') { + if !types.contains(&base) { + return false; + } + scope.ends_with(')') + && scope.len() > 1 + && scope[..scope.len() - 1] + .chars() + .all(|c| c.is_ascii_alphanumeric() || "/._-".contains(c)) + } else { + types.contains(&ty) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn format_joins_title_body() { + assert_eq!(format_note_text("Hi", "body"), "Hi\n\nbody"); + assert_eq!(format_note_text("Hi", ""), "Hi"); + assert_eq!(format_note_text("", "body"), "body"); + } + + #[test] + fn auth_urls() { + assert!(is_apple_auth_url("https://idmsa.apple.com/appleauth/auth")); + assert!(is_apple_auth_url("https://appleid.apple.com/")); + assert!(!is_apple_auth_url("https://www.icloud.com/notes/")); + } + + #[test] + fn logged_out_signals() { + assert!(looks_logged_out(&LoggedOutSignals { + body_text: "Sign in to iCloud to continue".into(), + ..Default::default() + })); + assert!(looks_logged_out(&LoggedOutSignals { + has_password_field: true, + ..Default::default() + })); + assert!(looks_logged_out(&LoggedOutSignals { + has_sign_in_control: true, + has_notes_app: false, + ..Default::default() + })); + assert!(!looks_logged_out(&LoggedOutSignals { + has_sign_in_control: true, + has_notes_app: true, + ..Default::default() + })); + } + + #[test] + fn create_content_required() { + assert!(require_create_content("", "").is_err()); + let (t, b) = require_create_content("T", "hi\n\n").unwrap(); + assert_eq!(t, "T"); + assert_eq!(b, "hi"); + } + + #[test] + fn conventional_subjects() { + assert!(is_conventional_commit_subject( + "feat: add icloud.com/notes helper and agent skill" + )); + assert!(is_conventional_commit_subject( + "fix: run create/status headless without a visible browser" + )); + assert!(is_conventional_commit_subject("feat(notes): add dry-run")); + assert!(!is_conventional_commit_subject("Added tests")); + assert!(!is_conventional_commit_subject("FIX: caps type")); + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..e6752a2 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,3 @@ +pub mod browser; +pub mod config; +pub mod helpers; diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..ccd21e2 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,176 @@ +use std::io::{self, Read}; +use std::path::PathBuf; +use std::process::ExitCode; + +use anyhow::{bail, Context, Result}; +use clap::{Parser, Subcommand}; + +use icloud_note::browser; +use icloud_note::config::{dry_run, Paths}; +use icloud_note::helpers::{format_note_text, require_create_content}; + +#[derive(Parser, Debug)] +#[command( + name = "icloud-note", + about = "Create Apple Notes from Linux via icloud.com/notes", + long_about = "create/status always run headless (no window).\n\ + login is the only command that opens a visible browser." +)] +struct Cli { + #[command(subcommand)] + cmd: Option<Command>, +} + +#[derive(Subcommand, Debug)] +enum Command { + /// Install Chromium deps + install this binary to ~/.local/bin + Setup, + /// Headless check that the saved session can open Notes + Status, + /// One-time Apple ID sign-in (visible browser) + Login, + /// Headless create a note + Create { + /// Note title (or positional) + #[arg(long)] + title: Option<String>, + /// Note body text + #[arg(long)] + body: Option<String>, + /// Read body from file (`-` = stdin) + #[arg(long = "body-file")] + body_file: Option<PathBuf>, + /// Positional title fallback + #[arg(value_name = "TITLE")] + positional_title: Option<String>, + }, +} + +#[tokio::main] +async fn main() -> ExitCode { + tracing_subscriber::fmt() + .with_env_filter( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("warn")), + ) + .with_writer(std::io::stderr) + .init(); + + match run().await { + Ok(()) => ExitCode::SUCCESS, + Err(e) => { + eprintln!("{e:#}"); + ExitCode::FAILURE + } + } +} + +async fn run() -> Result<()> { + let cli = Cli::parse(); + let paths = Paths::resolve(); + + let Some(cmd) = cli.cmd else { + print_help(&paths); + return Ok(()); + }; + + match cmd { + Command::Setup => run_setup(), + Command::Status => { + if dry_run() { + if !paths.has_session() { + bail!("not ready: No saved session. Run: icloud-note login"); + } + println!("ok: dry-run status (would check Notes headless)"); + return Ok(()); + } + browser::cmd_status(&paths) + .await + .map_err(|e| anyhow::anyhow!("not ready: {e}")) + } + Command::Login => { + if dry_run() { + bail!("login dry-run: would open a visible browser (refusing)"); + } + browser::cmd_login(&paths).await + } + Command::Create { + title, + body, + body_file, + positional_title, + } => { + let title = title.or(positional_title).unwrap_or_default(); + let body_raw = read_body(body, body_file)?; + let (title, body) = require_create_content(&title, &body_raw) + .map_err(|e| anyhow::anyhow!(e))?; + if dry_run() { + let text = format_note_text(&title, &body); + println!( + "dry-run: would create note title={} chars={}", + serde_json::to_string(&title)?, + text.len() + ); + return Ok(()); + } + browser::cmd_create(&paths, &title, &body).await + } + } +} + +fn read_body(body: Option<String>, body_file: Option<PathBuf>) -> Result<String> { + if let Some(path) = body_file { + if path.as_os_str() == "-" { + let mut s = String::new(); + io::stdin().read_to_string(&mut s)?; + return Ok(s); + } + return Ok(std::fs::read_to_string(&path) + .with_context(|| format!("read body-file {}", path.display()))?); + } + if let Some(b) = body { + return Ok(b); + } + if !atty_stdin() { + let mut s = String::new(); + io::stdin().read_to_string(&mut s)?; + return Ok(s); + } + Ok(String::new()) +} + +fn atty_stdin() -> bool { + // avoid libc dep: treat non-tty as piped when `isatty` unavailable via std + std::io::IsTerminal::is_terminal(&io::stdin()) +} + +fn print_help(paths: &Paths) { + println!( + "Usage: + icloud-note setup + icloud-note status + icloud-note login # only command that opens a visible browser + icloud-note create --title TITLE [--body TEXT | --body-file PATH|-] + +Config: {} +Profile: {} +create/status always run headless (no window). +", + paths.config_dir.display(), + paths.profile_dir.display() + ); +} + +fn run_setup() -> Result<()> { + let script = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("scripts/setup.sh"); + if !script.is_file() { + bail!("setup.sh not found at {}", script.display()); + } + let status = std::process::Command::new(&script) + .status() + .with_context(|| format!("run {}", script.display()))?; + if !status.success() { + bail!("setup.sh failed with {status}"); + } + Ok(()) +} diff --git a/tests/cli.test.sh b/tests/cli.test.sh index d3f8d88..6aeef87 100755 --- a/tests/cli.test.sh +++ b/tests/cli.test.sh @@ -3,7 +3,9 @@ set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" -CLI=(node "$ROOT/scripts/icloud-note.mjs") +cd "$ROOT" +cargo build -q +CLI=("$ROOT/target/debug/icloud-note") TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT export ICLOUD_NOTES_CONFIG="$TMP/cfg" @@ -13,14 +15,17 @@ fail() { echo "FAIL: $*" >&2; exit 1; } pass() { echo "ok: $*"; } # --- help --- -for flag in help -h --help; do - out="$("${CLI[@]}" "$flag" 2>&1)" || fail "help ($flag) exited non-zero" - [[ "$out" == *"icloud-note create"* ]] || fail "help missing create ($flag)" -done -out="$("${CLI[@]}" help 2>&1)" +out="$("${CLI[@]}" 2>&1)" || fail "no-args help failed" +[[ "$out" == *"icloud-note create"* ]] || fail "help missing create: $out" [[ "$out" == *"headless"* ]] || fail "help should say create/status are headless" [[ "$out" != *"--headed"* ]] || fail "help must not advertise --headed" [[ "$out" == *"$ICLOUD_NOTES_CONFIG"* ]] || fail "help should show ICLOUD_NOTES_CONFIG path" +set +e +out_h="$("${CLI[@]}" -h 2>&1)" +code_h=$? +set -e +[[ "$code_h" -eq 0 ]] || fail "-h exited $code_h" +[[ "$out_h" == *"create"* || "$out_h" == *"Create"* ]] || fail "-h missing create" pass "help" # --- unknown --- @@ -29,7 +34,6 @@ err="$("${CLI[@]}" nosuchcmd 2>&1)" code=$? set -e [[ "$code" -ne 0 ]] || fail "unknown command should fail" -[[ "$err" == *"Unknown command"* ]] || fail "unknown command message" pass "unknown command" # --- create validation --- @@ -38,10 +42,10 @@ err="$("${CLI[@]}" create 2>&1)" code=$? set -e [[ "$code" -ne 0 ]] || fail "create without content should fail" -[[ "$err" == *"Provide --title"* ]] || fail "create empty message" +[[ "$err" == *"Provide --title"* ]] || fail "create empty message: $err" pass "create requires content" -# --- create dry-run (no browser) --- +# --- create dry-run --- out="$("${CLI[@]}" create --title "T" --body "hello" 2>&1)" || fail "create dry-run failed" [[ "$out" == *'dry-run: would create note title="T"'* ]] || fail "create dry-run output: $out" [[ "$out" == *"chars="* ]] || fail "create dry-run missing chars" @@ -71,11 +75,10 @@ set -e [[ "$err" == *"No saved session"* ]] || fail "status empty message: $err" pass "status dry-run without session" -mkdir -p "$ICLOUD_NOTES_CONFIG" -echo '{"cookies":[]}' > "$ICLOUD_NOTES_CONFIG/storage-state.json" -out="$("${CLI[@]}" status 2>&1)" || fail "status dry-run with state failed" +mkdir -p "$ICLOUD_NOTES_CONFIG/browser-profile/Default" +out="$("${CLI[@]}" status 2>&1)" || fail "status dry-run with profile failed" [[ "$out" == *"dry-run status"* ]] || fail "status dry-run ok: $out" -pass "status dry-run with session file" +pass "status dry-run with session profile" # --- login dry-run must not open a browser --- set +e @@ -86,7 +89,7 @@ set -e [[ "$err" == *"dry-run"* ]] || fail "login dry-run message: $err" pass "login dry-run refuses browser" -# --- login without display (real path, no dry-run) --- +# --- login without display --- unset ICLOUD_NOTES_DRY_RUN set +e err="$(env -u DISPLAY -u WAYLAND_DISPLAY ICLOUD_NOTES_CONFIG="$ICLOUD_NOTES_CONFIG" \ @@ -97,13 +100,11 @@ set -e [[ "$err" == *"graphical session"* ]] || fail "login DISPLAY message: $err" pass "login requires graphical session" -# --- setup script present --- [[ -x "$ROOT/scripts/setup.sh" ]] || fail "setup.sh not executable" pass "setup.sh executable" -# --- skill / docs mention headless --- rg -q 'headless' "$ROOT/SKILL.md" || fail "SKILL.md should mention headless" -rg -q 'headless' "$ROOT/README.md" || fail "README.md should mention headless" -pass "docs mention headless" +rg -q 'Rust|cargo' "$ROOT/README.md" || fail "README should mention Rust" +pass "docs" echo "All cli tests passed." diff --git a/tests/conventional-commits.test.sh b/tests/conventional-commits.test.sh index 042b819..12c1f46 100755 --- a/tests/conventional-commits.test.sh +++ b/tests/conventional-commits.test.sh @@ -8,7 +8,6 @@ cd "$ROOT" fail() { echo "FAIL: $*" >&2; exit 1; } pass() { echo "ok: $*"; } -# Same rule as scripts/lib/note-helpers.mjs isConventionalCommitSubject RE='^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-zA-Z0-9._/-]+\))?!?: .+' mapfile -t SUBJECTS < <(git log --format=%s) @@ -25,18 +24,9 @@ for s in "${SUBJECTS[@]}"; do done [[ "$bad" -eq 0 ]] || fail "one or more commits are not Conventional Commits" -# Unit helper agrees with git history -node --input-type=module -e ' -import { isConventionalCommitSubject } from "./scripts/lib/note-helpers.mjs"; -import { execSync } from "node:child_process"; -const subjects = execSync("git log --format=%s", { encoding: "utf8" }) - .trim().split("\n").filter(Boolean); -for (const s of subjects) { - if (!isConventionalCommitSubject(s)) { - console.error("helper rejected:", s); - process.exit(1); - } -} -' +# Cross-check with Rust helper unit tests +out="$(cargo test -q --lib helpers::tests::conventional_subjects -- --exact 2>&1)" +echo "$out" +echo "$out" | rg -q '1 passed' || fail "Rust conventional_subjects test did not run/pass" echo "All conventional-commit checks passed." diff --git a/tests/run.sh b/tests/run.sh index 6d845df..f34fd3e 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -1,11 +1,10 @@ #!/usr/bin/env bash -# Full test suite for iphone-notes. set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" -echo "== helpers (node:test) ==" -node --test tests/helpers.test.mjs +echo "== cargo test ==" +cargo test -q echo "== cli ==" ./tests/cli.test.sh |
