$dshubuser@dshub:~/plugins$
  • Plugins
  • Submit
  • Blog
  • Changelog
Configuration: Give Plugins Validated Options and Defaults
2026/08/27

Configuration: Give Plugins Validated Options and Defaults

Define Cordis plugin configuration with Schemastery and see how defaults, path-aware errors, and FAILED Fibers prevent a sick start.

The conclusion: configuration is not an unchecked object. A schema runs before apply, fills defaults, rejects invalid input, and lets the plugin handle only valid options.

Behavior choices can stay in cordis.yml or a profile patch while runtime preconditions remain explicit.

01 / Keep the type and schema together

A configurable plugin can declare its options like this:

import type { Context } from '@deepseek-ai/cordis'
import Schema from '@deepseek-ai/schemastery'

export interface Config {
  greeting: string
  targets: string[]
}

export const Config: Schema<Config> = Schema.object({
  greeting: Schema.string().default('Hello'),
  targets: Schema.array(String).default(['world']),
})

export function apply(ctx: Context, config: Config) {
  for (const target of config.targets) {
    console.log(config.greeting + ', ' + target + '!')
  }
}

The Config interface supplies static TypeScript types. The runtime schema with the same name validates and defaults values. A plain object is not enough because Cordis needs a runtime validator that follows Standard Schema.

02 / Configuration comes from cordis.yml

- name: './config-demo.ts'
  config:
    targets: ['alpha', 'beta']

Because greeting is omitted, the schema fills in Hello. apply receives a complete configuration:

Hello, alpha!
Hello, beta!
Cordis configuration lifecycle from raw YAML to defaults, apply, and Fiber state

03 / Errors appear before apply

Pass a string where the schema requires an array:

- name: './config-demo.ts'
  config:
    targets: 'not-an-array'

Loader reports a path-aware ValidationError, for example:

ValidationError: invalid config:
  - $.targets expected array but got not-an-array (at targets)

The Fiber enters FAILED and the launcher exits with failure. The plugin does not run several steps with bad input and leave an ambiguous error deeper in the runtime.

Cordis configuration tree showing schema options, defaults, and constraints

04 / The schema is part of the configuration API

A schema records input types, defaults, and constraints together. If a field changes deployment behavior, make it a schema field instead of scattering a DEFAULT_* constant through the plugin.

This repository uses Schemastery, while Cordis accepts validators that follow Standard Schema. Schemas can also express required values, unions, arrays, and objects.

05 / Keep computed values in explicit locations

The repository’s loader extension supports !!js:

- name: './config-demo.ts'
  config:
    greeting: !!js process.env.DEMO_GREETING ?? 'Hello'

It is evaluated only inside config and an entry’s disabled field. Metadata such as name, id, and inject stays static. A config expression is evaluated against the plugin Context after required services are active; disabled is evaluated against the Loader Context at each mount decision. For environment-specific composition, a profile overlay is usually clearer than making every metadata field dynamic.

Where to go next

  • cordis.yml: Configuration as Composition
  • Lifecycle and effects
  • Composition and HMR

Sources: configuration tutorial, Schemastery, and Fiber implementation.

All Posts

Author

avatar for DSH Research
DSH Research

Categories

  • Agent Infrastructure
01 / Keep the type and schema together02 / Configuration comes from cordis.yml03 / Errors appear before apply04 / The schema is part of the configuration API05 / Keep computed values in explicit locationsWhere to go next

More Posts

Hands-on: Write Your First Cordis Plugin with hello.ts
Agent Infrastructure

Hands-on: Write Your First Cordis Plugin with hello.ts

Run the shortest path from a function plugin and cordis.yml through Loader, Context, and Fiber.

avatar for DSH Research
DSH Research
2026/08/20
Cordis: Five Concepts for Reading a Plugin Tree
Agent Infrastructure

Cordis: Five Concepts for Reading a Plugin Tree

Build the smallest useful mental model of Cordis with Plugin, Context, inject, Events, and Effect.

avatar for DSH Research
DSH Research
2026/08/19
Events: Let Plugins Cooperate Without Knowing Who Listens
Agent Infrastructure

Events: Let Plugins Cooperate Without Knowing Who Listens

Use typed events and five dispatch modes to understand how Cordis broadcasts facts, runs listeners concurrently, or hands over decisions.

avatar for DSH Research
DSH Research
2026/08/25

Newsletter

Join the community

Subscribe to our newsletter for the latest news and updates

[dshub] [zsh]$ dshub ls$ dshub submit$ dshub blog
-- NORMAL -- ✓ 2026 dshub