MCPcopy Index your code
hub / github.com/contextgeneric/hypershell

github.com/contextgeneric/hypershell @v0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.0 ↗ · + Follow
143 symbols 183 edges 103 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Hypershell

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.

Learn More

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

What is Hypershell?

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:

  • Type Safety: Your shell-like programs are checked by the Rust compiler.
  • Performance: DSL programs are interpreted at compile-time into native Rust code with no runtime overhead.
  • Extensibility: Seamlessly integrate native Rust functions (like HTTP requests or JSON parsing) with external CLI commands in your pipelines.
  • Modularity: The language itself is designed to be extended. You can add new syntax and handlers without modifying the core library.

Key Features

  • Type-Level DSL: Define shell scripts as Rust types.
  • Extensible Syntax and Semantics: Powered by CGP, allowing for deep customization.
  • Mix CLI and Native Handlers: Combine external commands like sha256sum or cut with native Rust logic for HTTP requests, JSON processing, and more.
  • Streaming Pipelines: Efficiently stream I/O between handlers, just like in a traditional shell.
  • Compile-Time Interpretation: Your DSL programs are resolved at compile-time, resulting in highly performant native code.

Getting Started

Installation

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"

Examples

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.

Disclaimer

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.

Extension points exported contracts — how you extend this code

WrapStaticArg (Interface)
(no doc) [2 implementers]
crates/hypershell-components/src/traits/wrap_static_arg.rs
CanUpdateRequestBuilder (Interface)
(no doc)
crates/hypershell-reqwest-components/src/components/update_builder.rs
CanUpdateCommand (Interface)
(no doc)
crates/hypershell-tokio-components/src/components/update_command.rs
WrapCall (Interface)
(no doc) [2 implementers]
crates/hypershell-components/src/traits/wrap_call.rs
HasReqwestClient (Interface)
(no doc)
crates/hypershell-reqwest-components/src/components/client.rs
CanExtractStringArg (Interface)
(no doc)
crates/hypershell-components/src/components/string_arg.rs
HasUrlType (Interface)
(no doc)
crates/hypershell-components/src/components/url_arg.rs
CanExtractUrlArg (Interface)
(no doc)
crates/hypershell-components/src/components/url_arg.rs

Core symbols most depended-on inside this repo

handle
called by 15
crates/hypershell-components/src/providers/use.rs
extract_command_arg
called by 4
crates/hypershell-tokio-components/src/providers/join_args.rs
expand_and_pipe
called by 3
crates/hypershell-macro/src/expand.rs
extract_string_arg
called by 3
crates/hypershell-components/src/providers/string_arg.rs
extract_string_arg
called by 2
crates/hypershell-reqwest-components/src/providers/url_encode.rs
expand_grouped
called by 2
crates/hypershell-macro/src/expand.rs
update_request_builder
called by 1
crates/hypershell-reqwest-components/src/providers/headers.rs
extract_method_arg
called by 1
crates/hypershell-reqwest-components/src/providers/method_arg.rs

Shape

Class 69
Method 39
Function 21
Interface 12
Enum 2

Languages

Rust100%

Modules by API surface

crates/hypershell-macro/src/expand.rs10 symbols
crates/hypershell-components/src/dsl/http.rs10 symbols
crates/hypershell-components/src/dsl/convert.rs6 symbols
crates/hypershell-tokio-components/src/providers/simple_exec.rs5 symbols
crates/hypershell-tokio-components/src/providers/core_exec.rs4 symbols
crates/hypershell-components/src/providers/convert.rs4 symbols
crates/hypershell-tokio-components/src/types/tokio_async_read.rs3 symbols
crates/hypershell-tokio-components/src/types/futures_stream.rs3 symbols
crates/hypershell-tokio-components/src/types/futures_async_read.rs3 symbols
crates/hypershell-examples/tests/tests/field.rs3 symbols
crates/hypershell-examples/examples/rust_playground.rs3 symbols
crates/hypershell-examples/examples/github_issues.rs3 symbols

For agents

$ claude mcp add hypershell \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact