# Sharing plugins

There is no plugin registry yet. A shared plugin today is a pack in a git
repository that people clone or copy. This page is a convention for doing that
well, so packs from different people install the same way and do not collide.

### Lay out a pack repository

One pack per repository, named `borer-pack-<name>`:

```text
borer-pack-sqlite-win/
  sqlite-win.borer          the pack: pack sqlite-win 1
  sqlite-win/               its scripts, in a folder named after the pack
    logger_names.rhai
    label_table.rhai
  README.md                 what it is for, what it names, which borer it needs
  LICENSE
```

- **The name** is one word, lowercase, words joined by `-`: the family and,
  when it matters, the platform or the version (`sqlite-win`, `qt6`,
  `unreal-5`). It is the word on the `pack` line and the file's name.
- **The scripts** go in a folder named after the pack, and the `[scripts]`
  lines name them through it: `run sqlite-win/logger_names.rhai`. Two packs
  installed side by side then never share a `scripts/` folder.
- **`[match]`** should be specific enough that the pack loads for its family
  and nothing else. A pack with no `[match]` lines never loads by itself.

### Install a pack

borer reads the `.borer` files directly inside each pack directory, and a
script's path is relative to its pack's file. Either of these works:

- Copy `sqlite-win.borer` and the `sqlite-win/` folder into your pack
  directory: `%APPDATA%\borer\packs` on Windows, `~/.config/borer/packs` (or
  `$XDG_CONFIG_HOME/borer/packs`) elsewhere.
- Clone the repository anywhere and add the clone to `BORER_PACK_DIRS`. That
  variable replaces the default directories, so list them too if you want
  both.

Then check that it loads for a binary it is meant for, and not for one it is
not:

```text
$ borer packs sqlite3.dll
...
sqlite-win	1	packs\sqlite-win.borer	yes	string os_win.c:%d: (%lu) %s(%s) - %s, export sqlite3_open_v2
...
# pack scripts: 2 ran, 0 failed, 20 functions named

$ borer packs notepad.exe
...
sqlite-win	1	packs\sqlite-win.borer	no	fails string os_win.c:%d: (%lu) %s(%s) - %s
```

To use a pack for one run only, name it: `borer --pack sqlite-win.borer ...`,
or `BORER_PACKS` for the MCP server.

### Version a pack

The second word on the `pack` line is its version. borer prints it and does
not compare it, so the convention is up to you:

- Start at `1` and add one whenever the pack names something differently.
- Tag the commit with the same number, `v2`, so a user can pin it.
- When two packs of the same name are installed, the one you name with
  `--pack` or `BORER_PACKS` wins. Between two pack directories, the first
  directory wins; within a directory, the first file name.

### Say which borer it needs

A pack written for a newer borer still loads in an older one: a key the older
one does not read is kept and warned about. A script is stricter: a call the
older borer lacks fails with `Function not found`, and that script names
nothing. State the borer version you tested with in the README. A script can
also check for a call before using it, since `help` answers `no call ...` for
one that does not exist:

```rhai
if help("layout").starts_with("no call") {
  print("this borer has no layout(); the field map is skipped");
}
```

### Before you publish

- `borer pack <file>` reports `0 warnings`, or only warnings you expect.
- `borer packs <binary>` shows `yes` for a binary of the family, `no` for one
  that is not, and `0 failed` for its scripts.
- Every name rests on evidence a reader can check: a string the function
  logs, a slot in a table, a signature. Skip what is ambiguous; a pack that
  names wrongly is worse than one that names less.
- The README lists what the pack names and how.
- `[names] fn` lines hold the first bytes of the target's functions. Publish
  them only where you may.

### Trust a pack you install

A pack's scripts run in borer's [sandbox](/docs/plugins.md): no file, network, process
or clock, under budgets. They run by themselves whenever the pack loads, and
they only fill names borer did not have: unnamed functions, and those named by
vtable slot or by an algorithm's constants. Read a pack's `[scripts]` before
you install it, the way you would read any rule that names your functions.
