Skip to content

CLI / MCP have no custom output formatter or template plugin mechanism #1941

Description

@Widthdom

Summary

Output for cdidx CLI / MCP commands is fixed: plain text (default), --json (rigid schema), and a handful of human-readable formats. There is no template / custom formatter mechanism: a user cannot say "render search results as CSV", "produce a SARIF report from unused", "format hotspots as a markdown table for a PR comment", or "emit Prometheus-style metric lines from status" without piping through jq and re-serializing. For integrators, the JSON schema is sometimes too narrow (only the documented fields) and sometimes too wide (every nullable metadata column), with no middle ground.

Where

Suggested approach

(1) Define IOutputFormatter { string Format(IReadOnlyList<object> rows, FormatterContext ctx); } with built-in implementations for json, plaintext, tsv, csv. (2) Add --format <name> CLI flag and format MCP tool argument; default remains current behaviour. (3) Allow template-based formatters via .cdidx/formatters/*.tmpl using Scriban or a similarly safe templating engine — no arbitrary code execution. (4) Discover custom formatter DLLs via the same plugin mechanism as C591. (5) Document each built-in DTO as a formatter-accessible variable schema. (6) Cross-link with #1808, C555, C591, C595.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions