deck-plugin-sdk 1.11.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,81 +1,81 @@
1
- # __NAME__: notes for AI agents
2
-
3
- This is a plugin for Deck, a Windows app (Tauri, React 19). It is
4
- bundled into one `plugin.js` that Deck imports at run time, inside Deck's own window. Read this
5
- before changing anything.
6
-
7
- ## Commands
8
-
9
- ```sh
10
- npm run dev # build on every save and install into the test Deck, which reloads it
11
- npm run build # build once into plugin.js
12
- npm run install-local # build and install into the user's real Deck
13
- npx deck-plugin check # validate plugin.json
14
- npx deck-plugin publish --dry-run # everything the registry checks, nothing published
15
- ```
16
-
17
- The test Deck is a second Deck with its own data, started with
18
- `& "$env:LOCALAPPDATA\Deck\deck.exe" --test` (PowerShell). Develop against it, never the real
19
- Deck: `npm run dev` only ever writes there. Run `npm run install-local` only when the user asks
20
- for the plugin to be installed for real. Its log is `%APPDATA%\Deck-Dev\logs\deck-<date>.log`;
21
- the plugin's `console.warn` and `console.error` lines land there.
22
-
23
- ## Files
24
-
25
- - `plugin.json`: `id` (letters, digits, dashes; it is a folder name and a config key), `name`,
26
- `description`, `icon` (a lucide icon name), `color`, `version`, `minDeck`, and `permissions`:
27
- what it uses of Deck (`files`, `processes`, `git`, `network`, `terminals`, `browser`,
28
- `secrets`, `system`, `deck`; the table is `node_modules/deck-plugin-sdk/permissions.json`). A
29
- bridge call outside them throws, naming the one to add: add it rather than working around it.
30
- - `src/plugin.tsx`: the entry. Its exports are what Deck uses (below).
31
- - `src/mcp.ts`, if present: tools for Deck's MCP server, built to `mcp.js`.
32
- - `plugin.js` (and `mcp.js`): the build's output, gitignored. Never edit them.
33
- - **The API is `node_modules/deck-plugin-sdk/types/core/bridge.d.ts`**: every function Deck
34
- exposes, with its documentation, generated from Deck's own source. Read it rather than guessing
35
- a name. A plugin imports it as `deck-plugin-sdk/bridge`.
36
-
37
- ## What the plugin can export
38
-
39
- `default` (a tab), `PaneView` (a view that can sit in a split pane, given `{ cwd, runInTerminal }`),
40
- `Status` (a footer readout), `Panel` (a footer drawer tab), `commands` (palette entries),
41
- `Settings` (a settings panel), `keybindings`, `Provider` (wraps the app, for state that must
42
- survive the tab closing), `Bar`, and `dispose`. At least one; none is required on its own.
43
-
44
- ## Rules that are easy to break
45
-
46
- - **Import Deck's copies.** `react`, `lucide-react` and the `deck-plugin-sdk/*` modules resolve to
47
- Deck's own at run time. Never add a second React, or a UI library that bundles one: two
48
- Reacts in one tree break hooks.
49
- - **No native code.** A plugin can only call what Deck already exposes (`deck-plugin-sdk/bridge`).
50
- To run a program, use `exec` or `procStream`; to read and write files, the `fs*` calls.
51
- - **Opening files**: `export const opens = [".ext"]` with a `PaneView` makes Deck open those files
52
- in the plugin, each as its own tab, given as the `file` prop. Open one yourself with `openFile`
53
- from `deck-plugin-sdk/terminals`; save with `fsWriteBytes`.
54
- - **npm packages are fine** (`npm install` and import): the build bundles them, their images,
55
- fonts and CSS included, into `plugin.js`. `?raw` on an import gives a file's text (a worker).
56
- A build step of your own (an esbuild plugin) goes in `deck-plugin.config.mjs` as
57
- `export const esbuildPlugins = [...]`. Not a package that needs Node (`fs`, `child_process`),
58
- one that bundles its own React, or one that starts a Web Worker from a file.
59
- - **Storage goes through `configRead` / `configWrite`** with plain names (`"settings"`, or
60
- `"notes.md"` for a plain file). Deck keeps them in the plugin's own folder. A name never
61
- written reads as `""`. Do not write a config whose text has not changed: every write wakes
62
- every config listener in Deck.
63
- - **`listen("config-changed", ...)` gets a `string[]` of names**: act only when it includes one
64
- of yours.
65
- - **Deck reloads the plugin on every rebuild.** Anything module scope starts (a `setInterval`,
66
- a `listen`, a window listener) must be stopped in an exported `dispose()`, or the old copy keeps
67
- running beside the new one. Anything a component creates outside the DOM (an `Audio`, a timer,
68
- a socket) is stopped in its effect's cleanup.
69
- - **A poll stops when nobody can see it**: skip ticks while `document.hidden`, and do not run it
70
- while the readout it feeds is switched off.
71
- - **Styling uses Deck's stylesheet.** Tailwind classes Deck does not already use do not exist.
72
- Use Deck's semantic tokens (`text-text-primary`, `text-text-secondary`, `text-text-muted`,
73
- `bg-elev`, `border-subtle`, `var(--accent)`) and Deck's components from `deck-plugin-sdk/ui`, so
74
- the plugin follows the user's theme.
75
- - **No error is dropped silently.** A failed save, load or action logs
76
- `console.warn("[__ID__] what failed", e)`.
77
-
78
- ## More
79
-
80
- The full guide (exports, storage, testing, publishing) is in Deck's **Docs** tab, which also has
81
- the API reference for the Deck that is installed.
1
+ # __NAME__: notes for AI agents
2
+
3
+ This is a plugin for Deck, a Windows app (Tauri, React 19). It is
4
+ bundled into one `plugin.js` that Deck imports at run time, inside Deck's own window. Read this
5
+ before changing anything.
6
+
7
+ ## Commands
8
+
9
+ ```sh
10
+ npm run dev # build on every save and install into the test Deck, which reloads it
11
+ npm run build # build once into plugin.js
12
+ npm run install-local # build and install into the user's real Deck
13
+ npx deck-plugin check # validate plugin.json
14
+ npx deck-plugin publish --dry-run # everything the registry checks, nothing published
15
+ ```
16
+
17
+ The test Deck is a second Deck with its own data, started with
18
+ `& "$env:LOCALAPPDATA\Deck\deck.exe" --test` (PowerShell). Develop against it, never the real
19
+ Deck: `npm run dev` only ever writes there. Run `npm run install-local` only when the user asks
20
+ for the plugin to be installed for real. Its log is `%APPDATA%\Deck-Dev\logs\deck-<date>.log`;
21
+ the plugin's `console.warn` and `console.error` lines land there.
22
+
23
+ ## Files
24
+
25
+ - `plugin.json`: `id` (letters, digits, dashes; it is a folder name and a config key), `name`,
26
+ `description`, `icon` (a lucide icon name), `color`, `version`, `minDeck`, and `permissions`:
27
+ what it uses of Deck (`files`, `processes`, `git`, `network`, `terminals`, `browser`,
28
+ `secrets`, `system`, `deck`; the table is `node_modules/deck-plugin-sdk/permissions.json`). A
29
+ bridge call outside them throws, naming the one to add: add it rather than working around it.
30
+ - `src/plugin.tsx`: the entry. Its exports are what Deck uses (below).
31
+ - `src/mcp.ts`, if present: tools for Deck's MCP server, built to `mcp.js`.
32
+ - `plugin.js` (and `mcp.js`): the build's output, gitignored. Never edit them.
33
+ - **The API is `node_modules/deck-plugin-sdk/types/core/bridge.d.ts`**: every function Deck
34
+ exposes, with its documentation, generated from Deck's own source. Read it rather than guessing
35
+ a name. A plugin imports it as `deck-plugin-sdk/bridge`.
36
+
37
+ ## What the plugin can export
38
+
39
+ `default` (a tab), `PaneView` (a view that can sit in a split pane, given `{ cwd, runInTerminal }`),
40
+ `Status` (a footer readout), `Panel` (a footer drawer tab), `commands` (palette entries),
41
+ `Settings` (a settings panel), `keybindings`, `Provider` (wraps the app, for state that must
42
+ survive the tab closing), `Bar`, and `dispose`. At least one; none is required on its own.
43
+
44
+ ## Rules that are easy to break
45
+
46
+ - **Import Deck's copies.** `react`, `lucide-react` and the `deck-plugin-sdk/*` modules resolve to
47
+ Deck's own at run time. Never add a second React, or a UI library that bundles one: two
48
+ Reacts in one tree break hooks.
49
+ - **No native code.** A plugin can only call what Deck already exposes (`deck-plugin-sdk/bridge`).
50
+ To run a program, use `exec` or `procStream`; to read and write files, the `fs*` calls.
51
+ - **Opening files**: `export const opens = [".ext"]` with a `PaneView` makes Deck open those files
52
+ in the plugin, each as its own tab, given as the `file` prop. Open one yourself with `openFile`
53
+ from `deck-plugin-sdk/terminals`; save with `fsWriteBytes`.
54
+ - **npm packages are fine** (`npm install` and import): the build bundles them, their images,
55
+ fonts and CSS included, into `plugin.js`. `?raw` on an import gives a file's text (a worker).
56
+ A build step of your own (an esbuild plugin) goes in `deck-plugin.config.mjs` as
57
+ `export const esbuildPlugins = [...]`. Not a package that needs Node (`fs`, `child_process`),
58
+ one that bundles its own React, or one that starts a Web Worker from a file.
59
+ - **Storage goes through `configRead` / `configWrite`** with plain names (`"settings"`, or
60
+ `"notes.md"` for a plain file). Deck keeps them in the plugin's own folder. A name never
61
+ written reads as `""`. Do not write a config whose text has not changed: every write wakes
62
+ every config listener in Deck.
63
+ - **`listen("config-changed", ...)` gets a `string[]` of names**: act only when it includes one
64
+ of yours.
65
+ - **Deck reloads the plugin on every rebuild.** Anything module scope starts (a `setInterval`,
66
+ a `listen`, a window listener) must be stopped in an exported `dispose()`, or the old copy keeps
67
+ running beside the new one. Anything a component creates outside the DOM (an `Audio`, a timer,
68
+ a socket) is stopped in its effect's cleanup.
69
+ - **A poll stops when nobody can see it**: skip ticks while `document.hidden`, and do not run it
70
+ while the readout it feeds is switched off.
71
+ - **Styling uses Deck's stylesheet.** Tailwind classes Deck does not already use do not exist.
72
+ Use Deck's semantic tokens (`text-text-primary`, `text-text-secondary`, `text-text-muted`,
73
+ `bg-elev`, `border-subtle`, `var(--accent)`) and Deck's components from `deck-plugin-sdk/ui`, so
74
+ the plugin follows the user's theme.
75
+ - **No error is dropped silently.** A failed save, load or action logs
76
+ `console.warn("[__ID__] what failed", e)`.
77
+
78
+ ## More
79
+
80
+ The full guide (exports, storage, testing, publishing) is in Deck's **Docs** tab, which also has
81
+ the API reference for the Deck that is installed.
@@ -1 +1 @@
1
- @AGENTS.md
1
+ @AGENTS.md
package/template/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) __YEAR__ __AUTHOR__
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) __YEAR__ __AUTHOR__
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,20 +1,20 @@
1
- # __NAME__
2
-
3
- A plugin for Deck.
4
-
5
- ## Developing
6
-
7
- ```sh
8
- npm run dev # rebuild as you edit; each save shows in your test Deck
9
- npm run install-local # when it is done: install it into your real Deck
10
- ```
11
-
12
- Start a test Deck from Settings › Plugins › Open a test Deck: it keeps its own settings and data,
13
- so trying the plugin never touches your real Deck.
14
-
15
- `src/plugin.tsx` is the entry point; its default export is the tab.
16
-
17
- ## What it does
18
-
19
- Say what this plugin is for. This file is what the registry shows on its page, so it is worth
20
- writing for somebody deciding whether to install it rather than for yourself.
1
+ # __NAME__
2
+
3
+ A plugin for Deck.
4
+
5
+ ## Developing
6
+
7
+ ```sh
8
+ npm run dev # rebuild as you edit; each save shows in your test Deck
9
+ npm run install-local # when it is done: install it into your real Deck
10
+ ```
11
+
12
+ Start a test Deck from Settings › Plugins › Open a test Deck: it keeps its own settings and data,
13
+ so trying the plugin never touches your real Deck.
14
+
15
+ `src/plugin.tsx` is the entry point; its default export is the tab.
16
+
17
+ ## What it does
18
+
19
+ Say what this plugin is for. This file is what the registry shows on its page, so it is worth
20
+ writing for somebody deciding whether to install it rather than for yourself.
@@ -1,4 +1,4 @@
1
- node_modules/
2
- # What the build writes. A release carries plugin.json and these; the repository holds the source.
3
- plugin.js
4
- mcp.js
1
+ node_modules/
2
+ # What the build writes. A release carries plugin.json and these; the repository holds the source.
3
+ plugin.js
4
+ mcp.js
@@ -1,10 +1,10 @@
1
- {
2
- "id": "__ID__",
3
- "name": "__NAME__",
4
- "description": "One line on what this is for, shown under its name in Settings.",
5
- "icon": "Sparkles",
6
- "color": "#a78bfa",
7
- "version": "0.1.0",
8
- "minDeck": "1.11.0",
9
- "permissions": []
10
- }
1
+ {
2
+ "id": "__ID__",
3
+ "name": "__NAME__",
4
+ "description": "One line on what this is for, shown under its name in Settings.",
5
+ "icon": "Sparkles",
6
+ "color": "#a78bfa",
7
+ "version": "0.1.0",
8
+ "minDeck": "1.11.1",
9
+ "permissions": []
10
+ }
@@ -1,16 +1,16 @@
1
- // What importing a file that is not code gives you, so the editor knows. The build inlines each
2
- // into plugin.js: an image or font as a data: URL, a stylesheet as its text (or, imported with
3
- // nothing bound — `import "x.css"` — applied to the page), a .wasm file as its bytes.
4
- declare module "*.png" { const url: string; export default url; }
5
- declare module "*.jpg" { const url: string; export default url; }
6
- declare module "*.jpeg" { const url: string; export default url; }
7
- declare module "*.gif" { const url: string; export default url; }
8
- declare module "*.webp" { const url: string; export default url; }
9
- declare module "*.svg" { const url: string; export default url; }
10
- declare module "*.woff2" { const url: string; export default url; }
11
- declare module "*.css" { const text: string; export default text; }
12
- declare module "*.wasm" { const bytes: Uint8Array; export default bytes; }
13
- // `import text from "some/file?raw"`: any file, as its text.
14
- declare module "*?raw" { const text: string; export default text; }
15
- // `import data from "some/file?base64"`: any file's bytes, as a base64 string.
16
- declare module "*?base64" { const base64: string; export default base64; }
1
+ // What importing a file that is not code gives you, so the editor knows. The build inlines each
2
+ // into plugin.js: an image or font as a data: URL, a stylesheet as its text (or, imported with
3
+ // nothing bound — `import "x.css"` — applied to the page), a .wasm file as its bytes.
4
+ declare module "*.png" { const url: string; export default url; }
5
+ declare module "*.jpg" { const url: string; export default url; }
6
+ declare module "*.jpeg" { const url: string; export default url; }
7
+ declare module "*.gif" { const url: string; export default url; }
8
+ declare module "*.webp" { const url: string; export default url; }
9
+ declare module "*.svg" { const url: string; export default url; }
10
+ declare module "*.woff2" { const url: string; export default url; }
11
+ declare module "*.css" { const text: string; export default text; }
12
+ declare module "*.wasm" { const bytes: Uint8Array; export default bytes; }
13
+ // `import text from "some/file?raw"`: any file, as its text.
14
+ declare module "*?raw" { const text: string; export default text; }
15
+ // `import data from "some/file?base64"`: any file's bytes, as a base64 string.
16
+ declare module "*?base64" { const base64: string; export default base64; }
@@ -1,65 +1,65 @@
1
- // __NAME__ — a Deck plugin.
2
- //
3
- // The default export is the tab. A plugin can export more than that — a footer readout, a
4
- // settings panel, palette commands, a pane view — and `docs/guide/api.md` in the Deck repository
5
- // lists every slot. One export is enough to start.
6
- import { useState } from "react";
7
- import { Sparkles } from "lucide-react";
8
- import { configRead, configWrite } from "deck-plugin-sdk/bridge";
9
-
10
- /** This plugin's own settings. Deck keeps a plugin's configs in its own folder, so a plain name. */
11
- const CONFIG = "settings";
12
-
13
- export default function __COMPONENT__() {
14
- const [note, setNote] = useState("");
15
- const [saved, setSaved] = useState(false);
16
-
17
- // Deck's config store, the same one its own modules use. Reading a key that has never been
18
- // written resolves to an empty string rather than throwing.
19
- const load = async () => {
20
- const raw = await configRead(CONFIG).catch(() => "");
21
- setNote(raw.trim() ? (JSON.parse(raw) as { note?: string }).note ?? "" : "");
22
- };
23
-
24
- const save = async () => {
25
- await configWrite(CONFIG, JSON.stringify({ note }));
26
- setSaved(true);
27
- setTimeout(() => setSaved(false), 1500);
28
- };
29
-
30
- return (
31
- <div className="flex h-full flex-col gap-4 p-6">
32
- <header className="flex items-center gap-3">
33
- <Sparkles size={18} style={{ color: "var(--accent)" }} />
34
- <h1 className="text-base font-semibold text-text-primary">__NAME__</h1>
35
- </header>
36
-
37
- <p className="max-w-[60ch] text-sm text-text-secondary">
38
- Edit <code className="rounded bg-elev px-1.5 py-0.5 text-text-primary">src/plugin.tsx</code>,
39
- run <code className="rounded bg-elev px-1.5 py-0.5 text-text-primary">npm run dev</code>,
40
- and Deck reloads the plugin as you save.
41
- </p>
42
-
43
- <div className="flex max-w-md items-center gap-2">
44
- <input
45
- value={note}
46
- onChange={(e) => setNote(e.target.value)}
47
- onFocus={() => void load()}
48
- placeholder="Type something, then save it"
49
- className="min-w-0 flex-1 rounded-lg border border-subtle bg-elev px-3 py-2 text-sm text-text-primary outline-none focus:border-accent"
50
- />
51
- <button
52
- onClick={() => void save()}
53
- className="shrink-0 rounded-lg border border-subtle bg-elev px-3 py-2 text-sm text-text-secondary hover:border-accent hover:text-text-primary"
54
- >
55
- {saved ? "Saved" : "Save"}
56
- </button>
57
- </div>
58
-
59
- <p className="text-xs text-text-muted">
60
- That writes to Deck's config store under <code>{CONFIG}</code>, which stays on this
61
- machine.
62
- </p>
63
- </div>
64
- );
65
- }
1
+ // __NAME__ — a Deck plugin.
2
+ //
3
+ // The default export is the tab. A plugin can export more than that — a footer readout, a
4
+ // settings panel, palette commands, a pane view — and `docs/guide/api.md` in the Deck repository
5
+ // lists every slot. One export is enough to start.
6
+ import { useState } from "react";
7
+ import { Sparkles } from "lucide-react";
8
+ import { configRead, configWrite } from "deck-plugin-sdk/bridge";
9
+
10
+ /** This plugin's own settings. Deck keeps a plugin's configs in its own folder, so a plain name. */
11
+ const CONFIG = "settings";
12
+
13
+ export default function __COMPONENT__() {
14
+ const [note, setNote] = useState("");
15
+ const [saved, setSaved] = useState(false);
16
+
17
+ // Deck's config store, the same one its own modules use. Reading a key that has never been
18
+ // written resolves to an empty string rather than throwing.
19
+ const load = async () => {
20
+ const raw = await configRead(CONFIG).catch(() => "");
21
+ setNote(raw.trim() ? (JSON.parse(raw) as { note?: string }).note ?? "" : "");
22
+ };
23
+
24
+ const save = async () => {
25
+ await configWrite(CONFIG, JSON.stringify({ note }));
26
+ setSaved(true);
27
+ setTimeout(() => setSaved(false), 1500);
28
+ };
29
+
30
+ return (
31
+ <div className="flex h-full flex-col gap-4 p-6">
32
+ <header className="flex items-center gap-3">
33
+ <Sparkles size={18} style={{ color: "var(--accent)" }} />
34
+ <h1 className="text-base font-semibold text-text-primary">__NAME__</h1>
35
+ </header>
36
+
37
+ <p className="max-w-[60ch] text-sm text-text-secondary">
38
+ Edit <code className="rounded bg-elev px-1.5 py-0.5 text-text-primary">src/plugin.tsx</code>,
39
+ run <code className="rounded bg-elev px-1.5 py-0.5 text-text-primary">npm run dev</code>,
40
+ and Deck reloads the plugin as you save.
41
+ </p>
42
+
43
+ <div className="flex max-w-md items-center gap-2">
44
+ <input
45
+ value={note}
46
+ onChange={(e) => setNote(e.target.value)}
47
+ onFocus={() => void load()}
48
+ placeholder="Type something, then save it"
49
+ className="min-w-0 flex-1 rounded-lg border border-subtle bg-elev px-3 py-2 text-sm text-text-primary outline-none focus:border-accent"
50
+ />
51
+ <button
52
+ onClick={() => void save()}
53
+ className="shrink-0 rounded-lg border border-subtle bg-elev px-3 py-2 text-sm text-text-secondary hover:border-accent hover:text-text-primary"
54
+ >
55
+ {saved ? "Saved" : "Save"}
56
+ </button>
57
+ </div>
58
+
59
+ <p className="text-xs text-text-muted">
60
+ That writes to Deck's config store under <code>{CONFIG}</code>, which stays on this
61
+ machine.
62
+ </p>
63
+ </div>
64
+ );
65
+ }