import type { ItemType } from '../types/findings.js'; import type { SignalRepair } from '@opensip-cli/core'; /** Type alias for a kebab-case check slug string. */ type CheckSlug = string; /** * Resolved scope with concrete glob patterns for file matching. * Produced by resolving a CheckScope against targets configuration. */ export interface ResolvedScope { readonly include: readonly string[]; readonly exclude: readonly string[]; readonly description: string; } /** * Semantic concern describing what kind of code a check targets. * Used for automatic target matching: a check with `concerns: ['backend']` * matches any target that declares `concerns: ['backend', ...]`. */ export type CheckConcern = string; /** * Language a check is designed for. Used for automatic target matching: * a check with `languages: ['typescript']` matches any target with * `languages: ['typescript', ...]`. */ export type CheckLanguage = string; /** * Portable scope declaration for a fitness check. * * Instead of referencing project-specific target names, checks declare * what kind of code they analyze. The platform matches this intent * against project targets automatically. * * @example * ```typescript * scope: { * languages: ['typescript'], * concerns: ['backend', 'server'], * } * ``` */ export interface CheckScope { /** File type affinity — which languages this check analyzes. */ readonly languages: readonly CheckLanguage[]; /** Semantic hints — what kind of code this check targets. */ readonly concerns: readonly CheckConcern[]; } /** * Violation returned by check authors. * This is the simplified shape - the framework converts it to a Signal. */ export interface CheckViolation { readonly line: number; readonly column?: number; readonly message: string; readonly severity: 'error' | 'warning'; readonly suggestion?: string; readonly match?: string; readonly type?: string; readonly filePath?: string; /** Structured repair guidance (ADR-0086). Prefer this over legacy fix hints. */ readonly repair?: SignalRepair; readonly fix?: { readonly action: 'replace' | 'insert' | 'delete' | 'refactor' | 'configure' | 'investigate'; readonly replacement?: string; readonly confidence: number; }; } /** * Lazy-loading file accessor for analyzeAll mode. */ export interface FileAccessor { /** List of matched file paths */ readonly paths: readonly string[]; /** Read a single file on demand (cached after first read) */ read(filePath: string): Promise; /** Read multiple files in batch */ readMany(filePaths: readonly string[]): Promise>; /** Read all matched files */ readAll(): Promise>; } /** Configuration for an external command-based check. */ export interface CommandConfig { readonly bin: string; readonly args: readonly string[] | ((files: readonly string[]) => readonly string[]); parseOutput(stdout: string, stderr: string, exitCode: number, files: readonly string[], cwd: string): CheckViolation[]; readonly expectedExitCodes?: readonly number[]; } /** Common configuration fields shared by all check types. */ interface BaseCheckConfig { readonly id: string; readonly slug: CheckSlug; readonly description: string; readonly longDescription?: string; readonly tags: readonly string[]; readonly docs?: string; readonly timeout?: number; readonly disabled?: boolean; readonly fileTypes?: readonly string[]; /** Signal provider name for external tool checks (default: 'opensip') */ readonly provider?: string; /** The type of items this check validates (default: 'files'). Used for display in results table. */ readonly itemType?: ItemType; /** Portable scope declaration for marketplace-ready target matching. */ readonly scope?: CheckScope; /** * Content filtering mode for the analyze() function. Names describe * what the filter strips so rule authors don't have to guess at intent. * * - 'raw' (default): Full file content, unchanged. Use for checks that * need to analyze string content (e.g., hardcoded secrets, PII detection). * - 'strip-strings': String literals replaced with whitespace, * preserving line/column positions. COMMENTS PRESERVED — use when * the check reads comment-based directives like the deprecation * marker, the swallow-ok marker, or `// @fitness-ignore-...` (we * don't reference those tag names verbatim in this JSDoc to avoid * confusing static analyzers). * - 'strip-strings-and-comments': BOTH string literals and comments * replaced with whitespace, preserving line/column positions. Use * for checks that pattern-match identifiers via regex and would * false-positive on the same banned phrase appearing in JSDoc / * line / block comments documenting the rule itself. */ readonly contentFilter?: 'raw' | 'strip-strings' | 'strip-strings-and-comments'; /** * Confidence level of this check's findings. Consumers of opensip-cli * signals (via --report-to) use this to decide how aggressively to act * on findings; this package treats it as pure metadata. * * - 'high': AST-based or structurally guaranteed no false positives. * - 'medium': Regex with context filtering — some false positives expected. * - 'low': Naive regex or heuristic — surfaced in reports but easily noisy. * * Default: 'medium' (applied at runtime, not in schema). */ readonly confidence?: 'high' | 'medium' | 'low'; /** * Display icon (emoji) for CLI/dashboard output. Optional — display travels * WITH the check (§5.3 fold), so authors (or a pack's display map applied via * {@link applyCheckDisplay}) set it here rather than in a separate sidecar. */ readonly icon?: string; /** Human-readable display name for CLI/dashboard output. Optional (slug fallback). */ readonly displayName?: string; } /** Check config with per-file analysis mode. */ export interface AnalyzeCheckConfig extends BaseCheckConfig { analyze(content: string, filePath: string): CheckViolation[]; } /** Check config with multi-file analysis mode using FileAccessor. */ export interface AnalyzeAllCheckConfig extends BaseCheckConfig { analyzeAll(files: FileAccessor): Promise; } /** Check config with external command execution mode. */ export interface CommandCheckConfig extends BaseCheckConfig { command: CommandConfig; } /** Union of all check configuration types (analyze, analyzeAll, command). */ export type UnifiedCheckConfig = AnalyzeCheckConfig | AnalyzeAllCheckConfig | CommandCheckConfig; /** Validate and parse a check configuration, throwing on invalid input. */ export declare function validateCheckConfig(config: unknown): UnifiedCheckConfig; /** Type guard for per-file analyze mode checks. */ export declare function isAnalyzeConfig(config: UnifiedCheckConfig): config is AnalyzeCheckConfig; /** Type guard for multi-file analyzeAll mode checks. */ export declare function isAnalyzeAllConfig(config: UnifiedCheckConfig): config is AnalyzeAllCheckConfig; /** Type guard for external command mode checks. */ export declare function isCommandConfig(config: UnifiedCheckConfig): config is CommandCheckConfig; /** Determine which analysis mode a check config uses. */ export declare function getAnalysisMode(config: UnifiedCheckConfig): 'analyze' | 'analyzeAll' | 'command'; export {}; //# sourceMappingURL=check-config.d.ts.map