/** * Severity of a sanity finding. * * - `error` blocks the commit (czar exits non-zero). * - `warning` is reported but doesn't fail the commit. * * A plugin may return both: e.g. the env-file plugin treats a tracked * `.env` as `error` but a stray `.env.preview` as `warning`. */ export type SanitySeverity = 'error' | 'warning'; export interface SanityFinding { readonly severity: SanitySeverity; /** Stable check id — used in summaries and (eventually) suppression flags. */ readonly check: string; readonly file?: string; readonly message: string; } /** * Per-plugin summary surfaced in the `sanity` section of czar's header * block. The verbose findings list (errors / warnings with file paths) * is still rendered separately whenever there are any. * * - `passed` the green ✓ / red ✗ indicator next to the plugin name. * - `message` optional one-line note shown after the indicator (use * for context that isn't a finding — e.g. * `envx-audit: scanning 3 files under vault/`). */ export interface SanitySummary { readonly passed: boolean; readonly message?: string; } /** * Read-only snapshot handed to every plugin. The orchestrator walks * staged files once and exposes lazy content / size accessors so plugins * only pay for the files they actually inspect — no quadratic re-reads * when several plugins want the same file. */ export interface SanityPluginContext { /** Working directory the staged-file resolution started from. */ readonly cwd: string; /** Every git-staged file (post-skip-paths filter, ACMR diff filter). */ readonly stagedFiles: ReadonlyArray; /** * Return the staged content (post-stage, pre-commit) of `file`. Cached * per-context, so multiple plugins reading the same file pay one git-show. */ readFileContent(file: string): Promise; /** * Return the staged size of `file` in bytes. Cached per-context. */ readFileSize(file: string): Promise; } /** * A czar sanity plugin. Plugins inspect the staged change-set and * report findings; they don't mutate the git index or commit message. * * Plugins are pure dispatchers — `run` should be idempotent and safe * to call from a hot path. Network calls and subprocess spawns are * fine but should be gated behind explicit user opt-in (and respect * the existing `enabled` flag). */ export interface SanityPlugin { /** Stable plugin name. Used in finding summaries and CLI output. */ readonly name: string; /** One-line description shown in `czar --list-plugins` (future). */ readonly description?: string; /** Run the check. Returning an array (sync) is fine — Promise<…> is also fine. */ run(ctx: SanityPluginContext): Promise> | ReadonlyArray; /** * Optional header summary. Returns the true/false indicator that * appears in the `sanity` section of czar's status block, plus an * optional one-line message. When omitted, czar derives a default: * `passed = no findings with severity 'error'`, no custom message. * * Called *after* `run()` so the plugin can base its summary on the * findings it produced (or on independent context — e.g. an envx * plugin can report `scanning with 3 .env files` * regardless of whether anything was flagged). */ summarize?(ctx: SanityPluginContext, findings: ReadonlyArray): Promise | SanitySummary; } //# sourceMappingURL=types.d.ts.map