Skip to main content

Module summary

Module summary 

Source
Expand description

summary — the deterministic default-summary composer.

Used by dbmd fm init and dbmd write when the agent doesn’t supply a summary. compose_default renders the type’s summary_template (from the store’s DB.md ## Schemas) when one is declared, and otherwise falls back to the body’s first non-heading paragraph. No type carries a built-in template — the template, like the schema, is the store’s to declare.

Contract: deterministic (same (type, frontmatter, body) → same string), single-line (newlines collapsed to spaces), and capped at 200 chars (the SPEC readability bound). The tool generates a deterministic floor; the agent provides the ceiling via dbmd fm set <file> summary='…'.

Constants§

MAX_SUMMARY_LEN
The SPEC’s summary length bound, in characters.

Functions§

compose_default
Compose a deterministic default summary for a file from its type, frontmatter, and body. If the store’s ## Schemas declares a summary_template for the type, it is rendered with {field} interpolation; otherwise the default is the body’s first non-heading paragraph. The result is always single-line and ≤ MAX_SUMMARY_LEN chars.
compose_from_body
The body fallback: the file’s first non-heading paragraph, truncated to MAX_SUMMARY_LEN chars (the truncation is applied by normalize).
normalize
Normalize any candidate summary to the contract: collapse runs of whitespace (including newlines) to single spaces, trim, and truncate to MAX_SUMMARY_LEN chars (never splitting a UTF-8 codepoint). Every composer runs its output through this.