@doccov/sdk 0.22.1 → 0.23.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.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { EntryPointDetectionMethod } from "@openpkg-ts/spec";
1
2
  /**
2
3
  * Configuration types for DocCov.
3
4
  * These types are shared between CLI and API.
@@ -114,209 +115,261 @@ interface DetectedSchemaEntry {
114
115
  schema: Record<string, unknown>;
115
116
  vendor: string;
116
117
  }
117
- interface SchemaDetectionContext {
118
- baseDir: string;
119
- entryFile: string;
120
- }
121
- interface DetectedSchema {
122
- schema: Record<string, unknown>;
123
- vendor: string;
124
- }
125
- interface SchemaDetectionResult {
126
- schemas: Map<string, DetectedSchema>;
127
- errors: string[];
128
- /** Warning when runtime was requested but compiled JS not found */
129
- noCompiledJsWarning?: boolean;
130
- }
131
- declare function detectRuntimeSchemas(context: SchemaDetectionContext): Promise<SchemaDetectionResult>;
132
- declare function clearSchemaCache(): void;
133
- import * as TS from "typescript";
134
- /**
135
- * A schema adapter can detect and extract output types from a specific
136
- * schema validation library.
137
- */
138
- interface SchemaAdapter {
139
- /** Unique identifier for this adapter */
140
- readonly id: string;
141
- /** npm package name(s) this adapter handles */
142
- readonly packages: readonly string[];
143
- /**
144
- * Check if a type matches this adapter's schema library.
145
- * Should be fast - called for every export.
146
- */
147
- matches(type: TS.Type, checker: TS.TypeChecker): boolean;
148
- /**
149
- * Extract the output type from a schema type.
150
- * Returns null if extraction fails.
151
- */
152
- extractOutputType(type: TS.Type, checker: TS.TypeChecker): TS.Type | null;
153
- /**
154
- * Extract the input type from a schema type (optional).
155
- * Useful for transforms where input differs from output.
156
- */
157
- extractInputType?(type: TS.Type, checker: TS.TypeChecker): TS.Type | null;
158
- }
118
+ import { OpenPkg as OpenPkg2 } from "@openpkg-ts/spec";
119
+ type OpenPkgSpec = OpenPkg2;
159
120
  /**
160
- * Result of schema type extraction
121
+ * Input for generation metadata that comes from the caller (CLI, API, etc.)
161
122
  */
162
- interface SchemaExtractionResult {
163
- /** The adapter that matched */
164
- adapter: SchemaAdapter;
165
- /** The extracted output type */
166
- outputType: TS.Type;
167
- /** The extracted input type (if different from output) */
168
- inputType?: TS.Type;
123
+ interface GenerationInput {
124
+ /** Entry point file path (relative to package root) */
125
+ entryPoint: string;
126
+ /** How the entry point was detected */
127
+ entryPointSource: EntryPointDetectionMethod;
128
+ /** Whether this is a declaration-only analysis (.d.ts file) */
129
+ isDeclarationOnly?: boolean;
130
+ /** Generator tool name */
131
+ generatorName: string;
132
+ /** Generator tool version */
133
+ generatorVersion: string;
134
+ /** Detected package manager */
135
+ packageManager?: string;
136
+ /** Whether this is a monorepo */
137
+ isMonorepo?: boolean;
138
+ /** Target package name (for monorepos) */
139
+ targetPackage?: string;
169
140
  }
170
- import * as TS2 from "typescript";
171
- /**
172
- * Find an adapter that matches the given type.
173
- * Returns null if no adapter matches.
174
- */
175
- declare function findAdapter(type: TS2.Type, checker: TS2.TypeChecker): SchemaAdapter | null;
176
- /**
177
- * Check if a type is from a recognized schema library.
178
- */
179
- declare function isSchemaType(type: TS2.Type, checker: TS2.TypeChecker): boolean;
180
141
  /**
181
- * Extract the output type from a schema type.
182
- * Returns null if:
183
- * - The type is not from a recognized schema library
184
- * - The adapter fails to extract the output type
142
+ * Compute a hash of file contents.
143
+ * Uses truncated SHA-256 for balance of speed and collision resistance.
144
+ *
145
+ * @param filePath - Absolute path to the file
146
+ * @returns 16-character hex hash, or null if file doesn't exist
185
147
  */
186
- declare function extractSchemaOutputType(type: TS2.Type, checker: TS2.TypeChecker): TS2.Type | null;
148
+ declare function hashFile(filePath: string): string | null;
187
149
  /**
188
- * Full extraction with adapter info.
189
- * Useful when you need to know which library was detected.
150
+ * Hash a string value.
151
+ *
152
+ * @param content - String to hash
153
+ * @returns 16-character hex hash
190
154
  */
191
- declare function extractSchemaType(type: TS2.Type, checker: TS2.TypeChecker): SchemaExtractionResult | null;
155
+ declare function hashString(content: string): string;
192
156
  /**
193
- * Get all registered adapters.
194
- * Useful for logging/debugging.
157
+ * Hash multiple files and return a map of relative paths to hashes.
158
+ *
159
+ * @param filePaths - Array of absolute file paths
160
+ * @param cwd - Base directory for relative path calculation
161
+ * @returns Map of relative paths to their content hashes
195
162
  */
196
- declare function getRegisteredAdapters(): readonly SchemaAdapter[];
163
+ declare function hashFiles(filePaths: string[], cwd: string): Record<string, string>;
197
164
  /**
198
- * Get supported library names.
199
- * Useful for documentation/help output.
165
+ * Compare two hash maps and return changed files.
166
+ *
167
+ * @param cached - Hash map from cache
168
+ * @param current - Current hash map
169
+ * @returns Array of file paths that changed, were added, or were removed
200
170
  */
201
- declare function getSupportedLibraries(): readonly string[];
171
+ declare function diffHashes(cached: Record<string, string>, current: Record<string, string>): string[];
172
+ import { OpenPkg as OpenPkg3 } from "@openpkg-ts/spec";
173
+ /** Current cache format version */
174
+ declare const CACHE_VERSION = "1.0.0";
175
+ /** Default cache file path */
176
+ declare const SPEC_CACHE_FILE = ".doccov/spec.cache.json";
202
177
  /**
203
- * Standard JSON Schema v1 interface (minimal for detection).
178
+ * Configuration that affects spec generation output.
204
179
  */
205
- interface StandardJSONSchemaV1 {
206
- "~standard": {
207
- version: number;
208
- vendor: string;
209
- jsonSchema?: {
210
- output: (target?: string) => Record<string, unknown>;
211
- input?: (target?: string) => Record<string, unknown>;
212
- };
213
- };
180
+ interface SpecCacheConfig {
181
+ resolveExternalTypes: boolean;
214
182
  }
215
183
  /**
216
- * Result of extracting Standard Schema from an export.
184
+ * Cached spec with validation metadata.
217
185
  */
218
- interface StandardSchemaExtractionResult {
219
- exportName: string;
220
- vendor: string;
221
- outputSchema: Record<string, unknown>;
222
- inputSchema?: Record<string, unknown>;
186
+ interface SpecCache {
187
+ /** Cache format version for migrations */
188
+ cacheVersion: string;
189
+ /** When cache was generated (ISO timestamp) */
190
+ generatedAt: string;
191
+ /** OpenPkg spec version (e.g., "0.3.0") */
192
+ specVersion: string;
193
+ /** Entry file that was analyzed (relative path) */
194
+ entryFile: string;
195
+ /** Hash validation data */
196
+ hashes: {
197
+ /** Hash of tsconfig.json content (null if not found) */
198
+ tsconfig: string | null;
199
+ /** Hash of package.json content */
200
+ packageJson: string;
201
+ /** Source file hashes: relative filepath → content hash */
202
+ sourceFiles: Record<string, string>;
203
+ };
204
+ /** Analysis configuration that affects output */
205
+ config: SpecCacheConfig;
206
+ /** The cached OpenPkg spec */
207
+ spec: OpenPkg3;
223
208
  }
224
209
  /**
225
- * Options for runtime Standard Schema extraction.
210
+ * Result of cache validation.
226
211
  */
227
- interface ExtractStandardSchemasOptions {
228
- /** Timeout in milliseconds (default: 10000) */
229
- timeout?: number;
230
- /** JSON Schema target version (default: 'draft-2020-12') */
231
- target?: "draft-2020-12" | "draft-07" | "openapi-3.0";
212
+ interface CacheValidationResult {
213
+ /** Whether the cache is valid */
214
+ valid: boolean;
215
+ /** Reason for invalidation (if invalid) */
216
+ reason?: "cache-version-mismatch" | "entry-file-changed" | "config-changed" | "tsconfig-changed" | "package-json-changed" | "source-files-changed";
217
+ /** Files that changed (if reason is source-files-changed) */
218
+ changedFiles?: string[];
232
219
  }
233
220
  /**
234
- * Result of Standard Schema extraction.
221
+ * Context needed for cache operations.
235
222
  */
236
- interface StandardSchemaExtractionOutput {
237
- schemas: Map<string, StandardSchemaExtractionResult>;
238
- errors: string[];
223
+ interface CacheContext {
224
+ /** Entry file being analyzed (absolute path) */
225
+ entryFile: string;
226
+ /** Source files included in analysis (absolute paths) */
227
+ sourceFiles: string[];
228
+ /** Path to tsconfig.json (absolute, or null if not found) */
229
+ tsconfigPath: string | null;
230
+ /** Path to package.json (absolute) */
231
+ packageJsonPath: string;
232
+ /** Configuration that affects output */
233
+ config: SpecCacheConfig;
234
+ /** Working directory */
235
+ cwd: string;
239
236
  }
240
237
  /**
241
- * Check if an object implements StandardJSONSchemaV1.
242
- * This is a static type guard - doesn't require runtime.
238
+ * Load cached spec from disk.
239
+ *
240
+ * @param cwd - Working directory
241
+ * @returns Cached spec, or null if not found or invalid JSON
243
242
  */
244
- declare function isStandardJSONSchema(obj: unknown): obj is StandardJSONSchemaV1;
243
+ declare function loadSpecCache(cwd: string): SpecCache | null;
245
244
  /**
246
- * Resolve compiled JS path from TypeScript source.
247
- * Tries common output locations: dist/, build/, lib/, same dir.
245
+ * Save spec to cache.
246
+ *
247
+ * @param spec - OpenPkg spec to cache
248
+ * @param context - Cache context with file paths and config
248
249
  */
249
- declare function resolveCompiledPath(tsPath: string, baseDir: string): string | null;
250
+ declare function saveSpecCache(spec: OpenPkg3, context: CacheContext): void;
250
251
  /**
251
- * Extract Standard Schema JSON Schemas from a compiled JS module.
252
+ * Validate if cached spec is still valid.
252
253
  *
253
- * **Security Note**: This executes the module in a subprocess.
254
- * Only use with trusted code (user's own packages).
254
+ * Checks:
255
+ * 1. Cache version matches
256
+ * 2. Entry file matches
257
+ * 3. Config matches
258
+ * 4. tsconfig.json hash matches
259
+ * 5. package.json hash matches
260
+ * 6. All source file hashes match
255
261
  *
256
- * @param compiledJsPath - Path to compiled .js file
257
- * @param options - Extraction options
258
- * @returns Extraction results with schemas and any errors
262
+ * @param cache - Cached spec to validate
263
+ * @param context - Current cache context
264
+ * @returns Validation result
259
265
  */
260
- declare function extractStandardSchemas(compiledJsPath: string, options?: ExtractStandardSchemasOptions): Promise<StandardSchemaExtractionOutput>;
266
+ declare function validateSpecCache(cache: SpecCache, context: CacheContext): CacheValidationResult;
261
267
  /**
262
- * Extract Standard Schema from a TypeScript project.
268
+ * Clear the spec cache.
263
269
  *
264
- * Convenience function that resolves compiled JS and extracts schemas.
270
+ * @param cwd - Working directory
271
+ * @returns True if cache was deleted, false if it didn't exist
272
+ */
273
+ declare function clearSpecCache(cwd: string): boolean;
274
+ /**
275
+ * Get cache file path for a given working directory.
265
276
  *
266
- * @param entryFile - TypeScript entry file path
267
- * @param baseDir - Project base directory
268
- * @param options - Extraction options
277
+ * @param cwd - Working directory
278
+ * @returns Absolute path to cache file
269
279
  */
270
- declare function extractStandardSchemasFromProject(entryFile: string, baseDir: string, options?: ExtractStandardSchemasOptions): Promise<StandardSchemaExtractionOutput>;
271
- import { DriftCategory, SpecDocDrift, SpecExport } from "@openpkg-ts/spec";
272
- interface ExampleRunResult {
273
- success: boolean;
274
- stdout: string;
275
- stderr: string;
276
- exitCode: number;
277
- duration: number;
280
+ declare function getSpecCachePath(cwd: string): string;
281
+ /**
282
+ * Release stage/visibility tags that can be used for filtering.
283
+ * Based on TSDoc release tags.
284
+ */
285
+ type ReleaseTag = "public" | "beta" | "alpha" | "internal";
286
+ interface FilterOptions {
287
+ /** Include exports matching these patterns */
288
+ include?: string[];
289
+ /** Exclude exports matching these patterns */
290
+ exclude?: string[];
291
+ /** Filter by visibility/release stage (e.g., ['public', 'beta']) */
292
+ visibility?: ReleaseTag[];
278
293
  }
279
- interface RunExampleOptions {
280
- /** Timeout in milliseconds (default: 5000) */
281
- timeout?: number;
282
- /** Working directory for execution */
283
- cwd?: string;
294
+ interface Diagnostic2 {
295
+ message: string;
296
+ severity: "error" | "warning" | "info";
297
+ suggestion?: string;
298
+ location?: {
299
+ file: string;
300
+ line?: number;
301
+ column?: number;
302
+ };
284
303
  }
285
- interface RunExamplesWithPackageOptions extends RunExampleOptions {
286
- /** Path to the local package to install */
287
- packagePath: string;
288
- /** Package manager to use (auto-detected if not specified) */
289
- packageManager?: "npm" | "pnpm" | "bun";
290
- /** Timeout for package installation in ms (default: 60000) */
291
- installTimeout?: number;
304
+ interface AnalysisResult {
305
+ spec: OpenPkgSpec;
306
+ diagnostics: Diagnostic2[];
307
+ metadata: AnalysisMetadata;
308
+ /** True if result came from cache (no fresh analysis) */
309
+ fromCache?: boolean;
310
+ /** Cache validation details (if cache was checked) */
311
+ cacheStatus?: CacheValidationResult;
292
312
  }
293
- interface RunExamplesWithPackageResult {
294
- /** Results for each example by index */
295
- results: Map<number, ExampleRunResult>;
296
- /** Whether package installation succeeded */
297
- installSuccess: boolean;
298
- /** Error message if installation failed */
299
- installError?: string;
300
- /** Total duration including install */
301
- totalDuration: number;
313
+ interface AnalysisMetadata {
314
+ baseDir: string;
315
+ configPath?: string;
316
+ packageJsonPath?: string;
317
+ hasNodeModules: boolean;
318
+ resolveExternalTypes: boolean;
319
+ /** Source files included in analysis (for caching) */
320
+ sourceFiles?: string[];
302
321
  }
303
- /**
304
- * Run an example code snippet in an isolated Node process.
305
- * Uses Node 22+ --experimental-strip-types for direct TS execution.
306
- */
307
- declare function runExample(code: string, options?: RunExampleOptions): Promise<ExampleRunResult>;
308
- /**
309
- * Run multiple examples and collect results
310
- */
311
- declare function runExamples(examples: string[], options?: RunExampleOptions): Promise<Map<number, ExampleRunResult>>;
312
- /**
313
- * Run multiple examples with a pre-installed local package.
314
- * Creates a single temp directory, installs the package once,
315
- * runs all examples, then cleans up.
316
- */
317
- declare function runExamplesWithPackage(examples: string[], options: RunExamplesWithPackageOptions): Promise<RunExamplesWithPackageResult>;
318
- import { OpenPkg as OpenPkg2 } from "@openpkg-ts/spec";
319
- type OpenPkgSpec = OpenPkg2;
322
+ interface AnalyzeOptions {
323
+ filters?: FilterOptions;
324
+ /** Generation metadata input (entry point info, tool version, etc.) */
325
+ generationInput?: GenerationInput;
326
+ }
327
+ declare class DocCov {
328
+ private readonly options;
329
+ constructor(options?: DocCovOptions);
330
+ analyze(code: string, fileName?: string, analyzeOptions?: AnalyzeOptions): Promise<OpenPkgSpec>;
331
+ analyzeFile(filePath: string, analyzeOptions?: AnalyzeOptions): Promise<OpenPkgSpec>;
332
+ analyzeProject(entryPath: string, analyzeOptions?: AnalyzeOptions): Promise<OpenPkgSpec>;
333
+ analyzeWithDiagnostics(code: string, fileName?: string, analyzeOptions?: AnalyzeOptions): Promise<AnalysisResult>;
334
+ analyzeFileWithDiagnostics(filePath: string, analyzeOptions?: AnalyzeOptions): Promise<AnalysisResult>;
335
+ /**
336
+ * Try to load spec from cache.
337
+ * Returns null if cache is invalid or doesn't exist.
338
+ */
339
+ private tryLoadFromCache;
340
+ /**
341
+ * Get current source files from a fresh TypeScript program.
342
+ * Used for cache validation to detect new files.
343
+ */
344
+ private getCurrentSourceFiles;
345
+ /**
346
+ * Save analysis result to cache.
347
+ */
348
+ private saveToCache;
349
+ /**
350
+ * Find tsconfig.json starting from a directory.
351
+ */
352
+ private findTsConfig;
353
+ /**
354
+ * Find package.json starting from a directory.
355
+ */
356
+ private findPackageJson;
357
+ /**
358
+ * Detect Standard Schema exports from compiled modules.
359
+ * Only runs when schemaExtraction is 'runtime' or 'hybrid'.
360
+ * Returns undefined if detection is disabled, fails, or no schemas found.
361
+ */
362
+ private detectSchemas;
363
+ private normalizeDiagnostic;
364
+ private mapSeverity;
365
+ private normalizeMetadata;
366
+ private applySpecFilters;
367
+ }
368
+ declare function analyze(code: string, options?: AnalyzeOptions): Promise<OpenPkgSpec>;
369
+ declare function analyzeFile(filePath: string, options?: AnalyzeOptions): Promise<OpenPkgSpec>;
370
+ import { OpenPkg as OpenPkg4, SpecDocDrift as SpecDocDrift8, SpecDocsMetadata, SpecExport as SpecExport7 } from "@openpkg-ts/spec";
371
+ import { DriftCategory as DriftCategory2, SpecDocDrift as SpecDocDrift2 } from "@openpkg-ts/spec";
372
+ import { DriftCategory, SpecDocDrift } from "@openpkg-ts/spec";
320
373
  /**
321
374
  * Result of computing drift for a single export.
322
375
  */
@@ -350,46 +403,6 @@ interface ExportRegistry {
350
403
  all: Set<string>;
351
404
  }
352
405
  /**
353
- * Build a registry of all export/type names for cross-reference validation.
354
- */
355
- declare function buildExportRegistry(spec: OpenPkgSpec): ExportRegistry;
356
- /**
357
- * Compute drift for all exports in a spec.
358
- *
359
- * @param spec - The OpenPkg spec to analyze
360
- * @returns Drift results per */
361
- declare function computeDrift(spec: OpenPkgSpec): DriftResult;
362
- /**
363
- * Compute drift for a single export.
364
- *
365
- * @param entry - The to analyze
366
- * @param registry - Registry of known exports and types for validation
367
- * @returns Array of drift issues detected
368
- */
369
- declare function computeExportDrift(entry: SpecExport, registry?: ExportRegistry): SpecDocDrift[];
370
- /**
371
- * Detect runtime errors in @example blocks.
372
- * Results are provided externally after running examples via runExamples().
373
- */
374
- declare function detectExampleRuntimeErrors(entry: SpecExport, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift[];
375
- /**
376
- * Parse assertion comments from example code.
377
- * Matches: // => expected_value
378
- */
379
- declare function parseAssertions(code: string): Array<{
380
- lineNumber: number;
381
- expected: string;
382
- }>;
383
- /**
384
- * Check if code contains comments that are not assertion syntax.
385
- * Used to determine if LLM fallback should be attempted.
386
- */
387
- declare function hasNonAssertionComments(code: string): boolean;
388
- /**
389
- * Detect assertion failures by comparing stdout to expected values.
390
- */
391
- declare function detectExampleAssertionFailures(entry: SpecExport, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift[];
392
- /**
393
406
  * Extended drift with category and fixability metadata.
394
407
  */
395
408
  interface CategorizedDrift extends SpecDocDrift {
@@ -397,6 +410,14 @@ interface CategorizedDrift extends SpecDocDrift {
397
410
  fixable: boolean;
398
411
  }
399
412
  /**
413
+ * Summary of drift issues by category.
414
+ */
415
+ interface DriftSummary {
416
+ total: number;
417
+ byCategory: Record<DriftCategory, number>;
418
+ fixable: number;
419
+ }
420
+ /**
400
421
  * Categorize a single drift issue.
401
422
  *
402
423
  * @param drift - The drift to categorize
@@ -414,7 +435,7 @@ interface CategorizedDrift extends SpecDocDrift {
414
435
  * console.log(categorized.fixable); // => true
415
436
  * ```
416
437
  */
417
- declare function categorizeDrift(drift: SpecDocDrift): CategorizedDrift;
438
+ declare function categorizeDrift(drift: SpecDocDrift2): CategorizedDrift;
418
439
  /**
419
440
  * Group drifts by category.
420
441
  *
@@ -429,15 +450,7 @@ declare function categorizeDrift(drift: SpecDocDrift): CategorizedDrift;
429
450
  * console.log(grouped.example.length); // Number of example issues
430
451
  * ```
431
452
  */
432
- declare function groupDriftsByCategory(drifts: SpecDocDrift[]): Record<DriftCategory, CategorizedDrift[]>;
433
- /**
434
- * Summary of drift issues by category.
435
- */
436
- interface DriftSummary {
437
- total: number;
438
- byCategory: Record<DriftCategory, number>;
439
- fixable: number;
440
- }
453
+ declare function groupDriftsByCategory(drifts: SpecDocDrift2[]): Record<DriftCategory2, CategorizedDrift[]>;
441
454
  /**
442
455
  * Get drift summary counts by category.
443
456
  *
@@ -451,7 +464,7 @@ interface DriftSummary {
451
464
  * // => "5 issues: 3 fixable"
452
465
  * ```
453
466
  */
454
- declare function getDriftSummary(drifts: SpecDocDrift[]): DriftSummary;
467
+ declare function getDriftSummary(drifts: SpecDocDrift2[]): DriftSummary;
455
468
  /**
456
469
  * Format drift summary for CLI output (single line).
457
470
  *
@@ -466,6 +479,25 @@ declare function getDriftSummary(drifts: SpecDocDrift[]): DriftSummary;
466
479
  * ```
467
480
  */
468
481
  declare function formatDriftSummaryLine(summary: DriftSummary): string;
482
+ import { SpecDocDrift as SpecDocDrift3, SpecExport } from "@openpkg-ts/spec";
483
+ /**
484
+ * Build a registry of all export/type names for cross-reference validation.
485
+ */
486
+ declare function buildExportRegistry(spec: OpenPkgSpec): ExportRegistry;
487
+ /**
488
+ * Compute drift for all exports in a spec.
489
+ *
490
+ * @param spec - The OpenPkg spec to analyze
491
+ * @returns Drift results per */
492
+ declare function computeDrift(spec: OpenPkgSpec): DriftResult;
493
+ /**
494
+ * Compute drift for a single export.
495
+ *
496
+ * @param entry - The to analyze
497
+ * @param registry - Registry of known exports and types for validation
498
+ * @returns Array of drift issues detected
499
+ */
500
+ declare function computeExportDrift(entry: SpecExport, registry?: ExportRegistry): SpecDocDrift3[];
469
501
  /**
470
502
  * Calculate aggregate coverage score from a spec's exports.
471
503
  *
@@ -514,12 +546,80 @@ declare function ensureSpecCoverage(spec: OpenPkgSpec): OpenPkgSpec & {
514
546
  coverageScore: number;
515
547
  };
516
548
  };
517
- import { OpenPkg as OpenPkg3, SpecDocDrift as SpecDocDrift2, SpecDocsMetadata, SpecExport as SpecExport2 } from "@openpkg-ts/spec";
549
+ import { SpecDocDrift as SpecDocDrift4, SpecExport as SpecExport2 } from "@openpkg-ts/spec";
550
+ interface ExampleRunResult {
551
+ success: boolean;
552
+ stdout: string;
553
+ stderr: string;
554
+ exitCode: number;
555
+ duration: number;
556
+ }
557
+ interface RunExampleOptions {
558
+ /** Timeout in milliseconds (default: 5000) */
559
+ timeout?: number;
560
+ /** Working directory for execution */
561
+ cwd?: string;
562
+ }
563
+ interface RunExamplesWithPackageOptions extends RunExampleOptions {
564
+ /** Path to the local package to install */
565
+ packagePath: string;
566
+ /** Package manager to use (auto-detected if not specified) */
567
+ packageManager?: "npm" | "pnpm" | "bun";
568
+ /** Timeout for package installation in ms (default: 60000) */
569
+ installTimeout?: number;
570
+ }
571
+ interface RunExamplesWithPackageResult {
572
+ /** Results for each example by index */
573
+ results: Map<number, ExampleRunResult>;
574
+ /** Whether package installation succeeded */
575
+ installSuccess: boolean;
576
+ /** Error message if installation failed */
577
+ installError?: string;
578
+ /** Total duration including install */
579
+ totalDuration: number;
580
+ }
581
+ /**
582
+ * Run an example code snippet in an isolated Node process.
583
+ * Uses Node 22+ --experimental-strip-types for direct TS execution.
584
+ */
585
+ declare function runExample(code: string, options?: RunExampleOptions): Promise<ExampleRunResult>;
586
+ /**
587
+ * Run multiple examples and collect results
588
+ */
589
+ declare function runExamples(examples: string[], options?: RunExampleOptions): Promise<Map<number, ExampleRunResult>>;
590
+ /**
591
+ * Run multiple examples with a pre-installed local package.
592
+ * Creates a single temp directory, installs the package once,
593
+ * runs all examples, then cleans up.
594
+ */
595
+ declare function runExamplesWithPackage(examples: string[], options: RunExamplesWithPackageOptions): Promise<RunExamplesWithPackageResult>;
596
+ /**
597
+ * Detect runtime errors in @example blocks.
598
+ * Results are provided externally after running examples via runExamples().
599
+ */
600
+ declare function detectExampleRuntimeErrors(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift4[];
601
+ /**
602
+ * Parse assertion comments from example code.
603
+ * Matches: // => expected_value
604
+ */
605
+ declare function parseAssertions(code: string): Array<{
606
+ lineNumber: number;
607
+ expected: string;
608
+ }>;
609
+ /**
610
+ * Check if code contains comments that are not assertion syntax.
611
+ * Used to determine if LLM fallback should be attempted.
612
+ */
613
+ declare function hasNonAssertionComments(code: string): boolean;
614
+ /**
615
+ * Detect assertion failures by comparing stdout to expected values.
616
+ */
617
+ declare function detectExampleAssertionFailures(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift4[];
518
618
  /**
519
619
  * An enriched with computed documentation metadata.
520
620
  * Extends SpecExport with the `docs` field for coverage analysis.
521
621
  */
522
- type EnrichedExport = SpecExport2 & {
622
+ type EnrichedExport = SpecExport7 & {
523
623
  docs?: EnrichedDocsMetadata;
524
624
  };
525
625
  /**
@@ -530,7 +630,7 @@ type EnrichedDocsMetadata = SpecDocsMetadata;
530
630
  * An enriched OpenPkg spec with computed documentation metadata.
531
631
  * Extends OpenPkg with per-and aggregate coverage data.
532
632
  */
533
- type EnrichedOpenPkg = Omit<OpenPkg3, "exports"> & {
633
+ type EnrichedOpenPkg = Omit<OpenPkg4, "exports"> & {
534
634
  exports: EnrichedExport[];
535
635
  docs?: EnrichedDocsMetadata;
536
636
  /** Drift summary with category breakdown (if drift exists) */
@@ -541,7 +641,7 @@ interface EnrichOptions {
541
641
  * Per-drift issues to include in enrichment.
542
642
  * Map from ID to drift issues.
543
643
  */
544
- driftByExport?: Map<string, SpecDocDrift2[]>;
644
+ driftByExport?: Map<string, SpecDocDrift8[]>;
545
645
  }
546
646
  /**
547
647
  * Enrich an OpenPkg spec with documentation coverage metadata.
@@ -563,9 +663,9 @@ interface EnrichOptions {
563
663
  * console.log(enriched.docs?.coverageScore); // e.g., 85
564
664
  * ```
565
665
  */
566
- declare function enrichSpec(spec: OpenPkg3, options?: EnrichOptions): EnrichedOpenPkg;
567
- import { OpenPkg as OpenPkg4 } from "@openpkg-ts/spec";
568
- import { DriftCategory as DriftCategory2, SpecDocDrift as SpecDocDrift3 } from "@openpkg-ts/spec";
666
+ declare function enrichSpec(spec: OpenPkg4, options?: EnrichOptions): EnrichedOpenPkg;
667
+ import { OpenPkg as OpenPkg5 } from "@openpkg-ts/spec";
668
+ import { DriftCategory as DriftCategory3, SpecDocDrift as SpecDocDrift9 } from "@openpkg-ts/spec";
569
669
  /**
570
670
  * DocCov report schema version.
571
671
  */
@@ -625,7 +725,7 @@ interface DriftReportSummary {
625
725
  /**
626
726
  * Count of issues per category.
627
727
  */
628
- byCategory: Record<DriftCategory2, number>;
728
+ byCategory: Record<DriftCategory3, number>;
629
729
  /**
630
730
  * Number of auto-fixable issues.
631
731
  */
@@ -647,7 +747,7 @@ interface DriftReport {
647
747
  /**
648
748
  * Issues grouped by category.
649
749
  */
650
- byCategory: Record<DriftCategory2, CategorizedDrift[]>;
750
+ byCategory: Record<DriftCategory3, CategorizedDrift[]>;
651
751
  /**
652
752
  * Flat list of all drift issues (backward compatible).
653
753
  */
@@ -705,7 +805,7 @@ interface ExportCoverageData {
705
805
  /**
706
806
  * Drift issues for this export.
707
807
  */
708
- drift?: SpecDocDrift3[];
808
+ drift?: SpecDocDrift9[];
709
809
  }
710
810
  /**
711
811
  * DocCov report - a persistable coverage analysis result.
@@ -759,7 +859,7 @@ interface DocCovReport {
759
859
  * console.log(`Coverage: ${report.coverage.score}%`);
760
860
  * ```
761
861
  */
762
- declare function generateReport(spec: OpenPkg4): DocCovReport;
862
+ declare function generateReport(spec: OpenPkg5): DocCovReport;
763
863
  /**
764
864
  * Generate a DocCov report from an already-enriched spec.
765
865
  *
@@ -785,365 +885,8 @@ declare function loadCachedReport(reportPath?: string): DocCovReport | null;
785
885
  */
786
886
  declare function saveReport(report: DocCovReport, reportPath?: string): void;
787
887
  /**
788
- * Check if a cached report is still valid.
789
- *
790
- * A report is considered stale if:
791
- * - It doesn't exist
792
- * - The spec version has changed
793
- * - Source files have been modified since generation
794
- *
795
- * @param reportPath - Path to the report file
796
- * @param sourceFiles - Source files to check modification times against
797
- * @returns True if the cached report is still valid
798
- */
799
- declare function isCachedReportValid(reportPath?: string, sourceFiles?: string[]): boolean;
800
- /**
801
- * Generate a git-trackable API surface markdown file from an OpenPkg spec.
802
- *
803
- * This produces a deterministic, sorted output suitable for version control.
804
- * Changes to the API will show up as diffs in this file.
805
- *
806
- * @param spec - The OpenPkg spec to render
807
- * @returns Markdown string representing the API surface
808
- *
809
- * @example
810
- * ```ts
811
- * import { DocCov, renderApiSurface } from '@doccov/sdk';
812
- *
813
- * const doccov = new DocCov();
814
- * const { spec } = await doccov.analyzeFileWithDiagnostics('src/index.ts');
815
- * const apiSurface = renderApiSurface(spec);
816
- *
817
- * fs.writeFileSync('api-surface.md', apiSurface);
818
- * ```
819
- */
820
- declare function renderApiSurface(spec: OpenPkg4): string;
821
- import { OpenPkg as OpenPkg5 } from "@openpkg-ts/spec";
822
- /** Directory for storing history snapshots */
823
- declare const HISTORY_DIR = ".doccov/history";
824
- /**
825
- * A historical coverage snapshot.
826
- */
827
- interface CoverageSnapshot {
828
- /** ISO 8601 timestamp */
829
- timestamp: string;
830
- /** Package name */
831
- package: string;
832
- /** Package version (if available) */
833
- version?: string;
834
- /** Coverage score (0-100) */
835
- coverageScore: number;
836
- /** Total number of exports */
837
- totalExports: number;
838
- /** Number of documented exports */
839
- documentedExports: number;
840
- /** Number of drift issues */
841
- driftCount: number;
842
- /** Git commit hash (if available) */
843
- commit?: string;
844
- /** Git branch (if available) */
845
- branch?: string;
846
- }
847
- /**
848
- * Coverage trend data.
849
- */
850
- interface CoverageTrend {
851
- /** Current snapshot */
852
- current: CoverageSnapshot;
853
- /** Previous snapshots (most recent first) */
854
- history: CoverageSnapshot[];
855
- /** Score delta from previous */
856
- delta?: number;
857
- /** Sparkline data (last N scores) */
858
- sparkline: number[];
859
- }
860
- /**
861
- * Tier-based retention settings.
862
- */
863
- type RetentionTier = "free" | "team" | "pro";
864
- /**
865
- * Retention days per tier.
866
- */
867
- declare const RETENTION_DAYS: Record<RetentionTier, number>;
868
- /**
869
- * Weekly summary of coverage data.
870
- */
871
- interface WeeklySummary {
872
- /** Week start date (ISO string) */
873
- weekStart: string;
874
- /** Week end date (ISO string) */
875
- weekEnd: string;
876
- /** Average coverage for the week */
877
- avgCoverage: number;
878
- /** Coverage at start of week */
879
- startCoverage: number;
880
- /** Coverage at end of week */
881
- endCoverage: number;
882
- /** Change during the week */
883
- delta: number;
884
- /** Number of snapshots in the week */
885
- snapshotCount: number;
886
- }
887
- /**
888
- * Extended trend analysis result.
889
- */
890
- interface ExtendedTrendAnalysis {
891
- /** Current trend data */
892
- trend: CoverageTrend;
893
- /** Weekly summaries (most recent first) */
894
- weeklySummaries: WeeklySummary[];
895
- /** 7-day velocity (average daily change) */
896
- velocity7d: number;
897
- /** 30-day velocity */
898
- velocity30d: number;
899
- /** 90-day velocity (Pro only) */
900
- velocity90d?: number;
901
- /** Projected coverage in 30 days (based on velocity) */
902
- projected30d: number;
903
- /** Best coverage ever recorded */
904
- allTimeHigh: number;
905
- /** Worst coverage ever recorded */
906
- allTimeLow: number;
907
- /** Date range of available data */
908
- dataRange: {
909
- start: string;
910
- end: string;
911
- } | null;
912
- }
913
- /**
914
- * Compute a coverage snapshot from an OpenPkg spec.
915
- */
916
- declare function computeSnapshot(spec: OpenPkg5, options?: {
917
- commit?: string;
918
- branch?: string;
919
- }): CoverageSnapshot;
920
- /**
921
- * Save a coverage snapshot to history.
922
- *
923
- * @param snapshot - The snapshot to save
924
- * @param cwd - Working directory
925
- */
926
- declare function saveSnapshot(snapshot: CoverageSnapshot, cwd: string): void;
927
- /**
928
- * Load all historical snapshots.
929
- *
930
- * @param cwd - Working directory
931
- * @returns Array of snapshots sorted by timestamp (most recent first)
932
- */
933
- declare function loadSnapshots(cwd: string): CoverageSnapshot[];
934
- /**
935
- * Get coverage trend data.
936
- *
937
- * @param spec - Current OpenPkg spec
938
- * @param cwd - Working directory
939
- * @param options - Optional git metadata
940
- * @returns Trend data with history and delta
941
- */
942
- declare function getTrend(spec: OpenPkg5, cwd: string, options?: {
943
- commit?: string;
944
- branch?: string;
945
- }): CoverageTrend;
946
- /**
947
- * Generate a sparkline character representation.
948
- *
949
- * @param values - Array of values (0-100 for coverage)
950
- * @returns Sparkline string using unicode characters
951
- */
952
- declare function renderSparkline(values: number[]): string;
953
- /**
954
- * Format a delta value with arrow and color indicator.
955
- *
956
- * @param delta - Coverage delta (positive = improvement)
957
- * @returns Formatted delta string
958
- */
959
- declare function formatDelta(delta: number): string;
960
- /**
961
- * Prune old snapshots to keep history manageable.
962
- *
963
- * @param cwd - Working directory
964
- * @param keepCount - Number of snapshots to keep (default: 100)
965
- * @returns Number of snapshots deleted
966
- */
967
- declare function pruneHistory(cwd: string, keepCount?: number): number;
968
- /**
969
- * Prune snapshots based on tier retention policy.
970
- *
971
- * @param cwd - Working directory
972
- * @param tier - Retention tier (free: 7d, team: 30d, pro: 90d)
973
- * @returns Number of snapshots deleted
974
- */
975
- declare function pruneByTier(cwd: string, tier: RetentionTier): number;
976
- /**
977
- * Load snapshots within a date range.
978
- *
979
- * @param cwd - Working directory
980
- * @param days - Number of days to include
981
- * @returns Filtered snapshots
982
- */
983
- declare function loadSnapshotsForDays(cwd: string, days: number): CoverageSnapshot[];
984
- /**
985
- * Generate weekly summaries from snapshots.
986
- *
987
- * @param snapshots - Snapshots to summarize (most recent first)
988
- * @returns Weekly summaries (most recent first)
989
- */
990
- declare function generateWeeklySummaries(snapshots: CoverageSnapshot[]): WeeklySummary[];
991
- /**
992
- * Get extended trend analysis with velocity and projections.
993
- *
994
- * @param spec - Current OpenPkg spec
995
- * @param cwd - Working directory
996
- * @param options - Analysis options
997
- * @returns Extended trend analysis
998
- */
999
- declare function getExtendedTrend(spec: OpenPkg5, cwd: string, options?: {
1000
- commit?: string;
1001
- branch?: string;
1002
- tier?: RetentionTier;
1003
- }): ExtendedTrendAnalysis;
1004
- /**
1005
- * Compute a hash of file contents.
1006
- * Uses truncated SHA-256 for balance of speed and collision resistance.
1007
- *
1008
- * @param filePath - Absolute path to the file
1009
- * @returns 16-character hex hash, or null if file doesn't exist
1010
- */
1011
- declare function hashFile(filePath: string): string | null;
1012
- /**
1013
- * Hash a string value.
1014
- *
1015
- * @param content - String to hash
1016
- * @returns 16-character hex hash
1017
- */
1018
- declare function hashString(content: string): string;
1019
- /**
1020
- * Hash multiple files and return a map of relative paths to hashes.
1021
- *
1022
- * @param filePaths - Array of absolute file paths
1023
- * @param cwd - Base directory for relative path calculation
1024
- * @returns Map of relative paths to their content hashes
1025
- */
1026
- declare function hashFiles(filePaths: string[], cwd: string): Record<string, string>;
1027
- /**
1028
- * Compare two hash maps and return changed files.
1029
- *
1030
- * @param cached - Hash map from cache
1031
- * @param current - Current hash map
1032
- * @returns Array of file paths that changed, were added, or were removed
1033
- */
1034
- declare function diffHashes(cached: Record<string, string>, current: Record<string, string>): string[];
1035
- import { OpenPkg as OpenPkg6 } from "@openpkg-ts/spec";
1036
- /** Current cache format version */
1037
- declare const CACHE_VERSION = "1.0.0";
1038
- /** Default cache file path */
1039
- declare const SPEC_CACHE_FILE = ".doccov/spec.cache.json";
1040
- /**
1041
- * Configuration that affects spec generation output.
1042
- */
1043
- interface SpecCacheConfig {
1044
- resolveExternalTypes: boolean;
1045
- }
1046
- /**
1047
- * Cached spec with validation metadata.
1048
- */
1049
- interface SpecCache {
1050
- /** Cache format version for migrations */
1051
- cacheVersion: string;
1052
- /** When cache was generated (ISO timestamp) */
1053
- generatedAt: string;
1054
- /** OpenPkg spec version (e.g., "0.3.0") */
1055
- specVersion: string;
1056
- /** Entry file that was analyzed (relative path) */
1057
- entryFile: string;
1058
- /** Hash validation data */
1059
- hashes: {
1060
- /** Hash of tsconfig.json content (null if not found) */
1061
- tsconfig: string | null;
1062
- /** Hash of package.json content */
1063
- packageJson: string;
1064
- /** Source file hashes: relative filepath → content hash */
1065
- sourceFiles: Record<string, string>;
1066
- };
1067
- /** Analysis configuration that affects output */
1068
- config: SpecCacheConfig;
1069
- /** The cached OpenPkg spec */
1070
- spec: OpenPkg6;
1071
- }
1072
- /**
1073
- * Result of cache validation.
1074
- */
1075
- interface CacheValidationResult {
1076
- /** Whether the cache is valid */
1077
- valid: boolean;
1078
- /** Reason for invalidation (if invalid) */
1079
- reason?: "cache-version-mismatch" | "entry-file-changed" | "config-changed" | "tsconfig-changed" | "package-json-changed" | "source-files-changed";
1080
- /** Files that changed (if reason is source-files-changed) */
1081
- changedFiles?: string[];
1082
- }
1083
- /**
1084
- * Context needed for cache operations.
1085
- */
1086
- interface CacheContext {
1087
- /** Entry file being analyzed (absolute path) */
1088
- entryFile: string;
1089
- /** Source files included in analysis (absolute paths) */
1090
- sourceFiles: string[];
1091
- /** Path to tsconfig.json (absolute, or null if not found) */
1092
- tsconfigPath: string | null;
1093
- /** Path to package.json (absolute) */
1094
- packageJsonPath: string;
1095
- /** Configuration that affects output */
1096
- config: SpecCacheConfig;
1097
- /** Working directory */
1098
- cwd: string;
1099
- }
1100
- /**
1101
- * Load cached spec from disk.
1102
- *
1103
- * @param cwd - Working directory
1104
- * @returns Cached spec, or null if not found or invalid JSON
1105
- */
1106
- declare function loadSpecCache(cwd: string): SpecCache | null;
1107
- /**
1108
- * Save spec to cache.
1109
- *
1110
- * @param spec - OpenPkg spec to cache
1111
- * @param context - Cache context with file paths and config
1112
- */
1113
- declare function saveSpecCache(spec: OpenPkg6, context: CacheContext): void;
1114
- /**
1115
- * Validate if cached spec is still valid.
1116
- *
1117
- * Checks:
1118
- * 1. Cache version matches
1119
- * 2. Entry file matches
1120
- * 3. Config matches
1121
- * 4. tsconfig.json hash matches
1122
- * 5. package.json hash matches
1123
- * 6. All source file hashes match
1124
- *
1125
- * @param cache - Cached spec to validate
1126
- * @param context - Current cache context
1127
- * @returns Validation result
1128
- */
1129
- declare function validateSpecCache(cache: SpecCache, context: CacheContext): CacheValidationResult;
1130
- /**
1131
- * Clear the spec cache.
1132
- *
1133
- * @param cwd - Working directory
1134
- * @returns True if cache was deleted, false if it didn't exist
1135
- */
1136
- declare function clearSpecCache(cwd: string): boolean;
1137
- /**
1138
- * Get cache file path for a given working directory.
1139
- *
1140
- * @param cwd - Working directory
1141
- * @returns Absolute path to cache file
1142
- */
1143
- declare function getSpecCachePath(cwd: string): string;
1144
- /**
1145
- * Project detection types for I/O-agnostic project analysis.
1146
- * Used by both CLI (NodeFileSystem) and API (SandboxFileSystem).
888
+ * Project detection types for I/O-agnostic project analysis.
889
+ * Used by both CLI (NodeFileSystem) and API (SandboxFileSystem).
1147
890
  */
1148
891
  /**
1149
892
  * Minimal filesystem interface for I/O-agnostic detection.
@@ -1238,6 +981,59 @@ interface AnalyzeProjectOptions {
1238
981
  targetPackage?: string;
1239
982
  }
1240
983
  /**
984
+ * Options for resolving a target package/entry point.
985
+ */
986
+ interface ResolveTargetOptions {
987
+ /** Working directory (usually process.cwd()) */
988
+ cwd: string;
989
+ /** Target package name for monorepos */
990
+ package?: string;
991
+ /** Explicit entry point path (relative to cwd or package dir) */
992
+ entry?: string;
993
+ }
994
+ /**
995
+ * Result of resolving a target package/entry point.
996
+ */
997
+ interface ResolvedTarget {
998
+ /** Resolved directory containing the package */
999
+ targetDir: string;
1000
+ /** Resolved entry point file path (absolute) */
1001
+ entryFile: string;
1002
+ /** Package info if this is a monorepo package */
1003
+ packageInfo?: WorkspacePackage;
1004
+ /** Entry point detection info */
1005
+ entryPointInfo: EntryPointInfo;
1006
+ }
1007
+ /**
1008
+ * Resolve a target package and entry point.
1009
+ *
1010
+ * This consolidates the repeated pattern from CLI commands:
1011
+ * 1. If --package specified, detect monorepo and find the package
1012
+ * 2. If no entry specified, auto-detect entry point
1013
+ * 3. If entry is a directory, detect entry point within it
1014
+ *
1015
+ * @param fs - FileSystem implementation (NodeFileSystem or SandboxFileSystem)
1016
+ * @param options - Resolution options
1017
+ * @returns Resolved target info
1018
+ * @throws Error if monorepo package not found, or entry point detection fails
1019
+ *
1020
+ * @example
1021
+ * ```typescript
1022
+ * import { NodeFileSystem, resolveTarget } from '@doccov/sdk';
1023
+ *
1024
+ * // Simple usage
1025
+ * const fs = new NodeFileSystem(process.cwd());
1026
+ * const { targetDir, entryFile } = await resolveTarget(fs, { cwd: process.cwd() });
1027
+ *
1028
+ * // With monorepo package
1029
+ * const { targetDir, entryFile, packageInfo } = await resolveTarget(fs, {
1030
+ * cwd: process.cwd(),
1031
+ * package: '@myorg/core',
1032
+ * });
1033
+ * ```
1034
+ */
1035
+ declare function resolveTarget(fs: FileSystem, options: ResolveTargetOptions): Promise<ResolvedTarget>;
1036
+ /**
1241
1037
  * Detect build configuration and exotic project indicators.
1242
1038
  *
1243
1039
  * @param fs - FileSystem implementation
@@ -1430,7 +1226,7 @@ declare function parseExamplesFlag(value: boolean | string | undefined): Example
1430
1226
  * Check if a specific validation is enabled.
1431
1227
  */
1432
1228
  declare function shouldValidate(validations: ExampleValidation[], check: ExampleValidation): boolean;
1433
- import { SpecExport as SpecExport3 } from "@openpkg-ts/spec";
1229
+ import { SpecExport as SpecExport8 } from "@openpkg-ts/spec";
1434
1230
  interface ExampleTypeError {
1435
1231
  /** Index of the example in the examples array */
1436
1232
  exampleIndex: number;
@@ -1527,103 +1323,35 @@ interface RunValidationResult {
1527
1323
  passed: number;
1528
1324
  failed: number;
1529
1325
  drifts: RuntimeDrift[];
1530
- installSuccess: boolean;
1531
- installError?: string;
1532
- }
1533
- /**
1534
- * Unified result from example validation.
1535
- */
1536
- interface ExampleValidationResult {
1537
- /** Which validations were run */
1538
- validations: ExampleValidation[];
1539
- /** Presence validation results (if run) */
1540
- presence?: PresenceResult;
1541
- /** Typecheck validation results (if run) */
1542
- typecheck?: TypecheckValidationResult;
1543
- /** Runtime validation results (if run) */
1544
- run?: RunValidationResult;
1545
- /** Total number of issues found */
1546
- totalIssues: number;
1547
- }
1548
- /**
1549
- * Validate examples across exports.
1550
- *
1551
- * Runs only the validations specified. Each validation is independent:
1552
- * - `presence`: checks examples exist (doesn't require typecheck or run)
1553
- * - `typecheck`: type-checks examples (doesn't require presence or run)
1554
- * - `run`: executes examples (doesn't require presence or typecheck)
1555
- */
1556
- declare function validateExamples(exports: SpecExport3[], options: ExampleValidationOptions): Promise<ExampleValidationResult>;
1557
- declare function extractPackageSpec(entryFile: string, packageDir?: string, content?: string, options?: DocCovOptions): Promise<OpenPkgSpec>;
1558
- /**
1559
- * Release stage/visibility tags that can be used for filtering.
1560
- * Based on TSDoc release tags.
1561
- */
1562
- type ReleaseTag = "public" | "beta" | "alpha" | "internal";
1563
- interface FilterOptions {
1564
- /** Include exports matching these patterns */
1565
- include?: string[];
1566
- /** Exclude exports matching these patterns */
1567
- exclude?: string[];
1568
- /** Filter by visibility/release stage (e.g., ['public', 'beta']) */
1569
- visibility?: ReleaseTag[];
1570
- }
1571
- /**
1572
- * Source of filter options.
1573
- */
1574
- type FilterSource = "config" | "override" | "combined";
1575
- /**
1576
- * Resolved filter options after merging config and overrides.
1577
- */
1578
- interface ResolvedFilters {
1579
- /** Include patterns */
1580
- include?: string[];
1581
- /** Exclude patterns */
1582
- exclude?: string[];
1583
- /** Source of the filters */
1584
- source?: FilterSource;
1585
- /** Whether filters were applied from config */
1586
- fromConfig: boolean;
1587
- /** Whether filters were applied from overrides */
1588
- fromOverride: boolean;
1589
- }
1590
- /**
1591
- * Parse a comma-separated list flag into an array.
1592
- *
1593
- * @param value - String or string array from CLI flag
1594
- * @returns Parsed array, or undefined if empty
1595
- *
1596
- * @example
1597
- * ```typescript
1598
- * parseListFlag('a,b,c'); // ['a', 'b', 'c']
1599
- * parseListFlag(['a,b', 'c']); // ['a', 'b', 'c']
1600
- * parseListFlag(undefined); // undefined
1601
- * ```
1326
+ installSuccess: boolean;
1327
+ installError?: string;
1328
+ }
1329
+ /**
1330
+ * Unified result from example validation.
1602
1331
  */
1603
- declare function parseListFlag(value?: string | string[]): string[] | undefined;
1332
+ interface ExampleValidationResult {
1333
+ /** Which validations were run */
1334
+ validations: ExampleValidation[];
1335
+ /** Presence validation results (if run) */
1336
+ presence?: PresenceResult;
1337
+ /** Typecheck validation results (if run) */
1338
+ typecheck?: TypecheckValidationResult;
1339
+ /** Runtime validation results (if run) */
1340
+ run?: RunValidationResult;
1341
+ /** Total number of issues found */
1342
+ totalIssues: number;
1343
+ }
1604
1344
  /**
1605
- * Merge filter options from config and CLI/API overrides.
1606
- *
1607
- * Merge behavior:
1608
- * - Include: CLI values intersect with config values (narrowing)
1609
- * - Exclude: CLI values are added to config values (expanding)
1610
- *
1611
- * @param config - Configuration (from doccov.config.ts)
1612
- * @param overrides - Override filters (from CLI flags or API params)
1613
- * @returns Merged filter options
1614
- *
1615
- * @example
1616
- * ```typescript
1617
- * const config = { include: ['A', 'B', 'C'] };
1618
- * const overrides = { include: ['B', 'C', 'D'] };
1345
+ * Validate examples across exports.
1619
1346
  *
1620
- * const resolved = mergeFilters(config, overrides);
1621
- * // resolved.include = ['B', 'C'] (intersection)
1622
- * ```
1347
+ * Runs only the validations specified. Each validation is independent:
1348
+ * - `presence`: checks examples exist (doesn't require typecheck or run)
1349
+ * - `typecheck`: type-checks examples (doesn't require presence or run)
1350
+ * - `run`: executes examples (doesn't require presence or typecheck)
1623
1351
  */
1624
- declare function mergeFilters(config: DocCovConfig | null, overrides: FilterOptions): ResolvedFilters;
1625
- import { SpecDocDrift as SpecDocDrift4, SpecExport as SpecExport4 } from "@openpkg-ts/spec";
1626
- import * as TS3 from "typescript";
1352
+ declare function validateExamples(exports: SpecExport8[], options: ExampleValidationOptions): Promise<ExampleValidationResult>;
1353
+ import { SpecDocDrift as SpecDocDrift10, SpecExport as SpecExport9 } from "@openpkg-ts/spec";
1354
+ import * as TS2 from "typescript";
1627
1355
  /**
1628
1356
  * Represents a single parameter in a JSDoc patch
1629
1357
  */
@@ -1704,7 +1432,7 @@ declare function serializeJSDoc(patch: JSDocPatch, indent?: string): string;
1704
1432
  /**
1705
1433
  * Find the JSDoc location for a declaration in a source file
1706
1434
  */
1707
- declare function findJSDocLocation(sourceFile: TS3.SourceFile, symbolName: string, approximateLine?: number): {
1435
+ declare function findJSDocLocation(sourceFile: TS2.SourceFile, symbolName: string, approximateLine?: number): {
1708
1436
  startLine: number;
1709
1437
  endLine: number;
1710
1438
  declarationLine: number;
@@ -1719,7 +1447,7 @@ declare function applyEdits(edits: JSDocEdit[]): Promise<ApplyEditsResult>;
1719
1447
  /**
1720
1448
  * Create a TypeScript source file from a file path
1721
1449
  */
1722
- declare function createSourceFile(filePath: string): TS3.SourceFile;
1450
+ declare function createSourceFile(filePath: string): TS2.SourceFile;
1723
1451
  /**
1724
1452
  * Types of fixes that can be generated
1725
1453
  */
@@ -1727,661 +1455,886 @@ type FixType = "add-param" | "remove-param" | "update-param-type" | "update-para
1727
1455
  /**
1728
1456
  * A fix suggestion with the patch to apply
1729
1457
  */
1730
- interface FixSuggestion {
1731
- type: FixType;
1732
- driftType: SpecDocDrift4["type"];
1733
- target: string;
1734
- description: string;
1735
- patch: Partial<JSDocPatch>;
1736
- }
1458
+ interface FixSuggestion {
1459
+ type: FixType;
1460
+ driftType: SpecDocDrift10["type"];
1461
+ target: string;
1462
+ description: string;
1463
+ patch: Partial<JSDocPatch>;
1464
+ }
1465
+ /**
1466
+ * Check if a drift type can be fixed deterministically
1467
+ */
1468
+ declare function isFixableDrift(drift: SpecDocDrift10): boolean;
1469
+ /**
1470
+ * Generate a fix for a single drift issue
1471
+ */
1472
+ declare function generateFix(drift: SpecDocDrift10, exportEntry: SpecExport9, existingPatch?: JSDocPatch): FixSuggestion | null;
1473
+ /**
1474
+ * Generate all fixes for an export's drift issues
1475
+ */
1476
+ declare function generateFixesForExport(exportEntry: SpecExport9, existingPatch?: JSDocPatch): FixSuggestion[];
1477
+ /**
1478
+ * Merge multiple fix patches into a single patch
1479
+ */
1480
+ declare function mergeFixes(fixes: FixSuggestion[], basePatch?: JSDocPatch): JSDocPatch;
1481
+ /**
1482
+ * Get a summary of fixable vs non-fixable drifts
1483
+ */
1484
+ declare function categorizeDrifts(drifts: SpecDocDrift10[]): {
1485
+ fixable: SpecDocDrift10[];
1486
+ nonFixable: SpecDocDrift10[];
1487
+ };
1488
+ import { SpecDiff } from "@openpkg-ts/spec";
1489
+ type MemberChangeType = "added" | "removed" | "signature-changed";
1490
+ interface MemberChange {
1491
+ /** The class this member belongs to */
1492
+ className: string;
1493
+ /** The member name (e.g., "evaluateChainhook") */
1494
+ memberName: string;
1495
+ /** Kind of member */
1496
+ memberKind: "method" | "property" | "accessor" | "constructor";
1497
+ /** Type of change */
1498
+ changeType: MemberChangeType;
1499
+ /** Old signature string (for signature changes) */
1500
+ oldSignature?: string;
1501
+ /** New signature string (for signature changes) */
1502
+ newSignature?: string;
1503
+ /** Suggested replacement (e.g., "Use replayChainhook instead") */
1504
+ suggestion?: string;
1505
+ }
1506
+ /**
1507
+ * Markdown/MDX documentation analysis types
1508
+ */
1509
+ /**
1510
+ * A code block extracted from a markdown file
1511
+ */
1512
+ interface MarkdownCodeBlock {
1513
+ /** Language tag (ts, typescript, js, javascript, tsx, jsx) */
1514
+ lang: string;
1515
+ /** The code content */
1516
+ code: string;
1517
+ /** Raw meta string from code fence (e.g., "title=example.ts") */
1518
+ meta?: string;
1519
+ /** Starting line number in the markdown file */
1520
+ lineStart: number;
1521
+ /** Ending line number in the markdown file */
1522
+ lineEnd: number;
1523
+ }
1524
+ /**
1525
+ * A parsed markdown documentation file
1526
+ */
1527
+ interface MarkdownDocFile {
1528
+ /** File path relative to project root */
1529
+ path: string;
1530
+ /** All executable code blocks found */
1531
+ codeBlocks: MarkdownCodeBlock[];
1532
+ }
1533
+ /**
1534
+ * A reference to an found in markdown
1535
+ */
1536
+ interface ExportReference {
1537
+ /** The name of the being referenced */
1538
+ exportName: string;
1539
+ /** File path where the reference was found */
1540
+ file: string;
1541
+ /** Line number in the file */
1542
+ line: number;
1543
+ /** Surrounding code/text for context */
1544
+ context: string;
1545
+ /** Whether this reference is inside a code block */
1546
+ inCodeBlock: boolean;
1547
+ /** The code block index if inside a code block */
1548
+ blockIndex?: number;
1549
+ }
1550
+ /**
1551
+ * Change type for an impacted reference
1552
+ */
1553
+ type DocsChangeType = "signature-changed" | "removed" | "deprecated" | "method-removed" | "method-changed" | "method-deprecated";
1554
+ /**
1555
+ * Member-level change type
1556
+ */
1557
+ type MemberChangeType2 = "added" | "removed" | "signature-changed";
1558
+ /**
1559
+ * An impacted reference in a documentation file
1560
+ */
1561
+ interface DocsImpactReference {
1562
+ /** The name that was changed */
1563
+ exportName: string;
1564
+ /** Line number in the file */
1565
+ line: number;
1566
+ /** Type of change affecting this reference */
1567
+ changeType: DocsChangeType;
1568
+ /** Suggested fix (AI-generated or deterministic) */
1569
+ suggestion?: string;
1570
+ /** Context around the reference */
1571
+ context?: string;
1572
+ /** Member/method name if this is a member-level change */
1573
+ memberName?: string;
1574
+ /** Type of member change (added, removed, signature-changed) */
1575
+ memberChangeType?: MemberChangeType2;
1576
+ /** Suggested replacement for removed/changed members */
1577
+ replacementSuggestion?: string;
1578
+ /** True if this is just a class instantiation (new ClassName()) */
1579
+ isInstantiation?: boolean;
1580
+ }
1581
+ /**
1582
+ * Documentation file impact summary
1583
+ */
1584
+ interface DocsImpact {
1585
+ /** File path */
1586
+ file: string;
1587
+ /** All impacted references in this file */
1588
+ references: DocsImpactReference[];
1589
+ }
1590
+ /**
1591
+ * Complete docs impact analysis result
1592
+ */
1593
+ interface DocsImpactResult {
1594
+ /** Files with impacted references */
1595
+ impactedFiles: DocsImpact[];
1596
+ /** New exports (from this diff) that have no documentation */
1597
+ missingDocs: string[];
1598
+ /** ALL exports from the spec that have no documentation in the scanned files */
1599
+ allUndocumented: string[];
1600
+ /** Statistics */
1601
+ stats: {
1602
+ /** Total markdown files scanned */
1603
+ filesScanned: number;
1604
+ /** Total code blocks found */
1605
+ codeBlocksFound: number;
1606
+ /** Total references found */
1607
+ referencesFound: number;
1608
+ /** References impacted by changes */
1609
+ impactedReferences: number;
1610
+ /** Total exports in the spec */
1611
+ totalExports: number;
1612
+ /** Exports found documented in markdown */
1613
+ documentedExports: number;
1614
+ };
1615
+ }
1616
+ /**
1617
+ * Analyze docs impact from a spec diff
1618
+ *
1619
+ * @param diff - The spec diff result
1620
+ * @param markdownFiles - Parsed markdown files
1621
+ * @param newExportNames - All names in the new spec (for missing docs detection)
1622
+ * @param memberChanges - Optional member-level changes for granular detection
1623
+ */
1624
+ declare function analyzeDocsImpact(diff: SpecDiff, markdownFiles: MarkdownDocFile[], newExportNames?: string[], memberChanges?: MemberChange[]): DocsImpactResult;
1625
+ /**
1626
+ * Find references to deprecated exports
1627
+ */
1628
+ declare function findDeprecatedReferences(markdownFiles: MarkdownDocFile[], deprecatedExports: string[]): ExportReference[];
1629
+ /**
1630
+ * Find references to removed exports
1631
+ */
1632
+ declare function findRemovedReferences(markdownFiles: MarkdownDocFile[], removedExports: string[]): ExportReference[];
1633
+ /**
1634
+ * Check if any docs reference a specific */
1635
+ declare function hasDocsForExport(markdownFiles: MarkdownDocFile[], exportName: string): boolean;
1636
+ /**
1637
+ * Get all exports that have documentation
1638
+ */
1639
+ declare function getDocumentedExports(markdownFiles: MarkdownDocFile[], exportNames: string[]): string[];
1640
+ /**
1641
+ * Get all exports that lack documentation
1642
+ */
1643
+ declare function getUndocumentedExports(markdownFiles: MarkdownDocFile[], exportNames: string[]): string[];
1644
+ import { CategorizedBreaking, OpenPkg as OpenPkg7, SpecDiff as SpecDiff2 } from "@openpkg-ts/spec";
1645
+ /**
1646
+ * Extended spec diff result with docs impact
1647
+ */
1648
+ interface SpecDiffWithDocs extends SpecDiff2 {
1649
+ /** Docs impact analysis (only present if markdown files provided) */
1650
+ docsImpact?: DocsImpactResult;
1651
+ /** Member-level changes for classes (methods added/removed/changed) */
1652
+ memberChanges?: MemberChange[];
1653
+ /** Breaking changes categorized by severity (high/medium/low) */
1654
+ categorizedBreaking?: CategorizedBreaking[];
1655
+ }
1656
+ /**
1657
+ * Options for diffSpecWithDocs
1658
+ */
1659
+ interface DiffWithDocsOptions {
1660
+ /** Parsed markdown documentation files */
1661
+ markdownFiles?: MarkdownDocFile[];
1662
+ }
1663
+ /**
1664
+ * Compute spec diff with optional docs impact analysis
1665
+ *
1666
+ * @param oldSpec - Previous version of the spec
1667
+ * @param newSpec - Current version of the spec
1668
+ * @param options - Options including markdown files to analyze
1669
+ * @returns Extended diff result with docs impact
1670
+ *
1671
+ * @example
1672
+ * ```ts
1673
+ * import { diffSpecWithDocs, parseMarkdownFiles } from '@doccov/sdk';
1674
+ * import type { OpenPkg } from '@openpkg-ts/spec';
1675
+ *
1676
+ * const oldSpec: OpenPkg = { openpkg: '0.2.0', meta: { name: 'my-pkg' }, exports: [] };
1677
+ * const newSpec: OpenPkg = { openpkg: '0.2.1', meta: { name: 'my-pkg' }, exports: [] };
1678
+ *
1679
+ * const markdownFiles = parseMarkdownFiles([
1680
+ * { path: 'docs/guide.md', content: '...' },
1681
+ * ]);
1682
+ *
1683
+ * const diff = diffSpecWithDocs(oldSpec, newSpec, { markdownFiles });
1684
+ *
1685
+ * if (diff.docsImpact?.impactedFiles.length) {
1686
+ * console.log('Docs need updating!');
1687
+ * }
1688
+ * ```
1689
+ */
1690
+ declare function diffSpecWithDocs(oldSpec: OpenPkg7, newSpec: OpenPkg7, options?: DiffWithDocsOptions): SpecDiffWithDocs;
1737
1691
  /**
1738
- * Check if a drift type can be fixed deterministically
1692
+ * Check if a diff has any docs impact
1739
1693
  */
1740
- declare function isFixableDrift(drift: SpecDocDrift4): boolean;
1694
+ declare function hasDocsImpact(diff: SpecDiffWithDocs): boolean;
1741
1695
  /**
1742
- * Generate a fix for a single drift issue
1696
+ * Get summary of docs impact for display
1743
1697
  */
1744
- declare function generateFix(drift: SpecDocDrift4, exportEntry: SpecExport4, existingPatch?: JSDocPatch): FixSuggestion | null;
1698
+ declare function getDocsImpactSummary(diff: SpecDiffWithDocs): {
1699
+ impactedFileCount: number;
1700
+ impactedReferenceCount: number;
1701
+ missingDocsCount: number;
1702
+ totalIssues: number;
1703
+ memberChangesCount: number;
1704
+ };
1745
1705
  /**
1746
- * Generate all fixes for an export's drift issues
1706
+ * Extract import statements from code (legacy interface).
1707
+ * @deprecated Use extractImportsAST for more detailed info.
1747
1708
  */
1748
- declare function generateFixesForExport(exportEntry: SpecExport4, existingPatch?: JSDocPatch): FixSuggestion[];
1709
+ declare function extractImports(code: string): Array<{
1710
+ name: string;
1711
+ from: string;
1712
+ }>;
1749
1713
  /**
1750
- * Merge multiple fix patches into a single patch
1714
+ * Extract function calls from code (legacy interface).
1715
+ * @deprecated Use extractCallsAST for more detailed info.
1751
1716
  */
1752
- declare function mergeFixes(fixes: FixSuggestion[], basePatch?: JSDocPatch): JSDocPatch;
1717
+ declare function extractFunctionCalls(code: string): string[];
1718
+ /** Options for parsing markdown files */
1719
+ interface ParseOptions {
1720
+ /** Custom set of executable language tags */
1721
+ executableLangs?: string[];
1722
+ }
1753
1723
  /**
1754
- * Get a summary of fixable vs non-fixable drifts
1724
+ * Check if a language tag represents executable code
1755
1725
  */
1756
- declare function categorizeDrifts(drifts: SpecDocDrift4[]): {
1757
- fixable: SpecDocDrift4[];
1758
- nonFixable: SpecDocDrift4[];
1759
- };
1760
- import { OpenPkg as OpenPkg7 } from "@openpkg-ts/spec";
1726
+ declare function isExecutableLang(lang: string | null | undefined, customLangs?: Set<string>): boolean;
1761
1727
  /**
1762
- * Parsed components of a GitHub URL.
1728
+ * Parse a markdown file and extract code blocks
1763
1729
  */
1764
- interface ParsedGitHubUrl {
1765
- /** Repository owner (user or org) */
1766
- owner: string;
1767
- /** Repository name */
1768
- repo: string;
1769
- /** Git ref (branch or tag) */
1770
- ref: string;
1771
- }
1730
+ declare function parseMarkdownFile(content: string, filePath: string, options?: ParseOptions): MarkdownDocFile;
1772
1731
  /**
1773
- * Parse a GitHub URL or shorthand into components.
1774
- *
1775
- * Supported formats:
1776
- * - https://github.com/owner/repo
1777
- * - https://github.com/owner/repo/tree/branch
1778
- * - https://github.com/owner/repo/tree/v1.0.0
1779
- * - github.com/owner/repo
1780
- * - owner/repo (shorthand)
1781
- * - git@github.com:owner/repo.git
1782
- *
1783
- * @param input - GitHub URL or shorthand
1784
- * @param defaultRef - Default ref if not specified in URL (default: 'main')
1785
- * @returns Parsed components
1786
- * @throws Error if the URL format is invalid
1787
- *
1788
- * @example
1789
- * ```typescript
1790
- * import { parseGitHubUrl } from '@doccov/sdk';
1791
- *
1792
- * const parsed = parseGitHubUrl('https://github.com/vercel/next.js/tree/canary');
1793
- * // { owner: 'vercel', repo: 'next.js', ref: 'canary' }
1794
- *
1795
- * const shorthand = parseGitHubUrl('vercel/next.js');
1796
- * // { owner: 'vercel', repo: 'next.js', ref: 'main' }
1797
- * ```
1732
+ * Parse multiple markdown files
1798
1733
  */
1799
- declare function parseGitHubUrl(input: string, defaultRef?: string): ParsedGitHubUrl;
1734
+ declare function parseMarkdownFiles(files: Array<{
1735
+ path: string;
1736
+ content: string;
1737
+ }>, options?: ParseOptions): MarkdownDocFile[];
1800
1738
  /**
1801
- * Build a clone URL from parsed components.
1802
- *
1803
- * @param parsed - Parsed GitHub URL components
1804
- * @returns HTTPS clone URL
1805
- *
1806
- * @example
1807
- * ```typescript
1808
- * const cloneUrl = buildCloneUrl({ owner: 'vercel', repo: 'next.js', ref: 'main' });
1809
- * // 'https://github.com/vercel/next.js.git'
1810
- * ```
1739
+ * Find all references to given names in markdown files
1811
1740
  */
1812
- declare function buildCloneUrl(parsed: ParsedGitHubUrl): string;
1741
+ declare function findExportReferences(files: MarkdownDocFile[], exportNames: string[]): ExportReference[];
1813
1742
  /**
1814
- * Build a display-friendly URL (without protocol or .git suffix).
1815
- *
1816
- * @param parsed - Parsed GitHub URL components
1817
- * @returns Display URL like 'github.com/owner/repo'
1818
- *
1819
- * @example
1820
- * ```typescript
1821
- * const displayUrl = buildDisplayUrl({ owner: 'vercel', repo: 'next.js', ref: 'main' });
1822
- * // 'github.com/vercel/next.js'
1823
- * ```
1743
+ * Check if a code block references any of the given names
1824
1744
  */
1825
- declare function buildDisplayUrl(parsed: ParsedGitHubUrl): string;
1745
+ declare function blockReferencesExport(block: MarkdownCodeBlock, exportName: string): boolean;
1826
1746
  /**
1827
- * Build a raw.githubusercontent.com URL for a file.
1828
- *
1829
- * @param parsed - Parsed GitHub URL components
1830
- * @param filePath - Path to the file in the repo
1831
- * @returns Raw content URL
1747
+ * Type-check a single example
1832
1748
  */
1833
- declare function buildRawUrl(parsed: ParsedGitHubUrl, filePath: string): string;
1749
+ declare function typecheckExample(example: string, packagePath: string, options?: TypecheckOptions): ExampleTypeError[];
1834
1750
  /**
1835
- * Fetch an OpenPkg spec from a GitHub repository.
1836
- *
1837
- * Tries the specified ref first, then falls back to 'master' if not found.
1838
- *
1839
- * @param parsed - Parsed GitHub URL components
1840
- * @returns The OpenPkg spec, or null if not found
1841
- *
1842
- * @example
1843
- * ```typescript
1844
- * import { parseGitHubUrl, fetchSpecFromGitHub } from '@doccov/sdk';
1845
- *
1846
- * const parsed = parseGitHubUrl('vercel/next.js');
1847
- * const spec = await fetchSpecFromGitHub(parsed);
1848
- * if (spec) {
1849
- * console.log(`Coverage: ${spec.docs?.coverageScore}%`);
1850
- * }
1851
- * ```
1751
+ * Type-check multiple examples
1852
1752
  */
1853
- declare function fetchSpecFromGitHub(parsed: ParsedGitHubUrl): Promise<OpenPkg7 | null>;
1753
+ declare function typecheckExamples(examples: string[], packagePath: string, options?: TypecheckOptions): TypecheckResult;
1754
+ import { OpenPkg as OpenPkg8 } from "@openpkg-ts/spec";
1755
+ /** Directory for storing history snapshots */
1756
+ declare const HISTORY_DIR = ".doccov/history";
1854
1757
  /**
1855
- * Options for fetching a spec from GitHub.
1758
+ * A historical coverage snapshot.
1856
1759
  */
1857
- interface FetchSpecOptions {
1858
- /** Git ref (branch or tag). Default: 'main' */
1859
- ref?: string;
1860
- /** Path to openpkg.json (for monorepos). Default: 'openpkg.json' */
1861
- path?: string;
1760
+ interface CoverageSnapshot {
1761
+ /** ISO 8601 timestamp */
1762
+ timestamp: string;
1763
+ /** Package name */
1764
+ package: string;
1765
+ /** Package version (if available) */
1766
+ version?: string;
1767
+ /** Coverage score (0-100) */
1768
+ coverageScore: number;
1769
+ /** Total number of exports */
1770
+ totalExports: number;
1771
+ /** Number of documented exports */
1772
+ documentedExports: number;
1773
+ /** Number of drift issues */
1774
+ driftCount: number;
1775
+ /** Git commit hash (if available) */
1776
+ commit?: string;
1777
+ /** Git branch (if available) */
1778
+ branch?: string;
1862
1779
  }
1863
1780
  /**
1864
- * Fetch an OpenPkg spec from a GitHub repository by owner/repo/branch.
1865
- *
1866
- * Convenience function that creates ParsedGitHubUrl internally.
1867
- *
1868
- * @param owner - Repository owner
1869
- * @param repo - Repository name
1870
- * @param branchOrOptions - Branch name (default: 'main') or options object
1871
- * @returns The OpenPkg spec, or null if not found
1872
- */
1873
- declare function fetchSpec(owner: string, repo: string, branchOrOptions?: string | FetchSpecOptions): Promise<OpenPkg7 | null>;
1874
- /**
1875
- * Progress event for installation status updates.
1781
+ * Coverage trend data.
1876
1782
  */
1877
- interface InstallProgressEvent {
1878
- /** Current stage */
1879
- stage: "installing";
1880
- /** Human-readable message */
1881
- message: string;
1882
- /** Progress percentage (0-100), if known */
1883
- progress?: number;
1783
+ interface CoverageTrend {
1784
+ /** Current snapshot */
1785
+ current: CoverageSnapshot;
1786
+ /** Previous snapshots (most recent first) */
1787
+ history: CoverageSnapshot[];
1788
+ /** Score delta from previous */
1789
+ delta?: number;
1790
+ /** Sparkline data (last N scores) */
1791
+ sparkline: number[];
1884
1792
  }
1885
1793
  /**
1886
- * Callback for receiving installation progress events.
1794
+ * Tier-based retention settings.
1887
1795
  */
1888
- type InstallProgressCallback = (event: InstallProgressEvent) => void;
1796
+ type RetentionTier = "free" | "team" | "pro";
1889
1797
  /**
1890
- * Result of running a command.
1798
+ * Retention days per tier.
1891
1799
  */
1892
- interface CommandResult {
1893
- /** Exit code (0 = success) */
1894
- exitCode: number;
1895
- /** Standard output */
1896
- stdout: string;
1897
- /** Standard error */
1898
- stderr: string;
1899
- }
1800
+ declare const RETENTION_DAYS: Record<RetentionTier, number>;
1900
1801
  /**
1901
- * Function that runs a shell command.
1902
- * Abstracts the difference between Node.js execSync and Sandbox runCommand.
1802
+ * Weekly summary of coverage data.
1903
1803
  */
1904
- type CommandRunner = (cmd: string, args: string[], options: {
1905
- cwd: string;
1906
- timeout?: number;
1907
- }) => Promise<CommandResult>;
1804
+ interface WeeklySummary {
1805
+ /** Week start date (ISO string) */
1806
+ weekStart: string;
1807
+ /** Week end date (ISO string) */
1808
+ weekEnd: string;
1809
+ /** Average coverage for the week */
1810
+ avgCoverage: number;
1811
+ /** Coverage at start of week */
1812
+ startCoverage: number;
1813
+ /** Coverage at end of week */
1814
+ endCoverage: number;
1815
+ /** Change during the week */
1816
+ delta: number;
1817
+ /** Number of snapshots in the week */
1818
+ snapshotCount: number;
1819
+ }
1908
1820
  /**
1909
- * Result of dependency installation.
1821
+ * Extended trend analysis result.
1910
1822
  */
1911
- interface InstallResult {
1912
- /** Whether installation succeeded */
1913
- success: boolean;
1914
- /** Package manager that was used */
1915
- packageManager: PackageManager;
1916
- /** If a fallback was used, which one */
1917
- fallbackUsed?: PackageManager;
1918
- /** Error message if installation failed */
1919
- error?: string;
1920
- /** Detailed error messages from each attempt */
1921
- errors?: string[];
1823
+ interface ExtendedTrendAnalysis {
1824
+ /** Current trend data */
1825
+ trend: CoverageTrend;
1826
+ /** Weekly summaries (most recent first) */
1827
+ weeklySummaries: WeeklySummary[];
1828
+ /** 7-day velocity (average daily change) */
1829
+ velocity7d: number;
1830
+ /** 30-day velocity */
1831
+ velocity30d: number;
1832
+ /** 90-day velocity (Pro only) */
1833
+ velocity90d?: number;
1834
+ /** Projected coverage in 30 days (based on velocity) */
1835
+ projected30d: number;
1836
+ /** Best coverage ever recorded */
1837
+ allTimeHigh: number;
1838
+ /** Worst coverage ever recorded */
1839
+ allTimeLow: number;
1840
+ /** Date range of available data */
1841
+ dataRange: {
1842
+ start: string;
1843
+ end: string;
1844
+ } | null;
1922
1845
  }
1923
1846
  /**
1924
- * Options for dependency installation.
1847
+ * Compute a coverage snapshot from an OpenPkg spec.
1925
1848
  */
1926
- interface InstallOptions {
1927
- /** Timeout in milliseconds for install commands (default: 180000) */
1928
- timeout?: number;
1929
- /** Order of fallback package managers to try */
1930
- fallbackOrder?: PackageManager[];
1931
- /** Progress callback for status updates */
1932
- onProgress?: InstallProgressCallback;
1933
- }
1849
+ declare function computeSnapshot(spec: OpenPkg8, options?: {
1850
+ commit?: string;
1851
+ branch?: string;
1852
+ }): CoverageSnapshot;
1934
1853
  /**
1935
- * Install dependencies for a project.
1936
- *
1937
- * This consolidates the install logic from CLI scan.ts and API scan-stream.ts:
1938
- * 1. Detect package manager from lockfile
1939
- * 2. Try primary install command
1940
- * 3. Fall back to other package managers if primary fails
1854
+ * Save a coverage snapshot to history.
1941
1855
  *
1942
- * @param fs - FileSystem implementation for package manager detection
1943
- * @param cwd - Working directory to install in
1944
- * @param runCommand - Function to run shell commands
1945
- * @param options - Installation options
1946
- * @returns Result of the installation attempt
1856
+ * @param snapshot - The snapshot to save
1857
+ * @param cwd - Working directory
1858
+ */
1859
+ declare function saveSnapshot(snapshot: CoverageSnapshot, cwd: string): void;
1860
+ /**
1861
+ * Load all historical snapshots.
1947
1862
  *
1948
- * @example
1949
- * ```typescript
1950
- * import { NodeFileSystem, installDependencies, createNodeCommandRunner } from '@doccov/sdk';
1863
+ * @param cwd - Working directory
1864
+ * @returns Array of snapshots sorted by timestamp (most recent first)
1865
+ */
1866
+ declare function loadSnapshots(cwd: string): CoverageSnapshot[];
1867
+ /**
1868
+ * Get coverage trend data.
1951
1869
  *
1952
- * const fs = new NodeFileSystem('/path/to/repo');
1953
- * const result = await installDependencies(fs, '/path/to/repo', createNodeCommandRunner());
1870
+ * @param spec - Current OpenPkg spec
1871
+ * @param cwd - Working directory
1872
+ * @param options - Optional git metadata
1873
+ * @returns Trend data with history and delta
1874
+ */
1875
+ declare function getTrend(spec: OpenPkg8, cwd: string, options?: {
1876
+ commit?: string;
1877
+ branch?: string;
1878
+ }): CoverageTrend;
1879
+ /**
1880
+ * Generate a sparkline character representation.
1954
1881
  *
1955
- * if (result.success) {
1956
- * console.log(`Installed using ${result.packageManager}`);
1957
- * } else {
1958
- * console.error(`Install failed: ${result.error}`);
1959
- * }
1960
- * ```
1882
+ * @param values - Array of values (0-100 for coverage)
1883
+ * @returns Sparkline string using unicode characters
1961
1884
  */
1962
- declare function installDependencies(fs: FileSystem, cwd: string, runCommand: CommandRunner, options?: InstallOptions): Promise<InstallResult>;
1885
+ declare function renderSparkline(values: number[]): string;
1963
1886
  /**
1964
- * Create a command runner for Node.js environments using execSync.
1965
- * This is used by the CLI for local dependency installation.
1887
+ * Format a delta value with arrow and color indicator.
1966
1888
  *
1967
- * @returns CommandRunner that uses child_process.execSync
1889
+ * @param delta - Coverage delta (positive = improvement)
1890
+ * @returns Formatted delta string
1891
+ */
1892
+ declare function formatDelta(delta: number): string;
1893
+ /**
1894
+ * Prune old snapshots to keep history manageable.
1968
1895
  *
1969
- * @example
1970
- * ```typescript
1971
- * const runner = createNodeCommandRunner();
1972
- * const result = await runner('npm', ['install'], { cwd: '/path/to/repo' });
1973
- * ```
1896
+ * @param cwd - Working directory
1897
+ * @param keepCount - Number of snapshots to keep (default: 100)
1898
+ * @returns Number of snapshots deleted
1974
1899
  */
1975
- declare function createNodeCommandRunner(): CommandRunner;
1976
- import { SpecDiff } from "@openpkg-ts/spec";
1977
- type MemberChangeType = "added" | "removed" | "signature-changed";
1978
- interface MemberChange {
1979
- /** The class this member belongs to */
1980
- className: string;
1981
- /** The member name (e.g., "evaluateChainhook") */
1982
- memberName: string;
1983
- /** Kind of member */
1984
- memberKind: "method" | "property" | "accessor" | "constructor";
1985
- /** Type of change */
1986
- changeType: MemberChangeType;
1987
- /** Old signature string (for signature changes) */
1988
- oldSignature?: string;
1989
- /** New signature string (for signature changes) */
1990
- newSignature?: string;
1991
- /** Suggested replacement (e.g., "Use replayChainhook instead") */
1992
- suggestion?: string;
1993
- }
1900
+ declare function pruneHistory(cwd: string, keepCount?: number): number;
1994
1901
  /**
1995
- * Markdown/MDX documentation analysis types
1902
+ * Get extended trend analysis with velocity and projections.
1903
+ *
1904
+ * @param spec - Current OpenPkg spec
1905
+ * @param cwd - Working directory
1906
+ * @param options - Analysis options
1907
+ * @returns Extended trend analysis
1996
1908
  */
1909
+ declare function getExtendedTrend(spec: OpenPkg8, cwd: string, options?: {
1910
+ commit?: string;
1911
+ branch?: string;
1912
+ tier?: RetentionTier;
1913
+ }): ExtendedTrendAnalysis;
1914
+ import * as TS3 from "typescript";
1997
1915
  /**
1998
- * A code block extracted from a markdown file
1916
+ * A schema adapter can detect and extract output types from a specific
1917
+ * schema validation library.
1999
1918
  */
2000
- interface MarkdownCodeBlock {
2001
- /** Language tag (ts, typescript, js, javascript, tsx, jsx) */
2002
- lang: string;
2003
- /** The code content */
2004
- code: string;
2005
- /** Raw meta string from code fence (e.g., "title=example.ts") */
2006
- meta?: string;
2007
- /** Starting line number in the markdown file */
2008
- lineStart: number;
2009
- /** Ending line number in the markdown file */
2010
- lineEnd: number;
1919
+ interface SchemaAdapter {
1920
+ /** Unique identifier for this adapter */
1921
+ readonly id: string;
1922
+ /** npm package name(s) this adapter handles */
1923
+ readonly packages: readonly string[];
1924
+ /**
1925
+ * Check if a type matches this adapter's schema library.
1926
+ * Should be fast - called for every export.
1927
+ */
1928
+ matches(type: TS3.Type, checker: TS3.TypeChecker): boolean;
1929
+ /**
1930
+ * Extract the output type from a schema type.
1931
+ * Returns null if extraction fails.
1932
+ */
1933
+ extractOutputType(type: TS3.Type, checker: TS3.TypeChecker): TS3.Type | null;
1934
+ /**
1935
+ * Extract the input type from a schema type (optional).
1936
+ * Useful for transforms where input differs from output.
1937
+ */
1938
+ extractInputType?(type: TS3.Type, checker: TS3.TypeChecker): TS3.Type | null;
2011
1939
  }
2012
1940
  /**
2013
- * A parsed markdown documentation file
1941
+ * Result of schema type extraction
2014
1942
  */
2015
- interface MarkdownDocFile {
2016
- /** File path relative to project root */
2017
- path: string;
2018
- /** All executable code blocks found */
2019
- codeBlocks: MarkdownCodeBlock[];
1943
+ interface SchemaExtractionResult {
1944
+ /** The adapter that matched */
1945
+ adapter: SchemaAdapter;
1946
+ /** The extracted output type */
1947
+ outputType: TS3.Type;
1948
+ /** The extracted input type (if different from output) */
1949
+ inputType?: TS3.Type;
2020
1950
  }
1951
+ import * as TS4 from "typescript";
2021
1952
  /**
2022
- * A reference to an found in markdown
1953
+ * Find an adapter that matches the given type.
1954
+ * Returns null if no adapter matches.
2023
1955
  */
2024
- interface ExportReference {
2025
- /** The name of the being referenced */
2026
- exportName: string;
2027
- /** File path where the reference was found */
2028
- file: string;
2029
- /** Line number in the file */
2030
- line: number;
2031
- /** Surrounding code/text for context */
2032
- context: string;
2033
- /** Whether this reference is inside a code block */
2034
- inCodeBlock: boolean;
2035
- /** The code block index if inside a code block */
2036
- blockIndex?: number;
2037
- }
1956
+ declare function findAdapter(type: TS4.Type, checker: TS4.TypeChecker): SchemaAdapter | null;
2038
1957
  /**
2039
- * Change type for an impacted reference
1958
+ * Check if a type is from a recognized schema library.
2040
1959
  */
2041
- type DocsChangeType = "signature-changed" | "removed" | "deprecated" | "method-removed" | "method-changed" | "method-deprecated";
1960
+ declare function isSchemaType(type: TS4.Type, checker: TS4.TypeChecker): boolean;
2042
1961
  /**
2043
- * Member-level change type
1962
+ * Extract the output type from a schema type.
1963
+ * Returns null if:
1964
+ * - The type is not from a recognized schema library
1965
+ * - The adapter fails to extract the output type
2044
1966
  */
2045
- type MemberChangeType2 = "added" | "removed" | "signature-changed";
1967
+ declare function extractSchemaOutputType(type: TS4.Type, checker: TS4.TypeChecker): TS4.Type | null;
2046
1968
  /**
2047
- * An impacted reference in a documentation file
1969
+ * Full extraction with adapter info.
1970
+ * Useful when you need to know which library was detected.
2048
1971
  */
2049
- interface DocsImpactReference {
2050
- /** The name that was changed */
2051
- exportName: string;
2052
- /** Line number in the file */
2053
- line: number;
2054
- /** Type of change affecting this reference */
2055
- changeType: DocsChangeType;
2056
- /** Suggested fix (AI-generated or deterministic) */
2057
- suggestion?: string;
2058
- /** Context around the reference */
2059
- context?: string;
2060
- /** Member/method name if this is a member-level change */
2061
- memberName?: string;
2062
- /** Type of member change (added, removed, signature-changed) */
2063
- memberChangeType?: MemberChangeType2;
2064
- /** Suggested replacement for removed/changed members */
2065
- replacementSuggestion?: string;
2066
- /** True if this is just a class instantiation (new ClassName()) */
2067
- isInstantiation?: boolean;
2068
- }
1972
+ declare function extractSchemaType(type: TS4.Type, checker: TS4.TypeChecker): SchemaExtractionResult | null;
2069
1973
  /**
2070
- * Documentation file impact summary
1974
+ * Get all registered adapters.
1975
+ * Useful for logging/debugging.
2071
1976
  */
2072
- interface DocsImpact {
2073
- /** File path */
2074
- file: string;
2075
- /** All impacted references in this file */
2076
- references: DocsImpactReference[];
2077
- }
1977
+ declare function getRegisteredAdapters(): readonly SchemaAdapter[];
2078
1978
  /**
2079
- * Complete docs impact analysis result
1979
+ * Get supported library names.
1980
+ * Useful for documentation/help output.
2080
1981
  */
2081
- interface DocsImpactResult {
2082
- /** Files with impacted references */
2083
- impactedFiles: DocsImpact[];
2084
- /** New exports (from this diff) that have no documentation */
2085
- missingDocs: string[];
2086
- /** ALL exports from the spec that have no documentation in the scanned files */
2087
- allUndocumented: string[];
2088
- /** Statistics */
2089
- stats: {
2090
- /** Total markdown files scanned */
2091
- filesScanned: number;
2092
- /** Total code blocks found */
2093
- codeBlocksFound: number;
2094
- /** Total references found */
2095
- referencesFound: number;
2096
- /** References impacted by changes */
2097
- impactedReferences: number;
2098
- /** Total exports in the spec */
2099
- totalExports: number;
2100
- /** Exports found documented in markdown */
2101
- documentedExports: number;
1982
+ declare function getSupportedLibraries(): readonly string[];
1983
+ /**
1984
+ * Standard JSON Schema v1 interface (minimal for detection).
1985
+ */
1986
+ interface StandardJSONSchemaV1 {
1987
+ "~standard": {
1988
+ version: number;
1989
+ vendor: string;
1990
+ jsonSchema?: {
1991
+ output: (target?: string) => Record<string, unknown>;
1992
+ input?: (target?: string) => Record<string, unknown>;
1993
+ };
2102
1994
  };
2103
1995
  }
2104
1996
  /**
2105
- * Analyze docs impact from a spec diff
2106
- *
2107
- * @param diff - The spec diff result
2108
- * @param markdownFiles - Parsed markdown files
2109
- * @param newExportNames - All names in the new spec (for missing docs detection)
2110
- * @param memberChanges - Optional member-level changes for granular detection
1997
+ * Result of extracting Standard Schema from an export.
2111
1998
  */
2112
- declare function analyzeDocsImpact(diff: SpecDiff, markdownFiles: MarkdownDocFile[], newExportNames?: string[], memberChanges?: MemberChange[]): DocsImpactResult;
1999
+ interface StandardSchemaExtractionResult {
2000
+ exportName: string;
2001
+ vendor: string;
2002
+ outputSchema: Record<string, unknown>;
2003
+ inputSchema?: Record<string, unknown>;
2004
+ }
2113
2005
  /**
2114
- * Find references to deprecated exports
2006
+ * Options for runtime Standard Schema extraction.
2115
2007
  */
2116
- declare function findDeprecatedReferences(markdownFiles: MarkdownDocFile[], deprecatedExports: string[]): ExportReference[];
2008
+ interface ExtractStandardSchemasOptions {
2009
+ /** Timeout in milliseconds (default: 10000) */
2010
+ timeout?: number;
2011
+ /** JSON Schema target version (default: 'draft-2020-12') */
2012
+ target?: "draft-2020-12" | "draft-07" | "openapi-3.0";
2013
+ }
2117
2014
  /**
2118
- * Find references to removed exports
2015
+ * Result of Standard Schema extraction.
2119
2016
  */
2120
- declare function findRemovedReferences(markdownFiles: MarkdownDocFile[], removedExports: string[]): ExportReference[];
2017
+ interface StandardSchemaExtractionOutput {
2018
+ schemas: Map<string, StandardSchemaExtractionResult>;
2019
+ errors: string[];
2020
+ }
2121
2021
  /**
2122
- * Check if any docs reference a specific */
2123
- declare function hasDocsForExport(markdownFiles: MarkdownDocFile[], exportName: string): boolean;
2022
+ * Check if an object implements StandardJSONSchemaV1.
2023
+ * This is a static type guard - doesn't require runtime.
2024
+ */
2025
+ declare function isStandardJSONSchema(obj: unknown): obj is StandardJSONSchemaV1;
2124
2026
  /**
2125
- * Get all exports that have documentation
2027
+ * Resolve compiled JS path from TypeScript source.
2028
+ * Tries common output locations: dist/, build/, lib/, same dir.
2126
2029
  */
2127
- declare function getDocumentedExports(markdownFiles: MarkdownDocFile[], exportNames: string[]): string[];
2030
+ declare function resolveCompiledPath(tsPath: string, baseDir: string): string | null;
2128
2031
  /**
2129
- * Get all exports that lack documentation
2032
+ * Extract Standard Schema JSON Schemas from a compiled JS module.
2033
+ *
2034
+ * **Security Note**: This executes the module in a subprocess.
2035
+ * Only use with trusted code (user's own packages).
2036
+ *
2037
+ * @param compiledJsPath - Path to compiled .js file
2038
+ * @param options - Extraction options
2039
+ * @returns Extraction results with schemas and any errors
2130
2040
  */
2131
- declare function getUndocumentedExports(markdownFiles: MarkdownDocFile[], exportNames: string[]): string[];
2132
- import { CategorizedBreaking, OpenPkg as OpenPkg9, SpecDiff as SpecDiff2 } from "@openpkg-ts/spec";
2041
+ declare function extractStandardSchemas(compiledJsPath: string, options?: ExtractStandardSchemasOptions): Promise<StandardSchemaExtractionOutput>;
2133
2042
  /**
2134
- * Extended spec diff result with docs impact
2043
+ * Extract Standard Schema from a TypeScript project.
2044
+ *
2045
+ * Convenience function that resolves compiled JS and extracts schemas.
2046
+ *
2047
+ * @param entryFile - TypeScript entry file path
2048
+ * @param baseDir - Project base directory
2049
+ * @param options - Extraction options
2135
2050
  */
2136
- interface SpecDiffWithDocs extends SpecDiff2 {
2137
- /** Docs impact analysis (only present if markdown files provided) */
2138
- docsImpact?: DocsImpactResult;
2139
- /** Member-level changes for classes (methods added/removed/changed) */
2140
- memberChanges?: MemberChange[];
2141
- /** Breaking changes categorized by severity (high/medium/low) */
2142
- categorizedBreaking?: CategorizedBreaking[];
2051
+ declare function extractStandardSchemasFromProject(entryFile: string, baseDir: string, options?: ExtractStandardSchemasOptions): Promise<StandardSchemaExtractionOutput>;
2052
+ declare function extractPackageSpec(entryFile: string, packageDir?: string, content?: string, options?: DocCovOptions): Promise<OpenPkgSpec>;
2053
+ interface SchemaDetectionContext {
2054
+ baseDir: string;
2055
+ entryFile: string;
2056
+ }
2057
+ interface DetectedSchema {
2058
+ schema: Record<string, unknown>;
2059
+ vendor: string;
2143
2060
  }
2061
+ interface SchemaDetectionResult {
2062
+ schemas: Map<string, DetectedSchema>;
2063
+ errors: string[];
2064
+ /** Warning when runtime was requested but compiled JS not found */
2065
+ noCompiledJsWarning?: boolean;
2066
+ }
2067
+ declare function detectRuntimeSchemas(context: SchemaDetectionContext): Promise<SchemaDetectionResult>;
2068
+ import { OpenPkg as OpenPkg9 } from "@openpkg-ts/spec";
2144
2069
  /**
2145
- * Options for diffSpecWithDocs
2070
+ * Parsed components of a GitHub URL.
2146
2071
  */
2147
- interface DiffWithDocsOptions {
2148
- /** Parsed markdown documentation files */
2149
- markdownFiles?: MarkdownDocFile[];
2072
+ interface ParsedGitHubUrl {
2073
+ /** Repository owner (user or org) */
2074
+ owner: string;
2075
+ /** Repository name */
2076
+ repo: string;
2077
+ /** Git ref (branch or tag) */
2078
+ ref: string;
2150
2079
  }
2151
2080
  /**
2152
- * Compute spec diff with optional docs impact analysis
2081
+ * Parse a GitHub URL or shorthand into components.
2153
2082
  *
2154
- * @param oldSpec - Previous version of the spec
2155
- * @param newSpec - Current version of the spec
2156
- * @param options - Options including markdown files to analyze
2157
- * @returns Extended diff result with docs impact
2083
+ * Supported formats:
2084
+ * - https://github.com/owner/repo
2085
+ * - https://github.com/owner/repo/tree/branch
2086
+ * - https://github.com/owner/repo/tree/v1.0.0
2087
+ * - github.com/owner/repo
2088
+ * - owner/repo (shorthand)
2089
+ * - git@github.com:owner/repo.git
2090
+ *
2091
+ * @param input - GitHub URL or shorthand
2092
+ * @param defaultRef - Default ref if not specified in URL (default: 'main')
2093
+ * @returns Parsed components
2094
+ * @throws Error if the URL format is invalid
2158
2095
  *
2159
2096
  * @example
2160
- * ```ts
2161
- * import { diffSpecWithDocs, parseMarkdownFiles } from '@doccov/sdk';
2162
- * import type { OpenPkg } from '@openpkg-ts/spec';
2097
+ * ```typescript
2098
+ * import { parseGitHubUrl } from '@doccov/sdk';
2163
2099
  *
2164
- * const oldSpec: OpenPkg = { openpkg: '0.2.0', meta: { name: 'my-pkg' }, exports: [] };
2165
- * const newSpec: OpenPkg = { openpkg: '0.2.1', meta: { name: 'my-pkg' }, exports: [] };
2100
+ * const parsed = parseGitHubUrl('https://github.com/vercel/next.js/tree/canary');
2101
+ * // { owner: 'vercel', repo: 'next.js', ref: 'canary' }
2166
2102
  *
2167
- * const markdownFiles = parseMarkdownFiles([
2168
- * { path: 'docs/guide.md', content: '...' },
2169
- * ]);
2103
+ * const shorthand = parseGitHubUrl('vercel/next.js');
2104
+ * // { owner: 'vercel', repo: 'next.js', ref: 'main' }
2105
+ * ```
2106
+ */
2107
+ declare function parseGitHubUrl(input: string, defaultRef?: string): ParsedGitHubUrl;
2108
+ /**
2109
+ * Build a clone URL from parsed components.
2170
2110
  *
2171
- * const diff = diffSpecWithDocs(oldSpec, newSpec, { markdownFiles });
2111
+ * @param parsed - Parsed GitHub URL components
2112
+ * @returns HTTPS clone URL
2172
2113
  *
2173
- * if (diff.docsImpact?.impactedFiles.length) {
2174
- * console.log('Docs need updating!');
2114
+ * @example
2115
+ * ```typescript
2116
+ * const cloneUrl = buildCloneUrl({ owner: 'vercel', repo: 'next.js', ref: 'main' });
2117
+ * // 'https://github.com/vercel/next.js.git'
2118
+ * ```
2119
+ */
2120
+ declare function buildCloneUrl(parsed: ParsedGitHubUrl): string;
2121
+ /**
2122
+ * Build a display-friendly URL (without protocol or .git suffix).
2123
+ *
2124
+ * @param parsed - Parsed GitHub URL components
2125
+ * @returns Display URL like 'github.com/owner/repo'
2126
+ *
2127
+ * @example
2128
+ * ```typescript
2129
+ * const displayUrl = buildDisplayUrl({ owner: 'vercel', repo: 'next.js', ref: 'main' });
2130
+ * // 'github.com/vercel/next.js'
2131
+ * ```
2132
+ */
2133
+ declare function buildDisplayUrl(parsed: ParsedGitHubUrl): string;
2134
+ /**
2135
+ * Build a raw.githubusercontent.com URL for a file.
2136
+ *
2137
+ * @param parsed - Parsed GitHub URL components
2138
+ * @param filePath - Path to the file in the repo
2139
+ * @returns Raw content URL
2140
+ */
2141
+ declare function buildRawUrl(parsed: ParsedGitHubUrl, filePath: string): string;
2142
+ /**
2143
+ * Fetch an OpenPkg spec from a GitHub repository.
2144
+ *
2145
+ * Tries the specified ref first, then falls back to 'master' if not found.
2146
+ *
2147
+ * @param parsed - Parsed GitHub URL components
2148
+ * @returns The OpenPkg spec, or null if not found
2149
+ *
2150
+ * @example
2151
+ * ```typescript
2152
+ * import { parseGitHubUrl, fetchSpecFromGitHub } from '@doccov/sdk';
2153
+ *
2154
+ * const parsed = parseGitHubUrl('vercel/next.js');
2155
+ * const spec = await fetchSpecFromGitHub(parsed);
2156
+ * if (spec) {
2157
+ * console.log(`Coverage: ${spec.docs?.coverageScore}%`);
2175
2158
  * }
2176
2159
  * ```
2177
2160
  */
2178
- declare function diffSpecWithDocs(oldSpec: OpenPkg9, newSpec: OpenPkg9, options?: DiffWithDocsOptions): SpecDiffWithDocs;
2161
+ declare function fetchSpecFromGitHub(parsed: ParsedGitHubUrl): Promise<OpenPkg9 | null>;
2179
2162
  /**
2180
- * Check if a diff has any docs impact
2163
+ * Options for fetching a spec from GitHub.
2181
2164
  */
2182
- declare function hasDocsImpact(diff: SpecDiffWithDocs): boolean;
2165
+ interface FetchSpecOptions {
2166
+ /** Git ref (branch or tag). Default: 'main' */
2167
+ ref?: string;
2168
+ /** Path to openpkg.json (for monorepos). Default: 'openpkg.json' */
2169
+ path?: string;
2170
+ }
2183
2171
  /**
2184
- * Get summary of docs impact for display
2172
+ * Fetch an OpenPkg spec from a GitHub repository by owner/repo/branch.
2173
+ *
2174
+ * Convenience function that creates ParsedGitHubUrl internally.
2175
+ *
2176
+ * @param owner - Repository owner
2177
+ * @param repo - Repository name
2178
+ * @param branchOrOptions - Branch name (default: 'main') or options object
2179
+ * @returns The OpenPkg spec, or null if not found
2185
2180
  */
2186
- declare function getDocsImpactSummary(diff: SpecDiffWithDocs): {
2187
- impactedFileCount: number;
2188
- impactedReferenceCount: number;
2189
- missingDocsCount: number;
2190
- totalIssues: number;
2191
- memberChangesCount: number;
2192
- };
2181
+ declare function fetchSpec(owner: string, repo: string, branchOrOptions?: string | FetchSpecOptions): Promise<OpenPkg9 | null>;
2193
2182
  /**
2194
- * Extract import statements from code (legacy interface).
2195
- * @deprecated Use extractImportsAST for more detailed info.
2183
+ * Progress event for installation status updates.
2196
2184
  */
2197
- declare function extractImports(code: string): Array<{
2198
- name: string;
2199
- from: string;
2200
- }>;
2185
+ interface InstallProgressEvent {
2186
+ /** Current stage */
2187
+ stage: "installing";
2188
+ /** Human-readable message */
2189
+ message: string;
2190
+ /** Progress percentage (0-100), if known */
2191
+ progress?: number;
2192
+ }
2201
2193
  /**
2202
- * Extract function calls from code (legacy interface).
2203
- * @deprecated Use extractCallsAST for more detailed info.
2194
+ * Callback for receiving installation progress events.
2204
2195
  */
2205
- declare function extractFunctionCalls(code: string): string[];
2206
- /** Options for parsing markdown files */
2207
- interface ParseOptions {
2208
- /** Custom set of executable language tags */
2209
- executableLangs?: string[];
2196
+ type InstallProgressCallback = (event: InstallProgressEvent) => void;
2197
+ /**
2198
+ * Result of running a command.
2199
+ */
2200
+ interface CommandResult {
2201
+ /** Exit code (0 = success) */
2202
+ exitCode: number;
2203
+ /** Standard output */
2204
+ stdout: string;
2205
+ /** Standard error */
2206
+ stderr: string;
2210
2207
  }
2211
2208
  /**
2212
- * Check if a language tag represents executable code
2209
+ * Function that runs a shell command.
2210
+ * Abstracts the difference between Node.js execSync and Sandbox runCommand.
2213
2211
  */
2214
- declare function isExecutableLang(lang: string | null | undefined, customLangs?: Set<string>): boolean;
2212
+ type CommandRunner = (cmd: string, args: string[], options: {
2213
+ cwd: string;
2214
+ timeout?: number;
2215
+ }) => Promise<CommandResult>;
2215
2216
  /**
2216
- * Parse a markdown file and extract code blocks
2217
+ * Result of dependency installation.
2217
2218
  */
2218
- declare function parseMarkdownFile(content: string, filePath: string, options?: ParseOptions): MarkdownDocFile;
2219
+ interface InstallResult {
2220
+ /** Whether installation succeeded */
2221
+ success: boolean;
2222
+ /** Package manager that was used */
2223
+ packageManager: PackageManager;
2224
+ /** If a fallback was used, which one */
2225
+ fallbackUsed?: PackageManager;
2226
+ /** Error message if installation failed */
2227
+ error?: string;
2228
+ /** Detailed error messages from each attempt */
2229
+ errors?: string[];
2230
+ }
2219
2231
  /**
2220
- * Parse multiple markdown files
2232
+ * Options for dependency installation.
2221
2233
  */
2222
- declare function parseMarkdownFiles(files: Array<{
2223
- path: string;
2224
- content: string;
2225
- }>, options?: ParseOptions): MarkdownDocFile[];
2234
+ interface InstallOptions {
2235
+ /** Timeout in milliseconds for install commands (default: 180000) */
2236
+ timeout?: number;
2237
+ /** Order of fallback package managers to try */
2238
+ fallbackOrder?: PackageManager[];
2239
+ /** Progress callback for status updates */
2240
+ onProgress?: InstallProgressCallback;
2241
+ }
2226
2242
  /**
2227
- * Find all references to given names in markdown files
2243
+ * Install dependencies for a project.
2244
+ *
2245
+ * This consolidates the install logic from CLI scan.ts and API scan-stream.ts:
2246
+ * 1. Detect package manager from lockfile
2247
+ * 2. Try primary install command
2248
+ * 3. Fall back to other package managers if primary fails
2249
+ *
2250
+ * @param fs - FileSystem implementation for package manager detection
2251
+ * @param cwd - Working directory to install in
2252
+ * @param runCommand - Function to run shell commands
2253
+ * @param options - Installation options
2254
+ * @returns Result of the installation attempt
2255
+ *
2256
+ * @example
2257
+ * ```typescript
2258
+ * import { NodeFileSystem, installDependencies, createNodeCommandRunner } from '@doccov/sdk';
2259
+ *
2260
+ * const fs = new NodeFileSystem('/path/to/repo');
2261
+ * const result = await installDependencies(fs, '/path/to/repo', createNodeCommandRunner());
2262
+ *
2263
+ * if (result.success) {
2264
+ * console.log(`Installed using ${result.packageManager}`);
2265
+ * } else {
2266
+ * console.error(`Install failed: ${result.error}`);
2267
+ * }
2268
+ * ```
2228
2269
  */
2229
- declare function findExportReferences(files: MarkdownDocFile[], exportNames: string[]): ExportReference[];
2270
+ declare function installDependencies(fs: FileSystem, cwd: string, runCommand: CommandRunner, options?: InstallOptions): Promise<InstallResult>;
2230
2271
  /**
2231
- * Check if a code block references any of the given names
2272
+ * Create a command runner for Node.js environments using execSync.
2273
+ * This is used by the CLI for local dependency installation.
2274
+ *
2275
+ * @returns CommandRunner that uses child_process.execSync
2276
+ *
2277
+ * @example
2278
+ * ```typescript
2279
+ * const runner = createNodeCommandRunner();
2280
+ * const result = await runner('npm', ['install'], { cwd: '/path/to/repo' });
2281
+ * ```
2232
2282
  */
2233
- declare function blockReferencesExport(block: MarkdownCodeBlock, exportName: string): boolean;
2234
- import { EntryPointDetectionMethod } from "@openpkg-ts/spec";
2283
+ declare function createNodeCommandRunner(): CommandRunner;
2235
2284
  /**
2236
- * Input for generation metadata that comes from the caller (CLI, API, etc.)
2285
+ * Source of filter options.
2237
2286
  */
2238
- interface GenerationInput {
2239
- /** Entry point file path (relative to package root) */
2240
- entryPoint: string;
2241
- /** How the entry point was detected */
2242
- entryPointSource: EntryPointDetectionMethod;
2243
- /** Whether this is a declaration-only analysis (.d.ts file) */
2244
- isDeclarationOnly?: boolean;
2245
- /** Generator tool name */
2246
- generatorName: string;
2247
- /** Generator tool version */
2248
- generatorVersion: string;
2249
- /** Detected package manager */
2250
- packageManager?: string;
2251
- /** Whether this is a monorepo */
2252
- isMonorepo?: boolean;
2253
- /** Target package name (for monorepos) */
2254
- targetPackage?: string;
2255
- }
2256
- interface Diagnostic2 {
2257
- message: string;
2258
- severity: "error" | "warning" | "info";
2259
- suggestion?: string;
2260
- location?: {
2261
- file: string;
2262
- line?: number;
2263
- column?: number;
2264
- };
2265
- }
2266
- interface AnalysisResult {
2267
- spec: OpenPkgSpec;
2268
- diagnostics: Diagnostic2[];
2269
- metadata: AnalysisMetadata;
2270
- /** True if result came from cache (no fresh analysis) */
2271
- fromCache?: boolean;
2272
- /** Cache validation details (if cache was checked) */
2273
- cacheStatus?: CacheValidationResult;
2274
- }
2275
- interface AnalysisMetadata {
2276
- baseDir: string;
2277
- configPath?: string;
2278
- packageJsonPath?: string;
2279
- hasNodeModules: boolean;
2280
- resolveExternalTypes: boolean;
2281
- /** Source files included in analysis (for caching) */
2282
- sourceFiles?: string[];
2283
- }
2284
- interface AnalyzeOptions {
2285
- filters?: FilterOptions;
2286
- /** Generation metadata input (entry point info, tool version, etc.) */
2287
- generationInput?: GenerationInput;
2288
- }
2289
- declare class DocCov {
2290
- private readonly options;
2291
- constructor(options?: DocCovOptions);
2292
- analyze(code: string, fileName?: string, analyzeOptions?: AnalyzeOptions): Promise<OpenPkgSpec>;
2293
- analyzeFile(filePath: string, analyzeOptions?: AnalyzeOptions): Promise<OpenPkgSpec>;
2294
- analyzeProject(entryPath: string, analyzeOptions?: AnalyzeOptions): Promise<OpenPkgSpec>;
2295
- analyzeWithDiagnostics(code: string, fileName?: string, analyzeOptions?: AnalyzeOptions): Promise<AnalysisResult>;
2296
- analyzeFileWithDiagnostics(filePath: string, analyzeOptions?: AnalyzeOptions): Promise<AnalysisResult>;
2297
- /**
2298
- * Try to load spec from cache.
2299
- * Returns null if cache is invalid or doesn't exist.
2300
- */
2301
- private tryLoadFromCache;
2302
- /**
2303
- * Get current source files from a fresh TypeScript program.
2304
- * Used for cache validation to detect new files.
2305
- */
2306
- private getCurrentSourceFiles;
2307
- /**
2308
- * Save analysis result to cache.
2309
- */
2310
- private saveToCache;
2311
- /**
2312
- * Find tsconfig.json starting from a directory.
2313
- */
2314
- private findTsConfig;
2315
- /**
2316
- * Find package.json starting from a directory.
2317
- */
2318
- private findPackageJson;
2319
- /**
2320
- * Detect Standard Schema exports from compiled modules.
2321
- * Only runs when schemaExtraction is 'runtime' or 'hybrid'.
2322
- * Returns undefined if detection is disabled, fails, or no schemas found.
2323
- */
2324
- private detectSchemas;
2325
- private normalizeDiagnostic;
2326
- private mapSeverity;
2327
- private normalizeMetadata;
2328
- private applySpecFilters;
2329
- }
2330
- declare function analyze(code: string, options?: AnalyzeOptions): Promise<OpenPkgSpec>;
2331
- declare function analyzeFile(filePath: string, options?: AnalyzeOptions): Promise<OpenPkgSpec>;
2287
+ type FilterSource = "config" | "override" | "combined";
2332
2288
  /**
2333
- * Options for resolving a target package/entry point.
2289
+ * Resolved filter options after merging config and overrides.
2334
2290
  */
2335
- interface ResolveTargetOptions {
2336
- /** Working directory (usually process.cwd()) */
2337
- cwd: string;
2338
- /** Target package name for monorepos */
2339
- package?: string;
2340
- /** Explicit entry point path (relative to cwd or package dir) */
2341
- entry?: string;
2291
+ interface ResolvedFilters {
2292
+ /** Include patterns */
2293
+ include?: string[];
2294
+ /** Exclude patterns */
2295
+ exclude?: string[];
2296
+ /** Source of the filters */
2297
+ source?: FilterSource;
2298
+ /** Whether filters were applied from config */
2299
+ fromConfig: boolean;
2300
+ /** Whether filters were applied from overrides */
2301
+ fromOverride: boolean;
2342
2302
  }
2343
2303
  /**
2344
- * Result of resolving a target package/entry point.
2304
+ * Parse a comma-separated list flag into an array.
2305
+ *
2306
+ * @param value - String or string array from CLI flag
2307
+ * @returns Parsed array, or undefined if empty
2308
+ *
2309
+ * @example
2310
+ * ```typescript
2311
+ * parseListFlag('a,b,c'); // ['a', 'b', 'c']
2312
+ * parseListFlag(['a,b', 'c']); // ['a', 'b', 'c']
2313
+ * parseListFlag(undefined); // undefined
2314
+ * ```
2345
2315
  */
2346
- interface ResolvedTarget {
2347
- /** Resolved directory containing the package */
2348
- targetDir: string;
2349
- /** Resolved entry point file path (absolute) */
2350
- entryFile: string;
2351
- /** Package info if this is a monorepo package */
2352
- packageInfo?: WorkspacePackage;
2353
- /** Entry point detection info */
2354
- entryPointInfo: EntryPointInfo;
2355
- }
2316
+ declare function parseListFlag(value?: string | string[]): string[] | undefined;
2356
2317
  /**
2357
- * Resolve a target package and entry point.
2318
+ * Merge filter options from config and CLI/API overrides.
2358
2319
  *
2359
- * This consolidates the repeated pattern from CLI commands:
2360
- * 1. If --package specified, detect monorepo and find the package
2361
- * 2. If no entry specified, auto-detect entry point
2362
- * 3. If entry is a directory, detect entry point within it
2320
+ * Merge behavior:
2321
+ * - Include: CLI values intersect with config values (narrowing)
2322
+ * - Exclude: CLI values are added to config values (expanding)
2363
2323
  *
2364
- * @param fs - FileSystem implementation (NodeFileSystem or SandboxFileSystem)
2365
- * @param options - Resolution options
2366
- * @returns Resolved target info
2367
- * @throws Error if monorepo package not found, or entry point detection fails
2324
+ * @param config - Configuration (from doccov.config.ts)
2325
+ * @param overrides - Override filters (from CLI flags or API params)
2326
+ * @returns Merged filter options
2368
2327
  *
2369
2328
  * @example
2370
2329
  * ```typescript
2371
- * import { NodeFileSystem, resolveTarget } from '@doccov/sdk';
2372
- *
2373
- * // Simple usage
2374
- * const fs = new NodeFileSystem(process.cwd());
2375
- * const { targetDir, entryFile } = await resolveTarget(fs, { cwd: process.cwd() });
2330
+ * const config = { include: ['A', 'B', 'C'] };
2331
+ * const overrides = { include: ['B', 'C', 'D'] };
2376
2332
  *
2377
- * // With monorepo package
2378
- * const { targetDir, entryFile, packageInfo } = await resolveTarget(fs, {
2379
- * cwd: process.cwd(),
2380
- * package: '@myorg/core',
2381
- * });
2333
+ * const resolved = mergeFilters(config, overrides);
2334
+ * // resolved.include = ['B', 'C'] (intersection)
2382
2335
  * ```
2383
2336
  */
2384
- declare function resolveTarget(fs: FileSystem, options: ResolveTargetOptions): Promise<ResolvedTarget>;
2337
+ declare function mergeFilters(config: DocCovConfig | null, overrides: FilterOptions): ResolvedFilters;
2385
2338
  /**
2386
2339
  * Repository metadata from GitHub API.
2387
2340
  */
@@ -2623,12 +2576,4 @@ interface BuildPlanExecutionResult {
2623
2576
  /** Overall error message if failed */
2624
2577
  error?: string;
2625
2578
  }
2626
- /**
2627
- * Type-check a single example
2628
- */
2629
- declare function typecheckExample(example: string, packagePath: string, options?: TypecheckOptions): ExampleTypeError[];
2630
- /**
2631
- * Type-check multiple examples
2632
- */
2633
- declare function typecheckExamples(examples: string[], packagePath: string, options?: TypecheckOptions): TypecheckResult;
2634
- export { validateSpecCache, validateExamples, typecheckExamples, typecheckExample, shouldValidate, serializeJSDoc, saveSpecCache, saveSnapshot, saveReport, safeParseJson, runExamplesWithPackage, runExamples, runExample, resolveTarget, resolveCompiledPath, renderSparkline, renderApiSurface, readPackageJson, pruneHistory, pruneByTier, parseGitHubUrl2 as parseScanGitHubUrl, parseMarkdownFiles, parseMarkdownFile, parseListFlag, parseJSDocToPatch, parseGitHubUrl, parseExamplesFlag, parseAssertions, mergeFixes, mergeFilters, loadSpecCache, loadSnapshotsForDays, loadSnapshots, loadCachedReport, listWorkspacePackages, isStandardJSONSchema, isSchemaType, isFixableDrift, isExecutableLang, isCachedReportValid, installDependencies, hashString, hashFiles, hashFile, hasNonAssertionComments, hasDocsImpact, hasDocsForExport, groupDriftsByCategory, getUndocumentedExports, getTrend, getSupportedLibraries, getSpecCachePath, getRunCommand, getReportPath, getRegisteredAdapters, getPrimaryBuildScript, getInstallCommand, getExtendedTrend, getDriftSummary, getDocumentedExports, getDocsImpactSummary, getDiffReportPath, generateWeeklySummaries, generateReportFromEnriched, generateReport, generateFixesForExport, generateFix, formatPackageList, formatDriftSummaryLine, formatDelta, findRemovedReferences, findPackageByName, findJSDocLocation, findExportReferences, findDeprecatedReferences, findAdapter, fetchSpecFromGitHub, fetchSpec, fetchGitHubContext, extractStandardSchemasFromProject, extractStandardSchemas, extractSpecSummary, extractSchemaType, extractSchemaOutputType, extractPackageSpec, extractImports, extractFunctionCalls, ensureSpecCoverage, enrichSpec, diffSpecWithDocs, diffHashes, detectRuntimeSchemas, detectPackageManager, detectMonorepo, detectExampleRuntimeErrors, detectExampleAssertionFailures, detectEntryPoint, detectBuildInfo, defineConfig, createSourceFile, createNodeCommandRunner, computeSnapshot, computeExportDrift, computeDrift, clearSpecCache, clearSchemaCache, categorizeDrifts, categorizeDrift, calculateAggregateCoverage, buildRawUrl, buildExportRegistry, buildDisplayUrl, buildCloneUrl, blockReferencesExport, applyPatchToJSDoc, applyEdits, analyzeProject2 as analyzeProject, analyzeFile, analyzeDocsImpact, analyze, WorkspacePackage, WorkspaceConfig, WeeklySummary, VALIDATION_INFO, TypecheckValidationResult, TypecheckResult, TypecheckOptions, SummaryDriftIssue, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, SpecSummary, SpecDiffWithDocs, SpecCacheConfig, SpecCache, SchemaExtractionResult, SchemaExtractionMode, SchemaDetectionResult, SchemaDetectionContext, SchemaAdapter, SandboxFileSystem, SPEC_CACHE_FILE, RuntimeDrift, RunValidationResult, RunExamplesWithPackageResult, RunExamplesWithPackageOptions, RunExampleOptions, RetentionTier, ResolvedTarget, ResolvedFilters, ResolveTargetOptions, ReleaseTag, RETENTION_DAYS, REPORT_VERSION, REPORT_EXTENSIONS, ProjectInfo, PresenceResult, ParsedGitHubUrl, PackageManagerInfo, PackageManager, PackageJson, PackageExports, OpenPkgSpec, NodeFileSystem, MonorepoType, MonorepoInfo, MemberChange, MarkdownDocFile, MarkdownCodeBlock, LLMAssertion, JSDocTag, JSDocReturn, JSDocPatch, JSDocParam, JSDocEdit, InstallResult, InstallOptions, HISTORY_DIR, GitHubRepoMetadata, GitHubProjectContext, FixType, FixSuggestion, FilterSource, FilterOptions, FileSystem, FetchGitHubContextOptions, ExtractStandardSchemasOptions, ExtendedTrendAnalysis, ExportReference, ExportDriftResult, ExportCoverageData, ExampleValidationTypeError, ExampleValidationResult, ExampleValidationOptions, ExampleValidationMode, ExampleValidation, ExampleTypeError, ExampleRunResult, EntryPointSource, EntryPointInfo, EnrichedOpenPkg, EnrichedExport, EnrichedDocsMetadata, EnrichOptions, DriftSummary, DriftResult, DriftReportSummary, DriftReport, DocsImpactResult, DocsImpactReference, DocsImpact, DocsConfig, DocsChangeType, DocCovReport, DocCovOptions, DocCovConfig, DocCov, DiffWithDocsOptions, Diagnostic2 as Diagnostic, DetectedSchemaEntry, DetectedPackageManager, DEFAULT_REPORT_PATH, DEFAULT_REPORT_DIR, CoverageTrend, CoverageSummary, CoverageSnapshot, CommandRunner, CommandResult, CheckConfig, CategorizedDrift, CacheValidationResult, CacheContext, CACHE_VERSION, BuildPlanTarget, BuildPlanStepResult, BuildPlanStep, BuildPlanExecutionResult, BuildPlanEnvironment, BuildPlan, BuildInfo, BuildHints, ApplyEditsResult, AnalyzeProjectOptions, AnalyzeOptions, AnalysisResult, ALL_VALIDATIONS };
2579
+ export { validateSpecCache, validateExamples, typecheckExamples, typecheckExample, shouldValidate, serializeJSDoc, saveSpecCache, saveSnapshot, saveReport, safeParseJson, runExamplesWithPackage, runExamples, runExample, resolveTarget, resolveCompiledPath, renderSparkline, readPackageJson, pruneHistory, parseGitHubUrl2 as parseScanGitHubUrl, parseMarkdownFiles, parseMarkdownFile, parseListFlag, parseJSDocToPatch, parseGitHubUrl, parseExamplesFlag, parseAssertions, mergeFixes, mergeFilters, loadSpecCache, loadSnapshots, loadCachedReport, listWorkspacePackages, isStandardJSONSchema, isSchemaType, isFixableDrift, isExecutableLang, installDependencies, hashString, hashFiles, hashFile, hasNonAssertionComments, hasDocsImpact, hasDocsForExport, groupDriftsByCategory, getUndocumentedExports, getTrend, getSupportedLibraries, getSpecCachePath, getRunCommand, getReportPath, getRegisteredAdapters, getPrimaryBuildScript, getInstallCommand, getExtendedTrend, getDriftSummary, getDocumentedExports, getDocsImpactSummary, getDiffReportPath, generateReportFromEnriched, generateReport, generateFixesForExport, generateFix, formatPackageList, formatDriftSummaryLine, formatDelta, findRemovedReferences, findPackageByName, findJSDocLocation, findExportReferences, findDeprecatedReferences, findAdapter, fetchSpecFromGitHub, fetchSpec, fetchGitHubContext, extractStandardSchemasFromProject, extractStandardSchemas, extractSpecSummary, extractSchemaType, extractSchemaOutputType, extractPackageSpec, extractImports, extractFunctionCalls, ensureSpecCoverage, enrichSpec, diffSpecWithDocs, diffHashes, detectRuntimeSchemas, detectPackageManager, detectMonorepo, detectExampleRuntimeErrors, detectExampleAssertionFailures, detectEntryPoint, detectBuildInfo, defineConfig, createSourceFile, createNodeCommandRunner, computeSnapshot, computeExportDrift, computeDrift, clearSpecCache, categorizeDrifts, categorizeDrift, calculateAggregateCoverage, buildRawUrl, buildExportRegistry, buildDisplayUrl, buildCloneUrl, blockReferencesExport, applyPatchToJSDoc, applyEdits, analyzeProject2 as analyzeProject, analyzeFile, analyzeDocsImpact, analyze, WorkspacePackage, WorkspaceConfig, VALIDATION_INFO, TypecheckValidationResult, TypecheckResult, TypecheckOptions, SummaryDriftIssue, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, SpecSummary, SpecDiffWithDocs, SpecCacheConfig, SpecCache, SchemaExtractionResult, SchemaExtractionMode, SchemaDetectionResult, SchemaDetectionContext, SchemaAdapter, SandboxFileSystem, SPEC_CACHE_FILE, RuntimeDrift, RunValidationResult, RunExamplesWithPackageResult, RunExamplesWithPackageOptions, RunExampleOptions, ResolvedTarget, ResolvedFilters, ResolveTargetOptions, ReleaseTag, RETENTION_DAYS, REPORT_VERSION, REPORT_EXTENSIONS, ProjectInfo, PresenceResult, ParsedGitHubUrl, PackageManagerInfo, PackageManager, PackageJson, PackageExports, OpenPkgSpec, NodeFileSystem, MonorepoType, MonorepoInfo, MemberChange, MarkdownDocFile, MarkdownCodeBlock, LLMAssertion, JSDocTag, JSDocReturn, JSDocPatch, JSDocParam, JSDocEdit, InstallResult, InstallOptions, HISTORY_DIR, GitHubRepoMetadata, GitHubProjectContext, FixType, FixSuggestion, FilterSource, FilterOptions, FileSystem, FetchGitHubContextOptions, ExtractStandardSchemasOptions, ExtendedTrendAnalysis, ExportReference, ExportDriftResult, ExportCoverageData, ExampleValidationTypeError, ExampleValidationResult, ExampleValidationOptions, ExampleValidationMode, ExampleValidation, ExampleTypeError, ExampleRunResult, EntryPointSource, EntryPointInfo, EnrichedOpenPkg, EnrichedExport, EnrichedDocsMetadata, EnrichOptions, DriftSummary, DriftResult, DriftReportSummary, DriftReport, DocsImpactResult, DocsImpactReference, DocsImpact, DocsConfig, DocsChangeType, DocCovReport, DocCovOptions, DocCovConfig, DocCov, DiffWithDocsOptions, Diagnostic2 as Diagnostic, DetectedSchemaEntry, DetectedPackageManager, DEFAULT_REPORT_PATH, DEFAULT_REPORT_DIR, CoverageTrend, CoverageSummary, CoverageSnapshot, CommandRunner, CommandResult, CheckConfig, CategorizedDrift, CacheValidationResult, CacheContext, CACHE_VERSION, BuildPlanTarget, BuildPlanStepResult, BuildPlanStep, BuildPlanExecutionResult, BuildPlanEnvironment, BuildPlan, BuildInfo, BuildHints, ApplyEditsResult, AnalyzeProjectOptions, AnalyzeOptions, AnalysisResult, ALL_VALIDATIONS };