Table of contents
- Extension Development Guide
- How extensions run
- Quick start
- Directory layout
- extension.yaml reference
- Backend
- Permissions
- Hooks
- Frontend module contract
- registerSettingsCard(card)
- registerWorkshopNavItem(item)
- registerWorkshopView(view)
- registerSidePanelAction(action)
- Worked example: Word Sprint Helper
- Packaging
- Validation checklist
- API reference
Extension Development Guide
This guide is for developers building a Writers Notebook extension. For the end-user side (installing, permissions, managing), see Extensions.
How extensions run
An extension is a .zip package, installed at the app level (shared across every project, not tied to one). It can contribute two independent pieces, and needs neither, either, or both:
- A frontend module: a plain JavaScript file loaded into the running app and executed in its main page context. It can register UI: a card in Settings, a Workshop navigation item, a whole custom Workshop view, or a button on the editor/review action bar.
- A backend program: a regular executable (a compiled binary, or a script) that the app runs as a separate OS process. The app talks to it by writing a JSON request to its stdin and reading a JSON response from its stdout. There's no embedded scripting engine or VM; your backend is a real program on the user's machine.
Everything an extension is allowed to do is gated by permissions the user grants individually after installing; see Permissions below.
Quick start
- Create a folder for your extension with an
extension.yamlat its root. - Add a
frontend/module.jsif you want UI contributions, and/or backend binaries/scripts if you want backend actions or lifecycle hooks. - Zip the folder's contents (
extension.yamlmust end up at the archive root, or inside exactly one top-level folder). - Install the
.zipfrom Settings > Extensions in the app. - Grant the permissions your manifest requests, then enable it.
- Exercise your actions/hooks and check the results.
Directory layout
A typical package:
my-extension/
extension.yaml
README.md
backend/
bin/
my-extension-darwin-arm64
my-extension-linux-amd64
my-extension-windows-amd64.exe
frontend/
module.js
extension.yaml reference
Required fields
titledescriptionversionurl
Optional fields
id: a slug. Generated fromtitleif omitted.tags: a list of free-form labels shown on the extension's card.sdk.version: defaults to1. Must match the SDK version the running app supports, or the extension won't load.permissions: the list of permissions this extension needs (see Permissions).backend: backend configuration (see Backend).frontend: frontend configuration; currently justfrontend.entry, a relative path to your JS module.
Complete example
id: word-sprint-helper
title: Word Sprint Helper
description: Adds sprint actions and lifecycle hooks.
version: 1.0.0
url: https://example.com/writersnotebook/extensions/word-sprint-helper
tags:
- editor
- productivity
sdk:
version: 1
permissions:
- ui.settings.cards
- ui.sidepanel.actions
- backend.invoke
- hook.models
- hook.backup
backend:
entry: backend/bin/word-sprint-helper-generic
targets:
- os: darwin
arch: amd64
entry: backend/bin/word-sprint-helper-darwin-amd64
- os: darwin
arch: arm64
entry: backend/bin/word-sprint-helper-darwin-arm64
- os: linux
arch: amd64
entry: backend/bin/word-sprint-helper-linux-amd64
- os: linux
arch: arm64
entry: backend/bin/word-sprint-helper-linux-arm64
- os: windows
arch: amd64
entry: backend/bin/word-sprint-helper-windows-amd64.exe
- os: windows
arch: arm64
entry: backend/bin/word-sprint-helper-windows-arm64.exe
actions:
- status
- start-sprint
hooks:
- backup.create
- project.create.after
frontend:
entry: frontend/module.js
Backend
backend.entry and/or backend.targets point at the executable(s) the app should run. backend.actions lists the action names your frontend module (or a Settings card button) can invoke; backend.hooks lists the lifecycle/domain events you want to receive.
Target matching
If backend.targets is present, the app picks the best match for the current OS/architecture, in this order:
- Exact
os+ exactarch - Exact
os+ wildcardarch(wildcard =*or omitted) - Wildcard
os+ exactarch - Wildcard
os+ wildcardarch
The first declared target wins a tie. If nothing matches and backend.entry is set, that's used as a fallback. If nothing matches and there's no fallback, invoking the backend fails with a platform-mismatch error.
How an entry file is run
.shfiles run via/bin/shon macOS/Linux; rejected on Windows..cmd/.batfiles run viacmd.exe /C, Windows only..ps1files run viapowershell.exe -ExecutionPolicy Bypass -File, Windows only.- Anything else is executed directly as a binary (given the executable bit on macOS/Linux automatically).
I/O contract
The app writes a single JSON object to your process's stdin, once per invocation, then closes stdin and waits (up to a 20-second timeout) for a JSON object on stdout:
{
"event": "invoke",
"action": "status",
"payload": {},
"extension": {
"id": "word-sprint-helper",
"manifest": { "title": "Word Sprint Helper", "version": "1.0.0" },
"enabled": true
}
}
Write a JSON object to stdout in response. Empty stdout is treated as { "ok": true }.
Lifecycle events
Beyond invoke (an action your UI or another extension explicitly triggered), your backend also receives:
installenabledisableuninstall
...plus any domain hooks you subscribed to in backend.hooks (see Hooks).
Permissions
Permissions gate what an extension is allowed to do; the user grants or revokes each one individually after install (see Extensions). Declare only what you actually use.
| Permission | Unlocks |
|---|---|
ui.settings.cards |
Adding an action card to Settings > Extensions |
ui.workshop.nav |
Adding a Workshop sidebar navigation item |
ui.workshop.view |
Registering a custom Workshop view/route |
ui.sidepanel.actions |
Adding a button to the editor/review right-hand action bar |
backend.invoke |
Calling your own backend's invoke action from the frontend |
hook.models |
Model lifecycle hooks (project/outline/character/plot/world/glossary/comment) |
hook.backup |
Backup/restore lifecycle hooks |
hook.storage |
Storage lifecycle hooks |
hook.import |
Import pipeline hooks |
hook.export |
Export pipeline hooks |
hook.analysis |
Analysis pipeline hooks |
If an extension requests zero permissions, it's enabled automatically on install (there's nothing to grant). If any requested permission is missing, the extension can't be enabled until it's granted or revoked from the manifest.
Hooks
Domain event families you can subscribe to via backend.hooks:
project.*outline.*character.*plot.*world.*glossary.*comment.*backup.*storage.*import.*export.*analysis.*
Concrete examples emitted by core flows include project.create.before / project.create.after and outline.node.content.save.before / outline.node.content.save.after.
First-handler hooks
backup.create and backup.restore use first-handler semantics: the app calls every enabled, permitted extension subscribed to that hook, in order, and stops at the first one that responds with { "handled": true }. This lets an extension fully replace the built-in backup/restore behavior, for example with a git-based backup, instead of just observing it. Every other hook is fire-and-forget: every subscribed extension gets it, and nothing they return changes app behavior.
Frontend module contract
If frontend.entry is set, that file is loaded when the extension is enabled and can export an activate(context) function:
export async function activate(ctx) {
// register things here
return {
deactivate() {
// release anything you set up, if needed
},
};
}
activate can return either a plain deactivate() function or an object with one. Both are optional; activate itself doesn't have to return anything.
context provides:
id: your extension's idmanifest: your parsedextension.yamlregisterSettingsCard(card), requiresui.settings.cardsregisterWorkshopNavItem(item), requiresui.workshop.navregisterWorkshopView(view), requiresui.workshop.viewregisterSidePanelAction(action), requiresui.sidepanel.actionsinvoke(action, payload), calls your own backend'sinvokehandler foraction, requiresbackend.invoke
Calling a register* helper without its permission throws.
registerSettingsCard(card)
ctx.registerSettingsCard({
id: "sprint-tools",
title: "Sprint Tools",
description: "Run backend extension actions.",
actions: [
{ id: "status", label: "Check Status", action: "status", variant: "tonal" },
{ id: "start", label: "Start Sprint", action: "start-sprint", payload: { minutes: 20 }, color: "primary", variant: "flat" },
],
});
Each entry in actions renders as a button on your card; clicking it calls your backend's invoke with that action and payload.
registerWorkshopNavItem(item)
ctx.registerWorkshopNavItem({
id: "my-nav-item",
title: "My Extension",
icon: "mdi-puzzle-outline",
to: "/workshop/extensions/my-extension/main",
order: 1000,
});
to must start with /workshop/, or registration throws.
registerWorkshopView(view)
ctx.registerWorkshopView({
id: "main",
title: "My Extension",
icon: "mdi-puzzle-outline",
component: MyViewComponent, // a Vue component
props: {},
order: 1000,
});
This also adds a matching navigation item for you, routed at /workshop/extensions/<your-extension-id>/<view-id>.
registerSidePanelAction(action)
ctx.registerSidePanelAction({
id: "word-sprint-helper-status",
title: "Word Sprint Status",
icon: "mdi-timer-outline",
action: "status", // or: run: () => { ... }
variant: "text",
order: 1200,
});
Provide either an action name (invoked against your own backend with payload, if any) or a run() function; exactly one is required.
Worked example: Word Sprint Helper
The repository ships a complete sample extension under docs/examples/extensions/word-sprint-helper/ that exercises most of the surface above.
extension.yaml requests ui.settings.cards, ui.sidepanel.actions, backend.invoke, hook.models, and hook.backup; declares two actions (status, start-sprint); and subscribes to backup.create, project.create.after, and outline.node.content.save.after.
frontend/module.js registers a Settings card with "Check Status" and "Start 20m Sprint" buttons, plus a side-panel action:
export async function activate(ctx) {
ctx.registerSettingsCard({
id: "word-sprint-helper-tools",
title: "Word Sprint Helper",
description: "Run sprint-related backend actions from Settings.",
actions: [
{ id: "status", label: "Check Status", action: "status", variant: "tonal" },
{ id: "start-20", label: "Start 20m Sprint", action: "start-sprint", payload: { minutes: 20 }, color: "primary", variant: "flat" },
],
});
ctx.registerSidePanelAction({
id: "word-sprint-helper-status",
title: "Word Sprint Status",
icon: "mdi-timer-outline",
action: "status",
variant: "text",
order: 1200,
});
return { deactivate() {} };
}
backend/cmd/entry/main.go is a small Go program that reads the stdin envelope and switches on event/action:
switch req.Event {
case "invoke":
handleInvoke(req.Action) // "status" or "start-sprint"
case "backup.create":
handleBackupCreate() // responds { ok: true, handled: true, ... }
case "project.create.after", "outline.node.content.save.after":
handleLifecycleEvent(req.Event)
default:
respond(map[string]any{"ok": true, "event": req.Event})
}
Its handleBackupCreate demonstrates the first-handler override pattern: responding with "handled": true tells the app this extension has fully handled the backup itself.
A backend/build.sh cross-compiles that Go program for darwin/amd64, darwin/arm64, linux/amd64, linux/arm64, windows/amd64, and windows/arm64 into backend/bin/, matching the backend.targets entries in the manifest. You don't have to use Go for your own backend; any language that can read stdin, write stdout, and be compiled or invoked as described in Backend works.
Packaging
From your extension folder, once any backend binaries are built:
zip -r ../my-extension.zip .
Install the resulting .zip from Settings > Extensions.
Validation checklist
Before sharing an extension:
extension.yamlis present and valid, with all required fields set.- Backend paths are relative to the package root.
- Every
backend.targetsentry points at a file that's actually in the archive. - Requested
permissionsare minimal and accurate, only what you actually use. frontend.entry, if declared, points at a real file.- Your backend always writes valid JSON to stdout (or nothing, which is treated as success).
- The package installs, enables, and its actions/hooks run successfully end to end.
API reference
For advanced tooling, testing, or understanding what the frontend module contract sits on top of.
Desktop (Wails-bound)
SelectExtensionArchive()InstallExtensionFromPath(path)InstallExtension(filename, data)ListExtensions()SetExtensionEnabled(id, enabled)SetExtensionPermission(id, permission, granted)RemoveExtension(id)GetExtensionFrontendModule(id)InvokeExtension(id, action, payload)
Web mode (REST)
GET /api/extensionsPOST /api/extensions(multipart field:extension)PUT /api/extensions/:id/enabledPUT /api/extensions/:id/permissionsDELETE /api/extensions/:idGET /api/extensions/:id/frontend/modulePOST /api/extensions/:id/invoke
Where extension data lives
- Extension root:
<app-config-dir>/writersnotebook/extensions/ - Installed-extension registry:
<app-config-dir>/writersnotebook/extensions/extensions.yaml - Each extension unpacked to:
<app-config-dir>/writersnotebook/extensions/<extension-id>/
This is app-level storage, shared by every project, the same pattern custom fonts use.