/* * plugin_notes - SCORPIOX BOT open-source markdown notes for your node * * A single clean-room C99 binary that serves THREE modes: * 1. --meta / SX_PLUGIN_META=1 -> JSON discovery metadata * 2. ?action=... / ?format=json / POST -> JSON node API * 3. GET (default) -> two-pane markdown editor * * Storage: one file per note, `.md`, plus `index.json` holding the * metadata and the ordering. Both live inside `/.notes/` * (Linux/macOS) or `%LOCALAPPDATA%\scorpiox\plugins\.notes\` (Windows), and * `$NOTES_DIR` overrides the location for tests and for people who want their * notes somewhere else. Every write goes to `.tmp` and is then renamed * over the real file, so a kill -9 mid-write leaves the previous content * intact rather than a truncated note. * * Note ids are generated by this binary (`[a-z0-9]{12}`), never taken from the * client as a path, and any id that arrives in a request is validated against * that shape before it can touch the filesystem. Markdown is rendered * server-side with raw HTML escaped first, so a note containing `