diff --git a/.gitignore b/.gitignore index 7db6bc67..e38d30a0 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,11 @@ dist/ .spacefast/ node_modules/ -content/cli/reference.md +content/(reference)/cli/reference.md content/(reference)/errors/ content/(reference)/changelog/ content/setup/ +content/connect/ public/_redirects .env .env.* diff --git a/.vale.ini b/.vale.ini index fa97736f..c7a1dbf7 100644 --- a/.vale.ini +++ b/.vale.ini @@ -31,17 +31,27 @@ Spacefast.Wordiness = NO Spacefast.Condescension = NO Spacefast.ApiKey = NO Spacefast.Hosting = NO +Spacefast.WpCloud = NO +Spacefast.Internals = NO -; Generated error pages are a verified snapshot synced from the monorepo, and -; the OpenAPI prose extraction reads generated/openapi. Both stay exempt from -; the "hosting" rule until the snapshot is refreshed with the monorepo fixes; -; then remove these carve-outs. +; Generated error pages and OpenAPI prose are synced snapshots from the product +; source. Keep narrow carve-outs here until the upstream snapshot removes those +; strings, then drop them. [content/(reference)/errors/**] BasedOnStyles = Vale, Spacefast Vale.Spelling = NO Spacefast.Hosting = NO +Spacefast.ApiKey = NO +Spacefast.Internals = NO [*openapi-prose.md] BasedOnStyles = Vale, Spacefast Vale.Spelling = NO Spacefast.Hosting = NO + +; Generated /connect pages put backticked `npx -y spacefast ...` commands inside +; YAML frontmatter descriptions, where Vale ignores Markdown code spans. +[content/connect/**] +BasedOnStyles = Vale, Spacefast +Vale.Spelling = NO +Spacefast.ProductName = NO diff --git a/AGENTS.md b/AGENTS.md index 7f3cfb6b..1cc8c787 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -49,7 +49,7 @@ Assume every commit and every line of history will be public. producer-owned snapshot. The exporter owns every file there, including the manifest and ownership marker. Do not hand-edit them. - `.blume/**` and `dist/**` are generated by Blume. Never edit or commit them. -- `content/cli/reference.md`, `content/(reference)/errors/**`, +- `content/(reference)/cli/reference.md`, `content/(reference)/errors/**`, `content/(reference)/changelog/**`, `content/setup/**`, and `public/_redirects` are ignored build overlays materialized from the verified snapshot. Do not hand-edit them. diff --git a/blume.config.ts b/blume.config.ts index 60a40685..2e02f2b2 100644 --- a/blume.config.ts +++ b/blume.config.ts @@ -67,7 +67,7 @@ export default defineConfig({ // Plan values from scripts/pricing-next.mjs, the source Pricing & Limits renders. ...planVariables(), }, - description: "Publish what your agents build.", + description: "Build better and ship with Spacefast — skills, tools, database, Workers, domains, and infrastructure in one Space.", // Two links (components/Logo.astro): the mark goes to the Website home at the // origin root, outside the /docs base; "Docs" goes to the Docs home. logo: { href: "/", image: { light: "/spacefast-wordmark.svg", alt: "Spacefast" }, text: "Docs" }, @@ -127,12 +127,16 @@ export default defineConfig({ ], repo: true, sidebar: { display: "group" }, + // Five tabs. Guides, Agents, and Platforms are real folders, so Blume + // scopes them by path. The Reference tab spans /cli, /api, and the other + // reference pages; components/Sidebar.astro and components/Header.astro + // resolve it from the (reference) folder group instead of a path prefix. tabs: [ { label: "Docs", path: "/", icon: icons.book }, - { label: "CLI", path: "/cli", icon: icons.terminal }, - { label: "API", path: "/api", icon: icons.braces }, + { label: "Guides", path: "/guides", icon: icons.rocket }, { label: "Agents", path: "/agents", icon: icons.robot }, - { label: "Spacefast for Platforms", path: "/platforms", icon: icons.handshake }, + { label: "Reference", path: "/reference", href: "/cli", icon: icons.braces }, + { label: "Platforms", path: "/platforms", icon: icons.handshake }, ], }, reference: [ @@ -166,7 +170,7 @@ export default defineConfig({ enabled: true, endpoint: "https://api.spacefast.com/v1/docs/ask", suggestions: [ - { label: "How do I publish a site?" }, + { label: "How do I publish a Space?" }, { label: "How should an agent use Spacefast?" }, { label: "How do I roll back a version?" }, ], @@ -178,6 +182,8 @@ export default defineConfig({ // and MCP: without this the component ships as raw JSX. markdownComponents: { PricingTable: ({ props }) => pricingTableMarkdown(String(props.table), props.row ? String(props.row) : undefined), + SpacefastStage: () => + `\`\`\`ts\nimport { defineConfig } from "spacefast/config";\n\nexport default defineConfig({\n name: "quiet-harbor",\n app: {\n collections: { posts: { title: "Posts" } },\n actions: { subscribe: { access: "anyone" } },\n },\n crons: [{ path: "/api/digest", schedule: "daily" }],\n});\n\`\`\``, WpCloudDocs: ({ props }) => `Using the [Partner API](${deploymentBase}/platforms/partner-api)? See [${String(props.title)}](${String(props.href)}) in the upstream infrastructure reference.`, }, diff --git a/components.ts b/components.ts index 3eca02e6..fa55700d 100644 --- a/components.ts +++ b/components.ts @@ -1,13 +1,15 @@ import { defineComponents } from "blume"; import Breadcrumbs from "./components/Breadcrumbs.astro"; +import Header from "./components/Header.astro"; import Logo from "./components/Logo.astro"; import Pagination from "./components/Pagination.astro"; import Sidebar from "./components/Sidebar.astro"; import PricingTable from "./components/PricingTable.astro"; +import SpacefastStage from "./components/SpacefastStage.astro"; import WpCloudDocs from "./components/WpCloudDocs.astro"; export default defineComponents({ - layout: { Breadcrumbs, Logo, Pagination, Sidebar }, - mdx: { PricingTable, WpCloudDocs }, + layout: { Breadcrumbs, Header, Logo, Pagination, Sidebar }, + mdx: { PricingTable, SpacefastStage, WpCloudDocs }, }); diff --git a/components/Header.astro b/components/Header.astro new file mode 100644 index 00000000..0ebdb504 --- /dev/null +++ b/components/Header.astro @@ -0,0 +1,20 @@ +--- +/* + * Blume's header, with the active tab picked by components/sections.ts. Blume + * marks the tab whose path is the longest prefix of the route, which would + * mark Docs on /cli or /setup/codex. The header uses `route` only to pick + * that tab (this site has no selectors or tab menus), so passing the owning + * tab's path is all the change needs. + */ +import Header from "blume/components/layout/Header.astro"; +import data from "blume:data"; + +import { tabForRoute } from "./sections.ts"; + +const props = Astro.props as Record & { route: string }; +const { sidebar, tabs } = data.navigation; +const tab = tabForRoute(tabs, sidebar, props.route); +const route = tab && tab.path !== "/" ? tab.path : props.route; +--- + +
diff --git a/components/Logo.astro b/components/Logo.astro index 46942b2d..6c8300f7 100644 --- a/components/Logo.astro +++ b/components/Logo.astro @@ -1,13 +1,22 @@ --- -// The brand lockup: the Spacefast mark links to the Website home, "Docs" links -// to the Docs home. Docs are always served inside the Website artifact at -// /docs, so the configured root-relative `logo.href` ("/") is emitted as is, -// without the deployment base, and reaches the Website home on whatever origin -// serves the page. The Website is not part of the Docs' client router, so the -// mark's link does a plain page load instead of a router fetch first. +// The brand's section lockup, drawn the way Drop and Push draw it +// ("spacefast | Drop"): the wordmark at 20px, a 28px rule in ink at 55% with +// 14px either side, and the section name in ink at text-lg, raised 1px so the +// lighter name sits level with the heavy wordmark. On a phone the lockup gives +// way to the star alone at 28px. +// +// Two links: the logo goes to the Website home, "Docs" to the Docs home. Docs +// are always served inside the Website artifact at /docs, so the configured +// root-relative `logo.href` ("/") is emitted as is, without the deployment +// base, and reaches the Website home on whatever origin serves the page. The +// Website is not part of the Docs' client router, so the logo's link does a +// plain page load instead of a router fetch first. import { withBase } from "blume/components/islands/base-path.ts"; import type { BlumeLogo } from "blume/core/data.ts"; +// The logo's star alone, for phones: the shared brand asset's path. +import star from "./spacefast-star.svg?raw"; + interface Props { site: { title: string }; logo?: BlumeLogo | null; @@ -16,26 +25,32 @@ interface Props { const { site, logo } = Astro.props; const label = logo?.text ?? site.title; -const link = "inline-flex items-center transition-opacity hover:opacity-80"; +// The logo and a linked title share one box: 36px tall and 6px either side, +// drawn back by matching negative margins so the lockup's spacing holds. +const box = "-mx-1.5 inline-flex h-9 shrink-0 items-center rounded-md px-1.5"; // The config inlines the wordmark so it follows the theme. Fail the build -// rather than ship a header whose mark silently disappeared. +// rather than ship a header whose logo silently disappeared. if (!logo?.svg) throw new Error("components/Logo.astro needs blume.config.ts `logo` to resolve to an inline SVG."); --- -
+
- { label && ( - - {label} - + <> +
diff --git a/components/Pagination.astro b/components/Pagination.astro index 672d70bc..0eaf86b5 100644 --- a/components/Pagination.astro +++ b/components/Pagination.astro @@ -1,22 +1,20 @@ --- -// Keep the /setup pages, which the Docs sidebar doesn't list, out of the Docs reading order. +// Previous/next follow the reading order of the page's own tab +// (components/sections.ts), so the Reference and Agents tabs page through +// their own sections instead of Blume's prefix-scoped tree. import Pagination from "blume/components/layout/Pagination.astro"; -import { flattenPages, getPagination, sidebarForRoute } from "blume/components/layout/nav-utils.ts"; +import { flattenPages, getPagination } from "blume/components/layout/nav-utils.ts"; import { stripBasePath } from "blume/core/base-path.ts"; import data from "blume:data"; -const { prev, next, strings } = Astro.props; +import { sectionSidebar } from "./sections.ts"; + +const { strings } = Astro.props; const base = import.meta.env.BASE_URL.replace(/\/$/u, ""); const route = stripBasePath(base, Astro.url.pathname.replace(/(.)\/$/u, "$1")); -const isSetup = (route: string) => route === "/setup" || route.startsWith("/setup/"); -let links = { prev, next }; -if (!isSetup(route) && [prev, next].some((link) => link && isSetup(link.route))) { - const { sidebar, tabs, root } = data.navigation; - const order = flattenPages(sidebarForRoute(sidebar, tabs, route, root)) - .filter((page) => !isSetup(page.route)); - links = getPagination(order, route); -} +const { sidebar, tabs, root } = data.navigation; +const { prev, next } = getPagination(flattenPages(sectionSidebar(sidebar, tabs, route, root)), route); --- - + diff --git a/components/Sidebar.astro b/components/Sidebar.astro index ac914292..17f10ad7 100644 --- a/components/Sidebar.astro +++ b/components/Sidebar.astro @@ -1,73 +1,22 @@ --- /* - * Blume's sidebar with two changes that link pages across folders, which - * folder meta can't express: - * - Docs: the Setup group lists plain links to the CLI and agent setup - * sections (which live under their own tabs) instead of the generated - * per-client setup pages. - * - Agents: the tab's own pages render as a flat "Agents" section, followed - * by an "Other agents" section linking the generated /setup/ pages - * that have no authored /agents page, split into coding and personal. The - * /setup/ pages keep this Agents sidebar instead of the Docs one. + * Blume's sidebar, scoped to this site's five tabs (components/sections.ts). + * Blume scopes by URL prefix, which cannot express the Reference tab (it spans + * /cli, /api, /config-file, and other root pages) or the Agents tab's generated + * /setup and /connect pages, so this recomputes the tab's tree from the full + * navigation. */ import NavTree from "blume/components/layout/NavTree.astro"; -import { sidebarForRoute } from "blume/components/layout/nav-utils.ts"; import type { NavNode } from "blume/core/types.ts"; import data from "blume:data"; -import setupSections from "../content/setup/_sidebar.json"; +import { sectionSidebar } from "./sections.ts"; type Props = Record & { items: NavNode[]; currentRoute: string }; -const { items, ...rest } = Astro.props as Props; -// Navigation routes are base-less; Blume adds the deployment base when it renders links. -const agentsRoute = "/agents"; -const setupRoute = "/setup"; -const under = (route: string, root: string) => route === root || route.startsWith(`${root}/`); - -const page = (label: string, route: string): NavNode => ({ kind: "page", label, route, pageId: "" }); - -// The generated /setup folder is the Docs "Setup" group; its header stops linking to -// the per-client index, and its rows point at the CLI and Agents tabs instead. -const withSetupLinks = (nodes: NavNode[]): NavNode[] => - nodes.map((node) => - node.kind === "group" && node.route === setupRoute - ? { ...node, route: undefined, children: [page("CLI", "/cli"), page("Agent setup", agentsRoute)] } - : node, - ); - -const withOtherAgents = (nodes: NavNode[]): NavNode[] => { - const hasAuthored = (slug: string) => - nodes.some((node) => node.kind === "page" && node.route === `${agentsRoute}/${slug}`); - const sections = setupSections.map(({ title, pages }) => ({ - kind: "group" as const, - label: title, - display: "group" as const, - collapsed: true, - children: pages - .filter(({ slug }) => !hasAuthored(slug)) - .map(({ slug, label }) => page(label, `${setupRoute}/${slug}`)), - })); - return [ - { - kind: "group", - label: "Agents", - display: "flat", - route: agentsRoute, - children: nodes.filter((node) => !(node.kind === "page" && node.route === agentsRoute)), - }, - { kind: "group", label: "Other agents", display: "flat", children: sections }, - ]; -}; - -const route = rest.currentRoute; -let sidebar = withSetupLinks(items); -if (under(route, agentsRoute)) sidebar = withOtherAgents(items); -else if (route.startsWith(`${setupRoute}/`)) { - // Outside the tab, Blume hands over the Docs tree; take the Agents tab's instead. - const { sidebar: tree, tabs, root } = data.navigation; - sidebar = withOtherAgents(sidebarForRoute(tree, tabs, agentsRoute, root)); -} +const { items: _scoped, ...rest } = Astro.props as Props; +const { sidebar, tabs, root } = data.navigation; +const items = sectionSidebar(sidebar, tabs, rest.currentRoute, root); --- - + diff --git a/components/SpacefastStage.astro b/components/SpacefastStage.astro new file mode 100644 index 00000000..5279d2bc --- /dev/null +++ b/components/SpacefastStage.astro @@ -0,0 +1,279 @@ +--- +/* + * Miniature Spacefast product stage for the Docs home page. + * Follows Stageshow framing (one hero window bled off the bottom/right edge + + * one live receipt satellite straddling the left margin, real strings only on + * the story, quiet neutral surface steps + single brand green #1efe57) and + * Unslop UI rules (no sparkles, no purple, no decorative eyebrows, no headings + * inside the stage, responsive compact layout on narrow screens). + */ +--- + + + + diff --git a/components/sections.ts b/components/sections.ts new file mode 100644 index 00000000..4c81364f --- /dev/null +++ b/components/sections.ts @@ -0,0 +1,115 @@ +/* + * Which header tab owns a route, and that tab's sidebar. + * + * Blume matches a tab by URL prefix. Guides (/guides), Agents (/agents), and + * Platforms (/platforms) are real folders, so prefix matching works for them. + * The Reference tab is different: it gathers /cli, /api, /config-file, + * /limits, /glossary, /errors, and /changelog, which share no prefix. It is + * the `(reference)` folder group instead, so membership comes from the + * navigation tree, and the generated /setup and /connect pages belong to the + * Agents tab even though they live at the root. + */ +import { sidebarForRoute } from "blume/components/layout/nav-utils.ts"; +import type { NavNode, NavTab } from "blume/core/types.ts"; + +// Navigation routes are base-less; Blume adds the deployment base when it renders links. +export const referenceTabPath = "/reference"; +export const agentsTabPath = "/agents"; +const referenceGroupLabel = "Reference"; +const agentRoots = ["/setup", "/connect"]; + +export const under = (route: string, root: string) => + root === "/" || route === root || route.startsWith(`${root}/`); + +const routesIn = (nodes: NavNode[]): string[] => + nodes.flatMap((node) => + node.kind === "page" ? [node.route] : [...(node.route ? [node.route] : []), ...routesIn(node.children)], + ); + +const referenceGroup = (sidebar: NavNode[]) => + sidebar.find( + (node): node is Extract => + node.kind === "group" && node.path === "/" && node.label === referenceGroupLabel, + ); + +/** The routes the Reference tab owns, generated references included. */ +export const referenceRoots = (sidebar: NavNode[]): string[] => [ + ...routesIn(referenceGroup(sidebar)?.children ?? []), + "/cli", + "/api", + "/errors", + "/changelog", +]; + +const isReference = (sidebar: NavNode[], route: string) => + referenceRoots(sidebar).some((root) => under(route, root)); + +const isAgents = (route: string) => [agentsTabPath, ...agentRoots].some((root) => under(route, root)); + +/** The tab a route belongs to, matching Blume's longest-prefix rule otherwise. */ +export const tabForRoute = (tabs: NavTab[], sidebar: NavNode[], route: string): NavTab | undefined => { + const byPath = (path: string) => tabs.find((tab) => tab.path === path); + if (isReference(sidebar, route)) return byPath(referenceTabPath); + if (isAgents(route)) return byPath(agentsTabPath); + return [...tabs] + .filter((tab) => under(route, tab.path)) + .toSorted((left, right) => right.path.length - left.path.length)[0]; +}; + +/** Whether a top-level node belongs to a tab other than Docs. */ +const outsideDocs = (node: NavNode, sidebar: NavNode[], tabs: NavTab[]) => { + if (node.kind === "group" && node.path === "/" && node.label === referenceGroupLabel) return true; + const route = node.kind === "page" ? node.route : (node.path ?? node.route); + if (!route || route === "/") return false; + return ( + isReference(sidebar, route) || + isAgents(route) || + tabs.some((tab) => tab.path !== "/" && under(route, tab.path)) + ); +}; + +/** Reference tab sidebar: fold top-level OpenAPI /api/reference into REST API and link /changelog. */ +const referenceSidebar = (sidebar: NavNode[]): NavNode[] => { + const apiReferenceNodes = sidebar + .filter((node): node is Extract => node.kind === "group" && node.path === "/api") + .flatMap((node) => node.children); + return (referenceGroup(sidebar)?.children ?? []).map((node) => { + if (node.kind === "group" && node.path === "/api" && apiReferenceNodes.length > 0) { + return { + ...node, + children: [ + ...node.children, + ...apiReferenceNodes.map((child) => + child.kind === "group" && child.path === "/api/reference" + ? { ...child, label: "API reference" } + : child, + ), + ], + }; + } + if (node.kind === "group" && node.path === "/changelog" && !node.route) { + return { ...node, route: "/changelog" }; + } + return node; + }); +}; + +/** The sidebar for a route's tab. */ +export const sectionSidebar = ( + sidebar: NavNode[], + tabs: NavTab[], + route: string, + root: string, +): NavNode[] => { + const tab = tabForRoute(tabs, sidebar, route); + if (tab?.path === referenceTabPath) return referenceSidebar(sidebar); + if (tab?.path === agentsTabPath) { + const agents = sidebarForRoute(sidebar, tabs, agentsTabPath, root); + const generated = sidebar.filter( + (node) => node.kind === "group" && agentRoots.some((root) => node.path === root || node.route === root), + ); + return [...agents, ...generated]; + } + if (tab && tab.path !== "/") return sidebarForRoute(sidebar, tabs, route, root); + return sidebar.filter((node) => !outsideDocs(node, sidebar, tabs)); +}; diff --git a/components/spacefast-star.svg b/components/spacefast-star.svg new file mode 100644 index 00000000..b705d06c --- /dev/null +++ b/components/spacefast-star.svg @@ -0,0 +1,3 @@ + + + diff --git a/content/(concepts)/design-system.mdx b/content/(account)/(labs)/design-system.mdx similarity index 50% rename from content/(concepts)/design-system.mdx rename to content/(account)/(labs)/design-system.mdx index c711eccf..f2cf3d0a 100644 --- a/content/(concepts)/design-system.mdx +++ b/content/(account)/(labs)/design-system.mdx @@ -3,15 +3,17 @@ title: Design System description: Save a team's design rules once, then reuse and check them across projects --- -Save your team's colors, type, layout, voice, and brand files in one Design System. A connected agent can reuse those standards in a new project, check a build against them, or bring a named Space up to date. You choose which Spaces change. Saving the system alone does not edit or publish a site. +Labs + +Save your team's colors, type, layout, voice, and brand files in one Design System. A connected agent can reuse those standards in a new project, check a build against them, or bring a named Space up to date. You choose which Spaces change. Saving the system alone does not edit or publish a Space. For agent imports and updates, use a Spacefast plugin with the [Design System task skills](/agents/skills#design-system-task-skills). ## Start a Design System -When Design System is enabled for your team, open the team and choose **Design System**. If you see **Set up team context**, select it first. Then choose how to start: +Design System is a [Labs](/labs) feature. Join **Design System** in **Team settings → Labs**, then open the team and choose **Design System**. If you see **Set up team context**, follow the [shared context setup](/labs#shared-team-context-setup) first. Then choose how to start: -- **Import what you already have.** Choose **Copy prompt** and give it to an agent connected to [Spacefast MCP](/agents). Give the agent your brand guide, Figma file, or repository too. With `import-design-system` installed, the agent saves supported values, registers source files, and keeps other guidance in supporting Memory records. Ask for a report of conflicts and anything it could not import. +- **Import what you already have.** Choose **Copy prompt** and give it to an agent connected to [Spacefast MCP](/agents). Give the agent your brand guide, Figma file, or repository too. With `import-design-system` installed, the agent saves supported values, registers source files, and keeps other guidance in supporting [Team Memories](/team-memories). Ask for a report of conflicts and anything it could not import. - **Start from a kit.** Choose **shadcn/ui**, **Tailwind CSS**, or **Spacefast default**. The kit saves editable colors, type, and layout values. Review them before applying them to a project. You can also add the standards yourself in the dashboard. **Look & feel** holds named colors, typography for headings and body text, and layout dimensions. **Voice** holds a tone description and writing rules with optional examples. @@ -20,7 +22,7 @@ You can also add the standards yourself in the dashboard. **Look & feel** holds Use **Brand files** to upload logos, images, fonts, and source documents. After uploading, edit **How to use** to tell your agent where and when a file belongs. A filename alone cannot do that job. -Each upload can be up to 100 MB. Files stay in the team's private Media Library. Accepted SVG files are sanitized on upload, so check the saved artwork. An agent must download needed files and put visitor-facing assets in the project's source; private file URLs do not belong in a live page. +Each upload must be no larger than 100 MB. Files stay in the team's private Media Library. Accepted SVG files are sanitized on upload, so check the saved artwork. An agent must download needed files and put visitor-facing assets in the project's source; private file URLs do not belong in a live page. ## Apply it to a project @@ -30,7 +32,7 @@ On a saved Design System, choose **Apply with your agent → Copy prompt**. Give - `verify-design-system` checks a matching source build or preview and fixes gaps when you ask for corrections. - `update-design` brings a named existing Space or linked project into line with the current standards. -The agent reads the saved Design System and applicable Memory, works from the complete project source, and checks the built result at desktop and mobile sizes. If a required file is unavailable or two rules conflict, it should report the specific gap. +The agent reads the saved Design System and applicable [Team Memories](/team-memories), works from the complete project source, and checks the built result at desktop and mobile sizes. If a required file is unavailable or two rules conflict, it should report the specific gap. Changes to team standards do not roll out to existing Spaces. Name each Space you want updated. Whether the agent publishes depends on your request and that Space's work mode. @@ -39,3 +41,19 @@ Changes to team standards do not roll out to existing Spaces. Name each Space yo Edit the saved values in **Look & feel**, **Voice**, or **Brand files**. The **Changelog** shows the current revision and changes made in this session. **Revert** can undo only the latest saved change; older changes cannot be selected for undo. If someone saves a newer revision while you are editing, reload the saved version and reconcile your draft before saving again. + +## Use the API + +All paths below start with `/v1/teams/{teamId}`. Use the current [OpenAPI specification](https://api.spacefast.com/openapi.json) for input fields and response schemas. + +| Method and path | Operation | Task | +| --- | --- | --- | +| `GET /design-system` | [`getTeamDesignSystem`](/api/reference/teams/getteamdesignsystem) | Read saved values, stable entry IDs, and the numeric write revision | +| `POST /design-system/assets/upload` | [`uploadTeamDesignSystemAsset`](/api/reference/teams/uploadteamdesignsystemasset) | Upload file bytes as `contentBase64`; receive an `attachmentId` | +| `GET /design-system/assets/{attachmentId}` | [`getTeamDesignSystemAsset`](/api/reference/teams/getteamdesignsystemasset) | Download a private asset | +| `POST /design-system/changes` | [`updateTeamDesignSystem`](/api/reference/teams/updateteamdesignsystem) | Save selected changes with `expectedRevision` and `operationId` | +| `POST /design-system/undo` | [`undoTeamDesignSystemChange`](/api/reference/teams/undoteamdesignsystemchange) | Undo the latest action with its `actionId`, `expectedRevision`, and `operationId` | + +An upload alone does not add an asset record or change the design revision. Reference the returned attachment ID in a changes request. Both the API and dashboard accept files up to 100 MB. + +Use the numeric revision from `GET /design-system` for writes, not the context fingerprint from `GET /agent-context`. A stale write revision returns `409`. Reuse the same `operationId` and identical input after an uncertain response. Saving standards does not change Space files. diff --git a/content/(account)/(labs)/labs.mdx b/content/(account)/(labs)/labs.mdx new file mode 100644 index 00000000..e82b73dc --- /dev/null +++ b/content/(account)/(labs)/labs.mdx @@ -0,0 +1,75 @@ +--- +title: Labs +description: Join early features for your team in Settings, check status, or turn them off +--- + +Labs + +Labs lets team owners and admins opt a team into early features before they open to everyone. Joining a feature turns it on for every member and connected agent on that team. + +## Available Labs features + +Three team-context features are available through Labs. They share one private storage home on your team, which you initialize the first time you open any of them: + + + + Save lasting facts, decisions, and preferences that every connected agent reads before it works. + + + Turn on preset practices such as SEO, accessibility, and spam protection for your team's agents. + + + Store colors, typography, layout, voice, and brand files so every Space matches your brand. + + + +| Feature | How to join | +| --- | --- | +| [Team Memories](/team-memories) | Join the waitlist | +| [Team Skills](/team-skills) | Apply with a short note | +| [Design System](/design-system) | Join the waitlist | + +## How joining works + +Open your team and go to **Team settings → Labs** to see available features, how to join each one, and your team's current status. + +| How to join | What happens | +| --- | --- | +| Turn on right away | Turns the feature on immediately for your team | +| Join the waitlist | Adds your team to the waitlist until Spacefast approves access | +| Apply with a short note | Submits a request with a required note (up to 1,000 characters) explaining what your team wants the feature for | + +Each feature shows your team's current status on the same page: + +- **On the waitlist** or **Applied**: waiting for Spacefast to review the request. +- **On**: approved and active for your team. +- **Paused**: temporarily paused by Spacefast or held by a plan requirement. +- **Not yet**: declined for now; you can submit a new request later. + +You can turn off an active feature, leave a waitlist, or withdraw an application from the same page at any time. + +### Who can join or leave + +Any team member can list Labs features and check enrollment status. Only team **owners and admins in a dashboard browser session** can join, leave, or withdraw a pending request. API keys, CLI logins, and agent grants cannot change Labs enrollment. + +## API operations + +All paths below start with `/v1/teams/{teamId}`. See the [API reference](/api/reference) for full schemas. + +| Method and path | Operation | What it does | +| --- | --- | --- | +| `GET /labs` | [`listTeamLabs`](/api/reference/teams/listteamlabs) | List every Labs feature and this team's enrollment status | +| `POST /labs/{featureKey}` | [`enrollTeamLabs`](/api/reference/teams/enrollteamlabs) | Join a feature or submit a request; send `{"note":"..."}` for features that require a note | +| `DELETE /labs/{featureKey}` | [`leaveTeamLabs`](/api/reference/teams/leaveteamlabs) | Leave an active feature or withdraw a pending request | + +Use these keys in the API: + +| Feature | API key | +| --- | --- | +| Team Memories | `agents.memories` | +| Team Skills | `agents.skills` | +| Design System | `agents.design_system` | + +## Shared team context setup + +Team Memories, Team Skills, and Design System store their records in one private context home per team. The first time you open **Memories**, **Skills**, or **Design System** in the dashboard, select **Set up team context** if prompted. Over the API, call [`ensureTeamContext`](/api/reference/teams/ensureteamcontext) (`POST /v1/teams/{teamId}/context`) with an empty request body and a credential that holds `spaces:write`. Repeated calls reuse the same storage home. diff --git a/content/(account)/(labs)/meta.ts b/content/(account)/(labs)/meta.ts new file mode 100644 index 00000000..b32892d6 --- /dev/null +++ b/content/(account)/(labs)/meta.ts @@ -0,0 +1,3 @@ +import { defineMeta } from "blume"; + +export default defineMeta({ title: "Labs", collapsed: true, pages: ["labs", "team-memories", "team-skills", "design-system"] }); diff --git a/content/(account)/(labs)/team-memories.mdx b/content/(account)/(labs)/team-memories.mdx new file mode 100644 index 00000000..ee5992cd --- /dev/null +++ b/content/(account)/(labs)/team-memories.mdx @@ -0,0 +1,62 @@ +--- +title: Team Memories +description: Save lasting team and Space facts that connected agents read before they work +--- + +Labs + +Team Memories stores durable facts, decisions, conventions, and preferences so every connected agent on your team reads them before creating or editing a Space. Memories is a [Labs](/labs) feature you join from team settings. + +## Set up team context + +Memories share private context storage with [Team Skills](/team-skills) and [Design System](/design-system). + + + + Join **Memories** in **Team settings → Labs**. See [Labs](/labs). + + + Open **Memories** in your team and select **Set up team context** if prompted. Owners, admins, and members with publishing access can run setup. + + + Add facts your agents should remember across sessions, scoped either to the whole team or to one Space. + + + +For API setup, call [`ensureTeamContext`](/api/reference/teams/ensureteamcontext) (`POST /v1/teams/{teamId}/context`) with a credential that has `spaces:write` and no request body. Repeated calls reuse the same private storage home without creating memories or changing skills. + +## How memories work + +Each memory (`mem_...`) is team-authored knowledge, not an instruction. Current user instructions always take precedence over saved memories. + +- **Scope**: Leave `spaceId` unset (`null`) for team-wide knowledge, or set `spaceId` to scope a memory to one Space. +- **Categories**: Every memory uses one category: `brand`, `voice`, `audience`, `design`, `decision`, `convention`, `preference`, or `fact`. +- **Pinning**: Pinned memories appear first in every agent-context read. Pin only the facts every task needs. +- **Limits**: Up to **200** active memories per team (archived memories do not count). Titles are 3 to 80 characters and unique per scope (case-insensitive). Bodies hold up to 1,000 characters. One agent-context read returns up to 16,000 characters of memory before setting `truncated: true`. + +Save one fact per memory. Never store credentials, payment details, private contact details, temporary task progress, or build output. List existing memories before creating duplicates, and read saved state before retrying after an uncertain write. + +## Read context before work + +Connected agents call [`getTeamAgentContext`](/api/reference/teams/getteamagentcontext) (`GET /v1/teams/{teamId}/agent-context`) before creating or editing a Space. Pass `spaceId` when working on an existing Space to include both team-wide memories and that Space's memories. + +Cache reads with the returned revision fingerprint: + +1. Save `memories.revision` from the response. +2. Pass it as `knownMemoriesRevision` on later reads. +3. When `memories.changed` is `false`, `memories.items` comes back empty and your cached copy still applies. + +A team that hasn't joined Memories gets empty memory context. Reading context never authorizes setup or a write. + +## Manage memories through the API + +All paths below start with `/v1/teams/{teamId}`. See the [OpenAPI specification](https://api.spacefast.com/openapi.json) for full request and response schemas. + +| Method and path | Operation | Task | +| --- | --- | --- | +| `GET /memories` | [`listTeamMemories`](/api/reference/teams/listteammemories) | List active memories (all on one page), or pass `status=archived` with `limit` and `cursor`; filter by `spaceId` | +| `POST /memories` | [`createTeamMemory`](/api/reference/teams/createteammemory) | Save one lasting fact, decision, or preference | +| `PATCH /memories/{memoryId}` | [`updateTeamMemory`](/api/reference/teams/updateteammemory) | Update `title`, `body`, `category`, `pinned`, or set `archived: true` / `false` | +| `DELETE /memories/{memoryId}` | [`deleteTeamMemory`](/api/reference/teams/deleteteammemory) | Permanently delete a memory (owners and admins with `teams:write`; refused for agent grants) | + +Memory reads require `spaces:read`. Creating, updating, and archiving memories require `spaces:write`. Agents archive stale memories (`archived: true`) instead of deleting them; permanent deletion requires `teams:write` and returns `authorization_level_not_allowed` for agent grants. diff --git a/content/(account)/(labs)/team-skills.mdx b/content/(account)/(labs)/team-skills.mdx new file mode 100644 index 00000000..f4556054 --- /dev/null +++ b/content/(account)/(labs)/team-skills.mdx @@ -0,0 +1,60 @@ +--- +title: Team Skills +description: Turn on preset practices like SEO, accessibility, and spam protection for every agent on your team +--- + +Labs + +Team Skills are preset, read-only practice briefs that team owners and admins turn on so every connected agent follows the same engineering and publishing standards. Team Skills is a [Labs](/labs) feature and is distinct from the Spacefast CLI and plugin skills documented in [Agent skills](/agents/skills). + +## Set up Team Skills + +Team Skills share private context storage with [Team Memories](/team-memories) and [Design System](/design-system). + + + + Apply for **Skills** in **Team settings → Labs** with a short note explaining how your team plans to use it. See [Labs](/labs). + + + Open **Skills** in your team and select **Set up team context** if prompted, or call [`ensureTeamContext`](/api/reference/teams/ensureteamcontext) (`POST /v1/teams/{teamId}/context`) with no request body. + + + Turn on the presets you want every agent on the team to follow. + + + +## Preset catalog + +Spacefast maintains each preset brief in four sections: **When this applies**, **Do**, **Don't**, and **Verify**. Teams toggle presets on or off without editing the brief text. + +| Key | Title | Default | Summary | +| --- | --- | --- | --- | +| `seo` | SEO | On | Titles, canonicals, sitemaps, and `301` redirects for search engines | +| `no-slop` | Anti-slop | On | Keeps copy and layout specific to your brand instead of generic templates | +| `front-end-craft` | Front-end craft | On | Semantic HTML, mobile responsiveness at `320px`, dark mode, and keyboard support | +| `social-previews` | Social previews | Off | Open Graph tags, share images, and `favicon.ico` icon sets on canonical URLs | +| `speed` | Speed | Off | Core Web Vitals budgets, image sizing, fonts, and caching | +| `accessibility` | Accessibility | Off | WCAG 2.2 AA contrast, focus management, landmarks, and screen-reader support | +| `spam-protection` | Spam protection | Off | Server-side spam checks and honeypots for forms (optional secret variable `AKISMET_API_KEY`) | +| `contact-forms` | Contact forms | Off | Accessible forms validated and delivered on the server | +| `security-headers` | Security headers | Off | Safe Content Security Policy (CSP), referrer, and permissions headers where Spacefast allows them | +| `privacy-consent` | Privacy & consent | Off | Cookie-free defaults, consent handling, and Global Privacy Control | + +Presets that require no extra setup (`seo`, `no-slop`, and `front-end-craft`) start enabled once Team Skills is active for your team. + +## Read enabled skills before work + +Connected agents read enabled skills through [`getTeamAgentContext`](/api/reference/teams/getteamagentcontext) (`GET /v1/teams/{teamId}/agent-context`). The response returns `skills` as Markdown briefs alongside `skillsRevision` and `skillsChanged`. + +Pass `skillsRevision` back as `knownSkillsRevision` on later reads. When `skillsChanged` is `false`, `skills` comes back empty and your cached briefs still apply. A team that hasn't joined Skills gets no team skills in agent context. + +## Manage skills through the API + +All paths below start with `/v1/teams/{teamId}`. See the [OpenAPI specification](https://api.spacefast.com/openapi.json) for full request and response schemas. + +| Method and path | Operation | Task | +| --- | --- | --- | +| `GET /skills` | [`listTeamSkills`](/api/reference/teams/listteamskills) | List every preset skill, its sections, setup status, and whether it is enabled | +| `PATCH /skills/{skillKey}` | [`updateTeamSkill`](/api/reference/teams/updateteamskill) | Send `{"enabled": true}` or `{"enabled": false}` to toggle a skill for the whole team | + +Reading skills requires `spaces:read`. Toggling a skill changes standing instructions for every agent on the team, so `PATCH /skills/{skillKey}` requires `teams:write` (team owners and admins) and returns `authorization_level_not_allowed` for agent grants. diff --git a/content/(account)/api-keys.mdx b/content/(account)/api-keys.mdx index 18998862..87832f9f 100644 --- a/content/(account)/api-keys.mdx +++ b/content/(account)/api-keys.mdx @@ -1,8 +1,6 @@ --- title: API keys and tokens description: Create, scope, use, and rotate Spacefast API keys, and tell them apart from the other credentials the platform hands you -sidebar: - order: 2 --- Team owners and admins can mint scoped API keys. To rotate without interrupting an integration, create a replacement, switch the integration to it, verify a request, and only then revoke the old key. @@ -107,6 +105,23 @@ A secret is immutable, so rotation means a new key. In the dashboard, **Replace Revoking is immediate. Anything using that key fails on its next request. The row stays in the list marked revoked, so the audit trail survives. +## Deploy tokens + +For a CI pipeline or script that only needs one Space, mint a Space-scoped **deploy token** (`sfm_`) instead of a team-wide `sfa_` API key. Deploy tokens are Share entries (`audience: "token"`) managed through [`sf deploy-tokens`](/cli/reference#sf-deploy-tokens) and `/v1/spaces/{spaceId}/share/entries`: + +```bash +# Preview-only deploy token (default) +sf deploy-tokens create --name ci-preview --show-secret + +# Preview + live deploy token with 90-day expiry +sf deploy-tokens create --name ci-release --live --expires 90d --show-secret + +# Read-only machine token limited to /docs/** +sf deploy-tokens create --name docs-feed --view-only --path '/docs/**' --show-secret +``` + +Pass the returned `sfm_` token in `SPACEFAST_TOKEN` or `Authorization: Bearer sfm_...`. Manage tokens without recreating them using [`sf deploy-tokens list`](/cli/reference#sf-deploy-tokens-list), [`sf deploy-tokens update`](/cli/reference#sf-deploy-tokens-update-id), [`sf deploy-tokens rotate`](/cli/reference#sf-deploy-tokens-rotate-id), and [`sf deploy-tokens revoke`](/cli/reference#sf-deploy-tokens-revoke-id). See [Publish from CI](/ci) for GitHub Actions and GitLab CI examples. + ## Every credential, by prefix Spacefast puts a prefix on each credential so you always know what you are holding. @@ -114,7 +129,7 @@ Spacefast puts a prefix on each credential so you always know what you are holdi | Prefix | What it is | Where you get it | |---|---|---| | `sfa_` | API key. The credential for the CLI, CI, and server-to-server calls | The team's **Agents** page, `sf api-keys create`, or `sf login` | -| `sfm_` | Space machine credential. Lets a script or service fetch a private Space's pages | `sf share token create`, shown once, rotatable | +| `sfm_` | Space machine or deploy token. Publishes one Space (preview-only or live) or reads a private Space's pages | [`sf deploy-tokens create`](/cli/reference#sf-deploy-tokens-create) or [`sf share token create`](/cli/reference#sf-share-token-create), shown once, rotatable | | `sfc_` | Space key. Proves you published an anonymous Space, keeps updating it, and claims it later | The publish receipt, and the fragment of the claim URL | | `sfl_` | Share link token. Rides in the `?__=` query of a share URL | `sf share link create`, or the dashboard access panel | | `sfp_` | Git push credential, embedded in the push remote URL | The dashboard, inside the `git remote add` line it gives you | @@ -125,6 +140,7 @@ Lifetimes differ by kind: | Credential | Lifetime | |---|---| | API key from the dashboard or `sf api-keys create` | The **Expires** date you set, otherwise no expiry | +| Deploy token from `sf deploy-tokens create` | The `--expires` duration or date you set, otherwise no expiry | | API key from `sf login` | 30 days, or 7 days without use | | Space key for an unclaimed Space | Matches that Space's unclaimed window. If you claim with **Claim & keep access**, it keeps working for another 7 days | | Continuation token | 30 minutes at most | diff --git a/content/(account)/authentication.mdx b/content/(account)/authentication.mdx index f7e69e5d..493701ca 100644 --- a/content/(account)/authentication.mdx +++ b/content/(account)/authentication.mdx @@ -1,8 +1,6 @@ --- title: Sign in and security description: Create a Spacefast account, add a password and two-factor, manage sessions, and log the sf CLI in from your terminal -sidebar: - order: 1 --- To create a Spacefast account, you need an email address and the six-digit code sent to it. A password is optional, and you can add one later. @@ -11,7 +9,7 @@ To create a Spacefast account, you need an email address and the six-digit code Type your email address on the sign-in page and press **Continue**. If the address has no account yet, Spacefast mails you a six-digit code. Enter the code to finish signing up. -There is no password signup. Passwords are something you add later, from settings, once you already have an account. +There is no password signup. Add a password later from **Account settings → Security**. Two other ways in create an account for you: @@ -32,7 +30,7 @@ The code is six digits and you get three tries. A fourth attempt stops working e Forgot the password you set? Sign in with a mailed code. Codes keep working whether or not a password exists. -A secondary address on your account signs you into that same account, and the code goes to the inbox you typed. +A secondary address on your account signs you in to that same account, and the code goes to the inbox you typed. ## Add a password @@ -86,11 +84,11 @@ Sessions are separate from agent access. To cut off an agent or a CLI, use **Acc ## Log the CLI in -`sf login` does not store a browser session. It walks a browser approval and ends up holding an API key scoped to what you approved. +[`sf login`](/cli/reference#sf-login) does not store a browser session. It runs a browser approval flow and stores an API key scoped to what you approved. - Run `sf login`. Add `--access read` if you want a credential that changes nothing. + Run [`sf login`](/cli/reference#sf-login). Add `--access read` if you want a credential that changes nothing. The CLI prints an eight-character code and a link, and opens your browser when it can. @@ -104,14 +102,14 @@ Sessions are separate from agent access. To cut off an agent or a CLI, use **Acc On a machine with no browser, open the link from your phone or laptop instead. Dashes and letter case in the code are ignored. - The page is titled **Authorize this device**. It shows the **Client**, the **Requested access**, the **Request origin** it was started from, and the line "This access expires after 30 days, or after 7 days unused." + The page says the client "is requesting access to your account". It shows the code to check against your terminal, the account you are signed in as (open the account menu and pick **Switch Account** if it is the wrong one), the **Client ID**, and the address the request was **Started from**. Under the requested access it says the access stays connected for 30 days, or until it goes 7 days unused. - Pick the team reach: **All teams** (including teams you join later), **Choose teams**, or **No team access** for sign-in only. Open **Customize what this device can do** to untick anything you would rather not hand over. You can narrow the request, never widen it. + Pick the team reach under **Team Access**: **All teams** (including teams you join later), **Choose teams**, or **No team access** for sign-in only. Open **Customize Access** to untick anything you would rather not hand over. You can narrow the request, never widen it. - Press **Approve**. + Press **Allow**, or **Deny** to refuse it. - The CLI picks the approval up within a few seconds and prints who you are and which teams the credential reaches. Run `sf whoami` any time to see it again. + The CLI picks the approval up within a few seconds and prints who you are and which teams the credential reaches. Run [`sf whoami`](/cli/reference#sf-whoami) any time to see it again. @@ -128,7 +126,7 @@ About that credential: Inside each team, the credential can't do more than your current role allows there. If your role changes, the new role applies from the credential's next request. -`sf logout` deletes the local login and revokes the key when the CLI minted it. To kill it from the browser instead, revoke the connection under **Account settings → Connected apps**. +[`sf logout`](/cli/reference#sf-logout) deletes the local login and revokes the key when the CLI minted it. To kill it from the browser instead, revoke the connection under **Account settings → Connected apps**. Requests made with an expired or revoked credential return `401` [`unauthorized`](/errors/unauthorized). ## Account settings @@ -145,4 +143,19 @@ Every `/account` page opens as a dialog over the dashboard. Your primary address gets account mail, drives the Gravatar avatar, and is the address sign-in codes go to. Two-factor codes, password resets, and other security mail are never turned off by the notification switches. -API keys are not on this branch. They live on the team page. See [API keys and tokens](/api-keys). +## API reference + +| Action | Endpoint | +|---|---| +| Read current account | [`GET /v1/me`](/api/reference/account/getme) | +| List sign-in methods | [`GET /v1/auth/methods`](/api/reference/account/listauthmethods) | +| Set or change password | [`POST /v1/auth/password`](/api/reference/account/setaccountpassword) | +| List account emails | [`GET /v1/auth/emails`](/api/reference/account/listaccountemails) | +| Start device login | [`POST /v1/auth/device`](/api/reference/account/startdeviceauthorization) | +| Poll device login | [`POST /v1/auth/device/poll`](/api/reference/account/polldeviceauthorization) | +| List active credentials | [`GET /v1/me/credentials`](/api/reference/account/listcredentials) | +| Revoke a credential | [`DELETE /v1/me/credentials/{kind}/{credentialId}`](/api/reference/account/revokecredential) | +| List connected apps | [`GET /v1/me/grants`](/api/reference/account/listgrants) | +| Stop all agent access | [`DELETE /v1/me/grants`](/api/reference/account/revokeallgrants) | + +API keys live on the team page, not under `/account`. See [API keys](/api-keys) and [API authentication](/api/authentication). diff --git a/content/(account)/auto-enroll.mdx b/content/(account)/auto-enroll.mdx index 295d4182..ab9376ed 100644 --- a/content/(account)/auto-enroll.mdx +++ b/content/(account)/auto-enroll.mdx @@ -50,7 +50,7 @@ Pressing **Join** makes them a member with the `member` role. Owners and admins A person who joins through a domain takes a seat like any other member. Members on Pro: {{plan-team-members-pro}}. -Personal and Go allow one member, the owner. On those plans, **Join** fails with `team_member_quota_exceeded`, so nobody can join until the team moves to Pro. See [Pricing & Limits](/pricing). +Personal and Go allow one member, the owner. On those plans, **Join** fails with `team_member_quota_exceeded`, so nobody can join until the team moves to Pro. See [Pricing and limits](/pricing). ## Remove a domain diff --git a/content/(account)/billing.mdx b/content/(account)/billing.mdx index ef1dee8a..cc60b40c 100644 --- a/content/(account)/billing.mdx +++ b/content/(account)/billing.mdx @@ -1,11 +1,9 @@ --- title: Plans and billing description: Change or cancel a plan, read it through the API, and what happens when a payment fails -sidebar: - order: 3 --- -Manage your plan here. Prices, allowances, and limits for every plan are on [Pricing & Limits](/pricing). +Manage your plan here. Prices, allowances, and limits for every plan are on [Pricing and limits](/pricing). ## Upgrade, downgrade or cancel @@ -15,9 +13,9 @@ Upgrades apply immediately and are prorated. Downgrades apply at renewal. Cancel ## Read the plan through the API -`GET /v1/teams/{teamId}/entitlements` and `GET /v1/teams/{teamId}/plan-policy` return the resolved `planCode` and limits. Plan codes are stable: `free` is Personal, `go` is Go and `plus` is Pro. The others are `gold`, `enterprise` and `internal`. +[`GET /v1/teams/{teamId}/entitlements`](/api/reference/teams/getteamentitlements) and [`GET /v1/teams/{teamId}/plan-policy`](/api/reference/teams/getteamplanpolicy) return the resolved `planCode` and active limits. Public plan codes are stable: `free` (Personal), `go` (Go), `plus` (Pro), and `enterprise` (Enterprise). -Use the returned entitlements for feature checks. +Use the returned entitlements for feature checks. Read subscription and payment status with [`GET /v1/teams/{teamId}/billing`](/api/reference/teams/getteambilling). ## When a payment fails @@ -25,8 +23,8 @@ Your Spaces keep serving through a grace period, but you cannot change anything. | Stage | How long | What visitors get | What you get | | --- | --- | --- | --- | -| Past due | 7 days from the failed payment | Spaces serve normally | Reads work. Every write returns `402` with code `tenant_past_due` | -| Suspended | After the grace period ends | Every space serves `402` with a **This space is paused** page | Reads work. Every write returns `403` with code `tenant_suspended` | +| Past due | 7 days from the failed payment | Spaces serve normally | Reads work. Every write returns `402` [`tenant_past_due`](/errors/tenant_past_due) | +| Suspended | After the grace period ends | Every Space serves `402` with a **This space is paused** page | Reads work. Every write returns `403` [`tenant_suspended`](/errors/tenant_suspended) | Settle the payment in the billing portal to restore access. API reads remain available in either state. diff --git a/content/(account)/identity-connections.mdx b/content/(account)/identity-connections.mdx index 1a8b3ef4..e84f0131 100644 --- a/content/(account)/identity-connections.mdx +++ b/content/(account)/identity-connections.mdx @@ -61,7 +61,7 @@ A signer body uses `authorizeUrl` and `publicKeys` instead of the client fields: } ``` -The `201` response holds the connection. Its `id` starts with `acn_`, and grants use that ID. A team can have one active connection per issuer. A second one fails with `409 identity_connection_issuer_exists`. From a terminal, run `sf share identity create`. See [`sf share`](/cli/share#sf-share-identity-create). +The `201` response holds the connection. Its `id` starts with `acn_`, and grants use that ID. A team can have one active connection per issuer. A second one fails with `409 identity_connection_issuer_exists`. From a terminal, run `sf share identity create`. See [`sf share identity create`](/cli/reference#sf-share-identity-create). | Field | Applies to | Rules | | --- | --- | --- | @@ -83,17 +83,19 @@ To add a grant in the dashboard, open the Space and go to **Share**. Open **Adva From a terminal, run `sf share identity grant`: ```bash -sf share identity grant --connection acn_xxxxxxxx --subject alex@example.com --name "Alex (Acme SSO)" --path '/docs/**' --space my-site +sf share identity grant --connection acn_xxxxxxxx --subject alex@example.com --name "Alex (Acme SSO)" --path '/docs/**' --space my-space ``` -Over HTTP, send [`createSpaceGrant`](/api/reference/access/createspacegrant) with an `external` audience: +Over HTTP, call [`createSpaceShareEntry`](/api/reference/spaces/createspaceshareentry) (`POST /v1/spaces/{spaceId}/share/entries`) with `audience: "identity"`: ```json { + "audience": "identity", + "connectionId": "acn_xxxxxxxx", + "subject": "alex@example.com", "name": "Alex (Acme SSO)", - "audience": { "kind": "external", "connectionId": "acn_xxxxxxxx", "subject": "alex@example.com" }, - "resources": { "include": ["/docs/**"] }, - "capabilities": ["page.view"], + "role": "viewer", + "paths": ["/docs/**"], "target": { "kind": "live" } } ``` diff --git a/content/(account)/meta.ts b/content/(account)/meta.ts index 96b0ad27..646e3809 100644 --- a/content/(account)/meta.ts +++ b/content/(account)/meta.ts @@ -1,8 +1,18 @@ import { defineMeta } from "blume"; export default defineMeta({ - title: "Account", + title: "Teams & account", collapsed: false, - order: 6, - pages: ["authentication", "api-keys", "identity-connections", "auto-enroll", "subteams", "pricing", "billing", "usage"], + pages: [ + "teams", + "subteams", + "auto-enroll", + "authentication", + "api-keys", + "identity-connections", + "billing", + "pricing", + "usage", + "labs", + ], }); diff --git a/content/(account)/pricing.mdx b/content/(account)/pricing.mdx index f372d099..42c48c93 100644 --- a/content/(account)/pricing.mdx +++ b/content/(account)/pricing.mdx @@ -1,6 +1,6 @@ --- -title: Pricing & Limits -description: Every plan's price, allowances and limits, per team and per Space +title: Pricing and limits +description: Every plan's price, allowances, usage budgets, per-Space Boost, and limits per team and per Space mode: wide --- @@ -10,18 +10,27 @@ Every plan allows commercial use. Hover the i on any row for what it -## Team pricing & limits +## Team pricing and limits Shared by every Space on a [team](/teams). Your included usage pays first and resets every month; unused usage doesn't roll over on any plan. Track it on [Usage](/usage). -## Space pricing & limits +## Space pricing and limits -Set per [Space](/spaces). Boost raises one Space; upgrading raises them all. +Set per [Space](/spaces). Every plan shares the same **24 MiB** uncompressed compiled Functions bundle limit, covering compiled JavaScript, embedded modules, and their manifest. +### Per-Space Boost + +Add Boost to one Space on **Go** or **Pro** for **$9 a month** instead of upgrading the whole team. Boost rides on your team's plan subscription, billing on the same invoice and prorating when you turn it on. Canceling credits unused time on the next invoice, and Boost ends when the plan ends (or without proration if you delete or transfer the Space out). + +On a Go or Pro Space, Boost raises: + +- **Scheduled crons**: at least **30** basic crons (hourly, daily, or weekly) and **10** five-field crontab crons, up to the config cap. See [Crons](/crons). +- **Transactional email**: adds **5,000** recipients per day on top of the plan's base allowance (Go: 5,200; Pro: 7,000). See [Transactional email](/email). + ## Features @@ -37,7 +46,8 @@ The first two are real usage from the last 30 days. | When | Pauses | Keeps working | | --- | --- | --- | | Personal uses its $1 | New [builds](/ci) and [Workers](/functions) | Deployed Spaces: serving, compute, email | -| You reach your spending cap | New builds and Workers. Nothing above the cap is charged | Deployed Spaces, until usage reaches the serving-pause threshold, twice the cap unless you change it. Then they stop serving until you raise the cap or the month resets | +| You reach a budget you set | New builds and Workers. Nothing above the budget is charged | Deployed Spaces | +| Usage reaches twice that budget (default serving-pause threshold) | Serving too. Visitors see "This space is paused" | Your content and settings. Raise the budget or wait for the month to reset, and serving returns | | A Space hits one of its limits | That request gets a 429 ([rate limiting](/infrastructure/rate-limiting)), or that publish gets an [error](/errors) naming the limit | The rest of the Space | ## Domains @@ -50,12 +60,6 @@ The first two are real usage from the last 30 days. Managed HTTPS is included. See [Custom domains](/domains) and [TLS certificates](/infrastructure/tls-certificates). -## Store and payments Beta - -No monthly fee and no Spacefast commission. US card processing rates: - - - ## Billing questions ### How am I billed? @@ -72,7 +76,9 @@ We may change our fees going forward, in line with the [Terms of Service](https: ### Can I cap my spending? -Yes, on Go, Pro and Business. The cap starts at twice your plan price, with alerts at 50%, 80% and 100%. You're never charged above it, even if usage briefly runs past it. +Yes. Set a monthly usage budget for a team, a subteam, or a Space in your team's **Settings**, or with [`sf budget set`](/cli/reference#sf-budget-set-amount). Go starts with a $25 default monthly budget and Pro starts with $100 (counted before the plan's included credit) until you set your own. Enterprise has no default budget unless you set one. + +Owners and admins get email and dashboard alerts at 50%, 80%, and 100% by default. At 100% of the budget, new builds and Workers pause; at 200% (adjustable between 100% and 200%), serving pauses too. You're never charged above the budget, even if usage briefly runs past it. ### Do you have nonprofit or education pricing? @@ -82,9 +88,6 @@ Yes. Contact sales. | Term | Meaning | | --- | --- | -| Beta | Free while in beta; limits still apply. A price marked \* is subject to change | -| Complimentary | Free for a limited time. The price marked † starts after a month's notice | -| Soon | Not available yet; may change before launch | | Generally available | Out of beta. Billing starts at the listed price after a month's notice | | Fair use | Normal use for a website or app. If a Space puts an unreasonable or disproportionately large load on our infrastructure, usually file sharing or storage, we ask you to adjust before restricting it. Deployed Spaces keep serving cached traffic | | Storage | Free for a limited time while we finish measuring it. Once billed: measured daily, averaged over the month, and the first 1 GB per Space isn't counted; it covers platform files on each Space. See [Server specs](/infrastructure/server-specs-settings) | diff --git a/content/(concepts)/teams.mdx b/content/(account)/teams.mdx similarity index 56% rename from content/(concepts)/teams.mdx rename to content/(account)/teams.mdx index 6880d835..c9a3295e 100644 --- a/content/(concepts)/teams.mdx +++ b/content/(account)/teams.mdx @@ -1,8 +1,6 @@ --- title: Teams and members -description: How teams own Spaces, what each role can do, and how to invite people, move Spaces between teams, and set the default access for new Spaces -sidebar: - order: 3 +description: How teams own Spaces, what each role can do, and how to invite people, move Spaces between teams, and set default access --- A team owns its Spaces, domains, API keys, and billing. Your role in that team caps what you can do with them. @@ -17,11 +15,11 @@ Personal and Go allow only the owner. Adding another member needs [Pro](/pricing ## What a team is -A team is the thing that owns work in a self-serve account. Spaces, custom domains, API keys, billing, and members all hang off it. A Space you claim belongs to the team you select, even when you are its only member. [Partner API customers](/platforms/partner-api/customers) use external principals instead. +A team owns work in a self-serve account. Spaces, custom domains, API keys, billing, and members all hang off it. A Space you claim belongs to the team you select, even when you are its only member. [Partner API customers](/platforms/partner-api/customers) use external principals instead. An Enterprise team can split into [subteams](/subteams), each with its own members and Spaces. A team can also hold [identity connections](/identity-connections), so people from your own sign-in system can open the Spaces you grant them. -A team can also hold a [Design System](/design-system) for colors, type, voice, and brand files. Saving those standards does not change any Space until you apply them to its project. +A team can also opt into [Labs](/labs) features such as [Team Memories](/team-memories), [Team Skills](/team-skills), and [Design System](/design-system). Saving standards in a Design System does not change any Space until you apply them to its project. A team has a name and a slug. The slug is the first segment of its dashboard URLs. You can change it in **Team settings → General**, where a live check tells you whether the new one is free. @@ -36,17 +34,19 @@ A team has a name and a slug. The slug is the first segment of its dashboard URL ## Roles -Your team role caps what you can do across the dashboard, CLI, API, and any agent acting on your behalf. +Your team role caps what you can do across the dashboard, CLI, API, and any agent acting on your behalf. Actions outside your role return `403` [`forbidden`](/errors/forbidden). | Action | Owner | Admin | Member | |---|---|---|---| | Read the team, its Spaces and versions | Yes | Yes | Yes | | Create Spaces, publish, rename a Space | Yes | Yes | Yes | +| Archive or restore a Space | Yes | Yes | Yes | | Promote or roll back a version, download one | Yes | Yes | Yes | | Start a build | Yes | Yes | Yes | | Read domains | Yes | Yes | Yes | | Read billing and usage | Yes | Yes | Yes | | Delete a Space or a version, export, import | Yes | Yes | No | +| List the team's inactive Spaces | Yes | Yes | No | | Attach a domain to a Space and verify it | Yes | Yes | Yes | | Detach or buy domains, change DNS | Yes | Yes | No | | Team variables and webhooks | Yes | Yes | No | @@ -78,14 +78,14 @@ Your team needs [Pro](/pricing) to add another member. Personal and Go include o -From a terminal, `sf teams invitations ls` lists invitations. Send one from the dashboard, with `sf teams members invite`, or through an agent with Agent access. Resend, cancel, or accept one in the dashboard. +From a terminal, use [`sf teams`](/cli/reference#sf-teams) and [`sf teams members`](/cli/reference#sf-teams-members) to manage teams and seats. [`sf teams invitations list`](/cli/reference#sf-teams-invitations-list) lists invitations. Send one from the dashboard, with [`sf teams members invite`](/cli/reference#sf-teams-members-invite-emails), via [`POST /v1/team-invitations`](/api/reference/teams/createteaminvitation), or through an agent with Agent access. Resend, cancel, or accept one in the dashboard. -To skip invitations for coworkers, add your company's [allowed email domain](/auto-enroll). +To skip invitations for coworkers, add your company's [allowed email domain](/auto-enroll) and share the team's join link. Print or rotate the join link with [`sf teams join-link`](/cli/reference#sf-teams-join-link) (`--reset` replaces the link and invalidates the old one immediately, without affecting current members). Over HTTP, read or reset it with [`getTeamJoinLink`](/api/reference/teams/getteamjoinlink) and [`resetTeamJoinLink`](/api/reference/teams/resetteamjoinlink); visitors resolve a join link with [`getJoinLink`](/api/reference/teams/getjoinlink). The link itself grants no access — joining still requires a verified allowed email domain or a pending invitation. Things that catch people out: - **Invitations expire after 7 days.** Resending re-stamps a fresh 7 days. -- **Pending invitations count against your seat limit.** Members plus pending invites are measured against your plan's team member limit. At the cap, remove a member or cancel an invitation first. See [billing](/billing). +- **Pending invitations count against your seat limit.** Members plus pending invites count against your plan's team member limit. At the cap, inviting returns `409` [`team_member_quota_exceeded`](/errors/team_member_quota_exceeded); remove a member or cancel an invitation first. See [billing](/billing). - **Any account with that verified address can accept**, including someone who added it as a secondary address. If the signed-in account does not hold the address, the page offers to sign in with the invited email or add the address to the current account. - **An agent cannot accept an invitation for you.** Accept it in the dashboard and the credentials you already approved pick the team up automatically. @@ -112,7 +112,13 @@ To hand the team over, use **Team settings → Danger zone → Transfer ownershi | `public` | Access for the owning team, plus view access for anyone on the web | | `parent_team` | Access for the owning team, plus view and comment access for everyone in its parent team. Needs subteams, which are on Enterprise | -The default is `private`. From a terminal, `sf teams defaults` prints the current value and `sf teams defaults public` sets it. Per-Space access, share links, and passwords are covered in [Spacefast Share](/share). +The default is `private`. From a terminal, [`sf teams defaults`](/cli/reference#sf-teams-defaults-access) prints the current value and `sf teams defaults public` sets it. Over the API, use [`GET /v1/teams/{teamId}/access/defaults`](/api/reference/access/getteamaccessdefaults) and [`PUT /v1/teams/{teamId}/access/defaults`](/api/reference/access/setteamaccessdefaults). Per-Space access, share links, and passwords are covered in [Spacefast Share](/share). + +## Organize Spaces with labels + +Teams can define shared labels (name and color) and attach them to Spaces to group projects by product, client, or owner. Label names are unique per team (case-insensitive); omitting a color picks the next unused palette hue. Deleting a label removes it from every Space that wears it without touching the Spaces themselves. + +Manage team labels with [`listTeamLabels`](/api/reference/teams/listteamlabels), [`createTeamLabel`](/api/reference/teams/createteamlabel), [`updateTeamLabel`](/api/reference/teams/updateteamlabel), and [`deleteTeamLabel`](/api/reference/teams/deleteteamlabel), and attach or remove them on a Space with [`addSpaceLabel`](/api/reference/spaces/addspacelabel) and [`removeSpaceLabel`](/api/reference/spaces/removespacelabel). ## Move a Space to another team @@ -121,7 +127,7 @@ Open the Space, then **Space settings → General → Transfer this space** and - If you are an owner or admin of the destination, the button reads **Move space** and it happens immediately. The Space keeps serving at its current address. - Otherwise the button reads **Request transfer**. Owners and admins of the destination team have 7 days to accept. Nothing changes until they do, and you can cancel any time before then. -From a terminal: +From a terminal (see [`sf spaces transfer`](/cli/reference#sf-spaces-transfer-team), [`sf transfers accept`](/cli/reference#sf-transfers-accept-transfer), and [`sf transfers cancel`](/cli/reference#sf-transfers-cancel-transfer)): ```bash sf spaces transfer @@ -137,4 +143,17 @@ Only owners and admins can transfer a Space. Two consequences to plan for: the o **Leave team** is blocked while you are the only member ("Add another owner before you can leave") or the only owner ("Transfer ownership before you can leave"). -**Delete this team** asks you to type the team slug. A team that still has live Spaces refuses to be deleted, so delete or move them first. For 30 days after the delete, an owner or admin of the team can restore it. The dashboard has no restore button yet, so ask support. Only the person who deleted the team can list it, with `GET /v1/teams?deleted=true`. After 30 days it can't be restored, but Spacefast keeps its records. +**Delete this team** asks you to type the team slug. A team that still has live Spaces refuses to be deleted, so delete or move them first. For 30 days after the delete, an owner or admin of the team can restore it. The dashboard has no restore button yet, so ask support. Only the person who deleted the team can list it, with [`GET /v1/teams`](/api/reference/teams/listteams) (`?deleted=true`). After 30 days it can't be restored, but Spacefast keeps its records. + +## API reference + +| Action | Endpoint | +|---|---| +| List or create teams | [`GET /v1/teams`](/api/reference/teams/listteams), [`POST /v1/teams`](/api/reference/teams/createteam) | +| Read, update, or delete a team | [`GET /v1/teams/{teamId}`](/api/reference/teams/getteam), [`PATCH /v1/teams/{teamId}`](/api/reference/teams/updateteam), [`DELETE /v1/teams/{teamId}`](/api/reference/teams/deleteteam) | +| List, re-role, or remove members | [`GET /v1/teams/{teamId}/members`](/api/reference/teams/listteammembers), [`PATCH /v1/teams/{teamId}/members/{memberId}`](/api/reference/teams/updateteammemberrole), [`DELETE /v1/teams/{teamId}/members/{memberId}`](/api/reference/teams/removeteammember) | +| Review connector offboarding | [`GET /v1/teams/{teamId}/members/{memberId}/offboarding`](/api/reference/teams/getteammemberoffboarding) | +| List or create invitations | [`GET /v1/team-invitations`](/api/reference/teams/listteaminvitations), [`POST /v1/team-invitations`](/api/reference/teams/createteaminvitation) | +| Read or reset the team join link | [`GET /v1/teams/{teamId}/join-link`](/api/reference/teams/getteamjoinlink), [`POST /v1/teams/{teamId}/join-link/reset`](/api/reference/teams/resetteamjoinlink), [`GET /v1/join-links/{token}`](/api/reference/teams/getjoinlink) | +| Manage team labels | [`GET /v1/teams/{teamId}/labels`](/api/reference/teams/listteamlabels), [`POST /v1/teams/{teamId}/labels`](/api/reference/teams/createteamlabel), [`PATCH /v1/teams/{teamId}/labels/{labelId}`](/api/reference/teams/updateteamlabel), [`DELETE /v1/teams/{teamId}/labels/{labelId}`](/api/reference/teams/deleteteamlabel) | +| Create, accept, or cancel Space transfers | [`POST /v1/space-transfers`](/api/reference/spaces/createspacetransfer), [`POST /v1/space-transfers/{transferId}/accept`](/api/reference/spaces/acceptspacetransfer), [`DELETE /v1/space-transfers/{transferId}`](/api/reference/spaces/cancelspacetransfer) | diff --git a/content/(account)/usage.mdx b/content/(account)/usage.mdx index 24c68011..c38c1c00 100644 --- a/content/(account)/usage.mdx +++ b/content/(account)/usage.mdx @@ -1,11 +1,9 @@ --- title: Usage description: How to read your team's and each Space's current usage -sidebar: - order: 4 --- -Check your current usage here. Allowances, unit prices, and what each meter counts are on [Pricing & Limits](/pricing). +Check your current usage here. Allowances, unit prices, and what each meter counts are on [Pricing and limits](/pricing). ## Read current usage @@ -13,7 +11,7 @@ Open your team's **Settings → Usage** to see usage against each plan limit. Fe **Settings → Billing** carries a shorter set of meters next to the plan card: Storage, Team members, Custom domains, and Publishes today. Each one highlights when you reach 80% of the limit. -Two endpoints return the numbers those pages draw. `GET /v1/teams/{teamId}/usage` gives team counters plus a per-space storage breakdown. `GET /v1/spaces/{spaceId}/usage` gives one space's measured period. +Two endpoints return the numbers those pages draw. [`GET /v1/teams/{teamId}/usage`](/api/reference/teams/getusage) gives team counters plus a per-Space storage breakdown. [`GET /v1/spaces/{spaceId}/usage`](/api/reference/spaces/getspaceusage) gives one Space's measured period. From a terminal, run [`sf usage`](/cli/reference#sf-usage). ## What gets metered @@ -21,34 +19,44 @@ Two endpoints return the numbers those pages draw. `GET /v1/teams/{teamId}/usage | Meter | Field | What it counts | At the limit | | --- | --- | --- | --- | -| Spaces | `spaces` | Live spaces in the team | Blocks at the plan limit. `409` `quota_exceeded` | -| Custom domains | `domains` | External domain groups against the plan quota | Blocks. `409` `domain_quota_exceeded` | -| Team members | `members` | Billable team members | Blocks at the plan limit. `409` `team_member_quota_exceeded` | -| Storage | `storageBytes` | Disk your spaces occupy | Displayed only. Nothing blocks | +| Spaces | `spaces` | Live Spaces in the team | Blocks at the plan limit. `409` [`quota_exceeded`](/errors/quota_exceeded) | +| Custom domains | `domains` | External domain groups against the plan quota | Blocks. `409` [`domain_quota_exceeded`](/errors/domain_quota_exceeded) | +| Team members | `members` | Billable team members | Blocks at the plan limit. `409` [`team_member_quota_exceeded`](/errors/team_member_quota_exceeded) | +| Storage | `storageBytes` | Disk your Spaces occupy | Displayed only. Nothing blocks | | Publishes | `buildsDeploysToday` | Publishes and builds since the UTC day started, pooled | Warns only. Publishing continues | The response also carries `storageQuotaBytes`, `storageOverageBytes`, `buildsDeploysDaily`, and `buildsDeploysThisMonth`, so you can compute headroom. -### Current per-space measurements +### Current per-Space measurements -`GET /v1/spaces/{spaceId}/usage` returns one settled period. +[`GET /v1/spaces/{spaceId}/usage`](/api/reference/spaces/getspaceusage) returns one settled period. | Field | What it measures | | --- | --- | | `storageBytes` | Average bytes on disk during the period, not the size of what you uploaded | -| `computeSeconds` | Compute the space consumed | -| `bandwidthBytes` | Bytes the space served | -| `emailCount` | Emails the space sent | -| `functionInvocations` | Function calls, counted where the space is known | +| `computeSeconds` | Compute the Space consumed | +| `bandwidthBytes` | Bytes the Space served | +| `emailCount` | Emails the Space sent | +| `functionInvocations` | Function calls, counted where the Space is known | | `functionErrors` | Those calls that ended in an error | These measurements are usage counters, not invoice line items. +## Usage budgets + +Cap monthly spending for a team, subteam, or Space in team **Settings**, from the CLI with [`sf budget`](/cli/reference#sf-budget) ([`sf budget set`](/cli/reference#sf-budget-set-amount), [`sf budget list`](/cli/reference#sf-budget-list), [`sf budget clear`](/cli/reference#sf-budget-clear-budget)), or through the API: + +- [`GET /v1/teams/{teamId}/usage/budgets`](/api/reference/teams/listusagebudgets) lists active budgets. +- [`PUT /v1/teams/{teamId}/usage/budgets`](/api/reference/teams/setusagebudget) creates or updates a budget. +- [`DELETE /v1/teams/{teamId}/usage/budgets/{budgetId}`](/api/reference/teams/clearusagebudget) removes a budget. + +When a budget is reached, new builds and Workers pause and return [`usage_budget_exceeded`](/errors/usage_budget_exceeded). See [Pricing and limits](/pricing#can-i-cap-my-spending) for default budgets and pause thresholds. + ## Measurement timing Storage is measured by the infra that serves your Spaces, and it lags the present by about an hour. `storageCalculatedAt` tells you how far back the weakest measurement behind the total reaches. -Nothing is deduplicated. A file present in two spaces sits on two disks and counts twice in your team total. +Nothing is deduplicated. A file present in two Spaces sits on two disks and counts twice in your team total. The newest measurement period is always dropped, because partial ingestion underreports it. When the measuring infrastructure is unreachable, usage comes back as `null` rather than a zero or a cached guess. A blank meter means unmeasured, not empty. diff --git a/content/(build)/actions.mdx b/content/(build)/actions.mdx new file mode 100644 index 00000000..edfb1737 --- /dev/null +++ b/content/(build)/actions.mdx @@ -0,0 +1,213 @@ +--- +title: Actions, queries, and jobs +description: Write typed SpacePress queries, server mutations, zero-JS forms, background jobs, transactional hooks, and custom HTTP routes on your Space +--- + +SpacePress runs typed server queries, validated mutations, progressive zero-JS forms, transactional hooks, Action Scheduler background jobs, and custom HTTP routes directly on your Space. Export them in TypeScript under `sp/` or declare actions under `app.actions` in `spacefast.config.ts`. + +## Write typed queries and mutations + +Export `query(options, handler)` for read-only server functions and `mutation(options, handler)` for writes. Both validate input from your TypeScript parameter types, enforce declarative access rules, and expose endpoints at `POST /wp-json/spacepress/v1/actions/` and as WordPress Abilities. + +```ts sp/tasks.ts +import { mutation, query } from "spacepress"; +import { HttpError } from "spacepress/server"; +import { tasks } from "spacepress/server/db"; + +export const openTasks = query( + { access: "authenticated" }, + async ({ limit }: { limit: number }) => { + return tasks.list({ where: { done: false }, limit }); + }, +); + +export const archiveTask = mutation( + { access: "editor", idempotent: true }, + async ({ id }: { id: number }) => { + const row = await tasks.update(id, { done: true }); + if (!row) throw new HttpError(404, "not_found", "Task not found"); + return row; + }, +); +``` + +Key options on `query()` and `mutation()`: + +- `access`: `"anyone"`, `"authenticated"`, `"self"`, a role on the ladder (`guest < subscriber < author < editor < admin`), a boolean, or an access function. +- `rateLimit`: Throttle calls per caller window, such as `"5/min"`. +- `idempotent` and `destructive`: Mark safe retries or destructive mutations for clients and agents. +- `signature`: Verify HMAC-signed inbound webhooks before the handler runs. +- **Inferred input schema:** Do not pass `input`, `args`, or `fields` in the options object — SpacePress infers input fields and validation directly from the handler's TypeScript parameter type. + +You can also declare inline actions under `app.actions` in `spacefast.config.ts` (publish only one app definition per project — inline `app` or standalone `spacepress.config.ts`, not both): + +```ts spacefast.config.ts +import { defineConfig } from "spacefast/config"; + +export default defineConfig({ + name: "my-space", + app: { + actions: { + contact: { access: "anyone" }, + rebuild: { access: "admin" }, + }, + }, +}); +``` + +Run `sf check` to validate `spacefast.config.ts` and your SpacePress handlers offline before publishing. + +## Scaffold a progressive form with `sf add form` + +`sf add form` writes plain SpacePress files into your project that you own and edit directly; nothing is regenerated later. It keeps existing files unless you pass `--force`, and `--dry-run` prints the plan without writing: + +```bash +sf add form --dry-run +sf add form +``` + +The recipe creates two files (plus a minimal `spacepress.config.ts` when the project does not declare an app yet): + +- `sp/contact.ts`: Defines a `contactMessages` table (admin-only read, no direct client writes) and a `sendContactMessage` mutation with `{ access: "anyone", rateLimit: "5/min" }`. +- `sp/app/contact/page.tsx`: Renders the contact form at `/contact`, wired straight to the mutation. + +### Server handler and field-level validation + +Throwing `HttpError` with a JSON Pointer (`"/email"`) binds the error message to that input in the form state and marks the field `aria-invalid="true"`: + +```ts sp/contact.ts +import { email, mutation, table, text, timestamp } from "spacepress"; +import { db, HttpError, mail } from "spacepress/server"; + +export const contactMessages = table( + { + name: text().max(120), + email: email(), + message: text({ multiline: true }).max(5000), + createdAt: timestamp().defaultNow(), + }, + { access: { read: "admin", create: false, update: false, delete: false } }, +); + +export const sendContactMessage = mutation( + { access: "anyone", rateLimit: "5/min" }, + async (input: { name: string; email: string; message: string }) => { + if (!input.email.includes("@")) { + throw new HttpError(422, "invalid_input", "Enter an email address", "/email"); + } + const [row] = await db.insert(contactMessages).values(input).returning(); + await mail.send({ + to: "you@example.com", + replyTo: input.email, + subject: `New message from ${input.name}`, + text: input.message, + }); + return { id: row?.id ?? null }; + }, +); +``` + +Inserting into `contactMessages` before calling `mail.send()` keeps every submission in your [Database](/database) even if outbound delivery retries. To deliver live mail, authenticate a custom primary domain for [Transactional email](/email). + +### Zero-JS forms and `useFormState` + +Pass any mutation directly to `
` (omit `method` and `encType` — SpacePress sets them). Forms work before JavaScript loads (form-encoded POST with a `303` redirect back to the page) and upgrade to in-place `fetch` updates once the router script runs: + +```tsx sp/app/contact/page.tsx +import { useFormState } from "spacepress/app"; +import { sendContactMessage } from "../../contact"; + +export default function Contact() { + const sent = useFormState(sendContactMessage); + return ( + + + +