# pi-nyaa

Project-local pi extension for querying public metadata from:

- <https://nyaa.si/>
- <https://sukebei.nyaa.si/>

The extension registers two tools:

- `nyaa_search` — searches RSS metadata and returns titles, categories, size, dates, swarm counts, comments, and view-page URLs.
- `nyaa_view` — fetches one `/view/<id>` page and returns public metadata, description, and file list.

The tools intentionally do **not** return torrent download links or magnet links.

## Install / load

### Install from npm

This extension is published as an npm pi package:

```bash
pi install npm:pi-nyaa
```

This installs `pi-nyaa` into your global pi settings, so `nyaa_search` and `nyaa_view` are available in all pi sessions.

To install it only for the current project, write it to the project-local `.pi/settings.json` instead:

```bash
pi install -l npm:pi-nyaa
```

After installing, restart pi. If pi is already running, use:

```text
/reload
```

You can also load the npm package for a single run without installing it:

```bash
pi -e npm:pi-nyaa
```

### Load from this repository

This repository also places the extension in pi's conventional package path:

```text
extensions/nyaa.ts
```

Start `pi` from this repository, then run `/reload` if pi was already open.

For a one-off run from another directory:

```bash
pi -e /home/narumi/workspace/pi-nyaa/extensions/nyaa.ts
```

## Examples

Ask pi:

```text
用 nyaa_search 在 nyaa 查詢 "frieren"，依 seeders 排序，列出前 5 筆。
```

```text
用 nyaa_view 查 nyaa id 2097677，不要 description，只列 category、size 和 files。
```

```text
用 nyaa_search 在 sukebei 查詢 "test"，limit 3。
```

## Notes

- `site` is required and must be `nyaa` or `sukebei`.
- `sukebei` is the adult index; request it explicitly.
- `category` accepts raw Nyaa category IDs such as `0_0` or `1_2`.
- Search output is capped at 50 items and tool output is truncated to pi's default limits.
