presenters

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package presenters renders structured query results as text for CLI output. Presenters take pure data from finders plus an io.Writer and formatting parameters; they have no IO of their own beyond the writer.

The package isolates the view layer from finders (data) and from CLI command plumbing — separating concerns so each can be tested in isolation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EntryLine

func EntryLine(w io.Writer, e *model.Entry, g *model.Graph)

EntryLine writes a single entry summary line — used by status, list, and other surfaces that show entries in a flat list.

Format: `<id> <layer> <kind>? <type> [confidence: <conf>]? (<participants>) {status: <status>}? <summary>` Kind renders as a qualifier alongside layer/type — it's identity, not an attribute (d-cpt-omm's two-type redesign makes every entry carry a kind). Square brackets denote stored attributes (today: confidence); curly braces denote derived attributes computed from graph relationships (d-tac-3yi). Participants are always present — empty is rendered as `()`. Status is present for signals and decisions; omitted for actions.

func FormatConfidence

func FormatConfidence(c string) string

FormatConfidence renders a stored confidence attribute in square-bracket notation.

func FormatSearchCapability added in v0.4.0

func FormatSearchCapability(vectorAvailable bool) string

FormatSearchCapability renders the capability suffix shown in `sdd status`'s header: `text` when only text mode is available; `vector,text` when a vector embedder is configured. Used by callers that want to surface the search surface alongside other status fields.

func FormatStatus

func FormatStatus(s model.Status) string

FormatStatus renders a derived status in curly-brace notation. Returns the empty string for StatusNone so callers can omit the attribute. Compound states use a space separator in the value (`closed-by <id>`) to avoid ambiguity with the outer `{key: value}` delimiter.

func GroupByLayer

func GroupByLayer(entries []*model.Entry) map[model.Layer][]*model.Entry

GroupByLayer groups entries by layer for display. Returns a map from layer to entries; iterate with LayerOrder to render in canonical order.

func LayerOrder

func LayerOrder() []model.Layer

LayerOrder returns the display order for layers (strategic → process).

func RenderInitSkills added in v0.2.0

func RenderInitSkills(w io.Writer, installDir string, result command.SkillInstallResult)

RenderInitSkills summarises a skill install pass for the user. Counts are always printed; individual paths appear only for categories that warrant per-path attention (overwritten, skipped-modified).

func RenderLint

func RenderLint(w io.Writer, result *query.LintResult, g *model.Graph)

RenderLint writes a human-readable lint report to w. Returns nothing — the caller decides what to do about a non-zero issue count (typically returning a non-zero exit code from the CLI).

func RenderList

func RenderList(w io.Writer, result *query.ListResult)

RenderList writes one EntryLine per matched entry.

func RenderSchemaError added in v0.2.0

func RenderSchemaError(w io.Writer, compat model.CompatibilityResult)

RenderSchemaError writes a user-facing explanation of a compatibility failure to w. The CompatibilityResult.Reason is already human-readable; this presenter frames it with a fixed prefix and exit hint so output reads the same across every write command.

func RenderSearch added in v0.4.0

func RenderSearch(w io.Writer, result *query.SearchResult, g *model.Graph)

RenderSearch writes one section per ranked entry: a header line that matches `sdd list` shape, then one citation line per entry-citation (capped by SearchQuery.MaxCitationsPerEntry on the finder side).

Render format (single-citation case):

<id> <layer> <kind>? <type> [confidence: ?]? (<participants>) {status: ?}? <summary>
  ↳ 100%  ·  Breadcrumb > Chain  ·  <snippet>

Render format (multi-citation case):

<id> ...
  ↳ 100%  ·  Summary  ·  <snippet>
  ↳  91%  ·  Approach > Storage  ·  <snippet>
  ↳  87%  ·  ... [attachment: ...]  ·  <snippet>

The percentage is each citation's score normalized against the strongest score in the result set — the top citation everywhere renders 100%, others scale relative. This is honest about the cross- entry ranking without making any claims about absolute "confidence" (cosine values aren't calibrated across embedders, and text-mode match counts and hybrid RRF scores live on different scales than cosine — but ALL citations within a single result set share whatever scale the active mode uses).

func RenderShow

func RenderShow(w io.Writer, result *query.ShowResult)

RenderShow writes the show output for a ShowResult. Each group renders: the primary entry at full detail, then an upstream section (summary lines), then a downstream section (summary lines). Groups are separated by "---".

func RenderStatus

func RenderStatus(w io.Writer, result *query.StatusResult)

RenderStatus writes the status view: top-line counts, then one section per decision kind (Aspirations, Contracts, Plans, Activities, Directives), followed by the signal sections (Gaps and Questions, Recent Insights, Recent Done Signals). Decision-kind sections are grouped by layer; signal sections are flat activity streams. Empty sections are suppressed — the section header implies membership, so "open" / "active" prefixes are not needed on the headers.

func RenderWIPList

func RenderWIPList(w io.Writer, result *query.WIPListResult)

RenderWIPList writes the active WIP markers in a fixed-width layout.

func WriteEntryFull

func WriteEntryFull(w io.Writer, e *model.Entry, graph *model.Graph)

WriteEntryFull writes the full metadata and content of an entry. Stored frontmatter fields render first, then a "Derived:" section lists attributes computed from graph relationships (d-tac-3yi). The curly-brace inline notation (`{status: ...}`) is reserved for flat contexts like status, list, and summary chains — the labeled block here keeps the stored/derived split explicit without redundant wrapping.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL