# atomd plugin reference (API 1.31) ## Host calls and posts ### atomd.note.read Reads the open note (API 1.26). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: void Result: Note | null ``` ### atomd.note.applyEdits Edits the open note (undoable) (API 1.0). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; edits: Edit[] } Result: null ``` ### atomd.ui.render Shows its views (API 1.0). Use call or post. Grant via contributes.views, a spec settings view, or capabilities.host. ```ts Data: { view?: string; leaf?: string; content: unknown } Result: null ``` ### atomd.ui.notify Shows notices (API 1.0). Use call or post. Grant via name or matching pattern in capabilities.host. ```ts Data: { message: string } Result: null ``` ### atomd.vault.list Lists your notes (API 1.1). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { folder?: string } Result: NoteInfo[] ``` ### atomd.vault.read Reads any note (API 1.26). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string } Result: NoteWithHash ``` ### atomd.vault.create Creates notes (API 1.1). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; markdown?: string } Result: { path: string } ``` ### atomd.vault.modify Edits any note (API 1.26). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; ifHash?: string } & ({ text: string; edits?: never } | { edits: Edit[]; text?: never }) Result: { hash: string } ``` ### atomd.vault.rename Renames files and folders (API 1.26). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { from: string; to: string } Result: { path: string; updated: string[] | number } ``` ### atomd.metadata.get Reads note properties, links and tags (API 1.1). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string } Result: Metadata ``` ### atomd.metadata.backlinks Finds notes that link to a note (API 1.1). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string } Result: NoteRef[] ``` ### atomd.editor.insert Inserts text at the cursor (API 1.1). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; text: string } Result: null ``` ### atomd.workspace.open Opens notes (API 1.1). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; line?: number; heading?: string } Result: null ``` ### atomd.settings.get Reads its settings (API 1.1). Use call. Grant via contributes.settings or capabilities.host. ```ts Data: void Result: Record ``` ### atomd.settings.set Changes its settings (API 1.1). Use call. Grant via contributes.settings or capabilities.host. ```ts Data: { key: string; value: unknown } Result: null ``` ### atomd.ui.prompt Asks you for text (API 1.1). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { title: string; placeholder?: string; value?: string; multiline?: boolean; confirmLabel?: string } Result: string | null ``` ### atomd.ui.confirm Asks you to confirm (API 1.1). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { title: string; message?: string; confirmLabel?: string; danger?: boolean } Result: boolean ``` ### atomd.ui.pick Shows a list to pick from (API 1.1). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { title?: string; placeholder?: string; items: PickItem[] } Result: string | null ``` ### atomd.ui.status Shows a status bar item (API 1.1). Use post. Grant via name or matching pattern in capabilities.host. ```ts Data: { id?: string; text?: string | null; tooltip?: string; icon?: string } Result: none ``` ### atomd.vault.delete Deletes notes (API 1.2). Use call. Grant via exact name in capabilities.host. ```ts Data: { path: string } Result: null ``` ### atomd.editor.replaceSelection Replaces the selected text (API 1.2). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; text: string } Result: null ``` ### atomd.ui.block Draws code blocks and file embeds in notes (API 1.2). Use post. Grant via contributes.embeds or capabilities.host. ```ts Data: { key: string; body: unknown[] } Result: none ``` ### atomd.ui.toolbar Updates its toolbar buttons (API 1.3). Use post. Grant via contributes.toolbarItems or capabilities.host. ```ts Data: { item: string; icon?: string; title?: string; active?: boolean; disabled?: boolean; hidden?: boolean; open?: boolean } Result: none ``` ### atomd.editor.selection Reads the selection (API 1.3). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string } Result: Selection ``` ### atomd.editor.exec Runs editor commands (API 1.3). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; command: string; args?: unknown } Result: boolean ``` ### atomd.editor.replaceRange Replaces text in the open note (API 1.3). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; from: number; to: number; text: string } Result: null ``` ### atomd.workspace.openView Opens its views in tabs (API 1.5). Use call. Grant via contributes.views or capabilities.host. ```ts Data: { view: string; state?: unknown; focus?: boolean; placement?: "tab" | "split" | "left" | "right" | "bottom" } Result: { leaf: string } ``` ### atomd.workspace.closeView Closes its tabs (API 1.5). Use call. Grant via contributes.views or capabilities.host. ```ts Data: { leaf: string } Result: null ``` ### atomd.workspace.leaves Lists its tabs (API 1.5). Use call. Grant via contributes.views or capabilities.host. ```ts Data: void Result: Leaf[] ``` ### atomd.panel.post Talks between its panels and itself (API 1.11). Use call or post. Grant via a declared TSX panel or capabilities.host. ```ts Data: { data: unknown; view?: string; leaf?: string } Result: null ``` ### atomd.view.setState Keeps its tabs' state (API 1.5). Use call or post. Grant via contributes.views or capabilities.host. ```ts Data: { leaf: string; state: unknown } Result: null ``` ### atomd.view.setTitle Names its tabs (API 1.5). Use call. Grant via contributes.views or capabilities.host. ```ts Data: { leaf: string; title?: string; icon?: string } Result: null ``` ### atomd.editor.setSelection Moves the cursor (API 1.6). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; from: number; to?: number; scroll?: boolean; focus?: boolean } Result: { from: number; to: number } ``` ### atomd.suggest.items Suggests as you type (API 1.6). Use call or post. Grant via contributes.suggest or capabilities.host. ```ts Data: { seq: number; items: SuggestItem[] } Result: null ``` ### atomd.metadata.graph Reads the vault's link graph (API 1.7). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { after?: string; limit?: number } Result: GraphPage ``` ### atomd.metadata.resolve Finds where links lead (API 1.7). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { from: string; links: string[] } Result: { links: ResolvedLink[]; ready: boolean } ``` ### atomd.context.set Shows its commands only where they apply (API 1.9). Use call. Grant via contributes.commands or capabilities.host. ```ts Data: { key: string; value: unknown } Result: null ``` ### atomd.vault.readBinary Reads any file (API 1.9). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; encoding?: "base64" | "utf8" } Result: { path: string; size: number; data?: string; text?: string } ``` ### atomd.vault.writeBinary Writes files other than notes (API 1.9). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; data?: string; text?: string; overwrite?: boolean } Result: { path: string; size: number } ``` ### atomd.vault.stat Reads file sizes and dates (API 1.9). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string } Result: FileStat | null ``` ### atomd.vault.files Lists all files (API 1.9). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { folder?: string; extensions?: string[]; after?: string; limit?: number } Result: FilesPage ``` ### atomd.workspace.get Sees your tabs and splits (API 1.15). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: void Result: WorkspaceState ``` ### atomd.workspace.apply Can rearrange and close your tabs (API 1.15). Use call. Grant via exact name in capabilities.host. ```ts Data: { rev: number; ops: WorkspaceOp[] } Result: { rev: number; leaves: string[] } ``` ### atomd.workspace.decorate Marks your tabs (API 1.15). Use post. Grant via name or matching pattern in capabilities.host. ```ts Data: { leaf: string; badge?: string; color?: "primary" | "destructive" | "success" | "link" | "marker" | "muted-foreground"; icon?: string; tooltip?: string } Result: none ``` ### atomd.editor.textblocks Reads your open notes (API 1.16). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string } Result: { version: number; blocks: { from: number; type: string; text: string }[] } ``` ### atomd.editor.decorate Marks text in your open notes (API 1.16). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; set?: string; version: number; marks: EditorMark[] } Result: null ``` ### atomd.metadata.tags Counts the vault's tags (API 1.17). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { prefix?: string } | void Result: { tag: string; count: number }[] ``` ### atomd.metadata.setFrontmatter Changes note properties (API 1.17). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; set?: Record; remove?: string[] } Result: null ``` ### atomd.ui.modal Shows dialogs of its own (API 1.18). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { id: string; title: string; body?: unknown[]; width?: number; buttons?: { id: string; label: string; variant?: "primary" | "danger" }[] } Result: { button: string; values: Record } | null ``` ### atomd.ui.setMenu Fills its submenus (API 1.18). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { submenu: string; items: MenuItem[] | null } Result: null ``` ### atomd.ui.closeModal Closes its dialogs (API 1.18). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { id: string; button?: string } Result: null ``` ### atomd.metadata.query Reads note properties, links and tags (API 1.20). Use call. Grant via atomd.metadata.get. ```ts Data: MetadataQuery Result: { rows: (QueryRow & Task)[]; total: number; ready: boolean } ``` ### atomd.metadata.status Reads note properties, links and tags (API 1.20). Use call. Grant via atomd.metadata.get. ```ts Data: void Result: { ready: boolean; notes: number } ``` ### atomd.storage.get Keeps data of its own (API 1.21). Use call. Grant via implicit for every plugin. ```ts Data: { key: string; scope?: StorageScope } Result: unknown ``` ### atomd.storage.set Keeps data of its own (API 1.21). Use call. Grant via implicit for every plugin. ```ts Data: { key: string; value: unknown; scope?: StorageScope } Result: null ``` ### atomd.storage.delete Keeps data of its own (API 1.21). Use call. Grant via implicit for every plugin. ```ts Data: { key: string; scope?: StorageScope } Result: null ``` ### atomd.storage.list Keeps data of its own (API 1.21). Use call. Grant via implicit for every plugin. ```ts Data: { prefix?: string; after?: string; limit?: number; values?: boolean; scope?: StorageScope } Result: { entries: { key: string; value?: unknown }[]; next: string | null } ``` ### atomd.storage.batch Keeps data of its own (API 1.21). Use call. Grant via implicit for every plugin. ```ts Data: { ops: ({ op: "set"; key: string; value: unknown } | { op: "delete"; key: string })[]; scope?: StorageScope } Result: null ``` ### atomd.storage.usage Keeps data of its own (API 1.21). Use call. Grant via implicit for every plugin. ```ts Data: { scope?: StorageScope } Result: { bytes: number; limit: number } ``` ### atomd.plugins.call Calls other plugins (API 1.22). Use call. Grant via manifest plugins. ```ts Data: { plugin: string; method: string; args?: unknown; timeout?: number } Result: unknown ``` ### atomd.plugins.reply Answers other plugins (API 1.22). Use call or post. Grant via manifest contributes.api. ```ts Data: { id: number; result?: unknown; error?: string | null } Result: null ``` ### atomd.plugins.emit Tells other plugins of its events (API 1.22). Use call. Grant via manifest contributes.events. ```ts Data: { topic: string; data?: unknown } Result: { heard: number } ``` ### atomd.plugins.list Calls other plugins (API 1.22). Use call. Grant via manifest plugins. ```ts Data: void Result: PluginInfo[] ``` ### atomd.app.openUrl Opens links in your browser (API 1.23). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { url: string } Result: null ``` ### atomd.vault.createFolder Creates folders (API 1.23). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string } Result: { path: string } ``` ### atomd.vault.copy Copies files (API 1.23). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { from: string; to: string } Result: { path: string; size: number } ``` ### atomd.ui.decorateFiles Marks files in the sidebar (API 1.23). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { set?: string; files: Record | null } Result: null ``` ### atomd.editor.transaction Edits the open note (API 1.24). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { path: string; version?: number; changes: { from: number; to?: number; text?: string }[]; selection?: { from: number; to?: number } } Result: { version: number } ``` ### atomd.editor.paste Takes what you paste into notes (API 1.24). Use call. Grant via exact name in capabilities.host. ```ts Data: { seq: number; text?: string | null; handled?: boolean } Result: null ``` ### atomd.link.preview Previews links (API 1.24). Use call. Grant via contributes.linkPreview or capabilities.host. ```ts Data: { seq: number; title?: string | null; body: unknown[] | null } Result: null ``` ### atomd.editor.willSave Edits notes as you save them (API 1.24). Use call. Grant via contributes.willSave or capabilities.host. ```ts Data: { seq: number } Result: null ``` ### atomd.metadata.setTask Edits a task in a note (API 1.28). Use call. Grant via exact name in capabilities.host. ```ts Data: SetTask Result: null ``` ### atomd.commands.list Sees atomd's and other plugins' commands (API 1.29). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: void Result: CommandInfo[] ``` ### atomd.commands.run Runs atomd's and other plugins' commands (API 1.29). Use call. Grant via exact name in capabilities.host. ```ts Data: { id: string } Result: boolean ``` ### atomd.attachments.save Adds attachments to notes (API 1.9). Use call. Grant via name or matching pattern in capabilities.host. ```ts Data: { note: string; name: string; data: string; mime?: string } Result: { path: string; link: string; markdown: string } ``` ## Events Use host.on(name, listener). The final column describes when atomd sends the event and any required grant. | Name | Data | Since | Delivery | | --- | --- | --- | --- | | `atomd.note.changed` | `{note: {path, title} \| null}` | 1.0 | at start and when the open note changes, if the plugin may call `atomd.note.read` | | `atomd.note.edited` | `{note: {path, title}}` | 1.1 | the open note's Markdown changed in the editor (typing, undo, a plugin's edit), 500 ms after the changes stop, if the plugin may call `atomd.note.read`. Not for a note switch. | | `atomd.view.event` | `{view, id, action: "press" \| "submit" \| "change", value}` | 1.0 | the user used a control of its view; pressing one of its status bar items sends `{view: "status", id, action: "press", value: null}`, `id` the item's (`"status"` for the item without one) | | `atomd.command` | `{id, context: {path, paths?, fileCount?, selection?, menu?, leaf?, key?, editor?}}` | 1.0 | the user ran one of its commands. `path` is the open note (`null` when none) from quick open or a hotkey, the menu's note or folder from a single-row menu; `selection` is the selected text, from the editor's menu when there is one. From a menu (API 1.18), `menu` is `editor`, `file` or `tab`, and a tab's menu gives its `leaf` (`path` only for a note's tab). A `files` menu (API 1.26) sets `menu: "files"`, `path: null`, `paths` to the selected vault paths, and `fileCount` to their count. From an `editorKey` (API 1.24), `key` is the key as the manifest writes it and `editor` `{from, to, version}` the selection then. | | `atomd.editor.paste` | `{seq, kind, path, text, from, to, version}` | 1.24 | a paste (`kind` `paste`) or a drop of text (`drop`) into the open note it took, held until it answers (API 1.24; below, Pastes and saves) | | `atomd.editor.willSave` | `{seq, path, version}` | 1.24 | Save (the command, ⌘S) of the open note, if it declared `contributes.willSave`; the note is saved once it answers (API 1.24; below, Pastes and saves) | | `atomd.link.preview` | `{seq, href, path}` | 1.24 | the link card shows `href` (of note `path`), which its `contributes.linkPreview` matches (API 1.24; below, Link previews) | | `atomd.menu.select` | `{submenu, id, context}` | 1.18 | the user chose an item it set in its submenu with `atomd.ui.setMenu` (API 1.18); `context` as a menu command's | | `atomd.settings.changed` | `{key, value}` | 1.1 | the user changed a declarative setting, or a synced setting changed. The background and mounted panels hear it. | | `atomd.settings.opened` | `{}` | 1.27 | its spec settings page opened (API 1.27) | | `atomd.settings.closed` | `{}` | 1.27 | its spec settings page closed (API 1.27) | | `atomd.vault.changed` | `{kind: "created" \| "modified" \| "deleted" \| "renamed", path, from?}` | 1.2 | a note (`.md`, outside hidden folders) changed on disk (below), if the plugin may call `atomd.vault.list`. `from`: a rename's old path. | | `atomd.metadata.changed` | `{changed: [path], removed: [path], renamed: [{from, to}], all}` | 1.20 | the vault index wrote a batch that changed notes (above, Querying notes), if the plugin may call `atomd.metadata.get` (API 1.20). One event per batch, never one per note | | `atomd.metadata.resolved` | `{}` | 1.20 | the first index is complete, or files came or went so links may lead elsewhere, if the plugin may call `atomd.metadata.get` (API 1.20) | | `atomd.storage.changed` | `{scope: "vault", keys: [string]}` | 1.21 | a sync round changed these keys of its `vault` data (above, Plugin data) (API 1.21) | | `atomd.plugins.called` | `{id, caller, method, args}` | 1.22 | another plugin called one of its methods (below, Plugins calling plugins); answer with `atomd.plugins.reply` (API 1.22) | | `atomd.plugins.event` | `{plugin, topic, data}` | 1.22 | a plugin it hears told one of the topics it listens to (API 1.22) | | `atomd.app.changed` | `{locale, theme: {mode, id}}` | 1.23 | the app's language or look changed (API 1.23); every running plugin hears it, including mounted panels since API 1.31 | | `atomd.vault.filesChanged` | `{changes: [{kind, path, from?, note, folder}], all}` | 1.23 | files or folders (any kind, outside hidden folders) changed on disk, if the plugin may call `atomd.vault.files` (API 1.23). One event per look at the vault, never one per file; a move is `renamed` only when it is certain (one file or folder with that identity), else a deletion and a creation; `folder` marks a folder's own change (a folder moved is renamed, and so is each file in it). Over 10,000 changes: `{changes: [], all: true}`, list again what matters | | `atomd.editor.selectionChanged` | `{path, from, to, empty}` | 1.23 | the selection moved in the open note and rested 100 ms, if the plugin may call `atomd.editor.selection` (API 1.23). Positions as `editor.selection`'s | | `atomd.codeblock.render` | `{key, language, source, path}` | 1.2 | a note shows a code block of a language it draws (below, Code blocks), if it may call `atomd.ui.block` | | `atomd.embed.render` | `{key, path, subpath, note}` | 1.27 | an editor shows an embed of a file type it draws (API 1.27, below, Embeds) | | `atomd.toolbar.open` | `{item, context}` | 1.3 | the user opened its `popover` item (below, Toolbars) | | `atomd.toolbar.close` | `{item}` | 1.3 | its popover closed (a press outside, the selection went, another opened) | | `atomd.panel.message` | `{view, leaf, data}` or `{data}` | 1.11 | to the background or a panel, respectively, from `atomd.panel.post` (API 1.11) | | `atomd.suggest.query` | `{suggest, query, seq, path}` | 1.6 | a query for its declared suggestion provider (API 1.6) | | `atomd.suggest.select` | `{suggest, query, item, label, path}` | 1.6 | the user picked one of its suggestions (API 1.6) | | `atomd.workspace.changed` | `{rev, reason, opened, closed}` | 1.15 | the tabs or splits changed, if it may call `atomd.workspace.get` (API 1.15). `reason`: `close`, `open`, `focus`, `layout` (moved, resized, a dock opened or closed) or `update` (a title, a tab shown); `opened`, `closed`: leaf ids. Several changes in one turn come as one. Read `atomd.workspace.get` for the rest | | `atomd.workspace.leafActive` | `{leaf, previous}` | 1.15 | after `changed`, when another tab took the focus (Obsidian's `active-leaf-change`) | | `atomd.workspace.dock` | `{placement, open}` | 1.15 | after `changed`, when a dock (`left`, `right`, `bottom`) opened or closed | | `atomd.uri.opened` | `{action, query, url}` | 1.25 | an external link addressed to this plugin (API 1.25) | | `atomd.view.open` | `{leaf, view, state}` | 1.5 | one of its tabs needs drawing: it opened (by the plugin, the ribbon, ⌘⇧T, or the workspace read at launch), or the plugin (re)started with the tab open | | `atomd.view.close` | `{leaf}` | 1.5 | the tab closed: forget it | | `atomd.view.renamed` | `{leaf, path, from}` | 1.19 | the file a tab of an `extensions` view shows moved from `from` to `path` (it, or its folder, was renamed); its `state.path` is `path` now (API 1.19) | ## Shared TypeScript types ```ts // The host API of atomd's plugin API 1, made from atomd's own table: // do not edit (atomd's `the_template_types_match_the_table` test // rewrites it with ATOMD_BLESS=1). import type { IconName } from "./atomd-icons"; export type { IconName } from "./atomd-icons"; export type HostParams = { api: number; /** The host's plugin API level as MAJOR.MINOR. * @since API 1.30 */ apiVersion?: string; /** Shared plugin translations from packaged i18n/.json files (API 1.31). */ i18n?: Record>; /** The app language when the engine starts (API 1.23). */ locale?: string; pluginId: string; vault: string; }; export type NoteRef = { path: string; title: string }; export type NoteWithHash = NoteRef & { markdown: string; hash: string }; export type Note = NoteWithHash & { selection: string | null }; export type NoteInfo = NoteRef & { size: number; mtime: number }; export type Edit = { find: string; replace: string }; /** 0-based; `col` and `offset` count UTF-16 units, as JS strings do. * @since API 1.17 */ export type Loc = { line: number; col: number; offset: number }; export type Pos = { start: Loc; end: Loc }; export type Link = { target: string; text: string | null; subpath?: string; line: number; original: string; position: Pos }; export type Metadata = { /** The YAML as typed JSON (`{}` when there is none); null when it doesn't parse. */ frontmatter: Record | null; /** Why the front matter didn't parse; only then. */ frontmatterError?: string; /** Where the front matter is, `---` lines included. * @since API 1.17 */ frontmatterPosition: Pos | null; headings: { level: number; text: string; line: number; position: Pos }[]; links: Link[]; embeds: Link[]; blocks: { id: string; line: number; position: Pos }[]; tags: string[]; /** Each `#tag` in the text. * @since API 1.17 */ inlineTags: { tag: string; position: Pos }[]; tasks: { text: string; done: boolean; line: number; position: Pos }[]; /** The top-level blocks. * @since API 1.17 */ sections: { type: "yaml" | "heading" | "paragraph" | "list" | "code" | "blockquote" | "callout" | "table" | "thematicBreak" | "math" | "html" | "footnoteDefinition" | "definition" | "other"; position: Pos }[]; /** Every list item: `parent` the line of the item it is under, or minus its list's first line; `task` the character in its `[ ]`. * @since API 1.17 */ listItems: { parent: number; task?: string; position: Pos }[]; }; /** An item a plugin sets in one of its submenus. * @since API 1.18 */ export type MenuItem = { id: string; title: string; icon?: string; checked?: boolean; disabled?: boolean }; export type PickItem = { id: string; label: string; detail?: string; icon?: IconName }; export type Selection = { path: string; from: number; to: number; empty: boolean; text: string; markdown: string; marks: string[]; block: string; inTable: boolean; cells: boolean; size: number; /** The note's version: its edits since it opened, for `editor.decorate`. * @since API 1.16 */ version: number; }; export type Leaf = { leaf: string; view: string; title: string; visible: boolean; focused: boolean }; export type SuggestItem = { label: string; detail?: string; icon?: string; insert?: string; id?: string }; export type GraphPage = { edges: { from: string; to: string; count: number }[]; unresolved: { from: string; name: string; count: number }[]; next: string | null; ready: boolean; }; export type ResolvedLink = { path: string | null; subpath?: string; line?: number }; export type FileStat = { path: string; isFile: boolean; isFolder: boolean; size: number; mtime: number; ctime: number }; export type WorkspaceLeaf = { view: string; title: string | null; pinned: boolean; fixed: boolean; shown: boolean; path?: string }; export type WorkspaceState = { rev: number; /** NSH's `DockAreaState`: the center and the docks, each tab by its leaf id. */ layout: unknown; leaves: Record; focus: string | null; lastNote: string | null; presentation: string; }; /** A theme color a mark may use. */ export type MarkColor = "primary" | "destructive" | "success" | "link" | "marker" | "muted-foreground"; /** A mark over `from`..`to`, or (`line`) on the line holding `from`. */ export type EditorMark = | { from: number; to: number; line?: false; style: { color?: MarkColor; background?: MarkColor; underline?: "solid" | "wavy" | "dotted" | "dashed"; underlineColor?: MarkColor; strike?: boolean; bold?: boolean; italic?: boolean; faded?: boolean } } | { from: number; line: true; style: { background?: MarkColor; border?: MarkColor; faded?: boolean } }; /** Where `addPanel` and `movePanel` put a leaf: beside one (in its group at `index`, or split off on `side`), or in a dock. */ export type WorkspaceTarget = { beside: string; side?: "left" | "right" | "top" | "bottom"; index?: number } | { dock: "left" | "right" | "bottom" }; export type WorkspaceOp = | { op: "addPanel"; view: string; state?: unknown; target?: WorkspaceTarget; focus?: boolean } | { op: "closePanel"; leaf: string } | { op: "movePanel"; leaf: string; target: WorkspaceTarget; focus?: boolean } | { op: "selectPanel"; leaf: string } | { op: "setPinned"; leaf: string; pinned: boolean } | { op: "setDockOpen"; placement: "left" | "right" | "bottom"; open: boolean } | { op: "setDockSize"; placement: "left" | "right" | "bottom"; size: number } | { op: "setLayout"; layout: unknown; leaves?: Record }; /** Where `storage` keeps a plugin's data: `device` (this * device only, the default) or `vault` (syncs with the vault). * @since API 1.21 */ export type StorageScope = "device" | "vault"; /** A command `commands.run` can run: atomd's own * (`atomd:new-note`) or an on plugin's (`:`). * `available`: its `when` holds now. * @since API 1.29 */ export type CommandInfo = { id: string; title: string; plugin: string | null; available: boolean }; /** The declared plugin and the methods and topics it offers. * @since API 1.22 */ export type PluginInfo = { id: string; installed: boolean; on: boolean; name?: string; version?: string; methods?: string[]; events?: string[] }; /** A condition of `metadata.query`. A `tag` counts the tags * under it (`a` counts `a/b`); a `folder` its subfolders. * @since API 1.20 */ export type QueryCondition = | { and: QueryCondition[] } | { or: QueryCondition[] } | { not: QueryCondition } | { tag: string } | ("noteTag" extends F ? { noteTag: string } : never) | { folder: string } | { field: F; op?: "eq" | "ne" | "in" | "contains" | "exists" | "lt" | "lte" | "gt" | "gte" | "startsWith"; value?: unknown; }; export type NoteQueryField = "path" | "name" | "folder" | "mtime" | "size" | "tag" | `frontmatter.${string}`; export type TaskQueryField = "path" | "name" | "folder" | "line" | "text" | "status" | "completed" | "checked" | "depth" | "parent" | "due" | "scheduled" | "start" | "done" | "created" | "cancelled" | "priority" | "recurrence" | "tag" | "noteTag" | `fields.${string}` | `note.frontmatter.${string}`; export type QuerySort = F | { field: F; desc?: boolean; order?: "asc" | "desc" }; export type NotesQuery = { rows?: "notes"; where?: QueryCondition; select?: (NoteQueryField | "tags" | "frontmatter")[]; sort?: QuerySort | QuerySort[]; limit?: number; offset?: number; }; export type TasksQuery = { rows: "tasks"; where?: QueryCondition; select?: (TaskQueryField | "tags" | "noteTags" | "fields" | "note.frontmatter")[]; sort?: QuerySort | QuerySort[]; limit?: number; offset?: number; }; export type MetadataQuery = NotesQuery | TasksQuery; /** A task from the vault index. Only path is present in every projection. * @since API 1.28 */ export type Task = { path: string; name?: string; folder?: string; line?: number; text?: string; status?: string; completed?: boolean; checked?: boolean; depth?: number; parent?: number | null; due?: string | null; scheduled?: string | null; start?: string | null; done?: string | null; created?: string | null; cancelled?: string | null; priority?: "highest" | "high" | "medium" | "low" | "lowest" | "none"; recurrence?: string | null; tags?: string[]; noteTags?: string[]; fields?: Record; note?: { frontmatter: Record }; }; export type SetTask = { path: string; line: number; status?: string; text?: string; expect?: string; doneDate?: boolean; }; export type QueryRow = { path: string; name?: string; folder?: string; mtime?: number; size?: number; tags?: string[]; frontmatter?: Record; }; export type FilesPage = { files: { path: string; size: number; mtime: number; note: boolean }[]; next: string | null; ready: boolean; }; /** Calls (`host.call(name, data)`), answered. */ export interface HostCalls { /** Reads the open note. * @since API 1.26 */ "atomd.note.read": { data: void; result: Note | null }; /** Edits the open note (undoable). * @since API 1.0 */ "atomd.note.applyEdits": { data: { path: string; edits: Edit[] }; result: null }; /** Shows its views. * @since API 1.0 */ "atomd.ui.render": { data: { view?: string; leaf?: string; content: unknown }; result: null }; /** Shows notices. * @since API 1.0 */ "atomd.ui.notify": { data: { message: string }; result: null }; /** Lists your notes. * @since API 1.1 */ "atomd.vault.list": { data: { folder?: string }; result: NoteInfo[] }; /** Reads any note. * @since API 1.26 */ "atomd.vault.read": { data: { path: string }; result: NoteWithHash }; /** Creates notes. * @since API 1.1 */ "atomd.vault.create": { data: { path: string; markdown?: string }; result: { path: string } }; /** Edits any note. * @since API 1.26 */ "atomd.vault.modify": { data: { path: string; ifHash?: string } & ({ text: string; edits?: never } | { edits: Edit[]; text?: never }); result: { hash: string } }; /** Renames files and folders. * @since API 1.26 */ "atomd.vault.rename": { data: { from: string; to: string }; result: { path: string; updated: string[] | number } }; /** Reads note properties, links and tags. * @since API 1.1 */ "atomd.metadata.get": { data: { path: string }; result: Metadata }; /** Finds notes that link to a note. * @since API 1.1 */ "atomd.metadata.backlinks": { data: { path: string }; result: NoteRef[] }; /** Inserts text at the cursor. * @since API 1.1 */ "atomd.editor.insert": { data: { path: string; text: string }; result: null }; /** Opens notes. * @since API 1.1 */ "atomd.workspace.open": { data: { path: string; line?: number; heading?: string }; result: null }; /** Reads its settings. * @since API 1.1 */ "atomd.settings.get": { data: void; result: Record }; /** Changes its settings. * @since API 1.1 */ "atomd.settings.set": { data: { key: string; value: unknown }; result: null }; /** Asks you for text. * @since API 1.1 */ "atomd.ui.prompt": { data: { title: string; placeholder?: string; value?: string; multiline?: boolean; confirmLabel?: string }; result: string | null }; /** Asks you to confirm. * @since API 1.1 */ "atomd.ui.confirm": { data: { title: string; message?: string; confirmLabel?: string; danger?: boolean }; result: boolean }; /** Shows a list to pick from. * @since API 1.1 */ "atomd.ui.pick": { data: { title?: string; placeholder?: string; items: PickItem[] }; result: string | null }; /** Deletes notes. * @since API 1.2 */ "atomd.vault.delete": { data: { path: string }; result: null }; /** Replaces the selected text. * @since API 1.2 */ "atomd.editor.replaceSelection": { data: { path: string; text: string }; result: null }; /** Reads the selection. * @since API 1.3 */ "atomd.editor.selection": { data: { path: string }; result: Selection }; /** Runs editor commands. * @since API 1.3 */ "atomd.editor.exec": { data: { path: string; command: string; args?: unknown }; result: boolean }; /** Replaces text in the open note. * @since API 1.3 */ "atomd.editor.replaceRange": { data: { path: string; from: number; to: number; text: string }; result: null }; /** Opens its views in tabs. * @since API 1.5 */ "atomd.workspace.openView": { data: { view: string; state?: unknown; focus?: boolean; placement?: "tab" | "split" | "left" | "right" | "bottom" }; result: { leaf: string } }; /** Closes its tabs. * @since API 1.5 */ "atomd.workspace.closeView": { data: { leaf: string }; result: null }; /** Lists its tabs. * @since API 1.5 */ "atomd.workspace.leaves": { data: void; result: Leaf[] }; /** Talks between its panels and itself. * @since API 1.11 */ "atomd.panel.post": { data: { data: unknown; view?: string; leaf?: string }; result: null }; /** Keeps its tabs' state. * @since API 1.5 */ "atomd.view.setState": { data: { leaf: string; state: unknown }; result: null }; /** Names its tabs. * @since API 1.5 */ "atomd.view.setTitle": { data: { leaf: string; title?: string; icon?: string }; result: null }; /** Moves the cursor. * @since API 1.6 */ "atomd.editor.setSelection": { data: { path: string; from: number; to?: number; scroll?: boolean; focus?: boolean }; result: { from: number; to: number } }; /** Suggests as you type. * @since API 1.6 */ "atomd.suggest.items": { data: { seq: number; items: SuggestItem[] }; result: null }; /** Reads the vault's link graph. * @since API 1.7 */ "atomd.metadata.graph": { data: { after?: string; limit?: number }; result: GraphPage }; /** Finds where links lead. * @since API 1.7 */ "atomd.metadata.resolve": { data: { from: string; links: string[] }; result: { links: ResolvedLink[]; ready: boolean } }; /** Shows its commands only where they apply. * @since API 1.9 */ "atomd.context.set": { data: { key: string; value: unknown }; result: null }; /** Reads any file. * @since API 1.9 */ "atomd.vault.readBinary": { data: { path: string; encoding?: "base64" | "utf8" }; result: { path: string; size: number; data?: string; text?: string } }; /** Writes files other than notes. * @since API 1.9 */ "atomd.vault.writeBinary": { data: { path: string; data?: string; text?: string; overwrite?: boolean }; result: { path: string; size: number } }; /** Reads file sizes and dates. * @since API 1.9 */ "atomd.vault.stat": { data: { path: string }; result: FileStat | null }; /** Lists all files. * @since API 1.9 */ "atomd.vault.files": { data: { folder?: string; extensions?: string[]; after?: string; limit?: number }; result: FilesPage }; /** Sees your tabs and splits. * @since API 1.15 */ "atomd.workspace.get": { data: void; result: WorkspaceState }; /** Can rearrange and close your tabs. * @since API 1.15 */ "atomd.workspace.apply": { data: { rev: number; ops: WorkspaceOp[] }; result: { rev: number; leaves: string[] } }; /** Reads your open notes. * @since API 1.16 */ "atomd.editor.textblocks": { data: { path: string }; result: { version: number; blocks: { from: number; type: string; text: string }[] } }; /** Marks text in your open notes. * @since API 1.16 */ "atomd.editor.decorate": { data: { path: string; set?: string; version: number; marks: EditorMark[] }; result: null }; /** Counts the vault's tags. * @since API 1.17 */ "atomd.metadata.tags": { data: { prefix?: string } | void; result: { tag: string; count: number }[] }; /** Changes note properties. * @since API 1.17 */ "atomd.metadata.setFrontmatter": { data: { path: string; set?: Record; remove?: string[] }; result: null }; /** Shows dialogs of its own. * @since API 1.18 */ "atomd.ui.modal": { data: { id: string; title: string; body?: unknown[]; width?: number; buttons?: { id: string; label: string; variant?: "primary" | "danger" }[] }; result: { button: string; values: Record } | null }; /** Fills its submenus. * @since API 1.18 */ "atomd.ui.setMenu": { data: { submenu: string; items: MenuItem[] | null }; result: null }; /** Closes its dialogs. * @since API 1.18 */ "atomd.ui.closeModal": { data: { id: string; button?: string }; result: null }; /** Reads note properties, links and tags. * @since API 1.20 */ "atomd.metadata.query": { data: MetadataQuery; result: { rows: (QueryRow & Task)[]; total: number; ready: boolean } }; /** Reads note properties, links and tags. * @since API 1.20 */ "atomd.metadata.status": { data: void; result: { ready: boolean; notes: number } }; /** Keeps data of its own. * @since API 1.21 */ "atomd.storage.get": { data: { key: string; scope?: StorageScope }; result: unknown }; /** Keeps data of its own. * @since API 1.21 */ "atomd.storage.set": { data: { key: string; value: unknown; scope?: StorageScope }; result: null }; /** Keeps data of its own. * @since API 1.21 */ "atomd.storage.delete": { data: { key: string; scope?: StorageScope }; result: null }; /** Keeps data of its own. * @since API 1.21 */ "atomd.storage.list": { data: { prefix?: string; after?: string; limit?: number; values?: boolean; scope?: StorageScope }; result: { entries: { key: string; value?: unknown }[]; next: string | null } }; /** Keeps data of its own. * @since API 1.21 */ "atomd.storage.batch": { data: { ops: ({ op: "set"; key: string; value: unknown } | { op: "delete"; key: string })[]; scope?: StorageScope }; result: null }; /** Keeps data of its own. * @since API 1.21 */ "atomd.storage.usage": { data: { scope?: StorageScope }; result: { bytes: number; limit: number } }; /** Calls other plugins. * @since API 1.22 */ "atomd.plugins.call": { data: { plugin: string; method: string; args?: unknown; timeout?: number }; result: unknown }; /** Answers other plugins. * @since API 1.22 */ "atomd.plugins.reply": { data: { id: number; result?: unknown; error?: string | null }; result: null }; /** Tells other plugins of its events. * @since API 1.22 */ "atomd.plugins.emit": { data: { topic: string; data?: unknown }; result: { heard: number } }; /** Calls other plugins. * @since API 1.22 */ "atomd.plugins.list": { data: void; result: PluginInfo[] }; /** Opens links in your browser. * @since API 1.23 */ "atomd.app.openUrl": { data: { url: string }; result: null }; /** Creates folders. * @since API 1.23 */ "atomd.vault.createFolder": { data: { path: string }; result: { path: string } }; /** Copies files. * @since API 1.23 */ "atomd.vault.copy": { data: { from: string; to: string }; result: { path: string; size: number } }; /** Marks files in the sidebar. * @since API 1.23 */ "atomd.ui.decorateFiles": { data: { set?: string; files: Record | null }; result: null }; /** Edits the open note. * @since API 1.24 */ "atomd.editor.transaction": { data: { path: string; version?: number; changes: { from: number; to?: number; text?: string }[]; selection?: { from: number; to?: number } }; result: { version: number } }; /** Takes what you paste into notes. * @since API 1.24 */ "atomd.editor.paste": { data: { seq: number; text?: string | null; handled?: boolean }; result: null }; /** Previews links. * @since API 1.24 */ "atomd.link.preview": { data: { seq: number; title?: string | null; body: unknown[] | null }; result: null }; /** Edits notes as you save them. * @since API 1.24 */ "atomd.editor.willSave": { data: { seq: number }; result: null }; /** Edits a task in a note. * @since API 1.28 */ "atomd.metadata.setTask": { data: SetTask; result: null }; /** Sees atomd's and other plugins' commands. * @since API 1.29 */ "atomd.commands.list": { data: void; result: CommandInfo[] }; /** Runs atomd's and other plugins' commands. * @since API 1.29 */ "atomd.commands.run": { data: { id: string }; result: boolean }; /** Adds attachments to notes. * @since API 1.9 */ "atomd.attachments.save": { data: { note: string; name: string; data: string; mime?: string }; result: { path: string; link: string; markdown: string } }; } /** Posts (`host.post(name, data)`), without a result. */ export interface HostPosts { /** Shows its views. * @since API 1.0 */ "atomd.ui.render": Pick; /** Shows notices. * @since API 1.0 */ "atomd.ui.notify": Pick; /** Shows a status bar item. * @since API 1.1 */ "atomd.ui.status": { data: { id?: string; text?: string | null; tooltip?: string; icon?: string } }; /** Draws code blocks and file embeds in notes. * @since API 1.2 */ "atomd.ui.block": { data: { key: string; body: unknown[] } }; /** Updates its toolbar buttons. * @since API 1.3 */ "atomd.ui.toolbar": { data: { item: string; icon?: string; title?: string; active?: boolean; disabled?: boolean; hidden?: boolean; open?: boolean } }; /** Talks between its panels and itself. * @since API 1.11 */ "atomd.panel.post": Pick; /** Keeps its tabs' state. * @since API 1.5 */ "atomd.view.setState": Pick; /** Suggests as you type. * @since API 1.6 */ "atomd.suggest.items": Pick; /** Marks your tabs. * @since API 1.15 */ "atomd.workspace.decorate": { data: { leaf: string; badge?: string; color?: "primary" | "destructive" | "success" | "link" | "marker" | "muted-foreground"; icon?: string; tooltip?: string } }; /** Answers other plugins. * @since API 1.22 */ "atomd.plugins.reply": Pick; } ``` ## Manifest schema ```json { "$defs": { "CodeBlockSpec": { "description": "A fenced code block's language a plugin draws (`contributes.codeBlocks`).", "properties": { "language": { "type": "string" } }, "required": [ "language" ], "type": "object" }, "CommandSpec": { "properties": { "editorKey": { "default": null, "description": "A key it takes in the note editor while its `when` holds (`tab`,\n`shift+enter`, `alt+up`; 1.24.0): atomd decides, the plugin hears\nthe command.", "type": [ "string", "null" ] }, "hotkey": { "default": null, "description": "A shortcut (`mod+shift+k`), while the plugin is on.", "type": [ "string", "null" ] }, "id": { "type": "string" }, "title": { "$ref": "#/$defs/LocalizedText" }, "when": { "default": null, "description": "A condition over platform, mobile, menu, noteOpen, notePath, noteName, noteFolder, hasSelection, filePath, fileName, fileExtension, isFolder, fileCount, leafView, editorFocused, blockType, inList, listDepth, inCode, inTable, lineEmpty, atLineStart, atLineEnd, or context.. See Command conditions in the plugin spec.", "examples": [ "noteOpen", "hasSelection && !mobile", "context.ready" ], "maxLength": 500, "type": [ "string", "null" ] } }, "required": [ "id", "title" ], "type": "object" }, "Contributes": { "properties": { "api": { "description": "The methods other plugins may call (1.22.0); calling one starts it.", "items": { "$ref": "#/$defs/Exposed" }, "type": "array" }, "codeBlocks": { "description": "The fenced code blocks it draws, by language.", "items": { "$ref": "#/$defs/CodeBlockSpec" }, "type": "array" }, "commands": { "description": "Commands in quick open.", "items": { "$ref": "#/$defs/CommandSpec" }, "type": "array" }, "editorMarks": { "description": "Text it marks wherever it appears, by pattern (1.16.0, `docs/plugins.md`,\nMarks in the editor), drawn by atomd without the plugin running.", "items": { "$ref": "#/$defs/EditorMarkSpec" }, "type": "array" }, "editorPaste": { "anyOf": [ { "$ref": "#/$defs/PasteSpec" }, { "type": "null" } ], "description": "The pastes (and drops) into notes it takes, by what is pasted\n(1.24.0, `docs/plugins.md`, Pastes and saves)." }, "embeds": { "anyOf": [ { "$ref": "#/$defs/EmbedSpec" }, { "type": "null" } ], "description": "File extensions it draws in notes (1.27.0)." }, "events": { "description": "The topics other plugins may hear (1.22.0).", "items": { "$ref": "#/$defs/Exposed" }, "type": "array" }, "iconPacks": { "default": [], "description": "Its icon packs, which Settings → General offers (1.12.0).", "items": { "$ref": "#/$defs/IconPackSpec" }, "type": "array" }, "linkPreview": { "anyOf": [ { "$ref": "#/$defs/PasteSpec" }, { "type": "null" } ], "description": "The links (by address) whose card it previews (1.24.0)." }, "menus": { "$ref": "#/$defs/Menus", "description": "Its commands in atomd's menus." }, "openPolicy": { "anyOf": [ { "$ref": "#/$defs/OpenPolicy" }, { "type": "null" } ], "description": "Where a click opens a note, and how many tabs a group keeps\n(1.15.0, `docs/workspace.md`, `openPolicy`). It needs\n`atomd.workspace.apply`." }, "ribbon": { "description": "Its buttons in the ribbon, the strip left of the sidebar (1.4.0).", "items": { "$ref": "#/$defs/RibbonSpec" }, "type": "array" }, "settings": { "description": "Its options, in Settings → Plugins.", "items": { "$ref": "#/$defs/SettingSpec" }, "type": "array" }, "settingsView": { "anyOf": [ { "$ref": "#/$defs/SettingsViewSpec" }, { "type": "null" } ], "description": "Its custom page under the options (1.27.0)." }, "sidebar": { "anyOf": [ { "$ref": "#/$defs/Sidebar" }, { "type": "null" } ], "description": "A view in the right sidebar." }, "submenus": { "description": "Its submenus in them (1.18.0).", "items": { "$ref": "#/$defs/SubmenuSpec" }, "type": "array" }, "suggest": { "description": "Its suggestions as the user types after a trigger (1.6.0).", "items": { "$ref": "#/$defs/SuggestSpec" }, "type": "array" }, "themes": { "description": "Its themes, which Settings → General offers.", "items": { "$ref": "#/$defs/ThemeSpec" }, "type": "array" }, "tokens": { "default": null, "description": "A theme file declaring the plugin's own panel tokens.", "type": [ "string", "null" ] }, "toolbarItems": { "description": "Its toolbar items (docs/plugins.md, Toolbars).", "items": { "$ref": "#/$defs/ToolbarItemSpec" }, "type": "array" }, "toolbarLayouts": { "description": "Its toolbar layouts, which Settings → Toolbar offers.", "items": { "$ref": "#/$defs/ToolbarLayoutSpec" }, "type": "array" }, "uri": { "anyOf": [ { "$ref": "#/$defs/UriSpec" }, { "type": "null" } ], "description": "External atomd:// links this plugin receives (1.25.0)." }, "views": { "description": "Its views, which open in tabs (1.5.0, `docs/workspace.md`).", "items": { "$ref": "#/$defs/ViewSpec" }, "type": "array" }, "willSave": { "default": false, "description": "It hears `atomd.editor.willSave` before a note is saved with Save\n(1.24.0).", "type": "boolean" } }, "type": "object" }, "EditorMarkSpec": { "description": "`contributes.editorMarks`: a pattern and how what it matches looks.", "properties": { "flags": { "default": "", "description": "`i`: case-insensitive.", "type": "string" }, "id": { "type": "string" }, "line": { "default": false, "description": "The whole line holding a match, not the match.", "type": "boolean" }, "pattern": { "description": "A regular expression (Rust's `regex`: no look-around, no\nbackreferences, linear time).", "type": "string" }, "style": { "description": "The style, as `atomd.editor.decorate`'s." } }, "required": [ "id", "pattern", "style" ], "type": "object" }, "EmbedSpec": { "properties": { "extensions": { "items": { "type": "string" }, "type": "array" } }, "required": [ "extensions" ], "type": "object" }, "Exposed": { "description": "A method other plugins may call (`contributes.api`), or a topic they\nmay hear (`contributes.events`), and what that takes of them.", "oneOf": [ { "required": [ "method" ] }, { "required": [ "topic" ] } ], "properties": { "callers": { "default": null, "description": "Only these plugins may call (hear) it; any that declares it when\nabsent.", "items": { "type": "string" }, "type": [ "array", "null" ] }, "description": { "default": "", "type": "string" }, "listeners": { "default": null, "description": "Only these plugins may call (hear) it; any that declares it when\nabsent.", "items": { "type": "string" }, "type": [ "array", "null" ] }, "method": { "description": "The method's name (`api`) or the topic (`events`).", "type": "string" }, "requires": { "description": "The host API names its caller (or listener) must have been allowed:\nwhat it does for them, so that no plugin gets through another what\nit was not allowed. It must be said; `[]` for none.", "items": { "type": "string" }, "type": [ "array", "null" ] }, "topic": { "description": "The method's name (`api`) or the topic (`events`).", "type": "string" } }, "type": "object" }, "IconPackSpec": { "description": "An icon pack a plugin gives (`contributes.iconPacks`): a folder of\n`.svg` files, each replacing the atomd icon of that name.", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "path": { "description": "The folder, inside the plugin.", "type": "string" } }, "required": [ "id", "name", "path" ], "type": "object" }, "LocalizedText": { "anyOf": [ { "type": "string" }, { "additionalProperties": { "type": "string" }, "minProperties": 1, "type": "object" } ], "description": "Text, a %key% from i18n/.json, or an object of locale-to-text translations (API 1.31)." }, "MenuEntry": { "anyOf": [ { "type": "string" }, { "properties": { "command": { "type": "string" }, "group": { "default": null, "description": "Entries of another group come after a separator.", "type": [ "string", "null" ] }, "icon": { "default": null, "type": [ "string", "null" ] }, "title": { "anyOf": [ { "$ref": "#/$defs/LocalizedText" }, { "type": "null" } ] } }, "required": [ "command" ], "type": "object" }, { "properties": { "group": { "default": null, "type": [ "string", "null" ] }, "submenu": { "type": "string" }, "title": { "anyOf": [ { "$ref": "#/$defs/LocalizedText" }, { "type": "null" } ] } }, "required": [ "submenu" ], "type": "object" } ], "description": "An entry of a menu: one of its commands (by id, or with an icon and a\ngroup), or one of its submenus." }, "Menus": { "additionalProperties": false, "description": "A plugin's menus: by location (`editor`, `file`, `tab`) or by one of\nits submenus' ids, their entries.", "patternProperties": { "^[a-z0-9-]{1,40}$": { "items": { "$ref": "#/$defs/MenuEntry" }, "type": "array" } }, "properties": { "editor": { "items": { "$ref": "#/$defs/MenuEntry" }, "type": "array" }, "file": { "items": { "$ref": "#/$defs/MenuEntry" }, "type": "array" }, "files": { "items": { "$ref": "#/$defs/MenuEntry" }, "type": "array" }, "tab": { "items": { "$ref": "#/$defs/MenuEntry" }, "type": "array" } }, "type": "object" }, "OpenPolicy": { "description": "`contributes.openPolicy`: rules as data, applied by atomd in Rust, so a\nclick never waits on a plugin.", "properties": { "click": { "anyOf": [ { "enum": [ "here", "newTab", "newTabBackground", "split" ] }, { "type": "null" } ], "default": null, "description": "`here` (the default), `newTab`, `newTabBackground` or `split`.", "type": [ "string", "null" ] }, "closeOldest": { "default": false, "description": "Above `maxTabsPerGroup`, close the tab focused least recently\n(never a pinned one); else the limit is not kept.", "type": "boolean" }, "maxTabsPerGroup": { "default": null, "description": "The most tabs a group of the center keeps when a note opens.", "format": "uint", "minimum": 0, "type": [ "integer", "null" ] } }, "type": "object" }, "PasteSpec": { "description": "`contributes.editorPaste`: which pastes a plugin takes; also\n`contributes.linkPreview`, the links it previews (`drop` unused).", "properties": { "drop": { "default": false, "description": "Text dropped into the note too.", "type": "boolean" }, "flags": { "default": "", "description": "`i`: case-insensitive.", "type": "string" }, "pattern": { "default": null, "description": "A regular expression the pasted text must match somewhere (Rust's\n`regex`); none, every paste.", "type": [ "string", "null" ] } }, "type": "object" }, "RibbonSpec": { "description": "A button in the ribbon (`contributes.ribbon`): pressing it runs one of\nthe plugin's commands, or shows or hides one of its views (atomd does\nthat itself, without the plugin). atomd draws it from the manifest.", "properties": { "command": { "default": null, "description": "The command it runs…", "type": [ "string", "null" ] }, "icon": { "description": "An icon name atomd knows, or an `.svg` file in the package\n(`icons/graph.svg`).", "type": "string" }, "id": { "type": "string" }, "title": { "$ref": "#/$defs/LocalizedText" }, "view": { "default": null, "description": "…or the view it shows and hides: `sidebar`.", "type": [ "string", "null" ] } }, "required": [ "id", "icon", "title" ], "type": "object" }, "RunSpec": { "description": "An editor command and its arguments (Tiptap's catalog).", "properties": { "args": { "default": null }, "command": { "type": "string" } }, "required": [ "command" ], "type": "object" }, "SettingOption": { "properties": { "label": { "$ref": "#/$defs/LocalizedText" }, "value": true }, "required": [ "value", "label" ], "type": "object" }, "SettingSpec": { "description": "One of a plugin's options.", "properties": { "default": { "default": null }, "description": { "anyOf": [ { "$ref": "#/$defs/LocalizedText" }, { "type": "null" } ] }, "key": { "type": "string" }, "options": { "description": "A `select`'s choices.", "items": { "$ref": "#/$defs/SettingOption" }, "type": "array" }, "placeholder": { "anyOf": [ { "$ref": "#/$defs/LocalizedText" }, { "type": "null" } ] }, "scope": { "default": null, "description": "`device` (the default: kept on this device) or `synced` (kept in the\nvault, the same on every device that syncs it). Never `synced` for a\n`secret`.", "type": [ "string", "null" ] }, "title": { "$ref": "#/$defs/LocalizedText" }, "type": { "description": "`string`, `number`, `boolean`, `select` or `secret`.", "enum": [ "string", "number", "boolean", "select", "secret" ], "type": "string" } }, "required": [ "key", "type", "title" ], "type": "object" }, "SettingsViewSpec": { "allOf": [ { "else": { "properties": { "entry": { "type": "null" } } }, "if": { "properties": { "kind": { "const": "app" } }, "required": [ "kind" ] }, "then": { "properties": { "entry": { "pattern": "[.]js$", "type": "string" } }, "required": [ "entry" ] } } ], "properties": { "entry": { "default": null, "type": [ "string", "null" ] }, "kind": { "enum": [ "spec", "app" ], "type": "string" } }, "required": [ "kind" ], "type": "object" }, "Sidebar": { "allOf": [ { "else": { "properties": { "entry": { "type": "null" } } }, "if": { "properties": { "kind": { "const": "app" } }, "required": [ "kind" ] }, "then": { "properties": { "entry": { "pattern": "[.]js$", "type": "string" } }, "required": [ "entry" ] } } ], "properties": { "entry": { "default": null, "description": "A panel's bundle (`kind: \"app\"`).", "type": [ "string", "null" ] }, "icon": { "default": "", "description": "An icon name atomd knows (`sparkles`, `puzzle`…).", "type": "string" }, "kind": { "anyOf": [ { "enum": [ "spec", "app" ] }, { "type": "null" } ], "default": null, "description": "As a view's: `spec` (the default) or `app`, a panel.", "type": [ "string", "null" ] }, "title": { "$ref": "#/$defs/LocalizedText" } }, "required": [ "title" ], "type": "object" }, "SubmenuSpec": { "description": "A submenu a plugin's menus may hold: a row opening its own entries\n(`menus.`) and the items it sets with `atomd.ui.setMenu`.", "properties": { "icon": { "default": null, "type": [ "string", "null" ] }, "id": { "type": "string" }, "title": { "$ref": "#/$defs/LocalizedText" } }, "required": [ "id", "title" ], "type": "object" }, "SuggestSpec": { "description": "A list the editor shows as the user types after `trigger`\n(`contributes.suggest`), filled by the plugin (`atomd.suggest.items`).", "properties": { "id": { "type": "string" }, "spaces": { "default": false, "description": "The query may hold spaces.", "type": "boolean" }, "startOfLine": { "default": false, "description": "The trigger must start the line.", "type": "boolean" }, "trigger": { "description": "1 to 3 characters, no letters, digits or spaces (```, `::`).", "type": "string" } }, "required": [ "id", "trigger" ], "type": "object" }, "ThemeSpec": { "description": "A theme a plugin gives (`contributes.themes`): a theme file, shadcn's\n`cssVars` over atomd's (`themes/default.json`), at `path` in the plugin.", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "path": { "type": "string" } }, "required": [ "id", "name", "path" ], "type": "object" }, "ToolbarItemSpec": { "description": "A toolbar item a plugin gives (`contributes.toolbarItems`).", "properties": { "active": { "default": null, "description": "When it shows on (a condition).", "type": [ "string", "null" ] }, "command": { "default": null, "description": "One of its commands, sent `atomd.command` when pressed.", "type": [ "string", "null" ] }, "icon": { "default": "", "description": "An icon name atomd knows.", "type": "string" }, "id": { "description": "Lowercase letters, digits and `-`; `.` in layouts.", "type": "string" }, "items": { "default": [], "description": "A menu's items: its own item ids, `atomd.*`, `.`, `|`.", "items": { "type": "string" }, "type": "array" }, "run": { "anyOf": [ { "$ref": "#/$defs/RunSpec" }, { "type": "null" } ], "description": "Or an editor command atomd runs itself (`toggleMark`…)." }, "surfaces": { "default": null, "description": "The surfaces it goes to by itself (default `[\"selection\"]`).", "items": { "type": "string" }, "type": [ "array", "null" ] }, "title": { "$ref": "#/$defs/LocalizedText" }, "type": { "default": "button", "description": "`button` (the default), `toggle` (a button that shows on), `menu`\n(its `items` in a dropdown) or `popover` (a view of the plugin's).", "enum": [ "button", "toggle", "menu", "popover" ], "type": "string" }, "when": { "default": null, "description": "When it shows (a condition, `toolbar.rs`).", "type": [ "string", "null" ] }, "width": { "default": null, "description": "A popover's width (160 to 480, default 300).", "format": "float", "type": [ "number", "null" ] } }, "required": [ "id", "title" ], "type": "object" }, "ToolbarLayoutSpec": { "description": "A toolbar layout a plugin gives (`contributes.toolbarLayouts`): item\nids for each surface it sets.", "properties": { "id": { "type": "string" }, "layouts": { "additionalProperties": { "items": { "type": "string" }, "type": "array" }, "type": "object" }, "name": { "$ref": "#/$defs/LocalizedText" } }, "required": [ "id", "name", "layouts" ], "type": "object" }, "UriSpec": { "additionalProperties": false, "description": "`contributes.uri`: the actions addressed to this plugin by external links.", "properties": { "actions": { "items": { "type": "string" }, "type": "array" } }, "required": [ "actions" ], "type": "object" }, "Uses": { "description": "What a plugin uses of another (`plugins` in its manifest).", "properties": { "call": { "default": [], "description": "The methods it calls (the other's `contributes.api`).", "items": { "type": "string" }, "type": "array" }, "listen": { "default": [], "description": "The topics it hears (the other's `contributes.events`).", "items": { "type": "string" }, "type": "array" } }, "type": "object" }, "ViewSpec": { "allOf": [ { "else": { "properties": { "entry": { "type": "null" } } }, "if": { "properties": { "kind": { "const": "app" } }, "required": [ "kind" ] }, "then": { "properties": { "entry": { "pattern": "[.]js$", "type": "string" } }, "required": [ "entry" ] } } ], "description": "A view a plugin draws in a tab (`contributes.views`): views as data,\nin the sidebar's vocabulary. Its tabs are `plugin:/`.", "properties": { "entry": { "default": null, "description": "A panel's bundle in the package, as `nsh build` wrote it\n(`panels/board.js`).", "type": [ "string", "null" ] }, "extensions": { "default": [], "description": "Files with these extensions (lowercase, without `.`) open in this\nview, a tab each, its state `{path}` (1.19.0).", "items": { "type": "string" }, "type": "array" }, "icon": { "default": "", "description": "An icon name atomd knows.", "type": "string" }, "id": { "type": "string" }, "kind": { "anyOf": [ { "enum": [ "spec", "app" ] }, { "type": "null" } ], "default": null, "description": "How it is drawn: `spec` (the default), from what the plugin renders\nas data; or `app`, a panel: its own TSX app, [`Self::entry`].", "type": [ "string", "null" ] }, "lifecycle": { "anyOf": [ { "enum": [ "tab", "panel" ] }, { "type": "null" } ], "default": null, "description": "How long its tab lives (1.14.0): `tab` (the default), opened and\nclosed as any; or `panel`, a fixed panel in its dock, there while\nthe plugin is on, which the user hides but can't close (a\n`singleton` placed `left`, `right` or `bottom`).", "type": [ "string", "null" ] }, "placement": { "anyOf": [ { "enum": [ "tab", "left", "right", "bottom" ] }, { "type": "null" } ], "default": null, "description": "Where it opens by default ([`ViewPlacement`]: `tab`, `left`, `right`,\n`bottom`); `tab` when none.", "type": [ "string", "null" ] }, "singleton": { "default": false, "description": "At most one tab: opening it again focuses that tab.", "type": "boolean" }, "source": { "default": null, "description": "The TSX source atomd builds for this panel.", "type": [ "string", "null" ] }, "title": { "$ref": "#/$defs/LocalizedText", "description": "The tab's title until the plugin names it (`atomd.view.setTitle`)." } }, "required": [ "id", "title" ], "type": "object" } }, "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { "$schema": { "description": "The schema URL for your editor.", "type": "string" }, "activation": { "default": [], "description": "When its engine starts (`docs/plugins.md`, Activation): what it\nlists here added to what its contributions imply. Only\n`onStartup` starts it with atomd; otherwise it starts the first\ntime it is used.", "items": { "anyOf": [ { "enum": [ "onStartup", "onUri", "onCall" ] }, { "pattern": "^(?:onCommand|onView|onLanguage|onEmbed|onSuggest):[^\\s]{1,128}$", "type": "string" } ] }, "maxItems": 64, "type": "array" }, "api": { "const": 1, "default": 1, "format": "uint32", "minimum": 0, "type": "integer" }, "author": { "default": "", "type": "string" }, "authorUrl": { "default": null, "description": "Shown in Settings only.", "type": [ "string", "null" ] }, "contributes": { "$ref": "#/$defs/Contributes" }, "description": { "$ref": "#/$defs/LocalizedText" }, "fundingUrl": { "default": null, "type": [ "string", "null" ] }, "id": { "description": "The plugin id and its installed folder name.", "pattern": "^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$", "type": "string" }, "minApi": { "description": "Minimum plugin API level as 1.N. The form 1.N.0 is also accepted. The atomd app version is set independently with minAtomdVersion.", "examples": [ "1.26" ], "pattern": "^1[.][0-9]+([.]0)?$", "type": "string" }, "minAtomdVersion": { "default": null, "description": "Minimum atomd app version, independent of the plugin API level.", "type": [ "string", "null" ] }, "name": { "$ref": "#/$defs/LocalizedText", "description": "The name shown to the user." }, "platforms": { "default": null, "description": "Where it runs (`macos`, `windows`, `linux`, `ios`, `android`, or the\ngroups `desktop` and `mobile`); everywhere when absent.", "items": { "enum": [ "macos", "windows", "linux", "ios", "android", "desktop", "mobile" ] }, "minItems": 1, "type": [ "array", "null" ] }, "plugins": { "additionalProperties": { "$ref": "#/$defs/Uses" }, "default": {}, "description": "The other plugins it calls and hears (1.22.0, `docs/plugins.md`,\nPlugins calling plugins), by id: approved by the user with the rest\nof what it asks for.", "type": "object" }, "repo": { "default": null, "description": "GitHub `owner/name`.", "type": [ "string", "null" ] }, "version": { "description": "The release version shared with nsh.json.", "type": "string" } }, "required": [ "id", "name", "version" ], "title": "Manifest", "type": "object" } ``` ## Plugin spec An atomd plugin is an NSH TSX app. atomd runs it in an NSH engine of its own (one QuickJS VM per plugin), with no surface of its own. The plugin talks to atomd through NSH's host channel (`host` from `"nsh"`). It reaches files, processes and the network only through the NSH standard modules, as far as its capabilities allow. It shows UI by sending atomd declarative views, which atomd draws in its own style. Everything that enforces this is NSH's runtime: - capability checks (declared by the plugin and granted by atomd); - VM limits; - release hardening. atomd adds the API the host channel serves, and the views it draws. ## Why this shape | Need | How | |---|---| | Runs without anything installed | QuickJS ships inside atomd: no Node, no Python | | Can only do what it declares | NSH capabilities: a call needs the plugin's declaration and atomd's grant, else `ERR_ACCESS_DENIED` | | Can't hang or bloat the app | NSH limits per VM (heap, time per call, nodes); a stopped VM stays stopped | | Talks to the app | `host.call` / `host.post` / `host.on`, every name a capability | | Looks like atomd | declarative views drawn by atomd (below) | A plugin's views are data drawn by atomd (Views, below), or, since API 1.11, its own TSX app drawn inside atomd's window (Panels, below): a nested `AppView`, which since NSH 0.8.0 mounts its root in itself. ## Package Source, an NSH project: ``` my-plugin/ nsh.json NSH app: id, version, build, capabilities manifest.json atomd manifest App.tsx entry ``` A plugin is a folder `/` in `/atomd/plugins/` or `/.atomd/plugins/`, in one of two layouts. A signed release, what the community registry installs: ``` / manifest.json plugin.nshpkg `nsh publish`, by a release key atomd's root certified ``` atomd verifies the package against its plugin root (`Q8yQYCb2L2RcvxwltZAVi2uFzadmqvIZrQEnM79zS0Q=`, key id `593282881a9b3e2d`) with an NSH trust store in `/atomd/trust/`: certificate, signature, hashes, revocations, and no build older than one it ran before. Its app id must be `dev.atomd.plugin.` and its `app.version` the manifest's `version`. What it declares comes from the package. Its assets are written to `/atomd/plugin-assets/`. Its build is accepted (older builds refused from then on) once its engine has started. A development folder, what `nsh build` writes: ``` / manifest.json bundle.js ┐ capabilities.json ├ `nsh build . -o ` app.json ┘ ``` These are unsigned. atomd loads them only in **Developer mode** (Settings → Plugins) and labels them "Unsigned · development". With it off, the plugin is listed but can't be turned on. `app.json`'s id (and `nsh.json`'s, if present) must be `dev.atomd.plugin.`. `bundle.js` is loaded as source. Bytecode (`bundle.nshc`) is trusted input in NSH and is never loaded from a plugin folder. A folder with both is a signed release. A folder that breaks a rule is skipped, and Settings says why. ### manifest.json ```json { "id": "codex-agent", "name": "Codex Agent", "version": "0.4.0", "description": "Chat with the open note.", "author": "atomd", "api": 1, "minApi": "1.26", "minAtomdVersion": "1.0.0", "platforms": ["desktop"], "authorUrl": "https://example.com", "fundingUrl": "https://example.com/sponsor", "repo": "owner/codex-agent", "contributes": { "sidebar": { "title": "Codex", "icon": "sparkles" }, "commands": [ { "id": "codex.ask", "title": "Ask Codex about this note", "hotkey": "mod+shift+k" }, { "id": "codex.explain", "title": "Explain with Codex" } ], "menus": { "editor": ["codex.explain"], "file": ["codex.ask"] }, "codeBlocks": [{ "language": "chart" }], "ribbon": [ { "id": "chat", "icon": "sparkles", "title": "Codex", "view": "sidebar" }, { "id": "ask", "icon": "icons/ask.svg", "title": "Ask Codex", "command": "codex.ask" } ], "settings": [ { "key": "model", "type": "select", "title": "Model", "options": [{ "value": "fast", "label": "Fast" }, { "value": "best", "label": "Best" }] }, { "key": "token", "type": "secret", "title": "API token", "placeholder": "sk-…" } ] } } ``` - `id`: the plugin id, `^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$`, the source of truth. It is the folder's name, and the NSH app id is `dev.atomd.plugin.`. - `version`: the package's `app.version`. - The optional `minApi` sets the minimum plugin API level, such as `"1.26"`. The form `"1.26.0"` is also accepted. The major must be `1`. atomd refuses to install, update or load a plugin that needs a higher API level. - The optional `minAtomdVersion` sets the minimum atomd app release. atomd checks it against the running app's version and checks `minApi` independently. Settings shows why the plugin could not be installed or loaded. - `authorUrl`, `fundingUrl`, `repo` (GitHub `owner/name`): optional, only shown. - `platforms` (optional): where it runs, any of `macos`, `windows`, `linux`, `ios`, `android` and the groups `desktop` (the first three) and `mobile` (the last two). Without it, everywhere. An empty list or an unknown name skips the plugin, with the reason in Settings. An older atomd ignores the field. - `activation` (optional): when the engine starts. See Activation. - `plugins` (optional, API 1.22): the other plugins it calls and hears, `{"": {"call": [methods], "listen": [topics]}}`; `contributes.api` and `contributes.events` are what it offers them. See Plugins calling plugins. ### Manifest localization Since API 1.31, the plugin's name and description, titles of commands, views (including the sidebar), ribbon buttons, menu entries, submenus, settings and toolbar items, toolbar layout names, and setting descriptions, option labels and placeholders can use any of these forms: - Plain string: `"title": "Word count"`. - Inline translations: `"title": {"en": "Word count", "zh-CN": "字数统计"}`. - Message key: `"title": "%wordCount.title%"`, with `"wordCount.title"` in `i18n/en.json` and other flat JSON catalogs such as `i18n/zh-CN.json`. Set `minApi` to `"1.31"`. atomd tries the exact locale, its language, then `en`. It falls back to the first inline translation as written, or the first catalog containing the key in locale filename order. If no catalog has the key, atomd displays the key without its percent signs. Manifest text follows the app's language live. Menu objects can set a `title` or inherit the command or submenu title. `atomd plugin check` requires every manifest message key in `i18n/en.json` and warns about missing keys in the other catalogs. To publish, import `manifest.json` and each catalog with `?url` in the background entry so NSH includes them in the signed package. Development folders hold the catalogs at `i18n/.json`. Each catalog is at most 256 KiB. The sample's `atomd.ts` exports `t(key, vars?)`. It uses `host.params.locale` and the catalogs atomd passes as `host.params.i18n`. Use `%{name}` for substitutions, and redraw dynamic UI on `atomd.app.changed` in the background or a TSX panel. ### Activation A plugin that is on does not start with atomd. Its engine starts the first time it is used: when something addressed to it happens. Its contributions say what that is, so most plugins list nothing: | Event | Happens when | |---|---| | `onCommand:` | one of its commands runs: palette, hotkey, menu, ribbon, toolbar | | `onView:sidebar` | its sidebar is shown | | `onView:` | a tab of its view opens, or is restored with the workspace | | `onLanguage:` | a code block of its language is drawn | | `onEmbed:` | an embed of its file type needs drawing | | `onView:settings` | its custom settings page is shown | | `onSuggest:` | its trigger is typed | | `onCall` | another plugin calls one of its methods (`contributes.api`, API 1.22) | | `onUri` | an external `atomd://plugin//` link names one of its declared URI actions (API 1.25) | The event that started it is then delivered: the command a plugin starts for is the first `atomd.command` it hears. Settings shows it as "Starts when used" until then. `"activation": ["onStartup"]` starts it with atomd instead. List it only when the plugin must hear what isn't addressed to it from launch on: `note.changed`, `note.edited`, `vault.changed` and `settings.changed` go only to plugins that run. One that starts later reads what it needs (`note.read`, `settings.get`) when it does. Other entries (`onCommand:…` and the rest above) are accepted and change nothing: atomd derives them. Anything else, or more than 64 entries, skips the plugin with the reason in Settings. An older atomd ignores the field and starts every plugin that is on at launch. ### Platforms A plugin runs on the platforms its manifest lists, less the phones when it declares `process` (iOS lets no app start programs; Android none it ships): a plugin that runs `codex` is desktop only whatever it lists. So `platforms` is for what the capabilities don't show, such as a view made for a wide window, or a plugin only tried on some. Where it doesn't run, a plugin is still listed in Settings → Plugins with a tag ("Desktop only", "Phone only", or the platforms) and why ("Runs programs on a computer (codex), which iOS doesn't allow"; "Made for macOS, Windows, Linux: not available on iOS"). It can't be turned on there. One that is on (from an older atomd, later from another device) stays on but idle: it isn't started, and its commands, menus, sidebar and hotkeys are left out. The registry's list may carry the manifest's `platforms`, so a plugin made for other platforms shows why instead of an Install button; installing checks the release's manifest and package again and refuses one that doesn't run here. In debug builds `ATOMD_PLATFORM` (`ios`, `android`…) makes atomd check plugins as on that platform, to test the phone's rules on a desktop. Contributions are data atomd knows without running the plugin: the sidebar's header, the commands in quick open, its menu items, hotkeys and settings. atomd checks them when it finds the plugin; one that doesn't make sense (a setting of an unknown type, a key used twice, a select without options, a default of the wrong type, a menu naming something that isn't one of its commands, a code block language that isn't one or comes twice) skips the plugin with the reason in Settings → Plugins. - `commands[].hotkey` (optional): a shortcut such as `mod+shift+k` (`mod` is Command on macOS, Control elsewhere), bound while the plugin runs and shown next to the command in quick open. A plugin that is on but not running (waiting for permissions to be allowed, failed) takes no key. It needs a modifier. atomd's own shortcuts (`mod+n`, `mod+p`, `mod+o`, `mod+j`, `mod+,`, the editor's…) and the keys of plugins listed earlier win; a hotkey that is taken, not a key, or one the system keeps is ignored, and the plugin's row in Settings says so ("Hotkey mod+n of “…” is ignored: …"). - `commands[].editorKey` (optional, API 1.24): a key the command takes in the note editor while its `when` holds (below, Editor keys): `tab`, `shift+tab`, `enter`, `alt+up`, `mod+shift+d`. Unlike a hotkey it may be a key without a modifier, the editor's own (Tab, Enter, Backspace, arrows, `alt+up`), but never one that types a character: a character or Space needs `mod` or `ctrl` (Option with a letter types one on a Mac). - `commands[].when` (optional, API 1.9): where the command is offered (below, Command conditions). Quick open and the menus leave it out, and its hotkey and ribbon button do nothing, while it doesn't hold. - `menus` (optional): entries for the editor's right-click menu (`editor`), a note's or folder's menu in the file tree (`file`, the row's "…" or right-click) and a tab's menu (`tab`, API 1.18). They come after atomd's own items. An entry is a command id, or (API 1.18) an object; `submenus` adds submenus (below, Menus). - `settings` (optional): `[{key, type, title, description?, default?, options?, placeholder?, scope?}]`, shown in Settings → Plugins → the plugin's **Options**. `scope` (API 1.3) is `device` (the default) or `synced`; a `secret` is always `device` (below, Settings storage). `type` is `string`, `number`, `boolean`, `select` (with `options: [{value, label}]`) or `secret` (a string shown masked). Without a `default` a value is `""`, `0`, `false` or the first option. A plugin that has settings may call `atomd.settings.get` and `atomd.settings.set` without declaring them. - `settingsView` (optional, API 1.27): `{kind, entry?}`, a custom page under **Options** (below, Settings page). - `codeBlocks` (optional, API 1.2): `[{language}]`, the fenced code blocks (```` ```chart ````) the plugin draws in notes (below, Code blocks). A `language` is lowercase `[a-z0-9][a-z0-9+#.-]*`, at most 32 long, once per plugin; it is matched with the fence's word in lowercase. atomd draws no fence language itself (`$$` formulas aren't fences), so none is reserved. It takes effect while the plugin runs and may call `atomd.ui.block`. When running plugins claim the same language, the first (by id) draws it; the others' row in Settings says so ("Code blocks `chart` are drawn by “…”, which comes first: this one's are ignored."). - `embeds` (optional, API 1.27): `{extensions: ["xyz"]}`, file types it draws inside notes (below, Embeds). - `toolbarItems`, `toolbarLayouts` (optional, API 1.3): its buttons in atomd's toolbars, and whole toolbar layouts (below, Toolbars). - `themes` (optional, API 1.2): `[{id, name, path}]`, themes Settings → General → **Theme** offers while the plugin is on (below, Themes). An `id` is lowercase letters, digits and `-` (at most 64), once per plugin; `path` is a `.json` file inside the plugin. ### Themes A theme is a file of design tokens in shadcn/ui's `cssVars` form (what tweakcn and shadcn's themes export), each color with a light and a dark value: ```json { "cssVars": { "light": { "background": "#eceff4", "body": "#2e3440", "link": "#5e81ac" }, "dark": { "background": "#2e3440", "body": "#d8dee9", "link": "#88c0d0" } } } ``` It goes over atomd's own theme (`crates/atomd-ui/themes/default.json`), so it sets only what it changes. Colors are CSS colors (`#rrggbb`, `#rrggbbaa`, `rgb()`, `oklch()`, `color-mix()`, …). A value atomd can't read, or one of another kind than the token's (a length for a color), is left out (logged) and the one under it stays; a file that isn't JSON, is over 256 KB or isn't there skips the plugin with the reason in Settings → Plugins. How a file is read (API 1.30), as CSS custom properties are: - `theme`'s values are both appearances', `light`'s the light one's and the dark one's unless `dark` sets it, `dark`'s the dark one's. A value only `dark` sets leaves the light appearance as it was. - A value may name any token with `var(--name)` or `var(--name, fallback)`, in `color-mix()` too: atomd's (`var(--body)`), the file's own, or a plugin's own `x-` names (below). It names the token as all the layers end up making it, so a layer over the theme changes what it names. A name that names itself, directly or through others, is left out, its fallback too (as in CSS). - A token keeps its kind: a value that isn't a color where atomd or NSH has a color is left out, and so is one that names such a value. - The plugin's panels are drawn with the very tokens atomd is. **Contract versions.** A theme file may say which version of atomd's theme contract it was written for, at its top: `"atomdTheme": 2`. Without it, it is 1. What a file draws under its version never changes when atomd updates: - In version 2, some of atomd's tokens follow others unless a theme sets them: `ring` follows `primary`; `accent-foreground`, `card-foreground`, `popover-foreground` and `secondary-foreground` follow `foreground`; `secondary` follows `muted`; `input` follows `border`; `block-text` follows `link`; `block-other` follows `code-foreground`; `radius-ui` (atomd's corners) follows `radius`. A theme setting `primary` gets a focus ring of that color; one setting `radius` (as tweakcn's do) gets corners that round. - In version 1 they keep atomd's own values, as they always did. Write new themes as version 2 (the sample does). To change tokens a panel plugin declares, put its plugin id and `cssVars` under `plugins`: ```json { "atomdTheme": 2, "plugins": { "chart-colors": { "cssVars": { "theme": { "x-chart-up": "var(--primary)" } } } } } ``` Each plugin section can set that plugin's declared `x-*` tokens, using `theme`, `light` and `dark` as above. References to atomd tokens use the app's final values. Settings → Customize lists enabled plugins' tokens under their names. Edits are stored in the same `plugins` section of `themeOverrides`, and that section is included in imports and exports. A plugin that gives themes and nothing else runs no code: its folder is `manifest.json` and its theme files, with no `bundle.js`, no `capabilities.json` and nothing to allow. A signed release carries its theme files as package assets (matched by `path`, with or without a leading `assets/`), so the signature covers them; a development folder's are read from the folder (Developer mode, as any unsigned plugin). The theme chosen is kept per device (`theme`: `/`). The user's own changes (Settings → Customize) are a theme file of the same form laid over the theme picked, kept for every device that syncs the vault (`themeOverrides`); a plugin's panels are drawn with them too. The user can also export what is drawn as a theme plugin folder of this form. When its plugin is turned off, removed or no longer gives it, atomd's own theme is drawn, and the plugin's theme comes back when it is on again. The token names are the API, and they stay: later versions add names (drawn with atomd's value until a theme sets them) and never rename or remove one. - Chrome: `background`, `foreground`, `icon`, `heading`, `muted`, `muted-foreground`, `soft-foreground`, `faint-foreground`, `accent`, `popover`, `primary`, `destructive`, `border`, `overlay`, `primary-foreground`, `card`, `success`, `scrim`, `ghost-hover`, `ghost-press`, `chip-hover`, `chip-press`, `grouped`, `pressed`, `switch-track`, and shadcn's names that panels' classes compile against: `accent-foreground`, `card-foreground`, `popover-foreground`, `secondary`, `secondary-foreground`, `input`, `ring`. - Sidebar and search: `sidebar`, `sidebar-foreground`, `sidebar-accent`, `sidebar-selected`, `sidebar-border`, `search-lit`, `palette-footer`. - Document: `body`, `placeholder`, `selection`, `link`, `link-hover`, `marker`, `code`, `code-border`, `code-foreground`, `mark`, `inserted`, `quote-border`, `rule`, `table-border`, `table-header`, `table-grip`, `checkbox-border`, `done-foreground`, `removed`. - Code highlighting: `syntax-comment`, `syntax-keyword`, `syntax-string`, `syntax-number`, `syntax-title`, `syntax-attr`, `syntax-deletion`. - Block families: `block-text`, `block-list`, `block-code`, `block-divider`, `block-table`, `block-other`. - What floats (API 1.30): `popover-edge` (the hairline around menus, popovers, dialogs and toasts), `card-edge` (around cards), `popover-shadow` (the color shadows are cast in; each layer takes a share of its alpha). - Sizes and fonts (API 1.30). Sizes are scales: every corner, text size and line height atomd draws is its own default times the token over its default, so the look stays atomd's while its proportions follow the theme. - `radius-ui`: atomd's corners (default: `radius`, NSH's 10px). `0px` squares every corner; circles and pills stay round. - `text-ui`: the chrome's text (default `13px`): menus, the sidebar, settings, the data table. - `text-doc`: the note's text (default `16px`): its body, headings, title and code blocks, with their line heights. - `font-sans`: the chrome's font, `font-mono`: every monospaced text (code in notes, the code of properties, plugin views and math), both the system's unless set. - Data tables (API 1.30): `grid-header`, `grid-header-border`, `grid-found`, `grid-found-current`, `grid-star`, `grid-frozen-shadow`; the option colors `tag-0` to `tag-19`, each with `tag-N-foreground` for its text (`tag-9` follows `muted`). `templates/atomd-sample-theme/` is a theme plugin to start from. ### Icon packs An icon pack (API 1.12) replaces atomd's icons by name. It is a folder of SVG files, `.svg` replacing the icon ``: ```json "contributes": { "iconPacks": [{ "id": "thin", "name": "Thin", "path": "icons" }] } ``` Settings → General → Icons offers atomd's own and the packs of the plugins that are on; the one chosen is kept per device (`iconPack`: `/`). Every icon atomd draws by name follows it: the window's, the editor's, and those plugins name (a ribbon button's `icon`, an element's `icon`), so a plugin's buttons look like the rest. An icon the pack leaves out is atomd's; a file whose name is not one of atomd's is not read. When the pack's plugin is turned off, removed or no longer gives it, atomd's icons are drawn, and the pack's come back when it is on again. Changing the pack redraws the icons and nothing else. Each file is an SVG document of at most 16 KB. Use a 24 px grid and `currentColor` so it follows the theme. The built-in Kubai Line icons use a 1.5 px stroke. [Icon credits and licenses](../crates/atomd-ui/assets/icons/README.md) The SVG must be self-contained. A file holding `