Skip to content

Open-source, local-first AI agent for real work.

7.0 KB
Raw Blame
---
title: Create your first plugin
description: Create, build, and install a minimal Vetta desktop plugin.
---

## Prerequisites

- Node or Bun.
- Vetta Desktop, running — installing and hot reload both talk to the live app.

You do **not** need a Vetta source checkout.

## Scaffold in one command

```bash
npx @vetta-org/plugin-cli init --id my-plugin --name "My Plugin"
cd my-plugin && npm install
```

You get `plugin.json`, a Vite + Module Federation config, a Tailwind entry, and an `AGENTS.md`
brief.

<Callout title="First step for an agent" type="info">
  The manual ships inside `@vetta-org/plugin-sdk`, so it lands in `node_modules`. **Do not
  hard-code that path** — a workspace may hoist the dependency to the repository root, and in a
  multi-plugin repository each plugin can pin a different SDK version. Resolve it with a command:

  ```bash
  npx vetta-plugin-cli docs
  ```

  It prints the manual's absolute path and the SDK version it documents. Because the manual is
  published with the SDK, the contract an agent reads is the contract this project compiles
  against — fetching the latest docs from the network cannot offer that guarantee.
</Callout>

## The development loop

```bash
npm run dev            # Vite + Module Federation dev server
npm run validate       # check the manifest against the build output
npm run install:vetta  # build, package, install into the running desktop app
npx vetta-plugin-cli watch      # hot reload: the host loads the plugin from this directory
npx vetta-plugin-cli reload <id>  # switch over when a pending version is reported
npx vetta-plugin-cli uninstall  # remove it
```

`install:vetta` hands the archive to the running desktop app, which validates, authorizes, and
installs it. It never writes `~/.vetta/plugins` directly.

Installing a newer version is only recorded as pending; the app keeps loading the current active
version until `reload` switches over. If a code change does not show up, check that `version` in
`plugin.json` was raised.

## Project structure

<Files>
  <Folder name="my-plugin" defaultOpen>
    <File name="plugin.json" />
    <File name="package.json" />
    <File name="tsconfig.json" />
    <File name="vite.config.ts" />
    <Folder name="src" defaultOpen>
      <File name="index.tsx" />
      <File name="style.css" />
    </Folder>
  </Folder>
</Files>

## Configure the build

Use `@vetta-org/plugin-vite` to configure Module Federation:

```ts
import tailwindcss from "@tailwindcss/vite";
import { vettaPluginFederation } from "@vetta-org/plugin-vite";
import { defineConfig } from "vite";

export default defineConfig({
	plugins: [
		tailwindcss(),
		vettaPluginFederation({
			name: "my_plugin",
			entry: "./src/index.tsx",
			expose: "./plugin",
		}),
	],
	esbuild: { jsx: "automatic", jsxImportSource: "react" },
});
```

## Create the entry point

```tsx
import { definePlugin } from "@vetta-org/plugin-sdk";

function MyPanel() {
	return <div className="p-3 text-sm text-foreground">Plugin loaded</div>;
}

export default definePlugin({
	activate(ctx) {
		ctx.ui.registerGlobalSlot({ id: "root", component: MyPanel });
	},
});
```

<Callout title="Do not create JSX at module scope" type="warn">
  Module Federation's shared React dependency is available after bootstrap. Put JSX inside a component or on the execution path after `activate()` runs.
</Callout>

## Build and load

Choose the path for development debugging or release installation:

<Tabs items={["Development", "Release installation"]}>
  <Tab value="Development">
    Install once with `npm run install:vetta` (so the host has the manifest and grants), then run `npx vetta-plugin-cli watch`: the host loads the plugin from your project directory, React components and CSS update through Vite HMR, and changes to the entry, `plugin.json`, or locales replace only this plugin's activation. This is useful for quickly checking UI and tool registration, but reinstall after changing install-time content such as permissions or `commands`, and run the production build and `.vettapkg` installation flow before release.
  </Tab>
  <Tab value="Release installation">
    <Steps>
      <Step>
        ### Production build

        Run `npm run build` (`vite build`) to generate `dist/mf-manifest.json`, `remoteEntry.js`, and the stylesheet.
      </Step>
      <Step>
        ### Archive the package

        Run `npm run pack` (`vetta-plugin pack`) to produce the release package. It uses the `.vettapkg` extension and ZIP container. Its archive root must contain `plugin.json` and `dist/`. Once Vetta is installed, users can double-click the file to install it.
      </Step>
      <Step>
        ### Install and enable

        On the **Abilities** page, open **Add ability → Import plugin package** and select the `.vettapkg` file (a legacy `.zip` containing `plugin.json` also works). Enable it and grant permissions in the **Enable and permissions** dialog.
      </Step>
      <Step>
        ### Verify loading

        Open the registered UI or invoke its tool and confirm that the host actually loaded the release artifact.
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Publishing several abilities: a marketplace repository

When one repository ships several abilities (plugins, MCP servers, skills), scaffold a
marketplace:

```bash
npx @vetta-org/plugin-cli init hub --name my-market \
  --repository https://github.com/me/my-market --min-app-version 0.6.35
```

`--min-app-version` is the oldest Vetta Desktop version your abilities support. Set it from the host features you actually use and never above the version your users run, or nobody can install them. The command creates the `.vetta/marketplace.json` index, the `abilities/` layout, a repository-level
`AGENTS.md`, and CI running `sync --check`. Add abilities by running `init` inside
`abilities/plugins/<slug>` — **every development command acts on the nearest ability directory**,
so working inside a marketplace is identical to working on a standalone plugin.

The index carries fields derived from each ability package, reconciled by a tool rather than by
hand:

```bash
npx @vetta-org/plugin-cli sync          # pull derived fields, advance marketplaceVersion
npx @vetta-org/plugin-cli sync --check  # report only, non-zero exit — for CI
```

<Callout title="Three constraints that bite remotely" type="warn">
  The host refuses to sync an entry whose `version` differs from the package. It will not install a
  plugin whose `entry` or `styles` are missing from the published directory — clients do not build
  for you, so those directories commit their `dist/`. And when `marketplaceVersion` does not change,
  clients silently skip the update: no error, no new version for anyone. `sync --check` covers all
  three.
</Callout>

## Next steps

<Cards>
  <Card title="Manifest and permissions" href="/plugins/manifest-and-permissions/" description="Align plugin.json fields, permissions, and release checks." />
  <Card title="Extension points" href="/plugins/extension-points/" description="Choose UI, file, message, Agent, or App Action extension points." />
</Cards>