zshrs 0.9.2

The first compiled Unix shell — bytecode VM, worker pool, AOP intercept, SQLite caching
Documentation
```
 ███████╗███████╗██╗  ██╗██████╗ ███████╗
 ╚══███╔╝██╔════╝██║  ██║██╔══██╗██╔════╝
   ███╔╝ ███████╗███████║██████╔╝███████╗
  ███╔╝  ╚════██║██╔══██║██╔══██╗╚════█��║
 ███████╗███████║██║  ██║██║  ██║███████║
 ╚══════╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝
```

[![CI](https://github.com/MenkeTechnologies/zshrs/actions/workflows/ci.yml/badge.svg)](https://github.com/MenkeTechnologies/zshrs/actions/workflows/ci.yml)
[![Crates.io](https://img.shields.io/crates/v/zshrs.svg)](https://crates.io/crates/zshrs)
[![Downloads](https://img.shields.io/crates/d/zshrs.svg)](https://crates.io/crates/zshrs)
[![Docs.rs](https://docs.rs/zshrs/badge.svg)](https://docs.rs/zshrs)
[![Docs](https://img.shields.io/badge/docs-online-blue.svg)](https://menketechnologies.github.io/zshrs/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

### `[THE FIRST COMPILED UNIX SHELL]`

> *"No fork, no problems."*

The first Unix shell to compile to bytecodes and execute on a purpose-built virtual machine with fused superinstructions. Since the Bourne shell at Bell Labs in 1970, every Unix shell has been an interpreter. zshrs is the first to be a compiler. A drop-in zsh replacement written in Rust — 190k+ lines, 267 source files, 80 core modules, 26 ZLE widgets, 48 fish-ported builtins, persistent worker pool, AOP intercept, SQLite FTS5 caching, and full zsh compatibility.

### [`Docs`]https://menketechnologies.github.io/zshrs/zshrs.html · [`Coverage Report`]https://menketechnologies.github.io/zshrs/report.html · [`strykelang`]https://github.com/MenkeTechnologies/strykelang · [`fusevm`]https://github.com/MenkeTechnologies/fusevm · [`compsys`]compsys/

---

## Table of Contents

- [\[0x00\] Overview]#0x00-overview
- [\[0x01\] Install]#0x01-install
- [\[0x02\] No-Fork Architecture]#0x02-no-fork-architecture
- [\[0x03\] Bytecode Compilation]#0x03-bytecode-compilation
- [\[0x04\] Concurrent Primitives]#0x04-concurrent-primitives
- [\[0x05\] AOP Intercept]#0x05-aop-intercept
- [\[0x06\] Worker Thread Pool]#0x06-worker-thread-pool
- [\[0x07\] SQLite Caching]#0x07-sqlite-caching
- [\[0x08\] Exclusive Builtins]#0x08-exclusive-builtins
- [\[0x09\] Compatibility]#0x09-compatibility
- [\[0x0A\] Architecture]#0x0a-architecture
- [\[0xFF\] License]#0xff-license

---

## [0x00] OVERVIEW

zshrs replaces `fork + exec` with a persistent worker thread pool, compiles every command to [fusevm](https://github.com/MenkeTechnologies/fusevm) bytecodes, caches compiled chunks in SQLite, and runs the completion system on FTS5 indexes. The result: shell startup, command dispatch, globbing, completion, and autoloading are all faster by orders of magnitude.

---

## [0x01] INSTALL

```sh
# From crates.io
cargo install zshrs

# From source — lean build, pure shell, no stryke dependency
git clone https://github.com/MenkeTechnologies/zshrs
cd zshrs && cargo build --release
# binary: target/release/zshrs

# Set as login shell
sudo sh -c 'echo ~/.cargo/bin/zshrs >> /etc/shells'
chsh -s ~/.cargo/bin/zshrs
```

---

## [0x02] NO-FORK ARCHITECTURE

Every operation that zsh forks for runs in-process on a persistent worker thread pool:

| Operation | zsh | zshrs |
|-----------|-----|-------|
| `$(cmd)` | fork + pipe | In-process stdout capture via `dup2` |
| `<(cmd)` / `>(cmd)` | fork + FIFO | Worker pool thread + FIFO |
| `**/*.rs` | Single-threaded `opendir` | Parallel `walkdir` per-subdir on pool |
| `*(.x)` qualifiers | N serial `stat` calls | One parallel metadata prefetch |
| `rehash` | Serial `readdir` per PATH dir | Parallel scan across pool |
| `compinit` | Synchronous fpath scan | Background scan + bytecode compilation |
| History write | Synchronous `fsync` | Fire-and-forget to pool |
| Autoload | Read file + parse every time | Bytecode deserialization from SQLite |
| Plugin source | Parse + execute every startup | Delta replay from SQLite cache |

---

## [0x03] BYTECODE COMPILATION

Every command compiles to [fusevm](https://github.com/MenkeTechnologies/fusevm) bytecodes:

```
Interactive command  ──► Parser ──► ShellCompiler ──► fusevm::Op ──► VM::run()
Script file (first)  ──► Parser ──► ShellCompiler ──► VM::run() ──► cache in SQLite
Script file (cached) ──► SQLite ──► deserialize Chunk ──► VM::run()
                         (no lex, no parse, no compile)
Autoload function    ──► SQLite ──► deserialize Chunk ──► VM::run()
                         (microseconds)
```

The shell compiler targets the same `Op` enum that [strykelang](https://github.com/MenkeTechnologies/strykelang) uses. Both frontends share fused superinstructions, extension dispatch, and the Cranelift JIT path.

---

## [0x04] CONCURRENT PRIMITIVES

Full parallelism in the lean binary. No stryke dependency needed.

```zsh
# Async/await
id=$(async 'sleep 5; curl https://api.example.com')
result=$(await $id)

# Parallel map — ordered output
pmap 'gzip {}' *.log

# Parallel filter
pgrep 'grep -q TODO {}' **/*.rs

# Parallel for-each — unordered, fire as completed
peach 'convert {} {}.png' *.svg

# Barrier — run all, wait for all
barrier 'npm test' ::: 'cargo test' ::: 'pytest'
```

---

## [0x05] AOP INTERCEPT

First shell with aspect-oriented programming:

```zsh
# Before — log every git command
intercept before git { echo "[$(date)] git $INTERCEPT_ARGS" >> ~/git.log }

# After — timing
intercept after '_*' { echo "$INTERCEPT_NAME took ${INTERCEPT_MS}ms" }

# Around — memoize
intercept around expensive_func {
    local cache=/tmp/cache_${INTERCEPT_ARGS// /_}
    if [[ -f $cache ]]; then cat $cache
    else intercept_proceed | tee $cache; fi
}
```

---

## [0x06] WORKER THREAD POOL

Persistent pool of [2-18] threads. Configurable:

```toml
# ~/.config/zshrs/config.toml
[worker_pool]
size = 8

[completion]
bytecode_cache = true

[history]
async_writes = true

[glob]
parallel_threshold = 32
recursive_parallel = true
```

---

## [0x07] SQLITE CACHING

Three databases power the shell:

| Database | Purpose |
|----------|---------|
| **compsys.db** | Completions: autoloads with bytecodes, comps, services, PATH executables (FTS5) |
| **history.db** | Frequency-ranked, timestamped, duration, exit status per command |
| **plugins.db** | Plugin delta cache: functions, aliases, variables, hooks, zstyles, options |

Browse without SQL:

```zsh
dbview                        # list tables + row counts
dbview autoloads _git         # single function: source, body, bytecode status
dbview comps git              # search completions
dbview history docker         # search history
```

---

## [0x08] EXCLUSIVE BUILTINS

| Builtin | Description |
|---------|-------------|
| `intercept` | AOP before/after/around advice on any command |
| `intercept_proceed` | Call original from around advice |
| `async` / `await` | Ship work to pool, collect result |
| `pmap` | Parallel map with ordered output |
| `pgrep` | Parallel filter |
| `peach` | Parallel for-each, unordered |
| `barrier` | Run all commands in parallel, wait for all |
| `doctor` | Full diagnostic: pool metrics, cache stats, bytecode coverage |
| `dbview` | Browse SQLite caches without SQL |
| `profile` | In-process command profiling with nanosecond accuracy |

---

## [0x09] COMPATIBILITY

- Full zsh script compatibility — runs existing `.zshrc`
- Full bash compatibility via emulation
- Fish-style syntax highlighting, autosuggestions, abbreviations
- 150+ builtins ported from zsh
- ZWC precompiled function support
- Glob qualifiers, parameter expansion flags, completion system
- zstyle, ZLE widgets, hooks, modules

---

## [0x0A] ARCHITECTURE

```
                  ┌──────────────────────────────────────────┐
                  │              zshrs binary                 │
                  ├──────────────┬───────────────────────────┤
                  │   src/ (80)  │      fish/ (48 builtins)  │
                  │   lexer      │      reader + line editor  │
                  │   parser     │      syntax highlighting   │
                  │   compiler   │      autosuggestions        │
                  │   exec       │      abbreviations          │
                  │   jobs       │      env dispatch           │
                  │   signals    │      history backend        │
                  │   params     │      process control        │
                  │   glob       │      event system           │
                  │   zle/ (26)  │                             │
                  ├──────────────┴───────────────────────────┤
                  │             compsys (27 files)            │
                  │   SQLite FTS5 · menuselect · zstyle      │
                  ├────────���─────────────────────────────────┤
                  │           fusevm (bytecode VM)            │
                  │   127 opcodes · fused loops · JIT path   │
                  └──────────────────────────────────────────┘
```

---

## [0xFF] LICENSE

MIT — Copyright (c) 2026 [MenkeTechnologies](https://github.com/MenkeTechnologies)