Skip to content

EMBED-AND-CI-10: Map findings to editor diagnostics

Translating positioned Findings into editor diagnostics via Finding.pos and level.

Builds on: EMBED-AND-CI-02: Scope a subtree with cwd and globs

A TypeScript program against the library API; inline comments show the resulting values and behavior.

const { findings } = runCorpus(config, { cwd: workspaceRoot });
const diagnostics = findings.map((f) => ({
uri: f.path,
line: (f.pos?.line ?? 1) - 1, // editors are 0-based; whole-doc findings have no pos
col: (f.pos?.col ?? 1) - 1,
severity: f.level, // "error" | "warn" | "report"
source: f.id,
message: f.message,
}));
  • runCorpus findings
  • Finding.pos {line, col}
  • level/id/path/message for diagnostics