Hypershell is a modular, type-level domain-specific language (DSL) for writing shell-script-like programs in Rust. It is powered by context-generic programming (CGP), which makes it possible for users to extend or modify both the language syntax and semantics.
This README provides a brief overview of Hypershell. To learn about the concepts behind Hypershell, Context-Generic Programming, and how to create your own extensions, please read the introductory blog post:
Hypershell: A Type-Level DSL for Shell-Scripting in Rust
Hypershell allows you to define complex command pipelines, similar to shell scripts, but directly within Rust's type system. This approach provides several key benefits:
sha256sum or cut with native Rust logic for HTTP requests, JSON processing, and more.Add hypershell and cgp to your Cargo.toml:
[dependencies]
cgp = { version = "0.4.1" }
hypershell = { version = "0.1.0" }
# You'll also need tokio for async runtime and reqwest for the example
tokio = { version = "1", features = ["full"] }
reqwest = "0.11"
anyhow = "1.0"
The hypershell-examples crate contains various examples demonstrating different features and use cases of Hypershell. You can find the full source code for these examples in the crates/hypershell-examples/examples/ directory.
Here are a few hand-picked examples with short descriptions:
hello.rs: A basic "hello world" program that executes echo hello world! using SimpleExec.hello_name.rs: Demonstrates using variable parameters (FieldArg) to pass dynamic values to shell commands.http_checksum_cli.rs: Fetches a URL using curl and pipes the output to sha256sum and cut via streaming execution.http_checksum_client.rs: Fetches a URL using Hypershell's native HTTP client, then pipes the response to sha256sum and cut via streaming execution.http_checksum_native.rs: The same checksum functionality, but uses Hypershell's native HTTP client together with an extended version of the DSL that introduces Checksum to the language syntax, showcasing the extensibility of the DSL.rust_playground.rs: Shows how to encode and decode JSON, sending a Rust code snippet to the Rust Playground API and parsing its response.bluesky.rs: Connects to the Bluesky social media firehose via nix-shell and websocat, and then filters the stream using grep.bluesky_websocket.rs: The same Bluesky firehose example, but extends the DSL with native Websocket handling and using it in the program, showcasing the extensibility of the DSL.Hypershell is an experimental proof of concept designed to showcase the capabilities of Context-Generic Programming (CGP). Its primary purpose is to demonstrate how CGP can be used to build highly modular DSLs in Rust, rather than to be a production-ready shell replacement.
$ claude mcp add hypershell \
-- python -m otcore.mcp_server <graph>