···11-# adiff
22-33-A semantic, side-by-side diff viewer for the terminal with `$EDITOR` support.
44-55-Unlike traditional diff tools, adiff uses [tree-sitter](https://tree-sitter.github.io/tree-sitter/) to parse source files into ASTs and diffs at the token level. This means pure formatting changes — re-indented blocks, reformatted function signatures, whitespace normalization — are shown as equal, while genuine logic changes are clearly highlighted.
66-77-
88-99-## Features
1010-1111-- **Semantic diff** — tree-sitter token-level diffing ignores style-only changes
1212-- **Syntax highlighting** — per-language color via [Chroma](https://github.com/alecthomas/chroma)
1313-- **Live file watching** — press `e` to open the new file in `$EDITOR`; adiff watches for saves and reloads automatically
1414-- **Vim keybindings** — `j`/`k`, `g`/`G`, `n`/`p` for change navigation
1515-- **Themeable** — TOML theme files with full colour control; `nord` built-in
1616-1717-### Semantic Supported languages
1818-1919-Bash, C, C++, Go, JavaScript, JSON, Nix, Python, Ruby, Rust, TypeScript
2020-2121-### Supported languages
2222-2323-All languages without semantic support are supported with traditional text diffs
2424-2525-## Installation
2626-2727-### Nix (flake)
2828-2929-```nix
3030-inputs.adiff.url = "git+https://tangled.org/adriano.tngl.sh/adiff";
3131-```
3232-3333-Then add `inputs.adiff.packages.${system}.default` to your packages, or use the provided overlay.
3434-3535-**Direct package reference** (home-manager / NixOS `environment.systemPackages`):
3636-3737-```nix
3838-home.packages = [ inputs.adiff.packages.${pkgs.system}.default ];
3939-```
4040-4141-**Overlay** — adds `pkgs.adiff` to your package set:
4242-4343-```nix
4444-nixpkgs.overlays = [ inputs.adiff.overlays.default ];
4545-4646-# Then reference it like any nixpkgs package:
4747-home.packages = [ pkgs.adiff ];
4848-```
4949-5050-In a NixOS or home-manager flake this typically looks like:
5151-5252-```nix
5353-{
5454- inputs = {
5555- nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
5656- home-manager.url = "github:nix-community/home-manager";
5757- adiff.url = "git+https://tangled.org/adriano.tngl.sh/adiff";
5858- };
5959-6060- outputs = { nixpkgs, home-manager, adiff, ... }: {
6161- homeConfigurations.yourname = home-manager.lib.homeManagerConfiguration {
6262- pkgs = import nixpkgs {
6363- system = "x86_64-linux";
6464- overlays = [ adiff.overlays.default ];
6565- };
6666- modules = [
6767- ({ pkgs, ... }: { home.packages = [ pkgs.adiff ]; })
6868- ];
6969- };
7070- };
7171-}
7272-```
7373-7474-## Usage
7575-7676-```
7777-adiff [flags] <old-file> <new-file>
7878-```
7979-8080-| Flag | Default | Description |
8181-|------|---------|-------------|
8282-| `-theme` | `nord` | Theme name or path to a `.toml` file |
8383-8484-### Keybindings
8585-8686-| Key | Action |
8787-|-----|--------|
8888-| `j` / `k` | Move down / up |
8989-| `n` / `p` | Jump to next / previous change |
9090-| `g` / `G` | Jump to top / bottom |
9191-| `s` | Toggle semantic ↔ text diff mode |
9292-| `e` | Open new file in `$EDITOR`; diff reloads on save |
9393-| `q` | Quit |
9494-9595-## Diff modes
9696-9797-**Semantic mode** (default) uses the tree-sitter AST to identify which tokens actually changed. Adjacent removed/added line blocks where all tokens are identical are collapsed into equal (unhighlighted) lines. Only lines containing genuinely changed tokens are highlighted.
9898-9999-**Text mode** falls back to a standard line-level diff with no AST involvement. Toggle between modes with `s`.
100100-101101-## Themes
102102-103103-Themes are TOML files. adiff searches for themes in this order:
104104-105105-1. Literal path (if the value contains `/` or ends in `.toml`)
106106-2. `~/.config/adiff/themes/<name>.toml`
107107-3. Built-in `nord`
108108-109109-### Theme format
110110-111111-```toml
112112-[meta]
113113-name = "mytheme"
114114-description = "My custom theme"
115115-author = "you"
116116-117117-[chroma]
118118-style = "nord" # any Chroma style name
119119-120120-[diff]
121121-added_bg = "#2E4034"
122122-added_fg = "#A3BE8C"
123123-removed_bg = "#3D1F1F"
124124-removed_fg = "#BF616A"
125125-equal_fg = "#D8DEE9"
126126-header_fg = "#88C0D0"
127127-line_number_fg = "#4C566A"
128128-status_fg = "#5E81AC"
129129-help_fg = "#4C566A"
130130-cursor_symbol = "▶"
131131-```
132132-133133-Place custom themes at `~/.config/adiff/themes/<name>.toml` and reference them with `-theme <name>`.
134134-135135-## hookable integration
136136-137137-[hookable](https://tangled.org/adriano.tngl.sh/hookable) is a Claude Code hook runner that exposes tool call inputs as environment variables and forwards them to an arbitrary command. adiff reads these variables natively, so it can be dropped in as the `--cmd` to preview file changes before Claude applies them.
138138-139139-When invoked with no file arguments and `HOOKABLE_TOOL_NAME` is set, adiff constructs the before/after diff automatically:
140140-141141-| Tool | Before | After |
142142-|------|--------|-------|
143143-| `Edit` | Current file on disk | File with `old_string` replaced by `new_string` |
144144-| `Write` | Current file on disk (empty if new) | Incoming content |
145145-146146-### Claude Code hook configuration
147147-148148-Add to `~/.claude/settings.json`:
149149-150150-```json
151151-{
152152- "hooks": {
153153- "PreToolUse": [
154154- {
155155- "matcher": "Edit",
156156- "hooks": [{"type": "command", "command": "hookable --interactive --no-exit-code --cmd 'adiff -i'"}]
157157- },
158158- {
159159- "matcher": "Write",
160160- "hooks": [{"type": "command", "command": "hookable --interactive --no-exit-code --cmd 'adiff -i'"}]
161161- }
162162- ]
163163- }
164164-}
165165-```
166166-167167-`--interactive` runs adiff under a PTY so the full TUI renders. `--no-exit-code` tells hookable to ignore adiff's exit code and always wait for a keypress — press `y` to allow the change or `n` to deny it.
11+# sdiff
1682169169-## Development
33+`sdiff` has been renamed [adiff](https://tangled.org/adriano.tngl.sh/adiff/), but Tangled does not support repo renames.
1704171171-```sh
172172-nix develop # CGO-aware dev shell
173173-go test ./... # run tests
174174-nix build # hermetic build → ./result/bin/adiff
175175-```
55+Now at: [https://tangled.org/adriano.tngl.sh/adiff/](https://tangled.org/adriano.tngl.sh/adiff/)