# Install & run on every terminal

`kb` is the universal CLI. Same commands whether you used **brew**, **uv**, **go**, **npm**, **cargo**, or a plain path link.

## One-shot (recommended)

```bash
cd ~/Projects/KBatch-dictionary   # or git clone …
chmod +x install.sh bin/kb
./install.sh                      # auto: path + npm + go + uv if present
# or
./install.sh all                  # try every toolchain
make install
```

Then:

```bash
kb doctor
kb serve          # http://127.0.0.1:8765
kb open           # serve + browser
kb update         # registers + gutter vendor + stamp
kb upgrade        # + version bump set
```

---

## By toolchain

### Path / any shell

```bash
./install.sh path
export PATH="$HOME/.local/bin:$PATH"
kb doctor
```

### Homebrew

```bash
# from this checkout
brew install --build-from-source ./Formula/kbatch.rb

# after you publish a tap
# brew install qbitOS/tap/kbatch

kb serve
```

Depends on **node** (and recommends **python@3.12** for `http.server`).

### npm / node

```bash
npm install
npm link                 # puts `kb` on PATH via package.json bin
# or
npm install -g .

kb version
kb serve
```

### uv / pip (Python)

```bash
uv tool install --from . ugrad-kbatch
# or editable
uv pip install -e .

kb serve
# module form
python -m kbatch_cli doctor
```

Requires the full checkout (or packaged tree with `bin/kb` + `scripts/`).

### Go

```bash
go install ./cmd/kb
# ensure $(go env GOPATH)/bin on PATH
export PATH="$(go env GOPATH)/bin:$PATH"

kb doctor
kb update
```

The Go binary is a thin launcher into `bin/kb` / `KBATCH_ROOT`.

### Cargo / Rust

```bash
cargo install --path rust-cli --force
kb version
```

### Make

```bash
make install
make doctor
make serve
make go-install uv-install npm-link cargo-install brew-local
```

---

## Environment

| Var | Default | Meaning |
|-----|---------|---------|
| `KBATCH_ROOT` | auto-detect | Project root (package.json + index.html) |
| `KBATCH_PORT` | `8765` | `kb serve` port |
| `KBATCH_HOST` | `127.0.0.1` | Bind address |
| `KBATCH_PREFIX` | `~/.local` | `./install.sh path` prefix |

---

## Commands

```
kb serve [port]       Static SPA
kb open               Serve + open browser
kb update|upgrade     KB update set
kb stamp              Cache-bust stamp
kb registers          Grow slang/shorthand layers
kb analyze "text"     Quick shadow strip (node)
kb version
kb doctor
kb help
```

In-app terminal (browser): same verbs — `update`, `upgrade`, `mesh`, `gutter`, …

---

## Doctor checklist

`kb doctor` reports:

- node · npm · python3 · uv · go · brew · cargo · wrangler  
- index.html · quantum gutter vendor · data/words · registers  

Minimum to **serve UI**: `python3` *or* `npx`  
Minimum to **update KB**: `node`  
Optional: full corpus via `npm run grow-corpus` (large)

---

## Uninstall

```bash
# path link
rm -f ~/.local/bin/kb ~/.local/bin/kbatch

# npm
npm unlink -g ugrad-kbatch

# brew
brew uninstall kbatch

# go
rm -f "$(go env GOPATH)/bin/kb"

# cargo
cargo uninstall kbatch-cli

# uv
uv tool uninstall ugrad-kbatch
```
