PermDock
Concepts

Presets

A preset is an archetype plus the features, auth, backend, framework, agent runtimes, UI and PermDock Cloud services an app needs, encoded as a short versioned code; permdock/preset generates the application's own files from it, the same in permdock init, the @permdock registry and the /create page.

A preset describes a starting point: a SaaS archetype and the features and stack it runs on. /create builds one in the browser, permdock init writes it into a project, and the code that names it can be shared, opened and changed again.

PartChoices
Archetypeb2b, agent, marketplace, api, internal, consumer
Featurestenancy, custom-roles, approvals, agents, audit, limits, plans, ownership, api-keys, rls
Authcustom, supabase, better-auth, clerk, jwt
Backendmemory, supabase, drizzle, prisma
Frameworknext, hono, express, none
Agentsai-sdk, mcp
UIshadcn, react-native
Servicescloud-decision-log, cloud-approvals, cloud-snapshots, cloud-hosted-grants

An archetype turns on the features it needs (b2b adds tenancy, custom-roles and audit); an agent runtime adds agents; custom-roles adds tenancy. Features are only ever added.

Codes

A code is p1 and base64url bytes: the archetype, auth, backend and framework, then a bitset per multi-select list. Each list only grows at the end, so a code keeps its meaning as choices are added; a new layout gets a new prefix, and a version that cannot read it says so.

Generating

permdock/preset is pure: no file system, no network, the same in Node and the browser.

import { encodePreset, generatePreset, resolvePreset } from "permdock/preset";

const preset = resolvePreset({ archetype: "b2b", framework: "hono" });
const { code, files, dependencies, recipes, docs } = generatePreset(preset);
FileWhat
src/permissions.tsThe archetype's resources with crud() or readable() and Zod schemas
src/policy.tsRoles and grants as data: on, min and assigns with tenancy; where on the owner field with ownership; approval: "human" on destructive actions with approvals; limit with limits; a plan("pro") grant with plans
src/permdock.tsdefineApp with the features and services the preset picked and profile from NODE_ENV (apps and profiles)
src/data.ts, src/session.tsRow loaders and the signed-in user, to replace with your database and auth; the session returns null until wired, so every check fails closed
Framework filesrc/permdock/server.ts (Next.js) or src/server.ts (Hono, Express, core)
src/operations.ts, src/agent.ts, src/mcp.tsWith agent runtimes
src/keys.tsWith api-keys: a decideCredential call
permdock.config.tsWith rls

Every generated file is the application's own code. The rules (role ceilings, holder counts, approval binding, limits, verification) are in the permdock package that these files call, so updating the package updates them.

Why

A preset generates declarations and wiring, never rules. A starter that copied authorization logic into the application could not receive a security fix; one that generates definePolicy data and defineApp wiring can, because npm update replaces everything the generated code calls. The code format is versioned and append-only for the same reason as the wire formats: a link shared today opens the same preset after the catalogue grows.

Last updated on

On this page