Interfaces and implementations
An interface is a named contract. A plugin declares it in an interface document. Any tier can hold a reference that implements it, and a skill, the consumer, loads the implementations. The command lists the implementations of an interface and checks that each one has the shape the interface describes.
| Term | Means |
|---|---|
| interface | An id, a cardinality, a version, the sections an implementation has, and the frontmatter keys it carries |
| interface document | The reference that declares an interface, named <id>.interface |
| implementation | A reference that declares implements: <id>@<version> |
| consumer | A skill that reads the implementations of an interface |
| pin | The name a consumer loads an implementation by |
An interface whose id ends in .blueprints has one implementation per way of using a system. See
capability references and blueprints. Registered interfaces are listed in
the interface registry; registering is optional.
Declaring an interface
Section titled “Declaring an interface”The plugin that owns an interface ships its interface document, <id>.interface.md. Its frontmatter holds the
contract. Its body holds the prose implementers read.
---description: How release notes are laid out.interface: cardinality: one version: 1 sections: - {heading: Layout, required: true, holds: The sections of the notes, in order.} - {heading: Audience, holds: Who the notes are written for.}---
## Purpose
A skill that writes release notes follows the implementation in use.| Key | Holds |
|---|---|
cardinality |
one: the implementation is named <id>. many: each is named <id>.<key> |
version |
A positive integer |
versions |
The versions the owner’s consumers accept. Defaults to [version] |
sections |
The implementation’s top-level sections, in order, each listed once |
frontmatter |
Optional. The frontmatter keys every implementation carries |
A section is a plain heading, or {heading, required, holds, sections}. required is true or false (default
false). holds is one line saying what the section holds. An implementation’s stub repeats it, and nothing checks it.
The older form - <heading>: required fails the interface check, and its message shows the new form.
sections inside a section lists the sections it holds, one heading level below it, with the same required and order
rules. They are checked while the section itself is present; a section left out fails only its own required check.
A frontmatter field is a plain key, or {key, type}. Every listed key is required. type is string, number,
boolean, list, or mapping, as YAML reads the value; with none, any value passes.
interface: cardinality: many version: 1 frontmatter: - description - {key: tags, type: list} sections: - {heading: Delegator, required: true} - heading: Delegatee required: true sections: - {heading: The brief, required: true} - The reportA missing or malformed key fails the interface check, naming each problem. Any other key is ignored. Heading text is
API: renaming or removing a section raises the version.
An interface document is never composed. To change a contract, define a new interface id.
Implementing an interface
Section titled “Implementing an interface”---description: Release notes grouped by change type.implements: release-notes.format@1---
## Layout
Features, then fixes, then chores.
## Audience
**Partial.** Written for developers; no separate summary for users.- The name is
<id>for cardinalityone, or<id>.<key>formany. The interface id is the namespace, so an implementation takes no plugin prefix. implementsnames one interface.- A listed section whose first line is
**Unsupported.**, or that is left out, is listed as unsupported. A required section that is unsupported failscheck. - A listed section whose first line is
**Partial.**is honored only in part. It counts as present, so a required section may be partial. It is listed as partial. - Either mark is followed by one sentence saying what is missing or why. A mark with none fails
check. - A section the interface does not list may sit anywhere.
- A nested section follows the same rules under its section, and is listed by its path, such as
Delegatee > The report. - Each key the interface lists under
frontmatteris present, of its type. checkreads the document a load composes across the tiers, so a customization that drops a section or a field, or changes a field’s type, fails.
Authoring references shows how to start one from the interface’s stub.
Loading the implementations
Section titled “Loading the implementations”A consumer names the interface in one line, and declares it under metadata.reference-interfaces in its frontmatter:
Load the implementations of the `release-notes.format` interface with the `reference` skill of `cyber-agentkit`.The reference skill then runs reference implementations <id>. For the one interface above, shipped with its
implementation by the plugin acme-release:
npx -y cyber-agentkit reference implementations release-notes.formatimplementations[1]: - pin: acme-release/release-notes.format description: Release notes grouped by change type. partial[1]: AudienceinUse: acme-release/release-notes.formatEach implementation listed passes check for the interface. It carries its pin, its description, the sections it
does not support (unsupported), and the sections it supports only in part (partial). The consumer picks the ones
it needs and loads each by its pin, with reference load <pin>. --trace adds each one’s name, tier, and version, and
the interface’s cardinality and accepted versions. It also lists each implementation left out, with the reason, such
as version: unknown version 2.
- A plugin’s implementation is pinned by its qualified name,
<plugin>/<name>, so the consumer loads that plugin’s own stack. - A
manyimplementation in the repo or user tier is pinned by its bare name, and a plugin’s implementation of the same name is left out. - When several plugins hold one name and nothing orders them, none is listed until a customizer picks one with
reference customize --extends. - A skill’s default is never listed. It has no qualified name to pin.
In the fixture repository of this site, the many interface scaffold.recipe has one implementation in the repo tier,
so its pin is the bare name:
implementations[1]: - pin: scaffold.recipe.typescript-lib tier: repo description: A TypeScript library. unsupported[1]: VerifyThe one in use: inUse
Section titled “The one in use: inUse”For a one interface, implementations also gives inUse: the stack a load of <id> builds on. It is a pin, or
default when only the loading skill’s default holds the name. It is absent for a many interface.
inUse names the stack only. A repo or user contribution to <id> still applies over it when the name loads. With a
repository file release-notes.format.md that writes merge: replace, inUse still reads
acme-release/release-notes.format, and reference load release-notes.format returns the repository’s text.
Versions
Section titled “Versions”A consumer shipped apart from the interface’s owner may know other versions than the owner’s versions.
--accept 1,2 replaces the accepted versions. An implementation whose version is not accepted is left out.
A family of interfaces
Section titled “A family of interfaces”implementations <prefix>.* lists every interface under the prefix at once, each as implementations <id> lists it.
reference customize <prefix>.* --extends <plugin> writes the same pick for each. The skill skill’s aspects,
skill-design.aspects.*, are such a family.
From the library
Section titled “From the library”import { homedir } from 'node:os'import { referenceImplementations, referenceLayers } from 'cyber-agentkit'
const layers = await referenceLayers({ root: process.cwd(), home: homedir(), platform: process.platform })const { implementations, excluded, inUse } = referenceImplementations('release-notes.format', layers)A consumer that reads one known implementation, such as a one slot, can also load it by name with load. load
warns interface-check when the document it composes fails its interface check.
Building on another plugin’s implementation
Section titled “Building on another plugin’s implementation”A plugin can change how another plugin’s implementation reads without forking it, such as a house style. It ships the
same name, lists the other plugin in extends, and holds only the sections it changes:
---implements: project-tracker.capabilities@1extends: [repobuddy]---
## Create
The house way to file an issue.With no extends written in the managed, repo, or user tier, the plugins’ own extends order them: repobuddy sits
below, and this contribution patches it. A qualified name such as
repobuddy/project-tracker.capabilities.github builds only repobuddy’s own stack.