Skip to content
venizia.ai

Documentation · VULCAN

okf renderers ​

okf generates reference documents and managed markdown blocks from source code. You configure okf through the okf object in .configs/vulcan.config.mts.

OptionTypeDefaultMeaning
renderersArray<string | object>[]Built-in renderer identifiers or custom generator modules
regionsArray<object>[]Target files and renderers for managed markdown blocks
coverageArray<object>[]Directory axes checked for concept documentation coverage
denyliststring[][]Directory names dropped across every coverage axis
contentsobject{ files: ['AGENTS.md', '.agents/rules.md'] }Files that receive generated table of contents when exceeding 100 lines
brandstringroot package name, unscoped, upper-casedHow the project's name is written in prose

To configure okf features, export an okf section in .configs/vulcan.config.mts:

ts
import type { VulcanConfig } from '@venizia/vulcan';

export default {
  knowledge: {
    okf: {
      renderers: [
        'source-map',
        'makefile-targets',
      ],
      regions: [
        { id: 'packages-table', file: 'overview/repository-layout.md', renderer: 'packages-table' },
      ],
      coverage: [
        { name: 'packages', path: 'packages/*' },
      ],
    },
  },
} satisfies VulcanConfig;

Built-in renderers ​

okf ships four built-in renderers:

IdWritesCollects fromOptions
source-mapWhole page (reference/source-map.md)packages/*/src subsystems and source filespath, seeAlso
makefile-targetsWhole page (reference/makefile-targets.md)Root make database targets, prerequisites, and descriptionspath, seeAlso
binding-keysWhole page (reference/binding-keys.md)Source file configured in options.sourcesource (required), path, description, seeAlso
packages-tableManaged region onlyPackage manifests and directoriesNone

To pass options, use the object form { id, module, options } in knowledge.okf.renderers. module is an optional path from the repository root. options passes settings to the renderer. Because binding-keys requires options.source, configure it using the object form:

ts
{ id: 'binding-keys', options: { source: 'packages/kernel/src/keys.ts' } }

source-map ​

source-map documents packages from the top-level packages key. It skips retired entries and missing directories. When no packages list is configured, it falls back to every directory under packages/. The top-level knowledge.okf.denylist drops packages too. For each package, it scans package directories under packages/*/src and counts source files. Subsystems named __tests__ or with zero files are left out. Rows sort by file count.

OptionTypeDefaultMeaning
pathstring'reference/source-map.md'Output path relative to bundle
seeAlsostringsee note belowRelated concept link on notice line

makefile-targets ​

makefile-targets runs make -pRrq and reads make's own database. It requires make on PATH. It lists generated targets too. Descriptions come first from make help rows in make/help.mk, then from a target: ## description line. It fails with an error if make fails or is missing.

OptionTypeDefaultMeaning
pathstring'reference/makefile-targets.md'Output path relative to bundle
seeAlsostringsee note belowRelated concept link on notice line

binding-keys ​

binding-keys extracts dependency-injection binding classes from TypeScript source. It tabulates constant names and string keys across binding classes. Because binding-keys requires options.source, declare it using the object form:

ts
{ id: 'binding-keys', options: { source: 'packages/kernel/src/keys.ts' } }
OptionTypeDefaultMeaning
sourcestringnone (required)Path to binding keys file from repository root
pathstring'reference/binding-keys.md'Output path relative to bundle
descriptionstring'Every dependency-injection binding key declared in the kernel (generated).'Frontmatter description text
seeAlsostringsee note belowRelated concept link on notice line

If you omit options.source, collection halts with an error.

packages-table ​

packages-table implements only the region method. It generates a markdown table listing package directories, npm names, and descriptions. Each directory links to its corresponding package concept. packages-table takes no options.

Generated page header convention ​

Every generated reference file begins with frontmatter:

md
---
type: Reference
title: <title>
description: <description>
resource: <resource>
tags: [<tags>]
generated:
  by: process:okf-gen
---

Under the frontmatter, okf adds a warning notice without a timestamp:

md
> Generated from source - do not edit; run `make okf-gen`.

When you omit seeAlso, okf appends a default link if that concept exists in the bundle:

RendererDefault link target
source-mapoverview/monorepo-layout.md
makefile-targetsprocess/build-system.md
binding-keysconventions/binding-key-namespaces.md

If you provide an explicit seeAlso string, okf prints your text as given.

To run generation, run vulcan okf gen:

text
$ bun node_modules/.bin/vulcan okf gen
gen: wrote .agents/knowledge/reference/makefile-targets.md

Your own renderer ​

To declare a custom renderer, provide an object in knowledge.okf.renderers:

ts
import type { VulcanConfig } from '@venizia/vulcan';

export default {
  knowledge: {
    okf: {
      renderers: [
        { id: 'probe', module: '.agents/okf/probe.ts' },
      ],
    },
  },
} satisfies VulcanConfig;

A custom renderer module exports the result of defineRenderer as its default export. Import defineRenderer from @venizia/vulcan/okf.

Only id and collect are required. render, region, and coverage are optional.

  • collect: Extracts facts from source files. Its signature is ({ context }) => facts.
  • render: Generates one or more complete files. It returns { path, content } or an array of them, with path relative to the bundle. Its signature is ({ context, facts }) => IRenderedFile | IRenderedFile[].
  • region: Generates markdown content for a managed region block. Its signature is ({ context, facts }) => string.
  • coverage: Reports facts to vulcan okf coverage. Its signature is ({ facts }) => { name, count }.

The context object provides repository paths, source scanners, and formatting helpers:

  • context.root: Absolute path to the repository root.
  • context.bundle: Absolute path to the knowledge bundle directory.
  • context.options: Options object declared in configuration.
  • context.source: Source helpers including listDirs and sourceFiles.
  • context.page: Page formatters for header and note.

The following example shows a custom renderer module:

ts
import { defineRenderer } from '@venizia/vulcan/okf';

export default defineRenderer({
  id: 'probe',
  collect: ({ context }) => context.source.listDirs({ dir: '.agents' }),
  render: ({ context, facts }) => ({
    path: 'reference/probe.md',
    content:
      context.page.header({ title: 'Probe', description: 'Smoke.', resource: '.agents', tags: ['reference'] }) +
      `${facts.length} directories.\n`,
  }),
});

The id property in the module must match the id declared in .configs/vulcan.config.mts. Two entries in knowledge.okf.renderers with the same id are an error. A custom module with a built-in id replaces that built-in renderer. When okf loads the module, it prints:

text
okf: module '<id>' replaces the built-in renderer

Regions ​

A managed region is a marked block inside a markdown file. When you run vulcan okf gen, okf rewrites the content between the markers. Content outside the markers remains untouched.

To configure a region, add an entry to knowledge.okf.regions:

OptionTypeDefaultMeaning
idstringnoneUnique region identifier matching marker comments
filestringnonePath to markdown file relative to bundle
rendererstringrequiredIdentifier of renderer generating region content

The renderer key is required. A region without one is dropped silently. A region's renderer need not be listed in knowledge.okf.renderers. An id not listed in knowledge.okf.renderers must be a built-in renderer, otherwise gen fails. okf runs unlisted built-in renderers with empty options.

If the region's file does not exist, gen prints:

text
gen: skipped region '<id>' - <file> does not exist yet

Each region uses HTML comment markers:

md
<!-- okf:generated:<id> start -->
Managed content here.
<!-- okf:generated:<id> end -->

The region identifier must match the marker comment. For example, the packages-table region uses these markers:

md
<!-- okf:generated:packages-table start -->
<!-- okf:generated:packages-table end -->

If markers are malformed, okf halts with an error:

  • Missing markers: a region is missing its markers (okf: <file>: managed region '<id>' is missing its markers - add <start> and <end>).
  • Duplicate start marker: okf: <file>: managed region '<id>' is malformed - a duplicate start marker.
  • Duplicate end marker: okf: <file>: managed region '<id>' is malformed - a duplicate end marker.
  • Reversed markers: okf: <file>: managed region '<id>' is malformed - the end marker precedes the start marker.
  • Reserved identifier: okf: region id 'contents' is reserved for the contents list okf writes - rename the region.

If a region names a renderer without a region method, gen halts with an error:

text
okf: region '<id>' names renderer '<renderer>', which renders no region

Coverage axes ​

Setting knowledge.okf.coverage defines structural coverage axes for your codebase. Each axis verifies that source directories have corresponding concept documents in the bundle.

OptionTypeDefaultMeaning
namestringnoneAxis name and target concept subfolder
pathstringnoneGlob pattern matching source directories from repository root
excludestring[][]Glob patterns from repository root dropped from this axis
denyliststring[][]Directory base names dropped from this axis only

A directory item is covered when either condition holds:

  • A concept exists at /<name>/<directory>.md.
  • Any concept declares the item directory in its frontmatter resource: property.

An axis must match at least one directory. If path matches no directory, okf reports a problem:

text
coverage: axis '<name>' (<path>) matches no directory

If exclusions or denylists remove all matched directories, okf also reports a problem:

text
coverage: axis '<name>' (<path>) has no directory left after exclude/denylist

To inspect coverage, run vulcan okf coverage:

text
$ bun node_modules/.bin/vulcan okf coverage

COVERAGE - 2 curated concepts

STRUCTURAL  (target 100% - one curated concept each)

REFERENCE  (advisory - generated)
  make targets    14      generated

KNOWLEDGE TYPES  (Diátaxis / arc42)
  Reference:1  Concept:1
  how-to (Playbook) 0  (target >= 1)  <- gap
  tutorial 0  (target 1)  <- gap
  glossary 0  (target 1)  <- gap

structural: 0/0  100%

The shown outputs come from a project with only makefile-targets configured and no coverage axes. Structural gaps fail under vulcan okf check --strict.

Contents lists ​

okf generates table of contents blocks for long agent-read documents. This gives agents a quick overview of headings when inspecting files partially.

OptionTypeDefaultMeaning
filesstring[]['AGENTS.md', '.agents/rules.md']File paths or globs relative to repository root

The contents.files array accepts exact paths and glob patterns relative to the repository root. A pattern is recognised as a glob if it contains one of * ? [ ] { }. Listed files that do not exist are skipped silently.

okf counts lines using the newline convention of wc -l. When a file exceeds 100 lines and contains ## headings, okf inserts a contents list of its ## headings. A file with no ## headings gets no list even over 100 lines. When a file contains 100 lines or fewer, okf writes no contents list and removes existing contents markers.

okf checks curated bundle markdown files and configured contents.files. The skip rules (log.md, generated: files, renderer-owned pages) apply to bundle files only, not to contents.files entries.

okf places the contents list immediately after frontmatter and the # document title:

md
<!-- okf:generated:contents start -->
**Contents**

- [First heading](#first-heading)
- [Second heading](#second-heading)
<!-- okf:generated:contents end -->

Under vulcan okf check --strict, missing or stale contents lists fail verification.

brand ​

knowledge.okf.brand is how the project's name is written in prose. When it is all capitals of two letters or more, okf check --strict flags its title-case spelling, and lifted package.json descriptions take the brand spelling.

If you omit it, okf derives the brand from the root package.json: it strips the npm scope and a -workspace suffix, then upper-cases the result. The brand falls back to the directory name when package.json has no name.

ts
import type { VulcanConfig } from '@venizia/vulcan';

export default {
  knowledge: {
    okf: { brand: 'VULCAN' },
  },
} satisfies VulcanConfig;

See also ​