@doccov/sdk 0.22.1 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,691 @@
1
+ /**
2
+ * Pre-detected Standard Schema for a variable export.
3
+ */
4
+ interface DetectedSchemaEntry {
5
+ schema: Record<string, unknown>;
6
+ vendor: string;
7
+ }
8
+ /**
9
+ * All possible drift type identifiers.
10
+ */
11
+ type DriftType = "param-mismatch" | "param-type-mismatch" | "return-type-mismatch" | "generic-constraint-mismatch" | "optionality-mismatch" | "deprecated-mismatch" | "visibility-mismatch" | "async-mismatch" | "property-type-drift" | "example-drift" | "example-syntax-error" | "example-runtime-error" | "example-assertion-failed" | "broken-link";
12
+ type SpecDocDrift = {
13
+ type: DriftType;
14
+ target?: string;
15
+ issue: string;
16
+ suggestion?: string;
17
+ };
18
+ /**
19
+ * Drift categories group related drift types for progressive disclosure.
20
+ */
21
+ type DriftCategory = "structural" | "semantic" | "example";
22
+ type SpecDocsMetadata = {
23
+ coverageScore?: number;
24
+ missing?: string[];
25
+ drift?: SpecDocDrift[];
26
+ };
27
+ /**
28
+ * Result of computing drift for a single export.
29
+ */
30
+ type ExportDriftResult = {
31
+ id: string;
32
+ drift: SpecDocDrift[];
33
+ };
34
+ /**
35
+ * Result of computing drift for all exports.
36
+ */
37
+ type DriftResult = {
38
+ exports: Map<string, SpecDocDrift[]>;
39
+ };
40
+ /**
41
+ * Information about an for context-aware suggestions.
42
+ */
43
+ interface ExportInfo {
44
+ name: string;
45
+ kind: string;
46
+ isCallable: boolean;
47
+ }
48
+ /**
49
+ * Registry of exports and types for cross-reference validation.
50
+ */
51
+ interface ExportRegistry {
52
+ /** Map of names to their info (for context-aware suggestions) */
53
+ exports: Map<string, ExportInfo>;
54
+ /** Set of type names (interfaces, type aliases, etc.) */
55
+ types: Set<string>;
56
+ /** Combined set of all names (for backward compatibility) */
57
+ all: Set<string>;
58
+ }
59
+ /**
60
+ * Extended drift with category and fixability metadata.
61
+ */
62
+ interface CategorizedDrift extends SpecDocDrift {
63
+ category: DriftCategory;
64
+ fixable: boolean;
65
+ }
66
+ /**
67
+ * Summary of drift issues by category.
68
+ */
69
+ interface DriftSummary {
70
+ total: number;
71
+ byCategory: Record<DriftCategory, number>;
72
+ fixable: number;
73
+ }
74
+ /**
75
+ * Categorize a single drift issue.
76
+ *
77
+ * @param drift - The drift to categorize
78
+ * @returns The drift with category and fixable metadata
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * const drift: SpecDocDrift = {
83
+ * type: 'param-type-mismatch',
84
+ * target: 'userId',
85
+ * issue: 'Type mismatch'
86
+ * };
87
+ * const categorized = categorizeDrift(drift);
88
+ * console.log(categorized.category); // => 'structural'
89
+ * console.log(categorized.fixable); // => true
90
+ * ```
91
+ */
92
+ declare function categorizeDrift(drift: SpecDocDrift): CategorizedDrift;
93
+ /**
94
+ * Group drifts by category.
95
+ *
96
+ * @param drifts - Array of drift issues to group
97
+ * @returns Drifts organized by category
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const grouped = groupDriftsByCategory(spec.docs.drift ?? []);
102
+ * console.log(grouped.structural.length); // Number of structural issues
103
+ * console.log(grouped.semantic.length); // Number of semantic issues
104
+ * console.log(grouped.example.length); // Number of example issues
105
+ * ```
106
+ */
107
+ declare function groupDriftsByCategory(drifts: SpecDocDrift[]): Record<DriftCategory, CategorizedDrift[]>;
108
+ /**
109
+ * Get drift summary counts by category.
110
+ *
111
+ * @param drifts - Array of drift issues
112
+ * @returns Summary with totals, category breakdown, and fixable count
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * const summary = getDriftSummary(exportEntry.docs?.drift ?? []);
117
+ * console.log(`${summary.total} issues: ${summary.fixable} fixable`);
118
+ * // => "5 issues: 3 fixable"
119
+ * ```
120
+ */
121
+ declare function getDriftSummary(drifts: SpecDocDrift[]): DriftSummary;
122
+ /**
123
+ * Format drift summary for CLI output (single line).
124
+ *
125
+ * @param summary - Drift summary to format
126
+ * @returns Human-readable summary string
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const summary = getDriftSummary(drifts);
131
+ * console.log(formatDriftSummaryLine(summary));
132
+ * // => "5 issues (3 structural, 1 semantic, 1 example)"
133
+ * ```
134
+ */
135
+ declare function formatDriftSummaryLine(summary: DriftSummary): string;
136
+ import { SpecExport } from "@openpkg-ts/spec";
137
+ import { OpenPkg } from "@openpkg-ts/spec";
138
+ type OpenPkgSpec = OpenPkg;
139
+ /**
140
+ * Build a registry of all export/type names for cross-reference validation.
141
+ */
142
+ declare function buildExportRegistry(spec: OpenPkgSpec): ExportRegistry;
143
+ /**
144
+ * Compute drift for all exports in a spec.
145
+ *
146
+ * @param spec - The OpenPkg spec to analyze
147
+ * @returns Drift results per */
148
+ declare function computeDrift(spec: OpenPkgSpec): DriftResult;
149
+ /**
150
+ * Compute drift for a single export.
151
+ *
152
+ * @param entry - The to analyze
153
+ * @param registry - Registry of known exports and types for validation
154
+ * @returns Array of drift issues detected
155
+ */
156
+ declare function computeExportDrift(entry: SpecExport, registry?: ExportRegistry): SpecDocDrift[];
157
+ /**
158
+ * Calculate aggregate coverage score from a spec's exports.
159
+ *
160
+ * This is a lightweight function that calculates coverage without
161
+ * requiring full quality evaluation. It handles three cases:
162
+ * 1. Exports with `docs.coverageScore` - uses that value
163
+ * 2. Exports without score but with description - counts as 100%
164
+ * 3. Exports without score and no description - counts as 0%
165
+ *
166
+ * @param spec - The OpenPkg spec to calculate coverage for
167
+ * @returns The aggregate coverage score (0-100)
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * import { calculateAggregateCoverage } from '@doccov/sdk';
172
+ *
173
+ * const coverage = calculateAggregateCoverage(spec);
174
+ * console.log(`Coverage: ${coverage}%`);
175
+ * ```
176
+ */
177
+ declare function calculateAggregateCoverage(spec: OpenPkgSpec): number;
178
+ /**
179
+ * Ensure a spec has a top-level docs.coverageScore.
180
+ *
181
+ * If the spec already has `docs.coverageScore`, returns the spec unchanged.
182
+ * Otherwise, calculates aggregate coverage from exports and returns a
183
+ * new spec with the coverage score added.
184
+ *
185
+ * This is useful for commands like `diff` that need coverage scores
186
+ * but may receive raw specs that haven't been enriched.
187
+ *
188
+ * @param spec - The OpenPkg spec to ensure coverage for
189
+ * @returns The spec with guaranteed top-level coverage score
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * import { ensureSpecCoverage } from '@doccov/sdk';
194
+ *
195
+ * // Works with raw or enriched specs
196
+ * const specWithCoverage = ensureSpecCoverage(rawSpec);
197
+ * console.log(specWithCoverage.docs?.coverageScore); // e.g., 85
198
+ * ```
199
+ */
200
+ declare function ensureSpecCoverage(spec: OpenPkgSpec): OpenPkgSpec & {
201
+ docs: {
202
+ coverageScore: number;
203
+ };
204
+ };
205
+ import { SpecExport as SpecExport2 } from "@openpkg-ts/spec";
206
+ interface ExampleRunResult {
207
+ success: boolean;
208
+ stdout: string;
209
+ stderr: string;
210
+ exitCode: number;
211
+ duration: number;
212
+ }
213
+ /**
214
+ * Detect runtime errors in @example blocks.
215
+ * Results are provided externally after running examples via runExamples().
216
+ */
217
+ declare function detectExampleRuntimeErrors(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift[];
218
+ /**
219
+ * Parse assertion comments from example code.
220
+ * Matches: // => expected_value
221
+ */
222
+ declare function parseAssertions(code: string): Array<{
223
+ lineNumber: number;
224
+ expected: string;
225
+ }>;
226
+ /**
227
+ * Check if code contains comments that are not assertion syntax.
228
+ * Used to determine if LLM fallback should be attempted.
229
+ */
230
+ declare function hasNonAssertionComments(code: string): boolean;
231
+ /**
232
+ * Detect assertion failures by comparing stdout to expected values.
233
+ */
234
+ declare function detectExampleAssertionFailures(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift[];
235
+ import { OpenPkg as OpenPkg2, SpecExport as SpecExport7 } from "@openpkg-ts/spec";
236
+ /**
237
+ * An enriched with computed documentation metadata.
238
+ * Extends SpecExport with the `docs` field for coverage analysis.
239
+ */
240
+ type EnrichedExport = SpecExport7 & {
241
+ docs?: EnrichedDocsMetadata;
242
+ };
243
+ /**
244
+ * Extended docs metadata.
245
+ */
246
+ type EnrichedDocsMetadata = SpecDocsMetadata;
247
+ /**
248
+ * An enriched OpenPkg spec with computed documentation metadata.
249
+ * Extends OpenPkg with per-and aggregate coverage data.
250
+ */
251
+ type EnrichedOpenPkg = Omit<OpenPkg2, "exports"> & {
252
+ exports: EnrichedExport[];
253
+ docs?: EnrichedDocsMetadata;
254
+ /** Drift summary with category breakdown (if drift exists) */
255
+ driftSummary?: DriftSummary;
256
+ };
257
+ interface EnrichOptions {
258
+ /**
259
+ * Per-drift issues to include in enrichment.
260
+ * Map from ID to drift issues.
261
+ */
262
+ driftByExport?: Map<string, SpecDocDrift[]>;
263
+ }
264
+ /**
265
+ * Enrich an OpenPkg spec with documentation coverage metadata.
266
+ *
267
+ * Computes coverage scores and detects drift issues.
268
+ *
269
+ * @param spec - The pure OpenPkg spec to enrich
270
+ * @param options - Optional enrichment configuration
271
+ * @returns An enriched spec with documentation metadata
272
+ *
273
+ * @example
274
+ * ```ts
275
+ * import { DocCov, enrichSpec } from '@doccov/sdk';
276
+ *
277
+ * const doccov = new DocCov();
278
+ * const { spec } = await doccov.analyzeFileWithDiagnostics('src/index.ts');
279
+ *
280
+ * const enriched = enrichSpec(spec);
281
+ * console.log(enriched.docs?.coverageScore); // e.g., 85
282
+ * ```
283
+ */
284
+ declare function enrichSpec(spec: OpenPkg2, options?: EnrichOptions): EnrichedOpenPkg;
285
+ import { SpecDiff } from "@openpkg-ts/spec";
286
+ /**
287
+ * Extended diff result with doccov-specific coverage tracking.
288
+ */
289
+ interface EnrichedSpecDiff extends SpecDiff {
290
+ coverageDelta: number;
291
+ oldCoverage: number;
292
+ newCoverage: number;
293
+ newUndocumented: string[];
294
+ improvedExports: string[];
295
+ regressedExports: string[];
296
+ driftIntroduced: number;
297
+ driftResolved: number;
298
+ }
299
+ type ExportWithDocs = EnrichedExport & {
300
+ docs?: SpecDocsMetadata;
301
+ };
302
+ type SpecWithDocs = EnrichedOpenPkg & {
303
+ docs?: SpecDocsMetadata;
304
+ exports: ExportWithDocs[];
305
+ };
306
+ /**
307
+ * Compare two enriched OpenPkg specs with coverage tracking.
308
+ */
309
+ declare function diffEnrichedSpec(oldSpec: SpecWithDocs, newSpec: SpecWithDocs): EnrichedSpecDiff;
310
+ import { OpenPkg as OpenPkg3 } from "@openpkg-ts/spec";
311
+ /** Directory for storing history snapshots */
312
+ declare const HISTORY_DIR = ".doccov/history";
313
+ /**
314
+ * A historical coverage snapshot.
315
+ */
316
+ interface CoverageSnapshot {
317
+ /** ISO 8601 timestamp */
318
+ timestamp: string;
319
+ /** Package name */
320
+ package: string;
321
+ /** Package version (if available) */
322
+ version?: string;
323
+ /** Coverage score (0-100) */
324
+ coverageScore: number;
325
+ /** Total number of exports */
326
+ totalExports: number;
327
+ /** Number of documented exports */
328
+ documentedExports: number;
329
+ /** Number of drift issues */
330
+ driftCount: number;
331
+ /** Git commit hash (if available) */
332
+ commit?: string;
333
+ /** Git branch (if available) */
334
+ branch?: string;
335
+ }
336
+ /**
337
+ * Coverage trend data.
338
+ */
339
+ interface CoverageTrend {
340
+ /** Current snapshot */
341
+ current: CoverageSnapshot;
342
+ /** Previous snapshots (most recent first) */
343
+ history: CoverageSnapshot[];
344
+ /** Score delta from previous */
345
+ delta?: number;
346
+ /** Sparkline data (last N scores) */
347
+ sparkline: number[];
348
+ }
349
+ /**
350
+ * Tier-based retention settings.
351
+ */
352
+ type RetentionTier = "free" | "team" | "pro";
353
+ /**
354
+ * Retention days per tier.
355
+ */
356
+ declare const RETENTION_DAYS: Record<RetentionTier, number>;
357
+ /**
358
+ * Weekly summary of coverage data.
359
+ */
360
+ interface WeeklySummary {
361
+ /** Week start date (ISO string) */
362
+ weekStart: string;
363
+ /** Week end date (ISO string) */
364
+ weekEnd: string;
365
+ /** Average coverage for the week */
366
+ avgCoverage: number;
367
+ /** Coverage at start of week */
368
+ startCoverage: number;
369
+ /** Coverage at end of week */
370
+ endCoverage: number;
371
+ /** Change during the week */
372
+ delta: number;
373
+ /** Number of snapshots in the week */
374
+ snapshotCount: number;
375
+ }
376
+ /**
377
+ * Extended trend analysis result.
378
+ */
379
+ interface ExtendedTrendAnalysis {
380
+ /** Current trend data */
381
+ trend: CoverageTrend;
382
+ /** Weekly summaries (most recent first) */
383
+ weeklySummaries: WeeklySummary[];
384
+ /** 7-day velocity (average daily change) */
385
+ velocity7d: number;
386
+ /** 30-day velocity */
387
+ velocity30d: number;
388
+ /** 90-day velocity (Pro only) */
389
+ velocity90d?: number;
390
+ /** Projected coverage in 30 days (based on velocity) */
391
+ projected30d: number;
392
+ /** Best coverage ever recorded */
393
+ allTimeHigh: number;
394
+ /** Worst coverage ever recorded */
395
+ allTimeLow: number;
396
+ /** Date range of available data */
397
+ dataRange: {
398
+ start: string;
399
+ end: string;
400
+ } | null;
401
+ }
402
+ /**
403
+ * Compute a coverage snapshot from an OpenPkg spec.
404
+ */
405
+ declare function computeSnapshot(spec: OpenPkg3, options?: {
406
+ commit?: string;
407
+ branch?: string;
408
+ }): CoverageSnapshot;
409
+ /**
410
+ * Save a coverage snapshot to history.
411
+ *
412
+ * @param snapshot - The snapshot to save
413
+ * @param cwd - Working directory
414
+ */
415
+ declare function saveSnapshot(snapshot: CoverageSnapshot, cwd: string): void;
416
+ /**
417
+ * Load all historical snapshots.
418
+ *
419
+ * @param cwd - Working directory
420
+ * @returns Array of snapshots sorted by timestamp (most recent first)
421
+ */
422
+ declare function loadSnapshots(cwd: string): CoverageSnapshot[];
423
+ /**
424
+ * Get coverage trend data.
425
+ *
426
+ * @param spec - Current OpenPkg spec
427
+ * @param cwd - Working directory
428
+ * @param options - Optional git metadata
429
+ * @returns Trend data with history and delta
430
+ */
431
+ declare function getTrend(spec: OpenPkg3, cwd: string, options?: {
432
+ commit?: string;
433
+ branch?: string;
434
+ }): CoverageTrend;
435
+ /**
436
+ * Generate a sparkline character representation.
437
+ *
438
+ * @param values - Array of values (0-100 for coverage)
439
+ * @returns Sparkline string using unicode characters
440
+ */
441
+ declare function renderSparkline(values: number[]): string;
442
+ /**
443
+ * Format a delta value with arrow and color indicator.
444
+ *
445
+ * @param delta - Coverage delta (positive = improvement)
446
+ * @returns Formatted delta string
447
+ */
448
+ declare function formatDelta(delta: number): string;
449
+ /**
450
+ * Prune old snapshots to keep history manageable.
451
+ *
452
+ * @param cwd - Working directory
453
+ * @param keepCount - Number of snapshots to keep (default: 100)
454
+ * @returns Number of snapshots deleted
455
+ */
456
+ declare function pruneHistory(cwd: string, keepCount?: number): number;
457
+ /**
458
+ * Prune snapshots based on tier retention policy.
459
+ *
460
+ * @param cwd - Working directory
461
+ * @param tier - Retention tier (free: 7d, team: 30d, pro: 90d)
462
+ * @returns Number of snapshots deleted
463
+ */
464
+ declare function pruneByTier(cwd: string, tier: RetentionTier): number;
465
+ /**
466
+ * Load snapshots within a date range.
467
+ *
468
+ * @param cwd - Working directory
469
+ * @param days - Number of days to include
470
+ * @returns Filtered snapshots
471
+ */
472
+ declare function loadSnapshotsForDays(cwd: string, days: number): CoverageSnapshot[];
473
+ /**
474
+ * Generate weekly summaries from snapshots.
475
+ *
476
+ * @param snapshots - Snapshots to summarize (most recent first)
477
+ * @returns Weekly summaries (most recent first)
478
+ */
479
+ declare function generateWeeklySummaries(snapshots: CoverageSnapshot[]): WeeklySummary[];
480
+ /**
481
+ * Get extended trend analysis with velocity and projections.
482
+ *
483
+ * @param spec - Current OpenPkg spec
484
+ * @param cwd - Working directory
485
+ * @param options - Analysis options
486
+ * @returns Extended trend analysis
487
+ */
488
+ declare function getExtendedTrend(spec: OpenPkg3, cwd: string, options?: {
489
+ commit?: string;
490
+ branch?: string;
491
+ tier?: RetentionTier;
492
+ }): ExtendedTrendAnalysis;
493
+ import { OpenPkg as OpenPkg4 } from "@openpkg-ts/spec";
494
+ /**
495
+ * Drift summary with category breakdown.
496
+ */
497
+ interface DriftReportSummary {
498
+ /**
499
+ * Total number of drift issues.
500
+ */
501
+ total: number;
502
+ /**
503
+ * Count of issues per category.
504
+ */
505
+ byCategory: Record<DriftCategory, number>;
506
+ /**
507
+ * Number of auto-fixable issues.
508
+ */
509
+ fixable: number;
510
+ }
511
+ /**
512
+ * Coverage summary for an entire package or project.
513
+ */
514
+ interface CoverageSummary {
515
+ /**
516
+ * Overall coverage score (0-100).
517
+ */
518
+ score: number;
519
+ /**
520
+ * Total number of exports analyzed.
521
+ */
522
+ totalExports: number;
523
+ /**
524
+ * Number of fully documented exports.
525
+ */
526
+ documentedExports: number;
527
+ /**
528
+ * Breakdown of missing documentation by rule ID.
529
+ */
530
+ missingByRule: Record<string, number>;
531
+ /**
532
+ * Total number of drift issues detected.
533
+ */
534
+ driftCount: number;
535
+ /**
536
+ * Drift summary with category breakdown.
537
+ */
538
+ driftSummary?: DriftReportSummary;
539
+ }
540
+ /**
541
+ * Coverage data for a single export.
542
+ */
543
+ interface ExportCoverageData {
544
+ /**
545
+ * Export name.
546
+ */
547
+ name: string;
548
+ /**
549
+ * Export kind (function, class, etc.).
550
+ */
551
+ kind: string;
552
+ /**
553
+ * Coverage score for this (0-100).
554
+ */
555
+ coverageScore: number;
556
+ /**
557
+ * Missing documentation rule IDs.
558
+ */
559
+ missing?: string[];
560
+ /**
561
+ * Drift issues for this export.
562
+ */
563
+ drift?: SpecDocDrift[];
564
+ }
565
+ /**
566
+ * DocCov report - a persistable coverage analysis result.
567
+ *
568
+ * This is the format saved to `.doccov/report.json` and returned
569
+ * by the `check` command with `--format json`.
570
+ */
571
+ interface DocCovReport {
572
+ /**
573
+ * JSON Schema reference for validation.
574
+ */
575
+ $schema: string;
576
+ /**
577
+ * Report format version.
578
+ */
579
+ version: string;
580
+ /**
581
+ * ISO 8601 timestamp when report was generated.
582
+ */
583
+ generatedAt: string;
584
+ /**
585
+ * Package/project metadata.
586
+ */
587
+ spec: {
588
+ name: string;
589
+ version?: string;
590
+ };
591
+ /**
592
+ * Aggregate coverage summary.
593
+ */
594
+ coverage: CoverageSummary;
595
+ /**
596
+ * Per-coverage data, keyed by ID.
597
+ */
598
+ exports: Record<string, ExportCoverageData>;
599
+ }
600
+ /**
601
+ * Generate a DocCov report from an OpenPkg spec.
602
+ *
603
+ * @param spec - The pure OpenPkg spec to analyze
604
+ * @returns A DocCov report with coverage analysis
605
+ *
606
+ * @example
607
+ * ```ts
608
+ * import { DocCov, generateReport } from '@doccov/sdk';
609
+ *
610
+ * const doccov = new DocCov();
611
+ * const { spec } = await doccov.analyzeFileWithDiagnostics('src/index.ts');
612
+ * const report = generateReport(spec);
613
+ *
614
+ * console.log(`Coverage: ${report.coverage.score}%`);
615
+ * ```
616
+ */
617
+ declare function generateReport(spec: OpenPkg4): DocCovReport;
618
+ /**
619
+ * Generate a DocCov report from an already-enriched spec.
620
+ *
621
+ * Use this when you've already called enrichSpec() and want to avoid
622
+ * recomputing coverage data.
623
+ *
624
+ * @param enriched - The enriched OpenPkg spec
625
+ * @returns A DocCov report with coverage analysis
626
+ */
627
+ declare function generateReportFromEnriched(enriched: EnrichedOpenPkg): DocCovReport;
628
+ /**
629
+ * Load a cached DocCov report from disk.
630
+ *
631
+ * @param reportPath - Path to the report file (defaults to .doccov/report.json)
632
+ * @returns The cached report, or null if not found
633
+ */
634
+ declare function loadCachedReport(reportPath?: string): DocCovReport | null;
635
+ /**
636
+ * Save a DocCov report to disk.
637
+ *
638
+ * @param report - The report to save
639
+ * @param reportPath - Path to save the report (defaults to .doccov/report.json)
640
+ */
641
+ declare function saveReport(report: DocCovReport, reportPath?: string): void;
642
+ /**
643
+ * Check if a cached report is still valid.
644
+ *
645
+ * A report is considered stale if:
646
+ * - It doesn't exist
647
+ * - The spec version has changed
648
+ * - Source files have been modified since generation
649
+ *
650
+ * @param reportPath - Path to the report file
651
+ * @param sourceFiles - Source files to check modification times against
652
+ * @returns True if the cached report is still valid
653
+ */
654
+ declare function isCachedReportValid(reportPath?: string, sourceFiles?: string[]): boolean;
655
+ /**
656
+ * Generate a git-trackable API surface markdown file from an OpenPkg spec.
657
+ *
658
+ * This produces a deterministic, sorted output suitable for version control.
659
+ * Changes to the API will show up as diffs in this file.
660
+ *
661
+ * @param spec - The OpenPkg spec to render
662
+ * @returns Markdown string representing the API surface
663
+ *
664
+ * @example
665
+ * ```ts
666
+ * import { DocCov, renderApiSurface } from '@doccov/sdk';
667
+ *
668
+ * const doccov = new DocCov();
669
+ * const { spec } = await doccov.analyzeFileWithDiagnostics('src/index.ts');
670
+ * const apiSurface = renderApiSurface(spec);
671
+ *
672
+ * fs.writeFileSync('api-surface.md', apiSurface);
673
+ * ```
674
+ */
675
+ declare function renderApiSurface(spec: OpenPkg4): string;
676
+ interface SchemaDetectionContext {
677
+ baseDir: string;
678
+ entryFile: string;
679
+ }
680
+ interface DetectedSchema {
681
+ schema: Record<string, unknown>;
682
+ vendor: string;
683
+ }
684
+ interface SchemaDetectionResult {
685
+ schemas: Map<string, DetectedSchema>;
686
+ errors: string[];
687
+ /** Warning when runtime was requested but compiled JS not found */
688
+ noCompiledJsWarning?: boolean;
689
+ }
690
+ declare function detectRuntimeSchemas(context: SchemaDetectionContext): Promise<SchemaDetectionResult>;
691
+ export { saveSnapshot, saveReport, renderSparkline, renderApiSurface, pruneHistory, pruneByTier, parseAssertions, loadSnapshotsForDays, loadSnapshots, loadCachedReport, isCachedReportValid, hasNonAssertionComments, groupDriftsByCategory, getTrend, getExtendedTrend, getDriftSummary, generateWeeklySummaries, generateReportFromEnriched, generateReport, formatDriftSummaryLine, formatDelta, ensureSpecCoverage, enrichSpec, diffEnrichedSpec, detectRuntimeSchemas, detectExampleRuntimeErrors, detectExampleAssertionFailures, computeSnapshot, computeExportDrift, computeDrift, categorizeDrift, calculateAggregateCoverage, buildExportRegistry, WeeklySummary, SchemaDetectionResult, SchemaDetectionContext, RetentionTier, RETENTION_DAYS, OpenPkgSpec, HISTORY_DIR, ExtendedTrendAnalysis, ExportDriftResult, EnrichedSpecDiff, EnrichedOpenPkg, EnrichedExport, EnrichedDocsMetadata, EnrichOptions, DriftSummary, DriftResult, DetectedSchemaEntry, CoverageTrend, CoverageSnapshot, CategorizedDrift };