Ignis / Plugins

Ignis plugin guide

How to write a plugin for the Ignis launcher in C# with the plugin SDK: answer what the user types, give Ignis a list of items to search, add actions, settings and previews, and publish the result. Ignis is a launcher for Windows 11, and it is on the Microsoft Store.

What you need

Ignis is a launcher for Windows 11: press its hotkey (Win+Alt+Space unless you changed it), type, and choose a result. A plugin adds results of its own. It either answers what the user types after its keyword (a calculator, a translator), or gives Ignis a list of items that Ignis keeps and searches itself (boards, bookmarks, snippets), or both.

A plugin is a program of its own. Ignis starts it and talks to it over stdin and stdout, so a plugin that crashes, hangs or leaks memory can't take Ignis down with it. Plugins are written in C# with the Ignis plugin SDK, the NuGet package Ignis.Plugins.Sdk, which does all the talking for you.

To write one you need:

Your first plugin

The Ignis.Plugins.Templates package has a template, ignis-plugin, that makes a working plugin:

dotnet new install Ignis.Plugins.Templates
dotnet new ignis-plugin -n Shout
cd Shout
dotnet publish -c Release

dotnet new ignis-plugin -n Shout makes a folder Shout with:

Shout\
├── Shout.csproj            Native AOT, win-x64, a reference to Ignis.Plugins.Sdk
├── Program.cs              Starts the plugin
├── ShoutQueryHandler.cs    Answers the searches
├── plugin.json             What Ignis needs to know about the plugin
├── README.md
└── .gitignore

The template takes two options besides the name (-n; without it, the current folder's name):

Option Default
--id The plugin's id. By default the project name in lower case, with every character other than a-z, 0-9, ., _ and - replaced by -, and any leading characters that aren't a-z or 0-9 left out (plugin if nothing is left): My.Cool_Plugin gives my.cool_plugin.
--keyword The text that sends a search to the plugin. By default the project name in lower case, letters (of any alphabet) and digits only (plugin if nothing is left): My.Cool_Plugin gives mycoolplugin.

Both end up in plugin.json, where you can change them later. An id is for good: Ignis treats a plugin with another id as another plugin, so pick one that is yours, such as com.example.shout.

The code. Program.cs hands your class to the SDK:

using Shout;

// The SDK type by its full name, so that a project named like it (PluginHost) still builds.
await global::Ignis.Plugins.Sdk.PluginHost.RunAsync(new ShoutQueryHandler());

and ShoutQueryHandler.cs answers each search:

namespace Shout;

// Inside the namespace, so that the SDK's types win over a namespace of the same name (a project named PluginResult).
using System.Runtime.CompilerServices;
using Ignis.Plugins.Sdk;

sealed class ShoutQueryHandler : IQueryHandler
{
    public async IAsyncEnumerable<PluginResult> QueryAsync(
        PluginQuery query, [EnumeratorCancellation] CancellationToken ct)
    {
        if (string.IsNullOrWhiteSpace(query.Text))
        {
            yield return new PluginResult("help", "Type some text to shout it")
            {
                Subtitle = "Shows what you type in upper case, ready to copy",
            };
            yield break;
        }

        var shouted = query.Text.ToUpperInvariant();

        yield return new PluginResult("shout", shouted)
        {
            Subtitle = "Enter to copy",
            Actions = [PluginAction.Copy(shouted)],
        };
    }
}

query.Text is what the user typed after the keyword and a space. Each PluginResult is a row in Ignis's list, and its Copy action is what Enter does.

The manifest. plugin.json tells Ignis what the plugin is and how to start it:

{
  "id": "shout",
  "name": "Shout",
  "description": "Answers searches that start with 'shout'.",
  "version": "1.0.0",
  "author": "",
  "protocolVersion": 1,
  "minIgnisVersion": "2.1.0",
  "run": { "command": "Shout.exe" },
  "keyword": "shout",
  "permissions": [],
  "logLevel": "Info"
}

Every field is described under plugin.json.

Build it. dotnet publish -c Release compiles the plugin with Native AOT (a minute or so) and writes the installable package, bin\Release\shout-1.0.0.zip. If it fails, see Publishing the plugin.

Install it. Open Ignis's Settings (right-click the Ignis icon in the notification area and choose Settings...). Under Plugins, choose Install plugin, pick the ZIP and answer Yes. Then open Ignis and type shout hello: one row, HELLO, and Enter copies it.

To change the plugin, edit the code, raise version in plugin.json, publish again and install the new ZIP over the old one. That is an update: the plugin keeps its settings and secrets.

Answering queries

A class that implements IQueryHandler answers the searches meant for the plugin: those that start with its keyword, and every search if it is global. QueryAsync returns IAsyncEnumerable<PluginResult>, so results can come in as they are ready:

public async IAsyncEnumerable<PluginResult> QueryAsync(
    PluginQuery query, [EnumeratorCancellation] CancellationToken ct)
{
    if (string.IsNullOrWhiteSpace(query.Text))
        yield break;

    var shouted = query.Text.ToUpperInvariant();

    // The first result is shown at once.
    yield return new PluginResult("shout", shouted)
    {
        Subtitle = "Enter to copy",
        Score = 100,
        Actions = [PluginAction.Copy(shouted)],
    };

    // A slower one is streamed in when it is ready. Using the same id again would replace the
    // row instead.
    await Task.Delay(300, ct);
    yield return new PluginResult("whisper", query.Text.ToLowerInvariant())
    {
        Score = 40,
        Actions = [PluginAction.Copy(query.Text.ToLowerInvariant())],
    };
}

What the SDK does for you:

PluginHost.RunAsync takes one object, which implements whichever of IQueryHandler, IItemSource (item sources), IFallbackHandler (fallbacks), IActionHandler (custom actions) and IPluginStartup (below) the plugin needs.

Start-up, shut-down and logging

Results and actions

PluginResult has Id, Title, Subtitle, IconPath, Score (0-100), Autocomplete, PreviewMarkdown, PreviewText, PreviewImagePath and Actions. See Previews and autocomplete.

IconPath (and the manifest's icon) must name an image file inside your plugin folder: .png, .jpg, .jpeg, .ico, .bmp or .gif, at most 1 MB, given relative to the folder or as a full path into it. Anything else (a file elsewhere, a network share, a link) is ignored: the result shows the manifest's icon, else the Ignis icon.

Actions are made with PluginAction:

Factory Does Done by
PluginAction.Copy(text, title) Puts text on the clipboard Ignis
PluginAction.Open(target, title) Opens a web address, file or folder Ignis
PluginAction.Launch(command, args, title, workingDirectory) Starts a program for the user (args, title and workingDirectory are optional) Ignis; needs the launch permission
PluginAction.SetQuery(text, title) Puts text in the search box Ignis
PluginAction.Custom(id, title) Whatever your IActionHandler does Your plugin

The first four are built-in actions: Ignis does them itself, with no round trip to your plugin, so Enter never waits for your process and they work even if it has stopped. Use them whenever you can. Set IsDefault = true on the action Enter should run (otherwise the first one is the default), and KeepOpen = true to leave the window open afterwards, with with: PluginAction.Copy(text) with { KeepOpen = true }. The other actions are in the actions menu and run by their shortcut: see Actions: shortcuts, confirmation and the menu.

What Open may open. Without the launch permission, Open only opens:

Anything else needs "launch" in permissions: other URI schemes (ms-settings:, spotify:, file:), programs and scripts. A relative or missing path is refused either way. Launch is never run through a shell and refuses .bat and .cmd files. A console program started with Launch gets no console window (a program with windows of its own shows them as usual). An action that is refused is logged and the window stays open.

Custom actions. For something only your plugin can do, return PluginAction.Custom("archive", "Archive") and implement IActionHandler:

sealed class MyPlugin : IQueryHandler, IActionHandler
{
    public Task<ActionOutcome> InvokeAsync(PluginActionRequest request, CancellationToken ct)
    {
        // request.ResultId and request.ActionId say what the user picked.
        return Task.FromResult(ActionOutcome.Hide);   // or ActionOutcome.KeepWindowOpen,
                                                      // or new ActionOutcome(true, "new search text")
    }
}

A custom action has 10 seconds, starting your plugin included. If it isn't done by then, it is cancelled and the window stays open. For anything longer, start the work, return at once, and show the outcome some other way.

Action ids. They must be unique within one result. The SDK gives built-in actions ids that start with $ ($copy, then $copy.1 for a second copy) and throws if a custom id starts with $.

Actions: shortcuts, confirmation and the menu

Enter or a click runs a result's default action. The others are in the actions menu, which opens with Tab, Shift+F10, the Apps key or a right-click on the result. A result with no actions has no menu. An item's actions are read from where Ignis keeps the item, so its menu may take a moment to fill.

Three more things can be set on a PluginAction:

Actions =
[
    PluginAction.Copy(board.Url, "Copy link"),
    PluginAction.Custom("archive", "Archive board") with { Shortcut = "Ctrl+B", HideAtOnce = true },
    PluginAction.Custom("delete", "Delete board") with
    {
        Shortcut = "Ctrl+D",
        Confirm = new ActionConfirmation("Delete board?", "This can't be undone.", "Delete"),
    },
]

PluginAction is a record, so these are set with with on what a factory returns.

Previews and autocomplete

A result can carry a preview: PreviewMarkdown, PreviewText or PreviewImagePath. While the selected result has one, Ignis shows it in a pane to the right of the list and widens the window (from 640 to 1,048 px, kept centred on its monitor). A streaming answer updates its preview by sending the result again with the same id.

Autocomplete. When the selected result has Autocomplete and the caret is at the end of the search text, Right arrow replaces the text after your keyword with it (the keyword and its space stay) and searches again. Tab isn't used for this: it opens the actions menu.

Fallbacks

A fallback plugin answers when nothing else found anything, such as "search the web for ...". Mark the manifest "fallback": true and implement IFallbackHandler:

sealed class WebSearchPlugin : IFallbackHandler
{
    public async IAsyncEnumerable<PluginResult> FallbackAsync(
        PluginQuery query, [EnumeratorCancellation] CancellationToken ct)
    {
        await Task.CompletedTask;   // nothing to wait for here
        yield return new PluginResult("web", $"Search the web for \"{query.Text}\"")
        {
            Actions = [PluginAction.Open("https://duckduckgo.com/?q=" + Uri.EscapeDataString(query.Text))],
        };
    }
}

The "working…" row. A plugin with a keyword that hasn't answered 300 ms after the query gets one row, "{Name} is working…", which can't be run and has no menu. It goes when the plugin's first results arrive or its query ends, or when every plugin for the search is done.

Cancelling a query

Ignis cancels a plugin's previous query on every keystroke. In C# that is the CancellationToken your QueryAsync (or FallbackAsync) gets: when it is cancelled, stop working on that query and return. Pass the token on to what you wait for (Task.Delay(300, ct), HttpClient.GetAsync(url, ct)); an OperationCanceledException that comes out of QueryAsync because of it is fine.

The SDK tells Ignis at once that the query is cancelled and sends nothing more for it, even while your code still runs, so results yielded after the cancel are never shown. Code that ignores the token only wastes the plugin's own time, and holds up the next query if it keeps the plugin busy.

Time limits

Message size. Each message between Ignis and a plugin is one line of JSON of at most 4 MB. The SDK never sends a bigger one, so a plugin built with it is never killed for this:

A plugin that writes anything else to stdout (a line that isn't a protocol message) is killed and counted as crashed.

Queues. The SDK and Ignis each hold only so much of what the other sends:

Item sources

A plugin that answers a query on every keystroke is right for a calculator. For a list (boards, bookmarks, snippets, files) it is better to hand Ignis the list: Ignis stores it, searches it itself as the user types, and still has it at start-up before your plugin has started. Such a plugin is an item source: it implements IItemSource and its manifest has an items section.

{
  "id": "com.example.snippets",
  "name": "Snippets",
  "version": "1.0.0",
  "protocolVersion": 1,
  "run": { "command": "Snippets.exe" },
  "keyword": "snip",
  "items": { "refresh": "PT10M", "watch": false, "global": false }
}
items field Meaning
refresh How often Ignis asks for the items again, an ISO 8601 duration of at least one minute ("PT5M", "PT1H"). Left out or null: only at start-up.
watch true keeps your plugin running so it can push changes as they happen. Default false: Ignis stops the plugin when a load is done and starts it again for the next one.
global true searches your items for every query. Default false: only after your keyword.

A manifest with items needs a keyword or global: true (at the top level or in items); without one nothing could bring the user to the items, and Ignis refuses the manifest.

What the user sees. Typing the keyword and a space lists your items, best Score first, and text after it narrows them (the match is against Title and Keywords). With global, items also appear among the results of ordinary searches. An item's final rank is how well the text matches it plus its Score (0 to 100, 50 when left out). Choose Enter and the item's default action runs.

The code. Implement IItemSource.LoadAsync; the SDK pages and sends what you return.

using Ignis.Plugins.Sdk;

await PluginHost.RunAsync(new SnippetsPlugin());

sealed class SnippetsPlugin : IItemSource, IPluginStartup
{
    private string _file = "";

    public Task StartAsync(PluginContext context, CancellationToken ct)
    {
        _file = Path.Combine(context.DataDirectory, "snippets.txt");
        return Task.CompletedTask;
    }

    public Task<ItemLoad> LoadAsync(ItemLoadRequest request, CancellationToken ct)
    {
        // The token is whatever tells us where we were: here, when the file last changed.
        var token = File.Exists(_file) ? File.GetLastWriteTimeUtc(_file).Ticks.ToString() : "none";

        // Nothing changed since the load Ignis has: say so with an empty delta. Ignis keeps its items.
        if (request.SyncToken == token)
            return Task.FromResult(new ItemLoad(ItemLoadMode.Delta, [], token));

        // Otherwise send everything. A reset replaces all the items Ignis has for this plugin.
        return Task.FromResult(new ItemLoad(ItemLoadMode.Reset, ReadAll(), token));
    }

    private List<PluginItem> ReadAll() =>
        File.Exists(_file)
            ? File.ReadLines(_file).Where(l => l.Length > 0).Select(ToItem).ToList()
            : [];

    // The id is what makes an item "the same item" in the next load, so it must be stable: not a
    // string.GetHashCode(), which differs from run to run.
    private static PluginItem ToItem(string line) => new(Id: line, Title: line)
    {
        Subtitle = "Enter to copy",
        Keywords = ["snippet"],
        Score = 50,
        Actions = [PluginAction.Copy(line)],
    };
}

Reset and delta. ItemLoad.Mode says what the items are:

SyncToken is yours to define (a timestamp, a cursor, a version). Ignis stores the token you return with the items, once the load is complete, and gives it back in the next ItemLoadRequest; it is null for the first load, and after the items were cleared. A load that is not completed (your plugin crashed, or ran out of time) changes nothing for a reset; for a delta, the changes received stay and the token stays what it was.

Pushing changes. An item source that stays running ("watch": true) tells Ignis about changes as they happen, through PluginContext.Items, which StartAsync receives:

public Task StartAsync(PluginContext context, CancellationToken ct)
{
    _items = context.Items;
    _watcher = new FileSystemWatcher(Path.GetDirectoryName(_file)!, "snippets.txt");
    _watcher.Changed += async (_, _) => await _items.UpsertAsync(ReadAll());
    _watcher.EnableRaisingEvents = true;
    return Task.CompletedTask;
}

// Elsewhere:
await _items.RemoveAsync(["an old snippet"]);  // drop items by id
await _items.NotifyDataChangedAsync();         // "my data changed": Ignis runs the shown search again

Limits.

When your plugin is started. About five seconds after Ignis starts it loads every item source, one at a time, and then again whenever refresh has passed (the schedule is looked at once a minute, so a load can be up to a minute late). A load starts your plugin if it is not running. When the load is complete, Ignis stops a plugin that does not watch; if the load did not complete, it stops the plugin whatever watch says, and starts it again at the next load. A source whose loads keep failing waits longer each time: after the n-th load in a row that was not completed, the next try waits 2^(n-1) minutes, at most 60, so a failing watching source is not restarted every minute. A completed load ends the wait, and Refresh now on the plugin's card in Settings skips it. A change to one of the source's settings loads it again at once. The items from the last run are searchable from the moment Ignis starts, before this. An item's actions that Ignis does itself (Copy, Open, Launch, SetQuery) run without your plugin; a Custom action starts it if needed.

Turning off and uninstalling. A plugin the user turned off is not loaded and its items are not searched. Uninstalling it, or installing a new version over it, removes its stored items; the new version loads its own. A source that was just installed is loaded at once, not at the next look.

A plugin that is both. A class may implement IQueryHandler as well as IItemSource, to answer live queries (for a keyword) and give a list. A plugin that only implements IItemSource is never sent a query.

Settings

A plugin declares the settings it needs in plugin.json; Ignis shows them on the plugin's card in Settings and keeps the values. The plugin never builds a settings screen.

"settings": [
  { "key": "apiKey", "type": "secret", "label": "API key", "description": "From your account page." },
  { "key": "model", "type": "choice", "label": "Model", "choices": ["small", "large"], "default": "small" },
  { "key": "cliPath", "type": "path", "label": "Command-line tool", "pathKind": "file" },
  { "key": "maxResults", "type": "number", "label": "Results", "min": 1, "max": 50, "default": 10 },
  { "key": "includeArchived", "type": "bool", "label": "Include archived", "default": false },
  { "key": "nickname", "type": "string", "label": "Nickname" },
  { "key": "signIn", "type": "button", "label": "Sign in to OneDrive" }
]
Type Shown as Value Fields besides key, type, label, description
string A text box Text default
secret A password box Kept as a secret, never a value none (no default)
bool A switch true or false default
number A number box A number default, min, max
choice A drop-down One of choices choices (needed, not empty), default
path A box and a Browse button A file or folder path default, pathKind ("file", the default, or "folder")
button A button None none (no default)

Reading the settings. context.Settings (on the PluginContext that StartAsync gets) holds the values:

public Task StartAsync(PluginContext context, CancellationToken ct)
{
    _settings = context.Settings;
    _settings.Changed += OnSettingsChanged;
    return Task.CompletedTask;
}

private int MaxResults => (int)(_settings.GetNumber("maxResults") ?? 10);
private string? Cli => _settings.GetString("cliPath");   // GetBool for a bool

Secrets

An API key or token belongs in a secret, never in a plain setting or in the plugin's own files.

Host services

A plugin asks Ignis to do things for it through context.Host. Each call is a request to Ignis:

SDK call Permission Does
Host.SetClipboardTextAsync(text) clipboard Puts text on the clipboard
Host.GetClipboardTextAsync() clipboard The clipboard's text, or null; text over 1,000,000 characters is refused
Host.OpenAsync(target) none Opens a URL, file or folder, by the rules of the built-in Open action
Host.LaunchAsync(command, args, workingDirectory) launch Starts a program for the user, outside the plugin's job, so it keeps running when the plugin stops
Host.NotifyAsync(title, message) notifications Shows a notification from Ignis
Host.PasteAsync(text) paste Pastes text into the window the user came from
Host.SetQueryAsync(text) none Replaces the search text, only while Ignis is shown
Host.AllowForegroundAsync() windows Lets the plugin's process bring a window of its own to the front
context.Secrets.SetAsync(key, value) none Stores or deletes a secret

context.Settings and context.Secrets.Get are read for you when the plugin starts and when a setting changes; they don't ask Ignis each time.

Details:

Rate limits. Ignis counts each plugin's requests in token buckets that refill evenly. Over a limit the answer is RateLimited:

Requests Limit
All host requests together 20 per second
NotifyAsync 3 per minute
SetClipboardTextAsync and PasteAsync, together 5 per 10 seconds
GetClipboardTextAsync 5 per 10 seconds
SetQueryAsync 5 per 10 seconds
OpenAsync, LaunchAsync and AllowForegroundAsync, together 5 per 10 seconds

Errors. A refusal throws PluginHostException, with the reason's code in Code (the constants are in ProtocolInfo, such as ProtocolInfo.PermissionDenied). No answer within 10 seconds throws TimeoutException.

Code Name Means
-32002 PermissionDenied The manifest doesn't ask for the permission
-32003 RateLimited Too many requests; try again in a moment
-32004 NotAvailable Can't be done now (SetQueryAsync while hidden, PasteAsync with no window, a busy clipboard); try again later
-32602 InvalidParams A missing field, a refused OpenAsync or LaunchAsync, a bad secret key or value, a request over 4 MB
-32603 InternalError It failed on Ignis's side; the message says so in plain words, never more
-32601 MethodNotFound This Ignis doesn't offer the service

Besides RateLimited, which any of them can answer, the codes each call answers:

Call Codes
SetClipboardTextAsync, GetClipboardTextAsync PermissionDenied; NotAvailable "The clipboard is busy." when another app holds the clipboard or it doesn't answer within 2 seconds; for GetClipboardTextAsync, NotAvailable "The clipboard text is too large." over 1,000,000 characters
OpenAsync PermissionDenied (needs launch), InvalidParams (refused), InternalError
LaunchAsync PermissionDenied, InvalidParams (refused), InternalError
NotifyAsync PermissionDenied, InternalError
PasteAsync PermissionDenied; NotAvailable when it can't be done now (see PasteAsync above) or "The clipboard is busy."
SetQueryAsync NotAvailable (see SetQueryAsync above), InternalError
Secrets.SetAsync InvalidParams (a bad key or value, or over a limit); InternalError "Ignis could not store the secret." when the secrets file can't be read, written or encrypted
AllowForegroundAsync PermissionDenied, NotAvailable (the plugin's process isn't known), InternalError

Any other failure on Ignis's side is InternalError "Ignis could not do that.". A permission refusal, a rate-limit refusal and a failure on Ignis's side are logged in the plugin's log, each kind at most once a minute per call.

Permissions

A plugin lists what it needs in permissions: clipboard, paste, notifications, launch, network and windows. Ignis enforces clipboard, paste, notifications, launch and windows for the host services and built-in actions above. network is declared and shown but not enforced. A permission Ignis doesn't know makes the plugin "built for a newer version of Ignis".

The user sees the permissions in two places, in plain words:

Permissions are not a sandbox: a plugin still runs with the user's rights, and can read what the user can.

plugin.json

{
  "id": "com.example.shout",
  "name": "Shout",
  "description": "Upper-case whatever you type",
  "version": "1.0.0",
  "author": "Your Name",
  "protocolVersion": 1,
  "minIgnisVersion": "2.1.0",
  "run": { "command": "Shout.exe" },
  "keyword": "shout",
  "startup": "onDemand",
  "permissions": [],
  "logLevel": "Info"
}
Field Required Description
id Yes A letter or digit (a-z, A-Z, 0-9), then also ., _ and -, at most 128 characters. It names the plugin's folders and log.
name Yes Shown in Settings
protocolVersion Yes The protocol version the plugin was built for: 1
minIgnisVersion No Oldest Ignis that can run the plugin, as major.minor.build. The template fills in the first Ignis that runs plugins built with this SDK.
run.command Yes The program to start: the plugin's exe (Shout.exe); run.args is an optional list of arguments
keyword No The text before a space that sends a search to your plugin
global No true to receive every search, not only those that start with your keyword
fallback No true makes the plugin a fallback: asked only when nothing else found anything
startup No onDemand (default) or eager
items No Makes the plugin an item source: { "refresh": "PT5M", "watch": false, "global": false }
settings No The plugin's settings, shown on its card: a list of { key, type, label, ... } (at most 50)
permissions No clipboard, paste, notifications, launch, windows (enforced) and network (shown, not enforced). See Permissions.
logLevel No Minimum level for the plugin's log: Trace, Debug, Info, Warn, Error or Fatal
description, version, author No Shown in Settings; the install question names the author and version. dotnet publish needs version: it names the ZIP.
icon No An image file in the plugin folder, shown for the plugin's results and on its card in Settings. dotnet publish puts it in the ZIP.

run.command must be the exe that the project publishes, <project name>.exe: dotnet publish checks it (see Publishing the plugin). Ignis runs it from the plugin's folder and never through a shell.

A plugin.json Ignis can't read, or that fails a check above, shows in Settings with the reason. A folder whose plugin.json has no protocolVersion is listed as "built for an older version of Ignis: uninstall it, or ask its author for an update".

Compatibility is checked before your plugin runs. If protocolVersion is newer than Ignis speaks, or minIgnisVersion is higher than the running Ignis, Settings lists the plugin with "built for a newer version of Ignis: update Ignis" and never starts it. If the protocol version is one this Ignis has dropped, the reason is "built for a version of Ignis this one no longer supports: ask its author for an update". Ignis keeps speaking old protocol versions, and new features inside a version are additions, so a plugin built for protocol 1 keeps working as Ignis is updated.

Publishing the plugin

A user's machine may have no .NET runtime, so a plugin is published with Native AOT: one small exe that needs no runtime and starts in about 10 ms. The SDK uses source-generated JSON and no reflection, so it works with AOT; keep your own code AOT-compatible too (the publish warns about code that isn't).

dotnet publish -c Release

Run it in the project's folder. It checks plugin.json first, before anything is compiled, then compiles the plugin, and then writes the installable package:

Use dotnet publish. Visual Studio's Publish command isn't supported: the ZIP step needs the MSBuild that comes with the .NET SDK.

When the publish refuses. Each problem is a build error with a code, pointing at the file to fix:

Code Message Fix
IGNISPLUGIN001 plugin.json is not valid JSON: the reason Fix the JSON at the line and column given. Comments and trailing commas are allowed.
IGNISPLUGIN002 plugin.json needs "id". (or "version", "protocolVersion", "run.command") Add the field.
IGNISPLUGIN003 run.command "command" is not the exe this project publishes ("name.exe"). Set run.command to the exe's name, which is the project's (assembly's) name with .exe.
IGNISPLUGIN004 An Ignis plugin is published with Native AOT: set PublishAot to true. Add <PublishAot>true</PublishAot> to the project.
IGNISPLUGIN005 plugin.json names the icon "icon", which is not in the project folder. Put the icon file in the project's folder (or a folder under it), or fix the path in icon.
IGNISPLUGIN006 plugin.json's id "id" is not one Ignis accepts: a letter or digit first, then letters, digits, '.', '_' or '-', at most 128 characters. Change id to fit that rule, such as yourname.weather.
IGNISPLUGIN007 plugin.json's version "version" can't be used in a file name. Use a plain version such as 1.0.0, with no /, \, : or other character a file name can't hold.

A project with a plugin.json that publishes something other than a console exe gets the warning IGNISPLUGIN100 ("plugin.json is here, but this project's OutputType is "type", so no plugin ZIP is made; ...") and no ZIP. Set <OutputType>Exe</OutputType>.

The C++ build tools. Native AOT links the exe with the Microsoft C++ tools. Install the "Desktop development with C++" workload, in Visual Studio or in the Build Tools for Visual Studio. The AOT compiler finds those tools with vswhere.exe, which it calls by name, and the folder Visual Studio puts it in isn't on PATH by default. If the publish fails with an error about vswhere, add the folder first:

$env:PATH = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer;$env:PATH"
dotnet publish -c Release

A project of your own. The template's project is all a plugin needs. To turn another console project into a plugin, add the package (dotnet add package Ignis.Plugins.Sdk), put a plugin.json next to the project file, and give the project the template's properties:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <PublishAot>true</PublishAot>
    <InvariantGlobalization>true</InvariantGlobalization>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Ignis.Plugins.Sdk" Version="1.0.0" />
  </ItemGroup>

  <ItemGroup>
    <None Update="plugin.json" CopyToOutputDirectory="PreserveNewest" />
  </ItemGroup>

</Project>

A plugin needs no WPF and no -windows target framework. The package brings the step that checks plugin.json and writes the ZIP, for any exe project with a plugin.json in its folder.

A plugin with more files. The ZIP from dotnet publish holds only the exe, plugin.json and the icon. A plugin that needs other files beside it (data files, a second program) can be zipped by hand: plugin.json and the plugin's program at the ZIP's root, or inside one top-level folder. Ignis unpacks all of it, up to 100 MB and 2,000 files, and refuses a package that packs a file at a ratio only a zip bomb has.

Installing and trying a plugin

Install. In Ignis's Settings, under Plugins, choose Install plugin and pick the ZIP. Ignis reads the package first and refuses one it can't use, with the reason: not a readable ZIP, no usable plugin.json, built for an older version of Ignis, needing a newer Ignis (protocol, minIgnisVersion or a permission it doesn't know), a run.command that is not in the package, or the id of a plugin that comes with Ignis. Then it asks: the plugin's name and version (or "from X to Y" for an update), that the author is only what the package claims, and that a plugin runs with your permissions. On Yes it stops the plugin if a copy is running, unpacks the package to %LOCALAPPDATA%\Ignis\Plugins\<id>\, and finds all the plugins again, so the plugin can be used at once. Installing a version over an older one is an update, and a failed install leaves the old copy in place.

Uninstall. Settings > Plugins has a trash-can button (tooltip "Uninstall plugin") on every plugin that did not come with Ignis. It stops the plugin, deletes its folder, removes its stored items, its settings values and its secrets, and finds the plugins again. (An update keeps the values and the secrets.) Turn a plugin off instead (the switch on its card) to keep it installed but never started or asked.

The plugin's card. Each plugin in Settings shows its own icon (the manifest's icon, else a puzzle piece), its state (Off, Stopped, Starting…, Running, or "Failed: the reason" with a Start again button), what it may do, its settings, and View log, which opens the plugin's log (or its folder, when there is no log yet). An item source has Refresh now, which loads its items again at once.

Try it. Open Ignis and type the keyword and some text (shout hello). The plugin's log is %LOCALAPPDATA%\Ignis\Logs\Plugins\<id>.log: it holds what the plugin writes to stderr and its Logger lines, the loading of its items, and anything Ignis refused it. If the plugin crashes, its exit code and the last lines of its stderr are in Ignis's main log, %LOCALAPPDATA%\Ignis\Logs\Ignis.log.

During development, copying the published exe and plugin.json straight to %LOCALAPPDATA%\Ignis\Plugins\<id>\ and restarting Ignis works too.

How a plugin talks to Ignis

You don't need this to write a plugin with the SDK, but it helps when you read a plugin's log or debug one that won't start.

To see a plugin's side of it, start the exe in a console and type a message on one line:

{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersions":[1],"ignisVersion":"2.1.0","pluginId":"shout","dataDirectory":"C:\\temp","theme":"dark","culture":"en-US"}}
{"jsonrpc":"2.0","id":2,"method":"query","params":{"queryId":"q1","text":"hello","keyword":"shout","reason":"keyword"}}

Use the C# SDK to write plugins: the protocol's full reference is not published yet.

Troubleshooting

dotnet publish fails. An IGNISPLUGIN error says what is wrong with plugin.json or the project: see the table under Publishing the plugin. An error about vswhere, a linker or the C++ tools means the C++ build tools are missing or not found.

The plugin is listed in Settings with a problem. The card says what is wrong: "built for an older version of Ignis" (no protocolVersion), "built for a newer version of Ignis: update Ignis" (a newer protocol, minIgnisVersion or permission), "its program was not found", a keyword that is taken or starts with @, # or !, or what is wrong in plugin.json (an items section without a keyword or global, a refresh under one minute).

Nothing happens when I type the keyword. Check that the plugin is on in Settings, and read %LOCALAPPDATA%\Ignis\Logs\Plugins\<id>.log and Ignis.log beside it (the card's View log opens the first). A plugin that crashed three times in five minutes is Failed: its card says why and has Start again.

An item source shows no items. The first load starts about five seconds after Ignis starts, and a load that misses its limits or whose plugin crashed is logged in the plugin's log and tried again at the next refresh, later each time it fails (up to an hour). A plugin with no refresh is loaded once per start; use Refresh now on its card to load again. Items past 100,000 are refused (also logged). Remember a manifest's keyword: without global, items show only after it.

Enter does nothing. An action that is refused, fails or runs out of time keeps the window open and is logged: Open of a program or a custom URI scheme needs the launch permission, and a custom action has 10 seconds. A shortcut that does nothing was probably dropped: it needs Ctrl or Alt (unless it is F1 to F24), and Ignis's own keys are refused. The plugin's log says so.

A host call throws. PluginHostException.Code says why: PermissionDenied (add the permission to permissions), RateLimited (see the limits under Host services), NotAvailable (SetQueryAsync while Ignis is hidden, PasteAsync with no window to paste into) or InvalidParams (a refused target, or a request over 4 MB). TimeoutException means Ignis gave no answer within 10 seconds; see the queues under Time limits.

My settings are empty. Only a plugin that implements IPluginStartup gets context.Settings. A setting with no stored value and no default has no entry in Values; check with GetString and friends, which return null.

The plugin writes to stdout and Ignis kills it. Stdout belongs to the messages between the plugin and Ignis. The SDK redirects Console.Out to stderr after PluginHost.RunAsync starts; anything written before it, or by a program the plugin starts that inherits stdout, can corrupt a message.