# Claude Code (/docs/agents/claude-code)
[Claude Code](https://docs.claude.com/en/docs/claude-code) connects to conciv as an MCP server. It is also the harness
a new chat starts with.
## Connect Claude Code [#connect-claude-code]
Run this once, in any folder:
```bash title="Terminal"
npx @conciv/cli mcp connect claude
```
It adds conciv's MCP server, named conciv-hub, to Claude Code for your user. Under the hood it runs
`claude mcp add -s user`. On success it prints:
```json title="Output"
{"ok": true, "data": {"connected": "claude"}}
```
Then drive the tab you have open from Claude Code in your terminal. The walkthrough, from the first prompt to
picking a tab and troubleshooting, is in [Outside agent](/docs/usage/outside-agent).
## The project plugin [#the-project-plugin]
conciv's init also installs a Claude Code plugin, conciv-connect, for this project only. It lives in
`.conciv/claude-connect`. It holds a conciv skill and an MCP bridge. The bridge reads the engine's address from
`.conciv/mcp-endpoint.json`, which the engine writes when it starts.
## What conciv runs in the chat [#what-conciv-runs-in-the-chat]
When Claude is the session's harness, conciv runs Claude Code on your machine, in your project, with your own login:
```text title="What conciv passes Claude Code"
permission mode auto <- Claude Code asks when it judges a step risky
ask rules git push --force, ... <- these commands always ask, as a card
system prompt appended <- conciv's instructions follow Claude Code's own
AskUserQuestion off <- the agent asks with a card in the thread instead
model opus <- unless you pick another in the model menu
```
conciv adds ask rules, so these commands always ask, even in auto mode:
- `git push` that forces (`--force`, `-f`) or deletes a remote branch (`--delete`, `-d`, a `:branch` refspec)
- `git reset --hard`
- `git clean`
- `git branch -D`
- `git gc --prune`
- a recursive `rm` (`-r`, `-R`, `-fr`, `-fR`)
- a recursive `chmod -R` or `chown -R`
- anything run with `sudo`
Each ask shows as a [Permission card](/docs/usage/approvals). A tool call waits up to an hour for your answer.
The model menu lists your account's own models, the same list as Claude Code's model picker. A picked effort level
reaches Claude Code as its effort setting.
Claude gives the chat the most of any harness: its own commands, image attachments, compaction, past sessions and the
**Terminal** tab. Learn more in [Harnesses](/docs/harnesses).
## Disconnect [#disconnect]
```bash title="Terminal"
npx @conciv/cli mcp disconnect claude
```
This stops conciv answering Claude Code. It removes `conciv-hub` from its config.
init prints the commands to run yourself:
```bash title="Terminal"
claude plugin marketplace add .conciv/claude-connect
claude plugin install conciv-connect@conciv --scope local
claude plugin update conciv-connect@conciv --scope local
```
conciv passes Claude Code a plugin folder and a settings file by path. If either path has a space, the turn fails.
The error names the path and says to move it to a path with no space.
## Next steps [#next-steps]
- **[Approvals](/docs/usage/approvals):** answer the cards Claude Code asks.
- **[Chat](/docs/usage/chat):** what you do in the chat.
- **[Codex](/docs/agents/codex):** the same for Codex.
# Codex (/docs/agents/codex)
[Codex](https://developers.openai.com/codex/cli) connects to conciv as an MCP server. In the panel it chats
inside its own sandbox.
## Connect Codex [#connect-codex]
Run this once, in any folder:
```bash title="Terminal"
npx @conciv/cli mcp connect codex
```
It adds conciv's MCP server, named conciv-hub, to Codex. Under the hood it runs `codex mcp add`. On success it
prints:
```json title="Output"
{"ok": true, "data": {"connected": "codex"}}
```
Then drive the tab you have open from Codex in your terminal. The walkthrough, from the first prompt to
picking a tab and troubleshooting, is in [Outside agent](/docs/usage/outside-agent).
## What conciv runs in the chat [#what-conciv-runs-in-the-chat]
When Codex is the session's harness, conciv runs the Codex CLI on your machine, in your project, with your own login:
```text title="What conciv passes Codex"
sandbox workspace-write <- Codex can write only inside your project
approval policy never <- Codex never asks, so no Permission card shows
model your default <- the model in your Codex config.toml, unless you pick one
```
The model menu lists the models in Codex's own model cache. A picked effort level reaches Codex as its reasoning
effort. Past Codex sessions in this project show in the session list.
## Disconnect [#disconnect]
```bash title="Terminal"
npx @conciv/cli mcp disconnect codex
```
This stops conciv answering Codex. It removes `conciv-hub` from its config.
conciv checks the Codex login before a turn. Log in to Codex in a terminal, then send the message again.
conciv runs it with the never approval policy. Its sandbox limits what it can touch instead. Pick Claude Code or
Gemini CLI for a harness that asks with cards.
## Next steps [#next-steps]
- **[Harnesses](/docs/harnesses):** compare what each harness can do.
- **[Approvals](/docs/usage/approvals):** what asks before the agent acts.
- **[Gemini CLI](/docs/agents/gemini-cli):** the same for Gemini CLI.
# Gemini CLI (/docs/agents/gemini-cli)
[Gemini CLI](https://github.com/google-gemini/gemini-cli) connects to conciv as an MCP server. In the panel it chats
over the Agent Client Protocol (ACP).
## Connect Gemini CLI [#connect-gemini-cli]
Run this once, in any folder:
```bash title="Terminal"
npx @conciv/cli mcp connect gemini-cli
```
It adds conciv's MCP server, named conciv-hub, to Gemini CLI for your user. Under the hood it runs
`gemini mcp add -s user`. On success it prints:
```json title="Output"
{"ok": true, "data": {"connected": "gemini-cli"}}
```
Then drive the tab you have open from Gemini CLI in your terminal. The walkthrough, from the first prompt to
picking a tab and troubleshooting, is in [Outside agent](/docs/usage/outside-agent).
## What conciv runs in the chat [#what-conciv-runs-in-the-chat]
When Gemini CLI is the session's harness, conciv runs it on your machine, in your project, with your own login:
```text title="What conciv runs"
gemini --acp -m gemini-3-pro-preview <- ACP mode, with the model you picked
```
Every permission Gemini CLI asks for shows as a [Permission card](/docs/usage/approvals). The model menu lists four
models:
- `gemini-3-pro-preview`, the default
- `gemini-3-flash-preview`
- `gemini-2.5-pro`
- `gemini-2.5-flash`
Gemini CLI keeps no history conciv can read, so its past sessions do not show in the session list.
## Disconnect [#disconnect]
```bash title="Terminal"
npx @conciv/cli mcp disconnect gemini-cli
```
This stops conciv answering Gemini CLI. It removes `conciv-hub` from its config.
You cannot. The list is fixed in conciv today. Pick the closest one in the model menu.
## Next steps [#next-steps]
- **[Harnesses](/docs/harnesses):** compare what each harness can do.
- **[Approvals](/docs/usage/approvals):** what asks before the agent acts.
- **[opencode](/docs/agents/opencode):** the same for opencode.
# Agents (/docs/agents)
conciv works with an agent CLI in two ways. A connected agent runs in your own terminal and drives your open conciv
tabs through the `conciv-hub` MCP server. The session's harness is the agent CLI that conciv itself runs to answer in
the chat. Each page covers both for one agent.
## Pick your agent [#pick-your-agent]
- [Claude Code](/docs/agents/claude-code): connects, and gives the chat the most: cards, commands and a terminal tab.
- [Codex](/docs/agents/codex): connects, and chats in its sandbox with no permission cards.
- [Gemini CLI](/docs/agents/gemini-cli): connects, and chats over ACP with permission cards.
- [opencode](/docs/agents/opencode): connects, and chats with opencode's own models.
- [Pi](/docs/agents/pi): no connection and no chat yet. Its past sessions show in the list.
## What a connected agent gets [#what-a-connected-agent-gets]
- `list_tabs` lists the open conciv tabs of every running dev server on this machine.
- `discover_tools` lists the tools it can call on a tab.
- `execute_typescript` runs those tools on the tab you name.
- Work a call leaves running is a job. Its result comes back at the top of the next reply on that tab.
- By default it can use any open tab with no card. Learn to make it ask in [Approvals](/docs/usage/approvals).
## What init sets up [#what-init-sets-up]
- conciv's init connects every agent it finds on your machine.
- It writes a conciv section to `AGENTS.md`. It writes the same section to `CLAUDE.md` when that file does not import it.
- For Claude Code it also installs a project plugin with a conciv skill. See [Claude Code](/docs/agents/claude-code).
- Re-running init updates the section in place.
## Learn more [#learn-more]
- [Outside agent](/docs/usage/outside-agent): use a connected agent on your open tab, step by step.
- [Harnesses](/docs/harnesses): pick the harness a new chat starts with, and compare what each can do.
- [CLI](/docs/reference/cli): every `mcp` command.
# opencode (/docs/agents/opencode)
[opencode](https://opencode.ai) connects to conciv as an MCP server. In the panel it chats with the models
opencode can use.
## Connect opencode [#connect-opencode]
Run this once, in any folder:
```bash title="Terminal"
npx @conciv/cli mcp connect opencode
```
It adds conciv's MCP server, named conciv-hub, to opencode. Under the hood it runs `opencode mcp add`. On success
it prints:
```json title="Output"
{"ok": true, "data": {"connected": "opencode"}}
```
Then drive the tab you have open from opencode in your terminal. The walkthrough, from the first prompt to
picking a tab and troubleshooting, is in [Outside agent](/docs/usage/outside-agent).
## What conciv runs in the chat [#what-conciv-runs-in-the-chat]
When opencode is the session's harness, conciv runs it on your machine, in your project, with your own login:
```text title="What conciv passes opencode"
model opencode/claude-sonnet-4-5 <- the default, unless you pick another
```
The model menu lists the models opencode reports as usable, newest first. Past opencode sessions in this project
show in the session list.
## Disconnect [#disconnect]
```bash title="Terminal"
npx @conciv/cli mcp disconnect opencode
```
This stops conciv answering opencode. The `conciv-hub` entry stays in `opencode.json`. conciv
refuses it until you connect again.
opencode asks in its own way, and those asks do not reach conciv yet. No Permission card shows in the chat.
## Next steps [#next-steps]
- **[Harnesses](/docs/harnesses):** compare what each harness can do.
- **[Approvals](/docs/usage/approvals):** what asks before the agent acts.
- **[Pi](/docs/agents/pi):** the same for Pi.
# Pi (/docs/agents/pi)
[Pi](https://github.com/badlogic/pi-mono) cannot connect to conciv or chat in the panel yet. conciv reads its past
sessions only.
## Read past Pi sessions [#read-past-pi-sessions]
There is nothing to set up. conciv finds Pi's past sessions and lists them in the session picker. A Pi session from
another project offers **Copy resume command**. It copies the command that continues it in your terminal:
```bash title="Terminal"
pi --session
```
## What works [#what-works]
- Past Pi sessions show in the session list, with their titles and their messages.
- Pi shows in the model menu, but a turn with it fails.
- `npx @conciv/cli mcp connect pi` refuses, because Pi has no conciv hub connection.
That is the answer to every Pi turn today. Switch the session to another harness in the model menu.
conciv reads them from `PI_CODING_AGENT_DIR`, the same variable Pi reads. When it is unset, conciv reads
`~/.pi/agent`.
## Next steps [#next-steps]
- **[Harnesses](/docs/harnesses):** the harnesses that chat in the panel.
- **[Claude Code](/docs/agents/claude-code):** the harness a new chat starts with.
# Agents and permissions (/docs/agents-and-permissions)
An agent profile is the engine's set of permission rules for the agent in a session. It is not the agent CLI. It is
what the engine checks before a tool call runs. Each check ends in one of three effects: `allow`, `ask` or `deny`.
## Set rules in your config [#set-rules-in-your-config]
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
permission: {page_eval: 'allow'}, // <- runs JavaScript in the page with no card
permissions: [
{action: 'server_restart', resource: '*', effect: 'deny'}, // <- never restarts the dev server
],
}),
],
})
```
## Agent profile [#agent-profile]
The engine starts with one profile, `build`. It allows every action. It asks before it reads a `.env` file, but not
`.env.example`. Plugins can change a profile. The engine adds your config rules to every profile. Learn more in
[Ask for permission](/docs/plugins/guides/permission).
## Rules [#rules]
A rule has an action, a resource and an effect. The action is the tool's name, such as `page_eval`. The resource is
what it acts on, such as the code it would run. Both take `*` as a wildcard. Learn more in [Configuration](/docs/reference/configuration#permission).
## The order rules apply in [#the-order-rules-apply-in]
The last rule that matches decides. The engine reads them in this order:
1. the agent profile's rules: its built-in ones, the ones plugins add and your config rules.
2. the tool's fallback, below.
3. the session's own rules, which a plugin can set for one session.
4. your saved answers.
A `deny` among the first three always wins, before any saved answer is read. When no rule matches, the call asks.
## Fallback ask [#fallback-ask]
A risky tool asks for `fallback: 'ask'`. Then a call that only the catch-all `*` rule allows asks you instead. That is
why the `build` profile allows everything, yet running JavaScript in the page still asks. A rule that names the action,
such as `{page_eval: 'allow'}`, skips the card.
## The ask card [#the-ask-card]
An `ask` shows a **Permission** card in the chat. The call waits until you answer:
- **Allow once** (⌘ Enter or Ctrl Enter) runs this one call.
- **Allow always** runs it and saves the answer. It shows only when the tool offers a saved answer.
- **Deny** (Escape) refuses the call. Every other card waiting in the same session is refused with it.
Your agent CLI's own asks, from Claude Code or Gemini CLI, use the same card. They can be allowed once or denied, never
allowed always. Learn more in [Approvals](/docs/usage/approvals).
## Saved answers [#saved-answers]
**Allow always** saves an `allow` rule for the call's action and resources. The engine keeps it for this project, in the
`permission` table of `.conciv/conciv.db`. It applies to every session. Saved answers come last, so a saved answer
beats an `ask` rule from your config. Only a `deny` rule beats it.
A rule cannot make a call ask every time once it has been allowed always. A tool that must always ask leaves out its
saved answer, so the card has no **Allow always** button. Running JavaScript in the page works this way.
## Forget a saved answer [#forget-a-saved-answer]
conciv has no button or command to forget a saved answer yet. Delete its row from the database instead. List them
first:
```bash title="Terminal"
sqlite3 .conciv/conciv.db "select action, resource from permission"
```
Then delete the one you no longer want:
```bash title="Terminal"
sqlite3 .conciv/conciv.db "delete from permission where action = 'server_restart'"
```
The engine reads saved answers on every check, so the next call asks again.
## A deny in plugin code [#a-deny-in-plugin-code]
A tool that asks fails its call when you deny. In a Promise plugin, the ask rejects. In an Effect plugin, a deny rule
fails it with a `Tool.Error`. A plain **Deny** on the card is different: it interrupts the effect as a defect, so
`catchTag` never sees it. Learn more in [Ask for permission](/docs/plugins/guides/permission).
## Outside agents [#outside-agents]
An agent connected from your own terminal can use your open tabs. With `hubAccess: 'project'`, its first call shows a
card in the tab. An outside agent can never answer a card itself. Learn more in [Configuration](/docs/reference/configuration#hubaccess).
## Next steps [#next-steps]
- **[Approvals](/docs/usage/approvals):** which tools and CLIs ask, and how you answer.
- **[Ask for permission](/docs/plugins/guides/permission):** make your own tool ask before it acts.
- **[Configuration](/docs/reference/configuration):** the `permission`, `permissions` and `policies` options.
# API reference (/docs/api-reference)
Each package name links to its page on npm. The guides beside it show the package in use. Most apps install only
`@conciv/it`. It brings in everything under [Installed for you](#installed-for-you).
Every config option is in the [Configuration reference](/docs/reference/configuration), and every command in the [CLI
reference](/docs/reference/cli). The plugin API has its own [reference](/docs/plugins/reference).
## Set up [#set-up]
| Package | Purpose | Related guides |
| -------------------------------------------------------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| [@conciv/it](https://www.npmjs.com/package/@conciv/it) | The bundler plugin: adds the engine and the widget to your dev server. | [Vite](/docs/bundlers/vite), [Next.js](/docs/bundlers/nextjs), [webpack](/docs/bundlers/webpack), [Rspack](/docs/bundlers/rspack) |
| [@conciv/cli](https://www.npmjs.com/package/@conciv/cli) | `init`, the tools your agent calls, login and MCP connections. | [Getting started](/docs/getting-started), [CLI](/docs/reference/cli), [Connect your agents](/docs/agents) |
| [@conciv/skills](https://www.npmjs.com/package/@conciv/skills) | Agent skills that teach coding agents to build with conciv. | [Getting started](/docs/getting-started#installation) |
| [@conciv/try](https://www.npmjs.com/package/@conciv/try) | Try conciv live on conciv.dev, with the agent already on your machine. | [Playground](/docs/playground) |
## Widget components [#widget-components]
| Package | Purpose | Related guides |
| -------------------------------------------------------------------------- | --------------------------------------------------------- | ----------------------------------------------------- |
| [@conciv/react](https://www.npmjs.com/package/@conciv/react) | Mount the widget as a `` React component. | [widget option](/docs/reference/configuration#widget) |
| [@conciv/preact](https://www.npmjs.com/package/@conciv/preact) | Mount the widget as a Preact component. | [widget option](/docs/reference/configuration#widget) |
| [@conciv/solid](https://www.npmjs.com/package/@conciv/solid) | Mount the widget as a Solid component. | [widget option](/docs/reference/configuration#widget) |
| [@conciv/mascot-react](https://www.npmjs.com/package/@conciv/mascot-react) | The conciv robot mascot as a React component. | none |
## Plugins [#plugins]
| Package | Purpose | Related guides |
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| [@conciv/plugin-page](https://www.npmjs.com/package/@conciv/plugin-page) | Built in: the page tools that read and drive your open tab. | [Tools and code mode](/docs/tools-and-code-mode) |
| [@conciv/plugin-test-runner](https://www.npmjs.com/package/@conciv/plugin-test-runner) | Runs your vitest or Playwright tests, live in the Tests tab. | [Add plugins](/docs/usage/add-plugins) |
| [@conciv/plugin-tanstack](https://www.npmjs.com/package/@conciv/plugin-tanstack) | Build errors, routes and server-function traces of a TanStack app. | [Add plugins](/docs/usage/add-plugins), [TanStack Start](/docs/bundlers/tanstack-start) |
| [@conciv/plugin-recorder](https://www.npmjs.com/package/@conciv/plugin-recorder) | Records the page, so the agent can read what you just did. | [Add plugins](/docs/usage/add-plugins) |
| [@conciv/plugin-ios](https://www.npmjs.com/package/@conciv/plugin-ios) | Builds, runs and reads a native iOS app in the simulator. | [iOS](/docs/bundlers/ios) |
| [@conciv/plugin-try-it](https://www.npmjs.com/package/@conciv/plugin-try-it) | The connect steps conciv.dev shows. conciv.dev adds it; you do not. | [Playground](/docs/playground) |
## Build plugins [#build-plugins]
| Package | Purpose | Related guides |
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| [@conciv/backend-plugin-api](https://www.npmjs.com/package/@conciv/backend-plugin-api) | A plugin's engine part: `Plugin.define`, tools, rpc and context types. | [Build your first plugin](/docs/plugins/first-plugin), [Plugin API](/docs/plugins/reference) |
| [@conciv/frontend-plugin-api](https://www.npmjs.com/package/@conciv/frontend-plugin-api) | A plugin's browser part: cards, panels, slots and the rpc client. | [Build your first plugin](/docs/plugins/first-plugin), [Plugin API](/docs/plugins/reference) |
| [@conciv/backend-test-utils](https://www.npmjs.com/package/@conciv/backend-test-utils) | Starts the real engine with a scripted model, for plugin tests. | [Test your plugin](/docs/plugins/guides/testing) |
| [@conciv/simulation](https://www.npmjs.com/package/@conciv/simulation) | The scripted agent, and the driver that answers its turns. | [Drive the widget from a script](/docs/recipes/drive-the-widget-from-a-script) |
## Installed for you [#installed-for-you]
`@conciv/it` depends on these. Do not install them yourself.
| Package | Purpose | Related guides |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------- | -------------------------------------------------------------- |
| [@conciv/unplugin](https://www.npmjs.com/package/@conciv/unplugin) | The bundler plugin itself, one entry per bundler. | [Vite](/docs/bundlers/vite), [webpack](/docs/bundlers/webpack) |
| [@conciv/backend](https://www.npmjs.com/package/@conciv/backend) | The engine app, with the built-in page plugin. | [Engine and widget](/docs/engine-and-widget) |
| [@conciv/backend-defaults](https://www.npmjs.com/package/@conciv/backend-defaults) | The engine with no plugin in it: chat, sessions, permissions. | [Engine and widget](/docs/engine-and-widget) |
| [@conciv/backend-app-api](https://www.npmjs.com/package/@conciv/backend-app-api) | The engine's plugin host: plugin state, hooks and the tool service. | [Tools and code mode](/docs/tools-and-code-mode) |
| [@conciv/serve](https://www.npmjs.com/package/@conciv/serve) | The engine's HTTP server. | [Engine and widget](/docs/engine-and-widget) |
| [@conciv/harness](https://www.npmjs.com/package/@conciv/harness) | The adapters for each agent CLI. | [Connect your agents](/docs/agents) |
| [@conciv/protocol](https://www.npmjs.com/package/@conciv/protocol) | The oRPC contract between the engine and its clients. | [Engine and widget](/docs/engine-and-widget) |
| [@conciv/types](https://www.npmjs.com/package/@conciv/types) | Wire types shared by the plugin and the widget. | [Configuration](/docs/reference/configuration) |
| [@conciv/client](https://www.npmjs.com/package/@conciv/client) | The browser's connection to the engine. | [Engine and widget](/docs/engine-and-widget) |
| [@conciv/home](https://www.npmjs.com/package/@conciv/home) | The per-user registry of running engines and agent connections. | [Connect your agents](/docs/agents) |
| [@conciv/app](https://www.npmjs.com/package/@conciv/app) | The widget bundle the page loads. | [Engine and widget](/docs/engine-and-widget) |
| [@conciv/grab](https://www.npmjs.com/package/@conciv/grab) | The shape of an element you pin from the page. | [Tools and code mode](/docs/tools-and-code-mode) |
| [@conciv/storage-history](https://www.npmjs.com/package/@conciv/storage-history) | The widget's own navigation history, kept in web storage. | none |
| [@conciv/ui-kit-system](https://www.npmjs.com/package/@conciv/ui-kit-system) | The widget's design system. | none |
| [@conciv/ui-kit-chat](https://www.npmjs.com/package/@conciv/ui-kit-chat) | The chat thread, messages and composer. | [Sessions](/docs/sessions) |
| [@conciv/ui-kit-chat-tools](https://www.npmjs.com/package/@conciv/ui-kit-chat-tools) | The cards for built-in tool calls. | [Tools and code mode](/docs/tools-and-code-mode) |
| [@conciv/ui-kit-tap](https://www.npmjs.com/package/@conciv/ui-kit-tap) | The rich-text composer. | none |
| [@conciv/ui-kit-terminal](https://www.npmjs.com/package/@conciv/ui-kit-terminal) | The terminal in the panel. | none |
| [@conciv/solid-diffs](https://www.npmjs.com/package/@conciv/solid-diffs) | The diff and code views in tool cards. | none |
| [@conciv/solid-streamdown](https://www.npmjs.com/package/@conciv/solid-streamdown) | Streaming markdown for agent replies. | none |
| [@conciv/mascot](https://www.npmjs.com/package/@conciv/mascot) | The conciv robot mascot. | none |
# Bundlers (/docs/bundlers)
A bundler page shows the config that adds conciv to your dev server, and what the agent can do there. The widget and
the chat are the same everywhere. Only the wiring and the dev server tools differ.
## Vite [#vite]
- [Vite](/docs/bundlers/vite): Vite apps, Astro included. The agent also reads your dev server.
- [TanStack Start](/docs/bundlers/tanstack-start): TanStack Start apps, which run on Vite.
## Other bundlers [#other-bundlers]
- [Next.js](/docs/bundlers/nextjs): `withConciv` plus two instrumentation files.
- [webpack](/docs/bundlers/webpack): the widget and the engine in your development build.
- [Rspack](/docs/bundlers/rspack): the widget and the engine in your development build.
## Native apps [#native-apps]
- [iOS](/docs/bundlers/ios): the widget over a native app in the simulator, in early alpha.
## Not supported yet [#not-supported-yet]
Rollup and esbuild do not run conciv yet. Their plugin entries exist but do nothing. Serve your app with
[Vite](/docs/bundlers/vite) instead.
# iOS (/docs/bundlers/ios)
conciv for iOS floats the widget over your native app in the simulator. A web dev server runs the engine and serves
the widget.
The Swift API can change without notice. The iOS simulator is the only supported target.
Copy this prompt into your coding agent. It sets up the dev server and the Swift package for you.
## Attach conciv to your app [#attach-conciv-to-your-app]
First set up a web dev server with conciv, as on the [Vite page](/docs/bundlers/vite), and start it. The app loads the
widget from the engine that server runs.
In Xcode, use File > Add Package Dependencies and paste this URL:
```text title="Package URL"
https://github.com/conciv-dev/conciv-swift.git
```
Pick the version that matches your `@conciv/it` version. Add the `ConcivWidget` product to the target that shows your
UI. The package needs iOS 17.
Call `attach()` once at app start:
```swift title="MyApp.swift"
import SwiftUI
import ConcivWidget // [!code ++]
@main
struct MyApp: App {
init() { // [!code ++]
ConcivWidget.attach() // [!code ++]
} // [!code ++]
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
```
`attach()` finds the key window and the engine itself, so `App.init` is early enough. Build and run a Debug build in
the simulator. Tap the conciv button and type the 6-digit code your dev server prints.
## What works [#what-works]
- The chat and the panel over your own UI.
- Pick mode, which hands a native view to the agent.
- A Release build shows no widget.
- A Swift edit reaches the screen only after a build and a run. There is no hot reload.
## Let the agent build and run the app [#let-the-agent-build-and-run-the-app]
Add the iOS plugin to the plugins of your conciv config. The engine installs it from npm, so there is nothing to
install:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: [['@conciv/plugin-ios', {projectRoot: './ios', bundleId: 'com.example.MyApp'}]], // [!code ++]
}),
],
})
```
- `projectRoot` is the folder of your Xcode project, relative to the dev server.
- `bundleId` is the bundle id the agent installs and launches.
The agent then gets four tools, named `ios_*`: build, run, screenshot and logs. The first two ask you first, with a
[Permission card](/docs/usage/approvals). Without options, every tool answers that the plugin is not configured.
With `CONCIV_URL` set, the app uses that address, for example `http://127.0.0.1:4599`. Leave `/widget` off the end.
Without it, the app reads `~/.conciv/dev-endpoint.json`. The engine writes that file when it starts. Otherwise it tries
`http://127.0.0.1` on ports 4599, 8787 and 3000.
`ios_run` passes the address for you. A fixed `port` in your conciv config keeps it the same across restarts. With
`devEndpointDir` set, the engine writes the file elsewhere. Set `CONCIV_URL` in that case.
Call `attach()` in your scene delegate's willConnectTo method, before or after the window becomes key:
```swift title="SceneDelegate.swift"
import UIKit
import ConcivWidget // [!code ++]
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
ConcivWidget.attach() // [!code ++]
}
}
```
For a round native button instead of the mascot, call `ConcivWidget.attach(launcher: .native)`.
- `scheme`: the Xcode scheme to build. Unset, it comes from the end of `bundleId`.
- `simulator`: the simulator to boot. Default `iPhone 17 Pro`.
- `buildMode`: `xcodebuild` (the default) or `swiftc`.
- `developerDir`: the Xcode developer folder. Default `/Applications/Xcode.app/Contents/Developer`.
- `extraSourceDirs`: more Swift source folders to compile.
- `concivUrl`: the engine address the app gets. Default: the engine that runs the tool.
## Next steps [#next-steps]
- **[Use conciv](/docs/usage):** what the agent can do in your app.
- **[Approvals](/docs/usage/approvals):** the ask before a build and a run.
# Next.js (/docs/bundlers/nextjs)
conciv runs in `next dev` through `withConciv` around your config and two instrumentation files.
Copy this prompt into your coding agent. It runs conciv's init command, which makes the same changes as below.
## Add conciv to Next.js [#add-conciv-to-nextjs]
Install `@conciv/it` as a dev dependency:
```package-install
npm install -D @conciv/it
```
Wrap the default export of your config with `withConciv`:
```ts twoslash title="next.config.ts"
import type {NextConfig} from 'next'
import {withConciv} from '@conciv/it/plugin/nextjs' // [!code ++]
const nextConfig: NextConfig = {
reactStrictMode: true,
}
export default withConciv(nextConfig) // [!code ++]
```
Options go in its second argument, as in `withConciv(nextConfig, {harness: 'codex'})`. Learn more in
[Configuration](/docs/reference/configuration).
Then create both instrumentation files next to your `app` or `pages` folder:
```ts twoslash title="instrumentation.ts"
export {register} from '@conciv/it/plugin/nextjs' // <- starts the engine with the dev server
```
```ts twoslash title="instrumentation-client.ts"
import '@conciv/it/plugin/nextjs/widget' // <- adds the conciv button to your pages
```
Next.js reads the instrumentation files from the folder that holds `app` or `pages`. init writes them to the project
root. With routes in src/app or src/pages, move both files into `src/`, or conciv never starts.
Start your dev server with `npm run dev`, open your app, and click the conciv button. Type the 6-digit code your dev
server prints. Learn more in [Logging in](/docs/usage/logging-in).
## What works [#what-works]
- The chat, the page tools and the plugins work as on Vite.
- The [dev server tools](/docs/usage/dev-server) do not. They answer that no dev server is attached. So do plugin
tools that read the dev server, such as the TanStack build errors.
- `next build` and `next start` leave conciv out.
init does not overwrite an instrumentation file that holds something else. It prints a card instead. In
`instrumentation.ts`, call conciv's `register` from your own:
```ts twoslash title="instrumentation.ts"
import {register as registerConciv} from '@conciv/it/plugin/nextjs'
export async function register() {
await registerConciv()
}
```
Next.js gives conciv no hook to stop the engine. The engine ends with the dev server's process. When `next dev` kills its
worker fast, the agent CLI of a live run can outlive it. A larger `NEXT_EXIT_TIMEOUT_MS` gives the worker time to
exit on its own.
## Next steps [#next-steps]
- **[Use conciv](/docs/usage):** what the agent can do in your app.
- **[Configuration](/docs/reference/configuration):** the options `withConciv` takes.
# Rspack (/docs/bundlers/rspack)
conciv runs in an Rspack development build through the plugin from `@conciv/it/plugin/rspack`.
Copy this prompt into your coding agent. It runs conciv's init command, which makes the same changes as below.
## Add conciv to Rspack [#add-conciv-to-rspack]
Install `@conciv/it` as a dev dependency:
```package-install
npm install -D @conciv/it
```
Add the plugin and a development mode to your config:
```js title="rspack.config.js"
const {rspack} = require('@rspack/core')
const conciv = require('@conciv/it/plugin/rspack') // [!code ++]
module.exports = {
mode: 'development', // [!code ++]
plugins: [
new rspack.HtmlRspackPlugin(),
conciv.default(), // [!code ++]
],
}
```
A CommonJS `require` gets the plugin as `.default`. Options go in its one argument. Learn more in [Configuration](/docs/reference/configuration).
Start your dev server with `npx rspack serve`, or a build in watch mode with `--watch`.
Open your app, click the conciv button, and type the 6-digit code your dev server prints.
The development and none modes turn conciv on. The production mode turns it off. So does a config with no `mode`,
because Rspack then builds for production. Passing `--mode development` on the command line works too.
## What works [#what-works]
- The dev server, or a watch build, adds the conciv button to every page and starts the engine.
- A one-off development build adds the button only. The engine does not start.
- The chat, the page tools and the plugins work. The [dev server tools](/docs/usage/dev-server) do not. They answer
that no dev server is attached.
## An ES module config [#an-es-module-config]
In an ES module config, import the plugin and call it directly. init writes this form when your config uses `import`.
```js title="rspack.config.js"
import {rspack} from '@rspack/core'
import conciv from '@conciv/it/plugin/rspack' // [!code ++]
export default {
mode: 'development', // [!code ++]
plugins: [
new rspack.HtmlRspackPlugin(),
conciv(), // [!code ++]
],
}
```
init edits only a config it can read as CommonJS or as an ES module. Otherwise it prints the CommonJS snippet. Add
it as shown above.
The plugin picks the engine port before the first watch build. It builds the widget with that port. When the port is
in use, the plugin takes a free one, with no warning. Learn more in
[Configuration](/docs/reference/configuration#port).
The engine could not start. The reason follows the message in the build output. Stopping the watch, or closing the
compiler, stops the engine.
## Next steps [#next-steps]
- **[Use conciv](/docs/usage):** what the agent can do in your app.
- **[Configuration](/docs/reference/configuration):** the options the plugin takes.
# TanStack Start (/docs/bundlers/tanstack-start)
TanStack Start runs on Vite. conciv joins it as the same `conciv()` Vite plugin, beside `tanstackStart()`.
Copy this prompt into your coding agent. It runs conciv's init command, which makes the same changes as below.
## Add conciv to TanStack Start [#add-conciv-to-tanstack-start]
Install `@conciv/it` as a dev dependency:
```package-install
npm install -D @conciv/it
```
Add `conciv()` to the plugins of your `vite.config.ts`:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import {tanstackStart} from '@tanstack/react-start/plugin/vite'
import viteReact from '@vitejs/plugin-react'
import conciv from '@conciv/it/plugin/vite' // [!code ++]
export default defineConfig({
plugins: [
tanstackStart(),
viteReact(),
conciv(), // [!code ++]
],
})
```
Start your dev server with `npm run dev`, open your app, and click the conciv button. Type the 6-digit code your dev
server prints. Learn more in [Logging in](/docs/usage/logging-in).
## What works [#what-works]
Everything that works on [Vite](/docs/bundlers/vite):
- The widget on every page, server-rendered ones included, and the engine that starts with `vite dev`.
- The [dev server tools](/docs/usage/dev-server): the agent reads your config, URLs and module graph.
- `vite build` leaves conciv out.
## Add the TanStack plugin [#add-the-tanstack-plugin]
The TanStack plugin gives the agent your build errors, your route list and recent server function calls:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import {tanstackStart} from '@tanstack/react-start/plugin/vite'
import viteReact from '@vitejs/plugin-react'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
tanstackStart(),
viteReact(),
conciv({
plugins: ['@conciv/plugin-tanstack'], // [!code ++]
}),
],
})
```
Restart your dev server to load it. Learn more in [TanStack](/docs/usage/tanstack).
The plugin reads your routes from the generated `src/routeTree.gen.ts`. When that file cannot be read, the tool says
so. Start the dev server once, so TanStack Router generates it.
init edits only a config shape it can prove: one `plugins` array in the exported config object. A config built in a
function, as some TanStack Start templates are, can get the snippet instead. Add it as shown above.
## Next steps [#next-steps]
- **[Use conciv](/docs/usage):** what the agent can do in your app.
- **[Examples](/docs/examples):** a TanStack Start app with conciv and its plugins set up.
# Vite (/docs/bundlers/vite)
conciv runs inside the Vite dev server, through the `conciv()` plugin from `@conciv/it`.
Copy this prompt into your coding agent. It runs conciv's init command, which makes the same changes as below.
## Add conciv to Vite [#add-conciv-to-vite]
Install `@conciv/it` as a dev dependency:
```package-install
npm install -D @conciv/it
```
Add `conciv()` to the plugins of your Vite config:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import react from '@vitejs/plugin-react'
import conciv from '@conciv/it/plugin/vite' // [!code ++]
export default defineConfig({
plugins: [
react(),
conciv(), // [!code ++]
],
})
```
Options go in the one argument of `conciv()`. Learn more in [Configuration](/docs/reference/configuration).
Start your dev server with `npm run dev`, open your app, and click the conciv button. Type the 6-digit code your dev
server prints. Learn more in [Logging in](/docs/usage/logging-in).
## What works [#what-works]
Every feature works on Vite:
- The widget on every page the dev server serves, and the engine that starts with `vite dev`.
- The [dev server tools](/docs/usage/dev-server): the agent reads your config, URLs and module graph.
- `vite build` leaves conciv out.
## Astro [#astro]
Astro takes Vite plugins under its `vite` key:
```js title="astro.config.mjs"
import {defineConfig} from 'astro/config'
import conciv from '@conciv/it/plugin/vite' // [!code ++]
export default defineConfig({
vite: {
plugins: [conciv()], // [!code ++]
},
})
```
With Vite DevTools in your plugins, conciv opens in the DevTools dock instead of the corner. It logs in with no
code. Learn more in [Logging in](/docs/usage/logging-in#vite-devtools).
init edits only a config shape it can prove: one `plugins` array in the exported config object. For any other shape
it prints the snippet to paste. Add it as shown above.
## Next steps [#next-steps]
- **[Use conciv](/docs/usage):** what the agent can do in your app.
- **[Configuration](/docs/reference/configuration):** the options `conciv()` takes.
# webpack (/docs/bundlers/webpack)
conciv runs in a webpack development build through the plugin from `@conciv/it/plugin/webpack`.
Copy this prompt into your coding agent. It runs conciv's init command, which makes the same changes as below.
## Add conciv to webpack [#add-conciv-to-webpack]
Install `@conciv/it` as a dev dependency:
```package-install
npm install -D @conciv/it
```
Add the plugin and a development mode to your config:
```js title="webpack.config.js"
const HtmlWebpackPlugin = require('html-webpack-plugin')
const conciv = require('@conciv/it/plugin/webpack') // [!code ++]
module.exports = {
mode: 'development', // [!code ++]
plugins: [
new HtmlWebpackPlugin(),
conciv.default(), // [!code ++]
],
}
```
A CommonJS `require` gets the plugin as `.default`. Options go in its one argument. Learn more in [Configuration](/docs/reference/configuration).
Start your dev server with `npx webpack serve`, or a build in watch mode with `--watch`.
Open your app, click the conciv button, and type the 6-digit code your dev server prints.
The development and none modes turn conciv on. The production mode turns it off. So does a config with no `mode`,
because webpack then builds for production. Passing `--mode development` on the command line works too.
## What works [#what-works]
- The dev server, or a watch build, adds the conciv button to every page and starts the engine.
- A one-off development build adds the button only. The engine does not start.
- The chat, the page tools and the plugins work. The [dev server tools](/docs/usage/dev-server) do not. They answer
that no dev server is attached.
## An ES module config [#an-es-module-config]
In an ES module config, import the plugin and call it directly. init writes this form when your config uses `import`.
```js title="webpack.config.js"
import HtmlWebpackPlugin from 'html-webpack-plugin'
import conciv from '@conciv/it/plugin/webpack' // [!code ++]
export default {
mode: 'development', // [!code ++]
plugins: [
new HtmlWebpackPlugin(),
conciv(), // [!code ++]
],
}
```
init edits only a config it can read as CommonJS or as an ES module. Otherwise it prints the CommonJS snippet. Add
it as shown above.
The plugin picks the engine port before the first watch build. It builds the widget with that port. When the port is
in use, the plugin takes a free one, with no warning. Learn more in
[Configuration](/docs/reference/configuration#port).
The engine could not start. The reason follows the message in the build output. Stopping the watch, or closing the
compiler, stops the engine.
## Next steps [#next-steps]
- **[Use conciv](/docs/usage):** what the agent can do in your app.
- **[Configuration](/docs/reference/configuration):** the options the plugin takes.
# conciv vs terminal agents, MCP browser tools and browser extensions (/docs/comparison)
A coding agent in your terminal, such as Claude Code or Codex, edits your source but cannot see your app. MCP browser
tools, such as Playwright MCP or Chrome DevTools MCP, give an agent a browser to drive. A browser-extension agent, such
as Claude in Chrome, reads and clicks web pages from an extension you install in your browser. conciv puts the agent
inside your running app, in the tab you already have open, and ties what it sees to your source. It needs no browser
extension: your dev server adds the widget to your pages, and the agent reaches the tab through it.
The four are not rivals. conciv runs your terminal agent's own CLI. It can also connect that agent to your open tabs.
## Features [#features]
- built in.
- possible, with set-up or limits.
- not supported.
Facts about other tools are general. Check each tool's own docs for its current options.
### Seeing the app [#seeing-the-app]
| Feature | conciv | Terminal agent | MCP browser tools | Browser extension |
| ------------------------------------------------------------------------ | :-----: | :------------: | :---------------: | :---------------: |
| Reads the rendered page | | | | |
| Works in your open tab, with its state and login | | | | |
| [Point at an element to pin it to the message](/docs/usage/page-control) | | | | |
| [Names the source file of an element](/docs/usage/page-control) | | | | |
| [Reads the dev server's config and module graph](/docs/usage/dev-server) | | | | |
| [Replays what you just did in the page](/docs/usage/live-recorder) | | | | |
| Works on any site, production included | | | | |
| [Works in Firefox as well as Chrome](/docs/requirements) | | | | |
MCP browser tools reach your open tab only if you start them attached to your own browser. conciv names an element's
source file when it can find it. It reads the dev server's module graph on Vite only. The widget is tested in Chromium
and Firefox. Playwright MCP also drives Firefox and WebKit. Claude in Chrome runs in Google Chrome only.
Playwright MCP can save a trace of the steps the agent takes, not of yours. Claude in Chrome can record a workflow you click through, in its classic side panel, so it can repeat it.
### Changing the code [#changing-the-code]
| Feature | conciv | Terminal agent | MCP browser tools | Browser extension |
| --------------------------------------------------------- | :-----: | :------------: | :---------------: | :---------------: |
| Edits your source | | | | |
| [Checks its change in the page](/docs/usage/page-control) | | | | |
| [Runs your tests](/docs/usage/live-tests) | | | | |
| [Asks before risky actions](/docs/usage/approvals) | | | | |
conciv edits your source through your own agent CLI. MCP browser tools edit nothing themselves: the agent that calls
them does, and that agent can check its change in a page when it pairs them. A browser-extension agent works on the
page, not your files; paired with a terminal agent, it tests what that agent built. conciv runs your tests with the
test runner plugin, and asks as a card in the page. A terminal agent asks in the terminal. Claude in Chrome asks
before each action, per site, or checks each action itself, by the mode you pick.
### Set-up and reach [#set-up-and-reach]
| Feature | conciv | Terminal agent | MCP browser tools | Browser extension |
| -------------------------------------------------------- | :--------: | :------------: | :---------------: | :---------------: |
| Needs no browser extension installed | | | | |
| [Uses your own agent CLI and login](/docs/harnesses) | | | | |
| [Works with any framework](/docs/bundlers) | | | | |
| [Extended by your own tools](/docs/plugins) | | | | |
| [Gives your terminal agent your open tabs](/docs/agents) | | | | |
MCP browser tools are not an agent, so they have no CLI or login of their own. A browser-extension agent brings its
own model and account: Claude in Chrome needs a paid Claude plan. conciv works with Vite, Next.js, webpack and Rspack.
It takes your own tools as plugins; a terminal agent takes them through MCP. conciv gives your terminal agent your
open tabs through MCP. MCP browser tools give it a browser of their own to drive, and Claude in Chrome can work with
Claude Code.
## Where each one fits [#where-each-one-fits]
- **A terminal agent** is the right tool for work away from the page: refactors, scripts, backend code.
- **MCP browser tools** fit a page you do not build, a production site, or deep browser data. Chrome DevTools MCP
centres on performance traces, network requests and the console. Playwright MCP drives pages through accessibility
snapshots.
- **A browser-extension agent** fits tasks on sites you do not build, with your logins: internal tools, admin
consoles, forms.
- **conciv** fits work on your own app while it runs: point at it, change it, see it.
## Limits [#limits]
- conciv runs in development builds only. It is not for production sites.
- It needs a supported bundler. Rollup and esbuild do nothing yet.
- On webpack and Rspack, the agent cannot read the dev server's module graph.
- It needs Node 22.19 or newer, and an agent CLI you install and log in to yourself.
- The Pi CLI has no chat in conciv yet.
- The iOS setup is an early alpha, for the simulator only.
See [Requirements](/docs/requirements) for every version.
## Next steps [#next-steps]
- **Try it on your app**: [Getting started](/docs/getting-started).
- **Connect your terminal agent**: [Connect your agents](/docs/agents).
- **See what it can do**: [Use conciv](/docs/usage).
# Packages (/docs/contributing/packages)
This page is for working on conciv itself. An app installs only `@conciv/it`. The repo holds one folder per package
under `packages/`. Each list below names the package to open for one kind of change. A `@conciv/*` package is
published to npm. An `@internal/*` package is never published. It is built into the package that uses it.
## Install conciv in an app [#install-conciv-in-an-app]
- [`@conciv/it`](https://github.com/conciv-dev/conciv/tree/main/packages/it): what an app installs, with the build
plugin for each bundler.
- [`@conciv/cli`](https://github.com/conciv-dev/conciv/tree/main/packages/cli): the CLI, `init` included.
- [`@conciv/unplugin`](https://github.com/conciv-dev/conciv/tree/main/packages/unplugin): how conciv starts with a dev
server, on every bundler. `@conciv/it` wraps it.
## The engine [#the-engine]
- [`@conciv/backend-defaults`](https://github.com/conciv-dev/conciv/tree/main/packages/backend-defaults): the engine,
with its HTTP and rpc surface, login, chat and code mode.
- [`@conciv/backend-app-api`](https://github.com/conciv-dev/conciv/tree/main/packages/backend-app-api): the plugin
host, the tool service, permissions and hooks.
- [`@conciv/backend-plugin-api`](https://github.com/conciv-dev/conciv/tree/main/packages/backend-plugin-api): what a
plugin's engine part imports. Change it only to change the plugin API.
- [`@conciv/backend`](https://github.com/conciv-dev/conciv/tree/main/packages/backend): the shipped engine, and the
plugins it always loads.
- [`@conciv/harness`](https://github.com/conciv-dev/conciv/tree/main/packages/harness): one adapter per agent CLI.
## The widget [#the-widget]
- [`@internal/frontend-defaults`](https://github.com/conciv-dev/conciv/tree/main/packages/frontend-defaults): the
widget shell, with the router, the pane, the composer, sessions and settings.
- [`@internal/frontend-app-api`](https://github.com/conciv-dev/conciv/tree/main/packages/frontend-app-api): plugin
loading in the browser, and what plugins save.
- [`@conciv/frontend-plugin-api`](https://github.com/conciv-dev/conciv/tree/main/packages/frontend-plugin-api): what a
plugin's browser part imports.
- [`@conciv/app`](https://github.com/conciv-dev/conciv/tree/main/packages/app): the shipped widget, its built-in
plugins and the widget bundle.
- [`@conciv/ui-kit-system`](https://github.com/conciv-dev/conciv/tree/main/packages/ui-kit-system),
[`ui-kit-chat`](https://github.com/conciv-dev/conciv/tree/main/packages/ui-kit-chat),
[`ui-kit-chat-tools`](https://github.com/conciv-dev/conciv/tree/main/packages/ui-kit-chat-tools) and
[`ui-kit-terminal`](https://github.com/conciv-dev/conciv/tree/main/packages/ui-kit-terminal): the base parts, the
thread and composer, the tool cards and the terminal.
- [`@conciv/react`](https://github.com/conciv-dev/conciv/tree/main/packages/react),
[`preact`](https://github.com/conciv-dev/conciv/tree/main/packages/preact) and
[`solid`](https://github.com/conciv-dev/conciv/tree/main/packages/solid): the widget as a component, for an app that
places it itself.
## Both sides [#both-sides]
- [`@conciv/protocol`](https://github.com/conciv-dev/conciv/tree/main/packages/protocol): the rpc contract between the
widget and the engine.
- [`@conciv/types`](https://github.com/conciv-dev/conciv/tree/main/packages/types): the wire types and the config
schema. A new conciv option starts here.
- [`@conciv/client`](https://github.com/conciv-dev/conciv/tree/main/packages/client): the browser's connection to the
engine.
- [`@conciv/home`](https://github.com/conciv-dev/conciv/tree/main/packages/home): the per-user registry, so engines,
connected agents and the CLI find each other.
## Plugins [#plugins]
Each plugin is one package under `packages/plugins/`, with its engine part and its browser part together.
- [`@conciv/plugin-page`](https://github.com/conciv-dev/conciv/tree/main/packages/plugins/page): the agent's actions
in an open tab.
- [`@internal/plugin-terminal`](https://github.com/conciv-dev/conciv/tree/main/packages/plugins/terminal): the
session's **Terminal** tab.
- [`@conciv/plugin-test-runner`](https://github.com/conciv-dev/conciv/tree/main/packages/plugins/test-runner): runs
tests into the **Tests** tab.
- [`@conciv/plugin-recorder`](https://github.com/conciv-dev/conciv/tree/main/packages/plugins/recorder): records the
page for the agent.
- [`@conciv/plugin-tanstack`](https://github.com/conciv-dev/conciv/tree/main/packages/plugins/tanstack): TanStack
Router and Start tools.
- [`@conciv/plugin-ios`](https://github.com/conciv-dev/conciv/tree/main/packages/plugins/ios): builds and runs an iOS
app in the simulator.
- [`@conciv/plugin-whiteboard`](https://github.com/conciv-dev/conciv/tree/main/packages/plugins/whiteboard): the
shared canvas over the app.
- [`@conciv/plugin-try-it`](https://github.com/conciv-dev/conciv/tree/main/packages/plugins/try-it): starts a local
engine from the conciv.dev site.
## Tests [#tests]
- [`@conciv/backend-test-utils`](https://github.com/conciv-dev/conciv/tree/main/packages/backend-test-utils): starts
the real engine with a scripted model, for engine and plugin tests.
- [`@internal/frontend-test-utils`](https://github.com/conciv-dev/conciv/tree/main/packages/frontend-test-utils):
renders a plugin's screens, or the whole widget, against a fake or a real engine.
- [`@internal/test-utils`](https://github.com/conciv-dev/conciv/tree/main/packages/test-utils): the fake engine those
renders use.
- [`@conciv/simulation`](https://github.com/conciv-dev/conciv/tree/main/packages/simulation): the engine with a driver
in place of the model. Learn more in [Drive the widget from a script](/docs/recipes/drive-the-widget-from-a-script).
No package may depend on another in a loop, through any dependency field. A test lives in the package whose code it
tests. The repo's `AGENTS.md` holds the full rules.
## Next steps [#next-steps]
- **[Engine and widget](/docs/engine-and-widget):** how the engine and the widget connect.
- **[Plugins](/docs/plugins):** add a feature as a plugin, the usual way to change conciv.
# Engine and widget (/docs/engine-and-widget)
conciv is two programs that your dev server starts together. The engine runs in node and runs the agent. The widget
runs on your page and is the chat you type into.
## What runs where [#what-runs-where]
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv(), // <- starts the engine and adds the widget, in development only
],
})
```
|starts| engine[Engine on 127.0.0.1]
engine -->|runs| harness[Agent CLI: claude, codex, ...]
outside[Agent in your terminal] -->|MCP| engine
end
widget <-->|websocket, after login| engine`}
/>
## Build plugin [#build-plugin]
The build plugin is `@conciv/it` in your bundler config. In development it starts the engine and adds the widget to
every page. A production build leaves both out. Learn more in [Bundlers](/docs/bundlers).
## Engine [#engine]
The engine is a node server inside your dev server's process. It listens on `127.0.0.1` only, on a port of its own. It
answers only browsers that logged in. Learn more in [Logging in](/docs/usage/logging-in).
## Widget [#widget]
The widget is the conciv button, the panel and the quick terminal. It mounts in a shadow root, so your styles and its
styles stay apart. It talks to the engine over one websocket.
## Harness [#harness]
A harness is the agent CLI the engine runs a turn with, such as Claude Code. It runs on your machine, with your own
login. Learn more in [Harnesses](/docs/harnesses).
## A turn [#a-turn]
A turn is one message from you and everything the agent does to answer it:
1. The widget sends your message to the engine over the websocket.
2. The engine runs the harness in your project folder, with conciv's tools added.
3. The agent calls tools. It reads the page, drives it, edits files and runs tests.
4. A risky call waits on a permission card in the panel. It goes on once you answer.
5. Text, tool calls and cards stream back into the panel.
If the socket drops, the widget dials again. A running turn picks up from its last event. Learn more in [Tools and
code mode](/docs/tools-and-code-mode).
## Outside agents [#outside-agents]
An agent CLI in your own terminal can reach the engine too, over MCP. It drives your open tabs with the same tools.
Learn how in [Outside agent](/docs/usage/outside-agent).
## Where state lives [#where-state-lives]
The engine keeps its state in `.conciv/` at your project root. The folder has its own `.gitignore`, which ignores
everything except `settings/`.
- `server.json` holds the engine's port and token. The engine reuses the port on its next start.
- `trusted-browsers.json` lists the browsers that logged in.
- `conciv.db` is a SQLite file. It holds sessions, chat history and saved permission answers.
- `chat-system-prompt.txt` is the prompt the engine gives the agent, written on every start.
- `mcp-endpoint.json` holds the engine's MCP address. The engine writes it on every start.
- `claude-connect/` holds the Claude Code plugin that `init` sets up. Its bridge reads `mcp-endpoint.json`.
- `settings/` holds project settings saved from the widget. Git does not ignore it, so you can commit it.
- `bin/conciv` is the conciv command. It comes first on the `PATH` of the agents the engine starts.
Set `stateRoot` to keep `.conciv/` somewhere else. Learn more in
[Configuration](/docs/reference/configuration#stateroot).
## Next steps [#next-steps]
- **[Sessions](/docs/sessions):** what a conversation holds, and where it is kept.
- **[Tools and code mode](/docs/tools-and-code-mode):** how the agent calls conciv's tools.
- **[Agents and permissions](/docs/agents-and-permissions):** what decides when a card asks you.
# Examples (/docs/examples)
The conciv repo has two example apps with conciv already set up. Run one to try every feature, the plugins included,
on a real app.
## Available examples [#available-examples]
| Example | What it shows | Source |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| TanStack Start | Vite, with the test runner, TanStack, recorder and whiteboard plugins, a project plugin, and `Alt+k` for the quick terminal. | [View source](https://github.com/conciv-dev/conciv/tree/main/apps/examples/tanstack-start) |
| Next.js | `withConciv`, with the test runner, TanStack and whiteboard plugins. | [View source](https://github.com/conciv-dev/conciv/tree/main/apps/examples/nextjs-app) |
## Local development [#local-development]
Clone the repo and install:
```bash title="Terminal"
git clone https://github.com/conciv-dev/conciv.git
cd conciv
pnpm install # <- the repo pins its pnpm version, and needs Node 26 or newer
```
Then start one example:
```bash title="Terminal"
pnpm turbo run dev --filter=tanstack-start-example # <- or --filter=nextjs-app
```
The first run builds the conciv packages the example uses, then starts its dev server. It prints the address to open.
Click the conciv button. Type the code the dev server prints in its terminal. Then ask the agent about the page:
```text title="Prompt"
What is on this page, and which file renders it?
```
A few things to notice:
- The TanStack Start example's `conciv/plugins/deploy` folder is a project plugin. conciv loads it with no config
entry.
- The examples load their plugins from the repo by folder path. Your own app lists published plugins by package name,
as in [Add plugins](/docs/usage/add-plugins).
- The chat runs a real agent CLI, so it must be installed and logged in.
## Next steps [#next-steps]
- **Add conciv to your own app**: [Getting started](/docs/getting-started).
- **Try it without an app**: the [Playground](/docs/playground) plays each feature in your browser.
- **Learn the features**: [Use conciv](/docs/usage), feature by feature.
# Getting started (/docs/getting-started)
conciv puts your coding agent inside the app you are running, where it reads the page you are on and edits the source
that renders it.
New here? [What is conciv](/docs) shows how it works.
## Quick start [#quick-start]
Then open the conciv panel in your app and ask about the page you are on:
## Use conciv [#use-conciv]
## Build your own [#build-your-own]
## Work with agents [#work-with-agents]
## Manual setup [#manual-setup]
The prompt runs these steps for you. To do them by hand:
### Installation [#installation]
With pnpm, yarn or bun, run it with `pnpm dlx`, `yarn dlx` or `bunx` instead of `npx`.
init asks what to set up and shows the plan. It writes nothing until you say yes. What init changes:
- It adds `@conciv/it` to your dev dependencies.
- It wires conciv into your bundler config.
- It adds a conciv section to `AGENTS.md`, so your agent knows the conciv commands. With Claude Code, `CLAUDE.md`
gets it too.
- It installs the conciv plugin for Claude Code, when Claude Code is on your machine.
- It connects Claude Code, Codex, Gemini CLI and opencode, when it finds them, so the agent in your terminal can
drive your open tabs.
- It adds the `@conciv/skills` docs pack, only if you check that box.
init writes the two instrumentation files to the project root. Next.js reads them from the folder that holds your
routes. If your routes live in `src/`, move both files there.
Each bundler has its own page with the manual setup and its edge cases: [Vite](/docs/bundlers/vite),
[Next.js](/docs/bundlers/nextjs), [webpack](/docs/bundlers/webpack), [Rspack](/docs/bundlers/rspack) and
[TanStack Start](/docs/bundlers/tanstack-start).
init checks your project first, and stops with one of these messages:
- `no package.json here: run init from your app directory`
- `uncommitted changes: commit first or pass --force`
- `Non-interactive terminal: re-run with --yes or --dry-run`
Pressing Ctrl-C while init runs puts your config back as it was. Every flag is in the
[CLI reference](/docs/reference/cli).
### Start your dev server [#start-your-dev-server]
Start your dev server the way you always do. conciv starts with it. It adds a conciv button to the corner of every
page.
```bash title="Terminal"
npm run dev
```
A few things to notice:
- conciv runs in dev builds only. A production build leaves it out.
- The chat runs an agent CLI on your machine, `claude` by default. It must be on the `PATH` of the shell that starts
your dev server, and logged in. See [Connect your agents](/docs/agents) for the others.
### Log in [#log-in]
The engine can read your project and run commands, so it answers only browsers you let in. Click the conciv button.
Your dev server prints a box with a 6-digit code:
```text title="Dev server terminal"
╭──────────────────────────────────────────────────────╮
│ conciv: a browser asks to connect to this engine │
│ From: Chrome 142 | macOS at http://localhost:5173 │
│ Code: 482913 │
│ Link: http://localhost:5173/#conciv_otp=482913 │
│ Expires: 10:42:07 │
╰──────────────────────────────────────────────────────╯
```
Type the code in the panel, or open the link. You log in once per browser. Learn more in
[Logging in](/docs/usage/logging-in).
### Ask about the page [#ask-about-the-page]
Open the panel and ask about the page you have open. The agent reads the rendered page first, then finds the file
that renders it.
```text title="Prompt"
What is on this page, and which file renders it?
```
A few things to notice:
- The crosshair beside the composer pins an element to your message, with its source file when conciv finds it.
- When the agent edits your source, your dev server reloads the page.
- A risky action shows a card first: Allow once, Allow always or Deny.
# Harnesses (/docs/harnesses)
A harness is the agent CLI that answers in the chat. conciv runs it on your machine, in your project folder, with your
own login, models and settings.
## Pick a harness [#pick-a-harness]
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
harness: 'codex', // <- a new session starts with Codex; the default is claude
}),
],
})
```
`harness` is one of `claude`, `codex`, `opencode`, `gemini-cli` or `pi`. The full comparison is at the [end of the
page](#what-each-one-can-do).
Each harness keeps its own login and settings, and conciv reuses them. Pick the one you already work with.
## Install and log in [#install-and-log-in]
conciv does not install the CLI or log you in. Do both first, in your own terminal. For Claude Code, run `claude`, log
in when it asks, then quit. conciv finds the CLI on the `PATH` of the process that started your dev server.
## Switch in a session [#switch-in-a-session]
The model menu in the panel lists the harness you set. It also lists every other harness whose CLI is on your `PATH`.
Pick a model there to switch the session. Learn more in [Sessions](/docs/sessions#switching-harness).
## Set it for one run [#set-it-for-one-run]
`CONCIV_HARNESS` picks a harness without a config edit:
```bash title="Terminal"
CONCIV_HARNESS=opencode pnpm dev
```
`harness` in the config wins over the variable.
## Claude [#claude]
conciv runs Claude Code in its `auto` permission mode. It adds ask rules for risky Bash commands, and those asks
become permission cards. conciv's instructions come after Claude Code's own system prompt. Claude gives you the most:
`/` commands, image attachments, permission cards and a **Terminal** tab.
## Codex [#codex]
conciv runs Codex in the `workspace-write` sandbox, with `approvalPolicy: 'never'`. It never shows a permission card.
Its sandbox limits what it can touch instead.
## Gemini CLI [#gemini-cli]
conciv runs Gemini CLI over ACP, as `gemini --acp -m `. The default model is `gemini-3-pro-preview`. Its asks
show as permission cards.
## OpenCode [#opencode]
OpenCode chats in the panel. It can ask for permission, but its asks do not reach conciv yet. No card shows.
## Pi [#pi]
Pi has no chat in conciv yet. Its past sessions still show in the session list. A turn with it ends with "pi is not
installed or not yet supported".
## What each one can do [#what-each-one-can-do]
conciv generates this table from its harness registry.
**Compress the conversation** works on every harness. A harness with no compaction of its own gets a prompt to sum up
the conversation instead.
A `harness` value conciv does not know stops the engine with `conciv: unknown harness ""`. The message lists the
known ids. Learn more in [Troubleshooting](/docs/reference/troubleshooting#unknown-harness).
## Next steps [#next-steps]
- **[Agents and permissions](/docs/agents-and-permissions):** what each harness asks, and how you answer.
- **[Sessions](/docs/sessions):** what a harness transcript is, and how a session switches harness.
- **[Agents](/docs/agents):** drive conciv from your own terminal agent instead.
# What is conciv (/docs)
An agent in a terminal works on files it cannot see rendered. You describe the page to it, then copy errors and markup
back and forth. conciv adds a panel to your app in development. The agent there reads the page you are on, drives it,
and edits the source that renders it. With the test runner plugin, it runs your tests too. It uses the agent CLI
you already have, on your own machine.
Reach for conciv when:
- You want to point at something on the page and say "change this".
- A bug only shows in the running app, with its real data and state.
- You want the agent to check its own change in the browser before it says it is done.
- You want the agent in your terminal to see and drive the tab you have open.
# Playground (/docs/playground)
A playground is the real conciv panel, playing a scripted session in your browser. Nothing runs on a server. You need no
agent CLI. Each one also sits on the page that explains it.
## Available playgrounds [#available-playgrounds]
### First session [#first-session]
A question about the page, a change, and the agent checking the result.
### Ask about the page [#ask-about-the-page]
The agent reads the open page and names the file that renders it. From [Getting started](/docs/getting-started).
### Send and queue [#send-and-queue]
A message sent while the agent works waits in the queue, then goes next.
### Point and change [#point-and-change]
Pin an element with the crosshair, then ask for a change to it.
### Allow once [#allow-once]
A risky action asks first. Allow once answers it for this call only.
### Run the tests [#run-the-tests]
A test run streams into the Tests tab, then lands as a card in the thread.
### Quick terminal [#quick-terminal]
The hotkey opens the quick terminal, and a command runs in your project.
### Build errors [#build-errors]
The agent reads the dev server's build errors and fixes the source.
### Your first plugin's card [#your-first-plugins-card]
A tool call shows the generic card first, then the card your plugin draws. From
[Build your first plugin](/docs/plugins/first-plugin).
### Direct call or code mode [#direct-call-or-code-mode]
The same tool, called directly and from inside a code-mode script. From
[Tools and code mode](/docs/tools-and-code-mode).
### A plugin's permission card [#a-plugins-permission-card]
A plugin tool asks for permission, and the card shows its question.
### A panel tab [#a-panel-tab]
A plugin adds its own tab to the panel.
## Local development [#local-development]
Prefer a real app? The conciv repo has two example apps with conciv already set up. Clone the repo and install:
```bash title="Terminal"
git clone https://github.com/conciv-dev/conciv.git
cd conciv
pnpm install
```
Then start an example:
```bash title="Terminal"
pnpm turbo run dev --filter=tanstack-start-example # <- or --filter=nextjs-app
```
- The repo pins its pnpm version. It needs Node 26 or newer.
- The first run builds the conciv packages the example uses. It then prints the address to open.
- These examples run a real agent CLI, so it must be installed and logged in.
Learn more in [Examples](/docs/examples).
## Write a playground [#write-a-playground]
A playground is one script file and one line of MDX. The script lists what the reader types and what the agent answers:
```ts title="apps/site/src/playground/scripts/chat/hello.ts"
import type {PlaygroundScript} from '../../script'
export default {
title: 'Say hello',
screen: 'panel', // <- or 'quick' for the quick terminal
plugins: [], // <- browser parts to load, such as 'test-runner'
turns: [
{
prompt: 'Rename the heading to Hello.', // <- typed into the real composer
replies: [
{
kind: 'tool',
name: 'page_settext',
input: {selector: 'h1', text: 'Hello'},
result: {ok: true},
page: {heading: 'Hello'},
},
{kind: 'text', text: 'The heading says **Hello** now.'},
],
},
],
} satisfies PlaygroundScript
```
Add it to `playground-scripts.ts`, then put it on a page:
```mdx title="content/docs/usage/chat.mdx"
```
A few things to notice:
- A tool reply can ask first (`ask`), change the demo page (`page`), or run from code mode (`mode: 'code'`).
- The script is typed. A change to the widget's contract fails the site's typecheck, not the page.
- Under reduced motion, each step jumps to its end. On a narrow screen, the page shows the transcript only.
## Next steps [#next-steps]
- **Add it to your app**: [Getting started](/docs/getting-started).
- **Run an example**: [Examples](/docs/examples).
# Build your first plugin (/docs/plugins/first-plugin)
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:
1. Write the tool in `conciv/plugins/project-version`.
2. Ask the agent, and see the generic card.
3. Draw the calls as your own card.
4. Build the card, and see it in the chat.
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](https://effect.website): 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.
## Installation [#installation]
You need a project where conciv already runs. See [Getting started](/docs/getting-started). Then install what the
engine part imports:
```package-install
npm install -D @conciv/backend-plugin-api zod
```
For the Effect style, also install Effect and the package that holds the `Tool` error type:
```package-install
npm install -D effect @conciv/protocol
```
## Write the tool [#write-the-tool]
A plugin is a folder in `conciv/plugins`. Its engine part is `server.ts`. Make the folder and the file:
```ts twoslash title="conciv/plugins/project-version/server.ts" tab="Promise" tab-group="plugin-api"
import {readFile} from 'node:fs/promises'
import path from 'node:path'
import {z} from 'zod'
import {Plugin, Tool} from '@conciv/backend-plugin-api'
const Manifest = z.object({name: z.string(), version: z.string()})
async function readManifest(directory: string) {
try {
return Manifest.parse(JSON.parse(await readFile(path.join(directory, 'package.json'), 'utf8')))
} catch {
throw Tool.toolError({message: 'package.json is missing, or has no name and version.'}) // <- what the agent reads
}
}
export default Plugin.define({
id: 'project-version', // <- the plugin's name in conciv
async setup(ctx) {
await ctx.tool.transform((tools) => {
tools.add({
name: 'project_version',
description: "Read the project's name and version from its package.json.", // <- the agent reads this
input: z.object({}),
output: Manifest,
options: {codemode: false}, // <- a direct tool: each call gets its own card
execute: async () => ({output: await readManifest(ctx.location.directory)}),
})
})
},
})
```
```ts twoslash title="conciv/plugins/project-version/server.ts" tab="Effect" tab-group="plugin-api"
import {readFile} from 'node:fs/promises'
import path from 'node:path'
import {Effect} from 'effect'
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api/effect'
import * as Tool from '@conciv/protocol/schema/tool'
const Manifest = z.object({name: z.string(), version: z.string()})
export default Plugin.define({
id: 'project-version', // <- the plugin's name in conciv
effect: (ctx) =>
ctx.tool.transform((tools) => {
tools.add({
name: 'project_version',
description: "Read the project's name and version from its package.json.", // <- the agent reads this
input: z.object({}),
output: Manifest,
options: {codemode: false}, // <- a direct tool: each call gets its own card
execute: () =>
Effect.tryPromise({
try: async () =>
Manifest.parse(JSON.parse(await readFile(path.join(ctx.location.directory, 'package.json'), 'utf8'))),
catch: () => Tool.toolError({message: 'package.json is missing, or has no name and version.'}),
}).pipe(Effect.map((manifest) => ({output: manifest}))),
})
}),
})
```
A few things to notice:
- `setup` (Promise) or `effect` (Effect) runs once, when the engine loads the plugin. `ctx` is what the engine
gives it. `ctx.location.directory` is your project folder.
- `input` and `output` are 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.toolError` message.
- `codemode: false` makes it a direct tool. Learn more in
[Tools and code mode](/docs/tools-and-code-mode).
## Ask the agent [#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:
```text title="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](/docs/usage/add-plugins).
## Draw the card [#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:
```package-install
npm install -D @conciv/frontend-plugin-api solid-js vite vite-plugin-solid
```
Add `plugin-experimental.tsx` next to `server.ts`:
```tsx twoslash title="conciv/plugins/project-version/plugin-experimental.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// ---cut---
import {Plugin, ToolRegistry} from '@conciv/frontend-plugin-api'
import {z} from 'zod'
const Manifest = z.object({name: z.string(), version: z.string()})
function readManifest(output: string | undefined) {
try {
return Manifest.safeParse(JSON.parse(output ?? '')).data
} catch {
return undefined // <- a denied or cancelled call has text, not JSON
}
}
export default Plugin.define({
setup(ctx) {
ctx.add(ToolRegistry, {
name: 'project_version', // <- the tool this card draws
render: (props) => {
const manifest = () => readManifest(props.output)
// ^?
return (
{manifest()
? `${manifest()?.name} ${manifest()?.version}`
: props.output === undefined
? 'Reading package.json'
: 'No version to show'}
)
},
})
},
})
```
Install the React bridge:
```package-install
npm install -D @conciv/react @conciv/frontend-plugin-api zod
```
Add the card to your app:
```tsx twoslash title="src/conciv/project-version.tsx"
// @jsx: react-jsx
// @jsxImportSource: react
// ---cut---
import {ToolRegistry, type Plugin, type ToolProps} from '@conciv/frontend-plugin-api'
import {reactRender} from '@conciv/react'
import {z} from 'zod'
const Manifest = z.object({name: z.string(), version: z.string()})
function readManifest(output: string | undefined) {
try {
return Manifest.safeParse(JSON.parse(output ?? '')).data
} catch {
return undefined // <- a denied or cancelled call has text, not JSON
}
}
function ProjectVersionCard(props: ToolProps) {
const manifest = readManifest(props.output)
// ^?
if (manifest) return
{`${manifest.name} ${manifest.version}`}
return
{props.output === undefined ? 'Reading package.json' : 'No version to show'}
}
export const projectVersion: Plugin.Setup = (ctx) => {
ctx.add(ToolRegistry, {
name: 'project_version', // <- the tool this card draws
render: reactRender(ProjectVersionCard),
})
}
```
Install the Preact bridge:
```package-install
npm install -D @conciv/preact @conciv/frontend-plugin-api zod
```
Add the card to your app:
```tsx twoslash title="src/conciv/project-version.tsx"
// @jsx: react-jsx
// @jsxImportSource: preact
// ---cut---
import {ToolRegistry, type Plugin, type ToolProps} from '@conciv/frontend-plugin-api'
import {preactRender} from '@conciv/preact'
import {z} from 'zod'
const Manifest = z.object({name: z.string(), version: z.string()})
function readManifest(output: string | undefined) {
try {
return Manifest.safeParse(JSON.parse(output ?? '')).data
} catch {
return undefined // <- a denied or cancelled call has text, not JSON
}
}
function ProjectVersionCard(props: ToolProps) {
const manifest = readManifest(props.output)
// ^?
if (manifest) return
{`${manifest.name} ${manifest.version}`}
return
{props.output === undefined ? 'Reading package.json' : 'No version to show'}
}
export const projectVersion: Plugin.Setup = (ctx) => {
ctx.add(ToolRegistry, {
name: 'project_version', // <- the tool this card draws
render: preactRender(ProjectVersionCard),
})
}
```
Install 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:
```package-install
npm install -D @conciv/frontend-plugin-api solid-js vite vite-plugin-solid
```
Add `plugin-experimental.ts` next to `server.ts`:
```ts twoslash title="conciv/plugins/project-version/plugin-experimental.ts"
import {mountRender, Plugin, ToolRegistry, type ToolProps} from '@conciv/frontend-plugin-api'
import {z} from 'zod'
const Manifest = z.object({name: z.string(), version: z.string()})
function describeCall(output: string | undefined) {
try {
const manifest = Manifest.parse(JSON.parse(output ?? ''))
return `${manifest.name} ${manifest.version}`
} catch {
return output === undefined ? 'Reading package.json' : 'No version to show'
}
}
export default Plugin.define({
setup(ctx) {
ctx.add(ToolRegistry, {
name: 'project_version', // <- the tool this card draws
render: mountRender((element, props) => {
const line = element.appendChild(document.createElement('p'))
const stop = props.subscribe(() => {
line.textContent = describeCall(props.current().output) // <- runs now, and on every change
})
return () => {
stop()
line.remove()
}
}),
})
},
})
```
A few things to notice:
- `render` draws one call. It runs again as the call moves on. `props.output` is empty until the call ends.
- A failed call draws the error card, not `render`.
- In Solid, the browser part's `Plugin.define` has no `id`. It takes the engine part's.
- In Solid, `ctx.ui.Icon` draws an icon from the widget's set. The names are [lucide](https://lucide.dev/icons) names.
- `reactRender`, `preactRender` and `mountRender` each turn your component into the `render` the registry takes.
## Build or wire the browser part [#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:
```ts twoslash title="conciv/plugins/project-version/vite.config.ts"
import {defineConfig} from 'vite'
import {experimental} from '@conciv/frontend-plugin-api/vite'
export default defineConfig({
root: import.meta.dirname, // <- entry and outFile resolve from the plugin folder
publicDir: false,
plugins: [experimental({entry: 'plugin-experimental.tsx', outFile: 'plugin-experimental.cjs'})],
})
```
Build it from your project folder:
```bash title="terminal"
npx vite build --config conciv/plugins/project-version/vite.config.ts
```
Run the build again after each change to the browser part, then reload your app.
The card draws through `` from `@conciv/react`. Render it once in your app, and give it the card under
the plugin's id:
```tsx twoslash title="src/app.tsx"
// @jsx: react-jsx
// @jsxImportSource: react
// @filename: src/conciv/project-version.tsx
import type {Plugin} from '@conciv/frontend-plugin-api'
export const projectVersion: Plugin.Setup = () => {}
// @filename: src/app.tsx
// ---cut---
import {ConcivWidget} from '@conciv/react'
import {projectVersion} from './conciv/project-version'
const plugins = [[{id: 'project-version', windowEntry: async () => ({default: projectVersion})}, {}]] as const
export function App() {
return (
<>
Your app
>
)
}
```
`` mounts the widget itself, so turn off the widget the bundler plugin adds. Set `widget: false`:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [conciv({widget: false})], // <- keep your framework's plugin next to it
})
```
A card drawn outside a `` throws. Use the engine part's id, here `project-version`.
The card draws through `` from `@conciv/preact`. Render it once in your app, and give it the card under
the plugin's id:
```tsx twoslash title="src/app.tsx"
// @jsx: react-jsx
// @jsxImportSource: preact
// @filename: src/conciv/project-version.tsx
import type {Plugin} from '@conciv/frontend-plugin-api'
export const projectVersion: Plugin.Setup = () => {}
// @filename: src/app.tsx
// ---cut---
import {ConcivWidget} from '@conciv/preact'
import {projectVersion} from './conciv/project-version'
const plugins = [[{id: 'project-version', windowEntry: async () => ({default: projectVersion})}, {}]] as const
export function App() {
return (
<>
Your app
>
)
}
```
`` mounts the widget itself, so turn off the widget the bundler plugin adds. Set `widget: false`:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [conciv({widget: false})], // <- keep your framework's plugin next to it
})
```
A card drawn outside a `` throws. Use the engine part's id, here `project-version`.
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:
```ts twoslash title="conciv/plugins/project-version/vite.config.ts"
import {defineConfig} from 'vite'
import {experimental} from '@conciv/frontend-plugin-api/vite'
export default defineConfig({
root: import.meta.dirname, // <- entry and outFile resolve from the plugin folder
publicDir: false,
plugins: [experimental({entry: 'plugin-experimental.ts', outFile: 'plugin-experimental.cjs'})],
})
```
Build it from your project folder:
```bash title="terminal"
npx vite build --config conciv/plugins/project-version/vite.config.ts
```
Run the build again after each change to the browser part, then reload your app.
Reload your app and ask again. The call now shows your card with your project's name and version.
## Next steps [#next-steps]
- **[Add a tool](/docs/plugins/guides/tool)**: namespaces, failures, and code mode.
- **[Share an RPC method](/docs/plugins/guides/rpc)**: let the browser part call the engine part.
- **[Test your plugin](/docs/plugins/guides/testing)**: run this plugin on a real engine in a test.
# Add a panel (/docs/plugins/guides/panel)
A panel adds a tab next to the chat, for something your plugin shows all the time: a list, a log, a live run. You
write the browser part in Solid, React, Preact or plain DOM. Pick a tab: the site keeps your pick on every page.
In React and Preact the panel lives in your app. Give it to `` as in
[Build your first plugin](/docs/plugins/first-plugin#build-or-wire-the-browser-part). The widget's `ctx.ui` parts,
such as `Icon`, are Solid components. The other tabs draw plain elements instead.
## Add a tab [#add-a-tab]
Add the panel in your plugin's browser part:
```tsx twoslash title="conciv/plugins/plant-shelf/plugin-experimental.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// ---cut---
import {Panel, Plugin, type PanelTab} from '@conciv/frontend-plugin-api'
export default Plugin.define({
setup(ctx) {
const shelf: PanelTab = {
id: 'shelf',
title: 'Shelf', // <- the tab's name, wherever the widget needs text
pinned: true, // <- always in the strip
label: () => (
<>
Shelf
>
), // <- what the strip draws; without it, the title
}
ctx.add(Panel, {
id: 'shelf',
region: 'pane', // <- required, and the only region today
list: () => [shelf],
render: (props) =>
Plants in {props.session.directory}
,
})
},
})
```
```tsx twoslash title="src/conciv/plant-shelf.tsx"
// @jsx: react-jsx
// @jsxImportSource: react
// ---cut---
import {Panel, type PanelProps, type PanelTab, type Plugin} from '@conciv/frontend-plugin-api'
import {reactRender} from '@conciv/react'
const shelf: PanelTab = {
id: 'shelf',
title: 'Shelf', // <- the tab's name, wherever the widget needs text
pinned: true, // <- always in the strip
}
function ShelfPanel(props: PanelProps) {
return
Plants in {props.session.directory}
}
export const plantShelf: Plugin.Setup = (ctx) => {
ctx.add(Panel, {
id: 'shelf',
region: 'pane', // <- required, and the only region today
list: () => [shelf],
render: reactRender(ShelfPanel),
})
}
```
```tsx twoslash title="src/conciv/plant-shelf.tsx"
// @jsx: react-jsx
// @jsxImportSource: preact
// ---cut---
import {Panel, type PanelProps, type PanelTab, type Plugin} from '@conciv/frontend-plugin-api'
import {preactRender} from '@conciv/preact'
const shelf: PanelTab = {
id: 'shelf',
title: 'Shelf', // <- the tab's name, wherever the widget needs text
pinned: true, // <- always in the strip
}
function ShelfPanel(props: PanelProps) {
return
Plants in {props.session.directory}
}
export const plantShelf: Plugin.Setup = (ctx) => {
ctx.add(Panel, {
id: 'shelf',
region: 'pane', // <- required, and the only region today
list: () => [shelf],
render: preactRender(ShelfPanel),
})
}
```
```ts twoslash title="conciv/plugins/plant-shelf/plugin-experimental.ts"
import {mountRender, Panel, Plugin, type PanelProps, type PanelTab} from '@conciv/frontend-plugin-api'
const shelf: PanelTab = {
id: 'shelf',
title: 'Shelf', // <- the tab's name, wherever the widget needs text
pinned: true, // <- always in the strip
}
export default Plugin.define({
setup(ctx) {
ctx.add(Panel, {
id: 'shelf',
region: 'pane', // <- required, and the only region today
list: () => [shelf],
render: mountRender((element, props) => {
const line = element.appendChild(document.createElement('p'))
const stop = props.subscribe(() => {
line.textContent = `Plants in ${props.current().session.directory}` // <- runs now, and on every change
})
return () => {
stop()
line.remove()
}
}),
})
},
})
```
A few things to notice:
- `title` is the tab's name. The strip draws `label` when you give one, and the title when you do not.
- `list` returns the tabs to show. It runs again when what it reads changes. Return a pinned tab every time.
- `render` draws a tab's content once. Your component updates itself from then on.
- `props.session` is the session on screen. Read it where you use it. It changes without a remount.
Build or wire it as in [Build or wire the browser part](/docs/plugins/first-plugin#build-or-wire-the-browser-part),
then reload.
## Show a tab only some of the time [#show-a-tab-only-some-of-the-time]
Return the tab from `list` only when it applies:
```tsx twoslash title="conciv/plugins/plant-shelf/plugin-experimental.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// ---cut---
import {Panel, Plugin, type PanelTab} from '@conciv/frontend-plugin-api'
export default Plugin.define({
setup(ctx) {
const report: PanelTab = {id: 'report', title: 'Report'}
ctx.add(Panel, {
id: 'report',
region: 'pane',
list: (input) => (input.open.includes('report') ? [report] : []), // <- open: your tabs the user has open
render: () =>
The last report
,
})
},
})
```
```tsx twoslash title="src/conciv/plant-shelf.tsx"
// @jsx: react-jsx
// @jsxImportSource: react
// ---cut---
import {Panel, type PanelTab, type Plugin} from '@conciv/frontend-plugin-api'
import {reactRender} from '@conciv/react'
const report: PanelTab = {id: 'report', title: 'Report'}
function Report() {
return
The last report
}
export const plantShelf: Plugin.Setup = (ctx) => {
ctx.add(Panel, {
id: 'report',
region: 'pane',
list: (input) => (input.open.includes('report') ? [report] : []), // <- open: your tabs the user has open
render: reactRender(Report),
})
}
```
```tsx twoslash title="src/conciv/plant-shelf.tsx"
// @jsx: react-jsx
// @jsxImportSource: preact
// ---cut---
import {Panel, type PanelTab, type Plugin} from '@conciv/frontend-plugin-api'
import {preactRender} from '@conciv/preact'
const report: PanelTab = {id: 'report', title: 'Report'}
function Report() {
return
The last report
}
export const plantShelf: Plugin.Setup = (ctx) => {
ctx.add(Panel, {
id: 'report',
region: 'pane',
list: (input) => (input.open.includes('report') ? [report] : []), // <- open: your tabs the user has open
render: preactRender(Report),
})
}
```
```ts twoslash title="conciv/plugins/plant-shelf/plugin-experimental.ts"
import {mountRender, Panel, Plugin, type PanelProps, type PanelTab} from '@conciv/frontend-plugin-api'
const report: PanelTab = {id: 'report', title: 'Report'}
export default Plugin.define({
setup(ctx) {
ctx.add(Panel, {
id: 'report',
region: 'pane',
list: (input) => (input.open.includes('report') ? [report] : []), // <- open: your tabs the user has open
render: mountRender((element) => {
const line = element.appendChild(document.createElement('p'))
line.textContent = 'The last report'
return () => line.remove()
}),
})
},
})
```
A tab that is not pinned shows only while the user has it open. When they close it, it leaves `input.open`. Build or
wire it as in [Build or wire the browser part](/docs/plugins/first-plugin#build-or-wire-the-browser-part), then
reload.
## Load data into the tab [#load-data-into-the-tab]
Read from your engine part inside `render`. In Solid, use the widget's query hooks from `@conciv/client`, so the
data shares the widget's cache. The tutorial did not install it. The widget provides it at run time, and the install
gives your editor its types:
```package-install
npm install -D @conciv/client
```
Those hooks are Solid hooks. The other tabs call the method themselves:
```tsx twoslash title="conciv/plugins/plant-shelf/plugin-experimental.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// @filename: rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {count: {input: Plant, output: Stock}},
events: {},
})
// @filename: plugin-experimental.tsx
// ---cut---
import {useQuery} from '@conciv/client'
import {Panel, Plugin, type PanelTab} from '@conciv/frontend-plugin-api'
import {Shelf} from './rpc'
export default Plugin.define({
setup(ctx) {
const shelf: PanelTab = {id: 'shelf', title: 'Shelf', pinned: true}
ctx.add(Panel, {
id: 'shelf',
region: 'pane',
list: () => [shelf],
render: () => {
const ferns = useQuery(() => ({
queryKey: ['plant-shelf', 'fern'], // <- start with your plugin's id, so keys never clash
queryFn: () => ctx.client.rpc(Shelf).count({plant: 'fern'}),
}))
return
},
})
},
})
```
```tsx twoslash title="src/conciv/plant-shelf.tsx"
// @jsx: react-jsx
// @jsxImportSource: react
// @filename: conciv/plugins/plant-shelf/rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {count: {input: Plant, output: Stock}},
events: {},
})
// @filename: src/conciv/plant-shelf.tsx
// ---cut---
import {Suspense, use, useState} from 'react'
import {Panel, type PanelTab, type Plugin} from '@conciv/frontend-plugin-api'
import {reactRender} from '@conciv/react'
import {Shelf} from '../../conciv/plugins/plant-shelf/rpc'
const shelf: PanelTab = {id: 'shelf', title: 'Shelf', pinned: true}
function FernCount(props: {readonly stock: Promise<{readonly count: number} | undefined>}) {
const stock = use(props.stock) // <- suspends until the call ends
return
{stock ? `${stock.count} ferns` : 'The shelf did not answer'}
}
export const plantShelf: Plugin.Setup = (ctx) => {
function ShelfPanel() {
const [stock] = useState(() =>
ctx.client
.rpc(Shelf)
.count({plant: 'fern'})
.catch(() => undefined),
) // <- one call each time the tab opens
return (
Counting
}>
)
}
ctx.add(Panel, {id: 'shelf', region: 'pane', list: () => [shelf], render: reactRender(ShelfPanel)})
}
```
```tsx twoslash title="src/conciv/plant-shelf.tsx"
// @jsx: react-jsx
// @jsxImportSource: preact
// @filename: conciv/plugins/plant-shelf/rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {count: {input: Plant, output: Stock}},
events: {},
})
// @filename: src/conciv/plant-shelf.tsx
// ---cut---
import {Suspense, use} from 'preact/compat'
import {useState} from 'preact/hooks'
import {Panel, type PanelTab, type Plugin} from '@conciv/frontend-plugin-api'
import {preactRender} from '@conciv/preact'
import {Shelf} from '../../conciv/plugins/plant-shelf/rpc'
const shelf: PanelTab = {id: 'shelf', title: 'Shelf', pinned: true}
function FernCount(props: {readonly stock: Promise<{readonly count: number} | undefined>}) {
const stock = use(props.stock) // <- suspends until the call ends
return
{stock ? `${stock.count} ferns` : 'The shelf did not answer'}
}
export const plantShelf: Plugin.Setup = (ctx) => {
function ShelfPanel() {
const [stock] = useState(() =>
ctx.client
.rpc(Shelf)
.count({plant: 'fern'})
.catch(() => undefined),
) // <- one call each time the tab opens
return (
Counting}>
)
}
ctx.add(Panel, {id: 'shelf', region: 'pane', list: () => [shelf], render: preactRender(ShelfPanel)})
}
```
```ts twoslash title="conciv/plugins/plant-shelf/plugin-experimental.ts"
// @filename: rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {count: {input: Plant, output: Stock}},
events: {},
})
// @filename: plugin-experimental.ts
// ---cut---
import {mountRender, Panel, Plugin, type PanelTab} from '@conciv/frontend-plugin-api'
import {Shelf} from './rpc'
const shelf: PanelTab = {id: 'shelf', title: 'Shelf', pinned: true}
export default Plugin.define({
setup(ctx) {
ctx.add(Panel, {
id: 'shelf',
region: 'pane',
list: () => [shelf],
render: mountRender((element) => {
const line = element.appendChild(document.createElement('p'))
line.textContent = 'Counting'
ctx.client
.rpc(Shelf)
.count({plant: 'fern'})
.then(
(stock) => (line.textContent = `${stock.count} ferns`),
() => (line.textContent = 'The shelf did not answer'),
) // <- one call each time the tab opens
return () => line.remove()
}),
})
},
})
```
`ctx.client.rpc(Shelf)` calls your engine part through its contract. See
[Share an RPC method](/docs/plugins/guides/rpc). Build or wire it as in
[Build or wire the browser part](/docs/plugins/first-plugin#build-or-wire-the-browser-part), then reload.
## Next steps [#next-steps]
- **[Add a slot or composer pill](/docs/plugins/guides/slot-pill)**: smaller places for your plugin in the widget.
- **[Share an RPC method](/docs/plugins/guides/rpc)**: the methods your panel reads.
# Ask for permission (/docs/plugins/guides/permission)
Ask first when a tool changes something the user cares about: it deploys, deletes, pays or sends. The user gets a
card in the chat. Your tool waits for the answer.
## Ask before the tool acts [#ask-before-the-tool-acts]
Call `ctx.permission.assert` at the start of the tool, before it acts:
```ts twoslash title="conciv/plugins/release/server.ts" tab="Promise" tab-group="plugin-api"
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api'
export default Plugin.define({
id: 'release',
async setup(ctx) {
await ctx.tool.transform((tools) => {
tools.add({
name: 'release_ship',
description: 'Ship a branch to production, once the user allows it.',
input: z.object({branch: z.string()}),
output: z.object({shipped: z.boolean()}),
options: {codemode: false},
execute: async ({branch}, tool) => {
await ctx.permission.assert({
action: 'release_ship', // <- a rule names this action
resources: [branch], // <- what the action touches; rules match on it
save: [branch], // <- what "Allow always" remembers
fallback: 'ask', // <- ask even when only a catch-all rule allows it
metadata: {branch}, // <- shown on the card as the call's details
sessionId: tool.sessionId,
agent: tool.agent,
source: {type: 'tool', messageId: tool.messageId, id: tool.id},
})
return {output: {shipped: true}}
},
})
})
},
})
```
```ts twoslash title="conciv/plugins/release/server.ts" tab="Effect" tab-group="plugin-api"
import {Effect} from 'effect'
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api/effect'
export default Plugin.define({
id: 'release',
effect: (ctx) =>
ctx.tool.transform((tools) => {
tools.add({
name: 'release_ship',
description: 'Ship a branch to production, once the user allows it.',
input: z.object({branch: z.string()}),
output: z.object({shipped: z.boolean()}),
options: {codemode: false},
execute: ({branch}, tool) =>
ctx.permission
.assert({
action: 'release_ship', // <- a rule names this action
resources: [branch], // <- what the action touches; rules match on it
save: [branch], // <- what "Allow always" remembers
fallback: 'ask', // <- ask even when only a catch-all rule allows it
metadata: {branch}, // <- shown on the card as the call's details
sessionId: tool.sessionId,
agent: tool.agent,
source: {type: 'tool', messageId: tool.messageId, id: tool.id},
})
.pipe(Effect.as({output: {shipped: true}})),
})
}),
})
```
A few things to notice:
- The last three fields come from the tool context, the second argument of `execute`. They tie the card to this
call in this chat.
- `agent` is the engine's agent profile running the call. Its permission rules decide whether to ask. Learn more in
the [Agents and permissions documentation](/docs/agents-and-permissions).
- `metadata` is optional. The card shows it under its title, so pass what helps the user decide.
- Without `fallback: 'ask'`, an agent whose rules allow everything would never ask.
## What the user sees [#what-the-user-sees]
The chat shows a card titled with the action and its resources, here "release_ship main". It has three buttons:
- **Allow once.** This call runs.
- **Allow always.** This call runs, and the project remembers the `save` values for this action.
- **Deny.** The call fails, and conciv tells the agent.
When the user picks Deny, the call fails. In the Promise tab `assert` rejects. In the Effect tab a plain Deny
interrupts your effect as a defect, so a typed handler never sees it. A deny rule, or a Deny with feedback, fails
with a `Tool.Error`. Either way the agent reads that the user refused.
## Ask on every call [#ask-on-every-call]
Leave out `save` for a call that must ask every time. The card then has no Allow always button, so no saved answer
can skip it later:
```ts twoslash title="conciv/plugins/release/server.ts" tab="Promise" tab-group="plugin-api"
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api'
export default Plugin.define({
id: 'release',
async setup(ctx) {
await ctx.tool.transform((tools) => {
tools.add({
name: 'release_rollback',
description: 'Roll production back to the last release, once the user allows it.',
input: z.object({}),
options: {codemode: false},
execute: async (_input, tool) => {
await ctx.permission.assert({
action: 'release_rollback',
resources: ['production'],
fallback: 'ask',
sessionId: tool.sessionId,
agent: tool.agent,
source: {type: 'tool', messageId: tool.messageId, id: tool.id},
})
return {content: 'Production is back on the last release.'}
},
})
})
},
})
```
```ts twoslash title="conciv/plugins/release/server.ts" tab="Effect" tab-group="plugin-api"
import {Effect} from 'effect'
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api/effect'
export default Plugin.define({
id: 'release',
effect: (ctx) =>
ctx.tool.transform((tools) => {
tools.add({
name: 'release_rollback',
description: 'Roll production back to the last release, once the user allows it.',
input: z.object({}),
options: {codemode: false},
execute: (_input, tool) =>
ctx.permission
.assert({
action: 'release_rollback',
resources: ['production'],
fallback: 'ask',
sessionId: tool.sessionId,
agent: tool.agent,
source: {type: 'tool', messageId: tool.messageId, id: tool.id},
})
.pipe(Effect.as({content: 'Production is back on the last release.'})),
})
}),
})
```
The last rule that matches wins. The engine reads them in this order:
1. the agent profile's rules, including your config rules and the rules plugins add;
2. the tool's fallback;
3. the session's own rules;
4. saved answers.
A `deny` among the first three always wins. Learn more in [Agents and permissions](/docs/agents-and-permissions).
An `ask` rule you push onto an agent with `ctx.agent.transform` beats the catch-all rules before it. A saved
Allow always answer still wins, because it comes after. Leaving out `save` is the way to ask on every call.
## Next steps [#next-steps]
- **[Add a tool](/docs/plugins/guides/tool)**: the tool this page guards.
- **[Test your plugin](/docs/plugins/guides/testing)**: check in a test that the call asks.
- **[Approvals](/docs/usage/approvals)**: what the user does with the card.
# Share an RPC method (/docs/plugins/guides/rpc)
An RPC method is a function your engine part answers. Anything else calls it by name: your browser part, a terminal,
or another plugin. This guide builds a plant shelf, with a `count` method and a `sell` method that can fail.
The contract file imports `@conciv/protocol`, which the tutorial installed only for the Effect style.
```package-install
npm install -D @conciv/protocol
```
## Declare the contract [#declare-the-contract]
Declare the contract in its own file, so the engine part and the browser part both import it:
```ts twoslash title="conciv/plugins/plant-shelf/rpc.ts"
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
export const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf', // <- the name callers use
methods: {
count: {input: Plant, output: Stock},
sell: {input: Plant, output: Stock, errors: {'sold-out': Plant}}, // <- a failure callers can tell apart
},
events: {sold: {schema: Stock}}, // <- sent to everyone listening
})
```
The contract imports `Rpc` from `@conciv/protocol/schema/rpc` because the widget provides that module to browser
parts. Then answer every method in the engine part:
```ts twoslash title="conciv/plugins/plant-shelf/server.ts" tab="Promise" tab-group="plugin-api"
// @filename: rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
export const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {
count: {input: Plant, output: Stock},
sell: {input: Plant, output: Stock, errors: {'sold-out': Plant}},
},
events: {sold: {schema: Stock}},
})
// @filename: server.ts
// ---cut---
import {Plugin, type RpcRegistration} from '@conciv/backend-plugin-api'
import {Shelf} from './rpc'
export default Plugin.define({
id: 'plant-shelf',
async setup(ctx) {
let count = 3
const shelf: RpcRegistration = await ctx.rpc.register(Shelf, {
count: async ({plant}) => ({plant, count}),
sell: async ({plant}, call) => {
if (count === 0) return call.error('sold-out', `${plant} is sold out`, {plant}) // <- a declared error
count -= 1
await shelf.events
.emit('sold', {plant, count})
.catch((error: unknown) => console.error('a sold event was not delivered', error))
return {plant, count}
},
})
},
})
```
```ts twoslash title="conciv/plugins/plant-shelf/server.ts" tab="Effect" tab-group="plugin-api"
// @filename: rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
export const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {
count: {input: Plant, output: Stock},
sell: {input: Plant, output: Stock, errors: {'sold-out': Plant}},
},
events: {sold: {schema: Stock}},
})
// @filename: server.ts
// ---cut---
import {Effect, Ref} from 'effect'
import {Plugin} from '@conciv/backend-plugin-api/effect'
import type {RpcRegistration} from '@conciv/backend-plugin-api/effect/rpc'
import {Shelf} from './rpc'
export default Plugin.define({
id: 'plant-shelf',
effect: (ctx) =>
Effect.gen(function* () {
const count = yield* Ref.make(3)
const shelf: RpcRegistration = yield* ctx.rpc.register(Shelf, {
count: ({plant}) => Ref.get(count).pipe(Effect.map((left) => ({plant, count: left}))),
sell: ({plant}, call) =>
Effect.gen(function* () {
const left = yield* Ref.get(count)
if (left === 0) return yield* Effect.fail(call.error('sold-out', `${plant} is sold out`, {plant})) // <- a declared error
yield* Ref.set(count, left - 1)
yield* shelf.events
.emit('sold', {plant, count: left - 1})
.pipe(Effect.catchCause((cause) => Effect.logError('a sold event was not delivered', cause)))
return {plant, count: left - 1}
}),
})
}).pipe(Effect.orDie),
})
```
A few things to notice:
- Each handler gets the checked input. What it returns is checked against `output` before it goes back.
- `call.error` makes one of the method's declared errors: its name, a message and its data.
- In both tabs the plugin logs a failed `emit`. The sale still succeeds.
- `Effect.catchCause` catches any failure of the emit. `Effect.orDie` makes a failed `register` stop the plugin load,
as a rejected `register` does in the Promise tab.
- `shelf` has its type written out, because a handler uses the registration it belongs to.
## Call it from the browser part [#call-it-from-the-browser-part]
`ctx.client.rpc(Shelf)` gives one typed function per method. You write the browser part in Solid, React, Preact or
plain DOM. This code draws nothing, so it is the same in every tab. Only where it lives changes:
```tsx twoslash title="conciv/plugins/plant-shelf/plugin-experimental.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// @filename: rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
export const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {
count: {input: Plant, output: Stock},
sell: {input: Plant, output: Stock, errors: {'sold-out': Plant}},
},
events: {sold: {schema: Stock}},
})
// @filename: plugin-experimental.tsx
// ---cut---
import {Command, Plugin} from '@conciv/frontend-plugin-api'
import {Shelf} from './rpc'
export default Plugin.define({
setup(ctx) {
ctx.add(Command, {
id: 'count-ferns',
title: 'Count the ferns',
run: async () => {
const stock = await ctx.client.rpc(Shelf).count({plant: 'fern'})
ctx.toast.show({title: `${stock.count} ferns on the shelf`})
},
})
},
})
```
The code lives in your app. Give it to `` as in
[Build your first plugin](/docs/plugins/first-plugin#build-or-wire-the-browser-part).
```ts twoslash title="src/conciv/plant-shelf.ts"
// @filename: conciv/plugins/plant-shelf/rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
export const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {
count: {input: Plant, output: Stock},
sell: {input: Plant, output: Stock, errors: {'sold-out': Plant}},
},
events: {sold: {schema: Stock}},
})
// @filename: src/conciv/plant-shelf.ts
// ---cut---
import {Command, type Plugin} from '@conciv/frontend-plugin-api'
import {Shelf} from '../../conciv/plugins/plant-shelf/rpc'
export const plantShelf: Plugin.Setup = (ctx) => {
ctx.add(Command, {
id: 'count-ferns',
title: 'Count the ferns',
run: async () => {
const stock = await ctx.client.rpc(Shelf).count({plant: 'fern'})
ctx.toast.show({title: `${stock.count} ferns on the shelf`})
},
})
}
```
The code lives in your app. Give it to `` as in
[Build your first plugin](/docs/plugins/first-plugin#build-or-wire-the-browser-part).
```ts twoslash title="src/conciv/plant-shelf.ts"
// @filename: conciv/plugins/plant-shelf/rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
export const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {
count: {input: Plant, output: Stock},
sell: {input: Plant, output: Stock, errors: {'sold-out': Plant}},
},
events: {sold: {schema: Stock}},
})
// @filename: src/conciv/plant-shelf.ts
// ---cut---
import {Command, type Plugin} from '@conciv/frontend-plugin-api'
import {Shelf} from '../../conciv/plugins/plant-shelf/rpc'
export const plantShelf: Plugin.Setup = (ctx) => {
ctx.add(Command, {
id: 'count-ferns',
title: 'Count the ferns',
run: async () => {
const stock = await ctx.client.rpc(Shelf).count({plant: 'fern'})
ctx.toast.show({title: `${stock.count} ferns on the shelf`})
},
})
}
```
```ts twoslash title="conciv/plugins/plant-shelf/plugin-experimental.ts"
// @filename: rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
export const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {
count: {input: Plant, output: Stock},
sell: {input: Plant, output: Stock, errors: {'sold-out': Plant}},
},
events: {sold: {schema: Stock}},
})
// @filename: plugin-experimental.ts
// ---cut---
import {Command, Plugin} from '@conciv/frontend-plugin-api'
import {Shelf} from './rpc'
export default Plugin.define({
setup(ctx) {
ctx.add(Command, {
id: 'count-ferns',
title: 'Count the ferns',
run: async () => {
const stock = await ctx.client.rpc(Shelf).count({plant: 'fern'})
ctx.toast.show({title: `${stock.count} ferns on the shelf`})
},
})
},
})
```
Read `ctx.client` where you call it, because the widget makes a new client after the engine restarts. Build or wire it
as in [Build or wire the browser part](/docs/plugins/first-plugin#build-or-wire-the-browser-part), then reload.
## Follow the events [#follow-the-events]
Subscribe to an event by its full name, `rpc..`:
```tsx twoslash title="conciv/plugins/plant-shelf/plugin-experimental.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// @filename: rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
export const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {count: {input: Plant, output: Stock}},
events: {sold: {schema: Stock}},
})
// @filename: plugin-experimental.tsx
// ---cut---
import {Plugin} from '@conciv/frontend-plugin-api'
import {Stock} from './rpc'
export default Plugin.define({
setup(ctx) {
const follow = async () => {
for await (const event of ctx.client.event.subscribe({types: ['rpc.plant-shelf.sold'], signal: ctx.signal})) {
if (event.type !== 'rpc.plant-shelf.sold') continue // <- server.connected comes through too
const stock = Stock.safeParse(event.data)
if (stock.success) ctx.toast.show({title: `${stock.data.plant} sold, ${stock.data.count} left`})
}
}
void follow()
},
})
```
```ts twoslash title="src/conciv/plant-shelf.ts"
// @filename: conciv/plugins/plant-shelf/rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
export const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {count: {input: Plant, output: Stock}},
events: {sold: {schema: Stock}},
})
// @filename: src/conciv/plant-shelf.ts
// ---cut---
import type {Plugin} from '@conciv/frontend-plugin-api'
import {Stock} from '../../conciv/plugins/plant-shelf/rpc'
export const plantShelf: Plugin.Setup = (ctx) => {
const follow = async () => {
for await (const event of ctx.client.event.subscribe({types: ['rpc.plant-shelf.sold'], signal: ctx.signal})) {
if (event.type !== 'rpc.plant-shelf.sold') continue // <- server.connected comes through too
const stock = Stock.safeParse(event.data)
if (stock.success) ctx.toast.show({title: `${stock.data.plant} sold, ${stock.data.count} left`})
}
}
void follow()
}
```
```ts twoslash title="src/conciv/plant-shelf.ts"
// @filename: conciv/plugins/plant-shelf/rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
export const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {count: {input: Plant, output: Stock}},
events: {sold: {schema: Stock}},
})
// @filename: src/conciv/plant-shelf.ts
// ---cut---
import type {Plugin} from '@conciv/frontend-plugin-api'
import {Stock} from '../../conciv/plugins/plant-shelf/rpc'
export const plantShelf: Plugin.Setup = (ctx) => {
const follow = async () => {
for await (const event of ctx.client.event.subscribe({types: ['rpc.plant-shelf.sold'], signal: ctx.signal})) {
if (event.type !== 'rpc.plant-shelf.sold') continue // <- server.connected comes through too
const stock = Stock.safeParse(event.data)
if (stock.success) ctx.toast.show({title: `${stock.data.plant} sold, ${stock.data.count} left`})
}
}
void follow()
}
```
```ts twoslash title="conciv/plugins/plant-shelf/plugin-experimental.ts"
// @filename: rpc.ts
import * as Rpc from '@conciv/protocol/schema/rpc'
import {z} from 'zod'
const Plant = z.object({plant: z.string()})
export const Stock = z.object({plant: z.string(), count: z.number()})
export const Shelf = Rpc.define({
id: 'plant-shelf',
methods: {count: {input: Plant, output: Stock}},
events: {sold: {schema: Stock}},
})
// @filename: plugin-experimental.ts
// ---cut---
import {Plugin} from '@conciv/frontend-plugin-api'
import {Stock} from './rpc'
export default Plugin.define({
setup(ctx) {
const follow = async () => {
for await (const event of ctx.client.event.subscribe({types: ['rpc.plant-shelf.sold'], signal: ctx.signal})) {
if (event.type !== 'rpc.plant-shelf.sold') continue // <- server.connected comes through too
const stock = Stock.safeParse(event.data)
if (stock.success) ctx.toast.show({title: `${stock.data.plant} sold, ${stock.data.count} left`})
}
}
void follow()
},
})
```
A few things to notice:
- `subscribe` always lets `server.connected` through, at the start and after each reconnect. Read your data again
then. You can have missed events in between.
- `event.data` is what the engine part sent. Check it with your schema before you use it.
- `ctx.signal` ends the loop when the plugin reloads or stops.
Build or wire it as in [Build or wire the browser part](/docs/plugins/first-plugin#build-or-wire-the-browser-part),
then reload.
## Call it from a terminal [#call-it-from-a-terminal]
The same methods answer from your shell, while the dev server runs:
```bash title="terminal"
npx @conciv/cli plugin call plant-shelf count --data '{"plant": "fern"}'
```
```json title="output"
{"ok": true, "data": {"plant": "fern", "count": 3}}
```
Learn more in [Call your plugin from a terminal](/docs/plugins/guides/terminal).
The engine keeps names that start with `rpc.` for its own errors. `Rpc.define` throws on one.
## Next steps [#next-steps]
- **[Add a panel](/docs/plugins/guides/panel)**: show the data in a tab next to the chat.
- **[Call your plugin from a terminal](/docs/plugins/guides/terminal)**: every flag and every error.
# Add settings (/docs/plugins/guides/settings)
A plugin has two kinds of settings. **Options** live in the project's conciv config. The team shares them
through the repo. **A setting in the widget** is one the user changes. It stays on their machine.
## Pass options from the config [#pass-options-from-the-config]
A plugin in `conciv/plugins` loads with no options. To pass some, list its folder in the `plugins` option as
`[path, options]`:
```ts twoslash title="vite.config.ts" tab="Vite" tab-group="bundler"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [conciv({plugins: [['./conciv/plugins/tickets', {project: 'OPS', closeAfterDays: 30}]]})],
})
```
```ts twoslash title="next.config.ts" tab="Next.js" tab-group="bundler"
import type {NextConfig} from 'next'
import {withConciv} from '@conciv/it/plugin/nextjs'
const nextConfig: NextConfig = {}
export default withConciv(nextConfig, {plugins: [['./conciv/plugins/tickets', {project: 'OPS', closeAfterDays: 30}]]})
```
```js title="webpack.config.js" tab="webpack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/webpack')
module.exports = {
mode: 'development',
plugins: [conciv.default({plugins: [['./conciv/plugins/tickets', {project: 'OPS', closeAfterDays: 30}]]})],
}
```
```js title="rspack.config.js" tab="Rspack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/rspack')
module.exports = {
mode: 'development',
plugins: [conciv.default({plugins: [['./conciv/plugins/tickets', {project: 'OPS', closeAfterDays: 30}]]})],
}
```
Your engine part reads them as `ctx.options`. Check them with a schema first, since the user can write anything:
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Promise" tab-group="plugin-api"
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api'
const Options = z.object({
project: z.string(),
closeAfterDays: z.number().int().positive().default(14), // <- 14 unless the user sets it
})
export default Plugin.define({
id: 'tickets',
async setup(ctx) {
const options = Options.parse(ctx.options)
await ctx.tool.transform((tools) => {
tools.add({
name: 'ticket_policy',
description: 'Name the tracker project this repo files tickets in, and when stale tickets close.',
input: z.object({}),
execute: async () => ({
content: `Tickets go in ${options.project}. Stale tickets close after ${options.closeAfterDays} days.`,
}),
})
})
},
})
```
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Effect" tab-group="plugin-api"
import {Effect} from 'effect'
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api/effect'
const Options = z.object({
project: z.string(),
closeAfterDays: z.number().int().positive().default(14), // <- 14 unless the user sets it
})
export default Plugin.define({
id: 'tickets',
effect: (ctx) =>
Effect.gen(function* () {
const options = yield* Effect.sync(() => Options.parse(ctx.options))
yield* ctx.tool.transform((tools) => {
tools.add({
name: 'ticket_policy',
description: 'Name the tracker project this repo files tickets in, and when stale tickets close.',
input: z.object({}),
execute: () =>
Effect.succeed({
content: `Tickets go in ${options.project}. Stale tickets close after ${options.closeAfterDays} days.`,
}),
})
})
}),
})
```
A few things to notice:
- `ctx.options` is the object from the config entry. Every value in it is JSON.
- `Options.parse` checks it and fills in the defaults.
- In both tabs a parse that fails stops the plugin from loading, with zod's message in the log. That tells the user
what to fix.
- The browser part gets the same object as `ctx.options`.
## Add a setting to the widget [#add-a-setting-to-the-widget]
Declare a store for the value, then add a row to the widget's settings. You write the browser part in Solid, React,
Preact or plain DOM:
```tsx twoslash title="conciv/plugins/tickets/plugin-experimental.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// ---cut---
import {Plugin, SettingsPage, Store, usePlugin} from '@conciv/frontend-plugin-api'
import {z} from 'zod'
const stores = {
prefs: Store.global(z.object({showClosed: z.boolean()}), {showClosed: false}), // <- one value for every project
}
function ShowClosedRow() {
const ctx = usePlugin<{stores: typeof stores}>()
const prefs = ctx.stores.prefs
return (
prefs.set({showClosed: checked})}
/>
)
}
export default Plugin.define({
stores, // <- the widget loads these before setup runs
setup(ctx) {
ctx.add(SettingsPage, {
id: 'tickets',
page: 'general',
section: 'general', // <- one row in the General section
title: 'Tickets',
entries: [{id: 'show-closed', title: 'Show closed tickets', keywords: 'tickets closed'}],
render: () => ,
})
},
})
```
The row lives in your app. Give it to `` as in
[Build your first plugin](/docs/plugins/first-plugin#build-or-wire-the-browser-part).
```tsx twoslash title="src/conciv/tickets.tsx"
// @jsx: react-jsx
// @jsxImportSource: react
// ---cut---
import {useState} from 'react'
import {Plugin, SettingsPage, Store} from '@conciv/frontend-plugin-api'
import {reactRender} from '@conciv/react'
import {z} from 'zod'
export const ticketsDeclarations = Plugin.define({
stores: {
prefs: Store.global(z.object({showClosed: z.boolean()}), {showClosed: false}), // <- one value for every project
},
})
export const tickets: Plugin.Setup = (ctx) => {
const prefs = ctx.stores.prefs
function ShowClosedRow() {
const [showClosed, setShowClosed] = useState(prefs.value.showClosed) // <- read once, as the row draws
return (
)
}
ctx.add(SettingsPage, {
id: 'tickets',
page: 'general',
section: 'general', // <- one row in the General section
title: 'Tickets',
entries: [{id: 'show-closed', title: 'Show closed tickets', keywords: 'tickets closed'}],
render: reactRender(ShowClosedRow),
})
}
```
Spread the declarations into the entry, so the widget loads the store before setup runs:
```ts twoslash title="src/app.tsx"
// @filename: src/conciv/tickets.ts
import {Plugin, Store} from '@conciv/frontend-plugin-api'
import {z} from 'zod'
export const ticketsDeclarations = Plugin.define({
stores: {prefs: Store.global(z.object({showClosed: z.boolean()}), {showClosed: false})},
})
export const tickets: Plugin.Setup = () => {}
// @filename: src/app.ts
// ---cut---
import {tickets, ticketsDeclarations} from './conciv/tickets'
const plugins = [[{id: 'tickets', ...ticketsDeclarations, windowEntry: async () => ({default: tickets})}, {}]] as const
```
The row lives in your app. Give it to `` as in
[Build your first plugin](/docs/plugins/first-plugin#build-or-wire-the-browser-part).
```tsx twoslash title="src/conciv/tickets.tsx"
// @jsx: react-jsx
// @jsxImportSource: preact
// ---cut---
import {useState} from 'preact/hooks'
import {Plugin, SettingsPage, Store} from '@conciv/frontend-plugin-api'
import {preactRender} from '@conciv/preact'
import {z} from 'zod'
export const ticketsDeclarations = Plugin.define({
stores: {
prefs: Store.global(z.object({showClosed: z.boolean()}), {showClosed: false}), // <- one value for every project
},
})
export const tickets: Plugin.Setup = (ctx) => {
const prefs = ctx.stores.prefs
function ShowClosedRow() {
const [showClosed, setShowClosed] = useState(prefs.value.showClosed) // <- read once, as the row draws
return (
)
}
ctx.add(SettingsPage, {
id: 'tickets',
page: 'general',
section: 'general', // <- one row in the General section
title: 'Tickets',
entries: [{id: 'show-closed', title: 'Show closed tickets', keywords: 'tickets closed'}],
render: preactRender(ShowClosedRow),
})
}
```
Spread the declarations into the entry, so the widget loads the store before setup runs:
```ts twoslash title="src/app.tsx"
// @filename: src/conciv/tickets.ts
import {Plugin, Store} from '@conciv/frontend-plugin-api'
import {z} from 'zod'
export const ticketsDeclarations = Plugin.define({
stores: {prefs: Store.global(z.object({showClosed: z.boolean()}), {showClosed: false})},
})
export const tickets: Plugin.Setup = () => {}
// @filename: src/app.ts
// ---cut---
import {tickets, ticketsDeclarations} from './conciv/tickets'
const plugins = [[{id: 'tickets', ...ticketsDeclarations, windowEntry: async () => ({default: tickets})}, {}]] as const
```
```ts twoslash title="conciv/plugins/tickets/plugin-experimental.ts"
import {mountRender, Plugin, SettingsPage, Store} from '@conciv/frontend-plugin-api'
import {z} from 'zod'
const stores = {
prefs: Store.global(z.object({showClosed: z.boolean()}), {showClosed: false}), // <- one value for every project
}
export default Plugin.define({
stores, // <- the widget loads these before setup runs
setup(ctx) {
const prefs = ctx.stores.prefs
ctx.add(SettingsPage, {
id: 'tickets',
page: 'general',
section: 'general', // <- one row in the General section
title: 'Tickets',
entries: [{id: 'show-closed', title: 'Show closed tickets', keywords: 'tickets closed'}],
render: mountRender((element) => {
const label = element.appendChild(document.createElement('label'))
const box = label.appendChild(document.createElement('input'))
box.type = 'checkbox'
box.checked = prefs.value.showClosed // <- read once, as the row draws
box.addEventListener('change', () => prefs.set({showClosed: box.checked}))
label.append('Show closed tickets')
return () => label.remove()
}),
})
},
})
```
A few things to notice:
- `prefs.value` is the stored value. `prefs.set` replaces it. The widget saves it for you.
- In Solid, `usePlugin` gives a component your plugin's context. `ctx.stores.prefs` is typed from the declaration.
- In Solid, `ctx.ui` holds the widget's own components, so the row looks like the widget's own settings. They are
Solid components, so the other tabs draw a plain checkbox.
- `prefs.value` is a Solid store. Outside Solid, read it once as the row draws, and keep your own state after.
- `entries` is what the settings search finds.
- With no `page`, the entry is a page of its own. With only `page: 'general'`, it is a section on the General page.
Build or wire it as in [Build or wire the browser part](/docs/plugins/first-plugin#build-or-wire-the-browser-part),
then reload.
`Store.project` keeps one value for the project the engine runs in. `Store.session` keeps one value per session.
You call it with the session:
```tsx twoslash title="conciv/plugins/tickets/plugin-experimental.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// ---cut---
import {Plugin, Slot, Store} from '@conciv/frontend-plugin-api'
import {z} from 'zod'
const stores = {
view: Store.session(z.object({filter: z.string()}), {filter: 'open'}),
}
export default Plugin.define({
stores,
setup(ctx) {
ctx.add(Slot, {
at: 'session.status',
render: (input) => Showing {ctx.stores.view(input.session).value?.filter ?? 'open'} tickets,
})
},
})
```
The store's `value` is a Solid signal. Read it in the function you give `ctx.add`, which runs again when it changes:
```tsx twoslash title="src/conciv/tickets.tsx"
// @jsx: react-jsx
// @jsxImportSource: react
// ---cut---
import {Plugin, Slot, Store} from '@conciv/frontend-plugin-api'
import {reactRender} from '@conciv/react'
import {z} from 'zod'
export const ticketsDeclarations = Plugin.define({
stores: {view: Store.session(z.object({filter: z.string()}), {filter: 'open'})},
})
function Showing(props: {readonly filter: string}) {
return Showing {props.filter} tickets
}
export const tickets: Plugin.Setup = (ctx) => {
ctx.add(Slot, (): Slot => {
const session = ctx.sessions.current()
const filter = (session && ctx.stores.view(session).value?.filter) ?? 'open'
return {at: 'session.status', render: reactRender(() => )}
})
}
```
The store's `value` is a Solid signal. Read it in the function you give `ctx.add`, which runs again when it changes:
```tsx twoslash title="src/conciv/tickets.tsx"
// @jsx: react-jsx
// @jsxImportSource: preact
// ---cut---
import {Plugin, Slot, Store} from '@conciv/frontend-plugin-api'
import {preactRender} from '@conciv/preact'
import {z} from 'zod'
export const ticketsDeclarations = Plugin.define({
stores: {view: Store.session(z.object({filter: z.string()}), {filter: 'open'})},
})
function Showing(props: {readonly filter: string}) {
return Showing {props.filter} tickets
}
export const tickets: Plugin.Setup = (ctx) => {
ctx.add(Slot, (): Slot => {
const session = ctx.sessions.current()
const filter = (session && ctx.stores.view(session).value?.filter) ?? 'open'
return {at: 'session.status', render: preactRender(() => )}
})
}
```
The store's `value` is a Solid signal. Read it in the function you give `ctx.add`, which runs again when it changes:
```ts twoslash title="conciv/plugins/tickets/plugin-experimental.ts"
import {mountRender, Plugin, Slot, Store} from '@conciv/frontend-plugin-api'
import {z} from 'zod'
const stores = {
view: Store.session(z.object({filter: z.string()}), {filter: 'open'}),
}
export default Plugin.define({
stores,
setup(ctx) {
ctx.add(Slot, (): Slot => {
const session = ctx.sessions.current()
const filter = (session && ctx.stores.view(session).value?.filter) ?? 'open'
return {
at: 'session.status',
render: mountRender((element) => {
const span = element.appendChild(document.createElement('span'))
span.textContent = `Showing ${filter} tickets`
return () => span.remove()
}),
}
})
},
})
```
A session store is still loading when the session first mounts, so its `value` can be `undefined`.
## Next steps [#next-steps]
- **[Add a slot or composer pill](/docs/plugins/guides/slot-pill)**: show something that the setting switches.
- **[Plugin API reference](/docs/plugins/reference)**: every field of `ctx`.
# Add a skill (/docs/plugins/guides/skill)
A skill is a page of instructions the agent reads when a task needs it. Ship one with your plugin when its tools need
a how-to: which tool to call first, what the results mean, what to avoid. If you only need the instructions, with no
new code, a skill file in your project is enough. See [Skills](/docs/skills).
This guide also imports `@conciv/protocol`, which the tutorial installed only for the Effect style.
```package-install
npm install -D @conciv/protocol
```
## Ship a skill file [#ship-a-skill-file]
Keep the instructions in a Markdown file in your plugin folder:
```md title="conciv/plugins/tickets/skill/SKILL.md"
# Tickets
Read a ticket with ticket_read before you change it.
Never close a ticket whose id starts with SEC-: the security team closes those.
```
The engine does not find this file on its own. Your engine part reads it and adds it inside `ctx.skill.transform`:
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Promise" tab-group="plugin-api"
import {readFile} from 'node:fs/promises'
import {fileURLToPath} from 'node:url'
import {Plugin, Skill} from '@conciv/backend-plugin-api'
import {AbsolutePath} from '@conciv/protocol/schema/schema'
const file = fileURLToPath(new URL('./skill/SKILL.md', import.meta.url))
export default Plugin.define({
id: 'tickets',
async setup(ctx) {
const content = await readFile(file, 'utf8')
await ctx.skill.transform((skills) =>
skills.add({
id: Skill.Id.make('tickets'),
name: Skill.Name.make('Tickets'),
description: 'Read and close tickets in the team tracker. Load it before your first ticket tool call.',
path: AbsolutePath.make(file), // <- the skill's folder is the one this file is in
content, // <- what the agent reads when it loads the skill
}),
)
},
})
```
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Effect" tab-group="plugin-api"
import {readFile} from 'node:fs/promises'
import {fileURLToPath} from 'node:url'
import {Effect} from 'effect'
import {Plugin, Skill} from '@conciv/backend-plugin-api/effect'
import {AbsolutePath} from '@conciv/protocol/schema/schema'
const file = fileURLToPath(new URL('./skill/SKILL.md', import.meta.url))
export default Plugin.define({
id: 'tickets',
effect: (ctx) =>
Effect.gen(function* () {
const content = yield* Effect.promise(() => readFile(file, 'utf8'))
yield* ctx.skill.transform((skills) =>
skills.add({
id: Skill.Id.make('tickets'),
name: Skill.Name.make('Tickets'),
description: 'Read and close tickets in the team tracker. Load it before your first ticket tool call.',
path: AbsolutePath.make(file), // <- the skill's folder is the one this file is in
content, // <- what the agent reads when it loads the skill
}),
)
}),
})
```
A few things to notice:
- `Skill.Id`, `Skill.Name` and `AbsolutePath` are branded strings. `.make` turns a plain string into one. An id
then cannot go where a name belongs.
- `description` is what the agent always sees. The agent decides from this line when to load the skill.
- The agent sees the files next to `SKILL.md` and can read them, such as a `reference/` folder.
- In both tabs, a missing file stops the plugin from loading.
The agent gets the skill's name and description in every turn. When it starts a ticket task, it loads the content.
Then it follows it.
## A skill with no file [#a-skill-with-no-file]
Write the content in code, and give the skill a `skill://` path. That path names the skill without pointing at a
folder, so the agent sees no files beside it:
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Promise" tab-group="plugin-api"
import {Plugin, Skill} from '@conciv/backend-plugin-api'
import {AbsolutePath} from '@conciv/protocol/schema/schema'
export default Plugin.define({
id: 'tickets',
async setup(ctx) {
await ctx.skill.transform((skills) =>
skills.add({
id: Skill.Id.make('tickets'),
name: Skill.Name.make('Tickets'),
description: 'Read and close tickets in the team tracker. Load it before your first ticket tool call.',
path: AbsolutePath.make('skill://tickets/SKILL.md'),
content: 'Read a ticket with ticket_read before you change it.',
}),
)
},
})
```
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Effect" tab-group="plugin-api"
import {Plugin, Skill} from '@conciv/backend-plugin-api/effect'
import {AbsolutePath} from '@conciv/protocol/schema/schema'
export default Plugin.define({
id: 'tickets',
effect: (ctx) =>
ctx.skill.transform((skills) =>
skills.add({
id: Skill.Id.make('tickets'),
name: Skill.Name.make('Tickets'),
description: 'Read and close tickets in the team tracker. Load it before your first ticket tool call.',
path: AbsolutePath.make('skill://tickets/SKILL.md'),
content: 'Read a ticket with ticket_read before you change it.',
}),
),
})
```
Leave out its `description`, or set `autoinvoke: false`. The engine then does not tell the agent about it. The user can still
attach it to a message on purpose.
## Next steps [#next-steps]
- **[Add a tool](/docs/plugins/guides/tool)**: the tools your skill teaches.
- **[Skills](/docs/skills)**: skills written as files in your project.
# Add a slot or composer pill (/docs/plugins/guides/slot-pill)
A slot puts your content at a fixed place in the widget, such as a session's status area. A pill sits above the
composer. It runs an action when the user clicks it. You write the browser part in Solid, React, Preact or plain DOM.
In React and Preact the code lives in your app. Give it to `` as in
[Build your first plugin](/docs/plugins/first-plugin#build-or-wire-the-browser-part).
## Add a slot [#add-a-slot]
Add a slot in your plugin's browser part:
```tsx twoslash title="conciv/plugins/status/plugin-experimental.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// ---cut---
import {Plugin, Slot} from '@conciv/frontend-plugin-api'
export default Plugin.define({
setup(ctx) {
ctx.add(Slot, {
at: 'session.status', // <- the place in the widget
render: (input) => {input.session.run.status() === 'running' ? 'Agent working' : 'Agent idle'},
})
},
})
```
`run.status()` is a Solid signal, so a React component does not draw again when it changes. Pass a function to
`ctx.add` instead. The widget runs it again when the status changes:
```tsx twoslash title="src/conciv/status.tsx"
// @jsx: react-jsx
// @jsxImportSource: react
// ---cut---
import {Slot, type Plugin} from '@conciv/frontend-plugin-api'
import {reactRender} from '@conciv/react'
function Working() {
return Agent working
}
function Idle() {
return Agent idle
}
const working: Slot = {at: 'session.status', render: reactRender(Working)} // <- the place in the widget
const idle: Slot = {at: 'session.status', render: reactRender(Idle)}
export const status: Plugin.Setup = (ctx) => {
ctx.add(Slot, () => (ctx.sessions.current()?.run.status() === 'running' ? working : idle))
}
```
`run.status()` is a Solid signal, so a Preact component does not draw again when it changes. Pass a function to
`ctx.add` instead. The widget runs it again when the status changes:
```tsx twoslash title="src/conciv/status.tsx"
// @jsx: react-jsx
// @jsxImportSource: preact
// ---cut---
import {Slot, type Plugin} from '@conciv/frontend-plugin-api'
import {preactRender} from '@conciv/preact'
function Working() {
return Agent working
}
function Idle() {
return Agent idle
}
const working: Slot = {at: 'session.status', render: preactRender(Working)} // <- the place in the widget
const idle: Slot = {at: 'session.status', render: preactRender(Idle)}
export const status: Plugin.Setup = (ctx) => {
ctx.add(Slot, () => (ctx.sessions.current()?.run.status() === 'running' ? working : idle))
}
```
`run.status()` is a Solid signal, so `subscribe` does not call you when it changes. Pass a function to `ctx.add`
instead. The widget runs it again when the status changes:
```ts twoslash title="conciv/plugins/status/plugin-experimental.ts"
import {mountRender, Plugin, Slot} from '@conciv/frontend-plugin-api'
function drawText(text: string): Slot {
return {
at: 'session.status', // <- the place in the widget
render: mountRender((element) => {
const span = element.appendChild(document.createElement('span'))
span.textContent = text
return () => span.remove()
}),
}
}
const working = drawText('Agent working')
const idle = drawText('Agent idle')
export default Plugin.define({
setup(ctx) {
ctx.add(Slot, () => (ctx.sessions.current()?.run.status() === 'running' ? working : idle))
},
})
```
`render` draws the content once. Read `input.session` where you use it, so it follows the session on screen. The
places a slot can go:
- `session.header`: a session's header.
- `session.status`: a session's status area.
- `window.bottom`: the bottom of the widget window.
- `page.overlay`: over your app's page, outside the widget. It keeps keyboard focus inside, unless you set
`hides: false`.
Build or wire it as in [Build or wire the browser part](/docs/plugins/first-plugin#build-or-wire-the-browser-part),
then reload.
## Add a pill above the composer [#add-a-pill-above-the-composer]
A pill can put text in the composer for the user to send. It draws no UI of its own, so the code is the same in
every tab. Only where it lives changes:
```tsx twoslash title="conciv/plugins/status/plugin-experimental.tsx"
import {ComposerPill, Plugin} from '@conciv/frontend-plugin-api'
export default Plugin.define({
setup(ctx) {
ctx.add(ComposerPill, {
id: 'review',
order: 20, // <- sorts it among the other pills
show: (input) => ({
label: 'Review',
icon: 'eye',
run: () => input.screen.composer.insert('Review my last change and list what could break.'),
}),
})
},
})
```
```ts twoslash title="src/conciv/status.ts"
import {ComposerPill, type Plugin} from '@conciv/frontend-plugin-api'
export const status: Plugin.Setup = (ctx) => {
ctx.add(ComposerPill, {
id: 'review',
order: 20, // <- sorts it among the other pills
show: (input) => ({
label: 'Review',
icon: 'eye',
run: () => input.screen.composer.insert('Review my last change and list what could break.'),
}),
})
}
```
```ts twoslash title="src/conciv/status.ts"
import {ComposerPill, type Plugin} from '@conciv/frontend-plugin-api'
export const status: Plugin.Setup = (ctx) => {
ctx.add(ComposerPill, {
id: 'review',
order: 20, // <- sorts it among the other pills
show: (input) => ({
label: 'Review',
icon: 'eye',
run: () => input.screen.composer.insert('Review my last change and list what could break.'),
}),
})
}
```
```ts twoslash title="conciv/plugins/status/plugin-experimental.ts"
import {ComposerPill, Plugin} from '@conciv/frontend-plugin-api'
export default Plugin.define({
setup(ctx) {
ctx.add(ComposerPill, {
id: 'review',
order: 20, // <- sorts it among the other pills
show: (input) => ({
label: 'Review',
icon: 'eye',
run: () => input.screen.composer.insert('Review my last change and list what could break.'),
}),
})
},
})
```
A few things to notice:
- `show` returns what the pill looks like, or `undefined` to hide it. It runs once per composer on screen.
- `icon` is a name from the widget's icon set. The names are [lucide](https://lucide.dev/icons) names.
- `run` is what a click does. Here it puts a prompt in the composer. The user sends it.
Build or wire it as in [Build or wire the browser part](/docs/plugins/first-plugin#build-or-wire-the-browser-part),
then reload.
## Show something only some of the time [#show-something-only-some-of-the-time]
Pass a function to `ctx.add`. The widget runs it again when what it reads changes. Returning `undefined` adds nothing:
```tsx twoslash title="conciv/plugins/status/plugin-experimental.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// ---cut---
import {Plugin, Slot} from '@conciv/frontend-plugin-api'
export default Plugin.define({
setup(ctx) {
const badge: Slot = {at: 'window.bottom', render: () => Dev build}
ctx.add(Slot, () => (ctx.app.channel === 'dev' ? badge : undefined)) // <- only in a dev build
},
})
```
```tsx twoslash title="src/conciv/status.tsx"
// @jsx: react-jsx
// @jsxImportSource: react
// ---cut---
import {Slot, type Plugin} from '@conciv/frontend-plugin-api'
import {reactRender} from '@conciv/react'
function DevBadge() {
return Dev build
}
const badge: Slot = {at: 'window.bottom', render: reactRender(DevBadge)}
export const status: Plugin.Setup = (ctx) => {
ctx.add(Slot, () => (ctx.app.channel === 'dev' ? badge : undefined)) // <- only in a dev build
}
```
```tsx twoslash title="src/conciv/status.tsx"
// @jsx: react-jsx
// @jsxImportSource: preact
// ---cut---
import {Slot, type Plugin} from '@conciv/frontend-plugin-api'
import {preactRender} from '@conciv/preact'
function DevBadge() {
return Dev build
}
const badge: Slot = {at: 'window.bottom', render: preactRender(DevBadge)}
export const status: Plugin.Setup = (ctx) => {
ctx.add(Slot, () => (ctx.app.channel === 'dev' ? badge : undefined)) // <- only in a dev build
}
```
```ts twoslash title="conciv/plugins/status/plugin-experimental.ts"
import {mountRender, Plugin, Slot} from '@conciv/frontend-plugin-api'
const badge: Slot = {
at: 'window.bottom',
render: mountRender((element) => {
const span = element.appendChild(document.createElement('span'))
span.textContent = 'Dev build'
return () => span.remove()
}),
}
export default Plugin.define({
setup(ctx) {
ctx.add(Slot, () => (ctx.app.channel === 'dev' ? badge : undefined)) // <- only in a dev build
},
})
```
`ctx.app.channel` is the widget's release channel. Build or wire it as in
[Build or wire the browser part](/docs/plugins/first-plugin#build-or-wire-the-browser-part), then reload.
Instead of `run`, return `rows`: a list, each row with a `label` and its own `run`. For anything more, give the
pill a `menu` function that renders your own content in the popover. `reactRender`, `preactRender` and
`mountRender` each make one too.
## Next steps [#next-steps]
- **[Add a panel](/docs/plugins/guides/panel)**: a whole tab next to the chat.
- **[Add settings](/docs/plugins/guides/settings)**: let the user switch your slot on and off.
# Call your plugin from a terminal (/docs/plugins/guides/terminal)
`npx @conciv/cli plugin call` runs one of your plugin's RPC methods on the running engine and prints the answer. Use
it to try a method while you write it, or to call your plugin from a script.
## Call a method [#call-a-method]
Start your dev server, then run the method from your project folder:
```bash title="terminal"
npx @conciv/cli plugin call plant-shelf count --data '{"plant": "fern"}'
```
```json title="output"
{"ok": true, "data": {"plant": "fern", "count": 3}}
```
A few things to notice:
- `plant-shelf` is the id of the plugin's RPC contract. `count` is the method. See
[Share an RPC method](/docs/plugins/guides/rpc).
- `--data` is the method's input, as JSON. Leave it out for a method that takes no input. `-d` is the short form.
- The answer is one line of JSON. The command exits `0` on success.
The plugins conciv ships answer the same way. This reads the test runner's last result:
```bash title="terminal"
npx @conciv/cli plugin call test-runner status
```
## Read a failure [#read-a-failure]
A failure prints `ok: false` and an error. The command exits `1`. A method's own error carries its name as
`type`, with its message and data. Here the shelf has no ferns left:
```bash title="terminal"
npx @conciv/cli plugin call plant-shelf sell --data '{"plant": "fern"}'
```
```json title="output"
{
"ok": false,
"error": {
"kind": "user",
"message": "fern is sold out",
"code": "PLUGIN_RPC",
"type": "sold-out",
"data": {"plant": "fern"}
}
}
```
The engine answers some errors itself:
- `rpc.unavailable`: no plugin registered that contract id.
- `rpc.method_not_found`: the contract has no such method.
- `rpc.invalid_input`: the data does not match the method's input.
- `rpc.internal`: the method threw. The code is `PLUGIN_RPC_INTERNAL`.
- `rpc.invalid_output`: the method returned something its output schema refuses. The code is `PLUGIN_RPC_INTERNAL`.
The command refuses data that is not JSON before it sends anything:
```json title="output"
{
"ok": false,
"error": {
"kind": "user",
"message": "--data is not JSON: {plant: fern}",
"hint": "pass the method's input as JSON, for example --data '{}'"
}
}
```
The command looks for an engine in this order:
1. The port in `CONCIV_PORT`, when it is set. `CONCIV_TOKEN` is the token it sends.
2. The engine recorded in the `.conciv` folder of the current folder, or of the nearest folder above it.
3. The engine that started last on this machine.
4. Port 5173 on `127.0.0.1`, when no engine was ever registered.
Two messages mean no engine answered:
- `No conciv dev server on .` prints when the engine at the chosen port does not answer.
- `no conciv dev server answered: ...` prints when the command tried the registered engines and none answered.
See [Troubleshooting](/docs/reference/troubleshooting#no-dev-server) for both. The call runs outside any
session, so it takes no `--tab`.
## Next steps [#next-steps]
- **[Share an RPC method](/docs/plugins/guides/rpc)**: write the methods this command calls.
- **[CLI reference](/docs/reference/cli)**: every conciv command.
# Test your plugin (/docs/plugins/guides/testing)
This guide installs the test utilities, which the tutorial did not:
```package-install
npm install -D vitest @conciv/backend-test-utils @internal/vitest-config
```
Test your plugin the way the user uses it. A real engine loads your plugin, a scripted model plays the agent, and
your test checks what comes back. Nothing is mocked. This guide tests `project_version` from
[Build your first plugin](/docs/plugins/first-plugin) and `release_ship` from
[Ask for permission](/docs/plugins/guides/permission). Both are direct tools, with `codemode: false`.
## Call your tool in a test [#call-your-tool-in-a-test]
Add the conciv test setup to a vitest config at your project root:
```ts twoslash title="vitest.config.ts"
import {defineConfig} from 'vitest/config'
import {concivTest} from '@internal/vitest-config/conciv-test'
export default defineConfig({
plugins: [concivTest()], // <- each run gets its own conciv home, removed after
})
```
Then call your tool on a real engine:
```ts twoslash title="test/it/project-version.it.test.ts"
import {expect} from 'vitest'
import {test} from '@conciv/backend-test-utils'
test('the agent reads the project version', async ({createEngine}) => {
const engine = await createEngine({}, {directory: '.'}) // <- '.' is the folder you run vitest from
expect(await engine.session.tool('project_version').call({})).toMatchObject({version: expect.any(String)})
})
```
Run it from your project root with `npx vitest run`.
A few things to notice:
- vitest collects tests from `test/unit`, `test/it` and `test/e2e`. Engine tests go in `test/it`.
- `test` is vitest's `test` with a `createEngine` fixture. It starts the real engine on a free port.
- The first argument of `createEngine` is your conciv config. Here it is empty, because `conciv/plugins` loads on
its own, as in your app.
- `directory: '.'` resolves against vitest's working folder. Run vitest from your project root, or pass that folder.
- The fixture stops every engine the test started when the test ends, pass or fail.
## Script the agent [#script-the-agent]
`TestLLM` plays the agent. Queue its replies, then send a message as the user:
```ts twoslash title="test/it/release.it.test.ts"
import {expect} from 'vitest'
import {test, TestLLM} from '@conciv/backend-test-utils'
test('shipping a branch asks the user first', async ({createEngine}) => {
const engine = await createEngine({}, {directory: '.'})
await engine.reply(TestLLM.toolCall('c1', 'release_ship', {branch: 'main'})) // <- the model calls the tool
const asked = await engine.event('permission.asked') // <- listen before it happens
const shipping = engine.session.send('Ship main')
await expect(asked.arrived).resolves.toMatchObject({data: {action: 'release_ship', resources: ['main']}})
await engine.session.stop()
await shipping
})
```
The turn runs your real tool, so the permission ask is real. `engine.session.stop` stops the turn, as the user's
Stop button does. `TestLLM.text` makes a plain text reply, to end a turn after a tool call.
## Drive the widget in a browser test [#drive-the-widget-in-a-browser-test]
A browser test renders the real widget against the real engine, in Chromium. Install what it imports, and the
browser:
```package-install
npm install -D @internal/frontend-test-utils @solidjs/testing-library @testing-library/user-event
```
```bash title="terminal"
npx playwright install chromium
```
Turn on browser tests in the config with `concivTest({browser: true})`. Then check that the user sees the card:
```tsx twoslash title="test/e2e/project-version.e2e.test.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// @filename: conciv/plugins/project-version/plugin-experimental.tsx
import {Plugin, ToolRegistry} from '@conciv/frontend-plugin-api'
export default Plugin.define({
setup(ctx) {
ctx.add(ToolRegistry, {name: 'project_version', render: (props) =>
{props.output}
})
},
})
// @filename: test/e2e/project-version.e2e.test.tsx
import '@testing-library/jest-dom/vitest'
// ---cut---
import {expect} from 'vitest'
import {screen} from '@solidjs/testing-library'
import userEvent from '@testing-library/user-event'
import {test, TestLLM} from '@conciv/backend-test-utils'
import {renderTestApp} from '@internal/frontend-test-utils/app'
import versionCard from '../../conciv/plugins/project-version/plugin-experimental'
test('the user sees the version card', async ({createEngine}) => {
const user = userEvent.setup()
const engine = await createEngine({}, {directory: '.'})
await engine.reply(TestLLM.toolCall('c1', 'project_version', {}), TestLLM.text('Here is the version'))
await renderTestApp({engine, plugins: [{id: 'project-version', plugin: versionCard}]}) // <- the whole widget
await user.type(await screen.findByRole('textbox', {name: 'Message the conciv agent'}), 'What version is this?')
await user.click(screen.getByRole('button', {name: 'Send message'}))
expect(await screen.findByText(/^\S+ \d+\.\d+\.\d+/)).toBeVisible() // <- your card: name and version
})
```
The test finds the composer by its label and types into it, as a user does. `findByText` waits until the card
shows.
- `TestLLM.failAfter(error)`: the model fails part way through its reply.
- `TestLLM.hang()`: a reply that never ends, so the turn runs until it is stopped.
- `engine.gate()`: holds the next reply until the test lets it go.
- `engine.requests()`: every request the model got, with its system prompt, tools and messages.
- `engine.rpc.call(id, method, input)`: calls one of your RPC methods. `engine.rpc.failure(...)` resolves to the
error of one that must fail.
## Next steps [#next-steps]
- **[Add a tool](/docs/plugins/guides/tool)**: the tools these tests call.
- **[Plugin API reference](/docs/plugins/reference)**: every `ctx` domain.
# Add a tool (/docs/plugins/guides/tool)
A tool is a function in your plugin's engine part that the agent can call. This guide builds `ticket_read`, which
reads a ticket from your tracker by its id.
## Write the tool [#write-the-tool]
Add tools inside `ctx.tool.transform`. Each `tools.add` call adds one:
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Promise" tab-group="plugin-api"
import {z} from 'zod'
import {Plugin, Tool} from '@conciv/backend-plugin-api'
const Ticket = z.object({title: z.string(), status: z.string()})
export default Plugin.define({
id: 'tickets',
async setup(ctx) {
await ctx.tool.transform((tools) => {
tools.add({
name: 'ticket_read', // <- letters, digits and _
description: 'Read a ticket from the tracker by its id, such as OPS-42.',
input: z.object({id: z.string().regex(/^OPS-[0-9]+$/)}), // <- checked before your code runs
output: Ticket,
options: {codemode: false},
execute: async ({id}, context) => {
try {
const response = await fetch(`https://tickets.example.com/api/${id}`, {signal: context.signal})
return {output: Ticket.parse(await response.json())}
} catch {
throw Tool.toolError({message: `The tracker did not answer for ${id}.`})
}
},
})
})
},
})
```
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Effect" tab-group="plugin-api"
import {Effect} from 'effect'
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api/effect'
import * as Tool from '@conciv/protocol/schema/tool'
const Ticket = z.object({title: z.string(), status: z.string()})
export default Plugin.define({
id: 'tickets',
effect: (ctx) =>
ctx.tool.transform((tools) => {
tools.add({
name: 'ticket_read', // <- letters, digits and _
description: 'Read a ticket from the tracker by its id, such as OPS-42.',
input: z.object({id: z.string().regex(/^OPS-[0-9]+$/)}), // <- checked before your code runs
output: Ticket,
options: {codemode: false},
execute: ({id}) =>
Effect.tryPromise({
try: async (signal) => {
const response = await fetch(`https://tickets.example.com/api/${id}`, {signal})
return Ticket.parse(await response.json())
},
catch: () => Tool.toolError({message: `The tracker did not answer for ${id}.`}),
}).pipe(Effect.map((ticket) => ({output: ticket}))),
})
}),
})
```
Ask the agent "What is the status of OPS-42?". It calls `ticket_read` and answers from the ticket.
A few things to notice:
- `description` is how the agent decides when to call the tool. Say what it does and what input it expects.
- What you return as `output` is what the agent reads. It must match the `output` schema.
- A network error and a bad shape both fail the call with the same message, in both tabs.
- The signal aborts when the user stops the turn. Pass it to `fetch` so the request stops too.
## Direct or code mode [#direct-or-code-mode]
A tool is a code-mode tool unless you set `codemode: false`. In code mode the agent writes a short TypeScript program
that calls your tool as `external_ticket_read`. The call shows inside its code card. The agent calls a direct tool by
its name. Each call gets its own card.
Pick direct when the user should see each call, or when you draw a card for it. Learn more in
[Tools and code mode](/docs/tools-and-code-mode).
## Group tools under a namespace [#group-tools-under-a-namespace]
A namespace puts related tools under one name and one description:
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Promise" tab-group="plugin-api"
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api'
export default Plugin.define({
id: 'tickets',
async setup(ctx) {
await ctx.tool.transform((tools) => {
tools.namespace({name: 'ticket', description: 'The team tracker: read and search tickets.'})
tools.add({
name: 'read',
description: 'Read a ticket by its id, such as OPS-42.',
input: z.object({id: z.string()}),
options: {namespace: 'ticket'}, // <- the full name becomes ticket_read
execute: async ({id}) => ({content: `${id} is open.`}),
})
})
},
})
```
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Effect" tab-group="plugin-api"
import {Effect} from 'effect'
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api/effect'
export default Plugin.define({
id: 'tickets',
effect: (ctx) =>
ctx.tool.transform((tools) => {
tools.namespace({name: 'ticket', description: 'The team tracker: read and search tickets.'})
tools.add({
name: 'read',
description: 'Read a ticket by its id, such as OPS-42.',
input: z.object({id: z.string()}),
options: {namespace: 'ticket'}, // <- the full name becomes ticket_read
execute: ({id}) => Effect.succeed({content: `${id} is open.`}),
})
}),
})
```
The agent reads the namespace's description to decide which group to look at. `content` is plain text for the
agent, in place of an output. A result can carry both.
## Fail a call [#fail-a-call]
Fail a call when the tool cannot do what was asked. The agent reads the message and can try something else:
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Promise" tab-group="plugin-api"
import {z} from 'zod'
import {Plugin, Tool} from '@conciv/backend-plugin-api'
export default Plugin.define({
id: 'tickets',
async setup(ctx) {
await ctx.tool.transform((tools) => {
tools.add({
name: 'ticket_close',
description: 'Close a ticket by its id.',
input: z.object({id: z.string()}),
execute: async ({id}) => {
if (id.startsWith('SEC-'))
throw Tool.toolError({message: 'Security tickets are closed by the security team.'})
return {content: `${id} is closed.`}
},
})
})
},
})
```
```ts twoslash title="conciv/plugins/tickets/server.ts" tab="Effect" tab-group="plugin-api"
import {Effect} from 'effect'
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api/effect'
import * as Tool from '@conciv/protocol/schema/tool'
export default Plugin.define({
id: 'tickets',
effect: (ctx) =>
ctx.tool.transform((tools) => {
tools.add({
name: 'ticket_close',
description: 'Close a ticket by its id.',
input: z.object({id: z.string()}),
execute: ({id}) =>
id.startsWith('SEC-')
? Effect.fail(Tool.toolError({message: 'Security tickets are closed by the security team.'}))
: Effect.succeed({content: `${id} is closed.`}),
})
}),
})
```
`Tool.toolError` makes the error. Its `message` is what the agent sees. In the Promise tab, any other thrown
error also fails the call, with that error's message. In the Effect tab the failure type is `Tool.Error`.
Errors of your own come from one evlog error catalog, in your plugin's `errors.ts`. Each entry has a `message`, and
`why` and `fix` where someone can act on it:
```ts title="conciv/plugins/tickets/errors.ts"
import {defineErrorCatalog} from 'evlog'
export const ticketErrors = defineErrorCatalog('tickets', {
TRACKER_DOWN: {
message: ({id}: {id: string}) => `The tracker did not answer for ${id}.`,
fix: 'Check that the tracker is up, then ask again.',
},
})
declare module 'evlog' {
interface RegisteredErrorCatalogs {
tickets: typeof ticketErrors
}
}
```
Fail with `Effect.fail(ticketErrors.TRACKER_DOWN({id}))`. Turn it into a `Tool.Error` once, at the edge, and branch
on `error.code`, never on a tag:
```ts
Effect.catchIf(
(error) => error.code === ticketErrors.TRACKER_DOWN.code,
(error) => Effect.fail(Tool.toolError({message: error.message, error})),
)
```
## Draw a card [#draw-a-card]
Each call of a direct tool shows as a card in the chat. Your plugin's browser part can draw its own. You write the
browser part in Solid, React, Preact or plain DOM:
```tsx twoslash title="conciv/plugins/tickets/plugin-experimental.tsx"
// @jsx: preserve
// @jsxImportSource: solid-js
// ---cut---
import {Plugin, ToolRegistry} from '@conciv/frontend-plugin-api'
import {z} from 'zod'
const Ticket = z.object({title: z.string(), status: z.string()})
function readTicket(output: string | undefined) {
try {
return Ticket.safeParse(JSON.parse(output ?? '')).data
} catch {
return undefined
}
}
export default Plugin.define({
setup(ctx) {
ctx.add(ToolRegistry, {
name: 'ticket_read',
render: (props) => {
const ticket = () => readTicket(props.output) // <- output is JSON text once the call ends
return (
{ticket()
? `${ticket()?.title}: ${ticket()?.status}`
: props.output === undefined
? 'Reading the ticket'
: 'No ticket to show'}
)
},
errorComponent: (props) =>
The ticket could not be read: {props.error}
, // <- a failed call
})
},
})
```
The card lives in your app. Give it to `` as in
[Build your first plugin](/docs/plugins/first-plugin#build-or-wire-the-browser-part).
```tsx twoslash title="src/conciv/tickets.tsx"
// @jsx: react-jsx
// @jsxImportSource: react
// ---cut---
import {ToolRegistry, type Plugin, type ToolProps} from '@conciv/frontend-plugin-api'
import {reactRender} from '@conciv/react'
import {z} from 'zod'
const Ticket = z.object({title: z.string(), status: z.string()})
function readTicket(output: string | undefined) {
try {
return Ticket.safeParse(JSON.parse(output ?? '')).data
} catch {
return undefined
}
}
function TicketCard(props: ToolProps) {
const ticket = readTicket(props.output) // <- output is JSON text once the call ends
if (ticket) return
{`${ticket.title}: ${ticket.status}`}
return
{props.output === undefined ? 'Reading the ticket' : 'No ticket to show'}
}
function TicketError(props: ToolProps) {
return
The ticket could not be read: {props.error}
}
export const tickets: Plugin.Setup = (ctx) => {
ctx.add(ToolRegistry, {
name: 'ticket_read',
render: reactRender(TicketCard),
errorComponent: reactRender(TicketError), // <- a failed call
})
}
```
The card lives in your app. Give it to `` as in
[Build your first plugin](/docs/plugins/first-plugin#build-or-wire-the-browser-part).
```tsx twoslash title="src/conciv/tickets.tsx"
// @jsx: react-jsx
// @jsxImportSource: preact
// ---cut---
import {ToolRegistry, type Plugin, type ToolProps} from '@conciv/frontend-plugin-api'
import {preactRender} from '@conciv/preact'
import {z} from 'zod'
const Ticket = z.object({title: z.string(), status: z.string()})
function readTicket(output: string | undefined) {
try {
return Ticket.safeParse(JSON.parse(output ?? '')).data
} catch {
return undefined
}
}
function TicketCard(props: ToolProps) {
const ticket = readTicket(props.output) // <- output is JSON text once the call ends
if (ticket) return
{`${ticket.title}: ${ticket.status}`}
return
{props.output === undefined ? 'Reading the ticket' : 'No ticket to show'}
}
function TicketError(props: ToolProps) {
return
The ticket could not be read: {props.error}
}
export const tickets: Plugin.Setup = (ctx) => {
ctx.add(ToolRegistry, {
name: 'ticket_read',
render: preactRender(TicketCard),
errorComponent: preactRender(TicketError), // <- a failed call
})
}
```
```ts twoslash title="conciv/plugins/tickets/plugin-experimental.ts"
import {mountRender, Plugin, ToolRegistry, type ToolProps} from '@conciv/frontend-plugin-api'
import {z} from 'zod'
const Ticket = z.object({title: z.string(), status: z.string()})
function describeCall(output: string | undefined) {
try {
const ticket = Ticket.parse(JSON.parse(output ?? '')) // <- output is JSON text once the call ends
return `${ticket.title}: ${ticket.status}`
} catch {
return output === undefined ? 'Reading the ticket' : 'No ticket to show'
}
}
function drawLine(text: (props: ToolProps) => string) {
return mountRender((element, props) => {
const line = element.appendChild(document.createElement('p'))
const stop = props.subscribe(() => {
line.textContent = text(props.current())
})
return () => {
stop()
line.remove()
}
})
}
export default Plugin.define({
setup(ctx) {
ctx.add(ToolRegistry, {
name: 'ticket_read',
render: drawLine((props) => describeCall(props.output)),
errorComponent: drawLine((props) => `The ticket could not be read: ${props.error}`), // <- a failed call
})
},
})
```
A few things to notice:
- `render` draws one call. It runs again as the call moves on. `props.input` is the input the agent sent.
- A denied or cancelled call reaches `render` too, with text that is not JSON. The guarded parse keeps the card up.
- `errorComponent` draws a failed call, with the message in `props.error`. Without it the widget shows its error
card.
- A card that pulls in a large library can load on its first call: give `render` a component made with Solid's
`lazy()`. Learn more in [Load a part lazily](/docs/plugins/reference#load-a-part-lazily).
Build or wire it as in [Build or wire the browser part](/docs/plugins/first-plugin#build-or-wire-the-browser-part),
then reload.
A tool's input and output schemas can be:
- a zod schema
- any other Standard Schema, such as Valibot or ArkType
- an Effect Schema
- a raw JSON Schema object
## Next steps [#next-steps]
- **[Ask for permission](/docs/plugins/guides/permission)**: make the user approve a call before it runs.
- **[Test your plugin](/docs/plugins/guides/testing)**: call your tool on a real engine in a test.
- **[Plugin API reference](/docs/plugins/reference)**: every field of a tool and its context.
# Plugins (/docs/plugins)
A plugin is code you add to conciv. Its engine part gives the agent new tools. Its browser part adds screens to
the widget. A plugin in your project's `conciv/plugins` folder loads with no config entry.
## What a plugin can do [#what-a-plugin-can-do]
- **Give the agent a tool.** The agent calls it like any built-in tool. The test runner adds `test_runner_run`, so
you can say "run the tests".
- **Ask the user first.** A tool can stop and show an approval card before it acts.
- **Draw a card in the chat.** A tool's calls show as your own component instead of the generic card.
- **Add a panel.** A tab next to the chat. The test runner's Tests tab follows a run live.
- **Add a slot or a pill.** Content at a fixed place in the widget, or a button above the composer.
- **Answer RPC calls.** Your browser part, a terminal or another plugin calls your engine part by name.
## Pick a plugin or a skill [#pick-a-plugin-or-a-skill]
Start with the smallest thing that does the job:
| You want the agent to | Use |
| ----------------------------------------------------- | -------------------------------------------------------------------------- |
| Follow your steps for a kind of task | a [skill](/docs/skills), a Markdown file with no code |
| Run code you wrote, or read something it cannot reach | a plugin with a [tool](/docs/plugins/guides/tool) |
| Show you something in the widget | a plugin with a [panel](/docs/plugins/guides/panel) or a card for its tool |
To add a plugin someone else wrote, such as the test runner or the [live recorder](/docs/usage/live-recorder), see
[Add plugins](/docs/usage/add-plugins).
## Start here [#start-here]
- [Build your first plugin](/docs/plugins/first-plugin): a tool the agent calls and the card it draws, from an empty
folder.
## Engine part [#engine-part]
- [Add a tool](/docs/plugins/guides/tool): run your code when the agent asks, direct or in code mode.
- [Ask for permission](/docs/plugins/guides/permission): show an approval card before a tool acts.
- [Add a skill](/docs/plugins/guides/skill): ship instructions that teach the agent your tools.
- [Share an RPC method](/docs/plugins/guides/rpc): let the browser part and other callers reach the engine part.
- [Call your plugin from a terminal](/docs/plugins/guides/terminal): run an RPC method from your shell.
## Browser part [#browser-part]
- [Add a panel](/docs/plugins/guides/panel): a tab next to the chat with your own screen.
- [Add a slot or composer pill](/docs/plugins/guides/slot-pill): a small piece of UI at a fixed place.
- [Add settings](/docs/plugins/guides/settings): read config options, and add a setting to the widget.
## Check and look up [#check-and-look-up]
- [Test your plugin](/docs/plugins/guides/testing): run your plugin on a real engine in a test.
- [Plugin API reference](/docs/plugins/reference): every import and every field of `ctx`, in both styles.
# Plugin API reference (/docs/plugins/reference)
Look up an import or a field here. Each table is generated from the published packages' types. The list under it says
what each row is for. The [guides](/docs/plugins) show each one in use.
## What to import [#what-to-import]
| Import | You import it when you |
| ------------------------------------------ | ------------------------------------------------------------ |
| `@conciv/backend-plugin-api` | write an engine part with async and await |
| `@conciv/backend-plugin-api/effect` | write an engine part with Effect |
| `@conciv/backend-plugin-api/effect/plugin` | type a helper function that takes the Effect `ctx` |
| `@conciv/backend-plugin-api/effect/rpc` | type the registration your RPC handlers belong to, in Effect |
| `@conciv/protocol/schema/rpc` | declare an RPC contract that both parts import |
| `@conciv/protocol/schema/tool` | fail a tool call with a `Tool.Error` in Effect |
| `@conciv/frontend-plugin-api` | write a browser part: panels, slots, pills, cards, settings |
| `@conciv/frontend-plugin-api/vite` | build a browser part into the bundle the engine serves |
| `@conciv/react` | draw a browser part's UI with React components, in your app |
| `@conciv/preact` | draw a browser part's UI with Preact components, in your app |
| `@conciv/client` | read data in a browser part through the widget's query cache |
| `@conciv/backend-test-utils` | start a real engine in a test and script the agent |
## Plugin.define [#plugindefine]
What the engine part's `Plugin.define` takes:
### $Fumadocs
| Prop | Type | Description |
| ------- | ------------------------------------------------------------------- | ----------- |
| `id` | `string` | |
| `setup` | `(context: Context) => Promise \| Cleanup \| void` | |
- `id`: the plugin's name. A config entry turns it off as `-`.
- `setup`: runs once when the engine loads the plugin. It can return a cleanup that runs when the plugin unloads.
### $Fumadocs
| Prop | Type | Description |
| -------- | -------------------------------------------------- | ----------- |
| `id` | `string` | |
| `effect` | `(context: Context) => Effect` | |
- `id`: the plugin's name. A config entry turns it off as `-`.
- `effect`: runs once when the engine loads the plugin. Its scope closes when the plugin unloads.
What the browser part's `Plugin.define` takes:
### $Fumadocs
| Prop | Type | Description |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `stores?` | `Readonly>> \| undefined` | |
| `icons?` | `Readonly> \| undefined` | The plugin's own icons, by name, for artwork the app's icon catalog does not have. Each value is an SVG document as text, as a design tool exports it; a bundle built with `gui()` imports the file with `?raw`. The host registers them before setup, and `ctx.icons` gives each one's name for every SDK icon field and for `ctx.ui.Icon`. A value that is not an SVG document fails the plugin when it starts. - The document's `viewBox` frames the drawing, else its `width` and `height`. The host scales the drawing to the place that shows it, so draw on the app's 16px grid. - Draw with `currentColor`: the icon takes the color of the place that shows it, such as a pill's `tone`. - A drawing may move with SVG animation elements (`animate`, `animateTransform`). Every place that shows the icon moves in step, and the animation goes on while the host renders that place again. Under the user's reduced motion setting the host holds the icon on its first frame, so make that frame the resting drawing. - An `id` in the drawing is the whole window's; keep it unique, or leave it out. |
| `beforeRegister?` | `((options: PluginOptions) => void) \| undefined` | Runs once, synchronously, with the plugin's options, before any plugin's window setup: as soon as the host knows the plugin, which for a built-in is the top of the app's mount. For page-wide hooks that must exist before the host page's own code reads them. `enforce` orders the calls as Vite orders plugins: every `pre`, then those without, then every `post`. Return nothing; a throw is logged and the plugin still loads. |
| `enforce?` | `Enforce \| undefined` | |
| `setup?` | `Setup>>, Readonly>>>> \| undefined` | |
- `stores`: values the widget keeps for the plugin. See [Add settings](/docs/plugins/guides/settings).
- `icons`: SVG icons of your own, named for `ctx.ui.Icon`.
- `beforeRegister`: runs once with the options, before any plugin's setup, for hooks the page needs early.
- `enforce`: orders `beforeRegister` calls: every `pre`, then the rest, then every `post`.
- `setup`: runs once when the widget loads the browser part. It has no `id`. It takes the engine part's.
## Engine ctx [#engine-ctx]
What `setup` or `effect` gets as `ctx`. In the Promise style each domain returns a `Promise`. In the Effect style the
same fields return an `Effect`.
### $Fumadocs
| Prop | Type | Description |
| -------------- | ---------------------------------------------------------------------------------------------------------------- | ----------- |
| `app` | `App \| undefined` | |
| `location` | `Info` | |
| `options` | `Readonly>` | |
| `agent` | `AgentDomain` | |
| `bundler` | `BundlerDomain` | |
| `credential` | `CredentialDomain` | |
| `event` | `EventDomain` | |
| `experimental` | `{ readonly generate: ExperimentalGenerateApi \| undefined; }` | |
| `integration` | `IntegrationDomain` | |
| `model` | `ModelDomain` | |
| `permission` | `PermissionDomain` | |
| `plugin` | `{ readonly list: (requestOptions?: RpcCallOptions) => Promise<{ location: PublicRef; data: PluginInfo[]; }>; }` | |
| `rpc` | `RpcDomain` | |
| `browserTabs` | `BrowserTabDomain` | |
| `job` | `JobDomain` | |
| `session` | `SessionDomain` | |
| `skill` | `SkillDomain` | |
| `storage` | `StorageDomain` | |
| `tool` | `ToolDomain` | |
| `servers` | `Servers` | |
### $Fumadocs
| Prop | Type | Description |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| `app` | `App` | |
| `location` | `Info` | |
| `options` | `Readonly>` | |
| `agent` | `AgentDomain` | |
| `bundler` | `BundlerDomain` | |
| `credential` | `CredentialDomain` | |
| `event` | `EventDomain` | |
| `experimental` | `{ readonly generate: undefined; }` | |
| `integration` | `IntegrationDomain` | |
| `model` | `ModelDomain` | |
| `permission` | `PermissionDomain` | |
| `plugin` | `{ readonly list: (input?: { readonly location?: { readonly directory?: string \| undefined; } \| undefined; }) => Effect<{ readonly location: PublicRef; readonly data: ReadonlyArray; }, unknown>; }` | |
| `rpc` | `RpcDomain` | |
| `browserTabs` | `BrowserTabDomain` | |
| `job` | `JobDomain` | |
| `session` | `SessionDomain` | |
| `skill` | `SkillDomain` | |
| `storage` | `StorageDomain` | |
| `tool` | `ToolDomain` | |
| `servers` | `Servers` | |
- `app`: the running conciv, with its version, release channel and platform.
- `location`: where the engine runs. Its `directory` is your project folder.
- `options`: the options from the plugin's config entry, as JSON.
- `agent`: change the agent profiles, such as their permission rules.
- `event`: follow the engine's events.
- `model`: list the models, and add or change them.
- `permission`: ask the user before an action. See [Ask for permission](/docs/plugins/guides/permission).
- `plugin`: list the plugins the engine loaded.
- `rpc`: answer an RPC contract, or call another plugin's. See [Share an RPC method](/docs/plugins/guides/rpc).
- `browserTabs`: list the browser tabs a session's page plugin sees.
- `job`: start, wait on and cancel background jobs.
- `session`: list, create and drive sessions.
- `skill`: add, change and remove skills. See [Add a skill](/docs/plugins/guides/skill).
- `storage`: a key-value store kept for your plugin, and a folder for its files.
- `tool`: add, change and remove tools, and hook into their calls. See [Add a tool](/docs/plugins/guides/tool).
- `servers`: the dev servers the engine knows about.
- `bundler`: hook into your app's bundler, with `resolveId`, `load` and `transform`.
- `experimental`: APIs that can still change. Its `generate` asks a model for text, decisions or an image. It is
`undefined` in the Effect style.
## A tool [#a-tool]
What `tools.add` takes:
### $Fumadocs
| Prop | Type | Description |
| ------------- | ---------------------------------------------------------------------------------------------- | ----------- |
| `name` | `string` | |
| `input` | `ValueSchema` | |
| `description` | `string` | |
| `output?` | `ValueSchema \| undefined` | |
| `options?` | `Options \| undefined` | |
| `execute` | `(input: unknown, context: ToolContext) => Promise \| undefined>>` | |
### $Fumadocs
| Prop | Type | Description |
| ------------- | ----------------------------------------------------------------------------------------------- | ----------- |
| `name` | `string` | |
| `input` | `ValueSchema` | |
| `description` | `string` | |
| `execute` | `(input: any, context: Context) => Effect \| undefined>, Error, never>` | |
| `output?` | `ValueSchema \| undefined` | |
| `options?` | `Options \| undefined` | |
- `name`: what the agent calls. Use letters, digits and `_`.
- `description`: how the agent decides when to call it.
- `input`: the schema the agent's input must match. The engine checks it before your code runs.
- `output`: the schema of the result's `output`.
- `options`: `codemode`, `namespace`, `permission` and `pinned`. See
[Tools and code mode](/docs/tools-and-code-mode).
- `execute`: runs one call. It returns a `Promise` or an `Effect` of the result.
What `execute` gets as its second argument:
### $Fumadocs
| Prop | Type | Description |
| ----------- | ----------------------------------------------------- | ----------- |
| `signal` | `AbortSignal` | |
| `progress` | `(update: Metadata) => Promise` | |
| `sessionId` | `string & $brand<"ConcivSessionId">` | |
| `agent` | `string & Brand<"Agent.ID">` | |
| `messageId` | `(string & Brand<"Session.Message.ID">) \| undefined` | |
| `id` | `string & Brand<"Tool.CallID">` | |
| `origin` | `Origin` | |
### $Fumadocs
| Prop | Type | Description |
| ----------- | ----------------------------------------------------- | ----------- |
| `sessionId` | `string & $brand<"ConcivSessionId">` | |
| `agent` | `string & Brand<"Agent.ID">` | |
| `messageId` | `(string & Brand<"Session.Message.ID">) \| undefined` | |
| `id` | `string & Brand<"Tool.CallID">` | |
| `origin` | `Origin` | |
| `progress` | `(update: Metadata) => Effect` | |
| `cancel?` | `Effect \| undefined` | |
- `sessionId`: the chat the call runs in.
- `agent`: the agent profile running the call.
- `messageId`: the agent message that holds the call, when there is one.
- `id`: the call's own id.
- `origin`: where the call came from: `chat` for the widget, `hub` for an agent outside it.
- `progress`: sends an update the card can show while the call runs.
- `signal` (Promise): aborts when the user stops the turn.
- `cancel` (Effect): set when the call can be cancelled.
What `execute` returns:
### $Fumadocs
| Prop | Type | Description |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| `output?` | `any` | |
| `content?` | `string \| readonly ({ readonly type: "text"; readonly text: string; } \| { readonly type: "file"; readonly uri: string; readonly mime: string; readonly name?: string \| undefined; })[] \| undefined` | |
| `metadata?` | `Readonly> \| undefined` | |
- `output`: the result the agent reads, matching the `output` schema.
- `content`: text or files for the agent, in place of or beside `output`.
- `metadata`: data for the card. The agent does not read it.
What `tools` is inside `ctx.tool.transform`:
### $Fumadocs
| Prop | Type | Description |
| ----------- | ---------------------------------------------------------------------------------------------------------------------- | ----------- |
| `list` | `() => readonly (Info & { readonly id: string; })[]` | |
| `get` | `(id: string) => (Info & { readonly id: string; }) \| undefined` | |
| `namespace` | `(namespace: Namespace) => void` | |
| `add` | `(tool: Info) => void` | |
| `update` | `(id: string, update: (tool: Mutable, ValueSchema \| undefined>>) => void) => void` | |
| `remove` | `(id: string) => void` | |
### $Fumadocs
| Prop | Type | Description |
| ----------- | --------------------------------------------------------------------------------------------------------- | ----------- |
| `list` | `() => readonly (Info & { readonly id: string; })[]` | |
| `get` | `(id: string) => (Info & { readonly id: string; }) \| undefined` | |
| `namespace` | `(namespace: Namespace) => void` | |
| `add` | `(tool: Info) => void` | |
| `update` | `(id: string, update: (tool: Mutable) => void) => void` | |
| `remove` | `(id: string) => void` | |
- `list`: every tool, with its full id.
- `get`: one tool by its id.
- `namespace`: describe a group of tools once.
- `add`: add one tool.
- `update`: change a tool, such as another plugin's.
- `remove`: remove a tool by its id.
## An RPC method [#an-rpc-method]
One entry of a contract's `methods`:
### $Fumadocs
| Prop | Type | Description |
| --------- | ----------------------- | ----------- |
| `input` | `ValueSchema` | |
| `output` | `ValueSchema` | |
| `errors?` | `ErrorMap \| undefined` | |
- `input`: the schema the caller's input must match.
- `output`: the schema of what the method returns.
- `errors`: the failures callers can tell apart, each with the schema of its data.
## Browser ctx [#browser-ctx]
What the browser part's `setup` gets as `ctx`:
### $Fumadocs
| Prop | Type | Description |
| ------------ | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `options` | `PluginOptions` | The plugin's options from the conciv config, as `ctx.options` in its engine part. A built-in gets the options of the config entry naming its id, else nothing. |
| `client` | `ConcivClient` | The client of the engine that runs the plugin. Call the plugin's engine part through it. A new client after that engine restarts; read it where you call it. While the engine is unreachable, every call rejects. A built-in plugin gets a client whose calls all reject. |
| `id` | `string` | The plugin's id, as its engine part's `Plugin.define` declares it. |
| `signal` | `AbortSignal` | Aborts when the plugin is disabled or reloaded, or when the window closes. After an `await`, return if it aborted. A window has no owner after an `await`, so listen to the signal for teardown that starts there. |
| `log` | `Log` | The widget's logger: off unless the engine's `logs.level` turns it on, and drained to the engine with the widget's own events. Log with an object whose `action` names the area and `message` says what happened. |
| `add` | `{ (registry: Registry, item: () => T \| undefined): Cleanup; (registry: Registry, item: T): Cleanup; }` | Contributes an item that follows reactive state: the window re-runs the function when what it reads changes. Return undefined to withdraw the item until it returns one again. The host withdraws it with the current owner (a `createKeyed` run or a component), else with the plugin; made after that owner or the plugin ended, it is withdrawn at once. Contributes a fixed item to a registry. The host withdraws it with the current owner (a `createKeyed` run or a component), else with the plugin; made after that owner or the plugin ended, it is withdrawn at once. Use the function form for an item that follows reactive state. |
| `list` | `(registry: Registry) => readonly T[]` | The items every plugin contributed to a registry, in contribution order. Reactive. Use it for a registry your plugin owns. |
| `provide` | `>(token: C, impl: TokenValue) => Cleanup` | Provides an in-process contract. Withdrawn with the current owner, else with the plugin. Throws for a contract whose id is not your plugin's id or under it (`.`). |
| `use` | `(token: T) => Accessor>>` | Follows a contract that another plugin provides. Returns a `Live` accessor: pending while its provider loads, active with its value, inactive while it is turned off or failed. The plugin must keep working while it is inactive. Branch on it, or follow it with `createKeyed`. The provider is the plugin whose id the token's id names. |
| `layout` | `Layout` | Panel tabs, scroll offsets, and the settings page. |
| `sessions` | `Sessions` | The sessions of open shell tabs, and the mounted one. |
| `screen` | `Screen` | The mounted session screen and its route-following composer. Read it where you act, so an action targets the session routed at that moment; a `MountedSession` carries no such actions. |
| `storage` | `Storage` | Stores for keys only known at runtime, and window-local memory. Declare `stores` for keys known up front. |
| `system` | `System` | The clipboard, saving files, and opening URLs in a new browser tab. |
| `desktop` | `Desktop \| undefined` | Abilities on the user's machine, through the engine: opening a file in the user's editor. |
| `dialogs` | `Dialogs` | Dialogs that close with the owner that opened them, else when the plugin goes away. |
| `toast` | `Toasts` | Short messages in a corner of the window. A plugin's toasts close when it goes away. |
| `tabs` | `Tabs` | The open session tabs across engines: list, open, show and close them. |
| `attention` | `Attention` | Tells the user something waits for them while the panel is closed, through the launcher. |
| `commands` | `Commands \| undefined` | |
| `links` | `Links` | Routes local links to the plugins that handle them. |
| `ui` | `Ui` | The app's own components: icons, buttons, tooltips, menus and menu rows, the loading indicator, the dialog frame, switches, text fields, selects, keybind chips, Markdown, highlighted code, and settings pages, sections and rows. |
| `app` | `App` | The running app: its version, release channel and platform, as `ctx.app` in engine plugins. |
| `appearance` | `Appearance` | The user's appearance settings. |
| `overlay` | `(options?: { readonly styles?: readonly string[]; }) => { readonly element: HTMLElement; dispose(): void; }` | A layer over the page, under the app: a `div` in its own shadow root on `document.body`, styled with the app's stylesheet and carrying the app's base font and text color, color scheme and skin. Removed by `dispose`, else with the current owner, else with the plugin. The layer lets clicks through to the page; content that must be clickable opts back in with `pointer-events-auto`. The layer is not an Ark environment: a `ctx.ui` popover, menu or tooltip rendered inside it portals to the page's `document.body`, outside the app's stylesheet. |
| `router` | `Router` | The app's route. |
| `keybinds` | `Keybinds` | The effective keybinds of published commands. |
| `servers` | `Servers` | The servers the app lists: their ids, and each one's live `ServerRef`. |
- `id`: the plugin's id, from its engine part.
- `options`: the options from the plugin's config entry.
- `signal`: aborts when the plugin reloads or stops.
- `client`: calls the engine: `client.rpc(contract)` and `client.event.subscribe`.
- `add`: adds an entry to a registry, such as `Panel` or `ToolRegistry`. `list` reads a registry.
- `provide` and `use`: share an in-process contract with another plugin.
- `layout`: panel tabs, scroll offsets and the settings page.
- `sessions`: the sessions of open tabs, and the mounted one.
- `screen`: the mounted session's screen and its composer.
- `storage`: stores for keys known only at run time.
- `system`: the clipboard, saving files and opening URLs.
- `desktop`: opens a file in the user's editor, when the engine can.
- `dialogs`: opens dialogs that close with their owner.
- `toast`: short messages in a corner of the window.
- `tabs`: the open session tabs, across engines.
- `links`: routes local links to the plugins that handle them.
- `ui`: the widget's own Solid components, such as `Icon`, `Button`, `Switch` and `SettingsRow`.
- `app`: the widget's version, release channel and platform.
- `appearance`: the user's appearance settings.
- `overlay`: a layer over the page, under the widget.
- `router`: the widget's route.
- `keybinds`: the keybinds of published commands.
- `servers`: the dev servers the engine knows about.
- `attention` and `commands`: not implemented yet, always `undefined`.
## Browser registries [#browser-registries]
### Panel [#panel]
### $Fumadocs
| Prop | Type | Description |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | `string` | |
| `region` | `"pane"` | |
| `transient?` | `boolean \| undefined` | |
| `normalize?` | `((input: { readonly id: string; readonly session: MountedSession; readonly screen: SessionScreen; }) => string) \| undefined` | The canonical form of one of this panel's stored tab ids, when one tab can be stored more than one way (e.g. the same file as an absolute and a relative path). The host rewrites stored ids and drops duplicates. Reactive. |
| `mobile?` | `MobileView \| undefined` | |
| `list` | `(input: { readonly session: MountedSession; readonly screen: SessionScreen; readonly open: readonly string[]; }) => readonly PanelTab[]` | Reactive, and runs again when another session is routed. `open` holds this plugin's tab ids stored in the strip. List those that still apply, plus any `pinned` tab. The host renders triggers, restore, and selection from this data. Cache tab objects by something that outlives one session object (the tab id, `session.key`, or the screen passed as `input.screen`), so a session switch does not render their labels again. Read the getters; do not destructure. |
| `render` | `(props: PanelProps) => JSX.Element` | Renders a tab's content once; its own reactivity updates it, also when another session is routed. A render that throws renders nothing and records the error. |
| `close?` | `((input: PanelProps) => void) \| undefined` | Runs after the host removes the tab from the strip. |
| `closed?` | `((input: PanelProps) => ClosedPanelTab \| false \| undefined) \| undefined` | Read as the user closes a tab, so it can come back. Return how the entry reads and the data `restore` needs, or `false` when the tab cannot come back. Without it, a tab that is not `transient` comes back under the same key. The host stores the entry, so keep `data` small. |
| `restore?` | `((input: { readonly session: MountedSession; readonly screen: SessionScreen; readonly id: string; readonly data?: string; }) => void) \| undefined` | Brings back a tab `closed` listed. Without it, the host opens the same key again. |
| `focus?` | `((input: PanelProps & { readonly restored: boolean; }) => void) \| undefined` | Runs when the tab becomes selected. `restored` is true for the selection the pane mounts with, e.g. the tab selected before a reload, and false for every later selection change. |
- `id`: the panel's name, unique in your plugin.
- `region`: where the tabs go. It is required, and `'pane'` is the only value.
- `list`: the tabs to show. It runs again when what it reads changes.
- `render`: draws a tab's content once.
- `close`, `closed` and `restore`: run as the user closes a tab, and bring it back.
- `focus`: runs when one of your tabs is selected.
- `normalize`, `mobile` and `transient`: how stored tabs are matched, shown on a phone, and kept.
One tab that `list` returns:
### $Fumadocs
| Prop | Type | Description |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| `id` | `string` | |
| `title` | `string` | |
| `label?` | `((state: { readonly active: boolean; readonly preview: boolean; readonly session: MountedSession; }) => JSX.Element) \| undefined` | |
| `pinned?` | `boolean \| undefined` | |
| `draggable?` | `boolean \| undefined` | |
| `closable?` | `"compact" \| "hover" \| false \| undefined` | |
| `transient?` | `boolean \| undefined` | |
| `fallback?` | `boolean \| undefined` | |
| `group?` | `string \| undefined` | |
| `missing?` | `boolean \| undefined` | |
| `hidden?` | `boolean \| undefined` | |
| `file?` | `string \| undefined` | |
| `tabbable?` | `boolean \| undefined` | |
- `id`: the tab's id, stored in the user's open tabs.
- `title`: the tab's name, shown when it has no `label`.
- `label`: what the tab strip draws.
- `pinned`: always in the strip.
- `closable`, `draggable` and `tabbable`: how the user can close, move and reach the tab.
- `transient`, `fallback`, `group`, `missing`, `hidden` and `file`: how the strip treats the tab.
### Slot [#slot]
### $Fumadocs
| Prop | Type | Description |
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `at` | `"page.overlay" \| "session.header" \| "session.status" \| "window.bottom"` | |
| `order?` | `number \| undefined` | |
| `render` | `((input: Record) => JSX.Element) \| ((input: { readonly screen: SessionScreen; readonly session: MountedSession; readonly active: boolean; readonly compact: boolean; }) => JSX.Element) \| ((input: { readonly screen: SessionScreen; readonly session: MountedSession; }) => JSX.Element) \| ((input: Record) => JSX.Element)` | Renders the content once; its own reactivity updates it. Session and active fields are reactive getters, so read `input.session` where you use it: another routed session arrives through it without a remount. `screen` on a session slot is its constant owning screen, available during the first render. A render that throws renders nothing and records the error. |
- `at`: the place: `session.header`, `session.status`, `window.bottom` or `page.overlay`.
- `order`: sorts the slot among others at the same place.
- `render`: draws the content once. A `page.overlay` slot also takes `hides`.
### ComposerPill [#composerpill]
### $Fumadocs
| Prop | Type | Description |
| -------- | -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | `string` | |
| `order?` | `number \| undefined` | |
| `show` | `(input: ComposerPillProps) => ComposerPillView \| undefined` | The pill above one session's composer, or undefined to show none there. Reactive: the host runs it for each mounted composer and again when what it reads changes, so read the session's state and your own here. |
| `menu?` | `((input: ComposerPillMenuProps) => JSX.Element) \| undefined` | Your content for the popover the pill opens, for a pill that needs more than `rows`, such as status text and buttons. The host owns the capsule and the popover around this content: its placement, focus, dismissal, and the heading (`title`, else `label`). When set, clicking the pill opens the popover, and the view's `rows` and `run` are unused. Renders each time the popover opens; its own reactivity updates it while open, also when another session is routed. A render that throws renders nothing and records the error. |
- `id`: the pill's name.
- `order`: sorts it among the other pills.
- `show`: what the pill looks like for one composer, or `undefined` to hide it.
- `menu`: your own content for the popover the pill opens.
What `show` returns:
### $Fumadocs
| Prop | Type | Description |
| -------- | ----------------------------------------- | ----------- |
| `label` | `string` | |
| `icon?` | `IconName \| undefined` | |
| `tone?` | `ComposerPillTone \| undefined` | |
| `title?` | `string \| undefined` | |
| `rows?` | `readonly ComposerPillRow[] \| undefined` | |
| `run?` | `(() => void) \| undefined` | |
- `label`: the pill's text, and `title` the popover's heading.
- `icon` and `tone`: the pill's icon, and its colour for success, warning or danger.
- `run`: what a click does.
- `rows`: a menu of rows, each with its own `run`, in place of `run`.
### SettingsPage [#settingspage]
### $Fumadocs
| Prop | Type | Description |
| ---------- | ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | `string` | |
| `page?` | `"general" \| undefined` | |
| `section?` | `"general" \| undefined` | |
| `title` | `string` | |
| `icon?` | `IconName \| undefined` | |
| `entries?` | `readonly SettingEntry[] \| undefined` | |
| `render` | `(input: { readonly target?: string; }) => JSX.Element` | Renders the page, section or rows: `Ui.SettingsLayout` frames a page, `Ui.SettingsSection` a section, and `Ui.SettingsRow` is one row, each as the app's own settings render them. |
- `id`: the entry's name.
- `page` and `section`: put it on the General page, or in its General section.
- `title` and `icon`: how the entry reads.
- `entries`: what the settings search finds.
- `render`: draws the page, section or row.
### ToolRegistry [#toolregistry]
### $Fumadocs
| Prop | Type | Description |
| ----------------- | ---------------------------- | ----------- |
| `name` | `string` | |
| `render?` | `ToolComponent \| undefined` | |
| `errorComponent?` | `ToolComponent \| undefined` | |
- `name`: the tool whose calls this card draws.
- `render`: draws one call.
- `errorComponent`: draws a failed call.
What `render` gets:
### $Fumadocs
| Prop | Type | Description |
| -------------------- | ------------------------------------------------------- | ----------- |
| `input` | `Record` | |
| `error?` | `string \| undefined` | |
| `metadata` | `Record` | |
| `tool` | `string` | |
| `sessionID?` | `string \| undefined` | |
| `output?` | `string \| undefined` | |
| `status?` | `string \| undefined` | |
| `hideDetails?` | `boolean \| undefined` | |
| `defaultOpen?` | `boolean \| undefined` | |
| `open?` | `boolean \| undefined` | |
| `onOpenChange?` | `((open: boolean) => void) \| undefined` | |
| `fileOpen?` | `((path: string) => boolean \| undefined) \| undefined` | |
| `onFileOpenChange?` | `((path: string, open: boolean) => void) \| undefined` | |
| `deferContent?` | `boolean \| undefined` | |
| `virtualizeDiff?` | `boolean \| undefined` | |
| `onContentRendered?` | `(() => void) \| undefined` | |
| `pendingFiles?` | `readonly string[] \| undefined` | |
| `forceOpen?` | `boolean \| undefined` | |
| `locked?` | `boolean \| undefined` | |
- `tool`, `input` and `status`: the tool's name, the agent's input, and where the call is.
- `output`: the result as JSON text, once the call ends.
- `error`: the message of a failed call.
- `metadata`: the call's metadata, such as progress updates.
- The other props are how the widget opens, locks and lays out the card.
## Load a part lazily [#load-a-part-lazily]
Any `render` above can draw a component made with Solid's `lazy()`, such as
`render: lazy(() => import('./ticket-card.js'))`. The part loads the first time it shows, and the widget shows its own
loader until then.
## Render in any framework [#render-in-any-framework]
Every `render` above takes a Solid component. Three helpers turn your own UI into one, so a browser part can draw in
another framework:
| Helper | Import | Draws with |
| -------------- | ----------------------------- | ------------------------------------------------- |
| `mountRender` | `@conciv/frontend-plugin-api` | plain DOM, or any framework you mount by hand |
| `reactRender` | `@conciv/react` | a React component, inside your app's React tree |
| `preactRender` | `@conciv/preact` | a Preact component, inside your app's Preact tree |
Each one fits every render a registry takes: a panel, a slot, a settings page, a pill's menu, a code block and a
tool card.
- `mountRender` calls your mount function with an element and the props, once the element is in the page. The
mount returns a cleanup, which runs when the widget removes the contribution.
- `props.current()` gives the props as they are now. `props.subscribe(listener)` calls the listener at once and on
every change, and returns a stop function.
- The React and Preact helpers draw through a portal into your app's tree, so your providers reach the component.
They need a `` from the same package above them, and throw without one.
- `` mounts the widget itself. Set `widget: false` on the conciv bundler plugin, so the page does not
get a second one.
- A plugin folder's browser part is built with `experimental()`, which compiles Solid. React and Preact UI lives in
your app as a `Plugin.Setup`. You give it to `` in its plugins.
- The widget's reactive values, such as `run.status()`, are Solid signals. So is a store's value. Outside Solid, read
them in the function you pass to `ctx.add`, which runs again when they change.
Learn more in [Build your first plugin](/docs/plugins/first-plugin#draw-the-card).
## Next steps [#next-steps]
- **[Build your first plugin](/docs/plugins/first-plugin)**: every part in one tutorial.
- **[Plugins](/docs/plugins)**: every guide.
# Debug a plugin that does not load (/docs/recipes/debug-a-plugin-that-does-not-load)
## Problem [#problem]
You added a plugin, but nothing changed. This often shows as:
- the agent says it has no such tool;
- the tool works, but its calls show the generic card, not yours;
- the plugin's panel or pill never appears.
The engine skips a folder it cannot read as a plugin without a word. Guessing at the cause wastes a lot of time.
## Solution [#solution]
Open **Settings > Plugins** in the panel. Every plugin the engine found has a row there:
- **Failed** means it was found but did not start. The row shows the first line of the error. **Show details** opens
the rest.
- **Loading** means it has not started yet.
- No status means it is running.
Fix the error, then click **Reload** on its row. The engine also watches the `conciv` folder and every configured
path, so a saved change reloads the plugin by itself. Your dev server's terminal shows the same failure as `failed to
load plugin`.
### The plugin has no row [#the-plugin-has-no-row]
The engine never found it. Check where it lives:
```text title="Project"
conciv/
plugins/
tickets/ <- one folder per plugin, or a single .ts or .js file
server.ts <- the engine part: server, or index
plugin-experimental.cjs <- the browser part, built
```
- A folder plugin sits in `conciv/plugins/` at the project root. `conciv/plugin/` works too.
- A folder needs a `server` or `index` file, or a built `plugin-experimental.cjs`. A folder with none is skipped.
- A path in the `plugins` option starts with `./` or `../`. Without it, the engine reads the value as an npm package
name.
- A path to a single file is refused with `configured plugin path must be a directory`.
Learn more in [Add plugins](/docs/usage/add-plugins).
### The tools are missing [#the-tools-are-missing]
List what the running engine serves:
```bash title="Terminal"
npx @conciv/cli tools --help
```
A tool in the list is there for the agent. A tool in code mode is called `external_` plus its name, inside the code
card. Learn more in [Tools and code mode](/docs/tools-and-code-mode).
### The card or panel is missing [#the-card-or-panel-is-missing]
The browser part loads from `plugin-experimental.cjs` in the plugin folder. The engine looks for exactly that name. A source file next to it is not enough. Build it, then reload the page. A
code-mode call never shows your card. Only a direct tool's call does. Learn more in [Build or wire the browser part](/docs/plugins/first-plugin#build-or-wire-the-browser-part).
Two plugins share one `id`, for example a copy of a folder plugin that is also installed from npm. The later one
fails with `Duplicate plugin ID: `. Give each plugin its own id, or remove one.
## Next steps [#next-steps]
- **[Build your first plugin](/docs/plugins/first-plugin):** the folder, the tool and the build step, end to end.
- **[Troubleshooting](/docs/reference/troubleshooting):** every message conciv shows, with its fix.
# Drive the widget from a script (/docs/recipes/drive-the-widget-from-a-script)
## Problem [#problem]
You want a flow through the widget to run the same way every time. This often comes up when:
- you show a scripted demo, and a real model answers differently each run;
- you try a flow end to end, a permission card or a tool card, without a model;
- you want a script to type into the widget and click it, as a user does.
Each run against a real model takes time, costs tokens and gives a different answer. A demo or a check built on it
breaks for reasons that have nothing to do with your app.
## Solution [#solution]
Run the engine in simulation, and answer the model from a driver. A driver is a small node script of yours. Start the dev server
with two variables:
```bash title="Terminal"
CONCIV_SIMULATE=1 CONCIV_DRIVE=1 pnpm dev
```
`CONCIV_SIMULATE=1` puts the engine in simulation. `CONCIV_DRIVE=1` opens two local sockets. One answers the model.
The other acts on the widget. Once both listen, the dev server prints their addresses:
```text title="Terminal"
conciv drive backend websocket: ws://127.0.0.1:40950
conciv drive ui websocket: ws://127.0.0.1:40900
```
Open your app in the browser and log in, so a widget is on the page. Then install the driver package:
```package-install
npm install -D @conciv/simulation
```
The driver answers every model call and drives the widget:
```js title="driver.mjs"
import {connectDriver, text} from '@conciv/simulation/driver'
import {clickByRole, connectUi, typeInto} from '@conciv/simulation/frontend'
const model = await connectDriver('ws://127.0.0.1:40950') // <- the model socket
model.serve(() => text('Hello from the driver')) // <- every model call gets this answer
const widget = await connectUi('ws://127.0.0.1:40900') // <- the widget socket
await typeInto(widget.client, 'textbox', 'Message the conciv agent', 'Say hello') // <- found by role and label
await clickByRole(widget.client, 'button', 'Send message')
```
Run it with `node driver.mjs`. "Say hello" is sent from the composer, and "Hello from the driver" streams into the
thread. The driver keeps answering until you stop it with Ctrl C.
### Answer with a tool call [#answer-with-a-tool-call]
A real model often calls a tool first, then answers. Return a different answer for each call:
```js title="driver.mjs"
import {connectDriver, text, toolCall} from '@conciv/simulation/driver'
const model = await connectDriver('ws://127.0.0.1:40950')
let turn = 0
model.serve(() => {
turn += 1
if (turn === 1)
return toolCall('call-1', 'execute_typescript', {typescriptCode: 'return await external_server_urls()'}) // <- code mode
return text('The app listens on the address in the card above.')
})
```
The first call runs a code-mode program that asks the dev server where it listens. Its card shows in the thread. The
next call, after the tool's result, answers with text. The handler also gets the model request, so it can answer from
the messages instead of counting turns.
The driver has one function per kind of answer: `text`, `thinking`, `toolCall`, `toolCalls`, `disconnect` (a dropped
call) and `hang` (no answer at all). Learn more in [Tools and code mode](/docs/tools-and-code-mode).
### Read the widget [#read-the-widget]
`widget.client.ui.snapshot()` lists every element of the widget by its role and label:
```js title="driver.mjs"
import {byRole, connectUi} from '@conciv/simulation/frontend'
const widget = await connectUi('ws://127.0.0.1:40900')
const snapshot = await widget.client.ui.snapshot()
console.log(byRole(snapshot, 'textbox', 'Message the conciv agent').label) // <- throws when there is no such element
widget.close()
```
`client.ui` has one call per action: `snapshot`, `state`, `matches`, `type`, `press`, `enter`, `arrow`, `focus` and
`click`.
### What changes in simulation [#what-changes-in-simulation]
Only the model is fake. The engine, the tools, the widget and your app are all real. The engine's own network calls go
through a fixed list of allowed addresses, and the rest are refused. Tools your driver registers on the model socket
are offered to the agent, next to the plugins' tools. The widget takes driver calls in development builds only.
Any value of `CONCIV_DRIVE` other than `1` is an instance name. The engine reads `.json` with the two
addresses:
```json title="~/.local/state/conciv-drive/instances/demo.json"
{"endpoints": {"ui": "ws://127.0.0.1:41900", "backend": "ws://127.0.0.1:41950"}}
```
Start with `CONCIV_DRIVE=demo`. The engine looks for the file in the first of these that applies:
- `DRIVE_REGISTRY_DIR`, when set
- `conciv-drive/instances` under `XDG_STATE_HOME`, when set
- the path above
Both addresses must be `ws://127.0.0.1` with a port. A missing or broken
file stops the engine with `Drive manifest not found` or `Invalid Drive manifest`.
## Next steps [#next-steps]
- **[Troubleshooting](/docs/reference/troubleshooting):** messages from the engine and the CLI.
- **[Sessions](/docs/sessions):** what the driver's turns add to a session.
- **[Contributing: packages](/docs/contributing/packages):** where `@conciv/simulation` lives in the repo.
# Recipes (/docs/recipes)
A recipe is a short page for one real problem: what goes wrong, why it costs you, and the fix that works today.
## Run conciv [#run-conciv]
- [Drive the widget from a script](/docs/recipes/drive-the-widget-from-a-script): a scripted model and a script that
types into the widget.
- [Keep conciv out of production](/docs/recipes/keep-conciv-out-of-production): make sure no deployed build carries
the widget.
## Plugins [#plugins]
- [Debug a plugin that does not load](/docs/recipes/debug-a-plugin-that-does-not-load): find out why a tool, card or
panel does not show.
- [Share a plugin across projects](/docs/recipes/share-a-plugin-across-projects): one plugin in several projects, from
a shared folder or from npm.
# Keep conciv out of production (/docs/recipes/keep-conciv-out-of-production)
## Problem [#problem]
conciv is a development tool. You want it nowhere near what you deploy. The question comes up when:
- you deploy a staging build made in development mode;
- you run the dev server on a shared machine, for a demo or a review;
- you are not sure what each bundler does in a production build.
The engine listens on `127.0.0.1` only. It answers only browsers that logged in. A widget on a deployed page cannot
reach it, so visitors see a button that never works.
## Solution [#solution]
A production build already leaves conciv out, on every bundler:
- **Vite:** conciv runs with the dev server only. `vite build` never includes it.
- **Next.js:** with `NODE_ENV` set to `production`, no engine starts and the widget does not mount.
- **webpack and Rspack:** conciv runs only when `mode` is `development` or `none`. With no `mode`, the build is a
production build, so conciv is off.
For any other build you deploy, turn conciv off with `enabled`. Read it from a variable your deploy already sets:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
enabled: process.env.STAGING !== '1', // <- off in the staging build, on everywhere else
}),
],
})
```
With `enabled: false`, no engine starts and no widget is added. The same option works on every bundler. Learn more in
the [Configuration documentation](/docs/reference/configuration#enabled).
`widget: false` keeps the engine running and adds no widget to the page. Use it when you render the widget yourself,
or when only agents in your terminal should reach the engine.
## Next steps [#next-steps]
- **[Bundlers](/docs/bundlers):** what conciv does on each bundler, in each mode.
- **[Engine and widget](/docs/engine-and-widget):** what the build plugin starts, and where.
# Share a plugin across projects (/docs/recipes/share-a-plugin-across-projects)
## Problem [#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.
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 [#solution]
Keep the plugin in one place and point each project at it. In a monorepo, or on one machine, use a path:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: ['../../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 [#publish-it-to-npm]
For projects in other repos, publish the plugin as a package. Its `package.json` names the two parts in `exports`:
```json title="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](/docs/plugins/first-plugin#build-or-wire-the-browser-part).
Ship JavaScript. Node does not run TypeScript from a package. Each project then adds the plugin by name:
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({plugins: [['@acme/conciv-plugin-tickets', {board: '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](/docs/usage/add-plugins).
The engine follows a symbolic link in `conciv/plugins/` to a folder. That shares the plugin without a config entry,
but every project needs its own link.
## Next steps [#next-steps]
- **[Build your first plugin](/docs/plugins/first-plugin):** write the engine part and build the browser part.
- **[Debug a plugin that does not load](/docs/recipes/debug-a-plugin-that-does-not-load):** when a shared plugin does
not show up.
# CLI (/docs/reference/cli)
The conciv CLI sets a project up and drives your running dev server. The agent uses the same commands. Run one from
your project folder:
```bash title="Terminal"
npx @conciv/cli tools page snapshot
```
Every command accepts `--help` for its flags, for example `npx @conciv/cli auth link --help`. The full list of
commands and flags is at the [end of the page](#all-commands).
The agents conciv starts have `conciv` on their `PATH`, from `.conciv/bin`. Your own shell does not, so you type `npx
@conciv/cli` instead.
These commands print one JSON document, `{"ok":true,"data":...}` or `{"ok":false,"error":...}`:
- `tools`
- `plugin`
- `auth`
- `mcp connect`, `mcp disconnect` and `mcp list`
Pipe it to `jq` in a script.
## init [#init]
Sets a project up: installs `@conciv/it`, wires your bundler config, and connects your agents.
```bash title="Terminal"
npx @conciv/cli@latest init
```
- `--yes` accepts every detected default, with no prompts.
- `--dry-run` prints the plan and touches nothing.
- `--force` runs even with uncommitted git changes.
- `--json` prints one JSON result and never prompts. Pair it with `--yes`:
```bash title="Terminal"
npx @conciv/cli@latest init --yes --json
```
Learn more in [Getting started](/docs/getting-started).
## tools [#tools]
Reads and drives the live page through your running dev server. The commands under `tools` come from the engine's own
tool list. A plugin's tools show up as soon as the engine loads it.
```bash title="Terminal"
npx @conciv/cli tools page click --name SubmitButton
```
`page` is the tool group. `click` is the tool. A tool that targets an element takes one of:
- `--selector`: a CSS selector
- `--ref`: a ref from the last snapshot
- `--name`: a React component name
`--tab` with a session id acts on that one tab, on whichever dev server holds it.
`tools --help` lists every tool the running engine serves.
`tools tabs` lists the open conciv tabs of every running dev server on this machine:
```bash title="Terminal"
npx @conciv/cli tools tabs
```
Learn more in [Page control](/docs/usage/page-control).
## plugin call [#plugin-call]
Calls a method a plugin registered on the running engine, and prints its output.
```bash title="Terminal"
npx @conciv/cli plugin call server open --data '{"file":"src/routes/index.tsx","line":12}'
```
`server` is the plugin's RPC id. `open` is the method. `--data`, or `-d`, sends the method's input as JSON. Learn
more in the [Dev server documentation](/docs/usage/dev-server).
## auth link [#auth-link]
Prints a one-time login link for a page served by the conciv dev server.
```bash title="Terminal"
npx @conciv/cli auth link http://localhost:5173/
```
Open the link in the browser you want to log in. Learn more in [Logging in](/docs/usage/logging-in).
## auth revoke [#auth-revoke]
With no id, lists the browsers that logged in to this project's engine. It logs nobody out:
```bash title="Terminal"
npx @conciv/cli auth revoke
```
With an id from that list, logs that one browser out. `--all` logs every browser out:
```bash title="Terminal"
npx @conciv/cli auth revoke 3f2a9c1d
```
## mcp connect [#mcp-connect]
Adds conciv to an agent CLI, so that agent can find and drive your open conciv tabs.
```bash title="Terminal"
npx @conciv/cli mcp connect claude
```
The agent is one of `claude`, `codex`, `gemini-cli` or `opencode`. Learn more in [Agents](/docs/agents).
## mcp disconnect [#mcp-disconnect]
Removes conciv from an agent CLI.
```bash title="Terminal"
npx @conciv/cli mcp disconnect codex
```
## mcp list [#mcp-list]
Lists the agents connected to conciv.
```bash title="Terminal"
npx @conciv/cli mcp list
```
## mcp serve [#mcp-serve]
Serves conciv to an outside agent over MCP on stdio, not JSON. `mcp connect` writes this command into the agent's config.
You rarely run it yourself.
```bash title="Terminal"
npx @conciv/cli mcp serve --agent claude
```
## --version [#--version]
`--version`, or `-v`, prints the CLI's version as plain text.
```bash title="Terminal"
npx @conciv/cli --version
```
## All commands [#all-commands]
conciv generates this list from the CLI's own command tree. A flag listed under a command applies to the commands below it
too.
It tries these in order:
1. `CONCIV_PORT`.
2. `.conciv/server.json` in this folder or a parent.
3. The most recently started engine on this machine.
4. Port 5173.
With no engine running, `tools` prints the "No conciv dev server" error. So does its `--help`.
## Next steps [#next-steps]
- **[Page control](/docs/usage/page-control):** what the agent does with `tools page`.
- **[Agents](/docs/agents):** connect Claude Code, Codex and the rest.
- **[Troubleshooting](/docs/reference/troubleshooting):** every message the CLI prints, with its fix.
# Configuration (/docs/reference/configuration)
conciv takes one options object where you add it to your bundler. Every option is optional. Set only the ones you
need.
```ts twoslash title="vite.config.ts" tab="Vite" tab-group="bundler"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [conciv({harness: 'codex', port: 4321})], // <- the options object
})
```
```ts twoslash title="next.config.ts" tab="Next.js" tab-group="bundler"
import type {NextConfig} from 'next'
import {withConciv} from '@conciv/it/plugin/nextjs'
const nextConfig: NextConfig = {}
export default withConciv(nextConfig, {harness: 'codex', port: 4321}) // <- the second argument
```
```js title="webpack.config.js" tab="webpack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/webpack')
module.exports = {
mode: 'development',
plugins: [conciv.default({harness: 'codex', port: 4321})], // <- the plugin's argument
}
```
```js title="rspack.config.js" tab="Rspack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/rspack')
module.exports = {
mode: 'development',
plugins: [conciv.default({harness: 'codex', port: 4321})], // <- the plugin's argument
}
```
The examples below use Vite. The object is the same on every bundler. The full list with types and defaults is at the
[end of the page](#all-options).
## Options [#options]
### enabled [#enabled]
Turn conciv off without removing it. No engine starts and no widget is added.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({enabled: false})
```
### port [#port]
Ask the engine for a port.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({port: 4321})
```
Without `port`, the engine takes the port it used last time in this project. With no port from last time, Vite takes a
free one. Next.js, webpack and Rspack take one of 1000 ports from 24170 up, picked from the project folder, so two
projects rarely ask for the same one. The engine listens on `127.0.0.1` only. It writes the port it took to
`.conciv/server.json`.
When the port is taken, the engine takes a free one. On Vite it prints a warning. Next.js, webpack and Rspack switch
with no message. They switch before they build the widget, so the widget and the engine still agree.
### widget [#widget]
Move or turn off the two layouts. `modal` is the corner panel. `quickTerminal` is the sheet that drops from the top.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({widget: {modal: {position: 'top-left'}, quickTerminal: {hotkey: 'Alt+k'}}})
```
- `modal.position` is a corner or a middle edge. The default is `bottom-right`.
- `quickTerminal.hotkey` replaces the default ``Mod+` ``. Pass an array for more than one key.
- `false` for a layout turns it off.
Set `widget: false` when you render the widget yourself with ``. The engine still runs, and the page
does not get two widgets. Learn more in [Quick terminal](/docs/usage/quick-terminal).
### plugins [#plugins]
Load plugins by package name or by path.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({plugins: ['@conciv/plugin-test-runner', ['./my-plugin', {team: 'core'}]]})
```
- A string loads the plugin with no options.
- `[name, options]` passes options to the plugin. Every option value must be JSON.
- A path starts with `./` or `../` (from the project folder), or is absolute. Anything else is a package name.
- A name with a leading `-` removes that plugin.
Learn more in [Add plugins](/docs/usage/add-plugins).
### harness [#harness]
Pick the agent CLI a new session starts with. The default is `claude`.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({harness: 'opencode'})
```
You can still switch harness from the model menu. Learn more in [Harnesses](/docs/harnesses).
### systemPrompt [#systemprompt]
Replace the prompt conciv gives the agent, or give none.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({systemPrompt: 'Answer in one short paragraph.'})
```
- A string replaces conciv's built-in prompt.
- `false` gives no conciv prompt.
- Left out, the agent gets conciv's built-in prompt.
The engine writes the prompt it used to `.conciv/chat-system-prompt.txt`. Claude gets it after Claude Code's own prompt.
### permission [#permission]
Answer permission cards ahead of time, when you already know the answer.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({permission: {page_eval: 'allow'}})
```
`permission` takes three short forms:
- One effect for every action: `'allow'`.
- One effect per action: `{page_eval: 'deny'}`.
- One effect per action and resource: `{page_eval: {'document.title': 'allow'}}`.
The effect is `allow`, `deny` or `ask`. Learn more in [Agents and permissions](/docs/agents-and-permissions).
### permissions [#permissions]
Write permission rules in full, as a list.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({permissions: [{action: 'page_eval', resource: '*', effect: 'ask'}]})
```
These rules apply after the short forms in `permission`. A saved **Allow always** answer still beats an `ask` rule.
### policies [#policies]
Allow or deny a whole kind of use, such as one plugin.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({policies: [{action: 'plugin.use', resource: '*/greeter', effect: 'deny'}]})
```
The actions are:
- `provider.use`
- `tool.use`
- `integration.connect`
- `integration.use`
- `mcp.use`
- `skill.use`
- `plugin.use`
- `websearch.use`
The effect is `allow` or `deny`.
### hubAccess [#hubaccess]
Decide whether an agent outside the tab needs your yes first. An outside agent runs in your own terminal, connected
with `npx @conciv/cli mcp connect`.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({hubAccess: 'project'})
```
- `open`, the default, lets a connected agent into every open tab.
- `project` shows a card in the tab the first time an outside agent calls it. You allow it once, always, or not at all.
Learn more in [Agents](/docs/agents).
### stateRoot [#stateroot]
Move the `.conciv` state folder out of the project root.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({stateRoot: '../shared-state'})
```
### homeDir [#homedir]
Move the folder conciv shares across projects, such as the agents you connected.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({homeDir: '/tmp/conciv-home'})
```
The default is your platform's data folder.
### devEndpointDir [#devendpointdir]
Move `dev-endpoint.json`, the file the iOS SDK reads to find the engine. The default is `~/.conciv`.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({devEndpointDir: '/tmp/conciv-endpoint'})
```
### sessionId and claudeSessionId [#sessionid-and-claudesessionid]
Open the engine on a session you name.
```ts twoslash title="vite.config.ts"
import conciv from '@conciv/it/plugin/vite'
// ---cut---
conciv({claudeSessionId: 'release-notes'})
```
- `sessionId` is a conciv session id (`ses_...`). Any other value stops the engine with an error.
- `claudeSessionId` is a harness session id: up to 128 letters, digits, `_` and `-`.
The engine makes sure the session exists when it starts. Learn more in [Sessions](/docs/sessions).
## Set an option from the environment [#set-an-option-from-the-environment]
Some options also read an environment variable. Use one to change an option for a single run:
```bash title="Terminal"
CONCIV_HARNESS=codex pnpm dev
```
An option set in the config wins over its variable.
## All options [#all-options]
conciv generates this table from the config schema it validates your options with.
## Next steps [#next-steps]
- **[Add plugins](/docs/usage/add-plugins):** load a plugin and pass it options.
- **[Harnesses](/docs/harnesses):** the agent CLIs `harness` can name.
- **[Agents and permissions](/docs/agents-and-permissions):** how `permission`, `permissions` and saved answers combine.
# Troubleshooting (/docs/reference/troubleshooting)
Each entry here is one message conciv shows, with its cause and its fix. Find it by where it shows: in the panel, in
your dev server's terminal, or from the CLI. When nothing shows at all, start with the first section.
## When nothing shows [#when-nothing-shows]
### No conciv button [#no-conciv-button]
> The conciv button never appears on the page.
**Cause.** conciv adds the widget in development only, and only when it is turned on.
**Fix.** Run the dev server, not a production build. Check that your options set neither `enabled` nor `widget` to
`false`. Learn more in [Configuration](/docs/reference/configuration#enabled).
### No answer in the chat [#no-answer-in-the-chat]
> The chat never answers.
**Cause.** The default harness runs the `claude` CLI. The dev server cannot find it, or it is not logged in.
**Fix.** Install Claude Code and log in to it. Make sure `claude` is on the `PATH` of the shell that starts your dev
server. Learn more in [Harnesses](/docs/harnesses).
## In the panel [#in-the-panel]
The login messages live on this page only. Learn more in [Logging in](/docs/usage/logging-in).
### Not logged in [#not-logged-in]
> Log in to use conciv on this page.
**Cause.** This browser has not logged in to this engine.
**Fix.** Click **Log in**, and type the 6-digit code from your dev server's terminal.
### Logged out [#logged-out]
> This browser is no longer authorized to use conciv.
**Cause.** Someone logged this browser out with `auth revoke`.
**Fix.** Click **Log in** and log in again.
### Wrong code [#wrong-code]
> That code didn't match. Check your terminal and try again.
**Cause.** The digits differ from the newest code in your terminal.
**Fix.** Type the code from the newest box. After 5 wrong tries the engine drops the code. Then click **Send a new
code**.
### Expired code [#expired-code]
> That code expired. Send a new code and use the one your terminal prints.
**Cause.** A code lives 5 minutes. It is also dropped after 5 wrong tries.
**Fix.** Click **Send a new code**, and type the code from the new box.
### No code from the dev server [#no-code-from-the-dev-server]
> Could not ask the dev server for a code. Please try again.
**Cause.** The engine did not answer the login dialog.
**Fix.** Check that the dev server is running, then click **Send a new code**.
### Lost connection [#lost-connection]
> conciv lost connection to the engine.
**Cause.** The engine stopped answering, usually because the dev server stopped or restarted.
**Fix.** Start the dev server and click **Retry**. A message you tried to send meanwhile stays in the composer.
### Engine not reached [#engine-not-reached]
> conciv couldn't reach the engine. Check that the dev server is still running.
**Cause.** The panel could not load from the engine.
**Fix.** Start the dev server and click **Retry**.
### Older engine [#older-engine]
> This widget is version <version> but the conciv engine is older.
**Cause.** Your `@conciv/*` packages are on different versions.
**Fix.** Update them all to the version the message names. Then restart your dev server.
### Outdated engine code [#outdated-engine-code]
> Engine is running outdated code: the server code on disk is newer than the running engine. Restart the dev server.
**Cause.** conciv's code on disk changed after the engine started, for example after an install.
**Fix.** Restart the dev server.
### Pi turns fail [#pi-turns-fail]
> pi is not installed or not yet supported
**Cause.** The session runs the Pi harness, which has no chat in conciv yet.
**Fix.** Pick a model of another harness in the model menu. Learn more in [Harnesses](/docs/harnesses#pi).
### A path with a space [#a-path-with-a-space]
> claudeExecutable: --plugin-dir path "<path>" contains whitespace.
**Cause.** conciv cannot pass a path with a space in it to Claude Code. The message names the path, or `--settings`.
**Fix.** Move that folder to a path without spaces.
## In your dev server's terminal [#in-your-dev-servers-terminal]
### Port in use [#port-in-use]
> conciv: port <port> is already in use, the engine is listening on http://127.0.0.1:<other> instead
**Cause.** On Vite, the `port` you set is taken. The engine took a free port instead, and the widget follows it.
**Fix.** Nothing breaks, so you can leave it. To keep your port, stop what holds it and restart the dev server.
### Not a session id [#not-a-session-id]
> the configured conciv session id "<id>" is not a conciv session id (ses\_...)
**Cause.** The `sessionId` option is not a conciv session id, so the engine does not start.
**Fix.** Use an id that starts with `ses_`, or remove the option. Learn more in [Configuration](/docs/reference/configuration#sessionid-and-claudesessionid).
### Unknown harness [#unknown-harness]
> conciv: unknown harness "<id>". Known harnesses: claude, codex, gemini-cli, opencode, pi.
**Cause.** The `harness` option names a harness conciv does not have.
**Fix.** Use one of the ids the message lists. Learn more in [Harnesses](/docs/harnesses).
### Plugin path is a file [#plugin-path-is-a-file]
> configured plugin path must be a directory
**Cause.** A path in `plugins` points at a file. A plugin loaded by path is a folder.
**Fix.** Point the path at the plugin's folder. Learn more in [Debug a plugin that does not load](/docs/recipes/debug-a-plugin-that-does-not-load).
## In simulation [#in-simulation]
These show when the engine runs with a driver. Learn more in [Drive the widget from a script](/docs/recipes/drive-the-widget-from-a-script).
### No driver [#no-driver]
> the simulation has no driver: CONCIV_DRIVE is not set, so every model call is refused
**Cause.** `CONCIV_SIMULATE` is set without `CONCIV_DRIVE`. No socket opens, so nothing answers the model.
**Fix.** Set both variables.
### Address not on the list [#address-not-on-the-list]
> Simulation denied unregistered network destination
**Cause.** The engine tried to reach an address that is not on the simulation's fixed list. The message names the
method and the address.
**Fix.** Leave the call out of the flow you simulate. The list is fixed.
### Widget call not supported [#widget-call-not-supported]
> the widget does not support <call>
**Cause.** The widget does not answer `ui.capture`, `ui.recording.finish`, `ui.mouse` or `ui.resize`.
**Fix.** Use the calls under `client.ui` that it answers, such as `snapshot` and `click`.
### Widget socket did not start [#widget-socket-did-not-start]
> conciv drive ui websocket did not start
**Cause.** The widget socket could not listen, for example because its port is taken.
**Fix.** Free the port, or name an instance with other ports. The engine runs on without the socket, and the model
socket still works.
## From the CLI [#from-the-cli]
### No dev server [#no-dev-server]
> No conciv dev server on 127.0.0.1:<port>.
**Cause.** The command found no engine on that port.
**Fix.** Start your dev server. If it runs, set `CONCIV_PORT` to the engine's port, which is not the dev server's. The
command looks for the port in this order:
1. `CONCIV_PORT`.
2. `.conciv/server.json` in this folder or a parent.
3. The newest engine on this machine.
4. Port 5173.
### No registered engine answered [#no-registered-engine-answered]
> no conciv dev server answered: <folder> did not answer (<error>).
**Cause.** Engines are registered on this machine, but none answered when the command asked. This prints when neither
`CONCIV_PORT` nor a `.conciv/server.json` names a port, so the command tried the registered engines.
**Fix.** A dev server that is still starting answers once it is ready, so run the command again. Restart the dev
server if it stays silent.
### No engine state [#no-engine-state]
> no conciv engine state found here or in any parent directory
**Cause.** `auth` needs `.conciv/server.json`, which the dev server writes when it starts.
**Fix.** Run the command in your project folder, after the dev server has started there once.
### Unknown browser id [#unknown-browser-id]
> no trusted browser has the id "<id>"
**Cause.** No logged-in browser has that id.
**Fix.** Run `npx @conciv/cli auth revoke` with no id. It lists the browsers and their ids, and logs nobody out.
### Non-interactive terminal [#non-interactive-terminal]
> Non-interactive terminal
**Cause.** `init` had no terminal to ask its questions in.
**Fix.** Run it again with `--yes` to take the defaults. Or use `--dry-run` to print the plan only.
### Uncommitted changes [#uncommitted-changes]
> uncommitted changes
**Cause.** `init` refuses a git tree with uncommitted changes.
**Fix.** Commit first, or pass `--force`.
### No package.json [#no-packagejson]
> no package.json here
**Cause.** `init` runs in your app's folder, the one that holds `package.json`.
**Fix.** Change to that folder and run it again.
## Next steps [#next-steps]
- **[Logging in](/docs/usage/logging-in):** codes, links and logging out.
- **[Harnesses](/docs/harnesses):** install and pick an agent CLI.
- **[CLI](/docs/reference/cli):** every command, with its flags.
# Requirements (/docs/requirements)
conciv runs on your machine, inside your dev server. It needs four things: Node, a bundler it plugs into, a browser
for the panel, and an agent CLI to answer in the chat.
## What you need [#what-you-need]
| Needs | Supported |
| --------- | ------------------------------------------------------------------- |
| Node.js | 22.19 or newer |
| Bundler | Vite 6, 7 or 8; Next.js 15.3 or 16; webpack 5; Rspack |
| Browser | A current desktop browser; tested in Chromium and Firefox |
| Agent CLI | Claude Code, Codex, Gemini CLI or opencode, installed and logged in |
| Build | Development builds only |
## Node.js [#nodejs]
conciv needs Node.js 22.19 or newer. Its per-user registry is built on `node:sqlite`. Every published package
declares that floor in its `engines` field.
Your app itself can target any runtime. Only the dev server process that runs conciv needs Node 22.19.
## Bundlers [#bundlers]
conciv plugs into your bundler through `@conciv/it`. Each bundler has its own entry.
| Bundler | Versions | Entry | Notes |
| --------------- | --------------- | --------------------------- | ---------------------------------------------------------------------------------- |
| Vite | 6, 7 and 8 | `@conciv/it/plugin/vite` | The full feature set. Also Astro and TanStack Start, which run on Vite. |
| Next.js | 15.3 and 16 | `@conciv/it/plugin/nextjs` | `withConciv` plus two instrumentation files. |
| webpack | 5 | `@conciv/it/plugin/webpack` | The chat and page tools work. The agent cannot read the dev server's module graph. |
| Rspack | tested with 2.x | `@conciv/it/plugin/rspack` | The same as webpack. |
| Rollup, esbuild | none | none | The entries exist but do nothing yet. Serve the app with Vite instead. |
The Vite and Next.js ranges are the `peerDependencies` of `@conciv/it`. webpack and Rspack have no declared range.
conciv is built and tested against webpack 5 and Rspack 2.
A native iOS app runs through the [iOS setup](/docs/bundlers/ios), in early alpha. It needs Xcode and the iOS
simulator, plus a web dev server with conciv to run the engine.
## Browsers [#browsers]
The panel runs in the page your dev server serves. Use a current version of a desktop browser. The widget is tested in
Chromium and Firefox. Other browsers are not in the test matrix.
## Agent CLIs [#agent-clis]
The chat runs an agent CLI on your machine, with your own login. conciv does not install it or log you in. The CLI
must be on the `PATH` of the shell that starts your dev server.
| Agent | Command | In conciv |
| ----------- | ---------- | ------------------------------------------------------------- |
| Claude Code | `claude` | The default. Chat, permission cards, `/` commands and images. |
| Codex | `codex` | Chat. Codex never asks. Its sandbox limits what it can do. |
| Gemini CLI | `gemini` | Chat, with permission cards. |
| opencode | `opencode` | Chat. Its permission asks do not reach conciv yet. |
| Pi | `pi` | No chat yet. Its past sessions show in the session list. |
Learn more in [Connect your agents](/docs/agents).
## Development builds only [#development-builds-only]
conciv runs only in development:
- `vite dev` starts it. `vite build` leaves it out.
- `next dev` starts it. `next build` and `next start` leave it out.
- webpack and Rspack run it when the build mode is not `production`.
Learn more in [Keep conciv out of production](/docs/recipes/keep-conciv-out-of-production).
## Next steps [#next-steps]
- **Install it**: [Getting started](/docs/getting-started) takes the shortest path.
- **Pick your bundler**: [Vite](/docs/bundlers/vite), [Next.js](/docs/bundlers/nextjs),
[webpack](/docs/bundlers/webpack) and [Rspack](/docs/bundlers/rspack).
# Sessions (/docs/sessions)
A session is one conversation with the agent. It holds your messages, the agent's answers, your draft and the messages
waiting to be sent. The engine keeps every session in `.conciv/conciv.db`.
## Pick the harness and the opening session [#pick-the-harness-and-the-opening-session]
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
harness: 'claude', // <- a new session starts with this harness
claudeSessionId: 'release-notes', // <- the engine opens on this session when it starts
}),
],
})
```
## Session id [#session-id]
Every session has a conciv id that starts with `ses_`. The CLI's `--tab` flag takes it. The agent finds it in
`CONCIV_SESSION_ID`. A deleted session stays deleted. conciv never brings its id back. Learn more in
the [CLI documentation](/docs/reference/cli#tools).
## Messages [#messages]
A session's messages are its chat history. They stream into the panel as the agent works. They stay after a reload. Learn more in [Chat](/docs/usage/chat).
## Draft [#draft]
The draft is what you typed and have not sent yet, attachments included. Each session keeps its own draft, so it comes
back after a reload.
## Queue [#queue]
The queue holds the messages you send while the agent works. Each one waits under the composer. **Steer** sends it into
the running turn now, and **Remove** drops it. Learn more in [Chat](/docs/usage/chat).
## Harness transcript [#harness-transcript]
The harness keeps its own record of the conversation, such as Claude Code's session. A conciv session points at that
record, so the next turn resumes it. `claudeSessionId` names the harness session to open. Learn more in
[Harnesses](/docs/harnesses).
## Past CLI sessions [#past-cli-sessions]
The session list also shows sessions you started in your agent CLI, outside the browser. This needs a harness that
keeps a history conciv can read. Open one, and the next message goes on from where it ended.
## Switching harness [#switching-harness]
A session can change harness halfway, from the model menu. The new harness starts its own transcript. The session
keeps the earlier one, so the list still shows it once, under the same session.
## Compression [#compression]
You can compress a long session. The agent sums up the decisions, the current state and the open threads. It goes on
from the summary. On Claude, conciv runs Claude Code's own `/compact` instead.
## Next steps [#next-steps]
- **[Chat](/docs/usage/chat):** send, queue, search and switch sessions in the panel.
- **[Harnesses](/docs/harnesses):** which agent CLIs keep a history conciv can read.
- **[Engine and widget](/docs/engine-and-widget):** where `conciv.db` and the other state files live.
# Skills (/docs/skills)
A skill is a Markdown guide the agent reads when a task needs it. Write one when you keep telling the agent the same
steps: how your team names components, how to add a route, what to check before a release.
## Write a skill [#write-a-skill]
```md title="conciv/skills/new-route/SKILL.md"
---
name: new-route
description: How to add a page route in this app. Use when the user asks for a new page or URL.
---
1. Add the route file under `src/routes`, named after the URL.
2. Export the route with `createFileRoute`.
3. Add a link to it in `src/components/Nav.tsx`.
4. Run the tests for the routes folder.
```
- `name` is what the agent sees in its list of skills.
- `description` decides when the agent picks the skill.
- The body is the guide. Write it as you would brief a new teammate.
Save the file. The engine watches the folder, so the agent sees the skill with no restart.
Use a skill when written steps are enough. When the agent needs a new tool, a card or a panel, write a
[plugin](/docs/plugins) instead.
## Locations [#locations]
conciv loads skills from two places:
- **The project:** `conciv/skills/` at your project root. These belong to this project.
- **Your conciv home folder:** `skills/` there. These apply to every project.
The home folder is `CONCIV_HOME` when you set it. Otherwise it is:
- macOS: `~/Library/Application Support/conciv`
- Linux: `~/.local/share/conciv`
- Windows: `%LOCALAPPDATA%\conciv\Data`
A project skill replaces a home skill
with the same id. A folder named `skill` works the same as `skills`, in both places.
## How skills work [#how-skills-work]
The agent sees each skill's name and description up front. It reads the full guide only when your request matches the
description. So a skill costs nothing until the agent reads it.
To make sure it reads one, name it in your message, or type `@` in the composer and pick it:
```text title="Message"
Use the new-route skill to add a /pricing page.
```
## Skill structure [#skill-structure]
A skill is a folder with a `SKILL.md` inside. The folder name is the skill's id. A single `.md` file in
`conciv/skills/` is a skill too. Its file name is its id. The folder form is better, because it can hold more files.
## Frontmatter [#frontmatter]
- `name` is the name the agent sees. Without it, the id is used.
- `description` says what the skill does and when it applies. A skill with no description is never offered on its own.
- `disable-model-invocation: true` keeps the skill out of the agent's list. It still reads the skill when you name it.
## Files beside a skill [#files-beside-a-skill]
Put examples, templates or scripts next to `SKILL.md`. When the agent loads the skill, it gets their paths too. So the
guide can point at them:
```md title="conciv/skills/new-route/SKILL.md"
Copy `template.tsx` from this skill's folder as the start of the new route file.
```
A skill can tell the agent to do anything, and its scripts run with your rights. Read a skill you did not write before
you add it.
## Built-in skills [#built-in-skills]
conciv comes with two skills of its own:
- `conciv` answers questions about conciv: setup, configuration, harnesses, the widget, the CLI and plugins.
- `report` files a bug about conciv. It collects diagnostics, adds your steps and opens the issue with the GitHub CLI.
## Skills from plugins [#skills-from-plugins]
Plugins add skills too. The page plugin, which conciv ships, adds `page`. The test runner, TanStack and recorder
plugins each add a skill named after themselves when you load them. Learn more in [Add a skill](/docs/plugins/guides/skill).
## Next steps [#next-steps]
- **[Chat](/docs/usage/chat):** mention a skill with `@` in the composer.
- **[Add a skill](/docs/plugins/guides/skill):** ship a skill from a plugin.
- **[Plugins](/docs/plugins):** when written steps are not enough, give the agent a tool.
# Tools and code mode (/docs/tools-and-code-mode)
A tool is one action the agent can take through conciv, such as reading the page or running the tests. Code mode is
how the agent calls most of them. It writes a short TypeScript program that calls the tools, and conciv runs it.
## Pick a mode per tool [#pick-a-mode-per-tool]
```ts twoslash title="conciv/plugins/tickets/server.ts"
import {z} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api'
export default Plugin.define({
id: 'tickets',
async setup(ctx) {
await ctx.tool.transform((tools) => {
tools.add({
name: 'ticket_read', // <- code mode: the agent calls it as external_ticket_read
description: 'Read a ticket by its id, such as OPS-42.',
input: z.object({id: z.string()}),
execute: async ({id}) => ({content: `${id} is open.`}),
})
tools.add({
name: 'ticket_close', // <- direct: the agent calls ticket_close by name
description: 'Close a ticket by its id.',
input: z.object({id: z.string()}),
options: {codemode: false}, // <- turns code mode off for this tool
execute: async ({id}) => ({content: `${id} is closed.`}),
})
})
},
})
```
## Code mode [#code-mode]
Code mode is the default for every tool. The agent gets one tool, `execute_typescript`, and writes a program for it.
The program can call several tools, wait for each result and work with the values. The agent reads only what the program
returns, not every tool's whole output.
## Tool names in code mode [#tool-names-in-code-mode]
Inside a code-mode program, a tool is a function named `external_` plus the tool's name. A tool in a namespace joins
the two names with `_`, so `read` in the `ticket` namespace is `external_ticket_read`. These are the names you see in
the code card. Learn more in [Add a tool](/docs/plugins/guides/tool).
## The catalog [#the-catalog]
The agent's instructions list the code-mode tools it can call. When the list is too long, they show part of it. The
agent finds the rest with a `search(...)` function inside the program. It never guesses a name.
## Direct tools [#direct-tools]
A direct tool has `codemode: false`. The agent calls it by its name, one call at a time, as it calls its CLI's own
tools. Pick direct when the user should see each call, or when your plugin draws a card for it.
## The code card [#the-code-card]
A code-mode run shows as one code card in the chat. The card holds the program, its console output, its result and
any error. Every tool the program called ran inside it, so a plugin's own card never shows for a code-mode call.
## A tool's own card [#a-tools-own-card]
A direct call gets a card of its own. Without a plugin card, it is a generic card with the input and the output. A
plugin can draw its own card for its direct tools. Learn more in [Build your first plugin](/docs/plugins/first-plugin).
A deny rule for the `execute` action turns code mode off: every tool becomes direct. A deny rule for one tool's
action, on every resource, hides that tool. Learn more in [Agents and
permissions](/docs/agents-and-permissions#rules).
## Next steps [#next-steps]
- **[Add a tool](/docs/plugins/guides/tool):** write a tool, pick its mode and draw its card.
- **[Agents and permissions](/docs/agents-and-permissions):** what makes a tool call ask you first.
- **[Page control](/docs/usage/page-control):** the page tools the agent drives your app with.
# Add plugins (/docs/usage/add-plugins)
A plugin adds tools for the agent and screens for the widget. You add one with the `plugins` option of your conciv
config.
## List your plugins [#list-your-plugins]
List plugins in `plugins`:
```ts twoslash title="vite.config.ts" tab="Vite" tab-group="bundler"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: ['@conciv/plugin-test-runner', './tools/deploy'], // [!code ++]
}),
],
})
```
```ts twoslash title="next.config.ts" tab="Next.js" tab-group="bundler"
import type {NextConfig} from 'next'
import {withConciv} from '@conciv/it/plugin/nextjs'
const nextConfig: NextConfig = {}
export default withConciv(nextConfig, {
plugins: ['@conciv/plugin-test-runner', './tools/deploy'], // [!code ++]
})
```
```js title="webpack.config.js" tab="webpack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/webpack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
plugins: ['@conciv/plugin-test-runner', './tools/deploy'], // [!code ++]
}),
],
}
```
```js title="rspack.config.js" tab="Rspack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/rspack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
plugins: ['@conciv/plugin-test-runner', './tools/deploy'], // [!code ++]
}),
],
}
```
Restart your dev server to load them.
- `'@conciv/plugin-test-runner'` is a package name. The engine installs it from npm into its own cache, so you do not
add it to your `package.json`.
- `'./tools/deploy'` is a folder in your project. It resolves from your project folder, not from the config file.
## Pass options [#pass-options]
Write an entry as a pair, the name and then its options:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: [['@conciv/plugin-test-runner', {runner: 'playwright'}]], // [!code ++]
}),
],
})
```
Every option value must be JSON: a string, number, boolean, null, array or object.
## Turn a plugin off [#turn-a-plugin-off]
Put `-` before a plugin's id:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: ['-project-version'], // [!code ++]
}),
],
})
```
This turns off a plugin that loads on its own, such as one in the `conciv/plugins` folder.
## Add a plugin from your project [#add-a-plugin-from-your-project]
Every plugin in a `conciv/plugins` folder at your project root loads with no config entry. A plugin there is one
`.ts` or `.js` file, or a folder:
The engine watches these files. Save a change and the plugin loads again with no restart. Learn to write one in the
[first plugin guide](/docs/plugins/first-plugin).
## The plugins conciv ships [#the-plugins-conciv-ships]
The first two are on in every widget. Add the others with the line in the third column.
| Plugin | What it gives you | Add it | Options |
| ----------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------- | ------------------------------------------------- |
| Page | The agent reads and drives the page you have open. See [Page control](/docs/usage/page-control). | On by default | None |
| Terminal | The **Terminal** tab, the agent CLI in a terminal. See [Terminal](/docs/usage/terminal). | On by default | None |
| Test runner | Runs your tests from the chat, live in a Tests tab. See [Live tests](/docs/usage/live-tests). | `'@conciv/plugin-test-runner'` | `runner`: vitest (default) or playwright |
| Recorder | Records the page, replays it and exports a video. See [Live recorder](/docs/usage/live-recorder). | `'@conciv/plugin-recorder'` | `masking`, `windowMinutes`, `console` |
| TanStack | Build errors, routes and server function calls of a TanStack app. See [TanStack](/docs/usage/tanstack). | `'@conciv/plugin-tanstack'` | `bundlerWaitMs` |
| iOS | Builds, runs, screenshots and reads the logs of your iOS app in the simulator. See [iOS](/docs/bundlers/ios). | `['@conciv/plugin-ios', {...}]` | `projectRoot` and `bundleId` (required), and more |
| Whiteboard | A shared canvas over the app. See [Whiteboard](/docs/usage/whiteboard). | `'@conciv/plugin-whiteboard'` | None |
| Try it | The connect pane of the widget on conciv.dev. | Not added in config | None |
Try-it is published, but conciv.dev composes it into its own widget. It is not a plugin you add in config.
- A string that is not a path is a package name, installed from npm.
- A path that starts with `./` or `../` resolves from your project folder.
- An absolute path or a `file://` URL is used as it is.
- A configured path must be a folder. A file there is skipped with the warning
`configured plugin path must be a directory`.
- A string that starts with `-` turns off the plugin with that id.
## Next steps [#next-steps]
- **[Live tests](/docs/usage/live-tests):** the test runner, step by step.
- **[Live recorder](/docs/usage/live-recorder):** the recorder and its options.
- **[TanStack](/docs/usage/tanstack):** the TanStack plugin and its tools.
- **[iOS](/docs/bundlers/ios):** every iOS plugin option.
- **[Plugins](/docs/plugins):** write a plugin of your own.
# Approvals (/docs/usage/approvals)
A Permission card is how the agent asks you before a risky action. The action waits until you answer.
## Answer a card [#answer-a-card]
This prompt makes the agent ask before code runs in your page:
```text title="Prompt"
Run some JavaScript in the page to count the buttons on it.
```
The card names the action and what it acts on, such as the code it would run. Answer it:
- **Allow once** (Cmd Enter or Ctrl Enter) runs it this one time.
- **Deny** (Escape) refuses it.
- **Allow always** allows this action in this project from now on. It shows only when the action can be remembered.
The keys work while the card has focus. The card waits as long as you need. Stop the turn, and the card goes with it.
## Know what asks [#know-what-asks]
Two things can ask you: your agent CLI, and some of conciv's own tools.
Your agent CLI decides for itself what it asks about:
- **Claude Code** runs in its `auto` mode. It asks when it judges a step risky. conciv adds rules so these commands
always ask:
- `git push` that forces (`--force`, `-f`) or deletes a remote branch (`--delete`, `-d`, a `:branch` refspec)
- `git reset --hard`
- `git clean`
- `git branch -D`
- `git gc --prune`
- a recursive `rm` (`-r`, `-R`, `-fr`, `-fR`)
- a recursive `chmod -R` or `chown -R`
- anything run with `sudo`
- **Codex** never asks. Its `workspace-write` sandbox limits what it can touch.
- **Gemini CLI** asks by its own rules. Each ask shows as a card.
- **opencode** asks in its own way. Those asks do not show as cards in conciv yet.
- **Pi** has no chat in conciv yet.
An ask from your agent CLI can be allowed once or denied, never allowed always. Learn more on each
[agent's page](/docs/agents).
conciv's own tools that ask, on every CLI:
- running JavaScript in your page. This one asks every time: it has no **Allow always**.
- restarting the dev server
- with the iOS plugin: building the app, and running it in the simulator
- with the whiteboard: deleting an element, clearing the canvas, and resolving or deleting a
comment
A plugin's tools exist only when you load that plugin. Learn more in [Add plugins](/docs/usage/add-plugins).
## Forget a saved answer [#forget-a-saved-answer]
An **Allow always** answer is saved for the project, in its `.conciv/conciv.db`. conciv has no button or command to
list or clear saved answers yet.
Until a way to clear saved answers lands, click **Allow always** only for an action you will never want to check
again.
## Let outside agents in [#let-outside-agents-in]
An agent CLI in your own terminal can drive your open tabs once you [connect it](/docs/agents). By default it can
use any open tab with no card. To make it ask first, set `hubAccess` to `'project'`:
```ts twoslash title="vite.config.ts" tab="Vite" tab-group="bundler"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
hubAccess: 'project', // [!code ++]
}),
],
})
```
```ts twoslash title="next.config.ts" tab="Next.js" tab-group="bundler"
import type {NextConfig} from 'next'
import {withConciv} from '@conciv/it/plugin/nextjs'
const nextConfig: NextConfig = {}
export default withConciv(nextConfig, {
hubAccess: 'project', // [!code ++]
})
```
```js title="webpack.config.js" tab="webpack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/webpack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
hubAccess: 'project', // [!code ++]
}),
],
}
```
```js title="rspack.config.js" tab="Rspack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/rspack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
hubAccess: 'project', // [!code ++]
}),
],
}
```
Now the first call from an outside agent shows a Permission card in the tab. **Allow once** lets that one call in.
**Allow always** lets that agent in for this project from now on.
An agent connected from your terminal can never answer a Permission card. It cannot connect or disconnect agents
either. You do that in the tab.
An ask from your agent CLI lives only as long as its turn. When you stop the turn, or the CLI gives up on the call,
the card goes.
## Next steps [#next-steps]
- **[Agents and permissions](/docs/agents-and-permissions):** the rules behind each card.
- **[Page control](/docs/usage/page-control):** what the agent does in your page.
- **[Configuration](/docs/reference/configuration):** `hubAccess` and the permission rules.
# Chat (/docs/usage/chat)
The chat is where you ask the agent for what you want, about the page you have open.
## Send a message [#send-a-message]
Type in the composer and press Enter. Say "this" or "here", and the agent reads the page before it changes anything:
```text title="Prompt"
Why is this list empty when I am logged out?
```
The agent runs in your project through your own agent CLI, Claude Code by default. Learn more in
[Harnesses](/docs/harnesses).
- **Enter** sends the message.
- **Shift Enter** starts a new line.
- **Escape** stops the agent while it works.
Your draft is saved for each session, so it comes back after a reload.
## Attach a file or an element [#attach-a-file-or-an-element]
Click **Add an attachment** to add a file, or paste one into the composer. Images reach the agent only on Claude.
Click **Select an element from the page**, then click an element in your app. conciv pins it to your message, with its
source file when it can find it:
```text title="Prompt"
Make this button match the primary button style.
```
Learn more in [Page control](/docs/usage/page-control).
## Use commands and mentions [#use-commands-and-mentions]
Type `/` to open the commands. You get conciv's own commands, plus those of your plugins. On Claude you also get
Claude Code's own commands.
Type `@` to mention a skill, an agent, a tool, another session or a file. Pick it from the list. It joins your
message.
## Send while the agent works [#send-while-the-agent-works]
A message you send while the agent works waits in a queue under the composer. Each queued message has two buttons:
- **Steer** sends it now, into the running turn.
- **Remove** drops it.
**Stop generating** ends the turn. The queued messages go back into your draft, unsent.
## Answer the agent's questions [#generative-ui]
When the agent needs a decision, it puts a card in the thread instead of asking in plain text. A card can hold
options to pick from, a yes or no question, a proposed change, or a few fields to fill in.
```text title="Prompt"
Add a dark mode toggle. Ask me where it should go.
```
Answer within two minutes and the agent goes on with your answer. Later, it goes on without it, and your answer
arrives as a new message.
## Find a session [#find-a-session]
Open the session picker to see your sessions under Today, Yesterday and Earlier. Type to search them.
- Turn on **All projects** to search your other projects too.
- Rest on a row, with the pointer or the arrow keys, to preview it.
- A session from another project has **Copy resume command**, to continue it there.
The list also holds sessions you started in your agent CLI, when the harness keeps them. Learn more in
[Sessions](/docs/sessions).
## Switch the model [#model-and-harness]
Open the model menu. It lists the models of every agent CLI conciv found, and the effort levels of the current model.
Picking a model of another CLI switches the session to that CLI. If the chat has messages, conciv asks first. It shows
how much history it would send along.
## Shorten a long chat [#shorten-a-long-chat]
Click **Compress the conversation** when a chat gets long. conciv asks the agent to sum up the decisions, the state
and the open threads. On Claude it runs Claude Code's own compaction instead.
## Use the Terminal tab [#use-the-terminal-tab]
On Claude, the panel has a pinned **Terminal** tab. It runs Claude Code itself, in your project, for this session. The
CLI starts the first time you open the tab.
A message holds at most 16 parts, its text and its attachments together. Remove some attachments, or send them in
two messages.
Sessions you started outside the browser show only when the harness keeps a history conciv can read. The table on
the [Harnesses page](/docs/harnesses) says which ones do.
## Next steps [#next-steps]
- **[Page control](/docs/usage/page-control):** point at an element and have it changed.
- **[Approvals](/docs/usage/approvals):** what the agent asks before it acts.
- **[Quick terminal](/docs/usage/quick-terminal):** the chat as a drop-down sheet with panes.
# Dev server (/docs/usage/dev-server)
The dev server tools let the agent ask your running Vite dev server about your code, instead of guessing from config
files. They are built in, with nothing to install.
## Ask about a build problem [#ask-about-a-build-problem]
Ask about your dev server when a build question comes up:
```text title="Prompt"
Why does @/components/Header resolve to the wrong file from src/routes/index.tsx?
```
The agent asks the server how the import resolves from that file. It answers from what the server says.
The tools need a Vite dev server. TanStack Start and Astro count, since they run on Vite. On Next.js, webpack and
Rspack they answer that no dev server is attached.
## Ask how the server is set up [#ask-how-the-server-is-set-up]
The agent reads the resolved config: the root, the base path, the mode, the aliases and the plugins. It also knows
where the server listens, on this machine and on your network:
```text title="Prompt"
What URL do I open on my phone to see this app?
```
## Ask what a file pulls in [#ask-what-a-file-pulls-in]
The agent reads a file's place in the module graph: what it imports, and what imports it.
```text title="Prompt"
Which modules import src/lib/store.ts? I want to know what a change there touches.
```
## See the code the server serves [#see-the-code-the-server-serves]
The agent reads the code the dev server sends to the browser for a URL, after every plugin ran:
```text title="Prompt"
Show me what /src/main.ts looks like after the transform. Is the env variable inlined?
```
## Read build errors [#read-build-errors]
With the TanStack plugin added, the agent also reads the dev server's build errors. Learn more in
[TanStack](/docs/usage/tanstack).
## Open a file or restart the server [#open-a-file-or-restart-the-server]
```text title="Prompt"
Open src/routes/index.tsx at line 12 in my editor. Then restart the dev server and check the page loads.
```
A restart asks you first, with a [Permission card](/docs/usage/approvals). Allow it, and the server restarts and
bundles its dependencies again.
## Ask from your terminal [#ask-from-your-terminal]
The same questions work from a terminal, with the question's name after `server`:
```bash title="Terminal"
npx @conciv/cli plugin call server urls
```
It prints the answer as JSON:
```json title="Output"
{"ok": true, "data": {"local": ["http://localhost:5173/"], "network": ["http://192.168.1.20:5173/"]}}
```
The other questions take their input as JSON after `--data`:
```bash title="Terminal"
npx @conciv/cli plugin call server config
npx @conciv/cli plugin call server resolve --data '{"spec":"@/lib/auth","importer":"src/routes/login.tsx"}'
npx @conciv/cli plugin call server graph --data '{"file":"src/lib/store.ts"}'
npx @conciv/cli plugin call server transform --data '{"url":"/src/main.ts"}'
npx @conciv/cli plugin call server open --data '{"file":"src/routes/index.tsx","line":12,"column":4}'
```
- `resolve` takes the import, and optionally the file it is imported from. Its `id` is `null` when nothing matches.
- `graph` takes a file. `transform` takes the URL the browser asks for.
- `open` takes a file, and optionally a line and a column.
A restart is not on this list. It always goes through the agent, so you get the card first.
The engine has no Vite dev server to ask. It runs on another bundler, or on its own. Opening a file in your editor
still works.
The dev server itself refused the question, for example a transform that throws. From the terminal, the error's
`data.message` holds the dev server's own message.
That is the tool's name in code mode, where the agent calls tools from a short program. Learn more in [Tools and
code mode](/docs/tools-and-code-mode).
## Next steps [#next-steps]
- **[Page control](/docs/usage/page-control):** the page the server serves.
- **[CLI](/docs/reference/cli):** every command, `plugin call` included.
- **[Plugins](/docs/plugins):** add your own questions with a plugin.
# Use conciv (/docs/usage)
The widget is the conciv button and chat panel in the corner of your dev app. You open it and ask for an outcome in
plain words. The agent works on the page you see and in your source. These pages cover one task each.
## First steps [#first-steps]
- [Logging in](/docs/usage/logging-in): let a browser in once, with the code your dev server prints.
- [Chat](/docs/usage/chat): send a message, queue the next one, switch sessions and models.
## Work on your app [#work-on-your-app]
- [Page control](/docs/usage/page-control): point at an element and have the agent change it.
- [Dev server](/docs/usage/dev-server): ask how an import resolves, what a file pulls in, or restart the server.
- [Live tests](/docs/usage/live-tests): run your tests from the chat and read the result.
- [Live recorder](/docs/usage/live-recorder): record what you do on the page, and send it to the agent.
- [Quick terminal](/docs/usage/quick-terminal): drop the chat from the top of the page and split it into panes.
## Stay in control [#stay-in-control]
- [Approvals](/docs/usage/approvals): allow or deny a risky action before it runs.
- [Skills](/docs/skills): write the steps once, and the agent follows them.
## Add more [#add-more]
- [Add plugins](/docs/usage/add-plugins): the `plugins` option, and the plugins conciv ships.
- [Whiteboard](/docs/usage/whiteboard): a shared canvas over the app.
# Live recorder (/docs/usage/live-recorder)
The live recorder comes from the recorder plugin, `@conciv/plugin-recorder`. It records the page you have open, so the
agent can see what you just did there.
## Add the recorder [#add-the-recorder]
Add the plugin to the `plugins` option of your conciv config:
```ts twoslash title="vite.config.ts" tab="Vite" tab-group="bundler"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: ['@conciv/plugin-recorder'], // [!code ++]
}),
],
})
```
```ts twoslash title="next.config.ts" tab="Next.js" tab-group="bundler"
import type {NextConfig} from 'next'
import {withConciv} from '@conciv/it/plugin/nextjs'
const nextConfig: NextConfig = {}
export default withConciv(nextConfig, {
plugins: ['@conciv/plugin-recorder'], // [!code ++]
})
```
```js title="webpack.config.js" tab="webpack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/webpack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
plugins: ['@conciv/plugin-recorder'], // [!code ++]
}),
],
}
```
```js title="rspack.config.js" tab="Rspack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/rspack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
plugins: ['@conciv/plugin-recorder'], // [!code ++]
}),
],
}
```
Restart your dev server. The engine installs the plugin from npm into its own cache, so it does not go in your
`package.json`.
## What it records [#what-it-records]
The recorder captures the page with [rrweb](https://www.rrweb.io), which records changes to the page, not pixels. The
conciv widget is left out of the recording. Clicks, typing, navigations, scrolls and reloads all go in.
It records only while a recording is live. That is while the **Recorder** tab is open, or while the agent has started
a recording. It also needs page control, the built-in page plugin. Learn more in [Page control](/docs/usage/page-control).
The engine keeps only the most recent part of the page, the last 10 minutes by default. Older events drop off.
## The Recorder tab [#the-recorder-tab]
Open the **Recorder** tab in the panel. It replays the page as you use it, with a **LIVE** badge. Scrub back to
look at an earlier moment, then click **GO LIVE** to follow the page again.
The buttons under the replay:
- **Send to agent** saves the recording and pins it to your next message as a **Screen recording** note.
- **New recording** clears what was kept and starts again from the page as it is now.
- **Export video** saves the recording and downloads it as a `.webm` video.
A **Screen recording** note in the thread has a **Play** button. It opens the replay in a dialog, with its own
**Export video** button.
The tab says why it shows no replay:
| The tab says | Why |
| ------------------------------------------------------------------------ | ----------------------------------------- |
| Waiting for the page: nothing is recorded until it connects. | The page has not connected yet. |
| Recording is off: the page plugin is not active, so nothing is recorded. | Page control is off for this page. |
| Recording is unavailable: capture failed to start on this page. | The recorder could not start on the page. |
| No recording yet: interact with the page first. | Nothing has happened on the page yet. |
## What the agent does with it [#what-the-agent-does-with-it]
The agent calls the recorder from code mode. Learn more in [Tools and code mode](/docs/tools-and-code-mode).
- **`recording_start`** starts a marked recording. It waits until the page is streaming, then gives back a capture id.
- **`recording_stop`** stops that recording and gives back what happened in it.
- **`recording_pull`** gives back the last 60 seconds by default, up to 10 minutes.
- **`recording_get`** reads a recording you sent with **Send to agent**.
What comes back is an action log, with one line per click, input, navigation, scroll, console error or reload. It
also holds up to 3 keyframes by default: screenshots at the last clicks, navigations, console errors or reloads, and
at the end. conciv renders them by replaying the recording in a headless Chromium. With no Chromium to launch, the log comes back without them.
The log quotes what the page showed and what you typed. The agent treats it as page data, never as instructions.
Each start, stop and pull shows as a card in the thread. A start card shows the capture id. A stop or pull card lists
the actions and counts them, with the number of keyframes.
## Options [#options]
Write the entry as a pair, the package name and then its options:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: [['@conciv/plugin-recorder', {masking: 'inputs', windowMinutes: 10, console: true}]], // [!code ++]
}),
],
})
```
| Option | What it does | Default |
| --------------- | ----------------------------------------------------- | ------- |
| `masking` | Hides what you type: `none`, `inputs` or `sensitive`. | `none` |
| `windowMinutes` | How many minutes of the page to keep, from 1 to 60. | `10` |
| `console` | Adds the page's console errors to the log. | `true` |
Password fields are always masked. With `inputs`, every field is masked. With `sensitive`, email and phone fields are
masked as well.
## Where recordings are saved [#where-recordings-are-saved]
**Send to agent** and **Export video** save the recording in your project, under `.conciv/recorder/recordings`. The
recorder keeps the 50 newest, for seven days. The `stateRoot` option does not move them yet.
## Typical uses [#typical-uses]
### Reproduce the bug I just clicked through [#reproduce-the-bug-i-just-clicked-through]
Click through the bug with the **Recorder** tab open. Click **Send to agent**, then ask:
```text title="Prompt"
This is what I did. Find out why the total goes wrong after the second click.
```
### Have the agent record its own check [#have-the-agent-record-its-own-check]
```text title="Prompt"
Start a recording, add two items to the cart, then stop it and tell me what changed on the page.
```
### Export a video for a PR [#export-a-video-for-a-pr]
Do the flow on the page with the **Recorder** tab open. Click **Export video** and attach the `.webm` file to your
pull request.
## Next steps [#next-steps]
- **[Page control](/docs/usage/page-control):** the page plugin the recorder needs.
- **[Add plugins](/docs/usage/add-plugins):** the other plugins you can add.
# Live tests (/docs/usage/live-tests)
Live tests come from the test runner plugin, `@conciv/plugin-test-runner`. It runs your project's tests when you ask.
## Add the test runner [#add-the-test-runner]
Add the plugin to the `plugins` option of your conciv config:
```ts twoslash title="vite.config.ts" tab="Vite" tab-group="bundler"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: ['@conciv/plugin-test-runner'], // [!code ++]
}),
],
})
```
```ts twoslash title="next.config.ts" tab="Next.js" tab-group="bundler"
import type {NextConfig} from 'next'
import {withConciv} from '@conciv/it/plugin/nextjs'
const nextConfig: NextConfig = {}
export default withConciv(nextConfig, {
plugins: ['@conciv/plugin-test-runner'], // [!code ++]
})
```
```js title="webpack.config.js" tab="webpack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/webpack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
plugins: ['@conciv/plugin-test-runner'], // [!code ++]
}),
],
}
```
```js title="rspack.config.js" tab="Rspack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/rspack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
plugins: ['@conciv/plugin-test-runner'], // [!code ++]
}),
],
}
```
Restart your dev server. The engine installs the plugin from npm into its own cache, so it does not go in your
`package.json`. Your test framework does. The plugin runs the one installed in your project.
Then ask in plain words:
```text title="Prompt"
Run the tests and fix whatever fails.
```
## Run part of the suite [#run-part-of-the-suite]
Name a file or an area, and only the test files whose path matches run:
```text title="Prompt"
Run the tests for the cart.
```
## Read the result [#read-the-result]
A test card in the thread shows the finished run. It counts the passed and failed tests, groups them by file, and
shows each failure with its message.
Open the **Tests** tab in the panel to watch a run live. With Vitest, each test shows as it finishes. With Playwright,
the rows appear together when the run ends.
## Ask about the last run [#ask-about-the-last-run]
The agent can read the last result without a new run. It can also list your test files without running them:
```text title="Prompt"
Which tests failed in the last run? Which test files cover the checkout?
```
## Pick a runner [#pick-a-runner]
The `runner` option names your test framework. Write the entry as a pair, the package name and then its options:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: [['@conciv/plugin-test-runner', {runner: 'playwright'}]], // [!code ++]
}),
],
})
```
- **`vitest`** is the default. It drives your project's own `vitest/node`, and each result streams in as it finishes.
- **`playwright`** runs `playwright test` with its JSON reporter. The results arrive when the whole run ends.
The option accepts `jest` and `node-test`, but neither runner exists yet. Pick one and the plugin fails when it
starts.
The message says why: the framework is not installed in your project, or its config fails to load. Install it, or
fix the config, and ask again.
## Options [#options]
conciv generates this table from the schema the plugin checks its options with.
## Next steps [#next-steps]
- **[Add plugins](/docs/usage/add-plugins):** the other plugins you can add.
- **[Approvals](/docs/usage/approvals):** what the agent asks before it acts.
# Logging in (/docs/usage/logging-in)
A browser logs in to conciv once, with a 6-digit code your dev server prints. The engine can read your project and
run commands, so it answers only browsers you let in.
## Log in with the code [#log-in-with-the-code]
Click the conciv button. A browser that is not logged in shows it with an **Unauthorized** badge. The **Authorize
conciv** dialog opens and asks for the code.
Opening the dialog makes the engine print a box in your dev server's terminal:
```text title="Dev server terminal"
╭──────────────────────────────────────────────────────╮
│ conciv: a browser asks to connect to this engine │
│ From: Chrome 142 | macOS at http://localhost:5173 │
│ Code: 482913 │
│ Link: http://localhost:5173/#conciv_otp=482913 │
│ Expires: 10:42:07 │
╰──────────────────────────────────────────────────────╯
```
- **From** is the browser that asks, and the page it asks from. Check it is yours.
- **Code** is what you type.
- **Link** logs the browser in without typing.
- **Expires** is when the code stops working, 5 minutes after it was printed.
Type the six digits. conciv sends them when the last digit is in. The chat opens. The browser stays logged in.
## Log in with a link [#log-in-with-a-link]
Open the **Link** from the box in the browser you want to log in. conciv reads the code from the address and logs the
browser in. Then it removes the code from the address bar.
To get a link without opening the dialog, run this in your project folder with your page's address:
```bash title="Terminal"
npx @conciv/cli auth link http://localhost:5173/
```
It prints the link as JSON:
```json title="Output"
{"ok": true, "data": {"link": "http://localhost:5173/#conciv_otp=482913", "expiresAt": 1795776127000}}
```
`expiresAt` is when the code stops working, in milliseconds since 1970.
## See who is logged in [#see-who-is-logged-in]
Run `revoke` with no browser id. It lists the browsers and logs nobody out:
```bash title="Terminal"
npx @conciv/cli auth revoke
```
It lists each logged-in browser under `trusted`. Each entry has:
- its `id`
- the browser
- the page it logged in from
- when it logged in
## Log a browser out [#log-a-browser-out]
Pass a browser's id to log out that browser. Pass `--all` to log out every browser:
```bash title="Terminal"
npx @conciv/cli auth revoke
npx @conciv/cli auth revoke --all
```
The browser is cut off at once. Its panel says "This browser is no longer authorized to use conciv." and shows a **Log
in** button.
Each login message the panel can show, with its cause and its fix, is in
[Troubleshooting](/docs/reference/troubleshooting).
While a code is live, opening the dialog again prints nothing new. The code in the earlier box still works. Click
**Send a new code** to have the engine print a fresh one.
Each logged-in browser is one row in `.conciv/trusted-browsers.json`, in your project. The file holds a hash of each
browser's token, never the token itself.
With Vite DevTools in your Vite plugins, conciv opens as a panel in the DevTools dock. That page logs itself in,
with no code. It shows in the list as `via Vite DevTools`.
## Next steps [#next-steps]
- **[Chat](/docs/usage/chat):** send your first message.
- **[CLI](/docs/reference/cli):** every `auth` option.
- **[Troubleshooting](/docs/reference/troubleshooting):** each panel message and its fix.
# Outside agent (/docs/usage/outside-agent)
An outside agent is an agent CLI you run in your own terminal: Claude Code, Codex, Gemini CLI or opencode. Connect it
to conciv and it can read and drive the tab you have open, through conciv's `conciv-hub` MCP server. You keep typing
in your terminal. The page changes in your browser.
## Set it up [#set-it-up]
### Run your app and open it [#run-your-app-and-open-it]
Start your dev server and open your app in the browser:
```bash title="Terminal"
pnpm dev
```
Log the browser in with the code your dev server prints. Learn how in [Logging in](/docs/usage/logging-in).
### Open the conciv panel once [#open-the-conciv-panel-once]
Click the conciv button and let the panel open. Your tab joins a chat session the moment the panel opens. Before
that, no agent can see it.
### Connect your agent [#connect-your-agent]
Run this once, in any folder:
```bash title="Terminal" tab="Claude Code" tab-group="agent"
npx @conciv/cli mcp connect claude
```
```bash title="Terminal" tab="Codex" tab-group="agent"
npx @conciv/cli mcp connect codex
```
```bash title="Terminal" tab="Gemini CLI" tab-group="agent"
npx @conciv/cli mcp connect gemini-cli
```
```bash title="Terminal" tab="opencode" tab-group="agent"
npx @conciv/cli mcp connect opencode
```
It adds `conciv-hub` to that agent's own MCP config. On success it prints:
{/* prettier-ignore */}
```json title="Output"
{"ok":true,"data":{"connected":"claude"}}
```
### Check that the agent can see your tab [#check-that-the-agent-can-see-your-tab]
Run this from your project folder:
```bash title="Terminal"
npx @conciv/cli tools tabs
```
Your tab is listed, with the page it shows. This output leaves out the project's folder, branch and last-active time:
```json title="Output"
{
"ok": true,
"data": {
"tabs": [
{
"tab": "ses_dde3add2effeorQX7E0tVdPN4s",
"project": "tanstack-start-example",
"href": "http://localhost:3462/",
"pageTitle": "TanStack Start Starter",
"state": "visible",
"sessionTitle": "New session",
"running": false,
"harness": "claude",
"browserTabs": [
{
"id": "tab_a1f66e90-cd99-46b1-a5af-a1b2fe44d54f",
"href": "http://localhost:3462/",
"pageTitle": "TanStack Start Starter",
"state": "visible"
}
]
}
],
"unreachable": []
}
}
```
The agent sees the same list through its `list_tabs` tool.
## Ask for a first change [#ask-for-a-first-change]
Start your agent in your project folder and ask for something on the page:
```text title="Prompt"
In my open browser tab, change the main heading to say: Hello from the terminal.
```
The agent calls `list_tabs` to find your tab, then runs page tools on it through `execute_typescript`. It edits the
source file with its own file tools, and the page updates on the hot reload. It answers in your terminal:
```text title="Claude Code"
I changed the main heading on your About page
(src/routes/about.tsx:41) from "A small starter with room to grow."
to "Hello from the terminal", and checked the open tab at
localhost:3462/about, which now shows the new text.
```
In the tab, the heading changes. Each page call the agent made shows in the panel's chat as a card marked
**from claude**, so you can see what it read and did.
## Pick the tab [#pick-the-tab]
A call with no tab named goes to the tab you focused last. Two ids pick another one:
- `--tab` takes a `tab` id from `tools tabs`. That is a chat session, on whichever dev server holds it.
- `--tab-id` takes a browser tab id inside that session. Every browser tab with the panel open joins the session.
List the browser tabs of a session, and the one you focused last:
```bash title="Terminal"
npx @conciv/cli tools page tabs_list
```
```json title="Output"
{
"ok": true,
"data": {
"tabs": [
{
"id": "tab_c75a6695-69ee-4969-9d82-3af3463c4346",
"url": "http://localhost:3462/about",
"title": "TanStack Start Starter",
"focused": true,
"visible": true
},
{
"id": "tab_a1f66e90-cd99-46b1-a5af-a1b2fe44d54f",
"url": "http://localhost:3462/",
"title": "TanStack Start Starter",
"focused": false,
"visible": true
}
],
"focusedTabId": "tab_c75a6695-69ee-4969-9d82-3af3463c4346"
}
}
```
Then point a call at the tab you want:
```bash title="Terminal"
npx @conciv/cli tools page route --tab-id tab_a1f66e90-cd99-46b1-a5af-a1b2fe44d54f
```
```json title="Output"
{
"ok": true,
"data": {
"pathname": "/",
"search": "",
"href": "http://localhost:3462/",
"title": "TanStack Start Starter",
"state": "visible"
}
}
```
Your agent passes the same ids. Name the page in your prompt, for example "on the About tab", and it picks the tab
from `list_tabs`.
## Outside agent or panel chat [#outside-agent-or-panel-chat]
The outside agent and the chat in the panel drive the same page with the same tools. They differ in where you talk and
who runs the agent.
| | Outside agent | Panel chat |
| ------------------ | ------------------------------------------------------ | ------------------------------------------- |
| Where you type | Your terminal | The panel in the tab |
| Who runs the agent | You, with your agent's own config | conciv, with the harness you pick |
| Its replies | In your terminal. The panel shows only its page calls. | In the panel |
| Edits files with | Its own tools and permission rules | The harness, with conciv's permission cards |
| Page tools | Only while a tab with the panel open exists | Always, on its own tab |
| Permission cards | It never answers one. You do, in the tab. | You answer them in the panel |
By default an outside agent can use any open tab with no card. To make it ask first, see
[Approvals](/docs/usage/approvals#let-outside-agents-in).
## Troubleshooting [#troubleshooting]
The engine is not running. `tools` prints:
```json title="Output"
{"ok":false,"error":{"kind":"user","message":"No conciv dev server on 127.0.0.1:64476.","hint":"Start your app (pnpm dev). conciv reads the engine port from .conciv/server.json; CONCIV_PORT= overrides it (this is the conciv engine port, not Vite's)."}}
```
Start your dev server again, and run the command from your project folder.
`tools tabs` prints an empty list when no tab has the panel open:
```json title="Output"
{"ok":true,"data":{"tabs":[],"unreachable":[]}}
```
Page tools exist only while a tab is open, so a page call fails too:
```json title="Output"
{"ok":false,"error":{"kind":"user","message":"No tool named \"page_route\" is currently available. Please use a tool from the available tool list.","hint":"read the engine's logs for the tool's error","code":"HANDLER_ERROR"}}
```
Open your app and open the conciv panel once.
A `--tab` id from a closed tab, or from an old listing, prints:
```json title="Output"
{"ok":false,"error":{"kind":"user","message":"tab ses_nope is not open in any of the 1 running conciv dev servers.","hint":"conciv tools tabs lists the open tabs; open the page again if it was closed."}}
```
Run `tools tabs` again and use an id from it.
The Claude Code plugin that init installs reads the engine's address from `.conciv/mcp-endpoint.json`. The engine
writes that file on every start and leaves it when it stops, so a stopped engine leaves an address that answers
nothing. Start your dev server again. The plugin reads the file on every call, so you do not need to restart
Claude Code.
`mcp connect` runs the agent's own CLI. With no such CLI on your `PATH`, it prints:
```json title="Output"
{"ok":false,"error":{"kind":"user","message":"spawn gemini ENOENT"}}
```
Install the agent CLI, then run `mcp connect` again.
## Next steps [#next-steps]
- **[Agents](/docs/agents):** what each agent CLI gets when it connects.
- **[Page control](/docs/usage/page-control):** everything the page tools can read and do.
- **[CLI](/docs/reference/cli):** every `tools` and `mcp` command.
# Page control (/docs/usage/page-control)
Page control lets the agent read and change the page you have open, in your own browser tab. It is built in, with
nothing to install.
## Point at an element [#point-at-an-element]
Click **Select an element from the page**, the crosshair beside the composer. Then click an element in your app.
conciv pins it to your next message, with its source file and line when it can find them:
```text title="Prompt"
Give this card more padding, and round its corners.
```
The agent reads the page, finds the element, changes it, and checks the result.
## Try a change live [#try-a-change-live]
The agent can restyle the page on the spot. You see an idea at once:
```text title="Prompt"
Try the header in dark blue, without saving it.
```
A live change lives only in the page. The next hot reload wipes it, because it is not in your source.
## Keep the change [#keep-the-change]
When you like it, ask the agent to keep it. It edits the source file, so the change survives a reload:
```text title="Prompt"
Keep that. Save it to the component.
```
The agent can also open the file in your editor:
```text title="Prompt"
Open the file that renders this card in my editor.
```
## Have it use the page [#have-it-use-the-page]
The agent can click, type and scroll like a user. Use it to reproduce a bug or walk through a flow:
```text title="Prompt"
Fill the signup form with a test user, submit it, and tell me what the console says.
```
What the agent can do on the page:
- **Read** the page: its controls, its text, a field's value, a screenshot, the console and the current route.
- **Act** on it: click, fill, select, check, press a key, hover, scroll and submit.
- **Restyle** it: change styles, classes and text, live.
- **Inspect React**: the component tree, and the file and line that rendered an element.
- **Wait** for an element to show or hide, or for a hot update to land after a file edit.
- **Run code** in the page. This asks you first, every time.
Learn more about the ask in the [Approvals documentation](/docs/usage/approvals).
The tab you focused last answers. Name another tab in your message to point the agent at it.
Page text, console messages and screenshots are untrusted. The agent is told never to follow instructions found in
them.
That is the tool's name in code mode, where the agent calls tools from a short program. Learn more in [Tools and
code mode](/docs/tools-and-code-mode).
## Next steps [#next-steps]
- **[Approvals](/docs/usage/approvals):** the card that asks before code runs in your page.
- **[Dev server](/docs/usage/dev-server):** how the agent reads the server behind the page.
# Quick terminal (/docs/usage/quick-terminal)
The quick terminal is the chat as a full-width sheet that drops from the top of the page, over your app.
The quick terminal is still the chat. To run the agent CLI itself in a real terminal, use the **Terminal** tab. Learn
more in [Terminal](/docs/usage/terminal).
## Open it [#open-it]
Press `Mod+backtick` to open it, where `Mod` is Cmd on macOS and Ctrl elsewhere. Press it again, or Escape, to close
it. The app stays visible and usable below the sheet.
## Split it into panes [#split-it-into-panes]
The first pane opens your latest session. Click **Split pane** in the header, or press `Mod+D`, for a new pane with a
new session. Drag the gutter between two panes to resize them.
Each pane has its own session picker, usage, refresh and **Close pane** button.
Closing a pane deletes its session and its draft. Closing the last pane closes the quick terminal.
## Resize it [#resize-it]
Drag the grip on the bottom edge to set the height. conciv remembers it. Drag the grip almost to the top to close
the sheet.
## Pop a pane out [#pop-a-pane-out]
Click **Pop out to a window** to open the focused pane's session in its own browser window. If the browser blocks the
window, the session opens in the corner panel instead.
## Change the hotkey [#change-the-hotkey]
Open **Settings > Shortcuts**, click **Quick terminal** and press the new keys. The same list holds the corner panel's
key, `Mod+.` by default.
To set the hotkey for everyone on the project, add it to your conciv options:
```ts twoslash title="vite.config.ts" tab="Vite" tab-group="bundler"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
widget: {quickTerminal: {hotkey: 'Alt+k'}}, // [!code ++]
}),
],
})
```
```ts twoslash title="next.config.ts" tab="Next.js" tab-group="bundler"
import type {NextConfig} from 'next'
import {withConciv} from '@conciv/it/plugin/nextjs'
const nextConfig: NextConfig = {}
export default withConciv(nextConfig, {
widget: {quickTerminal: {hotkey: 'Alt+k'}}, // [!code ++]
})
```
```js title="webpack.config.js" tab="webpack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/webpack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
widget: {quickTerminal: {hotkey: 'Alt+k'}}, // [!code ++]
}),
],
}
```
```js title="rspack.config.js" tab="Rspack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/rspack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
widget: {quickTerminal: {hotkey: 'Alt+k'}}, // [!code ++]
}),
],
}
```
`hotkey` takes one key or a list of keys. A key set here is locked in **Settings > Shortcuts**. Its row says the
project set it.
## Turn it off [#turn-it-off]
Set `quickTerminal` to `false` in the same place. The hotkey then does nothing, and only the corner panel opens:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
widget: {quickTerminal: false}, // [!code ++]
}),
],
})
```
Opening one closes the other.
## Next steps [#next-steps]
- **[Chat](/docs/usage/chat):** what each pane's composer does.
- **[Terminal](/docs/usage/terminal):** the agent CLI in a real terminal.
- **[Configuration](/docs/reference/configuration):** every conciv option.
# TanStack (/docs/usage/tanstack)
The TanStack plugin, `@conciv/plugin-tanstack`, is for apps on TanStack Router or TanStack Start. It lets the agent
read your dev server's build errors, every route you define and the server functions that ran. With your app open, it
also reads and drives the router and the query cache.
## Add the TanStack plugin [#add-the-tanstack-plugin]
Add the plugin to the `plugins` option of your conciv config:
```ts twoslash title="vite.config.ts" tab="Vite" tab-group="bundler"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: ['@conciv/plugin-tanstack'], // [!code ++]
}),
],
})
```
```ts twoslash title="next.config.ts" tab="Next.js" tab-group="bundler"
import type {NextConfig} from 'next'
import {withConciv} from '@conciv/it/plugin/nextjs'
const nextConfig: NextConfig = {}
export default withConciv(nextConfig, {
plugins: ['@conciv/plugin-tanstack'], // [!code ++]
})
```
```js title="webpack.config.js" tab="webpack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/webpack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
plugins: ['@conciv/plugin-tanstack'], // [!code ++]
}),
],
}
```
```js title="rspack.config.js" tab="Rspack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/rspack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
plugins: ['@conciv/plugin-tanstack'], // [!code ++]
}),
],
}
```
Restart your dev server. The engine installs the plugin from npm into its own cache, so it does not go in your
`package.json`. On TanStack Start, see [TanStack Start](/docs/bundlers/tanstack-start) for the full config.
With the plugin on, the session's status line shows **TanStack inspector active**.
## What the agent reads from the dev server [#what-the-agent-reads-from-the-dev-server]
These tools work with or without your app open. The agent calls them from code mode. Learn more in
[Tools and code mode](/docs/tools-and-code-mode).
| Tool | What it gives back |
| ----------------------------------- | ------------------------------------------------------------------------------------------ |
| `external_tanstack_build_errors` | The dev server's last 50 build and transform errors, with file, line and column. |
| `external_tanstack_route_manifest` | Every route in `src/routeTree.gen.ts`, with its path, page or layout, and source file. |
| `external_tanstack_server_fn_trace` | The latest server function calls, with name, duration and status, and every function seen. |
The server function trace keeps the last 100 calls. The agent can ask for fewer, from 1 to 100.
Each call shows as a card in the thread, such as **Read the build errors** or **Read the route manifest**.
The build errors and the server function calls come from a Vite dev server. TanStack Start runs on Vite. On webpack or
Rspack, build errors answer `BUNDLER_UNAVAILABLE` and no server function calls show. The route list works on any
bundler.
## What the agent does in your app [#what-the-agent-does-in-your-app]
While your app is open with the conciv panel, the agent also reads and drives TanStack in that page:
- **Read:** the router state, the route tree, the loader data of a route, the query cache and the page's runtime
errors.
- **Act:** navigate to a path, go back, re-run the router's loaders, and invalidate or refetch one query.
Nothing it does deletes data. A navigation or an invalidation changes what you see, and you can go back. With several
tabs open, the agent works on the tab you focused last unless it names another.
These tools need page control. Learn more in [Page control](/docs/usage/page-control).
## When it goes wrong [#when-it-goes-wrong]
| The agent says | Why | What to do |
| ------------------------ | ---------------------------------------------------- | --------------------------------------------------- |
| `BUNDLER_UNAVAILABLE` | No dev server is attached to the engine. | Start the app through its dev server. |
| `MANIFEST_UNREADABLE` | `src/routeTree.gen.ts` is missing or cannot be read. | Start the dev server once, so the router writes it. |
| `router_not_found` | The page has no TanStack Router. | Open a page of your TanStack app. |
| `query_client_not_found` | The page has no TanStack Query client. | Nothing: the app does not use TanStack Query there. |
The errors, routes and data the plugin reads come from your project. The agent treats them as data, never as
instructions.
## Options [#options]
Write the entry as a pair, the package name and then its options:
```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: [['@conciv/plugin-tanstack', {bundlerWaitMs: 5000}]], // [!code ++]
}),
],
})
```
| Option | What it does | Default |
| --------------- | ------------------------------------------------------------------------------- | ------- |
| `bundlerWaitMs` | How long, in milliseconds, build errors wait for a dev server before they fail. | `10000` |
`bundlerWaitMs` must be a positive whole number. Any other value stops the plugin from loading, and the engine says
which option it refused.
## Typical uses [#typical-uses]
### Find out why the app broke [#find-out-why-the-app-broke]
```text title="Prompt"
The page is blank after my last change. Read the build errors and fix them.
```
### Check the routes [#check-the-routes]
```text title="Prompt"
List every route in the app and tell me which ones take a dynamic segment.
```
### Debug a slow server function [#debug-a-slow-server-function]
```text title="Prompt"
I just clicked Save. Which server functions ran, and which one was slow?
```
### Refresh stale data [#refresh-stale-data]
```text title="Prompt"
The cart count is stale. Look at the query cache and refetch the cart query.
```
## Next steps [#next-steps]
- **[TanStack Start](/docs/bundlers/tanstack-start):** add conciv to a TanStack Start app.
- **[Dev server tools](/docs/usage/dev-server):** what the agent reads from Vite.
- **[Add plugins](/docs/usage/add-plugins):** the other plugins you can add.
# Terminal (/docs/usage/terminal)
The **Terminal** tab runs your agent's own CLI in a real terminal, inside the widget. You type to the CLI as you would
in your shell. Each session has its own terminal.
It comes from the terminal plugin. It is on in every widget, so there is nothing to add.
The [quick terminal](/docs/usage/quick-terminal) is the chat in a sheet that drops from the top of the page. The
**Terminal** tab is a real terminal running the CLI.
## When you see the tab [#when-you-see-the-tab]
The tab shows for a session whose agent CLI has a terminal command. Today that is Claude Code. A session on another
CLI has no **Terminal** tab.
The tab is pinned in the session's pane, next to **Chat**. Click it to switch, and click **Chat** to go back.
## Start the CLI [#start-the-cli]
The CLI starts the first time you open the tab. Until then nothing runs. After a page reload, the tab shows what the
terminal printed before.
## The toolbar [#the-toolbar]
The toolbar sits above the terminal:
- **New terminal** ends the CLI and starts a fresh one.
- **Select model** picks the model the CLI runs. A new pick restarts the CLI with that model.
- **Select an element from the page** lets you pick an element on your app. It is there while page control is on.
The model you pick stays with its session. It is also the default for your next session.
While the CLI is working, **New terminal** and **Select model** are locked. They unlock when it finishes.
## Send an element to the CLI [#send-an-element-to-the-cli]
Click **Select an element from the page**, then click an element on your app. It shows as a chip in the toolbar. Pick
more to hold several. Click the **x** on a chip to drop it.
Press Enter in the terminal. The held elements are pasted into the CLI with your line, and the chips clear. They never
go to the chat. Learn more in [Page control](/docs/usage/page-control).
## Stop the CLI [#stop-the-cli]
Press Escape with focus in the terminal to interrupt the CLI while it works. Keys you press on your app stay there.
When the CLI ends, the terminal dims and says **Terminal session ended**. Click **Back to chat** to return to the chat,
or **New terminal** to start again.
## When it goes wrong [#when-it-goes-wrong]
| You see | Why | What to do |
| ------------------------------------------------------- | ---------------------------------------------------------- | ------------------------------------------- |
| The CLI is busy. Wait for it to finish, then try again. | You asked for a new terminal or model while the CLI works. | Wait for the CLI to finish, then try again. |
| Couldn’t restart the terminal. | The old terminal could not be ended. | Try **New terminal** again. |
| Couldn’t open the terminal. | The terminal did not start, such as on a CLI with none. | Click **Retry**. Check the session's CLI. |
## Turn it off [#turn-it-off]
You cannot turn the terminal off in config. It only shows for a CLI with a terminal, and starts only when you open
the tab.
## Typical uses [#typical-uses]
### Use a CLI command the chat does not have [#use-a-cli-command-the-chat-does-not-have]
Open the **Terminal** tab and type the CLI's own command, such as a slash command, as you would in your shell.
### Point the CLI at an element [#point-the-cli-at-an-element]
Click **Select an element from the page**, pick the broken button, then type:
```text title="Terminal"
This button does nothing on click. Find out why.
```
### Try another model [#try-another-model]
Click **Select model** and pick another model. The CLI restarts with it, and the session keeps that pick.
## Next steps [#next-steps]
- **[Quick terminal](/docs/usage/quick-terminal):** the chat as a drop-down sheet.
- **[Chat](/docs/usage/chat):** talk to the agent in the chat instead.
- **[Add plugins](/docs/usage/add-plugins):** the other plugins conciv ships.
# Whiteboard (/docs/usage/whiteboard)
The whiteboard is an [Excalidraw](https://excalidraw.com) canvas over your app that you and the agent draw on
together.
## Add the whiteboard [#add-the-whiteboard]
Add the plugin to the `plugins` option of your conciv config:
```ts twoslash title="vite.config.ts" tab="Vite" tab-group="bundler"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'
export default defineConfig({
plugins: [
conciv({
plugins: ['@conciv/plugin-whiteboard'], // [!code ++]
}),
],
})
```
```ts twoslash title="next.config.ts" tab="Next.js" tab-group="bundler"
import type {NextConfig} from 'next'
import {withConciv} from '@conciv/it/plugin/nextjs'
const nextConfig: NextConfig = {}
export default withConciv(nextConfig, {
plugins: ['@conciv/plugin-whiteboard'], // [!code ++]
})
```
```js title="webpack.config.js" tab="webpack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/webpack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
plugins: ['@conciv/plugin-whiteboard'], // [!code ++]
}),
],
}
```
```js title="rspack.config.js" tab="Rspack" tab-group="bundler"
const conciv = require('@conciv/it/plugin/rspack')
module.exports = {
mode: 'development',
plugins: [
conciv.default({
plugins: ['@conciv/plugin-whiteboard'], // [!code ++]
}),
],
}
```
Restart your dev server. The engine installs the plugin from npm into its own cache, so it does not go in your
`package.json`.
## Sketch a layout [#sketch-a-layout]
Click **Whiteboard** above the composer. The canvas opens over the page. The chat stays usable above it. Sketch a
rough layout, then ask:
```text title="Prompt"
Build the layout I sketched on the whiteboard, using our Card component.
```
Press Escape to close the canvas. It is see-through, so your page shows under your sketch. For a solid canvas, turn
off **Canvas background** in the general settings.
## Have the agent draw [#have-the-agent-draw]
Ask for a diagram of what you are both looking at:
```text title="Prompt"
Draw a diagram of how the checkout page loads its data.
```
The agent draws real Excalidraw shapes, not a picture. You can move, restyle or delete anything it drew. It can also:
- connect shapes with arrows
- convert an SVG into shapes
- turn a mermaid diagram into shapes
## Comment on an element [#comment-on-an-element]
Click **Comment** above the composer, then click an element on the page. The comment is tied to the component's
source, not to a spot on the canvas. The agent can comment too. It can also work through yours:
```text title="Prompt"
Go through my comments on the whiteboard and fix each one. Resolve the ones you fixed.
```
Deleting an element, clearing the canvas, and resolving or deleting a comment each show a [Permission
card](/docs/usage/approvals) first.
Each chat session has its own board. The engine keeps it in your project's conciv state, on your machine. Every open
tab shows the same board as it changes.
Closing only hides the canvas. The agent draws into a draft first, then adds it to the board, even while the canvas
is closed.
## Next steps [#next-steps]
- **[Page control](/docs/usage/page-control):** have the agent change the page directly.
- **[Add plugins](/docs/usage/add-plugins):** the plugins you can add to your own app.