Build your first plugin
Build a plugin from an empty folder to a tool the agent calls and a card you see in the chat.
The agent cannot run your code or read what only your project knows. A plugin gives it a tool that can. This guide
builds project_version, a tool that reads your project's package.json, and a card that shows each call in the
chat.
This guide takes the shortest path:
- Write the tool in
conciv/plugins/project-version. - Ask the agent, and see the generic card.
- Draw the calls as your own card.
- Build the card, and see it in the chat.
Promise or Effect?
You write the engine part in one of two styles. Both can do the same things. Promise is plain async and await.
Effect is for code that already uses Effect: typed errors, and work that stops when the
user stops the turn. Every engine example has a tab for each. The site remembers your choice.
Copy this prompt into your agent. It builds this in your project from this page.
Build this in my project with conciv. conciv is a dev-only AI agent widget, and it already runs in my app. 1. Read https://conciv.dev/docs/plugins/first-plugin.md and follow it. It is the source of truth for the API. 2. If the project has the conciv-develop skill (conciv init installs it with the @conciv/skills docs pack), load it too. 3. Add a plugin folder, conciv/plugins/project-version. Its server.ts adds a project_version tool that reads my package.json and returns its name and version. 4. Add a browser card that shows the name and version for each project_version call. 5. Write the browser part in the UI framework my app uses. For React or Preact, put it in my app with @conciv/react or @conciv/preact and give it to <ConcivWidget>, as the page shows. For anything else, use Solid in the plugin folder and build it as the page shows. 6. Install only the packages the page lists, with the package manager this project uses. 7. Check that the engine sees it: run `npx @conciv/cli tools --help` while the dev server runs. project_version must be listed. 8. Tell me to ask the conciv chat "What version is this project?" and to look for the card. 9. When you are done, tell me what you changed and how to see it.
Installation
You need a project where conciv already runs. See Getting started. Then install what the engine part imports:
npm install -D @conciv/backend-plugin-api zodpnpm add -D @conciv/backend-plugin-api zodyarn add --dev @conciv/backend-plugin-api zodbun add --dev @conciv/backend-plugin-api zodFor the Effect style, also install Effect and the package that holds the Tool error type:
npm install -D effect @conciv/protocolpnpm add -D effect @conciv/protocolyarn add --dev effect @conciv/protocolbun add --dev effect @conciv/protocolWrite the tool
A plugin is a folder in conciv/plugins. Its engine part is server.ts. Make the folder and the file:
import {} from 'node:fs/promises'
import path from 'node:path'
import {} from 'zod'
import {Plugin, } from '@conciv/backend-plugin-api'
const = .({: .(), : .()})
async function (: string) {
try {
return .(.(await (path.(, 'package.json'), 'utf8')))
} catch {
throw .({: 'package.json is missing, or has no name and version.'}) // <- what the agent reads
}
}
export default Plugin.({
: 'project-version', // <- the plugin's name in conciv
async () {
await ..(() => {
.({
: 'project_version',
: "Read the project's name and version from its package.json.", // <- the agent reads this
: .({}),
: ,
: {: false}, // <- a direct tool: each call gets its own card
: async () => ({: await (..)}),
})
})
},
})import {} from 'node:fs/promises'
import path from 'node:path'
import {} from 'effect'
import {} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api/effect'
import * as from '@conciv/protocol/schema/tool'
const = .
export default Plugin.({
: 'project-version', // <- the plugin's name in conciv
: () =>
..(() => {
.
: 'project_version',
: "Read the project's name and version from its package.json.", // <- the agent reads this
: .
:
: {: false}, // <- a direct tool: each call gets its own card
: () =>
.
: async () =>
.(
A few things to notice:
setup(Promise) oreffect(Effect) runs once, when the engine loads the plugin.ctxis what the engine gives it.ctx.location.directoryis your project folder.inputandoutputare zod schemas. The engine checks the agent's input before your code runs.- Both tabs fail the same way. A missing file or a bad shape fails the call with one
Tool.toolErrormessage. codemode: falsemakes it a direct tool. Learn more in Tools and code mode.
Ask the agent
The engine watches conciv/plugins. A new folder loads with no restart. So does a saved change. Open your
app and ask in the chat:
What version is this project?The agent calls project_version and answers with your project's name and version. The call shows as the generic
card for now.
A folder elsewhere, such as one shared across projects, loads through the plugins option instead. See
Add plugins.
Draw the card
The browser part draws a tool's calls as your own card. Write it in Solid, React, Preact or plain DOM. Pick a tab: the site keeps your pick on every page.
- Solid and plain DOM: the browser part sits in the plugin folder, and you build it into one file.
- React and Preact: the card lives in your app and draws inside your app's own tree, so your providers reach it. Your app's bundler compiles it, with no extra build.
Install what the browser part is built with:
npm install -D @conciv/frontend-plugin-api solid-js vite vite-plugin-solidpnpm add -D @conciv/frontend-plugin-api solid-js vite vite-plugin-solidyarn add --dev @conciv/frontend-plugin-api solid-js vite vite-plugin-solidbun add --dev @conciv/frontend-plugin-api solid-js vite vite-plugin-solidAdd plugin-experimental.tsx next to server.ts:
import
Install the React bridge:
npm install -D @conciv/react @conciv/frontend-plugin-api zodpnpm add -D @conciv/react @conciv/frontend-plugin-api zodyarn add --dev @conciv/react @conciv/frontend-plugin-apiInstall the Preact bridge:
npm install -D @conciv/preact @conciv/frontend-plugin-api zodpnpm add -D @conciv/preact @conciv/frontend-plugin-api zodyarn add --dev @conciv/preact @conciv/frontend-plugin-apiInstall what the browser part is built with. The build helper compiles with vite-plugin-solid, so it needs Solid
even when your code does not use it:
npm install -D @conciv/frontend-plugin-api solid-js vite vite-plugin-solidpnpm add -D @conciv/frontend-plugin-api solid-js vite vite-plugin-solidyarnA few things to notice:
renderdraws one call. It runs again as the call moves on.props.outputis empty until the call ends.- A failed call draws the error card, not
render. - In Solid, the browser part's
Plugin.definehas noid. It takes the engine part's. - In Solid,
ctx.ui.Icondraws an icon from the widget's set. The names are lucide names. reactRender,preactRenderandmountRendereach turn your component into therenderthe registry takes.
Build or wire the browser part
The engine looks for exactly plugin-experimental.cjs (or .js) in the plugin folder. The name says "experimental"
because the browser API can still change. Add a Vite config that builds it:
import {} from 'vite'
import {
export default ({
: import.., // <- entry and outFile resolve from the plugin folder
: false,
: [
})Build it from your project folder:
npx vite build --config conciv/plugins/project-version/vite.config.tsRun the build again after each change to the browser part, then reload your app.
The card draws through <ConcivWidget> from @conciv/react. Render it once in your app, and give it the card under
the plugin's id:
The card draws through <ConcivWidget> from @conciv/preact. Render it once in your app, and give it the card under
the plugin's id:
The engine looks for exactly plugin-experimental.cjs (or .js) in the plugin folder. The name says "experimental"
because the browser API can still change. Add a Vite config that builds it:
import {
Reload your app and ask again. The call now shows your card with your project's name and version.
Your plugin draws its own card
A scripted session in the real panel. It plays in your browser, with no server.
Your plugin draws its own card
You: Which version is this project?
The agent calls
project_versionThis is vite-project 0.0.0, read from package.json.
Next steps
- Add a tool: namespaces, failures, and code mode.
- Share an RPC method: let the browser part call the engine part.
- Test your plugin: run this plugin on a real engine in a test.