PiscesQuickstart

Plugin development

Extend Pisces with declarative editor features, sandboxed Wasm blocks, and versioned interfaces.

Choose an extension surface

Surface Use it for Execution
Declarative blocks Native Gutenberg controls, semantic markup, and nested blocks The embedded editor reads a validated manifest
Publishing panels Title, description, canonical, social fields, or indexing controls Pisces validates fields and builds the head and sitemap
Wasm blocks Request-time behavior based on block attributes A restricted worker returns a structured result
Interfaces and form actions Approved provider calls and reactions to accepted submissions The host brokers calls or queues granted work

Install a package version, then activate its digest on the selected site. Shared catalog entries can be installed across sites. Each site has its own activation and interface approvals.

Build a Gutenberg block

Save the Reading annotation manifest as reading-note.json. The manifest registers a block called reading-note/annotation, with one text control and an aside as its saved markup. The block namespace matches the package ID.

digest=$(pisces plugin-install reading-note.json --site journal)
pisces plugin-activate journal "$digest" --approved-by local-operator

Reload Gutenberg, insert Reading annotation, edit its Annotation field in the block inspector, and publish. Check the aside.reading-annotation on the public article. The manifest’s markup property tells the host which element and field to serialize.

{
  "tag": "aside",
  "class_name": "reading-annotation",
  "children": [{ "type": "text", "field": "note" }]
}

Try pisces plugin-deactivate journal reading-note and refresh the article. The editor registration goes away. Saved static markup remains part of the post and still renders through the sanitizer. Reactivate the digest to edit the block with its original controls.

For a larger block, declare allowed inner blocks and a starting template in inner_blocks. A field can refer to a compatible plugin setting via default_from_setting to set defaults for newly inserted blocks. Existing saved attributes keep their values.

Add a publishing panel

A manifest can declare publishing.editor_hook as document.publish and publishing.publish_hook as page.metadata. Its fields array can include title, description, canonical, social_title, social_description, article_type, and noindex. The source checkout’s packages/publishing-seo/manifest.json demonstrates the contract. The host owns document visibility and uses active contributions when generating metadata.

Build a Wasm block

The sandbox loads a WebAssembly component. Its WIT world exports render, which takes a JSON string and returns a JSON string or guest error. Pisces supplies inputs for the current operation and validates the result. The guest has no WASI imports. Use wasm32-unknown-unknown for the Rust example and componentize the resulting module.

From the Pisces source checkout with its binary on your path, run the build below. Use the same scratch site and data directory as Quickstart.

rustup target add wasm32-unknown-unknown
cargo build --manifest-path crates/pisces-sandbox/examples/block/Cargo.toml \
  --release --target wasm32-unknown-unknown
cargo run --manifest-path crates/pisces-sandbox/Cargo.toml --example componentize -- \
  crates/pisces-sandbox/examples/block/target/wasm32-unknown-unknown/release/pisces_example_block.wasm \
  /tmp/pisces-example.component.wasm

Save this manifest as message.json.

{
  "plugin_id": "example",
  "version": "1.0.0",
  "block_name": "example/message"
}
digest=$(pisces plugin-install message.json /tmp/pisces-example.component.wasm --site journal)
pisces plugin-activate journal "$digest" --approved-by local-operator

Start or restart the scratch server with the worker image configured. Place the serialized block below into a post’s code editor, publish, and open the public route.

<!-- wp:example/message {"text":"Rendered in the worker"} /-->

The checkout’s example returns a structured node such as {"type":"text","value":"Rendered in the worker"}. The host escapes text and validates an element tree against bounds and an allowed tag set. Each worker runs with fuel, memory, output, and wall-clock limits. An unavailable worker or unapproved package omits that dynamic result and leaves the rest of the page available.

Broker a versioned interface

Interfaces use IDs such as editorial/review@1. A definition publishes bounded schemas for input and output. Providers declare which packages they serve, consumers declare the interfaces they use, and the site operator approves both sides plus the caller grant.

pisces plugin-activate journal "$consumer_digest" --approved-by local-operator --allow-interfaces
pisces plugin-activate journal "$provider_digest" --approved-by local-operator --allow-interfaces
pisces plugin-interface-grant journal caller editorial/review@1 --approved-by local-operator
pisces plugin-interface-pin journal editorial/review@1 provider
pisces plugin-interface-resolve journal caller editorial/review@1

The example assumes installed packages with IDs caller and provider that declare editorial/review@1. With a single eligible provider the site can resolve it automatically. With several eligible providers a pin can select the intended one. An unavailable pinned provider stops resolution. Inspect consumers and selected providers in Plugins → Connections where supported.

A form action can subscribe to form.accepted@1 with only the fields granted for that binding. The host can queue a plain-text email to an operator-selected recipient or increment a declared counter. It rechecks approval and binding state at execution. See crates/pisces-sandbox/examples/interfaces/ in the source checkout for provider, consumer, and form action fixtures.