You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(plugins): update docs for QuickJS bootstrap refactor
- Fix stale server/plugins/quickjsHost.ts path → server/plugins/quickjs/vm.ts
across plugin-system.md, README.md, architecture.md, server.md
- Add bootstrap source paths to plugin-system.md Related section
(bootstrap/src/, bootstrap/generated/, scripts/sync-plugin-bootstrap.ts)
- Add new gate and test files to plugin-system.md Related section:
plugin-bootstrap-fresh.test.ts, pluginVmPermissions.test.ts,
pluginVmLoopDispatch.test.ts
- Add plugin-bootstrap-fresh.test.ts to reference/architecture-tests.md
Plugin system table
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/features/plugin-system.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ A plugin is a zip package containing a `plugin.json` manifest and one or more Ja
9
9
## TL;DR
10
10
11
11
-**Package shape:** a zip containing `plugin.json` plus entrypoint bundles (`server/index.js`, `editor/index.js`, `admin/dashboard.js`, `modules/index.js`, `frontend/*.js`, optional `pack/site.json`).
12
-
-**Runtime:** server entrypoint runs in **QuickJS-WASM** (`server/plugins/quickjsHost.ts`). Canvas module packs run in a separate QuickJS VM (`server/plugins/modulePackVm.ts`). No host APIs leak.
12
+
-**Runtime:** server entrypoint runs in **QuickJS-WASM** (`server/plugins/quickjs/vm.ts`). Canvas module packs run in a separate QuickJS VM (`server/plugins/modulePackVm.ts`). No host APIs leak.
13
13
-**SDK:** every API call goes through `api` — `api.plugin.*` for plugin metadata + logging, `api.cms.*` for routes, storage, hooks, loops, settings, schedule, pages.
14
14
-**Lifecycle:**`install` → `activate` → (optionally `deactivate` / `migrate`) → `uninstall`. Each hook is async-capable and isolated; if one throws, the host rolls back and parks the plugin in `error`.
15
15
-**Permissions:** declared in `plugin.json`, approved by the site owner at install time, enforced by the SDK at runtime. Outbound network also requires `networkAllowedHosts` allowlist.
-`src/__tests__/architecture/plugin-bootstrap-fresh.test.ts` — generated bootstrap artifacts match source; fails if `bun run bootstrap:sync` is needed
699
703
-`src/__tests__/plugins/gatedFetchSsrf.test.ts` — SSRF guards: allowlist, DNS rebinding, redirect re-validation, redirect cap
700
704
-`src/__tests__/plugins/pluginModulePack.test.ts` — module pack activation, re-activation, deactivation, and VM disposal
705
+
-`src/__tests__/server/pluginVmPermissions.test.ts` — VM-side permission check: declared-but-not-granted permissions are denied at the VM boundary before host dispatch
|`plugin-bootstrap-fresh.test.ts`| Generated bootstrap artifacts in `bootstrap/generated/` match a fresh bundle of `bootstrap/src/`. Fails if `bun run bootstrap:sync` is needed. |
132
133
|`plugin-sandbox-invariants.test.ts`| No `node:`, `bun:`, `require(`, `process.binding` in plugin bundles. Sandbox-safe assertions.|
133
134
|`plugin-boot-resilience.test.ts`| One bad plugin doesn't bring the server down. Crashes are isolated. |
134
135
|`plugin-cms-content-surface.test.ts`| All five `cms.content.*` permissions are wired across all sync-points (permission values, capability matrix, permission alias builder, SDK type surface, host-side dispatch). |
Copy file name to clipboardExpand all lines: docs/server.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ The server is a single `Bun.serve` process that boots the DB, runs migrations, a
14
14
-**Auth:** session cookie (`SESSION_COOKIE_NAME`) → `findUserBySessionHash` → `requireCapability(req, db, 'site.read')`. Every state-changing handler starts with one of these guards.
15
15
-**DB:** one `DbClient` interface (`server/db/client.ts`) — tagged-template callable returning `{ rows, rowCount }`. Two adapters: `postgres.ts` (via `Bun.sql`) and `sqlite.ts` (via `bun:sqlite`). Selected by `DATABASE_URL`.
16
16
-**Repositories** (`server/repositories/`) hold all SQL. Handlers never write SQL directly.
17
-
-**Plugins:**`server/plugins/runtime.ts` activates installed plugins at boot; per-plugin code runs in QuickJS-WASM sandboxes (`server/plugins/quickjsHost.ts`, `modulePackVm.ts`).
17
+
-**Plugins:**`server/plugins/runtime.ts` activates installed plugins at boot; per-plugin code runs in QuickJS-WASM sandboxes (`server/plugins/quickjs/vm.ts`, `modulePackVm.ts`).
18
18
-**Published pages and content rows** are served by `tryServePublicRoute`, which delegates resolution + render to `server/publish/publicRouter.ts` (live render from the JSON snapshot stored in `data_row_versions.snapshot_json`). Uploads + admin SPA assets are served from disk by `tryServeUpload` and `tryServeStaticAsset`.
19
19
20
20
---
@@ -453,7 +453,7 @@ Plugins ship as zip packages with a `plugin.json` manifest. The host:
453
453
454
454
1.**Installs** the package (unzips into `uploads/plugins/<id>/<version>/`) — `server/plugins/package.ts`.
455
455
2.**Validates** the manifest and scans the bundled JS for forbidden sandbox-incompatible patterns — `assertSandboxSafe` in `package.ts` + `parsePluginManifest` in `src/core/plugins/manifest.ts`.
456
-
3.**Activates** the plugin at boot or on user action — `server/plugins/runtime.ts`. Activation loads the server entrypoint into a per-plugin QuickJS-WASM VM (`server/plugins/quickjsHost.ts`) and runs its `activate(api)` lifecycle hook.
456
+
3.**Activates** the plugin at boot or on user action — `server/plugins/runtime.ts`. Activation loads the server entrypoint into a per-plugin QuickJS-WASM VM (`server/plugins/quickjs/vm.ts`) and runs its `activate(api)` lifecycle hook.
457
457
4.**Routes** plugin-registered HTTP routes through `/admin/api/cms/plugins/<id>/runtime/…` (handled by `handleRuntimeRoutes`).
458
458
5.**Brokers** the SDK boundary — `api.cms.routes.*`, `api.cms.storage.*`, `api.cms.hooks.*`, `api.cms.loops.*`, `api.cms.settings.*`, `api.cms.schedule.*`. The SDK shape is defined in `src/core/plugin-sdk/`.
0 commit comments