scorpiox-bot-plugin-notes

scorpiox-bot-plugin-notes

main1 branch · 0 tags
VS Code
HTTPS
ForkDelete
Recent Commits
README

SCORPIOX BOT — notes

Zero-dependency markdown notes that live on your own node.

A note is one <id>.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:

# 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 <pwd>, 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=<id> {"ok":true,"note":{...,"body":"..."}}
save POST ?action=save with {"id?","title","body","pinned?"} {"ok":true,"note":{...}}
delete POST ?action=delete&id=<id> {"ok":true,"deleted":"<id>","trash":true}
search GET ?action=search&q=<text> same shape as list, title and body matched, case-insensitive
pin POST ?action=pin&id=<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:

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=<id>&$P"

Storage

Platform Location
Linux / macOS <plugin dir>/.notes/ — or $NOTES_DIR
Windows %LOCALAPPDATA%\scorpiox\plugins\.notes\
.notes/
├── index.json        # {"version":1,"notes":[{id,title,pinned,created,updated}]}
├── <id>.md           # the markdown body of one note
└── .trash/<id>.md    # deleted notes, kept so a wrong click is recoverable

Every write is fwrite to <path>.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 <script>, <img onerror=...> or a javascript: link

renders as inert text; only https:, http:, mailto: and same-page links

become real anchors. tests/run.sh asserts this for each payload.

  • CSP — the page ships

default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'self'

so even a future regression cannot fetch a remote script.

UI

Two panes: the note list with search on the left, editor above a live rendered

preview on the right. Under 700 px the layout collapses to a single pane with a

back button and a preview toggle, so the same page is usable at 390 px and inside

the Chat floating window.

  • autosave with an 800 ms debounce and a visible saved / unsaved / saving

pill (Ctrl/Cmd+S forces an immediate save)

  • Ctrl/Cmd+K focuses search, Alt+Ctrl/Cmd+N starts a new note, Tab in the

editor inserts two spaces

  • pin and delete per note, delete moves to .trash
  • dark and light from the SCORPIOX BOT theme tokens, following ?theme=,

localStorage.bot_theme, prefers-color-scheme and the sx-theme postMessage

handoff; the plugin's own toggle hides under ?embed=1

  • no <script src=>, no CDN, no framework, zero emoji — inline SVG only

1440 dark

390 dark

API routes the page uses

The single most common plugin bug is calling the wrong route. This page branches

exactly once, using preferred-bot-plugin's template:

  • served through the hub (/plugins?plugin=plugin_notes&node=...) → call the hub

proxy back: /plugins?plugin=plugin_notes&action=...

  • opened directly on the node (/plugin_notes) → the plugin is the route:

/plugin_notes?action=...

Calling /plugins?plugin= on the node itself returns the discovery list, not the

plugin.

Test

make test        # 150+ offline assertions, 0 fail, no network, no Playwright
make e2e         # Playwright: 6 viewports × theme, console/overflow/autosave

The offline suite proves the contract (meta, auth, every action's JSON shape, CRUD

round trip, atomic write, the size cap, id validation, XSS inertness, trash,

pinning order, search, the generated UI's CSP and route branching), builds the

same source with -D_FORTIFY_SOURCE=2 and runs it, checks the MinGW MZ header

when the PE is present, and audits the whole git history for secrets and internal

addresses.

License

MIT © 2026 SCORPIOX INC. See LICENSE.