Skip to Content
Recipes

Share a plugin across projects

Use one plugin in several projects, from a shared folder or from npm, instead of a copy in each.

Copy this prompt into your agent. It builds this in your project from this page.

Prompt
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/recipes/share-a-plugin-across-projects.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. Move my plugin out of conciv/plugins so several projects can use it: a shared folder listed in the plugins option of conciv(), or a package, as the page shows.
4. Ask me which one, and which projects use it, before you move anything.
5. Install only the packages the page lists, with the package manager this project uses.
6. Check that the engine sees it: run `npx @conciv/cli tools --help` while the dev server runs. The plugin's tools must still be listed in each project.
7. When you are done, tell me what you changed and how to see it.

Problem

A plugin in conciv/plugins/ belongs to one project. You want the same plugin in several. This comes up when:

  • your team's apps share one ticket tracker or one deploy tool;
  • several apps live in one monorepo;
  • you want to publish a plugin for others to add.

Copies drift

A copy of the plugin folder in each project works, but you then make every fix in every copy. Sooner or later one project runs an old version.

Solution

Keep the plugin in one place and point each project at it. In a monorepo, or on one machine, use a path:

vite.config.ts
import {} from 'vite'
import  from '@conciv/it/plugin/vite'

export default ({
  : [
    ({
      : ['../../shared/conciv-plugins/tickets'], // <- a folder outside the project
    }),
  ],
})

A path that starts with ./ or ../ is read from the project folder. The engine watches it, so a change there reloads the plugin in every running project. The plugin's imports resolve from its own folder, so install its dependencies there.

Publish it to npm

For projects in other repos, publish the plugin as a package. Its package.json names the two parts in exports:

package.json
{
  "name": "@acme/conciv-plugin-tickets",
  "type": "module",
  "exports": {
    "./server": "./dist/server.js",
    "./plugin-experimental": "./dist/plugin-experimental.cjs"
  },
  "peerDependencies": {
    "@conciv/backend-plugin-api": "*",
    "@conciv/frontend-plugin-api": "*"
  }
}
  • ./server is the engine part.
  • ./plugin-experimental is the built browser part.

The browser part is built with experimental(), which compiles Solid. So a shared package's UI is Solid or plain DOM. React or Preact UI lives in each app instead. Learn more in Build your first plugin.

Ship JavaScript. Node does not run TypeScript from a package. Each project then adds the plugin by name:

vite.config.ts
({: [['@acme/conciv-plugin-tickets', {: 'web'}]]}) // <- a name, with options

The engine installs the package from npm into its own cache. You do not add it to the project's package.json. Learn more in the Add plugins documentation.

Next steps

On this page