Skip to content
Vector
Esc
↑↓navigate↵open⌘Jpreview
On this page

Build and run your first Vector Configuration

Define a project-aware command, load its OpenCode Plugin Entrypoint, invoke it, and recover from common setup errors.

This tutorial starts from a Node.js 24 ESM project with Vector installed. It creates one command and loads it directly from source.

Define the extension

Create an Extension Definition with the fixed command name project-summary.

import { defineCommand } from '@evilkiwi/vector';

export const projectSummary = defineCommand({
  name: 'project-summary',
  build: (context) => ({
    template: `Summarize the project at ${context.project.canonical}`,
  }),
});

The module now exports one reusable Extension Definition. Its command template is assembled from the active Context during activation.

Define the configuration

Select the extension in the Extension Plan and default-export the returned OpenCode Plugin Entrypoint.

import { defineVector } from '@evilkiwi/vector';

import { projectSummary } from './extensions.js';

export default defineVector({
  id: 'project-tools',
  build: () => ({
    commands: [projectSummary],
  }),
});

The default export is the OpenCode Plugin.Plugin value for this Vector Configuration.

Load the entrypoint

Add the module to OpenCode’s plugins setting with an absolute file URL.

{
  "plugins": ["file:///absolute/path/to/your-project/src/opencode.ts"]
}

Replace the example path with the absolute path to your project before starting OpenCode.

Invoke the command

Start OpenCode with that configuration, then invoke the registered command.

/project-summary

Success is observable when OpenCode accepts project-summary and starts a response from the prompt that names the active project’s canonical path.

Recover from likely errors

Symptom Check Recovery
The plugin module does not load The URL is absolute, uses file://, and points to src/opencode.ts. Correct the URL, then reload OpenCode.
project-summary is not available src/opencode.ts default-exports the value returned by defineVector(). Restore the default export, then reload OpenCode.
The source cannot resolve its import The relative import uses the ESM .js specifier and the project can execute TS entrypoints. Correct the import or load the built ESM entrypoint described in Package.

Vector resolves Context, builds the Extension Plan, materializes and preflights the Snapshot, then registers the command with OpenCode.

Next, reuse the extension or review the core concepts.