Single FastAPI container with a registry-driven single-page front end, so new tools are one module plus one registry entry. Runs as one container behind a reverse proxy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1.9 KiB
1.9 KiB
CLAUDE.md
See README.md for what this is and how it's deployed. This file is how to extend it.
Adding a tool
- Front end: create
app/static/js/tools/<id>.jsexportingmount(root, ctx):- append the UI to
root; start withel('div.tool', {}, toolbar, …)so it fills the view (.toolbar,.btn,.segmented,.pane,.statusbarare the shared building blocks incss/style.css); ctx.restis the path after the tool's own (/paste/abc→abc),ctx.querythe search params,ctx.navigate(path)client-side navigation,ctx.setTitle(text)the top-bar suffix;- return a cleanup function if you add global listeners or timers.
- append the UI to
- Register it in
app/static/js/registry.js(id, name, path, category, icon, description,load). The sidebar, home grid,/-search and router all come from that list. Add a new category toCATEGORY_ORDERif it should not sort last. - Server side, only if needed: add
app/tools/<id>.pyexposingrouter(a FastAPIAPIRouter) with routes under/api/<id>/…, and optionalasync startup()/shutdown().main.pymounts every module intools/automatically. Persistent files go under$DATA_DIR(/data, bind-mounted from/opt/tools/data). Keep it light: this runs on the shared server (container capped at 192 MB / 0.5 CPU). - Prefer running in the browser. Vendor any library into
static/vendor/(pinned version in the filename comment or README); the CSP allows scripts from'self'only, no CDNs.
Conventions
- Persist per-browser state with
storefromui.js(namespaced, never throws), and flush debounced saves on leave (onLeave,debounce(...).flush). - Never render user content as HTML without DOMPurify (the Markdown preview) or
textContent. - Run
node --test tests/and check the page in a browser before deploying;deploy.shrefuses to deploy if the tests fail.