---
title: Compute shared Context properties
description: Bind one synchronous computeContext callback to a builder and share its inferred Context across configurations and extensions.
sidebar:
  label: Computed context
---

Use `createVectorBuilder({ computeContext })` when several configuration and extension callbacks need the same derived value. The builder binds one inferred Context extension to all of its helpers.

This example derives a short project label for the existing project-summary command.

```ts title="src/vector.ts"
import { createVectorBuilder } from '@evilkiwi/vector';

export const vector = createVectorBuilder({
  computeContext: ({ project }) => ({
    projectLabel: project.canonical.split('/').at(-1) ?? project.id,
  }),
});
```

Define the command with the bound helper so `context.projectLabel` is inferred.

```ts title="src/extensions/project-summary.ts"
import { vector } from '../vector.js';

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

Select it with the same builder's `defineVector()`.

```ts title="src/opencode.ts"
import { projectSummary } from './extensions/project-summary.js';
import { vector } from './vector.js';

export default vector.defineVector({
  id: 'project-tools',
  build: (context) => ({
    commands: context.projectLabel.length === 0 ? [] : [projectSummary],
  }),
});
```

Vector calls `computeContext` once per activation and shares the resulting Context properties with the root callback and every selected bound extension.

> **Keep computeContext synchronous**
>
> Return a plain object without the reserved `runtimeConfig`, `cwd`, or `project` keys. Arrays, class instances, dates,
> callable `then` properties, and promises fail activation before extension building or registration.

An ordinary non-callable `then` property and a null-prototype record are valid. A builder created without options preserves the root helpers' base Context shape.

See [`createVectorBuilder()`](/api/create-vector-builder) and [Context](/api/context) for the exact types and boundaries.
