# SCORPIOX BOT — notes Zero-dependency markdown notes that live on your **own node**. A note is one `.md` file plus a row in `index.json`, both inside the plugin directory. Nothing leaves the machine: no account, no sync service, no CDN, no network call of any kind. Create, edit, rename, search, pin and delete notes with a live rendered preview beside the editor. ``` make # native build -> ./plugin_notes make musl # static musl x86_64 -> ./plugin_notes.musl make arm64 # static aarch64 -> ./plugin_notes.arm64 make win64 # MinGW-w64 static PE -> ./plugin_notes.exe make macos # Apple clang (on macOS) -> ./plugin_notes make ui # regenerate src/ui_html.h from src/ui.html make test # offline suite (100+ assertions) make e2e # Playwright viewport suite (1440 / 1024 / 390, dark + light) ``` ## Install Drop the binary where the node looks for plugins, then open **Settings → Plugins**, or use the market installer: ```sh # node plugin directory (created by scorpiox-bot on startup) cp plugin_notes ~/.scorpiox/plugins/plugin_notes chmod +x ~/.scorpiox/plugins/plugin_notes # or from the market curl -s -H "X-Bot-Password: $BOT_PASSWORD" \ "http://127.0.0.1:8150/plugin_manage?action=install&slug=notes&mode=prebuilt" ``` Windows: `%LOCALAPPDATA%\scorpiox\plugins\plugin_notes.exe`. BotCloud container: `/workspace/.scorpiox/plugins/plugin_notes`. ## Three modes, one binary | Mode | Trigger | Response | |---|---|---| | Discovery | `--meta` or `SX_PLUGIN_META=1` | `{"name":"notes","desc":"Markdown notes"}` (unauthenticated) | | API | `?action=...`, `?format=json`, or any `POST` | `application/json; charset=utf-8` | | UI | plain `GET` (`?embed=1` aware) | the two-pane editor, `text/html` | Every API call is behind `require_node_auth()`: `X-Bot-Password`, `Authorization: Bearer `, or `?pwd=`. With `BOT_PASSWORD` unset the check is a no-op, which is the intended behaviour on a single-user box. ## Actions | Action | Call | Returns | |---|---|---| | `list` | `GET ?action=list` | `{"ok":true,"count":N,"notes":[{id,title,pinned,created,updated}]}` | | `get` | `GET ?action=get&id=` | `{"ok":true,"note":{...,"body":"..."}}` | | `save` | `POST ?action=save` with `{"id?","title","body","pinned?"}` | `{"ok":true,"note":{...}}` | | `delete` | `POST ?action=delete&id=` | `{"ok":true,"deleted":"","trash":true}` | | `search` | `GET ?action=search&q=` | same shape as `list`, title **and** body matched, case-insensitive | | `pin` | `POST ?action=pin&id=` with `{"pin":0\|1}` | `{"ok":true,"id":"...","pinned":1}` | | `render` | `POST ?action=render` with `{"body":"..."}` | `{"ok":true,"html":"..."}` | `save` without an `id` creates a note and generates a `[a-z0-9]{12}` id server-side; with an id it updates in place and keeps `created`. Examples: ```sh P="pwd=$BOT_PASSWORD" curl -s "http://127.0.0.1:8150/plugin_notes?action=list&$P" curl -s -X POST -H "Content-Type: application/json" \ "http://127.0.0.1:8150/plugin_notes?action=save&$P" \ -d '{"title":"Release checklist","body":"# Release checklist\n\n- build\n- verify"}' curl -s "http://127.0.0.1:8150/plugin_notes?action=search&q=verify&$P" curl -s -X POST "http://127.0.0.1:8150/plugin_notes?action=delete&id=&$P" ``` ## Storage | Platform | Location | |---|---| | Linux / macOS | `/.notes/` — or `$NOTES_DIR` | | Windows | `%LOCALAPPDATA%\scorpiox\plugins\.notes\` | ``` .notes/ ├── index.json # {"version":1,"notes":[{id,title,pinned,created,updated}]} ├── .md # the markdown body of one note └── .trash/.md # deleted notes, kept so a wrong click is recoverable ``` Every write is `fwrite` to `.tmp`, `fflush` + `fsync`, then `rename` (POSIX) or `MoveFileExA(..., MOVEFILE_REPLACE_EXISTING)` (Windows). A process killed mid-write leaves the previous note intact rather than a half file. The body is written before the index, so an index row never points at a note that was never written. ## Security model * **Authentication** — every action requires the node password (three accepted forms above); `--meta` alone stays open so discovery still works. * **Path safety** — ids are generated by the binary (`[a-z0-9]{12}`) and any id arriving in a request is validated against that shape before it can be turned into a path. `?id=../../etc/passwd`, `%2f`, uppercase and length overruns are all rejected with `400`. * **Write scope** — nothing is written outside the notes directory; the trash subdirectory is inside it. * **Size cap** — a note body is capped at 512 KiB; over that the request is refused with `413` naming the limit. The CGI body read is guarded on `CONTENT_LENGTH` so an inherited empty stdin never blocks the process. * **XSS** — markdown is rendered **server-side**, and every literal byte of note content is HTML-escaped before any tag is emitted (`&`, `<`, `>`, `"`, `'`) so a note containing `