refern.
Extensions

Manifest reference

Every key of a refern extension's manifest.json (apiVersion 1), its limits and checks, contribution points, and .refernplugin packaging.

Every extension has a manifest.json at the top of its folder. refern, refern-cli and the extension registry check it with the same rules (validatePluginManifest in @refern/plugin-sdk/manifest). The CLI and the registry are strict: an unknown key is an error. refern itself treats an unknown key as a warning, so a manifest written for a newer refern still loads.

A complete example

 { "id" : "yourname.color-tools" , "name" : "Color Tools" , "version" : "1.0.0" , "apiVersion" : 1 , "minAppVersion" : "1.12.0" , "author" : "Your Name" , "description" : "Find items by color and tag them." , "homepage" : "https://example.com/color-tools" , "fundingUrl" : null , "kind" : "app" , "entry" : "dist/index.html" , "permissions" : { "scopes" : [ "read" , "write" ], "includeNsfw" : false , "network" : [ "api.example.com" ], "managedTools" : [] }, "contributes" : { "commands" : [ { "id" : "palette" , "title" : "Show Color Palette..." , "category" : "Color Tools" , "defaultShortcut" : null , "when" : "selection.single && selection.hasImages" } ], "menus" : { "itemContext" : [{ "command" : "palette" , "group" : "color" }] }, "panels" : [ { "id" : "palette" , "slot" : "dialog" , "title" : "Color Palette" , "entry" : "dist/index.html" , "size" : "medium" } ], "settings" : [ { "key" : "apiKey" , "type" : "secret" , "label" : "API key" }, { "key" : "swatches" , "type" : "number" , "label" : "Swatches" , "default" : 6 , "min" : 2 , "max" : 12 } ] } } 

Top-level keys

KeyTypeRequiredRules
idstringyesLowercase reverse-domain id, at most 64 characters: yourname.my-plugin. At least one .; parts of a-z, 0-9 and inner -.
namestringyes1 to 64 characters.
versionstringyesMAJOR.MINOR.PATCH, with an optional -prerelease (1.0.0, 2.1.0-beta.1).
apiVersionnumberyesExactly 1.
minAppVersionstringnoThe oldest refern version the extension needs, same format as version. refern refuses to install it on an older version (app_too_old).
authorstringno1 to 80 characters.
descriptionstringno1 to 400 characters. Shown on the Extensions page and in the install confirm.
homepagestring or nullnoAn https:// address.
fundingUrlstring or nullnoAn https:// address.
kind"app", "theme" or "format"yesThe tier. It decides which other keys are allowed.
entrystringapp: yesapp and format only. A package path to an HTML page (see Package paths).
permissionsobjectapp, formatSee Permissions. A format plugin uses { "scopes": [] }.
contributesobjectnoapp and format only. See Contribution points.
themesstring[]theme: yestheme only. 1 to 16 .json package paths. See Themes.

The first-party extensions and the starter templates use minAppVersion: "1.12.0" so pre-release builds load them. Set it to the oldest refern version you test with.

Package paths

Every file a manifest names (entry, panel and overlay entries, wasm, viewer entries, theme files) is a relative path inside the package: /-separated names of A-Z a-z 0-9 . _ - + @, each 1 to 128 characters, at most 512 in all. .., ., a leading /, a backslash, a drive (C:) or a URL are refused. This check is a security boundary.

Permissions

 "permissions" : { "scopes" : [ "read" ], "includeNsfw" : false , "network" : [ "api.example.com" , "*.cdn.example.com" ], "managedTools" : [] } 
KeyTypeRules
scopesstring[]Required (may be empty). Each of "read", "write", "organize", once.
includeNsfwbooleanDefault false: items marked NSFW are hidden from the extension, as from a token that hides them.
networkstring[]At most 32 hosts for refern.net.fetch: api.example.com exactly, or *.example.com for its subdomains. No IP address, port, path, scheme, localhost, .local or .internal.
managedToolsstring[]At most 1: "exiftool", for refern.tools.exiftool.*.

What each scope allows:

ScopeAllows
readRead items, folders, tags, creators, groups, smart folders, search, the change list, the selection, thumbnails.
writeChange metadata and tags (items.update), create tags, creators, folders and groups, link items, import URLs, undo.
organizeRename, move, copy and trash files; edit and delete tags and creators; change smart folders and tag structures.

The user sees every permission before an extension installs, and can turn an extension off at any time on the Extensions page. Ask for the fewest scopes you need: refern refuses a call outside the granted scopes with scope_required or forbidden.

Contribution points

contributes may hold commands, menus, panels, overlays, importSources, formats and settings. Local ids (command, panel, overlay and import source ids) are 1 to 64 characters, start with a letter, and use A-Z a-z 0-9 . _ -. Each is unique within its list.

commands (at most 64)

KeyTypeRules
idstringLocal id. refern registers it as plugin:<pluginId>:<id>.
titlestring1 to 80 characters.
categorystringOptional, 1 to 40 characters.
defaultShortcutstring or nullOptional key such as Alt+Q, 1 to 40 characters. The user can change it.
whenstringOptional when expression. The command runs only when it holds.

Commands are listed in Settings > Shortcuts > Extensions and tools, grouped by extension name, where the user can give them keys. What a command does depends on its id:

  1. An overlays entry with the same id: the overlay opens at the pointer.
  2. A dialog panel with the same id: the dialog opens.
  3. Otherwise: refern loads the manifest's entry page in a hidden frame (on first use) and sends it the event command.run with { commandId, args }. Listen with refern.on("command.run", ...) at the top level of that page.

Context menu entries, each naming a command of this extension.

 "menus" : { "itemContext" : [{ "command" : "palette" , "group" : "color" , "when" : "selection.hasImages" }], "folderContext" : [{ "command" : "palette" }], "canvasItemContext" : [] } 
SlotWhere
itemContextThe context menu of items.
folderContextThe context menu of folders.
canvasItemContextThe context menu of canvas items.

Each slot holds at most 32 entries of { command, group?, when? }. command must be the id of a command in this manifest; group is 1 to 40 characters. An entry shows only when both its own when and the command's when hold. A menu passes args to the command: { menu, entityId, selectionCount } (entityId is the item the menu opened on, or null for a multi-item selection).

panels (at most 16)

KeyTypeRules
idstringLocal id.
slot"dialog" or "metadataSidebar"Where the panel shows.
titlestring1 to 80 characters, shown above the frame.
entrystringAn HTML page in the package.
size"small", "medium", "large"dialog only: 400 x 320, 640 x 480 (default) or 960 x 640 pixels.
defaultHeightintegermetadataSidebar only: 48 to 1200 (refern shows at most 640). Default 200.
whenstringOptional. For metadataSidebar: the panel shows only when it holds.
  • A dialog opens from a command with the same id, or from refern.ui.openDialog({ panelId, context }) after a click. Its frame context is the command's { commandId, args } or your context. Escape and the backdrop close it, also while focus is inside the frame (the SDK forwards Escape unless a text field, an editable element, an open menu or a list box has focus, or your keydown handler calls event.preventDefault()); the page can close it with refern.ui.closeOverlay(). Dialogs do not open in pop-out viewer windows.
  • A metadata sidebar panel shows under the item's metadata, with its title and the extension's name. Its frame context is { workspaceId, entityIds: [id] } for one item and { workspaceId, selectionCount } for several. The frame starts again for each new item or selection.

overlays (at most 4)

A fixed-size transparent frame at the pointer, such as a pie menu.

KeyTypeRules
idstringLocal id. A command with this id opens it.
entrystringAn HTML page in the package.
widthinteger16 to 640 pixels.
heightinteger16 to 640 pixels.

Make the page background transparent. refern.ui.closeOverlay() closes it.

importSources (at most 4)

KeyTypeRules
idstringLocal id.
titlestring1 to 80 characters.
subtitlestringOptional, 1 to 120 characters.
panelstringThe id of a dialog panel of this manifest.

An extension needs at least one import source (and the write scope) to call refern.imports.enqueueUrls.

refern lists each import source of an enabled extension in the import dialog (under Add files and Add folder), in the Create menu, and in a folder's right-click menu. A click opens the source's panel with the refern:init context { importSourceId, folderId }. folderId is the folder the user opened it from, or null. Pass it on to imports.enqueueUrls so the files land in that folder.

formats (at most 8)

For kind: "format" (at least one entry is required) and, rarely, app plugins.

KeyTypeRules
extensionsstring[]1 to 16, lowercase, no dot, 1 to 10 of a-z 0-9. Each extension once per manifest.
wasmstringA .wasm file in the package. See the decoder ABI in SDK and CLI.
categoryHintstringOptional, 1 to 32 characters. Not used by refern yet.
maxInputBytesintegerOptional, 1 to 67108864 (64 MiB, the default). Larger files go to the OS preview.
viewerobjectOptional { entry, maxFileBytes? }: an HTML page that shows the open file, with refern.viewer.readCurrentFile(). maxFileBytes is at most 64 MiB.

When two active format plugins claim one extension, the one installed first decodes it. A newly enabled format plugin version queues the files of its extensions again (files with no preview, an OS preview, or one from another version of it).

When a file of one of its extensions opens in the file viewer, refern shows the viewer page of the first active format plugin that has one, in place of the still preview. The page reads the file with refern.viewer.readCurrentFile(). Grid and canvas thumbnails come from the decoder.

settings (at most 64)

Declarative settings that refern shows on the Extensions page under the extension. Read them with refern.settings.getAll(); refern sends settings.changed when the user changes one. A format plugin's decoder gets them as JSON in cfg.

KeyTypeRules
keystring1 to 64 of A-Z a-z 0-9 _, starting with a letter. Unique.
type"boolean", "string", "number", "select", "secret"
labelstring1 to 120 characters.
descriptionstringOptional, 1 to 400 characters.
defaultboolean, string, number or nullMust match the type. A secret has no default.
maxLengthnumberOptional, for string.
min, max, stepnumberOptional, for number.
options{ value, label }[]Required for select: 1 to 64 options, value 1 to 64 characters, label 1 to 80.

A secret setting (an API key) is stored in the operating system's credential store (service refern.plugin.<pluginId>), never in a file. settings.getAll() leaves it out. Read it with refern.settings.getSecret({ key }), or better, let refern put it into a request header with {{secret:<key>}} in refern.net.fetch, so the frame never holds it.

when expressions

Atoms joined by &&. There is no ||, no ! except !popout, no parentheses. At most 256 characters. refern checks them before any extension code runs.

AtomHolds when
selection.nonEmptyAt least one item is selected.
selection.singleExactly one item is selected.
selection.multipleMore than one item is selected.
selection.singleFileExactly one item is selected and it is a file.
selection.hasFilesThe selection holds a file.
selection.hasImagesThe selection holds an image.
selection.hasVideosThe selection holds a video.
selection.ext:<ext>The selection holds a file with this extension (selection.ext:psd; 1 to 10 of a-z 0-9).
view.gridThe grid is showing.
view.viewerThe viewer is showing.
view.canvasA canvas is showing.
!popoutThe window is not a pop-out viewer window.

For a large selection refern does not read every item for a when expression: the item atoms (hasFiles, hasImages, ext:) then hold, and your code checks the items it reads.

Themes

A theme package (kind: "theme") holds only id, name, version, apiVersion, the optional base keys, kind and themes. Each theme file:

 { "id" : "ocean-night" , "name" : "Ocean Night" , "base" : "dark" , "colors" : { "background" : "16 24 32" , "surface" : "24 34 44" , "on-background" : "232 240 245" , "on-surface" : "232 240 245" , "muted" : "150 170 185" , "primary" : "96 180 240" , "on-primary" : "16 24 32" }, "fonts" : [ { "role" : "sans" , "family" : "My Sans" , "file" : "fonts/MySans.woff2" , "weight" : 400 , "style" : "normal" } ], "backgroundImage" : { "file" : "images/ocean-night.webp" , "opacity" : 0.5 , "blur" : 0 , "fit" : "cover" , "position" : "center" } } 
KeyRules
id1 to 64 of a-z 0-9 . _ -, starting with a letter or digit.
name1 to 64 characters, no control characters.
base"light" or "dark": the built-in palette it starts from. Give at most one file of each base: refern uses the first one of each and shows the one that matches the Light/Dark setting.
colorsToken to "R G B" (three integers 0 to 255, one space apart). Tokens: primary, secondary, accent, neutral, info, success, warning, danger, favourite, rating, focus-ring, drop, drop-fill, background, surface, surface-elevated, surface-raised, border, shadow, on-primary, on-secondary, on-accent, on-neutral, on-background, muted, on-surface, on-danger, on-warning, on-info, on-success. Required: background, surface, on-background, on-surface.
fontsOptional, at most 2, one per role ("sans", "serif"). family: 1 to 64 of letters, digits, spaces, _, -. file: a .ttf, .otf, .woff or .woff2 path from the top of the package. weight 1 to 1000; style "normal" or "italic".
backgroundImageOptional shell frame backdrop (rendered behind docked bars and sidebars; the main content viewport stays opaque surface). file: a relative .png, .jpg, .jpeg, .webp or .avif path inside the package (at most 16 MiB). Optional opacity (0.05 to 1, default 0.45), blur (0 to 64 pixels, default 0), fit ("cover", "contain" or "repeat", default "cover"), and position ("center", "top", "bottom", "left" or "right", default "center").

Contrast: on-background on background and on-surface on surface must reach WCAG AA, 4.5:1 (an error below). muted on both is a warning below 4.5:1. The first-party themes also hold 4.5:1 for on-surface on surface-elevated and surface-raised and for each on-X on X; do the same. Keep theme files at the top of the package so font paths mean the same to refern and to refern-cli.

People choose a theme in Settings > General > Custom Theme.

Packaging: .refernplugin

refern-cli plugin pack <dir> writes <id>-<version>.refernplugin, a ZIP file that holds:

  • manifest.json, and README.md, LICENSE, LICENSE.md or LICENSE.txt when present;
  • every file the manifest (and its theme files' fonts) names;
  • for each named file inside a folder, that whole top-level folder (so dist/ comes with its scripts, styles and images). src/, node_modules/ and other folders the manifest does not name stay out. Names that start with . are skipped.

It refuses links, paths outside the folder, unsafe file names, more than 2,000 files, a file over 64 MiB and a package over 128 MiB. The ZIP is deterministic (sorted entries, fixed time stamps): the same files give the same SHA-256, which the command prints.

People install a package with Install from File... on the Extensions page (themes also from Settings > General > Custom Theme). refern shows what it asks for first. A developer folder (Load Developer Folder...) is loaded in place, and refern serves from it only manifest.json, the files the manifest names and the top-level folders that hold them: never src/, node_modules/ or .env.

refern also keeps a kill list from the extension directory. The app reads the directory index at start and every 24 hours and keeps its last copy when the index cannot be reached. A blocked id, version or package SHA-256 does not install, and an installed one is turned off at that read.

Quickstart

Build, load and change your first refern extension in about five minutes with a developer folder, then pack it to share. Includes steps for AI coding agents.

SDK and CLI reference

Copy-pasteable reference for @refern/plugin-sdk, its UI controls, the format decoder ABI, @refern/sdk (the Local API client) and @refern/cli.

On this page

A complete exampleTop-level keysPackage pathsPermissionsContribution pointscommands (at most 64)menuspanels (at most 16)overlays (at most 4)importSources (at most 4)formats (at most 8)settings (at most 64)when expressionsThemesPackaging: .refernplugin