slash-lang 0.1.0

Parser and AST for the slash-command language
Documentation
  • Coverage
  • 56.67%
    51 out of 90 items documented1 out of 21 items with examples
  • Size
  • Source code size: 72.76 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.01 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 40s Average build duration of successful builds.
  • all releases: 40s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • 89jobrien

slash

An AI agent tool orchestration language. Commands are compact slash-expressions embedded in configuration files (e.g., settings.json) and dispatched to self-contained Rust builtins by a CommandRegistry.

Crates

Crate Description
slash-lang Lexer, parser, and AST
slash-lib Executor, CommandRegistry, SlashCommand trait, and builtins
slash-cmd CLI binary (slash)
slash-testing Proptest strategies and harness

Language Overview

Commands are whitespace-tokenized with no quoting, escaping, or variable expansion. Priority is inferred from the shape of the command token. Urgency is a trailing suffix.

Primary argument

/read($FILE)
/exec(cargo build)
/write(out.txt).append(hello world)

Builder-chain methods

/deploy.env(prod).region(us-east-1)
/write(out.txt).append(line one)

Priority (inferred from casing)

Token shape Priority
ALL_CAPS Max
TitleCase High
camelCase Medium
kebab-case / plain lowercase Low
snake_case Lowest

Urgency (trailing ! suffix)

/build!    # Low urgency
/build!!   # Medium urgency
/build!!!  # High urgency

Optional commands and pipe context

/cmd? marks a command optional. When optional commands are piped together, their outputs accumulate into a Context object (key = command name, value = Option<String>) passed as JSON to the first non-optional command.

/fetch? | /validate? | /deploy

Operators

/build && /test          # run /test only if /build succeeds
/build || /fallback      # run /fallback only if /build fails
/generate | /format      # pipe stdout
/build |& /log           # pipe stdout + stderr
/build > out.txt         # redirect output (overwrite)
/build >> out.txt        # redirect output (append)

Builtins

Command Description
/echo(text) Print text; .text(val) appends words
/read($PATH) Read a file; resolves $KEY env vars
/write(path).append(text) Write or append to a file
/exec(shell cmd) Run a shell command, capture stdout
/find(dir).name(pattern) Find files by name glob
/obfsck(text) Redact secrets from text

All commands are registered via the SlashCommand trait. Builder-chain methods are validated against each command's declared MethodDef table before dispatch — unknown methods produce a clear error.

Environment Variables

$KEY tokens in primary args are resolved at runtime. The registry loads .slenv (then .env) via dotenvy on first use. If a key is not found in the env files, dotenvx is tried as a fallback for encrypted secrets.

/read($CONFIG_PATH)
/exec($BUILD_CMD)

CLI

# Execute a slash expression
slash '/echo.text(hello world)'

# Execute with automatic secret redaction
slash --redact '/exec(cat secrets.txt)'

Usage (library)

use slash_lib::{parse, CommandRegistry};

let registry = CommandRegistry::default();
let output = registry.run("/echo.text(hello world)", None)?;
println!("{}", output.stdout);

Building

cargo build --all-targets
cargo nextest run
cargo clippy --all-targets -- -D warnings

License

Licensed under either of MIT or Apache-2.0 at your option.