> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# Pack and install a plugin from a local signed registry

You pack a plugin into a registry you sign, point a kernel at it, install the plugin by its consent digest, then update and remove it. You need a checkout [built from source](https://docs.taji.is/guide/install.md) with `cargo build -p taji-open -p echo`, and `jq`. Every command runs from the repository root, in one shell.

A [registry](https://docs.taji.is/reference/glossary.md#signed-registry) is a directory you sign: `index.json`, its signature and one artifact per version. There is no hosted registry, so the directory is local and the setting that names it is a `file://` URL. The kernel checks the index's signature against its registry key before it reads a line of it. A release kernel holds no key and installs from no registry; a debug kernel reads the public key from `TAJI_REGISTRY_KEY` ([configuration](https://docs.taji.is/reference/configuration.md#environment-variables)). Your own plugin takes the same steps as `echo`, the plugin below.

## 1. Stage a clean directory

`pack` builds nothing. It packs the directory as it stands, so build the program first and copy what ships into a new directory:

| In the directory | What pack does |
|---|---|
| `taji-plugin.toml`, the program `[process] run` names | Packs them. The program is the built file, `echo` here, or its `.exe` on Windows. |
| `SKILL.md`, indicator scripts, the Python `lock` | Packs them and signs their text into the index, because consent shows each whole. A `SKILL.md` opens with `---` frontmatter holding `name` (the plugin's id) and a `description` of 1,024 characters at most, and is under 500 lines; `pack` refuses one that is not. |
| `ui/` | Packs only `index.js`, `index.css`, `.svg` and `.png` files and the renderer scripts and shaders your `[[ui.layers]]` name, from its top level. Run `bun run ui/pack.ts <dir>` first ([window reference](https://docs.taji.is/plugins/window.md#pack-serve-and-open)). |
| Anything else | Packs it, except `.venv` and `node_modules` at any depth. A `target/` that `plugin check` or `plugin dev` wrote is packed too, so stage a copy instead of packing your working directory. |

A symlink anywhere in the directory is refused.

```sh
W=$(mktemp -d); mkdir -p "$W/echo" "$W/registry"
cp plugins/echo/taji-plugin.toml target/debug/echo$([ "$OS" = Windows_NT ] && echo .exe) "$W/echo/"
```

## 2. Make a key and pack

`keygen` writes the private key to a file, mode `0600`, and never over one that exists. It prints the public key, 64 hex digits, alone on stdout. Keep the private key outside the registry directory. `pack` writes the artifact, adds its entry to `index.json` and signs the index again. `--publisher` is the name consent shows.

```sh
export TAJI_REGISTRY_KEY=$(target/debug/taji registry keygen "$W/registry.key")
target/debug/taji registry pack --registry "$W/registry" --key "$W/registry.key" --publisher "Me" "$W/echo"
```

You see one line, `packed echo 0.1.0` and the artifact's sha256. The registry holds `artifacts/echo-0.1.0.tar.gz`, `index.json` and `index.json.sig`.

- Packing an id and version already in the index repacks only from the same bytes under the same publisher. Anything else is refused: pack a higher `version`.
- The same tree packs to the same bytes on every OS, whatever mode its filesystem gives a file.

## 3. Boot a kernel that holds the key

Boot a headless kernel on throwaway state, in the shell that exported `TAJI_REGISTRY_KEY`. `TAJI_WIRE=0` takes a free port, and every request carries the token in `x-taji-token`:

```sh
mkdir -p "$W/state" "$W/store" "$W/home"
export TAJI_NO_UPDATE_CHECK=1 TAJI_NO_REPORT=1 TAJI_STATE_DIR=$W/state TAJI_STORE_DIR=$W/store TAJI_HOME=$W/home
TAJI_HEADLESS=1 TAJI_WIRE=0 target/debug/taji > "$W/boot.log" 2>&1 &
until [ -s "$W/state/wire-token" ] && curl -sf -o /dev/null -H "x-taji-token: $(cat "$W/state/wire-token")" "localhost:$(cat "$W/state/wire-port")/"; do sleep 1; done
PORT=$(cat "$W/state/wire-port"); TOKEN=$(cat "$W/state/wire-token")
get() { curl -s -H "x-taji-token: $TOKEN" "localhost:$PORT/$1"; echo; }
v() { curl -s -H "x-taji-token: $TOKEN" -H 'content-type: application/json' -X POST "localhost:$PORT/verb/$1" --data-binary "$2"; echo; }
```

## 4. Name the registry

Set `taji.plugins.registry` to the registry's absolute `file://` URL:

```sh
v ui/settings/set "{\"key\":\"taji.plugins.registry\",\"value\":\"file://$W/registry\"}"
```

You see the key and a `seq` number. Until you set it, `GET /read/plugins/index` answers `503 no_registry`.

## 5. Read the offer

`GET /read/plugins/index` verifies the signature and answers one offer per version in the index. Echo's has six `lines`: its publisher, that it places no order, that it runs its own program, that it has no network and its one verb and node. Each field of an offer:

| Field | It is |
|---|---|
| `lines` | What consent says, one sentence per grant. A manifest's own words come only after "it says:". |
| `added` | The lines the installed version lacks, every line when none is installed. |
| `digest` | The 64 hex digits that bind those lines to the artifact. Installing sends it back. |
| `refused` | What an install would refuse the offer with, `null` if nothing. |
| `installed` | The installed record of the plugin, `null` if none. |

```sh
D=$(get read/plugins/index | jq -r '.[] | select(.version == "0.1.0") | .digest'); echo "$D"
```

You see 64 hex digits. The `agent` token cannot read the index (`403 scope`): the lines hold skill text nobody has agreed to.

## 6. Install

Send the digest as `consent`. Only the `local` token and a sheet's may install; the `agent` and `page` tokens get `403 scope`.

```sh
v plugins/install "{\"id\":\"echo\",\"version\":\"0.1.0\",\"consent\":\"$D\"}"
v echo/say '{"text":"hello"}'
```

You see echo's `GET /read/plugins` row, with `"source":"installed"`, `"publisher":"Me"` and `"enabled":true`, then the verb's answer, `{"said":"hello"}`.

- Taji unpacked the package into `<state dir>/plugins/echo/package-<12 hex>/`, started its process in the sandbox and recorded what you agreed to in `<state dir>/plugins.json`. A plugin with a `SKILL.md` also has it laid into the `taji` skill.
- Any other digest is `409 consent`, and its body holds the lines and the digest the offer wants.

## 7. Update, disable and remove

To update, pack a higher `version` into the same registry and install the new offer's digest. The index keeps every version, so select the new one:

```sh
sed 's/^version = "0.1.0"/version = "0.2.0"/' "$W/echo/taji-plugin.toml" > "$W/echo/next.toml" && mv "$W/echo/next.toml" "$W/echo/taji-plugin.toml"
target/debug/taji registry pack --registry "$W/registry" --key "$W/registry.key" --publisher "Me" "$W/echo"
D=$(get read/plugins/index | jq -r '.[] | select(.version == "0.2.0") | .digest')
v plugins/install "{\"id\":\"echo\",\"version\":\"0.2.0\",\"consent\":\"$D\"}"
```

The new offer's first line is `Updates Echo from 0.1.0 to 0.2.0.`, and its `added` holds only the lines the old version lacks. It also lists each alert the update stops (one pinned to a script at the version it leaves) and each Desk whose own script of the same name the install takes over. The same id from another publisher is a different offer: `lines[0]` names both publishers, `added` is every line, and the plugin starts unlinked.

`plugins/disable`, `plugins/enable` and `plugins/uninstall` take the id:

```sh
v plugins/disable '{"id":"echo"}'
v plugins/enable '{"id":"echo"}'
v plugins/uninstall '{"id":"echo"}'
v ui/quit '{}'
```

- Disable stops the process and takes its verbs out of the registry; its row stays, `enabled` false with `reason` `disabled`.
- Enable checks the package against what you agreed to and starts it again. If the package changed on disk, it answers `409 consent`: install it again.
- Uninstall forgets the plugin's link, removes its record and deletes its files; its row is gone.

`engine/crates/taji/scripts/plugin_install_gate.sh` walks every step, with the `sheet` token and the consent page.

## If it fails

- **`503 no_registry`:** the setting is unset or is not an absolute `file://` directory, or the kernel holds no key. Export `TAJI_REGISTRY_KEY` before you start the kernel.
- **`502 signature`:** `index.json` changed after it was signed, or another key signed it. Pack again with the key whose public half the kernel holds.
- **`409 consent`:** the digest is not the offer's. An update's digest differs from the installed version's: read the index again.
- **`409 claim`:** the id belongs to this build, `TAJI_PLUGINS` or a first-party provider. Rename it.
- **`409 manifest`:** the offer's `refused` says which rule the package breaks.

The `plugins/install` row in the `//!` header of `engine/crates/taji/src/wire/mod.rs` lists every refusal.

## Next

- [The plugin platform](https://docs.taji.is/architecture/plugins.md): the registry, the tiers and install, from the inside.
- [The manifest](https://docs.taji.is/plugins/manifest.md): every field a package's lines are derived from.
- [Build your first plugin](https://docs.taji.is/plugins/first-plugin.md): a plugin worth packing.
- [Configuration](https://docs.taji.is/reference/configuration.md#environment-variables): `TAJI_REGISTRY_KEY` and every other variable.
