The `tangu` binary provides project scaffolding, execution, compilation, testing, formatting, linting, semantic navigation, refactoring, and API documentation in one self-contained CLI alongside `tangu-language-server` (LSP).

## Global flags

Every `tangu` subcommand accepts:

- `--json` — Emit structured machine-readable JSON output.
- `--no-color` — Disable ANSI color sequences in terminal output.
- `-v`, `--verbose` — Show detailed execution and diagnostic information.
- `-h`, `--help` — Print command-line help.
- `-V`, `--version` — Print the installed `tangu` version.

## Execution & evaluation

### `tangu run`

Executes a `.tan` script or project directory (reads `manifest.data.tan` when omitted) and forwards trailing arguments to the program.

```sh
tangu run main.tan arg1 arg2
tangu run --type-check main.tan
tangu run --jit --strict compute.tan
tangu run --hot-reload app/server.tan
tangu run --release --opt aggressive main.tan
```

Options: `--type-check`, `--no-type-check`, `--hot-reload`, `--jit`, `--strict`, `--release`, `--opt <none|basic|aggressive|speed|speed_and_size>`.

### `tangu eval` (alias `e`)

Evaluates an expression directly from arguments or `--stdin` with optional module imports and JIT execution.

```sh
tangu eval "(+ 1 2 3)"
tangu eval -u /chrono "(String (Date))"
tangu eval -r -u /string "(to-upper-case \"tangu\")"
```

Options: `-e, --expr <EXPR>`, `-m, --module <MODULE_PATH>`, `-C, --context <PATH>`, `-u, --use <SPEC>`, `--stdin`, `-r, --raw`, `--no-type-check`, `--jit`, `--strict`.

### `tangu repl`

Starts an interactive REPL session for experimenting with expressions, prelude functions, and `@standard` imports.

```sh
tangu repl
```

### `tangu compile` (alias `c`)

Compiles Tangu programs ahead of time to native executables, Cranelift object files/IR, Rust crates, or JavaScript modules.

```sh
tangu compile -t native -o dist/service main.tan
tangu compile -t cranelift --emit-obj -o build/service.o main.tan
tangu compile -t rust --cargo --out-dir target/rust-out main.tan
tangu compile -t js -f esm --emit js,dts,map --bundle --minify -o dist/app.js main.tan
```

Options: `-t, --target <js|rust|cranelift|native>`, `-f, --format <esm|cjs|iife>`, `--emit <js,dts,map>`, `-o, --output <PATH>`, `--out-dir <DIR>`, `--minify`, `-b, --bundle`, `--skip-comments`, `--lib`, `--bin`, `--rustfmt`, `--profile`, `--emit-obj`, `--emit-clif`, `--opt <LEVEL>`, `--target-triple <TRIPLE>`, `--cargo`.

### `tangu bench`

Runs `#bench` functions across optimization levels and execution engines (`--jit`, `--native`).

```sh
tangu bench --dir benchmarks --iters 20 --only json
tangu bench --jit --opt aggressive --json
```

Options: `--dir <DIR>`, `--iters <N>`, `--opt <none|basic|aggressive>`, `-o, --only <PATTERN>`, `--jit`, `--native`.

## Quality, testing & formatting

### `tangu test`

Discovers and runs `#test` unit and integration tests (`*.test.tan`) in parallel.

```sh
tangu test
tangu test --changed --only auth
tangu test -x --file app/handler.test.tan
tangu test --release --opt basic --json
```

Options: `--stdin-filepath <FILE>`, `--file <FILE>`, `--only <REGEX>`, `-x, --fail-fast`, `-q, --quiet`, `--failed-only`, `--release`, `--opt <LEVEL>`, `--changed`, `--staged`, `--direct`, `--list`.

### `tangu check`

Runs static parsing, type checking, symbol resolution, and critical lint checks across files or workspaces.

```sh
tangu check app/
tangu check --fast --changed --json
```

Options: `--stdin`, `--stdin-filepath <FILE>`, `--fast` (alias `types-only`), `--changed`, `--staged`, `-q, --quiet`, `--errors-only`, `--max-diagnostics <N>`.

### `tangu lint`

Runs static code-quality, dialect (`#shtml`/`#css`), performance, and import rules across Tangu files. Browse all rules interactively at [Lint rules](/lints).

```sh
tangu lint app/
tangu lint --category correctness --errors-only
tangu lint --fix --all app/
tangu lint --list-rules --json
tangu lint --explain unused-variable
```

Options: `--stdin-filepath <FILE>`, `--changed`, `--staged`, `--fix`, `--all`, `--dry-run`, `-q, --quiet`, `--errors-only`, `--max-diagnostics <N>`, `--list-rules`, `--explain <RULE>`, `-c, --category <CAT>`, `-r, --rule <RULE>`.

### `tangu fix`

Applies safe lint auto-fixes, unambiguous `(use ...)` auto-imports, and canonical formatting in one command.

```sh
tangu fix --changed --auto-import
tangu fix --dry-run --rule redundant-else
```

Options: `--changed`, `--staged`, `--dry-run`, `--auto-import`, `--no-format`, `-r, --rule <RULE>`, `--stdin`, `--stdin-filepath <FILE>`, `-q, --quiet`.

### `tangu format`

Formats `.tan`, `.data.tan`, `#shtml`, and `#css` sources deterministically.

```sh
tangu format app/
tangu format --check --diff .
```

Options: `-d, --dialect <code|data|html|css>`, `--stdout`, `--check`, `--diff`, `--stdin-filepath <FILE>`.

## Introspection & refactoring

### `tangu sym`

Queries AST outlines, symbol definitions, workspace references, trait implementations, call graphs, and inferred hover types.

```sh
tangu sym outline app/ --json
tangu sym search "handle-" --json
tangu sym def app/handler.tan:12:5 --json
tangu sym refs app/handler.tan:12:5 --json
tangu sym impls Display --json
tangu sym calls route-map --json
tangu sym hover app/handler.tan:18:10 --json
```

Subcommands: `outline`, `search`, `def`, `refs`, `impls`, `calls`, `hover`.

### `tangu refactor`

Executes workspace-wide semantic symbol renames and module moves with import rewriting.

```sh
tangu refactor rename old-fn new-fn --json
tangu refactor move app/old-name.tan app/new-dir/name.tan --json
```

Subcommands: `rename`, `move`.

### `tangu doc` (alias `docs`)

Looks up inline API documentation for `/prelude`, `@standard` modules, symbols, `.schema.tan` definitions, or workspace files.

```sh
tangu doc --list
tangu doc /chrono --json
tangu doc count-of
tangu doc --search "uuid" --stdlib-only
tangu doc --schema user.schema.tan
```

Options: `-s, --search <QUERY>`, `-l, --list`, `--schema`, `--stdlib-only`, `--workspace-only`.

### `tangu dump` (alias `debug`)

Prints lexer tokens, delimiter depth checks, AST trees, macro expansions, TIR, Cranelift IR, or transpiled JavaScript.

```sh
tangu dump --ast main.tan
tangu dump --tokens --ranges main.tan
tangu dump --delimiters broken.tan
tangu dump --expanded --macro-step --at 14:5 main.tan
tangu dump --tir main.tan
tangu dump --clif main.tan
tangu dump --js main.tan
```

Options: `--stdin-filepath <FILE>`, `--ast`, `--tokens`, `--delimiters`, `--lines <START:END>`, `--expanded`, `--macro-step`, `--at <LINE:COL>`, `--tir`, `--clif`, `--js`, `--ranges`, `--compact`.

## Projects, dependencies & maintenance

### `tangu new`

Scaffolds a binary application (`--bin`) or library (`--lib`) workspace with `manifest.data.tan` and starter source/test files.

```sh
tangu new my-service
tangu new --lib my-toolkit
```

### `tangu manifest`

Initializes or bumps versions inside `manifest.data.tan`.

```sh
tangu manifest init
tangu manifest bump-patch
```

Subcommands: `init`, `bump-major`, `bump-minor`, `bump-patch`.

### `tangu deps`

Manages package dependencies declared in `manifest.data.tan`.

```sh
tangu deps install
tangu deps update
tangu deps list
tangu deps clean
```

Subcommands: `install`, `update`, `list`, `clean`.

### `tangu schema`

Validates `.data.tan` documents against `.schema.tan` definitions or synthesizes conformant sample data.

```sh
tangu schema check config.schema.tan config.data.tan
tangu schema sample config.schema.tan
```

Subcommands: `check`, `sample`.

### `tangu doctor`

Verifies `$TANGU_ROOT`, standard library `.so` availability, compiler paths, and environment configuration.

```sh
tangu doctor
```

### `tangu upgrade`

Downloads and installs the latest release bundle from `tangu.dev` (or a custom `--url` / `TANGU_SERVER_URL`).

```sh
tangu upgrade
tangu upgrade --force
```

## Language server (`tangu-language-server`)

The installer places `tangu-language-server` alongside `tangu` to provide full Language Server Protocol (LSP) integration over stdio for VS Code, Neovim, Helix, and Zed:

- **Navigation & intelligence**: Go to definition, declaration, type definition, and trait implementation; find references; workspace & document symbols; call hierarchy (`prepare`, `incoming`, `outgoing`); type hierarchy (`prepare`, `subtypes`, `supertypes`).
- **Editing & diagnostics**: Autocomplete with item resolution, parameter signature help, hover types & docs, inlay type/parameter hints, folding ranges, selection ranges, semantic tokens (full/delta/range), linked editing, and pull/workspace diagnostics with quick-fix code actions.
- **Formatting & commands**: Full-document, range, and on-type CST/AST formatting, workspace file-rename import updates (`willRenameFiles`), plus editor commands for macro expansion, inline evaluation, and running `#test` targets directly from CodeLens annotations.

Configure your LSP client to launch `tangu-language-server` for `.tan`, `.data.tan`, and `.schema.tan` files. Ensure `$TANGU_ROOT` is exported in your login shell or editor environment so standard library imports resolve automatically.
