Skip to content

An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.

Rust

feat: make rusty-claude-cli usable end-to-end

Yeachan-Heo3faf8dd36561
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index a77b9960..308a108a 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -2,6 +2,92 @@
# 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 = "api"
+version = "0.1.0"
+dependencies = [
+ "reqwest",
+ "serde",
+ "serde_json",
+ "tokio",
+]
+
+[[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 = "bincode"
+version = "1.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "bitflags"
+version = "2.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
+
+[[package]]
+name = "bumpalo"
+version = "3.20.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
+
+[[package]]
+name = "bytes"
+version = "1.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
+
+[[package]]
+name = "cc"
+version = "1.2.58"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1e928d4b69e3077709075a938a05ffbedfa53a84c8f766efbf8220bb1ff60e1"
+dependencies = [
+ "find-msvc-tools",
+ "shlex",
+]
+
+[[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.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
+
[[package]]
name = "commands"
version = "0.1.0"
@@ -19,18 +105,1807 @@ dependencies = [
]
[[package]]
-name = "runtime"
-version = "0.1.0"
+name = "crc32fast"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
+dependencies = [
+ "cfg-if",
+]
[[package]]
-name = "rusty-claude-cli"
-version = "0.1.0"
+name = "crossterm"
+version = "0.28.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
dependencies = [
- "commands",
- "compat-harness",
- "runtime",
+ "bitflags",
+ "crossterm_winapi",
+ "mio",
+ "parking_lot",
+ "rustix",
+ "signal-hook",
+ "signal-hook-mio",
+ "winapi",
]
[[package]]
-name = "tools"
-version = "0.1.0"
+name = "crossterm_winapi"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "deranged"
+version = "0.5.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
+dependencies = [
+ "powerfmt",
+]
+
+[[package]]
+name = "displaydoc"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[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 = "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 = "futures-channel"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d"
+dependencies = [
+ "futures-core",
+]
+
+[[package]]
+name = "futures-core"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d"
+
+[[package]]
+name = "futures-task"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393"
+
+[[package]]
+name = "futures-util"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6"
+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.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
+dependencies = [
+ "cfg-if",
+ "js-sys",
+ "libc",
+ "r-efi",
+ "wasip2",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "glob"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
+
+[[package]]
+name = "hashbrown"
+version = "0.16.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
+
+[[package]]
+name = "http"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a"
+dependencies = [
+ "bytes",
+ "itoa",
+]
+
+[[package]]
+name = "http-body"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
+dependencies = [
+ "bytes",
+ "http",
+]
+
+[[package]]
+name = "http-body-util"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a"
+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.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca"
+dependencies = [
+ "atomic-waker",
+ "bytes",
+ "futures-channel",
+ "futures-core",
+ "http",
+ "http-body",
+ "httparse",
+ "itoa",
+ "pin-project-lite",
+ "smallvec",
+ "tokio",
+ "want",
+]
+
+[[package]]
+name = "hyper-rustls"
+version = "0.27.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58"
+dependencies = [
+ "http",
+ "hyper",
+ "hyper-util",
+ "rustls",
+ "rustls-pki-types",
+ "tokio",
+ "tokio-rustls",
+ "tower-service",
+ "webpki-roots",
+]
+
+[[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 = "icu_collections"
+version = "2.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43"
+dependencies = [
+ "displaydoc",
+ "potential_utf",
+ "yoke",
+ "zerofrom",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_locale_core"
+version = "2.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6"
+dependencies = [
+ "displaydoc",
+ "litemap",
+ "tinystr",
+ "writeable",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer"
+version = "2.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599"
+dependencies = [
+ "icu_collections",
+ "icu_normalizer_data",
+ "icu_properties",
+ "icu_provider",
+ "smallvec",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer_data"
+version = "2.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a"
+
+[[package]]
+name = "icu_properties"
+version = "2.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec"
+dependencies = [
+ "icu_collections",
+ "icu_locale_core",
+ "icu_properties_data",
+ "icu_provider",
+ "zerotrie",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_properties_data"
+version = "2.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af"
+
+[[package]]
+name = "icu_provider"
+version = "2.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614"
+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.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344"
+dependencies = [
+ "icu_normalizer",
+ "icu_properties",
+]
+
+[[package]]
+name = "indexmap"
+version = "2.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
+dependencies = [
+ "equivalent",
+ "hashbrown",
+]
+
+[[package]]
+name = "ipnet"
+version = "2.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2"
+
+[[package]]
+name = "iri-string"
+version = "0.7.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "25e659a4bb38e810ebc252e53b5814ff908a8c58c2a9ce2fae1bbec24cbf4e20"
+dependencies = [
+ "memchr",
+ "serde",
+]
+
+[[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.93"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "797146bb2677299a1eb6b7b50a890f4c361b29ef967addf5b2fa45dae1bb6d7d"
+dependencies = [
+ "cfg-if",
+ "futures-util",
+ "once_cell",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.183"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
+
+[[package]]
+name = "linked-hash-map"
+version = "0.5.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
+
+[[package]]
+name = "litemap"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77"
+
+[[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.29"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
+
+[[package]]
+name = "lru-slab"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154"
+
+[[package]]
+name = "memchr"
+version = "2.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
+
+[[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.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1"
+dependencies = [
+ "libc",
+ "log",
+ "wasi",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "num-conv"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967"
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+
+[[package]]
+name = "onig"
+version = "6.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "336b9c63443aceef14bea841b899035ae3abe89b7c486aaf4c5bd8aafedac3f0"
+dependencies = [
+ "bitflags",
+ "libc",
+ "once_cell",
+ "onig_sys",
+]
+
+[[package]]
+name = "onig_sys"
+version = "69.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c7f86c6eef3d6df15f23bcfb6af487cbd2fed4e5581d58d5bf1f5f8b7f6727dc"
+dependencies = [
+ "cc",
+ "pkg-config",
+]
+
+[[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 = "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.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
+
+[[package]]
+name = "plist"
+version = "1.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07"
+dependencies = [
+ "base64",
+ "indexmap",
+ "quick-xml",
+ "serde",
+ "time",
+]
+
+[[package]]
+name = "potential_utf"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77"
+dependencies = [
+ "zerovec",
+]
+
+[[package]]
+name = "powerfmt"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
+
+[[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.106"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "pulldown-cmark"
+version = "0.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7c3a14896dfa883796f1cb410461aef38810ea05f2b2c33c5aded3649095fdad"
+dependencies = [
+ "bitflags",
+ "getopts",
+ "memchr",
+ "pulldown-cmark-escape",
+ "unicase",
+]
+
+[[package]]
+name = "pulldown-cmark-escape"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae"
+
+[[package]]
+name = "quick-xml"
+version = "0.38.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b66c2058c55a409d601666cffe35f04333cf1013010882cec174a7467cd4e21c"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "quinn"
+version = "0.11.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20"
+dependencies = [
+ "bytes",
+ "cfg_aliases",
+ "pin-project-lite",
+ "quinn-proto",
+ "quinn-udp",
+ "rustc-hash",
+ "rustls",
+ "socket2",
+ "thiserror",
+ "tokio",
+ "tracing",
+ "web-time",
+]
+
+[[package]]
+name = "quinn-proto"
+version = "0.11.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098"
+dependencies = [
+ "bytes",
+ "getrandom 0.3.4",
+ "lru-slab",
+ "rand",
+ "ring",
+ "rustc-hash",
+ "rustls",
+ "rustls-pki-types",
+ "slab",
+ "thiserror",
+ "tinyvec",
+ "tracing",
+ "web-time",
+]
+
+[[package]]
+name = "quinn-udp"
+version = "0.5.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd"
+dependencies = [
+ "cfg_aliases",
+ "libc",
+ "once_cell",
+ "socket2",
+ "tracing",
+ "windows-sys 0.60.2",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
+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 = "rand"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
+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_syscall"
+version = "0.5.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "regex"
+version = "1.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
+
+[[package]]
+name = "reqwest"
+version = "0.12.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147"
+dependencies = [
+ "base64",
+ "bytes",
+ "futures-core",
+ "http",
+ "http-body",
+ "http-body-util",
+ "hyper",
+ "hyper-rustls",
+ "hyper-util",
+ "js-sys",
+ "log",
+ "percent-encoding",
+ "pin-project-lite",
+ "quinn",
+ "rustls",
+ "rustls-pki-types",
+ "serde",
+ "serde_json",
+ "serde_urlencoded",
+ "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 = "runtime"
+version = "0.1.0"
+dependencies = [
+ "glob",
+ "regex",
+ "serde",
+ "serde_json",
+ "tokio",
+ "walkdir",
+]
+
+[[package]]
+name = "rustc-hash"
+version = "2.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe"
+
+[[package]]
+name = "rustix"
+version = "0.38.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "rustls"
+version = "0.23.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4"
+dependencies = [
+ "once_cell",
+ "ring",
+ "rustls-pki-types",
+ "rustls-webpki",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-pki-types"
+version = "1.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd"
+dependencies = [
+ "web-time",
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-webpki"
+version = "0.103.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df33b2b81ac578cabaf06b89b0631153a3f416b0a886e8a7a1707fb51abbd1ef"
+dependencies = [
+ "ring",
+ "rustls-pki-types",
+ "untrusted",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
+
+[[package]]
+name = "rusty-claude-cli"
+version = "0.1.0"
+dependencies = [
+ "api",
+ "commands",
+ "compat-harness",
+ "crossterm",
+ "pulldown-cmark",
+ "runtime",
+ "serde_json",
+ "syntect",
+ "tokio",
+ "tools",
+]
+
+[[package]]
+name = "ryu"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
+
+[[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 = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+[[package]]
+name = "serde"
+version = "1.0.228"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.228"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.228"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.149"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
+dependencies = [
+ "itoa",
+ "memchr",
+ "serde",
+ "serde_core",
+ "zmij",
+]
+
+[[package]]
+name = "serde_urlencoded"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
+dependencies = [
+ "form_urlencoded",
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "shlex"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
+
+[[package]]
+name = "signal-hook"
+version = "0.3.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
+dependencies = [
+ "libc",
+ "signal-hook-registry",
+]
+
+[[package]]
+name = "signal-hook-mio"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc"
+dependencies = [
+ "libc",
+ "mio",
+ "signal-hook",
+]
+
+[[package]]
+name = "signal-hook-registry"
+version = "1.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
+dependencies = [
+ "errno",
+ "libc",
+]
+
+[[package]]
+name = "simd-adler32"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
+
+[[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.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
+
+[[package]]
+name = "socket2"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"
+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 = "subtle"
+version = "2.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
+
+[[package]]
+name = "syn"
+version = "2.0.117"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
+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",
+]
+
+[[package]]
+name = "syntect"
+version = "5.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "656b45c05d95a5704399aeef6bd0ddec7b2b3531b7c9e900abbf7c4d2190c925"
+dependencies = [
+ "bincode",
+ "flate2",
+ "fnv",
+ "once_cell",
+ "onig",
+ "plist",
+ "regex-syntax",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "thiserror",
+ "walkdir",
+ "yaml-rust",
+]
+
+[[package]]
+name = "thiserror"
+version = "2.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "2.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "time"
+version = "0.3.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c"
+dependencies = [
+ "deranged",
+ "itoa",
+ "num-conv",
+ "powerfmt",
+ "serde_core",
+ "time-core",
+ "time-macros",
+]
+
+[[package]]
+name = "time-core"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca"
+
+[[package]]
+name = "time-macros"
+version = "0.2.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215"
+dependencies = [
+ "num-conv",
+ "time-core",
+]
+
+[[package]]
+name = "tinystr"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869"
+dependencies = [
+ "displaydoc",
+ "zerovec",
+]
+
+[[package]]
+name = "tinyvec"
+version = "1.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3"
+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.50.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d"
+dependencies = [
+ "bytes",
+ "libc",
+ "mio",
+ "pin-project-lite",
+ "signal-hook-registry",
+ "socket2",
+ "tokio-macros",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "2.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[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 = "tools"
+version = "0.1.0"
+dependencies = [
+ "runtime",
+ "serde",
+ "serde_json",
+]
+
+[[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.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8"
+dependencies = [
+ "bitflags",
+ "bytes",
+ "futures-util",
+ "http",
+ "http-body",
+ "iri-string",
+ "pin-project-lite",
+ "tower",
+ "tower-layer",
+ "tower-service",
+]
+
+[[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-core",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.36"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
+dependencies = [
+ "once_cell",
+]
+
+[[package]]
+name = "try-lock"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
+
+[[package]]
+name = "unicase"
+version = "2.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
+
+[[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 = "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 = "wasip2"
+version = "1.0.2+wasi-0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
+dependencies = [
+ "wit-bindgen",
+]
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.116"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7dc0882f7b5bb01ae8c5215a1230832694481c1a4be062fd410e12ea3da5b631"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "rustversion",
+ "wasm-bindgen-macro",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-futures"
+version = "0.4.66"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19280959e2844181895ef62f065c63e0ca07ece4771b53d89bfdb967d97cbf05"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.116"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75973d3066e01d035dbedaad2864c398df42f8dd7b1ea057c35b8407c015b537"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.116"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "91af5e4be765819e0bcfee7322c14374dc821e35e72fa663a830bbc7dc199eac"
+dependencies = [
+ "bumpalo",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.116"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c9bf0406a78f02f336bf1e451799cca198e8acde4ffa278f0fb20487b150a633"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "web-sys"
+version = "0.3.93"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "749466a37ee189057f54748b200186b59a03417a117267baf3fd89cecc9fb837"
+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 = "webpki-roots"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed"
+dependencies = [
+ "rustls-pki-types",
+]
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[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 = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[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.60.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
+dependencies = [
+ "windows-targets 0.53.5",
+]
+
+[[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.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 0.52.6",
+ "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-targets"
+version = "0.53.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
+dependencies = [
+ "windows-link",
+ "windows_aarch64_gnullvm 0.53.1",
+ "windows_aarch64_msvc 0.53.1",
+ "windows_i686_gnu 0.53.1",
+ "windows_i686_gnullvm 0.53.1",
+ "windows_i686_msvc 0.53.1",
+ "windows_x86_64_gnu 0.53.1",
+ "windows_x86_64_gnullvm 0.53.1",
+ "windows_x86_64_msvc 0.53.1",
+]
+
+[[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_gnullvm"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
+
+[[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_gnu"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
+
+[[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_gnullvm"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
+
+[[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_gnu"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
+
+[[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_gnullvm"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
+
+[[package]]
+name = "wit-bindgen"
+version = "0.51.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
+
+[[package]]
+name = "writeable"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
+
+[[package]]
+name = "yaml-rust"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
+dependencies = [
+ "linked-hash-map",
+]
+
+[[package]]
+name = "yoke"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954"
+dependencies = [
+ "stable_deref_trait",
+ "yoke-derive",
+ "zerofrom",
+]
+
+[[package]]
+name = "yoke-derive"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
+
+[[package]]
+name = "zerocopy"
+version = "0.8.48"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9"
+dependencies = [
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.8.48"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "zerofrom"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5"
+dependencies = [
+ "zerofrom-derive",
+]
+
+[[package]]
+name = "zerofrom-derive"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
+
+[[package]]
+name = "zeroize"
+version = "1.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0"
+
+[[package]]
+name = "zerotrie"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851"
+dependencies = [
+ "displaydoc",
+ "yoke",
+ "zerofrom",
+]
+
+[[package]]
+name = "zerovec"
+version = "0.11.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002"
+dependencies = [
+ "yoke",
+ "zerofrom",
+ "zerovec-derive",
+]
+
+[[package]]
+name = "zerovec-derive"
+version = "0.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "zmij"
+version = "1.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
diff --git a/rust/crates/api/src/client.rs b/rust/crates/api/src/client.rs
index 47dbf272..9c289d29 100644
--- a/rust/crates/api/src/client.rs
+++ b/rust/crates/api/src/client.rs
@@ -41,14 +41,12 @@ impl AnthropicClient {
}
pub fn from_env() -> Result<Self, ApiError> {
- Ok(Self::new(read_api_key(|key| std::env::var(key))?)
- .with_auth_token(std::env::var("ANTHROPIC_AUTH_TOKEN").ok())
- .with_base_url(
- std::env::var("ANTHROPIC_BASE_URL")
- .ok()
- .or_else(|| std::env::var("CLAUDE_CODE_API_BASE_URL").ok())
- .unwrap_or_else(|| DEFAULT_BASE_URL.to_string()),
- ))
+ Ok(Self::new(read_api_key()?).with_base_url(
+ std::env::var("ANTHROPIC_BASE_URL")
+ .ok()
+ .or_else(|| std::env::var("CLAUDE_CODE_API_BASE_URL").ok())
+ .unwrap_or_else(|| DEFAULT_BASE_URL.to_string()),
+ ))
}
#[must_use]
@@ -187,13 +185,16 @@ impl AnthropicClient {
}
}
-fn read_api_key(
- getter: impl FnOnce(&str) -> Result<String, std::env::VarError>,
-) -> Result<String, ApiError> {
- match getter("ANTHROPIC_API_KEY") {
- Ok(api_key) if api_key.is_empty() => Err(ApiError::MissingApiKey),
- Ok(api_key) => Ok(api_key),
- Err(std::env::VarError::NotPresent) => Err(ApiError::MissingApiKey),
+fn read_api_key() -> Result<String, ApiError> {
+ match std::env::var("ANTHROPIC_AUTH_TOKEN") {
+ Ok(api_key) if !api_key.is_empty() => Ok(api_key),
+ Ok(_) => Err(ApiError::MissingApiKey),
+ Err(std::env::VarError::NotPresent) => match std::env::var("ANTHROPIC_API_KEY") {
+ Ok(api_key) if !api_key.is_empty() => Ok(api_key),
+ Ok(_) => Err(ApiError::MissingApiKey),
+ Err(std::env::VarError::NotPresent) => Err(ApiError::MissingApiKey),
+ Err(error) => Err(ApiError::from(error)),
+ },
Err(error) => Err(ApiError::from(error)),
}
}
@@ -289,8 +290,6 @@ struct AnthropicErrorBody {
#[cfg(test)]
mod tests {
- use std::env::VarError;
-
use super::{ALT_REQUEST_ID_HEADER, REQUEST_ID_HEADER};
use std::time::Duration;
@@ -298,21 +297,30 @@ mod tests {
#[test]
fn read_api_key_requires_presence() {
- let error = super::read_api_key(|_| Err(VarError::NotPresent))
- .expect_err("missing key should error");
+ std::env::remove_var("ANTHROPIC_AUTH_TOKEN");
+ std::env::remove_var("ANTHROPIC_API_KEY");
+ let error = super::read_api_key().expect_err("missing key should error");
assert!(matches!(error, crate::error::ApiError::MissingApiKey));
}
#[test]
fn read_api_key_requires_non_empty_value() {
- let error = super::read_api_key(|_| Ok(String::new())).expect_err("empty key should error");
+ std::env::set_var("ANTHROPIC_AUTH_TOKEN", "");
+ std::env::remove_var("ANTHROPIC_API_KEY");
+ let error = super::read_api_key().expect_err("empty key should error");
assert!(matches!(error, crate::error::ApiError::MissingApiKey));
}
#[test]
- fn with_auth_token_drops_empty_values() {
- let client = super::AnthropicClient::new("test-key").with_auth_token(Some(String::new()));
- assert!(client.auth_token.is_none());
+ fn read_api_key_prefers_auth_token() {
+ std::env::set_var("ANTHROPIC_AUTH_TOKEN", "auth-token");
+ std::env::set_var("ANTHROPIC_API_KEY", "legacy-key");
+ assert_eq!(
+ super::read_api_key().expect("token should load"),
+ "auth-token"
+ );
+ std::env::remove_var("ANTHROPIC_AUTH_TOKEN");
+ std::env::remove_var("ANTHROPIC_API_KEY");
}
#[test]
diff --git a/rust/crates/api/src/error.rs b/rust/crates/api/src/error.rs
index f52704c1..02ec584e 100644
--- a/rust/crates/api/src/error.rs
+++ b/rust/crates/api/src/error.rs
@@ -50,11 +50,14 @@ impl Display for ApiError {
Self::MissingApiKey => {
write!(
f,
- "ANTHROPIC_API_KEY is not set; export it before calling the Anthropic API"
+ "ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY is not set; export one before calling the Anthropic API"
)
}
Self::InvalidApiKeyEnv(error) => {
- write!(f, "failed to read ANTHROPIC_API_KEY: {error}")
+ write!(
+ f,
+ "failed to read ANTHROPIC_AUTH_TOKEN / ANTHROPIC_API_KEY: {error}"
+ )
}
Self::Http(error) => write!(f, "http error: {error}"),
Self::Io(error) => write!(f, "io error: {error}"),
diff --git a/rust/crates/api/src/sse.rs b/rust/crates/api/src/sse.rs
index 9a84dd95..d7334cd5 100644
--- a/rust/crates/api/src/sse.rs
+++ b/rust/crates/api/src/sse.rs
@@ -178,6 +178,8 @@ mod tests {
},
usage: Usage {
input_tokens: 1,
+ cache_creation_input_tokens: 0,
+ cache_read_input_tokens: 0,
output_tokens: 2,
},
}),
diff --git a/rust/crates/api/src/types.rs b/rust/crates/api/src/types.rs
index db5d89ef..45d5c082 100644
--- a/rust/crates/api/src/types.rs
+++ b/rust/crates/api/src/types.rs
@@ -64,6 +64,11 @@ pub enum InputContentBlock {
Text {
text: String,
},
+ ToolUse {
+ id: String,
+ name: String,
+ input: Value,
+ },
ToolResult {
tool_use_id: String,
content: Vec<ToolResultContentBlock>,
@@ -135,6 +140,10 @@ pub enum OutputContentBlock {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Usage {
pub input_tokens: u32,
+ #[serde(default)]
+ pub cache_creation_input_tokens: u32,
+ #[serde(default)]
+ pub cache_read_input_tokens: u32,
pub output_tokens: u32,
}
diff --git a/rust/crates/runtime/Cargo.toml b/rust/crates/runtime/Cargo.toml
index 8cd5d629..8bd9a424 100644
--- a/rust/crates/runtime/Cargo.toml
+++ b/rust/crates/runtime/Cargo.toml
@@ -5,5 +5,13 @@ edition.workspace = true
license.workspace = true
publish.workspace = true
+[dependencies]
+glob = "0.3"
+regex = "1"
+serde = { version = "1", features = ["derive"] }
+serde_json = "1"
+tokio = { version = "1", features = ["macros", "process", "rt", "rt-multi-thread", "time"] }
+walkdir = "2"
+
[lints]
workspace = true
diff --git a/rust/crates/runtime/src/file_ops.rs b/rust/crates/runtime/src/file_ops.rs
index ddff873a..42b3babe 100644
--- a/rust/crates/runtime/src/file_ops.rs
+++ b/rust/crates/runtime/src/file_ops.rs
@@ -129,7 +129,11 @@ pub struct GrepSearchOutput {
pub applied_offset: Option<usize>,
}
-pub fn read_file(path: &str, offset: Option<usize>, limit: Option<usize>) -> io::Result<ReadFileOutput> {
+pub fn read_file(
+ path: &str,
+ offset: Option<usize>,
+ limit: Option<usize>,
+) -> io::Result<ReadFileOutput> {
let absolute_path = normalize_path(path)?;
let content = fs::read_to_string(&absolute_path)?;
let lines: Vec<&str> = content.lines().collect();
@@ -173,14 +177,25 @@ pub fn write_file(path: &str, content: &str) -> io::Result<WriteFileOutput> {
})
}
-pub fn edit_file(path: &str, old_string: &str, new_string: &str, replace_all: bool) -> io::Result<EditFileOutput> {
+pub fn edit_file(
+ path: &str,
+ old_string: &str,
+ new_string: &str,
+ replace_all: bool,
+) -> io::Result<EditFileOutput> {
let absolute_path = normalize_path(path)?;
let original_file = fs::read_to_string(&absolute_path)?;
if old_string == new_string {
- return Err(io::Error::new(io::ErrorKind::InvalidInput, "old_string and new_string must differ"));
+ return Err(io::Error::new(
+ io::ErrorKind::InvalidInput,
+ "old_string and new_string must differ",
+ ));
}
if !original_file.contains(old_string) {
- return Err(io::Error::new(io::ErrorKind::NotFound, "old_string not found in file"));
+ return Err(io::Error::new(
+ io::ErrorKind::NotFound,
+ "old_string not found in file",
+ ));
}
let updated = if replace_all {
@@ -204,7 +219,10 @@ pub fn edit_file(path: &str, old_string: &str, new_string: &str, replace_all: bo
pub fn glob_search(pattern: &str, path: Option<&str>) -> io::Result<GlobSearchOutput> {
let started = Instant::now();
- let base_dir = path.map(normalize_path).transpose()?.unwrap_or(std::env::current_dir()?);
+ let base_dir = path
+ .map(normalize_path)
+ .transpose()?
+ .unwrap_or(std::env::current_dir()?);
let search_pattern = if Path::new(pattern).is_absolute() {
pattern.to_owned()
} else {
@@ -212,7 +230,8 @@ pub fn glob_search(pattern: &str, path: Option<&str>) -> io::Result<GlobSearchOu
};
let mut matches = Vec::new();
- let entries = glob::glob(&search_pattern).map_err(|error| io::Error::new(io::ErrorKind::InvalidInput, error.to_string()))?;
+ let entries = glob::glob(&search_pattern)
+ .map_err(|error| io::Error::new(io::ErrorKind::InvalidInput, error.to_string()))?;
for entry in entries.flatten() {
if entry.is_file() {
matches.push(entry);
@@ -255,9 +274,17 @@ pub fn grep_search(input: &GrepSearchInput) -> io::Result<GrepSearchOutput> {
.build()
.map_err(|error| io::Error::new(io::ErrorKind::InvalidInput, error.to_string()))?;
- let glob_filter = input.glob.as_deref().map(Pattern::new).transpose().map_err(|error| io::Error::new(io::ErrorKind::InvalidInput, error.to_string()))?;
+ let glob_filter = input
+ .glob
+ .as_deref()
+ .map(Pattern::new)
+ .transpose()
+ .map_err(|error| io::Error::new(io::ErrorKind::InvalidInput, error.to_string()))?;
let file_type = input.file_type.as_deref();
- let output_mode = input.output_mode.clone().unwrap_or_else(|| String::from("files_with_matches"));
+ let output_mode = input
+ .output_mode
+ .clone()
+ .unwrap_or_else(|| String::from("files_with_matches"));
let context = input.context.or(input.context_short).unwrap_or(0);
let mut filenames = Vec::new();
@@ -312,7 +339,8 @@ pub fn grep_search(input: &GrepSearchInput) -> io::Result<GrepSearchOutput> {
}
}
- let (filenames, applied_limit, applied_offset) = apply_limit(filenames, input.head_limit, input.offset);
+ let (filenames, applied_limit, applied_offset) =
+ apply_limit(filenames, input.head_limit, input.offset);
let content = if output_mode == "content" {
let (lines, limit, offset) = apply_limit(content_lines, input.head_limit, input.offset);
return Ok(GrepSearchOutput {
@@ -348,7 +376,8 @@ fn collect_search_files(base_path: &Path) -> io::Result<Vec<PathBuf>> {
let mut files = Vec::new();
for entry in WalkDir::new(base_path) {
- let entry = entry.map_err(|error| io::Error::new(io::ErrorKind::Other, error.to_string()))?;
+ let entry =
+ entry.map_err(|error| io::Error::new(io::ErrorKind::Other, error.to_string()))?;
if entry.file_type().is_file() {
files.push(entry.path().to_path_buf());
}
@@ -356,7 +385,11 @@ fn collect_search_files(base_path: &Path) -> io::Result<Vec<PathBuf>> {
Ok(files)
}
-fn matches_optional_filters(path: &Path, glob_filter: Option<&Pattern>, file_type: Option<&str>) -> bool {
+fn matches_optional_filters(
+ path: &Path,
+ glob_filter: Option<&Pattern>,
+ file_type: Option<&str>,
+) -> bool {
if let Some(glob_filter) = glob_filter {
let path_string = path.to_string_lossy();
if !glob_filter.matches(&path_string) && !glob_filter.matches_path(path) {
@@ -374,7 +407,11 @@ fn matches_optional_filters(path: &Path, glob_filter: Option<&Pattern>, file_typ
true
}
-fn apply_limit<T>(items: Vec<T>, limit: Option<usize>, offset: Option<usize>) -> (Vec<T>, Option<usize>, Option<usize>) {
+fn apply_limit<T>(
+ items: Vec<T>,
+ limit: Option<usize>,
+ offset: Option<usize>,
+) -> (Vec<T>, Option<usize>, Option<usize>) {
let offset_value = offset.unwrap_or(0);
let mut items = items.into_iter().skip(offset_value).collect::<Vec<_>>();
let explicit_limit = limit.unwrap_or(250);
@@ -430,7 +467,9 @@ fn normalize_path_allow_missing(path: &str) -> io::Result<PathBuf> {
}
if let Some(parent) = candidate.parent() {
- let canonical_parent = parent.canonicalize().unwrap_or_else(|_| parent.to_path_buf());
+ let canonical_parent = parent
+ .canonicalize()
+ .unwrap_or_else(|_| parent.to_path_buf());
if let Some(name) = candidate.file_name() {
return Ok(canonical_parent.join(name));
}
@@ -456,18 +495,22 @@ mod tests {
#[test]
fn reads_and_writes_files() {
let path = temp_path("read-write.txt");
- let write_output = write_file(path.to_string_lossy().as_ref(), "one\ntwo\nthree").expect("write should succeed");
+ let write_output = write_file(path.to_string_lossy().as_ref(), "one\ntwo\nthree")
+ .expect("write should succeed");
assert_eq!(write_output.kind, "create");
- let read_output = read_file(path.to_string_lossy().as_ref(), Some(1), Some(1)).expect("read should succeed");
+ let read_output = read_file(path.to_string_lossy().as_ref(), Some(1), Some(1))
+ .expect("read should succeed");
assert_eq!(read_output.file.content, "two");
}
#[test]
fn edits_file_contents() {
let path = temp_path("edit.txt");
- write_file(path.to_string_lossy().as_ref(), "alpha beta alpha").expect("initial write should succeed");
- let output = edit_file(path.to_string_lossy().as_ref(), "alpha", "omega", true).expect("edit should succeed");
+ write_file(path.to_string_lossy().as_ref(), "alpha beta alpha")
+ .expect("initial write should succeed");
+ let output = edit_file(path.to_string_lossy().as_ref(), "alpha", "omega", true)
+ .expect("edit should succeed");
assert!(output.replace_all);
}
@@ -476,9 +519,14 @@ mod tests {
let dir = temp_path("search-dir");
std::fs::create_dir_all(&dir).expect("directory should be created");
let file = dir.join("demo.rs");
- write_file(file.to_string_lossy().as_ref(), "fn main() {\n println!(\"hello\");\n}\n").expect("file write should succeed");
-
- let globbed = glob_search("**/*.rs", Some(dir.to_string_lossy().as_ref())).expect("glob should succeed");
+ write_file(
+ file.to_string_lossy().as_ref(),
+ "fn main() {\n println!(\"hello\");\n}\n",
+ )
+ .expect("file write should succeed");
+
+ let globbed = glob_search("**/*.rs", Some(dir.to_string_lossy().as_ref()))
+ .expect("glob should succeed");
assert_eq!(globbed.num_files, 1);
let grep_output = grep_search(&GrepSearchInput {
diff --git a/rust/crates/runtime/src/lib.rs b/rust/crates/runtime/src/lib.rs
index 63c2a7c8..0cb58145 100644
--- a/rust/crates/runtime/src/lib.rs
+++ b/rust/crates/runtime/src/lib.rs
@@ -1,13 +1,16 @@
+mod bash;
mod bootstrap;
mod compact;
mod config;
mod conversation;
+mod file_ops;
mod json;
mod permissions;
mod prompt;
mod session;
mod usage;
+pub use bash::{execute_bash, BashCommandInput, BashCommandOutput};
pub use bootstrap::{BootstrapPhase, BootstrapPlan};
pub use compact::{
compact_session, estimate_session_tokens, format_compact_summary,
@@ -21,6 +24,11 @@ pub use conversation::{
ApiClient, ApiRequest, AssistantEvent, ConversationRuntime, RuntimeError, StaticToolExecutor,
ToolError, ToolExecutor, TurnSummary,
};
+pub use file_ops::{
+ edit_file, glob_search, grep_search, read_file, write_file, EditFileOutput, GlobSearchOutput,
+ GrepSearchInput, GrepSearchOutput, ReadFileOutput, StructuredPatchHunk, TextFilePayload,
+ WriteFileOutput,
+};
pub use permissions::{
PermissionMode, PermissionOutcome, PermissionPolicy, PermissionPromptDecision,
PermissionPrompter, PermissionRequest,
diff --git a/rust/crates/rusty-claude-cli/Cargo.toml b/rust/crates/rusty-claude-cli/Cargo.toml
index 5d72a5a4..7fe9991a 100644
--- a/rust/crates/rusty-claude-cli/Cargo.toml
+++ b/rust/crates/rusty-claude-cli/Cargo.toml
@@ -6,9 +6,16 @@ license.workspace = true
publish.workspace = true
[dependencies]
+api = { path = "../api" }
commands = { path = "../commands" }
compat-harness = { path = "../compat-harness" }
+crossterm = "0.28"
+pulldown-cmark = "0.13"
runtime = { path = "../runtime" }
+serde_json = "1"
+syntect = "5"
+tokio = { version = "1", features = ["rt-multi-thread", "time"] }
+tools = { path = "../tools" }
[lints]
workspace = true
diff --git a/rust/crates/rusty-claude-cli/src/input.rs b/rust/crates/rusty-claude-cli/src/input.rs
index 09116677..3ca982e8 100644
--- a/rust/crates/rusty-claude-cli/src/input.rs
+++ b/rust/crates/rusty-claude-cli/src/input.rs
@@ -1,4 +1,4 @@
-use std::io::{self, Write};
+use std::io::{self, IsTerminal, Write};
use crossterm::cursor::MoveToColumn;
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers};
@@ -100,6 +100,10 @@ impl LineEditor {
}
pub fn read_line(&self) -> io::Result<Option<String>> {
+ if !io::stdin().is_terminal() || !io::stdout().is_terminal() {
+ return self.read_line_fallback();
+ }
+
enable_raw_mode()?;
let mut stdout = io::stdout();
let mut input = InputBuffer::new();
@@ -125,6 +129,23 @@ impl LineEditor {
}
}
+ fn read_line_fallback(&self) -> io::Result<Option<String>> {
+ let mut stdout = io::stdout();
+ write!(stdout, "{}", self.prompt)?;
+ stdout.flush()?;
+
+ let mut buffer = String::new();
+ let bytes_read = io::stdin().read_line(&mut buffer)?;
+ if bytes_read == 0 {
+ return Ok(None);
+ }
+
+ while matches!(buffer.chars().last(), Some('\n' | '\r')) {
+ buffer.pop();
+ }
+ Ok(Some(buffer))
+ }
+
fn handle_key(key: KeyEvent, input: &mut InputBuffer) -> EditorAction {
match key {
KeyEvent {
diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs
index a0af7d30..43033e22 100644
--- a/rust/crates/rusty-claude-cli/src/main.rs
+++ b/rust/crates/rusty-claude-cli/src/main.rs
@@ -1,28 +1,52 @@
+mod input;
+mod render;
+
use std::env;
+use std::io::{self, Write};
use std::path::{Path, PathBuf};
+use api::{
+ AnthropicClient, ContentBlockDelta, InputContentBlock, InputMessage, MessageRequest,
+ MessageResponse, OutputContentBlock, StreamEvent as ApiStreamEvent, ToolChoice, ToolDefinition,
+ ToolResultContentBlock,
+};
+
use commands::handle_slash_command;
use compat_harness::{extract_manifest, UpstreamPaths};
-use runtime::{load_system_prompt, BootstrapPlan, CompactionConfig, Session};
+use render::{Spinner, TerminalRenderer};
+use runtime::{
+ load_system_prompt, ApiClient, ApiRequest, AssistantEvent, CompactionConfig, ContentBlock,
+ ConversationMessage, ConversationRuntime, MessageRole, PermissionMode, PermissionPolicy,
+ RuntimeError, Session, TokenUsage, ToolError, ToolExecutor,
+};
+use tools::{execute_tool, mvp_tool_specs};
+
+const DEFAULT_MODEL: &str = "claude-sonnet-4-20250514";
+const DEFAULT_MAX_TOKENS: u32 = 32;
+const DEFAULT_DATE: &str = "2026-03-31";
fn main() {
- let args: Vec<String> = env::args().skip(1).collect();
+ if let Err(error) = run() {
+ eprintln!("{error}");
+ std::process::exit(1);
+ }
+}
- match parse_args(&args) {
- Ok(CliAction::DumpManifests) => dump_manifests(),
- Ok(CliAction::BootstrapPlan) => print_bootstrap_plan(),
- Ok(CliAction::PrintSystemPrompt { cwd, date }) => print_system_prompt(cwd, date),
- Ok(CliAction::ResumeSession {
+fn run() -> Result<(), Box<dyn std::error::Error>> {
+ let args: Vec<String> = env::args().skip(1).collect();
+ match parse_args(&args)? {
+ CliAction::DumpManifests => dump_manifests(),
+ CliAction::BootstrapPlan => print_bootstrap_plan(),
+ CliAction::PrintSystemPrompt { cwd, date } => print_system_prompt(cwd, date),
+ CliAction::ResumeSession {
session_path,
command,
- }) => resume_session(&session_path, command),
- Ok(CliAction::Help) => print_help(),
- Err(error) => {
- eprintln!("{error}");
- print_help();
- std::process::exit(2);
- }
+ } => resume_session(&session_path, command),
+ CliAction::Prompt { prompt, model } => LiveCli::new(model, false)?.run_turn(&prompt)?,
+ CliAction::Repl { model } => run_repl(model)?,
+ CliAction::Help => print_help(),
}
+ Ok(())
}
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -37,33 +61,69 @@ enum CliAction {
session_path: PathBuf,
command: Option<String>,
},
+ Prompt {
+ prompt: String,
+ model: String,
+ },
+ Repl {
+ model: String,
+ },
Help,
}
fn parse_args(args: &[String]) -> Result<CliAction, String> {
- if args.is_empty() {
- return Ok(CliAction::Help);
+ let mut model = DEFAULT_MODEL.to_string();
+ let mut rest = Vec::new();
+ let mut index = 0;
+
+ while index < args.len() {
+ match args[index].as_str() {
+ "--model" => {
+ let value = args
+ .get(index + 1)
+ .ok_or_else(|| "missing value for --model".to_string())?;
+ model = value.clone();
+ index += 2;
+ }
+ flag if flag.starts_with("--model=") => {
+ model = flag[8..].to_string();
+ index += 1;
+ }
+ other => {
+ rest.push(other.to_string());
+ index += 1;
+ }
+ }
}
- if matches!(args.first().map(String::as_str), Some("--help" | "-h")) {
+ if rest.is_empty() {
+ return Ok(CliAction::Repl { model });
+ }
+ if matches!(rest.first().map(String::as_str), Some("--help" | "-h")) {
return Ok(CliAction::Help);
}
-
- if args.first().map(String::as_str) == Some("--resume") {
- return parse_resume_args(&args[1..]);
+ if rest.first().map(String::as_str) == Some("--resume") {
+ return parse_resume_args(&rest[1..]);
}
- match args[0].as_str() {
+ match rest[0].as_str() {
"dump-manifests" => Ok(CliAction::DumpManifests),
"bootstrap-plan" => Ok(CliAction::BootstrapPlan),
- "system-prompt" => parse_system_prompt_args(&args[1..]),
+ "system-prompt" => parse_system_prompt_args(&rest[1..]),
+ "prompt" => {
+ let prompt = rest[1..].join(" ");
+ if prompt.trim().is_empty() {
+ return Err("prompt subcommand requires a prompt string".to_string());
+ }
+ Ok(CliAction::Prompt { prompt, model })
+ }
other => Err(format!("unknown subcommand: {other}")),
}
}
fn parse_system_prompt_args(args: &[String]) -> Result<CliAction, String> {
let mut cwd = env::current_dir().map_err(|error| error.to_string())?;
- let mut date = "2026-03-31".to_string();
+ let mut date = DEFAULT_DATE.to_string();
let mut index = 0;
while index < args.len() {
@@ -121,7 +181,7 @@ fn dump_manifests() {
}
fn print_bootstrap_plan() {
- for phase in BootstrapPlan::claude_code_default().phases() {
+ for phase in runtime::BootstrapPlan::claude_code_default().phases() {
println!("- {phase:?}");
}
}
@@ -178,24 +238,444 @@ fn resume_session(session_path: &Path, command: Option<String>) {
}
}
+fn run_repl(model: String) -> Result<(), Box<dyn std::error::Error>> {
+ let mut cli = LiveCli::new(model, true)?;
+ let editor = input::LineEditor::new("› ");
+ println!("Rusty Claude CLI interactive mode");
+ println!("Type /help for commands. Shift+Enter or Ctrl+J inserts a newline.");
+
+ while let Some(input) = editor.read_line()? {
+ let trimmed = input.trim();
+ if trimmed.is_empty() {
+ continue;
+ }
+ match trimmed {
+ "/exit" | "/quit" => break,
+ "/help" => {
+ println!("Available commands:");
+ println!(" /help Show help");
+ println!(" /status Show session status");
+ println!(" /compact Compact session history");
+ println!(" /exit Quit the REPL");
+ }
+ "/status" => cli.print_status(),
+ "/compact" => cli.compact()?,
+ _ => cli.run_turn(trimmed)?,
+ }
+ }
+
+ Ok(())
+}
+
+struct LiveCli {
+ model: String,
+ system_prompt: Vec<String>,
+ runtime: ConversationRuntime<AnthropicRuntimeClient, CliToolExecutor>,
+}
+
+impl LiveCli {
+ fn new(model: String, enable_tools: bool) -> Result<Self, Box<dyn std::error::Error>> {
+ let system_prompt = build_system_prompt()?;
+ let runtime = build_runtime(
+ Session::new(),
+ model.clone(),
+ system_prompt.clone(),
+ enable_tools,
+ )?;
+ Ok(Self {
+ model,
+ system_prompt,
+ runtime,
+ })
+ }
+
+ fn run_turn(&mut self, input: &str) -> Result<(), Box<dyn std::error::Error>> {
+ let mut spinner = Spinner::new();
+ let mut stdout = io::stdout();
+ spinner.tick(
+ "Waiting for Claude",
+ TerminalRenderer::new().color_theme(),
+ &mut stdout,
+ )?;
+ let result = self.runtime.run_turn(input, None);
+ match result {
+ Ok(_) => {
+ spinner.finish(
+ "Claude response complete",
+ TerminalRenderer::new().color_theme(),
+ &mut stdout,
+ )?;
+ println!();
+ Ok(())
+ }
+ Err(error) => {
+ spinner.fail(
+ "Claude request failed",
+ TerminalRenderer::new().color_theme(),
+ &mut stdout,
+ )?;
+ Err(Box::new(error))
+ }
+ }
+ }
+
+ fn print_status(&self) {
+ let usage = self.runtime.usage().cumulative_usage();
+ println!(
+ "status: messages={} turns={} input_tokens={} output_tokens={}",
+ self.runtime.session().messages.len(),
+ self.runtime.usage().turns(),
+ usage.input_tokens,
+ usage.output_tokens
+ );
+ }
+
+ fn compact(&mut self) -> Result<(), Box<dyn std::error::Error>> {
+ let result = self.runtime.compact(CompactionConfig::default());
+ let removed = result.removed_message_count;
+ self.runtime = build_runtime(
+ result.compacted_session,
+ self.model.clone(),
+ self.system_prompt.clone(),
+ true,
+ )?;
+ println!("Compacted {removed} messages.");
+ Ok(())
+ }
+}
+
+fn build_system_prompt() -> Result<Vec<String>, Box<dyn std::error::Error>> {
+ Ok(load_system_prompt(
+ env::current_dir()?,
+ DEFAULT_DATE,
+ env::consts::OS,
+ "unknown",
+ )?)
+}
+
+fn build_runtime(
+ session: Session,
+ model: String,
+ system_prompt: Vec<String>,
+ enable_tools: bool,
+) -> Result<ConversationRuntime<AnthropicRuntimeClient, CliToolExecutor>, Box<dyn std::error::Error>>
+{
+ Ok(ConversationRuntime::new(
+ session,
+ AnthropicRuntimeClient::new(model, enable_tools)?,
+ CliToolExecutor::new(),
+ permission_policy_from_env(),
+ system_prompt,
+ ))
+}
+
+struct AnthropicRuntimeClient {
+ runtime: tokio::runtime::Runtime,
+ client: AnthropicClient,
+ model: String,
+ enable_tools: bool,
+}
+
+impl AnthropicRuntimeClient {
+ fn new(model: String, enable_tools: bool) -> Result<Self, Box<dyn std::error::Error>> {
+ Ok(Self {
+ runtime: tokio::runtime::Runtime::new()?,
+ client: AnthropicClient::from_env()?,
+ model,
+ enable_tools,
+ })
+ }
+}
+
+impl ApiClient for AnthropicRuntimeClient {
+ fn stream(&mut self, request: ApiRequest) -> Result<Vec<AssistantEvent>, RuntimeError> {
+ let message_request = MessageRequest {
+ model: self.model.clone(),
+ max_tokens: DEFAULT_MAX_TOKENS,
+ messages: convert_messages(&request.messages),
+ system: (!request.system_prompt.is_empty()).then(|| request.system_prompt.join("\n\n")),
+ tools: self.enable_tools.then(|| {
+ mvp_tool_specs()
+ .into_iter()
+ .map(|spec| ToolDefinition {
+ name: spec.name.to_string(),
+ description: Some(spec.description.to_string()),
+ input_schema: spec.input_schema,
+ })
+ .collect()
+ }),
+ tool_choice: self.enable_tools.then_some(ToolChoice::Auto),
+ stream: true,
+ };
+
+ self.runtime.block_on(async {
+ let mut stream = self
+ .client
+ .stream_message(&message_request)
+ .await
+ .map_err(|error| RuntimeError::new(error.to_string()))?;
+ let mut stdout = io::stdout();
+ let mut events = Vec::new();
+ let mut pending_tool: Option<(String, String, String)> = None;
+ let mut saw_stop = false;
+
+ while let Some(event) = stream
+ .next_event()
+ .await
+ .map_err(|error| RuntimeError::new(error.to_string()))?
+ {
+ match event {
+ ApiStreamEvent::MessageStart(start) => {
+ for block in start.message.content {
+ push_output_block(block, &mut stdout, &mut events, &mut pending_tool)?;
+ }
+ }
+ ApiStreamEvent::ContentBlockStart(start) => {
+ push_output_block(
+ start.content_block,
+ &mut stdout,
+ &mut events,
+ &mut pending_tool,
+ )?;
+ }
+ ApiStreamEvent::ContentBlockDelta(delta) => match delta.delta {
+ ContentBlockDelta::TextDelta { text } => {
+ if !text.is_empty() {
+ write!(stdout, "{text}")
+ .and_then(|_| stdout.flush())
+ .map_err(|error| RuntimeError::new(error.to_string()))?;
+ events.push(AssistantEvent::TextDelta(text));
+ }
+ }
+ ContentBlockDelta::InputJsonDelta { partial_json } => {
+ if let Some((_, _, input)) = &mut pending_tool {
+ input.push_str(&partial_json);
+ }
+ }
+ },
+ ApiStreamEvent::ContentBlockStop(_) => {
+ if let Some((id, name, input)) = pending_tool.take() {
+ events.push(AssistantEvent::ToolUse { id, name, input });
+ }
+ }
+ ApiStreamEvent::MessageDelta(delta) => {
+ events.push(AssistantEvent::Usage(TokenUsage {
+ input_tokens: delta.usage.input_tokens,
+ output_tokens: delta.usage.output_tokens,
+ cache_creation_input_tokens: 0,
+ cache_read_input_tokens: 0,
+ }));
+ }
+ ApiStreamEvent::MessageStop(_) => {
+ saw_stop = true;
+ events.push(AssistantEvent::MessageStop);
+ }
+ }
+ }
+
+ if !saw_stop
+ && events.iter().any(|event| {
+ matches!(event, AssistantEvent::TextDelta(text) if !text.is_empty())
+ || matches!(event, AssistantEvent::ToolUse { .. })
+ })
+ {
+ events.push(AssistantEvent::MessageStop);
+ }
+
+ if events
+ .iter()
+ .any(|event| matches!(event, AssistantEvent::MessageStop))
+ {
+ return Ok(events);
+ }
+
+ let response = self
+ .client
+ .send_message(&MessageRequest {
+ stream: false,
+ ..message_request.clone()
+ })
+ .await
+ .map_err(|error| RuntimeError::new(error.to_string()))?;
+ response_to_events(response, &mut stdout)
+ })
+ }
+}
+
+fn push_output_block(
+ block: OutputContentBlock,
+ out: &mut impl Write,
+ events: &mut Vec<AssistantEvent>,
+ pending_tool: &mut Option<(String, String, String)>,
+) -> Result<(), RuntimeError> {
+ match block {
+ OutputContentBlock::Text { text } => {
+ if !text.is_empty() {
+ write!(out, "{text}")
+ .and_then(|_| out.flush())
+ .map_err(|error| RuntimeError::new(error.to_string()))?;
+ events.push(AssistantEvent::TextDelta(text));
+ }
+ }
+ OutputContentBlock::ToolUse { id, name, input } => {
+ *pending_tool = Some((id, name, input.to_string()));
+ }
+ }
+ Ok(())
+}
+
+fn response_to_events(
+ response: MessageResponse,
+ out: &mut impl Write,
+) -> Result<Vec<AssistantEvent>, RuntimeError> {
+ let mut events = Vec::new();
+ let mut pending_tool = None;
+
+ for block in response.content {
+ push_output_block(block, out, &mut events, &mut pending_tool)?;
+ if let Some((id, name, input)) = pending_tool.take() {
+ events.push(AssistantEvent::ToolUse { id, name, input });
+ }
+ }
+
+ events.push(AssistantEvent::Usage(TokenUsage {
+ input_tokens: response.usage.input_tokens,
+ output_tokens: response.usage.output_tokens,
+ cache_creation_input_tokens: response.usage.cache_creation_input_tokens,
+ cache_read_input_tokens: response.usage.cache_read_input_tokens,
+ }));
+ events.push(AssistantEvent::MessageStop);
+ Ok(events)
+}
+
+struct CliToolExecutor {
+ renderer: TerminalRenderer,
+}
+
+impl CliToolExecutor {
+ fn new() -> Self {
+ Self {
+ renderer: TerminalRenderer::new(),
+ }
+ }
+}
+
+impl ToolExecutor for CliToolExecutor {
+ fn execute(&mut self, tool_name: &str, input: &str) -> Result<String, ToolError> {
+ let value = serde_json::from_str(input)
+ .map_err(|error| ToolError::new(format!("invalid tool input JSON: {error}")))?;
+ match execute_tool(tool_name, &value) {
+ Ok(output) => {
+ let markdown = format!("### Tool `{tool_name}`\n\n```json\n{output}\n```\n");
+ self.renderer
+ .stream_markdown(&markdown, &mut io::stdout())
+ .map_err(|error| ToolError::new(error.to_string()))?;
+ Ok(output)
+ }
+ Err(error) => Err(ToolError::new(error)),
+ }
+ }
+}
+
+fn permission_policy_from_env() -> PermissionPolicy {
+ let mode =
+ env::var("RUSTY_CLAUDE_PERMISSION_MODE").unwrap_or_else(|_| "workspace-write".to_string());
+ match mode.as_str() {
+ "read-only" => PermissionPolicy::new(PermissionMode::Deny)
+ .with_tool_mode("read_file", PermissionMode::Allow)
+ .with_tool_mode("glob_search", PermissionMode::Allow)
+ .with_tool_mode("grep_search", PermissionMode::Allow),
+ _ => PermissionPolicy::new(PermissionMode::Allow),
+ }
+}
+
+fn convert_messages(messages: &[ConversationMessage]) -> Vec<InputMessage> {
+ messages
+ .iter()
+ .filter_map(|message| {
+ let role = match message.role {
+ MessageRole::System | MessageRole::User | MessageRole::Tool => "user",
+ MessageRole::Assistant => "assistant",
+ };
+ let content = message
+ .blocks
+ .iter()
+ .map(|block| match block {
+ ContentBlock::Text { text } => InputContentBlock::Text { text: text.clone() },
+ ContentBlock::ToolUse { id, name, input } => InputContentBlock::ToolUse {
+ id: id.clone(),
+ name: name.clone(),
+ input: serde_json::from_str(input)
+ .unwrap_or_else(|_| serde_json::json!({ "raw": input })),
+ },
+ ContentBlock::ToolResult {
+ tool_use_id,
+ output,
+ is_error,
+ ..
+ } => InputContentBlock::ToolResult {
+ tool_use_id: tool_use_id.clone(),
+ content: vec![ToolResultContentBlock::Text {
+ text: output.clone(),
+ }],
+ is_error: *is_error,
+ },
+ })
+ .collect::<Vec<_>>();
+ (!content.is_empty()).then(|| InputMessage {
+ role: role.to_string(),
+ content,
+ })
+ })
+ .collect()
+}
+
fn print_help() {
println!("rusty-claude-cli");
println!();
- println!("Current scaffold commands:");
+ println!("Usage:");
+ println!(" rusty-claude-cli [--model MODEL] Start interactive REPL");
println!(
- " dump-manifests Read upstream TS sources and print extracted counts"
+ " rusty-claude-cli [--model MODEL] prompt TEXT Send one prompt and stream the response"
);
- println!(" bootstrap-plan Print the current bootstrap phase skeleton");
- println!(" system-prompt [--cwd PATH] [--date YYYY-MM-DD]");
- println!(" Build a Claude-style system prompt from CLAUDE.md and config files");
- println!(" --resume SESSION.json [/compact] Restore a saved session and optionally run a slash command");
+ println!(" rusty-claude-cli dump-manifests");
+ println!(" rusty-claude-cli bootstrap-plan");
+ println!(" rusty-claude-cli system-prompt [--cwd PATH] [--date YYYY-MM-DD]");
+ println!(" rusty-claude-cli --resume SESSION.json [/compact]");
}
#[cfg(test)]
mod tests {
- use super::{parse_args, CliAction};
+ use super::{parse_args, CliAction, DEFAULT_MODEL};
+ use runtime::{ContentBlock, ConversationMessage, MessageRole};
use std::path::PathBuf;
+ #[test]
+ fn defaults_to_repl_when_no_args() {
+ assert_eq!(
+ parse_args(&[]).expect("args should parse"),
+ CliAction::Repl {
+ model: DEFAULT_MODEL.to_string(),
+ }
+ );
+ }
+
+ #[test]
+ fn parses_prompt_subcommand() {
+ let args = vec![
+ "prompt".to_string(),
+ "hello".to_string(),
+ "world".to_string(),
+ ];
+ assert_eq!(
+ parse_args(&args).expect("args should parse"),
+ CliAction::Prompt {
+ prompt: "hello world".to_string(),
+ model: DEFAULT_MODEL.to_string(),
+ }
+ );
+ }
+
#[test]
fn parses_system_prompt_options() {
let args = vec![
@@ -229,4 +709,31 @@ mod tests {
}
);
}
+
+ #[test]
+ fn converts_tool_roundtrip_messages() {
+ let messages = vec![
+ ConversationMessage::user_text("hello"),
+ ConversationMessage::assistant(vec![ContentBlock::ToolUse {
+ id: "tool-1".to_string(),
+ name: "bash".to_string(),
+ input: "{\"command\":\"pwd\"}".to_string(),
+ }]),
+ ConversationMessage {
+ role: MessageRole::Tool,
+ blocks: vec![ContentBlock::ToolResult {
+ tool_use_id: "tool-1".to_string(),
+ tool_name: "bash".to_string(),
+ output: "ok".to_string(),
+ is_error: false,
+ }],
+ usage: None,
+ },
+ ];
+
+ let converted = super::convert_messages(&messages);
+ assert_eq!(converted.len(), 3);
+ assert_eq!(converted[1].role, "assistant");
+ assert_eq!(converted[2].role, "user");
+ }
}
diff --git a/rust/crates/tools/Cargo.toml b/rust/crates/tools/Cargo.toml
index b6a08cc5..e1fb5bb1 100644
--- a/rust/crates/tools/Cargo.toml
+++ b/rust/crates/tools/Cargo.toml
@@ -5,5 +5,10 @@ edition.workspace = true
license.workspace = true
publish.workspace = true
+[dependencies]
+runtime = { path = "../runtime" }
+serde = { version = "1", features = ["derive"] }
+serde_json = "1"
+
[lints]
workspace = true
diff --git a/rust/crates/tools/src/lib.rs b/rust/crates/tools/src/lib.rs
index 99e4eacf..d8806b89 100644
--- a/rust/crates/tools/src/lib.rs
+++ b/rust/crates/tools/src/lib.rs
@@ -1,3 +1,10 @@
+use runtime::{
+ edit_file, execute_bash, glob_search, grep_search, read_file, write_file, BashCommandInput,
+ GrepSearchInput,
+};
+use serde::Deserialize;
+use serde_json::{json, Value};
+
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ToolManifestEntry {
pub name: String,
@@ -26,3 +33,218 @@ impl ToolRegistry {
&self.entries
}
}
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct ToolSpec {
+ pub name: &'static str,
+ pub description: &'static str,
+ pub input_schema: Value,
+}
+
+#[must_use]
+pub fn mvp_tool_specs() -> Vec<ToolSpec> {
+ vec![
+ ToolSpec {
+ name: "bash",
+ description: "Execute a shell command in the current workspace.",
+ input_schema: json!({
+ "type": "object",
+ "properties": {
+ "command": { "type": "string" },
+ "timeout": { "type": "integer", "minimum": 1 },
+ "description": { "type": "string" },
+ "run_in_background": { "type": "boolean" },
+ "dangerouslyDisableSandbox": { "type": "boolean" }
+ },
+ "required": ["command"],
+ "additionalProperties": false
+ }),
+ },
+ ToolSpec {
+ name: "read_file",
+ description: "Read a text file from the workspace.",
+ input_schema: json!({
+ "type": "object",
+ "properties": {
+ "path": { "type": "string" },
+ "offset": { "type": "integer", "minimum": 0 },
+ "limit": { "type": "integer", "minimum": 1 }
+ },
+ "required": ["path"],
+ "additionalProperties": false
+ }),
+ },
+ ToolSpec {
+ name: "write_file",
+ description: "Write a text file in the workspace.",
+ input_schema: json!({
+ "type": "object",
+ "properties": {
+ "path": { "type": "string" },
+ "content": { "type": "string" }
+ },
+ "required": ["path", "content"],
+ "additionalProperties": false
+ }),
+ },
+ ToolSpec {
+ name: "edit_file",
+ description: "Replace text in a workspace file.",
+ input_schema: json!({
+ "type": "object",
+ "properties": {
+ "path": { "type": "string" },
+ "old_string": { "type": "string" },
+ "new_string": { "type": "string" },
+ "replace_all": { "type": "boolean" }
+ },
+ "required": ["path", "old_string", "new_string"],
+ "additionalProperties": false
+ }),
+ },
+ ToolSpec {
+ name: "glob_search",
+ description: "Find files by glob pattern.",
+ input_schema: json!({
+ "type": "object",
+ "properties": {
+ "pattern": { "type": "string" },
+ "path": { "type": "string" }
+ },
+ "required": ["pattern"],
+ "additionalProperties": false
+ }),
+ },
+ ToolSpec {
+ name: "grep_search",
+ description: "Search file contents with a regex pattern.",
+ input_schema: json!({
+ "type": "object",
+ "properties": {
+ "pattern": { "type": "string" },
+ "path": { "type": "string" },
+ "glob": { "type": "string" },
+ "output_mode": { "type": "string" },
+ "-B": { "type": "integer", "minimum": 0 },
+ "-A": { "type": "integer", "minimum": 0 },
+ "-C": { "type": "integer", "minimum": 0 },
+ "context": { "type": "integer", "minimum": 0 },
+ "-n": { "type": "boolean" },
+ "-i": { "type": "boolean" },
+ "type": { "type": "string" },
+ "head_limit": { "type": "integer", "minimum": 1 },
+ "offset": { "type": "integer", "minimum": 0 },
+ "multiline": { "type": "boolean" }
+ },
+ "required": ["pattern"],
+ "additionalProperties": false
+ }),
+ },
+ ]
+}
+
+pub fn execute_tool(name: &str, input: &Value) -> Result<String, String> {
+ match name {
+ "bash" => from_value::<BashCommandInput>(input).and_then(run_bash),
+ "read_file" => from_value::<ReadFileInput>(input).and_then(run_read_file),
+ "write_file" => from_value::<WriteFileInput>(input).and_then(run_write_file),
+ "edit_file" => from_value::<EditFileInput>(input).and_then(run_edit_file),
+ "glob_search" => from_value::<GlobSearchInputValue>(input).and_then(run_glob_search),
+ "grep_search" => from_value::<GrepSearchInput>(input).and_then(run_grep_search),
+ _ => Err(format!("unsupported tool: {name}")),
+ }
+}
+
+fn from_value<T: for<'de> Deserialize<'de>>(input: &Value) -> Result<T, String> {
+ serde_json::from_value(input.clone()).map_err(|error| error.to_string())
+}
+
+fn run_bash(input: BashCommandInput) -> Result<String, String> {
+ serde_json::to_string_pretty(&execute_bash(input).map_err(|error| error.to_string())?)
+ .map_err(|error| error.to_string())
+}
+
+fn run_read_file(input: ReadFileInput) -> Result<String, String> {
+ to_pretty_json(read_file(&input.path, input.offset, input.limit).map_err(io_to_string)?)
+}
+
+fn run_write_file(input: WriteFileInput) -> Result<String, String> {
+ to_pretty_json(write_file(&input.path, &input.content).map_err(io_to_string)?)
+}
+
+fn run_edit_file(input: EditFileInput) -> Result<String, String> {
+ to_pretty_json(
+ edit_file(
+ &input.path,
+ &input.old_string,
+ &input.new_string,
+ input.replace_all.unwrap_or(false),
+ )
+ .map_err(io_to_string)?,
+ )
+}
+
+fn run_glob_search(input: GlobSearchInputValue) -> Result<String, String> {
+ to_pretty_json(glob_search(&input.pattern, input.path.as_deref()).map_err(io_to_string)?)
+}
+
+fn run_grep_search(input: GrepSearchInput) -> Result<String, String> {
+ to_pretty_json(grep_search(&input).map_err(io_to_string)?)
+}
+
+fn to_pretty_json<T: serde::Serialize>(value: T) -> Result<String, String> {
+ serde_json::to_string_pretty(&value).map_err(|error| error.to_string())
+}
+
+fn io_to_string(error: std::io::Error) -> String {
+ error.to_string()
+}
+
+#[derive(Debug, Deserialize)]
+struct ReadFileInput {
+ path: String,
+ offset: Option<usize>,
+ limit: Option<usize>,
+}
+
+#[derive(Debug, Deserialize)]
+struct WriteFileInput {
+ path: String,
+ content: String,
+}
+
+#[derive(Debug, Deserialize)]
+struct EditFileInput {
+ path: String,
+ old_string: String,
+ new_string: String,
+ replace_all: Option<bool>,
+}
+
+#[derive(Debug, Deserialize)]
+struct GlobSearchInputValue {
+ pattern: String,
+ path: Option<String>,
+}
+
+#[cfg(test)]
+mod tests {
+ use super::{execute_tool, mvp_tool_specs};
+ use serde_json::json;
+
+ #[test]
+ fn exposes_mvp_tools() {
+ let names = mvp_tool_specs()
+ .into_iter()
+ .map(|spec| spec.name)
+ .collect::<Vec<_>>();
+ assert!(names.contains(&"bash"));
+ assert!(names.contains(&"read_file"));
+ }
+
+ #[test]
+ fn rejects_unknown_tool_names() {
+ let error = execute_tool("nope", &json!({})).expect_err("tool should be rejected");
+ assert!(error.contains("unsupported tool"));
+ }
+}